@rxap/form-system 14.1.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/control-data-source.mjs +41 -0
- package/esm2022/lib/directives/control-hide-show.directive.mjs +184 -0
- package/esm2022/lib/directives/form-directives.module.mjs +22 -0
- package/esm2022/lib/directives/input-select-options.directive.mjs +191 -0
- package/esm2022/lib/form-system-control.directive.mjs +158 -0
- package/esm2022/lib/form-system.module.mjs +18 -0
- package/{esm2020 → esm2022}/lib/mixins/extract-control.mixin.mjs +1 -1
- package/esm2022/lib/mixins/extract-options-data-source.mixin.mjs +59 -0
- package/esm2022/lib/validators/is-equal-to.mjs +72 -0
- package/esm2022/lib/validators/is-selectable-value.directive.mjs +91 -0
- package/{fesm2020 → fesm2022}/rxap-form-system.mjs +64 -65
- package/fesm2022/rxap-form-system.mjs.map +1 -0
- package/lib/directives/control-hide-show.directive.d.ts +2 -2
- package/lib/directives/input-select-options.directive.d.ts +3 -3
- package/lib/form-system-control.directive.d.ts +1 -1
- package/lib/mixins/extract-control.mixin.d.ts +1 -1
- package/lib/validators/is-equal-to.d.ts +1 -1
- package/lib/validators/is-selectable-value.directive.d.ts +1 -1
- package/package.json +22 -28
- package/esm2020/lib/control-data-source.mjs +0 -40
- package/esm2020/lib/directives/control-hide-show.directive.mjs +0 -183
- package/esm2020/lib/directives/form-directives.module.mjs +0 -21
- package/esm2020/lib/directives/input-select-options.directive.mjs +0 -191
- package/esm2020/lib/form-system-control.directive.mjs +0 -158
- package/esm2020/lib/form-system.module.mjs +0 -17
- package/esm2020/lib/mixins/extract-options-data-source.mixin.mjs +0 -59
- package/esm2020/lib/validators/is-equal-to.mjs +0 -70
- package/esm2020/lib/validators/is-selectable-value.directive.mjs +0 -90
- package/fesm2015/rxap-form-system.mjs +0 -893
- package/fesm2015/rxap-form-system.mjs.map +0 -1
- package/fesm2020/rxap-form-system.mjs.map +0 -1
- /package/{esm2020 → esm2022}/index.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/control-with-data-source.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/decorators/metadata-keys.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/decorators/use-component.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/decorators/use-data-source.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/decorators/use-form-component.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/error.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/mixins/extract-control-from-parent.mixin.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/mixins/extract-data-sources.mixin.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/mixins/extract-form-definition.mixin.mjs +0 -0
- /package/{esm2020 → esm2022}/rxap-form-system.mjs +0 -0
|
@@ -1,893 +0,0 @@
|
|
|
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 i1$1 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, setMetadataMapMap, setMetadataMap, setMetadata } from '@rxap/utilities/reflect-metadata';
|
|
12
|
-
import { map, startWith, distinctUntilChanged, shareReplay, tap, catchError, throttleTime, switchMap } from 'rxjs/operators';
|
|
13
|
-
import { Subscription, of, EMPTY } 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: "14.2.2", 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: "14.0.0", version: "14.2.2", 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: "14.2.2", 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: i1$1.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: "14.2.2", ngImport: i0, type: FormSystemModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
191
|
-
FormSystemModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.2", ngImport: i0, type: FormSystemModule, declarations: [FormSystemControlDirective], exports: [FormSystemControlDirective] });
|
|
192
|
-
FormSystemModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormSystemModule });
|
|
193
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", 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: "14.2.2", 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: "14.2.2", ngImport: i0, type: ControlDataSource });
|
|
221
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", 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 ExtractControlFromParentMixin {
|
|
240
|
-
extractControlFromParent(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 UseDataSource(dataSource, name, settings) {
|
|
270
|
-
return function (target, propertyKey) {
|
|
271
|
-
const value = { dataSource, settings };
|
|
272
|
-
setMetadataMapMap(propertyKey, name, value, FormSystemMetadataKeys.DATA_SOURCES, target);
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
class ExtractControlMixin {
|
|
277
|
-
extractControl(ngControl) {
|
|
278
|
-
var _a, _b, _c, _d;
|
|
279
|
-
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; }
|
|
280
|
-
if (!ngControl) {
|
|
281
|
-
throw new Error('The ngControl is not defined!');
|
|
282
|
-
}
|
|
283
|
-
if (!(ngControl instanceof NgControl)) {
|
|
284
|
-
throw new Error('The AbstractControlDirective is not a NgControl!');
|
|
285
|
-
}
|
|
286
|
-
this.ngControl = ngControl;
|
|
287
|
-
const control = this.ngControl.control;
|
|
288
|
-
if (!(control instanceof RxapFormControl)) {
|
|
289
|
-
throw new Error('Control is not a RxapFormControl!');
|
|
290
|
-
}
|
|
291
|
-
return this.control = control;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
const DATA_SOURCE_NAME = 'options';
|
|
296
|
-
function ComposeOptionsTransformers(...fnc) {
|
|
297
|
-
return base => fnc.reduce((source, transform) => transform(source), base);
|
|
298
|
-
}
|
|
299
|
-
function UseOptionsDataSource(dataSource, settings) {
|
|
300
|
-
return function (target, propertyKey) {
|
|
301
|
-
UseDataSource(dataSource, DATA_SOURCE_NAME, settings)(target, propertyKey);
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
let ExtractOptionsDataSourceMixin = class ExtractOptionsDataSourceMixin {
|
|
305
|
-
extractOptionsDatasource(control) {
|
|
306
|
-
var _a, _b;
|
|
307
|
-
control !== null && control !== void 0 ? control : (control = this.extractControl());
|
|
308
|
-
if (!(control instanceof RxapFormControl)) {
|
|
309
|
-
throw new Error('Ensure to use a RxapFromControl');
|
|
310
|
-
}
|
|
311
|
-
const formDefinition = this.extractFormDefinition(control);
|
|
312
|
-
const useDataSourceValueMap = this.extractDataSources(formDefinition, control.controlId);
|
|
313
|
-
if (!useDataSourceValueMap.has('options')) {
|
|
314
|
-
throw new Error(`The data source with the name 'options' is not defined`);
|
|
315
|
-
}
|
|
316
|
-
const useDataSourceValue = this.useDataSourceValue = useDataSourceValueMap.get('options');
|
|
317
|
-
this.settings = (_a = this.useDataSourceValue.settings) !== null && _a !== void 0 ? _a : {};
|
|
318
|
-
let dataSource;
|
|
319
|
-
try {
|
|
320
|
-
dataSource = this.dataSourceLoader.load(useDataSourceValue.dataSource, this.metadata, this.injector);
|
|
321
|
-
}
|
|
322
|
-
catch (e) {
|
|
323
|
-
if (e.name && e.name === 'NullInjectorError') {
|
|
324
|
-
if (isDevMode()) {
|
|
325
|
-
console.error('Cloud not inject the options data source', this.useDataSourceValue);
|
|
326
|
-
}
|
|
327
|
-
throw new Error('Cloud not inject the options data source:\n' + e.message);
|
|
328
|
-
}
|
|
329
|
-
throw e;
|
|
330
|
-
}
|
|
331
|
-
if ((_b = this.settings) === null || _b === void 0 ? void 0 : _b.transformer) {
|
|
332
|
-
dataSource = new PipeDataSource(dataSource, map(this.settings.transformer), tap(options => useDataSourceValue.lastValue = options));
|
|
333
|
-
}
|
|
334
|
-
else {
|
|
335
|
-
dataSource = new PipeDataSource(dataSource, tap(options => useDataSourceValue.lastValue = options));
|
|
336
|
-
}
|
|
337
|
-
return this.dataSource = dataSource;
|
|
338
|
-
}
|
|
339
|
-
};
|
|
340
|
-
ExtractOptionsDataSourceMixin = __decorate([
|
|
341
|
-
Mixin(ExtractControlMixin, ExtractFormDefinitionMixin, ExtractDataSourcesMixin)
|
|
342
|
-
], ExtractOptionsDataSourceMixin);
|
|
343
|
-
|
|
344
|
-
function UseComponent(component, setProperties = {}) {
|
|
345
|
-
return function (target, propertyKey) {
|
|
346
|
-
setMetadataMap(propertyKey, component, FormSystemMetadataKeys.COMPONENTS, target);
|
|
347
|
-
setMetadataMap(propertyKey, setProperties, FormSystemMetadataKeys.COMPONENTS_PROPERTIES, target);
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* Links a component with a form definition
|
|
353
|
-
*
|
|
354
|
-
* @param component
|
|
355
|
-
*/
|
|
356
|
-
function UseFormComponent(component) {
|
|
357
|
-
return function (target) {
|
|
358
|
-
setMetadata(FormSystemMetadataKeys.FORM_COMPONENT, component, target);
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
const RXAP_FORM_SYSTEM_SHOW_METADATA = 'rxap/form-system/show-function';
|
|
363
|
-
const RXAP_FORM_SYSTEM_HIDE_METADATA = 'rxap/form-system/hide-function';
|
|
364
|
-
const RXAP_FORM_SYSTEM_HIDE_SHOW_OPTIONS = 'rxap/form-system/hide-show-options';
|
|
365
|
-
function UseHideFunction(hideFunction, options = {}) {
|
|
366
|
-
return function (target, propertyKey) {
|
|
367
|
-
setMetadataMap(propertyKey, hideFunction, RXAP_FORM_SYSTEM_HIDE_METADATA, target);
|
|
368
|
-
if (Object.keys(options).length) {
|
|
369
|
-
setMetadataMap(propertyKey, options, RXAP_FORM_SYSTEM_HIDE_SHOW_OPTIONS, target);
|
|
370
|
-
}
|
|
371
|
-
};
|
|
372
|
-
}
|
|
373
|
-
function UseShowFunction(showFunction, options = {}) {
|
|
374
|
-
return function (target, propertyKey) {
|
|
375
|
-
setMetadataMap(propertyKey, showFunction, RXAP_FORM_SYSTEM_SHOW_METADATA, target);
|
|
376
|
-
if (Object.keys(options).length) {
|
|
377
|
-
setMetadataMap(propertyKey, options, RXAP_FORM_SYSTEM_HIDE_SHOW_OPTIONS, target);
|
|
378
|
-
}
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
let ControlHideShowDirective = class ControlHideShowDirective {
|
|
382
|
-
constructor(renderer, elementRef, parent, ngControl) {
|
|
383
|
-
this.renderer = renderer;
|
|
384
|
-
this.elementRef = elementRef;
|
|
385
|
-
this.parent = parent;
|
|
386
|
-
this.ngControl = ngControl;
|
|
387
|
-
this.subscription = new Subscription();
|
|
388
|
-
}
|
|
389
|
-
ngOnInit() {
|
|
390
|
-
var _a, _b;
|
|
391
|
-
if (!this.ngControl && !this.parent) {
|
|
392
|
-
throw new Error('Easier the ControlContainer or NgControl must be injectable');
|
|
393
|
-
}
|
|
394
|
-
if (!this.ngControl && !this.controlId) {
|
|
395
|
-
throw new Error('If the NgControl is not injectable then the control id must be defined!');
|
|
396
|
-
}
|
|
397
|
-
const control = (_b = (_a = this.ngControl) === null || _a === void 0 ? void 0 : _a.control) !== null && _b !== void 0 ? _b : this.extractControlFromParent(this.parent, this.controlId);
|
|
398
|
-
if (!(control instanceof RxapFormControl)) {
|
|
399
|
-
throw new Error('The control is not an instance of RxapFormControl');
|
|
400
|
-
}
|
|
401
|
-
this.control = control;
|
|
402
|
-
const formDefinition = this.extractFormDefinition(control);
|
|
403
|
-
const hideFunction = this.extractHideFunction(formDefinition);
|
|
404
|
-
const showFunction = this.extractShowFunction(formDefinition);
|
|
405
|
-
const options = this.extractOptions(formDefinition);
|
|
406
|
-
let changeTrigger = formDefinition.rxapFormGroup.valueChanges;
|
|
407
|
-
if (options.rootChange) {
|
|
408
|
-
changeTrigger = formDefinition.rxapFormGroup.root.valueChanges;
|
|
409
|
-
}
|
|
410
|
-
changeTrigger = changeTrigger.pipe(startWith(null));
|
|
411
|
-
if (showFunction) {
|
|
412
|
-
this.subscription.add(changeTrigger.pipe(tap(() => {
|
|
413
|
-
// TODO : resubscribe if the showFunction throws an error
|
|
414
|
-
const show = showFunction.call(formDefinition, control);
|
|
415
|
-
switch (show) {
|
|
416
|
-
case true:
|
|
417
|
-
this.show();
|
|
418
|
-
break;
|
|
419
|
-
case false:
|
|
420
|
-
this.hide();
|
|
421
|
-
break;
|
|
422
|
-
case null:
|
|
423
|
-
this.reset();
|
|
424
|
-
break;
|
|
425
|
-
}
|
|
426
|
-
}), catchError(err => {
|
|
427
|
-
console.error(err);
|
|
428
|
-
return of(null);
|
|
429
|
-
})).subscribe());
|
|
430
|
-
}
|
|
431
|
-
if (hideFunction) {
|
|
432
|
-
this.subscription.add(changeTrigger.pipe(tap(() => {
|
|
433
|
-
// TODO : resubscribe if the hideFunction throws an error
|
|
434
|
-
const hide = hideFunction.call(formDefinition, control);
|
|
435
|
-
switch (hide) {
|
|
436
|
-
case true:
|
|
437
|
-
this.hide();
|
|
438
|
-
break;
|
|
439
|
-
case false:
|
|
440
|
-
this.show();
|
|
441
|
-
break;
|
|
442
|
-
case null:
|
|
443
|
-
this.reset();
|
|
444
|
-
break;
|
|
445
|
-
}
|
|
446
|
-
}), catchError(err => {
|
|
447
|
-
console.error(err);
|
|
448
|
-
return of(null);
|
|
449
|
-
})).subscribe());
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
ngOnDestroy() {
|
|
453
|
-
this.subscription.unsubscribe();
|
|
454
|
-
}
|
|
455
|
-
extractOptions(formDefinition) {
|
|
456
|
-
var _a;
|
|
457
|
-
const map = (_a = getMetadata(RXAP_FORM_SYSTEM_HIDE_SHOW_OPTIONS, Object.getPrototypeOf(formDefinition))) !== null && _a !== void 0 ? _a : null;
|
|
458
|
-
if (!map || !map.has(this.control.controlId)) {
|
|
459
|
-
return {};
|
|
460
|
-
}
|
|
461
|
-
return map.get(this.control.controlId);
|
|
462
|
-
}
|
|
463
|
-
extractHideFunction(formDefinition) {
|
|
464
|
-
var _a;
|
|
465
|
-
const map = (_a = getMetadata(RXAP_FORM_SYSTEM_HIDE_METADATA, Object.getPrototypeOf(formDefinition))) !== null && _a !== void 0 ? _a : null;
|
|
466
|
-
if (!map || !map.has(this.control.controlId)) {
|
|
467
|
-
return null;
|
|
468
|
-
}
|
|
469
|
-
return map.get(this.control.controlId);
|
|
470
|
-
}
|
|
471
|
-
extractShowFunction(formDefinition) {
|
|
472
|
-
var _a;
|
|
473
|
-
const map = (_a = getMetadata(RXAP_FORM_SYSTEM_SHOW_METADATA, Object.getPrototypeOf(formDefinition))) !== null && _a !== void 0 ? _a : null;
|
|
474
|
-
if (!map || !map.has(this.control.controlId)) {
|
|
475
|
-
return null;
|
|
476
|
-
}
|
|
477
|
-
return map.get(this.control.controlId);
|
|
478
|
-
}
|
|
479
|
-
hide() {
|
|
480
|
-
this.renderer.setStyle(this.elementRef.nativeElement, 'display', 'none');
|
|
481
|
-
}
|
|
482
|
-
show() {
|
|
483
|
-
this.renderer.setStyle(this.elementRef.nativeElement, 'display', 'block');
|
|
484
|
-
}
|
|
485
|
-
reset() {
|
|
486
|
-
this.renderer.removeStyle(this.elementRef.nativeElement, 'display');
|
|
487
|
-
}
|
|
488
|
-
};
|
|
489
|
-
ControlHideShowDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: ControlHideShowDirective, deps: [{ token: Renderer2 }, { token: ElementRef }, { token: ControlContainer, optional: true }, { token: NgControl, optional: true, self: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
490
|
-
ControlHideShowDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: ControlHideShowDirective, selector: "[rxapControlHideShow]", inputs: { controlId: ["rxapControlHideShow", "controlId"] }, ngImport: i0 });
|
|
491
|
-
ControlHideShowDirective = __decorate([
|
|
492
|
-
Mixin(ExtractControlFromParentMixin, ExtractFormDefinitionMixin),
|
|
493
|
-
__metadata("design:paramtypes", [Renderer2,
|
|
494
|
-
ElementRef, Object, Object])
|
|
495
|
-
], ControlHideShowDirective);
|
|
496
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: ControlHideShowDirective, decorators: [{
|
|
497
|
-
type: Directive,
|
|
498
|
-
args: [{
|
|
499
|
-
selector: '[rxapControlHideShow]'
|
|
500
|
-
}]
|
|
501
|
-
}], ctorParameters: function () {
|
|
502
|
-
return [{ type: i0.Renderer2, decorators: [{
|
|
503
|
-
type: Inject,
|
|
504
|
-
args: [Renderer2]
|
|
505
|
-
}] }, { type: i0.ElementRef, decorators: [{
|
|
506
|
-
type: Inject,
|
|
507
|
-
args: [ElementRef]
|
|
508
|
-
}] }, { type: i1.ControlContainer, decorators: [{
|
|
509
|
-
type: Optional
|
|
510
|
-
}, {
|
|
511
|
-
type: Inject,
|
|
512
|
-
args: [ControlContainer]
|
|
513
|
-
}] }, { type: i1.NgControl, decorators: [{
|
|
514
|
-
type: Self
|
|
515
|
-
}, {
|
|
516
|
-
type: Optional
|
|
517
|
-
}, {
|
|
518
|
-
type: Inject,
|
|
519
|
-
args: [NgControl]
|
|
520
|
-
}] }];
|
|
521
|
-
}, propDecorators: { controlId: [{
|
|
522
|
-
type: Input,
|
|
523
|
-
args: ['rxapControlHideShow']
|
|
524
|
-
}] } });
|
|
525
|
-
class ControlHideShowDirectiveModule {
|
|
526
|
-
}
|
|
527
|
-
ControlHideShowDirectiveModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: ControlHideShowDirectiveModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
528
|
-
ControlHideShowDirectiveModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.2", ngImport: i0, type: ControlHideShowDirectiveModule, declarations: [ControlHideShowDirective], exports: [ControlHideShowDirective] });
|
|
529
|
-
ControlHideShowDirectiveModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: ControlHideShowDirectiveModule });
|
|
530
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: ControlHideShowDirectiveModule, decorators: [{
|
|
531
|
-
type: NgModule,
|
|
532
|
-
args: [{
|
|
533
|
-
declarations: [ControlHideShowDirective],
|
|
534
|
-
exports: [ControlHideShowDirective]
|
|
535
|
-
}]
|
|
536
|
-
}] });
|
|
537
|
-
|
|
538
|
-
let InputSelectOptionsDirective = class InputSelectOptionsDirective {
|
|
539
|
-
constructor(template, dataSourceLoader, viewContainerRef, injector, cdr,
|
|
540
|
-
// The ngControl could be unknown on construction
|
|
541
|
-
// bc it is available after the content is init
|
|
542
|
-
ngControl = null, matFormField = null) {
|
|
543
|
-
this.template = template;
|
|
544
|
-
this.dataSourceLoader = dataSourceLoader;
|
|
545
|
-
this.viewContainerRef = viewContainerRef;
|
|
546
|
-
this.injector = injector;
|
|
547
|
-
this.cdr = cdr;
|
|
548
|
-
this.ngControl = ngControl;
|
|
549
|
-
this.matFormField = matFormField;
|
|
550
|
-
this.viewer = { id: '[rxapInputSelectOptions]' };
|
|
551
|
-
this.subscription = new Subscription();
|
|
552
|
-
this.options = null;
|
|
553
|
-
/**
|
|
554
|
-
* This flag is used to prevent the setValue is called for each refresh
|
|
555
|
-
* of the options list. This is needed because the setValue method will
|
|
556
|
-
* trigger a new refresh of the options list. This results in an endless
|
|
557
|
-
* call stack. This flag is set to true if the setValue method is called
|
|
558
|
-
* once.
|
|
559
|
-
*/
|
|
560
|
-
this.isAutocompleteToDisplayTriggered = false;
|
|
561
|
-
}
|
|
562
|
-
ngAfterViewInit() {
|
|
563
|
-
var _b, _c, _d;
|
|
564
|
-
var _a;
|
|
565
|
-
this.extractOptionsDatasource();
|
|
566
|
-
this.viewer = {
|
|
567
|
-
id: '[rxapInputSelectOptions]' + this.control.controlId,
|
|
568
|
-
viewChange: ((_b = this.settings) === null || _b === void 0 ? void 0 : _b.loadOnce) ? EMPTY : this.control.value$.pipe(throttleTime(1000), distinctUntilChanged((a, b) => equals(a, b)), map(value => {
|
|
569
|
-
var _b;
|
|
570
|
-
if ((_b = this.settings) === null || _b === void 0 ? void 0 : _b.ignoreSelectedValue) {
|
|
571
|
-
return {};
|
|
572
|
-
}
|
|
573
|
-
return value;
|
|
574
|
-
})),
|
|
575
|
-
control: this.control,
|
|
576
|
-
};
|
|
577
|
-
if (this.matAutocomplete) {
|
|
578
|
-
this.matAutocomplete.displayWith = this.toDisplay.bind(this);
|
|
579
|
-
(_c = this.settings) !== null && _c !== void 0 ? _c : (this.settings = {});
|
|
580
|
-
(_d = (_a = this.settings).filteredOptions) !== null && _d !== void 0 ? _d : (_a.filteredOptions = true);
|
|
581
|
-
}
|
|
582
|
-
this.loadOptions();
|
|
583
|
-
}
|
|
584
|
-
toDisplay(value) {
|
|
585
|
-
var _b, _c, _d;
|
|
586
|
-
if (!value) {
|
|
587
|
-
return '';
|
|
588
|
-
}
|
|
589
|
-
return (_d = (_c = (_b = this.options) === null || _b === void 0 ? void 0 : _b.find((option) => option.value === value)) === null || _c === void 0 ? void 0 : _c.display) !== null && _d !== void 0 ? _d : (isDevMode() ? 'to display error' : '');
|
|
590
|
-
}
|
|
591
|
-
ngOnDestroy() {
|
|
592
|
-
var _b;
|
|
593
|
-
(_b = this.subscription) === null || _b === void 0 ? void 0 : _b.unsubscribe();
|
|
594
|
-
}
|
|
595
|
-
loadOptions(dataSource = this.dataSource) {
|
|
596
|
-
this.subscription.add(dataSource.connect(this.viewer).pipe(switchMap(options => {
|
|
597
|
-
var _b;
|
|
598
|
-
if ((_b = this.settings) === null || _b === void 0 ? void 0 : _b.filteredOptions) {
|
|
599
|
-
return this.control.value$.pipe(map(controlValue => {
|
|
600
|
-
if (typeof controlValue === 'string' && controlValue) {
|
|
601
|
-
controlValue = controlValue.toLowerCase();
|
|
602
|
-
if (Array.isArray(options)) {
|
|
603
|
-
return options.filter(option => option.display.toLowerCase().includes(controlValue));
|
|
604
|
-
}
|
|
605
|
-
else {
|
|
606
|
-
return Object.entries(options)
|
|
607
|
-
.filter(([value, display]) => typeof display === 'string' && display.toLowerCase().includes(controlValue))
|
|
608
|
-
.map(([value, display]) => ({ value, display }));
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
return options;
|
|
612
|
-
}));
|
|
613
|
-
}
|
|
614
|
-
return of(options);
|
|
615
|
-
}), tap(options => this.renderTemplate(this.options = options)), tap(() => {
|
|
616
|
-
var _b, _c, _d, _e;
|
|
617
|
-
if (this.matAutocomplete && !this.isAutocompleteToDisplayTriggered) {
|
|
618
|
-
this.isAutocompleteToDisplayTriggered = true;
|
|
619
|
-
// trigger a change detection after the options are rendered
|
|
620
|
-
// this is needed to trigger the mat-autocomplete options to display function
|
|
621
|
-
(_c = (_b = this.ngControl) === null || _b === void 0 ? void 0 : _b.control) === null || _c === void 0 ? void 0 : _c.setValue((_e = (_d = this.ngControl) === null || _d === void 0 ? void 0 : _d.control) === null || _e === void 0 ? void 0 : _e.value);
|
|
622
|
-
}
|
|
623
|
-
})).subscribe());
|
|
624
|
-
}
|
|
625
|
-
renderTemplate(options = this.options) {
|
|
626
|
-
this.viewContainerRef.clear();
|
|
627
|
-
if (options) {
|
|
628
|
-
if (!Array.isArray(options)) {
|
|
629
|
-
for (const [value, display] of Object.entries(options)) {
|
|
630
|
-
this.viewContainerRef.createEmbeddedView(this.template, { $implicit: { value, display } });
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
else {
|
|
634
|
-
for (const option of options) {
|
|
635
|
-
this.viewContainerRef.createEmbeddedView(this.template, { $implicit: option });
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
else {
|
|
640
|
-
if (isDevMode()) {
|
|
641
|
-
console.warn(`The options for the control ${this.control.fullControlPath} is empty/null/undefined!`);
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
this.cdr.detectChanges();
|
|
645
|
-
}
|
|
646
|
-
};
|
|
647
|
-
InputSelectOptionsDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", 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 });
|
|
648
|
-
InputSelectOptionsDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: InputSelectOptionsDirective, selector: "[rxapInputSelectOptions]", inputs: { viewer: ["rxapInputSelectOptionsViewer", "viewer"], metadata: ["rxapInputSelectOptionsMetadata", "metadata"], matAutocomplete: ["rxapInputSelectOptionsMatAutocomplete", "matAutocomplete"] }, ngImport: i0 });
|
|
649
|
-
__decorate([
|
|
650
|
-
Required,
|
|
651
|
-
__metadata("design:type", RxapFormControl)
|
|
652
|
-
], InputSelectOptionsDirective.prototype, "control", void 0);
|
|
653
|
-
__decorate([
|
|
654
|
-
Required,
|
|
655
|
-
__metadata("design:type", BaseDataSource)
|
|
656
|
-
], InputSelectOptionsDirective.prototype, "dataSource", void 0);
|
|
657
|
-
InputSelectOptionsDirective = __decorate([
|
|
658
|
-
Mixin(ExtractOptionsDataSourceMixin),
|
|
659
|
-
__metadata("design:paramtypes", [TemplateRef,
|
|
660
|
-
DataSourceLoader,
|
|
661
|
-
ViewContainerRef,
|
|
662
|
-
Injector,
|
|
663
|
-
ChangeDetectorRef, Object, Object])
|
|
664
|
-
], InputSelectOptionsDirective);
|
|
665
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: InputSelectOptionsDirective, decorators: [{
|
|
666
|
-
type: Directive,
|
|
667
|
-
args: [{
|
|
668
|
-
selector: '[rxapInputSelectOptions]'
|
|
669
|
-
}]
|
|
670
|
-
}], ctorParameters: function () {
|
|
671
|
-
return [{ type: i0.TemplateRef, decorators: [{
|
|
672
|
-
type: Inject,
|
|
673
|
-
args: [TemplateRef]
|
|
674
|
-
}] }, { type: i1$1.DataSourceLoader, decorators: [{
|
|
675
|
-
type: Inject,
|
|
676
|
-
args: [DataSourceLoader]
|
|
677
|
-
}] }, { type: i0.ViewContainerRef, decorators: [{
|
|
678
|
-
type: Inject,
|
|
679
|
-
args: [ViewContainerRef]
|
|
680
|
-
}] }, { type: i0.Injector, decorators: [{
|
|
681
|
-
type: Inject,
|
|
682
|
-
args: [INJECTOR]
|
|
683
|
-
}] }, { type: i0.ChangeDetectorRef, decorators: [{
|
|
684
|
-
type: Inject,
|
|
685
|
-
args: [ChangeDetectorRef]
|
|
686
|
-
}] }, { type: i1.NgControl, decorators: [{
|
|
687
|
-
type: Optional
|
|
688
|
-
}, {
|
|
689
|
-
type: Inject,
|
|
690
|
-
args: [NgControl]
|
|
691
|
-
}] }, { type: i3.MatFormField, decorators: [{
|
|
692
|
-
type: Optional
|
|
693
|
-
}, {
|
|
694
|
-
type: Inject,
|
|
695
|
-
args: [MAT_FORM_FIELD]
|
|
696
|
-
}] }];
|
|
697
|
-
}, propDecorators: { viewer: [{
|
|
698
|
-
type: Input,
|
|
699
|
-
args: ['rxapInputSelectOptionsViewer']
|
|
700
|
-
}], metadata: [{
|
|
701
|
-
type: Input,
|
|
702
|
-
args: ['rxapInputSelectOptionsMetadata']
|
|
703
|
-
}], matAutocomplete: [{
|
|
704
|
-
type: Input,
|
|
705
|
-
args: ['rxapInputSelectOptionsMatAutocomplete']
|
|
706
|
-
}], control: [], dataSource: [] } });
|
|
707
|
-
class InputSelectOptionsDirectiveModule {
|
|
708
|
-
}
|
|
709
|
-
InputSelectOptionsDirectiveModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: InputSelectOptionsDirectiveModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
710
|
-
InputSelectOptionsDirectiveModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.2", ngImport: i0, type: InputSelectOptionsDirectiveModule, declarations: [InputSelectOptionsDirective], exports: [InputSelectOptionsDirective] });
|
|
711
|
-
InputSelectOptionsDirectiveModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: InputSelectOptionsDirectiveModule });
|
|
712
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: InputSelectOptionsDirectiveModule, decorators: [{
|
|
713
|
-
type: NgModule,
|
|
714
|
-
args: [{
|
|
715
|
-
declarations: [InputSelectOptionsDirective],
|
|
716
|
-
exports: [InputSelectOptionsDirective]
|
|
717
|
-
}]
|
|
718
|
-
}] });
|
|
719
|
-
|
|
720
|
-
class FormSystemDirectivesModule {
|
|
721
|
-
}
|
|
722
|
-
FormSystemDirectivesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormSystemDirectivesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
723
|
-
FormSystemDirectivesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.2", ngImport: i0, type: FormSystemDirectivesModule, exports: [InputSelectOptionsDirectiveModule,
|
|
724
|
-
ControlHideShowDirectiveModule] });
|
|
725
|
-
FormSystemDirectivesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormSystemDirectivesModule, imports: [InputSelectOptionsDirectiveModule,
|
|
726
|
-
ControlHideShowDirectiveModule] });
|
|
727
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: FormSystemDirectivesModule, decorators: [{
|
|
728
|
-
type: NgModule,
|
|
729
|
-
args: [{
|
|
730
|
-
exports: [
|
|
731
|
-
InputSelectOptionsDirectiveModule,
|
|
732
|
-
ControlHideShowDirectiveModule
|
|
733
|
-
]
|
|
734
|
-
}]
|
|
735
|
-
}] });
|
|
736
|
-
|
|
737
|
-
class IsEqualToDirective {
|
|
738
|
-
set equalTo(value) {
|
|
739
|
-
this._equalTo = value;
|
|
740
|
-
if (this._onChange) {
|
|
741
|
-
this._onChange();
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
validate(control) {
|
|
745
|
-
if (this._equalTo === null || this._equalTo === control.value) {
|
|
746
|
-
return null;
|
|
747
|
-
}
|
|
748
|
-
return { isEqualTo: { value: this._equalTo, actualValue: control.value } };
|
|
749
|
-
}
|
|
750
|
-
/**
|
|
751
|
-
* @description
|
|
752
|
-
* Registers a callback function to call when the validator inputs change.
|
|
753
|
-
*
|
|
754
|
-
* @param fn The callback function
|
|
755
|
-
*/
|
|
756
|
-
registerOnValidatorChange(fn) {
|
|
757
|
-
this._onChange = fn;
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
IsEqualToDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: IsEqualToDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
761
|
-
IsEqualToDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: IsEqualToDirective, selector: "[rxapIsEqualTo]", inputs: { equalTo: ["rxapIsEqualTo", "equalTo"] }, providers: [
|
|
762
|
-
{
|
|
763
|
-
provide: NG_VALIDATORS,
|
|
764
|
-
multi: true,
|
|
765
|
-
useExisting: forwardRef(() => IsEqualToDirective)
|
|
766
|
-
}
|
|
767
|
-
], ngImport: i0 });
|
|
768
|
-
__decorate([
|
|
769
|
-
Required,
|
|
770
|
-
__metadata("design:type", Object),
|
|
771
|
-
__metadata("design:paramtypes", [Object])
|
|
772
|
-
], IsEqualToDirective.prototype, "equalTo", null);
|
|
773
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: IsEqualToDirective, decorators: [{
|
|
774
|
-
type: Directive,
|
|
775
|
-
args: [{
|
|
776
|
-
selector: '[rxapIsEqualTo]',
|
|
777
|
-
providers: [
|
|
778
|
-
{
|
|
779
|
-
provide: NG_VALIDATORS,
|
|
780
|
-
multi: true,
|
|
781
|
-
useExisting: forwardRef(() => IsEqualToDirective)
|
|
782
|
-
}
|
|
783
|
-
]
|
|
784
|
-
}]
|
|
785
|
-
}], propDecorators: { equalTo: [{
|
|
786
|
-
type: Input,
|
|
787
|
-
args: ['rxapIsEqualTo']
|
|
788
|
-
}] } });
|
|
789
|
-
class IsEqualToDirectiveModule {
|
|
790
|
-
}
|
|
791
|
-
IsEqualToDirectiveModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: IsEqualToDirectiveModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
792
|
-
IsEqualToDirectiveModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.2", ngImport: i0, type: IsEqualToDirectiveModule, declarations: [IsEqualToDirective], exports: [IsEqualToDirective] });
|
|
793
|
-
IsEqualToDirectiveModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: IsEqualToDirectiveModule });
|
|
794
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: IsEqualToDirectiveModule, decorators: [{
|
|
795
|
-
type: NgModule,
|
|
796
|
-
args: [{
|
|
797
|
-
declarations: [IsEqualToDirective],
|
|
798
|
-
exports: [IsEqualToDirective]
|
|
799
|
-
}]
|
|
800
|
-
}] });
|
|
801
|
-
|
|
802
|
-
var IsSelectableValueDirective_1;
|
|
803
|
-
let IsSelectableValueDirective = IsSelectableValueDirective_1 = class IsSelectableValueDirective {
|
|
804
|
-
constructor(dataSourceLoader, injector) {
|
|
805
|
-
this.dataSourceLoader = dataSourceLoader;
|
|
806
|
-
this.injector = injector;
|
|
807
|
-
this.viewer = { id: '[rxapIsSelectableValue]' };
|
|
808
|
-
}
|
|
809
|
-
validate(control) {
|
|
810
|
-
var _a;
|
|
811
|
-
if (control.value) {
|
|
812
|
-
this.extractOptionsDatasource(control);
|
|
813
|
-
const data = (_a = this.useDataSourceValue) === null || _a === void 0 ? void 0 : _a.lastValue;
|
|
814
|
-
if (data) {
|
|
815
|
-
let options;
|
|
816
|
-
if (Array.isArray(data)) {
|
|
817
|
-
options = data;
|
|
818
|
-
}
|
|
819
|
-
else {
|
|
820
|
-
options = Object.entries(data).map(([value, display]) => ({ value, display }));
|
|
821
|
-
}
|
|
822
|
-
if (!options.some(option => option.value === control.value)) {
|
|
823
|
-
return {
|
|
824
|
-
isSelectableValue: {
|
|
825
|
-
expected: 'Value should be from the list of provided options',
|
|
826
|
-
}
|
|
827
|
-
};
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
else if (isDevMode()) {
|
|
831
|
-
console.warn('The last value from the OptionsDataSource is empty', this);
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
return null;
|
|
835
|
-
}
|
|
836
|
-
};
|
|
837
|
-
IsSelectableValueDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: IsSelectableValueDirective, deps: [{ token: DataSourceLoader }, { token: INJECTOR }], target: i0.ɵɵFactoryTarget.Directive });
|
|
838
|
-
IsSelectableValueDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: IsSelectableValueDirective, selector: "[rxapIsSelectableValue]", inputs: { viewer: "viewer" }, providers: [
|
|
839
|
-
{
|
|
840
|
-
provide: NG_VALIDATORS,
|
|
841
|
-
multi: true,
|
|
842
|
-
useExisting: forwardRef(() => IsSelectableValueDirective_1)
|
|
843
|
-
}
|
|
844
|
-
], ngImport: i0 });
|
|
845
|
-
IsSelectableValueDirective = IsSelectableValueDirective_1 = __decorate([
|
|
846
|
-
Mixin(ExtractOptionsDataSourceMixin),
|
|
847
|
-
__metadata("design:paramtypes", [DataSourceLoader,
|
|
848
|
-
Injector])
|
|
849
|
-
], IsSelectableValueDirective);
|
|
850
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: IsSelectableValueDirective, decorators: [{
|
|
851
|
-
type: Directive,
|
|
852
|
-
args: [{
|
|
853
|
-
selector: '[rxapIsSelectableValue]',
|
|
854
|
-
providers: [
|
|
855
|
-
{
|
|
856
|
-
provide: NG_VALIDATORS,
|
|
857
|
-
multi: true,
|
|
858
|
-
useExisting: forwardRef(() => IsSelectableValueDirective)
|
|
859
|
-
}
|
|
860
|
-
]
|
|
861
|
-
}]
|
|
862
|
-
}], ctorParameters: function () {
|
|
863
|
-
return [{ type: i1$1.DataSourceLoader, decorators: [{
|
|
864
|
-
type: Inject,
|
|
865
|
-
args: [DataSourceLoader]
|
|
866
|
-
}] }, { type: i0.Injector, decorators: [{
|
|
867
|
-
type: Inject,
|
|
868
|
-
args: [INJECTOR]
|
|
869
|
-
}] }];
|
|
870
|
-
}, propDecorators: { viewer: [{
|
|
871
|
-
type: Input
|
|
872
|
-
}] } });
|
|
873
|
-
class IsSelectableValueDirectiveModule {
|
|
874
|
-
}
|
|
875
|
-
IsSelectableValueDirectiveModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: IsSelectableValueDirectiveModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
876
|
-
IsSelectableValueDirectiveModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.2", ngImport: i0, type: IsSelectableValueDirectiveModule, declarations: [IsSelectableValueDirective], exports: [IsSelectableValueDirective] });
|
|
877
|
-
IsSelectableValueDirectiveModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: IsSelectableValueDirectiveModule });
|
|
878
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: IsSelectableValueDirectiveModule, decorators: [{
|
|
879
|
-
type: NgModule,
|
|
880
|
-
args: [{
|
|
881
|
-
declarations: [IsSelectableValueDirective],
|
|
882
|
-
exports: [IsSelectableValueDirective]
|
|
883
|
-
}]
|
|
884
|
-
}] });
|
|
885
|
-
|
|
886
|
-
// endregion
|
|
887
|
-
|
|
888
|
-
/**
|
|
889
|
-
* Generated bundle index. Do not edit.
|
|
890
|
-
*/
|
|
891
|
-
|
|
892
|
-
export { ComposeOptionsTransformers, ControlDataSource, ControlHideShowDirective, ControlHideShowDirectiveModule, DATA_SOURCE_NAME, ExtractControlFromParentMixin, ExtractControlMixin, ExtractDataSourcesMixin, ExtractFormDefinitionMixin, ExtractOptionsDataSourceMixin, FormSystemControlDirective, FormSystemDirectivesModule, FormSystemMetadataKeys, FormSystemModule, InputSelectOptionsDirective, InputSelectOptionsDirectiveModule, IsEqualToDirective, IsEqualToDirectiveModule, IsSelectableValueDirective, IsSelectableValueDirectiveModule, 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 };
|
|
893
|
-
//# sourceMappingURL=rxap-form-system.mjs.map
|