@webority/chat-react 0.111.0 → 0.113.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 CHANGED
@@ -280,10 +280,10 @@ const parts = splitCitations(reply.text, (inner) => sources.has(inner));
280
280
 
281
281
  ## Replies
282
282
 
283
- `<ChatMarkdown text resolveLink linkComponent />` renders a reply from a small, safe subset of
284
- Markdown: paragraphs, bold, italics, inline code, bullet and numbered lists, simple tables,
285
- headings (as bold lines) and code blocks. It never renders HTML: every character reaches the page
286
- as text. Text still arriving updates the last block in place, and an unclosed `**` shows as typed
283
+ `<ChatMarkdown text resolveLink linkComponent />` draws a reply through `AppMarkdown` from
284
+ `@webority/ui-react`, with the chat link and heading rules: paragraphs, bold, italics, inline code,
285
+ bullet and numbered lists, tables, headings (as bold lines) and code blocks. It never renders HTML:
286
+ every character reaches the page as text. Text still arriving updates the last block in place, and an unclosed `**` shows as typed
287
287
  until its partner arrives.
288
288
 
289
289
  A link shows only when its href has the form `scheme:kind/id` (for example `ticket:support/3f2a`)
@@ -1 +1 @@
1
- import{ChatApiError as e,DEFAULT_CHAT_LABELS as t,createChatClient as n,createSseParser as r,linkRoute as i,mergeLabels as a,parseBlocks as o,parseInline as s}from"@webority/ui-elements/chat-core";import{AppActionIcon as c,AppAlert as l,AppButton as u,AppCard as d,AppChip as f,AppConfirmDialog as p,AppDataTable as m,AppDrawer as h,AppEmptyState as g,AppIcon as _,AppLink as v,AppSkeleton as y,AppSpinner as b,AppTextarea as x,useFloatingStack as S}from"@webority/ui-react";import{Fragment as C,memo as w,startTransition as T,useCallback as E,useEffect as D,useId as O,useMemo as k,useRef as A,useState as j}from"react";import{Fragment as M,jsx as N,jsxs as P}from"react/jsx-runtime";import{formatDateTime as F}from"@webority/ui-elements/helpers";import{createPortal as I}from"react-dom";function L(e,t){return e.kind===`Reply`?t.actionReply(e.ticketNumber):e.kind===`Reopen`?t.actionReopen(e.ticketNumber):t.actionRaiseTicket}function R(e,t,n){return e===`Reply`?n.actionDoneReply(t):e===`Reopen`?n.actionDoneReopen(t):n.actionDoneRaiseTicket(t)}function z({action:e,confirmAction:t,onViewTicket:n,labels:r}){let i=a(r),[o,s]=j(`ready`),[c,f]=j(null),[p,m]=j(``);if(o===`dismissed`)return N(`p`,{className:`wui-text-sm text-body-secondary mb-0`,children:i.actionDismissed});if(o===`done`)return N(l,{variant:`success`,role:`status`,size:`sm`,action:n?N(u,{size:`sm`,variant:`ghost`,onClick:()=>n(c),children:i.viewTicket}):void 0,children:R(e.kind,c.number,i)});async function h(){s(`sending`),m(``);try{f(await t(e.token)),s(`done`)}catch(e){m(e?.message||i.actionFailed),s(`ready`)}}let g=o===`sending`,_=new Date(e.expiresDateTimeUtc).getTime()<=Date.now(),v=e.kind===`RaiseTicket`?[e.category,e.subject].filter(Boolean).join(` · `):``;return N(d,{padding:`sm`,className:`border`,title:L(e,i),subtitle:v||void 0,children:P(`div`,{className:`d-flex flex-column gap-2`,children:[e.kind!==`Reopen`&&e.body&&N(`p`,{className:`wui-text-sm mb-0`,style:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`},children:e.body}),_?N(`p`,{className:`wui-text-sm text-body-secondary mb-0`,children:i.actionExpired}):P(M,{children:[N(`p`,{className:`wui-text-xs text-body-secondary mb-0`,children:i.actionNote}),p&&N(l,{size:`sm`,variant:`danger`,children:p}),P(`div`,{className:`d-flex flex-wrap gap-2`,children:[N(u,{size:`sm`,loading:g,onClick:h,children:i.actionConfirm}),N(u,{size:`sm`,variant:`secondary`,disabled:g,onClick:()=>s(`dismissed`),children:i.actionDismiss})]})]})]})})}function B({onSubmit:e,busy:t=!1,disabled:n=!1,maxLength:r=4e3,inputRef:i,labels:o}){let s=a(o),c=O(),[l,d]=j(``),f=t||n||!l.trim();function p(){f||(e(l.trim()),d(``))}return P(`form`,{className:`wui-chat-composer d-flex align-items-end gap-2`,"aria-label":s.composer,onSubmit:e=>{e.preventDefault(),p()},children:[N(x,{id:`${c}-message`,"aria-label":s.composer,"aria-describedby":`${c}-hint`,placeholder:s.placeholder,rows:1,autoGrow:!0,maxLength:r,value:l,disabled:n,ref:i,fieldClassName:`flex-grow-1 mb-0`,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),p())}}),N(`span`,{id:`${c}-hint`,className:`visually-hidden`,children:s.composerHint}),N(u,{type:`submit`,leftIcon:`send`,disabled:f,children:N(`span`,{className:`visually-hidden`,children:s.send})})]})}function V({client:e,onOpen:t,onDeleted:n,pageSize:r=20,labels:i}){let o=a(i),[s,f]=j([]),[m,h]=j(!0),[_,v]=j(``),[b,x]=j(!1),[S,C]=j(0),[w,T]=j(null),[O,k]=j(!1),[A,M]=j(``),I=E(async t=>{h(!0),v(``);try{let n=await e.listConversations({skip:t,take:r});f(e=>t===0?n:[...e,...n]),x(n.length===r)}catch(e){v(e?.message||o.loadFailed)}finally{h(!1)}},[e,r,o.loadFailed]);D(()=>{I(0)},[I,S]);async function L(){k(!0),M(``);try{await e.deleteConversation(w.publicId),f(e=>e.filter(e=>e.publicId!==w.publicId)),n?.(w.publicId),T(null)}catch(e){M(e?.message||o.deleteFailed)}finally{k(!1)}}return!m&&!_&&s.length===0?N(g,{icon:`chat`,size:`sm`,title:o.conversationsEmptyTitle,text:o.conversationsEmptyText}):P(`div`,{className:`d-flex flex-column gap-3`,children:[_&&N(l,{variant:`danger`,action:N(u,{size:`sm`,variant:`secondary`,onClick:()=>C(e=>e+1),children:o.retry}),children:_}),s.length>0&&N(`ul`,{className:`list-unstyled d-flex flex-column gap-2 mb-0`,"aria-label":o.conversations,children:s.map(e=>N(`li`,{children:P(d,{padding:`sm`,className:`border`,bodyClassName:`d-flex align-items-center gap-2`,children:[N(u,{variant:`ghost`,className:`flex-grow-1 text-start`,style:{minWidth:0},onClick:()=>t(e),children:P(`span`,{className:`d-flex flex-column`,style:{minWidth:0},children:[N(`span`,{className:`text-truncate fw-semibold`,children:e.title||o.untitled}),N(`time`,{dateTime:e.lastMessageDateTimeUtc,className:`wui-text-xs text-body-secondary`,children:F(e.lastMessageDateTimeUtc)})]})}),N(c,{icon:`trash-2`,danger:!0,label:o.deleteConversation,onClick:()=>{M(``),T(e)}})]})},e.publicId))}),m&&P(`div`,{className:`d-flex flex-column gap-2`,"aria-hidden":`true`,children:[N(y,{height:44}),N(y,{height:44}),N(y,{height:44})]}),!m&&b&&N(u,{variant:`secondary`,className:`align-self-center`,onClick:()=>I(s.length),children:o.loadMore}),N(p,{open:w!==null,title:o.deleteConfirmTitle,message:A?N(l,{variant:`danger`,children:A}):o.deleteConfirmMessage,confirmLabel:o.deleteConfirm,cancelLabel:o.cancel,danger:!0,loading:O,onConfirm:L,onClose:()=>{O||T(null)}})]})}var H={zIndex:`var(--wui-z-fixed)`,bottom:`var(--wui-consent-banner-block, 0px)`},U={end:{insetInlineEnd:0},start:{insetInlineStart:0}};function W({onClick:e,open:t=!1,position:n=`end`,icon:r=`sparkles`,compact:i=!1,className:o,style:s,labels:c}){let l=a(c);return i?N(G,{onClick:e,open:t,position:n,icon:r,className:o,style:s,label:l.launcher}):N(`span`,{"data-support-capture":`exclude`,className:[`position-fixed m-3`,o].filter(Boolean).join(` `),style:{...H,...U[n],...s},children:N(u,{leftIcon:r,className:`rounded-pill`,onClick:e,"aria-haspopup":`dialog`,"aria-expanded":t,children:l.launcher})})}function G({onClick:e,open:t,position:n,icon:r,className:i,style:a,label:o}){let s=S(n);return s?I(N(`span`,{className:[`wui-floating-stack-item wui-floating-stack-item--primary`,i].filter(Boolean).join(` `),style:a,children:N(u,{className:`wui-floating-btn`,onClick:e,"aria-label":o,"aria-haspopup":`dialog`,"aria-expanded":t,tooltip:o,tooltipPlacement:n===`start`?`end`:`start`,children:N(_,{name:r,size:24})})}),s):null}function K({tokens:e,resolveLink:t,linkComponent:n}){return e.map(e=>{switch(e.type){case`code`:return N(`code`,{children:e.text},e.key);case`strong`:return N(`strong`,{children:N(K,{tokens:e.children,resolveLink:t,linkComponent:n})},e.key);case`em`:return N(`em`,{children:N(K,{tokens:e.children,resolveLink:t,linkComponent:n})},e.key);case`link`:{let r=N(K,{tokens:e.children,resolveLink:t,linkComponent:n}),a=i(e.href,t);return a?N(v,{href:a,linkComponent:n,animation:`static`,children:r},e.key):N(`span`,{children:r},e.key)}default:return N(C,{children:e.text},e.key)}})}function q({text:e,resolveLink:t,linkComponent:n}){return N(K,{tokens:s(e),resolveLink:t,linkComponent:n})}function J({block:e,resolveLink:t,linkComponent:n}){let r=e=>N(q,{text:e,resolveLink:t,linkComponent:n}),i=k(()=>e.type===`table`?{columns:e.header.map((e,r)=>({key:`c${r}`,label:N(q,{text:e,resolveLink:t,linkComponent:n}),render:e=>N(q,{text:e.cells[r]??``,resolveLink:t,linkComponent:n})})),rows:e.rows.map((e,t)=>({id:t,cells:e}))}:null,[e,t,n]);switch(e.type){case`heading`:return N(`p`,{className:`fw-semibold mb-2`,children:r(e.text)});case`rule`:return N(`hr`,{className:`my-2`});case`code`:return N(`pre`,{className:`wui-text-sm mb-2`,children:N(`code`,{children:e.text})});case`list`:{let t=e.items.map((e,t)=>N(`li`,{children:r(e)},t));return e.ordered?N(`ol`,{className:`mb-2 ps-4`,start:e.start===1?void 0:e.start,children:t}):N(`ul`,{className:`mb-2 ps-4`,children:t})}case`table`:return N(m,{columns:i.columns,rows:i.rows,density:`compact`,empty:null,wrapperClassName:`mb-2`});default:return N(`p`,{className:`mb-2`,children:e.lines.map((e,t)=>P(`span`,{children:[t>0&&N(`br`,{}),r(e)]},t))})}}function Y({text:e,resolveLink:t,linkComponent:n,className:r}){let i=k(()=>o(e),[e]);return N(`div`,{className:[`wui-text-sm text-break`,r].filter(Boolean).join(` `),children:i.map(e=>N(J,{block:e,resolveLink:t,linkComponent:n},e.key))})}function X({rating:e,onRate:t,noteMaxLength:n=1e3,labels:r}){let i=a(r),o=O(),[s,c]=j(!1),[d,f]=j(!1),[p,m]=j(``),[h,g]=j(``),[_,v]=j(!1);async function y(e,n){c(!0),g(``);try{await t(e,n),f(e===`Down`&&n===void 0),v(e===`Up`||n!==void 0),n!==void 0&&m(``)}catch{g(i.ratingFailed)}finally{c(!1)}}return P(`div`,{className:`d-flex flex-column gap-2`,children:[P(`div`,{className:`d-flex flex-wrap align-items-center gap-1`,children:[N(u,{size:`sm`,variant:e===`Up`?`neutral`:`ghost`,leftIcon:`check`,"aria-pressed":e===`Up`,disabled:s,onClick:()=>y(`Up`),children:i.rateUp}),N(u,{size:`sm`,variant:e===`Down`?`neutral`:`ghost`,leftIcon:`x`,"aria-pressed":e===`Down`,disabled:s,onClick:()=>y(`Down`),children:i.rateDown}),_&&!d&&N(`span`,{className:`wui-text-xs text-body-secondary`,role:`status`,children:i.rated})]}),h&&N(l,{size:`sm`,variant:`danger`,children:h}),d&&P(`form`,{className:`d-flex flex-column gap-2`,onSubmit:e=>{e.preventDefault(),y(`Down`,p)},children:[N(x,{id:`${o}-note`,label:i.ratingNote,hint:i.ratingNoteHint,rows:2,maxLength:n,value:p,onChange:e=>m(e.target.value)}),P(`div`,{className:`d-flex gap-2`,children:[N(u,{type:`submit`,size:`sm`,loading:s,children:i.ratingNoteSend}),N(u,{size:`sm`,variant:`secondary`,disabled:s,onClick:()=>{f(!1),v(!0)},children:i.ratingNoteSkip})]})]})]})}var ee={maxWidth:`85%`,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`};function te({turn:e,onRate:t,resolveLink:n,linkComponent:r,confirmAction:i,onViewTicket:o,renderReply:s,labels:c}){let u=a(c),f=e.streaming&&!e.answer;return P(`li`,{className:`d-flex flex-column gap-2`,children:[e.question&&P(`div`,{className:`align-self-end`,style:ee,children:[P(`span`,{className:`visually-hidden`,children:[u.you,`: `]}),N(d,{padding:`sm`,variant:`muted`,className:`wui-text-sm`,children:e.question})]}),P(`div`,{className:`d-flex flex-column gap-2`,style:{minWidth:0},children:[P(`span`,{className:`visually-hidden`,children:[u.assistant,`: `]}),N(`div`,{"aria-live":`polite`,"aria-busy":e.streaming,children:f?P(`span`,{className:`d-inline-flex align-items-center gap-2 wui-text-sm text-body-secondary`,children:[N(b,{size:`sm`,label:u.thinking}),N(`span`,{"aria-hidden":`true`,children:u.thinking})]}):e.answer&&(s?s(e,{streaming:!!e.streaming}):N(Y,{text:e.answer,resolveLink:n,linkComponent:r}))}),e.error&&N(l,{size:`sm`,variant:`danger`,children:e.error.message}),i&&!e.streaming&&e.actions.map(e=>N(z,{action:e,confirmAction:i,onViewTicket:o,labels:c},e.token)),t&&e.messageId&&!e.streaming&&N(X,{rating:e.rating,onRate:(n,r)=>t(e.id,n,r),labels:c})]})]})}var Z=w(te);function ne(e){for(let t=e?.parentElement;t&&t!==document.body;t=t.parentElement){let{overflowY:e}=getComputedStyle(t);if((e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight)return t}return null}function Q({turns:e,empty:t,onRate:n,resolveLink:r,linkComponent:i,confirmAction:o,onViewTicket:s,renderReply:c,labels:l}){let u=a(l),d=A(null),f=e[e.length-1];return D(()=>{let e=ne(d.current);e&&(e.scrollTop=e.scrollHeight)},[e.length,f?.answer,f?.error,f?.actions]),e.length===0?t??N(g,{icon:`sparkles`,size:`sm`,title:u.emptyTitle,text:u.emptyText}):P(M,{children:[N(`ol`,{className:`list-unstyled d-flex flex-column gap-3 mb-0`,"aria-label":u.thread,children:e.map(e=>N(Z,{turn:e,onRate:n,resolveLink:r,linkComponent:i,confirmAction:o,onViewTicket:s,renderReply:c,labels:l},e.id))}),N(`div`,{ref:d})]})}function re({chat:e,open:t,onClose:n,title:r,titleIcon:i=`sparkles`,headerActions:o,empty:s,disclaimer:u,maxLength:d=4e3,allowanceThreshold:f=10,width:p=`440px`,resolveLink:m,linkComponent:g,confirmAction:v,onViewTicket:y,rating:x=!0,renderReply:S,labels:C}){let w=a(C),T=A(null),{refreshAllowance:E}=e;D(()=>{t&&E().catch(()=>{})},[t,E]);let O=e.messagesLeftToday,k=r??w.panelTitle;return N(h,{open:t,onClose:n,sheet:!1,width:p,header:P(`div`,{className:`drawer-header`,children:[P(`div`,{className:`drawer-title`,children:[i&&N(`span`,{className:`drawer-title-ic`,children:N(_,{name:i,size:18})}),k]}),P(`div`,{className:`d-flex align-items-center gap-1`,children:[o,N(c,{icon:`plus`,label:w.newChat,onClick:e.newConversation,disabled:e.turns.length===0&&!e.loading}),N(c,{icon:`x`,label:w.close,onClick:n})]})]}),footer:P(`div`,{className:`d-flex flex-column gap-2`,children:[O!==null&&O<=f&&N(`p`,{className:`wui-text-xs text-body-secondary mb-0`,role:`status`,children:w.allowance(O)}),N(B,{onSubmit:e.submit,busy:e.streaming||e.loading,disabled:O===0,maxLength:d,inputRef:T,labels:C}),N(`p`,{className:`wui-text-xs text-body-secondary mb-0`,children:u??w.disclaimer})]}),ariaLabel:typeof k==`string`?k:w.panelTitle,onOpened:()=>T.current?.focus(),children:e.loading?N(`div`,{className:`d-flex justify-content-center py-4`,children:N(b,{label:w.loadingConversation})}):e.loadError?N(l,{variant:`danger`,children:e.loadError.message}):N(Q,{turns:e.turns,empty:s,onRate:x?e.rate:void 0,resolveLink:m,linkComponent:g,confirmAction:v,onViewTicket:y,renderReply:S,labels:C})})}var ie=/\[([^[\]]*)\](?!\()/g;function ae(e,t){let n=[],r=0;for(let i of e.matchAll(ie)){let a=i[1];a===``||!t(a)||(i.index>r&&n.push({text:e.slice(r,i.index)}),n.push({citation:a}),r=i.index+i[0].length)}return r<e.length&&n.push({text:e.slice(r)}),n}function oe({citation:e,label:t,ariaLabel:n,onOpen:r}){return N(f,{label:t??e,size:`sm`,tone:`primary`,variant:`outline`,leadingIcon:`book-1`,"aria-label":n??e,onClick:()=>r(e)})}function se({title:e,subtitle:t,lines:n,note:r,onConfirm:i,labels:o}){let s=a(o),[c,f]=j(`ready`),[p,m]=j(null),[h,g]=j(``);if(c===`dismissed`)return N(`p`,{className:`wui-text-sm text-body-secondary mb-0`,children:s.actionDismissed});if(c===`done`)return N(l,{variant:`success`,role:`status`,size:`sm`,children:p?.message||s.actionDone});async function _(){f(`sending`),g(``);try{let e=await i();m(e??null),f(`done`)}catch(e){g(e?.message||s.actionFailed),f(`ready`)}}let v=c===`sending`;return N(d,{padding:`sm`,className:`border`,title:e,subtitle:t||void 0,children:P(`div`,{className:`d-flex flex-column gap-2`,children:[(n??[]).map((e,t)=>N(`p`,{className:`wui-text-sm mb-0`,style:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`},children:e},t)),N(`p`,{className:`wui-text-xs text-body-secondary mb-0`,children:r??s.actionNote}),h&&N(l,{size:`sm`,variant:`danger`,children:h}),P(`div`,{className:`d-flex flex-wrap gap-2`,children:[N(u,{size:`sm`,loading:v,onClick:_,children:s.actionConfirm}),N(u,{size:`sm`,variant:`secondary`,disabled:v,onClick:()=>f(`dismissed`),children:s.actionDismiss})]})]})})}function $(e){return{code:e?.code||`unknown`,message:e?.message||`Something went wrong. Please try again.`,resetsAtUtc:e?.resetsAtUtc??null}}function ce(e){if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}function le(e){let t=[];for(let n of e??[]){if(n.role===`User`){t.push({id:n.publicId,question:n.content,answer:``,streaming:!1,step:null,error:null,actions:[],messageId:null,rating:null,ratingNote:null});continue}let e=t[t.length-1],r={answer:n.content,actions:ce(n.actionsJson),messageId:n.publicId,rating:n.rating??null,ratingNote:n.ratingNote??null};e&&e.messageId===null&&e.answer===``?Object.assign(e,r):t.push({id:n.publicId,question:``,streaming:!1,step:null,error:null,...r})}return t}function ue({client:e,pageContext:t}){let[n,r]=j([]),[i,a]=j(null),[o,s]=j(null),[c,l]=j(!1),[u,d]=j(null),f=A(null),p=A(0),m=A(0),h=A(t);h.current=t;let g=A(null);g.current=i;let _=A(n);_.current=n;let v=A(new Map),y=A(0),b=A(!1),x=E(()=>{let e=v.current;e.size!==0&&(v.current=new Map,T(()=>{r(t=>t.map(t=>e.has(t.id)?{...t,answer:t.answer+e.get(t.id),step:null}:t))}))},[]),S=E((e,t)=>{v.current.set(e,(v.current.get(e)??``)+t),!b.current&&(b.current=!0,y.current=requestAnimationFrame(()=>{b.current=!1,x()}))},[x]),C=E(()=>{x(),p.current+=1,f.current?.abort(),f.current=null},[x]);D(()=>C,[C]),D(()=>()=>{cancelAnimationFrame(y.current),b.current=!1},[]);let w=E((e,t)=>{r(n=>n.map(n=>n.id===e?{...n,...typeof t==`function`?t(n):t}:n))},[]),O=E(async t=>{let n=typeof t==`string`?t.trim():``;if(!n||f.current)return;let i=p.current,o=new AbortController;f.current=o,m.current+=1;let c=`turn-${m.current}`;r(e=>[...e,{id:c,question:n,answer:``,streaming:!0,step:null,error:null,actions:[],messageId:null,rating:null,ratingNote:null}]);let l=()=>i===p.current&&!o.signal.aborted;try{let t=await e.sendMessage({message:n,conversationId:g.current,pageContext:h.current},{signal:o.signal,onEvent:(e,t)=>{if(l()){if(e===`delta`){S(c,t?.text??``);return}x(),e===`reset`?w(c,{answer:``,step:null}):e===`tool`?w(c,{step:typeof t?.toolName==`string`&&t.toolName?t.toolName:null}):e===`actions`&&w(c,{actions:Array.isArray(t?.actions)?t.actions:[]})}}});if(x(),!l())return;w(c,{answer:t.reply,messageId:t.messageId??null,streaming:!1,step:null}),g.current=t.conversationId,a(t.conversationId),s(t.messagesLeftToday??null)}catch(e){if(x(),!l())return;w(c,{answer:``,actions:[],streaming:!1,step:null,error:$(e)}),e?.code===`daily_limit`&&s(0),e?.code===`conversation_not_found`&&(g.current=null,a(null))}finally{f.current===o&&(f.current=null)}},[e,w,x,S]),k=E(async t=>{C();let n=p.current;r([]),a(null),d(null),l(!0);try{let i=await e.getConversation(t);if(n!==p.current)return;r(le(i.messages)),a(i.publicId)}catch(e){if(n!==p.current)return;d($(e))}finally{n===p.current&&l(!1)}},[C,e]),M=E(()=>{C(),r([]),a(null),d(null),l(!1)},[C]),N=E(()=>{C(),r([]),a(null),s(null),d(null),l(!1)},[C]),P=E(async()=>{let t=p.current,n=await e.getAllowance();t===p.current&&s(n?.messagesLeftToday??null)},[e]),F=E(async(t,n,r)=>{let i=_.current.find(e=>e.id===t),a=g.current;if(!i?.messageId||!a)throw Error(`Only a stored reply can be rated.`);let o={rating:i.rating,ratingNote:i.ratingNote},s=typeof r==`string`&&r.trim()?r.trim():null;w(t,{rating:n,ratingNote:s});try{await e.rateMessage(a,i.messageId,{rating:n,note:s})}catch(e){throw w(t,o),e}},[e,w]);return{turns:n,conversationId:i,messagesLeftToday:o,streaming:n.some(e=>e.streaming),loading:c,loadError:u,submit:O,openConversation:k,newConversation:M,rate:F,refreshAllowance:P,reset:N}}export{z as ActionCard,e as ChatApiError,B as ChatComposer,V as ChatConversationList,W as ChatLauncher,Y as ChatMarkdown,Z as ChatMessage,re as ChatPanel,Q as ChatThread,oe as CitationChip,se as ConfirmCard,t as DEFAULT_CHAT_LABELS,X as ReplyRating,n as createChatClient,r as createSseParser,ae as splitCitations,ue as useChat};
1
+ import{ChatApiError as e,DEFAULT_CHAT_LABELS as t,createChatClient as n,createSseParser as r,mergeLabels as i}from"@webority/ui-elements/chat-core";import{AppActionIcon as a,AppAlert as o,AppButton as s,AppCard as c,AppChip as l,AppConfirmDialog as u,AppDrawer as d,AppEmptyState as f,AppIcon as p,AppMarkdown as m,AppSkeleton as h,AppSpinner as g,AppTextarea as _,useFloatingStack as v}from"@webority/ui-react";import{memo as y,startTransition as b,useCallback as x,useEffect as S,useId as C,useRef as w,useState as T}from"react";import{Fragment as E,jsx as D,jsxs as O}from"react/jsx-runtime";import{formatDateTime as k}from"@webority/ui-elements/helpers";import{createPortal as A}from"react-dom";function j(e,t){return e.kind===`Reply`?t.actionReply(e.ticketNumber):e.kind===`Reopen`?t.actionReopen(e.ticketNumber):t.actionRaiseTicket}function M(e,t,n){return e===`Reply`?n.actionDoneReply(t):e===`Reopen`?n.actionDoneReopen(t):n.actionDoneRaiseTicket(t)}function N({action:e,confirmAction:t,onViewTicket:n,labels:r}){let a=i(r),[l,u]=T(`ready`),[d,f]=T(null),[p,m]=T(``);if(l===`dismissed`)return D(`p`,{className:`wui-text-sm text-body-secondary mb-0`,children:a.actionDismissed});if(l===`done`)return D(o,{variant:`success`,role:`status`,size:`sm`,action:n?D(s,{size:`sm`,variant:`ghost`,onClick:()=>n(d),children:a.viewTicket}):void 0,children:M(e.kind,d.number,a)});async function h(){u(`sending`),m(``);try{f(await t(e.token)),u(`done`)}catch(e){m(e?.message||a.actionFailed),u(`ready`)}}let g=l===`sending`,_=new Date(e.expiresDateTimeUtc).getTime()<=Date.now(),v=e.kind===`RaiseTicket`?[e.category,e.subject].filter(Boolean).join(` · `):``;return D(c,{padding:`sm`,className:`border`,title:j(e,a),subtitle:v||void 0,children:O(`div`,{className:`d-flex flex-column gap-2`,children:[e.kind!==`Reopen`&&e.body&&D(`p`,{className:`wui-text-sm mb-0`,style:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`},children:e.body}),_?D(`p`,{className:`wui-text-sm text-body-secondary mb-0`,children:a.actionExpired}):O(E,{children:[D(`p`,{className:`wui-text-xs text-body-secondary mb-0`,children:a.actionNote}),p&&D(o,{size:`sm`,variant:`danger`,children:p}),O(`div`,{className:`d-flex flex-wrap gap-2`,children:[D(s,{size:`sm`,loading:g,onClick:h,children:a.actionConfirm}),D(s,{size:`sm`,variant:`secondary`,disabled:g,onClick:()=>u(`dismissed`),children:a.actionDismiss})]})]})]})})}function P({onSubmit:e,busy:t=!1,disabled:n=!1,maxLength:r=4e3,inputRef:a,labels:o}){let c=i(o),l=C(),[u,d]=T(``),f=t||n||!u.trim();function p(){f||(e(u.trim()),d(``))}return O(`form`,{className:`wui-chat-composer d-flex align-items-end gap-2`,"aria-label":c.composer,onSubmit:e=>{e.preventDefault(),p()},children:[D(_,{id:`${l}-message`,"aria-label":c.composer,"aria-describedby":`${l}-hint`,placeholder:c.placeholder,rows:1,autoGrow:!0,maxLength:r,value:u,disabled:n,ref:a,fieldClassName:`flex-grow-1 mb-0`,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),p())}}),D(`span`,{id:`${l}-hint`,className:`visually-hidden`,children:c.composerHint}),D(s,{type:`submit`,leftIcon:`send`,disabled:f,children:D(`span`,{className:`visually-hidden`,children:c.send})})]})}function F({client:e,onOpen:t,onDeleted:n,pageSize:r=20,labels:l}){let d=i(l),[p,m]=T([]),[g,_]=T(!0),[v,y]=T(``),[b,C]=T(!1),[w,E]=T(0),[A,j]=T(null),[M,N]=T(!1),[P,F]=T(``),I=x(async t=>{_(!0),y(``);try{let n=await e.listConversations({skip:t,take:r});m(e=>t===0?n:[...e,...n]),C(n.length===r)}catch(e){y(e?.message||d.loadFailed)}finally{_(!1)}},[e,r,d.loadFailed]);S(()=>{I(0)},[I,w]);async function L(){N(!0),F(``);try{await e.deleteConversation(A.publicId),m(e=>e.filter(e=>e.publicId!==A.publicId)),n?.(A.publicId),j(null)}catch(e){F(e?.message||d.deleteFailed)}finally{N(!1)}}return!g&&!v&&p.length===0?D(f,{icon:`chat`,size:`sm`,title:d.conversationsEmptyTitle,text:d.conversationsEmptyText}):O(`div`,{className:`d-flex flex-column gap-3`,children:[v&&D(o,{variant:`danger`,action:D(s,{size:`sm`,variant:`secondary`,onClick:()=>E(e=>e+1),children:d.retry}),children:v}),p.length>0&&D(`ul`,{className:`list-unstyled d-flex flex-column gap-2 mb-0`,"aria-label":d.conversations,children:p.map(e=>D(`li`,{children:O(c,{padding:`sm`,className:`border`,bodyClassName:`d-flex align-items-center gap-2`,children:[D(s,{variant:`ghost`,className:`flex-grow-1 text-start`,style:{minWidth:0},onClick:()=>t(e),children:O(`span`,{className:`d-flex flex-column`,style:{minWidth:0},children:[D(`span`,{className:`text-truncate fw-semibold`,children:e.title||d.untitled}),D(`time`,{dateTime:e.lastMessageDateTimeUtc,className:`wui-text-xs text-body-secondary`,children:k(e.lastMessageDateTimeUtc)})]})}),D(a,{icon:`trash-2`,danger:!0,label:d.deleteConversation,onClick:()=>{F(``),j(e)}})]})},e.publicId))}),g&&O(`div`,{className:`d-flex flex-column gap-2`,"aria-hidden":`true`,children:[D(h,{height:44}),D(h,{height:44}),D(h,{height:44})]}),!g&&b&&D(s,{variant:`secondary`,className:`align-self-center`,onClick:()=>I(p.length),children:d.loadMore}),D(u,{open:A!==null,title:d.deleteConfirmTitle,message:P?D(o,{variant:`danger`,children:P}):d.deleteConfirmMessage,confirmLabel:d.deleteConfirm,cancelLabel:d.cancel,danger:!0,loading:M,onConfirm:L,onClose:()=>{M||j(null)}})]})}var I={zIndex:`var(--wui-z-fixed)`,bottom:`var(--wui-consent-banner-block, 0px)`},L={end:{insetInlineEnd:0},start:{insetInlineStart:0}};function R({onClick:e,open:t=!1,position:n=`end`,icon:r=`sparkles`,compact:a=!1,className:o,style:c,labels:l}){let u=i(l);return a?D(z,{onClick:e,open:t,position:n,icon:r,className:o,style:c,label:u.launcher}):D(`span`,{"data-support-capture":`exclude`,className:[`position-fixed m-3`,o].filter(Boolean).join(` `),style:{...I,...L[n],...c},children:D(s,{leftIcon:r,className:`rounded-pill`,onClick:e,"aria-haspopup":`dialog`,"aria-expanded":t,children:u.launcher})})}function z({onClick:e,open:t,position:n,icon:r,className:i,style:a,label:o}){let c=v(n);return c?A(D(`span`,{className:[`wui-floating-stack-item wui-floating-stack-item--primary`,i].filter(Boolean).join(` `),style:a,children:D(s,{className:`wui-floating-btn`,onClick:e,"aria-label":o,"aria-haspopup":`dialog`,"aria-expanded":t,tooltip:o,tooltipPlacement:n===`start`?`end`:`start`,children:D(p,{name:r,size:24})})}),c):null}function B({text:e,resolveLink:t,linkComponent:n,className:r}){return D(m,{value:e,links:`app`,headings:`text`,resolveLink:t,linkComponent:n,className:r})}function V({rating:e,onRate:t,noteMaxLength:n=1e3,labels:r}){let a=i(r),c=C(),[l,u]=T(!1),[d,f]=T(!1),[p,m]=T(``),[h,g]=T(``),[v,y]=T(!1);async function b(e,n){u(!0),g(``);try{await t(e,n),f(e===`Down`&&n===void 0),y(e===`Up`||n!==void 0),n!==void 0&&m(``)}catch{g(a.ratingFailed)}finally{u(!1)}}return O(`div`,{className:`d-flex flex-column gap-2`,children:[O(`div`,{className:`d-flex flex-wrap align-items-center gap-1`,children:[D(s,{size:`sm`,variant:e===`Up`?`neutral`:`ghost`,leftIcon:`check`,"aria-pressed":e===`Up`,disabled:l,onClick:()=>b(`Up`),children:a.rateUp}),D(s,{size:`sm`,variant:e===`Down`?`neutral`:`ghost`,leftIcon:`x`,"aria-pressed":e===`Down`,disabled:l,onClick:()=>b(`Down`),children:a.rateDown}),v&&!d&&D(`span`,{className:`wui-text-xs text-body-secondary`,role:`status`,children:a.rated})]}),h&&D(o,{size:`sm`,variant:`danger`,children:h}),d&&O(`form`,{className:`d-flex flex-column gap-2`,onSubmit:e=>{e.preventDefault(),b(`Down`,p)},children:[D(_,{id:`${c}-note`,label:a.ratingNote,hint:a.ratingNoteHint,rows:2,maxLength:n,value:p,onChange:e=>m(e.target.value)}),O(`div`,{className:`d-flex gap-2`,children:[D(s,{type:`submit`,size:`sm`,loading:l,children:a.ratingNoteSend}),D(s,{size:`sm`,variant:`secondary`,disabled:l,onClick:()=>{f(!1),y(!0)},children:a.ratingNoteSkip})]})]})]})}var H={maxWidth:`85%`,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`};function U({turn:e,onRate:t,resolveLink:n,linkComponent:r,confirmAction:a,onViewTicket:s,renderReply:l,labels:u}){let d=i(u),f=e.streaming&&!e.answer;return O(`li`,{className:`d-flex flex-column gap-2`,children:[e.question&&O(`div`,{className:`align-self-end`,style:H,children:[O(`span`,{className:`visually-hidden`,children:[d.you,`: `]}),D(c,{padding:`sm`,variant:`muted`,className:`wui-text-sm`,children:e.question})]}),O(`div`,{className:`d-flex flex-column gap-2`,style:{minWidth:0},children:[O(`span`,{className:`visually-hidden`,children:[d.assistant,`: `]}),D(`div`,{"aria-live":`polite`,"aria-busy":e.streaming,children:f?O(`span`,{className:`d-inline-flex align-items-center gap-2 wui-text-sm text-body-secondary`,children:[D(g,{size:`sm`,label:d.thinking}),D(`span`,{"aria-hidden":`true`,children:d.thinking})]}):e.answer&&(l?l(e,{streaming:!!e.streaming}):D(B,{text:e.answer,resolveLink:n,linkComponent:r}))}),e.error&&D(o,{size:`sm`,variant:`danger`,children:e.error.message}),a&&!e.streaming&&e.actions.map(e=>D(N,{action:e,confirmAction:a,onViewTicket:s,labels:u},e.token)),t&&e.messageId&&!e.streaming&&D(V,{rating:e.rating,onRate:(n,r)=>t(e.id,n,r),labels:u})]})]})}var W=y(U);function G(e){for(let t=e?.parentElement;t&&t!==document.body;t=t.parentElement){let{overflowY:e}=getComputedStyle(t);if((e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight)return t}return null}function K({turns:e,empty:t,onRate:n,resolveLink:r,linkComponent:a,confirmAction:o,onViewTicket:s,renderReply:c,labels:l}){let u=i(l),d=w(null),p=e[e.length-1];return S(()=>{let e=G(d.current);e&&(e.scrollTop=e.scrollHeight)},[e.length,p?.answer,p?.error,p?.actions]),e.length===0?t??D(f,{icon:`sparkles`,size:`sm`,title:u.emptyTitle,text:u.emptyText}):O(E,{children:[D(`ol`,{className:`list-unstyled d-flex flex-column gap-3 mb-0`,"aria-label":u.thread,children:e.map(e=>D(W,{turn:e,onRate:n,resolveLink:r,linkComponent:a,confirmAction:o,onViewTicket:s,renderReply:c,labels:l},e.id))}),D(`div`,{ref:d})]})}function q({chat:e,open:t,onClose:n,title:r,titleIcon:s=`sparkles`,headerActions:c,empty:l,disclaimer:u,maxLength:f=4e3,allowanceThreshold:m=10,width:h=`440px`,resolveLink:_,linkComponent:v,confirmAction:y,onViewTicket:b,rating:x=!0,renderReply:C,labels:T}){let E=i(T),k=w(null),{refreshAllowance:A}=e;S(()=>{t&&A().catch(()=>{})},[t,A]);let j=e.messagesLeftToday,M=r??E.panelTitle;return D(d,{open:t,onClose:n,sheet:!1,width:h,header:O(`div`,{className:`drawer-header`,children:[O(`div`,{className:`drawer-title`,children:[s&&D(`span`,{className:`drawer-title-ic`,children:D(p,{name:s,size:18})}),M]}),O(`div`,{className:`d-flex align-items-center gap-1`,children:[c,D(a,{icon:`plus`,label:E.newChat,onClick:e.newConversation,disabled:e.turns.length===0&&!e.loading}),D(a,{icon:`x`,label:E.close,onClick:n})]})]}),footer:O(`div`,{className:`d-flex flex-column gap-2`,children:[j!==null&&j<=m&&D(`p`,{className:`wui-text-xs text-body-secondary mb-0`,role:`status`,children:E.allowance(j)}),D(P,{onSubmit:e.submit,busy:e.streaming||e.loading,disabled:j===0,maxLength:f,inputRef:k,labels:T}),D(`p`,{className:`wui-text-xs text-body-secondary mb-0`,children:u??E.disclaimer})]}),ariaLabel:typeof M==`string`?M:E.panelTitle,onOpened:()=>k.current?.focus(),children:e.loading?D(`div`,{className:`d-flex justify-content-center py-4`,children:D(g,{label:E.loadingConversation})}):e.loadError?D(o,{variant:`danger`,children:e.loadError.message}):D(K,{turns:e.turns,empty:l,onRate:x?e.rate:void 0,resolveLink:_,linkComponent:v,confirmAction:y,onViewTicket:b,renderReply:C,labels:T})})}var J=/\[([^[\]]*)\](?!\()/g;function Y(e,t){let n=[],r=0;for(let i of e.matchAll(J)){let a=i[1];a===``||!t(a)||(i.index>r&&n.push({text:e.slice(r,i.index)}),n.push({citation:a}),r=i.index+i[0].length)}return r<e.length&&n.push({text:e.slice(r)}),n}function X({citation:e,label:t,ariaLabel:n,onOpen:r}){return D(l,{label:t??e,size:`sm`,tone:`primary`,variant:`outline`,leadingIcon:`book-1`,"aria-label":n??e,onClick:()=>r(e)})}function Z({title:e,subtitle:t,lines:n,note:r,onConfirm:a,labels:l}){let u=i(l),[d,f]=T(`ready`),[p,m]=T(null),[h,g]=T(``);if(d===`dismissed`)return D(`p`,{className:`wui-text-sm text-body-secondary mb-0`,children:u.actionDismissed});if(d===`done`)return D(o,{variant:`success`,role:`status`,size:`sm`,children:p?.message||u.actionDone});async function _(){f(`sending`),g(``);try{let e=await a();m(e??null),f(`done`)}catch(e){g(e?.message||u.actionFailed),f(`ready`)}}let v=d===`sending`;return D(c,{padding:`sm`,className:`border`,title:e,subtitle:t||void 0,children:O(`div`,{className:`d-flex flex-column gap-2`,children:[(n??[]).map((e,t)=>D(`p`,{className:`wui-text-sm mb-0`,style:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`},children:e},t)),D(`p`,{className:`wui-text-xs text-body-secondary mb-0`,children:r??u.actionNote}),h&&D(o,{size:`sm`,variant:`danger`,children:h}),O(`div`,{className:`d-flex flex-wrap gap-2`,children:[D(s,{size:`sm`,loading:v,onClick:_,children:u.actionConfirm}),D(s,{size:`sm`,variant:`secondary`,disabled:v,onClick:()=>f(`dismissed`),children:u.actionDismiss})]})]})})}function Q(e){return{code:e?.code||`unknown`,message:e?.message||`Something went wrong. Please try again.`,resetsAtUtc:e?.resetsAtUtc??null}}function $(e){if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}function ee(e){let t=[];for(let n of e??[]){if(n.role===`User`){t.push({id:n.publicId,question:n.content,answer:``,streaming:!1,step:null,error:null,actions:[],messageId:null,rating:null,ratingNote:null});continue}let e=t[t.length-1],r={answer:n.content,actions:$(n.actionsJson),messageId:n.publicId,rating:n.rating??null,ratingNote:n.ratingNote??null};e&&e.messageId===null&&e.answer===``?Object.assign(e,r):t.push({id:n.publicId,question:``,streaming:!1,step:null,error:null,...r})}return t}function te({client:e,pageContext:t}){let[n,r]=T([]),[i,a]=T(null),[o,s]=T(null),[c,l]=T(!1),[u,d]=T(null),f=w(null),p=w(0),m=w(0),h=w(t);h.current=t;let g=w(null);g.current=i;let _=w(n);_.current=n;let v=w(new Map),y=w(0),C=w(!1),E=x(()=>{let e=v.current;e.size!==0&&(v.current=new Map,b(()=>{r(t=>t.map(t=>e.has(t.id)?{...t,answer:t.answer+e.get(t.id),step:null}:t))}))},[]),D=x((e,t)=>{v.current.set(e,(v.current.get(e)??``)+t),!C.current&&(C.current=!0,y.current=requestAnimationFrame(()=>{C.current=!1,E()}))},[E]),O=x(()=>{E(),p.current+=1,f.current?.abort(),f.current=null},[E]);S(()=>O,[O]),S(()=>()=>{cancelAnimationFrame(y.current),C.current=!1},[]);let k=x((e,t)=>{r(n=>n.map(n=>n.id===e?{...n,...typeof t==`function`?t(n):t}:n))},[]),A=x(async t=>{let n=typeof t==`string`?t.trim():``;if(!n||f.current)return;let i=p.current,o=new AbortController;f.current=o,m.current+=1;let c=`turn-${m.current}`;r(e=>[...e,{id:c,question:n,answer:``,streaming:!0,step:null,error:null,actions:[],messageId:null,rating:null,ratingNote:null}]);let l=()=>i===p.current&&!o.signal.aborted;try{let t=await e.sendMessage({message:n,conversationId:g.current,pageContext:h.current},{signal:o.signal,onEvent:(e,t)=>{if(l()){if(e===`delta`){D(c,t?.text??``);return}E(),e===`reset`?k(c,{answer:``,step:null}):e===`tool`?k(c,{step:typeof t?.toolName==`string`&&t.toolName?t.toolName:null}):e===`actions`&&k(c,{actions:Array.isArray(t?.actions)?t.actions:[]})}}});if(E(),!l())return;k(c,{answer:t.reply,messageId:t.messageId??null,streaming:!1,step:null}),g.current=t.conversationId,a(t.conversationId),s(t.messagesLeftToday??null)}catch(e){if(E(),!l())return;k(c,{answer:``,actions:[],streaming:!1,step:null,error:Q(e)}),e?.code===`daily_limit`&&s(0),e?.code===`conversation_not_found`&&(g.current=null,a(null))}finally{f.current===o&&(f.current=null)}},[e,k,E,D]),j=x(async t=>{O();let n=p.current;r([]),a(null),d(null),l(!0);try{let i=await e.getConversation(t);if(n!==p.current)return;r(ee(i.messages)),a(i.publicId)}catch(e){if(n!==p.current)return;d(Q(e))}finally{n===p.current&&l(!1)}},[O,e]),M=x(()=>{O(),r([]),a(null),d(null),l(!1)},[O]),N=x(()=>{O(),r([]),a(null),s(null),d(null),l(!1)},[O]),P=x(async()=>{let t=p.current,n=await e.getAllowance();t===p.current&&s(n?.messagesLeftToday??null)},[e]),F=x(async(t,n,r)=>{let i=_.current.find(e=>e.id===t),a=g.current;if(!i?.messageId||!a)throw Error(`Only a stored reply can be rated.`);let o={rating:i.rating,ratingNote:i.ratingNote},s=typeof r==`string`&&r.trim()?r.trim():null;k(t,{rating:n,ratingNote:s});try{await e.rateMessage(a,i.messageId,{rating:n,note:s})}catch(e){throw k(t,o),e}},[e,k]);return{turns:n,conversationId:i,messagesLeftToday:o,streaming:n.some(e=>e.streaming),loading:c,loadError:u,submit:A,openConversation:j,newConversation:M,rate:F,refreshAllowance:P,reset:N}}export{N as ActionCard,e as ChatApiError,P as ChatComposer,F as ChatConversationList,R as ChatLauncher,B as ChatMarkdown,W as ChatMessage,q as ChatPanel,K as ChatThread,X as CitationChip,Z as ConfirmCard,t as DEFAULT_CHAT_LABELS,V as ReplyRating,n as createChatClient,r as createSseParser,Y as splitCitations,te as useChat};
@@ -2,7 +2,7 @@
2
2
  "format": "webority-guidance/1",
