@brainfish-ai/components 0.30.0 → 0.30.2
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/dist/esm/chunks/{ChatSearch.DNwmju2M.js → ChatSearch.C7YMDQa0.js} +3 -3
- package/dist/esm/chunks/{ChatSearch.DNwmju2M.js.map → ChatSearch.C7YMDQa0.js.map} +1 -1
- package/dist/esm/chunks/{Conversation.DmVOpOVx.js → Conversation.Biqpt5FT.js} +2 -2
- package/dist/esm/chunks/{Conversation.DmVOpOVx.js.map → Conversation.Biqpt5FT.js.map} +1 -1
- package/dist/esm/chunks/{FormattedMessage.CIbY8Io7.js → FormattedMessage.CrcIzpCM.js} +12 -12
- package/dist/esm/chunks/{FormattedMessage.CIbY8Io7.js.map → FormattedMessage.CrcIzpCM.js.map} +1 -1
- package/dist/esm/components/chat-search.js +1 -1
- package/dist/esm/components/conversation.js +1 -1
- package/dist/esm/components/convos.js +1 -1
- package/dist/esm/components/markdown.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/stats.html +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import e,{useRef as t,useLayoutEffect as n,useMemo as r,useContext as o,createContext as i,useCallback as s,useEffect as a,useState as l,Suspense as c,forwardRef as u,Component as d,createElement as f,useImperativeHandle as m}from"react";import{Tooltip as p,TooltipTrigger as g,TooltipContent as h,TooltipProvider as y}from"../components/ui/tooltip.js";import{c as v}from"./utils.C6Qu-kwd.js";import{ScrollArea as x}from"../components/ui/scroll-area.js";import{Copy as E,Browser as b,FileText as w,Folder as N,ChatsTeardrop as S,File as C,FileDoc as k,FilePdf as D,Video as R,Image as _,CircleNotch as O,X as T,Files as A,Plus as M,CaretRight as P,Stop as I,ArrowUp as F}from"@phosphor-icons/react";import{F as L}from"./FormattedMessage.
|
|
1
|
+
import e,{useRef as t,useLayoutEffect as n,useMemo as r,useContext as o,createContext as i,useCallback as s,useEffect as a,useState as l,Suspense as c,forwardRef as u,Component as d,createElement as f,useImperativeHandle as m}from"react";import{Tooltip as p,TooltipTrigger as g,TooltipContent as h,TooltipProvider as y}from"../components/ui/tooltip.js";import{c as v}from"./utils.C6Qu-kwd.js";import{ScrollArea as x}from"../components/ui/scroll-area.js";import{Copy as E,Browser as b,FileText as w,Folder as N,ChatsTeardrop as S,File as C,FileDoc as k,FilePdf as D,Video as R,Image as _,CircleNotch as O,X as T,Files as A,Plus as M,CaretRight as P,Stop as I,ArrowUp as F}from"@phosphor-icons/react";import{F as L}from"./FormattedMessage.CrcIzpCM.js";import*as j from"@radix-ui/react-dialog";import{DropdownMenu as K,DropdownMenuTrigger as z,DropdownMenuContent as B,DropdownMenuItem as $}from"../components/ui/dropdown-menu.js";import{Popover as U,PopoverTrigger as W,PopoverContent as J}from"../components/ui/popover.js";import{Command as V,CommandInput as q,CommandList as H,CommandEmpty as G,CommandGroup as Y,CommandItem as Z}from"../components/ui/command.js";import{createEditor as X,$getRoot as Q,$createParagraphNode as ee,$getSelection as te,HISTORY_MERGE_TAG as ne,$caretFromPoint as re,$isExtendableTextPointCaret as oe,$extendCaretToRange as ie,$isChildCaret as se,$isElementNode as ae,$isDecoratorNode as le,$isRootNode as ce,$getEditor as ue,$isTokenOrSegmented as de,$getCharacterOffsets as fe,$cloneWithPropertiesEphemeral as me,$isRangeSelection as pe,$findMatchingParent as ge,mergeRegister as he,DecoratorNode as ye,addClassNamesToElement as ve,shallowMergeConfig as xe,$create as Ee,defineExtension as be,safeCast as we,createState as Ne,FORMAT_TEXT_COMMAND as Se,$isNodeSelection as Ce,COMMAND_PRIORITY_LOW as ke,RootNode as De,TextNode as Re,LineBreakNode as _e,TabNode as Oe,ParagraphNode as Te,$isEditorState as Ae,createCommand as Me,CLICK_COMMAND as Pe,isDOMNode as Ie,$getNodeFromDOMNode as Fe,$createNodeSelection as Le,$setSelection as je,$getState as Ke,toggleTextFormatType as ze,TEXT_TYPE_TO_FORMAT as Be,$setState as $e,$getNodeByKey as Ue,removeClassNamesFromElement as We,CLEAR_EDITOR_COMMAND as Je,COMMAND_PRIORITY_EDITOR as Ve,KEY_TAB_COMMAND as qe,$isBlockElementNode as He,$createRangeSelection as Ge,$normalizeSelection__EXPERIMENTAL as Ye,OUTDENT_CONTENT_COMMAND as Ze,INDENT_CONTENT_COMMAND as Xe,INSERT_TAB_COMMAND as Qe,COMMAND_PRIORITY_CRITICAL as et,$isParagraphNode as tt,$isTextNode as nt,isDOMDocumentNode as rt,ArtificialNode__DO_NOT_USE as ot,$createLineBreakNode as it,$isRootOrShadowRoot as st,isBlockDomNode as at,isInlineDomNode as lt,getRegisteredNode as ct,isHTMLElement as ut,isDocumentFragment as dt,$createTabNode as ft,getDOMSelection as mt,COPY_COMMAND as pt,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as gt,$isTextPointCaret as ht,$getCaretRange as yt,$getChildCaret as vt,$parseSerializedNode as xt,isSelectionWithinEditor as Et,DELETE_CHARACTER_COMMAND as bt,DELETE_WORD_COMMAND as wt,DELETE_LINE_COMMAND as Nt,CONTROLLED_TEXT_INSERTION_COMMAND as St,REMOVE_TEXT_COMMAND as Ct,FORMAT_ELEMENT_COMMAND as kt,INSERT_LINE_BREAK_COMMAND as Dt,INSERT_PARAGRAPH_COMMAND as Rt,$insertNodes as _t,KEY_ARROW_UP_COMMAND as Ot,$getAdjacentNode as Tt,KEY_ARROW_DOWN_COMMAND as At,KEY_ARROW_LEFT_COMMAND as Mt,KEY_ARROW_RIGHT_COMMAND as Pt,KEY_BACKSPACE_COMMAND as It,KEY_DELETE_COMMAND as Ft,KEY_ENTER_COMMAND as Lt,KEY_ESCAPE_COMMAND as jt,DROP_COMMAND as Kt,$getNearestNodeFromDOMNode as zt,DRAGSTART_COMMAND as Bt,DRAGOVER_COMMAND as $t,SELECT_ALL_COMMAND as Ut,$selectAll as Wt,CUT_COMMAND as Jt,PASTE_COMMAND as Vt,isSelectionCapturedInDecoratorInput as qt,PASTE_TAG as Ht,KEY_SPACE_COMMAND as Gt,ElementNode as Yt,setNodeIndentFromDOM as Zt,$applyNodeReplacement as Xt,COMMAND_PRIORITY_HIGH as Qt}from"lexical";import{jsx as en,jsxs as tn,Fragment as nn}from"react/jsx-runtime";import{flushSync as rn,createPortal as on}from"react-dom";import{createEmptyHistoryState as sn,registerHistory as an}from"@lexical/history";import{ListNode as ln,ListItemNode as cn,registerList as un,registerListStrictIndentTransform as dn,$isListItemNode as fn}from"@lexical/list";import{LinkNode as mn,registerLink as pn,AutoLinkNode as gn}from"@lexical/link";import{registerMarkdownShortcuts as hn,TRANSFORMERS as yn,ORDERED_LIST as vn,UNORDERED_LIST as xn,LINK as En,INLINE_CODE as bn,CODE as wn,$convertToMarkdownString as Nn,$convertFromMarkdownString as Sn}from"@lexical/markdown";import{CodeNode as Cn,CodeHighlightNode as kn,$isCodeNode as Dn}from"@lexical/code";import{L as Rn}from"./logo.DtwFGMBj.js";const _n=i(null),On={onCopy:(e,t)=>{navigator.clipboard.writeText(t)}};function Tn(){const e=o(_n);if(!e)throw new Error("useConversation must be used within a <Conversation> provider");return e}function An({messages:o,callbacks:i,children:s}){const a=o.some(e=>"streaming"===e.status),l=t({...On,...i});n(()=>{l.current={...On,...i}});const c=r(()=>({onSend:(...e)=>l.current.onSend?.(...e),onStop:(...e)=>l.current.onStop?.(...e),onSuggestionClick:(...e)=>l.current.onSuggestionClick?.(...e),onActionClick:(...e)=>l.current.onActionClick?.(...e),onCitationClick:(...e)=>l.current.onCitationClick?.(...e),onAttachmentAdd:(...e)=>l.current.onAttachmentAdd?.(...e),onAttachmentRemove:(...e)=>l.current.onAttachmentRemove?.(...e),onCopy:(...e)=>l.current.onCopy?.(...e)}),[]),u=r(()=>({messages:o,callbacks:c,isStreaming:a}),[o,c,a]);/* @__PURE__ */
|
|
2
2
|
return e.createElement(_n.Provider,{value:u},s)}const Mn=({block:t,isStreaming:n})=>/* @__PURE__ */e.createElement(L,{message:{content:t.text},isStreaming:n}),Pn=({citations:t,onCitationClick:n})=>/* @__PURE__ */e.createElement("span",{className:"inline-flex flex-wrap gap-1"},t.map(t=>/* @__PURE__ */e.createElement(In,{key:t.id,citation:t,onClick:n}))),In=({citation:t,onClick:n})=>/* @__PURE__ */e.createElement(p,null,/* @__PURE__ */e.createElement(g,{asChild:!0},/* @__PURE__ */e.createElement("button",{type:"button",className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-primary/10 text-xs font-medium text-primary hover:bg-primary/20 transition-colors",onClick:()=>n?.(t)},t.index)),/* @__PURE__ */e.createElement(h,{side:"top",className:"max-w-xs"},/* @__PURE__ */e.createElement("p",{className:"text-sm font-medium"},t.title),/* @__PURE__ */e.createElement("p",{className:"text-xs text-muted-foreground truncate"},t.url))),Fn=({block:t,isStreaming:n,onCitationClick:r})=>"text"===t.type?/* @__PURE__ */e.createElement(e.Fragment,null,/* @__PURE__ */e.createElement(Mn,{block:t,isStreaming:n}),t.citations&&t.citations.length>0&&/* @__PURE__ */e.createElement(Pn,{citations:t.citations,onCitationClick:r})):null,Ln=({className:t})=>/* @__PURE__ */e.createElement("span",{className:v("text-sm font-medium animate-sweep bg-sweep-yellowfin bg-clip-text text-transparent [background-size:200%_auto]",t)},"Working..."),jn=({message:t,className:n})=>{const{callbacks:r}=Tn(),o="streaming"===t.status,i="pending"===t.status,a="completed"===t.status,l=s(()=>{const e=t.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n");r.onCopy?.(t.id,e)},[t,r]),c=t.content.some(e=>"text"===e.type&&e.text.length>0),u="error"===t.status;return i&&0===t.content.length||o&&!c?/* @__PURE__ */e.createElement(Ln,{className:n}):/* @__PURE__ */e.createElement("div",{className:v("flex gap-3 p-4 bg-surface rounded",n)},/* @__PURE__ */e.createElement("div",{className:"flex-1 min-w-0"},/* @__PURE__ */e.createElement("div",{className:"space-y-1"},u?/* @__PURE__ */e.createElement(Fn,{block:{type:"text",text:"Sorry, something went wrong. Please try again."}}):t.content.map((t,n)=>/* @__PURE__ */e.createElement(Fn,{key:n,block:t,isStreaming:o,onCitationClick:r.onCitationClick}))),a&&/* @__PURE__ */e.createElement("div",{className:"mt-3 flex items-center gap-1"},/* @__PURE__ */e.createElement(Kn,{tooltip:"Copy",onClick:l},/* @__PURE__ */e.createElement(E,{className:"h-4 w-4"})))))},Kn=({children:t,tooltip:n,active:r,onClick:o})=>/* @__PURE__ */e.createElement(p,null,/* @__PURE__ */e.createElement(g,{asChild:!0},/* @__PURE__ */e.createElement("button",{type:"button",className:v("inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",r&&"text-primary"),onClick:o},t)),/* @__PURE__ */e.createElement(h,{side:"bottom"},/* @__PURE__ */e.createElement("p",{className:"text-xs"},n))),zn={image:_,video:R,pdf:D,doc:k,file:C,channel:S,collection:N,article:w,page:b},Bn=({pill:t,onRemove:n})=>{const r=t.iconType?zn[t.iconType]:null,o=t.loading?t.progress??0:100;/* @__PURE__ */
|
|
3
3
|
return e.createElement("span",{className:"relative inline-flex items-center gap-0.5 overflow-hidden rounded-full border border-muted px-2 py-1 text-xs text-muted-foreground"},/* @__PURE__ */e.createElement("span",{className:"absolute inset-0 bg-muted transition-[width] duration-300 ease-out",style:{width:`${o}%`}}),/* @__PURE__ */e.createElement("span",{className:"relative flex items-center gap-0.5"},t.loading?/* @__PURE__ */e.createElement(O,{className:"h-3 w-3 shrink-0 mr-0.5 animate-spin"}):r&&/* @__PURE__ */e.createElement(r,{className:"h-3 w-3 shrink-0 mr-0.5"}),t.label,n&&/* @__PURE__ */e.createElement("button",{type:"button",className:"ml-0.5 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full hover:bg-muted-foreground/20",onClick:()=>n(t)},
|
|
4
4
|
/* @__PURE__ */e.createElement(T,{className:"h-2.5 w-2.5"}))))};function $n({src:t,alt:n,open:r,onClose:o}){/* @__PURE__ */
|
|
@@ -26,4 +26,4 @@ return e.createElement(Bn,{key:t.id,pill:t,onRemove:n?()=>f.onAttachmentRemove?.
|
|
|
26
26
|
/* @__PURE__ */e.createElement(M,{className:"h-4 w-4"}))),m?/* @__PURE__ */e.createElement("button",{type:"button",className:"inline-flex h-6 w-6 items-center justify-center rounded transition-colors bg-input text-primary-foreground hover:bg-input/90",onClick:ne,disabled:c},
|
|
27
27
|
/* @__PURE__ */e.createElement(I,{className:"h-4 w-4",weight:"fill"})):/* @__PURE__ */e.createElement("button",{type:"button",className:v("inline-flex h-6 w-6 items-center justify-center rounded transition-colors",p&&!X?"bg-input text-primary-foreground hover:bg-input/90":"bg-muted text-muted-foreground"),onClick:()=>te(),disabled:Q||!p},
|
|
28
28
|
/* @__PURE__ */e.createElement(F,{className:"h-4 w-4",weight:"bold"}))))))},ji=({items:t,className:n})=>{const{callbacks:r}=Tn();return 0===t.length?null:/* @__PURE__ */e.createElement("div",{className:v("flex flex-wrap justify-end gap-2 px-4 py-2",n)},t.map(t=>/* @__PURE__ */e.createElement("button",{key:t.id,type:"button",className:"rounded-full border border-border px-4 py-2 text-sm text-foreground hover:bg-muted transition-colors",onClick:()=>r.onSuggestionClick?.(t)},t.text)))},Ki=({actions:t,onActionClick:n,className:r})=>0===t.length?null:/* @__PURE__ */e.createElement("div",{className:v("flex flex-wrap gap-2 px-4 py-2",r)},t.map(t=>/* @__PURE__ */e.createElement("button",{key:t.id,type:"button",className:"inline-flex items-center gap-2 rounded-full border border-border px-4 py-2 text-sm text-foreground hover:bg-muted transition-colors",onClick:()=>n?.(t)},t.label,t.description&&/* @__PURE__ */e.createElement("span",{className:"text-muted-foreground"},t.description)))),zi=()=>/* @__PURE__ */e.createElement("div",{className:"flex items-center justify-center gap-1 text-[0.625rem] text-subtle"},/* @__PURE__ */e.createElement("span",null,"Powered by"),/* @__PURE__ */e.createElement(Rn,{variant:"full",color:"outline",className:"h-2.5 w-auto"})),Bi=Object.assign(({messages:n,callbacks:r,children:o,suggestions:i=[],actions:s=[],placeholder:c,attachments:u,collections:d,pages:f,acceptedFileTypes:m,showBranding:p=!1,className:g})=>{const h=!!o,x=t(null),[E,b]=l(0),[w,N]=l(!1);return a(()=>{const e=x.current;if(!e)return;const t=new ResizeObserver(([e])=>{e&&b(e.borderBoxSize[0]?.blockSize??e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[]),/* @__PURE__ */e.createElement(y,null,/* @__PURE__ */e.createElement(An,{messages:n,callbacks:r},/* @__PURE__ */e.createElement("div",{className:v("flex h-full flex-col pb-4",g)},h?o:/* @__PURE__ */e.createElement(e.Fragment,null,/* @__PURE__ */e.createElement("div",{className:"relative min-h-0 flex-1 grid grid-rows-[1fr] grid-cols-[1fr]"},/* @__PURE__ */e.createElement("div",{className:"row-start-1 col-start-1 min-h-0"},/* @__PURE__ */e.createElement(Zn,{bottomPadding:E,onContentBehind:N})),/* @__PURE__ */e.createElement("div",{ref:x,className:"row-start-1 col-start-1 self-end z-10 pointer-events-none px-4"},/* @__PURE__ */e.createElement("div",{className:"pointer-events-auto"},i.length>0&&/* @__PURE__ */e.createElement(ji,{items:i}),s.length>0&&/* @__PURE__ */e.createElement(Ki,{actions:s,onActionClick:e=>r.onActionClick?.(e,"")}),/* @__PURE__ */e.createElement(Li,{placeholder:c,attachments:u,collections:d,pages:f,acceptedFileTypes:m,isElevated:w})))),p&&/* @__PURE__ */e.createElement("div",{className:"relative z-10 pt-2"},/* @__PURE__ */e.createElement(zi,null))))))},{Messages:Zn,Input:Li,Suggestions:ji,Actions:Ki,Loading:Ln});export{Bn as C,Bi as a,Ki as b,Li as c,jn as d,Gn as e,Zn as f,An as g,Ln as h,ji as i,Tn as u};
|
|
29
|
-
//# sourceMappingURL=Conversation.
|
|
29
|
+
//# sourceMappingURL=Conversation.Biqpt5FT.js.map
|