@object-ui/plugin-calendar 16.0.0 → 17.1.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 +253 -0
- package/dist/CalendarView.d.ts.map +1 -1
- package/dist/ObjectCalendar.d.ts.map +1 -1
- package/dist/index.js +258 -282
- package/dist/index.umd.cjs +1 -1
- package/package.json +14 -14
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as e from "react";
|
|
2
2
|
import t, { useCallback as n, useEffect as r, useMemo as i, useRef as a, useState as o } from "react";
|
|
3
3
|
import { ComponentRegistry as s, buildExpandFields as c, extractRecords as l, getRecordDisplayName as u } from "@object-ui/core";
|
|
4
|
-
import {
|
|
5
|
-
import { CalendarIcon as
|
|
6
|
-
import { Button as
|
|
7
|
-
import {
|
|
8
|
-
import { Fragment as
|
|
9
|
-
import { usePullToRefresh as
|
|
10
|
-
import { RecordDetailDrawer as
|
|
4
|
+
import { extractWriteErrorMessage as d, isPermissionError as f, useNavigationOverlay as p, useSafeTranslate as m, useSchemaContext as h } from "@object-ui/react";
|
|
5
|
+
import { CalendarIcon as g, ChevronLeftIcon as _, ChevronRightIcon as v, PlusIcon as y } from "lucide-react";
|
|
6
|
+
import { Button as b, Calendar as x, Dialog as S, DialogContent as C, DialogDescription as w, DialogFooter as T, DialogHeader as E, DialogTitle as D, Input as ee, Label as te, Popover as O, PopoverContent as k, PopoverTrigger as A, Select as ne, SelectContent as j, SelectItem as M, SelectTrigger as N, SelectValue as re, cn as P, toast as ie, useIsMobile as ae } from "@object-ui/components";
|
|
7
|
+
import { createSafeTranslation as F } from "@object-ui/i18n";
|
|
8
|
+
import { Fragment as I, jsx as L, jsxs as R } from "react/jsx-runtime";
|
|
9
|
+
import { usePullToRefresh as oe } from "@object-ui/mobile";
|
|
10
|
+
import { RecordDetailDrawer as se, deriveRecordPageHref as ce } from "@object-ui/plugin-detail";
|
|
11
11
|
//#region src/CalendarView.tsx
|
|
12
|
-
var
|
|
12
|
+
var le = "bg-blue-100 text-blue-900 border border-blue-200", z = /* @__PURE__ */ new Date(), ue = [
|
|
13
13
|
"bg-blue-100 text-blue-900 border border-blue-200",
|
|
14
14
|
"bg-emerald-100 text-emerald-900 border border-emerald-200",
|
|
15
15
|
"bg-amber-100 text-amber-900 border border-amber-200",
|
|
@@ -18,19 +18,19 @@ var R = "bg-blue-100 text-blue-900 border border-blue-200", oe = /* @__PURE__ */
|
|
|
18
18
|
"bg-cyan-100 text-cyan-900 border border-cyan-200",
|
|
19
19
|
"bg-orange-100 text-orange-900 border border-orange-200",
|
|
20
20
|
"bg-fuchsia-100 text-fuchsia-900 border border-fuchsia-200"
|
|
21
|
-
],
|
|
21
|
+
], de = /^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i, fe = /(^|\s)(bg|text|from|to|via)-/;
|
|
22
22
|
function B(e) {
|
|
23
|
-
if (!e) return { className:
|
|
24
|
-
if (
|
|
23
|
+
if (!e) return { className: le };
|
|
24
|
+
if (de.test(e)) return {
|
|
25
25
|
className: "text-white",
|
|
26
26
|
inlineColor: e
|
|
27
27
|
};
|
|
28
|
-
if (
|
|
28
|
+
if (fe.test(e)) return { className: e };
|
|
29
29
|
let t = 0;
|
|
30
30
|
for (let n = 0; n < e.length; n++) t = (t << 5) - t + e.charCodeAt(n) | 0;
|
|
31
|
-
return { className:
|
|
31
|
+
return { className: ue[Math.abs(t) % ue.length] };
|
|
32
32
|
}
|
|
33
|
-
var V = {
|
|
33
|
+
var V = F({
|
|
34
34
|
"calendar.today": "Today",
|
|
35
35
|
"calendar.month": "Month",
|
|
36
36
|
"calendar.week": "Week",
|
|
@@ -38,64 +38,39 @@ var V = {
|
|
|
38
38
|
"calendar.newEvent": "New event",
|
|
39
39
|
"calendar.moreEvents": "+{{count}} more",
|
|
40
40
|
"calendar.allDay": "all-day"
|
|
41
|
-
};
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
let e = ne();
|
|
45
|
-
return e.t("calendar.today") === "calendar.today" ? {
|
|
46
|
-
t: (e, t) => {
|
|
47
|
-
let n = V[e] || e;
|
|
48
|
-
if (t) for (let [e, r] of Object.entries(t)) n = n.replace(`{{${e}}}`, String(r));
|
|
49
|
-
return n;
|
|
50
|
-
},
|
|
51
|
-
language: "en"
|
|
52
|
-
} : {
|
|
53
|
-
t: e.t,
|
|
54
|
-
language: e.language
|
|
55
|
-
};
|
|
56
|
-
} catch {
|
|
57
|
-
return {
|
|
58
|
-
t: (e, t) => {
|
|
59
|
-
let n = V[e] || e;
|
|
60
|
-
if (t) for (let [e, r] of Object.entries(t)) n = n.replace(`{{${e}}}`, String(r));
|
|
61
|
-
return n;
|
|
62
|
-
},
|
|
63
|
-
language: "en"
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
function le({ events: t = [], view: n = "month", currentDate: r = oe, locale: i = "default", onEventClick: a, onDateClick: o, onViewChange: s, onNavigate: c, onAddClick: l, onEventDrop: u, onTimeRangeSelect: d, slotMinutes: f = 30, className: y }) {
|
|
68
|
-
let [b, x] = e.useState(n), [S, C] = e.useState(r), { t: w, language: T } = H(), E = i === "default" ? T : i;
|
|
41
|
+
}, "calendar.today");
|
|
42
|
+
function pe({ events: t = [], view: n = "month", currentDate: r = z, locale: i = "default", onEventClick: a, onDateClick: o, onViewChange: s, onNavigate: c, onAddClick: l, onEventDrop: u, onTimeRangeSelect: d, slotMinutes: f = 30, className: p }) {
|
|
43
|
+
let [m, h] = e.useState(n), [S, C] = e.useState(r), { t: w, language: T } = V(), E = i === "default" ? T : i;
|
|
69
44
|
e.useEffect(() => {
|
|
70
45
|
C(r);
|
|
71
46
|
}, [r]), e.useEffect(() => {
|
|
72
|
-
|
|
47
|
+
h(n);
|
|
73
48
|
}, [n]);
|
|
74
|
-
let
|
|
75
|
-
|
|
49
|
+
let D = e.useRef(s);
|
|
50
|
+
D.current = s, e.useEffect(() => {
|
|
76
51
|
let e = window.matchMedia("(max-width: 639px)"), t = (e) => {
|
|
77
|
-
e.matches && (
|
|
52
|
+
e.matches && (h("day"), D.current?.("day"));
|
|
78
53
|
};
|
|
79
54
|
return t(e), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
80
55
|
}, []);
|
|
81
|
-
let
|
|
56
|
+
let ee = () => {
|
|
82
57
|
let e = new Date(S);
|
|
83
|
-
|
|
84
|
-
},
|
|
58
|
+
m === "month" ? e.setMonth(e.getMonth() - 1) : m === "week" ? e.setDate(e.getDate() - 7) : e.setDate(e.getDate() - 1), C(e), c?.(e);
|
|
59
|
+
}, te = () => {
|
|
85
60
|
let e = new Date(S);
|
|
86
|
-
|
|
61
|
+
m === "month" ? e.setMonth(e.getMonth() + 1) : m === "week" ? e.setDate(e.getDate() + 7) : e.setDate(e.getDate() + 1), C(e), c?.(e);
|
|
87
62
|
}, ie = () => {
|
|
88
63
|
let e = /* @__PURE__ */ new Date();
|
|
89
64
|
C(e), c?.(e);
|
|
90
65
|
}, ae = (e) => {
|
|
91
|
-
|
|
92
|
-
},
|
|
93
|
-
if (
|
|
66
|
+
h(e), s?.(e);
|
|
67
|
+
}, F = () => {
|
|
68
|
+
if (m === "month") return S.toLocaleDateString(E, {
|
|
94
69
|
month: "long",
|
|
95
70
|
year: "numeric"
|
|
96
71
|
});
|
|
97
|
-
if (
|
|
98
|
-
let e =
|
|
72
|
+
if (m === "week") {
|
|
73
|
+
let e = H(S), t = new Date(e);
|
|
99
74
|
return t.setDate(t.getDate() + 6), `${e.toLocaleDateString(E, {
|
|
100
75
|
month: "short",
|
|
101
76
|
day: "numeric"
|
|
@@ -110,19 +85,19 @@ function le({ events: t = [], view: n = "month", currentDate: r = oe, locale: i
|
|
|
110
85
|
day: "numeric",
|
|
111
86
|
year: "numeric"
|
|
112
87
|
});
|
|
113
|
-
},
|
|
114
|
-
return /* @__PURE__ */
|
|
88
|
+
}, I = e.useRef(0);
|
|
89
|
+
return /* @__PURE__ */ R("div", {
|
|
115
90
|
role: "region",
|
|
116
91
|
"aria-label": "Calendar",
|
|
117
|
-
className: P("flex flex-col h-full bg-background min-w-0 overflow-hidden",
|
|
118
|
-
children: [/* @__PURE__ */
|
|
92
|
+
className: P("flex flex-col h-full bg-background min-w-0 overflow-hidden", p),
|
|
93
|
+
children: [/* @__PURE__ */ R("div", {
|
|
119
94
|
className: "flex flex-wrap items-center justify-between gap-2 p-2 sm:p-4 border-b min-w-0",
|
|
120
|
-
children: [/* @__PURE__ */
|
|
95
|
+
children: [/* @__PURE__ */ R("div", {
|
|
121
96
|
className: "flex items-center gap-4",
|
|
122
|
-
children: [/* @__PURE__ */
|
|
97
|
+
children: [/* @__PURE__ */ R("div", {
|
|
123
98
|
className: "flex items-center bg-muted/50 rounded-lg p-1 gap-1",
|
|
124
99
|
children: [
|
|
125
|
-
/* @__PURE__ */
|
|
100
|
+
/* @__PURE__ */ L(b, {
|
|
126
101
|
variant: "ghost",
|
|
127
102
|
size: "sm",
|
|
128
103
|
onClick: ie,
|
|
@@ -130,36 +105,36 @@ function le({ events: t = [], view: n = "month", currentDate: r = oe, locale: i
|
|
|
130
105
|
"aria-label": "Go to today",
|
|
131
106
|
children: w("calendar.today")
|
|
132
107
|
}),
|
|
133
|
-
/* @__PURE__ */
|
|
134
|
-
/* @__PURE__ */
|
|
108
|
+
/* @__PURE__ */ L("div", { className: "h-4 w-px bg-border mx-1" }),
|
|
109
|
+
/* @__PURE__ */ L(b, {
|
|
135
110
|
variant: "ghost",
|
|
136
111
|
size: "icon",
|
|
137
112
|
"aria-label": "Previous period",
|
|
138
|
-
onClick:
|
|
113
|
+
onClick: ee,
|
|
139
114
|
className: "h-8 w-8",
|
|
140
|
-
children: /* @__PURE__ */
|
|
115
|
+
children: /* @__PURE__ */ L(_, { className: "h-4 w-4" })
|
|
141
116
|
}),
|
|
142
|
-
/* @__PURE__ */
|
|
117
|
+
/* @__PURE__ */ L(b, {
|
|
143
118
|
variant: "ghost",
|
|
144
119
|
size: "icon",
|
|
145
120
|
"aria-label": "Next period",
|
|
146
|
-
onClick:
|
|
121
|
+
onClick: te,
|
|
147
122
|
className: "h-8 w-8",
|
|
148
|
-
children: /* @__PURE__ */
|
|
123
|
+
children: /* @__PURE__ */ L(v, { className: "h-4 w-4" })
|
|
149
124
|
})
|
|
150
125
|
]
|
|
151
|
-
}), /* @__PURE__ */
|
|
126
|
+
}), /* @__PURE__ */ R(O, { children: [/* @__PURE__ */ L(A, {
|
|
152
127
|
asChild: !0,
|
|
153
|
-
children: /* @__PURE__ */
|
|
128
|
+
children: /* @__PURE__ */ R(b, {
|
|
154
129
|
variant: "ghost",
|
|
155
|
-
"aria-label": `Current date: ${
|
|
130
|
+
"aria-label": `Current date: ${F()}`,
|
|
156
131
|
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"),
|
|
157
|
-
children: [/* @__PURE__ */
|
|
132
|
+
children: [/* @__PURE__ */ L(g, { className: "h-5 w-5 text-muted-foreground" }), /* @__PURE__ */ L("span", { children: F() })]
|
|
158
133
|
})
|
|
159
|
-
}), /* @__PURE__ */
|
|
134
|
+
}), /* @__PURE__ */ L(k, {
|
|
160
135
|
className: "w-auto p-0",
|
|
161
136
|
align: "start",
|
|
162
|
-
children: /* @__PURE__ */
|
|
137
|
+
children: /* @__PURE__ */ L(x, {
|
|
163
138
|
mode: "single",
|
|
164
139
|
selected: S,
|
|
165
140
|
onSelect: (e) => {
|
|
@@ -170,49 +145,49 @@ function le({ events: t = [], view: n = "month", currentDate: r = oe, locale: i
|
|
|
170
145
|
endMonth: new Date(2050, 11)
|
|
171
146
|
})
|
|
172
147
|
})] })]
|
|
173
|
-
}), /* @__PURE__ */
|
|
148
|
+
}), /* @__PURE__ */ R("div", {
|
|
174
149
|
className: "flex items-center gap-2",
|
|
175
|
-
children: [/* @__PURE__ */
|
|
176
|
-
value:
|
|
150
|
+
children: [/* @__PURE__ */ R(ne, {
|
|
151
|
+
value: m,
|
|
177
152
|
onValueChange: ae,
|
|
178
|
-
children: [/* @__PURE__ */
|
|
153
|
+
children: [/* @__PURE__ */ L(N, {
|
|
179
154
|
className: "w-32 bg-background",
|
|
180
|
-
children: /* @__PURE__ */
|
|
181
|
-
}), /* @__PURE__ */
|
|
182
|
-
/* @__PURE__ */
|
|
155
|
+
children: /* @__PURE__ */ L(re, {})
|
|
156
|
+
}), /* @__PURE__ */ R(j, { children: [
|
|
157
|
+
/* @__PURE__ */ L(M, {
|
|
183
158
|
value: "day",
|
|
184
159
|
children: w("calendar.day")
|
|
185
160
|
}),
|
|
186
|
-
/* @__PURE__ */
|
|
161
|
+
/* @__PURE__ */ L(M, {
|
|
187
162
|
value: "week",
|
|
188
163
|
children: w("calendar.week")
|
|
189
164
|
}),
|
|
190
|
-
/* @__PURE__ */
|
|
165
|
+
/* @__PURE__ */ L(M, {
|
|
191
166
|
value: "month",
|
|
192
167
|
children: w("calendar.month")
|
|
193
168
|
})
|
|
194
169
|
] })]
|
|
195
|
-
}), l && /* @__PURE__ */
|
|
170
|
+
}), l && /* @__PURE__ */ R(b, {
|
|
196
171
|
onClick: l,
|
|
197
172
|
size: "sm",
|
|
198
173
|
className: "gap-1",
|
|
199
|
-
children: [/* @__PURE__ */
|
|
174
|
+
children: [/* @__PURE__ */ L(y, { className: "h-4 w-4" }), w("calendar.newEvent")]
|
|
200
175
|
})]
|
|
201
176
|
})]
|
|
202
|
-
}), /* @__PURE__ */
|
|
177
|
+
}), /* @__PURE__ */ R("div", {
|
|
203
178
|
className: "flex-1 overflow-auto",
|
|
204
179
|
onTouchStart: (e) => {
|
|
205
|
-
|
|
180
|
+
I.current = e.touches[0].clientX;
|
|
206
181
|
},
|
|
207
182
|
onTouchEnd: (e) => {
|
|
208
|
-
let t =
|
|
183
|
+
let t = I.current - e.changedTouches[0].clientX;
|
|
209
184
|
if (Math.abs(t) > 50) {
|
|
210
185
|
let e = new Date(S);
|
|
211
|
-
|
|
186
|
+
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)), C(e), c?.(e);
|
|
212
187
|
}
|
|
213
188
|
},
|
|
214
189
|
children: [
|
|
215
|
-
|
|
190
|
+
m === "month" && /* @__PURE__ */ L(ge, {
|
|
216
191
|
date: S,
|
|
217
192
|
events: t,
|
|
218
193
|
locale: E,
|
|
@@ -220,7 +195,7 @@ function le({ events: t = [], view: n = "month", currentDate: r = oe, locale: i
|
|
|
220
195
|
onDateClick: o,
|
|
221
196
|
onEventDrop: u
|
|
222
197
|
}),
|
|
223
|
-
|
|
198
|
+
m === "week" && /* @__PURE__ */ L(q, {
|
|
224
199
|
mode: "week",
|
|
225
200
|
date: S,
|
|
226
201
|
events: t,
|
|
@@ -230,7 +205,7 @@ function le({ events: t = [], view: n = "month", currentDate: r = oe, locale: i
|
|
|
230
205
|
onEventDrop: u,
|
|
231
206
|
onTimeRangeSelect: d
|
|
232
207
|
}),
|
|
233
|
-
|
|
208
|
+
m === "day" && /* @__PURE__ */ L(q, {
|
|
234
209
|
mode: "day",
|
|
235
210
|
date: S,
|
|
236
211
|
events: t,
|
|
@@ -244,11 +219,11 @@ function le({ events: t = [], view: n = "month", currentDate: r = oe, locale: i
|
|
|
244
219
|
})]
|
|
245
220
|
});
|
|
246
221
|
}
|
|
247
|
-
function
|
|
222
|
+
function H(e) {
|
|
248
223
|
let t = new Date(e), n = t.getDay(), r = t.getDate() - n;
|
|
249
224
|
return t.setDate(r), t;
|
|
250
225
|
}
|
|
251
|
-
function
|
|
226
|
+
function me(e) {
|
|
252
227
|
let t = e.getFullYear(), n = e.getMonth(), r = new Date(t, n, 1), i = new Date(t, n + 1, 0), a = r.getDay(), o = [];
|
|
253
228
|
for (let e = a - 1; e >= 0; e--) {
|
|
254
229
|
let t = new Date(r.getTime());
|
|
@@ -262,11 +237,11 @@ function de(e) {
|
|
|
262
237
|
}
|
|
263
238
|
return o;
|
|
264
239
|
}
|
|
265
|
-
function
|
|
240
|
+
function he(e, t) {
|
|
266
241
|
return e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth() && e.getDate() === t.getDate();
|
|
267
242
|
}
|
|
268
|
-
function
|
|
269
|
-
let s = e.useMemo(() =>
|
|
243
|
+
function ge({ date: t, events: n, locale: r = "default", onEventClick: i, onDateClick: a, onEventDrop: o }) {
|
|
244
|
+
let s = e.useMemo(() => me(t), [t.getFullYear(), t.getMonth()]), c = e.useMemo(() => /* @__PURE__ */ new Date(), []), { t: l } = V(), u = e.useMemo(() => {
|
|
270
245
|
let e = new Date(2024, 0, 7);
|
|
271
246
|
return Array.from({ length: 7 }, (t, n) => {
|
|
272
247
|
let i = new Date(e);
|
|
@@ -337,23 +312,23 @@ function pe({ date: t, events: n, locale: r = "default", onEventClick: i, onDate
|
|
|
337
312
|
let d = new Date(c.getTime() + u), p;
|
|
338
313
|
a.end && (p = new Date(new Date(a.end).getTime() + u)), o(a, d, p);
|
|
339
314
|
};
|
|
340
|
-
return /* @__PURE__ */
|
|
315
|
+
return /* @__PURE__ */ R("div", {
|
|
341
316
|
className: "flex flex-col h-full",
|
|
342
|
-
children: [/* @__PURE__ */
|
|
317
|
+
children: [/* @__PURE__ */ L("div", {
|
|
343
318
|
role: "row",
|
|
344
319
|
className: "grid grid-cols-7 border-b",
|
|
345
|
-
children: u.map((e) => /* @__PURE__ */
|
|
320
|
+
children: u.map((e) => /* @__PURE__ */ L("div", {
|
|
346
321
|
role: "columnheader",
|
|
347
322
|
className: "p-2 text-center text-sm font-medium text-muted-foreground border-r last:border-r-0",
|
|
348
323
|
children: e
|
|
349
324
|
}, e))
|
|
350
|
-
}), /* @__PURE__ */
|
|
325
|
+
}), /* @__PURE__ */ L("div", {
|
|
351
326
|
role: "grid",
|
|
352
327
|
"aria-label": "Calendar grid",
|
|
353
328
|
className: "grid grid-cols-7 flex-1 auto-rows-fr",
|
|
354
329
|
children: s.map((e, n) => {
|
|
355
|
-
let r = `${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`, s = h.get(r) || [], u = e.getMonth() === t.getMonth(), f =
|
|
356
|
-
return /* @__PURE__ */
|
|
330
|
+
let r = `${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`, s = h.get(r) || [], u = e.getMonth() === t.getMonth(), f = he(e, c);
|
|
331
|
+
return /* @__PURE__ */ R("div", {
|
|
357
332
|
role: "gridcell",
|
|
358
333
|
"aria-label": `${e.toLocaleDateString("default", {
|
|
359
334
|
weekday: "long",
|
|
@@ -366,15 +341,15 @@ function pe({ date: t, events: n, locale: r = "default", onEventClick: i, onDate
|
|
|
366
341
|
onDragOver: (e) => v(e, n),
|
|
367
342
|
onDragLeave: y,
|
|
368
343
|
onDrop: (t) => b(t, e),
|
|
369
|
-
children: [/* @__PURE__ */
|
|
344
|
+
children: [/* @__PURE__ */ L("div", {
|
|
370
345
|
className: P("text-sm font-medium mb-2", f && "inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-6 w-6"),
|
|
371
346
|
...f ? { "aria-current": "date" } : {},
|
|
372
347
|
children: e.getDate()
|
|
373
|
-
}), /* @__PURE__ */
|
|
348
|
+
}), /* @__PURE__ */ R("div", {
|
|
374
349
|
className: "space-y-0.5",
|
|
375
350
|
children: [s.slice(0, 4).map(({ event: t, isTitleDay: n, isSpanStart: r, isSpanEnd: a }, s) => {
|
|
376
351
|
let c = !n, { className: l, inlineColor: u } = B(t.color), f = !!o && a;
|
|
377
|
-
return /* @__PURE__ */
|
|
352
|
+
return /* @__PURE__ */ R("div", {
|
|
378
353
|
role: "button",
|
|
379
354
|
title: t.title,
|
|
380
355
|
"aria-label": t.title,
|
|
@@ -386,7 +361,7 @@ function pe({ date: t, events: n, locale: r = "default", onEventClick: i, onDate
|
|
|
386
361
|
onClick: (e) => {
|
|
387
362
|
e.stopPropagation(), i?.(t);
|
|
388
363
|
},
|
|
389
|
-
children: [c ? "" : t.title, f && /* @__PURE__ */
|
|
364
|
+
children: [c ? "" : t.title, f && /* @__PURE__ */ L("span", {
|
|
390
365
|
role: "separator",
|
|
391
366
|
"aria-label": "Resize event end",
|
|
392
367
|
title: "Drag to change end date",
|
|
@@ -397,7 +372,7 @@ function pe({ date: t, events: n, locale: r = "default", onEventClick: i, onDate
|
|
|
397
372
|
className: "absolute inset-y-0 right-0 w-2 cursor-ew-resize bg-black/25 hover:bg-black/50 rounded-r"
|
|
398
373
|
})]
|
|
399
374
|
}, `${t.id}-${s}`);
|
|
400
|
-
}), s.length > 4 && /* @__PURE__ */
|
|
375
|
+
}), s.length > 4 && /* @__PURE__ */ L("div", {
|
|
401
376
|
className: "text-xs text-muted-foreground px-2",
|
|
402
377
|
children: l("calendar.moreEvents", { count: s.length - 4 })
|
|
403
378
|
})]
|
|
@@ -419,9 +394,9 @@ function K(e) {
|
|
|
419
394
|
return `${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`;
|
|
420
395
|
}
|
|
421
396
|
function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a = 30, onEventClick: o, onEventDrop: s, onTimeRangeSelect: c }) {
|
|
422
|
-
let { t: l } =
|
|
397
|
+
let { t: l } = V(), u = U * a / 60, d = U * 24, f = e.useMemo(() => {
|
|
423
398
|
if (t === "day") return [W(n)];
|
|
424
|
-
let e =
|
|
399
|
+
let e = H(n);
|
|
425
400
|
return Array.from({ length: 7 }, (t, n) => {
|
|
426
401
|
let r = new Date(e);
|
|
427
402
|
return r.setDate(e.getDate() + n), W(r);
|
|
@@ -593,16 +568,16 @@ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
593
568
|
D,
|
|
594
569
|
E
|
|
595
570
|
]);
|
|
596
|
-
let
|
|
571
|
+
let ee = e.useMemo(() => f.map((e) => ({
|
|
597
572
|
weekday: e.toLocaleDateString(i, { weekday: "short" }),
|
|
598
573
|
day: e.getDate(),
|
|
599
574
|
month: e.toLocaleDateString(i, { month: "short" }),
|
|
600
|
-
isToday:
|
|
575
|
+
isToday: he(e, p)
|
|
601
576
|
})), [
|
|
602
577
|
f,
|
|
603
578
|
i,
|
|
604
579
|
p
|
|
605
|
-
]),
|
|
580
|
+
]), te = e.useMemo(() => Array.from({ length: 24 }, (e, t) => new Date(2024, 0, 1, t, 0).toLocaleTimeString(i, { hour: "numeric" })), [i]), O = (e, t, n, r) => {
|
|
606
581
|
if (!s || e.button !== 0) return;
|
|
607
582
|
e.stopPropagation(), e.preventDefault();
|
|
608
583
|
let i = E(e.clientY, n);
|
|
@@ -626,7 +601,7 @@ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
626
601
|
dayIndex: n,
|
|
627
602
|
minutes: i
|
|
628
603
|
});
|
|
629
|
-
},
|
|
604
|
+
}, k = (e, t) => {
|
|
630
605
|
if (!c || e.button !== 0) return;
|
|
631
606
|
e.preventDefault();
|
|
632
607
|
let n = E(e.clientY, t);
|
|
@@ -636,18 +611,18 @@ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
636
611
|
anchorMinutes: n,
|
|
637
612
|
headMinutes: n
|
|
638
613
|
});
|
|
639
|
-
},
|
|
614
|
+
}, A = (e) => {
|
|
640
615
|
if (!S) return null;
|
|
641
616
|
if (S.kind === "select" && S.dayIndex === e) {
|
|
642
617
|
let t = Math.min(S.anchorMinutes, S.headMinutes), n = Math.max(S.anchorMinutes, S.headMinutes);
|
|
643
|
-
return /* @__PURE__ */
|
|
618
|
+
return /* @__PURE__ */ L("div", {
|
|
644
619
|
className: "absolute left-1 right-1 rounded bg-primary/30 border border-primary pointer-events-none z-10",
|
|
645
620
|
style: {
|
|
646
621
|
top: t / 60 * U,
|
|
647
622
|
height: Math.max(u, (n - t) / 60 * U)
|
|
648
623
|
},
|
|
649
624
|
"aria-hidden": !0,
|
|
650
|
-
children: /* @__PURE__ */
|
|
625
|
+
children: /* @__PURE__ */ L("div", {
|
|
651
626
|
className: "px-2 py-0.5 text-xs font-medium text-primary",
|
|
652
627
|
children: J(f[e], t, n, i)
|
|
653
628
|
})
|
|
@@ -655,14 +630,14 @@ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
655
630
|
}
|
|
656
631
|
if (S.kind === "move" && S.dayIndex === e) {
|
|
657
632
|
let t = S.minutes - S.grabMinuteOffset, n = Math.max(0, Math.min(1440 - S.durationMin, Math.round(t / a) * a));
|
|
658
|
-
return /* @__PURE__ */
|
|
633
|
+
return /* @__PURE__ */ L("div", {
|
|
659
634
|
className: "absolute left-1 right-1 rounded border-2 border-dashed border-primary bg-primary/10 pointer-events-none z-10",
|
|
660
635
|
style: {
|
|
661
636
|
top: n / 60 * U,
|
|
662
637
|
height: S.durationMin / 60 * U
|
|
663
638
|
},
|
|
664
639
|
"aria-hidden": !0,
|
|
665
|
-
children: /* @__PURE__ */
|
|
640
|
+
children: /* @__PURE__ */ L("div", {
|
|
666
641
|
className: "px-2 py-0.5 text-xs font-medium text-primary",
|
|
667
642
|
children: J(f[e], n, n + S.durationMin, i)
|
|
668
643
|
})
|
|
@@ -670,14 +645,14 @@ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
670
645
|
}
|
|
671
646
|
if ((S.kind === "resize-top" || S.kind === "resize-bottom") && S.dayIndex === e) {
|
|
672
647
|
let t, n;
|
|
673
|
-
return S.kind === "resize-top" ? (t = Math.min(S.anchorEndMin - a, Math.max(0, S.minutes)), n = S.anchorEndMin) : (t = S.anchorStartMin, n = Math.max(S.anchorStartMin + a, Math.min(1440, S.minutes))), /* @__PURE__ */
|
|
648
|
+
return S.kind === "resize-top" ? (t = Math.min(S.anchorEndMin - a, Math.max(0, S.minutes)), n = S.anchorEndMin) : (t = S.anchorStartMin, n = Math.max(S.anchorStartMin + a, Math.min(1440, S.minutes))), /* @__PURE__ */ L("div", {
|
|
674
649
|
className: "absolute left-1 right-1 rounded border-2 border-dashed border-primary bg-primary/10 pointer-events-none z-10",
|
|
675
650
|
style: {
|
|
676
651
|
top: t / 60 * U,
|
|
677
652
|
height: (n - t) / 60 * U
|
|
678
653
|
},
|
|
679
654
|
"aria-hidden": !0,
|
|
680
|
-
children: /* @__PURE__ */
|
|
655
|
+
children: /* @__PURE__ */ L("div", {
|
|
681
656
|
className: "px-2 py-0.5 text-xs font-medium text-primary",
|
|
682
657
|
children: J(f[e], t, n, i)
|
|
683
658
|
})
|
|
@@ -685,39 +660,39 @@ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
685
660
|
}
|
|
686
661
|
return null;
|
|
687
662
|
};
|
|
688
|
-
return /* @__PURE__ */
|
|
663
|
+
return /* @__PURE__ */ R("div", {
|
|
689
664
|
className: "flex flex-col h-full",
|
|
690
665
|
ref: b,
|
|
691
666
|
children: [
|
|
692
|
-
/* @__PURE__ */
|
|
667
|
+
/* @__PURE__ */ R("div", {
|
|
693
668
|
className: "flex border-b sticky top-0 bg-background z-20",
|
|
694
|
-
children: [/* @__PURE__ */
|
|
669
|
+
children: [/* @__PURE__ */ L("div", {
|
|
695
670
|
className: "w-14 shrink-0 border-r",
|
|
696
671
|
"aria-hidden": !0
|
|
697
|
-
}),
|
|
672
|
+
}), ee.map((e, t) => /* @__PURE__ */ R("div", {
|
|
698
673
|
role: "columnheader",
|
|
699
674
|
className: P("flex-1 p-2 text-center text-sm border-r last:border-r-0", e.isToday && "bg-primary/5"),
|
|
700
|
-
children: [/* @__PURE__ */
|
|
675
|
+
children: [/* @__PURE__ */ L("div", {
|
|
701
676
|
className: "text-xs text-muted-foreground",
|
|
702
677
|
children: e.weekday
|
|
703
|
-
}), /* @__PURE__ */
|
|
678
|
+
}), /* @__PURE__ */ L("div", {
|
|
704
679
|
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"),
|
|
705
680
|
children: e.day
|
|
706
681
|
})]
|
|
707
682
|
}, t))]
|
|
708
683
|
}),
|
|
709
|
-
h.length > 0 && /* @__PURE__ */
|
|
684
|
+
h.length > 0 && /* @__PURE__ */ R("div", {
|
|
710
685
|
className: "flex border-b bg-muted/20 max-h-[140px] overflow-y-auto",
|
|
711
|
-
children: [/* @__PURE__ */
|
|
686
|
+
children: [/* @__PURE__ */ L("div", {
|
|
712
687
|
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",
|
|
713
688
|
children: l("calendar.allDay") === "calendar.allDay" ? "all-day" : l("calendar.allDay")
|
|
714
689
|
}), f.map((e) => {
|
|
715
690
|
let t = K(e);
|
|
716
|
-
return /* @__PURE__ */
|
|
691
|
+
return /* @__PURE__ */ L("div", {
|
|
717
692
|
className: "flex-1 border-r last:border-r-0 min-h-[28px] p-0.5 space-y-0.5",
|
|
718
693
|
children: (_.get(t) ?? []).map(({ event: e, isStart: t, isEnd: n }, r) => {
|
|
719
694
|
let { className: i, inlineColor: a } = B(e.color);
|
|
720
|
-
return /* @__PURE__ */
|
|
695
|
+
return /* @__PURE__ */ L("div", {
|
|
721
696
|
role: "button",
|
|
722
697
|
title: e.title,
|
|
723
698
|
onClick: (t) => {
|
|
@@ -731,27 +706,27 @@ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
731
706
|
}, t);
|
|
732
707
|
})]
|
|
733
708
|
}),
|
|
734
|
-
/* @__PURE__ */
|
|
709
|
+
/* @__PURE__ */ L("div", {
|
|
735
710
|
className: "flex-1 overflow-auto",
|
|
736
|
-
children: /* @__PURE__ */
|
|
711
|
+
children: /* @__PURE__ */ R("div", {
|
|
737
712
|
className: "flex",
|
|
738
713
|
style: { height: d },
|
|
739
|
-
children: [/* @__PURE__ */
|
|
714
|
+
children: [/* @__PURE__ */ L("div", {
|
|
740
715
|
className: "w-14 shrink-0 border-r relative",
|
|
741
|
-
children:
|
|
716
|
+
children: te.map((e, t) => /* @__PURE__ */ L("div", {
|
|
742
717
|
className: "absolute right-1 text-[10px] text-muted-foreground -translate-y-1/2",
|
|
743
718
|
style: { top: t * U },
|
|
744
719
|
children: t === 0 ? "" : e
|
|
745
720
|
}, t))
|
|
746
721
|
}), f.map((e, t) => {
|
|
747
722
|
let n = K(e), r = y.get(n) ?? [];
|
|
748
|
-
return /* @__PURE__ */
|
|
723
|
+
return /* @__PURE__ */ R("div", {
|
|
749
724
|
ref: (e) => {
|
|
750
725
|
x.current[t] = e;
|
|
751
726
|
},
|
|
752
727
|
className: "flex-1 border-r last:border-r-0 relative select-none",
|
|
753
728
|
style: { height: d },
|
|
754
|
-
onPointerDown: (e) =>
|
|
729
|
+
onPointerDown: (e) => k(e, t),
|
|
755
730
|
"aria-label": e.toLocaleDateString(i, {
|
|
756
731
|
weekday: "long",
|
|
757
732
|
month: "long",
|
|
@@ -759,25 +734,25 @@ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
759
734
|
year: "numeric"
|
|
760
735
|
}),
|
|
761
736
|
children: [
|
|
762
|
-
Array.from({ length: 24 }, (e, t) => /* @__PURE__ */
|
|
737
|
+
Array.from({ length: 24 }, (e, t) => /* @__PURE__ */ L("div", {
|
|
763
738
|
className: "absolute left-0 right-0 border-t border-muted/60 pointer-events-none",
|
|
764
739
|
style: { top: t * U }
|
|
765
740
|
}, t)),
|
|
766
741
|
a < 60 && Array.from({ length: Math.floor(1440 / a) }, (e, t) => {
|
|
767
742
|
let n = t * a;
|
|
768
|
-
return n % 60 == 0 ? null : /* @__PURE__ */
|
|
743
|
+
return n % 60 == 0 ? null : /* @__PURE__ */ L("div", {
|
|
769
744
|
className: "absolute left-0 right-0 border-t border-dashed border-muted/30 pointer-events-none",
|
|
770
745
|
style: { top: n / 60 * U }
|
|
771
746
|
}, t);
|
|
772
747
|
}),
|
|
773
748
|
r.map((n) => {
|
|
774
749
|
let r = n.startMin / 60 * U, a = Math.max(u, (n.endMin - n.startMin) / 60 * U), c = 100 / n.cols, l = n.col * c, { className: d, inlineColor: f } = B(n.event.color), p = S && S.eventId === n.event.id;
|
|
775
|
-
return /* @__PURE__ */
|
|
750
|
+
return /* @__PURE__ */ R("div", {
|
|
776
751
|
role: "button",
|
|
777
752
|
tabIndex: 0,
|
|
778
753
|
title: n.event.title,
|
|
779
754
|
"aria-label": n.event.title,
|
|
780
|
-
onPointerDown: (e) =>
|
|
755
|
+
onPointerDown: (e) => O(e, n, t, "body"),
|
|
781
756
|
onClick: (e) => {
|
|
782
757
|
if (T.current) {
|
|
783
758
|
e.stopPropagation();
|
|
@@ -794,28 +769,28 @@ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
794
769
|
...f ? { backgroundColor: f } : {}
|
|
795
770
|
},
|
|
796
771
|
children: [
|
|
797
|
-
/* @__PURE__ */
|
|
772
|
+
/* @__PURE__ */ L("div", {
|
|
798
773
|
className: "font-medium truncate",
|
|
799
774
|
children: n.event.title
|
|
800
775
|
}),
|
|
801
|
-
/* @__PURE__ */
|
|
776
|
+
/* @__PURE__ */ L("div", {
|
|
802
777
|
className: "text-[10px] opacity-80 truncate",
|
|
803
778
|
children: J(e, n.startMin, n.endMin, i)
|
|
804
779
|
}),
|
|
805
|
-
s && n.isStart && /* @__PURE__ */
|
|
806
|
-
onPointerDown: (e) =>
|
|
780
|
+
s && n.isStart && /* @__PURE__ */ L("div", {
|
|
781
|
+
onPointerDown: (e) => O(e, n, t, "top"),
|
|
807
782
|
className: "absolute top-0 left-0 right-0 h-1.5 cursor-ns-resize",
|
|
808
783
|
"aria-label": "Resize start"
|
|
809
784
|
}),
|
|
810
|
-
s && n.isEnd && /* @__PURE__ */
|
|
811
|
-
onPointerDown: (e) =>
|
|
785
|
+
s && n.isEnd && /* @__PURE__ */ L("div", {
|
|
786
|
+
onPointerDown: (e) => O(e, n, t, "bottom"),
|
|
812
787
|
className: "absolute bottom-0 left-0 right-0 h-1.5 cursor-ns-resize",
|
|
813
788
|
"aria-label": "Resize end"
|
|
814
789
|
})
|
|
815
790
|
]
|
|
816
791
|
}, `${n.event.id}-${n.startMin}`);
|
|
817
792
|
}),
|
|
818
|
-
|
|
793
|
+
A(t)
|
|
819
794
|
]
|
|
820
795
|
}, n);
|
|
821
796
|
})]
|
|
@@ -837,7 +812,7 @@ function J(e, t, n, r) {
|
|
|
837
812
|
}
|
|
838
813
|
//#endregion
|
|
839
814
|
//#region src/ObjectCalendar.tsx
|
|
840
|
-
function
|
|
815
|
+
function _e(e) {
|
|
841
816
|
return "data" in e && e.data ? e.data : "staticData" in e && e.staticData ? {
|
|
842
817
|
provider: "value",
|
|
843
818
|
items: e.staticData
|
|
@@ -846,7 +821,7 @@ function me(e) {
|
|
|
846
821
|
object: e.objectName
|
|
847
822
|
} : null;
|
|
848
823
|
}
|
|
849
|
-
function
|
|
824
|
+
function ve(e) {
|
|
850
825
|
if (e) {
|
|
851
826
|
if (typeof e == "string") {
|
|
852
827
|
let t = e.split(" "), n = t[0], r = t[1]?.toLowerCase() === "desc" ? "desc" : "asc";
|
|
@@ -855,7 +830,7 @@ function he(e) {
|
|
|
855
830
|
if (Array.isArray(e)) return e.reduce((e, t) => (t.field && t.order && (e[t.field] = t.order), e), {});
|
|
856
831
|
}
|
|
857
832
|
}
|
|
858
|
-
function
|
|
833
|
+
function ye(e) {
|
|
859
834
|
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 ? {
|
|
860
835
|
startDateField: e.startDateField || e.dateField,
|
|
861
836
|
endDateField: e.endDateField || e.endField,
|
|
@@ -864,87 +839,87 @@ function ge(e) {
|
|
|
864
839
|
allDayField: e.allDayField
|
|
865
840
|
} : null;
|
|
866
841
|
}
|
|
867
|
-
var Y = ({ schema: e, dataSource: t, className: s, data:
|
|
868
|
-
let
|
|
869
|
-
let e =
|
|
870
|
-
return typeof window < "u" && window.innerWidth < 768 && e ? "month" :
|
|
842
|
+
var Y = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventClick: _, onRowClick: v, onDateClick: y, onNavigate: x, onViewChange: O, onEventDrop: k, locale: A }) => {
|
|
843
|
+
let ne = m(), j = Array.isArray(h), [M, N] = o(j ? h : []), [re, P] = o(j ? g ?? !1 : !0), [F, le] = o(null), [z, ue] = o(null), [de, fe] = o(/* @__PURE__ */ new Date()), B = ae(), V = e.defaultView, [H, me] = o(() => {
|
|
844
|
+
let e = V === "day" || !V;
|
|
845
|
+
return typeof window < "u" && window.innerWidth < 768 && e ? "month" : V || "month";
|
|
871
846
|
});
|
|
872
847
|
r(() => {
|
|
873
|
-
|
|
874
|
-
}, [
|
|
875
|
-
let [
|
|
848
|
+
B && H === "day" && (V === "day" || !V) && me("month");
|
|
849
|
+
}, [B]);
|
|
850
|
+
let [he, ge] = o(0);
|
|
876
851
|
r(() => {
|
|
877
|
-
if (!
|
|
878
|
-
t.resource === e.objectName &&
|
|
852
|
+
if (!j && !(!t?.onMutation || !e.objectName)) return t.onMutation((t) => {
|
|
853
|
+
t.resource === e.objectName && ge((e) => e + 1);
|
|
879
854
|
});
|
|
880
855
|
}, [
|
|
881
856
|
t,
|
|
882
857
|
e.objectName,
|
|
883
|
-
|
|
858
|
+
j
|
|
884
859
|
]);
|
|
885
|
-
let { ref:
|
|
860
|
+
let { ref: U, isRefreshing: W, pullDistance: G } = oe({
|
|
886
861
|
onRefresh: n(async () => {
|
|
887
|
-
|
|
862
|
+
ge((e) => e + 1);
|
|
888
863
|
}, []),
|
|
889
864
|
enabled: !!t && !!e.objectName
|
|
890
|
-
}),
|
|
865
|
+
}), K = i(() => _e(e), [
|
|
891
866
|
e.data,
|
|
892
867
|
e.staticData,
|
|
893
868
|
e.objectName
|
|
894
|
-
]),
|
|
869
|
+
]), q = i(() => ye(e), [
|
|
895
870
|
e.filter,
|
|
896
871
|
e.calendar,
|
|
897
872
|
e.dateField,
|
|
898
873
|
e.endField,
|
|
899
874
|
e.titleField,
|
|
900
875
|
e.colorField
|
|
901
|
-
]),
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
}, [
|
|
905
|
-
|
|
906
|
-
}, [
|
|
907
|
-
if (
|
|
876
|
+
]), J = K?.provider === "value", Y = a(null);
|
|
877
|
+
Y.current = z, r(() => {
|
|
878
|
+
j && N(h);
|
|
879
|
+
}, [h, j]), r(() => {
|
|
880
|
+
j && g !== void 0 && P(g);
|
|
881
|
+
}, [g, j]), r(() => {
|
|
882
|
+
if (j) return;
|
|
908
883
|
let n = !0;
|
|
909
884
|
return (async () => {
|
|
910
885
|
try {
|
|
911
886
|
if (!n) return;
|
|
912
|
-
if (
|
|
913
|
-
n && (
|
|
887
|
+
if (P(!0), J && K?.provider === "value") {
|
|
888
|
+
n && (N(K.items), P(!1));
|
|
914
889
|
return;
|
|
915
890
|
}
|
|
916
891
|
if (!t || typeof t.find != "function") throw Error("DataSource required for object/api providers");
|
|
917
|
-
if (
|
|
918
|
-
let r =
|
|
892
|
+
if (K?.provider === "object") {
|
|
893
|
+
let r = K.object, i = c(Y.current?.fields), a = l(await t.find(r, {
|
|
919
894
|
$filter: e.filter,
|
|
920
|
-
$orderby:
|
|
895
|
+
$orderby: ve(e.sort),
|
|
921
896
|
...i.length > 0 ? { $expand: i } : {}
|
|
922
897
|
}));
|
|
923
|
-
n &&
|
|
924
|
-
} else
|
|
925
|
-
n &&
|
|
898
|
+
n && N(a);
|
|
899
|
+
} else K?.provider === "api" && (console.warn("API provider not yet implemented for ObjectCalendar"), n && N([]));
|
|
900
|
+
n && P(!1);
|
|
926
901
|
} catch (e) {
|
|
927
|
-
console.error("[ObjectCalendar] Error fetching data:", e), n && (
|
|
902
|
+
console.error("[ObjectCalendar] Error fetching data:", e), n && (le(e), P(!1));
|
|
928
903
|
}
|
|
929
904
|
})(), () => {
|
|
930
905
|
n = !1;
|
|
931
906
|
};
|
|
932
907
|
}, [
|
|
933
|
-
|
|
934
|
-
W,
|
|
935
|
-
t,
|
|
908
|
+
j,
|
|
936
909
|
K,
|
|
910
|
+
t,
|
|
911
|
+
J,
|
|
937
912
|
e.filter,
|
|
938
913
|
e.sort,
|
|
939
|
-
|
|
914
|
+
he
|
|
940
915
|
]), r(() => {
|
|
941
|
-
!
|
|
916
|
+
!J && t && (async () => {
|
|
942
917
|
try {
|
|
943
918
|
if (!t) return;
|
|
944
|
-
let n =
|
|
919
|
+
let n = K?.provider === "object" ? K.object : e.objectName;
|
|
945
920
|
if (!n) return;
|
|
946
921
|
let r = await t.getObjectSchema(n);
|
|
947
|
-
|
|
922
|
+
ue(r);
|
|
948
923
|
} catch (e) {
|
|
949
924
|
console.error("Failed to fetch object schema:", e);
|
|
950
925
|
}
|
|
@@ -952,19 +927,19 @@ var Y = ({ schema: e, dataSource: t, className: s, data: f, loading: p, onEventC
|
|
|
952
927
|
}, [
|
|
953
928
|
e.objectName,
|
|
954
929
|
t,
|
|
955
|
-
|
|
956
|
-
|
|
930
|
+
J,
|
|
931
|
+
K
|
|
957
932
|
]);
|
|
958
|
-
let
|
|
959
|
-
if (!
|
|
960
|
-
let { startDateField: e, endDateField: t, titleField: n, colorField: r } =
|
|
933
|
+
let be = i(() => {
|
|
934
|
+
if (!q || !M.length) return [];
|
|
935
|
+
let { startDateField: e, endDateField: t, titleField: n, colorField: r } = q, i = (e) => {
|
|
961
936
|
if (n) {
|
|
962
937
|
let t = e[n], r = typeof t == "string" ? t.trim() : t;
|
|
963
938
|
if (r) return String(r);
|
|
964
939
|
}
|
|
965
|
-
return u(
|
|
940
|
+
return u(z, e);
|
|
966
941
|
};
|
|
967
|
-
return
|
|
942
|
+
return M.map((n, a) => {
|
|
968
943
|
let o = n[e], s = t ? n[t] : null, c = i(n), l = r ? n[r] : void 0;
|
|
969
944
|
return {
|
|
970
945
|
id: n.id || n._id || `event-${a}`,
|
|
@@ -977,64 +952,65 @@ var Y = ({ schema: e, dataSource: t, className: s, data: f, loading: p, onEventC
|
|
|
977
952
|
};
|
|
978
953
|
}).filter((e) => !isNaN(e.start.getTime()));
|
|
979
954
|
}, [
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
955
|
+
M,
|
|
956
|
+
q,
|
|
957
|
+
z
|
|
983
958
|
]);
|
|
984
959
|
n(() => {
|
|
985
|
-
|
|
986
|
-
}, [
|
|
987
|
-
let
|
|
960
|
+
y?.(/* @__PURE__ */ new Date());
|
|
961
|
+
}, [y]);
|
|
962
|
+
let X = e.navigation ?? {
|
|
988
963
|
mode: "drawer",
|
|
989
964
|
width: "min(960px, 60vw)"
|
|
990
|
-
},
|
|
991
|
-
navigation:
|
|
965
|
+
}, xe = X.mode === "drawer" || X.mode === "modal" || X.mode === "split" || X.mode === "popover", Z = p({
|
|
966
|
+
navigation: X,
|
|
992
967
|
objectName: e.objectName,
|
|
993
|
-
onRowClick:
|
|
994
|
-
}),
|
|
995
|
-
if (!
|
|
996
|
-
let { startDateField: a, endDateField: o } =
|
|
968
|
+
onRowClick: xe ? void 0 : v
|
|
969
|
+
}), Se = n(async (n, r, i) => {
|
|
970
|
+
if (!q) return;
|
|
971
|
+
let { startDateField: a, endDateField: o } = q, s = n?.id ?? n?._id;
|
|
997
972
|
if (!s || !e.objectName || !t?.update) return;
|
|
998
973
|
let c = { [a]: r.toISOString() };
|
|
999
974
|
o && i && (c[o] = i.toISOString());
|
|
1000
|
-
let l =
|
|
1001
|
-
|
|
975
|
+
let l = M;
|
|
976
|
+
N((e) => e.map((e) => (e?.id ?? e?._id) === s ? {
|
|
1002
977
|
...e,
|
|
1003
978
|
...c
|
|
1004
979
|
} : e));
|
|
1005
980
|
try {
|
|
1006
981
|
await t.update(e.objectName, s, c);
|
|
1007
982
|
} catch (e) {
|
|
1008
|
-
|
|
983
|
+
N(l), console.error("[ObjectCalendar] Failed to persist drag-and-drop reschedule:", e), ie.error(f(e) ? ne("errors.unauthorized", "You are not authorized to perform this action.") : d(e) ?? ne("table.saveFailed", "Save failed"));
|
|
1009
984
|
}
|
|
1010
985
|
}, [
|
|
1011
|
-
|
|
986
|
+
q,
|
|
1012
987
|
e.objectName,
|
|
1013
988
|
t,
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
989
|
+
M,
|
|
990
|
+
ne
|
|
991
|
+
]), [Q, $] = o(null), Ce = n((n) => {
|
|
992
|
+
!q || !e.objectName || !t?.create || $({
|
|
1017
993
|
start: n,
|
|
1018
994
|
title: "",
|
|
1019
995
|
submitting: !1
|
|
1020
996
|
});
|
|
1021
997
|
}, [
|
|
1022
|
-
|
|
998
|
+
q,
|
|
1023
999
|
e.objectName,
|
|
1024
1000
|
t
|
|
1025
|
-
]),
|
|
1026
|
-
!
|
|
1001
|
+
]), we = n((n, r) => {
|
|
1002
|
+
!q || !e.objectName || !t?.create || $({
|
|
1027
1003
|
start: n,
|
|
1028
1004
|
end: r,
|
|
1029
1005
|
title: "",
|
|
1030
1006
|
submitting: !1
|
|
1031
1007
|
});
|
|
1032
1008
|
}, [
|
|
1033
|
-
|
|
1009
|
+
q,
|
|
1034
1010
|
e.objectName,
|
|
1035
1011
|
t
|
|
1036
|
-
]),
|
|
1037
|
-
if (!Q || !
|
|
1012
|
+
]), Te = n(async () => {
|
|
1013
|
+
if (!Q || !q) return;
|
|
1038
1014
|
let n = Q.title.trim();
|
|
1039
1015
|
if (!n) {
|
|
1040
1016
|
$((e) => e && {
|
|
@@ -1049,12 +1025,12 @@ var Y = ({ schema: e, dataSource: t, className: s, data: f, loading: p, onEventC
|
|
|
1049
1025
|
submitting: !0,
|
|
1050
1026
|
error: void 0
|
|
1051
1027
|
});
|
|
1052
|
-
let { startDateField: r, endDateField: i, titleField: a } =
|
|
1028
|
+
let { startDateField: r, endDateField: i, titleField: a } = q, o = {
|
|
1053
1029
|
[a || "name"]: n,
|
|
1054
1030
|
[r]: Q.start.toISOString()
|
|
1055
1031
|
};
|
|
1056
1032
|
i && (o[i] = (Q.end ?? Q.start).toISOString());
|
|
1057
|
-
let s =
|
|
1033
|
+
let s = z?.fields;
|
|
1058
1034
|
if (s && typeof s == "object") {
|
|
1059
1035
|
let e = Array.isArray(s) ? s.map((e) => [e.name ?? e.apiName, e]) : Object.entries(s);
|
|
1060
1036
|
for (let [t, n] of e) {
|
|
@@ -1072,7 +1048,7 @@ var Y = ({ schema: e, dataSource: t, className: s, data: f, loading: p, onEventC
|
|
|
1072
1048
|
}
|
|
1073
1049
|
try {
|
|
1074
1050
|
let n = await t.create(e.objectName, o), r = (n && (n.record || n.data || n)) ?? null;
|
|
1075
|
-
r && (r.id !== void 0 || r._id !== void 0) &&
|
|
1051
|
+
r && (r.id !== void 0 || r._id !== void 0) && N((e) => [...e, r]), $(null);
|
|
1076
1052
|
} catch (e) {
|
|
1077
1053
|
let t = e?.message || String(e);
|
|
1078
1054
|
$((e) => e && {
|
|
@@ -1083,84 +1059,84 @@ var Y = ({ schema: e, dataSource: t, className: s, data: f, loading: p, onEventC
|
|
|
1083
1059
|
}
|
|
1084
1060
|
}, [
|
|
1085
1061
|
Q,
|
|
1086
|
-
|
|
1062
|
+
q,
|
|
1087
1063
|
e.objectName,
|
|
1088
1064
|
t,
|
|
1089
|
-
|
|
1065
|
+
z
|
|
1090
1066
|
]);
|
|
1091
|
-
return
|
|
1067
|
+
return re ? /* @__PURE__ */ L("div", {
|
|
1092
1068
|
className: s,
|
|
1093
|
-
children: /* @__PURE__ */
|
|
1069
|
+
children: /* @__PURE__ */ L("div", {
|
|
1094
1070
|
className: "flex items-center justify-center h-96",
|
|
1095
|
-
children: /* @__PURE__ */
|
|
1071
|
+
children: /* @__PURE__ */ L("div", {
|
|
1096
1072
|
className: "text-muted-foreground",
|
|
1097
1073
|
children: "Loading calendar..."
|
|
1098
1074
|
})
|
|
1099
1075
|
})
|
|
1100
|
-
}) :
|
|
1076
|
+
}) : F ? /* @__PURE__ */ L("div", {
|
|
1101
1077
|
className: s,
|
|
1102
|
-
children: /* @__PURE__ */
|
|
1078
|
+
children: /* @__PURE__ */ L("div", {
|
|
1103
1079
|
className: "flex items-center justify-center h-96",
|
|
1104
|
-
children: /* @__PURE__ */
|
|
1080
|
+
children: /* @__PURE__ */ R("div", {
|
|
1105
1081
|
className: "text-destructive",
|
|
1106
|
-
children: ["Error: ",
|
|
1082
|
+
children: ["Error: ", F.message]
|
|
1107
1083
|
})
|
|
1108
1084
|
})
|
|
1109
|
-
}) :
|
|
1110
|
-
ref:
|
|
1085
|
+
}) : q ? /* @__PURE__ */ R("div", {
|
|
1086
|
+
ref: U,
|
|
1111
1087
|
className: s,
|
|
1112
1088
|
children: [
|
|
1113
|
-
|
|
1089
|
+
G > 0 && /* @__PURE__ */ L("div", {
|
|
1114
1090
|
className: "flex items-center justify-center text-xs text-muted-foreground",
|
|
1115
|
-
style: { height:
|
|
1116
|
-
children:
|
|
1091
|
+
style: { height: G },
|
|
1092
|
+
children: W ? "Refreshing…" : "Pull to refresh"
|
|
1117
1093
|
}),
|
|
1118
|
-
/* @__PURE__ */
|
|
1094
|
+
/* @__PURE__ */ L("div", {
|
|
1119
1095
|
className: "bg-background h-[calc(100vh-120px)] sm:h-[calc(100vh-160px)] md:h-[calc(100vh-200px)] min-h-[400px] sm:min-h-[600px]",
|
|
1120
|
-
children: /* @__PURE__ */
|
|
1121
|
-
events:
|
|
1122
|
-
currentDate:
|
|
1123
|
-
view:
|
|
1124
|
-
locale:
|
|
1096
|
+
children: /* @__PURE__ */ L(pe, {
|
|
1097
|
+
events: be,
|
|
1098
|
+
currentDate: de,
|
|
1099
|
+
view: H,
|
|
1100
|
+
locale: A,
|
|
1125
1101
|
onEventClick: (e) => {
|
|
1126
|
-
Z.handleClick(e.data),
|
|
1102
|
+
Z.handleClick(e.data), xe || _?.(e.data);
|
|
1127
1103
|
},
|
|
1128
1104
|
onDateClick: (e) => {
|
|
1129
|
-
|
|
1105
|
+
y ? y(e) : Ce(e);
|
|
1130
1106
|
},
|
|
1131
1107
|
onNavigate: (e) => {
|
|
1132
|
-
|
|
1108
|
+
fe(e), x?.(e);
|
|
1133
1109
|
},
|
|
1134
1110
|
onViewChange: (e) => {
|
|
1135
|
-
|
|
1111
|
+
me(e), O?.(e);
|
|
1136
1112
|
},
|
|
1137
1113
|
onAddClick: void 0,
|
|
1138
1114
|
onEventDrop: (e, t, n) => {
|
|
1139
|
-
|
|
1115
|
+
k ? k(e.data, t, n) : Se(e.data, t, n);
|
|
1140
1116
|
},
|
|
1141
|
-
onTimeRangeSelect:
|
|
1117
|
+
onTimeRangeSelect: we
|
|
1142
1118
|
})
|
|
1143
1119
|
}),
|
|
1144
|
-
/* @__PURE__ */
|
|
1120
|
+
/* @__PURE__ */ L(S, {
|
|
1145
1121
|
open: !!Q,
|
|
1146
1122
|
onOpenChange: (e) => {
|
|
1147
1123
|
e || $(null);
|
|
1148
1124
|
},
|
|
1149
|
-
children: /* @__PURE__ */
|
|
1125
|
+
children: /* @__PURE__ */ R(C, {
|
|
1150
1126
|
className: "sm:max-w-md",
|
|
1151
1127
|
children: [
|
|
1152
|
-
/* @__PURE__ */
|
|
1153
|
-
let e = Q.end && Q.end.getTime() !== Q.start.getTime(), t = Q.start.toLocaleDateString(
|
|
1128
|
+
/* @__PURE__ */ R(E, { children: [/* @__PURE__ */ L(D, { children: "New event" }), /* @__PURE__ */ L(w, { children: Q && (() => {
|
|
1129
|
+
let e = Q.end && Q.end.getTime() !== Q.start.getTime(), t = Q.start.toLocaleDateString(A, {
|
|
1154
1130
|
year: "numeric",
|
|
1155
1131
|
month: "long",
|
|
1156
1132
|
day: "numeric"
|
|
1157
1133
|
});
|
|
1158
1134
|
if (e) {
|
|
1159
|
-
let e = (e) => e.toLocaleTimeString(
|
|
1135
|
+
let e = (e) => e.toLocaleTimeString(A, {
|
|
1160
1136
|
hour: "numeric",
|
|
1161
1137
|
minute: "2-digit"
|
|
1162
1138
|
});
|
|
1163
|
-
return /* @__PURE__ */ I
|
|
1139
|
+
return /* @__PURE__ */ R(I, { children: [
|
|
1164
1140
|
t,
|
|
1165
1141
|
" · ",
|
|
1166
1142
|
e(Q.start),
|
|
@@ -1168,16 +1144,16 @@ var Y = ({ schema: e, dataSource: t, className: s, data: f, loading: p, onEventC
|
|
|
1168
1144
|
e(Q.end)
|
|
1169
1145
|
] });
|
|
1170
1146
|
}
|
|
1171
|
-
return /* @__PURE__ */ I
|
|
1147
|
+
return /* @__PURE__ */ R(I, { children: ["On ", t] });
|
|
1172
1148
|
})() })] }),
|
|
1173
|
-
/* @__PURE__ */
|
|
1149
|
+
/* @__PURE__ */ R("div", {
|
|
1174
1150
|
className: "space-y-2",
|
|
1175
1151
|
children: [
|
|
1176
|
-
/* @__PURE__ */
|
|
1152
|
+
/* @__PURE__ */ L(te, {
|
|
1177
1153
|
htmlFor: "quick-create-title",
|
|
1178
1154
|
children: "Title"
|
|
1179
1155
|
}),
|
|
1180
|
-
/* @__PURE__ */
|
|
1156
|
+
/* @__PURE__ */ L(ee, {
|
|
1181
1157
|
id: "quick-create-title",
|
|
1182
1158
|
autoFocus: !0,
|
|
1183
1159
|
value: Q?.title ?? "",
|
|
@@ -1187,24 +1163,24 @@ var Y = ({ schema: e, dataSource: t, className: s, data: f, loading: p, onEventC
|
|
|
1187
1163
|
error: void 0
|
|
1188
1164
|
}),
|
|
1189
1165
|
onKeyDown: (e) => {
|
|
1190
|
-
e.key === "Enter" && !Q?.submitting && (e.preventDefault(),
|
|
1166
|
+
e.key === "Enter" && !Q?.submitting && (e.preventDefault(), Te());
|
|
1191
1167
|
},
|
|
1192
1168
|
placeholder: "What's this event about?",
|
|
1193
1169
|
disabled: Q?.submitting
|
|
1194
1170
|
}),
|
|
1195
|
-
Q?.error && /* @__PURE__ */
|
|
1171
|
+
Q?.error && /* @__PURE__ */ L("p", {
|
|
1196
1172
|
className: "text-sm text-destructive",
|
|
1197
1173
|
children: Q.error
|
|
1198
1174
|
})
|
|
1199
1175
|
]
|
|
1200
1176
|
}),
|
|
1201
|
-
/* @__PURE__ */
|
|
1177
|
+
/* @__PURE__ */ R(T, { children: [/* @__PURE__ */ L(b, {
|
|
1202
1178
|
variant: "outline",
|
|
1203
1179
|
onClick: () => $(null),
|
|
1204
1180
|
disabled: Q?.submitting,
|
|
1205
1181
|
children: "Cancel"
|
|
1206
|
-
}), /* @__PURE__ */
|
|
1207
|
-
onClick: () => void
|
|
1182
|
+
}), /* @__PURE__ */ L(b, {
|
|
1183
|
+
onClick: () => void Te(),
|
|
1208
1184
|
disabled: Q?.submitting || !Q?.title.trim(),
|
|
1209
1185
|
children: Q?.submitting ? "Creating…" : "Create"
|
|
1210
1186
|
})] })
|
|
@@ -1212,10 +1188,10 @@ var Y = ({ schema: e, dataSource: t, className: s, data: f, loading: p, onEventC
|
|
|
1212
1188
|
})
|
|
1213
1189
|
}),
|
|
1214
1190
|
Z.isOverlay && Z.isOpen && Z.selectedRecord && (() => {
|
|
1215
|
-
let n =
|
|
1191
|
+
let n = K?.provider === "object" ? K.object : e.objectName, r = Z.selectedRecord, i = r.id ?? r._id;
|
|
1216
1192
|
if (!n || i == null) return null;
|
|
1217
|
-
let a =
|
|
1218
|
-
return /* @__PURE__ */
|
|
1193
|
+
let a = q?.titleField ? String(r[q.titleField] ?? "Event Details") : "Event Details";
|
|
1194
|
+
return /* @__PURE__ */ L(se, {
|
|
1219
1195
|
open: !0,
|
|
1220
1196
|
onClose: Z.close,
|
|
1221
1197
|
title: a,
|
|
@@ -1223,26 +1199,26 @@ var Y = ({ schema: e, dataSource: t, className: s, data: f, loading: p, onEventC
|
|
|
1223
1199
|
objectName: n,
|
|
1224
1200
|
recordId: i,
|
|
1225
1201
|
dataSource: t,
|
|
1226
|
-
objectSchema:
|
|
1202
|
+
objectSchema: z,
|
|
1227
1203
|
width: Z.width ?? "min(960px, 60vw)",
|
|
1228
|
-
fullPageHref:
|
|
1204
|
+
fullPageHref: ce(n, i) ?? void 0,
|
|
1229
1205
|
onFieldSave: async (e, r) => {
|
|
1230
|
-
t?.update && (await t.update(n, String(i), { [e]: r }),
|
|
1206
|
+
t?.update && (await t.update(n, String(i), { [e]: r }), N((t) => t.map((t) => String(t.id ?? t._id) === String(i) ? {
|
|
1231
1207
|
...t,
|
|
1232
1208
|
[e]: r
|
|
1233
1209
|
} : t)));
|
|
1234
1210
|
},
|
|
1235
1211
|
onDelete: async () => {
|
|
1236
|
-
t?.delete && (await t.delete(n, String(i)),
|
|
1212
|
+
t?.delete && (await t.delete(n, String(i)), N((e) => e.filter((e) => String(e.id ?? e._id) !== String(i))));
|
|
1237
1213
|
}
|
|
1238
1214
|
});
|
|
1239
1215
|
})()
|
|
1240
1216
|
]
|
|
1241
|
-
}) : /* @__PURE__ */
|
|
1217
|
+
}) : /* @__PURE__ */ L("div", {
|
|
1242
1218
|
className: s,
|
|
1243
|
-
children: /* @__PURE__ */
|
|
1219
|
+
children: /* @__PURE__ */ L("div", {
|
|
1244
1220
|
className: "flex items-center justify-center h-96",
|
|
1245
|
-
children: /* @__PURE__ */
|
|
1221
|
+
children: /* @__PURE__ */ L("div", {
|
|
1246
1222
|
className: "text-muted-foreground",
|
|
1247
1223
|
children: "Calendar configuration required. Please specify startDateField and titleField."
|
|
1248
1224
|
})
|
|
@@ -1251,7 +1227,7 @@ var Y = ({ schema: e, dataSource: t, className: s, data: f, loading: p, onEventC
|
|
|
1251
1227
|
};
|
|
1252
1228
|
//#endregion
|
|
1253
1229
|
//#region src/calendar-view-renderer.tsx
|
|
1254
|
-
s.register("calendar-view", ({ schema: e, className: n, onAction: r, ...i }) => /* @__PURE__ */
|
|
1230
|
+
s.register("calendar-view", ({ schema: e, className: n, onAction: r, ...i }) => /* @__PURE__ */ L(pe, {
|
|
1255
1231
|
className: n,
|
|
1256
1232
|
events: t.useMemo(() => !e.data || !Array.isArray(e.data) ? [] : e.data.map((t, n) => {
|
|
1257
1233
|
let r = e.titleField || "title", i = e.startDateField || "start", a = e.endDateField || "end", o = e.colorField || "color", s = e.allDayField || "allDay";
|
|
@@ -1399,15 +1375,15 @@ s.register("calendar-view", ({ schema: e, className: n, onAction: r, ...i }) =>
|
|
|
1399
1375
|
});
|
|
1400
1376
|
//#endregion
|
|
1401
1377
|
//#region src/index.tsx
|
|
1402
|
-
var
|
|
1403
|
-
let { dataSource: n } =
|
|
1404
|
-
return /* @__PURE__ */
|
|
1378
|
+
var be = ({ schema: e, ...t }) => {
|
|
1379
|
+
let { dataSource: n } = h() || {};
|
|
1380
|
+
return /* @__PURE__ */ L(Y, {
|
|
1405
1381
|
schema: e,
|
|
1406
1382
|
dataSource: n,
|
|
1407
1383
|
...t
|
|
1408
1384
|
});
|
|
1409
1385
|
};
|
|
1410
|
-
s.register("object-calendar",
|
|
1386
|
+
s.register("object-calendar", be, {
|
|
1411
1387
|
namespace: "plugin-calendar",
|
|
1412
1388
|
label: "Object Calendar",
|
|
1413
1389
|
category: "view",
|
|
@@ -1422,7 +1398,7 @@ s.register("object-calendar", X, {
|
|
|
1422
1398
|
label: "Calendar Config",
|
|
1423
1399
|
description: "startDateField, endDateField, titleField, colorField"
|
|
1424
1400
|
}]
|
|
1425
|
-
}), s.register("calendar",
|
|
1401
|
+
}), s.register("calendar", be, {
|
|
1426
1402
|
namespace: "view",
|
|
1427
1403
|
label: "Calendar View",
|
|
1428
1404
|
category: "view",
|
|
@@ -1439,4 +1415,4 @@ s.register("object-calendar", X, {
|
|
|
1439
1415
|
}]
|
|
1440
1416
|
});
|
|
1441
1417
|
//#endregion
|
|
1442
|
-
export {
|
|
1418
|
+
export { pe as CalendarView, Y as ObjectCalendar, be as ObjectCalendarRenderer };
|