@webority/mobile-chat 0.106.0 → 0.108.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 +1 -1
- package/lib/commonjs/components/ActionCard.js +1 -1
- package/lib/commonjs/components/ChatComposer.js +1 -1
- package/lib/commonjs/components/ChatConversationList.js +1 -1
- package/lib/commonjs/components/ChatLauncher.js +1 -1
- package/lib/commonjs/components/ChatScreen.js +1 -1
- package/lib/commonjs/components/ReplyRating.js +1 -1
- package/lib/module/components/ActionCard.js +1 -1
- package/lib/module/components/ChatComposer.js +1 -1
- package/lib/module/components/ChatConversationList.js +1 -1
- package/lib/module/components/ChatLauncher.js +1 -1
- package/lib/module/components/ChatScreen.js +1 -1
- package/lib/module/components/ReplyRating.js +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -53,7 +53,7 @@ export const AssistantScreen = ({ navigation }) => (
|
|
|
53
53
|
<ChatScreen
|
|
54
54
|
chat={useAssistant()}
|
|
55
55
|
title="Ask the assistant"
|
|
56
|
-
headerActions={<Button
|
|
56
|
+
headerActions={<Button label="All chats" size="sm" variant="ghost" onPress={() => navigation.navigate('PastChats')} />}
|
|
57
57
|
resolveLink={resolveLink}
|
|
58
58
|
onLinkPress={(target) => navigation.navigate(target.screen, target.params)}
|
|
59
59
|
confirmAction={supportClient.confirmAction}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ActionCard=void 0;var _mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_labels=require("../labels.js"),_jsxRuntime=require("react/jsx-runtime");const titleOf=(e,i)=>"Reply"===e.kind?i.actionReply(e.ticketNumber??""):"Reopen"===e.kind?i.actionReopen(e.ticketNumber??""):i.actionRaiseTicket,doneText=(e,i,t)=>"Reply"===e.kind?t.actionDoneReply(i):"Reopen"===e.kind?t.actionDoneReopen(i):t.actionDoneRaiseTicket(i),ActionCard=({action:e,confirmAction:i,onViewTicket:t,labels:n,testID:s="chat-action"})=>{const a=(0,_labels.mergeLabels)(n),o=(0,_mobileUi.useTheme)(),[r,l]=(0,_react.useState)("ready"),[c,d]=(0,_react.useState)(null),[m,x]=(0,_react.useState)("");if("dismissed"===r)return(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",testID:s,children:a.actionDismissed});if("done"===r&&c)return(0,_jsxRuntime.jsx)(_mobileUi.Banner,{
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ActionCard=void 0;var _mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_labels=require("../labels.js"),_jsxRuntime=require("react/jsx-runtime");const titleOf=(e,i)=>"Reply"===e.kind?i.actionReply(e.ticketNumber??""):"Reopen"===e.kind?i.actionReopen(e.ticketNumber??""):i.actionRaiseTicket,doneText=(e,i,t)=>"Reply"===e.kind?t.actionDoneReply(i):"Reopen"===e.kind?t.actionDoneReopen(i):t.actionDoneRaiseTicket(i),ActionCard=({action:e,confirmAction:i,onViewTicket:t,labels:n,testID:s="chat-action"})=>{const a=(0,_labels.mergeLabels)(n),o=(0,_mobileUi.useTheme)(),[r,l]=(0,_react.useState)("ready"),[c,d]=(0,_react.useState)(null),[m,x]=(0,_react.useState)("");if("dismissed"===r)return(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",testID:s,children:a.actionDismissed});if("done"===r&&c)return(0,_jsxRuntime.jsx)(_mobileUi.Banner,{tone:"success",message:doneText(e,c.number,a),actions:t?[{label:a.viewTicket,onPress:()=>t(c)}]:void 0,testID:s});const u="sending"===r,_=new Date(e.expiresDateTimeUtc).getTime()<=Date.now(),b="RaiseTicket"===e.kind?[e.category,e.subject].filter(Boolean).join(", "):"";return(0,_jsxRuntime.jsx)(_mobileUi.Card,{variant:"outline",padding:"sm",testID:s,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:o.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:titleOf(e,a)}),""!==b&&(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:b}),"Reopen"!==e.kind&&e.body?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:e.body}):null,_?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:a.actionExpired}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:a.actionNote}),""!==m&&(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:m}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",gap:o.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:a.actionConfirm,size:"sm",loading:u,disabled:u,onPress:()=>{(async()=>{l("sending"),x("");try{d(await i(e.token)),l("done")}catch(e){const i=e?.message;x("string"==typeof i&&i?i:a.actionFailed),l("ready")}})()},testID:`${s}-confirm`}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:a.actionDismiss,size:"sm",variant:"outline",disabled:u,onPress:()=>l("dismissed"),testID:`${s}-dismiss`})]})]})]})})};exports.ActionCard=ActionCard;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatComposer=void 0;var _mobileUi=require("@webority/mobile-ui"),_labels=require("../labels.js"),_jsxRuntime=require("react/jsx-runtime");const ChatComposer=({onSubmit:e,busy:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatComposer=void 0;var _mobileUi=require("@webority/mobile-ui"),_labels=require("../labels.js"),_jsxRuntime=require("react/jsx-runtime");const ChatComposer=({onSubmit:e,busy:o=!1,disabled:s=!1,maxLength:r=4e3,above:a,below:t,keyboardAware:l,keyboardOffset:b,safeArea:i,labels:d,testID:m="chat-composer"})=>{const n=(0,_labels.mergeLabels)(d);return(0,_jsxRuntime.jsx)(_mobileUi.Composer,{onSend:e,loading:o,disabled:s,maxLength:r,placeholder:n.placeholder,accessibilityLabel:n.composer,labels:{send:n.send},above:a,below:t,keyboardAware:l,keyboardOffset:b,safeArea:i,testID:m})};exports.ChatComposer=ChatComposer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatConversationList=void 0;var _mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_labels=require("../labels.js"),_jsxRuntime=require("react/jsx-runtime");const messageOf=(e,t)=>{const i=e?.message;return"string"==typeof i&&i?i:t},ChatConversationList=({client:e,onOpen:t,onDeleted:i,pageSize:s=20,labels:a,style:n,testID:l="chat-conversations"})=>{const r=(0,_labels.mergeLabels)(a),o=(0,_mobileUi.useTheme)(),[c,m]=(0,_react.useState)([]),[u,_]=(0,_react.useState)(!0),[d,b]=(0,_react.useState)(!1),[x,j]=(0,_react.useState)(""),[g,h]=(0,_react.useState)(!1),[p,v]=(0,_react.useState)(null),[y,f]=(0,_react.useState)(!1),[C,R]=(0,_react.useState)(""),I=r.loadFailed,S=(0,_react.useCallback)(async t=>{_(!0),j("");try{const i=await e.listConversations({skip:t,take:s});m(e=>0===t?i:[...e,...i]),h(i.length===s)}catch(e){j(messageOf(e,I))}finally{_(!1)}},[e,s,I]);(0,_react.useEffect)(()=>{S(0)},[S]);const U=!u&&""===x&&0===c.length;return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{style:n,contentContainerStyle:{padding:o.space.md,gap:o.space.sm,flexGrow:1},refreshControl:(0,_jsxRuntime.jsx)(_reactNative.RefreshControl,{refreshing:d,onRefresh:()=>{(async()=>{b(!0),await S(0),b(!1)})()}}),accessibilityLabel:r.conversations,testID:l,children:[""!==x&&(0,_jsxRuntime.jsx)(_mobileUi.Banner,{
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatConversationList=void 0;var _mobileCore=require("@webority/mobile-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_labels=require("../labels.js"),_jsxRuntime=require("react/jsx-runtime");const messageOf=(e,t)=>{const i=e?.message;return"string"==typeof i&&i?i:t},ChatConversationList=({client:e,onOpen:t,onDeleted:i,pageSize:s=20,labels:a,style:n,testID:l="chat-conversations"})=>{const r=(0,_labels.mergeLabels)(a),o=(0,_mobileUi.useTheme)(),[c,m]=(0,_react.useState)([]),[u,_]=(0,_react.useState)(!0),[d,b]=(0,_react.useState)(!1),[x,j]=(0,_react.useState)(""),[g,h]=(0,_react.useState)(!1),[p,v]=(0,_react.useState)(null),[y,f]=(0,_react.useState)(!1),[C,R]=(0,_react.useState)(""),I=r.loadFailed,S=(0,_react.useCallback)(async t=>{_(!0),j("");try{const i=await e.listConversations({skip:t,take:s});m(e=>0===t?i:[...e,...i]),h(i.length===s)}catch(e){j(messageOf(e,I))}finally{_(!1)}},[e,s,I]);(0,_react.useEffect)(()=>{S(0)},[S]);const U=!u&&""===x&&0===c.length;return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{style:n,contentContainerStyle:{padding:o.space.md,gap:o.space.sm,flexGrow:1},refreshControl:(0,_jsxRuntime.jsx)(_reactNative.RefreshControl,{refreshing:d,onRefresh:()=>{(async()=>{b(!0),await S(0),b(!1)})()}}),accessibilityLabel:r.conversations,testID:l,children:[""!==x&&(0,_jsxRuntime.jsx)(_mobileUi.Banner,{tone:"danger",message:x,actions:[{label:r.retry,onPress:()=>{S(0)}}],testID:`${l}-error`}),U&&(0,_jsxRuntime.jsx)(_mobileUi.EmptyState,{size:"sm",title:r.conversationsEmptyTitle,description:r.conversationsEmptyText,testID:`${l}-empty`}),c.map(e=>(0,_jsxRuntime.jsx)(_mobileUi.Card,{variant:"outline",padding:"sm",onPress:()=>t(e),accessibilityLabel:e.title||r.untitled,testID:`${l}-item-${e.publicId}`,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:o.space.sm},children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1,minWidth:0},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",numberOfLines:1,children:e.title||r.untitled}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:(0,_mobileCore.formatDateTime)(e.lastMessageDateTimeUtc)})]}),(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{icon:"trash",tone:"danger",variant:"ghost",accessibilityLabel:r.deleteConversation,onPress:()=>{R(""),v(e)},testID:`${l}-delete-${e.publicId}`})]})},e.publicId)),u&&!d&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:o.space.sm},accessibilityElementsHidden:!0,children:[(0,_jsxRuntime.jsx)(_mobileUi.Skeleton,{height:56}),(0,_jsxRuntime.jsx)(_mobileUi.Skeleton,{height:56}),(0,_jsxRuntime.jsx)(_mobileUi.Skeleton,{height:56})]}),!u&&g&&(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:r.loadMore,variant:"outline",onPress:()=>{S(c.length)},testID:`${l}-more`}),(0,_jsxRuntime.jsx)(_mobileUi.Dialog,{visible:null!==p,onClose:()=>{y||v(null)},tone:"warning",title:r.deleteConfirmTitle,message:C||r.deleteConfirmMessage,dismissOnAction:!1,actions:[{label:r.cancel,tone:"neutral",disabled:y,onPress:()=>v(null)},{label:r.deleteConfirm,tone:"danger",loading:y,onPress:()=>{(async()=>{if(p){f(!0),R("");try{await e.deleteConversation(p.publicId),m(e=>e.filter(e=>e.publicId!==p.publicId)),i?.(p.publicId),v(null)}catch(e){R(messageOf(e,r.deleteFailed))}finally{f(!1)}}})()}}],testID:`${l}-confirm`})]})};exports.ChatConversationList=ChatConversationList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatLauncher=void 0;var _mobileUi=require("@webority/mobile-ui"),_labels=require("../labels.js"),_jsxRuntime=require("react/jsx-runtime");const ChatLauncher=({onPress:e,position:t="end",bottomOffset:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatLauncher=void 0;var _mobileUi=require("@webority/mobile-ui"),_labels=require("../labels.js"),_jsxRuntime=require("react/jsx-runtime");const ChatLauncher=({onPress:e,position:t="end",bottomOffset:s,compact:o=!1,labels:i,testID:r="chat-launcher"})=>{const a=(0,_labels.mergeLabels)(i);return(0,_jsxRuntime.jsx)(_mobileUi.FloatingActionButton,{icon:"messages",label:o?void 0:a.launcher,accessibilityLabel:a.launcher,position:"end"===t?"bottomRight":"bottomLeft",bottomOffset:s,onPress:e,testID:r})};exports.ChatLauncher=ChatLauncher;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatScreen=ChatScreen;var _mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_labels=require("../labels.js"),_ChatComposer=require("./ChatComposer.js"),_ChatThread=require("./ChatThread.js"),_jsxRuntime=require("react/jsx-runtime");function ChatScreen({chat:e,title:t,headerActions:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatScreen=ChatScreen;var _mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_labels=require("../labels.js"),_ChatComposer=require("./ChatComposer.js"),_ChatThread=require("./ChatThread.js"),_jsxRuntime=require("react/jsx-runtime");function ChatScreen({chat:e,title:t,headerActions:s,empty:i,disclaimer:r,maxLength:a=4e3,allowanceThreshold:n=10,rating:l=!0,keyboardOffset:o,testID:m="chat-screen",...d}){const c=(0,_labels.mergeLabels)(d.labels),u=(0,_mobileUi.useTheme)(),x=e.messagesLeftToday,b=void 0===r?c.disclaimer:r;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1,backgroundColor:u.colors.bg},testID:m,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:u.space.sm,paddingHorizontal:u.space.md,paddingVertical:u.space.sm,borderBottomWidth:1,borderBottomColor:u.colors["border-subtle"]},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"title",accessibilityRole:"header",style:{flex:1},numberOfLines:1,children:t??c.panelTitle}),s,(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:c.newChat,size:"sm",variant:"soft",leftIcon:"add",disabled:0===e.turns.length&&!e.loading,onPress:e.newConversation,testID:`${m}-new`})]}),e.loading?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1,alignItems:"center",justifyContent:"center"},children:(0,_jsxRuntime.jsx)(_mobileUi.Spinner,{message:c.loadingConversation,testID:`${m}-loading`})}):(0,_jsxRuntime.jsx)(_ChatThread.ChatThread,{turns:e.turns,style:{flex:1},keyboardOffset:o,onRate:l?e.rate:void 0,empty:i??(0,_jsxRuntime.jsx)(_mobileUi.EmptyState,{fill:!0,size:"sm",title:c.emptyTitle,description:c.emptyText,testID:`${m}-empty`}),testID:`${m}-thread`,...d}),(0,_jsxRuntime.jsx)(_ChatComposer.ChatComposer,{onSubmit:t=>{e.submit(t)},busy:e.streaming,disabled:0===x||e.loading,maxLength:a,keyboardOffset:o,labels:d.labels,testID:`${m}-composer`,above:(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[e.loadError&&(0,_jsxRuntime.jsx)(_mobileUi.Banner,{tone:"danger",message:e.loadError.message,testID:`${m}-load-error`}),null!==x&&x<=n&&(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:0===x?"danger":"secondary",accessibilityLiveRegion:"polite",testID:`${m}-allowance`,children:c.allowance(x)})]}),below:b?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",testID:`${m}-disclaimer`,children:b}):null})]})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ReplyRating=void 0;var _mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_labels=require("../labels.js"),_jsxRuntime=require("react/jsx-runtime");const ReplyRating=({rating:e=null,onRate:t,noteMaxLength:i=1e3,labels:s,testID:a="chat-rating"})=>{const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ReplyRating=void 0;var _mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_labels=require("../labels.js"),_jsxRuntime=require("react/jsx-runtime");const ReplyRating=({rating:e=null,onRate:t,noteMaxLength:i=1e3,labels:s,testID:a="chat-rating"})=>{const l=(0,_labels.mergeLabels)(s),n=(0,_mobileUi.useTheme)(),[r,o]=(0,_react.useState)(!1),[c,d]=(0,_react.useState)(!1),[u,x]=(0,_react.useState)(""),[m,_]=(0,_react.useState)(""),[b,p]=(0,_react.useState)(!1),save=async(e,i)=>{o(!0),_("");try{await t(e,i),d("Down"===e&&void 0===i),p("Up"===e||void 0!==i),void 0!==i&&x("")}catch{_(l.ratingFailed)}finally{o(!1)}};return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:n.space.sm},testID:a,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:n.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:l.rateUp,size:"sm",leftIcon:"like",variant:"Up"===e?"soft":"ghost",accessibilityState:{selected:"Up"===e,disabled:r},"aria-selected":"Up"===e,"aria-disabled":r,disabled:r,onPress:()=>{save("Up")},testID:`${a}-up`}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:l.rateDown,size:"sm",leftIcon:"dislike",variant:"Down"===e?"soft":"ghost",accessibilityState:{selected:"Down"===e,disabled:r},"aria-selected":"Down"===e,"aria-disabled":r,disabled:r,onPress:()=>{save("Down")},testID:`${a}-down`}),b&&!c&&(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",accessibilityLiveRegion:"polite",children:l.rated})]}),""!==m&&(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:m}),c&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:n.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Input,{label:l.ratingNote,helperText:l.ratingNoteHint,multiline:!0,maxLength:i,value:u,onChangeText:x,testID:`${a}-note`}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",gap:n.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:l.ratingNoteSend,size:"sm",loading:r,disabled:r,onPress:()=>{save("Down",u)},testID:`${a}-note-send`}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:l.ratingNoteSkip,size:"sm",variant:"outline",disabled:r,onPress:()=>{d(!1),p(!0)},testID:`${a}-note-skip`})]})]})]})};exports.ReplyRating=ReplyRating;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Banner,Button,Card,Text,useTheme}from"@webority/mobile-ui";import{useState}from"react";import{View}from"react-native";import{mergeLabels}from"../labels.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const titleOf=(e,t)=>"Reply"===e.kind?t.actionReply(e.ticketNumber??""):"Reopen"===e.kind?t.actionReopen(e.ticketNumber??""):t.actionRaiseTicket,doneText=(e,t,i)=>"Reply"===e.kind?i.actionDoneReply(t):"Reopen"===e.kind?i.actionDoneReopen(t):i.actionDoneRaiseTicket(t);export const ActionCard=({action:e,confirmAction:t,onViewTicket:i,labels:n,testID:s="chat-action"})=>{const a=mergeLabels(n),o=useTheme(),[r,c]=useState("ready"),[l,d]=useState(null),[m,x]=useState("");if("dismissed"===r)return _jsx(Text,{variant:"bodySmall",color:"secondary",testID:s,children:a.actionDismissed});if("done"===r&&l)return _jsx(Banner,{
|
|
1
|
+
"use strict";import{Banner,Button,Card,Text,useTheme}from"@webority/mobile-ui";import{useState}from"react";import{View}from"react-native";import{mergeLabels}from"../labels.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const titleOf=(e,t)=>"Reply"===e.kind?t.actionReply(e.ticketNumber??""):"Reopen"===e.kind?t.actionReopen(e.ticketNumber??""):t.actionRaiseTicket,doneText=(e,t,i)=>"Reply"===e.kind?i.actionDoneReply(t):"Reopen"===e.kind?i.actionDoneReopen(t):i.actionDoneRaiseTicket(t);export const ActionCard=({action:e,confirmAction:t,onViewTicket:i,labels:n,testID:s="chat-action"})=>{const a=mergeLabels(n),o=useTheme(),[r,c]=useState("ready"),[l,d]=useState(null),[m,x]=useState("");if("dismissed"===r)return _jsx(Text,{variant:"bodySmall",color:"secondary",testID:s,children:a.actionDismissed});if("done"===r&&l)return _jsx(Banner,{tone:"success",message:doneText(e,l.number,a),actions:i?[{label:a.viewTicket,onPress:()=>i(l)}]:void 0,testID:s});const p="sending"===r,y=new Date(e.expiresDateTimeUtc).getTime()<=Date.now(),b="RaiseTicket"===e.kind?[e.category,e.subject].filter(Boolean).join(", "):"";return _jsx(Card,{variant:"outline",padding:"sm",testID:s,children:_jsxs(View,{style:{gap:o.space.sm},children:[_jsx(Text,{variant:"label",children:titleOf(e,a)}),""!==b&&_jsx(Text,{variant:"bodySmall",color:"secondary",children:b}),"Reopen"!==e.kind&&e.body?_jsx(Text,{variant:"bodySmall",children:e.body}):null,y?_jsx(Text,{variant:"bodySmall",color:"secondary",children:a.actionExpired}):_jsxs(_Fragment,{children:[_jsx(Text,{variant:"caption",color:"secondary",children:a.actionNote}),""!==m&&_jsx(Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:m}),_jsxs(View,{style:{flexDirection:"row",flexWrap:"wrap",gap:o.space.sm},children:[_jsx(Button,{label:a.actionConfirm,size:"sm",loading:p,disabled:p,onPress:()=>{(async()=>{c("sending"),x("");try{d(await t(e.token)),c("done")}catch(e){const t=e?.message;x("string"==typeof t&&t?t:a.actionFailed),c("ready")}})()},testID:`${s}-confirm`}),_jsx(Button,{label:a.actionDismiss,size:"sm",variant:"outline",disabled:p,onPress:()=>c("dismissed"),testID:`${s}-dismiss`})]})]})]})})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Composer}from"@webority/mobile-ui";import{mergeLabels}from"../labels.js";import{jsx as _jsx}from"react/jsx-runtime";export const ChatComposer=({onSubmit:e,busy:o=!1,disabled:s=!1,maxLength:
|
|
1
|
+
"use strict";import{Composer}from"@webority/mobile-ui";import{mergeLabels}from"../labels.js";import{jsx as _jsx}from"react/jsx-runtime";export const ChatComposer=({onSubmit:e,busy:o=!1,disabled:s=!1,maxLength:a=4e3,above:r,below:t,keyboardAware:b,keyboardOffset:l,safeArea:m,labels:i,testID:d="chat-composer"})=>{const n=mergeLabels(i);return _jsx(Composer,{onSend:e,loading:o,disabled:s,maxLength:a,placeholder:n.placeholder,accessibilityLabel:n.composer,labels:{send:n.send},above:r,below:t,keyboardAware:b,keyboardOffset:l,safeArea:m,testID:d})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{formatDateTime}from"@webority/mobile-core";import{Banner,Button,Card,Dialog,EmptyState,IconButton,Skeleton,Text,useTheme}from"@webority/mobile-ui";import{useCallback,useEffect,useState}from"react";import{RefreshControl,ScrollView,View}from"react-native";import{mergeLabels}from"../labels.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const messageOf=(e,t)=>{const s=e?.message;return"string"==typeof s&&s?s:t};export const ChatConversationList=({client:e,onOpen:t,onDeleted:s,pageSize:
|
|
1
|
+
"use strict";import{formatDateTime}from"@webority/mobile-core";import{Banner,Button,Card,Dialog,EmptyState,IconButton,Skeleton,Text,useTheme}from"@webority/mobile-ui";import{useCallback,useEffect,useState}from"react";import{RefreshControl,ScrollView,View}from"react-native";import{mergeLabels}from"../labels.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const messageOf=(e,t)=>{const s=e?.message;return"string"==typeof s&&s?s:t};export const ChatConversationList=({client:e,onOpen:t,onDeleted:s,pageSize:n=20,labels:i,style:a,testID:l="chat-conversations"})=>{const o=mergeLabels(i),r=useTheme(),[c,m]=useState([]),[d,u]=useState(!0),[p,f]=useState(!1),[g,b]=useState(""),[h,x]=useState(!1),[y,j]=useState(null),[S,I]=useState(!1),[_,C]=useState(""),v=o.loadFailed,D=useCallback(async t=>{u(!0),b("");try{const s=await e.listConversations({skip:t,take:n});m(e=>0===t?s:[...e,...s]),x(s.length===n)}catch(e){b(messageOf(e,v))}finally{u(!1)}},[e,n,v]);useEffect(()=>{D(0)},[D]);const w=!d&&""===g&&0===c.length;return _jsxs(ScrollView,{style:a,contentContainerStyle:{padding:r.space.md,gap:r.space.sm,flexGrow:1},refreshControl:_jsx(RefreshControl,{refreshing:p,onRefresh:()=>{(async()=>{f(!0),await D(0),f(!1)})()}}),accessibilityLabel:o.conversations,testID:l,children:[""!==g&&_jsx(Banner,{tone:"danger",message:g,actions:[{label:o.retry,onPress:()=>{D(0)}}],testID:`${l}-error`}),w&&_jsx(EmptyState,{size:"sm",title:o.conversationsEmptyTitle,description:o.conversationsEmptyText,testID:`${l}-empty`}),c.map(e=>_jsx(Card,{variant:"outline",padding:"sm",onPress:()=>t(e),accessibilityLabel:e.title||o.untitled,testID:`${l}-item-${e.publicId}`,children:_jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:r.space.sm},children:[_jsxs(View,{style:{flex:1,minWidth:0},children:[_jsx(Text,{variant:"label",numberOfLines:1,children:e.title||o.untitled}),_jsx(Text,{variant:"caption",color:"secondary",children:formatDateTime(e.lastMessageDateTimeUtc)})]}),_jsx(IconButton,{icon:"trash",tone:"danger",variant:"ghost",accessibilityLabel:o.deleteConversation,onPress:()=>{C(""),j(e)},testID:`${l}-delete-${e.publicId}`})]})},e.publicId)),d&&!p&&_jsxs(View,{style:{gap:r.space.sm},accessibilityElementsHidden:!0,children:[_jsx(Skeleton,{height:56}),_jsx(Skeleton,{height:56}),_jsx(Skeleton,{height:56})]}),!d&&h&&_jsx(Button,{label:o.loadMore,variant:"outline",onPress:()=>{D(c.length)},testID:`${l}-more`}),_jsx(Dialog,{visible:null!==y,onClose:()=>{S||j(null)},tone:"warning",title:o.deleteConfirmTitle,message:_||o.deleteConfirmMessage,dismissOnAction:!1,actions:[{label:o.cancel,tone:"neutral",disabled:S,onPress:()=>j(null)},{label:o.deleteConfirm,tone:"danger",loading:S,onPress:()=>{(async()=>{if(y){I(!0),C("");try{await e.deleteConversation(y.publicId),m(e=>e.filter(e=>e.publicId!==y.publicId)),s?.(y.publicId),j(null)}catch(e){C(messageOf(e,o.deleteFailed))}finally{I(!1)}}})()}}],testID:`${l}-confirm`})]})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{
|
|
1
|
+
"use strict";import{FloatingActionButton}from"@webority/mobile-ui";import{mergeLabels}from"../labels.js";import{jsx as _jsx}from"react/jsx-runtime";export const ChatLauncher=({onPress:t,position:o="end",bottomOffset:e,compact:s=!1,labels:i,testID:n="chat-launcher"})=>{const r=mergeLabels(i);return _jsx(FloatingActionButton,{icon:"messages",label:s?void 0:r.launcher,accessibilityLabel:r.launcher,position:"end"===o?"bottomRight":"bottomLeft",bottomOffset:e,onPress:t,testID:n})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Banner,Button,EmptyState,Spinner,Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{mergeLabels}from"../labels.js";import{ChatComposer}from"./ChatComposer.js";import{ChatThread}from"./ChatThread.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export function ChatScreen({chat:e,title:t,headerActions:s,empty:r,disclaimer:a,maxLength:o=4e3,allowanceThreshold:i=10,rating:n=!0,keyboardOffset:l,testID:m="chat-screen",...d}){const c=mergeLabels(d.labels),h=useTheme(),p=e.messagesLeftToday,x=void 0===a?c.disclaimer:a;return _jsxs(View,{style:{flex:1,backgroundColor:h.colors.bg},testID:m,children:[_jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:h.space.sm,paddingHorizontal:h.space.md,paddingVertical:h.space.sm,borderBottomWidth:1,borderBottomColor:h.colors["border-subtle"]},children:[_jsx(Text,{variant:"title",accessibilityRole:"header",style:{flex:1},numberOfLines:1,children:t??c.panelTitle}),s,_jsx(Button,{
|
|
1
|
+
"use strict";import{Banner,Button,EmptyState,Spinner,Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{mergeLabels}from"../labels.js";import{ChatComposer}from"./ChatComposer.js";import{ChatThread}from"./ChatThread.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export function ChatScreen({chat:e,title:t,headerActions:s,empty:r,disclaimer:a,maxLength:o=4e3,allowanceThreshold:i=10,rating:n=!0,keyboardOffset:l,testID:m="chat-screen",...d}){const c=mergeLabels(d.labels),h=useTheme(),p=e.messagesLeftToday,x=void 0===a?c.disclaimer:a;return _jsxs(View,{style:{flex:1,backgroundColor:h.colors.bg},testID:m,children:[_jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:h.space.sm,paddingHorizontal:h.space.md,paddingVertical:h.space.sm,borderBottomWidth:1,borderBottomColor:h.colors["border-subtle"]},children:[_jsx(Text,{variant:"title",accessibilityRole:"header",style:{flex:1},numberOfLines:1,children:t??c.panelTitle}),s,_jsx(Button,{label:c.newChat,size:"sm",variant:"soft",leftIcon:"add",disabled:0===e.turns.length&&!e.loading,onPress:e.newConversation,testID:`${m}-new`})]}),e.loading?_jsx(View,{style:{flex:1,alignItems:"center",justifyContent:"center"},children:_jsx(Spinner,{message:c.loadingConversation,testID:`${m}-loading`})}):_jsx(ChatThread,{turns:e.turns,style:{flex:1},keyboardOffset:l,onRate:n?e.rate:void 0,empty:r??_jsx(EmptyState,{fill:!0,size:"sm",title:c.emptyTitle,description:c.emptyText,testID:`${m}-empty`}),testID:`${m}-thread`,...d}),_jsx(ChatComposer,{onSubmit:t=>{e.submit(t)},busy:e.streaming,disabled:0===p||e.loading,maxLength:o,keyboardOffset:l,labels:d.labels,testID:`${m}-composer`,above:_jsxs(_Fragment,{children:[e.loadError&&_jsx(Banner,{tone:"danger",message:e.loadError.message,testID:`${m}-load-error`}),null!==p&&p<=i&&_jsx(Text,{variant:"caption",color:0===p?"danger":"secondary",accessibilityLiveRegion:"polite",testID:`${m}-allowance`,children:c.allowance(p)})]}),below:x?_jsx(Text,{variant:"caption",color:"tertiary",testID:`${m}-disclaimer`,children:x}):null})]})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Button,Input,Text,useTheme}from"@webority/mobile-ui";import{useState}from"react";import{View}from"react-native";import{mergeLabels}from"../labels.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const ReplyRating=({rating:e=null,onRate:t,noteMaxLength:s=1e3,labels:
|
|
1
|
+
"use strict";import{Button,Input,Text,useTheme}from"@webority/mobile-ui";import{useState}from"react";import{View}from"react-native";import{mergeLabels}from"../labels.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const ReplyRating=({rating:e=null,onRate:t,noteMaxLength:s=1e3,labels:a,testID:i="chat-rating"})=>{const n=mergeLabels(a),l=useTheme(),[o,r]=useState(!1),[c,d]=useState(!1),[p,x]=useState(""),[m,b]=useState(""),[g,u]=useState(!1),save=async(e,s)=>{r(!0),b("");try{await t(e,s),d("Down"===e&&void 0===s),u("Up"===e||void 0!==s),void 0!==s&&x("")}catch{b(n.ratingFailed)}finally{r(!1)}};return _jsxs(View,{style:{gap:l.space.sm},testID:i,children:[_jsxs(View,{style:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:l.space.xs},children:[_jsx(Button,{label:n.rateUp,size:"sm",leftIcon:"like",variant:"Up"===e?"soft":"ghost",accessibilityState:{selected:"Up"===e,disabled:o},"aria-selected":"Up"===e,"aria-disabled":o,disabled:o,onPress:()=>{save("Up")},testID:`${i}-up`}),_jsx(Button,{label:n.rateDown,size:"sm",leftIcon:"dislike",variant:"Down"===e?"soft":"ghost",accessibilityState:{selected:"Down"===e,disabled:o},"aria-selected":"Down"===e,"aria-disabled":o,disabled:o,onPress:()=>{save("Down")},testID:`${i}-down`}),g&&!c&&_jsx(Text,{variant:"caption",color:"secondary",accessibilityLiveRegion:"polite",children:n.rated})]}),""!==m&&_jsx(Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:m}),c&&_jsxs(View,{style:{gap:l.space.sm},children:[_jsx(Input,{label:n.ratingNote,helperText:n.ratingNoteHint,multiline:!0,maxLength:s,value:p,onChangeText:x,testID:`${i}-note`}),_jsxs(View,{style:{flexDirection:"row",gap:l.space.sm},children:[_jsx(Button,{label:n.ratingNoteSend,size:"sm",loading:o,disabled:o,onPress:()=>{save("Down",p)},testID:`${i}-note-send`}),_jsx(Button,{label:n.ratingNoteSkip,size:"sm",variant:"outline",disabled:o,onPress:()=>{d(!1),u(!0)},testID:`${i}-note-skip`})]})]})]})};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/mobile-chat",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.108.0",
|
|
4
4
|
"description": "AI assistant chat for Webority React Native apps: a streaming chat client, a store-agnostic chat hook, and the chat screen, thread, composer, past chats, reply rating and support action cards, built on @webority/mobile-ui.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"react-native": ">=0.81.0",
|
|
47
47
|
"react-native-keyboard-controller": ">=1.21.9",
|
|
48
48
|
"react-native-safe-area-context": ">=5.4.0",
|
|
49
|
-
"@webority/mobile-
|
|
50
|
-
"@webority/mobile-
|
|
49
|
+
"@webority/mobile-core": "0.108.0",
|
|
50
|
+
"@webority/mobile-ui": "0.108.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependenciesMeta": {},
|
|
53
53
|
"publishConfig": {
|
|
@@ -93,9 +93,9 @@
|
|
|
93
93
|
"react-test-renderer": "19.2.8",
|
|
94
94
|
"rimraf": "6.1.3",
|
|
95
95
|
"typescript": "5.9.3",
|
|
96
|
-
"@webority/mobile-core": "0.
|
|
96
|
+
"@webority/mobile-core": "0.108.0",
|
|
97
97
|
"@webority/mobile-dev": "0.0.0",
|
|
98
|
-
"@webority/mobile-ui": "0.
|
|
98
|
+
"@webority/mobile-ui": "0.108.0"
|
|
99
99
|
},
|
|
100
100
|
"scripts": {
|
|
101
101
|
"build": "bob build && node ../mobile-dev/scripts/minify-lib.mjs",
|