@jm-7c3/common-lib 1.7.2

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.
Files changed (52) hide show
  1. package/README.md +9 -0
  2. package/fesm2022/jm-7c3-common-lib.mjs +956 -0
  3. package/fesm2022/jm-7c3-common-lib.mjs.map +1 -0
  4. package/index.d.ts +5 -0
  5. package/jm-7c3-common-lib-1.7.2.tgz +0 -0
  6. package/lib/common-lib.module.d.ts +6 -0
  7. package/lib/controls/button/button.component.d.ts +14 -0
  8. package/lib/controls/button/button.models.d.ts +1 -0
  9. package/lib/controls/button/index.d.ts +1 -0
  10. package/lib/controls/confirmation/confirmation.component.d.ts +12 -0
  11. package/lib/controls/confirmation/confirmation.models.d.ts +7 -0
  12. package/lib/controls/confirmation/confirmation.service.d.ts +11 -0
  13. package/lib/controls/confirmation/index.d.ts +3 -0
  14. package/lib/controls/content-dialog/content-dialog.component.d.ts +15 -0
  15. package/lib/controls/content-dialog/content-dialog.models.d.ts +10 -0
  16. package/lib/controls/content-dialog/content-dialog.service.d.ts +13 -0
  17. package/lib/controls/content-dialog/index.d.ts +3 -0
  18. package/lib/controls/form-dialog/form-dialog.component.d.ts +21 -0
  19. package/lib/controls/form-dialog/form-dialog.models.d.ts +13 -0
  20. package/lib/controls/form-dialog/form-dialog.service.d.ts +12 -0
  21. package/lib/controls/form-dialog/index.d.ts +3 -0
  22. package/lib/controls/icon-button/icon-button.component.d.ts +15 -0
  23. package/lib/controls/icon-button/index.d.ts +1 -0
  24. package/lib/controls/progress-bar-dialog/index.d.ts +2 -0
  25. package/lib/controls/progress-bar-dialog/progress-bar-dialog.component.d.ts +9 -0
  26. package/lib/controls/progress-bar-dialog/progress-bar-dialog.service.d.ts +8 -0
  27. package/lib/controls/readonly-value/index.d.ts +1 -0
  28. package/lib/controls/readonly-value/readonly-value.component.d.ts +7 -0
  29. package/lib/controls/toasts/index.d.ts +3 -0
  30. package/lib/controls/toasts/toasts.component.d.ts +9 -0
  31. package/lib/controls/toasts/toasts.models.d.ts +5 -0
  32. package/lib/controls/toasts/toasts.service.d.ts +9 -0
  33. package/lib/forms/base-form/base-form.component.d.ts +24 -0
  34. package/lib/forms/base-form/index.d.ts +1 -0
  35. package/lib/forms/file-input/file-input.component.d.ts +40 -0
  36. package/lib/forms/file-input/index.d.ts +1 -0
  37. package/lib/forms/file-inputs/file-inputs.component.d.ts +24 -0
  38. package/lib/forms/file-inputs/index.d.ts +1 -0
  39. package/lib/forms/form-field/error.directive.d.ts +7 -0
  40. package/lib/forms/form-field/form-field.component.d.ts +10 -0
  41. package/lib/forms/form-field/form-field.module.d.ts +9 -0
  42. package/lib/forms/form-field/index.d.ts +4 -0
  43. package/lib/forms/form-field/label.directive.d.ts +7 -0
  44. package/lib/models/cl-dialog.model.d.ts +15 -0
  45. package/lib/models/cl-state.model.d.ts +9 -0
  46. package/lib/models/index.d.ts +2 -0
  47. package/lib/rxjs-operators/index.d.ts +1 -0
  48. package/lib/rxjs-operators/operators.d.ts +2 -0
  49. package/lib/services/cl-state.service.d.ts +12 -0
  50. package/lib/services/index.d.ts +1 -0
  51. package/package.json +29 -0
  52. package/public-api.d.ts +16 -0
