@object-ui/plugin-calendar 0.3.1 → 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/dist/index.js CHANGED
@@ -1,619 +1,460 @@
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) {
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 (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,
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: g !== void 0 ? g : null,
24
- props: c
24
+ ref: u !== void 0 ? u : null,
25
+ props: s
25
26
  };
26
27
  }
27
- return $.Fragment = o, $.jsx = n, $.jsxs = n, $;
28
+ return L.Fragment = n, L.jsx = o, L.jsxs = o, L;
28
29
  }
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:
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 E:
42
+ case $:
42
43
  return "Profiler";
43
- case i:
44
+ case I:
44
45
  return "StrictMode";
45
- case G:
46
+ case C:
46
47
  return "Suspense";
47
- case H:
48
+ case J:
48
49
  return "SuspenseList";
49
- case D:
50
+ case S:
50
51
  return "Activity";
51
52
  }
52
- if (typeof e == "object")
53
- switch (typeof e.tag == "number" && console.error(
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
- ), e.$$typeof) {
56
+ ), t.$$typeof) {
56
57
  case M:
57
58
  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;
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(e(d));
71
+ return e(t(i));
71
72
  } catch {
72
73
  }
73
74
  }
74
75
  return null;
75
76
  }
76
- function o(e) {
77
- return "" + e;
77
+ function n(t) {
78
+ return "" + t;
78
79
  }
79
- function n(e) {
80
+ function o(t) {
80
81
  try {
81
- o(e);
82
- var d = !1;
82
+ n(t);
83
+ var i = !1;
83
84
  } catch {
84
- d = !0;
85
+ i = !0;
85
86
  }
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,
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
- v
93
- ), o(e);
93
+ D
94
+ ), n(t);
94
95
  }
95
96
  }
96
- function m(e) {
97
- if (e === T) return "<>";
98
- if (typeof e == "object" && e !== null && e.$$typeof === Y)
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 d = t(e);
102
- return d ? "<" + d + ">" : "<...>";
102
+ var i = e(t);
103
+ return i ? "<" + i + ">" : "<...>";
103
104
  } catch {
104
105
  return "<...>";
105
106
  }
106
107
  }
107
- function g() {
108
- var e = x.A;
109
- return e === null ? null : e.getOwner();
108
+ function u() {
109
+ var t = j.A;
110
+ return t === null ? null : t.getOwner();
110
111
  }
111
- function c() {
112
+ function s() {
112
113
  return Error("react-stack-top-frame");
113
114
  }
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;
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 e.key !== void 0;
120
+ return t.key !== void 0;
120
121
  }
121
- function a(e, d) {
122
- function b() {
123
- _ || (_ = !0, console.error(
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
- d
126
+ i
126
127
  ));
127
128
  }
128
- b.isReactWarning = !0, Object.defineProperty(e, "key", {
129
- get: b,
129
+ x.isReactWarning = !0, Object.defineProperty(t, "key", {
130
+ get: x,
130
131
  configurable: !0
131
132
  });
132
133
  }
133
- function l() {
134
- var e = t(this.type);
135
- return A[e] || (A[e] = !0, console.error(
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
- )), e = this.props.ref, e !== void 0 ? e : null;
138
+ )), t = this.props.ref, t !== void 0 ? t : null;
138
139
  }
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", {
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: l
150
- }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
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(e, "_debugInfo", {
156
+ }), Object.defineProperty(t, "_debugInfo", {
156
157
  configurable: !1,
157
158
  enumerable: !1,
158
159
  writable: !0,
159
160
  value: null
160
- }), Object.defineProperty(e, "_debugStack", {
161
+ }), Object.defineProperty(t, "_debugStack", {
161
162
  configurable: !1,
162
163
  enumerable: !1,
163
164
  writable: !0,
164
- value: q
165
- }), Object.defineProperty(e, "_debugTask", {
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(e.props), Object.freeze(e)), e;
171
+ }), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
171
172
  }
