11/** @jsx  React.DOM */ 
2- var  React  =  require ( 'react/addons' ) , 
3- 	invariant  =  require ( 'react/lib/invariant' ) ; 
2+ var  React  =  require ( 'react/addons' ) ; 
3+ var  invariant  =  require ( 'react/lib/invariant' ) ; 
4+ var  jss  =  require ( 'js-stylesheet' ) ; 
5+ var  uuid  =  require ( '../helpers/uuid' ) ; 
46
57// Determine if a node from event.target is a Tab element 
68function  isTabNode ( node )  { 
79	return  node . nodeName  ===  'LI'  &&  node . getAttribute ( 'role' )  ===  'tab' ; 
810} 
911
10- // Get a universally unique identifier 
11- var  uuid  =  ( function  ( )  { 
12- 	var  count  =  0 ; 
13- 	return  function  ( )  { 
14- 		return  'react-tabs-'  +  count ++ ; 
15- 	} 
16- } ) ( ) ; 
17- 
1812module . exports  =  React . createClass ( { 
1913	displayName : 'Tabs' , 
2014
@@ -32,8 +26,8 @@ module.exports = React.createClass({
3226	} , 
3327
3428	getInitialState : function  ( )  { 
35- 		var  tabIds  =  [ ] , 
36- 			 panelIds  =  [ ] ; 
29+ 		var  tabIds  =  [ ] ; 
30+ 		var   panelIds  =  [ ] ; 
3731
3832		// Setup tab/panel ids 
3933		React . Children . forEach ( this . props . children [ 0 ] . props . children ,  function  ( )  { 
@@ -50,8 +44,8 @@ module.exports = React.createClass({
5044	} , 
5145
5246	componentWillMount : function  ( )  { 
53- 		var  tabsCount  =  this . getTabsCount ( ) , 
54- 			 panelsCount  =  this . getPanelsCount ( ) ; 
47+ 		var  tabsCount  =  this . getTabsCount ( ) ; 
48+ 		var   panelsCount  =  this . getPanelsCount ( ) ; 
5549
5650		invariant ( 
5751			tabsCount  ===  panelsCount , 
@@ -61,6 +55,10 @@ module.exports = React.createClass({
6155		) ; 
6256	} , 
6357
58+ 	componentDidMount : function  ( )  { 
59+ 		jss ( require ( '../helpers/styles.js' ) ) ; 		
60+ 	} , 
61+ 
6462	setSelected : function  ( index ,  focus )  { 
6563		// Don't do anything if nothing has changed 
6664		if  ( index  ===  this . state . selectedIndex )  return ; 
@@ -147,10 +145,10 @@ module.exports = React.createClass({
147145	} , 
148146
149147	render : function  ( )  { 
150- 		var  index  =  0 , 
151- 			 count  =  0 , 
152- 			 children , 
153- 			 state  =  this . state ; 
148+ 		var  index  =  0 ; 
149+ 		var   count  =  0 ; 
150+ 		var   children ; 
151+ 		var   state  =  this . state ; 
154152
155153		// Map children to dynamically setup refs 
156154		children  =  React . Children . map ( this . props . children ,  function  ( child )  { 
@@ -161,11 +159,11 @@ module.exports = React.createClass({
161159				result  =  React . addons . cloneWithProps ( child ,  { 
162160					ref : 'tablist' , 
163161					children : React . Children . map ( child . props . children ,  function  ( tab )  { 
164- 						var  ref  =  'tabs-'  +  index , 
165- 							 id  =  state . tabIds [ index ] , 
166- 							 panelId  =  state . panelIds [ index ] , 
167- 							 selected  =  state . selectedIndex  ===  index , 
168- 							 focus  =  selected  &&  state . focus ; 
162+ 						var  ref  =  'tabs-'  +  index ; 
163+ 						var   id  =  state . tabIds [ index ] ; 
164+ 						var   panelId  =  state . panelIds [ index ] ; 
165+ 						var   selected  =  state . selectedIndex  ===  index ; 
166+ 						var   focus  =  selected  &&  state . focus ; 
169167
170168						index ++ ; 
171169
@@ -184,10 +182,10 @@ module.exports = React.createClass({
184182			} 
185183			// Clone TabPanel components to have refs 
186184			else  { 
187- 				var  ref  =  'panels-'  +  index , 
188- 					 id  =  state . panelIds [ index ] , 
189- 					 tabId  =  state . tabIds [ index ] , 
190- 					 selected  =  state . selectedIndex  ===  index ; 
185+ 				var  ref  =  'panels-'  +  index ; 
186+ 				var   id  =  state . panelIds [ index ] ; 
187+ 				var   tabId  =  state . tabIds [ index ] ; 
188+ 				var   selected  =  state . selectedIndex  ===  index ; 
191189
192190				index  ++ ; 
193191
0 commit comments