vuetifyjs / vuetify
1
// Types
2 1
import Vue, { VNode, PropType } from 'vue'
3
import { DataTableHeader } from 'vuetify/types'
4

5
// Utils
6 1
import { getObjectValueByPath } from '../../util/helpers'
7

8 1
export default Vue.extend({
9
  name: 'row',
10

11
  functional: true,
12

13
  props: {
14
    headers: Array as PropType<DataTableHeader[]>,
15
    item: Object,
16
    rtl: Boolean,
17
  },
18

19 1
  render (h, { props, slots, data }): VNode {
20 1
    const computedSlots = slots()
21

22 1
    const columns: VNode[] = props.headers.map((header: DataTableHeader) => {
23 1
      const children = []
24 1
      const value = getObjectValueByPath(props.item, header.value)
25

26 1
      const slotName = header.value
27 1
      const scopedSlot = data.scopedSlots && data.scopedSlots[slotName]
28 1
      const regularSlot = computedSlots[slotName]
29

30 1
      if (scopedSlot) {
31 0
        children.push(scopedSlot({ item: props.item, header, value }))
32 1
      } else if (regularSlot) {
33 0
        children.push(regularSlot)
34
      } else {
35 1
        children.push(value == null ? value : String(value))
36
      }
37

38 1
      const textAlign = `text-${header.align || 'start'}`
39

40 1
      return h('td', {
41
        class: {
42
          [textAlign]: true,
43
          'v-data-table__divider': header.divider,
44
        },
45
      }, children)
46
    })
47

48 1
    return h('tr', data, columns)
49
  },
50
})

Read our documentation on viewing source code .

Loading