Skip to content

Commit dc27135

Browse files
committed
feat(select): update mdc-select as per MDCWeb 0.35.0
BREAKING CHANGE: bottomLine property has removed
1 parent 4ccbd9e commit dc27135

File tree

1 file changed

+64
-67
lines changed

1 file changed

+64
-67
lines changed

components/select/mdc-select.vue

Lines changed: 64 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,37 @@
11
<template>
2-
<div
3-
:class="rootClasses"
4-
:style="styles"
2+
<div
3+
:class="rootClasses"
4+
:style="styles"
55
class="mdc-select">
6-
<select
7-
ref="native_control"
8-
v-bind="$attrs"
9-
class="mdc-select__native-control"
6+
<select
7+
ref="native_control"
8+
v-bind="$attrs"
9+
class="mdc-select__native-control"
1010
v-on="listeners">
11-
<option
12-
v-if="!!label"
13-
class="mdc-option"
14-
value=""
15-
disabled
11+
<option
12+
v-if="!!label"
13+
class="mdc-option"
14+
value=""
15+
disabled
1616
selected/>
1717
<slot/>
1818
</select>
19-
<div
20-
ref="label"
21-
:class="labelClasses"
19+
<div
20+
ref="label"
21+
:class="labelClasses"
2222
class="mdc-floating-label">{{ label }}</div>
23-
<div
24-
v-if="bottomLine"
25-
ref="line"
26-
:class="lineClasses"
27-
:style="lineStyles"
28-
class="mdc-line-ripple"
29-
/>
23+
<div
24+
ref="line"
25+
:class="lineClasses"
26+
:style="lineStyles"
27+
class="mdc-line-ripple"/>
3028
</div>
3129
</template>
3230

3331
<script>
3432
import MDCSelectFoundation from '@material/select/foundation'
35-
import MDCFloatingLabelFoundation from '@material/floating-label/foundation'
3633
import MDCLineRippleFoundation from '@material/line-ripple/foundation'
34+
import MDCFloatingLabelFoundation from '@material/floating-label/foundation'
3735
import { RippleBase } from '../ripple'
3836
3937
export default {
@@ -47,8 +45,7 @@ export default {
4745
value: String,
4846
disabled: Boolean,
4947
label: String,
50-
box: Boolean,
51-
bottomLine: { type: Boolean, default: true }
48+
box: Boolean
5249
},
5350
data() {
5451
return {
@@ -80,44 +77,44 @@ export default {
8077
value: 'refreshIndex'
8178
},
8279
mounted() {
83-
if (this.label) {
84-
this.labelFoundation = new MDCFloatingLabelFoundation({
85-
addClass: className => this.$set(this.labelClasses, className, true),
86-
removeClass: className => this.$delete(this.labelClasses, className),
87-
getWidth: () => this.$refs.label.offsetWidth,
88-
registerInteractionHandler: (evtType, handler) => {
89-
this.$refs.label.addEventListener(evtType, handler)
90-
},
91-
deregisterInteractionHandler: (evtType, handler) => {
92-
this.$refs.label.removeEventListener(evtType, handler)
93-
}
94-
})
95-
this.labelFoundation.init()
96-
}
80+
this.labelFoundation = new MDCFloatingLabelFoundation({
81+
addClass: className => {
82+
this.$set(this.labelClasses, className, true)
83+
},
84+
removeClass: className => {
85+
this.$delete(this.labelClasses, className)
86+
},
87+
getWidth: () => this.$refs.label.offsetWidth,
88+
registerInteractionHandler: (evtType, handler) => {
89+
this.$refs.label.addEventListener(evtType, handler)
90+
},
91+
deregisterInteractionHandler: (evtType, handler) => {
92+
this.$refs.label.removeEventListener(evtType, handler)
93+
}
94+
})
95+
this.labelFoundation.init()
9796
98-
if (this.bottomLine) {
99-
this.lineFoundation = new MDCLineRippleFoundation({
100-
addClass: className => {
101-
this.$set(this.lineClasses, className, true)
102-
},
103-
removeClass: className => {
104-
this.$delete(this.lineClasses, className)
105-
},
106-
hasClass: className => {
107-
this.$refs.line.classList.contains(className)
108-
},
109-
setStyle: (name, value) => {
110-
this.$set(this.lineStyles, name, value)
111-
},
112-
registerEventHandler: (evtType, handler) => {
113-
this.$refs.line.addEventListener(evtType, handler)
114-
},
115-
deregisterEventHandler: (evtType, handler) => {
116-
this.$refs.line.removeEventListener(evtType, handler)
117-
}
118-
})
119-
this.lineFoundation.init()
120-
}
97+
this.lineRippleFoundation = new MDCLineRippleFoundation({
98+
addClass: className => {
99+
this.$set(this.lineClasses, className, true)
100+
},
101+
removeClass: className => {
102+
this.$delete(this.lineClasses, className)
103+
},
104+
hasClass: className => {
105+
this.$refs.line.classList.contains(className)
106+
},
107+
setStyle: (name, value) => {
108+
this.$set(this.lineStyles, name, value)
109+
},
110+
registerEventHandler: (evtType, handler) => {
111+
this.$refs.line.addEventListener(evtType, handler)
112+
},
113+
deregisterEventHandler: (evtType, handler) => {
114+
this.$refs.line.removeEventListener(evtType, handler)
115+
}
116+
})
117+
this.lineRippleFoundation.init()
121118
122119
this.foundation = new MDCSelectFoundation({
123120
addClass: className => this.$set(this.classes, className, true),
@@ -126,10 +123,10 @@ export default {
126123
this.labelFoundation.float(value)
127124
},
128125
activateBottomLine: () => {
129-
this.lineFoundation.activate()
126+
this.lineRippleFoundation.activate()
130127
},
131128
deactivateBottomLine: () => {
132-
this.lineFoundation.deactivate()
129+
this.lineRippleFoundation.deactivate()
133130
},
134131
registerInteractionHandler: (type, handler) =>
135132
this.$refs.native_control.addEventListener(type, handler),
@@ -170,9 +167,9 @@ export default {
170167
this.labelFoundation = null
171168
labelFoundation.destroy()
172169
173-
let lineFoundation = this.lineFoundation
174-
this.lineFoundation = null
175-
lineFoundation.destroy()
170+
let lineRippleFoundation = this.lineRippleFoundation
171+
this.lineRippleFoundation = null
172+
lineRippleFoundation.destroy()
176173
177174
this.ripple && this.ripple.destroy()
178175
},

0 commit comments

Comments
 (0)