@object-ui/plugin-view 0.5.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +184 -6
- package/CHANGELOG.md +16 -0
- package/README.md +58 -0
- package/dist/index.js +1168 -349
- package/dist/index.umd.cjs +2 -2
- package/dist/plugin-view/src/FilterUI.d.ts +16 -0
- package/dist/plugin-view/src/ObjectView.d.ts +85 -5
- package/dist/plugin-view/src/SortUI.d.ts +16 -0
- package/dist/plugin-view/src/ViewSwitcher.d.ts +16 -0
- package/dist/plugin-view/src/__tests__/FilterUI.test.d.ts +8 -0
- package/dist/plugin-view/src/__tests__/ObjectView.test.d.ts +8 -0
- package/dist/plugin-view/src/__tests__/SortUI.test.d.ts +8 -0
- package/dist/plugin-view/src/__tests__/registration.test.d.ts +8 -0
- package/dist/plugin-view/src/index.d.ts +7 -1
- package/package.json +8 -7
- package/src/FilterUI.tsx +317 -0
- package/src/ObjectView.tsx +668 -148
- package/src/SortUI.tsx +210 -0
- package/src/ViewSwitcher.tsx +311 -0
- package/src/__tests__/FilterUI.test.tsx +544 -0
- package/src/__tests__/ObjectView.test.tsx +375 -0
- package/src/__tests__/SortUI.test.tsx +380 -0
- package/src/__tests__/registration.test.tsx +32 -0
- package/src/index.tsx +147 -5
- package/vitest.config.ts +12 -0
- package/vitest.setup.ts +1 -0
package/dist/index.umd.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(P,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("react"),require("@object-ui/core"),require("@object-ui/plugin-grid"),require("@object-ui/plugin-form"),require("@object-ui/components"),require("lucide-react"),require("@object-ui/react")):typeof define=="function"&&define.amd?define(["exports","react","@object-ui/core","@object-ui/plugin-grid","@object-ui/plugin-form","@object-ui/components","lucide-react","@object-ui/react"],b):(P=typeof globalThis<"u"?globalThis:P||self,b(P.ObjectUIPluginView={},P.React,P.core,P.pluginGrid,P.pluginForm,P.components,P.lucideReact,P.react))})(this,(function(P,b,J,Me,me,l,$,je){"use strict";function ze(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const c in e)if(c!=="default"){const u=Object.getOwnPropertyDescriptor(e,c);Object.defineProperty(n,c,u.get?u:{enumerable:!0,get:()=>e[c]})}}return n.default=e,Object.freeze(n)}const O=ze(b);var se={exports:{}},re={};var xe;function Be(){if(xe)return re;xe=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function c(u,w,g){var F=null;if(g!==void 0&&(F=""+g),w.key!==void 0&&(F=""+w.key),"key"in w){g={};for(var y in w)y!=="key"&&(g[y]=w[y])}else g=w;return w=g.ref,{$$typeof:e,type:u,key:F,ref:w!==void 0?w:null,props:g}}return re.Fragment=n,re.jsx=c,re.jsxs=c,re}var le={};var he;function Ue(){return he||(he=1,process.env.NODE_ENV!=="production"&&(function(){function e(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===De?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case k:return"Fragment";case d:return"Profiler";case A:return"StrictMode";case ye:return"Suspense";case ue:return"SuspenseList";case q:return"Activity"}if(typeof r=="object")switch(typeof r.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),r.$$typeof){case o:return"Portal";case L:return r.displayName||"Context";case x:return(r._context.displayName||"Context")+".Consumer";case Z:var p=r.render;return r=r.displayName,r||(r=p.displayName||p.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case M:return p=r.displayName||null,p!==null?p:e(r.type)||"Memo";case de:p=r._payload,r=r._init;try{return e(r(p))}catch{}}return null}function n(r){return""+r}function c(r){try{n(r);var p=!1}catch{p=!0}if(p){p=console;var v=p.error,j=typeof Symbol=="function"&&Symbol.toStringTag&&r[Symbol.toStringTag]||r.constructor.name||"Object";return v.call(p,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",j),n(r)}}function u(r){if(r===k)return"<>";if(typeof r=="object"&&r!==null&&r.$$typeof===de)return"<...>";try{var p=e(r);return p?"<"+p+">":"<...>"}catch{return"<...>"}}function w(){var r=z.A;return r===null?null:r.getOwner()}function g(){return Error("react-stack-top-frame")}function F(r){if(Q.call(r,"key")){var p=Object.getOwnPropertyDescriptor(r,"key").get;if(p&&p.isReactWarning)return!1}return r.key!==void 0}function y(r,p){function v(){T||(T=!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)",p))}v.isReactWarning=!0,Object.defineProperty(r,"key",{get:v,configurable:!0})}function E(){var r=e(this.type);return R[r]||(R[r]=!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.")),r=this.props.ref,r!==void 0?r:null}function N(r,p,v,j,ee,te){var _=v.ref;return r={$$typeof:V,type:r,key:p,props:v,_owner:j},(_!==void 0?_:null)!==null?Object.defineProperty(r,"ref",{enumerable:!1,get:E}):Object.defineProperty(r,"ref",{enumerable:!1,value:null}),r._store={},Object.defineProperty(r._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(r,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(r,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:ee}),Object.defineProperty(r,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:te}),Object.freeze&&(Object.freeze(r.props),Object.freeze(r)),r}function C(r,p,v,j,ee,te){var _=p.children;if(_!==void 0)if(j)if(G(_)){for(j=0;j<_.length;j++)s(_[j]);Object.freeze&&Object.freeze(_)}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 s(_);if(Q.call(p,"key")){_=e(r);var W=Object.keys(p).filter(function(ve){return ve!=="key"});j=0<W.length?"{key: someKey, "+W.join(": ..., ")+": ...}":"{key: someKey}",h[_+j]||(W=0<W.length?"{"+W.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} />`,s,i,T,i),F[i+s]=!0)}if(i=null,l!==void 0&&(w(l),i=""+l),b(r)&&(w(r.key),i=""+r.key),"key"in r){l={};for(var $ in r)$!=="key"&&(l[$]=r[$])}else l=r;return i&&x(l,typeof e=="function"?e.displayName||e.name||"Unknown":e),k(e,i,l,u(),U,q)}function I(e){Y(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===O&&(e._payload.status==="fulfilled"?Y(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function Y(e){return typeof e=="object"&&e!==null&&e.$$typeof===V}var R=a,V=Symbol.for("react.transitional.element"),W=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),g=Symbol.for("react.profiler"),G=Symbol.for("react.consumer"),J=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),X=Symbol.for("react.suspense"),H=Symbol.for("react.suspense_list"),Q=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),Z=Symbol.for("react.activity"),K=Symbol.for("react.client.reference"),C=R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=Object.prototype.hasOwnProperty,z=Array.isArray,A=console.createTask?console.createTask:function(){return null};R={react_stack_bottom_frame:function(e){return e()}};var B,L={},n=R.react_stack_bottom_frame.bind(R,m)(),c=A(j(m)),F={};S.Fragment=E,S.jsx=function(e,r,l){var s=1e4>C.recentlyCreatedOwnerStacks++;return _(e,r,l,!1,s?Error("react-stack-top-frame"):n,s?A(j(e)):c)},S.jsxs=function(e,r,l){var s=1e4>C.recentlyCreatedOwnerStacks++;return _(e,r,l,!0,s?Error("react-stack-top-frame"):n,s?A(j(e)):c)}})()),S}var ne;function ce(){return ne||(ne=1,process.env.NODE_ENV==="production"?D.exports=se():D.exports=ie()),D.exports}var o=ce();const ae=({schema:t,dataSource:f,className:w})=>{const[j,u]=a.useState(null),[m,b]=a.useState(!1),[x,y]=a.useState("create"),[k,_]=a.useState(null),[I,Y]=a.useState(""),[R,V]=a.useState(!1),[W,E]=a.useState(0);a.useEffect(()=>{const n=async()=>{try{const c=await f.getObjectSchema(t.objectName);u(c)}catch(c){console.error("Failed to fetch object schema:",c)}};t.objectName&&f&&n()},[t.objectName,f]);const v=t.layout||"drawer",g=t.operations||t.table?.operations||{create:!0,read:!0,update:!0,delete:!0},G=a.useCallback(()=>{v==="page"&&t.onNavigate?t.onNavigate("new","edit"):(y("create"),_(null),b(!0))},[v,t]),J=a.useCallback(n=>{if(v==="page"&&t.onNavigate){const c=n._id||n.id;t.onNavigate(c,"edit")}else y("edit"),_(n),b(!0)},[v,t]),M=a.useCallback(n=>{if(v==="page"&&t.onNavigate){const c=n._id||n.id;t.onNavigate(c,"view")}else y("view"),_(n),b(!0)},[v,t]),X=a.useCallback(n=>{g.read!==!1&&M(n)},[g.read,M]),H=a.useCallback(n=>{E(c=>c+1)},[]),Q=a.useCallback(n=>{E(c=>c+1)},[]),O=a.useCallback(()=>{b(!1),_(null),E(n=>n+1)},[]),Z=a.useCallback(()=>{b(!1),_(null)},[]),K=a.useCallback(()=>{E(n=>n+1)},[]),C={type:"object-grid",objectName:t.objectName,title:t.table?.title,description:t.table?.description,fields:t.table?.fields,columns:t.table?.columns,operations:{...g,create:!1},defaultFilters:t.table?.defaultFilters,defaultSort:t.table?.defaultSort,pageSize:t.table?.pageSize,selectable:t.table?.selectable,className:t.table?.className},P=()=>{const n=k?k._id||k.id:void 0;return{type:"object-form",objectName:t.objectName,mode:x,recordId:n,title:t.form?.title,description:t.form?.description,fields:t.form?.fields,customFields:t.form?.customFields,groups:t.form?.groups,layout:t.form?.layout,columns:t.form?.columns,showSubmit:t.form?.showSubmit,submitText:t.form?.submitText,showCancel:t.form?.showCancel,cancelText:t.form?.cancelText,showReset:t.form?.showReset,initialValues:t.form?.initialValues,readOnly:t.form?.readOnly||x==="view",className:t.form?.className,onSuccess:O,onCancel:Z}},z=()=>{if(t.form?.title)return t.form.title;const n=j?.label||t.objectName;switch(x){case"create":return`Create ${n}`;case"edit":return`Edit ${n}`;case"view":return`View ${n}`;default:return n}},A=()=>o.jsx(d.Drawer,{open:m,onOpenChange:b,direction:"right",children:o.jsxs(d.DrawerContent,{className:"w-full sm:max-w-2xl",children:[o.jsxs(d.DrawerHeader,{children:[o.jsx(d.DrawerTitle,{children:z()}),t.form?.description&&o.jsx(d.DrawerDescription,{children:t.form.description})]}),o.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:o.jsx(te.ObjectForm,{schema:P(),dataSource:f})})]})}),B=()=>o.jsx(d.Dialog,{open:m,onOpenChange:b,children:o.jsxs(d.DialogContent,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[o.jsxs(d.DialogHeader,{children:[o.jsx(d.DialogTitle,{children:z()}),t.form?.description&&o.jsx(d.DialogDescription,{children:t.form.description})]}),o.jsx(te.ObjectForm,{schema:P(),dataSource:f})]})}),L=()=>{const n=t.showSearch!==!1,c=t.showFilters!==!1,F=t.showCreate!==!1&&g.create!==!1,e=t.showRefresh!==!1;return!n&&!c&&!F&&!e?null:o.jsxs("div",{className:"flex flex-col gap-4 mb-4",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsx("div",{className:"flex-1 max-w-md",children:n&&o.jsxs("div",{className:"relative",children:[o.jsx(h.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),o.jsx(d.Input,{type:"search",placeholder:`Search ${j?.label||t.objectName}...`,value:I,onChange:r=>Y(r.target.value),className:"pl-9"})]})}),o.jsxs("div",{className:"flex items-center gap-2",children:[c&&o.jsxs(d.Button,{variant:"outline",size:"sm",onClick:()=>V(!R),children:[o.jsx(h.Filter,{className:"h-4 w-4"}),"Filters",R&&o.jsx(h.X,{className:"h-3 w-3 ml-1"})]}),e&&o.jsx(d.Button,{variant:"outline",size:"sm",onClick:K,children:o.jsx(h.RefreshCw,{className:"h-4 w-4"})}),F&&o.jsxs(d.Button,{size:"sm",onClick:G,children:[o.jsx(h.Plus,{className:"h-4 w-4"}),"Create"]})]})]}),R&&o.jsx("div",{className:"p-4 border rounded-md bg-muted/50",children:o.jsx("p",{className:"text-sm text-muted-foreground",children:"Filter functionality will be integrated with FilterBuilder component"})})]})};return o.jsxs("div",{className:w,children:[(t.title||t.description)&&o.jsxs("div",{className:"mb-6",children:[t.title&&o.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:t.title}),t.description&&o.jsx("p",{className:"text-muted-foreground mt-1",children:t.description})]}),L(),o.jsx(le.ObjectGrid,{schema:C,dataSource:f,onRowClick:X,onEdit:g.update!==!1?J:void 0,onDelete:g.delete!==!1?H:void 0,onBulkDelete:g.delete!==!1?Q:void 0},W),v==="drawer"&&A(),v==="modal"&&B()]})},ue=({schema:t})=>o.jsx(ae,{schema:t,dataSource:null});ee.ComponentRegistry.register("object-view",ue,{namespace:"plugin-view"});const de=({schema:t,className:f,children:w,...j})=>{const u=t.props?.columns?{display:"grid",gridTemplateColumns:`repeat(${t.props.columns}, 1fr)`,gap:"1rem"}:void 0;return o.jsx("div",{className:f,style:u,...j,children:w})};ee.ComponentRegistry.register("view:simple",de,{namespace:"plugin-view",label:"Simple View",category:"view"}),p.ObjectView=ae,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})}));
|
|
6
|
+
<%s key={someKey} {...props} />`,j,_,W,_),h[_+j]=!0)}if(_=null,v!==void 0&&(c(v),_=""+v),F(p)&&(c(p.key),_=""+p.key),"key"in p){v={};for(var ae in p)ae!=="key"&&(v[ae]=p[ae])}else v=p;return _&&y(v,typeof r=="function"?r.displayName||r.name||"Unknown":r),N(r,_,v,w(),ee,te)}function s(r){S(r)?r._store&&(r._store.validated=1):typeof r=="object"&&r!==null&&r.$$typeof===de&&(r._payload.status==="fulfilled"?S(r._payload.value)&&r._payload.value._store&&(r._payload.value._store.validated=1):r._store&&(r._store.validated=1))}function S(r){return typeof r=="object"&&r!==null&&r.$$typeof===V}var m=b,V=Symbol.for("react.transitional.element"),o=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),A=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),x=Symbol.for("react.consumer"),L=Symbol.for("react.context"),Z=Symbol.for("react.forward_ref"),ye=Symbol.for("react.suspense"),ue=Symbol.for("react.suspense_list"),M=Symbol.for("react.memo"),de=Symbol.for("react.lazy"),q=Symbol.for("react.activity"),De=Symbol.for("react.client.reference"),z=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q=Object.prototype.hasOwnProperty,G=Array.isArray,ne=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(r){return r()}};var T,R={},ie=m.react_stack_bottom_frame.bind(m,g)(),ce=ne(u(g)),h={};le.Fragment=k,le.jsx=function(r,p,v){var j=1e4>z.recentlyCreatedOwnerStacks++;return C(r,p,v,!1,j?Error("react-stack-top-frame"):ie,j?ne(u(r)):ce)},le.jsxs=function(r,p,v){var j=1e4>z.recentlyCreatedOwnerStacks++;return C(r,p,v,!0,j?Error("react-stack-top-frame"):ie,j?ne(u(r)):ce)}})()),le}var Ce;function qe(){return Ce||(Ce=1,process.env.NODE_ENV==="production"?se.exports=Be():se.exports=Ue()),se.exports}var t=qe();function Se(e){var n,c,u="";if(typeof e=="string"||typeof e=="number")u+=e;else if(typeof e=="object")if(Array.isArray(e)){var w=e.length;for(n=0;n<w;n++)e[n]&&(c=Se(e[n]))&&(u&&(u+=" "),u+=c)}else for(c in e)e[c]&&(u&&(u+=" "),u+=c);return u}function Ye(){for(var e,n,c=0,u="",w=arguments.length;c<w;c++)(e=arguments[c])&&(n=Se(e))&&(u&&(u+=" "),u+=n);return u}const Ne=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Ve=Ye,X=(e,n)=>c=>{var u;if(n?.variants==null)return Ve(e,c?.class,c?.className);const{variants:w,defaultVariants:g}=n,F=Object.keys(w).map(N=>{const C=c?.[N],s=g?.[N];if(C===null)return null;const S=Ne(C)||Ne(s);return w[N][S]}),y=c&&Object.entries(c).reduce((N,C)=>{let[s,S]=C;return S===void 0||(N[s]=S),N},{}),E=n==null||(u=n.compoundVariants)===null||u===void 0?void 0:u.reduce((N,C)=>{let{class:s,className:S,...m}=C;return Object.entries(m).every(V=>{let[o,k]=V;return Array.isArray(k)?k.includes({...g,...y}[o]):{...g,...y}[o]===k})?[...N,s,S]:N},[]);return Ve(e,F,E,c?.class,c?.className)},We={list:"List",detail:"Detail",grid:"Grid",kanban:"Kanban",calendar:"Calendar",timeline:"Timeline",map:"Map"},Ge={list:$.List,detail:$.FileText,grid:$.Grid,kanban:$.LayoutGrid,calendar:$.Calendar,timeline:$.Activity,map:$.Map},He=X("flex gap-4",{variants:{position:{top:"flex-col",bottom:"flex-col-reverse",left:"flex-row",right:"flex-row-reverse"}},defaultVariants:{position:"top"}}),Ke=X("w-full",{variants:{orientation:{horizontal:"w-full",vertical:"w-48"}},defaultVariants:{orientation:"horizontal"}}),Je=X("flex gap-2",{variants:{orientation:{horizontal:"flex-row flex-wrap",vertical:"flex-col"}},defaultVariants:{orientation:"horizontal"}}),Xe=X("",{variants:{orientation:{horizontal:"",vertical:"flex h-auto flex-col items-stretch"}},defaultVariants:{orientation:"horizontal"}});function Ze(e){return e.split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}const Qe={Home:"House"};function et(e){if(!e)return null;const n=Ze(e),c=Qe[n]||n;return $.icons[c]||null}function fe(e){return e.label?e.label:We[e.type]||e.type}function Fe(e){return e.icon?et(e.icon):Ge[e.type]||null}function tt(e){return e.activeView?e.activeView:e.defaultView?e.defaultView:e.views?.[0]?.type}const pe=({schema:e,className:n,onViewChange:c,...u})=>{const w=O.useMemo(()=>e.storageKey?e.storageKey:`view-switcher${e.id?`-${e.id}`:""}`,[e.id,e.storageKey]),[g,F]=O.useState(()=>tt(e));O.useEffect(()=>{if(e.activeView){F(e.activeView);return}if(e.persistPreference)try{const d=localStorage.getItem(w);if(d){const x=e.views.find(L=>L.type===d)?.type;x&&F(x)}}catch{}},[e.activeView,e.persistPreference,e.views,w]),O.useEffect(()=>{if(!(!e.persistPreference||!g||e.activeView))try{localStorage.setItem(w,g)}catch{}},[g,e.activeView,e.persistPreference,w]);const y=O.useCallback(d=>{c?.(d),e.onViewChange&&typeof window<"u"&&window.dispatchEvent(new CustomEvent(e.onViewChange,{detail:{view:d}}))},[c,e.onViewChange]),E=O.useCallback(d=>{F(d),y(d)},[y]),N=g||e.views?.[0]?.type,C=N||"",s=e.views.find(d=>d.type===N)||e.views?.[0],S=e.variant||"tabs",m=e.position||"top",V=m==="left"||m==="right",o=V?"vertical":"horizontal",k=t.jsxs("div",{className:l.cn(Ke({orientation:o})),children:[S==="dropdown"&&t.jsxs(l.Select,{value:C,onValueChange:d=>E(d),children:[t.jsx(l.SelectTrigger,{className:l.cn("w-full",V?"h-10":"h-9"),children:t.jsx(l.SelectValue,{placeholder:"Select view"})}),t.jsx(l.SelectContent,{children:e.views.map((d,x)=>t.jsx(l.SelectItem,{value:d.type,children:fe(d)},`${d.type}-${x}`))})]}),S==="buttons"&&t.jsx("div",{className:l.cn(Je({orientation:o})),children:e.views.map((d,x)=>{const L=d.type===N,Z=Fe(d);return t.jsxs(l.Button,{type:"button",size:"sm",variant:L?"secondary":"ghost",className:l.cn("justify-start gap-2",V?"w-full":""),onClick:()=>E(d.type),children:[Z?t.jsx(Z,{className:"h-4 w-4"}):null,t.jsx("span",{children:fe(d)})]},`${d.type}-${x}`)})}),S==="tabs"&&t.jsx(l.Tabs,{value:C,onValueChange:d=>E(d),children:t.jsx(l.TabsList,{className:l.cn(Xe({orientation:o})),children:e.views.map((d,x)=>{const L=Fe(d);return t.jsxs(l.TabsTrigger,{value:d.type,className:l.cn("gap-2",V?"justify-start":""),children:[L?t.jsx(L,{className:"h-4 w-4"}):null,t.jsx("span",{children:fe(d)})]},`${d.type}-${x}`)})})})]}),A=s?.schema?Array.isArray(s.schema)?t.jsx("div",{className:"space-y-4",children:s.schema.map((d,x)=>t.jsx(je.SchemaRenderer,{schema:d,...u},`${s.type}-${x}`))}):t.jsx(je.SchemaRenderer,{schema:s.schema,...u}):null;return t.jsxs("div",{className:l.cn(He({position:m}),n),children:[t.jsx("div",{className:l.cn("shrink-0",V?"flex flex-col":"flex"),children:k}),t.jsx("div",{className:"flex-1 min-w-0",children:A})]})};let oe=null;try{oe=require("@object-ui/react").SchemaRenderer||null}catch{}const Te=({schema:e,dataSource:n,className:c,views:u,activeViewId:w,onViewChange:g,onRowClick:F,onEdit:y,renderListView:E,toolbarAddon:N})=>{const[C,s]=b.useState(null),[S,m]=b.useState(!1),[V,o]=b.useState("create"),[k,A]=b.useState(null),[d,x]=b.useState(0),[L,Z]=b.useState([]),[ye,ue]=b.useState(!1),[M,de]=b.useState({}),[q,De]=b.useState([]),z=e.listViews,Q=z!=null&&Object.keys(z).length>0,[G,ne]=b.useState(()=>e.defaultListView&&z?.[e.defaultListView]?e.defaultListView:z&&Object.keys(z)[0]||""),T=b.useMemo(()=>!Q||!G?null:z[G]||null,[Q,G,z]),R=b.useMemo(()=>u&&u.length>0?u:null,[u]),ie=R!=null&&R.length>0,ce=w||R?.[0]?.id,h=R?.find(i=>i.id===ce)||R?.[0],r=b.useMemo(()=>T?.type?T.type:h?.type?h.type:e.defaultViewType||"grid",[T,h,e.defaultViewType]),p=e.navigation;b.useEffect(()=>{let i=!0;const f=async()=>{try{const a=await n.getObjectSchema(e.objectName);i&&s(a)}catch(a){console.error("Failed to fetch object schema:",a)}};return e.objectName&&n&&f(),()=>{i=!1}},[e.objectName,n]),b.useEffect(()=>{let i=!0;return(async()=>{if(!(r==="grid"&&!E)&&!(!n||!e.objectName)){ue(!0);try{const a=T?.filter||h?.filter||e.table?.defaultFilters||[],U=Object.entries(M).filter(([,B])=>B!==void 0&&B!==""&&B!==null).map(([B,K])=>[B,"=",K]);let I=[];a.length>0&&U.length>0?I=["and",...a,...U]:U.length===1?I=U[0]:U.length>1?I=["and",...U]:I=a;const H=q.length>0?q.map(B=>({field:B.field,order:B.direction})):T?.sort||h?.sort||e.table?.defaultSort||void 0,D=await n.find(e.objectName,{$filter:I.length>0?I:void 0,$orderby:H,$top:100});let Y=[];Array.isArray(D)?Y=D:D&&typeof D=="object"&&(Array.isArray(D.data)?Y=D.data:Array.isArray(D.value)&&(Y=D.value)),i&&Z(Y)}catch(a){console.error("ObjectView data fetch error:",a)}finally{i&&ue(!1)}}})(),()=>{i=!1}},[e.objectName,n,r,M,q,d,T,h,E]);const v=e.layout||"drawer",j=e.operations||e.table?.operations||{create:!0,read:!0,update:!0,delete:!0},ee=b.useCallback(()=>{v==="page"&&e.onNavigate?e.onNavigate("new","edit"):(o("create"),A(null),m(!0))},[v,e]),te=b.useCallback(i=>{if(y){y(i);return}if(v==="page"&&e.onNavigate){const f=i._id||i.id;e.onNavigate(f,"edit")}else o("edit"),A(i),m(!0)},[v,e,y]),_=b.useCallback(i=>{if(v==="page"&&e.onNavigate){const f=i._id||i.id;e.onNavigate(f,"view")}else o("view"),A(i),m(!0)},[v,e]),W=b.useCallback(i=>{if(F){F(i);return}if(p){if(p.mode==="none"||p.preventNavigation)return;if(p.mode==="new_window"||p.openNewTab){const f=i._id||i.id,a=`/${e.objectName}/${f}`;window.open(a,"_blank");return}if(p.mode==="drawer"){o("view"),A(i),m(!0);return}if(p.mode==="modal"){o("view"),A(i),m(!0);return}if(p.mode==="page"){const f=i._id||i.id;e.onNavigate&&e.onNavigate(f,"view");return}}j.read!==!1&&_(i)},[F,p,j.read,_,e]),ae=b.useCallback(i=>{x(f=>f+1)},[]),ve=b.useCallback(i=>{x(f=>f+1)},[]),at=b.useCallback(()=>{m(!1),A(null),x(i=>i+1)},[]),st=b.useCallback(()=>{m(!1),A(null)},[]);b.useCallback(()=>{x(i=>i+1)},[]);const Pe=b.useMemo(()=>!ie||!R||R.length<=1?null:{type:"view-switcher",variant:"tabs",position:"top",persistPreference:!0,storageKey:`view-pref-${e.objectName}`,defaultView:h?.type||"grid",activeView:h?.type||"grid",views:R.map(i=>{const f={kanban:"kanban",calendar:"calendar",map:"map",gallery:"layout-grid",timeline:"activity",gantt:"gantt-chart",grid:"table",list:"list",detail:"file-text"};return{type:i.type,label:i.label,icon:f[i.type]||"table"}})},[ie,R,h,e.objectName]),ot=b.useCallback(i=>{if(!R)return;const f=R.find(a=>a.type===i);f&&g&&g(f.id)},[R,g]),ut=b.useCallback(i=>{ne(i)},[]);b.useMemo(()=>{if(e.showFilters===!1)return null;const i=e.filterableFields,f=C?.fields||{},U=(i?i.map(I=>[I,f[I]||{label:I}]):Object.entries(f).filter(([,I])=>!I.hidden).slice(0,8)).map(([I,H])=>{const D=H.type||"text";let Y="text",B;return D==="number"||D==="currency"||D==="percent"?Y="number":D==="boolean"||D==="toggle"?Y="boolean":D==="date"||D==="datetime"?Y="date":(D==="select"||H.options)&&(Y="select",B=(H.options||[]).map(K=>typeof K=="string"?{label:K,value:K}:{label:K.label,value:K.value})),{field:I,label:H.label||I,type:Y,placeholder:`Filter ${H.label||I}...`,...B?{options:B}:{}}});return U.length===0?null:{type:"filter-ui",layout:"popover",showClear:!0,showApply:!0,filters:U,values:M}},[e.showFilters,e.filterableFields,C,M]),b.useMemo(()=>{const i=C?.fields||{},f=Object.entries(i).filter(([,a])=>!a.hidden).slice(0,10).map(([a,U])=>({field:a,label:U.label||a}));return f.length===0?null:{type:"sort-ui",variant:"dropdown",multiple:!1,fields:f,sort:q}},[C,q]);const dt=b.useCallback(i=>{const f={objectName:e.objectName,fields:T?.columns||h?.columns||e.table?.fields,className:"h-full w-full",showSearch:!1},a=T?.options||h||{};switch(i){case"kanban":return{type:"object-kanban",...f,groupBy:a.kanban?.groupField||a.groupBy||a.groupField||"status",groupField:a.kanban?.groupField||a.groupField||"status",titleField:a.kanban?.titleField||a.titleField||"name",cardFields:f.fields||[],...a.kanban||{}};case"calendar":return{type:"object-calendar",...f,startDateField:a.calendar?.startDateField||a.startDateField||"start_date",endDateField:a.calendar?.endDateField||a.endDateField||"end_date",titleField:a.calendar?.titleField||a.titleField||"name",...a.calendar||{}};case"gallery":return{type:"object-gallery",...f,imageField:a.gallery?.imageField||a.imageField,titleField:a.gallery?.titleField||a.titleField||"name",subtitleField:a.gallery?.subtitleField||a.subtitleField,...a.gallery||{}};case"timeline":return{type:"object-timeline",...f,dateField:a.timeline?.dateField||a.dateField||"created_at",titleField:a.timeline?.titleField||a.titleField||"name",...a.timeline||{}};case"gantt":return{type:"object-gantt",...f,startDateField:a.gantt?.startDateField||a.startDateField||"start_date",endDateField:a.gantt?.endDateField||a.endDateField||"end_date",progressField:a.gantt?.progressField||a.progressField||"progress",dependenciesField:a.gantt?.dependenciesField||a.dependenciesField||"dependencies",...a.gantt||{}};case"map":return{type:"object-map",...f,locationField:a.map?.locationField||a.locationField||"location",...a.map||{}};default:return null}},[e.objectName,e.table?.fields,T,h]),ct=b.useMemo(()=>({type:"object-grid",objectName:e.objectName,title:e.table?.title,description:e.table?.description,fields:T?.columns||h?.columns||e.table?.fields,columns:T?.columns||h?.columns||e.table?.columns,operations:{...j,create:!1},defaultFilters:T?.filter||h?.filter||e.table?.defaultFilters,defaultSort:T?.sort||h?.sort||e.table?.defaultSort,pageSize:e.table?.pageSize,selectable:e.table?.selectable,className:e.table?.className}),[e,j,T,h]),Ie=()=>{const i=k?k._id||k.id:void 0;return{type:"object-form",objectName:e.objectName,mode:V,recordId:i,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||V==="view",className:e.form?.className,onSuccess:at,onCancel:st}},Re=()=>{if(e.form?.title)return e.form.title;const i=C?.label||e.objectName;switch(V){case"create":return`Create ${i}`;case"edit":return`Edit ${i}`;case"view":return`View ${i}`;default:return i}},$e=b.useMemo(()=>{const i=p?.width;return i?typeof i=="number"?`max-w-[${i}px]`:`max-w-[${i}]`:""},[p]),ft=()=>t.jsx(l.Drawer,{open:S,onOpenChange:m,direction:"right",children:t.jsxs(l.DrawerContent,{className:l.cn("w-full sm:max-w-2xl",$e),children:[t.jsxs(l.DrawerHeader,{children:[t.jsx(l.DrawerTitle,{children:Re()}),e.form?.description&&t.jsx(l.DrawerDescription,{children:e.form.description})]}),t.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:t.jsx(me.ObjectForm,{schema:Ie(),dataSource:n})})]})}),pt=()=>t.jsx(l.Dialog,{open:S,onOpenChange:m,children:t.jsxs(l.DialogContent,{className:l.cn("max-w-2xl max-h-[90vh] overflow-y-auto",$e),children:[t.jsxs(l.DialogHeader,{children:[t.jsx(l.DialogTitle,{children:Re()}),e.form?.description&&t.jsx(l.DialogDescription,{children:e.form.description})]}),t.jsx(me.ObjectForm,{schema:Ie(),dataSource:n})]})}),bt=b.useMemo(()=>Object.keys(M).some(f=>M[f]!==void 0&&M[f]!==""&&M[f]!==null)?Object.entries(M).filter(([,f])=>f!==void 0&&f!==""&&f!==null).map(([f,a])=>({field:f,operator:"equals",value:a})):T?.filter||h?.filter||e.table?.defaultFilters,[M,T,h,e.table?.defaultFilters]),wt=b.useMemo(()=>q.length>0?q:T?.sort||h?.sort||e.table?.defaultSort,[q,T,h,e.table?.defaultSort]),gt=()=>{const i=`${e.objectName}-${G||h?.id||"default"}-${r}-${d}`;if(E)return E({schema:{type:"list-view",objectName:e.objectName,viewType:r,fields:T?.columns||h?.columns||e.table?.fields,filters:bt,sort:wt,options:T?.options||h},dataSource:n,onEdit:te,onRowClick:W,className:"h-full"});if(r!=="grid"){const f=dt(r);if(f&&oe)return t.jsx(oe,{schema:f,dataSource:n,data:L,loading:ye},i);if(!oe)return t.jsx("div",{className:"flex items-center justify-center h-40 text-muted-foreground",children:t.jsxs("p",{children:["SchemaRenderer not available. Install @object-ui/react to render ",r," views."]})})}return t.jsx(Me.ObjectGrid,{schema:ct,dataSource:n,onRowClick:W,onEdit:j.update!==!1?te:void 0,onDelete:j.delete!==!1?ae:void 0,onBulkDelete:j.delete!==!1?ve:void 0},i)},yt=()=>{if(!Q)return null;const i=Object.entries(z);return i.length<=1?null:t.jsx(l.Tabs,{value:G,onValueChange:ut,className:"w-full",children:t.jsx(l.TabsList,{className:"w-auto",children:i.map(([f,a])=>t.jsx(l.TabsTrigger,{value:f,className:"text-sm",children:a.label||f},f))})})},vt=()=>{const i=e.showCreate!==!1&&j.create!==!1,f=e.showViewSwitcher===!0,a=yt();return!a&&!f&&!i&&!N?null:t.jsxs("div",{className:"flex flex-col gap-3",children:[a,(f||i||N)&&t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsx("div",{className:"flex items-center gap-2",children:f&&Pe&&t.jsx(pe,{schema:Pe,onViewChange:ot,className:"overflow-x-auto"})}),t.jsxs("div",{className:"flex items-center gap-2",children:[N,i&&t.jsxs(l.Button,{size:"sm",onClick:ee,children:[t.jsx($.Plus,{className:"h-4 w-4"}),"Create"]})]})]})]})},Le=p?.mode==="modal"?"modal":p?.mode==="drawer"?"drawer":v;return t.jsxs("div",{className:l.cn("flex flex-col h-full",c),children:[(e.title||e.description)&&t.jsxs("div",{className:"mb-4 shrink-0",children:[e.title&&t.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:e.title}),e.description&&t.jsx("p",{className:"text-muted-foreground mt-1",children:e.description})]}),t.jsx("div",{className:"mb-4 shrink-0",children:vt()}),t.jsx("div",{className:"flex-1 min-h-0",children:gt()}),Le==="drawer"&&ft(),Le==="modal"&&pt()]})},be=X("flex",{variants:{layout:{inline:"flex-col space-y-4",popover:"items-center",drawer:"items-center"}},defaultVariants:{layout:"inline"}}),rt=e=>e==null||e===""?!0:Array.isArray(e)?e.length===0:typeof e=="object"?Object.values(e).every(n=>n==null||n===""):!1,lt=e=>Array.isArray(e)?{start:e[0]||"",end:e[1]||""}:e&&typeof e=="object"?{start:e.start||"",end:e.end||""}:{start:"",end:""},Ee=({schema:e,className:n,onChange:c})=>{const[u,w]=O.useState(e.values||{}),[g,F]=O.useState(!1);O.useEffect(()=>{e.values&&w(e.values)},[e.values]);const y=O.useCallback(o=>{c?.(o),e.onChange&&typeof window<"u"&&window.dispatchEvent(new CustomEvent(e.onChange,{detail:{values:o}}))},[c,e.onChange]),E=O.useCallback((o,k)=>{const A={...u,[o]:k};w(A),e.showApply||y(A)},[y,e.showApply,u]),N=O.useCallback(()=>{const o={};if(w(o),e.showApply){y(o);return}y(o)},[y,e.showApply]),C=O.useCallback(()=>{y(u),F(!1)},[y,u]),s=O.useMemo(()=>Object.values(u).filter(o=>!rt(o)).length,[u]),S=o=>{const k=o.label||o.field,A=o.placeholder||`Filter by ${k}`;switch(o.type){case"number":return t.jsx(l.Input,{type:"number",value:u[o.field]??"",placeholder:A,onChange:d=>{const x=d.target.value,L=x===""?"":Number(x);E(o.field,L)}});case"select":return t.jsxs(l.Select,{value:u[o.field]!==void 0?String(u[o.field]):"",onValueChange:d=>{const x=o.options?.find(L=>String(L.value)===d);E(o.field,x?x.value:d)},children:[t.jsx(l.SelectTrigger,{children:t.jsx(l.SelectValue,{placeholder:A})}),t.jsx(l.SelectContent,{children:o.options?.map(d=>t.jsx(l.SelectItem,{value:String(d.value),children:d.label},String(d.value)))})]});case"date":return t.jsx(l.Input,{type:"date",value:u[o.field]??"",onChange:d=>E(o.field,d.target.value)});case"date-range":{const d=lt(u[o.field]);return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(l.Input,{type:"date",value:d.start??"",onChange:x=>{E(o.field,{...d,start:x.target.value})}}),t.jsx(l.Input,{type:"date",value:d.end??"",onChange:x=>{E(o.field,{...d,end:x.target.value})}})]})}case"boolean":return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(l.Checkbox,{checked:!!u[o.field],onCheckedChange:d=>E(o.field,!!d)}),t.jsx("span",{className:"text-sm text-muted-foreground",children:"Enabled"})]});default:return t.jsx(l.Input,{value:u[o.field]??"",placeholder:A,onChange:d=>E(o.field,d.target.value)})}},m=t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"grid gap-4 sm:grid-cols-2",children:e.filters.map(o=>t.jsxs("div",{className:"space-y-2",children:[t.jsx(l.Label,{className:"text-xs text-muted-foreground",children:o.label||o.field}),S(o)]},o.field))}),(e.showApply||e.showClear)&&t.jsxs("div",{className:"flex items-center justify-end gap-2 border-t pt-3",children:[e.showClear&&t.jsx(l.Button,{type:"button",variant:"ghost",size:"sm",onClick:N,children:"Clear"}),e.showApply&&t.jsx(l.Button,{type:"button",size:"sm",onClick:C,children:"Apply"})]})]}),V=e.layout||"inline";return V==="popover"?t.jsx("div",{className:l.cn(be({layout:V}),n),children:t.jsxs(l.Popover,{open:g,onOpenChange:F,children:[t.jsx(l.PopoverTrigger,{asChild:!0,children:t.jsxs(l.Button,{type:"button",variant:s>0?"secondary":"outline",size:"sm",className:"gap-2",children:[t.jsx($.SlidersHorizontal,{className:"h-4 w-4"}),"Filters",s>0&&t.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:s})]})}),t.jsx(l.PopoverContent,{align:"start",className:"w-[520px] p-4",children:m})]})}):V==="drawer"?t.jsxs("div",{className:l.cn(be({layout:V}),n),children:[t.jsxs(l.Button,{type:"button",variant:s>0?"secondary":"outline",size:"sm",className:"gap-2",onClick:()=>F(!0),children:[t.jsx($.SlidersHorizontal,{className:"h-4 w-4"}),"Filters",s>0&&t.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:s})]}),t.jsx(l.Drawer,{open:g,onOpenChange:F,children:t.jsxs(l.DrawerContent,{children:[t.jsxs(l.DrawerHeader,{children:[t.jsx(l.DrawerTitle,{children:"Filters"}),t.jsx(l.DrawerDescription,{children:"Refine the data with advanced filters."})]}),t.jsx("div",{className:"px-4 pb-6",children:m})]})})]}):t.jsxs("div",{className:l.cn(be({layout:V}),n),children:[m,!e.showApply&&e.showClear&&t.jsxs(l.Button,{type:"button",variant:"ghost",size:"sm",className:"gap-2",onClick:N,children:[t.jsx($.X,{className:"h-3.5 w-3.5"}),"Clear filters"]})]})},we=X("",{variants:{variant:{buttons:"flex flex-wrap gap-2",dropdown:"flex flex-wrap items-center gap-3",builder:"space-y-3"}},defaultVariants:{variant:"dropdown"}}),ge=e=>e?e.map(n=>({field:n.field,direction:n.direction})):[],_e=e=>e.map(n=>({id:`${n.field}-${n.direction}`,field:n.field,order:n.direction})),nt=e=>e.filter(n=>n.field).map(n=>({field:n.field,direction:n.order})),ke=({schema:e,className:n,onChange:c})=>{const[u,w]=O.useState(()=>ge(e.sort)),[g,F]=O.useState(()=>_e(ge(e.sort)));O.useEffect(()=>{const s=ge(e.sort);w(s),F(_e(s))},[e.sort]);const y=O.useCallback(s=>{w(s),c?.(s),e.onChange&&typeof window<"u"&&window.dispatchEvent(new CustomEvent(e.onChange,{detail:{sort:s}}))},[c,e.onChange]),E=O.useCallback(s=>{const S=u.find(o=>o.field===s),m=!!e.multiple;if(!S){const o=m?[...u,{field:s,direction:"asc"}]:[{field:s,direction:"asc"}];y(o);return}if(S.direction==="asc"){const o=u.map(k=>k.field===s?{...k,direction:"desc"}:k);y(o);return}const V=u.filter(o=>o.field!==s);y(V)},[y,e.multiple,u]);if((e.variant||"dropdown")==="buttons")return t.jsx("div",{className:l.cn(we({variant:"buttons"}),n),children:e.fields.map(s=>{const S=u.find(V=>V.field===s.field),m=S?.direction==="asc"?$.ArrowUp:$.ArrowDown;return t.jsxs(l.Button,{type:"button",variant:S?"secondary":"outline",size:"sm",onClick:()=>E(s.field),className:"gap-2",children:[t.jsx("span",{children:s.label||s.field}),S&&t.jsx(m,{className:"h-3.5 w-3.5"})]},s.field)})});if(e.multiple)return t.jsx("div",{className:l.cn(we({variant:"builder"}),n),children:t.jsx(l.SortBuilder,{fields:e.fields.map(s=>({value:s.field,label:s.label||s.field})),value:g,onChange:s=>{F(s),y(nt(s))}})});const C=u[0];return t.jsxs("div",{className:l.cn(we({variant:"dropdown"}),n),children:[t.jsxs(l.Select,{value:C?.field||"",onValueChange:s=>{if(!s){y([]);return}y([{field:s,direction:C?.direction||"asc"}])},children:[t.jsx(l.SelectTrigger,{className:"w-56",children:t.jsx(l.SelectValue,{placeholder:"Select field"})}),t.jsx(l.SelectContent,{children:e.fields.map(s=>t.jsx(l.SelectItem,{value:s.field,children:s.label||s.field},s.field))})]}),t.jsxs(l.Select,{value:C?.direction||"asc",onValueChange:s=>{C?.field&&y([{field:C.field,direction:s}])},children:[t.jsx(l.SelectTrigger,{className:"w-36",children:t.jsx(l.SelectValue,{})}),t.jsxs(l.SelectContent,{children:[t.jsx(l.SelectItem,{value:"asc",children:"Ascending"}),t.jsx(l.SelectItem,{value:"desc",children:"Descending"})]})]})]})};let Oe=b.createContext(null);try{const e=require("@object-ui/react");e.SchemaRendererContext&&(Oe=e.SchemaRendererContext)}catch{}const Ae=({schema:e})=>{const c=b.useContext(Oe)?.dataSource??null;return t.jsx(Te,{schema:e,dataSource:c})};J.ComponentRegistry.register("object-view",Ae,{namespace:"plugin-view",label:"Object View",category:"view",icon:"LayoutDashboard",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"title",type:"string",label:"Title"},{name:"description",type:"string",label:"Description"},{name:"layout",type:"enum",label:"Form Layout",enum:["drawer","modal","page"]},{name:"defaultViewType",type:"enum",label:"Default View Type",enum:["grid","kanban","gallery","calendar","timeline","gantt","map"]},{name:"defaultListView",type:"string",label:"Default Named View"},{name:"showSearch",type:"boolean",label:"Show Search"},{name:"showFilters",type:"boolean",label:"Show Filters"},{name:"showCreate",type:"boolean",label:"Show Create Button"},{name:"showRefresh",type:"boolean",label:"Show Refresh Button"},{name:"showViewSwitcher",type:"boolean",label:"Show View Switcher"},{name:"listViews",type:"object",label:"Named List Views"},{name:"navigation",type:"object",label:"Navigation Config"},{name:"searchableFields",type:"array",label:"Searchable Fields"},{name:"filterableFields",type:"array",label:"Filterable Fields"}],defaultProps:{layout:"drawer",defaultViewType:"grid",showSearch:!0,showFilters:!0,showCreate:!0,showRefresh:!0,showViewSwitcher:!0}}),J.ComponentRegistry.register("view",Ae,{namespace:"plugin-view",label:"View",category:"view"}),J.ComponentRegistry.register("view-switcher",pe,{namespace:"view",label:"View Switcher",category:"view",icon:"LayoutGrid",inputs:[{name:"views",type:"array",label:"Views",required:!0},{name:"defaultView",type:"string",label:"Default View"},{name:"activeView",type:"string",label:"Active View"},{name:"variant",type:"enum",label:"Variant",enum:["tabs","buttons","dropdown"]},{name:"position",type:"enum",label:"Position",enum:["top","bottom","left","right"]},{name:"persistPreference",type:"boolean",label:"Persist Preference"},{name:"storageKey",type:"string",label:"Storage Key"},{name:"onViewChange",type:"string",label:"On View Change Event"}],defaultProps:{variant:"tabs",position:"top",defaultView:"grid",views:[{type:"grid",label:"Grid",schema:{type:"text",content:"Grid view"}},{type:"list",label:"List",schema:{type:"text",content:"List view"}}]}}),J.ComponentRegistry.register("filter-ui",Ee,{namespace:"view",label:"Filter UI",category:"view",icon:"SlidersHorizontal",inputs:[{name:"filters",type:"array",label:"Filters",required:!0},{name:"values",type:"object",label:"Values"},{name:"onChange",type:"string",label:"On Change Event"},{name:"showClear",type:"boolean",label:"Show Clear Button"},{name:"showApply",type:"boolean",label:"Show Apply Button"},{name:"layout",type:"enum",label:"Layout",enum:["inline","popover","drawer"]}],defaultProps:{layout:"inline",showApply:!1,showClear:!0,filters:[{field:"name",label:"Name",type:"text",placeholder:"Search name"},{field:"status",label:"Status",type:"select",options:[{label:"Open",value:"open"},{label:"Closed",value:"closed"}]},{field:"created_at",label:"Created",type:"date"}]}}),J.ComponentRegistry.register("sort-ui",ke,{namespace:"view",label:"Sort UI",category:"view",icon:"ArrowUpDown",inputs:[{name:"fields",type:"array",label:"Fields",required:!0},{name:"sort",type:"array",label:"Sort"},{name:"onChange",type:"string",label:"On Change Event"},{name:"multiple",type:"boolean",label:"Allow Multiple"},{name:"variant",type:"enum",label:"Variant",enum:["dropdown","buttons"]}],defaultProps:{variant:"dropdown",multiple:!0,fields:[{field:"name",label:"Name"},{field:"created_at",label:"Created At"}],sort:[{field:"name",direction:"asc"}]}});const it=({schema:e,className:n,children:c,dataSource:u,...w})=>{const g=e.props?.columns?{display:"grid",gridTemplateColumns:`repeat(${e.props.columns}, 1fr)`,gap:"1rem"}:void 0;return t.jsx("div",{className:n,style:g,...w,children:c})};J.ComponentRegistry.register("view:simple",it,{namespace:"plugin-view",label:"Simple View",category:"view"}),P.FilterUI=Ee,P.ObjectView=Te,P.SortUI=ke,P.ViewSwitcher=pe,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FilterUISchema } from '../../types/src';
|
|
2
|
+
/**
|
|
3
|
+
* ObjectUI
|
|
4
|
+
* Copyright (c) 2024-present ObjectStack Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
export type FilterUIProps = {
|
|
11
|
+
schema: FilterUISchema;
|
|
12
|
+
className?: string;
|
|
13
|
+
onChange?: (values: Record<string, any>) => void;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
};
|
|
16
|
+
export declare const FilterUI: React.FC<FilterUIProps>;
|
|
@@ -1,25 +1,76 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { ObjectViewSchema, DataSource } from '../../types/src';
|
|
2
|
+
import { ObjectViewSchema, DataSource, ViewType } from '../../types/src';
|
|
3
3
|
export interface ObjectViewProps {
|
|
4
4
|
/**
|
|
5
5
|
* The schema configuration for the view
|
|
6
6
|
*/
|
|
7
7
|
schema: ObjectViewSchema;
|
|
8
8
|
/**
|
|
9
|
-
* Data source (ObjectQL or ObjectStack adapter)
|
|
9
|
+
* Data source (ObjectQL or ObjectStack adapter).
|
|
10
|
+
* If not provided, falls back to SchemaRendererProvider context.
|
|
10
11
|
*/
|
|
11
12
|
dataSource: DataSource;
|
|
12
13
|
/**
|
|
13
14
|
* Additional CSS class
|
|
14
15
|
*/
|
|
15
16
|
className?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Views available for the ViewSwitcher.
|
|
19
|
+
* Each view defines a type (grid, kanban, calendar, etc.) and display columns/config.
|
|
20
|
+
* If not provided, uses schema.listViews or falls back to default grid view.
|
|
21
|
+
*/
|
|
22
|
+
views?: Array<{
|
|
23
|
+
id: string;
|
|
24
|
+
label: string;
|
|
25
|
+
type: ViewType;
|
|
26
|
+
columns?: string[];
|
|
27
|
+
sort?: Array<{
|
|
28
|
+
field: string;
|
|
29
|
+
direction: 'asc' | 'desc';
|
|
30
|
+
}>;
|
|
31
|
+
filter?: any[];
|
|
32
|
+
[key: string]: any;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* The currently active view ID.
|
|
36
|
+
* Used for controlled ViewSwitcher state.
|
|
37
|
+
*/
|
|
38
|
+
activeViewId?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Callback when the active view changes
|
|
41
|
+
*/
|
|
42
|
+
onViewChange?: (viewId: string) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Callback when a row is clicked (for record detail navigation)
|
|
45
|
+
*/
|
|
46
|
+
onRowClick?: (record: Record<string, unknown>) => void;
|
|
47
|
+
/**
|
|
48
|
+
* Callback when edit is triggered on a record
|
|
49
|
+
*/
|
|
50
|
+
onEdit?: (record: Record<string, unknown>) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Render a custom ListView implementation for multi-view support.
|
|
53
|
+
* When provided, this replaces the default view rendering for the content area.
|
|
54
|
+
*/
|
|
55
|
+
renderListView?: (props: {
|
|
56
|
+
schema: any;
|
|
57
|
+
dataSource: DataSource;
|
|
58
|
+
onEdit?: (record: Record<string, unknown>) => void;
|
|
59
|
+
onRowClick?: (record: Record<string, unknown>) => void;
|
|
60
|
+
className?: string;
|
|
61
|
+
}) => React.ReactNode;
|
|
62
|
+
/**
|
|
63
|
+
* Toolbar addon: extra elements to render in the toolbar (e.g., MetadataToggle)
|
|
64
|
+
*/
|
|
65
|
+
toolbarAddon?: React.ReactNode;
|
|
16
66
|
}
|
|
17
67
|
/**
|
|
18
68
|
* ObjectView Component
|
|
19
69
|
*
|
|
20
|
-
* Renders a complete object management interface with
|
|
70
|
+
* Renders a complete object management interface with multi-view rendering
|
|
71
|
+
* and integrated CRUD operations.
|
|
21
72
|
*
|
|
22
|
-
* @example
|
|
73
|
+
* @example Basic usage (grid only)
|
|
23
74
|
* ```tsx
|
|
24
75
|
* <ObjectView
|
|
25
76
|
* schema={{
|
|
@@ -27,7 +78,36 @@ export interface ObjectViewProps {
|
|
|
27
78
|
* objectName: 'users',
|
|
28
79
|
* layout: 'drawer',
|
|
29
80
|
* showSearch: true,
|
|
30
|
-
* showFilters: true
|
|
81
|
+
* showFilters: true,
|
|
82
|
+
* }}
|
|
83
|
+
* dataSource={dataSource}
|
|
84
|
+
* />
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* @example Named listViews
|
|
88
|
+
* ```tsx
|
|
89
|
+
* <ObjectView
|
|
90
|
+
* schema={{
|
|
91
|
+
* type: 'object-view',
|
|
92
|
+
* objectName: 'contacts',
|
|
93
|
+
* listViews: {
|
|
94
|
+
* all: { label: 'All Contacts', type: 'grid', columns: ['name', 'email', 'phone'] },
|
|
95
|
+
* board: { label: 'By Status', type: 'kanban', options: { kanban: { groupField: 'status' } } },
|
|
96
|
+
* calendar: { label: 'Meetings', type: 'calendar', options: { calendar: { startDateField: 'meeting_date' } } },
|
|
97
|
+
* },
|
|
98
|
+
* defaultListView: 'all',
|
|
99
|
+
* }}
|
|
100
|
+
* dataSource={dataSource}
|
|
101
|
+
* />
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* @example With navigation config
|
|
105
|
+
* ```tsx
|
|
106
|
+
* <ObjectView
|
|
107
|
+
* schema={{
|
|
108
|
+
* type: 'object-view',
|
|
109
|
+
* objectName: 'accounts',
|
|
110
|
+
* navigation: { mode: 'drawer', width: '600px' },
|
|
31
111
|
* }}
|
|
32
112
|
* dataSource={dataSource}
|
|
33
113
|
* />
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SortUISchema } from '../../types/src';
|
|
2
|
+
/**
|
|
3
|
+
* ObjectUI
|
|
4
|
+
* Copyright (c) 2024-present ObjectStack Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
export type SortUIProps = {
|
|
11
|
+
schema: SortUISchema;
|
|
12
|
+
className?: string;
|
|
13
|
+
onChange?: (sort: SortUISchema['sort']) => void;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
};
|
|
16
|
+
export declare const SortUI: React.FC<SortUIProps>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ViewSwitcherSchema, ViewType } from '../../types/src';
|
|
2
|
+
/**
|
|
3
|
+
* ObjectUI
|
|
4
|
+
* Copyright (c) 2024-present ObjectStack Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
export type ViewSwitcherProps = {
|
|
11
|
+
schema: ViewSwitcherSchema;
|
|
12
|
+
className?: string;
|
|
13
|
+
onViewChange?: (view: ViewType) => void;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
};
|
|
16
|
+
export declare const ViewSwitcher: React.FC<ViewSwitcherProps>;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { ObjectView } from './ObjectView';
|
|
2
|
-
|
|
2
|
+
import { ViewSwitcher } from './ViewSwitcher';
|
|
3
|
+
import { FilterUI } from './FilterUI';
|
|
4
|
+
import { SortUI } from './SortUI';
|
|
5
|
+
export { ObjectView, ViewSwitcher, FilterUI, SortUI };
|
|
3
6
|
export type { ObjectViewProps } from './ObjectView';
|
|
7
|
+
export type { ViewSwitcherProps } from './ViewSwitcher';
|
|
8
|
+
export type { FilterUIProps } from './FilterUI';
|
|
9
|
+
export type { SortUIProps } from './SortUI';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/plugin-view",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Object View plugin for Object UI",
|
|
@@ -15,13 +15,14 @@
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
+
"class-variance-authority": "^0.7.1",
|
|
18
19
|
"lucide-react": "^0.563.0",
|
|
19
|
-
"@object-ui/components": "0.
|
|
20
|
-
"@object-ui/core": "0.
|
|
21
|
-
"@object-ui/plugin-
|
|
22
|
-
"@object-ui/
|
|
23
|
-
"@object-ui/
|
|
24
|
-
"@object-ui/
|
|
20
|
+
"@object-ui/components": "2.0.0",
|
|
21
|
+
"@object-ui/core": "2.0.0",
|
|
22
|
+
"@object-ui/plugin-form": "2.0.0",
|
|
23
|
+
"@object-ui/plugin-grid": "2.0.0",
|
|
24
|
+
"@object-ui/react": "2.0.0",
|
|
25
|
+
"@object-ui/types": "2.0.0"
|
|
25
26
|
},
|
|
26
27
|
"peerDependencies": {
|
|
27
28
|
"react": "^18.0.0 || ^19.0.0",
|