vuetifyjs / vuetify
1
import { VDataTable } from '../'
2 1
import VIcon from '../../VIcon'
3 1
import VSimpleCheckbox from '../../VCheckbox/VSimpleCheckbox'
4 1
import ripple from '../../../directives/ripple'
5

6
import Vue from 'vue'
7
import { PropValidator } from 'vue/types/options'
8 1
import mixins from '../../../util/mixins'
9
import { DataOptions, DataTableHeader } from 'vuetify/types'
10

11
type VDataTableInstance = InstanceType<typeof VDataTable>
12

13
interface options extends Vue {
14
  dataTable: VDataTableInstance
15
}
16

17 1
export default mixins<options>().extend({
18
  // https://github.com/vuejs/vue/issues/6872
19
  directives: {
20
    ripple,
21
  },
22

23
  props: {
24
    headers: {
25
      type: Array,
26 0
      default: () => ([]),
27
    } as PropValidator<DataTableHeader[]>,
28
    options: {
29
      type: Object,
30 1
      default: () => ({
31
        page: 1,
32
        itemsPerPage: 10,
33
        sortBy: [],
34
        sortDesc: [],
35
        groupBy: [],
36
        groupDesc: [],
37
        multiSort: false,
38
        mustSort: false,
39
      }),
40
    } as PropValidator<DataOptions>,
41
    sortIcon: {
42
      type: String,
43
      default: '$sort',
44
    },
45
    everyItem: Boolean,
46
    someItems: Boolean,
47
    showGroupBy: Boolean,
48
    singleSelect: Boolean,
49
    disableSort: Boolean,
50
  },
51

52
  methods: {
53 1
    genSelectAll () {
54 1
      const data = {
55
        props: {
56
          value: this.everyItem,
57 1
          indeterminate: !this.everyItem && this.someItems,
58
        },
59
        on: {
60 1
          input: (v: boolean) => this.$emit('toggle-select-all', v),
61
        },
62
      }
63

64 1
      if (this.$scopedSlots['data-table-select']) {
65 1
        return this.$scopedSlots['data-table-select']!(data)
66
      }
67

68 1
      return this.$createElement(VSimpleCheckbox, {
69
        staticClass: 'v-data-table__checkbox',
70
        ...data,
71
      })
72
    },
73 1
    genSortIcon () {
74 1
      return this.$createElement(VIcon, {
75
        staticClass: 'v-data-table-header__icon',
76
        props: {
77
          size: 18,
78
        },
79
      }, [this.sortIcon])
80
    },
81
  },
82
})

Read our documentation on viewing source code .

Loading