"use strict"; const common_vendor = require("../../../../common/vendor.js"); require("../../../adapter-vue.js"); const common_assets = require("../../../../common/assets.js"); const TUIKit_utils_env = require("../../../utils/env.js"); if (!Math) { (Icon + DateTable)(); } const DateTable = () => "./date-table.js"; const Icon = () => "../Icon.js"; const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({ __name: "date-picker-panel", props: { type: { type: String, default: "range" // "single"/"range" }, // Unique attribute when type is single date: { type: common_vendor.dayjs_minExports.Dayjs, default: () => common_vendor.dayjs() }, // Unique attribute when type is range startDate: { type: common_vendor.dayjs_minExports.Dayjs, default: null }, endDate: { type: common_vendor.dayjs_minExports.Dayjs, default: null }, rangeType: { type: String, default: "" // "left"/"right" }, currentOtherPanelValue: { type: common_vendor.dayjs_minExports.Dayjs, default: null } }, emits: ["pick", "change"], setup(__props, { emit: __emit }) { const props = __props; const emit = __emit; const n = (className) => { return className ? [ "tui-date-picker-panel-" + className, !TUIKit_utils_env.isPC && "tui-date-picker-panel-h5-" + className ] : ["tui-date-picker-panel", !TUIKit_utils_env.isPC && "tui-date-picker-panel-h5"]; }; const currentPanelDate = common_vendor.ref(); const year = common_vendor.computed(() => { var _a; return (_a = currentPanelDate.value) == null ? void 0 : _a.get("year"); }); const month = common_vendor.computed(() => { var _a; return (_a = currentPanelDate.value) == null ? void 0 : _a.format("MMMM"); }); const canYearMore = common_vendor.computed(() => { var _a, _b, _c; const prevYearNumber = ((_a = props.currentOtherPanelValue) == null ? void 0 : _a.year()) - 1; const prevYear = (_b = props.currentOtherPanelValue) == null ? void 0 : _b.year(prevYearNumber); return props.rangeType === "right" || ((_c = currentPanelDate.value) == null ? void 0 : _c.isBefore(prevYear, "year")); }); const canMonthMore = common_vendor.computed(() => { var _a, _b, _c; const prevMonthNumber = ((_a = props.currentOtherPanelValue) == null ? void 0 : _a.month()) - 1; const prevMonth = (_b = props.currentOtherPanelValue) == null ? void 0 : _b.month(prevMonthNumber); return props.rangeType === "right" || ((_c = currentPanelDate.value) == null ? void 0 : _c.isBefore(prevMonth, "month")); }); const canYearLess = common_vendor.computed(() => { var _a, _b, _c; const nextYearNumber = ((_a = props.currentOtherPanelValue) == null ? void 0 : _a.year()) + 1; const nextYear = (_b = props.currentOtherPanelValue) == null ? void 0 : _b.year(nextYearNumber); return props.rangeType === "left" || ((_c = currentPanelDate.value) == null ? void 0 : _c.isAfter(nextYear, "year")); }); const canMonthLess = common_vendor.computed(() => { var _a, _b, _c; const nextMonthNumber = ((_a = props.currentOtherPanelValue) == null ? void 0 : _a.month()) + 1; const nextMonth = (_b = props.currentOtherPanelValue) == null ? void 0 : _b.month(nextMonthNumber); return props.rangeType === "left" || ((_c = currentPanelDate.value) == null ? void 0 : _c.isAfter(nextMonth, "month")); }); const handleSingleDate = () => { var _a; if (props.date && ((_a = common_vendor.dayjs(props.date)) == null ? void 0 : _a.isValid())) { return { date: props == null ? void 0 : props.date }; } return { date: common_vendor.dayjs() }; }; const handleRangeDate = () => { var _a; switch (props.rangeType) { case "left": if (props.startDate && common_vendor.dayjs.isDayjs(props.startDate)) { return { date: props == null ? void 0 : props.startDate }; } else { return { date: common_vendor.dayjs() }; } case "right": if (props.endDate && common_vendor.dayjs.isDayjs(props.endDate) && ((_a = props == null ? void 0 : props.endDate) == null ? void 0 : _a.isAfter(props.startDate, "month"))) { return { date: props == null ? void 0 : props.endDate }; } else { const _month = (props.startDate || common_vendor.dayjs()).month(); return { date: (props.startDate || common_vendor.dayjs()).month(_month + 1) }; } default: return { date: common_vendor.dayjs() }; } }; function handlePick(cell) { emit("pick", cell); } function change(type, num) { currentPanelDate.value = common_vendor.dayjs(currentPanelDate.value.toDate()).add( num, type ); emit("change", currentPanelDate.value); } common_vendor.onBeforeMount(() => { switch (props.type) { case "single": currentPanelDate.value = handleSingleDate().date; emit("change", currentPanelDate.value); break; case "range": currentPanelDate.value = handleRangeDate().date; emit("change", currentPanelDate.value); break; } }); return (_ctx, _cache) => { return common_vendor.e({ a: common_vendor.unref(canYearLess) }, common_vendor.unref(canYearLess) ? { b: common_vendor.p({ file: common_vendor.unref(common_assets.dLeftArrowIcon), width: "12px", height: "12px" }), c: common_vendor.n(n("icon")), d: common_vendor.o$1(($event) => change("year", -1)) } : {}, { e: common_vendor.unref(canMonthLess) }, common_vendor.unref(canMonthLess) ? { f: common_vendor.p({ file: common_vendor.unref(common_assets.leftArrowIcon), width: "10px", height: "10px" }), g: common_vendor.n(n("icon")), h: common_vendor.o$1(($event) => change("month", -1)) } : {}, { i: common_vendor.n(n("body-header-prev")), j: common_vendor.t(common_vendor.unref(year)), k: common_vendor.n(n("body-header-label-item")), l: common_vendor.t(common_vendor.unref(common_vendor.Wt).t(`time.${common_vendor.unref(month)}`)), m: common_vendor.n(n("body-header-label-item")), n: common_vendor.n(n("body-header-label")), o: common_vendor.unref(canMonthMore) }, common_vendor.unref(canMonthMore) ? { p: common_vendor.p({ file: common_vendor.unref(common_assets.rightArrowIcon), width: "10px", height: "10px" }), q: common_vendor.n(n("icon")), r: common_vendor.o$1(($event) => change("month", 1)) } : {}, { s: common_vendor.unref(canYearMore) }, common_vendor.unref(canYearMore) ? { t: common_vendor.p({ file: common_vendor.unref(common_assets.dRightArrowIcon), width: "12px", height: "12px" }), v: common_vendor.n(n("icon")), w: common_vendor.o$1(($event) => change("year", 1)) } : {}, { x: common_vendor.n(n("body-header-next")), y: common_vendor.n(n("body-header")), z: common_vendor.o$1(handlePick), A: common_vendor.p({ type: props.type, date: props.date, startDate: props.startDate, endDate: props.endDate, currentPanelDate: common_vendor.unref(currentPanelDate) }), B: common_vendor.n(n("body-content")), C: common_vendor.n(n("body")), D: common_vendor.n(n("")), E: common_vendor.o$1(() => { }) }); }; } }); const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-389108a1"]]); wx.createComponent(Component); //# sourceMappingURL=../../../../../.sourcemap/mp-weixin/TUIKit/components/common/DatePicker/date-picker-panel.js.map