@object-ui/plugin-calendar 17.6.0 → 18.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3286 -0
- package/README.md +195 -45
- package/dist/CalendarView.d.ts.map +1 -1
- package/dist/ObjectCalendar.d.ts +93 -15
- package/dist/ObjectCalendar.d.ts.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +881 -664
- package/dist/index.umd.cjs +1 -1
- package/dist/visibleDays.d.ts +19 -0
- package/dist/visibleDays.d.ts.map +1 -0
- package/package.json +15 -13
package/dist/index.js
CHANGED
|
@@ -1,15 +1,56 @@
|
|
|
1
1
|
import * as e from "react";
|
|
2
2
|
import t, { useCallback as n, useEffect as r, useMemo as i, useRef as a, useState as o } from "react";
|
|
3
|
-
import { ComponentRegistry as s,
|
|
4
|
-
import { ElementDataSourceGate as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { Fragment as
|
|
9
|
-
import { usePullToRefresh as
|
|
10
|
-
import {
|
|
3
|
+
import { ComponentRegistry as s, ValueDataSource as c, applyNonGridRowCeiling as l, buildExpandFields as u, convertSortToQueryParams as d, createFieldColorResolver as f, elementDataSourceBlock as p, getRecordDisplayName as m, isRealCalendarDate as h, nonGridRowCeilingQuery as g, resolveAffordance as _, resolveRecordSourceConfig as v, resolveRecordSourceObjectName as y, toDateInputValue as b, toDisplayDate as x } from "@object-ui/core";
|
|
4
|
+
import { ElementDataSourceGate as S, NonGridRowCeilingNote as C, declaredUserMessage as w, extractWriteErrorMessage as ee, isPermissionError as T, useDataInvalidation as E, useFilterScope as te, useNavigationOverlay as ne, useObjectTranslation as re, useResolvedFilter as ie, useSafeTranslate as ae, useSchemaContext as oe, useSettledSchema as se } from "@object-ui/react";
|
|
5
|
+
import { createSafeTranslation as ce, firstDayOfWeek as le, useDisplayLocale as ue, useObjectTranslation as de } from "@object-ui/i18n";
|
|
6
|
+
import { CalendarIcon as fe, ChevronLeftIcon as pe, ChevronRight as me, ChevronRightIcon as he, PlusIcon as ge } from "lucide-react";
|
|
7
|
+
import { Button as D, Calendar as O, Dialog as _e, DialogContent as ve, DialogDescription as ye, DialogFooter as be, DialogHeader as xe, DialogTitle as Se, Input as Ce, Label as we, NavigationOverlay as Te, Popover as Ee, PopoverContent as De, PopoverTrigger as Oe, Select as k, SelectContent as A, SelectItem as j, SelectTrigger as ke, SelectValue as M, cn as N, legacyRecordDrawerWidthKey as Ae, recordOverlayWidthStorageKey as je, toast as Me, useIsMobile as Ne, useOverlayAnchor as Pe } from "@object-ui/components";
|
|
8
|
+
import { Fragment as Fe, jsx as P, jsxs as F } from "react/jsx-runtime";
|
|
9
|
+
import { usePullToRefresh as Ie } from "@object-ui/mobile";
|
|
10
|
+
import { RECORD_OVERLAY_DEFAULT_WIDTH as Le, RecordDetailPanel as Re, deriveRecordPageHref as ze } from "@object-ui/plugin-detail";
|
|
11
|
+
import { usePermissions as Be } from "@object-ui/permissions";
|
|
12
|
+
//#region src/visibleDays.ts
|
|
13
|
+
function Ve(e, t) {
|
|
14
|
+
return (e.getDay() - t + 7) % 7;
|
|
15
|
+
}
|
|
16
|
+
function I(e, t) {
|
|
17
|
+
let n = new Date(e);
|
|
18
|
+
return n.setDate(n.getDate() - Ve(n, t)), n;
|
|
19
|
+
}
|
|
20
|
+
function He(e, t) {
|
|
21
|
+
let n = e.getFullYear(), r = e.getMonth(), i = new Date(n, r, 1), a = new Date(n, r + 1, 0), o = Ve(i, t), s = [];
|
|
22
|
+
for (let e = o - 1; e >= 0; e--) {
|
|
23
|
+
let t = new Date(i.getTime());
|
|
24
|
+
t.setDate(t.getDate() - (e + 1)), s.push(t);
|
|
25
|
+
}
|
|
26
|
+
for (let e = 1; e <= a.getDate(); e++) s.push(new Date(n, r, e));
|
|
27
|
+
let c = 42 - s.length;
|
|
28
|
+
for (let e = 1; e <= c; e++) {
|
|
29
|
+
let t = new Date(a.getTime());
|
|
30
|
+
t.setDate(t.getDate() + e), s.push(t);
|
|
31
|
+
}
|
|
32
|
+
return s;
|
|
33
|
+
}
|
|
34
|
+
function L(e, t = 0) {
|
|
35
|
+
return new Date(e.getFullYear(), e.getMonth(), e.getDate() + t);
|
|
36
|
+
}
|
|
37
|
+
function Ue(e, t, n) {
|
|
38
|
+
if (t === "month") {
|
|
39
|
+
let t = He(e, n);
|
|
40
|
+
return {
|
|
41
|
+
start: L(t[0]),
|
|
42
|
+
end: L(t[t.length - 1], 1)
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
let r = L(t === "week" ? I(e, n) : e);
|
|
46
|
+
return {
|
|
47
|
+
start: r,
|
|
48
|
+
end: L(r, t === "week" ? 7 : 1)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
11
52
|
//#region src/CalendarView.tsx
|
|
12
|
-
var
|
|
53
|
+
var We = "bg-blue-100 text-blue-900 border border-blue-200", Ge = /* @__PURE__ */ new Date(), R = [
|
|
13
54
|
"bg-blue-100 text-blue-900 border border-blue-200",
|
|
14
55
|
"bg-emerald-100 text-emerald-900 border border-emerald-200",
|
|
15
56
|
"bg-amber-100 text-amber-900 border border-amber-200",
|
|
@@ -18,125 +59,160 @@ var z = "bg-blue-100 text-blue-900 border border-blue-200", de = /* @__PURE__ */
|
|
|
18
59
|
"bg-cyan-100 text-cyan-900 border border-cyan-200",
|
|
19
60
|
"bg-orange-100 text-orange-900 border border-orange-200",
|
|
20
61
|
"bg-fuchsia-100 text-fuchsia-900 border border-fuchsia-200"
|
|
21
|
-
],
|
|
22
|
-
function
|
|
23
|
-
if (!e) return { className:
|
|
24
|
-
if (
|
|
62
|
+
], Ke = /^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i, qe = /(^|\s)(bg|text|from|to|via)-/;
|
|
63
|
+
function z(e) {
|
|
64
|
+
if (!e) return { className: We };
|
|
65
|
+
if (Ke.test(e)) return {
|
|
25
66
|
className: "text-white",
|
|
26
67
|
inlineColor: e
|
|
27
68
|
};
|
|
28
|
-
if (
|
|
69
|
+
if (qe.test(e)) return { className: e };
|
|
29
70
|
let t = 0;
|
|
30
71
|
for (let n = 0; n < e.length; n++) t = (t << 5) - t + e.charCodeAt(n) | 0;
|
|
31
|
-
return { className:
|
|
72
|
+
return { className: R[Math.abs(t) % R.length] };
|
|
32
73
|
}
|
|
33
|
-
var
|
|
74
|
+
var B = ce({
|
|
34
75
|
"calendar.today": "Today",
|
|
35
76
|
"calendar.month": "Month",
|
|
36
77
|
"calendar.week": "Week",
|
|
37
78
|
"calendar.day": "Day",
|
|
38
79
|
"calendar.newEvent": "New event",
|
|
39
80
|
"calendar.moreEvents": "+{{count}} more",
|
|
40
|
-
"calendar.allDay": "
|
|
81
|
+
"calendar.allDay": "All Day",
|
|
82
|
+
"calendar.a11y.region": "Calendar",
|
|
83
|
+
"calendar.a11y.grid": "Calendar grid",
|
|
84
|
+
"calendar.a11y.goToToday": "Go to today",
|
|
85
|
+
"calendar.a11y.previousPeriod": "Previous period",
|
|
86
|
+
"calendar.a11y.nextPeriod": "Next period",
|
|
87
|
+
"calendar.a11y.currentDate": "Current date: {{date}}",
|
|
88
|
+
"calendar.a11y.dayCell": "{{date}}, {{count}} events",
|
|
89
|
+
"calendar.a11y.resizeEventEnd": "Resize event end",
|
|
90
|
+
"calendar.a11y.resizeEventEndHint": "Drag to change end date",
|
|
91
|
+
"calendar.a11y.resizeStart": "Resize start",
|
|
92
|
+
"calendar.a11y.resizeEnd": "Resize end"
|
|
41
93
|
}, "calendar.today");
|
|
42
|
-
function
|
|
43
|
-
let [m, h] = e.useState(n), [g, _] = e.useState(r), { t:
|
|
94
|
+
function Je({ events: t = [], view: n = "month", currentDate: r = Ge, locale: i = "default", onEventClick: a, onDateClick: o, onViewChange: s, onNavigate: c, onAddClick: l, onEventDrop: u, onTimeRangeSelect: d, slotMinutes: f = 30, className: p }) {
|
|
95
|
+
let [m, h] = e.useState(n), [g, _] = e.useState(r), { t: v } = B(), y = ue(), b = i === "default" ? y : i, x = le(b);
|
|
44
96
|
e.useEffect(() => {
|
|
45
97
|
_(r);
|
|
46
98
|
}, [r]), e.useEffect(() => {
|
|
47
99
|
h(n);
|
|
48
100
|
}, [n]);
|
|
49
|
-
let
|
|
50
|
-
|
|
101
|
+
let S = e.useRef(s);
|
|
102
|
+
S.current = s, e.useEffect(() => {
|
|
51
103
|
let e = window.matchMedia("(max-width: 639px)"), t = (e) => {
|
|
52
|
-
e.matches && (h("day"),
|
|
104
|
+
e.matches && (h("day"), S.current?.("day"));
|
|
53
105
|
};
|
|
54
106
|
return t(e), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
55
107
|
}, []);
|
|
56
|
-
let
|
|
108
|
+
let C = () => {
|
|
57
109
|
let e = new Date(g);
|
|
58
110
|
m === "month" ? e.setMonth(e.getMonth() - 1) : m === "week" ? e.setDate(e.getDate() - 7) : e.setDate(e.getDate() - 1), _(e), c?.(e);
|
|
59
|
-
},
|
|
111
|
+
}, w = () => {
|
|
60
112
|
let e = new Date(g);
|
|
61
113
|
m === "month" ? e.setMonth(e.getMonth() + 1) : m === "week" ? e.setDate(e.getDate() + 7) : e.setDate(e.getDate() + 1), _(e), c?.(e);
|
|
62
|
-
},
|
|
114
|
+
}, ee = () => {
|
|
63
115
|
let e = /* @__PURE__ */ new Date();
|
|
64
116
|
_(e), c?.(e);
|
|
65
|
-
},
|
|
117
|
+
}, T = (e) => {
|
|
66
118
|
h(e), s?.(e);
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
|
|
119
|
+
}, E = (e = "full") => {
|
|
120
|
+
let t = e === "short";
|
|
121
|
+
if (m === "month") return g.toLocaleDateString(b, {
|
|
122
|
+
month: t ? "short" : "long",
|
|
70
123
|
year: "numeric"
|
|
71
124
|
});
|
|
72
125
|
if (m === "week") {
|
|
73
|
-
let e =
|
|
74
|
-
return
|
|
126
|
+
let e = I(g, x), n = new Date(e);
|
|
127
|
+
return n.setDate(n.getDate() + 6), `${e.toLocaleDateString(b, {
|
|
128
|
+
month: "short",
|
|
129
|
+
day: "numeric"
|
|
130
|
+
})} - ${n.toLocaleDateString(b, t ? {
|
|
75
131
|
month: "short",
|
|
76
132
|
day: "numeric"
|
|
77
|
-
}
|
|
133
|
+
} : {
|
|
78
134
|
month: "short",
|
|
79
135
|
day: "numeric",
|
|
80
136
|
year: "numeric"
|
|
81
137
|
})}`;
|
|
82
138
|
}
|
|
83
|
-
return g.toLocaleDateString(
|
|
139
|
+
return g.toLocaleDateString(b, t ? {
|
|
140
|
+
weekday: "short",
|
|
141
|
+
month: "short",
|
|
142
|
+
day: "numeric"
|
|
143
|
+
} : {
|
|
84
144
|
weekday: "long",
|
|
85
145
|
month: "long",
|
|
86
146
|
day: "numeric",
|
|
87
147
|
year: "numeric"
|
|
88
148
|
});
|
|
89
|
-
},
|
|
90
|
-
return /* @__PURE__ */
|
|
149
|
+
}, te = e.useRef(0);
|
|
150
|
+
return /* @__PURE__ */ F("div", {
|
|
91
151
|
role: "region",
|
|
92
|
-
"aria-label": "
|
|
93
|
-
className:
|
|
94
|
-
children: [/* @__PURE__ */
|
|
152
|
+
"aria-label": v("calendar.a11y.region"),
|
|
153
|
+
className: N("flex flex-col h-full bg-background min-w-0 overflow-hidden", p),
|
|
154
|
+
children: [/* @__PURE__ */ F("div", {
|
|
95
155
|
className: "flex flex-wrap items-center justify-between gap-2 p-2 sm:p-4 border-b min-w-0",
|
|
96
|
-
children: [/* @__PURE__ */
|
|
97
|
-
className: "flex items-center gap-4",
|
|
98
|
-
children: [/* @__PURE__ */
|
|
99
|
-
className: "flex items-center bg-muted/50 rounded-lg p-1 gap-1",
|
|
156
|
+
children: [/* @__PURE__ */ F("div", {
|
|
157
|
+
className: "flex items-center gap-4 min-w-0 max-w-full",
|
|
158
|
+
children: [/* @__PURE__ */ F("div", {
|
|
159
|
+
className: "flex shrink-0 items-center bg-muted/50 rounded-lg p-1 gap-1",
|
|
100
160
|
children: [
|
|
101
|
-
/* @__PURE__ */
|
|
161
|
+
/* @__PURE__ */ P(D, {
|
|
102
162
|
variant: "ghost",
|
|
103
163
|
size: "sm",
|
|
104
|
-
onClick:
|
|
164
|
+
onClick: ee,
|
|
105
165
|
className: "h-8",
|
|
106
|
-
"aria-label": "
|
|
107
|
-
children:
|
|
166
|
+
"aria-label": v("calendar.a11y.goToToday"),
|
|
167
|
+
children: v("calendar.today")
|
|
108
168
|
}),
|
|
109
|
-
/* @__PURE__ */
|
|
110
|
-
/* @__PURE__ */
|
|
169
|
+
/* @__PURE__ */ P("div", { className: "h-4 w-px bg-border mx-1" }),
|
|
170
|
+
/* @__PURE__ */ P(D, {
|
|
111
171
|
variant: "ghost",
|
|
112
172
|
size: "icon",
|
|
113
|
-
"aria-label": "
|
|
114
|
-
onClick:
|
|
173
|
+
"aria-label": v("calendar.a11y.previousPeriod"),
|
|
174
|
+
onClick: C,
|
|
115
175
|
className: "h-8 w-8",
|
|
116
|
-
children: /* @__PURE__ */
|
|
176
|
+
children: /* @__PURE__ */ P(pe, { className: "h-4 w-4" })
|
|
117
177
|
}),
|
|
118
|
-
/* @__PURE__ */
|
|
178
|
+
/* @__PURE__ */ P(D, {
|
|
119
179
|
variant: "ghost",
|
|
120
180
|
size: "icon",
|
|
121
|
-
"aria-label": "
|
|
122
|
-
onClick:
|
|
181
|
+
"aria-label": v("calendar.a11y.nextPeriod"),
|
|
182
|
+
onClick: w,
|
|
123
183
|
className: "h-8 w-8",
|
|
124
|
-
children: /* @__PURE__ */
|
|
184
|
+
children: /* @__PURE__ */ P(he, { className: "h-4 w-4" })
|
|
125
185
|
})
|
|
126
186
|
]
|
|
127
|
-
}), /* @__PURE__ */
|
|
187
|
+
}), /* @__PURE__ */ F(Ee, { children: [/* @__PURE__ */ P(Oe, {
|
|
128
188
|
asChild: !0,
|
|
129
|
-
children: /* @__PURE__ */
|
|
189
|
+
children: /* @__PURE__ */ F(D, {
|
|
130
190
|
variant: "ghost",
|
|
131
|
-
"aria-label":
|
|
132
|
-
|
|
133
|
-
|
|
191
|
+
"aria-label": v("calendar.a11y.currentDate", { date: E() }),
|
|
192
|
+
title: E(),
|
|
193
|
+
className: N("text-base sm:text-xl font-semibold h-auto px-2 sm:px-3 py-1 hover:bg-muted/50 transition-colors", "flex items-center gap-2 min-w-0 max-w-full"),
|
|
194
|
+
children: [
|
|
195
|
+
/* @__PURE__ */ P(fe, { className: "h-5 w-5 shrink-0 text-muted-foreground" }),
|
|
196
|
+
/* @__PURE__ */ P("span", {
|
|
197
|
+
"data-date-label": "full",
|
|
198
|
+
className: "hidden min-w-0 truncate sm:block",
|
|
199
|
+
children: E()
|
|
200
|
+
}),
|
|
201
|
+
/* @__PURE__ */ P("span", {
|
|
202
|
+
"data-date-label": "short",
|
|
203
|
+
className: "min-w-0 truncate sm:hidden",
|
|
204
|
+
children: E("short")
|
|
205
|
+
})
|
|
206
|
+
]
|
|
134
207
|
})
|
|
135
|
-
}), /* @__PURE__ */
|
|
208
|
+
}), /* @__PURE__ */ P(De, {
|
|
136
209
|
className: "w-auto p-0",
|
|
137
210
|
align: "start",
|
|
138
|
-
children: /* @__PURE__ */
|
|
211
|
+
children: /* @__PURE__ */ P(O, {
|
|
212
|
+
localeTag: b,
|
|
213
|
+
weekStartsOn: x,
|
|
139
214
|
mode: "single",
|
|
215
|
+
defaultMonth: Number.isNaN(g.getTime()) ? void 0 : g,
|
|
140
216
|
selected: g,
|
|
141
217
|
onSelect: (e) => {
|
|
142
218
|
e && (_(e), c?.(e));
|
|
@@ -146,71 +222,74 @@ function he({ events: t = [], view: n = "month", currentDate: r = de, locale: i
|
|
|
146
222
|
endMonth: new Date(2050, 11)
|
|
147
223
|
})
|
|
148
224
|
})] })]
|
|
149
|
-
}), /* @__PURE__ */
|
|
225
|
+
}), /* @__PURE__ */ F("div", {
|
|
150
226
|
className: "flex items-center gap-2",
|
|
151
|
-
children: [/* @__PURE__ */
|
|
227
|
+
children: [/* @__PURE__ */ F(k, {
|
|
152
228
|
value: m,
|
|
153
|
-
onValueChange:
|
|
154
|
-
children: [/* @__PURE__ */
|
|
229
|
+
onValueChange: T,
|
|
230
|
+
children: [/* @__PURE__ */ P(ke, {
|
|
155
231
|
className: "w-32 bg-background",
|
|
156
|
-
children: /* @__PURE__ */
|
|
157
|
-
}), /* @__PURE__ */
|
|
158
|
-
/* @__PURE__ */
|
|
232
|
+
children: /* @__PURE__ */ P(M, {})
|
|
233
|
+
}), /* @__PURE__ */ F(A, { children: [
|
|
234
|
+
/* @__PURE__ */ P(j, {
|
|
159
235
|
value: "day",
|
|
160
|
-
children:
|
|
236
|
+
children: v("calendar.day")
|
|
161
237
|
}),
|
|
162
|
-
/* @__PURE__ */
|
|
238
|
+
/* @__PURE__ */ P(j, {
|
|
163
239
|
value: "week",
|
|
164
|
-
children:
|
|
240
|
+
children: v("calendar.week")
|
|
165
241
|
}),
|
|
166
|
-
/* @__PURE__ */
|
|
242
|
+
/* @__PURE__ */ P(j, {
|
|
167
243
|
value: "month",
|
|
168
|
-
children:
|
|
244
|
+
children: v("calendar.month")
|
|
169
245
|
})
|
|
170
246
|
] })]
|
|
171
|
-
}), l && /* @__PURE__ */
|
|
247
|
+
}), l && /* @__PURE__ */ F(D, {
|
|
172
248
|
onClick: l,
|
|
173
249
|
size: "sm",
|
|
174
250
|
className: "gap-1",
|
|
175
|
-
children: [/* @__PURE__ */
|
|
251
|
+
children: [/* @__PURE__ */ P(ge, { className: "h-4 w-4" }), v("calendar.newEvent")]
|
|
176
252
|
})]
|
|
177
253
|
})]
|
|
178
|
-
}), /* @__PURE__ */
|
|
254
|
+
}), /* @__PURE__ */ F("div", {
|
|
179
255
|
className: "flex-1 overflow-auto",
|
|
180
256
|
onTouchStart: (e) => {
|
|
181
|
-
|
|
257
|
+
te.current = e.touches[0].clientX;
|
|
182
258
|
},
|
|
183
259
|
onTouchEnd: (e) => {
|
|
184
|
-
let t =
|
|
260
|
+
let t = te.current - e.changedTouches[0].clientX;
|
|
185
261
|
if (Math.abs(t) > 50) {
|
|
186
262
|
let e = new Date(g);
|
|
187
263
|
m === "day" ? e.setDate(e.getDate() + (t > 0 ? 1 : -1)) : m === "week" ? e.setDate(e.getDate() + (t > 0 ? 7 : -7)) : e.setMonth(e.getMonth() + (t > 0 ? 1 : -1)), _(e), c?.(e);
|
|
188
264
|
}
|
|
189
265
|
},
|
|
190
266
|
children: [
|
|
191
|
-
m === "month" && /* @__PURE__ */
|
|
267
|
+
m === "month" && /* @__PURE__ */ P(Qe, {
|
|
192
268
|
date: g,
|
|
193
269
|
events: t,
|
|
194
|
-
locale:
|
|
270
|
+
locale: b,
|
|
271
|
+
weekStart: x,
|
|
195
272
|
onEventClick: a,
|
|
196
273
|
onDateClick: o,
|
|
197
274
|
onEventDrop: u
|
|
198
275
|
}),
|
|
199
|
-
m === "week" && /* @__PURE__ */
|
|
276
|
+
m === "week" && /* @__PURE__ */ P(nt, {
|
|
200
277
|
mode: "week",
|
|
201
278
|
date: g,
|
|
202
279
|
events: t,
|
|
203
|
-
locale:
|
|
280
|
+
locale: b,
|
|
281
|
+
weekStart: x,
|
|
204
282
|
slotMinutes: f,
|
|
205
283
|
onEventClick: a,
|
|
206
284
|
onEventDrop: u,
|
|
207
285
|
onTimeRangeSelect: d
|
|
208
286
|
}),
|
|
209
|
-
m === "day" && /* @__PURE__ */
|
|
287
|
+
m === "day" && /* @__PURE__ */ P(nt, {
|
|
210
288
|
mode: "day",
|
|
211
289
|
date: g,
|
|
212
290
|
events: t,
|
|
213
|
-
locale:
|
|
291
|
+
locale: b,
|
|
292
|
+
weekStart: x,
|
|
214
293
|
slotMinutes: f,
|
|
215
294
|
onEventClick: a,
|
|
216
295
|
onEventDrop: u,
|
|
@@ -220,67 +299,60 @@ function he({ events: t = [], view: n = "month", currentDate: r = de, locale: i
|
|
|
220
299
|
})]
|
|
221
300
|
});
|
|
222
301
|
}
|
|
223
|
-
function
|
|
224
|
-
|
|
225
|
-
return t.setDate(r), t;
|
|
302
|
+
function Ye(e, t) {
|
|
303
|
+
return e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth() && e.getDate() === t.getDate();
|
|
226
304
|
}
|
|
227
|
-
function
|
|
228
|
-
|
|
229
|
-
for (let e = a - 1; e >= 0; e--) {
|
|
230
|
-
let t = new Date(r.getTime());
|
|
231
|
-
t.setDate(t.getDate() - (e + 1)), o.push(t);
|
|
232
|
-
}
|
|
233
|
-
for (let e = 1; e <= i.getDate(); e++) o.push(new Date(t, n, e));
|
|
234
|
-
let s = 42 - o.length;
|
|
235
|
-
for (let e = 1; e <= s; e++) {
|
|
236
|
-
let t = new Date(i.getTime());
|
|
237
|
-
t.setDate(t.getDate() + e), o.push(t);
|
|
238
|
-
}
|
|
239
|
-
return o;
|
|
305
|
+
function Xe(e, t) {
|
|
306
|
+
return (Date.UTC(t.getFullYear(), t.getMonth(), t.getDate()) - Date.UTC(e.getFullYear(), e.getMonth(), e.getDate())) / 864e5;
|
|
240
307
|
}
|
|
241
|
-
function
|
|
242
|
-
|
|
308
|
+
function Ze(e, t) {
|
|
309
|
+
let n = new Date(e);
|
|
310
|
+
return n.setDate(n.getDate() + t), n;
|
|
243
311
|
}
|
|
244
|
-
function
|
|
245
|
-
let
|
|
312
|
+
function Qe({ date: t, events: n, locale: r = "default", weekStart: i, onEventClick: a, onDateClick: o, onEventDrop: s }) {
|
|
313
|
+
let c = e.useMemo(() => He(t, i), [
|
|
314
|
+
t.getFullYear(),
|
|
315
|
+
t.getMonth(),
|
|
316
|
+
i
|
|
317
|
+
]), l = e.useMemo(() => /* @__PURE__ */ new Date(), []), { t: u } = B(), d = e.useMemo(() => {
|
|
246
318
|
let e = new Date(2024, 0, 7);
|
|
247
319
|
return Array.from({ length: 7 }, (t, n) => {
|
|
248
|
-
let
|
|
249
|
-
return
|
|
320
|
+
let a = new Date(e);
|
|
321
|
+
return a.setDate(a.getDate() + i + n), a.toLocaleDateString(r, { weekday: "short" });
|
|
250
322
|
});
|
|
251
|
-
}, [r]), [
|
|
323
|
+
}, [r, i]), [f, p] = e.useState(null), [m, h] = e.useState(null), g = e.useMemo(() => {
|
|
252
324
|
let e = /* @__PURE__ */ new Map();
|
|
253
325
|
for (let t of n) {
|
|
254
326
|
let n = new Date(t.start), r = t.end ? new Date(t.end) : new Date(n);
|
|
255
327
|
n.setHours(0, 0, 0, 0), r.setHours(0, 0, 0, 0);
|
|
256
|
-
let
|
|
257
|
-
for (;
|
|
258
|
-
let
|
|
328
|
+
let a = new Date(n);
|
|
329
|
+
for (; a <= r;) {
|
|
330
|
+
let o = `${a.getFullYear()}-${a.getMonth()}-${a.getDate()}`, s = a.getTime() === n.getTime(), c = a.getTime() === r.getTime(), l = s || c || a.getDay() === i, u = e.get(o), d = {
|
|
259
331
|
event: t,
|
|
260
|
-
isTitleDay:
|
|
261
|
-
isSpanStart:
|
|
262
|
-
isSpanEnd:
|
|
332
|
+
isTitleDay: l,
|
|
333
|
+
isSpanStart: s,
|
|
334
|
+
isSpanEnd: c
|
|
263
335
|
};
|
|
264
|
-
|
|
336
|
+
u ? u.push(d) : e.set(o, [d]), a.setDate(a.getDate() + 1);
|
|
265
337
|
}
|
|
266
338
|
}
|
|
267
339
|
return e;
|
|
268
|
-
}, [n]),
|
|
269
|
-
|
|
340
|
+
}, [n, i]), _ = (e, t, n = "move", r) => {
|
|
341
|
+
p(t.id), e.dataTransfer.effectAllowed = "move";
|
|
270
342
|
let i = {
|
|
271
343
|
id: t.id,
|
|
272
344
|
mode: n,
|
|
273
345
|
...r ? { sourceDay: `${r.getFullYear()}-${r.getMonth()}-${r.getDate()}` } : {}
|
|
274
346
|
};
|
|
275
347
|
e.dataTransfer.setData("text/plain", JSON.stringify(i)), n === "resize-end" && e.stopPropagation();
|
|
276
|
-
},
|
|
277
|
-
|
|
278
|
-
},
|
|
279
|
-
e.preventDefault(), e.dataTransfer.dropEffect = "move",
|
|
280
|
-
},
|
|
281
|
-
e.currentTarget.contains(e.relatedTarget) ||
|
|
282
|
-
},
|
|
283
|
-
if (e.preventDefault(),
|
|
348
|
+
}, v = () => {
|
|
349
|
+
p(null), h(null);
|
|
350
|
+
}, y = (e, t) => {
|
|
351
|
+
e.preventDefault(), e.dataTransfer.dropEffect = "move", h(t);
|
|
352
|
+
}, b = (e) => {
|
|
353
|
+
e.currentTarget.contains(e.relatedTarget) || h(null);
|
|
354
|
+
}, x = (e, t) => {
|
|
355
|
+
if (e.preventDefault(), h(null), p(null), !s) return;
|
|
284
356
|
let r = e.dataTransfer.getData("text/plain"), i;
|
|
285
357
|
try {
|
|
286
358
|
i = JSON.parse(r);
|
|
@@ -292,90 +364,91 @@ function _e({ date: t, events: n, locale: r = "default", onEventClick: i, onDate
|
|
|
292
364
|
}
|
|
293
365
|
let a = n.find((e) => String(e.id) === String(i.id));
|
|
294
366
|
if (!a) return;
|
|
295
|
-
let
|
|
296
|
-
if (
|
|
297
|
-
let e = a.end ? new Date(a.end) : new Date(a.start), t =
|
|
298
|
-
if (t
|
|
367
|
+
let o = new Date(t);
|
|
368
|
+
if (o.setHours(0, 0, 0, 0), i.mode === "resize-end") {
|
|
369
|
+
let e = a.end ? new Date(a.end) : new Date(a.start), t = Xe(e, o);
|
|
370
|
+
if (t === 0) return;
|
|
299
371
|
let n = new Date(a.start);
|
|
300
|
-
if (n.setHours(0, 0, 0, 0),
|
|
301
|
-
|
|
302
|
-
r.setHours(e.getHours(), e.getMinutes(), e.getSeconds(), 0), o(a, new Date(a.start), r);
|
|
372
|
+
if (n.setHours(0, 0, 0, 0), o.getTime() < n.getTime()) return;
|
|
373
|
+
s(a, new Date(a.start), Ze(e, t));
|
|
303
374
|
return;
|
|
304
375
|
}
|
|
305
376
|
let c = new Date(a.start), l;
|
|
306
377
|
if (i.sourceDay) {
|
|
307
378
|
let [e, t, n] = i.sourceDay.split("-").map((e) => parseInt(e, 10));
|
|
308
379
|
l = new Date(e, t, n);
|
|
309
|
-
} else l =
|
|
310
|
-
|
|
311
|
-
let u = s.getTime() - l.getTime();
|
|
380
|
+
} else l = c;
|
|
381
|
+
let u = Xe(l, o);
|
|
312
382
|
if (u === 0) return;
|
|
313
|
-
let d =
|
|
314
|
-
a.end && (
|
|
383
|
+
let d = Ze(c, u), f;
|
|
384
|
+
a.end && (f = Ze(new Date(a.end), u)), s(a, d, f);
|
|
315
385
|
};
|
|
316
|
-
return /* @__PURE__ */
|
|
386
|
+
return /* @__PURE__ */ F("div", {
|
|
317
387
|
className: "flex flex-col h-full",
|
|
318
|
-
children: [/* @__PURE__ */
|
|
388
|
+
children: [/* @__PURE__ */ P("div", {
|
|
319
389
|
role: "row",
|
|
320
390
|
className: "grid grid-cols-7 border-b",
|
|
321
|
-
children:
|
|
391
|
+
children: d.map((e) => /* @__PURE__ */ P("div", {
|
|
322
392
|
role: "columnheader",
|
|
323
393
|
className: "p-2 text-center text-sm font-medium text-muted-foreground border-r last:border-r-0",
|
|
324
394
|
children: e
|
|
325
395
|
}, e))
|
|
326
|
-
}), /* @__PURE__ */
|
|
396
|
+
}), /* @__PURE__ */ P("div", {
|
|
327
397
|
role: "grid",
|
|
328
|
-
"aria-label": "
|
|
398
|
+
"aria-label": u("calendar.a11y.grid"),
|
|
329
399
|
className: "grid grid-cols-7 flex-1 auto-rows-fr",
|
|
330
|
-
children:
|
|
331
|
-
let
|
|
332
|
-
|
|
400
|
+
children: c.map((e, n) => {
|
|
401
|
+
let i = `${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`, c = g.get(i) || [], d = e.getMonth() === t.getMonth(), p = Ye(e, l), h = e.toLocaleDateString(r, {
|
|
402
|
+
weekday: "long",
|
|
403
|
+
month: "long",
|
|
404
|
+
day: "numeric",
|
|
405
|
+
year: "numeric"
|
|
406
|
+
});
|
|
407
|
+
return /* @__PURE__ */ F("div", {
|
|
333
408
|
role: "gridcell",
|
|
334
|
-
"aria-label":
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
className: I("text-sm font-medium mb-2", f && "inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-6 w-6"),
|
|
347
|
-
...f ? { "aria-current": "date" } : {},
|
|
409
|
+
"aria-label": c.length > 0 ? u("calendar.a11y.dayCell", {
|
|
410
|
+
date: h,
|
|
411
|
+
count: c.length
|
|
412
|
+
}) : h,
|
|
413
|
+
className: N("border-b border-r last:border-r-0 p-2 min-h-[100px] cursor-pointer hover:bg-accent/50", !d && "bg-muted/50 text-muted-foreground opacity-50", m === n && "ring-2 ring-primary"),
|
|
414
|
+
onClick: () => o?.(e),
|
|
415
|
+
onDragOver: (e) => y(e, n),
|
|
416
|
+
onDragLeave: b,
|
|
417
|
+
onDrop: (t) => x(t, e),
|
|
418
|
+
children: [/* @__PURE__ */ P("div", {
|
|
419
|
+
className: N("text-sm font-medium mb-2", p && "inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-6 w-6"),
|
|
420
|
+
...p ? { "aria-current": "date" } : {},
|
|
348
421
|
children: e.getDate()
|
|
349
|
-
}), /* @__PURE__ */
|
|
422
|
+
}), /* @__PURE__ */ F("div", {
|
|
350
423
|
className: "space-y-0.5",
|
|
351
|
-
children: [
|
|
352
|
-
let c = !n, { className: l, inlineColor:
|
|
353
|
-
return /* @__PURE__ */
|
|
424
|
+
children: [c.slice(0, 4).map(({ event: t, isTitleDay: n, isSpanStart: r, isSpanEnd: i }, o) => {
|
|
425
|
+
let c = !n, { className: l, inlineColor: d } = z(t.color), p = !!s && i;
|
|
426
|
+
return /* @__PURE__ */ F("div", {
|
|
354
427
|
role: "button",
|
|
355
428
|
title: t.title,
|
|
356
429
|
"aria-label": t.title,
|
|
357
|
-
draggable: !!
|
|
358
|
-
onDragStart: (n) =>
|
|
359
|
-
onDragEnd:
|
|
360
|
-
className:
|
|
361
|
-
style:
|
|
430
|
+
draggable: !!s,
|
|
431
|
+
onDragStart: (n) => _(n, t, "move", e),
|
|
432
|
+
onDragEnd: v,
|
|
433
|
+
className: N("relative text-xs hover:opacity-80 truncate", s ? "cursor-move" : "cursor-pointer", c ? "h-1.5" : "px-2 py-0.5", r ? "rounded-l" : "rounded-l-none", i ? "rounded-r" : "rounded-r-none", !i && "-mr-2", l, f === t.id && "opacity-50"),
|
|
434
|
+
style: d ? { backgroundColor: d } : void 0,
|
|
362
435
|
onClick: (e) => {
|
|
363
|
-
e.stopPropagation(),
|
|
436
|
+
e.stopPropagation(), a?.(t);
|
|
364
437
|
},
|
|
365
|
-
children: [c ? "" : t.title,
|
|
438
|
+
children: [c ? "" : t.title, p && /* @__PURE__ */ P("span", {
|
|
366
439
|
role: "separator",
|
|
367
|
-
"aria-label": "
|
|
368
|
-
title: "
|
|
440
|
+
"aria-label": u("calendar.a11y.resizeEventEnd"),
|
|
441
|
+
title: u("calendar.a11y.resizeEventEndHint"),
|
|
369
442
|
draggable: !0,
|
|
370
|
-
onDragStart: (n) =>
|
|
371
|
-
onDragEnd:
|
|
443
|
+
onDragStart: (n) => _(n, t, "resize-end", e),
|
|
444
|
+
onDragEnd: v,
|
|
372
445
|
onClick: (e) => e.stopPropagation(),
|
|
373
446
|
className: "absolute inset-y-0 right-0 w-2 cursor-ew-resize bg-black/25 hover:bg-black/50 rounded-r"
|
|
374
447
|
})]
|
|
375
|
-
}, `${t.id}-${
|
|
376
|
-
}),
|
|
448
|
+
}, `${t.id}-${o}`);
|
|
449
|
+
}), c.length > 4 && /* @__PURE__ */ P("div", {
|
|
377
450
|
className: "text-xs text-muted-foreground px-2",
|
|
378
|
-
children:
|
|
451
|
+
children: u("calendar.moreEvents", { count: c.length - 4 })
|
|
379
452
|
})]
|
|
380
453
|
})]
|
|
381
454
|
}, n);
|
|
@@ -383,50 +456,88 @@ function _e({ date: t, events: n, locale: r = "default", onEventClick: i, onDate
|
|
|
383
456
|
})]
|
|
384
457
|
});
|
|
385
458
|
}
|
|
386
|
-
var
|
|
387
|
-
function
|
|
459
|
+
var V = 48;
|
|
460
|
+
function H(e) {
|
|
388
461
|
let t = new Date(e);
|
|
389
462
|
return t.setHours(0, 0, 0, 0), t;
|
|
390
463
|
}
|
|
391
|
-
function
|
|
464
|
+
function $e(e) {
|
|
392
465
|
return e.getHours() * 60 + e.getMinutes();
|
|
393
466
|
}
|
|
394
|
-
function
|
|
467
|
+
function U(e) {
|
|
395
468
|
return `${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`;
|
|
396
469
|
}
|
|
397
|
-
function
|
|
398
|
-
let
|
|
399
|
-
|
|
400
|
-
|
|
470
|
+
function W(e, t) {
|
|
471
|
+
let n = new Date(e);
|
|
472
|
+
return n.setHours(0, t, 0, 0), n;
|
|
473
|
+
}
|
|
474
|
+
function et(e) {
|
|
475
|
+
let t = new Date(e.start);
|
|
476
|
+
return {
|
|
477
|
+
start: t,
|
|
478
|
+
end: e.end ? new Date(e.end) : new Date(t.getTime() + 36e5)
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
function tt(e, t) {
|
|
482
|
+
let n = e.minutes - e.grabOffsetMs / 6e4, r = Math.round(n / t) * t;
|
|
483
|
+
return e.withinOneDay ? Math.max(0, Math.min(1440 - e.durationMs / 6e4, r)) : r;
|
|
484
|
+
}
|
|
485
|
+
function G(e, t) {
|
|
486
|
+
return Math.round((H(t).getTime() - e.getTime()) / 864e5) * 1440 + $e(t);
|
|
487
|
+
}
|
|
488
|
+
function K(e, t, n) {
|
|
489
|
+
let r = new Date(e.keptMs), i = G(t, r);
|
|
490
|
+
if (e.kind === "resize-top") {
|
|
491
|
+
let a = Math.min(i - n, Math.max(0, e.minutes));
|
|
492
|
+
return {
|
|
493
|
+
start: W(t, a),
|
|
494
|
+
end: r,
|
|
495
|
+
startMin: a,
|
|
496
|
+
endMin: i
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
let a = Math.max(i + n, Math.min(1440, e.minutes));
|
|
500
|
+
return {
|
|
501
|
+
start: r,
|
|
502
|
+
end: W(t, a),
|
|
503
|
+
startMin: i,
|
|
504
|
+
endMin: a
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
function nt({ mode: t, date: n, events: r, locale: i = "default", weekStart: a, slotMinutes: o = 30, onEventClick: s, onEventDrop: c, onTimeRangeSelect: l }) {
|
|
508
|
+
let { t: u } = B(), d = V * o / 60, f = 1152, p = e.useMemo(() => {
|
|
509
|
+
if (t === "day") return [H(n)];
|
|
510
|
+
let e = I(n, a);
|
|
401
511
|
return Array.from({ length: 7 }, (t, n) => {
|
|
402
512
|
let r = new Date(e);
|
|
403
|
-
return r.setDate(e.getDate() + n),
|
|
513
|
+
return r.setDate(e.getDate() + n), H(r);
|
|
404
514
|
});
|
|
405
515
|
}, [
|
|
406
516
|
t,
|
|
407
517
|
n.getFullYear(),
|
|
408
518
|
n.getMonth(),
|
|
409
|
-
n.getDate()
|
|
410
|
-
|
|
519
|
+
n.getDate(),
|
|
520
|
+
a
|
|
521
|
+
]), m = e.useMemo(() => /* @__PURE__ */ new Date(), []), h = e.useCallback((e) => {
|
|
411
522
|
if (e.allDay) return !0;
|
|
412
523
|
let t = new Date(e.start), n = e.end ? new Date(e.end) : new Date(t), r = t.getHours() === 0 && t.getMinutes() === 0 && t.getSeconds() === 0, i = n.getHours() === 0 && n.getMinutes() === 0 && n.getSeconds() === 0, a = n.getTime() - t.getTime();
|
|
413
524
|
return !!(r && i || a >= 864e5);
|
|
414
|
-
}, []), { allDayEvents:
|
|
525
|
+
}, []), { allDayEvents: g, timedEvents: _ } = e.useMemo(() => {
|
|
415
526
|
let e = [], t = [];
|
|
416
|
-
for (let n of r)
|
|
527
|
+
for (let n of r) h(n) ? e.push(n) : t.push(n);
|
|
417
528
|
return {
|
|
418
529
|
allDayEvents: e,
|
|
419
530
|
timedEvents: t
|
|
420
531
|
};
|
|
421
|
-
}, [r,
|
|
532
|
+
}, [r, h]), v = e.useMemo(() => {
|
|
422
533
|
let e = /* @__PURE__ */ new Map();
|
|
423
|
-
for (let t of
|
|
424
|
-
for (let t of
|
|
425
|
-
let n =
|
|
534
|
+
for (let t of p) e.set(U(t), []);
|
|
535
|
+
for (let t of g) {
|
|
536
|
+
let n = H(new Date(t.start)), r = t.end ? new Date(t.end) : new Date(t.start), i = H(r);
|
|
426
537
|
r.getHours() === 0 && r.getMinutes() === 0 && r.getSeconds() === 0 && r.getTime() > n.getTime() && (i = new Date(i), i.setDate(i.getDate() - 1));
|
|
427
|
-
for (let r of
|
|
428
|
-
let a =
|
|
429
|
-
a < n || a > i || e.get(
|
|
538
|
+
for (let r of p) {
|
|
539
|
+
let a = H(r);
|
|
540
|
+
a < n || a > i || e.get(U(r)).push({
|
|
430
541
|
event: t,
|
|
431
542
|
isStart: a.getTime() === n.getTime(),
|
|
432
543
|
isEnd: a.getTime() === i.getTime()
|
|
@@ -434,16 +545,16 @@ function J({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
434
545
|
}
|
|
435
546
|
}
|
|
436
547
|
return e;
|
|
437
|
-
}, [
|
|
548
|
+
}, [p, g]), y = e.useMemo(() => {
|
|
438
549
|
let e = /* @__PURE__ */ new Map();
|
|
439
|
-
for (let t of
|
|
440
|
-
for (let t of
|
|
441
|
-
let
|
|
442
|
-
for (let i of
|
|
443
|
-
let a =
|
|
550
|
+
for (let t of p) e.set(U(t), []);
|
|
551
|
+
for (let t of _) {
|
|
552
|
+
let { start: n, end: r } = et(t);
|
|
553
|
+
for (let i of p) {
|
|
554
|
+
let a = H(i), o = new Date(a);
|
|
444
555
|
if (o.setDate(o.getDate() + 1), r <= a || n >= o) continue;
|
|
445
|
-
let s = n < a ? a : n, c = r > o ? o : r, l =
|
|
446
|
-
e.get(
|
|
556
|
+
let s = n < a ? a : n, c = r > o ? o : r, l = $e(s), u = c.getTime() === o.getTime() ? 1440 : $e(c);
|
|
557
|
+
e.get(U(i)).push({
|
|
447
558
|
event: t,
|
|
448
559
|
startMin: l,
|
|
449
560
|
endMin: Math.max(u, l + 15),
|
|
@@ -453,9 +564,9 @@ function J({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
453
564
|
}
|
|
454
565
|
}
|
|
455
566
|
return e;
|
|
456
|
-
}, [
|
|
567
|
+
}, [p, _]), b = e.useMemo(() => {
|
|
457
568
|
let e = /* @__PURE__ */ new Map();
|
|
458
|
-
for (let [t, n] of
|
|
569
|
+
for (let [t, n] of y) {
|
|
459
570
|
let r = [...n].sort((e, t) => e.startMin - t.startMin || e.endMin - t.endMin), i = [], a = [], o = [];
|
|
460
571
|
for (let e of r) {
|
|
461
572
|
let t = 0;
|
|
@@ -481,16 +592,16 @@ function J({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
481
592
|
e.set(t, o);
|
|
482
593
|
}
|
|
483
594
|
return e;
|
|
484
|
-
}, [
|
|
485
|
-
|
|
595
|
+
}, [y]), x = e.useRef(null), S = e.useRef([]), [C, w] = e.useState(null), ee = e.useRef(null);
|
|
596
|
+
ee.current = C;
|
|
486
597
|
let T = e.useRef(!1), E = e.useCallback((e, t) => {
|
|
487
|
-
let n =
|
|
598
|
+
let n = S.current[t];
|
|
488
599
|
if (!n) return 0;
|
|
489
|
-
let r = (e - n.getBoundingClientRect().top + n.scrollTop) /
|
|
600
|
+
let r = (e - n.getBoundingClientRect().top + n.scrollTop) / V * 60, i = Math.round(r / o) * o;
|
|
490
601
|
return Math.max(0, Math.min(1440, i));
|
|
491
|
-
}, [
|
|
492
|
-
for (let t = 0; t <
|
|
493
|
-
let n =
|
|
602
|
+
}, [o]), te = e.useCallback((e) => {
|
|
603
|
+
for (let t = 0; t < S.current.length; t++) {
|
|
604
|
+
let n = S.current[t];
|
|
494
605
|
if (!n) continue;
|
|
495
606
|
let r = n.getBoundingClientRect();
|
|
496
607
|
if (e >= r.left && e <= r.right) return t;
|
|
@@ -498,10 +609,10 @@ function J({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
498
609
|
return -1;
|
|
499
610
|
}, []);
|
|
500
611
|
e.useEffect(() => {
|
|
501
|
-
if (!
|
|
612
|
+
if (!C) return;
|
|
502
613
|
let e = (e) => {
|
|
503
|
-
let t =
|
|
504
|
-
|
|
614
|
+
let t = C.kind === "select" || C.kind === "move" ? te(e.clientX) : C.dayIndex, n = t < 0 ? C.dayIndex ?? 0 : t, r = E(e.clientY, n);
|
|
615
|
+
w((e) => e && (e.kind === "select" ? {
|
|
505
616
|
...e,
|
|
506
617
|
dayIndex: n >= 0 ? n : e.dayIndex,
|
|
507
618
|
headMinutes: r
|
|
@@ -514,44 +625,32 @@ function J({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
514
625
|
minutes: r
|
|
515
626
|
}));
|
|
516
627
|
}, t = (e) => {
|
|
517
|
-
let t =
|
|
628
|
+
let t = ee.current;
|
|
518
629
|
if (!t) {
|
|
519
|
-
|
|
630
|
+
w(null);
|
|
520
631
|
return;
|
|
521
632
|
}
|
|
522
633
|
try {
|
|
523
|
-
if (t.kind === "select" &&
|
|
524
|
-
let e = Math.min(t.anchorMinutes, t.headMinutes), n = Math.max(t.anchorMinutes, t.headMinutes), r = e, i = n === e ? Math.min(1440, e +
|
|
634
|
+
if (t.kind === "select" && l) {
|
|
635
|
+
let e = Math.min(t.anchorMinutes, t.headMinutes), n = Math.max(t.anchorMinutes, t.headMinutes), r = e, i = n === e ? Math.min(1440, e + o) : n, a = p[t.dayIndex] ?? p[0], s = new Date(a);
|
|
525
636
|
s.setHours(0, Math.round(r), 0, 0);
|
|
526
|
-
let
|
|
527
|
-
|
|
528
|
-
} else if (t.kind === "move" &&
|
|
529
|
-
let e = r.find((e) => String(e.id) === String(t.eventId));
|
|
530
|
-
if (e) {
|
|
531
|
-
let n = t.dayIndex < 0 ? 0 : t.dayIndex, r = t.minutes - t.grabMinuteOffset, i = Math.max(0, Math.min(1440 - t.durationMin, Math.round(r / a) * a)), o = f[n] ?? f[0], c = new Date(o);
|
|
532
|
-
c.setHours(0, i, 0, 0);
|
|
533
|
-
let l = new Date(c.getTime() + t.durationMin * 60 * 1e3);
|
|
534
|
-
T.current = !0, s(e, c, l);
|
|
535
|
-
}
|
|
536
|
-
} else if (t.kind === "resize-top" && s) {
|
|
637
|
+
let c = new Date(a);
|
|
638
|
+
c.setHours(0, Math.round(i), 0, 0), T.current = !0, l(s, c);
|
|
639
|
+
} else if (t.kind === "move" && c) {
|
|
537
640
|
let e = r.find((e) => String(e.id) === String(t.eventId));
|
|
538
641
|
if (e) {
|
|
539
|
-
let n =
|
|
540
|
-
|
|
541
|
-
let o = new Date(n);
|
|
542
|
-
o.setHours(0, t.anchorEndMin, 0, 0), T.current = !0, s(e, i, o);
|
|
642
|
+
let n = t.dayIndex < 0 ? 0 : t.dayIndex, r = W(p[n] ?? p[0], tt(t, o)), i = new Date(r.getTime() + t.durationMs);
|
|
643
|
+
T.current = !0, c(e, r, i);
|
|
543
644
|
}
|
|
544
|
-
} else if (t.kind === "resize-bottom" &&
|
|
645
|
+
} else if ((t.kind === "resize-top" || t.kind === "resize-bottom") && c) {
|
|
545
646
|
let e = r.find((e) => String(e.id) === String(t.eventId));
|
|
546
647
|
if (e) {
|
|
547
|
-
let n =
|
|
548
|
-
|
|
549
|
-
let o = new Date(n);
|
|
550
|
-
o.setHours(0, r, 0, 0), T.current = !0, s(e, i, o);
|
|
648
|
+
let { start: n, end: r } = K(t, p[t.dayIndex] ?? p[0], o);
|
|
649
|
+
T.current = !0, c(e, n, r);
|
|
551
650
|
}
|
|
552
651
|
}
|
|
553
652
|
} finally {
|
|
554
|
-
|
|
653
|
+
w(null), setTimeout(() => {
|
|
555
654
|
T.current = !1;
|
|
556
655
|
}, 50);
|
|
557
656
|
}
|
|
@@ -560,148 +659,147 @@ function J({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
560
659
|
window.removeEventListener("pointermove", e), window.removeEventListener("pointerup", t);
|
|
561
660
|
};
|
|
562
661
|
}, [
|
|
563
|
-
|
|
564
|
-
|
|
662
|
+
C,
|
|
663
|
+
p,
|
|
565
664
|
r,
|
|
566
|
-
|
|
567
|
-
s,
|
|
665
|
+
o,
|
|
568
666
|
c,
|
|
569
|
-
|
|
667
|
+
l,
|
|
668
|
+
te,
|
|
570
669
|
E
|
|
571
670
|
]);
|
|
572
|
-
let
|
|
671
|
+
let ne = e.useMemo(() => p.map((e) => ({
|
|
573
672
|
weekday: e.toLocaleDateString(i, { weekday: "short" }),
|
|
574
673
|
day: e.getDate(),
|
|
575
674
|
month: e.toLocaleDateString(i, { month: "short" }),
|
|
576
|
-
isToday:
|
|
675
|
+
isToday: Ye(e, m)
|
|
577
676
|
})), [
|
|
578
|
-
|
|
677
|
+
p,
|
|
579
678
|
i,
|
|
580
|
-
|
|
581
|
-
]),
|
|
582
|
-
if (!
|
|
679
|
+
m
|
|
680
|
+
]), re = e.useMemo(() => Array.from({ length: 24 }, (e, t) => new Date(2024, 0, 1, t, 0).toLocaleTimeString(i, { hour: "numeric" })), [i]), ie = (e, t, n, r) => {
|
|
681
|
+
if (!c || e.button !== 0) return;
|
|
583
682
|
e.stopPropagation(), e.preventDefault();
|
|
584
683
|
let i = E(e.clientY, n);
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
684
|
+
if (r === "body") {
|
|
685
|
+
let { start: e, end: r } = et(t.event), a = r.getTime() - e.getTime(), o = W(p[n], i);
|
|
686
|
+
w({
|
|
687
|
+
kind: "move",
|
|
688
|
+
eventId: t.event.id,
|
|
689
|
+
grabOffsetMs: Math.max(0, Math.min(a, o.getTime() - e.getTime())),
|
|
690
|
+
durationMs: a,
|
|
691
|
+
withinOneDay: t.isStart && t.isEnd,
|
|
692
|
+
dayIndex: n,
|
|
693
|
+
minutes: i
|
|
694
|
+
});
|
|
695
|
+
} else {
|
|
696
|
+
let { start: e, end: a } = et(t.event);
|
|
697
|
+
w({
|
|
698
|
+
kind: r === "top" ? "resize-top" : "resize-bottom",
|
|
699
|
+
eventId: t.event.id,
|
|
700
|
+
keptMs: (r === "top" ? a : e).getTime(),
|
|
701
|
+
dayIndex: n,
|
|
702
|
+
minutes: i
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
}, ae = (e, t) => {
|
|
706
|
+
if (!l || e.button !== 0) return;
|
|
607
707
|
e.preventDefault();
|
|
608
708
|
let n = E(e.clientY, t);
|
|
609
|
-
|
|
709
|
+
w({
|
|
610
710
|
kind: "select",
|
|
611
711
|
dayIndex: t,
|
|
612
712
|
anchorMinutes: n,
|
|
613
713
|
headMinutes: n
|
|
614
714
|
});
|
|
615
|
-
},
|
|
616
|
-
if (!
|
|
617
|
-
if (
|
|
618
|
-
let t = Math.min(
|
|
619
|
-
return /* @__PURE__ */
|
|
715
|
+
}, oe = (e) => {
|
|
716
|
+
if (!C) return null;
|
|
717
|
+
if (C.kind === "select" && C.dayIndex === e) {
|
|
718
|
+
let t = Math.min(C.anchorMinutes, C.headMinutes), n = Math.max(C.anchorMinutes, C.headMinutes), r = t / 60 * V, a = Math.max(d, (n - t) / 60 * V);
|
|
719
|
+
return /* @__PURE__ */ P("div", {
|
|
620
720
|
className: "absolute left-1 right-1 rounded bg-primary/30 border border-primary pointer-events-none z-10",
|
|
621
721
|
style: {
|
|
622
722
|
top: r,
|
|
623
723
|
height: a
|
|
624
724
|
},
|
|
625
725
|
"aria-hidden": !0,
|
|
626
|
-
children: /* @__PURE__ */
|
|
726
|
+
children: /* @__PURE__ */ P("div", {
|
|
627
727
|
className: "px-2 py-0.5 text-xs font-medium text-primary",
|
|
628
|
-
children:
|
|
728
|
+
children: q(p[e], t, n, i)
|
|
629
729
|
})
|
|
630
730
|
});
|
|
631
731
|
}
|
|
632
|
-
if (
|
|
633
|
-
let t =
|
|
634
|
-
return /* @__PURE__ */
|
|
732
|
+
if (C.kind === "move" && C.dayIndex === e) {
|
|
733
|
+
let t = tt(C, o), n = W(p[e], t), r = new Date(n.getTime() + C.durationMs), a = Math.max(0, t), s = Math.min(1440, t + Math.max(15, C.durationMs / 6e4)), c = a / 60 * V, l = Math.max(0, (s - a) / 60 * V);
|
|
734
|
+
return /* @__PURE__ */ P("div", {
|
|
635
735
|
className: "absolute left-1 right-1 rounded border-2 border-dashed border-primary bg-primary/10 pointer-events-none z-10",
|
|
636
736
|
style: {
|
|
637
|
-
top:
|
|
638
|
-
height:
|
|
737
|
+
top: c,
|
|
738
|
+
height: l
|
|
639
739
|
},
|
|
640
740
|
"aria-hidden": !0,
|
|
641
|
-
children: /* @__PURE__ */
|
|
741
|
+
children: /* @__PURE__ */ P("div", {
|
|
642
742
|
className: "px-2 py-0.5 text-xs font-medium text-primary",
|
|
643
|
-
children:
|
|
743
|
+
children: rt(n, r, i)
|
|
644
744
|
})
|
|
645
745
|
});
|
|
646
746
|
}
|
|
647
|
-
if ((
|
|
648
|
-
let t, n;
|
|
649
|
-
|
|
650
|
-
let r = t / 60 * W, o = (n - t) / 60 * W;
|
|
651
|
-
return /* @__PURE__ */ L("div", {
|
|
747
|
+
if ((C.kind === "resize-top" || C.kind === "resize-bottom") && C.dayIndex === e) {
|
|
748
|
+
let { start: t, end: n, startMin: r, endMin: a } = K(C, p[e], o), s = Math.max(0, r), c = Math.min(1440, a), l = s / 60 * V, u = Math.max(0, (c - s) / 60 * V);
|
|
749
|
+
return /* @__PURE__ */ P("div", {
|
|
652
750
|
className: "absolute left-1 right-1 rounded border-2 border-dashed border-primary bg-primary/10 pointer-events-none z-10",
|
|
653
751
|
style: {
|
|
654
|
-
top:
|
|
655
|
-
height:
|
|
752
|
+
top: l,
|
|
753
|
+
height: u
|
|
656
754
|
},
|
|
657
755
|
"aria-hidden": !0,
|
|
658
|
-
children: /* @__PURE__ */
|
|
756
|
+
children: /* @__PURE__ */ P("div", {
|
|
659
757
|
className: "px-2 py-0.5 text-xs font-medium text-primary",
|
|
660
|
-
children:
|
|
758
|
+
children: rt(t, n, i)
|
|
661
759
|
})
|
|
662
760
|
});
|
|
663
761
|
}
|
|
664
762
|
return null;
|
|
665
763
|
};
|
|
666
|
-
return /* @__PURE__ */
|
|
764
|
+
return /* @__PURE__ */ F("div", {
|
|
667
765
|
className: "flex flex-col h-full",
|
|
668
|
-
ref:
|
|
766
|
+
ref: x,
|
|
669
767
|
children: [
|
|
670
|
-
/* @__PURE__ */
|
|
768
|
+
/* @__PURE__ */ F("div", {
|
|
671
769
|
className: "flex border-b sticky top-0 bg-background z-20",
|
|
672
|
-
children: [/* @__PURE__ */
|
|
770
|
+
children: [/* @__PURE__ */ P("div", {
|
|
673
771
|
className: "w-14 shrink-0 border-r",
|
|
674
772
|
"aria-hidden": !0
|
|
675
|
-
}),
|
|
773
|
+
}), ne.map((e, t) => /* @__PURE__ */ F("div", {
|
|
676
774
|
role: "columnheader",
|
|
677
|
-
className:
|
|
678
|
-
children: [/* @__PURE__ */
|
|
775
|
+
className: N("flex-1 p-2 text-center text-sm border-r last:border-r-0", e.isToday && "bg-primary/5"),
|
|
776
|
+
children: [/* @__PURE__ */ P("div", {
|
|
679
777
|
className: "text-xs text-muted-foreground",
|
|
680
778
|
children: e.weekday
|
|
681
|
-
}), /* @__PURE__ */
|
|
682
|
-
className:
|
|
779
|
+
}), /* @__PURE__ */ P("div", {
|
|
780
|
+
className: N("font-medium", e.isToday && "inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-6 w-6 mx-auto"),
|
|
683
781
|
children: e.day
|
|
684
782
|
})]
|
|
685
783
|
}, t))]
|
|
686
784
|
}),
|
|
687
|
-
|
|
785
|
+
g.length > 0 && /* @__PURE__ */ F("div", {
|
|
688
786
|
className: "flex border-b bg-muted/20 max-h-[140px] overflow-y-auto",
|
|
689
|
-
children: [/* @__PURE__ */
|
|
787
|
+
children: [/* @__PURE__ */ P("div", {
|
|
690
788
|
className: "w-14 shrink-0 border-r flex items-start justify-end pr-1 pt-1 text-[10px] text-muted-foreground sticky left-0 bg-muted/20",
|
|
691
|
-
children:
|
|
692
|
-
}),
|
|
693
|
-
let t =
|
|
694
|
-
return /* @__PURE__ */
|
|
789
|
+
children: u("calendar.allDay")
|
|
790
|
+
}), p.map((e) => {
|
|
791
|
+
let t = U(e), n = v.get(t) ?? [];
|
|
792
|
+
return /* @__PURE__ */ P("div", {
|
|
695
793
|
className: "flex-1 border-r last:border-r-0 min-h-[28px] p-0.5 space-y-0.5",
|
|
696
794
|
children: n.map(({ event: e, isStart: t, isEnd: n }, r) => {
|
|
697
|
-
let { className: i, inlineColor: a } =
|
|
698
|
-
return /* @__PURE__ */
|
|
795
|
+
let { className: i, inlineColor: a } = z(e.color);
|
|
796
|
+
return /* @__PURE__ */ P("div", {
|
|
699
797
|
role: "button",
|
|
700
798
|
title: e.title,
|
|
701
799
|
onClick: (t) => {
|
|
702
|
-
t.stopPropagation(),
|
|
800
|
+
t.stopPropagation(), s?.(e);
|
|
703
801
|
},
|
|
704
|
-
className:
|
|
802
|
+
className: N("text-[11px] px-2 py-0.5 truncate cursor-pointer hover:opacity-80", t ? "rounded-l" : "rounded-l-none -ml-0.5", n ? "rounded-r" : "rounded-r-none -mr-0.5", i),
|
|
705
803
|
style: a ? { backgroundColor: a } : void 0,
|
|
706
804
|
children: t ? e.title : "\xA0"
|
|
707
805
|
}, `${e.id}-${r}`);
|
|
@@ -709,27 +807,27 @@ function J({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
709
807
|
}, t);
|
|
710
808
|
})]
|
|
711
809
|
}),
|
|
712
|
-
/* @__PURE__ */
|
|
810
|
+
/* @__PURE__ */ P("div", {
|
|
713
811
|
className: "flex-1 overflow-auto",
|
|
714
|
-
children: /* @__PURE__ */
|
|
812
|
+
children: /* @__PURE__ */ F("div", {
|
|
715
813
|
className: "flex",
|
|
716
|
-
style: { height:
|
|
717
|
-
children: [/* @__PURE__ */
|
|
814
|
+
style: { height: f },
|
|
815
|
+
children: [/* @__PURE__ */ P("div", {
|
|
718
816
|
className: "w-14 shrink-0 border-r relative",
|
|
719
|
-
children:
|
|
817
|
+
children: re.map((e, t) => /* @__PURE__ */ P("div", {
|
|
720
818
|
className: "absolute right-1 text-[10px] text-muted-foreground -translate-y-1/2",
|
|
721
|
-
style: { top: t *
|
|
819
|
+
style: { top: t * V },
|
|
722
820
|
children: t === 0 ? "" : e
|
|
723
821
|
}, t))
|
|
724
|
-
}),
|
|
725
|
-
let n =
|
|
726
|
-
return /* @__PURE__ */
|
|
822
|
+
}), p.map((e, t) => {
|
|
823
|
+
let n = U(e), r = b.get(n) ?? [];
|
|
824
|
+
return /* @__PURE__ */ F("div", {
|
|
727
825
|
ref: (e) => {
|
|
728
|
-
|
|
826
|
+
S.current[t] = e;
|
|
729
827
|
},
|
|
730
828
|
className: "flex-1 border-r last:border-r-0 relative select-none",
|
|
731
|
-
style: { height:
|
|
732
|
-
onPointerDown: (e) =>
|
|
829
|
+
style: { height: f },
|
|
830
|
+
onPointerDown: (e) => ae(e, t),
|
|
733
831
|
"aria-label": e.toLocaleDateString(i, {
|
|
734
832
|
weekday: "long",
|
|
735
833
|
month: "long",
|
|
@@ -737,63 +835,63 @@ function J({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
737
835
|
year: "numeric"
|
|
738
836
|
}),
|
|
739
837
|
children: [
|
|
740
|
-
Array.from({ length: 24 }, (e, t) => /* @__PURE__ */
|
|
838
|
+
Array.from({ length: 24 }, (e, t) => /* @__PURE__ */ P("div", {
|
|
741
839
|
className: "absolute left-0 right-0 border-t border-muted/60 pointer-events-none",
|
|
742
|
-
style: { top: t *
|
|
840
|
+
style: { top: t * V }
|
|
743
841
|
}, t)),
|
|
744
|
-
|
|
745
|
-
let n = t *
|
|
746
|
-
return n % 60 == 0 ? null : /* @__PURE__ */
|
|
842
|
+
o < 60 && Array.from({ length: Math.floor(1440 / o) }, (e, t) => {
|
|
843
|
+
let n = t * o;
|
|
844
|
+
return n % 60 == 0 ? null : /* @__PURE__ */ P("div", {
|
|
747
845
|
className: "absolute left-0 right-0 border-t border-dashed border-muted/30 pointer-events-none",
|
|
748
|
-
style: { top: n / 60 *
|
|
846
|
+
style: { top: n / 60 * V }
|
|
749
847
|
}, t);
|
|
750
848
|
}),
|
|
751
849
|
r.map((n) => {
|
|
752
|
-
let r = n.startMin / 60 *
|
|
753
|
-
return /* @__PURE__ */
|
|
850
|
+
let r = n.startMin / 60 * V, a = Math.max(d, (n.endMin - n.startMin) / 60 * V), o = 100 / n.cols, l = n.col * o, { className: f, inlineColor: p } = z(n.event.color), m = C && C.eventId === n.event.id;
|
|
851
|
+
return /* @__PURE__ */ F("div", {
|
|
754
852
|
role: "button",
|
|
755
853
|
tabIndex: 0,
|
|
756
854
|
title: n.event.title,
|
|
757
855
|
"aria-label": n.event.title,
|
|
758
|
-
onPointerDown: (e) =>
|
|
856
|
+
onPointerDown: (e) => ie(e, n, t, "body"),
|
|
759
857
|
onClick: (e) => {
|
|
760
858
|
if (T.current) {
|
|
761
859
|
e.stopPropagation();
|
|
762
860
|
return;
|
|
763
861
|
}
|
|
764
|
-
e.stopPropagation(),
|
|
862
|
+
e.stopPropagation(), s?.(n.event);
|
|
765
863
|
},
|
|
766
|
-
className:
|
|
864
|
+
className: N("absolute rounded text-xs px-2 py-1 overflow-hidden shadow-sm", c ? "cursor-move" : "cursor-pointer", f, m && "opacity-40"),
|
|
767
865
|
style: {
|
|
768
866
|
top: r,
|
|
769
867
|
height: a,
|
|
770
868
|
left: `calc(${l}% + 2px)`,
|
|
771
|
-
width: `calc(${
|
|
772
|
-
...
|
|
869
|
+
width: `calc(${o}% - 4px)`,
|
|
870
|
+
...p ? { backgroundColor: p } : {}
|
|
773
871
|
},
|
|
774
872
|
children: [
|
|
775
|
-
/* @__PURE__ */
|
|
873
|
+
/* @__PURE__ */ P("div", {
|
|
776
874
|
className: "font-medium truncate",
|
|
777
875
|
children: n.event.title
|
|
778
876
|
}),
|
|
779
|
-
/* @__PURE__ */
|
|
877
|
+
/* @__PURE__ */ P("div", {
|
|
780
878
|
className: "text-[10px] opacity-80 truncate",
|
|
781
|
-
children:
|
|
879
|
+
children: q(e, n.startMin, n.endMin, i)
|
|
782
880
|
}),
|
|
783
|
-
|
|
784
|
-
onPointerDown: (e) =>
|
|
881
|
+
c && n.isStart && /* @__PURE__ */ P("div", {
|
|
882
|
+
onPointerDown: (e) => ie(e, n, t, "top"),
|
|
785
883
|
className: "absolute top-0 left-0 right-0 h-1.5 cursor-ns-resize",
|
|
786
|
-
"aria-label": "
|
|
884
|
+
"aria-label": u("calendar.a11y.resizeStart")
|
|
787
885
|
}),
|
|
788
|
-
|
|
789
|
-
onPointerDown: (e) =>
|
|
886
|
+
c && n.isEnd && /* @__PURE__ */ P("div", {
|
|
887
|
+
onPointerDown: (e) => ie(e, n, t, "bottom"),
|
|
790
888
|
className: "absolute bottom-0 left-0 right-0 h-1.5 cursor-ns-resize",
|
|
791
|
-
"aria-label": "
|
|
889
|
+
"aria-label": u("calendar.a11y.resizeEnd")
|
|
792
890
|
})
|
|
793
891
|
]
|
|
794
892
|
}, `${n.event.id}-${n.startMin}`);
|
|
795
893
|
}),
|
|
796
|
-
|
|
894
|
+
oe(t)
|
|
797
895
|
]
|
|
798
896
|
}, n);
|
|
799
897
|
})]
|
|
@@ -802,214 +900,274 @@ function J({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
802
900
|
]
|
|
803
901
|
});
|
|
804
902
|
}
|
|
805
|
-
function
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
let o = (e) => e.toLocaleTimeString(r, {
|
|
903
|
+
function q(e, t, n, r) {
|
|
904
|
+
return rt(W(e, Math.round(t)), W(e, Math.round(n)), r);
|
|
905
|
+
}
|
|
906
|
+
function rt(e, t, n) {
|
|
907
|
+
let r = (e) => e.toLocaleTimeString(n, {
|
|
811
908
|
hour: "numeric",
|
|
812
909
|
minute: "2-digit"
|
|
813
910
|
});
|
|
814
|
-
return `${
|
|
911
|
+
return `${r(e)} – ${r(t)}`;
|
|
815
912
|
}
|
|
816
913
|
//#endregion
|
|
817
914
|
//#region src/ObjectCalendar.tsx
|
|
818
|
-
function
|
|
819
|
-
return
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
} : e.objectName ? {
|
|
823
|
-
provider: "object",
|
|
824
|
-
object: e.objectName
|
|
825
|
-
} : null;
|
|
826
|
-
}
|
|
827
|
-
function ye(e) {
|
|
828
|
-
return "filter" in e && e.filter && typeof e.filter == "object" && "calendar" in e.filter ? e.filter.calendar : e.calendar ? e.calendar : e.startDateField || e.dateField ? {
|
|
829
|
-
startDateField: e.startDateField || e.dateField,
|
|
830
|
-
endDateField: e.endDateField || e.endField,
|
|
915
|
+
function it(e) {
|
|
916
|
+
return e.calendar ? e.calendar : e.startDateField ? {
|
|
917
|
+
startDateField: e.startDateField,
|
|
918
|
+
endDateField: e.endDateField,
|
|
831
919
|
titleField: e.titleField,
|
|
832
920
|
colorField: e.colorField,
|
|
833
921
|
allDayField: e.allDayField
|
|
834
922
|
} : null;
|
|
835
923
|
}
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
924
|
+
function at(e, t, n) {
|
|
925
|
+
return J(t, n) ? b(e) : e.toISOString();
|
|
926
|
+
}
|
|
927
|
+
function J(e, t) {
|
|
928
|
+
return typeof e == "string" ? e === "date" : typeof t == "string" && h(t);
|
|
929
|
+
}
|
|
930
|
+
function ot(e, t, n, r) {
|
|
931
|
+
let i = { [e.startDateField]: at(n, t?.[e.startDateField]?.type, void 0) };
|
|
932
|
+
return e.endDateField && (i[e.endDateField] = at(r ?? n, t?.[e.endDateField]?.type, void 0)), i;
|
|
933
|
+
}
|
|
934
|
+
function st(e) {
|
|
935
|
+
return !e || typeof e != "object" ? [] : Array.isArray(e) ? e.map((e) => [e.name ?? e.apiName ?? "", e]) : Object.entries(e);
|
|
936
|
+
}
|
|
937
|
+
function ct(e) {
|
|
938
|
+
if (e.defaultValue !== void 0 && e.defaultValue !== null) return { value: e.defaultValue };
|
|
939
|
+
let t = e.type;
|
|
940
|
+
if (t === "select" || t === "picklist" || t === "status") {
|
|
941
|
+
let t = (e.options || e.choices || [])[0];
|
|
942
|
+
if (t === void 0) return;
|
|
943
|
+
if (typeof t != "object" || !t) return { value: t };
|
|
944
|
+
let n = t;
|
|
945
|
+
return { value: n.value ?? n.id };
|
|
946
|
+
}
|
|
947
|
+
if (t === "boolean" || t === "checkbox") return { value: !1 };
|
|
948
|
+
if (t === "number" || t === "integer" || t === "decimal" || t === "currency" || t === "percent") return { value: 0 };
|
|
949
|
+
}
|
|
950
|
+
function lt(e, t) {
|
|
951
|
+
let n = [];
|
|
952
|
+
for (let [r, i] of st(e)) r && !t.has(r) && i?.required && i.readonly !== !0 && i.system !== !0 && i.type !== "autonumber" && (ct(i) || n.push(r));
|
|
953
|
+
return n;
|
|
954
|
+
}
|
|
955
|
+
var ut = ({ schema: e, dataSource: t, className: s, data: p, loading: h, onEventClick: b, onRowClick: S, onDateClick: oe, onEdit: ce, onNavigate: de, onViewChange: fe, onVisibleRangeChange: pe, onEventDrop: he, locale: ge }) => {
|
|
956
|
+
let O = ae(), { t: Ee } = re(), De = ue(), Oe = ge !== void 0 && ge !== "default" ? ge : De, k = Array.isArray(p), [A, j] = o(k ? p : []), [ke, M] = o(k ? h ?? !1 : !0), [Ve, I] = o(null), [He, L] = o(null), [We, Ge] = o(/* @__PURE__ */ new Date()), [R, Ke] = o(!1), qe = Ne(), z = e.defaultView, [B, Ye] = o(() => {
|
|
957
|
+
let e = z === "day" || !z;
|
|
958
|
+
return typeof window < "u" && window.innerWidth < 768 && e ? "month" : z || "month";
|
|
840
959
|
});
|
|
841
960
|
r(() => {
|
|
842
|
-
|
|
843
|
-
}, [
|
|
844
|
-
let
|
|
961
|
+
qe && B === "day" && (z === "day" || !z) && Ye("month");
|
|
962
|
+
}, [qe]);
|
|
963
|
+
let Xe = Ue(We, B, le(Oe)), Ze = Xe.start.getTime(), Qe = Xe.end.getTime(), V = a(pe);
|
|
845
964
|
r(() => {
|
|
846
|
-
|
|
847
|
-
|
|
965
|
+
V.current = pe;
|
|
966
|
+
}), r(() => {
|
|
967
|
+
V.current?.({
|
|
968
|
+
start: new Date(Ze),
|
|
969
|
+
end: new Date(Qe)
|
|
970
|
+
});
|
|
971
|
+
}, [Ze, Qe]);
|
|
972
|
+
let [H, $e] = o(0);
|
|
973
|
+
r(() => {
|
|
974
|
+
if (!k && t?.onMutation && e.objectName) return t.onMutation((t) => {
|
|
975
|
+
t.resource === e.objectName && $e((e) => e + 1);
|
|
848
976
|
});
|
|
849
977
|
}, [
|
|
850
978
|
t,
|
|
851
979
|
e.objectName,
|
|
852
|
-
|
|
980
|
+
k
|
|
853
981
|
]);
|
|
854
|
-
let
|
|
855
|
-
|
|
856
|
-
}, []), { ref: W, isRefreshing:
|
|
857
|
-
onRefresh:
|
|
982
|
+
let U = n(async () => {
|
|
983
|
+
$e((e) => e + 1);
|
|
984
|
+
}, []), { ref: W, isRefreshing: et, pullDistance: tt } = Ie({
|
|
985
|
+
onRefresh: U,
|
|
858
986
|
enabled: !!t && !!e.objectName
|
|
859
|
-
}),
|
|
987
|
+
}), G = i(() => v({
|
|
988
|
+
objectName: e.objectName,
|
|
989
|
+
data: e.data,
|
|
990
|
+
staticData: e.staticData
|
|
991
|
+
}, "array"), [
|
|
860
992
|
e.data,
|
|
861
993
|
e.staticData,
|
|
862
994
|
e.objectName
|
|
863
|
-
]),
|
|
864
|
-
e.filter,
|
|
995
|
+
]), K = i(() => it(e), [
|
|
865
996
|
e.calendar,
|
|
866
|
-
e.
|
|
867
|
-
e.
|
|
997
|
+
e.startDateField,
|
|
998
|
+
e.endDateField,
|
|
868
999
|
e.titleField,
|
|
869
|
-
e.colorField
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
1000
|
+
e.colorField,
|
|
1001
|
+
e.allDayField
|
|
1002
|
+
]), nt = G?.provider === "value", q = G?.provider, rt = G?.provider === "value" ? G.items : void 0, J = y(e, G), { ready: ut, def: Y } = se(J ?? "", nt ? void 0 : t), dt = Be();
|
|
1003
|
+
r(() => {
|
|
1004
|
+
k && (j(p), L(null), I(null));
|
|
1005
|
+
}, [p, k]), r(() => {
|
|
1006
|
+
k && h !== void 0 && M(h);
|
|
1007
|
+
}, [h, k]);
|
|
1008
|
+
let ft = E(!k && q === "object" && J || void 0), pt = te(), mt = ie(e.filter, pt);
|
|
1009
|
+
r(() => {
|
|
1010
|
+
if (k || q === "object" && !ut) return;
|
|
877
1011
|
let n = !0;
|
|
878
1012
|
return (async () => {
|
|
879
1013
|
try {
|
|
880
1014
|
if (!n) return;
|
|
881
|
-
if (
|
|
882
|
-
|
|
1015
|
+
if (M(!0), nt && q === "value") {
|
|
1016
|
+
let t = await new c({ items: rt ?? [] }).find("", {
|
|
1017
|
+
$filter: mt,
|
|
1018
|
+
$orderby: d(e.sort),
|
|
1019
|
+
...g()
|
|
1020
|
+
}), r = l(t);
|
|
1021
|
+
n && (j(r.rows), L(r), I(null), M(!1));
|
|
883
1022
|
return;
|
|
884
1023
|
}
|
|
885
|
-
if (!t || typeof t.find != "function") throw Error("DataSource required for object
|
|
886
|
-
if (q
|
|
887
|
-
let r =
|
|
888
|
-
$filter:
|
|
889
|
-
$orderby:
|
|
890
|
-
...
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
1024
|
+
if (!t || typeof t.find != "function") throw Error("DataSource required for the object provider");
|
|
1025
|
+
if (q === "object") {
|
|
1026
|
+
let r = J, i = u(Y?.fields), a = dt?.isLoaded ? i.filter((e) => dt.checkField(r, e, "read")) : i, o = await t.find(r, {
|
|
1027
|
+
$filter: mt,
|
|
1028
|
+
$orderby: d(e.sort),
|
|
1029
|
+
...g(),
|
|
1030
|
+
...a.length > 0 ? { $expand: a } : {}
|
|
1031
|
+
}), s = l(o);
|
|
1032
|
+
n && (j(s.rows), L(s), I(null));
|
|
1033
|
+
}
|
|
1034
|
+
n && M(!1);
|
|
895
1035
|
} catch (e) {
|
|
896
|
-
console.error("[ObjectCalendar] Error fetching data:", e), n && (
|
|
1036
|
+
console.error("[ObjectCalendar] Error fetching data:", e), n && (I(e), M(!1));
|
|
897
1037
|
}
|
|
898
1038
|
})(), () => {
|
|
899
1039
|
n = !1;
|
|
900
1040
|
};
|
|
901
1041
|
}, [
|
|
902
|
-
|
|
1042
|
+
k,
|
|
903
1043
|
q,
|
|
1044
|
+
J,
|
|
1045
|
+
rt,
|
|
904
1046
|
t,
|
|
905
|
-
|
|
906
|
-
|
|
1047
|
+
nt,
|
|
1048
|
+
mt,
|
|
907
1049
|
e.sort,
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
!Y && t && (async () => {
|
|
911
|
-
try {
|
|
912
|
-
if (!t) return;
|
|
913
|
-
let n = q?.provider === "object" ? q.object : e.objectName;
|
|
914
|
-
if (!n) return;
|
|
915
|
-
let r = await t.getObjectSchema(n);
|
|
916
|
-
de(r);
|
|
917
|
-
} catch (e) {
|
|
918
|
-
console.error("Failed to fetch object schema:", e);
|
|
919
|
-
}
|
|
920
|
-
})();
|
|
921
|
-
}, [
|
|
922
|
-
e.objectName,
|
|
923
|
-
t,
|
|
1050
|
+
H,
|
|
1051
|
+
ut,
|
|
924
1052
|
Y,
|
|
925
|
-
|
|
1053
|
+
dt,
|
|
1054
|
+
ft
|
|
926
1055
|
]);
|
|
927
|
-
let
|
|
928
|
-
if (!
|
|
929
|
-
|
|
1056
|
+
let { events: ht, unscheduledRecords: gt } = i(() => {
|
|
1057
|
+
if (!K || !A.length) return {
|
|
1058
|
+
events: [],
|
|
1059
|
+
unscheduledRecords: []
|
|
1060
|
+
};
|
|
1061
|
+
let { startDateField: e, endDateField: t, titleField: n, colorField: r, allDayField: i } = K, a = f(Y?.fields?.[r ?? ""]), o = (e) => {
|
|
930
1062
|
if (n) {
|
|
931
1063
|
let t = e[n], r = typeof t == "string" ? t.trim() : t;
|
|
932
1064
|
if (r) return String(r);
|
|
933
1065
|
}
|
|
934
|
-
return
|
|
935
|
-
};
|
|
936
|
-
return
|
|
937
|
-
let
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
1066
|
+
return m(Y, e);
|
|
1067
|
+
}, s = [], c = [];
|
|
1068
|
+
return A.forEach((n, l) => {
|
|
1069
|
+
let u = n[e], d = t ? n[t] : null, f = o(n), p = r ? n[r] : void 0, m = a(p) ?? p, h = n.id || n._id || `event-${l}`;
|
|
1070
|
+
if (!u) {
|
|
1071
|
+
c.push({
|
|
1072
|
+
id: h,
|
|
1073
|
+
title: f
|
|
1074
|
+
});
|
|
1075
|
+
return;
|
|
1076
|
+
}
|
|
1077
|
+
let g = x(u);
|
|
1078
|
+
isNaN(g.getTime()) || s.push({
|
|
1079
|
+
id: h,
|
|
1080
|
+
title: f,
|
|
1081
|
+
start: g,
|
|
1082
|
+
end: d ? x(d) : void 0,
|
|
1083
|
+
color: m,
|
|
1084
|
+
allDay: i ? !!n[i] : !d,
|
|
945
1085
|
data: n
|
|
946
|
-
};
|
|
947
|
-
})
|
|
1086
|
+
});
|
|
1087
|
+
}), {
|
|
1088
|
+
events: s,
|
|
1089
|
+
unscheduledRecords: c
|
|
1090
|
+
};
|
|
948
1091
|
}, [
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
1092
|
+
A,
|
|
1093
|
+
K,
|
|
1094
|
+
Y
|
|
952
1095
|
]);
|
|
953
1096
|
n(() => {
|
|
954
|
-
|
|
955
|
-
}, [
|
|
956
|
-
let X = e.navigation ?? {
|
|
957
|
-
mode: "drawer",
|
|
958
|
-
width: "min(960px, 60vw)"
|
|
959
|
-
}, Se = X.mode === "drawer" || X.mode === "modal" || X.mode === "split" || X.mode === "popover", Z = h({
|
|
1097
|
+
oe?.(/* @__PURE__ */ new Date());
|
|
1098
|
+
}, [oe]);
|
|
1099
|
+
let X = e.navigation ?? { mode: "drawer" }, _t = X.mode === "drawer" || X.mode === "modal" || X.mode === "split" || X.mode === "popover", Z = ne({
|
|
960
1100
|
navigation: X,
|
|
1101
|
+
objectName: J ?? e.objectName,
|
|
1102
|
+
onRowClick: _t ? void 0 : S
|
|
1103
|
+
}), { anchorRef: vt, anchorCaptureProps: yt } = Pe(), bt = {
|
|
1104
|
+
objectSchema: J === e.objectName ? Y : null,
|
|
961
1105
|
objectName: e.objectName,
|
|
962
|
-
|
|
963
|
-
}),
|
|
964
|
-
if (!
|
|
965
|
-
let { startDateField: a, endDateField: o } =
|
|
1106
|
+
perms: dt
|
|
1107
|
+
}, xt = _("calendarQuickCreate", bt).allowed, St = _("calendarReschedule", bt).allowed, Ct = n(async (n, r, i) => {
|
|
1108
|
+
if (!K) return;
|
|
1109
|
+
let { startDateField: a, endDateField: o } = K, s = n?.id ?? n?._id;
|
|
966
1110
|
if (!s || !e.objectName || !t?.update) return;
|
|
967
|
-
let c = { [a]: r
|
|
968
|
-
o && i && (
|
|
969
|
-
let
|
|
970
|
-
|
|
1111
|
+
let c = Y?.fields, l = { [a]: at(r, c?.[a]?.type, n?.[a]) };
|
|
1112
|
+
o && i && (l[o] = at(i, c?.[o]?.type, n?.[o]));
|
|
1113
|
+
let u = A;
|
|
1114
|
+
j((e) => e.map((e) => (e?.id ?? e?._id) === s ? {
|
|
971
1115
|
...e,
|
|
972
|
-
...
|
|
1116
|
+
...l
|
|
973
1117
|
} : e));
|
|
974
1118
|
try {
|
|
975
|
-
await t.update(e.objectName, s,
|
|
1119
|
+
await t.update(e.objectName, s, l);
|
|
976
1120
|
} catch (e) {
|
|
977
|
-
|
|
1121
|
+
j(u), console.error("[ObjectCalendar] Failed to persist drag-and-drop reschedule:", e), Me.error(w(e) ?? (T(e) ? O("errors.unauthorized", "You are not authorized to perform this action.") : ee(e) ?? O("table.saveFailed", "Save failed")));
|
|
978
1122
|
}
|
|
979
1123
|
}, [
|
|
980
|
-
|
|
1124
|
+
K,
|
|
981
1125
|
e.objectName,
|
|
982
1126
|
t,
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
1127
|
+
A,
|
|
1128
|
+
O,
|
|
1129
|
+
Y
|
|
1130
|
+
]), [Q, $] = o(null), wt = O("calendar.titleRequired", "Title is required"), Tt = n((n) => {
|
|
1131
|
+
K && e.objectName && t?.create && $({
|
|
987
1132
|
start: n,
|
|
988
1133
|
title: "",
|
|
989
1134
|
submitting: !1
|
|
990
1135
|
});
|
|
991
1136
|
}, [
|
|
992
|
-
|
|
1137
|
+
K,
|
|
993
1138
|
e.objectName,
|
|
994
1139
|
t
|
|
995
|
-
]),
|
|
996
|
-
|
|
1140
|
+
]), Et = n((n, r) => {
|
|
1141
|
+
K && e.objectName && t?.create && $({
|
|
997
1142
|
start: n,
|
|
998
1143
|
end: r,
|
|
999
1144
|
title: "",
|
|
1000
1145
|
submitting: !1
|
|
1001
1146
|
});
|
|
1002
1147
|
}, [
|
|
1003
|
-
|
|
1148
|
+
K,
|
|
1004
1149
|
e.objectName,
|
|
1005
1150
|
t
|
|
1006
|
-
]),
|
|
1007
|
-
|
|
1151
|
+
]), Dt = (K ? lt(Y?.fields, new Set([
|
|
1152
|
+
K.titleField || "name",
|
|
1153
|
+
K.startDateField,
|
|
1154
|
+
K.endDateField
|
|
1155
|
+
].filter((e) => !!e))) : []).length === 0, Ot = n((t, n) => {
|
|
1156
|
+
if (!K || !e.objectName || !ce) return;
|
|
1157
|
+
let r = Y?.fields;
|
|
1158
|
+
ce(ot(K, r, t, n));
|
|
1159
|
+
}, [
|
|
1160
|
+
K,
|
|
1161
|
+
e.objectName,
|
|
1162
|
+
ce,
|
|
1163
|
+
Y
|
|
1164
|
+
]), kt = ce ? Ot : void 0, At = xt ? Dt ? Tt : kt : void 0, jt = xt ? Dt ? Et : kt : void 0, Mt = n(async () => {
|
|
1165
|
+
if (!Q || !K) return;
|
|
1008
1166
|
let n = Q.title.trim();
|
|
1009
1167
|
if (!n) {
|
|
1010
1168
|
$((e) => e && {
|
|
1011
1169
|
...e,
|
|
1012
|
-
error:
|
|
1170
|
+
error: wt
|
|
1013
1171
|
});
|
|
1014
1172
|
return;
|
|
1015
1173
|
}
|
|
@@ -1019,30 +1177,18 @@ var be = ({ schema: e, dataSource: t, className: s, data: f, loading: _, onEvent
|
|
|
1019
1177
|
submitting: !0,
|
|
1020
1178
|
error: void 0
|
|
1021
1179
|
});
|
|
1022
|
-
let {
|
|
1023
|
-
[
|
|
1024
|
-
|
|
1180
|
+
let { titleField: r } = K, i = Y?.fields, a = {
|
|
1181
|
+
[r || "name"]: n,
|
|
1182
|
+
...ot(K, i, Q.start, Q.end)
|
|
1025
1183
|
};
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
for (let [t, n] of e) {
|
|
1031
|
-
if (!t || t in o || !n?.required) continue;
|
|
1032
|
-
if (n.defaultValue !== void 0 && n.defaultValue !== null) {
|
|
1033
|
-
o[t] = n.defaultValue;
|
|
1034
|
-
continue;
|
|
1035
|
-
}
|
|
1036
|
-
let e = n.type;
|
|
1037
|
-
if (e === "select" || e === "picklist" || e === "status") {
|
|
1038
|
-
let e = (n.options || n.choices || [])[0];
|
|
1039
|
-
e !== void 0 && (o[t] = typeof e == "object" ? e.value ?? e.id : e);
|
|
1040
|
-
} else e === "boolean" || e === "checkbox" ? o[t] = !1 : (e === "number" || e === "integer" || e === "decimal" || e === "currency" || e === "percent") && (o[t] = 0);
|
|
1041
|
-
}
|
|
1184
|
+
for (let [e, t] of st(Y?.fields)) {
|
|
1185
|
+
if (!e || e in a || !t?.required) continue;
|
|
1186
|
+
let n = ct(t);
|
|
1187
|
+
n && (a[e] = n.value);
|
|
1042
1188
|
}
|
|
1043
1189
|
try {
|
|
1044
|
-
let n = await t.create(e.objectName,
|
|
1045
|
-
r && (r.id !== void 0 || r._id !== void 0) &&
|
|
1190
|
+
let n = await t.create(e.objectName, a), r = (n && (n.record || n.data || n)) ?? null;
|
|
1191
|
+
r && (r.id !== void 0 || r._id !== void 0) && j((e) => [...e, r]), $(null);
|
|
1046
1192
|
} catch (e) {
|
|
1047
1193
|
let t = e?.message || String(e);
|
|
1048
1194
|
$((e) => e && {
|
|
@@ -1053,84 +1199,162 @@ var be = ({ schema: e, dataSource: t, className: s, data: f, loading: _, onEvent
|
|
|
1053
1199
|
}
|
|
1054
1200
|
}, [
|
|
1055
1201
|
Q,
|
|
1056
|
-
|
|
1202
|
+
K,
|
|
1057
1203
|
e.objectName,
|
|
1058
1204
|
t,
|
|
1059
|
-
|
|
1205
|
+
Y,
|
|
1206
|
+
wt
|
|
1060
1207
|
]);
|
|
1061
|
-
|
|
1208
|
+
if (ke) return /* @__PURE__ */ P("div", {
|
|
1062
1209
|
className: s,
|
|
1063
|
-
children: /* @__PURE__ */
|
|
1210
|
+
children: /* @__PURE__ */ P("div", {
|
|
1064
1211
|
className: "flex items-center justify-center h-96",
|
|
1065
|
-
children: /* @__PURE__ */
|
|
1212
|
+
children: /* @__PURE__ */ P("div", {
|
|
1066
1213
|
className: "text-muted-foreground",
|
|
1067
|
-
children: "Loading calendar
|
|
1214
|
+
children: O("calendar.loading", "Loading calendar…")
|
|
1068
1215
|
})
|
|
1069
1216
|
})
|
|
1070
|
-
})
|
|
1217
|
+
});
|
|
1218
|
+
if (Ve) return /* @__PURE__ */ P("div", {
|
|
1071
1219
|
className: s,
|
|
1072
|
-
children: /* @__PURE__ */
|
|
1220
|
+
children: /* @__PURE__ */ P("div", {
|
|
1073
1221
|
className: "flex items-center justify-center h-96",
|
|
1074
|
-
children: /* @__PURE__ */
|
|
1222
|
+
children: /* @__PURE__ */ P("div", {
|
|
1075
1223
|
className: "text-destructive",
|
|
1076
|
-
children:
|
|
1224
|
+
children: Ee("calendar.loadError", {
|
|
1225
|
+
message: Ve.message,
|
|
1226
|
+
defaultValue: "Error: {{message}}"
|
|
1227
|
+
})
|
|
1228
|
+
})
|
|
1229
|
+
})
|
|
1230
|
+
});
|
|
1231
|
+
if (!K) return /* @__PURE__ */ P("div", {
|
|
1232
|
+
className: s,
|
|
1233
|
+
children: /* @__PURE__ */ P("div", {
|
|
1234
|
+
className: "flex items-center justify-center h-96",
|
|
1235
|
+
children: /* @__PURE__ */ F("div", {
|
|
1236
|
+
className: "text-muted-foreground max-w-md text-center space-y-2",
|
|
1237
|
+
children: [/* @__PURE__ */ P("p", { children: O("calendar.configRequired", "Calendar configuration required. Please specify startDateField, the calendar's one required key; the event title resolves without titleField.") }), /* @__PURE__ */ P("p", {
|
|
1238
|
+
className: "text-sm",
|
|
1239
|
+
children: O("calendar.configRequiredHint", "It belongs on the view's calendar block. An interface page has no calendar slot of its own: point its sourceView at a view that declares one.")
|
|
1240
|
+
})]
|
|
1077
1241
|
})
|
|
1078
1242
|
})
|
|
1079
|
-
})
|
|
1243
|
+
});
|
|
1244
|
+
let Nt = (n) => {
|
|
1245
|
+
if (!Z.isOverlay || !Z.isOpen || !Z.selectedRecord) return null;
|
|
1246
|
+
let r = y(e, G), i = Z.selectedRecord, a = i.id ?? i._id;
|
|
1247
|
+
if (!r || a == null) return null;
|
|
1248
|
+
let o = O("calendar.eventDetails", "Event Details"), s = K?.titleField ? String(i[K.titleField] ?? o) : o;
|
|
1249
|
+
return /* @__PURE__ */ P(Te, {
|
|
1250
|
+
...Z,
|
|
1251
|
+
title: s,
|
|
1252
|
+
mainContent: n,
|
|
1253
|
+
popoverAnchorRef: vt,
|
|
1254
|
+
storageKey: je(r),
|
|
1255
|
+
legacyStorageKey: Ae(r),
|
|
1256
|
+
width: Z.width ?? Le,
|
|
1257
|
+
children: () => /* @__PURE__ */ P("div", {
|
|
1258
|
+
className: "px-6 pt-6 pb-6",
|
|
1259
|
+
children: /* @__PURE__ */ P(Re, {
|
|
1260
|
+
record: i,
|
|
1261
|
+
objectName: r,
|
|
1262
|
+
recordId: a,
|
|
1263
|
+
dataSource: t,
|
|
1264
|
+
objectSchema: Y,
|
|
1265
|
+
onClose: Z.close,
|
|
1266
|
+
fullPageHref: ze(r, a) ?? void 0,
|
|
1267
|
+
onFieldSave: async (e, n) => {
|
|
1268
|
+
t?.update && (await t.update(r, String(a), { [e]: n }), j((t) => t.map((t) => String(t.id ?? t._id) === String(a) ? {
|
|
1269
|
+
...t,
|
|
1270
|
+
[e]: n
|
|
1271
|
+
} : t)));
|
|
1272
|
+
},
|
|
1273
|
+
onDelete: async () => {
|
|
1274
|
+
t?.delete && (await t.delete(r, String(a)), j((e) => e.filter((e) => String(e.id ?? e._id) !== String(a))));
|
|
1275
|
+
}
|
|
1276
|
+
})
|
|
1277
|
+
})
|
|
1278
|
+
});
|
|
1279
|
+
}, Pt = /* @__PURE__ */ F("div", {
|
|
1080
1280
|
ref: W,
|
|
1081
1281
|
className: s,
|
|
1282
|
+
...yt,
|
|
1082
1283
|
children: [
|
|
1083
|
-
|
|
1284
|
+
tt > 0 && /* @__PURE__ */ P("div", {
|
|
1084
1285
|
className: "flex items-center justify-center text-xs text-muted-foreground",
|
|
1085
|
-
style: { height:
|
|
1086
|
-
children:
|
|
1286
|
+
style: { height: tt },
|
|
1287
|
+
children: et ? O("calendar.refreshing", "Refreshing…") : O("calendar.pullToRefresh", "Pull to refresh")
|
|
1087
1288
|
}),
|
|
1088
|
-
/* @__PURE__ */
|
|
1289
|
+
/* @__PURE__ */ P("div", {
|
|
1089
1290
|
className: "bg-background h-[calc(100vh-120px)] sm:h-[calc(100vh-160px)] md:h-[calc(100vh-200px)] min-h-[400px] sm:min-h-[600px]",
|
|
1090
|
-
children: /* @__PURE__ */
|
|
1091
|
-
events:
|
|
1092
|
-
currentDate:
|
|
1093
|
-
view:
|
|
1094
|
-
locale:
|
|
1291
|
+
children: /* @__PURE__ */ P(Je, {
|
|
1292
|
+
events: ht,
|
|
1293
|
+
currentDate: We,
|
|
1294
|
+
view: B,
|
|
1295
|
+
locale: ge,
|
|
1095
1296
|
onEventClick: (e) => {
|
|
1096
|
-
Z.handleClick(e.data),
|
|
1097
|
-
},
|
|
1098
|
-
onDateClick: (e) => {
|
|
1099
|
-
b ? b(e) : we(e);
|
|
1297
|
+
Z.handleClick(e.data), _t || b?.(e.data);
|
|
1100
1298
|
},
|
|
1299
|
+
onDateClick: oe ?? At,
|
|
1101
1300
|
onNavigate: (e) => {
|
|
1102
|
-
|
|
1301
|
+
Ge(e), de?.(e);
|
|
1103
1302
|
},
|
|
1104
1303
|
onViewChange: (e) => {
|
|
1105
|
-
|
|
1304
|
+
Ye(e), fe?.(e);
|
|
1106
1305
|
},
|
|
1107
1306
|
onAddClick: void 0,
|
|
1108
|
-
onEventDrop: (e, t, n) => {
|
|
1109
|
-
|
|
1110
|
-
},
|
|
1111
|
-
onTimeRangeSelect:
|
|
1307
|
+
onEventDrop: he ? (e, t, n) => he(e.data, t, n) : St ? (e, t, n) => {
|
|
1308
|
+
Ct(e.data, t, n);
|
|
1309
|
+
} : void 0,
|
|
1310
|
+
onTimeRangeSelect: jt
|
|
1112
1311
|
})
|
|
1113
1312
|
}),
|
|
1114
|
-
/* @__PURE__ */
|
|
1313
|
+
He && /* @__PURE__ */ P(C, { result: He }),
|
|
1314
|
+
gt.length > 0 && /* @__PURE__ */ F("div", {
|
|
1315
|
+
className: "mt-2 border-t pt-2",
|
|
1316
|
+
"data-calendar-unscheduled": "",
|
|
1317
|
+
children: [/* @__PURE__ */ F("button", {
|
|
1318
|
+
type: "button",
|
|
1319
|
+
className: "flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground",
|
|
1320
|
+
"aria-expanded": R,
|
|
1321
|
+
onClick: () => Ke((e) => !e),
|
|
1322
|
+
children: [/* @__PURE__ */ P(me, {
|
|
1323
|
+
"aria-hidden": "true",
|
|
1324
|
+
className: N("h-4 w-4 transition-transform", R && "rotate-90")
|
|
1325
|
+
}), Ee("calendar.unscheduled", {
|
|
1326
|
+
count: gt.length,
|
|
1327
|
+
defaultValue: "Unscheduled ({{count}})"
|
|
1328
|
+
})]
|
|
1329
|
+
}), R && /* @__PURE__ */ P("ul", {
|
|
1330
|
+
className: "mt-1 space-y-1 pl-6",
|
|
1331
|
+
"data-calendar-unscheduled-list": "",
|
|
1332
|
+
children: gt.map((e) => /* @__PURE__ */ P("li", {
|
|
1333
|
+
className: "truncate text-sm",
|
|
1334
|
+
children: e.title
|
|
1335
|
+
}, e.id))
|
|
1336
|
+
})]
|
|
1337
|
+
}),
|
|
1338
|
+
/* @__PURE__ */ P(_e, {
|
|
1115
1339
|
open: !!Q,
|
|
1116
1340
|
onOpenChange: (e) => {
|
|
1117
1341
|
e || $(null);
|
|
1118
1342
|
},
|
|
1119
|
-
children: /* @__PURE__ */
|
|
1343
|
+
children: /* @__PURE__ */ F(ve, {
|
|
1120
1344
|
className: "sm:max-w-md",
|
|
1121
1345
|
children: [
|
|
1122
|
-
/* @__PURE__ */
|
|
1123
|
-
let e = Q.end && Q.end.getTime() !== Q.start.getTime(), t = Q.start.toLocaleDateString(
|
|
1346
|
+
/* @__PURE__ */ F(xe, { children: [/* @__PURE__ */ P(Se, { children: O("calendar.newEvent", "New event") }), /* @__PURE__ */ P(ye, { children: Q && (() => {
|
|
1347
|
+
let e = Q.end && Q.end.getTime() !== Q.start.getTime(), t = Q.start.toLocaleDateString(Oe, {
|
|
1124
1348
|
year: "numeric",
|
|
1125
1349
|
month: "long",
|
|
1126
1350
|
day: "numeric"
|
|
1127
1351
|
});
|
|
1128
1352
|
if (e) {
|
|
1129
|
-
let e = (e) => e.toLocaleTimeString(
|
|
1353
|
+
let e = (e) => e.toLocaleTimeString(Oe, {
|
|
1130
1354
|
hour: "numeric",
|
|
1131
1355
|
minute: "2-digit"
|
|
1132
1356
|
});
|
|
1133
|
-
return /* @__PURE__ */
|
|
1357
|
+
return /* @__PURE__ */ F(Fe, { children: [
|
|
1134
1358
|
t,
|
|
1135
1359
|
" · ",
|
|
1136
1360
|
e(Q.start),
|
|
@@ -1138,16 +1362,19 @@ var be = ({ schema: e, dataSource: t, className: s, data: f, loading: _, onEvent
|
|
|
1138
1362
|
e(Q.end)
|
|
1139
1363
|
] });
|
|
1140
1364
|
}
|
|
1141
|
-
return /* @__PURE__ */
|
|
1365
|
+
return /* @__PURE__ */ P(Fe, { children: Ee("calendar.onDate", {
|
|
1366
|
+
date: t,
|
|
1367
|
+
defaultValue: "On {{date}}"
|
|
1368
|
+
}) });
|
|
1142
1369
|
})() })] }),
|
|
1143
|
-
/* @__PURE__ */
|
|
1370
|
+
/* @__PURE__ */ F("div", {
|
|
1144
1371
|
className: "space-y-2",
|
|
1145
1372
|
children: [
|
|
1146
|
-
/* @__PURE__ */
|
|
1373
|
+
/* @__PURE__ */ P(we, {
|
|
1147
1374
|
htmlFor: "quick-create-title",
|
|
1148
|
-
children: "Title"
|
|
1375
|
+
children: O("calendar.eventTitle", "Title")
|
|
1149
1376
|
}),
|
|
1150
|
-
/* @__PURE__ */
|
|
1377
|
+
/* @__PURE__ */ P(Ce, {
|
|
1151
1378
|
id: "quick-create-title",
|
|
1152
1379
|
autoFocus: !0,
|
|
1153
1380
|
value: Q?.title ?? "",
|
|
@@ -1157,68 +1384,38 @@ var be = ({ schema: e, dataSource: t, className: s, data: f, loading: _, onEvent
|
|
|
1157
1384
|
error: void 0
|
|
1158
1385
|
}),
|
|
1159
1386
|
onKeyDown: (e) => {
|
|
1160
|
-
e.key === "Enter" && !Q?.submitting && (e.preventDefault(),
|
|
1387
|
+
e.key === "Enter" && !Q?.submitting && (e.preventDefault(), Mt());
|
|
1161
1388
|
},
|
|
1162
|
-
placeholder: "What's this event about?",
|
|
1389
|
+
placeholder: O("calendar.eventTitlePlaceholder", "What's this event about?"),
|
|
1163
1390
|
disabled: Q?.submitting
|
|
1164
1391
|
}),
|
|
1165
|
-
Q?.error && /* @__PURE__ */
|
|
1392
|
+
Q?.error && /* @__PURE__ */ P("p", {
|
|
1166
1393
|
className: "text-sm text-destructive",
|
|
1167
1394
|
children: Q.error
|
|
1168
1395
|
})
|
|
1169
1396
|
]
|
|
1170
1397
|
}),
|
|
1171
|
-
/* @__PURE__ */
|
|
1398
|
+
/* @__PURE__ */ F(be, { children: [/* @__PURE__ */ P(D, {
|
|
1172
1399
|
variant: "outline",
|
|
1173
1400
|
onClick: () => $(null),
|
|
1174
1401
|
disabled: Q?.submitting,
|
|
1175
|
-
children: "Cancel"
|
|
1176
|
-
}), /* @__PURE__ */
|
|
1177
|
-
onClick: () => void
|
|
1402
|
+
children: O("common.cancel", "Cancel")
|
|
1403
|
+
}), /* @__PURE__ */ P(D, {
|
|
1404
|
+
onClick: () => void Mt(),
|
|
1178
1405
|
disabled: Q?.submitting || !Q?.title.trim(),
|
|
1179
|
-
children: Q?.submitting ? "Creating…" : "Create"
|
|
1406
|
+
children: Q?.submitting ? O("calendar.creating", "Creating…") : O("common.create", "Create")
|
|
1180
1407
|
})] })
|
|
1181
1408
|
]
|
|
1182
1409
|
})
|
|
1183
|
-
}),
|
|
1184
|
-
Z.isOverlay && Z.isOpen && Z.selectedRecord && (() => {
|
|
1185
|
-
let n = q?.provider === "object" ? q.object : e.objectName, r = Z.selectedRecord, i = r.id ?? r._id;
|
|
1186
|
-
if (!n || i == null) return null;
|
|
1187
|
-
let a = J?.titleField ? String(r[J.titleField] ?? "Event Details") : "Event Details";
|
|
1188
|
-
return /* @__PURE__ */ L(le, {
|
|
1189
|
-
open: !0,
|
|
1190
|
-
onClose: Z.close,
|
|
1191
|
-
title: a,
|
|
1192
|
-
record: r,
|
|
1193
|
-
objectName: n,
|
|
1194
|
-
recordId: i,
|
|
1195
|
-
dataSource: t,
|
|
1196
|
-
objectSchema: z,
|
|
1197
|
-
width: Z.width ?? "min(960px, 60vw)",
|
|
1198
|
-
fullPageHref: ue(n, i) ?? void 0,
|
|
1199
|
-
onFieldSave: async (e, r) => {
|
|
1200
|
-
t?.update && (await t.update(n, String(i), { [e]: r }), P((t) => t.map((t) => String(t.id ?? t._id) === String(i) ? {
|
|
1201
|
-
...t,
|
|
1202
|
-
[e]: r
|
|
1203
|
-
} : t)));
|
|
1204
|
-
},
|
|
1205
|
-
onDelete: async () => {
|
|
1206
|
-
t?.delete && (await t.delete(n, String(i)), P((e) => e.filter((e) => String(e.id ?? e._id) !== String(i))));
|
|
1207
|
-
}
|
|
1208
|
-
});
|
|
1209
|
-
})()
|
|
1210
|
-
]
|
|
1211
|
-
}) : /* @__PURE__ */ L("div", {
|
|
1212
|
-
className: s,
|
|
1213
|
-
children: /* @__PURE__ */ L("div", {
|
|
1214
|
-
className: "flex items-center justify-center h-96",
|
|
1215
|
-
children: /* @__PURE__ */ L("div", {
|
|
1216
|
-
className: "text-muted-foreground",
|
|
1217
|
-
children: "Calendar configuration required. Please specify startDateField and titleField."
|
|
1218
1410
|
})
|
|
1219
|
-
|
|
1411
|
+
]
|
|
1220
1412
|
});
|
|
1221
|
-
|
|
1413
|
+
if (Z.isOverlay && Z.mode === "split" && Z.isOpen && Z.selectedRecord) {
|
|
1414
|
+
let e = Nt(Pt);
|
|
1415
|
+
if (e) return /* @__PURE__ */ P(Fe, { children: e });
|
|
1416
|
+
}
|
|
1417
|
+
return /* @__PURE__ */ F(Fe, { children: [Pt, Nt()] });
|
|
1418
|
+
}, Y = [
|
|
1222
1419
|
"onEventClick",
|
|
1223
1420
|
"onDateClick",
|
|
1224
1421
|
"onViewChange",
|
|
@@ -1227,23 +1424,23 @@ var be = ({ schema: e, dataSource: t, className: s, data: f, loading: _, onEvent
|
|
|
1227
1424
|
"onEventDrop",
|
|
1228
1425
|
"onTimeRangeSelect"
|
|
1229
1426
|
];
|
|
1230
|
-
function
|
|
1427
|
+
function dt(e) {
|
|
1231
1428
|
let t = {};
|
|
1232
|
-
for (let n of
|
|
1429
|
+
for (let n of Y) {
|
|
1233
1430
|
let r = e[n];
|
|
1234
1431
|
typeof r == "function" && (t[n] = r);
|
|
1235
1432
|
}
|
|
1236
1433
|
return t;
|
|
1237
1434
|
}
|
|
1238
|
-
var
|
|
1435
|
+
var ft = [
|
|
1239
1436
|
"month",
|
|
1240
1437
|
"week",
|
|
1241
1438
|
"day"
|
|
1242
1439
|
];
|
|
1243
|
-
function
|
|
1244
|
-
return
|
|
1440
|
+
function pt(e) {
|
|
1441
|
+
return ft.includes(e) ? e : void 0;
|
|
1245
1442
|
}
|
|
1246
|
-
function
|
|
1443
|
+
function mt(e) {
|
|
1247
1444
|
if (typeof e == "string") {
|
|
1248
1445
|
try {
|
|
1249
1446
|
Intl.getCanonicalLocales(e);
|
|
@@ -1253,16 +1450,16 @@ function Ce(e) {
|
|
|
1253
1450
|
return e;
|
|
1254
1451
|
}
|
|
1255
1452
|
}
|
|
1256
|
-
function
|
|
1453
|
+
function ht(e) {
|
|
1257
1454
|
return typeof e == "number" && Number.isFinite(e) && e > 0 ? e : void 0;
|
|
1258
1455
|
}
|
|
1259
|
-
function
|
|
1456
|
+
function gt(e) {
|
|
1260
1457
|
if (e instanceof Date) return e;
|
|
1261
1458
|
if (typeof e != "string") return;
|
|
1262
|
-
let t =
|
|
1459
|
+
let t = x(e);
|
|
1263
1460
|
return Number.isNaN(t.getTime()) ? void 0 : t;
|
|
1264
1461
|
}
|
|
1265
|
-
function
|
|
1462
|
+
function X(e) {
|
|
1266
1463
|
return e === !0;
|
|
1267
1464
|
}
|
|
1268
1465
|
s.register("calendar-view", ({ schema: e, className: n, onAction: r, events: i, currentDate: a, view: o, allowCreate: s, ...c }) => {
|
|
@@ -1271,8 +1468,8 @@ s.register("calendar-view", ({ schema: e, className: n, onAction: r, events: i,
|
|
|
1271
1468
|
return {
|
|
1272
1469
|
id: t.id || t._id || n,
|
|
1273
1470
|
title: t[r] || "Untitled Event",
|
|
1274
|
-
start:
|
|
1275
|
-
end: t[a] ?
|
|
1471
|
+
start: x(t[i]),
|
|
1472
|
+
end: t[a] ? x(t[a]) : void 0,
|
|
1276
1473
|
allDay: t[s],
|
|
1277
1474
|
color: t[o],
|
|
1278
1475
|
data: t
|
|
@@ -1284,7 +1481,7 @@ s.register("calendar-view", ({ schema: e, className: n, onAction: r, events: i,
|
|
|
1284
1481
|
e.endDateField,
|
|
1285
1482
|
e.colorField,
|
|
1286
1483
|
e.allDayField
|
|
1287
|
-
]), u = t.useMemo(() =>
|
|
1484
|
+
]), u = t.useMemo(() => gt(a), [a]), d = pt(o), f = X(s), p = dt(c), m = mt(c.locale), h = ht(c.slotMinutes), g = typeof r == "function" ? r : void 0, _ = (e) => {
|
|
1288
1485
|
g?.({
|
|
1289
1486
|
type: "event-click",
|
|
1290
1487
|
payload: e
|
|
@@ -1295,7 +1492,7 @@ s.register("calendar-view", ({ schema: e, className: n, onAction: r, events: i,
|
|
|
1295
1492
|
payload: {}
|
|
1296
1493
|
});
|
|
1297
1494
|
};
|
|
1298
|
-
return /* @__PURE__ */
|
|
1495
|
+
return /* @__PURE__ */ P(Je, {
|
|
1299
1496
|
className: n,
|
|
1300
1497
|
events: l,
|
|
1301
1498
|
currentDate: u,
|
|
@@ -1313,42 +1510,31 @@ s.register("calendar-view", ({ schema: e, className: n, onAction: r, events: i,
|
|
|
1313
1510
|
{
|
|
1314
1511
|
name: "data",
|
|
1315
1512
|
type: "array",
|
|
1316
|
-
label: "Data",
|
|
1317
1513
|
description: "Array of record objects to display as events"
|
|
1318
1514
|
},
|
|
1319
1515
|
{
|
|
1320
1516
|
name: "titleField",
|
|
1321
1517
|
type: "string",
|
|
1322
|
-
label: "Title Field",
|
|
1323
|
-
defaultValue: "title",
|
|
1324
1518
|
description: "Field name to use for event title"
|
|
1325
1519
|
},
|
|
1326
1520
|
{
|
|
1327
1521
|
name: "startDateField",
|
|
1328
1522
|
type: "string",
|
|
1329
|
-
label: "Start Date Field",
|
|
1330
|
-
defaultValue: "start",
|
|
1331
1523
|
description: "Field name for event start date"
|
|
1332
1524
|
},
|
|
1333
1525
|
{
|
|
1334
1526
|
name: "endDateField",
|
|
1335
1527
|
type: "string",
|
|
1336
|
-
label: "End Date Field",
|
|
1337
|
-
defaultValue: "end",
|
|
1338
1528
|
description: "Field name for event end date (optional)"
|
|
1339
1529
|
},
|
|
1340
1530
|
{
|
|
1341
1531
|
name: "allDayField",
|
|
1342
1532
|
type: "string",
|
|
1343
|
-
label: "All Day Field",
|
|
1344
|
-
defaultValue: "allDay",
|
|
1345
1533
|
description: "Field name for all-day flag"
|
|
1346
1534
|
},
|
|
1347
1535
|
{
|
|
1348
1536
|
name: "colorField",
|
|
1349
1537
|
type: "string",
|
|
1350
|
-
label: "Color Field",
|
|
1351
|
-
defaultValue: "color",
|
|
1352
1538
|
description: "Field name for event color"
|
|
1353
1539
|
},
|
|
1354
1540
|
{
|
|
@@ -1359,27 +1545,21 @@ s.register("calendar-view", ({ schema: e, className: n, onAction: r, events: i,
|
|
|
1359
1545
|
"week",
|
|
1360
1546
|
"day"
|
|
1361
1547
|
],
|
|
1362
|
-
defaultValue: "month",
|
|
1363
|
-
label: "View Mode",
|
|
1364
1548
|
description: "Calendar view mode (month, week, or day)"
|
|
1365
1549
|
},
|
|
1366
1550
|
{
|
|
1367
1551
|
name: "currentDate",
|
|
1368
1552
|
type: "string",
|
|
1369
|
-
label: "Current Date",
|
|
1370
1553
|
description: "ISO date string for initial calendar date"
|
|
1371
1554
|
},
|
|
1372
1555
|
{
|
|
1373
1556
|
name: "allowCreate",
|
|
1374
1557
|
type: "boolean",
|
|
1375
|
-
label: "Allow Create",
|
|
1376
|
-
defaultValue: !1,
|
|
1377
1558
|
description: "Allow creating events by clicking on dates"
|
|
1378
1559
|
},
|
|
1379
1560
|
{
|
|
1380
1561
|
name: "className",
|
|
1381
|
-
type: "string"
|
|
1382
|
-
label: "CSS Class"
|
|
1562
|
+
type: "string"
|
|
1383
1563
|
}
|
|
1384
1564
|
],
|
|
1385
1565
|
defaultProps: {
|
|
@@ -1420,10 +1600,10 @@ s.register("calendar-view", ({ schema: e, className: n, onAction: r, events: i,
|
|
|
1420
1600
|
});
|
|
1421
1601
|
//#endregion
|
|
1422
1602
|
//#region src/index.tsx
|
|
1423
|
-
var
|
|
1603
|
+
var _t = {
|
|
1424
1604
|
filter: !0,
|
|
1425
1605
|
sort: !0
|
|
1426
|
-
},
|
|
1606
|
+
}, Z = [
|
|
1427
1607
|
"onEventClick",
|
|
1428
1608
|
"onRowClick",
|
|
1429
1609
|
"onDateClick",
|
|
@@ -1431,17 +1611,18 @@ var Te = {
|
|
|
1431
1611
|
"onDelete",
|
|
1432
1612
|
"onNavigate",
|
|
1433
1613
|
"onViewChange",
|
|
1614
|
+
"onVisibleRangeChange",
|
|
1434
1615
|
"onEventDrop"
|
|
1435
1616
|
];
|
|
1436
|
-
function
|
|
1617
|
+
function vt(e) {
|
|
1437
1618
|
let t = {};
|
|
1438
|
-
for (let n of
|
|
1619
|
+
for (let n of Z) {
|
|
1439
1620
|
let r = e[n];
|
|
1440
1621
|
typeof r == "function" && (t[n] = r);
|
|
1441
1622
|
}
|
|
1442
1623
|
return t;
|
|
1443
1624
|
}
|
|
1444
|
-
function
|
|
1625
|
+
function yt(e) {
|
|
1445
1626
|
if (typeof e == "string") {
|
|
1446
1627
|
try {
|
|
1447
1628
|
Intl.getCanonicalLocales(e);
|
|
@@ -1451,64 +1632,100 @@ function Oe(e) {
|
|
|
1451
1632
|
return e;
|
|
1452
1633
|
}
|
|
1453
1634
|
}
|
|
1454
|
-
function
|
|
1635
|
+
function bt(e) {
|
|
1455
1636
|
return Array.isArray(e) ? e : void 0;
|
|
1456
1637
|
}
|
|
1457
|
-
function
|
|
1638
|
+
function xt(e) {
|
|
1458
1639
|
return typeof e == "boolean" ? e : void 0;
|
|
1459
1640
|
}
|
|
1460
|
-
function
|
|
1641
|
+
function St(e) {
|
|
1461
1642
|
return e && typeof e.find == "function" ? e : void 0;
|
|
1462
1643
|
}
|
|
1463
|
-
var
|
|
1464
|
-
let { dataSource: r } =
|
|
1465
|
-
return /* @__PURE__ */
|
|
1644
|
+
var Ct = p(({ schema: e, className: t, ...n }) => {
|
|
1645
|
+
let { dataSource: r } = oe() || {}, i = r ?? void 0, a = vt(n), o = yt(n.locale), s = bt(n.data), c = xt(n.loading), l = St(n.dataSource), { t: u } = de();
|
|
1646
|
+
return /* @__PURE__ */ P(S, {
|
|
1466
1647
|
schema: e,
|
|
1467
|
-
mapping:
|
|
1468
|
-
dataSource:
|
|
1648
|
+
mapping: _t,
|
|
1649
|
+
dataSource: i,
|
|
1469
1650
|
testId: "object-calendar",
|
|
1470
|
-
errorTitle: "This calendar’s data source could not be resolved",
|
|
1471
|
-
children: (e) => /* @__PURE__ */
|
|
1651
|
+
errorTitle: u("element.calendar.sourceUnresolved", { defaultValue: "This calendar’s data source could not be resolved" }),
|
|
1652
|
+
children: (e) => /* @__PURE__ */ P(ut, {
|
|
1472
1653
|
schema: e,
|
|
1473
|
-
dataSource:
|
|
1654
|
+
dataSource: l ?? i,
|
|
1474
1655
|
className: t,
|
|
1475
|
-
data:
|
|
1476
|
-
loading:
|
|
1477
|
-
locale:
|
|
1478
|
-
...
|
|
1656
|
+
data: s,
|
|
1657
|
+
loading: c,
|
|
1658
|
+
locale: o,
|
|
1659
|
+
...a
|
|
1479
1660
|
})
|
|
1480
1661
|
});
|
|
1481
|
-
}
|
|
1482
|
-
|
|
1483
|
-
namespace: "plugin-calendar",
|
|
1484
|
-
label: "Object Calendar",
|
|
1485
|
-
category: "view",
|
|
1486
|
-
inputs: [{
|
|
1662
|
+
}), Q = [
|
|
1663
|
+
{
|
|
1487
1664
|
name: "objectName",
|
|
1488
1665
|
type: "string",
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1666
|
+
description: "ObjectQL object name. The record source is one of `data`, `staticData` and `objectName`; the `object-calendar` schema refuses a block that declares none of them, unless the node's `dataSource.object` names the object, which then lands on this key."
|
|
1667
|
+
},
|
|
1668
|
+
{
|
|
1492
1669
|
name: "calendar",
|
|
1493
1670
|
type: "object",
|
|
1494
|
-
label: "Calendar Config",
|
|
1495
1671
|
description: "startDateField, endDateField, titleField, colorField"
|
|
1496
|
-
}
|
|
1497
|
-
|
|
1672
|
+
},
|
|
1673
|
+
{
|
|
1674
|
+
name: "filter",
|
|
1675
|
+
type: "array",
|
|
1676
|
+
description: "Base query filter — the `ViewFilterRule` array `[{ field, operator, value }, ...]`, narrowing the records the calendar fetches. Lowered to `$filter` on the query."
|
|
1677
|
+
},
|
|
1678
|
+
{
|
|
1679
|
+
name: "sort",
|
|
1680
|
+
type: "array",
|
|
1681
|
+
description: "Sort order in `[{ field, order }]` form, ordering the records the calendar fetches. Lowered to `$orderby` on the query."
|
|
1682
|
+
},
|
|
1683
|
+
{
|
|
1684
|
+
name: "defaultView",
|
|
1685
|
+
type: "enum",
|
|
1686
|
+
enum: [
|
|
1687
|
+
"month",
|
|
1688
|
+
"week",
|
|
1689
|
+
"day"
|
|
1690
|
+
],
|
|
1691
|
+
description: "The grid the calendar opens on. A narrow viewport downgrades `day` to `month`; the author’s choice is otherwise honoured on first render."
|
|
1692
|
+
},
|
|
1693
|
+
{
|
|
1694
|
+
name: "locale",
|
|
1695
|
+
type: "string",
|
|
1696
|
+
description: "BCP-47 tag used to format the dates and times this calendar renders. A tag `Intl` refuses is dropped — the same answer as an absent key — rather than passed through to throw out of render."
|
|
1697
|
+
},
|
|
1698
|
+
{
|
|
1699
|
+
name: "data",
|
|
1700
|
+
type: "array",
|
|
1701
|
+
description: "Pre-fetched records drawn as-is, IN PLACE OF the calendar’s own query — `objectName`, `filter` and `sort` are then unused and `staticData` is never reached. Each member is a RECORD, read for the fields the `calendar` config names plus its `id`; a member with no value in the start field is counted in the unscheduled area rather than dropped."
|
|
1702
|
+
},
|
|
1703
|
+
{
|
|
1704
|
+
name: "staticData",
|
|
1705
|
+
type: "array",
|
|
1706
|
+
description: "Inline records, read SECOND on the record-source ladder: an authored `data` wins and this key is then never reached, while `objectName` is read AFTER it, so a calendar carrying both draws these rows and issues no query. Members are records read exactly as `data`’s are."
|
|
1707
|
+
},
|
|
1708
|
+
{
|
|
1709
|
+
name: "loading",
|
|
1710
|
+
type: "boolean",
|
|
1711
|
+
description: "External loading state, honoured ONLY alongside an array `data`: it then replaces the calendar with its loading placeholder. On a calendar fed by `staticData` or by `objectName` it is dropped, because that calendar owns its own loading state."
|
|
1712
|
+
},
|
|
1713
|
+
{
|
|
1714
|
+
name: "navigation",
|
|
1715
|
+
type: "object",
|
|
1716
|
+
description: "What an event click opens — the `{ mode, size, openNewTab, preventNavigation }` block a list view declares. With the key ABSENT a click opens the record in a drawer. `mode` is an overlay (`drawer`, `modal`, `split`, `popover`), `new_window`, `page` or `none`, and a block written without `mode` takes the spec’s `page` default. `page` opens the record page through the record navigator the host publishes (the console publishes one on its custom pages, record pages and list views); under a host that publishes none, such as an embedded renderer, there is no record page to open and the click opens nothing. `openNewTab: true` opens the record page in a new tab and outranks every mode except `none`, `preventNavigation: true` opens nothing, and `size` sets the overlay width. An overlay mode wins over a parent view’s click handler; any other mode hands the click to it."
|
|
1717
|
+
}
|
|
1718
|
+
];
|
|
1719
|
+
s.register("object-calendar", Ct, {
|
|
1720
|
+
namespace: "plugin-calendar",
|
|
1721
|
+
label: "Object Calendar",
|
|
1722
|
+
category: "view",
|
|
1723
|
+
inputs: [...Q]
|
|
1724
|
+
}), s.register("calendar", Ct, {
|
|
1498
1725
|
namespace: "view",
|
|
1499
1726
|
label: "Calendar View",
|
|
1500
1727
|
category: "view",
|
|
1501
|
-
inputs: [
|
|
1502
|
-
name: "objectName",
|
|
1503
|
-
type: "string",
|
|
1504
|
-
label: "Object Name",
|
|
1505
|
-
required: !0
|
|
1506
|
-
}, {
|
|
1507
|
-
name: "calendar",
|
|
1508
|
-
type: "object",
|
|
1509
|
-
label: "Calendar Config",
|
|
1510
|
-
description: "startDateField, endDateField, titleField, colorField"
|
|
1511
|
-
}]
|
|
1728
|
+
inputs: [...Q]
|
|
1512
1729
|
});
|
|
1513
1730
|
//#endregion
|
|
1514
|
-
export {
|
|
1731
|
+
export { Je as CalendarView, ut as ObjectCalendar, Ct as ObjectCalendarRenderer };
|