172
- function s(e, d, b, v, q, B) {
173
- var y = d.children;
173
+ function w(t, i, x, D, z, B) {
174
+ var y = i.children;
174
175
  if (y !== void 0)
175
- if (v)
176
- if (h(y)) {
177
- for (v = 0; v < y.length; v++)
178
- S(y[v]);
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 S(y);
185
- if (N.call(d, "key")) {
186
- y = t(e);
187
- var V = Object.keys(d).filter(function(me) {
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
- v = 0 < V.length ? "{key: someKey, " + V.join(": ..., ") + ": ...}" : "{key: someKey}", re[y + v] || (V = 0 < V.length ? "{" + V.join(": ..., ") + ": ...}" : "{}", console.error(
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
- v,
198
+ D,
198
199
  y,
199
- V,
200
+ A,
200
201
  y
201
- ), re[y + v] = !0);
202
+ ), ae[y + D] = !0);
202
203
  }
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;
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
- b,
210
- typeof e == "function" ? e.displayName || e.name || "Unknown" : e
211
- ), u(
212
- e,
210
+ x,
211
+ typeof t == "function" ? t.displayName || t.name || "Unknown" : t
212
+ ), l(
213
+ t,
213
214
  y,
214
- b,
215
- g(),
216
- q,
215
+ x,
216
+ u(),
217
+ z,
217
218
  B
218
219
  );
219
220
  }
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));
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 j(e) {
224
- return typeof e == "object" && e !== null && e.$$typeof === C;
224
+ function b(t) {
225
+ return typeof t == "object" && t !== null && t.$$typeof === P;
225
226
  }
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
+ 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
- w = {
230
- react_stack_bottom_frame: function(e) {
231
- return e();
230
+ N = {
231
+ react_stack_bottom_frame: function(t) {
232
+ return t();
232
233
  }
233
234
  };
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,
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
- v ? Error("react-stack-top-frame") : U,
246
- v ? k(m(e)) : J
246
+ D ? Error("react-stack-top-frame") : U,
247
+ D ? T(m(t)) : re
247
248
  );
248
- }, W.jsxs = function(e, d, b) {
249
- var v = 1e4 > x.recentlyCreatedOwnerStacks++;
250
- return s(
251
- e,
252
- d,
253
- b,
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
- v ? Error("react-stack-top-frame") : U,
256
- v ? k(m(e)) : J
256
+ D ? Error("react-stack-top-frame") : U,
257
+ D ? T(m(t)) : re
257
258
  );
258
259
  };
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;
260
+ })()), Y;
274
261
  }
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;
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
- const Ee = ({
289
- schema: t,
290
- dataSource: o,
291
- className: n,
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: 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,
273
+ onDateClick: u,
274
+ onViewChange: s,
476
275
  onNavigate: f,
477
- className: a
276
+ onAddClick: a,
277
+ className: d
478
278
  }) {
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 = () => {
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 s.toLocaleDateString("default", {
298
+ return p.toLocaleDateString("default", {
493
299
  month: "long",
494
300
  year: "numeric"
495
301
  });
496
302
  if (l === "week") {
497
- const i = ue(s), E = new Date(i);
498
- return E.setDate(E.getDate() + 6), `${i.toLocaleDateString("default", {
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
- })} - ${E.toLocaleDateString("default", {
307
+ })} - ${h.toLocaleDateString("default", {
502
308
  month: "short",
503
309
  day: "numeric",
504
310
  year: "numeric"
505
311
  })}`;
506
312
  } else
507
- return s.toLocaleDateString("default", {
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: O("flex flex-col h-full bg-background", a), children: [
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-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: [
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
- Z,
329
+ V,
521
330
  {
522
331
  variant: "ghost",
523
332
  size: "icon",
524
- onClick: j,
333
+ onClick: N,
525
334
  className: "h-8 w-8",
526
- children: /* @__PURE__ */ r.jsx(ge, { className: "h-4 w-4" })
335
+ children: /* @__PURE__ */ r.jsx(xe, { className: "h-4 w-4" })
527
336
  }
528
337
  ),
529
338
  /* @__PURE__ */ r.jsx(
530
- Z,
339
+ V,
531
340
  {
532
341
  variant: "ghost",
533
342
  size: "icon",
534
- onClick: w,
343
+ onClick: P,
535
344
  className: "h-8 w-8",
536
- children: /* @__PURE__ */ r.jsx(pe, { className: "h-4 w-4" })
345
+ children: /* @__PURE__ */ r.jsx(be, { className: "h-4 w-4" })
537
346
  }
538
347
  )
539
348
  ] }),
540
- /* @__PURE__ */ r.jsx("h2", { className: "text-lg font-semibold ml-2", children: T() })
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.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" })
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
- _e,
394
+ Re,
554
395
  {
555
- date: s,
556
- events: t,
396
+ date: p,
397
+ events: e,
557
398
  onEventClick: m,
558
- onDateClick: g
399
+ onDateClick: u
559
400
  }
560
401
  ),
561
402
  l === "week" && /* @__PURE__ */ r.jsx(
562
- Te,
403
+ Ae,
563
404
  {
564
- date: s,
565
- events: t,
405
+ date: p,
406
+ events: e,
566
407
  onEventClick: m,
567
- onDateClick: g
408
+ onDateClick: u
568
409
  }
569
410
  ),
570
411
  l === "day" && /* @__PURE__ */ r.jsx(
571
- Fe,
412
+ Oe,
572
413
  {
573
- date: s,
574
- events: t,
414
+ date: p,
415
+ events: e,
575
416
  onEventClick: m
576
417
  }
577
418
  )
578
419
  ] })
