UNPKG

comic-plus

Version:

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

148 lines (147 loc) 5.49 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); const vue = require("vue"); const type = require("./type.js"); const card_vue_vue_type_script_setup_true_lang = require("./card.vue.js"); require("../../../utils/config.js"); const tools = require("../../../utils/tools.js"); require("@vueuse/core"); require("../../../icons/index.js"); const components = require("../../../icons/components/components.js"); const _hoisted_1 = { class: "cu-schedule-content" }; const _hoisted_2 = { class: "cu-schedule-list--warpper" }; const _hoisted_3 = { class: "cu-schedule-list" }; const _hoisted_4 = { key: 0, class: "cu-schedule-list__time" }; const _hoisted_5 = { key: 1, class: "cu-schedule-list__line" }; const _hoisted_6 = { key: 0, class: "cu-schedule-empty" }; const _hoisted_7 = { class: "loading-mask" }; const flag = 100 / 60; const _sfc_main = /* @__PURE__ */ vue.defineComponent({ __name: "content", setup(__props) { const { date, props, spacing } = vue.inject(type.SCHEDULE_PROVIDE); const timeList = vue.computed(() => { let result = []; let i = props.start; do { if (i > 23) { i -= 24; } result.push({ key: i, timeTemp: date.value.setHours(i, 0, 0, 0) }); i++; if (i === 24) { i = 0; } } while (!(i === props.end + 1)); return result; }); function getNumber(t) { let t1 = Math.floor(t); let t2 = t % 1 * flag; return t1 + t2; } const cardForArr = vue.computed(() => { let arr = props.schedules.map((v, index) => { return { ...v, _index: index, color: props.cardColor ? v.color ?? tools.randomColor() : void 0, getTimes: v.time.split(props.separator).map((v2) => { return getNumber(Number(v2.replace(/:/g, "."))); }) }; }).sort((a, b) => a.getTimes[0] - b.getTimes[0]); let chunkArr = []; if (arr.length > 0) { chunkArr = [ { startTime: arr[0].getTimes[0], endTime: arr[0].getTimes[1], children: [arr[0]] } ]; for (let i = 1; i < arr.length; i++) { let item = arr[i]; let last = chunkArr[chunkArr.length - 1]; if (item.getTimes[0] < last.endTime) { last.children.push(item); last.endTime = Math.max(last.endTime, item.getTimes[1]); } else { chunkArr.push({ startTime: item.getTimes[0], endTime: item.getTimes[1], children: [item] }); } } } return chunkArr; }); return (_ctx, _cache) => { return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [ vue.createElementVNode("div", _hoisted_2, [ vue.createElementVNode("ul", _hoisted_3, [ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(timeList.value, (el) => { return vue.openBlock(), vue.createElementBlock("li", { class: "cu-schedule-list__li", style: vue.normalizeStyle({ height: vue.unref(spacing) + "px" }) }, [ vue.unref(props).showTime ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_4, [ vue.createElementVNode("span", null, vue.toDisplayString((el.key < 10 ? "0" + el.key : el.key) + ":00"), 1) ])) : vue.createCommentVNode("", true), vue.unref(props).showLine ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_5)) : vue.createCommentVNode("", true) ], 4); }), 256)) ]), vue.createElementVNode("div", { class: "cu-schedule-cards--warpper", style: vue.normalizeStyle({ paddingLeft: vue.unref(props).showTime ? void 0 : "0" }) }, [ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(cardForArr.value, (item, idx) => { return vue.openBlock(), vue.createBlock(card_vue_vue_type_script_setup_true_lang.default, { data: item, key: idx }, vue.createSlots({ _: 2 }, [ _ctx.$slots["card"] ? { name: "card", fn: vue.withCtx(({ data }) => [ vue.renderSlot(_ctx.$slots, "card", { data }) ]), key: "0" } : void 0 ]), 1032, ["data"]); }), 128)) ], 4) ]), vue.unref(props).showEmpty && cardForArr.value.length === 0 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_6, [ vue.renderSlot(_ctx.$slots, "empty", { date: vue.unref(date) }, () => [ vue.createTextVNode(vue.toDisplayString(vue.unref(props).emptyText), 1) ]) ])) : vue.createCommentVNode("", true), vue.createVNode(vue.Transition, { name: "cu-fade" }, { default: vue.withCtx(() => [ vue.withDirectives(vue.createElementVNode("div", _hoisted_7, [ vue.createVNode(vue.unref(components.Loading), { class: "is-loading" }) ], 512), [ [vue.vShow, vue.unref(props).loading] ]) ]), _: 1 }) ]); }; } }); exports.default = _sfc_main;