@object-ui/plugin-view 3.1.2 → 3.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
 
2
- > @object-ui/plugin-view@3.1.2 build /home/runner/work/objectui/objectui/packages/plugin-view
2
+ > @object-ui/plugin-view@3.1.3 build /home/runner/work/objectui/objectui/packages/plugin-view
3
3
  > vite build
4
4
 
5
5
  vite v7.3.1 building client environment for production...
@@ -9,8 +9,8 @@ rendering chunks...
9
9
  
10
10
  [vite:dts] Start generate declaration files...
11
11
  computing gzip size...
12
- dist/index.js 144.91 kB │ gzip: 36.59 kB
13
- [vite:dts] Declaration files built in 9094ms.
12
+ dist/index.js 144.91 kB │ gzip: 36.60 kB
13
+ [vite:dts] Declaration files built in 7189ms.
14
14
  
15
15
  No name was provided for external module "@object-ui/core" in "output.globals" – guessing "core".
16
16
  No name was provided for external module "@object-ui/plugin-grid" in "output.globals" – guessing "pluginGrid".
@@ -19,4 +19,4 @@ computing gzip size...
19
19
  No name was provided for external module "lucide-react" in "output.globals" – guessing "lucideReact".
20
20
  No name was provided for external module "@object-ui/react" in "output.globals" – guessing "react".
21
21
  dist/index.umd.cjs 96.51 kB │ gzip: 30.84 kB
22
- ✓ built in 9.97s
22
+ ✓ built in 8.03s
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @object-ui/plugin-view
2
2
 
3
+ ## 3.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - @object-ui/types@3.1.3
8
+ - @object-ui/core@3.1.3
9
+ - @object-ui/react@3.1.3
10
+ - @object-ui/components@3.1.3
11
+ - @object-ui/plugin-form@3.1.3
12
+ - @object-ui/plugin-grid@3.1.3
13
+
3
14
  ## 3.1.2
4
15
 
5
16
  ### Patch Changes
