forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQTh.js
More file actions
73 lines (59 loc) · 1.44 KB
/
QTh.js
File metadata and controls
73 lines (59 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import Vue from 'vue'
import QIcon from '../icon/QIcon.js'
import ListenersMixin from '../../mixins/listeners.js'
import { slot, uniqueSlot } from '../../utils/slot.js'
export default Vue.extend({
name: 'QTh',
mixins: [ ListenersMixin ],
props: {
props: Object,
autoWidth: Boolean
},
render (h) {
const on = { ...this.qListeners }
if (this.props === void 0) {
return h('th', {
on,
class: this.autoWidth === true ? 'q-table--col-auto-width' : null
}, slot(this, 'default'))
}
let col, child
const name = this.$vnode.key
if (name) {
col = this.props.colsMap[name]
if (col === void 0) { return }
}
else {
col = this.props.col
}
if (col.sortable === true) {
const action = col.align === 'right'
? 'unshift'
: 'push'
child = uniqueSlot(this, 'default', [])
child[action](
h(QIcon, {
props: { name: this.$q.iconSet.table.arrowUp },
staticClass: col.__iconClass
})
)
}
else {
child = slot(this, 'default')
}
const evt = col.sortable === true
? {
click: evt => {
this.props.sort(col)
this.$emit('click', evt)
}
}
: {}
return h('th', {
on: { ...on, ...evt },
style: col.headerStyle,
class: col.__thClass +
(this.autoWidth === true ? ' q-table--col-auto-width' : '')
}, child)
}
})