@brainfish-ai/components 0.31.5 → 0.32.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/dist/chat-search.d.ts +2 -2
- package/dist/esm/chunks/{ChatSearch.DobsL73L.js → ChatSearch.DLxjq2j8.js} +4 -4
- package/dist/esm/chunks/ChatSearch.DLxjq2j8.js.map +1 -0
- package/dist/esm/components/chat-search.js +1 -1
- package/dist/esm/components/convos.js +26 -26
- package/dist/esm/components/convos.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/stats.html +1 -1
- package/package.json +1 -1
- package/dist/esm/chunks/ChatSearch.DobsL73L.js.map +0 -1
package/dist/chat-search.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ declare enum ActionType {
|
|
|
66
66
|
LaunchFreshdesk = "launch_freshdesk",
|
|
67
67
|
LaunchSupportTicketForm = "launch_support_ticket_form",
|
|
68
68
|
LaunchZendeskSunshineChat = "launch_zendesk_sunshine_chat",
|
|
69
|
-
|
|
69
|
+
LaunchWebhookHandoff = "launch_webhook_handoff"
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
declare type AddActionButtons = {
|
|
@@ -385,7 +385,7 @@ declare enum NextBestActionType {
|
|
|
385
385
|
IntercomChat = "intercom_chat",
|
|
386
386
|
Freshdesk = "freshdesk",
|
|
387
387
|
ZendeskSunshineChat = "zendesk_sunshine_chat",
|
|
388
|
-
|
|
388
|
+
WebhookHandoff = "webhook_handoff"
|
|
389
389
|
}
|
|
390
390
|
|
|
391
391
|
declare type NoArticlesFound = {
|
|
@@ -14,7 +14,7 @@ return e.createElement(zt,{block:t});default:return null}}function Sr({text:t,cl
|
|
|
14
14
|
return e.createElement(ae,{text:t,className:r})}const Pr={xs:{container:"size-12",spinner:"size-3",close:"top-0.5 right-0.5 p-0.5",closeIcon:"size-2"},sm:{container:"size-16",spinner:"size-4",close:"top-0.5 right-0.5 p-0.5",closeIcon:"size-2.5"},md:{container:"size-20",spinner:"size-5",close:"top-1 right-1 p-1",closeIcon:"size-3"}};function Tr({items:t,size:r="sm",onRemove:n,className:a}){if(0===t.length)return null;const s=Pr[r];/* @__PURE__ */
|
|
15
15
|
return e.createElement("div",{className:Z("flex gap-2 overflow-x-auto",a)},t.map(t=>/* @__PURE__ */e.createElement("div",{key:t.id,className:Z("relative group rounded-lg overflow-hidden flex-shrink-0",s.container)},/* @__PURE__ */e.createElement("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:Z(!t.url&&"pointer-events-none")},
|
|
16
16
|
/* @__PURE__ */e.createElement("img",{src:t.src,alt:t.alt||"Attachment",className:"w-full h-full object-cover"})),"uploading"===t.status&&/* @__PURE__ */e.createElement("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40"},/* @__PURE__ */e.createElement("div",{className:Z("animate-spin rounded-full border-[2.5px] border-black/30 border-t-white",s.spinner)})),n&&/* @__PURE__ */e.createElement("button",{onClick:()=>n(t.id),className:Z("absolute rounded-full opacity-0","group-hover:opacity-100 transition-opacity duration-200","hover:bg-black/70 bg-black/50",s.close)},
|
|
17
|
-
/* @__PURE__ */e.createElement(b,{className:Z("text-white",s.closeIcon),"aria-label":"Remove attachment"})))))}const Ar=d(v);function Rr({groups:t,onGroupSelect:r}){return t.length?/* @__PURE__ */e.createElement(d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"w-full px-4 py-3"},/* @__PURE__ */e.createElement("p",{className:"text-sm text-muted-foreground mb-2 text-right"},"Please select an option"),/* @__PURE__ */e.createElement("div",{className:"flex flex-wrap justify-end gap-2"},t.map((t,n)=>/* @__PURE__ */e.createElement(Ar,{key:t.id,initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:.05*n},onClick:()=>r(t),variant:"outline",className:"border-border font-normal h-auto rounded-full px-4 py-1.5 text-sm"},t.name)))):null}var jr=/* @__PURE__ */(e=>(e.CallPhone="call_phone",e.OpenUrl="open_url",e.SendEmail="send_email",e.RunCallback="run_callback",e.LaunchIntercomChat="launch_intercom_chat",e.LaunchZendeskChat="launch_zendesk_chat",e.LaunchZendeskMessenger="launch_zendesk_messenger",e.LaunchFreshdesk="launch_freshdesk",e.LaunchSupportTicketForm="launch_support_ticket_form",e.LaunchZendeskSunshineChat="launch_zendesk_sunshine_chat",e.
|
|
17
|
+
/* @__PURE__ */e.createElement(b,{className:Z("text-white",s.closeIcon),"aria-label":"Remove attachment"})))))}const Ar=d(v);function Rr({groups:t,onGroupSelect:r}){return t.length?/* @__PURE__ */e.createElement(d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"w-full px-4 py-3"},/* @__PURE__ */e.createElement("p",{className:"text-sm text-muted-foreground mb-2 text-right"},"Please select an option"),/* @__PURE__ */e.createElement("div",{className:"flex flex-wrap justify-end gap-2"},t.map((t,n)=>/* @__PURE__ */e.createElement(Ar,{key:t.id,initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:.05*n},onClick:()=>r(t),variant:"outline",className:"border-border font-normal h-auto rounded-full px-4 py-1.5 text-sm"},t.name)))):null}var jr=/* @__PURE__ */(e=>(e.CallPhone="call_phone",e.OpenUrl="open_url",e.SendEmail="send_email",e.RunCallback="run_callback",e.LaunchIntercomChat="launch_intercom_chat",e.LaunchZendeskChat="launch_zendesk_chat",e.LaunchZendeskMessenger="launch_zendesk_messenger",e.LaunchFreshdesk="launch_freshdesk",e.LaunchSupportTicketForm="launch_support_ticket_form",e.LaunchZendeskSunshineChat="launch_zendesk_sunshine_chat",e.LaunchWebhookHandoff="launch_webhook_handoff",e))(jr||{}),Or=/* @__PURE__ */(e=>(e.Link="link",e.Email="email",e.Phone="phone",e.Callback="callback",e.Function="function",e.ZendeskChat="zendesk_chat",e.ZendeskMessenger="zendesk_messenger",e.IntercomChat="intercom_chat",e.Freshdesk="freshdesk",e.ZendeskSunshineChat="zendesk_sunshine_chat",e.WebhookHandoff="webhook_handoff",e))(Or||{});const Dr=d(v),zr=()=>{window.Brainfish?.HelpWidget?.close&&window.Brainfish.HelpWidget.close()},Lr=({icon:t,label:r,index:n,onClick:a,showArrowOut:s=!1,asChild:o=!1,children:i})=>/* @__PURE__ */e.createElement(Dr,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.1*n},className:"w-full text-left h-12 text-base [&_svg]:size-6",variant:"ghost",onClick:a,asChild:o},o?i:/* @__PURE__ */e.createElement(e.Fragment,null,t&&/* @__PURE__ */e.createElement(se,{iconName:t}),/* @__PURE__ */e.createElement("span",{className:"flex-grow"},r),s&&/* @__PURE__ */e.createElement(se,{iconName:"ArrowSquareOut"}))),Fr=({href:t,icon:r,label:n,index:a,onClick:s})=>/* @__PURE__ */e.createElement(Lr,{icon:r,label:n,index:a,onClick:s,asChild:!0},/* @__PURE__ */e.createElement("a",{href:t,target:"_blank",rel:"noopener noreferrer"},r&&/* @__PURE__ */e.createElement(se,{iconName:r}),/* @__PURE__ */e.createElement("span",{className:"flex-grow"},n),/* @__PURE__ */e.createElement(se,{iconName:"ArrowSquareOut"}))),Ur=({nextBestActions:t,onActionClick:r})=>t.length?/* @__PURE__ */e.createElement(d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"w-full"},
|
|
18
18
|
/* @__PURE__ */e.createElement("div",{className:"rounded-lg overflow-hidden bg-card border divide-y divide-dark-300"},t.map((t,n)=>{const a=e=>{r(t,e)},s=`${t.label}-${n}`.replace(/\s+/g,"-");switch(t.type){case Or.Email:/* @__PURE__ */
|
|
19
19
|
return e.createElement(Fr,{key:s,href:`mailto:${t.value}`,icon:t.icon,label:t.label,index:n,onClick:()=>a()});case Or.Link:/* @__PURE__ */
|
|
20
20
|
return e.createElement(Fr,{key:s,href:L(t.value),icon:t.icon,label:t.label,index:n,onClick:()=>a()});case Or.Phone:/* @__PURE__ */
|
|
@@ -22,9 +22,9 @@ return e.createElement(Fr,{key:s,href:`tel:${t.value}`,icon:t.icon,label:t.label
|
|
|
22
22
|
return e.createElement(Lr,{key:s,icon:t.icon,label:t.label,index:n,onClick:()=>{window.zE?(zr(),window.zE("webWidget","open"),a(!0)):(console.error("Zendesk Chat is not loaded. Make sure you've included the Zendesk Chat script in your website."),a(!1))}});case Or.ZendeskMessenger:/* @__PURE__ */
|
|
23
23
|
return e.createElement(Lr,{key:s,icon:t.icon,label:t.label,index:n,onClick:()=>{window.zE?(zr(),window.zE("messenger","open"),a(!0)):(console.error("Zendesk Messenger is not loaded. Make sure you've included the Zendesk Messenger script in your website."),a(!1))}});case Or.IntercomChat:/* @__PURE__ */
|
|
24
24
|
return e.createElement(Lr,{key:s,icon:t.icon,label:t.label,index:n,onClick:()=>{window.Intercom?(zr(),window.Intercom("show"),a(!0)):(console.error("Intercom is not loaded. Make sure you've included the Intercom script in your website."),a(!1))}});case Or.Freshdesk:/* @__PURE__ */
|
|
25
|
-
return e.createElement(Lr,{key:s,icon:t.icon,label:t.label,index:n,onClick:()=>{window.fcWidget?(zr(),setTimeout(()=>{window.fcWidget.open(),window.fcWidget.show()},300),a(!0)):(console.error("Freshdesk is not loaded. Make sure you've included the Freshdesk script in your website."),a(!1))}});case Or.ZendeskSunshineChat:case Or.
|
|
25
|
+
return e.createElement(Lr,{key:s,icon:t.icon,label:t.label,index:n,onClick:()=>{window.fcWidget?(zr(),setTimeout(()=>{window.fcWidget.open(),window.fcWidget.show()},300),a(!0)):(console.error("Freshdesk is not loaded. Make sure you've included the Freshdesk script in your website."),a(!1))}});case Or.ZendeskSunshineChat:case Or.WebhookHandoff:/* @__PURE__ */
|
|
26
26
|
return e.createElement(Lr,{key:s,icon:"CalendarBlank",label:t.label,index:n,onClick:()=>a()});default:/* @__PURE__ */
|
|
27
|
-
return e.createElement(Lr,{key:s,icon:"ArrowCircleRight",label:t.label,index:n,onClick:()=>a(),showArrowOut:!0})}}))):null,Qr=({actions:r,nextBestActions:n,isLastAnswer:a,handleActionClick:s,searchQueryId:o,searchIntentId:i,question:c,answer:l})=>{const d=r&&r.length>0,u=n&&a&&n.length>0,[m]=t(d||u);if(!m)return null;let p=[];if(d&&(p=r.map(e=>{const t={...e,searchIntentId:i},r=(e=>{const t={[jr.CallPhone]:{type:Or.Phone,icon:"Phone",getValue:e=>e.action?.options?.phoneNumber||e.id,getLabel:e=>e.action?.options?.title||e.type},[jr.SendEmail]:{type:Or.Email,icon:"EnvelopeSimple",getValue:e=>e.action?.options?.to||e.id,getLabel:e=>e.action?.options?.title||e.type},[jr.OpenUrl]:{type:Or.Link,icon:"Link",getValue:e=>e.action?.options?.url||e.id,getLabel:e=>e.action?.options?.title||e.type},[jr.RunCallback]:{type:Or.Callback,icon:"Sparkle",getValue:e=>JSON.stringify({actionId:e.id,searchIntentId:e.searchIntentId}),getLabel:e=>e.action?.options?.title||"Run Action"},[jr.LaunchZendeskChat]:{type:Or.ZendeskChat,icon:"ChatCircleDots",getValue:e=>e.action?.options?.embedKey||e.id,getLabel:e=>e.action?.options?.title||"Chat with us"},[jr.LaunchZendeskMessenger]:{type:Or.ZendeskMessenger,icon:"ChatCircleDots",getValue:e=>e.action?.options?.embedKey||e.id,getLabel:e=>e.action?.options?.title||"Chat with us"},[jr.LaunchIntercomChat]:{type:Or.IntercomChat,icon:"ChatCircleDots",getValue:e=>e.action?.options?.appId||e.id,getLabel:e=>e.action?.options?.title||"Chat with us"},[jr.LaunchFreshdesk]:{type:Or.Freshdesk,icon:"ChatCircleDots",getValue:e=>e.action?.options?.token||e.id,getLabel:e=>e.action?.options?.title||"Chat with us"},[jr.LaunchSupportTicketForm]:{type:Or.Link,icon:"Notepad",getValue:e=>e.action?.options?.formUrl||e.id,getLabel:e=>e.action?.options?.title||"Submit a ticket"},[jr.LaunchZendeskSunshineChat]:{type:Or.ZendeskSunshineChat,icon:"CalendarBlank",getValue:e=>JSON.stringify({actionId:e.id,requireConfirmation:Boolean(e.action?.options?.requireConfirmation)}),getLabel:e=>e.action?.options?.title||"Speak to an expert"},[jr.
|
|
27
|
+
return e.createElement(Lr,{key:s,icon:"ArrowCircleRight",label:t.label,index:n,onClick:()=>a(),showArrowOut:!0})}}))):null,Qr=({actions:r,nextBestActions:n,isLastAnswer:a,handleActionClick:s,searchQueryId:o,searchIntentId:i,question:c,answer:l})=>{const d=r&&r.length>0,u=n&&a&&n.length>0,[m]=t(d||u);if(!m)return null;let p=[];if(d&&(p=r.map(e=>{const t={...e,searchIntentId:i},r=(e=>{const t={[jr.CallPhone]:{type:Or.Phone,icon:"Phone",getValue:e=>e.action?.options?.phoneNumber||e.id,getLabel:e=>e.action?.options?.title||e.type},[jr.SendEmail]:{type:Or.Email,icon:"EnvelopeSimple",getValue:e=>e.action?.options?.to||e.id,getLabel:e=>e.action?.options?.title||e.type},[jr.OpenUrl]:{type:Or.Link,icon:"Link",getValue:e=>e.action?.options?.url||e.id,getLabel:e=>e.action?.options?.title||e.type},[jr.RunCallback]:{type:Or.Callback,icon:"Sparkle",getValue:e=>JSON.stringify({actionId:e.id,searchIntentId:e.searchIntentId}),getLabel:e=>e.action?.options?.title||"Run Action"},[jr.LaunchZendeskChat]:{type:Or.ZendeskChat,icon:"ChatCircleDots",getValue:e=>e.action?.options?.embedKey||e.id,getLabel:e=>e.action?.options?.title||"Chat with us"},[jr.LaunchZendeskMessenger]:{type:Or.ZendeskMessenger,icon:"ChatCircleDots",getValue:e=>e.action?.options?.embedKey||e.id,getLabel:e=>e.action?.options?.title||"Chat with us"},[jr.LaunchIntercomChat]:{type:Or.IntercomChat,icon:"ChatCircleDots",getValue:e=>e.action?.options?.appId||e.id,getLabel:e=>e.action?.options?.title||"Chat with us"},[jr.LaunchFreshdesk]:{type:Or.Freshdesk,icon:"ChatCircleDots",getValue:e=>e.action?.options?.token||e.id,getLabel:e=>e.action?.options?.title||"Chat with us"},[jr.LaunchSupportTicketForm]:{type:Or.Link,icon:"Notepad",getValue:e=>e.action?.options?.formUrl||e.id,getLabel:e=>e.action?.options?.title||"Submit a ticket"},[jr.LaunchZendeskSunshineChat]:{type:Or.ZendeskSunshineChat,icon:"CalendarBlank",getValue:e=>JSON.stringify({actionId:e.id,requireConfirmation:Boolean(e.action?.options?.requireConfirmation)}),getLabel:e=>e.action?.options?.title||"Speak to an expert"},[jr.LaunchWebhookHandoff]:{type:Or.WebhookHandoff,icon:"CalendarBlank",getValue:e=>JSON.stringify({actionId:e.id,requireConfirmation:Boolean(e.action?.options?.requireConfirmation)}),getLabel:e=>e.action?.options?.title||"Talk to a human"}},r=t[e.type]||{type:Or.Link,icon:"Link",getValue:e=>e.action?.options?.url||e.id,getLabel:e=>e.action?.options?.title||e.type};return r})(t);return{id:e.id,label:r.getLabel(t),type:r.type,icon:r.icon,value:r.getValue(t)}})),u){const e=n.filter(e=>!p.some(t=>t.type===e.type));p=p.concat(e)}/* @__PURE__ */
|
|
28
28
|
return e.createElement("div",{className:"p-4"},/* @__PURE__ */e.createElement(Ur,{nextBestActions:p,onActionClick:(e,t)=>{e&&s?.({action:e,searchQueryId:o||"",query:c,answer:l,success:t})}}))};function Mr({index:r,blocks:n=[],question:a,searchResults:s,state:o="completed",searchQueryId:i,searchIntentId:c,hideCitations:l=!1,feedback:d,onFeedback:u,disableFeedback:m=!1,textConfig:p={},redirectRules:w,attachments:b=[],actions:k,handleActionClick:N,nextBestActions:C,isLastAnswer:I,onFeedbackReasonSubmit:S,hasError:P=!1,knowledgeSourceGroups:T,onKnowledgeGroupSelect:A,statusMessage:R}){const[j,O]=t(!1),[D,z]=t(!1),F=Qt(n),U="awaiting-knowledge-group"===o,Q=("fetching-search-results"===o||"fetching-stream"===o)&&(1===n.length||Boolean(R)),M="fetching-search-results"===o,V="completed"===o,q=P&&V,K=R??p.loadingAnswerText,B=M?p.loadingSearchText:K,H=Q&&Boolean(R);/* @__PURE__ */
|
|
29
29
|
return e.createElement("div",{className:"rounded-lg relative mx-auto overflow-hidden bg-card border border-primary","data-name":"SearchResults","data-index":r},
|
|
30
30
|
/* @__PURE__ */e.createElement("div",{className:"px-4 pt-4 pb-2"},/* @__PURE__ */e.createElement("div",{className:"flex items-start justify-between gap-2 min-h-9"},/* @__PURE__ */e.createElement("h2",{className:"leading-normal font-semibold m-0 text-foreground self-center text-lg"},a),V&&!q&&/* @__PURE__ */e.createElement(h,null,/* @__PURE__ */e.createElement(f,null,/* @__PURE__ */e.createElement(g,{asChild:!0},/* @__PURE__ */e.createElement(v,{variant:"ghost",size:"icon",onClick:()=>{(async()=>{try{await navigator.clipboard.writeText(F)}catch(e){console.warn("Clipboard API failed, using fallback:",e);const r=document.createElement("textarea");r.value=F,r.style.position="fixed",r.style.opacity="0",document.body.appendChild(r),r.focus(),r.select();try{document.execCommand("copy")}catch(t){console.error("Fallback: Oops, unable to copy",t)}document.body.removeChild(r)}O(!0),setTimeout(()=>O(!1),2e3)})()},className:"-mt-1 flex-shrink-0"},j?/* @__PURE__ */e.createElement(E,{className:"text-feedback-positive",weight:"bold"}):/* @__PURE__ */e.createElement($,{className:"text-secondary-foreground",weight:"bold"}))),/* @__PURE__ */e.createElement(y,null,/* @__PURE__ */e.createElement("p",null,j?"Copied!":"Copy"))))),/* @__PURE__ */e.createElement(Tr,{items:b.map((e,t)=>({id:`${t}`,src:e.url,url:e.url,alt:e.filename})),size:"xs",className:"mt-2"})),Q&&/* @__PURE__ */e.createElement("div",{className:"px-4 pt-0 pb-2"},/* @__PURE__ */e.createElement(Sr,{text:B??""})),U&&T&&A?/* @__PURE__ */e.createElement(Rr,{groups:T,onGroupSelect:A}):/* @__PURE__ */e.createElement("div",{className:"flex flex-col"},!H&&n?.map((t,r)=>/* @__PURE__ */e.createElement("div",{key:r,className:Z("px-4 pt-0 pb-2 border-b last:border-b-0 border-dashed",q&&"text-muted-foreground")},
|
|
@@ -93,4 +93,4 @@ return e.createElement(d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},t
|
|
|
93
93
|
/* @__PURE__ */e.createElement("div",{ref:dt})),fe&&tt&&!wt&&!W&&!ht&&(()=>{const t=oe.some(e=>"awaiting-knowledge-group"===e.state);/* @__PURE__ */
|
|
94
94
|
return e.createElement(Wr,{ref:lt,initialQuery:de,onQueryChange:ue,isSearching:me,handleFollowUpSearch:Ut,textConfig:ze,enableFileAttachment:Fe,attachedFiles:Ke,isUploading:Be,onAddFiles:He,onRemoveFile:Ge,disabled:t})})(),fe&&wt&&!W&&!ht&&/* @__PURE__ */e.createElement(un,{onStartNewConversation:()=>Lt()}),!ht&&W)});gn.displayName="ChatSearch";const yn=c(({featureFlags:t,...r},n)=>/* @__PURE__ */e.createElement(fe,{flags:t},/* @__PURE__ */e.createElement(kr,{searchPath:r.searchPath,contentTypeEndpoint:r.contentTypeEndpoint,widgetKey:r.apiKey},
|
|
95
95
|
/* @__PURE__ */e.createElement(gn,{...r,ref:n}))));yn.displayName="ChatSearch";export{yn as C,un as R,kr as a,Jr as b,Nr as u};
|
|
96
|
-
//# sourceMappingURL=ChatSearch.
|
|
96
|
+
//# sourceMappingURL=ChatSearch.DLxjq2j8.js.map
|