tyh-ui2
Version:
The next generation ui component library of tyh-ui is based on vue3 Version, fully embrace vue3.
133 lines (132 loc) • 4.68 kB
JavaScript
import { defineComponent as k, ref as g, computed as h, openBlock as n, createElementBlock as a, createElementVNode as m, normalizeStyle as p, unref as r, toDisplayString as s, createVNode as d, withCtx as B, Fragment as y, renderList as f } from "vue";
import { Props as S } from "./index2.js";
import "../../button/index.js";
import "../../list/index.js";
import "../../card/index.js";
import "../../tag/index.js";
import "../../link/index.js";
import "../../menu/index.js";
import "../../menu-item/index.js";
import "../../division/index.js";
import "../../icon/index.js";
import "../../crumbs/index.js";
import "../../crumbs-item/index.js";
import "../../input/index.js";
import "../../back-top/index.js";
import "../../skeleton/index.js";
import "../../alert/index.js";
import "../../rate/index.js";
import "../../image/index.js";
import "../../avatar/index.js";
import "../../aside/index.js";
import "../../container/index.js";
import "../../footer/index.js";
import "../../header/index.js";
import "../../main/index.js";
import "../../text/index.js";
import "../../table/index.js";
import "../../button-group/index.js";
import "../index.js";
import "../../switch/index.js";
import "../../radio/index.js";
import "../../tree/index.js";
import "../../page-header/index.js";
import "../../info/index.js";
import "../../textarea/index.js";
import "../../select/index.js";
import "../../option/index.js";
import "../../tagging/index.js";
import "../../drawer/index.js";
import "../../dialog/index.js";
import "../../message/src/index.js";
import "../../notification/src/index.js";
import F from "../../button-group/index2.js";
import v from "../../button/src/index.js";
const N = { class: "tyh-calendar" }, Y = { class: "tyh-calendar-header" }, b = { class: "tyh-calendar-isDay" }, T = { class: "tyh-calendar-week" }, G = { class: "tyh-calendar-month" }, I = k({
name: "TyhCalendar"
}), xt = /* @__PURE__ */ k({
...I,
props: S,
setup(w) {
const o = w, e = g(o.modelValue.getMonth()), l = g(o.modelValue.getFullYear()), D = o.modelValue.getDate(), E = h(() => {
const t = new Date(
`${l.value}/${e.value + 1}/1`
).getDay();
return t === 0 ? 7 - 1 : t - 1;
}), z = (t = e.value, u) => t !== 1 ? [31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][t] : u % 4 == 0 && u % 100 != 0 || u % 400 == 0 ? 29 : 28, C = () => {
if (e.value > 0) {
e.value--;
return;
}
l.value--, e.value = 11;
}, V = () => {
if (e.value < 11) {
e.value++;
return;
}
l.value++, e.value = 0;
}, W = () => {
e.value = o.modelValue.getMonth(), l.value = o.modelValue.getFullYear();
}, $ = (t) => ["\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D", "\u65E5"][t - 1], M = (t) => t + 1 === o.modelValue.getDate() ? {
backgroundColor: "#3a6ff4",
color: "#fff"
} : {}, x = h(() => ({ width: `${((o.cellWidth < 28 ? 28 : o.cellWidth) + 2) * 7}px` })), _ = h(() => {
const t = o.cellWidth < 28 ? 28 : o.cellWidth;
return { width: `${t}px`, height: `${t}px` };
});
return (t, u) => (n(), a("span", N, [
m("div", {
class: "tyh-calendar-container",
style: p(r(x))
}, [
m("div", Y, [
m("span", b, s(l.value) + "\u5E74 " + s(e.value + 1) + "\u6708 " + s(r(D)) + "\u65E5 ", 1),
d(r(F), null, {
default: B(() => [
d(r(v), {
size: "mini",
icon: "tyh-ui-arrow-left-bold",
onClick: C
}),
d(r(v), {
size: "mini",
simple: "",
type: "primary",
icon: "tyh-ui-time",
onClick: W
}),
d(r(v), {
size: "mini",
icon: "tyh-ui-arrow-right",
onClick: V
})
]),
_: 1
})
]),
m("tr", T, [
(n(), a(y, null, f(7, (c, i) => m("td", {
key: i,
class: "tyh-calendar-week-item",
style: p({ width: `${t.cellWidth < 28 ? 28 : t.cellWidth}px` })
}, s($(c)), 5)), 64))
]),
m("tr", G, [
(n(!0), a(y, null, f(r(E), (c, i) => (n(), a("td", {
key: i,
class: "tyh-calendar-day",
style: p(r(_))
}, null, 4))), 128)),
(n(!0), a(y, null, f(z(e.value, l.value), (c, i) => (n(), a("td", {
key: i,
class: "tyh-calendar-day",
style: p([M(i), r(_)])
}, s(i + 1), 5))), 128))
])
], 4)
]));
}
});
export {
xt as default
};