@geoffai/elements 0.1.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/README.md +81 -0
- package/dist/components/index.cjs +2 -0
- package/dist/components/index.d.cts +382 -0
- package/dist/components/index.d.ts +382 -0
- package/dist/components/index.js +2 -0
- package/dist/hooks/index.cjs +1 -0
- package/dist/hooks/index.d.cts +26 -0
- package/dist/hooks/index.d.ts +26 -0
- package/dist/hooks/index.js +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +2 -0
- package/dist/types/index.cjs +1 -0
- package/dist/types/index.d.cts +155 -0
- package/dist/types/index.d.ts +155 -0
- package/dist/types/index.js +0 -0
- package/dist/utils/index.cjs +1 -0
- package/dist/utils/index.d.cts +29 -0
- package/dist/utils/index.d.ts +29 -0
- package/dist/utils/index.js +1 -0
- package/package.json +86 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { AnyMessagePart, Attachment, ChainOfThoughtStepStatus, ChatHelpers, ChatStatus, FilePart, GeneratedImage, LanguageModelUsage, Message, MessagePart, MessageRole, ReasoningPart, SourceReference, TextPart, ToolInvocation, ToolPart, ToolState, ToolUIPart, Vote } from './types/index.js';
|
|
2
|
+
export { cn, formatBytes, formatDuration, truncate } from './utils/index.js';
|
|
3
|
+
export { UseScrollToBottomOptions, UseScrollToBottomReturn, useScrollToBottom } from './hooks/index.js';
|
|
4
|
+
export { Avatar, AvatarFallback, AvatarImage, Badge, BadgeProps, Button, ButtonProps, ChainOfThought, ChainOfThoughtContent, ChainOfThoughtContentProps, ChainOfThoughtHeader, ChainOfThoughtHeaderProps, ChainOfThoughtProps, ChainOfThoughtSearchResult, ChainOfThoughtSearchResultProps, ChainOfThoughtSearchResults, ChainOfThoughtSearchResultsProps, ChainOfThoughtStep, ChainOfThoughtStepProps, ChatContainer, ChatContainerProps, ChatEmptyState, ChatEmptyStateProps, ChatInputArea, ChatInputAreaProps, ChatMessages, ChatMessagesProps, ChatScrollButton, ChatScrollButtonProps, CodeBlock, CodeBlockCopyButton, CodeBlockCopyButtonProps, CodeBlockHeader, CodeBlockHeaderProps, CodeBlockLanguage, CodeBlockLanguageProps, CodeBlockProps, Collapsible, CollapsibleContent, CollapsibleTrigger, GeoffThinking, ImageCard, ImageCardProps, ImageGrid, ImageGridProps, MessageAvatar, MessageAvatarProps, MessageContainer, MessageContainerProps, MessageContent, MessageContentProps, MessageGroup, MessageGroupProps, MessageText, MessageTextProps, MessageTimestamp, MessageTimestampProps, MusicPlayer, MusicPlayerProps, PromptInput, PromptInputButton, PromptInputButtonProps, PromptInputModelSelect, PromptInputModelSelectContent, PromptInputModelSelectContentProps, PromptInputModelSelectItem, PromptInputModelSelectItemProps, PromptInputModelSelectProps, PromptInputModelSelectTrigger, PromptInputModelSelectTriggerProps, PromptInputModelSelectValue, PromptInputModelSelectValueProps, PromptInputProps, PromptInputSubmit, PromptInputSubmitProps, PromptInputTextarea, PromptInputTextareaProps, PromptInputToolbar, PromptInputToolbarProps, PromptInputTools, PromptInputToolsProps, Reasoning, ReasoningContent, ReasoningContentProps, ReasoningProps, ReasoningTrigger, ReasoningTriggerProps, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Shimmer, ShimmerProps, Source, SourceList, SourceListProps, SourceProps, Sources, SourcesContent, SourcesContentProps, SourcesProps, SourcesTrigger, SourcesTriggerProps, Textarea, ThinkingProps, Tool, ToolContent, ToolContentProps, ToolHeader, ToolHeaderProps, ToolInput, ToolInputProps, ToolOutput, ToolOutputProps, ToolProps, badgeVariants, buttonVariants, useReasoning } from './components/index.js';
|
|
5
|
+
import 'clsx';
|
|
6
|
+
import 'class-variance-authority/types';
|
|
7
|
+
import 'react';
|
|
8
|
+
import 'class-variance-authority';
|
|
9
|
+
import '@radix-ui/react-select';
|
|
10
|
+
import '@radix-ui/react-collapsible';
|
|
11
|
+
import '@radix-ui/react-avatar';
|
|
12
|
+
import 'react/jsx-runtime';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import*as E from'react';import {memo,useEffect,createContext,useState,useRef,useCallback,useContext,Children}from'react';import {Slot}from'@radix-ui/react-slot';import {cva}from'class-variance-authority';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import*as s from'@radix-ui/react-select';import {ChevronDown,ChevronUp,Check,ArrowDownIcon,ChevronDownIcon,CheckCircleIcon,CircleDotIcon,CircleIcon,Pause,Play,Heart,SendIcon,Loader2Icon,SquareIcon,XIcon,WrenchIcon,CheckIcon,CopyIcon,BookIcon,XCircleIcon,ClockIcon}from'lucide-react';import*as _ from'@radix-ui/react-collapsible';import*as L from'@radix-ui/react-avatar';import {useControllableState}from'@radix-ui/react-use-controllable-state';function r(...e){return twMerge(clsx(e))}function ue(e){let t=Math.floor(e/60),o=Math.floor(e%60);return `${t}:${o.toString().padStart(2,"0")}`}function $o(e){if(e===0)return "0 Bytes";let t=1024,o=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(e)/Math.log(t));return `${parseFloat((e/Math.pow(t,n)).toFixed(1))} ${o[n]}`}function Uo(e,t){return e.length<=t?e:`${e.slice(0,t-3)}...`}function fe(e={}){let{threshold:t=100,smooth:o=true}=e,n=useRef(null),a=useRef(null),[p,l]=useState(true),i=useCallback(()=>{if(!n.current)return;let{scrollTop:d,scrollHeight:T,clientHeight:$}=n.current;l(d+$>=T-t);},[t]);useEffect(()=>{let d=n.current;if(d)return d.addEventListener("scroll",i),i(),()=>{d.removeEventListener("scroll",i);}},[i]);let c=useCallback((d=o?"smooth":"instant")=>{n.current&&n.current.scrollTo({top:n.current.scrollHeight,behavior:d});},[o]),v=useCallback(()=>{l(true);},[]),m=useCallback(()=>{l(false);},[]);return {containerRef:n,endRef:a,isAtBottom:p,scrollToBottom:c,onViewportEnter:v,onViewportLeave:m}}var Oe=cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),N=E.forwardRef(({className:e,variant:t,size:o,asChild:n=false,...a},p)=>jsx(n?Slot:"button",{className:r(Oe({variant:t,size:o,className:e})),ref:p,...a}));N.displayName="Button";var oe=E.forwardRef(({className:e,...t},o)=>jsx("textarea",{className:r("flex min-h-[45px] w-full rounded-md border border-input bg-background px-3 py-2 md:text-xl text-lg ring-offset-background placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:o,...t}));oe.displayName="Textarea";var ge=s.Root,Pt=s.Group,he=s.Value,re=E.forwardRef(({className:e,children:t,...o},n)=>jsxs(s.Trigger,{ref:n,className:r("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...o,children:[t,jsx(s.Icon,{asChild:true,children:jsx(ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));re.displayName=s.Trigger.displayName;var xe=E.forwardRef(({className:e,...t},o)=>jsx(s.ScrollUpButton,{ref:o,className:r("flex cursor-default items-center justify-center py-1",e),...t,children:jsx(ChevronUp,{className:"h-4 w-4"})}));xe.displayName=s.ScrollUpButton.displayName;var ve=E.forwardRef(({className:e,...t},o)=>jsx(s.ScrollDownButton,{ref:o,className:r("flex cursor-default items-center justify-center py-1",e),...t,children:jsx(ChevronDown,{className:"h-4 w-4"})}));ve.displayName=s.ScrollDownButton.displayName;var ne=E.forwardRef(({className:e,children:t,position:o="popper",...n},a)=>jsx(s.Portal,{children:jsxs(s.Content,{ref:a,className:r("data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-32 overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=closed]:animate-out data-[state=open]:animate-in",o==="popper"&&"data-[side=left]:-translate-x-1 data-[side=top]:-translate-y-1 data-[side=right]:translate-x-1 data-[side=bottom]:translate-y-1",e),position:o,...n,children:[jsx(xe,{}),jsx(s.Viewport,{className:r("p-2",o==="popper"&&"h-(--radix-select-trigger-height) w-full min-w-(--radix-select-trigger-width)"),children:t}),jsx(ve,{})]})}));ne.displayName=s.Content.displayName;var ze=E.forwardRef(({className:e,...t},o)=>jsx(s.Label,{ref:o,className:r("py-1.5 pr-2 pl-8 font-semibold text-sm",e),...t}));ze.displayName=s.Label.displayName;var ae=E.forwardRef(({className:e,children:t,...o},n)=>jsxs(s.Item,{ref:n,className:r("relative flex w-full cursor-default select-none items-center rounded-md py-1.5 pr-8 pl-3 text-sm outline-hidden transition-colors hover:bg-muted/50 focus:bg-muted data-disabled:pointer-events-none data-[state=checked]:bg-muted data-disabled:opacity-50",e),...o,children:[jsx("span",{className:"absolute right-3 flex h-4 w-4 items-center justify-center",children:jsx(s.ItemIndicator,{children:jsx(Check,{className:"h-4 w-4 text-foreground"})})}),jsx(s.ItemText,{children:t})]}));ae.displayName=s.Item.displayName;var Ve=E.forwardRef(({className:e,...t},o)=>jsx(s.Separator,{ref:o,className:r("-mx-1 my-1 h-px bg-muted",e),...t}));Ve.displayName=s.Separator.displayName;var M=_.Root,k=_.CollapsibleTrigger,B=_.CollapsibleContent;var ie=E.forwardRef(({className:e,...t},o)=>jsx(L.Root,{ref:o,className:r("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));ie.displayName=L.Root.displayName;var le=E.forwardRef(({className:e,...t},o)=>jsx(L.Image,{ref:o,className:r("aspect-square h-full w-full",e),...t}));le.displayName=L.Image.displayName;var J=E.forwardRef(({className:e,...t},o)=>jsx(J,{ref:o,className:r("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));J.displayName=L.Fallback.displayName;var Ge=cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function ye({className:e,variant:t,...o}){return jsx("div",{className:r(Ge({variant:t}),e),...o})}var Rt=memo(({children:e,className:t})=>jsx("div",{className:r("flex h-full flex-col",t),children:e}));Rt.displayName="ChatContainer";var wt=memo(({children:e,status:t,className:o,maxWidth:n="4xl",onScrollChange:a})=>{let{containerRef:p,endRef:l,isAtBottom:i,scrollToBottom:c}=fe();return useEffect(()=>{t==="submitted"&&requestAnimationFrame(()=>{c("smooth");});},[t,c]),useEffect(()=>{a?.(i);},[i,a]),jsx("div",{ref:p,className:r("-webkit-overflow-scrolling-touch flex-1 touch-pan-y overflow-y-scroll",o),style:{overflowAnchor:"none"},children:jsx("div",{className:r("mx-auto flex min-w-0 flex-col gap-4 md:gap-6",`max-w-${n}`),children:jsxs("div",{className:"flex flex-col gap-4 px-2 py-4 md:gap-6",children:[e,jsx("div",{ref:l,className:"min-h-[24px] min-w-[24px] shrink-0"})]})})})});wt.displayName="ChatMessages";var It=memo(({visible:e,onClick:t,className:o})=>e?jsx(N,{variant:"outline",size:"icon",className:r("-translate-x-1/2 absolute bottom-40 left-1/2 z-10 rounded-full border bg-background p-2 shadow-lg transition-colors hover:bg-muted",o),onClick:t,type:"button","aria-label":"Scroll to bottom",children:jsx(ArrowDownIcon,{className:"size-4"})}):null);It.displayName="ChatScrollButton";var Mt=memo(({children:e,className:t})=>jsx("div",{className:r("shrink-0 border-t bg-background p-4",t),children:e}));Mt.displayName="ChatInputArea";var kt=memo(({children:e,className:t})=>jsx("div",{className:r("flex flex-1 items-center justify-center",t),children:e}));kt.displayName="ChatEmptyState";var At=memo(({className:e,role:t="user",children:o,...n})=>jsx("div",{className:r("flex w-full gap-3",t==="user"?"flex-row-reverse":"flex-row",e),"data-role":t,...n,children:o}));At.displayName="MessageContainer";var Et=memo(({className:e,role:t="user",children:o,...n})=>jsx("div",{className:r("rounded-2xl px-4 py-3 max-w-[85%]",t==="user"?"bg-primary text-white":"bg-muted text-white",e),...n,children:o}));Et.displayName="MessageContent";var Lt=memo(({role:e="user",src:t,fallback:o,className:n})=>jsxs(ie,{className:r("size-8 shrink-0",n),children:[t&&jsx(le,{src:t,alt:e}),jsx(J,{children:o??(e==="user"?"U":"A")})]}));Lt.displayName="MessageAvatar";var Ot=memo(({className:e,children:t,...o})=>jsx("div",{className:r("prose prose-sm dark:prose-invert max-w-none",e),...o,children:t}));Ot.displayName="MessageText";var Ht=memo(({className:e,children:t,...o})=>jsx("div",{className:r("flex flex-col gap-4",e),...o,children:t}));Ht.displayName="MessageGroup";var Dt=memo(({className:e,date:t,children:o,...n})=>jsx("span",{className:r("text-xs text-muted-foreground",e),...n,children:o??t?.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}));Dt.displayName="MessageTimestamp";var Vr=({className:e,...t})=>jsx("form",{className:r("w-full overflow-hidden rounded-2xl border bg-background shadow-xs",e),...t}),Gr=({onChange:e,onKeyDown:t,className:o,placeholder:n="What would you like to know?",minHeight:a=48,maxHeight:p=164,disableAutoResize:l=false,resizeOnNewLinesOnly:i=false,...c})=>{let v=m=>{if(t?.(m),!m.defaultPrevented&&m.key==="Enter"){if(m.nativeEvent.isComposing||m.shiftKey)return;m.preventDefault();let d=m.currentTarget.form;d&&d.requestSubmit();}};return jsx(oe,{className:r("w-full resize-none rounded-none border-none p-3 shadow-none outline-hidden ring-0",l||i?"field-sizing-fixed":"field-sizing-content max-h-[6lh]","bg-transparent dark:bg-transparent","focus-visible:ring-0",o),name:"message",onChange:m=>{e?.(m);},onKeyDown:v,placeholder:n,...c})},$r=({className:e,...t})=>jsx("div",{className:r("flex items-center justify-between p-1",e),...t}),Ur=({className:e,...t})=>jsx("div",{className:r("flex items-center gap-1","[&_button:first-child]:rounded-bl-xl",e),...t}),Wr=({variant:e="ghost",className:t,size:o,...n})=>{let a=o??Children.count(n.children)>1?"default":"icon";return jsx(N,{className:r("shrink-0 gap-1.5 rounded-lg",e==="ghost"&&"text-muted-foreground",a==="default"&&"px-3",t),size:a,type:"button",variant:e,...n})},_r=({className:e,variant:t="default",size:o="icon",status:n,children:a,...p})=>{let l=jsx(SendIcon,{className:"size-4"});return n==="submitted"?l=jsx(Loader2Icon,{className:"size-4 animate-spin"}):n==="streaming"?l=jsx(SquareIcon,{className:"size-4"}):n==="error"&&(l=jsx(XIcon,{className:"size-4"})),jsx(N,{className:r("gap-1.5 rounded-lg",e),size:o,type:"submit",variant:t,...p,children:a??l})},Fr=e=>jsx(ge,{...e}),qr=({className:e,...t})=>jsx(re,{className:r("border-none bg-transparent font-medium text-muted-foreground shadow-none transition-colors","hover:bg-accent hover:text-foreground aria-expanded:bg-accent aria-expanded:text-foreground","h-auto px-2 py-1.5",e),...t}),Kr=({className:e,...t})=>jsx(ne,{className:r(e),...t}),Xr=({className:e,...t})=>jsx(ae,{className:r(e),...t}),Zr=({className:e,...t})=>jsx(he,{className:r(e),...t});var Ue=createContext(null),Jt=()=>{let e=useContext(Ue);if(!e)throw new Error("ChainOfThought components must be used within ChainOfThought");return e},Yt=memo(({className:e,open:t,defaultOpen:o=true,onOpenChange:n,children:a,...p})=>{let[l,i]=useControllableState({prop:t,defaultProp:o,onChange:n});return jsx(Ue.Provider,{value:{isOpen:l??true,setIsOpen:i},children:jsx(M,{className:r("not-prose border rounded-lg p-4",e),onOpenChange:i,open:l,...p,children:a})})}),Qt=memo(({className:e,children:t,...o})=>{let{isOpen:n}=Jt();return jsxs(k,{className:r("flex w-full items-center justify-between text-sm font-medium transition-colors hover:text-foreground",e),...o,children:[t??"Chain of Thought",jsx(ChevronDownIcon,{className:r("size-4 text-muted-foreground transition-transform",n?"rotate-180":"rotate-0")})]})}),eo=memo(({className:e,children:t,...o})=>jsx(B,{className:r("mt-4 space-y-3","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 outline-hidden data-[state=closed]:animate-out data-[state=open]:animate-in",e),...o,children:t})),to=memo(({icon:e,label:t,description:o,status:n="complete",children:a,className:p})=>{let l=n==="complete"?CheckCircleIcon:n==="active"?CircleDotIcon:CircleIcon,i=n==="complete"?"text-green-500":n==="active"?"text-blue-500":"text-muted-foreground",c=e??l;return jsxs("div",{className:r("flex gap-3",p),children:[jsx("div",{className:"flex-shrink-0 mt-0.5",children:jsx(c,{className:r("size-4",i)})}),jsxs("div",{className:"flex-1 space-y-1",children:[jsx("div",{className:"text-sm font-medium",children:t}),o&&jsx("div",{className:"text-xs text-muted-foreground",children:o}),a&&jsx("div",{className:"mt-2",children:a})]})]})}),oo=memo(({children:e,className:t})=>jsx("div",{className:r("space-y-2 mt-2",t),children:e})),ro=memo(({children:e,className:t})=>jsx("div",{className:r("text-xs bg-muted/50 rounded p-2 border",t),children:e}));Yt.displayName="ChainOfThought";Qt.displayName="ChainOfThoughtHeader";eo.displayName="ChainOfThoughtContent";to.displayName="ChainOfThoughtStep";oo.displayName="ChainOfThoughtSearchResults";ro.displayName="ChainOfThoughtSearchResult";function no({children:e,duration:t=1,active:o=true,className:n}){return o?jsx("span",{className:r("inline-block bg-clip-text text-transparent","bg-gradient-to-r from-zinc-400 via-white to-zinc-400","bg-[length:200%_100%]","animate-shimmer",n),style:{animationDuration:`${t}s`},children:e}):jsx("span",{className:n,children:e})}var z={xs:{size:30,dotRadius:2,numDots:15},sm:{size:30,dotRadius:1.5,numDots:15},lg:{size:30,dotRadius:1.5,numDots:15},xl:{size:200,dotRadius:3,numDots:100}};function ao({isActive:e,className:t="",size:o="sm",color:n="#a855f7"}){let a=useRef(null),p=useRef(null);return useEffect(()=>{if(!a.current)return;let l=z[o].numDots,i=z[o].size,c=z[o].dotRadius,v=2,m=1.5,d=Math.PI*(3-Math.sqrt(5)),T=i/2,$=T-v-c,w="http://www.w3.org/2000/svg";a.current.innerHTML="";let h=document.createElementNS(w,"svg");h.setAttribute("width",i.toString()),h.setAttribute("height",i.toString()),h.setAttribute("viewBox",`0 0 ${i} ${i}`),h.style.width="100%",h.style.height="100%",h.style.maxWidth=`${z[o].size}px`,h.style.maxHeight=`${z[o].size}px`,a.current.appendChild(h),p.current=h;for(let H=0;H<l;H++){let I=H+.5,U=I/l,X=Math.sqrt(U)*$,Z=I*d,Q=T+X*Math.cos(Z),ee=T+X*Math.sin(Z),y=document.createElementNS(w,"circle");y.setAttribute("cx",Q.toString()),y.setAttribute("cy",ee.toString()),y.setAttribute("r",c.toString()),y.style.fill=n,y.style.opacity="0.6",h.appendChild(y);let P=document.createElementNS(w,"animate");P.setAttribute("attributeName","r"),P.setAttribute("values",`${c*.5};${c*1.5};${c*.5}`),P.setAttribute("dur",`${m}s`),P.setAttribute("begin",`${U*m}s`),P.setAttribute("repeatCount","indefinite"),P.setAttribute("calcMode","spline"),P.setAttribute("keySplines","0.4 0 0.6 1;0.4 0 0.6 1"),y.appendChild(P);let b=document.createElementNS(w,"animate");b.setAttribute("attributeName","opacity"),b.setAttribute("values","0.3;1;0.3"),b.setAttribute("dur",`${m}s`),b.setAttribute("begin",`${U*m}s`),b.setAttribute("repeatCount","indefinite"),b.setAttribute("calcMode","spline"),b.setAttribute("keySplines","0.4 0 0.6 1;0.4 0 0.6 1"),y.appendChild(b);}},[o,n]),useEffect(()=>{if(!p.current)return;p.current.querySelectorAll("animate").forEach(i=>{e?i.beginElement():i.endElement();});},[e]),jsx("div",{ref:a,className:`flex items-center justify-center ${t}`,style:{width:`${z[o].size}px`,height:`${z[o].size}px`,background:"transparent"}})}var Se=memo(({base64:e,uint8Array:t,mediaType:o,className:n,alt:a="Generated image",onClick:p})=>{let l=`data:${o};base64,${e}`;return jsx("img",{src:l,alt:a,onClick:p,className:r("h-auto max-w-full overflow-hidden rounded-md",p&&"cursor-pointer hover:opacity-90 transition-opacity",n)})});Se.displayName="ImageCard";var Ke=memo(({images:e,className:t,onImageClick:o})=>jsx("div",{className:r("grid grid-cols-2 gap-2 md:grid-cols-3",t),children:e.map((n,a)=>jsx(Se,{...n,onClick:()=>o?.(n,a)},a))}));Ke.displayName="ImageGrid";var Ze=memo(({audioUrl:e,title:t="Untitled",imageUrl:o,videoUrl:n,duration:a,tags:p,likeCount:l=0,isLiked:i=false,onLike:c,showWaveform:v=false,showTitle:m=true,showPlayButton:d=true,className:T="",waveColor:$="#666666",progressColor:w="#ffffff",height:h=60,maxWidth:H="100%",onPlay:I,onPause:U,onEnded:X,onTimeUpdate:Z,onError:Q,autoPlay:ee=false})=>{let[y,P]=useState(false),[b,rt]=useState(i),[Me,ke]=useState(0),[j,nt]=useState(0),[at,Be]=useState(true),[st,it]=useState(null),W=useRef(null),ce=useRef(null);useEffect(()=>{let u=new Audio(e);return W.current=u,u.addEventListener("loadedmetadata",()=>{nt(u.duration),Be(false);}),u.addEventListener("timeupdate",()=>{ke(u.currentTime),Z?.(u.currentTime,u.duration);}),u.addEventListener("ended",()=>{P(false),X?.();}),u.addEventListener("error",me=>{let de=new Error("Failed to load audio");it(de.message),Be(false),Q?.(de);}),ee&&u.play().catch(()=>{}),()=>{u.pause(),u.src="";}},[e,ee,X,Q,Z]);let lt=useCallback(()=>{W.current&&(y?(W.current.pause(),P(false),U?.()):W.current.play().then(()=>{P(true),I?.();}).catch(u=>{console.error("Failed to play:",u);}));},[y,U,I]),pt=useCallback(u=>{if(!ce.current||!W.current)return;let me=ce.current.getBoundingClientRect(),Ae=(u.clientX-me.left)/me.width*j;W.current.currentTime=Ae,ke(Ae);},[j]),ct=useCallback(()=>{rt(!b),c?.();},[b,c]),mt=j>0?Me/j*100:0;return st?jsx("div",{className:r("rounded-lg bg-muted p-4 text-sm text-muted-foreground",T),children:"Failed to load audio"}):jsxs("div",{className:r("relative overflow-hidden rounded-xl bg-black/90",T),style:{maxWidth:H,height:h},children:[n?jsx("video",{src:n,className:"absolute inset-0 h-full w-full object-cover opacity-30",autoPlay:true,muted:true,loop:true,playsInline:true}):o?jsx("img",{src:o,alt:"",className:"absolute inset-0 h-full w-full object-cover opacity-30"}):null,jsxs("div",{className:"relative flex h-full items-center gap-3 px-3",children:[d&&jsx(N,{variant:"ghost",size:"icon",onClick:lt,disabled:at,className:"shrink-0 text-white hover:bg-white/20",children:y?jsx(Pause,{className:"size-5"}):jsx(Play,{className:"size-5"})}),jsxs("div",{className:"flex flex-1 flex-col gap-1 min-w-0",children:[m&&jsx("div",{className:"truncate text-sm font-medium text-white",children:t}),jsx("div",{ref:ce,onClick:pt,className:"h-1 w-full cursor-pointer rounded-full bg-white/20",children:jsx("div",{className:"h-full rounded-full bg-white transition-all",style:{width:`${mt}%`}})}),jsxs("div",{className:"flex justify-between text-xs text-white/60",children:[jsx("span",{children:ue(Me)}),jsx("span",{children:ue(j)})]})]}),c&&jsx(N,{variant:"ghost",size:"icon",onClick:ct,className:r("shrink-0 hover:bg-white/20",b?"text-red-500":"text-white"),children:jsx(Heart,{className:r("size-4",b&&"fill-current")})})]})]})});Ze.displayName="MusicPlayer";var En=({className:e,...t})=>jsx(M,{className:r("not-prose mb-4 w-full rounded-md border",e),...t}),bo=e=>{let t={"input-streaming":"Pending","input-available":"Running","output-available":"Completed","output-error":"Error"};return jsxs(ye,{className:"flex items-center gap-1 rounded-full text-xs",variant:"secondary",children:[{"input-streaming":jsx(CircleIcon,{className:"size-4"}),"input-available":jsx(ClockIcon,{className:"size-4 animate-pulse"}),"output-available":jsx(CheckCircleIcon,{className:"size-4 text-green-600"}),"output-error":jsx(XCircleIcon,{className:"size-4 text-red-600"})}[e],jsx("span",{children:t[e]})]})},Ln=({className:e,toolName:t,state:o,...n})=>jsxs(k,{className:r("group flex w-full min-w-0 items-center justify-between gap-2 p-3",e),...n,children:[jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[jsx(WrenchIcon,{className:"size-4 shrink-0 text-muted-foreground"}),jsx("span",{className:"truncate font-medium text-sm",children:t})]}),jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[bo(o),jsx(ChevronDownIcon,{className:"size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})]}),On=({className:e,...t})=>jsx(B,{className:r("data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-hidden data-[state=closed]:animate-out data-[state=open]:animate-in",e),...t}),Hn=({className:e,input:t,...o})=>jsxs("div",{className:r("space-y-2 overflow-hidden p-4",e),...o,children:[jsx("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:"Parameters"}),jsx("div",{className:"rounded-md bg-muted/50",children:jsx("pre",{className:"overflow-x-auto p-3 font-mono text-xs",children:JSON.stringify(t,null,2)})})]}),Dn=({className:e,output:t,errorText:o,...n})=>t||o?jsxs("div",{className:r("space-y-2 p-4",e),...n,children:[jsx("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:o?"Error":"Result"}),jsxs("div",{className:r("overflow-x-auto rounded-md text-xs [&_table]:w-full",o?"bg-destructive/10 p-3 text-destructive":"bg-muted/50 text-foreground"),children:[o&&jsx("div",{children:o}),t&&jsx("div",{children:t})]})]}):null;var et=createContext(null),No=()=>{let e=useContext(et);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},So=500,To=1e3,Ro=memo(({className:e,isStreaming:t=false,open:o,defaultOpen:n=true,onOpenChange:a,duration:p,children:l,...i})=>{let[c,v]=useControllableState({prop:o,defaultProp:n,onChange:a}),[m,d]=useControllableState({prop:p,defaultProp:0}),[T,$]=useState(false),[w,h]=useState(null);useEffect(()=>{t?w===null&&h(Date.now()):w!==null&&(d(Math.round((Date.now()-w)/To)),h(null));},[t,w,d]),useEffect(()=>{if(n&&!t&&c&&!T){let I=setTimeout(()=>{v(false),$(true);},So);return ()=>clearTimeout(I)}},[t,c,n,v,T]);let H=I=>{v(I);};return jsx(et.Provider,{value:{isStreaming:t,isOpen:c??false,setIsOpen:v,duration:m??0},children:jsx(M,{className:r("not-prose",e),onOpenChange:H,open:c,...i,children:l})})}),wo=memo(({className:e,children:t,...o})=>{let{isStreaming:n,isOpen:a,duration:p}=No();return jsx(k,{className:r("flex items-center gap-1.5 text-muted-foreground text-lg transition-colors hover:text-foreground",e),...o,children:t??jsxs(Fragment,{children:[n||p===0?jsx("p",{children:"Thinking..."}):jsxs("p",{children:["Thought for ",p,"s"]}),jsx(ChevronDownIcon,{className:r("size-3 text-muted-foreground transition-transform",a?"rotate-180":"rotate-0")})]})})}),Io=memo(({className:e,children:t,...o})=>jsx(B,{className:r("mt-2 text-muted-foreground text-xs","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 outline-hidden data-[state=closed]:animate-out data-[state=open]:animate-in",e),...o,children:jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:t})}));Ro.displayName="Reasoning";wo.displayName="ReasoningTrigger";Io.displayName="ReasoningContent";var tt=createContext({code:""}),Jn=({code:e,language:t,showLineNumbers:o=false,className:n,children:a,...p})=>{let l=e.split(`
|
|
2
|
+
`);return jsx(tt.Provider,{value:{code:e},children:jsxs("div",{className:r("relative w-full overflow-hidden rounded-md border bg-muted/50",n),...p,children:[t&&jsx("div",{className:"flex items-center justify-between border-b bg-muted/30 px-4 py-2",children:jsx("span",{className:"font-mono text-muted-foreground text-xs",children:t})}),jsxs("div",{className:"relative",children:[jsx("pre",{className:"overflow-x-auto p-4",children:jsx("code",{className:"font-mono text-sm",children:o?l.map((i,c)=>jsxs("div",{className:"flex",children:[jsx("span",{className:"mr-4 inline-block w-8 select-none text-right text-muted-foreground",children:c+1}),jsx("span",{children:i})]},c)):e})}),a&&jsx("div",{className:"absolute top-2 right-2 flex items-center gap-2",children:a})]})]})})},Yn=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:a,...p})=>{let[l,i]=useState(false),{code:c}=useContext(tt),v=async()=>{if(typeof window>"u"||!navigator.clipboard?.writeText){t?.(new Error("Clipboard API not available"));return}try{await navigator.clipboard.writeText(c),i(!0),e?.(),setTimeout(()=>i(!1),o);}catch(d){t?.(d);}},m=l?CheckIcon:CopyIcon;return jsx(N,{className:r("shrink-0",a),onClick:v,size:"icon",type:"button",variant:"ghost",...p,children:n??jsx(m,{size:14})})},Qn=({className:e,children:t,...o})=>jsx("div",{className:r("flex items-center justify-between border-b bg-muted/30 px-4 py-2",e),...o,children:t}),ea=({className:e,children:t,...o})=>jsx("span",{className:r("font-mono text-muted-foreground text-xs",e),...o,children:t});var sa=({className:e,...t})=>jsx(M,{className:r("not-prose mb-4 text-primary text-xs",e),...t}),ia=({className:e,count:t,children:o,...n})=>jsx(k,{className:r("flex items-center gap-2",e),...n,children:o??jsxs(Fragment,{children:[jsxs("p",{className:"font-medium",children:["Used ",t," sources"]}),jsx(ChevronDownIcon,{className:"size-4"})]})}),la=({className:e,...t})=>jsx(B,{className:r("mt-3 flex w-fit flex-col gap-2","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 outline-hidden data-[state=closed]:animate-out data-[state=open]:animate-in",e),...t}),Do=({href:e,title:t,children:o,className:n,...a})=>jsx("a",{className:r("flex items-center gap-2 text-muted-foreground hover:text-foreground transition-colors",n),href:e,rel:"noreferrer",target:"_blank",...a,children:o??jsxs(Fragment,{children:[jsx(BookIcon,{className:"size-4 shrink-0"}),jsx("span",{className:"block font-medium truncate",children:t})]})}),pa=({sources:e,className:t,...o})=>jsx("div",{className:r("space-y-2",t),...o,children:e.map((n,a)=>jsx(Do,{href:n.url,title:n.title},a))});export{ie as Avatar,J as AvatarFallback,le as AvatarImage,ye as Badge,N as Button,Yt as ChainOfThought,eo as ChainOfThoughtContent,Qt as ChainOfThoughtHeader,ro as ChainOfThoughtSearchResult,oo as ChainOfThoughtSearchResults,to as ChainOfThoughtStep,Rt as ChatContainer,kt as ChatEmptyState,Mt as ChatInputArea,wt as ChatMessages,It as ChatScrollButton,Jn as CodeBlock,Yn as CodeBlockCopyButton,Qn as CodeBlockHeader,ea as CodeBlockLanguage,M as Collapsible,B as CollapsibleContent,k as CollapsibleTrigger,ao as GeoffThinking,Se as ImageCard,Ke as ImageGrid,Lt as MessageAvatar,At as MessageContainer,Et as MessageContent,Ht as MessageGroup,Ot as MessageText,Dt as MessageTimestamp,Ze as MusicPlayer,Vr as PromptInput,Wr as PromptInputButton,Fr as PromptInputModelSelect,Kr as PromptInputModelSelectContent,Xr as PromptInputModelSelectItem,qr as PromptInputModelSelectTrigger,Zr as PromptInputModelSelectValue,_r as PromptInputSubmit,Gr as PromptInputTextarea,$r as PromptInputToolbar,Ur as PromptInputTools,Ro as Reasoning,Io as ReasoningContent,wo as ReasoningTrigger,ge as Select,ne as SelectContent,Pt as SelectGroup,ae as SelectItem,ze as SelectLabel,ve as SelectScrollDownButton,xe as SelectScrollUpButton,Ve as SelectSeparator,re as SelectTrigger,he as SelectValue,no as Shimmer,Do as Source,pa as SourceList,sa as Sources,la as SourcesContent,ia as SourcesTrigger,oe as Textarea,En as Tool,On as ToolContent,Ln as ToolHeader,Hn as ToolInput,Dn as ToolOutput,Ge as badgeVariants,Oe as buttonVariants,r as cn,$o as formatBytes,ue as formatDuration,Uo as truncate,No as useReasoning,fe as useScrollToBottom};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat status representing the current state of a chat session
|
|
3
|
+
* Replaces ai-sdk's ChatStatus type
|
|
4
|
+
*/
|
|
5
|
+
type ChatStatus = 'idle' | 'submitted' | 'streaming' | 'error';
|
|
6
|
+
/**
|
|
7
|
+
* Message role in a conversation
|
|
8
|
+
*/
|
|
9
|
+
type MessageRole = 'user' | 'assistant' | 'system';
|
|
10
|
+
/**
|
|
11
|
+
* Base message part interface
|
|
12
|
+
*/
|
|
13
|
+
interface MessagePart {
|
|
14
|
+
type: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Text content part
|
|
18
|
+
*/
|
|
19
|
+
interface TextPart extends MessagePart {
|
|
20
|
+
type: 'text';
|
|
21
|
+
text: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* File attachment part
|
|
25
|
+
*/
|
|
26
|
+
interface FilePart extends MessagePart {
|
|
27
|
+
type: 'file';
|
|
28
|
+
url: string;
|
|
29
|
+
name?: string;
|
|
30
|
+
mediaType?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Tool invocation part
|
|
34
|
+
*/
|
|
35
|
+
interface ToolPart extends MessagePart {
|
|
36
|
+
type: 'tool-invocation';
|
|
37
|
+
toolName: string;
|
|
38
|
+
toolCallId: string;
|
|
39
|
+
state: 'pending' | 'result' | 'error';
|
|
40
|
+
args?: Record<string, unknown>;
|
|
41
|
+
result?: unknown;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Reasoning/thinking part
|
|
45
|
+
*/
|
|
46
|
+
interface ReasoningPart extends MessagePart {
|
|
47
|
+
type: 'reasoning';
|
|
48
|
+
reasoning: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Union of all message part types
|
|
52
|
+
*/
|
|
53
|
+
type AnyMessagePart = TextPart | FilePart | ToolPart | ReasoningPart | MessagePart;
|
|
54
|
+
/**
|
|
55
|
+
* Base message interface
|
|
56
|
+
* Replaces ai-sdk's UIMessage type
|
|
57
|
+
*/
|
|
58
|
+
interface Message {
|
|
59
|
+
id: string;
|
|
60
|
+
role: MessageRole;
|
|
61
|
+
content?: string;
|
|
62
|
+
parts?: AnyMessagePart[];
|
|
63
|
+
createdAt?: Date;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Tool invocation data
|
|
67
|
+
* Replaces ai-sdk's ToolInvocation type
|
|
68
|
+
*/
|
|
69
|
+
interface ToolInvocation {
|
|
70
|
+
toolCallId: string;
|
|
71
|
+
toolName: string;
|
|
72
|
+
state: 'pending' | 'result' | 'error';
|
|
73
|
+
args?: Record<string, unknown>;
|
|
74
|
+
result?: unknown;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Generated image data
|
|
78
|
+
* Replaces ai-sdk's Experimental_GeneratedImage type
|
|
79
|
+
*/
|
|
80
|
+
interface GeneratedImage {
|
|
81
|
+
base64: string;
|
|
82
|
+
uint8Array?: Uint8Array;
|
|
83
|
+
mediaType: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Language model usage statistics
|
|
87
|
+
* Replaces ai-sdk's LanguageModelUsage type
|
|
88
|
+
*/
|
|
89
|
+
interface LanguageModelUsage {
|
|
90
|
+
promptTokens: number;
|
|
91
|
+
completionTokens: number;
|
|
92
|
+
totalTokens: number;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Chat helpers interface for controlling chat state
|
|
96
|
+
* Replaces ai-sdk's UseChatHelpers type
|
|
97
|
+
*/
|
|
98
|
+
interface ChatHelpers<T extends Message = Message> {
|
|
99
|
+
messages: T[];
|
|
100
|
+
setMessages: (messages: T[] | ((prev: T[]) => T[])) => void;
|
|
101
|
+
status: ChatStatus;
|
|
102
|
+
input?: string;
|
|
103
|
+
setInput?: (input: string) => void;
|
|
104
|
+
sendMessage?: (message: Partial<T>) => void;
|
|
105
|
+
stop?: () => void;
|
|
106
|
+
regenerate?: () => void;
|
|
107
|
+
isLoading?: boolean;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Chain of thought step status
|
|
111
|
+
*/
|
|
112
|
+
type ChainOfThoughtStepStatus = 'pending' | 'active' | 'complete';
|
|
113
|
+
/**
|
|
114
|
+
* Attachment interface for file uploads
|
|
115
|
+
*/
|
|
116
|
+
interface Attachment {
|
|
117
|
+
url: string;
|
|
118
|
+
name: string;
|
|
119
|
+
contentType: string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Vote interface for message feedback
|
|
123
|
+
*/
|
|
124
|
+
interface Vote {
|
|
125
|
+
id: string;
|
|
126
|
+
messageId: string;
|
|
127
|
+
chatId: string;
|
|
128
|
+
type: 'up' | 'down';
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Tool invocation state
|
|
132
|
+
* Replaces ai-sdk's ToolUIPart['state']
|
|
133
|
+
*/
|
|
134
|
+
type ToolState = 'input-streaming' | 'input-available' | 'output-available' | 'output-error';
|
|
135
|
+
/**
|
|
136
|
+
* Tool UI part for displaying tool invocations
|
|
137
|
+
* Replaces ai-sdk's ToolUIPart
|
|
138
|
+
*/
|
|
139
|
+
interface ToolUIPart {
|
|
140
|
+
type: string;
|
|
141
|
+
state: ToolState;
|
|
142
|
+
input?: Record<string, unknown>;
|
|
143
|
+
output?: unknown;
|
|
144
|
+
errorText?: string;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Source/citation reference
|
|
148
|
+
*/
|
|
149
|
+
interface SourceReference {
|
|
150
|
+
url: string;
|
|
151
|
+
title: string;
|
|
152
|
+
snippet?: string;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export type { AnyMessagePart, Attachment, ChainOfThoughtStepStatus, ChatHelpers, ChatStatus, FilePart, GeneratedImage, LanguageModelUsage, Message, MessagePart, MessageRole, ReasoningPart, SourceReference, TextPart, ToolInvocation, ToolPart, ToolState, ToolUIPart, Vote };
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat status representing the current state of a chat session
|
|
3
|
+
* Replaces ai-sdk's ChatStatus type
|
|
4
|
+
*/
|
|
5
|
+
type ChatStatus = 'idle' | 'submitted' | 'streaming' | 'error';
|
|
6
|
+
/**
|
|
7
|
+
* Message role in a conversation
|
|
8
|
+
*/
|
|
9
|
+
type MessageRole = 'user' | 'assistant' | 'system';
|
|
10
|
+
/**
|
|
11
|
+
* Base message part interface
|
|
12
|
+
*/
|
|
13
|
+
interface MessagePart {
|
|
14
|
+
type: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Text content part
|
|
18
|
+
*/
|
|
19
|
+
interface TextPart extends MessagePart {
|
|
20
|
+
type: 'text';
|
|
21
|
+
text: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* File attachment part
|
|
25
|
+
*/
|
|
26
|
+
interface FilePart extends MessagePart {
|
|
27
|
+
type: 'file';
|
|
28
|
+
url: string;
|
|
29
|
+
name?: string;
|
|
30
|
+
mediaType?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Tool invocation part
|
|
34
|
+
*/
|
|
35
|
+
interface ToolPart extends MessagePart {
|
|
36
|
+
type: 'tool-invocation';
|
|
37
|
+
toolName: string;
|
|
38
|
+
toolCallId: string;
|
|
39
|
+
state: 'pending' | 'result' | 'error';
|
|
40
|
+
args?: Record<string, unknown>;
|
|
41
|
+
result?: unknown;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Reasoning/thinking part
|
|
45
|
+
*/
|
|
46
|
+
interface ReasoningPart extends MessagePart {
|
|
47
|
+
type: 'reasoning';
|
|
48
|
+
reasoning: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Union of all message part types
|
|
52
|
+
*/
|
|
53
|
+
type AnyMessagePart = TextPart | FilePart | ToolPart | ReasoningPart | MessagePart;
|
|
54
|
+
/**
|
|
55
|
+
* Base message interface
|
|
56
|
+
* Replaces ai-sdk's UIMessage type
|
|
57
|
+
*/
|
|
58
|
+
interface Message {
|
|
59
|
+
id: string;
|
|
60
|
+
role: MessageRole;
|
|
61
|
+
content?: string;
|
|
62
|
+
parts?: AnyMessagePart[];
|
|
63
|
+
createdAt?: Date;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Tool invocation data
|
|
67
|
+
* Replaces ai-sdk's ToolInvocation type
|
|
68
|
+
*/
|
|
69
|
+
interface ToolInvocation {
|
|
70
|
+
toolCallId: string;
|
|
71
|
+
toolName: string;
|
|
72
|
+
state: 'pending' | 'result' | 'error';
|
|
73
|
+
args?: Record<string, unknown>;
|
|
74
|
+
result?: unknown;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Generated image data
|
|
78
|
+
* Replaces ai-sdk's Experimental_GeneratedImage type
|
|
79
|
+
*/
|
|
80
|
+
interface GeneratedImage {
|
|
81
|
+
base64: string;
|
|
82
|
+
uint8Array?: Uint8Array;
|
|
83
|
+
mediaType: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Language model usage statistics
|
|
87
|
+
* Replaces ai-sdk's LanguageModelUsage type
|
|
88
|
+
*/
|
|
89
|
+
interface LanguageModelUsage {
|
|
90
|
+
promptTokens: number;
|
|
91
|
+
completionTokens: number;
|
|
92
|
+
totalTokens: number;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Chat helpers interface for controlling chat state
|
|
96
|
+
* Replaces ai-sdk's UseChatHelpers type
|
|
97
|
+
*/
|
|
98
|
+
interface ChatHelpers<T extends Message = Message> {
|
|
99
|
+
messages: T[];
|
|
100
|
+
setMessages: (messages: T[] | ((prev: T[]) => T[])) => void;
|
|
101
|
+
status: ChatStatus;
|
|
102
|
+
input?: string;
|
|
103
|
+
setInput?: (input: string) => void;
|
|
104
|
+
sendMessage?: (message: Partial<T>) => void;
|
|
105
|
+
stop?: () => void;
|
|
106
|
+
regenerate?: () => void;
|
|
107
|
+
isLoading?: boolean;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Chain of thought step status
|
|
111
|
+
*/
|
|
112
|
+
type ChainOfThoughtStepStatus = 'pending' | 'active' | 'complete';
|
|
113
|
+
/**
|
|
114
|
+
* Attachment interface for file uploads
|
|
115
|
+
*/
|
|
116
|
+
interface Attachment {
|
|
117
|
+
url: string;
|
|
118
|
+
name: string;
|
|
119
|
+
contentType: string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Vote interface for message feedback
|
|
123
|
+
*/
|
|
124
|
+
interface Vote {
|
|
125
|
+
id: string;
|
|
126
|
+
messageId: string;
|
|
127
|
+
chatId: string;
|
|
128
|
+
type: 'up' | 'down';
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Tool invocation state
|
|
132
|
+
* Replaces ai-sdk's ToolUIPart['state']
|
|
133
|
+
*/
|
|
134
|
+
type ToolState = 'input-streaming' | 'input-available' | 'output-available' | 'output-error';
|
|
135
|
+
/**
|
|
136
|
+
* Tool UI part for displaying tool invocations
|
|
137
|
+
* Replaces ai-sdk's ToolUIPart
|
|
138
|
+
*/
|
|
139
|
+
interface ToolUIPart {
|
|
140
|
+
type: string;
|
|
141
|
+
state: ToolState;
|
|
142
|
+
input?: Record<string, unknown>;
|
|
143
|
+
output?: unknown;
|
|
144
|
+
errorText?: string;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Source/citation reference
|
|
148
|
+
*/
|
|
149
|
+
interface SourceReference {
|
|
150
|
+
url: string;
|
|
151
|
+
title: string;
|
|
152
|
+
snippet?: string;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export type { AnyMessagePart, Attachment, ChainOfThoughtStepStatus, ChatHelpers, ChatStatus, FilePart, GeneratedImage, LanguageModelUsage, Message, MessagePart, MessageRole, ReasoningPart, SourceReference, TextPart, ToolInvocation, ToolPart, ToolState, ToolUIPart, Vote };
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var clsx=require('clsx'),tailwindMerge=require('tailwind-merge');function u(...t){return tailwindMerge.twMerge(clsx.clsx(t))}function c(t){let r=Math.floor(t/60),n=Math.floor(t%60);return `${r}:${n.toString().padStart(2,"0")}`}function f(t){if(t===0)return "0 Bytes";let r=1024,n=["Bytes","KB","MB","GB"],o=Math.floor(Math.log(t)/Math.log(r));return `${parseFloat((t/Math.pow(r,o)).toFixed(1))} ${n[o]}`}function l(t,r){return t.length<=r?t:`${t.slice(0,r-3)}...`}exports.cn=u;exports.formatBytes=f;exports.formatDuration=c;exports.truncate=l;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ClassValue } from 'clsx';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Combines clsx and tailwind-merge for optimal class name handling
|
|
5
|
+
* @param inputs - Class values to merge
|
|
6
|
+
* @returns Merged class string
|
|
7
|
+
*/
|
|
8
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
9
|
+
/**
|
|
10
|
+
* Format duration in seconds to MM:SS format
|
|
11
|
+
* @param seconds - Duration in seconds
|
|
12
|
+
* @returns Formatted duration string
|
|
13
|
+
*/
|
|
14
|
+
declare function formatDuration(seconds: number): string;
|
|
15
|
+
/**
|
|
16
|
+
* Format bytes to human readable string
|
|
17
|
+
* @param bytes - Number of bytes
|
|
18
|
+
* @returns Formatted string (e.g., "1.5 MB")
|
|
19
|
+
*/
|
|
20
|
+
declare function formatBytes(bytes: number): string;
|
|
21
|
+
/**
|
|
22
|
+
* Truncate text with ellipsis
|
|
23
|
+
* @param text - Text to truncate
|
|
24
|
+
* @param maxLength - Maximum length before truncation
|
|
25
|
+
* @returns Truncated text
|
|
26
|
+
*/
|
|
27
|
+
declare function truncate(text: string, maxLength: number): string;
|
|
28
|
+
|
|
29
|
+
export { cn, formatBytes, formatDuration, truncate };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ClassValue } from 'clsx';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Combines clsx and tailwind-merge for optimal class name handling
|
|
5
|
+
* @param inputs - Class values to merge
|
|
6
|
+
* @returns Merged class string
|
|
7
|
+
*/
|
|
8
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
9
|
+
/**
|
|
10
|
+
* Format duration in seconds to MM:SS format
|
|
11
|
+
* @param seconds - Duration in seconds
|
|
12
|
+
* @returns Formatted duration string
|
|
13
|
+
*/
|
|
14
|
+
declare function formatDuration(seconds: number): string;
|
|
15
|
+
/**
|
|
16
|
+
* Format bytes to human readable string
|
|
17
|
+
* @param bytes - Number of bytes
|
|
18
|
+
* @returns Formatted string (e.g., "1.5 MB")
|
|
19
|
+
*/
|
|
20
|
+
declare function formatBytes(bytes: number): string;
|
|
21
|
+
/**
|
|
22
|
+
* Truncate text with ellipsis
|
|
23
|
+
* @param text - Text to truncate
|
|
24
|
+
* @param maxLength - Maximum length before truncation
|
|
25
|
+
* @returns Truncated text
|
|
26
|
+
*/
|
|
27
|
+
declare function truncate(text: string, maxLength: number): string;
|
|
28
|
+
|
|
29
|
+
export { cn, formatBytes, formatDuration, truncate };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {clsx}from'clsx';import {twMerge}from'tailwind-merge';function u(...t){return twMerge(clsx(t))}function c(t){let r=Math.floor(t/60),n=Math.floor(t%60);return `${r}:${n.toString().padStart(2,"0")}`}function f(t){if(t===0)return "0 Bytes";let r=1024,n=["Bytes","KB","MB","GB"],o=Math.floor(Math.log(t)/Math.log(r));return `${parseFloat((t/Math.pow(r,o)).toFixed(1))} ${n[o]}`}function l(t,r){return t.length<=r?t:`${t.slice(0,r-3)}...`}export{u as cn,f as formatBytes,c as formatDuration,l as truncate};
|
package/package.json
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@geoffai/elements",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Reusable UI components for building AI chat interfaces",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./components": {
|
|
16
|
+
"types": "./dist/components/index.d.ts",
|
|
17
|
+
"import": "./dist/components/index.js",
|
|
18
|
+
"require": "./dist/components/index.cjs"
|
|
19
|
+
},
|
|
20
|
+
"./hooks": {
|
|
21
|
+
"types": "./dist/hooks/index.d.ts",
|
|
22
|
+
"import": "./dist/hooks/index.js",
|
|
23
|
+
"require": "./dist/hooks/index.cjs"
|
|
24
|
+
},
|
|
25
|
+
"./types": {
|
|
26
|
+
"types": "./dist/types/index.d.ts",
|
|
27
|
+
"import": "./dist/types/index.js",
|
|
28
|
+
"require": "./dist/types/index.cjs"
|
|
29
|
+
},
|
|
30
|
+
"./utils": {
|
|
31
|
+
"types": "./dist/utils/index.d.ts",
|
|
32
|
+
"import": "./dist/utils/index.js",
|
|
33
|
+
"require": "./dist/utils/index.cjs"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"README.md"
|
|
39
|
+
],
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsup",
|
|
42
|
+
"dev": "tsup --watch",
|
|
43
|
+
"clean": "rm -rf dist",
|
|
44
|
+
"typecheck": "tsc --noEmit",
|
|
45
|
+
"build:prod": "NODE_ENV=production tsup",
|
|
46
|
+
"prepublishOnly": "npm run build:prod"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@radix-ui/react-avatar": "^1.1.0",
|
|
50
|
+
"@radix-ui/react-collapsible": "^1.1.0",
|
|
51
|
+
"@radix-ui/react-select": "^2.1.1",
|
|
52
|
+
"@radix-ui/react-slot": "^1.1.0",
|
|
53
|
+
"@radix-ui/react-use-controllable-state": "^1.1.0",
|
|
54
|
+
"class-variance-authority": "^0.7.0",
|
|
55
|
+
"clsx": "^2.1.1",
|
|
56
|
+
"lucide-react": "^0.460.0",
|
|
57
|
+
"tailwind-merge": "^2.5.4"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@types/react": "^19.0.0",
|
|
61
|
+
"@types/react-dom": "^19.0.0",
|
|
62
|
+
"react": "^19.0.0",
|
|
63
|
+
"react-dom": "^19.0.0",
|
|
64
|
+
"tsup": "^8.3.5",
|
|
65
|
+
"typescript": "^5.6.3"
|
|
66
|
+
},
|
|
67
|
+
"peerDependencies": {
|
|
68
|
+
"react": ">=18.0.0",
|
|
69
|
+
"react-dom": ">=18.0.0"
|
|
70
|
+
},
|
|
71
|
+
"optionalDependencies": {
|
|
72
|
+
"wavesurfer.js": "^7.8.8"
|
|
73
|
+
},
|
|
74
|
+
"keywords": [
|
|
75
|
+
"react",
|
|
76
|
+
"components",
|
|
77
|
+
"ai",
|
|
78
|
+
"chat",
|
|
79
|
+
"ui"
|
|
80
|
+
],
|
|
81
|
+
"license": "MIT",
|
|
82
|
+
"repository": {
|
|
83
|
+
"type": "git",
|
|
84
|
+
"url": "https://github.com/geoffai/metachain-v2"
|
|
85
|
+
}
|
|
86
|
+
}
|