@@ -3,46 +3,49 @@ import { Form as FormConstructor, PluginSettings, usePlugin } from '@forms.js/co
3
3
import { PropType , defineComponent , h } from 'vue' ;
4
4
5
5
const Form = defineComponent ( {
6
- props : {
7
- options : {
8
- type : Object as PropType < FormOptions > ,
9
- required : true
10
- }
6
+ props : {
7
+ options : {
8
+ type : Object as PropType < FormOptions > ,
9
+ required : true ,
11
10
} ,
12
-
13
- data ( ) {
14
- return {
15
- formInstance : null as FormConstructor | null
16
- }
11
+ plugins : {
12
+ type : Array as PropType < PluginSettings [ ] > | object as PropType < PluginSettings > ,
13
+ default : [ ] ,
14
+ required : false ,
17
15
} ,
16
+ } ,
18
17
19
- methods : {
20
- getForm ( ) : FormConstructor | null {
21
- return this . formInstance as FormConstructor | null ;
22
- } ,
23
- usePlugin ( pluginSettings : PluginSettings | PluginSettings [ ] ) {
24
- usePlugin ( pluginSettings ) ;
25
- }
26
- } ,
18
+ data ( ) {
19
+ return {
20
+ formInstance : null as FormConstructor | null ,
21
+ } ;
22
+ } ,
27
23
28
- render ( ) {
29
- return h ( 'div' , {
30
- attrs : { 'data-formsjs-id' : this . $props . options . id }
31
- } )
24
+ methods : {
25
+ getForm ( ) : FormConstructor | null {
26
+ return this . formInstance as FormConstructor | null ;
32
27
} ,
33
-
34
- mounted ( ) {
35
- this . formInstance = new FormConstructor ( this . $el as HTMLElement , this . $props . options ) ;
36
- } ,
37
-
38
- beforeUnmount ( ) {
39
- const form = this . getForm ( ) ;
40
- form . destroy ( ) ;
41
- } ,
42
-
43
- watch : {
44
- // check for option changes and rerender form
45
- } ,
46
- } )
47
-
48
- export default Form
28
+ } ,
29
+
30
+ render ( ) {
31
+ return h ( 'div' , {
32
+ attrs : { 'data-formsjs-id' : this . $props . options . id } ,
33
+ } ) ;
34
+ } ,
35
+
36
+ mounted ( ) {
37
+ usePlugin ( this . $props . plugins ) ;
38
+ this . formInstance = new FormConstructor ( this . $el as HTMLElement , this . $props . options ) ;
39
+ } ,
40
+
41
+ beforeUnmount ( ) {
42
+ const form = this . getForm ( ) ;
43
+ form ?. destroy ( ) ;
44
+ } ,
45
+
46
+ watch : {
47
+ // check for option changes and rerender form
48
+ } ,
49
+ } ) ;
50
+
51
+ export default Form ;
0 commit comments