@arsedizioni/ars-utils 21.2.298 → 21.2.299

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, inject, Renderer2, ElementRef, afterNextRender, Directive, output, ChangeDetectorRef, signal, ChangeDetectionStrategy, Component, Injectable, DestroyRef, viewChild, NgModule, effect, Input, Optional, Self, computed, booleanAttribute, model } from '@angular/core';
2
+ import { input, inject, Renderer2, ElementRef, afterNextRender, Directive, output, ChangeDetectorRef, signal, ChangeDetectionStrategy, Component, Injectable, DestroyRef, viewChild, NgModule, effect, Input, Optional, Self, computed, booleanAttribute, HostBinding, ViewChild, model } from '@angular/core';
3
3
  import * as i14 from '@angular/material/paginator';
4
4
  import { MatPaginatorModule, MatPaginatorIntl } from '@angular/material/paginator';
5
5
  import { DialogService, OtpInputComponent, PaginatorIntl, UIService } from '@arsedizioni/ars-utils/ui';
@@ -2165,6 +2165,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImpo
2165
2165
  }] } });
2166
2166
 
2167
2167
  class FileInputComponent {
2168
+ // Initialize
2168
2169
  static { this.nextId = 0; }
2169
2170
  set value(value) {
2170
2171
  this._value = value;
@@ -2172,21 +2173,18 @@ class FileInputComponent {
2172
2173
  this.stateChanges.next();
2173
2174
  this.changed.emit(this._value);
2174
2175
  }
2175
- /** The current FileInfo value. */
2176
2176
  get value() {
2177
2177
  return this._value;
2178
2178
  }
2179
- /** Size of the current file in bytes. */
2180
2179
  get size() {
2181
2180
  return this._value?.file?.size;
2182
2181
  }
2183
- /** True when the control is required (implements `MatFormFieldControl.required`). */
2184
2182
  get required() {
2185
- return this._requiredInput();
2183
+ return this._required;
2186
2184
  }
2187
- /** The effective placeholder label shown in the form field (implements `MatFormFieldControl.placeholder`). */
2188
- get placeholder() {
2189
- return this._placeholder();
2185
+ set required(value) {
2186
+ this._required = coerceBooleanProperty(value);
2187
+ this.stateChanges.next();
2190
2188
  }
2191
2189
  get disabled() {
2192
2190
  if (this.ngControl && this.ngControl.disabled != null) {
@@ -2201,22 +2199,24 @@ class FileInputComponent {
2201
2199
  this.stateChanges.next();
2202
2200
  }
2203
2201
  }
2204
- /** True when no file is selected. */
2202
+ get placeholder() {
2203
+ return this._placeholder();
2204
+ }
2205
+ set placeholder(value) {
2206
+ this._placeholder.set(value);
2207
+ this.stateChanges.next();
2208
+ }
2205
2209
  get empty() {
2206
2210
  return !this._value || !this._value.file;
2207
2211
  }
2208
- /** True when the control has validation errors and has been touched. */
2209
2212
  get errorState() {
2210
- return (this.ngControl?.errors != null) && (this.ngControl?.touched ?? false);
2213
+ return this.ngControl.errors != null && this.ngControl.touched;
2211
2214
  }
2212
- /** True when the label should float above the field. */
2213
2215
  get shouldLabelFloat() {
2214
2216
  return this.focused || !this.empty;
2215
2217
  }
2216
2218
  constructor(ngControl) {
2217
2219
  this.ngControl = ngControl;
2218
- /** Reference to the hidden native file input element. */
2219
- this.__file = viewChild.required('__file');
2220
2220
  this.renderer = inject(Renderer2);
2221
2221
  this.uiService = inject(UIService);
2222
2222
  this.stateChanges = new Subject();
@@ -2226,22 +2226,16 @@ class FileInputComponent {
2226
2226
  this.canCapture = signal(false, ...(ngDevMode ? [{ debugName: "canCapture" }] : /* istanbul ignore next */ []));
2227
2227
  /** Size in MB of the currently selected file. */
2228
2228
  this.fileSize = signal(0, ...(ngDevMode ? [{ debugName: "fileSize" }] : /* istanbul ignore next */ []));
2229
- /** Internal placeholder text, derived from the input and camera availability. */
2230
2229
  this._placeholder = signal('', ...(ngDevMode ? [{ debugName: "_placeholder" }] : /* istanbul ignore next */ []));
2231
2230
  this._value = new FileInfo();
2232
- /** The currently displayed file name. Can be bound from outside or updated by file selection. */
2233
- this.fileName = model(undefined, ...(ngDevMode ? [{ debugName: "fileName" }] : /* istanbul ignore next */ []));
2231
+ this._required = false;
2232
+ this._disabled = false;
2234
2233
  this.maxSizeMb = input(5, ...(ngDevMode ? [{ debugName: "maxSizeMb" }] : /* istanbul ignore next */ []));
2235
2234
  this.minSizeMb = input(0, ...(ngDevMode ? [{ debugName: "minSizeMb" }] : /* istanbul ignore next */ []));
2236
2235
  this.isNew = input(false, ...(ngDevMode ? [{ debugName: "isNew" }] : /* istanbul ignore next */ []));
2237
2236
  this.canPreview = input(false, ...(ngDevMode ? [{ debugName: "canPreview" }] : /* istanbul ignore next */ []));
2238
2237
  this.appearance = input(this.uiService.appearance(), ...(ngDevMode ? [{ debugName: "appearance" }] : /* istanbul ignore next */ []));
2239
2238
  this.accept = input(...(ngDevMode ? [undefined, { debugName: "accept" }] : /* istanbul ignore next */ []));
2240
- /** @internal Input signal for the required state (bound via the `[required]` attribute). */
2241
- this._requiredInput = input(false, { ...(ngDevMode ? { debugName: "_requiredInput" } : /* istanbul ignore next */ {}), alias: 'required', transform: booleanAttribute });
2242
- /** @internal Input signal for the placeholder text (bound via the `[placeholder]` attribute). */
2243
- this._placeholderInput = input('', { ...(ngDevMode ? { debugName: "_placeholderInput" } : /* istanbul ignore next */ {}), alias: 'placeholder' });
2244
- this._disabled = false;
2245
2239
  this.id = `${this.controlType}-${FileInputComponent.nextId++}`;
2246
2240
  this.describedBy = '';
2247
2241
  this.changed = output();
@@ -2252,31 +2246,12 @@ class FileInputComponent {
2252
2246
  if (this.ngControl != null) {
2253
2247
  this.ngControl.valueAccessor = this;
2254
2248
  }
2255
- // Notify state changes when required changes
2256
- effect(() => {
2257
- this._requiredInput();
2258
- this.stateChanges.next();
2259
- });
2260
- // Sync placeholder input into internal signal; setupDevices may override it when empty
2261
- effect(() => {
2262
- const p = this._placeholderInput();
2263
- if (p) {
2264
- this._placeholder.set(p);
2265
- }
2266
- });
2267
- // Detect camera availability and set the default placeholder after the first render
2268
- afterNextRender(() => {
2269
- this.setupDevices();
2270
- });
2271
- }
2272
- ngOnDestroy() {
2273
- this.stateChanges.complete();
2274
2249
  }
2275
- ngDoCheck() {
2276
- this.updateInputDirtyCheck();
2250
+ async ngOnInit() {
2251
+ await this.setupDevices();
2277
2252
  }
2278
2253
  /**
2279
- * Detects camera availability and sets the default placeholder when none is explicitly provided.
2254
+ * Detects camera availability and updates the placeholder accordingly.
2280
2255
  */
2281
2256
  async setupDevices() {
2282
2257
  this.canCapture.set(false);
@@ -2289,13 +2264,18 @@ class FileInputComponent {
2289
2264
  }
2290
2265
  catch { }
2291
2266
  }
2292
- const current = this._placeholderInput();
2293
- if (!current || current === 'Seleziona file') {
2267
+ if (!this.placeholder || this.placeholder === 'Seleziona file') {
2294
2268
  this._placeholder.set(this.canCapture()
2295
2269
  ? 'Seleziona file o acquisisci con fotocamera'
2296
2270
  : 'Seleziona file');
2297
2271
  }
2298
2272
  }
2273
+ ngOnDestroy() {
2274
+ this.stateChanges.complete();
2275
+ }
2276
+ ngDoCheck() {
2277
+ this.updateInputDirtyCheck();
2278
+ }
2299
2279
  /**
2300
2280
  * Writes a new value to the component (called by the form layer).
2301
2281
  * @param value - The new file info to display.
@@ -2325,15 +2305,10 @@ class FileInputComponent {
2325
2305
  this.describedBy = ids.join(' ');
2326
2306
  }
2327
2307
  /**
2328
- * Updates the disabled state when the Angular form layer changes it.
2308
+ * Updates the disabled state of the underlying native element.
2329
2309
  * @param isDisabled - Whether the control should be disabled.
2330
2310
  */
2331
2311
  setDisabledState(isDisabled) {
2332
- this._disabled = isDisabled;
2333
- if (isDisabled && this.focused) {
2334
- this.focused = false;
2335
- this.stateChanges.next();
2336
- }
2337
2312
  if (!SystemUtils.isBrowser())
2338
2313
  return;
2339
2314
  const elem = document.getElementById(this.id);
@@ -2378,7 +2353,7 @@ class FileInputComponent {
2378
2353
  (!this.maxSizeMb() || fileSizeMb <= this.maxSizeMb()) &&
2379
2354
  (!this.minSizeMb() || fileSizeMb >= this.minSizeMb());
2380
2355
  this.writeValue(fileInfo);
2381
- this.fileName.set(f.name);
2356
+ this.fileName = f.name;
2382
2357
  this.fileSize.set(Math.round(fileSizeMb));
2383
2358
  }
2384
2359
  }
@@ -2394,13 +2369,13 @@ class FileInputComponent {
2394
2369
  */
2395
2370
  clearFile() {
2396
2371
  if (this.hasFile()) {
2397
- this.fileName.set(undefined);
2372
+ this.fileName = undefined;
2398
2373
  this.fileSize.set(0);
2399
2374
  const fi = new FileInfo();
2400
2375
  fi.file = undefined;
2401
2376
  fi.valid = !this.required;
2402
2377
  this.writeValue(fi);
2403
- this.__file().nativeElement.value = '';
2378
+ this.__file.nativeElement.value = '';
2404
2379
  }
2405
2380
  }
2406
2381
  /**
@@ -2418,22 +2393,35 @@ class FileInputComponent {
2418
2393
  this.preview.emit();
2419
2394
  }
2420
2395
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: FileInputComponent, deps: [{ token: i1.NgControl, optional: true, self: true }], target: i0.ɵɵFactoryTarget.Component }); }
2421
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.11", type: FileInputComponent, isStandalone: true, selector: "file-input", inputs: { fileName: { classPropertyName: "fileName", publicName: "fileName", isSignal: true, isRequired: false, transformFunction: null }, maxSizeMb: { classPropertyName: "maxSizeMb", publicName: "maxSizeMb", isSignal: true, isRequired: false, transformFunction: null }, minSizeMb: { classPropertyName: "minSizeMb", publicName: "minSizeMb", isSignal: true, isRequired: false, transformFunction: null }, isNew: { classPropertyName: "isNew", publicName: "isNew", isSignal: true, isRequired: false, transformFunction: null }, canPreview: { classPropertyName: "canPreview", publicName: "canPreview", isSignal: true, isRequired: false, transformFunction: null }, appearance: { classPropertyName: "appearance", publicName: "appearance", isSignal: true, isRequired: false, transformFunction: null }, accept: { classPropertyName: "accept", publicName: "accept", isSignal: true, isRequired: false, transformFunction: null }, _requiredInput: { classPropertyName: "_requiredInput", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, _placeholderInput: { classPropertyName: "_placeholderInput", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: false, isRequired: false, transformFunction: null } }, outputs: { fileName: "fileNameChange", changed: "changed", download: "download", preview: "preview" }, host: { properties: { "id": "id", "class.floating": "shouldLabelFloat", "attr.aria-describedBy": "describedBy" } }, providers: [{ provide: MatFormFieldControl, useExisting: FileInputComponent }], viewQueries: [{ propertyName: "__file", first: true, predicate: ["__file"], descendants: true, isSignal: true }], ngImport: i0, template: "<mat-form-field style=\"width:100%\" [appearance]=\"appearance()\">\r\n <mat-label>{{_placeholder()}}</mat-label>\r\n <input type=\"file\" [hidden]=\"true\" [accept]=\"accept()\" (change)=\"selectFile($event)\" #__file />\r\n <input name=\"_fileName\" #_fileName=\"ngModel\" [ngModel]=\"fileName()\" (ngModelChange)=\"fileName.set($event)\"\r\n [id]=\"id\" matInput readonly [required]=\"required\"\r\n fileSize [size]=\"fileSize()\" [maxSizeMb]=\"maxSizeMb()\" [minSizeMb]=\"minSizeMb()\" [disabled]=\"disabled\" />\r\n @if (hasFile()) {\r\n <button type=\"button\" tabindex=\"-1\" mat-icon-button matSuffix aria-label=\"Azzera\" (click)=\"clearFile()\" [disabled]=\"disabled\">\r\n <mat-icon>close</mat-icon>\r\n </button>\r\n }\r\n @if (!disabled) {\r\n <button type=\"button\" type=\"button\" mat-icon-button matSuffix (click)=\"__file.click()\" aria-label=\"Seleziona file\"\r\n matTooltip=\"Seleziona\" [disabled]=\"disabled\">\r\n <mat-icon>add</mat-icon>\r\n </button>\r\n }\r\n @if (!isNew() && canPreview()) {\r\n <button type=\"button\" mat-icon-button matSuffix (click)=\"previewFile()\" aria-label=\"Anteprima\" matTooltip=\"Anteprima\" [disabled]=\"disabled\">\r\n <mat-icon>preview</mat-icon>\r\n </button>\r\n }\r\n @if (!isNew()) {\r\n <button type=\"button\" mat-icon-button matSuffix (click)=\"downloadFile()\" aria-label=\"Scarica file\"\r\n matTooltip=\"Scarica\" [disabled]=\"disabled\">\r\n <mat-icon>save_alt</mat-icon>\r\n </button>\r\n }\r\n @if (hasFile() && fileSize() > 0) {\r\n <mat-hint align=\"start\">{{fileSize()}} MB</mat-hint>\r\n }\r\n @if (hasFile() && fileSize() == 0) {\r\n <mat-hint align=\"start\">\r\n &gt; 1 MB</mat-hint>\r\n } @if (maxSizeMb()) {\r\n <mat-hint align=\"end\">Massimo {{maxSizeMb()}} MB\r\n </mat-hint>\r\n }\r\n @if (_fileName.invalid && !hasFile()) {\r\n <mat-error>Obbligatorio.</mat-error>\r\n }\r\n @if (_fileName.invalid && hasFile()) {\r\n <mat-error>Dimensione non consentita.</mat-error>\r\n }\r\n</mat-form-field>", styles: [""], dependencies: [{ kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i3.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3.MatLabel, selector: "mat-label" }, { kind: "directive", type: i3.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i3.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i3.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i4.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: FileSizeValidatorDirective, selector: "[fileSize]", inputs: ["maxSizeMb", "minSizeMb", "size"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i6.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i7.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i8.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
2396
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.11", type: FileInputComponent, isStandalone: true, selector: "file-input", inputs: { required: { classPropertyName: "required", publicName: "required", isSignal: false, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: false, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: false, isRequired: false, transformFunction: null }, fileName: { classPropertyName: "fileName", publicName: "fileName", isSignal: false, isRequired: false, transformFunction: null }, maxSizeMb: { classPropertyName: "maxSizeMb", publicName: "maxSizeMb", isSignal: true, isRequired: false, transformFunction: null }, minSizeMb: { classPropertyName: "minSizeMb", publicName: "minSizeMb", isSignal: true, isRequired: false, transformFunction: null }, isNew: { classPropertyName: "isNew", publicName: "isNew", isSignal: true, isRequired: false, transformFunction: null }, canPreview: { classPropertyName: "canPreview", publicName: "canPreview", isSignal: true, isRequired: false, transformFunction: null }, appearance: { classPropertyName: "appearance", publicName: "appearance", isSignal: true, isRequired: false, transformFunction: null }, accept: { classPropertyName: "accept", publicName: "accept", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { changed: "changed", download: "download", preview: "preview" }, host: { properties: { "id": "this.id", "class.floating": "this.shouldLabelFloat", "attr.aria-describedBy": "this.describedBy" } }, providers: [{ provide: MatFormFieldControl, useExisting: FileInputComponent }], viewQueries: [{ propertyName: "__file", first: true, predicate: ["__file"], descendants: true }], ngImport: i0, template: "<mat-form-field style=\"width:100%\" [appearance]=\"appearance()\">\r\n <mat-label>{{placeholder}}</mat-label>\r\n <input type=\"file\" [hidden]=\"true\" [accept]=\"accept()\" (change)=\"selectFile($event)\" #__file />\r\n <input name=\"_fileName\" #_fileName=\"ngModel\" [(ngModel)]=\"fileName\" [id]=\"id\" matInput readonly [required]=\"required\"\r\n fileSize [size]=\"fileSize()\" [maxSizeMb]=\"maxSizeMb()\" [minSizeMb]=\"minSizeMb()\" [disabled]=\"disabled\" />\r\n @if (hasFile()) {\r\n <button type=\"button\" tabindex=\"-1\" mat-icon-button matSuffix aria-label=\"Azzera\" (click)=\"clearFile()\" [disabled]=\"disabled\">\r\n <mat-icon>close</mat-icon>\r\n </button>\r\n }\r\n @if (!disabled) {\r\n <button type=\"button\" type=\"button\" mat-icon-button matSuffix (click)=\"__file.click()\" aria-label=\"Seleziona file\"\r\n matTooltip=\"Seleziona\" [disabled]=\"disabled\">\r\n <mat-icon>add</mat-icon>\r\n </button>\r\n }\r\n @if (!isNew() && canPreview()) {\r\n <button type=\"button\" mat-icon-button matSuffix (click)=\"previewFile()\" aria-label=\"Anteprima\" matTooltip=\"Anteprima\" [disabled]=\"disabled\">\r\n <mat-icon>preview</mat-icon>\r\n </button>\r\n }\r\n @if (!isNew()) {\r\n <button type=\"button\" mat-icon-button matSuffix (click)=\"downloadFile()\" aria-label=\"Scarica file\"\r\n matTooltip=\"Scarica\" [disabled]=\"disabled\">\r\n <mat-icon>save_alt</mat-icon>\r\n </button>\r\n }\r\n @if (hasFile() && fileSize() > 0) {\r\n <mat-hint align=\"start\">{{fileSize()}} MB</mat-hint>\r\n }\r\n @if (hasFile() && fileSize() == 0) {\r\n <mat-hint align=\"start\">\r\n &gt; 1 MB</mat-hint>\r\n } @if (maxSizeMb()) {\r\n <mat-hint align=\"end\">Massimo {{maxSizeMb()}} MB\r\n </mat-hint>\r\n }\r\n @if (_fileName.invalid && !hasFile()) {\r\n <mat-error>Obbligatorio.</mat-error>\r\n }\r\n @if (_fileName.invalid && hasFile()) {\r\n <mat-error>Dimensione non consentita.</mat-error>\r\n }\r\n</mat-form-field>", styles: [""], dependencies: [{ kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i3.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3.MatLabel, selector: "mat-label" }, { kind: "directive", type: i3.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i3.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i3.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i4.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: FileSizeValidatorDirective, selector: "[fileSize]", inputs: ["maxSizeMb", "minSizeMb", "size"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i6.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i7.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i8.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
2422
2397
  }
2423
2398
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: FileInputComponent, decorators: [{
2424
2399
  type: Component,
2425
2400
  args: [{ selector: 'file-input', providers: [{ provide: MatFormFieldControl, useExisting: FileInputComponent }], standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [MatFormFieldModule, MatInputModule, FormsModule, FileSizeValidatorDirective, MatButtonModule,
2426
- MatIconModule, MatTooltipModule], host: {
2427
- '[id]': 'id',
2428
- '[class.floating]': 'shouldLabelFloat',
2429
- '[attr.aria-describedBy]': 'describedBy',
2430
- }, template: "<mat-form-field style=\"width:100%\" [appearance]=\"appearance()\">\r\n <mat-label>{{_placeholder()}}</mat-label>\r\n <input type=\"file\" [hidden]=\"true\" [accept]=\"accept()\" (change)=\"selectFile($event)\" #__file />\r\n <input name=\"_fileName\" #_fileName=\"ngModel\" [ngModel]=\"fileName()\" (ngModelChange)=\"fileName.set($event)\"\r\n [id]=\"id\" matInput readonly [required]=\"required\"\r\n fileSize [size]=\"fileSize()\" [maxSizeMb]=\"maxSizeMb()\" [minSizeMb]=\"minSizeMb()\" [disabled]=\"disabled\" />\r\n @if (hasFile()) {\r\n <button type=\"button\" tabindex=\"-1\" mat-icon-button matSuffix aria-label=\"Azzera\" (click)=\"clearFile()\" [disabled]=\"disabled\">\r\n <mat-icon>close</mat-icon>\r\n </button>\r\n }\r\n @if (!disabled) {\r\n <button type=\"button\" type=\"button\" mat-icon-button matSuffix (click)=\"__file.click()\" aria-label=\"Seleziona file\"\r\n matTooltip=\"Seleziona\" [disabled]=\"disabled\">\r\n <mat-icon>add</mat-icon>\r\n </button>\r\n }\r\n @if (!isNew() && canPreview()) {\r\n <button type=\"button\" mat-icon-button matSuffix (click)=\"previewFile()\" aria-label=\"Anteprima\" matTooltip=\"Anteprima\" [disabled]=\"disabled\">\r\n <mat-icon>preview</mat-icon>\r\n </button>\r\n }\r\n @if (!isNew()) {\r\n <button type=\"button\" mat-icon-button matSuffix (click)=\"downloadFile()\" aria-label=\"Scarica file\"\r\n matTooltip=\"Scarica\" [disabled]=\"disabled\">\r\n <mat-icon>save_alt</mat-icon>\r\n </button>\r\n }\r\n @if (hasFile() && fileSize() > 0) {\r\n <mat-hint align=\"start\">{{fileSize()}} MB</mat-hint>\r\n }\r\n @if (hasFile() && fileSize() == 0) {\r\n <mat-hint align=\"start\">\r\n &gt; 1 MB</mat-hint>\r\n } @if (maxSizeMb()) {\r\n <mat-hint align=\"end\">Massimo {{maxSizeMb()}} MB\r\n </mat-hint>\r\n }\r\n @if (_fileName.invalid && !hasFile()) {\r\n <mat-error>Obbligatorio.</mat-error>\r\n }\r\n @if (_fileName.invalid && hasFile()) {\r\n <mat-error>Dimensione non consentita.</mat-error>\r\n }\r\n</mat-form-field>" }]
2401
+ MatIconModule, MatTooltipModule], template: "<mat-form-field style=\"width:100%\" [appearance]=\"appearance()\">\r\n <mat-label>{{placeholder}}</mat-label>\r\n <input type=\"file\" [hidden]=\"true\" [accept]=\"accept()\" (change)=\"selectFile($event)\" #__file />\r\n <input name=\"_fileName\" #_fileName=\"ngModel\" [(ngModel)]=\"fileName\" [id]=\"id\" matInput readonly [required]=\"required\"\r\n fileSize [size]=\"fileSize()\" [maxSizeMb]=\"maxSizeMb()\" [minSizeMb]=\"minSizeMb()\" [disabled]=\"disabled\" />\r\n @if (hasFile()) {\r\n <button type=\"button\" tabindex=\"-1\" mat-icon-button matSuffix aria-label=\"Azzera\" (click)=\"clearFile()\" [disabled]=\"disabled\">\r\n <mat-icon>close</mat-icon>\r\n </button>\r\n }\r\n @if (!disabled) {\r\n <button type=\"button\" type=\"button\" mat-icon-button matSuffix (click)=\"__file.click()\" aria-label=\"Seleziona file\"\r\n matTooltip=\"Seleziona\" [disabled]=\"disabled\">\r\n <mat-icon>add</mat-icon>\r\n </button>\r\n }\r\n @if (!isNew() && canPreview()) {\r\n <button type=\"button\" mat-icon-button matSuffix (click)=\"previewFile()\" aria-label=\"Anteprima\" matTooltip=\"Anteprima\" [disabled]=\"disabled\">\r\n <mat-icon>preview</mat-icon>\r\n </button>\r\n }\r\n @if (!isNew()) {\r\n <button type=\"button\" mat-icon-button matSuffix (click)=\"downloadFile()\" aria-label=\"Scarica file\"\r\n matTooltip=\"Scarica\" [disabled]=\"disabled\">\r\n <mat-icon>save_alt</mat-icon>\r\n </button>\r\n }\r\n @if (hasFile() && fileSize() > 0) {\r\n <mat-hint align=\"start\">{{fileSize()}} MB</mat-hint>\r\n }\r\n @if (hasFile() && fileSize() == 0) {\r\n <mat-hint align=\"start\">\r\n &gt; 1 MB</mat-hint>\r\n } @if (maxSizeMb()) {\r\n <mat-hint align=\"end\">Massimo {{maxSizeMb()}} MB\r\n </mat-hint>\r\n }\r\n @if (_fileName.invalid && !hasFile()) {\r\n <mat-error>Obbligatorio.</mat-error>\r\n }\r\n @if (_fileName.invalid && hasFile()) {\r\n <mat-error>Dimensione non consentita.</mat-error>\r\n }\r\n</mat-form-field>" }]
2431
2402
  }], ctorParameters: () => [{ type: i1.NgControl, decorators: [{
2432
2403
  type: Optional
2433
2404
  }, {
2434
2405
  type: Self
2435
- }] }], propDecorators: { __file: [{ type: i0.ViewChild, args: ['__file', { isSignal: true }] }], fileName: [{ type: i0.Input, args: [{ isSignal: true, alias: "fileName", required: false }] }, { type: i0.Output, args: ["fileNameChange"] }], maxSizeMb: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxSizeMb", required: false }] }], minSizeMb: [{ type: i0.Input, args: [{ isSignal: true, alias: "minSizeMb", required: false }] }], isNew: [{ type: i0.Input, args: [{ isSignal: true, alias: "isNew", required: false }] }], canPreview: [{ type: i0.Input, args: [{ isSignal: true, alias: "canPreview", required: false }] }], appearance: [{ type: i0.Input, args: [{ isSignal: true, alias: "appearance", required: false }] }], accept: [{ type: i0.Input, args: [{ isSignal: true, alias: "accept", required: false }] }], _requiredInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], _placeholderInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], disabled: [{
2406
+ }] }], propDecorators: { __file: [{
2407
+ type: ViewChild,
2408
+ args: ['__file']
2409
+ }], required: [{
2410
+ type: Input
2411
+ }], disabled: [{
2412
+ type: Input
2413
+ }], placeholder: [{
2414
+ type: Input
2415
+ }], fileName: [{
2436
2416
  type: Input
2417
+ }], maxSizeMb: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxSizeMb", required: false }] }], minSizeMb: [{ type: i0.Input, args: [{ isSignal: true, alias: "minSizeMb", required: false }] }], isNew: [{ type: i0.Input, args: [{ isSignal: true, alias: "isNew", required: false }] }], canPreview: [{ type: i0.Input, args: [{ isSignal: true, alias: "canPreview", required: false }] }], appearance: [{ type: i0.Input, args: [{ isSignal: true, alias: "appearance", required: false }] }], accept: [{ type: i0.Input, args: [{ isSignal: true, alias: "accept", required: false }] }], id: [{
2418
+ type: HostBinding
2419
+ }], shouldLabelFloat: [{
2420
+ type: HostBinding,
2421
+ args: ['class.floating']
2422
+ }], describedBy: [{
2423
+ type: HostBinding,
2424
+ args: ['attr.aria-describedBy']
2437
2425
  }], changed: [{ type: i0.Output, args: ["changed"] }], download: [{ type: i0.Output, args: ["download"] }], preview: [{ type: i0.Output, args: ["preview"] }] } });
2438
2426
 
2439
2427
  class FilePreviewComponent {