@rxap/forms 14.1.0-dev.0 → 16.0.0-dev.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/esm2022/lib/directives/form-control-error.directive.mjs +60 -0
- package/esm2022/lib/directives/form-control-mark-dirty.directive.mjs +32 -0
- package/esm2022/lib/directives/form-control-mark-pristine.directive.mjs +32 -0
- package/esm2022/lib/directives/form-control-mark-touched.directive.mjs +25 -0
- package/esm2022/lib/directives/form-control-mark-untouched.directive.mjs +32 -0
- package/esm2022/lib/directives/form-control-name.directive.mjs +65 -0
- package/esm2022/lib/directives/form-group-name.directive.mjs +62 -0
- package/esm2022/lib/directives/form-loaded.directive.mjs +42 -0
- package/esm2022/lib/directives/form-loading-error.directive.mjs +42 -0
- package/esm2022/lib/directives/form-loading.directive.mjs +42 -0
- package/esm2022/lib/directives/form-submit-failed.directive.mjs +42 -0
- package/esm2022/lib/directives/form-submit-invalid.directive.mjs +40 -0
- package/esm2022/lib/directives/form-submit-successful.directive.mjs +40 -0
- package/esm2022/lib/directives/form-submit.directive.mjs +79 -0
- package/esm2022/lib/directives/form-submitting.directive.mjs +42 -0
- package/esm2022/lib/directives/form.directive.mjs +552 -0
- package/esm2022/lib/directives/forms.module.mjs +101 -0
- package/esm2022/lib/directives/parent-control-container.directive.mjs +26 -0
- package/esm2022/lib/form-array.mjs +252 -0
- package/esm2022/lib/form-control.mjs +169 -0
- package/esm2022/lib/form-group.mjs +201 -0
- package/esm2022/lib/model.mjs +2 -0
- package/esm2022/lib/types.mjs +2 -0
- package/{esm2020 → esm2022}/lib/validators/is-complex.mjs +1 -1
- package/{fesm2020 → fesm2022}/rxap-forms.mjs +244 -238
- package/fesm2022/rxap-forms.mjs.map +1 -0
- package/lib/directives/form-control-error.directive.d.ts +1 -1
- package/lib/directives/form-control-mark-dirty.directive.d.ts +1 -1
- package/lib/directives/form-control-mark-pristine.directive.d.ts +1 -1
- package/lib/directives/form-control-mark-touched.directive.d.ts +1 -1
- package/lib/directives/form-control-mark-untouched.directive.d.ts +1 -1
- package/lib/directives/form-control-name.directive.d.ts +1 -1
- package/lib/directives/form-group-name.directive.d.ts +1 -1
- package/lib/directives/form-loaded.directive.d.ts +1 -1
- package/lib/directives/form-loading-error.directive.d.ts +1 -1
- package/lib/directives/form-loading.directive.d.ts +1 -1
- package/lib/directives/form-submit-failed.directive.d.ts +1 -1
- package/lib/directives/form-submit-invalid.directive.d.ts +1 -1
- package/lib/directives/form-submit-successful.directive.d.ts +1 -1
- package/lib/directives/form-submit.directive.d.ts +1 -1
- package/lib/directives/form-submitting.directive.d.ts +1 -1
- package/lib/directives/form.directive.d.ts +2 -2
- package/lib/directives/parent-control-container.directive.d.ts +1 -1
- package/lib/form-group.d.ts +2 -2
- package/lib/model.d.ts +9 -9
- package/lib/types.d.ts +17 -17
- package/migration.json +10 -0
- package/package.json +20 -25
- package/src/migrations/v12-2-1/index.d.ts +5 -0
- package/src/migrations/v12-2-1/index.js +76 -0
- package/src/migrations/v12-2-1/index.js.map +1 -0
- package/esm2020/lib/directives/form-control-error.directive.mjs +0 -59
- package/esm2020/lib/directives/form-control-mark-dirty.directive.mjs +0 -31
- package/esm2020/lib/directives/form-control-mark-pristine.directive.mjs +0 -31
- package/esm2020/lib/directives/form-control-mark-touched.directive.mjs +0 -24
- package/esm2020/lib/directives/form-control-mark-untouched.directive.mjs +0 -31
- package/esm2020/lib/directives/form-control-name.directive.mjs +0 -64
- package/esm2020/lib/directives/form-group-name.directive.mjs +0 -61
- package/esm2020/lib/directives/form-loaded.directive.mjs +0 -41
- package/esm2020/lib/directives/form-loading-error.directive.mjs +0 -41
- package/esm2020/lib/directives/form-loading.directive.mjs +0 -41
- package/esm2020/lib/directives/form-submit-failed.directive.mjs +0 -41
- package/esm2020/lib/directives/form-submit-invalid.directive.mjs +0 -39
- package/esm2020/lib/directives/form-submit-successful.directive.mjs +0 -39
- package/esm2020/lib/directives/form-submit.directive.mjs +0 -78
- package/esm2020/lib/directives/form-submitting.directive.mjs +0 -41
- package/esm2020/lib/directives/form.directive.mjs +0 -551
- package/esm2020/lib/directives/forms.module.mjs +0 -100
- package/esm2020/lib/directives/parent-control-container.directive.mjs +0 -25
- package/esm2020/lib/form-array.mjs +0 -252
- package/esm2020/lib/form-control.mjs +0 -169
- package/esm2020/lib/form-group.mjs +0 -195
- package/esm2020/lib/model.mjs +0 -2
- package/esm2020/lib/types.mjs +0 -2
- package/fesm2015/rxap-forms.mjs +0 -2814
- package/fesm2015/rxap-forms.mjs.map +0 -1
- package/fesm2020/rxap-forms.mjs.map +0 -1
- /package/{esm2020 → esm2022}/index.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/control-actions.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/control-value-accessor.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/decorators/control-async-validator.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/decorators/control-change.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/decorators/control-set-value.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/decorators/control-validator.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/decorators/form.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/decorators/metadata-keys.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/decorators/use-form-array.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/decorators/use-form-control.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/decorators/use-form-group.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/directives/models.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/directives/tokens.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/form-builder.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/tokens.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/validators/index.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/validators/is-array.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/validators/is-boolean.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/validators/is-date.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/validators/is-email.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/validators/is-enum.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/validators/is-int.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/validators/is-ip.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/validators/is-number.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/validators/is-object.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/validators/is-phone-number.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/validators/is-port.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/validators/is-string.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/validators/is-url.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/validators/is-uuid.mjs +0 -0
- /package/{esm2020 → esm2022}/rxap-forms.mjs +0 -0
package/fesm2015/rxap-forms.mjs
DELETED
|
@@ -1,2814 +0,0 @@
|
|
|
1
|
-
import * as i1 from '@angular/forms';
|
|
2
|
-
import { UntypedFormArray, AbstractControl, UntypedFormGroup, UntypedFormControl, Validators, FormGroupDirective, ControlContainer, FormGroupName, NG_VALIDATORS, NG_ASYNC_VALIDATORS, FormControlName, NG_VALUE_ACCESSOR, NgControl } from '@angular/forms';
|
|
3
|
-
import { map, distinctUntilChanged, debounceTime, filter, tap, startWith, take } from 'rxjs/operators';
|
|
4
|
-
import { merge, defer, of, EMPTY, Subject, isObservable, BehaviorSubject, Subscription } from 'rxjs';
|
|
5
|
-
import { equals, coerceArray, HasRxapOnInitMethod, assertIsArray, assertIsObject, assertIsFunction, isPromise, isObject, clone, Required, hasIndexSignature, coerceBoolean } from '@rxap/utilities';
|
|
6
|
-
import * as i0 from '@angular/core';
|
|
7
|
-
import { isDevMode, Injector, InjectionToken, EventEmitter, ChangeDetectorRef, forwardRef, Directive, Inject, Optional, SkipSelf, Input, Output, HostBinding, TemplateRef, ViewContainerRef, Host, HostListener, Self, NgModule } from '@angular/core';
|
|
8
|
-
import { GetDefinitionMetadata, DefinitionMetadata } from '@rxap/definition';
|
|
9
|
-
import { getMetadata, setMetadataMapSet, setMetadataMap } from '@rxap/utilities/reflect-metadata';
|
|
10
|
-
import { __decorate, __metadata } from 'tslib';
|
|
11
|
-
import * as i2 from '@rxap/services';
|
|
12
|
-
import { LoadingIndicatorService } from '@rxap/services';
|
|
13
|
-
import { ToggleSubject } from '@rxap/utilities/rxjs';
|
|
14
|
-
import * as i2$1 from '@angular/router';
|
|
15
|
-
import { Router } from '@angular/router';
|
|
16
|
-
import { ConfirmClick } from '@rxap/directives';
|
|
17
|
-
import { isMobilePhone, isEmail, isURL, isIP, isPort, isUUID } from '@rxap/validator';
|
|
18
|
-
|
|
19
|
-
function getControlValue(control) {
|
|
20
|
-
if (control.getRawValue) {
|
|
21
|
-
return control.getRawValue();
|
|
22
|
-
}
|
|
23
|
-
return control.value;
|
|
24
|
-
}
|
|
25
|
-
function controlValueChanges$(control) {
|
|
26
|
-
return merge(defer(() => of(getControlValue(control))), control.valueChanges.pipe(map(() => getControlValue(control))));
|
|
27
|
-
}
|
|
28
|
-
function controlDisabled$(control) {
|
|
29
|
-
var _a;
|
|
30
|
-
return merge(defer(() => of(control.disabled)), merge(control.statusChanges, (_a = control.stateChanges) !== null && _a !== void 0 ? _a : EMPTY).pipe(map(() => control.disabled), distinctUntilChanged()));
|
|
31
|
-
}
|
|
32
|
-
function controlEnabled$(control) {
|
|
33
|
-
var _a;
|
|
34
|
-
return merge(defer(() => of(control.enabled)), merge(control.statusChanges, (_a = control.stateChanges) !== null && _a !== void 0 ? _a : EMPTY).pipe(map(() => control.enabled), distinctUntilChanged()));
|
|
35
|
-
}
|
|
36
|
-
function controlReadonly$(control) {
|
|
37
|
-
var _a;
|
|
38
|
-
return merge(defer(() => { var _a; return of((_a = control.readonly) !== null && _a !== void 0 ? _a : false); }), merge(control.statusChanges, (_a = control.stateChanges) !== null && _a !== void 0 ? _a : EMPTY).pipe(map(() => { var _a; return (_a = control.readonly) !== null && _a !== void 0 ? _a : false; }), distinctUntilChanged()));
|
|
39
|
-
}
|
|
40
|
-
function controlStatusChanges$(control) {
|
|
41
|
-
return merge(defer(() => of(control.status)), control.statusChanges.pipe(map(() => control.status), distinctUntilChanged()));
|
|
42
|
-
}
|
|
43
|
-
function controlErrorChanges$(control) {
|
|
44
|
-
return merge(defer(() => of(control.errors)), control.valueChanges.pipe(map(() => control.errors)), control.statusChanges.pipe(map(() => control.errors))).pipe(distinctUntilChanged((a, b) => equals(a, b)));
|
|
45
|
-
}
|
|
46
|
-
function enableControl(control, enabled, opts) {
|
|
47
|
-
if (enabled) {
|
|
48
|
-
control.enable(opts);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
control.disable(opts);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function disableControl(control, disabled, opts) {
|
|
55
|
-
enableControl(control, !disabled, opts);
|
|
56
|
-
}
|
|
57
|
-
function controlDisabledWhile(control, observable, opts) {
|
|
58
|
-
return observable.subscribe(isDisabled => disableControl(control, isDisabled, opts));
|
|
59
|
-
}
|
|
60
|
-
function controlEnabledWhile(control, observable, opts) {
|
|
61
|
-
return observable.subscribe(isEnabled => enableControl(control, isEnabled, opts));
|
|
62
|
-
}
|
|
63
|
-
function mergeControlValidators(control, validators) {
|
|
64
|
-
control.setValidators([...coerceArray(control.validator), ...coerceArray(validators)]);
|
|
65
|
-
control.updateValueAndValidity();
|
|
66
|
-
}
|
|
67
|
-
function validateControlOn(control, validation) {
|
|
68
|
-
return validation.subscribe(maybeError => {
|
|
69
|
-
control.setErrors(maybeError);
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
function hasErrorAndTouched(control, error, path) {
|
|
73
|
-
const hasError = control.hasError(error, !path || path.length === 0 ? undefined : path);
|
|
74
|
-
return hasError && control.touched;
|
|
75
|
-
}
|
|
76
|
-
function hasErrorAndDirty(control, error, path) {
|
|
77
|
-
const hasError = control.hasError(error, !path || path.length === 0 ? undefined : path);
|
|
78
|
-
return hasError && control.dirty;
|
|
79
|
-
}
|
|
80
|
-
function markAllDirty(control) {
|
|
81
|
-
control.markAsDirty({ onlySelf: true });
|
|
82
|
-
control._forEachChild((_control) => _control.markAllAsDirty());
|
|
83
|
-
}
|
|
84
|
-
function markAllPristine(control) {
|
|
85
|
-
control.markAsPristine({ onlySelf: true });
|
|
86
|
-
control._forEachChild((_control) => _control.markAllAsPristine());
|
|
87
|
-
}
|
|
88
|
-
function markAllUntouched(control) {
|
|
89
|
-
control.markAsUntouched({ onlySelf: true });
|
|
90
|
-
control._forEachChild((_control) => _control.markAllAsUntouched());
|
|
91
|
-
}
|
|
92
|
-
function selectControlValue$(control, mapFn) {
|
|
93
|
-
return control.value$.pipe(map(mapFn), distinctUntilChanged());
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
class RxapFormArray extends UntypedFormArray {
|
|
97
|
-
constructor(controls, options) {
|
|
98
|
-
super(controls, options);
|
|
99
|
-
this.controls = controls;
|
|
100
|
-
this._readonly = false;
|
|
101
|
-
this.value$ = controlValueChanges$(this);
|
|
102
|
-
this.disabled$ = controlDisabled$(this);
|
|
103
|
-
this.enabled$ = controlEnabled$(this);
|
|
104
|
-
this.status$ = controlStatusChanges$(this);
|
|
105
|
-
this.errors$ = controlErrorChanges$(this);
|
|
106
|
-
this.touchChanges = new Subject();
|
|
107
|
-
this.touch$ = this.touchChanges
|
|
108
|
-
.asObservable()
|
|
109
|
-
.pipe(distinctUntilChanged());
|
|
110
|
-
this.dirtyChanges = new Subject();
|
|
111
|
-
this.dirty$ = this.dirtyChanges
|
|
112
|
-
.asObservable()
|
|
113
|
-
.pipe(distinctUntilChanged());
|
|
114
|
-
this.controlId = options.controlId;
|
|
115
|
-
this._builder = options.builder;
|
|
116
|
-
this._controlInsertedFn = options.controlInsertedFn;
|
|
117
|
-
this._controlRemovedFn = options.controlRemovedFn;
|
|
118
|
-
}
|
|
119
|
-
get readonly() {
|
|
120
|
-
var _a, _b;
|
|
121
|
-
return (_b = (_a = this.parent) === null || _a === void 0 ? void 0 : _a.readonly) !== null && _b !== void 0 ? _b : this._readonly;
|
|
122
|
-
}
|
|
123
|
-
set readonly(value) {
|
|
124
|
-
this._readonly = value;
|
|
125
|
-
this.controls.forEach(control => { var _a; return (_a = control.stateChanges) === null || _a === void 0 ? void 0 : _a.next(); });
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* @internal
|
|
129
|
-
*/
|
|
130
|
-
get rxapFormDefinition() {
|
|
131
|
-
return this.parent.rxapFormDefinition;
|
|
132
|
-
}
|
|
133
|
-
get controlPath() {
|
|
134
|
-
const parent = this.parent;
|
|
135
|
-
if (parent) {
|
|
136
|
-
if (parent.controlPath) {
|
|
137
|
-
if (parent === this.root) {
|
|
138
|
-
return this.controlId;
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
return [parent.controlPath, this.controlId].join('.');
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return this.controlId;
|
|
146
|
-
}
|
|
147
|
-
get fullControlPath() {
|
|
148
|
-
const parent = this.parent;
|
|
149
|
-
if (parent) {
|
|
150
|
-
if (parent.fullControlPath) {
|
|
151
|
-
return [parent.fullControlPath, this.controlId].join('.');
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
return this.controlId;
|
|
155
|
-
}
|
|
156
|
-
select(mapFn) {
|
|
157
|
-
return this.value$.pipe(map(mapFn), distinctUntilChanged());
|
|
158
|
-
}
|
|
159
|
-
at(index) {
|
|
160
|
-
return super.at(index);
|
|
161
|
-
}
|
|
162
|
-
getRawValue() {
|
|
163
|
-
return super.getRawValue();
|
|
164
|
-
}
|
|
165
|
-
insert(index, control) {
|
|
166
|
-
if (isDevMode()) {
|
|
167
|
-
console.warn('It is not recommend to use the FormArray.insert method');
|
|
168
|
-
}
|
|
169
|
-
return super.insert(index, control);
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* inserts a new control at the specified index. If the index is undefined
|
|
173
|
-
* the new control will be added to the end.
|
|
174
|
-
*
|
|
175
|
-
* @param index (optional) the index where the control should be created
|
|
176
|
-
* @param state (optional) the initial state of the new control
|
|
177
|
-
* @param options (optional) ControlEventOptions
|
|
178
|
-
*/
|
|
179
|
-
insertAt(index, state, options) {
|
|
180
|
-
const insertIndex = index !== null && index !== void 0 ? index : this.controls.length;
|
|
181
|
-
const controlOrDefinition = this._builder(state, {
|
|
182
|
-
controlId: insertIndex.toFixed(0),
|
|
183
|
-
});
|
|
184
|
-
this._controlInsertedFn(insertIndex, controlOrDefinition);
|
|
185
|
-
if (insertIndex < this.controls.length) {
|
|
186
|
-
// update the control ids for all controls, that are moved.
|
|
187
|
-
for (let i = insertIndex; i < this.controls.length; i++) {
|
|
188
|
-
Reflect.set(this.controls[i], 'controlId', (i + 1).toFixed(0));
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
// call the super insert after the update, bc the insert method will
|
|
192
|
-
// trigger a change detection
|
|
193
|
-
if (controlOrDefinition instanceof AbstractControl) {
|
|
194
|
-
super.insert(insertIndex, controlOrDefinition, options);
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
super.insert(insertIndex, controlOrDefinition.rxapFormGroup, options);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
disabledWhile(observable, options) {
|
|
201
|
-
return controlDisabledWhile(this, observable, options);
|
|
202
|
-
}
|
|
203
|
-
enabledWhile(observable, options) {
|
|
204
|
-
return controlEnabledWhile(this, observable, options);
|
|
205
|
-
}
|
|
206
|
-
mergeValidators(validators) {
|
|
207
|
-
mergeControlValidators(this, validators);
|
|
208
|
-
}
|
|
209
|
-
mergeAsyncValidators(validators) {
|
|
210
|
-
this.setAsyncValidators([
|
|
211
|
-
...coerceArray(this.asyncValidator),
|
|
212
|
-
...coerceArray(validators),
|
|
213
|
-
]);
|
|
214
|
-
this.updateValueAndValidity();
|
|
215
|
-
}
|
|
216
|
-
markAllAsDirty() {
|
|
217
|
-
markAllDirty(this);
|
|
218
|
-
}
|
|
219
|
-
markAllAsPristine() {
|
|
220
|
-
markAllPristine(this);
|
|
221
|
-
}
|
|
222
|
-
setValue(valueOrObservable, options) {
|
|
223
|
-
if (isObservable(valueOrObservable)) {
|
|
224
|
-
return valueOrObservable.subscribe((value) => {
|
|
225
|
-
super.setValue(value, options);
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
super.setValue(valueOrObservable, options);
|
|
229
|
-
}
|
|
230
|
-
markAllAsUntouched() {
|
|
231
|
-
markAllUntouched(this);
|
|
232
|
-
}
|
|
233
|
-
validateOn(observableValidation) {
|
|
234
|
-
return observableValidation.subscribe((maybeError) => {
|
|
235
|
-
this.setErrors(maybeError);
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
hasErrorAndTouched(errorCode, path) {
|
|
239
|
-
return hasErrorAndTouched(this, errorCode, path);
|
|
240
|
-
}
|
|
241
|
-
_patchValue(value, options) {
|
|
242
|
-
// Even though the `value` argument type doesn't allow `null` and `undefined` values, the
|
|
243
|
-
// `patchValue` can be called recursively and inner data structures might have these values, so
|
|
244
|
-
// we just ignore such cases when a field containing FormArray instance receives `null` or
|
|
245
|
-
// `undefined` as a value.
|
|
246
|
-
if (value == null /* both `null` and `undefined` */)
|
|
247
|
-
return;
|
|
248
|
-
if (options === null || options === void 0 ? void 0 : options.strict) {
|
|
249
|
-
if (this.length > value.length) {
|
|
250
|
-
for (let index = this.length - 1; index >= value.length; index--) {
|
|
251
|
-
this.removeAt(index);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
value.forEach((newValue, index) => {
|
|
256
|
-
if (this.at(index)) {
|
|
257
|
-
this.at(index).patchValue(newValue, Object.assign(Object.assign({}, (options !== null && options !== void 0 ? options : {})), { onlySelf: true }));
|
|
258
|
-
}
|
|
259
|
-
else if (options === null || options === void 0 ? void 0 : options.coerce) {
|
|
260
|
-
this.insertAt(index, value[index]);
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
this.updateValueAndValidity(options);
|
|
264
|
-
}
|
|
265
|
-
patchValue(valueOrObservable, options) {
|
|
266
|
-
if (isObservable(valueOrObservable)) {
|
|
267
|
-
return valueOrObservable.subscribe((value) => {
|
|
268
|
-
this._patchValue(value, options);
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
this._patchValue(valueOrObservable, options);
|
|
272
|
-
}
|
|
273
|
-
hasErrorAndDirty(errorCode, path) {
|
|
274
|
-
return hasErrorAndDirty(this, errorCode, path);
|
|
275
|
-
}
|
|
276
|
-
removeAt(index) {
|
|
277
|
-
if (isDevMode()) {
|
|
278
|
-
console.warn('It is not recommend to use the FormArray.removeAt method');
|
|
279
|
-
}
|
|
280
|
-
super.removeAt(index);
|
|
281
|
-
this._controlRemovedFn(index);
|
|
282
|
-
}
|
|
283
|
-
setEnable(enable = true, opts) {
|
|
284
|
-
enableControl(this, enable, opts);
|
|
285
|
-
}
|
|
286
|
-
push(control, options) {
|
|
287
|
-
if (isDevMode()) {
|
|
288
|
-
console.warn('It is not recommend to use the FormArray.push method');
|
|
289
|
-
}
|
|
290
|
-
return super.push(control, options);
|
|
291
|
-
}
|
|
292
|
-
setDisable(disable = true, opts) {
|
|
293
|
-
disableControl(this, disable, opts);
|
|
294
|
-
}
|
|
295
|
-
setControl(index, control, options) {
|
|
296
|
-
if (isDevMode()) {
|
|
297
|
-
console.warn('It is not recommend to use the FormArray.setControl method');
|
|
298
|
-
}
|
|
299
|
-
return super.setControl(index, control, options);
|
|
300
|
-
}
|
|
301
|
-
markAsTouched(opts) {
|
|
302
|
-
super.markAsTouched(opts);
|
|
303
|
-
this.touchChanges.next(true);
|
|
304
|
-
}
|
|
305
|
-
markAsUntouched(opts) {
|
|
306
|
-
super.markAsUntouched(opts);
|
|
307
|
-
this.touchChanges.next(false);
|
|
308
|
-
}
|
|
309
|
-
markAsPristine(opts) {
|
|
310
|
-
super.markAsPristine(opts);
|
|
311
|
-
this.dirtyChanges.next(false);
|
|
312
|
-
}
|
|
313
|
-
markAsDirty(opts) {
|
|
314
|
-
super.markAsDirty(opts);
|
|
315
|
-
this.dirtyChanges.next(true);
|
|
316
|
-
}
|
|
317
|
-
reset(value, options) {
|
|
318
|
-
super.reset(value, options);
|
|
319
|
-
}
|
|
320
|
-
setValidators(newValidator, updateValueAndValidity = true) {
|
|
321
|
-
super.setValidators(newValidator);
|
|
322
|
-
if (updateValueAndValidity) {
|
|
323
|
-
super.updateValueAndValidity();
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
setAsyncValidators(newValidator, updateValueAndValidity = true) {
|
|
327
|
-
super.setAsyncValidators(newValidator);
|
|
328
|
-
if (updateValueAndValidity) {
|
|
329
|
-
super.updateValueAndValidity();
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
hasError(errorCode, path) {
|
|
333
|
-
return super.hasError(errorCode, path);
|
|
334
|
-
}
|
|
335
|
-
setErrors(errors, opts = {}) {
|
|
336
|
-
return super.setErrors(errors, opts);
|
|
337
|
-
}
|
|
338
|
-
getError(errorCode, path) {
|
|
339
|
-
return super.getError(errorCode, path);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
var MetadataKeys;
|
|
344
|
-
(function (MetadataKeys) {
|
|
345
|
-
MetadataKeys["CONTROL_VALIDATORS"] = "rxap/forms/control-validators";
|
|
346
|
-
MetadataKeys["CONTROL_ASYNC_VALIDATORS"] = "rxap/forms/control-async-validators";
|
|
347
|
-
MetadataKeys["CONTROL_CHANGES"] = "rxap/forms/control-changes";
|
|
348
|
-
MetadataKeys["CONTROL_SET_VALUE"] = "rxap/forms/control-set-value";
|
|
349
|
-
MetadataKeys["FORM_ARRAY_GROUPS"] = "rxap/forms/form-array-groups";
|
|
350
|
-
MetadataKeys["FORM_ARRAY_CONTROLS"] = "rxap/forms/form-array-controls";
|
|
351
|
-
MetadataKeys["FORM_GROUPS"] = "rxap/forms/form-groups";
|
|
352
|
-
MetadataKeys["FORM_CONTROLS"] = "rxap/forms/form-controls";
|
|
353
|
-
})(MetadataKeys || (MetadataKeys = {}));
|
|
354
|
-
|
|
355
|
-
class RxapFormGroup extends UntypedFormGroup {
|
|
356
|
-
constructor(controls, options) {
|
|
357
|
-
super(controls, options);
|
|
358
|
-
this.controls = controls;
|
|
359
|
-
this._readonly = false;
|
|
360
|
-
this.touchChanges = new Subject();
|
|
361
|
-
this.dirtyChanges = new Subject();
|
|
362
|
-
this.touch$ = this.touchChanges.asObservable().pipe(distinctUntilChanged());
|
|
363
|
-
this.dirty$ = this.dirtyChanges.asObservable().pipe(distinctUntilChanged());
|
|
364
|
-
this.value$ = controlValueChanges$(this);
|
|
365
|
-
this.disabled$ = controlDisabled$(this);
|
|
366
|
-
this.enabled$ = controlEnabled$(this);
|
|
367
|
-
this.status$ = controlStatusChanges$(this);
|
|
368
|
-
this.errors$ = controlErrorChanges$(this);
|
|
369
|
-
this.controlId = options.controlId;
|
|
370
|
-
}
|
|
371
|
-
/**
|
|
372
|
-
* @internal
|
|
373
|
-
*/
|
|
374
|
-
get rxapFormDefinition() {
|
|
375
|
-
if (!this.parent) {
|
|
376
|
-
return this._rxapFormDefinition;
|
|
377
|
-
}
|
|
378
|
-
if (this._rxapFormDefinition) {
|
|
379
|
-
return this._rxapFormDefinition;
|
|
380
|
-
}
|
|
381
|
-
return this.parent.rxapFormDefinition;
|
|
382
|
-
}
|
|
383
|
-
get readonly() {
|
|
384
|
-
var _a, _b;
|
|
385
|
-
return (_b = (_a = this.parent) === null || _a === void 0 ? void 0 : _a.readonly) !== null && _b !== void 0 ? _b : this._readonly;
|
|
386
|
-
}
|
|
387
|
-
set readonly(value) {
|
|
388
|
-
var _a;
|
|
389
|
-
this._readonly = value;
|
|
390
|
-
Object.values((_a = this.controls) !== null && _a !== void 0 ? _a : {}).forEach(control => { var _a; return (_a = control.stateChanges) === null || _a === void 0 ? void 0 : _a.next(); });
|
|
391
|
-
}
|
|
392
|
-
get controlPath() {
|
|
393
|
-
const parent = this.parent;
|
|
394
|
-
if (parent) {
|
|
395
|
-
if (parent.controlPath) {
|
|
396
|
-
if (parent === this.root) {
|
|
397
|
-
return this.controlId;
|
|
398
|
-
}
|
|
399
|
-
else {
|
|
400
|
-
return [parent.controlPath, this.controlId].join('.');
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
return '';
|
|
405
|
-
}
|
|
406
|
-
get fullControlPath() {
|
|
407
|
-
const parent = this.parent;
|
|
408
|
-
if (parent) {
|
|
409
|
-
if (parent.fullControlPath) {
|
|
410
|
-
return [parent.fullControlPath, this.controlId].join('.');
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
return this.controlId;
|
|
414
|
-
}
|
|
415
|
-
select(mapFn) {
|
|
416
|
-
return selectControlValue$(this, mapFn);
|
|
417
|
-
}
|
|
418
|
-
getRawValue() {
|
|
419
|
-
return super.getRawValue();
|
|
420
|
-
}
|
|
421
|
-
get(path) {
|
|
422
|
-
return super.get(path);
|
|
423
|
-
}
|
|
424
|
-
getControl(...names) {
|
|
425
|
-
return this.get(names.join('.'));
|
|
426
|
-
}
|
|
427
|
-
addControl(name, control) {
|
|
428
|
-
super.addControl(name, control);
|
|
429
|
-
}
|
|
430
|
-
removeControl(name) {
|
|
431
|
-
super.removeControl(name);
|
|
432
|
-
}
|
|
433
|
-
contains(controlName) {
|
|
434
|
-
return super.contains(controlName);
|
|
435
|
-
}
|
|
436
|
-
setControl(name, control) {
|
|
437
|
-
super.setControl(name, control);
|
|
438
|
-
}
|
|
439
|
-
setValue(valueOrObservable, options) {
|
|
440
|
-
if (isObservable(valueOrObservable)) {
|
|
441
|
-
return valueOrObservable.subscribe((value) => super.setValue(value, options));
|
|
442
|
-
}
|
|
443
|
-
super.setValue(valueOrObservable, options);
|
|
444
|
-
}
|
|
445
|
-
_patchValue(value, options) {
|
|
446
|
-
// Even though the `value` argument type doesn't allow `null` and `undefined` values, the
|
|
447
|
-
// `patchValue` can be called recursively and inner data structures might have these values, so
|
|
448
|
-
// we just ignore such cases when a field containing FormGroup instance receives `null` or
|
|
449
|
-
// `undefined` as a value.
|
|
450
|
-
if (value == null /* both `null` and `undefined` */)
|
|
451
|
-
return;
|
|
452
|
-
Object.keys(value).forEach(name => {
|
|
453
|
-
if (this.controls[name]) {
|
|
454
|
-
this.controls[name].patchValue(value[name], Object.assign(Object.assign({}, (options !== null && options !== void 0 ? options : {})), { onlySelf: true }));
|
|
455
|
-
}
|
|
456
|
-
});
|
|
457
|
-
this.updateValueAndValidity(options);
|
|
458
|
-
}
|
|
459
|
-
patchValue(valueOrObservable, options) {
|
|
460
|
-
if (isObservable(valueOrObservable)) {
|
|
461
|
-
return valueOrObservable.subscribe((value) => this._patchValue(value, options));
|
|
462
|
-
}
|
|
463
|
-
this._patchValue(valueOrObservable, options);
|
|
464
|
-
}
|
|
465
|
-
disabledWhile(observable, options) {
|
|
466
|
-
return controlDisabledWhile(this, observable, options);
|
|
467
|
-
}
|
|
468
|
-
enabledWhile(observable, options) {
|
|
469
|
-
return controlEnabledWhile(this, observable, options);
|
|
470
|
-
}
|
|
471
|
-
mergeValidators(validators) {
|
|
472
|
-
mergeControlValidators(this, validators);
|
|
473
|
-
}
|
|
474
|
-
mergeAsyncValidators(validators) {
|
|
475
|
-
this.setAsyncValidators([
|
|
476
|
-
...coerceArray(this.asyncValidator),
|
|
477
|
-
...coerceArray(validators),
|
|
478
|
-
]);
|
|
479
|
-
this.updateValueAndValidity();
|
|
480
|
-
}
|
|
481
|
-
markAsTouched(opts) {
|
|
482
|
-
super.markAsTouched(opts);
|
|
483
|
-
this.touchChanges.next(true);
|
|
484
|
-
}
|
|
485
|
-
markAsUntouched(opts) {
|
|
486
|
-
super.markAsUntouched(opts);
|
|
487
|
-
this.touchChanges.next(false);
|
|
488
|
-
}
|
|
489
|
-
markAsPristine(opts) {
|
|
490
|
-
super.markAsPristine(opts);
|
|
491
|
-
this.dirtyChanges.next(false);
|
|
492
|
-
}
|
|
493
|
-
markAsDirty(opts) {
|
|
494
|
-
super.markAsDirty(opts);
|
|
495
|
-
this.dirtyChanges.next(true);
|
|
496
|
-
}
|
|
497
|
-
markAllAsDirty() {
|
|
498
|
-
markAllDirty(this);
|
|
499
|
-
}
|
|
500
|
-
markAllAsPristine() {
|
|
501
|
-
markAllPristine(this);
|
|
502
|
-
}
|
|
503
|
-
markAllAsUntouched() {
|
|
504
|
-
markAllUntouched(this);
|
|
505
|
-
}
|
|
506
|
-
reset(formState, options) {
|
|
507
|
-
super.reset(formState, options);
|
|
508
|
-
}
|
|
509
|
-
setValidators(newValidator, updateValueAndValidity = true) {
|
|
510
|
-
super.setValidators(newValidator);
|
|
511
|
-
if (updateValueAndValidity) {
|
|
512
|
-
super.updateValueAndValidity();
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
setAsyncValidators(newValidator, updateValueAndValidity = true) {
|
|
516
|
-
super.setAsyncValidators(newValidator);
|
|
517
|
-
if (updateValueAndValidity) {
|
|
518
|
-
super.updateValueAndValidity();
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
validateOn(observableValidation) {
|
|
522
|
-
return validateControlOn(this, observableValidation);
|
|
523
|
-
}
|
|
524
|
-
hasError(errorCode, path) {
|
|
525
|
-
return super.hasError(errorCode, path);
|
|
526
|
-
}
|
|
527
|
-
setErrors(errors, opts = {}) {
|
|
528
|
-
return super.setErrors(errors, opts);
|
|
529
|
-
}
|
|
530
|
-
getError(errorCode, path) {
|
|
531
|
-
return super.getError(errorCode, path);
|
|
532
|
-
}
|
|
533
|
-
hasErrorAndTouched(error, ...path) {
|
|
534
|
-
return hasErrorAndTouched(this, error, ...path);
|
|
535
|
-
}
|
|
536
|
-
hasErrorAndDirty(error, ...path) {
|
|
537
|
-
return hasErrorAndDirty(this, error, ...path);
|
|
538
|
-
}
|
|
539
|
-
setEnable(enable = true, opts) {
|
|
540
|
-
enableControl(this, enable, opts);
|
|
541
|
-
}
|
|
542
|
-
setDisable(disable = true, opts) {
|
|
543
|
-
disableControl(this, disable, opts);
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
class RxapFormControl extends UntypedFormControl {
|
|
548
|
-
constructor(formState, options) {
|
|
549
|
-
super(formState, options);
|
|
550
|
-
this._readonly = false;
|
|
551
|
-
this.touchChanges = new Subject();
|
|
552
|
-
this.dirtyChanges = new Subject();
|
|
553
|
-
this.touch$ = this.touchChanges
|
|
554
|
-
.asObservable()
|
|
555
|
-
.pipe(distinctUntilChanged());
|
|
556
|
-
this.dirty$ = this.dirtyChanges
|
|
557
|
-
.asObservable()
|
|
558
|
-
.pipe(distinctUntilChanged());
|
|
559
|
-
this.value$ = controlValueChanges$(this);
|
|
560
|
-
this.disabled$ = controlDisabled$(this);
|
|
561
|
-
this.enabled$ = controlEnabled$(this);
|
|
562
|
-
this.status$ = controlStatusChanges$(this);
|
|
563
|
-
this.errors$ = controlErrorChanges$(this);
|
|
564
|
-
this._onSetValue = [];
|
|
565
|
-
this.stateChanges = new Subject();
|
|
566
|
-
this.readonly$ = controlReadonly$(this);
|
|
567
|
-
this.controlId = options.controlId;
|
|
568
|
-
this.initialState = formState;
|
|
569
|
-
}
|
|
570
|
-
/**
|
|
571
|
-
* @internal
|
|
572
|
-
*/
|
|
573
|
-
get rxapFormDefinition() {
|
|
574
|
-
return this.parent.rxapFormDefinition;
|
|
575
|
-
}
|
|
576
|
-
get readonly() {
|
|
577
|
-
var _a, _b;
|
|
578
|
-
return (_b = (_a = this.parent) === null || _a === void 0 ? void 0 : _a.readonly) !== null && _b !== void 0 ? _b : this._readonly;
|
|
579
|
-
}
|
|
580
|
-
set readonly(value) {
|
|
581
|
-
this._readonly = value;
|
|
582
|
-
this.stateChanges.next();
|
|
583
|
-
}
|
|
584
|
-
get controlPath() {
|
|
585
|
-
const parent = this.parent;
|
|
586
|
-
if (parent) {
|
|
587
|
-
if (parent.controlPath) {
|
|
588
|
-
if (parent === this.root) {
|
|
589
|
-
return this.controlId;
|
|
590
|
-
}
|
|
591
|
-
else {
|
|
592
|
-
return [parent.controlPath, this.controlId].join('.');
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
return this.controlId;
|
|
597
|
-
}
|
|
598
|
-
get fullControlPath() {
|
|
599
|
-
const parent = this.parent;
|
|
600
|
-
if (parent) {
|
|
601
|
-
if (parent.fullControlPath) {
|
|
602
|
-
return [parent.fullControlPath, this.controlId].join('.');
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
return this.controlId;
|
|
606
|
-
}
|
|
607
|
-
setValue(valueOrObservable, options) {
|
|
608
|
-
if (isObservable(valueOrObservable)) {
|
|
609
|
-
return valueOrObservable.subscribe((value) => {
|
|
610
|
-
super.setValue(value, options);
|
|
611
|
-
this._onSetValue.forEach((setValueFn) => setValueFn(value, options));
|
|
612
|
-
});
|
|
613
|
-
}
|
|
614
|
-
super.setValue(valueOrObservable, options);
|
|
615
|
-
this._onSetValue.forEach((setValueFn) => setValueFn(valueOrObservable, options));
|
|
616
|
-
}
|
|
617
|
-
patchValue(valueOrObservable, options) {
|
|
618
|
-
if (isObservable(valueOrObservable)) {
|
|
619
|
-
return valueOrObservable.subscribe((value) => super.patchValue(value, options));
|
|
620
|
-
}
|
|
621
|
-
super.patchValue(valueOrObservable, options);
|
|
622
|
-
}
|
|
623
|
-
disabledWhile(observable, options) {
|
|
624
|
-
return controlDisabledWhile(this, observable, options);
|
|
625
|
-
}
|
|
626
|
-
enabledWhile(observable, options) {
|
|
627
|
-
return controlEnabledWhile(this, observable, options);
|
|
628
|
-
}
|
|
629
|
-
mergeValidators(validators) {
|
|
630
|
-
mergeControlValidators(this, validators);
|
|
631
|
-
}
|
|
632
|
-
mergeAsyncValidators(validators) {
|
|
633
|
-
this.setAsyncValidators([
|
|
634
|
-
// TODO : remove 'as any' if solution for the type overwrite issue is found (above)
|
|
635
|
-
this.asyncValidator,
|
|
636
|
-
...coerceArray(validators),
|
|
637
|
-
]);
|
|
638
|
-
this.updateValueAndValidity();
|
|
639
|
-
}
|
|
640
|
-
markAsTouched(opts) {
|
|
641
|
-
super.markAsTouched(opts);
|
|
642
|
-
this.touchChanges.next(true);
|
|
643
|
-
}
|
|
644
|
-
markAsUntouched(opts) {
|
|
645
|
-
super.markAsUntouched(opts);
|
|
646
|
-
this.touchChanges.next(false);
|
|
647
|
-
}
|
|
648
|
-
markAsPristine(opts) {
|
|
649
|
-
super.markAsPristine(opts);
|
|
650
|
-
this.dirtyChanges.next(false);
|
|
651
|
-
}
|
|
652
|
-
markAsDirty(opts) {
|
|
653
|
-
super.markAsDirty(opts);
|
|
654
|
-
this.dirtyChanges.next(true);
|
|
655
|
-
}
|
|
656
|
-
markAllAsDirty() {
|
|
657
|
-
this.markAsDirty({ onlySelf: true });
|
|
658
|
-
}
|
|
659
|
-
reset(formState, options) {
|
|
660
|
-
const newState = formState !== null && formState !== void 0 ? formState : this.initialState;
|
|
661
|
-
if (typeof newState === 'function') {
|
|
662
|
-
super.reset(newState(), options);
|
|
663
|
-
}
|
|
664
|
-
else {
|
|
665
|
-
super.reset(newState, options);
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
setValidators(newValidator, updateValueAndValidity = true) {
|
|
669
|
-
super.setValidators(newValidator);
|
|
670
|
-
if (updateValueAndValidity) {
|
|
671
|
-
super.updateValueAndValidity();
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
setAsyncValidators(newValidator, updateValueAndValidity = true) {
|
|
675
|
-
super.setAsyncValidators(newValidator);
|
|
676
|
-
if (updateValueAndValidity) {
|
|
677
|
-
super.updateValueAndValidity();
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
validateOn(observableValidation) {
|
|
681
|
-
return validateControlOn(this, observableValidation);
|
|
682
|
-
}
|
|
683
|
-
getError(errorCode) {
|
|
684
|
-
return super.getError(errorCode);
|
|
685
|
-
}
|
|
686
|
-
hasError(errorCode) {
|
|
687
|
-
return super.hasError(errorCode);
|
|
688
|
-
}
|
|
689
|
-
setErrors(errors, opts = {}) {
|
|
690
|
-
return super.setErrors(errors, opts);
|
|
691
|
-
}
|
|
692
|
-
setError(key, value, opts = {}) {
|
|
693
|
-
super.setErrors({ [key]: value }, opts);
|
|
694
|
-
}
|
|
695
|
-
hasErrorAndTouched(error) {
|
|
696
|
-
return hasErrorAndTouched(this, error);
|
|
697
|
-
}
|
|
698
|
-
hasErrorAndDirty(error) {
|
|
699
|
-
return hasErrorAndDirty(this, error);
|
|
700
|
-
}
|
|
701
|
-
setEnable(enable = true, opts) {
|
|
702
|
-
enableControl(this, enable, opts);
|
|
703
|
-
}
|
|
704
|
-
setDisable(disable = true, opts) {
|
|
705
|
-
disableControl(this, disable, opts);
|
|
706
|
-
}
|
|
707
|
-
registerOnSetValue(setValueFn) {
|
|
708
|
-
this._onSetValue.push(setValueFn);
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
class FormArrayControlManager {
|
|
713
|
-
constructor(form, controlId) {
|
|
714
|
-
this.form = form;
|
|
715
|
-
this.controlId = controlId;
|
|
716
|
-
}
|
|
717
|
-
inserted(index, controlOrDefinition) {
|
|
718
|
-
const controlContainer = this.form[this.controlId];
|
|
719
|
-
if (Array.isArray(controlContainer)) {
|
|
720
|
-
controlContainer.splice(index, 0, controlOrDefinition);
|
|
721
|
-
}
|
|
722
|
-
else {
|
|
723
|
-
throw new Error('Could not register inserted control or definition. The control id does not points to an array of control or definition instance!');
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
removed(index) {
|
|
727
|
-
const controlContainer = this.form[this.controlId];
|
|
728
|
-
if (Array.isArray(controlContainer)) {
|
|
729
|
-
controlContainer.splice(index, 1);
|
|
730
|
-
}
|
|
731
|
-
else {
|
|
732
|
-
throw new Error('Could not register inserted control or definition. The control id does not points to an array of control or definition instance!');
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
class RxapFormBuilder {
|
|
737
|
-
constructor(definition, injector = Injector.NULL, providers = []) {
|
|
738
|
-
var _a;
|
|
739
|
-
this.definition = definition;
|
|
740
|
-
this.injector = injector;
|
|
741
|
-
this.formArrayGroups = this.extractArrayGroups();
|
|
742
|
-
this.formArrayControls = this.extractArrayControls();
|
|
743
|
-
this.formControls = this.extractControls();
|
|
744
|
-
this.formGroups = this.extractGroups();
|
|
745
|
-
this.validators = this.extractValidators();
|
|
746
|
-
this.asyncValidators = this.extractAsyncValidators();
|
|
747
|
-
this.controlChanges = this.extractControlChanges();
|
|
748
|
-
this.controlSetValue = this.extractControlSetValue();
|
|
749
|
-
const formOptions = (this.formOptions = this.extractFormOptions());
|
|
750
|
-
// merge the providers from the from options with the providers from the
|
|
751
|
-
// constructor. If the provider is defined in the form options and constructor
|
|
752
|
-
// then the provider from the constructor will be used.
|
|
753
|
-
this.providers = [...providers, ...((_a = formOptions.providers) !== null && _a !== void 0 ? _a : [])].filter((provider, index, self) => provider.hasOwnProperty('provide') &&
|
|
754
|
-
self.findIndex((selfProvider) => selfProvider.hasOwnProperty('provide') &&
|
|
755
|
-
selfProvider.provide === provider.provide) === index);
|
|
756
|
-
}
|
|
757
|
-
build(state = {}, options = {}) {
|
|
758
|
-
var _a, _b;
|
|
759
|
-
const injector = Injector.create({
|
|
760
|
-
name: `rxap/form-builder/${this.formOptions.id}`,
|
|
761
|
-
parent: this.injector,
|
|
762
|
-
providers: this.providers
|
|
763
|
-
});
|
|
764
|
-
let form;
|
|
765
|
-
// don't use the notFoundValue feature of the injector.
|
|
766
|
-
// if used for each call of the get method an "empty" or "fallback"
|
|
767
|
-
// instance is created
|
|
768
|
-
try {
|
|
769
|
-
form = injector.get(this.definition);
|
|
770
|
-
}
|
|
771
|
-
catch (e) {
|
|
772
|
-
if (isDevMode()) {
|
|
773
|
-
console.error(`Could not inject the definition instance. Fallback and call the constructor of the definition class: ${e.message}`);
|
|
774
|
-
}
|
|
775
|
-
form = new this.definition();
|
|
776
|
-
}
|
|
777
|
-
const controls = {};
|
|
778
|
-
this.buildControls(state, form, controls);
|
|
779
|
-
this.buildGroups(state, form, controls);
|
|
780
|
-
this.buildArrayGroups(state, form, controls);
|
|
781
|
-
this.buildArrayControls(state, form, controls);
|
|
782
|
-
const formOptions = Object.assign(Object.assign(Object.assign({}, this.formOptions), { controlId: (_a = options.controlId) !== null && _a !== void 0 ? _a : (options.id ? options.id : this.formOptions.id) }), options);
|
|
783
|
-
form.rxapFormGroup = new RxapFormGroup(controls, formOptions);
|
|
784
|
-
Reflect.set(form.rxapFormGroup, '_rxapFormDefinition', form);
|
|
785
|
-
form.rxapMetadata = this.formOptions;
|
|
786
|
-
if (HasRxapOnInitMethod(form)) {
|
|
787
|
-
form.rxapOnInit();
|
|
788
|
-
}
|
|
789
|
-
for (const control of Object.values(form.rxapFormGroup.controls)) {
|
|
790
|
-
if (control.controlId) {
|
|
791
|
-
const controlSetValueOnInit = Array.from((_b = this.controlSetValue.get(control.controlId)) !== null && _b !== void 0 ? _b : []).filter((controlSetValueOptions) => controlSetValueOptions.initial);
|
|
792
|
-
for (const onSetValue of this.coerceToFnArray(form, controlSetValueOnInit)) {
|
|
793
|
-
onSetValue(control.value, { initial: true });
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
return form;
|
|
798
|
-
}
|
|
799
|
-
buildArrayControls(builderFormState, form, controls) {
|
|
800
|
-
for (const [controlId, options] of this.formArrayControls.entries()) {
|
|
801
|
-
const formState = this.coerceToArrayFormState(controlId, [], builderFormState, options.state);
|
|
802
|
-
assertIsArray(formState);
|
|
803
|
-
const formControls = formState.map((fs, index) => new RxapFormControl(fs, { controlId: index.toFixed(0) }));
|
|
804
|
-
const manager = new FormArrayControlManager(form, controlId);
|
|
805
|
-
const formArray = (formControls.rxapFormArray =
|
|
806
|
-
controls[controlId] =
|
|
807
|
-
new RxapFormArray(
|
|
808
|
-
// TODO : add the formControlOptions property. To definition the form control options
|
|
809
|
-
formControls, Object.assign(Object.assign({}, options), { controlId, validators: [], asyncValidators: [], controlInsertedFn: manager.inserted.bind(manager), controlRemovedFn: manager.removed.bind(manager), builder: (state, controlOptions) => new RxapFormControl(state, controlOptions) })));
|
|
810
|
-
// TODO : add support for injectable validators
|
|
811
|
-
formArray.setValidators(this.coerceToValidatorArray(form, options.validators, this.validators.get(controlId)), false);
|
|
812
|
-
formArray.setAsyncValidators(this.coerceToValidatorArray(form, options.asyncValidators, this.asyncValidators.get(controlId)), false);
|
|
813
|
-
Reflect.set(form, controlId, formControls);
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
buildArrayGroups(builderFormState, form, controls) {
|
|
817
|
-
for (const [controlId, options] of this.formArrayGroups.entries()) {
|
|
818
|
-
const formState = this.coerceToArrayFormState(controlId, [], builderFormState, options.state);
|
|
819
|
-
assertIsArray(formState);
|
|
820
|
-
const formGroupBuilder = new RxapFormBuilder(options.definition, this.injector, this.providers);
|
|
821
|
-
// TODO : add the formGroupOptions property. To definition of the form group options
|
|
822
|
-
const formGroupDefinitions = formState.map((fs, index) => formGroupBuilder.build(fs, { id: index.toFixed(0) }));
|
|
823
|
-
const manager = new FormArrayControlManager(form, controlId);
|
|
824
|
-
const formArray = (formGroupDefinitions.rxapFormArray =
|
|
825
|
-
controls[controlId] =
|
|
826
|
-
new RxapFormArray(formGroupDefinitions.map((fgd) => fgd.rxapFormGroup), Object.assign(Object.assign({}, options), { builder: formGroupBuilder.build.bind(formGroupBuilder), controlId, validators: [], asyncValidators: [], controlInsertedFn: manager.inserted.bind(manager), controlRemovedFn: manager.removed.bind(manager) })));
|
|
827
|
-
// TODO : add support for injectable validators
|
|
828
|
-
formArray.setValidators(this.coerceToValidatorArray(form, options.validators, this.validators.get(controlId)), false);
|
|
829
|
-
formArray.setAsyncValidators(this.coerceToValidatorArray(form, options.asyncValidators, this.asyncValidators.get(controlId)), false);
|
|
830
|
-
Reflect.set(form, controlId, formGroupDefinitions);
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
buildGroups(builderFormState, form, controls) {
|
|
834
|
-
for (const [controlId, options] of this.formGroups.entries()) {
|
|
835
|
-
const formState = this.coerceToGroupFormState(controlId, {}, builderFormState, options.state);
|
|
836
|
-
assertIsObject(formState);
|
|
837
|
-
const formGroupDefinition = new RxapFormBuilder(options.definition, this.injector, this.providers).build(formState, Object.assign(Object.assign({}, options), { validators: [], asyncValidators: [] }));
|
|
838
|
-
controls[controlId] = formGroupDefinition.rxapFormGroup;
|
|
839
|
-
const formGroup = formGroupDefinition.rxapFormGroup;
|
|
840
|
-
// TODO : add support for injectable validators
|
|
841
|
-
formGroup.setValidators(this.coerceToValidatorArray(form, options.validators, this.validators.get(controlId)), false);
|
|
842
|
-
formGroup.setAsyncValidators(this.coerceToValidatorArray(form, options.asyncValidators, this.asyncValidators.get(controlId)), false);
|
|
843
|
-
// set the form group definition instance to the form definition instance
|
|
844
|
-
Reflect.set(form, controlId, formGroupDefinition);
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
buildControls(builderFormState, form, controls) {
|
|
848
|
-
var _a, _b;
|
|
849
|
-
for (const [controlId, options] of this.formControls.entries()) {
|
|
850
|
-
const control = (controls[controlId] = new ((_a = options.controlType) !== null && _a !== void 0 ? _a : RxapFormControl)(this.coerceToControlFormState(controlId, null, builderFormState, options.state), Object.assign(Object.assign({}, options), { controlId, validators: [], asyncValidators: [] })));
|
|
851
|
-
const injectValidators = [];
|
|
852
|
-
const injectAsyncValidators = [];
|
|
853
|
-
for (const injectValidator of (_b = options.injectValidators) !== null && _b !== void 0 ? _b : []) {
|
|
854
|
-
const injectableValidator = this.injector.get(injectValidator);
|
|
855
|
-
if (injectableValidator.validate) {
|
|
856
|
-
injectValidators.push(injectableValidator.validate.bind(injectableValidator));
|
|
857
|
-
}
|
|
858
|
-
if (injectableValidator.asyncValidate) {
|
|
859
|
-
injectAsyncValidators.push(injectableValidator.asyncValidate.bind(injectableValidator));
|
|
860
|
-
}
|
|
861
|
-
}
|
|
862
|
-
control.setValidators(this.coerceToValidatorArray(form, options.validators, this.validators.get(controlId), injectValidators), false);
|
|
863
|
-
control.setAsyncValidators(this.coerceToValidatorArray(form, options.asyncValidators, this.asyncValidators.get(controlId), injectAsyncValidators), false);
|
|
864
|
-
// register all control on change function with the form control
|
|
865
|
-
this.coerceToFnArray(form, this.controlChanges.get(controlId)).forEach((changeFn) => control.registerOnChange(changeFn));
|
|
866
|
-
// register all control on set value function with the form control
|
|
867
|
-
this.coerceToFnArray(form, this.controlSetValue.get(controlId)).forEach((setValueFn) => control.registerOnSetValue(setValueFn));
|
|
868
|
-
if (Array.isArray(options.validators)) {
|
|
869
|
-
if (options.validators.includes(Validators.required) ||
|
|
870
|
-
options.validators.includes(Validators.requiredTrue)) {
|
|
871
|
-
Reflect.set(control, 'hasRequiredValidator', true);
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
// set the form control instance to the form definition instance
|
|
875
|
-
Reflect.set(form, controlId, control);
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
/**
|
|
879
|
-
* Coerce to a function array.
|
|
880
|
-
*
|
|
881
|
-
* @param form the current form definition instance
|
|
882
|
-
* @param methodKeys A set of propertyKeys that points to form
|
|
883
|
-
* definition instance methods
|
|
884
|
-
*/
|
|
885
|
-
coerceToFnArray(form, methodKeys) {
|
|
886
|
-
const changes = [];
|
|
887
|
-
if (methodKeys) {
|
|
888
|
-
for (const propertyKeyOrOptions of methodKeys) {
|
|
889
|
-
const propertyKey = typeof propertyKeyOrOptions === 'string'
|
|
890
|
-
? propertyKeyOrOptions
|
|
891
|
-
: propertyKeyOrOptions.propertyKey;
|
|
892
|
-
assertIsFunction(form[propertyKey]);
|
|
893
|
-
changes.push(form[propertyKey].bind(form));
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
return changes;
|
|
897
|
-
}
|
|
898
|
-
/**
|
|
899
|
-
* Coerce to a validator function array.
|
|
900
|
-
*
|
|
901
|
-
* @param form the current form definition instance
|
|
902
|
-
* @param optionsValidators The options validator functions
|
|
903
|
-
* @param validatorMethodKeys A set of propertyKeys that points to form
|
|
904
|
-
* definition instance methods
|
|
905
|
-
* @param injectValidators Injected validator functions
|
|
906
|
-
*/
|
|
907
|
-
coerceToValidatorArray(form, optionsValidators, validatorMethodKeys, injectValidators) {
|
|
908
|
-
const validators = optionsValidators
|
|
909
|
-
? Array.isArray(optionsValidators)
|
|
910
|
-
? optionsValidators
|
|
911
|
-
: [optionsValidators]
|
|
912
|
-
: [];
|
|
913
|
-
if (validatorMethodKeys) {
|
|
914
|
-
validatorMethodKeys.forEach((propertyKey) => {
|
|
915
|
-
assertIsFunction(form[propertyKey]);
|
|
916
|
-
validators.push(form[propertyKey].bind(form));
|
|
917
|
-
});
|
|
918
|
-
}
|
|
919
|
-
if (injectValidators) {
|
|
920
|
-
validators.push(...injectValidators);
|
|
921
|
-
}
|
|
922
|
-
return validators;
|
|
923
|
-
}
|
|
924
|
-
/**
|
|
925
|
-
* Coerce to the form state for the specified controlId. If none form state is
|
|
926
|
-
* found the default form state will be returned.
|
|
927
|
-
*
|
|
928
|
-
* @param controlId A control id
|
|
929
|
-
* @param defaultFormState The default form state
|
|
930
|
-
* @param builderFormState The form state provides as build state parameter
|
|
931
|
-
* @param optionsFormState The form state set by the decorator in the form definition
|
|
932
|
-
*/
|
|
933
|
-
coerceToControlFormState(controlId, defaultFormState, builderFormState, optionsFormState) {
|
|
934
|
-
let formState = defaultFormState;
|
|
935
|
-
if (builderFormState && builderFormState[controlId] !== undefined) {
|
|
936
|
-
formState = builderFormState[controlId];
|
|
937
|
-
}
|
|
938
|
-
else if (optionsFormState !== undefined) {
|
|
939
|
-
formState = optionsFormState !== null && optionsFormState !== void 0 ? optionsFormState : null;
|
|
940
|
-
}
|
|
941
|
-
if (typeof formState === 'function') {
|
|
942
|
-
formState = formState();
|
|
943
|
-
}
|
|
944
|
-
return formState;
|
|
945
|
-
}
|
|
946
|
-
/**
|
|
947
|
-
* Coerce to the form state for the specified controlId. If none form state is
|
|
948
|
-
* found the default form state will be returned.
|
|
949
|
-
*
|
|
950
|
-
* The difference to the method coerceToControlFormState is that null will be
|
|
951
|
-
* handled as undefined and the defaultFormState is used
|
|
952
|
-
*
|
|
953
|
-
* @param controlId A control id
|
|
954
|
-
* @param defaultFormState The default form state
|
|
955
|
-
* @param builderFormState The form state provides as build state parameter
|
|
956
|
-
* @param optionsFormState The form state set by the decorator in the form definition
|
|
957
|
-
*/
|
|
958
|
-
coerceToGroupFormState(controlId, defaultFormState, builderFormState, optionsFormState) {
|
|
959
|
-
let formState = defaultFormState;
|
|
960
|
-
if (builderFormState && builderFormState[controlId]) {
|
|
961
|
-
formState = builderFormState[controlId];
|
|
962
|
-
}
|
|
963
|
-
else if (optionsFormState) {
|
|
964
|
-
formState = optionsFormState;
|
|
965
|
-
}
|
|
966
|
-
if (typeof formState === 'function') {
|
|
967
|
-
formState = formState();
|
|
968
|
-
if (!formState) {
|
|
969
|
-
throw new Error(`The form state function for the form group '${controlId}' returns a empty value (null/undefined)`);
|
|
970
|
-
}
|
|
971
|
-
if (typeof formState !== 'object') {
|
|
972
|
-
throw new Error(`The form state function for the form group '${controlId}' returns a non object like value instead '${typeof formState}'`);
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
return formState;
|
|
976
|
-
}
|
|
977
|
-
/**
|
|
978
|
-
* Coerce to the form state for the specified controlId. If none form state is
|
|
979
|
-
* found the default form state will be returned.
|
|
980
|
-
*
|
|
981
|
-
* The difference to the method coerceToControlFormState is that null will be
|
|
982
|
-
* handled as undefined and the defaultFormState is used
|
|
983
|
-
*
|
|
984
|
-
* @param controlId A control id
|
|
985
|
-
* @param defaultFormState The default form state
|
|
986
|
-
* @param builderFormState The form state provides as build state parameter
|
|
987
|
-
* @param optionsFormState The form state set by the decorator in the form definition
|
|
988
|
-
*/
|
|
989
|
-
coerceToArrayFormState(controlId, defaultFormState, builderFormState, optionsFormState) {
|
|
990
|
-
let formState = defaultFormState;
|
|
991
|
-
if (builderFormState && builderFormState[controlId] && Array.isArray(builderFormState[controlId])) {
|
|
992
|
-
formState = builderFormState[controlId];
|
|
993
|
-
}
|
|
994
|
-
else if (optionsFormState && Array.isArray(optionsFormState)) {
|
|
995
|
-
formState = optionsFormState;
|
|
996
|
-
}
|
|
997
|
-
if (typeof formState === 'function') {
|
|
998
|
-
formState = formState();
|
|
999
|
-
if (!formState) {
|
|
1000
|
-
throw new Error(`The form state function for the form array '${controlId}' returns a empty value (null/undefined)`);
|
|
1001
|
-
}
|
|
1002
|
-
if (!Array.isArray(formState)) {
|
|
1003
|
-
throw new Error(`The form state function for the form array '${controlId}' returns a non array like value instead '${typeof formState}'`);
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
return formState;
|
|
1007
|
-
}
|
|
1008
|
-
extractControlChanges() {
|
|
1009
|
-
var _a;
|
|
1010
|
-
return ((_a = getMetadata(MetadataKeys.CONTROL_CHANGES, this.definition.prototype)) !== null && _a !== void 0 ? _a : new Map());
|
|
1011
|
-
}
|
|
1012
|
-
extractControlSetValue() {
|
|
1013
|
-
var _a;
|
|
1014
|
-
return ((_a = getMetadata(MetadataKeys.CONTROL_SET_VALUE, this.definition.prototype)) !== null && _a !== void 0 ? _a : new Map());
|
|
1015
|
-
}
|
|
1016
|
-
extractValidators() {
|
|
1017
|
-
var _a;
|
|
1018
|
-
return ((_a = getMetadata(MetadataKeys.CONTROL_VALIDATORS, this.definition.prototype)) !== null && _a !== void 0 ? _a : new Map());
|
|
1019
|
-
}
|
|
1020
|
-
extractAsyncValidators() {
|
|
1021
|
-
var _a;
|
|
1022
|
-
return ((_a = getMetadata(MetadataKeys.CONTROL_ASYNC_VALIDATORS, this.definition.prototype)) !== null && _a !== void 0 ? _a : new Map());
|
|
1023
|
-
}
|
|
1024
|
-
extractArrayGroups() {
|
|
1025
|
-
var _a;
|
|
1026
|
-
return ((_a = getMetadata(MetadataKeys.FORM_ARRAY_GROUPS, this.definition.prototype)) !== null && _a !== void 0 ? _a : new Map());
|
|
1027
|
-
}
|
|
1028
|
-
extractArrayControls() {
|
|
1029
|
-
var _a;
|
|
1030
|
-
return ((_a = getMetadata(MetadataKeys.FORM_ARRAY_CONTROLS, this.definition.prototype)) !== null && _a !== void 0 ? _a : new Map());
|
|
1031
|
-
}
|
|
1032
|
-
extractGroups() {
|
|
1033
|
-
var _a;
|
|
1034
|
-
return ((_a = getMetadata(MetadataKeys.FORM_GROUPS, this.definition.prototype)) !== null && _a !== void 0 ? _a : new Map());
|
|
1035
|
-
}
|
|
1036
|
-
extractControls() {
|
|
1037
|
-
var _a;
|
|
1038
|
-
return ((_a = getMetadata(MetadataKeys.FORM_CONTROLS, this.definition.prototype)) !== null && _a !== void 0 ? _a : new Map());
|
|
1039
|
-
}
|
|
1040
|
-
extractFormOptions() {
|
|
1041
|
-
const options = GetDefinitionMetadata(this.definition);
|
|
1042
|
-
if (!options || !options.hasOwnProperty('id')) {
|
|
1043
|
-
throw new Error('Ensure that the @UseForm decorator is used.');
|
|
1044
|
-
}
|
|
1045
|
-
if (!options.providers) {
|
|
1046
|
-
options.providers = [];
|
|
1047
|
-
}
|
|
1048
|
-
return options;
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
|
-
|
|
1052
|
-
class ControlValueAccessor {
|
|
1053
|
-
constructor() {
|
|
1054
|
-
this.onChange = (value) => { };
|
|
1055
|
-
this.onTouched = () => { };
|
|
1056
|
-
this.setDisabledState = (isDisabled) => { };
|
|
1057
|
-
}
|
|
1058
|
-
registerOnChange(fn) {
|
|
1059
|
-
this.onChange = fn;
|
|
1060
|
-
}
|
|
1061
|
-
registerOnTouched(fn) {
|
|
1062
|
-
this.onTouched = fn;
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
const RXAP_FORM_INITIAL_STATE = new InjectionToken('rxap/forms/initial-state');
|
|
1067
|
-
const RXAP_FORM_CONTEXT = new InjectionToken('rxap/forms/context');
|
|
1068
|
-
|
|
1069
|
-
function ControlAsyncValidator(...controlIds) {
|
|
1070
|
-
return function (target, propertyKey) {
|
|
1071
|
-
for (const controlId of controlIds) {
|
|
1072
|
-
setMetadataMapSet(controlId, propertyKey, MetadataKeys.CONTROL_ASYNC_VALIDATORS, target);
|
|
1073
|
-
}
|
|
1074
|
-
};
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
function ControlChange(...controlIds) {
|
|
1078
|
-
return function (target, propertyKey) {
|
|
1079
|
-
for (const controlId of controlIds) {
|
|
1080
|
-
setMetadataMapSet(controlId, propertyKey, MetadataKeys.CONTROL_CHANGES, target);
|
|
1081
|
-
}
|
|
1082
|
-
};
|
|
1083
|
-
}
|
|
1084
|
-
|
|
1085
|
-
function ControlSetValue(controlId, options = {}) {
|
|
1086
|
-
return function (target, propertyKey) {
|
|
1087
|
-
setMetadataMapSet(controlId, Object.assign(Object.assign({}, options), { propertyKey }), MetadataKeys.CONTROL_SET_VALUE, target);
|
|
1088
|
-
};
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
function ControlValidator(...controlIds) {
|
|
1092
|
-
return function (target, propertyKey) {
|
|
1093
|
-
for (const controlId of controlIds) {
|
|
1094
|
-
setMetadataMapSet(controlId, propertyKey, MetadataKeys.CONTROL_VALIDATORS, target);
|
|
1095
|
-
}
|
|
1096
|
-
};
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
function UseFormArrayGroup(definition, options = {}) {
|
|
1100
|
-
return function (target, propertyKey) {
|
|
1101
|
-
setMetadataMap(propertyKey, Object.assign(Object.assign({}, options), { definition }), MetadataKeys.FORM_ARRAY_GROUPS, target);
|
|
1102
|
-
};
|
|
1103
|
-
}
|
|
1104
|
-
function UseFormArrayControl(options = {}) {
|
|
1105
|
-
return function (target, propertyKey) {
|
|
1106
|
-
setMetadataMap(propertyKey, options, MetadataKeys.FORM_ARRAY_CONTROLS, target);
|
|
1107
|
-
};
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
function UseFormControl(options = {}) {
|
|
1111
|
-
return function (target, propertyKey) {
|
|
1112
|
-
setMetadataMap(propertyKey, options, MetadataKeys.FORM_CONTROLS, target);
|
|
1113
|
-
};
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
function UseFormGroup(definition, options = {}) {
|
|
1117
|
-
return function (target, propertyKey) {
|
|
1118
|
-
setMetadataMap(propertyKey, Object.assign(Object.assign({}, options), { definition }), MetadataKeys.FORM_GROUPS, target);
|
|
1119
|
-
};
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
function RxapForm(optionsOrId, className = 'FormDefinition', packageName = '@rxap/forms') {
|
|
1123
|
-
return function (target) {
|
|
1124
|
-
DefinitionMetadata(optionsOrId, className, packageName)(target);
|
|
1125
|
-
};
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
const RXAP_FORM_DEFINITION = new InjectionToken('rxap/forms/definition');
|
|
1129
|
-
const RXAP_FORM_DEFINITION_BUILDER = new InjectionToken('rxap/forms/definition-builder');
|
|
1130
|
-
const RXAP_FORM_SUBMIT_METHOD = new InjectionToken('rxap/form/submit-method');
|
|
1131
|
-
const RXAP_FORM_SUBMIT_FAILED_METHOD = new InjectionToken('rxap/form/submit-failed-method');
|
|
1132
|
-
const RXAP_FORM_SUBMIT_SUCCESSFUL_METHOD = new InjectionToken('rxap/form/submit-successful-method');
|
|
1133
|
-
const RXAP_FORM_LOAD_METHOD = new InjectionToken('rxap/form/load-method');
|
|
1134
|
-
const RXAP_FORM_LOAD_FAILED_METHOD = new InjectionToken('rxap/form/load-failed-method');
|
|
1135
|
-
const RXAP_FORM_LOAD_SUCCESSFUL_METHOD = new InjectionToken('rxap/form/load-successful-method');
|
|
1136
|
-
|
|
1137
|
-
class FormDirective extends FormGroupDirective {
|
|
1138
|
-
constructor(cdr, formDefinition = null,
|
|
1139
|
-
// skip self, bc the token is set to null
|
|
1140
|
-
submitMethod = null,
|
|
1141
|
-
// skip self, bc the token is set to null
|
|
1142
|
-
loadMethod = null,
|
|
1143
|
-
// skip self, bc the token is set to null
|
|
1144
|
-
loadFailedMethod = null,
|
|
1145
|
-
// skip self, bc the token is set to null
|
|
1146
|
-
loadSuccessfulMethod = null,
|
|
1147
|
-
// skip self, bc the token is set to null
|
|
1148
|
-
submitFailedMethod = null,
|
|
1149
|
-
// skip self, bc the token is set to null
|
|
1150
|
-
submitSuccessfulMethod = null,
|
|
1151
|
-
// skip self, bc the token is set to null
|
|
1152
|
-
formDefinitionBuilder = null, loadingIndicatorService = null) {
|
|
1153
|
-
var _a, _b;
|
|
1154
|
-
super([], []);
|
|
1155
|
-
this.cdr = cdr;
|
|
1156
|
-
this.loadMethod = loadMethod;
|
|
1157
|
-
this.loadFailedMethod = loadFailedMethod;
|
|
1158
|
-
this.loadSuccessfulMethod = loadSuccessfulMethod;
|
|
1159
|
-
this.submitFailedMethod = submitFailedMethod;
|
|
1160
|
-
this.submitSuccessfulMethod = submitSuccessfulMethod;
|
|
1161
|
-
this.formDefinitionBuilder = formDefinitionBuilder;
|
|
1162
|
-
this.loadingIndicatorService = loadingIndicatorService;
|
|
1163
|
-
/**
|
|
1164
|
-
* Emits when the submit method is executed without errors. The result of the
|
|
1165
|
-
* submit method is passed as event object.
|
|
1166
|
-
*
|
|
1167
|
-
* If no submit method is defined then emit after the submit button
|
|
1168
|
-
* is clicked.
|
|
1169
|
-
*/
|
|
1170
|
-
this.rxapSubmit = new EventEmitter();
|
|
1171
|
-
this.invalidSubmit = new EventEmitter();
|
|
1172
|
-
this.submitSuccessful$ = new EventEmitter();
|
|
1173
|
-
this.submitting$ = new ToggleSubject();
|
|
1174
|
-
this.submitError$ = new BehaviorSubject(null);
|
|
1175
|
-
this.loading$ = new ToggleSubject();
|
|
1176
|
-
this.loaded$ = new ToggleSubject();
|
|
1177
|
-
this.loadingError$ = new BehaviorSubject(null);
|
|
1178
|
-
this.submitMethod = null;
|
|
1179
|
-
this._autoSubmitSubscription = new Subscription();
|
|
1180
|
-
if (submitMethod) {
|
|
1181
|
-
this.submitMethod = submitMethod;
|
|
1182
|
-
}
|
|
1183
|
-
if (!formDefinition && formDefinitionBuilder) {
|
|
1184
|
-
formDefinition = formDefinitionBuilder.build();
|
|
1185
|
-
}
|
|
1186
|
-
if (formDefinition) {
|
|
1187
|
-
this._formDefinition = formDefinition;
|
|
1188
|
-
this.form = formDefinition.rxapFormGroup;
|
|
1189
|
-
}
|
|
1190
|
-
(_a = this.loadingIndicatorService) === null || _a === void 0 ? void 0 : _a.attachLoading(this.loading$);
|
|
1191
|
-
(_b = this.loadingIndicatorService) === null || _b === void 0 ? void 0 : _b.attachLoading(this.submitting$);
|
|
1192
|
-
}
|
|
1193
|
-
get submitting() {
|
|
1194
|
-
return this.submitting$.value;
|
|
1195
|
-
}
|
|
1196
|
-
get submitError() {
|
|
1197
|
-
return this.submitError$.value;
|
|
1198
|
-
}
|
|
1199
|
-
get loading() {
|
|
1200
|
-
return this.loading$.value;
|
|
1201
|
-
}
|
|
1202
|
-
get loaded() {
|
|
1203
|
-
return this.loaded$.value;
|
|
1204
|
-
}
|
|
1205
|
-
get loadingError() {
|
|
1206
|
-
return this.loadingError$.value;
|
|
1207
|
-
}
|
|
1208
|
-
set useFormDefinition(value) {
|
|
1209
|
-
if (value) {
|
|
1210
|
-
this._formDefinition = value;
|
|
1211
|
-
this.form = value.rxapFormGroup;
|
|
1212
|
-
}
|
|
1213
|
-
}
|
|
1214
|
-
get formDefinition() {
|
|
1215
|
-
return this._formDefinition;
|
|
1216
|
-
}
|
|
1217
|
-
ngOnChanges(changes) {
|
|
1218
|
-
super.ngOnChanges(changes);
|
|
1219
|
-
const formChange = changes.form;
|
|
1220
|
-
if (formChange && !formChange.firstChange) {
|
|
1221
|
-
this.loadInitialState(formChange.currentValue);
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
ngOnInit() {
|
|
1225
|
-
if (!this._formDefinition) {
|
|
1226
|
-
// TODO : replace with rxap error
|
|
1227
|
-
throw new Error('The form definition instance is not defined');
|
|
1228
|
-
}
|
|
1229
|
-
if (!this.form) {
|
|
1230
|
-
// TODO : replace with rxap error
|
|
1231
|
-
throw new Error('The form instance is not defined');
|
|
1232
|
-
}
|
|
1233
|
-
this.loadInitialState(this.form);
|
|
1234
|
-
function HasNgOnInitMethod(obj) {
|
|
1235
|
-
return obj && typeof obj.ngOnInit === 'function';
|
|
1236
|
-
}
|
|
1237
|
-
if (HasNgOnInitMethod(this._formDefinition)) {
|
|
1238
|
-
this._formDefinition.ngOnInit();
|
|
1239
|
-
}
|
|
1240
|
-
if (this._formDefinition.rxapMetadata.autoSubmit) {
|
|
1241
|
-
const debounce = typeof this._formDefinition.rxapMetadata.autoSubmit === 'number'
|
|
1242
|
-
? this._formDefinition.rxapMetadata.autoSubmit
|
|
1243
|
-
: 5000;
|
|
1244
|
-
this._autoSubmitSubscription = this
|
|
1245
|
-
.form
|
|
1246
|
-
.valueChanges
|
|
1247
|
-
.pipe(debounceTime(debounce), filter(() => this.form.valid), tap((value) => {
|
|
1248
|
-
if (isDevMode()) {
|
|
1249
|
-
console.debug(`Auto submit form '${this._formDefinition.rxapMetadata.id}'`, value);
|
|
1250
|
-
}
|
|
1251
|
-
}), tap(() => this.submit()))
|
|
1252
|
-
.subscribe();
|
|
1253
|
-
}
|
|
1254
|
-
}
|
|
1255
|
-
onSubmit($event) {
|
|
1256
|
-
$event.preventDefault();
|
|
1257
|
-
super.onSubmit($event);
|
|
1258
|
-
if (this.form.valid) {
|
|
1259
|
-
this.submit();
|
|
1260
|
-
}
|
|
1261
|
-
else {
|
|
1262
|
-
function reduceErrors(control, errors = {}) {
|
|
1263
|
-
if (control.invalid) {
|
|
1264
|
-
if (control.controls) {
|
|
1265
|
-
if (Array.isArray(control.controls)) {
|
|
1266
|
-
const errorList = [];
|
|
1267
|
-
for (const item of control.controls) {
|
|
1268
|
-
errorList.push(reduceErrors(item));
|
|
1269
|
-
}
|
|
1270
|
-
errors[control.controlId] = errorList;
|
|
1271
|
-
}
|
|
1272
|
-
else {
|
|
1273
|
-
const innerErrors = {};
|
|
1274
|
-
for (const child of Object.values(control.controls)) {
|
|
1275
|
-
reduceErrors(child, innerErrors);
|
|
1276
|
-
}
|
|
1277
|
-
errors[control.controlId] = innerErrors;
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
else {
|
|
1281
|
-
if (control.errors) {
|
|
1282
|
-
errors[control.controlId] = control.errors;
|
|
1283
|
-
}
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
return errors;
|
|
1287
|
-
}
|
|
1288
|
-
if (isDevMode()) {
|
|
1289
|
-
console.log('Form submit is not valid for: ' + this.form.controlId, this.form.errors);
|
|
1290
|
-
function printErrorControls(control) {
|
|
1291
|
-
if (!control.valid) {
|
|
1292
|
-
console.group(control.controlId);
|
|
1293
|
-
if (control.controls) {
|
|
1294
|
-
if (Array.isArray(control.controls)) {
|
|
1295
|
-
for (let i = 0; i < control.controls.length; i++) {
|
|
1296
|
-
const child = control.controls[i];
|
|
1297
|
-
if (!child.valid) {
|
|
1298
|
-
console.group(`index: ${i}`);
|
|
1299
|
-
printErrorControls(child);
|
|
1300
|
-
console.groupEnd();
|
|
1301
|
-
}
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1304
|
-
else {
|
|
1305
|
-
for (const child of Object.values(control.controls)) {
|
|
1306
|
-
printErrorControls(child);
|
|
1307
|
-
}
|
|
1308
|
-
}
|
|
1309
|
-
}
|
|
1310
|
-
else {
|
|
1311
|
-
if (control.errors) {
|
|
1312
|
-
for (const [key, value] of Object.entries(control.errors)) {
|
|
1313
|
-
console.group(key);
|
|
1314
|
-
console.log(value);
|
|
1315
|
-
console.groupEnd();
|
|
1316
|
-
}
|
|
1317
|
-
}
|
|
1318
|
-
console.log('value: ', control.value);
|
|
1319
|
-
}
|
|
1320
|
-
console.groupEnd();
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
printErrorControls(this.form);
|
|
1324
|
-
}
|
|
1325
|
-
this.invalidSubmit.emit(reduceErrors(this.form));
|
|
1326
|
-
}
|
|
1327
|
-
return false;
|
|
1328
|
-
}
|
|
1329
|
-
loadInitialState(form) {
|
|
1330
|
-
if (this.initial) {
|
|
1331
|
-
if (isDevMode()) {
|
|
1332
|
-
console.log('use the value from input initial');
|
|
1333
|
-
}
|
|
1334
|
-
form.patchValue(this.initial);
|
|
1335
|
-
}
|
|
1336
|
-
else {
|
|
1337
|
-
if (this.loadMethod) {
|
|
1338
|
-
this.loading$.enable();
|
|
1339
|
-
try {
|
|
1340
|
-
const resultOrPromise = this.loadMethod.call();
|
|
1341
|
-
if (isPromise(resultOrPromise)) {
|
|
1342
|
-
resultOrPromise
|
|
1343
|
-
.then((value) => {
|
|
1344
|
-
form.patchValue(value);
|
|
1345
|
-
this.loaded$.enable();
|
|
1346
|
-
this.loadSuccessful(value);
|
|
1347
|
-
})
|
|
1348
|
-
.catch((error) => {
|
|
1349
|
-
this.loadingError$.next(error);
|
|
1350
|
-
this.loadFailed(error);
|
|
1351
|
-
})
|
|
1352
|
-
.finally(() => {
|
|
1353
|
-
this.loading$.disable();
|
|
1354
|
-
this.cdr.detectChanges();
|
|
1355
|
-
});
|
|
1356
|
-
}
|
|
1357
|
-
else if (isObject(resultOrPromise)) {
|
|
1358
|
-
form.patchValue(resultOrPromise);
|
|
1359
|
-
this.loaded$.enable();
|
|
1360
|
-
this.loadSuccessful(resultOrPromise);
|
|
1361
|
-
this.loading$.disable();
|
|
1362
|
-
}
|
|
1363
|
-
}
|
|
1364
|
-
catch (error) {
|
|
1365
|
-
this.loaded$.disable();
|
|
1366
|
-
this.loadingError$.next(error);
|
|
1367
|
-
this.loadFailed(error);
|
|
1368
|
-
this.loading$.disable();
|
|
1369
|
-
}
|
|
1370
|
-
}
|
|
1371
|
-
else {
|
|
1372
|
-
if (isDevMode()) {
|
|
1373
|
-
console.warn('The form loading method is not defined for: ' + this.form.controlId);
|
|
1374
|
-
}
|
|
1375
|
-
this.loaded$.enable();
|
|
1376
|
-
}
|
|
1377
|
-
}
|
|
1378
|
-
}
|
|
1379
|
-
loadSuccessful(value) {
|
|
1380
|
-
if (this.loadSuccessfulMethod) {
|
|
1381
|
-
this.loadSuccessfulMethod.call(value);
|
|
1382
|
-
}
|
|
1383
|
-
else if (isDevMode()) {
|
|
1384
|
-
console.warn('The load successful is not defined for: ' + this.form.controlId);
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
loadFailed(error) {
|
|
1388
|
-
var _a;
|
|
1389
|
-
console.debug('Load Error:', error);
|
|
1390
|
-
console.error('Load Error:', error.message);
|
|
1391
|
-
if (this.loadFailedMethod) {
|
|
1392
|
-
(_a = this.loadFailedMethod) === null || _a === void 0 ? void 0 : _a.call(error);
|
|
1393
|
-
}
|
|
1394
|
-
else if (isDevMode()) {
|
|
1395
|
-
console.warn('The form loading failed for: ' + this.form.controlId);
|
|
1396
|
-
}
|
|
1397
|
-
}
|
|
1398
|
-
getSubmitValue() {
|
|
1399
|
-
let value = undefined;
|
|
1400
|
-
if (typeof this._formDefinition['getSubmitValue'] === 'function') {
|
|
1401
|
-
value = this._formDefinition.getSubmitValue();
|
|
1402
|
-
}
|
|
1403
|
-
else if (typeof this._formDefinition['toJSON'] === 'function') {
|
|
1404
|
-
value = this._formDefinition.toJSON();
|
|
1405
|
-
}
|
|
1406
|
-
value = value !== null && value !== void 0 ? value : this.form.value;
|
|
1407
|
-
return clone(value);
|
|
1408
|
-
}
|
|
1409
|
-
submit() {
|
|
1410
|
-
const value = this.getSubmitValue();
|
|
1411
|
-
if (this.submitMethod) {
|
|
1412
|
-
Reflect.set(this, 'submitted', false);
|
|
1413
|
-
this.submitting$.enable();
|
|
1414
|
-
this.submitError$.next(null);
|
|
1415
|
-
try {
|
|
1416
|
-
const resultOrPromise = this.submitMethod.call(value);
|
|
1417
|
-
if (isPromise(resultOrPromise)) {
|
|
1418
|
-
resultOrPromise
|
|
1419
|
-
.then((result) => {
|
|
1420
|
-
Reflect.set(this, 'submitted', true);
|
|
1421
|
-
this.rxapSubmit.emit(result);
|
|
1422
|
-
this.submitSuccessful(result);
|
|
1423
|
-
})
|
|
1424
|
-
.catch((error) => {
|
|
1425
|
-
this.submitError$.next(error);
|
|
1426
|
-
this.submitFailed(error);
|
|
1427
|
-
})
|
|
1428
|
-
.finally(() => {
|
|
1429
|
-
this.submitting$.disable();
|
|
1430
|
-
this.cdr.detectChanges();
|
|
1431
|
-
});
|
|
1432
|
-
}
|
|
1433
|
-
else {
|
|
1434
|
-
Reflect.set(this, 'submitted', true);
|
|
1435
|
-
this.rxapSubmit.emit(resultOrPromise);
|
|
1436
|
-
this.submitSuccessful(resultOrPromise);
|
|
1437
|
-
this.submitting$.disable();
|
|
1438
|
-
}
|
|
1439
|
-
}
|
|
1440
|
-
catch (error) {
|
|
1441
|
-
this.submitting$.disable();
|
|
1442
|
-
this.submitError$.next(error);
|
|
1443
|
-
this.submitFailed(error);
|
|
1444
|
-
}
|
|
1445
|
-
}
|
|
1446
|
-
else {
|
|
1447
|
-
if (isDevMode()) {
|
|
1448
|
-
console.warn('The form submit method is not defined for: ' + this.form.controlId);
|
|
1449
|
-
}
|
|
1450
|
-
this.rxapSubmit.emit(value);
|
|
1451
|
-
this.submitSuccessful(value);
|
|
1452
|
-
}
|
|
1453
|
-
}
|
|
1454
|
-
submitFailed(error) {
|
|
1455
|
-
console.debug('Submit Error:', error);
|
|
1456
|
-
console.error('Submit Error:', error.message);
|
|
1457
|
-
if (this.submitFailedMethod) {
|
|
1458
|
-
this.submitFailedMethod.call(error);
|
|
1459
|
-
}
|
|
1460
|
-
else if (isDevMode()) {
|
|
1461
|
-
console.warn('The form submit failed method is not defined for: ' +
|
|
1462
|
-
this.form.controlId);
|
|
1463
|
-
}
|
|
1464
|
-
}
|
|
1465
|
-
submitSuccessful(value) {
|
|
1466
|
-
this.submitSuccessful$.next(value);
|
|
1467
|
-
if (this.submitSuccessfulMethod) {
|
|
1468
|
-
this.submitSuccessfulMethod.call(value);
|
|
1469
|
-
}
|
|
1470
|
-
else if (isDevMode()) {
|
|
1471
|
-
console.warn('The form submit successful method is not defined for: ' +
|
|
1472
|
-
this.form.controlId);
|
|
1473
|
-
}
|
|
1474
|
-
}
|
|
1475
|
-
ngOnDestroy() {
|
|
1476
|
-
var _a;
|
|
1477
|
-
super.ngOnDestroy();
|
|
1478
|
-
(_a = this._autoSubmitSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
1479
|
-
function HasNgOnDestroyMethod(obj) {
|
|
1480
|
-
return obj && typeof obj.ngOnDestroy === 'function';
|
|
1481
|
-
}
|
|
1482
|
-
if (HasNgOnDestroyMethod(this._formDefinition)) {
|
|
1483
|
-
this._formDefinition.ngOnDestroy();
|
|
1484
|
-
}
|
|
1485
|
-
}
|
|
1486
|
-
}
|
|
1487
|
-
FormDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormDirective, deps: [{ token: ChangeDetectorRef }, { token: RXAP_FORM_DEFINITION, optional: true }, { token: RXAP_FORM_SUBMIT_METHOD, optional: true, skipSelf: true }, { token: RXAP_FORM_LOAD_METHOD, optional: true, skipSelf: true }, { token: RXAP_FORM_LOAD_FAILED_METHOD, optional: true, skipSelf: true }, { token: RXAP_FORM_LOAD_SUCCESSFUL_METHOD, optional: true, skipSelf: true }, { token: RXAP_FORM_SUBMIT_FAILED_METHOD, optional: true, skipSelf: true }, { token: RXAP_FORM_SUBMIT_SUCCESSFUL_METHOD, optional: true, skipSelf: true }, { token: RXAP_FORM_DEFINITION_BUILDER, optional: true, skipSelf: true }, { token: LoadingIndicatorService, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1488
|
-
FormDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: FormDirective, selector: "form[rxapForm]:not([formGroup]):not([ngForm]),rxap-form,form[rxapForm]", inputs: { initial: "initial", useFormDefinition: ["rxapForm", "useFormDefinition"], submitMethod: "submitMethod" }, outputs: { ngSubmit: "ngSubmit", rxapSubmit: "rxapSubmit", invalidSubmit: "invalidSubmit", submitSuccessful$: "submitSuccessful" }, host: { listeners: { "reset": "onReset()" }, properties: { "class.rxap-submitting": "this.submitting", "class.rxap-submit-error": "this.submitError", "class.rxap-loading": "this.loading", "class.rxap-loaded": "this.loaded", "class.rxap-loading-error": "this.loadingError" } }, providers: [
|
|
1489
|
-
{
|
|
1490
|
-
provide: ControlContainer,
|
|
1491
|
-
// ignore coverage
|
|
1492
|
-
useExisting: forwardRef(() => FormDirective)
|
|
1493
|
-
},
|
|
1494
|
-
// region form provider clear
|
|
1495
|
-
// form provider that are directly associated with the current form
|
|
1496
|
-
// are cleared to prevent that inner forms can access this providers
|
|
1497
|
-
// Example: The parent form has a submit method provider and the inner should
|
|
1498
|
-
// not have a submit method provider. If the parent submit method provider is
|
|
1499
|
-
// not cleared then the inner form uses the parent submit method provider on
|
|
1500
|
-
// submit
|
|
1501
|
-
{
|
|
1502
|
-
provide: RXAP_FORM_SUBMIT_METHOD,
|
|
1503
|
-
useValue: null,
|
|
1504
|
-
},
|
|
1505
|
-
{
|
|
1506
|
-
provide: RXAP_FORM_LOAD_METHOD,
|
|
1507
|
-
useValue: null,
|
|
1508
|
-
},
|
|
1509
|
-
{
|
|
1510
|
-
provide: RXAP_FORM_LOAD_FAILED_METHOD,
|
|
1511
|
-
useValue: null,
|
|
1512
|
-
},
|
|
1513
|
-
{
|
|
1514
|
-
provide: RXAP_FORM_LOAD_SUCCESSFUL_METHOD,
|
|
1515
|
-
useValue: null,
|
|
1516
|
-
},
|
|
1517
|
-
{
|
|
1518
|
-
provide: RXAP_FORM_SUBMIT_FAILED_METHOD,
|
|
1519
|
-
useValue: null,
|
|
1520
|
-
},
|
|
1521
|
-
{
|
|
1522
|
-
provide: RXAP_FORM_SUBMIT_SUCCESSFUL_METHOD,
|
|
1523
|
-
useValue: null,
|
|
1524
|
-
},
|
|
1525
|
-
{
|
|
1526
|
-
provide: RXAP_FORM_DEFINITION_BUILDER,
|
|
1527
|
-
useValue: null,
|
|
1528
|
-
},
|
|
1529
|
-
// endregion
|
|
1530
|
-
], exportAs: ["rxapForm"], usesInheritance: true, usesOnChanges: true, ngImport: i0 });
|
|
1531
|
-
__decorate([
|
|
1532
|
-
Required,
|
|
1533
|
-
__metadata("design:type", Object)
|
|
1534
|
-
], FormDirective.prototype, "_formDefinition", void 0);
|
|
1535
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormDirective, decorators: [{
|
|
1536
|
-
type: Directive,
|
|
1537
|
-
args: [{
|
|
1538
|
-
selector: 'form[rxapForm]:not([formGroup]):not([ngForm]),rxap-form,form[rxapForm]',
|
|
1539
|
-
providers: [
|
|
1540
|
-
{
|
|
1541
|
-
provide: ControlContainer,
|
|
1542
|
-
// ignore coverage
|
|
1543
|
-
useExisting: forwardRef(() => FormDirective)
|
|
1544
|
-
},
|
|
1545
|
-
// region form provider clear
|
|
1546
|
-
// form provider that are directly associated with the current form
|
|
1547
|
-
// are cleared to prevent that inner forms can access this providers
|
|
1548
|
-
// Example: The parent form has a submit method provider and the inner should
|
|
1549
|
-
// not have a submit method provider. If the parent submit method provider is
|
|
1550
|
-
// not cleared then the inner form uses the parent submit method provider on
|
|
1551
|
-
// submit
|
|
1552
|
-
{
|
|
1553
|
-
provide: RXAP_FORM_SUBMIT_METHOD,
|
|
1554
|
-
useValue: null,
|
|
1555
|
-
},
|
|
1556
|
-
{
|
|
1557
|
-
provide: RXAP_FORM_LOAD_METHOD,
|
|
1558
|
-
useValue: null,
|
|
1559
|
-
},
|
|
1560
|
-
{
|
|
1561
|
-
provide: RXAP_FORM_LOAD_FAILED_METHOD,
|
|
1562
|
-
useValue: null,
|
|
1563
|
-
},
|
|
1564
|
-
{
|
|
1565
|
-
provide: RXAP_FORM_LOAD_SUCCESSFUL_METHOD,
|
|
1566
|
-
useValue: null,
|
|
1567
|
-
},
|
|
1568
|
-
{
|
|
1569
|
-
provide: RXAP_FORM_SUBMIT_FAILED_METHOD,
|
|
1570
|
-
useValue: null,
|
|
1571
|
-
},
|
|
1572
|
-
{
|
|
1573
|
-
provide: RXAP_FORM_SUBMIT_SUCCESSFUL_METHOD,
|
|
1574
|
-
useValue: null,
|
|
1575
|
-
},
|
|
1576
|
-
{
|
|
1577
|
-
provide: RXAP_FORM_DEFINITION_BUILDER,
|
|
1578
|
-
useValue: null,
|
|
1579
|
-
},
|
|
1580
|
-
// endregion
|
|
1581
|
-
],
|
|
1582
|
-
host: { '(reset)': 'onReset()' },
|
|
1583
|
-
outputs: ['ngSubmit'],
|
|
1584
|
-
exportAs: 'rxapForm',
|
|
1585
|
-
}]
|
|
1586
|
-
}], ctorParameters: function () {
|
|
1587
|
-
return [{ type: i0.ChangeDetectorRef, decorators: [{
|
|
1588
|
-
type: Inject,
|
|
1589
|
-
args: [ChangeDetectorRef]
|
|
1590
|
-
}] }, { type: undefined, decorators: [{
|
|
1591
|
-
type: Optional
|
|
1592
|
-
}, {
|
|
1593
|
-
type: Inject,
|
|
1594
|
-
args: [RXAP_FORM_DEFINITION]
|
|
1595
|
-
}] }, { type: undefined, decorators: [{
|
|
1596
|
-
type: SkipSelf
|
|
1597
|
-
}, {
|
|
1598
|
-
type: Optional
|
|
1599
|
-
}, {
|
|
1600
|
-
type: Inject,
|
|
1601
|
-
args: [RXAP_FORM_SUBMIT_METHOD]
|
|
1602
|
-
}] }, { type: undefined, decorators: [{
|
|
1603
|
-
type: SkipSelf
|
|
1604
|
-
}, {
|
|
1605
|
-
type: Optional
|
|
1606
|
-
}, {
|
|
1607
|
-
type: Inject,
|
|
1608
|
-
args: [RXAP_FORM_LOAD_METHOD]
|
|
1609
|
-
}] }, { type: undefined, decorators: [{
|
|
1610
|
-
type: SkipSelf
|
|
1611
|
-
}, {
|
|
1612
|
-
type: Optional
|
|
1613
|
-
}, {
|
|
1614
|
-
type: Inject,
|
|
1615
|
-
args: [RXAP_FORM_LOAD_FAILED_METHOD]
|
|
1616
|
-
}] }, { type: undefined, decorators: [{
|
|
1617
|
-
type: SkipSelf
|
|
1618
|
-
}, {
|
|
1619
|
-
type: Optional
|
|
1620
|
-
}, {
|
|
1621
|
-
type: Inject,
|
|
1622
|
-
args: [RXAP_FORM_LOAD_SUCCESSFUL_METHOD]
|
|
1623
|
-
}] }, { type: undefined, decorators: [{
|
|
1624
|
-
type: SkipSelf
|
|
1625
|
-
}, {
|
|
1626
|
-
type: Optional
|
|
1627
|
-
}, {
|
|
1628
|
-
type: Inject,
|
|
1629
|
-
args: [RXAP_FORM_SUBMIT_FAILED_METHOD]
|
|
1630
|
-
}] }, { type: undefined, decorators: [{
|
|
1631
|
-
type: SkipSelf
|
|
1632
|
-
}, {
|
|
1633
|
-
type: Optional
|
|
1634
|
-
}, {
|
|
1635
|
-
type: Inject,
|
|
1636
|
-
args: [RXAP_FORM_SUBMIT_SUCCESSFUL_METHOD]
|
|
1637
|
-
}] }, { type: RxapFormBuilder, decorators: [{
|
|
1638
|
-
type: SkipSelf
|
|
1639
|
-
}, {
|
|
1640
|
-
type: Optional
|
|
1641
|
-
}, {
|
|
1642
|
-
type: Inject,
|
|
1643
|
-
args: [RXAP_FORM_DEFINITION_BUILDER]
|
|
1644
|
-
}] }, { type: i2.LoadingIndicatorService, decorators: [{
|
|
1645
|
-
type: Optional
|
|
1646
|
-
}, {
|
|
1647
|
-
type: Inject,
|
|
1648
|
-
args: [LoadingIndicatorService]
|
|
1649
|
-
}] }];
|
|
1650
|
-
}, propDecorators: { initial: [{
|
|
1651
|
-
type: Input
|
|
1652
|
-
}], rxapSubmit: [{
|
|
1653
|
-
type: Output
|
|
1654
|
-
}], invalidSubmit: [{
|
|
1655
|
-
type: Output
|
|
1656
|
-
}], submitSuccessful$: [{
|
|
1657
|
-
type: Output,
|
|
1658
|
-
args: ['submitSuccessful']
|
|
1659
|
-
}], submitting: [{
|
|
1660
|
-
type: HostBinding,
|
|
1661
|
-
args: ['class.rxap-submitting']
|
|
1662
|
-
}], submitError: [{
|
|
1663
|
-
type: HostBinding,
|
|
1664
|
-
args: ['class.rxap-submit-error']
|
|
1665
|
-
}], loading: [{
|
|
1666
|
-
type: HostBinding,
|
|
1667
|
-
args: ['class.rxap-loading']
|
|
1668
|
-
}], loaded: [{
|
|
1669
|
-
type: HostBinding,
|
|
1670
|
-
args: ['class.rxap-loaded']
|
|
1671
|
-
}], loadingError: [{
|
|
1672
|
-
type: HostBinding,
|
|
1673
|
-
args: ['class.rxap-loading-error']
|
|
1674
|
-
}], useFormDefinition: [{
|
|
1675
|
-
type: Input,
|
|
1676
|
-
args: ['rxapForm']
|
|
1677
|
-
}], _formDefinition: [], submitMethod: [{
|
|
1678
|
-
type: Input
|
|
1679
|
-
}] } });
|
|
1680
|
-
|
|
1681
|
-
class FormSubmitFailedDirective {
|
|
1682
|
-
constructor(formDirective, template, viewContainerRef) {
|
|
1683
|
-
this.formDirective = formDirective;
|
|
1684
|
-
this.template = template;
|
|
1685
|
-
this.viewContainerRef = viewContainerRef;
|
|
1686
|
-
}
|
|
1687
|
-
ngAfterViewInit() {
|
|
1688
|
-
this.subscription = this.formDirective.submitError$.pipe(tap(error => {
|
|
1689
|
-
this.viewContainerRef.clear();
|
|
1690
|
-
if (error !== null) {
|
|
1691
|
-
this.viewContainerRef.createEmbeddedView(this.template, { $implicit: error });
|
|
1692
|
-
}
|
|
1693
|
-
})).subscribe();
|
|
1694
|
-
}
|
|
1695
|
-
ngOnDestroy() {
|
|
1696
|
-
var _a;
|
|
1697
|
-
(_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
1698
|
-
}
|
|
1699
|
-
}
|
|
1700
|
-
FormSubmitFailedDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormSubmitFailedDirective, deps: [{ token: FormDirective }, { token: TemplateRef }, { token: ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1701
|
-
FormSubmitFailedDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: FormSubmitFailedDirective, selector: "[rxapFormSubmitFailed]", ngImport: i0 });
|
|
1702
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormSubmitFailedDirective, decorators: [{
|
|
1703
|
-
type: Directive,
|
|
1704
|
-
args: [{
|
|
1705
|
-
selector: '[rxapFormSubmitFailed]'
|
|
1706
|
-
}]
|
|
1707
|
-
}], ctorParameters: function () {
|
|
1708
|
-
return [{ type: FormDirective, decorators: [{
|
|
1709
|
-
type: Inject,
|
|
1710
|
-
args: [FormDirective]
|
|
1711
|
-
}] }, { type: i0.TemplateRef, decorators: [{
|
|
1712
|
-
type: Inject,
|
|
1713
|
-
args: [TemplateRef]
|
|
1714
|
-
}] }, { type: i0.ViewContainerRef, decorators: [{
|
|
1715
|
-
type: Inject,
|
|
1716
|
-
args: [ViewContainerRef]
|
|
1717
|
-
}] }];
|
|
1718
|
-
} });
|
|
1719
|
-
|
|
1720
|
-
class FormLoadingDirective {
|
|
1721
|
-
constructor(formDirective, template, viewContainerRef) {
|
|
1722
|
-
this.formDirective = formDirective;
|
|
1723
|
-
this.template = template;
|
|
1724
|
-
this.viewContainerRef = viewContainerRef;
|
|
1725
|
-
}
|
|
1726
|
-
ngAfterViewInit() {
|
|
1727
|
-
this.subscription = this.formDirective.loading$.pipe(distinctUntilChanged(), tap(loading => {
|
|
1728
|
-
this.viewContainerRef.clear();
|
|
1729
|
-
if (loading) {
|
|
1730
|
-
this.viewContainerRef.createEmbeddedView(this.template);
|
|
1731
|
-
}
|
|
1732
|
-
})).subscribe();
|
|
1733
|
-
}
|
|
1734
|
-
ngOnDestroy() {
|
|
1735
|
-
var _a;
|
|
1736
|
-
(_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
1737
|
-
}
|
|
1738
|
-
}
|
|
1739
|
-
FormLoadingDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormLoadingDirective, deps: [{ token: FormDirective }, { token: TemplateRef }, { token: ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1740
|
-
FormLoadingDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: FormLoadingDirective, selector: "[rxapFormLoading]", ngImport: i0 });
|
|
1741
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormLoadingDirective, decorators: [{
|
|
1742
|
-
type: Directive,
|
|
1743
|
-
args: [{
|
|
1744
|
-
selector: '[rxapFormLoading]'
|
|
1745
|
-
}]
|
|
1746
|
-
}], ctorParameters: function () {
|
|
1747
|
-
return [{ type: FormDirective, decorators: [{
|
|
1748
|
-
type: Inject,
|
|
1749
|
-
args: [FormDirective]
|
|
1750
|
-
}] }, { type: i0.TemplateRef, decorators: [{
|
|
1751
|
-
type: Inject,
|
|
1752
|
-
args: [TemplateRef]
|
|
1753
|
-
}] }, { type: i0.ViewContainerRef, decorators: [{
|
|
1754
|
-
type: Inject,
|
|
1755
|
-
args: [ViewContainerRef]
|
|
1756
|
-
}] }];
|
|
1757
|
-
} });
|
|
1758
|
-
|
|
1759
|
-
class FormSubmittingDirective {
|
|
1760
|
-
constructor(formDirective, template, viewContainerRef) {
|
|
1761
|
-
this.formDirective = formDirective;
|
|
1762
|
-
this.template = template;
|
|
1763
|
-
this.viewContainerRef = viewContainerRef;
|
|
1764
|
-
}
|
|
1765
|
-
ngAfterViewInit() {
|
|
1766
|
-
this.subscription = this.formDirective.submitting$.pipe(distinctUntilChanged(), tap(loading => {
|
|
1767
|
-
this.viewContainerRef.clear();
|
|
1768
|
-
if (loading) {
|
|
1769
|
-
this.viewContainerRef.createEmbeddedView(this.template);
|
|
1770
|
-
}
|
|
1771
|
-
})).subscribe();
|
|
1772
|
-
}
|
|
1773
|
-
ngOnDestroy() {
|
|
1774
|
-
var _a;
|
|
1775
|
-
(_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
1776
|
-
}
|
|
1777
|
-
}
|
|
1778
|
-
FormSubmittingDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormSubmittingDirective, deps: [{ token: FormDirective }, { token: TemplateRef }, { token: ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1779
|
-
FormSubmittingDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: FormSubmittingDirective, selector: "[rxapFormSubmitting]", ngImport: i0 });
|
|
1780
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormSubmittingDirective, decorators: [{
|
|
1781
|
-
type: Directive,
|
|
1782
|
-
args: [{
|
|
1783
|
-
selector: '[rxapFormSubmitting]'
|
|
1784
|
-
}]
|
|
1785
|
-
}], ctorParameters: function () {
|
|
1786
|
-
return [{ type: FormDirective, decorators: [{
|
|
1787
|
-
type: Inject,
|
|
1788
|
-
args: [FormDirective]
|
|
1789
|
-
}] }, { type: i0.TemplateRef, decorators: [{
|
|
1790
|
-
type: Inject,
|
|
1791
|
-
args: [TemplateRef]
|
|
1792
|
-
}] }, { type: i0.ViewContainerRef, decorators: [{
|
|
1793
|
-
type: Inject,
|
|
1794
|
-
args: [ViewContainerRef]
|
|
1795
|
-
}] }];
|
|
1796
|
-
} });
|
|
1797
|
-
|
|
1798
|
-
class FormLoadedDirective {
|
|
1799
|
-
constructor(formDirective, template, viewContainerRef) {
|
|
1800
|
-
this.formDirective = formDirective;
|
|
1801
|
-
this.template = template;
|
|
1802
|
-
this.viewContainerRef = viewContainerRef;
|
|
1803
|
-
}
|
|
1804
|
-
ngAfterViewInit() {
|
|
1805
|
-
this.subscription = this.formDirective.loaded$.pipe(distinctUntilChanged(), tap(loading => {
|
|
1806
|
-
this.viewContainerRef.clear();
|
|
1807
|
-
if (loading) {
|
|
1808
|
-
this.viewContainerRef.createEmbeddedView(this.template);
|
|
1809
|
-
}
|
|
1810
|
-
})).subscribe();
|
|
1811
|
-
}
|
|
1812
|
-
ngOnDestroy() {
|
|
1813
|
-
var _a;
|
|
1814
|
-
(_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
1815
|
-
}
|
|
1816
|
-
}
|
|
1817
|
-
FormLoadedDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormLoadedDirective, deps: [{ token: FormDirective }, { token: TemplateRef }, { token: ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1818
|
-
FormLoadedDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: FormLoadedDirective, selector: "[rxapFormLoaded]", ngImport: i0 });
|
|
1819
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormLoadedDirective, decorators: [{
|
|
1820
|
-
type: Directive,
|
|
1821
|
-
args: [{
|
|
1822
|
-
selector: '[rxapFormLoaded]'
|
|
1823
|
-
}]
|
|
1824
|
-
}], ctorParameters: function () {
|
|
1825
|
-
return [{ type: FormDirective, decorators: [{
|
|
1826
|
-
type: Inject,
|
|
1827
|
-
args: [FormDirective]
|
|
1828
|
-
}] }, { type: i0.TemplateRef, decorators: [{
|
|
1829
|
-
type: Inject,
|
|
1830
|
-
args: [TemplateRef]
|
|
1831
|
-
}] }, { type: i0.ViewContainerRef, decorators: [{
|
|
1832
|
-
type: Inject,
|
|
1833
|
-
args: [ViewContainerRef]
|
|
1834
|
-
}] }];
|
|
1835
|
-
} });
|
|
1836
|
-
|
|
1837
|
-
class FormLoadingErrorDirective {
|
|
1838
|
-
constructor(formDirective, template, viewContainerRef) {
|
|
1839
|
-
this.formDirective = formDirective;
|
|
1840
|
-
this.template = template;
|
|
1841
|
-
this.viewContainerRef = viewContainerRef;
|
|
1842
|
-
}
|
|
1843
|
-
ngAfterViewInit() {
|
|
1844
|
-
this.subscription = this.formDirective.loadingError$.pipe(tap(error => {
|
|
1845
|
-
this.viewContainerRef.clear();
|
|
1846
|
-
if (error !== null) {
|
|
1847
|
-
this.viewContainerRef.createEmbeddedView(this.template, { $implicit: error });
|
|
1848
|
-
}
|
|
1849
|
-
})).subscribe();
|
|
1850
|
-
}
|
|
1851
|
-
ngOnDestroy() {
|
|
1852
|
-
var _a;
|
|
1853
|
-
(_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
1854
|
-
}
|
|
1855
|
-
}
|
|
1856
|
-
FormLoadingErrorDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormLoadingErrorDirective, deps: [{ token: FormDirective }, { token: TemplateRef }, { token: ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1857
|
-
FormLoadingErrorDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: FormLoadingErrorDirective, selector: "[rxapFormLoadingError]", ngImport: i0 });
|
|
1858
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormLoadingErrorDirective, decorators: [{
|
|
1859
|
-
type: Directive,
|
|
1860
|
-
args: [{
|
|
1861
|
-
selector: '[rxapFormLoadingError]'
|
|
1862
|
-
}]
|
|
1863
|
-
}], ctorParameters: function () {
|
|
1864
|
-
return [{ type: FormDirective, decorators: [{
|
|
1865
|
-
type: Inject,
|
|
1866
|
-
args: [FormDirective]
|
|
1867
|
-
}] }, { type: i0.TemplateRef, decorators: [{
|
|
1868
|
-
type: Inject,
|
|
1869
|
-
args: [TemplateRef]
|
|
1870
|
-
}] }, { type: i0.ViewContainerRef, decorators: [{
|
|
1871
|
-
type: Inject,
|
|
1872
|
-
args: [ViewContainerRef]
|
|
1873
|
-
}] }];
|
|
1874
|
-
} });
|
|
1875
|
-
|
|
1876
|
-
/**
|
|
1877
|
-
* @deprecated removed
|
|
1878
|
-
*/
|
|
1879
|
-
class FormControlErrorDirective {
|
|
1880
|
-
constructor(template, parent, viewContainerRef) {
|
|
1881
|
-
this.template = template;
|
|
1882
|
-
this.parent = parent;
|
|
1883
|
-
this.viewContainerRef = viewContainerRef;
|
|
1884
|
-
}
|
|
1885
|
-
ngOnInit() {
|
|
1886
|
-
var _a;
|
|
1887
|
-
const control = (_a = this.parent.control) === null || _a === void 0 ? void 0 : _a.get(this.name);
|
|
1888
|
-
if (!control) {
|
|
1889
|
-
throw new Error('Could not extract form control instance');
|
|
1890
|
-
}
|
|
1891
|
-
this.subscription = control.statusChanges.pipe(startWith(control.status), filter(status => status === 'INVALID'), tap(() => {
|
|
1892
|
-
this.viewContainerRef.clear();
|
|
1893
|
-
if (control.hasError(this.errorKey)) {
|
|
1894
|
-
this.viewContainerRef.createEmbeddedView(this.template, { $implicit: control.getError(this.errorKey) });
|
|
1895
|
-
}
|
|
1896
|
-
})).subscribe();
|
|
1897
|
-
}
|
|
1898
|
-
ngOnDestroy() {
|
|
1899
|
-
var _a;
|
|
1900
|
-
(_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
1901
|
-
}
|
|
1902
|
-
}
|
|
1903
|
-
FormControlErrorDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormControlErrorDirective, deps: [{ token: i0.TemplateRef }, { token: i1.ControlContainer, host: true, skipSelf: true }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1904
|
-
FormControlErrorDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: FormControlErrorDirective, selector: "[rxapFormControlError]", inputs: { name: ["rxapFormControlErrorFrom", "name"], errorKey: ["rxapFormControlErrorIf", "errorKey"] }, ngImport: i0 });
|
|
1905
|
-
__decorate([
|
|
1906
|
-
Required,
|
|
1907
|
-
__metadata("design:type", String)
|
|
1908
|
-
], FormControlErrorDirective.prototype, "name", void 0);
|
|
1909
|
-
__decorate([
|
|
1910
|
-
Required,
|
|
1911
|
-
__metadata("design:type", String)
|
|
1912
|
-
], FormControlErrorDirective.prototype, "errorKey", void 0);
|
|
1913
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormControlErrorDirective, decorators: [{
|
|
1914
|
-
type: Directive,
|
|
1915
|
-
args: [{
|
|
1916
|
-
selector: '[rxapFormControlError]'
|
|
1917
|
-
}]
|
|
1918
|
-
}], ctorParameters: function () {
|
|
1919
|
-
return [{ type: i0.TemplateRef }, { type: i1.ControlContainer, decorators: [{
|
|
1920
|
-
type: Host
|
|
1921
|
-
}, {
|
|
1922
|
-
type: SkipSelf
|
|
1923
|
-
}] }, { type: i0.ViewContainerRef }];
|
|
1924
|
-
}, propDecorators: { name: [{
|
|
1925
|
-
type: Input,
|
|
1926
|
-
args: ['rxapFormControlErrorFrom']
|
|
1927
|
-
}], errorKey: [{
|
|
1928
|
-
type: Input,
|
|
1929
|
-
args: ['rxapFormControlErrorIf']
|
|
1930
|
-
}] } });
|
|
1931
|
-
|
|
1932
|
-
class FormControlMarkDirtyDirective {
|
|
1933
|
-
constructor(parent) {
|
|
1934
|
-
this.parent = parent;
|
|
1935
|
-
}
|
|
1936
|
-
onClick() {
|
|
1937
|
-
const control = this.parent.control;
|
|
1938
|
-
if (control && hasIndexSignature(control) && typeof control['markAllAsDirty'] === 'function') {
|
|
1939
|
-
control.markAllAsDirty();
|
|
1940
|
-
}
|
|
1941
|
-
else {
|
|
1942
|
-
control === null || control === void 0 ? void 0 : control.markAsDirty();
|
|
1943
|
-
}
|
|
1944
|
-
}
|
|
1945
|
-
}
|
|
1946
|
-
FormControlMarkDirtyDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormControlMarkDirtyDirective, deps: [{ token: i1.ControlContainer }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1947
|
-
FormControlMarkDirtyDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: FormControlMarkDirtyDirective, selector: "[rxapFormControlMarkDirty]", host: { listeners: { "click": "onClick()" } }, ngImport: i0 });
|
|
1948
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormControlMarkDirtyDirective, decorators: [{
|
|
1949
|
-
type: Directive,
|
|
1950
|
-
args: [{
|
|
1951
|
-
selector: '[rxapFormControlMarkDirty]'
|
|
1952
|
-
}]
|
|
1953
|
-
}], ctorParameters: function () { return [{ type: i1.ControlContainer }]; }, propDecorators: { onClick: [{
|
|
1954
|
-
type: HostListener,
|
|
1955
|
-
args: ['click']
|
|
1956
|
-
}] } });
|
|
1957
|
-
|
|
1958
|
-
class FormControlMarkTouchedDirective {
|
|
1959
|
-
constructor(parent) {
|
|
1960
|
-
this.parent = parent;
|
|
1961
|
-
}
|
|
1962
|
-
onClick() {
|
|
1963
|
-
var _a;
|
|
1964
|
-
(_a = this.parent.control) === null || _a === void 0 ? void 0 : _a.markAllAsTouched();
|
|
1965
|
-
}
|
|
1966
|
-
}
|
|
1967
|
-
FormControlMarkTouchedDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormControlMarkTouchedDirective, deps: [{ token: i1.ControlContainer }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1968
|
-
FormControlMarkTouchedDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: FormControlMarkTouchedDirective, selector: "[rxapFormControlMarkTouched]", host: { listeners: { "click": "onClick()" } }, ngImport: i0 });
|
|
1969
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormControlMarkTouchedDirective, decorators: [{
|
|
1970
|
-
type: Directive,
|
|
1971
|
-
args: [{
|
|
1972
|
-
selector: '[rxapFormControlMarkTouched]'
|
|
1973
|
-
}]
|
|
1974
|
-
}], ctorParameters: function () { return [{ type: i1.ControlContainer }]; }, propDecorators: { onClick: [{
|
|
1975
|
-
type: HostListener,
|
|
1976
|
-
args: ['click']
|
|
1977
|
-
}] } });
|
|
1978
|
-
|
|
1979
|
-
class FormControlMarkUntouchedDirective {
|
|
1980
|
-
constructor(parent) {
|
|
1981
|
-
this.parent = parent;
|
|
1982
|
-
}
|
|
1983
|
-
onClick() {
|
|
1984
|
-
const control = this.parent.control;
|
|
1985
|
-
if (control && hasIndexSignature(control) && typeof control['markAllAsUntouched'] === 'function') {
|
|
1986
|
-
control.markAllAsUntouched();
|
|
1987
|
-
}
|
|
1988
|
-
else {
|
|
1989
|
-
control === null || control === void 0 ? void 0 : control.markAsUntouched();
|
|
1990
|
-
}
|
|
1991
|
-
}
|
|
1992
|
-
}
|
|
1993
|
-
FormControlMarkUntouchedDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormControlMarkUntouchedDirective, deps: [{ token: i1.ControlContainer }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1994
|
-
FormControlMarkUntouchedDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: FormControlMarkUntouchedDirective, selector: "[rxapFormControlMarkUntouched]", host: { listeners: { "click": "onClick()" } }, ngImport: i0 });
|
|
1995
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormControlMarkUntouchedDirective, decorators: [{
|
|
1996
|
-
type: Directive,
|
|
1997
|
-
args: [{
|
|
1998
|
-
selector: '[rxapFormControlMarkUntouched]'
|
|
1999
|
-
}]
|
|
2000
|
-
}], ctorParameters: function () { return [{ type: i1.ControlContainer }]; }, propDecorators: { onClick: [{
|
|
2001
|
-
type: HostListener,
|
|
2002
|
-
args: ['click']
|
|
2003
|
-
}] } });
|
|
2004
|
-
|
|
2005
|
-
class FormControlMarkPristineDirective {
|
|
2006
|
-
constructor(parent) {
|
|
2007
|
-
this.parent = parent;
|
|
2008
|
-
}
|
|
2009
|
-
onClick() {
|
|
2010
|
-
const control = this.parent.control;
|
|
2011
|
-
if (control && hasIndexSignature(control) && typeof control['markAllAsPristine'] === 'function') {
|
|
2012
|
-
control.markAllAsPristine();
|
|
2013
|
-
}
|
|
2014
|
-
else {
|
|
2015
|
-
control === null || control === void 0 ? void 0 : control.markAsPristine();
|
|
2016
|
-
}
|
|
2017
|
-
}
|
|
2018
|
-
}
|
|
2019
|
-
FormControlMarkPristineDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormControlMarkPristineDirective, deps: [{ token: i1.ControlContainer }], target: i0.ɵɵFactoryTarget.Directive });
|
|
2020
|
-
FormControlMarkPristineDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: FormControlMarkPristineDirective, selector: "[rxapFormControlMarkPristine]", host: { listeners: { "click": "onClick()" } }, ngImport: i0 });
|
|
2021
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormControlMarkPristineDirective, decorators: [{
|
|
2022
|
-
type: Directive,
|
|
2023
|
-
args: [{
|
|
2024
|
-
selector: '[rxapFormControlMarkPristine]'
|
|
2025
|
-
}]
|
|
2026
|
-
}], ctorParameters: function () { return [{ type: i1.ControlContainer }]; }, propDecorators: { onClick: [{
|
|
2027
|
-
type: HostListener,
|
|
2028
|
-
args: ['click']
|
|
2029
|
-
}] } });
|
|
2030
|
-
|
|
2031
|
-
class FormSubmitDirective extends ConfirmClick {
|
|
2032
|
-
constructor(formDirective, router = null) {
|
|
2033
|
-
super();
|
|
2034
|
-
this.formDirective = formDirective;
|
|
2035
|
-
this.router = router;
|
|
2036
|
-
this.type = 'button';
|
|
2037
|
-
this.afterSubmit = new EventEmitter();
|
|
2038
|
-
this._resetAfterSubmit = false;
|
|
2039
|
-
}
|
|
2040
|
-
set resetAfterSubmit(value) {
|
|
2041
|
-
this._resetAfterSubmit = coerceBoolean(value);
|
|
2042
|
-
}
|
|
2043
|
-
execute() {
|
|
2044
|
-
this.formDirective.form.markAllAsDirty();
|
|
2045
|
-
this.formDirective.form.markAllAsTouched();
|
|
2046
|
-
this.formDirective.cdr.markForCheck();
|
|
2047
|
-
this.subscription = this.formDirective.rxapSubmit.pipe(take(1), tap(value => {
|
|
2048
|
-
const clonedValue = clone(value);
|
|
2049
|
-
this.afterSubmit.emit(clonedValue);
|
|
2050
|
-
if (this._resetAfterSubmit) {
|
|
2051
|
-
this.formDirective.reset();
|
|
2052
|
-
}
|
|
2053
|
-
if (this.navigateAfterSubmit) {
|
|
2054
|
-
if (!this.router) {
|
|
2055
|
-
throw new Error('Could not resolve the router!');
|
|
2056
|
-
}
|
|
2057
|
-
return this.router.navigate(this.navigateAfterSubmit);
|
|
2058
|
-
}
|
|
2059
|
-
return Promise.resolve();
|
|
2060
|
-
})).subscribe();
|
|
2061
|
-
this.formDirective.onSubmit(new Event('submit'));
|
|
2062
|
-
}
|
|
2063
|
-
ngOnDestroy() {
|
|
2064
|
-
var _a;
|
|
2065
|
-
(_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
2066
|
-
}
|
|
2067
|
-
}
|
|
2068
|
-
FormSubmitDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormSubmitDirective, deps: [{ token: FormDirective }, { token: Router, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
2069
|
-
FormSubmitDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: FormSubmitDirective, selector: "[rxapFormSubmit]", inputs: { type: "type", resetAfterSubmit: "resetAfterSubmit", navigateAfterSubmit: "navigateAfterSubmit" }, outputs: { afterSubmit: "afterSubmit" }, host: { listeners: { "click": "onClick()", "confirmed": "onConfirm()" }, properties: { "type": "this.type" } }, usesInheritance: true, ngImport: i0 });
|
|
2070
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormSubmitDirective, decorators: [{
|
|
2071
|
-
type: Directive,
|
|
2072
|
-
args: [{
|
|
2073
|
-
selector: '[rxapFormSubmit]',
|
|
2074
|
-
host: {
|
|
2075
|
-
'(click)': 'onClick()',
|
|
2076
|
-
'(confirmed)': 'onConfirm()',
|
|
2077
|
-
}
|
|
2078
|
-
}]
|
|
2079
|
-
}], ctorParameters: function () {
|
|
2080
|
-
return [{ type: FormDirective, decorators: [{
|
|
2081
|
-
type: Inject,
|
|
2082
|
-
args: [FormDirective]
|
|
2083
|
-
}] }, { type: i2$1.Router, decorators: [{
|
|
2084
|
-
type: Optional
|
|
2085
|
-
}, {
|
|
2086
|
-
type: Inject,
|
|
2087
|
-
args: [Router]
|
|
2088
|
-
}] }];
|
|
2089
|
-
}, propDecorators: { type: [{
|
|
2090
|
-
type: HostBinding,
|
|
2091
|
-
args: ['type']
|
|
2092
|
-
}, {
|
|
2093
|
-
type: Input
|
|
2094
|
-
}], resetAfterSubmit: [{
|
|
2095
|
-
type: Input,
|
|
2096
|
-
args: ['resetAfterSubmit']
|
|
2097
|
-
}], navigateAfterSubmit: [{
|
|
2098
|
-
type: Input
|
|
2099
|
-
}], afterSubmit: [{
|
|
2100
|
-
type: Output
|
|
2101
|
-
}] } });
|
|
2102
|
-
|
|
2103
|
-
/**
|
|
2104
|
-
* A full exertion of FormGroupName from @angular/forms. The only change is the
|
|
2105
|
-
* ability to access the control container outside of the current component
|
|
2106
|
-
*
|
|
2107
|
-
* @deprecated use the ParentControlContainerDirective
|
|
2108
|
-
*/
|
|
2109
|
-
class FormGroupNameDirective extends FormGroupName {
|
|
2110
|
-
constructor(parent, validators, asyncValidators) {
|
|
2111
|
-
super(parent, validators, asyncValidators);
|
|
2112
|
-
}
|
|
2113
|
-
get control() {
|
|
2114
|
-
// TODO : add type check
|
|
2115
|
-
return this.formDirective.getFormGroup(this);
|
|
2116
|
-
}
|
|
2117
|
-
}
|
|
2118
|
-
FormGroupNameDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormGroupNameDirective, deps: [{ token: i1.ControlContainer, optional: true, skipSelf: true }, { token: NG_VALIDATORS, optional: true, self: true }, { token: NG_ASYNC_VALIDATORS, optional: true, self: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
2119
|
-
FormGroupNameDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: FormGroupNameDirective, selector: "[rxapFormGroupName]", inputs: { name: ["rxapFormGroupName", "name"] }, providers: [
|
|
2120
|
-
{
|
|
2121
|
-
provide: ControlContainer,
|
|
2122
|
-
useExisting: forwardRef(() => FormGroupNameDirective)
|
|
2123
|
-
}
|
|
2124
|
-
], exportAs: ["rxapFormGroup"], usesInheritance: true, ngImport: i0 });
|
|
2125
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormGroupNameDirective, decorators: [{
|
|
2126
|
-
type: Directive,
|
|
2127
|
-
args: [{
|
|
2128
|
-
selector: '[rxapFormGroupName]',
|
|
2129
|
-
providers: [
|
|
2130
|
-
{
|
|
2131
|
-
provide: ControlContainer,
|
|
2132
|
-
useExisting: forwardRef(() => FormGroupNameDirective)
|
|
2133
|
-
}
|
|
2134
|
-
],
|
|
2135
|
-
exportAs: 'rxapFormGroup'
|
|
2136
|
-
}]
|
|
2137
|
-
}], ctorParameters: function () {
|
|
2138
|
-
return [{ type: i1.ControlContainer, decorators: [{
|
|
2139
|
-
type: Optional
|
|
2140
|
-
}, {
|
|
2141
|
-
type: SkipSelf
|
|
2142
|
-
}] }, { type: undefined, decorators: [{
|
|
2143
|
-
type: Optional
|
|
2144
|
-
}, {
|
|
2145
|
-
type: Self
|
|
2146
|
-
}, {
|
|
2147
|
-
type: Inject,
|
|
2148
|
-
args: [NG_VALIDATORS]
|
|
2149
|
-
}] }, { type: undefined, decorators: [{
|
|
2150
|
-
type: Optional
|
|
2151
|
-
}, {
|
|
2152
|
-
type: Self
|
|
2153
|
-
}, {
|
|
2154
|
-
type: Inject,
|
|
2155
|
-
args: [NG_ASYNC_VALIDATORS]
|
|
2156
|
-
}] }];
|
|
2157
|
-
}, propDecorators: { name: [{
|
|
2158
|
-
type: Input,
|
|
2159
|
-
args: ['rxapFormGroupName']
|
|
2160
|
-
}] } });
|
|
2161
|
-
|
|
2162
|
-
/**
|
|
2163
|
-
* A full exertion of FormControlName from @angular/forms. The only change is the
|
|
2164
|
-
* ability to access the control container outside of the current component
|
|
2165
|
-
*
|
|
2166
|
-
* @deprecated use the ParentControlContainerDirective
|
|
2167
|
-
*/
|
|
2168
|
-
class FormControlNameDirective extends FormControlName {
|
|
2169
|
-
constructor(parent, validators, asyncValidators, valueAccessors) {
|
|
2170
|
-
super(parent, validators, asyncValidators, valueAccessors, null);
|
|
2171
|
-
}
|
|
2172
|
-
}
|
|
2173
|
-
FormControlNameDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormControlNameDirective, deps: [{ token: i1.ControlContainer, optional: true, skipSelf: true }, { token: NG_VALIDATORS, optional: true, self: true }, { token: NG_ASYNC_VALIDATORS, optional: true, self: true }, { token: NG_VALUE_ACCESSOR, optional: true, self: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
2174
|
-
FormControlNameDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: FormControlNameDirective, selector: "[rxapFormControlName]", inputs: { name: ["rxapFormControlName", "name"] }, providers: [
|
|
2175
|
-
{
|
|
2176
|
-
provide: NgControl,
|
|
2177
|
-
useExisting: forwardRef(() => FormControlNameDirective)
|
|
2178
|
-
}
|
|
2179
|
-
], exportAs: ["rxapFormControl"], usesInheritance: true, ngImport: i0 });
|
|
2180
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormControlNameDirective, decorators: [{
|
|
2181
|
-
type: Directive,
|
|
2182
|
-
args: [{
|
|
2183
|
-
selector: '[rxapFormControlName]',
|
|
2184
|
-
providers: [
|
|
2185
|
-
{
|
|
2186
|
-
provide: NgControl,
|
|
2187
|
-
useExisting: forwardRef(() => FormControlNameDirective)
|
|
2188
|
-
}
|
|
2189
|
-
],
|
|
2190
|
-
exportAs: 'rxapFormControl'
|
|
2191
|
-
}]
|
|
2192
|
-
}], ctorParameters: function () {
|
|
2193
|
-
return [{ type: i1.ControlContainer, decorators: [{
|
|
2194
|
-
type: Optional
|
|
2195
|
-
}, {
|
|
2196
|
-
type: SkipSelf
|
|
2197
|
-
}] }, { type: Array, decorators: [{
|
|
2198
|
-
type: Optional
|
|
2199
|
-
}, {
|
|
2200
|
-
type: Self
|
|
2201
|
-
}, {
|
|
2202
|
-
type: Inject,
|
|
2203
|
-
args: [NG_VALIDATORS]
|
|
2204
|
-
}] }, { type: Array, decorators: [{
|
|
2205
|
-
type: Optional
|
|
2206
|
-
}, {
|
|
2207
|
-
type: Self
|
|
2208
|
-
}, {
|
|
2209
|
-
type: Inject,
|
|
2210
|
-
args: [NG_ASYNC_VALIDATORS]
|
|
2211
|
-
}] }, { type: undefined, decorators: [{
|
|
2212
|
-
type: Optional
|
|
2213
|
-
}, {
|
|
2214
|
-
type: Self
|
|
2215
|
-
}, {
|
|
2216
|
-
type: Inject,
|
|
2217
|
-
args: [NG_VALUE_ACCESSOR]
|
|
2218
|
-
}] }];
|
|
2219
|
-
}, propDecorators: { name: [{
|
|
2220
|
-
type: Input,
|
|
2221
|
-
args: ['rxapFormControlName']
|
|
2222
|
-
}] } });
|
|
2223
|
-
|
|
2224
|
-
class ParentControlContainerDirective {
|
|
2225
|
-
}
|
|
2226
|
-
ParentControlContainerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: ParentControlContainerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2227
|
-
ParentControlContainerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: ParentControlContainerDirective, selector: "[formControlName][parentControlContainer],[formControlGroup][parentControlContainer]", providers: [
|
|
2228
|
-
{
|
|
2229
|
-
provide: ControlContainer,
|
|
2230
|
-
useExisting: ControlContainer
|
|
2231
|
-
}
|
|
2232
|
-
], ngImport: i0 });
|
|
2233
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: ParentControlContainerDirective, decorators: [{
|
|
2234
|
-
type: Directive,
|
|
2235
|
-
args: [{
|
|
2236
|
-
selector: '[formControlName][parentControlContainer],[formControlGroup][parentControlContainer]',
|
|
2237
|
-
providers: [
|
|
2238
|
-
{
|
|
2239
|
-
provide: ControlContainer,
|
|
2240
|
-
useExisting: ControlContainer
|
|
2241
|
-
}
|
|
2242
|
-
]
|
|
2243
|
-
}]
|
|
2244
|
-
}] });
|
|
2245
|
-
|
|
2246
|
-
class FormSubmitSuccessfulDirective {
|
|
2247
|
-
constructor(formDirective, template, viewContainerRef) {
|
|
2248
|
-
this.formDirective = formDirective;
|
|
2249
|
-
this.template = template;
|
|
2250
|
-
this.viewContainerRef = viewContainerRef;
|
|
2251
|
-
}
|
|
2252
|
-
ngAfterViewInit() {
|
|
2253
|
-
this.subscription = this.formDirective.submitSuccessful$.pipe(tap(result => {
|
|
2254
|
-
this.viewContainerRef.clear();
|
|
2255
|
-
this.viewContainerRef.createEmbeddedView(this.template, { $implicit: result });
|
|
2256
|
-
})).subscribe();
|
|
2257
|
-
}
|
|
2258
|
-
ngOnDestroy() {
|
|
2259
|
-
var _a;
|
|
2260
|
-
(_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
2261
|
-
}
|
|
2262
|
-
}
|
|
2263
|
-
FormSubmitSuccessfulDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormSubmitSuccessfulDirective, deps: [{ token: FormDirective }, { token: TemplateRef }, { token: ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
2264
|
-
FormSubmitSuccessfulDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: FormSubmitSuccessfulDirective, selector: "[rxapFormSubmitSuccessful]", ngImport: i0 });
|
|
2265
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormSubmitSuccessfulDirective, decorators: [{
|
|
2266
|
-
type: Directive,
|
|
2267
|
-
args: [{
|
|
2268
|
-
selector: '[rxapFormSubmitSuccessful]'
|
|
2269
|
-
}]
|
|
2270
|
-
}], ctorParameters: function () {
|
|
2271
|
-
return [{ type: FormDirective, decorators: [{
|
|
2272
|
-
type: Inject,
|
|
2273
|
-
args: [FormDirective]
|
|
2274
|
-
}] }, { type: i0.TemplateRef, decorators: [{
|
|
2275
|
-
type: Inject,
|
|
2276
|
-
args: [TemplateRef]
|
|
2277
|
-
}] }, { type: i0.ViewContainerRef, decorators: [{
|
|
2278
|
-
type: Inject,
|
|
2279
|
-
args: [ViewContainerRef]
|
|
2280
|
-
}] }];
|
|
2281
|
-
} });
|
|
2282
|
-
|
|
2283
|
-
class FormSubmitInvalidDirective {
|
|
2284
|
-
constructor(formDirective, template, viewContainerRef) {
|
|
2285
|
-
this.formDirective = formDirective;
|
|
2286
|
-
this.template = template;
|
|
2287
|
-
this.viewContainerRef = viewContainerRef;
|
|
2288
|
-
}
|
|
2289
|
-
ngAfterViewInit() {
|
|
2290
|
-
this.subscription = this.formDirective.invalidSubmit.pipe(tap(result => {
|
|
2291
|
-
this.viewContainerRef.clear();
|
|
2292
|
-
this.viewContainerRef.createEmbeddedView(this.template, { $implicit: result });
|
|
2293
|
-
})).subscribe();
|
|
2294
|
-
}
|
|
2295
|
-
ngOnDestroy() {
|
|
2296
|
-
var _a;
|
|
2297
|
-
(_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
2298
|
-
}
|
|
2299
|
-
}
|
|
2300
|
-
FormSubmitInvalidDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormSubmitInvalidDirective, deps: [{ token: FormDirective }, { token: TemplateRef }, { token: ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
2301
|
-
FormSubmitInvalidDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: FormSubmitInvalidDirective, selector: "[rxapFormSubmitInvalid]", ngImport: i0 });
|
|
2302
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormSubmitInvalidDirective, decorators: [{
|
|
2303
|
-
type: Directive,
|
|
2304
|
-
args: [{
|
|
2305
|
-
selector: '[rxapFormSubmitInvalid]'
|
|
2306
|
-
}]
|
|
2307
|
-
}], ctorParameters: function () {
|
|
2308
|
-
return [{ type: FormDirective, decorators: [{
|
|
2309
|
-
type: Inject,
|
|
2310
|
-
args: [FormDirective]
|
|
2311
|
-
}] }, { type: i0.TemplateRef, decorators: [{
|
|
2312
|
-
type: Inject,
|
|
2313
|
-
args: [TemplateRef]
|
|
2314
|
-
}] }, { type: i0.ViewContainerRef, decorators: [{
|
|
2315
|
-
type: Inject,
|
|
2316
|
-
args: [ViewContainerRef]
|
|
2317
|
-
}] }];
|
|
2318
|
-
} });
|
|
2319
|
-
|
|
2320
|
-
class RxapFormsModule {
|
|
2321
|
-
}
|
|
2322
|
-
RxapFormsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: RxapFormsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
2323
|
-
RxapFormsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.2", ngImport: i0, type: RxapFormsModule, declarations: [FormDirective,
|
|
2324
|
-
FormSubmitFailedDirective,
|
|
2325
|
-
FormLoadingDirective,
|
|
2326
|
-
FormSubmittingDirective,
|
|
2327
|
-
FormLoadingErrorDirective,
|
|
2328
|
-
FormLoadedDirective,
|
|
2329
|
-
FormControlErrorDirective,
|
|
2330
|
-
FormControlMarkDirtyDirective,
|
|
2331
|
-
FormControlMarkTouchedDirective,
|
|
2332
|
-
FormControlMarkUntouchedDirective,
|
|
2333
|
-
FormControlMarkPristineDirective,
|
|
2334
|
-
FormSubmitDirective,
|
|
2335
|
-
FormGroupNameDirective,
|
|
2336
|
-
FormControlNameDirective,
|
|
2337
|
-
ParentControlContainerDirective,
|
|
2338
|
-
FormSubmitSuccessfulDirective,
|
|
2339
|
-
FormSubmitInvalidDirective], exports: [FormDirective,
|
|
2340
|
-
FormSubmitFailedDirective,
|
|
2341
|
-
FormLoadingDirective,
|
|
2342
|
-
FormSubmittingDirective,
|
|
2343
|
-
FormLoadingErrorDirective,
|
|
2344
|
-
FormLoadedDirective,
|
|
2345
|
-
FormControlErrorDirective,
|
|
2346
|
-
FormControlMarkDirtyDirective,
|
|
2347
|
-
FormControlMarkTouchedDirective,
|
|
2348
|
-
FormControlMarkUntouchedDirective,
|
|
2349
|
-
FormControlMarkPristineDirective,
|
|
2350
|
-
FormSubmitDirective,
|
|
2351
|
-
FormGroupNameDirective,
|
|
2352
|
-
FormControlNameDirective,
|
|
2353
|
-
ParentControlContainerDirective,
|
|
2354
|
-
FormSubmitSuccessfulDirective,
|
|
2355
|
-
FormSubmitInvalidDirective] });
|
|
2356
|
-
RxapFormsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: RxapFormsModule });
|
|
2357
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: RxapFormsModule, decorators: [{
|
|
2358
|
-
type: NgModule,
|
|
2359
|
-
args: [{
|
|
2360
|
-
declarations: [
|
|
2361
|
-
FormDirective,
|
|
2362
|
-
FormSubmitFailedDirective,
|
|
2363
|
-
FormLoadingDirective,
|
|
2364
|
-
FormSubmittingDirective,
|
|
2365
|
-
FormLoadingErrorDirective,
|
|
2366
|
-
FormLoadedDirective,
|
|
2367
|
-
FormControlErrorDirective,
|
|
2368
|
-
FormControlMarkDirtyDirective,
|
|
2369
|
-
FormControlMarkTouchedDirective,
|
|
2370
|
-
FormControlMarkUntouchedDirective,
|
|
2371
|
-
FormControlMarkPristineDirective,
|
|
2372
|
-
FormSubmitDirective,
|
|
2373
|
-
FormGroupNameDirective,
|
|
2374
|
-
FormControlNameDirective,
|
|
2375
|
-
ParentControlContainerDirective,
|
|
2376
|
-
FormSubmitSuccessfulDirective,
|
|
2377
|
-
FormSubmitInvalidDirective,
|
|
2378
|
-
],
|
|
2379
|
-
exports: [
|
|
2380
|
-
FormDirective,
|
|
2381
|
-
FormSubmitFailedDirective,
|
|
2382
|
-
FormLoadingDirective,
|
|
2383
|
-
FormSubmittingDirective,
|
|
2384
|
-
FormLoadingErrorDirective,
|
|
2385
|
-
FormLoadedDirective,
|
|
2386
|
-
FormControlErrorDirective,
|
|
2387
|
-
FormControlMarkDirtyDirective,
|
|
2388
|
-
FormControlMarkTouchedDirective,
|
|
2389
|
-
FormControlMarkUntouchedDirective,
|
|
2390
|
-
FormControlMarkPristineDirective,
|
|
2391
|
-
FormSubmitDirective,
|
|
2392
|
-
FormGroupNameDirective,
|
|
2393
|
-
FormControlNameDirective,
|
|
2394
|
-
ParentControlContainerDirective,
|
|
2395
|
-
FormSubmitSuccessfulDirective,
|
|
2396
|
-
FormSubmitInvalidDirective,
|
|
2397
|
-
]
|
|
2398
|
-
}]
|
|
2399
|
-
}] });
|
|
2400
|
-
|
|
2401
|
-
function ToFormMethod(call) {
|
|
2402
|
-
return { call };
|
|
2403
|
-
}
|
|
2404
|
-
/**
|
|
2405
|
-
* @deprecated use ToFormMethod instead
|
|
2406
|
-
*
|
|
2407
|
-
* @param call the call method implementation
|
|
2408
|
-
*/
|
|
2409
|
-
function ToFormSubmitMethod(call) {
|
|
2410
|
-
return ToFormMethod(call);
|
|
2411
|
-
}
|
|
2412
|
-
|
|
2413
|
-
/**
|
|
2414
|
-
* Checks if a given value is a number.
|
|
2415
|
-
*/
|
|
2416
|
-
function isNumber(value, options = {}) {
|
|
2417
|
-
var _a, _b;
|
|
2418
|
-
if (typeof value !== 'number') {
|
|
2419
|
-
return false;
|
|
2420
|
-
}
|
|
2421
|
-
if (value === Infinity || value === -Infinity) {
|
|
2422
|
-
return (_a = options.allowInfinity) !== null && _a !== void 0 ? _a : false;
|
|
2423
|
-
}
|
|
2424
|
-
if (Number.isNaN(value)) {
|
|
2425
|
-
return (_b = options.allowNaN) !== null && _b !== void 0 ? _b : false;
|
|
2426
|
-
}
|
|
2427
|
-
if (options.maxDecimalPlaces !== undefined) {
|
|
2428
|
-
let decimalPlaces = 0;
|
|
2429
|
-
if (value % 1 !== 0) {
|
|
2430
|
-
decimalPlaces = value.toString().split('.')[1].length;
|
|
2431
|
-
}
|
|
2432
|
-
if (decimalPlaces > options.maxDecimalPlaces) {
|
|
2433
|
-
return false;
|
|
2434
|
-
}
|
|
2435
|
-
}
|
|
2436
|
-
return Number.isFinite(value);
|
|
2437
|
-
}
|
|
2438
|
-
/**
|
|
2439
|
-
* @deprecated use RxapValidators.isNumber() instead
|
|
2440
|
-
* @param control
|
|
2441
|
-
* @constructor
|
|
2442
|
-
*/
|
|
2443
|
-
function IsNumber(control) {
|
|
2444
|
-
if (control.value === null) {
|
|
2445
|
-
return null;
|
|
2446
|
-
}
|
|
2447
|
-
if (isNaN(Number(control.value))) {
|
|
2448
|
-
return { isNumber: { expected: 'A number or a string representing a number', actual: control.value } };
|
|
2449
|
-
}
|
|
2450
|
-
return null;
|
|
2451
|
-
}
|
|
2452
|
-
function _IsNumber({ message, options } = {}) {
|
|
2453
|
-
return (control) => {
|
|
2454
|
-
if (control.value === null) {
|
|
2455
|
-
return null;
|
|
2456
|
-
}
|
|
2457
|
-
if (!isNumber(!(options === null || options === void 0 ? void 0 : options.strict) && typeof control.value === 'string' ? Number(control.value) : control.value, options)) {
|
|
2458
|
-
return {
|
|
2459
|
-
isNumber: {
|
|
2460
|
-
expected: 'A number value',
|
|
2461
|
-
actual: control.value,
|
|
2462
|
-
message
|
|
2463
|
-
}
|
|
2464
|
-
};
|
|
2465
|
-
}
|
|
2466
|
-
return null;
|
|
2467
|
-
};
|
|
2468
|
-
}
|
|
2469
|
-
|
|
2470
|
-
function IsBoolean({ message } = {}) {
|
|
2471
|
-
return (control) => {
|
|
2472
|
-
if (control.value === null) {
|
|
2473
|
-
return null;
|
|
2474
|
-
}
|
|
2475
|
-
if (!(control.value instanceof Boolean || typeof control.value === 'boolean')) {
|
|
2476
|
-
return {
|
|
2477
|
-
isBoolean: {
|
|
2478
|
-
expected: 'A boolean value',
|
|
2479
|
-
actual: control.value,
|
|
2480
|
-
message
|
|
2481
|
-
}
|
|
2482
|
-
};
|
|
2483
|
-
}
|
|
2484
|
-
return null;
|
|
2485
|
-
};
|
|
2486
|
-
}
|
|
2487
|
-
|
|
2488
|
-
function IsObject({ message } = {}) {
|
|
2489
|
-
return (control) => {
|
|
2490
|
-
if (control.value === null) {
|
|
2491
|
-
return null;
|
|
2492
|
-
}
|
|
2493
|
-
if (!(control.value !== undefined && (typeof control.value === 'object' || typeof control.value === 'function') && !Array.isArray(control.value))) {
|
|
2494
|
-
return {
|
|
2495
|
-
isObject: {
|
|
2496
|
-
expected: 'A object value',
|
|
2497
|
-
actual: control.value,
|
|
2498
|
-
message
|
|
2499
|
-
}
|
|
2500
|
-
};
|
|
2501
|
-
}
|
|
2502
|
-
return null;
|
|
2503
|
-
};
|
|
2504
|
-
}
|
|
2505
|
-
|
|
2506
|
-
function IsString({ message } = {}) {
|
|
2507
|
-
return (control) => {
|
|
2508
|
-
if (control.value === null) {
|
|
2509
|
-
return null;
|
|
2510
|
-
}
|
|
2511
|
-
if (!(control.value instanceof String || typeof control.value === 'string')) {
|
|
2512
|
-
return {
|
|
2513
|
-
isString: {
|
|
2514
|
-
expected: 'A string value',
|
|
2515
|
-
actual: control.value,
|
|
2516
|
-
message
|
|
2517
|
-
}
|
|
2518
|
-
};
|
|
2519
|
-
}
|
|
2520
|
-
return null;
|
|
2521
|
-
};
|
|
2522
|
-
}
|
|
2523
|
-
|
|
2524
|
-
function IsInt({ message, options } = {}) {
|
|
2525
|
-
return (control) => {
|
|
2526
|
-
if (control.value === null) {
|
|
2527
|
-
return null;
|
|
2528
|
-
}
|
|
2529
|
-
if (!isNumber(control.value, options) || Number.isInteger(control.value)) {
|
|
2530
|
-
return {
|
|
2531
|
-
isInt: {
|
|
2532
|
-
expected: 'A int value',
|
|
2533
|
-
actual: control.value,
|
|
2534
|
-
message
|
|
2535
|
-
}
|
|
2536
|
-
};
|
|
2537
|
-
}
|
|
2538
|
-
return null;
|
|
2539
|
-
};
|
|
2540
|
-
}
|
|
2541
|
-
|
|
2542
|
-
function IsEnum({ message, entity }) {
|
|
2543
|
-
return (control) => {
|
|
2544
|
-
if (control.value === null) {
|
|
2545
|
-
return null;
|
|
2546
|
-
}
|
|
2547
|
-
if (Object.keys(entity).map(k => entity[k]).indexOf(control.value) === -1) {
|
|
2548
|
-
return {
|
|
2549
|
-
isEnum: {
|
|
2550
|
-
expected: 'A enum value',
|
|
2551
|
-
actual: control.value,
|
|
2552
|
-
message
|
|
2553
|
-
}
|
|
2554
|
-
};
|
|
2555
|
-
}
|
|
2556
|
-
return null;
|
|
2557
|
-
};
|
|
2558
|
-
}
|
|
2559
|
-
|
|
2560
|
-
function IsDate({ message } = {}) {
|
|
2561
|
-
return (control) => {
|
|
2562
|
-
if (control.value === null) {
|
|
2563
|
-
return null;
|
|
2564
|
-
}
|
|
2565
|
-
if (!(control.value instanceof Date && !isNaN(control.value.getTime()))) {
|
|
2566
|
-
return {
|
|
2567
|
-
isDate: {
|
|
2568
|
-
expected: 'A date value',
|
|
2569
|
-
actual: control.value,
|
|
2570
|
-
message
|
|
2571
|
-
}
|
|
2572
|
-
};
|
|
2573
|
-
}
|
|
2574
|
-
return null;
|
|
2575
|
-
};
|
|
2576
|
-
}
|
|
2577
|
-
|
|
2578
|
-
function IsArray({ message } = {}) {
|
|
2579
|
-
return (control) => {
|
|
2580
|
-
if (control.value === null) {
|
|
2581
|
-
return null;
|
|
2582
|
-
}
|
|
2583
|
-
if (!Array.isArray(control.value)) {
|
|
2584
|
-
return {
|
|
2585
|
-
isArray: {
|
|
2586
|
-
expected: 'A array value',
|
|
2587
|
-
actual: control.value,
|
|
2588
|
-
message
|
|
2589
|
-
}
|
|
2590
|
-
};
|
|
2591
|
-
}
|
|
2592
|
-
return null;
|
|
2593
|
-
};
|
|
2594
|
-
}
|
|
2595
|
-
|
|
2596
|
-
const regexOptions = {
|
|
2597
|
-
uppercase: '.*[A-Z]',
|
|
2598
|
-
special: '.*[^A-Za-z0-9]',
|
|
2599
|
-
digit: '.*[0-9]',
|
|
2600
|
-
lowercase: '.*[a-z]',
|
|
2601
|
-
upperLower: '.*[a-zA-Z]',
|
|
2602
|
-
alphaNumeric: '.*[a-zA-Z0-9]'
|
|
2603
|
-
};
|
|
2604
|
-
const lengthOptions = {
|
|
2605
|
-
min: '.{n,}',
|
|
2606
|
-
max: '.{0,n}',
|
|
2607
|
-
range: '.{min,max}',
|
|
2608
|
-
exact: '.{n}',
|
|
2609
|
-
no_limit: '.*'
|
|
2610
|
-
};
|
|
2611
|
-
function inOperator(k, o) {
|
|
2612
|
-
return k in o;
|
|
2613
|
-
}
|
|
2614
|
-
function create(options) {
|
|
2615
|
-
let regex = '^';
|
|
2616
|
-
for (const [key, value] of Object.entries(regexOptions)) {
|
|
2617
|
-
if (inOperator(key, options) && isNumber(options[key])) {
|
|
2618
|
-
regex += '(?=' + value.repeat(options[key]) + ')';
|
|
2619
|
-
}
|
|
2620
|
-
}
|
|
2621
|
-
if (isNumber(options.min) && isNumber(options.max)) {
|
|
2622
|
-
regex += lengthOptions.range.replace('min', options.min.toFixed(0)).replace('max', options.max.toFixed(0));
|
|
2623
|
-
}
|
|
2624
|
-
else if (isNumber(options.max)) {
|
|
2625
|
-
regex += lengthOptions.max.replace('n', options.max.toFixed(0));
|
|
2626
|
-
}
|
|
2627
|
-
else if (isNumber(options.min)) {
|
|
2628
|
-
regex += lengthOptions.min.replace('n', options.min.toFixed(0));
|
|
2629
|
-
}
|
|
2630
|
-
else if (isNumber(options.exact)) {
|
|
2631
|
-
regex += lengthOptions.exact.replace('n', options.exact.toFixed(0));
|
|
2632
|
-
}
|
|
2633
|
-
else {
|
|
2634
|
-
regex += lengthOptions.no_limit;
|
|
2635
|
-
}
|
|
2636
|
-
regex += '$';
|
|
2637
|
-
return regex;
|
|
2638
|
-
}
|
|
2639
|
-
function check(str, regexStringOrOptions) {
|
|
2640
|
-
let regex;
|
|
2641
|
-
let regexString;
|
|
2642
|
-
if (typeof regexStringOrOptions === 'object') {
|
|
2643
|
-
regexString = create(regexStringOrOptions);
|
|
2644
|
-
}
|
|
2645
|
-
else {
|
|
2646
|
-
regexString = regexStringOrOptions;
|
|
2647
|
-
}
|
|
2648
|
-
regex = new RegExp(regexString);
|
|
2649
|
-
return regex.test(str);
|
|
2650
|
-
}
|
|
2651
|
-
function checkError(str, options) {
|
|
2652
|
-
const returnObject = {};
|
|
2653
|
-
for (const [key, value] of Object.entries(options)) {
|
|
2654
|
-
returnObject[key] = check(str, { [key]: value });
|
|
2655
|
-
}
|
|
2656
|
-
return returnObject;
|
|
2657
|
-
}
|
|
2658
|
-
function IsComplex({ message, options }) {
|
|
2659
|
-
return (control) => {
|
|
2660
|
-
if (control.value === null) {
|
|
2661
|
-
return null;
|
|
2662
|
-
}
|
|
2663
|
-
const isNotString = IsString({ message })(control);
|
|
2664
|
-
if (isNotString !== null) {
|
|
2665
|
-
return isNotString;
|
|
2666
|
-
}
|
|
2667
|
-
const errors = checkError(control.value, options);
|
|
2668
|
-
if (Object.keys(errors).length && Object.values(errors).some(item => !item)) {
|
|
2669
|
-
return {
|
|
2670
|
-
isComplex: {
|
|
2671
|
-
expected: options,
|
|
2672
|
-
actual: errors,
|
|
2673
|
-
message
|
|
2674
|
-
}
|
|
2675
|
-
};
|
|
2676
|
-
}
|
|
2677
|
-
return null;
|
|
2678
|
-
};
|
|
2679
|
-
}
|
|
2680
|
-
|
|
2681
|
-
function IsPhoneNumber({ message, locale, options } = {}) {
|
|
2682
|
-
return (control) => {
|
|
2683
|
-
if (control.value === null) {
|
|
2684
|
-
return null;
|
|
2685
|
-
}
|
|
2686
|
-
if (!isMobilePhone(control.value, locale, options)) {
|
|
2687
|
-
return {
|
|
2688
|
-
isPhoneNumber: {
|
|
2689
|
-
expected: 'A phone number value',
|
|
2690
|
-
actual: control.value,
|
|
2691
|
-
message
|
|
2692
|
-
}
|
|
2693
|
-
};
|
|
2694
|
-
}
|
|
2695
|
-
return null;
|
|
2696
|
-
};
|
|
2697
|
-
}
|
|
2698
|
-
|
|
2699
|
-
function IsEmail({ message, options } = {}) {
|
|
2700
|
-
return (control) => {
|
|
2701
|
-
if (control.value === null) {
|
|
2702
|
-
return null;
|
|
2703
|
-
}
|
|
2704
|
-
if (!(typeof control.value === 'string' && isEmail(control.value, options))) {
|
|
2705
|
-
return {
|
|
2706
|
-
isEmail: {
|
|
2707
|
-
expected: 'A email value',
|
|
2708
|
-
actual: control.value,
|
|
2709
|
-
message
|
|
2710
|
-
}
|
|
2711
|
-
};
|
|
2712
|
-
}
|
|
2713
|
-
return null;
|
|
2714
|
-
};
|
|
2715
|
-
}
|
|
2716
|
-
|
|
2717
|
-
function IsUrl({ message, options } = {}) {
|
|
2718
|
-
return (control) => {
|
|
2719
|
-
if (control.value === null) {
|
|
2720
|
-
return null;
|
|
2721
|
-
}
|
|
2722
|
-
if (!(typeof control.value === 'string' && isURL(control.value, options))) {
|
|
2723
|
-
return {
|
|
2724
|
-
isURL: {
|
|
2725
|
-
expected: 'A url value',
|
|
2726
|
-
actual: control.value,
|
|
2727
|
-
message
|
|
2728
|
-
}
|
|
2729
|
-
};
|
|
2730
|
-
}
|
|
2731
|
-
return null;
|
|
2732
|
-
};
|
|
2733
|
-
}
|
|
2734
|
-
|
|
2735
|
-
function IsIP({ message, version } = {}) {
|
|
2736
|
-
return (control) => {
|
|
2737
|
-
if (control.value === null) {
|
|
2738
|
-
return null;
|
|
2739
|
-
}
|
|
2740
|
-
if (!(typeof control.value === 'string' && isIP(control.value, version))) {
|
|
2741
|
-
return {
|
|
2742
|
-
isIp: {
|
|
2743
|
-
expected: `A valid IPv${version !== null && version !== void 0 ? version : '4'} value`,
|
|
2744
|
-
actual: control.value,
|
|
2745
|
-
message
|
|
2746
|
-
}
|
|
2747
|
-
};
|
|
2748
|
-
}
|
|
2749
|
-
return null;
|
|
2750
|
-
};
|
|
2751
|
-
}
|
|
2752
|
-
|
|
2753
|
-
function IsPort({ message } = {}) {
|
|
2754
|
-
return (control) => {
|
|
2755
|
-
if (control.value === null) {
|
|
2756
|
-
return null;
|
|
2757
|
-
}
|
|
2758
|
-
if (!(typeof control.value === 'string' && isPort(control.value))) {
|
|
2759
|
-
return {
|
|
2760
|
-
isPort: {
|
|
2761
|
-
expected: `A valid port number between 1 and 65535`,
|
|
2762
|
-
actual: control.value,
|
|
2763
|
-
message
|
|
2764
|
-
}
|
|
2765
|
-
};
|
|
2766
|
-
}
|
|
2767
|
-
return null;
|
|
2768
|
-
};
|
|
2769
|
-
}
|
|
2770
|
-
|
|
2771
|
-
function IsUUID({ message, version = 'all' } = {}) {
|
|
2772
|
-
return (control) => {
|
|
2773
|
-
if (control.value === null) {
|
|
2774
|
-
return null;
|
|
2775
|
-
}
|
|
2776
|
-
if (!(typeof control.value === 'string' && isUUID(control.value, version))) {
|
|
2777
|
-
return {
|
|
2778
|
-
isUuid: {
|
|
2779
|
-
expected: version === 'all' ? `A valid uuid` : `A valid uuid version ${version}`,
|
|
2780
|
-
actual: control.value,
|
|
2781
|
-
message
|
|
2782
|
-
}
|
|
2783
|
-
};
|
|
2784
|
-
}
|
|
2785
|
-
return null;
|
|
2786
|
-
};
|
|
2787
|
-
}
|
|
2788
|
-
|
|
2789
|
-
const RxapValidators = {
|
|
2790
|
-
IsNumber: _IsNumber,
|
|
2791
|
-
IsBoolean,
|
|
2792
|
-
IsArray,
|
|
2793
|
-
IsDate,
|
|
2794
|
-
IsEnum,
|
|
2795
|
-
IsInt,
|
|
2796
|
-
IsObject,
|
|
2797
|
-
IsString,
|
|
2798
|
-
IsComplex,
|
|
2799
|
-
IsPhoneNumber,
|
|
2800
|
-
IsEmail,
|
|
2801
|
-
IsUrl,
|
|
2802
|
-
IsIP,
|
|
2803
|
-
IsPort,
|
|
2804
|
-
IsUUID,
|
|
2805
|
-
};
|
|
2806
|
-
|
|
2807
|
-
// endregion
|
|
2808
|
-
|
|
2809
|
-
/**
|
|
2810
|
-
* Generated bundle index. Do not edit.
|
|
2811
|
-
*/
|
|
2812
|
-
|
|
2813
|
-
export { ControlAsyncValidator, ControlChange, ControlSetValue, ControlValidator, ControlValueAccessor, FormArrayControlManager, FormControlErrorDirective, FormControlMarkDirtyDirective, FormControlMarkPristineDirective, FormControlMarkTouchedDirective, FormControlMarkUntouchedDirective, FormControlNameDirective, FormDirective, FormGroupNameDirective, FormLoadedDirective, FormLoadingDirective, FormLoadingErrorDirective, FormSubmitDirective, FormSubmitFailedDirective, FormSubmitInvalidDirective, FormSubmitSuccessfulDirective, FormSubmittingDirective, IsArray, IsBoolean, IsDate, IsEnum, IsInt, IsNumber, IsObject, IsString, ParentControlContainerDirective, RXAP_FORM_CONTEXT, RXAP_FORM_DEFINITION, RXAP_FORM_DEFINITION_BUILDER, RXAP_FORM_INITIAL_STATE, RXAP_FORM_LOAD_FAILED_METHOD, RXAP_FORM_LOAD_METHOD, RXAP_FORM_LOAD_SUCCESSFUL_METHOD, RXAP_FORM_SUBMIT_FAILED_METHOD, RXAP_FORM_SUBMIT_METHOD, RXAP_FORM_SUBMIT_SUCCESSFUL_METHOD, RxapForm, RxapFormArray, RxapFormBuilder, RxapFormControl, RxapFormGroup, RxapFormsModule, RxapValidators, ToFormMethod, ToFormSubmitMethod, UseFormArrayControl, UseFormArrayGroup, UseFormControl, UseFormGroup, _IsNumber, controlDisabled$, controlDisabledWhile, controlEnabled$, controlEnabledWhile, controlErrorChanges$, controlReadonly$, controlStatusChanges$, controlValueChanges$, disableControl, enableControl, hasErrorAndDirty, hasErrorAndTouched, isNumber, markAllDirty, markAllPristine, markAllUntouched, mergeControlValidators, selectControlValue$, validateControlOn };
|
|
2814
|
-
//# sourceMappingURL=rxap-forms.mjs.map
|