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