@ng-formworks/core 15.2.7

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.
Files changed (67) hide show
  1. package/karma.conf.js +46 -0
  2. package/ng-package.json +11 -0
  3. package/package.json +54 -0
  4. package/src/lib/framework-library/framework-library.service.ts +195 -0
  5. package/src/lib/framework-library/framework.ts +11 -0
  6. package/src/lib/framework-library/no-framework.component.html +2 -0
  7. package/src/lib/framework-library/no-framework.component.ts +11 -0
  8. package/src/lib/framework-library/no-framework.module.ts +18 -0
  9. package/src/lib/framework-library/no.framework.ts +11 -0
  10. package/src/lib/json-schema-form.component.html +7 -0
  11. package/src/lib/json-schema-form.component.ts +809 -0
  12. package/src/lib/json-schema-form.module.ts +17 -0
  13. package/src/lib/json-schema-form.service.ts +907 -0
  14. package/src/lib/locale/de-validation-messages.ts +58 -0
  15. package/src/lib/locale/en-validation-messages.ts +58 -0
  16. package/src/lib/locale/es-validation-messages.ts +55 -0
  17. package/src/lib/locale/fr-validation-messages.ts +58 -0
  18. package/src/lib/locale/index.ts +7 -0
  19. package/src/lib/locale/it-validation-messages.ts +58 -0
  20. package/src/lib/locale/pt-validation-messages.ts +58 -0
  21. package/src/lib/locale/zh-validation-messages.ts +58 -0
  22. package/src/lib/locale-dates/en-US.ts +5 -0
  23. package/src/lib/shared/convert-schema-to-draft6.function.ts +321 -0
  24. package/src/lib/shared/form-group.functions.ts +522 -0
  25. package/src/lib/shared/format-regex.constants.ts +73 -0
  26. package/src/lib/shared/index.ts +40 -0
  27. package/src/lib/shared/json-schema.functions.ts +788 -0
  28. package/src/lib/shared/json.validators.ts +878 -0
  29. package/src/lib/shared/jsonpointer.functions.ts +1012 -0
  30. package/src/lib/shared/jspointer.functions.json.spec.ts +103 -0
  31. package/src/lib/shared/layout.functions.ts +1233 -0
  32. package/src/lib/shared/merge-schemas.function.ts +329 -0
  33. package/src/lib/shared/utility.functions.ts +373 -0
  34. package/src/lib/shared/validator.functions.spec.ts +55 -0
  35. package/src/lib/shared/validator.functions.ts +601 -0
  36. package/src/lib/widget-library/add-reference.component.ts +59 -0
  37. package/src/lib/widget-library/button.component.ts +54 -0
  38. package/src/lib/widget-library/checkbox.component.ts +74 -0
  39. package/src/lib/widget-library/checkboxes.component.ts +104 -0
  40. package/src/lib/widget-library/file.component.ts +36 -0
  41. package/src/lib/widget-library/hidden.component.ts +39 -0
  42. package/src/lib/widget-library/index.ts +56 -0
  43. package/src/lib/widget-library/input.component.ts +76 -0
  44. package/src/lib/widget-library/message.component.ts +29 -0
  45. package/src/lib/widget-library/none.component.ts +12 -0
  46. package/src/lib/widget-library/number.component.ts +79 -0
  47. package/src/lib/widget-library/one-of.component.ts +36 -0
  48. package/src/lib/widget-library/orderable.directive.ts +130 -0
  49. package/src/lib/widget-library/radios.component.ts +101 -0
  50. package/src/lib/widget-library/root.component.ts +78 -0
  51. package/src/lib/widget-library/section.component.ts +133 -0
  52. package/src/lib/widget-library/select-framework.component.ts +50 -0
  53. package/src/lib/widget-library/select-widget.component.ts +46 -0
  54. package/src/lib/widget-library/select.component.ts +96 -0
  55. package/src/lib/widget-library/submit.component.ts +68 -0
  56. package/src/lib/widget-library/tab.component.ts +29 -0
  57. package/src/lib/widget-library/tabs.component.ts +83 -0
  58. package/src/lib/widget-library/template.component.ts +52 -0
  59. package/src/lib/widget-library/textarea.component.ts +68 -0
  60. package/src/lib/widget-library/widget-library.module.ts +13 -0
  61. package/src/lib/widget-library/widget-library.service.ts +234 -0
  62. package/src/public_api.ts +21 -0
  63. package/src/test.ts +18 -0
  64. package/tsconfig.lib.json +25 -0
  65. package/tsconfig.lib.prod.json +9 -0
  66. package/tsconfig.spec.json +17 -0
  67. package/tslint.json +11 -0
