@rxap/form-system 12.1.5 → 13.0.0-next.2
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/esm2020/index.mjs +26 -0
- package/esm2020/lib/control-data-source.mjs +40 -0
- package/esm2020/lib/control-with-data-source.mjs +2 -0
- package/esm2020/lib/decorators/metadata-keys.mjs +8 -0
- package/esm2020/lib/decorators/use-component.mjs +9 -0
- package/esm2020/lib/decorators/use-data-source.mjs +9 -0
- package/esm2020/lib/decorators/use-form-component.mjs +13 -0
- package/esm2020/lib/directives/control-hide-show.directive.mjs +183 -0
- package/esm2020/lib/directives/form-directives.module.mjs +21 -0
- package/esm2020/lib/directives/input-select-options.directive.mjs +205 -0
- package/esm2020/lib/error.mjs +7 -0
- package/esm2020/lib/form-system-control.directive.mjs +158 -0
- package/esm2020/lib/form-system.module.mjs +17 -0
- package/esm2020/lib/mixins/extract-control.mixin.mjs +21 -0
- package/esm2020/lib/mixins/extract-data-sources.mixin.mjs +16 -0
- package/esm2020/lib/mixins/extract-form-definition.mixin.mjs +12 -0
- package/esm2020/lib/validators/is-equal-to.mjs +70 -0
- package/esm2020/rxap-form-system.mjs +5 -0
- package/fesm2015/rxap-form-system.mjs +752 -0
- package/fesm2015/rxap-form-system.mjs.map +1 -0
- package/{fesm2015/rxap-form-system.js → fesm2020/rxap-form-system.mjs} +46 -55
- package/fesm2020/rxap-form-system.mjs.map +1 -0
- package/package.json +38 -24
- package/bundles/rxap-form-system.umd.js +0 -1204
- package/bundles/rxap-form-system.umd.js.map +0 -1
- package/esm2015/index.js +0 -26
- package/esm2015/index.js.map +0 -1
- package/esm2015/lib/control-data-source.js +0 -40
- package/esm2015/lib/control-data-source.js.map +0 -1
- package/esm2015/lib/control-with-data-source.js +0 -2
- package/esm2015/lib/control-with-data-source.js.map +0 -1
- package/esm2015/lib/decorators/metadata-keys.js +0 -8
- package/esm2015/lib/decorators/metadata-keys.js.map +0 -1
- package/esm2015/lib/decorators/use-component.js +0 -9
- package/esm2015/lib/decorators/use-component.js.map +0 -1
- package/esm2015/lib/decorators/use-data-source.js +0 -9
- package/esm2015/lib/decorators/use-data-source.js.map +0 -1
- package/esm2015/lib/decorators/use-form-component.js +0 -13
- package/esm2015/lib/decorators/use-form-component.js.map +0 -1
- package/esm2015/lib/directives/control-hide-show.directive.js +0 -187
- package/esm2015/lib/directives/control-hide-show.directive.js.map +0 -1
- package/esm2015/lib/directives/form-directives.module.js +0 -21
- package/esm2015/lib/directives/form-directives.module.js.map +0 -1
- package/esm2015/lib/directives/input-select-options.directive.js +0 -210
- package/esm2015/lib/directives/input-select-options.directive.js.map +0 -1
- package/esm2015/lib/error.js +0 -7
- package/esm2015/lib/error.js.map +0 -1
- package/esm2015/lib/form-system-control.directive.js +0 -158
- package/esm2015/lib/form-system-control.directive.js.map +0 -1
- package/esm2015/lib/form-system.module.js +0 -17
- package/esm2015/lib/form-system.module.js.map +0 -1
- package/esm2015/lib/mixins/extract-control.mixin.js +0 -21
- package/esm2015/lib/mixins/extract-control.mixin.js.map +0 -1
- package/esm2015/lib/mixins/extract-data-sources.mixin.js +0 -16
- package/esm2015/lib/mixins/extract-data-sources.mixin.js.map +0 -1
- package/esm2015/lib/mixins/extract-form-definition.mixin.js +0 -12
- package/esm2015/lib/mixins/extract-form-definition.mixin.js.map +0 -1
- package/esm2015/lib/validators/is-equal-to.js +0 -70
- package/esm2015/lib/validators/is-equal-to.js.map +0 -1
- package/esm2015/rxap-form-system.js +0 -5
- package/esm2015/rxap-form-system.js.map +0 -1
- package/fesm2015/rxap-form-system.js.map +0 -1
|
@@ -0,0 +1,752 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { ComponentFactoryResolver, ViewContainerRef, INJECTOR, ComponentRef, Injector, Directive, Inject, Input, NgModule, InjectionToken, isDevMode, Injectable, Optional, Renderer2, ElementRef, Self, TemplateRef, ChangeDetectorRef, forwardRef } from '@angular/core';
|
|
3
|
+
import { __decorate, __metadata } from 'tslib';
|
|
4
|
+
import { RxapError, Required, equals } from '@rxap/utilities';
|
|
5
|
+
import * as i1 from '@angular/forms';
|
|
6
|
+
import { ControlContainer, NgControl, NG_VALIDATORS } from '@angular/forms';
|
|
7
|
+
import { RxapFormControl, RxapFormGroup, RxapFormArray } from '@rxap/forms';
|
|
8
|
+
import * as i2 from '@rxap/data-source';
|
|
9
|
+
import { PipeDataSource, DataSourceLoader, BaseDataSource, RXAP_DATA_SOURCE_METADATA } from '@rxap/data-source';
|
|
10
|
+
import { Mixin } from '@rxap/mixin';
|
|
11
|
+
import { getMetadata, setMetadataMap, setMetadataMapMap, setMetadata } from '@rxap/utilities/reflect-metadata';
|
|
12
|
+
import { map, startWith, distinctUntilChanged, shareReplay, tap, catchError } from 'rxjs/operators';
|
|
13
|
+
import { Subscription, of } from 'rxjs';
|
|
14
|
+
import * as i3 from '@angular/material/form-field';
|
|
15
|
+
import { MAT_FORM_FIELD } from '@angular/material/form-field';
|
|
16
|
+
|
|
17
|
+
class RxapFormSystemError extends RxapError {
|
|
18
|
+
constructor(message, code, className) {
|
|
19
|
+
super('@rxap/form-system', message, code, className);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var FormSystemMetadataKeys;
|
|
24
|
+
(function (FormSystemMetadataKeys) {
|
|
25
|
+
FormSystemMetadataKeys["COMPONENTS"] = "rxap/form-system/components";
|
|
26
|
+
FormSystemMetadataKeys["DATA_SOURCES"] = "rxap/form-system/data-sources";
|
|
27
|
+
FormSystemMetadataKeys["COMPONENTS_PROPERTIES"] = "rxap/form-system/components-properties";
|
|
28
|
+
FormSystemMetadataKeys["FORM_COMPONENT"] = "rxap/window-form-system/form-component";
|
|
29
|
+
})(FormSystemMetadataKeys || (FormSystemMetadataKeys = {}));
|
|
30
|
+
|
|
31
|
+
class ExtractDataSourcesMixin {
|
|
32
|
+
extractDataSources(formDefinition, controlId) {
|
|
33
|
+
const map = getMetadata(FormSystemMetadataKeys.DATA_SOURCES, Object.getPrototypeOf(formDefinition));
|
|
34
|
+
if (!map) {
|
|
35
|
+
throw new RxapFormSystemError('Could not extract the use data source map from the form definition instance', '');
|
|
36
|
+
}
|
|
37
|
+
if (!map.has(controlId)) {
|
|
38
|
+
throw new RxapFormSystemError('A use data source definition does not exists in the form definition metadata', '');
|
|
39
|
+
}
|
|
40
|
+
return map.get(controlId);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let FormSystemControlDirective = class FormSystemControlDirective {
|
|
45
|
+
constructor(parent, cfr, viewContainerRef, dataSourceLoader, injector) {
|
|
46
|
+
this.parent = parent;
|
|
47
|
+
this.cfr = cfr;
|
|
48
|
+
this.viewContainerRef = viewContainerRef;
|
|
49
|
+
this.dataSourceLoader = dataSourceLoader;
|
|
50
|
+
this.injector = injector;
|
|
51
|
+
}
|
|
52
|
+
ngOnInit() {
|
|
53
|
+
this.control = this.extractControl();
|
|
54
|
+
const formDefinition = this.extractFormDefinition();
|
|
55
|
+
this.componentRef = this.createComponent(formDefinition);
|
|
56
|
+
this.setDataSources(formDefinition, this.componentRef.instance);
|
|
57
|
+
this.setComponentProperties(formDefinition, this.componentRef.instance);
|
|
58
|
+
this.viewContainerRef.insert(this.componentRef.hostView);
|
|
59
|
+
}
|
|
60
|
+
registerOnChange(fn) {
|
|
61
|
+
this.componentRef.instance.registerOnChange(fn);
|
|
62
|
+
}
|
|
63
|
+
registerOnTouched(fn) {
|
|
64
|
+
this.componentRef.instance.registerOnTouched(fn);
|
|
65
|
+
}
|
|
66
|
+
writeValue(value) {
|
|
67
|
+
this.componentRef.instance.writeValue(value);
|
|
68
|
+
}
|
|
69
|
+
setDisabledState(isDisabled) {
|
|
70
|
+
if (this.componentRef.instance.setDisabledState) {
|
|
71
|
+
this.componentRef.instance.setDisabledState(isDisabled);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
setDataSources(formDefinition, component) {
|
|
75
|
+
if (!component.setDataSource) {
|
|
76
|
+
throw new RxapFormSystemError('The ControlWithDataSource interface is not implemented for the control component, but the control has defined data sources', '');
|
|
77
|
+
}
|
|
78
|
+
const useDataSourceValueMap = this.extractDataSources(formDefinition, this.controlId);
|
|
79
|
+
for (const [name, useDataSourceValue] of useDataSourceValueMap.entries()) {
|
|
80
|
+
let dataSource = this.dataSourceLoader.load(useDataSourceValue.dataSource);
|
|
81
|
+
const settings = useDataSourceValue.settings;
|
|
82
|
+
if (settings === null || settings === void 0 ? void 0 : settings.transformer) {
|
|
83
|
+
dataSource = new PipeDataSource(dataSource, map(settings.transformer));
|
|
84
|
+
}
|
|
85
|
+
component.setDataSource(name, dataSource, useDataSourceValue.settings);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
setComponentProperties(formDefinition, component) {
|
|
89
|
+
const componentProperties = this.extractComponentProperties(formDefinition);
|
|
90
|
+
for (const [key, value] of Object.entries(componentProperties)) {
|
|
91
|
+
Reflect.set(component, key, value);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
createComponent(formDefinition) {
|
|
95
|
+
const component = this.extractComponent(formDefinition);
|
|
96
|
+
const componentFactory = this.cfr.resolveComponentFactory(component);
|
|
97
|
+
return componentFactory.create(this.injector);
|
|
98
|
+
}
|
|
99
|
+
extractControl() {
|
|
100
|
+
if (!this.parent.control) {
|
|
101
|
+
throw new RxapFormSystemError('The control property of ControlContainer is not defined', '');
|
|
102
|
+
}
|
|
103
|
+
const control = this.parent.control.get(this.controlId);
|
|
104
|
+
if (!control) {
|
|
105
|
+
throw new RxapFormSystemError('Could not find the control instance', '');
|
|
106
|
+
}
|
|
107
|
+
if (!(control instanceof RxapFormControl)) {
|
|
108
|
+
throw new RxapFormSystemError('The extracted control is not a RxapFormControl', '');
|
|
109
|
+
}
|
|
110
|
+
return control;
|
|
111
|
+
}
|
|
112
|
+
extractFormDefinition() {
|
|
113
|
+
const formDefinition = this.control.rxapFormDefinition;
|
|
114
|
+
if (!formDefinition) {
|
|
115
|
+
throw new RxapFormSystemError('Could not find the form definition instance', '');
|
|
116
|
+
}
|
|
117
|
+
return formDefinition;
|
|
118
|
+
}
|
|
119
|
+
extractComponent(formDefinition) {
|
|
120
|
+
const map = getMetadata(FormSystemMetadataKeys.COMPONENTS, Object.getPrototypeOf(formDefinition));
|
|
121
|
+
if (!map) {
|
|
122
|
+
throw new RxapFormSystemError('Could not extract the use component map from the form definition instance', '');
|
|
123
|
+
}
|
|
124
|
+
if (!map.has(this.controlId)) {
|
|
125
|
+
throw new RxapFormSystemError('A use component definition does not exists in the form definition metadata', '');
|
|
126
|
+
}
|
|
127
|
+
return map.get(this.controlId);
|
|
128
|
+
}
|
|
129
|
+
extractComponentProperties(formDefinition) {
|
|
130
|
+
const map = getMetadata(FormSystemMetadataKeys.COMPONENTS_PROPERTIES, Object.getPrototypeOf(formDefinition));
|
|
131
|
+
if (!map) {
|
|
132
|
+
throw new RxapFormSystemError('Could not extract the use component properties map from the form definition instance', '');
|
|
133
|
+
}
|
|
134
|
+
if (!map.has(this.controlId)) {
|
|
135
|
+
throw new RxapFormSystemError('A use component definition does not exists in the form definition metadata', '');
|
|
136
|
+
}
|
|
137
|
+
return map.get(this.controlId);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
FormSystemControlDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: FormSystemControlDirective, deps: [{ token: ControlContainer }, { token: ComponentFactoryResolver }, { token: ViewContainerRef }, { token: DataSourceLoader }, { token: INJECTOR }], target: i0.ɵɵFactoryTarget.Directive });
|
|
141
|
+
FormSystemControlDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.3", type: FormSystemControlDirective, selector: "[rxapFormSystemControl]", inputs: { controlId: "controlId" }, ngImport: i0 });
|
|
142
|
+
__decorate([
|
|
143
|
+
Required,
|
|
144
|
+
__metadata("design:type", String)
|
|
145
|
+
], FormSystemControlDirective.prototype, "controlId", void 0);
|
|
146
|
+
__decorate([
|
|
147
|
+
Required,
|
|
148
|
+
__metadata("design:type", RxapFormControl)
|
|
149
|
+
], FormSystemControlDirective.prototype, "control", void 0);
|
|
150
|
+
__decorate([
|
|
151
|
+
Required,
|
|
152
|
+
__metadata("design:type", ComponentRef)
|
|
153
|
+
], FormSystemControlDirective.prototype, "componentRef", void 0);
|
|
154
|
+
FormSystemControlDirective = __decorate([
|
|
155
|
+
Mixin(ExtractDataSourcesMixin),
|
|
156
|
+
__metadata("design:paramtypes", [ControlContainer,
|
|
157
|
+
ComponentFactoryResolver,
|
|
158
|
+
ViewContainerRef,
|
|
159
|
+
DataSourceLoader,
|
|
160
|
+
Injector])
|
|
161
|
+
], FormSystemControlDirective);
|
|
162
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: FormSystemControlDirective, decorators: [{
|
|
163
|
+
type: Directive,
|
|
164
|
+
args: [{
|
|
165
|
+
selector: '[rxapFormSystemControl]'
|
|
166
|
+
}]
|
|
167
|
+
}], ctorParameters: function () {
|
|
168
|
+
return [{ type: i1.ControlContainer, decorators: [{
|
|
169
|
+
type: Inject,
|
|
170
|
+
args: [ControlContainer]
|
|
171
|
+
}] }, { type: i0.ComponentFactoryResolver, decorators: [{
|
|
172
|
+
type: Inject,
|
|
173
|
+
args: [ComponentFactoryResolver]
|
|
174
|
+
}] }, { type: i0.ViewContainerRef, decorators: [{
|
|
175
|
+
type: Inject,
|
|
176
|
+
args: [ViewContainerRef]
|
|
177
|
+
}] }, { type: i2.DataSourceLoader, decorators: [{
|
|
178
|
+
type: Inject,
|
|
179
|
+
args: [DataSourceLoader]
|
|
180
|
+
}] }, { type: i0.Injector, decorators: [{
|
|
181
|
+
type: Inject,
|
|
182
|
+
args: [INJECTOR]
|
|
183
|
+
}] }];
|
|
184
|
+
}, propDecorators: { controlId: [{
|
|
185
|
+
type: Input
|
|
186
|
+
}], control: [], componentRef: [] } });
|
|
187
|
+
|
|
188
|
+
class FormSystemModule {
|
|
189
|
+
}
|
|
190
|
+
FormSystemModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: FormSystemModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
191
|
+
FormSystemModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: FormSystemModule, declarations: [FormSystemControlDirective], exports: [FormSystemControlDirective] });
|
|
192
|
+
FormSystemModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: FormSystemModule, imports: [[]] });
|
|
193
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: FormSystemModule, decorators: [{
|
|
194
|
+
type: NgModule,
|
|
195
|
+
args: [{
|
|
196
|
+
declarations: [FormSystemControlDirective],
|
|
197
|
+
exports: [FormSystemControlDirective],
|
|
198
|
+
imports: []
|
|
199
|
+
}]
|
|
200
|
+
}] });
|
|
201
|
+
|
|
202
|
+
const RXAP_FORM_CONTROL_SOURCE = new InjectionToken('rxap/forms/data-source');
|
|
203
|
+
class ControlDataSource extends BaseDataSource {
|
|
204
|
+
constructor(control, metadata = null) {
|
|
205
|
+
super(metadata);
|
|
206
|
+
this.control = control;
|
|
207
|
+
}
|
|
208
|
+
init() {
|
|
209
|
+
if (this._initialised) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
super.init();
|
|
213
|
+
if (isDevMode()) {
|
|
214
|
+
console.log(this.control);
|
|
215
|
+
}
|
|
216
|
+
this._data$ = this.control.valueChanges.pipe(startWith(this.control.value), distinctUntilChanged((a, b) => equals(a, b)), shareReplay(1));
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
ControlDataSource.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ControlDataSource, deps: [{ token: RXAP_FORM_CONTROL_SOURCE }, { token: RXAP_DATA_SOURCE_METADATA, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
220
|
+
ControlDataSource.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ControlDataSource });
|
|
221
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ControlDataSource, decorators: [{
|
|
222
|
+
type: Injectable
|
|
223
|
+
}], ctorParameters: function () {
|
|
224
|
+
return [{ type: undefined, decorators: [{
|
|
225
|
+
type: Inject,
|
|
226
|
+
args: [RXAP_FORM_CONTROL_SOURCE]
|
|
227
|
+
}] }, { type: undefined, decorators: [{
|
|
228
|
+
type: Optional
|
|
229
|
+
}, {
|
|
230
|
+
type: Inject,
|
|
231
|
+
args: [RXAP_DATA_SOURCE_METADATA]
|
|
232
|
+
}] }];
|
|
233
|
+
} });
|
|
234
|
+
function controlDataSource(control) {
|
|
235
|
+
// TODO : remove as any (wait for @rxap/forms update)
|
|
236
|
+
return new ControlDataSource(control, { id: control.controlId });
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
class ExtractControlMixin {
|
|
240
|
+
extractControl(parent, controlPath) {
|
|
241
|
+
if (!controlPath) {
|
|
242
|
+
throw new RxapFormSystemError('The control path is empty', '');
|
|
243
|
+
}
|
|
244
|
+
if (!parent.control) {
|
|
245
|
+
throw new RxapFormSystemError('The control property of ControlContainer is not defined', '');
|
|
246
|
+
}
|
|
247
|
+
const control = parent.control.get(controlPath);
|
|
248
|
+
if (!control) {
|
|
249
|
+
throw new RxapFormSystemError('Could not find the control instance', '');
|
|
250
|
+
}
|
|
251
|
+
if (!(control instanceof RxapFormControl) && !(control instanceof RxapFormGroup) && !(control instanceof RxapFormArray)) {
|
|
252
|
+
throw new RxapFormSystemError('The extracted control is not a RxapFormControl', '');
|
|
253
|
+
}
|
|
254
|
+
return control;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
class ExtractFormDefinitionMixin {
|
|
259
|
+
// TODO : change to AbstractControl from @rxap/forms
|
|
260
|
+
extractFormDefinition(control) {
|
|
261
|
+
const formDefinition = control.rxapFormDefinition;
|
|
262
|
+
if (!formDefinition) {
|
|
263
|
+
throw new RxapFormSystemError('Could not find the form definition instance', '');
|
|
264
|
+
}
|
|
265
|
+
return formDefinition;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function UseComponent(component, setProperties = {}) {
|
|
270
|
+
return function (target, propertyKey) {
|
|
271
|
+
setMetadataMap(propertyKey, component, FormSystemMetadataKeys.COMPONENTS, target);
|
|
272
|
+
setMetadataMap(propertyKey, setProperties, FormSystemMetadataKeys.COMPONENTS_PROPERTIES, target);
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function UseDataSource(dataSource, name, settings) {
|
|
277
|
+
return function (target, propertyKey) {
|
|
278
|
+
const value = { dataSource, settings };
|
|
279
|
+
setMetadataMapMap(propertyKey, name, value, FormSystemMetadataKeys.DATA_SOURCES, target);
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Links a component with a form definition
|
|
285
|
+
*
|
|
286
|
+
* @param component
|
|
287
|
+
*/
|
|
288
|
+
function UseFormComponent(component) {
|
|
289
|
+
return function (target) {
|
|
290
|
+
setMetadata(FormSystemMetadataKeys.FORM_COMPONENT, component, target);
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
const RXAP_FORM_SYSTEM_SHOW_METADATA = 'rxap/form-system/show-function';
|
|
295
|
+
const RXAP_FORM_SYSTEM_HIDE_METADATA = 'rxap/form-system/hide-function';
|
|
296
|
+
const RXAP_FORM_SYSTEM_HIDE_SHOW_OPTIONS = 'rxap/form-system/hide-show-options';
|
|
297
|
+
function UseHideFunction(hideFunction, options = {}) {
|
|
298
|
+
return function (target, propertyKey) {
|
|
299
|
+
setMetadataMap(propertyKey, hideFunction, RXAP_FORM_SYSTEM_HIDE_METADATA, target);
|
|
300
|
+
if (Object.keys(options).length) {
|
|
301
|
+
setMetadataMap(propertyKey, options, RXAP_FORM_SYSTEM_HIDE_SHOW_OPTIONS, target);
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
function UseShowFunction(showFunction, options = {}) {
|
|
306
|
+
return function (target, propertyKey) {
|
|
307
|
+
setMetadataMap(propertyKey, showFunction, RXAP_FORM_SYSTEM_SHOW_METADATA, target);
|
|
308
|
+
if (Object.keys(options).length) {
|
|
309
|
+
setMetadataMap(propertyKey, options, RXAP_FORM_SYSTEM_HIDE_SHOW_OPTIONS, target);
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
let ControlHideShowDirective = class ControlHideShowDirective {
|
|
314
|
+
constructor(renderer, elementRef, parent, ngControl) {
|
|
315
|
+
this.renderer = renderer;
|
|
316
|
+
this.elementRef = elementRef;
|
|
317
|
+
this.parent = parent;
|
|
318
|
+
this.ngControl = ngControl;
|
|
319
|
+
this.subscription = new Subscription();
|
|
320
|
+
}
|
|
321
|
+
ngOnInit() {
|
|
322
|
+
var _a, _b;
|
|
323
|
+
if (!this.ngControl && !this.parent) {
|
|
324
|
+
throw new Error('Easier the ControlContainer or NgControl must be injectable');
|
|
325
|
+
}
|
|
326
|
+
if (!this.ngControl && !this.controlId) {
|
|
327
|
+
throw new Error('If the NgControl is not injectable then the control id must be defined!');
|
|
328
|
+
}
|
|
329
|
+
const control = (_b = (_a = this.ngControl) === null || _a === void 0 ? void 0 : _a.control) !== null && _b !== void 0 ? _b : this.extractControl(this.parent, this.controlId);
|
|
330
|
+
if (!(control instanceof RxapFormControl)) {
|
|
331
|
+
throw new Error('The control is not an instance of RxapFormControl');
|
|
332
|
+
}
|
|
333
|
+
this.control = control;
|
|
334
|
+
const formDefinition = this.extractFormDefinition(control);
|
|
335
|
+
const hideFunction = this.extractHideFunction(formDefinition);
|
|
336
|
+
const showFunction = this.extractShowFunction(formDefinition);
|
|
337
|
+
const options = this.extractOptions(formDefinition);
|
|
338
|
+
let changeTrigger = formDefinition.rxapFormGroup.valueChanges;
|
|
339
|
+
if (options.rootChange) {
|
|
340
|
+
changeTrigger = formDefinition.rxapFormGroup.root.valueChanges;
|
|
341
|
+
}
|
|
342
|
+
changeTrigger = changeTrigger.pipe(startWith(null));
|
|
343
|
+
if (showFunction) {
|
|
344
|
+
this.subscription.add(changeTrigger.pipe(tap(() => {
|
|
345
|
+
// TODO : resubscribe if the showFunction throws an error
|
|
346
|
+
const show = showFunction.call(formDefinition, control);
|
|
347
|
+
switch (show) {
|
|
348
|
+
case true:
|
|
349
|
+
this.show();
|
|
350
|
+
break;
|
|
351
|
+
case false:
|
|
352
|
+
this.hide();
|
|
353
|
+
break;
|
|
354
|
+
case null:
|
|
355
|
+
this.reset();
|
|
356
|
+
break;
|
|
357
|
+
}
|
|
358
|
+
}), catchError(err => {
|
|
359
|
+
console.error(err);
|
|
360
|
+
return of(null);
|
|
361
|
+
})).subscribe());
|
|
362
|
+
}
|
|
363
|
+
if (hideFunction) {
|
|
364
|
+
this.subscription.add(changeTrigger.pipe(tap(() => {
|
|
365
|
+
// TODO : resubscribe if the hideFunction throws an error
|
|
366
|
+
const hide = hideFunction.call(formDefinition, control);
|
|
367
|
+
switch (hide) {
|
|
368
|
+
case true:
|
|
369
|
+
this.hide();
|
|
370
|
+
break;
|
|
371
|
+
case false:
|
|
372
|
+
this.show();
|
|
373
|
+
break;
|
|
374
|
+
case null:
|
|
375
|
+
this.reset();
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
}), catchError(err => {
|
|
379
|
+
console.error(err);
|
|
380
|
+
return of(null);
|
|
381
|
+
})).subscribe());
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
ngOnDestroy() {
|
|
385
|
+
this.subscription.unsubscribe();
|
|
386
|
+
}
|
|
387
|
+
extractOptions(formDefinition) {
|
|
388
|
+
var _a;
|
|
389
|
+
const map = (_a = getMetadata(RXAP_FORM_SYSTEM_HIDE_SHOW_OPTIONS, Object.getPrototypeOf(formDefinition))) !== null && _a !== void 0 ? _a : null;
|
|
390
|
+
if (!map || !map.has(this.control.controlId)) {
|
|
391
|
+
return {};
|
|
392
|
+
}
|
|
393
|
+
return map.get(this.control.controlId);
|
|
394
|
+
}
|
|
395
|
+
extractHideFunction(formDefinition) {
|
|
396
|
+
var _a;
|
|
397
|
+
const map = (_a = getMetadata(RXAP_FORM_SYSTEM_HIDE_METADATA, Object.getPrototypeOf(formDefinition))) !== null && _a !== void 0 ? _a : null;
|
|
398
|
+
if (!map || !map.has(this.control.controlId)) {
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
return map.get(this.control.controlId);
|
|
402
|
+
}
|
|
403
|
+
extractShowFunction(formDefinition) {
|
|
404
|
+
var _a;
|
|
405
|
+
const map = (_a = getMetadata(RXAP_FORM_SYSTEM_SHOW_METADATA, Object.getPrototypeOf(formDefinition))) !== null && _a !== void 0 ? _a : null;
|
|
406
|
+
if (!map || !map.has(this.control.controlId)) {
|
|
407
|
+
return null;
|
|
408
|
+
}
|
|
409
|
+
return map.get(this.control.controlId);
|
|
410
|
+
}
|
|
411
|
+
hide() {
|
|
412
|
+
this.renderer.setStyle(this.elementRef.nativeElement, 'display', 'none');
|
|
413
|
+
}
|
|
414
|
+
show() {
|
|
415
|
+
this.renderer.setStyle(this.elementRef.nativeElement, 'display', 'block');
|
|
416
|
+
}
|
|
417
|
+
reset() {
|
|
418
|
+
this.renderer.removeStyle(this.elementRef.nativeElement, 'display');
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
ControlHideShowDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ControlHideShowDirective, deps: [{ token: Renderer2 }, { token: ElementRef }, { token: ControlContainer, optional: true }, { token: NgControl, optional: true, self: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
422
|
+
ControlHideShowDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.3", type: ControlHideShowDirective, selector: "[rxapControlHideShow]", inputs: { controlId: ["rxapControlHideShow", "controlId"] }, ngImport: i0 });
|
|
423
|
+
ControlHideShowDirective = __decorate([
|
|
424
|
+
Mixin(ExtractControlMixin, ExtractFormDefinitionMixin),
|
|
425
|
+
__metadata("design:paramtypes", [Renderer2,
|
|
426
|
+
ElementRef, Object, Object])
|
|
427
|
+
], ControlHideShowDirective);
|
|
428
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ControlHideShowDirective, decorators: [{
|
|
429
|
+
type: Directive,
|
|
430
|
+
args: [{
|
|
431
|
+
selector: '[rxapControlHideShow]'
|
|
432
|
+
}]
|
|
433
|
+
}], ctorParameters: function () {
|
|
434
|
+
return [{ type: i0.Renderer2, decorators: [{
|
|
435
|
+
type: Inject,
|
|
436
|
+
args: [Renderer2]
|
|
437
|
+
}] }, { type: i0.ElementRef, decorators: [{
|
|
438
|
+
type: Inject,
|
|
439
|
+
args: [ElementRef]
|
|
440
|
+
}] }, { type: i1.ControlContainer, decorators: [{
|
|
441
|
+
type: Optional
|
|
442
|
+
}, {
|
|
443
|
+
type: Inject,
|
|
444
|
+
args: [ControlContainer]
|
|
445
|
+
}] }, { type: i1.NgControl, decorators: [{
|
|
446
|
+
type: Self
|
|
447
|
+
}, {
|
|
448
|
+
type: Optional
|
|
449
|
+
}, {
|
|
450
|
+
type: Inject,
|
|
451
|
+
args: [NgControl]
|
|
452
|
+
}] }];
|
|
453
|
+
}, propDecorators: { controlId: [{
|
|
454
|
+
type: Input,
|
|
455
|
+
args: ['rxapControlHideShow']
|
|
456
|
+
}] } });
|
|
457
|
+
class ControlHideShowDirectiveModule {
|
|
458
|
+
}
|
|
459
|
+
ControlHideShowDirectiveModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ControlHideShowDirectiveModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
460
|
+
ControlHideShowDirectiveModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ControlHideShowDirectiveModule, declarations: [ControlHideShowDirective], exports: [ControlHideShowDirective] });
|
|
461
|
+
ControlHideShowDirectiveModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ControlHideShowDirectiveModule });
|
|
462
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ControlHideShowDirectiveModule, decorators: [{
|
|
463
|
+
type: NgModule,
|
|
464
|
+
args: [{
|
|
465
|
+
declarations: [ControlHideShowDirective],
|
|
466
|
+
exports: [ControlHideShowDirective]
|
|
467
|
+
}]
|
|
468
|
+
}] });
|
|
469
|
+
|
|
470
|
+
const DATA_SOURCE_NAME = 'options';
|
|
471
|
+
function ComposeOptionsTransformers(...fnc) {
|
|
472
|
+
return base => fnc.reduce((source, transform) => transform(source), base);
|
|
473
|
+
}
|
|
474
|
+
function UseOptionsDataSource(dataSource, settings) {
|
|
475
|
+
return function (target, propertyKey) {
|
|
476
|
+
UseDataSource(dataSource, DATA_SOURCE_NAME, settings)(target, propertyKey);
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
let InputSelectOptionsDirective = class InputSelectOptionsDirective {
|
|
480
|
+
constructor(template, dataSourceLoader, viewContainerRef, injector, cdr,
|
|
481
|
+
// The ngControl could be unknown on construction
|
|
482
|
+
// bc it is available after the content is init
|
|
483
|
+
ngControl = null, matFormField = null) {
|
|
484
|
+
this.template = template;
|
|
485
|
+
this.dataSourceLoader = dataSourceLoader;
|
|
486
|
+
this.viewContainerRef = viewContainerRef;
|
|
487
|
+
this.injector = injector;
|
|
488
|
+
this.cdr = cdr;
|
|
489
|
+
this.ngControl = ngControl;
|
|
490
|
+
this.matFormField = matFormField;
|
|
491
|
+
this.viewer = { id: '[rxapInputSelectOptions]' };
|
|
492
|
+
this.subscription = new Subscription();
|
|
493
|
+
this.options = null;
|
|
494
|
+
}
|
|
495
|
+
ngAfterViewInit() {
|
|
496
|
+
this.extractControl();
|
|
497
|
+
this.extractDatasource();
|
|
498
|
+
this.viewer = {
|
|
499
|
+
id: '[rxapInputSelectOptions]' + this.control.controlId,
|
|
500
|
+
viewChange: this.control.value$.pipe(map(value => {
|
|
501
|
+
var _a;
|
|
502
|
+
if ((_a = this.settings) === null || _a === void 0 ? void 0 : _a.ignoreSelectedValue) {
|
|
503
|
+
return {};
|
|
504
|
+
}
|
|
505
|
+
return value;
|
|
506
|
+
})),
|
|
507
|
+
control: this.control,
|
|
508
|
+
};
|
|
509
|
+
this.loadOptions();
|
|
510
|
+
if (this.matAutocomplete) {
|
|
511
|
+
this.matAutocomplete.displayWith = this.toDisplay.bind(this);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
extractDatasource(control = this.control) {
|
|
515
|
+
const formDefinition = this.extractFormDefinition(control);
|
|
516
|
+
const useDataSourceValueMap = this.extractDataSources(formDefinition, control.controlId);
|
|
517
|
+
if (!useDataSourceValueMap.has(DATA_SOURCE_NAME)) {
|
|
518
|
+
throw new Error(`The data source with the name 'options' is not defined`);
|
|
519
|
+
}
|
|
520
|
+
const useDataSourceValue = useDataSourceValueMap.get(DATA_SOURCE_NAME);
|
|
521
|
+
this.settings = useDataSourceValue.settings;
|
|
522
|
+
let dataSource;
|
|
523
|
+
try {
|
|
524
|
+
dataSource = this.dataSourceLoader.load(useDataSourceValue.dataSource, this.metadata, this.injector);
|
|
525
|
+
}
|
|
526
|
+
catch (e) {
|
|
527
|
+
if (e.name && e.name === 'NullInjectorError') {
|
|
528
|
+
if (isDevMode()) {
|
|
529
|
+
console.error('Cloud not inject the options data source', useDataSourceValue);
|
|
530
|
+
}
|
|
531
|
+
throw new Error('Cloud not inject the options data source:\n' + e.message);
|
|
532
|
+
}
|
|
533
|
+
throw e;
|
|
534
|
+
}
|
|
535
|
+
const settings = useDataSourceValue.settings;
|
|
536
|
+
if (settings === null || settings === void 0 ? void 0 : settings.transformer) {
|
|
537
|
+
dataSource = new PipeDataSource(dataSource, map(settings.transformer));
|
|
538
|
+
}
|
|
539
|
+
return this.dataSource = dataSource;
|
|
540
|
+
}
|
|
541
|
+
toDisplay(value) {
|
|
542
|
+
var _a, _b, _c;
|
|
543
|
+
if (!value) {
|
|
544
|
+
return '';
|
|
545
|
+
}
|
|
546
|
+
return (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.find((option) => option.value === value)) === null || _b === void 0 ? void 0 : _b.display) !== null && _c !== void 0 ? _c : (isDevMode() ? 'to display error' : '');
|
|
547
|
+
}
|
|
548
|
+
extractControl(ngControl) {
|
|
549
|
+
var _a, _b, _c, _d;
|
|
550
|
+
if (ngControl === void 0) { ngControl = (_d = (_a = this.ngControl) !== null && _a !== void 0 ? _a : (_c = (_b = this.matFormField) === null || _b === void 0 ? void 0 : _b._control) === null || _c === void 0 ? void 0 : _c.ngControl) !== null && _d !== void 0 ? _d : null; }
|
|
551
|
+
if (!ngControl) {
|
|
552
|
+
throw new Error('The ngControl is not defined!');
|
|
553
|
+
}
|
|
554
|
+
this.ngControl = ngControl;
|
|
555
|
+
const control = this.ngControl.control;
|
|
556
|
+
if (!(control instanceof RxapFormControl)) {
|
|
557
|
+
throw new Error('Control is not a RxapFormControl!');
|
|
558
|
+
}
|
|
559
|
+
return this.control = control;
|
|
560
|
+
}
|
|
561
|
+
ngOnDestroy() {
|
|
562
|
+
var _a;
|
|
563
|
+
(_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
564
|
+
}
|
|
565
|
+
loadOptions(dataSource = this.dataSource) {
|
|
566
|
+
this.subscription.add(dataSource.connect(this.viewer).pipe(tap(options => this.renderTemplate(this.options = options))).subscribe());
|
|
567
|
+
}
|
|
568
|
+
renderTemplate(options = this.options) {
|
|
569
|
+
this.viewContainerRef.clear();
|
|
570
|
+
if (options) {
|
|
571
|
+
if (!Array.isArray(options)) {
|
|
572
|
+
for (const [value, display] of Object.entries(options)) {
|
|
573
|
+
this.viewContainerRef.createEmbeddedView(this.template, { $implicit: { value, display } });
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
else {
|
|
577
|
+
for (const option of options) {
|
|
578
|
+
this.viewContainerRef.createEmbeddedView(this.template, { $implicit: option });
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
else {
|
|
583
|
+
if (isDevMode()) {
|
|
584
|
+
console.warn(`The options for the control ${this.control.fullControlPath} is empty/null/undefined!`);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
this.cdr.detectChanges();
|
|
588
|
+
}
|
|
589
|
+
};
|
|
590
|
+
InputSelectOptionsDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: InputSelectOptionsDirective, deps: [{ token: TemplateRef }, { token: DataSourceLoader }, { token: ViewContainerRef }, { token: INJECTOR }, { token: ChangeDetectorRef }, { token: NgControl, optional: true }, { token: MAT_FORM_FIELD, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
591
|
+
InputSelectOptionsDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.3", type: InputSelectOptionsDirective, selector: "[rxapInputSelectOptions]", inputs: { viewer: ["rxapInputSelectOptionsViewer", "viewer"], metadata: ["rxapInputSelectOptionsMetadata", "metadata"], matAutocomplete: ["rxapInputSelectOptionsMatAutocomplete", "matAutocomplete"] }, ngImport: i0 });
|
|
592
|
+
__decorate([
|
|
593
|
+
Required,
|
|
594
|
+
__metadata("design:type", RxapFormControl)
|
|
595
|
+
], InputSelectOptionsDirective.prototype, "control", void 0);
|
|
596
|
+
__decorate([
|
|
597
|
+
Required,
|
|
598
|
+
__metadata("design:type", BaseDataSource)
|
|
599
|
+
], InputSelectOptionsDirective.prototype, "dataSource", void 0);
|
|
600
|
+
InputSelectOptionsDirective = __decorate([
|
|
601
|
+
Mixin(ExtractFormDefinitionMixin, ExtractDataSourcesMixin),
|
|
602
|
+
__metadata("design:paramtypes", [TemplateRef,
|
|
603
|
+
DataSourceLoader,
|
|
604
|
+
ViewContainerRef,
|
|
605
|
+
Injector,
|
|
606
|
+
ChangeDetectorRef, Object, Object])
|
|
607
|
+
], InputSelectOptionsDirective);
|
|
608
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: InputSelectOptionsDirective, decorators: [{
|
|
609
|
+
type: Directive,
|
|
610
|
+
args: [{
|
|
611
|
+
selector: '[rxapInputSelectOptions]'
|
|
612
|
+
}]
|
|
613
|
+
}], ctorParameters: function () {
|
|
614
|
+
return [{ type: i0.TemplateRef, decorators: [{
|
|
615
|
+
type: Inject,
|
|
616
|
+
args: [TemplateRef]
|
|
617
|
+
}] }, { type: i2.DataSourceLoader, decorators: [{
|
|
618
|
+
type: Inject,
|
|
619
|
+
args: [DataSourceLoader]
|
|
620
|
+
}] }, { type: i0.ViewContainerRef, decorators: [{
|
|
621
|
+
type: Inject,
|
|
622
|
+
args: [ViewContainerRef]
|
|
623
|
+
}] }, { type: i0.Injector, decorators: [{
|
|
624
|
+
type: Inject,
|
|
625
|
+
args: [INJECTOR]
|
|
626
|
+
}] }, { type: i0.ChangeDetectorRef, decorators: [{
|
|
627
|
+
type: Inject,
|
|
628
|
+
args: [ChangeDetectorRef]
|
|
629
|
+
}] }, { type: i1.NgControl, decorators: [{
|
|
630
|
+
type: Optional
|
|
631
|
+
}, {
|
|
632
|
+
type: Inject,
|
|
633
|
+
args: [NgControl]
|
|
634
|
+
}] }, { type: i3.MatFormField, decorators: [{
|
|
635
|
+
type: Optional
|
|
636
|
+
}, {
|
|
637
|
+
type: Inject,
|
|
638
|
+
args: [MAT_FORM_FIELD]
|
|
639
|
+
}] }];
|
|
640
|
+
}, propDecorators: { viewer: [{
|
|
641
|
+
type: Input,
|
|
642
|
+
args: ['rxapInputSelectOptionsViewer']
|
|
643
|
+
}], metadata: [{
|
|
644
|
+
type: Input,
|
|
645
|
+
args: ['rxapInputSelectOptionsMetadata']
|
|
646
|
+
}], matAutocomplete: [{
|
|
647
|
+
type: Input,
|
|
648
|
+
args: ['rxapInputSelectOptionsMatAutocomplete']
|
|
649
|
+
}], control: [], dataSource: [] } });
|
|
650
|
+
class InputSelectOptionsDirectiveModule {
|
|
651
|
+
}
|
|
652
|
+
InputSelectOptionsDirectiveModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: InputSelectOptionsDirectiveModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
653
|
+
InputSelectOptionsDirectiveModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: InputSelectOptionsDirectiveModule, declarations: [InputSelectOptionsDirective], exports: [InputSelectOptionsDirective] });
|
|
654
|
+
InputSelectOptionsDirectiveModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: InputSelectOptionsDirectiveModule });
|
|
655
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: InputSelectOptionsDirectiveModule, decorators: [{
|
|
656
|
+
type: NgModule,
|
|
657
|
+
args: [{
|
|
658
|
+
declarations: [InputSelectOptionsDirective],
|
|
659
|
+
exports: [InputSelectOptionsDirective]
|
|
660
|
+
}]
|
|
661
|
+
}] });
|
|
662
|
+
|
|
663
|
+
class FormSystemDirectivesModule {
|
|
664
|
+
}
|
|
665
|
+
FormSystemDirectivesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: FormSystemDirectivesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
666
|
+
FormSystemDirectivesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: FormSystemDirectivesModule, exports: [InputSelectOptionsDirectiveModule,
|
|
667
|
+
ControlHideShowDirectiveModule] });
|
|
668
|
+
FormSystemDirectivesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: FormSystemDirectivesModule, imports: [InputSelectOptionsDirectiveModule,
|
|
669
|
+
ControlHideShowDirectiveModule] });
|
|
670
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: FormSystemDirectivesModule, decorators: [{
|
|
671
|
+
type: NgModule,
|
|
672
|
+
args: [{
|
|
673
|
+
exports: [
|
|
674
|
+
InputSelectOptionsDirectiveModule,
|
|
675
|
+
ControlHideShowDirectiveModule
|
|
676
|
+
]
|
|
677
|
+
}]
|
|
678
|
+
}] });
|
|
679
|
+
|
|
680
|
+
class IsEqualToDirective {
|
|
681
|
+
set equalTo(value) {
|
|
682
|
+
this._equalTo = value;
|
|
683
|
+
if (this._onChange) {
|
|
684
|
+
this._onChange();
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
validate(control) {
|
|
688
|
+
if (this._equalTo === null || this._equalTo === control.value) {
|
|
689
|
+
return null;
|
|
690
|
+
}
|
|
691
|
+
return { isEqualTo: { value: this._equalTo, actualValue: control.value } };
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* @description
|
|
695
|
+
* Registers a callback function to call when the validator inputs change.
|
|
696
|
+
*
|
|
697
|
+
* @param fn The callback function
|
|
698
|
+
*/
|
|
699
|
+
registerOnValidatorChange(fn) {
|
|
700
|
+
this._onChange = fn;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
IsEqualToDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: IsEqualToDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
704
|
+
IsEqualToDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.3", type: IsEqualToDirective, selector: "[rxapIsEqualTo]", inputs: { equalTo: ["rxapIsEqualTo", "equalTo"] }, providers: [
|
|
705
|
+
{
|
|
706
|
+
provide: NG_VALIDATORS,
|
|
707
|
+
multi: true,
|
|
708
|
+
useExisting: forwardRef(() => IsEqualToDirective)
|
|
709
|
+
}
|
|
710
|
+
], ngImport: i0 });
|
|
711
|
+
__decorate([
|
|
712
|
+
Required,
|
|
713
|
+
__metadata("design:type", Object),
|
|
714
|
+
__metadata("design:paramtypes", [Object])
|
|
715
|
+
], IsEqualToDirective.prototype, "equalTo", null);
|
|
716
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: IsEqualToDirective, decorators: [{
|
|
717
|
+
type: Directive,
|
|
718
|
+
args: [{
|
|
719
|
+
selector: '[rxapIsEqualTo]',
|
|
720
|
+
providers: [
|
|
721
|
+
{
|
|
722
|
+
provide: NG_VALIDATORS,
|
|
723
|
+
multi: true,
|
|
724
|
+
useExisting: forwardRef(() => IsEqualToDirective)
|
|
725
|
+
}
|
|
726
|
+
]
|
|
727
|
+
}]
|
|
728
|
+
}], propDecorators: { equalTo: [{
|
|
729
|
+
type: Input,
|
|
730
|
+
args: ['rxapIsEqualTo']
|
|
731
|
+
}] } });
|
|
732
|
+
class IsEqualToDirectiveModule {
|
|
733
|
+
}
|
|
734
|
+
IsEqualToDirectiveModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: IsEqualToDirectiveModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
735
|
+
IsEqualToDirectiveModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: IsEqualToDirectiveModule, declarations: [IsEqualToDirective], exports: [IsEqualToDirective] });
|
|
736
|
+
IsEqualToDirectiveModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: IsEqualToDirectiveModule });
|
|
737
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: IsEqualToDirectiveModule, decorators: [{
|
|
738
|
+
type: NgModule,
|
|
739
|
+
args: [{
|
|
740
|
+
declarations: [IsEqualToDirective],
|
|
741
|
+
exports: [IsEqualToDirective]
|
|
742
|
+
}]
|
|
743
|
+
}] });
|
|
744
|
+
|
|
745
|
+
// endregion
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* Generated bundle index. Do not edit.
|
|
749
|
+
*/
|
|
750
|
+
|
|
751
|
+
export { ComposeOptionsTransformers, ControlDataSource, ControlHideShowDirective, ControlHideShowDirectiveModule, DATA_SOURCE_NAME, ExtractControlMixin, ExtractDataSourcesMixin, ExtractFormDefinitionMixin, FormSystemControlDirective, FormSystemDirectivesModule, FormSystemMetadataKeys, FormSystemModule, InputSelectOptionsDirective, InputSelectOptionsDirectiveModule, IsEqualToDirective, IsEqualToDirectiveModule, RXAP_FORM_CONTROL_SOURCE, RXAP_FORM_SYSTEM_HIDE_METADATA, RXAP_FORM_SYSTEM_HIDE_SHOW_OPTIONS, RXAP_FORM_SYSTEM_SHOW_METADATA, RxapFormSystemError, UseComponent, UseDataSource, UseFormComponent, UseHideFunction, UseOptionsDataSource, UseShowFunction, controlDataSource };
|
|
752
|
+
//# sourceMappingURL=rxap-form-system.mjs.map
|