<commit_before>import React from 'react';

function prefixClsFn(prefixCls, ...args) {
  return args.map((s)=> {
    return prefixCls + '-' + s;
  }).join(' ');
}

class Group extends React.Component {
  render() {
    return (
      <div className={this.props.className} key="ant-input-group">
        {this.props.children}
      </div>
    );
  }
}

Group.propTypes = {
  className: React.PropTypes.string,
  children: React.PropTypes.any,
};

Group.defaultProps = {
  className: 'ant-input-group',
};

class Input extends React.Component {
  // TODO
  getInputDOMNode() {
    return this.refs.input;
  }

  // TODO
  getValue() {
    if (this.props.type === 'static') {
      return this.props.value;
    } else if (this.props.type) {
      return this.getInputDOMNode().value;
    }

    throw new Error('Cannot use getValue without specifying input type.');
  }

  renderLabledInput(children) {
    const props = this.props;
    const wrapperClassName = prefixClsFn(props.prefixCls, 'input-group');
    const addonClassName = prefixClsFn(wrapperClassName, 'addon');
    const addonBefore = props.addonBefore ? (
      <span className={addonClassName} key="addonBefore">
        {props.addonBefore}
      </span>
    ) : null;

    const addonAfter = props.addonAfter ? (
      <span className={addonClassName} key="addonAfter">
        {props.addonAfter}
      </span>
    ) : null;

    return addonBefore || addonAfter ? (
      <div className={wrapperClassName} key="ant-input-group">
        {addonBefore}
        {children}
        {addonAfter}
      </div>
    ) : children;
  }

  renderInput() {
    const props = this.props;
    const prefixCls = props.prefixCls;
    const inputClassName = prefixClsFn(prefixCls, 'input');
    if (!props.type) {
      return props.children;
    }

    // let inputClass;
    // switch (props.size) {
    // case 'small': inputClass = prefixClsFn(inputClassName, 'sm'); break;
    // case 'large': inputClass = prefixClsFn(inputClassName, 'lg'); break;
    // default:
    // }

    switch (props.type) {
    case 'textarea':
      return <textarea {...props} className={inputClassName} ref="input" />;
    case 'static':
      return (
        <p id={props.id} className={prefixClsFn(prefixCls, 'form-text')} ref="input">
          {props.value}
        </p>
      );
    default:
      return <input {...props} className={inputClassName} ref="input" key="input"/>;
    }
  }

  render() {
    return this.renderLabledInput(this.renderInput());
  }
}

Input.propTypes = {
  type: React.PropTypes.string,
  id: React.PropTypes.oneOfType([
    React.PropTypes.string,
    React.PropTypes.number,
  ]),
  size: React.PropTypes.oneOf(['small', 'medium', 'large']),
  disabled: React.PropTypes.bool,
  value: React.PropTypes.any,
  defaultValue: React.PropTypes.any,
  className: React.PropTypes.string,
  addonBefore: React.PropTypes.node,
  addonAfter: React.PropTypes.node,
  children: React.PropTypes.any,
  prefixCls: React.PropTypes.string,
};

Input.defaultProps = {<commit_msg>增加 size 定义。<commit_after>import React from 'react';

function prefixClsFn(prefixCls, ...args) {
  return args.map((s)=> {
    return prefixCls + '-' + s;
  }).join(' ');
}

class Group extends React.Component {
  render() {
    return (
      <div className={this.props.className} key="ant-input-group">
        {this.props.children}
      </div>
    );
  }
}

Group.propTypes = {
  className: React.PropTypes.string,
  children: React.PropTypes.any,
};

Group.defaultProps = {
  className: 'ant-input-group',
};


class Input extends React.Component {
  getInputDOMNode() {
    return this.refs.input;
  }

  getValue() {
    if (this.props.type === 'static') {
      return this.props.value;
    } else if (this.props.type) {
      return this.getInputDOMNode().value;
    }

    throw new Error('Cannot use getValue without specifying input type.');
  }

  renderLabledInput(children) {
    const props = this.props;
    const wrapperClassName = prefixClsFn(props.prefixCls, 'input-group');
    const addonClassName = prefixClsFn(wrapperClassName, 'addon');
    const addonBefore = props.addonBefore ? (
      <span className={addonClassName} key="addonBefore">
        {props.addonBefore}
      </span>
    ) : null;

    const addonAfter = props.addonAfter ? (
      <span className={addonClassName} key="addonAfter">
        {props.addonAfter}
      </span>
    ) : null;

    return addonBefore || addonAfter ? (
      <div className={wrapperClassName} key="ant-input-group">
        {addonBefore}
        {children}
        {addonAfter}
      </div>
    ) : children;
  }

  renderInput() {
    const props = this.props;
    const prefixCls = props.prefixCls;
    let inputClassName = prefixClsFn(prefixCls, 'input');
    if (!props.type) {
      return props.children;
    }

    switch (props.size) {
    case 'small': inputClassName = prefixClsFn(prefixCls, 'input', 'input-sm'); break;
    case 'large': inputClassName = prefixClsFn(prefixCls, 'input', 'input-lg'); break;
    default:
    }

    switch (props.type) {
    case 'textarea':
      return <textarea {...props} className={inputClassName} ref="input" />;
    case 'static':
      return (
        <p id={props.id} className={prefixClsFn(prefixCls, 'form-text')} ref="input">
          {props.value}
        </p>
      );
    default:
      inputClassName = props.className ? props.className : inputClassName;
      return <input {...props} className={inputClassName} ref="input" key="input"/>;
    }
  }

  render() {
    return this.renderLabledInput(this.renderInput());
  }
}

Input.propTypes = {
  type: React.PropTypes.string,
  id: React.PropTypes.oneOfType([
    React.PropTypes.string,
    React.PropTypes.number,
  ]),
  size: React.PropTypes.oneOf(['small', 'default', 'large']),
  disabled: React.PropTypes.bool,
  value: React.PropTypes.any,
  defaultValue: React.PropTypes.any,
  className: React.PropTypes.string,
  addonBefore: React.PropTypes.node,
  addonAfter: React.PropTypes.node,
  children: React.PropTypes.any,
  prefixCls: React.PropTypes.string,
};

Input.defaultProps = {
{'fraction_non_alphanumeric': 0.14756517461878996, 'fraction_numerical': 0.0, 'mean_word_length': 3.005252790544977, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 29, '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': '1276009', 'n_tokens_mistral': 1992, 'n_tokens_neox': 1968, 'n_words': 386}