Skip to content

Commit 58342ff

Browse files
authored
Update form-timepicker.js
1 parent 9600681 commit 58342ff

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

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

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import identity from '../../utils/identity'
33
import { getComponentConfig } from '../../utils/config'
44
import dropdownMixin from '../../mixins/dropdown'
55
import idMixin from '../../mixins/id'
6+
import normalizeSlotMixin from '../../mixins/normalize-slot'
67
import { BButton } from '../button/button'
78
import { BTime } from '../time/time'
89
import { BIconClock, BIconClockFill } from '../../icons/icons'
@@ -182,7 +183,7 @@ export const BFormTimepicker = /*#__PURE__*/ Vue.extend({
182183
BHover: VBHover
183184
},
184185
// The mixins order determines the order of appearance in the props reference section
185-
mixins: [idMixin, propsMixin, dropdownMixin],
186+
mixins: [idMixin, normalizeSlotMixin, propsMixin, dropdownMixin],
186187
model: {
187188
prop: 'value',
188189
event: 'input'
@@ -310,6 +311,16 @@ export const BFormTimepicker = /*#__PURE__*/ Vue.extend({
310311
},
311312
handleHover(hovered) /* istanbul ignore next: until tests written */ {
312313
this.isHovered = hovered
314+
},
315+
// Render funtion helpers
316+
defaultButtonFn(scope) {
317+
return this.$createElement(
318+
scope.isHovered || scope.hasFocus ? BIconClockFill : BIconClock,
319+
{
320+
props: { scale: 1.25 },
321+
attrs: { 'aria-hidden': 'true' }
322+
}
323+
)
313324
}
314325
},
315326
render(h) {
@@ -328,12 +339,8 @@ export const BFormTimepicker = /*#__PURE__*/ Vue.extend({
328339
const idMenu = this.safeId('_dialog_')
329340
const idWrapper = this.safeId('_b-form-time_')
330341

331-
let $button = h('div', { attrs: { 'aria-hidden': 'true' } }, [
332-
isHovered || hasFocus
333-
? h(BIconClockFill, { props: { scale: 1.25 } })
334-
: h(BIconClock, { props: { scale: 1.25 } })
335-
])
336-
$button = h(
342+
const btnScope = { isHovered, hasFocus, state, opened: visible }
343+
const $button = h(
337344
'button',
338345
{
339346
ref: 'toggle',
@@ -356,7 +363,11 @@ export const BFormTimepicker = /*#__PURE__*/ Vue.extend({
356363
'!blur': this.setFocus
357364
}
358365
},
359-
[$button]
366+
[
367+
this.hasNormalizedSlot('button-content')
368+
? this.normalizeSlot('button-content', btnScope)
369+
: this.defaultButtonFn(btnScope)
370+
]
360371
)
361372

362373
// Label as a "fake" input

0 commit comments

Comments
 (0)