@rxdi/forms 0.7.229 → 0.7.230
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/dist/form.group.js +27 -7
- package/package.json +2 -2
package/dist/form.group.js
CHANGED
|
@@ -76,11 +76,12 @@ class FormGroup {
|
|
|
76
76
|
}
|
|
77
77
|
else if (value[0].constructor === String ||
|
|
78
78
|
value[0].constructor === Number ||
|
|
79
|
-
value[0].constructor === Boolean
|
|
79
|
+
value[0].constructor === Boolean ||
|
|
80
|
+
value[0].constructor === Array) {
|
|
80
81
|
this.value[v] = value[0];
|
|
81
82
|
}
|
|
82
83
|
else {
|
|
83
|
-
throw new Error(`Input value must be of type 'string', 'boolean' or 'number'`);
|
|
84
|
+
throw new Error(`Input value must be of type 'string', 'boolean', 'array' or 'number'`);
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
});
|
|
@@ -169,12 +170,16 @@ class FormGroup {
|
|
|
169
170
|
.querySelectorAll(`input[name="${this.name}"]:checked`)).values(),
|
|
170
171
|
];
|
|
171
172
|
if (hasMultipleBindings > 1) {
|
|
172
|
-
if (
|
|
173
|
+
if (self.options.multi && this.type === 'checkbox') {
|
|
173
174
|
value = inputsWithBindings.map((e) => e.value);
|
|
174
175
|
}
|
|
175
|
-
if (self.options.multi) {
|
|
176
|
-
inputsWithBindings.forEach((el) =>
|
|
176
|
+
if (!self.options.multi && this.type === 'checkbox') {
|
|
177
|
+
inputsWithBindings.forEach((el) => {
|
|
178
|
+
if (el !== this)
|
|
179
|
+
el.checked = false;
|
|
180
|
+
});
|
|
177
181
|
this.checked = true;
|
|
182
|
+
value = this.value;
|
|
178
183
|
}
|
|
179
184
|
}
|
|
180
185
|
self.resetErrors();
|
|
@@ -452,8 +457,12 @@ class FormGroup {
|
|
|
452
457
|
// User code had return; but we might want to update model even if no input?
|
|
453
458
|
// return;
|
|
454
459
|
}
|
|
455
|
-
if (input &&
|
|
460
|
+
if (input &&
|
|
461
|
+
input.value !== undefined &&
|
|
462
|
+
input.type !== 'checkbox' &&
|
|
463
|
+
input.type !== 'radio') {
|
|
456
464
|
input.value = value;
|
|
465
|
+
}
|
|
457
466
|
const values = this.value;
|
|
458
467
|
values[name] = value;
|
|
459
468
|
this.value = values;
|
|
@@ -472,7 +481,18 @@ class FormGroup {
|
|
|
472
481
|
setInputs(inputs) {
|
|
473
482
|
this.inputs = new Map(inputs.map((e) => {
|
|
474
483
|
const key = this.getModelKeyName(e.name);
|
|
475
|
-
|
|
484
|
+
const modelValue = this.getValue(key);
|
|
485
|
+
if (e.type === 'checkbox' || e.type === 'radio') {
|
|
486
|
+
if (Array.isArray(modelValue)) {
|
|
487
|
+
e.checked = modelValue.includes(e.value);
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
e.checked = modelValue === e.value;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
e.value = modelValue;
|
|
495
|
+
}
|
|
476
496
|
e.valueChanges = this._valueChanges.pipe((0, operators_1.map)((value) => value === null || value === void 0 ? void 0 : value[key]), (0, operators_1.distinctUntilChanged)());
|
|
477
497
|
return [key, e];
|
|
478
498
|
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rxdi/forms",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.230",
|
|
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.229",
|
|
16
16
|
"@types/node": "^25.0.3",
|
|
17
17
|
"rxjs": "^7.8.2",
|
|
18
18
|
"typescript": "^5.9.3"
|