<commit_before>import React from 'react';
import ReactDOM from 'react-dom';
import classnames from 'classnames';
import uniqueid from 'lodash.uniqueid';

import mixin from 'pui-react-mixins';
import Scrim from 'pui-react-mixins/mixins/scrim_mixin';

require('pui-css-dropdowns');

const types = React.PropTypes;

const DEFAULT_KIND = 'btn-default';
const DEFAULT_TOGGLE = <span className="caret"/>;

class Dropdown extends mixin(React.Component).with(Scrim) {
  constructor(props, context) {
    super(props, context);
    this.state = {
      isOpen: false
    };
  }

  static propTypes = {
    border: types.bool,
    buttonClassName: types.string,
    disableScrim: types.bool,
    id: types.oneOfType([types.string, types.number]),
    pullRight: types.bool,
    split: types.bool,
    style: types.any,
    title: types.node,
    toggle: types.node,
    onClick: types.func
  };

  static defaultProps = {
    disableScrim: false
  };

  click = (event) => {
    this.setState({isOpen: !this.state.isOpen});
    this.props.onClick && this.props.onClick(event);
  };

  scrimClick = () => {
    this.setState({isOpen: false});
  };

  render() {
    const {border, buttonClassName, children, className, id, kind, pullRight, split, style, title, toggle} = this.props;
    const {isOpen} = this.state;

    let buttonKind, dropdownLabel, dropdownToggle, toggleNode;

    buttonKind = kind ? `btn-${kind}` : DEFAULT_KIND;
    toggleNode = toggle ? toggle : DEFAULT_TOGGLE;

    const buttonStyleClasses = classnames('btn', buttonKind, buttonClassName);
    dropdownLabel = split ? <div className={classnames('dropdown-label', buttonStyleClasses)}>{title}</div> : null;
    dropdownToggle = (
      <button id={id} style={style} onClick={this.click} className={classnames('dropdown-toggle', buttonStyleClasses)}>
        {!split ? title : null}
        {toggleNode}
      </button>
    );

    const dropdownClasses = classnames('dropdown', 'btn-group', {open: isOpen}, {split: split}, className);
    const dropdownMenuClasses = classnames('dropdown-menu', {'dropdown-border': border}, {'dropdown-menu-right': pullRight});
    return (
      <div className={dropdownClasses}>
        {dropdownLabel}
        {dropdownToggle}
        <ul className={dropdownMenuClasses}>{children}</ul>
      </div>
    );
  };
}

class LinkDropdown extends Dropdown {
  static defaultProps = {
    kind: 'link'
  };
}

class DefaultAltDropdown extends Dropdown {
  static defaultProps = {
    kind: 'default-alt'
  };
}

class LowlightDropdown extends Dropdown {
  static defaultProps = {
    kind: 'lowlight'
  };
}

class DangerDropdown extends Dropdown {
  static defaultProps = {
    kind: 'danger'
  };
}

class HighlightDropdown extends Dropdown {
  static defaultProps = {
    kind: 'highlight'
  };
}

class HighlightAltDropdown extends Dropdown {
  static defaultProps = {
    kind: 'highlight-alt'
  };
}

class DropdownItem extends React.Component {
  static propTypes = {
    className: types.string,
    style: types.object,
    href: types.string,
    id: types.string,
    header: types.bool,
    divider: types.bool,
    disabled: types.bool,
    eventKey: types.string,
    onSelect: types.func,
    target: types.string
  };

  handleClick = (event) => {
    const {href, disabled, onSelect, eventKey} = this.props;

    if (!href || disabled) {
      event.preventDefault();
    }

    if (disabled) return;

    if (onSelect) {
      onSelect(event, eventKey);
    }
  };

