@@ -3,16 +3,14 @@ const { throwMissingParam: missingParamEr, throwInvalidParam: invalidParamEr } =
3
3
export const apiConstructor = function ( getDeps , param = { options : { } } ) {
4
4
param . options = param . options || { } ;
5
5
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 } ) ;
9
7
this . _setUserProxy ( ) . _alterOnChangeCallback ( ) . _subscribeCallbacksOptions ( ) . _subscribeSelectedTabsHistory ( ) ;
10
8
} ;
11
- export const apiMethods = {
9
+ const _apiProps = {
12
10
_setUserProxy : function ( ) {
13
11
const userProxy = { } ;
14
12
for ( var prop in this )
15
- if ( prop [ 0 ] !== '_' ) {
13
+ if ( prop [ 0 ] !== '_' && prop !== 'constructor' ) {
16
14
const propValue = this [ prop ] ;
17
15
if ( typeof propValue === 'function' ) {
18
16
userProxy [ prop ] = propValue . bind ( this ) ;
@@ -69,14 +67,6 @@ export const apiMethods = {
69
67
} ,
70
68
isSelected : function ( id = missingParamEr ( 'isSelected' ) ) { return this . _state . selectedTabID == id ; } ,
71
69
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
- } ,
80
70
_getOnChangePromise : function ( ) {
81
71
return new ( Promise ) ( resolve => { this . one ( 'onChange' , ( ) => { resolve . call ( this . userProxy ) ; } ) ; } ) ;
82
72
} ,
@@ -138,3 +128,14 @@ export const apiMethods = {
138
128
return result ;
139
129
}
140
130
} ;
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