@ajsf/material 0.2.0-beta.1 → 0.4.0-beta.1
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/ajsf-material.d.ts +4 -0
- package/ajsf-material.metadata.json +1 -0
- package/bundles/ajsf-material.umd.js +1431 -0
- package/bundles/ajsf-material.umd.js.map +1 -0
- package/bundles/ajsf-material.umd.min.js +16 -0
- package/bundles/ajsf-material.umd.min.js.map +1 -0
- package/esm2015/ajsf-material.js +5 -0
- package/esm2015/lib/angular-flex-monkey-patch.js +12 -0
- package/esm2015/lib/material-design-framework.component.js +101 -0
- package/esm2015/lib/material-design-framework.module.js +80 -0
- package/esm2015/lib/material-design.framework.js +54 -0
- package/esm2015/lib/widgets/flex-layout-root.component.js +55 -0
- package/esm2015/lib/widgets/flex-layout-section.component.js +221 -0
- package/esm2015/lib/widgets/material-add-reference.component.js +53 -0
- package/esm2015/lib/widgets/material-button-group.component.js +63 -0
- package/esm2015/lib/widgets/material-button.component.js +60 -0
- package/esm2015/lib/widgets/material-checkbox.component.js +109 -0
- package/esm2015/lib/widgets/material-checkboxes.component.js +101 -0
- package/esm2015/lib/widgets/material-chip-list.component.js +33 -0
- package/esm2015/lib/widgets/material-datepicker.component.js +101 -0
- package/esm2015/lib/widgets/material-file.component.js +33 -0
- package/esm2015/lib/widgets/material-input.component.js +95 -0
- package/esm2015/lib/widgets/material-number.component.js +97 -0
- package/esm2015/lib/widgets/material-one-of.component.js +33 -0
- package/esm2015/lib/widgets/material-radios.component.js +84 -0
- package/esm2015/lib/widgets/material-select.component.js +115 -0
- package/esm2015/lib/widgets/material-slider.component.js +60 -0
- package/esm2015/lib/widgets/material-stepper.component.js +33 -0
- package/esm2015/lib/widgets/material-tabs.component.js +69 -0
- package/esm2015/lib/widgets/material-textarea.component.js +88 -0
- package/esm2015/lib/widgets/public_api.js +52 -0
- package/esm2015/public_api.js +8 -0
- package/fesm2015/ajsf-material.js +1721 -0
- package/fesm2015/ajsf-material.js.map +1 -0
- package/lib/angular-flex-monkey-patch.d.ts +1 -0
- package/lib/material-design-framework.component.d.ts +25 -0
- package/lib/material-design-framework.module.d.ts +12 -0
- package/lib/material-design.framework.d.ts +41 -0
- package/lib/widgets/flex-layout-root.component.d.ts +12 -0
- package/lib/widgets/flex-layout-section.component.d.ts +22 -0
- package/lib/widgets/material-add-reference.component.d.ts +17 -0
- package/lib/widgets/material-button-group.component.d.ts +20 -0
- package/lib/widgets/material-button.component.d.ts +18 -0
- package/lib/widgets/material-checkbox.component.d.ts +22 -0
- package/lib/widgets/material-checkboxes.component.d.ts +24 -0
- package/lib/widgets/material-chip-list.component.d.ts +18 -0
- package/lib/widgets/material-datepicker.component.d.ts +22 -0
- package/lib/widgets/material-file.component.d.ts +18 -0
- package/lib/widgets/material-input.component.d.ts +20 -0
- package/lib/widgets/material-number.component.d.ts +23 -0
- package/lib/widgets/material-one-of.component.d.ts +18 -0
- package/lib/widgets/material-radios.component.d.ts +20 -0
- package/lib/widgets/material-select.component.d.ts +21 -0
- package/lib/widgets/material-slider.component.d.ts +22 -0
- package/lib/widgets/material-stepper.component.d.ts +18 -0
- package/lib/widgets/material-tabs.component.d.ts +17 -0
- package/lib/widgets/material-textarea.component.d.ts +19 -0
- package/{src/lib/widgets/public_api.ts → lib/widgets/public_api.d.ts} +1 -14
- package/package.json +25 -7
- package/{src/public_api.ts → public_api.d.ts} +0 -4
- package/karma.conf.js +0 -37
- package/ng-package.json +0 -16
- package/src/lib/angular-flex-monkey-patch.ts +0 -13
- package/src/lib/material-design-framework.component.html +0 -20
- package/src/lib/material-design-framework.component.scss +0 -51
- package/src/lib/material-design-framework.component.spec.ts +0 -37
- package/src/lib/material-design-framework.component.ts +0 -121
- package/src/lib/material-design-framework.module.ts +0 -84
- package/src/lib/material-design.framework.ts +0 -75
- package/src/lib/widgets/flex-layout-root.component.html +0 -11
- package/src/lib/widgets/flex-layout-root.component.ts +0 -52
- package/src/lib/widgets/flex-layout-section.component.ts +0 -216
- package/src/lib/widgets/material-add-reference.component.ts +0 -56
- package/src/lib/widgets/material-button-group.component.ts +0 -68
- package/src/lib/widgets/material-button.component.ts +0 -59
- package/src/lib/widgets/material-checkbox.component.ts +0 -112
- package/src/lib/widgets/material-checkboxes.component.ts +0 -109
- package/src/lib/widgets/material-chip-list.component.ts +0 -35
- package/src/lib/widgets/material-datepicker.component.ts +0 -105
- package/src/lib/widgets/material-file.component.ts +0 -35
- package/src/lib/widgets/material-input.component.ts +0 -99
- package/src/lib/widgets/material-number.component.ts +0 -97
- package/src/lib/widgets/material-one-of.component.ts +0 -35
- package/src/lib/widgets/material-radios.component.ts +0 -89
- package/src/lib/widgets/material-select.component.ts +0 -120
- package/src/lib/widgets/material-slider.component.ts +0 -61
- package/src/lib/widgets/material-stepper.component.ts +0 -35
- package/src/lib/widgets/material-tabs.component.ts +0 -69
- package/src/lib/widgets/material-textarea.component.ts +0 -90
- package/src/test.ts +0 -21
- package/tsconfig.lib.json +0 -25
- package/tsconfig.lib.prod.json +0 -6
- package/tsconfig.spec.json +0 -17
- package/tslint.json +0 -11
|
@@ -0,0 +1,1721 @@
|
|
|
1
|
+
import { Component, ChangeDetectionStrategy, Input, Inject, Optional, ChangeDetectorRef, Injectable, NgModule } from '@angular/core';
|
|
2
|
+
import { JsonSchemaFormService, hasOwn, buildTitleMap, dateToString, isDefined, isArray, Framework, WidgetLibraryModule, JsonSchemaFormModule, FrameworkLibraryService, WidgetLibraryService } from '@ajsf/core';
|
|
3
|
+
import { MAT_FORM_FIELD_DEFAULT_OPTIONS, MatFormFieldModule } from '@angular/material/form-field';
|
|
4
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
5
|
+
import { CommonModule } from '@angular/common';
|
|
6
|
+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
7
|
+
import { FlexLayoutModule } from '@angular/flex-layout';
|
|
8
|
+
import { MatAutocompleteModule } from '@angular/material/autocomplete';
|
|
9
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
10
|
+
import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
|
11
|
+
import { MatCardModule } from '@angular/material/card';
|
|
12
|
+
import { MatCheckboxModule } from '@angular/material/checkbox';
|
|
13
|
+
import { MatChipsModule } from '@angular/material/chips';
|
|
14
|
+
import { MatNativeDateModule } from '@angular/material/core';
|
|
15
|
+
import { MatDatepickerModule } from '@angular/material/datepicker';
|
|
16
|
+
import { MatExpansionModule } from '@angular/material/expansion';
|
|
17
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
18
|
+
import { MatInputModule } from '@angular/material/input';
|
|
19
|
+
import { MatRadioModule } from '@angular/material/radio';
|
|
20
|
+
import { MatSelectModule } from '@angular/material/select';
|
|
21
|
+
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
|
|
22
|
+
import { MatSliderModule } from '@angular/material/slider';
|
|
23
|
+
import { MatStepperModule } from '@angular/material/stepper';
|
|
24
|
+
import { MatTabsModule } from '@angular/material/tabs';
|
|
25
|
+
import { MatTooltipModule } from '@angular/material/tooltip';
|
|
26
|
+
import { MatMenuModule } from '@angular/material/menu';
|
|
27
|
+
import { MatToolbarModule } from '@angular/material/toolbar';
|
|
28
|
+
import { MediaMarshaller } from '@angular/flex-layout/core';
|
|
29
|
+
|
|
30
|
+
class FlexLayoutRootComponent {
|
|
31
|
+
constructor(jsf) {
|
|
32
|
+
this.jsf = jsf;
|
|
33
|
+
this.isFlexItem = false;
|
|
34
|
+
}
|
|
35
|
+
removeItem(item) {
|
|
36
|
+
this.jsf.removeItem(item);
|
|
37
|
+
}
|
|
38
|
+
// Set attributes for flexbox child
|
|
39
|
+
// (container attributes are set in flex-layout-section.component)
|
|
40
|
+
getFlexAttribute(node, attribute) {
|
|
41
|
+
const index = ['flex-grow', 'flex-shrink', 'flex-basis'].indexOf(attribute);
|
|
42
|
+
return ((node.options || {}).flex || '').split(/\s+/)[index] ||
|
|
43
|
+
(node.options || {})[attribute] || ['1', '1', 'auto'][index];
|
|
44
|
+
}
|
|
45
|
+
showWidget(layoutNode) {
|
|
46
|
+
return this.jsf.evaluateCondition(layoutNode, this.dataIndex);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
FlexLayoutRootComponent.decorators = [
|
|
50
|
+
{ type: Component, args: [{
|
|
51
|
+
// tslint:disable-next-line:component-selector
|
|
52
|
+
selector: 'flex-layout-root-widget',
|
|
53
|
+
template: `
|
|
54
|
+
<div *ngFor="let layoutNode of layout; let i = index"
|
|
55
|
+
[class.form-flex-item]="isFlexItem"
|
|
56
|
+
[style.flex-grow]="getFlexAttribute(layoutNode, 'flex-grow')"
|
|
57
|
+
[style.flex-shrink]="getFlexAttribute(layoutNode, 'flex-shrink')"
|
|
58
|
+
[style.flex-basis]="getFlexAttribute(layoutNode, 'flex-basis')"
|
|
59
|
+
[style.align-self]="(layoutNode?.options || {})['align-self']"
|
|
60
|
+
[style.order]="layoutNode?.options?.order"
|
|
61
|
+
[fxFlex]="layoutNode?.options?.fxFlex"
|
|
62
|
+
[fxFlexOrder]="layoutNode?.options?.fxFlexOrder"
|
|
63
|
+
[fxFlexOffset]="layoutNode?.options?.fxFlexOffset"
|
|
64
|
+
[fxFlexAlign]="layoutNode?.options?.fxFlexAlign">
|
|
65
|
+
<select-framework-widget *ngIf="showWidget(layoutNode)"
|
|
66
|
+
[dataIndex]="layoutNode?.arrayItem ? (dataIndex || []).concat(i) : (dataIndex || [])"
|
|
67
|
+
[layoutIndex]="(layoutIndex || []).concat(i)"
|
|
68
|
+
[layoutNode]="layoutNode"></select-framework-widget>
|
|
69
|
+
<div>`,
|
|
70
|
+
changeDetection: ChangeDetectionStrategy.Default
|
|
71
|
+
},] }
|
|
72
|
+
];
|
|
73
|
+
FlexLayoutRootComponent.ctorParameters = () => [
|
|
74
|
+
{ type: JsonSchemaFormService }
|
|
75
|
+
];
|
|
76
|
+
FlexLayoutRootComponent.propDecorators = {
|
|
77
|
+
dataIndex: [{ type: Input }],
|
|
78
|
+
layoutIndex: [{ type: Input }],
|
|
79
|
+
layout: [{ type: Input }],
|
|
80
|
+
isFlexItem: [{ type: Input }]
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
class FlexLayoutSectionComponent {
|
|
84
|
+
constructor(jsf) {
|
|
85
|
+
this.jsf = jsf;
|
|
86
|
+
this.controlDisabled = false;
|
|
87
|
+
this.boundControl = false;
|
|
88
|
+
this.expanded = true;
|
|
89
|
+
this.containerType = 'div';
|
|
90
|
+
}
|
|
91
|
+
get sectionTitle() {
|
|
92
|
+
return this.options.notitle ? null : this.jsf.setItemTitle(this);
|
|
93
|
+
}
|
|
94
|
+
ngOnInit() {
|
|
95
|
+
this.jsf.initializeControl(this);
|
|
96
|
+
this.options = this.layoutNode.options || {};
|
|
97
|
+
this.expanded = typeof this.options.expanded === 'boolean' ?
|
|
98
|
+
this.options.expanded : !this.options.expandable;
|
|
99
|
+
switch (this.layoutNode.type) {
|
|
100
|
+
case 'section':
|
|
101
|
+
case 'array':
|
|
102
|
+
case 'fieldset':
|
|
103
|
+
case 'advancedfieldset':
|
|
104
|
+
case 'authfieldset':
|
|
105
|
+
case 'optionfieldset':
|
|
106
|
+
case 'selectfieldset':
|
|
107
|
+
this.containerType = 'fieldset';
|
|
108
|
+
break;
|
|
109
|
+
case 'card':
|
|
110
|
+
this.containerType = 'card';
|
|
111
|
+
break;
|
|
112
|
+
case 'expansion-panel':
|
|
113
|
+
this.containerType = 'expansion-panel';
|
|
114
|
+
break;
|
|
115
|
+
default: // 'div', 'flex', 'tab', 'conditional', 'actions'
|
|
116
|
+
this.containerType = 'div';
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
toggleExpanded() {
|
|
120
|
+
if (this.options.expandable) {
|
|
121
|
+
this.expanded = !this.expanded;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// Set attributes for flexbox container
|
|
125
|
+
// (child attributes are set in flex-layout-root.component)
|
|
126
|
+
getFlexAttribute(attribute) {
|
|
127
|
+
const flexActive = this.layoutNode.type === 'flex' ||
|
|
128
|
+
!!this.options.displayFlex ||
|
|
129
|
+
this.options.display === 'flex';
|
|
130
|
+
// if (attribute !== 'flex' && !flexActive) { return null; }
|
|
131
|
+
switch (attribute) {
|
|
132
|
+
case 'is-flex':
|
|
133
|
+
return flexActive;
|
|
134
|
+
case 'display':
|
|
135
|
+
return flexActive ? 'flex' : 'initial';
|
|
136
|
+
case 'flex-direction':
|
|
137
|
+
case 'flex-wrap':
|
|
138
|
+
const index = ['flex-direction', 'flex-wrap'].indexOf(attribute);
|
|
139
|
+
return (this.options['flex-flow'] || '').split(/\s+/)[index] ||
|
|
140
|
+
this.options[attribute] || ['column', 'nowrap'][index];
|
|
141
|
+
case 'justify-content':
|
|
142
|
+
case 'align-items':
|
|
143
|
+
case 'align-content':
|
|
144
|
+
return this.options[attribute];
|
|
145
|
+
case 'layout':
|
|
146
|
+
return (this.options.fxLayout || 'row') +
|
|
147
|
+
this.options.fxLayoutWrap ? ' ' + this.options.fxLayoutWrap : '';
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
FlexLayoutSectionComponent.decorators = [
|
|
152
|
+
{ type: Component, args: [{
|
|
153
|
+
// tslint:disable-next-line:component-selector
|
|
154
|
+
selector: 'flex-layout-section-widget',
|
|
155
|
+
template: `
|
|
156
|
+
<div *ngIf="containerType === 'div'"
|
|
157
|
+
[class]="options?.htmlClass || ''"
|
|
158
|
+
[class.expandable]="options?.expandable && !expanded"
|
|
159
|
+
[class.expanded]="options?.expandable && expanded">
|
|
160
|
+
<label *ngIf="sectionTitle"
|
|
161
|
+
[class]="'legend ' + (options?.labelHtmlClass || '')"
|
|
162
|
+
[innerHTML]="sectionTitle"
|
|
163
|
+
(click)="toggleExpanded()"></label>
|
|
164
|
+
<flex-layout-root-widget *ngIf="expanded"
|
|
165
|
+
[layout]="layoutNode.items"
|
|
166
|
+
[dataIndex]="dataIndex"
|
|
167
|
+
[layoutIndex]="layoutIndex"
|
|
168
|
+
[isFlexItem]="getFlexAttribute('is-flex')"
|
|
169
|
+
[class.form-flex-column]="getFlexAttribute('flex-direction') === 'column'"
|
|
170
|
+
[class.form-flex-row]="getFlexAttribute('flex-direction') === 'row'"
|
|
171
|
+
[style.display]="getFlexAttribute('display')"
|
|
172
|
+
[style.flex-direction]="getFlexAttribute('flex-direction')"
|
|
173
|
+
[style.flex-wrap]="getFlexAttribute('flex-wrap')"
|
|
174
|
+
[style.justify-content]="getFlexAttribute('justify-content')"
|
|
175
|
+
[style.align-items]="getFlexAttribute('align-items')"
|
|
176
|
+
[style.align-content]="getFlexAttribute('align-content')"
|
|
177
|
+
[fxLayout]="getFlexAttribute('layout')"
|
|
178
|
+
[fxLayoutGap]="options?.fxLayoutGap"
|
|
179
|
+
[fxLayoutAlign]="options?.fxLayoutAlign"
|
|
180
|
+
[attr.fxFlexFill]="options?.fxLayoutAlign"></flex-layout-root-widget>
|
|
181
|
+
<mat-error *ngIf="options?.showErrors && options?.errorMessage"
|
|
182
|
+
[innerHTML]="options?.errorMessage"></mat-error>
|
|
183
|
+
</div>
|
|
184
|
+
|
|
185
|
+
<fieldset *ngIf="containerType === 'fieldset'"
|
|
186
|
+
[class]="options?.htmlClass || ''"
|
|
187
|
+
[class.expandable]="options?.expandable && !expanded"
|
|
188
|
+
[class.expanded]="options?.expandable && expanded"
|
|
189
|
+
[disabled]="options?.readonly">
|
|
190
|
+
<legend *ngIf="sectionTitle"
|
|
191
|
+
[class]="'legend ' + (options?.labelHtmlClass || '')"
|
|
192
|
+
[innerHTML]="sectionTitle"
|
|
193
|
+
(click)="toggleExpanded()"></legend>
|
|
194
|
+
<flex-layout-root-widget *ngIf="expanded"
|
|
195
|
+
[layout]="layoutNode.items"
|
|
196
|
+
[dataIndex]="dataIndex"
|
|
197
|
+
[layoutIndex]="layoutIndex"
|
|
198
|
+
[isFlexItem]="getFlexAttribute('is-flex')"
|
|
199
|
+
[class.form-flex-column]="getFlexAttribute('flex-direction') === 'column'"
|
|
200
|
+
[class.form-flex-row]="getFlexAttribute('flex-direction') === 'row'"
|
|
201
|
+
[style.display]="getFlexAttribute('display')"
|
|
202
|
+
[style.flex-direction]="getFlexAttribute('flex-direction')"
|
|
203
|
+
[style.flex-wrap]="getFlexAttribute('flex-wrap')"
|
|
204
|
+
[style.justify-content]="getFlexAttribute('justify-content')"
|
|
205
|
+
[style.align-items]="getFlexAttribute('align-items')"
|
|
206
|
+
[style.align-content]="getFlexAttribute('align-content')"
|
|
207
|
+
[fxLayout]="getFlexAttribute('layout')"
|
|
208
|
+
[fxLayoutGap]="options?.fxLayoutGap"
|
|
209
|
+
[fxLayoutAlign]="options?.fxLayoutAlign"
|
|
210
|
+
[attr.fxFlexFill]="options?.fxLayoutAlign"></flex-layout-root-widget>
|
|
211
|
+
<mat-error *ngIf="options?.showErrors && options?.errorMessage"
|
|
212
|
+
[innerHTML]="options?.errorMessage"></mat-error>
|
|
213
|
+
</fieldset>
|
|
214
|
+
|
|
215
|
+
<mat-card *ngIf="containerType === 'card'"
|
|
216
|
+
[ngClass]="options?.htmlClass || ''"
|
|
217
|
+
[class.expandable]="options?.expandable && !expanded"
|
|
218
|
+
[class.expanded]="options?.expandable && expanded">
|
|
219
|
+
<mat-card-header *ngIf="sectionTitle">
|
|
220
|
+
<legend
|
|
221
|
+
[class]="'legend ' + (options?.labelHtmlClass || '')"
|
|
222
|
+
[innerHTML]="sectionTitle"
|
|
223
|
+
(click)="toggleExpanded()"></legend>
|
|
224
|
+
</mat-card-header>
|
|
225
|
+
<mat-card-content *ngIf="expanded">
|
|
226
|
+
<fieldset [disabled]="options?.readonly">
|
|
227
|
+
<flex-layout-root-widget *ngIf="expanded"
|
|
228
|
+
[layout]="layoutNode.items"
|
|
229
|
+
[dataIndex]="dataIndex"
|
|
230
|
+
[layoutIndex]="layoutIndex"
|
|
231
|
+
[isFlexItem]="getFlexAttribute('is-flex')"
|
|
232
|
+
[class.form-flex-column]="getFlexAttribute('flex-direction') === 'column'"
|
|
233
|
+
[class.form-flex-row]="getFlexAttribute('flex-direction') === 'row'"
|
|
234
|
+
[style.display]="getFlexAttribute('display')"
|
|
235
|
+
[style.flex-direction]="getFlexAttribute('flex-direction')"
|
|
236
|
+
[style.flex-wrap]="getFlexAttribute('flex-wrap')"
|
|
237
|
+
[style.justify-content]="getFlexAttribute('justify-content')"
|
|
238
|
+
[style.align-items]="getFlexAttribute('align-items')"
|
|
239
|
+
[style.align-content]="getFlexAttribute('align-content')"
|
|
240
|
+
[fxLayout]="getFlexAttribute('layout')"
|
|
241
|
+
[fxLayoutGap]="options?.fxLayoutGap"
|
|
242
|
+
[fxLayoutAlign]="options?.fxLayoutAlign"
|
|
243
|
+
[attr.fxFlexFill]="options?.fxLayoutAlign"></flex-layout-root-widget>
|
|
244
|
+
</fieldset>
|
|
245
|
+
</mat-card-content>
|
|
246
|
+
<mat-card-footer>
|
|
247
|
+
<mat-error *ngIf="options?.showErrors && options?.errorMessage"
|
|
248
|
+
[innerHTML]="options?.errorMessage"></mat-error>
|
|
249
|
+
</mat-card-footer>
|
|
250
|
+
</mat-card>
|
|
251
|
+
|
|
252
|
+
<mat-expansion-panel *ngIf="containerType === 'expansion-panel'"
|
|
253
|
+
[expanded]="expanded"
|
|
254
|
+
[hideToggle]="!options?.expandable">
|
|
255
|
+
<mat-expansion-panel-header>
|
|
256
|
+
<mat-panel-title>
|
|
257
|
+
<legend *ngIf="sectionTitle"
|
|
258
|
+
[class]="options?.labelHtmlClass"
|
|
259
|
+
[innerHTML]="sectionTitle"
|
|
260
|
+
(click)="toggleExpanded()"></legend>
|
|
261
|
+
</mat-panel-title>
|
|
262
|
+
</mat-expansion-panel-header>
|
|
263
|
+
<fieldset [disabled]="options?.readonly">
|
|
264
|
+
<flex-layout-root-widget *ngIf="expanded"
|
|
265
|
+
[layout]="layoutNode.items"
|
|
266
|
+
[dataIndex]="dataIndex"
|
|
267
|
+
[layoutIndex]="layoutIndex"
|
|
268
|
+
[isFlexItem]="getFlexAttribute('is-flex')"
|
|
269
|
+
[class.form-flex-column]="getFlexAttribute('flex-direction') === 'column'"
|
|
270
|
+
[class.form-flex-row]="getFlexAttribute('flex-direction') === 'row'"
|
|
271
|
+
[style.display]="getFlexAttribute('display')"
|
|
272
|
+
[style.flex-direction]="getFlexAttribute('flex-direction')"
|
|
273
|
+
[style.flex-wrap]="getFlexAttribute('flex-wrap')"
|
|
274
|
+
[style.justify-content]="getFlexAttribute('justify-content')"
|
|
275
|
+
[style.align-items]="getFlexAttribute('align-items')"
|
|
276
|
+
[style.align-content]="getFlexAttribute('align-content')"
|
|
277
|
+
[fxLayout]="getFlexAttribute('layout')"
|
|
278
|
+
[fxLayoutGap]="options?.fxLayoutGap"
|
|
279
|
+
[fxLayoutAlign]="options?.fxLayoutAlign"
|
|
280
|
+
[attr.fxFlexFill]="options?.fxLayoutAlign"></flex-layout-root-widget>
|
|
281
|
+
</fieldset>
|
|
282
|
+
<mat-error *ngIf="options?.showErrors && options?.errorMessage"
|
|
283
|
+
[innerHTML]="options?.errorMessage"></mat-error>
|
|
284
|
+
</mat-expansion-panel>`,
|
|
285
|
+
styles: [`
|
|
286
|
+
fieldset { border: 0; margin: 0; padding: 0; }
|
|
287
|
+
.legend { font-weight: bold; }
|
|
288
|
+
.expandable > .legend:before { content: '▶'; padding-right: .3em; }
|
|
289
|
+
.expanded > .legend:before { content: '▼'; padding-right: .2em; }
|
|
290
|
+
`]
|
|
291
|
+
},] }
|
|
292
|
+
];
|
|
293
|
+
FlexLayoutSectionComponent.ctorParameters = () => [
|
|
294
|
+
{ type: JsonSchemaFormService }
|
|
295
|
+
];
|
|
296
|
+
FlexLayoutSectionComponent.propDecorators = {
|
|
297
|
+
layoutNode: [{ type: Input }],
|
|
298
|
+
layoutIndex: [{ type: Input }],
|
|
299
|
+
dataIndex: [{ type: Input }]
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
class MaterialAddReferenceComponent {
|
|
303
|
+
constructor(jsf) {
|
|
304
|
+
this.jsf = jsf;
|
|
305
|
+
}
|
|
306
|
+
ngOnInit() {
|
|
307
|
+
this.options = this.layoutNode.options || {};
|
|
308
|
+
}
|
|
309
|
+
get showAddButton() {
|
|
310
|
+
return !this.layoutNode.arrayItem ||
|
|
311
|
+
this.layoutIndex[this.layoutIndex.length - 1] < this.options.maxItems;
|
|
312
|
+
}
|
|
313
|
+
addItem(event) {
|
|
314
|
+
event.preventDefault();
|
|
315
|
+
this.jsf.addItem(this);
|
|
316
|
+
}
|
|
317
|
+
get buttonText() {
|
|
318
|
+
const parent = {
|
|
319
|
+
dataIndex: this.dataIndex.slice(0, -1),
|
|
320
|
+
layoutIndex: this.layoutIndex.slice(0, -1),
|
|
321
|
+
layoutNode: this.jsf.getParentNode(this),
|
|
322
|
+
};
|
|
323
|
+
return parent.layoutNode.add ||
|
|
324
|
+
this.jsf.setArrayItemTitle(parent, this.layoutNode, this.itemCount);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
MaterialAddReferenceComponent.decorators = [
|
|
328
|
+
{ type: Component, args: [{
|
|
329
|
+
// tslint:disable-next-line:component-selector
|
|
330
|
+
selector: 'material-add-reference-widget',
|
|
331
|
+
template: `
|
|
332
|
+
<section [class]="options?.htmlClass || ''" align="end">
|
|
333
|
+
<button mat-raised-button *ngIf="showAddButton"
|
|
334
|
+
[color]="options?.color || 'accent'"
|
|
335
|
+
[disabled]="options?.readonly"
|
|
336
|
+
(click)="addItem($event)">
|
|
337
|
+
<span *ngIf="options?.icon" [class]="options?.icon"></span>
|
|
338
|
+
<span *ngIf="options?.title" [innerHTML]="buttonText"></span>
|
|
339
|
+
</button>
|
|
340
|
+
</section>`,
|
|
341
|
+
changeDetection: ChangeDetectionStrategy.Default
|
|
342
|
+
},] }
|
|
343
|
+
];
|
|
344
|
+
MaterialAddReferenceComponent.ctorParameters = () => [
|
|
345
|
+
{ type: JsonSchemaFormService }
|
|
346
|
+
];
|
|
347
|
+
MaterialAddReferenceComponent.propDecorators = {
|
|
348
|
+
layoutNode: [{ type: Input }],
|
|
349
|
+
layoutIndex: [{ type: Input }],
|
|
350
|
+
dataIndex: [{ type: Input }]
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
class MaterialButtonComponent {
|
|
354
|
+
constructor(jsf) {
|
|
355
|
+
this.jsf = jsf;
|
|
356
|
+
this.controlDisabled = false;
|
|
357
|
+
this.boundControl = false;
|
|
358
|
+
}
|
|
359
|
+
ngOnInit() {
|
|
360
|
+
this.options = this.layoutNode.options || {};
|
|
361
|
+
this.jsf.initializeControl(this);
|
|
362
|
+
if (hasOwn(this.options, 'disabled')) {
|
|
363
|
+
this.controlDisabled = this.options.disabled;
|
|
364
|
+
}
|
|
365
|
+
else if (this.jsf.formOptions.disableInvalidSubmit) {
|
|
366
|
+
this.controlDisabled = !this.jsf.isValid;
|
|
367
|
+
this.jsf.isValidChanges.subscribe(isValid => this.controlDisabled = !isValid);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
updateValue(event) {
|
|
371
|
+
if (typeof this.options.onClick === 'function') {
|
|
372
|
+
this.options.onClick(event);
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
this.jsf.updateValue(this, event.target.value);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
MaterialButtonComponent.decorators = [
|
|
380
|
+
{ type: Component, args: [{
|
|
381
|
+
// tslint:disable-next-line:component-selector
|
|
382
|
+
selector: 'material-button-widget',
|
|
383
|
+
template: `
|
|
384
|
+
<div class="button-row" [class]="options?.htmlClass || ''">
|
|
385
|
+
<button mat-raised-button
|
|
386
|
+
[attr.readonly]="options?.readonly ? 'readonly' : null"
|
|
387
|
+
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
388
|
+
[color]="options?.color || 'primary'"
|
|
389
|
+
[disabled]="controlDisabled || options?.readonly"
|
|
390
|
+
[id]="'control' + layoutNode?._id"
|
|
391
|
+
[name]="controlName"
|
|
392
|
+
[type]="layoutNode?.type"
|
|
393
|
+
[value]="controlValue"
|
|
394
|
+
(click)="updateValue($event)">
|
|
395
|
+
<mat-icon *ngIf="options?.icon" class="mat-24">{{options?.icon}}</mat-icon>
|
|
396
|
+
<span *ngIf="options?.title" [innerHTML]="options?.title"></span>
|
|
397
|
+
</button>
|
|
398
|
+
</div>`,
|
|
399
|
+
styles: [` button { margin-top: 10px; } `]
|
|
400
|
+
},] }
|
|
401
|
+
];
|
|
402
|
+
MaterialButtonComponent.ctorParameters = () => [
|
|
403
|
+
{ type: JsonSchemaFormService }
|
|
404
|
+
];
|
|
405
|
+
MaterialButtonComponent.propDecorators = {
|
|
406
|
+
layoutNode: [{ type: Input }],
|
|
407
|
+
layoutIndex: [{ type: Input }],
|
|
408
|
+
dataIndex: [{ type: Input }]
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
class MaterialButtonGroupComponent {
|
|
412
|
+
constructor(jsf) {
|
|
413
|
+
this.jsf = jsf;
|
|
414
|
+
this.controlDisabled = false;
|
|
415
|
+
this.boundControl = false;
|
|
416
|
+
this.radiosList = [];
|
|
417
|
+
this.vertical = false;
|
|
418
|
+
}
|
|
419
|
+
ngOnInit() {
|
|
420
|
+
this.options = this.layoutNode.options || {};
|
|
421
|
+
this.radiosList = buildTitleMap(this.options.titleMap || this.options.enumNames, this.options.enum, true);
|
|
422
|
+
this.jsf.initializeControl(this);
|
|
423
|
+
}
|
|
424
|
+
updateValue(value) {
|
|
425
|
+
this.options.showErrors = true;
|
|
426
|
+
this.jsf.updateValue(this, value);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
MaterialButtonGroupComponent.decorators = [
|
|
430
|
+
{ type: Component, args: [{
|
|
431
|
+
// tslint:disable-next-line:component-selector
|
|
432
|
+
selector: 'material-button-group-widget',
|
|
433
|
+
template: `
|
|
434
|
+
<div>
|
|
435
|
+
<div *ngIf="options?.title">
|
|
436
|
+
<label
|
|
437
|
+
[attr.for]="'control' + layoutNode?._id"
|
|
438
|
+
[class]="options?.labelHtmlClass || ''"
|
|
439
|
+
[style.display]="options?.notitle ? 'none' : ''"
|
|
440
|
+
[innerHTML]="options?.title"></label>
|
|
441
|
+
</div>
|
|
442
|
+
<mat-button-toggle-group
|
|
443
|
+
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
444
|
+
[attr.readonly]="options?.readonly ? 'readonly' : null"
|
|
445
|
+
[attr.required]="options?.required"
|
|
446
|
+
[disabled]="controlDisabled || options?.readonly"
|
|
447
|
+
[name]="controlName"
|
|
448
|
+
[value]="controlValue"
|
|
449
|
+
[vertical]="!!options.vertical">
|
|
450
|
+
<mat-button-toggle *ngFor="let radioItem of radiosList"
|
|
451
|
+
[id]="'control' + layoutNode?._id + '/' + radioItem?.name"
|
|
452
|
+
[value]="radioItem?.value"
|
|
453
|
+
(click)="updateValue(radioItem?.value)">
|
|
454
|
+
<span [innerHTML]="radioItem?.name"></span>
|
|
455
|
+
</mat-button-toggle>
|
|
456
|
+
</mat-button-toggle-group>
|
|
457
|
+
<mat-error *ngIf="options?.showErrors && options?.errorMessage"
|
|
458
|
+
[innerHTML]="options?.errorMessage"></mat-error>
|
|
459
|
+
</div>`,
|
|
460
|
+
styles: [` mat-error { font-size: 75%; } `]
|
|
461
|
+
},] }
|
|
462
|
+
];
|
|
463
|
+
MaterialButtonGroupComponent.ctorParameters = () => [
|
|
464
|
+
{ type: JsonSchemaFormService }
|
|
465
|
+
];
|
|
466
|
+
MaterialButtonGroupComponent.propDecorators = {
|
|
467
|
+
layoutNode: [{ type: Input }],
|
|
468
|
+
layoutIndex: [{ type: Input }],
|
|
469
|
+
dataIndex: [{ type: Input }]
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
class MaterialCheckboxComponent {
|
|
473
|
+
constructor(jsf) {
|
|
474
|
+
this.jsf = jsf;
|
|
475
|
+
this.controlDisabled = false;
|
|
476
|
+
this.boundControl = false;
|
|
477
|
+
this.trueValue = true;
|
|
478
|
+
this.falseValue = false;
|
|
479
|
+
this.showSlideToggle = false;
|
|
480
|
+
}
|
|
481
|
+
ngOnInit() {
|
|
482
|
+
this.options = this.layoutNode.options || {};
|
|
483
|
+
this.jsf.initializeControl(this, !this.options.readonly);
|
|
484
|
+
if (this.controlValue === null || this.controlValue === undefined) {
|
|
485
|
+
this.controlValue = false;
|
|
486
|
+
this.jsf.updateValue(this, this.falseValue);
|
|
487
|
+
}
|
|
488
|
+
if (this.layoutNode.type === 'slide-toggle' ||
|
|
489
|
+
this.layoutNode.format === 'slide-toggle') {
|
|
490
|
+
this.showSlideToggle = true;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
updateValue(event) {
|
|
494
|
+
this.options.showErrors = true;
|
|
495
|
+
this.jsf.updateValue(this, event.checked ? this.trueValue : this.falseValue);
|
|
496
|
+
}
|
|
497
|
+
get isChecked() {
|
|
498
|
+
return this.jsf.getFormControlValue(this) === this.trueValue;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
MaterialCheckboxComponent.decorators = [
|
|
502
|
+
{ type: Component, args: [{
|
|
503
|
+
// tslint:disable-next-line:component-selector
|
|
504
|
+
selector: 'material-checkbox-widget',
|
|
505
|
+
template: `
|
|
506
|
+
<mat-checkbox *ngIf="boundControl && !showSlideToggle"
|
|
507
|
+
[formControl]="formControl"
|
|
508
|
+
align="left"
|
|
509
|
+
[color]="options?.color || 'primary'"
|
|
510
|
+
[id]="'control' + layoutNode?._id"
|
|
511
|
+
labelPosition="after"
|
|
512
|
+
[name]="controlName"
|
|
513
|
+
(blur)="options.showErrors = true">
|
|
514
|
+
<span *ngIf="options?.title"
|
|
515
|
+
class="checkbox-name"
|
|
516
|
+
[style.display]="options?.notitle ? 'none' : ''"
|
|
517
|
+
[innerHTML]="options?.title"></span>
|
|
518
|
+
</mat-checkbox>
|
|
519
|
+
<mat-checkbox *ngIf="!boundControl && !showSlideToggle"
|
|
520
|
+
align="left"
|
|
521
|
+
[color]="options?.color || 'primary'"
|
|
522
|
+
[disabled]="controlDisabled || options?.readonly"
|
|
523
|
+
[id]="'control' + layoutNode?._id"
|
|
524
|
+
labelPosition="after"
|
|
525
|
+
[name]="controlName"
|
|
526
|
+
[checked]="isChecked"
|
|
527
|
+
(blur)="options.showErrors = true"
|
|
528
|
+
(change)="updateValue($event)">
|
|
529
|
+
<span *ngIf="options?.title"
|
|
530
|
+
class="checkbox-name"
|
|
531
|
+
[style.display]="options?.notitle ? 'none' : ''"
|
|
532
|
+
[innerHTML]="options?.title"></span>
|
|
533
|
+
</mat-checkbox>
|
|
534
|
+
<mat-slide-toggle *ngIf="boundControl && showSlideToggle"
|
|
535
|
+
[formControl]="formControl"
|
|
536
|
+
align="left"
|
|
537
|
+
[color]="options?.color || 'primary'"
|
|
538
|
+
[id]="'control' + layoutNode?._id"
|
|
539
|
+
labelPosition="after"
|
|
540
|
+
[name]="controlName"
|
|
541
|
+
(blur)="options.showErrors = true">
|
|
542
|
+
<span *ngIf="options?.title"
|
|
543
|
+
class="checkbox-name"
|
|
544
|
+
[style.display]="options?.notitle ? 'none' : ''"
|
|
545
|
+
[innerHTML]="options?.title"></span>
|
|
546
|
+
</mat-slide-toggle>
|
|
547
|
+
<mat-slide-toggle *ngIf="!boundControl && showSlideToggle"
|
|
548
|
+
align="left"
|
|
549
|
+
[color]="options?.color || 'primary'"
|
|
550
|
+
[disabled]="controlDisabled || options?.readonly"
|
|
551
|
+
[id]="'control' + layoutNode?._id"
|
|
552
|
+
labelPosition="after"
|
|
553
|
+
[name]="controlName"
|
|
554
|
+
[checked]="isChecked"
|
|
555
|
+
(blur)="options.showErrors = true"
|
|
556
|
+
(change)="updateValue($event)">
|
|
557
|
+
<span *ngIf="options?.title"
|
|
558
|
+
class="checkbox-name"
|
|
559
|
+
[style.display]="options?.notitle ? 'none' : ''"
|
|
560
|
+
[innerHTML]="options?.title"></span>
|
|
561
|
+
</mat-slide-toggle>
|
|
562
|
+
<mat-error *ngIf="options?.showErrors && options?.errorMessage"
|
|
563
|
+
[innerHTML]="options?.errorMessage"></mat-error>`,
|
|
564
|
+
styles: [`
|
|
565
|
+
.checkbox-name { white-space: nowrap; }
|
|
566
|
+
mat-error { font-size: 75%; }
|
|
567
|
+
`]
|
|
568
|
+
},] }
|
|
569
|
+
];
|
|
570
|
+
MaterialCheckboxComponent.ctorParameters = () => [
|
|
571
|
+
{ type: JsonSchemaFormService }
|
|
572
|
+
];
|
|
573
|
+
MaterialCheckboxComponent.propDecorators = {
|
|
574
|
+
layoutNode: [{ type: Input }],
|
|
575
|
+
layoutIndex: [{ type: Input }],
|
|
576
|
+
dataIndex: [{ type: Input }]
|
|
577
|
+
};
|
|
578
|
+
|
|
579
|
+
// TODO: Change this to use a Selection List instead?
|
|
580
|
+
// https://material.angular.io/components/list/overview
|
|
581
|
+
class MaterialCheckboxesComponent {
|
|
582
|
+
constructor(jsf) {
|
|
583
|
+
this.jsf = jsf;
|
|
584
|
+
this.controlDisabled = false;
|
|
585
|
+
this.boundControl = false;
|
|
586
|
+
this.horizontalList = false;
|
|
587
|
+
this.checkboxList = [];
|
|
588
|
+
}
|
|
589
|
+
ngOnInit() {
|
|
590
|
+
this.options = this.layoutNode.options || {};
|
|
591
|
+
this.horizontalList = this.layoutNode.type === 'checkboxes-inline' ||
|
|
592
|
+
this.layoutNode.type === 'checkboxbuttons';
|
|
593
|
+
this.jsf.initializeControl(this);
|
|
594
|
+
this.checkboxList = buildTitleMap(this.options.titleMap || this.options.enumNames, this.options.enum, true);
|
|
595
|
+
if (this.boundControl) {
|
|
596
|
+
const formArray = this.jsf.getFormControl(this);
|
|
597
|
+
for (const checkboxItem of this.checkboxList) {
|
|
598
|
+
checkboxItem.checked = formArray.value.includes(checkboxItem.value);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
get allChecked() {
|
|
603
|
+
return this.checkboxList.filter(t => t.checked).length === this.checkboxList.length;
|
|
604
|
+
}
|
|
605
|
+
get someChecked() {
|
|
606
|
+
const checkedItems = this.checkboxList.filter(t => t.checked).length;
|
|
607
|
+
return checkedItems > 0 && checkedItems < this.checkboxList.length;
|
|
608
|
+
}
|
|
609
|
+
updateValue() {
|
|
610
|
+
this.options.showErrors = true;
|
|
611
|
+
if (this.boundControl) {
|
|
612
|
+
this.jsf.updateArrayCheckboxList(this, this.checkboxList);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
updateAllValues(event) {
|
|
616
|
+
this.options.showErrors = true;
|
|
617
|
+
this.checkboxList.forEach(t => t.checked = event.checked);
|
|
618
|
+
this.updateValue();
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
MaterialCheckboxesComponent.decorators = [
|
|
622
|
+
{ type: Component, args: [{
|
|
623
|
+
// tslint:disable-next-line:component-selector
|
|
624
|
+
selector: 'material-checkboxes-widget',
|
|
625
|
+
template: `
|
|
626
|
+
<div>
|
|
627
|
+
<mat-checkbox type="checkbox"
|
|
628
|
+
[checked]="allChecked"
|
|
629
|
+
[color]="options?.color || 'primary'"
|
|
630
|
+
[disabled]="controlDisabled || options?.readonly"
|
|
631
|
+
[indeterminate]="someChecked"
|
|
632
|
+
[name]="options?.name"
|
|
633
|
+
(blur)="options.showErrors = true"
|
|
634
|
+
(change)="updateAllValues($event)">
|
|
635
|
+
<span class="checkbox-name" [innerHTML]="options?.name"></span>
|
|
636
|
+
</mat-checkbox>
|
|
637
|
+
<label *ngIf="options?.title"
|
|
638
|
+
class="title"
|
|
639
|
+
[class]="options?.labelHtmlClass || ''"
|
|
640
|
+
[style.display]="options?.notitle ? 'none' : ''"
|
|
641
|
+
[innerHTML]="options?.title"></label>
|
|
642
|
+
<ul class="checkbox-list" [class.horizontal-list]="horizontalList">
|
|
643
|
+
<li *ngFor="let checkboxItem of checkboxList"
|
|
644
|
+
[class]="options?.htmlClass || ''">
|
|
645
|
+
<mat-checkbox type="checkbox"
|
|
646
|
+
[(ngModel)]="checkboxItem.checked"
|
|
647
|
+
[color]="options?.color || 'primary'"
|
|
648
|
+
[disabled]="controlDisabled || options?.readonly"
|
|
649
|
+
[name]="checkboxItem?.name"
|
|
650
|
+
(blur)="options.showErrors = true"
|
|
651
|
+
(change)="updateValue()">
|
|
652
|
+
<span class="checkbox-name" [innerHTML]="checkboxItem?.name"></span>
|
|
653
|
+
</mat-checkbox>
|
|
654
|
+
</li>
|
|
655
|
+
</ul>
|
|
656
|
+
<mat-error *ngIf="options?.showErrors && options?.errorMessage"
|
|
657
|
+
[innerHTML]="options?.errorMessage"></mat-error>
|
|
658
|
+
</div>`,
|
|
659
|
+
styles: [`
|
|
660
|
+
.title { font-weight: bold; }
|
|
661
|
+
.checkbox-list { list-style-type: none; }
|
|
662
|
+
.horizontal-list > li { display: inline-block; margin-right: 10px; zoom: 1; }
|
|
663
|
+
.checkbox-name { white-space: nowrap; }
|
|
664
|
+
mat-error { font-size: 75%; }
|
|
665
|
+
`]
|
|
666
|
+
},] }
|
|
667
|
+
];
|
|
668
|
+
MaterialCheckboxesComponent.ctorParameters = () => [
|
|
669
|
+
{ type: JsonSchemaFormService }
|
|
670
|
+
];
|
|
671
|
+
MaterialCheckboxesComponent.propDecorators = {
|
|
672
|
+
layoutNode: [{ type: Input }],
|
|
673
|
+
layoutIndex: [{ type: Input }],
|
|
674
|
+
dataIndex: [{ type: Input }]
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
// TODO: Add this control
|
|
678
|
+
class MaterialChipListComponent {
|
|
679
|
+
constructor(jsf) {
|
|
680
|
+
this.jsf = jsf;
|
|
681
|
+
this.controlDisabled = false;
|
|
682
|
+
this.boundControl = false;
|
|
683
|
+
}
|
|
684
|
+
ngOnInit() {
|
|
685
|
+
this.options = this.layoutNode.options || {};
|
|
686
|
+
this.jsf.initializeControl(this);
|
|
687
|
+
}
|
|
688
|
+
updateValue(event) {
|
|
689
|
+
this.jsf.updateValue(this, event.target.value);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
MaterialChipListComponent.decorators = [
|
|
693
|
+
{ type: Component, args: [{
|
|
694
|
+
// tslint:disable-next-line:component-selector
|
|
695
|
+
selector: 'material-chip-list-widget',
|
|
696
|
+
template: ``
|
|
697
|
+
},] }
|
|
698
|
+
];
|
|
699
|
+
MaterialChipListComponent.ctorParameters = () => [
|
|
700
|
+
{ type: JsonSchemaFormService }
|
|
701
|
+
];
|
|
702
|
+
MaterialChipListComponent.propDecorators = {
|
|
703
|
+
layoutNode: [{ type: Input }],
|
|
704
|
+
layoutIndex: [{ type: Input }],
|
|
705
|
+
dataIndex: [{ type: Input }]
|
|
706
|
+
};
|
|
707
|
+
|
|
708
|
+
class MaterialDatepickerComponent {
|
|
709
|
+
constructor(matFormFieldDefaultOptions, jsf) {
|
|
710
|
+
this.matFormFieldDefaultOptions = matFormFieldDefaultOptions;
|
|
711
|
+
this.jsf = jsf;
|
|
712
|
+
this.controlDisabled = false;
|
|
713
|
+
this.boundControl = false;
|
|
714
|
+
this.autoCompleteList = [];
|
|
715
|
+
}
|
|
716
|
+
ngOnInit() {
|
|
717
|
+
this.options = this.layoutNode.options || {};
|
|
718
|
+
this.jsf.initializeControl(this, !this.options.readonly);
|
|
719
|
+
if (this.controlValue) {
|
|
720
|
+
this.formControl.setValue(dateToString(this.controlValue, this.options));
|
|
721
|
+
}
|
|
722
|
+
if (!this.options.notitle && !this.options.description && this.options.placeholder) {
|
|
723
|
+
this.options.description = this.options.placeholder;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
updateValue(event) {
|
|
727
|
+
this.options.showErrors = true;
|
|
728
|
+
if (event.value) {
|
|
729
|
+
this.formControl.setValue(dateToString(event.value, this.options));
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
MaterialDatepickerComponent.decorators = [
|
|
734
|
+
{ type: Component, args: [{
|
|
735
|
+
// tslint:disable-next-line:component-selector
|
|
736
|
+
selector: 'material-datepicker-widget',
|
|
737
|
+
template: `
|
|
738
|
+
<mat-form-field [appearance]="options?.appearance || matFormFieldDefaultOptions?.appearance || 'standard'"
|
|
739
|
+
[class]="options?.htmlClass || ''"
|
|
740
|
+
[floatLabel]="options?.floatLabel || matFormFieldDefaultOptions?.floatLabel || (options?.notitle ? 'never' : 'auto')"
|
|
741
|
+
[hideRequiredMarker]="options?.hideRequired ? 'true' : 'false'"
|
|
742
|
+
[style.width]="'100%'">
|
|
743
|
+
<mat-label *ngIf="!options?.notitle">{{options?.title}}</mat-label>
|
|
744
|
+
<span matPrefix *ngIf="options?.prefix || options?.fieldAddonLeft"
|
|
745
|
+
[innerHTML]="options?.prefix || options?.fieldAddonLeft"></span>
|
|
746
|
+
<input matInput *ngIf="boundControl"
|
|
747
|
+
[formControl]="formControl"
|
|
748
|
+
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
749
|
+
[attr.list]="'control' + layoutNode?._id + 'Autocomplete'"
|
|
750
|
+
[attr.readonly]="options?.readonly ? 'readonly' : null"
|
|
751
|
+
[id]="'control' + layoutNode?._id"
|
|
752
|
+
[max]="options?.maximum"
|
|
753
|
+
[matDatepicker]="picker"
|
|
754
|
+
[min]="options?.minimum"
|
|
755
|
+
[name]="controlName"
|
|
756
|
+
[placeholder]="options?.title"
|
|
757
|
+
[readonly]="options?.readonly"
|
|
758
|
+
[required]="options?.required"
|
|
759
|
+
[style.width]="'100%'"
|
|
760
|
+
(blur)="options.showErrors = true"
|
|
761
|
+
(dateChange)="updateValue($event)"
|
|
762
|
+
(dateInput)="updateValue($event)">
|
|
763
|
+
<input matInput *ngIf="!boundControl"
|
|
764
|
+
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
765
|
+
[attr.list]="'control' + layoutNode?._id + 'Autocomplete'"
|
|
766
|
+
[attr.readonly]="options?.readonly ? 'readonly' : null"
|
|
767
|
+
[disabled]="controlDisabled || options?.readonly"
|
|
768
|
+
[id]="'control' + layoutNode?._id"
|
|
769
|
+
[max]="options?.maximum"
|
|
770
|
+
[matDatepicker]="picker"
|
|
771
|
+
[min]="options?.minimum"
|
|
772
|
+
[name]="controlName"
|
|
773
|
+
[placeholder]="options?.title"
|
|
774
|
+
[required]="options?.required"
|
|
775
|
+
[style.width]="'100%'"
|
|
776
|
+
[readonly]="options?.readonly"
|
|
777
|
+
(blur)="options.showErrors = true"
|
|
778
|
+
(dateChange)="updateValue($event)"
|
|
779
|
+
(dateInput)="updateValue($event)">
|
|
780
|
+
<span matSuffix *ngIf="options?.suffix || options?.fieldAddonRight"
|
|
781
|
+
[innerHTML]="options?.suffix || options?.fieldAddonRight"></span>
|
|
782
|
+
<mat-hint *ngIf="options?.description && (!options?.showErrors || !options?.errorMessage)"
|
|
783
|
+
align="end" [innerHTML]="options?.description"></mat-hint>
|
|
784
|
+
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
|
|
785
|
+
</mat-form-field>
|
|
786
|
+
<mat-datepicker #picker ></mat-datepicker>
|
|
787
|
+
<mat-error *ngIf="options?.showErrors && options?.errorMessage"
|
|
788
|
+
[innerHTML]="options?.errorMessage"></mat-error>`,
|
|
789
|
+
styles: [`
|
|
790
|
+
mat-error { font-size: 75%; margin-top: -1rem; margin-bottom: 0.5rem; }
|
|
791
|
+
::ng-deep json-schema-form mat-form-field .mat-form-field-wrapper .mat-form-field-flex
|
|
792
|
+
.mat-form-field-infix { width: initial; }
|
|
793
|
+
`]
|
|
794
|
+
},] }
|
|
795
|
+
];
|
|
796
|
+
MaterialDatepickerComponent.ctorParameters = () => [
|
|
797
|
+
{ type: undefined, decorators: [{ type: Inject, args: [MAT_FORM_FIELD_DEFAULT_OPTIONS,] }, { type: Optional }] },
|
|
798
|
+
{ type: JsonSchemaFormService }
|
|
799
|
+
];
|
|
800
|
+
MaterialDatepickerComponent.propDecorators = {
|
|
801
|
+
layoutNode: [{ type: Input }],
|
|
802
|
+
layoutIndex: [{ type: Input }],
|
|
803
|
+
dataIndex: [{ type: Input }]
|
|
804
|
+
};
|
|
805
|
+
|
|
806
|
+
class MaterialDesignFrameworkComponent {
|
|
807
|
+
constructor(changeDetector, jsf) {
|
|
808
|
+
this.changeDetector = changeDetector;
|
|
809
|
+
this.jsf = jsf;
|
|
810
|
+
this.frameworkInitialized = false;
|
|
811
|
+
this.formControl = null;
|
|
812
|
+
this.parentArray = null;
|
|
813
|
+
this.isOrderable = false;
|
|
814
|
+
this.dynamicTitle = null;
|
|
815
|
+
}
|
|
816
|
+
get showRemoveButton() {
|
|
817
|
+
if (!this.layoutNode || !this.widgetOptions.removable ||
|
|
818
|
+
this.widgetOptions.readonly || this.layoutNode.type === '$ref') {
|
|
819
|
+
return false;
|
|
820
|
+
}
|
|
821
|
+
if (this.layoutNode.recursiveReference) {
|
|
822
|
+
return true;
|
|
823
|
+
}
|
|
824
|
+
if (!this.layoutNode.arrayItem || !this.parentArray) {
|
|
825
|
+
return false;
|
|
826
|
+
}
|
|
827
|
+
// If array length <= minItems, don't allow removing any items
|
|
828
|
+
return this.parentArray.items.length - 1 <= this.parentArray.options.minItems ? false :
|
|
829
|
+
// For removable list items, allow removing any item
|
|
830
|
+
this.layoutNode.arrayItemType === 'list' ? true :
|
|
831
|
+
// For removable tuple items, only allow removing last item in list
|
|
832
|
+
this.layoutIndex[this.layoutIndex.length - 1] === this.parentArray.items.length - 2;
|
|
833
|
+
}
|
|
834
|
+
ngOnInit() {
|
|
835
|
+
this.initializeFramework();
|
|
836
|
+
}
|
|
837
|
+
ngOnChanges() {
|
|
838
|
+
if (!this.frameworkInitialized) {
|
|
839
|
+
this.initializeFramework();
|
|
840
|
+
}
|
|
841
|
+
if (this.dynamicTitle) {
|
|
842
|
+
this.updateTitle();
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
initializeFramework() {
|
|
846
|
+
if (this.layoutNode) {
|
|
847
|
+
this.options = cloneDeep(this.layoutNode.options || {});
|
|
848
|
+
this.widgetLayoutNode = Object.assign(Object.assign({}, this.layoutNode), { options: cloneDeep(this.layoutNode.options || {}) });
|
|
849
|
+
this.widgetOptions = this.widgetLayoutNode.options;
|
|
850
|
+
this.formControl = this.jsf.getFormControl(this);
|
|
851
|
+
if (isDefined(this.widgetOptions.minimum) &&
|
|
852
|
+
isDefined(this.widgetOptions.maximum) &&
|
|
853
|
+
this.widgetOptions.multipleOf >= 1) {
|
|
854
|
+
this.layoutNode.type = 'range';
|
|
855
|
+
}
|
|
856
|
+
if (!['$ref', 'advancedfieldset', 'authfieldset', 'button', 'card',
|
|
857
|
+
'checkbox', 'expansion-panel', 'help', 'message', 'msg', 'section',
|
|
858
|
+
'submit', 'tabarray', 'tabs'].includes(this.layoutNode.type) &&
|
|
859
|
+
/{{.+?}}/.test(this.widgetOptions.title || '')) {
|
|
860
|
+
this.dynamicTitle = this.widgetOptions.title;
|
|
861
|
+
this.updateTitle();
|
|
862
|
+
}
|
|
863
|
+
if (this.layoutNode.arrayItem && this.layoutNode.type !== '$ref') {
|
|
864
|
+
this.parentArray = this.jsf.getParentNode(this);
|
|
865
|
+
if (this.parentArray) {
|
|
866
|
+
this.isOrderable =
|
|
867
|
+
this.parentArray.type.slice(0, 3) !== 'tab' &&
|
|
868
|
+
this.layoutNode.arrayItemType === 'list' &&
|
|
869
|
+
!this.widgetOptions.readonly &&
|
|
870
|
+
this.parentArray.options.orderable;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
this.frameworkInitialized = true;
|
|
874
|
+
}
|
|
875
|
+
else {
|
|
876
|
+
this.options = {};
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
updateTitle() {
|
|
880
|
+
this.widgetLayoutNode.options.title = this.jsf.parseText(this.dynamicTitle, this.jsf.getFormControlValue(this), this.jsf.getFormControlGroup(this).value, this.dataIndex[this.dataIndex.length - 1]);
|
|
881
|
+
}
|
|
882
|
+
removeItem() {
|
|
883
|
+
this.jsf.removeItem(this);
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
MaterialDesignFrameworkComponent.decorators = [
|
|
887
|
+
{ type: Component, args: [{
|
|
888
|
+
// tslint:disable-next-line:component-selector
|
|
889
|
+
selector: 'material-design-framework',
|
|
890
|
+
template: "<div\n [class.array-item]=\"widgetLayoutNode?.arrayItem && widgetLayoutNode?.type !== '$ref'\"\n [orderable]=\"isOrderable\"\n [dataIndex]=\"dataIndex\"\n [layoutIndex]=\"layoutIndex\"\n [layoutNode]=\"widgetLayoutNode\">\n <svg *ngIf=\"showRemoveButton\"\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"18\" width=\"18\" viewBox=\"0 0 24 24\"\n class=\"close-button\"\n (click)=\"removeItem()\">\n <path\n d=\"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z\"/>\n </svg>\n <select-widget-widget\n [dataIndex]=\"dataIndex\"\n [layoutIndex]=\"layoutIndex\"\n [layoutNode]=\"widgetLayoutNode\"></select-widget-widget>\n</div>\n<div class=\"spacer\" *ngIf=\"widgetLayoutNode?.arrayItem && widgetLayoutNode?.type !== '$ref'\"></div>\n",
|
|
891
|
+
styles: [".array-item{border-radius:2px;box-shadow:0 3px 1px -2px rgba(0,0,0,.2),0 2px 2px 0 rgba(0,0,0,.14),0 1px 5px 0 rgba(0,0,0,.12);padding:6px;position:relative;transition:all .28s cubic-bezier(.4,0,.2,1)}.close-button{cursor:pointer;position:absolute;top:6px;right:6px;fill:rgba(0,0,0,.4);visibility:hidden;z-index:500}.close-button:hover{fill:rgba(0,0,0,.8)}.array-item:hover>.close-button{visibility:visible}.spacer{margin:6px 0}[draggable=true]:hover{box-shadow:0 5px 5px -3px rgba(0,0,0,.2),0 8px 10px 1px rgba(0,0,0,.14),0 3px 14px 2px rgba(0,0,0,.12);cursor:move;z-index:10}[draggable=true].drag-target-top{box-shadow:0 -2px 0 #000;position:relative;z-index:20}[draggable=true].drag-target-bottom{box-shadow:0 2px 0 #000;position:relative;z-index:20}"]
|
|
892
|
+
},] }
|
|
893
|
+
];
|
|
894
|
+
MaterialDesignFrameworkComponent.ctorParameters = () => [
|
|
895
|
+
{ type: ChangeDetectorRef },
|
|
896
|
+
{ type: JsonSchemaFormService }
|
|
897
|
+
];
|
|
898
|
+
MaterialDesignFrameworkComponent.propDecorators = {
|
|
899
|
+
layoutNode: [{ type: Input }],
|
|
900
|
+
layoutIndex: [{ type: Input }],
|
|
901
|
+
dataIndex: [{ type: Input }]
|
|
902
|
+
};
|
|
903
|
+
|
|
904
|
+
// TODO: Add this control
|
|
905
|
+
class MaterialFileComponent {
|
|
906
|
+
constructor(jsf) {
|
|
907
|
+
this.jsf = jsf;
|
|
908
|
+
this.controlDisabled = false;
|
|
909
|
+
this.boundControl = false;
|
|
910
|
+
}
|
|
911
|
+
ngOnInit() {
|
|
912
|
+
this.options = this.layoutNode.options || {};
|
|
913
|
+
this.jsf.initializeControl(this);
|
|
914
|
+
}
|
|
915
|
+
updateValue(event) {
|
|
916
|
+
this.jsf.updateValue(this, event.target.value);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
MaterialFileComponent.decorators = [
|
|
920
|
+
{ type: Component, args: [{
|
|
921
|
+
// tslint:disable-next-line:component-selector
|
|
922
|
+
selector: 'material-file-widget',
|
|
923
|
+
template: ``
|
|
924
|
+
},] }
|
|
925
|
+
];
|
|
926
|
+
MaterialFileComponent.ctorParameters = () => [
|
|
927
|
+
{ type: JsonSchemaFormService }
|
|
928
|
+
];
|
|
929
|
+
MaterialFileComponent.propDecorators = {
|
|
930
|
+
layoutNode: [{ type: Input }],
|
|
931
|
+
layoutIndex: [{ type: Input }],
|
|
932
|
+
dataIndex: [{ type: Input }]
|
|
933
|
+
};
|
|
934
|
+
|
|
935
|
+
class MaterialInputComponent {
|
|
936
|
+
constructor(matFormFieldDefaultOptions, jsf) {
|
|
937
|
+
this.matFormFieldDefaultOptions = matFormFieldDefaultOptions;
|
|
938
|
+
this.jsf = jsf;
|
|
939
|
+
this.controlDisabled = false;
|
|
940
|
+
this.boundControl = false;
|
|
941
|
+
this.autoCompleteList = [];
|
|
942
|
+
}
|
|
943
|
+
ngOnInit() {
|
|
944
|
+
this.options = this.layoutNode.options || {};
|
|
945
|
+
this.jsf.initializeControl(this);
|
|
946
|
+
if (!this.options.notitle && !this.options.description && this.options.placeholder) {
|
|
947
|
+
this.options.description = this.options.placeholder;
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
updateValue(event) {
|
|
951
|
+
this.jsf.updateValue(this, event.target.value);
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
MaterialInputComponent.decorators = [
|
|
955
|
+
{ type: Component, args: [{
|
|
956
|
+
// tslint:disable-next-line:component-selector
|
|
957
|
+
selector: 'material-input-widget',
|
|
958
|
+
template: `
|
|
959
|
+
<mat-form-field [appearance]="options?.appearance || matFormFieldDefaultOptions?.appearance || 'standard'"
|
|
960
|
+
[class]="options?.htmlClass || ''"
|
|
961
|
+
[floatLabel]="options?.floatLabel || matFormFieldDefaultOptions?.floatLabel || (options?.notitle ? 'never' : 'auto')"
|
|
962
|
+
[hideRequiredMarker]="options?.hideRequired ? 'true' : 'false'"
|
|
963
|
+
[style.width]="'100%'">
|
|
964
|
+
<mat-label *ngIf="!options?.notitle">{{options?.title}}</mat-label>
|
|
965
|
+
<span matPrefix *ngIf="options?.prefix || options?.fieldAddonLeft"
|
|
966
|
+
[innerHTML]="options?.prefix || options?.fieldAddonLeft"></span>
|
|
967
|
+
<input matInput *ngIf="boundControl"
|
|
968
|
+
[formControl]="formControl"
|
|
969
|
+
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
970
|
+
[attr.list]="'control' + layoutNode?._id + 'Autocomplete'"
|
|
971
|
+
[attr.maxlength]="options?.maxLength"
|
|
972
|
+
[attr.minlength]="options?.minLength"
|
|
973
|
+
[attr.pattern]="options?.pattern"
|
|
974
|
+
[readonly]="options?.readonly ? 'readonly' : null"
|
|
975
|
+
[id]="'control' + layoutNode?._id"
|
|
976
|
+
[name]="controlName"
|
|
977
|
+
[placeholder]="options?.notitle ? options?.placeholder : options?.title"
|
|
978
|
+
[required]="options?.required"
|
|
979
|
+
[style.width]="'100%'"
|
|
980
|
+
[type]="layoutNode?.type"
|
|
981
|
+
(blur)="options.showErrors = true">
|
|
982
|
+
<input matInput *ngIf="!boundControl"
|
|
983
|
+
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
984
|
+
[attr.list]="'control' + layoutNode?._id + 'Autocomplete'"
|
|
985
|
+
[attr.maxlength]="options?.maxLength"
|
|
986
|
+
[attr.minlength]="options?.minLength"
|
|
987
|
+
[attr.pattern]="options?.pattern"
|
|
988
|
+
[disabled]="controlDisabled"
|
|
989
|
+
[id]="'control' + layoutNode?._id"
|
|
990
|
+
[name]="controlName"
|
|
991
|
+
[placeholder]="options?.notitle ? options?.placeholder : options?.title"
|
|
992
|
+
[readonly]="options?.readonly ? 'readonly' : null"
|
|
993
|
+
[required]="options?.required"
|
|
994
|
+
[style.width]="'100%'"
|
|
995
|
+
[type]="layoutNode?.type"
|
|
996
|
+
[value]="controlValue"
|
|
997
|
+
(input)="updateValue($event)"
|
|
998
|
+
(blur)="options.showErrors = true">
|
|
999
|
+
<span matSuffix *ngIf="options?.suffix || options?.fieldAddonRight"
|
|
1000
|
+
[innerHTML]="options?.suffix || options?.fieldAddonRight"></span>
|
|
1001
|
+
<mat-hint *ngIf="options?.description && (!options?.showErrors || !options?.errorMessage)"
|
|
1002
|
+
align="end" [innerHTML]="options?.description"></mat-hint>
|
|
1003
|
+
<mat-autocomplete *ngIf="options?.typeahead?.source">
|
|
1004
|
+
<mat-option *ngFor="let word of options?.typeahead?.source"
|
|
1005
|
+
[value]="word">{{word}}</mat-option>
|
|
1006
|
+
</mat-autocomplete>
|
|
1007
|
+
</mat-form-field>
|
|
1008
|
+
<mat-error *ngIf="options?.showErrors && options?.errorMessage"
|
|
1009
|
+
[innerHTML]="options?.errorMessage"></mat-error>`,
|
|
1010
|
+
styles: [`
|
|
1011
|
+
mat-error { font-size: 75%; margin-top: -1rem; margin-bottom: 0.5rem; }
|
|
1012
|
+
::ng-deep json-schema-form mat-form-field .mat-form-field-wrapper .mat-form-field-flex
|
|
1013
|
+
.mat-form-field-infix { width: initial; }
|
|
1014
|
+
`]
|
|
1015
|
+
},] }
|
|
1016
|
+
];
|
|
1017
|
+
MaterialInputComponent.ctorParameters = () => [
|
|
1018
|
+
{ type: undefined, decorators: [{ type: Inject, args: [MAT_FORM_FIELD_DEFAULT_OPTIONS,] }, { type: Optional }] },
|
|
1019
|
+
{ type: JsonSchemaFormService }
|
|
1020
|
+
];
|
|
1021
|
+
MaterialInputComponent.propDecorators = {
|
|
1022
|
+
layoutNode: [{ type: Input }],
|
|
1023
|
+
layoutIndex: [{ type: Input }],
|
|
1024
|
+
dataIndex: [{ type: Input }]
|
|
1025
|
+
};
|
|
1026
|
+
|
|
1027
|
+
class MaterialNumberComponent {
|
|
1028
|
+
constructor(matFormFieldDefaultOptions, jsf) {
|
|
1029
|
+
this.matFormFieldDefaultOptions = matFormFieldDefaultOptions;
|
|
1030
|
+
this.jsf = jsf;
|
|
1031
|
+
this.controlDisabled = false;
|
|
1032
|
+
this.boundControl = false;
|
|
1033
|
+
this.allowNegative = true;
|
|
1034
|
+
this.allowDecimal = true;
|
|
1035
|
+
this.allowExponents = false;
|
|
1036
|
+
this.lastValidNumber = '';
|
|
1037
|
+
}
|
|
1038
|
+
ngOnInit() {
|
|
1039
|
+
this.options = this.layoutNode.options || {};
|
|
1040
|
+
this.jsf.initializeControl(this);
|
|
1041
|
+
if (this.layoutNode.dataType === 'integer') {
|
|
1042
|
+
this.allowDecimal = false;
|
|
1043
|
+
}
|
|
1044
|
+
if (!this.options.notitle && !this.options.description && this.options.placeholder) {
|
|
1045
|
+
this.options.description = this.options.placeholder;
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
updateValue(event) {
|
|
1049
|
+
this.jsf.updateValue(this, event.target.value);
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
MaterialNumberComponent.decorators = [
|
|
1053
|
+
{ type: Component, args: [{
|
|
1054
|
+
// tslint:disable-next-line:component-selector
|
|
1055
|
+
selector: 'material-number-widget',
|
|
1056
|
+
template: `
|
|
1057
|
+
<mat-form-field [appearance]="options?.appearance || matFormFieldDefaultOptions?.appearance || 'standard'"
|
|
1058
|
+
[class]="options?.htmlClass || ''"
|
|
1059
|
+
[floatLabel]="options?.floatLabel || matFormFieldDefaultOptions?.floatLabel || (options?.notitle ? 'never' : 'auto')"
|
|
1060
|
+
[hideRequiredMarker]="options?.hideRequired ? 'true' : 'false'"
|
|
1061
|
+
[style.width]="'100%'">
|
|
1062
|
+
<mat-label *ngIf="!options?.notitle">{{options?.title}}</mat-label>
|
|
1063
|
+
<span matPrefix *ngIf="options?.prefix || options?.fieldAddonLeft"
|
|
1064
|
+
[innerHTML]="options?.prefix || options?.fieldAddonLeft"></span>
|
|
1065
|
+
<input matInput *ngIf="boundControl"
|
|
1066
|
+
[formControl]="formControl"
|
|
1067
|
+
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
1068
|
+
[attr.max]="options?.maximum"
|
|
1069
|
+
[attr.min]="options?.minimum"
|
|
1070
|
+
[attr.step]="options?.multipleOf || options?.step || 'any'"
|
|
1071
|
+
[id]="'control' + layoutNode?._id"
|
|
1072
|
+
[name]="controlName"
|
|
1073
|
+
[placeholder]="options?.notitle ? options?.placeholder : options?.title"
|
|
1074
|
+
[readonly]="options?.readonly ? 'readonly' : null"
|
|
1075
|
+
[required]="options?.required"
|
|
1076
|
+
[style.width]="'100%'"
|
|
1077
|
+
[type]="'number'"
|
|
1078
|
+
(blur)="options.showErrors = true">
|
|
1079
|
+
<input matInput *ngIf="!boundControl"
|
|
1080
|
+
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
1081
|
+
[attr.max]="options?.maximum"
|
|
1082
|
+
[attr.min]="options?.minimum"
|
|
1083
|
+
[attr.step]="options?.multipleOf || options?.step || 'any'"
|
|
1084
|
+
[disabled]="controlDisabled"
|
|
1085
|
+
[id]="'control' + layoutNode?._id"
|
|
1086
|
+
[name]="controlName"
|
|
1087
|
+
[placeholder]="options?.notitle ? options?.placeholder : options?.title"
|
|
1088
|
+
[readonly]="options?.readonly ? 'readonly' : null"
|
|
1089
|
+
[required]="options?.required"
|
|
1090
|
+
[style.width]="'100%'"
|
|
1091
|
+
[type]="'number'"
|
|
1092
|
+
[value]="controlValue"
|
|
1093
|
+
(input)="updateValue($event)"
|
|
1094
|
+
(blur)="options.showErrors = true">
|
|
1095
|
+
<span matSuffix *ngIf="options?.suffix || options?.fieldAddonRight"
|
|
1096
|
+
[innerHTML]="options?.suffix || options?.fieldAddonRight"></span>
|
|
1097
|
+
<mat-hint *ngIf="layoutNode?.type === 'range'" align="start"
|
|
1098
|
+
[innerHTML]="controlValue"></mat-hint>
|
|
1099
|
+
<mat-hint *ngIf="options?.description && (!options?.showErrors || !options?.errorMessage)"
|
|
1100
|
+
align="end" [innerHTML]="options?.description"></mat-hint>
|
|
1101
|
+
</mat-form-field>
|
|
1102
|
+
<mat-error *ngIf="options?.showErrors && options?.errorMessage"
|
|
1103
|
+
[innerHTML]="options?.errorMessage"></mat-error>`,
|
|
1104
|
+
styles: [`
|
|
1105
|
+
mat-error { font-size: 75%; margin-top: -1rem; margin-bottom: 0.5rem; }
|
|
1106
|
+
::ng-deep json-schema-form mat-form-field .mat-form-field-wrapper .mat-form-field-flex
|
|
1107
|
+
.mat-form-field-infix { width: initial; }
|
|
1108
|
+
`]
|
|
1109
|
+
},] }
|
|
1110
|
+
];
|
|
1111
|
+
MaterialNumberComponent.ctorParameters = () => [
|
|
1112
|
+
{ type: undefined, decorators: [{ type: Inject, args: [MAT_FORM_FIELD_DEFAULT_OPTIONS,] }, { type: Optional }] },
|
|
1113
|
+
{ type: JsonSchemaFormService }
|
|
1114
|
+
];
|
|
1115
|
+
MaterialNumberComponent.propDecorators = {
|
|
1116
|
+
layoutNode: [{ type: Input }],
|
|
1117
|
+
layoutIndex: [{ type: Input }],
|
|
1118
|
+
dataIndex: [{ type: Input }]
|
|
1119
|
+
};
|
|
1120
|
+
|
|
1121
|
+
// TODO: Add this control
|
|
1122
|
+
class MaterialOneOfComponent {
|
|
1123
|
+
constructor(jsf) {
|
|
1124
|
+
this.jsf = jsf;
|
|
1125
|
+
this.controlDisabled = false;
|
|
1126
|
+
this.boundControl = false;
|
|
1127
|
+
}
|
|
1128
|
+
ngOnInit() {
|
|
1129
|
+
this.options = this.layoutNode.options || {};
|
|
1130
|
+
this.jsf.initializeControl(this);
|
|
1131
|
+
}
|
|
1132
|
+
updateValue(event) {
|
|
1133
|
+
this.jsf.updateValue(this, event.target.value);
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
MaterialOneOfComponent.decorators = [
|
|
1137
|
+
{ type: Component, args: [{
|
|
1138
|
+
// tslint:disable-next-line:component-selector
|
|
1139
|
+
selector: 'material-one-of-widget',
|
|
1140
|
+
template: ``
|
|
1141
|
+
},] }
|
|
1142
|
+
];
|
|
1143
|
+
MaterialOneOfComponent.ctorParameters = () => [
|
|
1144
|
+
{ type: JsonSchemaFormService }
|
|
1145
|
+
];
|
|
1146
|
+
MaterialOneOfComponent.propDecorators = {
|
|
1147
|
+
layoutNode: [{ type: Input }],
|
|
1148
|
+
layoutIndex: [{ type: Input }],
|
|
1149
|
+
dataIndex: [{ type: Input }]
|
|
1150
|
+
};
|
|
1151
|
+
|
|
1152
|
+
class MaterialRadiosComponent {
|
|
1153
|
+
constructor(jsf) {
|
|
1154
|
+
this.jsf = jsf;
|
|
1155
|
+
this.controlDisabled = false;
|
|
1156
|
+
this.boundControl = false;
|
|
1157
|
+
this.flexDirection = 'column';
|
|
1158
|
+
this.radiosList = [];
|
|
1159
|
+
}
|
|
1160
|
+
ngOnInit() {
|
|
1161
|
+
this.options = this.layoutNode.options || {};
|
|
1162
|
+
if (this.layoutNode.type === 'radios-inline') {
|
|
1163
|
+
this.flexDirection = 'row';
|
|
1164
|
+
}
|
|
1165
|
+
this.radiosList = buildTitleMap(this.options.titleMap || this.options.enumNames, this.options.enum, true);
|
|
1166
|
+
this.jsf.initializeControl(this, !this.options.readonly);
|
|
1167
|
+
}
|
|
1168
|
+
updateValue(value) {
|
|
1169
|
+
this.options.showErrors = true;
|
|
1170
|
+
this.jsf.updateValue(this, value);
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
MaterialRadiosComponent.decorators = [
|
|
1174
|
+
{ type: Component, args: [{
|
|
1175
|
+
// tslint:disable-next-line:component-selector
|
|
1176
|
+
selector: 'material-radios-widget',
|
|
1177
|
+
template: `
|
|
1178
|
+
<div>
|
|
1179
|
+
<div *ngIf="options?.title">
|
|
1180
|
+
<label
|
|
1181
|
+
[attr.for]="'control' + layoutNode?._id"
|
|
1182
|
+
[class]="options?.labelHtmlClass || ''"
|
|
1183
|
+
[style.display]="options?.notitle ? 'none' : ''"
|
|
1184
|
+
[innerHTML]="options?.title"></label>
|
|
1185
|
+
</div>
|
|
1186
|
+
<mat-radio-group *ngIf="boundControl"
|
|
1187
|
+
[formControl]="formControl"
|
|
1188
|
+
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
1189
|
+
[attr.readonly]="options?.readonly ? 'readonly' : null"
|
|
1190
|
+
[attr.required]="options?.required"
|
|
1191
|
+
[style.flex-direction]="flexDirection"
|
|
1192
|
+
[name]="controlName"
|
|
1193
|
+
(blur)="options.showErrors = true">
|
|
1194
|
+
<mat-radio-button *ngFor="let radioItem of radiosList"
|
|
1195
|
+
[id]="'control' + layoutNode?._id + '/' + radioItem?.name"
|
|
1196
|
+
[value]="radioItem?.value">
|
|
1197
|
+
<span [innerHTML]="radioItem?.name"></span>
|
|
1198
|
+
</mat-radio-button>
|
|
1199
|
+
</mat-radio-group>
|
|
1200
|
+
<mat-radio-group *ngIf="!boundControl"
|
|
1201
|
+
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
1202
|
+
[attr.readonly]="options?.readonly ? 'readonly' : null"
|
|
1203
|
+
[attr.required]="options?.required"
|
|
1204
|
+
[style.flex-direction]="flexDirection"
|
|
1205
|
+
[disabled]="controlDisabled || options?.readonly"
|
|
1206
|
+
[name]="controlName"
|
|
1207
|
+
[value]="controlValue">
|
|
1208
|
+
<mat-radio-button *ngFor="let radioItem of radiosList"
|
|
1209
|
+
[id]="'control' + layoutNode?._id + '/' + radioItem?.name"
|
|
1210
|
+
[value]="radioItem?.value"
|
|
1211
|
+
(click)="updateValue(radioItem?.value)">
|
|
1212
|
+
<span [innerHTML]="radioItem?.name"></span>
|
|
1213
|
+
</mat-radio-button>
|
|
1214
|
+
</mat-radio-group>
|
|
1215
|
+
<mat-error *ngIf="options?.showErrors && options?.errorMessage"
|
|
1216
|
+
[innerHTML]="options?.errorMessage"></mat-error>
|
|
1217
|
+
</div>`,
|
|
1218
|
+
styles: [`
|
|
1219
|
+
mat-radio-group { display: inline-flex; }
|
|
1220
|
+
mat-radio-button { margin: 2px; }
|
|
1221
|
+
mat-error { font-size: 75%; }
|
|
1222
|
+
`]
|
|
1223
|
+
},] }
|
|
1224
|
+
];
|
|
1225
|
+
MaterialRadiosComponent.ctorParameters = () => [
|
|
1226
|
+
{ type: JsonSchemaFormService }
|
|
1227
|
+
];
|
|
1228
|
+
MaterialRadiosComponent.propDecorators = {
|
|
1229
|
+
layoutNode: [{ type: Input }],
|
|
1230
|
+
layoutIndex: [{ type: Input }],
|
|
1231
|
+
dataIndex: [{ type: Input }]
|
|
1232
|
+
};
|
|
1233
|
+
|
|
1234
|
+
class MaterialSelectComponent {
|
|
1235
|
+
constructor(matFormFieldDefaultOptions, jsf) {
|
|
1236
|
+
this.matFormFieldDefaultOptions = matFormFieldDefaultOptions;
|
|
1237
|
+
this.jsf = jsf;
|
|
1238
|
+
this.controlDisabled = false;
|
|
1239
|
+
this.boundControl = false;
|
|
1240
|
+
this.selectList = [];
|
|
1241
|
+
this.isArray = isArray;
|
|
1242
|
+
}
|
|
1243
|
+
ngOnInit() {
|
|
1244
|
+
this.options = this.layoutNode.options || {};
|
|
1245
|
+
this.selectList = buildTitleMap(this.options.titleMap || this.options.enumNames, this.options.enum, !!this.options.required, !!this.options.flatList);
|
|
1246
|
+
this.jsf.initializeControl(this, !this.options.readonly);
|
|
1247
|
+
if (!this.options.notitle && !this.options.description && this.options.placeholder) {
|
|
1248
|
+
this.options.description = this.options.placeholder;
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
updateValue(event) {
|
|
1252
|
+
this.options.showErrors = true;
|
|
1253
|
+
this.jsf.updateValue(this, event.value);
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
MaterialSelectComponent.decorators = [
|
|
1257
|
+
{ type: Component, args: [{
|
|
1258
|
+
// tslint:disable-next-line:component-selector
|
|
1259
|
+
selector: 'material-select-widget',
|
|
1260
|
+
template: `
|
|
1261
|
+
<mat-form-field
|
|
1262
|
+
[appearance]="options?.appearance || matFormFieldDefaultOptions?.appearance || 'standard'"
|
|
1263
|
+
[class]="options?.htmlClass || ''"
|
|
1264
|
+
[floatLabel]="options?.floatLabel || matFormFieldDefaultOptions?.floatLabel || (options?.notitle ? 'never' : 'auto')"
|
|
1265
|
+
[hideRequiredMarker]="options?.hideRequired ? 'true' : 'false'"
|
|
1266
|
+
[style.width]="'100%'">
|
|
1267
|
+
<mat-label *ngIf="!options?.notitle">{{options?.title}}</mat-label>
|
|
1268
|
+
<span matPrefix *ngIf="options?.prefix || options?.fieldAddonLeft"
|
|
1269
|
+
[innerHTML]="options?.prefix || options?.fieldAddonLeft"></span>
|
|
1270
|
+
<mat-select *ngIf="boundControl"
|
|
1271
|
+
[formControl]="formControl"
|
|
1272
|
+
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
1273
|
+
[attr.name]="controlName"
|
|
1274
|
+
[id]="'control' + layoutNode?._id"
|
|
1275
|
+
[multiple]="options?.multiple"
|
|
1276
|
+
[placeholder]="options?.notitle ? options?.placeholder : options?.title"
|
|
1277
|
+
[required]="options?.required"
|
|
1278
|
+
[style.width]="'100%'"
|
|
1279
|
+
(blur)="options.showErrors = true">
|
|
1280
|
+
<ng-template ngFor let-selectItem [ngForOf]="selectList">
|
|
1281
|
+
<mat-option *ngIf="!isArray(selectItem?.items)"
|
|
1282
|
+
[value]="selectItem?.value">
|
|
1283
|
+
<span [innerHTML]="selectItem?.name"></span>
|
|
1284
|
+
</mat-option>
|
|
1285
|
+
<mat-optgroup *ngIf="isArray(selectItem?.items)"
|
|
1286
|
+
[label]="selectItem?.group">
|
|
1287
|
+
<mat-option *ngFor="let subItem of selectItem.items"
|
|
1288
|
+
[value]="subItem?.value">
|
|
1289
|
+
<span [innerHTML]="subItem?.name"></span>
|
|
1290
|
+
</mat-option>
|
|
1291
|
+
</mat-optgroup>
|
|
1292
|
+
</ng-template>
|
|
1293
|
+
</mat-select>
|
|
1294
|
+
<mat-select *ngIf="!boundControl"
|
|
1295
|
+
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
1296
|
+
[attr.name]="controlName"
|
|
1297
|
+
[disabled]="controlDisabled || options?.readonly"
|
|
1298
|
+
[id]="'control' + layoutNode?._id"
|
|
1299
|
+
[multiple]="options?.multiple"
|
|
1300
|
+
[placeholder]="options?.notitle ? options?.placeholder : options?.title"
|
|
1301
|
+
[required]="options?.required"
|
|
1302
|
+
[style.width]="'100%'"
|
|
1303
|
+
[value]="controlValue"
|
|
1304
|
+
(blur)="options.showErrors = true"
|
|
1305
|
+
(change)="updateValue($event)">
|
|
1306
|
+
<ng-template ngFor let-selectItem [ngForOf]="selectList">
|
|
1307
|
+
<mat-option *ngIf="!isArray(selectItem?.items)"
|
|
1308
|
+
[attr.selected]="selectItem?.value === controlValue"
|
|
1309
|
+
[value]="selectItem?.value">
|
|
1310
|
+
<span [innerHTML]="selectItem?.name"></span>
|
|
1311
|
+
</mat-option>
|
|
1312
|
+
<mat-optgroup *ngIf="isArray(selectItem?.items)"
|
|
1313
|
+
[label]="selectItem?.group">
|
|
1314
|
+
<mat-option *ngFor="let subItem of selectItem.items"
|
|
1315
|
+
[attr.selected]="subItem?.value === controlValue"
|
|
1316
|
+
[value]="subItem?.value">
|
|
1317
|
+
<span [innerHTML]="subItem?.name"></span>
|
|
1318
|
+
</mat-option>
|
|
1319
|
+
</mat-optgroup>
|
|
1320
|
+
</ng-template>
|
|
1321
|
+
</mat-select>
|
|
1322
|
+
<span matSuffix *ngIf="options?.suffix || options?.fieldAddonRight"
|
|
1323
|
+
[innerHTML]="options?.suffix || options?.fieldAddonRight"></span>
|
|
1324
|
+
<mat-hint *ngIf="options?.description && (!options?.showErrors || !options?.errorMessage)"
|
|
1325
|
+
align="end" [innerHTML]="options?.description"></mat-hint>
|
|
1326
|
+
</mat-form-field>
|
|
1327
|
+
<mat-error *ngIf="options?.showErrors && options?.errorMessage"
|
|
1328
|
+
[innerHTML]="options?.errorMessage"></mat-error>`,
|
|
1329
|
+
styles: [`
|
|
1330
|
+
mat-error { font-size: 75%; margin-top: -1rem; margin-bottom: 0.5rem; }
|
|
1331
|
+
::ng-deep json-schema-form mat-form-field .mat-form-field-wrapper .mat-form-field-flex
|
|
1332
|
+
.mat-form-field-infix { width: initial; }
|
|
1333
|
+
`]
|
|
1334
|
+
},] }
|
|
1335
|
+
];
|
|
1336
|
+
MaterialSelectComponent.ctorParameters = () => [
|
|
1337
|
+
{ type: undefined, decorators: [{ type: Inject, args: [MAT_FORM_FIELD_DEFAULT_OPTIONS,] }, { type: Optional }] },
|
|
1338
|
+
{ type: JsonSchemaFormService }
|
|
1339
|
+
];
|
|
1340
|
+
MaterialSelectComponent.propDecorators = {
|
|
1341
|
+
layoutNode: [{ type: Input }],
|
|
1342
|
+
layoutIndex: [{ type: Input }],
|
|
1343
|
+
dataIndex: [{ type: Input }]
|
|
1344
|
+
};
|
|
1345
|
+
|
|
1346
|
+
class MaterialSliderComponent {
|
|
1347
|
+
constructor(jsf) {
|
|
1348
|
+
this.jsf = jsf;
|
|
1349
|
+
this.controlDisabled = false;
|
|
1350
|
+
this.boundControl = false;
|
|
1351
|
+
this.allowNegative = true;
|
|
1352
|
+
this.allowDecimal = true;
|
|
1353
|
+
this.allowExponents = false;
|
|
1354
|
+
this.lastValidNumber = '';
|
|
1355
|
+
}
|
|
1356
|
+
ngOnInit() {
|
|
1357
|
+
this.options = this.layoutNode.options || {};
|
|
1358
|
+
this.jsf.initializeControl(this, !this.options.readonly);
|
|
1359
|
+
}
|
|
1360
|
+
updateValue(event) {
|
|
1361
|
+
this.options.showErrors = true;
|
|
1362
|
+
this.jsf.updateValue(this, event.value);
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
MaterialSliderComponent.decorators = [
|
|
1366
|
+
{ type: Component, args: [{
|
|
1367
|
+
// tslint:disable-next-line:component-selector
|
|
1368
|
+
selector: 'material-slider-widget',
|
|
1369
|
+
template: `
|
|
1370
|
+
<mat-slider thumbLabel *ngIf="boundControl"
|
|
1371
|
+
[formControl]="formControl"
|
|
1372
|
+
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
1373
|
+
[id]="'control' + layoutNode?._id"
|
|
1374
|
+
[max]="options?.maximum"
|
|
1375
|
+
[min]="options?.minimum"
|
|
1376
|
+
[step]="options?.multipleOf || options?.step || 'any'"
|
|
1377
|
+
[style.width]="'100%'"
|
|
1378
|
+
(blur)="options.showErrors = true"></mat-slider>
|
|
1379
|
+
<mat-slider thumbLabel *ngIf="!boundControl"
|
|
1380
|
+
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
1381
|
+
[disabled]="controlDisabled || options?.readonly"
|
|
1382
|
+
[id]="'control' + layoutNode?._id"
|
|
1383
|
+
[max]="options?.maximum"
|
|
1384
|
+
[min]="options?.minimum"
|
|
1385
|
+
[step]="options?.multipleOf || options?.step || 'any'"
|
|
1386
|
+
[style.width]="'100%'"
|
|
1387
|
+
[value]="controlValue"
|
|
1388
|
+
(blur)="options.showErrors = true"
|
|
1389
|
+
(change)="updateValue($event)"></mat-slider>
|
|
1390
|
+
<mat-error *ngIf="options?.showErrors && options?.errorMessage"
|
|
1391
|
+
[innerHTML]="options?.errorMessage"></mat-error>`,
|
|
1392
|
+
styles: [` mat-error { font-size: 75%; } `]
|
|
1393
|
+
},] }
|
|
1394
|
+
];
|
|
1395
|
+
MaterialSliderComponent.ctorParameters = () => [
|
|
1396
|
+
{ type: JsonSchemaFormService }
|
|
1397
|
+
];
|
|
1398
|
+
MaterialSliderComponent.propDecorators = {
|
|
1399
|
+
layoutNode: [{ type: Input }],
|
|
1400
|
+
layoutIndex: [{ type: Input }],
|
|
1401
|
+
dataIndex: [{ type: Input }]
|
|
1402
|
+
};
|
|
1403
|
+
|
|
1404
|
+
// TODO: Add this control
|
|
1405
|
+
class MaterialStepperComponent {
|
|
1406
|
+
constructor(jsf) {
|
|
1407
|
+
this.jsf = jsf;
|
|
1408
|
+
this.controlDisabled = false;
|
|
1409
|
+
this.boundControl = false;
|
|
1410
|
+
}
|
|
1411
|
+
ngOnInit() {
|
|
1412
|
+
this.options = this.layoutNode.options || {};
|
|
1413
|
+
this.jsf.initializeControl(this);
|
|
1414
|
+
}
|
|
1415
|
+
updateValue(event) {
|
|
1416
|
+
this.jsf.updateValue(this, event.target.value);
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
MaterialStepperComponent.decorators = [
|
|
1420
|
+
{ type: Component, args: [{
|
|
1421
|
+
// tslint:disable-next-line:component-selector
|
|
1422
|
+
selector: 'material-stepper-widget',
|
|
1423
|
+
template: ``
|
|
1424
|
+
},] }
|
|
1425
|
+
];
|
|
1426
|
+
MaterialStepperComponent.ctorParameters = () => [
|
|
1427
|
+
{ type: JsonSchemaFormService }
|
|
1428
|
+
];
|
|
1429
|
+
MaterialStepperComponent.propDecorators = {
|
|
1430
|
+
layoutNode: [{ type: Input }],
|
|
1431
|
+
layoutIndex: [{ type: Input }],
|
|
1432
|
+
dataIndex: [{ type: Input }]
|
|
1433
|
+
};
|
|
1434
|
+
|
|
1435
|
+
class MaterialTabsComponent {
|
|
1436
|
+
constructor(jsf) {
|
|
1437
|
+
this.jsf = jsf;
|
|
1438
|
+
this.selectedItem = 0;
|
|
1439
|
+
this.showAddTab = true;
|
|
1440
|
+
}
|
|
1441
|
+
ngOnInit() {
|
|
1442
|
+
this.options = this.layoutNode.options || {};
|
|
1443
|
+
this.itemCount = this.layoutNode.items.length - 1;
|
|
1444
|
+
this.updateControl();
|
|
1445
|
+
}
|
|
1446
|
+
select(index) {
|
|
1447
|
+
if (this.layoutNode.items[index].type === '$ref') {
|
|
1448
|
+
this.jsf.addItem({
|
|
1449
|
+
layoutNode: this.layoutNode.items[index],
|
|
1450
|
+
layoutIndex: this.layoutIndex.concat(index),
|
|
1451
|
+
dataIndex: this.dataIndex.concat(index)
|
|
1452
|
+
});
|
|
1453
|
+
this.updateControl();
|
|
1454
|
+
}
|
|
1455
|
+
this.selectedItem = index;
|
|
1456
|
+
}
|
|
1457
|
+
updateControl() {
|
|
1458
|
+
this.itemCount = this.layoutNode.items.length - 1;
|
|
1459
|
+
const lastItem = this.layoutNode.items[this.layoutNode.items.length - 1];
|
|
1460
|
+
this.showAddTab = lastItem.type === '$ref' &&
|
|
1461
|
+
this.itemCount < (lastItem.options.maxItems || 1000);
|
|
1462
|
+
}
|
|
1463
|
+
setTabTitle(item, index) {
|
|
1464
|
+
return this.jsf.setArrayItemTitle(this, item, index);
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
MaterialTabsComponent.decorators = [
|
|
1468
|
+
{ type: Component, args: [{
|
|
1469
|
+
// tslint:disable-next-line:component-selector
|
|
1470
|
+
selector: 'material-tabs-widget',
|
|
1471
|
+
template: `
|
|
1472
|
+
<nav mat-tab-nav-bar
|
|
1473
|
+
[attr.aria-label]="options?.label || options?.title || ''"
|
|
1474
|
+
[style.width]="'100%'">
|
|
1475
|
+
<a mat-tab-link *ngFor="let item of layoutNode?.items; let i = index"
|
|
1476
|
+
[active]="selectedItem === i"
|
|
1477
|
+
(click)="select(i)">
|
|
1478
|
+
<span *ngIf="showAddTab || item.type !== '$ref'"
|
|
1479
|
+
[innerHTML]="setTabTitle(item, i)"></span>
|
|
1480
|
+
</a>
|
|
1481
|
+
</nav>
|
|
1482
|
+
<div *ngFor="let layoutItem of layoutNode?.items; let i = index"
|
|
1483
|
+
[class]="options?.htmlClass || ''">
|
|
1484
|
+
<select-framework-widget *ngIf="selectedItem === i"
|
|
1485
|
+
[class]="(options?.fieldHtmlClass || '') + ' ' + (options?.activeClass || '') + ' ' + (options?.style?.selected || '')"
|
|
1486
|
+
[dataIndex]="layoutNode?.dataType === 'array' ? (dataIndex || []).concat(i) : dataIndex"
|
|
1487
|
+
[layoutIndex]="(layoutIndex || []).concat(i)"
|
|
1488
|
+
[layoutNode]="layoutItem"></select-framework-widget>
|
|
1489
|
+
</div>`,
|
|
1490
|
+
styles: [` a { cursor: pointer; } `]
|
|
1491
|
+
},] }
|
|
1492
|
+
];
|
|
1493
|
+
MaterialTabsComponent.ctorParameters = () => [
|
|
1494
|
+
{ type: JsonSchemaFormService }
|
|
1495
|
+
];
|
|
1496
|
+
MaterialTabsComponent.propDecorators = {
|
|
1497
|
+
layoutNode: [{ type: Input }],
|
|
1498
|
+
layoutIndex: [{ type: Input }],
|
|
1499
|
+
dataIndex: [{ type: Input }]
|
|
1500
|
+
};
|
|
1501
|
+
|
|
1502
|
+
class MaterialTextareaComponent {
|
|
1503
|
+
constructor(matFormFieldDefaultOptions, jsf) {
|
|
1504
|
+
this.matFormFieldDefaultOptions = matFormFieldDefaultOptions;
|
|
1505
|
+
this.jsf = jsf;
|
|
1506
|
+
this.controlDisabled = false;
|
|
1507
|
+
this.boundControl = false;
|
|
1508
|
+
}
|
|
1509
|
+
ngOnInit() {
|
|
1510
|
+
this.options = this.layoutNode.options || {};
|
|
1511
|
+
this.jsf.initializeControl(this);
|
|
1512
|
+
if (!this.options.notitle && !this.options.description && this.options.placeholder) {
|
|
1513
|
+
this.options.description = this.options.placeholder;
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
updateValue(event) {
|
|
1517
|
+
this.jsf.updateValue(this, event.target.value);
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
MaterialTextareaComponent.decorators = [
|
|
1521
|
+
{ type: Component, args: [{
|
|
1522
|
+
// tslint:disable-next-line:component-selector
|
|
1523
|
+
selector: 'material-textarea-widget',
|
|
1524
|
+
template: `
|
|
1525
|
+
<mat-form-field [appearance]="options?.appearance || matFormFieldDefaultOptions?.appearance || 'standard'"
|
|
1526
|
+
[class]="options?.htmlClass || ''"
|
|
1527
|
+
[floatLabel]="options?.floatLabel || matFormFieldDefaultOptions?.floatLabel || (options?.notitle ? 'never' : 'auto')"
|
|
1528
|
+
[hideRequiredMarker]="options?.hideRequired ? 'true' : 'false'"
|
|
1529
|
+
[style.width]="'100%'">
|
|
1530
|
+
<mat-label *ngIf="!options?.notitle">{{options?.title}}</mat-label>
|
|
1531
|
+
<span matPrefix *ngIf="options?.prefix || options?.fieldAddonLeft"
|
|
1532
|
+
[innerHTML]="options?.prefix || options?.fieldAddonLeft"></span>
|
|
1533
|
+
<textarea matInput *ngIf="boundControl"
|
|
1534
|
+
[formControl]="formControl"
|
|
1535
|
+
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
1536
|
+
[attr.list]="'control' + layoutNode?._id + 'Autocomplete'"
|
|
1537
|
+
[attr.maxlength]="options?.maxLength"
|
|
1538
|
+
[attr.minlength]="options?.minLength"
|
|
1539
|
+
[attr.pattern]="options?.pattern"
|
|
1540
|
+
[required]="options?.required"
|
|
1541
|
+
[id]="'control' + layoutNode?._id"
|
|
1542
|
+
[name]="controlName"
|
|
1543
|
+
[placeholder]="options?.notitle ? options?.placeholder : options?.title"
|
|
1544
|
+
[readonly]="options?.readonly ? 'readonly' : null"
|
|
1545
|
+
[style.width]="'100%'"
|
|
1546
|
+
(blur)="options.showErrors = true"></textarea>
|
|
1547
|
+
<textarea matInput *ngIf="!boundControl"
|
|
1548
|
+
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
1549
|
+
[attr.list]="'control' + layoutNode?._id + 'Autocomplete'"
|
|
1550
|
+
[attr.maxlength]="options?.maxLength"
|
|
1551
|
+
[attr.minlength]="options?.minLength"
|
|
1552
|
+
[attr.pattern]="options?.pattern"
|
|
1553
|
+
[required]="options?.required"
|
|
1554
|
+
[disabled]="controlDisabled"
|
|
1555
|
+
[id]="'control' + layoutNode?._id"
|
|
1556
|
+
[name]="controlName"
|
|
1557
|
+
[placeholder]="options?.notitle ? options?.placeholder : options?.title"
|
|
1558
|
+
[readonly]="options?.readonly ? 'readonly' : null"
|
|
1559
|
+
[style.width]="'100%'"
|
|
1560
|
+
[value]="controlValue"
|
|
1561
|
+
(input)="updateValue($event)"
|
|
1562
|
+
(blur)="options.showErrors = true"></textarea>
|
|
1563
|
+
<span matSuffix *ngIf="options?.suffix || options?.fieldAddonRight"
|
|
1564
|
+
[innerHTML]="options?.suffix || options?.fieldAddonRight"></span>
|
|
1565
|
+
<mat-hint *ngIf="options?.description && (!options?.showErrors || !options?.errorMessage)"
|
|
1566
|
+
align="end" [innerHTML]="options?.description"></mat-hint>
|
|
1567
|
+
</mat-form-field>
|
|
1568
|
+
<mat-error *ngIf="options?.showErrors && options?.errorMessage"
|
|
1569
|
+
[innerHTML]="options?.errorMessage"></mat-error>`,
|
|
1570
|
+
styles: [`
|
|
1571
|
+
mat-error { font-size: 75%; margin-top: -1rem; margin-bottom: 0.5rem; }
|
|
1572
|
+
::ng-deep json-schema-form mat-form-field .mat-form-field-wrapper .mat-form-field-flex
|
|
1573
|
+
.mat-form-field-infix { width: initial; }
|
|
1574
|
+
`]
|
|
1575
|
+
},] }
|
|
1576
|
+
];
|
|
1577
|
+
MaterialTextareaComponent.ctorParameters = () => [
|
|
1578
|
+
{ type: undefined, decorators: [{ type: Inject, args: [MAT_FORM_FIELD_DEFAULT_OPTIONS,] }, { type: Optional }] },
|
|
1579
|
+
{ type: JsonSchemaFormService }
|
|
1580
|
+
];
|
|
1581
|
+
MaterialTextareaComponent.propDecorators = {
|
|
1582
|
+
layoutNode: [{ type: Input }],
|
|
1583
|
+
layoutIndex: [{ type: Input }],
|
|
1584
|
+
dataIndex: [{ type: Input }]
|
|
1585
|
+
};
|
|
1586
|
+
|
|
1587
|
+
const MATERIAL_FRAMEWORK_COMPONENTS = [
|
|
1588
|
+
FlexLayoutRootComponent, FlexLayoutSectionComponent,
|
|
1589
|
+
MaterialAddReferenceComponent, MaterialOneOfComponent,
|
|
1590
|
+
MaterialButtonComponent, MaterialButtonGroupComponent,
|
|
1591
|
+
MaterialCheckboxComponent, MaterialCheckboxesComponent,
|
|
1592
|
+
MaterialChipListComponent, MaterialDatepickerComponent,
|
|
1593
|
+
MaterialFileComponent, MaterialInputComponent, MaterialNumberComponent,
|
|
1594
|
+
MaterialRadiosComponent, MaterialSelectComponent, MaterialSliderComponent,
|
|
1595
|
+
MaterialStepperComponent, MaterialTabsComponent, MaterialTextareaComponent,
|
|
1596
|
+
MaterialDesignFrameworkComponent
|
|
1597
|
+
];
|
|
1598
|
+
|
|
1599
|
+
// Material Design Framework
|
|
1600
|
+
// https://github.com/angular/material2
|
|
1601
|
+
class MaterialDesignFramework extends Framework {
|
|
1602
|
+
constructor() {
|
|
1603
|
+
super(...arguments);
|
|
1604
|
+
this.name = 'material-design';
|
|
1605
|
+
this.framework = MaterialDesignFrameworkComponent;
|
|
1606
|
+
this.stylesheets = [
|
|
1607
|
+
'//fonts.googleapis.com/icon?family=Material+Icons',
|
|
1608
|
+
'//fonts.googleapis.com/css?family=Roboto:300,400,500,700',
|
|
1609
|
+
];
|
|
1610
|
+
this.widgets = {
|
|
1611
|
+
'root': FlexLayoutRootComponent,
|
|
1612
|
+
'section': FlexLayoutSectionComponent,
|
|
1613
|
+
'$ref': MaterialAddReferenceComponent,
|
|
1614
|
+
'button': MaterialButtonComponent,
|
|
1615
|
+
'button-group': MaterialButtonGroupComponent,
|
|
1616
|
+
'checkbox': MaterialCheckboxComponent,
|
|
1617
|
+
'checkboxes': MaterialCheckboxesComponent,
|
|
1618
|
+
'chip-list': MaterialChipListComponent,
|
|
1619
|
+
'date': MaterialDatepickerComponent,
|
|
1620
|
+
'file': MaterialFileComponent,
|
|
1621
|
+
'number': MaterialNumberComponent,
|
|
1622
|
+
'one-of': MaterialOneOfComponent,
|
|
1623
|
+
'radios': MaterialRadiosComponent,
|
|
1624
|
+
'select': MaterialSelectComponent,
|
|
1625
|
+
'slider': MaterialSliderComponent,
|
|
1626
|
+
'stepper': MaterialStepperComponent,
|
|
1627
|
+
'tabs': MaterialTabsComponent,
|
|
1628
|
+
'text': MaterialInputComponent,
|
|
1629
|
+
'textarea': MaterialTextareaComponent,
|
|
1630
|
+
'alt-date': 'date',
|
|
1631
|
+
'any-of': 'one-of',
|
|
1632
|
+
'card': 'section',
|
|
1633
|
+
'color': 'text',
|
|
1634
|
+
'expansion-panel': 'section',
|
|
1635
|
+
'hidden': 'none',
|
|
1636
|
+
'image': 'none',
|
|
1637
|
+
'integer': 'number',
|
|
1638
|
+
'radiobuttons': 'button-group',
|
|
1639
|
+
'range': 'slider',
|
|
1640
|
+
'submit': 'button',
|
|
1641
|
+
'tagsinput': 'chip-list',
|
|
1642
|
+
'wizard': 'stepper',
|
|
1643
|
+
};
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
MaterialDesignFramework.decorators = [
|
|
1647
|
+
{ type: Injectable }
|
|
1648
|
+
];
|
|
1649
|
+
|
|
1650
|
+
function fixAngularFlex() {
|
|
1651
|
+
// monkey patch based on errors in console - https://github.com/angular/flex-layout/issues/1011
|
|
1652
|
+
const MediaMarshallerUpdateElement = MediaMarshaller.prototype.updateElement;
|
|
1653
|
+
MediaMarshaller.prototype.updateElement = function (element, key, value) {
|
|
1654
|
+
if (key === 'layout-gap' && (value === null || value === undefined)) {
|
|
1655
|
+
value = '0px';
|
|
1656
|
+
}
|
|
1657
|
+
MediaMarshallerUpdateElement.apply(this, [element, key, value]);
|
|
1658
|
+
};
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
/**
|
|
1662
|
+
* unused @angular/material modules:
|
|
1663
|
+
* MatDialogModule, MatGridListModule, MatListModule, MatMenuModule,
|
|
1664
|
+
* MatPaginatorModule, MatProgressBarModule, MatProgressSpinnerModule,
|
|
1665
|
+
* MatSidenavModule, MatSnackBarModule, MatSortModule, MatTableModule,
|
|
1666
|
+
* ,
|
|
1667
|
+
*/
|
|
1668
|
+
const ANGULAR_MATERIAL_MODULES = [
|
|
1669
|
+
MatAutocompleteModule, MatButtonModule, MatButtonToggleModule, MatCardModule,
|
|
1670
|
+
MatCheckboxModule, MatChipsModule, MatDatepickerModule, MatExpansionModule,
|
|
1671
|
+
MatFormFieldModule, MatIconModule, MatInputModule, MatNativeDateModule,
|
|
1672
|
+
MatRadioModule, MatSelectModule, MatSliderModule, MatSlideToggleModule,
|
|
1673
|
+
MatStepperModule, MatTabsModule, MatTooltipModule,
|
|
1674
|
+
MatToolbarModule, MatMenuModule, MatToolbarModule,
|
|
1675
|
+
];
|
|
1676
|
+
class MaterialDesignFrameworkModule {
|
|
1677
|
+
constructor() {
|
|
1678
|
+
fixAngularFlex();
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
MaterialDesignFrameworkModule.decorators = [
|
|
1682
|
+
{ type: NgModule, args: [{
|
|
1683
|
+
imports: [
|
|
1684
|
+
CommonModule,
|
|
1685
|
+
FormsModule,
|
|
1686
|
+
ReactiveFormsModule,
|
|
1687
|
+
FlexLayoutModule,
|
|
1688
|
+
...ANGULAR_MATERIAL_MODULES,
|
|
1689
|
+
WidgetLibraryModule,
|
|
1690
|
+
JsonSchemaFormModule,
|
|
1691
|
+
],
|
|
1692
|
+
declarations: [
|
|
1693
|
+
...MATERIAL_FRAMEWORK_COMPONENTS,
|
|
1694
|
+
],
|
|
1695
|
+
exports: [
|
|
1696
|
+
JsonSchemaFormModule,
|
|
1697
|
+
...MATERIAL_FRAMEWORK_COMPONENTS,
|
|
1698
|
+
],
|
|
1699
|
+
providers: [
|
|
1700
|
+
JsonSchemaFormService,
|
|
1701
|
+
FrameworkLibraryService,
|
|
1702
|
+
WidgetLibraryService,
|
|
1703
|
+
{ provide: Framework, useClass: MaterialDesignFramework, multi: true },
|
|
1704
|
+
],
|
|
1705
|
+
entryComponents: [
|
|
1706
|
+
...MATERIAL_FRAMEWORK_COMPONENTS,
|
|
1707
|
+
]
|
|
1708
|
+
},] }
|
|
1709
|
+
];
|
|
1710
|
+
MaterialDesignFrameworkModule.ctorParameters = () => [];
|
|
1711
|
+
|
|
1712
|
+
/*
|
|
1713
|
+
* Public API Surface of @ajsf/material-framework
|
|
1714
|
+
*/
|
|
1715
|
+
|
|
1716
|
+
/**
|
|
1717
|
+
* Generated bundle index. Do not edit.
|
|
1718
|
+
*/
|
|
1719
|
+
|
|
1720
|
+
export { ANGULAR_MATERIAL_MODULES, FlexLayoutRootComponent, FlexLayoutSectionComponent, MATERIAL_FRAMEWORK_COMPONENTS, MaterialAddReferenceComponent, MaterialButtonComponent, MaterialButtonGroupComponent, MaterialCheckboxComponent, MaterialCheckboxesComponent, MaterialChipListComponent, MaterialDatepickerComponent, MaterialDesignFramework, MaterialDesignFrameworkComponent, MaterialDesignFrameworkModule, MaterialFileComponent, MaterialInputComponent, MaterialNumberComponent, MaterialOneOfComponent, MaterialRadiosComponent, MaterialSelectComponent, MaterialSliderComponent, MaterialStepperComponent, MaterialTabsComponent, MaterialTextareaComponent };
|
|
1721
|
+
//# sourceMappingURL=ajsf-material.js.map
|