import { defineComponent, provide, ref } from 'vue' import dayjs from 'dayjs' import customParseFormat from 'dayjs/plugin/customParseFormat.js' import { DEFAULT_FORMATS_TIME } from './constants' import Picker from './common/picker.vue' import TimePickPanel from './time-picker-com/panel-time-pick.vue' import TimeRangePanel from './time-picker-com/panel-time-range.vue' import { timePickerDefaultProps } from './common/props' dayjs.extend(customParseFormat) export default defineComponent({ name: 'ElTimePicker', install: null, props: { ...timePickerDefaultProps, isRange: { type: Boolean, default: false, }, }, emits: ['update:modelValue'], setup(props, ctx) { const commonPicker = ref>() const [type, Panel] = props.isRange ? ['timerange', TimeRangePanel] : ['time', TimePickPanel] const modelUpdater = (value: any) => ctx.emit('update:modelValue', value) provide('ElPopperOptions', props.popperOptions) ctx.expose({ /** * @description focus on the input element */ focus: (e: FocusEvent | undefined) => { commonPicker.value?.handleFocusInput(e) }, /** * @description blur from the input element */ blur: (e: FocusEvent | undefined) => { commonPicker.value?.handleBlurInput(e) }, }) return () => { const format = props.format ?? DEFAULT_FORMATS_TIME return ( {{ default: (props: any) => , }} ) } }, })