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