  render() {
    const {children, className, style, href, header, divider, disabled, ...anchorProps} = this.props;

    if (header) return (<li role="heading" className="dropdown-header">{children}</li>);
    if (divider) return (<li role="separator" className="divider"/>);

    let anchor;<commit_msg>chore(Dropdowns): Prune propTypes in DropdownItem<commit_after>import React from 'react';
import ReactDOM from 'react-dom';
import classnames from 'classnames';
import uniqueid from 'lodash.uniqueid';

import mixin from 'pui-react-mixins';
import Scrim from 'pui-react-mixins/mixins/scrim_mixin';

require('pui-css-dropdowns');

const types = React.PropTypes;

const DEFAULT_KIND = 'btn-default';
const DEFAULT_TOGGLE = <span className="caret"/>;

class Dropdown extends mixin(React.Component).with(Scrim) {
  constructor(props, context) {
    super(props, context);
    this.state = {
      isOpen: false
    };
  }

  static propTypes = {
    border: types.bool,
    buttonClassName: types.string,
    disableScrim: types.bool,
    id: types.oneOfType([types.string, types.number]),
    pullRight: types.bool,
    split: types.bool,
    style: types.any,
    title: types.node,
    toggle: types.node,
    onClick: types.func
  };

  static defaultProps = {
    disableScrim: false
  };

  click = (event) => {
    this.setState({isOpen: !this.state.isOpen});
    this.props.onClick && this.props.onClick(event);
  };

  scrimClick = () => {
    this.setState({isOpen: false});
  };

  render() {
    const {border, buttonClassName, children, className, id, kind, pullRight, split, style, title, toggle} = this.props;
    const {isOpen} = this.state;

    let buttonKind, dropdownLabel, dropdownToggle, toggleNode;

    buttonKind = kind ? `btn-${kind}` : DEFAULT_KIND;
    toggleNode = toggle ? toggle : DEFAULT_TOGGLE;

    const buttonStyleClasses = classnames('btn', buttonKind, buttonClassName);
    dropdownLabel = split ? <div className={classnames('dropdown-label', buttonStyleClasses)}>{title}</div> : null;
    dropdownToggle = (
      <button id={id} style={style} onClick={this.click} className={classnames('dropdown-toggle', buttonStyleClasses)}>
        {!split ? title : null}
        {toggleNode}
      </button>
    );

    const dropdownClasses = classnames('dropdown', 'btn-group', {open: isOpen}, {split: split}, className);
    const dropdownMenuClasses = classnames('dropdown-menu', {'dropdown-border': border}, {'dropdown-menu-right': pullRight});
    return (
      <div className={dropdownClasses}>
        {dropdownLabel}
        {dropdownToggle}
        <ul className={dropdownMenuClasses}>{children}</ul>
      </div>
    );
  };
}

class LinkDropdown extends Dropdown {
  static defaultProps = {
    kind: 'link'
  };
}

class DefaultAltDropdown extends Dropdown {
  static defaultProps = {
    kind: 'default-alt'
  };
}

class LowlightDropdown extends Dropdown {
  static defaultProps = {
    kind: 'lowlight'
  };
}

class DangerDropdown extends Dropdown {
  static defaultProps = {
    kind: 'danger'
  };
}

class HighlightDropdown extends Dropdown {
  static defaultProps = {
    kind: 'highlight'
  };
}

class HighlightAltDropdown extends Dropdown {
  static defaultProps = {
    kind: 'highlight-alt'
  };
}

class DropdownItem extends React.Component {
  static propTypes = {
    className: types.string,
    style: types.object,
    href: types.string,
    header: types.bool,
    divider: types.bool,
    disabled: types.bool,
    eventKey: types.string,
    onSelect: types.func
  };

  handleClick = (event) => {
    const {href, disabled, onSelect, eventKey} = this.props;

    if (!href || disabled) {
      event.preventDefault();
    }

    if (disabled) return;

    if (onSelect) {
      onSelect(event, eventKey);
    }
  };

  render() {
    const {children, className, style, href, header, divider, disabled, ...anchorProps} = this.props;

    if (header) return (<li role="heading" className="dropdown-header">{children}</li>);
    if (divider) return (<li role="separator" className="divider"/>);

    let anchor;
{'fraction_non_alphanumeric': 0.13602649006622516, 'fraction_numerical': 0.0, 'mean_word_length': 3.540589296452195, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 33, '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': '4934106', 'n_tokens_mistral': 2359, 'n_tokens_neox': 2309, 'n_words': 553}