@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.
Files changed (95) hide show
  1. package/LICENSE +21 -0
  2. package/ajsf-material.d.ts +4 -0
  3. package/ajsf-material.metadata.json +1 -0
  4. package/bundles/ajsf-material.umd.js +1431 -0
  5. package/bundles/ajsf-material.umd.js.map +1 -0
  6. package/bundles/ajsf-material.umd.min.js +16 -0
  7. package/bundles/ajsf-material.umd.min.js.map +1 -0
  8. package/esm2015/ajsf-material.js +5 -0
  9. package/esm2015/lib/angular-flex-monkey-patch.js +12 -0
  10. package/esm2015/lib/material-design-framework.component.js +101 -0
  11. package/esm2015/lib/material-design-framework.module.js +80 -0
  12. package/esm2015/lib/material-design.framework.js +54 -0
  13. package/esm2015/lib/widgets/flex-layout-root.component.js +55 -0
  14. package/esm2015/lib/widgets/flex-layout-section.component.js +221 -0
  15. package/esm2015/lib/widgets/material-add-reference.component.js +53 -0
  16. package/esm2015/lib/widgets/material-button-group.component.js +63 -0
  17. package/esm2015/lib/widgets/material-button.component.js +60 -0
  18. package/esm2015/lib/widgets/material-checkbox.component.js +109 -0
  19. package/esm2015/lib/widgets/material-checkboxes.component.js +101 -0
  20. package/esm2015/lib/widgets/material-chip-list.component.js +33 -0
  21. package/esm2015/lib/widgets/material-datepicker.component.js +101 -0
  22. package/esm2015/lib/widgets/material-file.component.js +33 -0
  23. package/esm2015/lib/widgets/material-input.component.js +95 -0
  24. package/esm2015/lib/widgets/material-number.component.js +97 -0
  25. package/esm2015/lib/widgets/material-one-of.component.js +33 -0
  26. package/esm2015/lib/widgets/material-radios.component.js +84 -0
  27. package/esm2015/lib/widgets/material-select.component.js +115 -0
  28. package/esm2015/lib/widgets/material-slider.component.js +60 -0
  29. package/esm2015/lib/widgets/material-stepper.component.js +33 -0
  30. package/esm2015/lib/widgets/material-tabs.component.js +69 -0
  31. package/esm2015/lib/widgets/material-textarea.component.js +88 -0
  32. package/esm2015/lib/widgets/public_api.js +52 -0
  33. package/esm2015/public_api.js +8 -0
  34. package/fesm2015/ajsf-material.js +1721 -0
  35. package/fesm2015/ajsf-material.js.map +1 -0
  36. package/lib/angular-flex-monkey-patch.d.ts +1 -0
  37. package/lib/material-design-framework.component.d.ts +25 -0
  38. package/lib/material-design-framework.module.d.ts +12 -0
  39. package/lib/material-design.framework.d.ts +41 -0
  40. package/lib/widgets/flex-layout-root.component.d.ts +12 -0
  41. package/lib/widgets/flex-layout-section.component.d.ts +22 -0
  42. package/lib/widgets/material-add-reference.component.d.ts +17 -0
  43. package/lib/widgets/material-button-group.component.d.ts +20 -0
  44. package/lib/widgets/material-button.component.d.ts +18 -0
  45. package/lib/widgets/material-checkbox.component.d.ts +22 -0
  46. package/lib/widgets/material-checkboxes.component.d.ts +24 -0
  47. package/lib/widgets/material-chip-list.component.d.ts +18 -0
  48. package/lib/widgets/material-datepicker.component.d.ts +22 -0
  49. package/lib/widgets/material-file.component.d.ts +18 -0
  50. package/lib/widgets/material-input.component.d.ts +20 -0
  51. package/lib/widgets/material-number.component.d.ts +23 -0
  52. package/lib/widgets/material-one-of.component.d.ts +18 -0
  53. package/lib/widgets/material-radios.component.d.ts +20 -0
  54. package/lib/widgets/material-select.component.d.ts +21 -0
  55. package/lib/widgets/material-slider.component.d.ts +22 -0
  56. package/lib/widgets/material-stepper.component.d.ts +18 -0
  57. package/lib/widgets/material-tabs.component.d.ts +17 -0
  58. package/lib/widgets/material-textarea.component.d.ts +19 -0
  59. package/{src/lib/widgets/public_api.ts → lib/widgets/public_api.d.ts} +1 -14
  60. package/package.json +25 -7
  61. package/{src/public_api.ts → public_api.d.ts} +0 -4
  62. package/karma.conf.js +0 -37
  63. package/ng-package.json +0 -16
  64. package/src/lib/angular-flex-monkey-patch.ts +0 -13
  65. package/src/lib/material-design-framework.component.html +0 -20
  66. package/src/lib/material-design-framework.component.scss +0 -51
  67. package/src/lib/material-design-framework.component.spec.ts +0 -37
  68. package/src/lib/material-design-framework.component.ts +0 -121
  69. package/src/lib/material-design-framework.module.ts +0 -84
  70. package/src/lib/material-design.framework.ts +0 -75
  71. package/src/lib/widgets/flex-layout-root.component.html +0 -11
  72. package/src/lib/widgets/flex-layout-root.component.ts +0 -52
  73. package/src/lib/widgets/flex-layout-section.component.ts +0 -216
  74. package/src/lib/widgets/material-add-reference.component.ts +0 -56
  75. package/src/lib/widgets/material-button-group.component.ts +0 -68
  76. package/src/lib/widgets/material-button.component.ts +0 -59
  77. package/src/lib/widgets/material-checkbox.component.ts +0 -112
  78. package/src/lib/widgets/material-checkboxes.component.ts +0 -109
  79. package/src/lib/widgets/material-chip-list.component.ts +0 -35
  80. package/src/lib/widgets/material-datepicker.component.ts +0 -105
  81. package/src/lib/widgets/material-file.component.ts +0 -35
  82. package/src/lib/widgets/material-input.component.ts +0 -99
  83. package/src/lib/widgets/material-number.component.ts +0 -97
  84. package/src/lib/widgets/material-one-of.component.ts +0 -35
  85. package/src/lib/widgets/material-radios.component.ts +0 -89
  86. package/src/lib/widgets/material-select.component.ts +0 -120
  87. package/src/lib/widgets/material-slider.component.ts +0 -61
  88. package/src/lib/widgets/material-stepper.component.ts +0 -35
  89. package/src/lib/widgets/material-tabs.component.ts +0 -69
  90. package/src/lib/widgets/material-textarea.component.ts +0 -90
  91. package/src/test.ts +0 -21
  92. package/tsconfig.lib.json +0 -25
  93. package/tsconfig.lib.prod.json +0 -6
  94. package/tsconfig.spec.json +0 -17
  95. package/tslint.json +0 -11
