@object-ui/plugin-calendar 0.3.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/LICENSE +21 -0
- package/README.md +198 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +946 -0
- package/dist/index.umd.cjs +6 -0
- package/dist/src/CalendarView.d.ts +29 -0
- package/dist/src/CalendarView.d.ts.map +1 -0
- package/dist/src/ObjectCalendar.d.ts +13 -0
- package/dist/src/ObjectCalendar.d.ts.map +1 -0
- package/dist/src/calendar-view-renderer.d.ts +9 -0
- package/dist/src/calendar-view-renderer.d.ts.map +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -0
- package/package.json +53 -0
- package/src/CalendarView.tsx +504 -0
- package/src/ObjectCalendar.tsx +385 -0
- package/src/calendar-view-renderer.tsx +231 -0
- package/src/index.tsx +37 -0
- package/tsconfig.json +18 -0
- package/vite.config.ts +50 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,946 @@
|
|
|
1
|
+
import * as ae from "react";
|
|
2
|
+
import L, { useState as I, useEffect as ne, useMemo as oe, useCallback as le } from "react";
|
|
3
|
+
import { ComponentRegistry as de } from "@object-ui/core";
|
|
4
|
+
import { ChevronLeftIcon as ge, ChevronRightIcon as pe } from "lucide-react";
|
|
5
|
+
import { cn as O, Button as Z, Select as xe, SelectTrigger as De, SelectValue as be, SelectContent as he, SelectItem as K } from "@object-ui/components";
|
|
6
|
+
var z = { exports: {} }, $ = {};
|
|
7
|
+
var se;
|
|
8
|
+
function ve() {
|
|
9
|
+
if (se) return $;
|
|
10
|
+
se = 1;
|
|
11
|
+
var t = /* @__PURE__ */ Symbol.for("react.transitional.element"), o = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
12
|
+
function n(m, g, c) {
|
|
13
|
+
var f = null;
|
|
14
|
+
if (c !== void 0 && (f = "" + c), g.key !== void 0 && (f = "" + g.key), "key" in g) {
|
|
15
|
+
c = {};
|
|
16
|
+
for (var a in g)
|
|
17
|
+
a !== "key" && (c[a] = g[a]);
|
|
18
|
+
} else c = g;
|
|
19
|
+
return g = c.ref, {
|
|
20
|
+
$$typeof: t,
|
|
21
|
+
type: m,
|
|
22
|
+
key: f,
|
|
23
|
+
ref: g !== void 0 ? g : null,
|
|
24
|
+
props: c
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return $.Fragment = o, $.jsx = n, $.jsxs = n, $;
|
|
28
|
+
}
|
|
29
|
+
var W = {};
|
|
30
|
+
var ie;
|
|
31
|
+
function ye() {
|
|
32
|
+
return ie || (ie = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
33
|
+
function t(e) {
|
|
34
|
+
if (e == null) return null;
|
|
35
|
+
if (typeof e == "function")
|
|
36
|
+
return e.$$typeof === p ? null : e.displayName || e.name || null;
|
|
37
|
+
if (typeof e == "string") return e;
|
|
38
|
+
switch (e) {
|
|
39
|
+
case T:
|
|
40
|
+
return "Fragment";
|
|
41
|
+
case E:
|
|
42
|
+
return "Profiler";
|
|
43
|
+
case i:
|
|
44
|
+
return "StrictMode";
|
|
45
|
+
case G:
|
|
46
|
+
return "Suspense";
|
|
47
|
+
case H:
|
|
48
|
+
return "SuspenseList";
|
|
49
|
+
case D:
|
|
50
|
+
return "Activity";
|
|
51
|
+
}
|
|
52
|
+
if (typeof e == "object")
|
|
53
|
+
switch (typeof e.tag == "number" && console.error(
|
|
54
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
55
|
+
), e.$$typeof) {
|
|
56
|
+
case M:
|
|
57
|
+
return "Portal";
|
|
58
|
+
case P:
|
|
59
|
+
return e.displayName || "Context";
|
|
60
|
+
case R:
|
|
61
|
+
return (e._context.displayName || "Context") + ".Consumer";
|
|
62
|
+
case F:
|
|
63
|
+
var d = e.render;
|
|
64
|
+
return e = e.displayName, e || (e = d.displayName || d.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
65
|
+
case X:
|
|
66
|
+
return d = e.displayName || null, d !== null ? d : t(e.type) || "Memo";
|
|
67
|
+
case Y:
|
|
68
|
+
d = e._payload, e = e._init;
|
|
69
|
+
try {
|
|
70
|
+
return t(e(d));
|
|
71
|
+
} catch {
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
function o(e) {
|
|
77
|
+
return "" + e;
|
|
78
|
+
}
|
|
79
|
+
function n(e) {
|
|
80
|
+
try {
|
|
81
|
+
o(e);
|
|
82
|
+
var d = !1;
|
|
83
|
+
} catch {
|
|
84
|
+
d = !0;
|
|
85
|
+
}
|
|
86
|
+
if (d) {
|
|
87
|
+
d = console;
|
|
88
|
+
var b = d.error, v = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
89
|
+
return b.call(
|
|
90
|
+
d,
|
|
91
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
92
|
+
v
|
|
93
|
+
), o(e);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function m(e) {
|
|
97
|
+
if (e === T) return "<>";
|
|
98
|
+
if (typeof e == "object" && e !== null && e.$$typeof === Y)
|
|
99
|
+
return "<...>";
|
|
100
|
+
try {
|
|
101
|
+
var d = t(e);
|
|
102
|
+
return d ? "<" + d + ">" : "<...>";
|
|
103
|
+
} catch {
|
|
104
|
+
return "<...>";
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function g() {
|
|
108
|
+
var e = x.A;
|
|
109
|
+
return e === null ? null : e.getOwner();
|
|
110
|
+
}
|
|
111
|
+
function c() {
|
|
112
|
+
return Error("react-stack-top-frame");
|
|
113
|
+
}
|
|
114
|
+
function f(e) {
|
|
115
|
+
if (N.call(e, "key")) {
|
|
116
|
+
var d = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
117
|
+
if (d && d.isReactWarning) return !1;
|
|
118
|
+
}
|
|
119
|
+
return e.key !== void 0;
|
|
120
|
+
}
|
|
121
|
+
function a(e, d) {
|
|
122
|
+
function b() {
|
|
123
|
+
_ || (_ = !0, console.error(
|
|
124
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
125
|
+
d
|
|
126
|
+
));
|
|
127
|
+
}
|
|
128
|
+
b.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
129
|
+
get: b,
|
|
130
|
+
configurable: !0
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
function l() {
|
|
134
|
+
var e = t(this.type);
|
|
135
|
+
return A[e] || (A[e] = !0, console.error(
|
|
136
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
137
|
+
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
138
|
+
}
|
|
139
|
+
function u(e, d, b, v, q, B) {
|
|
140
|
+
var y = b.ref;
|
|
141
|
+
return e = {
|
|
142
|
+
$$typeof: C,
|
|
143
|
+
type: e,
|
|
144
|
+
key: d,
|
|
145
|
+
props: b,
|
|
146
|
+
_owner: v
|
|
147
|
+
}, (y !== void 0 ? y : null) !== null ? Object.defineProperty(e, "ref", {
|
|
148
|
+
enumerable: !1,
|
|
149
|
+
get: l
|
|
150
|
+
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
151
|
+
configurable: !1,
|
|
152
|
+
enumerable: !1,
|
|
153
|
+
writable: !0,
|
|
154
|
+
value: 0
|
|
155
|
+
}), Object.defineProperty(e, "_debugInfo", {
|
|
156
|
+
configurable: !1,
|
|
157
|
+
enumerable: !1,
|
|
158
|
+
writable: !0,
|
|
159
|
+
value: null
|
|
160
|
+
}), Object.defineProperty(e, "_debugStack", {
|
|
161
|
+
configurable: !1,
|
|
162
|
+
enumerable: !1,
|
|
163
|
+
writable: !0,
|
|
164
|
+
value: q
|
|
165
|
+
}), Object.defineProperty(e, "_debugTask", {
|
|
166
|
+
configurable: !1,
|
|
167
|
+
enumerable: !1,
|
|
168
|
+
writable: !0,
|
|
169
|
+
value: B
|
|
170
|
+
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
171
|
+
}
|
|
172
|
+
function s(e, d, b, v, q, B) {
|
|
173
|
+
var y = d.children;
|
|
174
|
+
if (y !== void 0)
|
|
175
|
+
if (v)
|
|
176
|
+
if (h(y)) {
|
|
177
|
+
for (v = 0; v < y.length; v++)
|
|
178
|
+
S(y[v]);
|
|
179
|
+
Object.freeze && Object.freeze(y);
|
|
180
|
+
} else
|
|
181
|
+
console.error(
|
|
182
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
183
|
+
);
|
|
184
|
+
else S(y);
|
|
185
|
+
if (N.call(d, "key")) {
|
|
186
|
+
y = t(e);
|
|
187
|
+
var V = Object.keys(d).filter(function(me) {
|
|
188
|
+
return me !== "key";
|
|
189
|
+
});
|
|
190
|
+
v = 0 < V.length ? "{key: someKey, " + V.join(": ..., ") + ": ...}" : "{key: someKey}", re[y + v] || (V = 0 < V.length ? "{" + V.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
191
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
192
|
+
let props = %s;
|
|
193
|
+
<%s {...props} />
|
|
194
|
+
React keys must be passed directly to JSX without using spread:
|
|
195
|
+
let props = %s;
|
|
196
|
+
<%s key={someKey} {...props} />`,
|
|
197
|
+
v,
|
|
198
|
+
y,
|
|
199
|
+
V,
|
|
200
|
+
y
|
|
201
|
+
), re[y + v] = !0);
|
|
202
|
+
}
|
|
203
|
+
if (y = null, b !== void 0 && (n(b), y = "" + b), f(d) && (n(d.key), y = "" + d.key), "key" in d) {
|
|
204
|
+
b = {};
|
|
205
|
+
for (var Q in d)
|
|
206
|
+
Q !== "key" && (b[Q] = d[Q]);
|
|
207
|
+
} else b = d;
|
|
208
|
+
return y && a(
|
|
209
|
+
b,
|
|
210
|
+
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
211
|
+
), u(
|
|
212
|
+
e,
|
|
213
|
+
y,
|
|
214
|
+
b,
|
|
215
|
+
g(),
|
|
216
|
+
q,
|
|
217
|
+
B
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
function S(e) {
|
|
221
|
+
j(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === Y && (e._payload.status === "fulfilled" ? j(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
222
|
+
}
|
|
223
|
+
function j(e) {
|
|
224
|
+
return typeof e == "object" && e !== null && e.$$typeof === C;
|
|
225
|
+
}
|
|
226
|
+
var w = L, C = /* @__PURE__ */ Symbol.for("react.transitional.element"), M = /* @__PURE__ */ Symbol.for("react.portal"), T = /* @__PURE__ */ Symbol.for("react.fragment"), i = /* @__PURE__ */ Symbol.for("react.strict_mode"), E = /* @__PURE__ */ Symbol.for("react.profiler"), R = /* @__PURE__ */ Symbol.for("react.consumer"), P = /* @__PURE__ */ Symbol.for("react.context"), F = /* @__PURE__ */ Symbol.for("react.forward_ref"), G = /* @__PURE__ */ Symbol.for("react.suspense"), H = /* @__PURE__ */ Symbol.for("react.suspense_list"), X = /* @__PURE__ */ Symbol.for("react.memo"), Y = /* @__PURE__ */ Symbol.for("react.lazy"), D = /* @__PURE__ */ Symbol.for("react.activity"), p = /* @__PURE__ */ Symbol.for("react.client.reference"), x = w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, N = Object.prototype.hasOwnProperty, h = Array.isArray, k = console.createTask ? console.createTask : function() {
|
|
227
|
+
return null;
|
|
228
|
+
};
|
|
229
|
+
w = {
|
|
230
|
+
react_stack_bottom_frame: function(e) {
|
|
231
|
+
return e();
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
var _, A = {}, U = w.react_stack_bottom_frame.bind(
|
|
235
|
+
w,
|
|
236
|
+
c
|
|
237
|
+
)(), J = k(m(c)), re = {};
|
|
238
|
+
W.Fragment = T, W.jsx = function(e, d, b) {
|
|
239
|
+
var v = 1e4 > x.recentlyCreatedOwnerStacks++;
|
|
240
|
+
return s(
|
|
241
|
+
e,
|
|
242
|
+
d,
|
|
243
|
+
b,
|
|
244
|
+
!1,
|
|
245
|
+
v ? Error("react-stack-top-frame") : U,
|
|
246
|
+
v ? k(m(e)) : J
|
|
247
|
+
);
|
|
248
|
+
}, W.jsxs = function(e, d, b) {
|
|
249
|
+
var v = 1e4 > x.recentlyCreatedOwnerStacks++;
|
|
250
|
+
return s(
|
|
251
|
+
e,
|
|
252
|
+
d,
|
|
253
|
+
b,
|
|
254
|
+
!0,
|
|
255
|
+
v ? Error("react-stack-top-frame") : U,
|
|
256
|
+
v ? k(m(e)) : J
|
|
257
|
+
);
|
|
258
|
+
};
|
|
259
|
+
})()), W;
|
|
260
|
+
}
|
|
261
|
+
var ce;
|
|
262
|
+
function we() {
|
|
263
|
+
return ce || (ce = 1, process.env.NODE_ENV === "production" ? z.exports = ve() : z.exports = ye()), z.exports;
|
|
264
|
+
}
|
|
265
|
+
var r = we();
|
|
266
|
+
function je(t) {
|
|
267
|
+
return t.data ? t.data : t.staticData ? {
|
|
268
|
+
provider: "value",
|
|
269
|
+
items: t.staticData
|
|
270
|
+
} : t.objectName ? {
|
|
271
|
+
provider: "object",
|
|
272
|
+
object: t.objectName
|
|
273
|
+
} : null;
|
|
274
|
+
}
|
|
275
|
+
function Ne(t) {
|
|
276
|
+
if (t) {
|
|
277
|
+
if (typeof t == "string") {
|
|
278
|
+
const o = t.split(" "), n = o[0], m = o[1]?.toLowerCase() === "desc" ? "desc" : "asc";
|
|
279
|
+
return { [n]: m };
|
|
280
|
+
}
|
|
281
|
+
if (Array.isArray(t))
|
|
282
|
+
return t.reduce((o, n) => (n.field && n.order && (o[n.field] = n.order), o), {});
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
function ke(t) {
|
|
286
|
+
return t.filter && typeof t.filter == "object" && "calendar" in t.filter ? t.filter.calendar : t.calendar ? t.calendar : null;
|
|
287
|
+
}
|
|
288
|
+
const Ee = ({
|
|
289
|
+
schema: t,
|
|
290
|
+
dataSource: o,
|
|
291
|
+
className: n,
|
|
292
|
+
onEventClick: m,
|
|
293
|
+
onDateClick: g
|
|
294
|
+
}) => {
|
|
295
|
+
const [c, f] = I([]), [a, l] = I(!0), [u, s] = I(null), [S, j] = I(null), [w, C] = I(/* @__PURE__ */ new Date()), [M, T] = I("month"), i = je(t), E = ke(t), R = i?.provider === "value";
|
|
296
|
+
ne(() => {
|
|
297
|
+
(async () => {
|
|
298
|
+
try {
|
|
299
|
+
if (l(!0), R && i?.provider === "value") {
|
|
300
|
+
f(i.items), l(!1);
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
if (!o)
|
|
304
|
+
throw new Error("DataSource required for object/api providers");
|
|
305
|
+
if (i?.provider === "object") {
|
|
306
|
+
const p = i.object, x = await o.find(p, {
|
|
307
|
+
$filter: t.filter,
|
|
308
|
+
$orderby: Ne(t.sort)
|
|
309
|
+
});
|
|
310
|
+
f(x?.data || []);
|
|
311
|
+
} else i?.provider === "api" && (console.warn("API provider not yet implemented for ObjectCalendar"), f([]));
|
|
312
|
+
l(!1);
|
|
313
|
+
} catch (p) {
|
|
314
|
+
s(p), l(!1);
|
|
315
|
+
}
|
|
316
|
+
})();
|
|
317
|
+
}, [i, o, R, t.filter, t.sort]), ne(() => {
|
|
318
|
+
!R && o && (async () => {
|
|
319
|
+
try {
|
|
320
|
+
if (!o) return;
|
|
321
|
+
const p = i?.provider === "object" ? i.object : t.objectName;
|
|
322
|
+
if (!p) return;
|
|
323
|
+
const x = await o.getObjectSchema(p);
|
|
324
|
+
j(x);
|
|
325
|
+
} catch (p) {
|
|
326
|
+
console.error("Failed to fetch object schema:", p);
|
|
327
|
+
}
|
|
328
|
+
})();
|
|
329
|
+
}, [t.objectName, o, R, i]);
|
|
330
|
+
const P = oe(() => {
|
|
331
|
+
if (!E || !c.length)
|
|
332
|
+
return [];
|
|
333
|
+
const { startDateField: D, endDateField: p, titleField: x, colorField: N } = E;
|
|
334
|
+
return c.map((h, k) => {
|
|
335
|
+
const _ = h[D], A = p ? h[p] : null, U = h[x] || "Untitled", J = N ? h[N] : void 0;
|
|
336
|
+
return {
|
|
337
|
+
id: h.id || h._id || `event-${k}`,
|
|
338
|
+
title: U,
|
|
339
|
+
start: _ ? new Date(_) : /* @__PURE__ */ new Date(),
|
|
340
|
+
end: A ? new Date(A) : void 0,
|
|
341
|
+
color: J,
|
|
342
|
+
allDay: !A,
|
|
343
|
+
// If no end date, treat as all-day event
|
|
344
|
+
data: h
|
|
345
|
+
};
|
|
346
|
+
}).filter((h) => !isNaN(h.start.getTime()));
|
|
347
|
+
}, [c, E]), F = oe(() => {
|
|
348
|
+
const D = w.getFullYear(), p = w.getMonth(), x = new Date(D, p, 1), N = new Date(x);
|
|
349
|
+
N.setDate(N.getDate() - N.getDay());
|
|
350
|
+
const h = [], k = new Date(N);
|
|
351
|
+
for (let _ = 0; _ < 42; _++)
|
|
352
|
+
h.push(new Date(k)), k.setDate(k.getDate() + 1);
|
|
353
|
+
return h;
|
|
354
|
+
}, [w]), G = le((D) => P.filter((p) => {
|
|
355
|
+
const x = new Date(p.start);
|
|
356
|
+
x.setHours(0, 0, 0, 0);
|
|
357
|
+
const N = p.end ? new Date(p.end) : x;
|
|
358
|
+
N.setHours(23, 59, 59, 999);
|
|
359
|
+
const h = new Date(D);
|
|
360
|
+
return h.setHours(0, 0, 0, 0), h >= x && h <= N;
|
|
361
|
+
}), [P]), H = le((D) => {
|
|
362
|
+
C((p) => {
|
|
363
|
+
const x = new Date(p);
|
|
364
|
+
return x.setMonth(x.getMonth() + (D === "next" ? 1 : -1)), x;
|
|
365
|
+
});
|
|
366
|
+
}, []);
|
|
367
|
+
if (a)
|
|
368
|
+
return /* @__PURE__ */ r.jsx("div", { className: n, children: /* @__PURE__ */ r.jsx("div", { className: "flex items-center justify-center h-96", children: /* @__PURE__ */ r.jsx("div", { className: "text-muted-foreground", children: "Loading calendar..." }) }) });
|
|
369
|
+
if (u)
|
|
370
|
+
return /* @__PURE__ */ r.jsx("div", { className: n, children: /* @__PURE__ */ r.jsx("div", { className: "flex items-center justify-center h-96", children: /* @__PURE__ */ r.jsxs("div", { className: "text-destructive", children: [
|
|
371
|
+
"Error: ",
|
|
372
|
+
u.message
|
|
373
|
+
] }) }) });
|
|
374
|
+
if (!E)
|
|
375
|
+
return /* @__PURE__ */ r.jsx("div", { className: n, children: /* @__PURE__ */ r.jsx("div", { className: "flex items-center justify-center h-96", children: /* @__PURE__ */ r.jsx("div", { className: "text-muted-foreground", children: "Calendar configuration required. Please specify startDateField and titleField." }) }) });
|
|
376
|
+
const X = [
|
|
377
|
+
"January",
|
|
378
|
+
"February",
|
|
379
|
+
"March",
|
|
380
|
+
"April",
|
|
381
|
+
"May",
|
|
382
|
+
"June",
|
|
383
|
+
"July",
|
|
384
|
+
"August",
|
|
385
|
+
"September",
|
|
386
|
+
"October",
|
|
387
|
+
"November",
|
|
388
|
+
"December"
|
|
389
|
+
], Y = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
390
|
+
return /* @__PURE__ */ r.jsx("div", { className: n, children: /* @__PURE__ */ r.jsxs("div", { className: "border rounded-lg bg-background", children: [
|
|
391
|
+
/* @__PURE__ */ r.jsxs("div", { className: "flex items-center justify-between p-4 border-b", children: [
|
|
392
|
+
/* @__PURE__ */ r.jsxs("h2", { className: "text-xl font-semibold", children: [
|
|
393
|
+
X[w.getMonth()],
|
|
394
|
+
" ",
|
|
395
|
+
w.getFullYear()
|
|
396
|
+
] }),
|
|
397
|
+
/* @__PURE__ */ r.jsxs("div", { className: "flex gap-2", children: [
|
|
398
|
+
/* @__PURE__ */ r.jsx(
|
|
399
|
+
"button",
|
|
400
|
+
{
|
|
401
|
+
onClick: () => H("prev"),
|
|
402
|
+
className: "px-3 py-1 border rounded hover:bg-muted",
|
|
403
|
+
children: "Previous"
|
|
404
|
+
}
|
|
405
|
+
),
|
|
406
|
+
/* @__PURE__ */ r.jsx(
|
|
407
|
+
"button",
|
|
408
|
+
{
|
|
409
|
+
onClick: () => C(/* @__PURE__ */ new Date()),
|
|
410
|
+
className: "px-3 py-1 border rounded hover:bg-muted",
|
|
411
|
+
children: "Today"
|
|
412
|
+
}
|
|
413
|
+
),
|
|
414
|
+
/* @__PURE__ */ r.jsx(
|
|
415
|
+
"button",
|
|
416
|
+
{
|
|
417
|
+
onClick: () => H("next"),
|
|
418
|
+
className: "px-3 py-1 border rounded hover:bg-muted",
|
|
419
|
+
children: "Next"
|
|
420
|
+
}
|
|
421
|
+
)
|
|
422
|
+
] })
|
|
423
|
+
] }),
|
|
424
|
+
/* @__PURE__ */ r.jsxs("div", { className: "p-4", children: [
|
|
425
|
+
/* @__PURE__ */ r.jsx("div", { className: "grid grid-cols-7 gap-px mb-px", children: Y.map((D) => /* @__PURE__ */ r.jsx(
|
|
426
|
+
"div",
|
|
427
|
+
{
|
|
428
|
+
className: "text-center text-sm font-medium text-muted-foreground py-2",
|
|
429
|
+
children: D
|
|
430
|
+
},
|
|
431
|
+
D
|
|
432
|
+
)) }),
|
|
433
|
+
/* @__PURE__ */ r.jsx("div", { className: "grid grid-cols-7 gap-px bg-border", children: F.map((D, p) => {
|
|
434
|
+
const x = G(D), N = D.getMonth() === w.getMonth(), h = D.getDate() === (/* @__PURE__ */ new Date()).getDate() && D.getMonth() === (/* @__PURE__ */ new Date()).getMonth() && D.getFullYear() === (/* @__PURE__ */ new Date()).getFullYear();
|
|
435
|
+
return /* @__PURE__ */ r.jsxs(
|
|
436
|
+
"div",
|
|
437
|
+
{
|
|
438
|
+
className: `min-h-24 bg-background p-2 ${N ? "" : "text-muted-foreground bg-muted/30"} ${h ? "ring-2 ring-primary" : ""}`,
|
|
439
|
+
onClick: () => g?.(D),
|
|
440
|
+
children: [
|
|
441
|
+
/* @__PURE__ */ r.jsx("div", { className: "text-sm font-medium mb-1", children: D.getDate() }),
|
|
442
|
+
/* @__PURE__ */ r.jsxs("div", { className: "space-y-1", children: [
|
|
443
|
+
x.slice(0, 3).map((k) => /* @__PURE__ */ r.jsx(
|
|
444
|
+
"div",
|
|
445
|
+
{
|
|
446
|
+
className: "text-xs px-1 py-0.5 rounded bg-primary/10 hover:bg-primary/20 cursor-pointer truncate",
|
|
447
|
+
onClick: (_) => {
|
|
448
|
+
_.stopPropagation(), m?.(k.data);
|
|
449
|
+
},
|
|
450
|
+
style: k.color ? { borderLeft: `3px solid ${k.color}` } : void 0,
|
|
451
|
+
children: k.title
|
|
452
|
+
},
|
|
453
|
+
k.id
|
|
454
|
+
)),
|
|
455
|
+
x.length > 3 && /* @__PURE__ */ r.jsxs("div", { className: "text-xs text-muted-foreground", children: [
|
|
456
|
+
"+",
|
|
457
|
+
x.length - 3,
|
|
458
|
+
" more"
|
|
459
|
+
] })
|
|
460
|
+
] })
|
|
461
|
+
]
|
|
462
|
+
},
|
|
463
|
+
p
|
|
464
|
+
);
|
|
465
|
+
}) })
|
|
466
|
+
] })
|
|
467
|
+
] }) });
|
|
468
|
+
}, ee = "bg-blue-500 text-white";
|
|
469
|
+
function Se({
|
|
470
|
+
events: t = [],
|
|
471
|
+
view: o = "month",
|
|
472
|
+
currentDate: n = /* @__PURE__ */ new Date(),
|
|
473
|
+
onEventClick: m,
|
|
474
|
+
onDateClick: g,
|
|
475
|
+
onViewChange: c,
|
|
476
|
+
onNavigate: f,
|
|
477
|
+
className: a
|
|
478
|
+
}) {
|
|
479
|
+
const [l, u] = ae.useState(o), [s, S] = ae.useState(n), j = () => {
|
|
480
|
+
const i = new Date(s);
|
|
481
|
+
l === "month" ? i.setMonth(i.getMonth() - 1) : l === "week" ? i.setDate(i.getDate() - 7) : i.setDate(i.getDate() - 1), S(i), f?.(i);
|
|
482
|
+
}, w = () => {
|
|
483
|
+
const i = new Date(s);
|
|
484
|
+
l === "month" ? i.setMonth(i.getMonth() + 1) : l === "week" ? i.setDate(i.getDate() + 7) : i.setDate(i.getDate() + 1), S(i), f?.(i);
|
|
485
|
+
}, C = () => {
|
|
486
|
+
const i = /* @__PURE__ */ new Date();
|
|
487
|
+
S(i), f?.(i);
|
|
488
|
+
}, M = (i) => {
|
|
489
|
+
u(i), c?.(i);
|
|
490
|
+
}, T = () => {
|
|
491
|
+
if (l === "month")
|
|
492
|
+
return s.toLocaleDateString("default", {
|
|
493
|
+
month: "long",
|
|
494
|
+
year: "numeric"
|
|
495
|
+
});
|
|
496
|
+
if (l === "week") {
|
|
497
|
+
const i = ue(s), E = new Date(i);
|
|
498
|
+
return E.setDate(E.getDate() + 6), `${i.toLocaleDateString("default", {
|
|
499
|
+
month: "short",
|
|
500
|
+
day: "numeric"
|
|
501
|
+
})} - ${E.toLocaleDateString("default", {
|
|
502
|
+
month: "short",
|
|
503
|
+
day: "numeric",
|
|
504
|
+
year: "numeric"
|
|
505
|
+
})}`;
|
|
506
|
+
} else
|
|
507
|
+
return s.toLocaleDateString("default", {
|
|
508
|
+
weekday: "long",
|
|
509
|
+
month: "long",
|
|
510
|
+
day: "numeric",
|
|
511
|
+
year: "numeric"
|
|
512
|
+
});
|
|
513
|
+
};
|
|
514
|
+
return /* @__PURE__ */ r.jsxs("div", { className: O("flex flex-col h-full bg-background", a), children: [
|
|
515
|
+
/* @__PURE__ */ r.jsxs("div", { className: "flex items-center justify-between p-4 border-b", children: [
|
|
516
|
+
/* @__PURE__ */ r.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
517
|
+
/* @__PURE__ */ r.jsx(Z, { variant: "outline", size: "sm", onClick: C, children: "Today" }),
|
|
518
|
+
/* @__PURE__ */ r.jsxs("div", { className: "flex items-center", children: [
|
|
519
|
+
/* @__PURE__ */ r.jsx(
|
|
520
|
+
Z,
|
|
521
|
+
{
|
|
522
|
+
variant: "ghost",
|
|
523
|
+
size: "icon",
|
|
524
|
+
onClick: j,
|
|
525
|
+
className: "h-8 w-8",
|
|
526
|
+
children: /* @__PURE__ */ r.jsx(ge, { className: "h-4 w-4" })
|
|
527
|
+
}
|
|
528
|
+
),
|
|
529
|
+
/* @__PURE__ */ r.jsx(
|
|
530
|
+
Z,
|
|
531
|
+
{
|
|
532
|
+
variant: "ghost",
|
|
533
|
+
size: "icon",
|
|
534
|
+
onClick: w,
|
|
535
|
+
className: "h-8 w-8",
|
|
536
|
+
children: /* @__PURE__ */ r.jsx(pe, { className: "h-4 w-4" })
|
|
537
|
+
}
|
|
538
|
+
)
|
|
539
|
+
] }),
|
|
540
|
+
/* @__PURE__ */ r.jsx("h2", { className: "text-lg font-semibold ml-2", children: T() })
|
|
541
|
+
] }),
|
|
542
|
+
/* @__PURE__ */ r.jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ r.jsxs(xe, { value: l, onValueChange: M, children: [
|
|
543
|
+
/* @__PURE__ */ r.jsx(De, { className: "w-32", children: /* @__PURE__ */ r.jsx(be, {}) }),
|
|
544
|
+
/* @__PURE__ */ r.jsxs(he, { children: [
|
|
545
|
+
/* @__PURE__ */ r.jsx(K, { value: "day", children: "Day" }),
|
|
546
|
+
/* @__PURE__ */ r.jsx(K, { value: "week", children: "Week" }),
|
|
547
|
+
/* @__PURE__ */ r.jsx(K, { value: "month", children: "Month" })
|
|
548
|
+
] })
|
|
549
|
+
] }) })
|
|
550
|
+
] }),
|
|
551
|
+
/* @__PURE__ */ r.jsxs("div", { className: "flex-1 overflow-auto", children: [
|
|
552
|
+
l === "month" && /* @__PURE__ */ r.jsx(
|
|
553
|
+
_e,
|
|
554
|
+
{
|
|
555
|
+
date: s,
|
|
556
|
+
events: t,
|
|
557
|
+
onEventClick: m,
|
|
558
|
+
onDateClick: g
|
|
559
|
+
}
|
|
560
|
+
),
|
|
561
|
+
l === "week" && /* @__PURE__ */ r.jsx(
|
|
562
|
+
Te,
|
|
563
|
+
{
|
|
564
|
+
date: s,
|
|
565
|
+
events: t,
|
|
566
|
+
onEventClick: m,
|
|
567
|
+
onDateClick: g
|
|
568
|
+
}
|
|
569
|
+
),
|
|
570
|
+
l === "day" && /* @__PURE__ */ r.jsx(
|
|
571
|
+
Fe,
|
|
572
|
+
{
|
|
573
|
+
date: s,
|
|
574
|
+
events: t,
|
|
575
|
+
onEventClick: m
|
|
576
|
+
}
|
|
577
|
+
)
|
|
578
|
+
] })
|
|
579
|
+
] });
|
|
580
|
+
}
|
|
581
|
+
function ue(t) {
|
|
582
|
+
const o = new Date(t), n = o.getDay(), m = o.getDate() - n;
|
|
583
|
+
return o.setDate(m), o;
|
|
584
|
+
}
|
|
585
|
+
function Ce(t) {
|
|
586
|
+
const o = t.getFullYear(), n = t.getMonth(), m = new Date(o, n, 1), g = new Date(o, n + 1, 0), c = m.getDay(), f = [];
|
|
587
|
+
for (let l = c - 1; l >= 0; l--) {
|
|
588
|
+
const u = new Date(m.getTime());
|
|
589
|
+
u.setDate(u.getDate() - (l + 1)), f.push(u);
|
|
590
|
+
}
|
|
591
|
+
for (let l = 1; l <= g.getDate(); l++)
|
|
592
|
+
f.push(new Date(o, n, l));
|
|
593
|
+
const a = 42 - f.length;
|
|
594
|
+
for (let l = 1; l <= a; l++) {
|
|
595
|
+
const u = new Date(g.getTime());
|
|
596
|
+
u.setDate(u.getDate() + l), f.push(u);
|
|
597
|
+
}
|
|
598
|
+
return f;
|
|
599
|
+
}
|
|
600
|
+
function fe(t, o) {
|
|
601
|
+
return t.getFullYear() === o.getFullYear() && t.getMonth() === o.getMonth() && t.getDate() === o.getDate();
|
|
602
|
+
}
|
|
603
|
+
function te(t, o) {
|
|
604
|
+
return o.filter((n) => {
|
|
605
|
+
const m = new Date(n.start), g = n.end ? new Date(n.end) : new Date(m), c = new Date(t);
|
|
606
|
+
c.setHours(0, 0, 0, 0);
|
|
607
|
+
const f = new Date(t);
|
|
608
|
+
f.setHours(23, 59, 59, 999);
|
|
609
|
+
const a = new Date(m);
|
|
610
|
+
a.setHours(0, 0, 0, 0);
|
|
611
|
+
const l = new Date(g);
|
|
612
|
+
return l.setHours(23, 59, 59, 999), c <= l && f >= a;
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
function _e({ date: t, events: o, onEventClick: n, onDateClick: m }) {
|
|
616
|
+
const g = Ce(t), c = /* @__PURE__ */ new Date(), f = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
617
|
+
return /* @__PURE__ */ r.jsxs("div", { className: "flex flex-col h-full", children: [
|
|
618
|
+
/* @__PURE__ */ r.jsx("div", { className: "grid grid-cols-7 border-b", children: f.map((a) => /* @__PURE__ */ r.jsx(
|
|
619
|
+
"div",
|
|
620
|
+
{
|
|
621
|
+
className: "p-2 text-center text-sm font-medium text-muted-foreground border-r last:border-r-0",
|
|
622
|
+
children: a
|
|
623
|
+
},
|
|
624
|
+
a
|
|
625
|
+
)) }),
|
|
626
|
+
/* @__PURE__ */ r.jsx("div", { className: "grid grid-cols-7 flex-1 auto-rows-fr", children: g.map((a, l) => {
|
|
627
|
+
const u = te(a, o), s = a.getMonth() === t.getMonth(), S = fe(a, c);
|
|
628
|
+
return /* @__PURE__ */ r.jsxs(
|
|
629
|
+
"div",
|
|
630
|
+
{
|
|
631
|
+
className: O(
|
|
632
|
+
"border-b border-r last:border-r-0 p-2 min-h-[100px] cursor-pointer hover:bg-accent/50",
|
|
633
|
+
!s && "bg-muted/30 text-muted-foreground"
|
|
634
|
+
),
|
|
635
|
+
onClick: () => m?.(a),
|
|
636
|
+
children: [
|
|
637
|
+
/* @__PURE__ */ r.jsx(
|
|
638
|
+
"div",
|
|
639
|
+
{
|
|
640
|
+
className: O(
|
|
641
|
+
"text-sm font-medium mb-1",
|
|
642
|
+
S && "inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-6 w-6"
|
|
643
|
+
),
|
|
644
|
+
children: a.getDate()
|
|
645
|
+
}
|
|
646
|
+
),
|
|
647
|
+
/* @__PURE__ */ r.jsxs("div", { className: "space-y-1", children: [
|
|
648
|
+
u.slice(0, 3).map((j) => /* @__PURE__ */ r.jsx(
|
|
649
|
+
"div",
|
|
650
|
+
{
|
|
651
|
+
className: O(
|
|
652
|
+
"text-xs px-2 py-1 rounded truncate cursor-pointer hover:opacity-80",
|
|
653
|
+
j.color || ee
|
|
654
|
+
),
|
|
655
|
+
style: j.color && j.color.startsWith("#") ? { backgroundColor: j.color } : void 0,
|
|
656
|
+
onClick: (w) => {
|
|
657
|
+
w.stopPropagation(), n?.(j);
|
|
658
|
+
},
|
|
659
|
+
children: j.title
|
|
660
|
+
},
|
|
661
|
+
j.id
|
|
662
|
+
)),
|
|
663
|
+
u.length > 3 && /* @__PURE__ */ r.jsxs("div", { className: "text-xs text-muted-foreground px-2", children: [
|
|
664
|
+
"+",
|
|
665
|
+
u.length - 3,
|
|
666
|
+
" more"
|
|
667
|
+
] })
|
|
668
|
+
] })
|
|
669
|
+
]
|
|
670
|
+
},
|
|
671
|
+
l
|
|
672
|
+
);
|
|
673
|
+
}) })
|
|
674
|
+
] });
|
|
675
|
+
}
|
|
676
|
+
function Te({ date: t, events: o, onEventClick: n, onDateClick: m }) {
|
|
677
|
+
const g = ue(t), c = Array.from({ length: 7 }, (a, l) => {
|
|
678
|
+
const u = new Date(g);
|
|
679
|
+
return u.setDate(u.getDate() + l), u;
|
|
680
|
+
}), f = /* @__PURE__ */ new Date();
|
|
681
|
+
return /* @__PURE__ */ r.jsxs("div", { className: "flex flex-col h-full", children: [
|
|
682
|
+
/* @__PURE__ */ r.jsx("div", { className: "grid grid-cols-7 border-b", children: c.map((a) => {
|
|
683
|
+
const l = fe(a, f);
|
|
684
|
+
return /* @__PURE__ */ r.jsxs(
|
|
685
|
+
"div",
|
|
686
|
+
{
|
|
687
|
+
className: "p-3 text-center border-r last:border-r-0",
|
|
688
|
+
children: [
|
|
689
|
+
/* @__PURE__ */ r.jsx("div", { className: "text-sm font-medium text-muted-foreground", children: a.toLocaleDateString("default", { weekday: "short" }) }),
|
|
690
|
+
/* @__PURE__ */ r.jsx(
|
|
691
|
+
"div",
|
|
692
|
+
{
|
|
693
|
+
className: O(
|
|
694
|
+
"text-lg font-semibold mt-1",
|
|
695
|
+
l && "inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-8 w-8"
|
|
696
|
+
),
|
|
697
|
+
children: a.getDate()
|
|
698
|
+
}
|
|
699
|
+
)
|
|
700
|
+
]
|
|
701
|
+
},
|
|
702
|
+
a.toISOString()
|
|
703
|
+
);
|
|
704
|
+
}) }),
|
|
705
|
+
/* @__PURE__ */ r.jsx("div", { className: "grid grid-cols-7 flex-1", children: c.map((a) => {
|
|
706
|
+
const l = te(a, o);
|
|
707
|
+
return /* @__PURE__ */ r.jsx(
|
|
708
|
+
"div",
|
|
709
|
+
{
|
|
710
|
+
className: "border-r last:border-r-0 p-2 min-h-[400px] cursor-pointer hover:bg-accent/50",
|
|
711
|
+
onClick: () => m?.(a),
|
|
712
|
+
children: /* @__PURE__ */ r.jsx("div", { className: "space-y-2", children: l.map((u) => /* @__PURE__ */ r.jsxs(
|
|
713
|
+
"div",
|
|
714
|
+
{
|
|
715
|
+
className: O(
|
|
716
|
+
"text-sm px-3 py-2 rounded cursor-pointer hover:opacity-80",
|
|
717
|
+
u.color || ee
|
|
718
|
+
),
|
|
719
|
+
style: u.color && u.color.startsWith("#") ? { backgroundColor: u.color } : void 0,
|
|
720
|
+
onClick: (s) => {
|
|
721
|
+
s.stopPropagation(), n?.(u);
|
|
722
|
+
},
|
|
723
|
+
children: [
|
|
724
|
+
/* @__PURE__ */ r.jsx("div", { className: "font-medium", children: u.title }),
|
|
725
|
+
!u.allDay && /* @__PURE__ */ r.jsx("div", { className: "text-xs opacity-90 mt-1", children: u.start.toLocaleTimeString("default", {
|
|
726
|
+
hour: "numeric",
|
|
727
|
+
minute: "2-digit"
|
|
728
|
+
}) })
|
|
729
|
+
]
|
|
730
|
+
},
|
|
731
|
+
u.id
|
|
732
|
+
)) })
|
|
733
|
+
},
|
|
734
|
+
a.toISOString()
|
|
735
|
+
);
|
|
736
|
+
}) })
|
|
737
|
+
] });
|
|
738
|
+
}
|
|
739
|
+
function Fe({ date: t, events: o, onEventClick: n }) {
|
|
740
|
+
const m = te(t, o), g = Array.from({ length: 24 }, (c, f) => f);
|
|
741
|
+
return /* @__PURE__ */ r.jsx("div", { className: "flex flex-col h-full", children: /* @__PURE__ */ r.jsx("div", { className: "flex-1 overflow-auto", children: g.map((c) => {
|
|
742
|
+
const f = m.filter((a) => a.allDay ? c === 0 : a.start.getHours() === c);
|
|
743
|
+
return /* @__PURE__ */ r.jsxs("div", { className: "flex border-b min-h-[60px]", children: [
|
|
744
|
+
/* @__PURE__ */ r.jsx("div", { className: "w-20 p-2 text-sm text-muted-foreground border-r", children: c === 0 ? "12 AM" : c < 12 ? `${c} AM` : c === 12 ? "12 PM" : `${c - 12} PM` }),
|
|
745
|
+
/* @__PURE__ */ r.jsx("div", { className: "flex-1 p-2 space-y-2", children: f.map((a) => /* @__PURE__ */ r.jsxs(
|
|
746
|
+
"div",
|
|
747
|
+
{
|
|
748
|
+
className: O(
|
|
749
|
+
"px-3 py-2 rounded cursor-pointer hover:opacity-80",
|
|
750
|
+
a.color || ee
|
|
751
|
+
),
|
|
752
|
+
style: a.color && a.color.startsWith("#") ? { backgroundColor: a.color } : void 0,
|
|
753
|
+
onClick: () => n?.(a),
|
|
754
|
+
children: [
|
|
755
|
+
/* @__PURE__ */ r.jsx("div", { className: "font-medium", children: a.title }),
|
|
756
|
+
!a.allDay && /* @__PURE__ */ r.jsxs("div", { className: "text-xs opacity-90 mt-1", children: [
|
|
757
|
+
a.start.toLocaleTimeString("default", {
|
|
758
|
+
hour: "numeric",
|
|
759
|
+
minute: "2-digit"
|
|
760
|
+
}),
|
|
761
|
+
a.end && ` - ${a.end.toLocaleTimeString("default", {
|
|
762
|
+
hour: "numeric",
|
|
763
|
+
minute: "2-digit"
|
|
764
|
+
})}`
|
|
765
|
+
] })
|
|
766
|
+
]
|
|
767
|
+
},
|
|
768
|
+
a.id
|
|
769
|
+
)) })
|
|
770
|
+
] }, c);
|
|
771
|
+
}) }) });
|
|
772
|
+
}
|
|
773
|
+
de.register(
|
|
774
|
+
"calendar-view",
|
|
775
|
+
({ schema: t, className: o, onAction: n, ...m }) => {
|
|
776
|
+
const g = L.useMemo(() => !t.data || !Array.isArray(t.data) ? [] : t.data.map((s, S) => {
|
|
777
|
+
const j = t.titleField || "title", w = t.startDateField || "start", C = t.endDateField || "end", M = t.colorField || "color", T = t.allDayField || "allDay", i = s[j] || "Untitled", E = s[w] ? new Date(s[w]) : /* @__PURE__ */ new Date(), R = s[C] ? new Date(s[C]) : void 0, P = s[T] !== void 0 ? s[T] : !1;
|
|
778
|
+
let F = s[M];
|
|
779
|
+
return F && t.colorMapping && t.colorMapping[F] && (F = t.colorMapping[F]), {
|
|
780
|
+
id: String(s.id || s._id || S),
|
|
781
|
+
title: i,
|
|
782
|
+
start: E,
|
|
783
|
+
end: R,
|
|
784
|
+
allDay: P,
|
|
785
|
+
color: F,
|
|
786
|
+
data: s
|
|
787
|
+
};
|
|
788
|
+
}), [t.data, t.titleField, t.startDateField, t.endDateField, t.colorField, t.allDayField, t.colorMapping]), c = L.useCallback((s) => {
|
|
789
|
+
n && n({
|
|
790
|
+
type: "event_click",
|
|
791
|
+
payload: { event: s.data, eventId: s.id }
|
|
792
|
+
}), t.onEventClick && t.onEventClick(s.data);
|
|
793
|
+
}, [n, t]), f = L.useCallback((s) => {
|
|
794
|
+
n && n({
|
|
795
|
+
type: "date_click",
|
|
796
|
+
payload: { date: s }
|
|
797
|
+
}), t.onDateClick && t.onDateClick(s);
|
|
798
|
+
}, [n, t]), a = L.useCallback((s) => {
|
|
799
|
+
n && n({
|
|
800
|
+
type: "view_change",
|
|
801
|
+
payload: { view: s }
|
|
802
|
+
}), t.onViewChange && t.onViewChange(s);
|
|
803
|
+
}, [n, t]), l = L.useCallback((s) => {
|
|
804
|
+
n && n({
|
|
805
|
+
type: "navigate",
|
|
806
|
+
payload: { date: s }
|
|
807
|
+
}), t.onNavigate && t.onNavigate(s);
|
|
808
|
+
}, [n, t]), u = t.view && ["month", "week", "day"].includes(t.view) ? t.view : "month";
|
|
809
|
+
return /* @__PURE__ */ r.jsx(
|
|
810
|
+
Se,
|
|
811
|
+
{
|
|
812
|
+
events: g,
|
|
813
|
+
view: u,
|
|
814
|
+
currentDate: t.currentDate ? new Date(t.currentDate) : void 0,
|
|
815
|
+
onEventClick: c,
|
|
816
|
+
onDateClick: t.allowCreate || t.onDateClick ? f : void 0,
|
|
817
|
+
onViewChange: a,
|
|
818
|
+
onNavigate: l,
|
|
819
|
+
className: o,
|
|
820
|
+
...m
|
|
821
|
+
}
|
|
822
|
+
);
|
|
823
|
+
},
|
|
824
|
+
{
|
|
825
|
+
label: "Calendar View",
|
|
826
|
+
inputs: [
|
|
827
|
+
{
|
|
828
|
+
name: "data",
|
|
829
|
+
type: "array",
|
|
830
|
+
label: "Data",
|
|
831
|
+
description: "Array of record objects to display as events"
|
|
832
|
+
},
|
|
833
|
+
{
|
|
834
|
+
name: "titleField",
|
|
835
|
+
type: "string",
|
|
836
|
+
label: "Title Field",
|
|
837
|
+
defaultValue: "title",
|
|
838
|
+
description: "Field name to use for event title"
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
name: "startDateField",
|
|
842
|
+
type: "string",
|
|
843
|
+
label: "Start Date Field",
|
|
844
|
+
defaultValue: "start",
|
|
845
|
+
description: "Field name for event start date"
|
|
846
|
+
},
|
|
847
|
+
{
|
|
848
|
+
name: "endDateField",
|
|
849
|
+
type: "string",
|
|
850
|
+
label: "End Date Field",
|
|
851
|
+
defaultValue: "end",
|
|
852
|
+
description: "Field name for event end date (optional)"
|
|
853
|
+
},
|
|
854
|
+
{
|
|
855
|
+
name: "allDayField",
|
|
856
|
+
type: "string",
|
|
857
|
+
label: "All Day Field",
|
|
858
|
+
defaultValue: "allDay",
|
|
859
|
+
description: "Field name for all-day flag"
|
|
860
|
+
},
|
|
861
|
+
{
|
|
862
|
+
name: "colorField",
|
|
863
|
+
type: "string",
|
|
864
|
+
label: "Color Field",
|
|
865
|
+
defaultValue: "color",
|
|
866
|
+
description: "Field name for event color"
|
|
867
|
+
},
|
|
868
|
+
{
|
|
869
|
+
name: "colorMapping",
|
|
870
|
+
type: "object",
|
|
871
|
+
label: "Color Mapping",
|
|
872
|
+
description: 'Map field values to colors (e.g., {meeting: "blue", deadline: "red"})'
|
|
873
|
+
},
|
|
874
|
+
{
|
|
875
|
+
name: "view",
|
|
876
|
+
type: "enum",
|
|
877
|
+
enum: ["month", "week", "day"],
|
|
878
|
+
defaultValue: "month",
|
|
879
|
+
label: "View Mode",
|
|
880
|
+
description: "Calendar view mode (month, week, or day)"
|
|
881
|
+
},
|
|
882
|
+
{
|
|
883
|
+
name: "currentDate",
|
|
884
|
+
type: "string",
|
|
885
|
+
label: "Current Date",
|
|
886
|
+
description: "ISO date string for initial calendar date"
|
|
887
|
+
},
|
|
888
|
+
{
|
|
889
|
+
name: "allowCreate",
|
|
890
|
+
type: "boolean",
|
|
891
|
+
label: "Allow Create",
|
|
892
|
+
defaultValue: !1,
|
|
893
|
+
description: "Allow creating events by clicking on dates"
|
|
894
|
+
},
|
|
895
|
+
{ name: "className", type: "string", label: "CSS Class" }
|
|
896
|
+
],
|
|
897
|
+
defaultProps: {
|
|
898
|
+
view: "month",
|
|
899
|
+
titleField: "title",
|
|
900
|
+
startDateField: "start",
|
|
901
|
+
endDateField: "end",
|
|
902
|
+
allDayField: "allDay",
|
|
903
|
+
colorField: "color",
|
|
904
|
+
allowCreate: !1,
|
|
905
|
+
data: [
|
|
906
|
+
{
|
|
907
|
+
id: 1,
|
|
908
|
+
title: "Team Meeting",
|
|
909
|
+
start: new Date((/* @__PURE__ */ new Date()).setHours(10, 0, 0, 0)).toISOString(),
|
|
910
|
+
end: new Date((/* @__PURE__ */ new Date()).setHours(11, 0, 0, 0)).toISOString(),
|
|
911
|
+
color: "#3b82f6",
|
|
912
|
+
allDay: !1
|
|
913
|
+
},
|
|
914
|
+
{
|
|
915
|
+
id: 2,
|
|
916
|
+
title: "Project Deadline",
|
|
917
|
+
start: new Date((/* @__PURE__ */ new Date()).setDate((/* @__PURE__ */ new Date()).getDate() + 3)).toISOString(),
|
|
918
|
+
color: "#ef4444",
|
|
919
|
+
allDay: !0
|
|
920
|
+
},
|
|
921
|
+
{
|
|
922
|
+
id: 3,
|
|
923
|
+
title: "Conference",
|
|
924
|
+
start: new Date((/* @__PURE__ */ new Date()).setDate((/* @__PURE__ */ new Date()).getDate() + 7)).toISOString(),
|
|
925
|
+
end: new Date((/* @__PURE__ */ new Date()).setDate((/* @__PURE__ */ new Date()).getDate() + 9)).toISOString(),
|
|
926
|
+
color: "#10b981",
|
|
927
|
+
allDay: !0
|
|
928
|
+
}
|
|
929
|
+
],
|
|
930
|
+
className: "h-[600px] border rounded-lg"
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
);
|
|
934
|
+
const Re = ({ schema: t }) => /* @__PURE__ */ r.jsx(Ee, { schema: t, dataSource: null });
|
|
935
|
+
de.register("object-calendar", Re, {
|
|
936
|
+
label: "Object Calendar",
|
|
937
|
+
category: "plugin",
|
|
938
|
+
inputs: [
|
|
939
|
+
{ name: "objectName", type: "string", label: "Object Name", required: !0 },
|
|
940
|
+
{ name: "calendar", type: "object", label: "Calendar Config", description: "startDateField, endDateField, titleField, colorField" }
|
|
941
|
+
]
|
|
942
|
+
});
|
|
943
|
+
export {
|
|
944
|
+
Se as CalendarView,
|
|
945
|
+
Ee as ObjectCalendar
|
|
946
|
+
};
|