@layui/layui-vue
Version:
a component library for Vue 3 base on layui-vue
20 lines (19 loc) • 2.35 kB
JavaScript
import { defineComponent as g, computed as P, inject as D, openBlock as n, createElementBlock as d, createElementVNode as u, Fragment as y, renderList as m, toDisplayString as f, normalizeClass as L, unref as v, createVNode as V, withCtx as b, createTextVNode as E } from "vue";
import { useI18n as _ } from "../../../language/index.js";
import s from "dayjs";
import { DATE_PICKER_CONTEXT as j } from "../../interface.js";
import N from "./DatePickerRender.js";
const T = { class: "layui-laydate-content" }, w = { style: { width: "100%" } }, B = ["data-unix", "onClick", "onMouseenter"], R = g({ name: "DateContent", __name: "DateContent", props: { dateList: {}, modelValue: { default: -1 }, classes: { type: Function, default: () => ({}) } }, emits: ["update:modelValue", "hover-cell"], setup(M, { emit: k }) {
const p = k, { t: l } = _(), h = P(() => [l("datePicker.sunday"), l("datePicker.monday"), l("datePicker.tuesday"), l("datePicker.wednesday"), l("datePicker.thursday"), l("datePicker.friday"), l("datePicker.saturday")]), t = D(j);
function i(e) {
return !(e.type === "current" || !t.range) || (t.disabledDate ? t.disabledDate(s(e.value).toDate()) : !(!t.min || !s(e.value).isBefore(s(t.min), "day")) || !(!t.max || !s(e.value).isAfter(s(t.max), "day")));
}
return (e, O) => (n(), d("div", T, [u("table", w, [u("thead", null, [u("tr", null, [(n(!0), d(y, null, m(h.value, (o) => (n(), d("th", { key: o }, f(o), 1))), 128))])]), u("tbody", null, [(n(!0), d(y, null, m(e.dateList.length % 7 == 0 ? e.dateList.length / 7 : Math.floor(e.dateList.length / 7) + 1, (o, c) => (n(), d("tr", { key: c }, [(n(!0), d(y, null, m(e.dateList.slice(7 * c, 7 * c + 7), (a, x) => (n(), d("td", { key: x, "data-unix": a.value, class: L({ "laydate-day-prev": a.type !== "current", "layui-this": a.value === e.modelValue, "layui-disabled": i(a), "layui-laydate-current": a.value === v(s)().startOf("day").valueOf(), ...e.classes(a) }), onClick: (C) => function(r) {
i(r) || t.range && r.type !== "current" || p("update:modelValue", r.value);
}(a), onMouseenter: (C) => function(r) {
t.range && !i(r) && p("hover-cell", r.value);
}(a) }, [V(N, { type: "date", unix: a.value, dayjs: v(s)(a.value) }, { default: b(() => [E(f(a.day), 1)]), _: 2 }, 1032, ["unix", "dayjs"])], 42, B))), 128))]))), 128))])])]));
} });
export {
R as default
};