@ruc-lib/metaform 2.0.0 → 2.0.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/.eslintrc.json +36 -0
- package/dist/README.md +135 -0
- package/dist/package.json +38 -0
- package/jest.config.ts +22 -0
- package/ng-package.json +6 -0
- package/package.json +20 -38
- package/project.json +50 -0
- package/src/components/ruc-meta-checkbox-group/ruc-meta-checkbox-group.component.css +10 -0
- package/src/components/ruc-meta-checkbox-group/ruc-meta-checkbox-group.component.html +11 -0
- package/src/components/ruc-meta-checkbox-group/ruc-meta-checkbox-group.component.spec.ts +103 -0
- package/src/components/ruc-meta-checkbox-group/ruc-meta-checkbox-group.component.ts +33 -0
- package/src/components/ruc-meta-inputs/ruc-meta-inputs.component.css +16 -0
- package/src/components/ruc-meta-inputs/ruc-meta-inputs.component.html +18 -0
- package/src/components/ruc-meta-inputs/ruc-meta-inputs.component.spec.ts +85 -0
- package/src/components/ruc-meta-inputs/ruc-meta-inputs.component.ts +44 -0
- package/src/components/ruc-meta-radio-group/ruc-meta-radio-group.component.css +13 -0
- package/src/components/ruc-meta-radio-group/ruc-meta-radio-group.component.html +12 -0
- package/src/components/ruc-meta-radio-group/ruc-meta-radio-group.component.spec.ts +98 -0
- package/src/components/ruc-meta-radio-group/ruc-meta-radio-group.component.ts +28 -0
- package/src/components/ruc-meta-select/ruc-meta-select.component.css +9 -0
- package/src/components/ruc-meta-select/ruc-meta-select.component.html +12 -0
- package/src/components/ruc-meta-select/ruc-meta-select.component.spec.ts +1165 -0
- package/src/components/ruc-meta-select/ruc-meta-select.component.ts +45 -0
- package/src/components/ruc-text-area/ruc-text-area.component.css +0 -0
- package/src/components/ruc-text-area/ruc-text-area.component.html +16 -0
- package/src/components/ruc-text-area/ruc-text-area.component.spec.ts +100 -0
- package/src/components/ruc-text-area/ruc-text-area.component.ts +30 -0
- package/src/index.ts +2 -0
- package/src/interfaces/metaFormsDefault.ts +71 -0
- package/src/lib/ruclib-metaform/ruclib-metaform.component.html +99 -0
- package/src/lib/ruclib-metaform/ruclib-metaform.component.scss +15 -0
- package/src/lib/ruclib-metaform/ruclib-metaform.component.spec.ts +1253 -0
- package/src/lib/ruclib-metaform/ruclib-metaform.component.stories.ts +676 -0
- package/src/lib/ruclib-metaform/ruclib-metaform.component.ts +91 -0
- package/src/lib/ruclib-metaform.module.ts +59 -0
- package/src/services/ruc-meta-form-validation.service.spec.ts +75 -0
- package/src/services/ruc-meta-form-validation.service.ts +30 -0
- package/src/services/ruc-meta-form.service.spec.ts +63 -0
- package/src/services/ruc-meta-form.service.ts +20 -0
- package/src/test-setup.ts +1 -0
- package/tsconfig.json +30 -0
- package/tsconfig.lib.json +17 -0
- package/tsconfig.lib.prod.json +9 -0
- package/tsconfig.spec.json +16 -0
- /package/{components → dist/components}/ruc-meta-checkbox-group/ruc-meta-checkbox-group.component.d.ts +0 -0
- /package/{components → dist/components}/ruc-meta-inputs/ruc-meta-inputs.component.d.ts +0 -0
- /package/{components → dist/components}/ruc-meta-radio-group/ruc-meta-radio-group.component.d.ts +0 -0
- /package/{components → dist/components}/ruc-meta-select/ruc-meta-select.component.d.ts +0 -0
- /package/{components → dist/components}/ruc-text-area/ruc-text-area.component.d.ts +0 -0
- /package/{esm2020 → dist/esm2020}/components/ruc-meta-checkbox-group/ruc-meta-checkbox-group.component.mjs +0 -0
- /package/{esm2020 → dist/esm2020}/components/ruc-meta-inputs/ruc-meta-inputs.component.mjs +0 -0
- /package/{esm2020 → dist/esm2020}/components/ruc-meta-radio-group/ruc-meta-radio-group.component.mjs +0 -0
- /package/{esm2020 → dist/esm2020}/components/ruc-meta-select/ruc-meta-select.component.mjs +0 -0
- /package/{esm2020 → dist/esm2020}/components/ruc-text-area/ruc-text-area.component.mjs +0 -0
- /package/{esm2020 → dist/esm2020}/index.mjs +0 -0
- /package/{esm2020 → dist/esm2020}/interfaces/metaFormsDefault.mjs +0 -0
- /package/{esm2020 → dist/esm2020}/lib/ruclib-metaform/ruclib-metaform.component.mjs +0 -0
- /package/{esm2020 → dist/esm2020}/lib/ruclib-metaform.module.mjs +0 -0
- /package/{esm2020 → dist/esm2020}/ruc-lib-metaform.mjs +0 -0
- /package/{esm2020 → dist/esm2020}/services/ruc-meta-form-validation.service.mjs +0 -0
- /package/{esm2020 → dist/esm2020}/services/ruc-meta-form.service.mjs +0 -0
- /package/{fesm2015 → dist/fesm2015}/ruc-lib-metaform.mjs +0 -0
- /package/{fesm2015 → dist/fesm2015}/ruc-lib-metaform.mjs.map +0 -0
- /package/{fesm2020 → dist/fesm2020}/ruc-lib-metaform.mjs +0 -0
- /package/{fesm2020 → dist/fesm2020}/ruc-lib-metaform.mjs.map +0 -0
- /package/{index.d.ts → dist/index.d.ts} +0 -0
- /package/{interfaces → dist/interfaces}/metaFormsDefault.d.ts +0 -0
- /package/{lib → dist/lib}/ruclib-metaform/ruclib-metaform.component.d.ts +0 -0
- /package/{lib → dist/lib}/ruclib-metaform.module.d.ts +0 -0
- /package/{services → dist/services}/ruc-meta-form-validation.service.d.ts +0 -0
- /package/{services → dist/services}/ruc-meta-form.service.d.ts +0 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Component, Input, OnInit, EventEmitter, Output } from '@angular/core';
|
|
2
|
+
import {RucMetaFormValidationService} from '../../services/ruc-meta-form-validation.service';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'ruc-meta-inputs',
|
|
6
|
+
templateUrl: './ruc-meta-inputs.component.html',
|
|
7
|
+
styleUrls: ['./ruc-meta-inputs.component.css']
|
|
8
|
+
})
|
|
9
|
+
export class RucMetaInputsComponent implements OnInit {
|
|
10
|
+
@Input() rucInputData : any;
|
|
11
|
+
@Input() selectedParentId?:any;
|
|
12
|
+
@Output() transferUserInput = new EventEmitter<any>();
|
|
13
|
+
@Input() customTheme: string | undefined;
|
|
14
|
+
errorMessage: string | undefined
|
|
15
|
+
options: string[] = [];
|
|
16
|
+
filteredOptions: any;
|
|
17
|
+
constructor(public validationService:RucMetaFormValidationService) {
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
ngOnInit(): void {
|
|
22
|
+
this.errorMessage = this.validationService.defaultErrorMessage;
|
|
23
|
+
this.rucInputData.value === undefined ? "" : this.rucInputData.value;
|
|
24
|
+
this.options = this.rucInputData.autocomplete;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @param e
|
|
29
|
+
*/
|
|
30
|
+
modelChangeFn(e:any) {
|
|
31
|
+
const validate = this.validationService.alphaNumericValidator(this.rucInputData);
|
|
32
|
+
this.rucInputData.errorMsg = validate;
|
|
33
|
+
if(this.rucInputData.autocomplete){
|
|
34
|
+
this.filteredOptions = this._filter(this.rucInputData.value);
|
|
35
|
+
}
|
|
36
|
+
this.transferUserInput.emit(this.rucInputData);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private _filter(value: string): string[] {
|
|
40
|
+
const filterValue = value.toLowerCase();
|
|
41
|
+
return this.options.filter(option => option.toLowerCase().includes(filterValue));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<mat-label>{{rucInputData?.label}}</mat-label>
|
|
2
|
+
<mat-radio-group
|
|
3
|
+
aria-labelledby="radio-group-label"
|
|
4
|
+
class="{{customTheme}} radio-group" [(ngModel)]="radioValue">
|
|
5
|
+
<mat-radio-button class="radio-button" *ngFor="let item of rucInputData?.groupOptions" [value]="item.value"
|
|
6
|
+
(change)="modelChangeFn($event)">
|
|
7
|
+
{{item?.name}}
|
|
8
|
+
</mat-radio-button>
|
|
9
|
+
</mat-radio-group>
|
|
10
|
+
<div *ngIf="rucInputData?.errorMsg" class="form-error">
|
|
11
|
+
{{rucInputData?.customErrorMessage ? rucInputData?.customErrorMessage : errorMessage}}
|
|
12
|
+
</div>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { RucMetaRadioGroupComponent } from './ruc-meta-radio-group.component';
|
|
4
|
+
import { MetaFormConfig } from '../../interfaces/metaFormsDefault';
|
|
5
|
+
|
|
6
|
+
describe('RucMetaRadioGroupComponent', () => {
|
|
7
|
+
let component: RucMetaRadioGroupComponent;
|
|
8
|
+
let fixture: ComponentFixture<RucMetaRadioGroupComponent>;
|
|
9
|
+
const mockFormData: MetaFormConfig = {
|
|
10
|
+
"formType": "simple",
|
|
11
|
+
"fieldType": "radio",
|
|
12
|
+
"inputType": "radio",
|
|
13
|
+
"id": "radio",
|
|
14
|
+
"name": "radio",
|
|
15
|
+
"label": "radio configuration",
|
|
16
|
+
"className": "radio",
|
|
17
|
+
"value": "",
|
|
18
|
+
"alt": "na",
|
|
19
|
+
"appearance": "outline",
|
|
20
|
+
"min": "4",
|
|
21
|
+
"max": "20",
|
|
22
|
+
"width": "100",
|
|
23
|
+
"height": "20",
|
|
24
|
+
"checked": false,
|
|
25
|
+
"disabled": false,
|
|
26
|
+
"maxlength": "100",
|
|
27
|
+
"readonly": false,
|
|
28
|
+
"required": true,
|
|
29
|
+
"size": "100",
|
|
30
|
+
"step": "100",
|
|
31
|
+
"sameRow":false,
|
|
32
|
+
"sameRowColumnWidth": "100",
|
|
33
|
+
"tooltip": "Checkpoint",
|
|
34
|
+
"tooltipPosition": "above",
|
|
35
|
+
"pattern": "any",
|
|
36
|
+
"placeholder": "",
|
|
37
|
+
"autofocus": true,
|
|
38
|
+
"autocomplete": false,
|
|
39
|
+
"customComponentName": "none",
|
|
40
|
+
"rucDialogInput": {},
|
|
41
|
+
"hasDependentFields": false,
|
|
42
|
+
"dependentFieldParentId": "any",
|
|
43
|
+
"dependentFields": [],
|
|
44
|
+
"toolTipDescription": "none",
|
|
45
|
+
"errorMsg": false,
|
|
46
|
+
"customErrorMessage": "invalid selection",
|
|
47
|
+
"showErrorOnPopUp": true,
|
|
48
|
+
"groupOptions": [
|
|
49
|
+
{
|
|
50
|
+
"id": "Winter",
|
|
51
|
+
"name": "Winter",
|
|
52
|
+
"value": ""
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"id": "Spring",
|
|
56
|
+
"name": "Spring",
|
|
57
|
+
"value": ""
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"id": "Summer",
|
|
61
|
+
"name": "Summer",
|
|
62
|
+
"value": ""
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"id": "Autumn",
|
|
66
|
+
"name": "Autumn",
|
|
67
|
+
"value": ""
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
beforeEach(async () => {
|
|
72
|
+
await TestBed.configureTestingModule({
|
|
73
|
+
declarations: [ RucMetaRadioGroupComponent ]
|
|
74
|
+
})
|
|
75
|
+
.compileComponents();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
beforeEach(() => {
|
|
79
|
+
fixture = TestBed.createComponent(RucMetaRadioGroupComponent);
|
|
80
|
+
component = fixture.componentInstance;
|
|
81
|
+
fixture.detectChanges();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('should create', () => {
|
|
85
|
+
expect(component).toBeTruthy();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('should called modelChangeFn ', () => {
|
|
89
|
+
component.dataSource = mockFormData;
|
|
90
|
+
const event = {
|
|
91
|
+
value: "Winter"
|
|
92
|
+
}
|
|
93
|
+
const spy = spyOn(component.transferUserInput, 'emit');
|
|
94
|
+
component.modelChangeFn(event);
|
|
95
|
+
|
|
96
|
+
expect(spy).toHaveBeenCalled();
|
|
97
|
+
})
|
|
98
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Component, Input, OnInit,EventEmitter, Output } from '@angular/core';
|
|
2
|
+
import {RucMetaFormValidationService} from '../../services/ruc-meta-form-validation.service';
|
|
3
|
+
import { MatRadioChange } from '@angular/material/radio';
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'ruc-meta-radio-group',
|
|
6
|
+
templateUrl: './ruc-meta-radio-group.component.html',
|
|
7
|
+
styleUrls: ['./ruc-meta-radio-group.component.css'],
|
|
8
|
+
})
|
|
9
|
+
export class RucMetaRadioGroupComponent implements OnInit {
|
|
10
|
+
@Input() rucInputData : any;
|
|
11
|
+
@Input() customTheme: string | undefined;
|
|
12
|
+
@Output() transferUserInput = new EventEmitter<any>();
|
|
13
|
+
errorMessage: string | undefined
|
|
14
|
+
radioValue: string | undefined;
|
|
15
|
+
constructor(public validationService:RucMetaFormValidationService) { }
|
|
16
|
+
|
|
17
|
+
ngOnInit(): void {
|
|
18
|
+
this.errorMessage = this.validationService.defaultErrorMessage;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @param e
|
|
23
|
+
*/
|
|
24
|
+
modelChangeFn(e:any) {
|
|
25
|
+
this.rucInputData.value = e.value;
|
|
26
|
+
this.transferUserInput.emit(this.rucInputData);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<div class="select-label">
|
|
2
|
+
<mat-label>{{rucInputData?.label}}</mat-label>
|
|
3
|
+
</div>
|
|
4
|
+
<mat-form-field [ngStyle]="{ 'width.%': rucInputData?.width }" matTooltip="{{rucInputData?.tooltip}}" [appearance]="rucInputData?.appearance || 'fill'">
|
|
5
|
+
<mat-label>Choose an option</mat-label>
|
|
6
|
+
<mat-select (selectionChange)="modelChangeFn($event)" [(ngModel)]="rucInputData.value">
|
|
7
|
+
<mat-option *ngFor="let item of rucInputData?.groupOptions" [value]="item.value" [disabled]="item?.disable"> {{item.name}}</mat-option>
|
|
8
|
+
</mat-select>
|
|
9
|
+
</mat-form-field>
|
|
10
|
+
<div *ngIf="rucInputData?.errorMsg" class="form-error">
|
|
11
|
+
{{rucInputData?.customErrorMessage ? rucInputData?.customErrorMessage : errorMessage}}
|
|
12
|
+
</div>
|