UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,685 lines (1,684 loc) 96.2 kB
var xt = Object.defineProperty; var Ft = (e, t, n) => t in e ? xt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n; var Be = (e, t, n) => Ft(e, typeof t != "symbol" ? t + "" : t, n); import { defineComponent as ee, ref as B, watch as Y, computed as A, createVNode as l, inject as le, nextTick as Ve, onMounted as ie, createTextVNode as se, provide as Et, onUnmounted as It, Fragment as Ae } from "vue"; import { resolveAppearance as Vt, createPropsResolver as Nt, getPropsResolverGenerator as Ot } from "../dynamic-resolver/index.esm.js"; import { DgControl as ye, useDesignerComponent as Pt } from "../designer-canvas/index.esm.js"; import { cloneDeep as ce, isFunction as Te, isPlainObject as $e } from "lodash-es"; import { resolveField as K, useDateFormat as Wt, useResizeObserver as Re, getCustomClass as Lt, getCustomStyle as jt } from "../common/index.esm.js"; import Bt from "../popover/index.esm.js"; import { LocaleService as $t } from "../locale/index.esm.js"; import { BaseControlProperty as Rt } from "../property-panel/index.esm.js"; const ze = /* @__PURE__ */ new Map([ ["appearance", Vt] ]), At = "root-viewmodel"; function zt(e, t) { const { formSchemaUtils: n, designViewModelUtils: o } = t; function m(f) { return { id: `${f.componentId}-component-viewmodel`, code: `${f.componentId}-component-viewmodel`, name: f.componentName, bindTo: f.bindTo, parent: At, fields: [], commands: [], states: [], enableValidation: !0 }; } function w(f) { const a = e.getSchemaByType("component-ref"); return Object.assign(a, { id: `${f.componentId}-component-ref`, component: `${f.componentId}-component` }), a; } function p(f, a, c) { var v, u, E, s; const y = (u = (v = a == null ? void 0 : a.parentComponentInstance) == null ? void 0 : v.schema) == null ? void 0 : u.type, r = (s = (E = n.getFormSchema()) == null ? void 0 : E.module) == null ? void 0 : s.templateId; if (["double-list-template", "tree-list-template", "list-template"].includes(r)) return f; const i = [ye["content-container"].type, ye["response-layout-item"].type, ye["splitter-pane"].type, ye.drawer.type]; if (y && i.includes(y)) { const h = e.getSchemaByType( "section", { parentComponentInstance: a.parentComponentInstance, mainTitle: a.componentName }, t ); if (h && h.contents && h.contents.length) { const N = h.contents[0]; return N.contents = [f], h; } } return f; } function D(f) { const a = e.getSchemaByType("calendar"); return Object.assign(a, { id: f.componentId + "-calendar", appearance: { class: "" }, type: "calendar", dataSource: f.dataSource || "", pagination: { enable: !1 } }), [a]; } function I(f) { var i, v, u; const a = e.getSchemaByType("component"), c = D(f); let y = !1; const r = (u = (v = (i = f.parentComponentInstance) == null ? void 0 : i.schema) == null ? void 0 : v.appearance) == null ? void 0 : u.class; return r && r.includes("f-page-main") && (y = !0), Object.assign(a, { id: `${f.componentId}-component`, viewModel: `${f.componentId}-component-viewmodel`, componentType: f.componentType, appearance: { class: y ? "f-utils-fill-flex-column f-utils-overflow-auto" : "f-grid-is-sub f-utils-overflow-auto" }, contents: c }), a; } function C(f) { const a = w(f), c = I(f), y = m(f), r = n.getFormSchema(); return r.module.viewmodels.push(y), r.module.components.push(c), o.assembleDesignViewModel(), p(a, f); } return { createComponent: C }; } function Ye(e, t, n, o) { var w, p, D, I, C, f; const m = n.parentComponentInstance; if (m && o) { const a = Math.random().toString(36).slice(2, 6), c = { componentId: `calendar-${a}`, componentName: ((w = n.bindingSourceContext) == null ? void 0 : w.entityTitle) || ((D = (p = n.bindingSourceContext) == null ? void 0 : p.bindingEntity) == null ? void 0 : D.name) || `日历-${a}`, componentType: "calendar", parentContainerId: m.schema.id, parentComponentInstance: m, bindTo: ((I = n.bindingSourceContext) == null ? void 0 : I.bindTo) || "", dataSource: (f = (C = n.bindingSourceContext) == null ? void 0 : C.bindingEntity) == null ? void 0 : f.label }, { createComponent: y } = zt(e, o); return y(c); } else return t; } const Yt = "https://json-schema.org/draft/2020-12/schema", qt = "https://farris-design.gitee.io/calendar.schema.json", Ht = "calendar", Gt = "A Farris Input Component", Ut = "object", _t = { id: { description: "The unique identifier for calendar", type: "string" }, type: { description: "The type string of calendar", type: "string", default: "calendar" }, appearance: { description: "", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} }, dataSource: { description: "", type: "string", default: "" }, visible: { description: "", type: "boolean", default: !0 }, fit: { description: "填充父容器", type: "boolean", default: !0 }, width: { description: "宽度", type: "Number", default: 600 }, height: { description: "高度", type: "Number", default: 500 }, firstDayOfTheWeek: { description: "每周起始日", type: "String", default: "Sun" }, highLightWeekend: { description: "是否高亮周末", type: "Boolean", default: !0 }, eventDateField: { description: "事件日期字段", type: "String", default: "" }, activeDate: { description: "默认日期", type: "String", default: "" }, eventItemFormatter: { description: "自定义事件内容格式化", type: "String", default: "" }, customEventStyles: { description: "自定义事件样式", type: "String", default: "" }, textField: { description: "事件文本字段", type: "String", default: "title" }, idField: { description: "事件id字段", type: "String", default: "id" }, enableMoreView: { description: "是否启用多视图", type: "Boolean", default: !1 }, defaultView: { description: "默认视图", type: "String", default: "month" }, enableCrossDay: { description: "是否允许跨天", type: "Boolean", default: !1 }, startDateField: { description: "事件开始日期字段", type: "String", default: "" }, endDateField: { description: "事件结束日期字段", type: "String", default: "" } }, Jt = [ "id", "type" ], Xt = { onEventClick: "日程点击事件", onDateChange: "日期切换事件", onMoreClick: "更多点击事件", onViewChange: "视图切换事件" }, Me = { $schema: Yt, $id: qt, title: Ht, description: Gt, type: Ut, properties: _t, required: Jt, events: Xt }, Ne = { events: { type: Array, default: [] }, firstDayOfTheWeek: { type: String, default: "Sun" }, enableMoreView: { type: Boolean, default: !1 }, defaultView: { type: String, default: "month" }, fit: { type: Boolean, default: !0 }, height: { type: Number, default: 600 }, width: { type: Number, default: 800 }, highLightWeekend: { type: Boolean, default: !1 }, eventItemFormatter: { type: Function }, customEventStyles: { type: Function }, eventDateField: { type: String, default: "startDate" }, customClass: { type: String, default: "" }, startDateField: { type: String, default: "startDate" }, endDateField: { type: String, default: "endDate" }, enableCrossDay: { type: Boolean, default: !1 }, idField: { type: String, default: "id" }, activeDate: { type: Date, default: /* @__PURE__ */ new Date() }, textField: { type: String, default: "title" }, customStyle: { type: String, default: "" }, enableWeekdayBorder: { type: Boolean, default: !1 }, visible: { type: Boolean, default: !0 } }, ia = Nt(Ne, Me, ze, Ye), qe = Ot( Me, Me, ze, Ye ), X = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; var te = /* @__PURE__ */ ((e) => (e[e.previous = 1] = "previous", e[e.current = 2] = "current", e[e.next = 3] = "next", e))(te || {}); function ue() { function e() { return { year: 0, month: 0, day: 0 }; } function t(a) { return new Date( a.year || 0, a.month ? a.month - 1 : 0, a.day || 0, a.hour ? a.hour : 0, a.minute ? a.minute : 0, a.second ? a.second : 0, 0 ); } function n(a) { const c = /* @__PURE__ */ new Date(); return a.year || (a.year = c.getFullYear()), a.month || (a.month = c.getMonth() + 1), a.day || (a.day = 1), new Date( a.year, a.month - 1, a.day, a.hour ? a.hour : 0, a.minute ? a.minute : 0, a.second ? a.second : 0, 0 ); } function o(a) { return new Date( a.year || 1, (a.month || 1) - 1, a.day, a.hour ? a.hour : 0, a.minute ? a.minute : 0, a.second ? a.second : 0, 0 ).getDay(); } function m(a) { return X.indexOf(a); } function w(a) { return t(a).getTime(); } function p(a) { return Math.round(w(a) / 1e3); } function D(a, c, y) { const r = w(c), i = w(y), v = w(a); return i - v > v - r ? c : y; } function I() { const a = /* @__PURE__ */ new Date(); return { year: a.getFullYear(), month: a.getMonth() + 1, day: a.getDate(), hour: a.getHours(), minute: a.getMinutes(), second: a.getSeconds() }; } function C(a) { return a ? { year: a.getFullYear(), month: a.getMonth() + 1, day: a.getDate(), hour: a.getHours(), minute: a.getMinutes(), second: a.getSeconds() } : e(); } function f(a) { const c = o(a); return c === 0 || c === 6; } return { convertDateToDateObject: C, emptyDate: e, getDate: t, getDate2: n, getDayNumber: o, getEpocTime: p, getNearDate: D, getWeekdayIndex: m, getTimeInMilliseconds: w, getToday: I, isWeekEnd: f }; } function Qt() { function e(w, p) { return new Date(p, w, 0).getDate(); } function t(w, p, D) { return new Date(w, p - 1, D, 0, 0, 0, 0); } function n(w, p) { const D = t(p, w, 1); return D.setMonth(D.getMonth() - 1), e(D.getMonth() + 1, D.getFullYear()); } function o(w, p) { const D = { year: w === 12 ? p + 1 : p }, I = w === 12 ? 1 : w + 1; return D.month = I, D; } function m(w, p) { const D = { year: w === 1 ? p - 1 : p }, I = w === 1 ? 12 : w - 1; return D.month = I, D; } return { daysInMonth: e, daysInPreMonth: n, getNextMonth: o, getPreviousMonth: m }; } function Zt() { const { getToday: e, getDayNumber: t, isWeekEnd: n } = ue(), { daysInMonth: o, daysInPreMonth: m, getNextMonth: w, getPreviousMonth: p } = Qt(); function D(u) { const { day: E, month: s, year: h } = u; if (E === void 0 || s === void 0 || h === void 0) throw new Error("invalided date."); const N = E === 1, M = N ? m(s, h) : E - 1, $ = N ? s - 1 : s, S = $ < 1, P = S ? 12 : $; return { year: S ? h - 1 : h, month: P, day: M }; } function I(u) { const { day: E, month: s, year: h } = u; if (E === void 0 || s === void 0 || h === void 0) throw new Error("invalided date."); const N = o(s, h), M = E === N, $ = M ? 1 : E + 1, S = M ? s + 1 : s, P = S > 12, x = P ? 1 : S; return { year: P ? h + 1 : h, month: x, day: $ }; } function C(u) { const E = p(u.month || 1, u.year || 1), s = o(E.month || 1, E.year || 1); return { day: (u.day || 1) <= s ? u.day : s, month: E.month, year: E.year }; } function f(u) { const E = w(u.month || 1, u.year || 1), s = o(E.month || 1, E.year || 1); return { day: (u.day || 1) <= s ? u.day : s, month: E.month, year: E.year }; } function a(u) { return { day: u.day, month: u.month, year: (u.year || 1) + 1 }; } function c(u) { return { day: u.day, month: u.month, year: (u.year || 1) - 1 }; } function y(u) { const s = (u.day || 1) - 7, h = s < 1, N = h ? o(u.month || 1, u.year || 1) + s : s, M = h ? p(u.month || 1, u.year || 1) : u; return { day: N, month: M.month, year: M.year }; } function r(u) { const s = (u.day || 1) + 7, h = o(u.month || 1, u.year || 1), N = s > h, M = N ? s - h : s, $ = N ? w(u.month || 1, u.year || 1) : u; return { day: M, month: $.month, year: $.year }; } function i(u, E, s, h, N) { if (u < 1 || E < 1 || s < 1) throw new Error("Invalid date input"); const M = { day: u, month: E, year: s }, $ = X.indexOf(h); if ($ === -1) throw new Error("Invalid firstDayOfWeek value"); const P = (t(M) - $ + 7) % 7, x = e(), g = (O) => O.day === x.day && O.month === x.month && O.year === x.year, d = []; let T = { ...M }; for (let O = 0; O < P; O++) T = D(T); for (let O = 0; O < 7; O++) { let b; if (T.month === N.month && T.year === N.year) b = te.current; else { const F = p(M.month, M.year); T.month === F.month && T.year === F.year ? b = te.previous : b = te.next; } const j = g(T), V = n(T); d.push({ date: T, monthTag: b, isCurrent: j, weekEnd: V }), O < 6 && (T = I(T)); } return { days: d, weekNumber: 0, year: s }; } function v(u, E, s, h) { const N = [], M = { day: 1, month: u, year: E }, $ = t(M), S = X.indexOf(s); if (S === -1) throw new Error("Invalid firstDayOfWeek value"); const P = ($ - S + 7) % 7; let x = M; for (let d = 0; d < P; d++) x = D(x); let g = x; for (let d = 0; d < 6; d++) { const T = i(g.day, g.month, g.year, s, h); N.push(T); for (let L = 0; L < 7; L++) g = I(g); } return N; } return { getMonthlyCalendar: v, getWeeklyCalendar: i, getPreviousDay: D, getNextDay: I, getDayInPreviousWeek: y, getDayInNextWeek: r, getDayInPreviousMonth: C, getDayInNextMonth: f, getNextYear: a, getPreviousYear: c }; } const oe = ["year", "month", "week", "day"]; var ke = /* @__PURE__ */ ((e) => (e[e.Equal = 0] = "Equal", e[e.NotEqual = 1] = "NotEqual", e[e.Greater = 2] = "Greater", e[e.GreaterOrEqual = 3] = "GreaterOrEqual", e[e.Less = 4] = "Less", e[e.LessOrEqual = 5] = "LessOrEqual", e[e.Like = 6] = "Like", e[e.LikeStartWith = 7] = "LikeStartWith", e[e.LikeEndWith = 8] = "LikeEndWith", e[e.NotLike = 9] = "NotLike", e[e.NotLikeStartWith = 10] = "NotLikeStartWith", e[e.NotLikeEndWith = 11] = "NotLikeEndWith", e[e.Is = 12] = "Is", e[e.IsNot = 13] = "IsNot", e[e.In = 14] = "In", e[e.NotIn = 15] = "NotIn", e))(ke || {}), Se = /* @__PURE__ */ ((e) => (e[e.Empty = 0] = "Empty", e[e.And = 1] = "And", e[e.Or = 2] = "Or", e))(Se || {}); function Oe() { const { getTimeInMilliseconds: e } = ue(); function t(r) { return r && r.year !== 0 && r.month !== 0 && r.day !== 0; } function n(r) { return r && r.year !== 0 && r.month !== 0; } function o(r) { return r && r.year !== 0; } function m(r, i) { return e(r) < e(i); } function w(r) { return e({ year: r.year, month: r.month, day: r.day }); } function p(r, i, v = !0) { return v ? e(r) <= e(i) : w(r) <= w(i); } function D(r, i) { return e(r) === e(i); } function I(r, i) { const v = e(i); return e(r.from) === v || e(r.to) === v; } function C(r, i) { return !i || !t(i.to) || !t(i.from) ? !1 : p(i.from, r) && p(r, i.to); } function f(r, i) { return t(i) && e(r) >= e(i); } function a(r, i) { return t(i) && e(r) <= e(i); } function c(r, i) { return e({ year: r.year, month: r.month, day: r.day }) === e({ year: i.year, month: i.month, day: i.day }); } function y(r, i) { return e({ hour: r.hour, minute: r.minute, second: r.second }) === e({ hour: i.hour, minute: i.minute, second: i.second }); } return { isDateEarlier: m, equal: D, inPeriod: C, isPoint: I, equalOrEarlier: p, isInitializedDate: t, isInitializedMonth: n, isInitializedYear: o, isMonthDisabledByDisableSince: f, isMonthDisabledByDisableUntil: a, sameTime: y, sameDay: c }; } const Kt = { activeView: { type: Number, default: 3 }, title: { type: String, default: "" }, dailyViewTitle: { type: String, default: "Day" }, weeklyViewTitle: { type: String, default: "Week" }, monthlyViewTitle: { type: String, default: "Month" }, todayText: { type: String, default: "Today" }, previousText: { type: String, default: "Previous" }, nextText: { type: String, default: "Next" }, enableMoreView: { type: Boolean, default: !1 }, isCurrent: { type: Boolean, default: !1 }, yearViewTitle: { type: String, default: "Year" } }, xe = /* @__PURE__ */ ee({ name: "FCalendarHeader", props: Kt, emits: ["viewChange", "previous", "next", "resetToToday"], setup(e, t) { const n = B(e.title), o = B(e.dailyViewTitle), m = B(e.weeklyViewTitle), w = B(e.monthlyViewTitle), p = B(e.yearViewTitle), D = 2, I = 62, C = B(e.activeView); Y(() => e.activeView, (v, u) => { C.value = v; }), Y(() => e.title, () => { n.value = e.title; }); const f = A(() => ({ top: `${D}px`, left: `${C.value * (D + 1) + (C.value - 1) * (I + 1)}px` })), a = A(() => C.value === 4 ? o.value : C.value === 3 ? m.value : C.value === 1 ? p.value : w.value); function c(v) { const u = oe.indexOf(v) + 1; C.value = u, t.emit("viewChange", u); } function y() { t.emit("previous", C.value); } function r() { t.emit("next", C.value); } function i() { t.emit("resetToToday"); } return () => l("div", { class: "f-calendar-header align-items-center" }, [l("div", { class: "f-calendar-title" }, [n.value]), l("div", { class: "f-calendar-navigator pl-3", style: "height:26px" }, [l("button", { class: "btn btn-secondary mr-2", onClick: () => i(), disabled: e.isCurrent }, [e.todayText || "Today"]), l("div", { class: "f-calendar-navigator-button-group" }, [l("div", { class: "f-calendar-navigator-previous btn btn-default", onClick: () => y(), title: e.previousText }, [l("i", { class: "f-icon f-icon-arrow-chevron-left" }, null)]), l("div", { class: "f-calendar-navigator-next btn btn-default", onClick: () => r(), title: e.nextText }, [l("i", { class: "f-icon f-icon-arrow-chevron-right" }, null)])])]), e.enableMoreView && l("div", { class: "f-calendar-view-switch" }, [l("div", { class: "f-calendar-view-switch-panel", style: "width: 134px;" }, [l("span", { class: "f-calendar-view-switch-monthly", onClick: (v) => c("year") }, [p.value]), l("span", { class: "f-calendar-view-switch-monthly", onClick: (v) => c("month") }, [w.value])]), l("div", { class: "f-calendar-view-switch-active-view", style: f.value }, [a.value])])]); } }), en = { dates: { type: Array, default: [] }, daysInWeek: { type: Array, default: X }, enableKeyboadNavigate: { type: Boolean, default: !0 }, enableMarkCurrent: { type: Boolean, default: !0 }, events: { type: Array, default: [] }, activeDay: { type: Object, default: null }, width: { type: Number, default: 0 }, height: { type: Number, default: 0 }, disabled: { type: Boolean, default: !1 }, monthLabels: { type: Object, default: {} }, eventDateField: { type: String, default: "startDate" }, enableCrossDay: { type: Boolean, default: !1 }, startDateField: { type: String, default: "startDate" }, endDateField: { type: String, default: "endDate" }, idField: { type: String, default: "id" }, customEventStyles: { type: Function, default: null }, eventItemFormatter: { type: Function, default: null }, popoverRef: { type: Object, default: null }, /** 月视图头部应用边框线条与背景色,默认不启用 */ showBorder: { type: Boolean, default: !1 }, moreText: { type: String, default: "更多" } }, Fe = /* @__PURE__ */ ee({ name: "FCalendarMonthView", props: en, emits: ["click", "keyDown", "moreClick"], setup(e, t) { const n = B(e.daysInWeek); B(e.enableKeyboadNavigate); const o = B(e.enableMarkCurrent), m = B(e.activeDay), w = B(e.events), { assignEventsToWeeks: p, assignEventsToDays: D, renderEventItem: I, useCompareCompsition: C } = le("eventsComposition"), { equal: f } = C, a = B(); function c(g, d) { return e.enableCrossDay ? p(g, d) : D(g, d); } const y = B(c(e.dates, w.value)); Y(() => e.enableCrossDay, () => { y.value = c(e.dates, e.events); }), Y(() => e.dates, () => { y.value = c(e.dates, w.value); }), Y(() => e.activeDay, () => { m.value = e.activeDay; }), Y(() => e.events, () => { w.value = e.events, y.value = c(e.dates, e.events); }), Y(() => e.daysInWeek, (g, d) => { n.value = g; }); function r(g) { return !!m.value && f({ year: m.value.year, month: m.value.month, day: m.value.day }, g); } const i = (g, d, T) => { const O = { "f-datepicker-no-currmonth": g.monthTag === te.previous || g.monthTag === te.next, "f-calendar-weekday": g.weekEnd, "f-calendar-workday": !g.weekEnd, "f-calendar-today": g.isCurrent }, b = `d_${d}_${T}`; return O[b] = !0, O; }, v = (g) => { const d = g.monthTag === te.current && r(g.date), T = g.isCurrent && o.value; return { "f-calendar-month-view-date": !0, "f-calendar-month-view-selected": d, "f-calendar-month-view-current": T }; }; function u(g, d) { e.disabled || d.showMore || (g.stopPropagation(), t.emit("click", { date: d.date, view: "month" })); } function E(g, d) { e.disabled || t.emit("moreClick", { date: d.date, view: "month" }); } const s = A(() => ({ width: `${e.width}px`, height: `${e.height}px` })), h = B(0), N = () => { const g = a.value; if (!g) return 0; const d = g.querySelector(".f-calendar--daygrid-row"); if (!d) return 0; const T = d.offsetHeight; return Math.max(0, Math.floor(T / 19) - 1); }; function M() { return l("div", { class: "w-100" }, [l("table", { class: { "w-100": !0, "show-border": e.showBorder } }, [n.value && n.value.map((g) => l("th", null, [g]))])]); } function $(g, d) { return l("div", { class: "f-calendar--daygrid-row-header" }, [l("table", null, [l("tbody", null, [l("tr", null, [g.days && g.days.map((T, L) => l("td", { class: i(T, d, L), onClick: (O) => u(O, T), style: "position: relative;" }, null))])])])]); } function S(g, d) { return g.days && g.days.map((T, L) => l("td", { class: i(T, d, L) }, [l("div", { class: "f-calendar-month-view-title" }, [l("div", { class: v(T) }, [T.date.day]), l("div", { class: "f-calendar-month-view-date-month" }, [T.date.day === 1 ? e.monthLabels[T.date.month || 1] : ""])])])); } function P(g) { const d = Math.max(0, h.value || N()), T = !!(g.events && g.events.length > d), L = ce([...g.events || []]), O = T ? L.slice(0, d) : L; return T && O && O.length > 0 && O[O.length - 1].forEach((b) => { b.data && (b.showMore = !0, b.moreCount = g.events.length - d + 1); }), O.map((b, j) => l("tr", null, [b.map((V, F) => V.showMore ? l("td", { colspan: 1, rowspan: 1, onClick: (q) => u(q, V) }, [l("a", { class: "f-calendar-event p-0 m-0 pl-1 more-events ", onClick: (q) => E(q, g.days[F]) }, [l("div", { class: "event-title" }, [e.moreText.replace("#count#", V.moreCount)])])]) : l("td", { colspan: V.colspan || 1, rowspan: V.rowspan || 1, onClick: (q) => u(q, g.days[F]) }, [V.data && I(V)]))])); } function x() { return l("div", { class: "w-100 h-100" }, [l("div", { class: "f-calendar--daygrid" }, [y.value.map((g, d) => l("div", { class: "f-calendar--daygrid-row" }, [$(g, d), l("div", { class: "f-calendar--daygrid-content" }, [l("table", null, [l("thead", null, [l("tr", null, [S(g, d)])]), l("tbody", null, [P(g)])])])]))])]); } return Y(() => e.height, (g, d) => { g !== d && Ve(() => { h.value = N(), y.value = [...y.value]; }); }), ie(() => { h.value = N(); }), () => l("div", { class: "f-calendar-month-view", ref: a }, [l("table", { class: "f-calendar-table", cellpadding: "0", style: s.value }, [l("thead", null, [l("tr", null, [l("td", { class: "f-calendar-header" }, [M()])])]), l("tbody", null, [l("tr", { style: "height: 100%" }, [l("td", { class: "f-calendar-content" }, [x()])])])])]); } }), tn = { daysInWeek: { type: Array, default: X }, enableMarkCurrent: { type: Boolean, default: !0 }, events: { type: Array, default: [] }, week: { type: Object, default: { days: [], weekNumber: 0, year: 0 } }, dateField: { type: String, default: "date" }, startDateField: { type: String, default: "startDate" }, endDateField: { type: String, default: "endDate" } }, Ee = /* @__PURE__ */ ee({ name: "FCalendarWeekView", props: tn, emits: [], setup(e) { const t = B(), n = B(), o = B(e.daysInWeek), m = B(e.week), w = B(e.enableMarkCurrent), p = B(e.events), D = B([]), { equal: I } = Oe(), { convertDateToDateObject: C } = ue(); function f(s) { return m.value.days.map((N) => { const M = { year: N.date.year, month: N.date.month, day: N.date.day, hour: s.hour, minute: s.minute, second: s.second }, $ = p.value.filter((S) => I(C(S[e.startDateField]), M)); return { day: M, events: $ }; }); } function a() { const s = []; for (let h = 0; h < 24; h++) { const N = { hour: h, minute: 0, second: 0 }, M = { hour: h, minute: 30, second: 0 }, $ = f(N), S = f(M); s.push({ time: N, events: $, title: h > 0 ? `${h}:00` : "", part: "upper" }), s.push({ time: M, events: S, title: `${h}:30`, part: "lower" }); } D.value = s; } a(), Y(() => e.week, () => { m.value = e.week, a(); }), Y(() => e.events, () => { p.value = e.events, a(); }); const c = (s) => ({ "f-calendar-week-view-date": !0, "f-calendar-week-view-current": s.isCurrent && w.value }); function y() { return l("div", { class: "f-calendar-week-view-header" }, [l("div", { class: "f-calendar-week-view-header-corner" }, null), l("div", { class: "f-calendar-week-view-header-primary" }, [l("div", { class: "f-calendar-week-view-header-columns" }, [o.value.map((s, h) => l("div", { class: "f-calendar-week-view-header-cell" }, [l("div", { class: c(m.value.days[h]) }, [m.value.days[h].date.day]), l("span", null, [s])]))])])]); } function r() { return l("div", { class: "f-calendar-week-view-content-side" }, [l("div", { class: "f-calendar-side" }, [D.value.map((s) => l("div", { class: "f-calendar-side-row" }, [l("div", { class: "f-calendar-side-row-number" }, [s.part === "upper" ? s.title : ""])]))])]); } function i(s) { return { "f-calendar-week-view-item": !0, "f-calendar-week-view-item-upper": s.part === "upper", "f-calendar-week-view-item-lower": s.part === "lower" }; } function v(s) { const P = (s[e.startDateField].hour || 0) + (s[e.startDateField].minute || 0) / 60; return { height: `${44 * ((s.ends.hour || 0) + (s.ends.minute || 0) / 60 - P) - 2 - 2 - 1 - 1}px` }; } function u() { return D.value.map((s) => l("div", { class: i(s) }, [s.events.map((h) => l("div", { class: "f-calendar-week-view-item-cell" }, [h.events.length > 0 && h.events.map((N) => l("div", { class: "f-calendar-event", style: v(N) }, [N.title]))]))])); } function E() { return l("div", { ref: n, class: "f-calendar-content-primary" }, [l("div", { class: "f-calendar-content-data" }, [u()])]); } return ie(() => { t.value && t.value.scrollTo(0, 250); }), () => l("div", { class: "f-calendar-week-view" }, [y(), l("div", { class: "f-calendar-week-view-content", ref: t }, [r(), E()])]); } }), nn = { day: { type: Object, default: {} }, dayInWeek: { type: String, default: "" }, enableMarkCurrent: { type: Boolean, default: !0 }, events: { type: Array, default: [] }, dateField: { type: String, default: "date" } }, Ie = /* @__PURE__ */ ee({ name: "FCalendarDayView", props: nn, emits: [], setup(e) { const t = B(), n = B(), o = B(e.dayInWeek), m = B(e.day), w = B(e.enableMarkCurrent), p = B(e.events), D = B([]), { convertDateToDateObject: I } = ue(), { equal: C } = Oe(); function f(s) { const h = { year: m.value.date.year, month: m.value.date.month, day: m.value.date.day, hour: s.hour, minute: s.minute, second: s.second }, N = p.value.filter((M) => C(I(M[e.dateField]), h)); return [{ day: h, events: N }]; } function a() { const s = []; for (let h = 0; h < 24; h++) { const N = { hour: h, minute: 0, second: 0 }, M = { hour: h, minute: 30, second: 0 }, $ = f(N), S = f(M); s.push({ time: N, events: $, title: h > 0 ? `${h}:00` : "", part: "upper" }), s.push({ time: M, events: S, title: `${h}:30`, part: "lower" }); } D.value = s; } a(), Y(() => e.day, () => { m.value = e.day, a(); }), Y(() => e.events, () => { p.value = e.events, a(); }); const c = (s) => ({ "f-calendar-day-view-date": !0, "f-calendar-day-view-current": s.isCurrent && w.value }); function y() { return l("div", { class: "f-calendar-day-view-header" }, [l("div", { class: "f-calendar-day-view-header-corner" }, null), l("div", { class: "f-calendar-day-view-header-primary" }, [l("div", { class: "f-calendar-day-view-header-columns" }, [l("div", { class: "f-calendar-day-view-header-cell" }, [l("div", { class: c(m.value) }, [m.value.date.day]), l("span", null, [o.value])])])])]); } function r() { return l("div", { class: "f-calendar-day-view-content-side" }, [l("div", { class: "f-calendar-side" }, [D.value.map((s) => l("div", { class: "f-calendar-side-row" }, [l("div", { class: "f-calendar-side-row-number" }, [s.part === "upper" ? s.title : ""])]))])]); } function i(s) { return { "f-calendar-day-view-item": !0, "f-calendar-day-view-item-upper": s.part === "upper", "f-calendar-day-view-item-lower": s.part === "lower" }; } function v(s) { var T, L, O, b; const P = (((T = s.starts) == null ? void 0 : T.hour) || 0) + (((L = s.starts) == null ? void 0 : L.minute) || 0) / 60; return { height: `${44 * ((((O = s.ends) == null ? void 0 : O.hour) || 0) + (((b = s.ends) == null ? void 0 : b.minute) || 0) / 60 - P) - 2 - 2 - 1 - 1}px` }; } function u() { return D.value.map((s) => l("div", { class: i(s) }, [s.events.map((h) => l("div", { class: "f-calendar-day-view-item-cell" }, [h.events.length > 0 && h.events.map((N) => l("div", { class: "f-calendar-event", style: v(N) }, [N.title]))]))])); } function E() { return l("div", { ref: n, class: "f-calendar-content-primary" }, [l("div", { class: "f-calendar-content-data" }, [u()])]); } return ie(() => { t.value && t.value.scrollTo(0, 250); }), () => l("div", { class: "f-calendar-day-view" }, [y(), l("div", { class: "f-calendar-day-view-content", ref: t }, [r(), E()])]); } }), an = /* @__PURE__ */ ee({ name: "FCalendarYearView", props: { monthLabels: { type: Object, default: null }, height: { type: Number, default: 300 }, events: { type: Array, default: [] }, dateField: { type: String, default: "date" }, activeYear: { type: Number, default: 2025 }, moreText: { type: String, default: "更多" } }, emits: ["moreClick"], setup(e, t) { const n = B(), o = B(e.monthLabels), { assignEventsToMonths: m, renderEventItemForMonths: w } = le("eventsComposition"), p = B(0), D = () => { const a = n.value; if (!a) return 0; const y = a.querySelector(".yearview-monthitem").offsetHeight; return Math.max(0, Math.floor((y - 40) / 24)); }, I = (a) => { const c = !!(a && a.length > p.value); if (c) { const y = ce(a), r = c ? y == null ? void 0 : y.slice(0, p.value) : y; if (r && r.length > 0) { const i = r[r.length - 1]; i.data && (i.showMore = !0, i.moreCount = a.length - p.value + 1); } return r; } return a; }, C = A(() => m(e.activeYear, e.events)); function f(a, c) { const y = { year: e.activeYear, month: parseInt(c, 10) }; t.emit("moreClick", a, { date: y, view: "year" }); } return Y(() => e.height, (a, c) => { a !== c && Ve(() => { p.value = D(), o.value = { ...e.monthLabels }; }); }), ie(() => { p.value = D(); }), () => l("div", { class: "h-100 w-100 f-calendar-year-view", ref: n }, [l("ul", { style: "height: 100%;overflow: auto; display: flex;flex-wrap: wrap;" }, [Object.keys(e.monthLabels).map((a, c) => { var y; return l("li", { key: c, class: "col-md-4 col-lg-3 col-sm-12 yearview-monthitem" }, [l("div", { class: "f-calendar-year-view-content w-100 h-100 d-flex flex-column", style: "overflow: hidden;" }, [l("div", { class: "f-calendar-month-view-title px-2" }, [e.monthLabels[a]]), l("div", { class: "f-calendar-month-events p-2" }, [l("ul", { class: "events" }, [(y = I(C.value[a])) == null ? void 0 : y.map((r, i) => r.showMore ? l("li", { class: "event-item more-events ", key: i }, [l("a", { class: "f-calendar-event p-0 mt-0 pl-1 ", onClick: (v) => f(v, a) }, [e.moreText.replace("#count#", r.moreCount)])]) : w(r))])])])]); })])]); } }), rn = /* @__PURE__ */ ee({ name: "MoreEventList", props: { events: Array, popoverOffsetX: Number }, setup(e, t) { const n = B(), o = A(() => n), m = A(() => e.events), { renderEventItemForMore: w } = le("eventsComposition"), p = B(0); return t.expose({ popoverRef: o }), () => l(Bt, { id: "calendar-more-events", customStyles: { filter: "drop-shadow(#c5c5c5 0px 0px 6px)" }, offsetX: p, ref: n, placement: "auto", keepWidthWithReference: !1, fitContent: !0 }, { default: () => { var D; return [l("div", { style: "height: 400px; width: 300px;overflow: hidden;" }, [l("div", { class: "f-calendar-more-events-list h-100", style: "overflow:auto;" }, [l("ul", null, [(D = m.value) == null ? void 0 : D.map((I) => w(I))])])])]; } }); } }); function on() { const { getLocaleValue: e, getLocale: t } = $t, n = { 1: e("calendar.monthLabels.1"), 2: e("calendar.monthLabels.2"), 3: e("calendar.monthLabels.3"), 4: e("calendar.monthLabels.4"), 5: e("calendar.monthLabels.5"), 6: e("calendar.monthLabels.6"), 7: e("calendar.monthLabels.7"), 8: e("calendar.monthLabels.8"), 9: e("calendar.monthLabels.9"), 10: e("calendar.monthLabels.10"), 11: e("calendar.monthLabels.11"), 12: e("calendar.monthLabels.12") }, o = { Sun: e("calendar.dayLabels.Sun"), Mon: e("calendar.dayLabels.Mon"), Tue: e("calendar.dayLabels.Tue"), Wed: e("calendar.dayLabels.Wed"), Thu: e("calendar.dayLabels.Thu"), Fri: e("calendar.dayLabels.Fri"), Sat: e("calendar.dayLabels.Sat") }, m = e("calendar.today"), w = e("calendar.thisYear"), p = e("calendar.yearView"), D = e("calendar.monthView"), I = e("calendar.weekView"), C = e("calendar.dayView"), f = e("calendar.titleFormat"), a = e("calendar.yearViewTitleFormat"), c = e("calendar.prevMonth"), y = e("calendar.nextMonth"), r = e("calendar.prevWeek"), i = e("calendar.nextWeek"), v = e("calendar.prevDay"), u = e("calendar.nextDay"), E = e("calendar.prevYear"), s = e("calendar.nextYear"), h = e("calendar.more", "") || "还有 #count# 项..."; return { monthLabels: n, weekDayLabels: o, today: m, monthViewTitle: D, weekViewTitle: I, dayViewTitle: C, titleFormat: f, prevMonth: c, nextMonth: y, prevWeek: r, nextWeek: i, prevDay: v, nextDay: u, yearViewTitle: p, yearViewTitleFormat: a, thisYear: w, prevYear: E, nextYear: s, moreText: h, locale: t() }; } function ln(e) { const t = Object.prototype.toString.call(e); return e instanceof Date || typeof e == "object" && t === "[object Date]" ? new e.constructor(+e) : typeof e == "number" || t === "[object Number]" || typeof e == "string" || t === "[object String]" ? new Date(e) : /* @__PURE__ */ new Date(NaN); } function sn(e) { return e instanceof Date || typeof e == "object" && Object.prototype.toString.call(e) === "[object Date]"; } function cn(e) { if (!sn(e) && typeof e != "number") return !1; const t = ln(e); return !isNaN(Number(t)); } function un(e, t, n, o, m, w, p) { const { equalOrEarlier: D, sameDay: I } = o, { convertDateToDateObject: C } = t, { parseToDate: f, formatTo: a } = n; function c(S, P) { S.forEach((d) => { d.days.forEach((T) => { T.events = []; }); }); const x = /* @__PURE__ */ new Map(), g = (d) => { if (!d) return null; if (x.has(d)) return x.get(d); const T = f(d, "yyyy-MM-dd"); if (!T) return null; const L = C(T); return x.set(d, L), L; }; return P.forEach((d) => { const { eventDateField: T, startDateField: L } = e, O = K(d, T) || K(d, L), b = g(O); b && S.forEach((j) => { j.days.forEach((V) => { var F; I(V.date, b) && ((F = V.events) == null || F.push({ id: d[e.idField], data: { ...d }, eventDate: b, isSingleDay: !0 })); }); }); }), S.forEach((d) => { const T = [], L = d.days.map((b, j) => b.events && b.events.length > 0 ? b.events.map((V, F) => ({ ...V, // 在非跨天模式下,colspan为1,rowspan为1 colspan: 1, rowspan: 1, // 添加位置信息 startIndex: j, endIndex: j })) : []), O = Math.max(...L.map((b) => b.length), 0); for (let b = 0; b < O; b++) { const j = []; for (let V = 0; V < 7; V++) L[V][b] ? j.push(L[V][b]) : j.push({ colspan: 1, rowspan: 1, data: null }); T.push(j); } d.events = T; }), S; } function y(S, P) { S.forEach((d) => { d.events = []; }); const x = /* @__PURE__ */ new Map(), g = (d) => { if (!d) return null; if (x.has(d)) return x.get(d); const T = f(d, "yyyy-MM-dd"); if (!T) return null; const L = C(T); return x.set(d, L), L; }; return P.forEach((d) => { const { startDateField: T, endDateField: L } = e, O = g(K(d, T)), b = g(K(d, L)); !O || !b || S.forEach((j) => { var W, z, G, _; const V = j.days[0].date, F = j.days[j.days.length - 1].date; if (!(D(b, V, !1) || D(F, O, !1))) if (I(O, b)) (W = j.events) == null || W.push({ id: d[e.idField], data: { ...d }, eventDate: O, isSingleDay: !0 }); else { const J = D(V, O, !1) ? O : V, H = D(b, F, !1) ? b : F; let Q = -1, ae = -1; j.days.forEach((de, fe) => { I(de.date, J) && (Q = fe), I(de.date, H) && (ae = fe); }), Q !== -1 && ae !== -1 && ((z = j.events) == null || z.push({ id: d[e.idField], data: { ...d }, // 修复:eventDate 应该是事件在整个事件范围内的起始日期 eventDate: O, // 添加在当前周的起始和结束日期 startDate: J, endDate: H, // 添加在当前周的起始和结束索引 startIndex: Q, endIndex: ae, colspan: ae - Q + 1, isCrossDay: !0 })); } else I(O, F) && !I(b, F) && ((G = j.events) == null || G.push({ id: `${d[e.idField]}_start`, data: { ...d }, eventDate: O, isSingleDay: !0, isOverlapping: !0, originalId: d[e.idField] })), I(b, V) && !I(O, V) && ((_ = j.events) == null || _.push({ id: `${d[e.idField]}_end`, data: { ...d }, eventDate: b, isSingleDay: !0, isOverlapping: !0, originalId: d[e.idField] })); }); }), S.forEach((d) => { d.days.forEach((T, L) => { var V; const O = (V = d.events) == null ? void 0 : V.filter((F) => F.isCrossDay ? L >= F.startIndex && L <= F.endIndex : F.isSingleDay ? I({ year: F.eventDate.year, month: F.eventDate.month, day: F.eventDate.day }, { year: T.date.year, month: T.date.month, day: T.date.day }) : !1), b = O == null ? void 0 : O.find((F) => F.isCrossDay), j = (O == null ? void 0 : O.filter((F) => F.isSingleDay)) || []; b && j.length > 0 && j.forEach((F) => { var W, z; ((W = d.events) == null ? void 0 : W.some((G) => (G.originalId === F.id || G.id === F.id) && I({ year: G.eventDate.year, month: G.eventDate.month, day: G.eventDate.day }, { year: T.date.year, month: T.date.month, day: T.date.day }))) || (z = d.events) == null || z.push({ id: F.id, data: { ...F.data }, eventDate: T.date, isSingleDay: !0, isOverlapping: !0, originalId: F.id }); }); }); }), S.forEach((d) => { const T = []; for (let b = 0; b < 10; b++) T[b] = Array(7).fill(null); [...d.events].sort((b, j) => { if (b.isCrossDay && !j.isCrossDay) return -1; if (!b.isCrossDay && j.isCrossDay) return 1; if (b.isCrossDay && j.isCrossDay) return b.startIndex - j.startIndex; const V = b.eventDate, F = j.eventDate; return V.year !== F.year ? V.year - F.year : V.month !== F.month ? V.month - F.month : V.day - F.day; }).forEach((b) => { let j = 0, V = !1, F = 0, q = 1; for (b.isCrossDay ? (F = b.startIndex, q = b.colspan) : (F = d.days.findIndex((W) => I({ year: b.eventDate.year, month: b.eventDate.month, day: b.eventDate.day }, { year: W.date.year, month: W.date.month, day: W.date.day })), q = 1); !V && j < T.length; ) { let W = !0; for (let z = F; z < F + q; z++) if (T[j][z] !== null) { W = !1; break; } if (W) { for (let z = F; z < F + q; z++) T[j][z] = z === F ? b : { ...b, isPlaceholder: !0, colspan: z === F ? q : 0 }; V = !0; } else j++; } }); const O = []; T.forEach((b) => { if (b.some((j) => j !== null)) { const j = []; for (let V = 0; V < b.length; V++) { const F = b[V]; F === null ? j.push({ colspan: 1, rowspan: 1, data: null }) : F.isPlaceholder || j.push(F), F && (F.colspan = F.colspan || 1, F.colspan > 1 && (V += F.colspan - 1)); } O.push(j); } }), d.events = O; }), S; } function r(S, P) { const x = {}; return P.forEach((g) => { const { eventDateField: d, startDateField: T } = e, L = K(g, d) || K(g, T); if (!L) return; const O = C(f(L, "yyyy-MM-dd")); if (O.year === S) { const b = "" + O.month; x[b] = x[b] || [], x[b].push({ data: { ...g }, eventDate: O }); } }), x; } function i() { return oe[w.value - 1]; } function v(S, P) { S.stopPropagation(), !e.disabled && m.emit("eventClick", { data: P.data, view: i() }); } const u = (S, P, x) => { const g = K(S, P); return typeof g == "string" ? g : g !== null && typeof g == "object" && !Array.isArray(g) && x ? g[x] || "" : g || ""; }; function E(S) { return Te(e.eventItemFormatter) ? e.eventItemFormatter(S.data, { parseToDate: f, formatTo: a, getValue: u, view: i(), locale: p }) : K(S.data, e.textField || "title"); } function s(S) { return Te(e.eventItemFormatter) ? "" : u(S.data, e.textField || "title", p); } const h = (S) => { if (!S || !S.data) return {}; if (!Te(e.customEventStyles)) return { styles: { "background-color": "#f3f3f3" } }; const P = e.customEventStyles(S.data, { parseToDate: f, formatTo: a, getValue: u, view: i(), locale: p }); return P && Object.keys(P).length > 0 ? P : {}; }; function N(S) { const { cls: P, styles: x } = h(S); return l("a", { onClick: (g) => v(g, S), style: x || {}, class: "f-calendar-event p-0 mx-1 my-0 " + (P || "") }, [l("div", { class: "event-title", innerHTML: E(S), title: s(S) }, null)]); } function M(S) { return l("li", null, [se(" "), E(S)]); } function $(S) { const { cls: P, styles: x } = h(S); return l("li", { style: { ...x || {}, "padding-bottom": "2px" }, class: P, onClick: (g) => v(g, S) }, [l("div", { class: "event-title pb-0 text-truncate", innerHTML: E(S), title: s(S) }, null)]); } return { assignEventsToDays: c, assignEventsToWeeks: y, renderEventItem: N, useCompareCompsition: o, useDateComposition: t, useDateFormatComposition: n, renderEventItemForMore: M, assignEventsToMonths: r, renderEventItemForMonths: $, getEventItemStyles: h }; } const ne = /* @__PURE__ */ ee({ name: "FCalendar", props: Ne, emits: ["dayClick", "dateChange", "eventClick", "moreClick", "viewChange"], setup(e, t) { const { titleFormat: n, today: o, prevMonth: m, nextMonth: w, dayViewTitle: p, monthViewTitle: D, weekViewTitle: I, weekDayLabels: C, monthLabels: f, prevWeek: a, nextWeek: c, prevDay: y, nextDay: r, yearViewTitle: i, yearViewTitleFormat: v, thisYear: u, prevYear: E, nextYear: s, moreText: h, locale: N } = on(), M = Oe(), $ = Wt(), S = ue(), { sameDay: P } = M, { getToday: x, convertDateToDateObject: g } = S, { parseToDate: d } = $, T = B(e.firstDayOfTheWeek), L = B(e.events), O = B(e.enableCrossDay), b = x(), j = B(e.activeDate), V = B(0), F = B(e.visible), q = un(e, S, $, M, t, V, N); Et("eventsComposition", q); const W = B({ year: b.year || 1, month: b.month || 1, day: b.day || 1 }); function z() { typeof j.value == "string" && (j.value = d(j.value, "yyyy-MM-dd")), cn(j.value) && (W.value = g(j.value)); } z(), Y(() => e.activeDate, () => { j.value = e.activeDate, z(); }), Y(() => e.firstDayOfTheWeek, (k, R) => { k !== R && (T.value = k); }), Y(() => e.enableCrossDay, (k, R) => {