time-picker.mjs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { defineComponent, ref, provide, createVNode, mergeProps } from 'vue';
  2. import dayjs from 'dayjs';
  3. import customParseFormat from 'dayjs/plugin/customParseFormat.js';
  4. import { PICKER_POPPER_OPTIONS_INJECTION_KEY, DEFAULT_FORMATS_TIME } from './constants.mjs';
  5. import CommonPicker from './common/picker.mjs';
  6. import TimePickPanel from './time-picker-com/panel-time-pick.mjs';
  7. import TimeRangePanel from './time-picker-com/panel-time-range.mjs';
  8. import { timePickerDefaultProps } from './common/props.mjs';
  9. import { UPDATE_MODEL_EVENT } from '../../../constants/event.mjs';
  10. dayjs.extend(customParseFormat);
  11. var TimePicker = defineComponent({
  12. name: "ElTimePicker",
  13. install: null,
  14. props: {
  15. ...timePickerDefaultProps,
  16. isRange: Boolean
  17. },
  18. emits: [UPDATE_MODEL_EVENT],
  19. setup(props, ctx) {
  20. const commonPicker = ref();
  21. const [type, Panel] = props.isRange ? ["timerange", TimeRangePanel] : ["time", TimePickPanel];
  22. const modelUpdater = (value) => ctx.emit(UPDATE_MODEL_EVENT, value);
  23. provide(PICKER_POPPER_OPTIONS_INJECTION_KEY, props.popperOptions);
  24. ctx.expose({
  25. focus: () => {
  26. var _a;
  27. (_a = commonPicker.value) == null ? void 0 : _a.focus();
  28. },
  29. blur: () => {
  30. var _a;
  31. (_a = commonPicker.value) == null ? void 0 : _a.blur();
  32. },
  33. handleOpen: () => {
  34. var _a;
  35. (_a = commonPicker.value) == null ? void 0 : _a.handleOpen();
  36. },
  37. handleClose: () => {
  38. var _a;
  39. (_a = commonPicker.value) == null ? void 0 : _a.handleClose();
  40. }
  41. });
  42. return () => {
  43. var _a;
  44. const format = (_a = props.format) != null ? _a : DEFAULT_FORMATS_TIME;
  45. return createVNode(CommonPicker, mergeProps(props, {
  46. "ref": commonPicker,
  47. "type": type,
  48. "format": format,
  49. "onUpdate:modelValue": modelUpdater
  50. }), {
  51. default: (props2) => createVNode(Panel, props2, null)
  52. });
  53. };
  54. }
  55. });
  56. export { TimePicker as default };
  57. //# sourceMappingURL=time-picker.mjs.map