@ng-modular-forms/core 0.7.8 → 0.8.0
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 +19 -12
- package/fesm2022/ng-modular-forms-core.mjs +656 -122
- package/fesm2022/ng-modular-forms-core.mjs.map +1 -1
- package/lib/base/form-control-base.d.ts +28 -11
- package/lib/base/form-handler-base.d.ts +6 -9
- package/lib/behavior/lookup/lookup.behavior.d.ts +22 -0
- package/lib/{input/input-currency.component.d.ts → controls/currency/currency.component.d.ts} +2 -2
- package/lib/{input/input-datepicker.component.d.ts → controls/datepicker/datepicker.component.d.ts} +1 -1
- package/lib/{input → controls/form-field}/form-field.component.d.ts +3 -1
- package/lib/controls/lookup/lookup.component.d.ts +43 -0
- package/lib/controls/lookup/lookup.types.d.ts +17 -0
- package/lib/{input/input-number.component.d.ts → controls/number/number.component.d.ts} +3 -3
- package/lib/{input/input-select.component.d.ts → controls/select/select.component.d.ts} +5 -4
- package/lib/{input/input-text.component.d.ts → controls/text/text.component.d.ts} +3 -2
- package/lib/{input/input-textarea.component.d.ts → controls/textarea/textarea.component.d.ts} +2 -1
- package/lib/{input/input-timepicker.component.d.ts → controls/timepicker/timepicker.component.d.ts} +1 -1
- package/lib/form-orchestrator.d.ts +2 -2
- package/lib/types.d.ts +2 -2
- package/package.json +1 -1
- package/public-api.d.ts +12 -9
- /package/lib/behavior/{currency.behavior.d.ts → currency/currency.behavior.d.ts} +0 -0
- /package/lib/behavior/{text.behavior.d.ts → text/text.behavior.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -138,22 +138,23 @@ Encapsulates cross-field reactive behavior. Keeps UI logic out of the component.
|
|
|
138
138
|
|
|
139
139
|
```ts
|
|
140
140
|
import { Subscription } from 'rxjs';
|
|
141
|
-
import { FormHandlerBase
|
|
141
|
+
import { FormHandlerBase } from '@ng-modular-forms/core';
|
|
142
142
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
type Controls = {
|
|
144
|
+
'fieldA': FormControl<string>;
|
|
145
|
+
'fieldB': FormControl<string>;
|
|
146
|
+
}
|
|
146
147
|
|
|
147
148
|
@Injectable()
|
|
148
|
-
export class SectionAHandler extends FormHandlerBase<
|
|
149
|
+
export class SectionAHandler extends FormHandlerBase<Controls> {
|
|
149
150
|
override getReactiveLogic(form: FormGroup): Subscription {
|
|
150
|
-
this.
|
|
151
|
+
this.initializeForm(form);
|
|
151
152
|
|
|
152
153
|
const subscription = new Subscription();
|
|
153
154
|
|
|
154
155
|
subscription.add(
|
|
155
|
-
this.valueChangesOf
|
|
156
|
-
const fieldB = getControl
|
|
156
|
+
this.valueChangesOf('fieldA').subscribe((val) => {
|
|
157
|
+
const fieldB = this.getControl('fieldB', form);
|
|
157
158
|
|
|
158
159
|
val?.trim()
|
|
159
160
|
? fieldB.enable()
|
|
@@ -162,7 +163,7 @@ export class SectionAHandler extends FormHandlerBase<ControlNames> {
|
|
|
162
163
|
);
|
|
163
164
|
|
|
164
165
|
subscription.add(
|
|
165
|
-
this.valueChangesOf
|
|
166
|
+
this.valueChangesOf('fieldB').subscribe((val) => {
|
|
166
167
|
console.log('Field B changed:', val);
|
|
167
168
|
}),
|
|
168
169
|
);
|
|
@@ -180,9 +181,9 @@ Handles transformations between API and form. `FormHydrator` and `FormSerializer
|
|
|
180
181
|
import { FormMapperBase, getControlValue } from '@ng-modular-forms/core';
|
|
181
182
|
|
|
182
183
|
export class SectionAMapper extends FormMapperBase<
|
|
183
|
-
ApiModel, RequestModel, FormModel
|
|
184
|
+
ApiModel, RequestModel, FormModel, FormMapperOptions
|
|
184
185
|
> {
|
|
185
|
-
toRequest(form: FormGroup): RequestModel {
|
|
186
|
+
toRequest(form: FormGroup, _options?: FormMapperOptions): RequestModel {
|
|
186
187
|
const fieldAValue = getControlValue<string>('fieldA', form);
|
|
187
188
|
const fieldBValue = getControlValue<string>('fieldB', form);
|
|
188
189
|
return {
|
|
@@ -210,6 +211,11 @@ type ApiModel = {
|
|
|
210
211
|
type RequestModel = ApiModel;
|
|
211
212
|
type FormModel = ApiModel;
|
|
212
213
|
|
|
214
|
+
interface FormMapperOptions {
|
|
215
|
+
extraField1?: string;
|
|
216
|
+
extraField2?: string;
|
|
217
|
+
}
|
|
218
|
+
|
|
213
219
|
/**
|
|
214
220
|
* These are intentionally separated even if identical.
|
|
215
221
|
* In real applications:
|
|
@@ -363,12 +369,13 @@ All components share a consistent API and are interchangeable between Native and
|
|
|
363
369
|
| Input Type | Native Selector | Material Selector |
|
|
364
370
|
|-----------------|----------------------|-----------------------|
|
|
365
371
|
| Text / Password | `nmf-text` | `nmf-mat-text` |
|
|
372
|
+
| Lookup | `nmf-lookup` | `nmf-mat-lookup` |
|
|
366
373
|
| Number | `nmf-number` | `nmf-mat-number` |
|
|
367
374
|
| Currency | `nmf-currency` | `nmf-mat-currency` |
|
|
368
375
|
| Date | `nmf-datepicker` | `nmf-mat-datepicker` |
|
|
369
|
-
| Time | `nmf-timepicker` | `nmf-mat-timepicker` |
|
|
370
376
|
| Select | `nmf-select` | `nmf-mat-select` |
|
|
371
377
|
| Textarea | `nmf-textarea` | `nmf-mat-textarea` |
|
|
378
|
+
| Time | `nmf-timepicker` | `nmf-mat-timepicker` |
|
|
372
379
|
|
|
373
380
|
### Shared Features
|
|
374
381
|
|