@smartsoft001/angular 2.155.0 → 2.157.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -21538,9 +21538,20 @@ class FormComponent {
|
|
|
21538
21538
|
});
|
|
21539
21539
|
_options;
|
|
21540
21540
|
_subscription = new Subscription();
|
|
21541
|
+
_formSubscription = new Subscription();
|
|
21541
21542
|
_mode;
|
|
21542
21543
|
_uniqueProvider;
|
|
21543
|
-
|
|
21544
|
+
// Counts the builds started so far, so a build that settles after a newer
|
|
21545
|
+
// one has already won can recognise itself as stale and step aside.
|
|
21546
|
+
_build = 0;
|
|
21547
|
+
// The group lives in a signal: the body is rendered through
|
|
21548
|
+
// `componentInputs()`, and a plain field would leave that computed - and so
|
|
21549
|
+
// the rendered inputs - bound to the group of the previous build.
|
|
21550
|
+
_form = signal(undefined, /* @ts-ignore */
|
|
21551
|
+
...(ngDevMode ? [{ debugName: "_form" }] : /* istanbul ignore next */ []));
|
|
21552
|
+
get form() {
|
|
21553
|
+
return this._form();
|
|
21554
|
+
}
|
|
21544
21555
|
export;
|
|
21545
21556
|
exportHandler;
|
|
21546
21557
|
import;
|
|
@@ -21575,9 +21586,10 @@ class FormComponent {
|
|
|
21575
21586
|
if (options?.uniqueProvider) {
|
|
21576
21587
|
this._uniqueProvider = options.uniqueProvider;
|
|
21577
21588
|
}
|
|
21589
|
+
const build = ++this._build;
|
|
21578
21590
|
if (options.control) {
|
|
21579
|
-
this.
|
|
21580
|
-
this.registerChanges();
|
|
21591
|
+
this._form.set(options.control);
|
|
21592
|
+
this.registerChanges(options.control);
|
|
21581
21593
|
this.cd.detectChanges();
|
|
21582
21594
|
}
|
|
21583
21595
|
else {
|
|
@@ -21587,8 +21599,10 @@ class FormComponent {
|
|
|
21587
21599
|
uniqueProvider: this._uniqueProvider,
|
|
21588
21600
|
})
|
|
21589
21601
|
.then((res) => {
|
|
21590
|
-
this.
|
|
21591
|
-
|
|
21602
|
+
if (build !== this._build)
|
|
21603
|
+
return;
|
|
21604
|
+
this._form.set(res);
|
|
21605
|
+
this.registerChanges(res);
|
|
21592
21606
|
this.cd.detectChanges();
|
|
21593
21607
|
});
|
|
21594
21608
|
}
|
|
@@ -21603,15 +21617,17 @@ class FormComponent {
|
|
|
21603
21617
|
uniqueProvider: this._uniqueProvider,
|
|
21604
21618
|
})
|
|
21605
21619
|
.then((res) => {
|
|
21606
|
-
this.form
|
|
21607
|
-
|
|
21620
|
+
const current = this.form;
|
|
21621
|
+
if (!current)
|
|
21622
|
+
return;
|
|
21623
|
+
current.setForm(res);
|
|
21624
|
+
this.registerChanges(current);
|
|
21608
21625
|
this.cd.detectChanges();
|
|
21609
21626
|
});
|
|
21610
21627
|
}
|
|
21611
21628
|
ngOnDestroy() {
|
|
21612
|
-
|
|
21613
|
-
|
|
21614
|
-
}
|
|
21629
|
+
this._subscription.unsubscribe();
|
|
21630
|
+
this._formSubscription.unsubscribe();
|
|
21615
21631
|
}
|
|
21616
21632
|
initLoading() {
|
|
21617
21633
|
if (this._options.loading$) {
|
|
@@ -21619,27 +21635,31 @@ class FormComponent {
|
|
|
21619
21635
|
.pipe(filter(() => !!this.form))
|
|
21620
21636
|
.subscribe((val) => {
|
|
21621
21637
|
if (val) {
|
|
21622
|
-
this.form
|
|
21638
|
+
this.form?.disable();
|
|
21623
21639
|
}
|
|
21624
21640
|
else {
|
|
21625
|
-
this.form
|
|
21641
|
+
this.form?.enable();
|
|
21626
21642
|
}
|
|
21627
21643
|
}));
|
|
21628
21644
|
}
|
|
21629
21645
|
}
|
|
21630
|
-
registerChanges() {
|
|
21631
|
-
|
|
21632
|
-
|
|
21633
|
-
|
|
21646
|
+
registerChanges(form) {
|
|
21647
|
+
// Only the group currently rendered may emit, so the previous
|
|
21648
|
+
// subscription goes away before the new one is created.
|
|
21649
|
+
this._formSubscription.unsubscribe();
|
|
21650
|
+
this._formSubscription = new Subscription();
|
|
21651
|
+
this._formSubscription.add(form.valueChanges.subscribe(() => {
|
|
21652
|
+
this.validChange.emit(form.valid);
|
|
21653
|
+
this.valueChange.emit(form.value);
|
|
21634
21654
|
const partialModel = {};
|
|
21635
|
-
Object.keys(
|
|
21636
|
-
.filter((key) => !key.endsWith('Confirm') &&
|
|
21655
|
+
Object.keys(form.controls)
|
|
21656
|
+
.filter((key) => !key.endsWith('Confirm') && form.controls[key].dirty)
|
|
21637
21657
|
.forEach((key) => {
|
|
21638
|
-
partialModel[key] =
|
|
21658
|
+
partialModel[key] = form.controls[key].value;
|
|
21639
21659
|
});
|
|
21640
21660
|
this.valuePartialChange.emit(partialModel);
|
|
21641
21661
|
}));
|
|
21642
|
-
|
|
21662
|
+
form.updateValueAndValidity();
|
|
21643
21663
|
}
|
|
21644
21664
|
async initExportImport() {
|
|
21645
21665
|
const modelOptions = getModelOptions(this._options.model.constructor);
|
|
@@ -21682,11 +21702,11 @@ class FormComponent {
|
|
|
21682
21702
|
}
|
|
21683
21703
|
</div>
|
|
21684
21704
|
}-->
|
|
21685
|
-
@if (form) {
|
|
21705
|
+
@if (form; as currentForm) {
|
|
21686
21706
|
<form
|
|
21687
|
-
[formGroup]="
|
|
21688
|
-
(ngSubmit)="invokeSubmit.emit(
|
|
21689
|
-
(keyup.enter)="invokeSubmit.emit(
|
|
21707
|
+
[formGroup]="currentForm"
|
|
21708
|
+
(ngSubmit)="invokeSubmit.emit(currentForm.value)"
|
|
21709
|
+
(keyup.enter)="invokeSubmit.emit(currentForm.value)"
|
|
21690
21710
|
>
|
|
21691
21711
|
@if (componentType()) {
|
|
21692
21712
|
<ng-container
|
|
@@ -21695,7 +21715,7 @@ class FormComponent {
|
|
|
21695
21715
|
} @else {
|
|
21696
21716
|
<smart-form-standard
|
|
21697
21717
|
[options]="options()"
|
|
21698
|
-
[form]="
|
|
21718
|
+
[form]="currentForm"
|
|
21699
21719
|
[class]="cssClass()"
|
|
21700
21720
|
></smart-form-standard>
|
|
21701
21721
|
}
|
|
@@ -21725,11 +21745,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
21725
21745
|
}
|
|
21726
21746
|
</div>
|
|
21727
21747
|
}-->
|
|
21728
|
-
@if (form) {
|
|
21748
|
+
@if (form; as currentForm) {
|
|
21729
21749
|
<form
|
|
21730
|
-
[formGroup]="
|
|
21731
|
-
(ngSubmit)="invokeSubmit.emit(
|
|
21732
|
-
(keyup.enter)="invokeSubmit.emit(
|
|
21750
|
+
[formGroup]="currentForm"
|
|
21751
|
+
(ngSubmit)="invokeSubmit.emit(currentForm.value)"
|
|
21752
|
+
(keyup.enter)="invokeSubmit.emit(currentForm.value)"
|
|
21733
21753
|
>
|
|
21734
21754
|
@if (componentType()) {
|
|
21735
21755
|
<ng-container
|
|
@@ -21738,7 +21758,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
21738
21758
|
} @else {
|
|
21739
21759
|
<smart-form-standard
|
|
21740
21760
|
[options]="options()"
|
|
21741
|
-
[form]="
|
|
21761
|
+
[form]="currentForm"
|
|
21742
21762
|
[class]="cssClass()"
|
|
21743
21763
|
></smart-form-standard>
|
|
21744
21764
|
}
|