@@ -3,16 +3,14 @@ const { throwMissingParam: missingParamEr, throwInvalidParam: invalidParamEr } =
33export const apiConstructor = function ( getDeps , param = { options : { } } ) {
44 param . options = param . options || { } ;
55 const { optionManagerIns, helper, activedTabsHistoryIns } = getDeps . call ( this , param . options ) ;
6- this . optionManager = optionManagerIns ;
7- this . helper = helper ;
8- this . activedTabsHistory = activedTabsHistoryIns ;
6+ helper . setNoneEnumProps ( this , { helper, optionManager : optionManagerIns , activedTabsHistory : activedTabsHistoryIns } ) ;
97 this . _setUserProxy ( ) . _alterOnChangeCallback ( ) . _subscribeCallbacksOptions ( ) . _subscribeSelectedTabsHistory ( ) ;
108} ;
11- export const apiMethods = {
9+ const _apiProps = {
1210 _setUserProxy : function ( ) {
1311 const userProxy = { } ;
1412 for ( var prop in this )
15- if ( prop [ 0 ] !== '_' ) {
13+ if ( prop [ 0 ] !== '_' && prop !== 'constructor' ) {
1614 const propValue = this [ prop ] ;
1715 if ( typeof propValue === 'function' ) {
1816 userProxy [ prop ] = propValue . bind ( this ) ;
@@ -69,14 +67,6 @@ export const apiMethods = {
6967 } ,
7068 isSelected : function ( id = missingParamEr ( 'isSelected' ) ) { return this . _state . selectedTabID == id ; } ,
7169 isOpen : function ( id = missingParamEr ( 'isOpen' ) ) { return this . _state . openTabIDs . indexOf ( id ) >= 0 ; } ,
72- eventHandlerFactory : function ( { e, id } ) {
73- const { beforeClose, beforeSelect } = this . getOptions ( ) , el = e . target , parentEl = el . parentElement
74- , { close, tab } = this . getSetting ( ) . cssClasses ;
75- if ( el . className . includes ( close ) && parentEl && parentEl . lastChild && ( parentEl . lastChild == el ) && parentEl . className . includes ( tab ) )
76- beforeClose . call ( this . userProxy , e , id ) && this . close ( id ) ;
77- else
78- beforeSelect . call ( this . userProxy , e , id ) && this . select ( id ) ;
79- } ,
8070 _getOnChangePromise : function ( ) {
8171 return new ( Promise ) ( resolve => { this . one ( 'onChange' , ( ) => { resolve . call ( this . userProxy ) ; } ) ; } ) ;
8272 } ,
@@ -138,3 +128,14 @@ export const apiMethods = {
138128 return result ;
139129 }
140130} ;
131+ Helper . setNoneEnumProps ( _apiProps , {
132+ eventHandlerFactory : function ( { e, id } ) {
133+ const { beforeClose, beforeSelect } = this . getOptions ( ) , el = e . target , parentEl = el . parentElement
134+ , { close, tab } = this . getSetting ( ) . cssClasses ;
135+ if ( el . className . includes ( close ) && parentEl && parentEl . lastChild && ( parentEl . lastChild == el ) && parentEl . className . includes ( tab ) )
136+ beforeClose . call ( this . userProxy , e , id ) && this . close ( id ) ;
137+ else
138+ beforeSelect . call ( this . userProxy , e , id ) && this . select ( id ) ;
139+ }
140+ } ) ;
141+ export const apiProps = _apiProps ;
0 commit comments