@object-ui/plugin-calendar 2.0.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,391 @@
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
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 ie;
32
- function Ce() {
33
- return ie || (ie = 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 M:
44
+ case x:
45
45
  return "StrictMode";
46
- case k:
46
+ case j:
47
47
  return "Suspense";
48
- case J:
48
+ case A:
49
49
  return "SuspenseList";
50
- case F:
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) {
57
- case P:
56
+ ), e.$$typeof) {
57
+ case M:
58
58
  return "Portal";
59
- case l:
60
- return t.displayName || "Context";
59
+ case F:
60
+ return e.displayName || "Context";
61
+ case k:
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;
61
66
  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;
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 f(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 = w.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 m(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
- T || (T = !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 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", {
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: q
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 b(t, i, x, D, q, 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
- h(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 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";
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 < R.length ? "{key: someKey, " + R.join(": ..., ") + ": ...}" : "{key: someKey}", ne[y + D] || (R = 0 < R.length ? "{" + R.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
- R,
201
- y
202
- ), ne[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), 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;
209
- return y && a(
210
- x,
211
- typeof t == "function" ? t.displayName || t.name || "Unknown" : 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
212
  ), c(
213
- t,
213
+ e,
214
+ S,
214
215
  y,
215
- x,
216
- u(),
217
- q,
218
- B
216
+ m(),
217
+ U,
218
+ J
219
219
  );
220
220
  }
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));
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 p(t) {
225
- return typeof t == "object" && t !== null && t.$$typeof === O;
224
+ function h(e) {
225
+ return typeof e == "object" && e !== null && e.$$typeof === T;
226
226
  }
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
+ 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
- j = {
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 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++;
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
241
  return b(
242
- t,
243
- i,
244
- x,
242
+ e,
243
+ f,
244
+ y,
245
245
  !1,
246
- D ? Error("react-stack-top-frame") : U,
247
- D ? C(f(t)) : ae
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 > w.recentlyCreatedOwnerStacks++;
249
+ }, B.jsxs = function(e, f, y) {
250
+ var w = 1e4 > Y.recentlyCreatedOwnerStacks++;
251
251
  return b(
252
- t,
253
- i,
254
- x,
252
+ e,
253
+ f,
254
+ y,
255
255
  !0,
256
- D ? Error("react-stack-top-frame") : U,
257
- D ? C(f(t)) : ae
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 se;
263
- function Te() {
264
- return se || (se = 1, process.env.NODE_ENV === "production" ? H.exports = ke() : H.exports = Ce()), H.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 = Te();
267
- const te = "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(),
272
- locale: f = "default",
273
- onEventClick: u,
274
- onDateClick: s,
275
- onViewChange: m,
276
- onNavigate: a,
277
- onAddClick: d,
278
- className: c
271
+ currentDate: s = /* @__PURE__ */ new Date(),
272
+ locale: d = "default",
273
+ onEventClick: m,
274
+ onDateClick: i,
275
+ onViewChange: g,
276
+ onNavigate: u,
277
+ onAddClick: p,
278
+ onEventDrop: c,
279
+ className: b
279
280
  }) {
280
- const [b, h] = z.useState(n), [p, j] = z.useState(o);
281
- z.useEffect(() => {
282
- j(o);
283
- }, [o]), z.useEffect(() => {
281
+ const [a, h] = P.useState(n), [l, T] = P.useState(s);
282
+ P.useEffect(() => {
283
+ T(s);
284
+ }, [s]), P.useEffect(() => {
284
285
  h(n);
285
286
  }, [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, {
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, {
300
308
  month: "long",
301
309
  year: "numeric"
302
310
  });
303
- if (b === "week") {
304
- const l = ue(p), N = new Date(l);
305
- return N.setDate(N.getDate() + 6), `${l.toLocaleDateString(f, {
311
+ if (a === "week") {
312
+ const o = me(l), E = new Date(o);
313
+ return E.setDate(E.getDate() + 6), `${o.toLocaleDateString(d, {
306
314
  month: "short",
307
315
  day: "numeric"
308
- })} - ${N.toLocaleDateString(f, {
316
+ })} - ${E.toLocaleDateString(d, {
309
317
  month: "short",
310
318
  day: "numeric",
311
319
  year: "numeric"
312
320
  })}`;
313
321
  } else
314
- return p.toLocaleDateString(f, {
322
+ return l.toLocaleDateString(d, {
315
323
  weekday: "long",
316
324
  month: "long",
317
325
  day: "numeric",
318
326
  year: "numeric"
319
327
  });
320
- }, I = (l) => {
321
- l && (j(l), a?.(l));
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));
322
338
  };
323
- return /* @__PURE__ */ r.jsxs("div", { className: S("flex flex-col h-full bg-background", c), children: [
339
+ return /* @__PURE__ */ r.jsxs("div", { role: "region", "aria-label": "Calendar", className: V("flex flex-col h-full bg-background", b), children: [
324
340
  /* @__PURE__ */ r.jsxs("div", { className: "flex items-center justify-between p-4 border-b", children: [
325
341
  /* @__PURE__ */ r.jsxs("div", { className: "flex items-center gap-4", children: [
326
342
  /* @__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" }),
343
+ /* @__PURE__ */ r.jsx(G, { variant: "ghost", size: "sm", onClick: N, className: "h-8", "aria-label": "Go to today", children: "Today" }),
328
344
  /* @__PURE__ */ r.jsx("div", { className: "h-4 w-px bg-border mx-1" }),
329
345
  /* @__PURE__ */ r.jsx(
330
- V,
346
+ G,
331
347
  {
332
348
  variant: "ghost",
333
349
  size: "icon",
334
- onClick: O,
350
+ "aria-label": "Previous period",
351
+ onClick: L,
335
352
  className: "h-8 w-8",
336
- children: /* @__PURE__ */ r.jsx(be, { className: "h-4 w-4" })
353
+ children: /* @__PURE__ */ r.jsx(ve, { className: "h-4 w-4" })
337
354
  }
338
355
  ),
339
356
  /* @__PURE__ */ r.jsx(
340
- V,
357
+ G,
341
358
  {
342
359
  variant: "ghost",
343
360
  size: "icon",
344
- onClick: P,
361
+ "aria-label": "Next period",
362
+ onClick: x,
345
363
  className: "h-8 w-8",
346
- children: /* @__PURE__ */ r.jsx(De, { className: "h-4 w-4" })
364
+ children: /* @__PURE__ */ r.jsx(ye, { className: "h-4 w-4" })
347
365
  }
348
366
  )
349
367
  ] }),
350
- /* @__PURE__ */ r.jsxs(he, { children: [
351
- /* @__PURE__ */ r.jsx(je, { asChild: !0, children: /* @__PURE__ */ r.jsxs(
352
- V,
368
+ /* @__PURE__ */ r.jsxs(Ee, { children: [
369
+ /* @__PURE__ */ r.jsx(Te, { asChild: !0, children: /* @__PURE__ */ r.jsxs(
370
+ G,
353
371
  {
354
372
  variant: "ghost",
355
- className: S(
373
+ "aria-label": `Current date: ${F()}`,
374
+ className: V(
356
375
  "text-xl font-semibold h-auto px-3 py-1 hover:bg-muted/50 transition-colors",
357
376
  "flex items-center gap-2"
358
377
  ),
359
378
  children: [
360
- /* @__PURE__ */ r.jsx(ye, { className: "h-5 w-5 text-muted-foreground" }),
361
- /* @__PURE__ */ r.jsx("span", { children: $() })
379
+ /* @__PURE__ */ r.jsx(je, { className: "h-5 w-5 text-muted-foreground" }),
380
+ /* @__PURE__ */ r.jsx("span", { children: F() })
362
381
  ]
363
382
  }
364
383
  ) }),
365
- /* @__PURE__ */ r.jsx(we, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ r.jsx(
366
- Ee,
384
+ /* @__PURE__ */ r.jsx(Se, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ r.jsx(
385
+ Ne,
367
386
  {
368
387
  mode: "single",
369
- selected: p,
388
+ selected: l,
370
389
  onSelect: I,
371
390
  initialFocus: !0,
372
391
  fromYear: 2e3,
@@ -376,165 +395,209 @@ function de({
376
395
  ] })
377
396
  ] }),
378
397
  /* @__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, {}) }),
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, {}) }),
381
400
  /* @__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" })
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" })
385
404
  ] })
386
405
  ] }),
387
- d && /* @__PURE__ */ r.jsxs(V, { onClick: d, size: "sm", className: "gap-1", children: [
388
- /* @__PURE__ */ r.jsx(ve, { 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" }),
389
408
  "New"
390
409
  ] })
391
410
  ] })
392
411
  ] }),
393
- /* @__PURE__ */ r.jsxs("div", { className: "flex-1 overflow-auto", children: [
394
- b === "month" && /* @__PURE__ */ r.jsx(
395
- Ae,
412
+ /* @__PURE__ */ r.jsxs("div", { className: "flex-1 overflow-auto", onTouchStart: j, onTouchEnd: A, children: [
413
+ a === "month" && /* @__PURE__ */ r.jsx(
414
+ Le,
396
415
  {
397
- date: p,
398
- events: e,
399
- onEventClick: u,
400
- onDateClick: s
416
+ date: l,
417
+ events: t,
418
+ onEventClick: m,
419
+ onDateClick: i,
420
+ onEventDrop: c
401
421
  }
402
422
  ),
403
- b === "week" && /* @__PURE__ */ r.jsx(
404
- Oe,
423
+ a === "week" && /* @__PURE__ */ r.jsx(
424
+ Ie,
405
425
  {
406
- date: p,
407
- events: e,
408
- onEventClick: u,
409
- onDateClick: s
426
+ date: l,
427
+ events: t,
428
+ locale: d,
429
+ onEventClick: m,
430
+ onDateClick: i
410
431
  }
411
432
  ),
412
- b === "day" && /* @__PURE__ */ r.jsx(
413
- Pe,
433
+ a === "day" && /* @__PURE__ */ r.jsx(
434
+ $e,
414
435
  {
415
- date: p,
416
- events: e,
417
- onEventClick: u
436
+ date: l,
437
+ events: t,
438
+ onEventClick: m,
439
+ onDateClick: i
418
440
  }
419
441
  )
420
442
  ] })
421
443
  ] });
422
444
  }
423
- function ue(e) {
424
- const n = new Date(e), o = n.getDay(), f = n.getDate() - o;
425
- return n.setDate(f), n;
445
+ function me(t) {
446
+ const n = new Date(t), s = n.getDay(), d = n.getDate() - s;
447
+ return n.setDate(d), n;
426
448
  }
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);
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);
432
454
  }
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);
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);
439
461
  }
440
- return m;
462
+ return g;
441
463
  }
442
- function fe(e, n) {
443
- 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();
444
466
  }
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);
452
- a.setHours(0, 0, 0, 0);
453
- const d = new Date(u);
454
- return d.setHours(23, 59, 59, 999), s <= d && m >= 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;
455
477
  });
456
478
  }
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"];
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
+ };
459
502
  return /* @__PURE__ */ r.jsxs("div", { className: "flex flex-col h-full", children: [
460
- /* @__PURE__ */ r.jsx("div", { className: "grid grid-cols-7 border-b", children: m.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(
461
504
  "div",
462
505
  {
506
+ role: "columnheader",
463
507
  className: "p-2 text-center text-sm font-medium text-muted-foreground border-r last:border-r-0",
464
- children: a
508
+ children: x
465
509
  },
466
- a
510
+ x
467
511
  )) }),
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);
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);
470
514
  return /* @__PURE__ */ r.jsxs(
471
515
  "div",
472
516
  {
473
- className: S(
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(
474
520
  "border-b border-r last:border-r-0 p-2 min-h-[100px] cursor-pointer hover:bg-accent/50",
475
- !b && "bg-muted/30 text-muted-foreground"
521
+ !F && "bg-muted/30 text-muted-foreground",
522
+ b === N && "ring-2 ring-primary"
476
523
  ),
477
- onClick: () => f?.(a),
524
+ onClick: () => d?.(x),
525
+ onDragOver: (j) => T(j, N),
526
+ onDragLeave: M,
527
+ onDrop: (j) => L(j, x),
478
528
  children: [
479
529
  /* @__PURE__ */ r.jsx(
480
530
  "div",
481
531
  {
482
- className: S(
532
+ className: V(
483
533
  "text-sm font-medium mb-1",
484
- h && "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"
485
535
  ),
486
- children: a.getDate()
536
+ ...O ? { "aria-current": "date" } : {},
537
+ children: x.getDate()
487
538
  }
488
539
  ),
489
540
  /* @__PURE__ */ r.jsxs("div", { className: "space-y-1", children: [
490
- c.slice(0, 3).map((p) => /* @__PURE__ */ r.jsx(
541
+ k.slice(0, 3).map((j) => /* @__PURE__ */ r.jsx(
491
542
  "div",
492
543
  {
493
- className: S(
544
+ role: "button",
545
+ "aria-label": j.title,
546
+ draggable: !!m,
547
+ onDragStart: (A) => h(A, j),
548
+ onDragEnd: l,
549
+ className: V(
494
550
  "text-xs px-2 py-1 rounded truncate cursor-pointer hover:opacity-80",
495
- p.color || te
551
+ j.color || le,
552
+ p === j.id && "opacity-50"
496
553
  ),
497
- style: p.color && p.color.startsWith("#") ? { backgroundColor: p.color } : void 0,
498
- onClick: (j) => {
499
- j.stopPropagation(), o?.(p);
554
+ style: j.color && j.color.startsWith("#") ? { backgroundColor: j.color } : void 0,
555
+ onClick: (A) => {
556
+ A.stopPropagation(), s?.(j);
500
557
  },
501
- children: p.title
558
+ children: j.title
502
559
  },
503
- p.id
560
+ j.id
504
561
  )),
505
- c.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: [
506
563
  "+",
507
- c.length - 3,
564
+ k.length - 3,
508
565
  " more"
509
566
  ] })
510
567
  ] })
511
568
  ]
512
569
  },
513
- d
570
+ N
514
571
  );
515
572
  }) })
516
573
  ] });
517
574
  }
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();
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();
523
586
  return /* @__PURE__ */ r.jsxs("div", { className: "flex flex-col h-full", children: [
524
- /* @__PURE__ */ r.jsx("div", { className: "grid grid-cols-7 border-b", children: s.map((a) => {
525
- const d = fe(a, m);
587
+ /* @__PURE__ */ r.jsx("div", { className: "grid grid-cols-7 border-b", children: c.map((a) => {
588
+ const h = ge(a, b);
526
589
  return /* @__PURE__ */ r.jsxs(
527
590
  "div",
528
591
  {
529
592
  className: "p-3 text-center border-r last:border-r-0",
530
593
  children: [
531
- /* @__PURE__ */ r.jsx("div", { className: "text-sm font-medium text-muted-foreground", children: a.toLocaleDateString(locale, { weekday: "short" }) }),
594
+ /* @__PURE__ */ r.jsx("div", { className: "text-sm font-medium text-muted-foreground", children: a.toLocaleDateString(s, { weekday: "short" }) }),
532
595
  /* @__PURE__ */ r.jsx(
533
596
  "div",
534
597
  {
535
- className: S(
598
+ className: V(
536
599
  "text-lg font-semibold mt-1",
537
- 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"
538
601
  ),
539
602
  children: a.getDate()
540
603
  }
@@ -544,33 +607,39 @@ function Oe({ date: e, events: n, onEventClick: o, onDateClick: f }) {
544
607
  a.toISOString()
545
608
  );
546
609
  }) }),
547
- /* @__PURE__ */ r.jsx("div", { className: "grid grid-cols-7 flex-1", children: s.map((a) => {
548
- const d = re(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);
549
612
  return /* @__PURE__ */ r.jsx(
550
613
  "div",
551
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" : ""}` : ""}`,
552
617
  className: "border-r last:border-r-0 p-2 min-h-[400px] cursor-pointer hover:bg-accent/50",
553
- onClick: () => f?.(a),
554
- children: /* @__PURE__ */ r.jsx("div", { className: "space-y-2", children: d.map((c) => /* @__PURE__ */ r.jsxs(
618
+ onClick: () => m?.(a),
619
+ onTouchStart: () => g(a),
620
+ onTouchEnd: u,
621
+ children: /* @__PURE__ */ r.jsx("div", { className: "space-y-2", children: h.map((l) => /* @__PURE__ */ r.jsxs(
555
622
  "div",
556
623
  {
557
- className: S(
558
- "text-sm px-3 py-2 rounded cursor-pointer hover:opacity-80",
559
- c.color || te
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
560
629
  ),
561
- style: c.color && c.color.startsWith("#") ? { backgroundColor: c.color } : void 0,
562
- onClick: (b) => {
563
- b.stopPropagation(), o?.(c);
630
+ style: l.color && l.color.startsWith("#") ? { backgroundColor: l.color } : void 0,
631
+ onClick: (T) => {
632
+ T.stopPropagation(), d?.(l);
564
633
  },
565
634
  children: [
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", {
635
+ /* @__PURE__ */ r.jsx("div", { className: "font-medium truncate", children: l.title }),
636
+ !l.allDay && /* @__PURE__ */ r.jsx("div", { className: "text-xs opacity-90 mt-1", children: l.start.toLocaleTimeString("default", {
568
637
  hour: "numeric",
569
638
  minute: "2-digit"
570
639
  }) })
571
640
  ]
572
641
  },
573
- c.id
642
+ l.id
574
643
  )) })
575
644
  },
576
645
  a.toISOString()
@@ -578,210 +647,286 @@ function Oe({ date: e, events: n, onEventClick: o, onDateClick: f }) {
578
647
  }) })
579
648
  ] });
580
649
  }
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);
585
- return /* @__PURE__ */ r.jsxs("div", { className: "flex border-b min-h-[60px]", children: [
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(
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(
588
664
  "div",
589
665
  {
590
- className: S(
591
- "px-3 py-2 rounded cursor-pointer hover:opacity-80",
592
- a.color || te
593
- ),
594
- style: a.color && a.color.startsWith("#") ? { backgroundColor: a.color } : void 0,
595
- onClick: () => o?.(a),
596
- children: [
597
- /* @__PURE__ */ r.jsx("div", { className: "font-medium", children: a.title }),
598
- !a.allDay && /* @__PURE__ */ r.jsxs("div", { className: "text-xs opacity-90 mt-1", children: [
599
- a.start.toLocaleTimeString("default", {
600
- hour: "numeric",
601
- minute: "2-digit"
602
- }),
603
- a.end && ` - ${a.end.toLocaleTimeString("default", {
604
- hour: "numeric",
605
- minute: "2-digit"
606
- })}`
607
- ] })
608
- ]
609
- },
610
- a.id
611
- )) })
612
- ] }, 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);
613
698
  }) }) });
614
699
  }
615
- function Me(e) {
616
- 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 ? {
617
736
  provider: "value",
618
- items: e.staticData
619
- } : e.objectName ? {
737
+ items: t.staticData
738
+ } : t.objectName ? {
620
739
  provider: "object",
621
- object: e.objectName
740
+ object: t.objectName
622
741
  } : null;
623
742
  }
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 };
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 };
629
748
  }
630
- if (Array.isArray(e))
631
- 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), {});
632
751
  }
633
752
  }
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
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
641
760
  } : null;
642
761
  }
643
- const Le = ({
644
- schema: e,
762
+ const qe = ({
763
+ schema: t,
645
764
  dataSource: n,
646
- className: o,
647
- onEventClick: f,
648
- onDateClick: u,
649
- onNavigate: s,
650
- onViewChange: m,
651
- ...a
765
+ className: s,
766
+ onEventClick: d,
767
+ onRowClick: m,
768
+ onDateClick: i,
769
+ onNavigate: g,
770
+ onViewChange: u,
771
+ ...p
652
772
  }) => {
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;
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;
667
792
  return (async () => {
668
793
  try {
669
- if (!g) return;
670
- if (h(!0), k && l?.provider === "value") {
671
- g && (c(l.items), h(!1));
794
+ if (!D) return;
795
+ if (h(!0), W && v?.provider === "value") {
796
+ D && (b(v.items), h(!1));
672
797
  return;
673
798
  }
674
- if (e.data || a.data) {
675
- const E = e.data || a.data;
676
- if (Array.isArray(E)) {
677
- c(E), h(!1);
799
+ if (t.data || p.data) {
800
+ const R = t.data || p.data;
801
+ if (Array.isArray(R)) {
802
+ b(R), h(!1);
678
803
  return;
679
804
  }
680
805
  }
681
806
  if (!n)
682
807
  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)
808
+ if (v?.provider === "object") {
809
+ const R = v.object, _ = await n.find(R, {
810
+ $filter: t.filter,
811
+ $orderby: He(t.sort)
687
812
  });
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));
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));
694
819
  }
695
820
  })(), () => {
696
- g = !1;
821
+ D = !1;
697
822
  };
698
- }, [l, n, k, e.filter, e.sort]), le(() => {
699
- !k && n && (async () => {
823
+ }, [v, n, W, t.filter, t.sort, O]), ae(() => {
824
+ !W && n && (async () => {
700
825
  try {
701
826
  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);
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);
708
833
  }
709
834
  })();
710
- }, [e.objectName, n, k, l]);
711
- const J = Z(() => {
712
- if (!N || !d.length)
835
+ }, [t.objectName, n, W, v]);
836
+ const K = te(() => {
837
+ if (!Y || !c.length)
713
838
  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;
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;
717
842
  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,
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,
724
849
  // If no end date, treat as all-day event
725
- data: v
850
+ data: e
726
851
  };
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: [
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: [
732
861
  "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." }) }) });
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." }) }) });
751
896
  };
752
- ee.register(
897
+ ne.register(
753
898
  "calendar-view",
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";
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";
757
902
  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
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
765
910
  };
766
- }), [e.data, e.titleField, e.startDateField, e.endDateField, e.colorField, e.allDayField]), s = (a) => {
767
- e.onEventClick && o?.({
911
+ }), [t.data, t.titleField, t.startDateField, t.endDateField, t.colorField, t.allDayField]), i = (u) => {
912
+ t.onEventClick && s?.({
768
913
  type: "event-click",
769
- payload: a
914
+ payload: u
770
915
  });
771
- }, m = () => {
772
- o?.({
916
+ }, g = () => {
917
+ s?.({
773
918
  type: "create",
774
919
  payload: {}
775
920
  });
776
921
  };
777
922
  return /* @__PURE__ */ r.jsx(
778
- de,
923
+ fe,
779
924
  {
780
925
  className: n,
781
- events: u,
782
- onEventClick: s,
783
- onAddClick: m,
784
- ...f
926
+ events: m,
927
+ onEventClick: i,
928
+ onAddClick: g,
929
+ ...d
785
930
  }
786
931
  );
787
932
  },
@@ -896,11 +1041,11 @@ ee.register(
896
1041
  }
897
1042
  }
898
1043
  );
899
- const me = ({ schema: e }) => {
900
- const { dataSource: n } = xe();
901
- return /* @__PURE__ */ r.jsx(Le, { schema: e, dataSource: n });
1044
+ const pe = ({ schema: t }) => {
1045
+ const { dataSource: n } = be();
1046
+ return /* @__PURE__ */ r.jsx(qe, { schema: t, dataSource: n });
902
1047
  };
903
- ee.register("object-calendar", me, {
1048
+ ne.register("object-calendar", pe, {
904
1049
  namespace: "plugin-calendar",
905
1050
  label: "Object Calendar",
906
1051
  category: "view",
@@ -909,7 +1054,7 @@ ee.register("object-calendar", me, {
909
1054
  { name: "calendar", type: "object", label: "Calendar Config", description: "startDateField, endDateField, titleField, colorField" }
910
1055
  ]
911
1056
  });
912
- ee.register("calendar", me, {
1057
+ ne.register("calendar", pe, {
913
1058
  namespace: "view",
914
1059
  label: "Calendar View",
915
1060
  category: "view",
@@ -919,7 +1064,7 @@ ee.register("calendar", me, {
919
1064
  ]
920
1065
  });
921
1066
  export {
922
- de as CalendarView,
923
- Le as ObjectCalendar,
924
- me as ObjectCalendarRenderer
1067
+ fe as CalendarView,
1068
+ qe as ObjectCalendar,
1069
+ pe as ObjectCalendarRenderer
925
1070
  };