518c3ce44c6d4f2f143e3b30152f94f80ab08c5863d9ed81135bdbe1d621e4304a8b92bd3c84c984cae0cde178748a25887f51f9ec2979d9e7d194f724f669 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import { defineComponent, computed, provide, reactive, toRef, ref, createVNode, mergeProps, isVNode } from 'vue';
  2. import '../../time-picker/index.mjs';
  3. import { ElDatePickerPanel } from '../../date-picker-panel/index.mjs';
  4. import { datePickerProps } from './props.mjs';
  5. import { ROOT_PICKER_IS_DEFAULT_FORMAT_INJECTION_KEY } from '../../date-picker-panel/src/constants.mjs';
  6. import { PICKER_POPPER_OPTIONS_INJECTION_KEY, DEFAULT_FORMATS_DATEPICKER, DEFAULT_FORMATS_DATE } from '../../time-picker/src/constants.mjs';
  7. import CommonPicker from '../../time-picker/src/common/picker.mjs';
  8. import { UPDATE_MODEL_EVENT } from '../../../constants/event.mjs';
  9. function _isSlot(s) {
  10. return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
  11. }
  12. var DatePicker = defineComponent({
  13. name: "ElDatePicker",
  14. install: null,
  15. props: datePickerProps,
  16. emits: [UPDATE_MODEL_EVENT],
  17. setup(props, {
  18. expose,
  19. emit,
  20. slots
  21. }) {
  22. const isDefaultFormat = computed(() => {
  23. return !props.format;
  24. });
  25. provide(ROOT_PICKER_IS_DEFAULT_FORMAT_INJECTION_KEY, isDefaultFormat);
  26. provide(PICKER_POPPER_OPTIONS_INJECTION_KEY, reactive(toRef(props, "popperOptions")));
  27. const commonPicker = ref();
  28. const refProps = {
  29. focus: () => {
  30. var _a;
  31. (_a = commonPicker.value) == null ? void 0 : _a.focus();
  32. },
  33. blur: () => {
  34. var _a;
  35. (_a = commonPicker.value) == null ? void 0 : _a.blur();
  36. },
  37. handleOpen: () => {
  38. var _a;
  39. (_a = commonPicker.value) == null ? void 0 : _a.handleOpen();
  40. },
  41. handleClose: () => {
  42. var _a;
  43. (_a = commonPicker.value) == null ? void 0 : _a.handleClose();
  44. }
  45. };
  46. expose(refProps);
  47. const onModelValueUpdated = (val) => {
  48. emit(UPDATE_MODEL_EVENT, val);
  49. };
  50. return () => {
  51. var _a;
  52. const format = (_a = props.format) != null ? _a : DEFAULT_FORMATS_DATEPICKER[props.type] || DEFAULT_FORMATS_DATE;
  53. return createVNode(CommonPicker, mergeProps(props, {
  54. "format": format,
  55. "type": props.type,
  56. "ref": commonPicker,
  57. "onUpdate:modelValue": onModelValueUpdated
  58. }), {
  59. default: (scopedProps) => createVNode(ElDatePickerPanel, mergeProps({
  60. "border": false
  61. }, scopedProps), _isSlot(slots) ? slots : {
  62. default: () => [slots]
  63. }),
  64. "range-separator": slots["range-separator"]
  65. });
  66. };
  67. }
  68. });
  69. export { DatePicker as default };
  70. //# sourceMappingURL=date-picker.mjs.map