@@ -20,6 +20,7 @@ import {
20
20
} from '../../utils/date'
21
21
import { requestAF } from '../../utils/dom'
22
22
import { isArray, isFunction, isPlainObject, isString } from '../../utils/inspect'
23
+
import { isLocaleRTL } from '../../utils/locale'
23
24
import { toInteger } from '../../utils/number'
24
25
import { toString } from '../../utils/string'
25
26
import idMixin from '../../mixins/id'
@@ -34,37 +35,6 @@ const NAME = 'BCalendar'
34
35
// Key Codes
35
36
const { UP, DOWN, LEFT, RIGHT, PAGEUP, PAGEDOWN, HOME, END, ENTER, SPACE } = KeyCodes
36
37
37
-
// Languages that are RTL
38
-
const RTL_LANGS = [
39
-
'ar',
40
-
'az',
41
-
'ckb',
42
-
'fa',
43
-
'he',
44
-
'ks',
45
-
'lrc',
46
-
'mzn',
47
-
'ps',
48
-
'sd',
49
-
'te',
50
-
'ug',
51
-
'ur',
52
-
'yi'
53
-
].map(locale => locale.toLowerCase())
54
-
55
-
// --- Helper utilities ---
56
-
57
-
export const isLocaleRTL = locale => {
58
-
// Determines if the locale is RTL (only single locale supported)
59
-
const parts = toString(locale)
60
-
.toLowerCase()
61
-
.replace(/-u-.+/, '')
62
-
.split('-')
63
-
const locale1 = parts.slice(0, 2).join('-')
64
-
const locale2 = parts[0]
65
-
return arrayIncludes(RTL_LANGS, locale1) || arrayIncludes(RTL_LANGS, locale2)
66
-
}
67
-
68
38
// --- BCalendar component ---
69
39
70
40
// @vue/component
@@ -667,7 +637,6 @@ export const BCalendar = Vue.extend({
667
637
},
668
638
onClickDay(day) {
669
639
// Clicking on a date "button" to select it
670
-
// TODO: Change to lookup the `data-data` attribute
671
640
const selectedDate = this.selectedDate
672
641
const activeDate = this.activeDate
673
642
const clickedDate = parseYMD(day.ymd)
@@ -702,6 +671,12 @@ export const BCalendar = Vue.extend({
702
671
},
703
672
gotoNextYear() {
704
673
this.activeYMD = formatYMD(this.constrainDate(oneYearAhead(this.activeDate)))
674
+
},
675
+
onHeaderClick() {
676
+
if (!this.disabled) {
677
+
this.activeYMD = this.selectedYMD || formatYMD(this.getToday())
678
+
this.focus()
679
+
}
705
680
}
706
681
},
707
682
render(h) {
@@ -719,8 +694,9 @@ export const BCalendar = Vue.extend({
719
694
// Flag for making the `aria-live` regions live
720
695
const isLive = this.isLive
721
696
// Pre-compute some IDs
722
-
const idWidget = safeId()
723
-
const idValue = safeId('_calendar-value_')
697
+
// Thes should be computed props
698
+
const idValue = safeId()
699
+
const idWidget = safeId('_calendar-wrapper_')
724
700
const idNav = safeId('_calendar-nav_')
725
701
const idGrid = safeId('_calendar-grid_')
726
702
const idGridCaption = safeId('_calendar-grid-caption_')
@@ -737,13 +713,20 @@ export const BCalendar = Vue.extend({
737
713
id: idValue,
738
714
for: idGrid,
739
715
role: 'status',
716
+
tabindex: this.disabled ? null : '-1',
740
717
// Mainly for testing purposes, as we do not know
741
718
// the exact format `Intl` will format the date string
742
719
'data-selected': toString(selectedYMD),
743
720
// We wait until after mount to enable `aria-live`
744
721
// to prevent initial announcement on page render
745
722
'aria-live': isLive ? 'polite' : 'off',
746
723
'aria-atomic': isLive ? 'true' : null
724
+
},
725
+
on: {
726
+
// Transfer focus/click to focus grid
727
+
// and focus active date (or today if no selection)
728
+
click: this.onHeaderClick,
729
+
focus: this.onHeaderClick
747
730
}
748
731
},
749
732
this.selectedDate
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4