UNPKG

tdesign-react

Version:
93 lines (89 loc) 3.58 kB
/** * tdesign v1.16.2 * (c) 2025 tdesign * @license MIT */ import { _ as _slicedToArray } from '../_chunks/dep-10d5731f.js'; import React from 'react'; import useConfig from '../hooks/useConfig.js'; import usePrefixClass from './hooks/usePrefixClass.js'; import { useLocaleReceiver } from '../locale/LocalReceiver.js'; import { blockName } from './_util.js'; import '../_chunks/dep-74a10cfb.js'; import '../config-provider/ConfigContext.js'; import '../_chunks/dep-d67deb2c.js'; import '../_chunks/dep-8abcbcbc.js'; import 'lodash-es'; import '../locale/zh_CN.js'; import '../_chunks/dep-751cada9.js'; import 'dayjs'; import '../_chunks/dep-37c4dbb1.js'; import '../config-provider/index.js'; import '../config-provider/ConfigProvider.js'; import '../config-provider/type.js'; var CalendarCellComp = function CalendarCellComp(props) { var mode = props.mode, cell = props.cell, cellAppend = props.cellAppend, theme = props.theme, _props$isDisabled = props.isDisabled, isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled, cellData = props.cellData, isCurrent = props.isCurrent, isNow = props.isNow, fillWithZero = props.fillWithZero, createCalendarCell = props.createCalendarCell, onCellClick = props.onCellClick, onCellDoubleClick = props.onCellDoubleClick, onCellRightClick = props.onCellRightClick; var _useLocaleReceiver = useLocaleReceiver("calendar"), _useLocaleReceiver2 = _slicedToArray(_useLocaleReceiver, 2), local = _useLocaleReceiver2[0], t = _useLocaleReceiver2[1]; var monthLabelList = t(local.cellMonth).split(","); var getMonthCN = function getMonthCN(month) { return monthLabelList[month]; }; var _useConfig = useConfig(), calendarConfig = _useConfig.calendar; var fix0 = function fix0(num) { var _ref; var fillZero = num < 10 && ((_ref = fillWithZero !== null && fillWithZero !== void 0 ? fillWithZero : calendarConfig.fillWithZero) !== null && _ref !== void 0 ? _ref : true); return fillZero ? "0".concat(num) : num; }; var prefixCls = usePrefixClass(); return /* @__PURE__ */React.createElement("td", { className: prefixCls([blockName, "table-body-cell"], isDisabled ? "is-disabled" : null, isCurrent ? "is-checked" : null, isNow ? [blockName, "table-body-cell--now"] : null), onClick: onCellClick, onDoubleClick: onCellDoubleClick, onContextMenu: onCellRightClick }, function () { if (cell && typeof cell === "function") return cell(mode === "month" ? createCalendarCell(cellData) : cellData); if (cell && typeof cell !== "function") return cell; var cellCtx; if (mode === "year") { var mIndex = cellData.date.getMonth(); cellCtx = theme === "full" ? getMonthCN(mIndex) : t(local.monthSelection, { month: "".concat(mIndex + 1) }); } else { cellCtx = fix0(cellData.date.getDate()); } return /* @__PURE__ */React.createElement("div", { className: prefixCls([blockName, "table-body-cell-display"]) }, cellCtx); }(), function () { var cellCtx; if (cellAppend && typeof cellAppend === "function") { cellCtx = cellAppend(mode === "month" ? createCalendarCell(cellData) : cellData); } if (cellAppend && typeof cellAppend !== "function") { cellCtx = cellAppend; } return cellAppend && /* @__PURE__ */React.createElement("div", { className: prefixCls([blockName, "table-body-cell-content"]) }, cellCtx); }()); }; export { CalendarCellComp as default }; //# sourceMappingURL=CalendarCellComp.js.map