@@ -28,6 +28,7 @@ export default class Tab {
2828 _icon
2929 _iconSvgSanitized
3030 _mount
31+ _setIsActive
3132 _update
3233 _destroy
3334 _enabled
@@ -42,12 +43,13 @@ export default class Tab {
4243 * @param {?string } options.icon the icon css class
4344 * @param {?string } options.iconSvg the icon in svg format
4445 * @param {Function } options.mount function to mount the tab
46+ * @param {Function } [options.setIsActive] function to forward the active state of the tab
4547 * @param {Function } options.update function to update the tab
4648 * @param {Function } options.destroy function to destroy the tab
4749 * @param {Function } [options.enabled] define conditions whether this tab is active. Must returns a boolean
4850 * @param {Function } [options.scrollBottomReached] executed when the tab is scrolled to the bottom
4951 */
50- constructor ( { id, name, icon, iconSvg, mount, update, destroy, enabled, scrollBottomReached } = { } ) {
52+ constructor ( { id, name, icon, iconSvg, mount, setIsActive , update, destroy, enabled, scrollBottomReached } = { } ) {
5153 if ( enabled === undefined ) {
5254 enabled = ( ) => true
5355 }
@@ -68,6 +70,9 @@ export default class Tab {
6870 if ( typeof mount !== 'function' ) {
6971 throw new Error ( 'The mount argument should be a function' )
7072 }
73+ if ( setIsActive !== undefined && typeof setIsActive !== 'function' ) {
74+ throw new Error ( 'The setIsActive argument should be a function' )
75+ }
7176 if ( typeof update !== 'function' ) {
7277 throw new Error ( 'The update argument should be a function' )
7378 }
@@ -85,6 +90,7 @@ export default class Tab {
8590 this . _name = name
8691 this . _icon = icon
8792 this . _mount = mount
93+ this . _setIsActive = setIsActive
8894 this . _update = update
8995 this . _destroy = destroy
9096 this . _enabled = enabled
@@ -119,6 +125,10 @@ export default class Tab {
119125 return this . _mount
120126 }
121127
128+ get setIsActive ( ) {
129+ return this . _setIsActive || ( ( ) => undefined )
130+ }
131+
122132 get update ( ) {
123133 return this . _update
124134 }
0 commit comments