@ng-formworks/core 17.2.7 → 18.0.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.
Files changed (177) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +834 -0
  3. package/esm2022/lib/framework-library/framework-library.service.mjs +175 -0
  4. package/esm2022/lib/framework-library/framework.mjs +15 -0
  5. package/esm2022/lib/framework-library/no-framework.component.mjs +18 -0
  6. package/esm2022/lib/framework-library/no-framework.module.mjs +27 -0
  7. package/esm2022/lib/framework-library/no.framework.mjs +19 -0
  8. package/esm2022/lib/json-schema-form.component.mjs +765 -0
  9. package/esm2022/lib/json-schema-form.module.mjs +26 -0
  10. package/esm2022/lib/json-schema-form.service.mjs +676 -0
  11. package/esm2022/lib/locale/de-validation-messages.mjs +60 -0
  12. package/esm2022/lib/locale/en-validation-messages.mjs +60 -0
  13. package/esm2022/lib/locale/es-validation-messages.mjs +57 -0
  14. package/esm2022/lib/locale/fr-validation-messages.mjs +60 -0
  15. package/esm2022/lib/locale/index.mjs +8 -0
  16. package/esm2022/lib/locale/it-validation-messages.mjs +60 -0
  17. package/esm2022/lib/locale/pt-validation-messages.mjs +60 -0
  18. package/esm2022/lib/locale/zh-validation-messages.mjs +60 -0
  19. package/esm2022/lib/shared/convert-schema-to-draft6.function.mjs +300 -0
  20. package/esm2022/lib/shared/form-group.functions.mjs +442 -0
  21. package/esm2022/lib/shared/format-regex.constants.mjs +54 -0
  22. package/esm2022/lib/shared/index.mjs +12 -0
  23. package/esm2022/lib/shared/json-schema.functions.mjs +784 -0
  24. package/esm2022/lib/shared/json.validators.mjs +884 -0
  25. package/esm2022/lib/shared/jsonpointer.functions.mjs +1026 -0
  26. package/esm2022/lib/shared/layout.functions.mjs +1158 -0
  27. package/esm2022/lib/shared/merge-schemas.function.mjs +345 -0
  28. package/esm2022/lib/shared/utility.functions.mjs +380 -0
  29. package/esm2022/lib/shared/validator.functions.mjs +584 -0
  30. package/esm2022/lib/widget-library/add-reference.component.mjs +61 -0
  31. package/esm2022/lib/widget-library/button.component.mjs +72 -0
  32. package/esm2022/lib/widget-library/checkbox.component.mjs +105 -0
  33. package/esm2022/lib/widget-library/checkboxes.component.mjs +147 -0
  34. package/esm2022/lib/widget-library/file.component.mjs +35 -0
  35. package/esm2022/lib/widget-library/hidden.component.mjs +54 -0
  36. package/esm2022/lib/widget-library/index.mjs +55 -0
  37. package/esm2022/lib/widget-library/input.component.mjs +119 -0
  38. package/esm2022/lib/widget-library/message.component.mjs +38 -0
  39. package/esm2022/lib/widget-library/none.component.mjs +21 -0
  40. package/esm2022/lib/widget-library/number.component.mjs +123 -0
  41. package/esm2022/lib/widget-library/one-of.component.mjs +35 -0
  42. package/esm2022/lib/widget-library/orderable.directive.mjs +123 -0
  43. package/esm2022/lib/widget-library/radios.component.mjs +153 -0
  44. package/esm2022/lib/widget-library/root.component.mjs +79 -0
  45. package/esm2022/lib/widget-library/section.component.mjs +199 -0
  46. package/esm2022/lib/widget-library/select-framework.component.mjs +51 -0
  47. package/esm2022/lib/widget-library/select-widget.component.mjs +46 -0
  48. package/esm2022/lib/widget-library/select.component.mjs +150 -0
  49. package/esm2022/lib/widget-library/submit.component.mjs +82 -0
  50. package/esm2022/lib/widget-library/tab.component.mjs +41 -0
  51. package/esm2022/lib/widget-library/tabs.component.mjs +108 -0
  52. package/esm2022/lib/widget-library/template.component.mjs +46 -0
  53. package/esm2022/lib/widget-library/textarea.component.mjs +104 -0
  54. package/esm2022/lib/widget-library/widget-library.module.mjs +42 -0
  55. package/esm2022/lib/widget-library/widget-library.service.mjs +226 -0
  56. package/esm2022/ng-formworks-core.mjs +5 -0
  57. package/esm2022/public_api.mjs +13 -0
  58. package/fesm2022/ng-formworks-core.mjs +10151 -0
  59. package/fesm2022/ng-formworks-core.mjs.map +1 -0
  60. package/index.d.ts +5 -0
  61. package/lib/framework-library/framework-library.service.d.ts +55 -0
  62. package/lib/framework-library/framework.d.ts +13 -0
  63. package/lib/framework-library/no-framework.component.d.ts +8 -0
  64. package/lib/framework-library/no-framework.module.d.ts +9 -0
  65. package/lib/framework-library/no.framework.d.ts +10 -0
  66. package/lib/json-schema-form.component.d.ts +218 -0
  67. package/lib/json-schema-form.module.d.ts +11 -0
  68. package/lib/json-schema-form.service.d.ts +115 -0
  69. package/lib/locale/de-validation-messages.d.ts +1 -0
  70. package/lib/locale/en-validation-messages.d.ts +1 -0
  71. package/lib/locale/es-validation-messages.d.ts +1 -0
  72. package/lib/locale/fr-validation-messages.d.ts +1 -0
  73. package/{src/lib/locale/index.ts → lib/locale/index.d.ts} +7 -7
  74. package/lib/locale/it-validation-messages.d.ts +1 -0
  75. package/lib/locale/pt-validation-messages.d.ts +1 -0
  76. package/lib/locale/zh-validation-messages.d.ts +1 -0
  77. package/lib/shared/convert-schema-to-draft6.function.d.ts +21 -0
  78. package/lib/shared/form-group.functions.d.ts +100 -0
  79. package/lib/shared/format-regex.constants.d.ts +19 -0
  80. package/lib/shared/index.d.ts +9 -0
  81. package/lib/shared/json-schema.functions.d.ts +193 -0
  82. package/lib/shared/json.validators.d.ts +441 -0
  83. package/lib/shared/jsonpointer.functions.d.ts +416 -0
  84. package/lib/shared/layout.functions.d.ts +83 -0
  85. package/lib/shared/merge-schemas.function.d.ts +19 -0
  86. package/lib/shared/utility.functions.d.ts +165 -0
  87. package/{src/lib/shared/validator.functions.ts → lib/shared/validator.functions.d.ts} +364 -601
  88. package/lib/widget-library/add-reference.component.d.ts +20 -0
  89. package/lib/widget-library/button.component.d.ts +21 -0
  90. package/lib/widget-library/checkbox.component.d.ts +24 -0
  91. package/lib/widget-library/checkboxes.component.d.ts +24 -0
  92. package/lib/widget-library/file.component.d.ts +21 -0
  93. package/lib/widget-library/hidden.component.d.ts +19 -0
  94. package/{src/lib/widget-library/index.ts → lib/widget-library/index.d.ts} +47 -56
  95. package/lib/widget-library/input.component.d.ts +22 -0
  96. package/lib/widget-library/message.component.d.ts +15 -0
  97. package/lib/widget-library/none.component.d.ts +8 -0
  98. package/lib/widget-library/number.component.d.ts +25 -0
  99. package/lib/widget-library/one-of.component.d.ts +21 -0
  100. package/lib/widget-library/orderable.directive.d.ts +41 -0
  101. package/lib/widget-library/radios.component.d.ts +23 -0
  102. package/lib/widget-library/root.component.d.ts +17 -0
  103. package/lib/widget-library/section.component.d.ts +19 -0
  104. package/lib/widget-library/select-framework.component.d.ts +18 -0
  105. package/lib/widget-library/select-widget.component.d.ts +18 -0
  106. package/lib/widget-library/select.component.d.ts +24 -0
  107. package/lib/widget-library/submit.component.d.ts +24 -0
  108. package/lib/widget-library/tab.component.d.ts +14 -0
  109. package/lib/widget-library/tabs.component.d.ts +20 -0
  110. package/lib/widget-library/template.component.d.ts +18 -0
  111. package/lib/widget-library/textarea.component.d.ts +21 -0
  112. package/lib/widget-library/widget-library.module.d.ts +31 -0
  113. package/lib/widget-library/widget-library.service.d.ts +22 -0
  114. package/package.json +66 -53
  115. package/{src/public_api.ts → public_api.d.ts} +9 -21
  116. package/karma.conf.js +0 -46
  117. package/ng-package.json +0 -11
  118. package/src/lib/framework-library/framework-library.service.ts +0 -195
  119. package/src/lib/framework-library/framework.ts +0 -11
  120. package/src/lib/framework-library/no-framework.component.html +0 -2
  121. package/src/lib/framework-library/no-framework.component.ts +0 -11
  122. package/src/lib/framework-library/no-framework.module.ts +0 -18
  123. package/src/lib/framework-library/no.framework.ts +0 -11
  124. package/src/lib/json-schema-form.component.html +0 -7
  125. package/src/lib/json-schema-form.component.ts +0 -809
  126. package/src/lib/json-schema-form.module.ts +0 -17
  127. package/src/lib/json-schema-form.service.ts +0 -907
  128. package/src/lib/locale/de-validation-messages.ts +0 -58
  129. package/src/lib/locale/en-validation-messages.ts +0 -58
  130. package/src/lib/locale/es-validation-messages.ts +0 -55
  131. package/src/lib/locale/fr-validation-messages.ts +0 -58
  132. package/src/lib/locale/it-validation-messages.ts +0 -58
  133. package/src/lib/locale/pt-validation-messages.ts +0 -58
  134. package/src/lib/locale/zh-validation-messages.ts +0 -58
  135. package/src/lib/locale-dates/en-US.ts +0 -5
  136. package/src/lib/shared/convert-schema-to-draft6.function.ts +0 -321
  137. package/src/lib/shared/form-group.functions.ts +0 -522
  138. package/src/lib/shared/format-regex.constants.ts +0 -73
  139. package/src/lib/shared/index.ts +0 -40
  140. package/src/lib/shared/json-schema.functions.ts +0 -788
  141. package/src/lib/shared/json.validators.ts +0 -878
  142. package/src/lib/shared/jsonpointer.functions.ts +0 -1012
  143. package/src/lib/shared/jspointer.functions.json.spec.ts +0 -103
  144. package/src/lib/shared/layout.functions.ts +0 -1233
  145. package/src/lib/shared/merge-schemas.function.ts +0 -329
  146. package/src/lib/shared/utility.functions.ts +0 -373
  147. package/src/lib/shared/validator.functions.spec.ts +0 -55
  148. package/src/lib/widget-library/add-reference.component.ts +0 -59
  149. package/src/lib/widget-library/button.component.ts +0 -54
  150. package/src/lib/widget-library/checkbox.component.ts +0 -74
  151. package/src/lib/widget-library/checkboxes.component.ts +0 -104
  152. package/src/lib/widget-library/file.component.ts +0 -36
  153. package/src/lib/widget-library/hidden.component.ts +0 -39
  154. package/src/lib/widget-library/input.component.ts +0 -76
  155. package/src/lib/widget-library/message.component.ts +0 -29
  156. package/src/lib/widget-library/none.component.ts +0 -12
  157. package/src/lib/widget-library/number.component.ts +0 -79
  158. package/src/lib/widget-library/one-of.component.ts +0 -36
  159. package/src/lib/widget-library/orderable.directive.ts +0 -130
  160. package/src/lib/widget-library/radios.component.ts +0 -101
  161. package/src/lib/widget-library/root.component.ts +0 -78
  162. package/src/lib/widget-library/section.component.ts +0 -133
  163. package/src/lib/widget-library/select-framework.component.ts +0 -50
  164. package/src/lib/widget-library/select-widget.component.ts +0 -46
  165. package/src/lib/widget-library/select.component.ts +0 -96
  166. package/src/lib/widget-library/submit.component.ts +0 -68
  167. package/src/lib/widget-library/tab.component.ts +0 -29
  168. package/src/lib/widget-library/tabs.component.ts +0 -83
  169. package/src/lib/widget-library/template.component.ts +0 -52
  170. package/src/lib/widget-library/textarea.component.ts +0 -68
  171. package/src/lib/widget-library/widget-library.module.ts +0 -13
  172. package/src/lib/widget-library/widget-library.service.ts +0 -234
  173. package/src/test.ts +0 -18
  174. package/tsconfig.lib.json +0 -25
  175. package/tsconfig.lib.prod.json +0 -9
  176. package/tsconfig.spec.json +0 -17
  177. package/tslint.json +0 -11
