ba90be4e8b11995dfb44c609ee70e94fd21baa32b8fe08a70cd565991a4c2c6869bb068d5f1ac95a1299467c700bf3b299202110e66ede0a792c435f808492 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, unref, createElementVNode, renderSlot, toDisplayString, createVNode, withCtx, createTextVNode, createCommentVNode, createSlots, normalizeProps, guardReactiveProps, Fragment, renderList, createBlock } from 'vue';
  2. import { ElButtonGroup, ElButton } from '../../button/index.mjs';
  3. import DateTable from './date-table2.mjs';
  4. import { useCalendar } from './use-calendar.mjs';
  5. import { calendarProps, calendarEmits } from './calendar.mjs';
  6. import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
  7. import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
  8. import { useLocale } from '../../../hooks/use-locale/index.mjs';
  9. const COMPONENT_NAME = "ElCalendar";
  10. const __default__ = defineComponent({
  11. name: COMPONENT_NAME
  12. });
  13. const _sfc_main = /* @__PURE__ */ defineComponent({
  14. ...__default__,
  15. props: calendarProps,
  16. emits: calendarEmits,
  17. setup(__props, { expose, emit }) {
  18. const props = __props;
  19. const ns = useNamespace("calendar");
  20. const {
  21. calculateValidatedDateRange,
  22. date,
  23. pickDay,
  24. realSelectedDay,
  25. selectDate,
  26. validatedRange
  27. } = useCalendar(props, emit);
  28. const { t } = useLocale();
  29. const i18nDate = computed(() => {
  30. const pickedMonth = `el.datepicker.month${date.value.format("M")}`;
  31. return `${date.value.year()} ${t("el.datepicker.year")} ${t(pickedMonth)}`;
  32. });
  33. expose({
  34. selectedDay: realSelectedDay,
  35. pickDay,
  36. selectDate,
  37. calculateValidatedDateRange
  38. });
  39. return (_ctx, _cache) => {
  40. return openBlock(), createElementBlock("div", {
  41. class: normalizeClass(unref(ns).b())
  42. }, [
  43. createElementVNode("div", {
  44. class: normalizeClass(unref(ns).e("header"))
  45. }, [
  46. renderSlot(_ctx.$slots, "header", { date: unref(i18nDate) }, () => [
  47. createElementVNode("div", {
  48. class: normalizeClass(unref(ns).e("title"))
  49. }, toDisplayString(unref(i18nDate)), 3),
  50. unref(validatedRange).length === 0 ? (openBlock(), createElementBlock("div", {
  51. key: 0,
  52. class: normalizeClass(unref(ns).e("button-group"))
  53. }, [
  54. createVNode(unref(ElButtonGroup), null, {
  55. default: withCtx(() => [
  56. createVNode(unref(ElButton), {
  57. size: "small",
  58. onClick: ($event) => unref(selectDate)("prev-month")
  59. }, {
  60. default: withCtx(() => [
  61. createTextVNode(toDisplayString(unref(t)("el.datepicker.prevMonth")), 1)
  62. ]),
  63. _: 1
  64. }, 8, ["onClick"]),
  65. createVNode(unref(ElButton), {
  66. size: "small",
  67. onClick: ($event) => unref(selectDate)("today")
  68. }, {
  69. default: withCtx(() => [
  70. createTextVNode(toDisplayString(unref(t)("el.datepicker.today")), 1)
  71. ]),
  72. _: 1
  73. }, 8, ["onClick"]),
  74. createVNode(unref(ElButton), {
  75. size: "small",
  76. onClick: ($event) => unref(selectDate)("next-month")
  77. }, {
  78. default: withCtx(() => [
  79. createTextVNode(toDisplayString(unref(t)("el.datepicker.nextMonth")), 1)
  80. ]),
  81. _: 1
  82. }, 8, ["onClick"])
  83. ]),
  84. _: 1
  85. })
  86. ], 2)) : createCommentVNode("v-if", true)
  87. ])
  88. ], 2),
  89. unref(validatedRange).length === 0 ? (openBlock(), createElementBlock("div", {
  90. key: 0,
  91. class: normalizeClass(unref(ns).e("body"))
  92. }, [
  93. createVNode(DateTable, {
  94. date: unref(date),
  95. "selected-day": unref(realSelectedDay),
  96. onPick: unref(pickDay)
  97. }, createSlots({
  98. _: 2
  99. }, [
  100. _ctx.$slots["date-cell"] ? {
  101. name: "date-cell",
  102. fn: withCtx((data) => [
  103. renderSlot(_ctx.$slots, "date-cell", normalizeProps(guardReactiveProps(data)))
  104. ])
  105. } : void 0
  106. ]), 1032, ["date", "selected-day", "onPick"])
  107. ], 2)) : (openBlock(), createElementBlock("div", {
  108. key: 1,
  109. class: normalizeClass(unref(ns).e("body"))
  110. }, [
  111. (openBlock(true), createElementBlock(Fragment, null, renderList(unref(validatedRange), (range_, index) => {
  112. return openBlock(), createBlock(DateTable, {
  113. key: index,
  114. date: range_[0],
  115. "selected-day": unref(realSelectedDay),
  116. range: range_,
  117. "hide-header": index !== 0,
  118. onPick: unref(pickDay)
  119. }, createSlots({
  120. _: 2
  121. }, [
  122. _ctx.$slots["date-cell"] ? {
  123. name: "date-cell",
  124. fn: withCtx((data) => [
  125. renderSlot(_ctx.$slots, "date-cell", normalizeProps(guardReactiveProps(data)))
  126. ])
  127. } : void 0
  128. ]), 1032, ["date", "selected-day", "range", "hide-header", "onPick"]);
  129. }), 128))
  130. ], 2))
  131. ], 2);
  132. };
  133. }
  134. });
  135. var Calendar = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "calendar.vue"]]);
  136. export { Calendar as default };
  137. //# sourceMappingURL=calendar2.mjs.map