@@ -0,0 +1,54 @@
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: 'button-widget',
9
+ template: `
10
+ <div
11
+ [class]="options?.htmlClass || ''">
12
+ <button
13
+ [attr.readonly]="options?.readonly ? 'readonly' : null"
14
+ [attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
15
+ [class]="options?.fieldHtmlClass || ''"
16
+ [disabled]="controlDisabled"
17
+ [name]="controlName"
18
+ [type]="layoutNode?.type"
19
+ [value]="controlValue"
20
+ (click)="updateValue($event)">
21
+ <span *ngIf="options?.icon || options?.title"
22
+ [class]="options?.icon"
23
+ [innerHTML]="options?.title"></span>
24
+ </button>
25
+ </div>`,
26
+ })
27
+ export class ButtonComponent implements OnInit {
28
+ formControl: AbstractControl;
29
+ controlName: string;
30
+ controlValue: any;
31
+ controlDisabled = false;
32
+ boundControl = false;
33
+ options: any;
34
+ @Input() layoutNode: any;
35
+ @Input() layoutIndex: number[];
36
+ @Input() dataIndex: number[];
37
+
38
+ constructor(
39
+ private jsf: JsonSchemaFormService
40
+ ) { }
41
+
42
+ ngOnInit() {
43
+ this.options = this.layoutNode.options || {};
44
+ this.jsf.initializeControl(this);
45
+ }
46
+
47
+ updateValue(event) {
48
+ if (typeof this.options.onClick === 'function') {
49
+ this.options.onClick(event);
50
+ } else {
51
+ this.jsf.updateValue(this, event.target.value);
52
+ }
53
+ }
54
+ }
@@ -0,0 +1,74 @@
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: 'checkbox-widget',
9
+ template: `
10
+ <label
11
+ [attr.for]="'control' + layoutNode?._id"
12
+ [class]="options?.itemLabelHtmlClass || ''">
13
+ <input *ngIf="boundControl"
14
+ [formControl]="formControl"
15
+ [attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
16
+ [class]="(options?.fieldHtmlClass || '') + (isChecked ?
17
+ (' ' + (options?.activeClass || '') + ' ' + (options?.style?.selected || '')) :
18
+ (' ' + (options?.style?.unselected || '')))"
19
+ [id]="'control' + layoutNode?._id"
20
+ [name]="controlName"
21
+ [readonly]="options?.readonly ? 'readonly' : null"
22
+ type="checkbox">
23
+ <input *ngIf="!boundControl"
24
+ [attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
25
+ [checked]="isChecked ? 'checked' : null"
26
+ [class]="(options?.fieldHtmlClass || '') + (isChecked ?
27
+ (' ' + (options?.activeClass || '') + ' ' + (options?.style?.selected || '')) :
28
+ (' ' + (options?.style?.unselected || '')))"
29
+ [disabled]="controlDisabled"
30
+ [id]="'control' + layoutNode?._id"
31
+ [name]="controlName"
32
+ [readonly]="options?.readonly ? 'readonly' : null"
33
+ [value]="controlValue"
34
+ type="checkbox"
35
+ (change)="updateValue($event)">
36
+ <span *ngIf="options?.title"
37
+ [style.display]="options?.notitle ? 'none' : ''"
38
+ [innerHTML]="options?.title"></span>
39
+ </label>`,
40
+ })
41
+ export class CheckboxComponent implements OnInit {
42
+ formControl: AbstractControl;
43
+ controlName: string;
44
+ controlValue: any;
45
+ controlDisabled = false;
46
+ boundControl = false;
47
+ options: any;
48
+ trueValue: any = true;
49
+ falseValue: any = false;
50
+ @Input() layoutNode: any;
51
+ @Input() layoutIndex: number[];
52
+ @Input() dataIndex: number[];
53
+
54
+ constructor(
55
+ private jsf: JsonSchemaFormService
56
+ ) { }
57
+
58
+ ngOnInit() {
59
+ this.options = this.layoutNode.options || {};
60
+ this.jsf.initializeControl(this);
61
+ if (this.controlValue === null || this.controlValue === undefined) {
62
+ this.controlValue = this.options.title;
63
+ }
64
+ }
65
+
66
+ updateValue(event) {
67
+ event.preventDefault();
68
+ this.jsf.updateValue(this, event.target.checked ? this.trueValue : this.falseValue);
69
+ }
70
+
71
+ get isChecked() {
72
+ return this.jsf.getFormControlValue(this) === this.trueValue;
73
+ }
74
+ }
@@ -0,0 +1,104 @@
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
+ }
@@ -0,0 +1,36 @@
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
+ }
@@ -0,0 +1,39 @@
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
+ }
@@ -0,0 +1,56 @@
1
+ import { AddReferenceComponent } from './add-reference.component';
2
+ import { ButtonComponent } from './button.component';
3
+ import { CheckboxComponent } from './checkbox.component';
4
+ import { CheckboxesComponent } from './checkboxes.component';
5
+ import { FileComponent } from './file.component';
6
+ import { HiddenComponent } from './hidden.component';
7
+ import { InputComponent } from './input.component';
8
+ import { MessageComponent } from './message.component';
9
+ import { NoneComponent } from './none.component';
10
+ import { NumberComponent } from './number.component';
11
+ import { OneOfComponent } from './one-of.component';
12
+ import { RadiosComponent } from './radios.component';
13
+ import { RootComponent } from './root.component';
14
+ import { SectionComponent } from './section.component';
15
+ import { SelectComponent } from './select.component';
16
+ import { SelectFrameworkComponent } from './select-framework.component';
17
+ import { SelectWidgetComponent } from './select-widget.component';
18
+ import { SubmitComponent } from './submit.component';
19
+ import { TabComponent } from './tab.component';
20
+ import { TabsComponent } from './tabs.component';
21
+ import { TemplateComponent } from './template.component';
22
+ import { TextareaComponent } from './textarea.component';
23
+
24
+ export const BASIC_WIDGETS = [
25
+ AddReferenceComponent, OneOfComponent, ButtonComponent, CheckboxComponent,
26
+ CheckboxesComponent, FileComponent, HiddenComponent, InputComponent,
27
+ MessageComponent, NoneComponent, NumberComponent, RadiosComponent,
28
+ RootComponent, SectionComponent, SelectComponent, SelectFrameworkComponent,
29
+ SelectWidgetComponent, SubmitComponent, TabComponent, TabsComponent,
30
+ TemplateComponent, TextareaComponent
31
+ ];
32
+
33
+ export { AddReferenceComponent } from './add-reference.component';
34
+ export { OneOfComponent } from './one-of.component';
35
+ export { ButtonComponent } from './button.component';
36
+ export { CheckboxComponent } from './checkbox.component';
37
+ export { CheckboxesComponent } from './checkboxes.component';
38
+ export { FileComponent } from './file.component';
39
+ export { HiddenComponent } from './hidden.component';
40
+ export { InputComponent } from './input.component';
41
+ export { MessageComponent } from './message.component';
42
+ export { NoneComponent } from './none.component';
43
+ export { NumberComponent } from './number.component';
44
+ export { OrderableDirective } from './orderable.directive';
45
+ export { RadiosComponent } from './radios.component';
46
+ export { RootComponent } from './root.component';
47
+ export { SectionComponent } from './section.component';
48
+ export { SelectComponent } from './select.component';
49
+ export { SelectFrameworkComponent } from './select-framework.component';
50
+ export { SelectWidgetComponent } from './select-widget.component';
51
+ export { SubmitComponent } from './submit.component';
52
+ export { TabComponent } from './tab.component';
53
+ export { TabsComponent } from './tabs.component';
54
+ export { TemplateComponent } from './template.component';
55
+ export { TextareaComponent } from './textarea.component';
56
+ export { WidgetLibraryService } from './widget-library.service';
@@ -0,0 +1,76 @@
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
+ }
@@ -0,0 +1,29 @@
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
+ }
@@ -0,0 +1,12 @@
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
+ }
@@ -0,0 +1,79 @@
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
+ }
@@ -0,0 +1,36 @@
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
+ }