<commit_before><template lang="pug">
table
  thead(v-if="!onlybody")
    tr(v-for="column in columnsRows")
      th(
        v-for="item in column.columns"
        :style="getTHCellStyle(item)"
        :colspan="item.colspan"
        :rowspan="item.rowspan"
        :class="getColumnClassName(item)"
      )
        span.c-table__check(v-if="item.type === 'selection'")
          c-checkbox(
            v-model="allSelect"
            :indeterminate="checkIndeterminate"
            @change="onSelectAllChange"
          )
        slot(:name="item.key + '-base-th'")
          span {{item.title}}
        span.c-table__sort(v-if="item.sorter")
          .c-sort-asc(
            :class="{'sorted': checkSorted(item.key, 'asc')}"
            @click="onSorted(item.key, 'asc')"
          )
            i.sort-asc
          .c-sort-desc(
            :class="{'sorted': checkSorted(item.key, 'desc')}"
            @click="onSorted(item.key, 'desc')"
          )
            i.sort-desc
  tbody(v-if="!onlyhead")
    tr(
      v-if="dataList.length == 0"
    )
      td.c-table__noresult(:colspan="columns.length") {{noresultMsg}}
    tr(
      v-for="dataItem,index in dataList"
      @mouseenter="setCurrentItem(dataItem, index)"
      @mouseleave="resetCurrentItem"
      :class="getRowClassName(item, index)"
      v-else
    )
      td(
        v-for="columnsItem in allColumns"
        :style="getCellStyle(columnsItem)"
        :class="getColumnClassName(columnsItem)"
      )
        slot(
          :name="columnsItem.key + '-base-td'"
          :item="dataItem"
        )
          span.c-table__check(v-if="columnsItem.type === 'selection'")
            c-checkbox(
              v-model="!dataItem._disabled && dataItem._checked"
              :disabled="dataItem._disabled"
              @change="onSelectChange"
            )
          div(
            v-if="columnsItem.render"
            v-html="columnsItem.render(index, dataItem[columnsItem.key], dataItem)"
          )
          span(v-else) {{dataItem[columnsItem.key]}}
</template>

<script>
import './index.css'
import _ from 'lodash'

export default {
  name: 'c-basetable',
  props: {
    columns: Array,
    datasource: Array,
    allChecked: Boolean,
    indeterminate: Boolean,
    height: [String, Number],
    sortkey: String,
    sortorder: String,
    rowClassName: [String, Function],
    hoverRowIndex: [Number, String],
    onlybody: [String, Boolean],
    onlyhead: [String, Boolean],
    noresultMsg: String
  },

  data () {
    return {
      currentItem: {},
      columnsRows: [],
      allSelect: false,
      checkIndeterminate: false
    }
  },

  computed: {
    dataList () {
      return this.datasource
    },
    allColumns () {
      const columns = _.cloneDeep(this.columns)
      return this.getAllColumns(columns)
    }
  },

  created () {
    this.allSelect = this.allChecked
    this.checkIndeterminate = this.indeterminate
  },

  mounted () {
    this.getTHWidth(this.columns)
    const maxlevel = this.findMaxLevel(this.columns)
    this.columnsRows = this.getLevelColumns(this.columns, maxlevel)<commit_msg>fix: avoid importing lodash entirely<commit_after><template lang="pug">
table
  thead(v-if="!onlybody")
    tr(v-for="column in columnsRows")
      th(
        v-for="item in column.columns"
        :style="getTHCellStyle(item)"
        :colspan="item.colspan"
        :rowspan="item.rowspan"
        :class="getColumnClassName(item)"
      )
        span.c-table__check(v-if="item.type === 'selection'")
          c-checkbox(
            v-model="allSelect"
            :indeterminate="checkIndeterminate"
            @change="onSelectAllChange"
          )
        slot(:name="item.key + '-base-th'")
          span {{item.title}}
        span.c-table__sort(v-if="item.sorter")
          .c-sort-asc(
            :class="{'sorted': checkSorted(item.key, 'asc')}"
            @click="onSorted(item.key, 'asc')"
          )
            i.sort-asc
          .c-sort-desc(
            :class="{'sorted': checkSorted(item.key, 'desc')}"
            @click="onSorted(item.key, 'desc')"
          )
            i.sort-desc
  tbody(v-if="!onlyhead")
    tr(
      v-if="dataList.length == 0"
    )
      td.c-table__noresult(:colspan="columns.length") {{noresultMsg}}
    tr(
      v-for="dataItem,index in dataList"
      @mouseenter="setCurrentItem(dataItem, index)"
      @mouseleave="resetCurrentItem"
      :class="getRowClassName(item, index)"
      v-else
    )
      td(
        v-for="columnsItem in allColumns"
        :style="getCellStyle(columnsItem)"
        :class="getColumnClassName(columnsItem)"
      )
        slot(
          :name="columnsItem.key + '-base-td'"
          :item="dataItem"
        )
          span.c-table__check(v-if="columnsItem.type === 'selection'")
            c-checkbox(
              v-model="!dataItem._disabled && dataItem._checked"
              :disabled="dataItem._disabled"
              @change="onSelectChange"
            )
          div(
            v-if="columnsItem.render"
            v-html="columnsItem.render(index, dataItem[columnsItem.key], dataItem)"
          )
          span(v-else) {{dataItem[columnsItem.key]}}
</template>

<script>
import './index.css'
import cloneDeep from 'lodash/cloneDeep'

export default {
  name: 'c-basetable',
  props: {
    columns: Array,
    datasource: Array,
    allChecked: Boolean,
    indeterminate: Boolean,
    height: [String, Number],
    sortkey: String,
    sortorder: String,
    rowClassName: [String, Function],
    hoverRowIndex: [Number, String],
    onlybody: [String, Boolean],
    onlyhead: [String, Boolean],
    noresultMsg: String
  },

  data () {
    return {
      currentItem: {},
      columnsRows: [],
      allSelect: false,
      checkIndeterminate: false
    }
  },

  computed: {
    dataList () {
      return this.datasource
    },
    allColumns () {
      const columns = cloneDeep(this.columns)
      return this.getAllColumns(columns)
    }
  },

  created () {
    this.allSelect = this.allChecked
    this.checkIndeterminate = this.indeterminate
  },

  mounted () {
    this.getTHWidth(this.columns)
    const maxlevel = this.findMaxLevel(this.columns)
    this.columnsRows = this.getLevelColumns(this.columns, maxlevel)
{'fraction_non_alphanumeric': 0.14445331205107742, 'fraction_numerical': 0.0003192338387869114, 'mean_word_length': 2.255064935064935, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2538263', 'n_tokens_mistral': 1995, 'n_tokens_neox': 1970, 'n_words': 308}