import { createVNode } from 'vue';
import '../../../../utils/index.mjs';
import { useInjectPanel } from '../PanelContext.mjs';
import { getLastDay } from '../utils/timeUtil.mjs';
import { getCellDateDisabled } from '../utils/dateUtil.mjs';
import useMergeProps from '../hooks/useMergeProps.mjs';
import { classNames } from '../../../../utils/dom/class.mjs';

function PanelBody(_props) {
  const {
    prefixCls,
    disabledDate,
    onSelect,
    picker,
    rowNum,
    colNum,
    prefixColumn,
    rowClassName,
    baseDate,
    getCellClassName,
    getCellText,
    getCellNode,
    getCellDate,
    generateConfig,
    titleCell,
    headerCells
  } = useMergeProps(_props);
  const {
    onDateMouseenter,
    onDateMouseleave,
    mode
  } = 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 = 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(createVNode("td", {
        "key": j,
        "title": title,
        "class": classNames(cellPrefixCls, {
          [`${cellPrefixCls}-disabled`]: disabled,
          [`${cellPrefixCls}-start`]: getCellText(currentDate) === 1 || picker === "year" && Number(title) % 10 === 0,
          [`${cellPrefixCls}-end`]: title === 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) : createVNode("div", {
        "class": `${cellPrefixCls}-inner`
      }, [getCellText(currentDate)])]));
    }
    rows.push(createVNode("tr", {
      "key": i,
      "class": rowClassName && rowClassName(rowStartDate)
    }, [row]));
  }
  return createVNode("div", {
    "class": `${prefixCls}-body`
  }, [createVNode("table", {
    "class": `${prefixCls}-content`
  }, [headerCells && createVNode("thead", null, [createVNode("tr", null, [headerCells])]), createVNode("tbody", null, [rows])])]);
}
PanelBody.displayName = "PanelBody";
PanelBody.inheritAttrs = false;

export { PanelBody as default };
//# sourceMappingURL=PanelBody.mjs.map
