UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,684 lines 97.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 z, computed as A, createVNode as l, inject as le, nextTick as Ne, onMounted as ie, createTextVNode as se, provide as Et, onUnmounted as It, Fragment as Ae } from "vue"; import { resolveAppearance as Nt, createPropsResolver as Vt, 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 Re } from "lodash-es"; import { resolveField as K, useDateFormat as Wt, useResizeObserver as $e, getCustomClass as Lt, getCustomStyle as jt, EVENT_PROPERTY_TAB_IDS as Bt } from "../common/index.esm.js"; import Rt from "../popover/index.esm.js"; import { LocaleService as $t } from "../locale/index.esm.js"; import { BaseControlProperty as At } from "../property-panel/index.esm.js"; const Ye = /* @__PURE__ */ new Map([ ["appearance", Nt] ]), Yt = "root-viewmodel"; function zt(e, t) { const { formSchemaUtils: n, designViewModelUtils: o } = t; function d(m) { return { id: `${m.componentId}-component-viewmodel`, code: `${m.componentId}-component-viewmodel`, name: m.componentName, bindTo: m.bindTo, parent: Yt, fields: [], commands: [], states: [], enableValidation: !0 }; } function g(m) { const a = e.getSchemaByType("component-ref"); return Object.assign(a, { id: `${m.componentId}-component-ref`, component: `${m.componentId}-component` }), a; } function y(m, a, c) { var v, u, E, s; const h = (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 m; const i = [ye["content-container"].type, ye["response-layout-item"].type, ye["splitter-pane"].type, ye.drawer.type]; if (h && i.includes(h)) { const p = e.getSchemaByType( "section", { parentComponentInstance: a.parentComponentInstance, mainTitle: a.componentName }, t ); if (p && p.contents && p.contents.length) { const V = p.contents[0]; return V.contents = [m], p; } } return m; } function D(m) { const a = e.getSchemaByType("calendar"); return Object.assign(a, { id: m.componentId + "-calendar", appearance: { class: "" }, type: "calendar", dataSource: m.dataSource || "", pagination: { enable: !1 } }), [a]; } function O(m) { var i, v, u; const a = e.getSchemaByType("component"), c = D(m); let h = !1; const r = (u = (v = (i = m.parentComponentInstance) == null ? void 0 : i.schema) == null ? void 0 : v.appearance) == null ? void 0 : u.class; return r && r.includes("f-page-main") && (h = !0), Object.assign(a, { id: `${m.componentId}-component`, viewModel: `${m.componentId}-component-viewmodel`, componentType: m.componentType, appearance: { class: h ? "f-utils-fill-flex-column f-utils-overflow-auto" : "f-grid-is-sub f-utils-overflow-auto" }, contents: c }), a; } function C(m) { const a = g(m), c = O(m), h = d(m), r = n.getFormSchema(); return r.module.viewmodels.push(h), r.module.components.push(c), o.assembleDesignViewModel(), y(a, m); } return { createComponent: C }; } function ze(e, t, n, o) { var g, y, D, O, C, m; const d = n.parentComponentInstance; if (d && o) { const a = Math.random().toString(36).slice(2, 6), c = { componentId: `calendar-${a}`, componentName: ((g = n.bindingSourceContext) == null ? void 0 : g.entityTitle) || ((D = (y = n.bindingSourceContext) == null ? void 0 : y.bindingEntity) == null ? void 0 : D.name) || `日历-${a}`, componentType: "calendar", parentContainerId: d.schema.id, parentComponentInstance: d, bindTo: ((O = n.bindingSourceContext) == null ? void 0 : O.bindTo) || "", dataSource: (m = (C = n.bindingSourceContext) == null ? void 0 : C.bindingEntity) == null ? void 0 : m.label }, { createComponent: h } = zt(e, o); return h(c); } else return t; } const qt = "https://json-schema.org/draft/2020-12/schema", Ht = "https://farris-design.gitee.io/calendar.schema.json", Gt = "calendar", _t = "A Farris Input Component", Ut = "object", Jt = { 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: "" } }, Xt = [ "id", "type" ], Qt = { onEventClick: "日程点击事件", onDateChange: "日期切换事件", onMoreClick: "更多点击事件", onViewChange: "视图切换事件" }, ke = { $schema: qt, $id: Ht, title: Gt, description: _t, type: Ut, properties: Jt, required: Xt, events: Qt }, Ve = { 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 } }, sa = Vt(Ve, ke, Ye, ze), qe = Ot( ke, ke, Ye, ze ), Q = ["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 d(a) { return Q.indexOf(a); } function g(a) { return t(a).getTime(); } function y(a) { return Math.round(g(a) / 1e3); } function D(a, c, h) { const r = g(c), i = g(h), v = g(a); return i - v > v - r ? c : h; } function O() { 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 m(a) { const c = o(a); return c === 0 || c === 6; } return { convertDateToDateObject: C, emptyDate: e, getDate: t, getDate2: n, getDayNumber: o, getEpocTime: y, getNearDate: D, getWeekdayIndex: d, getTimeInMilliseconds: g, getToday: O, isWeekEnd: m }; } function Zt() { function e(g, y) { return new Date(y, g, 0).getDate(); } function t(g, y, D) { return new Date(g, y - 1, D, 0, 0, 0, 0); } function n(g, y) { const D = t(y, g, 1); return D.setMonth(D.getMonth() - 1), e(D.getMonth() + 1, D.getFullYear()); } function o(g, y) { const D = { year: g === 12 ? y + 1 : y }, O = g === 12 ? 1 : g + 1; return D.month = O, D; } function d(g, y) { const D = { year: g === 1 ? y - 1 : y }, O = g === 1 ? 12 : g - 1; return D.month = O, D; } return { daysInMonth: e, daysInPreMonth: n, getNextMonth: o, getPreviousMonth: d }; } function Kt() { const { getToday: e, getDayNumber: t, isWeekEnd: n } = ue(), { daysInMonth: o, daysInPreMonth: d, getNextMonth: g, getPreviousMonth: y } = Zt(); function D(u) { const { day: E, month: s, year: p } = u; if (E === void 0 || s === void 0 || p === void 0) throw new Error("invalided date."); const V = E === 1, k = V ? d(s, p) : E - 1, R = V ? s - 1 : s, S = R < 1, I = S ? 12 : R; return { year: S ? p - 1 : p, month: I, day: k }; } function O(u) { const { day: E, month: s, year: p } = u; if (E === void 0 || s === void 0 || p === void 0) throw new Error("invalided date."); const V = o(s, p), k = E === V, R = k ? 1 : E + 1, S = k ? s + 1 : s, I = S > 12, x = I ? 1 : S; return { year: I ? p + 1 : p, month: x, day: R }; } function C(u) { const E = y(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 m(u) { const E = g(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 h(u) { const s = (u.day || 1) - 7, p = s < 1, V = p ? o(u.month || 1, u.year || 1) + s : s, k = p ? y(u.month || 1, u.year || 1) : u; return { day: V, month: k.month, year: k.year }; } function r(u) { const s = (u.day || 1) + 7, p = o(u.month || 1, u.year || 1), V = s > p, k = V ? s - p : s, R = V ? g(u.month || 1, u.year || 1) : u; return { day: k, month: R.month, year: R.year }; } function i(u, E, s, p, V) { if (u < 1 || E < 1 || s < 1) throw new Error("Invalid date input"); const k = { day: u, month: E, year: s }, R = Q.indexOf(p); if (R === -1) throw new Error("Invalid firstDayOfWeek value"); const I = (t(k) - R + 7) % 7, x = e(), b = (P) => P.day === x.day && P.month === x.month && P.year === x.year, f = []; let T = { ...k }; for (let P = 0; P < I; P++) T = D(T); for (let P = 0; P < 7; P++) { let w; if (T.month === V.month && T.year === V.year) w = te.current; else { const F = y(k.month, k.year); T.month === F.month && T.year === F.year ? w = te.previous : w = te.next; } const j = b(T), N = n(T); f.push({ date: T, monthTag: w, isCurrent: j, weekEnd: N }), P < 6 && (T = O(T)); } return { days: f, weekNumber: 0, year: s }; } function v(u, E, s, p) { const V = [], k = { day: 1, month: u, year: E }, R = t(k), S = Q.indexOf(s); if (S === -1) throw new Error("Invalid firstDayOfWeek value"); const I = (R - S + 7) % 7; let x = k; for (let f = 0; f < I; f++) x = D(x); let b = x; for (let f = 0; f < 6; f++) { const T = i(b.day, b.month, b.year, s, p); V.push(T); for (let L = 0; L < 7; L++) b = O(b); } return V; } return { getMonthlyCalendar: v, getWeeklyCalendar: i, getPreviousDay: D, getNextDay: O, getDayInPreviousWeek: h, getDayInNextWeek: r, getDayInPreviousMonth: C, getDayInNextMonth: m, getNextYear: a, getPreviousYear: c }; } const oe = ["year", "month", "week", "day"]; var Me = /* @__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))(Me || {}), 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 d(r, i) { return e(r) < e(i); } function g(r) { return e({ year: r.year, month: r.month, day: r.day }); } function y(r, i, v = !0) { return v ? e(r) <= e(i) : g(r) <= g(i); } function D(r, i) { return e(r) === e(i); } function O(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 : y(i.from, r) && y(r, i.to); } function m(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 h(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: d, equal: D, inPeriod: C, isPoint: O, equalOrEarlier: y, isInitializedDate: t, isInitializedMonth: n, isInitializedYear: o, isMonthDisabledByDisableSince: m, isMonthDisabledByDisableUntil: a, sameTime: h, sameDay: c }; } const en = { 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: en, emits: ["viewChange", "previous", "next", "resetToToday"], setup(e, t) { const n = B(e.title), o = B(e.dailyViewTitle), d = B(e.weeklyViewTitle), g = B(e.monthlyViewTitle), y = B(e.yearViewTitle), D = 2, O = 62, C = B(e.activeView); z(() => e.activeView, (v, u) => { C.value = v; }), z(() => e.title, () => { n.value = e.title; }); const m = A(() => ({ top: `${D}px`, left: `${C.value * (D + 1) + (C.value - 1) * (O + 1)}px` })), a = A(() => C.value === 4 ? o.value : C.value === 3 ? d.value : C.value === 1 ? y.value : g.value); function c(v) { const u = oe.indexOf(v) + 1; C.value = u, t.emit("viewChange", u); } function h() { 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: () => h(), 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") }, [y.value]), l("span", { class: "f-calendar-view-switch-monthly", onClick: (v) => c("month") }, [g.value])]), l("div", { class: "f-calendar-view-switch-active-view", style: m.value }, [a.value])])]); } }), tn = { dates: { type: Array, default: [] }, daysInWeek: { type: Array, default: Q }, 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: tn, emits: ["click", "keyDown", "moreClick"], setup(e, t) { const n = B(e.daysInWeek); B(e.enableKeyboadNavigate); const o = B(e.enableMarkCurrent), d = B(e.activeDay), g = B(e.events), { assignEventsToWeeks: y, assignEventsToDays: D, renderEventItem: O, useCompareCompsition: C } = le("eventsComposition"), { equal: m } = C, a = B(); function c(b, f) { return e.enableCrossDay ? y(b, f) : D(b, f); } const h = B(c(e.dates, g.value)); z(() => e.enableCrossDay, () => { h.value = c(e.dates, e.events); }), z(() => e.dates, () => { h.value = c(e.dates, g.value); }), z(() => e.activeDay, () => { d.value = e.activeDay; }), z(() => e.events, () => { g.value = e.events, h.value = c(e.dates, e.events); }), z(() => e.daysInWeek, (b, f) => { n.value = b; }); function r(b) { return !!d.value && m({ year: d.value.year, month: d.value.month, day: d.value.day }, b); } const i = (b, f, T) => { const P = { "f-datepicker-no-currmonth": b.monthTag === te.previous || b.monthTag === te.next, "f-calendar-weekday": b.weekEnd, "f-calendar-workday": !b.weekEnd, "f-calendar-today": b.isCurrent }, w = `d_${f}_${T}`; return P[w] = !0, P; }, v = (b) => { const f = b.monthTag === te.current && r(b.date), T = b.isCurrent && o.value; return { "f-calendar-month-view-date": !0, "f-calendar-month-view-selected": f, "f-calendar-month-view-current": T }; }; function u(b, f) { e.disabled || f.showMore || (b.stopPropagation(), t.emit("click", { date: f.date, view: "month" })); } function E(b, f) { e.disabled || t.emit("moreClick", { date: f.date, view: "month" }); } const s = A(() => ({ width: `${e.width}px`, height: `${e.height}px` })), p = B(0), V = () => { const b = a.value; if (!b) return 0; const f = b.querySelector(".f-calendar--daygrid-row"); if (!f) return 0; const T = f.offsetHeight; return Math.max(0, Math.floor(T / 19) - 1); }; function k() { return l("div", { class: "w-100" }, [l("table", { class: { "w-100": !0, "show-border": e.showBorder } }, [n.value && n.value.map((b) => l("th", null, [b]))])]); } function R(b, f) { return l("div", { class: "f-calendar--daygrid-row-header" }, [l("table", null, [l("tbody", null, [l("tr", null, [b.days && b.days.map((T, L) => l("td", { class: i(T, f, L), onClick: (P) => u(P, T), style: "position: relative;" }, null))])])])]); } function S(b, f) { return b.days && b.days.map((T, L) => l("td", { class: i(T, f, 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 I(b) { const f = Math.max(0, p.value || V()), T = !!(b.events && b.events.length > f), L = ce([...b.events || []]), P = T ? L.slice(0, f) : L; return T && P && P.length > 0 && P[P.length - 1].forEach((w) => { w.data && (w.showMore = !0, w.moreCount = b.events.length - f + 1); }), P.map((w, j) => l("tr", null, [w.map((N, F) => N.showMore ? l("td", { colspan: 1, rowspan: 1, onClick: (q) => u(q, N) }, [l("a", { class: "f-calendar-event p-0 m-0 pl-1 more-events ", onClick: (q) => E(q, b.days[F]) }, [l("div", { class: "event-title" }, [e.moreText.replace("#count#", N.moreCount)])])]) : l("td", { colspan: N.colspan || 1, rowspan: N.rowspan || 1, onClick: (q) => u(q, b.days[F]) }, [N.data && O(N)]))])); } function x() { return l("div", { class: "w-100 h-100" }, [l("div", { class: "f-calendar--daygrid" }, [h.value.map((b, f) => l("div", { class: "f-calendar--daygrid-row" }, [R(b, f), l("div", { class: "f-calendar--daygrid-content" }, [l("table", null, [l("thead", null, [l("tr", null, [S(b, f)])]), l("tbody", null, [I(b)])])])]))])]); } return z(() => e.height, (b, f) => { b !== f && Ne(() => { p.value = V(), h.value = [...h.value]; }); }), ie(() => { p.value = V(); }), () => 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" }, [k()])])]), l("tbody", null, [l("tr", { style: "height: 100%" }, [l("td", { class: "f-calendar-content" }, [x()])])])])]); } }), nn = { daysInWeek: { type: Array, default: Q }, 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: nn, emits: [], setup(e) { const t = B(), n = B(), o = B(e.daysInWeek), d = B(e.week), g = B(e.enableMarkCurrent), y = B(e.events), D = B([]), { equal: O } = Oe(), { convertDateToDateObject: C } = ue(); function m(s) { return d.value.days.map((V) => { const k = { year: V.date.year, month: V.date.month, day: V.date.day, hour: s.hour, minute: s.minute, second: s.second }, R = y.value.filter((S) => O(C(S[e.startDateField]), k)); return { day: k, events: R }; }); } function a() { const s = []; for (let p = 0; p < 24; p++) { const V = { hour: p, minute: 0, second: 0 }, k = { hour: p, minute: 30, second: 0 }, R = m(V), S = m(k); s.push({ time: V, events: R, title: p > 0 ? `${p}:00` : "", part: "upper" }), s.push({ time: k, events: S, title: `${p}:30`, part: "lower" }); } D.value = s; } a(), z(() => e.week, () => { d.value = e.week, a(); }), z(() => e.events, () => { y.value = e.events, a(); }); const c = (s) => ({ "f-calendar-week-view-date": !0, "f-calendar-week-view-current": s.isCurrent && g.value }); function h() { 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, p) => l("div", { class: "f-calendar-week-view-header-cell" }, [l("div", { class: c(d.value.days[p]) }, [d.value.days[p].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 I = (s[e.startDateField].hour || 0) + (s[e.startDateField].minute || 0) / 60; return { height: `${44 * ((s.ends.hour || 0) + (s.ends.minute || 0) / 60 - I) - 2 - 2 - 1 - 1}px` }; } function u() { return D.value.map((s) => l("div", { class: i(s) }, [s.events.map((p) => l("div", { class: "f-calendar-week-view-item-cell" }, [p.events.length > 0 && p.events.map((V) => l("div", { class: "f-calendar-event", style: v(V) }, [V.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" }, [h(), l("div", { class: "f-calendar-week-view-content", ref: t }, [r(), E()])]); } }), an = { 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: an, emits: [], setup(e) { const t = B(), n = B(), o = B(e.dayInWeek), d = B(e.day), g = B(e.enableMarkCurrent), y = B(e.events), D = B([]), { convertDateToDateObject: O } = ue(), { equal: C } = Oe(); function m(s) { const p = { year: d.value.date.year, month: d.value.date.month, day: d.value.date.day, hour: s.hour, minute: s.minute, second: s.second }, V = y.value.filter((k) => C(O(k[e.dateField]), p)); return [{ day: p, events: V }]; } function a() { const s = []; for (let p = 0; p < 24; p++) { const V = { hour: p, minute: 0, second: 0 }, k = { hour: p, minute: 30, second: 0 }, R = m(V), S = m(k); s.push({ time: V, events: R, title: p > 0 ? `${p}:00` : "", part: "upper" }), s.push({ time: k, events: S, title: `${p}:30`, part: "lower" }); } D.value = s; } a(), z(() => e.day, () => { d.value = e.day, a(); }), z(() => e.events, () => { y.value = e.events, a(); }); const c = (s) => ({ "f-calendar-day-view-date": !0, "f-calendar-day-view-current": s.isCurrent && g.value }); function h() { 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(d.value) }, [d.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, P, w; const I = (((T = s.starts) == null ? void 0 : T.hour) || 0) + (((L = s.starts) == null ? void 0 : L.minute) || 0) / 60; return { height: `${44 * ((((P = s.ends) == null ? void 0 : P.hour) || 0) + (((w = s.ends) == null ? void 0 : w.minute) || 0) / 60 - I) - 2 - 2 - 1 - 1}px` }; } function u() { return D.value.map((s) => l("div", { class: i(s) }, [s.events.map((p) => l("div", { class: "f-calendar-day-view-item-cell" }, [p.events.length > 0 && p.events.map((V) => l("div", { class: "f-calendar-event", style: v(V) }, [V.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" }, [h(), l("div", { class: "f-calendar-day-view-content", ref: t }, [r(), E()])]); } }), rn = /* @__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: d, renderEventItemForMonths: g } = le("eventsComposition"), y = B(0), D = () => { const a = n.value; if (!a) return 0; const h = a.querySelector(".yearview-monthitem").offsetHeight; return Math.max(0, Math.floor((h - 40) / 24)); }, O = (a) => { const c = !!(a && a.length > y.value); if (c) { const h = ce(a), r = c ? h == null ? void 0 : h.slice(0, y.value) : h; if (r && r.length > 0) { const i = r[r.length - 1]; i.data && (i.showMore = !0, i.moreCount = a.length - y.value + 1); } return r; } return a; }, C = A(() => d(e.activeYear, e.events)); function m(a, c) { const h = { year: e.activeYear, month: parseInt(c, 10) }; t.emit("moreClick", a, { date: h, view: "year" }); } return z(() => e.height, (a, c) => { a !== c && Ne(() => { y.value = D(), o.value = { ...e.monthLabels }; }); }), ie(() => { y.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 h; 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" }, [(h = O(C.value[a])) == null ? void 0 : h.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) => m(v, a) }, [e.moreText.replace("#count#", r.moreCount)])]) : g(r))])])])]); })])]); } }), on = /* @__PURE__ */ ee({ name: "MoreEventList", props: { events: Array, popoverOffsetX: Number }, setup(e, t) { const n = B(), o = A(() => n), d = A(() => e.events), { renderEventItemForMore: g } = le("eventsComposition"), y = B(0); return t.expose({ popoverRef: o }), () => l(Rt, { id: "calendar-more-events", customStyles: { filter: "drop-shadow(#c5c5c5 0px 0px 6px)" }, offsetX: y, 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 = d.value) == null ? void 0 : D.map((O) => g(O))])])])]; } }); } }); function ln() { 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") }, d = e("calendar.today"), g = e("calendar.thisYear"), y = e("calendar.yearView"), D = e("calendar.monthView"), O = e("calendar.weekView"), C = e("calendar.dayView"), m = e("calendar.titleFormat"), a = e("calendar.yearViewTitleFormat"), c = e("calendar.prevMonth"), h = 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"), p = e("calendar.more", "") || "还有 #count# 项..."; return { monthLabels: n, weekDayLabels: o, today: d, monthViewTitle: D, weekViewTitle: O, dayViewTitle: C, titleFormat: m, prevMonth: c, nextMonth: h, prevWeek: r, nextWeek: i, prevDay: v, nextDay: u, yearViewTitle: y, yearViewTitleFormat: a, thisYear: g, prevYear: E, nextYear: s, moreText: p, locale: t() }; } function sn(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 cn(e) { return e instanceof Date || typeof e == "object" && Object.prototype.toString.call(e) === "[object Date]"; } function un(e) { if (!cn(e) && typeof e != "number") return !1; const t = sn(e); return !isNaN(Number(t)); } function dn(e, t, n, o, d, g, y) { const { equalOrEarlier: D, sameDay: O } = o, { convertDateToDateObject: C } = t, { parseToDate: m, formatTo: a } = n; function c(S, I) { S.forEach((f) => { f.days.forEach((T) => { T.events = []; }); }); const x = /* @__PURE__ */ new Map(), b = (f) => { if (!f) return null; if (x.has(f)) return x.get(f); const T = m(f, "yyyy-MM-dd"); if (!T) return null; const L = C(T); return x.set(f, L), L; }; return I.forEach((f) => { const { eventDateField: T, startDateField: L } = e, P = K(f, T) || K(f, L), w = b(P); w && S.forEach((j) => { j.days.forEach((N) => { var F; O(N.date, w) && ((F = N.events) == null || F.push({ id: f[e.idField], data: { ...f }, eventDate: w, isSingleDay: !0 })); }); }); }), S.forEach((f) => { const T = [], L = f.days.map((w, j) => w.events && w.events.length > 0 ? w.events.map((N, F) => ({ ...N, // 在非跨天模式下,colspan为1,rowspan为1 colspan: 1, rowspan: 1, // 添加位置信息 startIndex: j, endIndex: j })) : []), P = Math.max(...L.map((w) => w.length), 0); for (let w = 0; w < P; w++) { const j = []; for (let N = 0; N < 7; N++) L[N][w] ? j.push(L[N][w]) : j.push({ colspan: 1, rowspan: 1, data: null }); T.push(j); } f.events = T; }), S; } function h(S, I) { S.forEach((f) => { f.events = []; }); const x = /* @__PURE__ */ new Map(), b = (f) => { if (!f) return null; if (x.has(f)) return x.get(f); const T = m(f, "yyyy-MM-dd"); if (!T) return null; const L = C(T); return x.set(f, L), L; }; return I.forEach((f) => { const { startDateField: T, endDateField: L } = e, P = b(K(f, T)), w = b(K(f, L)); !P || !w || S.forEach((j) => { var W, Y, G, U; const N = j.days[0].date, F = j.days[j.days.length - 1].date; if (!(D(w, N, !1) || D(F, P, !1))) if (O(P, w)) (W = j.events) == null || W.push({ id: f[e.idField], data: { ...f }, eventDate: P, isSingleDay: !0 }); else { const J = D(N, P, !1) ? P : N, H = D(w, F, !1) ? w : F; let X = -1, ae = -1; j.days.forEach((de, fe) => { O(de.date, J) && (X = fe), O(de.date, H) && (ae = fe); }), X !== -1 && ae !== -1 && ((Y = j.events) == null || Y.push({ id: f[e.idField], data: { ...f }, // 修复:eventDate 应该是事件在整个事件范围内的起始日期 eventDate: P, // 添加在当前周的起始和结束日期 startDate: J, endDate: H, // 添加在当前周的起始和结束索引 startIndex: X, endIndex: ae, colspan: ae - X + 1, isCrossDay: !0 })); } else O(P, F) && !O(w, F) && ((G = j.events) == null || G.push({ id: `${f[e.idField]}_start`, data: { ...f }, eventDate: P, isSingleDay: !0, isOverlapping: !0, originalId: f[e.idField] })), O(w, N) && !O(P, N) && ((U = j.events) == null || U.push({ id: `${f[e.idField]}_end`, data: { ...f }, eventDate: w, isSingleDay: !0, isOverlapping: !0, originalId: f[e.idField] })); }); }), S.forEach((f) => { f.days.forEach((T, L) => { var N; const P = (N = f.events) == null ? void 0 : N.filter((F) => F.isCrossDay ? L >= F.startIndex && L <= F.endIndex : F.isSingleDay ? O({ 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), w = P == null ? void 0 : P.find((F) => F.isCrossDay), j = (P == null ? void 0 : P.filter((F) => F.isSingleDay)) || []; w && j.length > 0 && j.forEach((F) => { var W, Y; ((W = f.events) == null ? void 0 : W.some((G) => (G.originalId === F.id || G.id === F.id) && O({ year: G.eventDate.year, month: G.eventDate.month, day: G.eventDate.day }, { year: T.date.year, month: T.date.month, day: T.date.day }))) || (Y = f.events) == null || Y.push({ id: F.id, data: { ...F.data }, eventDate: T.date, isSingleDay: !0, isOverlapping: !0, originalId: F.id }); }); }); }), S.forEach((f) => { const T = []; for (let w = 0; w < 10; w++) T[w] = Array(7).fill(null); [...f.events].sort((w, j) => { if (w.isCrossDay && !j.isCrossDay) return -1; if (!w.isCrossDay && j.isCrossDay) return 1; if (w.isCrossDay && j.isCrossDay) return w.startIndex - j.startIndex; const N = w.eventDate, F = j.eventDate; return N.year !== F.year ? N.year - F.year : N.month !== F.month ? N.month - F.month : N.day - F.day; }).forEach((w) => { let j = 0, N = !1, F = 0, q = 1; for (w.isCrossDay ? (F = w.startIndex, q = w.colspan) : (F = f.days.findIndex((W) => O({ year: w.eventDate.year, month: w.eventDate.month, day: w.eventDate.day }, { year: W.date.year, month: W.date.month, day: W.date.day })), q = 1); !N && j < T.length; ) { let W = !0; for (let Y = F; Y < F + q; Y++) if (T[j][Y] !== null) { W = !1; break; } if (W) { for (let Y = F; Y < F + q; Y++) T[j][Y] = Y === F ? w : { ...w, isPlaceholder: !0, colspan: Y === F ? q : 0 }; N = !0; } else j++; } }); const P = []; T.forEach((w) => { if (w.some((j) => j !== null)) { const j = []; for (let N = 0; N < w.length; N++) { const F = w[N]; F === null ? j.push({ colspan: 1, rowspan: 1, data: null }) : F.isPlaceholder || j.push(F), F && (F.colspan = F.colspan || 1, F.colspan > 1 && (N += F.colspan - 1)); } P.push(j); } }), f.events = P; }), S; } function r(S, I) { const x = {}; return I.forEach((b) => { const { eventDateField: f, startDateField: T } = e, L = K(b, f) || K(b, T); if (!L) return; const P = C(m(L, "yyyy-MM-dd")); if (P.year === S) { const w = "" + P.month; x[w] = x[w] || [], x[w].push({ data: { ...b }, eventDate: P }); } }), x; } function i() { return oe[g.value - 1]; } function v(S, I) { S.stopPropagation(), !e.disabled && d.emit("eventClick", { data: I.data, view: i() }); } const u = (S, I, x) => { const b = K(S, I); return typeof b == "string" ? b : b !== null && typeof b == "object" && !Array.isArray(b) && x ? b[x] || "" : b || ""; }; function E(S) { return Te(e.eventItemFormatter) ? e.eventItemFormatter(S.data, { parseToDate: m, formatTo: a, getValue: u, view: i(), locale: y }) : K(S.data, e.textField || "title"); } function s(S) { return Te(e.eventItemFormatter) ? "" : u(S.data, e.textField || "title", y); } const p = (S) => { if (!S || !S.data) return {}; if (!Te(e.customEventStyles)) return { styles: { "background-color": "#f3f3f3" } }; const I = e.customEventStyles(S.data, { parseToDate: m, formatTo: a, getValue: u, view: i(), locale: y }); return I && Object.keys(I).length > 0 ? I : {}; }; function V(S) { const { cls: I, styles: x } = p(S); return l("a", { onClick: (b) => v(b, S), style: x || {}, class: "f-calendar-event p-0 mx-1 my-0 " + (I || "") }, [l("div", { class: "event-title", innerHTML: E(S), title: s(S) }, null)]); } function k(S) { return l("li", null, [se(" "), E(S)]); } function R(S) { const { cls: I, styles: x } = p(S); return l("li", { style: { ...x || {}, "padding-bottom": "2px" }, class: I, onClick: (b) => v(b, S) }, [l("div", { class: "event-title pb-0 text-truncate", innerHTML: E(S), title: s(S) }, null)]); } return { assignEventsToDays: c, assignEventsToWeeks: h, renderEventItem: V, useCompareCompsition: o, useDateComposition: t, useDateFormatComposition: n, renderEventItemForMore: k, assignEventsToMonths: r, renderEventItemForMonths: R, getEventItemStyles: p }; } const ne = /* @__PURE__ */ ee({ name: "FCalendar", props: Ve, emits: ["dayClick", "dateChange", "eventClick", "moreClick", "viewChange"], setup(e, t) { const { titleFormat: n, today: o, prevMonth: d, nextMonth: g, dayViewTitle: y, monthViewTitle: D, weekViewTitle: O, weekDayLabels: C, monthLabels: m, prevWeek: a, nextWeek: c, prevDay: h, nextDay: r, yearViewTitle: i, yearViewTitleFormat: v, thisYear: u, prevYear: E, nextYear: s, moreText: p, locale: V } = ln(), k = Oe(), R = Wt(), S = ue(), { sameDay: I } = k, { getToday: x, convertDateToDateObject: b } = S, { parseToDate: f } = R, T = B(e.firstDayOfTheWeek), L = B(e.events), P = B(e.enableCrossDay), w = x(), j = B(e.activeDate), N = B(0), F = B(e.visible), q = dn(e, S, R, k, t, N, V); Et("eventsComposition", q); const W = B({ year: w.year || 1, month: w.month || 1, day: w.day || 1 }); function Y() { typeof j.value == "string" && (j.value = f(j.value, "yyyy-MM-dd")), un(j.value) && (W.value = b(j.value)); } Y(), z(() => e.activeDate, () => { j.value = e.activeDate, Y(); }), z(() => e.firstDayOfTheWeek, (M, $) => { M !== $ && (T.value = M); }), z(() =>