3
3
  "package": {
4
4
  "name": "@webority/chat-react",
5
- "version": "0.111.0"
5
+ "version": "0.113.0"
6
6
  },
7
7
  "components": [
8
8
  {
@@ -80,7 +80,8 @@
80
80
  "do": [],
81
81
  "dont": [],
82
82
  "a11y": [
83
- "Lists render as real ordered and unordered lists, and tables render through AppDataTable.",
83
+ "Lists render as real ordered and unordered lists, and tables render as the markdown table, with a header row.",
84
+ "Code blocks have a Copy button.",
84
85
  "A link renders only when the host maps it to a route; any other link shows its label as plain text.",
85
86
  "Headings render as bold lines, not heading elements, so a reply does not change the page outline."
86
87
  ]
@@ -26,6 +26,6 @@ export declare const meta: {
26
26
  readonly whenNot: readonly [];
27
27
  readonly do: readonly [];
28
28
  readonly dont: readonly [];
29
- readonly a11y: readonly ["Lists render as real ordered and unordered lists, and tables render through AppDataTable.", "A link renders only when the host maps it to a route; any other link shows its label as plain text.", "Headings render as bold lines, not heading elements, so a reply does not change the page outline."];
29
+ readonly a11y: readonly ["Lists render as real ordered and unordered lists, and tables render as the markdown table, with a header row.", "Code blocks have a Copy button.", "A link renders only when the host maps it to a route; any other link shows its label as plain text.", "Headings render as bold lines, not heading elements, so a reply does not change the page outline."];
30
30
  };
31
31
  };
@@ -1,9 +1,7 @@
1
1
  /**
2
- * A reply rendered from a small, safe subset of Markdown: paragraphs, bold, italics, inline code,
3
- * bullet and numbered lists, simple tables, headings (shown as bold lines) and code blocks. It
4
- * never renders HTML: every character reaches the page as text. A link shows only when its href
5
- * is `scheme:kind/id` and `resolveLink` maps it to an in-app route; any other link shows its label
6
- * as plain text.
2
+ * A chat reply, drawn by `AppMarkdown` with the chat rules: a link opens only when `resolveLink`
3
+ * maps its `scheme:kind/id` href to an in-app route, and a heading draws as a bold line so a reply
4
+ * never changes the page outline. Any other link shows its label as text, and raw HTML shows as text.
7
5
  *
8
6
  * @param {object} props
9
7
  * @param {string} props.text
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/chat-react",
3
- "version": "0.111.0",
3
+ "version": "0.113.0",
4
4
  "description": "Webority AI assistant for React portals: a streaming chat client, a store-agnostic chat hook, and the launcher, panel, thread, rating and support action card, built on @webority/ui-react.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -31,8 +31,8 @@
31
31
  "react": "^19.0.0",
32
32
  "react-bootstrap": "^2.10.0",
33
33
  "react-dom": "^19.0.0",
34
- "@webority/ui-elements": "0.111.0",
35
- "@webority/ui-react": "0.111.0"
34
+ "@webority/ui-elements": "0.113.0",
35
+ "@webority/ui-react": "0.113.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@testing-library/dom": "10.4.2",
@@ -50,9 +50,9 @@
50
50
  "typescript": "^7.0.2",
51
51
  "vite": "^8.0.12",
52
52
  "vitest": "5.0.1",
53
- "@webority/canvas-kit": "0.111.0",
54
- "@webority/ui-elements": "0.111.0",
55
- "@webority/ui-react": "0.111.0"
53
+ "@webority/canvas-kit": "0.113.0",
54
+ "@webority/ui-elements": "0.113.0",
55
+ "@webority/ui-react": "0.113.0"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "vite build && tsc -p tsconfig.json && node ../canvas-kit/dist/cli.js guidance --config canvas-kit.json --out dist/guidance.json",