<commit_before>/* eslint indent:0 */
import React, {PropTypes} from 'react/addons';
import jss from 'js-stylesheet';
import uuid from '../helpers/uuid';
import childrenPropType from '../helpers/childrenPropType';

// Determine if a node from event.target is a Tab element
function isTabNode(node) {
  return node.nodeName === 'LI' && node.getAttribute('role') === 'tab';
}

// Determine if a tab node is disabled
function isTabDisabled(node) {
  return node.getAttribute('aria-disabled') === 'true';
}

module.exports = React.createClass({
  displayName: 'Tabs',

	propTypes: {
		selectedIndex: PropTypes.number,
		onSelect: PropTypes.func,
		focus: PropTypes.bool,
    children: childrenPropType,
    forceRenderTabPanel: PropTypes.bool
	},

  childContextTypes: {
    forceRenderTabPanel: PropTypes.bool
  },

	getDefaultProps() {
		return {
			selectedIndex: -1,
			focus: false,
      forceRenderTabPanel: false
		};
	},

	getInitialState() {
    return this.copyPropsToState(this.props);
  },

  getChildContext() {
    return {
      forceRenderTabPanel: this.props.forceRenderTabPanel
    };
  },

	componentWillMount() {
    jss(require('../helpers/styles.js'));
	},

  componentWillReceiveProps(newProps) {
    this.setState(this.copyPropsToState(newProps));
  },

	handleClick(e) {
		let node = e.target;
		do {
			if (isTabNode(node)) {
        if (isTabDisabled(node)) {
          return;
        }

        const index = [].slice.call(node.parentNode.children).indexOf(node);
        this.setSelected(index);
				return;
			}
		} while ((node = node.parentNode) !== null);
	},

	handleKeyDown(e) {
		if (isTabNode(e.target)) {
			let index = this.state.selectedIndex;
			let preventDefault = false;

			// Select next tab to the left
			if (e.keyCode === 37 || e.keyCode === 38) {
				index = this.getPrevTab(index);
				preventDefault = true;
			}
			// Select next tab to the right<commit_msg>Add static method Tabs.setUseDefaultStyles(bool) to disable default styling<commit_after>/* eslint indent:0 */
import React, {PropTypes} from 'react/addons';
import jss from 'js-stylesheet';
import uuid from '../helpers/uuid';
import childrenPropType from '../helpers/childrenPropType';

// Determine if a node from event.target is a Tab element
function isTabNode(node) {
  return node.nodeName === 'LI' && node.getAttribute('role') === 'tab';
}

// Determine if a tab node is disabled
function isTabDisabled(node) {
  return node.getAttribute('aria-disabled') === 'true';
}

let useDefaultStyles = true;

module.exports = React.createClass({
  displayName: 'Tabs',

	propTypes: {
		selectedIndex: PropTypes.number,
		onSelect: PropTypes.func,
		focus: PropTypes.bool,
    children: childrenPropType,
    forceRenderTabPanel: PropTypes.bool
	},

  childContextTypes: {
    forceRenderTabPanel: PropTypes.bool
  },

  statics: {
    setUseDefaultStyles(use) {
      useDefaultStyles = use;
    }
  },

	getDefaultProps() {
		return {
			selectedIndex: -1,
			focus: false,
      forceRenderTabPanel: false
		};
	},

	getInitialState() {
    return this.copyPropsToState(this.props);
  },

  getChildContext() {
    return {
      forceRenderTabPanel: this.props.forceRenderTabPanel
    };
  },

  componentWillMount() {
    if (useDefaultStyles) {
      jss(require('../helpers/styles.js'));
	}
  },

  componentWillReceiveProps(newProps) {
    this.setState(this.copyPropsToState(newProps));
  },

	handleClick(e) {
		let node = e.target;
		do {
			if (isTabNode(node)) {
        if (isTabDisabled(node)) {
          return;
        }

        const index = [].slice.call(node.parentNode.children).indexOf(node);
        this.setSelected(index);
				return;
			}
		} while ((node = node.parentNode) !== null);
	},

	handleKeyDown(e) {
		if (isTabNode(e.target)) {
			let index = this.state.selectedIndex;
			let preventDefault = false;

			// Select next tab to the left
			if (e.keyCode === 37 || e.keyCode === 38) {
				index = this.getPrevTab(index);
				preventDefault = true;
			}
			// Select next tab to the right
{'fraction_non_alphanumeric': 0.1357656986845371, 'fraction_numerical': 0.0029784065524944155, 'mean_word_length': 3.3379978471474705, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5593332', 'n_tokens_mistral': 1364, 'n_tokens_neox': 1286, 'n_words': 285}