<commit_before>'use strict'
import React from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'

const ButtonGroup = ({
  match,
  buttons,
  handle,
  vertical,
  name,
}) => {
  let buttonList = buttons.map(function (value, key) {
    const activeColor = 'btn-' + activeColor
    let cn = classnames('btn', 'btn-default')
    if (match !== null && match !== undefined) {
      if (match.constructor === Array && (match.indexOf(value.value) !== -1)) {
        cn = classnames('btn', 'active', activeColor)
      } else if (match == value.value) {
        cn = classnames('btn', 'active', activeColor)
      }
    }

    return (
      <button
        type="button"
        key={key}
        className={cn}
        value={value.value}
        onClick={handle.bind(null, value.value)}>
        {value.label}
      </button>
    )
  }.bind(this))

  const buttonClass = vertical === true
    ? 'btn-group-vertical'
    : 'btn-group'

  let hidden
  if (match && match.constructor === Array) {
    hidden = match.map(function (value, key) {
      let name = name + '[]'
      return <input type="hidden" name={name} value={value} key={key}/>
    }.bind(this))
  } else {
    hidden = <input type="hidden" name={name} value={match}/>
  }

  return (
    <div className={buttonClass} role="group">
      {buttonList}
      {hidden}
    </div>
  )
}

ButtonGroup.propTypes = {
  buttons: PropTypes.array.isRequired,
  handle: PropTypes.func.isRequired,
  match: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array,]),
  vertical: PropTypes.bool,
  name: PropTypes.string
}

ButtonGroup.defaultProp = {
  match: null,
  name: null
}

export default ButtonGroup<commit_msg>Fixed bugs that came up changing ButtonGroup function<commit_after>'use strict'
import React from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'

const ButtonGroup = ({
  match,
  buttons,
  handle,
  vertical,
  name,
  activeColor
}) => {
  let buttonList = buttons.map(function (value, key) {
    const buttonColor = 'btn-' + activeColor
    let cn = classnames('btn', 'btn-default')
    if (match !== null && match !== undefined) {
      if (match.constructor === Array && (match.indexOf(value.value) !== -1)) {
        cn = classnames('btn', 'active', buttonColor)
      } else if (match == value.value) {
        cn = classnames('btn', 'active', buttonColor)
      }
    }
    return (
      <button
        type="button"
        key={key}
        className={cn}
        value={value.value}
        onClick={handle.bind(null, value.value)}>
        {value.label}
      </button>
    )
  }.bind(this))

  const buttonClass = vertical === true
    ? 'btn-group-vertical'
    : 'btn-group'

  let hidden
  if (match && match.constructor === Array) {
    hidden = match.map(function (value, key) {
      let name = name + '[]'
      return <input type="hidden" name={name} value={value} key={key}/>
    }.bind(this))
  } else {
    hidden = <input type="hidden" name={name} value={match}/>
  }

  return (
    <div className={buttonClass} role="group">
      {buttonList}
      {hidden}
    </div>
  )
}

ButtonGroup.propTypes = {
  buttons: PropTypes.array.isRequired,
  handle: PropTypes.func.isRequired,
  activeColor: PropTypes.string,
  match: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
  vertical: PropTypes.bool,
  name: PropTypes.string
}

ButtonGroup.defaultProps = {
  activeColor: 'default',
  match: null,
  name: null
}

export default ButtonGroup
{'fraction_non_alphanumeric': 0.1513269339356296, 'fraction_numerical': 0.000564652738565782, 'mean_word_length': 2.9943630214205186, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '2625074', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1111, 'n_words': 265}