@rxdi/forms 0.7.215 → 0.7.216
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.
- package/README.md +2 -0
- package/dist/form.array.js +7 -14
- package/dist/form.group.d.ts +1 -1
- package/dist/form.group.js +18 -13
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -154,6 +154,8 @@ this.form.patchValue({
|
|
|
154
154
|
}
|
|
155
155
|
});
|
|
156
156
|
// Only updates 'isActive', leaves other fields untouched.
|
|
157
|
+
````
|
|
158
|
+
|
|
157
159
|
### Dynamic Array Inputs (FormArray)
|
|
158
160
|
|
|
159
161
|
For lists of primitive values, use `FormArray` with an `itemFactory` and automatic model binding. This removes the need for manual population.
|
package/dist/form.array.js
CHANGED
|
@@ -88,15 +88,14 @@ class FormArray {
|
|
|
88
88
|
unsubscribe() {
|
|
89
89
|
this.subscriptions.forEach((sub) => sub.unsubscribe());
|
|
90
90
|
this.subscriptions.clear();
|
|
91
|
-
this.controls.forEach((c) => c.unsubscribe
|
|
91
|
+
this.controls.forEach((c) => { var _a; return (_a = c.unsubscribe) === null || _a === void 0 ? void 0 : _a.call(c); });
|
|
92
92
|
}
|
|
93
93
|
updateValue() {
|
|
94
94
|
this._valueChanges.next(this.value);
|
|
95
95
|
}
|
|
96
96
|
requestUpdate() {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
97
|
+
var _a;
|
|
98
|
+
(_a = this.parentElement) === null || _a === void 0 ? void 0 : _a.requestUpdate();
|
|
100
99
|
}
|
|
101
100
|
setParentElement(parent) {
|
|
102
101
|
this.parentElement = parent;
|
|
@@ -118,9 +117,7 @@ class FormArray {
|
|
|
118
117
|
return;
|
|
119
118
|
}
|
|
120
119
|
values.forEach((v, i) => {
|
|
121
|
-
|
|
122
|
-
this.controls[i].value = v;
|
|
123
|
-
}
|
|
120
|
+
this.controls[i] && (this.controls[i].value = v);
|
|
124
121
|
});
|
|
125
122
|
this.updateValue();
|
|
126
123
|
}
|
|
@@ -129,13 +126,9 @@ class FormArray {
|
|
|
129
126
|
return;
|
|
130
127
|
}
|
|
131
128
|
values.forEach((v, i) => {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
this.controls[i].value = v;
|
|
138
|
-
}
|
|
129
|
+
const control = this.controls[i];
|
|
130
|
+
if (control) {
|
|
131
|
+
control.patchValue ? control.patchValue(v) : (control.value = v);
|
|
139
132
|
}
|
|
140
133
|
else if (this.options.itemFactory) {
|
|
141
134
|
this.push(this.options.itemFactory(v));
|
package/dist/form.group.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LitElement } from '@rxdi/lit-html';
|
|
2
|
-
import { AbstractControl, AbstractInput, ErrorObject, FormInputOptions, FormOptions, NestedKeyOf, UnwrapValue, ValidatorFn
|
|
2
|
+
import { AbstractControl, AbstractInput, DeepPropType, ErrorObject, FormInputOptions, FormOptions, NestedKeyOf, UnwrapValue, ValidatorFn } from './form.tokens';
|
|
3
3
|
export declare class FormGroup<T = FormInputOptions, E = {
|
|
4
4
|
[key: string]: never;
|
|
5
5
|
}> implements AbstractControl<UnwrapValue<T>> {
|
package/dist/form.group.js
CHANGED
|
@@ -46,10 +46,13 @@ class FormGroup {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
init() {
|
|
49
|
+
if (!this.parentElement) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
49
52
|
this.setFormElement(this.querySelectForm(this.parentElement.shadowRoot || this.parentElement)).setInputs(this.mapEventToInputs(this.querySelectorAllInputs()));
|
|
50
53
|
this.controls.forEach((c) => {
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
var _a;
|
|
55
|
+
(_a = c.init) === null || _a === void 0 ? void 0 : _a.call(c);
|
|
53
56
|
});
|
|
54
57
|
}
|
|
55
58
|
prepareValues() {
|
|
@@ -84,9 +87,8 @@ class FormGroup {
|
|
|
84
87
|
setParentElement(parent) {
|
|
85
88
|
this.parentElement = parent;
|
|
86
89
|
this.controls.forEach((c) => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
+
var _a;
|
|
91
|
+
(_a = c.setParentElement) === null || _a === void 0 ? void 0 : _a.call(c, parent);
|
|
90
92
|
});
|
|
91
93
|
return this;
|
|
92
94
|
}
|
|
@@ -96,9 +98,8 @@ class FormGroup {
|
|
|
96
98
|
setOptions(options) {
|
|
97
99
|
this.options = options;
|
|
98
100
|
this.controls.forEach((c) => {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
101
|
+
var _a;
|
|
102
|
+
(_a = c.setOptions) === null || _a === void 0 ? void 0 : _a.call(c, Object.assign(Object.assign({}, options), { namespace: this.options.namespace ? `${this.options.namespace}.${c.name}` : c.name }));
|
|
102
103
|
});
|
|
103
104
|
return this;
|
|
104
105
|
}
|
|
@@ -200,6 +201,9 @@ class FormGroup {
|
|
|
200
201
|
if (this.options['form']) {
|
|
201
202
|
return this.options['form'];
|
|
202
203
|
}
|
|
204
|
+
if (!(shadowRoot === null || shadowRoot === void 0 ? void 0 : shadowRoot.querySelector)) {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
203
207
|
const form = shadowRoot.querySelector(`form[name="${this.options.name}"]`);
|
|
204
208
|
if (!form) {
|
|
205
209
|
throw new Error(`Form element with name "${this.options.name}" not present inside ${this.getParentElement().outerHTML} component`);
|
|
@@ -335,7 +339,7 @@ class FormGroup {
|
|
|
335
339
|
const names = String(name).split('.');
|
|
336
340
|
const key = names.shift();
|
|
337
341
|
const control = this.controls.get(key);
|
|
338
|
-
if (control
|
|
342
|
+
if (control === null || control === void 0 ? void 0 : control.get) {
|
|
339
343
|
return control.get(names.join('.'));
|
|
340
344
|
}
|
|
341
345
|
}
|
|
@@ -390,8 +394,9 @@ class FormGroup {
|
|
|
390
394
|
return;
|
|
391
395
|
}
|
|
392
396
|
Object.keys(value).forEach((key) => {
|
|
393
|
-
|
|
394
|
-
|
|
397
|
+
const control = this.controls.get(key);
|
|
398
|
+
if (control === null || control === void 0 ? void 0 : control['patchValue']) {
|
|
399
|
+
control['patchValue'](value[key]);
|
|
395
400
|
}
|
|
396
401
|
else {
|
|
397
402
|
this.setValue(key, value[key]);
|
|
@@ -417,8 +422,8 @@ class FormGroup {
|
|
|
417
422
|
setFormElement(form) {
|
|
418
423
|
this.form = form;
|
|
419
424
|
this.controls.forEach((c) => {
|
|
420
|
-
|
|
421
|
-
|
|
425
|
+
var _a;
|
|
426
|
+
(_a = c.setFormElement) === null || _a === void 0 ? void 0 : _a.call(c, form);
|
|
422
427
|
});
|
|
423
428
|
return this;
|
|
424
429
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rxdi/forms",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.216",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"author": "Kristiyan Tachev",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"build": "tsc"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@rxdi/lit-html": "^0.7.
|
|
15
|
+
"@rxdi/lit-html": "^0.7.215",
|
|
16
16
|
"@types/node": "^25.0.3",
|
|
17
17
|
"rxjs": "^7.8.2",
|
|
18
18
|
"typescript": "^5.9.3"
|