@object-ui/plugin-calendar 3.3.1 → 3.4.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/CHANGELOG.md +41 -0
- package/dist/index.js +245 -201
- package/dist/index.umd.cjs +1 -1
- package/dist/packages/plugin-calendar/src/ObjectCalendar.d.ts.map +1 -1
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# @object-ui/plugin-calendar
|
|
2
2
|
|
|
3
|
+
## 3.4.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b2be122: fix(mobile): round 2 — kanban readability, calendar default view, timeline dot clipping
|
|
8
|
+
|
|
9
|
+
**Kanban**
|
|
10
|
+
- Remove `font-mono` from card titles, descriptions, column headers, and empty-state labels — CRM cards no longer render in a monospace font.
|
|
11
|
+
- Constrain column body height (`max-h-full min-h-0` + `h-full` on the layout root) so `ScrollArea` activates and cards don't bleed past the viewport bottom.
|
|
12
|
+
- Opportunistically derive `description` (e.g. `$60K · Acme Corp · @owner`) and up to two `badges` (priority/severity/industry/rating) in `ObjectKanban` when the schema/source omits them, giving mobile cards more context at a glance.
|
|
13
|
+
|
|
14
|
+
**Calendar**
|
|
15
|
+
- `ObjectCalendar` previously hardcoded `view={schema.defaultView ?? 'month'}`, making the view-selector dropdown a no-op. Wire the `view` state through to the `<Calendar>` prop so user selection is respected.
|
|
16
|
+
- On mobile (viewport < 768 px) coerce `day` defaults to `month` via a synchronous lazy initialiser and a resize/orientation effect — avoids the useless 24-hour empty-hour grid for date-only events.
|
|
17
|
+
|
|
18
|
+
**Timeline**
|
|
19
|
+
- Add `ml-3` to the `<Timeline>` `<ol>` so the `absolute -left-3` marker dots are no longer clipped at the scroll-container edge.
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [a2d7023]
|
|
22
|
+
- Updated dependencies [f1ca238]
|
|
23
|
+
- Updated dependencies [de881ef]
|
|
24
|
+
- @object-ui/components@3.4.0
|
|
25
|
+
- @object-ui/fields@3.4.0
|
|
26
|
+
- @object-ui/mobile@3.4.0
|
|
27
|
+
- @object-ui/types@3.4.0
|
|
28
|
+
- @object-ui/core@3.4.0
|
|
29
|
+
- @object-ui/react@3.4.0
|
|
30
|
+
- @object-ui/i18n@3.4.0
|
|
31
|
+
|
|
32
|
+
## 3.3.2
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- @object-ui/types@3.3.2
|
|
37
|
+
- @object-ui/core@3.3.2
|
|
38
|
+
- @object-ui/i18n@3.3.2
|
|
39
|
+
- @object-ui/react@3.3.2
|
|
40
|
+
- @object-ui/components@3.3.2
|
|
41
|
+
- @object-ui/fields@3.3.2
|
|
42
|
+
- @object-ui/mobile@3.3.2
|
|
43
|
+
|
|
3
44
|
## 3.3.1
|
|
4
45
|
|
|
5
46
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -3,21 +3,21 @@ import t, { createContext as n, useCallback as r, useContext as i, useEffect as
|
|
|
3
3
|
import { ComponentRegistry as l, buildExpandFields as u, extractRecords as d } from "@object-ui/core";
|
|
4
4
|
import { useNavigationOverlay as f, useSchemaContext as p } from "@object-ui/react";
|
|
5
5
|
import { CalendarIcon as m, ChevronLeftIcon as h, ChevronRightIcon as g, PlusIcon as _ } from "lucide-react";
|
|
6
|
-
import { Button as v, Calendar as y, NavigationOverlay as b, Popover as x, PopoverContent as S, PopoverTrigger as C, Select as w, SelectContent as T, SelectItem as E, SelectTrigger as D, SelectValue as O, cn as k } from "@object-ui/components";
|
|
6
|
+
import { Button as v, Calendar as y, NavigationOverlay as b, Popover as x, PopoverContent as S, PopoverTrigger as C, Select as w, SelectContent as T, SelectItem as E, SelectTrigger as D, SelectValue as O, cn as k, useIsMobile as A } from "@object-ui/components";
|
|
7
7
|
//#region \0rolldown/runtime.js
|
|
8
|
-
var
|
|
8
|
+
var j = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), M = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
|
|
9
9
|
if (typeof require < "u") return require.apply(this, arguments);
|
|
10
10
|
throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
11
|
-
}),
|
|
11
|
+
}), N = (e, t, n, r) => {
|
|
12
12
|
let i = [n, {
|
|
13
13
|
code: t,
|
|
14
14
|
...r || {}
|
|
15
15
|
}];
|
|
16
16
|
if (e?.services?.logger?.forward) return e.services.logger.forward(i, "warn", "react-i18next::", !0);
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
},
|
|
17
|
+
B(i[0]) && (i[0] = `react-i18next:: ${i[0]}`), e?.services?.logger?.warn ? e.services.logger.warn(...i) : console?.warn && console.warn(...i);
|
|
18
|
+
}, P = {}, F = (e, t, n, r) => {
|
|
19
|
+
B(n) && P[n] || (B(n) && (P[n] = /* @__PURE__ */ new Date()), N(e, t, n, r));
|
|
20
|
+
}, I = (e, t) => () => {
|
|
21
21
|
if (e.isInitialized) t();
|
|
22
22
|
else {
|
|
23
23
|
let n = () => {
|
|
@@ -27,19 +27,19 @@ var A = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
27
27
|
};
|
|
28
28
|
e.on("initialized", n);
|
|
29
29
|
}
|
|
30
|
-
},
|
|
31
|
-
e.loadNamespaces(t,
|
|
32
|
-
},
|
|
33
|
-
if (
|
|
30
|
+
}, L = (e, t, n) => {
|
|
31
|
+
e.loadNamespaces(t, I(e, n));
|
|
32
|
+
}, R = (e, t, n, r) => {
|
|
33
|
+
if (B(n) && (n = [n]), e.options.preload && e.options.preload.indexOf(t) > -1) return L(e, n, r);
|
|
34
34
|
n.forEach((t) => {
|
|
35
35
|
e.options.ns.indexOf(t) < 0 && e.options.ns.push(t);
|
|
36
|
-
}), e.loadLanguages(t,
|
|
37
|
-
},
|
|
36
|
+
}), e.loadLanguages(t, I(e, r));
|
|
37
|
+
}, z = (e, t, n = {}) => !t.languages || !t.languages.length ? (F(t, "NO_LANGUAGES", "i18n.languages were undefined or empty", { languages: t.languages }), !0) : t.hasLoadedNamespace(e, {
|
|
38
38
|
lng: n.lng,
|
|
39
39
|
precheck: (t, r) => {
|
|
40
40
|
if (n.bindI18n && n.bindI18n.indexOf("languageChanging") > -1 && t.services.backendConnector.backend && t.isLanguageChangingTo && !r(t.isLanguageChangingTo, e)) return !1;
|
|
41
41
|
}
|
|
42
|
-
}),
|
|
42
|
+
}), B = (e) => typeof e == "string", V = (e) => typeof e == "object" && !!e, H = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g, U = {
|
|
43
43
|
"&": "&",
|
|
44
44
|
"&": "&",
|
|
45
45
|
"<": "<",
|
|
@@ -60,7 +60,7 @@ var A = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
60
60
|
"…": "…",
|
|
61
61
|
"/": "/",
|
|
62
62
|
"/": "/"
|
|
63
|
-
},
|
|
63
|
+
}, W = (e) => U[e], G = {
|
|
64
64
|
bindI18n: "languageChanged",
|
|
65
65
|
bindI18nStore: "",
|
|
66
66
|
transEmptyNodeValue: "",
|
|
@@ -73,9 +73,9 @@ var A = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
73
73
|
"p"
|
|
74
74
|
],
|
|
75
75
|
useSuspense: !0,
|
|
76
|
-
unescape: (e) => e.replace(
|
|
76
|
+
unescape: (e) => e.replace(H, W),
|
|
77
77
|
transDefaultProps: void 0
|
|
78
|
-
},
|
|
78
|
+
}, K = () => G, q, ee = () => q, te = n(), ne = class {
|
|
79
79
|
constructor() {
|
|
80
80
|
this.usedNamespaces = {};
|
|
81
81
|
}
|
|
@@ -87,8 +87,8 @@ var A = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
87
87
|
getUsedNamespaces() {
|
|
88
88
|
return Object.keys(this.usedNamespaces);
|
|
89
89
|
}
|
|
90
|
-
},
|
|
91
|
-
var t =
|
|
90
|
+
}, re = /* @__PURE__ */ j(((e) => {
|
|
91
|
+
var t = M("react");
|
|
92
92
|
function n(e, t) {
|
|
93
93
|
return e === t && (e !== 0 || 1 / e == 1 / t) || e !== e && t !== t;
|
|
94
94
|
}
|
|
@@ -125,7 +125,7 @@ var A = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
125
125
|
}
|
|
126
126
|
var d = typeof window > "u" || window.document === void 0 || window.document.createElement === void 0 ? u : c;
|
|
127
127
|
e.useSyncExternalStore = t.useSyncExternalStore === void 0 ? d : t.useSyncExternalStore;
|
|
128
|
-
})),
|
|
128
|
+
})), ie = /* @__PURE__ */ j(((e) => {
|
|
129
129
|
process.env.NODE_ENV !== "production" && (function() {
|
|
130
130
|
function t(e, t) {
|
|
131
131
|
return e === t && (e !== 0 || 1 / e == 1 / t) || e !== e && t !== t;
|
|
@@ -168,15 +168,15 @@ var A = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
168
168
|
return t();
|
|
169
169
|
}
|
|
170
170
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
171
|
-
var a =
|
|
171
|
+
var a = M("react"), o = typeof Object.is == "function" ? Object.is : t, s = a.useState, c = a.useEffect, l = a.useLayoutEffect, u = a.useDebugValue, d = !1, f = !1, p = typeof window > "u" || window.document === void 0 || window.document.createElement === void 0 ? i : n;
|
|
172
172
|
e.useSyncExternalStore = a.useSyncExternalStore === void 0 ? p : a.useSyncExternalStore, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
173
173
|
})();
|
|
174
|
-
})),
|
|
175
|
-
process.env.NODE_ENV === "production" ? t.exports =
|
|
176
|
-
})))(),
|
|
174
|
+
})), ae = (/* @__PURE__ */ j(((e, t) => {
|
|
175
|
+
process.env.NODE_ENV === "production" ? t.exports = re() : t.exports = ie();
|
|
176
|
+
})))(), oe = {
|
|
177
177
|
t: (e, t) => {
|
|
178
|
-
if (
|
|
179
|
-
if (
|
|
178
|
+
if (B(t)) return t;
|
|
179
|
+
if (V(t) && B(t.defaultValue)) return t.defaultValue;
|
|
180
180
|
if (typeof e == "function") return "";
|
|
181
181
|
if (Array.isArray(e)) {
|
|
182
182
|
let t = e[e.length - 1];
|
|
@@ -185,17 +185,17 @@ var A = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
185
185
|
return e;
|
|
186
186
|
},
|
|
187
187
|
ready: !1
|
|
188
|
-
},
|
|
189
|
-
let { i18n: n } = t, { i18n: l, defaultNS: u } = i(
|
|
190
|
-
d && !d.reportNamespaces && (d.reportNamespaces = new
|
|
188
|
+
}, se = () => () => {}, ce = (e, t = {}) => {
|
|
189
|
+
let { i18n: n } = t, { i18n: l, defaultNS: u } = i(te) || {}, d = n || l || ee();
|
|
190
|
+
d && !d.reportNamespaces && (d.reportNamespaces = new ne()), d || F(d, "NO_I18NEXT_INSTANCE", "useTranslation: You will need to pass in an i18next instance by using initReactI18next");
|
|
191
191
|
let f = o(() => ({
|
|
192
|
-
...
|
|
192
|
+
...K(),
|
|
193
193
|
...d?.options?.react,
|
|
194
194
|
...t
|
|
195
|
-
}), [d, t]), { useSuspense: p, keyPrefix: m } = f, h = e || u || d?.options?.defaultNS, g =
|
|
195
|
+
}), [d, t]), { useSuspense: p, keyPrefix: m } = f, h = e || u || d?.options?.defaultNS, g = B(h) ? [h] : h || ["translation"], _ = o(() => g, g);
|
|
196
196
|
d?.reportNamespaces?.addUsedNamespaces?.(_);
|
|
197
197
|
let v = s(0), y = r((e) => {
|
|
198
|
-
if (!d) return
|
|
198
|
+
if (!d) return se;
|
|
199
199
|
let { bindI18n: t, bindI18nStore: n } = f, r = () => {
|
|
200
200
|
v.current += 1, e();
|
|
201
201
|
};
|
|
@@ -203,8 +203,8 @@ var A = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
203
203
|
t && t.split(" ").forEach((e) => d.off(e, r)), n && n.split(" ").forEach((e) => d.store.off(e, r));
|
|
204
204
|
};
|
|
205
205
|
}, [d, f]), b = s(), x = r(() => {
|
|
206
|
-
if (!d) return
|
|
207
|
-
let e = !!(d.isInitialized || d.initializedStoreOnce) && _.every((e) =>
|
|
206
|
+
if (!d) return oe;
|
|
207
|
+
let e = !!(d.isInitialized || d.initializedStoreOnce) && _.every((e) => z(e, d, f)), n = t.lng || d.language, r = v.current, i = b.current;
|
|
208
208
|
if (i && i.ready === e && i.lng === n && i.keyPrefix === m && i.revision === r) return i;
|
|
209
209
|
let a = {
|
|
210
210
|
t: d.getFixedT(n, f.nsMode === "fallback" ? _ : _[0], m),
|
|
@@ -220,11 +220,11 @@ var A = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
220
220
|
m,
|
|
221
221
|
f,
|
|
222
222
|
t.lng
|
|
223
|
-
]), [S, C] = c(0), { t: w, ready: T } = (0,
|
|
223
|
+
]), [S, C] = c(0), { t: w, ready: T } = (0, ae.useSyncExternalStore)(y, x, x);
|
|
224
224
|
a(() => {
|
|
225
225
|
if (d && !T && !p) {
|
|
226
226
|
let e = () => C((e) => e + 1);
|
|
227
|
-
t.lng ?
|
|
227
|
+
t.lng ? R(d, t.lng, _, e) : L(d, _, e);
|
|
228
228
|
}
|
|
229
229
|
}, [
|
|
230
230
|
d,
|
|
@@ -250,7 +250,7 @@ var A = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
250
250
|
}, A = o(() => {
|
|
251
251
|
let e = E, t = e?.language, n = e;
|
|
252
252
|
e && (D.current && D.current.__original === e && O.current === t ? n = D.current : (n = k(e), D.current = n, O.current = t));
|
|
253
|
-
let r = !T && !p ? (...e) => (
|
|
253
|
+
let r = !T && !p ? (...e) => (F(d, "USE_T_BEFORE_READY", "useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t."), w(...e)) : w, i = [
|
|
254
254
|
r,
|
|
255
255
|
n,
|
|
256
256
|
T
|
|
@@ -266,12 +266,12 @@ var A = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
266
266
|
]);
|
|
267
267
|
if (d && p && !T) throw new Promise((e) => {
|
|
268
268
|
let n = () => e();
|
|
269
|
-
t.lng ?
|
|
269
|
+
t.lng ? R(d, t.lng, _, n) : L(d, _, n);
|
|
270
270
|
});
|
|
271
271
|
return A;
|
|
272
|
-
},
|
|
273
|
-
function
|
|
274
|
-
let t = i(
|
|
272
|
+
}, le = n(null);
|
|
273
|
+
function ue(e) {
|
|
274
|
+
let t = i(le), { t: n, i18n: r } = ce(e);
|
|
275
275
|
return {
|
|
276
276
|
t: n,
|
|
277
277
|
language: t?.language || r.language || "en",
|
|
@@ -284,7 +284,7 @@ function fe(e) {
|
|
|
284
284
|
}
|
|
285
285
|
//#endregion
|
|
286
286
|
//#region ../../node_modules/.pnpm/react@19.2.5/node_modules/react/cjs/react-jsx-runtime.production.js
|
|
287
|
-
var
|
|
287
|
+
var de = /* @__PURE__ */ j(((e) => {
|
|
288
288
|
var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
|
|
289
289
|
function r(e, n, r) {
|
|
290
290
|
var i = null;
|
|
@@ -299,7 +299,7 @@ var pe = /* @__PURE__ */ A(((e) => {
|
|
|
299
299
|
};
|
|
300
300
|
}
|
|
301
301
|
e.Fragment = n, e.jsx = r, e.jsxs = r;
|
|
302
|
-
})),
|
|
302
|
+
})), fe = /* @__PURE__ */ j(((e) => {
|
|
303
303
|
process.env.NODE_ENV !== "production" && (function() {
|
|
304
304
|
function t(e) {
|
|
305
305
|
if (e == null) return null;
|
|
@@ -420,7 +420,7 @@ var pe = /* @__PURE__ */ A(((e) => {
|
|
|
420
420
|
}
|
|
421
421
|
function d(e, n, i, o, l, d) {
|
|
422
422
|
var p = n.children;
|
|
423
|
-
if (p !== void 0) if (o) if (
|
|
423
|
+
if (p !== void 0) if (o) if (j(p)) {
|
|
424
424
|
for (o = 0; o < p.length; o++) f(p[o]);
|
|
425
425
|
Object.freeze && Object.freeze(p);
|
|
426
426
|
} else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
|
@@ -442,7 +442,7 @@ var pe = /* @__PURE__ */ A(((e) => {
|
|
|
442
442
|
function p(e) {
|
|
443
443
|
return typeof e == "object" && !!e && e.$$typeof === h;
|
|
444
444
|
}
|
|
445
|
-
var m =
|
|
445
|
+
var m = M("react"), h = Symbol.for("react.transitional.element"), g = Symbol.for("react.portal"), _ = Symbol.for("react.fragment"), v = Symbol.for("react.strict_mode"), y = Symbol.for("react.profiler"), b = Symbol.for("react.consumer"), x = Symbol.for("react.context"), S = Symbol.for("react.forward_ref"), C = Symbol.for("react.suspense"), w = Symbol.for("react.suspense_list"), T = Symbol.for("react.memo"), E = Symbol.for("react.lazy"), D = Symbol.for("react.activity"), O = Symbol.for("react.client.reference"), k = m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, A = Object.prototype.hasOwnProperty, j = Array.isArray, N = console.createTask ? console.createTask : function() {
|
|
446
446
|
return null;
|
|
447
447
|
};
|
|
448
448
|
m = { react_stack_bottom_frame: function(e) {
|
|
@@ -457,9 +457,9 @@ var pe = /* @__PURE__ */ A(((e) => {
|
|
|
457
457
|
return d(e, t, n, !0, r ? Error("react-stack-top-frame") : I, r ? N(i(e)) : L);
|
|
458
458
|
};
|
|
459
459
|
})();
|
|
460
|
-
})),
|
|
461
|
-
process.env.NODE_ENV === "production" ? t.exports =
|
|
462
|
-
})))(),
|
|
460
|
+
})), J = (/* @__PURE__ */ j(((e, t) => {
|
|
461
|
+
process.env.NODE_ENV === "production" ? t.exports = de() : t.exports = fe();
|
|
462
|
+
})))(), Y = "bg-blue-500 text-white", pe = /* @__PURE__ */ new Date(), X = {
|
|
463
463
|
"calendar.today": "Today",
|
|
464
464
|
"calendar.month": "Month",
|
|
465
465
|
"calendar.week": "Week",
|
|
@@ -467,12 +467,12 @@ var pe = /* @__PURE__ */ A(((e) => {
|
|
|
467
467
|
"calendar.newEvent": "New event",
|
|
468
468
|
"calendar.moreEvents": "+{{count}} more"
|
|
469
469
|
};
|
|
470
|
-
function
|
|
470
|
+
function Z() {
|
|
471
471
|
try {
|
|
472
|
-
let e =
|
|
472
|
+
let e = ue();
|
|
473
473
|
return e.t("calendar.today") === "calendar.today" ? {
|
|
474
474
|
t: (e, t) => {
|
|
475
|
-
let n =
|
|
475
|
+
let n = X[e] || e;
|
|
476
476
|
if (t) for (let [e, r] of Object.entries(t)) n = n.replace(`{{${e}}}`, String(r));
|
|
477
477
|
return n;
|
|
478
478
|
},
|
|
@@ -484,7 +484,7 @@ function J() {
|
|
|
484
484
|
} catch {
|
|
485
485
|
return {
|
|
486
486
|
t: (e, t) => {
|
|
487
|
-
let n =
|
|
487
|
+
let n = X[e] || e;
|
|
488
488
|
if (t) for (let [e, r] of Object.entries(t)) n = n.replace(`{{${e}}}`, String(r));
|
|
489
489
|
return n;
|
|
490
490
|
},
|
|
@@ -492,8 +492,8 @@ function J() {
|
|
|
492
492
|
};
|
|
493
493
|
}
|
|
494
494
|
}
|
|
495
|
-
function
|
|
496
|
-
let [f, p] = e.useState(n), [b, A] = e.useState(r), { t: j, language: M } =
|
|
495
|
+
function Q({ events: t = [], view: n = "month", currentDate: r = pe, locale: i = "default", onEventClick: a, onDateClick: o, onViewChange: s, onNavigate: c, onAddClick: l, onEventDrop: u, className: d }) {
|
|
496
|
+
let [f, p] = e.useState(n), [b, A] = e.useState(r), { t: j, language: M } = Z(), N = i === "default" ? M : i;
|
|
497
497
|
e.useEffect(() => {
|
|
498
498
|
A(r);
|
|
499
499
|
}, [r]), e.useEffect(() => {
|
|
@@ -523,7 +523,7 @@ function Y({ events: t = [], view: n = "month", currentDate: r = he, locale: i =
|
|
|
523
523
|
year: "numeric"
|
|
524
524
|
});
|
|
525
525
|
if (f === "week") {
|
|
526
|
-
let e =
|
|
526
|
+
let e = me(b), t = new Date(e);
|
|
527
527
|
return t.setDate(t.getDate() + 6), `${e.toLocaleDateString(N, {
|
|
528
528
|
month: "short",
|
|
529
529
|
day: "numeric"
|
|
@@ -539,18 +539,18 @@ function Y({ events: t = [], view: n = "month", currentDate: r = he, locale: i =
|
|
|
539
539
|
year: "numeric"
|
|
540
540
|
});
|
|
541
541
|
}, B = e.useRef(0);
|
|
542
|
-
return /* @__PURE__ */ (0,
|
|
542
|
+
return /* @__PURE__ */ (0, J.jsxs)("div", {
|
|
543
543
|
role: "region",
|
|
544
544
|
"aria-label": "Calendar",
|
|
545
545
|
className: k("flex flex-col h-full bg-background min-w-0 overflow-hidden", d),
|
|
546
|
-
children: [/* @__PURE__ */ (0,
|
|
546
|
+
children: [/* @__PURE__ */ (0, J.jsxs)("div", {
|
|
547
547
|
className: "flex flex-wrap items-center justify-between gap-2 p-2 sm:p-4 border-b min-w-0",
|
|
548
|
-
children: [/* @__PURE__ */ (0,
|
|
548
|
+
children: [/* @__PURE__ */ (0, J.jsxs)("div", {
|
|
549
549
|
className: "flex items-center gap-4",
|
|
550
|
-
children: [/* @__PURE__ */ (0,
|
|
550
|
+
children: [/* @__PURE__ */ (0, J.jsxs)("div", {
|
|
551
551
|
className: "flex items-center bg-muted/50 rounded-lg p-1 gap-1",
|
|
552
552
|
children: [
|
|
553
|
-
/* @__PURE__ */ (0,
|
|
553
|
+
/* @__PURE__ */ (0, J.jsx)(v, {
|
|
554
554
|
variant: "ghost",
|
|
555
555
|
size: "sm",
|
|
556
556
|
onClick: L,
|
|
@@ -558,36 +558,36 @@ function Y({ events: t = [], view: n = "month", currentDate: r = he, locale: i =
|
|
|
558
558
|
"aria-label": "Go to today",
|
|
559
559
|
children: j("calendar.today")
|
|
560
560
|
}),
|
|
561
|
-
/* @__PURE__ */ (0,
|
|
562
|
-
/* @__PURE__ */ (0,
|
|
561
|
+
/* @__PURE__ */ (0, J.jsx)("div", { className: "h-4 w-px bg-border mx-1" }),
|
|
562
|
+
/* @__PURE__ */ (0, J.jsx)(v, {
|
|
563
563
|
variant: "ghost",
|
|
564
564
|
size: "icon",
|
|
565
565
|
"aria-label": "Previous period",
|
|
566
566
|
onClick: F,
|
|
567
567
|
className: "h-8 w-8",
|
|
568
|
-
children: /* @__PURE__ */ (0,
|
|
568
|
+
children: /* @__PURE__ */ (0, J.jsx)(h, { className: "h-4 w-4" })
|
|
569
569
|
}),
|
|
570
|
-
/* @__PURE__ */ (0,
|
|
570
|
+
/* @__PURE__ */ (0, J.jsx)(v, {
|
|
571
571
|
variant: "ghost",
|
|
572
572
|
size: "icon",
|
|
573
573
|
"aria-label": "Next period",
|
|
574
574
|
onClick: I,
|
|
575
575
|
className: "h-8 w-8",
|
|
576
|
-
children: /* @__PURE__ */ (0,
|
|
576
|
+
children: /* @__PURE__ */ (0, J.jsx)(g, { className: "h-4 w-4" })
|
|
577
577
|
})
|
|
578
578
|
]
|
|
579
|
-
}), /* @__PURE__ */ (0,
|
|
579
|
+
}), /* @__PURE__ */ (0, J.jsxs)(x, { children: [/* @__PURE__ */ (0, J.jsx)(C, {
|
|
580
580
|
asChild: !0,
|
|
581
|
-
children: /* @__PURE__ */ (0,
|
|
581
|
+
children: /* @__PURE__ */ (0, J.jsxs)(v, {
|
|
582
582
|
variant: "ghost",
|
|
583
583
|
"aria-label": `Current date: ${z()}`,
|
|
584
584
|
className: k("text-base sm:text-xl font-semibold h-auto px-2 sm:px-3 py-1 hover:bg-muted/50 transition-colors", "flex items-center gap-2"),
|
|
585
|
-
children: [/* @__PURE__ */ (0,
|
|
585
|
+
children: [/* @__PURE__ */ (0, J.jsx)(m, { className: "h-5 w-5 text-muted-foreground" }), /* @__PURE__ */ (0, J.jsx)("span", { children: z() })]
|
|
586
586
|
})
|
|
587
|
-
}), /* @__PURE__ */ (0,
|
|
587
|
+
}), /* @__PURE__ */ (0, J.jsx)(S, {
|
|
588
588
|
className: "w-auto p-0",
|
|
589
589
|
align: "start",
|
|
590
|
-
children: /* @__PURE__ */ (0,
|
|
590
|
+
children: /* @__PURE__ */ (0, J.jsx)(y, {
|
|
591
591
|
mode: "single",
|
|
592
592
|
selected: b,
|
|
593
593
|
onSelect: (e) => {
|
|
@@ -598,36 +598,36 @@ function Y({ events: t = [], view: n = "month", currentDate: r = he, locale: i =
|
|
|
598
598
|
toYear: 2050
|
|
599
599
|
})
|
|
600
600
|
})] })]
|
|
601
|
-
}), /* @__PURE__ */ (0,
|
|
601
|
+
}), /* @__PURE__ */ (0, J.jsxs)("div", {
|
|
602
602
|
className: "flex items-center gap-2",
|
|
603
|
-
children: [/* @__PURE__ */ (0,
|
|
603
|
+
children: [/* @__PURE__ */ (0, J.jsxs)(w, {
|
|
604
604
|
value: f,
|
|
605
605
|
onValueChange: R,
|
|
606
|
-
children: [/* @__PURE__ */ (0,
|
|
606
|
+
children: [/* @__PURE__ */ (0, J.jsx)(D, {
|
|
607
607
|
className: "w-32 bg-background",
|
|
608
|
-
children: /* @__PURE__ */ (0,
|
|
609
|
-
}), /* @__PURE__ */ (0,
|
|
610
|
-
/* @__PURE__ */ (0,
|
|
608
|
+
children: /* @__PURE__ */ (0, J.jsx)(O, {})
|
|
609
|
+
}), /* @__PURE__ */ (0, J.jsxs)(T, { children: [
|
|
610
|
+
/* @__PURE__ */ (0, J.jsx)(E, {
|
|
611
611
|
value: "day",
|
|
612
612
|
children: j("calendar.day")
|
|
613
613
|
}),
|
|
614
|
-
/* @__PURE__ */ (0,
|
|
614
|
+
/* @__PURE__ */ (0, J.jsx)(E, {
|
|
615
615
|
value: "week",
|
|
616
616
|
children: j("calendar.week")
|
|
617
617
|
}),
|
|
618
|
-
/* @__PURE__ */ (0,
|
|
618
|
+
/* @__PURE__ */ (0, J.jsx)(E, {
|
|
619
619
|
value: "month",
|
|
620
620
|
children: j("calendar.month")
|
|
621
621
|
})
|
|
622
622
|
] })]
|
|
623
|
-
}), l && /* @__PURE__ */ (0,
|
|
623
|
+
}), l && /* @__PURE__ */ (0, J.jsxs)(v, {
|
|
624
624
|
onClick: l,
|
|
625
625
|
size: "sm",
|
|
626
626
|
className: "gap-1",
|
|
627
|
-
children: [/* @__PURE__ */ (0,
|
|
627
|
+
children: [/* @__PURE__ */ (0, J.jsx)(_, { className: "h-4 w-4" }), j("calendar.newEvent")]
|
|
628
628
|
})]
|
|
629
629
|
})]
|
|
630
|
-
}), /* @__PURE__ */ (0,
|
|
630
|
+
}), /* @__PURE__ */ (0, J.jsxs)("div", {
|
|
631
631
|
className: "flex-1 overflow-auto",
|
|
632
632
|
onTouchStart: (e) => {
|
|
633
633
|
B.current = e.touches[0].clientX;
|
|
@@ -640,7 +640,7 @@ function Y({ events: t = [], view: n = "month", currentDate: r = he, locale: i =
|
|
|
640
640
|
}
|
|
641
641
|
},
|
|
642
642
|
children: [
|
|
643
|
-
f === "month" && /* @__PURE__ */ (0,
|
|
643
|
+
f === "month" && /* @__PURE__ */ (0, J.jsx)(ve, {
|
|
644
644
|
date: b,
|
|
645
645
|
events: t,
|
|
646
646
|
locale: N,
|
|
@@ -648,14 +648,14 @@ function Y({ events: t = [], view: n = "month", currentDate: r = he, locale: i =
|
|
|
648
648
|
onDateClick: o,
|
|
649
649
|
onEventDrop: u
|
|
650
650
|
}),
|
|
651
|
-
f === "week" && /* @__PURE__ */ (0,
|
|
651
|
+
f === "week" && /* @__PURE__ */ (0, J.jsx)(ye, {
|
|
652
652
|
date: b,
|
|
653
653
|
events: t,
|
|
654
654
|
locale: N,
|
|
655
655
|
onEventClick: a,
|
|
656
656
|
onDateClick: o
|
|
657
657
|
}),
|
|
658
|
-
f === "day" && /* @__PURE__ */ (0,
|
|
658
|
+
f === "day" && /* @__PURE__ */ (0, J.jsx)(be, {
|
|
659
659
|
date: b,
|
|
660
660
|
events: t,
|
|
661
661
|
onEventClick: a,
|
|
@@ -665,11 +665,11 @@ function Y({ events: t = [], view: n = "month", currentDate: r = he, locale: i =
|
|
|
665
665
|
})]
|
|
666
666
|
});
|
|
667
667
|
}
|
|
668
|
-
function
|
|
668
|
+
function me(e) {
|
|
669
669
|
let t = new Date(e), n = t.getDay(), r = t.getDate() - n;
|
|
670
670
|
return t.setDate(r), t;
|
|
671
671
|
}
|
|
672
|
-
function
|
|
672
|
+
function he(e) {
|
|
673
673
|
let t = e.getFullYear(), n = e.getMonth(), r = new Date(t, n, 1), i = new Date(t, n + 1, 0), a = r.getDay(), o = [];
|
|
674
674
|
for (let e = a - 1; e >= 0; e--) {
|
|
675
675
|
let t = new Date(r.getTime());
|
|
@@ -683,10 +683,10 @@ function ge(e) {
|
|
|
683
683
|
}
|
|
684
684
|
return o;
|
|
685
685
|
}
|
|
686
|
-
function
|
|
686
|
+
function ge(e, t) {
|
|
687
687
|
return e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth() && e.getDate() === t.getDate();
|
|
688
688
|
}
|
|
689
|
-
function
|
|
689
|
+
function _e(e, t) {
|
|
690
690
|
return t.filter((t) => {
|
|
691
691
|
let n = new Date(t.start), r = t.end ? new Date(t.end) : new Date(n), i = new Date(e);
|
|
692
692
|
i.setHours(0, 0, 0, 0);
|
|
@@ -698,8 +698,8 @@ function Q(e, t) {
|
|
|
698
698
|
return s.setHours(23, 59, 59, 999), i <= s && a >= o;
|
|
699
699
|
});
|
|
700
700
|
}
|
|
701
|
-
function
|
|
702
|
-
let s = e.useMemo(() =>
|
|
701
|
+
function ve({ date: t, events: n, locale: r = "default", onEventClick: i, onDateClick: a, onEventDrop: o }) {
|
|
702
|
+
let s = e.useMemo(() => he(t), [t.getFullYear(), t.getMonth()]), c = e.useMemo(() => /* @__PURE__ */ new Date(), []), { t: l } = Z(), u = e.useMemo(() => {
|
|
703
703
|
let e = new Date(2024, 0, 7);
|
|
704
704
|
return Array.from({ length: 7 }, (t, n) => {
|
|
705
705
|
let i = new Date(e);
|
|
@@ -738,23 +738,23 @@ function _e({ date: t, events: n, locale: r = "default", onEventClick: i, onDate
|
|
|
738
738
|
let u = new Date(a.getTime() + l), d;
|
|
739
739
|
i.end && (d = new Date(new Date(i.end).getTime() + l)), o(i, u, d);
|
|
740
740
|
};
|
|
741
|
-
return /* @__PURE__ */ (0,
|
|
741
|
+
return /* @__PURE__ */ (0, J.jsxs)("div", {
|
|
742
742
|
className: "flex flex-col h-full",
|
|
743
|
-
children: [/* @__PURE__ */ (0,
|
|
743
|
+
children: [/* @__PURE__ */ (0, J.jsx)("div", {
|
|
744
744
|
role: "row",
|
|
745
745
|
className: "grid grid-cols-7 border-b",
|
|
746
|
-
children: u.map((e) => /* @__PURE__ */ (0,
|
|
746
|
+
children: u.map((e) => /* @__PURE__ */ (0, J.jsx)("div", {
|
|
747
747
|
role: "columnheader",
|
|
748
748
|
className: "p-2 text-center text-sm font-medium text-muted-foreground border-r last:border-r-0",
|
|
749
749
|
children: e
|
|
750
750
|
}, e))
|
|
751
|
-
}), /* @__PURE__ */ (0,
|
|
751
|
+
}), /* @__PURE__ */ (0, J.jsx)("div", {
|
|
752
752
|
role: "grid",
|
|
753
753
|
"aria-label": "Calendar grid",
|
|
754
754
|
className: "grid grid-cols-7 flex-1 auto-rows-fr",
|
|
755
755
|
children: s.map((e, n) => {
|
|
756
|
-
let r = `${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`, s = h.get(r) || [], u = e.getMonth() === t.getMonth(), f =
|
|
757
|
-
return /* @__PURE__ */ (0,
|
|
756
|
+
let r = `${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`, s = h.get(r) || [], u = e.getMonth() === t.getMonth(), f = ge(e, c);
|
|
757
|
+
return /* @__PURE__ */ (0, J.jsxs)("div", {
|
|
758
758
|
role: "gridcell",
|
|
759
759
|
"aria-label": `${e.toLocaleDateString("default", {
|
|
760
760
|
weekday: "long",
|
|
@@ -767,26 +767,26 @@ function _e({ date: t, events: n, locale: r = "default", onEventClick: i, onDate
|
|
|
767
767
|
onDragOver: (e) => v(e, n),
|
|
768
768
|
onDragLeave: y,
|
|
769
769
|
onDrop: (t) => b(t, e),
|
|
770
|
-
children: [/* @__PURE__ */ (0,
|
|
770
|
+
children: [/* @__PURE__ */ (0, J.jsx)("div", {
|
|
771
771
|
className: k("text-sm font-medium mb-2", f && "inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-6 w-6"),
|
|
772
772
|
...f ? { "aria-current": "date" } : {},
|
|
773
773
|
children: e.getDate()
|
|
774
|
-
}), /* @__PURE__ */ (0,
|
|
774
|
+
}), /* @__PURE__ */ (0, J.jsxs)("div", {
|
|
775
775
|
className: "space-y-1",
|
|
776
|
-
children: [s.slice(0, 3).map((e) => /* @__PURE__ */ (0,
|
|
776
|
+
children: [s.slice(0, 3).map((e) => /* @__PURE__ */ (0, J.jsx)("div", {
|
|
777
777
|
role: "button",
|
|
778
778
|
title: e.title,
|
|
779
779
|
"aria-label": e.title,
|
|
780
780
|
draggable: !!o,
|
|
781
781
|
onDragStart: (t) => g(t, e),
|
|
782
782
|
onDragEnd: _,
|
|
783
|
-
className: k("text-xs px-2 py-1 rounded truncate cursor-pointer hover:opacity-80", e.color?.startsWith("#") ? "text-white" : e.color ||
|
|
783
|
+
className: k("text-xs px-2 py-1 rounded truncate cursor-pointer hover:opacity-80", e.color?.startsWith("#") ? "text-white" : e.color || Y, d === e.id && "opacity-50"),
|
|
784
784
|
style: e.color && e.color.startsWith("#") ? { backgroundColor: e.color } : void 0,
|
|
785
785
|
onClick: (t) => {
|
|
786
786
|
t.stopPropagation(), i?.(e);
|
|
787
787
|
},
|
|
788
788
|
children: e.title
|
|
789
|
-
}, e.id)), s.length > 3 && /* @__PURE__ */ (0,
|
|
789
|
+
}, e.id)), s.length > 3 && /* @__PURE__ */ (0, J.jsx)("div", {
|
|
790
790
|
className: "text-xs text-muted-foreground px-2",
|
|
791
791
|
children: l("calendar.moreEvents", { count: s.length - 3 })
|
|
792
792
|
})]
|
|
@@ -796,40 +796,40 @@ function _e({ date: t, events: n, locale: r = "default", onEventClick: i, onDate
|
|
|
796
796
|
})]
|
|
797
797
|
});
|
|
798
798
|
}
|
|
799
|
-
function
|
|
799
|
+
function ye({ date: t, events: n, locale: r = "default", onEventClick: i, onDateClick: a }) {
|
|
800
800
|
let o = e.useRef(null), s = (e) => {
|
|
801
801
|
a && (o.current = setTimeout(() => {
|
|
802
802
|
a(e);
|
|
803
803
|
}, 500));
|
|
804
804
|
}, c = () => {
|
|
805
805
|
o.current &&= (clearTimeout(o.current), null);
|
|
806
|
-
}, l =
|
|
806
|
+
}, l = me(t), u = Array.from({ length: 7 }, (e, t) => {
|
|
807
807
|
let n = new Date(l);
|
|
808
808
|
return n.setDate(n.getDate() + t), n;
|
|
809
809
|
}), d = /* @__PURE__ */ new Date();
|
|
810
|
-
return /* @__PURE__ */ (0,
|
|
810
|
+
return /* @__PURE__ */ (0, J.jsxs)("div", {
|
|
811
811
|
className: "flex flex-col h-full",
|
|
812
|
-
children: [/* @__PURE__ */ (0,
|
|
812
|
+
children: [/* @__PURE__ */ (0, J.jsx)("div", {
|
|
813
813
|
className: "grid grid-cols-7 border-b",
|
|
814
814
|
children: u.map((e) => {
|
|
815
|
-
let t =
|
|
816
|
-
return /* @__PURE__ */ (0,
|
|
815
|
+
let t = ge(e, d);
|
|
816
|
+
return /* @__PURE__ */ (0, J.jsxs)("div", {
|
|
817
817
|
className: "p-3 text-center border-r last:border-r-0",
|
|
818
|
-
children: [/* @__PURE__ */ (0,
|
|
818
|
+
children: [/* @__PURE__ */ (0, J.jsx)("div", {
|
|
819
819
|
className: "text-sm font-medium text-muted-foreground",
|
|
820
820
|
children: e.toLocaleDateString(r, { weekday: "short" })
|
|
821
|
-
}), /* @__PURE__ */ (0,
|
|
821
|
+
}), /* @__PURE__ */ (0, J.jsx)("div", {
|
|
822
822
|
className: k("text-lg font-semibold mt-1", t && "inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-8 w-8"),
|
|
823
823
|
children: e.getDate()
|
|
824
824
|
})]
|
|
825
825
|
}, e.toISOString());
|
|
826
826
|
})
|
|
827
|
-
}), /* @__PURE__ */ (0,
|
|
827
|
+
}), /* @__PURE__ */ (0, J.jsx)("div", {
|
|
828
828
|
role: "grid",
|
|
829
829
|
className: "grid grid-cols-7 flex-1",
|
|
830
830
|
children: u.map((e) => {
|
|
831
|
-
let t =
|
|
832
|
-
return /* @__PURE__ */ (0,
|
|
831
|
+
let t = _e(e, n);
|
|
832
|
+
return /* @__PURE__ */ (0, J.jsx)("div", {
|
|
833
833
|
role: "gridcell",
|
|
834
834
|
"aria-label": `${e.toLocaleDateString("default", {
|
|
835
835
|
weekday: "long",
|
|
@@ -841,21 +841,21 @@ function ve({ date: t, events: n, locale: r = "default", onEventClick: i, onDate
|
|
|
841
841
|
onClick: () => a?.(e),
|
|
842
842
|
onTouchStart: () => s(e),
|
|
843
843
|
onTouchEnd: c,
|
|
844
|
-
children: /* @__PURE__ */ (0,
|
|
844
|
+
children: /* @__PURE__ */ (0, J.jsx)("div", {
|
|
845
845
|
className: "space-y-2",
|
|
846
|
-
children: t.map((e) => /* @__PURE__ */ (0,
|
|
846
|
+
children: t.map((e) => /* @__PURE__ */ (0, J.jsxs)("div", {
|
|
847
847
|
role: "button",
|
|
848
848
|
title: e.title,
|
|
849
849
|
"aria-label": e.title,
|
|
850
|
-
className: k("text-xs sm:text-sm px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80", e.color?.startsWith("#") ? "text-white" : e.color ||
|
|
850
|
+
className: k("text-xs sm:text-sm px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80", e.color?.startsWith("#") ? "text-white" : e.color || Y),
|
|
851
851
|
style: e.color && e.color.startsWith("#") ? { backgroundColor: e.color } : void 0,
|
|
852
852
|
onClick: (t) => {
|
|
853
853
|
t.stopPropagation(), i?.(e);
|
|
854
854
|
},
|
|
855
|
-
children: [/* @__PURE__ */ (0,
|
|
855
|
+
children: [/* @__PURE__ */ (0, J.jsx)("div", {
|
|
856
856
|
className: "font-medium truncate",
|
|
857
857
|
children: e.title
|
|
858
|
-
}), !e.allDay && /* @__PURE__ */ (0,
|
|
858
|
+
}), !e.allDay && /* @__PURE__ */ (0, J.jsx)("div", {
|
|
859
859
|
className: "text-xs opacity-90 mt-1",
|
|
860
860
|
children: e.start.toLocaleTimeString("default", {
|
|
861
861
|
hour: "numeric",
|
|
@@ -869,8 +869,8 @@ function ve({ date: t, events: n, locale: r = "default", onEventClick: i, onDate
|
|
|
869
869
|
})]
|
|
870
870
|
});
|
|
871
871
|
}
|
|
872
|
-
function
|
|
873
|
-
let a =
|
|
872
|
+
function be({ date: t, events: n, onEventClick: r, onDateClick: i }) {
|
|
873
|
+
let a = _e(t, n), o = Array.from({ length: 24 }, (e, t) => t), s = e.useRef(null), c = (e) => {
|
|
874
874
|
i && (s.current = setTimeout(() => {
|
|
875
875
|
let n = new Date(t);
|
|
876
876
|
n.setHours(e, 0, 0, 0), i(n);
|
|
@@ -878,33 +878,33 @@ function ye({ date: t, events: n, onEventClick: r, onDateClick: i }) {
|
|
|
878
878
|
}, l = () => {
|
|
879
879
|
s.current &&= (clearTimeout(s.current), null);
|
|
880
880
|
};
|
|
881
|
-
return /* @__PURE__ */ (0,
|
|
881
|
+
return /* @__PURE__ */ (0, J.jsx)("div", {
|
|
882
882
|
className: "flex flex-col h-full",
|
|
883
|
-
children: /* @__PURE__ */ (0,
|
|
883
|
+
children: /* @__PURE__ */ (0, J.jsx)("div", {
|
|
884
884
|
role: "list",
|
|
885
885
|
className: "flex-1 overflow-auto",
|
|
886
886
|
children: o.map((e) => {
|
|
887
887
|
let t = a.filter((t) => t.allDay ? e === 0 : t.start.getHours() === e);
|
|
888
|
-
return /* @__PURE__ */ (0,
|
|
888
|
+
return /* @__PURE__ */ (0, J.jsxs)("div", {
|
|
889
889
|
role: "listitem",
|
|
890
890
|
className: "flex border-b min-h-[60px]",
|
|
891
|
-
children: [/* @__PURE__ */ (0,
|
|
891
|
+
children: [/* @__PURE__ */ (0, J.jsx)("div", {
|
|
892
892
|
className: "w-20 p-2 text-sm text-muted-foreground border-r",
|
|
893
893
|
children: e === 0 ? "12 AM" : e < 12 ? `${e} AM` : e === 12 ? "12 PM" : `${e - 12} PM`
|
|
894
|
-
}), /* @__PURE__ */ (0,
|
|
894
|
+
}), /* @__PURE__ */ (0, J.jsx)("div", {
|
|
895
895
|
className: "flex-1 p-2 space-y-2",
|
|
896
896
|
onTouchStart: () => c(e),
|
|
897
897
|
onTouchEnd: l,
|
|
898
|
-
children: t.map((e) => /* @__PURE__ */ (0,
|
|
898
|
+
children: t.map((e) => /* @__PURE__ */ (0, J.jsxs)("div", {
|
|
899
899
|
title: e.title,
|
|
900
900
|
"aria-label": e.title,
|
|
901
|
-
className: k("px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80", e.color?.startsWith("#") ? "text-white" : e.color ||
|
|
901
|
+
className: k("px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80", e.color?.startsWith("#") ? "text-white" : e.color || Y),
|
|
902
902
|
style: e.color && e.color.startsWith("#") ? { backgroundColor: e.color } : void 0,
|
|
903
903
|
onClick: () => r?.(e),
|
|
904
|
-
children: [/* @__PURE__ */ (0,
|
|
904
|
+
children: [/* @__PURE__ */ (0, J.jsx)("div", {
|
|
905
905
|
className: "font-medium truncate",
|
|
906
906
|
children: e.title
|
|
907
|
-
}), !e.allDay && /* @__PURE__ */ (0,
|
|
907
|
+
}), !e.allDay && /* @__PURE__ */ (0, J.jsxs)("div", {
|
|
908
908
|
className: "text-xs opacity-90 mt-1",
|
|
909
909
|
children: [e.start.toLocaleTimeString("default", {
|
|
910
910
|
hour: "numeric",
|
|
@@ -923,7 +923,7 @@ function ye({ date: t, events: n, onEventClick: r, onDateClick: i }) {
|
|
|
923
923
|
}
|
|
924
924
|
//#endregion
|
|
925
925
|
//#region ../mobile/dist/usePullToRefresh.js
|
|
926
|
-
function
|
|
926
|
+
function xe(e) {
|
|
927
927
|
let { onRefresh: t, threshold: n = 80, enabled: i = !0 } = e, o = s(null), [l, u] = c(!1), [d, f] = c(0), p = s(0), m = r((e) => {
|
|
928
928
|
if (!i || l) return;
|
|
929
929
|
let t = o.current;
|
|
@@ -972,11 +972,11 @@ function be(e) {
|
|
|
972
972
|
}
|
|
973
973
|
//#endregion
|
|
974
974
|
//#region ../mobile/dist/MobileProvider.js
|
|
975
|
-
var
|
|
976
|
-
|
|
975
|
+
var Se = n(null);
|
|
976
|
+
Se.displayName = "MobileContext";
|
|
977
977
|
//#endregion
|
|
978
978
|
//#region src/ObjectCalendar.tsx
|
|
979
|
-
function
|
|
979
|
+
function Ce(e) {
|
|
980
980
|
return "data" in e && e.data ? e.data : "staticData" in e && e.staticData ? {
|
|
981
981
|
provider: "value",
|
|
982
982
|
items: e.staticData
|
|
@@ -985,7 +985,7 @@ function Se(e) {
|
|
|
985
985
|
object: e.objectName
|
|
986
986
|
} : null;
|
|
987
987
|
}
|
|
988
|
-
function
|
|
988
|
+
function we(e) {
|
|
989
989
|
if (e) {
|
|
990
990
|
if (typeof e == "string") {
|
|
991
991
|
let t = e.split(" "), n = t[0], r = t[1]?.toLowerCase() === "desc" ? "desc" : "asc";
|
|
@@ -994,44 +994,51 @@ function Ce(e) {
|
|
|
994
994
|
if (Array.isArray(e)) return e.reduce((e, t) => (t.field && t.order && (e[t.field] = t.order), e), {});
|
|
995
995
|
}
|
|
996
996
|
}
|
|
997
|
-
function
|
|
997
|
+
function Te(e) {
|
|
998
998
|
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 ? {
|
|
999
999
|
startDateField: e.startDateField || e.dateField,
|
|
1000
1000
|
endDateField: e.endDateField || e.endField,
|
|
1001
|
-
titleField: e.titleField
|
|
1001
|
+
titleField: e.titleField,
|
|
1002
1002
|
colorField: e.colorField,
|
|
1003
1003
|
allDayField: e.allDayField
|
|
1004
1004
|
} : null;
|
|
1005
1005
|
}
|
|
1006
|
-
var
|
|
1007
|
-
let x = Array.isArray(i), [S, C] = c(x ? i : []), [w, T] = c(x ? l ?? !1 : !0), [E, D] = c(null), [O, k] = c(null), [
|
|
1006
|
+
var Ee = ({ schema: e, dataSource: t, className: n, data: i, loading: l, onEventClick: p, onRowClick: m, onDateClick: h, onNavigate: g, onViewChange: _, onEventDrop: v, locale: y }) => {
|
|
1007
|
+
let x = Array.isArray(i), [S, C] = c(x ? i : []), [w, T] = c(x ? l ?? !1 : !0), [E, D] = c(null), [O, k] = c(null), [j, M] = c(/* @__PURE__ */ new Date()), N = A(), P = e.defaultView, [F, I] = c(() => {
|
|
1008
|
+
let e = P === "day" || !P;
|
|
1009
|
+
return typeof window < "u" && window.innerWidth < 768 && e ? "month" : P || "month";
|
|
1010
|
+
});
|
|
1011
|
+
a(() => {
|
|
1012
|
+
N && F === "day" && (P === "day" || !P) && I("month");
|
|
1013
|
+
}, [N]);
|
|
1014
|
+
let [L, R] = c(0);
|
|
1008
1015
|
a(() => {
|
|
1009
1016
|
if (!x && !(!t?.onMutation || !e.objectName)) return t.onMutation((t) => {
|
|
1010
|
-
t.resource === e.objectName &&
|
|
1017
|
+
t.resource === e.objectName && R((e) => e + 1);
|
|
1011
1018
|
});
|
|
1012
1019
|
}, [
|
|
1013
1020
|
t,
|
|
1014
1021
|
e.objectName,
|
|
1015
1022
|
x
|
|
1016
1023
|
]);
|
|
1017
|
-
let { ref:
|
|
1024
|
+
let { ref: z, isRefreshing: B, pullDistance: V } = xe({
|
|
1018
1025
|
onRefresh: r(async () => {
|
|
1019
|
-
|
|
1026
|
+
R((e) => e + 1);
|
|
1020
1027
|
}, []),
|
|
1021
1028
|
enabled: !!t && !!e.objectName
|
|
1022
|
-
}),
|
|
1029
|
+
}), H = o(() => Ce(e), [
|
|
1023
1030
|
e.data,
|
|
1024
1031
|
e.staticData,
|
|
1025
1032
|
e.objectName
|
|
1026
|
-
]),
|
|
1033
|
+
]), U = o(() => Te(e), [
|
|
1027
1034
|
e.filter,
|
|
1028
1035
|
e.calendar,
|
|
1029
1036
|
e.dateField,
|
|
1030
1037
|
e.endField,
|
|
1031
1038
|
e.titleField,
|
|
1032
1039
|
e.colorField
|
|
1033
|
-
]),
|
|
1034
|
-
|
|
1040
|
+
]), W = H?.provider === "value", G = s(null);
|
|
1041
|
+
G.current = O, a(() => {
|
|
1035
1042
|
x && C(i);
|
|
1036
1043
|
}, [i, x]), a(() => {
|
|
1037
1044
|
x && l !== void 0 && T(l);
|
|
@@ -1041,19 +1048,19 @@ var Te = ({ schema: e, dataSource: t, className: n, data: i, loading: l, onEvent
|
|
|
1041
1048
|
return (async () => {
|
|
1042
1049
|
try {
|
|
1043
1050
|
if (!n) return;
|
|
1044
|
-
if (T(!0),
|
|
1045
|
-
n && (C(
|
|
1051
|
+
if (T(!0), W && H?.provider === "value") {
|
|
1052
|
+
n && (C(H.items), T(!1));
|
|
1046
1053
|
return;
|
|
1047
1054
|
}
|
|
1048
1055
|
if (!t || typeof t.find != "function") throw Error("DataSource required for object/api providers");
|
|
1049
|
-
if (
|
|
1050
|
-
let r =
|
|
1056
|
+
if (H?.provider === "object") {
|
|
1057
|
+
let r = H.object, i = u(G.current?.fields), a = d(await t.find(r, {
|
|
1051
1058
|
$filter: e.filter,
|
|
1052
|
-
$orderby:
|
|
1059
|
+
$orderby: we(e.sort),
|
|
1053
1060
|
...i.length > 0 ? { $expand: i } : {}
|
|
1054
1061
|
}));
|
|
1055
1062
|
n && C(a);
|
|
1056
|
-
} else
|
|
1063
|
+
} else H?.provider === "api" && (console.warn("API provider not yet implemented for ObjectCalendar"), n && C([]));
|
|
1057
1064
|
n && T(!1);
|
|
1058
1065
|
} catch (e) {
|
|
1059
1066
|
console.error("[ObjectCalendar] Error fetching data:", e), n && (D(e), T(!1));
|
|
@@ -1063,17 +1070,17 @@ var Te = ({ schema: e, dataSource: t, className: n, data: i, loading: l, onEvent
|
|
|
1063
1070
|
};
|
|
1064
1071
|
}, [
|
|
1065
1072
|
x,
|
|
1066
|
-
|
|
1073
|
+
H,
|
|
1067
1074
|
t,
|
|
1068
|
-
|
|
1075
|
+
W,
|
|
1069
1076
|
e.filter,
|
|
1070
1077
|
e.sort,
|
|
1071
|
-
|
|
1078
|
+
L
|
|
1072
1079
|
]), a(() => {
|
|
1073
|
-
!
|
|
1080
|
+
!W && t && (async () => {
|
|
1074
1081
|
try {
|
|
1075
1082
|
if (!t) return;
|
|
1076
|
-
let n =
|
|
1083
|
+
let n = H?.provider === "object" ? H.object : e.objectName;
|
|
1077
1084
|
if (!n) return;
|
|
1078
1085
|
k(await t.getObjectSchema(n));
|
|
1079
1086
|
} catch (e) {
|
|
@@ -1083,76 +1090,113 @@ var Te = ({ schema: e, dataSource: t, className: n, data: i, loading: l, onEvent
|
|
|
1083
1090
|
}, [
|
|
1084
1091
|
e.objectName,
|
|
1085
1092
|
t,
|
|
1086
|
-
|
|
1087
|
-
|
|
1093
|
+
W,
|
|
1094
|
+
H
|
|
1088
1095
|
]);
|
|
1089
|
-
let
|
|
1090
|
-
if (!
|
|
1091
|
-
let { startDateField: e, endDateField: t, titleField: n, colorField: r } =
|
|
1092
|
-
|
|
1093
|
-
|
|
1096
|
+
let K = o(() => {
|
|
1097
|
+
if (!U || !S.length) return [];
|
|
1098
|
+
let { startDateField: e, endDateField: t, titleField: n, colorField: r } = U, i = O?.titleFormat, a = O?.NAME_FIELD_KEY, o = [
|
|
1099
|
+
"name",
|
|
1100
|
+
"full_name",
|
|
1101
|
+
"fullName",
|
|
1102
|
+
"title",
|
|
1103
|
+
"subject",
|
|
1104
|
+
"label",
|
|
1105
|
+
"display_name",
|
|
1106
|
+
"displayName"
|
|
1107
|
+
], s = (e, t) => {
|
|
1108
|
+
let n = !1, r = e.replace(/\{(.+?)\}/g, (e, r) => {
|
|
1109
|
+
let i = t[r.trim()];
|
|
1110
|
+
return i != null && i !== "" ? (n = !0, String(i)) : "";
|
|
1111
|
+
}).replace(/\s+-\s+(?=$|\s*$)/, "").trim();
|
|
1112
|
+
return n ? r : "";
|
|
1113
|
+
}, c = (e) => {
|
|
1114
|
+
let t;
|
|
1115
|
+
if (n && (t = e[n], typeof t == "string" && (t = t.trim())), !t && i) {
|
|
1116
|
+
let n = s(i, e);
|
|
1117
|
+
n && (t = n);
|
|
1118
|
+
}
|
|
1119
|
+
if (!t && a) {
|
|
1120
|
+
let n = e[a];
|
|
1121
|
+
typeof n == "string" ? t = n.trim() : n && (t = n);
|
|
1122
|
+
}
|
|
1123
|
+
if (!t) for (let n of o) {
|
|
1124
|
+
let r = e[n], i = typeof r == "string" ? r.trim() : r;
|
|
1125
|
+
if (i) {
|
|
1126
|
+
t = i;
|
|
1127
|
+
break;
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
return t || "Untitled";
|
|
1131
|
+
};
|
|
1132
|
+
return S.map((n, i) => {
|
|
1133
|
+
let a = n[e], o = t ? n[t] : null, s = c(n), l = r ? n[r] : void 0;
|
|
1094
1134
|
return {
|
|
1095
|
-
id:
|
|
1096
|
-
title:
|
|
1097
|
-
start:
|
|
1098
|
-
end:
|
|
1135
|
+
id: n.id || n._id || `event-${i}`,
|
|
1136
|
+
title: s,
|
|
1137
|
+
start: a ? new Date(a) : /* @__PURE__ */ new Date(),
|
|
1138
|
+
end: o ? new Date(o) : void 0,
|
|
1099
1139
|
color: l,
|
|
1100
|
-
allDay: !
|
|
1101
|
-
data:
|
|
1140
|
+
allDay: !o,
|
|
1141
|
+
data: n
|
|
1102
1142
|
};
|
|
1103
1143
|
}).filter((e) => !isNaN(e.start.getTime()));
|
|
1104
|
-
}, [
|
|
1144
|
+
}, [
|
|
1145
|
+
S,
|
|
1146
|
+
U,
|
|
1147
|
+
O
|
|
1148
|
+
]);
|
|
1105
1149
|
r(() => {
|
|
1106
1150
|
h?.(/* @__PURE__ */ new Date());
|
|
1107
1151
|
}, [h]);
|
|
1108
|
-
let
|
|
1152
|
+
let q = f({
|
|
1109
1153
|
navigation: e.navigation,
|
|
1110
1154
|
objectName: e.objectName,
|
|
1111
1155
|
onRowClick: m
|
|
1112
1156
|
});
|
|
1113
|
-
return w ? /* @__PURE__ */ (0,
|
|
1157
|
+
return w ? /* @__PURE__ */ (0, J.jsx)("div", {
|
|
1114
1158
|
className: n,
|
|
1115
|
-
children: /* @__PURE__ */ (0,
|
|
1159
|
+
children: /* @__PURE__ */ (0, J.jsx)("div", {
|
|
1116
1160
|
className: "flex items-center justify-center h-96",
|
|
1117
|
-
children: /* @__PURE__ */ (0,
|
|
1161
|
+
children: /* @__PURE__ */ (0, J.jsx)("div", {
|
|
1118
1162
|
className: "text-muted-foreground",
|
|
1119
1163
|
children: "Loading calendar..."
|
|
1120
1164
|
})
|
|
1121
1165
|
})
|
|
1122
|
-
}) : E ? /* @__PURE__ */ (0,
|
|
1166
|
+
}) : E ? /* @__PURE__ */ (0, J.jsx)("div", {
|
|
1123
1167
|
className: n,
|
|
1124
|
-
children: /* @__PURE__ */ (0,
|
|
1168
|
+
children: /* @__PURE__ */ (0, J.jsx)("div", {
|
|
1125
1169
|
className: "flex items-center justify-center h-96",
|
|
1126
|
-
children: /* @__PURE__ */ (0,
|
|
1170
|
+
children: /* @__PURE__ */ (0, J.jsxs)("div", {
|
|
1127
1171
|
className: "text-destructive",
|
|
1128
1172
|
children: ["Error: ", E.message]
|
|
1129
1173
|
})
|
|
1130
1174
|
})
|
|
1131
|
-
}) :
|
|
1132
|
-
ref:
|
|
1175
|
+
}) : U ? /* @__PURE__ */ (0, J.jsxs)("div", {
|
|
1176
|
+
ref: z,
|
|
1133
1177
|
className: n,
|
|
1134
1178
|
children: [
|
|
1135
|
-
|
|
1179
|
+
V > 0 && /* @__PURE__ */ (0, J.jsx)("div", {
|
|
1136
1180
|
className: "flex items-center justify-center text-xs text-muted-foreground",
|
|
1137
|
-
style: { height:
|
|
1138
|
-
children:
|
|
1181
|
+
style: { height: V },
|
|
1182
|
+
children: B ? "Refreshing…" : "Pull to refresh"
|
|
1139
1183
|
}),
|
|
1140
|
-
/* @__PURE__ */ (0,
|
|
1184
|
+
/* @__PURE__ */ (0, J.jsx)("div", {
|
|
1141
1185
|
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]",
|
|
1142
|
-
children: /* @__PURE__ */ (0,
|
|
1143
|
-
events:
|
|
1144
|
-
currentDate:
|
|
1145
|
-
view:
|
|
1186
|
+
children: /* @__PURE__ */ (0, J.jsx)(Q, {
|
|
1187
|
+
events: K,
|
|
1188
|
+
currentDate: j,
|
|
1189
|
+
view: F,
|
|
1146
1190
|
locale: y,
|
|
1147
1191
|
onEventClick: (e) => {
|
|
1148
|
-
|
|
1192
|
+
q.handleClick(e.data), p?.(e.data);
|
|
1149
1193
|
},
|
|
1150
1194
|
onDateClick: h,
|
|
1151
1195
|
onNavigate: (e) => {
|
|
1152
|
-
|
|
1196
|
+
M(e), g?.(e);
|
|
1153
1197
|
},
|
|
1154
1198
|
onViewChange: (e) => {
|
|
1155
|
-
|
|
1199
|
+
I(e), _?.(e);
|
|
1156
1200
|
},
|
|
1157
1201
|
onAddClick: void 0,
|
|
1158
1202
|
onEventDrop: v ? (e, t, n) => {
|
|
@@ -1160,17 +1204,17 @@ var Te = ({ schema: e, dataSource: t, className: n, data: i, loading: l, onEvent
|
|
|
1160
1204
|
} : void 0
|
|
1161
1205
|
})
|
|
1162
1206
|
}),
|
|
1163
|
-
|
|
1164
|
-
...
|
|
1207
|
+
q.isOverlay && /* @__PURE__ */ (0, J.jsx)(b, {
|
|
1208
|
+
...q,
|
|
1165
1209
|
title: "Event Details",
|
|
1166
|
-
children: (e) => /* @__PURE__ */ (0,
|
|
1210
|
+
children: (e) => /* @__PURE__ */ (0, J.jsx)("div", {
|
|
1167
1211
|
className: "space-y-3",
|
|
1168
|
-
children: Object.entries(e).map(([e, t]) => /* @__PURE__ */ (0,
|
|
1212
|
+
children: Object.entries(e).map(([e, t]) => /* @__PURE__ */ (0, J.jsxs)("div", {
|
|
1169
1213
|
className: "flex flex-col",
|
|
1170
|
-
children: [/* @__PURE__ */ (0,
|
|
1214
|
+
children: [/* @__PURE__ */ (0, J.jsx)("span", {
|
|
1171
1215
|
className: "text-xs font-medium text-muted-foreground uppercase tracking-wide",
|
|
1172
1216
|
children: e.replace(/_/g, " ")
|
|
1173
|
-
}), /* @__PURE__ */ (0,
|
|
1217
|
+
}), /* @__PURE__ */ (0, J.jsx)("span", {
|
|
1174
1218
|
className: "text-sm",
|
|
1175
1219
|
children: String(t ?? "—")
|
|
1176
1220
|
})]
|
|
@@ -1178,11 +1222,11 @@ var Te = ({ schema: e, dataSource: t, className: n, data: i, loading: l, onEvent
|
|
|
1178
1222
|
})
|
|
1179
1223
|
})
|
|
1180
1224
|
]
|
|
1181
|
-
}) : /* @__PURE__ */ (0,
|
|
1225
|
+
}) : /* @__PURE__ */ (0, J.jsx)("div", {
|
|
1182
1226
|
className: n,
|
|
1183
|
-
children: /* @__PURE__ */ (0,
|
|
1227
|
+
children: /* @__PURE__ */ (0, J.jsx)("div", {
|
|
1184
1228
|
className: "flex items-center justify-center h-96",
|
|
1185
|
-
children: /* @__PURE__ */ (0,
|
|
1229
|
+
children: /* @__PURE__ */ (0, J.jsx)("div", {
|
|
1186
1230
|
className: "text-muted-foreground",
|
|
1187
1231
|
children: "Calendar configuration required. Please specify startDateField and titleField."
|
|
1188
1232
|
})
|
|
@@ -1211,7 +1255,7 @@ l.register("calendar-view", ({ schema: e, className: n, onAction: r, ...i }) =>
|
|
|
1211
1255
|
e.colorField,
|
|
1212
1256
|
e.allDayField
|
|
1213
1257
|
]);
|
|
1214
|
-
return /* @__PURE__ */ (0,
|
|
1258
|
+
return /* @__PURE__ */ (0, J.jsx)(Q, {
|
|
1215
1259
|
className: n,
|
|
1216
1260
|
events: a,
|
|
1217
1261
|
onEventClick: (e) => {
|
|
@@ -1344,7 +1388,7 @@ l.register("calendar-view", ({ schema: e, className: n, onAction: r, ...i }) =>
|
|
|
1344
1388
|
//#region src/index.tsx
|
|
1345
1389
|
var $ = ({ schema: e, ...t }) => {
|
|
1346
1390
|
let { dataSource: n } = p() || {};
|
|
1347
|
-
return /* @__PURE__ */ (0,
|
|
1391
|
+
return /* @__PURE__ */ (0, J.jsx)(Ee, {
|
|
1348
1392
|
schema: e,
|
|
1349
1393
|
dataSource: n,
|
|
1350
1394
|
...t
|
|
@@ -1382,4 +1426,4 @@ l.register("object-calendar", $, {
|
|
|
1382
1426
|
}]
|
|
1383
1427
|
});
|
|
1384
1428
|
//#endregion
|
|
1385
|
-
export {
|
|
1429
|
+
export { Q as CalendarView, Ee as ObjectCalendar, $ as ObjectCalendarRenderer };
|
package/dist/index.umd.cjs
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,o,p,m,p),L[p+o]=!0)}if(p=null,i!==void 0&&(r(i),p=``+i),s(n)&&(r(n.key),p=``+n.key),`key`in n)for(var h in i={},n)h!==`key`&&(i[h]=n[h]);else i=n;return p&&c(i,typeof e==`function`?e.displayName||e.name||`Unknown`:e),u(e,p,i,a(),l,d)}function f(e){p(e)?e._store&&(e._store.validated=1):typeof e==`object`&&e&&e.$$typeof===E&&(e._payload.status===`fulfilled`?p(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function p(e){return typeof e==`object`&&!!e&&e.$$typeof===h}var m=require(`react`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.client.reference`),k=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=Object.prototype.hasOwnProperty,j=Array.isArray,M=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(e){return e()}};var N,P={},F=m.react_stack_bottom_frame.bind(m,o)(),I=M(i(o)),L={};e.Fragment=_,e.jsx=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!1,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)},e.jsxs=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!0,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)}})()})),H=f(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=B():t.exports=V()}))(),U=`bg-blue-500 text-white`,W=new Date,G={"calendar.today":`Today`,"calendar.month":`Month`,"calendar.week":`Week`,"calendar.day":`Day`,"calendar.newEvent":`New event`,"calendar.moreEvents":`+{{count}} more`};function K(){try{let e=z();return e.t(`calendar.today`)===`calendar.today`?{t:(e,t)=>{let n=G[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n},language:`en`}:{t:e.t,language:e.language}}catch{return{t:(e,t)=>{let n=G[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n},language:`en`}}}function q({events:e=[],view:n=`month`,currentDate:r=W,locale:o=`default`,onEventClick:s,onDateClick:c,onViewChange:l,onNavigate:u,onAddClick:d,onEventDrop:f,className:p}){let[m,h]=t.useState(n),[g,_]=t.useState(r),{t:v,language:y}=K(),b=o===`default`?y:o;t.useEffect(()=>{_(r)},[r]),t.useEffect(()=>{h(n)},[n]);let x=t.useRef(l);x.current=l,t.useEffect(()=>{let e=window.matchMedia(`(max-width: 639px)`),t=e=>{e.matches&&(h(`day`),x.current?.(`day`))};return t(e),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let S=()=>{let e=new Date(g);m===`month`?e.setMonth(e.getMonth()-1):m===`week`?e.setDate(e.getDate()-7):e.setDate(e.getDate()-1),_(e),u?.(e)},C=()=>{let e=new Date(g);m===`month`?e.setMonth(e.getMonth()+1):m===`week`?e.setDate(e.getDate()+7):e.setDate(e.getDate()+1),_(e),u?.(e)},w=()=>{let e=new Date;_(e),u?.(e)},T=e=>{h(e),l?.(e)},E=()=>{if(m===`month`)return g.toLocaleDateString(b,{month:`long`,year:`numeric`});if(m===`week`){let e=J(g),t=new Date(e);return t.setDate(t.getDate()+6),`${e.toLocaleDateString(b,{month:`short`,day:`numeric`})} - ${t.toLocaleDateString(b,{month:`short`,day:`numeric`,year:`numeric`})}`}else return g.toLocaleDateString(b,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})},D=t.useRef(0);return(0,H.jsxs)(`div`,{role:`region`,"aria-label":`Calendar`,className:(0,a.cn)(`flex flex-col h-full bg-background min-w-0 overflow-hidden`,p),children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 p-2 sm:p-4 border-b min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center bg-muted/50 rounded-lg p-1 gap-1`,children:[(0,H.jsx)(a.Button,{variant:`ghost`,size:`sm`,onClick:w,className:`h-8`,"aria-label":`Go to today`,children:v(`calendar.today`)}),(0,H.jsx)(`div`,{className:`h-4 w-px bg-border mx-1`}),(0,H.jsx)(a.Button,{variant:`ghost`,size:`icon`,"aria-label":`Previous period`,onClick:S,className:`h-8 w-8`,children:(0,H.jsx)(i.ChevronLeftIcon,{className:`h-4 w-4`})}),(0,H.jsx)(a.Button,{variant:`ghost`,size:`icon`,"aria-label":`Next period`,onClick:C,className:`h-8 w-8`,children:(0,H.jsx)(i.ChevronRightIcon,{className:`h-4 w-4`})})]}),(0,H.jsxs)(a.Popover,{children:[(0,H.jsx)(a.PopoverTrigger,{asChild:!0,children:(0,H.jsxs)(a.Button,{variant:`ghost`,"aria-label":`Current date: ${E()}`,className:(0,a.cn)(`text-base sm:text-xl font-semibold h-auto px-2 sm:px-3 py-1 hover:bg-muted/50 transition-colors`,`flex items-center gap-2`),children:[(0,H.jsx)(i.CalendarIcon,{className:`h-5 w-5 text-muted-foreground`}),(0,H.jsx)(`span`,{children:E()})]})}),(0,H.jsx)(a.PopoverContent,{className:`w-auto p-0`,align:`start`,children:(0,H.jsx)(a.Calendar,{mode:`single`,selected:g,onSelect:e=>{e&&(_(e),u?.(e))},initialFocus:!0,fromYear:2e3,toYear:2050})})]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(a.Select,{value:m,onValueChange:T,children:[(0,H.jsx)(a.SelectTrigger,{className:`w-32 bg-background`,children:(0,H.jsx)(a.SelectValue,{})}),(0,H.jsxs)(a.SelectContent,{children:[(0,H.jsx)(a.SelectItem,{value:`day`,children:v(`calendar.day`)}),(0,H.jsx)(a.SelectItem,{value:`week`,children:v(`calendar.week`)}),(0,H.jsx)(a.SelectItem,{value:`month`,children:v(`calendar.month`)})]})]}),d&&(0,H.jsxs)(a.Button,{onClick:d,size:`sm`,className:`gap-1`,children:[(0,H.jsx)(i.PlusIcon,{className:`h-4 w-4`}),v(`calendar.newEvent`)]})]})]}),(0,H.jsxs)(`div`,{className:`flex-1 overflow-auto`,onTouchStart:e=>{D.current=e.touches[0].clientX},onTouchEnd:e=>{let t=D.current-e.changedTouches[0].clientX;if(Math.abs(t)>50){let e=new Date(g);m===`day`?e.setDate(e.getDate()+(t>0?1:-1)):m===`week`?e.setDate(e.getDate()+(t>0?7:-7)):e.setMonth(e.getMonth()+(t>0?1:-1)),_(e),u?.(e)}},children:[m===`month`&&(0,H.jsx)(ee,{date:g,events:e,locale:b,onEventClick:s,onDateClick:c,onEventDrop:f}),m===`week`&&(0,H.jsx)(te,{date:g,events:e,locale:b,onEventClick:s,onDateClick:c}),m===`day`&&(0,H.jsx)(ne,{date:g,events:e,onEventClick:s,onDateClick:c})]})]})}function J(e){let t=new Date(e),n=t.getDay(),r=t.getDate()-n;return t.setDate(r),t}function Y(e){let t=e.getFullYear(),n=e.getMonth(),r=new Date(t,n,1),i=new Date(t,n+1,0),a=r.getDay(),o=[];for(let e=a-1;e>=0;e--){let t=new Date(r.getTime());t.setDate(t.getDate()-(e+1)),o.push(t)}for(let e=1;e<=i.getDate();e++)o.push(new Date(t,n,e));let s=42-o.length;for(let e=1;e<=s;e++){let t=new Date(i.getTime());t.setDate(t.getDate()+e),o.push(t)}return o}function X(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function Z(e,t){return t.filter(t=>{let n=new Date(t.start),r=t.end?new Date(t.end):new Date(n),i=new Date(e);i.setHours(0,0,0,0);let a=new Date(e);a.setHours(23,59,59,999);let o=new Date(n);o.setHours(0,0,0,0);let s=new Date(r);return s.setHours(23,59,59,999),i<=s&&a>=o})}function ee({date:e,events:n,locale:r=`default`,onEventClick:i,onDateClick:o,onEventDrop:s}){let c=t.useMemo(()=>Y(e),[e.getFullYear(),e.getMonth()]),l=t.useMemo(()=>new Date,[]),{t:u}=K(),d=t.useMemo(()=>{let e=new Date(2024,0,7);return Array.from({length:7},(t,n)=>{let i=new Date(e);return i.setDate(i.getDate()+n),i.toLocaleDateString(r,{weekday:`short`})})},[r]),[f,p]=t.useState(null),[m,h]=t.useState(null),g=t.useMemo(()=>{let e=new Map;for(let t of n){let n=new Date(t.start),r=t.end?new Date(t.end):new Date(n);n.setHours(0,0,0,0),r.setHours(0,0,0,0);let i=new Date(n);for(;i<=r;){let n=`${i.getFullYear()}-${i.getMonth()}-${i.getDate()}`,r=e.get(n);r?r.push(t):e.set(n,[t]),i.setDate(i.getDate()+1)}}return e},[n]),_=(e,t)=>{p(t.id),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,String(t.id))},v=()=>{p(null),h(null)},y=(e,t)=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`,h(t)},b=e=>{e.currentTarget.contains(e.relatedTarget)||h(null)},x=(e,t)=>{if(e.preventDefault(),h(null),p(null),!s)return;let r=e.dataTransfer.getData(`text/plain`),i=n.find(e=>String(e.id)===r);if(!i)return;let a=new Date(i.start),o=new Date(a);o.setHours(0,0,0,0);let c=new Date(t);c.setHours(0,0,0,0);let l=c.getTime()-o.getTime();if(l===0)return;let u=new Date(a.getTime()+l),d;i.end&&(d=new Date(new Date(i.end).getTime()+l)),s(i,u,d)};return(0,H.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,H.jsx)(`div`,{role:`row`,className:`grid grid-cols-7 border-b`,children:d.map(e=>(0,H.jsx)(`div`,{role:`columnheader`,className:`p-2 text-center text-sm font-medium text-muted-foreground border-r last:border-r-0`,children:e},e))}),(0,H.jsx)(`div`,{role:`grid`,"aria-label":`Calendar grid`,className:`grid grid-cols-7 flex-1 auto-rows-fr`,children:c.map((t,n)=>{let r=`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`,c=g.get(r)||[],d=t.getMonth()===e.getMonth(),p=X(t,l);return(0,H.jsxs)(`div`,{role:`gridcell`,"aria-label":`${t.toLocaleDateString(`default`,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})}${c.length>0?`, ${c.length} event${c.length>1?`s`:``}`:``}`,className:(0,a.cn)(`border-b border-r last:border-r-0 p-2 min-h-[100px] cursor-pointer hover:bg-accent/50`,!d&&`bg-muted/50 text-muted-foreground opacity-50`,m===n&&`ring-2 ring-primary`),onClick:()=>o?.(t),onDragOver:e=>y(e,n),onDragLeave:b,onDrop:e=>x(e,t),children:[(0,H.jsx)(`div`,{className:(0,a.cn)(`text-sm font-medium mb-2`,p&&`inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-6 w-6`),...p?{"aria-current":`date`}:{},children:t.getDate()}),(0,H.jsxs)(`div`,{className:`space-y-1`,children:[c.slice(0,3).map(e=>(0,H.jsx)(`div`,{role:`button`,title:e.title,"aria-label":e.title,draggable:!!s,onDragStart:t=>_(t,e),onDragEnd:v,className:(0,a.cn)(`text-xs px-2 py-1 rounded truncate cursor-pointer hover:opacity-80`,e.color?.startsWith(`#`)?`text-white`:e.color||U,f===e.id&&`opacity-50`),style:e.color&&e.color.startsWith(`#`)?{backgroundColor:e.color}:void 0,onClick:t=>{t.stopPropagation(),i?.(e)},children:e.title},e.id)),c.length>3&&(0,H.jsx)(`div`,{className:`text-xs text-muted-foreground px-2`,children:u(`calendar.moreEvents`,{count:c.length-3})})]})]},n)})})]})}function te({date:e,events:n,locale:r=`default`,onEventClick:i,onDateClick:o}){let s=t.useRef(null),c=e=>{o&&(s.current=setTimeout(()=>{o(e)},500))},l=()=>{s.current&&=(clearTimeout(s.current),null)},u=J(e),d=Array.from({length:7},(e,t)=>{let n=new Date(u);return n.setDate(n.getDate()+t),n}),f=new Date;return(0,H.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,H.jsx)(`div`,{className:`grid grid-cols-7 border-b`,children:d.map(e=>{let t=X(e,f);return(0,H.jsxs)(`div`,{className:`p-3 text-center border-r last:border-r-0`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-muted-foreground`,children:e.toLocaleDateString(r,{weekday:`short`})}),(0,H.jsx)(`div`,{className:(0,a.cn)(`text-lg font-semibold mt-1`,t&&`inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-8 w-8`),children:e.getDate()})]},e.toISOString())})}),(0,H.jsx)(`div`,{role:`grid`,className:`grid grid-cols-7 flex-1`,children:d.map(e=>{let t=Z(e,n);return(0,H.jsx)(`div`,{role:`gridcell`,"aria-label":`${e.toLocaleDateString(`default`,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})}${t.length>0?`, ${t.length} event${t.length>1?`s`:``}`:``}`,className:`border-r last:border-r-0 p-2 min-h-[400px] cursor-pointer hover:bg-accent/50`,onClick:()=>o?.(e),onTouchStart:()=>c(e),onTouchEnd:l,children:(0,H.jsx)(`div`,{className:`space-y-2`,children:t.map(e=>(0,H.jsxs)(`div`,{role:`button`,title:e.title,"aria-label":e.title,className:(0,a.cn)(`text-xs sm:text-sm px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80`,e.color?.startsWith(`#`)?`text-white`:e.color||U),style:e.color&&e.color.startsWith(`#`)?{backgroundColor:e.color}:void 0,onClick:t=>{t.stopPropagation(),i?.(e)},children:[(0,H.jsx)(`div`,{className:`font-medium truncate`,children:e.title}),!e.allDay&&(0,H.jsx)(`div`,{className:`text-xs opacity-90 mt-1`,children:e.start.toLocaleTimeString(`default`,{hour:`numeric`,minute:`2-digit`})})]},e.id))})},e.toISOString())})})]})}function ne({date:e,events:n,onEventClick:r,onDateClick:i}){let o=Z(e,n),s=Array.from({length:24},(e,t)=>t),c=t.useRef(null),l=t=>{i&&(c.current=setTimeout(()=>{let n=new Date(e);n.setHours(t,0,0,0),i(n)},500))},u=()=>{c.current&&=(clearTimeout(c.current),null)};return(0,H.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,H.jsx)(`div`,{role:`list`,className:`flex-1 overflow-auto`,children:s.map(e=>{let t=o.filter(t=>t.allDay?e===0:t.start.getHours()===e);return(0,H.jsxs)(`div`,{role:`listitem`,className:`flex border-b min-h-[60px]`,children:[(0,H.jsx)(`div`,{className:`w-20 p-2 text-sm text-muted-foreground border-r`,children:e===0?`12 AM`:e<12?`${e} AM`:e===12?`12 PM`:`${e-12} PM`}),(0,H.jsx)(`div`,{className:`flex-1 p-2 space-y-2`,onTouchStart:()=>l(e),onTouchEnd:u,children:t.map(e=>(0,H.jsxs)(`div`,{title:e.title,"aria-label":e.title,className:(0,a.cn)(`px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80`,e.color?.startsWith(`#`)?`text-white`:e.color||U),style:e.color&&e.color.startsWith(`#`)?{backgroundColor:e.color}:void 0,onClick:()=>r?.(e),children:[(0,H.jsx)(`div`,{className:`font-medium truncate`,children:e.title}),!e.allDay&&(0,H.jsxs)(`div`,{className:`text-xs opacity-90 mt-1`,children:[e.start.toLocaleTimeString(`default`,{hour:`numeric`,minute:`2-digit`}),e.end&&` - ${e.end.toLocaleTimeString(`default`,{hour:`numeric`,minute:`2-digit`})}`]})]},e.id))})]},e)})})})}function re(e){let{onRefresh:n,threshold:r=80,enabled:i=!0}=e,a=(0,t.useRef)(null),[o,s]=(0,t.useState)(!1),[c,l]=(0,t.useState)(0),u=(0,t.useRef)(0),d=(0,t.useCallback)(e=>{if(!i||o)return;let t=a.current;t&&t.scrollTop===0&&(u.current=e.touches[0].clientY)},[i,o]),f=(0,t.useCallback)(e=>{if(!i||o||!u.current)return;let t=e.touches[0].clientY-u.current;t>0&&l(Math.min(t,r*1.5))},[i,o,r]),p=(0,t.useCallback)(async()=>{if(!i||o)return;let e=c;if(l(0),u.current=0,e>=r){s(!0);try{await n()}finally{s(!1)}}},[i,o,c,r,n]);return(0,t.useEffect)(()=>{let e=a.current;if(!(!e||!i))return e.addEventListener(`touchstart`,d,{passive:!0}),e.addEventListener(`touchmove`,f,{passive:!0}),e.addEventListener(`touchend`,p,{passive:!0}),()=>{e.removeEventListener(`touchstart`,d),e.removeEventListener(`touchmove`,f),e.removeEventListener(`touchend`,p)}},[d,f,p,i]),{ref:a,isRefreshing:o,pullDistance:c}}var ie=(0,t.createContext)(null);ie.displayName=`MobileContext`;function ae(e){return`data`in e&&e.data?e.data:`staticData`in e&&e.staticData?{provider:`value`,items:e.staticData}:e.objectName?{provider:`object`,object:e.objectName}:null}function oe(e){if(e){if(typeof e==`string`){let t=e.split(` `),n=t[0],r=t[1]?.toLowerCase()===`desc`?`desc`:`asc`;return{[n]:r}}if(Array.isArray(e))return e.reduce((e,t)=>(t.field&&t.order&&(e[t.field]=t.order),e),{})}}function se(e){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?{startDateField:e.startDateField||e.dateField,endDateField:e.endDateField||e.endField,titleField:e.titleField||`name`,colorField:e.colorField,allDayField:e.allDayField}:null}var Q=({schema:e,dataSource:i,className:o,data:s,loading:c,onEventClick:l,onRowClick:u,onDateClick:d,onNavigate:f,onViewChange:p,onEventDrop:m,locale:h})=>{let g=Array.isArray(s),[_,v]=(0,t.useState)(g?s:[]),[y,b]=(0,t.useState)(g?c??!1:!0),[x,S]=(0,t.useState)(null),[C,w]=(0,t.useState)(null),[T,E]=(0,t.useState)(new Date),[D,O]=(0,t.useState)(`month`),[k,A]=(0,t.useState)(0);(0,t.useEffect)(()=>{if(!g&&!(!i?.onMutation||!e.objectName))return i.onMutation(t=>{t.resource===e.objectName&&A(e=>e+1)})},[i,e.objectName,g]);let{ref:j,isRefreshing:M,pullDistance:N}=re({onRefresh:(0,t.useCallback)(async()=>{A(e=>e+1)},[]),enabled:!!i&&!!e.objectName}),P=(0,t.useMemo)(()=>ae(e),[e.data,e.staticData,e.objectName]),F=(0,t.useMemo)(()=>se(e),[e.filter,e.calendar,e.dateField,e.endField,e.titleField,e.colorField]),I=P?.provider===`value`,L=(0,t.useRef)(null);L.current=C,(0,t.useEffect)(()=>{g&&v(s)},[s,g]),(0,t.useEffect)(()=>{g&&c!==void 0&&b(c)},[c,g]),(0,t.useEffect)(()=>{if(g)return;let t=!0;return(async()=>{try{if(!t)return;if(b(!0),I&&P?.provider===`value`){t&&(v(P.items),b(!1));return}if(!i||typeof i.find!=`function`)throw Error(`DataSource required for object/api providers`);if(P?.provider===`object`){let r=P.object,a=(0,n.buildExpandFields)(L.current?.fields),o=(0,n.extractRecords)(await i.find(r,{$filter:e.filter,$orderby:oe(e.sort),...a.length>0?{$expand:a}:{}}));t&&v(o)}else P?.provider===`api`&&(console.warn(`API provider not yet implemented for ObjectCalendar`),t&&v([]));t&&b(!1)}catch(e){console.error(`[ObjectCalendar] Error fetching data:`,e),t&&(S(e),b(!1))}})(),()=>{t=!1}},[g,P,i,I,e.filter,e.sort,k]),(0,t.useEffect)(()=>{!I&&i&&(async()=>{try{if(!i)return;let t=P?.provider===`object`?P.object:e.objectName;if(!t)return;w(await i.getObjectSchema(t))}catch(e){console.error(`Failed to fetch object schema:`,e)}})()},[e.objectName,i,I,P]);let R=(0,t.useMemo)(()=>{if(!F||!_.length)return[];let{startDateField:e,endDateField:t,titleField:n,colorField:r}=F;return _.map((i,a)=>{let o=i[e],s=t?i[t]:null,c=i[n]||`Untitled`,l=r?i[r]:void 0;return{id:i.id||i._id||`event-${a}`,title:c,start:o?new Date(o):new Date,end:s?new Date(s):void 0,color:l,allDay:!s,data:i}}).filter(e=>!isNaN(e.start.getTime()))},[_,F]);(0,t.useCallback)(()=>{d?.(new Date)},[d]);let z=(0,r.useNavigationOverlay)({navigation:e.navigation,objectName:e.objectName,onRowClick:u});return y?(0,H.jsx)(`div`,{className:o,children:(0,H.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,H.jsx)(`div`,{className:`text-muted-foreground`,children:`Loading calendar...`})})}):x?(0,H.jsx)(`div`,{className:o,children:(0,H.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,H.jsxs)(`div`,{className:`text-destructive`,children:[`Error: `,x.message]})})}):F?(0,H.jsxs)(`div`,{ref:j,className:o,children:[N>0&&(0,H.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:N},children:M?`Refreshing…`:`Pull to refresh`}),(0,H.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:(0,H.jsx)(q,{events:R,currentDate:T,view:e.defaultView||`month`,locale:h,onEventClick:e=>{z.handleClick(e.data),l?.(e.data)},onDateClick:d,onNavigate:e=>{E(e),f?.(e)},onViewChange:e=>{O(e),p?.(e)},onAddClick:void 0,onEventDrop:m?(e,t,n)=>{m(e.data,t,n)}:void 0})}),z.isOverlay&&(0,H.jsx)(a.NavigationOverlay,{...z,title:`Event Details`,children:e=>(0,H.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,H.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]}):(0,H.jsx)(`div`,{className:o,children:(0,H.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,H.jsx)(`div`,{className:`text-muted-foreground`,children:`Calendar configuration required. Please specify startDateField and titleField.`})})})};n.ComponentRegistry.register(`calendar-view`,({schema:e,className:n,onAction:r,...i})=>{let a=t.default.useMemo(()=>!e.data||!Array.isArray(e.data)?[]:e.data.map((t,n)=>{let r=e.titleField||`title`,i=e.startDateField||`start`,a=e.endDateField||`end`,o=e.colorField||`color`,s=e.allDayField||`allDay`;return{id:t.id||t._id||n,title:t[r]||`Untitled Event`,start:new Date(t[i]),end:t[a]?new Date(t[a]):void 0,allDay:t[s],color:t[o],data:t}}),[e.data,e.titleField,e.startDateField,e.endDateField,e.colorField,e.allDayField]);return(0,H.jsx)(q,{className:n,events:a,onEventClick:e=>{r?.({type:`event-click`,payload:e})},...i})},{namespace:`plugin-calendar`,label:`Calendar View`,inputs:[{name:`data`,type:`array`,label:`Data`,description:`Array of record objects to display as events`},{name:`titleField`,type:`string`,label:`Title Field`,defaultValue:`title`,description:`Field name to use for event title`},{name:`startDateField`,type:`string`,label:`Start Date Field`,defaultValue:`start`,description:`Field name for event start date`},{name:`endDateField`,type:`string`,label:`End Date Field`,defaultValue:`end`,description:`Field name for event end date (optional)`},{name:`allDayField`,type:`string`,label:`All Day Field`,defaultValue:`allDay`,description:`Field name for all-day flag`},{name:`colorField`,type:`string`,label:`Color Field`,defaultValue:`color`,description:`Field name for event color`},{name:`colorMapping`,type:`object`,label:`Color Mapping`,description:`Map field values to colors (e.g., {meeting: "blue", deadline: "red"})`},{name:`view`,type:`enum`,enum:[`month`,`week`,`day`],defaultValue:`month`,label:`View Mode`,description:`Calendar view mode (month, week, or day)`},{name:`currentDate`,type:`string`,label:`Current Date`,description:`ISO date string for initial calendar date`},{name:`allowCreate`,type:`boolean`,label:`Allow Create`,defaultValue:!1,description:`Allow creating events by clicking on dates`},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{view:`month`,titleField:`title`,startDateField:`start`,endDateField:`end`,allDayField:`allDay`,colorField:`color`,allowCreate:!1,data:[{id:1,title:`Team Meeting`,start:new Date(new Date().setHours(10,0,0,0)).toISOString(),end:new Date(new Date().setHours(11,0,0,0)).toISOString(),color:`#3b82f6`,allDay:!1},{id:2,title:`Project Deadline`,start:new Date(new Date().setDate(new Date().getDate()+3)).toISOString(),color:`#ef4444`,allDay:!0},{id:3,title:`Conference`,start:new Date(new Date().setDate(new Date().getDate()+7)).toISOString(),end:new Date(new Date().setDate(new Date().getDate()+9)).toISOString(),color:`#10b981`,allDay:!0}],className:`h-[600px] border rounded-lg`}});var $=({schema:e,...t})=>{let{dataSource:n}=(0,r.useSchemaContext)()||{};return(0,H.jsx)(Q,{schema:e,dataSource:n,...t})};n.ComponentRegistry.register(`object-calendar`,$,{namespace:`plugin-calendar`,label:`Object Calendar`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`calendar`,type:`object`,label:`Calendar Config`,description:`startDateField, endDateField, titleField, colorField`}]}),n.ComponentRegistry.register(`calendar`,$,{namespace:`view`,label:`Calendar View`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`calendar`,type:`object`,label:`Calendar Config`,description:`startDateField, endDateField, titleField, colorField`}]}),e.CalendarView=q,e.ObjectCalendar=Q,e.ObjectCalendarRenderer=$});
|
|
6
|
+
<%s key={someKey} {...props} />`,o,p,m,p),L[p+o]=!0)}if(p=null,i!==void 0&&(r(i),p=``+i),s(n)&&(r(n.key),p=``+n.key),`key`in n)for(var h in i={},n)h!==`key`&&(i[h]=n[h]);else i=n;return p&&c(i,typeof e==`function`?e.displayName||e.name||`Unknown`:e),u(e,p,i,a(),l,d)}function f(e){p(e)?e._store&&(e._store.validated=1):typeof e==`object`&&e&&e.$$typeof===E&&(e._payload.status===`fulfilled`?p(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function p(e){return typeof e==`object`&&!!e&&e.$$typeof===h}var m=require(`react`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.client.reference`),k=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=Object.prototype.hasOwnProperty,j=Array.isArray,M=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(e){return e()}};var N,P={},F=m.react_stack_bottom_frame.bind(m,o)(),I=M(i(o)),L={};e.Fragment=_,e.jsx=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!1,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)},e.jsxs=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!0,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)}})()})),H=f(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=B():t.exports=V()}))(),U=`bg-blue-500 text-white`,W=new Date,G={"calendar.today":`Today`,"calendar.month":`Month`,"calendar.week":`Week`,"calendar.day":`Day`,"calendar.newEvent":`New event`,"calendar.moreEvents":`+{{count}} more`};function K(){try{let e=z();return e.t(`calendar.today`)===`calendar.today`?{t:(e,t)=>{let n=G[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n},language:`en`}:{t:e.t,language:e.language}}catch{return{t:(e,t)=>{let n=G[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n},language:`en`}}}function q({events:e=[],view:n=`month`,currentDate:r=W,locale:o=`default`,onEventClick:s,onDateClick:c,onViewChange:l,onNavigate:u,onAddClick:d,onEventDrop:f,className:p}){let[m,h]=t.useState(n),[g,_]=t.useState(r),{t:v,language:y}=K(),b=o===`default`?y:o;t.useEffect(()=>{_(r)},[r]),t.useEffect(()=>{h(n)},[n]);let x=t.useRef(l);x.current=l,t.useEffect(()=>{let e=window.matchMedia(`(max-width: 639px)`),t=e=>{e.matches&&(h(`day`),x.current?.(`day`))};return t(e),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let S=()=>{let e=new Date(g);m===`month`?e.setMonth(e.getMonth()-1):m===`week`?e.setDate(e.getDate()-7):e.setDate(e.getDate()-1),_(e),u?.(e)},C=()=>{let e=new Date(g);m===`month`?e.setMonth(e.getMonth()+1):m===`week`?e.setDate(e.getDate()+7):e.setDate(e.getDate()+1),_(e),u?.(e)},w=()=>{let e=new Date;_(e),u?.(e)},T=e=>{h(e),l?.(e)},E=()=>{if(m===`month`)return g.toLocaleDateString(b,{month:`long`,year:`numeric`});if(m===`week`){let e=J(g),t=new Date(e);return t.setDate(t.getDate()+6),`${e.toLocaleDateString(b,{month:`short`,day:`numeric`})} - ${t.toLocaleDateString(b,{month:`short`,day:`numeric`,year:`numeric`})}`}else return g.toLocaleDateString(b,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})},D=t.useRef(0);return(0,H.jsxs)(`div`,{role:`region`,"aria-label":`Calendar`,className:(0,a.cn)(`flex flex-col h-full bg-background min-w-0 overflow-hidden`,p),children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 p-2 sm:p-4 border-b min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center bg-muted/50 rounded-lg p-1 gap-1`,children:[(0,H.jsx)(a.Button,{variant:`ghost`,size:`sm`,onClick:w,className:`h-8`,"aria-label":`Go to today`,children:v(`calendar.today`)}),(0,H.jsx)(`div`,{className:`h-4 w-px bg-border mx-1`}),(0,H.jsx)(a.Button,{variant:`ghost`,size:`icon`,"aria-label":`Previous period`,onClick:S,className:`h-8 w-8`,children:(0,H.jsx)(i.ChevronLeftIcon,{className:`h-4 w-4`})}),(0,H.jsx)(a.Button,{variant:`ghost`,size:`icon`,"aria-label":`Next period`,onClick:C,className:`h-8 w-8`,children:(0,H.jsx)(i.ChevronRightIcon,{className:`h-4 w-4`})})]}),(0,H.jsxs)(a.Popover,{children:[(0,H.jsx)(a.PopoverTrigger,{asChild:!0,children:(0,H.jsxs)(a.Button,{variant:`ghost`,"aria-label":`Current date: ${E()}`,className:(0,a.cn)(`text-base sm:text-xl font-semibold h-auto px-2 sm:px-3 py-1 hover:bg-muted/50 transition-colors`,`flex items-center gap-2`),children:[(0,H.jsx)(i.CalendarIcon,{className:`h-5 w-5 text-muted-foreground`}),(0,H.jsx)(`span`,{children:E()})]})}),(0,H.jsx)(a.PopoverContent,{className:`w-auto p-0`,align:`start`,children:(0,H.jsx)(a.Calendar,{mode:`single`,selected:g,onSelect:e=>{e&&(_(e),u?.(e))},initialFocus:!0,fromYear:2e3,toYear:2050})})]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(a.Select,{value:m,onValueChange:T,children:[(0,H.jsx)(a.SelectTrigger,{className:`w-32 bg-background`,children:(0,H.jsx)(a.SelectValue,{})}),(0,H.jsxs)(a.SelectContent,{children:[(0,H.jsx)(a.SelectItem,{value:`day`,children:v(`calendar.day`)}),(0,H.jsx)(a.SelectItem,{value:`week`,children:v(`calendar.week`)}),(0,H.jsx)(a.SelectItem,{value:`month`,children:v(`calendar.month`)})]})]}),d&&(0,H.jsxs)(a.Button,{onClick:d,size:`sm`,className:`gap-1`,children:[(0,H.jsx)(i.PlusIcon,{className:`h-4 w-4`}),v(`calendar.newEvent`)]})]})]}),(0,H.jsxs)(`div`,{className:`flex-1 overflow-auto`,onTouchStart:e=>{D.current=e.touches[0].clientX},onTouchEnd:e=>{let t=D.current-e.changedTouches[0].clientX;if(Math.abs(t)>50){let e=new Date(g);m===`day`?e.setDate(e.getDate()+(t>0?1:-1)):m===`week`?e.setDate(e.getDate()+(t>0?7:-7)):e.setMonth(e.getMonth()+(t>0?1:-1)),_(e),u?.(e)}},children:[m===`month`&&(0,H.jsx)(ee,{date:g,events:e,locale:b,onEventClick:s,onDateClick:c,onEventDrop:f}),m===`week`&&(0,H.jsx)(te,{date:g,events:e,locale:b,onEventClick:s,onDateClick:c}),m===`day`&&(0,H.jsx)(ne,{date:g,events:e,onEventClick:s,onDateClick:c})]})]})}function J(e){let t=new Date(e),n=t.getDay(),r=t.getDate()-n;return t.setDate(r),t}function Y(e){let t=e.getFullYear(),n=e.getMonth(),r=new Date(t,n,1),i=new Date(t,n+1,0),a=r.getDay(),o=[];for(let e=a-1;e>=0;e--){let t=new Date(r.getTime());t.setDate(t.getDate()-(e+1)),o.push(t)}for(let e=1;e<=i.getDate();e++)o.push(new Date(t,n,e));let s=42-o.length;for(let e=1;e<=s;e++){let t=new Date(i.getTime());t.setDate(t.getDate()+e),o.push(t)}return o}function X(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function Z(e,t){return t.filter(t=>{let n=new Date(t.start),r=t.end?new Date(t.end):new Date(n),i=new Date(e);i.setHours(0,0,0,0);let a=new Date(e);a.setHours(23,59,59,999);let o=new Date(n);o.setHours(0,0,0,0);let s=new Date(r);return s.setHours(23,59,59,999),i<=s&&a>=o})}function ee({date:e,events:n,locale:r=`default`,onEventClick:i,onDateClick:o,onEventDrop:s}){let c=t.useMemo(()=>Y(e),[e.getFullYear(),e.getMonth()]),l=t.useMemo(()=>new Date,[]),{t:u}=K(),d=t.useMemo(()=>{let e=new Date(2024,0,7);return Array.from({length:7},(t,n)=>{let i=new Date(e);return i.setDate(i.getDate()+n),i.toLocaleDateString(r,{weekday:`short`})})},[r]),[f,p]=t.useState(null),[m,h]=t.useState(null),g=t.useMemo(()=>{let e=new Map;for(let t of n){let n=new Date(t.start),r=t.end?new Date(t.end):new Date(n);n.setHours(0,0,0,0),r.setHours(0,0,0,0);let i=new Date(n);for(;i<=r;){let n=`${i.getFullYear()}-${i.getMonth()}-${i.getDate()}`,r=e.get(n);r?r.push(t):e.set(n,[t]),i.setDate(i.getDate()+1)}}return e},[n]),_=(e,t)=>{p(t.id),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,String(t.id))},v=()=>{p(null),h(null)},y=(e,t)=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`,h(t)},b=e=>{e.currentTarget.contains(e.relatedTarget)||h(null)},x=(e,t)=>{if(e.preventDefault(),h(null),p(null),!s)return;let r=e.dataTransfer.getData(`text/plain`),i=n.find(e=>String(e.id)===r);if(!i)return;let a=new Date(i.start),o=new Date(a);o.setHours(0,0,0,0);let c=new Date(t);c.setHours(0,0,0,0);let l=c.getTime()-o.getTime();if(l===0)return;let u=new Date(a.getTime()+l),d;i.end&&(d=new Date(new Date(i.end).getTime()+l)),s(i,u,d)};return(0,H.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,H.jsx)(`div`,{role:`row`,className:`grid grid-cols-7 border-b`,children:d.map(e=>(0,H.jsx)(`div`,{role:`columnheader`,className:`p-2 text-center text-sm font-medium text-muted-foreground border-r last:border-r-0`,children:e},e))}),(0,H.jsx)(`div`,{role:`grid`,"aria-label":`Calendar grid`,className:`grid grid-cols-7 flex-1 auto-rows-fr`,children:c.map((t,n)=>{let r=`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`,c=g.get(r)||[],d=t.getMonth()===e.getMonth(),p=X(t,l);return(0,H.jsxs)(`div`,{role:`gridcell`,"aria-label":`${t.toLocaleDateString(`default`,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})}${c.length>0?`, ${c.length} event${c.length>1?`s`:``}`:``}`,className:(0,a.cn)(`border-b border-r last:border-r-0 p-2 min-h-[100px] cursor-pointer hover:bg-accent/50`,!d&&`bg-muted/50 text-muted-foreground opacity-50`,m===n&&`ring-2 ring-primary`),onClick:()=>o?.(t),onDragOver:e=>y(e,n),onDragLeave:b,onDrop:e=>x(e,t),children:[(0,H.jsx)(`div`,{className:(0,a.cn)(`text-sm font-medium mb-2`,p&&`inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-6 w-6`),...p?{"aria-current":`date`}:{},children:t.getDate()}),(0,H.jsxs)(`div`,{className:`space-y-1`,children:[c.slice(0,3).map(e=>(0,H.jsx)(`div`,{role:`button`,title:e.title,"aria-label":e.title,draggable:!!s,onDragStart:t=>_(t,e),onDragEnd:v,className:(0,a.cn)(`text-xs px-2 py-1 rounded truncate cursor-pointer hover:opacity-80`,e.color?.startsWith(`#`)?`text-white`:e.color||U,f===e.id&&`opacity-50`),style:e.color&&e.color.startsWith(`#`)?{backgroundColor:e.color}:void 0,onClick:t=>{t.stopPropagation(),i?.(e)},children:e.title},e.id)),c.length>3&&(0,H.jsx)(`div`,{className:`text-xs text-muted-foreground px-2`,children:u(`calendar.moreEvents`,{count:c.length-3})})]})]},n)})})]})}function te({date:e,events:n,locale:r=`default`,onEventClick:i,onDateClick:o}){let s=t.useRef(null),c=e=>{o&&(s.current=setTimeout(()=>{o(e)},500))},l=()=>{s.current&&=(clearTimeout(s.current),null)},u=J(e),d=Array.from({length:7},(e,t)=>{let n=new Date(u);return n.setDate(n.getDate()+t),n}),f=new Date;return(0,H.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,H.jsx)(`div`,{className:`grid grid-cols-7 border-b`,children:d.map(e=>{let t=X(e,f);return(0,H.jsxs)(`div`,{className:`p-3 text-center border-r last:border-r-0`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-muted-foreground`,children:e.toLocaleDateString(r,{weekday:`short`})}),(0,H.jsx)(`div`,{className:(0,a.cn)(`text-lg font-semibold mt-1`,t&&`inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-8 w-8`),children:e.getDate()})]},e.toISOString())})}),(0,H.jsx)(`div`,{role:`grid`,className:`grid grid-cols-7 flex-1`,children:d.map(e=>{let t=Z(e,n);return(0,H.jsx)(`div`,{role:`gridcell`,"aria-label":`${e.toLocaleDateString(`default`,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})}${t.length>0?`, ${t.length} event${t.length>1?`s`:``}`:``}`,className:`border-r last:border-r-0 p-2 min-h-[400px] cursor-pointer hover:bg-accent/50`,onClick:()=>o?.(e),onTouchStart:()=>c(e),onTouchEnd:l,children:(0,H.jsx)(`div`,{className:`space-y-2`,children:t.map(e=>(0,H.jsxs)(`div`,{role:`button`,title:e.title,"aria-label":e.title,className:(0,a.cn)(`text-xs sm:text-sm px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80`,e.color?.startsWith(`#`)?`text-white`:e.color||U),style:e.color&&e.color.startsWith(`#`)?{backgroundColor:e.color}:void 0,onClick:t=>{t.stopPropagation(),i?.(e)},children:[(0,H.jsx)(`div`,{className:`font-medium truncate`,children:e.title}),!e.allDay&&(0,H.jsx)(`div`,{className:`text-xs opacity-90 mt-1`,children:e.start.toLocaleTimeString(`default`,{hour:`numeric`,minute:`2-digit`})})]},e.id))})},e.toISOString())})})]})}function ne({date:e,events:n,onEventClick:r,onDateClick:i}){let o=Z(e,n),s=Array.from({length:24},(e,t)=>t),c=t.useRef(null),l=t=>{i&&(c.current=setTimeout(()=>{let n=new Date(e);n.setHours(t,0,0,0),i(n)},500))},u=()=>{c.current&&=(clearTimeout(c.current),null)};return(0,H.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,H.jsx)(`div`,{role:`list`,className:`flex-1 overflow-auto`,children:s.map(e=>{let t=o.filter(t=>t.allDay?e===0:t.start.getHours()===e);return(0,H.jsxs)(`div`,{role:`listitem`,className:`flex border-b min-h-[60px]`,children:[(0,H.jsx)(`div`,{className:`w-20 p-2 text-sm text-muted-foreground border-r`,children:e===0?`12 AM`:e<12?`${e} AM`:e===12?`12 PM`:`${e-12} PM`}),(0,H.jsx)(`div`,{className:`flex-1 p-2 space-y-2`,onTouchStart:()=>l(e),onTouchEnd:u,children:t.map(e=>(0,H.jsxs)(`div`,{title:e.title,"aria-label":e.title,className:(0,a.cn)(`px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80`,e.color?.startsWith(`#`)?`text-white`:e.color||U),style:e.color&&e.color.startsWith(`#`)?{backgroundColor:e.color}:void 0,onClick:()=>r?.(e),children:[(0,H.jsx)(`div`,{className:`font-medium truncate`,children:e.title}),!e.allDay&&(0,H.jsxs)(`div`,{className:`text-xs opacity-90 mt-1`,children:[e.start.toLocaleTimeString(`default`,{hour:`numeric`,minute:`2-digit`}),e.end&&` - ${e.end.toLocaleTimeString(`default`,{hour:`numeric`,minute:`2-digit`})}`]})]},e.id))})]},e)})})})}function re(e){let{onRefresh:n,threshold:r=80,enabled:i=!0}=e,a=(0,t.useRef)(null),[o,s]=(0,t.useState)(!1),[c,l]=(0,t.useState)(0),u=(0,t.useRef)(0),d=(0,t.useCallback)(e=>{if(!i||o)return;let t=a.current;t&&t.scrollTop===0&&(u.current=e.touches[0].clientY)},[i,o]),f=(0,t.useCallback)(e=>{if(!i||o||!u.current)return;let t=e.touches[0].clientY-u.current;t>0&&l(Math.min(t,r*1.5))},[i,o,r]),p=(0,t.useCallback)(async()=>{if(!i||o)return;let e=c;if(l(0),u.current=0,e>=r){s(!0);try{await n()}finally{s(!1)}}},[i,o,c,r,n]);return(0,t.useEffect)(()=>{let e=a.current;if(!(!e||!i))return e.addEventListener(`touchstart`,d,{passive:!0}),e.addEventListener(`touchmove`,f,{passive:!0}),e.addEventListener(`touchend`,p,{passive:!0}),()=>{e.removeEventListener(`touchstart`,d),e.removeEventListener(`touchmove`,f),e.removeEventListener(`touchend`,p)}},[d,f,p,i]),{ref:a,isRefreshing:o,pullDistance:c}}var ie=(0,t.createContext)(null);ie.displayName=`MobileContext`;function ae(e){return`data`in e&&e.data?e.data:`staticData`in e&&e.staticData?{provider:`value`,items:e.staticData}:e.objectName?{provider:`object`,object:e.objectName}:null}function oe(e){if(e){if(typeof e==`string`){let t=e.split(` `),n=t[0],r=t[1]?.toLowerCase()===`desc`?`desc`:`asc`;return{[n]:r}}if(Array.isArray(e))return e.reduce((e,t)=>(t.field&&t.order&&(e[t.field]=t.order),e),{})}}function se(e){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?{startDateField:e.startDateField||e.dateField,endDateField:e.endDateField||e.endField,titleField:e.titleField,colorField:e.colorField,allDayField:e.allDayField}:null}var Q=({schema:e,dataSource:i,className:o,data:s,loading:c,onEventClick:l,onRowClick:u,onDateClick:d,onNavigate:f,onViewChange:p,onEventDrop:m,locale:h})=>{let g=Array.isArray(s),[_,v]=(0,t.useState)(g?s:[]),[y,b]=(0,t.useState)(g?c??!1:!0),[x,S]=(0,t.useState)(null),[C,w]=(0,t.useState)(null),[T,E]=(0,t.useState)(new Date),D=(0,a.useIsMobile)(),O=e.defaultView,[k,A]=(0,t.useState)(()=>{let e=O===`day`||!O;return typeof window<`u`&&window.innerWidth<768&&e?`month`:O||`month`});(0,t.useEffect)(()=>{D&&k===`day`&&(O===`day`||!O)&&A(`month`)},[D]);let[j,M]=(0,t.useState)(0);(0,t.useEffect)(()=>{if(!g&&!(!i?.onMutation||!e.objectName))return i.onMutation(t=>{t.resource===e.objectName&&M(e=>e+1)})},[i,e.objectName,g]);let{ref:N,isRefreshing:P,pullDistance:F}=re({onRefresh:(0,t.useCallback)(async()=>{M(e=>e+1)},[]),enabled:!!i&&!!e.objectName}),I=(0,t.useMemo)(()=>ae(e),[e.data,e.staticData,e.objectName]),L=(0,t.useMemo)(()=>se(e),[e.filter,e.calendar,e.dateField,e.endField,e.titleField,e.colorField]),R=I?.provider===`value`,z=(0,t.useRef)(null);z.current=C,(0,t.useEffect)(()=>{g&&v(s)},[s,g]),(0,t.useEffect)(()=>{g&&c!==void 0&&b(c)},[c,g]),(0,t.useEffect)(()=>{if(g)return;let t=!0;return(async()=>{try{if(!t)return;if(b(!0),R&&I?.provider===`value`){t&&(v(I.items),b(!1));return}if(!i||typeof i.find!=`function`)throw Error(`DataSource required for object/api providers`);if(I?.provider===`object`){let r=I.object,a=(0,n.buildExpandFields)(z.current?.fields),o=(0,n.extractRecords)(await i.find(r,{$filter:e.filter,$orderby:oe(e.sort),...a.length>0?{$expand:a}:{}}));t&&v(o)}else I?.provider===`api`&&(console.warn(`API provider not yet implemented for ObjectCalendar`),t&&v([]));t&&b(!1)}catch(e){console.error(`[ObjectCalendar] Error fetching data:`,e),t&&(S(e),b(!1))}})(),()=>{t=!1}},[g,I,i,R,e.filter,e.sort,j]),(0,t.useEffect)(()=>{!R&&i&&(async()=>{try{if(!i)return;let t=I?.provider===`object`?I.object:e.objectName;if(!t)return;w(await i.getObjectSchema(t))}catch(e){console.error(`Failed to fetch object schema:`,e)}})()},[e.objectName,i,R,I]);let B=(0,t.useMemo)(()=>{if(!L||!_.length)return[];let{startDateField:e,endDateField:t,titleField:n,colorField:r}=L,i=C?.titleFormat,a=C?.NAME_FIELD_KEY,o=[`name`,`full_name`,`fullName`,`title`,`subject`,`label`,`display_name`,`displayName`],s=(e,t)=>{let n=!1,r=e.replace(/\{(.+?)\}/g,(e,r)=>{let i=t[r.trim()];return i!=null&&i!==``?(n=!0,String(i)):``}).replace(/\s+-\s+(?=$|\s*$)/,``).trim();return n?r:``},c=e=>{let t;if(n&&(t=e[n],typeof t==`string`&&(t=t.trim())),!t&&i){let n=s(i,e);n&&(t=n)}if(!t&&a){let n=e[a];typeof n==`string`?t=n.trim():n&&(t=n)}if(!t)for(let n of o){let r=e[n],i=typeof r==`string`?r.trim():r;if(i){t=i;break}}return t||`Untitled`};return _.map((n,i)=>{let a=n[e],o=t?n[t]:null,s=c(n),l=r?n[r]:void 0;return{id:n.id||n._id||`event-${i}`,title:s,start:a?new Date(a):new Date,end:o?new Date(o):void 0,color:l,allDay:!o,data:n}}).filter(e=>!isNaN(e.start.getTime()))},[_,L,C]);(0,t.useCallback)(()=>{d?.(new Date)},[d]);let V=(0,r.useNavigationOverlay)({navigation:e.navigation,objectName:e.objectName,onRowClick:u});return y?(0,H.jsx)(`div`,{className:o,children:(0,H.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,H.jsx)(`div`,{className:`text-muted-foreground`,children:`Loading calendar...`})})}):x?(0,H.jsx)(`div`,{className:o,children:(0,H.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,H.jsxs)(`div`,{className:`text-destructive`,children:[`Error: `,x.message]})})}):L?(0,H.jsxs)(`div`,{ref:N,className:o,children:[F>0&&(0,H.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:F},children:P?`Refreshing…`:`Pull to refresh`}),(0,H.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:(0,H.jsx)(q,{events:B,currentDate:T,view:k,locale:h,onEventClick:e=>{V.handleClick(e.data),l?.(e.data)},onDateClick:d,onNavigate:e=>{E(e),f?.(e)},onViewChange:e=>{A(e),p?.(e)},onAddClick:void 0,onEventDrop:m?(e,t,n)=>{m(e.data,t,n)}:void 0})}),V.isOverlay&&(0,H.jsx)(a.NavigationOverlay,{...V,title:`Event Details`,children:e=>(0,H.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,H.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]}):(0,H.jsx)(`div`,{className:o,children:(0,H.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,H.jsx)(`div`,{className:`text-muted-foreground`,children:`Calendar configuration required. Please specify startDateField and titleField.`})})})};n.ComponentRegistry.register(`calendar-view`,({schema:e,className:n,onAction:r,...i})=>{let a=t.default.useMemo(()=>!e.data||!Array.isArray(e.data)?[]:e.data.map((t,n)=>{let r=e.titleField||`title`,i=e.startDateField||`start`,a=e.endDateField||`end`,o=e.colorField||`color`,s=e.allDayField||`allDay`;return{id:t.id||t._id||n,title:t[r]||`Untitled Event`,start:new Date(t[i]),end:t[a]?new Date(t[a]):void 0,allDay:t[s],color:t[o],data:t}}),[e.data,e.titleField,e.startDateField,e.endDateField,e.colorField,e.allDayField]);return(0,H.jsx)(q,{className:n,events:a,onEventClick:e=>{r?.({type:`event-click`,payload:e})},...i})},{namespace:`plugin-calendar`,label:`Calendar View`,inputs:[{name:`data`,type:`array`,label:`Data`,description:`Array of record objects to display as events`},{name:`titleField`,type:`string`,label:`Title Field`,defaultValue:`title`,description:`Field name to use for event title`},{name:`startDateField`,type:`string`,label:`Start Date Field`,defaultValue:`start`,description:`Field name for event start date`},{name:`endDateField`,type:`string`,label:`End Date Field`,defaultValue:`end`,description:`Field name for event end date (optional)`},{name:`allDayField`,type:`string`,label:`All Day Field`,defaultValue:`allDay`,description:`Field name for all-day flag`},{name:`colorField`,type:`string`,label:`Color Field`,defaultValue:`color`,description:`Field name for event color`},{name:`colorMapping`,type:`object`,label:`Color Mapping`,description:`Map field values to colors (e.g., {meeting: "blue", deadline: "red"})`},{name:`view`,type:`enum`,enum:[`month`,`week`,`day`],defaultValue:`month`,label:`View Mode`,description:`Calendar view mode (month, week, or day)`},{name:`currentDate`,type:`string`,label:`Current Date`,description:`ISO date string for initial calendar date`},{name:`allowCreate`,type:`boolean`,label:`Allow Create`,defaultValue:!1,description:`Allow creating events by clicking on dates`},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{view:`month`,titleField:`title`,startDateField:`start`,endDateField:`end`,allDayField:`allDay`,colorField:`color`,allowCreate:!1,data:[{id:1,title:`Team Meeting`,start:new Date(new Date().setHours(10,0,0,0)).toISOString(),end:new Date(new Date().setHours(11,0,0,0)).toISOString(),color:`#3b82f6`,allDay:!1},{id:2,title:`Project Deadline`,start:new Date(new Date().setDate(new Date().getDate()+3)).toISOString(),color:`#ef4444`,allDay:!0},{id:3,title:`Conference`,start:new Date(new Date().setDate(new Date().getDate()+7)).toISOString(),end:new Date(new Date().setDate(new Date().getDate()+9)).toISOString(),color:`#10b981`,allDay:!0}],className:`h-[600px] border rounded-lg`}});var $=({schema:e,...t})=>{let{dataSource:n}=(0,r.useSchemaContext)()||{};return(0,H.jsx)(Q,{schema:e,dataSource:n,...t})};n.ComponentRegistry.register(`object-calendar`,$,{namespace:`plugin-calendar`,label:`Object Calendar`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`calendar`,type:`object`,label:`Calendar Config`,description:`startDateField, endDateField, titleField, colorField`}]}),n.ComponentRegistry.register(`calendar`,$,{namespace:`view`,label:`Calendar View`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`calendar`,type:`object`,label:`Calendar Config`,description:`startDateField, endDateField, titleField, colorField`}]}),e.CalendarView=q,e.ObjectCalendar=Q,e.ObjectCalendarRenderer=$});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectCalendar.d.ts","sourceRoot":"","sources":["../../../../src/ObjectCalendar.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAA4D,MAAM,OAAO,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAA4B,MAAM,kBAAkB,CAAC;AAO/F,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,wBAAwB;IACxB,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;CACxC;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,gBAAgB,GAAG,cAAc,CAAC;IAC1C,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6GAA6G;IAC7G,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,2FAA2F;IAC3F,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACrC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACnC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACjC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAClC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,KAAK,IAAI,CAAC;IACxD,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,IAAI,KAAK,IAAI,CAAC;IACnE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAkFD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"ObjectCalendar.d.ts","sourceRoot":"","sources":["../../../../src/ObjectCalendar.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAA4D,MAAM,OAAO,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAA4B,MAAM,kBAAkB,CAAC;AAO/F,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,wBAAwB;IACxB,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;CACxC;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,gBAAgB,GAAG,cAAc,CAAC;IAC1C,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6GAA6G;IAC7G,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,2FAA2F;IAC3F,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACrC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACnC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACjC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAClC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,KAAK,IAAI,CAAC;IACxD,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,IAAI,KAAK,IAAI,CAAC;IACnE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAkFD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA8VxD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/plugin-calendar",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Calendar view plugins for Object UI - includes both ObjectQL-integrated and standalone calendar components",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"lucide-react": "^1.
|
|
28
|
-
"@object-ui/components": "3.
|
|
29
|
-
"@object-ui/core": "3.
|
|
30
|
-
"@object-ui/fields": "3.
|
|
31
|
-
"@object-ui/i18n": "3.
|
|
32
|
-
"@object-ui/mobile": "3.
|
|
33
|
-
"@object-ui/react": "3.
|
|
34
|
-
"@object-ui/types": "3.
|
|
27
|
+
"lucide-react": "^1.14.0",
|
|
28
|
+
"@object-ui/components": "3.4.0",
|
|
29
|
+
"@object-ui/core": "3.4.0",
|
|
30
|
+
"@object-ui/fields": "3.4.0",
|
|
31
|
+
"@object-ui/i18n": "3.4.0",
|
|
32
|
+
"@object-ui/mobile": "3.4.0",
|
|
33
|
+
"@object-ui/react": "3.4.0",
|
|
34
|
+
"@object-ui/types": "3.4.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"@types/react-dom": "19.2.3",
|
|
43
43
|
"@vitejs/plugin-react": "^6.0.1",
|
|
44
44
|
"typescript": "^6.0.3",
|
|
45
|
-
"vite": "^8.0.
|
|
46
|
-
"vite-plugin-dts": "^
|
|
47
|
-
"@object-ui/data-objectstack": "3.
|
|
45
|
+
"vite": "^8.0.10",
|
|
46
|
+
"vite-plugin-dts": "^5.0.0",
|
|
47
|
+
"@object-ui/data-objectstack": "3.4.0"
|
|
48
48
|
},
|
|
49
49
|
"keywords": [
|
|
50
50
|
"objectui",
|