@@ -1,109 +0,0 @@
1
- import { AbstractControl } from '@angular/forms';
2
- import { buildTitleMap } from '@ajsf/core';
3
- import { Component, Input, OnInit } from '@angular/core';
4
- import { JsonSchemaFormService, TitleMapItem } from '@ajsf/core';
5
-
6
- // TODO: Change this to use a Selection List instead?
7
- // https://material.angular.io/components/list/overview
8
-
9
- @Component({
10
- // tslint:disable-next-line:component-selector
11
- selector: 'material-checkboxes-widget',
12
- template: `
13
- <div>
14
- <mat-checkbox type="checkbox"
15
- [checked]="allChecked"
16
- [color]="options?.color || 'primary'"
17
- [disabled]="controlDisabled || options?.readonly"
18
- [indeterminate]="someChecked"
19
- [name]="options?.name"
20
- (blur)="options.showErrors = true"
21
- (change)="updateAllValues($event)">
22
- <span class="checkbox-name" [innerHTML]="options?.name"></span>
23
- </mat-checkbox>
24
- <label *ngIf="options?.title"
25
- class="title"
26
- [class]="options?.labelHtmlClass || ''"
27
- [style.display]="options?.notitle ? 'none' : ''"
28
- [innerHTML]="options?.title"></label>
29
- <ul class="checkbox-list" [class.horizontal-list]="horizontalList">
30
- <li *ngFor="let checkboxItem of checkboxList"
31
- [class]="options?.htmlClass || ''">
32
- <mat-checkbox type="checkbox"
33
- [(ngModel)]="checkboxItem.checked"
34
- [color]="options?.color || 'primary'"
35
- [disabled]="controlDisabled || options?.readonly"
36
- [name]="checkboxItem?.name"
37
- (blur)="options.showErrors = true"
38
- (change)="updateValue()">
39
- <span class="checkbox-name" [innerHTML]="checkboxItem?.name"></span>
40
- </mat-checkbox>
41
- </li>
42
- </ul>
43
- <mat-error *ngIf="options?.showErrors && options?.errorMessage"
44
- [innerHTML]="options?.errorMessage"></mat-error>
45
- </div>`,
46
- styles: [`
47
- .title { font-weight: bold; }
48
- .checkbox-list { list-style-type: none; }
49
- .horizontal-list > li { display: inline-block; margin-right: 10px; zoom: 1; }
50
- .checkbox-name { white-space: nowrap; }
51
- mat-error { font-size: 75%; }
52
- `],
53
- })
54
- export class MaterialCheckboxesComponent implements OnInit {
55
- formControl: AbstractControl;
56
- controlName: string;
57
- controlValue: any;
58
- controlDisabled = false;
59
- boundControl = false;
60
- options: any;
61
- horizontalList = false;
62
- formArray: AbstractControl;
63
- checkboxList: TitleMapItem[] = [];
64
- @Input() layoutNode: any;
65
- @Input() layoutIndex: number[];
66
- @Input() dataIndex: number[];
67
-
68
- constructor(
69
- private jsf: JsonSchemaFormService
70
- ) { }
71
-
72
- ngOnInit() {
73
- this.options = this.layoutNode.options || {};
74
- this.horizontalList = this.layoutNode.type === 'checkboxes-inline' ||
75
- this.layoutNode.type === 'checkboxbuttons';
76
- this.jsf.initializeControl(this);
77
- this.checkboxList = buildTitleMap(
78
- this.options.titleMap || this.options.enumNames, this.options.enum, true
79
- );
80
- if (this.boundControl) {
81
- const formArray = this.jsf.getFormControl(this);
82
- for (const checkboxItem of this.checkboxList) {
83
- checkboxItem.checked = formArray.value.includes(checkboxItem.value);
84
- }
85
- }
86
- }
87
-
88
- get allChecked(): boolean {
89
- return this.checkboxList.filter(t => t.checked).length === this.checkboxList.length;
90
- }
91
-
92
- get someChecked(): boolean {
93
- const checkedItems = this.checkboxList.filter(t => t.checked).length;
94
- return checkedItems > 0 && checkedItems < this.checkboxList.length;
95
- }
96
-
97
- updateValue() {
98
- this.options.showErrors = true;
99
- if (this.boundControl) {
100
- this.jsf.updateArrayCheckboxList(this, this.checkboxList);
101
- }
102
- }
103
-
104
- updateAllValues(event: any) {
105
- this.options.showErrors = true;
106
- this.checkboxList.forEach(t => t.checked = event.checked);
107
- this.updateValue();
108
- }
109
- }
@@ -1,35 +0,0 @@
1
- import { Component, Input, OnInit } from '@angular/core';
2
- import { AbstractControl } from '@angular/forms';
3
- import { JsonSchemaFormService } from '@ajsf/core';
4
-
5
- // TODO: Add this control
6
-
7
- @Component({
8
- // tslint:disable-next-line:component-selector
9
- selector: 'material-chip-list-widget',
10
- template: ``,
11
- })
12
- export class MaterialChipListComponent 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
- }
@@ -1,105 +0,0 @@
1
- import { Component, Inject, Input, OnInit, Optional } from '@angular/core';
2
- import { AbstractControl } from '@angular/forms';
3
- import { JsonSchemaFormService, dateToString } from '@ajsf/core';
4
- import { MatDatepickerInputEvent } from '@angular/material/datepicker';
5
- import { MAT_LABEL_GLOBAL_OPTIONS } from '@angular/material/core';
6
- import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
7
-
8
- @Component({
9
- // tslint:disable-next-line:component-selector
10
- selector: 'material-datepicker-widget',
11
- template: `
12
- <mat-form-field [appearance]="options?.appearance || matFormFieldDefaultOptions?.appearance || 'standard'"
13
- [class]="options?.htmlClass || ''"
14
- [floatLabel]="options?.floatLabel || matLabelGlobalOptions?.float || (options?.notitle ? 'never' : 'auto')"
15
- [hideRequiredMarker]="options?.hideRequired ? 'true' : 'false'"
16
- [style.width]="'100%'">
17
- <mat-label *ngIf="!options?.notitle">{{options?.title}}</mat-label>
18
- <span matPrefix *ngIf="options?.prefix || options?.fieldAddonLeft"
19
- [innerHTML]="options?.prefix || options?.fieldAddonLeft"></span>
20
- <input matInput *ngIf="boundControl"
21
- [formControl]="formControl"
22
- [attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
23
- [attr.list]="'control' + layoutNode?._id + 'Autocomplete'"
24
- [attr.readonly]="options?.readonly ? 'readonly' : null"
25
- [id]="'control' + layoutNode?._id"
26
- [max]="options?.maximum"
27
- [matDatepicker]="picker"
28
- [min]="options?.minimum"
29
- [name]="controlName"
30
- [placeholder]="options?.title"
31
- [readonly]="options?.readonly"
32
- [required]="options?.required"
33
- [style.width]="'100%'"
34
- (blur)="options.showErrors = true"
35
- (dateChange)="updateValue($event)"
36
- (dateInput)="updateValue($event)">
37
- <input matInput *ngIf="!boundControl"
38
- [attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
39
- [attr.list]="'control' + layoutNode?._id + 'Autocomplete'"
40
- [attr.readonly]="options?.readonly ? 'readonly' : null"
41
- [disabled]="controlDisabled || options?.readonly"
42
- [id]="'control' + layoutNode?._id"
43
- [max]="options?.maximum"
44
- [matDatepicker]="picker"
45
- [min]="options?.minimum"
46
- [name]="controlName"
47
- [placeholder]="options?.title"
48
- [required]="options?.required"
49
- [style.width]="'100%'"
50
- [readonly]="options?.readonly"
51
- (blur)="options.showErrors = true"
52
- (dateChange)="updateValue($event)"
53
- (dateInput)="updateValue($event)">
54
- <span matSuffix *ngIf="options?.suffix || options?.fieldAddonRight"
55
- [innerHTML]="options?.suffix || options?.fieldAddonRight"></span>
56
- <mat-hint *ngIf="options?.description && (!options?.showErrors || !options?.errorMessage)"
57
- align="end" [innerHTML]="options?.description"></mat-hint>
58
- <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
59
- </mat-form-field>
60
- <mat-datepicker #picker ></mat-datepicker>
61
- <mat-error *ngIf="options?.showErrors && options?.errorMessage"
62
- [innerHTML]="options?.errorMessage"></mat-error>`,
63
- styles: [`
64
- mat-error { font-size: 75%; margin-top: -1rem; margin-bottom: 0.5rem; }
65
- ::ng-deep json-schema-form mat-form-field .mat-form-field-wrapper .mat-form-field-flex
66
- .mat-form-field-infix { width: initial; }
67
- `],
68
- })
69
- export class MaterialDatepickerComponent implements OnInit {
70
- formControl: AbstractControl;
71
- controlName: string;
72
- controlValue: string;
73
- dateValue: any;
74
- controlDisabled = false;
75
- boundControl = false;
76
- options: any;
77
- autoCompleteList: string[] = [];
78
- @Input() layoutNode: any;
79
- @Input() layoutIndex: number[];
80
- @Input() dataIndex: number[];
81
-
82
- constructor(
83
- @Inject(MAT_FORM_FIELD_DEFAULT_OPTIONS) @Optional() public matFormFieldDefaultOptions,
84
- @Inject(MAT_LABEL_GLOBAL_OPTIONS) @Optional() public matLabelGlobalOptions,
85
- private jsf: JsonSchemaFormService
86
- ) { }
87
-
88
- ngOnInit() {
89
- this.options = this.layoutNode.options || {};
90
- this.jsf.initializeControl(this, !this.options.readonly);
91
- if (this.controlValue) {
92
- this.formControl.setValue(dateToString(this.controlValue, this.options));
93
- }
94
- if (!this.options.notitle && !this.options.description && this.options.placeholder) {
95
- this.options.description = this.options.placeholder;
96
- }
97
- }
98
-
99
- updateValue(event: MatDatepickerInputEvent<Date>) {
100
- this.options.showErrors = true;
101
- if (event.value) {
102
- this.formControl.setValue(dateToString(event.value, this.options));
103
- }
104
- }
105
- }
@@ -1,35 +0,0 @@
1
- import { AbstractControl } from '@angular/forms';
2
- import { Component, Input, OnInit } from '@angular/core';
3
- import { JsonSchemaFormService } from '@ajsf/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
- }
@@ -1,99 +0,0 @@
1
- import { AbstractControl } from '@angular/forms';
2
- import {Component, Inject, Input, OnInit, Optional} from '@angular/core';
3
- import { JsonSchemaFormService } from '@ajsf/core';
4
- import { MAT_LABEL_GLOBAL_OPTIONS } from '@angular/material/core';
5
- import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
6
-
7
- @Component({
8
- // tslint:disable-next-line:component-selector
9
- selector: 'material-input-widget',
10
- template: `
11
- <mat-form-field [appearance]="options?.appearance || matFormFieldDefaultOptions?.appearance || 'standard'"
12
- [class]="options?.htmlClass || ''"
13
- [floatLabel]="options?.floatLabel || matLabelGlobalOptions?.float || (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
- <input matInput *ngIf="boundControl"
20
- [formControl]="formControl"
21
- [attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
22
- [attr.list]="'control' + layoutNode?._id + 'Autocomplete'"
23
- [attr.maxlength]="options?.maxLength"
24
- [attr.minlength]="options?.minLength"
25
- [attr.pattern]="options?.pattern"
26
- [readonly]="options?.readonly ? 'readonly' : null"
27
- [id]="'control' + layoutNode?._id"
28
- [name]="controlName"
29
- [placeholder]="options?.notitle ? options?.placeholder : options?.title"
30
- [required]="options?.required"
31
- [style.width]="'100%'"
32
- [type]="layoutNode?.type"
33
- (blur)="options.showErrors = true">
34
- <input matInput *ngIf="!boundControl"
35
- [attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
36
- [attr.list]="'control' + layoutNode?._id + 'Autocomplete'"
37
- [attr.maxlength]="options?.maxLength"
38
- [attr.minlength]="options?.minLength"
39
- [attr.pattern]="options?.pattern"
40
- [disabled]="controlDisabled"
41
- [id]="'control' + layoutNode?._id"
42
- [name]="controlName"
43
- [placeholder]="options?.notitle ? options?.placeholder : options?.title"
44
- [readonly]="options?.readonly ? 'readonly' : null"
45
- [required]="options?.required"
46
- [style.width]="'100%'"
47
- [type]="layoutNode?.type"
48
- [value]="controlValue"
49
- (input)="updateValue($event)"
50
- (blur)="options.showErrors = true">
51
- <span matSuffix *ngIf="options?.suffix || options?.fieldAddonRight"
52
- [innerHTML]="options?.suffix || options?.fieldAddonRight"></span>
53
- <mat-hint *ngIf="options?.description && (!options?.showErrors || !options?.errorMessage)"
54
- align="end" [innerHTML]="options?.description"></mat-hint>
55
- <mat-autocomplete *ngIf="options?.typeahead?.source">
56
- <mat-option *ngFor="let word of options?.typeahead?.source"
57
- [value]="word">{{word}}</mat-option>
58
- </mat-autocomplete>
59
- </mat-form-field>
60
- <mat-error *ngIf="options?.showErrors && options?.errorMessage"
61
- [innerHTML]="options?.errorMessage"></mat-error>`,
62
- styles: [`
63
- mat-error { font-size: 75%; margin-top: -1rem; margin-bottom: 0.5rem; }
64
- ::ng-deep json-schema-form mat-form-field .mat-form-field-wrapper .mat-form-field-flex
65
- .mat-form-field-infix { width: initial; }
66
- `],
67
- })
68
- export class MaterialInputComponent implements OnInit {
69
- formControl: AbstractControl;
70
- controlName: string;
71
- controlValue: string;
72
- controlDisabled = false;
73
- boundControl = false;
74
- options: any;
75
- autoCompleteList: string[] = [];
76
- @Input() layoutNode: any;
77
- @Input() layoutIndex: number[];
78
- @Input() dataIndex: number[];
79
-
80
-
81
- constructor(
82
- @Inject(MAT_FORM_FIELD_DEFAULT_OPTIONS) @Optional() public matFormFieldDefaultOptions,
83
- @Inject(MAT_LABEL_GLOBAL_OPTIONS) @Optional() public matLabelGlobalOptions,
84
- private jsf: JsonSchemaFormService
85
- ) {
86
- }
87
-
88
- ngOnInit() {
89
- this.options = this.layoutNode.options || {};
90
- this.jsf.initializeControl(this);
91
- if (!this.options.notitle && !this.options.description && this.options.placeholder) {
92
- this.options.description = this.options.placeholder;
93
- }
94
- }
95
-
96
- updateValue(event) {
97
- this.jsf.updateValue(this, event.target.value);
98
- }
99
- }
@@ -1,97 +0,0 @@
1
- import {Component, Inject, Input, OnInit, Optional} from '@angular/core';
2
- import { AbstractControl } from '@angular/forms';
3
- import { JsonSchemaFormService } from '@ajsf/core';
4
- import { MAT_LABEL_GLOBAL_OPTIONS } from '@angular/material/core';
5
- import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
6
-
7
- @Component({
8
- // tslint:disable-next-line:component-selector
9
- selector: 'material-number-widget',
10
- template: `
11
- <mat-form-field [appearance]="options?.appearance || matFormFieldDefaultOptions?.appearance || 'standard'"
12
- [class]="options?.htmlClass || ''"
13
- [floatLabel]="options?.floatLabel || matLabelGlobalOptions?.float || (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
- <input matInput *ngIf="boundControl"
20
- [formControl]="formControl"
21
- [attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
22
- [attr.max]="options?.maximum"
23
- [attr.min]="options?.minimum"
24
- [attr.step]="options?.multipleOf || options?.step || 'any'"
25
- [id]="'control' + layoutNode?._id"
26
- [name]="controlName"
27
- [placeholder]="options?.notitle ? options?.placeholder : options?.title"
28
- [readonly]="options?.readonly ? 'readonly' : null"
29
- [required]="options?.required"
30
- [style.width]="'100%'"
31
- [type]="'number'"
32
- (blur)="options.showErrors = true">
33
- <input matInput *ngIf="!boundControl"
34
- [attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
35
- [attr.max]="options?.maximum"
36
- [attr.min]="options?.minimum"
37
- [attr.step]="options?.multipleOf || options?.step || 'any'"
38
- [disabled]="controlDisabled"
39
- [id]="'control' + layoutNode?._id"
40
- [name]="controlName"
41
- [placeholder]="options?.notitle ? options?.placeholder : options?.title"
42
- [readonly]="options?.readonly ? 'readonly' : null"
43
- [required]="options?.required"
44
- [style.width]="'100%'"
45
- [type]="'number'"
46
- [value]="controlValue"
47
- (input)="updateValue($event)"
48
- (blur)="options.showErrors = true">
49
- <span matSuffix *ngIf="options?.suffix || options?.fieldAddonRight"
50
- [innerHTML]="options?.suffix || options?.fieldAddonRight"></span>
51
- <mat-hint *ngIf="layoutNode?.type === 'range'" align="start"
52
- [innerHTML]="controlValue"></mat-hint>
53
- <mat-hint *ngIf="options?.description && (!options?.showErrors || !options?.errorMessage)"
54
- align="end" [innerHTML]="options?.description"></mat-hint>
55
- </mat-form-field>
56
- <mat-error *ngIf="options?.showErrors && options?.errorMessage"
57
- [innerHTML]="options?.errorMessage"></mat-error>`,
58
- styles: [`
59
- mat-error { font-size: 75%; margin-top: -1rem; margin-bottom: 0.5rem; }
60
- ::ng-deep json-schema-form mat-form-field .mat-form-field-wrapper .mat-form-field-flex
61
- .mat-form-field-infix { width: initial; }
62
- `],
63
- })
64
- export class MaterialNumberComponent implements OnInit {
65
- formControl: AbstractControl;
66
- controlName: string;
67
- controlValue: any;
68
- controlDisabled = false;
69
- boundControl = false;
70
- options: any;
71
- allowNegative = true;
72
- allowDecimal = true;
73
- allowExponents = false;
74
- lastValidNumber = '';
75
- @Input() layoutNode: any;
76
- @Input() layoutIndex: number[];
77
- @Input() dataIndex: number[];
78
-
79
- constructor(
80
- @Inject(MAT_FORM_FIELD_DEFAULT_OPTIONS) @Optional() public matFormFieldDefaultOptions,
81
- @Inject(MAT_LABEL_GLOBAL_OPTIONS) @Optional() public matLabelGlobalOptions,
82
- private jsf: JsonSchemaFormService
83
- ) { }
84
-
85
- ngOnInit() {
86
- this.options = this.layoutNode.options || {};
87
- this.jsf.initializeControl(this);
88
- if (this.layoutNode.dataType === 'integer') { this.allowDecimal = false; }
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
- }
@@ -1,35 +0,0 @@
1
- import { Component, Input, OnInit } from '@angular/core';
2
- import { AbstractControl } from '@angular/forms';
3
- import { JsonSchemaFormService } from '@ajsf/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
- }
@@ -1,89 +0,0 @@
1
- import { AbstractControl } from '@angular/forms';
2
- import { Component, Input, OnInit } from '@angular/core';
3
- import { JsonSchemaFormService, buildTitleMap } from '@ajsf/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
- mat-radio-group { display: inline-flex; }
52
- mat-radio-button { margin: 2px; }
53
- mat-error { font-size: 75%; }
54
- `]
55
- })
56
- export class MaterialRadiosComponent implements OnInit {
57
- formControl: AbstractControl;
58
- controlName: string;
59
- controlValue: any;
60
- controlDisabled = false;
61
- boundControl = false;
62
- options: any;
63
- flexDirection = 'column';
64
- radiosList: any[] = [];
65
- @Input() layoutNode: any;
66
- @Input() layoutIndex: number[];
67
- @Input() dataIndex: number[];
68
-
69
- constructor(
70
- private jsf: JsonSchemaFormService
71
- ) { }
72
-
73
- ngOnInit() {
74
- this.options = this.layoutNode.options || {};
75
- if (this.layoutNode.type === 'radios-inline') {
76
- this.flexDirection = 'row';
77
- }
78
- this.radiosList = buildTitleMap(
79
- this.options.titleMap || this.options.enumNames,
80
- this.options.enum, true
81
- );
82
- this.jsf.initializeControl(this, !this.options.readonly);
83
- }
84
-
85
- updateValue(value) {
86
- this.options.showErrors = true;
87
- this.jsf.updateValue(this, value);
88
- }
89
- }