ngx-eiffage-material 0.1.4 → 0.1.5
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.
|
@@ -7,7 +7,7 @@ import { MatIconModule } from '@angular/material/icon';
|
|
|
7
7
|
import * as i2 from '@angular/material/progress-spinner';
|
|
8
8
|
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
|
9
9
|
import * as i3$1 from '@angular/forms';
|
|
10
|
-
import { FormControl, ReactiveFormsModule, NG_VALUE_ACCESSOR, NgControl, Validators, FormArray, FormGroup, FormBuilder, FormsModule } from '@angular/forms';
|
|
10
|
+
import { FormControl, ReactiveFormsModule, NG_VALUE_ACCESSOR, NgControl, FormGroupDirective, NgForm, Validators, FormArray, FormGroup, FormBuilder, FormsModule } from '@angular/forms';
|
|
11
11
|
import * as i11 from '@angular/common';
|
|
12
12
|
import { CommonModule, DatePipe, isPlatformBrowser, LowerCasePipe } from '@angular/common';
|
|
13
13
|
import * as i2$1 from '@angular/material/chips';
|
|
@@ -597,6 +597,9 @@ class NgxBasicSelect {
|
|
|
597
597
|
* y para no fallar cuando el componente se usa sin formulario.
|
|
598
598
|
*/
|
|
599
599
|
_ngControl = inject(NgControl, { self: true, optional: true });
|
|
600
|
+
/** Formulario contenedor, para saber si ya se intentó enviar (reactive o template-driven). */
|
|
601
|
+
_parentFormGroup = inject(FormGroupDirective, { optional: true });
|
|
602
|
+
_parentForm = inject(NgForm, { optional: true });
|
|
600
603
|
// ─── Inputs ──────────────────────────────────────────────────────────────
|
|
601
604
|
label = input.required(...(ngDevMode ? [{ debugName: "label" }] : []));
|
|
602
605
|
options = input.required(...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
@@ -673,9 +676,15 @@ class NgxBasicSelect {
|
|
|
673
676
|
const count = this.resolvedOptions().filter(o => o.visible).length;
|
|
674
677
|
return this.intl.getSearchResultsCountMessage(count);
|
|
675
678
|
}, ...(ngDevMode ? [{ debugName: "searchAnnouncement" }] : []));
|
|
676
|
-
/**
|
|
679
|
+
/**
|
|
680
|
+
* ErrorStateMatcher que refleja el estado del control del formulario.
|
|
681
|
+
* Replica el criterio por defecto de Material: se muestra el error si el
|
|
682
|
+
* control es inválido y además ha sido tocado O ya se ha enviado el
|
|
683
|
+
* formulario. Sin la parte de `submitted`, al pulsar "Guardar" los campos
|
|
684
|
+
* obligatorios que el usuario no llegó a tocar no se marcaban en rojo.
|
|
685
|
+
*/
|
|
677
686
|
errorStateMatcher = {
|
|
678
|
-
isErrorState: () => !!(this._ngControl?.invalid && this._ngControl?.touched),
|
|
687
|
+
isErrorState: () => !!(this._ngControl?.invalid && (this._ngControl?.touched || this._isParentFormSubmitted())),
|
|
679
688
|
};
|
|
680
689
|
/**
|
|
681
690
|
* Obligatorio si el control del formulario tiene el validador `required`.
|
|
@@ -685,6 +694,10 @@ class NgxBasicSelect {
|
|
|
685
694
|
isRequired() {
|
|
686
695
|
return this._ngControl?.control?.hasValidator(Validators.required) ?? false;
|
|
687
696
|
}
|
|
697
|
+
/** true cuando el formulario contenedor ya ha intentado enviarse. */
|
|
698
|
+
_isParentFormSubmitted() {
|
|
699
|
+
return this._parentFormGroup?.submitted || this._parentForm?.submitted || false;
|
|
700
|
+
}
|
|
688
701
|
constructor() {
|
|
689
702
|
// Auto-registro como CVA (evita el provider NG_VALUE_ACCESSOR y su DI circular).
|
|
690
703
|
if (this._ngControl)
|
|
@@ -3503,6 +3516,9 @@ class NgxPaginatedSelect {
|
|
|
3503
3516
|
_bottomSheet = inject(MatBottomSheet);
|
|
3504
3517
|
/** Se auto-registra como CVA (self/optional para leer validación y no fallar sin form). */
|
|
3505
3518
|
_ngControl = inject(NgControl, { self: true, optional: true });
|
|
3519
|
+
/** Formulario contenedor, para saber si ya se intento enviar (reactive o template-driven). */
|
|
3520
|
+
_parentFormGroup = inject(FormGroupDirective, { optional: true });
|
|
3521
|
+
_parentForm = inject(NgForm, { optional: true });
|
|
3506
3522
|
intl = inject(NgxTablesIntl);
|
|
3507
3523
|
// ─── Inputs ────────────────────────────────────────────────────────────────
|
|
3508
3524
|
/** Label that floats on the form field */
|
|
@@ -3594,8 +3610,12 @@ class NgxPaginatedSelect {
|
|
|
3594
3610
|
remainingChipsCount = computed(() => Math.max(0, this._selectedItems().length - this.maxChipsDisplayed()), ...(ngDevMode ? [{ debugName: "remainingChipsCount" }] : []));
|
|
3595
3611
|
/** ErrorStateMatcher que refleja el estado del control del formulario. */
|
|
3596
3612
|
errorStateMatcher = {
|
|
3597
|
-
isErrorState: () => !!(this._ngControl?.invalid && this._ngControl?.touched),
|
|
3613
|
+
isErrorState: () => !!(this._ngControl?.invalid && (this._ngControl?.touched || this._isParentFormSubmitted())),
|
|
3598
3614
|
};
|
|
3615
|
+
/** true cuando el formulario contenedor ya ha intentado enviarse. */
|
|
3616
|
+
_isParentFormSubmitted() {
|
|
3617
|
+
return this._parentFormGroup?.submitted || this._parentForm?.submitted || false;
|
|
3618
|
+
}
|
|
3599
3619
|
/**
|
|
3600
3620
|
* Obligatorio si el control del formulario tiene el validador `required`.
|
|
3601
3621
|
* Se propaga al input interno para que el mat-form-field pinte el asterisco,
|