c926354ca0686d69d493342be0c50df3eea0d3e7d1a1ad101282a75273b819f240ceea234f48f1e5f7c93b2741b1f3c9721f2eac760e2ed73320d21a5115eb 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { defineComponent, inject, reactive, toRefs, provide, createVNode, mergeProps, isVNode } from 'vue';
  2. import dayjs from 'dayjs';
  3. import customParseFormat from 'dayjs/plugin/customParseFormat.js';
  4. import advancedFormat from 'dayjs/plugin/advancedFormat.js';
  5. import localeData from 'dayjs/plugin/localeData.js';
  6. import weekOfYear from 'dayjs/plugin/weekOfYear.js';
  7. import weekYear from 'dayjs/plugin/weekYear.js';
  8. import dayOfYear from 'dayjs/plugin/dayOfYear.js';
  9. import isSameOrAfter from 'dayjs/plugin/isSameOrAfter.js';
  10. import isSameOrBefore from 'dayjs/plugin/isSameOrBefore.js';
  11. import { datePickerPanelProps } from './props/date-picker-panel.mjs';
  12. import { ROOT_PICKER_INJECTION_KEY } from './constants.mjs';
  13. import { getPanel } from './panel-utils.mjs';
  14. import { useCommonPicker } from '../../time-picker/src/composables/use-common-picker.mjs';
  15. import { PICKER_BASE_INJECTION_KEY, ROOT_COMMON_PICKER_INJECTION_KEY } from '../../time-picker/src/constants.mjs';
  16. import { UPDATE_MODEL_EVENT } from '../../../constants/event.mjs';
  17. import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
  18. import { isUndefined } from '../../../utils/types.mjs';
  19. function _isSlot(s) {
  20. return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
  21. }
  22. dayjs.extend(localeData);
  23. dayjs.extend(advancedFormat);
  24. dayjs.extend(customParseFormat);
  25. dayjs.extend(weekOfYear);
  26. dayjs.extend(weekYear);
  27. dayjs.extend(dayOfYear);
  28. dayjs.extend(isSameOrAfter);
  29. dayjs.extend(isSameOrBefore);
  30. var DatePickerPanel = defineComponent({
  31. name: "ElDatePickerPanel",
  32. install: null,
  33. props: datePickerPanelProps,
  34. emits: [UPDATE_MODEL_EVENT, "calendar-change", "panel-change", "visible-change", "pick"],
  35. setup(props, {
  36. slots,
  37. emit
  38. }) {
  39. const ns = useNamespace("picker-panel");
  40. const pickerInjection = inject(PICKER_BASE_INJECTION_KEY, void 0);
  41. if (isUndefined(pickerInjection)) {
  42. const _props = reactive({
  43. ...toRefs(props)
  44. });
  45. provide(PICKER_BASE_INJECTION_KEY, {
  46. props: _props
  47. });
  48. }
  49. provide(ROOT_PICKER_INJECTION_KEY, {
  50. slots,
  51. pickerNs: ns
  52. });
  53. const {
  54. parsedValue,
  55. onCalendarChange,
  56. onPanelChange,
  57. onSetPickerOption,
  58. onPick
  59. } = inject(ROOT_COMMON_PICKER_INJECTION_KEY, () => useCommonPicker(props, emit), true);
  60. return () => {
  61. const Component = getPanel(props.type);
  62. return createVNode(Component, mergeProps(props, {
  63. "parsedValue": parsedValue.value,
  64. "onSet-picker-option": onSetPickerOption,
  65. "onCalendar-change": onCalendarChange,
  66. "onPanel-change": onPanelChange,
  67. "onPick": onPick
  68. }), _isSlot(slots) ? slots : {
  69. default: () => [slots]
  70. });
  71. };
  72. }
  73. });
  74. export { DatePickerPanel as default };
  75. //# sourceMappingURL=date-picker-panel.mjs.map