forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStepHeader.js
More file actions
187 lines (153 loc) · 5.04 KB
/
StepHeader.js
File metadata and controls
187 lines (153 loc) · 5.04 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
import Vue from 'vue'
import QIcon from '../icon/QIcon.js'
import Ripple from '../../directives/Ripple.js'
import AttrsMixin from '../../mixins/attrs.js'
import cache from '../../utils/cache.js'
export default Vue.extend({
name: 'StepHeader',
mixins: [ AttrsMixin ],
directives: {
Ripple
},
props: {
stepper: {},
step: {}
},
computed: {
isActive () {
return this.stepper.value === this.step.name
},
isDisable () {
const opt = this.step.disable
return opt === true || opt === ''
},
isError () {
const opt = this.step.error
return opt === true || opt === ''
},
isDone () {
const opt = this.step.done
return this.isDisable === false && (opt === true || opt === '')
},
headerNav () {
const
opt = this.step.headerNav,
nav = opt === true || opt === '' || opt === void 0
return this.isDisable === false &&
this.stepper.headerNav &&
nav
},
hasPrefix () {
return this.step.prefix &&
(this.isActive === false || this.stepper.activeIcon === 'none') &&
(this.isError === false || this.stepper.errorIcon === 'none') &&
(this.isDone === false || this.stepper.doneIcon === 'none')
},
icon () {
const defaultIcon = this.step.icon || this.stepper.inactiveIcon
if (this.isActive === true) {
const icon = this.step.activeIcon || this.stepper.activeIcon
return icon === 'none'
? defaultIcon
: icon || this.$q.iconSet.stepper.active
}
if (this.isError === true) {
const icon = this.step.errorIcon || this.stepper.errorIcon
return icon === 'none'
? defaultIcon
: icon || this.$q.iconSet.stepper.error
}
if (this.isDisable === false && this.isDone === true) {
const icon = this.step.doneIcon || this.stepper.doneIcon
return icon === 'none'
? defaultIcon
: icon || this.$q.iconSet.stepper.done
}
return defaultIcon
},
color () {
const errorColor = this.isError === true
? this.step.errorColor || this.stepper.errorColor
: void 0
if (this.isActive === true) {
const color = this.step.activeColor || this.stepper.activeColor || this.step.color
return color !== void 0
? color
: errorColor
}
if (errorColor !== void 0) {
return errorColor
}
if (this.isDisable === false && this.isDone === true) {
return this.step.doneColor || this.stepper.doneColor || this.step.color || this.stepper.inactiveColor
}
return this.step.color || this.stepper.inactiveColor
},
classes () {
return `q-stepper__tab col-grow flex items-center no-wrap relative-position` +
(this.color !== void 0 ? ` text-${this.color}` : '') +
(this.isError === true
? ' q-stepper__tab--error q-stepper__tab--error-with-' + (this.hasPrefix === true ? 'prefix' : 'icon')
: '') +
(this.isActive === true ? ' q-stepper__tab--active' : '') +
(this.isDone === true ? ' q-stepper__tab--done' : '') +
(this.headerNav === true ? ' q-stepper__tab--navigation q-focusable q-hoverable' : '') +
(this.isDisable === true ? ' q-stepper__tab--disabled' : '')
}
},
methods: {
activate () {
this.$refs.blurTarget !== void 0 && this.$refs.blurTarget.focus()
this.isActive === false && this.stepper.goTo(this.step.name)
},
keyup (e) {
if (e.keyCode === 13 && this.isActive === false) {
this.stepper.goTo(this.step.name)
}
}
},
render (h) {
const data = { class: this.classes }
if (this.stepper.headerNav === true) {
data.directives = [{
name: 'ripple',
value: this.headerNav
}]
}
this.headerNav === true && Object.assign(data, {
on: cache(this, 'headnavon', {
click: this.activate,
keyup: this.keyup
}),
attrs: this.isDisable === true
? { tabindex: -1, 'aria-disabled': 'true' }
: { tabindex: this.qAttrs.tabindex || 0 }
})
const child = [
h('div', { staticClass: 'q-focus-helper', attrs: { tabindex: -1 }, ref: 'blurTarget' }),
h('div', { staticClass: 'q-stepper__dot row flex-center q-stepper__line relative-position' }, [
h('span', { staticClass: 'row flex-center' }, [
this.hasPrefix === true
? this.step.prefix
: h(QIcon, { props: { name: this.icon } })
])
])
]
if (this.step.title !== void 0 && this.step.title !== null) {
const content = [
h('div', { staticClass: 'q-stepper__title' }, [ this.step.title ])
]
if (this.step.caption !== void 0 && this.step.caption !== null) {
content.push(
h('div', { staticClass: 'q-stepper__caption' }, [ this.step.caption ])
)
}
child.push(
h('div', {
staticClass: 'q-stepper__label q-stepper__line relative-position'
}, content)
)
}
return h('div', data, child)
}
})