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