@@ -0,0 +1,956 @@
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';
3
+ import * as i1$2 from '@angular/common';
4
+ import { CommonModule } from '@angular/common';
5
+ import * as i1 from 'primeng/button';
6
+ import { ButtonModule } from 'primeng/button';
7
+ import * as i2 from 'primeng/api';
8
+ import { ConfirmationService as ConfirmationService$1, MessageService } from 'primeng/api';
9
+ import * as i1$1 from 'primeng/confirmdialog';
10
+ import { ConfirmDialogModule } from 'primeng/confirmdialog';
11
+ import { toObservable } from '@angular/core/rxjs-interop';
12
+ import { signalState, patchState } from '@ngrx/signals';
13
+ import { filter, map, Subscription, concatWith, toArray } from 'rxjs';
14
+ import { DynamicDialogConfig, DynamicDialogRef, DialogService, DynamicDialogModule } from 'primeng/dynamicdialog';
15
+ import * as i2$2 from '@angular/forms';
16
+ import { FormsModule, ReactiveFormsModule, NG_VALUE_ACCESSOR, FormControl, Validators, FormArray, NG_VALIDATORS, FormControlName } from '@angular/forms';
17
+ import * as i1$3 from 'primeng/dialog';
18
+ import { DialogModule } from 'primeng/dialog';
19
+ import * as i2$1 from 'primeng/progressbar';
20
+ import { ProgressBarModule } from 'primeng/progressbar';
21
+ import * as i1$4 from 'primeng/toast';
22
+ import { ToastModule } from 'primeng/toast';
23
+ import { cloneDeep } from 'lodash-es';
24
+ import { v4 } from 'uuid';
25
+
26
+ class ButtonComponent {
27
+ color = input('primary');
28
+ disabled = input(false);
29
+ icon = input();
30
+ label = input();
31
+ loading = input(false);
32
+ type = input('button');
33
+ buttonClass = signal('');
34
+ constructor() {
35
+ effect(() => {
36
+ switch (this.color()) {
37
+ case 'danger':
38
+ this.buttonClass.set('p-button-danger p-button-raised p-button-text');
39
+ break;
40
+ case 'main':
41
+ this.buttonClass.set('p-button-primary p-button-raised');
42
+ break;
43
+ case 'primary':
44
+ this.buttonClass.set('p-button-primary p-button-raised p-button-text');
45
+ break;
46
+ case 'secondary':
47
+ this.buttonClass.set('p-button-secondary p-button-raised p-button-text');
48
+ break;
49
+ }
50
+ });
51
+ }
52
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
53
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.12", type: ButtonComponent, isStandalone: true, selector: "cl-button", inputs: { color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", 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 }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<button [class]=\"buttonClass()\" [disabled]=\"disabled()\" [icon]=\"icon()!\" [label]=\"label()!\" [loading]=\"loading()\" pButton\n [type]=\"type()\">\n</button>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: ButtonModule }, { kind: "directive", type: i1.ButtonDirective, selector: "[pButton]", inputs: ["iconPos", "loadingIcon", "loading", "severity", "raised", "rounded", "text", "outlined", "size", "plain", "fluid", "label", "icon", "buttonProps"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
54
+ }
55
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ButtonComponent, decorators: [{
56
+ type: Component,
57
+ args: [{ selector: 'cl-button', imports: [
58
+ CommonModule,
59
+ ButtonModule
60
+ ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<button [class]=\"buttonClass()\" [disabled]=\"disabled()\" [icon]=\"icon()!\" [label]=\"label()!\" [loading]=\"loading()\" pButton\n [type]=\"type()\">\n</button>\n" }]
61
+ }], ctorParameters: () => [] });
62
+
63
+ const initialState = {
64
+ stateMessage: null
65
+ };
66
+ class ClStateService {
67
+ state = signalState(initialState);
68
+ stateMessage = this.state.stateMessage;
69
+ stateMessage$ = toObservable(this.state.stateMessage);
70
+ onStateMessage(type) {
71
+ return this.stateMessage$.pipe(filter(message => message?.type === type));
72
+ }
73
+ updateStateMessage(stateMessage) {
74
+ patchState(this.state, { stateMessage });
75
+ }
76
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ClStateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
77
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ClStateService, providedIn: 'root' });
78
+ }
79
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ClStateService, decorators: [{
80
+ type: Injectable,
81
+ args: [{
82
+ providedIn: 'root'
83
+ }]
84
+ }] });
85
+
86
+ class ConfirmationComponent {
87
+ env;
88
+ clStateService = inject(ClStateService);
89
+ confirmationService = inject(ConfirmationService$1);
90
+ acceptLabel = signal('Accept');
91
+ cancelLabel = signal('Cancel');
92
+ constructor(env) {
93
+ this.env = env;
94
+ const confirmationConfig = this.env?.commonLib?.confirmation;
95
+ if (confirmationConfig) {
96
+ if (confirmationConfig.acceptLabel) {
97
+ this.acceptLabel.set(confirmationConfig.acceptLabel);
98
+ }
99
+ if (confirmationConfig.cancelLabel) {
100
+ this.cancelLabel.set(confirmationConfig.cancelLabel);
101
+ }
102
+ }
103
+ effect(() => {
104
+ const message = this.clStateService.stateMessage();
105
+ if (message?.type === 'confirmation') {
106
+ this.openConfirmDialog(message);
107
+ }
108
+ });
109
+ }
110
+ openConfirmDialog(stateMessge) {
111
+ const { data, header, key, message } = stateMessge.payload;
112
+ this.confirmationService.confirm({
113
+ accept: () => {
114
+ this.clStateService.updateStateMessage({
115
+ key: stateMessge.key,
116
+ payload: data,
117
+ type: 'confirmation-accept'
118
+ });
119
+ },
120
+ acceptButtonStyleClass: 'primary',
121
+ closeOnEscape: false,
122
+ header,
123
+ key,
124
+ message,
125
+ reject: () => {
126
+ this.clStateService.updateStateMessage({
127
+ key: stateMessge.key,
128
+ payload: data,
129
+ type: 'confirmation-cancel'
130
+ });
131
+ },
132
+ });
133
+ }
134
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ConfirmationComponent, deps: [{ token: 'env' }], target: i0.ɵɵFactoryTarget.Component });
135
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.12", type: ConfirmationComponent, isStandalone: true, selector: "cl-confirmation", ngImport: i0, template: "<p-confirmDialog #general key=\"general\">\n <ng-template pTemplate=\"footer\">\n <cl-button class=\"mr-2\" (click)=\"general.onAccept()\" color=\"primary\" icon=\"pi pi-check\" [label]=\"acceptLabel()\" />\n <cl-button (click)=\"general.onReject()\" color=\"secondary\" icon=\"pi pi-times\" [label]=\"cancelLabel()\" />\n </ng-template>\n</p-confirmDialog>\n\n<p-confirmDialog icon=\"pi pi-exclamation-triangle\" key=\"general-warning\" #warning>\n <ng-template pTemplate=\"footer\">\n <cl-button class=\"mr-2\" (click)=\"warning.onAccept()\" color=\"primary\" icon=\"pi pi-check\" [label]=\"acceptLabel()\" />\n <cl-button (click)=\"warning.onReject()\" color=\"secondary\" icon=\"pi pi-times\" [label]=\"cancelLabel()\" />\n </ng-template>\n</p-confirmDialog>\n", styles: [""], dependencies: [{ kind: "component", type: ButtonComponent, selector: "cl-button", inputs: ["color", "disabled", "icon", "label", "loading", "type"] }, { kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: ConfirmDialogModule }, { kind: "component", type: i1$1.ConfirmDialog, selector: "p-confirmDialog, p-confirmdialog, p-confirm-dialog", inputs: ["header", "icon", "message", "style", "styleClass", "maskStyleClass", "acceptIcon", "acceptLabel", "closeAriaLabel", "acceptAriaLabel", "acceptVisible", "rejectIcon", "rejectLabel", "rejectAriaLabel", "rejectVisible", "acceptButtonStyleClass", "rejectButtonStyleClass", "closeOnEscape", "dismissableMask", "blockScroll", "rtl", "closable", "appendTo", "key", "autoZIndex", "baseZIndex", "transitionOptions", "focusTrap", "defaultFocus", "breakpoints", "visible", "position", "draggable"], outputs: ["onHide"] }, { kind: "directive", type: i2.PrimeTemplate, selector: "[pTemplate]", inputs: ["type", "pTemplate"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
136
+ }
137
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ConfirmationComponent, decorators: [{
138
+ type: Component,
139
+ args: [{ selector: 'cl-confirmation', imports: [
140
+ ButtonComponent,
141
+ CommonModule,
142
+ ConfirmDialogModule,
143
+ ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<p-confirmDialog #general key=\"general\">\n <ng-template pTemplate=\"footer\">\n <cl-button class=\"mr-2\" (click)=\"general.onAccept()\" color=\"primary\" icon=\"pi pi-check\" [label]=\"acceptLabel()\" />\n <cl-button (click)=\"general.onReject()\" color=\"secondary\" icon=\"pi pi-times\" [label]=\"cancelLabel()\" />\n </ng-template>\n</p-confirmDialog>\n\n<p-confirmDialog icon=\"pi pi-exclamation-triangle\" key=\"general-warning\" #warning>\n <ng-template pTemplate=\"footer\">\n <cl-button class=\"mr-2\" (click)=\"warning.onAccept()\" color=\"primary\" icon=\"pi pi-check\" [label]=\"acceptLabel()\" />\n <cl-button (click)=\"warning.onReject()\" color=\"secondary\" icon=\"pi pi-times\" [label]=\"cancelLabel()\" />\n </ng-template>\n</p-confirmDialog>\n" }]
144
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
145
+ type: Inject,
146
+ args: ['env']
147
+ }] }] });
148
+
149
+ class ConfirmationService {
150
+ clStateService = inject(ClStateService);
151
+ confirm({ data, header, key, message, type }) {
152
+ const confirmationData = {
153
+ data,
154
+ header,
155
+ key: 'general',
156
+ message
157
+ };
158
+ switch (type) {
159
+ case 'warning':
160
+ confirmationData.key = 'general-warning';
161
+ break;
162
+ }
163
+ this.clStateService.updateStateMessage({
164
+ key,
165
+ payload: confirmationData,
166
+ type: 'confirmation'
167
+ });
168
+ }
169
+ onAccept(key) {
170
+ return this.clStateService.onStateMessage('confirmation-accept').pipe(filter(message => message?.key === key), map(message => message?.payload));
171
+ }
172
+ onCancel(key) {
173
+ return this.clStateService.onStateMessage('confirmation-cancel').pipe(filter(message => message?.key === key), map(() => null));
174
+ }
175
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ConfirmationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
176
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ConfirmationService, providedIn: 'root' });
177
+ }
178
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ConfirmationService, decorators: [{
179
+ type: Injectable,
180
+ args: [{
181
+ providedIn: 'root'
182
+ }]
183
+ }] });
184
+
185
+ class ContentDialogComponent {
186
+ env;
187
+ dialogConfig = inject(DynamicDialogConfig);
188
+ dialogRef = inject(DynamicDialogRef);
189
+ component = signal(null);
190
+ closeLabel = signal('Close');
191
+ header = signal('');
192
+ constructor(env) {
193
+ this.env = env;
194
+ const contentDialogConfig = this.env?.commonLib?.contentDialog;
195
+ if (contentDialogConfig) {
196
+ if (contentDialogConfig.closeLabel) {
197
+ this.closeLabel.set(contentDialogConfig.closeLabel);
198
+ }
199
+ }
200
+ }
201
+ ngOnInit() {
202
+ const { component, config, header } = this.dialogConfig.data;
203
+ if (component) {
204
+ this.component.set(component);
205
+ }
206
+ if (config) {
207
+ const { closeLabel } = config;
208
+ if (closeLabel) {
209
+ this.closeLabel.set(closeLabel);
210
+ }
211
+ }
212
+ if (header) {
213
+ this.header.set(header);
214
+ }
215
+ }
216
+ onClose() {
217
+ this.dialogRef.close();
218
+ }
219
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ContentDialogComponent, deps: [{ token: 'env' }], target: i0.ɵɵFactoryTarget.Component });
220
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.12", type: ContentDialogComponent, isStandalone: true, selector: "cl-content-dialog", ngImport: i0, template: "@if (component()) {\n <ng-container *ngComponentOutlet=\"component()\" />\n}\n\n<div class=\"text-right\">\n <cl-button (click)=\"onClose()\" color=\"secondary\" [label]=\"closeLabel()\" />\n</div>\n", styles: [""], dependencies: [{ kind: "component", type: ButtonComponent, selector: "cl-button", inputs: ["color", "disabled", "icon", "label", "loading", "type"] }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1$2.NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletContent", "ngComponentOutletNgModule", "ngComponentOutletNgModuleFactory"], exportAs: ["ngComponentOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
221
+ }
222
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ContentDialogComponent, decorators: [{
223
+ type: Component,
224
+ args: [{ selector: 'cl-content-dialog', imports: [
225
+ ButtonComponent,
226
+ CommonModule,
227
+ ], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (component()) {\n <ng-container *ngComponentOutlet=\"component()\" />\n}\n\n<div class=\"text-right\">\n <cl-button (click)=\"onClose()\" color=\"secondary\" [label]=\"closeLabel()\" />\n</div>\n" }]
228
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
229
+ type: Inject,
230
+ args: ['env']
231
+ }] }] });
232
+
233
+ class ContentDialogService {
234
+ clStateService = inject(ClStateService);
235
+ dialogService = inject(DialogService);
236
+ onCancel(key) {
237
+ return this.clStateService.onStateMessage('content-dialog-close').pipe(filter(message => message?.payload.key === key), map(() => ({ key })));
238
+ }
239
+ open(data) {
240
+ const { component, config, header, key, styleClass } = data;
241
+ const dialogConfig = {
242
+ closable: false,
243
+ data: { component, config, key },
244
+ header,
245
+ showHeader: true,
246
+ styleClass: styleClass ?? 'w-4'
247
+ };
248
+ this.dialogService.open(ContentDialogComponent, dialogConfig).onClose
249
+ .subscribe(() => {
250
+ this.clStateService.updateStateMessage({
251
+ key,
252
+ type: 'content-dialog-close'
253
+ });
254
+ });
255
+ }
256
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ContentDialogService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
257
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ContentDialogService, providedIn: 'root' });
258
+ }
259
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ContentDialogService, decorators: [{
260
+ type: Injectable,
261
+ args: [{
262
+ providedIn: 'root'
263
+ }]
264
+ }] });
265
+
266
+ class FormDialogComponent {
267
+ env;
268
+ cdRef = inject(ChangeDetectorRef);
269
+ dialogConfig = inject(DynamicDialogConfig);
270
+ dialogRef = inject(DynamicDialogRef);
271
+ formContainer = viewChild('formContainer', { read: ViewContainerRef });
272
+ cancelLabel = signal('Cancel');
273
+ form = signal(null);
274
+ header = signal('');
275
+ hideSubmitButton = signal(false);
276
+ submitLabel = signal('Submit');
277
+ constructor(env) {
278
+ this.env = env;
279
+ const formDialogConfig = this.env?.commonLib?.formDialog;
280
+ if (formDialogConfig) {
281
+ if (formDialogConfig.cancelLabel) {
282
+ this.cancelLabel.set(formDialogConfig.cancelLabel);
283
+ }
284
+ if (formDialogConfig.submitLabel) {
285
+ this.submitLabel.set(formDialogConfig.submitLabel);
286
+ }
287
+ }
288
+ }
289
+ ngOnInit() {
290
+ const { component, config, header, value } = this.dialogConfig.data;
291
+ this.header.set(header);
292
+ if (component) {
293
+ setTimeout(() => {
294
+ const { instance } = this.formContainer().createComponent(component);
295
+ this.form.set(instance.form);
296
+ if (!this.form) {
297
+ throw new Error('Form not found.');
298
+ }
299
+ if (value) {
300
+ this.form()?.patchValue(value);
301
+ }
302
+ this.cdRef.markForCheck();
303
+ });
304
+ }
305
+ if (config) {
306
+ this.hideSubmitButton.set(config.hideSubmitButton ?? this.hideSubmitButton);
307
+ if (config.cancelLabel) {
308
+ this.cancelLabel.set(config.cancelLabel);
309
+ }
310
+ if (config.submitLabel) {
311
+ this.submitLabel.set(config.submitLabel);
312
+ }
313
+ }
314
+ }
315
+ onCancel() {
316
+ this.dialogRef.close();
317
+ }
318
+ onSubmit() {
319
+ if (this.form()?.valid) {
320
+ this.dialogRef.close(this.form().value);
321
+ }
322
+ }
323
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: FormDialogComponent, deps: [{ token: 'env' }], target: i0.ɵɵFactoryTarget.Component });
324
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.12", type: FormDialogComponent, isStandalone: true, selector: "cl-form-dialog", viewQueries: [{ propertyName: "formContainer", first: true, predicate: ["formContainer"], descendants: true, read: ViewContainerRef, isSignal: true }], ngImport: i0, template: "<h2>{{ header() }}</h2>\n\n<div class=\"mb-2\">\n <ng-container #formContainer />\n</div>\n\n@if (form()) {\n <div class=\"text-right\">\n @if (!hideSubmitButton()) {\n <cl-button class=\"mr-2\" (click)=\"onSubmit()\" color=\"main\" [disabled]=\"form()!.invalid || form()!.pristine\"\n [label]=\"submitLabel()\" />\n }\n\n <cl-button (click)=\"onCancel()\" color=\"secondary\" [label]=\"cancelLabel()\" />\n </div>\n}\n", styles: [""], dependencies: [{ kind: "component", type: ButtonComponent, selector: "cl-button", inputs: ["color", "disabled", "icon", "label", "loading", "type"] }, { kind: "ngmodule", type: DynamicDialogModule }, { kind: "ngmodule", type: FormsModule }, { kind: "ngmodule", type: ReactiveFormsModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
325
+ }
326
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: FormDialogComponent, decorators: [{
327
+ type: Component,
328
+ args: [{ selector: 'cl-form-dialog', imports: [
329
+ ButtonComponent,
330
+ DynamicDialogModule,
331
+ FormsModule,
332
+ ReactiveFormsModule,
333
+ ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<h2>{{ header() }}</h2>\n\n<div class=\"mb-2\">\n <ng-container #formContainer />\n</div>\n\n@if (form()) {\n <div class=\"text-right\">\n @if (!hideSubmitButton()) {\n <cl-button class=\"mr-2\" (click)=\"onSubmit()\" color=\"main\" [disabled]=\"form()!.invalid || form()!.pristine\"\n [label]=\"submitLabel()\" />\n }\n\n <cl-button (click)=\"onCancel()\" color=\"secondary\" [label]=\"cancelLabel()\" />\n </div>\n}\n" }]
334
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
335
+ type: Inject,
336
+ args: ['env']
337
+ }] }] });
338
+
339
+ class FormDialogService {
340
+ clStateService = inject(ClStateService);
341
+ dialogService = inject(DialogService);
342
+ onCancel(key) {
343
+ return this.clStateService.onStateMessage('form-dialog-cancel').pipe(filter(message => message?.key === key), map(() => null));
344
+ }
345
+ onSubmit(key) {
346
+ return this.clStateService.onStateMessage('form-dialog-submit').pipe(filter(message => message?.key === key), map(message => message?.payload));
347
+ }
348
+ // Workaround untill primeng v16.2.1 is available
349
+ open(data) {
350
+ const { component, config, header, key, styleClass, value } = data;
351
+ const dialogConfig = {
352
+ data: { component, config, key, value },
353
+ focusOnShow: false,
354
+ header,
355
+ modal: true,
356
+ styleClass
357
+ };
358
+ const ref = this.dialogService.open(FormDialogComponent, dialogConfig);
359
+ ref.onClose.subscribe(value => {
360
+ if (value) {
361
+ this.clStateService.updateStateMessage({
362
+ key,
363
+ payload: value,
364
+ type: 'form-dialog-submit'
365
+ });
366
+ }
367
+ else {
368
+ this.clStateService.updateStateMessage({
369
+ key,
370
+ type: 'form-dialog-cancel'
371
+ });
372
+ }
373
+ });
374
+ }
375
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: FormDialogService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
376
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: FormDialogService, providedIn: 'root' });
377
+ }
378
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: FormDialogService, decorators: [{
379
+ type: Injectable,
380
+ args: [{
381
+ providedIn: 'root'
382
+ }]
383
+ }] });
384
+
385
+ class IconButtonComponent {
386
+ disabled = input(false);
387
+ icon = input.required();
388
+ loading = input(false);
389
+ severity = input('');
390
+ type = input('button');
391
+ class = signal('p-button-icon-only p-button-text');
392
+ constructor() {
393
+ effect(() => {
394
+ this.updateClass(this.severity());
395
+ });
396
+ }
397
+ updateClass(severity) {
398
+ this.class.update(value => value + ' p-button-' + severity);
399
+ }
400
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: IconButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
401
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.12", type: IconButtonComponent, isStandalone: true, selector: "cl-icon-button", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: true, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, severity: { classPropertyName: "severity", publicName: "severity", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<button [class]=\"class()\" [disabled]=\"disabled()\" [icon]=\"icon()\" [loading]=\"loading()\" pButton [type]=\"type()\">\n</button>\n", styles: ["button{border-radius:25px}\n"], dependencies: [{ kind: "ngmodule", type: ButtonModule }, { kind: "directive", type: i1.ButtonDirective, selector: "[pButton]", inputs: ["iconPos", "loadingIcon", "loading", "severity", "raised", "rounded", "text", "outlined", "size", "plain", "fluid", "label", "icon", "buttonProps"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
402
+ }
403
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: IconButtonComponent, decorators: [{
404
+ type: Component,
405
+ args: [{ selector: 'cl-icon-button', imports: [
406
+ ButtonModule,
407
+ ], 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"] }]
408
+ }], ctorParameters: () => [] });
409
+
410
+ class ProgressBarDialogComponent {
411
+ cdRef = inject(ChangeDetectorRef);
412
+ clStateService = inject(ClStateService);
413
+ visible = false;
414
+ constructor() {
415
+ effect(() => {
416
+ switch (this.clStateService.stateMessage()?.type) {
417
+ case 'progess-bar-dialog-close':
418
+ this.visible = false;
419
+ this.cdRef.markForCheck();
420
+ break;
421
+ case 'progess-bar-dialog-open':
422
+ this.visible = true;
423
+ this.cdRef.markForCheck();
424
+ break;
425
+ }
426
+ });
427
+ }
428
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ProgressBarDialogComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
429
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.12", 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: CommonModule }, { kind: "ngmodule", type: DialogModule }, { kind: "component", type: i1$3.Dialog, selector: "p-dialog", inputs: ["header", "draggable", "resizable", "positionLeft", "positionTop", "contentStyle", "contentStyleClass", "modal", "closeOnEscape", "dismissableMask", "rtl", "closable", "responsive", "appendTo", "breakpoints", "styleClass", "maskStyleClass", "maskStyle", "showHeader", "breakpoint", "blockScroll", "autoZIndex", "baseZIndex", "minX", "minY", "focusOnShow", "maximizable", "keepInViewport", "focusTrap", "transitionOptions", "closeIcon", "closeAriaLabel", "closeTabindex", "minimizeIcon", "maximizeIcon", "closeButtonProps", "maximizeButtonProps", "visible", "style", "position", "role", "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", "style", "unit", "mode", "color"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
430
+ }
431
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ProgressBarDialogComponent, decorators: [{
432
+ type: Component,
433
+ args: [{ selector: 'cl-progress-bar-dialog', imports: [
434
+ CommonModule,
435
+ DialogModule,
436
+ ProgressBarModule,
437
+ ], changeDetection: ChangeDetectionStrategy.OnPush, 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"] }]
438
+ }], ctorParameters: () => [] });
439
+
440
+ class ProgressBarDialogService {
441
+ clStateService = inject(ClStateService);
442
+ close() {
443
+ this.clStateService.updateStateMessage({
444
+ type: 'progess-bar-dialog-close'
445
+ });
446
+ }
447
+ open() {
448
+ this.clStateService.updateStateMessage({
449
+ type: 'progess-bar-dialog-open'
450
+ });
451
+ }
452
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ProgressBarDialogService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
453
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ProgressBarDialogService, providedIn: 'root' });
454
+ }
455
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ProgressBarDialogService, decorators: [{
456
+ type: Injectable,
457
+ args: [{
458
+ providedIn: 'root'
459
+ }]
460
+ }] });
461
+
462
+ class ReadonlyValueComponent {
463
+ label = input();
464
+ value = input();
465
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ReadonlyValueComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
466
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.12", type: ReadonlyValueComponent, isStandalone: true, selector: "cl-readonly-value", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<div>\n <strong>{{ label() }}</strong>\n <div>{{ value() }}</div>\n</div>\n", styles: [""], changeDetection: i0.ChangeDetectionStrategy.OnPush });
467
+ }
468
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ReadonlyValueComponent, decorators: [{
469
+ type: Component,
470
+ args: [{ selector: 'cl-readonly-value', imports: [], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div>\n <strong>{{ label() }}</strong>\n <div>{{ value() }}</div>\n</div>\n" }]
471
+ }] });
472
+
473
+ class ToastsComponent {
474
+ clStateService = inject(ClStateService);
475
+ messageService = inject(MessageService);
476
+ constructor() {
477
+ effect(() => {
478
+ const message = this.clStateService.stateMessage();
479
+ if (message?.type === 'toast') {
480
+ const { detail, severity, summary } = message?.payload;
481
+ this.add(detail, summary, severity, 'general');
482
+ }
483
+ });
484
+ }
485
+ add(detail, summary, severity, key) {
486
+ const message = { detail, severity, summary };
487
+ if (key) {
488
+ message.key = key;
489
+ }
490
+ setTimeout(() => {
491
+ this.messageService.add(message);
492
+ });
493
+ }
494
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ToastsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
495
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.12", 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", "style", "styleClass", "position", "preventOpenDuplicates", "preventDuplicates", "showTransformOptions", "hideTransformOptions", "showTransitionOptions", "hideTransitionOptions", "breakpoints"], outputs: ["onClose"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
496
+ }
497
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ToastsComponent, decorators: [{
498
+ type: Component,
499
+ args: [{ selector: 'cl-toasts', imports: [
500
+ ToastModule,
501
+ ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<p-toast key=\"general\" position=\"bottom-center\" />\n" }]
502
+ }], ctorParameters: () => [] });
503
+
504
+ class ToastsService {
505
+ clStateService = inject(ClStateService);
506
+ toastError(detail, summary = 'Error') {
507
+ this.clStateService.updateStateMessage({
508
+ payload: {
509
+ detail,
510
+ severity: 'error',
511
+ summary
512
+ },
513
+ type: 'toast'
514
+ });
515
+ }
516
+ toastSuccess(detail, summary = 'Success') {
517
+ this.clStateService.updateStateMessage({
518
+ payload: {
519
+ detail,
520
+ severity: 'success',
521
+ summary
522
+ },
523
+ type: 'toast'
524
+ });
525
+ }
526
+ toastWarning(detail, summary = 'Warning') {
527
+ this.clStateService.updateStateMessage({
528
+ payload: {
529
+ detail,
530
+ severity: 'warning',
531
+ summary
532
+ },
533
+ type: 'toast'
534
+ });
535
+ }
536
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ToastsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
537
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ToastsService, providedIn: 'root' });
538
+ }
539
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ToastsService, decorators: [{
540
+ type: Injectable,
541
+ args: [{
542
+ providedIn: 'root'
543
+ }]
544
+ }] });
545
+
546
+ class BaseFormComponent {
547
+ control = this.getForm();
548
+ disabled = signal(false);
549
+ subscription = new Subscription();
550
+ ngOnDestroy() {
551
+ this.subscription.unsubscribe();
552
+ }
553
+ // Control Value Accessor methods
554
+ registerOnChange(fn) {
555
+ this.subscription.add(this.control.valueChanges.subscribe(fn));
556
+ }
557
+ registerOnTouched(fn) {
558
+ this.onTouched = fn;
559
+ }
560
+ setDisabledState(isDisabled) {
561
+ if (isDisabled) {
562
+ this.control.disable();
563
+ }
564
+ else {
565
+ this.control.enable();
566
+ }
567
+ setTimeout(() => {
568
+ this.disabled.set(isDisabled);
569
+ });
570
+ }
571
+ writeValue(obj) {
572
+ if (obj) {
573
+ this.setValue(obj);
574
+ }
575
+ }
576
+ // Validator methods
577
+ validate(control) {
578
+ if (this.control.invalid) {
579
+ return { invalid: true };
580
+ }
581
+ return null;
582
+ }
583
+ // Custom protected methods
584
+ getForm() {
585
+ throw new Error('Not implemented.');
586
+ }
587
+ setValue(value) {
588
+ this.control.patchValue(value);
589
+ this.onChanged(value);
590
+ this.onTouched();
591
+ }
592
+ // Custom private methods
593
+ onChanged = (value) => { };
594
+ onTouched = () => { };
595
+ // Getters and setters
596
+ get formArray() {
597
+ return this.control;
598
+ }
599
+ get formControl() {
600
+ return this.control;
601
+ }
602
+ get formGroup() {
603
+ return this.control;
604
+ }
605
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: BaseFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
606
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.12", type: BaseFormComponent, isStandalone: true, selector: "ng-component", ngImport: i0, template: '', isInline: true, styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
607
+ }
608
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: BaseFormComponent, decorators: [{
609
+ type: Component,
610
+ args: [{ imports: [CommonModule], template: '', changeDetection: ChangeDetectionStrategy.OnPush }]
611
+ }] });
612
+
613
+ class FileInputComponent {
614
+ directory = input('');
615
+ icon = input('pi pi-plus');
616
+ label = input('Browse');
617
+ readonly = input(false);
618
+ onDownloadEmitter = output({ alias: 'onDownload' });
619
+ fileInput = viewChild('fileInput');
620
+ fileName = signal('');
621
+ isDisabled = signal(false);
622
+ isFileSelected = signal(false);
623
+ value = signal(null);
624
+ // ControlValueAccessor interface methods
625
+ registerOnChange(fn) {
626
+ this.onChange = fn;
627
+ }
628
+ registerOnTouched(fn) {
629
+ this.onTouched = fn;
630
+ }
631
+ setDisabledState(isDisabled) {
632
+ setTimeout(() => {
633
+ this.isDisabled.set(isDisabled);
634
+ });
635
+ }
636
+ writeValue(value = null) {
637
+ let newValue = [];
638
+ if (Array.isArray(value)) {
639
+ newValue = cloneDeep(value);
640
+ this.selectFile(newValue[0]);
641
+ }
642
+ else if (typeof value === 'string') {
643
+ const lastSlashPosition = value.lastIndexOf('/');
644
+ const fileName = value.substring(lastSlashPosition + 1, value.length);
645
+ const name = fileName.split('.');
646
+ const file = {
647
+ isNew: !value,
648
+ hash: name[1],
649
+ name: fileName,
650
+ path: this.directory(),
651
+ toDelete: false
652
+ };
653
+ newValue.push(file);
654
+ this.selectFile(file);
655
+ }
656
+ this.setValue(newValue);
657
+ }
658
+ // Custom public methods
659
+ onClick() {
660
+ this.fileInput()?.nativeElement.click();
661
+ this.onTouched();
662
+ }
663
+ onFileSelected(event) {
664
+ const file = event.target.files[0];
665
+ const name = file.name.split('.');
666
+ if (file) {
667
+ const hash = v4().split('-')[0];
668
+ const newFile = {
669
+ file,
670
+ hash,
671
+ isNew: true,
672
+ name: `${encodeURIComponent(name[0])}.${hash}.${name[1]}`,
673
+ path: this.directory(),
674
+ toDelete: false
675
+ };
676
+ const newValue = [...this.value()];
677
+ newValue.push(newFile);
678
+ this.selectFile(newFile);
679
+ this.setValue(newValue);
680
+ }
681
+ }
682
+ onDelete() {
683
+ const newValue = [...this.value()];
684
+ const file = this.getLastFile(newValue);
685
+ if (file) {
686
+ if (file.isNew) {
687
+ newValue.pop();
688
+ }
689
+ else {
690
+ file.toDelete = true;
691
+ }
692
+ this.fileName.set('');
693
+ this.isFileSelected.set(false);
694
+ this.setValue(newValue);
695
+ }
696
+ }
697
+ onDownload() {
698
+ this.onDownloadEmitter.emit(this.value());
699
+ }
700
+ // Custom private methods
701
+ getLastFile(value) {
702
+ return value[value.length - 1];
703
+ }
704
+ onChange = (value) => { };
705
+ onTouched = () => { };
706
+ selectFile(file) {
707
+ this.fileName.set(getSafeFileName(file));
708
+ this.isFileSelected.set(true);
709
+ }
710
+ setValue(value) {
711
+ this.value.set(value);
712
+ this.onChange(value);
713
+ this.onTouched();
714
+ }
715
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: FileInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
716
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.12", type: FileInputComponent, isStandalone: true, selector: "cl-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: [
717
+ {
718
+ multi: true,
719
+ provide: NG_VALUE_ACCESSOR,
720
+ useExisting: FileInputComponent,
721
+ }
722
+ ], viewQueries: [{ propertyName: "fileInput", first: true, predicate: ["fileInput"], descendants: true, isSignal: true }], ngImport: i0, template: "<input type=\"hidden\" [value]=\"value()\" />\n<input (change)=\"onFileSelected($event)\" class=\"file-input\" #fileInput type=\"file\" />\n\n@if (isFileSelected()) {\n @if (readonly()) {\n <button class=\"link-button\" (click)=\"onDownload()\" type=\"button\">\n {{ fileName() }}\n </button>\n } @else {\n <div class=\"flex\">\n <cl-button class=\"mr-3\" [label]=\"fileName()\" />\n <button class=\"p-button-danger p-button-rounded p-button-text\" (click)=\"onDelete()\" [disabled]=\"isDisabled()\"\n icon=\"pi pi-trash\" pButton type=\"button\">\n </button>\n </div>\n }\n} @else {\n <cl-button (click)=\"onClick()\" [disabled]=\"isDisabled()\" [icon]=\"icon()\" [label]=\"label()\" />\n}\n\n", styles: [".file-input{display:none}.link-button{background:none!important;border:none;padding:0!important;color:#069;text-decoration:underline;cursor:pointer}\n"], dependencies: [{ kind: "component", type: ButtonComponent, selector: "cl-button", inputs: ["color", "disabled", "icon", "label", "loading", "type"] }, { kind: "ngmodule", type: ButtonModule }, { kind: "directive", type: i1.ButtonDirective, selector: "[pButton]", inputs: ["iconPos", "loadingIcon", "loading", "severity", "raised", "rounded", "text", "outlined", "size", "plain", "fluid", "label", "icon", "buttonProps"] }, { kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: FormsModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
723
+ }
724
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: FileInputComponent, decorators: [{
725
+ type: Component,
726
+ args: [{ selector: 'cl-file-input', imports: [
727
+ ButtonComponent,
728
+ ButtonModule,
729
+ CommonModule,
730
+ FormsModule
731
+ ], changeDetection: ChangeDetectionStrategy.OnPush, providers: [
732
+ {
733
+ multi: true,
734
+ provide: NG_VALUE_ACCESSOR,
735
+ useExisting: FileInputComponent,
736
+ }
737
+ ], template: "<input type=\"hidden\" [value]=\"value()\" />\n<input (change)=\"onFileSelected($event)\" class=\"file-input\" #fileInput type=\"file\" />\n\n@if (isFileSelected()) {\n @if (readonly()) {\n <button class=\"link-button\" (click)=\"onDownload()\" type=\"button\">\n {{ fileName() }}\n </button>\n } @else {\n <div class=\"flex\">\n <cl-button class=\"mr-3\" [label]=\"fileName()\" />\n <button class=\"p-button-danger p-button-rounded p-button-text\" (click)=\"onDelete()\" [disabled]=\"isDisabled()\"\n icon=\"pi pi-trash\" pButton type=\"button\">\n </button>\n </div>\n }\n} @else {\n <cl-button (click)=\"onClick()\" [disabled]=\"isDisabled()\" [icon]=\"icon()\" [label]=\"label()\" />\n}\n\n", styles: [".file-input{display:none}.link-button{background:none!important;border:none;padding:0!important;color:#069;text-decoration:underline;cursor:pointer}\n"] }]
738
+ }] });
739
+ function getSafeFileName(file) {
740
+ const name = file.name.split('.');
741
+ return `${decodeURIComponent(name[0])}.${name[2]}`;
742
+ }
743
+
744
+ class FileInputsComponent extends BaseFormComponent {
745
+ cdRef = inject(ChangeDetectorRef);
746
+ directory = input('');
747
+ icon = input('pi pi-plus');
748
+ label = input('Browse');
749
+ max = input(5);
750
+ readonly = input(false);
751
+ onDownloadEmitter = output({ alias: 'onDownload' });
752
+ onAdd() {
753
+ this.formArray.push(new FormControl());
754
+ this.cdRef.markForCheck();
755
+ }
756
+ onDelete(index) {
757
+ this.formArray.removeAt(index);
758
+ this.cdRef.markForCheck();
759
+ }
760
+ onDownload(file) {
761
+ this.onDownloadEmitter.emit(file);
762
+ }
763
+ setDisabledState(isDisabled) {
764
+ for (const control of this.formArray.controls) {
765
+ if (isDisabled) {
766
+ control.disable();
767
+ }
768
+ else {
769
+ control.enable();
770
+ }
771
+ }
772
+ }
773
+ validate(control) {
774
+ if (control?.hasValidator(Validators.required) && Array.isArray(control?.value)) {
775
+ const first = control.value[0];
776
+ if (!(typeof first === 'string' ||
777
+ (Array.isArray(first) && first.some(({ toDelete }) => toDelete === false)))) {
778
+ return {
779
+ required: true
780
+ };
781
+ }
782
+ }
783
+ return null;
784
+ }
785
+ writeValue(value) {
786
+ if (Array.isArray(value)) {
787
+ setTimeout(() => {
788
+ if (value.length === 0) {
789
+ this.onAdd();
790
+ }
791
+ else {
792
+ for (let i = 0, j = value.length; i < j; i++) {
793
+ this.onAdd();
794
+ }
795
+ this.setValue(value);
796
+ }
797
+ });
798
+ }
799
+ else if (!this.readonly()) {
800
+ this.onAdd();
801
+ }
802
+ }
803
+ getForm() {
804
+ return new FormArray([]);
805
+ }
806
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: FileInputsComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
807
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.12", type: FileInputsComponent, isStandalone: true, selector: "cl-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: [
808
+ {
809
+ multi: true,
810
+ provide: NG_VALIDATORS,
811
+ useExisting: FileInputsComponent
812
+ },
813
+ {
814
+ multi: true,
815
+ provide: NG_VALUE_ACCESSOR,
816
+ useExisting: FileInputsComponent
817
+ }
818
+ ], 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-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 class=\"p-button-rounded p-button-text\" (click)=\"onAdd()\" [disabled]=\"formArray.length >= max()\"\n icon=\"pi pi-plus\" pButton type=\"button\">\n </button>\n } @else if (index > 0) {\n <button class=\"p-button-rounded p-button-text\" (click)=\"onDelete(index)\" icon=\"pi pi-minus\" pButton\n type=\"button\">\n </button>\n }\n }\n </div>\n }\n</ng-container>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: ButtonModule }, { kind: "directive", type: i1.ButtonDirective, selector: "[pButton]", inputs: ["iconPos", "loadingIcon", "loading", "severity", "raised", "rounded", "text", "outlined", "size", "plain", "fluid", "label", "icon", "buttonProps"] }, { kind: "component", type: FileInputComponent, selector: "cl-file-input", inputs: ["directory", "icon", "label", "readonly"], outputs: ["onDownload"] }, { 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],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"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
819
+ }
820
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: FileInputsComponent, decorators: [{
821
+ type: Component,
822
+ args: [{ selector: 'cl-file-inputs', imports: [
823
+ ButtonModule,
824
+ FileInputComponent,
825
+ FormsModule,
826
+ ReactiveFormsModule,
827
+ ], changeDetection: ChangeDetectionStrategy.OnPush, providers: [
828
+ {
829
+ multi: true,
830
+ provide: NG_VALIDATORS,
831
+ useExisting: FileInputsComponent
832
+ },
833
+ {
834
+ multi: true,
835
+ provide: NG_VALUE_ACCESSOR,
836
+ useExisting: FileInputsComponent
837
+ }
838
+ ], template: "<ng-container [formGroup]=\"formGroup\">\n @for (item of formArray.value; track index; let index = $index) {\n <div class=\"flex mb-3\">\n <cl-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 class=\"p-button-rounded p-button-text\" (click)=\"onAdd()\" [disabled]=\"formArray.length >= max()\"\n icon=\"pi pi-plus\" pButton type=\"button\">\n </button>\n } @else if (index > 0) {\n <button class=\"p-button-rounded p-button-text\" (click)=\"onDelete(index)\" icon=\"pi pi-minus\" pButton\n type=\"button\">\n </button>\n }\n }\n </div>\n }\n</ng-container>\n" }]
839
+ }] });
840
+
841
+ const ERROR_DIRECTIVE = new InjectionToken('ErrorDirective');
842
+ class ErrorDirective {
843
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ErrorDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
844
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.12", type: ErrorDirective, isStandalone: true, selector: "ff-error", providers: [
845
+ { provide: ERROR_DIRECTIVE, useExisting: ErrorDirective }
846
+ ], ngImport: i0 });
847
+ }
848
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ErrorDirective, decorators: [{
849
+ type: Directive,
850
+ args: [{
851
+ selector: 'ff-error',
852
+ standalone: true,
853
+ providers: [
854
+ { provide: ERROR_DIRECTIVE, useExisting: ErrorDirective }
855
+ ]
856
+ }]
857
+ }] });
858
+
859
+ const FORM_FIELD = new InjectionToken('FormFieldComponent');
860
+ class FormFieldComponent {
861
+ control = contentChild(FormControlName);
862
+ isRequired = computed(() => this.control()?.control.hasValidator(Validators.required) ?? false);
863
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: FormFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
864
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.12", type: FormFieldComponent, isStandalone: true, selector: "cl-form-field", providers: [
865
+ { provide: FORM_FIELD, useExisting: FormFieldComponent }
866
+ ], queries: [{ propertyName: "control", first: true, predicate: FormControlName, descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"field\">\n <label class=\"block\" [class.required]=\"isRequired()\">\n <ng-content select=\"ff-label\" />\n </label>\n <div>\n <ng-content />\n </div>\n @if ((control()?.dirty || control()?.touched) && control()?.errors) {\n <small class=\"p-block p-error\">\n <ng-content select=\"ff-error\" />\n </small>\n }\n</div>\n", styles: [""], encapsulation: i0.ViewEncapsulation.None });
867
+ }
868
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: FormFieldComponent, decorators: [{
869
+ type: Component,
870
+ args: [{ selector: 'cl-form-field', imports: [], encapsulation: ViewEncapsulation.None, providers: [
871
+ { provide: FORM_FIELD, useExisting: FormFieldComponent }
872
+ ], template: "<div class=\"field\">\n <label class=\"block\" [class.required]=\"isRequired()\">\n <ng-content select=\"ff-label\" />\n </label>\n <div>\n <ng-content />\n </div>\n @if ((control()?.dirty || control()?.touched) && control()?.errors) {\n <small class=\"p-block p-error\">\n <ng-content select=\"ff-error\" />\n </small>\n }\n</div>\n" }]
873
+ }] });
874
+
875
+ const LABEL_DIRECTIVE = new InjectionToken('LabelDirective');
876
+ class LabelDirective {
877
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: LabelDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
878
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.12", type: LabelDirective, isStandalone: true, selector: "ff-label", providers: [
879
+ { provide: LABEL_DIRECTIVE, useExisting: LabelDirective }
880
+ ], ngImport: i0 });
881
+ }
882
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: LabelDirective, decorators: [{
883
+ type: Directive,
884
+ args: [{
885
+ selector: 'ff-label',
886
+ standalone: true,
887
+ providers: [
888
+ { provide: LABEL_DIRECTIVE, useExisting: LabelDirective }
889
+ ]
890
+ }]
891
+ }] });
892
+
893
+ class FormFieldModule {
894
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: FormFieldModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
895
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.12", ngImport: i0, type: FormFieldModule, imports: [ErrorDirective,
896
+ FormFieldComponent,
897
+ LabelDirective], exports: [ErrorDirective,
898
+ FormFieldComponent,
899
+ LabelDirective] });
900
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: FormFieldModule });
901
+ }
902
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: FormFieldModule, decorators: [{
903
+ type: NgModule,
904
+ args: [{
905
+ exports: [
906
+ ErrorDirective,
907
+ FormFieldComponent,
908
+ LabelDirective,
909
+ ],
910
+ imports: [
911
+ ErrorDirective,
912
+ FormFieldComponent,
913
+ LabelDirective,
914
+ ]
915
+ }]
916
+ }] });
917
+
918
+ ;
919
+
920
+ class CommonLibModule {
921
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: CommonLibModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
922
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.12", ngImport: i0, type: CommonLibModule });
923
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: CommonLibModule, providers: [
924
+ ConfirmationService$1,
925
+ DialogService,
926
+ DynamicDialogConfig,
927
+ MessageService,
928
+ ] });
929
+ }
930
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: CommonLibModule, decorators: [{
931
+ type: NgModule,
932
+ args: [{
933
+ providers: [
934
+ ConfirmationService$1,
935
+ DialogService,
936
+ DynamicDialogConfig,
937
+ MessageService,
938
+ ]
939
+ }]
940
+ }] });
941
+
942
+ function concatWithToArray(values) {
943
+ return values[0].pipe(concatWith(...values.slice(1)), toArray());
944
+ }
945
+
946
+ /*
947
+ * Public API Surface of common-lib
948
+ */
949
+ // Controls
950
+
951
+ /**
952
+ * Generated bundle index. Do not edit.
953
+ */
954
+
955
+ 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 };
956
+ //# sourceMappingURL=jm-7c3-common-lib.mjs.map