tdesign-vue
Version:
130 lines (126 loc) • 4.42 kB
JavaScript
/**
* tdesign v1.12.1
* (c) 2025 tdesign
* @license MIT
*/
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import dayjs from 'dayjs';
import { renderTNodeJSX, renderTNodeJSXDefault } from '../utils/render-tnode.js';
import mixins from '../utils/mixins.js';
import { getClassPrefixMixins } from '../config-provider/config-receiver.js';
import '@babel/runtime/helpers/readOnlyError';
import '@babel/runtime/helpers/typeof';
import 'vue';
import '@vue/composition-api';
import 'lodash-es';
import '../config-provider/context.js';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '../_chunks/dep-c44a474d.js';
import '../_chunks/dep-d639fbd7.js';
import '../_chunks/dep-3c66615e.js';
import '../config-provider/type.js';
import '../_common/js/global-config/t.js';
import '@babel/runtime/helpers/slicedToArray';
var classPrefixMixins = getClassPrefixMixins("calendar");
var clickTypeEmitEventMap = {
click: "click",
dblclick: "dblclick",
contextmenu: "rightclick"
};
var CalendarCellItem = mixins(classPrefixMixins).extend({
name: "TCalendarCell",
props: {
item: {
type: Object,
"default": function _default() {
return null;
}
},
theme: {
type: String,
"default": function _default() {
return null;
}
},
fillWithZero: {
type: Boolean,
"default": void 0
},
t: Function,
global: Object,
cell: Function
},
computed: {
allowSlot: function allowSlot() {
return this.theme === "full";
},
disabled: function disabled() {
return this.item.mode === "month" && this.item.belongTo !== 0;
},
valueDisplay: function valueDisplay() {
if (this.item.mode === "month") {
var _ref, _this$fillWithZero;
var dateNum = this.item.date.getDate();
var fillZero = dateNum < 10 && ((_ref = (_this$fillWithZero = this.fillWithZero) !== null && _this$fillWithZero !== void 0 ? _this$fillWithZero : this.global.fillWithZero) !== null && _ref !== void 0 ? _ref : true);
return fillZero ? "0".concat(dateNum) : dateNum;
}
var map = this.t(this.global.cellMonth).split(",");
return map[this.item.date.getMonth().toString()];
},
cellCls: function cellCls() {
var _this$item = this.item,
mode = _this$item.mode,
date = _this$item.date,
formattedDate = _this$item.formattedDate,
isCurrent = _this$item.isCurrent;
var now = new Date();
var isNow = mode === "year" ? now.getMonth() === date.getMonth() && now.getFullYear() === date.getFullYear() : formattedDate === dayjs().format("YYYY-MM-DD");
return ["".concat(this.componentName, "__table-body-cell"), _defineProperty(_defineProperty(_defineProperty({}, "".concat(this.classPrefix, "-is-disabled"), this.disabled), "".concat(this.classPrefix, "-is-checked"), isCurrent), "".concat(this.componentName, "__table-body-cell--now"), isNow)];
}
},
methods: {
clickCell: function clickCell(e) {
if (this.disabled) return;
this.$emit(clickTypeEmitEventMap[e.type], e);
}
},
render: function render() {
var _this = this;
var h = arguments[0];
var item = this.item,
cellCls = this.cellCls,
clickCell = this.clickCell,
valueDisplay = this.valueDisplay,
allowSlot = this.allowSlot;
var defaultNode = function defaultNode() {
var cellContentOuterDomStyle = {
display: "flex",
flexDirection: "column",
alignItems: "flex-end"
};
return h("div", {
"style": cellContentOuterDomStyle
}, [h("div", {
"class": "".concat(_this.componentName, "__table-body-cell-display")
}, [valueDisplay]), h("div", {
"class": "".concat(_this.componentName, "__table-body-cell-content")
}, [allowSlot && renderTNodeJSX(_this, "cellAppend", {
params: item
})])]);
};
return item && h("div", {
"class": cellCls,
"on": {
"click": clickCell,
"dblclick": clickCell,
"contextmenu": clickCell
}
}, [typeof this.cell === "function" ? this.cell(this.$createElement, item) : renderTNodeJSXDefault(this, "cell", {
defaultNode: defaultNode(),
params: item
})]);
}
});
export { CalendarCellItem as default };
//# sourceMappingURL=calendar-cell.js.map