tdesign-vue
Version:
1,016 lines (1,002 loc) • 36.8 kB
JavaScript
/**
* tdesign v1.11.2
* (c) 2025 tdesign
* @license MIT
*/
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var helper = require('../_chunks/dep-ece3c062.js');
var _typeof = require('@babel/runtime/helpers/typeof');
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var dayjs = require('dayjs');
var _commonjsHelpers = require('../_chunks/dep-27dd8cc6.js');
var calendar_props = require('./props.js');
var utils_mixins = require('../utils/mixins.js');
var configProvider_configReceiver = require('../config-provider/config-receiver.js');
var calendar_utils = require('./utils.js');
var utils_event = require('../utils/event.js');
var _common_js_utils_helper = require('../_common/js/utils/helper.js');
var calendar_const = require('./const.js');
var select_index = require('../select/index.js');
var radio_index = require('../radio/index.js');
var button_index = require('../button/index.js');
var tag_index = require('../tag/index.js');
var calendar_calendarCell = require('./calendar-cell.js');
var utils_renderComponent = require('../utils/render-component.js');
var utils_renderTnode = require('../utils/render-tnode.js');
var _baseForOwn = require('../_chunks/dep-315a67f0.js');
var omit = require('../_chunks/dep-6dc0a916.js');
var _isIndex = require('../_chunks/dep-234b7c02.js');
require('vue');
require('../_chunks/dep-07fb8c0e.js');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('../_chunks/dep-a4a18104.js');
require('../_chunks/dep-87c765cc.js');
require('../_chunks/dep-75cd6d52.js');
require('../_chunks/dep-b1a02818.js');
require('../_chunks/dep-3d8ab37d.js');
require('../_chunks/dep-ecccff93.js');
require('../_chunks/dep-a4308f57.js');
require('../_chunks/dep-a4cecac4.js');
require('../_chunks/dep-ab142eaf.js');
require('../_chunks/dep-6ad3de7c.js');
require('../_chunks/dep-e4278c54.js');
require('../_chunks/dep-fcf0662d.js');
require('../_chunks/dep-8b1e056e.js');
require('../_chunks/dep-5db8defc.js');
require('../_chunks/dep-6e4c473c.js');
require('../_chunks/dep-a4747856.js');
require('../_chunks/dep-932dd69e.js');
require('../_chunks/dep-9f4caea4.js');
require('../_chunks/dep-dbd838d6.js');
require('../_chunks/dep-b3120c1b.js');
require('../_chunks/dep-68ba2357.js');
require('../_chunks/dep-173eb46c.js');
require('../utils/helper.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('../_chunks/dep-7c854ec6.js');
require('../_chunks/dep-eceed11d.js');
require('../_chunks/dep-201f7798.js');
require('../_chunks/dep-d3015b4c.js');
require('../_chunks/dep-f8a85d6a.js');
require('../_chunks/dep-5b117689.js');
require('../_chunks/dep-6478392e.js');
require('@babel/runtime/helpers/toConsumableArray');
require('../_chunks/dep-62de1188.js');
require('../_chunks/dep-867c284e.js');
require('../_chunks/dep-738b4f21.js');
require('../_chunks/dep-aa0a4aac.js');
require('@vue/composition-api');
require('../select/select.js');
require('../hooks/useDefaultValue.js');
require('../hooks/useVModel.js');
require('../_chunks/dep-47bca35e.js');
require('../hooks/tnode.js');
require('../hooks/render-tnode.js');
require('../_chunks/dep-a6490a32.js');
require('../_chunks/dep-3eec664c.js');
require('../_chunks/dep-eeb2e214.js');
require('../config-provider/useConfig.js');
require('../select/props.js');
require('../loading/index.js');
require('../loading/directive.js');
require('../loading/plugin.js');
require('../loading/loading.js');
require('../loading/icon/gradient.js');
require('../_common/js/loading/circle-adapter.js');
require('../_common/js/utils/setStyle.js');
require('../utils/dom.js');
require('raf');
require('../utils/easing.js');
require('../utils/transfer-dom.js');
require('../loading/props.js');
require('../config.js');
require('@babel/runtime/helpers/readOnlyError');
require('../_chunks/dep-013a3403.js');
require('../_chunks/dep-8cb0d589.js');
require('../_chunks/dep-d23147db.js');
require('../_chunks/dep-de60f5aa.js');
require('../_chunks/dep-63b02f7b.js');
require('../_chunks/dep-bebcd284.js');
require('../_chunks/dep-f84d1ea5.js');
require('../_chunks/dep-362bc4d7.js');
require('../_chunks/dep-2e32c1f2.js');
require('../_chunks/dep-f14aac54.js');
require('../utils/withInstall.js');
require('../popup/index.js');
require('../popup/popup.js');
require('@popperjs/core');
require('../popup/props.js');
require('../popup/container.js');
require('../popup/utils.js');
require('../_chunks/dep-f3761329.js');
require('../_chunks/dep-848a5a32.js');
require('../utils/map-props.js');
require('../popup/plugin.js');
require('../_common/js/log/log.js');
require('../input/index.js');
require('../input/input.js');
require('tdesign-icons-vue');
require('../input/props.js');
require('../input/input-group.js');
require('../select-input/index.js');
require('../select-input/select-input.js');
require('../select-input/props.js');
require('../select-input/useSingle.js');
require('../hooks/useConfig.js');
require('../_chunks/dep-71fa6788.js');
require('../_chunks/dep-73fb598e.js');
require('../_chunks/dep-a9e7deb2.js');
require('../select-input/useMultiple.js');
require('../tag-input/index.js');
require('../tag-input/tag-input.js');
require('../tag-input/props.js');
require('../tag-input/hooks/useTagScroll.js');
require('../tag-input/useTagList.js');
require('../tag-input/hooks/useHover.js');
require('../tag-input/hooks/useDragSorter.js');
require('../hooks/useGlobalIcon.js');
require('../tag/tag.js');
require('tinycolor2');
require('../tag/props.js');
require('../tag/check-tag.js');
require('../tag/check-tag-props.js');
require('../_common/js/common.js');
require('../tag/check-tag-group.js');
require('../tag/check-tag-group-props.js');
require('../select-input/useOverlayInnerStyle.js');
require('../common-components/fake-arrow.js');
require('../select/option.js');
require('../utils/ripple.js');
require('../select/option-props.js');
require('../checkbox/index.js');
require('../checkbox/group.js');
require('../checkbox/checkbox.js');
require('../checkbox/props.js');
require('../checkbox/constants.js');
require('../checkbox/store.js');
require('@babel/runtime/helpers/classCallCheck');
require('@babel/runtime/helpers/createClass');
require('../checkbox/hooks/useKeyboardEvent.js');
require('../hooks/useFormDisabled.js');
require('../hooks/useElementLazyRender.js');
require('../_common/js/utils/observe.js');
require('../checkbox/checkbox-group-props.js');
require('../_chunks/dep-e83685df.js');
require('../_chunks/dep-502c56be.js');
require('../hooks/slots.js');
require('../hooks/useLazyLoad.js');
require('../select/util.js');
require('../_chunks/dep-f45125c9.js');
require('../_chunks/dep-f33eb57d.js');
require('../hooks/useCommonClassName.js');
require('../select/select-panel.js');
require('../select/optionGroup.js');
require('../select/option-group-props.js');
require('../hooks/useVirtualScroll.js');
require('../select/hooks/useSelectOptions.js');
require('../_chunks/dep-b5c96567.js');
require('../radio/radio.js');
require('../radio/props.js');
require('../radio/group.js');
require('../radio/radio-group-props.js');
require('../radio/radio-button.js');
require('../button/button.js');
require('../button/props.js');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
/** Used for built-in method references. */
var arrayProto = Array.prototype;
/** Built-in value references. */
var splice = arrayProto.splice;
/**
* The base implementation of `_.pullAt` without support for individual
* indexes or capturing the removed elements.
*
* @private
* @param {Array} array The array to modify.
* @param {number[]} indexes The indexes of elements to remove.
* @returns {Array} Returns `array`.
*/
function basePullAt(array, indexes) {
var length = array ? indexes.length : 0,
lastIndex = length - 1;
while (length--) {
var index = indexes[length];
if (length == lastIndex || index !== previous) {
var previous = index;
if (_isIndex.isIndex(index)) {
splice.call(array, index, 1);
} else {
omit.baseUnset(array, index);
}
}
}
return array;
}
/**
* Removes all elements from `array` that `predicate` returns truthy for
* and returns an array of the removed elements. The predicate is invoked
* with three arguments: (value, index, array).
*
* **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
* to pull elements from an array by value.
*
* @static
* @memberOf _
* @since 2.0.0
* @category Array
* @param {Array} array The array to modify.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {Array} Returns the new array of removed elements.
* @example
*
* var array = [1, 2, 3, 4];
* var evens = _.remove(array, function(n) {
* return n % 2 == 0;
* });
*
* console.log(array);
* // => [1, 3]
*
* console.log(evens);
* // => [2, 4]
*/
function remove(array, predicate) {
var result = [];
if (!(array && array.length)) {
return result;
}
var index = -1,
indexes = [],
length = array.length;
predicate = _baseForOwn.baseIteratee(predicate);
while (++index < length) {
var value = array[index];
if (predicate(value, index, array)) {
result.push(value);
indexes.push(index);
}
}
basePullAt(array, indexes);
return result;
}
var calendar = _commonjsHelpers.createCommonjsModule(function (module, exports) {
!function (e, t) {
module.exports = t() ;
}(_commonjsHelpers.commonjsGlobal, function () {
return function (e, t, a) {
var n = "h:mm A",
d = {
lastDay: "[Yesterday at] " + n,
sameDay: "[Today at] " + n,
nextDay: "[Tomorrow at] " + n,
nextWeek: "dddd [at] " + n,
lastWeek: "[Last] dddd [at] " + n,
sameElse: "MM/DD/YYYY"
};
t.prototype.calendar = function (e, t) {
var n = t || this.$locale().calendar || d,
o = a(e || void 0).startOf("d"),
s = this.diff(o, "d", !0),
i = "sameElse",
f = s < -6 ? i : s < -1 ? "lastWeek" : s < 0 ? "lastDay" : s < 1 ? "sameDay" : s < 2 ? "nextDay" : s < 7 ? "nextWeek" : i,
l = n[f] || d[f];
return "function" == typeof l ? l.call(this, a()) : this.format(l);
};
};
});
});
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty__default["default"](e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
dayjs__default["default"].extend(calendar);
var createDefaultCurDate = function createDefaultCurDate() {
return dayjs__default["default"](dayjs__default["default"]().format("YYYY-MM-DD"));
};
var getDefaultControllerConfigData = function getDefaultControllerConfigData() {
var visible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
return {
visible: visible,
disabled: false,
mode: {
visible: true,
radioGroupProps: {}
},
year: {
visible: true,
selectProps: {}
},
month: {
visible: true,
selectProps: {}
},
weekend: {
visible: true,
showWeekendButtonProps: {},
hideWeekendButtonProps: {}
},
current: {
visible: true,
currentDayButtonProps: {},
currentMonthButtonProps: {}
}
};
};
var _Calendar = utils_mixins["default"](configProvider_configReceiver["default"]("calendar")).extend({
name: "TCalendar",
components: {
TCheckTag: tag_index.CheckTag,
TSelect: select_index.Select,
TOption: select_index.Option,
TRadioGroup: radio_index.RadioGroup,
TRadioButton: radio_index.RadioButton,
TButton: button_index.Button,
CalendarCellItem: calendar_calendarCell["default"],
RenderComponent: utils_renderComponent["default"]
},
props: _objectSpread({}, calendar_props["default"]),
data: function data() {
return {
realFirstDayOfWeek: 1,
curDate: null,
curDateList: [],
curSelectedYear: null,
curSelectedMonth: null,
curSelectedMode: null,
isShowWeekend: true,
controlSize: "medium"
};
},
computed: {
state: function state() {
return this.$data;
},
props: function props() {
return this.$props;
},
TEXT_MAP: function TEXT_MAP() {
var t = this.t,
global = this.global;
var r = {
showWeekend: t(global.showWeekend),
hideWeekend: t(global.hideWeekend),
today: t(global.today),
thisMonth: t(global.thisMonth)
};
return r;
},
weekDipalyText: function weekDipalyText() {
return this.week || this.t(this.global.week).split(",");
},
calendarCls: function calendarCls() {
return ["".concat(this.componentName), "".concat(this.componentName, "--").concat(this.theme)];
},
calendarPanelCls: function calendarPanelCls() {
return ["".concat(this.componentName, "__panel"), "".concat(this.componentName, "__panel--").concat(this.curSelectedMode)];
},
isWeekRender: function isWeekRender() {
return typeof this.week === "function";
},
rangeFromTo: function rangeFromTo() {
if (!this.range || this.range.length < 2) {
return null;
}
var _this$range = _slicedToArray__default["default"](this.range, 2),
v1 = _this$range[0],
v2 = _this$range[1];
if (dayjs__default["default"](v1).isBefore(dayjs__default["default"](v2))) {
return {
from: v1,
to: v2
};
}
return {
from: v2,
to: v1
};
},
controllerOptions: function controllerOptions() {
var dayJsFilterDate = dayjs__default["default"]("".concat(this.curSelectedYear, "-").concat(this.curSelectedMonth));
var re = {
isShowWeekend: this.isShowWeekend,
filterDate: dayJsFilterDate.toDate(),
formattedFilterDate: dayJsFilterDate.format(this.format),
mode: this.curSelectedMode
};
return re;
},
cellColHeaders: function cellColHeaders() {
var re = [];
var min = 1;
var max = 7;
for (var i = this.realFirstDayOfWeek; i <= max; i++) {
re.push({
num: i,
display: this.getWeekDisplay(i)
});
}
if (this.realFirstDayOfWeek > min) {
for (var _i = min; _i < this.realFirstDayOfWeek; _i++) {
re.push({
num: _i,
display: this.getWeekDisplay(_i)
});
}
}
return re;
},
yearSelectOptionList: function yearSelectOptionList() {
var re = [];
var begin = this.curSelectedYear - 10;
var end = this.curSelectedYear + 10;
if (this.rangeFromTo && this.rangeFromTo.from && this.rangeFromTo.to) {
begin = dayjs__default["default"](this.rangeFromTo.from).year();
end = dayjs__default["default"](this.rangeFromTo.to).year();
}
if (begin < calendar_const.MIN_YEAR) {
begin = calendar_const.MIN_YEAR;
}
if (end < calendar_const.MIN_YEAR) {
end = calendar_const.MIN_YEAR;
}
for (var i = begin; i <= end; i++) {
var disabled = this.checkMonthAndYearSelectorDisabled(i, this.curSelectedMonth);
re.push({
value: i,
label: this.t(this.global.yearSelection, {
year: i
}),
disabled: disabled
});
}
return re;
},
monthSelectOptionList: function monthSelectOptionList() {
var re = [];
for (var i = calendar_const.FIRST_MONTH_OF_YEAR; i <= calendar_const.LAST_MONTH_OF_YEAR; i++) {
var disabled = this.checkMonthAndYearSelectorDisabled(this.curSelectedYear, i);
re.push({
value: i,
label: this.t(this.global.monthSelection, {
month: i
}),
disabled: disabled
});
}
return re;
},
modeSelectOptionList: function modeSelectOptionList() {
return [{
value: "month",
label: this.t(this.global.monthRadio)
}, {
value: "year",
label: this.t(this.global.yearRadio)
}];
},
monthCellsData: function monthCellsData() {
var daysArr = calendar_utils.createMonthCellsData(this.props, this.state);
return daysArr;
},
yearCellsData: function yearCellsData() {
var re = [];
var monthsArr = calendar_utils.createYearCellsData(this.props, this.state);
var rowCount = Math.ceil(monthsArr.length / calendar_const.DEFAULT_YEAR_CELL_NUMINROW);
var index = 0;
for (var i = 1; i <= rowCount; i++) {
var row = [];
for (var j = 1; j <= calendar_const.DEFAULT_YEAR_CELL_NUMINROW; j++) {
row.push(monthsArr[index]);
index += 1;
}
re.push(row);
}
return re;
},
controllerConfigData: function controllerConfigData() {
var _ref, _this$controllerConfi;
var controllerConfig = (_ref = (_this$controllerConfi = this.controllerConfig) !== null && _this$controllerConfi !== void 0 ? _this$controllerConfi : this.global.controllerConfig) !== null && _ref !== void 0 ? _ref : true;
if (typeof controllerConfig === "boolean") {
return getDefaultControllerConfigData(controllerConfig);
}
return _objectSpread(_objectSpread({}, getDefaultControllerConfigData()), controllerConfig);
},
isControllerVisible: function isControllerVisible() {
return this.controllerConfigData && this.controllerConfigData.visible;
},
weekendBtnText: function weekendBtnText() {
return this.isShowWeekend ? this.TEXT_MAP.hideWeekend : this.TEXT_MAP.showWeekend;
},
weekendBtnVBind: function weekendBtnVBind() {
var c = this.controllerConfigData.weekend;
return this.isShowWeekend ? c.hideWeekendButtonProps : c.showWeekendButtonProps;
},
currentBtnText: function currentBtnText() {
return this.curSelectedMode === "month" ? this.TEXT_MAP.today : this.TEXT_MAP.thisMonth;
},
currentBtnVBind: function currentBtnVBind() {
var c = this.controllerConfigData.current;
return this.curSelectedMode === "month" ? c.currentDayButtonProps : c.currentMonthButtonProps;
},
isModeVisible: function isModeVisible() {
return this.checkControllerVisible("mode");
},
isYearVisible: function isYearVisible() {
return this.checkControllerVisible("year");
},
isMonthVisible: function isMonthVisible() {
return this.checkControllerVisible("month");
},
isWeekendToggleVisible: function isWeekendToggleVisible() {
return this.checkControllerVisible("weekend");
},
isCurrentBtnVisible: function isCurrentBtnVisible() {
return this.checkControllerVisible("current");
},
isModeDisabled: function isModeDisabled() {
return this.checkControllerDisabled("mode", "radioGroupProps");
},
isYearDisabled: function isYearDisabled() {
return this.checkControllerDisabled("year", "selectProps");
},
isMonthDisabled: function isMonthDisabled() {
return this.checkControllerDisabled("month", "selectProps");
},
isWeekendToggleDisabled: function isWeekendToggleDisabled() {
var p = this.isShowWeekend ? "hideWeekendButtonProps" : "showWeekendButtonProps";
return this.checkControllerDisabled("weekend", p);
},
isCurrentBtnDisabled: function isCurrentBtnDisabled() {
var p = this.curSelectedMode === "month" ? "currentDayButtonProps" : "currentMonthButtonProps";
return this.checkControllerDisabled("current", p);
},
filterYearStr: function filterYearStr() {
return "".concat(this.controllerOptions.filterDate.getFullYear());
},
filterMonthStr: function filterMonthStr() {
return "".concat(this.controllerOptions.filterDate.getMonth() + 1);
},
filterYearMonth: function filterYearMonth() {
return {
year: this.filterYearStr,
month: this.filterMonthStr
};
}
},
watch: {
firstDayOfWeek: {
handler: function handler() {
var _ref2, _this$firstDayOfWeek;
this.realFirstDayOfWeek = (_ref2 = (_this$firstDayOfWeek = this.firstDayOfWeek) !== null && _this$firstDayOfWeek !== void 0 ? _this$firstDayOfWeek : this.global.firstDayOfWeek) !== null && _ref2 !== void 0 ? _ref2 : 1;
},
immediate: true
},
value: {
handler: function handler(v) {
if (this.multiple) {
this.setCurrentDateList(v);
} else {
this.setCurrentDate(v);
}
},
immediate: true
},
year: {
handler: function handler(v) {
this.setCurSelectedYear(v);
},
immediate: true
},
month: {
handler: function handler(v) {
this.setCurSelectedMonth(v);
},
immediate: true
},
mode: {
handler: function handler(v) {
this.curSelectedMode = v;
},
immediate: true
},
isShowWeekendDefault: {
handler: function handler(v) {
this.isShowWeekend = v;
},
immediate: true
},
filterYearMonth: {
handler: function handler(v) {
utils_event.emitEvent(this, "month-change", v);
this.controllerChange();
}
},
curSelectedMode: function curSelectedMode() {
this.handleIE();
},
isShowWeekend: function isShowWeekend() {
this.handleIE();
},
isControllerVisible: function isControllerVisible() {
this.handleIE();
},
theme: {
handler: function handler(v) {
if (v === "card") this.controlSize = "small";
if (v === "full") this.controlSize = "medium";
},
immediate: true
}
},
mounted: function mounted() {
this.handleIE();
},
methods: {
handleIE: function handleIE() {
var _this = this;
if (_common_js_utils_helper.getIEVersion() <= 9) {
this.$nextTick(function () {
var element = _this.$el.children[_this.isControllerVisible ? 1 : 0];
if (_this.curSelectedMode === "month") {
element.setAttribute("is-show-weekend", "".concat(_this.isShowWeekend));
} else {
element.removeAttribute("is-show-weekend");
}
});
}
},
getCalendarWeekSlotData: function getCalendarWeekSlotData(item) {
return {
day: item.num
};
},
getWeekDisplay: function getWeekDisplay(weekNum) {
var weekText = this.weekDipalyText;
return _typeof__default["default"](weekText) === "object" && weekText[weekNum - 1] ? weekText[weekNum - 1] : calendar_utils.getDayCn(weekNum);
},
checkMonthCellItemShowed: function checkMonthCellItemShowed(cellData) {
return this.isShowWeekend || cellData.day < 6;
},
createCalendarCell: function createCalendarCell(cellData) {
return _objectSpread(_objectSpread({}, cellData), this.controllerOptions);
},
clickCell: function clickCell(e, cellData) {
var d = dayjs__default["default"](cellData.date);
if (this.multiple) {
if (this.curDateList.find(function (item) {
return item.isSame(d);
})) {
this.curDateList = remove(this.curDateList, function (item) {
return !item.isSame(d);
});
} else {
this.curDateList.push(d);
}
} else {
this.curDate = d;
}
var options = this.getCellClickEventOptions(e, cellData);
utils_event.emitEvent(this, "cell-click", options);
},
doubleClickCell: function doubleClickCell(e, cellData) {
var options = this.getCellClickEventOptions(e, cellData);
utils_event.emitEvent(this, "cell-double-click", options);
},
rightClickCell: function rightClickCell(e, cellData) {
if (this.preventCellContextmenu) {
e.preventDefault();
}
var options = this.getCellClickEventOptions(e, cellData);
utils_event.emitEvent(this, "cell-right-click", options);
},
getCellClickEventOptions: function getCellClickEventOptions(e, cellData) {
return {
cell: this.createCalendarCell(cellData),
e: e
};
},
controllerChange: function controllerChange() {
var options = this.controllerOptions;
utils_event.emitEvent(this, "controller-change", options);
},
onWeekendToggleClick: function onWeekendToggleClick() {
this.isShowWeekend = !this.isShowWeekend;
this.controllerChange();
},
checkMonthCellColHeaderVisibled: function checkMonthCellColHeaderVisibled(item) {
var re = true;
if (!this.isShowWeekend) {
re = item.num !== 6 && item.num !== 7;
}
return re;
},
checkControllerDisabled: function checkControllerDisabled(name, propsName) {
var re = false;
var conf = this.controllerConfigData;
if (conf && (conf.disabled || conf[name] && conf[name][propsName] && conf[name][propsName].disabled)) {
re = true;
}
return re;
},
checkControllerVisible: function checkControllerVisible(name) {
var re = true;
var conf = this.controllerConfigData;
if (!conf || !conf.visible || conf[name] === false || conf[name] && !conf[name].visible) {
re = false;
}
return re;
},
toToday: function toToday() {
var currentSelectDate = createDefaultCurDate();
this.curSelectedYear = currentSelectDate.year();
this.curSelectedMonth = parseInt(currentSelectDate.format("M"), 10);
},
setCurSelectedYear: function setCurSelectedYear(year) {
var curSelectedYear = year ? parseInt("".concat(year), 10) : createDefaultCurDate().year();
if (!isNaN(curSelectedYear) && curSelectedYear > 0) {
this.curSelectedYear = curSelectedYear;
}
},
setCurSelectedMonth: function setCurSelectedMonth(month) {
var curSelectedMonth = month ? parseInt("".concat(month), 10) : parseInt(createDefaultCurDate().format("M"), 10);
if (!isNaN(curSelectedMonth) && curSelectedMonth > 0 && curSelectedMonth <= 12) {
this.curSelectedMonth = curSelectedMonth;
}
},
setCurrentDate: function setCurrentDate(value) {
if (Array.isArray(value)) {
this.curDate = value && value.length ? dayjs__default["default"](value[0]) : createDefaultCurDate();
} else {
this.curDate = value ? dayjs__default["default"](value) : createDefaultCurDate();
}
},
setCurrentDateList: function setCurrentDateList(value) {
if (Array.isArray(value)) {
this.curDateList = value && value.length ? value.map(function (item) {
return dayjs__default["default"](item);
}) : [createDefaultCurDate()];
} else {
this.curDateList = value ? [dayjs__default["default"](value)] : [createDefaultCurDate()];
}
},
checkMonthAndYearSelectorDisabled: function checkMonthAndYearSelectorDisabled(year, month) {
var disabled = false;
if (this.rangeFromTo && this.rangeFromTo.from && this.rangeFromTo.to) {
var beginYear = dayjs__default["default"](this.rangeFromTo.from).year();
var endYear = dayjs__default["default"](this.rangeFromTo.to).year();
if (year === beginYear) {
var beginMon = parseInt(dayjs__default["default"](this.rangeFromTo.from).format("M"), 10);
disabled = month < beginMon;
} else if (year === endYear) {
var endMon = parseInt(dayjs__default["default"](this.rangeFromTo.to).format("M"), 10);
disabled = month > endMon;
}
}
return disabled;
},
renderControl: function renderControl() {
var _this2 = this;
var h = this.$createElement;
var controllerOptions = this.controllerOptions;
return h("div", {
"class": "".concat(this.componentName, "__control")
}, [h("div", {
"class": "".concat(this.componentName, "__title")
}, [utils_renderTnode.renderTNodeJSX(this, "head", {
params: controllerOptions
})]), h("div", {
"class": "".concat(this.componentName, "__control-section")
}, [this.isYearVisible && h("div", {
"class": "".concat(this.componentName, "__control-section-cell")
}, [h("t-select", helper.helper([{
"attrs": {
"size": this.controlSize,
"disabled": this.isYearDisabled,
"autoWidth": true
}
}, {
"props": _objectSpread({}, this.controllerConfigData.year.selectProps)
}, {
"model": {
value: _this2.curSelectedYear,
callback: function callback($$v) {
_this2.curSelectedYear = $$v;
}
}
}]), [this.yearSelectOptionList.map(function (item) {
return h("t-option", {
"key": item.value,
"attrs": {
"value": item.value,
"label": item.label,
"disabled": item.disabled
}
}, [item.label]);
})])]), this.curSelectedMode === "month" && this.isMonthVisible && h("div", {
"class": "".concat(this.componentName, "__control-section-cell")
}, [h("t-select", helper.helper([{
"attrs": {
"size": this.controlSize,
"disabled": this.isMonthDisabled,
"autoWidth": true
}
}, {
"props": _objectSpread({}, this.controllerConfigData.month.selectProps)
}, {
"model": {
value: _this2.curSelectedMonth,
callback: function callback($$v) {
_this2.curSelectedMonth = $$v;
}
}
}]), [this.monthSelectOptionList.map(function (item) {
return h("t-option", {
"key": item.value,
"attrs": {
"value": item.value,
"label": item.label,
"disabled": item.disabled
}
}, [item.label]);
})])]), this.isModeVisible && h("div", {
"class": "".concat(this.componentName, "__control-section-cell"),
"style": "height: auto"
}, [h("t-radio-group", helper.helper([{
"attrs": {
"variant": "default-filled",
"size": this.controlSize,
"disabled": this.isModeDisabled
}
}, {
"props": _objectSpread({}, this.controllerConfigData.mode.radioGroupProps)
}, {
"on": {
"change": this.controllerChange
},
"model": {
value: _this2.curSelectedMode,
callback: function callback($$v) {
_this2.curSelectedMode = $$v;
}
}
}]), [this.modeSelectOptionList.map(function (item) {
return h("t-radio-button", {
"key": item.value,
"attrs": {
"value": item.value
}
}, [item.label]);
})])]), this.theme === "full" && this.curSelectedMode === "month" && this.isWeekendToggleVisible && h("div", {
"class": "".concat(this.componentName, "__control-section-cell")
}, [h("t-check-tag", helper.helper([{
"class": "".concat(this.componentName, "__control-tag"),
"attrs": {
"defaultChecked": !this.isShowWeekend,
"disabled": this.isWeekendToggleDisabled,
"size": "large"
},
"on": {
"click": this.onWeekendToggleClick
}
}, {
"props": _objectSpread({}, this.weekendBtnVBind)
}]), [this.weekendBtnText])]), this.theme === "full" && this.isCurrentBtnVisible && h("div", {
"class": "".concat(this.componentName, "__control-section-cell")
}, [h("t-button", helper.helper([{
"attrs": {
"size": this.controlSize,
"disabled": this.isCurrentBtnDisabled
},
"on": {
"click": function click() {
_this2.toToday();
}
}
}, {
"props": _objectSpread({}, this.currentBtnVBind)
}]), [this.currentBtnText])])])]);
}
},
render: function render() {
var _this3 = this;
var h = arguments[0];
var calendarCls = this.calendarCls,
calendarPanelCls = this.calendarPanelCls,
isControllerVisible = this.isControllerVisible,
cellColHeaders = this.cellColHeaders,
checkMonthCellColHeaderVisibled = this.checkMonthCellColHeaderVisibled;
var monthBody = function monthBody() {
return h("table", {
"class": "".concat(_this3.componentName, "__table")
}, [h("thead", {
"class": "".concat(_this3.componentName, "__table-head")
}, [h("tr", {
"class": "".concat(_this3.componentName, "__table-head-row")
}, [cellColHeaders.map(function (item, index) {
return checkMonthCellColHeaderVisibled(item) && h("th", {
"class": "".concat(_this3.componentName, "__table-head-cell")
}, [Array.isArray(_this3.week) ? _this3.week[index] : utils_renderTnode.renderTNodeJSXDefault(_this3, "week", {
defaultNode: h("span", [item.display]),
params: _this3.getCalendarWeekSlotData(item)
})]);
})])]), h("tbody", {
"class": "".concat(_this3.componentName, "__table-body")
}, [_this3.monthCellsData.map(function (week, weekIndex) {
return h("tr", {
"class": "".concat(_this3.componentName, "__table-body-row")
}, [week.map(function (item, itemIndex) {
return _this3.checkMonthCellItemShowed(item) && h("calendar-cell-item", {
"key": "d-".concat(weekIndex, "-").concat(itemIndex),
"attrs": {
"item": item,
"theme": _this3.theme,
"t": _this3.t,
"global": _this3.global,
"cell": _this3.cell,
"fillWithZero": _this3.fillWithZero
},
"on": {
"click": function click(e) {
return _this3.clickCell(e, item);
},
"dblclick": function dblclick(e) {
return _this3.doubleClickCell(e, item);
},
"rightclick": function rightclick(e) {
return _this3.rightClickCell(e, item);
}
},
"scopedSlots": _objectSpread({}, _this3.$scopedSlots)
});
})]);
})])]);
};
var yearBody = function yearBody() {
return h("table", {
"class": "".concat(_this3.componentName, "__table")
}, [h("tbody", {
"class": "".concat(_this3.componentName, "__table-body")
}, [_this3.yearCellsData.map(function (cell, cellIndex) {
return h("tr", {
"class": "".concat(_this3.componentName, "__table-body-row")
}, [cell.map(function (item, itemIndex) {
return h("calendar-cell-item", {
"key": "m-".concat(cellIndex, "-").concat(itemIndex),
"attrs": {
"item": item,
"theme": _this3.theme,
"t": _this3.t,
"global": _this3.global,
"cell": _this3.cell,
"fillWithZero": _this3.fillWithZero
},
"on": {
"click": function click(e) {
return _this3.clickCell(e, item);
},
"dblclick": function dblclick(e) {
return _this3.doubleClickCell(e, item);
},
"rightclick": function rightclick(e) {
return _this3.rightClickCell(e, item);
}
},
"scopedSlots": _objectSpread({}, _this3.$scopedSlots)
});
})]);
})])]);
};
return h("div", {
"class": calendarCls
}, [isControllerVisible && this.renderControl(), h("div", {
"class": calendarPanelCls
}, [this.curSelectedMode === "month" ? monthBody() : yearBody()])]);
}
});
exports["default"] = _Calendar;
//# sourceMappingURL=calendar.js.map