@cqmcui/cqmcui
Version:
轻量级移动端 Vue2、Vue3 组件库(支持小程序开发)
280 lines (279 loc) • 7.73 kB
JavaScript
import { computed, ref, resolveComponent, openBlock, createBlock, withCtx, createSlots, renderSlot, createCommentVNode } from "vue";
import { c as createComponent } from "./component-81a4c1d0.js";
import { C as CalendarItem, U as Utils } from "./index-f933fcf6.js";
import { P as Popup } from "./index-c55ad69e.js";
import { u as useExpose } from "./index-79c5dc33.js";
import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
import "../locale/lang";
import "./raf-729dad54.js";
import "./Overlay.js";
import "@cqmcui/icons-vue";
const { create } = createComponent("calendar");
const _sfc_main = create({
components: {
[CalendarItem.name]: CalendarItem,
[Popup.name]: Popup
},
props: {
type: {
type: String,
default: "one"
},
isAutoBackFill: {
type: Boolean,
default: false
},
toDateAnimation: {
type: Boolean,
default: true
},
poppable: {
type: Boolean,
default: true
},
showTitle: {
type: Boolean,
default: true
},
showSubTitle: {
type: Boolean,
default: true
},
visible: {
type: Boolean,
default: false
},
showToday: {
type: Boolean,
default: true
},
title: {
type: String,
default: ""
},
confirmText: {
type: String,
default: ""
},
startText: {
type: String,
default: ""
},
endText: {
type: String,
default: ""
},
defaultValue: {
type: [String, Array]
},
startDate: {
type: String,
default: Utils.getDay(0)
},
endDate: {
type: String,
default: Utils.getDay(365)
},
firstDayOfWeek: {
type: Number,
default: 0,
validator: (val) => val >= 0 && val <= 6
}
},
emits: ["choose", "close", "update:visible", "select"],
setup(props, { emit, slots }) {
const showTopBtn = computed(() => {
return slots.btn;
});
const topInfo = computed(() => {
return slots["top-info"];
});
const dayInfo = computed(() => {
return slots.day;
});
const bottomInfo = computed(() => {
return slots["bottom-info"];
});
const calendarRef = ref(null);
const scrollToDate = (date) => {
var _a;
(_a = calendarRef.value) == null ? void 0 : _a.scrollToDate(date);
};
const initPosition = () => {
var _a;
(_a = calendarRef.value) == null ? void 0 : _a.initPosition();
};
useExpose({
scrollToDate,
initPosition
});
const update = () => {
emit("update:visible", false);
};
const close = () => {
emit("close");
emit("update:visible", false);
};
const choose = (param) => {
close();
emit("choose", param);
};
const select = (param) => {
emit("select", param);
};
const closePopup = () => {
close();
};
return {
closePopup,
update,
close,
choose,
select,
calendarRef,
showTopBtn,
topInfo,
dayInfo,
bottomInfo
};
}
});
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_nut_calendar_item = resolveComponent("cqmc-calendar-item");
const _component_nut_popup = resolveComponent("cqmc-popup");
return _ctx.poppable ? (openBlock(), createBlock(_component_nut_popup, {
key: 0,
visible: _ctx.visible,
position: "bottom",
round: "",
closeable: true,
onClickOverlay: _ctx.closePopup,
onClickCloseIcon: _ctx.closePopup,
"destroy-on-close": true,
style: { height: "85vh" }
}, {
default: withCtx(() => [
_ctx.visible ? (openBlock(), createBlock(_component_nut_calendar_item, {
key: 0,
props: "",
ref: "calendarRef",
type: _ctx.type,
"is-auto-back-fill": _ctx.isAutoBackFill,
poppable: _ctx.poppable,
title: _ctx.title,
"confirm-text": _ctx.confirmText,
"start-text": _ctx.startText,
"end-text": _ctx.endText,
"default-value": _ctx.defaultValue,
"start-date": _ctx.startDate,
"end-date": _ctx.endDate,
onUpdate: _ctx.update,
onClose: _ctx.close,
onChoose: _ctx.choose,
onSelect: _ctx.select,
"show-today": _ctx.showToday,
"show-title": _ctx.showTitle,
"show-sub-title": _ctx.showSubTitle,
"to-date-animation": _ctx.toDateAnimation,
"first-day-of-week": _ctx.firstDayOfWeek
}, createSlots({ _: 2 }, [
_ctx.showTopBtn ? {
name: "btn",
fn: withCtx(() => [
renderSlot(_ctx.$slots, "btn")
]),
key: "0"
} : void 0,
_ctx.dayInfo ? {
name: "day",
fn: withCtx((date) => [
renderSlot(_ctx.$slots, "day", {
date: date.date
})
]),
key: "1"
} : void 0,
_ctx.topInfo ? {
name: "top-info",
fn: withCtx((date) => [
renderSlot(_ctx.$slots, "top-info", {
date: date.date
})
]),
key: "2"
} : void 0,
_ctx.bottomInfo ? {
name: "bottom-info",
fn: withCtx((date) => [
renderSlot(_ctx.$slots, "bottom-info", {
date: date.date
})
]),
key: "3"
} : void 0
]), 1032, ["type", "is-auto-back-fill", "poppable", "title", "confirm-text", "start-text", "end-text", "default-value", "start-date", "end-date", "onUpdate", "onClose", "onChoose", "onSelect", "show-today", "show-title", "show-sub-title", "to-date-animation", "first-day-of-week"])) : createCommentVNode("", true)
]),
_: 3
}, 8, ["visible", "onClickOverlay", "onClickCloseIcon"])) : (openBlock(), createBlock(_component_nut_calendar_item, {
key: 1,
type: _ctx.type,
"is-auto-back-fill": _ctx.isAutoBackFill,
poppable: _ctx.poppable,
title: _ctx.title,
"confirm-text": _ctx.confirmText,
"start-text": _ctx.startText,
"end-text": _ctx.endText,
"default-value": _ctx.defaultValue,
"start-date": _ctx.startDate,
"end-date": _ctx.endDate,
onUpdate: _ctx.update,
onClose: _ctx.close,
onChoose: _ctx.choose,
onSelect: _ctx.select,
"show-today": _ctx.showToday,
"show-title": _ctx.showTitle,
"show-sub-title": _ctx.showSubTitle,
"to-date-animation": _ctx.toDateAnimation,
"first-day-of-week": _ctx.firstDayOfWeek,
ref: "calendarRef"
}, createSlots({ _: 2 }, [
_ctx.showTopBtn ? {
name: "btn",
fn: withCtx(() => [
renderSlot(_ctx.$slots, "btn")
]),
key: "0"
} : void 0,
_ctx.dayInfo ? {
name: "day",
fn: withCtx((date) => [
renderSlot(_ctx.$slots, "day", {
date: date.date
})
]),
key: "1"
} : void 0,
_ctx.topInfo ? {
name: "top-info",
fn: withCtx((date) => [
renderSlot(_ctx.$slots, "top-info", {
date: date.date
})
]),
key: "2"
} : void 0,
_ctx.bottomInfo ? {
name: "bottom-info",
fn: withCtx((date) => [
renderSlot(_ctx.$slots, "bottom-info", {
date: date.date
})
]),
key: "3"
} : void 0
]), 1032, ["type", "is-auto-back-fill", "poppable", "title", "confirm-text", "start-text", "end-text", "default-value", "start-date", "end-date", "onUpdate", "onClose", "onChoose", "onSelect", "show-today", "show-title", "show-sub-title", "to-date-animation", "first-day-of-week"]));
}
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
export {
index as default
};