xdesign-vue-next
Version:
XDesign Component for vue-next
166 lines (162 loc) • 6.85 kB
JavaScript
/**
* xdesign v1.0.6
* (c) 2023 xdesign
* @license MIT
*/
import { _ as _defineProperty } from '../_chunks/dep-f9e836af.mjs';
import { _ as _toConsumableArray } from '../_chunks/dep-5bec687c.mjs';
import { defineComponent, computed, createVNode, Fragment } from 'vue';
import { d as dayjs } from '../_chunks/dep-6fe15f5a.mjs';
import { useCommonClassName } from '../hooks/useConfig.mjs';
import { useContent } from '../hooks/tnode.mjs';
import './hook/index.mjs';
import { useCalendarCellClass } from './hook/useCalendarClass.mjs';
import '../_chunks/dep-82805301.mjs';
import '../_chunks/dep-89b966f4.mjs';
import '../_chunks/dep-10a947a6.mjs';
import '../config-provider/useConfig.mjs';
import '../_chunks/dep-1cc1c24f.mjs';
import '../_chunks/dep-b75d8d74.mjs';
import '../_chunks/dep-6ad18815.mjs';
import '../_chunks/dep-91ac8f71.mjs';
import '../_chunks/dep-c4737535.mjs';
import '../_chunks/dep-81c83986.mjs';
import '../_chunks/dep-6aa0223b.mjs';
import '../_chunks/dep-db381ece.mjs';
import '../_chunks/dep-5755c21c.mjs';
import '../_chunks/dep-7f239c43.mjs';
import '../_chunks/dep-6f04869e.mjs';
import '../_chunks/dep-d32fbbb3.mjs';
import '../_chunks/dep-dafada74.mjs';
import '../_chunks/dep-addc2a84.mjs';
import '../_chunks/dep-a95026f2.mjs';
import '../_chunks/dep-068e912d.mjs';
import '../_chunks/dep-6e7b37b8.mjs';
import '../_chunks/dep-e1ab85c5.mjs';
import '../_chunks/dep-5f0e0453.mjs';
import '../_chunks/dep-71f84cf2.mjs';
import '../_chunks/dep-0e832fc7.mjs';
import '../_chunks/dep-69963a8c.mjs';
import '../_chunks/dep-8d1c9a23.mjs';
import '../_chunks/dep-03412fab.mjs';
import '../_chunks/dep-205ff58d.mjs';
import '../_chunks/dep-11fa9c2c.mjs';
import '../_chunks/dep-b09f48fa.mjs';
import '../_chunks/dep-26bf361a.mjs';
import '../_chunks/dep-3ec3335a.mjs';
import '../_chunks/dep-ed4e7c50.mjs';
import '../_chunks/dep-a666b9ad.mjs';
import '../_common/js/global-config/default-config.mjs';
import '../_common/js/global-config/locale/en_US.mjs';
import '../config-provider/type.mjs';
import '../_chunks/dep-a628549d.mjs';
import '../_chunks/dep-4903a8a8.mjs';
import '../_chunks/dep-7dcfa37a.mjs';
import '../_chunks/dep-f4eba04c.mjs';
import '../_chunks/dep-735bcd0d.mjs';
import '../_chunks/dep-765678ef.mjs';
import '../_chunks/dep-8db27830.mjs';
import '../_chunks/dep-ae4bffa5.mjs';
import '../utils/render-tnode.mjs';
import '../_chunks/dep-9d7ebc32.mjs';
import './hook/useState.mjs';
import './const.mjs';
import './utils.mjs';
import './hook/useController.mjs';
import '../_chunks/dep-b9fae426.mjs';
import './hook/useColHeaders.mjs';
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var clickTypeEmitEventMap = {
click: "click",
dblclick: "dblclick",
contextmenu: "rightclick"
};
var CalendarCellItem = defineComponent({
name: "TCalendarCell",
inheritAttrs: false,
props: {
item: {
type: Object,
"default": function _default() {
return null;
}
},
fillWithZero: {
type: Boolean,
"default": void 0
},
theme: {
type: String,
"default": function _default() {
return null;
}
},
t: Function,
global: Object,
cell: [String, Function],
cellAppend: [String, Function]
},
emits: _toConsumableArray(Object.values(clickTypeEmitEventMap)),
setup: function setup(props, _ref) {
var emit = _ref.emit;
var renderContent = useContent();
var cls = useCalendarCellClass();
var _useCommonClassName = useCommonClassName(),
STATUS = _useCommonClassName.STATUS;
var valueDisplay = computed(function () {
if (props.item.mode === "month") {
var _ref2, _props$fillWithZero;
var dateNum = props.item.date.getDate();
var fillZero = dateNum < 10 && ((_ref2 = (_props$fillWithZero = props.fillWithZero) !== null && _props$fillWithZero !== void 0 ? _props$fillWithZero : props.global.fillWithZero) !== null && _ref2 !== void 0 ? _ref2 : true);
return fillZero ? "0".concat(dateNum) : dateNum;
}
var map = props.t(props.global.cellMonth).split(",");
return map[props.item.date.getMonth().toString()];
});
var allowSlot = computed(function () {
return props.theme === "full";
});
var disabled = computed(function () {
return props.item.mode === "month" && props.item.belongTo !== 0;
});
var cellCls = computed(function () {
var _ref3;
var _props$item = props.item,
mode = _props$item.mode,
date = _props$item.date,
formattedDate = _props$item.formattedDate,
isCurrent = _props$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 [cls.tableBodyCell.value, (_ref3 = {}, _defineProperty(_ref3, STATUS.value.disabled, disabled.value), _defineProperty(_ref3, STATUS.value.checked, isCurrent), _defineProperty(_ref3, cls.tableBodyCell4Now.value, isNow), _ref3)];
});
var clickCell = function clickCell(e) {
if (disabled.value) return;
var emitName = clickTypeEmitEventMap[e.type];
emit(emitName, e);
};
var renderDefaultNode = function renderDefaultNode() {
return createVNode(Fragment, null, [createVNode("div", {
"class": cls.tableBodyCellDisplay.value
}, [valueDisplay.value]), createVNode("div", {
"class": cls.tableBodyCellCsontent.value
}, [allowSlot.value && renderContent("cellAppend", void 0, {
params: _objectSpread({}, props.item)
})])]);
};
return function () {
return props.item && createVNode("td", {
"class": cellCls.value,
"onClick": clickCell,
"ondblclick": clickCell,
"oncontextmenu": clickCell
}, [renderContent("cell", void 0, {
defaultNode: renderDefaultNode(),
params: _objectSpread({}, props.item)
})]);
};
}
});
export { CalendarCellItem as default };
//# sourceMappingURL=calendar-cell.mjs.map