579
420
  ] });
580
421
  }
581
- function ue(t) {
582
- const o = new Date(t), n = o.getDay(), m = o.getDate() - n;
583
- return o.setDate(m), o;
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 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);
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 l = 1; l <= g.getDate(); l++)
592
- f.push(new Date(o, n, l));
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 l = 1; l <= a; l++) {
595
- const u = new Date(g.getTime());
596
- u.setDate(u.getDate() + l), f.push(u);
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(t, o) {
601
- return t.getFullYear() === o.getFullYear() && t.getMonth() === o.getMonth() && t.getDate() === o.getDate();
441
+ function fe(e, n) {
442
+ return e.getFullYear() === n.getFullYear() && e.getMonth() === n.getMonth() && e.getDate() === n.getDate();
602
443
  }
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);
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 l = new Date(g);
612
- return l.setHours(23, 59, 59, 999), c <= l && f >= a;
452
+ const d = new Date(u);
453
+ return d.setHours(23, 59, 59, 999), s <= d && f >= a;
613
454
  });
614
455
  }
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"];
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: g.map((a, l) => {
627
- const u = te(a, o), s = a.getMonth() === t.getMonth(), S = fe(a, c);
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: O(
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
- !s && "bg-muted/30 text-muted-foreground"
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: O(
481
+ className: F(
641
482
  "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"
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
- u.slice(0, 3).map((j) => /* @__PURE__ */ r.jsx(
489
+ l.slice(0, 3).map((b) => /* @__PURE__ */ r.jsx(
649
490
  "div",
650
491
  {
651
- className: O(
492
+ className: F(
652
493
  "text-xs px-2 py-1 rounded truncate cursor-pointer hover:opacity-80",
653
- j.color || ee
494
+ b.color || ee
654
495
  ),
655
- style: j.color && j.color.startsWith("#") ? { backgroundColor: j.color } : void 0,
656
- onClick: (w) => {
657
- w.stopPropagation(), n?.(j);
496
+ style: b.color && b.color.startsWith("#") ? { backgroundColor: b.color } : void 0,
497
+ onClick: (N) => {
498
+ N.stopPropagation(), o?.(b);
658
499
  },
659
- children: j.title
500
+ children: b.title
660
501
  },
661
- j.id
502
+ b.id
662
503
  )),
663
- u.length > 3 && /* @__PURE__ */ r.jsxs("div", { className: "text-xs text-muted-foreground px-2", children: [
504
+ l.length > 3 && /* @__PURE__ */ r.jsxs("div", { className: "text-xs text-muted-foreground px-2", children: [
664
505
  "+",
665
- u.length - 3,
506
+ l.length - 3,
666
507
  " more"
667
508
  ] })
668
509
  ] })
669
510
  ]
670
511
  },
671
- l
512
+ d
672
513
  );
673
514
  }) })
674
515
  ] });
675
516
  }
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;
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: c.map((a) => {
683
- const l = fe(a, f);
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: O(
534
+ className: F(
694
535
  "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"
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: c.map((a) => {
706
- const l = te(a, o);
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: l.map((u) => /* @__PURE__ */ r.jsxs(
553
+ children: /* @__PURE__ */ r.jsx("div", { className: "space-y-2", children: d.map((l) => /* @__PURE__ */ r.jsxs(
713
554
  "div",
714
555
  {
715
- className: O(
556
+ className: F(
716
557
  "text-sm px-3 py-2 rounded cursor-pointer hover:opacity-80",
717
- u.color || ee
558
+ l.color || ee
718
559
  ),
719
- style: u.color && u.color.startsWith("#") ? { backgroundColor: u.color } : void 0,
720
- onClick: (s) => {
721
- s.stopPropagation(), n?.(u);
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: u.title }),
725
- !u.allDay && /* @__PURE__ */ r.jsx("div", { className: "text-xs opacity-90 mt-1", children: u.start.toLocaleTimeString("default", {
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
- u.id
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 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);
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: c === 0 ? "12 AM" : c < 12 ? `${c} AM` : c === 12 ? "12 PM" : `${c - 12} PM` }),
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: O(
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: () => n?.(a),
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
- ] }, c);
611
+ ] }, s);
771
612
  }) }) });
772
613
  }
773
- de.register(
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: 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
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
- }), [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";
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
- Se,
777
+ de,
811
778
  {
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,
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 Re = ({ schema: t }) => /* @__PURE__ */ r.jsx(Ee, { schema: t, dataSource: null });
935
- de.register("object-calendar", Re, {
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
- Se as CalendarView,
945
- Ee as ObjectCalendar
912
+ de as CalendarView,
913
+ Ve as ObjectCalendar,
914
+ Le as ObjectCalendarRenderer
946
915
  };