1
1
import { BuilderInfo , Components , ExtendedComponentSchema , Utils as FormioUtils } from 'formiojs' ;
2
- import { FormioCustomComponentInfo , FormioCustomElement } from '../formio.common' ;
2
+ import { FormioCustomComponentInfo , FormioCustomElement , FormioEvent } from '../formio.common' ;
3
3
import { clone , isNil , isArray } from 'lodash' ;
4
4
5
5
const BaseInputComponent = Components . components . input ;
@@ -106,16 +106,19 @@ export function createCustomFormioComponent(customComponentOptions: FormioCustom
106
106
superAttach = super . attach ( element ) ;
107
107
}
108
108
109
+ // Bind customOptions
109
110
for ( const key in this . component . customOptions ) {
110
111
if ( this . component . customOptions . hasOwnProperty ( key ) ) {
111
112
this . _customAngularElement [ key ] = this . component . customOptions [ key ] ;
112
113
}
113
114
}
115
+ // Bind validate options
114
116
for ( const key in this . component . validate ) {
115
117
if ( this . component . validate . hasOwnProperty ( key ) ) {
116
118
this . _customAngularElement [ key ] = this . component . validate [ key ] ;
117
119
}
118
120
}
121
+ // Bind options explicitly set
119
122
const fieldOptions = customComponentOptions . fieldOptions ;
120
123
if ( isArray ( fieldOptions ) && fieldOptions . length > 0 ) {
121
124
for ( const key in fieldOptions ) {
@@ -125,6 +128,14 @@ export function createCustomFormioComponent(customComponentOptions: FormioCustom
125
128
}
126
129
}
127
130
131
+ // Attach event listener for emit event
132
+ this . _customAngularElement . addEventListener ( 'formioEvent' , ( event : CustomEvent < FormioEvent > ) => {
133
+ this . emit ( event . detail . eventName , {
134
+ ...event . detail . data ,
135
+ component : this . component
136
+ } ) ;
137
+ } ) ;
138
+
128
139
// Ensure we bind the value (if it isn't a multiple-value component with no wrapper)
129
140
if ( ! this . _customAngularElement . value && ! this . component . disableMultiValueWrapper ) {
130
141
this . restoreValue ( ) ;
0 commit comments