File tree 3 files changed +44
-0
lines changed
3 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 6
6
:data-type =" col.type"
7
7
:data-index =" i"
8
8
@click =" handleSelect"
9
+ @keydown.enter =" handleSelect"
9
10
>
10
11
<li
11
12
v-for =" (item, j) in col.list"
12
13
:key =" item.value"
14
+ :ref =" `item-${i}-${j}`"
15
+ :tabindex =" isDisabledTime(item.value, col.type) ? '-1' : '0'"
13
16
:data-index =" j"
14
17
:class =" [`${prefixClass}-time-item`, getClasses(item.value, col.type)]"
18
+ @keydown.left.prevent =" handleArrowLeft(i, j)"
19
+ @keydown.right.prevent =" handleArrowRight(i, j)"
15
20
>
16
21
{{ item.text }}
17
22
</li >
@@ -82,6 +87,10 @@ export default {
82
87
type: Function ,
83
88
default : () => [],
84
89
},
90
+ isDisabledTime: {
91
+ type: Function ,
92
+ default : () => false ,
93
+ },
85
94
hourOptions: Array ,
86
95
minuteOptions: Array ,
87
96
secondOptions: Array ,
@@ -173,6 +182,24 @@ export default {
173
182
return { text, value };
174
183
});
175
184
},
185
+ handleArrowLeft (col , row ) {
186
+ if (col <= 0 ) {
187
+ return ;
188
+ }
189
+ const ref = this .$refs [` item-${ col - 1 } -${ row} ` ]? .[0 ];
190
+ if (ref) {
191
+ ref .focus ();
192
+ }
193
+ },
194
+ handleArrowRight (col , row ) {
195
+ if (col >= 2 ) {
196
+ return ;
197
+ }
198
+ const ref = this .$refs [` item-${ col + 1 } -${ row} ` ]? .[0 ];
199
+ if (ref) {
200
+ ref .focus ();
201
+ }
202
+ },
176
203
scrollToSelected (duration ) {
177
204
const elements = this .$el .querySelectorAll (' .active' );
178
205
for (let i = 0 ; i < elements .length ; i++ ) {
Original file line number Diff line number Diff line change 3
3
<div
4
4
v-for =" item in list"
5
5
:key =" item.value"
6
+ :tabindex =" isDisabled(item.value) ? '-1' : '0'"
6
7
:class =" [`${prefixClass}-time-option`, getClasses(item.value)]"
7
8
@click =" handleSelect(item.value)"
9
+ @keydown.enter =" handleSelect(item.value)"
8
10
>
9
11
{{ item.text }}
10
12
</div >
@@ -63,6 +65,10 @@ export default {
63
65
type: Function ,
64
66
default : () => [],
65
67
},
68
+ isDisabled: {
69
+ type: Function ,
70
+ default : () => false ,
71
+ },
66
72
},
67
73
computed: {
68
74
list () {
Original file line number Diff line number Diff line change 2
2
<div :class =" `${prefixClass}-time`" >
3
3
<div v-if =" showTimeHeader" :class =" `${prefixClass}-time-header`" >
4
4
<button
5
+ ref =" dateButton"
5
6
type =" button"
6
7
:class =" `${prefixClass}-btn ${prefixClass}-btn-text ${prefixClass}-time-header-title`"
7
8
@click =" handleClickTitle"
14
15
v-if =" timePickerOptions"
15
16
:date =" innerValue"
16
17
:get-classes =" getClasses"
18
+ :is-disabled =" isDisabled"
17
19
:options =" timePickerOptions"
18
20
:format =" innerForamt"
19
21
@select =" handleSelect"
20
22
></list-options >
21
23
<list-columns
22
24
v-else
23
25
:date =" innerValue"
26
+ :is-disabled-time =" isDisabled"
24
27
:get-classes =" getClasses"
25
28
:hour-options =" hourOptions"
26
29
:minute-options =" minuteOptions"
@@ -157,6 +160,14 @@ export default {
157
160
},
158
161
},
159
162
},
163
+ mounted () {
164
+ const ref = this .$refs .dateButton ;
165
+ if (ref) {
166
+ setTimeout (() => {
167
+ ref .focus ();
168
+ }, 300 );
169
+ }
170
+ },
160
171
methods: {
161
172
formatDate (date , fmt ) {
162
173
return format (date, fmt, { locale: this .getLocale ().formatLocale });
You can’t perform that action at this time.
0 commit comments