import {debounce} from "canknow-core/src/libs";

export default {
    inject: ['dataCalendar'],
    props: {
        cellValue: {
            type: Function,
            default(time) {
                return time;
            }
        },
        cellClass: {
            type: Function,
            default(time) {
                return 'cell-class';
            }
        },
        loading: {
            type: Boolean,
            default: true
        }
    },
    methods: {
        getCellClass (date, column) {
            return this.cellClass(this.getTime(date, column));
        },
        getCellValue (date, column) {
            return this.cellValue(this.getTime(date, column));
        },
        onClick($event, date, column) {
            this.$emit('select', this.getTime(date, column), $event);
        },
        handleCellMouseEnter (event, row, column) {
            if (!this.isCellValid(row, column)) {
                return;
            }
            const reference = event.target;
            const time = this.getTime(date, column);
            this.dataCalendar.onMouseEnter(reference, time, row, column);
        },
        handleCellMouseLeave () {
            this.dataCalendar.onMouseLeave();
        },
    }
}