@object-ui/plugin-ai 3.1.3 → 3.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- (function(b,A){typeof exports=="object"&&typeof module<"u"?A(exports,require("@object-ui/core"),require("react"),require("@object-ui/components"),require("lucide-react")):typeof define=="function"&&define.amd?define(["exports","@object-ui/core","react","@object-ui/components","lucide-react"],A):(b=typeof globalThis<"u"?globalThis:b||self,A(b.ObjectUIPluginAI={},b.ObjectUICore,b.React,b.ObjectUIComponents,b.lucideReact))})(this,(function(b,A,S,s,c){"use strict";var D={exports:{}},P={};var W;function ae(){if(W)return P;W=1;var p=Symbol.for("react.transitional.element"),N=Symbol.for("react.fragment");function v(h,m,f){var y=null;if(f!==void 0&&(y=""+f),m.key!==void 0&&(y=""+m.key),"key"in m){f={};for(var g in m)g!=="key"&&(f[g]=m[g])}else f=m;return m=f.ref,{$$typeof:p,type:h,key:y,ref:m!==void 0?m:null,props:f}}return P.Fragment=N,P.jsx=v,P.jsxs=v,P}var I={};var G;function re(){return G||(G=1,process.env.NODE_ENV!=="production"&&(function(){function p(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===oe?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case T:return"Fragment";case x:return"Profiler";case i:return"StrictMode";case L:return"Suspense";case Y:return"SuspenseList";case ie:return"Activity"}if(typeof t=="object")switch(typeof t.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case E:return"Portal";case F:return t.displayName||"Context";case R:return(t._context.displayName||"Context")+".Consumer";case n:var r=t.render;return t=t.displayName,t||(t=r.displayName||r.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case le:return r=t.displayName||null,r!==null?r:p(t.type)||"Memo";case B:r=t._payload,t=t._init;try{return p(t(r))}catch{}}return null}function N(t){return""+t}function v(t){try{N(t);var r=!1}catch{r=!0}if(r){r=console;var o=r.error,d=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return o.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",d),N(t)}}function h(t){if(t===T)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===B)return"<...>";try{var r=p(t);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function m(){var t=M.A;return t===null?null:t.getOwner()}function f(){return Error("react-stack-top-frame")}function y(t){if($.call(t,"key")){var r=Object.getOwnPropertyDescriptor(t,"key").get;if(r&&r.isReactWarning)return!1}return t.key!==void 0}function g(t,r){function o(){Z||(Z=!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)",r))}o.isReactWarning=!0,Object.defineProperty(t,"key",{get:o,configurable:!0})}function C(){var t=p(this.type);return K[t]||(K[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),t=this.props.ref,t!==void 0?t:null}function w(t,r,o,d,z,U){var u=o.ref;return t={$$typeof:j,type:t,key:r,props:o,_owner:d},(u!==void 0?u:null)!==null?Object.defineProperty(t,"ref",{enumerable:!1,get:C}):Object.defineProperty(t,"ref",{enumerable:!1,value:null}),t._store={},Object.defineProperty(t._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(t,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(t,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:z}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:U}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function l(t,r,o,d,z,U){var u=r.children;if(u!==void 0)if(d)if(ce(u)){for(d=0;d<u.length;d++)_(u[d]);Object.freeze&&Object.freeze(u)}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 _(u);if($.call(r,"key")){u=p(t);var O=Object.keys(r).filter(function(de){return de!=="key"});d=0<O.length?"{key: someKey, "+O.join(": ..., ")+": ...}":"{key: someKey}",se[u+d]||(O=0<O.length?"{"+O.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@object-ui/core`),require(`react`),require(`@object-ui/components`),require(`lucide-react`)):typeof define==`function`&&define.amd?define([`exports`,`@object-ui/core`,`react`,`@object-ui/components`,`lucide-react`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginAI={},e.ObjectUICore,e.React,e.ObjectUIComponents,e.lucide_react))})(this,function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var a=Object.create,o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,l=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty,d=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),f=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=c(t),a=0,l=i.length,d;a<l;a++)d=i[a],!u.call(e,d)&&d!==n&&o(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=s(t,d))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:a(l(e)),f(t||!e||!e.__esModule?o(n,`default`,{value:e,enumerable:!0}):n,e)))(n);var p=d((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),m=d((e=>{process.env.NODE_ENV!==`production`&&(function(){function t(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===O?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case D:return`Activity`}if(typeof e==`object`)switch(typeof e.tag==`number`&&console.error(`Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.`),e.$$typeof){case g:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var n=e.render;return e=e.displayName,e||=(e=n.displayName||n.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return n=e.displayName||null,n===null?t(e.type)||`Memo`:n;case E:n=e._payload,e=e._init;try{return t(e(n))}catch{}}return null}function n(e){return``+e}function r(e){try{n(e);var t=!1}catch{t=!0}if(t){t=console;var r=t.error,i=typeof Symbol==`function`&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||`Object`;return r.call(t,`The provided key is an unsupported type %s. This value must be coerced to a string before using it here.`,i),n(e)}}function i(e){if(e===_)return`<>`;if(typeof e==`object`&&e&&e.$$typeof===E)return`<...>`;try{var n=t(e);return n?`<`+n+`>`:`<...>`}catch{return`<...>`}}function a(){var e=k.A;return e===null?null:e.getOwner()}function o(){return Error(`react-stack-top-frame`)}function s(e){if(A.call(e,`key`)){var t=Object.getOwnPropertyDescriptor(e,`key`).get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function c(e,t){function n(){N||(N=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",t))}n.isReactWarning=!0,Object.defineProperty(e,`key`,{get:n,configurable:!0})}function l(){var e=t(this.type);return P[e]||(P[e]=!0,console.error(`Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.`)),e=this.props.ref,e===void 0?null:e}function u(e,t,n,r,i,a){var o=n.ref;return e={$$typeof:h,type:e,key:t,props:n,_owner:r},(o===void 0?null:o)===null?Object.defineProperty(e,`ref`,{enumerable:!1,value:null}):Object.defineProperty(e,`ref`,{enumerable:!1,get:l}),e._store={},Object.defineProperty(e._store,`validated`,{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,`_debugInfo`,{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,`_debugStack`,{configurable:!1,enumerable:!1,writable:!0,value:i}),Object.defineProperty(e,`_debugTask`,{configurable:!1,enumerable:!1,writable:!0,value:a}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function d(e,n,i,o,l,d){var p=n.children;if(p!==void 0)if(o)if(j(p)){for(o=0;o<p.length;o++)f(p[o]);Object.freeze&&Object.freeze(p)}else console.error(`React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.`);else f(p);if(A.call(n,`key`)){p=t(e);var m=Object.keys(n).filter(function(e){return e!==`key`});o=0<m.length?`{key: someKey, `+m.join(`: ..., `)+`: ...}`:`{key: someKey}`,L[p+o]||(m=0<m.length?`{`+m.join(`: ..., `)+`: ...}`:`{}`,console.error(`A props object containing a "key" prop is being spread into JSX:
2
2
  let props = %s;
3
3
  <%s {...props} />
4
4
  React keys must be passed directly to JSX without using spread:
5
5
  let props = %s;
6
- <%s key={someKey} {...props} />`,d,u,O,u),se[u+d]=!0)}if(u=null,o!==void 0&&(v(o),u=""+o),y(r)&&(v(r.key),u=""+r.key),"key"in r){o={};for(var q in r)q!=="key"&&(o[q]=r[q])}else o=r;return u&&g(o,typeof t=="function"?t.displayName||t.name||"Unknown":t),w(t,u,o,m(),z,U)}function _(t){k(t)?t._store&&(t._store.validated=1):typeof t=="object"&&t!==null&&t.$$typeof===B&&(t._payload.status==="fulfilled"?k(t._payload.value)&&t._payload.value._store&&(t._payload.value._store.validated=1):t._store&&(t._store.validated=1))}function k(t){return typeof t=="object"&&t!==null&&t.$$typeof===j}var a=S,j=Symbol.for("react.transitional.element"),E=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),R=Symbol.for("react.consumer"),F=Symbol.for("react.context"),n=Symbol.for("react.forward_ref"),L=Symbol.for("react.suspense"),Y=Symbol.for("react.suspense_list"),le=Symbol.for("react.memo"),B=Symbol.for("react.lazy"),ie=Symbol.for("react.activity"),oe=Symbol.for("react.client.reference"),M=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=Object.prototype.hasOwnProperty,ce=Array.isArray,V=console.createTask?console.createTask:function(){return null};a={react_stack_bottom_frame:function(t){return t()}};var Z,K={},ee=a.react_stack_bottom_frame.bind(a,f)(),te=V(h(f)),se={};I.Fragment=T,I.jsx=function(t,r,o){var d=1e4>M.recentlyCreatedOwnerStacks++;return l(t,r,o,!1,d?Error("react-stack-top-frame"):ee,d?V(h(t)):te)},I.jsxs=function(t,r,o){var d=1e4>M.recentlyCreatedOwnerStacks++;return l(t,r,o,!0,d?Error("react-stack-top-frame"):ee,d?V(h(t)):te)}})()),I}var H;function ne(){return H||(H=1,process.env.NODE_ENV==="production"?D.exports=ae():D.exports=re()),D.exports}var e=ne();const J=({schema:p,onApply:N,onRefresh:v})=>{const{suggestions:h=[],showConfidence:m=!0,showReasoning:f=!1,autoFill:y=!1}=p,[g,C]=S.useState(h),[w,l]=S.useState(new Set),[_,k]=S.useState(!1),[a,j]=S.useState(!1),E=n=>{N?.(n),l(L=>new Set(L).add(n.fieldName))},T=()=>{g.forEach(n=>N?.(n)),l(new Set(g.map(n=>n.fieldName)))},i=n=>{C(L=>L.filter(Y=>Y.fieldName!==n))},x=()=>{j(!0),v&&v(),setTimeout(()=>j(!1),1e3)};if(_||g.length===0)return null;const R=g.filter(n=>!w.has(n.fieldName)),F=n=>n>=.8?"text-green-600":n>=.5?"text-yellow-600":"text-red-600";return e.jsxs(s.Card,{className:"border-blue-200 bg-blue-50/30",children:[e.jsx(s.CardHeader,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(s.CardTitle,{className:"text-sm flex items-center gap-2",children:[e.jsx(c.Sparkles,{className:"h-4 w-4 text-blue-500"}),"AI Suggestions",e.jsxs(s.Badge,{variant:"secondary",className:"text-xs",children:[R.length," suggestion",R.length!==1?"s":""]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(s.Button,{variant:"ghost",size:"sm",onClick:x,disabled:a,className:"h-7",children:e.jsx(c.RefreshCw,{className:`h-3 w-3 ${a?"animate-spin":""}`})}),R.length>1&&e.jsx(s.Button,{variant:"outline",size:"sm",onClick:T,className:"h-7 text-xs",children:"Apply All"}),e.jsx(s.Button,{variant:"ghost",size:"sm",onClick:()=>k(!0),className:"h-7",children:e.jsx(c.X,{className:"h-3 w-3"})})]})]})}),e.jsxs(s.CardContent,{className:"space-y-2 pt-0",children:[R.map(n=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-md bg-white border text-sm",children:[e.jsx(c.Lightbulb,{className:"h-4 w-4 text-yellow-500 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:n.fieldName}),e.jsx("span",{className:"text-muted-foreground",children:"→"}),e.jsx("span",{className:"font-mono text-blue-600 truncate",children:typeof n.value=="object"?JSON.stringify(n.value):String(n.value)})]}),m&&e.jsxs("div",{className:`text-xs ${F(n.confidence)}`,children:[Math.round(n.confidence*100),"% confidence"]}),f&&n.reasoning&&e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:n.reasoning})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(s.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-green-600 hover:text-green-700 hover:bg-green-50",onClick:()=>E(n),children:e.jsx(c.Check,{className:"h-3.5 w-3.5"})}),e.jsx(s.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-red-500 hover:text-red-700 hover:bg-red-50",onClick:()=>i(n.fieldName),children:e.jsx(c.X,{className:"h-3.5 w-3.5"})})]})]},n.fieldName)),w.size>0&&e.jsxs("div",{className:"text-xs text-green-600 flex items-center gap-1 pt-1",children:[e.jsx(c.Check,{className:"h-3 w-3"}),w.size," suggestion",w.size!==1?"s":""," applied"]})]})]})},X=({schema:p,onSelect:N,onDismiss:v})=>{const{recommendations:h=[],showScores:m=!1,layout:f="list",loading:y=!1,emptyMessage:g="No recommendations available"}=p,C=a=>{N?.(a)},w=a=>{v?.(a)};if(y)return e.jsx(s.Card,{children:e.jsxs(s.CardContent,{className:"p-8 text-center",children:[e.jsx(c.Sparkles,{className:"h-8 w-8 text-blue-500 mx-auto mb-3 animate-pulse"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generating recommendations..."})]})});if(h.length===0)return e.jsx(s.Card,{children:e.jsx(s.CardContent,{className:"p-8 text-center text-muted-foreground",children:g})});const l=a=>{if(!m)return null;const j=Math.round(a*100),E=a>=.7?"default":a>=.4?"secondary":"outline";return e.jsxs(s.Badge,{variant:E,className:"text-xs",children:[j,"%"]})},_=a=>e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg border hover:bg-muted/30 transition-colors cursor-pointer",onClick:()=>C(a),children:[e.jsx("div",{className:"mt-1 shrink-0",children:e.jsx(c.Star,{className:"h-4 w-4 text-yellow-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium text-sm",children:a.title}),a.category&&e.jsx(s.Badge,{variant:"outline",className:"text-xs",children:a.category}),l(a.score)]}),a.description&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:a.description})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[a.action&&e.jsx(s.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",children:e.jsx(c.ExternalLink,{className:"h-3.5 w-3.5"})}),e.jsx(s.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground",onClick:j=>{j.stopPropagation(),w(a)},children:e.jsx(c.X,{className:"h-3.5 w-3.5"})})]})]},a.id),k=a=>e.jsx(s.Card,{className:"cursor-pointer hover:shadow-md transition-shadow",onClick:()=>C(a),children:e.jsxs(s.CardContent,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsx(c.Star,{className:"h-4 w-4 text-yellow-500"}),l(a.score)]}),e.jsx("h4",{className:"font-medium text-sm mb-1",children:a.title}),a.description&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-3",children:a.description}),a.category&&e.jsx(s.Badge,{variant:"outline",className:"text-xs mt-2",children:a.category}),e.jsxs("div",{className:"flex items-center gap-1 mt-3",children:[e.jsx(s.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-green-600",children:e.jsx(c.ThumbsUp,{className:"h-3 w-3"})}),e.jsx(s.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-red-500",children:e.jsx(c.ThumbsDown,{className:"h-3 w-3"})})]})]})},a.id);return e.jsxs(s.Card,{children:[e.jsx(s.CardHeader,{children:e.jsxs(s.CardTitle,{className:"flex items-center gap-2 text-sm",children:[e.jsx(c.Sparkles,{className:"h-4 w-4 text-blue-500"}),"Recommendations",e.jsx(s.Badge,{variant:"secondary",className:"text-xs",children:h.length})]})}),e.jsx(s.CardContent,{children:f==="grid"?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:h.map(k)}):e.jsx("div",{className:"space-y-2",children:h.map(_)})})]})},Q=({schema:p,onSubmit:N})=>{const{placeholder:v="Ask a question about your data...",result:h,suggestions:m=[],showHistory:f=!1,history:y=[],loading:g=!1}=p,[C,w]=S.useState(""),[l,_]=S.useState(h),[k,a]=S.useState(!1),j=k||g,E=i=>{const x=i||C;x.trim()&&(a(!0),N?.(x),N?a(!1):setTimeout(()=>{_({query:x,summary:`Results for: "${x}"`,confidence:.85,data:[],columns:[]}),a(!1)},1e3))},T=i=>{w(i),E(i)};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(s.Card,{children:e.jsxs(s.CardContent,{className:"p-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"relative flex-1",children:[e.jsx(c.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(s.Input,{value:C,onChange:i=>w(i.target.value),onKeyDown:i=>i.key==="Enter"&&E(),placeholder:v,className:"pl-10 pr-20",disabled:j}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2",children:e.jsx(s.Button,{size:"sm",onClick:()=>E(),disabled:j||!C.trim(),className:"h-7",children:j?e.jsx(c.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(c.Sparkles,{className:"h-3.5 w-3.5 mr-1"}),"Ask"]})})})]})}),m.length>0&&!l&&e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:m.map((i,x)=>e.jsx("button",{onClick:()=>T(i),className:"text-xs px-2.5 py-1 rounded-full border bg-muted/30 hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",disabled:j,children:i},x))})]})}),l&&e.jsxs(s.Card,{children:[e.jsx(s.CardHeader,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(s.CardTitle,{className:"text-sm flex items-center gap-2",children:[e.jsx(c.Table,{className:"h-4 w-4"}),"Results"]}),l.confidence!==void 0&&e.jsxs(s.Badge,{variant:l.confidence>=.7?"default":"secondary",className:"text-xs",children:[Math.round(l.confidence*100),"% match"]})]})}),e.jsxs(s.CardContent,{children:[l.summary&&e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:l.summary}),l.data&&l.data.length>0&&l.columns&&e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted",children:e.jsx("tr",{children:l.columns.map((i,x)=>e.jsx("th",{className:"px-4 py-2 text-left font-medium",children:i.label||i.name},x))})}),e.jsx("tbody",{children:l.data.map((i,x)=>e.jsx("tr",{className:"border-t",children:l.columns.map((R,F)=>e.jsx("td",{className:"px-4 py-2",children:String(i[R.name]??"")},F))},x))})]})}),(!l.data||l.data.length===0)&&e.jsx("div",{className:"text-center py-6 text-muted-foreground text-sm",children:"No matching records found"})]})]}),f&&y.length>0&&e.jsxs(s.Card,{children:[e.jsx(s.CardHeader,{className:"pb-2",children:e.jsxs(s.CardTitle,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(c.Clock,{className:"h-3 w-3"}),"Recent Queries"]})}),e.jsx(s.CardContent,{className:"space-y-1",children:y.slice(0,5).map((i,x)=>e.jsxs("button",{onClick:()=>T(i.query),className:"w-full flex items-center gap-2 p-2 rounded-md text-sm text-left hover:bg-muted/50 transition-colors",children:[e.jsx(c.ArrowRight,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsx("span",{className:"truncate",children:i.query}),e.jsx("span",{className:"text-xs text-muted-foreground shrink-0 ml-auto",children:new Date(i.timestamp).toLocaleDateString()})]},x))})]})]})};A.ComponentRegistry.register("ai-form-assist",J,{label:"AI Form Assist",category:"AI",inputs:[{name:"formId",type:"string",label:"Form ID"},{name:"objectName",type:"string",label:"Object Name"},{name:"fields",type:"array",label:"Fields to suggest"},{name:"suggestions",type:"code",label:"Suggestions Data"},{name:"autoFill",type:"boolean",label:"Auto Fill",defaultValue:!1},{name:"showConfidence",type:"boolean",label:"Show Confidence",defaultValue:!0},{name:"showReasoning",type:"boolean",label:"Show Reasoning",defaultValue:!1}]}),A.ComponentRegistry.register("ai-recommendations",X,{label:"AI Recommendations",category:"AI",inputs:[{name:"objectName",type:"string",label:"Object Name"},{name:"recommendations",type:"code",label:"Recommendations Data"},{name:"maxResults",type:"number",label:"Max Results",defaultValue:10},{name:"showScores",type:"boolean",label:"Show Scores",defaultValue:!1},{name:"layout",type:"enum",label:"Layout",enum:[{label:"List",value:"list"},{label:"Grid",value:"grid"},{label:"Carousel",value:"carousel"}],defaultValue:"list"},{name:"emptyMessage",type:"string",label:"Empty Message"}]}),A.ComponentRegistry.register("nl-query",Q,{label:"Natural Language Query",category:"AI",inputs:[{name:"objectName",type:"string",label:"Object Name"},{name:"placeholder",type:"string",label:"Placeholder Text"},{name:"suggestions",type:"array",label:"Example Queries"},{name:"showHistory",type:"boolean",label:"Show History",defaultValue:!1}]}),b.AIFormAssist=J,b.AIRecommendations=X,b.NLQueryInput=Q,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
6
+ <%s key={someKey} {...props} />`,o,p,m,p),L[p+o]=!0)}if(p=null,i!==void 0&&(r(i),p=``+i),s(n)&&(r(n.key),p=``+n.key),`key`in n)for(var h in i={},n)h!==`key`&&(i[h]=n[h]);else i=n;return p&&c(i,typeof e==`function`?e.displayName||e.name||`Unknown`:e),u(e,p,i,a(),l,d)}function f(e){p(e)?e._store&&(e._store.validated=1):typeof e==`object`&&e&&e.$$typeof===E&&(e._payload.status===`fulfilled`?p(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function p(e){return typeof e==`object`&&!!e&&e.$$typeof===h}var m=require(`react`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.client.reference`),k=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=Object.prototype.hasOwnProperty,j=Array.isArray,M=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(e){return e()}};var N,P={},F=m.react_stack_bottom_frame.bind(m,o)(),I=M(i(o)),L={};e.Fragment=_,e.jsx=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!1,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)},e.jsxs=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!0,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)}})()})),h=d(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=p():t.exports=m()}))(),g=({schema:e,onApply:t,onRefresh:a})=>{let{suggestions:o=[],showConfidence:s=!0,showReasoning:c=!1,autoFill:l=!1}=e,[u,d]=(0,n.useState)(o),[f,p]=(0,n.useState)(new Set),[m,g]=(0,n.useState)(!1),[_,v]=(0,n.useState)(!1),y=e=>{t?.(e),p(t=>new Set(t).add(e.fieldName))},b=()=>{u.forEach(e=>t?.(e)),p(new Set(u.map(e=>e.fieldName)))},x=e=>{d(t=>t.filter(t=>t.fieldName!==e))},S=()=>{v(!0),a&&a(),setTimeout(()=>v(!1),1e3)};if(m||u.length===0)return null;let C=u.filter(e=>!f.has(e.fieldName)),w=e=>e>=.8?`text-green-600`:e>=.5?`text-yellow-600`:`text-red-600`;return(0,h.jsxs)(r.Card,{className:`border-blue-200 bg-blue-50/30`,children:[(0,h.jsx)(r.CardHeader,{className:`pb-2`,children:(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsxs)(r.CardTitle,{className:`text-sm flex items-center gap-2`,children:[(0,h.jsx)(i.Sparkles,{className:`h-4 w-4 text-blue-500`}),`AI Suggestions`,(0,h.jsxs)(r.Badge,{variant:`secondary`,className:`text-xs`,children:[C.length,` suggestion`,C.length===1?``:`s`]})]}),(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(r.Button,{variant:`ghost`,size:`sm`,onClick:S,disabled:_,className:`h-7`,children:(0,h.jsx)(i.RefreshCw,{className:`h-3 w-3 ${_?`animate-spin`:``}`})}),C.length>1&&(0,h.jsx)(r.Button,{variant:`outline`,size:`sm`,onClick:b,className:`h-7 text-xs`,children:`Apply All`}),(0,h.jsx)(r.Button,{variant:`ghost`,size:`sm`,onClick:()=>g(!0),className:`h-7`,children:(0,h.jsx)(i.X,{className:`h-3 w-3`})})]})]})}),(0,h.jsxs)(r.CardContent,{className:`space-y-2 pt-0`,children:[C.map(e=>(0,h.jsxs)(`div`,{className:`flex items-center gap-3 p-2 rounded-md bg-white border text-sm`,children:[(0,h.jsx)(i.Lightbulb,{className:`h-4 w-4 text-yellow-500 shrink-0`}),(0,h.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`font-medium`,children:e.fieldName}),(0,h.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,h.jsx)(`span`,{className:`font-mono text-blue-600 truncate`,children:typeof e.value==`object`?JSON.stringify(e.value):String(e.value)})]}),s&&(0,h.jsxs)(`div`,{className:`text-xs ${w(e.confidence)}`,children:[Math.round(e.confidence*100),`% confidence`]}),c&&e.reasoning&&(0,h.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:e.reasoning})]}),(0,h.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,h.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 text-green-600 hover:text-green-700 hover:bg-green-50`,onClick:()=>y(e),children:(0,h.jsx)(i.Check,{className:`h-3.5 w-3.5`})}),(0,h.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 text-red-500 hover:text-red-700 hover:bg-red-50`,onClick:()=>x(e.fieldName),children:(0,h.jsx)(i.X,{className:`h-3.5 w-3.5`})})]})]},e.fieldName)),f.size>0&&(0,h.jsxs)(`div`,{className:`text-xs text-green-600 flex items-center gap-1 pt-1`,children:[(0,h.jsx)(i.Check,{className:`h-3 w-3`}),f.size,` suggestion`,f.size===1?``:`s`,` applied`]})]})]})},_=({schema:e,onSelect:t,onDismiss:n})=>{let{recommendations:a=[],showScores:o=!1,layout:s=`list`,loading:c=!1,emptyMessage:l=`No recommendations available`}=e,u=e=>{t?.(e)},d=e=>{n?.(e)};if(c)return(0,h.jsx)(r.Card,{children:(0,h.jsxs)(r.CardContent,{className:`p-8 text-center`,children:[(0,h.jsx)(i.Sparkles,{className:`h-8 w-8 text-blue-500 mx-auto mb-3 animate-pulse`}),(0,h.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Generating recommendations...`})]})});if(a.length===0)return(0,h.jsx)(r.Card,{children:(0,h.jsx)(r.CardContent,{className:`p-8 text-center text-muted-foreground`,children:l})});let f=e=>{if(!o)return null;let t=Math.round(e*100);return(0,h.jsxs)(r.Badge,{variant:e>=.7?`default`:e>=.4?`secondary`:`outline`,className:`text-xs`,children:[t,`%`]})};return(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.CardHeader,{children:(0,h.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-sm`,children:[(0,h.jsx)(i.Sparkles,{className:`h-4 w-4 text-blue-500`}),`Recommendations`,(0,h.jsx)(r.Badge,{variant:`secondary`,className:`text-xs`,children:a.length})]})}),(0,h.jsx)(r.CardContent,{children:s===`grid`?(0,h.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:a.map(e=>(0,h.jsx)(r.Card,{className:`cursor-pointer hover:shadow-md transition-shadow`,onClick:()=>u(e),children:(0,h.jsxs)(r.CardContent,{className:`p-4`,children:[(0,h.jsxs)(`div`,{className:`flex items-start justify-between mb-2`,children:[(0,h.jsx)(i.Star,{className:`h-4 w-4 text-yellow-500`}),f(e.score)]}),(0,h.jsx)(`h4`,{className:`font-medium text-sm mb-1`,children:e.title}),e.description&&(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground line-clamp-3`,children:e.description}),e.category&&(0,h.jsx)(r.Badge,{variant:`outline`,className:`text-xs mt-2`,children:e.category}),(0,h.jsxs)(`div`,{className:`flex items-center gap-1 mt-3`,children:[(0,h.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-green-600`,children:(0,h.jsx)(i.ThumbsUp,{className:`h-3 w-3`})}),(0,h.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-red-500`,children:(0,h.jsx)(i.ThumbsDown,{className:`h-3 w-3`})})]})]})},e.id))}):(0,h.jsx)(`div`,{className:`space-y-2`,children:a.map(e=>(0,h.jsxs)(`div`,{className:`flex items-start gap-3 p-3 rounded-lg border hover:bg-muted/30 transition-colors cursor-pointer`,onClick:()=>u(e),children:[(0,h.jsx)(`div`,{className:`mt-1 shrink-0`,children:(0,h.jsx)(i.Star,{className:`h-4 w-4 text-yellow-500`})}),(0,h.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,h.jsx)(`span`,{className:`font-medium text-sm`,children:e.title}),e.category&&(0,h.jsx)(r.Badge,{variant:`outline`,className:`text-xs`,children:e.category}),f(e.score)]}),e.description&&(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground line-clamp-2`,children:e.description})]}),(0,h.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[e.action&&(0,h.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,children:(0,h.jsx)(i.ExternalLink,{className:`h-3.5 w-3.5`})}),(0,h.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 text-muted-foreground`,onClick:t=>{t.stopPropagation(),d(e)},children:(0,h.jsx)(i.X,{className:`h-3.5 w-3.5`})})]})]},e.id))})})]})},v=({schema:e,onSubmit:t})=>{let{placeholder:a=`Ask a question about your data...`,result:o,suggestions:s=[],showHistory:c=!1,history:l=[],loading:u=!1}=e,[d,f]=(0,n.useState)(``),[p,m]=(0,n.useState)(o),[g,_]=(0,n.useState)(!1),v=g||u,y=e=>{let n=e||d;n.trim()&&(_(!0),t?.(n),t?_(!1):setTimeout(()=>{m({query:n,summary:`Results for: "${n}"`,confidence:.85,data:[],columns:[]}),_(!1)},1e3))},b=e=>{f(e),y(e)};return(0,h.jsxs)(`div`,{className:`space-y-4`,children:[(0,h.jsx)(r.Card,{children:(0,h.jsxs)(r.CardContent,{className:`p-4`,children:[(0,h.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,h.jsxs)(`div`,{className:`relative flex-1`,children:[(0,h.jsx)(i.Search,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`}),(0,h.jsx)(r.Input,{value:d,onChange:e=>f(e.target.value),onKeyDown:e=>e.key===`Enter`&&y(),placeholder:a,className:`pl-10 pr-20`,disabled:v}),(0,h.jsx)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2`,children:(0,h.jsx)(r.Button,{size:`sm`,onClick:()=>y(),disabled:v||!d.trim(),className:`h-7`,children:v?(0,h.jsx)(i.Loader2,{className:`h-3.5 w-3.5 animate-spin`}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(i.Sparkles,{className:`h-3.5 w-3.5 mr-1`}),`Ask`]})})})]})}),s.length>0&&!p&&(0,h.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:s.map((e,t)=>(0,h.jsx)(`button`,{onClick:()=>b(e),className:`text-xs px-2.5 py-1 rounded-full border bg-muted/30 hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,disabled:v,children:e},t))})]})}),p&&(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.CardHeader,{className:`pb-2`,children:(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsxs)(r.CardTitle,{className:`text-sm flex items-center gap-2`,children:[(0,h.jsx)(i.Table,{className:`h-4 w-4`}),`Results`]}),p.confidence!==void 0&&(0,h.jsxs)(r.Badge,{variant:p.confidence>=.7?`default`:`secondary`,className:`text-xs`,children:[Math.round(p.confidence*100),`% match`]})]})}),(0,h.jsxs)(r.CardContent,{children:[p.summary&&(0,h.jsx)(`p`,{className:`text-sm text-muted-foreground mb-3`,children:p.summary}),p.data&&p.data.length>0&&p.columns&&(0,h.jsx)(`div`,{className:`border rounded-lg overflow-hidden`,children:(0,h.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,h.jsx)(`thead`,{className:`bg-muted`,children:(0,h.jsx)(`tr`,{children:p.columns.map((e,t)=>(0,h.jsx)(`th`,{className:`px-4 py-2 text-left font-medium`,children:e.label||e.name},t))})}),(0,h.jsx)(`tbody`,{children:p.data.map((e,t)=>(0,h.jsx)(`tr`,{className:`border-t`,children:p.columns.map((t,n)=>(0,h.jsx)(`td`,{className:`px-4 py-2`,children:String(e[t.name]??``)},n))},t))})]})}),(!p.data||p.data.length===0)&&(0,h.jsx)(`div`,{className:`text-center py-6 text-muted-foreground text-sm`,children:`No matching records found`})]})]}),c&&l.length>0&&(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.CardHeader,{className:`pb-2`,children:(0,h.jsxs)(r.CardTitle,{className:`text-xs text-muted-foreground flex items-center gap-1`,children:[(0,h.jsx)(i.Clock,{className:`h-3 w-3`}),`Recent Queries`]})}),(0,h.jsx)(r.CardContent,{className:`space-y-1`,children:l.slice(0,5).map((e,t)=>(0,h.jsxs)(`button`,{onClick:()=>b(e.query),className:`w-full flex items-center gap-2 p-2 rounded-md text-sm text-left hover:bg-muted/50 transition-colors`,children:[(0,h.jsx)(i.ArrowRight,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,h.jsx)(`span`,{className:`truncate`,children:e.query}),(0,h.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0 ml-auto`,children:new Date(e.timestamp).toLocaleDateString()})]},t))})]})]})};t.ComponentRegistry.register(`ai-form-assist`,g,{label:`AI Form Assist`,category:`AI`,inputs:[{name:`formId`,type:`string`,label:`Form ID`},{name:`objectName`,type:`string`,label:`Object Name`},{name:`fields`,type:`array`,label:`Fields to suggest`},{name:`suggestions`,type:`code`,label:`Suggestions Data`},{name:`autoFill`,type:`boolean`,label:`Auto Fill`,defaultValue:!1},{name:`showConfidence`,type:`boolean`,label:`Show Confidence`,defaultValue:!0},{name:`showReasoning`,type:`boolean`,label:`Show Reasoning`,defaultValue:!1}]}),t.ComponentRegistry.register(`ai-recommendations`,_,{label:`AI Recommendations`,category:`AI`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`},{name:`recommendations`,type:`code`,label:`Recommendations Data`},{name:`maxResults`,type:`number`,label:`Max Results`,defaultValue:10},{name:`showScores`,type:`boolean`,label:`Show Scores`,defaultValue:!1},{name:`layout`,type:`enum`,label:`Layout`,enum:[{label:`List`,value:`list`},{label:`Grid`,value:`grid`},{label:`Carousel`,value:`carousel`}],defaultValue:`list`},{name:`emptyMessage`,type:`string`,label:`Empty Message`}]}),t.ComponentRegistry.register(`nl-query`,v,{label:`Natural Language Query`,category:`AI`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`},{name:`placeholder`,type:`string`,label:`Placeholder Text`},{name:`suggestions`,type:`array`,label:`Example Queries`},{name:`showHistory`,type:`boolean`,label:`Show History`,defaultValue:!1}]}),e.AIFormAssist=g,e.AIRecommendations=_,e.NLQueryInput=v});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@object-ui/plugin-ai",
3
- "version": "3.1.3",
3
+ "version": "3.1.5",
4
4
  "type": "module",
