"use strict"; const common_vendor = require("../../../../common/vendor.js"); require("../../../adapter-vue.js"); const TUIKit_utils_env = require("../../../utils/env.js"); const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({ __name: "date-table", props: { type: { type: String, default: "range" // "single"/"range" }, currentPanelDate: { type: common_vendor.dayjs_minExports.Dayjs, default: () => common_vendor.dayjs() }, // Unique attribute when type is single date: { type: common_vendor.dayjs_minExports.Dayjs, default: null }, // Unique attribute when type is range startDate: { type: common_vendor.dayjs_minExports.Dayjs, default: null }, endDate: { type: common_vendor.dayjs_minExports.Dayjs, default: null } }, emits: ["pick"], setup(__props, { emit: __emit }) { const props = __props; const emit = __emit; const instance = common_vendor.getCurrentInstance(); const tableRows = common_vendor.ref([[], [], [], [], [], []]); const currentPanelDateObject = common_vendor.ref( common_vendor.dayjs(props.currentPanelDate || null) ); const dateObject = common_vendor.ref(common_vendor.dayjs(props.date || null)); const startDateObject = common_vendor.ref(common_vendor.dayjs(props.startDate || null)); const endDateObject = common_vendor.ref(common_vendor.dayjs(props.endDate || null)); const WEEKS_CONSTANT = common_vendor.computed(() => { return common_vendor.dayjs.weekdaysShort(); }); const WEEKS = common_vendor.computed( () => WEEKS_CONSTANT.value.map((w) => w.substring(1)) ); const startDateOnTable = common_vendor.computed(() => { var _a; const startDayOfMonth = (_a = currentPanelDateObject.value) == null ? void 0 : _a.startOf("month"); return startDayOfMonth == null ? void 0 : startDayOfMonth.subtract((startDayOfMonth == null ? void 0 : startDayOfMonth.day()) || 7, "day"); }); const rows = common_vendor.computed(() => { var _a, _b, _c, _d, _e; const rows_ = tableRows.value; const cols = WEEKS.value.length; const startOfMonth = (_a = currentPanelDateObject.value) == null ? void 0 : _a.startOf("month"); const startOfMonthDay = (startOfMonth == null ? void 0 : startOfMonth.day()) || 7; const dateCountOfMonth = startOfMonth == null ? void 0 : startOfMonth.daysInMonth(); let count = 1; for (let row = 0; row < tableRows.value.length; row++) { for (let col = 0; col < cols; col++) { const cellDate = (_b = startDateOnTable.value) == null ? void 0 : _b.add(count, "day"); const text = cellDate == null ? void 0 : cellDate.date(); const isSelected = props.type === "single" && (cellDate == null ? void 0 : cellDate.format("YYYY-MM-DD")) === ((_c = dateObject.value) == null ? void 0 : _c.format("YYYY-MM-DD")); const isSelectedStart = props.type === "range" && (cellDate == null ? void 0 : cellDate.format("YYYY-MM-DD")) === ((_d = startDateObject.value) == null ? void 0 : _d.format("YYYY-MM-DD")); const isSelectedEnd = props.type === "range" && (cellDate == null ? void 0 : cellDate.format("YYYY-MM-DD")) === ((_e = endDateObject.value) == null ? void 0 : _e.format("YYYY-MM-DD")); const isInRange = (cellDate == null ? void 0 : cellDate.isSameOrBefore(endDateObject.value, "day")) && (cellDate == null ? void 0 : cellDate.isSameOrAfter(startDateObject.value, "day")); let type = "normal"; if (count < startOfMonthDay) { type = "prev-month"; } else if (count - startOfMonthDay >= dateCountOfMonth) { type = "next-month"; } rows_[row][col] = { type, date: cellDate, text, isSelected: isSelected || isSelectedStart || isSelectedEnd, isSelectedStart, isSelectedEnd, isInRange }; count++; } } return rows_; }); const handlePick = (cell) => { if ((cell == null ? void 0 : cell.type) !== "normal") { return; } emit("pick", cell); }; common_vendor.watch( () => [props.currentPanelDate, props.date, props.startDate, props.endDate], () => { currentPanelDateObject.value = common_vendor.dayjs(props.currentPanelDate || null); dateObject.value = common_vendor.dayjs(props.date || null); startDateObject.value = common_vendor.dayjs(props.startDate || null); endDateObject.value = common_vendor.dayjs(props.endDate || null); common_vendor.nextTick$1(() => { var _a; (_a = instance == null ? void 0 : instance.proxy) == null ? void 0 : _a.$forceUpdate(); }); }, { deep: true, immediate: true } ); return (_ctx, _cache) => { return { a: common_vendor.f(common_vendor.unref(WEEKS), (item, k0, i0) => { return { a: common_vendor.t(common_vendor.unref(common_vendor.Wt).t(`time.${item}`)), b: item, c: item + "" }; }), b: common_vendor.f(common_vendor.unref(rows), (row, rowKey, i0) => { return { a: common_vendor.f(row, (col, colKey, i1) => { return { a: common_vendor.t(col.text), b: common_vendor.n(col.isSelected && "selected"), c: common_vendor.n(col.isSelectedStart && "selected-start"), d: common_vendor.n(col.isSelectedEnd && "selected-end"), e: common_vendor.n(col.isInRange && "range"), f: common_vendor.o$1(($event) => handlePick(col), colKey), g: colKey, h: common_vendor.n(col.type) }; }), b: rowKey }; }), c: common_vendor.n(!common_vendor.unref(TUIKit_utils_env.isPC) && "tui-date-table-h5") }; }; } }); const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-0072a759"]]); wx.createComponent(Component); //# sourceMappingURL=../../../../../.sourcemap/mp-weixin/TUIKit/components/common/DatePicker/date-table.js.map