<commit_before>import React, { PropTypes } from 'react';
import keys from './keys';

export default class TabPanel extends React.Component {
  componentWillMount() {
    const { manager, tabId } = this.props;
    const managedIndex = manager.tabPanels.push({
      tabId,
      element: this,
    }) - 1;
    if (!manager.activeTabId && managedIndex === 0) {
      manager.activeTabId = tabId;
    }
  }

  handleKeyDown(e) {
    if (e.ctrlKey && e.key === keys.UP) {
      e.preventDefault();
      this.props.manager.moveFocusCurrent();
    }
  }

  render() {
    const props = this.props;
    const isActive = props.manager.activeTabId === props.tabId;

    const kids = (function() {
      if (typeof props.children === 'function') return props.children({ isActive });
      if (!isActive) return false;
      return props.children;
    }());

    return React.createElement(props.tag, {
      className: props.className,
      id: props.tabId,
      onKeyDown: this.handleKeyDown.bind(this),
      role: 'tabpanel',
      'aria-hidden': !isActive,
    }, kids);
  }
}

TabPanel.propTypes = {
  children: PropTypes.oneOfType([
    PropTypes.element,
    PropTypes.arrayOf(PropTypes.element),
    PropTypes.function,
    PropTypes.string,
  ]).isRequired,
  tabId: PropTypes.string.isRequired,
  manager: PropTypes.object.isRequired,
  className: PropTypes.string,
  tag: PropTypes.string,<commit_msg>Fix PropType validation of TabPanel; closes #1<commit_after>import React, { PropTypes } from 'react';
import keys from './keys';

export default class TabPanel extends React.Component {
  componentWillMount() {
    const { manager, tabId } = this.props;
    const managedIndex = manager.tabPanels.push({
      tabId,
      element: this,
    }) - 1;
    if (!manager.activeTabId && managedIndex === 0) {
      manager.activeTabId = tabId;
    }
  }

  handleKeyDown(e) {
    if (e.ctrlKey && e.key === keys.UP) {
      e.preventDefault();
      this.props.manager.moveFocusCurrent();
    }
  }

  render() {
    const props = this.props;
    const isActive = props.manager.activeTabId === props.tabId;

    const kids = (function() {
      if (typeof props.children === 'function') return props.children({ isActive });
      if (!isActive) return false;
      return props.children;
    }());

    return React.createElement(props.tag, {
      className: props.className,
      id: props.tabId,
      onKeyDown: this.handleKeyDown.bind(this),
      role: 'tabpanel',
      'aria-hidden': !isActive,
    }, kids);
  }
}

TabPanel.propTypes = {
  children: PropTypes.oneOfType([
    PropTypes.node,
    PropTypes.func,
  ]).isRequired,
  tabId: PropTypes.string.isRequired,
  manager: PropTypes.object.isRequired,
  className: PropTypes.string,
  tag: PropTypes.string,
{'fraction_non_alphanumeric': 0.13600288600288601, 'fraction_numerical': 0.0018037518037518038, 'mean_word_length': 3.0072254335260116, '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': '3659129', 'n_tokens_mistral': 856, 'n_tokens_neox': 860, 'n_words': 189}