c5e17b338062df4e16b05970dd9fcf403b43a059357102389aba5efcb40c99acc4139fb8fa03cf20b082a126a13a76a4149af1a101cc3c5e38565db3b5125f 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import { defineComponent, onBeforeUnmount, openBlock, createElementBlock, unref, normalizeClass, createElementVNode, createCommentVNode, Fragment, renderList, toDisplayString, createVNode } from 'vue';
  2. import { basicDateTableProps, basicDateTableEmits } from '../props/basic-date-table.mjs';
  3. import { useBasicDateTable, useBasicDateTableDOM } from '../composables/use-basic-date-table.mjs';
  4. import ElDatePickerCell from './basic-cell-render.mjs';
  5. import _export_sfc from '../../../../_virtual/plugin-vue_export-helper.mjs';
  6. const _sfc_main = /* @__PURE__ */ defineComponent({
  7. __name: "basic-date-table",
  8. props: basicDateTableProps,
  9. emits: basicDateTableEmits,
  10. setup(__props, { expose, emit }) {
  11. const props = __props;
  12. const {
  13. WEEKS,
  14. rows,
  15. tbodyRef,
  16. currentCellRef,
  17. focus,
  18. isCurrent,
  19. isWeekActive,
  20. isSelectedCell,
  21. handlePickDate,
  22. handleMouseUp,
  23. handleMouseDown,
  24. handleMouseMove,
  25. handleFocus
  26. } = useBasicDateTable(props, emit);
  27. const { tableLabel, tableKls, getCellClasses, getRowKls, weekHeaderClass, t } = useBasicDateTableDOM(props, {
  28. isCurrent,
  29. isWeekActive
  30. });
  31. let isUnmounting = false;
  32. onBeforeUnmount(() => {
  33. isUnmounting = true;
  34. });
  35. expose({
  36. focus
  37. });
  38. return (_ctx, _cache) => {
  39. return openBlock(), createElementBlock("table", {
  40. "aria-label": unref(tableLabel),
  41. class: normalizeClass(unref(tableKls)),
  42. cellspacing: "0",
  43. cellpadding: "0",
  44. role: "grid",
  45. onClick: unref(handlePickDate),
  46. onMousemove: unref(handleMouseMove),
  47. onMousedown: unref(handleMouseDown),
  48. onMouseup: unref(handleMouseUp)
  49. }, [
  50. createElementVNode("tbody", {
  51. ref_key: "tbodyRef",
  52. ref: tbodyRef
  53. }, [
  54. createElementVNode("tr", null, [
  55. _ctx.showWeekNumber ? (openBlock(), createElementBlock("th", {
  56. key: 0,
  57. scope: "col",
  58. class: normalizeClass(unref(weekHeaderClass))
  59. }, null, 2)) : createCommentVNode("v-if", true),
  60. (openBlock(true), createElementBlock(Fragment, null, renderList(unref(WEEKS), (week, key) => {
  61. return openBlock(), createElementBlock("th", {
  62. key,
  63. "aria-label": unref(t)("el.datepicker.weeksFull." + week),
  64. scope: "col"
  65. }, toDisplayString(unref(t)("el.datepicker.weeks." + week)), 9, ["aria-label"]);
  66. }), 128))
  67. ]),
  68. (openBlock(true), createElementBlock(Fragment, null, renderList(unref(rows), (row, rowKey) => {
  69. return openBlock(), createElementBlock("tr", {
  70. key: rowKey,
  71. class: normalizeClass(unref(getRowKls)(row[1]))
  72. }, [
  73. (openBlock(true), createElementBlock(Fragment, null, renderList(row, (cell, columnKey) => {
  74. return openBlock(), createElementBlock("td", {
  75. key: `${rowKey}.${columnKey}`,
  76. ref_for: true,
  77. ref: (el) => !unref(isUnmounting) && unref(isSelectedCell)(cell) && (currentCellRef.value = el),
  78. class: normalizeClass(unref(getCellClasses)(cell)),
  79. "aria-current": cell.isCurrent ? "date" : void 0,
  80. "aria-selected": cell.isCurrent,
  81. tabindex: unref(isSelectedCell)(cell) ? 0 : -1,
  82. onFocus: unref(handleFocus)
  83. }, [
  84. createVNode(unref(ElDatePickerCell), { cell }, null, 8, ["cell"])
  85. ], 42, ["aria-current", "aria-selected", "tabindex", "onFocus"]);
  86. }), 128))
  87. ], 2);
  88. }), 128))
  89. ], 512)
  90. ], 42, ["aria-label", "onClick", "onMousemove", "onMousedown", "onMouseup"]);
  91. };
  92. }
  93. });
  94. var DateTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "basic-date-table.vue"]]);
  95. export { DateTable as default };
  96. //# sourceMappingURL=basic-date-table.mjs.map