tdesign-react
Version:
TDesign Component for React
90 lines (86 loc) • 3.47 kB
JavaScript
/**
* tdesign v1.13.2
* (c) 2025 tdesign
* @license MIT
*/
import { _ as _slicedToArray } from '../_chunks/dep-118954e6.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-61f5e3d1.js';
import '../config-provider/ConfigContext.js';
import '../_chunks/dep-8618a2f1.js';
import '../_chunks/dep-c37cc2fd.js';
import 'lodash-es';
import '../_chunks/dep-698f8ddd.js';
import '../_chunks/dep-09955460.js';
import 'dayjs';
import '../config-provider/ConfigProvider.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