@the-control-group/ui
Advanced tools
Comparing version 1.7.18 to 1.7.19
@@ -13,3 +13,4 @@ import React, { Component } from 'react'; | ||
const defaultActiveIndex = Math.max(React.Children.toArray(this.props.children).findIndex(c => c.props.defaultActive), 0); | ||
const children = React.Children.toArray(this.props.children).filter(Boolean), | ||
defaultActiveIndex = Math.max(children.findIndex(c => c.props.defaultActive), 0); | ||
@@ -33,19 +34,18 @@ this.state = { | ||
const { activeIndex } = this.state, | ||
{ children, mobileDesign } = this.props; | ||
{ mobileDesign } = this.props, | ||
children = React.Children.toArray(this.props.children).filter(Boolean), | ||
activeTab = children.filter(c => !!c)[activeIndex]; | ||
const activeTab = React.Children.toArray(children)[activeIndex]; | ||
return ( | ||
<div className={classNames('ui-tabs-container', { desktop: (!isMobile() && !mobileDesign) })}> | ||
<List inline className="ui-tabs-nav"> | ||
{React.Children.map(children, (child, i) => ( | ||
//This check will allow empty nodes to be skipped over | ||
child && | ||
<TabNavItem | ||
{...child.props} | ||
tabId={i} | ||
changeTab={this.changeTab} | ||
active={i === activeIndex} | ||
width={`${100 / children.length}%`} | ||
/> | ||
{children.map((child, i) => ( | ||
<TabNavItem | ||
key={i} | ||
{...child.props} | ||
tabId={i} | ||
changeTab={this.changeTab} | ||
active={i === activeIndex} | ||
width={`${100 / children.length}%`} | ||
/> | ||
))} | ||
@@ -52,0 +52,0 @@ </List> |
{ | ||
"name": "@the-control-group/ui", | ||
"version": "1.7.18", | ||
"version": "1.7.19", | ||
"description": "UI kit based on ReactJS for TCG projects", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
76029
1557