@object-ui/plugin-calendar 0.5.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +10 -5
- package/CHANGELOG.md +15 -0
- package/dist/index.js +257 -247
- package/dist/index.umd.cjs +2 -2
- package/dist/src/CalendarView.d.ts +2 -1
- package/dist/src/CalendarView.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/CalendarView.test.tsx +6 -6
- package/src/CalendarView.tsx +7 -5
- package/src/ObjectCalendar.msw.test.tsx +8 -4
- package/src/index.tsx +11 -1
package/dist/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
3
|
-
import { ComponentRegistry as
|
|
4
|
-
import { useSchemaContext as
|
|
5
|
-
import { ChevronLeftIcon as
|
|
6
|
-
import { Button as V, Popover as
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
function
|
|
10
|
-
if (
|
|
11
|
-
|
|
1
|
+
import * as z from "react";
|
|
2
|
+
import ce, { useState as A, useMemo as Z, useEffect as le, useCallback as ge } from "react";
|
|
3
|
+
import { ComponentRegistry as ee } from "@object-ui/core";
|
|
4
|
+
import { useSchemaContext as xe } from "@object-ui/react";
|
|
5
|
+
import { ChevronLeftIcon as be, ChevronRightIcon as De, CalendarIcon as ye, PlusIcon as ve } from "lucide-react";
|
|
6
|
+
import { Button as V, Popover as he, PopoverTrigger as je, cn as S, PopoverContent as we, Calendar as Ee, Select as Ne, SelectTrigger as Fe, SelectValue as Se, SelectContent as _e, SelectItem as K } from "@object-ui/components";
|
|
7
|
+
var H = { exports: {} }, L = {};
|
|
8
|
+
var oe;
|
|
9
|
+
function ke() {
|
|
10
|
+
if (oe) return L;
|
|
11
|
+
oe = 1;
|
|
12
12
|
var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), n = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
13
|
-
function o(
|
|
14
|
-
var
|
|
15
|
-
if (s !== void 0 && (
|
|
13
|
+
function o(f, u, s) {
|
|
14
|
+
var m = null;
|
|
15
|
+
if (s !== void 0 && (m = "" + s), u.key !== void 0 && (m = "" + u.key), "key" in u) {
|
|
16
16
|
s = {};
|
|
17
17
|
for (var a in u)
|
|
18
18
|
a !== "key" && (s[a] = u[a]);
|
|
19
19
|
} else s = u;
|
|
20
20
|
return u = s.ref, {
|
|
21
21
|
$$typeof: e,
|
|
22
|
-
type:
|
|
23
|
-
key:
|
|
22
|
+
type: f,
|
|
23
|
+
key: m,
|
|
24
24
|
ref: u !== void 0 ? u : null,
|
|
25
25
|
props: s
|
|
26
26
|
};
|
|
@@ -28,9 +28,9 @@ function _e() {
|
|
|
28
28
|
return L.Fragment = n, L.jsx = o, L.jsxs = o, L;
|
|
29
29
|
}
|
|
30
30
|
var Y = {};
|
|
31
|
-
var
|
|
32
|
-
function
|
|
33
|
-
return
|
|
31
|
+
var ie;
|
|
32
|
+
function Ce() {
|
|
33
|
+
return ie || (ie = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
34
34
|
function e(t) {
|
|
35
35
|
if (t == null) return null;
|
|
36
36
|
if (typeof t == "function")
|
|
@@ -41,26 +41,26 @@ function ke() {
|
|
|
41
41
|
return "Fragment";
|
|
42
42
|
case $:
|
|
43
43
|
return "Profiler";
|
|
44
|
-
case
|
|
44
|
+
case M:
|
|
45
45
|
return "StrictMode";
|
|
46
|
-
case
|
|
46
|
+
case k:
|
|
47
47
|
return "Suspense";
|
|
48
48
|
case J:
|
|
49
49
|
return "SuspenseList";
|
|
50
|
-
case
|
|
50
|
+
case F:
|
|
51
51
|
return "Activity";
|
|
52
52
|
}
|
|
53
53
|
if (typeof t == "object")
|
|
54
54
|
switch (typeof t.tag == "number" && console.error(
|
|
55
55
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
56
56
|
), t.$$typeof) {
|
|
57
|
-
case
|
|
57
|
+
case P:
|
|
58
58
|
return "Portal";
|
|
59
|
-
case
|
|
59
|
+
case l:
|
|
60
60
|
return t.displayName || "Context";
|
|
61
|
-
case
|
|
61
|
+
case I:
|
|
62
62
|
return (t._context.displayName || "Context") + ".Consumer";
|
|
63
|
-
case
|
|
63
|
+
case N:
|
|
64
64
|
var i = t.render;
|
|
65
65
|
return t = t.displayName, t || (t = i.displayName || i.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
|
|
66
66
|
case G:
|
|
@@ -94,7 +94,7 @@ function ke() {
|
|
|
94
94
|
), n(t);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
function
|
|
97
|
+
function f(t) {
|
|
98
98
|
if (t === _) return "<>";
|
|
99
99
|
if (typeof t == "object" && t !== null && t.$$typeof === g)
|
|
100
100
|
return "<...>";
|
|
@@ -106,13 +106,13 @@ function ke() {
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
function u() {
|
|
109
|
-
var t =
|
|
109
|
+
var t = w.A;
|
|
110
110
|
return t === null ? null : t.getOwner();
|
|
111
111
|
}
|
|
112
112
|
function s() {
|
|
113
113
|
return Error("react-stack-top-frame");
|
|
114
114
|
}
|
|
115
|
-
function
|
|
115
|
+
function m(t) {
|
|
116
116
|
if (v.call(t, "key")) {
|
|
117
117
|
var i = Object.getOwnPropertyDescriptor(t, "key").get;
|
|
118
118
|
if (i && i.isReactWarning) return !1;
|
|
@@ -121,7 +121,7 @@ function ke() {
|
|
|
121
121
|
}
|
|
122
122
|
function a(t, i) {
|
|
123
123
|
function x() {
|
|
124
|
-
|
|
124
|
+
T || (T = !0, console.error(
|
|
125
125
|
"%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)",
|
|
126
126
|
i
|
|
127
127
|
));
|
|
@@ -137,10 +137,10 @@ function ke() {
|
|
|
137
137
|
"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."
|
|
138
138
|
)), t = this.props.ref, t !== void 0 ? t : null;
|
|
139
139
|
}
|
|
140
|
-
function
|
|
140
|
+
function c(t, i, x, D, q, B) {
|
|
141
141
|
var y = x.ref;
|
|
142
142
|
return t = {
|
|
143
|
-
$$typeof:
|
|
143
|
+
$$typeof: O,
|
|
144
144
|
type: t,
|
|
145
145
|
key: i,
|
|
146
146
|
props: x,
|
|
@@ -162,7 +162,7 @@ function ke() {
|
|
|
162
162
|
configurable: !1,
|
|
163
163
|
enumerable: !1,
|
|
164
164
|
writable: !0,
|
|
165
|
-
value:
|
|
165
|
+
value: q
|
|
166
166
|
}), Object.defineProperty(t, "_debugTask", {
|
|
167
167
|
configurable: !1,
|
|
168
168
|
enumerable: !1,
|
|
@@ -170,25 +170,25 @@ function ke() {
|
|
|
170
170
|
value: B
|
|
171
171
|
}), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
|
|
172
172
|
}
|
|
173
|
-
function
|
|
173
|
+
function b(t, i, x, D, q, B) {
|
|
174
174
|
var y = i.children;
|
|
175
175
|
if (y !== void 0)
|
|
176
176
|
if (D)
|
|
177
177
|
if (X(y)) {
|
|
178
178
|
for (D = 0; D < y.length; D++)
|
|
179
|
-
|
|
179
|
+
h(y[D]);
|
|
180
180
|
Object.freeze && Object.freeze(y);
|
|
181
181
|
} else
|
|
182
182
|
console.error(
|
|
183
183
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
184
184
|
);
|
|
185
|
-
else
|
|
185
|
+
else h(y);
|
|
186
186
|
if (v.call(i, "key")) {
|
|
187
187
|
y = e(t);
|
|
188
|
-
var
|
|
189
|
-
return
|
|
188
|
+
var R = Object.keys(i).filter(function(pe) {
|
|
189
|
+
return pe !== "key";
|
|
190
190
|
});
|
|
191
|
-
D = 0 <
|
|
191
|
+
D = 0 < R.length ? "{key: someKey, " + R.join(": ..., ") + ": ...}" : "{key: someKey}", ne[y + D] || (R = 0 < R.length ? "{" + R.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
192
192
|
`A props object containing a "key" prop is being spread into JSX:
|
|
193
193
|
let props = %s;
|
|
194
194
|
<%s {...props} />
|
|
@@ -197,11 +197,11 @@ React keys must be passed directly to JSX without using spread:
|
|
|
197
197
|
<%s key={someKey} {...props} />`,
|
|
198
198
|
D,
|
|
199
199
|
y,
|
|
200
|
-
|
|
200
|
+
R,
|
|
201
201
|
y
|
|
202
|
-
),
|
|
202
|
+
), ne[y + D] = !0);
|
|
203
203
|
}
|
|
204
|
-
if (y = null, x !== void 0 && (o(x), y = "" + x),
|
|
204
|
+
if (y = null, x !== void 0 && (o(x), y = "" + x), m(i) && (o(i.key), y = "" + i.key), "key" in i) {
|
|
205
205
|
x = {};
|
|
206
206
|
for (var Q in i)
|
|
207
207
|
Q !== "key" && (x[Q] = i[Q]);
|
|
@@ -209,130 +209,131 @@ React keys must be passed directly to JSX without using spread:
|
|
|
209
209
|
return y && a(
|
|
210
210
|
x,
|
|
211
211
|
typeof t == "function" ? t.displayName || t.name || "Unknown" : t
|
|
212
|
-
),
|
|
212
|
+
), c(
|
|
213
213
|
t,
|
|
214
214
|
y,
|
|
215
215
|
x,
|
|
216
216
|
u(),
|
|
217
|
-
|
|
217
|
+
q,
|
|
218
218
|
B
|
|
219
219
|
);
|
|
220
220
|
}
|
|
221
|
-
function
|
|
222
|
-
|
|
221
|
+
function h(t) {
|
|
222
|
+
p(t) ? t._store && (t._store.validated = 1) : typeof t == "object" && t !== null && t.$$typeof === g && (t._payload.status === "fulfilled" ? p(t._payload.value) && t._payload.value._store && (t._payload.value._store.validated = 1) : t._store && (t._store.validated = 1));
|
|
223
223
|
}
|
|
224
|
-
function
|
|
225
|
-
return typeof t == "object" && t !== null && t.$$typeof ===
|
|
224
|
+
function p(t) {
|
|
225
|
+
return typeof t == "object" && t !== null && t.$$typeof === O;
|
|
226
226
|
}
|
|
227
|
-
var
|
|
227
|
+
var j = ce, O = /* @__PURE__ */ Symbol.for("react.transitional.element"), P = /* @__PURE__ */ Symbol.for("react.portal"), _ = /* @__PURE__ */ Symbol.for("react.fragment"), M = /* @__PURE__ */ Symbol.for("react.strict_mode"), $ = /* @__PURE__ */ Symbol.for("react.profiler"), I = /* @__PURE__ */ Symbol.for("react.consumer"), l = /* @__PURE__ */ Symbol.for("react.context"), N = /* @__PURE__ */ Symbol.for("react.forward_ref"), k = /* @__PURE__ */ Symbol.for("react.suspense"), J = /* @__PURE__ */ Symbol.for("react.suspense_list"), G = /* @__PURE__ */ Symbol.for("react.memo"), g = /* @__PURE__ */ Symbol.for("react.lazy"), F = /* @__PURE__ */ Symbol.for("react.activity"), E = /* @__PURE__ */ Symbol.for("react.client.reference"), w = j.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, v = Object.prototype.hasOwnProperty, X = Array.isArray, C = console.createTask ? console.createTask : function() {
|
|
228
228
|
return null;
|
|
229
229
|
};
|
|
230
|
-
|
|
230
|
+
j = {
|
|
231
231
|
react_stack_bottom_frame: function(t) {
|
|
232
232
|
return t();
|
|
233
233
|
}
|
|
234
234
|
};
|
|
235
|
-
var
|
|
236
|
-
|
|
235
|
+
var T, W = {}, U = j.react_stack_bottom_frame.bind(
|
|
236
|
+
j,
|
|
237
237
|
s
|
|
238
|
-
)(),
|
|
238
|
+
)(), ae = C(f(s)), ne = {};
|
|
239
239
|
Y.Fragment = _, Y.jsx = function(t, i, x) {
|
|
240
|
-
var D = 1e4 >
|
|
241
|
-
return
|
|
240
|
+
var D = 1e4 > w.recentlyCreatedOwnerStacks++;
|
|
241
|
+
return b(
|
|
242
242
|
t,
|
|
243
243
|
i,
|
|
244
244
|
x,
|
|
245
245
|
!1,
|
|
246
246
|
D ? Error("react-stack-top-frame") : U,
|
|
247
|
-
D ?
|
|
247
|
+
D ? C(f(t)) : ae
|
|
248
248
|
);
|
|
249
249
|
}, Y.jsxs = function(t, i, x) {
|
|
250
|
-
var D = 1e4 >
|
|
251
|
-
return
|
|
250
|
+
var D = 1e4 > w.recentlyCreatedOwnerStacks++;
|
|
251
|
+
return b(
|
|
252
252
|
t,
|
|
253
253
|
i,
|
|
254
254
|
x,
|
|
255
255
|
!0,
|
|
256
256
|
D ? Error("react-stack-top-frame") : U,
|
|
257
|
-
D ?
|
|
257
|
+
D ? C(f(t)) : ae
|
|
258
258
|
);
|
|
259
259
|
};
|
|
260
260
|
})()), Y;
|
|
261
261
|
}
|
|
262
|
-
var
|
|
263
|
-
function
|
|
264
|
-
return
|
|
262
|
+
var se;
|
|
263
|
+
function Te() {
|
|
264
|
+
return se || (se = 1, process.env.NODE_ENV === "production" ? H.exports = ke() : H.exports = Ce()), H.exports;
|
|
265
265
|
}
|
|
266
|
-
var r =
|
|
267
|
-
const
|
|
266
|
+
var r = Te();
|
|
267
|
+
const te = "bg-blue-500 text-white";
|
|
268
268
|
function de({
|
|
269
269
|
events: e = [],
|
|
270
270
|
view: n = "month",
|
|
271
271
|
currentDate: o = /* @__PURE__ */ new Date(),
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
272
|
+
locale: f = "default",
|
|
273
|
+
onEventClick: u,
|
|
274
|
+
onDateClick: s,
|
|
275
|
+
onViewChange: m,
|
|
276
|
+
onNavigate: a,
|
|
277
|
+
onAddClick: d,
|
|
278
|
+
className: c
|
|
278
279
|
}) {
|
|
279
|
-
const [
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}, [o]),
|
|
283
|
-
|
|
280
|
+
const [b, h] = z.useState(n), [p, j] = z.useState(o);
|
|
281
|
+
z.useEffect(() => {
|
|
282
|
+
j(o);
|
|
283
|
+
}, [o]), z.useEffect(() => {
|
|
284
|
+
h(n);
|
|
284
285
|
}, [n]);
|
|
285
|
-
const
|
|
286
|
-
const
|
|
287
|
-
|
|
286
|
+
const O = () => {
|
|
287
|
+
const l = new Date(p);
|
|
288
|
+
b === "month" ? l.setMonth(l.getMonth() - 1) : b === "week" ? l.setDate(l.getDate() - 7) : l.setDate(l.getDate() - 1), j(l), a?.(l);
|
|
288
289
|
}, P = () => {
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
},
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
},
|
|
295
|
-
|
|
296
|
-
},
|
|
297
|
-
if (
|
|
298
|
-
return p.toLocaleDateString(
|
|
290
|
+
const l = new Date(p);
|
|
291
|
+
b === "month" ? l.setMonth(l.getMonth() + 1) : b === "week" ? l.setDate(l.getDate() + 7) : l.setDate(l.getDate() + 1), j(l), a?.(l);
|
|
292
|
+
}, _ = () => {
|
|
293
|
+
const l = /* @__PURE__ */ new Date();
|
|
294
|
+
j(l), a?.(l);
|
|
295
|
+
}, M = (l) => {
|
|
296
|
+
h(l), m?.(l);
|
|
297
|
+
}, $ = () => {
|
|
298
|
+
if (b === "month")
|
|
299
|
+
return p.toLocaleDateString(f, {
|
|
299
300
|
month: "long",
|
|
300
301
|
year: "numeric"
|
|
301
302
|
});
|
|
302
|
-
if (
|
|
303
|
-
const
|
|
304
|
-
return
|
|
303
|
+
if (b === "week") {
|
|
304
|
+
const l = ue(p), N = new Date(l);
|
|
305
|
+
return N.setDate(N.getDate() + 6), `${l.toLocaleDateString(f, {
|
|
305
306
|
month: "short",
|
|
306
307
|
day: "numeric"
|
|
307
|
-
})} - ${
|
|
308
|
+
})} - ${N.toLocaleDateString(f, {
|
|
308
309
|
month: "short",
|
|
309
310
|
day: "numeric",
|
|
310
311
|
year: "numeric"
|
|
311
312
|
})}`;
|
|
312
313
|
} else
|
|
313
|
-
return p.toLocaleDateString(
|
|
314
|
+
return p.toLocaleDateString(f, {
|
|
314
315
|
weekday: "long",
|
|
315
316
|
month: "long",
|
|
316
317
|
day: "numeric",
|
|
317
318
|
year: "numeric"
|
|
318
319
|
});
|
|
319
|
-
},
|
|
320
|
-
|
|
320
|
+
}, I = (l) => {
|
|
321
|
+
l && (j(l), a?.(l));
|
|
321
322
|
};
|
|
322
|
-
return /* @__PURE__ */ r.jsxs("div", { className:
|
|
323
|
+
return /* @__PURE__ */ r.jsxs("div", { className: S("flex flex-col h-full bg-background", c), children: [
|
|
323
324
|
/* @__PURE__ */ r.jsxs("div", { className: "flex items-center justify-between p-4 border-b", children: [
|
|
324
325
|
/* @__PURE__ */ r.jsxs("div", { className: "flex items-center gap-4", children: [
|
|
325
326
|
/* @__PURE__ */ r.jsxs("div", { className: "flex items-center bg-muted/50 rounded-lg p-1 gap-1", children: [
|
|
326
|
-
/* @__PURE__ */ r.jsx(V, { variant: "ghost", size: "sm", onClick:
|
|
327
|
+
/* @__PURE__ */ r.jsx(V, { variant: "ghost", size: "sm", onClick: _, className: "h-8", children: "Today" }),
|
|
327
328
|
/* @__PURE__ */ r.jsx("div", { className: "h-4 w-px bg-border mx-1" }),
|
|
328
329
|
/* @__PURE__ */ r.jsx(
|
|
329
330
|
V,
|
|
330
331
|
{
|
|
331
332
|
variant: "ghost",
|
|
332
333
|
size: "icon",
|
|
333
|
-
onClick:
|
|
334
|
+
onClick: O,
|
|
334
335
|
className: "h-8 w-8",
|
|
335
|
-
children: /* @__PURE__ */ r.jsx(
|
|
336
|
+
children: /* @__PURE__ */ r.jsx(be, { className: "h-4 w-4" })
|
|
336
337
|
}
|
|
337
338
|
),
|
|
338
339
|
/* @__PURE__ */ r.jsx(
|
|
@@ -342,31 +343,31 @@ function de({
|
|
|
342
343
|
size: "icon",
|
|
343
344
|
onClick: P,
|
|
344
345
|
className: "h-8 w-8",
|
|
345
|
-
children: /* @__PURE__ */ r.jsx(
|
|
346
|
+
children: /* @__PURE__ */ r.jsx(De, { className: "h-4 w-4" })
|
|
346
347
|
}
|
|
347
348
|
)
|
|
348
349
|
] }),
|
|
349
|
-
/* @__PURE__ */ r.jsxs(
|
|
350
|
-
/* @__PURE__ */ r.jsx(
|
|
350
|
+
/* @__PURE__ */ r.jsxs(he, { children: [
|
|
351
|
+
/* @__PURE__ */ r.jsx(je, { asChild: !0, children: /* @__PURE__ */ r.jsxs(
|
|
351
352
|
V,
|
|
352
353
|
{
|
|
353
354
|
variant: "ghost",
|
|
354
|
-
className:
|
|
355
|
+
className: S(
|
|
355
356
|
"text-xl font-semibold h-auto px-3 py-1 hover:bg-muted/50 transition-colors",
|
|
356
357
|
"flex items-center gap-2"
|
|
357
358
|
),
|
|
358
359
|
children: [
|
|
359
|
-
/* @__PURE__ */ r.jsx(
|
|
360
|
-
/* @__PURE__ */ r.jsx("span", { children:
|
|
360
|
+
/* @__PURE__ */ r.jsx(ye, { className: "h-5 w-5 text-muted-foreground" }),
|
|
361
|
+
/* @__PURE__ */ r.jsx("span", { children: $() })
|
|
361
362
|
]
|
|
362
363
|
}
|
|
363
364
|
) }),
|
|
364
|
-
/* @__PURE__ */ r.jsx(
|
|
365
|
-
|
|
365
|
+
/* @__PURE__ */ r.jsx(we, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ r.jsx(
|
|
366
|
+
Ee,
|
|
366
367
|
{
|
|
367
368
|
mode: "single",
|
|
368
369
|
selected: p,
|
|
369
|
-
onSelect:
|
|
370
|
+
onSelect: I,
|
|
370
371
|
initialFocus: !0,
|
|
371
372
|
fromYear: 2e3,
|
|
372
373
|
toYear: 2050
|
|
@@ -375,88 +376,88 @@ function de({
|
|
|
375
376
|
] })
|
|
376
377
|
] }),
|
|
377
378
|
/* @__PURE__ */ r.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
378
|
-
/* @__PURE__ */ r.jsxs(
|
|
379
|
-
/* @__PURE__ */ r.jsx(
|
|
380
|
-
/* @__PURE__ */ r.jsxs(
|
|
379
|
+
/* @__PURE__ */ r.jsxs(Ne, { value: b, onValueChange: M, children: [
|
|
380
|
+
/* @__PURE__ */ r.jsx(Fe, { className: "w-32 bg-background", children: /* @__PURE__ */ r.jsx(Se, {}) }),
|
|
381
|
+
/* @__PURE__ */ r.jsxs(_e, { children: [
|
|
381
382
|
/* @__PURE__ */ r.jsx(K, { value: "day", children: "Day" }),
|
|
382
383
|
/* @__PURE__ */ r.jsx(K, { value: "week", children: "Week" }),
|
|
383
384
|
/* @__PURE__ */ r.jsx(K, { value: "month", children: "Month" })
|
|
384
385
|
] })
|
|
385
386
|
] }),
|
|
386
|
-
|
|
387
|
-
/* @__PURE__ */ r.jsx(
|
|
387
|
+
d && /* @__PURE__ */ r.jsxs(V, { onClick: d, size: "sm", className: "gap-1", children: [
|
|
388
|
+
/* @__PURE__ */ r.jsx(ve, { className: "h-4 w-4" }),
|
|
388
389
|
"New"
|
|
389
390
|
] })
|
|
390
391
|
] })
|
|
391
392
|
] }),
|
|
392
393
|
/* @__PURE__ */ r.jsxs("div", { className: "flex-1 overflow-auto", children: [
|
|
393
|
-
|
|
394
|
-
|
|
394
|
+
b === "month" && /* @__PURE__ */ r.jsx(
|
|
395
|
+
Ae,
|
|
395
396
|
{
|
|
396
397
|
date: p,
|
|
397
398
|
events: e,
|
|
398
|
-
onEventClick:
|
|
399
|
-
onDateClick:
|
|
399
|
+
onEventClick: u,
|
|
400
|
+
onDateClick: s
|
|
400
401
|
}
|
|
401
402
|
),
|
|
402
|
-
|
|
403
|
-
|
|
403
|
+
b === "week" && /* @__PURE__ */ r.jsx(
|
|
404
|
+
Oe,
|
|
404
405
|
{
|
|
405
406
|
date: p,
|
|
406
407
|
events: e,
|
|
407
|
-
onEventClick:
|
|
408
|
-
onDateClick:
|
|
408
|
+
onEventClick: u,
|
|
409
|
+
onDateClick: s
|
|
409
410
|
}
|
|
410
411
|
),
|
|
411
|
-
|
|
412
|
-
|
|
412
|
+
b === "day" && /* @__PURE__ */ r.jsx(
|
|
413
|
+
Pe,
|
|
413
414
|
{
|
|
414
415
|
date: p,
|
|
415
416
|
events: e,
|
|
416
|
-
onEventClick:
|
|
417
|
+
onEventClick: u
|
|
417
418
|
}
|
|
418
419
|
)
|
|
419
420
|
] })
|
|
420
421
|
] });
|
|
421
422
|
}
|
|
422
423
|
function ue(e) {
|
|
423
|
-
const n = new Date(e), o = n.getDay(),
|
|
424
|
-
return n.setDate(
|
|
424
|
+
const n = new Date(e), o = n.getDay(), f = n.getDate() - o;
|
|
425
|
+
return n.setDate(f), n;
|
|
425
426
|
}
|
|
426
|
-
function
|
|
427
|
-
const n = e.getFullYear(), o = e.getMonth(),
|
|
427
|
+
function Re(e) {
|
|
428
|
+
const n = e.getFullYear(), o = e.getMonth(), f = new Date(n, o, 1), u = new Date(n, o + 1, 0), s = f.getDay(), m = [];
|
|
428
429
|
for (let d = s - 1; d >= 0; d--) {
|
|
429
|
-
const
|
|
430
|
-
|
|
430
|
+
const c = new Date(f.getTime());
|
|
431
|
+
c.setDate(c.getDate() - (d + 1)), m.push(c);
|
|
431
432
|
}
|
|
432
433
|
for (let d = 1; d <= u.getDate(); d++)
|
|
433
|
-
|
|
434
|
-
const a = 42 -
|
|
434
|
+
m.push(new Date(n, o, d));
|
|
435
|
+
const a = 42 - m.length;
|
|
435
436
|
for (let d = 1; d <= a; d++) {
|
|
436
|
-
const
|
|
437
|
-
|
|
437
|
+
const c = new Date(u.getTime());
|
|
438
|
+
c.setDate(c.getDate() + d), m.push(c);
|
|
438
439
|
}
|
|
439
|
-
return
|
|
440
|
+
return m;
|
|
440
441
|
}
|
|
441
442
|
function fe(e, n) {
|
|
442
443
|
return e.getFullYear() === n.getFullYear() && e.getMonth() === n.getMonth() && e.getDate() === n.getDate();
|
|
443
444
|
}
|
|
444
|
-
function
|
|
445
|
+
function re(e, n) {
|
|
445
446
|
return n.filter((o) => {
|
|
446
|
-
const
|
|
447
|
+
const f = new Date(o.start), u = o.end ? new Date(o.end) : new Date(f), s = new Date(e);
|
|
447
448
|
s.setHours(0, 0, 0, 0);
|
|
448
|
-
const
|
|
449
|
-
|
|
450
|
-
const a = new Date(
|
|
449
|
+
const m = new Date(e);
|
|
450
|
+
m.setHours(23, 59, 59, 999);
|
|
451
|
+
const a = new Date(f);
|
|
451
452
|
a.setHours(0, 0, 0, 0);
|
|
452
453
|
const d = new Date(u);
|
|
453
|
-
return d.setHours(23, 59, 59, 999), s <= d &&
|
|
454
|
+
return d.setHours(23, 59, 59, 999), s <= d && m >= a;
|
|
454
455
|
});
|
|
455
456
|
}
|
|
456
|
-
function
|
|
457
|
-
const u =
|
|
457
|
+
function Ae({ date: e, events: n, onEventClick: o, onDateClick: f }) {
|
|
458
|
+
const u = Re(e), s = /* @__PURE__ */ new Date(), m = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
458
459
|
return /* @__PURE__ */ r.jsxs("div", { className: "flex flex-col h-full", children: [
|
|
459
|
-
/* @__PURE__ */ r.jsx("div", { className: "grid grid-cols-7 border-b", children:
|
|
460
|
+
/* @__PURE__ */ r.jsx("div", { className: "grid grid-cols-7 border-b", children: m.map((a) => /* @__PURE__ */ r.jsx(
|
|
460
461
|
"div",
|
|
461
462
|
{
|
|
462
463
|
className: "p-2 text-center text-sm font-medium text-muted-foreground border-r last:border-r-0",
|
|
@@ -465,45 +466,45 @@ function Re({ date: e, events: n, onEventClick: o, onDateClick: m }) {
|
|
|
465
466
|
a
|
|
466
467
|
)) }),
|
|
467
468
|
/* @__PURE__ */ r.jsx("div", { className: "grid grid-cols-7 flex-1 auto-rows-fr", children: u.map((a, d) => {
|
|
468
|
-
const
|
|
469
|
+
const c = re(a, n), b = a.getMonth() === e.getMonth(), h = fe(a, s);
|
|
469
470
|
return /* @__PURE__ */ r.jsxs(
|
|
470
471
|
"div",
|
|
471
472
|
{
|
|
472
|
-
className:
|
|
473
|
+
className: S(
|
|
473
474
|
"border-b border-r last:border-r-0 p-2 min-h-[100px] cursor-pointer hover:bg-accent/50",
|
|
474
|
-
!
|
|
475
|
+
!b && "bg-muted/30 text-muted-foreground"
|
|
475
476
|
),
|
|
476
|
-
onClick: () =>
|
|
477
|
+
onClick: () => f?.(a),
|
|
477
478
|
children: [
|
|
478
479
|
/* @__PURE__ */ r.jsx(
|
|
479
480
|
"div",
|
|
480
481
|
{
|
|
481
|
-
className:
|
|
482
|
+
className: S(
|
|
482
483
|
"text-sm font-medium mb-1",
|
|
483
|
-
|
|
484
|
+
h && "inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-6 w-6"
|
|
484
485
|
),
|
|
485
486
|
children: a.getDate()
|
|
486
487
|
}
|
|
487
488
|
),
|
|
488
489
|
/* @__PURE__ */ r.jsxs("div", { className: "space-y-1", children: [
|
|
489
|
-
|
|
490
|
+
c.slice(0, 3).map((p) => /* @__PURE__ */ r.jsx(
|
|
490
491
|
"div",
|
|
491
492
|
{
|
|
492
|
-
className:
|
|
493
|
+
className: S(
|
|
493
494
|
"text-xs px-2 py-1 rounded truncate cursor-pointer hover:opacity-80",
|
|
494
|
-
|
|
495
|
+
p.color || te
|
|
495
496
|
),
|
|
496
|
-
style:
|
|
497
|
-
onClick: (
|
|
498
|
-
|
|
497
|
+
style: p.color && p.color.startsWith("#") ? { backgroundColor: p.color } : void 0,
|
|
498
|
+
onClick: (j) => {
|
|
499
|
+
j.stopPropagation(), o?.(p);
|
|
499
500
|
},
|
|
500
|
-
children:
|
|
501
|
+
children: p.title
|
|
501
502
|
},
|
|
502
|
-
|
|
503
|
+
p.id
|
|
503
504
|
)),
|
|
504
|
-
|
|
505
|
+
c.length > 3 && /* @__PURE__ */ r.jsxs("div", { className: "text-xs text-muted-foreground px-2", children: [
|
|
505
506
|
"+",
|
|
506
|
-
|
|
507
|
+
c.length - 3,
|
|
507
508
|
" more"
|
|
508
509
|
] })
|
|
509
510
|
] })
|
|
@@ -514,24 +515,24 @@ function Re({ date: e, events: n, onEventClick: o, onDateClick: m }) {
|
|
|
514
515
|
}) })
|
|
515
516
|
] });
|
|
516
517
|
}
|
|
517
|
-
function
|
|
518
|
+
function Oe({ date: e, events: n, onEventClick: o, onDateClick: f }) {
|
|
518
519
|
const u = ue(e), s = Array.from({ length: 7 }, (a, d) => {
|
|
519
|
-
const
|
|
520
|
-
return
|
|
521
|
-
}),
|
|
520
|
+
const c = new Date(u);
|
|
521
|
+
return c.setDate(c.getDate() + d), c;
|
|
522
|
+
}), m = /* @__PURE__ */ new Date();
|
|
522
523
|
return /* @__PURE__ */ r.jsxs("div", { className: "flex flex-col h-full", children: [
|
|
523
524
|
/* @__PURE__ */ r.jsx("div", { className: "grid grid-cols-7 border-b", children: s.map((a) => {
|
|
524
|
-
const d = fe(a,
|
|
525
|
+
const d = fe(a, m);
|
|
525
526
|
return /* @__PURE__ */ r.jsxs(
|
|
526
527
|
"div",
|
|
527
528
|
{
|
|
528
529
|
className: "p-3 text-center border-r last:border-r-0",
|
|
529
530
|
children: [
|
|
530
|
-
/* @__PURE__ */ r.jsx("div", { className: "text-sm font-medium text-muted-foreground", children: a.toLocaleDateString(
|
|
531
|
+
/* @__PURE__ */ r.jsx("div", { className: "text-sm font-medium text-muted-foreground", children: a.toLocaleDateString(locale, { weekday: "short" }) }),
|
|
531
532
|
/* @__PURE__ */ r.jsx(
|
|
532
533
|
"div",
|
|
533
534
|
{
|
|
534
|
-
className:
|
|
535
|
+
className: S(
|
|
535
536
|
"text-lg font-semibold mt-1",
|
|
536
537
|
d && "inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-8 w-8"
|
|
537
538
|
),
|
|
@@ -544,32 +545,32 @@ function Ae({ date: e, events: n, onEventClick: o, onDateClick: m }) {
|
|
|
544
545
|
);
|
|
545
546
|
}) }),
|
|
546
547
|
/* @__PURE__ */ r.jsx("div", { className: "grid grid-cols-7 flex-1", children: s.map((a) => {
|
|
547
|
-
const d =
|
|
548
|
+
const d = re(a, n);
|
|
548
549
|
return /* @__PURE__ */ r.jsx(
|
|
549
550
|
"div",
|
|
550
551
|
{
|
|
551
552
|
className: "border-r last:border-r-0 p-2 min-h-[400px] cursor-pointer hover:bg-accent/50",
|
|
552
|
-
onClick: () =>
|
|
553
|
-
children: /* @__PURE__ */ r.jsx("div", { className: "space-y-2", children: d.map((
|
|
553
|
+
onClick: () => f?.(a),
|
|
554
|
+
children: /* @__PURE__ */ r.jsx("div", { className: "space-y-2", children: d.map((c) => /* @__PURE__ */ r.jsxs(
|
|
554
555
|
"div",
|
|
555
556
|
{
|
|
556
|
-
className:
|
|
557
|
+
className: S(
|
|
557
558
|
"text-sm px-3 py-2 rounded cursor-pointer hover:opacity-80",
|
|
558
|
-
|
|
559
|
+
c.color || te
|
|
559
560
|
),
|
|
560
|
-
style:
|
|
561
|
-
onClick: (
|
|
562
|
-
|
|
561
|
+
style: c.color && c.color.startsWith("#") ? { backgroundColor: c.color } : void 0,
|
|
562
|
+
onClick: (b) => {
|
|
563
|
+
b.stopPropagation(), o?.(c);
|
|
563
564
|
},
|
|
564
565
|
children: [
|
|
565
|
-
/* @__PURE__ */ r.jsx("div", { className: "font-medium", children:
|
|
566
|
-
!
|
|
566
|
+
/* @__PURE__ */ r.jsx("div", { className: "font-medium", children: c.title }),
|
|
567
|
+
!c.allDay && /* @__PURE__ */ r.jsx("div", { className: "text-xs opacity-90 mt-1", children: c.start.toLocaleTimeString("default", {
|
|
567
568
|
hour: "numeric",
|
|
568
569
|
minute: "2-digit"
|
|
569
570
|
}) })
|
|
570
571
|
]
|
|
571
572
|
},
|
|
572
|
-
|
|
573
|
+
c.id
|
|
573
574
|
)) })
|
|
574
575
|
},
|
|
575
576
|
a.toISOString()
|
|
@@ -577,18 +578,18 @@ function Ae({ date: e, events: n, onEventClick: o, onDateClick: m }) {
|
|
|
577
578
|
}) })
|
|
578
579
|
] });
|
|
579
580
|
}
|
|
580
|
-
function
|
|
581
|
-
const
|
|
581
|
+
function Pe({ date: e, events: n, onEventClick: o }) {
|
|
582
|
+
const f = re(e, n), u = Array.from({ length: 24 }, (s, m) => m);
|
|
582
583
|
return /* @__PURE__ */ r.jsx("div", { className: "flex flex-col h-full", children: /* @__PURE__ */ r.jsx("div", { className: "flex-1 overflow-auto", children: u.map((s) => {
|
|
583
|
-
const
|
|
584
|
+
const m = f.filter((a) => a.allDay ? s === 0 : a.start.getHours() === s);
|
|
584
585
|
return /* @__PURE__ */ r.jsxs("div", { className: "flex border-b min-h-[60px]", children: [
|
|
585
586
|
/* @__PURE__ */ r.jsx("div", { className: "w-20 p-2 text-sm text-muted-foreground border-r", children: s === 0 ? "12 AM" : s < 12 ? `${s} AM` : s === 12 ? "12 PM" : `${s - 12} PM` }),
|
|
586
|
-
/* @__PURE__ */ r.jsx("div", { className: "flex-1 p-2 space-y-2", children:
|
|
587
|
+
/* @__PURE__ */ r.jsx("div", { className: "flex-1 p-2 space-y-2", children: m.map((a) => /* @__PURE__ */ r.jsxs(
|
|
587
588
|
"div",
|
|
588
589
|
{
|
|
589
|
-
className:
|
|
590
|
+
className: S(
|
|
590
591
|
"px-3 py-2 rounded cursor-pointer hover:opacity-80",
|
|
591
|
-
a.color ||
|
|
592
|
+
a.color || te
|
|
592
593
|
),
|
|
593
594
|
style: a.color && a.color.startsWith("#") ? { backgroundColor: a.color } : void 0,
|
|
594
595
|
onClick: () => o?.(a),
|
|
@@ -611,7 +612,7 @@ function Oe({ date: e, events: n, onEventClick: o }) {
|
|
|
611
612
|
] }, s);
|
|
612
613
|
}) }) });
|
|
613
614
|
}
|
|
614
|
-
function
|
|
615
|
+
function Me(e) {
|
|
615
616
|
return "data" in e && e.data ? e.data : "staticData" in e && e.staticData ? {
|
|
616
617
|
provider: "value",
|
|
617
618
|
items: e.staticData
|
|
@@ -620,17 +621,17 @@ function Pe(e) {
|
|
|
620
621
|
object: e.objectName
|
|
621
622
|
} : null;
|
|
622
623
|
}
|
|
623
|
-
function
|
|
624
|
+
function Ie(e) {
|
|
624
625
|
if (e) {
|
|
625
626
|
if (typeof e == "string") {
|
|
626
|
-
const n = e.split(" "), o = n[0],
|
|
627
|
-
return { [o]:
|
|
627
|
+
const n = e.split(" "), o = n[0], f = n[1]?.toLowerCase() === "desc" ? "desc" : "asc";
|
|
628
|
+
return { [o]: f };
|
|
628
629
|
}
|
|
629
630
|
if (Array.isArray(e))
|
|
630
631
|
return e.reduce((n, o) => (o.field && o.order && (n[o.field] = o.order), n), {});
|
|
631
632
|
}
|
|
632
633
|
}
|
|
633
|
-
function
|
|
634
|
+
function Ve(e) {
|
|
634
635
|
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 ? {
|
|
635
636
|
startDateField: e.startDateField || e.dateField,
|
|
636
637
|
endDateField: e.endDateField || e.endField,
|
|
@@ -639,127 +640,127 @@ function Ie(e) {
|
|
|
639
640
|
allDayField: e.allDayField
|
|
640
641
|
} : null;
|
|
641
642
|
}
|
|
642
|
-
const
|
|
643
|
+
const Le = ({
|
|
643
644
|
schema: e,
|
|
644
645
|
dataSource: n,
|
|
645
646
|
className: o,
|
|
646
|
-
onEventClick:
|
|
647
|
+
onEventClick: f,
|
|
647
648
|
onDateClick: u,
|
|
648
649
|
onNavigate: s,
|
|
649
|
-
onViewChange:
|
|
650
|
+
onViewChange: m,
|
|
650
651
|
...a
|
|
651
652
|
}) => {
|
|
652
|
-
const [d,
|
|
653
|
+
const [d, c] = A([]), [b, h] = A(!0), [p, j] = A(null), [O, P] = A(null), [_, M] = A(/* @__PURE__ */ new Date()), [$, I] = A("month"), l = Z(() => Me(e), [
|
|
653
654
|
e.data,
|
|
654
655
|
e.staticData,
|
|
655
656
|
e.objectName
|
|
656
|
-
]),
|
|
657
|
+
]), N = Z(() => Ve(e), [
|
|
657
658
|
e.filter,
|
|
658
659
|
e.calendar,
|
|
659
660
|
e.dateField,
|
|
660
661
|
e.endField,
|
|
661
662
|
e.titleField,
|
|
662
663
|
e.colorField
|
|
663
|
-
]),
|
|
664
|
-
|
|
664
|
+
]), k = l?.provider === "value";
|
|
665
|
+
le(() => {
|
|
665
666
|
let g = !0;
|
|
666
667
|
return (async () => {
|
|
667
668
|
try {
|
|
668
669
|
if (!g) return;
|
|
669
|
-
if (
|
|
670
|
-
g && (l
|
|
670
|
+
if (h(!0), k && l?.provider === "value") {
|
|
671
|
+
g && (c(l.items), h(!1));
|
|
671
672
|
return;
|
|
672
673
|
}
|
|
673
674
|
if (e.data || a.data) {
|
|
674
675
|
const E = e.data || a.data;
|
|
675
676
|
if (Array.isArray(E)) {
|
|
676
|
-
|
|
677
|
+
c(E), h(!1);
|
|
677
678
|
return;
|
|
678
679
|
}
|
|
679
680
|
}
|
|
680
681
|
if (!n)
|
|
681
682
|
throw new Error("DataSource required for object/api providers");
|
|
682
|
-
if (
|
|
683
|
-
const E =
|
|
683
|
+
if (l?.provider === "object") {
|
|
684
|
+
const E = l.object, w = await n.find(E, {
|
|
684
685
|
$filter: e.filter,
|
|
685
|
-
$orderby:
|
|
686
|
+
$orderby: Ie(e.sort)
|
|
686
687
|
});
|
|
687
688
|
let v = [];
|
|
688
|
-
Array.isArray(
|
|
689
|
-
} else
|
|
690
|
-
g &&
|
|
689
|
+
Array.isArray(w) ? v = w : w && typeof w == "object" && (Array.isArray(w.data) ? v = w.data : Array.isArray(w.value) && (v = w.value)), g && c(v);
|
|
690
|
+
} else l?.provider === "api" && (console.warn("API provider not yet implemented for ObjectCalendar"), g && c([]));
|
|
691
|
+
g && h(!1);
|
|
691
692
|
} catch (E) {
|
|
692
|
-
console.error("[ObjectCalendar] Error fetching data:", E), g && (
|
|
693
|
+
console.error("[ObjectCalendar] Error fetching data:", E), g && (j(E), h(!1));
|
|
693
694
|
}
|
|
694
695
|
})(), () => {
|
|
695
696
|
g = !1;
|
|
696
697
|
};
|
|
697
|
-
}, [
|
|
698
|
-
!
|
|
698
|
+
}, [l, n, k, e.filter, e.sort]), le(() => {
|
|
699
|
+
!k && n && (async () => {
|
|
699
700
|
try {
|
|
700
701
|
if (!n) return;
|
|
701
|
-
const
|
|
702
|
-
if (!
|
|
703
|
-
const E = await n.getObjectSchema(
|
|
704
|
-
|
|
705
|
-
} catch (
|
|
706
|
-
console.error("Failed to fetch object schema:",
|
|
702
|
+
const F = l?.provider === "object" ? l.object : e.objectName;
|
|
703
|
+
if (!F) return;
|
|
704
|
+
const E = await n.getObjectSchema(F);
|
|
705
|
+
P(E);
|
|
706
|
+
} catch (F) {
|
|
707
|
+
console.error("Failed to fetch object schema:", F);
|
|
707
708
|
}
|
|
708
709
|
})();
|
|
709
|
-
}, [e.objectName, n,
|
|
710
|
+
}, [e.objectName, n, k, l]);
|
|
710
711
|
const J = Z(() => {
|
|
711
|
-
if (!
|
|
712
|
+
if (!N || !d.length)
|
|
712
713
|
return [];
|
|
713
|
-
const { startDateField: g, endDateField:
|
|
714
|
+
const { startDateField: g, endDateField: F, titleField: E, colorField: w } = N;
|
|
714
715
|
return d.map((v, X) => {
|
|
715
|
-
const
|
|
716
|
+
const C = v[g], T = F ? v[F] : null, W = v[E] || "Untitled", U = w ? v[w] : void 0;
|
|
716
717
|
return {
|
|
717
718
|
id: v.id || v._id || `event-${X}`,
|
|
718
719
|
title: W,
|
|
719
|
-
start:
|
|
720
|
-
end:
|
|
720
|
+
start: C ? new Date(C) : /* @__PURE__ */ new Date(),
|
|
721
|
+
end: T ? new Date(T) : void 0,
|
|
721
722
|
color: U,
|
|
722
|
-
allDay: !
|
|
723
|
+
allDay: !T,
|
|
723
724
|
// If no end date, treat as all-day event
|
|
724
725
|
data: v
|
|
725
726
|
};
|
|
726
727
|
}).filter((v) => !isNaN(v.start.getTime()));
|
|
727
|
-
}, [d,
|
|
728
|
+
}, [d, N]), G = ge(() => {
|
|
728
729
|
u?.(/* @__PURE__ */ new Date());
|
|
729
730
|
}, [u]);
|
|
730
|
-
return
|
|
731
|
+
return b ? /* @__PURE__ */ r.jsx("div", { className: o, 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..." }) }) }) : p ? /* @__PURE__ */ r.jsx("div", { className: o, children: /* @__PURE__ */ r.jsx("div", { className: "flex items-center justify-center h-96", children: /* @__PURE__ */ r.jsxs("div", { className: "text-destructive", children: [
|
|
731
732
|
"Error: ",
|
|
732
|
-
|
|
733
|
-
] }) }) }) :
|
|
733
|
+
p.message
|
|
734
|
+
] }) }) }) : N ? /* @__PURE__ */ r.jsx("div", { className: o, children: /* @__PURE__ */ r.jsx("div", { className: "border rounded-lg bg-background h-[calc(100vh-200px)] min-h-[600px]", children: /* @__PURE__ */ r.jsx(
|
|
734
735
|
de,
|
|
735
736
|
{
|
|
736
737
|
events: J,
|
|
737
738
|
currentDate: _,
|
|
738
739
|
view: e.defaultView || "month",
|
|
739
|
-
onEventClick: (g) =>
|
|
740
|
+
onEventClick: (g) => f?.(g.data),
|
|
740
741
|
onDateClick: u,
|
|
741
742
|
onNavigate: (g) => {
|
|
742
|
-
|
|
743
|
+
M(g), s?.(g);
|
|
743
744
|
},
|
|
744
745
|
onViewChange: (g) => {
|
|
745
|
-
|
|
746
|
+
I(g), m?.(g);
|
|
746
747
|
},
|
|
747
748
|
onAddClick: G
|
|
748
749
|
}
|
|
749
750
|
) }) }) : /* @__PURE__ */ r.jsx("div", { className: o, 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." }) }) });
|
|
750
751
|
};
|
|
751
|
-
|
|
752
|
+
ee.register(
|
|
752
753
|
"calendar-view",
|
|
753
|
-
({ schema: e, className: n, onAction: o, ...
|
|
754
|
-
const u =
|
|
755
|
-
const
|
|
754
|
+
({ schema: e, className: n, onAction: o, ...f }) => {
|
|
755
|
+
const u = ce.useMemo(() => !e.data || !Array.isArray(e.data) ? [] : e.data.map((a, d) => {
|
|
756
|
+
const c = e.titleField || "title", b = e.startDateField || "start", h = e.endDateField || "end", p = e.colorField || "color", j = e.allDayField || "allDay";
|
|
756
757
|
return {
|
|
757
758
|
id: a._id || a.id || d,
|
|
758
|
-
title: a[
|
|
759
|
-
start: new Date(a[
|
|
760
|
-
end: a[
|
|
761
|
-
allDay: a[
|
|
762
|
-
color: a[
|
|
759
|
+
title: a[c] || "Untitled Event",
|
|
760
|
+
start: new Date(a[b]),
|
|
761
|
+
end: a[h] ? new Date(a[h]) : void 0,
|
|
762
|
+
allDay: a[j],
|
|
763
|
+
color: a[p],
|
|
763
764
|
data: a
|
|
764
765
|
};
|
|
765
766
|
}), [e.data, e.titleField, e.startDateField, e.endDateField, e.colorField, e.allDayField]), s = (a) => {
|
|
@@ -767,7 +768,7 @@ ce.register(
|
|
|
767
768
|
type: "event-click",
|
|
768
769
|
payload: a
|
|
769
770
|
});
|
|
770
|
-
},
|
|
771
|
+
}, m = () => {
|
|
771
772
|
o?.({
|
|
772
773
|
type: "create",
|
|
773
774
|
payload: {}
|
|
@@ -779,8 +780,8 @@ ce.register(
|
|
|
779
780
|
className: n,
|
|
780
781
|
events: u,
|
|
781
782
|
onEventClick: s,
|
|
782
|
-
onAddClick:
|
|
783
|
-
...
|
|
783
|
+
onAddClick: m,
|
|
784
|
+
...f
|
|
784
785
|
}
|
|
785
786
|
);
|
|
786
787
|
},
|
|
@@ -895,14 +896,23 @@ ce.register(
|
|
|
895
896
|
}
|
|
896
897
|
}
|
|
897
898
|
);
|
|
898
|
-
const
|
|
899
|
-
const { dataSource: n } =
|
|
900
|
-
return /* @__PURE__ */ r.jsx(
|
|
899
|
+
const me = ({ schema: e }) => {
|
|
900
|
+
const { dataSource: n } = xe();
|
|
901
|
+
return /* @__PURE__ */ r.jsx(Le, { schema: e, dataSource: n });
|
|
901
902
|
};
|
|
902
|
-
|
|
903
|
+
ee.register("object-calendar", me, {
|
|
903
904
|
namespace: "plugin-calendar",
|
|
904
905
|
label: "Object Calendar",
|
|
905
|
-
category: "
|
|
906
|
+
category: "view",
|
|
907
|
+
inputs: [
|
|
908
|
+
{ name: "objectName", type: "string", label: "Object Name", required: !0 },
|
|
909
|
+
{ name: "calendar", type: "object", label: "Calendar Config", description: "startDateField, endDateField, titleField, colorField" }
|
|
910
|
+
]
|
|
911
|
+
});
|
|
912
|
+
ee.register("calendar", me, {
|
|
913
|
+
namespace: "view",
|
|
914
|
+
label: "Calendar View",
|
|
915
|
+
category: "view",
|
|
906
916
|
inputs: [
|
|
907
917
|
{ name: "objectName", type: "string", label: "Object Name", required: !0 },
|
|
908
918
|
{ name: "calendar", type: "object", label: "Calendar Config", description: "startDateField, endDateField, titleField, colorField" }
|
|
@@ -910,6 +920,6 @@ ce.register("object-calendar", Le, {
|
|
|
910
920
|
});
|
|
911
921
|
export {
|
|
912
922
|
de as CalendarView,
|
|
913
|
-
|
|
914
|
-
|
|
923
|
+
Le as ObjectCalendar,
|
|
924
|
+
me as ObjectCalendarRenderer
|
|
915
925
|
};
|