@@ -27,6 +27,7 @@ import {
2727import { DEBUG_BUILD } from '../util/debug-build' ;
2828import { isScreenshotSupported } from '../util/isScreenshotSupported' ;
2929import { mergeOptions } from '../util/mergeOptions' ;
30+ import type { ActorComponent } from './components/Actor' ;
3031import { Actor } from './components/Actor' ;
3132import { createMainStyles } from './createMainStyles' ;
3233import { sendFeedback } from './sendFeedback' ;
@@ -53,7 +54,8 @@ export const buildFeedbackIntegration = ({
5354} : BuilderOptions ) : IntegrationFn <
5455 Integration & {
5556 attachTo ( el : Element | string , optionOverrides : OverrideFeedbackConfiguration ) : Unsubscribe ;
56- createWidget ( optionOverrides : OverrideFeedbackConfiguration ) : Promise < FeedbackDialog > ;
57+ createForm ( optionOverrides : OverrideFeedbackConfiguration ) : Promise < FeedbackDialog > ;
58+ createWidget ( optionOverrides : OverrideFeedbackConfiguration ) : ActorComponent ;
5759 remove ( ) : void ;
5860 }
5961> => {
@@ -198,7 +200,7 @@ export const buildFeedbackIntegration = ({
198200 } ) ;
199201 } ;
200202
201- const attachTo = ( el : Element | string , optionOverrides : OverrideFeedbackConfiguration = { } ) : Unsubscribe => {
203+ const _attachTo = ( el : Element | string , optionOverrides : OverrideFeedbackConfiguration = { } ) : Unsubscribe => {
202204 const mergedOptions = mergeOptions ( _options , optionOverrides ) ;
203205
204206 const targetEl =
@@ -238,10 +240,11 @@ export const buildFeedbackIntegration = ({
238240 return unsubscribe ;
239241 } ;
240242
241- const autoInjectActor = ( ) : void => {
243+ const _createActor = ( optionOverrides : OverrideFeedbackConfiguration = { } ) : ActorComponent => {
242244 const shadow = _createShadow ( _options ) ;
243245 const actor = Actor ( { buttonLabel : _options . buttonLabel , shadow } ) ;
244246 const mergedOptions = mergeOptions ( _options , {
247+ ...optionOverrides ,
245248 onFormOpen ( ) {
246249 actor . removeFromDom ( ) ;
247250 } ,
@@ -252,9 +255,8 @@ export const buildFeedbackIntegration = ({
252255 actor . appendToDom ( ) ;
253256 } ,
254257 } ) ;
255- attachTo ( actor . el , mergedOptions ) ;
256-
257- actor . appendToDom ( ) ;
258+ _attachTo ( actor . el , mergedOptions ) ;
259+ return actor ;
258260 } ;
259261
260262 return {
@@ -264,20 +266,31 @@ export const buildFeedbackIntegration = ({
264266 return ;
265267 }
266268
267- autoInjectActor ( ) ;
269+ _createActor ( ) . appendToDom ( ) ;
268270 } ,
269271
270272 /**
271273 * Adds click listener to the element to open a feedback dialog
272274 *
273275 * The returned function can be used to remove the click listener
274276 */
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+ } ,
276288
277289 /**
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.
279292 */
280- async createWidget ( optionOverrides : OverrideFeedbackConfiguration = { } ) : Promise < FeedbackDialog > {
293+ async createForm ( optionOverrides : OverrideFeedbackConfiguration = { } ) : Promise < FeedbackDialog > {
281294 return _loadAndRenderDialog ( mergeOptions ( _options , optionOverrides ) ) ;
282295 } ,
283296
0 commit comments