@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
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { Directive, TemplateRef, Inject, ViewContainerRef, Input, Injector, INJECTOR, Optional, ChangeDetectorRef, NgModule, isDevMode } from '@angular/core';
|
|
3
|
-
import { NgControl } from '@angular/forms';
|
|
4
|
-
import { DataSourceLoader, BaseDataSource, PipeDataSource } from '@rxap/data-source';
|
|
5
|
-
import { RxapFormControl } from '@rxap/forms';
|
|
6
|
-
import { Required } from '@rxap/utilities';
|
|
7
|
-
import { Mixin } from '@rxap/mixin';
|
|
8
|
-
import { Subscription } from 'rxjs';
|
|
9
|
-
import { tap, map } from 'rxjs/operators';
|
|
10
|
-
import { ExtractDataSourcesMixin } from '../mixins/extract-data-sources.mixin';
|
|
11
|
-
import { ExtractFormDefinitionMixin } from '../mixins/extract-form-definition.mixin';
|
|
12
|
-
import { UseDataSource } from '../decorators/use-data-source';
|
|
13
|
-
import { MAT_FORM_FIELD } from '@angular/material/form-field';
|
|
14
|
-
import { MatAutocomplete } from '@angular/material/autocomplete';
|
|
15
|
-
import * as i0 from "@angular/core";
|
|
16
|
-
import * as i1 from "@rxap/data-source";
|
|
17
|
-
import * as i2 from "@angular/forms";
|
|
18
|
-
import * as i3 from "@angular/material/form-field";
|
|
19
|
-
export const DATA_SOURCE_NAME = 'options';
|
|
20
|
-
export function ComposeOptionsTransformers(...fnc) {
|
|
21
|
-
return base => fnc.reduce((source, transform) => transform(source), base);
|
|
22
|
-
}
|
|
23
|
-
export function UseOptionsDataSource(dataSource, settings) {
|
|
24
|
-
return function (target, propertyKey) {
|
|
25
|
-
UseDataSource(dataSource, DATA_SOURCE_NAME, settings)(target, propertyKey);
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
let InputSelectOptionsDirective = class InputSelectOptionsDirective {
|
|
29
|
-
constructor(template, dataSourceLoader, viewContainerRef, injector, cdr,
|
|
30
|
-
// The ngControl could be unknown on construction
|
|
31
|
-
// bc it is available after the content is init
|
|
32
|
-
ngControl = null, matFormField = null) {
|
|
33
|
-
this.template = template;
|
|
34
|
-
this.dataSourceLoader = dataSourceLoader;
|
|
35
|
-
this.viewContainerRef = viewContainerRef;
|
|
36
|
-
this.injector = injector;
|
|
37
|
-
this.cdr = cdr;
|
|
38
|
-
this.ngControl = ngControl;
|
|
39
|
-
this.matFormField = matFormField;
|
|
40
|
-
this.viewer = { id: '[rxapInputSelectOptions]' };
|
|
41
|
-
this.subscription = new Subscription();
|
|
42
|
-
this.options = null;
|
|
43
|
-
}
|
|
44
|
-
ngAfterViewInit() {
|
|
45
|
-
this.extractControl();
|
|
46
|
-
this.extractDatasource();
|
|
47
|
-
this.viewer = {
|
|
48
|
-
id: '[rxapInputSelectOptions]' + this.control.controlId,
|
|
49
|
-
viewChange: this.control.value$.pipe(map(value => {
|
|
50
|
-
var _a;
|
|
51
|
-
if ((_a = this.settings) === null || _a === void 0 ? void 0 : _a.ignoreSelectedValue) {
|
|
52
|
-
return {};
|
|
53
|
-
}
|
|
54
|
-
return value;
|
|
55
|
-
})),
|
|
56
|
-
control: this.control,
|
|
57
|
-
};
|
|
58
|
-
this.loadOptions();
|
|
59
|
-
if (this.matAutocomplete) {
|
|
60
|
-
this.matAutocomplete.displayWith = this.toDisplay.bind(this);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
extractDatasource(control = this.control) {
|
|
64
|
-
const formDefinition = this.extractFormDefinition(control);
|
|
65
|
-
const useDataSourceValueMap = this.extractDataSources(formDefinition, control.controlId);
|
|
66
|
-
if (!useDataSourceValueMap.has(DATA_SOURCE_NAME)) {
|
|
67
|
-
throw new Error(`The data source with the name 'options' is not defined`);
|
|
68
|
-
}
|
|
69
|
-
const useDataSourceValue = useDataSourceValueMap.get(DATA_SOURCE_NAME);
|
|
70
|
-
this.settings = useDataSourceValue.settings;
|
|
71
|
-
let dataSource;
|
|
72
|
-
try {
|
|
73
|
-
dataSource = this.dataSourceLoader.load(useDataSourceValue.dataSource, this.metadata, this.injector);
|
|
74
|
-
}
|
|
75
|
-
catch (e) {
|
|
76
|
-
if (e.name && e.name === 'NullInjectorError') {
|
|
77
|
-
if (isDevMode()) {
|
|
78
|
-
console.error('Cloud not inject the options data source', useDataSourceValue);
|
|
79
|
-
}
|
|
80
|
-
throw new Error('Cloud not inject the options data source:\n' + e.message);
|
|
81
|
-
}
|
|
82
|
-
throw e;
|
|
83
|
-
}
|
|
84
|
-
const settings = useDataSourceValue.settings;
|
|
85
|
-
if (settings === null || settings === void 0 ? void 0 : settings.transformer) {
|
|
86
|
-
dataSource = new PipeDataSource(dataSource, map(settings.transformer));
|
|
87
|
-
}
|
|
88
|
-
return this.dataSource = dataSource;
|
|
89
|
-
}
|
|
90
|
-
toDisplay(value) {
|
|
91
|
-
var _a, _b, _c;
|
|
92
|
-
if (!value) {
|
|
93
|
-
return '';
|
|
94
|
-
}
|
|
95
|
-
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' : '');
|
|
96
|
-
}
|
|
97
|
-
extractControl(ngControl) {
|
|
98
|
-
var _a, _b, _c, _d;
|
|
99
|
-
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; }
|
|
100
|
-
if (!ngControl) {
|
|
101
|
-
throw new Error('The ngControl is not defined!');
|
|
102
|
-
}
|
|
103
|
-
this.ngControl = ngControl;
|
|
104
|
-
const control = this.ngControl.control;
|
|
105
|
-
if (!(control instanceof RxapFormControl)) {
|
|
106
|
-
throw new Error('Control is not a RxapFormControl!');
|
|
107
|
-
}
|
|
108
|
-
return this.control = control;
|
|
109
|
-
}
|
|
110
|
-
ngOnDestroy() {
|
|
111
|
-
var _a;
|
|
112
|
-
(_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
113
|
-
}
|
|
114
|
-
loadOptions(dataSource = this.dataSource) {
|
|
115
|
-
this.subscription.add(dataSource.connect(this.viewer).pipe(tap(options => this.renderTemplate(this.options = options))).subscribe());
|
|
116
|
-
}
|
|
117
|
-
renderTemplate(options = this.options) {
|
|
118
|
-
this.viewContainerRef.clear();
|
|
119
|
-
if (options) {
|
|
120
|
-
if (!Array.isArray(options)) {
|
|
121
|
-
for (const [value, display] of Object.entries(options)) {
|
|
122
|
-
this.viewContainerRef.createEmbeddedView(this.template, { $implicit: { value, display } });
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
for (const option of options) {
|
|
127
|
-
this.viewContainerRef.createEmbeddedView(this.template, { $implicit: option });
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
if (isDevMode()) {
|
|
133
|
-
console.warn(`The options for the control ${this.control.fullControlPath} is empty/null/undefined!`);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
this.cdr.detectChanges();
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
InputSelectOptionsDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", 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 });
|
|
140
|
-
InputSelectOptionsDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: InputSelectOptionsDirective, selector: "[rxapInputSelectOptions]", inputs: { viewer: ["rxapInputSelectOptionsViewer", "viewer"], metadata: ["rxapInputSelectOptionsMetadata", "metadata"], matAutocomplete: ["rxapInputSelectOptionsMatAutocomplete", "matAutocomplete"] }, ngImport: i0 });
|
|
141
|
-
__decorate([
|
|
142
|
-
Required,
|
|
143
|
-
__metadata("design:type", RxapFormControl)
|
|
144
|
-
], InputSelectOptionsDirective.prototype, "control", void 0);
|
|
145
|
-
__decorate([
|
|
146
|
-
Required,
|
|
147
|
-
__metadata("design:type", BaseDataSource)
|
|
148
|
-
], InputSelectOptionsDirective.prototype, "dataSource", void 0);
|
|
149
|
-
InputSelectOptionsDirective = __decorate([
|
|
150
|
-
Mixin(ExtractFormDefinitionMixin, ExtractDataSourcesMixin),
|
|
151
|
-
__metadata("design:paramtypes", [TemplateRef,
|
|
152
|
-
DataSourceLoader,
|
|
153
|
-
ViewContainerRef,
|
|
154
|
-
Injector,
|
|
155
|
-
ChangeDetectorRef, Object, Object])
|
|
156
|
-
], InputSelectOptionsDirective);
|
|
157
|
-
export { InputSelectOptionsDirective };
|
|
158
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: InputSelectOptionsDirective, decorators: [{
|
|
159
|
-
type: Directive,
|
|
160
|
-
args: [{
|
|
161
|
-
selector: '[rxapInputSelectOptions]'
|
|
162
|
-
}]
|
|
163
|
-
}], ctorParameters: function () { return [{ type: i0.TemplateRef, decorators: [{
|
|
164
|
-
type: Inject,
|
|
165
|
-
args: [TemplateRef]
|
|
166
|
-
}] }, { type: i1.DataSourceLoader, decorators: [{
|
|
167
|
-
type: Inject,
|
|
168
|
-
args: [DataSourceLoader]
|
|
169
|
-
}] }, { type: i0.ViewContainerRef, decorators: [{
|
|
170
|
-
type: Inject,
|
|
171
|
-
args: [ViewContainerRef]
|
|
172
|
-
}] }, { type: i0.Injector, decorators: [{
|
|
173
|
-
type: Inject,
|
|
174
|
-
args: [INJECTOR]
|
|
175
|
-
}] }, { type: i0.ChangeDetectorRef, decorators: [{
|
|
176
|
-
type: Inject,
|
|
177
|
-
args: [ChangeDetectorRef]
|
|
178
|
-
}] }, { type: i2.NgControl, decorators: [{
|
|
179
|
-
type: Optional
|
|
180
|
-
}, {
|
|
181
|
-
type: Inject,
|
|
182
|
-
args: [NgControl]
|
|
183
|
-
}] }, { type: i3.MatFormField, decorators: [{
|
|
184
|
-
type: Optional
|
|
185
|
-
}, {
|
|
186
|
-
type: Inject,
|
|
187
|
-
args: [MAT_FORM_FIELD]
|
|
188
|
-
}] }]; }, propDecorators: { viewer: [{
|
|
189
|
-
type: Input,
|
|
190
|
-
args: ['rxapInputSelectOptionsViewer']
|
|
191
|
-
}], metadata: [{
|
|
192
|
-
type: Input,
|
|
193
|
-
args: ['rxapInputSelectOptionsMetadata']
|
|
194
|
-
}], matAutocomplete: [{
|
|
195
|
-
type: Input,
|
|
196
|
-
args: ['rxapInputSelectOptionsMatAutocomplete']
|
|
197
|
-
}], control: [], dataSource: [] } });
|
|
198
|
-
export class InputSelectOptionsDirectiveModule {
|
|
199
|
-
}
|
|
200
|
-
InputSelectOptionsDirectiveModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: InputSelectOptionsDirectiveModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
201
|
-
InputSelectOptionsDirectiveModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: InputSelectOptionsDirectiveModule, declarations: [InputSelectOptionsDirective], exports: [InputSelectOptionsDirective] });
|
|
202
|
-
InputSelectOptionsDirectiveModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: InputSelectOptionsDirectiveModule });
|
|
203
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: InputSelectOptionsDirectiveModule, decorators: [{
|
|
204
|
-
type: NgModule,
|
|
205
|
-
args: [{
|
|
206
|
-
declarations: [InputSelectOptionsDirective],
|
|
207
|
-
exports: [InputSelectOptionsDirective]
|
|
208
|
-
}]
|
|
209
|
-
}] });
|
|
210
|
-
//# sourceMappingURL=input-select-options.directive.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"input-select-options.directive.js","sourceRoot":"","sources":["../../../../../../libs/form-system/src/lib/directives/input-select-options.directive.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,SAAS,EACT,WAAW,EAEX,MAAM,EACN,gBAAgB,EAChB,K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;oBACT,QAAQ,EAAE,0BAA0B;iBACrC;;0BAyBI,MAAM;2BAAC,WAAW;;0BAElB,MAAM;2BAAC,gBAAgB;;0BAEvB,MAAM;2BAAC,gBAAgB;;0BAEvB,MAAM;2BAAC,QAAQ;;0BAEf,MAAM;2BAAC,iBAAiB;;0BAIxB,QAAQ;;0BACR,MAAM;2BAAC,SAAS;;0BAEhB,QAAQ;;0BACR,MAAM;2BAAC,cAAc;4CArCjB,MAAM;sBADZ,KAAK;uBAAC,8BAA8B;gBAI9B,QAAQ;sBADd,KAAK;uBAAC,gCAAgC;gBAIhC,eAAe;sBADrB,KAAK;uBAAC,uCAAuC;gBAMpC,OAAO,MAGP,UAAU;AA+JtB,MAAM,OAAO,iCAAiC;;+HAAjC,iCAAiC;gIAAjC,iCAAiC,iBAhLjC,2BAA2B,aAA3B,2BAA2B;gIAgL3B,iCAAiC;4FAAjC,iCAAiC;kBAJ7C,QAAQ;mBAAC;oBACR,YAAY,EAAE,CAAE,2BAA2B,CAAE;oBAC7C,OAAO,EAAO,CAAE,2BAA2B,CAAE;iBAC9C","sourcesContent":["import {\n Directive,\n TemplateRef,\n OnInit,\n Inject,\n ViewContainerRef,\n Input,\n OnDestroy,\n Injector,\n INJECTOR,\n Optional,\n ChangeDetectorRef,\n NgModule,\n isDevMode,\n AfterViewInit\n} from '@angular/core';\nimport { NgControl } from '@angular/forms';\nimport {\n DataSourceLoader,\n BaseDataSource,\n BaseDataSourceViewer,\n BaseDataSourceMetadata,\n PipeDataSource\n} from '@rxap/data-source';\nimport { RxapFormControl } from '@rxap/forms';\nimport {\n ControlOptions,\n ControlOption,\n Required\n} from '@rxap/utilities';\nimport { Mixin } from '@rxap/mixin';\nimport { Subscription } from 'rxjs';\nimport {\n tap,\n map\n} from 'rxjs/operators';\nimport { ExtractDataSourcesMixin } from '../mixins/extract-data-sources.mixin';\nimport { ExtractFormDefinitionMixin } from '../mixins/extract-form-definition.mixin';\nimport {\n UseDataSource,\n UseDataSourceSettings\n} from '../decorators/use-data-source';\nimport { IdOrInstanceOrToken } from '@rxap/definition';\nimport {\n MAT_FORM_FIELD,\n MatFormField\n} from '@angular/material/form-field';\nimport { MatAutocomplete } from '@angular/material/autocomplete';\n\nexport interface InputSelectOptionsTemplateContext {\n $implicit: ControlOption;\n}\n\nexport interface InputSelectOptionsSettings<Source> extends UseDataSourceSettings<Source, ControlOptions | Record<string, any>> {\n /**\n * true - the selected value is not send to the data source with the viewChange event.\n * Instead an empty object {} is send to trigger a data source refresh.\n *\n * The OpenApiDataSource expects a Paramters Object in the viewChange event. This\n * can couse issue if the select value object as a property that is also a parameter for\n * the open-api operation. For instaed the select object has the property company and\n * the open-api operation has a query parameter company. Then the BuildOptions method\n * in the OpenApiDataSource would create a HttpParams object with the param company and the\n * value from the select object property company. This will result in unpredictable behaviors.\n */\n ignoreSelectedValue?: boolean;\n}\n\n\nexport const DATA_SOURCE_NAME = 'options';\n\nexport function ComposeOptionsTransformers(...fnc: Array<(value: any) => any>): (value: any) => any {\n return base => fnc.reduce((source, transform) => transform(source), base);\n}\n\n// tslint:disable-next-line:max-line-length\nexport function UseOptionsDataSource<Source>(\n dataSource: IdOrInstanceOrToken<BaseDataSource<Source>>,\n settings?: InputSelectOptionsSettings<Source>\n): (\n target: any,\n propertyKey: string\n) => any;\nexport function UseOptionsDataSource(\n dataSource: IdOrInstanceOrToken<BaseDataSource>,\n settings?: InputSelectOptionsSettings<ControlOptions>\n) {\n return function(target: any, propertyKey: string) {\n UseDataSource(dataSource, DATA_SOURCE_NAME, settings)(target, propertyKey);\n };\n}\n\nexport interface InputSelectOptionsDirective extends OnInit,\n ExtractFormDefinitionMixin,\n ExtractDataSourcesMixin {}\n\n@Mixin(ExtractFormDefinitionMixin, ExtractDataSourcesMixin)\n@Directive({\n selector: '[rxapInputSelectOptions]'\n})\nexport class InputSelectOptionsDirective implements OnDestroy, AfterViewInit {\n\n @Input('rxapInputSelectOptionsViewer')\n public viewer: BaseDataSourceViewer = { id: '[rxapInputSelectOptions]' };\n\n @Input('rxapInputSelectOptionsMetadata')\n public metadata?: BaseDataSourceMetadata;\n\n @Input('rxapInputSelectOptionsMatAutocomplete')\n public matAutocomplete?: MatAutocomplete;\n\n protected readonly subscription = new Subscription();\n\n @Required\n protected control!: RxapFormControl;\n\n @Required\n protected dataSource!: BaseDataSource<ControlOptions | Record<string, any>>;\n\n protected options: ControlOptions | Record<string, any> | null = null;\n\n protected settings!: InputSelectOptionsSettings<any>;\n\n constructor(\n @Inject(TemplateRef)\n protected readonly template: TemplateRef<InputSelectOptionsTemplateContext>,\n @Inject(DataSourceLoader)\n protected readonly dataSourceLoader: DataSourceLoader,\n @Inject(ViewContainerRef)\n protected readonly viewContainerRef: ViewContainerRef,\n @Inject(INJECTOR)\n protected readonly injector: Injector,\n @Inject(ChangeDetectorRef)\n protected readonly cdr: ChangeDetectorRef,\n // The ngControl could be unknown on construction\n // bc it is available after the content is init\n @Optional()\n @Inject(NgControl)\n protected ngControl: NgControl | null = null,\n @Optional()\n @Inject(MAT_FORM_FIELD)\n protected matFormField: MatFormField | null = null,\n ) { }\n\n public ngAfterViewInit() {\n this.extractControl();\n this.extractDatasource();\n this.viewer = {\n id: '[rxapInputSelectOptions]' + this.control.controlId,\n viewChange: this.control.value$.pipe(\n map(value => {\n if (this.settings?.ignoreSelectedValue) {\n return {}\n }\n return value;\n })\n ),\n control: this.control,\n }\n this.loadOptions();\n if (this.matAutocomplete) {\n this.matAutocomplete.displayWith = this.toDisplay.bind(this);\n }\n }\n\n protected extractDatasource(control: RxapFormControl = this.control): BaseDataSource<ControlOptions | Record<string, any>> {\n const formDefinition = this.extractFormDefinition(control);\n\n const useDataSourceValueMap = this.extractDataSources(formDefinition, control.controlId);\n\n if (!useDataSourceValueMap.has(DATA_SOURCE_NAME)) {\n throw new Error(`The data source with the name 'options' is not defined`);\n }\n\n const useDataSourceValue = useDataSourceValueMap.get(DATA_SOURCE_NAME)!;\n\n this.settings = useDataSourceValue.settings as any;\n\n let dataSource: BaseDataSource;\n\n try {\n\n dataSource = this.dataSourceLoader.load(\n useDataSourceValue.dataSource,\n this.metadata,\n this.injector\n );\n\n } catch (e) {\n\n if (e.name && e.name === 'NullInjectorError') {\n if (isDevMode()) {\n console.error('Cloud not inject the options data source', useDataSourceValue);\n }\n throw new Error('Cloud not inject the options data source:\\n' + e.message);\n }\n\n throw e;\n\n }\n\n const settings = useDataSourceValue.settings;\n\n if (settings?.transformer) {\n dataSource = new PipeDataSource(dataSource, map(settings.transformer));\n }\n\n return this.dataSource = dataSource;\n }\n\n public toDisplay(value: any): string {\n if (!value) {\n return '';\n }\n return this.options?.find((option: any) => option.value === value)?.display ?? (isDevMode() ? 'to display error' : '');\n }\n\n protected extractControl(ngControl: NgControl | null = this.ngControl ?? this.matFormField?._control?.ngControl ?? null): RxapFormControl {\n\n if (!ngControl) {\n throw new Error('The ngControl is not defined!');\n }\n\n this.ngControl = ngControl;\n\n const control = this.ngControl.control;\n\n if (!(control instanceof RxapFormControl)) {\n throw new Error('Control is not a RxapFormControl!');\n }\n\n return this.control = control;\n }\n\n public ngOnDestroy() {\n this.subscription?.unsubscribe();\n }\n\n private loadOptions(dataSource: BaseDataSource<ControlOptions | Record<string, any>> = this.dataSource) {\n this.subscription.add(dataSource.connect(this.viewer).pipe(\n tap(options => this.renderTemplate(this.options = options))\n ).subscribe());\n }\n\n protected renderTemplate(options: ControlOptions | Record<string, any> | null = this.options) {\n this.viewContainerRef.clear();\n\n if (options) {\n if (!Array.isArray(options)) {\n\n for (const [ value, display ] of Object.entries(options)) {\n this.viewContainerRef.createEmbeddedView(this.template, { $implicit: { value, display } });\n }\n\n } else {\n\n for (const option of options) {\n this.viewContainerRef.createEmbeddedView(this.template, { $implicit: option });\n }\n\n }\n } else {\n if (isDevMode()) {\n console.warn(`The options for the control ${this.control.fullControlPath} is empty/null/undefined!`);\n }\n }\n\n this.cdr.detectChanges();\n }\n\n}\n\n@NgModule({\n declarations: [ InputSelectOptionsDirective ],\n exports: [ InputSelectOptionsDirective ]\n})\nexport class InputSelectOptionsDirectiveModule {}\n"]}
|
package/esm2015/lib/error.js
DELETED
package/esm2015/lib/error.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../../../libs/form-system/src/lib/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,OAAO,mBAAoB,SAAQ,SAAS;IAEhD,YAAY,OAAe,EAAE,IAAY,EAAE,SAAkB;QAC3D,KAAK,CAAC,mBAAmB,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IACvD,CAAC;CAEF","sourcesContent":["import { RxapError } from '@rxap/utilities';\n\nexport class RxapFormSystemError extends RxapError {\n\n constructor(message: string, code: string, className?: string) {\n super('@rxap/form-system', message, code, className);\n }\n\n}\n"]}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { Input, Inject, ComponentFactoryResolver, ViewContainerRef, Directive, ComponentRef, INJECTOR, Injector } from '@angular/core';
|
|
3
|
-
import { Required } from '@rxap/utilities';
|
|
4
|
-
import { ControlContainer } from '@angular/forms';
|
|
5
|
-
import { RxapFormSystemError } from './error';
|
|
6
|
-
import { RxapFormControl } from '@rxap/forms';
|
|
7
|
-
import { FormSystemMetadataKeys } from './decorators/metadata-keys';
|
|
8
|
-
import { DataSourceLoader, PipeDataSource } from '@rxap/data-source';
|
|
9
|
-
import { Mixin } from '@rxap/mixin';
|
|
10
|
-
import { ExtractDataSourcesMixin } from './mixins/extract-data-sources.mixin';
|
|
11
|
-
import { map } from 'rxjs/operators';
|
|
12
|
-
import { getMetadata } from '@rxap/utilities/reflect-metadata';
|
|
13
|
-
import * as i0 from "@angular/core";
|
|
14
|
-
import * as i1 from "@angular/forms";
|
|
15
|
-
import * as i2 from "@rxap/data-source";
|
|
16
|
-
let FormSystemControlDirective = class FormSystemControlDirective {
|
|
17
|
-
constructor(parent, cfr, viewContainerRef, dataSourceLoader, injector) {
|
|
18
|
-
this.parent = parent;
|
|
19
|
-
this.cfr = cfr;
|
|
20
|
-
this.viewContainerRef = viewContainerRef;
|
|
21
|
-
this.dataSourceLoader = dataSourceLoader;
|
|
22
|
-
this.injector = injector;
|
|
23
|
-
}
|
|
24
|
-
ngOnInit() {
|
|
25
|
-
this.control = this.extractControl();
|
|
26
|
-
const formDefinition = this.extractFormDefinition();
|
|
27
|
-
this.componentRef = this.createComponent(formDefinition);
|
|
28
|
-
this.setDataSources(formDefinition, this.componentRef.instance);
|
|
29
|
-
this.setComponentProperties(formDefinition, this.componentRef.instance);
|
|
30
|
-
this.viewContainerRef.insert(this.componentRef.hostView);
|
|
31
|
-
}
|
|
32
|
-
registerOnChange(fn) {
|
|
33
|
-
this.componentRef.instance.registerOnChange(fn);
|
|
34
|
-
}
|
|
35
|
-
registerOnTouched(fn) {
|
|
36
|
-
this.componentRef.instance.registerOnTouched(fn);
|
|
37
|
-
}
|
|
38
|
-
writeValue(value) {
|
|
39
|
-
this.componentRef.instance.writeValue(value);
|
|
40
|
-
}
|
|
41
|
-
setDisabledState(isDisabled) {
|
|
42
|
-
if (this.componentRef.instance.setDisabledState) {
|
|
43
|
-
this.componentRef.instance.setDisabledState(isDisabled);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
setDataSources(formDefinition, component) {
|
|
47
|
-
if (!component.setDataSource) {
|
|
48
|
-
throw new RxapFormSystemError('The ControlWithDataSource interface is not implemented for the control component, but the control has defined data sources', '');
|
|
49
|
-
}
|
|
50
|
-
const useDataSourceValueMap = this.extractDataSources(formDefinition, this.controlId);
|
|
51
|
-
for (const [name, useDataSourceValue] of useDataSourceValueMap.entries()) {
|
|
52
|
-
let dataSource = this.dataSourceLoader.load(useDataSourceValue.dataSource);
|
|
53
|
-
const settings = useDataSourceValue.settings;
|
|
54
|
-
if (settings === null || settings === void 0 ? void 0 : settings.transformer) {
|
|
55
|
-
dataSource = new PipeDataSource(dataSource, map(settings.transformer));
|
|
56
|
-
}
|
|
57
|
-
component.setDataSource(name, dataSource, useDataSourceValue.settings);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
setComponentProperties(formDefinition, component) {
|
|
61
|
-
const componentProperties = this.extractComponentProperties(formDefinition);
|
|
62
|
-
for (const [key, value] of Object.entries(componentProperties)) {
|
|
63
|
-
Reflect.set(component, key, value);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
createComponent(formDefinition) {
|
|
67
|
-
const component = this.extractComponent(formDefinition);
|
|
68
|
-
const componentFactory = this.cfr.resolveComponentFactory(component);
|
|
69
|
-
return componentFactory.create(this.injector);
|
|
70
|
-
}
|
|
71
|
-
extractControl() {
|
|
72
|
-
if (!this.parent.control) {
|
|
73
|
-
throw new RxapFormSystemError('The control property of ControlContainer is not defined', '');
|
|
74
|
-
}
|
|
75
|
-
const control = this.parent.control.get(this.controlId);
|
|
76
|
-
if (!control) {
|
|
77
|
-
throw new RxapFormSystemError('Could not find the control instance', '');
|
|
78
|
-
}
|
|
79
|
-
if (!(control instanceof RxapFormControl)) {
|
|
80
|
-
throw new RxapFormSystemError('The extracted control is not a RxapFormControl', '');
|
|
81
|
-
}
|
|
82
|
-
return control;
|
|
83
|
-
}
|
|
84
|
-
extractFormDefinition() {
|
|
85
|
-
const formDefinition = this.control.rxapFormDefinition;
|
|
86
|
-
if (!formDefinition) {
|
|
87
|
-
throw new RxapFormSystemError('Could not find the form definition instance', '');
|
|
88
|
-
}
|
|
89
|
-
return formDefinition;
|
|
90
|
-
}
|
|
91
|
-
extractComponent(formDefinition) {
|
|
92
|
-
const map = getMetadata(FormSystemMetadataKeys.COMPONENTS, Object.getPrototypeOf(formDefinition));
|
|
93
|
-
if (!map) {
|
|
94
|
-
throw new RxapFormSystemError('Could not extract the use component map from the form definition instance', '');
|
|
95
|
-
}
|
|
96
|
-
if (!map.has(this.controlId)) {
|
|
97
|
-
throw new RxapFormSystemError('A use component definition does not exists in the form definition metadata', '');
|
|
98
|
-
}
|
|
99
|
-
return map.get(this.controlId);
|
|
100
|
-
}
|
|
101
|
-
extractComponentProperties(formDefinition) {
|
|
102
|
-
const map = getMetadata(FormSystemMetadataKeys.COMPONENTS_PROPERTIES, Object.getPrototypeOf(formDefinition));
|
|
103
|
-
if (!map) {
|
|
104
|
-
throw new RxapFormSystemError('Could not extract the use component properties map from the form definition instance', '');
|
|
105
|
-
}
|
|
106
|
-
if (!map.has(this.controlId)) {
|
|
107
|
-
throw new RxapFormSystemError('A use component definition does not exists in the form definition metadata', '');
|
|
108
|
-
}
|
|
109
|
-
return map.get(this.controlId);
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
FormSystemControlDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FormSystemControlDirective, deps: [{ token: ControlContainer }, { token: ComponentFactoryResolver }, { token: ViewContainerRef }, { token: DataSourceLoader }, { token: INJECTOR }], target: i0.ɵɵFactoryTarget.Directive });
|
|
113
|
-
FormSystemControlDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FormSystemControlDirective, selector: "[rxapFormSystemControl]", inputs: { controlId: "controlId" }, ngImport: i0 });
|
|
114
|
-
__decorate([
|
|
115
|
-
Required,
|
|
116
|
-
__metadata("design:type", String)
|
|
117
|
-
], FormSystemControlDirective.prototype, "controlId", void 0);
|
|
118
|
-
__decorate([
|
|
119
|
-
Required,
|
|
120
|
-
__metadata("design:type", RxapFormControl)
|
|
121
|
-
], FormSystemControlDirective.prototype, "control", void 0);
|
|
122
|
-
__decorate([
|
|
123
|
-
Required,
|
|
124
|
-
__metadata("design:type", ComponentRef)
|
|
125
|
-
], FormSystemControlDirective.prototype, "componentRef", void 0);
|
|
126
|
-
FormSystemControlDirective = __decorate([
|
|
127
|
-
Mixin(ExtractDataSourcesMixin),
|
|
128
|
-
__metadata("design:paramtypes", [ControlContainer,
|
|
129
|
-
ComponentFactoryResolver,
|
|
130
|
-
ViewContainerRef,
|
|
131
|
-
DataSourceLoader,
|
|
132
|
-
Injector])
|
|
133
|
-
], FormSystemControlDirective);
|
|
134
|
-
export { FormSystemControlDirective };
|
|
135
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FormSystemControlDirective, decorators: [{
|
|
136
|
-
type: Directive,
|
|
137
|
-
args: [{
|
|
138
|
-
selector: '[rxapFormSystemControl]'
|
|
139
|
-
}]
|
|
140
|
-
}], ctorParameters: function () { return [{ type: i1.ControlContainer, decorators: [{
|
|
141
|
-
type: Inject,
|
|
142
|
-
args: [ControlContainer]
|
|
143
|
-
}] }, { type: i0.ComponentFactoryResolver, decorators: [{
|
|
144
|
-
type: Inject,
|
|
145
|
-
args: [ComponentFactoryResolver]
|
|
146
|
-
}] }, { type: i0.ViewContainerRef, decorators: [{
|
|
147
|
-
type: Inject,
|
|
148
|
-
args: [ViewContainerRef]
|
|
149
|
-
}] }, { type: i2.DataSourceLoader, decorators: [{
|
|
150
|
-
type: Inject,
|
|
151
|
-
args: [DataSourceLoader]
|
|
152
|
-
}] }, { type: i0.Injector, decorators: [{
|
|
153
|
-
type: Inject,
|
|
154
|
-
args: [INJECTOR]
|
|
155
|
-
}] }]; }, propDecorators: { controlId: [{
|
|
156
|
-
type: Input
|
|
157
|
-
}], control: [], componentRef: [] } });
|
|
158
|
-
//# sourceMappingURL=form-system-control.directive.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"form-system-control.directive.js","sourceRoot":"","sources":["../../../../../libs/form-system/src/lib/form-system-control.directive.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,KAAK,EACL,MAAM,EAEN,wBAAwB,EACxB,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,QAAQ,EACT,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,QAAQ,EA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QAAQ;8BACW,eAAe;2DAAC;AAGpC;IADC,QAAQ;8BACgB,YAAY;gEAAwD;AAblF,0BAA0B;IAJtC,KAAK,CAAC,uBAAuB,CAAC;qCAqBF,gBAAgB;QAEnB,wBAAwB;QAEX,gBAAgB;QAEhB,gBAAgB;QAExB,QAAQ;GAzB1B,0BAA0B,CA+JtC;SA/JY,0BAA0B;4FAA1B,0BAA0B;kBAHtC,SAAS;mBAAC;oBACT,QAAQ,EAAE,yBAAyB;iBACpC;;0BAiBI,MAAM;2BAAC,gBAAgB;;0BAEvB,MAAM;2BAAC,wBAAwB;;0BAE/B,MAAM;2BAAC,gBAAgB;;0BAEvB,MAAM;2BAAC,gBAAgB;;0BAEvB,MAAM;2BAAC,QAAQ;4CAjBX,SAAS;sBAFf,KAAK;gBAKI,OAAO,MAGP,YAAY","sourcesContent":["import {\n Input,\n Inject,\n OnInit,\n ComponentFactoryResolver,\n ViewContainerRef,\n Directive,\n ComponentRef,\n INJECTOR,\n Injector\n} from '@angular/core';\nimport {\n Required,\n Constructor\n} from '@rxap/utilities';\nimport {\n ControlContainer,\n ControlValueAccessor\n} from '@angular/forms';\nimport { RxapFormSystemError } from './error';\nimport {\n RxapFormControl,\n FormDefinition\n} from '@rxap/forms';\nimport { FormSystemMetadataKeys } from './decorators/metadata-keys';\nimport { ControlWithDataSource } from './control-with-data-source';\nimport {\n DataSourceLoader,\n PipeDataSource\n} from '@rxap/data-source';\nimport { Mixin } from '@rxap/mixin';\nimport { ExtractDataSourcesMixin } from './mixins/extract-data-sources.mixin';\nimport { map } from 'rxjs/operators';\nimport { getMetadata } from '@rxap/utilities/reflect-metadata';\n\nexport interface FormSystemControlDirective<T> extends ExtractDataSourcesMixin, ControlValueAccessor, OnInit {}\n\n@Mixin(ExtractDataSourcesMixin)\n@Directive({\n selector: '[rxapFormSystemControl]'\n})\nexport class FormSystemControlDirective<T> implements ControlValueAccessor, OnInit {\n\n /**\n * Defines the form control id\n */\n @Input()\n @Required\n public controlId!: string;\n\n @Required\n protected control!: RxapFormControl;\n\n @Required\n protected componentRef!: ComponentRef<ControlValueAccessor & Partial<ControlWithDataSource>>;\n\n constructor(\n @Inject(ControlContainer)\n private readonly parent: ControlContainer,\n @Inject(ComponentFactoryResolver)\n private readonly cfr: ComponentFactoryResolver,\n @Inject(ViewContainerRef)\n private readonly viewContainerRef: ViewContainerRef,\n @Inject(DataSourceLoader)\n private readonly dataSourceLoader: DataSourceLoader,\n @Inject(INJECTOR)\n private readonly injector: Injector\n ) {}\n\n public ngOnInit() {\n\n this.control = this.extractControl();\n\n const formDefinition = this.extractFormDefinition();\n\n this.componentRef = this.createComponent(formDefinition);\n\n this.setDataSources(formDefinition, this.componentRef.instance);\n this.setComponentProperties(formDefinition, this.componentRef.instance);\n\n this.viewContainerRef.insert(this.componentRef.hostView);\n\n }\n\n public registerOnChange(fn: (value: (any | null)) => void): void {\n this.componentRef.instance.registerOnChange(fn);\n }\n\n public registerOnTouched(fn: () => void): void {\n this.componentRef.instance.registerOnTouched(fn);\n }\n\n public writeValue(value: any): void {\n this.componentRef.instance.writeValue(value);\n }\n\n public setDisabledState(isDisabled: boolean): void {\n if (this.componentRef.instance.setDisabledState) {\n this.componentRef.instance.setDisabledState(isDisabled);\n }\n }\n\n private setDataSources(formDefinition: FormDefinition, component: Partial<ControlWithDataSource>): void {\n\n if (!component.setDataSource) {\n throw new RxapFormSystemError(\n 'The ControlWithDataSource interface is not implemented for the control component, but the control has defined data sources',\n ''\n );\n }\n\n const useDataSourceValueMap = this.extractDataSources(formDefinition, this.controlId);\n\n for (const [ name, useDataSourceValue ] of useDataSourceValueMap.entries()) {\n\n let dataSource = this.dataSourceLoader.load(useDataSourceValue.dataSource);\n\n const settings = useDataSourceValue.settings;\n\n if (settings?.transformer) {\n dataSource = new PipeDataSource(dataSource, map(settings.transformer));\n }\n\n component.setDataSource(name, dataSource, useDataSourceValue.settings);\n\n }\n\n }\n\n private setComponentProperties(formDefinition: FormDefinition, component: any) {\n const componentProperties = this.extractComponentProperties(formDefinition);\n\n for (const [ key, value ] of Object.entries(componentProperties)) {\n Reflect.set(component, key, value);\n }\n\n }\n\n private createComponent(formDefinition: FormDefinition): ComponentRef<ControlValueAccessor> {\n const component = this.extractComponent(formDefinition);\n const componentFactory = this.cfr.resolveComponentFactory(component);\n return componentFactory.create(this.injector);\n }\n\n private extractControl(): RxapFormControl {\n if (!this.parent.control) {\n throw new RxapFormSystemError('The control property of ControlContainer is not defined', '');\n }\n\n const control = this.parent.control.get(this.controlId);\n\n if (!control) {\n throw new RxapFormSystemError('Could not find the control instance', '');\n }\n\n if (!(control instanceof RxapFormControl)) {\n throw new RxapFormSystemError('The extracted control is not a RxapFormControl', '');\n }\n\n return control;\n }\n\n private extractFormDefinition(): FormDefinition {\n const formDefinition = (this.control as any).rxapFormDefinition;\n\n if (!formDefinition) {\n throw new RxapFormSystemError('Could not find the form definition instance', '');\n }\n\n return formDefinition;\n }\n\n private extractComponent(formDefinition: FormDefinition): Constructor<ControlValueAccessor> {\n const map = getMetadata<Map<string, Constructor<ControlValueAccessor>>>(FormSystemMetadataKeys.COMPONENTS, Object.getPrototypeOf(formDefinition));\n\n if (!map) {\n throw new RxapFormSystemError('Could not extract the use component map from the form definition instance', '');\n }\n\n if (!map.has(this.controlId)) {\n throw new RxapFormSystemError('A use component definition does not exists in the form definition metadata', '');\n }\n\n return map.get(this.controlId)!;\n }\n\n private extractComponentProperties(formDefinition: FormDefinition): Record<string, any> {\n const map = getMetadata<Map<string, Record<string, any>>>(FormSystemMetadataKeys.COMPONENTS_PROPERTIES, Object.getPrototypeOf(formDefinition));\n\n if (!map) {\n throw new RxapFormSystemError('Could not extract the use component properties map from the form definition instance', '');\n }\n\n if (!map.has(this.controlId)) {\n throw new RxapFormSystemError('A use component definition does not exists in the form definition metadata', '');\n }\n\n return map.get(this.controlId)!;\n }\n\n}\n"]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { NgModule } from '@angular/core';
|
|
2
|
-
import { FormSystemControlDirective } from './form-system-control.directive';
|
|
3
|
-
import * as i0 from "@angular/core";
|
|
4
|
-
export class FormSystemModule {
|
|
5
|
-
}
|
|
6
|
-
FormSystemModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FormSystemModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
7
|
-
FormSystemModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FormSystemModule, declarations: [FormSystemControlDirective], exports: [FormSystemControlDirective] });
|
|
8
|
-
FormSystemModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FormSystemModule, imports: [[]] });
|
|
9
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FormSystemModule, decorators: [{
|
|
10
|
-
type: NgModule,
|
|
11
|
-
args: [{
|
|
12
|
-
declarations: [FormSystemControlDirective],
|
|
13
|
-
exports: [FormSystemControlDirective],
|
|
14
|
-
imports: []
|
|
15
|
-
}]
|
|
16
|
-
}] });
|
|
17
|
-
//# sourceMappingURL=form-system.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"form-system.module.js","sourceRoot":"","sources":["../../../../../libs/form-system/src/lib/form-system.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;;AAQ7E,MAAM,OAAO,gBAAgB;;8GAAhB,gBAAgB;+GAAhB,gBAAgB,iBAJX,0BAA0B,aAC1B,0BAA0B;+GAG/B,gBAAgB,YAFb,EAAE;4FAEL,gBAAgB;kBAL5B,QAAQ;mBAAC;oBACR,YAAY,EAAE,CAAE,0BAA0B,CAAE;oBAC5C,OAAO,EAAO,CAAE,0BAA0B,CAAE;oBAC5C,OAAO,EAAO,EAAE;iBACjB","sourcesContent":["import { NgModule } from '@angular/core';\nimport { FormSystemControlDirective } from './form-system-control.directive';\n\n\n@NgModule({\n declarations: [ FormSystemControlDirective ],\n exports: [ FormSystemControlDirective ],\n imports: []\n})\nexport class FormSystemModule {}\n"]}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { RxapFormControl, RxapFormGroup, RxapFormArray, } from '@rxap/forms';
|
|
2
|
-
import { RxapFormSystemError } from '../error';
|
|
3
|
-
export class ExtractControlMixin {
|
|
4
|
-
extractControl(parent, controlPath) {
|
|
5
|
-
if (!controlPath) {
|
|
6
|
-
throw new RxapFormSystemError('The control path is empty', '');
|
|
7
|
-
}
|
|
8
|
-
if (!parent.control) {
|
|
9
|
-
throw new RxapFormSystemError('The control property of ControlContainer is not defined', '');
|
|
10
|
-
}
|
|
11
|
-
const control = parent.control.get(controlPath);
|
|
12
|
-
if (!control) {
|
|
13
|
-
throw new RxapFormSystemError('Could not find the control instance', '');
|
|
14
|
-
}
|
|
15
|
-
if (!(control instanceof RxapFormControl) && !(control instanceof RxapFormGroup) && !(control instanceof RxapFormArray)) {
|
|
16
|
-
throw new RxapFormSystemError('The extracted control is not a RxapFormControl', '');
|
|
17
|
-
}
|
|
18
|
-
return control;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=extract-control.mixin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extract-control.mixin.js","sourceRoot":"","sources":["../../../../../../libs/form-system/src/lib/mixins/extract-control.mixin.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EAEf,aAAa,EACb,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,OAAO,mBAAmB;IAEpB,cAAc,CAAC,MAAwB,EAAE,WAAmB;QACpE,IAAI,CAAC,WAAW,EAAE;YAChB,MAAM,IAAI,mBAAmB,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAC;SAChE;QAED,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;YACnB,MAAM,IAAI,mBAAmB,CAAC,yDAAyD,EAAE,EAAE,CAAC,CAAC;SAC9F;QAED,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAEhD,IAAI,CAAC,OAAO,EAAE;YACZ,MAAM,IAAI,mBAAmB,CAAC,qCAAqC,EAAE,EAAE,CAAC,CAAC;SAC1E;QAED,IAAI,CAAC,CAAC,OAAO,YAAY,eAAe,CAAC,IAAI,CAAC,CAAC,OAAO,YAAY,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,YAAY,aAAa,CAAC,EAAE;YACvH,MAAM,IAAI,mBAAmB,CAAC,gDAAgD,EAAE,EAAE,CAAC,CAAC;SACrF;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CAEF","sourcesContent":["import { ControlContainer } from '@angular/forms';\nimport {\n RxapFormControl,\n AbstractControl,\n RxapFormGroup,\n RxapFormArray,\n} from '@rxap/forms';\nimport { RxapFormSystemError } from '../error';\n\nexport class ExtractControlMixin {\n\n protected extractControl(parent: ControlContainer, controlPath: string): AbstractControl {\n if (!controlPath) {\n throw new RxapFormSystemError('The control path is empty', '');\n }\n\n if (!parent.control) {\n throw new RxapFormSystemError('The control property of ControlContainer is not defined', '');\n }\n\n const control = parent.control.get(controlPath);\n\n if (!control) {\n throw new RxapFormSystemError('Could not find the control instance', '');\n }\n\n if (!(control instanceof RxapFormControl) && !(control instanceof RxapFormGroup) && !(control instanceof RxapFormArray)) {\n throw new RxapFormSystemError('The extracted control is not a RxapFormControl', '');\n }\n\n return control;\n }\n\n}\n"]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { RxapFormSystemError } from '../error';
|
|
2
|
-
import { FormSystemMetadataKeys } from '../decorators/metadata-keys';
|
|
3
|
-
import { getMetadata } from '@rxap/utilities/reflect-metadata';
|
|
4
|
-
export class ExtractDataSourcesMixin {
|
|
5
|
-
extractDataSources(formDefinition, controlId) {
|
|
6
|
-
const map = getMetadata(FormSystemMetadataKeys.DATA_SOURCES, Object.getPrototypeOf(formDefinition));
|
|
7
|
-
if (!map) {
|
|
8
|
-
throw new RxapFormSystemError('Could not extract the use data source map from the form definition instance', '');
|
|
9
|
-
}
|
|
10
|
-
if (!map.has(controlId)) {
|
|
11
|
-
throw new RxapFormSystemError('A use data source definition does not exists in the form definition metadata', '');
|
|
12
|
-
}
|
|
13
|
-
return map.get(controlId);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=extract-data-sources.mixin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extract-data-sources.mixin.js","sourceRoot":"","sources":["../../../../../../libs/form-system/src/lib/mixins/extract-data-sources.mixin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAE/D,MAAM,OAAO,uBAAuB;IAExB,kBAAkB,CAAC,cAA8B,EAAE,SAAiB;QAC5E,MAAM,GAAG,GAAG,WAAW,CACrB,sBAAsB,CAAC,YAAY,EACnC,MAAM,CAAC,cAAc,CAAC,cAAc,CAAC,CACtC,CAAC;QAEF,IAAI,CAAC,GAAG,EAAE;YACR,MAAM,IAAI,mBAAmB,CAAC,6EAA6E,EAAE,EAAE,CAAC,CAAC;SAClH;QAED,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YACvB,MAAM,IAAI,mBAAmB,CAAC,8EAA8E,EAAE,EAAE,CAAC,CAAC;SACnH;QAED,OAAO,GAAG,CAAC,GAAG,CAAC,SAAS,CAAE,CAAC;IAC7B,CAAC;CAEF","sourcesContent":["import { FormDefinition } from '@rxap/forms';\nimport { RxapFormSystemError } from '../error';\nimport { FormSystemMetadataKeys } from '../decorators/metadata-keys';\nimport { UseDataSourceValue } from '../decorators/use-data-source';\nimport { getMetadata } from '@rxap/utilities/reflect-metadata';\n\nexport class ExtractDataSourcesMixin {\n\n protected extractDataSources(formDefinition: FormDefinition, controlId: string): Map<string, UseDataSourceValue> {\n const map = getMetadata<Map<string, Map<string, UseDataSourceValue>>>(\n FormSystemMetadataKeys.DATA_SOURCES,\n Object.getPrototypeOf(formDefinition)\n );\n\n if (!map) {\n throw new RxapFormSystemError('Could not extract the use data source map from the form definition instance', '');\n }\n\n if (!map.has(controlId)) {\n throw new RxapFormSystemError('A use data source definition does not exists in the form definition metadata', '');\n }\n\n return map.get(controlId)!;\n }\n\n}\n"]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { RxapFormSystemError } from '../error';
|
|
2
|
-
export class ExtractFormDefinitionMixin {
|
|
3
|
-
// TODO : change to AbstractControl from @rxap/forms
|
|
4
|
-
extractFormDefinition(control) {
|
|
5
|
-
const formDefinition = control.rxapFormDefinition;
|
|
6
|
-
if (!formDefinition) {
|
|
7
|
-
throw new RxapFormSystemError('Could not find the form definition instance', '');
|
|
8
|
-
}
|
|
9
|
-
return formDefinition;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=extract-form-definition.mixin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extract-form-definition.mixin.js","sourceRoot":"","sources":["../../../../../../libs/form-system/src/lib/mixins/extract-form-definition.mixin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,OAAO,0BAA0B;IAErC,oDAAoD;IAC1C,qBAAqB,CAAC,OAAwB;QACtD,MAAM,cAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC;QAElD,IAAI,CAAC,cAAc,EAAE;YACnB,MAAM,IAAI,mBAAmB,CAAC,6CAA6C,EAAE,EAAE,CAAC,CAAC;SAClF;QAED,OAAO,cAAc,CAAC;IACxB,CAAC;CAEF","sourcesContent":["import {\n FormDefinition,\n AbstractControl,\n} from '@rxap/forms';\nimport { RxapFormSystemError } from '../error';\n\nexport class ExtractFormDefinitionMixin {\n\n // TODO : change to AbstractControl from @rxap/forms\n protected extractFormDefinition(control: AbstractControl): FormDefinition {\n const formDefinition = control.rxapFormDefinition;\n\n if (!formDefinition) {\n throw new RxapFormSystemError('Could not find the form definition instance', '');\n }\n\n return formDefinition;\n }\n\n}\n"]}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { Directive, forwardRef, Input, NgModule } from '@angular/core';
|
|
3
|
-
import { NG_VALIDATORS } from '@angular/forms';
|
|
4
|
-
import { Required } from '@rxap/utilities';
|
|
5
|
-
import * as i0 from "@angular/core";
|
|
6
|
-
export class IsEqualToDirective {
|
|
7
|
-
set equalTo(value) {
|
|
8
|
-
this._equalTo = value;
|
|
9
|
-
if (this._onChange) {
|
|
10
|
-
this._onChange();
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
validate(control) {
|
|
14
|
-
if (this._equalTo === null || this._equalTo === control.value) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
return { isEqualTo: { value: this._equalTo, actualValue: control.value } };
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* @description
|
|
21
|
-
* Registers a callback function to call when the validator inputs change.
|
|
22
|
-
*
|
|
23
|
-
* @param fn The callback function
|
|
24
|
-
*/
|
|
25
|
-
registerOnValidatorChange(fn) {
|
|
26
|
-
this._onChange = fn;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
IsEqualToDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: IsEqualToDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
30
|
-
IsEqualToDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: IsEqualToDirective, selector: "[rxapIsEqualTo]", inputs: { equalTo: ["rxapIsEqualTo", "equalTo"] }, providers: [
|
|
31
|
-
{
|
|
32
|
-
provide: NG_VALIDATORS,
|
|
33
|
-
multi: true,
|
|
34
|
-
useExisting: forwardRef(() => IsEqualToDirective)
|
|
35
|
-
}
|
|
36
|
-
], ngImport: i0 });
|
|
37
|
-
__decorate([
|
|
38
|
-
Required,
|
|
39
|
-
__metadata("design:type", Object),
|
|
40
|
-
__metadata("design:paramtypes", [Object])
|
|
41
|
-
], IsEqualToDirective.prototype, "equalTo", null);
|
|
42
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: IsEqualToDirective, decorators: [{
|
|
43
|
-
type: Directive,
|
|
44
|
-
args: [{
|
|
45
|
-
selector: '[rxapIsEqualTo]',
|
|
46
|
-
providers: [
|
|
47
|
-
{
|
|
48
|
-
provide: NG_VALIDATORS,
|
|
49
|
-
multi: true,
|
|
50
|
-
useExisting: forwardRef(() => IsEqualToDirective)
|
|
51
|
-
}
|
|
52
|
-
]
|
|
53
|
-
}]
|
|
54
|
-
}], propDecorators: { equalTo: [{
|
|
55
|
-
type: Input,
|
|
56
|
-
args: ['rxapIsEqualTo']
|
|
57
|
-
}] } });
|
|
58
|
-
export class IsEqualToDirectiveModule {
|
|
59
|
-
}
|
|
60
|
-
IsEqualToDirectiveModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: IsEqualToDirectiveModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
61
|
-
IsEqualToDirectiveModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: IsEqualToDirectiveModule, declarations: [IsEqualToDirective], exports: [IsEqualToDirective] });
|
|
62
|
-
IsEqualToDirectiveModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: IsEqualToDirectiveModule });
|
|
63
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: IsEqualToDirectiveModule, decorators: [{
|
|
64
|
-
type: NgModule,
|
|
65
|
-
args: [{
|
|
66
|
-
declarations: [IsEqualToDirective],
|
|
67
|
-
exports: [IsEqualToDirective]
|
|
68
|
-
}]
|
|
69
|
-
}] });
|
|
70
|
-
//# sourceMappingURL=is-equal-to.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-equal-to.js","sourceRoot":"","sources":["../../../../../../libs/form-system/src/lib/validators/is-equal-to.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,KAAK,EACL,QAAQ,EACT,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,aAAa,EAGd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;;AAY3C,MAAM,OAAO,kBAAkB;IAI7B,IAAW,OAAO,CAAC,KAAU;QAC3B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,IAAI,IAAI,CAAC,SAAS,EAAE;YAClB,IAAI,CAAC,SAAS,EAAE,CAAC;SAClB;IACH,CAAC;IAOM,QAAQ,CAAC,OAAwB;QACtC,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,IAAI,IAAI,CAAC,QAAQ,KAAK,OAAO,CAAC,KAAK,EAAE;YAC7D,OAAO,IAAI,CAAC;SACb;QACD,OAAO,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;IAC7E,CAAC;IAED;;;;;OAKG;IACI,yBAAyB,CAAC,EAAc;QAC7C,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;IACtB,CAAC;;gHA/BU,kBAAkB;oGAAlB,kBAAkB,6FARlB;QACT;YACE,OAAO,EAAM,aAAa;YAC1B,KAAK,EAAQ,IAAI;YACjB,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC;SAClD;KACF;AAMD;IADC,QAAQ;;;iDAMR;4FATU,kBAAkB;kBAV9B,SAAS;mBAAC;oBACT,QAAQ,EAAG,iBAAiB;oBAC5B,SAAS,EAAE;wBACT;4BACE,OAAO,EAAM,aAAa;4BAC1B,KAAK,EAAQ,IAAI;4BACjB,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,mBAAmB,CAAC;yBAClD;qBACF;iBACF;8BAKY,OAAO;sBAFjB,KAAK;uBAAC,eAAe;;AAqCxB,MAAM,OAAO,wBAAwB;;sHAAxB,wBAAwB;uHAAxB,wBAAwB,iBAvCxB,kBAAkB,aAAlB,kBAAkB;uHAuClB,wBAAwB;4FAAxB,wBAAwB;kBAJpC,QAAQ;mBAAC;oBACR,YAAY,EAAE,CAAE,kBAAkB,CAAE;oBACpC,OAAO,EAAO,CAAE,kBAAkB,CAAE;iBACrC","sourcesContent":["import {\n Directive,\n forwardRef,\n Input,\n NgModule\n} from '@angular/core';\nimport {\n AbstractControl,\n NG_VALIDATORS,\n ValidationErrors,\n Validator\n} from '@angular/forms';\nimport { Required } from '@rxap/utilities';\n\n@Directive({\n selector: '[rxapIsEqualTo]',\n providers: [\n {\n provide: NG_VALIDATORS,\n multi: true,\n useExisting: forwardRef(() => IsEqualToDirective)\n }\n ]\n})\nexport class IsEqualToDirective implements Validator {\n\n @Input('rxapIsEqualTo')\n @Required\n public set equalTo(value: any) {\n this._equalTo = value;\n if (this._onChange) {\n this._onChange();\n }\n }\n\n private _onChange!: () => void;\n\n\n private _equalTo!: any;\n\n public validate(control: AbstractControl): ValidationErrors | null {\n if (this._equalTo === null || this._equalTo === control.value) {\n return null;\n }\n return { isEqualTo: { value: this._equalTo, actualValue: control.value } };\n }\n\n /**\n * @description\n * Registers a callback function to call when the validator inputs change.\n *\n * @param fn The callback function\n */\n public registerOnValidatorChange(fn: () => void): void {\n this._onChange = fn;\n }\n\n}\n\n@NgModule({\n declarations: [ IsEqualToDirective ],\n exports: [ IsEqualToDirective ]\n})\nexport class IsEqualToDirectiveModule {\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rxap-form-system.js","sourceRoot":"","sources":["../../../../libs/form-system/src/rxap-form-system.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC","sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"]}
|