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.
1 line
39 KiB
1 line
39 KiB
3 months ago
|
{"ast":null,"code":"import \"core-js/modules/es.array.push.js\";\nimport { ref, computed, unref, watch, nextTick } from 'vue';\nimport dayjs from 'dayjs';\nimport { flatten } from 'lodash-unified';\nimport '../../../../hooks/index.mjs';\nimport '../../../../utils/index.mjs';\nimport { buildPickerTable } from '../utils.mjs';\nimport { useLocale } from '../../../../hooks/use-locale/index.mjs';\nimport { castArray } from '../../../../utils/arrays.mjs';\nimport { useNamespace } from '../../../../hooks/use-namespace/index.mjs';\nconst isNormalDay = (type = \"\") => {\n return [\"normal\", \"today\"].includes(type);\n};\nconst useBasicDateTable = (props, emit) => {\n const {\n lang\n } = useLocale();\n const tbodyRef = ref();\n const currentCellRef = ref();\n const lastRow = ref();\n const lastColumn = ref();\n const tableRows = ref([[], [], [], [], [], []]);\n let focusWithClick = false;\n const firstDayOfWeek = props.date.$locale().weekStart || 7;\n const WEEKS_CONSTANT = props.date.locale(\"en\").localeData().weekdaysShort().map(_ => _.toLowerCase());\n const offsetDay = computed(() => {\n return firstDayOfWeek > 3 ? 7 - firstDayOfWeek : -firstDayOfWeek;\n });\n const startDate = computed(() => {\n const startDayOfMonth = props.date.startOf(\"month\");\n return startDayOfMonth.subtract(startDayOfMonth.day() || 7, \"day\");\n });\n const WEEKS = computed(() => {\n return WEEKS_CONSTANT.concat(WEEKS_CONSTANT).slice(firstDayOfWeek, firstDayOfWeek + 7);\n });\n const hasCurrent = computed(() => {\n return flatten(unref(rows)).some(row => {\n return row.isCurrent;\n });\n });\n const days = computed(() => {\n const startOfMonth = props.date.startOf(\"month\");\n const startOfMonthDay = startOfMonth.day() || 7;\n const dateCountOfMonth = startOfMonth.daysInMonth();\n const dateCountOfLastMonth = startOfMonth.subtract(1, \"month\").daysInMonth();\n return {\n startOfMonthDay,\n dateCountOfMonth,\n dateCountOfLastMonth\n };\n });\n const selectedDate = computed(() => {\n return props.selectionMode === \"dates\" ? castArray(props.parsedValue) : [];\n });\n const setDateText = (cell, {\n count,\n rowIndex,\n columnIndex\n }) => {\n const {\n startOfMonthDay,\n dateCountOfMonth,\n dateCountOfLastMonth\n } = unref(days);\n const offset = unref(offsetDay);\n if (rowIndex >= 0 && rowIndex <= 1) {\n const numberOfDaysFromPreviousMonth = startOfMonthDay + offset < 0 ? 7 + startOfMonthDay + offset : startOfMonthDay + offset;\n if (columnIndex + rowIndex * 7 >= numberOfDaysFromPreviousMonth) {\n cell.text = count;\n return true;\n } else {\n cell.text = dateCountOfLastMonth - (numberOfDaysFromPreviousMonth - columnIndex % 7) + 1 + rowIndex * 7;\n cell.type = \"prev-month\";\n }\n } else {\n if (count <= dateCountOfMonth) {\n cell.text = count;\n } else {\n cell.text = count - dateCountOfMonth;\n cell.type = \"next-month\";\n }\n return true;\n }\n return false;\n };\n const setCellMetadata = (cell, {\n columnIndex,\n rowIndex\n }, count) => {\n const {\n disabledDate,\n cellClassName\n } = props;\n const _selectedDate = unref(selectedDate);\n const shouldIncrement = setDateText(cell, {\n count,\n rowIndex,\n columnIndex\n });\n const cellDate = cell.dayjs.toDate();\n cell.selected = _selectedDate.find(d => d.isSame(cell.dayjs, \"day\"));\n cell.isSelected = !!cell.selected;\n cell.isCurrent = isCurrent(cell);\n cell.disabled = disabledDate == null ? void 0 : disabledDate(cellDate);\n cell.customClass = cellClassName == null ? void 0 : cellClassName(cellDate);\n return shouldIncrement;\n };\n const setRowMetadata = row => {\n if (props.selectionMode === \"week\") {\n const [start, end] = props.showWeekNumber ? [1, 7] : [0, 6];\n const isActive = isWeekActive(row[start + 1]);\n row[start].inRange = isActive;\n row[start].start = isA
|