@object-ui/plugin-calendar 17.2.0 → 17.5.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 +422 -0
- package/README.md +0 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +327 -222
- package/dist/index.umd.cjs +1 -1
- package/package.json +15 -15
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 { createSafeTranslation as
|
|
8
|
-
import { Fragment as
|
|
9
|
-
import { usePullToRefresh as
|
|
10
|
-
import { RecordDetailDrawer as
|
|
4
|
+
import { ElementDataSourceGate as d, extractWriteErrorMessage as f, isPermissionError as p, useNavigationOverlay as m, useSafeTranslate as h, useSchemaContext as g } from "@object-ui/react";
|
|
5
|
+
import { CalendarIcon as _, ChevronLeftIcon as v, ChevronRightIcon as y, PlusIcon as b } from "lucide-react";
|
|
6
|
+
import { Button as x, Calendar as S, Dialog as C, DialogContent as w, DialogDescription as T, DialogFooter as E, DialogHeader as D, DialogTitle as ee, Input as te, Label as O, Popover as ne, PopoverContent as k, PopoverTrigger as A, Select as j, SelectContent as M, SelectItem as N, SelectTrigger as re, SelectValue as P, cn as F, toast as ie, useIsMobile as ae } from "@object-ui/components";
|
|
7
|
+
import { createSafeTranslation as I } from "@object-ui/i18n";
|
|
8
|
+
import { Fragment as oe, jsx as L, jsxs as R } from "react/jsx-runtime";
|
|
9
|
+
import { usePullToRefresh as se } from "@object-ui/mobile";
|
|
10
|
+
import { RecordDetailDrawer as ce, deriveRecordPageHref as le } from "@object-ui/plugin-detail";
|
|
11
11
|
//#region src/CalendarView.tsx
|
|
12
|
-
var
|
|
12
|
+
var z = "bg-blue-100 text-blue-900 border border-blue-200", ue = /* @__PURE__ */ new Date(), de = [
|
|
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 le = "bg-blue-100 text-blue-900 border border-blue-200", z = /* @__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
|
+
], fe = /^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i, pe = /(^|\s)(bg|text|from|to|via)-/;
|
|
22
22
|
function B(e) {
|
|
23
|
-
if (!e) return { className:
|
|
24
|
-
if (
|
|
23
|
+
if (!e) return { className: z };
|
|
24
|
+
if (fe.test(e)) return {
|
|
25
25
|
className: "text-white",
|
|
26
26
|
inlineColor: e
|
|
27
27
|
};
|
|
28
|
-
if (
|
|
28
|
+
if (pe.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: de[Math.abs(t) % de.length] };
|
|
32
32
|
}
|
|
33
|
-
var V =
|
|
33
|
+
var V = I({
|
|
34
34
|
"calendar.today": "Today",
|
|
35
35
|
"calendar.month": "Month",
|
|
36
36
|
"calendar.week": "Week",
|
|
@@ -39,8 +39,8 @@ var V = F({
|
|
|
39
39
|
"calendar.moreEvents": "+{{count}} more",
|
|
40
40
|
"calendar.allDay": "all-day"
|
|
41
41
|
}, "calendar.today");
|
|
42
|
-
function
|
|
43
|
-
let [m, h] = e.useState(n), [
|
|
42
|
+
function me({ events: t = [], view: n = "month", currentDate: r = ue, 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), [g, C] = e.useState(r), { t: w, language: T } = V(), E = i === "default" ? T : i;
|
|
44
44
|
e.useEffect(() => {
|
|
45
45
|
C(r);
|
|
46
46
|
}, [r]), e.useEffect(() => {
|
|
@@ -54,23 +54,23 @@ function pe({ events: t = [], view: n = "month", currentDate: r = z, locale: i =
|
|
|
54
54
|
return t(e), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
55
55
|
}, []);
|
|
56
56
|
let ee = () => {
|
|
57
|
-
let e = new Date(
|
|
57
|
+
let e = new Date(g);
|
|
58
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
59
|
}, te = () => {
|
|
60
|
-
let e = new Date(
|
|
60
|
+
let e = new Date(g);
|
|
61
61
|
m === "month" ? e.setMonth(e.getMonth() + 1) : m === "week" ? e.setDate(e.getDate() + 7) : e.setDate(e.getDate() + 1), C(e), c?.(e);
|
|
62
|
-
},
|
|
62
|
+
}, O = () => {
|
|
63
63
|
let e = /* @__PURE__ */ new Date();
|
|
64
64
|
C(e), c?.(e);
|
|
65
|
-
},
|
|
65
|
+
}, ie = (e) => {
|
|
66
66
|
h(e), s?.(e);
|
|
67
|
-
},
|
|
68
|
-
if (m === "month") return
|
|
67
|
+
}, ae = () => {
|
|
68
|
+
if (m === "month") return g.toLocaleDateString(E, {
|
|
69
69
|
month: "long",
|
|
70
70
|
year: "numeric"
|
|
71
71
|
});
|
|
72
72
|
if (m === "week") {
|
|
73
|
-
let e = H(
|
|
73
|
+
let e = H(g), t = new Date(e);
|
|
74
74
|
return t.setDate(t.getDate() + 6), `${e.toLocaleDateString(E, {
|
|
75
75
|
month: "short",
|
|
76
76
|
day: "numeric"
|
|
@@ -79,7 +79,8 @@ function pe({ events: t = [], view: n = "month", currentDate: r = z, locale: i =
|
|
|
79
79
|
day: "numeric",
|
|
80
80
|
year: "numeric"
|
|
81
81
|
})}`;
|
|
82
|
-
}
|
|
82
|
+
}
|
|
83
|
+
return g.toLocaleDateString(E, {
|
|
83
84
|
weekday: "long",
|
|
84
85
|
month: "long",
|
|
85
86
|
day: "numeric",
|
|
@@ -89,7 +90,7 @@ function pe({ events: t = [], view: n = "month", currentDate: r = z, locale: i =
|
|
|
89
90
|
return /* @__PURE__ */ R("div", {
|
|
90
91
|
role: "region",
|
|
91
92
|
"aria-label": "Calendar",
|
|
92
|
-
className:
|
|
93
|
+
className: F("flex flex-col h-full bg-background min-w-0 overflow-hidden", p),
|
|
93
94
|
children: [/* @__PURE__ */ R("div", {
|
|
94
95
|
className: "flex flex-wrap items-center justify-between gap-2 p-2 sm:p-4 border-b min-w-0",
|
|
95
96
|
children: [/* @__PURE__ */ R("div", {
|
|
@@ -97,46 +98,46 @@ function pe({ events: t = [], view: n = "month", currentDate: r = z, locale: i =
|
|
|
97
98
|
children: [/* @__PURE__ */ R("div", {
|
|
98
99
|
className: "flex items-center bg-muted/50 rounded-lg p-1 gap-1",
|
|
99
100
|
children: [
|
|
100
|
-
/* @__PURE__ */ L(
|
|
101
|
+
/* @__PURE__ */ L(x, {
|
|
101
102
|
variant: "ghost",
|
|
102
103
|
size: "sm",
|
|
103
|
-
onClick:
|
|
104
|
+
onClick: O,
|
|
104
105
|
className: "h-8",
|
|
105
106
|
"aria-label": "Go to today",
|
|
106
107
|
children: w("calendar.today")
|
|
107
108
|
}),
|
|
108
109
|
/* @__PURE__ */ L("div", { className: "h-4 w-px bg-border mx-1" }),
|
|
109
|
-
/* @__PURE__ */ L(
|
|
110
|
+
/* @__PURE__ */ L(x, {
|
|
110
111
|
variant: "ghost",
|
|
111
112
|
size: "icon",
|
|
112
113
|
"aria-label": "Previous period",
|
|
113
114
|
onClick: ee,
|
|
114
115
|
className: "h-8 w-8",
|
|
115
|
-
children: /* @__PURE__ */ L(
|
|
116
|
+
children: /* @__PURE__ */ L(v, { className: "h-4 w-4" })
|
|
116
117
|
}),
|
|
117
|
-
/* @__PURE__ */ L(
|
|
118
|
+
/* @__PURE__ */ L(x, {
|
|
118
119
|
variant: "ghost",
|
|
119
120
|
size: "icon",
|
|
120
121
|
"aria-label": "Next period",
|
|
121
122
|
onClick: te,
|
|
122
123
|
className: "h-8 w-8",
|
|
123
|
-
children: /* @__PURE__ */ L(
|
|
124
|
+
children: /* @__PURE__ */ L(y, { className: "h-4 w-4" })
|
|
124
125
|
})
|
|
125
126
|
]
|
|
126
|
-
}), /* @__PURE__ */ R(
|
|
127
|
+
}), /* @__PURE__ */ R(ne, { children: [/* @__PURE__ */ L(A, {
|
|
127
128
|
asChild: !0,
|
|
128
|
-
children: /* @__PURE__ */ R(
|
|
129
|
+
children: /* @__PURE__ */ R(x, {
|
|
129
130
|
variant: "ghost",
|
|
130
|
-
"aria-label": `Current date: ${
|
|
131
|
-
className:
|
|
132
|
-
children: [/* @__PURE__ */ L(
|
|
131
|
+
"aria-label": `Current date: ${ae()}`,
|
|
132
|
+
className: F("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"),
|
|
133
|
+
children: [/* @__PURE__ */ L(_, { className: "h-5 w-5 text-muted-foreground" }), /* @__PURE__ */ L("span", { children: ae() })]
|
|
133
134
|
})
|
|
134
135
|
}), /* @__PURE__ */ L(k, {
|
|
135
136
|
className: "w-auto p-0",
|
|
136
137
|
align: "start",
|
|
137
|
-
children: /* @__PURE__ */ L(
|
|
138
|
+
children: /* @__PURE__ */ L(S, {
|
|
138
139
|
mode: "single",
|
|
139
|
-
selected:
|
|
140
|
+
selected: g,
|
|
140
141
|
onSelect: (e) => {
|
|
141
142
|
e && (C(e), c?.(e));
|
|
142
143
|
},
|
|
@@ -147,31 +148,31 @@ function pe({ events: t = [], view: n = "month", currentDate: r = z, locale: i =
|
|
|
147
148
|
})] })]
|
|
148
149
|
}), /* @__PURE__ */ R("div", {
|
|
149
150
|
className: "flex items-center gap-2",
|
|
150
|
-
children: [/* @__PURE__ */ R(
|
|
151
|
+
children: [/* @__PURE__ */ R(j, {
|
|
151
152
|
value: m,
|
|
152
|
-
onValueChange:
|
|
153
|
-
children: [/* @__PURE__ */ L(
|
|
153
|
+
onValueChange: ie,
|
|
154
|
+
children: [/* @__PURE__ */ L(re, {
|
|
154
155
|
className: "w-32 bg-background",
|
|
155
|
-
children: /* @__PURE__ */ L(
|
|
156
|
-
}), /* @__PURE__ */ R(
|
|
157
|
-
/* @__PURE__ */ L(
|
|
156
|
+
children: /* @__PURE__ */ L(P, {})
|
|
157
|
+
}), /* @__PURE__ */ R(M, { children: [
|
|
158
|
+
/* @__PURE__ */ L(N, {
|
|
158
159
|
value: "day",
|
|
159
160
|
children: w("calendar.day")
|
|
160
161
|
}),
|
|
161
|
-
/* @__PURE__ */ L(
|
|
162
|
+
/* @__PURE__ */ L(N, {
|
|
162
163
|
value: "week",
|
|
163
164
|
children: w("calendar.week")
|
|
164
165
|
}),
|
|
165
|
-
/* @__PURE__ */ L(
|
|
166
|
+
/* @__PURE__ */ L(N, {
|
|
166
167
|
value: "month",
|
|
167
168
|
children: w("calendar.month")
|
|
168
169
|
})
|
|
169
170
|
] })]
|
|
170
|
-
}), l && /* @__PURE__ */ R(
|
|
171
|
+
}), l && /* @__PURE__ */ R(x, {
|
|
171
172
|
onClick: l,
|
|
172
173
|
size: "sm",
|
|
173
174
|
className: "gap-1",
|
|
174
|
-
children: [/* @__PURE__ */ L(
|
|
175
|
+
children: [/* @__PURE__ */ L(b, { className: "h-4 w-4" }), w("calendar.newEvent")]
|
|
175
176
|
})]
|
|
176
177
|
})]
|
|
177
178
|
}), /* @__PURE__ */ R("div", {
|
|
@@ -182,22 +183,22 @@ function pe({ events: t = [], view: n = "month", currentDate: r = z, locale: i =
|
|
|
182
183
|
onTouchEnd: (e) => {
|
|
183
184
|
let t = I.current - e.changedTouches[0].clientX;
|
|
184
185
|
if (Math.abs(t) > 50) {
|
|
185
|
-
let e = new Date(
|
|
186
|
+
let e = new Date(g);
|
|
186
187
|
m === "day" ? e.setDate(e.getDate() + (t > 0 ? 1 : -1)) : m === "week" ? e.setDate(e.getDate() + (t > 0 ? 7 : -7)) : e.setMonth(e.getMonth() + (t > 0 ? 1 : -1)), C(e), c?.(e);
|
|
187
188
|
}
|
|
188
189
|
},
|
|
189
190
|
children: [
|
|
190
191
|
m === "month" && /* @__PURE__ */ L(ge, {
|
|
191
|
-
date:
|
|
192
|
+
date: g,
|
|
192
193
|
events: t,
|
|
193
194
|
locale: E,
|
|
194
195
|
onEventClick: a,
|
|
195
196
|
onDateClick: o,
|
|
196
197
|
onEventDrop: u
|
|
197
198
|
}),
|
|
198
|
-
m === "week" && /* @__PURE__ */ L(
|
|
199
|
+
m === "week" && /* @__PURE__ */ L(J, {
|
|
199
200
|
mode: "week",
|
|
200
|
-
date:
|
|
201
|
+
date: g,
|
|
201
202
|
events: t,
|
|
202
203
|
locale: E,
|
|
203
204
|
slotMinutes: f,
|
|
@@ -205,9 +206,9 @@ function pe({ events: t = [], view: n = "month", currentDate: r = z, locale: i =
|
|
|
205
206
|
onEventDrop: u,
|
|
206
207
|
onTimeRangeSelect: d
|
|
207
208
|
}),
|
|
208
|
-
m === "day" && /* @__PURE__ */ L(
|
|
209
|
+
m === "day" && /* @__PURE__ */ L(J, {
|
|
209
210
|
mode: "day",
|
|
210
|
-
date:
|
|
211
|
+
date: g,
|
|
211
212
|
events: t,
|
|
212
213
|
locale: E,
|
|
213
214
|
slotMinutes: f,
|
|
@@ -223,7 +224,7 @@ function H(e) {
|
|
|
223
224
|
let t = new Date(e), n = t.getDay(), r = t.getDate() - n;
|
|
224
225
|
return t.setDate(r), t;
|
|
225
226
|
}
|
|
226
|
-
function
|
|
227
|
+
function he(e) {
|
|
227
228
|
let t = e.getFullYear(), n = e.getMonth(), r = new Date(t, n, 1), i = new Date(t, n + 1, 0), a = r.getDay(), o = [];
|
|
228
229
|
for (let e = a - 1; e >= 0; e--) {
|
|
229
230
|
let t = new Date(r.getTime());
|
|
@@ -237,11 +238,11 @@ function me(e) {
|
|
|
237
238
|
}
|
|
238
239
|
return o;
|
|
239
240
|
}
|
|
240
|
-
function
|
|
241
|
+
function U(e, t) {
|
|
241
242
|
return e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth() && e.getDate() === t.getDate();
|
|
242
243
|
}
|
|
243
244
|
function ge({ date: t, events: n, locale: r = "default", onEventClick: i, onDateClick: a, onEventDrop: o }) {
|
|
244
|
-
let s = e.useMemo(() =>
|
|
245
|
+
let s = e.useMemo(() => he(t), [t.getFullYear(), t.getMonth()]), c = e.useMemo(() => /* @__PURE__ */ new Date(), []), { t: l } = V(), u = e.useMemo(() => {
|
|
245
246
|
let e = new Date(2024, 0, 7);
|
|
246
247
|
return Array.from({ length: 7 }, (t, n) => {
|
|
247
248
|
let i = new Date(e);
|
|
@@ -327,7 +328,7 @@ function ge({ date: t, events: n, locale: r = "default", onEventClick: i, onDate
|
|
|
327
328
|
"aria-label": "Calendar grid",
|
|
328
329
|
className: "grid grid-cols-7 flex-1 auto-rows-fr",
|
|
329
330
|
children: s.map((e, n) => {
|
|
330
|
-
let r = `${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`, s = h.get(r) || [], u = e.getMonth() === t.getMonth(), f =
|
|
331
|
+
let r = `${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`, s = h.get(r) || [], u = e.getMonth() === t.getMonth(), f = U(e, c);
|
|
331
332
|
return /* @__PURE__ */ R("div", {
|
|
332
333
|
role: "gridcell",
|
|
333
334
|
"aria-label": `${e.toLocaleDateString("default", {
|
|
@@ -336,13 +337,13 @@ function ge({ date: t, events: n, locale: r = "default", onEventClick: i, onDate
|
|
|
336
337
|
day: "numeric",
|
|
337
338
|
year: "numeric"
|
|
338
339
|
})}${s.length > 0 ? `, ${s.length} event${s.length > 1 ? "s" : ""}` : ""}`,
|
|
339
|
-
className:
|
|
340
|
+
className: F("border-b border-r last:border-r-0 p-2 min-h-[100px] cursor-pointer hover:bg-accent/50", !u && "bg-muted/50 text-muted-foreground opacity-50", p === n && "ring-2 ring-primary"),
|
|
340
341
|
onClick: () => a?.(e),
|
|
341
342
|
onDragOver: (e) => v(e, n),
|
|
342
343
|
onDragLeave: y,
|
|
343
344
|
onDrop: (t) => b(t, e),
|
|
344
345
|
children: [/* @__PURE__ */ L("div", {
|
|
345
|
-
className:
|
|
346
|
+
className: F("text-sm font-medium mb-2", f && "inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-6 w-6"),
|
|
346
347
|
...f ? { "aria-current": "date" } : {},
|
|
347
348
|
children: e.getDate()
|
|
348
349
|
}), /* @__PURE__ */ R("div", {
|
|
@@ -356,7 +357,7 @@ function ge({ date: t, events: n, locale: r = "default", onEventClick: i, onDate
|
|
|
356
357
|
draggable: !!o,
|
|
357
358
|
onDragStart: (n) => g(n, t, "move", e),
|
|
358
359
|
onDragEnd: _,
|
|
359
|
-
className:
|
|
360
|
+
className: F("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", l, d === t.id && "opacity-50"),
|
|
360
361
|
style: u ? { backgroundColor: u } : void 0,
|
|
361
362
|
onClick: (e) => {
|
|
362
363
|
e.stopPropagation(), i?.(t);
|
|
@@ -382,24 +383,24 @@ function ge({ date: t, events: n, locale: r = "default", onEventClick: i, onDate
|
|
|
382
383
|
})]
|
|
383
384
|
});
|
|
384
385
|
}
|
|
385
|
-
var
|
|
386
|
-
function
|
|
386
|
+
var W = 48;
|
|
387
|
+
function G(e) {
|
|
387
388
|
let t = new Date(e);
|
|
388
389
|
return t.setHours(0, 0, 0, 0), t;
|
|
389
390
|
}
|
|
390
|
-
function
|
|
391
|
+
function K(e) {
|
|
391
392
|
return e.getHours() * 60 + e.getMinutes();
|
|
392
393
|
}
|
|
393
|
-
function
|
|
394
|
+
function q(e) {
|
|
394
395
|
return `${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`;
|
|
395
396
|
}
|
|
396
|
-
function
|
|
397
|
-
let { t: l } = V(), u =
|
|
398
|
-
if (t === "day") return [
|
|
397
|
+
function J({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a = 30, onEventClick: o, onEventDrop: s, onTimeRangeSelect: c }) {
|
|
398
|
+
let { t: l } = V(), u = W * a / 60, d = 1152, f = e.useMemo(() => {
|
|
399
|
+
if (t === "day") return [G(n)];
|
|
399
400
|
let e = H(n);
|
|
400
401
|
return Array.from({ length: 7 }, (t, n) => {
|
|
401
402
|
let r = new Date(e);
|
|
402
|
-
return r.setDate(e.getDate() + n),
|
|
403
|
+
return r.setDate(e.getDate() + n), G(r);
|
|
403
404
|
});
|
|
404
405
|
}, [
|
|
405
406
|
t,
|
|
@@ -409,7 +410,7 @@ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
409
410
|
]), p = e.useMemo(() => /* @__PURE__ */ new Date(), []), m = e.useCallback((e) => {
|
|
410
411
|
if (e.allDay) return !0;
|
|
411
412
|
let t = new Date(e.start), n = e.end ? new Date(e.end) : new Date(t), r = t.getHours() === 0 && t.getMinutes() === 0 && t.getSeconds() === 0, i = n.getHours() === 0 && n.getMinutes() === 0 && n.getSeconds() === 0, a = n.getTime() - t.getTime();
|
|
412
|
-
return !!(r && i || a >=
|
|
413
|
+
return !!(r && i || a >= 864e5);
|
|
413
414
|
}, []), { allDayEvents: h, timedEvents: g } = e.useMemo(() => {
|
|
414
415
|
let e = [], t = [];
|
|
415
416
|
for (let n of r) m(n) ? e.push(n) : t.push(n);
|
|
@@ -419,13 +420,13 @@ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
419
420
|
};
|
|
420
421
|
}, [r, m]), _ = e.useMemo(() => {
|
|
421
422
|
let e = /* @__PURE__ */ new Map();
|
|
422
|
-
for (let t of f) e.set(
|
|
423
|
+
for (let t of f) e.set(q(t), []);
|
|
423
424
|
for (let t of h) {
|
|
424
|
-
let n =
|
|
425
|
+
let n = G(new Date(t.start)), r = t.end ? new Date(t.end) : new Date(t.start), i = G(r);
|
|
425
426
|
r.getHours() === 0 && r.getMinutes() === 0 && r.getSeconds() === 0 && r.getTime() > n.getTime() && (i = new Date(i), i.setDate(i.getDate() - 1));
|
|
426
427
|
for (let r of f) {
|
|
427
|
-
let a =
|
|
428
|
-
a < n || a > i || e.get(
|
|
428
|
+
let a = G(r);
|
|
429
|
+
a < n || a > i || e.get(q(r)).push({
|
|
429
430
|
event: t,
|
|
430
431
|
isStart: a.getTime() === n.getTime(),
|
|
431
432
|
isEnd: a.getTime() === i.getTime()
|
|
@@ -435,14 +436,14 @@ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
435
436
|
return e;
|
|
436
437
|
}, [f, h]), v = e.useMemo(() => {
|
|
437
438
|
let e = /* @__PURE__ */ new Map();
|
|
438
|
-
for (let t of f) e.set(
|
|
439
|
+
for (let t of f) e.set(q(t), []);
|
|
439
440
|
for (let t of g) {
|
|
440
|
-
let n = new Date(t.start), r = t.end ? new Date(t.end) : new Date(n.getTime() +
|
|
441
|
+
let n = new Date(t.start), r = t.end ? new Date(t.end) : new Date(n.getTime() + 36e5);
|
|
441
442
|
for (let i of f) {
|
|
442
|
-
let a =
|
|
443
|
+
let a = G(i), o = new Date(a);
|
|
443
444
|
if (o.setDate(o.getDate() + 1), r <= a || n >= o) continue;
|
|
444
|
-
let s = n < a ? a : n, c = r > o ? o : r, l =
|
|
445
|
-
e.get(
|
|
445
|
+
let s = n < a ? a : n, c = r > o ? o : r, l = K(s), u = c.getTime() === o.getTime() ? 1440 : K(c);
|
|
446
|
+
e.get(q(i)).push({
|
|
446
447
|
event: t,
|
|
447
448
|
startMin: l,
|
|
448
449
|
endMin: Math.max(u, l + 15),
|
|
@@ -485,7 +486,7 @@ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
485
486
|
let T = e.useRef(!1), E = e.useCallback((e, t) => {
|
|
486
487
|
let n = x.current[t];
|
|
487
488
|
if (!n) return 0;
|
|
488
|
-
let r = (e - n.getBoundingClientRect().top + n.scrollTop) /
|
|
489
|
+
let r = (e - n.getBoundingClientRect().top + n.scrollTop) / W * 60, i = Math.round(r / a) * a;
|
|
489
490
|
return Math.max(0, Math.min(1440, i));
|
|
490
491
|
}, [a]), D = e.useCallback((e) => {
|
|
491
492
|
for (let t = 0; t < x.current.length; t++) {
|
|
@@ -572,7 +573,7 @@ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
572
573
|
weekday: e.toLocaleDateString(i, { weekday: "short" }),
|
|
573
574
|
day: e.getDate(),
|
|
574
575
|
month: e.toLocaleDateString(i, { month: "short" }),
|
|
575
|
-
isToday:
|
|
576
|
+
isToday: U(e, p)
|
|
576
577
|
})), [
|
|
577
578
|
f,
|
|
578
579
|
i,
|
|
@@ -601,7 +602,7 @@ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
601
602
|
dayIndex: n,
|
|
602
603
|
minutes: i
|
|
603
604
|
});
|
|
604
|
-
},
|
|
605
|
+
}, ne = (e, t) => {
|
|
605
606
|
if (!c || e.button !== 0) return;
|
|
606
607
|
e.preventDefault();
|
|
607
608
|
let n = E(e.clientY, t);
|
|
@@ -611,50 +612,52 @@ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
611
612
|
anchorMinutes: n,
|
|
612
613
|
headMinutes: n
|
|
613
614
|
});
|
|
614
|
-
},
|
|
615
|
+
}, k = (e) => {
|
|
615
616
|
if (!S) return null;
|
|
616
617
|
if (S.kind === "select" && S.dayIndex === e) {
|
|
617
|
-
let t = Math.min(S.anchorMinutes, S.headMinutes), n = Math.max(S.anchorMinutes, S.headMinutes);
|
|
618
|
+
let t = Math.min(S.anchorMinutes, S.headMinutes), n = Math.max(S.anchorMinutes, S.headMinutes), r = t / 60 * W, a = Math.max(u, (n - t) / 60 * W);
|
|
618
619
|
return /* @__PURE__ */ L("div", {
|
|
619
620
|
className: "absolute left-1 right-1 rounded bg-primary/30 border border-primary pointer-events-none z-10",
|
|
620
621
|
style: {
|
|
621
|
-
top:
|
|
622
|
-
height:
|
|
622
|
+
top: r,
|
|
623
|
+
height: a
|
|
623
624
|
},
|
|
624
625
|
"aria-hidden": !0,
|
|
625
626
|
children: /* @__PURE__ */ L("div", {
|
|
626
627
|
className: "px-2 py-0.5 text-xs font-medium text-primary",
|
|
627
|
-
children:
|
|
628
|
+
children: Y(f[e], t, n, i)
|
|
628
629
|
})
|
|
629
630
|
});
|
|
630
631
|
}
|
|
631
632
|
if (S.kind === "move" && S.dayIndex === e) {
|
|
632
|
-
let t = S.minutes - S.grabMinuteOffset, n = Math.max(0, Math.min(1440 - S.durationMin, Math.round(t / a) * a));
|
|
633
|
+
let t = S.minutes - S.grabMinuteOffset, n = Math.max(0, Math.min(1440 - S.durationMin, Math.round(t / a) * a)), r = n / 60 * W, o = S.durationMin / 60 * W;
|
|
633
634
|
return /* @__PURE__ */ L("div", {
|
|
634
635
|
className: "absolute left-1 right-1 rounded border-2 border-dashed border-primary bg-primary/10 pointer-events-none z-10",
|
|
635
636
|
style: {
|
|
636
|
-
top:
|
|
637
|
-
height:
|
|
637
|
+
top: r,
|
|
638
|
+
height: o
|
|
638
639
|
},
|
|
639
640
|
"aria-hidden": !0,
|
|
640
641
|
children: /* @__PURE__ */ L("div", {
|
|
641
642
|
className: "px-2 py-0.5 text-xs font-medium text-primary",
|
|
642
|
-
children:
|
|
643
|
+
children: Y(f[e], n, n + S.durationMin, i)
|
|
643
644
|
})
|
|
644
645
|
});
|
|
645
646
|
}
|
|
646
647
|
if ((S.kind === "resize-top" || S.kind === "resize-bottom") && S.dayIndex === e) {
|
|
647
648
|
let t, n;
|
|
648
|
-
|
|
649
|
+
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)));
|
|
650
|
+
let r = t / 60 * W, o = (n - t) / 60 * W;
|
|
651
|
+
return /* @__PURE__ */ L("div", {
|
|
649
652
|
className: "absolute left-1 right-1 rounded border-2 border-dashed border-primary bg-primary/10 pointer-events-none z-10",
|
|
650
653
|
style: {
|
|
651
|
-
top:
|
|
652
|
-
height:
|
|
654
|
+
top: r,
|
|
655
|
+
height: o
|
|
653
656
|
},
|
|
654
657
|
"aria-hidden": !0,
|
|
655
658
|
children: /* @__PURE__ */ L("div", {
|
|
656
659
|
className: "px-2 py-0.5 text-xs font-medium text-primary",
|
|
657
|
-
children:
|
|
660
|
+
children: Y(f[e], t, n, i)
|
|
658
661
|
})
|
|
659
662
|
});
|
|
660
663
|
}
|
|
@@ -671,12 +674,12 @@ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
671
674
|
"aria-hidden": !0
|
|
672
675
|
}), ee.map((e, t) => /* @__PURE__ */ R("div", {
|
|
673
676
|
role: "columnheader",
|
|
674
|
-
className:
|
|
677
|
+
className: F("flex-1 p-2 text-center text-sm border-r last:border-r-0", e.isToday && "bg-primary/5"),
|
|
675
678
|
children: [/* @__PURE__ */ L("div", {
|
|
676
679
|
className: "text-xs text-muted-foreground",
|
|
677
680
|
children: e.weekday
|
|
678
681
|
}), /* @__PURE__ */ L("div", {
|
|
679
|
-
className:
|
|
682
|
+
className: F("font-medium", e.isToday && "inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-6 w-6 mx-auto"),
|
|
680
683
|
children: e.day
|
|
681
684
|
})]
|
|
682
685
|
}, t))]
|
|
@@ -687,10 +690,10 @@ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
687
690
|
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",
|
|
688
691
|
children: l("calendar.allDay") === "calendar.allDay" ? "all-day" : l("calendar.allDay")
|
|
689
692
|
}), f.map((e) => {
|
|
690
|
-
let t =
|
|
693
|
+
let t = q(e), n = _.get(t) ?? [];
|
|
691
694
|
return /* @__PURE__ */ L("div", {
|
|
692
695
|
className: "flex-1 border-r last:border-r-0 min-h-[28px] p-0.5 space-y-0.5",
|
|
693
|
-
children:
|
|
696
|
+
children: n.map(({ event: e, isStart: t, isEnd: n }, r) => {
|
|
694
697
|
let { className: i, inlineColor: a } = B(e.color);
|
|
695
698
|
return /* @__PURE__ */ L("div", {
|
|
696
699
|
role: "button",
|
|
@@ -698,7 +701,7 @@ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
698
701
|
onClick: (t) => {
|
|
699
702
|
t.stopPropagation(), o?.(e);
|
|
700
703
|
},
|
|
701
|
-
className:
|
|
704
|
+
className: F("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),
|
|
702
705
|
style: a ? { backgroundColor: a } : void 0,
|
|
703
706
|
children: t ? e.title : "\xA0"
|
|
704
707
|
}, `${e.id}-${r}`);
|
|
@@ -715,18 +718,18 @@ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
715
718
|
className: "w-14 shrink-0 border-r relative",
|
|
716
719
|
children: te.map((e, t) => /* @__PURE__ */ L("div", {
|
|
717
720
|
className: "absolute right-1 text-[10px] text-muted-foreground -translate-y-1/2",
|
|
718
|
-
style: { top: t *
|
|
721
|
+
style: { top: t * W },
|
|
719
722
|
children: t === 0 ? "" : e
|
|
720
723
|
}, t))
|
|
721
724
|
}), f.map((e, t) => {
|
|
722
|
-
let n =
|
|
725
|
+
let n = q(e), r = y.get(n) ?? [];
|
|
723
726
|
return /* @__PURE__ */ R("div", {
|
|
724
727
|
ref: (e) => {
|
|
725
728
|
x.current[t] = e;
|
|
726
729
|
},
|
|
727
730
|
className: "flex-1 border-r last:border-r-0 relative select-none",
|
|
728
731
|
style: { height: d },
|
|
729
|
-
onPointerDown: (e) =>
|
|
732
|
+
onPointerDown: (e) => ne(e, t),
|
|
730
733
|
"aria-label": e.toLocaleDateString(i, {
|
|
731
734
|
weekday: "long",
|
|
732
735
|
month: "long",
|
|
@@ -736,17 +739,17 @@ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
736
739
|
children: [
|
|
737
740
|
Array.from({ length: 24 }, (e, t) => /* @__PURE__ */ L("div", {
|
|
738
741
|
className: "absolute left-0 right-0 border-t border-muted/60 pointer-events-none",
|
|
739
|
-
style: { top: t *
|
|
742
|
+
style: { top: t * W }
|
|
740
743
|
}, t)),
|
|
741
744
|
a < 60 && Array.from({ length: Math.floor(1440 / a) }, (e, t) => {
|
|
742
745
|
let n = t * a;
|
|
743
746
|
return n % 60 == 0 ? null : /* @__PURE__ */ L("div", {
|
|
744
747
|
className: "absolute left-0 right-0 border-t border-dashed border-muted/30 pointer-events-none",
|
|
745
|
-
style: { top: n / 60 *
|
|
748
|
+
style: { top: n / 60 * W }
|
|
746
749
|
}, t);
|
|
747
750
|
}),
|
|
748
751
|
r.map((n) => {
|
|
749
|
-
let r = n.startMin / 60 *
|
|
752
|
+
let r = n.startMin / 60 * W, a = Math.max(u, (n.endMin - n.startMin) / 60 * W), c = 100 / n.cols, l = n.col * c, { className: d, inlineColor: f } = B(n.event.color), p = S && S.eventId === n.event.id;
|
|
750
753
|
return /* @__PURE__ */ R("div", {
|
|
751
754
|
role: "button",
|
|
752
755
|
tabIndex: 0,
|
|
@@ -760,7 +763,7 @@ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
760
763
|
}
|
|
761
764
|
e.stopPropagation(), o?.(n.event);
|
|
762
765
|
},
|
|
763
|
-
className:
|
|
766
|
+
className: F("absolute rounded text-xs px-2 py-1 overflow-hidden shadow-sm", s ? "cursor-move" : "cursor-pointer", d, p && "opacity-40"),
|
|
764
767
|
style: {
|
|
765
768
|
top: r,
|
|
766
769
|
height: a,
|
|
@@ -775,7 +778,7 @@ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
775
778
|
}),
|
|
776
779
|
/* @__PURE__ */ L("div", {
|
|
777
780
|
className: "text-[10px] opacity-80 truncate",
|
|
778
|
-
children:
|
|
781
|
+
children: Y(e, n.startMin, n.endMin, i)
|
|
779
782
|
}),
|
|
780
783
|
s && n.isStart && /* @__PURE__ */ L("div", {
|
|
781
784
|
onPointerDown: (e) => O(e, n, t, "top"),
|
|
@@ -790,7 +793,7 @@ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
790
793
|
]
|
|
791
794
|
}, `${n.event.id}-${n.startMin}`);
|
|
792
795
|
}),
|
|
793
|
-
|
|
796
|
+
k(t)
|
|
794
797
|
]
|
|
795
798
|
}, n);
|
|
796
799
|
})]
|
|
@@ -799,7 +802,7 @@ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
799
802
|
]
|
|
800
803
|
});
|
|
801
804
|
}
|
|
802
|
-
function
|
|
805
|
+
function Y(e, t, n, r) {
|
|
803
806
|
let i = new Date(e);
|
|
804
807
|
i.setHours(0, Math.round(t), 0, 0);
|
|
805
808
|
let a = new Date(e);
|
|
@@ -839,44 +842,44 @@ function ye(e) {
|
|
|
839
842
|
allDayField: e.allDayField
|
|
840
843
|
} : null;
|
|
841
844
|
}
|
|
842
|
-
var
|
|
843
|
-
let
|
|
844
|
-
let e =
|
|
845
|
-
return typeof window < "u" && window.innerWidth < 768 && e ? "month" :
|
|
845
|
+
var be = ({ schema: e, dataSource: t, className: s, data: d, loading: g, onEventClick: _, onRowClick: v, onDateClick: y, onNavigate: b, onViewChange: S, onEventDrop: ne, locale: k }) => {
|
|
846
|
+
let A = h(), j = Array.isArray(d), [M, N] = o(j ? d : []), [re, P] = o(j ? g ?? !1 : !0), [F, I] = o(null), [z, ue] = o(null), [de, fe] = o(/* @__PURE__ */ new Date()), pe = ae(), B = e.defaultView, [V, H] = o(() => {
|
|
847
|
+
let e = B === "day" || !B;
|
|
848
|
+
return typeof window < "u" && window.innerWidth < 768 && e ? "month" : B || "month";
|
|
846
849
|
});
|
|
847
850
|
r(() => {
|
|
848
|
-
|
|
849
|
-
}, [
|
|
850
|
-
let [he,
|
|
851
|
+
pe && V === "day" && (B === "day" || !B) && H("month");
|
|
852
|
+
}, [pe]);
|
|
853
|
+
let [he, U] = o(0);
|
|
851
854
|
r(() => {
|
|
852
855
|
if (!j && !(!t?.onMutation || !e.objectName)) return t.onMutation((t) => {
|
|
853
|
-
t.resource === e.objectName &&
|
|
856
|
+
t.resource === e.objectName && U((e) => e + 1);
|
|
854
857
|
});
|
|
855
858
|
}, [
|
|
856
859
|
t,
|
|
857
860
|
e.objectName,
|
|
858
861
|
j
|
|
859
862
|
]);
|
|
860
|
-
let
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
863
|
+
let ge = n(async () => {
|
|
864
|
+
U((e) => e + 1);
|
|
865
|
+
}, []), { ref: W, isRefreshing: G, pullDistance: K } = se({
|
|
866
|
+
onRefresh: ge,
|
|
864
867
|
enabled: !!t && !!e.objectName
|
|
865
|
-
}),
|
|
868
|
+
}), q = i(() => _e(e), [
|
|
866
869
|
e.data,
|
|
867
870
|
e.staticData,
|
|
868
871
|
e.objectName
|
|
869
|
-
]),
|
|
872
|
+
]), J = i(() => ye(e), [
|
|
870
873
|
e.filter,
|
|
871
874
|
e.calendar,
|
|
872
875
|
e.dateField,
|
|
873
876
|
e.endField,
|
|
874
877
|
e.titleField,
|
|
875
878
|
e.colorField
|
|
876
|
-
]),
|
|
877
|
-
|
|
878
|
-
j && N(
|
|
879
|
-
}, [
|
|
879
|
+
]), Y = q?.provider === "value", be = a(null);
|
|
880
|
+
be.current = z, r(() => {
|
|
881
|
+
j && N(d);
|
|
882
|
+
}, [d, j]), r(() => {
|
|
880
883
|
j && g !== void 0 && P(g);
|
|
881
884
|
}, [g, j]), r(() => {
|
|
882
885
|
if (j) return;
|
|
@@ -884,39 +887,39 @@ var Y = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
884
887
|
return (async () => {
|
|
885
888
|
try {
|
|
886
889
|
if (!n) return;
|
|
887
|
-
if (P(!0),
|
|
888
|
-
n && (N(
|
|
890
|
+
if (P(!0), Y && q?.provider === "value") {
|
|
891
|
+
n && (N(q.items), P(!1));
|
|
889
892
|
return;
|
|
890
893
|
}
|
|
891
894
|
if (!t || typeof t.find != "function") throw Error("DataSource required for object/api providers");
|
|
892
|
-
if (
|
|
893
|
-
let r =
|
|
895
|
+
if (q?.provider === "object") {
|
|
896
|
+
let r = q.object, i = c(be.current?.fields), a = await t.find(r, {
|
|
894
897
|
$filter: e.filter,
|
|
895
898
|
$orderby: ve(e.sort),
|
|
896
899
|
...i.length > 0 ? { $expand: i } : {}
|
|
897
|
-
}));
|
|
898
|
-
n && N(
|
|
899
|
-
} else
|
|
900
|
+
}), o = l(a);
|
|
901
|
+
n && N(o);
|
|
902
|
+
} else q?.provider === "api" && (console.warn("API provider not yet implemented for ObjectCalendar"), n && N([]));
|
|
900
903
|
n && P(!1);
|
|
901
904
|
} catch (e) {
|
|
902
|
-
console.error("[ObjectCalendar] Error fetching data:", e), n && (
|
|
905
|
+
console.error("[ObjectCalendar] Error fetching data:", e), n && (I(e), P(!1));
|
|
903
906
|
}
|
|
904
907
|
})(), () => {
|
|
905
908
|
n = !1;
|
|
906
909
|
};
|
|
907
910
|
}, [
|
|
908
911
|
j,
|
|
909
|
-
|
|
912
|
+
q,
|
|
910
913
|
t,
|
|
911
|
-
|
|
914
|
+
Y,
|
|
912
915
|
e.filter,
|
|
913
916
|
e.sort,
|
|
914
917
|
he
|
|
915
918
|
]), r(() => {
|
|
916
|
-
!
|
|
919
|
+
!Y && t && (async () => {
|
|
917
920
|
try {
|
|
918
921
|
if (!t) return;
|
|
919
|
-
let n =
|
|
922
|
+
let n = q?.provider === "object" ? q.object : e.objectName;
|
|
920
923
|
if (!n) return;
|
|
921
924
|
let r = await t.getObjectSchema(n);
|
|
922
925
|
ue(r);
|
|
@@ -927,12 +930,12 @@ var Y = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
927
930
|
}, [
|
|
928
931
|
e.objectName,
|
|
929
932
|
t,
|
|
930
|
-
|
|
931
|
-
|
|
933
|
+
Y,
|
|
934
|
+
q
|
|
932
935
|
]);
|
|
933
|
-
let
|
|
934
|
-
if (!
|
|
935
|
-
let { startDateField: e, endDateField: t, titleField: n, colorField: r } =
|
|
936
|
+
let xe = i(() => {
|
|
937
|
+
if (!J || !M.length) return [];
|
|
938
|
+
let { startDateField: e, endDateField: t, titleField: n, colorField: r } = J, i = (e) => {
|
|
936
939
|
if (n) {
|
|
937
940
|
let t = e[n], r = typeof t == "string" ? t.trim() : t;
|
|
938
941
|
if (r) return String(r);
|
|
@@ -953,7 +956,7 @@ var Y = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
953
956
|
}).filter((e) => !isNaN(e.start.getTime()));
|
|
954
957
|
}, [
|
|
955
958
|
M,
|
|
956
|
-
|
|
959
|
+
J,
|
|
957
960
|
z
|
|
958
961
|
]);
|
|
959
962
|
n(() => {
|
|
@@ -962,13 +965,13 @@ var Y = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
962
965
|
let X = e.navigation ?? {
|
|
963
966
|
mode: "drawer",
|
|
964
967
|
width: "min(960px, 60vw)"
|
|
965
|
-
},
|
|
968
|
+
}, Se = X.mode === "drawer" || X.mode === "modal" || X.mode === "split" || X.mode === "popover", Z = m({
|
|
966
969
|
navigation: X,
|
|
967
970
|
objectName: e.objectName,
|
|
968
|
-
onRowClick:
|
|
969
|
-
}),
|
|
970
|
-
if (!
|
|
971
|
-
let { startDateField: a, endDateField: o } =
|
|
971
|
+
onRowClick: Se ? void 0 : v
|
|
972
|
+
}), Ce = n(async (n, r, i) => {
|
|
973
|
+
if (!J) return;
|
|
974
|
+
let { startDateField: a, endDateField: o } = J, s = n?.id ?? n?._id;
|
|
972
975
|
if (!s || !e.objectName || !t?.update) return;
|
|
973
976
|
let c = { [a]: r.toISOString() };
|
|
974
977
|
o && i && (c[o] = i.toISOString());
|
|
@@ -980,37 +983,37 @@ var Y = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
980
983
|
try {
|
|
981
984
|
await t.update(e.objectName, s, c);
|
|
982
985
|
} catch (e) {
|
|
983
|
-
N(l), console.error("[ObjectCalendar] Failed to persist drag-and-drop reschedule:", e), ie.error(
|
|
986
|
+
N(l), console.error("[ObjectCalendar] Failed to persist drag-and-drop reschedule:", e), ie.error(p(e) ? A("errors.unauthorized", "You are not authorized to perform this action.") : f(e) ?? A("table.saveFailed", "Save failed"));
|
|
984
987
|
}
|
|
985
988
|
}, [
|
|
986
|
-
|
|
989
|
+
J,
|
|
987
990
|
e.objectName,
|
|
988
991
|
t,
|
|
989
992
|
M,
|
|
990
|
-
|
|
991
|
-
]), [Q, $] = o(null),
|
|
992
|
-
!
|
|
993
|
+
A
|
|
994
|
+
]), [Q, $] = o(null), we = n((n) => {
|
|
995
|
+
!J || !e.objectName || !t?.create || $({
|
|
993
996
|
start: n,
|
|
994
997
|
title: "",
|
|
995
998
|
submitting: !1
|
|
996
999
|
});
|
|
997
1000
|
}, [
|
|
998
|
-
|
|
1001
|
+
J,
|
|
999
1002
|
e.objectName,
|
|
1000
1003
|
t
|
|
1001
|
-
]),
|
|
1002
|
-
!
|
|
1004
|
+
]), Te = n((n, r) => {
|
|
1005
|
+
!J || !e.objectName || !t?.create || $({
|
|
1003
1006
|
start: n,
|
|
1004
1007
|
end: r,
|
|
1005
1008
|
title: "",
|
|
1006
1009
|
submitting: !1
|
|
1007
1010
|
});
|
|
1008
1011
|
}, [
|
|
1009
|
-
|
|
1012
|
+
J,
|
|
1010
1013
|
e.objectName,
|
|
1011
1014
|
t
|
|
1012
|
-
]),
|
|
1013
|
-
if (!Q || !
|
|
1015
|
+
]), Ee = n(async () => {
|
|
1016
|
+
if (!Q || !J) return;
|
|
1014
1017
|
let n = Q.title.trim();
|
|
1015
1018
|
if (!n) {
|
|
1016
1019
|
$((e) => e && {
|
|
@@ -1025,7 +1028,7 @@ var Y = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
1025
1028
|
submitting: !0,
|
|
1026
1029
|
error: void 0
|
|
1027
1030
|
});
|
|
1028
|
-
let { startDateField: r, endDateField: i, titleField: a } =
|
|
1031
|
+
let { startDateField: r, endDateField: i, titleField: a } = J, o = {
|
|
1029
1032
|
[a || "name"]: n,
|
|
1030
1033
|
[r]: Q.start.toISOString()
|
|
1031
1034
|
};
|
|
@@ -1059,7 +1062,7 @@ var Y = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
1059
1062
|
}
|
|
1060
1063
|
}, [
|
|
1061
1064
|
Q,
|
|
1062
|
-
|
|
1065
|
+
J,
|
|
1063
1066
|
e.objectName,
|
|
1064
1067
|
t,
|
|
1065
1068
|
z
|
|
@@ -1082,61 +1085,61 @@ var Y = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
1082
1085
|
children: ["Error: ", F.message]
|
|
1083
1086
|
})
|
|
1084
1087
|
})
|
|
1085
|
-
}) :
|
|
1086
|
-
ref:
|
|
1088
|
+
}) : J ? /* @__PURE__ */ R("div", {
|
|
1089
|
+
ref: W,
|
|
1087
1090
|
className: s,
|
|
1088
1091
|
children: [
|
|
1089
|
-
|
|
1092
|
+
K > 0 && /* @__PURE__ */ L("div", {
|
|
1090
1093
|
className: "flex items-center justify-center text-xs text-muted-foreground",
|
|
1091
|
-
style: { height:
|
|
1092
|
-
children:
|
|
1094
|
+
style: { height: K },
|
|
1095
|
+
children: G ? "Refreshing…" : "Pull to refresh"
|
|
1093
1096
|
}),
|
|
1094
1097
|
/* @__PURE__ */ L("div", {
|
|
1095
1098
|
className: "bg-background h-[calc(100vh-120px)] sm:h-[calc(100vh-160px)] md:h-[calc(100vh-200px)] min-h-[400px] sm:min-h-[600px]",
|
|
1096
|
-
children: /* @__PURE__ */ L(
|
|
1097
|
-
events:
|
|
1099
|
+
children: /* @__PURE__ */ L(me, {
|
|
1100
|
+
events: xe,
|
|
1098
1101
|
currentDate: de,
|
|
1099
|
-
view:
|
|
1100
|
-
locale:
|
|
1102
|
+
view: V,
|
|
1103
|
+
locale: k,
|
|
1101
1104
|
onEventClick: (e) => {
|
|
1102
|
-
Z.handleClick(e.data),
|
|
1105
|
+
Z.handleClick(e.data), Se || _?.(e.data);
|
|
1103
1106
|
},
|
|
1104
1107
|
onDateClick: (e) => {
|
|
1105
|
-
y ? y(e) :
|
|
1108
|
+
y ? y(e) : we(e);
|
|
1106
1109
|
},
|
|
1107
1110
|
onNavigate: (e) => {
|
|
1108
|
-
fe(e),
|
|
1111
|
+
fe(e), b?.(e);
|
|
1109
1112
|
},
|
|
1110
1113
|
onViewChange: (e) => {
|
|
1111
|
-
|
|
1114
|
+
H(e), S?.(e);
|
|
1112
1115
|
},
|
|
1113
1116
|
onAddClick: void 0,
|
|
1114
1117
|
onEventDrop: (e, t, n) => {
|
|
1115
|
-
|
|
1118
|
+
ne ? ne(e.data, t, n) : Ce(e.data, t, n);
|
|
1116
1119
|
},
|
|
1117
|
-
onTimeRangeSelect:
|
|
1120
|
+
onTimeRangeSelect: Te
|
|
1118
1121
|
})
|
|
1119
1122
|
}),
|
|
1120
|
-
/* @__PURE__ */ L(
|
|
1123
|
+
/* @__PURE__ */ L(C, {
|
|
1121
1124
|
open: !!Q,
|
|
1122
1125
|
onOpenChange: (e) => {
|
|
1123
1126
|
e || $(null);
|
|
1124
1127
|
},
|
|
1125
|
-
children: /* @__PURE__ */ R(
|
|
1128
|
+
children: /* @__PURE__ */ R(w, {
|
|
1126
1129
|
className: "sm:max-w-md",
|
|
1127
1130
|
children: [
|
|
1128
|
-
/* @__PURE__ */ R(
|
|
1129
|
-
let e = Q.end && Q.end.getTime() !== Q.start.getTime(), t = Q.start.toLocaleDateString(
|
|
1131
|
+
/* @__PURE__ */ R(D, { children: [/* @__PURE__ */ L(ee, { children: "New event" }), /* @__PURE__ */ L(T, { children: Q && (() => {
|
|
1132
|
+
let e = Q.end && Q.end.getTime() !== Q.start.getTime(), t = Q.start.toLocaleDateString(k, {
|
|
1130
1133
|
year: "numeric",
|
|
1131
1134
|
month: "long",
|
|
1132
1135
|
day: "numeric"
|
|
1133
1136
|
});
|
|
1134
1137
|
if (e) {
|
|
1135
|
-
let e = (e) => e.toLocaleTimeString(
|
|
1138
|
+
let e = (e) => e.toLocaleTimeString(k, {
|
|
1136
1139
|
hour: "numeric",
|
|
1137
1140
|
minute: "2-digit"
|
|
1138
1141
|
});
|
|
1139
|
-
return /* @__PURE__ */ R(
|
|
1142
|
+
return /* @__PURE__ */ R(oe, { children: [
|
|
1140
1143
|
t,
|
|
1141
1144
|
" · ",
|
|
1142
1145
|
e(Q.start),
|
|
@@ -1144,16 +1147,16 @@ var Y = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
1144
1147
|
e(Q.end)
|
|
1145
1148
|
] });
|
|
1146
1149
|
}
|
|
1147
|
-
return /* @__PURE__ */ R(
|
|
1150
|
+
return /* @__PURE__ */ R(oe, { children: ["On ", t] });
|
|
1148
1151
|
})() })] }),
|
|
1149
1152
|
/* @__PURE__ */ R("div", {
|
|
1150
1153
|
className: "space-y-2",
|
|
1151
1154
|
children: [
|
|
1152
|
-
/* @__PURE__ */ L(
|
|
1155
|
+
/* @__PURE__ */ L(O, {
|
|
1153
1156
|
htmlFor: "quick-create-title",
|
|
1154
1157
|
children: "Title"
|
|
1155
1158
|
}),
|
|
1156
|
-
/* @__PURE__ */ L(
|
|
1159
|
+
/* @__PURE__ */ L(te, {
|
|
1157
1160
|
id: "quick-create-title",
|
|
1158
1161
|
autoFocus: !0,
|
|
1159
1162
|
value: Q?.title ?? "",
|
|
@@ -1163,7 +1166,7 @@ var Y = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
1163
1166
|
error: void 0
|
|
1164
1167
|
}),
|
|
1165
1168
|
onKeyDown: (e) => {
|
|
1166
|
-
e.key === "Enter" && !Q?.submitting && (e.preventDefault(),
|
|
1169
|
+
e.key === "Enter" && !Q?.submitting && (e.preventDefault(), Ee());
|
|
1167
1170
|
},
|
|
1168
1171
|
placeholder: "What's this event about?",
|
|
1169
1172
|
disabled: Q?.submitting
|
|
@@ -1174,13 +1177,13 @@ var Y = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
1174
1177
|
})
|
|
1175
1178
|
]
|
|
1176
1179
|
}),
|
|
1177
|
-
/* @__PURE__ */ R(
|
|
1180
|
+
/* @__PURE__ */ R(E, { children: [/* @__PURE__ */ L(x, {
|
|
1178
1181
|
variant: "outline",
|
|
1179
1182
|
onClick: () => $(null),
|
|
1180
1183
|
disabled: Q?.submitting,
|
|
1181
1184
|
children: "Cancel"
|
|
1182
|
-
}), /* @__PURE__ */ L(
|
|
1183
|
-
onClick: () => void
|
|
1185
|
+
}), /* @__PURE__ */ L(x, {
|
|
1186
|
+
onClick: () => void Ee(),
|
|
1184
1187
|
disabled: Q?.submitting || !Q?.title.trim(),
|
|
1185
1188
|
children: Q?.submitting ? "Creating…" : "Create"
|
|
1186
1189
|
})] })
|
|
@@ -1188,10 +1191,10 @@ var Y = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
1188
1191
|
})
|
|
1189
1192
|
}),
|
|
1190
1193
|
Z.isOverlay && Z.isOpen && Z.selectedRecord && (() => {
|
|
1191
|
-
let n =
|
|
1194
|
+
let n = q?.provider === "object" ? q.object : e.objectName, r = Z.selectedRecord, i = r.id ?? r._id;
|
|
1192
1195
|
if (!n || i == null) return null;
|
|
1193
|
-
let a =
|
|
1194
|
-
return /* @__PURE__ */ L(
|
|
1196
|
+
let a = J?.titleField ? String(r[J.titleField] ?? "Event Details") : "Event Details";
|
|
1197
|
+
return /* @__PURE__ */ L(ce, {
|
|
1195
1198
|
open: !0,
|
|
1196
1199
|
onClose: Z.close,
|
|
1197
1200
|
title: a,
|
|
@@ -1201,7 +1204,7 @@ var Y = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
1201
1204
|
dataSource: t,
|
|
1202
1205
|
objectSchema: z,
|
|
1203
1206
|
width: Z.width ?? "min(960px, 60vw)",
|
|
1204
|
-
fullPageHref:
|
|
1207
|
+
fullPageHref: le(n, i) ?? void 0,
|
|
1205
1208
|
onFieldSave: async (e, r) => {
|
|
1206
1209
|
t?.update && (await t.update(n, String(i), { [e]: r }), N((t) => t.map((t) => String(t.id ?? t._id) === String(i) ? {
|
|
1207
1210
|
...t,
|
|
@@ -1224,12 +1227,55 @@ var Y = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
1224
1227
|
})
|
|
1225
1228
|
})
|
|
1226
1229
|
});
|
|
1227
|
-
}
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1230
|
+
}, xe = [
|
|
1231
|
+
"onEventClick",
|
|
1232
|
+
"onDateClick",
|
|
1233
|
+
"onViewChange",
|
|
1234
|
+
"onNavigate",
|
|
1235
|
+
"onAddClick",
|
|
1236
|
+
"onEventDrop",
|
|
1237
|
+
"onTimeRangeSelect"
|
|
1238
|
+
];
|
|
1239
|
+
function X(e) {
|
|
1240
|
+
let t = {};
|
|
1241
|
+
for (let n of xe) {
|
|
1242
|
+
let r = e[n];
|
|
1243
|
+
typeof r == "function" && (t[n] = r);
|
|
1244
|
+
}
|
|
1245
|
+
return t;
|
|
1246
|
+
}
|
|
1247
|
+
var Se = [
|
|
1248
|
+
"month",
|
|
1249
|
+
"week",
|
|
1250
|
+
"day"
|
|
1251
|
+
];
|
|
1252
|
+
function Z(e) {
|
|
1253
|
+
return Se.includes(e) ? e : void 0;
|
|
1254
|
+
}
|
|
1255
|
+
function Ce(e) {
|
|
1256
|
+
if (typeof e == "string") {
|
|
1257
|
+
try {
|
|
1258
|
+
Intl.getCanonicalLocales(e);
|
|
1259
|
+
} catch {
|
|
1260
|
+
return;
|
|
1261
|
+
}
|
|
1262
|
+
return e;
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
function Q(e) {
|
|
1266
|
+
return typeof e == "number" && Number.isFinite(e) && e > 0 ? e : void 0;
|
|
1267
|
+
}
|
|
1268
|
+
function $(e) {
|
|
1269
|
+
if (e instanceof Date) return e;
|
|
1270
|
+
if (typeof e != "string") return;
|
|
1271
|
+
let t = new Date(e);
|
|
1272
|
+
return Number.isNaN(t.getTime()) ? void 0 : t;
|
|
1273
|
+
}
|
|
1274
|
+
function we(e) {
|
|
1275
|
+
return e === !0;
|
|
1276
|
+
}
|
|
1277
|
+
s.register("calendar-view", ({ schema: e, className: n, onAction: r, events: i, currentDate: a, view: o, allowCreate: s, ...c }) => {
|
|
1278
|
+
let l = t.useMemo(() => !e.data || !Array.isArray(e.data) ? [] : e.data.map((t, n) => {
|
|
1233
1279
|
let r = e.titleField || "title", i = e.startDateField || "start", a = e.endDateField || "end", o = e.colorField || "color", s = e.allDayField || "allDay";
|
|
1234
1280
|
return {
|
|
1235
1281
|
id: t.id || t._id || n,
|
|
@@ -1247,15 +1293,29 @@ s.register("calendar-view", ({ schema: e, className: n, onAction: r, ...i }) =>
|
|
|
1247
1293
|
e.endDateField,
|
|
1248
1294
|
e.colorField,
|
|
1249
1295
|
e.allDayField
|
|
1250
|
-
]),
|
|
1251
|
-
|
|
1252
|
-
r?.({
|
|
1296
|
+
]), u = t.useMemo(() => $(a), [a]), d = Z(o), f = we(s), p = X(c), m = Ce(c.locale), h = Q(c.slotMinutes), g = typeof r == "function" ? r : void 0, _ = (e) => {
|
|
1297
|
+
g?.({
|
|
1253
1298
|
type: "event-click",
|
|
1254
1299
|
payload: e
|
|
1255
1300
|
});
|
|
1256
|
-
},
|
|
1257
|
-
|
|
1258
|
-
|
|
1301
|
+
}, v = () => {
|
|
1302
|
+
g?.({
|
|
1303
|
+
type: "create",
|
|
1304
|
+
payload: {}
|
|
1305
|
+
});
|
|
1306
|
+
};
|
|
1307
|
+
return /* @__PURE__ */ L(me, {
|
|
1308
|
+
className: n,
|
|
1309
|
+
events: l,
|
|
1310
|
+
currentDate: u,
|
|
1311
|
+
view: d,
|
|
1312
|
+
locale: m,
|
|
1313
|
+
slotMinutes: h,
|
|
1314
|
+
...p,
|
|
1315
|
+
onEventClick: p.onEventClick ?? _,
|
|
1316
|
+
onAddClick: p.onAddClick ?? (f ? v : void 0)
|
|
1317
|
+
});
|
|
1318
|
+
}, {
|
|
1259
1319
|
namespace: "plugin-calendar",
|
|
1260
1320
|
label: "Calendar View",
|
|
1261
1321
|
inputs: [
|
|
@@ -1300,12 +1360,6 @@ s.register("calendar-view", ({ schema: e, className: n, onAction: r, ...i }) =>
|
|
|
1300
1360
|
defaultValue: "color",
|
|
1301
1361
|
description: "Field name for event color"
|
|
1302
1362
|
},
|
|
1303
|
-
{
|
|
1304
|
-
name: "colorMapping",
|
|
1305
|
-
type: "object",
|
|
1306
|
-
label: "Color Mapping",
|
|
1307
|
-
description: "Map field values to colors (e.g., {meeting: \"blue\", deadline: \"red\"})"
|
|
1308
|
-
},
|
|
1309
1363
|
{
|
|
1310
1364
|
name: "view",
|
|
1311
1365
|
type: "enum",
|
|
@@ -1375,15 +1429,66 @@ s.register("calendar-view", ({ schema: e, className: n, onAction: r, ...i }) =>
|
|
|
1375
1429
|
});
|
|
1376
1430
|
//#endregion
|
|
1377
1431
|
//#region src/index.tsx
|
|
1378
|
-
var
|
|
1379
|
-
|
|
1380
|
-
|
|
1432
|
+
var Te = {
|
|
1433
|
+
filter: !0,
|
|
1434
|
+
sort: !0
|
|
1435
|
+
}, Ee = [
|
|
1436
|
+
"onEventClick",
|
|
1437
|
+
"onRowClick",
|
|
1438
|
+
"onDateClick",
|
|
1439
|
+
"onEdit",
|
|
1440
|
+
"onDelete",
|
|
1441
|
+
"onNavigate",
|
|
1442
|
+
"onViewChange",
|
|
1443
|
+
"onEventDrop"
|
|
1444
|
+
];
|
|
1445
|
+
function De(e) {
|
|
1446
|
+
let t = {};
|
|
1447
|
+
for (let n of Ee) {
|
|
1448
|
+
let r = e[n];
|
|
1449
|
+
typeof r == "function" && (t[n] = r);
|
|
1450
|
+
}
|
|
1451
|
+
return t;
|
|
1452
|
+
}
|
|
1453
|
+
function Oe(e) {
|
|
1454
|
+
if (typeof e == "string") {
|
|
1455
|
+
try {
|
|
1456
|
+
Intl.getCanonicalLocales(e);
|
|
1457
|
+
} catch {
|
|
1458
|
+
return;
|
|
1459
|
+
}
|
|
1460
|
+
return e;
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
function ke(e) {
|
|
1464
|
+
return Array.isArray(e) ? e : void 0;
|
|
1465
|
+
}
|
|
1466
|
+
function Ae(e) {
|
|
1467
|
+
return typeof e == "boolean" ? e : void 0;
|
|
1468
|
+
}
|
|
1469
|
+
function je(e) {
|
|
1470
|
+
return e && typeof e.find == "function" ? e : void 0;
|
|
1471
|
+
}
|
|
1472
|
+
var Me = ({ schema: e, className: t, ...n }) => {
|
|
1473
|
+
let { dataSource: r } = g() || {}, i = De(n), a = Oe(n.locale), o = ke(n.data), s = Ae(n.loading), c = je(n.dataSource);
|
|
1474
|
+
return /* @__PURE__ */ L(d, {
|
|
1381
1475
|
schema: e,
|
|
1382
|
-
|
|
1383
|
-
|
|
1476
|
+
mapping: Te,
|
|
1477
|
+
dataSource: r,
|
|
1478
|
+
testId: "object-calendar",
|
|
1479
|
+
errorTitle: "This calendar’s data source could not be resolved",
|
|
1480
|
+
children: (e) => /* @__PURE__ */ L(be, {
|
|
1481
|
+
schema: e,
|
|
1482
|
+
dataSource: c ?? r,
|
|
1483
|
+
className: t,
|
|
1484
|
+
data: o,
|
|
1485
|
+
loading: s,
|
|
1486
|
+
locale: a,
|
|
1487
|
+
...i
|
|
1488
|
+
})
|
|
1384
1489
|
});
|
|
1385
1490
|
};
|
|
1386
|
-
s.register("object-calendar",
|
|
1491
|
+
s.register("object-calendar", Me, {
|
|
1387
1492
|
namespace: "plugin-calendar",
|
|
1388
1493
|
label: "Object Calendar",
|
|
1389
1494
|
category: "view",
|
|
@@ -1398,7 +1503,7 @@ s.register("object-calendar", be, {
|
|
|
1398
1503
|
label: "Calendar Config",
|
|
1399
1504
|
description: "startDateField, endDateField, titleField, colorField"
|
|
1400
1505
|
}]
|
|
1401
|
-
}), s.register("calendar",
|
|
1506
|
+
}), s.register("calendar", Me, {
|
|
1402
1507
|
namespace: "view",
|
|
1403
1508
|
label: "Calendar View",
|
|
1404
1509
|
category: "view",
|
|
@@ -1415,4 +1520,4 @@ s.register("object-calendar", be, {
|
|
|
1415
1520
|
}]
|
|
1416
1521
|
});
|
|
1417
1522
|
//#endregion
|
|
1418
|
-
export {
|
|
1523
|
+
export { me as CalendarView, be as ObjectCalendar, Me as ObjectCalendarRenderer };
|