@object-ui/plugin-calendar 17.6.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 +2791 -0
- package/README.md +158 -45
- package/dist/CalendarView.d.ts.map +1 -1
- package/dist/ObjectCalendar.d.ts +64 -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 +687 -560
- 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,125 +19,138 @@ var z = "bg-blue-100 text-blue-900 border border-blue-200", de = /* @__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, _] = e.useState(r), { t:
|
|
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
70
|
m === "month" ? e.setMonth(e.getMonth() - 1) : m === "week" ? e.setDate(e.getDate() - 7) : e.setDate(e.getDate() - 1), _(e), c?.(e);
|
|
59
|
-
},
|
|
71
|
+
}, C = () => {
|
|
60
72
|
let e = new Date(g);
|
|
61
73
|
m === "month" ? e.setMonth(e.getMonth() + 1) : m === "week" ? e.setDate(e.getDate() + 7) : e.setDate(e.getDate() + 1), _(e), c?.(e);
|
|
62
|
-
},
|
|
74
|
+
}, ee = () => {
|
|
63
75
|
let e = /* @__PURE__ */ new Date();
|
|
64
76
|
_(e), c?.(e);
|
|
65
|
-
},
|
|
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
156
|
e && (_(e), c?.(e));
|
|
@@ -146,71 +160,71 @@ function he({ events: t = [], view: n = "month", currentDate: r = de, locale: i
|
|
|
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
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 he({ events: t = [], view: n = "month", currentDate: r = de, 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 ge(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 _e({ 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: I("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 _e({ 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 _e({ 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);
|
|
535
|
-
}
|
|
536
|
-
} else if (t.kind === "resize-top" && s) {
|
|
537
|
-
let e = r.find((e) => String(e.id) === String(t.eventId));
|
|
538
|
-
if (e) {
|
|
539
|
-
let n = f[t.dayIndex] ?? f[0], r = Math.min(t.anchorEndMin - a, Math.max(0, t.minutes)), i = new Date(n);
|
|
540
|
-
i.setHours(0, r, 0, 0);
|
|
541
|
-
let o = new Date(n);
|
|
542
|
-
o.setHours(0, t.anchorEndMin, 0, 0), T.current = !0, s(e, i, o);
|
|
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);
|
|
543
592
|
}
|
|
544
|
-
} else if (t.kind === "resize-bottom" && s) {
|
|
593
|
+
} else if ((t.kind === "resize-top" || t.kind === "resize-bottom") && s) {
|
|
545
594
|
let e = r.find((e) => String(e.id) === String(t.eventId));
|
|
546
595
|
if (e) {
|
|
547
|
-
let n = f[t.dayIndex] ?? f[0],
|
|
548
|
-
|
|
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,214 +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 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,
|
|
863
|
+
function Ye(e) {
|
|
864
|
+
return e.calendar ? e.calendar : e.startDateField ? {
|
|
865
|
+
startDateField: e.startDateField,
|
|
866
|
+
endDateField: e.endDateField,
|
|
831
867
|
titleField: e.titleField,
|
|
832
868
|
colorField: e.colorField,
|
|
833
869
|
allDayField: e.allDayField
|
|
834
870
|
} : null;
|
|
835
871
|
}
|
|
836
|
-
|
|
837
|
-
|
|
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(() => {
|
|
838
880
|
let e = B === "day" || !B;
|
|
839
881
|
return typeof window < "u" && window.innerWidth < 768 && e ? "month" : B || "month";
|
|
840
882
|
});
|
|
841
883
|
r(() => {
|
|
842
|
-
|
|
843
|
-
}, [
|
|
844
|
-
let [
|
|
884
|
+
Ve && He === "day" && (B === "day" || !B) && Ue("month");
|
|
885
|
+
}, [Ve]);
|
|
886
|
+
let [We, Ge] = a(0);
|
|
845
887
|
r(() => {
|
|
846
|
-
if (!
|
|
847
|
-
t.resource === e.objectName &&
|
|
888
|
+
if (!A && t?.onMutation && e.objectName) return t.onMutation((t) => {
|
|
889
|
+
t.resource === e.objectName && Ge((e) => e + 1);
|
|
848
890
|
});
|
|
849
891
|
}, [
|
|
850
892
|
t,
|
|
851
893
|
e.objectName,
|
|
852
|
-
|
|
894
|
+
A
|
|
853
895
|
]);
|
|
854
|
-
let
|
|
855
|
-
|
|
856
|
-
}, []), { ref:
|
|
857
|
-
onRefresh:
|
|
896
|
+
let V = n(async () => {
|
|
897
|
+
Ge((e) => e + 1);
|
|
898
|
+
}, []), { ref: H, isRefreshing: Ke, pullDistance: U } = je({
|
|
899
|
+
onRefresh: V,
|
|
858
900
|
enabled: !!t && !!e.objectName
|
|
859
|
-
}),
|
|
901
|
+
}), W = i(() => g({
|
|
902
|
+
objectName: e.objectName,
|
|
903
|
+
data: e.data,
|
|
904
|
+
staticData: e.staticData
|
|
905
|
+
}, "array"), [
|
|
860
906
|
e.data,
|
|
861
907
|
e.staticData,
|
|
862
908
|
e.objectName
|
|
863
|
-
]),
|
|
864
|
-
e.filter,
|
|
909
|
+
]), G = i(() => Ye(e), [
|
|
865
910
|
e.calendar,
|
|
866
|
-
e.
|
|
867
|
-
e.
|
|
911
|
+
e.startDateField,
|
|
912
|
+
e.endDateField,
|
|
868
913
|
e.titleField,
|
|
869
|
-
e.colorField
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
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;
|
|
877
925
|
let n = !0;
|
|
878
926
|
return (async () => {
|
|
879
927
|
try {
|
|
880
928
|
if (!n) return;
|
|
881
|
-
if (
|
|
882
|
-
|
|
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));
|
|
883
936
|
return;
|
|
884
937
|
}
|
|
885
938
|
if (!t || typeof t.find != "function") throw Error("DataSource required for object/api providers");
|
|
886
|
-
if (q
|
|
887
|
-
let r =
|
|
888
|
-
$filter:
|
|
889
|
-
$orderby:
|
|
890
|
-
...
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
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);
|
|
895
949
|
} catch (e) {
|
|
896
|
-
console.error("[ObjectCalendar] Error fetching data:", e), n && (
|
|
950
|
+
console.error("[ObjectCalendar] Error fetching data:", e), n && (L(e), N(!1));
|
|
897
951
|
}
|
|
898
952
|
})(), () => {
|
|
899
953
|
n = !1;
|
|
900
954
|
};
|
|
901
955
|
}, [
|
|
902
|
-
|
|
956
|
+
A,
|
|
903
957
|
q,
|
|
958
|
+
J,
|
|
959
|
+
qe,
|
|
904
960
|
t,
|
|
905
|
-
|
|
906
|
-
|
|
961
|
+
K,
|
|
962
|
+
et,
|
|
907
963
|
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,
|
|
964
|
+
We,
|
|
965
|
+
Je,
|
|
924
966
|
Y,
|
|
925
|
-
|
|
967
|
+
Ze,
|
|
968
|
+
Qe
|
|
926
969
|
]);
|
|
927
|
-
let
|
|
928
|
-
if (!
|
|
929
|
-
|
|
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) => {
|
|
930
976
|
if (n) {
|
|
931
977
|
let t = e[n], r = typeof t == "string" ? t.trim() : t;
|
|
932
978
|
if (r) return String(r);
|
|
933
979
|
}
|
|
934
|
-
return
|
|
935
|
-
};
|
|
936
|
-
return
|
|
937
|
-
let
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
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,
|
|
945
999
|
data: n
|
|
946
|
-
};
|
|
947
|
-
})
|
|
1000
|
+
});
|
|
1001
|
+
}), {
|
|
1002
|
+
events: s,
|
|
1003
|
+
unscheduledRecords: c
|
|
1004
|
+
};
|
|
948
1005
|
}, [
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
1006
|
+
j,
|
|
1007
|
+
G,
|
|
1008
|
+
Y
|
|
952
1009
|
]);
|
|
953
1010
|
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({
|
|
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({
|
|
960
1014
|
navigation: X,
|
|
961
|
-
objectName: e.objectName,
|
|
962
|
-
onRowClick:
|
|
963
|
-
}),
|
|
964
|
-
if (!
|
|
965
|
-
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;
|
|
966
1020
|
if (!s || !e.objectName || !t?.update) return;
|
|
967
|
-
let c = { [a]: r
|
|
968
|
-
o && i && (
|
|
969
|
-
let
|
|
970
|
-
|
|
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 ? {
|
|
971
1025
|
...e,
|
|
972
|
-
...
|
|
1026
|
+
...l
|
|
973
1027
|
} : e));
|
|
974
1028
|
try {
|
|
975
|
-
await t.update(e.objectName, s,
|
|
1029
|
+
await t.update(e.objectName, s, l);
|
|
976
1030
|
} catch (e) {
|
|
977
|
-
|
|
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")));
|
|
978
1032
|
}
|
|
979
1033
|
}, [
|
|
980
|
-
|
|
1034
|
+
G,
|
|
981
1035
|
e.objectName,
|
|
982
1036
|
t,
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
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 && $({
|
|
987
1042
|
start: n,
|
|
988
1043
|
title: "",
|
|
989
1044
|
submitting: !1
|
|
990
1045
|
});
|
|
991
1046
|
}, [
|
|
992
|
-
|
|
1047
|
+
G,
|
|
993
1048
|
e.objectName,
|
|
994
1049
|
t
|
|
995
|
-
]),
|
|
996
|
-
|
|
1050
|
+
]), lt = n((n, r) => {
|
|
1051
|
+
G && e.objectName && t?.create && $({
|
|
997
1052
|
start: n,
|
|
998
1053
|
end: r,
|
|
999
1054
|
title: "",
|
|
1000
1055
|
submitting: !1
|
|
1001
1056
|
});
|
|
1002
1057
|
}, [
|
|
1003
|
-
|
|
1058
|
+
G,
|
|
1004
1059
|
e.objectName,
|
|
1005
1060
|
t
|
|
1006
|
-
]),
|
|
1007
|
-
if (!Q || !
|
|
1061
|
+
]), ut = n(async () => {
|
|
1062
|
+
if (!Q || !G) return;
|
|
1008
1063
|
let n = Q.title.trim();
|
|
1009
1064
|
if (!n) {
|
|
1010
1065
|
$((e) => e && {
|
|
1011
1066
|
...e,
|
|
1012
|
-
error:
|
|
1067
|
+
error: st
|
|
1013
1068
|
});
|
|
1014
1069
|
return;
|
|
1015
1070
|
}
|
|
@@ -1019,30 +1074,30 @@ var be = ({ schema: e, dataSource: t, className: s, data: f, loading: _, onEvent
|
|
|
1019
1074
|
submitting: !0,
|
|
1020
1075
|
error: void 0
|
|
1021
1076
|
});
|
|
1022
|
-
let { startDateField: r, endDateField: i, titleField: a } =
|
|
1077
|
+
let { startDateField: r, endDateField: i, titleField: a } = G, o = Y?.fields, s = {
|
|
1023
1078
|
[a || "name"]: n,
|
|
1024
|
-
[r]: Q.start
|
|
1079
|
+
[r]: Xe(Q.start, o?.[r]?.type, void 0)
|
|
1025
1080
|
};
|
|
1026
|
-
i && (
|
|
1027
|
-
let
|
|
1028
|
-
if (
|
|
1029
|
-
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);
|
|
1030
1085
|
for (let [t, n] of e) {
|
|
1031
|
-
if (!t || t in
|
|
1086
|
+
if (!t || t in s || !n?.required) continue;
|
|
1032
1087
|
if (n.defaultValue !== void 0 && n.defaultValue !== null) {
|
|
1033
|
-
|
|
1088
|
+
s[t] = n.defaultValue;
|
|
1034
1089
|
continue;
|
|
1035
1090
|
}
|
|
1036
1091
|
let e = n.type;
|
|
1037
1092
|
if (e === "select" || e === "picklist" || e === "status") {
|
|
1038
1093
|
let e = (n.options || n.choices || [])[0];
|
|
1039
|
-
e !== void 0 && (
|
|
1040
|
-
} 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);
|
|
1041
1096
|
}
|
|
1042
1097
|
}
|
|
1043
1098
|
try {
|
|
1044
|
-
let n = await t.create(e.objectName,
|
|
1045
|
-
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);
|
|
1046
1101
|
} catch (e) {
|
|
1047
1102
|
let t = e?.message || String(e);
|
|
1048
1103
|
$((e) => e && {
|
|
@@ -1053,84 +1108,164 @@ var be = ({ schema: e, dataSource: t, className: s, data: f, loading: _, onEvent
|
|
|
1053
1108
|
}
|
|
1054
1109
|
}, [
|
|
1055
1110
|
Q,
|
|
1056
|
-
|
|
1111
|
+
G,
|
|
1057
1112
|
e.objectName,
|
|
1058
1113
|
t,
|
|
1059
|
-
|
|
1114
|
+
Y,
|
|
1115
|
+
st
|
|
1060
1116
|
]);
|
|
1061
|
-
|
|
1062
|
-
className:
|
|
1063
|
-
children: /* @__PURE__ */
|
|
1117
|
+
if (Se) return /* @__PURE__ */ F("div", {
|
|
1118
|
+
className: o,
|
|
1119
|
+
children: /* @__PURE__ */ F("div", {
|
|
1064
1120
|
className: "flex items-center justify-center h-96",
|
|
1065
|
-
children: /* @__PURE__ */
|
|
1121
|
+
children: /* @__PURE__ */ F("div", {
|
|
1066
1122
|
className: "text-muted-foreground",
|
|
1067
|
-
children: "Loading calendar
|
|
1123
|
+
children: k("calendar.loading", "Loading calendar…")
|
|
1068
1124
|
})
|
|
1069
1125
|
})
|
|
1070
|
-
})
|
|
1071
|
-
|
|
1072
|
-
|
|
1126
|
+
});
|
|
1127
|
+
if (Oe) return /* @__PURE__ */ F("div", {
|
|
1128
|
+
className: o,
|
|
1129
|
+
children: /* @__PURE__ */ F("div", {
|
|
1073
1130
|
className: "flex items-center justify-center h-96",
|
|
1074
|
-
children: /* @__PURE__ */
|
|
1131
|
+
children: /* @__PURE__ */ F("div", {
|
|
1075
1132
|
className: "text-destructive",
|
|
1076
|
-
children:
|
|
1133
|
+
children: ye("calendar.loadError", {
|
|
1134
|
+
message: Oe.message,
|
|
1135
|
+
defaultValue: "Error: {{message}}"
|
|
1136
|
+
})
|
|
1077
1137
|
})
|
|
1078
1138
|
})
|
|
1079
|
-
})
|
|
1080
|
-
|
|
1081
|
-
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,
|
|
1082
1192
|
children: [
|
|
1083
|
-
|
|
1193
|
+
U > 0 && /* @__PURE__ */ F("div", {
|
|
1084
1194
|
className: "flex items-center justify-center text-xs text-muted-foreground",
|
|
1085
|
-
style: { height:
|
|
1086
|
-
children:
|
|
1195
|
+
style: { height: U },
|
|
1196
|
+
children: Ke ? k("calendar.refreshing", "Refreshing…") : k("calendar.pullToRefresh", "Pull to refresh")
|
|
1087
1197
|
}),
|
|
1088
|
-
/* @__PURE__ */
|
|
1198
|
+
/* @__PURE__ */ F("div", {
|
|
1089
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]",
|
|
1090
|
-
children: /* @__PURE__ */
|
|
1091
|
-
events:
|
|
1092
|
-
currentDate:
|
|
1093
|
-
view:
|
|
1094
|
-
locale:
|
|
1200
|
+
children: /* @__PURE__ */ F(Be, {
|
|
1201
|
+
events: tt,
|
|
1202
|
+
currentDate: Le,
|
|
1203
|
+
view: He,
|
|
1204
|
+
locale: D,
|
|
1095
1205
|
onEventClick: (e) => {
|
|
1096
|
-
Z.handleClick(e.data),
|
|
1206
|
+
Z.handleClick(e.data), rt || v?.(e.data);
|
|
1097
1207
|
},
|
|
1098
1208
|
onDateClick: (e) => {
|
|
1099
|
-
|
|
1209
|
+
E ? E(e) : ct(e);
|
|
1100
1210
|
},
|
|
1101
1211
|
onNavigate: (e) => {
|
|
1102
|
-
|
|
1212
|
+
Re(e), oe?.(e);
|
|
1103
1213
|
},
|
|
1104
1214
|
onViewChange: (e) => {
|
|
1105
|
-
|
|
1215
|
+
Ue(e), se?.(e);
|
|
1106
1216
|
},
|
|
1107
1217
|
onAddClick: void 0,
|
|
1108
1218
|
onEventDrop: (e, t, n) => {
|
|
1109
|
-
|
|
1219
|
+
le ? le(e.data, t, n) : ot(e.data, t, n);
|
|
1110
1220
|
},
|
|
1111
|
-
onTimeRangeSelect:
|
|
1221
|
+
onTimeRangeSelect: lt
|
|
1112
1222
|
})
|
|
1113
1223
|
}),
|
|
1114
|
-
/* @__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, {
|
|
1115
1250
|
open: !!Q,
|
|
1116
1251
|
onOpenChange: (e) => {
|
|
1117
1252
|
e || $(null);
|
|
1118
1253
|
},
|
|
1119
|
-
children: /* @__PURE__ */
|
|
1254
|
+
children: /* @__PURE__ */ I(de, {
|
|
1120
1255
|
className: "sm:max-w-md",
|
|
1121
1256
|
children: [
|
|
1122
|
-
/* @__PURE__ */
|
|
1123
|
-
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, {
|
|
1124
1259
|
year: "numeric",
|
|
1125
1260
|
month: "long",
|
|
1126
1261
|
day: "numeric"
|
|
1127
1262
|
});
|
|
1128
1263
|
if (e) {
|
|
1129
|
-
let e = (e) => e.toLocaleTimeString(
|
|
1264
|
+
let e = (e) => e.toLocaleTimeString(xe, {
|
|
1130
1265
|
hour: "numeric",
|
|
1131
1266
|
minute: "2-digit"
|
|
1132
1267
|
});
|
|
1133
|
-
return /* @__PURE__ */
|
|
1268
|
+
return /* @__PURE__ */ I(Ae, { children: [
|
|
1134
1269
|
t,
|
|
1135
1270
|
" · ",
|
|
1136
1271
|
e(Q.start),
|
|
@@ -1138,16 +1273,19 @@ var be = ({ schema: e, dataSource: t, className: s, data: f, loading: _, onEvent
|
|
|
1138
1273
|
e(Q.end)
|
|
1139
1274
|
] });
|
|
1140
1275
|
}
|
|
1141
|
-
return /* @__PURE__ */
|
|
1276
|
+
return /* @__PURE__ */ F(Ae, { children: ye("calendar.onDate", {
|
|
1277
|
+
date: t,
|
|
1278
|
+
defaultValue: "On {{date}}"
|
|
1279
|
+
}) });
|
|
1142
1280
|
})() })] }),
|
|
1143
|
-
/* @__PURE__ */
|
|
1281
|
+
/* @__PURE__ */ I("div", {
|
|
1144
1282
|
className: "space-y-2",
|
|
1145
1283
|
children: [
|
|
1146
|
-
/* @__PURE__ */
|
|
1284
|
+
/* @__PURE__ */ F(_e, {
|
|
1147
1285
|
htmlFor: "quick-create-title",
|
|
1148
|
-
children: "Title"
|
|
1286
|
+
children: k("calendar.eventTitle", "Title")
|
|
1149
1287
|
}),
|
|
1150
|
-
/* @__PURE__ */
|
|
1288
|
+
/* @__PURE__ */ F(ge, {
|
|
1151
1289
|
id: "quick-create-title",
|
|
1152
1290
|
autoFocus: !0,
|
|
1153
1291
|
value: Q?.title ?? "",
|
|
@@ -1157,68 +1295,38 @@ var be = ({ schema: e, dataSource: t, className: s, data: f, loading: _, onEvent
|
|
|
1157
1295
|
error: void 0
|
|
1158
1296
|
}),
|
|
1159
1297
|
onKeyDown: (e) => {
|
|
1160
|
-
e.key === "Enter" && !Q?.submitting && (e.preventDefault(),
|
|
1298
|
+
e.key === "Enter" && !Q?.submitting && (e.preventDefault(), ut());
|
|
1161
1299
|
},
|
|
1162
|
-
placeholder: "What's this event about?",
|
|
1300
|
+
placeholder: k("calendar.eventTitlePlaceholder", "What's this event about?"),
|
|
1163
1301
|
disabled: Q?.submitting
|
|
1164
1302
|
}),
|
|
1165
|
-
Q?.error && /* @__PURE__ */
|
|
1303
|
+
Q?.error && /* @__PURE__ */ F("p", {
|
|
1166
1304
|
className: "text-sm text-destructive",
|
|
1167
1305
|
children: Q.error
|
|
1168
1306
|
})
|
|
1169
1307
|
]
|
|
1170
1308
|
}),
|
|
1171
|
-
/* @__PURE__ */
|
|
1309
|
+
/* @__PURE__ */ I(pe, { children: [/* @__PURE__ */ F(O, {
|
|
1172
1310
|
variant: "outline",
|
|
1173
1311
|
onClick: () => $(null),
|
|
1174
1312
|
disabled: Q?.submitting,
|
|
1175
|
-
children: "Cancel"
|
|
1176
|
-
}), /* @__PURE__ */
|
|
1177
|
-
onClick: () => void
|
|
1313
|
+
children: k("common.cancel", "Cancel")
|
|
1314
|
+
}), /* @__PURE__ */ F(O, {
|
|
1315
|
+
onClick: () => void ut(),
|
|
1178
1316
|
disabled: Q?.submitting || !Q?.title.trim(),
|
|
1179
|
-
children: Q?.submitting ? "Creating…" : "Create"
|
|
1317
|
+
children: Q?.submitting ? k("calendar.creating", "Creating…") : k("common.create", "Create")
|
|
1180
1318
|
})] })
|
|
1181
1319
|
]
|
|
1182
1320
|
})
|
|
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
1321
|
})
|
|
1219
|
-
|
|
1322
|
+
]
|
|
1220
1323
|
});
|
|
1221
|
-
|
|
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 = [
|
|
1222
1330
|
"onEventClick",
|
|
1223
1331
|
"onDateClick",
|
|
1224
1332
|
"onViewChange",
|
|
@@ -1227,23 +1335,23 @@ var be = ({ schema: e, dataSource: t, className: s, data: f, loading: _, onEvent
|
|
|
1227
1335
|
"onEventDrop",
|
|
1228
1336
|
"onTimeRangeSelect"
|
|
1229
1337
|
];
|
|
1230
|
-
function
|
|
1338
|
+
function et(e) {
|
|
1231
1339
|
let t = {};
|
|
1232
|
-
for (let n of
|
|
1340
|
+
for (let n of $e) {
|
|
1233
1341
|
let r = e[n];
|
|
1234
1342
|
typeof r == "function" && (t[n] = r);
|
|
1235
1343
|
}
|
|
1236
1344
|
return t;
|
|
1237
1345
|
}
|
|
1238
|
-
var
|
|
1346
|
+
var tt = [
|
|
1239
1347
|
"month",
|
|
1240
1348
|
"week",
|
|
1241
1349
|
"day"
|
|
1242
1350
|
];
|
|
1243
|
-
function
|
|
1244
|
-
return
|
|
1351
|
+
function nt(e) {
|
|
1352
|
+
return tt.includes(e) ? e : void 0;
|
|
1245
1353
|
}
|
|
1246
|
-
function
|
|
1354
|
+
function X(e) {
|
|
1247
1355
|
if (typeof e == "string") {
|
|
1248
1356
|
try {
|
|
1249
1357
|
Intl.getCanonicalLocales(e);
|
|
@@ -1253,26 +1361,26 @@ function Ce(e) {
|
|
|
1253
1361
|
return e;
|
|
1254
1362
|
}
|
|
1255
1363
|
}
|
|
1256
|
-
function
|
|
1364
|
+
function rt(e) {
|
|
1257
1365
|
return typeof e == "number" && Number.isFinite(e) && e > 0 ? e : void 0;
|
|
1258
1366
|
}
|
|
1259
|
-
function
|
|
1367
|
+
function Z(e) {
|
|
1260
1368
|
if (e instanceof Date) return e;
|
|
1261
1369
|
if (typeof e != "string") return;
|
|
1262
|
-
let t =
|
|
1370
|
+
let t = y(e);
|
|
1263
1371
|
return Number.isNaN(t.getTime()) ? void 0 : t;
|
|
1264
1372
|
}
|
|
1265
|
-
function
|
|
1373
|
+
function it(e) {
|
|
1266
1374
|
return e === !0;
|
|
1267
1375
|
}
|
|
1268
|
-
|
|
1376
|
+
o.register("calendar-view", ({ schema: e, className: n, onAction: r, events: i, currentDate: a, view: o, allowCreate: s, ...c }) => {
|
|
1269
1377
|
let l = t.useMemo(() => !e.data || !Array.isArray(e.data) ? [] : e.data.map((t, n) => {
|
|
1270
1378
|
let r = e.titleField || "title", i = e.startDateField || "start", a = e.endDateField || "end", o = e.colorField || "color", s = e.allDayField || "allDay";
|
|
1271
1379
|
return {
|
|
1272
1380
|
id: t.id || t._id || n,
|
|
1273
1381
|
title: t[r] || "Untitled Event",
|
|
1274
|
-
start:
|
|
1275
|
-
end: t[a] ?
|
|
1382
|
+
start: y(t[i]),
|
|
1383
|
+
end: t[a] ? y(t[a]) : void 0,
|
|
1276
1384
|
allDay: t[s],
|
|
1277
1385
|
color: t[o],
|
|
1278
1386
|
data: t
|
|
@@ -1284,7 +1392,7 @@ s.register("calendar-view", ({ schema: e, className: n, onAction: r, events: i,
|
|
|
1284
1392
|
e.endDateField,
|
|
1285
1393
|
e.colorField,
|
|
1286
1394
|
e.allDayField
|
|
1287
|
-
]), 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) => {
|
|
1288
1396
|
g?.({
|
|
1289
1397
|
type: "event-click",
|
|
1290
1398
|
payload: e
|
|
@@ -1295,7 +1403,7 @@ s.register("calendar-view", ({ schema: e, className: n, onAction: r, events: i,
|
|
|
1295
1403
|
payload: {}
|
|
1296
1404
|
});
|
|
1297
1405
|
};
|
|
1298
|
-
return /* @__PURE__ */
|
|
1406
|
+
return /* @__PURE__ */ F(Be, {
|
|
1299
1407
|
className: n,
|
|
1300
1408
|
events: l,
|
|
1301
1409
|
currentDate: u,
|
|
@@ -1313,42 +1421,31 @@ s.register("calendar-view", ({ schema: e, className: n, onAction: r, events: i,
|
|
|
1313
1421
|
{
|
|
1314
1422
|
name: "data",
|
|
1315
1423
|
type: "array",
|
|
1316
|
-
label: "Data",
|
|
1317
1424
|
description: "Array of record objects to display as events"
|
|
1318
1425
|
},
|
|
1319
1426
|
{
|
|
1320
1427
|
name: "titleField",
|
|
1321
1428
|
type: "string",
|
|
1322
|
-
label: "Title Field",
|
|
1323
|
-
defaultValue: "title",
|
|
1324
1429
|
description: "Field name to use for event title"
|
|
1325
1430
|
},
|
|
1326
1431
|
{
|
|
1327
1432
|
name: "startDateField",
|
|
1328
1433
|
type: "string",
|
|
1329
|
-
label: "Start Date Field",
|
|
1330
|
-
defaultValue: "start",
|
|
1331
1434
|
description: "Field name for event start date"
|
|
1332
1435
|
},
|
|
1333
1436
|
{
|
|
1334
1437
|
name: "endDateField",
|
|
1335
1438
|
type: "string",
|
|
1336
|
-
label: "End Date Field",
|
|
1337
|
-
defaultValue: "end",
|
|
1338
1439
|
description: "Field name for event end date (optional)"
|
|
1339
1440
|
},
|
|
1340
1441
|
{
|
|
1341
1442
|
name: "allDayField",
|
|
1342
1443
|
type: "string",
|
|
1343
|
-
label: "All Day Field",
|
|
1344
|
-
defaultValue: "allDay",
|
|
1345
1444
|
description: "Field name for all-day flag"
|
|
1346
1445
|
},
|
|
1347
1446
|
{
|
|
1348
1447
|
name: "colorField",
|
|
1349
1448
|
type: "string",
|
|
1350
|
-
label: "Color Field",
|
|
1351
|
-
defaultValue: "color",
|
|
1352
1449
|
description: "Field name for event color"
|
|
1353
1450
|
},
|
|
1354
1451
|
{
|
|
@@ -1359,27 +1456,21 @@ s.register("calendar-view", ({ schema: e, className: n, onAction: r, events: i,
|
|
|
1359
1456
|
"week",
|
|
1360
1457
|
"day"
|
|
1361
1458
|
],
|
|
1362
|
-
defaultValue: "month",
|
|
1363
|
-
label: "View Mode",
|
|
1364
1459
|
description: "Calendar view mode (month, week, or day)"
|
|
1365
1460
|
},
|
|
1366
1461
|
{
|
|
1367
1462
|
name: "currentDate",
|
|
1368
1463
|
type: "string",
|
|
1369
|
-
label: "Current Date",
|
|
1370
1464
|
description: "ISO date string for initial calendar date"
|
|
1371
1465
|
},
|
|
1372
1466
|
{
|
|
1373
1467
|
name: "allowCreate",
|
|
1374
1468
|
type: "boolean",
|
|
1375
|
-
label: "Allow Create",
|
|
1376
|
-
defaultValue: !1,
|
|
1377
1469
|
description: "Allow creating events by clicking on dates"
|
|
1378
1470
|
},
|
|
1379
1471
|
{
|
|
1380
1472
|
name: "className",
|
|
1381
|
-
type: "string"
|
|
1382
|
-
label: "CSS Class"
|
|
1473
|
+
type: "string"
|
|
1383
1474
|
}
|
|
1384
1475
|
],
|
|
1385
1476
|
defaultProps: {
|
|
@@ -1420,10 +1511,10 @@ s.register("calendar-view", ({ schema: e, className: n, onAction: r, events: i,
|
|
|
1420
1511
|
});
|
|
1421
1512
|
//#endregion
|
|
1422
1513
|
//#region src/index.tsx
|
|
1423
|
-
var
|
|
1514
|
+
var at = {
|
|
1424
1515
|
filter: !0,
|
|
1425
1516
|
sort: !0
|
|
1426
|
-
},
|
|
1517
|
+
}, ot = [
|
|
1427
1518
|
"onEventClick",
|
|
1428
1519
|
"onRowClick",
|
|
1429
1520
|
"onDateClick",
|
|
@@ -1433,15 +1524,15 @@ var Te = {
|
|
|
1433
1524
|
"onViewChange",
|
|
1434
1525
|
"onEventDrop"
|
|
1435
1526
|
];
|
|
1436
|
-
function
|
|
1527
|
+
function Q(e) {
|
|
1437
1528
|
let t = {};
|
|
1438
|
-
for (let n of
|
|
1529
|
+
for (let n of ot) {
|
|
1439
1530
|
let r = e[n];
|
|
1440
1531
|
typeof r == "function" && (t[n] = r);
|
|
1441
1532
|
}
|
|
1442
1533
|
return t;
|
|
1443
1534
|
}
|
|
1444
|
-
function
|
|
1535
|
+
function $(e) {
|
|
1445
1536
|
if (typeof e == "string") {
|
|
1446
1537
|
try {
|
|
1447
1538
|
Intl.getCanonicalLocales(e);
|
|
@@ -1451,64 +1542,100 @@ function Oe(e) {
|
|
|
1451
1542
|
return e;
|
|
1452
1543
|
}
|
|
1453
1544
|
}
|
|
1454
|
-
function
|
|
1545
|
+
function st(e) {
|
|
1455
1546
|
return Array.isArray(e) ? e : void 0;
|
|
1456
1547
|
}
|
|
1457
|
-
function
|
|
1548
|
+
function ct(e) {
|
|
1458
1549
|
return typeof e == "boolean" ? e : void 0;
|
|
1459
1550
|
}
|
|
1460
|
-
function
|
|
1551
|
+
function lt(e) {
|
|
1461
1552
|
return e && typeof e.find == "function" ? e : void 0;
|
|
1462
1553
|
}
|
|
1463
|
-
var
|
|
1464
|
-
let { dataSource: r } =
|
|
1465
|
-
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, {
|
|
1466
1557
|
schema: e,
|
|
1467
|
-
mapping:
|
|
1468
|
-
dataSource:
|
|
1558
|
+
mapping: at,
|
|
1559
|
+
dataSource: i,
|
|
1469
1560
|
testId: "object-calendar",
|
|
1470
1561
|
errorTitle: "This calendar’s data source could not be resolved",
|
|
1471
|
-
children: (e) => /* @__PURE__ */
|
|
1562
|
+
children: (e) => /* @__PURE__ */ F(Qe, {
|
|
1472
1563
|
schema: e,
|
|
1473
|
-
dataSource:
|
|
1564
|
+
dataSource: l ?? i,
|
|
1474
1565
|
className: t,
|
|
1475
|
-
data:
|
|
1476
|
-
loading:
|
|
1477
|
-
locale:
|
|
1478
|
-
...
|
|
1566
|
+
data: s,
|
|
1567
|
+
loading: c,
|
|
1568
|
+
locale: o,
|
|
1569
|
+
...a
|
|
1479
1570
|
})
|
|
1480
1571
|
});
|
|
1481
|
-
}
|
|
1482
|
-
|
|
1483
|
-
namespace: "plugin-calendar",
|
|
1484
|
-
label: "Object Calendar",
|
|
1485
|
-
category: "view",
|
|
1486
|
-
inputs: [{
|
|
1572
|
+
}), dt = [
|
|
1573
|
+
{
|
|
1487
1574
|
name: "objectName",
|
|
1488
1575
|
type: "string",
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
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
|
+
{
|
|
1492
1579
|
name: "calendar",
|
|
1493
1580
|
type: "object",
|
|
1494
|
-
label: "Calendar Config",
|
|
1495
1581
|
description: "startDateField, endDateField, titleField, colorField"
|
|
1496
|
-
}
|
|
1497
|
-
|
|
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, {
|
|
1498
1635
|
namespace: "view",
|
|
1499
1636
|
label: "Calendar View",
|
|
1500
1637
|
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
|
-
}]
|
|
1638
|
+
inputs: [...dt]
|
|
1512
1639
|
});
|
|
1513
1640
|
//#endregion
|
|
1514
|
-
export {
|
|
1641
|
+
export { Be as CalendarView, Qe as ObjectCalendar, ut as ObjectCalendarRenderer };
|