@object-ui/plugin-calendar 4.0.7 → 4.0.9

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/dist/index.js CHANGED
@@ -3,25 +3,48 @@ import t, { useCallback as n, useEffect as r, useMemo as i, useRef as a, useStat
3
3
  import { ComponentRegistry as s, buildExpandFields as c, extractRecords as l } from "@object-ui/core";
4
4
  import { useNavigationOverlay as u, useSchemaContext as d } from "@object-ui/react";
5
5
  import { CalendarIcon as f, ChevronLeftIcon as p, ChevronRightIcon as m, PlusIcon as h } from "lucide-react";
6
- import { Button as g, Calendar as _, NavigationOverlay as v, Popover as y, PopoverContent as b, PopoverTrigger as x, Select as S, SelectContent as C, SelectItem as w, SelectTrigger as T, SelectValue as E, cn as D, useIsMobile as O } from "@object-ui/components";
7
- import { useObjectTranslation as k } from "@object-ui/i18n";
8
- import { jsx as A, jsxs as j } from "react/jsx-runtime";
9
- import { usePullToRefresh as M } from "@object-ui/mobile";
6
+ import { Button as g, Calendar as _, Dialog as v, DialogContent as y, DialogDescription as b, DialogFooter as x, DialogHeader as S, DialogTitle as C, Input as w, Label as T, Popover as E, PopoverContent as D, PopoverTrigger as O, Select as k, SelectContent as A, SelectItem as j, SelectTrigger as ee, SelectValue as M, cn as N, useIsMobile as P } from "@object-ui/components";
7
+ import { useObjectTranslation as F } from "@object-ui/i18n";
8
+ import { Fragment as te, jsx as I, jsxs as L } from "react/jsx-runtime";
9
+ import { usePullToRefresh as ne } from "@object-ui/mobile";
10
+ import { RecordDetailDrawer as re, deriveRecordPageHref as ie } from "@object-ui/plugin-detail";
10
11
  //#region src/CalendarView.tsx
11
- var N = "bg-blue-500 text-white", P = /* @__PURE__ */ new Date(), F = {
12
+ var R = "bg-blue-100 text-blue-900 border border-blue-200", ae = /* @__PURE__ */ new Date(), z = [
13
+ "bg-blue-100 text-blue-900 border border-blue-200",
14
+ "bg-emerald-100 text-emerald-900 border border-emerald-200",
15
+ "bg-amber-100 text-amber-900 border border-amber-200",
16
+ "bg-rose-100 text-rose-900 border border-rose-200",
17
+ "bg-violet-100 text-violet-900 border border-violet-200",
18
+ "bg-cyan-100 text-cyan-900 border border-cyan-200",
19
+ "bg-orange-100 text-orange-900 border border-orange-200",
20
+ "bg-fuchsia-100 text-fuchsia-900 border border-fuchsia-200"
21
+ ], oe = /^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i, se = /(^|\s)(bg|text|from|to|via)-/;
22
+ function B(e) {
23
+ if (!e) return { className: R };
24
+ if (oe.test(e)) return {
25
+ className: "text-white",
26
+ inlineColor: e
27
+ };
28
+ if (se.test(e)) return { className: e };
29
+ let t = 0;
30
+ for (let n = 0; n < e.length; n++) t = (t << 5) - t + e.charCodeAt(n) | 0;
31
+ return { className: z[Math.abs(t) % z.length] };
32
+ }
33
+ var V = {
12
34
  "calendar.today": "Today",
13
35
  "calendar.month": "Month",
14
36
  "calendar.week": "Week",
15
37
  "calendar.day": "Day",
16
38
  "calendar.newEvent": "New event",
17
- "calendar.moreEvents": "+{{count}} more"
39
+ "calendar.moreEvents": "+{{count}} more",
40
+ "calendar.allDay": "all-day"
18
41
  };
19
- function I() {
42
+ function H() {
20
43
  try {
21
- let e = k();
44
+ let e = F();
22
45
  return e.t("calendar.today") === "calendar.today" ? {
23
46
  t: (e, t) => {
24
- let n = F[e] || e;
47
+ let n = V[e] || e;
25
48
  if (t) for (let [e, r] of Object.entries(t)) n = n.replace(`{{${e}}}`, String(r));
26
49
  return n;
27
50
  },
@@ -33,7 +56,7 @@ function I() {
33
56
  } catch {
34
57
  return {
35
58
  t: (e, t) => {
36
- let n = F[e] || e;
59
+ let n = V[e] || e;
37
60
  if (t) for (let [e, r] of Object.entries(t)) n = n.replace(`{{${e}}}`, String(r));
38
61
  return n;
39
62
  },
@@ -41,184 +64,191 @@ function I() {
41
64
  };
42
65
  }
43
66
  }
44
- function L({ events: t = [], view: n = "month", currentDate: r = P, locale: i = "default", onEventClick: a, onDateClick: o, onViewChange: s, onNavigate: c, onAddClick: l, onEventDrop: u, className: d }) {
45
- let [v, O] = e.useState(n), [k, M] = e.useState(r), { t: N, language: F } = I(), L = i === "default" ? F : i;
67
+ function ce({ events: t = [], view: n = "month", currentDate: r = ae, locale: i = "default", onEventClick: a, onDateClick: o, onViewChange: s, onNavigate: c, onAddClick: l, onEventDrop: u, onTimeRangeSelect: d, slotMinutes: v = 30, className: y }) {
68
+ let [b, x] = e.useState(n), [S, C] = e.useState(r), { t: w, language: T } = H(), P = i === "default" ? T : i;
46
69
  e.useEffect(() => {
47
- M(r);
70
+ C(r);
48
71
  }, [r]), e.useEffect(() => {
49
- O(n);
72
+ x(n);
50
73
  }, [n]);
51
- let z = e.useRef(s);
52
- z.current = s, e.useEffect(() => {
74
+ let F = e.useRef(s);
75
+ F.current = s, e.useEffect(() => {
53
76
  let e = window.matchMedia("(max-width: 639px)"), t = (e) => {
54
- e.matches && (O("day"), z.current?.("day"));
77
+ e.matches && (x("day"), F.current?.("day"));
55
78
  };
56
79
  return t(e), e.addEventListener("change", t), () => e.removeEventListener("change", t);
57
80
  }, []);
58
- let B = () => {
59
- let e = new Date(k);
60
- v === "month" ? e.setMonth(e.getMonth() - 1) : v === "week" ? e.setDate(e.getDate() - 7) : e.setDate(e.getDate() - 1), M(e), c?.(e);
61
- }, V = () => {
62
- let e = new Date(k);
63
- v === "month" ? e.setMonth(e.getMonth() + 1) : v === "week" ? e.setDate(e.getDate() + 7) : e.setDate(e.getDate() + 1), M(e), c?.(e);
64
- }, G = () => {
81
+ let te = () => {
82
+ let e = new Date(S);
83
+ b === "month" ? e.setMonth(e.getMonth() - 1) : b === "week" ? e.setDate(e.getDate() - 7) : e.setDate(e.getDate() - 1), C(e), c?.(e);
84
+ }, ne = () => {
85
+ let e = new Date(S);
86
+ b === "month" ? e.setMonth(e.getMonth() + 1) : b === "week" ? e.setDate(e.getDate() + 7) : e.setDate(e.getDate() + 1), C(e), c?.(e);
87
+ }, re = () => {
65
88
  let e = /* @__PURE__ */ new Date();
66
- M(e), c?.(e);
67
- }, K = (e) => {
68
- O(e), s?.(e);
69
- }, q = () => {
70
- if (v === "month") return k.toLocaleDateString(L, {
89
+ C(e), c?.(e);
90
+ }, ie = (e) => {
91
+ x(e), s?.(e);
92
+ }, R = () => {
93
+ if (b === "month") return S.toLocaleDateString(P, {
71
94
  month: "long",
72
95
  year: "numeric"
73
96
  });
74
- if (v === "week") {
75
- let e = R(k), t = new Date(e);
76
- return t.setDate(t.getDate() + 6), `${e.toLocaleDateString(L, {
97
+ if (b === "week") {
98
+ let e = le(S), t = new Date(e);
99
+ return t.setDate(t.getDate() + 6), `${e.toLocaleDateString(P, {
77
100
  month: "short",
78
101
  day: "numeric"
79
- })} - ${t.toLocaleDateString(L, {
102
+ })} - ${t.toLocaleDateString(P, {
80
103
  month: "short",
81
104
  day: "numeric",
82
105
  year: "numeric"
83
106
  })}`;
84
- } else return k.toLocaleDateString(L, {
107
+ } else return S.toLocaleDateString(P, {
85
108
  weekday: "long",
86
109
  month: "long",
87
110
  day: "numeric",
88
111
  year: "numeric"
89
112
  });
90
- }, J = e.useRef(0);
91
- return /* @__PURE__ */ j("div", {
113
+ }, z = e.useRef(0);
114
+ return /* @__PURE__ */ L("div", {
92
115
  role: "region",
93
116
  "aria-label": "Calendar",
94
- className: D("flex flex-col h-full bg-background min-w-0 overflow-hidden", d),
95
- children: [/* @__PURE__ */ j("div", {
117
+ className: N("flex flex-col h-full bg-background min-w-0 overflow-hidden", y),
118
+ children: [/* @__PURE__ */ L("div", {
96
119
  className: "flex flex-wrap items-center justify-between gap-2 p-2 sm:p-4 border-b min-w-0",
97
- children: [/* @__PURE__ */ j("div", {
120
+ children: [/* @__PURE__ */ L("div", {
98
121
  className: "flex items-center gap-4",
99
- children: [/* @__PURE__ */ j("div", {
122
+ children: [/* @__PURE__ */ L("div", {
100
123
  className: "flex items-center bg-muted/50 rounded-lg p-1 gap-1",
101
124
  children: [
102
- /* @__PURE__ */ A(g, {
125
+ /* @__PURE__ */ I(g, {
103
126
  variant: "ghost",
104
127
  size: "sm",
105
- onClick: G,
128
+ onClick: re,
106
129
  className: "h-8",
107
130
  "aria-label": "Go to today",
108
- children: N("calendar.today")
131
+ children: w("calendar.today")
109
132
  }),
110
- /* @__PURE__ */ A("div", { className: "h-4 w-px bg-border mx-1" }),
111
- /* @__PURE__ */ A(g, {
133
+ /* @__PURE__ */ I("div", { className: "h-4 w-px bg-border mx-1" }),
134
+ /* @__PURE__ */ I(g, {
112
135
  variant: "ghost",
113
136
  size: "icon",
114
137
  "aria-label": "Previous period",
115
- onClick: B,
138
+ onClick: te,
116
139
  className: "h-8 w-8",
117
- children: /* @__PURE__ */ A(p, { className: "h-4 w-4" })
140
+ children: /* @__PURE__ */ I(p, { className: "h-4 w-4" })
118
141
  }),
119
- /* @__PURE__ */ A(g, {
142
+ /* @__PURE__ */ I(g, {
120
143
  variant: "ghost",
121
144
  size: "icon",
122
145
  "aria-label": "Next period",
123
- onClick: V,
146
+ onClick: ne,
124
147
  className: "h-8 w-8",
125
- children: /* @__PURE__ */ A(m, { className: "h-4 w-4" })
148
+ children: /* @__PURE__ */ I(m, { className: "h-4 w-4" })
126
149
  })
127
150
  ]
128
- }), /* @__PURE__ */ j(y, { children: [/* @__PURE__ */ A(x, {
151
+ }), /* @__PURE__ */ L(E, { children: [/* @__PURE__ */ I(O, {
129
152
  asChild: !0,
130
- children: /* @__PURE__ */ j(g, {
153
+ children: /* @__PURE__ */ L(g, {
131
154
  variant: "ghost",
132
- "aria-label": `Current date: ${q()}`,
133
- className: D("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"),
134
- children: [/* @__PURE__ */ A(f, { className: "h-5 w-5 text-muted-foreground" }), /* @__PURE__ */ A("span", { children: q() })]
155
+ "aria-label": `Current date: ${R()}`,
156
+ 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"),
157
+ children: [/* @__PURE__ */ I(f, { className: "h-5 w-5 text-muted-foreground" }), /* @__PURE__ */ I("span", { children: R() })]
135
158
  })
136
- }), /* @__PURE__ */ A(b, {
159
+ }), /* @__PURE__ */ I(D, {
137
160
  className: "w-auto p-0",
138
161
  align: "start",
139
- children: /* @__PURE__ */ A(_, {
162
+ children: /* @__PURE__ */ I(_, {
140
163
  mode: "single",
141
- selected: k,
164
+ selected: S,
142
165
  onSelect: (e) => {
143
- e && (M(e), c?.(e));
166
+ e && (C(e), c?.(e));
144
167
  },
145
168
  initialFocus: !0,
146
169
  fromYear: 2e3,
147
170
  toYear: 2050
148
171
  })
149
172
  })] })]
150
- }), /* @__PURE__ */ j("div", {
173
+ }), /* @__PURE__ */ L("div", {
151
174
  className: "flex items-center gap-2",
152
- children: [/* @__PURE__ */ j(S, {
153
- value: v,
154
- onValueChange: K,
155
- children: [/* @__PURE__ */ A(T, {
175
+ children: [/* @__PURE__ */ L(k, {
176
+ value: b,
177
+ onValueChange: ie,
178
+ children: [/* @__PURE__ */ I(ee, {
156
179
  className: "w-32 bg-background",
157
- children: /* @__PURE__ */ A(E, {})
158
- }), /* @__PURE__ */ j(C, { children: [
159
- /* @__PURE__ */ A(w, {
180
+ children: /* @__PURE__ */ I(M, {})
181
+ }), /* @__PURE__ */ L(A, { children: [
182
+ /* @__PURE__ */ I(j, {
160
183
  value: "day",
161
- children: N("calendar.day")
184
+ children: w("calendar.day")
162
185
  }),
163
- /* @__PURE__ */ A(w, {
186
+ /* @__PURE__ */ I(j, {
164
187
  value: "week",
165
- children: N("calendar.week")
188
+ children: w("calendar.week")
166
189
  }),
167
- /* @__PURE__ */ A(w, {
190
+ /* @__PURE__ */ I(j, {
168
191
  value: "month",
169
- children: N("calendar.month")
192
+ children: w("calendar.month")
170
193
  })
171
194
  ] })]
172
- }), l && /* @__PURE__ */ j(g, {
195
+ }), l && /* @__PURE__ */ L(g, {
173
196
  onClick: l,
174
197
  size: "sm",
175
198
  className: "gap-1",
176
- children: [/* @__PURE__ */ A(h, { className: "h-4 w-4" }), N("calendar.newEvent")]
199
+ children: [/* @__PURE__ */ I(h, { className: "h-4 w-4" }), w("calendar.newEvent")]
177
200
  })]
178
201
  })]
179
- }), /* @__PURE__ */ j("div", {
202
+ }), /* @__PURE__ */ L("div", {
180
203
  className: "flex-1 overflow-auto",
181
204
  onTouchStart: (e) => {
182
- J.current = e.touches[0].clientX;
205
+ z.current = e.touches[0].clientX;
183
206
  },
184
207
  onTouchEnd: (e) => {
185
- let t = J.current - e.changedTouches[0].clientX;
208
+ let t = z.current - e.changedTouches[0].clientX;
186
209
  if (Math.abs(t) > 50) {
187
- let e = new Date(k);
188
- v === "day" ? e.setDate(e.getDate() + (t > 0 ? 1 : -1)) : v === "week" ? e.setDate(e.getDate() + (t > 0 ? 7 : -7)) : e.setMonth(e.getMonth() + (t > 0 ? 1 : -1)), M(e), c?.(e);
210
+ let e = new Date(S);
211
+ b === "day" ? e.setDate(e.getDate() + (t > 0 ? 1 : -1)) : b === "week" ? e.setDate(e.getDate() + (t > 0 ? 7 : -7)) : e.setMonth(e.getMonth() + (t > 0 ? 1 : -1)), C(e), c?.(e);
189
212
  }
190
213
  },
191
214
  children: [
192
- v === "month" && /* @__PURE__ */ A(H, {
193
- date: k,
215
+ b === "month" && /* @__PURE__ */ I(fe, {
216
+ date: S,
194
217
  events: t,
195
- locale: L,
218
+ locale: P,
196
219
  onEventClick: a,
197
220
  onDateClick: o,
198
221
  onEventDrop: u
199
222
  }),
200
- v === "week" && /* @__PURE__ */ A(U, {
201
- date: k,
223
+ b === "week" && /* @__PURE__ */ I(q, {
224
+ mode: "week",
225
+ date: S,
202
226
  events: t,
203
- locale: L,
227
+ locale: P,
228
+ slotMinutes: v,
204
229
  onEventClick: a,
205
- onDateClick: o
230
+ onEventDrop: u,
231
+ onTimeRangeSelect: d
206
232
  }),
207
- v === "day" && /* @__PURE__ */ A(W, {
208
- date: k,
233
+ b === "day" && /* @__PURE__ */ I(q, {
234
+ mode: "day",
235
+ date: S,
209
236
  events: t,
237
+ locale: P,
238
+ slotMinutes: v,
210
239
  onEventClick: a,
211
- onDateClick: o
240
+ onEventDrop: u,
241
+ onTimeRangeSelect: d
212
242
  })
213
243
  ]
214
244
  })]
215
245
  });
216
246
  }
217
- function R(e) {
247
+ function le(e) {
218
248
  let t = new Date(e), n = t.getDay(), r = t.getDate() - n;
219
249
  return t.setDate(r), t;
220
250
  }
221
- function z(e) {
251
+ function ue(e) {
222
252
  let t = e.getFullYear(), n = e.getMonth(), r = new Date(t, n, 1), i = new Date(t, n + 1, 0), a = r.getDay(), o = [];
223
253
  for (let e = a - 1; e >= 0; e--) {
224
254
  let t = new Date(r.getTime());
@@ -232,23 +262,11 @@ function z(e) {
232
262
  }
233
263
  return o;
234
264
  }
235
- function B(e, t) {
265
+ function de(e, t) {
236
266
  return e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth() && e.getDate() === t.getDate();
237
267
  }
238
- function V(e, t) {
239
- return t.filter((t) => {
240
- let n = new Date(t.start), r = t.end ? new Date(t.end) : new Date(n), i = new Date(e);
241
- i.setHours(0, 0, 0, 0);
242
- let a = new Date(e);
243
- a.setHours(23, 59, 59, 999);
244
- let o = new Date(n);
245
- o.setHours(0, 0, 0, 0);
246
- let s = new Date(r);
247
- return s.setHours(23, 59, 59, 999), i <= s && a >= o;
248
- });
249
- }
250
- function H({ date: t, events: n, locale: r = "default", onEventClick: i, onDateClick: a, onEventDrop: o }) {
251
- let s = e.useMemo(() => z(t), [t.getFullYear(), t.getMonth()]), c = e.useMemo(() => /* @__PURE__ */ new Date(), []), { t: l } = I(), u = e.useMemo(() => {
268
+ function fe({ date: t, events: n, locale: r = "default", onEventClick: i, onDateClick: a, onEventDrop: o }) {
269
+ let s = e.useMemo(() => ue(t), [t.getFullYear(), t.getMonth()]), c = e.useMemo(() => /* @__PURE__ */ new Date(), []), { t: l } = H(), u = e.useMemo(() => {
252
270
  let e = new Date(2024, 0, 7);
253
271
  return Array.from({ length: 7 }, (t, n) => {
254
272
  let i = new Date(e);
@@ -261,13 +279,24 @@ function H({ date: t, events: n, locale: r = "default", onEventClick: i, onDateC
261
279
  n.setHours(0, 0, 0, 0), r.setHours(0, 0, 0, 0);
262
280
  let i = new Date(n);
263
281
  for (; i <= r;) {
264
- let n = `${i.getFullYear()}-${i.getMonth()}-${i.getDate()}`, r = e.get(n);
265
- r ? r.push(t) : e.set(n, [t]), i.setDate(i.getDate() + 1);
282
+ let a = `${i.getFullYear()}-${i.getMonth()}-${i.getDate()}`, o = i.getTime() === n.getTime(), s = i.getTime() === r.getTime(), c = o || s || i.getDay() === 0, l = e.get(a), u = {
283
+ event: t,
284
+ isTitleDay: c,
285
+ isSpanStart: o,
286
+ isSpanEnd: s
287
+ };
288
+ l ? l.push(u) : e.set(a, [u]), i.setDate(i.getDate() + 1);
266
289
  }
267
290
  }
268
291
  return e;
269
- }, [n]), g = (e, t) => {
270
- f(t.id), e.dataTransfer.effectAllowed = "move", e.dataTransfer.setData("text/plain", String(t.id));
292
+ }, [n]), g = (e, t, n = "move", r) => {
293
+ f(t.id), e.dataTransfer.effectAllowed = "move";
294
+ let i = {
295
+ id: t.id,
296
+ mode: n,
297
+ ...r ? { sourceDay: `${r.getFullYear()}-${r.getMonth()}-${r.getDate()}` } : {}
298
+ };
299
+ e.dataTransfer.setData("text/plain", JSON.stringify(i)), n === "resize-end" && e.stopPropagation();
271
300
  }, _ = () => {
272
301
  f(null), m(null);
273
302
  }, v = (e, t) => {
@@ -276,34 +305,55 @@ function H({ date: t, events: n, locale: r = "default", onEventClick: i, onDateC
276
305
  e.currentTarget.contains(e.relatedTarget) || m(null);
277
306
  }, b = (e, t) => {
278
307
  if (e.preventDefault(), m(null), f(null), !o) return;
279
- let r = e.dataTransfer.getData("text/plain"), i = n.find((e) => String(e.id) === r);
280
- if (!i) return;
281
- let a = new Date(i.start), s = new Date(a);
282
- s.setHours(0, 0, 0, 0);
283
- let c = new Date(t);
284
- c.setHours(0, 0, 0, 0);
285
- let l = c.getTime() - s.getTime();
286
- if (l === 0) return;
287
- let u = new Date(a.getTime() + l), d;
288
- i.end && (d = new Date(new Date(i.end).getTime() + l)), o(i, u, d);
308
+ let r = e.dataTransfer.getData("text/plain"), i;
309
+ try {
310
+ i = JSON.parse(r);
311
+ } catch {
312
+ i = {
313
+ id: r,
314
+ mode: "move"
315
+ };
316
+ }
317
+ let a = n.find((e) => String(e.id) === String(i.id));
318
+ if (!a) return;
319
+ let s = new Date(t);
320
+ if (s.setHours(0, 0, 0, 0), i.mode === "resize-end") {
321
+ let e = a.end ? new Date(a.end) : new Date(a.start), t = new Date(e);
322
+ if (t.setHours(0, 0, 0, 0), s.getTime() === t.getTime()) return;
323
+ let n = new Date(a.start);
324
+ if (n.setHours(0, 0, 0, 0), s.getTime() < n.getTime()) return;
325
+ let r = new Date(s);
326
+ r.setHours(e.getHours(), e.getMinutes(), e.getSeconds(), 0), o(a, new Date(a.start), r);
327
+ return;
328
+ }
329
+ let c = new Date(a.start), l;
330
+ if (i.sourceDay) {
331
+ let [e, t, n] = i.sourceDay.split("-").map((e) => parseInt(e, 10));
332
+ l = new Date(e, t, n);
333
+ } else l = new Date(c);
334
+ l.setHours(0, 0, 0, 0);
335
+ let u = s.getTime() - l.getTime();
336
+ if (u === 0) return;
337
+ let d = new Date(c.getTime() + u), p;
338
+ a.end && (p = new Date(new Date(a.end).getTime() + u)), o(a, d, p);
289
339
  };
290
- return /* @__PURE__ */ j("div", {
340
+ return /* @__PURE__ */ L("div", {
291
341
  className: "flex flex-col h-full",
292
- children: [/* @__PURE__ */ A("div", {
342
+ children: [/* @__PURE__ */ I("div", {
293
343
  role: "row",
294
344
  className: "grid grid-cols-7 border-b",
295
- children: u.map((e) => /* @__PURE__ */ A("div", {
345
+ children: u.map((e) => /* @__PURE__ */ I("div", {
296
346
  role: "columnheader",
297
347
  className: "p-2 text-center text-sm font-medium text-muted-foreground border-r last:border-r-0",
298
348
  children: e
299
349
  }, e))
300
- }), /* @__PURE__ */ A("div", {
350
+ }), /* @__PURE__ */ I("div", {
301
351
  role: "grid",
302
352
  "aria-label": "Calendar grid",
303
353
  className: "grid grid-cols-7 flex-1 auto-rows-fr",
304
354
  children: s.map((e, n) => {
305
- let r = `${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`, s = h.get(r) || [], u = e.getMonth() === t.getMonth(), f = B(e, c);
306
- return /* @__PURE__ */ j("div", {
355
+ let r = `${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`, s = h.get(r) || [], u = e.getMonth() === t.getMonth(), f = de(e, c);
356
+ return /* @__PURE__ */ L("div", {
307
357
  role: "gridcell",
308
358
  "aria-label": `${e.toLocaleDateString("default", {
309
359
  weekday: "long",
@@ -311,33 +361,45 @@ function H({ date: t, events: n, locale: r = "default", onEventClick: i, onDateC
311
361
  day: "numeric",
312
362
  year: "numeric"
313
363
  })}${s.length > 0 ? `, ${s.length} event${s.length > 1 ? "s" : ""}` : ""}`,
314
- className: D("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"),
364
+ className: N("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"),
315
365
  onClick: () => a?.(e),
316
366
  onDragOver: (e) => v(e, n),
317
367
  onDragLeave: y,
318
368
  onDrop: (t) => b(t, e),
319
- children: [/* @__PURE__ */ A("div", {
320
- className: D("text-sm font-medium mb-2", f && "inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-6 w-6"),
369
+ children: [/* @__PURE__ */ I("div", {
370
+ className: N("text-sm font-medium mb-2", f && "inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-6 w-6"),
321
371
  ...f ? { "aria-current": "date" } : {},
322
372
  children: e.getDate()
323
- }), /* @__PURE__ */ j("div", {
324
- className: "space-y-1",
325
- children: [s.slice(0, 3).map((e) => /* @__PURE__ */ A("div", {
326
- role: "button",
327
- title: e.title,
328
- "aria-label": e.title,
329
- draggable: !!o,
330
- onDragStart: (t) => g(t, e),
331
- onDragEnd: _,
332
- className: D("text-xs px-2 py-1 rounded truncate cursor-pointer hover:opacity-80", e.color?.startsWith("#") ? "text-white" : e.color || N, d === e.id && "opacity-50"),
333
- style: e.color && e.color.startsWith("#") ? { backgroundColor: e.color } : void 0,
334
- onClick: (t) => {
335
- t.stopPropagation(), i?.(e);
336
- },
337
- children: e.title
338
- }, e.id)), s.length > 3 && /* @__PURE__ */ A("div", {
373
+ }), /* @__PURE__ */ L("div", {
374
+ className: "space-y-0.5",
375
+ children: [s.slice(0, 4).map(({ event: t, isTitleDay: n, isSpanStart: r, isSpanEnd: a }, s) => {
376
+ let c = !n, { className: l, inlineColor: u } = B(t.color), f = !!o && a;
377
+ return /* @__PURE__ */ L("div", {
378
+ role: "button",
379
+ title: t.title,
380
+ "aria-label": t.title,
381
+ draggable: !!o,
382
+ onDragStart: (n) => g(n, t, "move", e),
383
+ onDragEnd: _,
384
+ className: N("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"),
385
+ style: u ? { backgroundColor: u } : void 0,
386
+ onClick: (e) => {
387
+ e.stopPropagation(), i?.(t);
388
+ },
389
+ children: [c ? "" : t.title, f && /* @__PURE__ */ I("span", {
390
+ role: "separator",
391
+ "aria-label": "Resize event end",
392
+ title: "Drag to change end date",
393
+ draggable: !0,
394
+ onDragStart: (n) => g(n, t, "resize-end", e),
395
+ onDragEnd: _,
396
+ onClick: (e) => e.stopPropagation(),
397
+ className: "absolute inset-y-0 right-0 w-2 cursor-ew-resize bg-black/25 hover:bg-black/50 rounded-r"
398
+ })]
399
+ }, `${t.id}-${s}`);
400
+ }), s.length > 4 && /* @__PURE__ */ I("div", {
339
401
  className: "text-xs text-muted-foreground px-2",
340
- children: l("calendar.moreEvents", { count: s.length - 3 })
402
+ children: l("calendar.moreEvents", { count: s.length - 4 })
341
403
  })]
342
404
  })]
343
405
  }, n);
@@ -345,134 +407,437 @@ function H({ date: t, events: n, locale: r = "default", onEventClick: i, onDateC
345
407
  })]
346
408
  });
347
409
  }
348
- function U({ date: t, events: n, locale: r = "default", onEventClick: i, onDateClick: a }) {
349
- let o = e.useRef(null), s = (e) => {
350
- a && (o.current = setTimeout(() => {
351
- a(e);
352
- }, 500));
353
- }, c = () => {
354
- o.current &&= (clearTimeout(o.current), null);
355
- }, l = R(t), u = Array.from({ length: 7 }, (e, t) => {
356
- let n = new Date(l);
357
- return n.setDate(n.getDate() + t), n;
358
- }), d = /* @__PURE__ */ new Date();
359
- return /* @__PURE__ */ j("div", {
410
+ var U = 48;
411
+ function W(e) {
412
+ let t = new Date(e);
413
+ return t.setHours(0, 0, 0, 0), t;
414
+ }
415
+ function G(e) {
416
+ return e.getHours() * 60 + e.getMinutes();
417
+ }
418
+ function K(e) {
419
+ return `${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`;
420
+ }
421
+ function q({ mode: t, date: n, events: r, locale: i = "default", slotMinutes: a = 30, onEventClick: o, onEventDrop: s, onTimeRangeSelect: c }) {
422
+ let { t: l } = H(), u = U * a / 60, d = U * 24, f = e.useMemo(() => {
423
+ if (t === "day") return [W(n)];
424
+ let e = le(n);
425
+ return Array.from({ length: 7 }, (t, n) => {
426
+ let r = new Date(e);
427
+ return r.setDate(e.getDate() + n), W(r);
428
+ });
429
+ }, [
430
+ t,
431
+ n.getFullYear(),
432
+ n.getMonth(),
433
+ n.getDate()
434
+ ]), p = e.useMemo(() => /* @__PURE__ */ new Date(), []), m = e.useCallback((e) => {
435
+ if (e.allDay) return !0;
436
+ 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();
437
+ return !!(r && i || a >= 1440 * 60 * 1e3);
438
+ }, []), { allDayEvents: h, timedEvents: g } = e.useMemo(() => {
439
+ let e = [], t = [];
440
+ for (let n of r) m(n) ? e.push(n) : t.push(n);
441
+ return {
442
+ allDayEvents: e,
443
+ timedEvents: t
444
+ };
445
+ }, [r, m]), _ = e.useMemo(() => {
446
+ let e = /* @__PURE__ */ new Map();
447
+ for (let t of f) e.set(K(t), []);
448
+ for (let t of h) {
449
+ let n = W(new Date(t.start)), r = t.end ? new Date(t.end) : new Date(t.start), i = W(r);
450
+ r.getHours() === 0 && r.getMinutes() === 0 && r.getSeconds() === 0 && r.getTime() > n.getTime() && (i = new Date(i), i.setDate(i.getDate() - 1));
451
+ for (let r of f) {
452
+ let a = W(r);
453
+ a < n || a > i || e.get(K(r)).push({
454
+ event: t,
455
+ isStart: a.getTime() === n.getTime(),
456
+ isEnd: a.getTime() === i.getTime()
457
+ });
458
+ }
459
+ }
460
+ return e;
461
+ }, [f, h]), v = e.useMemo(() => {
462
+ let e = /* @__PURE__ */ new Map();
463
+ for (let t of f) e.set(K(t), []);
464
+ for (let t of g) {
465
+ let n = new Date(t.start), r = t.end ? new Date(t.end) : new Date(n.getTime() + 3600 * 1e3);
466
+ for (let i of f) {
467
+ let a = W(i), o = new Date(a);
468
+ if (o.setDate(o.getDate() + 1), r <= a || n >= o) continue;
469
+ let s = n < a ? a : n, c = r > o ? o : r, l = G(s), u = c.getTime() === o.getTime() ? 1440 : G(c);
470
+ e.get(K(i)).push({
471
+ event: t,
472
+ startMin: l,
473
+ endMin: Math.max(u, l + 15),
474
+ isStart: s.getTime() === n.getTime(),
475
+ isEnd: c.getTime() === r.getTime()
476
+ });
477
+ }
478
+ }
479
+ return e;
480
+ }, [f, g]), y = e.useMemo(() => {
481
+ let e = /* @__PURE__ */ new Map();
482
+ for (let [t, n] of v) {
483
+ let r = [...n].sort((e, t) => e.startMin - t.startMin || e.endMin - t.endMin), i = [], a = [], o = [];
484
+ for (let e of r) {
485
+ let t = 0;
486
+ for (; i[t] && i[t].endMin > e.startMin;) t++;
487
+ i[t] = { endMin: e.endMin }, a.push({
488
+ entry: e,
489
+ col: t
490
+ });
491
+ }
492
+ for (let e = 0; e < a.length; e++) {
493
+ let t = a[e], n = t.col;
494
+ for (let r = 0; r < a.length; r++) {
495
+ if (r === e) continue;
496
+ let i = a[r];
497
+ i.entry.startMin < t.entry.endMin && i.entry.endMin > t.entry.startMin && i.col > n && (n = i.col);
498
+ }
499
+ o.push({
500
+ ...t.entry,
501
+ col: t.col,
502
+ cols: n + 1
503
+ });
504
+ }
505
+ e.set(t, o);
506
+ }
507
+ return e;
508
+ }, [v]), b = e.useRef(null), x = e.useRef([]), [S, C] = e.useState(null), w = e.useRef(null);
509
+ w.current = S;
510
+ let T = e.useRef(!1), E = e.useCallback((e, t) => {
511
+ let n = x.current[t];
512
+ if (!n) return 0;
513
+ let r = (e - n.getBoundingClientRect().top + n.scrollTop) / U * 60, i = Math.round(r / a) * a;
514
+ return Math.max(0, Math.min(1440, i));
515
+ }, [a]), D = e.useCallback((e) => {
516
+ for (let t = 0; t < x.current.length; t++) {
517
+ let n = x.current[t];
518
+ if (!n) continue;
519
+ let r = n.getBoundingClientRect();
520
+ if (e >= r.left && e <= r.right) return t;
521
+ }
522
+ return -1;
523
+ }, []);
524
+ e.useEffect(() => {
525
+ if (!S) return;
526
+ let e = (e) => {
527
+ let t = S.kind === "select" || S.kind === "move" ? D(e.clientX) : S.dayIndex, n = t < 0 ? S.dayIndex ?? 0 : t, r = E(e.clientY, n);
528
+ C((e) => e && (e.kind === "select" ? {
529
+ ...e,
530
+ dayIndex: n >= 0 ? n : e.dayIndex,
531
+ headMinutes: r
532
+ } : e.kind === "move" ? {
533
+ ...e,
534
+ dayIndex: n,
535
+ minutes: r
536
+ } : {
537
+ ...e,
538
+ minutes: r
539
+ }));
540
+ }, t = (e) => {
541
+ let t = w.current;
542
+ if (!t) {
543
+ C(null);
544
+ return;
545
+ }
546
+ try {
547
+ if (t.kind === "select" && c) {
548
+ let e = Math.min(t.anchorMinutes, t.headMinutes), n = Math.max(t.anchorMinutes, t.headMinutes), r = e, i = n === e ? Math.min(1440, e + a) : n, o = f[t.dayIndex] ?? f[0], s = new Date(o);
549
+ s.setHours(0, Math.round(r), 0, 0);
550
+ let l = new Date(o);
551
+ l.setHours(0, Math.round(i), 0, 0), T.current = !0, c(s, l);
552
+ } else if (t.kind === "move" && s) {
553
+ let e = r.find((e) => String(e.id) === String(t.eventId));
554
+ if (e) {
555
+ let n = t.dayIndex < 0 ? 0 : t.dayIndex, r = t.minutes - t.grabMinuteOffset, i = Math.max(0, Math.min(1440 - t.durationMin, Math.round(r / a) * a)), o = f[n] ?? f[0], c = new Date(o);
556
+ c.setHours(0, i, 0, 0);
557
+ let l = new Date(c.getTime() + t.durationMin * 60 * 1e3);
558
+ T.current = !0, s(e, c, l);
559
+ }
560
+ } else if (t.kind === "resize-top" && s) {
561
+ let e = r.find((e) => String(e.id) === String(t.eventId));
562
+ if (e) {
563
+ let n = f[t.dayIndex] ?? f[0], r = Math.min(t.anchorEndMin - a, Math.max(0, t.minutes)), i = new Date(n);
564
+ i.setHours(0, r, 0, 0);
565
+ let o = new Date(n);
566
+ o.setHours(0, t.anchorEndMin, 0, 0), T.current = !0, s(e, i, o);
567
+ }
568
+ } else if (t.kind === "resize-bottom" && s) {
569
+ let e = r.find((e) => String(e.id) === String(t.eventId));
570
+ if (e) {
571
+ let n = f[t.dayIndex] ?? f[0], r = Math.max(t.anchorStartMin + a, Math.min(1440, t.minutes)), i = new Date(n);
572
+ i.setHours(0, t.anchorStartMin, 0, 0);
573
+ let o = new Date(n);
574
+ o.setHours(0, r, 0, 0), T.current = !0, s(e, i, o);
575
+ }
576
+ }
577
+ } finally {
578
+ C(null), setTimeout(() => {
579
+ T.current = !1;
580
+ }, 50);
581
+ }
582
+ };
583
+ return window.addEventListener("pointermove", e), window.addEventListener("pointerup", t), () => {
584
+ window.removeEventListener("pointermove", e), window.removeEventListener("pointerup", t);
585
+ };
586
+ }, [
587
+ S,
588
+ f,
589
+ r,
590
+ a,
591
+ s,
592
+ c,
593
+ D,
594
+ E
595
+ ]);
596
+ let O = e.useMemo(() => f.map((e) => ({
597
+ weekday: e.toLocaleDateString(i, { weekday: "short" }),
598
+ day: e.getDate(),
599
+ month: e.toLocaleDateString(i, { month: "short" }),
600
+ isToday: de(e, p)
601
+ })), [
602
+ f,
603
+ i,
604
+ p
605
+ ]), k = e.useMemo(() => Array.from({ length: 24 }, (e, t) => new Date(2024, 0, 1, t, 0).toLocaleTimeString(i, { hour: "numeric" })), [i]), A = (e, t, n, r) => {
606
+ if (!s || e.button !== 0) return;
607
+ e.stopPropagation(), e.preventDefault();
608
+ let i = E(e.clientY, n);
609
+ C(r === "body" ? {
610
+ kind: "move",
611
+ eventId: t.event.id,
612
+ grabMinuteOffset: Math.max(0, i - t.startMin),
613
+ durationMin: t.endMin - t.startMin,
614
+ dayIndex: n,
615
+ minutes: i
616
+ } : r === "top" ? {
617
+ kind: "resize-top",
618
+ eventId: t.event.id,
619
+ anchorEndMin: t.endMin,
620
+ dayIndex: n,
621
+ minutes: i
622
+ } : {
623
+ kind: "resize-bottom",
624
+ eventId: t.event.id,
625
+ anchorStartMin: t.startMin,
626
+ dayIndex: n,
627
+ minutes: i
628
+ });
629
+ }, j = (e, t) => {
630
+ if (!c || e.button !== 0) return;
631
+ e.preventDefault();
632
+ let n = E(e.clientY, t);
633
+ C({
634
+ kind: "select",
635
+ dayIndex: t,
636
+ anchorMinutes: n,
637
+ headMinutes: n
638
+ });
639
+ }, ee = (e) => {
640
+ if (!S) return null;
641
+ if (S.kind === "select" && S.dayIndex === e) {
642
+ let t = Math.min(S.anchorMinutes, S.headMinutes), n = Math.max(S.anchorMinutes, S.headMinutes);
643
+ return /* @__PURE__ */ I("div", {
644
+ className: "absolute left-1 right-1 rounded bg-primary/30 border border-primary pointer-events-none z-10",
645
+ style: {
646
+ top: t / 60 * U,
647
+ height: Math.max(u, (n - t) / 60 * U)
648
+ },
649
+ "aria-hidden": !0,
650
+ children: /* @__PURE__ */ I("div", {
651
+ className: "px-2 py-0.5 text-xs font-medium text-primary",
652
+ children: J(f[e], t, n, i)
653
+ })
654
+ });
655
+ }
656
+ if (S.kind === "move" && S.dayIndex === e) {
657
+ let t = S.minutes - S.grabMinuteOffset, n = Math.max(0, Math.min(1440 - S.durationMin, Math.round(t / a) * a));
658
+ return /* @__PURE__ */ I("div", {
659
+ className: "absolute left-1 right-1 rounded border-2 border-dashed border-primary bg-primary/10 pointer-events-none z-10",
660
+ style: {
661
+ top: n / 60 * U,
662
+ height: S.durationMin / 60 * U
663
+ },
664
+ "aria-hidden": !0,
665
+ children: /* @__PURE__ */ I("div", {
666
+ className: "px-2 py-0.5 text-xs font-medium text-primary",
667
+ children: J(f[e], n, n + S.durationMin, i)
668
+ })
669
+ });
670
+ }
671
+ if ((S.kind === "resize-top" || S.kind === "resize-bottom") && S.dayIndex === e) {
672
+ let t, n;
673
+ return S.kind === "resize-top" ? (t = Math.min(S.anchorEndMin - a, Math.max(0, S.minutes)), n = S.anchorEndMin) : (t = S.anchorStartMin, n = Math.max(S.anchorStartMin + a, Math.min(1440, S.minutes))), /* @__PURE__ */ I("div", {
674
+ className: "absolute left-1 right-1 rounded border-2 border-dashed border-primary bg-primary/10 pointer-events-none z-10",
675
+ style: {
676
+ top: t / 60 * U,
677
+ height: (n - t) / 60 * U
678
+ },
679
+ "aria-hidden": !0,
680
+ children: /* @__PURE__ */ I("div", {
681
+ className: "px-2 py-0.5 text-xs font-medium text-primary",
682
+ children: J(f[e], t, n, i)
683
+ })
684
+ });
685
+ }
686
+ return null;
687
+ };
688
+ return /* @__PURE__ */ L("div", {
360
689
  className: "flex flex-col h-full",
361
- children: [/* @__PURE__ */ A("div", {
362
- className: "grid grid-cols-7 border-b",
363
- children: u.map((e) => {
364
- let t = B(e, d);
365
- return /* @__PURE__ */ j("div", {
366
- className: "p-3 text-center border-r last:border-r-0",
367
- children: [/* @__PURE__ */ A("div", {
368
- className: "text-sm font-medium text-muted-foreground",
369
- children: e.toLocaleDateString(r, { weekday: "short" })
370
- }), /* @__PURE__ */ A("div", {
371
- className: D("text-lg font-semibold mt-1", t && "inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-8 w-8"),
372
- children: e.getDate()
690
+ ref: b,
691
+ children: [
692
+ /* @__PURE__ */ L("div", {
693
+ className: "flex border-b sticky top-0 bg-background z-20",
694
+ children: [/* @__PURE__ */ I("div", {
695
+ className: "w-14 shrink-0 border-r",
696
+ "aria-hidden": !0
697
+ }), O.map((e, t) => /* @__PURE__ */ L("div", {
698
+ role: "columnheader",
699
+ className: N("flex-1 p-2 text-center text-sm border-r last:border-r-0", e.isToday && "bg-primary/5"),
700
+ children: [/* @__PURE__ */ I("div", {
701
+ className: "text-xs text-muted-foreground",
702
+ children: e.weekday
703
+ }), /* @__PURE__ */ I("div", {
704
+ 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"),
705
+ children: e.day
373
706
  })]
374
- }, e.toISOString());
375
- })
376
- }), /* @__PURE__ */ A("div", {
377
- role: "grid",
378
- className: "grid grid-cols-7 flex-1",
379
- children: u.map((e) => {
380
- let t = V(e, n);
381
- return /* @__PURE__ */ A("div", {
382
- role: "gridcell",
383
- "aria-label": `${e.toLocaleDateString("default", {
384
- weekday: "long",
385
- month: "long",
386
- day: "numeric",
387
- year: "numeric"
388
- })}${t.length > 0 ? `, ${t.length} event${t.length > 1 ? "s" : ""}` : ""}`,
389
- className: "border-r last:border-r-0 p-2 min-h-[400px] cursor-pointer hover:bg-accent/50",
390
- onClick: () => a?.(e),
391
- onTouchStart: () => s(e),
392
- onTouchEnd: c,
393
- children: /* @__PURE__ */ A("div", {
394
- className: "space-y-2",
395
- children: t.map((e) => /* @__PURE__ */ j("div", {
396
- role: "button",
397
- title: e.title,
398
- "aria-label": e.title,
399
- className: D("text-xs sm:text-sm px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80", e.color?.startsWith("#") ? "text-white" : e.color || N),
400
- style: e.color && e.color.startsWith("#") ? { backgroundColor: e.color } : void 0,
401
- onClick: (t) => {
402
- t.stopPropagation(), i?.(e);
707
+ }, t))]
708
+ }),
709
+ h.length > 0 && /* @__PURE__ */ L("div", {
710
+ className: "flex border-b bg-muted/20 max-h-[140px] overflow-y-auto",
711
+ children: [/* @__PURE__ */ I("div", {
712
+ className: "w-14 shrink-0 border-r flex items-start justify-end pr-1 pt-1 text-[10px] text-muted-foreground sticky left-0 bg-muted/20",
713
+ children: l("calendar.allDay") === "calendar.allDay" ? "all-day" : l("calendar.allDay")
714
+ }), f.map((e) => {
715
+ let t = K(e);
716
+ return /* @__PURE__ */ I("div", {
717
+ className: "flex-1 border-r last:border-r-0 min-h-[28px] p-0.5 space-y-0.5",
718
+ children: (_.get(t) ?? []).map(({ event: e, isStart: t, isEnd: n }, r) => {
719
+ let { className: i, inlineColor: a } = B(e.color);
720
+ return /* @__PURE__ */ I("div", {
721
+ role: "button",
722
+ title: e.title,
723
+ onClick: (t) => {
724
+ t.stopPropagation(), o?.(e);
725
+ },
726
+ 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),
727
+ style: a ? { backgroundColor: a } : void 0,
728
+ children: t ? e.title : "\xA0"
729
+ }, `${e.id}-${r}`);
730
+ })
731
+ }, t);
732
+ })]
733
+ }),
734
+ /* @__PURE__ */ I("div", {
735
+ className: "flex-1 overflow-auto",
736
+ children: /* @__PURE__ */ L("div", {
737
+ className: "flex",
738
+ style: { height: d },
739
+ children: [/* @__PURE__ */ I("div", {
740
+ className: "w-14 shrink-0 border-r relative",
741
+ children: k.map((e, t) => /* @__PURE__ */ I("div", {
742
+ className: "absolute right-1 text-[10px] text-muted-foreground -translate-y-1/2",
743
+ style: { top: t * U },
744
+ children: t === 0 ? "" : e
745
+ }, t))
746
+ }), f.map((e, t) => {
747
+ let n = K(e), r = y.get(n) ?? [];
748
+ return /* @__PURE__ */ L("div", {
749
+ ref: (e) => {
750
+ x.current[t] = e;
403
751
  },
404
- children: [/* @__PURE__ */ A("div", {
405
- className: "font-medium truncate",
406
- children: e.title
407
- }), !e.allDay && /* @__PURE__ */ A("div", {
408
- className: "text-xs opacity-90 mt-1",
409
- children: e.start.toLocaleTimeString("default", {
410
- hour: "numeric",
411
- minute: "2-digit"
412
- })
413
- })]
414
- }, e.id))
415
- })
416
- }, e.toISOString());
752
+ className: "flex-1 border-r last:border-r-0 relative select-none",
753
+ style: { height: d },
754
+ onPointerDown: (e) => j(e, t),
755
+ "aria-label": e.toLocaleDateString(i, {
756
+ weekday: "long",
757
+ month: "long",
758
+ day: "numeric",
759
+ year: "numeric"
760
+ }),
761
+ children: [
762
+ Array.from({ length: 24 }, (e, t) => /* @__PURE__ */ I("div", {
763
+ className: "absolute left-0 right-0 border-t border-muted/60 pointer-events-none",
764
+ style: { top: t * U }
765
+ }, t)),
766
+ a < 60 && Array.from({ length: Math.floor(1440 / a) }, (e, t) => {
767
+ let n = t * a;
768
+ return n % 60 == 0 ? null : /* @__PURE__ */ I("div", {
769
+ className: "absolute left-0 right-0 border-t border-dashed border-muted/30 pointer-events-none",
770
+ style: { top: n / 60 * U }
771
+ }, t);
772
+ }),
773
+ r.map((n) => {
774
+ let r = n.startMin / 60 * U, a = Math.max(u, (n.endMin - n.startMin) / 60 * U), c = 100 / n.cols, l = n.col * c, { className: d, inlineColor: f } = B(n.event.color), p = S && S.eventId === n.event.id;
775
+ return /* @__PURE__ */ L("div", {
776
+ role: "button",
777
+ tabIndex: 0,
778
+ title: n.event.title,
779
+ "aria-label": n.event.title,
780
+ onPointerDown: (e) => A(e, n, t, "body"),
781
+ onClick: (e) => {
782
+ if (T.current) {
783
+ e.stopPropagation();
784
+ return;
785
+ }
786
+ e.stopPropagation(), o?.(n.event);
787
+ },
788
+ className: N("absolute rounded text-xs px-2 py-1 overflow-hidden shadow-sm", s ? "cursor-move" : "cursor-pointer", d, p && "opacity-40"),
789
+ style: {
790
+ top: r,
791
+ height: a,
792
+ left: `calc(${l}% + 2px)`,
793
+ width: `calc(${c}% - 4px)`,
794
+ ...f ? { backgroundColor: f } : {}
795
+ },
796
+ children: [
797
+ /* @__PURE__ */ I("div", {
798
+ className: "font-medium truncate",
799
+ children: n.event.title
800
+ }),
801
+ /* @__PURE__ */ I("div", {
802
+ className: "text-[10px] opacity-80 truncate",
803
+ children: J(e, n.startMin, n.endMin, i)
804
+ }),
805
+ s && n.isStart && /* @__PURE__ */ I("div", {
806
+ onPointerDown: (e) => A(e, n, t, "top"),
807
+ className: "absolute top-0 left-0 right-0 h-1.5 cursor-ns-resize",
808
+ "aria-label": "Resize start"
809
+ }),
810
+ s && n.isEnd && /* @__PURE__ */ I("div", {
811
+ onPointerDown: (e) => A(e, n, t, "bottom"),
812
+ className: "absolute bottom-0 left-0 right-0 h-1.5 cursor-ns-resize",
813
+ "aria-label": "Resize end"
814
+ })
815
+ ]
816
+ }, `${n.event.id}-${n.startMin}`);
817
+ }),
818
+ ee(t)
819
+ ]
820
+ }, n);
821
+ })]
822
+ })
417
823
  })
418
- })]
824
+ ]
419
825
  });
420
826
  }
421
- function W({ date: t, events: n, onEventClick: r, onDateClick: i }) {
422
- let a = V(t, n), o = Array.from({ length: 24 }, (e, t) => t), s = e.useRef(null), c = (e) => {
423
- i && (s.current = setTimeout(() => {
424
- let n = new Date(t);
425
- n.setHours(e, 0, 0, 0), i(n);
426
- }, 500));
427
- }, l = () => {
428
- s.current &&= (clearTimeout(s.current), null);
429
- };
430
- return /* @__PURE__ */ A("div", {
431
- className: "flex flex-col h-full",
432
- children: /* @__PURE__ */ A("div", {
433
- role: "list",
434
- className: "flex-1 overflow-auto",
435
- children: o.map((e) => {
436
- let t = a.filter((t) => t.allDay ? e === 0 : t.start.getHours() === e);
437
- return /* @__PURE__ */ j("div", {
438
- role: "listitem",
439
- className: "flex border-b min-h-[60px]",
440
- children: [/* @__PURE__ */ A("div", {
441
- className: "w-20 p-2 text-sm text-muted-foreground border-r",
442
- children: e === 0 ? "12 AM" : e < 12 ? `${e} AM` : e === 12 ? "12 PM" : `${e - 12} PM`
443
- }), /* @__PURE__ */ A("div", {
444
- className: "flex-1 p-2 space-y-2",
445
- onTouchStart: () => c(e),
446
- onTouchEnd: l,
447
- children: t.map((e) => /* @__PURE__ */ j("div", {
448
- title: e.title,
449
- "aria-label": e.title,
450
- className: D("px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80", e.color?.startsWith("#") ? "text-white" : e.color || N),
451
- style: e.color && e.color.startsWith("#") ? { backgroundColor: e.color } : void 0,
452
- onClick: () => r?.(e),
453
- children: [/* @__PURE__ */ A("div", {
454
- className: "font-medium truncate",
455
- children: e.title
456
- }), !e.allDay && /* @__PURE__ */ j("div", {
457
- className: "text-xs opacity-90 mt-1",
458
- children: [e.start.toLocaleTimeString("default", {
459
- hour: "numeric",
460
- minute: "2-digit"
461
- }), e.end && ` - ${e.end.toLocaleTimeString("default", {
462
- hour: "numeric",
463
- minute: "2-digit"
464
- })}`]
465
- })]
466
- }, e.id))
467
- })]
468
- }, e);
469
- })
470
- })
827
+ function J(e, t, n, r) {
828
+ let i = new Date(e);
829
+ i.setHours(0, Math.round(t), 0, 0);
830
+ let a = new Date(e);
831
+ a.setHours(0, Math.round(n), 0, 0);
832
+ let o = (e) => e.toLocaleTimeString(r, {
833
+ hour: "numeric",
834
+ minute: "2-digit"
471
835
  });
836
+ return `${o(i)} – ${o(a)}`;
472
837
  }
473
838
  //#endregion
474
839
  //#region src/ObjectCalendar.tsx
475
- function G(e) {
840
+ function pe(e) {
476
841
  return "data" in e && e.data ? e.data : "staticData" in e && e.staticData ? {
477
842
  provider: "value",
478
843
  items: e.staticData
@@ -481,7 +846,7 @@ function G(e) {
481
846
  object: e.objectName
482
847
  } : null;
483
848
  }
484
- function K(e) {
849
+ function me(e) {
485
850
  if (e) {
486
851
  if (typeof e == "string") {
487
852
  let t = e.split(" "), n = t[0], r = t[1]?.toLowerCase() === "desc" ? "desc" : "asc";
@@ -490,7 +855,7 @@ function K(e) {
490
855
  if (Array.isArray(e)) return e.reduce((e, t) => (t.field && t.order && (e[t.field] = t.order), e), {});
491
856
  }
492
857
  }
493
- function q(e) {
858
+ function he(e) {
494
859
  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 ? {
495
860
  startDateField: e.startDateField || e.dateField,
496
861
  endDateField: e.endDateField || e.endField,
@@ -499,86 +864,86 @@ function q(e) {
499
864
  allDayField: e.allDayField
500
865
  } : null;
501
866
  }
502
- var J = ({ schema: e, dataSource: t, className: s, data: d, loading: f, onEventClick: p, onRowClick: m, onDateClick: h, onNavigate: g, onViewChange: _, onEventDrop: y, locale: b }) => {
503
- let x = Array.isArray(d), [S, C] = o(x ? d : []), [w, T] = o(x ? f ?? !1 : !0), [E, D] = o(null), [k, N] = o(null), [P, F] = o(/* @__PURE__ */ new Date()), I = O(), R = e.defaultView, [z, B] = o(() => {
504
- let e = R === "day" || !R;
505
- return typeof window < "u" && window.innerWidth < 768 && e ? "month" : R || "month";
867
+ var Y = ({ schema: e, dataSource: t, className: s, data: d, loading: f, onEventClick: p, onRowClick: m, onDateClick: h, onNavigate: _, onViewChange: E, onEventDrop: D, locale: O }) => {
868
+ let k = Array.isArray(d), [A, j] = o(k ? d : []), [ee, M] = o(k ? f ?? !1 : !0), [N, F] = o(null), [R, ae] = o(null), [z, oe] = o(/* @__PURE__ */ new Date()), se = P(), B = e.defaultView, [V, H] = o(() => {
869
+ let e = B === "day" || !B;
870
+ return typeof window < "u" && window.innerWidth < 768 && e ? "month" : B || "month";
506
871
  });
507
872
  r(() => {
508
- I && z === "day" && (R === "day" || !R) && B("month");
509
- }, [I]);
510
- let [V, H] = o(0);
873
+ se && V === "day" && (B === "day" || !B) && H("month");
874
+ }, [se]);
875
+ let [le, ue] = o(0);
511
876
  r(() => {
512
- if (!x && !(!t?.onMutation || !e.objectName)) return t.onMutation((t) => {
513
- t.resource === e.objectName && H((e) => e + 1);
877
+ if (!k && !(!t?.onMutation || !e.objectName)) return t.onMutation((t) => {
878
+ t.resource === e.objectName && ue((e) => e + 1);
514
879
  });
515
880
  }, [
516
881
  t,
517
882
  e.objectName,
518
- x
883
+ k
519
884
  ]);
520
- let { ref: U, isRefreshing: W, pullDistance: J } = M({
885
+ let { ref: de, isRefreshing: fe, pullDistance: U } = ne({
521
886
  onRefresh: n(async () => {
522
- H((e) => e + 1);
887
+ ue((e) => e + 1);
523
888
  }, []),
524
889
  enabled: !!t && !!e.objectName
525
- }), Y = i(() => G(e), [
890
+ }), W = i(() => pe(e), [
526
891
  e.data,
527
892
  e.staticData,
528
893
  e.objectName
529
- ]), X = i(() => q(e), [
894
+ ]), G = i(() => he(e), [
530
895
  e.filter,
531
896
  e.calendar,
532
897
  e.dateField,
533
898
  e.endField,
534
899
  e.titleField,
535
900
  e.colorField
536
- ]), Z = Y?.provider === "value", Q = a(null);
537
- Q.current = k, r(() => {
538
- x && C(d);
539
- }, [d, x]), r(() => {
540
- x && f !== void 0 && T(f);
541
- }, [f, x]), r(() => {
542
- if (x) return;
901
+ ]), K = W?.provider === "value", q = a(null);
902
+ q.current = R, r(() => {
903
+ k && j(d);
904
+ }, [d, k]), r(() => {
905
+ k && f !== void 0 && M(f);
906
+ }, [f, k]), r(() => {
907
+ if (k) return;
543
908
  let n = !0;
544
909
  return (async () => {
545
910
  try {
546
911
  if (!n) return;
547
- if (T(!0), Z && Y?.provider === "value") {
548
- n && (C(Y.items), T(!1));
912
+ if (M(!0), K && W?.provider === "value") {
913
+ n && (j(W.items), M(!1));
549
914
  return;
550
915
  }
551
916
  if (!t || typeof t.find != "function") throw Error("DataSource required for object/api providers");
552
- if (Y?.provider === "object") {
553
- let r = Y.object, i = c(Q.current?.fields), a = l(await t.find(r, {
917
+ if (W?.provider === "object") {
918
+ let r = W.object, i = c(q.current?.fields), a = l(await t.find(r, {
554
919
  $filter: e.filter,
555
- $orderby: K(e.sort),
920
+ $orderby: me(e.sort),
556
921
  ...i.length > 0 ? { $expand: i } : {}
557
922
  }));
558
- n && C(a);
559
- } else Y?.provider === "api" && (console.warn("API provider not yet implemented for ObjectCalendar"), n && C([]));
560
- n && T(!1);
923
+ n && j(a);
924
+ } else W?.provider === "api" && (console.warn("API provider not yet implemented for ObjectCalendar"), n && j([]));
925
+ n && M(!1);
561
926
  } catch (e) {
562
- console.error("[ObjectCalendar] Error fetching data:", e), n && (D(e), T(!1));
927
+ console.error("[ObjectCalendar] Error fetching data:", e), n && (F(e), M(!1));
563
928
  }
564
929
  })(), () => {
565
930
  n = !1;
566
931
  };
567
932
  }, [
568
- x,
569
- Y,
933
+ k,
934
+ W,
570
935
  t,
571
- Z,
936
+ K,
572
937
  e.filter,
573
938
  e.sort,
574
- V
939
+ le
575
940
  ]), r(() => {
576
- !Z && t && (async () => {
941
+ !K && t && (async () => {
577
942
  try {
578
943
  if (!t) return;
579
- let n = Y?.provider === "object" ? Y.object : e.objectName;
944
+ let n = W?.provider === "object" ? W.object : e.objectName;
580
945
  if (!n) return;
581
- N(await t.getObjectSchema(n));
946
+ ae(await t.getObjectSchema(n));
582
947
  } catch (e) {
583
948
  console.error("Failed to fetch object schema:", e);
584
949
  }
@@ -586,12 +951,12 @@ var J = ({ schema: e, dataSource: t, className: s, data: d, loading: f, onEventC
586
951
  }, [
587
952
  e.objectName,
588
953
  t,
589
- Z,
590
- Y
954
+ K,
955
+ W
591
956
  ]);
592
- let ee = i(() => {
593
- if (!X || !S.length) return [];
594
- let { startDateField: e, endDateField: t, titleField: n, colorField: r } = X, i = k?.titleFormat, a = typeof i == "string" ? i : i && typeof i == "object" && typeof i.source == "string" ? i.source : void 0, o = k?.NAME_FIELD_KEY, s = [
957
+ let J = i(() => {
958
+ if (!G || !A.length) return [];
959
+ let { startDateField: e, endDateField: t, titleField: n, colorField: r } = G, i = R?.titleFormat, a = typeof i == "string" ? i : i && typeof i == "object" && typeof i.source == "string" ? i.source : void 0, o = R?.NAME_FIELD_KEY, s = [
595
960
  "name",
596
961
  "full_name",
597
962
  "fullName",
@@ -625,7 +990,7 @@ var J = ({ schema: e, dataSource: t, className: s, data: d, loading: f, onEventC
625
990
  }
626
991
  return t || "Untitled";
627
992
  };
628
- return S.map((n, i) => {
993
+ return A.map((n, i) => {
629
994
  let a = n[e], o = t ? n[t] : null, s = l(n), c = r ? n[r] : void 0;
630
995
  return {
631
996
  id: n.id || n._id || `event-${i}`,
@@ -638,91 +1003,272 @@ var J = ({ schema: e, dataSource: t, className: s, data: d, loading: f, onEventC
638
1003
  };
639
1004
  }).filter((e) => !isNaN(e.start.getTime()));
640
1005
  }, [
641
- S,
642
- X,
643
- k
1006
+ A,
1007
+ G,
1008
+ R
644
1009
  ]);
645
1010
  n(() => {
646
1011
  h?.(/* @__PURE__ */ new Date());
647
1012
  }, [h]);
648
- let $ = u({
649
- navigation: e.navigation,
1013
+ let Y = e.navigation ?? {
1014
+ mode: "drawer",
1015
+ width: "min(960px, 60vw)"
1016
+ }, X = Y.mode === "drawer" || Y.mode === "modal" || Y.mode === "split" || Y.mode === "popover", Z = u({
1017
+ navigation: Y,
650
1018
  objectName: e.objectName,
651
- onRowClick: m
652
- });
653
- return w ? /* @__PURE__ */ A("div", {
1019
+ onRowClick: X ? void 0 : m
1020
+ }), ge = n(async (n, r, i) => {
1021
+ if (!G) return;
1022
+ let { startDateField: a, endDateField: o } = G, s = n?.id ?? n?._id;
1023
+ if (!s || !e.objectName || !t?.update) return;
1024
+ let c = { [a]: r.toISOString() };
1025
+ o && i && (c[o] = i.toISOString());
1026
+ let l = A;
1027
+ j((e) => e.map((e) => (e?.id ?? e?._id) === s ? {
1028
+ ...e,
1029
+ ...c
1030
+ } : e));
1031
+ try {
1032
+ await t.update(e.objectName, s, c);
1033
+ } catch (e) {
1034
+ j(l), console.error("[ObjectCalendar] Failed to persist drag-and-drop reschedule:", e);
1035
+ }
1036
+ }, [
1037
+ G,
1038
+ e.objectName,
1039
+ t,
1040
+ A
1041
+ ]), [Q, $] = o(null), _e = n((n) => {
1042
+ !G || !e.objectName || !t?.create || $({
1043
+ start: n,
1044
+ title: "",
1045
+ submitting: !1
1046
+ });
1047
+ }, [
1048
+ G,
1049
+ e.objectName,
1050
+ t
1051
+ ]), ve = n((n, r) => {
1052
+ !G || !e.objectName || !t?.create || $({
1053
+ start: n,
1054
+ end: r,
1055
+ title: "",
1056
+ submitting: !1
1057
+ });
1058
+ }, [
1059
+ G,
1060
+ e.objectName,
1061
+ t
1062
+ ]), ye = n(async () => {
1063
+ if (!Q || !G) return;
1064
+ let n = Q.title.trim();
1065
+ if (!n) {
1066
+ $((e) => e && {
1067
+ ...e,
1068
+ error: "Title is required"
1069
+ });
1070
+ return;
1071
+ }
1072
+ if (!e.objectName || !t?.create) return;
1073
+ $((e) => e && {
1074
+ ...e,
1075
+ submitting: !0,
1076
+ error: void 0
1077
+ });
1078
+ let { startDateField: r, endDateField: i, titleField: a } = G, o = {
1079
+ [a || "name"]: n,
1080
+ [r]: Q.start.toISOString()
1081
+ };
1082
+ i && (o[i] = (Q.end ?? Q.start).toISOString());
1083
+ let s = R?.fields;
1084
+ if (s && typeof s == "object") {
1085
+ let e = Array.isArray(s) ? s.map((e) => [e.name ?? e.apiName, e]) : Object.entries(s);
1086
+ for (let [t, n] of e) {
1087
+ if (!t || t in o || !n?.required) continue;
1088
+ if (n.defaultValue !== void 0 && n.defaultValue !== null) {
1089
+ o[t] = n.defaultValue;
1090
+ continue;
1091
+ }
1092
+ let e = n.type;
1093
+ if (e === "select" || e === "picklist" || e === "status") {
1094
+ let e = (n.options || n.choices || [])[0];
1095
+ e !== void 0 && (o[t] = typeof e == "object" ? e.value ?? e.id : e);
1096
+ } else e === "boolean" || e === "checkbox" ? o[t] = !1 : (e === "number" || e === "integer" || e === "decimal" || e === "currency" || e === "percent") && (o[t] = 0);
1097
+ }
1098
+ }
1099
+ try {
1100
+ let n = await t.create(e.objectName, o), r = (n && (n.record || n.data || n)) ?? null;
1101
+ r && (r.id !== void 0 || r._id !== void 0) && j((e) => [...e, r]), $(null);
1102
+ } catch (e) {
1103
+ let t = e?.message || String(e);
1104
+ $((e) => e && {
1105
+ ...e,
1106
+ submitting: !1,
1107
+ error: t
1108
+ }), console.error("[ObjectCalendar] Quick-create failed:", e);
1109
+ }
1110
+ }, [
1111
+ Q,
1112
+ G,
1113
+ e.objectName,
1114
+ t,
1115
+ R
1116
+ ]);
1117
+ return ee ? /* @__PURE__ */ I("div", {
654
1118
  className: s,
655
- children: /* @__PURE__ */ A("div", {
1119
+ children: /* @__PURE__ */ I("div", {
656
1120
  className: "flex items-center justify-center h-96",
657
- children: /* @__PURE__ */ A("div", {
1121
+ children: /* @__PURE__ */ I("div", {
658
1122
  className: "text-muted-foreground",
659
1123
  children: "Loading calendar..."
660
1124
  })
661
1125
  })
662
- }) : E ? /* @__PURE__ */ A("div", {
1126
+ }) : N ? /* @__PURE__ */ I("div", {
663
1127
  className: s,
664
- children: /* @__PURE__ */ A("div", {
1128
+ children: /* @__PURE__ */ I("div", {
665
1129
  className: "flex items-center justify-center h-96",
666
- children: /* @__PURE__ */ j("div", {
1130
+ children: /* @__PURE__ */ L("div", {
667
1131
  className: "text-destructive",
668
- children: ["Error: ", E.message]
1132
+ children: ["Error: ", N.message]
669
1133
  })
670
1134
  })
671
- }) : X ? /* @__PURE__ */ j("div", {
672
- ref: U,
1135
+ }) : G ? /* @__PURE__ */ L("div", {
1136
+ ref: de,
673
1137
  className: s,
674
1138
  children: [
675
- J > 0 && /* @__PURE__ */ A("div", {
1139
+ U > 0 && /* @__PURE__ */ I("div", {
676
1140
  className: "flex items-center justify-center text-xs text-muted-foreground",
677
- style: { height: J },
678
- children: W ? "Refreshing…" : "Pull to refresh"
1141
+ style: { height: U },
1142
+ children: fe ? "Refreshing…" : "Pull to refresh"
679
1143
  }),
680
- /* @__PURE__ */ A("div", {
681
- className: "border rounded-lg bg-background h-[calc(100vh-120px)] sm:h-[calc(100vh-160px)] md:h-[calc(100vh-200px)] min-h-[400px] sm:min-h-[600px]",
682
- children: /* @__PURE__ */ A(L, {
683
- events: ee,
684
- currentDate: P,
685
- view: z,
686
- locale: b,
1144
+ /* @__PURE__ */ I("div", {
1145
+ className: "bg-background h-[calc(100vh-120px)] sm:h-[calc(100vh-160px)] md:h-[calc(100vh-200px)] min-h-[400px] sm:min-h-[600px]",
1146
+ children: /* @__PURE__ */ I(ce, {
1147
+ events: J,
1148
+ currentDate: z,
1149
+ view: V,
1150
+ locale: O,
687
1151
  onEventClick: (e) => {
688
- $.handleClick(e.data), p?.(e.data);
1152
+ Z.handleClick(e.data), X || p?.(e.data);
1153
+ },
1154
+ onDateClick: (e) => {
1155
+ h ? h(e) : _e(e);
689
1156
  },
690
- onDateClick: h,
691
1157
  onNavigate: (e) => {
692
- F(e), g?.(e);
1158
+ oe(e), _?.(e);
693
1159
  },
694
1160
  onViewChange: (e) => {
695
- B(e), _?.(e);
1161
+ H(e), E?.(e);
696
1162
  },
697
1163
  onAddClick: void 0,
698
- onEventDrop: y ? (e, t, n) => {
699
- y(e.data, t, n);
700
- } : void 0
1164
+ onEventDrop: (e, t, n) => {
1165
+ D ? D(e.data, t, n) : ge(e.data, t, n);
1166
+ },
1167
+ onTimeRangeSelect: ve
701
1168
  })
702
1169
  }),
703
- $.isOverlay && /* @__PURE__ */ A(v, {
704
- ...$,
705
- title: "Event Details",
706
- children: (e) => /* @__PURE__ */ A("div", {
707
- className: "space-y-3",
708
- children: Object.entries(e).map(([e, t]) => /* @__PURE__ */ j("div", {
709
- className: "flex flex-col",
710
- children: [/* @__PURE__ */ A("span", {
711
- className: "text-xs font-medium text-muted-foreground uppercase tracking-wide",
712
- children: e.replace(/_/g, " ")
713
- }), /* @__PURE__ */ A("span", {
714
- className: "text-sm",
715
- children: String(t ?? "—")
716
- })]
717
- }, e))
1170
+ /* @__PURE__ */ I(v, {
1171
+ open: !!Q,
1172
+ onOpenChange: (e) => {
1173
+ e || $(null);
1174
+ },
1175
+ children: /* @__PURE__ */ L(y, {
1176
+ className: "sm:max-w-md",
1177
+ children: [
1178
+ /* @__PURE__ */ L(S, { children: [/* @__PURE__ */ I(C, { children: "New event" }), /* @__PURE__ */ I(b, { children: Q && (() => {
1179
+ let e = Q.end && Q.end.getTime() !== Q.start.getTime(), t = Q.start.toLocaleDateString(O, {
1180
+ year: "numeric",
1181
+ month: "long",
1182
+ day: "numeric"
1183
+ });
1184
+ if (e) {
1185
+ let e = (e) => e.toLocaleTimeString(O, {
1186
+ hour: "numeric",
1187
+ minute: "2-digit"
1188
+ });
1189
+ return /* @__PURE__ */ L(te, { children: [
1190
+ t,
1191
+ " · ",
1192
+ e(Q.start),
1193
+ " – ",
1194
+ e(Q.end)
1195
+ ] });
1196
+ }
1197
+ return /* @__PURE__ */ L(te, { children: ["On ", t] });
1198
+ })() })] }),
1199
+ /* @__PURE__ */ L("div", {
1200
+ className: "space-y-2",
1201
+ children: [
1202
+ /* @__PURE__ */ I(T, {
1203
+ htmlFor: "quick-create-title",
1204
+ children: "Title"
1205
+ }),
1206
+ /* @__PURE__ */ I(w, {
1207
+ id: "quick-create-title",
1208
+ autoFocus: !0,
1209
+ value: Q?.title ?? "",
1210
+ onChange: (e) => $((t) => t && {
1211
+ ...t,
1212
+ title: e.target.value,
1213
+ error: void 0
1214
+ }),
1215
+ onKeyDown: (e) => {
1216
+ e.key === "Enter" && !Q?.submitting && (e.preventDefault(), ye());
1217
+ },
1218
+ placeholder: "What's this event about?",
1219
+ disabled: Q?.submitting
1220
+ }),
1221
+ Q?.error && /* @__PURE__ */ I("p", {
1222
+ className: "text-sm text-destructive",
1223
+ children: Q.error
1224
+ })
1225
+ ]
1226
+ }),
1227
+ /* @__PURE__ */ L(x, { children: [/* @__PURE__ */ I(g, {
1228
+ variant: "outline",
1229
+ onClick: () => $(null),
1230
+ disabled: Q?.submitting,
1231
+ children: "Cancel"
1232
+ }), /* @__PURE__ */ I(g, {
1233
+ onClick: () => void ye(),
1234
+ disabled: Q?.submitting || !Q?.title.trim(),
1235
+ children: Q?.submitting ? "Creating…" : "Create"
1236
+ })] })
1237
+ ]
718
1238
  })
719
- })
1239
+ }),
1240
+ Z.isOverlay && Z.isOpen && Z.selectedRecord && (() => {
1241
+ let n = W?.provider === "object" ? W.object : e.objectName, r = Z.selectedRecord, i = r.id ?? r._id;
1242
+ if (!n || i == null) return null;
1243
+ let a = G?.titleField ? String(r[G.titleField] ?? "Event Details") : "Event Details";
1244
+ return /* @__PURE__ */ I(re, {
1245
+ open: !0,
1246
+ onClose: Z.close,
1247
+ title: a,
1248
+ record: r,
1249
+ objectName: n,
1250
+ recordId: i,
1251
+ dataSource: t,
1252
+ objectSchema: R,
1253
+ width: Z.width ?? "min(960px, 60vw)",
1254
+ fullPageHref: ie(n, i) ?? void 0,
1255
+ onFieldSave: async (e, r) => {
1256
+ t?.update && (await t.update(n, String(i), { [e]: r }), j((t) => t.map((t) => String(t.id ?? t._id) === String(i) ? {
1257
+ ...t,
1258
+ [e]: r
1259
+ } : t)));
1260
+ },
1261
+ onDelete: async () => {
1262
+ t?.delete && (await t.delete(n, String(i)), j((e) => e.filter((e) => String(e.id ?? e._id) !== String(i))));
1263
+ }
1264
+ });
1265
+ })()
720
1266
  ]
721
- }) : /* @__PURE__ */ A("div", {
1267
+ }) : /* @__PURE__ */ I("div", {
722
1268
  className: s,
723
- children: /* @__PURE__ */ A("div", {
1269
+ children: /* @__PURE__ */ I("div", {
724
1270
  className: "flex items-center justify-center h-96",
725
- children: /* @__PURE__ */ A("div", {
1271
+ children: /* @__PURE__ */ I("div", {
726
1272
  className: "text-muted-foreground",
727
1273
  children: "Calendar configuration required. Please specify startDateField and titleField."
728
1274
  })
@@ -731,7 +1277,7 @@ var J = ({ schema: e, dataSource: t, className: s, data: d, loading: f, onEventC
731
1277
  };
732
1278
  //#endregion
733
1279
  //#region src/calendar-view-renderer.tsx
734
- s.register("calendar-view", ({ schema: e, className: n, onAction: r, ...i }) => /* @__PURE__ */ A(L, {
1280
+ s.register("calendar-view", ({ schema: e, className: n, onAction: r, ...i }) => /* @__PURE__ */ I(ce, {
735
1281
  className: n,
736
1282
  events: t.useMemo(() => !e.data || !Array.isArray(e.data) ? [] : e.data.map((t, n) => {
737
1283
  let r = e.titleField || "title", i = e.startDateField || "start", a = e.endDateField || "end", o = e.colorField || "color", s = e.allDayField || "allDay";
@@ -879,15 +1425,15 @@ s.register("calendar-view", ({ schema: e, className: n, onAction: r, ...i }) =>
879
1425
  });
880
1426
  //#endregion
881
1427
  //#region src/index.tsx
882
- var Y = ({ schema: e, ...t }) => {
1428
+ var X = ({ schema: e, ...t }) => {
883
1429
  let { dataSource: n } = d() || {};
884
- return /* @__PURE__ */ A(J, {
1430
+ return /* @__PURE__ */ I(Y, {
885
1431
  schema: e,
886
1432
  dataSource: n,
887
1433
  ...t
888
1434
  });
889
1435
  };
890
- s.register("object-calendar", Y, {
1436
+ s.register("object-calendar", X, {
891
1437
  namespace: "plugin-calendar",
892
1438
  label: "Object Calendar",
893
1439
  category: "view",
@@ -902,7 +1448,7 @@ s.register("object-calendar", Y, {
902
1448
  label: "Calendar Config",
903
1449
  description: "startDateField, endDateField, titleField, colorField"
904
1450
  }]
905
- }), s.register("calendar", Y, {
1451
+ }), s.register("calendar", X, {
906
1452
  namespace: "view",
907
1453
  label: "Calendar View",
908
1454
  category: "view",
@@ -919,4 +1465,4 @@ s.register("object-calendar", Y, {
919
1465
  }]
920
1466
  });
921
1467
  //#endregion
922
- export { L as CalendarView, J as ObjectCalendar, Y as ObjectCalendarRenderer };
1468
+ export { ce as CalendarView, Y as ObjectCalendar, X as ObjectCalendarRenderer };