@rxdi/forms 0.7.231 → 0.7.232

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.
@@ -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].setParentElement(this).setOptions(options).prepareValues();
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
  }
@@ -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>> {
@@ -263,12 +263,15 @@ class FormGroup {
263
263
  const attr = customAttributes.find((a) => a.name.startsWith('#'));
264
264
  this.parentElement[attr.name.replace('#', '')] = el;
265
265
  }
266
- el.addEventListener('blur', () => __awaiter(this, void 0, void 0, function* () {
267
- this.setElementDirty(el);
268
- yield this.parentElement.requestUpdate();
269
- yield this.setElementValidity(el);
270
- }));
271
- el[strategy] = this.updateValueAndValidityOnEvent(el[strategy]);
266
+ if (!el._bound) {
267
+ el.addEventListener('blur', () => __awaiter(this, void 0, void 0, function* () {
268
+ this.setElementDirty(el);
269
+ yield this.parentElement.requestUpdate();
270
+ yield this.setElementValidity(el);
271
+ }));
272
+ el[strategy] = this.updateValueAndValidityOnEvent(el[strategy]);
273
+ el._bound = true;
274
+ }
272
275
  return el;
273
276
  });
274
277
  }
@@ -313,8 +316,11 @@ class FormGroup {
313
316
  validate(element) {
314
317
  return __awaiter(this, void 0, void 0, function* () {
315
318
  let errors = [];
316
- element.setCustomValidity('');
317
- if (!element.checkValidity()) {
319
+ if (typeof element.setCustomValidity === 'function') {
320
+ element.setCustomValidity('');
321
+ }
322
+ if (typeof element.checkValidity === 'function' &&
323
+ !element.checkValidity()) {
318
324
  return {
319
325
  errors: errors.concat(Object.keys(form_tokens_1.InputValidityState)
320
326
  .map((key) => element.validity[key]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rxdi/forms",
3
- "version": "0.7.231",
3
+ "version": "0.7.232",
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.230",
15
+ "@rxdi/lit-html": "^0.7.231",
16
16
  "@types/node": "^25.0.3",
17
17
  "rxjs": "^7.8.2",
18
18
  "typescript": "^5.9.3"