UNPKG

@layui/layui-vue

Version:

a component library for Vue 3 base on layui-vue

19 lines (18 loc) 2.14 kB
import { defineComponent as P, computed as C, inject as D, openBlock as n, createElementBlock as s, createElementVNode as u, Fragment as y, renderList as m, toDisplayString as f, normalizeClass as b, unref as x } from "vue"; import r from "dayjs"; import { useI18n as L } from "../../../language/index.js"; import { DATE_PICKER_CONTEXT as E } from "../../interface.js"; const V = { class: "layui-laydate-content" }, _ = { style: { width: "100%" } }, B = ["data-unix", "onClick", "onMouseenter"], I = P({ 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 } = L(), v = C(() => [l("datePicker.sunday"), l("datePicker.monday"), l("datePicker.tuesday"), l("datePicker.wednesday"), l("datePicker.thursday"), l("datePicker.friday"), l("datePicker.saturday")]), a = D(E); function i(e) { return !(e.type === "current" || !a.range) || (a.disabledDate ? a.disabledDate(r(e.value).toDate()) : !(!a.min || !r(e.value).isBefore(r(a.min), "day")) || !(!a.max || !r(e.value).isAfter(r(a.max), "day"))); } return (e, O) => (n(), s("div", V, [u("table", _, [u("thead", null, [u("tr", null, [(n(!0), s(y, null, m(v.value, (o) => (n(), s("th", { key: o }, f(o), 1))), 128))])]), u("tbody", null, [(n(!0), s(y, null, m(e.dateList.length % 7 == 0 ? e.dateList.length / 7 : Math.floor(e.dateList.length / 7) + 1, (o, c) => (n(), s("tr", { key: c }, [(n(!0), s(y, null, m(e.dateList.slice(7 * c, 7 * c + 7), (t, h) => (n(), s("td", { key: h, "data-unix": t.value, class: b({ "laydate-day-prev": t.type !== "current", "layui-this": t.value === e.modelValue, "layui-disabled": i(t), "layui-laydate-current": t.value === x(r)().startOf("day").valueOf(), ...e.classes(t) }), onClick: (g) => function(d) { i(d) || a.range && d.type !== "current" || p("update:modelValue", d.value); }(t), onMouseenter: (g) => function(d) { a.range && !i(d) && p("hover-cell", d.value); }(t) }, f(t.day), 43, B))), 128))]))), 128))])])])); } }); export { I as default };