1
1
<template >
2
- <div
3
- :class =" rootClasses"
4
- :style =" styles"
2
+ <div
3
+ :class =" rootClasses"
4
+ :style =" styles"
5
5
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"
10
10
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
16
16
selected />
17
17
<slot />
18
18
</select >
19
- <div
20
- ref =" label"
21
- :class =" labelClasses"
19
+ <div
20
+ ref =" label"
21
+ :class =" labelClasses"
22
22
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" />
30
28
</div >
31
29
</template >
32
30
33
31
<script >
34
32
import MDCSelectFoundation from ' @material/select/foundation'
35
- import MDCFloatingLabelFoundation from ' @material/floating-label/foundation'
36
33
import MDCLineRippleFoundation from ' @material/line-ripple/foundation'
34
+ import MDCFloatingLabelFoundation from ' @material/floating-label/foundation'
37
35
import { RippleBase } from ' ../ripple'
38
36
39
37
export default {
@@ -47,8 +45,7 @@ export default {
47
45
value: String ,
48
46
disabled: Boolean ,
49
47
label: String ,
50
- box: Boolean ,
51
- bottomLine: { type: Boolean , default: true }
48
+ box: Boolean
52
49
},
53
50
data () {
54
51
return {
@@ -80,44 +77,44 @@ export default {
80
77
value: ' refreshIndex'
81
78
},
82
79
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 ()
97
96
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 ()
121
118
122
119
this .foundation = new MDCSelectFoundation ({
123
120
addClass : className => this .$set (this .classes , className, true ),
@@ -126,10 +123,10 @@ export default {
126
123
this .labelFoundation .float (value)
127
124
},
128
125
activateBottomLine : () => {
129
- this .lineFoundation .activate ()
126
+ this .lineRippleFoundation .activate ()
130
127
},
131
128
deactivateBottomLine : () => {
132
- this .lineFoundation .deactivate ()
129
+ this .lineRippleFoundation .deactivate ()
133
130
},
134
131
registerInteractionHandler : (type , handler ) =>
135
132
this .$refs .native_control .addEventListener (type, handler),
@@ -170,9 +167,9 @@ export default {
170
167
this .labelFoundation = null
171
168
labelFoundation .destroy ()
172
169
173
- let lineFoundation = this .lineFoundation
174
- this .lineFoundation = null
175
- lineFoundation .destroy ()
170
+ let lineRippleFoundation = this .lineRippleFoundation
171
+ this .lineRippleFoundation = null
172
+ lineRippleFoundation .destroy ()
176
173
177
174
this .ripple && this .ripple .destroy ()
178
175
},
0 commit comments