UNPKG

comic-plus

Version:

<p align="center"> <img width="200px" src="./logo.png"/> </p>

305 lines (304 loc) 11.3 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); const vue = require("vue"); const type = require("./type.js"); require("../../../index2.js"); require("../../../icons/index.js"); const index = require("../../button-group/index.js"); const index$1 = require("../../button/index.js"); require("../../link/index.js"); require("../../container/index.js"); require("../../form/index.js"); require("../../form-item/index.js"); require("../../checkbox/index.js"); require("../../checkbox-group/index.js"); require("../../radio/index.js"); require("../../radio-button/index.js"); require("../../radio-group/index.js"); require("../../input/index.js"); require("../../input-number/index.js"); require("../../textarea/index.js"); require("../../switch/index.js"); require("../../slider/index.js"); require("../../select/index.js"); require("../../option/index.js"); require("../../option-group/index.js"); require("../../cascader/index.js"); require("../../time-picker/index.js"); require("../../date-picker/index.js"); require("../../color-picker/index.js"); require("../../upload/index.js"); require("../../tag/index.js"); require("../../tag-complex/index.js"); require("../../collapse/index.js"); require("../../collapse-item/index.js"); require("../../waterfall/index.js"); require("../../waterfall-item/index.js"); require("../../image/index.js"); require("../../badge/index.js"); require("../../carousel/index.js"); require("../../carousel-item/index.js"); require("../../progress/index.js"); require("../../card/index.js"); require("../../card-group/index.js"); require("../../empty/index.js"); require("../../ellipsis/index.js"); require("../../countdown/index.js"); require("../../pagination/index.js"); require("../../menu/index.js"); require("../../menu-item/index.js"); require("../../sub-menu/index.js"); require("../../tabs/index.js"); require("../../tab-pane/index.js"); require("../../elevator/index.js"); require("../../elevator-item/index.js"); require("../../backtop/index.js"); require("../../breadcrumb/index.js"); require("../../breadcrumb-item/index.js"); require("../../dialog/index.js"); require("../../drawer/index.js"); require("../../transition-collapse/index.js"); require("../../divider/index.js"); require("../../step/index.js"); require("../../step-item/index.js"); require("../../step-card/index.js"); require("../../scrollbar/index.js"); require("../../avatar/index.js"); require("../../avatar-group/index.js"); require("../../dropdown/index.js"); require("../../dropdown-menu/index.js"); require("../../dropdown-item/index.js"); require("../../tree/index.js"); require("../../atlas/index.js"); require("../../tip/index.js"); require("../../anchor/index.js"); require("../../anchor-link/index.js"); require("../../affix/index.js"); require("../../pistol/index.js"); require("../../bullet/index.js"); require("../../zone/index.js"); require("../../list/index.js"); require("../../list-item/index.js"); require("../../skeleton/index.js"); require("../../skeleton-item/index.js"); require("../../rate/index.js"); require("../../space/index.js"); require("../../clock/index.js"); require("../../web-footer/index.js"); require("../../timeline/index.js"); require("../../timeline-item/index.js"); require("../../calendar/index.js"); require("../index.js"); require("../../popover/index.js"); require("../../table/index.js"); require("../../table-column/index.js"); require("../../contextmenu/index.js"); require("../../watermark/index.js"); const components = require("../../../icons/components/components.js"); const _hoisted_1 = { class: "cu-schedule-calendar" }; const _hoisted_2 = { class: "cu-schedule-calendar__header" }; const _hoisted_3 = { class: "cu-schedule-calendar__table", cellspacing: "5", cellpadding: "5" }; const _hoisted_4 = { class: "cu-schedule-calendar__thead" }; const _hoisted_5 = { class: "cu-schedule-calendar__tr" }; const _hoisted_6 = { class: "cu-schedule-calendar__th" }; const _hoisted_7 = { class: "cu-schedule-calendar__tbody" }; const _hoisted_8 = { class: "cu-schedule-calendar__tr" }; const _hoisted_9 = ["onClick"]; const _hoisted_10 = { class: "cu-schedule-calendar__cell" }; const _hoisted_11 = { key: 0, class: "dot" }; const _hoisted_12 = { key: 0, class: "cu-schedule-calendar__extra" }; const _sfc_main = /* @__PURE__ */ vue.defineComponent({ ...{ name: "CuCalendar" }, __name: "calendar", setup(__props, { expose: __expose }) { const { date, props } = vue.inject(type.SCHEDULE_PROVIDE); const weeks = vue.ref([0, 1, 2, 3, 4, 5, 6]); const ty = vue.ref(); const tm = vue.ref(); const dn = vue.ref((/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0)); const weekForLang = { 0: "日", 1: "一", 2: "二", 3: "三", 4: "四", 5: "五", 6: "六" }; function setValue() { let time = new Date(dn.value); ty.value = time.getFullYear(); tm.value = time.getMonth(); } setValue(); const hasScheduleDays = vue.computed(() => { var _a; if (!props.hasScheduleDays) return []; return (_a = props.hasScheduleDays) == null ? void 0 : _a.map((v) => { return new Date(v).setHours(0, 0, 0, 0); }); }); const dates = vue.computed(() => { let tml = new Date(ty.value, tm.value + 1, 0).getDate(); let dl = Array.from({ length: tml }, (val, index2) => { return { isCurMonth: true, value: index2 + 1 }; }); let fd = new Date(ty.value, tm.value, 1).getDay(); let ld = new Date(ty.value, tm.value, 0).getDate(); let len, i; for (i = ld; i > ld - fd; --i) { dl.unshift({ isPrevMonth: true, value: i }); } for (i = 0, len = dl.length; i + len < 42; ++i) { dl.push({ isNextMonth: true, value: i + 1 }); } let result = []; for (var x = 0; x < Math.ceil(dl.length / 7); x++) { var start = x * 7; var end = start + 7; result.push(dl.slice(start, end)); } if (result[0].every((v) => v.isPrevMonth)) { result.shift(); } if (result[result.length - 1].every((v) => v.isNextMonth)) { result.pop(); } return result; }); function prevMonth() { if (props.loading) return; tm.value === 0 ? (--ty.value, tm.value = 11) : --tm.value; dn.value = new Date(ty.value, tm.value, 1).getTime(); } function nextMonth() { if (props.loading) return; tm.value === 11 ? (++ty.value, tm.value = 0) : ++tm.value; dn.value = new Date(ty.value, tm.value, 1).getTime(); } function prevYear() { ty.value--; dn.value = new Date(ty.value, tm.value, 1).getTime(); } function nextYear() { ty.value++; dn.value = new Date(ty.value, tm.value, 1).getTime(); } function today() { dn.value = (/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0); setValue(); } function isSelect(item) { let time = getTime(item); let f = new Date(dn.value).setHours(0, 0, 0, 0); return time === f; } function hasSchedule(item) { return hasScheduleDays.value.includes(getTime(item)); } function getTime(item) { let mon = tm.value; item.isPrevMonth && mon--; item.isNextMonth && mon++; return new Date(ty.value, mon, item.value).setHours(0, 0, 0, 0); } function selectDay(item) { if (props.loading) return; item.isPrevMonth ? tm.value === 0 ? (--ty.value, tm.value = 11) : --tm.value : item.isNextMonth ? tm.value === 11 ? (++ty.value, tm.value = 0) : ++tm.value : (ty.value, tm.value); dn.value = new Date(ty.value, tm.value, item.value).setHours(0, 0, 0, 0); } const dateTypeFn = { "prev-year": prevYear, "prev-month": prevMonth, today, "next-month": nextMonth, "next-year": nextYear }; function selectDate(value) { var _a; if (props.loading) return; if (value instanceof Date) { dn.value = new Date(value).setHours(0, 0, 0, 0); setValue(); } else if (value in dateTypeFn) { (_a = dateTypeFn[value]) == null ? void 0 : _a.call(dateTypeFn); } else { vue.warn("SelectDate can only pass in parameters in Date or specified string format"); return; } } vue.watch(dn, (val) => { date.value = new Date(val); }); __expose({ selectDate }); return (_ctx, _cache) => { return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [ vue.createElementVNode("div", _hoisted_2, [ vue.createElementVNode("span", null, vue.toDisplayString(ty.value + "年 " + (tm.value + 1) + "月"), 1), vue.createVNode(vue.unref(index.CuButtonGroup), { size: "small" }, { default: vue.withCtx(() => [ vue.createVNode(vue.unref(index$1.CuButton), { color: "#acadad", light: "", icon: vue.unref(components.Left), onClick: prevMonth }, null, 8, ["icon"]), vue.createVNode(vue.unref(index$1.CuButton), { color: "#acadad", light: "", icon: vue.unref(components.Right), onClick: nextMonth }, null, 8, ["icon"]) ]), _: 1 }) ]), vue.createElementVNode("table", _hoisted_3, [ vue.createElementVNode("thead", _hoisted_4, [ vue.createElementVNode("tr", _hoisted_5, [ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(weeks.value, (week) => { return vue.openBlock(), vue.createElementBlock("th", _hoisted_6, vue.toDisplayString(weekForLang[week]), 1); }), 256)) ]) ]), vue.createElementVNode("tbody", _hoisted_7, [ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(dates.value, (week) => { return vue.openBlock(), vue.createElementBlock("tr", _hoisted_8, [ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(week, (day) => { return vue.openBlock(), vue.createElementBlock("td", { class: vue.normalizeClass(["cu-schedule-calendar__td", { "is-prev": day.isPrevMonth, "is-next": day.isNextMonth, "is-today": isSelect(day) }]), onClick: ($event) => selectDay(day) }, [ vue.createElementVNode("div", _hoisted_10, [ hasSchedule(day) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_11)) : vue.createCommentVNode("", true), vue.createTextVNode(" " + vue.toDisplayString(day.value), 1) ]) ], 10, _hoisted_9); }), 256)) ]); }), 256)) ]) ]), _ctx.$slots.calendar ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_12, [ vue.renderSlot(_ctx.$slots, "calendar") ])) : vue.createCommentVNode("", true) ]); }; } }); exports.default = _sfc_main;