1.8.16 • Published 2 years ago
@farawayslv/v-factory v1.8.16
VFactory
Library for create dynamic reactive forms into Angular apps.
Start
Angular CLI version 12.2.2.
need to install angular material:
ng add @angular/material
install v-factory:
npm i @farawayslv/v-factory
Example
Full example: https://github.com/web-stack-slv/v-factory
import v-factory to module:
import { VFactoryModule } from '@farawayslv/v-factory';
@NgModule({
declarations: [
...
],
imports: [
VFactoryModule,
...
],
})
component.html
insert html part to container or card:
<v-v-factory
[formConfig]="formConfig"
[form]="form"
(submit)="submit($event)"
></v-v-factory>
component.ts
in component need define new form and formConfig:
form = new FormGroup({});
formConfig = [
new VInputField({
label: 'VInputField',
name: 'input',
validators: [{
required: true,
message: 'Field is required'
},{
maxlength: 10,
message: 'Max length 10 chars'
}]
}),
new VNumberField({
name: 'number',
label: 'VNumberField',
validators: [{
min: 10,
message: 'Min value 10'
},{
max: 20,
message: 'Max value 20'
}]
}),
new VButton({
text: 'Save',
styleType: 'raised',
type: 'submit'
})
];
List of available fields and containers:
VAccordion,
VAutocompleteField,
VBox,
VButton,
VCheckboxField,
VChipsField,
VColorField,
VDatepickerField,
VDragDropList,
VImage,
VInputField,
VLabel,
VMaskedField,
VNumberField,
VRadioField,
VSelectField,
VSlideToggleField,
VSliderField,
VTextField,
VFileField,
VEditorField,
VDivider,
VContent,
VImageField
json available types (all above classes in lowercase):
vaccordion,
vautocompletefield,
vbox,
vbutton,
vcheckboxfield,
vchipsfield,
vcolorfield,
vdatepickerfield,
vdragdroplist,
vimage,
vinputfield,
vlabel,
vmaskedfield,
vnumberfield,
vradiofield,
vselectfield,
vslidetogglefield,
vsliderfield,
vtextfield,
vfilefield,
veditorfield,
vdivider,
vcontent,
vimagefield
formConfig can be as array of items or objects like parsed json.
For json:
constructor(
private _factoryService: VFactoryService
){ }
jsonCfg = [
{
vtype: 'vinputfield',
label: 'VInputField',
name: 'input',
validators: [{
required: true,
message: 'Field is required'
},{
maxlength: 10,
message: 'Max length 10 chars'
}]
},
{
vtype: 'vbutton',
text: 'Save',
styleType: 'raised',
type: 'submit'
}
]
ngOnInit(): void {
this.formConfig = this._factoryService.fromJSON(this.jsonCfg);
this._factoryService.updateConfig(this.formConfig);
}
1.9.16
2 years ago
1.8.16
2 years ago
1.7.14
3 years ago
1.7.15
3 years ago
1.7.16
3 years ago
1.6.14
3 years ago
1.6.13
3 years ago
1.6.11
3 years ago
1.6.12
3 years ago
1.6.10
3 years ago
1.5.10
3 years ago
1.5.9
3 years ago
1.5.8
3 years ago
1.5.7
3 years ago
1.5.6
3 years ago
1.4.6
3 years ago
1.4.5
3 years ago
1.4.4
3 years ago
1.3.4
3 years ago
1.3.3
3 years ago
1.2.3
3 years ago
1.2.2
3 years ago
1.2.1
3 years ago
1.1.1
3 years ago
1.1.0
3 years ago
1.0.3
3 years ago
1.0.2
3 years ago
1.0.1
3 years ago