@@ -1,78 +0,0 @@
1
- import { Component, Input } from '@angular/core';
2
- import { JsonSchemaFormService } from '../json-schema-form.service';
3
-
4
-
5
- @Component({
6
- // tslint:disable-next-line:component-selector
7
- selector: 'root-widget',
8
- template: `
9
- <div *ngFor="let layoutItem of layout; let i = index"
10
- [class.form-flex-item]="isFlexItem"
11
- [style.align-self]="(layoutItem.options || {})['align-self']"
12
- [style.flex-basis]="getFlexAttribute(layoutItem, 'flex-basis')"
13
- [style.flex-grow]="getFlexAttribute(layoutItem, 'flex-grow')"
14
- [style.flex-shrink]="getFlexAttribute(layoutItem, 'flex-shrink')"
15
- [style.order]="(layoutItem.options || {}).order">
16
- <div
17
- [dataIndex]="layoutItem?.arrayItem ? (dataIndex || []).concat(i) : (dataIndex || [])"
18
- [layoutIndex]="(layoutIndex || []).concat(i)"
19
- [layoutNode]="layoutItem"
20
- [orderable]="isDraggable(layoutItem)">
21
- <select-framework-widget *ngIf="showWidget(layoutItem)"
22
- [dataIndex]="layoutItem?.arrayItem ? (dataIndex || []).concat(i) : (dataIndex || [])"
23
- [layoutIndex]="(layoutIndex || []).concat(i)"
24
- [layoutNode]="layoutItem"></select-framework-widget>
25
- </div>
26
- </div>`,
27
- styles: [`
28
- [draggable=true] {
29
- transition: all 150ms cubic-bezier(.4, 0, .2, 1);
30
- }
31
- [draggable=true]:hover {
32
- cursor: move;
33
- box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
34
- position: relative; z-index: 10;
35
- margin-top: -1px;
36
- margin-left: -1px;
37
- margin-right: 1px;
38
- margin-bottom: 1px;
39
- }
40
- [draggable=true].drag-target-top {
41
- box-shadow: 0 -2px 0 #000;
42
- position: relative; z-index: 20;
43
- }
44
- [draggable=true].drag-target-bottom {
45
- box-shadow: 0 2px 0 #000;
46
- position: relative; z-index: 20;
47
- }
48
- `],
49
- })
50
- export class RootComponent {
51
- options: any;
52
- @Input() dataIndex: number[];
53
- @Input() layoutIndex: number[];
54
- @Input() layout: any[];
55
- @Input() isOrderable: boolean;
56
- @Input() isFlexItem = false;
57
-
58
- constructor(
59
- private jsf: JsonSchemaFormService
60
- ) { }
61
-
62
- isDraggable(node: any): boolean {
63
- return node.arrayItem && node.type !== '$ref' &&
64
- node.arrayItemType === 'list' && this.isOrderable !== false;
65
- }
66
-
67
- // Set attributes for flexbox child
68
- // (container attributes are set in section.component)
69
- getFlexAttribute(node: any, attribute: string) {
70
- const index = ['flex-grow', 'flex-shrink', 'flex-basis'].indexOf(attribute);
71
- return ((node.options || {}).flex || '').split(/\s+/)[index] ||
72
- (node.options || {})[attribute] || ['1', '1', 'auto'][index];
73
- }
74
-
75
- showWidget(layoutNode: any): boolean {
76
- return this.jsf.evaluateCondition(layoutNode, this.dataIndex);
77
- }
78
- }
@@ -1,133 +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: 'section-widget',
8
- template: `
9
- <div *ngIf="containerType === 'div'"
10
- [class]="options?.htmlClass || ''"
11
- [class.expandable]="options?.expandable && !expanded"
12
- [class.expanded]="options?.expandable && expanded">
13
- <label *ngIf="sectionTitle"
14
- class="legend"
15
- [class]="options?.labelHtmlClass || ''"
16
- [innerHTML]="sectionTitle"
17
- (click)="toggleExpanded()"></label>
18
- <root-widget *ngIf="expanded"
19
- [dataIndex]="dataIndex"
20
- [layout]="layoutNode.items"
21
- [layoutIndex]="layoutIndex"
22
- [isFlexItem]="getFlexAttribute('is-flex')"
23
- [isOrderable]="options?.orderable"
24
- [class.form-flex-column]="getFlexAttribute('flex-direction') === 'column'"
25
- [class.form-flex-row]="getFlexAttribute('flex-direction') === 'row'"
26
- [style.align-content]="getFlexAttribute('align-content')"
27
- [style.align-items]="getFlexAttribute('align-items')"
28
- [style.display]="getFlexAttribute('display')"
29
- [style.flex-direction]="getFlexAttribute('flex-direction')"
30
- [style.flex-wrap]="getFlexAttribute('flex-wrap')"
31
- [style.justify-content]="getFlexAttribute('justify-content')"></root-widget>
32
- </div>
33
- <fieldset *ngIf="containerType === 'fieldset'"
34
- [class]="options?.htmlClass || ''"
35
- [class.expandable]="options?.expandable && !expanded"
36
- [class.expanded]="options?.expandable && expanded"
37
- [disabled]="options?.readonly">
38
- <legend *ngIf="sectionTitle"
39
- class="legend"
40
- [class]="options?.labelHtmlClass || ''"
41
- [innerHTML]="sectionTitle"
42
- (click)="toggleExpanded()"></legend>
43
- <div *ngIf="options?.messageLocation !== 'bottom'">
44
- <p *ngIf="options?.description"
45
- class="help-block"
46
- [class]="options?.labelHelpBlockClass || ''"
47
- [innerHTML]="options?.description"></p>
48
- </div>
49
- <root-widget *ngIf="expanded"
50
- [dataIndex]="dataIndex"
51
- [layout]="layoutNode.items"
52
- [layoutIndex]="layoutIndex"
53
- [isFlexItem]="getFlexAttribute('is-flex')"
54
- [isOrderable]="options?.orderable"
55
- [class.form-flex-column]="getFlexAttribute('flex-direction') === 'column'"
56
- [class.form-flex-row]="getFlexAttribute('flex-direction') === 'row'"
57
- [style.align-content]="getFlexAttribute('align-content')"
58
- [style.align-items]="getFlexAttribute('align-items')"
59
- [style.display]="getFlexAttribute('display')"
60
- [style.flex-direction]="getFlexAttribute('flex-direction')"
61
- [style.flex-wrap]="getFlexAttribute('flex-wrap')"
62
- [style.justify-content]="getFlexAttribute('justify-content')"></root-widget>
63
- <div *ngIf="options?.messageLocation === 'bottom'">
64
- <p *ngIf="options?.description"
65
- class="help-block"
66
- [class]="options?.labelHelpBlockClass || ''"
67
- [innerHTML]="options?.description"></p>
68
- </div>
69
- </fieldset>`,
70
- styles: [`
71
- .legend { font-weight: bold; }
72
- .expandable > legend:before, .expandable > label:before { content: '▶'; padding-right: .3em; }
73
- .expanded > legend:before, .expanded > label:before { content: '▼'; padding-right: .2em; }
74
- `],
75
- })
76
- export class SectionComponent implements OnInit {
77
- options: any;
78
- expanded = true;
79
- containerType: string;
80
- @Input() layoutNode: any;
81
- @Input() layoutIndex: number[];
82
- @Input() dataIndex: number[];
83
-
84
- constructor(
85
- private jsf: JsonSchemaFormService
86
- ) { }
87
-
88
- get sectionTitle() {
89
- return this.options.notitle ? null : this.jsf.setItemTitle(this);
90
- }
91
-
92
- ngOnInit() {
93
- this.jsf.initializeControl(this);
94
- this.options = this.layoutNode.options || {};
95
- this.expanded = typeof this.options.expanded === 'boolean' ?
96
- this.options.expanded : !this.options.expandable;
97
- switch (this.layoutNode.type) {
98
- case 'fieldset': case 'array': case 'tab': case 'advancedfieldset':
99
- case 'authfieldset': case 'optionfieldset': case 'selectfieldset':
100
- this.containerType = 'fieldset';
101
- break;
102
- default: // 'div', 'flex', 'section', 'conditional', 'actions', 'tagsinput'
103
- this.containerType = 'div';
104
- break;
105
- }
106
- }
107
-
108
- toggleExpanded() {
109
- if (this.options.expandable) { this.expanded = !this.expanded; }
110
- }
111
-
112
- // Set attributes for flexbox container
113
- // (child attributes are set in root.component)
114
- getFlexAttribute(attribute: string) {
115
- const flexActive: boolean =
116
- this.layoutNode.type === 'flex' ||
117
- !!this.options.displayFlex ||
118
- this.options.display === 'flex';
119
- if (attribute !== 'flex' && !flexActive) { return null; }
120
- switch (attribute) {
121
- case 'is-flex':
122
- return flexActive;
123
- case 'display':
124
- return flexActive ? 'flex' : 'initial';
125
- case 'flex-direction': case 'flex-wrap':
126
- const index = ['flex-direction', 'flex-wrap'].indexOf(attribute);
127
- return (this.options['flex-flow'] || '').split(/\s+/)[index] ||
128
- this.options[attribute] || ['column', 'nowrap'][index];
129
- case 'justify-content': case 'align-items': case 'align-content':
130
- return this.options[attribute];
131
- }
132
- }
133
- }
@@ -1,50 +0,0 @@
1
- import {
2
- Component, ComponentFactoryResolver, ComponentRef, Input,
3
- OnChanges, OnInit, ViewChild, ViewContainerRef
4
- } from '@angular/core';
5
-
6
- import { JsonSchemaFormService } from '../json-schema-form.service';
7
-
8
- @Component({
9
- // tslint:disable-next-line:component-selector
10
- selector: 'select-framework-widget',
11
- template: `<div #widgetContainer></div>`,
12
- })
13
- export class SelectFrameworkComponent implements OnChanges, OnInit {
14
- newComponent: ComponentRef<any> = null;
15
- @Input() layoutNode: any;
16
- @Input() layoutIndex: number[];
17
- @Input() dataIndex: number[];
18
- @ViewChild('widgetContainer', {
19
- read: ViewContainerRef,
20
- static: true })
21
- widgetContainer: ViewContainerRef;
22
-
23
- constructor(
24
- private componentFactory: ComponentFactoryResolver,
25
- private jsf: JsonSchemaFormService
26
- ) { }
27
-
28
- ngOnInit() {
29
- this.updateComponent();
30
- }
31
-
32
- ngOnChanges() {
33
- this.updateComponent();
34
- }
35
-
36
- updateComponent() {
37
- if (this.widgetContainer && !this.newComponent && this.jsf.framework) {
38
- this.newComponent = this.widgetContainer.createComponent(
39
- this.componentFactory.resolveComponentFactory(this.jsf.framework)
40
- );
41
- //TODO fix all deprecated calls and test
42
- //this.widgetContainer.createComponent<any>(this.jsf.framework)
43
- }
44
- if (this.newComponent) {
45
- for (const input of ['layoutNode', 'layoutIndex', 'dataIndex']) {
46
- this.newComponent.instance[input] = this[input];
47
- }
48
- }
49
- }
50
- }
@@ -1,46 +0,0 @@
1
- import {
2
- Component, ComponentFactoryResolver, ComponentRef, Input,
3
- OnChanges, OnInit, ViewChild, ViewContainerRef
4
- } from '@angular/core';
5
-
6
- import { JsonSchemaFormService } from '../json-schema-form.service';
7
-
8
- @Component({
9
- // tslint:disable-next-line:component-selector
10
- selector: 'select-widget-widget',
11
- template: `<div #widgetContainer></div>`,
12
- })
13
- export class SelectWidgetComponent implements OnChanges, OnInit {
14
- newComponent: ComponentRef<any> = null;
15
- @Input() layoutNode: any;
16
- @Input() layoutIndex: number[];
17
- @Input() dataIndex: number[];
18
- @ViewChild('widgetContainer', { read: ViewContainerRef, static: true })
19
- widgetContainer: ViewContainerRef;
20
-
21
- constructor(
22
- private componentFactory: ComponentFactoryResolver,
23
- private jsf: JsonSchemaFormService
24
- ) { }
25
-
26
- ngOnInit() {
27
- this.updateComponent();
28
- }
29
-
30
- ngOnChanges() {
31
- this.updateComponent();
32
- }
33
-
34
- updateComponent() {
35
- if (this.widgetContainer && !this.newComponent && (this.layoutNode || {}).widget) {
36
- this.newComponent = this.widgetContainer.createComponent(
37
- this.componentFactory.resolveComponentFactory(this.layoutNode.widget)
38
- );
39
- }
40
- if (this.newComponent) {
41
- for (const input of ['layoutNode', 'layoutIndex', 'dataIndex']) {
42
- this.newComponent.instance[input] = this[input];
43
- }
44
- }
45
- }
46
- }
@@ -1,96 +0,0 @@
1
- import { AbstractControl } from '@angular/forms';
2
- import { buildTitleMap, isArray } 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: 'select-widget',
10
- template: `
11
- <div
12
- [class]="options?.htmlClass || ''">
13
- <label *ngIf="options?.title"
14
- [attr.for]="'control' + layoutNode?._id"
15
- [class]="options?.labelHtmlClass || ''"
16
- [style.display]="options?.notitle ? 'none' : ''"
17
- [innerHTML]="options?.title"></label>
18
- <select *ngIf="boundControl"
19
- [formControl]="formControl"
20
- [attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
21
- [attr.readonly]="options?.readonly ? 'readonly' : null"
22
- [attr.required]="options?.required"
23
- [class]="options?.fieldHtmlClass || ''"
24
- [id]="'control' + layoutNode?._id"
25
- [name]="controlName">
26
- <ng-template ngFor let-selectItem [ngForOf]="selectList">
27
- <option *ngIf="!isArray(selectItem?.items)"
28
- [value]="selectItem?.value">
29
- <span [innerHTML]="selectItem?.name"></span>
30
- </option>
31
- <optgroup *ngIf="isArray(selectItem?.items)"
32
- [label]="selectItem?.group">
33
- <option *ngFor="let subItem of selectItem.items"
34
- [value]="subItem?.value">
35
- <span [innerHTML]="subItem?.name"></span>
36
- </option>
37
- </optgroup>
38
- </ng-template>
39
- </select>
40
- <select *ngIf="!boundControl"
41
- [attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
42
- [attr.readonly]="options?.readonly ? 'readonly' : null"
43
- [attr.required]="options?.required"
44
- [class]="options?.fieldHtmlClass || ''"
45
- [disabled]="controlDisabled"
46
- [id]="'control' + layoutNode?._id"
47
- [name]="controlName"
48
- (change)="updateValue($event)">
49
- <ng-template ngFor let-selectItem [ngForOf]="selectList">
50
- <option *ngIf="!isArray(selectItem?.items)"
51
- [selected]="selectItem?.value === controlValue"
52
- [value]="selectItem?.value">
53
- <span [innerHTML]="selectItem?.name"></span>
54
- </option>
55
- <optgroup *ngIf="isArray(selectItem?.items)"
56
- [label]="selectItem?.group">
57
- <option *ngFor="let subItem of selectItem.items"
58
- [attr.selected]="subItem?.value === controlValue"
59
- [value]="subItem?.value">
60
- <span [innerHTML]="subItem?.name"></span>
61
- </option>
62
- </optgroup>
63
- </ng-template>
64
- </select>
65
- </div>`,
66
- })
67
- export class SelectComponent implements OnInit {
68
- formControl: AbstractControl;
69
- controlName: string;
70
- controlValue: any;
71
- controlDisabled = false;
72
- boundControl = false;
73
- options: any;
74
- selectList: any[] = [];
75
- isArray = isArray;
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
- this.selectList = buildTitleMap(
87
- this.options.titleMap || this.options.enumNames,
88
- this.options.enum, !!this.options.required, !!this.options.flatList
89
- );
90
- this.jsf.initializeControl(this);
91
- }
92
-
93
- updateValue(event) {
94
- this.jsf.updateValue(this, event.target.value);
95
- }
96
- }
@@ -1,68 +0,0 @@
1
- import { Component, Input, OnDestroy, OnInit } from '@angular/core';
2
- import { AbstractControl } from '@angular/forms';
3
- import { Subscription } from 'rxjs';
4
- import { JsonSchemaFormService } from '../json-schema-form.service';
5
- import { hasOwn } from '../shared/utility.functions';
6
-
7
-
8
- @Component({
9
- // tslint:disable-next-line:component-selector
10
- selector: 'submit-widget',
11
- template: `
12
- <div
13
- [class]="options?.htmlClass || ''">
14
- <input
15
- [attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
16
- [attr.readonly]="options?.readonly ? 'readonly' : null"
17
- [attr.required]="options?.required"
18
- [class]="options?.fieldHtmlClass || ''"
19
- [disabled]="controlDisabled"
20
- [id]="'control' + layoutNode?._id"
21
- [name]="controlName"
22
- [type]="layoutNode?.type"
23
- [value]="controlValue"
24
- (click)="updateValue($event)">
25
- </div>`,
26
- })
27
- export class SubmitComponent implements OnInit,OnDestroy {
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
- isValidChangesSubs:Subscription;
39
- constructor(
40
- private jsf: JsonSchemaFormService
41
- ) { }
42
- ngOnDestroy(): void {
43
- this.isValidChangesSubs?.unsubscribe();
44
- this.isValidChangesSubs=null;
45
- }
46
-
47
- ngOnInit() {
48
- this.options = this.layoutNode.options || {};
49
- this.jsf.initializeControl(this);
50
- if (hasOwn(this.options, 'disabled')) {
51
- this.controlDisabled = this.options.disabled;
52
- } else if (this.jsf.formOptions.disableInvalidSubmit) {
53
- this.controlDisabled = !this.jsf.isValid;
54
- this.isValidChangesSubs=this.jsf.isValidChanges.subscribe(isValid => this.controlDisabled = !isValid);
55
- }
56
- if (this.controlValue === null || this.controlValue === undefined) {
57
- this.controlValue = this.options.title;
58
- }
59
- }
60
-
61
- updateValue(event) {
62
- if (typeof this.options.onClick === 'function') {
63
- this.options.onClick(event);
64
- } else {
65
- this.jsf.updateValue(this, event.target.value);
66
- }
67
- }
68
- }
@@ -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: 'tab-widget',
8
- template: `
9
- <div [class]="options?.htmlClass || ''">
10
- <root-widget
11
- [dataIndex]="dataIndex"
12
- [layoutIndex]="layoutIndex"
13
- [layout]="layoutNode.items"></root-widget>
14
- </div>`,
15
- })
16
- export class TabComponent implements OnInit {
17
- options: any;
18
- @Input() layoutNode: any;
19
- @Input() layoutIndex: number[];
20
- @Input() dataIndex: number[];
21
-
22
- constructor(
23
- private jsf: JsonSchemaFormService
24
- ) { }
25
-
26
- ngOnInit() {
27
- this.options = this.layoutNode.options || {};
28
- }
29
- }
@@ -1,83 +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: 'tabs-widget',
8
- template: `
9
- <ul
10
- [class]="options?.labelHtmlClass || ''">
11
- <li *ngFor="let item of layoutNode?.items; let i = index"
12
- [class]="(options?.itemLabelHtmlClass || '') + (selectedItem === i ?
13
- (' ' + (options?.activeClass || '') + ' ' + (options?.style?.selected || '')) :
14
- (' ' + options?.style?.unselected))"
15
- role="presentation"
16
- data-tabs>
17
- <a *ngIf="showAddTab || item.type !== '$ref'"
18
- [class]="'nav-link' + (selectedItem === i ? (' ' + options?.activeClass + ' ' + options?.style?.selected) :
19
- (' ' + options?.style?.unselected))"
20
- [innerHTML]="setTabTitle(item, i)"
21
- (click)="select(i)"></a>
22
- </li>
23
- </ul>
24
-
25
- <div *ngFor="let layoutItem of layoutNode?.items; let i = index"
26
- [class]="options?.htmlClass || ''">
27
-
28
- <select-framework-widget *ngIf="selectedItem === i"
29
- [class]="(options?.fieldHtmlClass || '') +
30
- ' ' + (options?.activeClass || '') +
31
- ' ' + (options?.style?.selected || '')"
32
- [dataIndex]="layoutNode?.dataType === 'array' ? (dataIndex || []).concat(i) : dataIndex"
33
- [layoutIndex]="(layoutIndex || []).concat(i)"
34
- [layoutNode]="layoutItem"></select-framework-widget>
35
-
36
- </div>`,
37
- styles: [` a { cursor: pointer; } `],
38
- })
39
- export class TabsComponent implements OnInit {
40
- options: any;
41
- itemCount: number;
42
- selectedItem = 0;
43
- showAddTab = true;
44
- @Input() layoutNode: any;
45
- @Input() layoutIndex: number[];
46
- @Input() dataIndex: number[];
47
-
48
- constructor(
49
- private jsf: JsonSchemaFormService
50
- ) { }
51
-
52
- ngOnInit() {
53
- this.options = this.layoutNode.options || {};
54
- this.itemCount = this.layoutNode.items.length - 1;
55
- this.updateControl();
56
- }
57
-
58
- select(index) {
59
- if (this.layoutNode.items[index].type === '$ref') {
60
- this.itemCount = this.layoutNode.items.length;
61
- this.jsf.addItem({
62
- layoutNode: this.layoutNode.items[index],
63
- layoutIndex: this.layoutIndex.concat(index),
64
- dataIndex: this.dataIndex.concat(index)
65
- });
66
- this.updateControl();
67
- }
68
- this.selectedItem = index;
69
- }
70
-
71
- updateControl() {
72
- const lastItem = this.layoutNode.items[this.layoutNode.items.length - 1];
73
- if (lastItem.type === '$ref' &&
74
- this.itemCount >= (lastItem.options.maxItems || 1000)
75
- ) {
76
- this.showAddTab = false;
77
- }
78
- }
79
-
80
- setTabTitle(item: any, index: number): string {
81
- return this.jsf.setArrayItemTitle(this, item, index);
82
- }
83
- }
@@ -1,52 +0,0 @@
1
- import {
2
- Component,
3
- ComponentFactoryResolver,
4
- ComponentRef,
5
- Input,
6
- OnChanges,
7
- OnInit,
8
- ViewChild,
9
- ViewContainerRef
10
- } from '@angular/core';
11
- import { JsonSchemaFormService } from '../json-schema-form.service';
12
-
13
-
14
- @Component({
15
- // tslint:disable-next-line:component-selector
16
- selector: 'template-widget',
17
- template: `<div #widgetContainer></div>`,
18
- })
19
- export class TemplateComponent implements OnInit, OnChanges {
20
- newComponent: ComponentRef<any> = null;
21
- @Input() layoutNode: any;
22
- @Input() layoutIndex: number[];
23
- @Input() dataIndex: number[];
24
- @ViewChild('widgetContainer', { read: ViewContainerRef , static: true})
25
- widgetContainer: ViewContainerRef;
26
-
27
- constructor(
28
- private componentFactory: ComponentFactoryResolver,
29
- private jsf: JsonSchemaFormService
30
- ) { }
31
-
32
- ngOnInit() {
33
- this.updateComponent();
34
- }
35
-
36
- ngOnChanges() {
37
- this.updateComponent();
38
- }
39
-
40
- updateComponent() {
41
- if (this.widgetContainer && !this.newComponent && this.layoutNode.options.template) {
42
- this.newComponent = this.widgetContainer.createComponent(
43
- this.componentFactory.resolveComponentFactory(this.layoutNode.options.template)
44
- );
45
- }
46
- if (this.newComponent) {
47
- for (const input of ['layoutNode', 'layoutIndex', 'dataIndex']) {
48
- this.newComponent.instance[input] = this[input];
49
- }
50
- }
51
- }
52
- }