@ng-formworks/material 15.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +133 -0
  2. package/assets/material-design-themes.scss +71 -0
  3. package/karma.conf.js +46 -0
  4. package/ng-package.json +13 -0
  5. package/package.json +49 -0
  6. package/src/lib/flexlayout-replacement-styles.scss +95 -0
  7. package/src/lib/material-design-cssframework.ts +20 -0
  8. package/src/lib/material-design-framework.component.html +13 -0
  9. package/src/lib/material-design-framework.component.scss +58 -0
  10. package/src/lib/material-design-framework.component.spec.ts +39 -0
  11. package/src/lib/material-design-framework.component.ts +143 -0
  12. package/src/lib/material-design-framework.module.ts +81 -0
  13. package/src/lib/material-design-themes.scss +71 -0
  14. package/src/lib/material-design.framework.ts +83 -0
  15. package/src/lib/tailwind-output.scss +622 -0
  16. package/src/lib/widgets/flex-layout-root.component.html +4 -0
  17. package/src/lib/widgets/flex-layout-root.component.ts +52 -0
  18. package/src/lib/widgets/flex-layout-section.component.ts +216 -0
  19. package/src/lib/widgets/material-add-reference.component.ts +56 -0
  20. package/src/lib/widgets/material-button-group.component.ts +68 -0
  21. package/src/lib/widgets/material-button.component.ts +66 -0
  22. package/src/lib/widgets/material-checkbox.component.ts +112 -0
  23. package/src/lib/widgets/material-checkboxes.component.ts +108 -0
  24. package/src/lib/widgets/material-chip-list.component.ts +35 -0
  25. package/src/lib/widgets/material-datepicker.component.ts +89 -0
  26. package/src/lib/widgets/material-file.component.ts +35 -0
  27. package/src/lib/widgets/material-input.component.ts +97 -0
  28. package/src/lib/widgets/material-number.component.ts +95 -0
  29. package/src/lib/widgets/material-one-of.component.ts +35 -0
  30. package/src/lib/widgets/material-radios.component.ts +91 -0
  31. package/src/lib/widgets/material-select.component.ts +118 -0
  32. package/src/lib/widgets/material-slider.component.ts +65 -0
  33. package/src/lib/widgets/material-stepper.component.ts +35 -0
  34. package/src/lib/widgets/material-tabs.component.ts +72 -0
  35. package/src/lib/widgets/material-textarea.component.ts +88 -0
  36. package/src/lib/widgets/public_api.ts +54 -0
  37. package/src/public_api.ts +9 -0
  38. package/src/test.ts +17 -0
  39. package/tailwind-input.css +3 -0
  40. package/tailwind.config.js +12 -0
  41. package/tsconfig.lib.json +25 -0
  42. package/tsconfig.lib.prod.json +9 -0
  43. package/tsconfig.spec.json +17 -0
  44. package/tslint.json +11 -0
