@object-ui/plugin-calendar 0.3.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,621 +1,463 @@
1
- import * as ae from "react";
2
- import L, { useState as I, useEffect as ne, useMemo as oe, useCallback as le } from "react";
3
- import { ComponentRegistry as de } from "@object-ui/core";
4
- import { ChevronLeftIcon as ge, ChevronRightIcon as pe } from "lucide-react";
5
- import { cn as O, Button as Z, Select as xe, SelectTrigger as De, SelectValue as be, SelectContent as he, SelectItem as K } from "@object-ui/components";
6
- var z = { exports: {} }, $ = {};
7
- var se;
8
- function ve() {
9
- if (se) return $;
10
- se = 1;
11
- var t = /* @__PURE__ */ Symbol.for("react.transitional.element"), o = /* @__PURE__ */ Symbol.for("react.fragment");
12
- function n(m, g, c) {
13
- var f = null;
14
- if (c !== void 0 && (f = "" + c), g.key !== void 0 && (f = "" + g.key), "key" in g) {
15
- c = {};
16
- for (var a in g)
17
- a !== "key" && (c[a] = g[a]);
18
- } else c = g;
19
- return g = c.ref, {
20
- $$typeof: t,
21
- type: m,
22
- key: f,
23
- ref: g !== void 0 ? g : null,
24
- props: c
1
+ import * as z from "react";
2
+ import ce, { useState as A, useMemo as Z, useEffect as le, useCallback as ge } from "react";
3
+ import { ComponentRegistry as ee } from "@object-ui/core";
4
+ import { useSchemaContext as xe } from "@object-ui/react";
5
+ import { ChevronLeftIcon as be, ChevronRightIcon as De, CalendarIcon as ye, PlusIcon as ve } from "lucide-react";
6
+ import { Button as V, Popover as he, PopoverTrigger as je, cn as S, PopoverContent as we, Calendar as Ee, Select as Ne, SelectTrigger as Fe, SelectValue as Se, SelectContent as _e, SelectItem as K } from "@object-ui/components";
7
+ var H = { exports: {} }, L = {};
8
+ var oe;
9
+ function ke() {
10
+ if (oe) return L;
11
+ oe = 1;
12
+ var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), n = /* @__PURE__ */ Symbol.for("react.fragment");
13
+ function o(f, u, s) {
14
+ var m = null;
15
+ if (s !== void 0 && (m = "" + s), u.key !== void 0 && (m = "" + u.key), "key" in u) {
16
+ 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,
22
+ type: f,
23
+ key: m,
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 Y = {};
30
31
  var ie;
31
- function ye() {
32
+ function Ce() {
32
33
  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:
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 M:
44
45
  return "StrictMode";
45
- case G:
46
+ case k:
46
47
  return "Suspense";
47
- case H:
48
+ case J:
48
49
  return "SuspenseList";
49
- case D:
50
+ case F:
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
- case M:
57
- return "Portal";
56
+ ), t.$$typeof) {
58
57
  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;
58
+ return "Portal";
59
+ case l:
60
+ return t.displayName || "Context";
61
+ case I:
62
+ return (t._context.displayName || "Context") + ".Consumer";
63
+ case N:
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 f(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 = w.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 m(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
+ T || (T = !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 c(t, i, x, D, q, B) {
141
+ var y = x.ref;
142
+ return t = {
143
+ $$typeof: O,
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
165
  value: q
165
- }), Object.defineProperty(e, "_debugTask", {
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 b(t, i, x, D, q, 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
+ h(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) {
188
- return me !== "key";
185
+ else h(y);
186
+ if (v.call(i, "key")) {
187
+ y = e(t);
188
+ var R = Object.keys(i).filter(function(pe) {
189
+ return pe !== "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 < R.length ? "{key: someKey, " + R.join(": ..., ") + ": ...}" : "{key: someKey}", ne[y + D] || (R = 0 < R.length ? "{" + R.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
+ R,
200
201
  y
201
- ), re[y + v] = !0);
202
+ ), ne[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), m(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
+ ), c(
213
+ t,
213
214
  y,
214
- b,
215
- g(),
215
+ x,
216
+ u(),
216
217
  q,
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 h(t) {
222
+ p(t) ? t._store && (t._store.validated = 1) : typeof t == "object" && t !== null && t.$$typeof === g && (t._payload.status === "fulfilled" ? p(t._payload.value) && t._payload.value._store && (t._payload.value._store.validated = 1) : t._store && (t._store.validated = 1));
222
223
  }
223
- function j(e) {
224
- return typeof e == "object" && e !== null && e.$$typeof === C;
224
+ function p(t) {
225
+ return typeof t == "object" && t !== null && t.$$typeof === O;
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 j = ce, O = /* @__PURE__ */ Symbol.for("react.transitional.element"), P = /* @__PURE__ */ Symbol.for("react.portal"), _ = /* @__PURE__ */ Symbol.for("react.fragment"), M = /* @__PURE__ */ Symbol.for("react.strict_mode"), $ = /* @__PURE__ */ Symbol.for("react.profiler"), I = /* @__PURE__ */ Symbol.for("react.consumer"), l = /* @__PURE__ */ Symbol.for("react.context"), N = /* @__PURE__ */ Symbol.for("react.forward_ref"), k = /* @__PURE__ */ Symbol.for("react.suspense"), J = /* @__PURE__ */ Symbol.for("react.suspense_list"), G = /* @__PURE__ */ Symbol.for("react.memo"), g = /* @__PURE__ */ Symbol.for("react.lazy"), F = /* @__PURE__ */ Symbol.for("react.activity"), E = /* @__PURE__ */ Symbol.for("react.client.reference"), w = j.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, v = Object.prototype.hasOwnProperty, X = Array.isArray, C = console.createTask ? console.createTask : function() {
227
228
  return null;
228
229
  };
229
- w = {
230
- react_stack_bottom_frame: function(e) {
231
- return e();
230
+ j = {
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 T, W = {}, U = j.react_stack_bottom_frame.bind(
236
+ j,
237
+ s
238
+ )(), ae = C(f(s)), ne = {};
239
+ Y.Fragment = _, Y.jsx = function(t, i, x) {
240
+ var D = 1e4 > w.recentlyCreatedOwnerStacks++;
241
+ return b(
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 ? C(f(t)) : ae
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 > w.recentlyCreatedOwnerStacks++;
251
+ return b(
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 ? C(f(t)) : ae
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;
274
- }
275
- function Ne(t) {
276
- if (t) {
277
- if (typeof t == "string") {
278
- const o = t.split(" "), n = o[0], m = o[1]?.toLowerCase() === "desc" ? "desc" : "asc";
279
- return { [n]: m };
280
- }
281
- if (Array.isArray(t))
282
- return t.reduce((o, n) => (n.field && n.order && (o[n.field] = n.order), o), {});
283
- }
260
+ })()), Y;
284
261
  }
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 se;
263
+ function Te() {
264
+ return se || (se = 1, process.env.NODE_ENV === "production" ? H.exports = ke() : H.exports = Ce()), H.exports;
287
265
  }
288
- const Ee = ({
289
- schema: t,
290
- dataSource: o,
291
- className: n,
292
- onEventClick: m,
293
- onDateClick: g
294
- }) => {
295
- const [c, f] = I([]), [a, l] = I(!0), [u, s] = I(null), [S, j] = I(null), [w, C] = I(/* @__PURE__ */ new Date()), [M, T] = I("month"), i = je(t), E = ke(t), R = i?.provider === "value";
296
- ne(() => {
297
- (async () => {
298
- try {
299
- if (l(!0), R && i?.provider === "value") {
300
- f(i.items), l(!1);
301
- return;
302
- }
303
- if (!o)
304
- throw new Error("DataSource required for object/api providers");
305
- if (i?.provider === "object") {
306
- const p = i.object, x = await o.find(p, {
307
- $filter: t.filter,
308
- $orderby: Ne(t.sort)
309
- });
310
- f(x?.data || []);
311
- } else i?.provider === "api" && (console.warn("API provider not yet implemented for ObjectCalendar"), f([]));
312
- l(!1);
313
- } catch (p) {
314
- s(p), l(!1);
315
- }
316
- })();
317
- }, [i, o, R, t.filter, t.sort]), ne(() => {
318
- !R && o && (async () => {
319
- try {
320
- if (!o) return;
321
- const p = i?.provider === "object" ? i.object : t.objectName;
322
- if (!p) return;
323
- const x = await o.getObjectSchema(p);
324
- j(x);
325
- } catch (p) {
326
- console.error("Failed to fetch object schema:", p);
327
- }
328
- })();
329
- }, [t.objectName, o, R, i]);
330
- const P = oe(() => {
331
- if (!E || !c.length)
332
- return [];
333
- const { startDateField: D, endDateField: p, titleField: x, colorField: N } = E;
334
- return c.map((h, k) => {
335
- const _ = h[D], A = p ? h[p] : null, U = h[x] || "Untitled", J = N ? h[N] : void 0;
336
- return {
337
- id: h.id || h._id || `event-${k}`,
338
- title: U,
339
- start: _ ? new Date(_) : /* @__PURE__ */ new Date(),
340
- end: A ? new Date(A) : void 0,
341
- color: J,
342
- allDay: !A,
343
- // If no end date, treat as all-day event
344
- data: h
345
- };
346
- }).filter((h) => !isNaN(h.start.getTime()));
347
- }, [c, E]), F = oe(() => {
348
- const D = w.getFullYear(), p = w.getMonth(), x = new Date(D, p, 1), N = new Date(x);
349
- N.setDate(N.getDate() - N.getDay());
350
- const h = [], k = new Date(N);
351
- for (let _ = 0; _ < 42; _++)
352
- h.push(new Date(k)), k.setDate(k.getDate() + 1);
353
- return h;
354
- }, [w]), G = le((D) => P.filter((p) => {
355
- const x = new Date(p.start);
356
- x.setHours(0, 0, 0, 0);
357
- const N = p.end ? new Date(p.end) : x;
358
- N.setHours(23, 59, 59, 999);
359
- const h = new Date(D);
360
- return h.setHours(0, 0, 0, 0), h >= x && h <= N;
361
- }), [P]), H = le((D) => {
362
- C((p) => {
363
- const x = new Date(p);
364
- return x.setMonth(x.getMonth() + (D === "next" ? 1 : -1)), x;
365
- });
366
- }, []);
367
- if (a)
368
- return /* @__PURE__ */ r.jsx("div", { className: n, children: /* @__PURE__ */ r.jsx("div", { className: "flex items-center justify-center h-96", children: /* @__PURE__ */ r.jsx("div", { className: "text-muted-foreground", children: "Loading calendar..." }) }) });
369
- if (u)
370
- return /* @__PURE__ */ r.jsx("div", { className: n, children: /* @__PURE__ */ r.jsx("div", { className: "flex items-center justify-center h-96", children: /* @__PURE__ */ r.jsxs("div", { className: "text-destructive", children: [
371
- "Error: ",
372
- u.message
373
- ] }) }) });
374
- if (!E)
375
- return /* @__PURE__ */ r.jsx("div", { className: n, children: /* @__PURE__ */ r.jsx("div", { className: "flex items-center justify-center h-96", children: /* @__PURE__ */ r.jsx("div", { className: "text-muted-foreground", children: "Calendar configuration required. Please specify startDateField and titleField." }) }) });
376
- const X = [
377
- "January",
378
- "February",
379
- "March",
380
- "April",
381
- "May",
382
- "June",
383
- "July",
384
- "August",
385
- "September",
386
- "October",
387
- "November",
388
- "December"
389
- ], Y = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
390
- return /* @__PURE__ */ r.jsx("div", { className: n, children: /* @__PURE__ */ r.jsxs("div", { className: "border rounded-lg bg-background", children: [
391
- /* @__PURE__ */ r.jsxs("div", { className: "flex items-center justify-between p-4 border-b", children: [
392
- /* @__PURE__ */ r.jsxs("h2", { className: "text-xl font-semibold", children: [
393
- X[w.getMonth()],
394
- " ",
395
- w.getFullYear()
396
- ] }),
397
- /* @__PURE__ */ r.jsxs("div", { className: "flex gap-2", children: [
398
- /* @__PURE__ */ r.jsx(
399
- "button",
400
- {
401
- onClick: () => H("prev"),
402
- className: "px-3 py-1 border rounded hover:bg-muted",
403
- children: "Previous"
404
- }
405
- ),
406
- /* @__PURE__ */ r.jsx(
407
- "button",
408
- {
409
- onClick: () => C(/* @__PURE__ */ new Date()),
410
- className: "px-3 py-1 border rounded hover:bg-muted",
411
- children: "Today"
412
- }
413
- ),
414
- /* @__PURE__ */ r.jsx(
415
- "button",
416
- {
417
- onClick: () => H("next"),
418
- className: "px-3 py-1 border rounded hover:bg-muted",
419
- children: "Next"
420
- }
421
- )
422
- ] })
423
- ] }),
424
- /* @__PURE__ */ r.jsxs("div", { className: "p-4", children: [
425
- /* @__PURE__ */ r.jsx("div", { className: "grid grid-cols-7 gap-px mb-px", children: Y.map((D) => /* @__PURE__ */ r.jsx(
426
- "div",
427
- {
428
- className: "text-center text-sm font-medium text-muted-foreground py-2",
429
- children: D
430
- },
431
- D
432
- )) }),
433
- /* @__PURE__ */ r.jsx("div", { className: "grid grid-cols-7 gap-px bg-border", children: F.map((D, p) => {
434
- const x = G(D), N = D.getMonth() === w.getMonth(), h = D.getDate() === (/* @__PURE__ */ new Date()).getDate() && D.getMonth() === (/* @__PURE__ */ new Date()).getMonth() && D.getFullYear() === (/* @__PURE__ */ new Date()).getFullYear();
435
- return /* @__PURE__ */ r.jsxs(
436
- "div",
437
- {
438
- className: `min-h-24 bg-background p-2 ${N ? "" : "text-muted-foreground bg-muted/30"} ${h ? "ring-2 ring-primary" : ""}`,
439
- onClick: () => g?.(D),
440
- children: [
441
- /* @__PURE__ */ r.jsx("div", { className: "text-sm font-medium mb-1", children: D.getDate() }),
442
- /* @__PURE__ */ r.jsxs("div", { className: "space-y-1", children: [
443
- x.slice(0, 3).map((k) => /* @__PURE__ */ r.jsx(
444
- "div",
445
- {
446
- className: "text-xs px-1 py-0.5 rounded bg-primary/10 hover:bg-primary/20 cursor-pointer truncate",
447
- onClick: (_) => {
448
- _.stopPropagation(), m?.(k.data);
449
- },
450
- style: k.color ? { borderLeft: `3px solid ${k.color}` } : void 0,
451
- children: k.title
452
- },
453
- k.id
454
- )),
455
- x.length > 3 && /* @__PURE__ */ r.jsxs("div", { className: "text-xs text-muted-foreground", children: [
456
- "+",
457
- x.length - 3,
458
- " more"
459
- ] })
460
- ] })
461
- ]
462
- },
463
- p
464
- );
465
- }) })
466
- ] })
467
- ] }) });
468
- }, ee = "bg-blue-500 text-white";
469
- function Se({
470
- events: t = [],
471
- view: o = "month",
472
- currentDate: n = /* @__PURE__ */ new Date(),
473
- onEventClick: m,
474
- onDateClick: g,
475
- onViewChange: c,
476
- onNavigate: f,
477
- className: a
266
+ var r = Te();
267
+ const te = "bg-blue-500 text-white";
268
+ function de({
269
+ events: e = [],
270
+ view: n = "month",
271
+ currentDate: o = /* @__PURE__ */ new Date(),
272
+ locale: f = "default",
273
+ onEventClick: u,
274
+ onDateClick: s,
275
+ onViewChange: m,
276
+ onNavigate: a,
277
+ onAddClick: d,
278
+ className: c
478
279
  }) {
479
- const [l, u] = ae.useState(o), [s, S] = ae.useState(n), j = () => {
480
- const i = new Date(s);
481
- l === "month" ? i.setMonth(i.getMonth() - 1) : l === "week" ? i.setDate(i.getDate() - 7) : i.setDate(i.getDate() - 1), S(i), f?.(i);
482
- }, w = () => {
483
- const i = new Date(s);
484
- l === "month" ? i.setMonth(i.getMonth() + 1) : l === "week" ? i.setDate(i.getDate() + 7) : i.setDate(i.getDate() + 1), S(i), f?.(i);
485
- }, C = () => {
486
- const i = /* @__PURE__ */ new Date();
487
- S(i), f?.(i);
488
- }, M = (i) => {
489
- u(i), c?.(i);
490
- }, T = () => {
491
- if (l === "month")
492
- return s.toLocaleDateString("default", {
280
+ const [b, h] = z.useState(n), [p, j] = z.useState(o);
281
+ z.useEffect(() => {
282
+ j(o);
283
+ }, [o]), z.useEffect(() => {
284
+ h(n);
285
+ }, [n]);
286
+ const O = () => {
287
+ const l = new Date(p);
288
+ b === "month" ? l.setMonth(l.getMonth() - 1) : b === "week" ? l.setDate(l.getDate() - 7) : l.setDate(l.getDate() - 1), j(l), a?.(l);
289
+ }, P = () => {
290
+ const l = new Date(p);
291
+ b === "month" ? l.setMonth(l.getMonth() + 1) : b === "week" ? l.setDate(l.getDate() + 7) : l.setDate(l.getDate() + 1), j(l), a?.(l);
292
+ }, _ = () => {
293
+ const l = /* @__PURE__ */ new Date();
294
+ j(l), a?.(l);
295
+ }, M = (l) => {
296
+ h(l), m?.(l);
297
+ }, $ = () => {
298
+ if (b === "month")
299
+ return p.toLocaleDateString(f, {
493
300
  month: "long",
494
301
  year: "numeric"
495
302
  });
496
- if (l === "week") {
497
- const i = ue(s), E = new Date(i);
498
- return E.setDate(E.getDate() + 6), `${i.toLocaleDateString("default", {
303
+ if (b === "week") {
304
+ const l = ue(p), N = new Date(l);
305
+ return N.setDate(N.getDate() + 6), `${l.toLocaleDateString(f, {
499
306
  month: "short",
500
307
  day: "numeric"
501
- })} - ${E.toLocaleDateString("default", {
308
+ })} - ${N.toLocaleDateString(f, {
502
309
  month: "short",
503
310
  day: "numeric",
504
311
  year: "numeric"
505
312
  })}`;
506
313
  } else
507
- return s.toLocaleDateString("default", {
314
+ return p.toLocaleDateString(f, {
508
315
  weekday: "long",
509
316
  month: "long",
510
317
  day: "numeric",
511
318
  year: "numeric"
512
319
  });
320
+ }, I = (l) => {
321
+ l && (j(l), a?.(l));
513
322
  };
514
- return /* @__PURE__ */ r.jsxs("div", { className: O("flex flex-col h-full bg-background", a), children: [
323
+ return /* @__PURE__ */ r.jsxs("div", { className: S("flex flex-col h-full bg-background", c), children: [
515
324
  /* @__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: [
325
+ /* @__PURE__ */ r.jsxs("div", { className: "flex items-center gap-4", children: [
326
+ /* @__PURE__ */ r.jsxs("div", { className: "flex items-center bg-muted/50 rounded-lg p-1 gap-1", children: [
327
+ /* @__PURE__ */ r.jsx(V, { variant: "ghost", size: "sm", onClick: _, className: "h-8", children: "Today" }),
328
+ /* @__PURE__ */ r.jsx("div", { className: "h-4 w-px bg-border mx-1" }),
519
329
  /* @__PURE__ */ r.jsx(
520
- Z,
330
+ V,
521
331
  {
522
332
  variant: "ghost",
523
333
  size: "icon",
524
- onClick: j,
334
+ onClick: O,
525
335
  className: "h-8 w-8",
526
- children: /* @__PURE__ */ r.jsx(ge, { className: "h-4 w-4" })
336
+ children: /* @__PURE__ */ r.jsx(be, { className: "h-4 w-4" })
527
337
  }
528
338
  ),
529
339
  /* @__PURE__ */ r.jsx(
530
- Z,
340
+ V,
531
341
  {
532
342
  variant: "ghost",
533
343
  size: "icon",
534
- onClick: w,
344
+ onClick: P,
535
345
  className: "h-8 w-8",
536
- children: /* @__PURE__ */ r.jsx(pe, { className: "h-4 w-4" })
346
+ children: /* @__PURE__ */ r.jsx(De, { className: "h-4 w-4" })
537
347
  }
538
348
  )
539
349
  ] }),
540
- /* @__PURE__ */ r.jsx("h2", { className: "text-lg font-semibold ml-2", children: T() })
541
- ] }),
542
- /* @__PURE__ */ r.jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ r.jsxs(xe, { value: l, onValueChange: M, children: [
543
- /* @__PURE__ */ r.jsx(De, { className: "w-32", children: /* @__PURE__ */ r.jsx(be, {}) }),
544
350
  /* @__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" })
351
+ /* @__PURE__ */ r.jsx(je, { asChild: !0, children: /* @__PURE__ */ r.jsxs(
352
+ V,
353
+ {
354
+ variant: "ghost",
355
+ className: S(
356
+ "text-xl font-semibold h-auto px-3 py-1 hover:bg-muted/50 transition-colors",
357
+ "flex items-center gap-2"
358
+ ),
359
+ children: [
360
+ /* @__PURE__ */ r.jsx(ye, { className: "h-5 w-5 text-muted-foreground" }),
361
+ /* @__PURE__ */ r.jsx("span", { children: $() })
362
+ ]
363
+ }
364
+ ) }),
365
+ /* @__PURE__ */ r.jsx(we, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ r.jsx(
366
+ Ee,
367
+ {
368
+ mode: "single",
369
+ selected: p,
370
+ onSelect: I,
371
+ initialFocus: !0,
372
+ fromYear: 2e3,
373
+ toYear: 2050
374
+ }
375
+ ) })
376
+ ] })
377
+ ] }),
378
+ /* @__PURE__ */ r.jsxs("div", { className: "flex items-center gap-2", children: [
379
+ /* @__PURE__ */ r.jsxs(Ne, { value: b, onValueChange: M, children: [
380
+ /* @__PURE__ */ r.jsx(Fe, { className: "w-32 bg-background", children: /* @__PURE__ */ r.jsx(Se, {}) }),
381
+ /* @__PURE__ */ r.jsxs(_e, { children: [
382
+ /* @__PURE__ */ r.jsx(K, { value: "day", children: "Day" }),
383
+ /* @__PURE__ */ r.jsx(K, { value: "week", children: "Week" }),
384
+ /* @__PURE__ */ r.jsx(K, { value: "month", children: "Month" })
385
+ ] })
386
+ ] }),
387
+ d && /* @__PURE__ */ r.jsxs(V, { onClick: d, size: "sm", className: "gap-1", children: [
388
+ /* @__PURE__ */ r.jsx(ve, { className: "h-4 w-4" }),
389
+ "New"
548
390
  ] })
549
- ] }) })
391
+ ] })
550
392
  ] }),
551
393
  /* @__PURE__ */ r.jsxs("div", { className: "flex-1 overflow-auto", children: [
552
- l === "month" && /* @__PURE__ */ r.jsx(
553
- _e,
394
+ b === "month" && /* @__PURE__ */ r.jsx(
395
+ Ae,
554
396
  {
555
- date: s,
556
- events: t,
557
- onEventClick: m,
558
- onDateClick: g
397
+ date: p,
398
+ events: e,
399
+ onEventClick: u,
400
+ onDateClick: s
559
401
  }
560
402
  ),
561
- l === "week" && /* @__PURE__ */ r.jsx(
562
- Te,
403
+ b === "week" && /* @__PURE__ */ r.jsx(
404
+ Oe,
563
405
  {
564
- date: s,
565
- events: t,
566
- onEventClick: m,
567
- onDateClick: g
406
+ date: p,
407
+ events: e,
408
+ onEventClick: u,
409
+ onDateClick: s
568
410
  }
569
411
  ),
570
- l === "day" && /* @__PURE__ */ r.jsx(
571
- Fe,
412
+ b === "day" && /* @__PURE__ */ r.jsx(
413
+ Pe,
572
414
  {
573
- date: s,
574
- events: t,
575
- onEventClick: m
415
+ date: p,
416
+ events: e,
417
+ onEventClick: u
576
418
  }
577
419
  )
578
420
  ] })
579
421
  ] });
580
422
  }
581
- function ue(t) {
582
- const o = new Date(t), n = o.getDay(), m = o.getDate() - n;
583
- return o.setDate(m), o;
423
+ function ue(e) {
424
+ const n = new Date(e), o = n.getDay(), f = n.getDate() - o;
425
+ return n.setDate(f), n;
584
426
  }
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);
427
+ function Re(e) {
428
+ const n = e.getFullYear(), o = e.getMonth(), f = new Date(n, o, 1), u = new Date(n, o + 1, 0), s = f.getDay(), m = [];
429
+ for (let d = s - 1; d >= 0; d--) {
430
+ const c = new Date(f.getTime());
431
+ c.setDate(c.getDate() - (d + 1)), m.push(c);
590
432
  }
591
- for (let l = 1; l <= g.getDate(); l++)
592
- f.push(new Date(o, n, l));
593
- const a = 42 - f.length;
594
- for (let l = 1; l <= a; l++) {
595
- const u = new Date(g.getTime());
596
- u.setDate(u.getDate() + l), f.push(u);
433
+ for (let d = 1; d <= u.getDate(); d++)
434
+ m.push(new Date(n, o, d));
435
+ const a = 42 - m.length;
436
+ for (let d = 1; d <= a; d++) {
437
+ const c = new Date(u.getTime());
438
+ c.setDate(c.getDate() + d), m.push(c);
597
439
  }
598
- return f;
440
+ return m;
599
441
  }
600
- function fe(t, o) {
601
- return t.getFullYear() === o.getFullYear() && t.getMonth() === o.getMonth() && t.getDate() === o.getDate();
442
+ function fe(e, n) {
443
+ return e.getFullYear() === n.getFullYear() && e.getMonth() === n.getMonth() && e.getDate() === n.getDate();
602
444
  }
603
- function te(t, o) {
604
- return o.filter((n) => {
605
- const m = new Date(n.start), g = n.end ? new Date(n.end) : new Date(m), c = new Date(t);
606
- c.setHours(0, 0, 0, 0);
607
- const f = new Date(t);
608
- f.setHours(23, 59, 59, 999);
609
- const a = new Date(m);
445
+ function re(e, n) {
446
+ return n.filter((o) => {
447
+ const f = new Date(o.start), u = o.end ? new Date(o.end) : new Date(f), s = new Date(e);
448
+ s.setHours(0, 0, 0, 0);
449
+ const m = new Date(e);
450
+ m.setHours(23, 59, 59, 999);
451
+ const a = new Date(f);
610
452
  a.setHours(0, 0, 0, 0);
611
- const l = new Date(g);
612
- return l.setHours(23, 59, 59, 999), c <= l && f >= a;
453
+ const d = new Date(u);
454
+ return d.setHours(23, 59, 59, 999), s <= d && m >= a;
613
455
  });
614
456
  }
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"];
457
+ function Ae({ date: e, events: n, onEventClick: o, onDateClick: f }) {
458
+ const u = Re(e), s = /* @__PURE__ */ new Date(), m = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
617
459
  return /* @__PURE__ */ r.jsxs("div", { className: "flex flex-col h-full", children: [
618
- /* @__PURE__ */ r.jsx("div", { className: "grid grid-cols-7 border-b", children: f.map((a) => /* @__PURE__ */ r.jsx(
460
+ /* @__PURE__ */ r.jsx("div", { className: "grid grid-cols-7 border-b", children: m.map((a) => /* @__PURE__ */ r.jsx(
619
461
  "div",
620
462
  {
621
463
  className: "p-2 text-center text-sm font-medium text-muted-foreground border-r last:border-r-0",
@@ -623,76 +465,76 @@ function _e({ date: t, events: o, onEventClick: n, onDateClick: m }) {
623
465
  },
624
466
  a
625
467
  )) }),
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);
468
+ /* @__PURE__ */ r.jsx("div", { className: "grid grid-cols-7 flex-1 auto-rows-fr", children: u.map((a, d) => {
469
+ const c = re(a, n), b = a.getMonth() === e.getMonth(), h = fe(a, s);
628
470
  return /* @__PURE__ */ r.jsxs(
629
471
  "div",
630
472
  {
631
- className: O(
473
+ className: S(
632
474
  "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"
475
+ !b && "bg-muted/30 text-muted-foreground"
634
476
  ),
635
- onClick: () => m?.(a),
477
+ onClick: () => f?.(a),
636
478
  children: [
637
479
  /* @__PURE__ */ r.jsx(
638
480
  "div",
639
481
  {
640
- className: O(
482
+ className: S(
641
483
  "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"
484
+ h && "inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-6 w-6"
643
485
  ),
644
486
  children: a.getDate()
645
487
  }
646
488
  ),
647
489
  /* @__PURE__ */ r.jsxs("div", { className: "space-y-1", children: [
648
- u.slice(0, 3).map((j) => /* @__PURE__ */ r.jsx(
490
+ c.slice(0, 3).map((p) => /* @__PURE__ */ r.jsx(
649
491
  "div",
650
492
  {
651
- className: O(
493
+ className: S(
652
494
  "text-xs px-2 py-1 rounded truncate cursor-pointer hover:opacity-80",
653
- j.color || ee
495
+ p.color || te
654
496
  ),
655
- style: j.color && j.color.startsWith("#") ? { backgroundColor: j.color } : void 0,
656
- onClick: (w) => {
657
- w.stopPropagation(), n?.(j);
497
+ style: p.color && p.color.startsWith("#") ? { backgroundColor: p.color } : void 0,
498
+ onClick: (j) => {
499
+ j.stopPropagation(), o?.(p);
658
500
  },
659
- children: j.title
501
+ children: p.title
660
502
  },
661
- j.id
503
+ p.id
662
504
  )),
663
- u.length > 3 && /* @__PURE__ */ r.jsxs("div", { className: "text-xs text-muted-foreground px-2", children: [
505
+ c.length > 3 && /* @__PURE__ */ r.jsxs("div", { className: "text-xs text-muted-foreground px-2", children: [
664
506
  "+",
665
- u.length - 3,
507
+ c.length - 3,
666
508
  " more"
667
509
  ] })
668
510
  ] })
669
511
  ]
670
512
  },
671
- l
513
+ d
672
514
  );
673
515
  }) })
674
516
  ] });
675
517
  }
676
- function Te({ date: t, events: o, onEventClick: n, onDateClick: m }) {
677
- const g = ue(t), c = Array.from({ length: 7 }, (a, l) => {
678
- const u = new Date(g);
679
- return u.setDate(u.getDate() + l), u;
680
- }), f = /* @__PURE__ */ new Date();
518
+ function Oe({ date: e, events: n, onEventClick: o, onDateClick: f }) {
519
+ const u = ue(e), s = Array.from({ length: 7 }, (a, d) => {
520
+ const c = new Date(u);
521
+ return c.setDate(c.getDate() + d), c;
522
+ }), m = /* @__PURE__ */ new Date();
681
523
  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);
524
+ /* @__PURE__ */ r.jsx("div", { className: "grid grid-cols-7 border-b", children: s.map((a) => {
525
+ const d = fe(a, m);
684
526
  return /* @__PURE__ */ r.jsxs(
685
527
  "div",
686
528
  {
687
529
  className: "p-3 text-center border-r last:border-r-0",
688
530
  children: [
689
- /* @__PURE__ */ r.jsx("div", { className: "text-sm font-medium text-muted-foreground", children: a.toLocaleDateString("default", { weekday: "short" }) }),
531
+ /* @__PURE__ */ r.jsx("div", { className: "text-sm font-medium text-muted-foreground", children: a.toLocaleDateString(locale, { weekday: "short" }) }),
690
532
  /* @__PURE__ */ r.jsx(
691
533
  "div",
692
534
  {
693
- className: O(
535
+ className: S(
694
536
  "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"
537
+ d && "inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-8 w-8"
696
538
  ),
697
539
  children: a.getDate()
698
540
  }
@@ -702,33 +544,33 @@ function Te({ date: t, events: o, onEventClick: n, onDateClick: m }) {
702
544
  a.toISOString()
703
545
  );
704
546
  }) }),
705
- /* @__PURE__ */ r.jsx("div", { className: "grid grid-cols-7 flex-1", children: c.map((a) => {
706
- const l = te(a, o);
547
+ /* @__PURE__ */ r.jsx("div", { className: "grid grid-cols-7 flex-1", children: s.map((a) => {
548
+ const d = re(a, n);
707
549
  return /* @__PURE__ */ r.jsx(
708
550
  "div",
709
551
  {
710
552
  className: "border-r last:border-r-0 p-2 min-h-[400px] cursor-pointer hover:bg-accent/50",
711
- onClick: () => m?.(a),
712
- children: /* @__PURE__ */ r.jsx("div", { className: "space-y-2", children: l.map((u) => /* @__PURE__ */ r.jsxs(
553
+ onClick: () => f?.(a),
554
+ children: /* @__PURE__ */ r.jsx("div", { className: "space-y-2", children: d.map((c) => /* @__PURE__ */ r.jsxs(
713
555
  "div",
714
556
  {
715
- className: O(
557
+ className: S(
716
558
  "text-sm px-3 py-2 rounded cursor-pointer hover:opacity-80",
717
- u.color || ee
559
+ c.color || te
718
560
  ),
719
- style: u.color && u.color.startsWith("#") ? { backgroundColor: u.color } : void 0,
720
- onClick: (s) => {
721
- s.stopPropagation(), n?.(u);
561
+ style: c.color && c.color.startsWith("#") ? { backgroundColor: c.color } : void 0,
562
+ onClick: (b) => {
563
+ b.stopPropagation(), o?.(c);
722
564
  },
723
565
  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", {
566
+ /* @__PURE__ */ r.jsx("div", { className: "font-medium", children: c.title }),
567
+ !c.allDay && /* @__PURE__ */ r.jsx("div", { className: "text-xs opacity-90 mt-1", children: c.start.toLocaleTimeString("default", {
726
568
  hour: "numeric",
727
569
  minute: "2-digit"
728
570
  }) })
729
571
  ]
730
572
  },
731
- u.id
573
+ c.id
732
574
  )) })
733
575
  },
734
576
  a.toISOString()
@@ -736,21 +578,21 @@ function Te({ date: t, events: o, onEventClick: n, onDateClick: m }) {
736
578
  }) })
737
579
  ] });
738
580
  }
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);
581
+ function Pe({ date: e, events: n, onEventClick: o }) {
582
+ const f = re(e, n), u = Array.from({ length: 24 }, (s, m) => m);
583
+ return /* @__PURE__ */ r.jsx("div", { className: "flex flex-col h-full", children: /* @__PURE__ */ r.jsx("div", { className: "flex-1 overflow-auto", children: u.map((s) => {
584
+ const m = f.filter((a) => a.allDay ? s === 0 : a.start.getHours() === s);
743
585
  return /* @__PURE__ */ r.jsxs("div", { className: "flex border-b min-h-[60px]", children: [
744
- /* @__PURE__ */ r.jsx("div", { className: "w-20 p-2 text-sm text-muted-foreground border-r", children: c === 0 ? "12 AM" : c < 12 ? `${c} AM` : c === 12 ? "12 PM" : `${c - 12} PM` }),
745
- /* @__PURE__ */ r.jsx("div", { className: "flex-1 p-2 space-y-2", children: f.map((a) => /* @__PURE__ */ r.jsxs(
586
+ /* @__PURE__ */ r.jsx("div", { className: "w-20 p-2 text-sm text-muted-foreground border-r", children: s === 0 ? "12 AM" : s < 12 ? `${s} AM` : s === 12 ? "12 PM" : `${s - 12} PM` }),
587
+ /* @__PURE__ */ r.jsx("div", { className: "flex-1 p-2 space-y-2", children: m.map((a) => /* @__PURE__ */ r.jsxs(
746
588
  "div",
747
589
  {
748
- className: O(
590
+ className: S(
749
591
  "px-3 py-2 rounded cursor-pointer hover:opacity-80",
750
- a.color || ee
592
+ a.color || te
751
593
  ),
752
594
  style: a.color && a.color.startsWith("#") ? { backgroundColor: a.color } : void 0,
753
- onClick: () => n?.(a),
595
+ onClick: () => o?.(a),
754
596
  children: [
755
597
  /* @__PURE__ */ r.jsx("div", { className: "font-medium", children: a.title }),
756
598
  !a.allDay && /* @__PURE__ */ r.jsxs("div", { className: "text-xs opacity-90 mt-1", children: [
@@ -767,61 +609,184 @@ function Fe({ date: t, events: o, onEventClick: n }) {
767
609
  },
768
610
  a.id
769
611
  )) })
770
- ] }, c);
612
+ ] }, s);
771
613
  }) }) });
772
614
  }
773
- de.register(
615
+ function Me(e) {
616
+ return "data" in e && e.data ? e.data : "staticData" in e && e.staticData ? {
617
+ provider: "value",
618
+ items: e.staticData
619
+ } : e.objectName ? {
620
+ provider: "object",
621
+ object: e.objectName
622
+ } : null;
623
+ }
624
+ function Ie(e) {
625
+ if (e) {
626
+ if (typeof e == "string") {
627
+ const n = e.split(" "), o = n[0], f = n[1]?.toLowerCase() === "desc" ? "desc" : "asc";
628
+ return { [o]: f };
629
+ }
630
+ if (Array.isArray(e))
631
+ return e.reduce((n, o) => (o.field && o.order && (n[o.field] = o.order), n), {});
632
+ }
633
+ }
634
+ function Ve(e) {
635
+ return "filter" in e && e.filter && typeof e.filter == "object" && "calendar" in e.filter ? e.filter.calendar : e.calendar ? e.calendar : e.startDateField || e.dateField ? {
636
+ startDateField: e.startDateField || e.dateField,
637
+ endDateField: e.endDateField || e.endField,
638
+ titleField: e.titleField || "name",
639
+ colorField: e.colorField,
640
+ allDayField: e.allDayField
641
+ } : null;
642
+ }
643
+ const Le = ({
644
+ schema: e,
645
+ dataSource: n,
646
+ className: o,
647
+ onEventClick: f,
648
+ onDateClick: u,
649
+ onNavigate: s,
650
+ onViewChange: m,
651
+ ...a
652
+ }) => {
653
+ const [d, c] = A([]), [b, h] = A(!0), [p, j] = A(null), [O, P] = A(null), [_, M] = A(/* @__PURE__ */ new Date()), [$, I] = A("month"), l = Z(() => Me(e), [
654
+ e.data,
655
+ e.staticData,
656
+ e.objectName
657
+ ]), N = Z(() => Ve(e), [
658
+ e.filter,
659
+ e.calendar,
660
+ e.dateField,
661
+ e.endField,
662
+ e.titleField,
663
+ e.colorField
664
+ ]), k = l?.provider === "value";
665
+ le(() => {
666
+ let g = !0;
667
+ return (async () => {
668
+ try {
669
+ if (!g) return;
670
+ if (h(!0), k && l?.provider === "value") {
671
+ g && (c(l.items), h(!1));
672
+ return;
673
+ }
674
+ if (e.data || a.data) {
675
+ const E = e.data || a.data;
676
+ if (Array.isArray(E)) {
677
+ c(E), h(!1);
678
+ return;
679
+ }
680
+ }
681
+ if (!n)
682
+ throw new Error("DataSource required for object/api providers");
683
+ if (l?.provider === "object") {
684
+ const E = l.object, w = await n.find(E, {
685
+ $filter: e.filter,
686
+ $orderby: Ie(e.sort)
687
+ });
688
+ let v = [];
689
+ Array.isArray(w) ? v = w : w && typeof w == "object" && (Array.isArray(w.data) ? v = w.data : Array.isArray(w.value) && (v = w.value)), g && c(v);
690
+ } else l?.provider === "api" && (console.warn("API provider not yet implemented for ObjectCalendar"), g && c([]));
691
+ g && h(!1);
692
+ } catch (E) {
693
+ console.error("[ObjectCalendar] Error fetching data:", E), g && (j(E), h(!1));
694
+ }
695
+ })(), () => {
696
+ g = !1;
697
+ };
698
+ }, [l, n, k, e.filter, e.sort]), le(() => {
699
+ !k && n && (async () => {
700
+ try {
701
+ if (!n) return;
702
+ const F = l?.provider === "object" ? l.object : e.objectName;
703
+ if (!F) return;
704
+ const E = await n.getObjectSchema(F);
705
+ P(E);
706
+ } catch (F) {
707
+ console.error("Failed to fetch object schema:", F);
708
+ }
709
+ })();
710
+ }, [e.objectName, n, k, l]);
711
+ const J = Z(() => {
712
+ if (!N || !d.length)
713
+ return [];
714
+ const { startDateField: g, endDateField: F, titleField: E, colorField: w } = N;
715
+ return d.map((v, X) => {
716
+ const C = v[g], T = F ? v[F] : null, W = v[E] || "Untitled", U = w ? v[w] : void 0;
717
+ return {
718
+ id: v.id || v._id || `event-${X}`,
719
+ title: W,
720
+ start: C ? new Date(C) : /* @__PURE__ */ new Date(),
721
+ end: T ? new Date(T) : void 0,
722
+ color: U,
723
+ allDay: !T,
724
+ // If no end date, treat as all-day event
725
+ data: v
726
+ };
727
+ }).filter((v) => !isNaN(v.start.getTime()));
728
+ }, [d, N]), G = ge(() => {
729
+ u?.(/* @__PURE__ */ new Date());
730
+ }, [u]);
731
+ return b ? /* @__PURE__ */ r.jsx("div", { className: o, children: /* @__PURE__ */ r.jsx("div", { className: "flex items-center justify-center h-96", children: /* @__PURE__ */ r.jsx("div", { className: "text-muted-foreground", children: "Loading calendar..." }) }) }) : p ? /* @__PURE__ */ r.jsx("div", { className: o, children: /* @__PURE__ */ r.jsx("div", { className: "flex items-center justify-center h-96", children: /* @__PURE__ */ r.jsxs("div", { className: "text-destructive", children: [
732
+ "Error: ",
733
+ p.message
734
+ ] }) }) }) : N ? /* @__PURE__ */ r.jsx("div", { className: o, children: /* @__PURE__ */ r.jsx("div", { className: "border rounded-lg bg-background h-[calc(100vh-200px)] min-h-[600px]", children: /* @__PURE__ */ r.jsx(
735
+ de,
736
+ {
737
+ events: J,
738
+ currentDate: _,
739
+ view: e.defaultView || "month",
740
+ onEventClick: (g) => f?.(g.data),
741
+ onDateClick: u,
742
+ onNavigate: (g) => {
743
+ M(g), s?.(g);
744
+ },
745
+ onViewChange: (g) => {
746
+ I(g), m?.(g);
747
+ },
748
+ onAddClick: G
749
+ }
750
+ ) }) }) : /* @__PURE__ */ r.jsx("div", { className: o, children: /* @__PURE__ */ r.jsx("div", { className: "flex items-center justify-center h-96", children: /* @__PURE__ */ r.jsx("div", { className: "text-muted-foreground", children: "Calendar configuration required. Please specify startDateField and titleField." }) }) });
751
+ };
752
+ ee.register(
774
753
  "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
754
+ ({ schema: e, className: n, onAction: o, ...f }) => {
755
+ const u = ce.useMemo(() => !e.data || !Array.isArray(e.data) ? [] : e.data.map((a, d) => {
756
+ const c = e.titleField || "title", b = e.startDateField || "start", h = e.endDateField || "end", p = e.colorField || "color", j = e.allDayField || "allDay";
757
+ return {
758
+ id: a._id || a.id || d,
759
+ title: a[c] || "Untitled Event",
760
+ start: new Date(a[b]),
761
+ end: a[h] ? new Date(a[h]) : void 0,
762
+ allDay: a[j],
763
+ color: a[p],
764
+ data: a
787
765
  };
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";
766
+ }), [e.data, e.titleField, e.startDateField, e.endDateField, e.colorField, e.allDayField]), s = (a) => {
767
+ e.onEventClick && o?.({
768
+ type: "event-click",
769
+ payload: a
770
+ });
771
+ }, m = () => {
772
+ o?.({
773
+ type: "create",
774
+ payload: {}
775
+ });
776
+ };
809
777
  return /* @__PURE__ */ r.jsx(
810
- Se,
778
+ de,
811
779
  {
812
- events: g,
813
- view: u,
814
- currentDate: t.currentDate ? new Date(t.currentDate) : void 0,
815
- onEventClick: c,
816
- onDateClick: t.allowCreate || t.onDateClick ? f : void 0,
817
- onViewChange: a,
818
- onNavigate: l,
819
- className: o,
820
- ...m
780
+ className: n,
781
+ events: u,
782
+ onEventClick: s,
783
+ onAddClick: m,
784
+ ...f
821
785
  }
822
786
  );
823
787
  },
824
788
  {
789
+ namespace: "plugin-calendar",
825
790
  label: "Calendar View",
826
791
  inputs: [
827
792
  {
@@ -931,16 +896,30 @@ de.register(
931
896
  }
932
897
  }
933
898
  );
934
- const Re = ({ schema: t }) => /* @__PURE__ */ r.jsx(Ee, { schema: t, dataSource: null });
935
- de.register("object-calendar", Re, {
899
+ const me = ({ schema: e }) => {
900
+ const { dataSource: n } = xe();
901
+ return /* @__PURE__ */ r.jsx(Le, { schema: e, dataSource: n });
902
+ };
903
+ ee.register("object-calendar", me, {
904
+ namespace: "plugin-calendar",
936
905
  label: "Object Calendar",
937
- category: "plugin",
906
+ category: "view",
907
+ inputs: [
908
+ { name: "objectName", type: "string", label: "Object Name", required: !0 },
909
+ { name: "calendar", type: "object", label: "Calendar Config", description: "startDateField, endDateField, titleField, colorField" }
910
+ ]
911
+ });
912
+ ee.register("calendar", me, {
913
+ namespace: "view",
914
+ label: "Calendar View",
915
+ category: "view",
938
916
  inputs: [
939
917
  { name: "objectName", type: "string", label: "Object Name", required: !0 },
940
918
  { name: "calendar", type: "object", label: "Calendar Config", description: "startDateField, endDateField, titleField, colorField" }
941
919
  ]
942
920
  });
943
921
  export {
944
- Se as CalendarView,
945
- Ee as ObjectCalendar
922
+ de as CalendarView,
923
+ Le as ObjectCalendar,
924
+ me as ObjectCalendarRenderer
946
925
  };