1- import { Store , StoreOptions , Module , ActionTree } from 'vuex' ;
2- import { ShowOptions , RemoveRequest , OverlayHostState , EntrySetting , PluginSettings , ShowResponse } from '@/common' ;
1+ import { Module , Store } from 'vuex' ;
32
4- function validateShowOptions ( options : ShowOptions , defaultTimeout : number ) : ShowOptions {
3+ import { EntrySetting , OverlayHostState , PluginSettings , RemoveRequest , ShowOptions , ShowResponse , FinalShowOptions } from './common' ;
4+
5+ function validateShowOptions ( options : ShowOptions , defaultTimeout : number ) : FinalShowOptions {
56 if ( options == null || typeof options !== 'object' ) {
67 throw new TypeError ( 'The Settings have to be specified!' ) ;
78 }
@@ -33,7 +34,12 @@ function validateShowOptions(options: ShowOptions, defaultTimeout: number): Show
3334 options . timeout = defaultTimeout ;
3435 }
3536
36- return options ;
37+ // Default the closeOnEscape to true
38+ if ( typeof options . closeOnEscape !== 'boolean' ) {
39+ options . closeOnEscape = true ;
40+ }
41+
42+ return options as FinalShowOptions ;
3743}
3844
3945function validateRemoveRequest ( payload : number | RemoveRequest ) : RemoveRequest {
@@ -95,8 +101,6 @@ export function createModule(pluginSettings: PluginSettings): Module<OverlayHost
95101
96102 const actions = {
97103 show ( store : Store < OverlayHostState > , options : ShowOptions ) : Promise < ShowResponse > {
98- options = validateShowOptions ( options , defaultTimeout ) ;
99-
100104 let resolve = ( ) => { } ;
101105 let reject = ( ) => { } ;
102106 const promise = new Promise < RemoveRequest > ( ( re , rj ) => {
@@ -110,11 +114,7 @@ export function createModule(pluginSettings: PluginSettings): Module<OverlayHost
110114 id,
111115 resolver : resolve ,
112116 rejector : reject ,
113- settings : {
114- timeout : defaultTimeout ,
115- closeOnEscape : true ,
116- ...options
117- }
117+ settings : validateShowOptions ( options , defaultTimeout ) ,
118118 } ;
119119
120120 if ( item . settings . timeout != null && item . settings . timeout > 0 ) {
@@ -148,7 +148,7 @@ export function createModule(pluginSettings: PluginSettings): Module<OverlayHost
148148 didRemoveElement . resolver ( { value : payload . value , origin : payload . origin } ) ;
149149 return Promise . resolve ( true ) ;
150150 } ,
151- abor ( store : Store < OverlayHostState > , payload : RemoveRequest ) : Promise < boolean > {
151+ abort ( store : Store < OverlayHostState > , payload : RemoveRequest ) : Promise < boolean > {
152152 payload = validateRemoveRequest ( payload ) ;
153153 const didRemoveElement = removeEntryFromStore ( store , payload . id ) ;
154154
0 commit comments