@object-ui/plugin-calendar 3.1.1 → 3.1.3
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/.turbo/turbo-build.log +3 -3
- package/CHANGELOG.md +24 -0
- package/dist/index.js +1 -1
- package/dist/index.umd.cjs +1 -1
- package/package.json +10 -10
- package/src/ObjectCalendar.msw.test.tsx +2 -2
- package/src/calendar-view-renderer.tsx +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @object-ui/plugin-calendar@3.1.
|
|
2
|
+
> @object-ui/plugin-calendar@3.1.3 build /home/runner/work/objectui/objectui/packages/plugin-calendar
|
|
3
3
|
> vite build
|
|
4
4
|
|
|
5
5
|
[36mvite v7.3.1 [32mbuilding client environment for production...[36m[39m
|
|
@@ -10,7 +10,7 @@ rendering chunks...
|
|
|
10
10
|
[36m[vite:dts][32m Start generate declaration files...[39m
|
|
11
11
|
computing gzip size...
|
|
12
12
|
[2mdist/[22m[36mindex.js [39m[1m[2m50.27 kB[22m[1m[22m[2m │ gzip: 13.72 kB[22m
|
|
13
|
-
[32m[36m[vite:dts][32m Declaration files built in
|
|
13
|
+
[32m[36m[vite:dts][32m Declaration files built in 20133ms.
|
|
14
14
|
[39m
|
|
15
15
|
[2mdist/[22m[36mindex.umd.cjs [39m[1m[2m34.61 kB[22m[1m[22m[2m │ gzip: 12.03 kB[22m
|
|
16
|
-
[32m✓ built in
|
|
16
|
+
[32m✓ built in 23.84s[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @object-ui/plugin-calendar
|
|
2
2
|
|
|
3
|
+
## 3.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @object-ui/types@3.1.3
|
|
8
|
+
- @object-ui/core@3.1.3
|
|
9
|
+
- @object-ui/i18n@3.1.3
|
|
10
|
+
- @object-ui/react@3.1.3
|
|
11
|
+
- @object-ui/components@3.1.3
|
|
12
|
+
- @object-ui/fields@3.1.3
|
|
13
|
+
- @object-ui/mobile@3.1.3
|
|
14
|
+
|
|
15
|
+
## 3.1.2
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- @object-ui/types@3.1.2
|
|
20
|
+
- @object-ui/core@3.1.2
|
|
21
|
+
- @object-ui/i18n@3.1.2
|
|
22
|
+
- @object-ui/react@3.1.2
|
|
23
|
+
- @object-ui/components@3.1.2
|
|
24
|
+
- @object-ui/fields@3.1.2
|
|
25
|
+
- @object-ui/mobile@3.1.2
|
|
26
|
+
|
|
3
27
|
## 3.1.1
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1247,7 +1247,7 @@ fe.register(
|
|
|
1247
1247
|
const i = oe.useMemo(() => !e.data || !Array.isArray(e.data) ? [] : e.data.map((u, v) => {
|
|
1248
1248
|
const h = e.titleField || "title", m = e.startDateField || "start", E = e.endDateField || "end", n = e.colorField || "color", g = e.allDayField || "allDay";
|
|
1249
1249
|
return {
|
|
1250
|
-
id: u.
|
|
1250
|
+
id: u.id || u._id || v,
|
|
1251
1251
|
title: u[h] || "Untitled Event",
|
|
1252
1252
|
start: new Date(u[m]),
|
|
1253
1253
|
end: u[E] ? new Date(u[E]) : void 0,
|
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} />`,k,R,W,R),$[R+k]=!0)}if(R=null,j!==void 0&&(n(j),R=""+j),d(x)&&(n(x.key),R=""+x.key),"key"in x){j={};for(var ce in x)ce!=="key"&&(j[ce]=x[ce])}else j=x;return R&&v(j,typeof t=="function"?t.displayName||t.name||"Unknown":t),p(t,R,j,i(),z,G)}function a(t){m(t)?t._store&&(t._store.validated=1):typeof t=="object"&&t!==null&&t.$$typeof===D&&(t._payload.status==="fulfilled"?m(t._payload.value)&&t._payload.value._store&&(t._payload.value._store.validated=1):t._store&&(t._store.validated=1))}function m(t){return typeof t=="object"&&t!==null&&t.$$typeof===h}var l=g,h=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),F=Symbol.for("react.strict_mode"),M=Symbol.for("react.profiler"),Y=Symbol.for("react.consumer"),b=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),P=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),_=Symbol.for("react.client.reference"),u=l.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,S=Object.prototype.hasOwnProperty,L=Array.isArray,H=console.createTask?console.createTask:function(){return null};l={react_stack_bottom_frame:function(t){return t()}};var Q,re={},B=l.react_stack_bottom_frame.bind(l,o)(),N=H(c(o)),$={};K.Fragment=A,K.jsx=function(t,x,j){var k=1e4>u.recentlyCreatedOwnerStacks++;return E(t,x,j,!1,k?Error("react-stack-top-frame"):B,k?H(c(t)):N)},K.jsxs=function(t,x,j){var k=1e4>u.recentlyCreatedOwnerStacks++;return E(t,x,j,!0,k?Error("react-stack-top-frame"):B,k?H(c(t)):N)}})()),K}var ge;function Ce(){return ge||(ge=1,process.env.NODE_ENV==="production"?ee.exports=Ne():ee.exports=Oe()),ee.exports}var s=Ce();const Fe=(e,r,n,c)=>{const i=[n,{code:r,...c||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(i,"warn","react-i18next::",!0);q(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...i):console?.warn&&console.warn(...i)},me={},pe=(e,r,n,c)=>{q(n)&&me[n]||(q(n)&&(me[n]=new Date),Fe(e,r,n,c))},he=(e,r)=>()=>{if(e.isInitialized)r();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),r()};e.on("initialized",n)}},ne=(e,r,n)=>{e.loadNamespaces(r,he(e,n))},ye=(e,r,n,c)=>{if(q(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(r)>-1)return ne(e,n,c);n.forEach(i=>{e.options.ns.indexOf(i)<0&&e.options.ns.push(i)}),e.loadLanguages(r,he(e,c))},ke=(e,r,n={})=>!r.languages||!r.languages.length?(pe(r,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:r.languages}),!0):r.hasLoadedNamespace(e,{lng:n.lng,precheck:(c,i)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&c.services.backendConnector.backend&&c.isLanguageChangingTo&&!i(c.isLanguageChangingTo,e))return!1}}),q=e=>typeof e=="string",Le=e=>typeof e=="object"&&e!==null,Ae=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,Re={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},Pe=e=>Re[e];let Ie={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(Ae,Pe),transDefaultProps:void 0};const Me=()=>Ie;let $e;const Ve=()=>$e,Ye=g.createContext();class Ue{constructor(){this.usedNamespaces={}}addUsedNamespaces(r){r.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var te={exports:{}},ae={};var xe;function He(){if(xe)return ae;xe=1;var e=g;function r(a,m){return a===m&&(a!==0||1/a===1/m)||a!==a&&m!==m}var n=typeof Object.is=="function"?Object.is:r,c=e.useState,i=e.useEffect,o=e.useLayoutEffect,d=e.useDebugValue;function v(a,m){var l=m(),h=c({inst:{value:l,getSnapshot:m}}),w=h[0].inst,A=h[1];return o(function(){w.value=l,w.getSnapshot=m,y(w)&&A({inst:w})},[a,l,m]),i(function(){return y(w)&&A({inst:w}),a(function(){y(w)&&A({inst:w})})},[a]),d(l),l}function y(a){var m=a.getSnapshot;a=a.value;try{var l=m();return!n(a,l)}catch{return!0}}function p(a,m){return m()}var E=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?p:v;return ae.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:E,ae}var oe={};var be;function We(){return be||(be=1,process.env.NODE_ENV!=="production"&&(function(){function e(l,h){return l===h&&(l!==0||1/l===1/h)||l!==l&&h!==h}function r(l,h){E||i.startTransition===void 0||(E=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var w=h();if(!a){var A=h();o(w,A)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),a=!0)}A=d({inst:{value:w,getSnapshot:h}});var F=A[0].inst,M=A[1];return y(function(){F.value=w,F.getSnapshot=h,n(F)&&M({inst:F})},[l,w,h]),v(function(){return n(F)&&M({inst:F}),l(function(){n(F)&&M({inst:F})})},[l]),p(w),w}function n(l){var h=l.getSnapshot;l=l.value;try{var w=h();return!o(l,w)}catch{return!0}}function c(l,h){return h()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var i=g,o=typeof Object.is=="function"?Object.is:e,d=i.useState,v=i.useEffect,y=i.useLayoutEffect,p=i.useDebugValue,E=!1,a=!1,m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:r;oe.useSyncExternalStore=i.useSyncExternalStore!==void 0?i.useSyncExternalStore:m,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),oe}var ve;function qe(){return ve||(ve=1,process.env.NODE_ENV==="production"?te.exports=He():te.exports=We()),te.exports}var ze=qe();const Ge={t:(e,r)=>q(r)?r:Le(r)&&q(r.defaultValue)?r.defaultValue:Array.isArray(e)?e[e.length-1]:e,ready:!1},Be=()=>()=>{},Je=(e,r={})=>{const{i18n:n}=r,{i18n:c,defaultNS:i}=g.useContext(Ye)||{},o=n||c||Ve();o&&!o.reportNamespaces&&(o.reportNamespaces=new Ue),o||pe(o,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const d=g.useMemo(()=>({...Me(),...o?.options?.react,...r}),[o,r]),{useSuspense:v,keyPrefix:y}=d,p=i||o?.options?.defaultNS,E=q(p)?[p]:p||["translation"],a=g.useMemo(()=>E,E);o?.reportNamespaces?.addUsedNamespaces?.(a);const m=g.useRef(0),l=g.useCallback(D=>{if(!o)return Be;const{bindI18n:f,bindI18nStore:_}=d,u=()=>{m.current+=1,D()};return f&&o.on(f,u),_&&o.store.on(_,u),()=>{f&&f.split(" ").forEach(S=>o.off(S,u)),_&&_.split(" ").forEach(S=>o.store.off(S,u))}},[o,d]),h=g.useRef(),w=g.useCallback(()=>{if(!o)return Ge;const D=!!(o.isInitialized||o.initializedStoreOnce)&&a.every(H=>ke(H,o,d)),f=r.lng||o.language,_=m.current,u=h.current;if(u&&u.ready===D&&u.lng===f&&u.keyPrefix===y&&u.revision===_)return u;const L={t:o.getFixedT(f,d.nsMode==="fallback"?a:a[0],y),ready:D,lng:f,keyPrefix:y,revision:_};return h.current=L,L},[o,a,y,d,r.lng]),[A,F]=g.useState(0),{t:M,ready:Y}=ze.useSyncExternalStore(l,w,w);g.useEffect(()=>{if(o&&!Y&&!v){const D=()=>F(f=>f+1);r.lng?ye(o,r.lng,a,D):ne(o,a,D)}},[o,r.lng,a,Y,v,A]);const b=o||{},O=g.useRef(null),I=g.useRef(),T=D=>{const f=Object.getOwnPropertyDescriptors(D);f.__original&&delete f.__original;const _=Object.create(Object.getPrototypeOf(D),f);if(!Object.prototype.hasOwnProperty.call(_,"__original"))try{Object.defineProperty(_,"__original",{value:D,writable:!1,enumerable:!1,configurable:!1})}catch{}return _},P=g.useMemo(()=>{const D=b,f=D?.language;let _=D;D&&(O.current&&O.current.__original===D?I.current!==f?(_=T(D),O.current=_,I.current=f):_=O.current:(_=T(D),O.current=_,I.current=f));const u=[M,_,Y];return u.t=M,u.i18n=_,u.ready=Y,u},[M,b,Y,b.resolvedLanguage,b.language,b.languages]);if(o&&v&&!Y)throw new Promise(D=>{const f=()=>D();r.lng?ye(o,r.lng,a,f):ne(o,a,f)});return P},Xe=g.createContext(null);function Ke(e){const r=g.useContext(Xe),{t:n,i18n:c}=Je();return{t:n,language:r?.language||c.language||"en",changeLanguage:r?.changeLanguage||(async i=>{await c.changeLanguage(i)}),direction:r?.direction||"ltr",i18n:c}}const se="bg-blue-500 text-white",Qe=new Date,De={"calendar.today":"Today","calendar.month":"Month","calendar.week":"Week","calendar.day":"Day","calendar.newEvent":"New event","calendar.moreEvents":"+{{count}} more"};function we(){try{const e=Ke();return e.t("calendar.today")==="calendar.today"?{t:(n,c)=>{let i=De[n]||n;if(c)for(const[o,d]of Object.entries(c))i=i.replace(`{{${o}}}`,String(d));return i},language:"en"}:{t:e.t,language:e.language}}catch{return{t:(e,r)=>{let n=De[e]||e;if(r)for(const[c,i]of Object.entries(r))n=n.replace(`{{${c}}}`,String(i));return n},language:"en"}}}function le({events:e=[],view:r="month",currentDate:n=Qe,locale:c="default",onEventClick:i,onDateClick:o,onViewChange:d,onNavigate:v,onAddClick:y,onEventDrop:p,className:E}){const[a,m]=V.useState(r),[l,h]=V.useState(n),{t:w,language:A}=we(),F=c!=="default"?c:A;V.useEffect(()=>{h(n)},[n]),V.useEffect(()=>{m(r)},[r]);const M=V.useRef(d);M.current=d,V.useEffect(()=>{const u=window.matchMedia("(max-width: 639px)"),S=L=>{L.matches&&(m("day"),M.current?.("day"))};return S(u),u.addEventListener("change",S),()=>u.removeEventListener("change",S)},[]);const Y=()=>{const u=new Date(l);a==="month"?u.setMonth(u.getMonth()-1):a==="week"?u.setDate(u.getDate()-7):u.setDate(u.getDate()-1),h(u),v?.(u)},b=()=>{const u=new Date(l);a==="month"?u.setMonth(u.getMonth()+1):a==="week"?u.setDate(u.getDate()+7):u.setDate(u.getDate()+1),h(u),v?.(u)},O=()=>{const u=new Date;h(u),v?.(u)},I=u=>{m(u),d?.(u)},T=()=>{if(a==="month")return l.toLocaleDateString(F,{month:"long",year:"numeric"});if(a==="week"){const u=Se(l),S=new Date(u);return S.setDate(S.getDate()+6),`${u.toLocaleDateString(F,{month:"short",day:"numeric"})} - ${S.toLocaleDateString(F,{month:"short",day:"numeric",year:"numeric"})}`}else return l.toLocaleDateString(F,{weekday:"long",month:"long",day:"numeric",year:"numeric"})},P=V.useRef(0),D=u=>{P.current=u.touches[0].clientX},f=u=>{const S=P.current-u.changedTouches[0].clientX;if(Math.abs(S)>50){const L=new Date(l);a==="day"?L.setDate(L.getDate()+(S>0?1:-1)):a==="week"?L.setDate(L.getDate()+(S>0?7:-7)):L.setMonth(L.getMonth()+(S>0?1:-1)),h(L),v?.(L)}},_=u=>{u&&(h(u),v?.(u))};return s.jsxs("div",{role:"region","aria-label":"Calendar",className:C.cn("flex flex-col h-full bg-background min-w-0 overflow-hidden",E),children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 p-2 sm:p-4 border-b min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("div",{className:"flex items-center bg-muted/50 rounded-lg p-1 gap-1",children:[s.jsx(C.Button,{variant:"ghost",size:"sm",onClick:O,className:"h-8","aria-label":"Go to today",children:w("calendar.today")}),s.jsx("div",{className:"h-4 w-px bg-border mx-1"}),s.jsx(C.Button,{variant:"ghost",size:"icon","aria-label":"Previous period",onClick:Y,className:"h-8 w-8",children:s.jsx(Z.ChevronLeftIcon,{className:"h-4 w-4"})}),s.jsx(C.Button,{variant:"ghost",size:"icon","aria-label":"Next period",onClick:b,className:"h-8 w-8",children:s.jsx(Z.ChevronRightIcon,{className:"h-4 w-4"})})]}),s.jsxs(C.Popover,{children:[s.jsx(C.PopoverTrigger,{asChild:!0,children:s.jsxs(C.Button,{variant:"ghost","aria-label":`Current date: ${T()}`,className:C.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:[s.jsx(Z.CalendarIcon,{className:"h-5 w-5 text-muted-foreground"}),s.jsx("span",{children:T()})]})}),s.jsx(C.PopoverContent,{className:"w-auto p-0",align:"start",children:s.jsx(C.Calendar,{mode:"single",selected:l,onSelect:_,initialFocus:!0,fromYear:2e3,toYear:2050})})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(C.Select,{value:a,onValueChange:I,children:[s.jsx(C.SelectTrigger,{className:"w-32 bg-background",children:s.jsx(C.SelectValue,{})}),s.jsxs(C.SelectContent,{children:[s.jsx(C.SelectItem,{value:"day",children:w("calendar.day")}),s.jsx(C.SelectItem,{value:"week",children:w("calendar.week")}),s.jsx(C.SelectItem,{value:"month",children:w("calendar.month")})]})]}),y&&s.jsxs(C.Button,{onClick:y,size:"sm",className:"gap-1",children:[s.jsx(Z.PlusIcon,{className:"h-4 w-4"}),w("calendar.newEvent")]})]})]}),s.jsxs("div",{className:"flex-1 overflow-auto",onTouchStart:D,onTouchEnd:f,children:[a==="month"&&s.jsx(et,{date:l,events:e,locale:F,onEventClick:i,onDateClick:o,onEventDrop:p}),a==="week"&&s.jsx(tt,{date:l,events:e,locale:F,onEventClick:i,onDateClick:o}),a==="day"&&s.jsx(rt,{date:l,events:e,onEventClick:i,onDateClick:o})]})]})}function Se(e){const r=new Date(e),n=r.getDay(),c=r.getDate()-n;return r.setDate(c),r}function Ze(e){const r=e.getFullYear(),n=e.getMonth(),c=new Date(r,n,1),i=new Date(r,n+1,0),o=c.getDay(),d=[];for(let y=o-1;y>=0;y--){const p=new Date(c.getTime());p.setDate(p.getDate()-(y+1)),d.push(p)}for(let y=1;y<=i.getDate();y++)d.push(new Date(r,n,y));const v=42-d.length;for(let y=1;y<=v;y++){const p=new Date(i.getTime());p.setDate(p.getDate()+y),d.push(p)}return d}function je(e,r){return e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth()&&e.getDate()===r.getDate()}function Ee(e,r){return r.filter(n=>{const c=new Date(n.start),i=n.end?new Date(n.end):new Date(c),o=new Date(e);o.setHours(0,0,0,0);const d=new Date(e);d.setHours(23,59,59,999);const v=new Date(c);v.setHours(0,0,0,0);const y=new Date(i);return y.setHours(23,59,59,999),o<=y&&d>=v})}function et({date:e,events:r,locale:n="default",onEventClick:c,onDateClick:i,onEventDrop:o}){const d=V.useMemo(()=>Ze(e),[e.getFullYear(),e.getMonth()]),v=V.useMemo(()=>new Date,[]),{t:y}=we(),p=V.useMemo(()=>{const b=new Date(2024,0,7);return Array.from({length:7},(O,I)=>{const T=new Date(b);return T.setDate(T.getDate()+I),T.toLocaleDateString(n,{weekday:"short"})})},[n]),[E,a]=V.useState(null),[m,l]=V.useState(null),h=V.useMemo(()=>{const b=new Map;for(const O of r){const I=new Date(O.start),T=O.end?new Date(O.end):new Date(I);I.setHours(0,0,0,0),T.setHours(0,0,0,0);const P=new Date(I);for(;P<=T;){const D=`${P.getFullYear()}-${P.getMonth()}-${P.getDate()}`,f=b.get(D);f?f.push(O):b.set(D,[O]),P.setDate(P.getDate()+1)}}return b},[r]),w=(b,O)=>{a(O.id),b.dataTransfer.effectAllowed="move",b.dataTransfer.setData("text/plain",String(O.id))},A=()=>{a(null),l(null)},F=(b,O)=>{b.preventDefault(),b.dataTransfer.dropEffect="move",l(O)},M=b=>{b.currentTarget.contains(b.relatedTarget)||l(null)},Y=(b,O)=>{if(b.preventDefault(),l(null),a(null),!o)return;const I=b.dataTransfer.getData("text/plain"),T=r.find(L=>String(L.id)===I);if(!T)return;const P=new Date(T.start),D=new Date(P);D.setHours(0,0,0,0);const f=new Date(O);f.setHours(0,0,0,0);const _=f.getTime()-D.getTime();if(_===0)return;const u=new Date(P.getTime()+_);let S;T.end&&(S=new Date(new Date(T.end).getTime()+_)),o(T,u,S)};return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsx("div",{role:"row",className:"grid grid-cols-7 border-b",children:p.map(b=>s.jsx("div",{role:"columnheader",className:"p-2 text-center text-sm font-medium text-muted-foreground border-r last:border-r-0",children:b},b))}),s.jsx("div",{role:"grid","aria-label":"Calendar grid",className:"grid grid-cols-7 flex-1 auto-rows-fr",children:d.map((b,O)=>{const I=`${b.getFullYear()}-${b.getMonth()}-${b.getDate()}`,T=h.get(I)||[],P=b.getMonth()===e.getMonth(),D=je(b,v);return s.jsxs("div",{role:"gridcell","aria-label":`${b.toLocaleDateString("default",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}${T.length>0?`, ${T.length} event${T.length>1?"s":""}`:""}`,className:C.cn("border-b border-r last:border-r-0 p-2 min-h-[100px] cursor-pointer hover:bg-accent/50",!P&&"bg-muted/50 text-muted-foreground opacity-50",m===O&&"ring-2 ring-primary"),onClick:()=>i?.(b),onDragOver:f=>F(f,O),onDragLeave:M,onDrop:f=>Y(f,b),children:[s.jsx("div",{className:C.cn("text-sm font-medium mb-2",D&&"inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-6 w-6"),...D?{"aria-current":"date"}:{},children:b.getDate()}),s.jsxs("div",{className:"space-y-1",children:[T.slice(0,3).map(f=>s.jsx("div",{role:"button",title:f.title,"aria-label":f.title,draggable:!!o,onDragStart:_=>w(_,f),onDragEnd:A,className:C.cn("text-xs px-2 py-1 rounded truncate cursor-pointer hover:opacity-80",f.color?.startsWith("#")?"text-white":f.color||se,E===f.id&&"opacity-50"),style:f.color&&f.color.startsWith("#")?{backgroundColor:f.color}:void 0,onClick:_=>{_.stopPropagation(),c?.(f)},children:f.title},f.id)),T.length>3&&s.jsx("div",{className:"text-xs text-muted-foreground px-2",children:y("calendar.moreEvents",{count:T.length-3})})]})]},O)})})]})}function tt({date:e,events:r,locale:n="default",onEventClick:c,onDateClick:i}){const o=V.useRef(null),d=a=>{i&&(o.current=setTimeout(()=>{i(a)},500))},v=()=>{o.current&&(clearTimeout(o.current),o.current=null)},y=Se(e),p=Array.from({length:7},(a,m)=>{const l=new Date(y);return l.setDate(l.getDate()+m),l}),E=new Date;return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsx("div",{className:"grid grid-cols-7 border-b",children:p.map(a=>{const m=je(a,E);return s.jsxs("div",{className:"p-3 text-center border-r last:border-r-0",children:[s.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:a.toLocaleDateString(n,{weekday:"short"})}),s.jsx("div",{className:C.cn("text-lg font-semibold mt-1",m&&"inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-8 w-8"),children:a.getDate()})]},a.toISOString())})}),s.jsx("div",{role:"grid",className:"grid grid-cols-7 flex-1",children:p.map(a=>{const m=Ee(a,r);return s.jsx("div",{role:"gridcell","aria-label":`${a.toLocaleDateString("default",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}${m.length>0?`, ${m.length} event${m.length>1?"s":""}`:""}`,className:"border-r last:border-r-0 p-2 min-h-[400px] cursor-pointer hover:bg-accent/50",onClick:()=>i?.(a),onTouchStart:()=>d(a),onTouchEnd:v,children:s.jsx("div",{className:"space-y-2",children:m.map(l=>s.jsxs("div",{role:"button",title:l.title,"aria-label":l.title,className:C.cn("text-xs sm:text-sm px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80",l.color?.startsWith("#")?"text-white":l.color||se),style:l.color&&l.color.startsWith("#")?{backgroundColor:l.color}:void 0,onClick:h=>{h.stopPropagation(),c?.(l)},children:[s.jsx("div",{className:"font-medium truncate",children:l.title}),!l.allDay&&s.jsx("div",{className:"text-xs opacity-90 mt-1",children:l.start.toLocaleTimeString("default",{hour:"numeric",minute:"2-digit"})})]},l.id))})},a.toISOString())})})]})}function rt({date:e,events:r,onEventClick:n,onDateClick:c}){const i=Ee(e,r),o=Array.from({length:24},(p,E)=>E),d=V.useRef(null),v=p=>{c&&(d.current=setTimeout(()=>{const E=new Date(e);E.setHours(p,0,0,0),c(E)},500))},y=()=>{d.current&&(clearTimeout(d.current),d.current=null)};return s.jsx("div",{className:"flex flex-col h-full",children:s.jsx("div",{role:"list",className:"flex-1 overflow-auto",children:o.map(p=>{const E=i.filter(a=>a.allDay?p===0:a.start.getHours()===p);return s.jsxs("div",{role:"listitem",className:"flex border-b min-h-[60px]",children:[s.jsx("div",{className:"w-20 p-2 text-sm text-muted-foreground border-r",children:p===0?"12 AM":p<12?`${p} AM`:p===12?"12 PM":`${p-12} PM`}),s.jsx("div",{className:"flex-1 p-2 space-y-2",onTouchStart:()=>v(p),onTouchEnd:y,children:E.map(a=>s.jsxs("div",{title:a.title,"aria-label":a.title,className:C.cn("px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80",a.color?.startsWith("#")?"text-white":a.color||se),style:a.color&&a.color.startsWith("#")?{backgroundColor:a.color}:void 0,onClick:()=>n?.(a),children:[s.jsx("div",{className:"font-medium truncate",children:a.title}),!a.allDay&&s.jsxs("div",{className:"text-xs opacity-90 mt-1",children:[a.start.toLocaleTimeString("default",{hour:"numeric",minute:"2-digit"}),a.end&&` - ${a.end.toLocaleTimeString("default",{hour:"numeric",minute:"2-digit"})}`]})]},a.id))})]},p)})})})}function nt(e){const{onRefresh:r,threshold:n=80,enabled:c=!0}=e,i=g.useRef(null),[o,d]=g.useState(!1),[v,y]=g.useState(0),p=g.useRef(0),E=g.useCallback(l=>{if(!c||o)return;const h=i.current;h&&h.scrollTop===0&&(p.current=l.touches[0].clientY)},[c,o]),a=g.useCallback(l=>{if(!c||o||!p.current)return;const w=l.touches[0].clientY-p.current;w>0&&y(Math.min(w,n*1.5))},[c,o,n]),m=g.useCallback(async()=>{if(!c||o)return;const l=v;if(y(0),p.current=0,l>=n){d(!0);try{await r()}finally{d(!1)}}},[c,o,v,n,r]);return g.useEffect(()=>{const l=i.current;if(!(!l||!c))return l.addEventListener("touchstart",E,{passive:!0}),l.addEventListener("touchmove",a,{passive:!0}),l.addEventListener("touchend",m,{passive:!0}),()=>{l.removeEventListener("touchstart",E),l.removeEventListener("touchmove",a),l.removeEventListener("touchend",m)}},[E,a,m,c]),{ref:i,isRefreshing:o,pullDistance:v}}const at=g.createContext(null);at.displayName="MobileContext";function ot(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 st(e){if(e){if(typeof e=="string"){const r=e.split(" "),n=r[0],c=r[1]?.toLowerCase()==="desc"?"desc":"asc";return{[n]:c}}if(Array.isArray(e))return e.reduce((r,n)=>(n.field&&n.order&&(r[n.field]=n.order),r),{})}}function lt(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}const _e=({schema:e,dataSource:r,className:n,onEventClick:c,onRowClick:i,onDateClick:o,onNavigate:d,onViewChange:v,onEventDrop:y,locale:p,...E})=>{const[a,m]=g.useState([]),[l,h]=g.useState(!0),[w,A]=g.useState(null),[F,M]=g.useState(null),[Y,b]=g.useState(new Date),[O,I]=g.useState("month"),[T,P]=g.useState(0),D=g.useCallback(async()=>{P(N=>N+1)},[]),{ref:f,isRefreshing:_,pullDistance:u}=nt({onRefresh:D,enabled:!!r&&!!e.objectName}),S=g.useMemo(()=>ot(e),[e.data,e.staticData,e.objectName]),L=g.useMemo(()=>lt(e),[e.filter,e.calendar,e.dateField,e.endField,e.titleField,e.colorField]),H=S?.provider==="value",Q=g.useRef(null);Q.current=F,g.useEffect(()=>{let N=!0;return(async()=>{try{if(!N)return;if(h(!0),H&&S?.provider==="value"){N&&(m(S.items),h(!1));return}if(e.data||E.data){const t=e.data||E.data;if(Array.isArray(t)){m(t),h(!1);return}}if(!r||typeof r.find!="function")throw new Error("DataSource required for object/api providers");if(S?.provider==="object"){const t=S.object,x=J.buildExpandFields(Q.current?.fields),j=await r.find(t,{$filter:e.filter,$orderby:st(e.sort),...x.length>0?{$expand:x}:{}});let k=J.extractRecords(j);N&&m(k)}else S?.provider==="api"&&(console.warn("API provider not yet implemented for ObjectCalendar"),N&&m([]));N&&h(!1)}catch(t){console.error("[ObjectCalendar] Error fetching data:",t),N&&(A(t),h(!1))}})(),()=>{N=!1}},[S,r,H,e.filter,e.sort,T]),g.useEffect(()=>{!H&&r&&(async()=>{try{if(!r)return;const $=S?.provider==="object"?S.object:e.objectName;if(!$)return;const t=await r.getObjectSchema($);M(t)}catch($){console.error("Failed to fetch object schema:",$)}})()},[e.objectName,r,H,S]);const re=g.useMemo(()=>{if(!L||!a.length)return[];const{startDateField:N,endDateField:$,titleField:t,colorField:x}=L;return a.map((j,k)=>{const z=j[N],G=$?j[$]:null,R=j[t]||"Untitled",W=x?j[x]:void 0;return{id:j.id||j._id||`event-${k}`,title:R,start:z?new Date(z):new Date,end:G?new Date(G):void 0,color:W,allDay:!G,data:j}}).filter(j=>!isNaN(j.start.getTime()))},[a,L]);g.useCallback(()=>{o?.(new Date)},[o]);const B=ue.useNavigationOverlay({navigation:e.navigation,objectName:e.objectName,onRowClick:i});return l?s.jsx("div",{className:n,children:s.jsx("div",{className:"flex items-center justify-center h-96",children:s.jsx("div",{className:"text-muted-foreground",children:"Loading calendar..."})})}):w?s.jsx("div",{className:n,children:s.jsx("div",{className:"flex items-center justify-center h-96",children:s.jsxs("div",{className:"text-destructive",children:["Error: ",w.message]})})}):L?s.jsxs("div",{ref:f,className:n,children:[u>0&&s.jsx("div",{className:"flex items-center justify-center text-xs text-muted-foreground",style:{height:u},children:_?"Refreshing…":"Pull to refresh"}),s.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:s.jsx(le,{events:re,currentDate:Y,view:e.defaultView||"month",locale:p,onEventClick:N=>{B.handleClick(N.data),c?.(N.data)},onDateClick:o,onNavigate:N=>{b(N),d?.(N)},onViewChange:N=>{I(N),v?.(N)},onAddClick:void 0,onEventDrop:y?(N,$,t)=>{y(N.data,$,t)}:void 0})}),B.isOverlay&&s.jsx(C.NavigationOverlay,{...B,title:"Event Details",children:N=>s.jsx("div",{className:"space-y-3",children:Object.entries(N).map(([$,t])=>s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:$.replace(/_/g," ")}),s.jsx("span",{className:"text-sm",children:String(t??"—")})]},$))})})]}):s.jsx("div",{className:n,children:s.jsx("div",{className:"flex items-center justify-center h-96",children:s.jsx("div",{className:"text-muted-foreground",children:"Calendar configuration required. Please specify startDateField and titleField."})})})};J.ComponentRegistry.register("calendar-view",({schema:e,className:r,onAction:n,...c})=>{const i=g.useMemo(()=>!e.data||!Array.isArray(e.data)?[]:e.data.map((d,v)=>{const y=e.titleField||"title",p=e.startDateField||"start",E=e.endDateField||"end",a=e.colorField||"color",m=e.allDayField||"allDay";return{id:d._id||d.id||v,title:d[y]||"Untitled Event",start:new Date(d[p]),end:d[E]?new Date(d[E]):void 0,allDay:d[m],color:d[a],data:d}}),[e.data,e.titleField,e.startDateField,e.endDateField,e.colorField,e.allDayField]),o=d=>{n?.({type:"event-click",payload:d})};return s.jsx(le,{className:r,events:i,onEventClick:o,...c})},{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"}});const ie=({schema:e,data:r,loading:n,...c})=>{const{dataSource:i}=ue.useSchemaContext()||{};return s.jsx(_e,{schema:e,dataSource:i,...c})};J.ComponentRegistry.register("object-calendar",ie,{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"}]}),J.ComponentRegistry.register("calendar",ie,{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"}]}),U.CalendarView=le,U.ObjectCalendar=_e,U.ObjectCalendarRenderer=ie,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})}));
|
|
6
|
+
<%s key={someKey} {...props} />`,k,R,W,R),$[R+k]=!0)}if(R=null,j!==void 0&&(n(j),R=""+j),d(x)&&(n(x.key),R=""+x.key),"key"in x){j={};for(var ce in x)ce!=="key"&&(j[ce]=x[ce])}else j=x;return R&&v(j,typeof t=="function"?t.displayName||t.name||"Unknown":t),p(t,R,j,i(),z,G)}function a(t){m(t)?t._store&&(t._store.validated=1):typeof t=="object"&&t!==null&&t.$$typeof===D&&(t._payload.status==="fulfilled"?m(t._payload.value)&&t._payload.value._store&&(t._payload.value._store.validated=1):t._store&&(t._store.validated=1))}function m(t){return typeof t=="object"&&t!==null&&t.$$typeof===h}var l=g,h=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),F=Symbol.for("react.strict_mode"),M=Symbol.for("react.profiler"),Y=Symbol.for("react.consumer"),b=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),P=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),_=Symbol.for("react.client.reference"),u=l.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,S=Object.prototype.hasOwnProperty,L=Array.isArray,H=console.createTask?console.createTask:function(){return null};l={react_stack_bottom_frame:function(t){return t()}};var Q,re={},B=l.react_stack_bottom_frame.bind(l,o)(),N=H(c(o)),$={};K.Fragment=A,K.jsx=function(t,x,j){var k=1e4>u.recentlyCreatedOwnerStacks++;return E(t,x,j,!1,k?Error("react-stack-top-frame"):B,k?H(c(t)):N)},K.jsxs=function(t,x,j){var k=1e4>u.recentlyCreatedOwnerStacks++;return E(t,x,j,!0,k?Error("react-stack-top-frame"):B,k?H(c(t)):N)}})()),K}var ge;function Ce(){return ge||(ge=1,process.env.NODE_ENV==="production"?ee.exports=Ne():ee.exports=Oe()),ee.exports}var s=Ce();const Fe=(e,r,n,c)=>{const i=[n,{code:r,...c||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(i,"warn","react-i18next::",!0);q(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...i):console?.warn&&console.warn(...i)},me={},pe=(e,r,n,c)=>{q(n)&&me[n]||(q(n)&&(me[n]=new Date),Fe(e,r,n,c))},he=(e,r)=>()=>{if(e.isInitialized)r();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),r()};e.on("initialized",n)}},ne=(e,r,n)=>{e.loadNamespaces(r,he(e,n))},ye=(e,r,n,c)=>{if(q(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(r)>-1)return ne(e,n,c);n.forEach(i=>{e.options.ns.indexOf(i)<0&&e.options.ns.push(i)}),e.loadLanguages(r,he(e,c))},ke=(e,r,n={})=>!r.languages||!r.languages.length?(pe(r,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:r.languages}),!0):r.hasLoadedNamespace(e,{lng:n.lng,precheck:(c,i)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&c.services.backendConnector.backend&&c.isLanguageChangingTo&&!i(c.isLanguageChangingTo,e))return!1}}),q=e=>typeof e=="string",Le=e=>typeof e=="object"&&e!==null,Ae=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,Re={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},Pe=e=>Re[e];let Ie={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(Ae,Pe),transDefaultProps:void 0};const Me=()=>Ie;let $e;const Ve=()=>$e,Ye=g.createContext();class Ue{constructor(){this.usedNamespaces={}}addUsedNamespaces(r){r.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var te={exports:{}},ae={};var xe;function He(){if(xe)return ae;xe=1;var e=g;function r(a,m){return a===m&&(a!==0||1/a===1/m)||a!==a&&m!==m}var n=typeof Object.is=="function"?Object.is:r,c=e.useState,i=e.useEffect,o=e.useLayoutEffect,d=e.useDebugValue;function v(a,m){var l=m(),h=c({inst:{value:l,getSnapshot:m}}),w=h[0].inst,A=h[1];return o(function(){w.value=l,w.getSnapshot=m,y(w)&&A({inst:w})},[a,l,m]),i(function(){return y(w)&&A({inst:w}),a(function(){y(w)&&A({inst:w})})},[a]),d(l),l}function y(a){var m=a.getSnapshot;a=a.value;try{var l=m();return!n(a,l)}catch{return!0}}function p(a,m){return m()}var E=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?p:v;return ae.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:E,ae}var oe={};var be;function We(){return be||(be=1,process.env.NODE_ENV!=="production"&&(function(){function e(l,h){return l===h&&(l!==0||1/l===1/h)||l!==l&&h!==h}function r(l,h){E||i.startTransition===void 0||(E=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var w=h();if(!a){var A=h();o(w,A)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),a=!0)}A=d({inst:{value:w,getSnapshot:h}});var F=A[0].inst,M=A[1];return y(function(){F.value=w,F.getSnapshot=h,n(F)&&M({inst:F})},[l,w,h]),v(function(){return n(F)&&M({inst:F}),l(function(){n(F)&&M({inst:F})})},[l]),p(w),w}function n(l){var h=l.getSnapshot;l=l.value;try{var w=h();return!o(l,w)}catch{return!0}}function c(l,h){return h()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var i=g,o=typeof Object.is=="function"?Object.is:e,d=i.useState,v=i.useEffect,y=i.useLayoutEffect,p=i.useDebugValue,E=!1,a=!1,m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:r;oe.useSyncExternalStore=i.useSyncExternalStore!==void 0?i.useSyncExternalStore:m,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),oe}var ve;function qe(){return ve||(ve=1,process.env.NODE_ENV==="production"?te.exports=He():te.exports=We()),te.exports}var ze=qe();const Ge={t:(e,r)=>q(r)?r:Le(r)&&q(r.defaultValue)?r.defaultValue:Array.isArray(e)?e[e.length-1]:e,ready:!1},Be=()=>()=>{},Je=(e,r={})=>{const{i18n:n}=r,{i18n:c,defaultNS:i}=g.useContext(Ye)||{},o=n||c||Ve();o&&!o.reportNamespaces&&(o.reportNamespaces=new Ue),o||pe(o,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const d=g.useMemo(()=>({...Me(),...o?.options?.react,...r}),[o,r]),{useSuspense:v,keyPrefix:y}=d,p=i||o?.options?.defaultNS,E=q(p)?[p]:p||["translation"],a=g.useMemo(()=>E,E);o?.reportNamespaces?.addUsedNamespaces?.(a);const m=g.useRef(0),l=g.useCallback(D=>{if(!o)return Be;const{bindI18n:f,bindI18nStore:_}=d,u=()=>{m.current+=1,D()};return f&&o.on(f,u),_&&o.store.on(_,u),()=>{f&&f.split(" ").forEach(S=>o.off(S,u)),_&&_.split(" ").forEach(S=>o.store.off(S,u))}},[o,d]),h=g.useRef(),w=g.useCallback(()=>{if(!o)return Ge;const D=!!(o.isInitialized||o.initializedStoreOnce)&&a.every(H=>ke(H,o,d)),f=r.lng||o.language,_=m.current,u=h.current;if(u&&u.ready===D&&u.lng===f&&u.keyPrefix===y&&u.revision===_)return u;const L={t:o.getFixedT(f,d.nsMode==="fallback"?a:a[0],y),ready:D,lng:f,keyPrefix:y,revision:_};return h.current=L,L},[o,a,y,d,r.lng]),[A,F]=g.useState(0),{t:M,ready:Y}=ze.useSyncExternalStore(l,w,w);g.useEffect(()=>{if(o&&!Y&&!v){const D=()=>F(f=>f+1);r.lng?ye(o,r.lng,a,D):ne(o,a,D)}},[o,r.lng,a,Y,v,A]);const b=o||{},O=g.useRef(null),I=g.useRef(),T=D=>{const f=Object.getOwnPropertyDescriptors(D);f.__original&&delete f.__original;const _=Object.create(Object.getPrototypeOf(D),f);if(!Object.prototype.hasOwnProperty.call(_,"__original"))try{Object.defineProperty(_,"__original",{value:D,writable:!1,enumerable:!1,configurable:!1})}catch{}return _},P=g.useMemo(()=>{const D=b,f=D?.language;let _=D;D&&(O.current&&O.current.__original===D?I.current!==f?(_=T(D),O.current=_,I.current=f):_=O.current:(_=T(D),O.current=_,I.current=f));const u=[M,_,Y];return u.t=M,u.i18n=_,u.ready=Y,u},[M,b,Y,b.resolvedLanguage,b.language,b.languages]);if(o&&v&&!Y)throw new Promise(D=>{const f=()=>D();r.lng?ye(o,r.lng,a,f):ne(o,a,f)});return P},Xe=g.createContext(null);function Ke(e){const r=g.useContext(Xe),{t:n,i18n:c}=Je();return{t:n,language:r?.language||c.language||"en",changeLanguage:r?.changeLanguage||(async i=>{await c.changeLanguage(i)}),direction:r?.direction||"ltr",i18n:c}}const se="bg-blue-500 text-white",Qe=new Date,De={"calendar.today":"Today","calendar.month":"Month","calendar.week":"Week","calendar.day":"Day","calendar.newEvent":"New event","calendar.moreEvents":"+{{count}} more"};function we(){try{const e=Ke();return e.t("calendar.today")==="calendar.today"?{t:(n,c)=>{let i=De[n]||n;if(c)for(const[o,d]of Object.entries(c))i=i.replace(`{{${o}}}`,String(d));return i},language:"en"}:{t:e.t,language:e.language}}catch{return{t:(e,r)=>{let n=De[e]||e;if(r)for(const[c,i]of Object.entries(r))n=n.replace(`{{${c}}}`,String(i));return n},language:"en"}}}function le({events:e=[],view:r="month",currentDate:n=Qe,locale:c="default",onEventClick:i,onDateClick:o,onViewChange:d,onNavigate:v,onAddClick:y,onEventDrop:p,className:E}){const[a,m]=V.useState(r),[l,h]=V.useState(n),{t:w,language:A}=we(),F=c!=="default"?c:A;V.useEffect(()=>{h(n)},[n]),V.useEffect(()=>{m(r)},[r]);const M=V.useRef(d);M.current=d,V.useEffect(()=>{const u=window.matchMedia("(max-width: 639px)"),S=L=>{L.matches&&(m("day"),M.current?.("day"))};return S(u),u.addEventListener("change",S),()=>u.removeEventListener("change",S)},[]);const Y=()=>{const u=new Date(l);a==="month"?u.setMonth(u.getMonth()-1):a==="week"?u.setDate(u.getDate()-7):u.setDate(u.getDate()-1),h(u),v?.(u)},b=()=>{const u=new Date(l);a==="month"?u.setMonth(u.getMonth()+1):a==="week"?u.setDate(u.getDate()+7):u.setDate(u.getDate()+1),h(u),v?.(u)},O=()=>{const u=new Date;h(u),v?.(u)},I=u=>{m(u),d?.(u)},T=()=>{if(a==="month")return l.toLocaleDateString(F,{month:"long",year:"numeric"});if(a==="week"){const u=Se(l),S=new Date(u);return S.setDate(S.getDate()+6),`${u.toLocaleDateString(F,{month:"short",day:"numeric"})} - ${S.toLocaleDateString(F,{month:"short",day:"numeric",year:"numeric"})}`}else return l.toLocaleDateString(F,{weekday:"long",month:"long",day:"numeric",year:"numeric"})},P=V.useRef(0),D=u=>{P.current=u.touches[0].clientX},f=u=>{const S=P.current-u.changedTouches[0].clientX;if(Math.abs(S)>50){const L=new Date(l);a==="day"?L.setDate(L.getDate()+(S>0?1:-1)):a==="week"?L.setDate(L.getDate()+(S>0?7:-7)):L.setMonth(L.getMonth()+(S>0?1:-1)),h(L),v?.(L)}},_=u=>{u&&(h(u),v?.(u))};return s.jsxs("div",{role:"region","aria-label":"Calendar",className:C.cn("flex flex-col h-full bg-background min-w-0 overflow-hidden",E),children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 p-2 sm:p-4 border-b min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("div",{className:"flex items-center bg-muted/50 rounded-lg p-1 gap-1",children:[s.jsx(C.Button,{variant:"ghost",size:"sm",onClick:O,className:"h-8","aria-label":"Go to today",children:w("calendar.today")}),s.jsx("div",{className:"h-4 w-px bg-border mx-1"}),s.jsx(C.Button,{variant:"ghost",size:"icon","aria-label":"Previous period",onClick:Y,className:"h-8 w-8",children:s.jsx(Z.ChevronLeftIcon,{className:"h-4 w-4"})}),s.jsx(C.Button,{variant:"ghost",size:"icon","aria-label":"Next period",onClick:b,className:"h-8 w-8",children:s.jsx(Z.ChevronRightIcon,{className:"h-4 w-4"})})]}),s.jsxs(C.Popover,{children:[s.jsx(C.PopoverTrigger,{asChild:!0,children:s.jsxs(C.Button,{variant:"ghost","aria-label":`Current date: ${T()}`,className:C.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:[s.jsx(Z.CalendarIcon,{className:"h-5 w-5 text-muted-foreground"}),s.jsx("span",{children:T()})]})}),s.jsx(C.PopoverContent,{className:"w-auto p-0",align:"start",children:s.jsx(C.Calendar,{mode:"single",selected:l,onSelect:_,initialFocus:!0,fromYear:2e3,toYear:2050})})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(C.Select,{value:a,onValueChange:I,children:[s.jsx(C.SelectTrigger,{className:"w-32 bg-background",children:s.jsx(C.SelectValue,{})}),s.jsxs(C.SelectContent,{children:[s.jsx(C.SelectItem,{value:"day",children:w("calendar.day")}),s.jsx(C.SelectItem,{value:"week",children:w("calendar.week")}),s.jsx(C.SelectItem,{value:"month",children:w("calendar.month")})]})]}),y&&s.jsxs(C.Button,{onClick:y,size:"sm",className:"gap-1",children:[s.jsx(Z.PlusIcon,{className:"h-4 w-4"}),w("calendar.newEvent")]})]})]}),s.jsxs("div",{className:"flex-1 overflow-auto",onTouchStart:D,onTouchEnd:f,children:[a==="month"&&s.jsx(et,{date:l,events:e,locale:F,onEventClick:i,onDateClick:o,onEventDrop:p}),a==="week"&&s.jsx(tt,{date:l,events:e,locale:F,onEventClick:i,onDateClick:o}),a==="day"&&s.jsx(rt,{date:l,events:e,onEventClick:i,onDateClick:o})]})]})}function Se(e){const r=new Date(e),n=r.getDay(),c=r.getDate()-n;return r.setDate(c),r}function Ze(e){const r=e.getFullYear(),n=e.getMonth(),c=new Date(r,n,1),i=new Date(r,n+1,0),o=c.getDay(),d=[];for(let y=o-1;y>=0;y--){const p=new Date(c.getTime());p.setDate(p.getDate()-(y+1)),d.push(p)}for(let y=1;y<=i.getDate();y++)d.push(new Date(r,n,y));const v=42-d.length;for(let y=1;y<=v;y++){const p=new Date(i.getTime());p.setDate(p.getDate()+y),d.push(p)}return d}function je(e,r){return e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth()&&e.getDate()===r.getDate()}function Ee(e,r){return r.filter(n=>{const c=new Date(n.start),i=n.end?new Date(n.end):new Date(c),o=new Date(e);o.setHours(0,0,0,0);const d=new Date(e);d.setHours(23,59,59,999);const v=new Date(c);v.setHours(0,0,0,0);const y=new Date(i);return y.setHours(23,59,59,999),o<=y&&d>=v})}function et({date:e,events:r,locale:n="default",onEventClick:c,onDateClick:i,onEventDrop:o}){const d=V.useMemo(()=>Ze(e),[e.getFullYear(),e.getMonth()]),v=V.useMemo(()=>new Date,[]),{t:y}=we(),p=V.useMemo(()=>{const b=new Date(2024,0,7);return Array.from({length:7},(O,I)=>{const T=new Date(b);return T.setDate(T.getDate()+I),T.toLocaleDateString(n,{weekday:"short"})})},[n]),[E,a]=V.useState(null),[m,l]=V.useState(null),h=V.useMemo(()=>{const b=new Map;for(const O of r){const I=new Date(O.start),T=O.end?new Date(O.end):new Date(I);I.setHours(0,0,0,0),T.setHours(0,0,0,0);const P=new Date(I);for(;P<=T;){const D=`${P.getFullYear()}-${P.getMonth()}-${P.getDate()}`,f=b.get(D);f?f.push(O):b.set(D,[O]),P.setDate(P.getDate()+1)}}return b},[r]),w=(b,O)=>{a(O.id),b.dataTransfer.effectAllowed="move",b.dataTransfer.setData("text/plain",String(O.id))},A=()=>{a(null),l(null)},F=(b,O)=>{b.preventDefault(),b.dataTransfer.dropEffect="move",l(O)},M=b=>{b.currentTarget.contains(b.relatedTarget)||l(null)},Y=(b,O)=>{if(b.preventDefault(),l(null),a(null),!o)return;const I=b.dataTransfer.getData("text/plain"),T=r.find(L=>String(L.id)===I);if(!T)return;const P=new Date(T.start),D=new Date(P);D.setHours(0,0,0,0);const f=new Date(O);f.setHours(0,0,0,0);const _=f.getTime()-D.getTime();if(_===0)return;const u=new Date(P.getTime()+_);let S;T.end&&(S=new Date(new Date(T.end).getTime()+_)),o(T,u,S)};return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsx("div",{role:"row",className:"grid grid-cols-7 border-b",children:p.map(b=>s.jsx("div",{role:"columnheader",className:"p-2 text-center text-sm font-medium text-muted-foreground border-r last:border-r-0",children:b},b))}),s.jsx("div",{role:"grid","aria-label":"Calendar grid",className:"grid grid-cols-7 flex-1 auto-rows-fr",children:d.map((b,O)=>{const I=`${b.getFullYear()}-${b.getMonth()}-${b.getDate()}`,T=h.get(I)||[],P=b.getMonth()===e.getMonth(),D=je(b,v);return s.jsxs("div",{role:"gridcell","aria-label":`${b.toLocaleDateString("default",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}${T.length>0?`, ${T.length} event${T.length>1?"s":""}`:""}`,className:C.cn("border-b border-r last:border-r-0 p-2 min-h-[100px] cursor-pointer hover:bg-accent/50",!P&&"bg-muted/50 text-muted-foreground opacity-50",m===O&&"ring-2 ring-primary"),onClick:()=>i?.(b),onDragOver:f=>F(f,O),onDragLeave:M,onDrop:f=>Y(f,b),children:[s.jsx("div",{className:C.cn("text-sm font-medium mb-2",D&&"inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-6 w-6"),...D?{"aria-current":"date"}:{},children:b.getDate()}),s.jsxs("div",{className:"space-y-1",children:[T.slice(0,3).map(f=>s.jsx("div",{role:"button",title:f.title,"aria-label":f.title,draggable:!!o,onDragStart:_=>w(_,f),onDragEnd:A,className:C.cn("text-xs px-2 py-1 rounded truncate cursor-pointer hover:opacity-80",f.color?.startsWith("#")?"text-white":f.color||se,E===f.id&&"opacity-50"),style:f.color&&f.color.startsWith("#")?{backgroundColor:f.color}:void 0,onClick:_=>{_.stopPropagation(),c?.(f)},children:f.title},f.id)),T.length>3&&s.jsx("div",{className:"text-xs text-muted-foreground px-2",children:y("calendar.moreEvents",{count:T.length-3})})]})]},O)})})]})}function tt({date:e,events:r,locale:n="default",onEventClick:c,onDateClick:i}){const o=V.useRef(null),d=a=>{i&&(o.current=setTimeout(()=>{i(a)},500))},v=()=>{o.current&&(clearTimeout(o.current),o.current=null)},y=Se(e),p=Array.from({length:7},(a,m)=>{const l=new Date(y);return l.setDate(l.getDate()+m),l}),E=new Date;return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsx("div",{className:"grid grid-cols-7 border-b",children:p.map(a=>{const m=je(a,E);return s.jsxs("div",{className:"p-3 text-center border-r last:border-r-0",children:[s.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:a.toLocaleDateString(n,{weekday:"short"})}),s.jsx("div",{className:C.cn("text-lg font-semibold mt-1",m&&"inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-8 w-8"),children:a.getDate()})]},a.toISOString())})}),s.jsx("div",{role:"grid",className:"grid grid-cols-7 flex-1",children:p.map(a=>{const m=Ee(a,r);return s.jsx("div",{role:"gridcell","aria-label":`${a.toLocaleDateString("default",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}${m.length>0?`, ${m.length} event${m.length>1?"s":""}`:""}`,className:"border-r last:border-r-0 p-2 min-h-[400px] cursor-pointer hover:bg-accent/50",onClick:()=>i?.(a),onTouchStart:()=>d(a),onTouchEnd:v,children:s.jsx("div",{className:"space-y-2",children:m.map(l=>s.jsxs("div",{role:"button",title:l.title,"aria-label":l.title,className:C.cn("text-xs sm:text-sm px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80",l.color?.startsWith("#")?"text-white":l.color||se),style:l.color&&l.color.startsWith("#")?{backgroundColor:l.color}:void 0,onClick:h=>{h.stopPropagation(),c?.(l)},children:[s.jsx("div",{className:"font-medium truncate",children:l.title}),!l.allDay&&s.jsx("div",{className:"text-xs opacity-90 mt-1",children:l.start.toLocaleTimeString("default",{hour:"numeric",minute:"2-digit"})})]},l.id))})},a.toISOString())})})]})}function rt({date:e,events:r,onEventClick:n,onDateClick:c}){const i=Ee(e,r),o=Array.from({length:24},(p,E)=>E),d=V.useRef(null),v=p=>{c&&(d.current=setTimeout(()=>{const E=new Date(e);E.setHours(p,0,0,0),c(E)},500))},y=()=>{d.current&&(clearTimeout(d.current),d.current=null)};return s.jsx("div",{className:"flex flex-col h-full",children:s.jsx("div",{role:"list",className:"flex-1 overflow-auto",children:o.map(p=>{const E=i.filter(a=>a.allDay?p===0:a.start.getHours()===p);return s.jsxs("div",{role:"listitem",className:"flex border-b min-h-[60px]",children:[s.jsx("div",{className:"w-20 p-2 text-sm text-muted-foreground border-r",children:p===0?"12 AM":p<12?`${p} AM`:p===12?"12 PM":`${p-12} PM`}),s.jsx("div",{className:"flex-1 p-2 space-y-2",onTouchStart:()=>v(p),onTouchEnd:y,children:E.map(a=>s.jsxs("div",{title:a.title,"aria-label":a.title,className:C.cn("px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80",a.color?.startsWith("#")?"text-white":a.color||se),style:a.color&&a.color.startsWith("#")?{backgroundColor:a.color}:void 0,onClick:()=>n?.(a),children:[s.jsx("div",{className:"font-medium truncate",children:a.title}),!a.allDay&&s.jsxs("div",{className:"text-xs opacity-90 mt-1",children:[a.start.toLocaleTimeString("default",{hour:"numeric",minute:"2-digit"}),a.end&&` - ${a.end.toLocaleTimeString("default",{hour:"numeric",minute:"2-digit"})}`]})]},a.id))})]},p)})})})}function nt(e){const{onRefresh:r,threshold:n=80,enabled:c=!0}=e,i=g.useRef(null),[o,d]=g.useState(!1),[v,y]=g.useState(0),p=g.useRef(0),E=g.useCallback(l=>{if(!c||o)return;const h=i.current;h&&h.scrollTop===0&&(p.current=l.touches[0].clientY)},[c,o]),a=g.useCallback(l=>{if(!c||o||!p.current)return;const w=l.touches[0].clientY-p.current;w>0&&y(Math.min(w,n*1.5))},[c,o,n]),m=g.useCallback(async()=>{if(!c||o)return;const l=v;if(y(0),p.current=0,l>=n){d(!0);try{await r()}finally{d(!1)}}},[c,o,v,n,r]);return g.useEffect(()=>{const l=i.current;if(!(!l||!c))return l.addEventListener("touchstart",E,{passive:!0}),l.addEventListener("touchmove",a,{passive:!0}),l.addEventListener("touchend",m,{passive:!0}),()=>{l.removeEventListener("touchstart",E),l.removeEventListener("touchmove",a),l.removeEventListener("touchend",m)}},[E,a,m,c]),{ref:i,isRefreshing:o,pullDistance:v}}const at=g.createContext(null);at.displayName="MobileContext";function ot(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 st(e){if(e){if(typeof e=="string"){const r=e.split(" "),n=r[0],c=r[1]?.toLowerCase()==="desc"?"desc":"asc";return{[n]:c}}if(Array.isArray(e))return e.reduce((r,n)=>(n.field&&n.order&&(r[n.field]=n.order),r),{})}}function lt(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}const _e=({schema:e,dataSource:r,className:n,onEventClick:c,onRowClick:i,onDateClick:o,onNavigate:d,onViewChange:v,onEventDrop:y,locale:p,...E})=>{const[a,m]=g.useState([]),[l,h]=g.useState(!0),[w,A]=g.useState(null),[F,M]=g.useState(null),[Y,b]=g.useState(new Date),[O,I]=g.useState("month"),[T,P]=g.useState(0),D=g.useCallback(async()=>{P(N=>N+1)},[]),{ref:f,isRefreshing:_,pullDistance:u}=nt({onRefresh:D,enabled:!!r&&!!e.objectName}),S=g.useMemo(()=>ot(e),[e.data,e.staticData,e.objectName]),L=g.useMemo(()=>lt(e),[e.filter,e.calendar,e.dateField,e.endField,e.titleField,e.colorField]),H=S?.provider==="value",Q=g.useRef(null);Q.current=F,g.useEffect(()=>{let N=!0;return(async()=>{try{if(!N)return;if(h(!0),H&&S?.provider==="value"){N&&(m(S.items),h(!1));return}if(e.data||E.data){const t=e.data||E.data;if(Array.isArray(t)){m(t),h(!1);return}}if(!r||typeof r.find!="function")throw new Error("DataSource required for object/api providers");if(S?.provider==="object"){const t=S.object,x=J.buildExpandFields(Q.current?.fields),j=await r.find(t,{$filter:e.filter,$orderby:st(e.sort),...x.length>0?{$expand:x}:{}});let k=J.extractRecords(j);N&&m(k)}else S?.provider==="api"&&(console.warn("API provider not yet implemented for ObjectCalendar"),N&&m([]));N&&h(!1)}catch(t){console.error("[ObjectCalendar] Error fetching data:",t),N&&(A(t),h(!1))}})(),()=>{N=!1}},[S,r,H,e.filter,e.sort,T]),g.useEffect(()=>{!H&&r&&(async()=>{try{if(!r)return;const $=S?.provider==="object"?S.object:e.objectName;if(!$)return;const t=await r.getObjectSchema($);M(t)}catch($){console.error("Failed to fetch object schema:",$)}})()},[e.objectName,r,H,S]);const re=g.useMemo(()=>{if(!L||!a.length)return[];const{startDateField:N,endDateField:$,titleField:t,colorField:x}=L;return a.map((j,k)=>{const z=j[N],G=$?j[$]:null,R=j[t]||"Untitled",W=x?j[x]:void 0;return{id:j.id||j._id||`event-${k}`,title:R,start:z?new Date(z):new Date,end:G?new Date(G):void 0,color:W,allDay:!G,data:j}}).filter(j=>!isNaN(j.start.getTime()))},[a,L]);g.useCallback(()=>{o?.(new Date)},[o]);const B=ue.useNavigationOverlay({navigation:e.navigation,objectName:e.objectName,onRowClick:i});return l?s.jsx("div",{className:n,children:s.jsx("div",{className:"flex items-center justify-center h-96",children:s.jsx("div",{className:"text-muted-foreground",children:"Loading calendar..."})})}):w?s.jsx("div",{className:n,children:s.jsx("div",{className:"flex items-center justify-center h-96",children:s.jsxs("div",{className:"text-destructive",children:["Error: ",w.message]})})}):L?s.jsxs("div",{ref:f,className:n,children:[u>0&&s.jsx("div",{className:"flex items-center justify-center text-xs text-muted-foreground",style:{height:u},children:_?"Refreshing…":"Pull to refresh"}),s.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:s.jsx(le,{events:re,currentDate:Y,view:e.defaultView||"month",locale:p,onEventClick:N=>{B.handleClick(N.data),c?.(N.data)},onDateClick:o,onNavigate:N=>{b(N),d?.(N)},onViewChange:N=>{I(N),v?.(N)},onAddClick:void 0,onEventDrop:y?(N,$,t)=>{y(N.data,$,t)}:void 0})}),B.isOverlay&&s.jsx(C.NavigationOverlay,{...B,title:"Event Details",children:N=>s.jsx("div",{className:"space-y-3",children:Object.entries(N).map(([$,t])=>s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:$.replace(/_/g," ")}),s.jsx("span",{className:"text-sm",children:String(t??"—")})]},$))})})]}):s.jsx("div",{className:n,children:s.jsx("div",{className:"flex items-center justify-center h-96",children:s.jsx("div",{className:"text-muted-foreground",children:"Calendar configuration required. Please specify startDateField and titleField."})})})};J.ComponentRegistry.register("calendar-view",({schema:e,className:r,onAction:n,...c})=>{const i=g.useMemo(()=>!e.data||!Array.isArray(e.data)?[]:e.data.map((d,v)=>{const y=e.titleField||"title",p=e.startDateField||"start",E=e.endDateField||"end",a=e.colorField||"color",m=e.allDayField||"allDay";return{id:d.id||d._id||v,title:d[y]||"Untitled Event",start:new Date(d[p]),end:d[E]?new Date(d[E]):void 0,allDay:d[m],color:d[a],data:d}}),[e.data,e.titleField,e.startDateField,e.endDateField,e.colorField,e.allDayField]),o=d=>{n?.({type:"event-click",payload:d})};return s.jsx(le,{className:r,events:i,onEventClick:o,...c})},{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"}});const ie=({schema:e,data:r,loading:n,...c})=>{const{dataSource:i}=ue.useSchemaContext()||{};return s.jsx(_e,{schema:e,dataSource:i,...c})};J.ComponentRegistry.register("object-calendar",ie,{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"}]}),J.ComponentRegistry.register("calendar",ie,{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"}]}),U.CalendarView=le,U.ObjectCalendar=_e,U.ObjectCalendarRenderer=ie,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/plugin-calendar",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.3",
|
|
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": "^0.
|
|
28
|
-
"@object-ui/components": "3.1.
|
|
29
|
-
"@object-ui/core": "3.1.
|
|
30
|
-
"@object-ui/fields": "3.1.
|
|
31
|
-
"@object-ui/i18n": "3.1.
|
|
32
|
-
"@object-ui/mobile": "3.1.
|
|
33
|
-
"@object-ui/react": "3.1.
|
|
34
|
-
"@object-ui/types": "3.1.
|
|
27
|
+
"lucide-react": "^0.577.0",
|
|
28
|
+
"@object-ui/components": "3.1.3",
|
|
29
|
+
"@object-ui/core": "3.1.3",
|
|
30
|
+
"@object-ui/fields": "3.1.3",
|
|
31
|
+
"@object-ui/i18n": "3.1.3",
|
|
32
|
+
"@object-ui/mobile": "3.1.3",
|
|
33
|
+
"@object-ui/react": "3.1.3",
|
|
34
|
+
"@object-ui/types": "3.1.3"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"typescript": "^5.9.3",
|
|
45
45
|
"vite": "^7.3.1",
|
|
46
46
|
"vite-plugin-dts": "^4.5.4",
|
|
47
|
-
"@object-ui/data-objectstack": "3.1.
|
|
47
|
+
"@object-ui/data-objectstack": "3.1.3"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "vite build",
|
|
@@ -18,14 +18,14 @@ todayAtNoon.setHours(12, 0, 0, 0);
|
|
|
18
18
|
const mockEvents = {
|
|
19
19
|
value: [
|
|
20
20
|
{
|
|
21
|
-
|
|
21
|
+
id: '1',
|
|
22
22
|
title: 'Meeting with Client',
|
|
23
23
|
start: todayAtNoon.toISOString(),
|
|
24
24
|
end: new Date(todayAtNoon.getTime() + 3600000).toISOString(),
|
|
25
25
|
type: 'business'
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
|
-
|
|
28
|
+
id: '2',
|
|
29
29
|
title: 'Team Lunch',
|
|
30
30
|
start: new Date(todayAtNoon.getTime() + 86400000).toISOString(), // Tomorrow
|
|
31
31
|
type: 'personal'
|
|
@@ -31,7 +31,7 @@ ComponentRegistry.register('calendar-view',
|
|
|
31
31
|
const allDayField = schema.allDayField || 'allDay';
|
|
32
32
|
|
|
33
33
|
return {
|
|
34
|
-
id: record.
|
|
34
|
+
id: record.id || record._id || index,
|
|
35
35
|
title: record[titleField] || 'Untitled Event',
|
|
36
36
|
start: new Date(record[startField]),
|
|
37
37
|
end: record[endField] ? new Date(record[endField]) : undefined,
|