@rxdi/forms 0.7.231 → 0.7.233
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.decorator.js +4 -1
- package/dist/form.group.d.ts +3 -0
- package/dist/form.group.js +32 -9
- package/package.json +2 -2
package/dist/form.decorator.js
CHANGED
|
@@ -18,7 +18,10 @@ function Form(options = {
|
|
|
18
18
|
if (!(this[name] instanceof form_group_1.FormGroup)) {
|
|
19
19
|
throw new Error('Value provided is not an instance of FormGroup!');
|
|
20
20
|
}
|
|
21
|
-
this[name]
|
|
21
|
+
this[name]
|
|
22
|
+
.setParentElement(this)
|
|
23
|
+
.setOptions(options)
|
|
24
|
+
.prepareValues();
|
|
22
25
|
if (options.model && this[options.model]) {
|
|
23
26
|
this[name].patchValue(this[options.model]);
|
|
24
27
|
}
|
package/dist/form.group.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { LitElement } from '@rxdi/lit-html';
|
|
2
2
|
import { AbstractControl, AbstractInput, DeepPropType, ErrorObject, FormInputOptions, FormOptions, NestedKeyOf, UnwrapValue, ValidatorFn } from './form.tokens';
|
|
3
|
+
export interface AbstractInputWithBound extends AbstractInput {
|
|
4
|
+
_bound?: boolean;
|
|
5
|
+
}
|
|
3
6
|
export declare class FormGroup<T = FormInputOptions, E = {
|
|
4
7
|
[key: string]: never;
|
|
5
8
|
}> implements AbstractControl<UnwrapValue<T>> {
|
package/dist/form.group.js
CHANGED
|
@@ -162,7 +162,24 @@ class FormGroup {
|
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
if (this.type === 'number') {
|
|
165
|
-
|
|
165
|
+
let val = Number(value);
|
|
166
|
+
const maxAttr = this.getAttribute('max');
|
|
167
|
+
if (maxAttr) {
|
|
168
|
+
const max = Number(maxAttr);
|
|
169
|
+
if (!isNaN(max) && val > max) {
|
|
170
|
+
val = max;
|
|
171
|
+
this.value = String(val);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
const minAttr = this.getAttribute('min');
|
|
175
|
+
if (minAttr) {
|
|
176
|
+
const min = Number(minAttr);
|
|
177
|
+
if (!isNaN(min) && val < min) {
|
|
178
|
+
val = min;
|
|
179
|
+
this.value = String(val);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
value = val;
|
|
166
183
|
}
|
|
167
184
|
const inputsWithBindings = [
|
|
168
185
|
...(self
|
|
@@ -263,12 +280,15 @@ class FormGroup {
|
|
|
263
280
|
const attr = customAttributes.find((a) => a.name.startsWith('#'));
|
|
264
281
|
this.parentElement[attr.name.replace('#', '')] = el;
|
|
265
282
|
}
|
|
266
|
-
el.
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
283
|
+
if (!el._bound) {
|
|
284
|
+
el.addEventListener('blur', () => __awaiter(this, void 0, void 0, function* () {
|
|
285
|
+
this.setElementDirty(el);
|
|
286
|
+
yield this.parentElement.requestUpdate();
|
|
287
|
+
yield this.setElementValidity(el);
|
|
288
|
+
}));
|
|
289
|
+
el[strategy] = this.updateValueAndValidityOnEvent(el[strategy]);
|
|
290
|
+
el._bound = true;
|
|
291
|
+
}
|
|
272
292
|
return el;
|
|
273
293
|
});
|
|
274
294
|
}
|
|
@@ -313,8 +333,11 @@ class FormGroup {
|
|
|
313
333
|
validate(element) {
|
|
314
334
|
return __awaiter(this, void 0, void 0, function* () {
|
|
315
335
|
let errors = [];
|
|
316
|
-
element.setCustomValidity
|
|
317
|
-
|
|
336
|
+
if (typeof element.setCustomValidity === 'function') {
|
|
337
|
+
element.setCustomValidity('');
|
|
338
|
+
}
|
|
339
|
+
if (typeof element.checkValidity === 'function' &&
|
|
340
|
+
!element.checkValidity()) {
|
|
318
341
|
return {
|
|
319
342
|
errors: errors.concat(Object.keys(form_tokens_1.InputValidityState)
|
|
320
343
|
.map((key) => element.validity[key]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rxdi/forms",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.233",
|
|
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.232",
|
|
16
16
|
"@types/node": "^25.0.3",
|
|
17
17
|
"rxjs": "^7.8.2",
|
|
18
18
|
"typescript": "^5.9.3"
|