Skip to content

Commit b8c1a90

Browse files
authored
Update form-timepicker.js
1 parent 9c448b0 commit b8c1a90

File tree

1 file changed

+38
-30
lines changed

1 file changed

+38
-30
lines changed

src/components/form-timepicker/form-timepicker.js

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -204,31 +204,34 @@ export const BFormTimepicker = /*#__PURE__*/ Vue.extend({
204204
computed: {
205205
timeProps() {
206206
// Props we pass to BTime
207+
// Use self for better minification, as `this` won't
208+
// minimize and we reference it a lot below
209+
const self = this
207210
// TODO: Make the ID's computed props
208-
const idLabel = this.safeId('_value_')
209-
const idWrapper = this.safeId('_b-form-time_')
211+
const idLabel = self.safeId('_value_')
212+
const idWrapper = self.safeId('_b-form-time_')
210213
return {
211-
hidden: !this.visible,
214+
hidden: !self.visible,
212215
ariaControls: [idLabel, idWrapper].filter(identity).join(' ') || null,
213-
value: this.localHMS,
214-
readonly: this.readonly,
215-
disabled: this.disabled,
216-
locale: this.locale,
217-
hour12: this.hour12,
218-
hideHeader: this.hideHeader,
219-
showSeconds: this.showSeconds,
220-
secondsStep: this.secondsStep,
221-
minutesStep: this.minutesStep,
222-
labelNoTime: this.labelNoTime,
223-
labelSelected: this.labelSelected,
224-
labelHours: this.labelHours,
225-
labelMinutes: this.labelMinutes,
226-
labelSeconds: this.labelSeconds,
227-
labelAmpm: this.labelAmpm,
228-
labelAm: this.labelAm,
229-
labelPm: this.labelPm,
230-
labelIncrement: this.labelIncrement,
231-
labelDecrement: this.labelDecrement,
216+
value: self.localHMS,
217+
readonly: self.readonly,
218+
disabled: self.disabled,
219+
locale: self.locale,
220+
hour12: self.hour12,
221+
hideHeader: self.hideHeader,
222+
showSeconds: self.showSeconds,
223+
secondsStep: self.secondsStep,
224+
minutesStep: self.minutesStep,
225+
labelNoTime: self.labelNoTime,
226+
labelSelected: self.labelSelected,
227+
labelHours: self.labelHours,
228+
labelMinutes: self.labelMinutes,
229+
labelSeconds: self.labelSeconds,
230+
labelAmpm: self.labelAmpm,
231+
labelAm: self.labelAm,
232+
labelPm: self.labelPm,
233+
labelIncrement: self.labelIncrement,
234+
labelDecrement: self.labelDecrement
232235
}
233236
}
234237
},
@@ -299,16 +302,21 @@ export const BFormTimepicker = /*#__PURE__*/ Vue.extend({
299302
render(h) {
300303
const size = this.size
301304
const state = this.state
305+
const visible = this.visible
302306
const localHMS = this.localHMS
303307
const disabled = this.disabled
304308
const readonly = this.readonly
309+
const required = this.required
310+
const hasFocus = this.hasFocus
311+
const isHovered = this.isHovered
312+
// These should be computed props?
305313
const idButton = this.safeId()
306314
const idLabel = this.safeId('_value_')
307315
const idMenu = this.safeId('_dialog_')
308316
const idWrapper = this.safeId('_b-form-time_')
309317

310318
let $button = h('div', { attrs: { 'aria-hidden': 'true' } }, [
311-
this.isHovered || this.hasFocus
319+
isHovered || hasFocus
312320
? h(BIconClockFill, { props: { scale: 1.25 } })
313321
: h(BIconClock, { props: { scale: 1.25 } })
314322
])
@@ -323,9 +331,9 @@ export const BFormTimepicker = /*#__PURE__*/ Vue.extend({
323331
type: 'button',
324332
disabled: disabled,
325333
'aria-haspopup': 'dialog',
326-
'aria-expanded': this.visible ? 'true' : 'false',
334+
'aria-expanded': visible ? 'true' : 'false',
327335
'aria-invalid': state === false ? 'true' : null,
328-
'aria-required': this.required ? 'true' : null
336+
'aria-required': required ? 'true' : null
329337
},
330338
on: {
331339
mousedown: this.onMousedown,
@@ -357,7 +365,7 @@ export const BFormTimepicker = /*#__PURE__*/ Vue.extend({
357365
dir: this.isRTL ? 'rtl' : 'ltr',
358366
lang: this.localLocale || null,
359367
'aria-invalid': state === false ? 'true' : null,
360-
'aria-required': this.required ? 'true' : null
368+
'aria-required': required ? 'true' : null
361369
},
362370
on: {
363371
// Disable bubbling of the click event to
@@ -369,7 +377,7 @@ export const BFormTimepicker = /*#__PURE__*/ Vue.extend({
369377
},
370378
[
371379
// Add the formatted value or placeholder
372-
localHMS ? this.formattedValue : this.placeholder || this.labelNoTime,
380+
localHMS ? this.formattedValue : this.placeholder || this.labelNoTime || '\u00A0',
373381
// Add an sr-only 'selected date' label if a date is selected
374382
localHMS ? h('span', { staticClass: 'sr-only' }, ` (${this.labelSelected}) `) : h()
375383
]
@@ -416,7 +424,7 @@ export const BFormTimepicker = /*#__PURE__*/ Vue.extend({
416424
h(
417425
BButton,
418426
{
419-
props: { size: 'sm', disabled: this.disabled, variant: this.closeButtonVariant },
427+
props: { size: 'sm', disabled: disabled, variant: this.closeButtonVariant },
420428
attrs: { 'aria-label': closeLabel || null },
421429
on: { click: this.onCloseButton }
422430
},
@@ -497,8 +505,8 @@ export const BFormTimepicker = /*#__PURE__*/ Vue.extend({
497505
class: [
498506
this.directionClass,
499507
{
500-
show: this.visible,
501-
focus: this.hasFocus,
508+
show: visible,
509+
focus: hasFocus,
502510
[`form-control-${size}`]: !!size,
503511
'is-invalid': state === false,
504512
'is-valid': state === true

0 commit comments

Comments
 (0)