@o3r/forms 12.3.0-prerelease.7 → 12.3.0-prerelease.70
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 +14 -78
- package/fesm2022/o3r-forms.mjs +24 -24
- package/package.json +5 -4
- package/schematics/ng-add/index.d.ts.map +1 -1
- package/schematics/ng-add/index.js +5 -13
package/README.md
CHANGED
|
@@ -12,7 +12,20 @@ This package is an [Otter Framework Module](https://github.com/AmadeusITGroup/ot
|
|
|
12
12
|
[](https://www.npmjs.com/package/@o3r/forms)
|
|
13
13
|
[](https://www.npmjs.com/package/@o3r/forms)
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
One of the approaches for writing forms that Angular provides is called [model-driven or reactive forms](https://angular.io/guide/reactive-forms),
|
|
16
|
+
which _"provide a model-driven approach to handling form inputs whose values change over time"_. This type of form is applicable in many use cases,
|
|
17
|
+
but there are a couple of exceptions where additional utilities may be useful.
|
|
18
|
+
|
|
19
|
+
These use cases include:
|
|
20
|
+
* A container/presenter structure for components
|
|
21
|
+
* Handling form submission at page level
|
|
22
|
+
* Displaying the error message outside the form
|
|
23
|
+
|
|
24
|
+
To handle these, this module provides utilities to enhance the build of Angular reactive forms, including:
|
|
25
|
+
* An asynchronous decorator (`@AsyncInput`) to ensure subscriptions are handled if the references of the input observables change.
|
|
26
|
+
* Basic and custom validators to validate user input for accuracy and completeness.
|
|
27
|
+
* A dedicated NgRX store for form errors to have the possibility of displaying error messages outside the form component.
|
|
28
|
+
* Helper functions to handle the interactions with the forms.
|
|
16
29
|
|
|
17
30
|
## How to install
|
|
18
31
|
|
|
@@ -23,83 +36,6 @@ ng add @o3r/forms
|
|
|
23
36
|
> [!WARNING]
|
|
24
37
|
> This module requires [@o3r/core](https://www.npmjs.com/package/@o3r/core) to be installed.
|
|
25
38
|
|
|
26
|
-
## Container/presenter and form creation
|
|
27
|
-
|
|
28
|
-
A Container/presenter architecture was put in place to ensure best reusability/sharing
|
|
29
|
-
|
|
30
|
-
### Where the form object creation should be done?
|
|
31
|
-
|
|
32
|
-
* **form created in presenter** - it's the presenter that decides how the data is displayed
|
|
33
|
-
* **container** only values and errors are propagated from the presenter
|
|
34
|
-
* **container** can set the default value
|
|
35
|
-
|
|
36
|
-
### How the container and presenter will communicate in forms context
|
|
37
|
-
|
|
38
|
-
* **presenter** implements [ControlValueAccessor](https://angular.io/api/forms/ControlValueAccessor) and [Validator](https://angular.io/api/forms/Validator) (or [AsyncValidator](https://angular.io/api/forms/AsyncValidator)) interfaces
|
|
39
|
-
* **propagate** the value, the form status and the errors
|
|
40
|
-
* **container** applies [FormControlDirective](https://angular.io/api/forms/FormControlDirective) on the presenter html tag
|
|
41
|
-
* **container** sets the default value using **formControl** directive
|
|
42
|
-
* **listen** to the value and status changes using the same directive
|
|
43
|
-
|
|
44
|
-
See [FORM_STRUCTURE](https://github.com/AmadeusITGroup/otter/tree/main/docs/forms/FORM_STRUCTURE.md)
|
|
45
|
-
|
|
46
|
-
## You want to include form validation and display the errors
|
|
47
|
-
|
|
48
|
-
* interfaces for the error messages provided in **@o3r/forms**
|
|
49
|
-
|
|
50
|
-
### Display inline errors
|
|
51
|
-
|
|
52
|
-
* the error messages returned by validators are used in the inline error display
|
|
53
|
-
* **simple/basic/primitive** validators - set as a configuration of the **presenter**
|
|
54
|
-
* localization of the associated error messages from the presenter
|
|
55
|
-
* the error object associated is computed here and has to be compliant with the store object model
|
|
56
|
-
* _getFlatControlErrors_ function is available in **@o3r/forms** to help with the creation of the associated error object
|
|
57
|
-
* **custom** validators created at container level
|
|
58
|
-
* localization of the associated error messages from the container
|
|
59
|
-
* custom validators are passed as an input to the presenter
|
|
60
|
-
* the error returned by the validator has to be compliant with the form error store model
|
|
61
|
-
|
|
62
|
-
### Display errors on a messages panel
|
|
63
|
-
|
|
64
|
-
* a dedicated _FormErrorStore_ is available on **@o3r/forms**
|
|
65
|
-
* allows the display of errors anywhere on the page
|
|
66
|
-
* the error object model contains the translation key and params
|
|
67
|
-
See [FORM_VALIDATION](https://github.com/AmadeusITGroup/otter/tree/main/docs/forms/FORM_VALIDATION.md) and [FORM_ERRORS](https://github.com/AmadeusITGroup/otter/tree/main/docs/forms/FORM_ERRORS.md)
|
|
68
|
-
|
|
69
|
-
## Form submit
|
|
70
|
-
|
|
71
|
-
### You want to submit the form
|
|
72
|
-
|
|
73
|
-
* The submit is triggered by the submit button **in the presenter** and an event is emitted
|
|
74
|
-
* **container** captures the event and executes the submit form logic
|
|
75
|
-
|
|
76
|
-
### What happens when you have multiple forms and you want to submit?
|
|
77
|
-
|
|
78
|
-
The answer is that we should avoid as much as possible having multiple form tags in the same page as it adds a lot of complexity. We should try to have only one _form_ tag that encapsulates everything and one submit action.
|
|
79
|
-
|
|
80
|
-
If multiple forms are really needed, then we found the following solution:
|
|
81
|
-
|
|
82
|
-
* the submit button is hidden on the presenters
|
|
83
|
-
* the **submit** is **triggered from the page**
|
|
84
|
-
* an **observable** to trigger the submit is passed as **input** to the containers;
|
|
85
|
-
* _AsyncInput_ decorator is provided in **@o3r/forms** to be applied on the observable input to ensure performance
|
|
86
|
-
* the submit form logic is executed on the containers
|
|
87
|
-
* containers emit events when the submit is done
|
|
88
|
-
* the page (parent) captures the events and continues its logic
|
|
89
|
-
|
|
90
|
-
This can be applied also, with only one form on the page, when you don't want a submit button in the presenter.
|
|
91
|
-
|
|
92
|
-
### What happens when the submit is triggered by the page with pristine forms
|
|
93
|
-
|
|
94
|
-
At the first display of the form, the inline errors (if the form is invalid) are not displayed because the form element is **not touched** and **dirty**
|
|
95
|
-
In case you want to show the inline errors after the submit, you have to:
|
|
96
|
-
|
|
97
|
-
* register a function in the container to _mark touched and dirty_ the form
|
|
98
|
-
* pass the function via an _@Output_ from the presenter and call it before executing the submit logic
|
|
99
|
-
* use _markAllControlsDirtyAndTouched_ helper is available in **@o3r/forms** to mark interactions on given form
|
|
100
|
-
|
|
101
|
-
See [FORM_SUBMIT&INTERCOMMUNICATION](https://github.com/AmadeusITGroup/otter/tree/main/docs/forms/FORM_SUBMIT_AND_INTERCOMMUNICATION.md)
|
|
102
|
-
|
|
103
39
|
## Details
|
|
104
40
|
|
|
105
41
|
Find more information in the [documentation](https://github.com/AmadeusITGroup/otter/tree/main/docs/forms).
|
package/fesm2022/o3r-forms.mjs
CHANGED
|
@@ -232,13 +232,13 @@ class FormErrorMessagesStoreModule {
|
|
|
232
232
|
]
|
|
233
233
|
};
|
|
234
234
|
}
|
|
235
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.
|
|
236
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.
|
|
237
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.
|
|
235
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: FormErrorMessagesStoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
236
|
+
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.8", ngImport: i0, type: FormErrorMessagesStoreModule, imports: [i1.StoreFeatureModule] }); }
|
|
237
|
+
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: FormErrorMessagesStoreModule, providers: [
|
|
238
238
|
{ provide: FORM_ERROR_MESSAGES_REDUCER_TOKEN, useFactory: getDefaultFormErrorMessagesReducer }
|
|
239
239
|
], imports: [StoreModule.forFeature(FORM_ERROR_MESSAGES_STORE_NAME, FORM_ERROR_MESSAGES_REDUCER_TOKEN)] }); }
|
|
240
240
|
}
|
|
241
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.
|
|
241
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: FormErrorMessagesStoreModule, decorators: [{
|
|
242
242
|
type: NgModule,
|
|
243
243
|
args: [{
|
|
244
244
|
imports: [
|
|
@@ -311,8 +311,8 @@ class MaxDateValidator {
|
|
|
311
311
|
};
|
|
312
312
|
return result;
|
|
313
313
|
}
|
|
314
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.
|
|
315
|
-
/** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.
|
|
314
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: MaxDateValidator, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
315
|
+
/** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.8", type: MaxDateValidator, isStandalone: true, selector: "[maxdate][formControlName],[maxdate][formControl],[maxdate][ngModel]", inputs: { maxdate: "maxdate" }, providers: [
|
|
316
316
|
{
|
|
317
317
|
provide: NG_VALIDATORS,
|
|
318
318
|
useExisting: forwardRef((() => MaxDateValidator)),
|
|
@@ -320,7 +320,7 @@ class MaxDateValidator {
|
|
|
320
320
|
}
|
|
321
321
|
], usesOnChanges: true, ngImport: i0 }); }
|
|
322
322
|
}
|
|
323
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.
|
|
323
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: MaxDateValidator, decorators: [{
|
|
324
324
|
type: Directive,
|
|
325
325
|
args: [{
|
|
326
326
|
selector: '[maxdate][formControlName],[maxdate][formControl],[maxdate][ngModel]',
|
|
@@ -381,8 +381,8 @@ class MinDateValidator {
|
|
|
381
381
|
};
|
|
382
382
|
return result;
|
|
383
383
|
}
|
|
384
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.
|
|
385
|
-
/** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.
|
|
384
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: MinDateValidator, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
385
|
+
/** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.8", type: MinDateValidator, isStandalone: true, selector: "[mindate][formControlName],[mindate][formControl],[mindate][ngModel]", inputs: { mindate: "mindate" }, providers: [
|
|
386
386
|
{
|
|
387
387
|
provide: NG_VALIDATORS,
|
|
388
388
|
useExisting: forwardRef((() => MinDateValidator)),
|
|
@@ -390,7 +390,7 @@ class MinDateValidator {
|
|
|
390
390
|
}
|
|
391
391
|
], usesOnChanges: true, ngImport: i0 }); }
|
|
392
392
|
}
|
|
393
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.
|
|
393
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: MinDateValidator, decorators: [{
|
|
394
394
|
type: Directive,
|
|
395
395
|
args: [{
|
|
396
396
|
selector: '[mindate][formControlName],[mindate][formControl],[mindate][ngModel]',
|
|
@@ -410,11 +410,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImpor
|
|
|
410
410
|
* @deprecated MaxDateValidator and MinDateValidator are now standalone, this module will be removed in v14
|
|
411
411
|
*/
|
|
412
412
|
class DateValidatorsModule {
|
|
413
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.
|
|
414
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.
|
|
415
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.
|
|
413
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: DateValidatorsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
414
|
+
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.8", ngImport: i0, type: DateValidatorsModule, imports: [CommonModule, MaxDateValidator, MinDateValidator], exports: [MaxDateValidator, MinDateValidator] }); }
|
|
415
|
+
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: DateValidatorsModule, imports: [CommonModule] }); }
|
|
416
416
|
}
|
|
417
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.
|
|
417
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: DateValidatorsModule, decorators: [{
|
|
418
418
|
type: NgModule,
|
|
419
419
|
args: [{
|
|
420
420
|
imports: [CommonModule, MaxDateValidator, MinDateValidator],
|
|
@@ -456,8 +456,8 @@ class MaxValidator {
|
|
|
456
456
|
registerOnValidatorChange(fn) {
|
|
457
457
|
this.onChange = fn;
|
|
458
458
|
}
|
|
459
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.
|
|
460
|
-
/** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.
|
|
459
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: MaxValidator, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
460
|
+
/** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.8", type: MaxValidator, isStandalone: true, selector: "[max][formControlName],[max][formControl],[max][ngModel]", inputs: { max: "max" }, host: { properties: { "attr.max": "max ? max : null" } }, providers: [
|
|
461
461
|
{
|
|
462
462
|
provide: NG_VALIDATORS,
|
|
463
463
|
useExisting: forwardRef((() => MaxValidator)),
|
|
@@ -465,7 +465,7 @@ class MaxValidator {
|
|
|
465
465
|
}
|
|
466
466
|
], usesOnChanges: true, ngImport: i0 }); }
|
|
467
467
|
}
|
|
468
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.
|
|
468
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: MaxValidator, decorators: [{
|
|
469
469
|
type: Directive,
|
|
470
470
|
args: [{
|
|
471
471
|
selector: '[max][formControlName],[max][formControl],[max][ngModel]',
|
|
@@ -516,8 +516,8 @@ class MinValidator {
|
|
|
516
516
|
registerOnValidatorChange(fn) {
|
|
517
517
|
this.onChange = fn;
|
|
518
518
|
}
|
|
519
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.
|
|
520
|
-
/** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.
|
|
519
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: MinValidator, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
520
|
+
/** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.8", type: MinValidator, isStandalone: true, selector: "[min][formControlName],[min][formControl],[min][ngModel]", inputs: { min: "min" }, host: { properties: { "attr.min": "min ? min : null" } }, providers: [
|
|
521
521
|
{
|
|
522
522
|
provide: NG_VALIDATORS,
|
|
523
523
|
useExisting: forwardRef((() => MinValidator)),
|
|
@@ -525,7 +525,7 @@ class MinValidator {
|
|
|
525
525
|
}
|
|
526
526
|
], usesOnChanges: true, ngImport: i0 }); }
|
|
527
527
|
}
|
|
528
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.
|
|
528
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: MinValidator, decorators: [{
|
|
529
529
|
type: Directive,
|
|
530
530
|
args: [{
|
|
531
531
|
selector: '[min][formControlName],[min][formControl],[min][ngModel]',
|
|
@@ -546,11 +546,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImpor
|
|
|
546
546
|
* @deprecated MaxValidator and MinValidator are now standalone, this module will be removed in v14
|
|
547
547
|
*/
|
|
548
548
|
class NumberValidatorsModule {
|
|
549
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.
|
|
550
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.
|
|
551
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.
|
|
549
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: NumberValidatorsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
550
|
+
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.8", ngImport: i0, type: NumberValidatorsModule, imports: [CommonModule, MaxValidator, MinValidator], exports: [MaxValidator, MinValidator] }); }
|
|
551
|
+
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: NumberValidatorsModule, imports: [CommonModule] }); }
|
|
552
552
|
}
|
|
553
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.
|
|
553
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: NumberValidatorsModule, decorators: [{
|
|
554
554
|
type: NgModule,
|
|
555
555
|
args: [{
|
|
556
556
|
imports: [CommonModule, MaxValidator, MinValidator],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@o3r/forms",
|
|
3
|
-
"version": "12.3.0-prerelease.
|
|
3
|
+
"version": "12.3.0-prerelease.70",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -11,15 +11,15 @@
|
|
|
11
11
|
"otter-module"
|
|
12
12
|
],
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"@ama-sdk/core": "^12.3.0-prerelease.
|
|
14
|
+
"@ama-sdk/core": "^12.3.0-prerelease.70",
|
|
15
15
|
"@angular-devkit/schematics": "^19.0.0",
|
|
16
16
|
"@angular/common": "^19.0.0",
|
|
17
17
|
"@angular/core": "^19.0.0",
|
|
18
18
|
"@angular/forms": "^19.0.0",
|
|
19
19
|
"@ngrx/entity": "^19.0.0",
|
|
20
20
|
"@ngrx/store": "^19.0.0",
|
|
21
|
-
"@o3r/core": "^12.3.0-prerelease.
|
|
22
|
-
"@o3r/schematics": "^12.3.0-prerelease.
|
|
21
|
+
"@o3r/core": "^12.3.0-prerelease.70",
|
|
22
|
+
"@o3r/schematics": "^12.3.0-prerelease.70",
|
|
23
23
|
"@schematics/angular": "^19.0.0",
|
|
24
24
|
"rxjs": "^7.8.1",
|
|
25
25
|
"ts-node": "~10.9.2"
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
+
"@o3r/schematics": "^12.3.0-prerelease.70",
|
|
39
40
|
"tslib": "^2.6.2"
|
|
40
41
|
},
|
|
41
42
|
"engines": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,IAAI,EACL,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,IAAI,EACL,MAAM,4BAA4B,CAAC;AAMpC,OAAO,KAAK,EACV,qBAAqB,EACtB,MAAM,UAAU,CAAC;AAkBlB;;;GAGG;AACH,eAAO,MAAM,KAAK,GAAI,SAAS,qBAAqB,SAA2C,CAAC"}
|
|
@@ -2,23 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ngAdd = void 0;
|
|
4
4
|
const path = require("node:path");
|
|
5
|
+
const schematics_1 = require("@o3r/schematics");
|
|
5
6
|
const packageJsonPath = path.resolve(__dirname, '..', '..', 'package.json');
|
|
6
|
-
const reportMissingSchematicsDep = (logger) => (reason) => {
|
|
7
|
-
logger.error(`[ERROR]: Adding @o3r/form has failed.
|
|
8
|
-
You need to install '@o3r/core' package to be able to use the form package. Please run 'ng add @o3r/core'.`);
|
|
9
|
-
throw reason;
|
|
10
|
-
};
|
|
11
7
|
/**
|
|
12
8
|
* Add Otter forms to an Angular Project
|
|
13
9
|
* @param options
|
|
14
10
|
*/
|
|
15
11
|
function ngAddFn(options) {
|
|
16
12
|
/* ng add rules */
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
return setupDependencies({
|
|
13
|
+
return (tree) => {
|
|
14
|
+
return (0, schematics_1.setupDependencies)({
|
|
20
15
|
projectName: options.projectName,
|
|
21
|
-
dependencies: getPackageInstallConfig(packageJsonPath, tree, options.projectName, false, !!options.exactO3rVersion)
|
|
16
|
+
dependencies: (0, schematics_1.getPackageInstallConfig)(packageJsonPath, tree, options.projectName, false, !!options.exactO3rVersion)
|
|
22
17
|
});
|
|
23
18
|
};
|
|
24
19
|
}
|
|
@@ -26,9 +21,6 @@ function ngAddFn(options) {
|
|
|
26
21
|
* Add Otter forms to an Angular Project
|
|
27
22
|
* @param options
|
|
28
23
|
*/
|
|
29
|
-
const ngAdd = (options) =>
|
|
30
|
-
const { createOtterSchematic } = await Promise.resolve().then(() => require('@o3r/schematics')).catch(reportMissingSchematicsDep(logger));
|
|
31
|
-
return createOtterSchematic(ngAddFn)(options);
|
|
32
|
-
};
|
|
24
|
+
const ngAdd = (options) => (0, schematics_1.createOtterSchematic)(ngAddFn)(options);
|
|
33
25
|
exports.ngAdd = ngAdd;
|
|
34
26
|
//# sourceMappingURL=index.js.map
|