5
5
  "main": "dist/index.umd.cjs",
6
6
  "module": "dist/index.js",
@@ -23,19 +23,19 @@
23
23
  "clsx": "^2.1.1",
24
24
  "lucide-react": "^0.577.0",
25
25
  "tailwind-merge": "^3.5.0",
26
- "@object-ui/components": "3.1.3",
27
- "@object-ui/core": "3.1.3",
28
- "@object-ui/react": "3.1.3",
29
- "@object-ui/types": "3.1.3"
26
+ "@object-ui/components": "3.1.5",
27
+ "@object-ui/core": "3.1.5",
28
+ "@object-ui/react": "3.1.5",
29
+ "@object-ui/types": "3.1.5"
30
30
  },
31
31
  "devDependencies": {
32
- "@types/node": "^25.4.0",
32
+ "@types/node": "^25.5.0",
33
33
  "@types/react": "19.2.14",
34
34
  "@types/react-dom": "19.2.3",
35
- "@vitejs/plugin-react": "^5.1.4",
36
- "vite": "^7.3.1",
35
+ "@vitejs/plugin-react": "^6.0.1",
36
+ "vite": "^8.0.1",
37
37
  "vite-plugin-dts": "^4.5.4",
38
- "vitest": "^4.0.18"
38
+ "vitest": "^4.1.0"
39
39
  },
40
40
  "scripts": {
41
41
  "build": "vite build",