@object-ui/plugin-calendar 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +9 -9
- package/CHANGELOG.md +22 -0
- package/dist/index.js +633 -488
- package/dist/index.umd.cjs +2 -2
- package/dist/src/CalendarView.d.ts +2 -1
- package/dist/src/CalendarView.d.ts.map +1 -1
- package/dist/src/ObjectCalendar.d.ts +1 -0
- package/dist/src/ObjectCalendar.d.ts.map +1 -1
- package/dist/src/ObjectCalendar.stories.d.ts +23 -0
- package/dist/src/ObjectCalendar.stories.d.ts.map +1 -0
- package/package.json +11 -10
- package/src/CalendarView.tsx +178 -18
- package/src/ObjectCalendar.stories.tsx +82 -0
- package/src/ObjectCalendar.tsx +54 -4
- package/src/__tests__/accessibility.test.tsx +290 -0
- package/src/__tests__/performance-benchmark.test.tsx +227 -0
- package/src/__tests__/view-states.test.tsx +377 -0
package/dist/index.umd.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(A,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("react"),require("@object-ui/core"),require("@object-ui/react"),require("lucide-react"),require("@object-ui/components")):typeof define=="function"&&define.amd?define(["exports","react","@object-ui/core","@object-ui/react","lucide-react","@object-ui/components"],p):(A=typeof globalThis<"u"?globalThis:A||self,p(A.ObjectUIPluginCalendar={},A.React,A.ObjectUICore,A.ObjectUIReact,A.LucideReact,A.ObjectUIComponents))})(this,(function(A,p,K,oe,Q,v){"use strict";function me(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const l in t)if(l!=="default"){const s=Object.getOwnPropertyDescriptor(t,l);Object.defineProperty(n,l,s.get?s:{enumerable:!0,get:()=>t[l]})}}return n.default=t,Object.freeze(n)}const L=me(p);var Z={exports:{}},J={};var ie;function ge(){if(ie)return J;ie=1;var t=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function l(s,m,c){var g=null;if(c!==void 0&&(g=""+c),m.key!==void 0&&(g=""+m.key),"key"in m){c={};for(var u in m)u!=="key"&&(c[u]=m[u])}else c=m;return m=c.ref,{$$typeof:t,type:s,key:g,ref:m!==void 0?m:null,props:c}}return J.Fragment=n,J.jsx=l,J.jsxs=l,J}var B={};var se;function he(){return se||(se=1,process.env.NODE_ENV!=="production"&&(function(){function t(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===j?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case V:return"Fragment";case F:return"Profiler";case x:return"StrictMode";case S:return"Suspense";case I:return"SuspenseList";case T:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case $:return"Portal";case _:return e.displayName||"Context";case P:return(e._context.displayName||"Context")+".Consumer";case M:var f=e.render;return e=e.displayName,e||(e=f.displayName||f.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Y:return f=e.displayName||null,f!==null?f:t(e.type)||"Memo";case i:f=e._payload,e=e._init;try{return t(e(f))}catch{}}return null}function n(e){return""+e}function l(e){try{n(e);var f=!1}catch{f=!0}if(f){f=console;var w=f.error,E=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return w.call(f,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",E),n(e)}}function s(e){if(e===V)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===i)return"<...>";try{var f=t(e);return f?"<"+f+">":"<...>"}catch{return"<...>"}}function m(){var e=W.A;return e===null?null:e.getOwner()}function c(){return Error("react-stack-top-frame")}function g(e){if(q.call(e,"key")){var f=Object.getOwnPropertyDescriptor(e,"key").get;if(f&&f.isReactWarning)return!1}return e.key!==void 0}function u(e,f){function w(){U||(U=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",f))}w.isReactWarning=!0,Object.defineProperty(e,"key",{get:w,configurable:!0})}function h(){var e=t(this.type);return D[e]||(D[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function d(e,f,w,E,H,X){var C=w.ref;return e={$$typeof:N,type:e,key:f,props:w,_owner:E},(C!==void 0?C:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:h}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:H}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:X}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function y(e,f,w,E,H,X){var C=f.children;if(C!==void 0)if(E)if(ne(C)){for(E=0;E<C.length;E++)a(C[E]);Object.freeze&&Object.freeze(C)}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.");else a(C);if(q.call(f,"key")){C=t(e);var z=Object.keys(f).filter(function(Te){return Te!=="key"});E=0<z.length?"{key: someKey, "+z.join(": ..., ")+": ...}":"{key: someKey}",R[C+E]||(z=0<z.length?"{"+z.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
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} />`,D,v,R,v),ue[v+D]=!0)}if(v=null,x!==void 0&&(l(x),v=""+x),m(o)&&(l(o.key),v=""+o.key),"key"in o){x={};for(var ae in o)ae!=="key"&&(x[ae]=o[ae])}else x=o;return v&&a(x,typeof t=="function"?t.displayName||t.name||"Unknown":t),c(t,v,x,f(),J,re)}function w(t){g(t)?t._store&&(t._store.validated=1):typeof t=="object"&&t!==null&&t.$$typeof===b&&(t._payload.status==="fulfilled"?g(t._payload.value)&&t._payload.value._store&&(t._payload.value._store.validated=1):t._store&&(t._store.validated=1))}function g(t){return typeof t=="object"&&t!==null&&t.$$typeof===I}var S=j,I=Symbol.for("react.transitional.element"),V=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),q=Symbol.for("react.profiler"),Y=Symbol.for("react.consumer"),i=Symbol.for("react.context"),F=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),K=Symbol.for("react.suspense_list"),ee=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),C=Symbol.for("react.client.reference"),E=S.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,h=Object.prototype.hasOwnProperty,te=Array.isArray,O=console.createTask?console.createTask:function(){return null};S={react_stack_bottom_frame:function(t){return t()}};var A,z={},H=S.react_stack_bottom_frame.bind(S,s)(),de=O(u(s)),ue={};M.Fragment=k,M.jsx=function(t,o,x){var D=1e4>E.recentlyCreatedOwnerStacks++;return y(t,o,x,!1,D?Error("react-stack-top-frame"):H,D?O(u(t)):de)},M.jsxs=function(t,o,x){var D=1e4>E.recentlyCreatedOwnerStacks++;return y(t,o,x,!0,D?Error("react-stack-top-frame"):H,D?O(u(t)):de)}})()),M}var ie;function be(){return ie||(ie=1,process.env.NODE_ENV==="production"?U.exports=ge():U.exports=pe()),U.exports}var r=be();const G="bg-blue-500 text-white";function X({events:e=[],view:n="month",currentDate:l=new Date,locale:u="default",onEventClick:f,onDateClick:s,onViewChange:m,onNavigate:a,onAddClick:d,className:c}){const[y,w]=W.useState(n),[g,S]=W.useState(l);W.useEffect(()=>{S(l)},[l]),W.useEffect(()=>{w(n)},[n]);const I=()=>{const i=new Date(g);y==="month"?i.setMonth(i.getMonth()-1):y==="week"?i.setDate(i.getDate()-7):i.setDate(i.getDate()-1),S(i),a?.(i)},V=()=>{const i=new Date(g);y==="month"?i.setMonth(i.getMonth()+1):y==="week"?i.setDate(i.getDate()+7):i.setDate(i.getDate()+1),S(i),a?.(i)},k=()=>{const i=new Date;S(i),a?.(i)},L=i=>{w(i),m?.(i)},q=()=>{if(y==="month")return g.toLocaleDateString(u,{month:"long",year:"numeric"});if(y==="week"){const i=oe(g),F=new Date(i);return F.setDate(F.getDate()+6),`${i.toLocaleDateString(u,{month:"short",day:"numeric"})} - ${F.toLocaleDateString(u,{month:"short",day:"numeric",year:"numeric"})}`}else return g.toLocaleDateString(u,{weekday:"long",month:"long",day:"numeric",year:"numeric"})},Y=i=>{i&&(S(i),a?.(i))};return r.jsxs("div",{className:p.cn("flex flex-col h-full bg-background",c),children:[r.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs("div",{className:"flex items-center bg-muted/50 rounded-lg p-1 gap-1",children:[r.jsx(p.Button,{variant:"ghost",size:"sm",onClick:k,className:"h-8",children:"Today"}),r.jsx("div",{className:"h-4 w-px bg-border mx-1"}),r.jsx(p.Button,{variant:"ghost",size:"icon",onClick:I,className:"h-8 w-8",children:r.jsx($.ChevronLeftIcon,{className:"h-4 w-4"})}),r.jsx(p.Button,{variant:"ghost",size:"icon",onClick:V,className:"h-8 w-8",children:r.jsx($.ChevronRightIcon,{className:"h-4 w-4"})})]}),r.jsxs(p.Popover,{children:[r.jsx(p.PopoverTrigger,{asChild:!0,children:r.jsxs(p.Button,{variant:"ghost",className:p.cn("text-xl font-semibold h-auto px-3 py-1 hover:bg-muted/50 transition-colors","flex items-center gap-2"),children:[r.jsx($.CalendarIcon,{className:"h-5 w-5 text-muted-foreground"}),r.jsx("span",{children:q()})]})}),r.jsx(p.PopoverContent,{className:"w-auto p-0",align:"start",children:r.jsx(p.Calendar,{mode:"single",selected:g,onSelect:Y,initialFocus:!0,fromYear:2e3,toYear:2050})})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(p.Select,{value:y,onValueChange:L,children:[r.jsx(p.SelectTrigger,{className:"w-32 bg-background",children:r.jsx(p.SelectValue,{})}),r.jsxs(p.SelectContent,{children:[r.jsx(p.SelectItem,{value:"day",children:"Day"}),r.jsx(p.SelectItem,{value:"week",children:"Week"}),r.jsx(p.SelectItem,{value:"month",children:"Month"})]})]}),d&&r.jsxs(p.Button,{onClick:d,size:"sm",className:"gap-1",children:[r.jsx($.PlusIcon,{className:"h-4 w-4"}),"New"]})]})]}),r.jsxs("div",{className:"flex-1 overflow-auto",children:[y==="month"&&r.jsx(ye,{date:g,events:e,onEventClick:f,onDateClick:s}),y==="week"&&r.jsx(je,{date:g,events:e,onEventClick:f,onDateClick:s}),y==="day"&&r.jsx(De,{date:g,events:e,onEventClick:f})]})]})}function oe(e){const n=new Date(e),l=n.getDay(),u=n.getDate()-l;return n.setDate(u),n}function xe(e){const n=e.getFullYear(),l=e.getMonth(),u=new Date(n,l,1),f=new Date(n,l+1,0),s=u.getDay(),m=[];for(let d=s-1;d>=0;d--){const c=new Date(u.getTime());c.setDate(c.getDate()-(d+1)),m.push(c)}for(let d=1;d<=f.getDate();d++)m.push(new Date(n,l,d));const a=42-m.length;for(let d=1;d<=a;d++){const c=new Date(f.getTime());c.setDate(c.getDate()+d),m.push(c)}return m}function se(e,n){return e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()}function Q(e,n){return n.filter(l=>{const u=new Date(l.start),f=l.end?new Date(l.end):new Date(u),s=new Date(e);s.setHours(0,0,0,0);const m=new Date(e);m.setHours(23,59,59,999);const a=new Date(u);a.setHours(0,0,0,0);const d=new Date(f);return d.setHours(23,59,59,999),s<=d&&m>=a})}function ye({date:e,events:n,onEventClick:l,onDateClick:u}){const f=xe(e),s=new Date,m=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return r.jsxs("div",{className:"flex flex-col h-full",children:[r.jsx("div",{className:"grid grid-cols-7 border-b",children:m.map(a=>r.jsx("div",{className:"p-2 text-center text-sm font-medium text-muted-foreground border-r last:border-r-0",children:a},a))}),r.jsx("div",{className:"grid grid-cols-7 flex-1 auto-rows-fr",children:f.map((a,d)=>{const c=Q(a,n),y=a.getMonth()===e.getMonth(),w=se(a,s);return r.jsxs("div",{className:p.cn("border-b border-r last:border-r-0 p-2 min-h-[100px] cursor-pointer hover:bg-accent/50",!y&&"bg-muted/30 text-muted-foreground"),onClick:()=>u?.(a),children:[r.jsx("div",{className:p.cn("text-sm font-medium mb-1",w&&"inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-6 w-6"),children:a.getDate()}),r.jsxs("div",{className:"space-y-1",children:[c.slice(0,3).map(g=>r.jsx("div",{className:p.cn("text-xs px-2 py-1 rounded truncate cursor-pointer hover:opacity-80",g.color||G),style:g.color&&g.color.startsWith("#")?{backgroundColor:g.color}:void 0,onClick:S=>{S.stopPropagation(),l?.(g)},children:g.title},g.id)),c.length>3&&r.jsxs("div",{className:"text-xs text-muted-foreground px-2",children:["+",c.length-3," more"]})]})]},d)})})]})}function je({date:e,events:n,onEventClick:l,onDateClick:u}){const f=oe(e),s=Array.from({length:7},(a,d)=>{const c=new Date(f);return c.setDate(c.getDate()+d),c}),m=new Date;return r.jsxs("div",{className:"flex flex-col h-full",children:[r.jsx("div",{className:"grid grid-cols-7 border-b",children:s.map(a=>{const d=se(a,m);return r.jsxs("div",{className:"p-3 text-center border-r last:border-r-0",children:[r.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:a.toLocaleDateString(locale,{weekday:"short"})}),r.jsx("div",{className:p.cn("text-lg font-semibold mt-1",d&&"inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-8 w-8"),children:a.getDate()})]},a.toISOString())})}),r.jsx("div",{className:"grid grid-cols-7 flex-1",children:s.map(a=>{const d=Q(a,n);return r.jsx("div",{className:"border-r last:border-r-0 p-2 min-h-[400px] cursor-pointer hover:bg-accent/50",onClick:()=>u?.(a),children:r.jsx("div",{className:"space-y-2",children:d.map(c=>r.jsxs("div",{className:p.cn("text-sm px-3 py-2 rounded cursor-pointer hover:opacity-80",c.color||G),style:c.color&&c.color.startsWith("#")?{backgroundColor:c.color}:void 0,onClick:y=>{y.stopPropagation(),l?.(c)},children:[r.jsx("div",{className:"font-medium",children:c.title}),!c.allDay&&r.jsx("div",{className:"text-xs opacity-90 mt-1",children:c.start.toLocaleTimeString("default",{hour:"numeric",minute:"2-digit"})})]},c.id))})},a.toISOString())})})]})}function De({date:e,events:n,onEventClick:l}){const u=Q(e,n),f=Array.from({length:24},(s,m)=>m);return r.jsx("div",{className:"flex flex-col h-full",children:r.jsx("div",{className:"flex-1 overflow-auto",children:f.map(s=>{const m=u.filter(a=>a.allDay?s===0:a.start.getHours()===s);return r.jsxs("div",{className:"flex border-b min-h-[60px]",children:[r.jsx("div",{className:"w-20 p-2 text-sm text-muted-foreground border-r",children:s===0?"12 AM":s<12?`${s} AM`:s===12?"12 PM":`${s-12} PM`}),r.jsx("div",{className:"flex-1 p-2 space-y-2",children:m.map(a=>r.jsxs("div",{className:p.cn("px-3 py-2 rounded cursor-pointer hover:opacity-80",a.color||G),style:a.color&&a.color.startsWith("#")?{backgroundColor:a.color}:void 0,onClick:()=>l?.(a),children:[r.jsx("div",{className:"font-medium",children:a.title}),!a.allDay&&r.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))})]},s)})})})}function ve(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 he(e){if(e){if(typeof e=="string"){const n=e.split(" "),l=n[0],u=n[1]?.toLowerCase()==="desc"?"desc":"asc";return{[l]:u}}if(Array.isArray(e))return e.reduce((n,l)=>(l.field&&l.order&&(n[l.field]=l.order),n),{})}}function we(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 ce=({schema:e,dataSource:n,className:l,onEventClick:u,onDateClick:f,onNavigate:s,onViewChange:m,...a})=>{const[d,c]=j.useState([]),[y,w]=j.useState(!0),[g,S]=j.useState(null),[I,V]=j.useState(null),[k,L]=j.useState(new Date),[q,Y]=j.useState("month"),i=j.useMemo(()=>ve(e),[e.data,e.staticData,e.objectName]),F=j.useMemo(()=>we(e),[e.filter,e.calendar,e.dateField,e.endField,e.titleField,e.colorField]),T=i?.provider==="value";j.useEffect(()=>{let b=!0;return(async()=>{try{if(!b)return;if(w(!0),T&&i?.provider==="value"){b&&(c(i.items),w(!1));return}if(e.data||a.data){const C=e.data||a.data;if(Array.isArray(C)){c(C),w(!1);return}}if(!n)throw new Error("DataSource required for object/api providers");if(i?.provider==="object"){const C=i.object,E=await n.find(C,{$filter:e.filter,$orderby:he(e.sort)});let h=[];Array.isArray(E)?h=E:E&&typeof E=="object"&&(Array.isArray(E.data)?h=E.data:Array.isArray(E.value)&&(h=E.value)),b&&c(h)}else i?.provider==="api"&&(console.warn("API provider not yet implemented for ObjectCalendar"),b&&c([]));b&&w(!1)}catch(C){console.error("[ObjectCalendar] Error fetching data:",C),b&&(S(C),w(!1))}})(),()=>{b=!1}},[i,n,T,e.filter,e.sort]),j.useEffect(()=>{!T&&n&&(async()=>{try{if(!n)return;const _=i?.provider==="object"?i.object:e.objectName;if(!_)return;const C=await n.getObjectSchema(_);V(C)}catch(_){console.error("Failed to fetch object schema:",_)}})()},[e.objectName,n,T,i]);const K=j.useMemo(()=>{if(!F||!d.length)return[];const{startDateField:b,endDateField:_,titleField:C,colorField:E}=F;return d.map((h,te)=>{const O=h[b],A=_?h[_]:null,z=h[C]||"Untitled",H=E?h[E]:void 0;return{id:h.id||h._id||`event-${te}`,title:z,start:O?new Date(O):new Date,end:A?new Date(A):void 0,color:H,allDay:!A,data:h}}).filter(h=>!isNaN(h.start.getTime()))},[d,F]),ee=j.useCallback(()=>{f?.(new Date)},[f]);return y?r.jsx("div",{className:l,children:r.jsx("div",{className:"flex items-center justify-center h-96",children:r.jsx("div",{className:"text-muted-foreground",children:"Loading calendar..."})})}):g?r.jsx("div",{className:l,children:r.jsx("div",{className:"flex items-center justify-center h-96",children:r.jsxs("div",{className:"text-destructive",children:["Error: ",g.message]})})}):F?r.jsx("div",{className:l,children:r.jsx("div",{className:"border rounded-lg bg-background h-[calc(100vh-200px)] min-h-[600px]",children:r.jsx(X,{events:K,currentDate:k,view:e.defaultView||"month",onEventClick:b=>u?.(b.data),onDateClick:f,onNavigate:b=>{L(b),s?.(b)},onViewChange:b=>{Y(b),m?.(b)},onAddClick:ee})})}):r.jsx("div",{className:l,children:r.jsx("div",{className:"flex items-center justify-center h-96",children:r.jsx("div",{className:"text-muted-foreground",children:"Calendar configuration required. Please specify startDateField and titleField."})})})};B.ComponentRegistry.register("calendar-view",({schema:e,className:n,onAction:l,...u})=>{const f=j.useMemo(()=>!e.data||!Array.isArray(e.data)?[]:e.data.map((a,d)=>{const c=e.titleField||"title",y=e.startDateField||"start",w=e.endDateField||"end",g=e.colorField||"color",S=e.allDayField||"allDay";return{id:a._id||a.id||d,title:a[c]||"Untitled Event",start:new Date(a[y]),end:a[w]?new Date(a[w]):void 0,allDay:a[S],color:a[g],data:a}}),[e.data,e.titleField,e.startDateField,e.endDateField,e.colorField,e.allDayField]),s=a=>{e.onEventClick&&l?.({type:"event-click",payload:a})},m=()=>{l?.({type:"create",payload:{}})};return r.jsx(X,{className:n,events:f,onEventClick:s,onAddClick:m,...u})},{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 Z=({schema:e})=>{const{dataSource:n}=fe.useSchemaContext();return r.jsx(ce,{schema:e,dataSource:n})};B.ComponentRegistry.register("object-calendar",Z,{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"}]}),B.ComponentRegistry.register("calendar",Z,{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"}]}),N.CalendarView=X,N.ObjectCalendar=ce,N.ObjectCalendarRenderer=Z,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})}));
|
|
6
|
+
<%s key={someKey} {...props} />`,E,C,z,C),R[C+E]=!0)}if(C=null,w!==void 0&&(l(w),C=""+w),g(f)&&(l(f.key),C=""+f.key),"key"in f){w={};for(var le in f)le!=="key"&&(w[le]=f[le])}else w=f;return C&&u(w,typeof e=="function"?e.displayName||e.name||"Unknown":e),d(e,C,w,m(),H,X)}function a(e){b(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===i&&(e._payload.status==="fulfilled"?b(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function b(e){return typeof e=="object"&&e!==null&&e.$$typeof===N}var o=p,N=Symbol.for("react.transitional.element"),$=Symbol.for("react.portal"),V=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),F=Symbol.for("react.profiler"),P=Symbol.for("react.consumer"),_=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),S=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),Y=Symbol.for("react.memo"),i=Symbol.for("react.lazy"),T=Symbol.for("react.activity"),j=Symbol.for("react.client.reference"),W=o.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,q=Object.prototype.hasOwnProperty,ne=Array.isArray,G=console.createTask?console.createTask:function(){return null};o={react_stack_bottom_frame:function(e){return e()}};var U,D={},O=o.react_stack_bottom_frame.bind(o,c)(),k=G(s(c)),R={};B.Fragment=V,B.jsx=function(e,f,w){var E=1e4>W.recentlyCreatedOwnerStacks++;return y(e,f,w,!1,E?Error("react-stack-top-frame"):O,E?G(s(e)):k)},B.jsxs=function(e,f,w){var E=1e4>W.recentlyCreatedOwnerStacks++;return y(e,f,w,!0,E?Error("react-stack-top-frame"):O,E?G(s(e)):k)}})()),B}var ce;function pe(){return ce||(ce=1,process.env.NODE_ENV==="production"?Z.exports=ge():Z.exports=he()),Z.exports}var r=pe();const ee="bg-blue-500 text-white";function te({events:t=[],view:n="month",currentDate:l=new Date,locale:s="default",onEventClick:m,onDateClick:c,onViewChange:g,onNavigate:u,onAddClick:h,onEventDrop:d,className:y}){const[a,b]=L.useState(n),[o,N]=L.useState(l);L.useEffect(()=>{N(l)},[l]),L.useEffect(()=>{b(n)},[n]);const $=L.useRef(g);$.current=g,L.useEffect(()=>{const i=window.matchMedia("(max-width: 639px)"),T=j=>{j.matches&&(b("day"),$.current?.("day"))};return T(i),i.addEventListener("change",T),()=>i.removeEventListener("change",T)},[]);const V=()=>{const i=new Date(o);a==="month"?i.setMonth(i.getMonth()-1):a==="week"?i.setDate(i.getDate()-7):i.setDate(i.getDate()-1),N(i),u?.(i)},x=()=>{const i=new Date(o);a==="month"?i.setMonth(i.getMonth()+1):a==="week"?i.setDate(i.getDate()+7):i.setDate(i.getDate()+1),N(i),u?.(i)},F=()=>{const i=new Date;N(i),u?.(i)},P=i=>{b(i),g?.(i)},_=()=>{if(a==="month")return o.toLocaleDateString(s,{month:"long",year:"numeric"});if(a==="week"){const i=de(o),T=new Date(i);return T.setDate(T.getDate()+6),`${i.toLocaleDateString(s,{month:"short",day:"numeric"})} - ${T.toLocaleDateString(s,{month:"short",day:"numeric",year:"numeric"})}`}else return o.toLocaleDateString(s,{weekday:"long",month:"long",day:"numeric",year:"numeric"})},M=L.useRef(0),S=i=>{M.current=i.touches[0].clientX},I=i=>{const T=M.current-i.changedTouches[0].clientX;if(Math.abs(T)>50){const j=new Date(o);a==="day"?j.setDate(j.getDate()+(T>0?1:-1)):a==="week"?j.setDate(j.getDate()+(T>0?7:-7)):j.setMonth(j.getMonth()+(T>0?1:-1)),N(j),u?.(j)}},Y=i=>{i&&(N(i),u?.(i))};return r.jsxs("div",{role:"region","aria-label":"Calendar",className:v.cn("flex flex-col h-full bg-background",y),children:[r.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs("div",{className:"flex items-center bg-muted/50 rounded-lg p-1 gap-1",children:[r.jsx(v.Button,{variant:"ghost",size:"sm",onClick:F,className:"h-8","aria-label":"Go to today",children:"Today"}),r.jsx("div",{className:"h-4 w-px bg-border mx-1"}),r.jsx(v.Button,{variant:"ghost",size:"icon","aria-label":"Previous period",onClick:V,className:"h-8 w-8",children:r.jsx(Q.ChevronLeftIcon,{className:"h-4 w-4"})}),r.jsx(v.Button,{variant:"ghost",size:"icon","aria-label":"Next period",onClick:x,className:"h-8 w-8",children:r.jsx(Q.ChevronRightIcon,{className:"h-4 w-4"})})]}),r.jsxs(v.Popover,{children:[r.jsx(v.PopoverTrigger,{asChild:!0,children:r.jsxs(v.Button,{variant:"ghost","aria-label":`Current date: ${_()}`,className:v.cn("text-xl font-semibold h-auto px-3 py-1 hover:bg-muted/50 transition-colors","flex items-center gap-2"),children:[r.jsx(Q.CalendarIcon,{className:"h-5 w-5 text-muted-foreground"}),r.jsx("span",{children:_()})]})}),r.jsx(v.PopoverContent,{className:"w-auto p-0",align:"start",children:r.jsx(v.Calendar,{mode:"single",selected:o,onSelect:Y,initialFocus:!0,fromYear:2e3,toYear:2050})})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(v.Select,{value:a,onValueChange:P,children:[r.jsx(v.SelectTrigger,{className:"w-32 bg-background",children:r.jsx(v.SelectValue,{})}),r.jsxs(v.SelectContent,{children:[r.jsx(v.SelectItem,{value:"day",children:"Day"}),r.jsx(v.SelectItem,{value:"week",children:"Week"}),r.jsx(v.SelectItem,{value:"month",children:"Month"})]})]}),h&&r.jsxs(v.Button,{onClick:h,size:"sm",className:"gap-1",children:[r.jsx(Q.PlusIcon,{className:"h-4 w-4"}),"New"]})]})]}),r.jsxs("div",{className:"flex-1 overflow-auto",onTouchStart:S,onTouchEnd:I,children:[a==="month"&&r.jsx(xe,{date:o,events:t,onEventClick:m,onDateClick:c,onEventDrop:d}),a==="week"&&r.jsx(De,{date:o,events:t,locale:s,onEventClick:m,onDateClick:c}),a==="day"&&r.jsx(ye,{date:o,events:t,onEventClick:m,onDateClick:c})]})]})}function de(t){const n=new Date(t),l=n.getDay(),s=n.getDate()-l;return n.setDate(s),n}function be(t){const n=t.getFullYear(),l=t.getMonth(),s=new Date(n,l,1),m=new Date(n,l+1,0),c=s.getDay(),g=[];for(let h=c-1;h>=0;h--){const d=new Date(s.getTime());d.setDate(d.getDate()-(h+1)),g.push(d)}for(let h=1;h<=m.getDate();h++)g.push(new Date(n,l,h));const u=42-g.length;for(let h=1;h<=u;h++){const d=new Date(m.getTime());d.setDate(d.getDate()+h),g.push(d)}return g}function ue(t,n){return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate()}function re(t,n){return n.filter(l=>{const s=new Date(l.start),m=l.end?new Date(l.end):new Date(s),c=new Date(t);c.setHours(0,0,0,0);const g=new Date(t);g.setHours(23,59,59,999);const u=new Date(s);u.setHours(0,0,0,0);const h=new Date(m);return h.setHours(23,59,59,999),c<=h&&g>=u})}function xe({date:t,events:n,onEventClick:l,onDateClick:s,onEventDrop:m}){const c=be(t),g=new Date,u=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],[h,d]=L.useState(null),[y,a]=L.useState(null),b=(x,F)=>{d(F.id),x.dataTransfer.effectAllowed="move",x.dataTransfer.setData("text/plain",String(F.id))},o=()=>{d(null),a(null)},N=(x,F)=>{x.preventDefault(),x.dataTransfer.dropEffect="move",a(F)},$=x=>{x.currentTarget.contains(x.relatedTarget)||a(null)},V=(x,F)=>{if(x.preventDefault(),a(null),d(null),!m)return;const P=x.dataTransfer.getData("text/plain"),_=n.find(j=>String(j.id)===P);if(!_)return;const M=new Date(_.start),S=new Date(M);S.setHours(0,0,0,0);const I=new Date(F);I.setHours(0,0,0,0);const Y=I.getTime()-S.getTime();if(Y===0)return;const i=new Date(M.getTime()+Y);let T;_.end&&(T=new Date(new Date(_.end).getTime()+Y)),m(_,i,T)};return r.jsxs("div",{className:"flex flex-col h-full",children:[r.jsx("div",{role:"row",className:"grid grid-cols-7 border-b",children:u.map(x=>r.jsx("div",{role:"columnheader",className:"p-2 text-center text-sm font-medium text-muted-foreground border-r last:border-r-0",children:x},x))}),r.jsx("div",{role:"grid","aria-label":"Calendar grid",className:"grid grid-cols-7 flex-1 auto-rows-fr",children:c.map((x,F)=>{const P=re(x,n),_=x.getMonth()===t.getMonth(),M=ue(x,g);return r.jsxs("div",{role:"gridcell","aria-label":`${x.toLocaleDateString("default",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}${P.length>0?`, ${P.length} event${P.length>1?"s":""}`:""}`,className:v.cn("border-b border-r last:border-r-0 p-2 min-h-[100px] cursor-pointer hover:bg-accent/50",!_&&"bg-muted/30 text-muted-foreground",y===F&&"ring-2 ring-primary"),onClick:()=>s?.(x),onDragOver:S=>N(S,F),onDragLeave:$,onDrop:S=>V(S,x),children:[r.jsx("div",{className:v.cn("text-sm font-medium mb-1",M&&"inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-6 w-6"),...M?{"aria-current":"date"}:{},children:x.getDate()}),r.jsxs("div",{className:"space-y-1",children:[P.slice(0,3).map(S=>r.jsx("div",{role:"button","aria-label":S.title,draggable:!!m,onDragStart:I=>b(I,S),onDragEnd:o,className:v.cn("text-xs px-2 py-1 rounded truncate cursor-pointer hover:opacity-80",S.color||ee,h===S.id&&"opacity-50"),style:S.color&&S.color.startsWith("#")?{backgroundColor:S.color}:void 0,onClick:I=>{I.stopPropagation(),l?.(S)},children:S.title},S.id)),P.length>3&&r.jsxs("div",{className:"text-xs text-muted-foreground px-2",children:["+",P.length-3," more"]})]})]},F)})})]})}function De({date:t,events:n,locale:l="default",onEventClick:s,onDateClick:m}){const c=L.useRef(null),g=a=>{m&&(c.current=setTimeout(()=>{m(a)},500))},u=()=>{c.current&&(clearTimeout(c.current),c.current=null)},h=de(t),d=Array.from({length:7},(a,b)=>{const o=new Date(h);return o.setDate(o.getDate()+b),o}),y=new Date;return r.jsxs("div",{className:"flex flex-col h-full",children:[r.jsx("div",{className:"grid grid-cols-7 border-b",children:d.map(a=>{const b=ue(a,y);return r.jsxs("div",{className:"p-3 text-center border-r last:border-r-0",children:[r.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:a.toLocaleDateString(l,{weekday:"short"})}),r.jsx("div",{className:v.cn("text-lg font-semibold mt-1",b&&"inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-8 w-8"),children:a.getDate()})]},a.toISOString())})}),r.jsx("div",{role:"grid",className:"grid grid-cols-7 flex-1",children:d.map(a=>{const b=re(a,n);return r.jsx("div",{role:"gridcell","aria-label":`${a.toLocaleDateString("default",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}${b.length>0?`, ${b.length} event${b.length>1?"s":""}`:""}`,className:"border-r last:border-r-0 p-2 min-h-[400px] cursor-pointer hover:bg-accent/50",onClick:()=>m?.(a),onTouchStart:()=>g(a),onTouchEnd:u,children:r.jsx("div",{className:"space-y-2",children:b.map(o=>r.jsxs("div",{role:"button","aria-label":o.title,className:v.cn("text-xs sm:text-sm px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80",o.color||ee),style:o.color&&o.color.startsWith("#")?{backgroundColor:o.color}:void 0,onClick:N=>{N.stopPropagation(),s?.(o)},children:[r.jsx("div",{className:"font-medium truncate",children:o.title}),!o.allDay&&r.jsx("div",{className:"text-xs opacity-90 mt-1",children:o.start.toLocaleTimeString("default",{hour:"numeric",minute:"2-digit"})})]},o.id))})},a.toISOString())})})]})}function ye({date:t,events:n,onEventClick:l,onDateClick:s}){const m=re(t,n),c=Array.from({length:24},(d,y)=>y),g=L.useRef(null),u=d=>{s&&(g.current=setTimeout(()=>{const y=new Date(t);y.setHours(d,0,0,0),s(y)},500))},h=()=>{g.current&&(clearTimeout(g.current),g.current=null)};return r.jsx("div",{className:"flex flex-col h-full",children:r.jsx("div",{role:"list",className:"flex-1 overflow-auto",children:c.map(d=>{const y=m.filter(a=>a.allDay?d===0:a.start.getHours()===d);return r.jsxs("div",{role:"listitem",className:"flex border-b min-h-[60px]",children:[r.jsx("div",{className:"w-20 p-2 text-sm text-muted-foreground border-r",children:d===0?"12 AM":d<12?`${d} AM`:d===12?"12 PM":`${d-12} PM`}),r.jsx("div",{className:"flex-1 p-2 space-y-2",onTouchStart:()=>u(d),onTouchEnd:h,children:y.map(a=>r.jsxs("div",{"aria-label":a.title,className:v.cn("px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80",a.color||ee),style:a.color&&a.color.startsWith("#")?{backgroundColor:a.color}:void 0,onClick:()=>l?.(a),children:[r.jsx("div",{className:"font-medium truncate",children:a.title}),!a.allDay&&r.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))})]},d)})})})}function ve(t){const{onRefresh:n,threshold:l=80,enabled:s=!0}=t,m=p.useRef(null),[c,g]=p.useState(!1),[u,h]=p.useState(0),d=p.useRef(0),y=p.useCallback(o=>{if(!s||c)return;const N=m.current;N&&N.scrollTop===0&&(d.current=o.touches[0].clientY)},[s,c]),a=p.useCallback(o=>{if(!s||c||!d.current)return;const $=o.touches[0].clientY-d.current;$>0&&h(Math.min($,l*1.5))},[s,c,l]),b=p.useCallback(async()=>{if(!(!s||c)){if(u>=l){g(!0);try{await n()}finally{g(!1)}}h(0),d.current=0}},[s,c,u,l,n]);return p.useEffect(()=>{const o=m.current;if(!(!o||!s))return o.addEventListener("touchstart",y,{passive:!0}),o.addEventListener("touchmove",a,{passive:!0}),o.addEventListener("touchend",b,{passive:!0}),()=>{o.removeEventListener("touchstart",y),o.removeEventListener("touchmove",a),o.removeEventListener("touchend",b)}},[y,a,b,s]),{ref:m,isRefreshing:c,pullDistance:u}}const je=p.createContext(null);je.displayName="MobileContext";function we(t){return"data"in t&&t.data?t.data:"staticData"in t&&t.staticData?{provider:"value",items:t.staticData}:t.objectName?{provider:"object",object:t.objectName}:null}function Se(t){if(t){if(typeof t=="string"){const n=t.split(" "),l=n[0],s=n[1]?.toLowerCase()==="desc"?"desc":"asc";return{[l]:s}}if(Array.isArray(t))return t.reduce((n,l)=>(l.field&&l.order&&(n[l.field]=l.order),n),{})}}function Ee(t){return"filter"in t&&t.filter&&typeof t.filter=="object"&&"calendar"in t.filter?t.filter.calendar:t.calendar?t.calendar:t.startDateField||t.dateField?{startDateField:t.startDateField||t.dateField,endDateField:t.endDateField||t.endField,titleField:t.titleField||"name",colorField:t.colorField,allDayField:t.allDayField}:null}const fe=({schema:t,dataSource:n,className:l,onEventClick:s,onRowClick:m,onDateClick:c,onNavigate:g,onViewChange:u,...h})=>{const[d,y]=p.useState([]),[a,b]=p.useState(!0),[o,N]=p.useState(null),[$,V]=p.useState(null),[x,F]=p.useState(new Date),[P,_]=p.useState("month"),[M,S]=p.useState(0),I=p.useCallback(async()=>{S(D=>D+1)},[]),{ref:Y,isRefreshing:i,pullDistance:T}=ve({onRefresh:I,enabled:!!n&&!!t.objectName}),j=p.useMemo(()=>we(t),[t.data,t.staticData,t.objectName]),W=p.useMemo(()=>Ee(t),[t.filter,t.calendar,t.dateField,t.endField,t.titleField,t.colorField]),q=j?.provider==="value";p.useEffect(()=>{let D=!0;return(async()=>{try{if(!D)return;if(b(!0),q&&j?.provider==="value"){D&&(y(j.items),b(!1));return}if(t.data||h.data){const k=t.data||h.data;if(Array.isArray(k)){y(k),b(!1);return}}if(!n)throw new Error("DataSource required for object/api providers");if(j?.provider==="object"){const k=j.object,R=await n.find(k,{$filter:t.filter,$orderby:Se(t.sort)});let e=[];Array.isArray(R)?e=R:R&&typeof R=="object"&&(Array.isArray(R.data)?e=R.data:Array.isArray(R.value)&&(e=R.value)),D&&y(e)}else j?.provider==="api"&&(console.warn("API provider not yet implemented for ObjectCalendar"),D&&y([]));D&&b(!1)}catch(k){console.error("[ObjectCalendar] Error fetching data:",k),D&&(N(k),b(!1))}})(),()=>{D=!1}},[j,n,q,t.filter,t.sort,M]),p.useEffect(()=>{!q&&n&&(async()=>{try{if(!n)return;const O=j?.provider==="object"?j.object:t.objectName;if(!O)return;const k=await n.getObjectSchema(O);V(k)}catch(O){console.error("Failed to fetch object schema:",O)}})()},[t.objectName,n,q,j]);const ne=p.useMemo(()=>{if(!W||!d.length)return[];const{startDateField:D,endDateField:O,titleField:k,colorField:R}=W;return d.map((e,f)=>{const w=e[D],E=O?e[O]:null,H=e[k]||"Untitled",X=R?e[R]:void 0;return{id:e.id||e._id||`event-${f}`,title:H,start:w?new Date(w):new Date,end:E?new Date(E):void 0,color:X,allDay:!E,data:e}}).filter(e=>!isNaN(e.start.getTime()))},[d,W]),G=p.useCallback(()=>{c?.(new Date)},[c]),U=oe.useNavigationOverlay({navigation:t.navigation,objectName:t.objectName,onRowClick:m});return a?r.jsx("div",{className:l,children:r.jsx("div",{className:"flex items-center justify-center h-96",children:r.jsx("div",{className:"text-muted-foreground",children:"Loading calendar..."})})}):o?r.jsx("div",{className:l,children:r.jsx("div",{className:"flex items-center justify-center h-96",children:r.jsxs("div",{className:"text-destructive",children:["Error: ",o.message]})})}):W?r.jsxs("div",{ref:Y,className:l,children:[T>0&&r.jsx("div",{className:"flex items-center justify-center text-xs text-muted-foreground",style:{height:T},children:i?"Refreshing…":"Pull to refresh"}),r.jsx("div",{className:"border rounded-lg bg-background h-[calc(100vh-120px)] sm:h-[calc(100vh-160px)] md:h-[calc(100vh-200px)] min-h-[400px] sm:min-h-[600px]",children:r.jsx(te,{events:ne,currentDate:x,view:t.defaultView||"month",onEventClick:D=>{U.handleClick(D.data),s?.(D.data)},onDateClick:c,onNavigate:D=>{F(D),g?.(D)},onViewChange:D=>{_(D),u?.(D)},onAddClick:G})}),U.isOverlay&&r.jsx(v.NavigationOverlay,{...U,title:"Event Details",children:D=>r.jsx("div",{className:"space-y-3",children:Object.entries(D).map(([O,k])=>r.jsxs("div",{className:"flex flex-col",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:O.replace(/_/g," ")}),r.jsx("span",{className:"text-sm",children:String(k??"—")})]},O))})})]}):r.jsx("div",{className:l,children:r.jsx("div",{className:"flex items-center justify-center h-96",children:r.jsx("div",{className:"text-muted-foreground",children:"Calendar configuration required. Please specify startDateField and titleField."})})})};K.ComponentRegistry.register("calendar-view",({schema:t,className:n,onAction:l,...s})=>{const m=p.useMemo(()=>!t.data||!Array.isArray(t.data)?[]:t.data.map((u,h)=>{const d=t.titleField||"title",y=t.startDateField||"start",a=t.endDateField||"end",b=t.colorField||"color",o=t.allDayField||"allDay";return{id:u._id||u.id||h,title:u[d]||"Untitled Event",start:new Date(u[y]),end:u[a]?new Date(u[a]):void 0,allDay:u[o],color:u[b],data:u}}),[t.data,t.titleField,t.startDateField,t.endDateField,t.colorField,t.allDayField]),c=u=>{t.onEventClick&&l?.({type:"event-click",payload:u})},g=()=>{l?.({type:"create",payload:{}})};return r.jsx(te,{className:n,events:m,onEventClick:c,onAddClick:g,...s})},{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 ae=({schema:t})=>{const{dataSource:n}=oe.useSchemaContext();return r.jsx(fe,{schema:t,dataSource:n})};K.ComponentRegistry.register("object-calendar",ae,{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"}]}),K.ComponentRegistry.register("calendar",ae,{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"}]}),A.CalendarView=te,A.ObjectCalendar=fe,A.ObjectCalendarRenderer=ae,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -24,8 +24,9 @@ export interface CalendarViewProps {
|
|
|
24
24
|
onViewChange?: (view: "month" | "week" | "day") => void;
|
|
25
25
|
onNavigate?: (date: Date) => void;
|
|
26
26
|
onAddClick?: () => void;
|
|
27
|
+
onEventDrop?: (event: CalendarEvent, newStart: Date, newEnd?: Date) => void;
|
|
27
28
|
className?: string;
|
|
28
29
|
}
|
|
29
|
-
declare function CalendarView({ events, view, currentDate, locale, onEventClick, onDateClick, onViewChange, onNavigate, onAddClick, className, }: CalendarViewProps): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
declare function CalendarView({ events, view, currentDate, locale, onEventClick, onDateClick, onViewChange, onNavigate, onAddClick, onEventDrop, className, }: CalendarViewProps): import("react/jsx-runtime").JSX.Element;
|
|
30
31
|
export { CalendarView };
|
|
31
32
|
//# sourceMappingURL=CalendarView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalendarView.d.ts","sourceRoot":"","sources":["../../src/CalendarView.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAsBH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,IAAI,CAAA;IACX,GAAG,CAAC,EAAE,IAAI,CAAA;IACV,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,GAAG,CAAA;CACX;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,aAAa,EAAE,CAAA;IACxB,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAA;IAC/B,WAAW,CAAC,EAAE,IAAI,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;IAC7C,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IAClC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,KAAK,IAAI,CAAA;IACvD,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IACjC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAA;IACvB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,iBAAS,YAAY,CAAC,EACpB,MAAW,EACX,IAAc,EACd,WAAwB,EACxB,MAAkB,EAClB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,UAAU,EACV,UAAU,EACV,SAAS,GACV,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"CalendarView.d.ts","sourceRoot":"","sources":["../../src/CalendarView.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAsBH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,IAAI,CAAA;IACX,GAAG,CAAC,EAAE,IAAI,CAAA;IACV,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,GAAG,CAAA;CACX;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,aAAa,EAAE,CAAA;IACxB,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAA;IAC/B,WAAW,CAAC,EAAE,IAAI,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;IAC7C,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IAClC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,KAAK,IAAI,CAAA;IACvD,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IACjC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAA;IACvB,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,IAAI,KAAK,IAAI,CAAA;IAC3E,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,iBAAS,YAAY,CAAC,EACpB,MAAW,EACX,IAAc,EACd,WAAwB,EACxB,MAAkB,EAClB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,UAAU,EACV,UAAU,EACV,WAAW,EACX,SAAS,GACV,EAAE,iBAAiB,2CAoOnB;AAobD,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -17,6 +17,7 @@ export interface ObjectCalendarProps {
|
|
|
17
17
|
dataSource?: DataSource;
|
|
18
18
|
className?: string;
|
|
19
19
|
onEventClick?: (record: any) => void;
|
|
20
|
+
onRowClick?: (record: any) => void;
|
|
20
21
|
onDateClick?: (date: Date) => void;
|
|
21
22
|
onEdit?: (record: any) => void;
|
|
22
23
|
onDelete?: (record: any) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectCalendar.d.ts","sourceRoot":"","sources":["../../src/ObjectCalendar.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAoD,MAAM,OAAO,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAA4B,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"ObjectCalendar.d.ts","sourceRoot":"","sources":["../../src/ObjectCalendar.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAoD,MAAM,OAAO,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAA4B,MAAM,kBAAkB,CAAC;AAM/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,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;CACzD;AAkFD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAqQxD,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/react';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: import('react').ForwardRefExoticComponent<Omit<{
|
|
5
|
+
schema: import('@object-ui/core').SchemaNode;
|
|
6
|
+
} & Record<string, any>, "ref"> & import('react').RefAttributes<any>>;
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: string;
|
|
9
|
+
};
|
|
10
|
+
tags: string[];
|
|
11
|
+
argTypes: {
|
|
12
|
+
schema: {
|
|
13
|
+
table: {
|
|
14
|
+
disable: true;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export default meta;
|
|
20
|
+
type Story = StoryObj<typeof meta>;
|
|
21
|
+
export declare const Default: Story;
|
|
22
|
+
export declare const MonthlyEvents: Story;
|
|
23
|
+
//# sourceMappingURL=ObjectCalendar.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObjectCalendar.stories.d.ts","sourceRoot":"","sources":["../../src/ObjectCalendar.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAKvD,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;CAUW,CAAC;AAEtB,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAUnC,eAAO,MAAM,OAAO,EAAE,KA0BrB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAyB3B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/plugin-calendar",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.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",
|
|
@@ -25,24 +25,25 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"lucide-react": "^0.563.0",
|
|
28
|
-
"@object-ui/components": "
|
|
29
|
-
"@object-ui/core": "
|
|
30
|
-
"@object-ui/fields": "
|
|
31
|
-
"@object-ui/
|
|
32
|
-
"@object-ui/
|
|
28
|
+
"@object-ui/components": "3.0.0",
|
|
29
|
+
"@object-ui/core": "3.0.0",
|
|
30
|
+
"@object-ui/fields": "3.0.0",
|
|
31
|
+
"@object-ui/mobile": "3.0.0",
|
|
32
|
+
"@object-ui/react": "3.0.0",
|
|
33
|
+
"@object-ui/types": "3.0.0"
|
|
33
34
|
},
|
|
34
35
|
"peerDependencies": {
|
|
35
36
|
"react": "^18.0.0 || ^19.0.0",
|
|
36
37
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
|
-
"@types/react": "
|
|
40
|
-
"@types/react-dom": "
|
|
41
|
-
"@vitejs/plugin-react": "^5.1.
|
|
40
|
+
"@types/react": "19.2.13",
|
|
41
|
+
"@types/react-dom": "19.2.3",
|
|
42
|
+
"@vitejs/plugin-react": "^5.1.4",
|
|
42
43
|
"typescript": "^5.9.3",
|
|
43
44
|
"vite": "^7.3.1",
|
|
44
45
|
"vite-plugin-dts": "^4.5.4",
|
|
45
|
-
"@object-ui/data-objectstack": "
|
|
46
|
+
"@object-ui/data-objectstack": "3.0.0"
|
|
46
47
|
},
|
|
47
48
|
"scripts": {
|
|
48
49
|
"build": "vite build",
|