date-picker-panel.mjs 2.8 KB

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