import PropTypes from '../../../_util/vue-types' import { getOptionProps } from '../../../_util/props-util' import cx from 'classnames' import DateConstants from './DateConstants' import { getTitleString, getTodayTime } from '../util/' function noop () {} function isSameDay (one, two) { return one && two && one.isSame(two, 'day') } function beforeCurrentMonthYear (current, today) { if (current.year() < today.year()) { return 1 } return current.year() === today.year() && current.month() < today.month() } function afterCurrentMonthYear (current, today) { if (current.year() > today.year()) { return 1 } return current.year() === today.year() && current.month() > today.month() } function getIdFromDate (date) { return `rc-calendar-${date.year()}-${date.month()}-${date.date()}` } const DateTBody = { props: { contentRender: PropTypes.func, dateRender: PropTypes.func, disabledDate: PropTypes.func, prefixCls: PropTypes.string, selectedValue: PropTypes.oneOfType([PropTypes.any, PropTypes.arrayOf(PropTypes.any)]), value: PropTypes.object, hoverValue: PropTypes.any.def([]), showWeekNumber: PropTypes.bool, }, render () { const props = getOptionProps(this) const { contentRender, prefixCls, selectedValue, value, showWeekNumber, dateRender, disabledDate, hoverValue, } = props const { $listeners = {}} = this const { select = noop, dayHover = noop } = $listeners let iIndex let jIndex let current const dateTable = [] const today = getTodayTime(value) const cellClass = `${prefixCls}-cell` const weekNumberCellClass = `${prefixCls}-week-number-cell` const dateClass = `${prefixCls}-date` const todayClass = `${prefixCls}-today` const selectedClass = `${prefixCls}-selected-day` const selectedDateClass = `${prefixCls}-selected-date` // do not move with mouse operation const selectedStartDateClass = `${prefixCls}-selected-start-date` const selectedEndDateClass = `${prefixCls}-selected-end-date` const inRangeClass = `${prefixCls}-in-range-cell` const lastMonthDayClass = `${prefixCls}-last-month-cell` const nextMonthDayClass = `${prefixCls}-next-month-btn-day` const disabledClass = `${prefixCls}-disabled-cell` const firstDisableClass = `${prefixCls}-disabled-cell-first-of-row` const lastDisableClass = `${prefixCls}-disabled-cell-last-of-row` const month1 = value.clone() month1.date(1) const day = month1.day() const lastMonthDiffDay = (day + 7 - value.localeData().firstDayOfWeek()) % 7 // calculate last month const lastMonth1 = month1.clone() lastMonth1.add(0 - lastMonthDiffDay, 'days') let passed = 0 for (iIndex = 0; iIndex < DateConstants.DATE_ROW_COUNT; iIndex++) { for (jIndex = 0; jIndex < DateConstants.DATE_COL_COUNT; jIndex++) { current = lastMonth1 if (passed) { current = current.clone() current.add(passed, 'days') } dateTable.push(current) passed++ } } const tableHtml = [] passed = 0 for (iIndex = 0; iIndex < DateConstants.DATE_ROW_COUNT; iIndex++) { let isCurrentWeek let weekNumberCell let isActiveWeek = false const dateCells = [] if (showWeekNumber) { weekNumberCell = (