package/dist/index.js CHANGED
@@ -593,13 +593,13 @@ const zi = ({
593
593
  return;
594
594
  }
595
595
  if (ce === "page" && e.onNavigate) {
596
- const D = y._id || y.id;
596
+ const D = y.id || y._id;
597
597
  e.onNavigate(D, "edit");
598
598
  } else
599
599
  N("edit"), C(y), f(!0);
600
600
  }, [ce, e, a]), ue = L((y) => {
601
601
  if (ce === "page" && e.onNavigate) {
602
- const D = y._id || y.id;
602
+ const D = y.id || y._id;
603
603
  e.onNavigate(D, "view");
604
604
  } else
605
605
  N("view"), C(y), f(!0);
@@ -612,7 +612,7 @@ const zi = ({
612
612
  if (T.mode === "none" || T.preventNavigation)
613
613
  return;
614
614
  if (T.mode === "new_window" || T.openNewTab) {
615
- const D = y._id || y.id, E = `/${e.objectName}/${encodeURIComponent(String(D))}`;
615
+ const D = y.id || y._id, E = `/${e.objectName}/${encodeURIComponent(String(D))}`;
616
616
  window.open(E, "_blank");
617
617
  return;
618
618
  }
@@ -625,7 +625,7 @@ const zi = ({
625
625
  return;
626
626
  }
627
627
  if (T.mode === "page") {
628
- const D = y._id || y.id;
628
+ const D = y.id || y._id;
629
629
  e.onNavigate && e.onNavigate(D, "view");
630
630
  return;
631
631
  }
@@ -829,7 +829,7 @@ const zi = ({
829
829
  bordered: d?.bordered ?? e.table?.bordered,
830
830
  className: e.table?.className
831
831
  }), [e, Y, $, d]), se = () => {
832
- const y = m ? m._id || m.id : void 0;
832
+ const y = m ? m.id || m._id : void 0;
833
833
  return {
834
834
  type: "object-form",
835
835
  objectName: e.objectName,
@@ -3,7 +3,7 @@
3
3
  <%s {...props} />
4
4
  React keys must be passed directly to JSX without using spread:
5
5
  let props = %s;
6
- <%s key={someKey} {...props} />`,O,G,oe,G),ye[G+O]=!0)}if(G=null,V!==void 0&&(n(V),G=""+V),c(u)&&(n(u.key),G=""+u.key),"key"in u){V={};for(var de in u)de!=="key"&&(V[de]=u[de])}else V=u;return G&&a(V,typeof b=="function"?b.displayName||b.name||"Unknown":b),g(b,G,V,s(),le,q)}function d(b){C(b)?b._store&&(b._store.validated=1):typeof b=="object"&&b!==null&&b.$$typeof===P&&(b._payload.status==="fulfilled"?C(b._payload.value)&&b._payload.value._store&&(b._payload.value._store.validated=1):b._store&&(b._store.validated=1))}function C(b){return typeof b=="object"&&b!==null&&b.$$typeof===D}var m=o,D=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),I=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),L=Symbol.for("react.suspense"),y=Symbol.for("react.suspense_list"),k=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),z=Symbol.for("react.client.reference"),U=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te=Object.prototype.hasOwnProperty,Q=Array.isArray,fe=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(b){return b()}};var he,ee={},R=m.react_stack_bottom_frame.bind(m,l)(),W=fe(r(l)),ye={};Ze.Fragment=S,Ze.jsx=function(b,u,V){var O=1e4>U.recentlyCreatedOwnerStacks++;return x(b,u,V,!1,O?Error("react-stack-top-frame"):R,O?fe(r(b)):W)},Ze.jsxs=function(b,u,V){var O=1e4>U.recentlyCreatedOwnerStacks++;return x(b,u,V,!0,O?Error("react-stack-top-frame"):R,O?fe(r(b)):W)}})()),Ze}var on;function rr(){return on||(on=1,process.env.NODE_ENV==="production"?bt.exports=tr():bt.exports=nr()),bt.exports}var i=rr();function an(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(n=an(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function ir(){for(var e,t,n=0,r="",s=arguments.length;n<s;n++)(e=arguments[n])&&(t=an(e))&&(r&&(r+=" "),r+=t);return r}const cn=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,dn=ir,Ye=(e,t)=>n=>{var r;if(t?.variants==null)return dn(e,n?.class,n?.className);const{variants:s,defaultVariants:l}=t,c=Object.keys(s).map(g=>{const x=n?.[g],d=l?.[g];if(x===null)return null;const C=cn(x)||cn(d);return s[g][C]}),a=n&&Object.entries(n).reduce((g,x)=>{let[d,C]=x;return C===void 0||(g[d]=C),g},{}),f=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((g,x)=>{let{class:d,className:C,...m}=x;return Object.entries(m).every(D=>{let[p,S]=D;return Array.isArray(S)?S.includes({...l,...a}[p]):{...l,...a}[p]===S})?[...g,d,C]:g},[]);return dn(e,c,f,n?.class,n?.className)},sr={list:"List",detail:"Detail",grid:"Grid",kanban:"Kanban",calendar:"Calendar",timeline:"Timeline",map:"Map",gallery:"Gallery",gantt:"Gantt"},lr={list:F.List,detail:F.FileText,grid:F.Grid,kanban:F.LayoutGrid,calendar:F.Calendar,timeline:F.Activity,map:F.Map,gallery:F.Images,gantt:F.GanttChartSquare},or=Ye("flex gap-4",{variants:{position:{top:"flex-col",bottom:"flex-col-reverse",left:"flex-row",right:"flex-row-reverse"}},defaultVariants:{position:"top"}}),ar=Ye("w-full",{variants:{orientation:{horizontal:"w-full",vertical:"w-48"}},defaultVariants:{orientation:"horizontal"}}),cr=Ye("flex gap-2",{variants:{orientation:{horizontal:"flex-row flex-wrap",vertical:"flex-col"}},defaultVariants:{orientation:"horizontal"}}),dr=Ye("",{variants:{orientation:{horizontal:"",vertical:"flex h-auto flex-col items-stretch"}},defaultVariants:{orientation:"horizontal"}});function ur(e){return e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")}const fr={Home:"House"};function un(e){if(!e)return null;const t=ur(e),n=fr[t]||t;return F.icons[n]||null}function It(e){return e.label?e.label:sr[e.type]||e.type}function fn(e){return e.icon?un(e.icon):lr[e.type]||null}function hr(e){return e.activeView?e.activeView:e.defaultView?e.defaultView:e.views?.[0]?.type}const hn={share:F.Share2,settings:F.Settings,duplicate:F.Copy,delete:F.Trash2},pr={share:"Share",settings:"Settings",duplicate:"Duplicate",delete:"Delete"},Ot=({schema:e,className:t,onViewChange:n,onCreateView:r,onViewAction:s,createViewLabel:l="Create view",...c})=>{const a=X.useMemo(()=>e.storageKey?e.storageKey:`view-switcher${e.id?`-${e.id}`:""}`,[e.id,e.storageKey]),[f,g]=X.useState(()=>hr(e));X.useEffect(()=>{if(e.activeView){g(e.activeView);return}if(e.persistPreference)try{const y=localStorage.getItem(a);if(y){const k=e.views.find(P=>P.type===y)?.type;k&&g(k)}}catch{}},[e.activeView,e.persistPreference,e.views,a]),X.useEffect(()=>{if(!(!e.persistPreference||!f||e.activeView))try{localStorage.setItem(a,f)}catch{}},[f,e.activeView,e.persistPreference,a]);const x=X.useCallback(y=>{n?.(y),e.onViewChange&&typeof window<"u"&&window.dispatchEvent(new CustomEvent(e.onViewChange,{detail:{view:y}}))},[n,e.onViewChange]),d=X.useCallback(y=>{g(y),x(y)},[x]),C=f||e.views?.[0]?.type,m=C||"",D=e.views.find(y=>y.type===C)||e.views?.[0],p=e.variant||"tabs",S=e.position||"top",E=S==="left"||S==="right",w=E?"vertical":"horizontal",N=e.viewActions&&e.viewActions.length>0?i.jsx("div",{className:"flex items-center gap-1",children:e.viewActions.map((y,k)=>{const P=y.icon&&un(y.icon)||hn[y.type];return i.jsx(h.Button,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>s?.(y.type,C),title:pr[y.type]||y.type,children:P?i.jsx(P,{className:"h-3.5 w-3.5"}):null},`action-${y.type}-${k}`)})}):null,I=e.allowCreateView?i.jsx(h.Button,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>r?.(),title:l,children:i.jsx(F.Plus,{className:"h-3.5 w-3.5"})}):null,M=i.jsxs("div",{className:h.cn(ar({orientation:w}),"flex items-center gap-1"),children:[p==="dropdown"&&i.jsxs(h.Select,{value:m,onValueChange:y=>d(y),children:[i.jsx(h.SelectTrigger,{className:h.cn("w-full",E?"h-10":"h-9"),children:i.jsx(h.SelectValue,{placeholder:"Select view"})}),i.jsx(h.SelectContent,{children:e.views.map((y,k)=>i.jsx(h.SelectItem,{value:y.type,children:It(y)},`${y.type}-${k}`))})]}),p==="buttons"&&i.jsx("div",{className:h.cn(cr({orientation:w})),children:e.views.map((y,k)=>{const P=y.type===C,_=fn(y);return i.jsxs(h.Button,{type:"button",size:"sm",variant:P?"secondary":"ghost",className:h.cn("justify-start gap-2",E?"w-full":""),onClick:()=>d(y.type),children:[_?i.jsx(_,{className:"h-4 w-4"}):null,i.jsx("span",{children:It(y)})]},`${y.type}-${k}`)})}),p==="tabs"&&i.jsx(h.Tabs,{value:m,onValueChange:y=>d(y),children:i.jsx(h.TabsList,{className:h.cn(dr({orientation:w})),children:e.views.map((y,k)=>{const P=fn(y);return i.jsxs(h.TabsTrigger,{value:y.type,className:h.cn("gap-2",E?"justify-start":""),children:[P?i.jsx(P,{className:"h-4 w-4"}):null,i.jsx("span",{children:It(y)})]},`${y.type}-${k}`)})})}),N,I]}),L=D?.schema?Array.isArray(D.schema)?i.jsx("div",{className:"space-y-4",children:D.schema.map((y,k)=>i.jsx(rn.SchemaRenderer,{schema:y,...c},`${D.type}-${k}`))}):i.jsx(rn.SchemaRenderer,{schema:D.schema,...c}):null;return i.jsxs("div",{className:h.cn(or({position:S}),t),children:[i.jsx("div",{className:h.cn("shrink-0",E?"flex flex-col":"flex"),children:M}),i.jsx("div",{className:"flex-1 min-w-0",children:L})]})};let vt=null;try{vt=require("@object-ui/react").SchemaRenderer||null}catch{}const pn=({schema:e,dataSource:t,className:n,views:r,activeViewId:s,onViewChange:l,onRowClick:c,onEdit:a,renderListView:f,toolbarAddon:g,onCreateView:x,onViewAction:d})=>{const[C,m]=o.useState(null),[D,p]=o.useState(!1),[S,E]=o.useState("create"),[w,N]=o.useState(null),[I,M]=o.useState(0),[L,y]=o.useState([]),[k,P]=o.useState(!1),[_,z]=o.useState({}),[U,te]=o.useState([]),Q=e.listViews,fe=Q!=null&&Object.keys(Q).length>0,[he,ee]=o.useState(()=>e.defaultListView&&Q?.[e.defaultListView]?e.defaultListView:Q&&Object.keys(Q)[0]||""),R=o.useMemo(()=>!fe||!he?null:Q[he]||null,[fe,he,Q]),W=o.useMemo(()=>r&&r.length>0?r:null,[r]),ye=W!=null&&W.length>0,b=s||W?.[0]?.id,u=W?.find(j=>j.id===b)||W?.[0],V=o.useMemo(()=>R?.type?R.type:u?.type?u.type:e.defaultViewType||"grid",[R,u,e.defaultViewType]),O=e.navigation;o.useEffect(()=>{let j=!0;const T=async()=>{try{const A=await t.getObjectSchema(e.objectName);j&&m(A)}catch(A){console.error("Failed to fetch object schema:",A)}};return e.objectName&&t&&T(),()=>{j=!1}},[e.objectName,t]),o.useEffect(()=>{let j=!0;return(async()=>{if(!(V==="grid"&&!f)&&!(!t||!e.objectName)){P(!0);try{const A=R?.filter||u?.filter||e.table?.defaultFilters||[],ve=Object.entries(_).filter(([,$])=>$!==void 0&&$!==""&&$!==null).map(([$,me])=>[$,"=",me]);let ie=[];A.length>0&&ve.length>0?ie=["and",...A,...ve]:ve.length===1?ie=ve[0]:ve.length>1?ie=["and",...ve]:ie=A;const xe=U.length>0?U.map($=>({field:$.field,order:$.direction})):R?.sort||u?.sort||e.table?.defaultSort||void 0,se=Ve.buildExpandFields(C?.fields),ge=await t.find(e.objectName,{$filter:ie.length>0?ie:void 0,$orderby:xe,$top:100,...se.length>0?{$expand:se}:{}});let J=[];Array.isArray(ge)?J=ge:ge&&typeof ge=="object"&&(Array.isArray(ge.data)?J=ge.data:Array.isArray(ge.records)&&(J=ge.records)),j&&y(J)}catch(A){console.error("ObjectView data fetch error:",A)}finally{j&&P(!1)}}})(),()=>{j=!1}},[e.objectName,t,V,_,U,I,R,u,f,C]);const le=e.layout||"drawer",q=e.operations||e.table?.operations||{create:!0,read:!0,update:!0,delete:!0},G=o.useCallback(()=>{le==="page"&&e.onNavigate?e.onNavigate("new","edit"):(E("create"),N(null),p(!0))},[le,e]),oe=o.useCallback(j=>{if(a){a(j);return}if(le==="page"&&e.onNavigate){const T=j._id||j.id;e.onNavigate(T,"edit")}else E("edit"),N(j),p(!0)},[le,e,a]),de=o.useCallback(j=>{if(le==="page"&&e.onNavigate){const T=j._id||j.id;e.onNavigate(T,"view")}else E("view"),N(j),p(!0)},[le,e]),v=o.useCallback(j=>{if(c){c(j);return}if(O){if(O.mode==="none"||O.preventNavigation)return;if(O.mode==="new_window"||O.openNewTab){const T=j._id||j.id,A=`/${e.objectName}/${encodeURIComponent(String(T))}`;window.open(A,"_blank");return}if(O.mode==="drawer"){E("view"),N(j),p(!0);return}if(O.mode==="modal"){E("view"),N(j),p(!0);return}if(O.mode==="page"){const T=j._id||j.id;e.onNavigate&&e.onNavigate(T,"view");return}if(O.mode==="split"||O.mode==="popover"){E("view"),N(j),p(!0);return}}q.read!==!1&&de(j)},[c,O,q.read,de,e]),Z=o.useCallback(j=>{M(T=>T+1)},[]),K=o.useCallback(j=>{M(T=>T+1)},[]),ne=o.useCallback(()=>{p(!1),N(null),M(j=>j+1)},[]),Y=o.useCallback(()=>{p(!1),N(null)},[]);o.useCallback(()=>{M(j=>j+1)},[]);const Ce=o.useMemo(()=>!ye||!W||W.length<=1?null:{type:"view-switcher",variant:"tabs",position:"top",persistPreference:!0,storageKey:`view-pref-${e.objectName}`,defaultView:u?.type||"grid",activeView:u?.type||"grid",views:W.map(j=>{const T={kanban:"kanban",calendar:"calendar",map:"map",gallery:"layout-grid",timeline:"activity",gantt:"gantt-chart",grid:"table",list:"list",detail:"file-text"};return{type:j.type,label:j.label,icon:T[j.type]||"table"}}),allowCreateView:e.allowCreateView,viewActions:e.viewActions},[ye,W,u,e.objectName,e.allowCreateView,e.viewActions]),pe=o.useCallback(j=>{if(!W)return;const T=W.find(A=>A.type===j);T&&l&&l(T.id)},[W,l]),ct=o.useCallback(j=>{ee(j)},[]);o.useMemo(()=>{if(e.showFilters===!1)return null;const j=e.filterableFields,T=C?.fields||{},ve=(j?j.map(ie=>[ie,T[ie]||{label:ie}]):Object.entries(T).filter(([,ie])=>!ie.hidden).slice(0,8)).map(([ie,xe])=>{const se=xe.type||"text";let ge="text",J;return se==="number"||se==="currency"||se==="percent"?ge="number":se==="boolean"||se==="toggle"?ge="boolean":se==="date"||se==="datetime"?ge="date":se==="select"||se==="status"||xe.options?(ge="select",J=(xe.options||[]).map($=>typeof $=="string"?{label:$,value:$}:{label:$.label,value:$.value})):(se==="lookup"||se==="master_detail"||se==="user"||se==="owner")&&xe.options&&xe.options.length>0&&(ge="multi-select",J=(xe.options||[]).map($=>typeof $=="string"?{label:$,value:$}:{label:$.label,value:$.value})),{field:ie,label:xe.label||ie,type:ge,placeholder:`Filter ${xe.label||ie}...`,...J?{options:J}:{}}});return ve.length===0?null:{type:"filter-ui",layout:"popover",showClear:!0,showApply:!0,filters:ve,values:_}},[e.showFilters,e.filterableFields,C,_]);const Re=e.showSort;o.useMemo(()=>{if(Re===!1)return null;const j=C?.fields||{},T=Object.entries(j).filter(([,A])=>!A.hidden).slice(0,10).map(([A,ve])=>({field:A,label:ve.label||A}));return T.length===0?null:{type:"sort-ui",variant:"dropdown",multiple:!1,fields:T,sort:U}},[C,U,Re]);const Le=o.useCallback(j=>{const T={objectName:e.objectName,fields:R?.columns||u?.columns||e.table?.fields,className:"h-full w-full",showSearch:u?.showSearch??e.showSearch??!1,showSort:u?.showSort??e.showSort??!1,showFilters:u?.showFilters??e.showFilters??!1,striped:u?.striped??!1,bordered:u?.bordered??!1,color:u?.color},A=R?.options||u||{};if(process.env.NODE_ENV==="development"){const ve=["startDateField","endDateField","dateField","groupBy","groupField","locationField","imageField","dependenciesField","progressField","titleField","subtitleField","latitudeField","longitudeField"],ie=A[j]||{},xe=ve.filter(se=>se in A&&!(se in ie));xe.length>0&&console.warn(`[Spec Compliance] View options use flat properties ${JSON.stringify(xe)}. Move them under options.${j} per @objectstack/spec protocol.`)}switch(j){case"kanban":return{type:"object-kanban",...T,groupBy:A.kanban?.groupField||"status",groupField:A.kanban?.groupField||"status",titleField:A.kanban?.titleField||"name",cardFields:T.fields||[],...A.kanban||{}};case"calendar":return{type:"object-calendar",...T,startDateField:A.calendar?.startDateField||"start_date",endDateField:A.calendar?.endDateField||"end_date",titleField:A.calendar?.titleField||"name",...A.calendar||{}};case"gallery":return{type:"object-gallery",...T,imageField:A.gallery?.imageField,titleField:A.gallery?.titleField||"name",subtitleField:A.gallery?.subtitleField,...A.gallery||{}};case"timeline":return{type:"object-timeline",...T,dateField:A.timeline?.dateField||"created_at",titleField:A.timeline?.titleField||"name",...A.timeline||{}};case"gantt":return{type:"object-gantt",...T,startDateField:A.gantt?.startDateField||"start_date",endDateField:A.gantt?.endDateField||"end_date",progressField:A.gantt?.progressField||"progress",dependenciesField:A.gantt?.dependenciesField||"dependencies",...A.gantt||{}};case"map":return{type:"object-map",...T,locationField:A.map?.locationField||"location",...A.map||{}};default:return null}},[e.objectName,e.table?.fields,R,u]),je=o.useMemo(()=>({type:"object-grid",objectName:e.objectName,title:e.table?.title,description:e.table?.description,fields:R?.columns||u?.columns||e.table?.fields,columns:R?.columns||u?.columns||e.table?.columns,operations:{...q,create:!1},defaultFilters:R?.filter||u?.filter||e.table?.defaultFilters,defaultSort:R?.sort||u?.sort||e.table?.defaultSort,pageSize:e.table?.pageSize,selectable:e.table?.selectable,striped:u?.striped??e.table?.striped,bordered:u?.bordered??e.table?.bordered,className:e.table?.className}),[e,q,R,u]),re=()=>{const j=w?w._id||w.id:void 0;return{type:"object-form",objectName:e.objectName,mode:S,recordId:j,title:e.form?.title,description:e.form?.description,fields:e.form?.fields,customFields:e.form?.customFields,groups:e.form?.groups,layout:e.form?.layout,columns:e.form?.columns,showSubmit:e.form?.showSubmit,submitText:e.form?.submitText,showCancel:e.form?.showCancel,cancelText:e.form?.cancelText,showReset:e.form?.showReset,initialValues:e.form?.initialValues,readOnly:e.form?.readOnly||S==="view",className:e.form?.className,onSuccess:ne,onCancel:Y}},H=()=>{if(e.form?.title)return e.form.title;const j=C?.label||e.objectName;switch(S){case"create":return`Create ${j}`;case"edit":return`Edit ${j}`;case"view":return`View ${j}`;default:return j}},Fe=o.useMemo(()=>{const j=O?.width;return j?typeof j=="number"?`max-w-[${j}px]`:`max-w-[${j}]`:""},[O]),Xe=()=>i.jsx(h.Drawer,{open:D,onOpenChange:p,direction:"right",children:i.jsxs(h.DrawerContent,{className:h.cn("w-full sm:max-w-2xl",Fe),children:[i.jsxs(h.DrawerHeader,{children:[i.jsx(h.DrawerTitle,{children:H()}),e.form?.description&&i.jsx(h.DrawerDescription,{children:e.form.description})]}),i.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:i.jsx(At.ObjectForm,{schema:re(),dataSource:t})})]})}),dt=()=>i.jsx(h.Dialog,{open:D,onOpenChange:p,children:i.jsxs(h.DialogContent,{className:h.cn("max-w-2xl max-h-[90vh] overflow-y-auto",Fe),children:[i.jsxs(h.DialogHeader,{children:[i.jsx(h.DialogTitle,{children:H()}),e.form?.description&&i.jsx(h.DialogDescription,{children:e.form.description})]}),i.jsx(At.ObjectForm,{schema:re(),dataSource:t})]})}),tn=o.useMemo(()=>Object.keys(_).some(T=>_[T]!==void 0&&_[T]!==""&&_[T]!==null)?Object.entries(_).filter(([,T])=>T!==void 0&&T!==""&&T!==null).map(([T,A])=>({field:T,operator:"equals",value:A})):R?.filter||u?.filter||e.table?.defaultFilters,[_,R,u,e.table?.defaultFilters]),_e=o.useMemo(()=>U.length>0?U:R?.sort||u?.sort||e.table?.defaultSort,[U,R,u,e.table?.defaultSort]),Ae=()=>{const j=`${e.objectName}-${he||u?.id||"default"}-${V}-${I}`;if(f)return f({schema:{type:"list-view",objectName:e.objectName,viewType:V,fields:R?.columns||u?.columns||e.table?.fields,filters:tn,sort:_e,rowHeight:u?.rowHeight,densityMode:u?.densityMode,groupBy:u?.groupBy,options:R?.options||u,showSearch:u?.showSearch??e.showSearch,showFilters:u?.showFilters??e.showFilters,showSort:u?.showSort??e.showSort,showHideFields:u?.showHideFields??e.showHideFields,showGroup:u?.showGroup??e.showGroup,showColor:u?.showColor??e.showColor,showDensity:u?.showDensity??e.showDensity,allowExport:u?.allowExport??e.allowExport,striped:u?.striped??e.striped,bordered:u?.bordered??e.bordered,color:u?.color??e.color,inlineEdit:u?.inlineEdit??e.inlineEdit,wrapHeaders:u?.wrapHeaders??e.wrapHeaders,clickIntoRecordDetails:u?.clickIntoRecordDetails??e.clickIntoRecordDetails,addRecordViaForm:u?.addRecordViaForm??e.addRecordViaForm,addDeleteRecordsInline:u?.addDeleteRecordsInline??e.addDeleteRecordsInline,collapseAllByDefault:u?.collapseAllByDefault??e.collapseAllByDefault,fieldTextColor:u?.fieldTextColor??e.fieldTextColor,prefixField:u?.prefixField??e.prefixField,showDescription:u?.showDescription??e.showDescription,navigation:u?.navigation??e.navigation,selection:u?.selection??e.selection,pagination:u?.pagination??e.pagination,searchableFields:u?.searchableFields??e.searchableFields,filterableFields:u?.filterableFields??e.filterableFields,resizable:u?.resizable??e.resizable,hiddenFields:u?.hiddenFields??e.hiddenFields,rowActions:u?.rowActions??e.rowActions,bulkActions:u?.bulkActions??e.bulkActions,sharing:u?.sharing??e.sharing,addRecord:u?.addRecord??e.addRecord,conditionalFormatting:u?.conditionalFormatting??e.conditionalFormatting,quickFilters:u?.quickFilters??e.quickFilters,userFilters:u?.userFilters??e.userFilters,showRecordCount:u?.showRecordCount??e.showRecordCount,allowPrinting:u?.allowPrinting??e.allowPrinting,virtualScroll:u?.virtualScroll??e.virtualScroll,emptyState:u?.emptyState??e.emptyState,aria:u?.aria??e.aria,tabs:e.tabs},dataSource:t,onEdit:oe,onRowClick:v,className:"h-full"});if(V!=="grid"){const T=Le(V);if(T&&vt)return i.jsx(vt,{schema:T,dataSource:t,data:L,loading:k},j);if(!vt)return i.jsx("div",{className:"flex items-center justify-center h-40 text-muted-foreground",children:i.jsxs("p",{children:["SchemaRenderer not available. Install @object-ui/react to render ",V," views."]})})}return i.jsx(Zn.ObjectGrid,{schema:je,dataSource:t,onRowClick:v,onEdit:q.update!==!1?oe:void 0,onDelete:q.delete!==!1?Z:void 0,onBulkDelete:q.delete!==!1?K:void 0},j)},Ue=()=>{if(!fe)return null;const j=Object.entries(Q);return j.length<=1?null:i.jsx(h.Tabs,{value:he,onValueChange:ct,className:"w-full",children:i.jsx(h.TabsList,{className:"w-auto",children:j.map(([T,A])=>i.jsx(h.TabsTrigger,{value:T,className:"text-sm",children:A.label||T},T))})})},ut=()=>{const j=e.showCreate!==!1&&q.create!==!1,T=e.showViewSwitcher===!0,A=Ue();return!A&&!T&&!j&&!g?null:i.jsxs("div",{className:"flex flex-col gap-3",children:[A,(T||j||g)&&i.jsxs("div",{className:"flex items-center justify-between gap-4",children:[i.jsx("div",{className:"flex items-center gap-2",children:T&&Ce&&i.jsx(Ot,{schema:Ce,onViewChange:pe,onCreateView:x,onViewAction:d,className:"overflow-x-auto"})}),i.jsxs("div",{className:"flex items-center gap-2",children:[g,j&&i.jsxs(h.Button,{size:"sm",onClick:G,children:[i.jsx(F.Plus,{className:"h-4 w-4"}),"Create"]})]})]})]})},Se=O?.mode==="modal"?"modal":O?.mode==="drawer"?"drawer":O?.mode==="split"?"split":O?.mode==="popover"?"popover":le,ft=j=>i.jsx("div",{className:"space-y-3",children:i.jsx(At.ObjectForm,{schema:re(),dataSource:t})}),kt=o.useCallback(j=>{j||Y()},[Y]);if(Se==="split"){const j=C?.label||e.objectName;return i.jsxs("div",{className:h.cn("flex flex-col h-full min-w-0 overflow-hidden",n),children:[(e.title||e.description)&&i.jsxs("div",{className:"mb-4 shrink-0",children:[e.title&&i.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:e.title}),e.description&&i.jsx("p",{className:"text-muted-foreground mt-1",children:e.description})]}),i.jsx("div",{className:"mb-4 shrink-0",children:ut()}),i.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden",children:D&&w?i.jsx(h.NavigationOverlay,{isOpen:D,selectedRecord:w,mode:"split",close:Y,setIsOpen:kt,width:O?.width,isOverlay:!0,title:`${j} Detail`,mainContent:i.jsx("div",{className:"h-full overflow-auto",children:Ae()}),children:ft}):Ae()})]})}return i.jsxs("div",{className:h.cn("flex flex-col h-full min-w-0 overflow-hidden",n),children:[(e.title||e.description)&&i.jsxs("div",{className:"mb-4 shrink-0",children:[e.title&&i.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:e.title}),e.description&&i.jsx("p",{className:"text-muted-foreground mt-1",children:e.description})]}),i.jsx("div",{className:"mb-4 shrink-0",children:ut()}),i.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden",children:Ae()}),Se==="drawer"&&Xe(),Se==="modal"&&dt(),Se==="popover"&&D&&w&&i.jsx(h.NavigationOverlay,{isOpen:D,selectedRecord:w,mode:"popover",close:Y,setIsOpen:kt,width:O?.width,isOverlay:!0,title:H(),children:ft})]})},Ft=Ye("flex",{variants:{layout:{inline:"flex-col space-y-4",popover:"items-center",drawer:"items-center"}},defaultVariants:{layout:"inline"}}),gr=e=>e==null||e===""?!0:Array.isArray(e)?e.length===0:typeof e=="object"?Object.values(e).every(t=>t==null||t===""):!1,br=e=>Array.isArray(e)?{start:e[0]||"",end:e[1]||""}:e&&typeof e=="object"?{start:e.start||"",end:e.end||""}:{start:"",end:""},gn=({schema:e,className:t,onChange:n})=>{const[r,s]=X.useState(e.values||{}),[l,c]=X.useState(!1);X.useEffect(()=>{e.values&&s(e.values)},[e.values]);const a=X.useCallback(p=>{n?.(p),e.onChange&&typeof window<"u"&&window.dispatchEvent(new CustomEvent(e.onChange,{detail:{values:p}}))},[n,e.onChange]),f=X.useCallback((p,S)=>{const E={...r,[p]:S};s(E),e.showApply||a(E)},[a,e.showApply,r]),g=X.useCallback(()=>{const p={};if(s(p),e.showApply){a(p);return}a(p)},[a,e.showApply]),x=X.useCallback(()=>{a(r),c(!1)},[a,r]),d=X.useMemo(()=>Object.values(r).filter(p=>!gr(p)).length,[r]),C=p=>{const S=p.label||p.field,E=p.placeholder||`Filter by ${S}`;switch(p.type){case"number":return i.jsx(h.Input,{type:"number",value:r[p.field]??"",placeholder:E,onChange:w=>{const N=w.target.value,I=N===""?"":Number(N);f(p.field,I)}});case"select":return i.jsxs(h.Select,{value:r[p.field]!==void 0?String(r[p.field]):"",onValueChange:w=>{const N=p.options?.find(I=>String(I.value)===w);f(p.field,N?N.value:w)},children:[i.jsx(h.SelectTrigger,{children:i.jsx(h.SelectValue,{placeholder:E})}),i.jsx(h.SelectContent,{children:p.options?.map(w=>i.jsx(h.SelectItem,{value:String(w.value),children:w.label},String(w.value)))})]});case"multi-select":{const w=r[p.field],N=Array.isArray(w)?w:w?[w]:[];return i.jsx("div",{className:"max-h-40 overflow-y-auto space-y-0.5 border rounded-md p-2",children:p.options?.map(I=>{const M=N.map(String).includes(String(I.value));return i.jsxs("label",{className:h.cn("flex items-center gap-2 text-sm py-1 px-1.5 rounded cursor-pointer",M?"bg-primary/5 text-primary":"hover:bg-muted"),children:[i.jsx(h.Checkbox,{checked:M,onCheckedChange:L=>{const y=L?[...N,I.value]:N.filter(k=>String(k)!==String(I.value));f(p.field,y)}}),i.jsx("span",{className:"truncate",children:I.label})]},String(I.value))})})}case"date":return i.jsx(h.Input,{type:"date",value:r[p.field]??"",onChange:w=>f(p.field,w.target.value)});case"date-range":{const w=br(r[p.field]);return i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(h.Input,{type:"date",value:w.start??"",onChange:N=>{f(p.field,{...w,start:N.target.value})}}),i.jsx(h.Input,{type:"date",value:w.end??"",onChange:N=>{f(p.field,{...w,end:N.target.value})}})]})}case"boolean":return i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(h.Checkbox,{checked:!!r[p.field],onCheckedChange:w=>f(p.field,!!w)}),i.jsx("span",{className:"text-sm text-muted-foreground",children:"Enabled"})]});default:return i.jsx(h.Input,{value:r[p.field]??"",placeholder:E,onChange:w=>f(p.field,w.target.value)})}},m=i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"grid gap-4 sm:grid-cols-2",children:e.filters.map(p=>i.jsxs("div",{className:"space-y-2",children:[i.jsx(h.Label,{className:"text-xs text-muted-foreground",children:p.label||p.field}),C(p)]},p.field))}),(e.showApply||e.showClear)&&i.jsxs("div",{className:"flex items-center justify-end gap-2 border-t pt-3",children:[e.showClear&&i.jsx(h.Button,{type:"button",variant:"ghost",size:"sm",onClick:g,children:"Clear"}),e.showApply&&i.jsx(h.Button,{type:"button",size:"sm",onClick:x,children:"Apply"})]})]}),D=e.layout||"inline";return D==="popover"?i.jsx("div",{className:h.cn(Ft({layout:D}),t),children:i.jsxs(h.Popover,{open:l,onOpenChange:c,children:[i.jsx(h.PopoverTrigger,{asChild:!0,children:i.jsxs(h.Button,{type:"button",variant:d>0?"secondary":"outline",size:"sm",className:"gap-2",children:[i.jsx(F.SlidersHorizontal,{className:"h-4 w-4"}),"Filters",d>0&&i.jsx("span",{className:"inline-flex h-5 min-w-[20px] items-center justify-center rounded-full bg-primary/10 px-1 text-xs font-medium text-primary",children:d})]})}),i.jsx(h.PopoverContent,{align:"start",className:"w-[520px] p-4",children:m})]})}):D==="drawer"?i.jsxs("div",{className:h.cn(Ft({layout:D}),t),children:[i.jsxs(h.Button,{type:"button",variant:d>0?"secondary":"outline",size:"sm",className:"gap-2",onClick:()=>c(!0),children:[i.jsx(F.SlidersHorizontal,{className:"h-4 w-4"}),"Filters",d>0&&i.jsx("span",{className:"inline-flex h-5 min-w-[20px] items-center justify-center rounded-full bg-primary/10 px-1 text-xs font-medium text-primary",children:d})]}),i.jsx(h.Drawer,{open:l,onOpenChange:c,children:i.jsxs(h.DrawerContent,{children:[i.jsxs(h.DrawerHeader,{children:[i.jsx(h.DrawerTitle,{children:"Filters"}),i.jsx(h.DrawerDescription,{children:"Refine the data with advanced filters."})]}),i.jsx("div",{className:"px-4 pb-6",children:m})]})})]}):i.jsxs("div",{className:h.cn(Ft({layout:D}),t),children:[m,!e.showApply&&e.showClear&&i.jsxs(h.Button,{type:"button",variant:"ghost",size:"sm",className:"gap-2",onClick:g,children:[i.jsx(F.X,{className:"h-3.5 w-3.5"}),"Clear filters"]})]})},Mt=Ye("",{variants:{variant:{buttons:"flex flex-wrap gap-2",dropdown:"flex flex-wrap items-center gap-3",builder:"space-y-3"}},defaultVariants:{variant:"dropdown"}}),Vt=e=>e?e.map(t=>({field:t.field,direction:t.direction})):[],bn=e=>e.map(t=>({id:`${t.field}-${t.direction}`,field:t.field,order:t.direction})),vr=e=>e.filter(t=>t.field).map(t=>({field:t.field,direction:t.order})),vn=({schema:e,className:t,onChange:n})=>{const[r,s]=X.useState(()=>Vt(e.sort)),[l,c]=X.useState(()=>bn(Vt(e.sort)));X.useEffect(()=>{const d=Vt(e.sort);s(d),c(bn(d))},[e.sort]);const a=X.useCallback(d=>{s(d),n?.(d),e.onChange&&typeof window<"u"&&window.dispatchEvent(new CustomEvent(e.onChange,{detail:{sort:d}}))},[n,e.onChange]),f=X.useCallback(d=>{const C=r.find(p=>p.field===d),m=!!e.multiple;if(!C){const p=m?[...r,{field:d,direction:"asc"}]:[{field:d,direction:"asc"}];a(p);return}if(C.direction==="asc"){const p=r.map(S=>S.field===d?{...S,direction:"desc"}:S);a(p);return}const D=r.filter(p=>p.field!==d);a(D)},[a,e.multiple,r]);if((e.variant||"dropdown")==="buttons")return i.jsx("div",{className:h.cn(Mt({variant:"buttons"}),t),children:e.fields.map(d=>{const C=r.find(D=>D.field===d.field),m=C?.direction==="asc"?F.ArrowUp:F.ArrowDown;return i.jsxs(h.Button,{type:"button",variant:C?"secondary":"outline",size:"sm",onClick:()=>f(d.field),className:"gap-2",children:[i.jsx("span",{children:d.label||d.field}),C&&i.jsx(m,{className:"h-3.5 w-3.5"})]},d.field)})});if(e.multiple)return i.jsx("div",{className:h.cn(Mt({variant:"builder"}),t),children:i.jsx(h.SortBuilder,{fields:e.fields.map(d=>({value:d.field,label:d.label||d.field})),value:l,onChange:d=>{c(d),a(vr(d))}})});const x=r[0];return i.jsxs("div",{className:h.cn(Mt({variant:"dropdown"}),t),children:[i.jsxs(h.Select,{value:x?.field||"",onValueChange:d=>{if(!d){a([]);return}a([{field:d,direction:x?.direction||"asc"}])},children:[i.jsx(h.SelectTrigger,{className:"w-56",children:i.jsx(h.SelectValue,{placeholder:"Select field"})}),i.jsx(h.SelectContent,{children:e.fields.map(d=>i.jsx(h.SelectItem,{value:d.field,children:d.label||d.field},d.field))})]}),i.jsxs(h.Select,{value:x?.direction||"asc",onValueChange:d=>{x?.field&&a([{field:x.field,direction:d}])},children:[i.jsx(h.SelectTrigger,{className:"w-36",children:i.jsx(h.SelectValue,{})}),i.jsxs(h.SelectContent,{children:[i.jsx(h.SelectItem,{value:"asc",children:"Ascending"}),i.jsx(h.SelectItem,{value:"desc",children:"Descending"})]})]})]})};function xr(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function"){const e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}return Math.random().toString(36).slice(2)+Math.random().toString(36).slice(2)}function mr(e,t,n,r){return`${e}/share/${t}/${n}?mode=readonly&token=${r}`}const xn=({objectName:e,viewId:t="default",baseUrl:n,onShare:r,className:s})=>{const[l,c]=X.useState(null),[a,f]=X.useState(!1),[g,x]=X.useState(!1),[d,C]=X.useState(""),[m,D]=X.useState(""),p=n??(typeof window<"u"?window.location.origin:""),S=X.useCallback(()=>{const w=xr(),N=mr(p,e,t,w);c(N),f(!1);const I=m?new Date(Date.now()+parseInt(m,10)*864e5).toISOString():void 0;r?.(N,{password:d||void 0,expiresAt:I})},[p,e,t,r,d,m]),E=X.useCallback(async()=>{if(l)try{await navigator.clipboard.writeText(l),f(!0),setTimeout(()=>f(!1),2e3)}catch{const w=document.createElement("textarea");w.value=l,document.body.appendChild(w),w.select(),document.execCommand("copy"),document.body.removeChild(w),f(!0),setTimeout(()=>f(!1),2e3)}},[l]);return i.jsxs(h.Popover,{open:g,onOpenChange:x,children:[i.jsx(h.PopoverTrigger,{asChild:!0,children:i.jsxs(h.Button,{variant:"outline",size:"sm",className:h.cn("gap-2",s),children:[i.jsx(F.Share2,{className:"h-4 w-4"}),"Share"]})}),i.jsxs(h.PopoverContent,{className:"w-96 space-y-4",align:"end",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("h4",{className:"text-sm font-medium",children:"Share View"}),i.jsx(h.Badge,{variant:"secondary",className:"text-xs",children:"Read-only"})]}),i.jsx("p",{className:"text-xs text-muted-foreground",children:"Generate a public link to share this view. Recipients can view data without logging in."})]}),l?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(h.Input,{value:l,readOnly:!0,className:"h-8 text-xs",onClick:w=>w.target.select()}),i.jsx(h.Button,{variant:"outline",size:"sm",onClick:E,className:"shrink-0 gap-1",children:a?i.jsx(F.Check,{className:"h-4 w-4 text-green-500"}):i.jsx(F.Copy,{className:"h-4 w-4"})})]}),(d||m)&&i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[d&&i.jsxs(h.Badge,{variant:"outline",className:"text-xs gap-1",children:[i.jsx(F.Lock,{className:"h-3 w-3"}),"Password protected"]}),m&&i.jsxs(h.Badge,{variant:"outline",className:"text-xs gap-1",children:[i.jsx(F.Calendar,{className:"h-3 w-3"}),"Expires in ",m," day",m!=="1"?"s":""]})]})]}):i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("label",{className:"flex items-center gap-1.5 text-xs font-medium text-foreground",children:[i.jsx(F.Lock,{className:"h-3.5 w-3.5"}),"Password protection (optional)"]}),i.jsx(h.Input,{type:"password",value:d,onChange:w=>C(w.target.value),placeholder:"Enter password...",className:"h-8 text-xs"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("label",{className:"flex items-center gap-1.5 text-xs font-medium text-foreground",children:[i.jsx(F.Calendar,{className:"h-3.5 w-3.5"}),"Expires after (optional)"]}),i.jsxs("select",{value:m,onChange:w=>D(w.target.value),className:"w-full h-8 text-xs rounded-md border border-input bg-background px-3",children:[i.jsx("option",{value:"",children:"Never"}),i.jsx("option",{value:"1",children:"1 day"}),i.jsx("option",{value:"7",children:"7 days"}),i.jsx("option",{value:"30",children:"30 days"}),i.jsx("option",{value:"90",children:"90 days"})]})]}),i.jsxs(h.Button,{onClick:S,className:"w-full gap-2",size:"sm",children:[i.jsx(F.Share2,{className:"h-4 w-4"}),"Generate Link"]})]})]})]})};function wr(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return o.useMemo(()=>r=>{t.forEach(s=>s(r))},t)}const xt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function qe(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Pt(e){return"nodeType"in e}function we(e){var t,n;return e?qe(e)?e:Pt(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Lt(e){const{Document:t}=we(e);return e instanceof t}function et(e){return qe(e)?!1:e instanceof we(e).HTMLElement}function mn(e){return e instanceof we(e).SVGElement}function We(e){return e?qe(e)?e.document:Pt(e)?Lt(e)?e:et(e)||mn(e)?e.ownerDocument:document:document:document}const ke=xt?o.useLayoutEffect:o.useEffect;function _t(e){const t=o.useRef(e);return ke(()=>{t.current=e}),o.useCallback(function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];return t.current==null?void 0:t.current(...r)},[])}function yr(){const e=o.useRef(null),t=o.useCallback((r,s)=>{e.current=setInterval(r,s)},[]),n=o.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function tt(e,t){t===void 0&&(t=[e]);const n=o.useRef(e);return ke(()=>{n.current!==e&&(n.current=e)},t),n}function nt(e,t){const n=o.useRef();return o.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function mt(e){const t=_t(e),n=o.useRef(null),r=o.useCallback(s=>{s!==n.current&&t?.(s,n.current),n.current=s},[]);return[n,r]}function $t(e){const t=o.useRef();return o.useEffect(()=>{t.current=e},[e]),t.current}let Bt={};function rt(e,t){return o.useMemo(()=>{if(t)return t;const n=Bt[e]==null?0:Bt[e]+1;return Bt[e]=n,e+"-"+n},[e,t])}function wn(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return r.reduce((l,c)=>{const a=Object.entries(c);for(const[f,g]of a){const x=l[f];x!=null&&(l[f]=x+e*g)}return l},{...t})}}const Ge=wn(1),wt=wn(-1);function Cr(e){return"clientX"in e&&"clientY"in e}function zt(e){if(!e)return!1;const{KeyboardEvent:t}=we(e.target);return t&&e instanceof t}function jr(e){if(!e)return!1;const{TouchEvent:t}=we(e.target);return t&&e instanceof t}function Rt(e){if(jr(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Cr(e)?{x:e.clientX,y:e.clientY}:null}const it=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[it.Translate.toString(e),it.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),yn="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Sr(e){return e.matches(yn)?e:e.querySelector(yn)}const Nr={display:"none"};function Dr(e){let{id:t,value:n}=e;return o.createElement("div",{id:t,style:Nr},n)}function Er(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const s={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return o.createElement("div",{id:t,style:s,role:"status","aria-live":r,"aria-atomic":!0},n)}function Tr(){const[e,t]=o.useState("");return{announce:o.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const Cn=o.createContext(null);function kr(e){const t=o.useContext(Cn);o.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Ar(){const[e]=o.useState(()=>new Set),t=o.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[o.useCallback(r=>{let{type:s,event:l}=r;e.forEach(c=>{var a;return(a=c[s])==null?void 0:a.call(c,l)})},[e]),t]}const Ir={draggable:`
6
+ <%s key={someKey} {...props} />`,O,G,oe,G),ye[G+O]=!0)}if(G=null,V!==void 0&&(n(V),G=""+V),c(u)&&(n(u.key),G=""+u.key),"key"in u){V={};for(var de in u)de!=="key"&&(V[de]=u[de])}else V=u;return G&&a(V,typeof b=="function"?b.displayName||b.name||"Unknown":b),g(b,G,V,s(),le,q)}function d(b){C(b)?b._store&&(b._store.validated=1):typeof b=="object"&&b!==null&&b.$$typeof===P&&(b._payload.status==="fulfilled"?C(b._payload.value)&&b._payload.value._store&&(b._payload.value._store.validated=1):b._store&&(b._store.validated=1))}function C(b){return typeof b=="object"&&b!==null&&b.$$typeof===D}var m=o,D=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),I=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),L=Symbol.for("react.suspense"),y=Symbol.for("react.suspense_list"),k=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),z=Symbol.for("react.client.reference"),U=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te=Object.prototype.hasOwnProperty,Q=Array.isArray,fe=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(b){return b()}};var he,ee={},R=m.react_stack_bottom_frame.bind(m,l)(),W=fe(r(l)),ye={};Ze.Fragment=S,Ze.jsx=function(b,u,V){var O=1e4>U.recentlyCreatedOwnerStacks++;return x(b,u,V,!1,O?Error("react-stack-top-frame"):R,O?fe(r(b)):W)},Ze.jsxs=function(b,u,V){var O=1e4>U.recentlyCreatedOwnerStacks++;return x(b,u,V,!0,O?Error("react-stack-top-frame"):R,O?fe(r(b)):W)}})()),Ze}var on;function rr(){return on||(on=1,process.env.NODE_ENV==="production"?bt.exports=tr():bt.exports=nr()),bt.exports}var i=rr();function an(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(n=an(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function ir(){for(var e,t,n=0,r="",s=arguments.length;n<s;n++)(e=arguments[n])&&(t=an(e))&&(r&&(r+=" "),r+=t);return r}const cn=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,dn=ir,Ye=(e,t)=>n=>{var r;if(t?.variants==null)return dn(e,n?.class,n?.className);const{variants:s,defaultVariants:l}=t,c=Object.keys(s).map(g=>{const x=n?.[g],d=l?.[g];if(x===null)return null;const C=cn(x)||cn(d);return s[g][C]}),a=n&&Object.entries(n).reduce((g,x)=>{let[d,C]=x;return C===void 0||(g[d]=C),g},{}),f=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((g,x)=>{let{class:d,className:C,...m}=x;return Object.entries(m).every(D=>{let[p,S]=D;return Array.isArray(S)?S.includes({...l,...a}[p]):{...l,...a}[p]===S})?[...g,d,C]:g},[]);return dn(e,c,f,n?.class,n?.className)},sr={list:"List",detail:"Detail",grid:"Grid",kanban:"Kanban",calendar:"Calendar",timeline:"Timeline",map:"Map",gallery:"Gallery",gantt:"Gantt"},lr={list:F.List,detail:F.FileText,grid:F.Grid,kanban:F.LayoutGrid,calendar:F.Calendar,timeline:F.Activity,map:F.Map,gallery:F.Images,gantt:F.GanttChartSquare},or=Ye("flex gap-4",{variants:{position:{top:"flex-col",bottom:"flex-col-reverse",left:"flex-row",right:"flex-row-reverse"}},defaultVariants:{position:"top"}}),ar=Ye("w-full",{variants:{orientation:{horizontal:"w-full",vertical:"w-48"}},defaultVariants:{orientation:"horizontal"}}),cr=Ye("flex gap-2",{variants:{orientation:{horizontal:"flex-row flex-wrap",vertical:"flex-col"}},defaultVariants:{orientation:"horizontal"}}),dr=Ye("",{variants:{orientation:{horizontal:"",vertical:"flex h-auto flex-col items-stretch"}},defaultVariants:{orientation:"horizontal"}});function ur(e){return e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")}const fr={Home:"House"};function un(e){if(!e)return null;const t=ur(e),n=fr[t]||t;return F.icons[n]||null}function It(e){return e.label?e.label:sr[e.type]||e.type}function fn(e){return e.icon?un(e.icon):lr[e.type]||null}function hr(e){return e.activeView?e.activeView:e.defaultView?e.defaultView:e.views?.[0]?.type}const hn={share:F.Share2,settings:F.Settings,duplicate:F.Copy,delete:F.Trash2},pr={share:"Share",settings:"Settings",duplicate:"Duplicate",delete:"Delete"},Ot=({schema:e,className:t,onViewChange:n,onCreateView:r,onViewAction:s,createViewLabel:l="Create view",...c})=>{const a=X.useMemo(()=>e.storageKey?e.storageKey:`view-switcher${e.id?`-${e.id}`:""}`,[e.id,e.storageKey]),[f,g]=X.useState(()=>hr(e));X.useEffect(()=>{if(e.activeView){g(e.activeView);return}if(e.persistPreference)try{const y=localStorage.getItem(a);if(y){const k=e.views.find(P=>P.type===y)?.type;k&&g(k)}}catch{}},[e.activeView,e.persistPreference,e.views,a]),X.useEffect(()=>{if(!(!e.persistPreference||!f||e.activeView))try{localStorage.setItem(a,f)}catch{}},[f,e.activeView,e.persistPreference,a]);const x=X.useCallback(y=>{n?.(y),e.onViewChange&&typeof window<"u"&&window.dispatchEvent(new CustomEvent(e.onViewChange,{detail:{view:y}}))},[n,e.onViewChange]),d=X.useCallback(y=>{g(y),x(y)},[x]),C=f||e.views?.[0]?.type,m=C||"",D=e.views.find(y=>y.type===C)||e.views?.[0],p=e.variant||"tabs",S=e.position||"top",E=S==="left"||S==="right",w=E?"vertical":"horizontal",N=e.viewActions&&e.viewActions.length>0?i.jsx("div",{className:"flex items-center gap-1",children:e.viewActions.map((y,k)=>{const P=y.icon&&un(y.icon)||hn[y.type];return i.jsx(h.Button,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>s?.(y.type,C),title:pr[y.type]||y.type,children:P?i.jsx(P,{className:"h-3.5 w-3.5"}):null},`action-${y.type}-${k}`)})}):null,I=e.allowCreateView?i.jsx(h.Button,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>r?.(),title:l,children:i.jsx(F.Plus,{className:"h-3.5 w-3.5"})}):null,M=i.jsxs("div",{className:h.cn(ar({orientation:w}),"flex items-center gap-1"),children:[p==="dropdown"&&i.jsxs(h.Select,{value:m,onValueChange:y=>d(y),children:[i.jsx(h.SelectTrigger,{className:h.cn("w-full",E?"h-10":"h-9"),children:i.jsx(h.SelectValue,{placeholder:"Select view"})}),i.jsx(h.SelectContent,{children:e.views.map((y,k)=>i.jsx(h.SelectItem,{value:y.type,children:It(y)},`${y.type}-${k}`))})]}),p==="buttons"&&i.jsx("div",{className:h.cn(cr({orientation:w})),children:e.views.map((y,k)=>{const P=y.type===C,_=fn(y);return i.jsxs(h.Button,{type:"button",size:"sm",variant:P?"secondary":"ghost",className:h.cn("justify-start gap-2",E?"w-full":""),onClick:()=>d(y.type),children:[_?i.jsx(_,{className:"h-4 w-4"}):null,i.jsx("span",{children:It(y)})]},`${y.type}-${k}`)})}),p==="tabs"&&i.jsx(h.Tabs,{value:m,onValueChange:y=>d(y),children:i.jsx(h.TabsList,{className:h.cn(dr({orientation:w})),children:e.views.map((y,k)=>{const P=fn(y);return i.jsxs(h.TabsTrigger,{value:y.type,className:h.cn("gap-2",E?"justify-start":""),children:[P?i.jsx(P,{className:"h-4 w-4"}):null,i.jsx("span",{children:It(y)})]},`${y.type}-${k}`)})})}),N,I]}),L=D?.schema?Array.isArray(D.schema)?i.jsx("div",{className:"space-y-4",children:D.schema.map((y,k)=>i.jsx(rn.SchemaRenderer,{schema:y,...c},`${D.type}-${k}`))}):i.jsx(rn.SchemaRenderer,{schema:D.schema,...c}):null;return i.jsxs("div",{className:h.cn(or({position:S}),t),children:[i.jsx("div",{className:h.cn("shrink-0",E?"flex flex-col":"flex"),children:M}),i.jsx("div",{className:"flex-1 min-w-0",children:L})]})};let vt=null;try{vt=require("@object-ui/react").SchemaRenderer||null}catch{}const pn=({schema:e,dataSource:t,className:n,views:r,activeViewId:s,onViewChange:l,onRowClick:c,onEdit:a,renderListView:f,toolbarAddon:g,onCreateView:x,onViewAction:d})=>{const[C,m]=o.useState(null),[D,p]=o.useState(!1),[S,E]=o.useState("create"),[w,N]=o.useState(null),[I,M]=o.useState(0),[L,y]=o.useState([]),[k,P]=o.useState(!1),[_,z]=o.useState({}),[U,te]=o.useState([]),Q=e.listViews,fe=Q!=null&&Object.keys(Q).length>0,[he,ee]=o.useState(()=>e.defaultListView&&Q?.[e.defaultListView]?e.defaultListView:Q&&Object.keys(Q)[0]||""),R=o.useMemo(()=>!fe||!he?null:Q[he]||null,[fe,he,Q]),W=o.useMemo(()=>r&&r.length>0?r:null,[r]),ye=W!=null&&W.length>0,b=s||W?.[0]?.id,u=W?.find(j=>j.id===b)||W?.[0],V=o.useMemo(()=>R?.type?R.type:u?.type?u.type:e.defaultViewType||"grid",[R,u,e.defaultViewType]),O=e.navigation;o.useEffect(()=>{let j=!0;const T=async()=>{try{const A=await t.getObjectSchema(e.objectName);j&&m(A)}catch(A){console.error("Failed to fetch object schema:",A)}};return e.objectName&&t&&T(),()=>{j=!1}},[e.objectName,t]),o.useEffect(()=>{let j=!0;return(async()=>{if(!(V==="grid"&&!f)&&!(!t||!e.objectName)){P(!0);try{const A=R?.filter||u?.filter||e.table?.defaultFilters||[],ve=Object.entries(_).filter(([,$])=>$!==void 0&&$!==""&&$!==null).map(([$,me])=>[$,"=",me]);let ie=[];A.length>0&&ve.length>0?ie=["and",...A,...ve]:ve.length===1?ie=ve[0]:ve.length>1?ie=["and",...ve]:ie=A;const xe=U.length>0?U.map($=>({field:$.field,order:$.direction})):R?.sort||u?.sort||e.table?.defaultSort||void 0,se=Ve.buildExpandFields(C?.fields),ge=await t.find(e.objectName,{$filter:ie.length>0?ie:void 0,$orderby:xe,$top:100,...se.length>0?{$expand:se}:{}});let J=[];Array.isArray(ge)?J=ge:ge&&typeof ge=="object"&&(Array.isArray(ge.data)?J=ge.data:Array.isArray(ge.records)&&(J=ge.records)),j&&y(J)}catch(A){console.error("ObjectView data fetch error:",A)}finally{j&&P(!1)}}})(),()=>{j=!1}},[e.objectName,t,V,_,U,I,R,u,f,C]);const le=e.layout||"drawer",q=e.operations||e.table?.operations||{create:!0,read:!0,update:!0,delete:!0},G=o.useCallback(()=>{le==="page"&&e.onNavigate?e.onNavigate("new","edit"):(E("create"),N(null),p(!0))},[le,e]),oe=o.useCallback(j=>{if(a){a(j);return}if(le==="page"&&e.onNavigate){const T=j.id||j._id;e.onNavigate(T,"edit")}else E("edit"),N(j),p(!0)},[le,e,a]),de=o.useCallback(j=>{if(le==="page"&&e.onNavigate){const T=j.id||j._id;e.onNavigate(T,"view")}else E("view"),N(j),p(!0)},[le,e]),v=o.useCallback(j=>{if(c){c(j);return}if(O){if(O.mode==="none"||O.preventNavigation)return;if(O.mode==="new_window"||O.openNewTab){const T=j.id||j._id,A=`/${e.objectName}/${encodeURIComponent(String(T))}`;window.open(A,"_blank");return}if(O.mode==="drawer"){E("view"),N(j),p(!0);return}if(O.mode==="modal"){E("view"),N(j),p(!0);return}if(O.mode==="page"){const T=j.id||j._id;e.onNavigate&&e.onNavigate(T,"view");return}if(O.mode==="split"||O.mode==="popover"){E("view"),N(j),p(!0);return}}q.read!==!1&&de(j)},[c,O,q.read,de,e]),Z=o.useCallback(j=>{M(T=>T+1)},[]),K=o.useCallback(j=>{M(T=>T+1)},[]),ne=o.useCallback(()=>{p(!1),N(null),M(j=>j+1)},[]),Y=o.useCallback(()=>{p(!1),N(null)},[]);o.useCallback(()=>{M(j=>j+1)},[]);const Ce=o.useMemo(()=>!ye||!W||W.length<=1?null:{type:"view-switcher",variant:"tabs",position:"top",persistPreference:!0,storageKey:`view-pref-${e.objectName}`,defaultView:u?.type||"grid",activeView:u?.type||"grid",views:W.map(j=>{const T={kanban:"kanban",calendar:"calendar",map:"map",gallery:"layout-grid",timeline:"activity",gantt:"gantt-chart",grid:"table",list:"list",detail:"file-text"};return{type:j.type,label:j.label,icon:T[j.type]||"table"}}),allowCreateView:e.allowCreateView,viewActions:e.viewActions},[ye,W,u,e.objectName,e.allowCreateView,e.viewActions]),pe=o.useCallback(j=>{if(!W)return;const T=W.find(A=>A.type===j);T&&l&&l(T.id)},[W,l]),ct=o.useCallback(j=>{ee(j)},[]);o.useMemo(()=>{if(e.showFilters===!1)return null;const j=e.filterableFields,T=C?.fields||{},ve=(j?j.map(ie=>[ie,T[ie]||{label:ie}]):Object.entries(T).filter(([,ie])=>!ie.hidden).slice(0,8)).map(([ie,xe])=>{const se=xe.type||"text";let ge="text",J;return se==="number"||se==="currency"||se==="percent"?ge="number":se==="boolean"||se==="toggle"?ge="boolean":se==="date"||se==="datetime"?ge="date":se==="select"||se==="status"||xe.options?(ge="select",J=(xe.options||[]).map($=>typeof $=="string"?{label:$,value:$}:{label:$.label,value:$.value})):(se==="lookup"||se==="master_detail"||se==="user"||se==="owner")&&xe.options&&xe.options.length>0&&(ge="multi-select",J=(xe.options||[]).map($=>typeof $=="string"?{label:$,value:$}:{label:$.label,value:$.value})),{field:ie,label:xe.label||ie,type:ge,placeholder:`Filter ${xe.label||ie}...`,...J?{options:J}:{}}});return ve.length===0?null:{type:"filter-ui",layout:"popover",showClear:!0,showApply:!0,filters:ve,values:_}},[e.showFilters,e.filterableFields,C,_]);const Re=e.showSort;o.useMemo(()=>{if(Re===!1)return null;const j=C?.fields||{},T=Object.entries(j).filter(([,A])=>!A.hidden).slice(0,10).map(([A,ve])=>({field:A,label:ve.label||A}));return T.length===0?null:{type:"sort-ui",variant:"dropdown",multiple:!1,fields:T,sort:U}},[C,U,Re]);const Le=o.useCallback(j=>{const T={objectName:e.objectName,fields:R?.columns||u?.columns||e.table?.fields,className:"h-full w-full",showSearch:u?.showSearch??e.showSearch??!1,showSort:u?.showSort??e.showSort??!1,showFilters:u?.showFilters??e.showFilters??!1,striped:u?.striped??!1,bordered:u?.bordered??!1,color:u?.color},A=R?.options||u||{};if(process.env.NODE_ENV==="development"){const ve=["startDateField","endDateField","dateField","groupBy","groupField","locationField","imageField","dependenciesField","progressField","titleField","subtitleField","latitudeField","longitudeField"],ie=A[j]||{},xe=ve.filter(se=>se in A&&!(se in ie));xe.length>0&&console.warn(`[Spec Compliance] View options use flat properties ${JSON.stringify(xe)}. Move them under options.${j} per @objectstack/spec protocol.`)}switch(j){case"kanban":return{type:"object-kanban",...T,groupBy:A.kanban?.groupField||"status",groupField:A.kanban?.groupField||"status",titleField:A.kanban?.titleField||"name",cardFields:T.fields||[],...A.kanban||{}};case"calendar":return{type:"object-calendar",...T,startDateField:A.calendar?.startDateField||"start_date",endDateField:A.calendar?.endDateField||"end_date",titleField:A.calendar?.titleField||"name",...A.calendar||{}};case"gallery":return{type:"object-gallery",...T,imageField:A.gallery?.imageField,titleField:A.gallery?.titleField||"name",subtitleField:A.gallery?.subtitleField,...A.gallery||{}};case"timeline":return{type:"object-timeline",...T,dateField:A.timeline?.dateField||"created_at",titleField:A.timeline?.titleField||"name",...A.timeline||{}};case"gantt":return{type:"object-gantt",...T,startDateField:A.gantt?.startDateField||"start_date",endDateField:A.gantt?.endDateField||"end_date",progressField:A.gantt?.progressField||"progress",dependenciesField:A.gantt?.dependenciesField||"dependencies",...A.gantt||{}};case"map":return{type:"object-map",...T,locationField:A.map?.locationField||"location",...A.map||{}};default:return null}},[e.objectName,e.table?.fields,R,u]),je=o.useMemo(()=>({type:"object-grid",objectName:e.objectName,title:e.table?.title,description:e.table?.description,fields:R?.columns||u?.columns||e.table?.fields,columns:R?.columns||u?.columns||e.table?.columns,operations:{...q,create:!1},defaultFilters:R?.filter||u?.filter||e.table?.defaultFilters,defaultSort:R?.sort||u?.sort||e.table?.defaultSort,pageSize:e.table?.pageSize,selectable:e.table?.selectable,striped:u?.striped??e.table?.striped,bordered:u?.bordered??e.table?.bordered,className:e.table?.className}),[e,q,R,u]),re=()=>{const j=w?w.id||w._id:void 0;return{type:"object-form",objectName:e.objectName,mode:S,recordId:j,title:e.form?.title,description:e.form?.description,fields:e.form?.fields,customFields:e.form?.customFields,groups:e.form?.groups,layout:e.form?.layout,columns:e.form?.columns,showSubmit:e.form?.showSubmit,submitText:e.form?.submitText,showCancel:e.form?.showCancel,cancelText:e.form?.cancelText,showReset:e.form?.showReset,initialValues:e.form?.initialValues,readOnly:e.form?.readOnly||S==="view",className:e.form?.className,onSuccess:ne,onCancel:Y}},H=()=>{if(e.form?.title)return e.form.title;const j=C?.label||e.objectName;switch(S){case"create":return`Create ${j}`;case"edit":return`Edit ${j}`;case"view":return`View ${j}`;default:return j}},Fe=o.useMemo(()=>{const j=O?.width;return j?typeof j=="number"?`max-w-[${j}px]`:`max-w-[${j}]`:""},[O]),Xe=()=>i.jsx(h.Drawer,{open:D,onOpenChange:p,direction:"right",children:i.jsxs(h.DrawerContent,{className:h.cn("w-full sm:max-w-2xl",Fe),children:[i.jsxs(h.DrawerHeader,{children:[i.jsx(h.DrawerTitle,{children:H()}),e.form?.description&&i.jsx(h.DrawerDescription,{children:e.form.description})]}),i.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:i.jsx(At.ObjectForm,{schema:re(),dataSource:t})})]})}),dt=()=>i.jsx(h.Dialog,{open:D,onOpenChange:p,children:i.jsxs(h.DialogContent,{className:h.cn("max-w-2xl max-h-[90vh] overflow-y-auto",Fe),children:[i.jsxs(h.DialogHeader,{children:[i.jsx(h.DialogTitle,{children:H()}),e.form?.description&&i.jsx(h.DialogDescription,{children:e.form.description})]}),i.jsx(At.ObjectForm,{schema:re(),dataSource:t})]})}),tn=o.useMemo(()=>Object.keys(_).some(T=>_[T]!==void 0&&_[T]!==""&&_[T]!==null)?Object.entries(_).filter(([,T])=>T!==void 0&&T!==""&&T!==null).map(([T,A])=>({field:T,operator:"equals",value:A})):R?.filter||u?.filter||e.table?.defaultFilters,[_,R,u,e.table?.defaultFilters]),_e=o.useMemo(()=>U.length>0?U:R?.sort||u?.sort||e.table?.defaultSort,[U,R,u,e.table?.defaultSort]),Ae=()=>{const j=`${e.objectName}-${he||u?.id||"default"}-${V}-${I}`;if(f)return f({schema:{type:"list-view",objectName:e.objectName,viewType:V,fields:R?.columns||u?.columns||e.table?.fields,filters:tn,sort:_e,rowHeight:u?.rowHeight,densityMode:u?.densityMode,groupBy:u?.groupBy,options:R?.options||u,showSearch:u?.showSearch??e.showSearch,showFilters:u?.showFilters??e.showFilters,showSort:u?.showSort??e.showSort,showHideFields:u?.showHideFields??e.showHideFields,showGroup:u?.showGroup??e.showGroup,showColor:u?.showColor??e.showColor,showDensity:u?.showDensity??e.showDensity,allowExport:u?.allowExport??e.allowExport,striped:u?.striped??e.striped,bordered:u?.bordered??e.bordered,color:u?.color??e.color,inlineEdit:u?.inlineEdit??e.inlineEdit,wrapHeaders:u?.wrapHeaders??e.wrapHeaders,clickIntoRecordDetails:u?.clickIntoRecordDetails??e.clickIntoRecordDetails,addRecordViaForm:u?.addRecordViaForm??e.addRecordViaForm,addDeleteRecordsInline:u?.addDeleteRecordsInline??e.addDeleteRecordsInline,collapseAllByDefault:u?.collapseAllByDefault??e.collapseAllByDefault,fieldTextColor:u?.fieldTextColor??e.fieldTextColor,prefixField:u?.prefixField??e.prefixField,showDescription:u?.showDescription??e.showDescription,navigation:u?.navigation??e.navigation,selection:u?.selection??e.selection,pagination:u?.pagination??e.pagination,searchableFields:u?.searchableFields??e.searchableFields,filterableFields:u?.filterableFields??e.filterableFields,resizable:u?.resizable??e.resizable,hiddenFields:u?.hiddenFields??e.hiddenFields,rowActions:u?.rowActions??e.rowActions,bulkActions:u?.bulkActions??e.bulkActions,sharing:u?.sharing??e.sharing,addRecord:u?.addRecord??e.addRecord,conditionalFormatting:u?.conditionalFormatting??e.conditionalFormatting,quickFilters:u?.quickFilters??e.quickFilters,userFilters:u?.userFilters??e.userFilters,showRecordCount:u?.showRecordCount??e.showRecordCount,allowPrinting:u?.allowPrinting??e.allowPrinting,virtualScroll:u?.virtualScroll??e.virtualScroll,emptyState:u?.emptyState??e.emptyState,aria:u?.aria??e.aria,tabs:e.tabs},dataSource:t,onEdit:oe,onRowClick:v,className:"h-full"});if(V!=="grid"){const T=Le(V);if(T&&vt)return i.jsx(vt,{schema:T,dataSource:t,data:L,loading:k},j);if(!vt)return i.jsx("div",{className:"flex items-center justify-center h-40 text-muted-foreground",children:i.jsxs("p",{children:["SchemaRenderer not available. Install @object-ui/react to render ",V," views."]})})}return i.jsx(Zn.ObjectGrid,{schema:je,dataSource:t,onRowClick:v,onEdit:q.update!==!1?oe:void 0,onDelete:q.delete!==!1?Z:void 0,onBulkDelete:q.delete!==!1?K:void 0},j)},Ue=()=>{if(!fe)return null;const j=Object.entries(Q);return j.length<=1?null:i.jsx(h.Tabs,{value:he,onValueChange:ct,className:"w-full",children:i.jsx(h.TabsList,{className:"w-auto",children:j.map(([T,A])=>i.jsx(h.TabsTrigger,{value:T,className:"text-sm",children:A.label||T},T))})})},ut=()=>{const j=e.showCreate!==!1&&q.create!==!1,T=e.showViewSwitcher===!0,A=Ue();return!A&&!T&&!j&&!g?null:i.jsxs("div",{className:"flex flex-col gap-3",children:[A,(T||j||g)&&i.jsxs("div",{className:"flex items-center justify-between gap-4",children:[i.jsx("div",{className:"flex items-center gap-2",children:T&&Ce&&i.jsx(Ot,{schema:Ce,onViewChange:pe,onCreateView:x,onViewAction:d,className:"overflow-x-auto"})}),i.jsxs("div",{className:"flex items-center gap-2",children:[g,j&&i.jsxs(h.Button,{size:"sm",onClick:G,children:[i.jsx(F.Plus,{className:"h-4 w-4"}),"Create"]})]})]})]})},Se=O?.mode==="modal"?"modal":O?.mode==="drawer"?"drawer":O?.mode==="split"?"split":O?.mode==="popover"?"popover":le,ft=j=>i.jsx("div",{className:"space-y-3",children:i.jsx(At.ObjectForm,{schema:re(),dataSource:t})}),kt=o.useCallback(j=>{j||Y()},[Y]);if(Se==="split"){const j=C?.label||e.objectName;return i.jsxs("div",{className:h.cn("flex flex-col h-full min-w-0 overflow-hidden",n),children:[(e.title||e.description)&&i.jsxs("div",{className:"mb-4 shrink-0",children:[e.title&&i.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:e.title}),e.description&&i.jsx("p",{className:"text-muted-foreground mt-1",children:e.description})]}),i.jsx("div",{className:"mb-4 shrink-0",children:ut()}),i.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden",children:D&&w?i.jsx(h.NavigationOverlay,{isOpen:D,selectedRecord:w,mode:"split",close:Y,setIsOpen:kt,width:O?.width,isOverlay:!0,title:`${j} Detail`,mainContent:i.jsx("div",{className:"h-full overflow-auto",children:Ae()}),children:ft}):Ae()})]})}return i.jsxs("div",{className:h.cn("flex flex-col h-full min-w-0 overflow-hidden",n),children:[(e.title||e.description)&&i.jsxs("div",{className:"mb-4 shrink-0",children:[e.title&&i.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:e.title}),e.description&&i.jsx("p",{className:"text-muted-foreground mt-1",children:e.description})]}),i.jsx("div",{className:"mb-4 shrink-0",children:ut()}),i.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden",children:Ae()}),Se==="drawer"&&Xe(),Se==="modal"&&dt(),Se==="popover"&&D&&w&&i.jsx(h.NavigationOverlay,{isOpen:D,selectedRecord:w,mode:"popover",close:Y,setIsOpen:kt,width:O?.width,isOverlay:!0,title:H(),children:ft})]})},Ft=Ye("flex",{variants:{layout:{inline:"flex-col space-y-4",popover:"items-center",drawer:"items-center"}},defaultVariants:{layout:"inline"}}),gr=e=>e==null||e===""?!0:Array.isArray(e)?e.length===0:typeof e=="object"?Object.values(e).every(t=>t==null||t===""):!1,br=e=>Array.isArray(e)?{start:e[0]||"",end:e[1]||""}:e&&typeof e=="object"?{start:e.start||"",end:e.end||""}:{start:"",end:""},gn=({schema:e,className:t,onChange:n})=>{const[r,s]=X.useState(e.values||{}),[l,c]=X.useState(!1);X.useEffect(()=>{e.values&&s(e.values)},[e.values]);const a=X.useCallback(p=>{n?.(p),e.onChange&&typeof window<"u"&&window.dispatchEvent(new CustomEvent(e.onChange,{detail:{values:p}}))},[n,e.onChange]),f=X.useCallback((p,S)=>{const E={...r,[p]:S};s(E),e.showApply||a(E)},[a,e.showApply,r]),g=X.useCallback(()=>{const p={};if(s(p),e.showApply){a(p);return}a(p)},[a,e.showApply]),x=X.useCallback(()=>{a(r),c(!1)},[a,r]),d=X.useMemo(()=>Object.values(r).filter(p=>!gr(p)).length,[r]),C=p=>{const S=p.label||p.field,E=p.placeholder||`Filter by ${S}`;switch(p.type){case"number":return i.jsx(h.Input,{type:"number",value:r[p.field]??"",placeholder:E,onChange:w=>{const N=w.target.value,I=N===""?"":Number(N);f(p.field,I)}});case"select":return i.jsxs(h.Select,{value:r[p.field]!==void 0?String(r[p.field]):"",onValueChange:w=>{const N=p.options?.find(I=>String(I.value)===w);f(p.field,N?N.value:w)},children:[i.jsx(h.SelectTrigger,{children:i.jsx(h.SelectValue,{placeholder:E})}),i.jsx(h.SelectContent,{children:p.options?.map(w=>i.jsx(h.SelectItem,{value:String(w.value),children:w.label},String(w.value)))})]});case"multi-select":{const w=r[p.field],N=Array.isArray(w)?w:w?[w]:[];return i.jsx("div",{className:"max-h-40 overflow-y-auto space-y-0.5 border rounded-md p-2",children:p.options?.map(I=>{const M=N.map(String).includes(String(I.value));return i.jsxs("label",{className:h.cn("flex items-center gap-2 text-sm py-1 px-1.5 rounded cursor-pointer",M?"bg-primary/5 text-primary":"hover:bg-muted"),children:[i.jsx(h.Checkbox,{checked:M,onCheckedChange:L=>{const y=L?[...N,I.value]:N.filter(k=>String(k)!==String(I.value));f(p.field,y)}}),i.jsx("span",{className:"truncate",children:I.label})]},String(I.value))})})}case"date":return i.jsx(h.Input,{type:"date",value:r[p.field]??"",onChange:w=>f(p.field,w.target.value)});case"date-range":{const w=br(r[p.field]);return i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(h.Input,{type:"date",value:w.start??"",onChange:N=>{f(p.field,{...w,start:N.target.value})}}),i.jsx(h.Input,{type:"date",value:w.end??"",onChange:N=>{f(p.field,{...w,end:N.target.value})}})]})}case"boolean":return i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(h.Checkbox,{checked:!!r[p.field],onCheckedChange:w=>f(p.field,!!w)}),i.jsx("span",{className:"text-sm text-muted-foreground",children:"Enabled"})]});default:return i.jsx(h.Input,{value:r[p.field]??"",placeholder:E,onChange:w=>f(p.field,w.target.value)})}},m=i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"grid gap-4 sm:grid-cols-2",children:e.filters.map(p=>i.jsxs("div",{className:"space-y-2",children:[i.jsx(h.Label,{className:"text-xs text-muted-foreground",children:p.label||p.field}),C(p)]},p.field))}),(e.showApply||e.showClear)&&i.jsxs("div",{className:"flex items-center justify-end gap-2 border-t pt-3",children:[e.showClear&&i.jsx(h.Button,{type:"button",variant:"ghost",size:"sm",onClick:g,children:"Clear"}),e.showApply&&i.jsx(h.Button,{type:"button",size:"sm",onClick:x,children:"Apply"})]})]}),D=e.layout||"inline";return D==="popover"?i.jsx("div",{className:h.cn(Ft({layout:D}),t),children:i.jsxs(h.Popover,{open:l,onOpenChange:c,children:[i.jsx(h.PopoverTrigger,{asChild:!0,children:i.jsxs(h.Button,{type:"button",variant:d>0?"secondary":"outline",size:"sm",className:"gap-2",children:[i.jsx(F.SlidersHorizontal,{className:"h-4 w-4"}),"Filters",d>0&&i.jsx("span",{className:"inline-flex h-5 min-w-[20px] items-center justify-center rounded-full bg-primary/10 px-1 text-xs font-medium text-primary",children:d})]})}),i.jsx(h.PopoverContent,{align:"start",className:"w-[520px] p-4",children:m})]})}):D==="drawer"?i.jsxs("div",{className:h.cn(Ft({layout:D}),t),children:[i.jsxs(h.Button,{type:"button",variant:d>0?"secondary":"outline",size:"sm",className:"gap-2",onClick:()=>c(!0),children:[i.jsx(F.SlidersHorizontal,{className:"h-4 w-4"}),"Filters",d>0&&i.jsx("span",{className:"inline-flex h-5 min-w-[20px] items-center justify-center rounded-full bg-primary/10 px-1 text-xs font-medium text-primary",children:d})]}),i.jsx(h.Drawer,{open:l,onOpenChange:c,children:i.jsxs(h.DrawerContent,{children:[i.jsxs(h.DrawerHeader,{children:[i.jsx(h.DrawerTitle,{children:"Filters"}),i.jsx(h.DrawerDescription,{children:"Refine the data with advanced filters."})]}),i.jsx("div",{className:"px-4 pb-6",children:m})]})})]}):i.jsxs("div",{className:h.cn(Ft({layout:D}),t),children:[m,!e.showApply&&e.showClear&&i.jsxs(h.Button,{type:"button",variant:"ghost",size:"sm",className:"gap-2",onClick:g,children:[i.jsx(F.X,{className:"h-3.5 w-3.5"}),"Clear filters"]})]})},Mt=Ye("",{variants:{variant:{buttons:"flex flex-wrap gap-2",dropdown:"flex flex-wrap items-center gap-3",builder:"space-y-3"}},defaultVariants:{variant:"dropdown"}}),Vt=e=>e?e.map(t=>({field:t.field,direction:t.direction})):[],bn=e=>e.map(t=>({id:`${t.field}-${t.direction}`,field:t.field,order:t.direction})),vr=e=>e.filter(t=>t.field).map(t=>({field:t.field,direction:t.order})),vn=({schema:e,className:t,onChange:n})=>{const[r,s]=X.useState(()=>Vt(e.sort)),[l,c]=X.useState(()=>bn(Vt(e.sort)));X.useEffect(()=>{const d=Vt(e.sort);s(d),c(bn(d))},[e.sort]);const a=X.useCallback(d=>{s(d),n?.(d),e.onChange&&typeof window<"u"&&window.dispatchEvent(new CustomEvent(e.onChange,{detail:{sort:d}}))},[n,e.onChange]),f=X.useCallback(d=>{const C=r.find(p=>p.field===d),m=!!e.multiple;if(!C){const p=m?[...r,{field:d,direction:"asc"}]:[{field:d,direction:"asc"}];a(p);return}if(C.direction==="asc"){const p=r.map(S=>S.field===d?{...S,direction:"desc"}:S);a(p);return}const D=r.filter(p=>p.field!==d);a(D)},[a,e.multiple,r]);if((e.variant||"dropdown")==="buttons")return i.jsx("div",{className:h.cn(Mt({variant:"buttons"}),t),children:e.fields.map(d=>{const C=r.find(D=>D.field===d.field),m=C?.direction==="asc"?F.ArrowUp:F.ArrowDown;return i.jsxs(h.Button,{type:"button",variant:C?"secondary":"outline",size:"sm",onClick:()=>f(d.field),className:"gap-2",children:[i.jsx("span",{children:d.label||d.field}),C&&i.jsx(m,{className:"h-3.5 w-3.5"})]},d.field)})});if(e.multiple)return i.jsx("div",{className:h.cn(Mt({variant:"builder"}),t),children:i.jsx(h.SortBuilder,{fields:e.fields.map(d=>({value:d.field,label:d.label||d.field})),value:l,onChange:d=>{c(d),a(vr(d))}})});const x=r[0];return i.jsxs("div",{className:h.cn(Mt({variant:"dropdown"}),t),children:[i.jsxs(h.Select,{value:x?.field||"",onValueChange:d=>{if(!d){a([]);return}a([{field:d,direction:x?.direction||"asc"}])},children:[i.jsx(h.SelectTrigger,{className:"w-56",children:i.jsx(h.SelectValue,{placeholder:"Select field"})}),i.jsx(h.SelectContent,{children:e.fields.map(d=>i.jsx(h.SelectItem,{value:d.field,children:d.label||d.field},d.field))})]}),i.jsxs(h.Select,{value:x?.direction||"asc",onValueChange:d=>{x?.field&&a([{field:x.field,direction:d}])},children:[i.jsx(h.SelectTrigger,{className:"w-36",children:i.jsx(h.SelectValue,{})}),i.jsxs(h.SelectContent,{children:[i.jsx(h.SelectItem,{value:"asc",children:"Ascending"}),i.jsx(h.SelectItem,{value:"desc",children:"Descending"})]})]})]})};function xr(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function"){const e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}return Math.random().toString(36).slice(2)+Math.random().toString(36).slice(2)}function mr(e,t,n,r){return`${e}/share/${t}/${n}?mode=readonly&token=${r}`}const xn=({objectName:e,viewId:t="default",baseUrl:n,onShare:r,className:s})=>{const[l,c]=X.useState(null),[a,f]=X.useState(!1),[g,x]=X.useState(!1),[d,C]=X.useState(""),[m,D]=X.useState(""),p=n??(typeof window<"u"?window.location.origin:""),S=X.useCallback(()=>{const w=xr(),N=mr(p,e,t,w);c(N),f(!1);const I=m?new Date(Date.now()+parseInt(m,10)*864e5).toISOString():void 0;r?.(N,{password:d||void 0,expiresAt:I})},[p,e,t,r,d,m]),E=X.useCallback(async()=>{if(l)try{await navigator.clipboard.writeText(l),f(!0),setTimeout(()=>f(!1),2e3)}catch{const w=document.createElement("textarea");w.value=l,document.body.appendChild(w),w.select(),document.execCommand("copy"),document.body.removeChild(w),f(!0),setTimeout(()=>f(!1),2e3)}},[l]);return i.jsxs(h.Popover,{open:g,onOpenChange:x,children:[i.jsx(h.PopoverTrigger,{asChild:!0,children:i.jsxs(h.Button,{variant:"outline",size:"sm",className:h.cn("gap-2",s),children:[i.jsx(F.Share2,{className:"h-4 w-4"}),"Share"]})}),i.jsxs(h.PopoverContent,{className:"w-96 space-y-4",align:"end",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("h4",{className:"text-sm font-medium",children:"Share View"}),i.jsx(h.Badge,{variant:"secondary",className:"text-xs",children:"Read-only"})]}),i.jsx("p",{className:"text-xs text-muted-foreground",children:"Generate a public link to share this view. Recipients can view data without logging in."})]}),l?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(h.Input,{value:l,readOnly:!0,className:"h-8 text-xs",onClick:w=>w.target.select()}),i.jsx(h.Button,{variant:"outline",size:"sm",onClick:E,className:"shrink-0 gap-1",children:a?i.jsx(F.Check,{className:"h-4 w-4 text-green-500"}):i.jsx(F.Copy,{className:"h-4 w-4"})})]}),(d||m)&&i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[d&&i.jsxs(h.Badge,{variant:"outline",className:"text-xs gap-1",children:[i.jsx(F.Lock,{className:"h-3 w-3"}),"Password protected"]}),m&&i.jsxs(h.Badge,{variant:"outline",className:"text-xs gap-1",children:[i.jsx(F.Calendar,{className:"h-3 w-3"}),"Expires in ",m," day",m!=="1"?"s":""]})]})]}):i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("label",{className:"flex items-center gap-1.5 text-xs font-medium text-foreground",children:[i.jsx(F.Lock,{className:"h-3.5 w-3.5"}),"Password protection (optional)"]}),i.jsx(h.Input,{type:"password",value:d,onChange:w=>C(w.target.value),placeholder:"Enter password...",className:"h-8 text-xs"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("label",{className:"flex items-center gap-1.5 text-xs font-medium text-foreground",children:[i.jsx(F.Calendar,{className:"h-3.5 w-3.5"}),"Expires after (optional)"]}),i.jsxs("select",{value:m,onChange:w=>D(w.target.value),className:"w-full h-8 text-xs rounded-md border border-input bg-background px-3",children:[i.jsx("option",{value:"",children:"Never"}),i.jsx("option",{value:"1",children:"1 day"}),i.jsx("option",{value:"7",children:"7 days"}),i.jsx("option",{value:"30",children:"30 days"}),i.jsx("option",{value:"90",children:"90 days"})]})]}),i.jsxs(h.Button,{onClick:S,className:"w-full gap-2",size:"sm",children:[i.jsx(F.Share2,{className:"h-4 w-4"}),"Generate Link"]})]})]})]})};function wr(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return o.useMemo(()=>r=>{t.forEach(s=>s(r))},t)}const xt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function qe(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Pt(e){return"nodeType"in e}function we(e){var t,n;return e?qe(e)?e:Pt(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Lt(e){const{Document:t}=we(e);return e instanceof t}function et(e){return qe(e)?!1:e instanceof we(e).HTMLElement}function mn(e){return e instanceof we(e).SVGElement}function We(e){return e?qe(e)?e.document:Pt(e)?Lt(e)?e:et(e)||mn(e)?e.ownerDocument:document:document:document}const ke=xt?o.useLayoutEffect:o.useEffect;function _t(e){const t=o.useRef(e);return ke(()=>{t.current=e}),o.useCallback(function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];return t.current==null?void 0:t.current(...r)},[])}function yr(){const e=o.useRef(null),t=o.useCallback((r,s)=>{e.current=setInterval(r,s)},[]),n=o.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function tt(e,t){t===void 0&&(t=[e]);const n=o.useRef(e);return ke(()=>{n.current!==e&&(n.current=e)},t),n}function nt(e,t){const n=o.useRef();return o.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function mt(e){const t=_t(e),n=o.useRef(null),r=o.useCallback(s=>{s!==n.current&&t?.(s,n.current),n.current=s},[]);return[n,r]}function $t(e){const t=o.useRef();return o.useEffect(()=>{t.current=e},[e]),t.current}let Bt={};function rt(e,t){return o.useMemo(()=>{if(t)return t;const n=Bt[e]==null?0:Bt[e]+1;return Bt[e]=n,e+"-"+n},[e,t])}function wn(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return r.reduce((l,c)=>{const a=Object.entries(c);for(const[f,g]of a){const x=l[f];x!=null&&(l[f]=x+e*g)}return l},{...t})}}const Ge=wn(1),wt=wn(-1);function Cr(e){return"clientX"in e&&"clientY"in e}function zt(e){if(!e)return!1;const{KeyboardEvent:t}=we(e.target);return t&&e instanceof t}function jr(e){if(!e)return!1;const{TouchEvent:t}=we(e.target);return t&&e instanceof t}function Rt(e){if(jr(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Cr(e)?{x:e.clientX,y:e.clientY}:null}const it=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[it.Translate.toString(e),it.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),yn="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Sr(e){return e.matches(yn)?e:e.querySelector(yn)}const Nr={display:"none"};function Dr(e){let{id:t,value:n}=e;return o.createElement("div",{id:t,style:Nr},n)}function Er(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const s={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return o.createElement("div",{id:t,style:s,role:"status","aria-live":r,"aria-atomic":!0},n)}function Tr(){const[e,t]=o.useState("");return{announce:o.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const Cn=o.createContext(null);function kr(e){const t=o.useContext(Cn);o.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Ar(){const[e]=o.useState(()=>new Set),t=o.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[o.useCallback(r=>{let{type:s,event:l}=r;e.forEach(c=>{var a;return(a=c[s])==null?void 0:a.call(c,l)})},[e]),t]}const Ir={draggable:`
7
7
  To pick up a draggable item, press the space bar.
8
8
  While dragging, use the arrow keys to move the item.
9
9
  Press space again to drop the item in its new position, or press escape to cancel.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@object-ui/plugin-view",
3
- "version": "3.1.2",
3
+ "version": "3.1.3",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Object View plugin for Object UI",
@@ -19,13 +19,13 @@
19
19
  "@dnd-kit/sortable": "^10.0.0",
20
20
  "@dnd-kit/utilities": "^3.2.2",
21
21
  "class-variance-authority": "^0.7.1",
22
- "lucide-react": "^0.576.0",
23
- "@object-ui/components": "3.1.2",
24
- "@object-ui/core": "3.1.2",
25
- "@object-ui/plugin-grid": "3.1.2",
26
- "@object-ui/react": "3.1.2",
27
- "@object-ui/plugin-form": "3.1.2",
28
- "@object-ui/types": "3.1.2"
22
+ "lucide-react": "^0.577.0",
23
+ "@object-ui/components": "3.1.3",
24
+ "@object-ui/core": "3.1.3",
25
+ "@object-ui/plugin-form": "3.1.3",
26
+ "@object-ui/plugin-grid": "3.1.3",
27
+ "@object-ui/react": "3.1.3",
28
+ "@object-ui/types": "3.1.3"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "react": "^18.0.0 || ^19.0.0",
@@ -384,7 +384,7 @@ export const ObjectView: React.FC<ObjectViewProps> = ({
384
384
  return;
385
385
  }
386
386
  if (layout === 'page' && schema.onNavigate) {
387
- const recordId = record._id || record.id;
387
+ const recordId = record.id || record._id;
388
388
  schema.onNavigate(recordId as string | number, 'edit');
389
389
  } else {
390
390
  setFormMode('edit');
@@ -396,7 +396,7 @@ export const ObjectView: React.FC<ObjectViewProps> = ({
396
396
  // Handle view action (read a record)
397
397
  const handleView = useCallback((record: Record<string, unknown>) => {
398
398
  if (layout === 'page' && schema.onNavigate) {
399
- const recordId = record._id || record.id;
399
+ const recordId = record.id || record._id;
400
400
  schema.onNavigate(recordId as string | number, 'view');
401
401
  } else {
402
402
  setFormMode('view');
@@ -418,7 +418,7 @@ export const ObjectView: React.FC<ObjectViewProps> = ({
418
418
  return; // Do nothing
419
419
  }
420
420
  if (navigationConfig.mode === 'new_window' || navigationConfig.openNewTab) {
421
- const recordId = record._id || record.id;
421
+ const recordId = record.id || record._id;
422
422
  const url = `/${schema.objectName}/${encodeURIComponent(String(recordId))}`;
423
423
  window.open(url, '_blank');
424
424
  return;
@@ -436,7 +436,7 @@ export const ObjectView: React.FC<ObjectViewProps> = ({
436
436
  return;
437
437
  }
438
438
  if (navigationConfig.mode === 'page') {
439
- const recordId = record._id || record.id;
439
+ const recordId = record.id || record._id;
440
440
  if (schema.onNavigate) {
441
441
  schema.onNavigate(recordId as string | number, 'view');
442
442
  }
@@ -727,7 +727,7 @@ export const ObjectView: React.FC<ObjectViewProps> = ({
727
727
  // Build form schema
728
728
  const buildFormSchema = (): ObjectFormSchema => {
729
729
  const recordId = selectedRecord
730
- ? ((selectedRecord._id || selectedRecord.id) as string | number | undefined)
730
+ ? ((selectedRecord.id || selectedRecord._id) as string | number | undefined)
731
731
  : undefined;
732
732
 
733
733
  return {
@@ -25,7 +25,7 @@ vi.mock('@object-ui/react', () => ({
25
25
  vi.mock('@object-ui/plugin-grid', () => ({
26
26
  ObjectGrid: ({ schema, onRowClick }: any) => (
27
27
  <div data-testid="object-grid" data-object={schema?.objectName}>
28
- <button data-testid="grid-row" onClick={() => onRowClick?.({ _id: '1', name: 'Test' })}>
28
+ <button data-testid="grid-row" onClick={() => onRowClick?.({ id: '1', name: 'Test' })}>
29
29
  Row 1
30
30
  </button>
31
31
  </div>
@@ -32,7 +32,7 @@ vi.mock('@object-ui/react', () => ({
32
32
  vi.mock('@object-ui/plugin-grid', () => ({
33
33
  ObjectGrid: ({ schema, onRowClick }: any) => (
34
34
  <div data-testid="object-grid" data-object={schema?.objectName}>
35
- <button data-testid="grid-row" onClick={() => onRowClick?.({ _id: '1', name: 'Test' })}>
35
+ <button data-testid="grid-row" onClick={() => onRowClick?.({ id: '1', name: 'Test' })}>
36
36
  Row 1
37
37
  </button>
38
38
  </div>