@ngrdt/forms 0.0.61 → 0.0.63

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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { inject, Injector, signal, input, model, linkedSignal, booleanAttribute, computed, effect, untracked, Directive, InjectionToken, forwardRef, output, numberAttribute, ElementRef, Pipe } from '@angular/core';
2
+ import { inject, Injector, signal, model, linkedSignal, input, booleanAttribute, computed, effect, untracked, Directive, InjectionToken, forwardRef, output, numberAttribute, ElementRef, Pipe } from '@angular/core';
3
3
  import { takeUntilDestroyed, toSignal, toObservable } from '@angular/core/rxjs-interop';
4
4
  import { FormControlName, FormControlDirective, NgModel, NgControl, Validators, NG_VALUE_ACCESSOR, FormControl, FormGroup } from '@angular/forms';
5
5
  import { RdtInteractiveElementComponent, RdtComponentOutletDirective } from '@ngrdt/core';
@@ -32,13 +32,16 @@ class RdtBaseFormInputComponent extends RdtInteractiveElementComponent {
32
32
  injector = inject(Injector);
33
33
  _control = signal(null);
34
34
  control = this._control.asReadonly();
35
- label = input('');
36
- placeholder = input('');
37
- name = input('');
38
35
  externalValue = model(null, { alias: 'value' });
39
36
  internalValue = linkedSignal(() => this.toInternalValue(this.externalValue()));
40
37
  dataTestIdInput = input(undefined, { alias: 'dataTestId' });
41
38
  dataTestId = linkedSignal(() => this.dataTestIdInput() ?? this.label() ?? '');
39
+ labelInput = input('', { alias: 'label' });
40
+ label = linkedSignal(() => this.labelInput() ?? '');
41
+ placeholderInput = input('', { alias: 'placeholder' });
42
+ placeholder = linkedSignal(() => this.placeholderInput() ?? '');
43
+ nameInput = input('', { alias: 'name' });
44
+ name = linkedSignal(() => this.nameInput() ?? '');
42
45
  readonlyInput = input(null, {
43
46
  alias: 'readonly',
44
47
  transform: booleanAttribute,
@@ -70,7 +73,7 @@ class RdtBaseFormInputComponent extends RdtInteractiveElementComponent {
70
73
  return control.statusReactive() === 'INVALID';
71
74
  }
72
75
  else {
73
- return false;
76
+ return !!this.additionalErrors();
74
77
  }
75
78
  });
76
79
  requiredEffect = effect(() => {
@@ -88,7 +91,8 @@ class RdtBaseFormInputComponent extends RdtInteractiveElementComponent {
88
91
  return null;
89
92
  }
90
93
  });
91
- errors = computed(() => this.controlErrors() ?? this.requiredError());
94
+ additionalErrors = signal(null);
95
+ errors = computed(() => this.controlErrors() ?? this.requiredError() ?? this.additionalErrors());
92
96
  visibleErrors = computed(() => this.invalid() && this.touched() ? this.errors() : null);
93
97
  get ngControl() {
94
98
  return this._ngControl;
@@ -156,6 +160,14 @@ class RdtBaseFormInputComponent extends RdtInteractiveElementComponent {
156
160
  this.onChange(externalValue);
157
161
  }
158
162
  }
163
+ setAdditionalErrors(errors) {
164
+ if (errors === null || Object.keys(errors).length === 0) {
165
+ this.additionalErrors.set(null);
166
+ }
167
+ else {
168
+ this.additionalErrors.set(errors);
169
+ }
170
+ }
159
171
  listenControlEvents(control) {
160
172
  control.events
161
173
  .pipe(startWith(null), takeUntilDestroyed(this.destroyRef))
@@ -182,7 +194,7 @@ class RdtBaseFormInputComponent extends RdtInteractiveElementComponent {
182
194
  }
183
195
  static REQUIRED_ERROR = { required: true };
184
196
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: RdtBaseFormInputComponent, deps: null, target: i0.ɵɵFactoryTarget.Directive });
185
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.0.0", type: RdtBaseFormInputComponent, isStandalone: true, inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, externalValue: { classPropertyName: "externalValue", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, dataTestIdInput: { classPropertyName: "dataTestIdInput", publicName: "dataTestId", isSignal: true, isRequired: false, transformFunction: null }, readonlyInput: { classPropertyName: "readonlyInput", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, requiredInput: { classPropertyName: "requiredInput", publicName: "required", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { externalValue: "valueChange" }, usesInheritance: true, ngImport: i0 });
197
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.0.0", type: RdtBaseFormInputComponent, isStandalone: true, inputs: { externalValue: { classPropertyName: "externalValue", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, dataTestIdInput: { classPropertyName: "dataTestIdInput", publicName: "dataTestId", isSignal: true, isRequired: false, transformFunction: null }, labelInput: { classPropertyName: "labelInput", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, placeholderInput: { classPropertyName: "placeholderInput", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, nameInput: { classPropertyName: "nameInput", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, readonlyInput: { classPropertyName: "readonlyInput", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, requiredInput: { classPropertyName: "requiredInput", publicName: "required", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { externalValue: "valueChange" }, usesInheritance: true, ngImport: i0 });
186
198
  }
187
199
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: RdtBaseFormInputComponent, decorators: [{
188
200
  type: Directive,