You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
24 KiB

3 months ago
  1. {"ast":null,"code":"import { defineComponent, ref, computed, watch, nextTick, openBlock, createElementBlock, unref, normalizeClass, createElementVNode, Fragment, renderList, withKeys, withModifiers, createVNode } from 'vue';\nimport dayjs from 'dayjs';\nimport { basicMonthTableProps } from '../props/basic-month-table.mjs';\nimport { datesInMonth, getValidDateOfMonth } from '../utils.mjs';\nimport ElDatePickerCell from './basic-cell-render.mjs';\nimport _export_sfc from '../../../../_virtual/plugin-vue_export-helper.mjs';\nimport { useNamespace } from '../../../../hooks/use-namespace/index.mjs';\nimport { useLocale } from '../../../../hooks/use-locale/index.mjs';\nimport { castArray } from '../../../../utils/arrays.mjs';\nimport { hasClass } from '../../../../utils/dom/style.mjs';\nconst _sfc_main = /* @__PURE__ */defineComponent({\n __name: \"basic-month-table\",\n props: basicMonthTableProps,\n emits: [\"changerange\", \"pick\", \"select\"],\n setup(__props, {\n expose,\n emit\n }) {\n const props = __props;\n const ns = useNamespace(\"month-table\");\n const {\n t,\n lang\n } = useLocale();\n const tbodyRef = ref();\n const currentCellRef = ref();\n const months = ref(props.date.locale(\"en\").localeData().monthsShort().map(_ => _.toLowerCase()));\n const tableRows = ref([[], [], []]);\n const lastRow = ref();\n const lastColumn = ref();\n const rows = computed(() => {\n var _a, _b;\n const rows2 = tableRows.value;\n const now = dayjs().locale(lang.value).startOf(\"month\");\n for (let i = 0; i < 3; i++) {\n const row = rows2[i];\n for (let j = 0; j < 4; j++) {\n const cell = row[j] || (row[j] = {\n row: i,\n column: j,\n type: \"normal\",\n inRange: false,\n start: false,\n end: false,\n text: -1,\n disabled: false\n });\n cell.type = \"normal\";\n const index = i * 4 + j;\n const calTime = props.date.startOf(\"year\").month(index);\n const calEndDate = props.rangeState.endDate || props.maxDate || props.rangeState.selecting && props.minDate || null;\n cell.inRange = !!(props.minDate && calTime.isSameOrAfter(props.minDate, \"month\") && calEndDate && calTime.isSameOrBefore(calEndDate, \"month\")) || !!(props.minDate && calTime.isSameOrBefore(props.minDate, \"month\") && calEndDate && calTime.isSameOrAfter(calEndDate, \"month\"));\n if ((_a = props.minDate) == null ? void 0 : _a.isSameOrAfter(calEndDate)) {\n cell.start = !!(calEndDate && calTime.isSame(calEndDate, \"month\"));\n cell.end = props.minDate && calTime.isSame(props.minDate, \"month\");\n } else {\n cell.start = !!(props.minDate && calTime.isSame(props.minDate, \"month\"));\n cell.end = !!(calEndDate && calTime.isSame(calEndDate, \"month\"));\n }\n const isToday = now.isSame(calTime);\n if (isToday) {\n cell.type = \"today\";\n }\n cell.text = index;\n cell.disabled = ((_b = props.disabledDate) == null ? void 0 : _b.call(props, calTime.toDate())) || false;\n }\n }\n return rows2;\n });\n const focus = () => {\n var _a;\n (_a = currentCellRef.value) == null ? void 0 : _a.focus();\n };\n const getCellStyle = cell => {\n const style = {};\n const year = props.date.year();\n const today = /* @__PURE__ */new Date();\n const month = cell.text;\n style.disabled = props.disabledDate ? datesInMonth(year, month, lang.value).every(props.disabledDate) : false;\n style.current = castArray(props.parsedValue).findIndex(date => dayjs.isDayjs(date) && date.year() === year && date.month() === month) >= 0;\n style.today = today.getFullYear() === year && today.getMonth() === month;\n if (cell.inRange) {\n style[\"in-range\"] = true;\n if (cell.start) {\n style[\"start-date\"] = true;\n }\n if (cell.end)