@@ -0,0 +1,89 @@
1
+ import { Component, Inject, Input, OnInit, Optional } from '@angular/core';
2
+ import { AbstractControl } from '@angular/forms';
3
+ import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
4
+ import { JsonSchemaFormService } from '@ng-formworks/core';
5
+
6
+ @Component({
7
+ // tslint:disable-next-line:component-selector
8
+ selector: 'material-datepicker-widget',
9
+ template: `
10
+ <mat-form-field [appearance]="options?.appearance || matFormFieldDefaultOptions?.appearance || 'fill'"
11
+ [class]="options?.htmlClass || ''"
12
+ [floatLabel]="options?.floatLabel || matFormFieldDefaultOptions?.floatLabel || (options?.notitle ? 'never' : 'auto')"
13
+ [hideRequiredMarker]="options?.hideRequired ? 'true' : 'false'"
14
+ [style.width]="'100%'">
15
+ <mat-label *ngIf="!options?.notitle">{{options?.title}}</mat-label>
16
+ <span matPrefix *ngIf="options?.prefix || options?.fieldAddonLeft"
17
+ [innerHTML]="options?.prefix || options?.fieldAddonLeft"></span>
18
+ <input matInput *ngIf="boundControl"
19
+ [formControl]="formControl"
20
+ [attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
21
+ [attr.list]="'control' + layoutNode?._id + 'Autocomplete'"
22
+ [attr.readonly]="options?.readonly ? 'readonly' : null"
23
+ [id]="'control' + layoutNode?._id"
24
+ [max]="options?.maximum"
25
+ [matDatepicker]="picker"
26
+ [min]="options?.minimum"
27
+ [name]="controlName"
28
+ [placeholder]="options?.title"
29
+ [readonly]="options?.readonly"
30
+ [required]="options?.required"
31
+ [style.width]="'100%'"
32
+ (blur)="options.showErrors = true"
33
+ >
34
+ <input matInput *ngIf="!boundControl"
35
+ [attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
36
+ [attr.list]="'control' + layoutNode?._id + 'Autocomplete'"
37
+ [attr.readonly]="options?.readonly ? 'readonly' : null"
38
+ [disabled]="controlDisabled || options?.readonly"
39
+ [id]="'control' + layoutNode?._id"
40
+ [max]="options?.maximum"
41
+ [matDatepicker]="picker"
42
+ [min]="options?.minimum"
43
+ [name]="controlName"
44
+ [placeholder]="options?.title"
45
+ [required]="options?.required"
46
+ [style.width]="'100%'"
47
+ [readonly]="options?.readonly"
48
+ (blur)="options.showErrors = true"
49
+ >
50
+ <span matSuffix *ngIf="options?.suffix || options?.fieldAddonRight"
51
+ [innerHTML]="options?.suffix || options?.fieldAddonRight"></span>
52
+ <mat-hint *ngIf="options?.description && (!options?.showErrors || !options?.errorMessage)"
53
+ align="end" [innerHTML]="options?.description"></mat-hint>
54
+ <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
55
+ </mat-form-field>
56
+ <mat-datepicker #picker ></mat-datepicker>
57
+ <mat-error *ngIf="options?.showErrors && options?.errorMessage"
58
+ [innerHTML]="options?.errorMessage"></mat-error>`,
59
+ styles: [`
60
+ mat-error { font-size: 75%; margin-top: -1rem; margin-bottom: 0.5rem; }
61
+ ::ng-deep json-schema-form mat-form-field .mat-mdc-form-field-wrapper .mat-form-field-flex
62
+ .mat-form-field-infix { width: initial; }
63
+ `],
64
+ })
65
+ export class MaterialDatepickerComponent implements OnInit {
66
+ formControl: AbstractControl;
67
+ controlName: string;
68
+ dateValue: any;
69
+ controlDisabled = false;
70
+ boundControl = false;
71
+ options: any;
72
+ autoCompleteList: string[] = [];
73
+ @Input() layoutNode: any;
74
+ @Input() layoutIndex: number[];
75
+ @Input() dataIndex: number[];
76
+
77
+ constructor(
78
+ @Inject(MAT_FORM_FIELD_DEFAULT_OPTIONS) @Optional() public matFormFieldDefaultOptions,
79
+ private jsf: JsonSchemaFormService
80
+ ) { }
81
+
82
+ ngOnInit() {
83
+ this.options = this.layoutNode.options || {};
84
+ this.jsf.initializeControl(this, !this.options.readonly);
85
+ if (!this.options.notitle && !this.options.description && this.options.placeholder) {
86
+ this.options.description = this.options.placeholder;
87
+ }
88
+ }
89
+ }
@@ -0,0 +1,35 @@
1
+ import { Component, Input, OnInit } from '@angular/core';
2
+ import { AbstractControl } from '@angular/forms';
3
+ import { JsonSchemaFormService } from '@ng-formworks/core';
4
+
5
+ // TODO: Add this control
6
+
7
+ @Component({
8
+ // tslint:disable-next-line:component-selector
9
+ selector: 'material-file-widget',
10
+ template: ``,
11
+ })
12
+ export class MaterialFileComponent implements OnInit {
13
+ formControl: AbstractControl;
14
+ controlName: string;
15
+ controlValue: any;
16
+ controlDisabled = false;
17
+ boundControl = false;
18
+ options: any;
19
+ @Input() layoutNode: any;
20
+ @Input() layoutIndex: number[];
21
+ @Input() dataIndex: number[];
22
+
23
+ constructor(
24
+ private jsf: JsonSchemaFormService
25
+ ) { }
26
+
27
+ ngOnInit() {
28
+ this.options = this.layoutNode.options || {};
29
+ this.jsf.initializeControl(this);
30
+ }
31
+
32
+ updateValue(event) {
33
+ this.jsf.updateValue(this, event.target.value);
34
+ }
35
+ }
@@ -0,0 +1,97 @@
1
+ import { Component, Inject, Input, OnInit, Optional } from '@angular/core';
2
+ import { AbstractControl } from '@angular/forms';
3
+ import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
4
+ import { JsonSchemaFormService } from '@ng-formworks/core';
5
+
6
+ @Component({
7
+ // tslint:disable-next-line:component-selector
8
+ selector: 'material-input-widget',
9
+ template: `
10
+ <mat-form-field [appearance]="options?.appearance || matFormFieldDefaultOptions?.appearance || 'fill'"
11
+ [class]="options?.htmlClass || ''"
12
+ [floatLabel]="options?.floatLabel || matFormFieldDefaultOptions?.floatLabel || (options?.notitle ? 'never' : 'auto')"
13
+ [hideRequiredMarker]="options?.hideRequired ? 'true' : 'false'"
14
+ [style.width]="'100%'">
15
+ <mat-label *ngIf="!options?.notitle">{{options?.title}}</mat-label>
16
+ <span matPrefix *ngIf="options?.prefix || options?.fieldAddonLeft"
17
+ [innerHTML]="options?.prefix || options?.fieldAddonLeft"></span>
18
+ <input matInput *ngIf="boundControl"
19
+ [formControl]="formControl"
20
+ [attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
21
+ [attr.list]="'control' + layoutNode?._id + 'Autocomplete'"
22
+ [attr.maxlength]="options?.maxLength"
23
+ [attr.minlength]="options?.minLength"
24
+ [attr.pattern]="options?.pattern"
25
+ [readonly]="options?.readonly ? 'readonly' : null"
26
+ [id]="'control' + layoutNode?._id"
27
+ [name]="controlName"
28
+ [placeholder]="options?.notitle ? options?.placeholder : options?.title"
29
+ [required]="options?.required"
30
+ [style.width]="'100%'"
31
+ [type]="layoutNode?.type"
32
+ (blur)="options.showErrors = true">
33
+ <input matInput *ngIf="!boundControl"
34
+ [attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
35
+ [attr.list]="'control' + layoutNode?._id + 'Autocomplete'"
36
+ [attr.maxlength]="options?.maxLength"
37
+ [attr.minlength]="options?.minLength"
38
+ [attr.pattern]="options?.pattern"
39
+ [disabled]="controlDisabled"
40
+ [id]="'control' + layoutNode?._id"
41
+ [name]="controlName"
42
+ [placeholder]="options?.notitle ? options?.placeholder : options?.title"
43
+ [readonly]="options?.readonly ? 'readonly' : null"
44
+ [required]="options?.required"
45
+ [style.width]="'100%'"
46
+ [type]="layoutNode?.type"
47
+ [value]="controlValue"
48
+ (input)="updateValue($event)"
49
+ (blur)="options.showErrors = true">
50
+ <span matSuffix *ngIf="options?.suffix || options?.fieldAddonRight"
51
+ [innerHTML]="options?.suffix || options?.fieldAddonRight"></span>
52
+ <mat-hint *ngIf="options?.description && (!options?.showErrors || !options?.errorMessage)"
53
+ align="end" [innerHTML]="options?.description"></mat-hint>
54
+ <mat-autocomplete *ngIf="options?.typeahead?.source">
55
+ <mat-option *ngFor="let word of options?.typeahead?.source"
56
+ [value]="word">{{word}}</mat-option>
57
+ </mat-autocomplete>
58
+ </mat-form-field>
59
+ <mat-error *ngIf="options?.showErrors && options?.errorMessage"
60
+ [innerHTML]="options?.errorMessage"></mat-error>`,
61
+ styles: [`
62
+ mat-error { font-size: 75%; margin-top: -1rem; margin-bottom: 0.5rem; }
63
+ ::ng-deep json-schema-form mat-form-field .mat-mdc-form-field-wrapper .mat-form-field-flex
64
+ .mat-form-field-infix { width: initial; }
65
+ `],
66
+ })
67
+ export class MaterialInputComponent implements OnInit {
68
+ formControl: AbstractControl;
69
+ controlName: string;
70
+ controlValue: string;
71
+ controlDisabled = false;
72
+ boundControl = false;
73
+ options: any;
74
+ autoCompleteList: string[] = [];
75
+ @Input() layoutNode: any;
76
+ @Input() layoutIndex: number[];
77
+ @Input() dataIndex: number[];
78
+
79
+
80
+ constructor(
81
+ @Inject(MAT_FORM_FIELD_DEFAULT_OPTIONS) @Optional() public matFormFieldDefaultOptions,
82
+ private jsf: JsonSchemaFormService
83
+ ) {
84
+ }
85
+
86
+ ngOnInit() {
87
+ this.options = this.layoutNode.options || {};
88
+ this.jsf.initializeControl(this);
89
+ if (!this.options.notitle && !this.options.description && this.options.placeholder) {
90
+ this.options.description = this.options.placeholder;
91
+ }
92
+ }
93
+
94
+ updateValue(event) {
95
+ this.jsf.updateValue(this, event.target.value);
96
+ }
97
+ }
@@ -0,0 +1,95 @@
1
+ import { Component, Inject, Input, OnInit, Optional } from '@angular/core';
2
+ import { AbstractControl } from '@angular/forms';
3
+ import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
4
+ import { JsonSchemaFormService } from '@ng-formworks/core';
5
+
6
+ @Component({
7
+ // tslint:disable-next-line:component-selector
8
+ selector: 'material-number-widget',
9
+ template: `
10
+ <mat-form-field [appearance]="options?.appearance || matFormFieldDefaultOptions?.appearance || 'fill'"
11
+ [class]="options?.htmlClass || ''"
12
+ [floatLabel]="options?.floatLabel || matFormFieldDefaultOptions?.floatLabel || (options?.notitle ? 'never' : 'auto')"
13
+ [hideRequiredMarker]="options?.hideRequired ? 'true' : 'false'"
14
+ [style.width]="'100%'">
15
+ <mat-label *ngIf="!options?.notitle">{{options?.title}}</mat-label>
16
+ <span matPrefix *ngIf="options?.prefix || options?.fieldAddonLeft"
17
+ [innerHTML]="options?.prefix || options?.fieldAddonLeft"></span>
18
+ <input matInput *ngIf="boundControl"
19
+ [formControl]="formControl"
20
+ [attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
21
+ [attr.max]="options?.maximum"
22
+ [attr.min]="options?.minimum"
23
+ [attr.step]="options?.multipleOf || options?.step || 'any'"
24
+ [id]="'control' + layoutNode?._id"
25
+ [name]="controlName"
26
+ [placeholder]="options?.notitle ? options?.placeholder : options?.title"
27
+ [readonly]="options?.readonly ? 'readonly' : null"
28
+ [required]="options?.required"
29
+ [style.width]="'100%'"
30
+ [type]="'number'"
31
+ (blur)="options.showErrors = true">
32
+ <input matInput *ngIf="!boundControl"
33
+ [attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
34
+ [attr.max]="options?.maximum"
35
+ [attr.min]="options?.minimum"
36
+ [attr.step]="options?.multipleOf || options?.step || 'any'"
37
+ [disabled]="controlDisabled"
38
+ [id]="'control' + layoutNode?._id"
39
+ [name]="controlName"
40
+ [placeholder]="options?.notitle ? options?.placeholder : options?.title"
41
+ [readonly]="options?.readonly ? 'readonly' : null"
42
+ [required]="options?.required"
43
+ [style.width]="'100%'"
44
+ [type]="'number'"
45
+ [value]="controlValue"
46
+ (input)="updateValue($event)"
47
+ (blur)="options.showErrors = true">
48
+ <span matSuffix *ngIf="options?.suffix || options?.fieldAddonRight"
49
+ [innerHTML]="options?.suffix || options?.fieldAddonRight"></span>
50
+ <mat-hint *ngIf="layoutNode?.type === 'range'" align="start"
51
+ [innerHTML]="controlValue"></mat-hint>
52
+ <mat-hint *ngIf="options?.description && (!options?.showErrors || !options?.errorMessage)"
53
+ align="end" [innerHTML]="options?.description"></mat-hint>
54
+ </mat-form-field>
55
+ <mat-error *ngIf="options?.showErrors && options?.errorMessage"
56
+ [innerHTML]="options?.errorMessage"></mat-error>`,
57
+ styles: [`
58
+ mat-error { font-size: 75%; margin-top: -1rem; margin-bottom: 0.5rem; }
59
+ ::ng-deep json-schema-form mat-form-field .mat-mdc-form-field-wrapper .mat-form-field-flex
60
+ .mat-form-field-infix { width: initial; }
61
+ `],
62
+ })
63
+ export class MaterialNumberComponent implements OnInit {
64
+ formControl: AbstractControl;
65
+ controlName: string;
66
+ controlValue: any;
67
+ controlDisabled = false;
68
+ boundControl = false;
69
+ options: any;
70
+ allowNegative = true;
71
+ allowDecimal = true;
72
+ allowExponents = false;
73
+ lastValidNumber = '';
74
+ @Input() layoutNode: any;
75
+ @Input() layoutIndex: number[];
76
+ @Input() dataIndex: number[];
77
+
78
+ constructor(
79
+ @Inject(MAT_FORM_FIELD_DEFAULT_OPTIONS) @Optional() public matFormFieldDefaultOptions,
80
+ private jsf: JsonSchemaFormService
81
+ ) { }
82
+
83
+ ngOnInit() {
84
+ this.options = this.layoutNode.options || {};
85
+ this.jsf.initializeControl(this);
86
+ if (this.layoutNode.dataType === 'integer') { this.allowDecimal = false; }
87
+ if (!this.options.notitle && !this.options.description && this.options.placeholder) {
88
+ this.options.description = this.options.placeholder;
89
+ }
90
+ }
91
+
92
+ updateValue(event) {
93
+ this.jsf.updateValue(this, event.target.value);
94
+ }
95
+ }
@@ -0,0 +1,35 @@
1
+ import { Component, Input, OnInit } from '@angular/core';
2
+ import { AbstractControl } from '@angular/forms';
3
+ import { JsonSchemaFormService } from '@ng-formworks/core';
4
+
5
+ // TODO: Add this control
6
+
7
+ @Component({
8
+ // tslint:disable-next-line:component-selector
9
+ selector: 'material-one-of-widget',
10
+ template: ``,
11
+ })
12
+ export class MaterialOneOfComponent implements OnInit {
13
+ formControl: AbstractControl;
14
+ controlName: string;
15
+ controlValue: any;
16
+ controlDisabled = false;
17
+ boundControl = false;
18
+ options: any;
19
+ @Input() layoutNode: any;
20
+ @Input() layoutIndex: number[];
21
+ @Input() dataIndex: number[];
22
+
23
+ constructor(
24
+ private jsf: JsonSchemaFormService
25
+ ) { }
26
+
27
+ ngOnInit() {
28
+ this.options = this.layoutNode.options || {};
29
+ this.jsf.initializeControl(this);
30
+ }
31
+
32
+ updateValue(event) {
33
+ this.jsf.updateValue(this, event.target.value);
34
+ }
35
+ }
@@ -0,0 +1,91 @@
1
+ import { Component, Input, OnInit } from '@angular/core';
2
+ import { AbstractControl } from '@angular/forms';
3
+ import { JsonSchemaFormService, buildTitleMap } from '@ng-formworks/core';
4
+
5
+
6
+ @Component({
7
+ // tslint:disable-next-line:component-selector
8
+ selector: 'material-radios-widget',
9
+ template: `
10
+ <div>
11
+ <div *ngIf="options?.title">
12
+ <label
13
+ [attr.for]="'control' + layoutNode?._id"
14
+ [class]="options?.labelHtmlClass || ''"
15
+ [style.display]="options?.notitle ? 'none' : ''"
16
+ [innerHTML]="options?.title"></label>
17
+ </div>
18
+ <mat-radio-group *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
+ [style.flex-direction]="flexDirection"
24
+ [name]="controlName"
25
+ (blur)="options.showErrors = true">
26
+ <mat-radio-button *ngFor="let radioItem of radiosList"
27
+ [id]="'control' + layoutNode?._id + '/' + radioItem?.name"
28
+ [value]="radioItem?.value">
29
+ <span [innerHTML]="radioItem?.name"></span>
30
+ </mat-radio-button>
31
+ </mat-radio-group>
32
+ <mat-radio-group *ngIf="!boundControl"
33
+ [attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
34
+ [attr.readonly]="options?.readonly ? 'readonly' : null"
35
+ [attr.required]="options?.required"
36
+ [style.flex-direction]="flexDirection"
37
+ [disabled]="controlDisabled || options?.readonly"
38
+ [name]="controlName"
39
+ [value]="controlValue">
40
+ <mat-radio-button *ngFor="let radioItem of radiosList"
41
+ [id]="'control' + layoutNode?._id + '/' + radioItem?.name"
42
+ [value]="radioItem?.value"
43
+ (click)="updateValue(radioItem?.value)">
44
+ <span [innerHTML]="radioItem?.name"></span>
45
+ </mat-radio-button>
46
+ </mat-radio-group>
47
+ <mat-error *ngIf="options?.showErrors && options?.errorMessage"
48
+ [innerHTML]="options?.errorMessage"></mat-error>
49
+ </div>`,
50
+ styles: [`
51
+ /* TODO(mdc-migration): The following rule targets internal classes of radio that may no longer apply for the MDC version. */
52
+ mat-radio-group { display: inline-flex; }
53
+ /* TODO(mdc-migration): The following rule targets internal classes of radio that may no longer apply for the MDC version. */
54
+ mat-radio-button { margin: 2px; }
55
+ mat-error { font-size: 75%; }
56
+ `]
57
+ })
58
+ export class MaterialRadiosComponent implements OnInit {
59
+ formControl: AbstractControl;
60
+ controlName: string;
61
+ controlValue: any;
62
+ controlDisabled = false;
63
+ boundControl = false;
64
+ options: any;
65
+ flexDirection = 'column';
66
+ radiosList: any[] = [];
67
+ @Input() layoutNode: any;
68
+ @Input() layoutIndex: number[];
69
+ @Input() dataIndex: number[];
70
+
71
+ constructor(
72
+ private jsf: JsonSchemaFormService
73
+ ) { }
74
+
75
+ ngOnInit() {
76
+ this.options = this.layoutNode.options || {};
77
+ if (this.layoutNode.type === 'radios-inline') {
78
+ this.flexDirection = 'row';
79
+ }
80
+ this.radiosList = buildTitleMap(
81
+ this.options.titleMap || this.options.enumNames,
82
+ this.options.enum, true
83
+ );
84
+ this.jsf.initializeControl(this, !this.options.readonly);
85
+ }
86
+
87
+ updateValue(value) {
88
+ this.options.showErrors = true;
89
+ this.jsf.updateValue(this, value);
90
+ }
91
+ }
@@ -0,0 +1,118 @@
1
+ import { Component, Inject, Input, OnInit, Optional } from '@angular/core';
2
+ import { AbstractControl } from '@angular/forms';
3
+ import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
4
+ import { JsonSchemaFormService, buildTitleMap, isArray } from '@ng-formworks/core';
5
+
6
+ @Component({
7
+ // tslint:disable-next-line:component-selector
8
+ selector: 'material-select-widget',
9
+ template: `
10
+ <mat-form-field
11
+ [appearance]="options?.appearance || matFormFieldDefaultOptions?.appearance || 'fill'"
12
+ [class]="options?.htmlClass || ''"
13
+ [floatLabel]="options?.floatLabel || matFormFieldDefaultOptions?.floatLabel || (options?.notitle ? 'never' : 'auto')"
14
+ [hideRequiredMarker]="options?.hideRequired ? 'true' : 'false'"
15
+ [style.width]="'100%'">
16
+ <mat-label *ngIf="!options?.notitle">{{options?.title}}</mat-label>
17
+ <span matPrefix *ngIf="options?.prefix || options?.fieldAddonLeft"
18
+ [innerHTML]="options?.prefix || options?.fieldAddonLeft"></span>
19
+ <mat-select *ngIf="boundControl"
20
+ [formControl]="formControl"
21
+ [attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
22
+ [attr.name]="controlName"
23
+ [id]="'control' + layoutNode?._id"
24
+ [multiple]="options?.multiple"
25
+ [placeholder]="options?.notitle ? options?.placeholder : options?.title"
26
+ [required]="options?.required"
27
+ [style.width]="'100%'"
28
+ (blur)="options.showErrors = true">
29
+ <ng-template ngFor let-selectItem [ngForOf]="selectList">
30
+ <mat-option *ngIf="!isArray(selectItem?.items)"
31
+ [value]="selectItem?.value">
32
+ <span [innerHTML]="selectItem?.name"></span>
33
+ </mat-option>
34
+ <mat-optgroup *ngIf="isArray(selectItem?.items)"
35
+ [label]="selectItem?.group">
36
+ <mat-option *ngFor="let subItem of selectItem.items"
37
+ [value]="subItem?.value">
38
+ <span [innerHTML]="subItem?.name"></span>
39
+ </mat-option>
40
+ </mat-optgroup>
41
+ </ng-template>
42
+ </mat-select>
43
+ <mat-select *ngIf="!boundControl"
44
+ [attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
45
+ [attr.name]="controlName"
46
+ [disabled]="controlDisabled || options?.readonly"
47
+ [id]="'control' + layoutNode?._id"
48
+ [multiple]="options?.multiple"
49
+ [placeholder]="options?.notitle ? options?.placeholder : options?.title"
50
+ [required]="options?.required"
51
+ [style.width]="'100%'"
52
+ [value]="controlValue"
53
+ (blur)="options.showErrors = true"
54
+ (change)="updateValue($event)">
55
+ <ng-template ngFor let-selectItem [ngForOf]="selectList">
56
+ <mat-option *ngIf="!isArray(selectItem?.items)"
57
+ [attr.selected]="selectItem?.value === controlValue"
58
+ [value]="selectItem?.value">
59
+ <span [innerHTML]="selectItem?.name"></span>
60
+ </mat-option>
61
+ <mat-optgroup *ngIf="isArray(selectItem?.items)"
62
+ [label]="selectItem?.group">
63
+ <mat-option *ngFor="let subItem of selectItem.items"
64
+ [attr.selected]="subItem?.value === controlValue"
65
+ [value]="subItem?.value">
66
+ <span [innerHTML]="subItem?.name"></span>
67
+ </mat-option>
68
+ </mat-optgroup>
69
+ </ng-template>
70
+ </mat-select>
71
+ <span matSuffix *ngIf="options?.suffix || options?.fieldAddonRight"
72
+ [innerHTML]="options?.suffix || options?.fieldAddonRight"></span>
73
+ <mat-hint *ngIf="options?.description && (!options?.showErrors || !options?.errorMessage)"
74
+ align="end" [innerHTML]="options?.description"></mat-hint>
75
+ </mat-form-field>
76
+ <mat-error *ngIf="options?.showErrors && options?.errorMessage"
77
+ [innerHTML]="options?.errorMessage"></mat-error>`,
78
+ styles: [`
79
+ mat-error { font-size: 75%; margin-top: -1rem; margin-bottom: 0.5rem; }
80
+ ::ng-deep json-schema-form mat-form-field .mat-mdc-form-field-wrapper .mat-form-field-flex
81
+ .mat-form-field-infix { width: initial; }
82
+ `],
83
+ })
84
+ export class MaterialSelectComponent implements OnInit {
85
+ formControl: AbstractControl;
86
+ controlName: string;
87
+ controlValue: any;
88
+ controlDisabled = false;
89
+ boundControl = false;
90
+ options: any;
91
+ selectList: any[] = [];
92
+ isArray = isArray;
93
+ @Input() layoutNode: any;
94
+ @Input() layoutIndex: number[];
95
+ @Input() dataIndex: number[];
96
+
97
+ constructor(
98
+ @Inject(MAT_FORM_FIELD_DEFAULT_OPTIONS) @Optional() public matFormFieldDefaultOptions,
99
+ private jsf: JsonSchemaFormService
100
+ ) { }
101
+
102
+ ngOnInit() {
103
+ this.options = this.layoutNode.options || {};
104
+ this.selectList = buildTitleMap(
105
+ this.options.titleMap || this.options.enumNames,
106
+ this.options.enum, !!this.options.required, !!this.options.flatList
107
+ );
108
+ this.jsf.initializeControl(this, !this.options.readonly);
109
+ if (!this.options.notitle && !this.options.description && this.options.placeholder) {
110
+ this.options.description = this.options.placeholder;
111
+ }
112
+ }
113
+
114
+ updateValue(event) {
115
+ this.options.showErrors = true;
116
+ this.jsf.updateValue(this, event.value);
117
+ }
118
+ }
@@ -0,0 +1,65 @@
1
+ import { Component, Input, OnInit } from '@angular/core';
2
+ import { AbstractControl } from '@angular/forms';
3
+ import { JsonSchemaFormService } from '@ng-formworks/core';
4
+
5
+ @Component({
6
+ // tslint:disable-next-line:component-selector
7
+ selector: 'material-slider-widget',
8
+ template: `
9
+ <mat-slider discrete *ngIf="boundControl"
10
+
11
+ [attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
12
+ [id]="'control' + layoutNode?._id"
13
+ [max]="options?.maximum"
14
+ [min]="options?.minimum"
15
+ [step]="options?.multipleOf || options?.step || 'any'"
16
+ [style.width]="'100%'"
17
+ (blur)="options.showErrors = true">
18
+ <input matSliderThumb [formControl]="formControl" />
19
+ </mat-slider>
20
+ <mat-slider discrete *ngIf="!boundControl"
21
+ [attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
22
+ [disabled]="controlDisabled || options?.readonly"
23
+ [id]="'control' + layoutNode?._id"
24
+ [max]="options?.maximum"
25
+ [min]="options?.minimum"
26
+ [step]="options?.multipleOf || options?.step || 'any'"
27
+ [style.width]="'100%'"
28
+ (blur)="options.showErrors = true" #ngSlider>
29
+ <input matSliderThumb [value]="controlValue"
30
+ (change)="updateValue({source: ngSliderThumb, parent: ngSlider, value: ngSliderThumb.value})"
31
+ #ngSliderThumb="matSliderThumb" />
32
+ </mat-slider>
33
+ <mat-error *ngIf="options?.showErrors && options?.errorMessage"
34
+ [innerHTML]="options?.errorMessage"></mat-error>`,
35
+ styles: [` mat-error { font-size: 75%; } `],
36
+ })
37
+ export class MaterialSliderComponent implements OnInit {
38
+ formControl: AbstractControl;
39
+ controlName: string;
40
+ controlValue: any;
41
+ controlDisabled = false;
42
+ boundControl = false;
43
+ options: any;
44
+ allowNegative = true;
45
+ allowDecimal = true;
46
+ allowExponents = false;
47
+ lastValidNumber = '';
48
+ @Input() layoutNode: any;
49
+ @Input() layoutIndex: number[];
50
+ @Input() dataIndex: number[];
51
+
52
+ constructor(
53
+ private jsf: JsonSchemaFormService
54
+ ) { }
55
+
56
+ ngOnInit() {
57
+ this.options = this.layoutNode.options || {};
58
+ this.jsf.initializeControl(this, !this.options.readonly);
59
+ }
60
+
61
+ updateValue(event) {
62
+ this.options.showErrors = true;
63
+ this.jsf.updateValue(this, event.value);
64
+ }
65
+ }
@@ -0,0 +1,35 @@
1
+ import { Component, Input, OnInit } from '@angular/core';
2
+ import { AbstractControl } from '@angular/forms';
3
+ import { JsonSchemaFormService } from '@ng-formworks/core';
4
+
5
+ // TODO: Add this control
6
+
7
+ @Component({
8
+ // tslint:disable-next-line:component-selector
9
+ selector: 'material-stepper-widget',
10
+ template: ``,
11
+ })
12
+ export class MaterialStepperComponent implements OnInit {
13
+ formControl: AbstractControl;
14
+ controlName: string;
15
+ controlValue: any;
16
+ controlDisabled = false;
17
+ boundControl = false;
18
+ options: any;
19
+ @Input() layoutNode: any;
20
+ @Input() layoutIndex: number[];
21
+ @Input() dataIndex: number[];
22
+
23
+ constructor(
24
+ private jsf: JsonSchemaFormService
25
+ ) { }
26
+
27
+ ngOnInit() {
28
+ this.options = this.layoutNode.options || {};
29
+ this.jsf.initializeControl(this);
30
+ }
31
+
32
+ updateValue(event) {
33
+ this.jsf.updateValue(this, event.target.value);
34
+ }
35
+ }