@object-ui/plugin-calendar 17.3.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 +346 -0
- package/README.md +0 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +304 -205
- package/dist/index.umd.cjs +1 -1
- package/package.json +12 -12
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"
|
|
@@ -80,7 +80,7 @@ function pe({ events: t = [], view: n = "month", currentDate: r = z, locale: i =
|
|
|
80
80
|
year: "numeric"
|
|
81
81
|
})}`;
|
|
82
82
|
}
|
|
83
|
-
return
|
|
83
|
+
return g.toLocaleDateString(E, {
|
|
84
84
|
weekday: "long",
|
|
85
85
|
month: "long",
|
|
86
86
|
day: "numeric",
|
|
@@ -90,7 +90,7 @@ function pe({ events: t = [], view: n = "month", currentDate: r = z, locale: i =
|
|
|
90
90
|
return /* @__PURE__ */ R("div", {
|
|
91
91
|
role: "region",
|
|
92
92
|
"aria-label": "Calendar",
|
|
93
|
-
className:
|
|
93
|
+
className: F("flex flex-col h-full bg-background min-w-0 overflow-hidden", p),
|
|
94
94
|
children: [/* @__PURE__ */ R("div", {
|
|
95
95
|
className: "flex flex-wrap items-center justify-between gap-2 p-2 sm:p-4 border-b min-w-0",
|
|
96
96
|
children: [/* @__PURE__ */ R("div", {
|
|
@@ -98,46 +98,46 @@ function pe({ events: t = [], view: n = "month", currentDate: r = z, locale: i =
|
|
|
98
98
|
children: [/* @__PURE__ */ R("div", {
|
|
99
99
|
className: "flex items-center bg-muted/50 rounded-lg p-1 gap-1",
|
|
100
100
|
children: [
|
|
101
|
-
/* @__PURE__ */ L(
|
|
101
|
+
/* @__PURE__ */ L(x, {
|
|
102
102
|
variant: "ghost",
|
|
103
103
|
size: "sm",
|
|
104
|
-
onClick:
|
|
104
|
+
onClick: O,
|
|
105
105
|
className: "h-8",
|
|
106
106
|
"aria-label": "Go to today",
|
|
107
107
|
children: w("calendar.today")
|
|
108
108
|
}),
|
|
109
109
|
/* @__PURE__ */ L("div", { className: "h-4 w-px bg-border mx-1" }),
|
|
110
|
-
/* @__PURE__ */ L(
|
|
110
|
+
/* @__PURE__ */ L(x, {
|
|
111
111
|
variant: "ghost",
|
|
112
112
|
size: "icon",
|
|
113
113
|
"aria-label": "Previous period",
|
|
114
114
|
onClick: ee,
|
|
115
115
|
className: "h-8 w-8",
|
|
116
|
-
children: /* @__PURE__ */ L(
|
|
116
|
+
children: /* @__PURE__ */ L(v, { className: "h-4 w-4" })
|
|
117
117
|
}),
|
|
118
|
-
/* @__PURE__ */ L(
|
|
118
|
+
/* @__PURE__ */ L(x, {
|
|
119
119
|
variant: "ghost",
|
|
120
120
|
size: "icon",
|
|
121
121
|
"aria-label": "Next period",
|
|
122
122
|
onClick: te,
|
|
123
123
|
className: "h-8 w-8",
|
|
124
|
-
children: /* @__PURE__ */ L(
|
|
124
|
+
children: /* @__PURE__ */ L(y, { className: "h-4 w-4" })
|
|
125
125
|
})
|
|
126
126
|
]
|
|
127
|
-
}), /* @__PURE__ */ R(
|
|
127
|
+
}), /* @__PURE__ */ R(ne, { children: [/* @__PURE__ */ L(A, {
|
|
128
128
|
asChild: !0,
|
|
129
|
-
children: /* @__PURE__ */ R(
|
|
129
|
+
children: /* @__PURE__ */ R(x, {
|
|
130
130
|
variant: "ghost",
|
|
131
|
-
"aria-label": `Current date: ${
|
|
132
|
-
className:
|
|
133
|
-
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() })]
|
|
134
134
|
})
|
|
135
135
|
}), /* @__PURE__ */ L(k, {
|
|
136
136
|
className: "w-auto p-0",
|
|
137
137
|
align: "start",
|
|
138
|
-
children: /* @__PURE__ */ L(
|
|
138
|
+
children: /* @__PURE__ */ L(S, {
|
|
139
139
|
mode: "single",
|
|
140
|
-
selected:
|
|
140
|
+
selected: g,
|
|
141
141
|
onSelect: (e) => {
|
|
142
142
|
e && (C(e), c?.(e));
|
|
143
143
|
},
|
|
@@ -148,31 +148,31 @@ function pe({ events: t = [], view: n = "month", currentDate: r = z, locale: i =
|
|
|
148
148
|
})] })]
|
|
149
149
|
}), /* @__PURE__ */ R("div", {
|
|
150
150
|
className: "flex items-center gap-2",
|
|
151
|
-
children: [/* @__PURE__ */ R(
|
|
151
|
+
children: [/* @__PURE__ */ R(j, {
|
|
152
152
|
value: m,
|
|
153
|
-
onValueChange:
|
|
154
|
-
children: [/* @__PURE__ */ L(
|
|
153
|
+
onValueChange: ie,
|
|
154
|
+
children: [/* @__PURE__ */ L(re, {
|
|
155
155
|
className: "w-32 bg-background",
|
|
156
|
-
children: /* @__PURE__ */ L(
|
|
157
|
-
}), /* @__PURE__ */ R(
|
|
158
|
-
/* @__PURE__ */ L(
|
|
156
|
+
children: /* @__PURE__ */ L(P, {})
|
|
157
|
+
}), /* @__PURE__ */ R(M, { children: [
|
|
158
|
+
/* @__PURE__ */ L(N, {
|
|
159
159
|
value: "day",
|
|
160
160
|
children: w("calendar.day")
|
|
161
161
|
}),
|
|
162
|
-
/* @__PURE__ */ L(
|
|
162
|
+
/* @__PURE__ */ L(N, {
|
|
163
163
|
value: "week",
|
|
164
164
|
children: w("calendar.week")
|
|
165
165
|
}),
|
|
166
|
-
/* @__PURE__ */ L(
|
|
166
|
+
/* @__PURE__ */ L(N, {
|
|
167
167
|
value: "month",
|
|
168
168
|
children: w("calendar.month")
|
|
169
169
|
})
|
|
170
170
|
] })]
|
|
171
|
-
}), l && /* @__PURE__ */ R(
|
|
171
|
+
}), l && /* @__PURE__ */ R(x, {
|
|
172
172
|
onClick: l,
|
|
173
173
|
size: "sm",
|
|
174
174
|
className: "gap-1",
|
|
175
|
-
children: [/* @__PURE__ */ L(
|
|
175
|
+
children: [/* @__PURE__ */ L(b, { className: "h-4 w-4" }), w("calendar.newEvent")]
|
|
176
176
|
})]
|
|
177
177
|
})]
|
|
178
178
|
}), /* @__PURE__ */ R("div", {
|
|
@@ -183,22 +183,22 @@ function pe({ events: t = [], view: n = "month", currentDate: r = z, locale: i =
|
|
|
183
183
|
onTouchEnd: (e) => {
|
|
184
184
|
let t = I.current - e.changedTouches[0].clientX;
|
|
185
185
|
if (Math.abs(t) > 50) {
|
|
186
|
-
let e = new Date(
|
|
186
|
+
let e = new Date(g);
|
|
187
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);
|
|
188
188
|
}
|
|
189
189
|
},
|
|
190
190
|
children: [
|
|
191
191
|
m === "month" && /* @__PURE__ */ L(ge, {
|
|
192
|
-
date:
|
|
192
|
+
date: g,
|
|
193
193
|
events: t,
|
|
194
194
|
locale: E,
|
|
195
195
|
onEventClick: a,
|
|
196
196
|
onDateClick: o,
|
|
197
197
|
onEventDrop: u
|
|
198
198
|
}),
|
|
199
|
-
m === "week" && /* @__PURE__ */ L(
|
|
199
|
+
m === "week" && /* @__PURE__ */ L(J, {
|
|
200
200
|
mode: "week",
|
|
201
|
-
date:
|
|
201
|
+
date: g,
|
|
202
202
|
events: t,
|
|
203
203
|
locale: E,
|
|
204
204
|
slotMinutes: f,
|
|
@@ -206,9 +206,9 @@ function pe({ events: t = [], view: n = "month", currentDate: r = z, locale: i =
|
|
|
206
206
|
onEventDrop: u,
|
|
207
207
|
onTimeRangeSelect: d
|
|
208
208
|
}),
|
|
209
|
-
m === "day" && /* @__PURE__ */ L(
|
|
209
|
+
m === "day" && /* @__PURE__ */ L(J, {
|
|
210
210
|
mode: "day",
|
|
211
|
-
date:
|
|
211
|
+
date: g,
|
|
212
212
|
events: t,
|
|
213
213
|
locale: E,
|
|
214
214
|
slotMinutes: f,
|
|
@@ -224,7 +224,7 @@ function H(e) {
|
|
|
224
224
|
let t = new Date(e), n = t.getDay(), r = t.getDate() - n;
|
|
225
225
|
return t.setDate(r), t;
|
|
226
226
|
}
|
|
227
|
-
function
|
|
227
|
+
function he(e) {
|
|
228
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 = [];
|
|
229
229
|
for (let e = a - 1; e >= 0; e--) {
|
|
230
230
|
let t = new Date(r.getTime());
|
|
@@ -238,11 +238,11 @@ function me(e) {
|
|
|
238
238
|
}
|
|
239
239
|
return o;
|
|
240
240
|
}
|
|
241
|
-
function
|
|
241
|
+
function U(e, t) {
|
|
242
242
|
return e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth() && e.getDate() === t.getDate();
|
|
243
243
|
}
|
|
244
244
|
function ge({ date: t, events: n, locale: r = "default", onEventClick: i, onDateClick: a, onEventDrop: o }) {
|
|
245
|
-
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(() => {
|
|
246
246
|
let e = new Date(2024, 0, 7);
|
|
247
247
|
return Array.from({ length: 7 }, (t, n) => {
|
|
248
248
|
let i = new Date(e);
|
|
@@ -328,7 +328,7 @@ function ge({ date: t, events: n, locale: r = "default", onEventClick: i, onDate
|
|
|
328
328
|
"aria-label": "Calendar grid",
|
|
329
329
|
className: "grid grid-cols-7 flex-1 auto-rows-fr",
|
|
330
330
|
children: s.map((e, n) => {
|
|
331
|
-
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);
|
|
332
332
|
return /* @__PURE__ */ R("div", {
|
|
333
333
|
role: "gridcell",
|
|
334
334
|
"aria-label": `${e.toLocaleDateString("default", {
|
|
@@ -337,13 +337,13 @@ function ge({ date: t, events: n, locale: r = "default", onEventClick: i, onDate
|
|
|
337
337
|
day: "numeric",
|
|
338
338
|
year: "numeric"
|
|
339
339
|
})}${s.length > 0 ? `, ${s.length} event${s.length > 1 ? "s" : ""}` : ""}`,
|
|
340
|
-
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"),
|
|
341
341
|
onClick: () => a?.(e),
|
|
342
342
|
onDragOver: (e) => v(e, n),
|
|
343
343
|
onDragLeave: y,
|
|
344
344
|
onDrop: (t) => b(t, e),
|
|
345
345
|
children: [/* @__PURE__ */ L("div", {
|
|
346
|
-
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"),
|
|
347
347
|
...f ? { "aria-current": "date" } : {},
|
|
348
348
|
children: e.getDate()
|
|
349
349
|
}), /* @__PURE__ */ R("div", {
|
|
@@ -357,7 +357,7 @@ function ge({ date: t, events: n, locale: r = "default", onEventClick: i, onDate
|
|
|
357
357
|
draggable: !!o,
|
|
358
358
|
onDragStart: (n) => g(n, t, "move", e),
|
|
359
359
|
onDragEnd: _,
|
|
360
|
-
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"),
|
|
361
361
|
style: u ? { backgroundColor: u } : void 0,
|
|
362
362
|
onClick: (e) => {
|
|
363
363
|
e.stopPropagation(), i?.(t);
|
|
@@ -383,24 +383,24 @@ function ge({ date: t, events: n, locale: r = "default", onEventClick: i, onDate
|
|
|
383
383
|
})]
|
|
384
384
|
});
|
|
385
385
|
}
|
|
386
|
-
var
|
|
387
|
-
function
|
|
386
|
+
var W = 48;
|
|
387
|
+
function G(e) {
|
|
388
388
|
let t = new Date(e);
|
|
389
389
|
return t.setHours(0, 0, 0, 0), t;
|
|
390
390
|
}
|
|
391
|
-
function
|
|
391
|
+
function K(e) {
|
|
392
392
|
return e.getHours() * 60 + e.getMinutes();
|
|
393
393
|
}
|
|
394
|
-
function
|
|
394
|
+
function q(e) {
|
|
395
395
|
return `${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`;
|
|
396
396
|
}
|
|
397
|
-
function
|
|
398
|
-
let { t: l } = V(), u =
|
|
399
|
-
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)];
|
|
400
400
|
let e = H(n);
|
|
401
401
|
return Array.from({ length: 7 }, (t, n) => {
|
|
402
402
|
let r = new Date(e);
|
|
403
|
-
return r.setDate(e.getDate() + n),
|
|
403
|
+
return r.setDate(e.getDate() + n), G(r);
|
|
404
404
|
});
|
|
405
405
|
}, [
|
|
406
406
|
t,
|
|
@@ -420,13 +420,13 @@ function K({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
420
420
|
};
|
|
421
421
|
}, [r, m]), _ = e.useMemo(() => {
|
|
422
422
|
let e = /* @__PURE__ */ new Map();
|
|
423
|
-
for (let t of f) e.set(
|
|
423
|
+
for (let t of f) e.set(q(t), []);
|
|
424
424
|
for (let t of h) {
|
|
425
|
-
let n =
|
|
425
|
+
let n = G(new Date(t.start)), r = t.end ? new Date(t.end) : new Date(t.start), i = G(r);
|
|
426
426
|
r.getHours() === 0 && r.getMinutes() === 0 && r.getSeconds() === 0 && r.getTime() > n.getTime() && (i = new Date(i), i.setDate(i.getDate() - 1));
|
|
427
427
|
for (let r of f) {
|
|
428
|
-
let a =
|
|
429
|
-
a < n || a > i || e.get(
|
|
428
|
+
let a = G(r);
|
|
429
|
+
a < n || a > i || e.get(q(r)).push({
|
|
430
430
|
event: t,
|
|
431
431
|
isStart: a.getTime() === n.getTime(),
|
|
432
432
|
isEnd: a.getTime() === i.getTime()
|
|
@@ -436,14 +436,14 @@ function K({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
436
436
|
return e;
|
|
437
437
|
}, [f, h]), v = e.useMemo(() => {
|
|
438
438
|
let e = /* @__PURE__ */ new Map();
|
|
439
|
-
for (let t of f) e.set(
|
|
439
|
+
for (let t of f) e.set(q(t), []);
|
|
440
440
|
for (let t of g) {
|
|
441
441
|
let n = new Date(t.start), r = t.end ? new Date(t.end) : new Date(n.getTime() + 36e5);
|
|
442
442
|
for (let i of f) {
|
|
443
|
-
let a =
|
|
443
|
+
let a = G(i), o = new Date(a);
|
|
444
444
|
if (o.setDate(o.getDate() + 1), r <= a || n >= o) continue;
|
|
445
|
-
let s = n < a ? a : n, c = r > o ? o : r, l =
|
|
446
|
-
e.get(
|
|
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({
|
|
447
447
|
event: t,
|
|
448
448
|
startMin: l,
|
|
449
449
|
endMin: Math.max(u, l + 15),
|
|
@@ -486,7 +486,7 @@ function K({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
486
486
|
let T = e.useRef(!1), E = e.useCallback((e, t) => {
|
|
487
487
|
let n = x.current[t];
|
|
488
488
|
if (!n) return 0;
|
|
489
|
-
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;
|
|
490
490
|
return Math.max(0, Math.min(1440, i));
|
|
491
491
|
}, [a]), D = e.useCallback((e) => {
|
|
492
492
|
for (let t = 0; t < x.current.length; t++) {
|
|
@@ -573,7 +573,7 @@ function K({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
573
573
|
weekday: e.toLocaleDateString(i, { weekday: "short" }),
|
|
574
574
|
day: e.getDate(),
|
|
575
575
|
month: e.toLocaleDateString(i, { month: "short" }),
|
|
576
|
-
isToday:
|
|
576
|
+
isToday: U(e, p)
|
|
577
577
|
})), [
|
|
578
578
|
f,
|
|
579
579
|
i,
|
|
@@ -602,7 +602,7 @@ function K({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
602
602
|
dayIndex: n,
|
|
603
603
|
minutes: i
|
|
604
604
|
});
|
|
605
|
-
},
|
|
605
|
+
}, ne = (e, t) => {
|
|
606
606
|
if (!c || e.button !== 0) return;
|
|
607
607
|
e.preventDefault();
|
|
608
608
|
let n = E(e.clientY, t);
|
|
@@ -612,10 +612,10 @@ function K({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
612
612
|
anchorMinutes: n,
|
|
613
613
|
headMinutes: n
|
|
614
614
|
});
|
|
615
|
-
},
|
|
615
|
+
}, k = (e) => {
|
|
616
616
|
if (!S) return null;
|
|
617
617
|
if (S.kind === "select" && S.dayIndex === e) {
|
|
618
|
-
let t = Math.min(S.anchorMinutes, S.headMinutes), n = Math.max(S.anchorMinutes, S.headMinutes), r = t / 60 *
|
|
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);
|
|
619
619
|
return /* @__PURE__ */ L("div", {
|
|
620
620
|
className: "absolute left-1 right-1 rounded bg-primary/30 border border-primary pointer-events-none z-10",
|
|
621
621
|
style: {
|
|
@@ -625,12 +625,12 @@ function K({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
625
625
|
"aria-hidden": !0,
|
|
626
626
|
children: /* @__PURE__ */ L("div", {
|
|
627
627
|
className: "px-2 py-0.5 text-xs font-medium text-primary",
|
|
628
|
-
children:
|
|
628
|
+
children: Y(f[e], t, n, i)
|
|
629
629
|
})
|
|
630
630
|
});
|
|
631
631
|
}
|
|
632
632
|
if (S.kind === "move" && S.dayIndex === e) {
|
|
633
|
-
let t = S.minutes - S.grabMinuteOffset, n = Math.max(0, Math.min(1440 - S.durationMin, Math.round(t / a) * a)), r = n / 60 *
|
|
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;
|
|
634
634
|
return /* @__PURE__ */ L("div", {
|
|
635
635
|
className: "absolute left-1 right-1 rounded border-2 border-dashed border-primary bg-primary/10 pointer-events-none z-10",
|
|
636
636
|
style: {
|
|
@@ -640,14 +640,14 @@ function K({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
640
640
|
"aria-hidden": !0,
|
|
641
641
|
children: /* @__PURE__ */ L("div", {
|
|
642
642
|
className: "px-2 py-0.5 text-xs font-medium text-primary",
|
|
643
|
-
children:
|
|
643
|
+
children: Y(f[e], n, n + S.durationMin, i)
|
|
644
644
|
})
|
|
645
645
|
});
|
|
646
646
|
}
|
|
647
647
|
if ((S.kind === "resize-top" || S.kind === "resize-bottom") && S.dayIndex === e) {
|
|
648
648
|
let t, n;
|
|
649
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 *
|
|
650
|
+
let r = t / 60 * W, o = (n - t) / 60 * W;
|
|
651
651
|
return /* @__PURE__ */ L("div", {
|
|
652
652
|
className: "absolute left-1 right-1 rounded border-2 border-dashed border-primary bg-primary/10 pointer-events-none z-10",
|
|
653
653
|
style: {
|
|
@@ -657,7 +657,7 @@ function K({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
657
657
|
"aria-hidden": !0,
|
|
658
658
|
children: /* @__PURE__ */ L("div", {
|
|
659
659
|
className: "px-2 py-0.5 text-xs font-medium text-primary",
|
|
660
|
-
children:
|
|
660
|
+
children: Y(f[e], t, n, i)
|
|
661
661
|
})
|
|
662
662
|
});
|
|
663
663
|
}
|
|
@@ -674,12 +674,12 @@ function K({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
674
674
|
"aria-hidden": !0
|
|
675
675
|
}), ee.map((e, t) => /* @__PURE__ */ R("div", {
|
|
676
676
|
role: "columnheader",
|
|
677
|
-
className:
|
|
677
|
+
className: F("flex-1 p-2 text-center text-sm border-r last:border-r-0", e.isToday && "bg-primary/5"),
|
|
678
678
|
children: [/* @__PURE__ */ L("div", {
|
|
679
679
|
className: "text-xs text-muted-foreground",
|
|
680
680
|
children: e.weekday
|
|
681
681
|
}), /* @__PURE__ */ L("div", {
|
|
682
|
-
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"),
|
|
683
683
|
children: e.day
|
|
684
684
|
})]
|
|
685
685
|
}, t))]
|
|
@@ -690,7 +690,7 @@ function K({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
690
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",
|
|
691
691
|
children: l("calendar.allDay") === "calendar.allDay" ? "all-day" : l("calendar.allDay")
|
|
692
692
|
}), f.map((e) => {
|
|
693
|
-
let t =
|
|
693
|
+
let t = q(e), n = _.get(t) ?? [];
|
|
694
694
|
return /* @__PURE__ */ L("div", {
|
|
695
695
|
className: "flex-1 border-r last:border-r-0 min-h-[28px] p-0.5 space-y-0.5",
|
|
696
696
|
children: n.map(({ event: e, isStart: t, isEnd: n }, r) => {
|
|
@@ -701,7 +701,7 @@ function K({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
701
701
|
onClick: (t) => {
|
|
702
702
|
t.stopPropagation(), o?.(e);
|
|
703
703
|
},
|
|
704
|
-
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),
|
|
705
705
|
style: a ? { backgroundColor: a } : void 0,
|
|
706
706
|
children: t ? e.title : "\xA0"
|
|
707
707
|
}, `${e.id}-${r}`);
|
|
@@ -718,18 +718,18 @@ function K({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
718
718
|
className: "w-14 shrink-0 border-r relative",
|
|
719
719
|
children: te.map((e, t) => /* @__PURE__ */ L("div", {
|
|
720
720
|
className: "absolute right-1 text-[10px] text-muted-foreground -translate-y-1/2",
|
|
721
|
-
style: { top: t *
|
|
721
|
+
style: { top: t * W },
|
|
722
722
|
children: t === 0 ? "" : e
|
|
723
723
|
}, t))
|
|
724
724
|
}), f.map((e, t) => {
|
|
725
|
-
let n =
|
|
725
|
+
let n = q(e), r = y.get(n) ?? [];
|
|
726
726
|
return /* @__PURE__ */ R("div", {
|
|
727
727
|
ref: (e) => {
|
|
728
728
|
x.current[t] = e;
|
|
729
729
|
},
|
|
730
730
|
className: "flex-1 border-r last:border-r-0 relative select-none",
|
|
731
731
|
style: { height: d },
|
|
732
|
-
onPointerDown: (e) =>
|
|
732
|
+
onPointerDown: (e) => ne(e, t),
|
|
733
733
|
"aria-label": e.toLocaleDateString(i, {
|
|
734
734
|
weekday: "long",
|
|
735
735
|
month: "long",
|
|
@@ -739,17 +739,17 @@ function K({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
739
739
|
children: [
|
|
740
740
|
Array.from({ length: 24 }, (e, t) => /* @__PURE__ */ L("div", {
|
|
741
741
|
className: "absolute left-0 right-0 border-t border-muted/60 pointer-events-none",
|
|
742
|
-
style: { top: t *
|
|
742
|
+
style: { top: t * W }
|
|
743
743
|
}, t)),
|
|
744
744
|
a < 60 && Array.from({ length: Math.floor(1440 / a) }, (e, t) => {
|
|
745
745
|
let n = t * a;
|
|
746
746
|
return n % 60 == 0 ? null : /* @__PURE__ */ L("div", {
|
|
747
747
|
className: "absolute left-0 right-0 border-t border-dashed border-muted/30 pointer-events-none",
|
|
748
|
-
style: { top: n / 60 *
|
|
748
|
+
style: { top: n / 60 * W }
|
|
749
749
|
}, t);
|
|
750
750
|
}),
|
|
751
751
|
r.map((n) => {
|
|
752
|
-
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;
|
|
753
753
|
return /* @__PURE__ */ R("div", {
|
|
754
754
|
role: "button",
|
|
755
755
|
tabIndex: 0,
|
|
@@ -763,7 +763,7 @@ function K({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
763
763
|
}
|
|
764
764
|
e.stopPropagation(), o?.(n.event);
|
|
765
765
|
},
|
|
766
|
-
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"),
|
|
767
767
|
style: {
|
|
768
768
|
top: r,
|
|
769
769
|
height: a,
|
|
@@ -778,7 +778,7 @@ function K({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
778
778
|
}),
|
|
779
779
|
/* @__PURE__ */ L("div", {
|
|
780
780
|
className: "text-[10px] opacity-80 truncate",
|
|
781
|
-
children:
|
|
781
|
+
children: Y(e, n.startMin, n.endMin, i)
|
|
782
782
|
}),
|
|
783
783
|
s && n.isStart && /* @__PURE__ */ L("div", {
|
|
784
784
|
onPointerDown: (e) => O(e, n, t, "top"),
|
|
@@ -793,7 +793,7 @@ function K({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
793
793
|
]
|
|
794
794
|
}, `${n.event.id}-${n.startMin}`);
|
|
795
795
|
}),
|
|
796
|
-
|
|
796
|
+
k(t)
|
|
797
797
|
]
|
|
798
798
|
}, n);
|
|
799
799
|
})]
|
|
@@ -802,7 +802,7 @@ function K({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a
|
|
|
802
802
|
]
|
|
803
803
|
});
|
|
804
804
|
}
|
|
805
|
-
function
|
|
805
|
+
function Y(e, t, n, r) {
|
|
806
806
|
let i = new Date(e);
|
|
807
807
|
i.setHours(0, Math.round(t), 0, 0);
|
|
808
808
|
let a = new Date(e);
|
|
@@ -815,7 +815,7 @@ function q(e, t, n, r) {
|
|
|
815
815
|
}
|
|
816
816
|
//#endregion
|
|
817
817
|
//#region src/ObjectCalendar.tsx
|
|
818
|
-
function
|
|
818
|
+
function _e(e) {
|
|
819
819
|
return "data" in e && e.data ? e.data : "staticData" in e && e.staticData ? {
|
|
820
820
|
provider: "value",
|
|
821
821
|
items: e.staticData
|
|
@@ -824,7 +824,7 @@ function ve(e) {
|
|
|
824
824
|
object: e.objectName
|
|
825
825
|
} : null;
|
|
826
826
|
}
|
|
827
|
-
function
|
|
827
|
+
function ve(e) {
|
|
828
828
|
if (e) {
|
|
829
829
|
if (typeof e == "string") {
|
|
830
830
|
let t = e.split(" "), n = t[0], r = t[1]?.toLowerCase() === "desc" ? "desc" : "asc";
|
|
@@ -833,7 +833,7 @@ function ye(e) {
|
|
|
833
833
|
if (Array.isArray(e)) return e.reduce((e, t) => (t.field && t.order && (e[t.field] = t.order), e), {});
|
|
834
834
|
}
|
|
835
835
|
}
|
|
836
|
-
function
|
|
836
|
+
function ye(e) {
|
|
837
837
|
return "filter" in e && e.filter && typeof e.filter == "object" && "calendar" in e.filter ? e.filter.calendar : e.calendar ? e.calendar : e.startDateField || e.dateField ? {
|
|
838
838
|
startDateField: e.startDateField || e.dateField,
|
|
839
839
|
endDateField: e.endDateField || e.endField,
|
|
@@ -842,44 +842,44 @@ function be(e) {
|
|
|
842
842
|
allDayField: e.allDayField
|
|
843
843
|
} : null;
|
|
844
844
|
}
|
|
845
|
-
var
|
|
846
|
-
let
|
|
847
|
-
let e =
|
|
848
|
-
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";
|
|
849
849
|
});
|
|
850
850
|
r(() => {
|
|
851
|
-
|
|
852
|
-
}, [
|
|
853
|
-
let [he,
|
|
851
|
+
pe && V === "day" && (B === "day" || !B) && H("month");
|
|
852
|
+
}, [pe]);
|
|
853
|
+
let [he, U] = o(0);
|
|
854
854
|
r(() => {
|
|
855
855
|
if (!j && !(!t?.onMutation || !e.objectName)) return t.onMutation((t) => {
|
|
856
|
-
t.resource === e.objectName &&
|
|
856
|
+
t.resource === e.objectName && U((e) => e + 1);
|
|
857
857
|
});
|
|
858
858
|
}, [
|
|
859
859
|
t,
|
|
860
860
|
e.objectName,
|
|
861
861
|
j
|
|
862
862
|
]);
|
|
863
|
-
let
|
|
864
|
-
|
|
865
|
-
}, []), { ref: W, isRefreshing:
|
|
866
|
-
onRefresh:
|
|
863
|
+
let ge = n(async () => {
|
|
864
|
+
U((e) => e + 1);
|
|
865
|
+
}, []), { ref: W, isRefreshing: G, pullDistance: K } = se({
|
|
866
|
+
onRefresh: ge,
|
|
867
867
|
enabled: !!t && !!e.objectName
|
|
868
|
-
}),
|
|
868
|
+
}), q = i(() => _e(e), [
|
|
869
869
|
e.data,
|
|
870
870
|
e.staticData,
|
|
871
871
|
e.objectName
|
|
872
|
-
]),
|
|
872
|
+
]), J = i(() => ye(e), [
|
|
873
873
|
e.filter,
|
|
874
874
|
e.calendar,
|
|
875
875
|
e.dateField,
|
|
876
876
|
e.endField,
|
|
877
877
|
e.titleField,
|
|
878
878
|
e.colorField
|
|
879
|
-
]),
|
|
880
|
-
|
|
881
|
-
j && N(
|
|
882
|
-
}, [
|
|
879
|
+
]), Y = q?.provider === "value", be = a(null);
|
|
880
|
+
be.current = z, r(() => {
|
|
881
|
+
j && N(d);
|
|
882
|
+
}, [d, j]), r(() => {
|
|
883
883
|
j && g !== void 0 && P(g);
|
|
884
884
|
}, [g, j]), r(() => {
|
|
885
885
|
if (j) return;
|
|
@@ -887,39 +887,39 @@ var J = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
887
887
|
return (async () => {
|
|
888
888
|
try {
|
|
889
889
|
if (!n) return;
|
|
890
|
-
if (P(!0),
|
|
891
|
-
n && (N(
|
|
890
|
+
if (P(!0), Y && q?.provider === "value") {
|
|
891
|
+
n && (N(q.items), P(!1));
|
|
892
892
|
return;
|
|
893
893
|
}
|
|
894
894
|
if (!t || typeof t.find != "function") throw Error("DataSource required for object/api providers");
|
|
895
|
-
if (
|
|
896
|
-
let r =
|
|
895
|
+
if (q?.provider === "object") {
|
|
896
|
+
let r = q.object, i = c(be.current?.fields), a = await t.find(r, {
|
|
897
897
|
$filter: e.filter,
|
|
898
|
-
$orderby:
|
|
898
|
+
$orderby: ve(e.sort),
|
|
899
899
|
...i.length > 0 ? { $expand: i } : {}
|
|
900
900
|
}), o = l(a);
|
|
901
901
|
n && N(o);
|
|
902
|
-
} else
|
|
902
|
+
} else q?.provider === "api" && (console.warn("API provider not yet implemented for ObjectCalendar"), n && N([]));
|
|
903
903
|
n && P(!1);
|
|
904
904
|
} catch (e) {
|
|
905
|
-
console.error("[ObjectCalendar] Error fetching data:", e), n && (
|
|
905
|
+
console.error("[ObjectCalendar] Error fetching data:", e), n && (I(e), P(!1));
|
|
906
906
|
}
|
|
907
907
|
})(), () => {
|
|
908
908
|
n = !1;
|
|
909
909
|
};
|
|
910
910
|
}, [
|
|
911
911
|
j,
|
|
912
|
-
|
|
912
|
+
q,
|
|
913
913
|
t,
|
|
914
|
-
|
|
914
|
+
Y,
|
|
915
915
|
e.filter,
|
|
916
916
|
e.sort,
|
|
917
917
|
he
|
|
918
918
|
]), r(() => {
|
|
919
|
-
!
|
|
919
|
+
!Y && t && (async () => {
|
|
920
920
|
try {
|
|
921
921
|
if (!t) return;
|
|
922
|
-
let n =
|
|
922
|
+
let n = q?.provider === "object" ? q.object : e.objectName;
|
|
923
923
|
if (!n) return;
|
|
924
924
|
let r = await t.getObjectSchema(n);
|
|
925
925
|
ue(r);
|
|
@@ -930,12 +930,12 @@ var J = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
930
930
|
}, [
|
|
931
931
|
e.objectName,
|
|
932
932
|
t,
|
|
933
|
-
|
|
934
|
-
|
|
933
|
+
Y,
|
|
934
|
+
q
|
|
935
935
|
]);
|
|
936
936
|
let xe = i(() => {
|
|
937
|
-
if (!
|
|
938
|
-
let { startDateField: e, endDateField: t, titleField: n, colorField: r } =
|
|
937
|
+
if (!J || !M.length) return [];
|
|
938
|
+
let { startDateField: e, endDateField: t, titleField: n, colorField: r } = J, i = (e) => {
|
|
939
939
|
if (n) {
|
|
940
940
|
let t = e[n], r = typeof t == "string" ? t.trim() : t;
|
|
941
941
|
if (r) return String(r);
|
|
@@ -956,7 +956,7 @@ var J = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
956
956
|
}).filter((e) => !isNaN(e.start.getTime()));
|
|
957
957
|
}, [
|
|
958
958
|
M,
|
|
959
|
-
|
|
959
|
+
J,
|
|
960
960
|
z
|
|
961
961
|
]);
|
|
962
962
|
n(() => {
|
|
@@ -965,13 +965,13 @@ var J = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
965
965
|
let X = e.navigation ?? {
|
|
966
966
|
mode: "drawer",
|
|
967
967
|
width: "min(960px, 60vw)"
|
|
968
|
-
}, Se = X.mode === "drawer" || X.mode === "modal" || X.mode === "split" || X.mode === "popover", Z =
|
|
968
|
+
}, Se = X.mode === "drawer" || X.mode === "modal" || X.mode === "split" || X.mode === "popover", Z = m({
|
|
969
969
|
navigation: X,
|
|
970
970
|
objectName: e.objectName,
|
|
971
971
|
onRowClick: Se ? void 0 : v
|
|
972
972
|
}), Ce = n(async (n, r, i) => {
|
|
973
|
-
if (!
|
|
974
|
-
let { startDateField: a, endDateField: o } =
|
|
973
|
+
if (!J) return;
|
|
974
|
+
let { startDateField: a, endDateField: o } = J, s = n?.id ?? n?._id;
|
|
975
975
|
if (!s || !e.objectName || !t?.update) return;
|
|
976
976
|
let c = { [a]: r.toISOString() };
|
|
977
977
|
o && i && (c[o] = i.toISOString());
|
|
@@ -983,37 +983,37 @@ var J = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
983
983
|
try {
|
|
984
984
|
await t.update(e.objectName, s, c);
|
|
985
985
|
} catch (e) {
|
|
986
|
-
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"));
|
|
987
987
|
}
|
|
988
988
|
}, [
|
|
989
|
-
|
|
989
|
+
J,
|
|
990
990
|
e.objectName,
|
|
991
991
|
t,
|
|
992
992
|
M,
|
|
993
|
-
|
|
993
|
+
A
|
|
994
994
|
]), [Q, $] = o(null), we = n((n) => {
|
|
995
|
-
!
|
|
995
|
+
!J || !e.objectName || !t?.create || $({
|
|
996
996
|
start: n,
|
|
997
997
|
title: "",
|
|
998
998
|
submitting: !1
|
|
999
999
|
});
|
|
1000
1000
|
}, [
|
|
1001
|
-
|
|
1001
|
+
J,
|
|
1002
1002
|
e.objectName,
|
|
1003
1003
|
t
|
|
1004
1004
|
]), Te = n((n, r) => {
|
|
1005
|
-
!
|
|
1005
|
+
!J || !e.objectName || !t?.create || $({
|
|
1006
1006
|
start: n,
|
|
1007
1007
|
end: r,
|
|
1008
1008
|
title: "",
|
|
1009
1009
|
submitting: !1
|
|
1010
1010
|
});
|
|
1011
1011
|
}, [
|
|
1012
|
-
|
|
1012
|
+
J,
|
|
1013
1013
|
e.objectName,
|
|
1014
1014
|
t
|
|
1015
1015
|
]), Ee = n(async () => {
|
|
1016
|
-
if (!Q || !
|
|
1016
|
+
if (!Q || !J) return;
|
|
1017
1017
|
let n = Q.title.trim();
|
|
1018
1018
|
if (!n) {
|
|
1019
1019
|
$((e) => e && {
|
|
@@ -1028,7 +1028,7 @@ var J = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
1028
1028
|
submitting: !0,
|
|
1029
1029
|
error: void 0
|
|
1030
1030
|
});
|
|
1031
|
-
let { startDateField: r, endDateField: i, titleField: a } =
|
|
1031
|
+
let { startDateField: r, endDateField: i, titleField: a } = J, o = {
|
|
1032
1032
|
[a || "name"]: n,
|
|
1033
1033
|
[r]: Q.start.toISOString()
|
|
1034
1034
|
};
|
|
@@ -1062,7 +1062,7 @@ var J = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
1062
1062
|
}
|
|
1063
1063
|
}, [
|
|
1064
1064
|
Q,
|
|
1065
|
-
|
|
1065
|
+
J,
|
|
1066
1066
|
e.objectName,
|
|
1067
1067
|
t,
|
|
1068
1068
|
z
|
|
@@ -1085,22 +1085,22 @@ var J = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
1085
1085
|
children: ["Error: ", F.message]
|
|
1086
1086
|
})
|
|
1087
1087
|
})
|
|
1088
|
-
}) :
|
|
1088
|
+
}) : J ? /* @__PURE__ */ R("div", {
|
|
1089
1089
|
ref: W,
|
|
1090
1090
|
className: s,
|
|
1091
1091
|
children: [
|
|
1092
|
-
|
|
1092
|
+
K > 0 && /* @__PURE__ */ L("div", {
|
|
1093
1093
|
className: "flex items-center justify-center text-xs text-muted-foreground",
|
|
1094
|
-
style: { height:
|
|
1095
|
-
children:
|
|
1094
|
+
style: { height: K },
|
|
1095
|
+
children: G ? "Refreshing…" : "Pull to refresh"
|
|
1096
1096
|
}),
|
|
1097
1097
|
/* @__PURE__ */ L("div", {
|
|
1098
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]",
|
|
1099
|
-
children: /* @__PURE__ */ L(
|
|
1099
|
+
children: /* @__PURE__ */ L(me, {
|
|
1100
1100
|
events: xe,
|
|
1101
1101
|
currentDate: de,
|
|
1102
|
-
view:
|
|
1103
|
-
locale:
|
|
1102
|
+
view: V,
|
|
1103
|
+
locale: k,
|
|
1104
1104
|
onEventClick: (e) => {
|
|
1105
1105
|
Z.handleClick(e.data), Se || _?.(e.data);
|
|
1106
1106
|
},
|
|
@@ -1108,38 +1108,38 @@ var J = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
1108
1108
|
y ? y(e) : we(e);
|
|
1109
1109
|
},
|
|
1110
1110
|
onNavigate: (e) => {
|
|
1111
|
-
fe(e),
|
|
1111
|
+
fe(e), b?.(e);
|
|
1112
1112
|
},
|
|
1113
1113
|
onViewChange: (e) => {
|
|
1114
|
-
|
|
1114
|
+
H(e), S?.(e);
|
|
1115
1115
|
},
|
|
1116
1116
|
onAddClick: void 0,
|
|
1117
1117
|
onEventDrop: (e, t, n) => {
|
|
1118
|
-
|
|
1118
|
+
ne ? ne(e.data, t, n) : Ce(e.data, t, n);
|
|
1119
1119
|
},
|
|
1120
1120
|
onTimeRangeSelect: Te
|
|
1121
1121
|
})
|
|
1122
1122
|
}),
|
|
1123
|
-
/* @__PURE__ */ L(
|
|
1123
|
+
/* @__PURE__ */ L(C, {
|
|
1124
1124
|
open: !!Q,
|
|
1125
1125
|
onOpenChange: (e) => {
|
|
1126
1126
|
e || $(null);
|
|
1127
1127
|
},
|
|
1128
|
-
children: /* @__PURE__ */ R(
|
|
1128
|
+
children: /* @__PURE__ */ R(w, {
|
|
1129
1129
|
className: "sm:max-w-md",
|
|
1130
1130
|
children: [
|
|
1131
|
-
/* @__PURE__ */ R(
|
|
1132
|
-
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, {
|
|
1133
1133
|
year: "numeric",
|
|
1134
1134
|
month: "long",
|
|
1135
1135
|
day: "numeric"
|
|
1136
1136
|
});
|
|
1137
1137
|
if (e) {
|
|
1138
|
-
let e = (e) => e.toLocaleTimeString(
|
|
1138
|
+
let e = (e) => e.toLocaleTimeString(k, {
|
|
1139
1139
|
hour: "numeric",
|
|
1140
1140
|
minute: "2-digit"
|
|
1141
1141
|
});
|
|
1142
|
-
return /* @__PURE__ */ R(
|
|
1142
|
+
return /* @__PURE__ */ R(oe, { children: [
|
|
1143
1143
|
t,
|
|
1144
1144
|
" · ",
|
|
1145
1145
|
e(Q.start),
|
|
@@ -1147,16 +1147,16 @@ var J = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
1147
1147
|
e(Q.end)
|
|
1148
1148
|
] });
|
|
1149
1149
|
}
|
|
1150
|
-
return /* @__PURE__ */ R(
|
|
1150
|
+
return /* @__PURE__ */ R(oe, { children: ["On ", t] });
|
|
1151
1151
|
})() })] }),
|
|
1152
1152
|
/* @__PURE__ */ R("div", {
|
|
1153
1153
|
className: "space-y-2",
|
|
1154
1154
|
children: [
|
|
1155
|
-
/* @__PURE__ */ L(
|
|
1155
|
+
/* @__PURE__ */ L(O, {
|
|
1156
1156
|
htmlFor: "quick-create-title",
|
|
1157
1157
|
children: "Title"
|
|
1158
1158
|
}),
|
|
1159
|
-
/* @__PURE__ */ L(
|
|
1159
|
+
/* @__PURE__ */ L(te, {
|
|
1160
1160
|
id: "quick-create-title",
|
|
1161
1161
|
autoFocus: !0,
|
|
1162
1162
|
value: Q?.title ?? "",
|
|
@@ -1177,12 +1177,12 @@ var J = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
1177
1177
|
})
|
|
1178
1178
|
]
|
|
1179
1179
|
}),
|
|
1180
|
-
/* @__PURE__ */ R(
|
|
1180
|
+
/* @__PURE__ */ R(E, { children: [/* @__PURE__ */ L(x, {
|
|
1181
1181
|
variant: "outline",
|
|
1182
1182
|
onClick: () => $(null),
|
|
1183
1183
|
disabled: Q?.submitting,
|
|
1184
1184
|
children: "Cancel"
|
|
1185
|
-
}), /* @__PURE__ */ L(
|
|
1185
|
+
}), /* @__PURE__ */ L(x, {
|
|
1186
1186
|
onClick: () => void Ee(),
|
|
1187
1187
|
disabled: Q?.submitting || !Q?.title.trim(),
|
|
1188
1188
|
children: Q?.submitting ? "Creating…" : "Create"
|
|
@@ -1191,10 +1191,10 @@ var J = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
1191
1191
|
})
|
|
1192
1192
|
}),
|
|
1193
1193
|
Z.isOverlay && Z.isOpen && Z.selectedRecord && (() => {
|
|
1194
|
-
let n =
|
|
1194
|
+
let n = q?.provider === "object" ? q.object : e.objectName, r = Z.selectedRecord, i = r.id ?? r._id;
|
|
1195
1195
|
if (!n || i == null) return null;
|
|
1196
|
-
let a =
|
|
1197
|
-
return /* @__PURE__ */ L(
|
|
1196
|
+
let a = J?.titleField ? String(r[J.titleField] ?? "Event Details") : "Event Details";
|
|
1197
|
+
return /* @__PURE__ */ L(ce, {
|
|
1198
1198
|
open: !0,
|
|
1199
1199
|
onClose: Z.close,
|
|
1200
1200
|
title: a,
|
|
@@ -1204,7 +1204,7 @@ var J = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
1204
1204
|
dataSource: t,
|
|
1205
1205
|
objectSchema: z,
|
|
1206
1206
|
width: Z.width ?? "min(960px, 60vw)",
|
|
1207
|
-
fullPageHref:
|
|
1207
|
+
fullPageHref: le(n, i) ?? void 0,
|
|
1208
1208
|
onFieldSave: async (e, r) => {
|
|
1209
1209
|
t?.update && (await t.update(n, String(i), { [e]: r }), N((t) => t.map((t) => String(t.id ?? t._id) === String(i) ? {
|
|
1210
1210
|
...t,
|
|
@@ -1227,11 +1227,55 @@ var J = ({ schema: e, dataSource: t, className: s, data: h, loading: g, onEventC
|
|
|
1227
1227
|
})
|
|
1228
1228
|
})
|
|
1229
1229
|
});
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
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) => {
|
|
1235
1279
|
let r = e.titleField || "title", i = e.startDateField || "start", a = e.endDateField || "end", o = e.colorField || "color", s = e.allDayField || "allDay";
|
|
1236
1280
|
return {
|
|
1237
1281
|
id: t.id || t._id || n,
|
|
@@ -1249,17 +1293,27 @@ s.register("calendar-view", ({ schema: e, className: n, onAction: r, ...i }) =>
|
|
|
1249
1293
|
e.endDateField,
|
|
1250
1294
|
e.colorField,
|
|
1251
1295
|
e.allDayField
|
|
1252
|
-
])
|
|
1253
|
-
|
|
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?.({
|
|
1298
|
+
type: "event-click",
|
|
1299
|
+
payload: e
|
|
1300
|
+
});
|
|
1301
|
+
}, v = () => {
|
|
1302
|
+
g?.({
|
|
1303
|
+
type: "create",
|
|
1304
|
+
payload: {}
|
|
1305
|
+
});
|
|
1306
|
+
};
|
|
1307
|
+
return /* @__PURE__ */ L(me, {
|
|
1254
1308
|
className: n,
|
|
1255
|
-
events:
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
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)
|
|
1263
1317
|
});
|
|
1264
1318
|
}, {
|
|
1265
1319
|
namespace: "plugin-calendar",
|
|
@@ -1306,12 +1360,6 @@ s.register("calendar-view", ({ schema: e, className: n, onAction: r, ...i }) =>
|
|
|
1306
1360
|
defaultValue: "color",
|
|
1307
1361
|
description: "Field name for event color"
|
|
1308
1362
|
},
|
|
1309
|
-
{
|
|
1310
|
-
name: "colorMapping",
|
|
1311
|
-
type: "object",
|
|
1312
|
-
label: "Color Mapping",
|
|
1313
|
-
description: "Map field values to colors (e.g., {meeting: \"blue\", deadline: \"red\"})"
|
|
1314
|
-
},
|
|
1315
1363
|
{
|
|
1316
1364
|
name: "view",
|
|
1317
1365
|
type: "enum",
|
|
@@ -1381,15 +1429,66 @@ s.register("calendar-view", ({ schema: e, className: n, onAction: r, ...i }) =>
|
|
|
1381
1429
|
});
|
|
1382
1430
|
//#endregion
|
|
1383
1431
|
//#region src/index.tsx
|
|
1384
|
-
var
|
|
1385
|
-
|
|
1386
|
-
|
|
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, {
|
|
1387
1475
|
schema: e,
|
|
1388
|
-
|
|
1389
|
-
|
|
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
|
+
})
|
|
1390
1489
|
});
|
|
1391
1490
|
};
|
|
1392
|
-
s.register("object-calendar",
|
|
1491
|
+
s.register("object-calendar", Me, {
|
|
1393
1492
|
namespace: "plugin-calendar",
|
|
1394
1493
|
label: "Object Calendar",
|
|
1395
1494
|
category: "view",
|
|
@@ -1404,7 +1503,7 @@ s.register("object-calendar", Y, {
|
|
|
1404
1503
|
label: "Calendar Config",
|
|
1405
1504
|
description: "startDateField, endDateField, titleField, colorField"
|
|
1406
1505
|
}]
|
|
1407
|
-
}), s.register("calendar",
|
|
1506
|
+
}), s.register("calendar", Me, {
|
|
1408
1507
|
namespace: "view",
|
|
1409
1508
|
label: "Calendar View",
|
|
1410
1509
|
category: "view",
|
|
@@ -1421,4 +1520,4 @@ s.register("object-calendar", Y, {
|
|
|
1421
1520
|
}]
|
|
1422
1521
|
});
|
|
1423
1522
|
//#endregion
|
|
1424
|
-
export {
|
|
1523
|
+
export { me as CalendarView, be as ObjectCalendar, Me as ObjectCalendarRenderer };
|