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