<commit_before>import React from 'react'

const NON_NUMERIC_CLASS = 'mdl-data-table__cell--non-numeric'

const Table = ({ headers, rows, className, indexed, indexColumnName }) => {
  return (
    <table className={`mdl-data-table mdl-js-data-table  mdl-shadow--2dp ${className}`}>
      <thead>
        <tr>
          {indexed && <th key='id' className={NON_NUMERIC_CLASS}>{indexColumnName}</th>}
          {headers.map((header) => (
            <th key={header.name} className={NON_NUMERIC_CLASS}>{header.name}</th>
          ))}
        </tr>
      </thead>
      <tbody>
        {rows.map((row, index) => (
          <tr key={row.id || index}>
            {indexed && <td key='id' className={NON_NUMERIC_CLASS}>{index + 1}</td>}
            {Object.keys(row).map((columnName, id) => {
              if (columnName === 'id') return
              return <td key={id} className={NON_NUMERIC_CLASS}>{row[columnName]}</td>
            })}
          </tr>
        ))}
      </tbody>
    </table>
  )
}<commit_msg>Make Table component more powerful<commit_after>/**
 * Currently not in use
 */
import React, { Component } from 'react'

const NON_NUMERIC_CLASS = 'mdl-data-table__cell--non-numeric'

class Table extends Component {
  constructor (props) {
    super(props)
    this.state = {
      hoveredIndex: null
    }
  }

  render () {
    return (
      <table className={`mdl-data-table mdl-js-data-table  mdl-shadow--2dp ${this.props.className}`}>
        <thead>
          <tr>
            {this.props.indexColumnName && <th key='id' className={NON_NUMERIC_CLASS}>{this.props.indexColumnName}</th>}
            {this.props.headers.map((header) => (
              <th key={header.name} className={NON_NUMERIC_CLASS}>{header.name}</th>
            ))}
          </tr>
        </thead>
        <tbody>
          {this.renderRow()}
        </tbody>
      </table>
    )
  }

  renderRow () {
    return this.props.rows.map((row, index) => {
      const _row = this.props.renderRow(row, this.state.hoveredIndex === index, index)
      return React.cloneElement(_row, {
        onMouseEnter: () => { this.setState({ hoveredIndex: index }) },
        onMouseLeave: () => { this.setState({ hoveredIndex: null }) }
      })
    })
  }
}
{'fraction_non_alphanumeric': 0.16980286738351255, 'fraction_numerical': 0.0013440860215053765, 'mean_word_length': 2.3328358208955224, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 41, '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': '7310510', 'n_tokens_mistral': 733, 'n_tokens_neox': 725, 'n_words': 126}