@object-ui/plugin-calendar 3.1.3 → 3.1.5
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 +14 -8
- package/CHANGELOG.md +25 -0
- package/dist/index.js +1357 -1393
- package/dist/index.umd.cjs +2 -2
- package/dist/src/ObjectCalendar.d.ts +4 -0
- package/dist/src/ObjectCalendar.d.ts.map +1 -1
- package/package.json +11 -11
- package/src/ObjectCalendar.tsx +29 -14
- package/src/index.tsx +1 -1
- package/src/registration.test.tsx +17 -1
package/dist/index.umd.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(U,g){typeof exports=="object"&&typeof module<"u"?g(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"],g):(U=typeof globalThis<"u"?globalThis:U||self,g(U.ObjectUIPluginCalendar={},U.React,U.ObjectUICore,U.ObjectUIReact,U.LucideReact,U.ObjectUIComponents))})(this,(function(U,g,J,ue,Z,C){"use strict";function Te(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const c=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,c.get?c:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const V=Te(g);var ee={exports:{}},X={};var de;function Ne(){if(de)return X;de=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function n(c,i,o){var d=null;if(o!==void 0&&(d=""+o),i.key!==void 0&&(d=""+i.key),"key"in i){o={};for(var v in i)v!=="key"&&(o[v]=i[v])}else o=i;return i=o.ref,{$$typeof:e,type:c,key:d,ref:i!==void 0?i:null,props:o}}return X.Fragment=r,X.jsx=n,X.jsxs=n,X}var K={};var fe;function Oe(){return fe||(fe=1,process.env.NODE_ENV!=="production"&&(function(){function e(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===_?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case A:return"Fragment";case M:return"Profiler";case F:return"StrictMode";case I:return"Suspense";case T:return"SuspenseList";case f:return"Activity"}if(typeof t=="object")switch(typeof t.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case w:return"Portal";case b:return t.displayName||"Context";case Y:return(t._context.displayName||"Context")+".Consumer";case O:var x=t.render;return t=t.displayName,t||(t=x.displayName||x.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case P:return x=t.displayName||null,x!==null?x:e(t.type)||"Memo";case D:x=t._payload,t=t._init;try{return e(t(x))}catch{}}return null}function r(t){return""+t}function n(t){try{r(t);var x=!1}catch{x=!0}if(x){x=console;var j=x.error,k=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return j.call(x,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",k),r(t)}}function c(t){if(t===A)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===D)return"<...>";try{var x=e(t);return x?"<"+x+">":"<...>"}catch{return"<...>"}}function i(){var t=u.A;return t===null?null:t.getOwner()}function o(){return Error("react-stack-top-frame")}function d(t){if(S.call(t,"key")){var x=Object.getOwnPropertyDescriptor(t,"key").get;if(x&&x.isReactWarning)return!1}return t.key!==void 0}function v(t,x){function j(){Q||(Q=!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)",x))}j.isReactWarning=!0,Object.defineProperty(t,"key",{get:j,configurable:!0})}function y(){var t=e(this.type);return re[t]||(re[t]=!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.")),t=this.props.ref,t!==void 0?t:null}function p(t,x,j,k,z,G){var R=j.ref;return t={$$typeof:h,type:t,key:x,props:j,_owner:k},(R!==void 0?R:null)!==null?Object.defineProperty(t,"ref",{enumerable:!1,get:y}):Object.defineProperty(t,"ref",{enumerable:!1,value:null}),t._store={},Object.defineProperty(t._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(t,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(t,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:z}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:G}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function E(t,x,j,k,z,G){var R=x.children;if(R!==void 0)if(k)if(L(R)){for(k=0;k<R.length;k++)a(R[k]);Object.freeze&&Object.freeze(R)}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(R);if(S.call(x,"key")){R=e(t);var W=Object.keys(x).filter(function(it){return it!=="key"});k=0<W.length?"{key: someKey, "+W.join(": ..., ")+": ...}":"{key: someKey}",$[R+k]||(W=0<W.length?"{"+W.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(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`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginCalendar={},e.React,e.ObjectUICore,e.ObjectUIReact,e.LucideReact,e.ObjectUIComponents))})(this,function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=Object.create,s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,u=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty,f=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),p=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=l(t),a=0,o=i.length,u;a<o;a++)u=i[a],!d.call(e,u)&&u!==n&&s(e,u,{get:(e=>t[e]).bind(null,u),enumerable:!(r=c(t,u))||r.enumerable});return e};t=((e,t,n)=>(n=e==null?{}:o(u(e)),p(t||!e||!e.__esModule?s(n,`default`,{value:e,enumerable:!0}):n,e)))(t);var m=(e,t,n,r)=>{let i=[n,{code:t,...r||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(i,`warn`,`react-i18next::`,!0);x(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...i):console?.warn&&console.warn(...i)},h={},g=(e,t,n,r)=>{x(n)&&h[n]||(x(n)&&(h[n]=new Date),m(e,t,n,r))},_=(e,t)=>()=>{if(e.isInitialized)t();else{let n=()=>{setTimeout(()=>{e.off(`initialized`,n)},0),t()};e.on(`initialized`,n)}},v=(e,t,n)=>{e.loadNamespaces(t,_(e,n))},y=(e,t,n,r)=>{if(x(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return v(e,n,r);n.forEach(t=>{e.options.ns.indexOf(t)<0&&e.options.ns.push(t)}),e.loadLanguages(t,_(e,r))},b=(e,t,n={})=>!t.languages||!t.languages.length?(g(t,`NO_LANGUAGES`,`i18n.languages were undefined or empty`,{languages:t.languages}),!0):t.hasLoadedNamespace(e,{lng:n.lng,precheck:(t,r)=>{if(n.bindI18n&&n.bindI18n.indexOf(`languageChanging`)>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!r(t.isLanguageChangingTo,e))return!1}}),x=e=>typeof e==`string`,S=e=>typeof e==`object`&&!!e,C=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,w={"&":`&`,"&":`&`,"<":`<`,"<":`<`,">":`>`,">":`>`,"'":`'`,"'":`'`,""":`"`,""":`"`," ":` `," ":` `,"©":`©`,"©":`©`,"®":`®`,"®":`®`,"…":`…`,"…":`…`,"/":`/`,"/":`/`},T=e=>w[e],E={bindI18n:`languageChanged`,bindI18nStore:``,transEmptyNodeValue:``,transSupportBasicHtmlNodes:!0,transWrapTextNodes:``,transKeepBasicHtmlNodesFor:[`br`,`strong`,`i`,`p`],useSuspense:!0,unescape:e=>e.replace(C,T),transDefaultProps:void 0},D=()=>E,O,k=()=>O,A=(0,t.createContext)(),j=class{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}},M=f((e=>{var t=require(`react`);function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),N=f((e=>{process.env.NODE_ENV!==`production`&&(function(){function t(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}function n(e,t){d||a.startTransition===void 0||(d=!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 n=t();if(!f){var i=t();o(n,i)||(console.error(`The result of getSnapshot should be cached to avoid an infinite loop`),f=!0)}i=s({inst:{value:n,getSnapshot:t}});var p=i[0].inst,m=i[1];return l(function(){p.value=n,p.getSnapshot=t,r(p)&&m({inst:p})},[e,n,t]),c(function(){return r(p)&&m({inst:p}),e(function(){r(p)&&m({inst:p})})},[e]),u(n),n}function r(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!o(e,n)}catch{return!0}}function i(e,t){return t()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart==`function`&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var a=require(`react`),o=typeof Object.is==`function`?Object.is:t,s=a.useState,c=a.useEffect,l=a.useLayoutEffect,u=a.useDebugValue,d=!1,f=!1,p=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?i:n;e.useSyncExternalStore=a.useSyncExternalStore===void 0?p:a.useSyncExternalStore,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop==`function`&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()})),P=f(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=M():t.exports=N()}))(),F={t:(e,t)=>{if(x(t))return t;if(S(t)&&x(t.defaultValue))return t.defaultValue;if(typeof e==`function`)return``;if(Array.isArray(e)){let t=e[e.length-1];return typeof t==`function`?``:t}return e},ready:!1},I=()=>()=>{},L=(e,n={})=>{let{i18n:r}=n,{i18n:i,defaultNS:a}=(0,t.useContext)(A)||{},o=r||i||k();o&&!o.reportNamespaces&&(o.reportNamespaces=new j),o||g(o,`NO_I18NEXT_INSTANCE`,`useTranslation: You will need to pass in an i18next instance by using initReactI18next`);let s=(0,t.useMemo)(()=>({...D(),...o?.options?.react,...n}),[o,n]),{useSuspense:c,keyPrefix:l}=s,u=e||a||o?.options?.defaultNS,d=x(u)?[u]:u||[`translation`],f=(0,t.useMemo)(()=>d,d);o?.reportNamespaces?.addUsedNamespaces?.(f);let p=(0,t.useRef)(0),m=(0,t.useCallback)(e=>{if(!o)return I;let{bindI18n:t,bindI18nStore:n}=s,r=()=>{p.current+=1,e()};return t&&o.on(t,r),n&&o.store.on(n,r),()=>{t&&t.split(` `).forEach(e=>o.off(e,r)),n&&n.split(` `).forEach(e=>o.store.off(e,r))}},[o,s]),h=(0,t.useRef)(),_=(0,t.useCallback)(()=>{if(!o)return F;let e=!!(o.isInitialized||o.initializedStoreOnce)&&f.every(e=>b(e,o,s)),t=n.lng||o.language,r=p.current,i=h.current;if(i&&i.ready===e&&i.lng===t&&i.keyPrefix===l&&i.revision===r)return i;let a={t:o.getFixedT(t,s.nsMode===`fallback`?f:f[0],l),ready:e,lng:t,keyPrefix:l,revision:r};return h.current=a,a},[o,f,l,s,n.lng]),[S,C]=(0,t.useState)(0),{t:w,ready:T}=(0,P.useSyncExternalStore)(m,_,_);(0,t.useEffect)(()=>{if(o&&!T&&!c){let e=()=>C(e=>e+1);n.lng?y(o,n.lng,f,e):v(o,f,e)}},[o,n.lng,f,T,c,S]);let E=o||{},O=(0,t.useRef)(null),M=(0,t.useRef)(),N=e=>{let t=Object.getOwnPropertyDescriptors(e);t.__original&&delete t.__original;let n=Object.create(Object.getPrototypeOf(e),t);if(!Object.prototype.hasOwnProperty.call(n,`__original`))try{Object.defineProperty(n,`__original`,{value:e,writable:!1,enumerable:!1,configurable:!1})}catch{}return n},L=(0,t.useMemo)(()=>{let e=E,t=e?.language,n=e;e&&(O.current&&O.current.__original===e&&M.current===t?n=O.current:(n=N(e),O.current=n,M.current=t));let r=!T&&!c?(...e)=>(g(o,`USE_T_BEFORE_READY`,`useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t.`),w(...e)):w,i=[r,n,T];return i.t=r,i.i18n=n,i.ready=T,i},[w,E,T,E.resolvedLanguage,E.language,E.languages]);if(o&&c&&!T)throw new Promise(e=>{let t=()=>e();n.lng?y(o,n.lng,f,t):v(o,f,t)});return L},R=(0,t.createContext)(null);function z(e){let n=(0,t.useContext)(R),{t:r,i18n:i}=L(e);return{t:r,language:n?.language||i.language||`en`,changeLanguage:n?.changeLanguage||(async e=>{await i.changeLanguage(e)}),direction:n?.direction||`ltr`,i18n:i}}var B=f((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),V=f((e=>{process.env.NODE_ENV!==`production`&&(function(){function t(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===O?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case D: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 g:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var n=e.render;return e=e.displayName,e||=(e=n.displayName||n.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return n=e.displayName||null,n===null?t(e.type)||`Memo`:n;case E:n=e._payload,e=e._init;try{return t(e(n))}catch{}}return null}function n(e){return``+e}function r(e){try{n(e);var t=!1}catch{t=!0}if(t){t=console;var r=t.error,i=typeof Symbol==`function`&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||`Object`;return r.call(t,`The provided key is an unsupported type %s. This value must be coerced to a string before using it here.`,i),n(e)}}function i(e){if(e===_)return`<>`;if(typeof e==`object`&&e&&e.$$typeof===E)return`<...>`;try{var n=t(e);return n?`<`+n+`>`:`<...>`}catch{return`<...>`}}function a(){var e=k.A;return e===null?null:e.getOwner()}function o(){return Error(`react-stack-top-frame`)}function s(e){if(A.call(e,`key`)){var t=Object.getOwnPropertyDescriptor(e,`key`).get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function c(e,t){function n(){N||(N=!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)",t))}n.isReactWarning=!0,Object.defineProperty(e,`key`,{get:n,configurable:!0})}function l(){var e=t(this.type);return P[e]||(P[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?null:e}function u(e,t,n,r,i,a){var o=n.ref;return e={$$typeof:h,type:e,key:t,props:n,_owner:r},(o===void 0?null:o)===null?Object.defineProperty(e,`ref`,{enumerable:!1,value:null}):Object.defineProperty(e,`ref`,{enumerable:!1,get:l}),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:i}),Object.defineProperty(e,`_debugTask`,{configurable:!1,enumerable:!1,writable:!0,value:a}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function d(e,n,i,o,l,d){var p=n.children;if(p!==void 0)if(o)if(j(p)){for(o=0;o<p.length;o++)f(p[o]);Object.freeze&&Object.freeze(p)}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 f(p);if(A.call(n,`key`)){p=t(e);var m=Object.keys(n).filter(function(e){return e!==`key`});o=0<m.length?`{key: someKey, `+m.join(`: ..., `)+`: ...}`:`{key: someKey}`,L[p+o]||(m=0<m.length?`{`+m.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} />`,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} />`,o,p,m,p),L[p+o]=!0)}if(p=null,i!==void 0&&(r(i),p=``+i),s(n)&&(r(n.key),p=``+n.key),`key`in n)for(var h in i={},n)h!==`key`&&(i[h]=n[h]);else i=n;return p&&c(i,typeof e==`function`?e.displayName||e.name||`Unknown`:e),u(e,p,i,a(),l,d)}function f(e){p(e)?e._store&&(e._store.validated=1):typeof e==`object`&&e&&e.$$typeof===E&&(e._payload.status===`fulfilled`?p(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function p(e){return typeof e==`object`&&!!e&&e.$$typeof===h}var m=require(`react`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.client.reference`),k=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=Object.prototype.hasOwnProperty,j=Array.isArray,M=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(e){return e()}};var N,P={},F=m.react_stack_bottom_frame.bind(m,o)(),I=M(i(o)),L={};e.Fragment=_,e.jsx=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!1,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)},e.jsxs=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!0,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)}})()})),H=f(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=B():t.exports=V()}))(),U=`bg-blue-500 text-white`,W=new Date,G={"calendar.today":`Today`,"calendar.month":`Month`,"calendar.week":`Week`,"calendar.day":`Day`,"calendar.newEvent":`New event`,"calendar.moreEvents":`+{{count}} more`};function K(){try{let e=z();return e.t(`calendar.today`)===`calendar.today`?{t:(e,t)=>{let n=G[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n},language:`en`}:{t:e.t,language:e.language}}catch{return{t:(e,t)=>{let n=G[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n},language:`en`}}}function q({events:e=[],view:n=`month`,currentDate:r=W,locale:o=`default`,onEventClick:s,onDateClick:c,onViewChange:l,onNavigate:u,onAddClick:d,onEventDrop:f,className:p}){let[m,h]=t.useState(n),[g,_]=t.useState(r),{t:v,language:y}=K(),b=o===`default`?y:o;t.useEffect(()=>{_(r)},[r]),t.useEffect(()=>{h(n)},[n]);let x=t.useRef(l);x.current=l,t.useEffect(()=>{let e=window.matchMedia(`(max-width: 639px)`),t=e=>{e.matches&&(h(`day`),x.current?.(`day`))};return t(e),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let S=()=>{let e=new Date(g);m===`month`?e.setMonth(e.getMonth()-1):m===`week`?e.setDate(e.getDate()-7):e.setDate(e.getDate()-1),_(e),u?.(e)},C=()=>{let e=new Date(g);m===`month`?e.setMonth(e.getMonth()+1):m===`week`?e.setDate(e.getDate()+7):e.setDate(e.getDate()+1),_(e),u?.(e)},w=()=>{let e=new Date;_(e),u?.(e)},T=e=>{h(e),l?.(e)},E=()=>{if(m===`month`)return g.toLocaleDateString(b,{month:`long`,year:`numeric`});if(m===`week`){let e=J(g),t=new Date(e);return t.setDate(t.getDate()+6),`${e.toLocaleDateString(b,{month:`short`,day:`numeric`})} - ${t.toLocaleDateString(b,{month:`short`,day:`numeric`,year:`numeric`})}`}else return g.toLocaleDateString(b,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})},D=t.useRef(0),O=e=>{D.current=e.touches[0].clientX},k=e=>{let t=D.current-e.changedTouches[0].clientX;if(Math.abs(t)>50){let e=new Date(g);m===`day`?e.setDate(e.getDate()+(t>0?1:-1)):m===`week`?e.setDate(e.getDate()+(t>0?7:-7)):e.setMonth(e.getMonth()+(t>0?1:-1)),_(e),u?.(e)}},A=e=>{e&&(_(e),u?.(e))};return(0,H.jsxs)(`div`,{role:`region`,"aria-label":`Calendar`,className:(0,a.cn)(`flex flex-col h-full bg-background min-w-0 overflow-hidden`,p),children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 p-2 sm:p-4 border-b min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center bg-muted/50 rounded-lg p-1 gap-1`,children:[(0,H.jsx)(a.Button,{variant:`ghost`,size:`sm`,onClick:w,className:`h-8`,"aria-label":`Go to today`,children:v(`calendar.today`)}),(0,H.jsx)(`div`,{className:`h-4 w-px bg-border mx-1`}),(0,H.jsx)(a.Button,{variant:`ghost`,size:`icon`,"aria-label":`Previous period`,onClick:S,className:`h-8 w-8`,children:(0,H.jsx)(i.ChevronLeftIcon,{className:`h-4 w-4`})}),(0,H.jsx)(a.Button,{variant:`ghost`,size:`icon`,"aria-label":`Next period`,onClick:C,className:`h-8 w-8`,children:(0,H.jsx)(i.ChevronRightIcon,{className:`h-4 w-4`})})]}),(0,H.jsxs)(a.Popover,{children:[(0,H.jsx)(a.PopoverTrigger,{asChild:!0,children:(0,H.jsxs)(a.Button,{variant:`ghost`,"aria-label":`Current date: ${E()}`,className:(0,a.cn)(`text-base sm:text-xl font-semibold h-auto px-2 sm:px-3 py-1 hover:bg-muted/50 transition-colors`,`flex items-center gap-2`),children:[(0,H.jsx)(i.CalendarIcon,{className:`h-5 w-5 text-muted-foreground`}),(0,H.jsx)(`span`,{children:E()})]})}),(0,H.jsx)(a.PopoverContent,{className:`w-auto p-0`,align:`start`,children:(0,H.jsx)(a.Calendar,{mode:`single`,selected:g,onSelect:A,initialFocus:!0,fromYear:2e3,toYear:2050})})]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(a.Select,{value:m,onValueChange:T,children:[(0,H.jsx)(a.SelectTrigger,{className:`w-32 bg-background`,children:(0,H.jsx)(a.SelectValue,{})}),(0,H.jsxs)(a.SelectContent,{children:[(0,H.jsx)(a.SelectItem,{value:`day`,children:v(`calendar.day`)}),(0,H.jsx)(a.SelectItem,{value:`week`,children:v(`calendar.week`)}),(0,H.jsx)(a.SelectItem,{value:`month`,children:v(`calendar.month`)})]})]}),d&&(0,H.jsxs)(a.Button,{onClick:d,size:`sm`,className:`gap-1`,children:[(0,H.jsx)(i.PlusIcon,{className:`h-4 w-4`}),v(`calendar.newEvent`)]})]})]}),(0,H.jsxs)(`div`,{className:`flex-1 overflow-auto`,onTouchStart:O,onTouchEnd:k,children:[m===`month`&&(0,H.jsx)(ee,{date:g,events:e,locale:b,onEventClick:s,onDateClick:c,onEventDrop:f}),m===`week`&&(0,H.jsx)(te,{date:g,events:e,locale:b,onEventClick:s,onDateClick:c}),m===`day`&&(0,H.jsx)(ne,{date:g,events:e,onEventClick:s,onDateClick:c})]})]})}function J(e){let t=new Date(e),n=t.getDay(),r=t.getDate()-n;return t.setDate(r),t}function Y(e){let t=e.getFullYear(),n=e.getMonth(),r=new Date(t,n,1),i=new Date(t,n+1,0),a=r.getDay(),o=[];for(let e=a-1;e>=0;e--){let t=new Date(r.getTime());t.setDate(t.getDate()-(e+1)),o.push(t)}for(let e=1;e<=i.getDate();e++)o.push(new Date(t,n,e));let s=42-o.length;for(let e=1;e<=s;e++){let t=new Date(i.getTime());t.setDate(t.getDate()+e),o.push(t)}return o}function X(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function Z(e,t){return t.filter(t=>{let n=new Date(t.start),r=t.end?new Date(t.end):new Date(n),i=new Date(e);i.setHours(0,0,0,0);let a=new Date(e);a.setHours(23,59,59,999);let o=new Date(n);o.setHours(0,0,0,0);let s=new Date(r);return s.setHours(23,59,59,999),i<=s&&a>=o})}function ee({date:e,events:n,locale:r=`default`,onEventClick:i,onDateClick:o,onEventDrop:s}){let c=t.useMemo(()=>Y(e),[e.getFullYear(),e.getMonth()]),l=t.useMemo(()=>new Date,[]),{t:u}=K(),d=t.useMemo(()=>{let e=new Date(2024,0,7);return Array.from({length:7},(t,n)=>{let i=new Date(e);return i.setDate(i.getDate()+n),i.toLocaleDateString(r,{weekday:`short`})})},[r]),[f,p]=t.useState(null),[m,h]=t.useState(null),g=t.useMemo(()=>{let e=new Map;for(let t of n){let n=new Date(t.start),r=t.end?new Date(t.end):new Date(n);n.setHours(0,0,0,0),r.setHours(0,0,0,0);let i=new Date(n);for(;i<=r;){let n=`${i.getFullYear()}-${i.getMonth()}-${i.getDate()}`,r=e.get(n);r?r.push(t):e.set(n,[t]),i.setDate(i.getDate()+1)}}return e},[n]),_=(e,t)=>{p(t.id),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,String(t.id))},v=()=>{p(null),h(null)},y=(e,t)=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`,h(t)},b=e=>{e.currentTarget.contains(e.relatedTarget)||h(null)},x=(e,t)=>{if(e.preventDefault(),h(null),p(null),!s)return;let r=e.dataTransfer.getData(`text/plain`),i=n.find(e=>String(e.id)===r);if(!i)return;let a=new Date(i.start),o=new Date(a);o.setHours(0,0,0,0);let c=new Date(t);c.setHours(0,0,0,0);let l=c.getTime()-o.getTime();if(l===0)return;let u=new Date(a.getTime()+l),d;i.end&&(d=new Date(new Date(i.end).getTime()+l)),s(i,u,d)};return(0,H.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,H.jsx)(`div`,{role:`row`,className:`grid grid-cols-7 border-b`,children:d.map(e=>(0,H.jsx)(`div`,{role:`columnheader`,className:`p-2 text-center text-sm font-medium text-muted-foreground border-r last:border-r-0`,children:e},e))}),(0,H.jsx)(`div`,{role:`grid`,"aria-label":`Calendar grid`,className:`grid grid-cols-7 flex-1 auto-rows-fr`,children:c.map((t,n)=>{let r=`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`,c=g.get(r)||[],d=t.getMonth()===e.getMonth(),p=X(t,l);return(0,H.jsxs)(`div`,{role:`gridcell`,"aria-label":`${t.toLocaleDateString(`default`,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})}${c.length>0?`, ${c.length} event${c.length>1?`s`:``}`:``}`,className:(0,a.cn)(`border-b border-r last:border-r-0 p-2 min-h-[100px] cursor-pointer hover:bg-accent/50`,!d&&`bg-muted/50 text-muted-foreground opacity-50`,m===n&&`ring-2 ring-primary`),onClick:()=>o?.(t),onDragOver:e=>y(e,n),onDragLeave:b,onDrop:e=>x(e,t),children:[(0,H.jsx)(`div`,{className:(0,a.cn)(`text-sm font-medium mb-2`,p&&`inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-6 w-6`),...p?{"aria-current":`date`}:{},children:t.getDate()}),(0,H.jsxs)(`div`,{className:`space-y-1`,children:[c.slice(0,3).map(e=>(0,H.jsx)(`div`,{role:`button`,title:e.title,"aria-label":e.title,draggable:!!s,onDragStart:t=>_(t,e),onDragEnd:v,className:(0,a.cn)(`text-xs px-2 py-1 rounded truncate cursor-pointer hover:opacity-80`,e.color?.startsWith(`#`)?`text-white`:e.color||U,f===e.id&&`opacity-50`),style:e.color&&e.color.startsWith(`#`)?{backgroundColor:e.color}:void 0,onClick:t=>{t.stopPropagation(),i?.(e)},children:e.title},e.id)),c.length>3&&(0,H.jsx)(`div`,{className:`text-xs text-muted-foreground px-2`,children:u(`calendar.moreEvents`,{count:c.length-3})})]})]},n)})})]})}function te({date:e,events:n,locale:r=`default`,onEventClick:i,onDateClick:o}){let s=t.useRef(null),c=e=>{o&&(s.current=setTimeout(()=>{o(e)},500))},l=()=>{s.current&&=(clearTimeout(s.current),null)},u=J(e),d=Array.from({length:7},(e,t)=>{let n=new Date(u);return n.setDate(n.getDate()+t),n}),f=new Date;return(0,H.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,H.jsx)(`div`,{className:`grid grid-cols-7 border-b`,children:d.map(e=>{let t=X(e,f);return(0,H.jsxs)(`div`,{className:`p-3 text-center border-r last:border-r-0`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-muted-foreground`,children:e.toLocaleDateString(r,{weekday:`short`})}),(0,H.jsx)(`div`,{className:(0,a.cn)(`text-lg font-semibold mt-1`,t&&`inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-8 w-8`),children:e.getDate()})]},e.toISOString())})}),(0,H.jsx)(`div`,{role:`grid`,className:`grid grid-cols-7 flex-1`,children:d.map(e=>{let t=Z(e,n);return(0,H.jsx)(`div`,{role:`gridcell`,"aria-label":`${e.toLocaleDateString(`default`,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})}${t.length>0?`, ${t.length} event${t.length>1?`s`:``}`:``}`,className:`border-r last:border-r-0 p-2 min-h-[400px] cursor-pointer hover:bg-accent/50`,onClick:()=>o?.(e),onTouchStart:()=>c(e),onTouchEnd:l,children:(0,H.jsx)(`div`,{className:`space-y-2`,children:t.map(e=>(0,H.jsxs)(`div`,{role:`button`,title:e.title,"aria-label":e.title,className:(0,a.cn)(`text-xs sm:text-sm px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80`,e.color?.startsWith(`#`)?`text-white`:e.color||U),style:e.color&&e.color.startsWith(`#`)?{backgroundColor:e.color}:void 0,onClick:t=>{t.stopPropagation(),i?.(e)},children:[(0,H.jsx)(`div`,{className:`font-medium truncate`,children:e.title}),!e.allDay&&(0,H.jsx)(`div`,{className:`text-xs opacity-90 mt-1`,children:e.start.toLocaleTimeString(`default`,{hour:`numeric`,minute:`2-digit`})})]},e.id))})},e.toISOString())})})]})}function ne({date:e,events:n,onEventClick:r,onDateClick:i}){let o=Z(e,n),s=Array.from({length:24},(e,t)=>t),c=t.useRef(null),l=t=>{i&&(c.current=setTimeout(()=>{let n=new Date(e);n.setHours(t,0,0,0),i(n)},500))},u=()=>{c.current&&=(clearTimeout(c.current),null)};return(0,H.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,H.jsx)(`div`,{role:`list`,className:`flex-1 overflow-auto`,children:s.map(e=>{let t=o.filter(t=>t.allDay?e===0:t.start.getHours()===e);return(0,H.jsxs)(`div`,{role:`listitem`,className:`flex border-b min-h-[60px]`,children:[(0,H.jsx)(`div`,{className:`w-20 p-2 text-sm text-muted-foreground border-r`,children:e===0?`12 AM`:e<12?`${e} AM`:e===12?`12 PM`:`${e-12} PM`}),(0,H.jsx)(`div`,{className:`flex-1 p-2 space-y-2`,onTouchStart:()=>l(e),onTouchEnd:u,children:t.map(e=>(0,H.jsxs)(`div`,{title:e.title,"aria-label":e.title,className:(0,a.cn)(`px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80`,e.color?.startsWith(`#`)?`text-white`:e.color||U),style:e.color&&e.color.startsWith(`#`)?{backgroundColor:e.color}:void 0,onClick:()=>r?.(e),children:[(0,H.jsx)(`div`,{className:`font-medium truncate`,children:e.title}),!e.allDay&&(0,H.jsxs)(`div`,{className:`text-xs opacity-90 mt-1`,children:[e.start.toLocaleTimeString(`default`,{hour:`numeric`,minute:`2-digit`}),e.end&&` - ${e.end.toLocaleTimeString(`default`,{hour:`numeric`,minute:`2-digit`})}`]})]},e.id))})]},e)})})})}function re(e){let{onRefresh:n,threshold:r=80,enabled:i=!0}=e,a=(0,t.useRef)(null),[o,s]=(0,t.useState)(!1),[c,l]=(0,t.useState)(0),u=(0,t.useRef)(0),d=(0,t.useCallback)(e=>{if(!i||o)return;let t=a.current;t&&t.scrollTop===0&&(u.current=e.touches[0].clientY)},[i,o]),f=(0,t.useCallback)(e=>{if(!i||o||!u.current)return;let t=e.touches[0].clientY-u.current;t>0&&l(Math.min(t,r*1.5))},[i,o,r]),p=(0,t.useCallback)(async()=>{if(!i||o)return;let e=c;if(l(0),u.current=0,e>=r){s(!0);try{await n()}finally{s(!1)}}},[i,o,c,r,n]);return(0,t.useEffect)(()=>{let e=a.current;if(!(!e||!i))return e.addEventListener(`touchstart`,d,{passive:!0}),e.addEventListener(`touchmove`,f,{passive:!0}),e.addEventListener(`touchend`,p,{passive:!0}),()=>{e.removeEventListener(`touchstart`,d),e.removeEventListener(`touchmove`,f),e.removeEventListener(`touchend`,p)}},[d,f,p,i]),{ref:a,isRefreshing:o,pullDistance:c}}var ie=(0,t.createContext)(null);ie.displayName=`MobileContext`;function ae(e){return`data`in e&&e.data?e.data:`staticData`in e&&e.staticData?{provider:`value`,items:e.staticData}:e.objectName?{provider:`object`,object:e.objectName}:null}function oe(e){if(e){if(typeof e==`string`){let t=e.split(` `),n=t[0],r=t[1]?.toLowerCase()===`desc`?`desc`:`asc`;return{[n]:r}}if(Array.isArray(e))return e.reduce((e,t)=>(t.field&&t.order&&(e[t.field]=t.order),e),{})}}function se(e){return`filter`in e&&e.filter&&typeof e.filter==`object`&&`calendar`in e.filter?e.filter.calendar:e.calendar?e.calendar:e.startDateField||e.dateField?{startDateField:e.startDateField||e.dateField,endDateField:e.endDateField||e.endField,titleField:e.titleField||`name`,colorField:e.colorField,allDayField:e.allDayField}:null}var Q=({schema:e,dataSource:i,className:o,data:s,loading:c,onEventClick:l,onRowClick:u,onDateClick:d,onNavigate:f,onViewChange:p,onEventDrop:m,locale:h})=>{let g=Array.isArray(s),[_,v]=(0,t.useState)(g?s:[]),[y,b]=(0,t.useState)(g?c??!1:!0),[x,S]=(0,t.useState)(null),[C,w]=(0,t.useState)(null),[T,E]=(0,t.useState)(new Date),[D,O]=(0,t.useState)(`month`),[k,A]=(0,t.useState)(0),{ref:j,isRefreshing:M,pullDistance:N}=re({onRefresh:(0,t.useCallback)(async()=>{A(e=>e+1)},[]),enabled:!!i&&!!e.objectName}),P=(0,t.useMemo)(()=>ae(e),[e.data,e.staticData,e.objectName]),F=(0,t.useMemo)(()=>se(e),[e.filter,e.calendar,e.dateField,e.endField,e.titleField,e.colorField]),I=P?.provider===`value`,L=(0,t.useRef)(null);L.current=C,(0,t.useEffect)(()=>{g&&v(s)},[s,g]),(0,t.useEffect)(()=>{g&&c!==void 0&&b(c)},[c,g]),(0,t.useEffect)(()=>{if(g)return;let t=!0;return(async()=>{try{if(!t)return;if(b(!0),I&&P?.provider===`value`){t&&(v(P.items),b(!1));return}if(!i||typeof i.find!=`function`)throw Error(`DataSource required for object/api providers`);if(P?.provider===`object`){let r=P.object,a=(0,n.buildExpandFields)(L.current?.fields),o=(0,n.extractRecords)(await i.find(r,{$filter:e.filter,$orderby:oe(e.sort),...a.length>0?{$expand:a}:{}}));t&&v(o)}else P?.provider===`api`&&(console.warn(`API provider not yet implemented for ObjectCalendar`),t&&v([]));t&&b(!1)}catch(e){console.error(`[ObjectCalendar] Error fetching data:`,e),t&&(S(e),b(!1))}})(),()=>{t=!1}},[g,P,i,I,e.filter,e.sort,k]),(0,t.useEffect)(()=>{!I&&i&&(async()=>{try{if(!i)return;let t=P?.provider===`object`?P.object:e.objectName;if(!t)return;w(await i.getObjectSchema(t))}catch(e){console.error(`Failed to fetch object schema:`,e)}})()},[e.objectName,i,I,P]);let R=(0,t.useMemo)(()=>{if(!F||!_.length)return[];let{startDateField:e,endDateField:t,titleField:n,colorField:r}=F;return _.map((i,a)=>{let o=i[e],s=t?i[t]:null,c=i[n]||`Untitled`,l=r?i[r]:void 0;return{id:i.id||i._id||`event-${a}`,title:c,start:o?new Date(o):new Date,end:s?new Date(s):void 0,color:l,allDay:!s,data:i}}).filter(e=>!isNaN(e.start.getTime()))},[_,F]);(0,t.useCallback)(()=>{d?.(new Date)},[d]);let z=(0,r.useNavigationOverlay)({navigation:e.navigation,objectName:e.objectName,onRowClick:u});return y?(0,H.jsx)(`div`,{className:o,children:(0,H.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,H.jsx)(`div`,{className:`text-muted-foreground`,children:`Loading calendar...`})})}):x?(0,H.jsx)(`div`,{className:o,children:(0,H.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,H.jsxs)(`div`,{className:`text-destructive`,children:[`Error: `,x.message]})})}):F?(0,H.jsxs)(`div`,{ref:j,className:o,children:[N>0&&(0,H.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:N},children:M?`Refreshing…`:`Pull to refresh`}),(0,H.jsx)(`div`,{className:`border rounded-lg bg-background h-[calc(100vh-120px)] sm:h-[calc(100vh-160px)] md:h-[calc(100vh-200px)] min-h-[400px] sm:min-h-[600px]`,children:(0,H.jsx)(q,{events:R,currentDate:T,view:e.defaultView||`month`,locale:h,onEventClick:e=>{z.handleClick(e.data),l?.(e.data)},onDateClick:d,onNavigate:e=>{E(e),f?.(e)},onViewChange:e=>{O(e),p?.(e)},onAddClick:void 0,onEventDrop:m?(e,t,n)=>{m(e.data,t,n)}:void 0})}),z.isOverlay&&(0,H.jsx)(a.NavigationOverlay,{...z,title:`Event Details`,children:e=>(0,H.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,H.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]}):(0,H.jsx)(`div`,{className:o,children:(0,H.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,H.jsx)(`div`,{className:`text-muted-foreground`,children:`Calendar configuration required. Please specify startDateField and titleField.`})})})};n.ComponentRegistry.register(`calendar-view`,({schema:e,className:n,onAction:r,...i})=>{let a=t.default.useMemo(()=>!e.data||!Array.isArray(e.data)?[]:e.data.map((t,n)=>{let r=e.titleField||`title`,i=e.startDateField||`start`,a=e.endDateField||`end`,o=e.colorField||`color`,s=e.allDayField||`allDay`;return{id:t.id||t._id||n,title:t[r]||`Untitled Event`,start:new Date(t[i]),end:t[a]?new Date(t[a]):void 0,allDay:t[s],color:t[o],data:t}}),[e.data,e.titleField,e.startDateField,e.endDateField,e.colorField,e.allDayField]);return(0,H.jsx)(q,{className:n,events:a,onEventClick:e=>{r?.({type:`event-click`,payload:e})},...i})},{namespace:`plugin-calendar`,label:`Calendar View`,inputs:[{name:`data`,type:`array`,label:`Data`,description:`Array of record objects to display as events`},{name:`titleField`,type:`string`,label:`Title Field`,defaultValue:`title`,description:`Field name to use for event title`},{name:`startDateField`,type:`string`,label:`Start Date Field`,defaultValue:`start`,description:`Field name for event start date`},{name:`endDateField`,type:`string`,label:`End Date Field`,defaultValue:`end`,description:`Field name for event end date (optional)`},{name:`allDayField`,type:`string`,label:`All Day Field`,defaultValue:`allDay`,description:`Field name for all-day flag`},{name:`colorField`,type:`string`,label:`Color Field`,defaultValue:`color`,description:`Field name for event color`},{name:`colorMapping`,type:`object`,label:`Color Mapping`,description:`Map field values to colors (e.g., {meeting: "blue", deadline: "red"})`},{name:`view`,type:`enum`,enum:[`month`,`week`,`day`],defaultValue:`month`,label:`View Mode`,description:`Calendar view mode (month, week, or day)`},{name:`currentDate`,type:`string`,label:`Current Date`,description:`ISO date string for initial calendar date`},{name:`allowCreate`,type:`boolean`,label:`Allow Create`,defaultValue:!1,description:`Allow creating events by clicking on dates`},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{view:`month`,titleField:`title`,startDateField:`start`,endDateField:`end`,allDayField:`allDay`,colorField:`color`,allowCreate:!1,data:[{id:1,title:`Team Meeting`,start:new Date(new Date().setHours(10,0,0,0)).toISOString(),end:new Date(new Date().setHours(11,0,0,0)).toISOString(),color:`#3b82f6`,allDay:!1},{id:2,title:`Project Deadline`,start:new Date(new Date().setDate(new Date().getDate()+3)).toISOString(),color:`#ef4444`,allDay:!0},{id:3,title:`Conference`,start:new Date(new Date().setDate(new Date().getDate()+7)).toISOString(),end:new Date(new Date().setDate(new Date().getDate()+9)).toISOString(),color:`#10b981`,allDay:!0}],className:`h-[600px] border rounded-lg`}});var $=({schema:e,...t})=>{let{dataSource:n}=(0,r.useSchemaContext)()||{};return(0,H.jsx)(Q,{schema:e,dataSource:n,...t})};n.ComponentRegistry.register(`object-calendar`,$,{namespace:`plugin-calendar`,label:`Object Calendar`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`calendar`,type:`object`,label:`Calendar Config`,description:`startDateField, endDateField, titleField, colorField`}]}),n.ComponentRegistry.register(`calendar`,$,{namespace:`view`,label:`Calendar View`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`calendar`,type:`object`,label:`Calendar Config`,description:`startDateField, endDateField, titleField, colorField`}]}),e.CalendarView=q,e.ObjectCalendar=Q,e.ObjectCalendarRenderer=$});
|
|
@@ -16,6 +16,10 @@ export interface ObjectCalendarProps {
|
|
|
16
16
|
schema: ObjectGridSchema | CalendarSchema;
|
|
17
17
|
dataSource?: DataSource;
|
|
18
18
|
className?: string;
|
|
19
|
+
/** Pre-fetched records passed by a parent (e.g. ObjectView). When provided, skips internal data fetching. */
|
|
20
|
+
data?: any[];
|
|
21
|
+
/** Loading state propagated from a parent. Respected only when `data` is also provided. */
|
|
22
|
+
loading?: boolean;
|
|
19
23
|
onEventClick?: (record: any) => void;
|
|
20
24
|
onRowClick?: (record: any) => void;
|
|
21
25
|
onDateClick?: (date: Date) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectCalendar.d.ts","sourceRoot":"","sources":["../../src/ObjectCalendar.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAA4D,MAAM,OAAO,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAA4B,MAAM,kBAAkB,CAAC;AAO/F,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,wBAAwB;IACxB,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;CACxC;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,gBAAgB,GAAG,cAAc,CAAC;IAC1C,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACrC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACnC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACjC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAClC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,KAAK,IAAI,CAAC;IACxD,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,IAAI,KAAK,IAAI,CAAC;IACnE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAkFD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"ObjectCalendar.d.ts","sourceRoot":"","sources":["../../src/ObjectCalendar.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAA4D,MAAM,OAAO,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAA4B,MAAM,kBAAkB,CAAC;AAO/F,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,wBAAwB;IACxB,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;CACxC;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,gBAAgB,GAAG,cAAc,CAAC;IAC1C,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6GAA6G;IAC7G,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,2FAA2F;IAC3F,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACrC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACnC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACjC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAClC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,KAAK,IAAI,CAAC;IACxD,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,IAAI,KAAK,IAAI,CAAC;IACnE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAkFD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAmRxD,CAAC"}
|
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.5",
|
|
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,13 +25,13 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"lucide-react": "^0.577.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.
|
|
28
|
+
"@object-ui/components": "3.1.5",
|
|
29
|
+
"@object-ui/core": "3.1.5",
|
|
30
|
+
"@object-ui/fields": "3.1.5",
|
|
31
|
+
"@object-ui/i18n": "3.1.5",
|
|
32
|
+
"@object-ui/mobile": "3.1.5",
|
|
33
|
+
"@object-ui/react": "3.1.5",
|
|
34
|
+
"@object-ui/types": "3.1.5"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/react": "19.2.14",
|
|
42
42
|
"@types/react-dom": "19.2.3",
|
|
43
|
-
"@vitejs/plugin-react": "^
|
|
43
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
44
44
|
"typescript": "^5.9.3",
|
|
45
|
-
"vite": "^
|
|
45
|
+
"vite": "^8.0.1",
|
|
46
46
|
"vite-plugin-dts": "^4.5.4",
|
|
47
|
-
"@object-ui/data-objectstack": "3.1.
|
|
47
|
+
"@object-ui/data-objectstack": "3.1.5"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "vite build",
|
package/src/ObjectCalendar.tsx
CHANGED
|
@@ -47,6 +47,10 @@ export interface ObjectCalendarProps {
|
|
|
47
47
|
schema: ObjectGridSchema | CalendarSchema;
|
|
48
48
|
dataSource?: DataSource;
|
|
49
49
|
className?: string;
|
|
50
|
+
/** Pre-fetched records passed by a parent (e.g. ObjectView). When provided, skips internal data fetching. */
|
|
51
|
+
data?: any[];
|
|
52
|
+
/** Loading state propagated from a parent. Respected only when `data` is also provided. */
|
|
53
|
+
loading?: boolean;
|
|
50
54
|
onEventClick?: (record: any) => void;
|
|
51
55
|
onRowClick?: (record: any) => void;
|
|
52
56
|
onDateClick?: (date: Date) => void;
|
|
@@ -142,6 +146,8 @@ export const ObjectCalendar: React.FC<ObjectCalendarProps> = ({
|
|
|
142
146
|
schema,
|
|
143
147
|
dataSource,
|
|
144
148
|
className,
|
|
149
|
+
data: externalData,
|
|
150
|
+
loading: externalLoading,
|
|
145
151
|
onEventClick,
|
|
146
152
|
onRowClick,
|
|
147
153
|
onDateClick,
|
|
@@ -149,10 +155,13 @@ export const ObjectCalendar: React.FC<ObjectCalendarProps> = ({
|
|
|
149
155
|
onViewChange,
|
|
150
156
|
onEventDrop,
|
|
151
157
|
locale,
|
|
152
|
-
...rest
|
|
153
158
|
}) => {
|
|
154
|
-
|
|
155
|
-
|
|
159
|
+
// When the parent (e.g. ObjectView) pre-fetches data and passes it via the `data` prop,
|
|
160
|
+
// we must not trigger a second fetch. Detect external data by checking for an array.
|
|
161
|
+
const hasExternalData = Array.isArray(externalData);
|
|
162
|
+
|
|
163
|
+
const [data, setData] = useState<any[]>(hasExternalData ? externalData! : []);
|
|
164
|
+
const [loading, setLoading] = useState(hasExternalData ? (externalLoading ?? false) : true);
|
|
156
165
|
const [error, setError] = useState<Error | null>(null);
|
|
157
166
|
const [objectSchema, setObjectSchema] = useState<any>(null);
|
|
158
167
|
const [currentDate, setCurrentDate] = useState(new Date());
|
|
@@ -187,8 +196,24 @@ export const ObjectCalendar: React.FC<ObjectCalendarProps> = ({
|
|
|
187
196
|
const objectSchemaRef = useRef<any>(null);
|
|
188
197
|
objectSchemaRef.current = objectSchema;
|
|
189
198
|
|
|
199
|
+
// Sync external data/loading changes from parent (e.g. ObjectView re-fetches after filter change)
|
|
200
|
+
useEffect(() => {
|
|
201
|
+
if (hasExternalData) {
|
|
202
|
+
setData(externalData!);
|
|
203
|
+
}
|
|
204
|
+
}, [externalData, hasExternalData]);
|
|
205
|
+
|
|
206
|
+
useEffect(() => {
|
|
207
|
+
if (hasExternalData && externalLoading !== undefined) {
|
|
208
|
+
setLoading(externalLoading);
|
|
209
|
+
}
|
|
210
|
+
}, [externalLoading, hasExternalData]);
|
|
211
|
+
|
|
190
212
|
// Fetch data based on provider
|
|
191
213
|
useEffect(() => {
|
|
214
|
+
// Skip internal fetch when data is managed by a parent component
|
|
215
|
+
if (hasExternalData) return;
|
|
216
|
+
|
|
192
217
|
let isMounted = true;
|
|
193
218
|
const fetchData = async () => {
|
|
194
219
|
try {
|
|
@@ -203,16 +228,6 @@ export const ObjectCalendar: React.FC<ObjectCalendarProps> = ({
|
|
|
203
228
|
return;
|
|
204
229
|
}
|
|
205
230
|
|
|
206
|
-
// Prioritize data passed from parent (ListView)
|
|
207
|
-
if ((schema as any).data || (rest as any).data) {
|
|
208
|
-
const passedData = (schema as any).data || (rest as any).data;
|
|
209
|
-
if (Array.isArray(passedData)) {
|
|
210
|
-
setData(passedData);
|
|
211
|
-
setLoading(false);
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
231
|
if (!dataSource || typeof dataSource.find !== 'function') {
|
|
217
232
|
throw new Error('DataSource required for object/api providers');
|
|
218
233
|
}
|
|
@@ -249,7 +264,7 @@ export const ObjectCalendar: React.FC<ObjectCalendarProps> = ({
|
|
|
249
264
|
|
|
250
265
|
fetchData();
|
|
251
266
|
return () => { isMounted = false; };
|
|
252
|
-
}, [dataConfig, dataSource, hasInlineData, schema.filter, schema.sort, refreshKey]);
|
|
267
|
+
}, [hasExternalData, dataConfig, dataSource, hasInlineData, schema.filter, schema.sort, refreshKey]);
|
|
253
268
|
|
|
254
269
|
// Fetch object schema for field metadata
|
|
255
270
|
useEffect(() => {
|
package/src/index.tsx
CHANGED
|
@@ -24,7 +24,7 @@ export type { CalendarViewProps, CalendarEvent } from './CalendarView';
|
|
|
24
24
|
import './calendar-view-renderer';
|
|
25
25
|
|
|
26
26
|
// Register object-calendar component
|
|
27
|
-
export const ObjectCalendarRenderer: React.FC<{ schema: any; [key: string]: any }> = ({ schema,
|
|
27
|
+
export const ObjectCalendarRenderer: React.FC<{ schema: any; [key: string]: any }> = ({ schema, ...props }) => {
|
|
28
28
|
const { dataSource } = useSchemaContext() || {};
|
|
29
29
|
return <ObjectCalendar schema={schema} dataSource={dataSource} {...props} />;
|
|
30
30
|
};
|
|
@@ -10,9 +10,11 @@ vi.mock('@object-ui/react', () => ({
|
|
|
10
10
|
|
|
11
11
|
// Mock the implementation
|
|
12
12
|
vi.mock('./ObjectCalendar', () => ({
|
|
13
|
-
ObjectCalendar: ({ dataSource }: any) => (
|
|
13
|
+
ObjectCalendar: ({ dataSource, data, loading }: any) => (
|
|
14
14
|
<div data-testid="calendar-mock">
|
|
15
15
|
{dataSource ? `DataSource: ${dataSource.type}` : 'No DataSource'}
|
|
16
|
+
{data !== undefined ? ` Data: ${JSON.stringify(data)}` : ''}
|
|
17
|
+
{loading !== undefined ? ` Loading: ${loading}` : ''}
|
|
16
18
|
</div>
|
|
17
19
|
)
|
|
18
20
|
}));
|
|
@@ -22,4 +24,18 @@ describe('Plugin Calendar Registration', () => {
|
|
|
22
24
|
render(<ObjectCalendarRenderer schema={{ type: 'object-calendar' }} />);
|
|
23
25
|
expect(screen.getByTestId('calendar-mock')).toHaveTextContent('DataSource: mock-datasource');
|
|
24
26
|
});
|
|
27
|
+
|
|
28
|
+
it('renderer passes data and loading props through to ObjectCalendar (no double-fetch)', () => {
|
|
29
|
+
const preloadedData = [{ id: 1, name: 'Event A' }];
|
|
30
|
+
render(
|
|
31
|
+
<ObjectCalendarRenderer
|
|
32
|
+
schema={{ type: 'object-calendar' }}
|
|
33
|
+
data={preloadedData}
|
|
34
|
+
loading={false}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
const el = screen.getByTestId('calendar-mock');
|
|
38
|
+
expect(el).toHaveTextContent('Data: [{"id":1,"name":"Event A"}]');
|
|
39
|
+
expect(el).toHaveTextContent('Loading: false');
|
|
40
|
+
});
|
|
25
41
|
});
|