@ng-formworks/core 17.2.7 → 17.3.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/LICENSE +21 -0
- package/README.md +833 -0
- package/esm2022/lib/framework-library/framework-library.service.mjs +175 -0
- package/esm2022/lib/framework-library/framework.mjs +15 -0
- package/esm2022/lib/framework-library/no-framework.component.mjs +18 -0
- package/esm2022/lib/framework-library/no-framework.module.mjs +27 -0
- package/esm2022/lib/framework-library/no.framework.mjs +19 -0
- package/esm2022/lib/json-schema-form.component.mjs +765 -0
- package/esm2022/lib/json-schema-form.module.mjs +26 -0
- package/esm2022/lib/json-schema-form.service.mjs +676 -0
- package/esm2022/lib/locale/de-validation-messages.mjs +60 -0
- package/esm2022/lib/locale/en-validation-messages.mjs +60 -0
- package/esm2022/lib/locale/es-validation-messages.mjs +57 -0
- package/esm2022/lib/locale/fr-validation-messages.mjs +60 -0
- package/esm2022/lib/locale/index.mjs +8 -0
- package/esm2022/lib/locale/it-validation-messages.mjs +60 -0
- package/esm2022/lib/locale/pt-validation-messages.mjs +60 -0
- package/esm2022/lib/locale/zh-validation-messages.mjs +60 -0
- package/esm2022/lib/shared/convert-schema-to-draft6.function.mjs +300 -0
- package/esm2022/lib/shared/form-group.functions.mjs +442 -0
- package/esm2022/lib/shared/format-regex.constants.mjs +54 -0
- package/esm2022/lib/shared/index.mjs +12 -0
- package/esm2022/lib/shared/json-schema.functions.mjs +784 -0
- package/esm2022/lib/shared/json.validators.mjs +884 -0
- package/esm2022/lib/shared/jsonpointer.functions.mjs +1026 -0
- package/esm2022/lib/shared/layout.functions.mjs +1154 -0
- package/esm2022/lib/shared/merge-schemas.function.mjs +345 -0
- package/esm2022/lib/shared/utility.functions.mjs +380 -0
- package/esm2022/lib/shared/validator.functions.mjs +584 -0
- package/esm2022/lib/widget-library/add-reference.component.mjs +61 -0
- package/esm2022/lib/widget-library/button.component.mjs +72 -0
- package/esm2022/lib/widget-library/checkbox.component.mjs +105 -0
- package/esm2022/lib/widget-library/checkboxes.component.mjs +147 -0
- package/esm2022/lib/widget-library/file.component.mjs +35 -0
- package/esm2022/lib/widget-library/hidden.component.mjs +54 -0
- package/esm2022/lib/widget-library/index.mjs +55 -0
- package/esm2022/lib/widget-library/input.component.mjs +119 -0
- package/esm2022/lib/widget-library/message.component.mjs +38 -0
- package/esm2022/lib/widget-library/none.component.mjs +21 -0
- package/esm2022/lib/widget-library/number.component.mjs +123 -0
- package/esm2022/lib/widget-library/one-of.component.mjs +35 -0
- package/esm2022/lib/widget-library/orderable.directive.mjs +123 -0
- package/esm2022/lib/widget-library/radios.component.mjs +153 -0
- package/esm2022/lib/widget-library/root.component.mjs +79 -0
- package/esm2022/lib/widget-library/section.component.mjs +199 -0
- package/esm2022/lib/widget-library/select-framework.component.mjs +51 -0
- package/esm2022/lib/widget-library/select-widget.component.mjs +46 -0
- package/esm2022/lib/widget-library/select.component.mjs +150 -0
- package/esm2022/lib/widget-library/submit.component.mjs +82 -0
- package/esm2022/lib/widget-library/tab.component.mjs +41 -0
- package/esm2022/lib/widget-library/tabs.component.mjs +108 -0
- package/esm2022/lib/widget-library/template.component.mjs +46 -0
- package/esm2022/lib/widget-library/textarea.component.mjs +104 -0
- package/esm2022/lib/widget-library/widget-library.module.mjs +42 -0
- package/esm2022/lib/widget-library/widget-library.service.mjs +226 -0
- package/esm2022/ng-formworks-core.mjs +5 -0
- package/esm2022/public_api.mjs +13 -0
- package/fesm2022/ng-formworks-core.mjs +10147 -0
- package/fesm2022/ng-formworks-core.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/framework-library/framework-library.service.d.ts +55 -0
- package/lib/framework-library/framework.d.ts +13 -0
- package/lib/framework-library/no-framework.component.d.ts +8 -0
- package/lib/framework-library/no-framework.module.d.ts +9 -0
- package/lib/framework-library/no.framework.d.ts +10 -0
- package/lib/json-schema-form.component.d.ts +218 -0
- package/lib/json-schema-form.module.d.ts +11 -0
- package/lib/json-schema-form.service.d.ts +115 -0
- package/lib/locale/de-validation-messages.d.ts +1 -0
- package/lib/locale/en-validation-messages.d.ts +1 -0
- package/lib/locale/es-validation-messages.d.ts +1 -0
- package/lib/locale/fr-validation-messages.d.ts +1 -0
- package/{src/lib/locale/index.ts → lib/locale/index.d.ts} +7 -7
- package/lib/locale/it-validation-messages.d.ts +1 -0
- package/lib/locale/pt-validation-messages.d.ts +1 -0
- package/lib/locale/zh-validation-messages.d.ts +1 -0
- package/lib/shared/convert-schema-to-draft6.function.d.ts +21 -0
- package/lib/shared/form-group.functions.d.ts +100 -0
- package/lib/shared/format-regex.constants.d.ts +19 -0
- package/lib/shared/index.d.ts +9 -0
- package/lib/shared/json-schema.functions.d.ts +193 -0
- package/lib/shared/json.validators.d.ts +441 -0
- package/lib/shared/jsonpointer.functions.d.ts +416 -0
- package/lib/shared/layout.functions.d.ts +83 -0
- package/lib/shared/merge-schemas.function.d.ts +19 -0
- package/lib/shared/utility.functions.d.ts +165 -0
- package/{src/lib/shared/validator.functions.ts → lib/shared/validator.functions.d.ts} +364 -601
- package/lib/widget-library/add-reference.component.d.ts +20 -0
- package/lib/widget-library/button.component.d.ts +21 -0
- package/lib/widget-library/checkbox.component.d.ts +24 -0
- package/lib/widget-library/checkboxes.component.d.ts +24 -0
- package/lib/widget-library/file.component.d.ts +21 -0
- package/lib/widget-library/hidden.component.d.ts +19 -0
- package/{src/lib/widget-library/index.ts → lib/widget-library/index.d.ts} +47 -56
- package/lib/widget-library/input.component.d.ts +22 -0
- package/lib/widget-library/message.component.d.ts +15 -0
- package/lib/widget-library/none.component.d.ts +8 -0
- package/lib/widget-library/number.component.d.ts +25 -0
- package/lib/widget-library/one-of.component.d.ts +21 -0
- package/lib/widget-library/orderable.directive.d.ts +41 -0
- package/lib/widget-library/radios.component.d.ts +23 -0
- package/lib/widget-library/root.component.d.ts +17 -0
- package/lib/widget-library/section.component.d.ts +19 -0
- package/lib/widget-library/select-framework.component.d.ts +18 -0
- package/lib/widget-library/select-widget.component.d.ts +18 -0
- package/lib/widget-library/select.component.d.ts +24 -0
- package/lib/widget-library/submit.component.d.ts +24 -0
- package/lib/widget-library/tab.component.d.ts +14 -0
- package/lib/widget-library/tabs.component.d.ts +20 -0
- package/lib/widget-library/template.component.d.ts +18 -0
- package/lib/widget-library/textarea.component.d.ts +21 -0
- package/lib/widget-library/widget-library.module.d.ts +31 -0
- package/lib/widget-library/widget-library.service.d.ts +22 -0
- package/package.json +64 -53
- package/{src/public_api.ts → public_api.d.ts} +9 -21
- package/karma.conf.js +0 -46
- package/ng-package.json +0 -11
- package/src/lib/framework-library/framework-library.service.ts +0 -195
- package/src/lib/framework-library/framework.ts +0 -11
- package/src/lib/framework-library/no-framework.component.html +0 -2
- package/src/lib/framework-library/no-framework.component.ts +0 -11
- package/src/lib/framework-library/no-framework.module.ts +0 -18
- package/src/lib/framework-library/no.framework.ts +0 -11
- package/src/lib/json-schema-form.component.html +0 -7
- package/src/lib/json-schema-form.component.ts +0 -809
- package/src/lib/json-schema-form.module.ts +0 -17
- package/src/lib/json-schema-form.service.ts +0 -907
- package/src/lib/locale/de-validation-messages.ts +0 -58
- package/src/lib/locale/en-validation-messages.ts +0 -58
- package/src/lib/locale/es-validation-messages.ts +0 -55
- package/src/lib/locale/fr-validation-messages.ts +0 -58
- package/src/lib/locale/it-validation-messages.ts +0 -58
- package/src/lib/locale/pt-validation-messages.ts +0 -58
- package/src/lib/locale/zh-validation-messages.ts +0 -58
- package/src/lib/locale-dates/en-US.ts +0 -5
- package/src/lib/shared/convert-schema-to-draft6.function.ts +0 -321
- package/src/lib/shared/form-group.functions.ts +0 -522
- package/src/lib/shared/format-regex.constants.ts +0 -73
- package/src/lib/shared/index.ts +0 -40
- package/src/lib/shared/json-schema.functions.ts +0 -788
- package/src/lib/shared/json.validators.ts +0 -878
- package/src/lib/shared/jsonpointer.functions.ts +0 -1012
- package/src/lib/shared/jspointer.functions.json.spec.ts +0 -103
- package/src/lib/shared/layout.functions.ts +0 -1233
- package/src/lib/shared/merge-schemas.function.ts +0 -329
- package/src/lib/shared/utility.functions.ts +0 -373
- package/src/lib/shared/validator.functions.spec.ts +0 -55
- package/src/lib/widget-library/add-reference.component.ts +0 -59
- package/src/lib/widget-library/button.component.ts +0 -54
- package/src/lib/widget-library/checkbox.component.ts +0 -74
- package/src/lib/widget-library/checkboxes.component.ts +0 -104
- package/src/lib/widget-library/file.component.ts +0 -36
- package/src/lib/widget-library/hidden.component.ts +0 -39
- package/src/lib/widget-library/input.component.ts +0 -76
- package/src/lib/widget-library/message.component.ts +0 -29
- package/src/lib/widget-library/none.component.ts +0 -12
- package/src/lib/widget-library/number.component.ts +0 -79
- package/src/lib/widget-library/one-of.component.ts +0 -36
- package/src/lib/widget-library/orderable.directive.ts +0 -130
- package/src/lib/widget-library/radios.component.ts +0 -101
- package/src/lib/widget-library/root.component.ts +0 -78
- package/src/lib/widget-library/section.component.ts +0 -133
- package/src/lib/widget-library/select-framework.component.ts +0 -50
- package/src/lib/widget-library/select-widget.component.ts +0 -46
- package/src/lib/widget-library/select.component.ts +0 -96
- package/src/lib/widget-library/submit.component.ts +0 -68
- package/src/lib/widget-library/tab.component.ts +0 -29
- package/src/lib/widget-library/tabs.component.ts +0 -83
- package/src/lib/widget-library/template.component.ts +0 -52
- package/src/lib/widget-library/textarea.component.ts +0 -68
- package/src/lib/widget-library/widget-library.module.ts +0 -13
- package/src/lib/widget-library/widget-library.service.ts +0 -234
- package/src/test.ts +0 -18
- package/tsconfig.lib.json +0 -25
- package/tsconfig.lib.prod.json +0 -9
- package/tsconfig.spec.json +0 -17
- package/tslint.json +0 -11
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { AbstractControl } from '@angular/forms';
|
|
2
|
-
import { buildTitleMap } from '../shared';
|
|
3
|
-
import { Component, Input, OnInit } from '@angular/core';
|
|
4
|
-
import { JsonSchemaFormService, TitleMapItem } from '../json-schema-form.service';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
@Component({
|
|
8
|
-
// tslint:disable-next-line:component-selector
|
|
9
|
-
selector: 'checkboxes-widget',
|
|
10
|
-
template: `
|
|
11
|
-
<label *ngIf="options?.title"
|
|
12
|
-
[class]="options?.labelHtmlClass || ''"
|
|
13
|
-
[style.display]="options?.notitle ? 'none' : ''"
|
|
14
|
-
[innerHTML]="options?.title"></label>
|
|
15
|
-
|
|
16
|
-
<!-- 'horizontal' = checkboxes-inline or checkboxbuttons -->
|
|
17
|
-
<div *ngIf="layoutOrientation === 'horizontal'" [class]="options?.htmlClass || ''">
|
|
18
|
-
<label *ngFor="let checkboxItem of checkboxList"
|
|
19
|
-
[attr.for]="'control' + layoutNode?._id + '/' + checkboxItem.value"
|
|
20
|
-
[class]="(options?.itemLabelHtmlClass || '') + (checkboxItem.checked ?
|
|
21
|
-
(' ' + (options?.activeClass || '') + ' ' + (options?.style?.selected || '')) :
|
|
22
|
-
(' ' + (options?.style?.unselected || '')))">
|
|
23
|
-
<input type="checkbox"
|
|
24
|
-
[attr.required]="options?.required"
|
|
25
|
-
[checked]="checkboxItem.checked"
|
|
26
|
-
[class]="options?.fieldHtmlClass || ''"
|
|
27
|
-
[disabled]="controlDisabled"
|
|
28
|
-
[id]="'control' + layoutNode?._id + '/' + checkboxItem.value"
|
|
29
|
-
[name]="checkboxItem?.name"
|
|
30
|
-
[readonly]="options?.readonly ? 'readonly' : null"
|
|
31
|
-
[value]="checkboxItem.value"
|
|
32
|
-
(change)="updateValue($event)">
|
|
33
|
-
<span [innerHTML]="checkboxItem.name"></span>
|
|
34
|
-
</label>
|
|
35
|
-
</div>
|
|
36
|
-
|
|
37
|
-
<!-- 'vertical' = regular checkboxes -->
|
|
38
|
-
<div *ngIf="layoutOrientation === 'vertical'">
|
|
39
|
-
<div *ngFor="let checkboxItem of checkboxList" [class]="options?.htmlClass || ''">
|
|
40
|
-
<label
|
|
41
|
-
[attr.for]="'control' + layoutNode?._id + '/' + checkboxItem.value"
|
|
42
|
-
[class]="(options?.itemLabelHtmlClass || '') + (checkboxItem.checked ?
|
|
43
|
-
(' ' + (options?.activeClass || '') + ' ' + (options?.style?.selected || '')) :
|
|
44
|
-
(' ' + (options?.style?.unselected || '')))">
|
|
45
|
-
<input type="checkbox"
|
|
46
|
-
[attr.required]="options?.required"
|
|
47
|
-
[checked]="checkboxItem.checked"
|
|
48
|
-
[class]="options?.fieldHtmlClass || ''"
|
|
49
|
-
[disabled]="controlDisabled"
|
|
50
|
-
[id]="options?.name + '/' + checkboxItem.value"
|
|
51
|
-
[name]="checkboxItem?.name"
|
|
52
|
-
[readonly]="options?.readonly ? 'readonly' : null"
|
|
53
|
-
[value]="checkboxItem.value"
|
|
54
|
-
(change)="updateValue($event)">
|
|
55
|
-
<span [innerHTML]="checkboxItem?.name"></span>
|
|
56
|
-
</label>
|
|
57
|
-
</div>
|
|
58
|
-
</div>`,
|
|
59
|
-
})
|
|
60
|
-
export class CheckboxesComponent implements OnInit {
|
|
61
|
-
formControl: AbstractControl;
|
|
62
|
-
controlName: string;
|
|
63
|
-
controlValue: any;
|
|
64
|
-
controlDisabled = false;
|
|
65
|
-
boundControl = false;
|
|
66
|
-
options: any;
|
|
67
|
-
layoutOrientation: string;
|
|
68
|
-
formArray: AbstractControl;
|
|
69
|
-
checkboxList: TitleMapItem[] = [];
|
|
70
|
-
@Input() layoutNode: any;
|
|
71
|
-
@Input() layoutIndex: number[];
|
|
72
|
-
@Input() dataIndex: number[];
|
|
73
|
-
|
|
74
|
-
constructor(
|
|
75
|
-
private jsf: JsonSchemaFormService
|
|
76
|
-
) { }
|
|
77
|
-
|
|
78
|
-
ngOnInit() {
|
|
79
|
-
this.options = this.layoutNode.options || {};
|
|
80
|
-
this.layoutOrientation = (this.layoutNode.type === 'checkboxes-inline' ||
|
|
81
|
-
this.layoutNode.type === 'checkboxbuttons') ? 'horizontal' : 'vertical';
|
|
82
|
-
this.jsf.initializeControl(this);
|
|
83
|
-
this.checkboxList = buildTitleMap(
|
|
84
|
-
this.options.titleMap || this.options.enumNames, this.options.enum, true
|
|
85
|
-
);
|
|
86
|
-
if (this.boundControl) {
|
|
87
|
-
const formArray = this.jsf.getFormControl(this);
|
|
88
|
-
this.checkboxList.forEach(checkboxItem =>
|
|
89
|
-
checkboxItem.checked = formArray.value.includes(checkboxItem.value)
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
updateValue(event) {
|
|
95
|
-
for (const checkboxItem of this.checkboxList) {
|
|
96
|
-
if (event.target.value === checkboxItem.value) {
|
|
97
|
-
checkboxItem.checked = event.target.checked;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
if (this.boundControl) {
|
|
101
|
-
this.jsf.updateArrayCheckboxList(this, this.checkboxList);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { AbstractControl } from '@angular/forms';
|
|
2
|
-
import { Component, Input, OnInit } from '@angular/core';
|
|
3
|
-
import { JsonSchemaFormService } from '../json-schema-form.service';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// TODO: Add this control
|
|
7
|
-
|
|
8
|
-
@Component({
|
|
9
|
-
// tslint:disable-next-line:component-selector
|
|
10
|
-
selector: 'file-widget',
|
|
11
|
-
template: ``,
|
|
12
|
-
})
|
|
13
|
-
export class FileComponent implements OnInit {
|
|
14
|
-
formControl: AbstractControl;
|
|
15
|
-
controlName: string;
|
|
16
|
-
controlValue: any;
|
|
17
|
-
controlDisabled = false;
|
|
18
|
-
boundControl = false;
|
|
19
|
-
options: any;
|
|
20
|
-
@Input() layoutNode: any;
|
|
21
|
-
@Input() layoutIndex: number[];
|
|
22
|
-
@Input() dataIndex: number[];
|
|
23
|
-
|
|
24
|
-
constructor(
|
|
25
|
-
private jsf: JsonSchemaFormService
|
|
26
|
-
) { }
|
|
27
|
-
|
|
28
|
-
ngOnInit() {
|
|
29
|
-
this.options = this.layoutNode.options || {};
|
|
30
|
-
this.jsf.initializeControl(this);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
updateValue(event) {
|
|
34
|
-
this.jsf.updateValue(this, event.target.value);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { AbstractControl } from '@angular/forms';
|
|
2
|
-
import { Component, Input, OnInit } from '@angular/core';
|
|
3
|
-
import { JsonSchemaFormService } from '../json-schema-form.service';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
@Component({
|
|
7
|
-
// tslint:disable-next-line:component-selector
|
|
8
|
-
selector: 'hidden-widget',
|
|
9
|
-
template: `
|
|
10
|
-
<input *ngIf="boundControl"
|
|
11
|
-
[formControl]="formControl"
|
|
12
|
-
[id]="'control' + layoutNode?._id"
|
|
13
|
-
[name]="controlName"
|
|
14
|
-
type="hidden">
|
|
15
|
-
<input *ngIf="!boundControl"
|
|
16
|
-
[disabled]="controlDisabled"
|
|
17
|
-
[name]="controlName"
|
|
18
|
-
[id]="'control' + layoutNode?._id"
|
|
19
|
-
type="hidden"
|
|
20
|
-
[value]="controlValue">`,
|
|
21
|
-
})
|
|
22
|
-
export class HiddenComponent implements OnInit {
|
|
23
|
-
formControl: AbstractControl;
|
|
24
|
-
controlName: string;
|
|
25
|
-
controlValue: any;
|
|
26
|
-
controlDisabled = false;
|
|
27
|
-
boundControl = false;
|
|
28
|
-
@Input() layoutNode: any;
|
|
29
|
-
@Input() layoutIndex: number[];
|
|
30
|
-
@Input() dataIndex: number[];
|
|
31
|
-
|
|
32
|
-
constructor(
|
|
33
|
-
private jsf: JsonSchemaFormService
|
|
34
|
-
) { }
|
|
35
|
-
|
|
36
|
-
ngOnInit() {
|
|
37
|
-
this.jsf.initializeControl(this);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { AbstractControl } from '@angular/forms';
|
|
2
|
-
import { Component, Input, OnInit } from '@angular/core';
|
|
3
|
-
import { JsonSchemaFormService } from '../json-schema-form.service';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
@Component({
|
|
7
|
-
// tslint:disable-next-line:component-selector
|
|
8
|
-
selector: 'input-widget',
|
|
9
|
-
template: `
|
|
10
|
-
<div [class]="options?.htmlClass || ''">
|
|
11
|
-
<label *ngIf="options?.title"
|
|
12
|
-
[attr.for]="'control' + layoutNode?._id"
|
|
13
|
-
[class]="options?.labelHtmlClass || ''"
|
|
14
|
-
[style.display]="options?.notitle ? 'none' : ''"
|
|
15
|
-
[innerHTML]="options?.title"></label>
|
|
16
|
-
<input *ngIf="boundControl"
|
|
17
|
-
[formControl]="formControl"
|
|
18
|
-
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
19
|
-
[attr.list]="'control' + layoutNode?._id + 'Autocomplete'"
|
|
20
|
-
[attr.maxlength]="options?.maxLength"
|
|
21
|
-
[attr.minlength]="options?.minLength"
|
|
22
|
-
[attr.pattern]="options?.pattern"
|
|
23
|
-
[attr.placeholder]="options?.placeholder"
|
|
24
|
-
[attr.required]="options?.required"
|
|
25
|
-
[class]="options?.fieldHtmlClass || ''"
|
|
26
|
-
[id]="'control' + layoutNode?._id"
|
|
27
|
-
[name]="controlName"
|
|
28
|
-
[readonly]="options?.readonly ? 'readonly' : null"
|
|
29
|
-
[type]="layoutNode?.type">
|
|
30
|
-
<input *ngIf="!boundControl"
|
|
31
|
-
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
32
|
-
[attr.list]="'control' + layoutNode?._id + 'Autocomplete'"
|
|
33
|
-
[attr.maxlength]="options?.maxLength"
|
|
34
|
-
[attr.minlength]="options?.minLength"
|
|
35
|
-
[attr.pattern]="options?.pattern"
|
|
36
|
-
[attr.placeholder]="options?.placeholder"
|
|
37
|
-
[attr.required]="options?.required"
|
|
38
|
-
[class]="options?.fieldHtmlClass || ''"
|
|
39
|
-
[disabled]="controlDisabled"
|
|
40
|
-
[id]="'control' + layoutNode?._id"
|
|
41
|
-
[name]="controlName"
|
|
42
|
-
[readonly]="options?.readonly ? 'readonly' : null"
|
|
43
|
-
[type]="layoutNode?.type"
|
|
44
|
-
[value]="controlValue"
|
|
45
|
-
(input)="updateValue($event)">
|
|
46
|
-
<datalist *ngIf="options?.typeahead?.source"
|
|
47
|
-
[id]="'control' + layoutNode?._id + 'Autocomplete'">
|
|
48
|
-
<option *ngFor="let word of options?.typeahead?.source" [value]="word">
|
|
49
|
-
</datalist>
|
|
50
|
-
</div>`,
|
|
51
|
-
})
|
|
52
|
-
export class InputComponent implements OnInit {
|
|
53
|
-
formControl: AbstractControl;
|
|
54
|
-
controlName: string;
|
|
55
|
-
controlValue: string;
|
|
56
|
-
controlDisabled = false;
|
|
57
|
-
boundControl = false;
|
|
58
|
-
options: any;
|
|
59
|
-
autoCompleteList: string[] = [];
|
|
60
|
-
@Input() layoutNode: any;
|
|
61
|
-
@Input() layoutIndex: number[];
|
|
62
|
-
@Input() dataIndex: number[];
|
|
63
|
-
|
|
64
|
-
constructor(
|
|
65
|
-
private jsf: JsonSchemaFormService
|
|
66
|
-
) { }
|
|
67
|
-
|
|
68
|
-
ngOnInit() {
|
|
69
|
-
this.options = this.layoutNode.options || {};
|
|
70
|
-
this.jsf.initializeControl(this);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
updateValue(event) {
|
|
74
|
-
this.jsf.updateValue(this, event.target.value);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Component, Input, OnInit } from '@angular/core';
|
|
2
|
-
import { JsonSchemaFormService } from '../json-schema-form.service';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
@Component({
|
|
6
|
-
// tslint:disable-next-line:component-selector
|
|
7
|
-
selector: 'message-widget',
|
|
8
|
-
template: `
|
|
9
|
-
<span *ngIf="message"
|
|
10
|
-
[class]="options?.labelHtmlClass || ''"
|
|
11
|
-
[innerHTML]="message"></span>`,
|
|
12
|
-
})
|
|
13
|
-
export class MessageComponent implements OnInit {
|
|
14
|
-
options: any;
|
|
15
|
-
message: string = null;
|
|
16
|
-
@Input() layoutNode: any;
|
|
17
|
-
@Input() layoutIndex: number[];
|
|
18
|
-
@Input() dataIndex: number[];
|
|
19
|
-
|
|
20
|
-
constructor(
|
|
21
|
-
private jsf: JsonSchemaFormService
|
|
22
|
-
) { }
|
|
23
|
-
|
|
24
|
-
ngOnInit() {
|
|
25
|
-
this.options = this.layoutNode.options || {};
|
|
26
|
-
this.message = this.options.help || this.options.helpvalue ||
|
|
27
|
-
this.options.msg || this.options.message;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Component, Input } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
@Component({
|
|
4
|
-
// tslint:disable-next-line:component-selector
|
|
5
|
-
selector: 'none-widget',
|
|
6
|
-
template: ``,
|
|
7
|
-
})
|
|
8
|
-
export class NoneComponent {
|
|
9
|
-
@Input() layoutNode: any;
|
|
10
|
-
@Input() layoutIndex: number[];
|
|
11
|
-
@Input() dataIndex: number[];
|
|
12
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { Component, Input, OnInit } from '@angular/core';
|
|
2
|
-
import { AbstractControl } from '@angular/forms';
|
|
3
|
-
|
|
4
|
-
import { JsonSchemaFormService } from '../json-schema-form.service';
|
|
5
|
-
|
|
6
|
-
@Component({
|
|
7
|
-
// tslint:disable-next-line:component-selector
|
|
8
|
-
selector: 'number-widget',
|
|
9
|
-
template: `
|
|
10
|
-
<div [class]="options?.htmlClass || ''">
|
|
11
|
-
<label *ngIf="options?.title"
|
|
12
|
-
[attr.for]="'control' + layoutNode?._id"
|
|
13
|
-
[class]="options?.labelHtmlClass || ''"
|
|
14
|
-
[style.display]="options?.notitle ? 'none' : ''"
|
|
15
|
-
[innerHTML]="options?.title"></label>
|
|
16
|
-
<input *ngIf="boundControl"
|
|
17
|
-
[formControl]="formControl"
|
|
18
|
-
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
19
|
-
[attr.max]="options?.maximum"
|
|
20
|
-
[attr.min]="options?.minimum"
|
|
21
|
-
[attr.placeholder]="options?.placeholder"
|
|
22
|
-
[attr.required]="options?.required"
|
|
23
|
-
[attr.readonly]="options?.readonly ? 'readonly' : null"
|
|
24
|
-
[attr.step]="options?.multipleOf || options?.step || 'any'"
|
|
25
|
-
[class]="options?.fieldHtmlClass || ''"
|
|
26
|
-
[id]="'control' + layoutNode?._id"
|
|
27
|
-
[name]="controlName"
|
|
28
|
-
[readonly]="options?.readonly ? 'readonly' : null"
|
|
29
|
-
[title]="lastValidNumber"
|
|
30
|
-
[type]="layoutNode?.type === 'range' ? 'range' : 'number'">
|
|
31
|
-
<input *ngIf="!boundControl"
|
|
32
|
-
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
33
|
-
[attr.max]="options?.maximum"
|
|
34
|
-
[attr.min]="options?.minimum"
|
|
35
|
-
[attr.placeholder]="options?.placeholder"
|
|
36
|
-
[attr.required]="options?.required"
|
|
37
|
-
[attr.readonly]="options?.readonly ? 'readonly' : null"
|
|
38
|
-
[attr.step]="options?.multipleOf || options?.step || 'any'"
|
|
39
|
-
[class]="options?.fieldHtmlClass || ''"
|
|
40
|
-
[disabled]="controlDisabled"
|
|
41
|
-
[id]="'control' + layoutNode?._id"
|
|
42
|
-
[name]="controlName"
|
|
43
|
-
[readonly]="options?.readonly ? 'readonly' : null"
|
|
44
|
-
[title]="lastValidNumber"
|
|
45
|
-
[type]="layoutNode?.type === 'range' ? 'range' : 'number'"
|
|
46
|
-
[value]="controlValue"
|
|
47
|
-
(input)="updateValue($event)">
|
|
48
|
-
<span *ngIf="layoutNode?.type === 'range'" [innerHTML]="controlValue"></span>
|
|
49
|
-
</div>`,
|
|
50
|
-
})
|
|
51
|
-
export class NumberComponent implements OnInit {
|
|
52
|
-
formControl: AbstractControl;
|
|
53
|
-
controlName: string;
|
|
54
|
-
controlValue: any;
|
|
55
|
-
controlDisabled = false;
|
|
56
|
-
boundControl = false;
|
|
57
|
-
options: any;
|
|
58
|
-
allowNegative = true;
|
|
59
|
-
allowDecimal = true;
|
|
60
|
-
allowExponents = false;
|
|
61
|
-
lastValidNumber = '';
|
|
62
|
-
@Input() layoutNode: any;
|
|
63
|
-
@Input() layoutIndex: number[];
|
|
64
|
-
@Input() dataIndex: number[];
|
|
65
|
-
|
|
66
|
-
constructor(
|
|
67
|
-
private jsf: JsonSchemaFormService
|
|
68
|
-
) { }
|
|
69
|
-
|
|
70
|
-
ngOnInit() {
|
|
71
|
-
this.options = this.layoutNode.options || {};
|
|
72
|
-
this.jsf.initializeControl(this);
|
|
73
|
-
if (this.layoutNode.dataType === 'integer') { this.allowDecimal = false; }
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
updateValue(event) {
|
|
77
|
-
this.jsf.updateValue(this, event.target.value);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Component, Input, OnInit } from '@angular/core';
|
|
2
|
-
import { AbstractControl } from '@angular/forms';
|
|
3
|
-
|
|
4
|
-
import { JsonSchemaFormService } from '../json-schema-form.service';
|
|
5
|
-
|
|
6
|
-
// TODO: Add this control
|
|
7
|
-
|
|
8
|
-
@Component({
|
|
9
|
-
// tslint:disable-next-line:component-selector
|
|
10
|
-
selector: 'one-of-widget',
|
|
11
|
-
template: ``,
|
|
12
|
-
})
|
|
13
|
-
export class OneOfComponent implements OnInit {
|
|
14
|
-
formControl: AbstractControl;
|
|
15
|
-
controlName: string;
|
|
16
|
-
controlValue: any;
|
|
17
|
-
controlDisabled = false;
|
|
18
|
-
boundControl = false;
|
|
19
|
-
options: any;
|
|
20
|
-
@Input() layoutNode: any;
|
|
21
|
-
@Input() layoutIndex: number[];
|
|
22
|
-
@Input() dataIndex: number[];
|
|
23
|
-
|
|
24
|
-
constructor(
|
|
25
|
-
private jsf: JsonSchemaFormService
|
|
26
|
-
) { }
|
|
27
|
-
|
|
28
|
-
ngOnInit() {
|
|
29
|
-
this.options = this.layoutNode.options || {};
|
|
30
|
-
this.jsf.initializeControl(this);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
updateValue(event) {
|
|
34
|
-
this.jsf.updateValue(this, event.target.value);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Directive,
|
|
3
|
-
ElementRef,
|
|
4
|
-
Input,
|
|
5
|
-
NgZone,
|
|
6
|
-
OnInit
|
|
7
|
-
} from '@angular/core';
|
|
8
|
-
import { JsonSchemaFormService } from '../json-schema-form.service';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* OrderableDirective
|
|
13
|
-
*
|
|
14
|
-
* Enables array elements to be reordered by dragging and dropping.
|
|
15
|
-
*
|
|
16
|
-
* Only works for arrays that have at least two elements.
|
|
17
|
-
*
|
|
18
|
-
* Also detects arrays-within-arrays, and correctly moves either
|
|
19
|
-
* the child array element or the parent array element,
|
|
20
|
-
* depending on the drop targert.
|
|
21
|
-
*
|
|
22
|
-
* Listeners for movable element being dragged:
|
|
23
|
-
* - dragstart: add 'dragging' class to element, set effectAllowed = 'move'
|
|
24
|
-
* - dragover: set dropEffect = 'move'
|
|
25
|
-
* - dragend: remove 'dragging' class from element
|
|
26
|
-
*
|
|
27
|
-
* Listeners for stationary items being dragged over:
|
|
28
|
-
* - dragenter: add 'drag-target-...' classes to element
|
|
29
|
-
* - dragleave: remove 'drag-target-...' classes from element
|
|
30
|
-
* - drop: remove 'drag-target-...' classes from element, move dropped array item
|
|
31
|
-
*/
|
|
32
|
-
@Directive({
|
|
33
|
-
// tslint:disable-next-line:directive-selector
|
|
34
|
-
selector: '[orderable]',
|
|
35
|
-
})
|
|
36
|
-
export class OrderableDirective implements OnInit {
|
|
37
|
-
arrayLayoutIndex: string;
|
|
38
|
-
element: any;
|
|
39
|
-
overParentElement = false;
|
|
40
|
-
overChildElement = false;
|
|
41
|
-
@Input() orderable: boolean;
|
|
42
|
-
@Input() layoutNode: any;
|
|
43
|
-
@Input() layoutIndex: number[];
|
|
44
|
-
@Input() dataIndex: number[];
|
|
45
|
-
|
|
46
|
-
constructor(
|
|
47
|
-
private elementRef: ElementRef,
|
|
48
|
-
private jsf: JsonSchemaFormService,
|
|
49
|
-
private ngZone: NgZone
|
|
50
|
-
) { }
|
|
51
|
-
|
|
52
|
-
ngOnInit() {
|
|
53
|
-
if (this.orderable && this.layoutNode && this.layoutIndex && this.dataIndex) {
|
|
54
|
-
this.element = this.elementRef.nativeElement;
|
|
55
|
-
this.element.draggable = true;
|
|
56
|
-
this.arrayLayoutIndex = 'move:' + this.layoutIndex.slice(0, -1).toString();
|
|
57
|
-
|
|
58
|
-
this.ngZone.runOutsideAngular(() => {
|
|
59
|
-
|
|
60
|
-
// Listeners for movable element being dragged:
|
|
61
|
-
|
|
62
|
-
this.element.addEventListener('dragstart', (event) => {
|
|
63
|
-
event.dataTransfer.effectAllowed = 'move';
|
|
64
|
-
event.dataTransfer.setData('text', '');
|
|
65
|
-
// Hack to bypass stupid HTML drag-and-drop dataTransfer protection
|
|
66
|
-
// so drag source info will be available on dragenter
|
|
67
|
-
const sourceArrayIndex = this.dataIndex[this.dataIndex.length - 1];
|
|
68
|
-
sessionStorage.setItem(this.arrayLayoutIndex, sourceArrayIndex + '');
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
this.element.addEventListener('dragover', (event) => {
|
|
72
|
-
if (event.preventDefault) { event.preventDefault(); }
|
|
73
|
-
event.dataTransfer.dropEffect = 'move';
|
|
74
|
-
return false;
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
// Listeners for stationary items being dragged over:
|
|
78
|
-
|
|
79
|
-
this.element.addEventListener('dragenter', (event) => {
|
|
80
|
-
// Part 1 of a hack, inspired by Dragster, to simulate mouseover and mouseout
|
|
81
|
-
// behavior while dragging items - http://bensmithett.github.io/dragster/
|
|
82
|
-
if (this.overParentElement) {
|
|
83
|
-
return this.overChildElement = true;
|
|
84
|
-
} else {
|
|
85
|
-
this.overParentElement = true;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const sourceArrayIndex = sessionStorage.getItem(this.arrayLayoutIndex);
|
|
89
|
-
if (sourceArrayIndex !== null) {
|
|
90
|
-
if (this.dataIndex[this.dataIndex.length - 1] < +sourceArrayIndex) {
|
|
91
|
-
this.element.classList.add('drag-target-top');
|
|
92
|
-
} else if (this.dataIndex[this.dataIndex.length - 1] > +sourceArrayIndex) {
|
|
93
|
-
this.element.classList.add('drag-target-bottom');
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
this.element.addEventListener('dragleave', (event) => {
|
|
99
|
-
// Part 2 of the Dragster hack
|
|
100
|
-
if (this.overChildElement) {
|
|
101
|
-
this.overChildElement = false;
|
|
102
|
-
} else if (this.overParentElement) {
|
|
103
|
-
this.overParentElement = false;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const sourceArrayIndex = sessionStorage.getItem(this.arrayLayoutIndex);
|
|
107
|
-
if (!this.overParentElement && !this.overChildElement && sourceArrayIndex !== null) {
|
|
108
|
-
this.element.classList.remove('drag-target-top');
|
|
109
|
-
this.element.classList.remove('drag-target-bottom');
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
this.element.addEventListener('drop', (event) => {
|
|
114
|
-
this.element.classList.remove('drag-target-top');
|
|
115
|
-
this.element.classList.remove('drag-target-bottom');
|
|
116
|
-
// Confirm that drop target is another item in the same array as source item
|
|
117
|
-
const sourceArrayIndex = sessionStorage.getItem(this.arrayLayoutIndex);
|
|
118
|
-
const destArrayIndex = this.dataIndex[this.dataIndex.length - 1];
|
|
119
|
-
if (sourceArrayIndex !== null && +sourceArrayIndex !== destArrayIndex) {
|
|
120
|
-
// Move array item
|
|
121
|
-
this.jsf.moveArrayItem(this, +sourceArrayIndex, destArrayIndex);
|
|
122
|
-
}
|
|
123
|
-
sessionStorage.removeItem(this.arrayLayoutIndex);
|
|
124
|
-
return false;
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { AbstractControl } from '@angular/forms';
|
|
2
|
-
import { buildTitleMap } from '../shared';
|
|
3
|
-
import { Component, Input, OnInit } from '@angular/core';
|
|
4
|
-
import { JsonSchemaFormService } from '../json-schema-form.service';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
@Component({
|
|
8
|
-
// tslint:disable-next-line:component-selector
|
|
9
|
-
selector: 'radios-widget',
|
|
10
|
-
template: `
|
|
11
|
-
<label *ngIf="options?.title"
|
|
12
|
-
[attr.for]="'control' + layoutNode?._id"
|
|
13
|
-
[class]="options?.labelHtmlClass || ''"
|
|
14
|
-
[style.display]="options?.notitle ? 'none' : ''"
|
|
15
|
-
[innerHTML]="options?.title"></label>
|
|
16
|
-
|
|
17
|
-
<!-- 'horizontal' = radios-inline or radiobuttons -->
|
|
18
|
-
<div *ngIf="layoutOrientation === 'horizontal'"
|
|
19
|
-
[class]="options?.htmlClass || ''">
|
|
20
|
-
<label *ngFor="let radioItem of radiosList"
|
|
21
|
-
[attr.for]="'control' + layoutNode?._id + '/' + radioItem?.value"
|
|
22
|
-
[class]="(options?.itemLabelHtmlClass || '') +
|
|
23
|
-
((controlValue + '' === radioItem?.value + '') ?
|
|
24
|
-
(' ' + (options?.activeClass || '') + ' ' + (options?.style?.selected || '')) :
|
|
25
|
-
(' ' + (options?.style?.unselected || '')))">
|
|
26
|
-
<input type="radio"
|
|
27
|
-
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
28
|
-
[attr.readonly]="options?.readonly ? 'readonly' : null"
|
|
29
|
-
[attr.required]="options?.required"
|
|
30
|
-
[checked]="radioItem?.value === controlValue"
|
|
31
|
-
[class]="options?.fieldHtmlClass || ''"
|
|
32
|
-
[disabled]="controlDisabled"
|
|
33
|
-
[id]="'control' + layoutNode?._id + '/' + radioItem?.value"
|
|
34
|
-
[name]="controlName"
|
|
35
|
-
[value]="radioItem?.value"
|
|
36
|
-
(change)="updateValue($event)">
|
|
37
|
-
<span [innerHTML]="radioItem?.name"></span>
|
|
38
|
-
</label>
|
|
39
|
-
</div>
|
|
40
|
-
|
|
41
|
-
<!-- 'vertical' = regular radios -->
|
|
42
|
-
<div *ngIf="layoutOrientation !== 'horizontal'">
|
|
43
|
-
<div *ngFor="let radioItem of radiosList"
|
|
44
|
-
[class]="options?.htmlClass || ''">
|
|
45
|
-
<label
|
|
46
|
-
[attr.for]="'control' + layoutNode?._id + '/' + radioItem?.value"
|
|
47
|
-
[class]="(options?.itemLabelHtmlClass || '') +
|
|
48
|
-
((controlValue + '' === radioItem?.value + '') ?
|
|
49
|
-
(' ' + (options?.activeClass || '') + ' ' + (options?.style?.selected || '')) :
|
|
50
|
-
(' ' + (options?.style?.unselected || '')))">
|
|
51
|
-
<input type="radio"
|
|
52
|
-
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
53
|
-
[attr.readonly]="options?.readonly ? 'readonly' : null"
|
|
54
|
-
[attr.required]="options?.required"
|
|
55
|
-
[checked]="radioItem?.value === controlValue"
|
|
56
|
-
[class]="options?.fieldHtmlClass || ''"
|
|
57
|
-
[disabled]="controlDisabled"
|
|
58
|
-
[id]="'control' + layoutNode?._id + '/' + radioItem?.value"
|
|
59
|
-
[name]="controlName"
|
|
60
|
-
[value]="radioItem?.value"
|
|
61
|
-
(change)="updateValue($event)">
|
|
62
|
-
<span [innerHTML]="radioItem?.name"></span>
|
|
63
|
-
</label>
|
|
64
|
-
</div>
|
|
65
|
-
</div>`,
|
|
66
|
-
})
|
|
67
|
-
export class RadiosComponent implements OnInit {
|
|
68
|
-
formControl: AbstractControl;
|
|
69
|
-
controlName: string;
|
|
70
|
-
controlValue: any;
|
|
71
|
-
controlDisabled = false;
|
|
72
|
-
boundControl = false;
|
|
73
|
-
options: any;
|
|
74
|
-
layoutOrientation = 'vertical';
|
|
75
|
-
radiosList: any[] = [];
|
|
76
|
-
@Input() layoutNode: any;
|
|
77
|
-
@Input() layoutIndex: number[];
|
|
78
|
-
@Input() dataIndex: number[];
|
|
79
|
-
|
|
80
|
-
constructor(
|
|
81
|
-
private jsf: JsonSchemaFormService
|
|
82
|
-
) { }
|
|
83
|
-
|
|
84
|
-
ngOnInit() {
|
|
85
|
-
this.options = this.layoutNode.options || {};
|
|
86
|
-
if (this.layoutNode.type === 'radios-inline' ||
|
|
87
|
-
this.layoutNode.type === 'radiobuttons'
|
|
88
|
-
) {
|
|
89
|
-
this.layoutOrientation = 'horizontal';
|
|
90
|
-
}
|
|
91
|
-
this.radiosList = buildTitleMap(
|
|
92
|
-
this.options.titleMap || this.options.enumNames,
|
|
93
|
-
this.options.enum, true
|
|
94
|
-
);
|
|
95
|
-
this.jsf.initializeControl(this);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
updateValue(event) {
|
|
99
|
-
this.jsf.updateValue(this, event.target.value);
|
|
100
|
-
}
|
|
101
|
-
}
|