@@ -27,6 +27,7 @@ import {
27
27
import { DEBUG_BUILD } from '../util/debug-build' ;
28
28
import { isScreenshotSupported } from '../util/isScreenshotSupported' ;
29
29
import { mergeOptions } from '../util/mergeOptions' ;
30
+ import type { ActorComponent } from './components/Actor' ;
30
31
import { Actor } from './components/Actor' ;
31
32
import { createMainStyles } from './createMainStyles' ;
32
33
import { sendFeedback } from './sendFeedback' ;
@@ -53,7 +54,8 @@ export const buildFeedbackIntegration = ({
53
54
} : BuilderOptions ) : IntegrationFn <
54
55
Integration & {
55
56
attachTo ( el : Element | string , optionOverrides : OverrideFeedbackConfiguration ) : Unsubscribe ;
56
- createWidget ( optionOverrides : OverrideFeedbackConfiguration ) : Promise < FeedbackDialog > ;
57
+ createForm ( optionOverrides : OverrideFeedbackConfiguration ) : Promise < FeedbackDialog > ;
58
+ createWidget ( optionOverrides : OverrideFeedbackConfiguration ) : ActorComponent ;
57
59
remove ( ) : void ;
58
60
}
59
61
> => {
@@ -198,7 +200,7 @@ export const buildFeedbackIntegration = ({
198
200
} ) ;
199
201
} ;
200
202
201
- const attachTo = ( el : Element | string , optionOverrides : OverrideFeedbackConfiguration = { } ) : Unsubscribe => {
203
+ const _attachTo = ( el : Element | string , optionOverrides : OverrideFeedbackConfiguration = { } ) : Unsubscribe => {
202
204
const mergedOptions = mergeOptions ( _options , optionOverrides ) ;
203
205
204
206
const targetEl =
@@ -238,10 +240,11 @@ export const buildFeedbackIntegration = ({
238
240
return unsubscribe ;
239
241
} ;
240
242
241
- const autoInjectActor = ( ) : void => {
243
+ const _createActor = ( optionOverrides : OverrideFeedbackConfiguration = { } ) : ActorComponent => {
242
244
const shadow = _createShadow ( _options ) ;
243
245
const actor = Actor ( { buttonLabel : _options . buttonLabel , shadow } ) ;
244
246
const mergedOptions = mergeOptions ( _options , {
247
+ ...optionOverrides ,
245
248
onFormOpen ( ) {
246
249
actor . removeFromDom ( ) ;
247
250
} ,
@@ -252,9 +255,8 @@ export const buildFeedbackIntegration = ({
252
255
actor . appendToDom ( ) ;
253
256
} ,
254
257
} ) ;
255
- attachTo ( actor . el , mergedOptions ) ;
256
-
257
- actor . appendToDom ( ) ;
258
+ _attachTo ( actor . el , mergedOptions ) ;
259
+ return actor ;
258
260
} ;
259
261
260
262
return {
@@ -264,20 +266,31 @@ export const buildFeedbackIntegration = ({
264
266
return ;
265
267
}
266
268
267
- autoInjectActor ( ) ;
269
+ _createActor ( ) . appendToDom ( ) ;
268
270
} ,
269
271
270
272
/**
271
273
* Adds click listener to the element to open a feedback dialog
272
274
*
273
275
* The returned function can be used to remove the click listener
274
276
*/
275
- attachTo,
277
+ attachTo : _attachTo ,
278
+
279
+ /**
280
+ * Creates a new widget which is composed of a Button which triggers a Dialog.
281
+ * Accepts partial options to override any options passed to constructor.
282
+ */
283
+ createWidget ( optionOverrides : OverrideFeedbackConfiguration = { } ) : ActorComponent {
284
+ const actor = _createActor ( mergeOptions ( _options , optionOverrides ) ) ;
285
+ actor . appendToDom ( ) ;
286
+ return actor ;
287
+ } ,
276
288
277
289
/**
278
- * Creates a new widget. Accepts partial options to override any options passed to constructor.
290
+ * Creates a new Form which you can
291
+ * Accepts partial options to override any options passed to constructor.
279
292
*/
280
- async createWidget ( optionOverrides : OverrideFeedbackConfiguration = { } ) : Promise < FeedbackDialog > {
293
+ async createForm ( optionOverrides : OverrideFeedbackConfiguration = { } ) : Promise < FeedbackDialog > {
281
294
return _loadAndRenderDialog ( mergeOptions ( _options , optionOverrides ) ) ;
282
295
} ,
283
296
0 commit comments