'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
require('../../../../utils/index.cjs');
var PanelContext = require('../PanelContext.cjs');
var timeUtil = require('../utils/timeUtil.cjs');
var dateUtil = require('../utils/dateUtil.cjs');
var useMergeProps = require('../hooks/useMergeProps.cjs');
var _class = require('../../../../utils/dom/class.cjs');

function PanelBody(_props) {
  const {
    prefixCls,
    disabledDate,
    onSelect,
    picker,
    rowNum,
    colNum,
    prefixColumn,
    rowClassName,
    baseDate,
    getCellClassName,
    getCellText,
    getCellNode,
    getCellDate,
    generateConfig,
    titleCell,
    headerCells
  } = useMergeProps.default(_props);
  const {
    onDateMouseenter,
    onDateMouseleave,
    mode
  } = PanelContext.useInjectPanel();
  const cellPrefixCls = `${prefixCls}-cell`;
  const rows = [];
  for (let i = 0; i < rowNum; i += 1) {
    const row = [];
    let rowStartDate;
    for (let j = 0; j < colNum; j += 1) {
      const offset = i * colNum + j;
      const currentDate = getCellDate(baseDate, offset);
      const disabled = dateUtil.getCellDateDisabled({
        cellDate: currentDate,
        mode: mode.value,
        disabledDate,
        generateConfig
      });
      if (j === 0) {
        rowStartDate = currentDate;
        if (prefixColumn)
          row.push(prefixColumn(rowStartDate));
      }
      const title = titleCell && titleCell(currentDate);
      row.push(vue.createVNode("td", {
        "key": j,
        "title": title,
        "class": _class.classNames(cellPrefixCls, {
          [`${cellPrefixCls}-disabled`]: disabled,
          [`${cellPrefixCls}-start`]: getCellText(currentDate) === 1 || picker === "year" && Number(title) % 10 === 0,
          [`${cellPrefixCls}-end`]: title === timeUtil.getLastDay(generateConfig, currentDate) || picker === "year" && Number(title) % 10 === 9,
          ...getCellClassName(currentDate)
        }),
        "onClick": (e) => {
          e.stopPropagation();
          if (!disabled)
            onSelect(currentDate);
        },
        "onMouseenter": () => {
          if (!disabled && onDateMouseenter)
            onDateMouseenter(currentDate);
        },
        "onMouseleave": () => {
          if (!disabled && onDateMouseleave)
            onDateMouseleave(currentDate);
        }
      }, [getCellNode ? getCellNode(currentDate) : vue.createVNode("div", {
        "class": `${cellPrefixCls}-inner`
      }, [getCellText(currentDate)])]));
    }
    rows.push(vue.createVNode("tr", {
      "key": i,
      "class": rowClassName && rowClassName(rowStartDate)
    }, [row]));
  }
  return vue.createVNode("div", {
    "class": `${prefixCls}-body`
  }, [vue.createVNode("table", {
    "class": `${prefixCls}-content`
  }, [headerCells && vue.createVNode("thead", null, [vue.createVNode("tr", null, [headerCells])]), vue.createVNode("tbody", null, [rows])])]);
}
PanelBody.displayName = "PanelBody";
PanelBody.inheritAttrs = false;

exports.default = PanelBody;
//# sourceMappingURL=PanelBody.cjs.map
