@webority/mobile-chat 0.128.0 → 0.133.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/lib/commonjs/AgentByline.js +1 -0
- package/lib/commonjs/ChatComposer.js +1 -0
- package/lib/commonjs/ChatConversationActions.js +1 -0
- package/lib/commonjs/ChatDictationButton.js +1 -0
- package/lib/commonjs/ChatEmbed.js +1 -0
- package/lib/commonjs/ChatEntrance.js +1 -0
- package/lib/commonjs/ChatFooter.js +1 -0
- package/lib/commonjs/ChatFrame.js +1 -0
- package/lib/commonjs/ChatHistory.js +1 -0
- package/lib/commonjs/ChatLiveBar.js +1 -0
- package/lib/commonjs/ChatMessageActions.js +1 -0
- package/lib/commonjs/ChatNudge.js +1 -0
- package/lib/commonjs/ChatOpenTickets.js +1 -0
- package/lib/commonjs/ChatScreen.js +1 -0
- package/lib/commonjs/ChatSheet.js +1 -0
- package/lib/commonjs/ChatStarters.js +1 -0
- package/lib/commonjs/ChatThread.js +1 -0
- package/lib/commonjs/ReadAloudButton.js +1 -0
- package/lib/commonjs/chatShared.js +1 -0
- package/lib/commonjs/features.map.json +40 -0
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/loaders/ChatLoader.js +1 -0
- package/lib/commonjs/loaders/OrbLoader.js +1 -0
- package/lib/commonjs/loaders/PhrasesLoader.js +1 -0
- package/lib/commonjs/loaders/SkeletonLoader.js +1 -0
- package/lib/commonjs/loaders/StepsLoader.js +1 -0
- package/lib/commonjs/loaders/TypingPill.js +1 -0
- package/lib/commonjs/pushOpen.js +1 -0
- package/lib/commonjs/renderers/ActionPart.js +1 -0
- package/lib/commonjs/renderers/ChartPart.js +1 -0
- package/lib/commonjs/renderers/FigureText.js +1 -0
- package/lib/commonjs/renderers/FiguresPart.js +1 -0
- package/lib/commonjs/renderers/FilePart.js +1 -0
- package/lib/commonjs/renderers/HandoffPart.js +1 -0
- package/lib/commonjs/renderers/ImagePart.js +1 -0
- package/lib/commonjs/renderers/InputRequestPart.js +1 -0
- package/lib/commonjs/renderers/NoticePart.js +1 -0
- package/lib/commonjs/renderers/QuickRepliesPart.js +1 -0
- package/lib/commonjs/renderers/RecordCardPart.js +1 -0
- package/lib/commonjs/renderers/SourcesPart.js +1 -0
- package/lib/commonjs/renderers/TablePart.js +1 -0
- package/lib/commonjs/renderers/TextPart.js +1 -0
- package/lib/commonjs/renderers/TicketPart.js +1 -0
- package/lib/commonjs/renderers/VoiceClipPart.js +1 -0
- package/lib/commonjs/renderers/index.js +1 -0
- package/lib/commonjs/speech/azureSpeech.js +1 -0
- package/lib/commonjs/speech/expoAudio.js +1 -0
- package/lib/commonjs/speech/phoneSpeech.js +1 -0
- package/lib/commonjs/speech/speechText.js +1 -0
- package/lib/commonjs/types.js +1 -0
- package/lib/commonjs/useChat.js +1 -1
- package/lib/commonjs/useChatHaptics.js +1 -0
- package/lib/commonjs/useChatSpeech.js +1 -0
- package/lib/commonjs/useTranscriptActions.js +1 -0
- package/lib/module/AgentByline.js +1 -0
- package/lib/module/ChatComposer.js +1 -0
- package/lib/module/ChatConversationActions.js +1 -0
- package/lib/module/ChatDictationButton.js +1 -0
- package/lib/module/ChatEmbed.js +1 -0
- package/lib/module/ChatEntrance.js +1 -0
- package/lib/module/ChatFooter.js +1 -0
- package/lib/module/ChatFrame.js +1 -0
- package/lib/module/ChatHistory.js +1 -0
- package/lib/module/ChatLiveBar.js +1 -0
- package/lib/module/ChatMessageActions.js +1 -0
- package/lib/module/ChatNudge.js +1 -0
- package/lib/module/ChatOpenTickets.js +1 -0
- package/lib/module/ChatScreen.js +1 -0
- package/lib/module/ChatSheet.js +1 -0
- package/lib/module/ChatStarters.js +1 -0
- package/lib/module/ChatThread.js +1 -0
- package/lib/module/ReadAloudButton.js +1 -0
- package/lib/module/chatShared.js +1 -0
- package/lib/module/features.map.json +40 -0
- package/lib/module/index.js +1 -1
- package/lib/module/loaders/ChatLoader.js +1 -0
- package/lib/module/loaders/OrbLoader.js +1 -0
- package/lib/module/loaders/PhrasesLoader.js +1 -0
- package/lib/module/loaders/SkeletonLoader.js +1 -0
- package/lib/module/loaders/StepsLoader.js +1 -0
- package/lib/module/loaders/TypingPill.js +1 -0
- package/lib/module/pushOpen.js +1 -0
- package/lib/module/renderers/ActionPart.js +1 -0
- package/lib/module/renderers/ChartPart.js +1 -0
- package/lib/module/renderers/FigureText.js +1 -0
- package/lib/module/renderers/FiguresPart.js +1 -0
- package/lib/module/renderers/FilePart.js +1 -0
- package/lib/module/renderers/HandoffPart.js +1 -0
- package/lib/module/renderers/ImagePart.js +1 -0
- package/lib/module/renderers/InputRequestPart.js +1 -0
- package/lib/module/renderers/NoticePart.js +1 -0
- package/lib/module/renderers/QuickRepliesPart.js +1 -0
- package/lib/module/renderers/RecordCardPart.js +1 -0
- package/lib/module/renderers/SourcesPart.js +1 -0
- package/lib/module/renderers/TablePart.js +1 -0
- package/lib/module/renderers/TextPart.js +1 -0
- package/lib/module/renderers/TicketPart.js +1 -0
- package/lib/module/renderers/VoiceClipPart.js +1 -0
- package/lib/module/renderers/index.js +1 -0
- package/lib/module/speech/azureSpeech.js +1 -0
- package/lib/module/speech/expoAudio.js +1 -0
- package/lib/module/speech/phoneSpeech.js +1 -0
- package/lib/module/speech/speechText.js +1 -0
- package/lib/module/types.js +1 -0
- package/lib/module/useChat.js +1 -1
- package/lib/module/useChatHaptics.js +1 -0
- package/lib/module/useChatSpeech.js +1 -0
- package/lib/module/useTranscriptActions.js +1 -0
- package/lib/typescript/commonjs/AgentByline.d.ts +9 -0
- package/lib/typescript/commonjs/ChatComposer.d.ts +14 -0
- package/lib/typescript/commonjs/ChatConversationActions.d.ts +10 -0
- package/lib/typescript/commonjs/ChatDictationButton.d.ts +17 -0
- package/lib/typescript/commonjs/ChatEmbed.d.ts +11 -0
- package/lib/typescript/commonjs/ChatEntrance.d.ts +8 -0
- package/lib/typescript/commonjs/ChatFooter.d.ts +9 -0
- package/lib/typescript/commonjs/ChatFrame.d.ts +39 -0
- package/lib/typescript/commonjs/ChatHistory.d.ts +11 -0
- package/lib/typescript/commonjs/ChatLiveBar.d.ts +11 -0
- package/lib/typescript/commonjs/ChatMessageActions.d.ts +15 -0
- package/lib/typescript/commonjs/ChatNudge.d.ts +14 -0
- package/lib/typescript/commonjs/ChatOpenTickets.d.ts +12 -0
- package/lib/typescript/commonjs/ChatScreen.d.ts +5 -0
- package/lib/typescript/commonjs/ChatSheet.d.ts +21 -0
- package/lib/typescript/commonjs/ChatStarters.d.ts +12 -0
- package/lib/typescript/commonjs/ChatThread.d.ts +34 -0
- package/lib/typescript/commonjs/ReadAloudButton.d.ts +11 -0
- package/lib/typescript/commonjs/chatShared.d.ts +4 -0
- package/lib/typescript/commonjs/index.d.ts +26 -21
- package/lib/typescript/commonjs/loaders/ChatLoader.d.ts +13 -0
- package/lib/typescript/commonjs/loaders/OrbLoader.d.ts +8 -0
- package/lib/typescript/commonjs/loaders/PhrasesLoader.d.ts +8 -0
- package/lib/typescript/commonjs/loaders/SkeletonLoader.d.ts +8 -0
- package/lib/typescript/commonjs/loaders/StepsLoader.d.ts +8 -0
- package/lib/typescript/commonjs/loaders/TypingPill.d.ts +7 -0
- package/lib/typescript/commonjs/pushOpen.d.ts +3 -0
- package/lib/typescript/commonjs/renderers/ActionPart.d.ts +3 -0
- package/lib/typescript/commonjs/renderers/ChartPart.d.ts +8 -0
- package/lib/typescript/commonjs/renderers/FigureText.d.ts +21 -0
- package/lib/typescript/commonjs/renderers/FiguresPart.d.ts +8 -0
- package/lib/typescript/commonjs/renderers/FilePart.d.ts +3 -0
- package/lib/typescript/commonjs/renderers/HandoffPart.d.ts +9 -0
- package/lib/typescript/commonjs/renderers/ImagePart.d.ts +8 -0
- package/lib/typescript/commonjs/renderers/InputRequestPart.d.ts +3 -0
- package/lib/typescript/commonjs/renderers/NoticePart.d.ts +8 -0
- package/lib/typescript/commonjs/renderers/QuickRepliesPart.d.ts +8 -0
- package/lib/typescript/commonjs/renderers/RecordCardPart.d.ts +8 -0
- package/lib/typescript/commonjs/renderers/SourcesPart.d.ts +8 -0
- package/lib/typescript/commonjs/renderers/TablePart.d.ts +8 -0
- package/lib/typescript/commonjs/renderers/TextPart.d.ts +8 -0
- package/lib/typescript/commonjs/renderers/TicketPart.d.ts +9 -0
- package/lib/typescript/commonjs/renderers/VoiceClipPart.d.ts +9 -0
- package/lib/typescript/commonjs/renderers/index.d.ts +3 -0
- package/lib/typescript/commonjs/speech/azureSpeech.d.ts +25 -0
- package/lib/typescript/commonjs/speech/expoAudio.d.ts +23 -0
- package/lib/typescript/commonjs/speech/phoneSpeech.d.ts +16 -0
- package/lib/typescript/commonjs/speech/speechText.d.ts +16 -0
- package/lib/typescript/commonjs/types.d.ts +21 -0
- package/lib/typescript/commonjs/useChat.d.ts +38 -10
- package/lib/typescript/commonjs/useChatHaptics.d.ts +3 -0
- package/lib/typescript/commonjs/useChatSpeech.d.ts +4 -0
- package/lib/typescript/commonjs/useTranscriptActions.d.ts +10 -0
- package/lib/typescript/module/AgentByline.d.ts +9 -0
- package/lib/typescript/module/ChatComposer.d.ts +14 -0
- package/lib/typescript/module/ChatConversationActions.d.ts +10 -0
- package/lib/typescript/module/ChatDictationButton.d.ts +17 -0
- package/lib/typescript/module/ChatEmbed.d.ts +11 -0
- package/lib/typescript/module/ChatEntrance.d.ts +8 -0
- package/lib/typescript/module/ChatFooter.d.ts +9 -0
- package/lib/typescript/module/ChatFrame.d.ts +39 -0
- package/lib/typescript/module/ChatHistory.d.ts +11 -0
- package/lib/typescript/module/ChatLiveBar.d.ts +11 -0
- package/lib/typescript/module/ChatMessageActions.d.ts +15 -0
- package/lib/typescript/module/ChatNudge.d.ts +14 -0
- package/lib/typescript/module/ChatOpenTickets.d.ts +12 -0
- package/lib/typescript/module/ChatScreen.d.ts +5 -0
- package/lib/typescript/module/ChatSheet.d.ts +21 -0
- package/lib/typescript/module/ChatStarters.d.ts +12 -0
- package/lib/typescript/module/ChatThread.d.ts +34 -0
- package/lib/typescript/module/ReadAloudButton.d.ts +11 -0
- package/lib/typescript/module/chatShared.d.ts +4 -0
- package/lib/typescript/module/index.d.ts +26 -21
- package/lib/typescript/module/loaders/ChatLoader.d.ts +13 -0
- package/lib/typescript/module/loaders/OrbLoader.d.ts +8 -0
- package/lib/typescript/module/loaders/PhrasesLoader.d.ts +8 -0
- package/lib/typescript/module/loaders/SkeletonLoader.d.ts +8 -0
- package/lib/typescript/module/loaders/StepsLoader.d.ts +8 -0
- package/lib/typescript/module/loaders/TypingPill.d.ts +7 -0
- package/lib/typescript/module/pushOpen.d.ts +3 -0
- package/lib/typescript/module/renderers/ActionPart.d.ts +3 -0
- package/lib/typescript/module/renderers/ChartPart.d.ts +8 -0
- package/lib/typescript/module/renderers/FigureText.d.ts +21 -0
- package/lib/typescript/module/renderers/FiguresPart.d.ts +8 -0
- package/lib/typescript/module/renderers/FilePart.d.ts +3 -0
- package/lib/typescript/module/renderers/HandoffPart.d.ts +9 -0
- package/lib/typescript/module/renderers/ImagePart.d.ts +8 -0
- package/lib/typescript/module/renderers/InputRequestPart.d.ts +3 -0
- package/lib/typescript/module/renderers/NoticePart.d.ts +8 -0
- package/lib/typescript/module/renderers/QuickRepliesPart.d.ts +8 -0
- package/lib/typescript/module/renderers/RecordCardPart.d.ts +8 -0
- package/lib/typescript/module/renderers/SourcesPart.d.ts +8 -0
- package/lib/typescript/module/renderers/TablePart.d.ts +8 -0
- package/lib/typescript/module/renderers/TextPart.d.ts +8 -0
- package/lib/typescript/module/renderers/TicketPart.d.ts +9 -0
- package/lib/typescript/module/renderers/VoiceClipPart.d.ts +9 -0
- package/lib/typescript/module/renderers/index.d.ts +3 -0
- package/lib/typescript/module/speech/azureSpeech.d.ts +25 -0
- package/lib/typescript/module/speech/expoAudio.d.ts +23 -0
- package/lib/typescript/module/speech/phoneSpeech.d.ts +16 -0
- package/lib/typescript/module/speech/speechText.d.ts +16 -0
- package/lib/typescript/module/types.d.ts +21 -0
- package/lib/typescript/module/useChat.d.ts +38 -10
- package/lib/typescript/module/useChatHaptics.d.ts +3 -0
- package/lib/typescript/module/useChatSpeech.d.ts +4 -0
- package/lib/typescript/module/useTranscriptActions.d.ts +10 -0
- package/package.json +42 -15
- package/README.md +0 -185
- package/lib/commonjs/components/ActionCard.js +0 -1
- package/lib/commonjs/components/ChatComposer.js +0 -1
- package/lib/commonjs/components/ChatConversationList.js +0 -1
- package/lib/commonjs/components/ChatLauncher.js +0 -1
- package/lib/commonjs/components/ChatMarkdown.js +0 -1
- package/lib/commonjs/components/ChatMessage.js +0 -1
- package/lib/commonjs/components/ChatScreen.js +0 -1
- package/lib/commonjs/components/ChatThread.js +0 -1
- package/lib/commonjs/components/ComposerAttachments.js +0 -1
- package/lib/commonjs/components/ReplyRating.js +0 -1
- package/lib/module/components/ActionCard.js +0 -1
- package/lib/module/components/ChatComposer.js +0 -1
- package/lib/module/components/ChatConversationList.js +0 -1
- package/lib/module/components/ChatLauncher.js +0 -1
- package/lib/module/components/ChatMarkdown.js +0 -1
- package/lib/module/components/ChatMessage.js +0 -1
- package/lib/module/components/ChatScreen.js +0 -1
- package/lib/module/components/ChatThread.js +0 -1
- package/lib/module/components/ComposerAttachments.js +0 -1
- package/lib/module/components/ReplyRating.js +0 -1
- package/lib/typescript/commonjs/components/ActionCard.d.ts +0 -23
- package/lib/typescript/commonjs/components/ChatComposer.d.ts +0 -42
- package/lib/typescript/commonjs/components/ChatConversationList.d.ts +0 -22
- package/lib/typescript/commonjs/components/ChatLauncher.d.ts +0 -22
- package/lib/typescript/commonjs/components/ChatMarkdown.d.ts +0 -24
- package/lib/typescript/commonjs/components/ChatMessage.d.ts +0 -55
- package/lib/typescript/commonjs/components/ChatScreen.d.ts +0 -40
- package/lib/typescript/commonjs/components/ChatThread.d.ts +0 -30
- package/lib/typescript/commonjs/components/ComposerAttachments.d.ts +0 -12
- package/lib/typescript/commonjs/components/ReplyRating.d.ts +0 -19
- package/lib/typescript/module/components/ActionCard.d.ts +0 -23
- package/lib/typescript/module/components/ChatComposer.d.ts +0 -42
- package/lib/typescript/module/components/ChatConversationList.d.ts +0 -22
- package/lib/typescript/module/components/ChatLauncher.d.ts +0 -22
- package/lib/typescript/module/components/ChatMarkdown.d.ts +0 -24
- package/lib/typescript/module/components/ChatMessage.d.ts +0 -55
- package/lib/typescript/module/components/ChatScreen.d.ts +0 -40
- package/lib/typescript/module/components/ChatThread.d.ts +0 -30
- package/lib/typescript/module/components/ComposerAttachments.d.ts +0 -12
- package/lib/typescript/module/components/ReplyRating.d.ts +0 -19
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{createConversationList}from"@webority/chat-core";import{formatDate}from"@webority/mobile-core";import{Banner,Button,Card,Dialog,EmptyState,IconButton,Input,Skeleton,Text,useTheme}from"@webority/mobile-ui";import{useCallback,useEffect,useState,useSyncExternalStore}from"react";import{ScrollView,View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const TITLE_MAX_LENGTH=120,EMPTY_LIST_STATE=Object.freeze({items:[],totalCount:null,loading:!1,error:null,hasMore:!1}),NO_SUBSCRIPTION=()=>()=>{};export function ChatHistory({chat:e,labels:t,onOpen:n,testID:l="chat-history"}){const s=useTheme(),[i,a]=useState(null),r=null!==i&&i.client===e.client?i.list:null,o=useCallback(e=>r?r.subscribe(e):NO_SUBSCRIPTION(),[r]),c=useCallback(()=>r?r.getState():EMPTY_LIST_STATE,[r]),u=useSyncExternalStore(o,c),[d,m]=useState(null),[b,p]=useState(""),[h,x]=useState(""),[g,y]=useState(null),[I,S]=useState(""),[f,_]=useState(!1);useEffect(()=>{const t=createConversationList({client:e.client});return a({client:e.client,list:t}),t.load(),()=>t.dispose()},[e.client]);const saveRename=async()=>{if(!d||!r)return;const e=b.trim();if(""!==e){_(!0),x("");try{await r.rename(d.publicId,e),m(null)}catch{x(t.renameFailed)}finally{_(!1)}}},T=!u.loading&&null===u.error&&0===u.items.length;return _jsxs(ScrollView,{contentContainerStyle:{padding:s.space.md,gap:s.space.sm,flexGrow:1},accessibilityLabel:t.history,testID:l,children:[u.error?_jsx(Banner,{tone:"danger",message:u.error.message||t.loadFailed,actions:[{label:t.retry,onPress:()=>{r?.load()}}],testID:`${l}-error`}):null,T?_jsx(EmptyState,{size:"sm",title:t.historyEmptyTitle,description:t.historyEmptyText,testID:`${l}-empty`}):null,u.items.map(i=>{const a=i.title||t.untitled;return _jsx(Card,{variant:"outline",padding:"sm",onPress:()=>(t=>{e.openConversation(t.publicId),n()})(i),accessibilityLabel:a,testID:`${l}-item-${i.publicId}`,children:_jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:s.space.sm},children:[_jsxs(View,{style:{flex:1,minWidth:0},children:[_jsx(Text,{variant:"label",numberOfLines:1,children:a}),_jsx(Text,{variant:"caption",color:"secondary",children:formatDate(i.lastActivityDateTimeUtc)})]}),e.features.Rename?_jsx(IconButton,{icon:"edit",variant:"ghost",accessibilityLabel:t.rename,onPress:()=>{x(""),p(i.title??""),m(i)},testID:`${l}-rename-${i.publicId}`}):null,e.features.Delete?_jsx(IconButton,{icon:"trash",tone:"danger",variant:"ghost",accessibilityLabel:t.deleteChat,onPress:()=>{S(""),y(i)},testID:`${l}-delete-${i.publicId}`}):null]})},i.publicId)}),u.loading&&0===u.items.length?_jsxs(View,{style:{gap:s.space.sm},accessibilityElementsHidden:!0,children:[_jsx(Skeleton,{height:56}),_jsx(Skeleton,{height:56}),_jsx(Skeleton,{height:56})]}):null,!u.loading&&u.hasMore?_jsx(Button,{label:t.loadMore,variant:"outline",onPress:()=>{r?.loadMore()},testID:`${l}-more`}):null,_jsxs(Dialog,{open:null!==d,onClose:()=>{f||m(null)},title:t.rename,dismissOnAction:!1,actions:[{label:t.cancel,tone:"neutral",disabled:f,onPress:()=>m(null)},{label:t.renameSave,disabled:""===b.trim()||f,loading:f,onPress:()=>{saveRename()}}],testID:`${l}-rename`,children:[_jsx(Input,{label:t.conversationTitle,value:b,onChangeText:p,maxLength:120,returnKeyType:"done",onSubmitEditing:()=>{saveRename()},testID:`${l}-rename-input`}),""!==h?_jsx(Text,{variant:"caption",color:"danger",testID:`${l}-rename-error`,children:h}):null]}),_jsx(Dialog,{open:null!==g,onClose:()=>{f||y(null)},tone:"warning",title:t.deleteConfirmTitle,message:I||t.deleteConfirmMessage,dismissOnAction:!1,actions:[{label:t.cancel,tone:"neutral",disabled:f,onPress:()=>y(null)},{label:t.deleteConfirm,tone:"danger",loading:f,onPress:()=>{(async()=>{if(g&&r){_(!0),S("");try{await r.remove(g.publicId),g.publicId===e.conversationId&&e.newConversation(),y(null)}catch{S(t.deleteFailed)}finally{_(!1)}}})()}}],testID:`${l}-confirm`})]})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{Banner,Button,Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const newestAgentName=(e,t)=>{for(let n=e.messages.length-1;n>=0;n-=1){const s=e.messages[n];if("Agent"===s?.author.kind)return s.author.displayName||t}return t};export function ChatLiveBar({chat:e,labels:t,testID:n="chat-live-bar"}){const s=useTheme();if(!e.features.HumanHandoff||null===e.conversationId)return null;const a=e.conversationState;if("Closed"===a)return null;if("Open"===a)return _jsx(View,{accessibilityLiveRegion:"polite",style:{paddingHorizontal:s.space.md,paddingVertical:s.space.xs},testID:n,children:_jsx(Button,{label:t.talkToPerson,variant:"soft",size:"sm",leftIcon:"user",loading:e.handoffPending,disabled:e.streaming||e.thinking,onPress:()=>{e.requestHandoff()},testID:`${n}-talk`})});const i="Lost"===e.live,o="WaitingForAgent"===a?t.handoffWaiting:t.handoffJoined(newestAgentName(e,t.agent));return _jsxs(View,{accessibilityLiveRegion:"polite",style:{gap:s.space.xs,paddingHorizontal:s.space.md,paddingVertical:s.space.xs},testID:n,children:[_jsx(Text,{variant:"caption",color:"secondary",children:o}),i?_jsx(Banner,{tone:"warning",message:t.liveLost,actions:[{label:t.retry,onPress:()=>e.resumeLive()}],testID:`${n}-lost`}):null]})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{buildTranscript,messagePlainText}from"@webority/chat-core";import{copyText}from"@webority/mobile-core/clipboard";import{Button,Text,useTheme}from"@webority/mobile-ui";import{useEffect,useMemo,useRef,useState}from"react";import{View}from"react-native";import{ReadAloudButton}from"./ReadAloudButton.js";import useTranscriptActions from"./useTranscriptActions.js";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";const TEXT_AUTHORS=new Set(["Assistant","Agent","Script"]),RATED_AUTHORS=new Set(["Assistant","Agent"]);export function ChatMessageActions({chat:e,message:t,labels:s,isLast:a,isLastVisitor:i,testID:r}){const n=useTheme(),[o,l]=useState(!1),[c,u]=useState("idle"),d=useRef(null),m=useTranscriptActions(e,s),p=useMemo(()=>TEXT_AUTHORS.has(t.author.kind)&&buildTranscript([t],{labels:s,title:null,figureText:!1}).entries.length>0,[t,s]);if(useEffect(()=>()=>{null!==d.current&&clearTimeout(d.current)},[]),t.streaming)return null;const g=t.parts.filter(e=>"Text"===e.kind).map(e=>e.text).join("\n\n"),f=TEXT_AUTHORS.has(t.author.kind)&&""!==g,h=t.stored&&RATED_AUTHORS.has(t.author.kind),T=("Assistant"===t.author.kind||"Agent"===t.author.kind)&&""!==messagePlainText(t.parts).trim(),x=a&&"Assistant"===t.author.kind&&!e.streaming&&!e.thinking&&e.features.Regenerate&&e.messages.some(e=>e.stored&&"Visitor"===e.author.kind),b=i&&t.stored&&e.features.Edit,save=async s=>{u("idle");try{await e.rate(t.id,s),u("saved")}catch{u("failed")}};return f&&e.features.Copy||p&&e.features.Share&&m.canShare||T||x||b||h&&e.features.Rating?_jsxs(View,{style:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:n.space.xs},testID:r,children:[f&&e.features.Copy?_jsx(Button,{label:o?s.copied:s.copy,variant:"link",size:"sm",onPress:()=>{(async()=>{await copyText(g)&&(l(!0),null!==d.current&&clearTimeout(d.current),d.current=setTimeout(()=>l(!1),2e3))})()},testID:`${r}-copy`}):null,p&&e.features.Share&&m.canShare?_jsx(Button,{label:s.share,variant:"link",size:"sm",leftIcon:"share",disabled:e.streaming||e.thinking,onPress:()=>{m.shareReply(t)},testID:`${r}-share`}):null,T?_jsx(ReadAloudButton,{chat:e,message:t,labels:s}):null,x?_jsx(Button,{label:s.regenerate,variant:"link",size:"sm",onPress:()=>{e.regenerate()},testID:`${r}-regenerate`}):null,b?_jsx(Button,{label:s.edit,variant:"link",size:"sm",onPress:()=>e.startEdit(t.id),testID:`${r}-edit`}):null,h&&e.features.Rating?_jsxs(_Fragment,{children:[_jsx(Button,{label:s.rateUp,size:"sm",leftIcon:"like",variant:"Up"===t.rating?"soft":"ghost",accessibilityState:{selected:"Up"===t.rating},onPress:()=>{save("Up")},testID:`${r}-rate-up`}),_jsx(Button,{label:s.rateDown,size:"sm",leftIcon:"dislike",variant:"Down"===t.rating?"soft":"ghost",accessibilityState:{selected:"Down"===t.rating},onPress:()=>{save("Down")},testID:`${r}-rate-down`}),"failed"===c?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:s.ratingFailed}):null,"saved"===c?_jsx(Text,{variant:"caption",color:"secondary",accessibilityLiveRegion:"polite",children:s.rated}):null]}):null,null!==m.notice?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:m.notice}):null]}):null}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{resolveNudge}from"@webority/chat-core";import{Banner}from"@webority/mobile-ui";import{useEffect,useState}from"react";import{View}from"react-native";import{jsx as _jsx}from"react/jsx-runtime";const LAUNCHER_CLEARANCE=72,EDGE_INSET=16;export function ChatNudge({chat:e,labels:t,enabled:o,onActivate:r,bottomOffset:s,position:i,testID:n="chat-nudge"}){const a=e.profile,u=e.features,l=a?resolveNudge(a,u):null,[c,m]=useState(!1),[f,b]=useState(!1);if(useEffect(()=>{if(!o||!l||c)return void b(!1);const e=setTimeout(()=>b(!0),1e3*l.delaySeconds);return()=>clearTimeout(e)},[o,l,c]),!l||!f||c)return null;return _jsx(View,{style:{position:"absolute",bottom:s+72,..."start"===i?{left:16}:{right:16},maxWidth:320},pointerEvents:"box-none",children:_jsx(Banner,{tone:"info",message:l.text,dismissible:!0,onClose:()=>m(!0),actions:[{label:t.launcher,onPress:r}],testID:n})})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{Card,Chip,Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const SHOWN_AT_MOST=3;export function ChatOpenTickets({chat:e,labels:t,onOpenTicket:s,testID:i="chat-open-tickets"}){const n=useTheme();return e.features.OpenTickets&&0!==e.openTickets.length?_jsxs(View,{accessibilityRole:"list",accessibilityLabel:t.openTickets,style:{gap:n.space.xs},testID:i,children:[_jsx(Text,{variant:"caption",color:"secondary",children:t.openTickets}),e.openTickets.slice(0,3).map(e=>{const n=s?()=>s({ticketId:e.ticketId,number:e.number}):void 0;return _jsxs(Card,{variant:"outline",padding:"sm",interactive:void 0!==n,onPress:n,testID:`${i}-${e.ticketId}`,children:[_jsx(Text,{variant:"label",children:t.ticketAria(e.number)}),_jsx(Text,{variant:"bodySmall",numberOfLines:1,children:e.subject}),_jsx(Chip,{size:"sm",variant:"soft",label:e.status})]},e.ticketId)})]}):null}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{mergeLabels}from"@webority/chat-core";import{useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{ChatFrame}from"./ChatFrame.js";import{jsx as _jsx}from"react/jsx-runtime";export function ChatScreen({chat:e,labels:t,renderers:r,layoutParts:o,loader:a="Steps",motion:s="On",pickAttachments:n,onOpenAttachment:i,onOpenTarget:c,onNavigate:m,openTicket:l,handoffHosts:h,keyboardOffset:f,title:p,headerActions:u,testID:d="chat-screen"}){const b=useTheme();return null===e.profile||e.features.VisitorChat?_jsx(View,{style:{flex:1,backgroundColor:b.colors.bg},testID:d,children:_jsx(ChatFrame,{chat:e,labels:mergeLabels(t),renderers:r,layoutParts:o,loader:a,motion:s,pickAttachments:n,onOpenAttachment:i,onOpenTarget:c,onNavigate:m,openTicket:l,handoffHosts:h,keyboardOffset:f,layout:"screen",title:p,headerActions:u,testID:`${d}-frame`})}):null}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{mergeLabels,messagePlainText}from"@webority/chat-core";import{BottomSheet,FloatingActionButton,useTheme}from"@webority/mobile-ui";import{useEffect,useRef}from"react";import{AccessibilityInfo,findNodeHandle,View}from"react-native";import{ChatFrame}from"./ChatFrame.js";import{ChatNudge}from"./ChatNudge.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DEFAULT_SNAP_POINTS=["92%"];export function ChatSheet({chat:e,labels:t,renderers:s,layoutParts:o,loader:n="Steps",motion:i="On",pickAttachments:a,onOpenAttachment:r,onOpenTarget:l,onNavigate:c,keyboardOffset:u,open:f,defaultOpen:m=!1,onOpenChange:p,position:h="end",bottomOffset:d=16,snapPoints:b=DEFAULT_SNAP_POINTS,compact:g=!1,openTicket:y,handoffHosts:A,conversationId:x,testID:O="chat-sheet"}){const T=useTheme(),j=mergeLabels(t),C=void 0!==f,P=C?f:e.open,I=useRef(null),N=useRef(null),_=useRef(!1),k=useRef(x??null),E=e.setChatVisible;useEffect(()=>{_.current||(_.current=!0,C||!m||null===e.profile||e.open||e.session.open({trigger:"manual"}))},[C,m,e.profile,e.open,e.session]),useEffect(()=>{C&&(f&&!e.open&&e.session.open({trigger:"manual"}),!f&&e.open&&e.session.close("button"))},[C,f,e.open,e.session]);const F=useRef(P);if(useEffect(()=>{if(F.current&&!P){const e=findNodeHandle(I.current);null!==e&&AccessibilityInfo.setAccessibilityFocus(e)}F.current=P},[P]),useEffect(()=>{E(P)},[E,P]),useEffect(()=>{!C&&x&&x!==k.current&&null!==e.profile&&(k.current=x,e.open||(e.session.open({trigger:"manual"}),p?.(!0)))},[C,x,e.profile,e.open,e.session,p]),useEffect(()=>{if(null!==N.current){if(P)for(const t of e.messages){if("Assistant"!==t.author.kind||t.streaming||N.current.has(t.id))continue;N.current.add(t.id);const e=messagePlainText(t.parts);""!==e&&AccessibilityInfo.announceForAccessibility(e)}}else N.current=new Set(e.messages.map(e=>e.id))},[e.messages,P]),null===e.profile||!e.features.VisitorChat)return null;const setOpen=t=>{t?e.session.open({trigger:"manual"}):e.session.close("button"),p?.(t)},S="start"===h?"bottomLeft":"bottomRight";return _jsxs(View,{testID:O,children:[P?null:_jsx(FloatingActionButton,{ref:I,icon:"messages",label:g?void 0:j.launcher,position:S,bottomOffset:d,accessibilityLabel:j.launcher,onPress:()=>setOpen(!0),testID:`${O}-launcher`}),_jsx(ChatNudge,{chat:e,labels:j,enabled:!P&&e.features.Nudges,onActivate:()=>setOpen(!0),bottomOffset:d,position:h,testID:`${O}-nudge`}),_jsx(BottomSheet,{open:P,onClose:()=>setOpen(!1),snapPoints:b,keyboardBehavior:"shift",scrollable:!1,enablePanDownToClose:!0,enableBackdropPress:!0,accessibilityViewIsModal:!0,accessibilityLabel:j.panelTitle,children:_jsx(View,{style:{flex:1,backgroundColor:T.colors.bg},children:_jsx(ChatFrame,{chat:e,labels:j,renderers:s,layoutParts:o,loader:n,motion:i,pickAttachments:a,onOpenAttachment:r,onOpenTarget:l,onNavigate:c,openTicket:y,handoffHosts:A,keyboardOffset:u,layout:"sheet",testID:`${O}-frame`})})})]})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{resolveStart}from"@webority/chat-core";import{formatDate}from"@webority/mobile-core";import{Card,Chip,Text,useTheme}from"@webority/mobile-ui";import{useMemo}from"react";import{View}from"react-native";import{ChatOpenTickets}from"./ChatOpenTickets.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function ChatStarters({chat:e,labels:t,openTicket:s,testID:r="chat-starters"}){const a=useTheme(),i=e.profile,n=null!==e.lastConversation,l=useMemo(()=>i?resolveStart(i,{pathname:i.screen??"/",returning:n}).greeting:"",[i,n]);if(!i)return null;const o=e.features.Starters&&e.features.BehaviourStarters&&e.starters.length>0,c=e.lastConversation,m=e.features.ResumeLast&&null!==c;return _jsxs(View,{style:{flex:1,justifyContent:"center",alignItems:"center",gap:a.space.md,padding:a.space.md},testID:r,children:[_jsx(Text,{variant:"h2",align:"center",children:l}),o?_jsx(View,{accessibilityRole:"none",accessibilityLabel:t.starters,style:{flexDirection:"row",flexWrap:"wrap",justifyContent:"center",gap:a.space.xs},children:e.starters.map(s=>_jsx(Chip,{label:s.label,onPress:()=>{e.submit(s.message)},accessibilityLabel:`${t.starters}: ${s.label}`,testID:`${r}-${s.id}`},s.id))}):null,m&&c?_jsxs(Card,{variant:"outline",padding:"sm",onPress:()=>{e.resumeLast()},testID:`${r}-resume`,children:[_jsx(Text,{variant:"caption",color:"secondary",children:t.resumeLast}),_jsx(Text,{variant:"label",numberOfLines:1,children:c.title||t.untitled}),_jsx(Text,{variant:"caption",color:"secondary",children:formatDate(c.lastActivityDateTimeUtc)})]}):null,_jsx(ChatOpenTickets,{chat:e,labels:t,onOpenTicket:s})]})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{createTurnApi,messagePlainText}from"@webority/chat-core";import{Button,MessageBubble,MessageList,Text,useTheme}from"@webority/mobile-ui";import{createElement,memo,useEffect,useMemo,useRef}from"react";import{AccessibilityInfo,View}from"react-native";import{AgentByline}from"./AgentByline.js";import{ChatEntrance}from"./ChatEntrance.js";import{ChatMessageActions}from"./ChatMessageActions.js";import{defaultOpenTarget,messageSignature}from"./chatShared.js";import{ChatLoader}from"./loaders/ChatLoader.js";import{TypingPill}from"./loaders/TypingPill.js";import{defaultRenderers}from"./renderers/index.js";import{NoticePart}from"./renderers/NoticePart.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const MINE=new Set(["Visitor","Customer"]),joinedText=e=>e.filter(e=>"Text"===e.kind).map(e=>e.text).join("\n\n"),renderPart=(e,t,s,a,r,i)=>{const n=e[t.kind];if(n)return createElement(n,{key:i,part:t,message:s,turn:a,pickAttachments:r});const o={kind:"Notice",code:"NeedsNewerApp",text:a.labels.needsNewerApp};return createElement(NoticePart,{key:i,part:o,message:s,turn:a})},sameMessage=(e,t)=>e.signature===t.signature&&e.message.id===t.message.id&&e.message.rating===t.message.rating&&e.message.stored===t.message.stored&&e.groupPosition===t.groupPosition&&e.isLast===t.isLast&&e.isLastVisitor===t.isLastVisitor&&e.thinking===t.thinking&&e.streaming===t.streaming&&e.pickAttachments===t.pickAttachments&&e.labels===t.labels&&e.all===t.all&&e.layoutParts===t.layoutParts&&e.chat.session===t.chat.session&&e.chat.features===t.chat.features&&e.chat.onNavigate===t.chat.onNavigate&&e.onNavigate===t.onNavigate&&e.onOpenAttachment===t.onOpenAttachment&&e.onOpenTarget===t.onOpenTarget&&e.openTicket===t.openTicket&&e.handoffHosts===t.handoffHosts;function ThreadMessageView({chat:e,message:t,labels:s,all:a,layoutParts:r,groupPosition:i,isLast:n,isLastVisitor:o,pickAttachments:l,onOpenAttachment:g,onOpenTarget:c,onNavigate:p,openTicket:m,handoffHosts:d,testID:h}){const u=useTheme(),f=createTurnApi(e.session,{messageId:t.id,labels:s,openAttachment:g,openTarget:c??defaultOpenTarget,onNavigate:p??e.onNavigate,openTicket:m,handoffHosts:d});let y=0;const nextSlot=()=>(y+=1,y),x=_jsx(ChatMessageActions,{chat:e,message:t,labels:s,isLast:n,isLastVisitor:o,testID:`${h}-actions`});if(MINE.has(t.author.kind)){const e=t.parts.filter(e=>"File"===e.kind),r=_jsxs(View,{style:{gap:u.space.xs},children:[e.map(e=>renderPart(a,e,t,f,l,`${t.id}-file-${nextSlot()}`)),x]});return _jsx(MessageBubble,{side:"mine",text:joinedText(t.parts),labels:{you:s.you},groupPosition:i,footer:r,testID:h})}const T="Agent"===t.author.kind,k=t.author.displayName||s.agent,j=(r?r(t):t.parts).map(e=>Array.isArray(e)?_jsx(View,{style:{flexDirection:"row",flexWrap:"wrap",gap:u.space.xs},children:e.map(e=>renderPart(a,e,t,f,l,`${t.id}-part-${nextSlot()}`))},`${t.id}-group-${nextSlot()}`):renderPart(a,e,t,f,l,`${t.id}-item-${nextSlot()}`)),A=T?[_jsx(AgentByline,{author:t.author,labels:s},`${t.id}-byline`),...j]:j,b=messagePlainText(t.parts);return _jsx(MessageBubble,{side:"theirs",author:T?void 0:s.assistant,text:T?`${s.agentSays(k)} ${b}`:b,streaming:t.streaming,groupPosition:i,footer:x,testID:h,children:A})}const ThreadMessage=memo(ThreadMessageView,sameMessage),TYPING_ORB_MARK=14,TYPING_ASSISTANT_MARK=8,TypingMark=({size:e})=>{const t=useTheme();return _jsx(View,{style:{width:e,height:e,borderRadius:t.radius.pill,backgroundColor:t.colors.primary}})},TurnGap=()=>{const e=useTheme();return _jsx(View,{style:{height:e.space.lg}})},followNew=()=>!0;export function ChatThread({chat:e,labels:t,renderers:s,layoutParts:a,loader:r="Steps",motion:i="On",pickAttachments:n,onOpenAttachment:o,onOpenTarget:l,onNavigate:g,openTicket:c,handoffHosts:p,keyboardAware:m,keyboardOffset:d,empty:h,style:u,testID:f="chat-thread"}){const y=useTheme(),x=useMemo(()=>({...defaultRenderers,...s}),[s]),T=useMemo(()=>e.messages.filter(e=>!(e.streaming&&0===e.parts.length)).reverse(),[e.messages]),k=e.messages[e.messages.length-1]?.id,j=useRef(k);useEffect(()=>{if(k===j.current)return;j.current=k;const s=e.messages[e.messages.length-1];if("Agent"!==s?.author.kind||!s.stored||s.restored||s.streaming)return;const a=s.author.displayName||t.agent;AccessibilityInfo.announceForAccessibility(`${t.agentSays(a)} ${messagePlainText(s.parts)}`)},[k,e.messages,t]);const A=useMemo(()=>{for(let t=e.messages.length-1;t>=0;t-=1){const s=e.messages[t];if(s?.stored&&"Visitor"===s.author.kind)return s.id}},[e.messages]),b=e.streaming||null===e.turnError&&!e.stopped?null:_jsxs(View,{style:{gap:y.space.xs},testID:`${f}-error`,children:[_jsx(Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:e.turnError?.message??t.stopped}),e.features.Retry?_jsx(View,{style:{flexDirection:"row"},children:_jsx(Button,{label:t.retry,variant:"link",size:"sm",onPress:()=>{e.retry()},testID:`${f}-retry`})}):null]}),P=e.thinking&&null!==e.profile?_jsx(ChatLoader,{style:r,steps:e.steps,phrases:e.profile.experience.pacing.thinkingPhrases,intervalMs:e.profile.experience.pacing.phraseIntervalMs,announce:t.preparingAnswer(e.profile.assistant.name),motion:i}):null,w=!0===e.pending?.typing?_jsx(TypingPill,{motion:i,mark:_jsx(TypingMark,{size:"Orb"===r?14:8})}):null,_=null!==e.agentTyping&&"WithAgent"===e.conversationState?_jsxs(View,{style:{gap:y.space.xs,alignSelf:"flex-start"},children:[_jsx(TypingPill,{motion:i,mark:_jsx(TypingMark,{size:8})}),_jsx(Text,{variant:"caption",color:"secondary",accessibilityLiveRegion:"polite",children:t.agentTyping(e.agentTyping.displayName||t.agent)})]}):null,M=w||P||b||_?_jsxs(View,{style:{gap:y.space.sm},children:[w,P,_,b]}):void 0;return _jsx(MessageList,{messages:T,keyExtractor:e=>e.id,renderMessage:({item:s,groupPosition:r})=>_jsx(ChatEntrance,{animate:!s.restored,children:_jsx(ThreadMessage,{chat:e,message:s,signature:messageSignature(s),labels:t,all:x,layoutParts:a,groupPosition:r,isLast:s.id===k,isLastVisitor:s.id===A,thinking:e.thinking,streaming:e.streaming,pickAttachments:n,onOpenAttachment:o,onOpenTarget:l,onNavigate:g,openTicket:c,handoffHosts:p,testID:`${f}-${s.id}`})}),getAuthorKey:e=>e.author.kind,getDate:e=>e.createdDateTimeUtc,followNew:followNew,typing:M,empty:h,ItemSeparatorComponent:TurnGap,keyboardAware:m,keyboardOffset:d,accessibilityLabel:t.thread,style:u,testID:f})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{messagePlainText}from"@webority/chat-core";import{Logger}from"@webority/mobile-core";import{IconButton,Text}from"@webority/mobile-ui";import{useEffect,useMemo,useRef,useState}from"react";import{PhoneSpeechError}from"./speech/phoneSpeech.js";import{useChatSpeech}from"./useChatSpeech.js";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";export function ReadAloudButton({chat:e,message:t,labels:r,testID:o="chat-read-aloud"}){const s=useChatSpeech(e),[a,n]=useState(!1),[i,u]=useState(!1),c=useRef(null),l=useRef(!0),m=useMemo(()=>messagePlainText(t.parts),[t.parts]);if(useEffect(()=>(l.current=!0,()=>{l.current=!1,c.current?.abort()}),[]),!e.features.ReadAloud||null===s||t.streaming||""===m.trim())return null;return _jsxs(_Fragment,{children:[_jsx(IconButton,{icon:a?"stop":"volume-high",accessibilityLabel:a?r.readAloudStop:r.readAloud,variant:"ghost",tone:"neutral",size:"sm",onPress:()=>{if(a)return void c.current?.abort();u(!1);const e=new AbortController;c.current=e,n(!0);(async()=>{try{await s.speak(m,{signal:e.signal})}catch(t){if(!l.current||e.signal.aborted)return;u(!0),t instanceof PhoneSpeechError||Logger.error("[chat] read aloud failed",t)}finally{l.current&&(c.current=null,n(!1))}})()},testID:o}),i?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:r.readAloudFailed}):null]})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{Linking}from"react-native";export function messageSignature(t){let e=0;for(const n of t.parts)"Text"===n.kind&&(e+=n.text.length);return`${t.id}|${t.parts.length}|${e}`}const ABSOLUTE_WEB_URL=/^https?:\/\//i;export function defaultOpenTarget(t){ABSOLUTE_WEB_URL.test(t)&&Linking.openURL(t).catch(()=>{})}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"VisitorChat": "src/ChatFrame.tsx",
|
|
3
|
+
"Starters": "src/ChatStarters.tsx",
|
|
4
|
+
"Nudges": "src/ChatSheet.tsx",
|
|
5
|
+
"ResumeLast": "src/ChatStarters.tsx",
|
|
6
|
+
"OpenTickets": "src/ChatOpenTickets.tsx",
|
|
7
|
+
"History": "src/ChatFrame.tsx",
|
|
8
|
+
"Rename": "src/ChatHistory.tsx",
|
|
9
|
+
"Delete": "src/ChatHistory.tsx",
|
|
10
|
+
"SuggestedReplies": "src/renderers/QuickRepliesPart.tsx",
|
|
11
|
+
"Stop": "src/ChatComposer.tsx",
|
|
12
|
+
"Retry": "src/ChatThread.tsx",
|
|
13
|
+
"Edit": "src/ChatMessageActions.tsx",
|
|
14
|
+
"Regenerate": "src/ChatMessageActions.tsx",
|
|
15
|
+
"Sources": "src/renderers/SourcesPart.tsx",
|
|
16
|
+
"Rating": "src/ChatMessageActions.tsx",
|
|
17
|
+
"Copy": "src/ChatMessageActions.tsx",
|
|
18
|
+
"Share": "src/ChatMessageActions.tsx",
|
|
19
|
+
"Print": null,
|
|
20
|
+
"Attachments": "src/ChatComposer.tsx",
|
|
21
|
+
"RichAnswers": null,
|
|
22
|
+
"InputRequests": null,
|
|
23
|
+
"LeadCapture": null,
|
|
24
|
+
"Booking": null,
|
|
25
|
+
"Scripts": null,
|
|
26
|
+
"AiAnswers": null,
|
|
27
|
+
"HumanHandoff": "src/ChatLiveBar.tsx",
|
|
28
|
+
"Dictation": "src/ChatDictationButton.tsx",
|
|
29
|
+
"ReadAloud": "src/ReadAloudButton.tsx",
|
|
30
|
+
"VoiceClips": "src/renderers/VoiceClipPart.tsx",
|
|
31
|
+
"Sounds": "src/useChatHaptics.ts",
|
|
32
|
+
"AutoOpen": null,
|
|
33
|
+
"BehaviourStarters": "src/ChatStarters.tsx",
|
|
34
|
+
"LeadShortcuts": "src/renderers/InputRequestPart.tsx",
|
|
35
|
+
"LeadRecap": "src/renderers/ActionPart.tsx",
|
|
36
|
+
"FigureText": "src/renderers/TextPart.tsx",
|
|
37
|
+
"LinkHandoff": "src/renderers/QuickRepliesPart.tsx",
|
|
38
|
+
"Explain": null,
|
|
39
|
+
"PanelSwitch": null
|
|
40
|
+
}
|
package/lib/module/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";export{
|
|
1
|
+
"use strict";export{AgentByline}from"./AgentByline.js";export{ChatComposer}from"./ChatComposer.js";export{ChatConversationActions}from"./ChatConversationActions.js";export{ChatDictationButton}from"./ChatDictationButton.js";export{ChatEmbed}from"./ChatEmbed.js";export{ChatFooter}from"./ChatFooter.js";export{ChatHistory}from"./ChatHistory.js";export{ChatLiveBar}from"./ChatLiveBar.js";export{ChatMessageActions}from"./ChatMessageActions.js";export{ChatNudge}from"./ChatNudge.js";export{ChatOpenTickets}from"./ChatOpenTickets.js";export{ChatScreen}from"./ChatScreen.js";export{ChatSheet}from"./ChatSheet.js";export{ChatStarters}from"./ChatStarters.js";export{ChatThread}from"./ChatThread.js";export{defaultOpenTarget,messageSignature}from"./chatShared.js";export{ChatLoader}from"./loaders/ChatLoader.js";export{TypingPill}from"./loaders/TypingPill.js";export{CHAT_PUSH_TYPE,chatConversationIdFromPush}from"./pushOpen.js";export{ReadAloudButton}from"./ReadAloudButton.js";export{defaultRenderers}from"./renderers/index.js";export{useChat}from"./useChat.js";export{useChatSpeech}from"./useChatSpeech.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{LOADER_STYLES,loaderView}from"@webority/chat-core";import{Text,useReducedMotion}from"@webority/mobile-ui";import{useEffect,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{OrbLoader}from"./OrbLoader.js";import{PhrasesLoader}from"./PhrasesLoader.js";import{SkeletonLoader}from"./SkeletonLoader.js";import{StepsLoader}from"./StepsLoader.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const ANNOUNCE_DELAY_MS=500;export function ChatLoader({style:e="Steps",steps:t=[],phrases:r,intervalMs:s,motion:o="On",announce:i,testID:a="chat-loader"}){if(!LOADER_STYLES.includes(e))throw new Error(`ChatLoader style must be one of ${LOADER_STYLES.join(", ")}; got "${e}".`);const c=useReducedMotion(),n="Reduced"===o||c,[u,l]=useState({style:e,count:0});useEffect(()=>{l({style:e,count:0})},[e]),useEffect(()=>{if(n)return;const t=setInterval(()=>{l(t=>({style:e,count:(t.style===e?t.count:0)+1}))},s);return()=>clearInterval(t)},[e,s,n]);const d=useRef(i),[f,m]=useState("");useEffect(()=>{const e=setTimeout(()=>m(d.current),500);return()=>clearTimeout(e)},[]);const L=n||u.style!==e?0:u.count,S=loaderView(e,t,r,L);return _jsxs(View,{accessibilityRole:"progressbar",accessibilityLabel:S.label,accessibilityLiveRegion:"polite",testID:a,children:[loaderBody(e,S,n),_jsx(Text,{accessibilityLiveRegion:"polite",style:styles.announce,children:f})]})}const loaderBody=(e,t,r)=>{switch(e){case"Steps":return _jsx(StepsLoader,{view:t,reduced:r});case"Phrases":return _jsx(PhrasesLoader,{view:t,reduced:r});case"Orb":return _jsx(OrbLoader,{view:t,reduced:r});case"Skeleton":return _jsx(SkeletonLoader,{view:t,reduced:r})}},styles=StyleSheet.create({announce:{position:"absolute",width:1,height:1,opacity:0,overflow:"hidden"}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{Text,useTheme}from"@webority/mobile-ui";import{useEffect,useMemo,useRef}from"react";import{Animated,StyleSheet,View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const CIRCLE=28,HALO=36,HALO_OPACITY=.6,BREATHE_MIN=.92,BREATHE_MAX=1.04,BREATHE_MS=1600;export function OrbLoader({view:e,reduced:t}){const r=useTheme(),i=useMemo(()=>buildStyles(r),[r]),s=useRef(new Animated.Value(t?1:.92)).current;return useEffect(()=>{if(t)return void s.setValue(1);const e=Animated.loop(Animated.sequence([Animated.timing(s,{toValue:1.04,duration:1600,useNativeDriver:!0}),Animated.timing(s,{toValue:.92,duration:1600,useNativeDriver:!0})]));return e.start(),()=>e.stop()},[s,t]),_jsxs(View,{style:i.row,children:[_jsxs(Animated.View,{style:[i.cell,{transform:[{scale:s}]}],children:[_jsx(View,{style:i.halo}),_jsx(View,{style:i.circle})]}),_jsx(Text,{variant:"bodySmall",color:"secondary",children:e.label})]})}const buildStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center",gap:e.space.sm},cell:{width:36,height:36,alignItems:"center",justifyContent:"center"},halo:{position:"absolute",width:36,height:36,borderRadius:e.radius.pill,backgroundColor:e.colors["primary-soft"],opacity:.6},circle:{width:28,height:28,borderRadius:e.radius.pill,backgroundColor:e.colors.primary}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{Text,useTheme}from"@webority/mobile-ui";import{useEffect,useMemo,useRef}from"react";import{Animated,StyleSheet,View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DOT=12,CROSS_FADE_MS=180,LABEL_RISE_PX=8;export function PhrasesLoader({view:e,reduced:t}){const r=useTheme(),s=useMemo(()=>buildStyles(r),[r]),i=useRef(new Animated.Value(1)).current,a=useRef(new Animated.Value(0)).current,l=useRef(e.label);return useEffect(()=>{if(l.current===e.label)return;if(l.current=e.label,t)return i.setValue(1),void a.setValue(0);i.setValue(0),a.setValue(8);const r=Animated.parallel([Animated.timing(i,{toValue:1,duration:180,useNativeDriver:!0}),Animated.timing(a,{toValue:0,duration:180,useNativeDriver:!0})]);return r.start(),()=>r.stop()},[e.label,t,i,a]),_jsxs(View,{style:s.row,children:[_jsx(View,{style:s.dot}),_jsx(Animated.View,{style:[s.label,{opacity:i,transform:[{translateY:a}]}],children:_jsx(Text,{variant:"bodySmall",color:"secondary",numberOfLines:1,children:e.label})})]})}const buildStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center",gap:e.space.sm},dot:{width:12,height:12,borderRadius:e.radius.pill,backgroundColor:e.colors.primary},label:{flexShrink:1}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{Skeleton,Text,useTheme}from"@webority/mobile-ui";import{useMemo}from"react";import{StyleSheet,View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const LINE_HEIGHT=10,BLOCK_HEIGHT=44,LINE_WIDTHS=["92%","78%","85%","40%"];export function SkeletonLoader({view:e,reduced:t}){const s=useTheme(),i=useMemo(()=>buildStyles(s),[s]),o=t?"none":"shimmer";return _jsxs(View,{style:i.root,children:[_jsx(Text,{variant:"caption",color:"secondary",children:e.label}),_jsxs(View,{style:i.body,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:[LINE_WIDTHS.map(e=>_jsx(Skeleton,{shape:"rounded",height:10,width:e,variant:o},e)),_jsx(Skeleton,{shape:"rect",height:44,width:"60%",variant:o})]})]})}const buildStyles=e=>StyleSheet.create({root:{gap:e.space.sm},body:{gap:e.space.xs}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{Spinner,Text,useTheme}from"@webority/mobile-ui";import{useEffect,useMemo,useRef}from"react";import{Animated,StyleSheet,View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const ICON=16,PENDING_DOT=6,PENDING_OPACITY=.4,ROW_FADE_MS=280,CHECK_MARK="✓";export function StepsLoader({view:e,reduced:t}){const s=useTheme(),i=useMemo(()=>buildStyles(s),[s]);return _jsx(View,{accessibilityRole:"list",style:i.list,children:keyedSteps(e.steps).map(({key:s,label:n},r)=>_jsx(StepRow,{label:n,state:stateOf(r,e.activeIndex),reduced:t,styles:i},s))})}const keyedSteps=e=>{const t=new Map;return e.map(e=>{const s=(t.get(e)??0)+1;return t.set(e,s),{key:`${e}\0${s}`,label:e}})},stateOf=(e,t)=>e<t?"done":e===t?"active":"pending",StepRow=({label:e,state:t,reduced:s,styles:i})=>{const n=useRef(new Animated.Value(s?1:0)).current;useEffect(()=>{if(s)return void n.setValue(1);const e=Animated.timing(n,{toValue:1,duration:280,useNativeDriver:!0});return e.start(),()=>e.stop()},[n,s]);const r="active"===t;return _jsxs(Animated.View,{accessibilityState:{busy:r},style:[i.row,{opacity:n}],children:[_jsxs(View,{style:i.icon,children:["done"===t?_jsx(Text,{variant:"bodySmall",color:"secondary",children:"✓"}):null,r?_jsx(Spinner,{size:"sm"}):null,"pending"===t?_jsx(View,{style:i.pendingDot}):null]}),_jsx(Text,r?{variant:"label",color:"primary",children:e}:{variant:"bodySmall",color:"secondary",style:"pending"===t?i.pendingLabel:void 0,children:e})]})},buildStyles=e=>StyleSheet.create({list:{gap:e.space.sm},row:{flexDirection:"row",alignItems:"center",gap:e.space.sm},icon:{width:16,height:16,alignItems:"center",justifyContent:"center"},pendingDot:{width:6,height:6,borderRadius:e.radius.pill,backgroundColor:e.colors["border-subtle"]},pendingLabel:{opacity:.4}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{useReducedMotion,useTheme}from"@webority/mobile-ui";import{useEffect,useMemo,useRef}from"react";import{Animated,StyleSheet,View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DOT=6,LIFT_PX=4,CYCLE_MS=1200,HALF_MS=300,STEP_MS=140,STILL_OPACITY=[1,.65,.3],DOT_INDEXES=[0,1,2];export function TypingPill({motion:e,mark:t}){const i=useTheme(),s=useMemo(()=>buildStyles(i),[i]),o=useReducedMotion(),r="Reduced"===e||o;return _jsxs(View,{style:s.pill,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:[t,_jsx(View,{style:s.dots,children:DOT_INDEXES.map(e=>_jsx(Dot,{index:e,reduced:r,color:i.colors["text-subtle"],size:6},e))})]})}const Dot=({index:e,reduced:t,color:i,size:s})=>{const o=useRef(new Animated.Value(0)).current;useEffect(()=>{if(t)return void o.setValue(0);const i=Animated.loop(Animated.sequence([Animated.delay(140*e),Animated.timing(o,{toValue:1,duration:300,useNativeDriver:!0}),Animated.timing(o,{toValue:0,duration:300,useNativeDriver:!0}),Animated.delay(600-140*e)]));return i.start(),()=>i.stop()},[o,e,t]);const r={width:s,height:s,borderRadius:s/2,backgroundColor:i};if(t)return _jsx(View,{style:[r,{opacity:STILL_OPACITY[e]}]});const n=o.interpolate({inputRange:[0,1],outputRange:[0,-4]});return _jsx(Animated.View,{style:[r,{transform:[{translateY:n}]}]})},buildStyles=e=>StyleSheet.create({pill:{flexDirection:"row",alignItems:"center",alignSelf:"flex-start",gap:e.space.sm,backgroundColor:e.colors["bg-subtle"],borderRadius:e.radius.pill,paddingHorizontal:e.space.md,paddingVertical:e.space.sm},dots:{flexDirection:"row",alignItems:"center",gap:e.space.xs}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export const CHAT_PUSH_TYPE="ChatAgentReplied";const CONVERSATION_ID=/^[0-9a-fA-F-]{36}$/;export function chatConversationIdFromPush(t){if(!t||t.type!==CHAT_PUSH_TYPE)return null;const n=t.conversationId;return"string"==typeof n&&CONVERSATION_ID.test(n)?n:null}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{formatChatDate}from"@webority/chat-core";import{Button,Card,OptionSheet,Text,useTheme}from"@webority/mobile-ui";import{useState}from"react";import{View}from"react-native";import{NoticePart}from"./NoticePart.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const statusLine=(e,t)=>{switch(e.state){case"Confirmed":return t.actionConfirmed;case"Done":return t.actionDone;case"Rejected":return t.actionRejected;case"Expired":return t.actionExpired;case"Failed":return t.actionFailed;case"Repeat":return e.decidedDateTimeUtc?t.actionRepeat(formatChatDate(e.decidedDateTimeUtc)):t.actionDone;case"Pending":return""}};function ActionBody({part:e,turn:t}){const n=useTheme(),{labels:a,features:i}=t,[r,o]=useState(null),[s,c]=useState(""),[l,d]=useState(!1),run=async(e,t)=>{o(e),c("");try{await t()}catch(e){const t=e?.message;c("string"==typeof t&&""!==t?t:a.actionFailed),o(null)}},u=(e.editFields??[]).map(e=>({label:e.label,value:e.id})),m=i.LeadRecap&&u.length>0,p=null!==r;return _jsxs(Card,{variant:"outline",padding:"sm",children:[_jsxs(View,{style:{gap:n.space.sm},children:[_jsx(Text,{variant:"label",children:e.title}),e.lines.map(e=>_jsx(Text,{variant:"bodySmall",children:e},e)),e.consentText?_jsx(Text,{variant:"caption",color:"secondary",children:e.consentText}):null,"Pending"===e.state?_jsxs(_Fragment,{children:[""!==s?_jsx(Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:s}):null,_jsxs(View,{style:{flexDirection:"row",flexWrap:"wrap",gap:n.space.sm},children:[_jsx(Button,{label:"confirm"===r?a.actionWorking:e.confirmLabel??a.actionConfirm,loading:"confirm"===r,disabled:p,onPress:()=>{run("confirm",()=>t.confirmAction(e.actionId))}}),_jsx(Button,{label:e.rejectLabel??a.actionDismiss,variant:"ghost",disabled:p,onPress:()=>{run("reject",()=>t.rejectAction(e.actionId))}}),m?_jsx(Button,{label:a.editSomething,variant:"ghost",disabled:p,onPress:()=>d(!0)}):null]})]}):_jsx(Text,{variant:"bodySmall",color:"secondary",children:statusLine(e,a)}),e.note?_jsx(Text,{variant:"caption",color:"secondary",children:e.note}):null]}),m?_jsx(OptionSheet,{open:l,onClose:()=>d(!1),title:a.editSomething,options:u,onChange:(e,n)=>{d(!1),t.chooseQuickReply({id:`lead.edit:${String(n.value)}`,label:n.label,action:"Send",target:null,navigateAfterMs:null,icon:null,variant:null})}}):null]})}export function ActionPart(e){const{part:t,message:n,turn:a}=e;if("Action"!==t.kind){const e={kind:"Notice",code:"NeedsNewerApp",text:a.labels.needsNewerApp};return _jsx(NoticePart,{part:e,message:n,turn:a})}return _jsx(ActionBody,{part:t,turn:a},t.actionId)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{formatFigure,toFigureText}from"@webority/chat-core";import{formatCompactNumber,formatNumber,formatPercent}from"@webority/mobile-core";import{BarChart,ProgressBar,Sparkline,Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{FigureText,runsToText}from"./FigureText.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const TONES=["primary","info","success","warning","danger","neutral"],toneAt=e=>TONES[e%TONES.length]??"primary",withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]),writeValue=(e,t)=>{const r=0!==e&&Math.abs(e)<.001?runsToText(formatFigure(e)):formatNumber(e,{maximumFractionDigits:2});return t?`${r} ${t}`:r};export function ChartPart({part:e,turn:t}){const r=useTheme();if(e.series.every(e=>0===e.points.length))return null;const{unit:a}=e,i=e.title?toFigureText(e.title):t.labels.chart,l=e.series.length>1;return _jsxs(View,{accessibilityLabel:i,style:{gap:r.space.sm},children:[e.title?_jsx(FigureText,{text:e.title,variant:"label",color:"primary",strong:!0}):null,withPositions(e.series).map(({key:s,item:o})=>{const n=toneAt(s),c=toFigureText(o.name)||i,u=o.points;if(0===u.length)return _jsxs(View,{style:{gap:r.space.xs},children:[l?_jsx(Text,{variant:"caption",color:"secondary",children:toFigureText(o.name)}):null,_jsx(Text,{variant:"bodySmall",color:"secondary",children:t.labels.chartEmpty})]},s);const m=u.map(e=>e.value),x=m.reduce((e,t)=>Math.min(e,t)),h=m.reduce((e,t)=>Math.max(e,t)),p=u[0],g=u[u.length-1];let b;if("Bar"===e.chartType)b=_jsx(BarChart,{data:u.map(e=>({label:toFigureText(e.label),value:e.value})),height:u.length>4?300:240,label:c,formatValue:e=>writeValue(e,a),formatTick:e=>a?`${formatCompactNumber(e)} ${a}`:formatCompactNumber(e),tone:n});else if("Line"===e.chartType)b=_jsxs(View,{style:{gap:r.space.xs},children:[_jsx(Sparkline,{data:m,height:160,fill:!0,tone:n,label:c,formatLabel:e=>writeValue(e,a)}),_jsxs(View,{style:{flexDirection:"row",justifyContent:"space-between"},children:[_jsx(Text,{variant:"caption",color:"tertiary",children:toFigureText(p.label)}),u.length>1?_jsx(Text,{variant:"caption",color:"tertiary",children:toFigureText(g.label)}):null]}),_jsx(Text,{variant:"caption",color:"secondary",children:`${t.labels.chartLow(writeValue(x,a))} ${t.labels.chartHigh(writeValue(h,a))}`})]});else{const e=m.reduce((e,t)=>e+(Number.isFinite(t)&&t>0?t:0),0);b=_jsx(View,{accessibilityRole:"list",style:{gap:r.space.sm},children:withPositions(u).map(({key:t,item:r})=>{const i=e>0&&Number.isFinite(r.value)&&r.value>0?r.value/e:0;return _jsx(ProgressBar,{progress:i,height:8,tone:toneAt(t),label:_jsx(FigureText,{text:r.label,variant:"bodySmall"}),valueLabel:`${writeValue(r.value,a)} (${formatPercent(i,{maximumFractionDigits:0})})`},t)})})}return _jsxs(View,{style:{gap:r.space.xs},children:[l?_jsx(Text,{variant:"caption",color:"secondary",children:toFigureText(o.name)}):null,b]},s)})]})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{toFigureRuns}from"@webority/chat-core";import{Text,useTheme}from"@webority/mobile-ui";import{Fragment,useMemo}from"react";import{Text as RNText,View}from"react-native";import{jsx as _jsx}from"react/jsx-runtime";const sizeStepOf=t=>"caption"===t?"xs":"bodySmall"===t||"label"===t?"sm":"title"===t?"lg":"base",inkFor=(t,e)=>"secondary"===e?t.colors["text-muted"]:"tertiary"===e?t.colors["text-subtle"]:"success"===e||"warning"===e||"danger"===e||"info"===e?t.colors[`${e}-text`]:t.colors["text-body"];export function runsToText(t){return t.map(t=>t.text).join("")}const withOffsets=t=>t.reduce((t,e)=>{const r=t[t.length-1],n=r?r.offset+r.run.text.length:0;return t.push({offset:n,run:e}),t},[]);function runNode(t,e,r){if("text"===t.kind)return t.text;const n="sub"===t.kind?Math.round(.4*e):-Math.round(.45*e),o=Math.round(.75*e);return _jsx(View,{style:{transform:[{translateY:n}]},children:_jsx(RNText,{style:{fontSize:o,lineHeight:o,includeFontPadding:!1,color:r},children:t.text})})}export function FigureRuns({runs:t,variant:e="bodySmall",color:r,strong:n=!1,numberOfLines:o,accessibilityLabel:s,testID:i}){const u=useTheme(),a=u.text[sizeStepOf(e)].size,c=inkFor(u,r);return _jsx(Text,{variant:e,color:r,weight:n?"semibold":void 0,numberOfLines:o,testID:i,accessibilityLabel:s??runsToText(t),children:withOffsets(t).map(({offset:t,run:e})=>_jsx(Fragment,{children:runNode(e,a,c)},t))})}export function FigureText({text:t,variant:e="bodySmall",...r}){const n=useMemo(()=>toFigureRuns(t),[t]);return _jsx(FigureRuns,{runs:n,variant:e,...r})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{formatFigure,toFigureText}from"@webority/chat-core";import{formatNumber}from"@webority/mobile-core";import{StatTile,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{FigureRuns,runsToText}from"./FigureText.js";import{jsx as _jsx}from"react/jsx-runtime";const TONE={Neutral:"neutral",Positive:"success",Caution:"warning",Negative:"danger"},withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]),valueRunsOf=e=>{const t=0!==e.value&&Math.abs(e.value)<.001?formatFigure(e.value):[{kind:"text",text:formatNumber(e.value,{maximumFractionDigits:2})}];return e.unit?[...t,{kind:"text",text:` ${e.unit}`}]:t};export function FiguresPart({part:e,turn:t}){const i=useTheme();return 0===e.figures.length?null:_jsx(View,{accessibilityRole:"list",accessibilityLabel:t.labels.figures,style:{flexDirection:"row",flexWrap:"wrap",gap:i.space.sm},children:withPositions(e.figures).map(({key:e,item:i})=>{const r=valueRunsOf(i),s=t.labels.figureStatus(i.status),a=toFigureText(i.label);return _jsx(View,{style:{flexBasis:"48%",flexGrow:1,minWidth:140},children:_jsx(StatTile,{label:a,value:_jsx(FigureRuns,{runs:r,variant:"title",color:"primary",strong:!0}),tone:TONE[i.status],caption:s||void 0,accessibilityLabel:`${a}: ${runsToText(r)}${s?`, ${s}`:""}`})},e)})})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{formatFileSize}from"@webority/chat-core";import{Chip}from"@webority/mobile-ui";import{NoticePart}from"./NoticePart.js";import{jsx as _jsx}from"react/jsx-runtime";export function FilePart(e){const{part:t,message:i,turn:r}=e;if("File"!==t.kind){const e={kind:"Notice",code:"NeedsNewerApp",text:r.labels.needsNewerApp};return _jsx(NoticePart,{part:e,message:i,turn:r})}const{openAttachment:o}=r;return _jsx(Chip,{label:`${t.fileName} (${formatFileSize(t.length)})`,leftIcon:"paperclip",variant:"soft",size:"sm",accessibilityLabel:r.labels.fileOpen(t.fileName),onPress:o?()=>o(t):void 0})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{Avatar,Card,Spinner,Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function HandoffPart({part:e,turn:a}){const i=useTheme(),{labels:s}=a,t=!a.isLast&&("Requested"===e.state||"Waiting"===e.state),n=e.agent?.displayName||s.agent,r=e.agent?.avatarUrl;let o;switch(e.state){case"Requested":o=_jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:i.space.sm},children:[_jsx(Spinner,{size:"sm"}),_jsx(Text,{variant:"bodySmall",children:s.handoffRequested})]});break;case"Waiting":o=_jsxs(View,{style:{gap:i.space.xs},children:[_jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:i.space.sm},children:[_jsx(Spinner,{size:"sm"}),_jsx(Text,{variant:"label",children:s.handoffWaiting})]}),"number"==typeof e.queuePosition?_jsx(Text,{variant:"caption",color:"secondary",children:s.handoffQueued(e.queuePosition)}):null,_jsx(Text,{variant:"caption",color:"secondary",children:s.handoffQueuedText})]});break;case"Joined":o=_jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:i.space.sm},children:[_jsx(Avatar,{size:"sm",name:n,source:r?{uri:r}:void 0}),_jsx(Text,{variant:"label",children:s.handoffJoined(n)})]});break;case"Left":o=_jsx(Text,{variant:"bodySmall",children:s.handoffLeft(n)});break;case"Ended":o=_jsx(Text,{variant:"bodySmall",children:s.handoffEnded})}return _jsx(Card,{variant:"outline",padding:"sm",accessibilityLiveRegion:t?void 0:"polite",children:o})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{AuthedImage,Button,Modal,Text,useTheme,ZoomableImage}from"@webority/mobile-ui";import{useState}from"react";import{Pressable,View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const DEFAULT_RATIO=4/3;export function ImagePart({part:e,turn:t}){const a=useTheme(),s=useSafeAreaInsets(),[i,l]=useState(!1),r=t.attachmentUrl?t.attachmentUrl(e.attachmentId):void 0;if(void 0===r)return _jsx(Text,{variant:"bodySmall",color:"secondary",children:e.alt});const o=null!==e.width&&null!==e.height&&e.width>0&&e.height>0?e.width/e.height:DEFAULT_RATIO,n=_jsx(Text,{variant:"bodySmall",color:"secondary",children:e.alt});return _jsxs(_Fragment,{children:[_jsx(Pressable,{accessibilityRole:"imagebutton",accessibilityLabel:t.labels.imageOpen(e.alt),onPress:()=>l(!0),children:_jsx(AuthedImage,{uri:r,contentFit:"cover",accessible:!0,accessibilityLabel:e.alt,style:{width:"100%",aspectRatio:o,maxHeight:320,borderRadius:a.radius.md},fallback:n})}),_jsx(Modal,{open:i,onClose:()=>l(!1),backdropPressClose:!1,presentation:"fullScreen",accessibilityLabel:e.alt,children:_jsxs(View,{style:{flex:1,backgroundColor:a.colors.bg},children:[_jsx(ZoomableImage,{style:{flex:1},accessibilityLabel:e.alt,children:_jsx(AuthedImage,{uri:r,contentFit:"contain",style:{flex:1},accessibilityLabel:e.alt})}),_jsx(View,{style:{position:"absolute",top:s.top+a.space.sm,right:a.space.sm},children:_jsx(Button,{variant:"soft",size:"sm",label:t.labels.close,onPress:()=>l(!1)})})]})})]})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{Button,Card,Checkbox,Chip,ChoiceGroup,Input,ProgressBar,Text,useTheme}from"@webority/mobile-ui";import{useState}from"react";import{View}from"react-native";import{NoticePart}from"./NoticePart.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const FIELD_TYPES=new Set(["Email","Phone","Name","Company","Text","LongText","Choice","MultiChoice","TimeSlot","File","Consent"]),isUndrawnField=(e,t)=>!FIELD_TYPES.has(e.type)||"File"===e.type&&!t,fileNameOf=(e,t)=>{const i=e.name;return"string"==typeof i&&""!==i?i:t},slotFormat=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short",hour:"numeric",minute:"2-digit"}),selectedIds=e=>""===e?[]:JSON.parse(e),KEYBOARD_TYPES={Email:"email-address",Phone:"phone-pad"},AUTO_COMPLETE={Email:"email",Phone:"tel",Name:"name",Company:"organization"},optionalSuffix=(e,t)=>e.required?"":` (${t.inputOptional})`;function OpenRequest({part:e,turn:t,pickAttachments:i}){const a=useTheme(),{labels:s,features:l}=t,[r,n]=useState({}),[o,c]=useState({}),[p,d]=useState(""),[u,y]=useState(!1),[m,x]=useState({}),setValue=(e,t)=>n(i=>({...i,[e]:t})),patchUpload=(e,t)=>x(i=>{const a=i[e];return a?{...i,[e]:{...a,...t}}:i}),h=Object.values(m).some(e=>"Ready"!==e.status),leave=async e=>{y(!0),d("");try{await e()}catch{d(s.errorGeneric),y(!1)}},b=l.LeadShortcuts,f=b&&1===e.fields.length&&!e.fields[0].required,g=b&&e.cancellable;return _jsx(Card,{variant:"outline",padding:"sm",children:_jsxs(View,{style:{gap:a.space.sm},children:[e.title?_jsx(Text,{variant:"label",children:e.title}):null,b&&e.allowTyped?_jsx(Text,{variant:"caption",color:"secondary",children:s.typeAnswer}):null,e.fields.map(e=>{const l=r[e.key]??"",n=o[e.key];if("File"===e.type){const l=m[e.key];return _jsxs(View,{style:{gap:a.space.xs},children:[_jsx(Text,{variant:"label",children:`${e.label}${optionalSuffix(e,s)}`}),l?_jsxs(View,{style:{gap:a.space.xxs},children:[_jsx(Chip,{label:l.fileName,variant:"soft",onRemove:"Uploading"===l.status?void 0:()=>{return t=e.key,x(e=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t))),void setValue(t,"");var t},labels:{remove:s.inputRemoveFile}}),"Uploading"===l.status?_jsx(ProgressBar,{progress:l.progress??void 0,label:s.attachmentUploading,height:4}):null,"Failed"===l.status?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:s.attachmentFailed}):null]}):_jsx(View,{style:{flexDirection:"row"},children:_jsx(Button,{label:s.inputChooseFile,variant:"soft",size:"sm",leftIcon:"paperclip",disabled:u,onPress:()=>{(async e=>{if(!i)return;let a;try{a=await i()}catch{return void d(s.errorGeneric)}const l=a[0];if(l){x(t=>({...t,[e.key]:{fileName:fileNameOf(l,e.label),status:"Uploading",progress:null}}));try{const i=await t.uploadInputFile(l,t=>patchUpload(e.key,{progress:t}));setValue(e.key,i),patchUpload(e.key,{status:"Ready",progress:null})}catch{setValue(e.key,""),patchUpload(e.key,{status:"Failed",progress:null})}}})(e)}})}),n?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:n}):null]},e.key)}if("MultiChoice"===e.type){const t=(e.options??[]).map(e=>({label:e.label,value:e.id}));return _jsxs(View,{style:{gap:a.space.xs},children:[_jsx(Text,{variant:"label",children:`${e.label}${optionalSuffix(e,s)}`}),_jsx(ChoiceGroup,{selectionMode:"multiple",options:t,value:selectedIds(l),onChange:i=>setValue(e.key,JSON.stringify(t.filter(e=>i.includes(e.value)).map(e=>e.value))),accessibilityLabel:e.label,error:n,disabled:u})]},e.key)}if("Choice"===e.type||"TimeSlot"===e.type){const t="TimeSlot"===e.type?(e.slots??[]).map(e=>({label:slotFormat.format(new Date(e.startDateTimeUtc)),value:e.id})):(e.options??[]).map(e=>({label:e.label,value:e.id}));return _jsxs(View,{style:{gap:a.space.xs},children:[_jsx(Text,{variant:"label",children:`${e.label}${optionalSuffix(e,s)}`}),_jsx(ChoiceGroup,{options:t,value:""===l?void 0:l,onChange:t=>setValue(e.key,String(t)),accessibilityLabel:e.label,error:n,disabled:u})]},e.key)}return"Consent"===e.type?_jsx(Checkbox,{checked:"true"===l,onChange:t=>setValue(e.key,t?"true":"false"),label:`${e.consentText??e.label}${optionalSuffix(e,s)}`,error:n,disabled:u},e.key):_jsx(Input,{label:e.label,placeholder:e.placeholder??void 0,value:l,onChangeText:t=>setValue(e.key,t),maxLength:e.maxLength??void 0,required:e.required,error:n,help:e.required?void 0:s.inputOptional,labelMode:"top",disabled:u,type:"LongText"===e.type?"textarea":e.secret?"password":"input",keyboardType:KEYBOARD_TYPES[e.type]??"default",autoCapitalize:"Email"===e.type?"none":void 0,autoComplete:AUTO_COMPLETE[e.type]},e.key)}),""!==p?_jsx(Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:p}):null,_jsxs(View,{style:{flexDirection:"row",flexWrap:"wrap",gap:a.space.sm},children:[_jsx(Button,{label:u?s.inputSubmitting:e.submitLabel,loading:u,disabled:u||h,onPress:()=>{(async()=>{if(h)return;const i={},a={};for(const t of e.fields){const e=r[t.key]??"";if("Consent"===t.type){const l="true"===e;t.required&&!l&&(i[t.key]=s.inputConsentRequired),a[t.key]=l?"true":"false"}else if("Choice"===t.type||"TimeSlot"===t.type)t.required&&""===e&&(i[t.key]=s.inputRequired),a[t.key]=e;else if("MultiChoice"===t.type){const l=selectedIds(e);t.required&&0===l.length&&(i[t.key]=s.inputRequired),a[t.key]=JSON.stringify(l)}else if("File"===t.type)t.required&&""===e&&(i[t.key]=s.inputRequired),a[t.key]=e;else{const l=e.trim();t.required&&""===l&&(i[t.key]=s.inputRequired),a[t.key]=l}}if(c(i),!(Object.keys(i).length>0)){y(!0),d("");try{const i=await t.answerInput(e.requestId,a);if(i.ok)return;c(i.errors),d(i.message??"")}catch{d(s.errorGeneric)}y(!1)}})()}}),f?_jsx(Button,{label:s.skip,variant:"ghost",disabled:u,onPress:()=>{leave(()=>t.skipInput(e.requestId))}}):null,g?_jsx(Button,{label:s.cancel,variant:"ghost",disabled:u,onPress:()=>{leave(()=>t.cancelLead())}}):null]})]})})}export function InputRequestPart(e){const{part:t,message:i,turn:a,pickAttachments:s}=e,l=void 0!==s;if("InputRequest"!==t.kind||t.fields.some(e=>isUndrawnField(e,l))){const e={kind:"Notice",code:"NeedsNewerApp",text:a.labels.needsNewerApp};return _jsx(NoticePart,{part:e,message:i,turn:a})}return"Answered"===t.state?_jsx(Text,{variant:"bodySmall",color:"secondary",children:t.answeredSummary??a.labels.inputAnswered}):"Skipped"===t.state?_jsx(Text,{variant:"bodySmall",color:"secondary",children:a.labels.inputSkipped}):"Expired"===t.state?_jsx(Text,{variant:"bodySmall",color:"secondary",children:a.labels.inputExpired}):_jsx(OpenRequest,{part:t,turn:a,pickAttachments:s},t.requestId)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{Banner}from"@webority/mobile-ui";import{jsx as _jsx}from"react/jsx-runtime";export function NoticePart({part:t}){const e="ActionLimitReached"===t.code||"AssistantUnavailable"===t.code?"warning":"info";return _jsx(Banner,{message:t.text,tone:e,accessibilityRole:"summary"})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{isHandoffTarget}from"@webority/chat-core";import{Chip,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{ChatEntrance}from"../ChatEntrance.js";import{defaultOpenTarget}from"../chatShared.js";import{jsx as _jsx}from"react/jsx-runtime";function lookOf(e){switch(e){case"Primary":return{variant:"soft",tone:"primary"};case"Cta":return{variant:"solid",tone:"primary"};default:return{variant:"outline"}}}export function QuickRepliesPart({part:e,turn:t}){const a=useTheme();if(!t.features.SuggestedReplies||!t.isLast||t.busy||t.handoffPause||0===e.replies.length)return null;const n=t.openTarget,r=void 0!==n&&n!==defaultOpenTarget;return _jsx(View,{accessibilityRole:"list",accessibilityLabel:t.labels.quickReplies,style:{flexDirection:"row",flexWrap:"wrap",gap:a.space.xs},children:e.replies.map((e,a)=>{const i=lookOf(e.variant),o=e.icon?e.icon:void 0;if("Send"===e.action)return _jsx(ChatEntrance,{index:a,children:_jsx(Chip,{label:e.label,variant:i.variant,tone:i.tone,leftIcon:o,onPress:()=>t.chooseQuickReply(e)})},e.id);const s=e.target;if("Open"===e.action&&s&&n)return _jsx(ChatEntrance,{index:a,children:_jsx(Chip,{label:e.label,variant:i.variant,tone:i.tone,leftIcon:o,onPress:()=>n(s)})},e.id);if("Navigate"===e.action&&t.features.LinkHandoff&&s&&n){const l=isHandoffTarget(s,t.handoffHosts)&&(!s.startsWith("/")||r);return _jsx(ChatEntrance,{index:a,children:_jsx(Chip,{label:e.label,variant:i.variant,tone:i.tone,leftIcon:o,onPress:l?()=>t.beginHandoff(e,()=>n(s)):void 0})},e.id)}return null})})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{formatChatValue}from"@webority/chat-core";import{Card,useTheme}from"@webority/mobile-ui";import{StyleSheet,View}from"react-native";import{FigureText}from"./FigureText.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]);export function RecordCardPart({part:e,turn:t}){const r=useTheme(),i=void 0!==t.openRecord&&null!==e.target;return _jsx(Card,{variant:"outline",padding:"sm",accessibilityRole:i?"button":"summary",accessibilityLabel:i?t.labels.recordOpenFor(e.title):void 0,onPress:i?()=>t.openRecord?.(e):void 0,children:_jsxs(View,{style:{gap:r.space.xs},children:[_jsx(FigureText,{text:e.title,variant:"label",color:"primary",strong:!0,numberOfLines:2}),e.subtitle?_jsx(FigureText,{text:e.subtitle,variant:"bodySmall",color:"secondary"}):null,withPositions(e.fields).map(({key:e,item:t})=>_jsxs(View,{style:{gap:r.space.xs},children:[e>0?_jsx(View,{style:{height:StyleSheet.hairlineWidth,backgroundColor:r.colors["border-subtle"]}}):null,_jsxs(View,{style:{flexDirection:"row",justifyContent:"space-between",gap:r.space.sm},children:[_jsx(View,{style:{flexShrink:1},children:_jsx(FigureText,{text:t.label,variant:"caption",color:"secondary"})}),_jsx(View,{style:{flex:1,alignItems:"flex-end"},children:_jsx(FigureText,{text:formatChatValue(t.value,t.type,null),variant:"bodySmall",color:"primary"})})]})]},e))]})})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{Chip,Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{ChatEntrance}from"../ChatEntrance.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const HTTP_LINK=/^https?:\/\//i;export function SourcesPart({part:e,turn:s}){const r=useTheme();if(!s.features.Sources||0===e.sources.length)return null;const t=s.openTarget;return _jsxs(View,{accessibilityRole:"list",accessibilityLabel:s.labels.sources,style:{gap:r.space.xs},children:[_jsx(Text,{variant:"caption",color:"secondary",children:s.labels.sources}),_jsx(View,{style:{flexDirection:"row",flexWrap:"wrap",gap:r.space.xs},children:e.sources.map((e,r)=>{const i=e.url;return _jsx(ChatEntrance,{index:r,children:_jsx(Chip,{label:`${e.marker} ${e.title}`,variant:"outline",size:"sm",accessibilityLabel:s.labels.openSource(e.title),onPress:null!==i&&HTTP_LINK.test(i)&&t?()=>t(i):void 0})},e.marker)})})]})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{formatChatValue,toFigureText}from"@webority/chat-core";import{Button,Card,Text,useTheme}from"@webority/mobile-ui";import{useState}from"react";import{ScrollView,StyleSheet,View}from"react-native";import{FigureText}from"./FigureText.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const PREVIEW_ROWS=10,COLUMN_WIDTH={Text:140,Integer:88,Decimal:96,MoneyMinor:112,Percent:80,Date:112,DateTimeUtc:152},NUMERIC=new Set(["Integer","Decimal","MoneyMinor","Percent"]),withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]);export function TablePart({part:e,turn:t}){const r=useTheme(),[i,l]=useState(!1);if(0===e.columns.length||0===e.rows.length)return null;const s=i?e.rows:e.rows.slice(0,10),n={height:StyleSheet.hairlineWidth,backgroundColor:r.colors["border-subtle"]},o={paddingVertical:r.space.xs,paddingHorizontal:r.space.sm},cellValue=(t,r,i)=>{const l=t[r];return null==l?null:formatChatValue(l,i.type,e.currency)};return _jsxs(View,{accessibilityLabel:e.title?toFigureText(e.title):t.labels.table,style:{gap:r.space.xs},children:[e.title?_jsx(FigureText,{text:e.title,variant:"label",color:"primary",strong:!0}):null,_jsx(Card,{variant:"outline",padding:"sm",children:_jsx(ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!0,nestedScrollEnabled:!0,children:_jsxs(View,{children:[_jsx(View,{style:{flexDirection:"row"},children:e.columns.map(e=>_jsx(View,{style:[o,{width:COLUMN_WIDTH[e.type],alignItems:NUMERIC.has(e.type)?"flex-end":"flex-start"}],children:_jsx(FigureText,{text:e.label,variant:"label",color:"secondary",strong:!0,numberOfLines:2})},e.key))}),_jsx(View,{style:n}),withPositions(s).map(({key:t,item:r})=>{const i=e.columns.map((e,t)=>`${toFigureText(e.label)}: ${cellValue(r,t,e)??"-"}`).join(", ");return _jsxs(View,{accessible:!0,accessibilityLabel:i,children:[_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:"row"},children:e.columns.map((e,t)=>{const i=cellValue(r,t,e);return _jsx(View,{style:[o,{width:COLUMN_WIDTH[e.type],alignItems:NUMERIC.has(e.type)?"flex-end":"flex-start"}],children:null===i?_jsx(Text,{variant:"bodySmall",color:"tertiary",children:"-"}):_jsx(FigureText,{text:i,variant:"bodySmall",color:"primary",numberOfLines:3})},e.key)})}),_jsx(View,{style:n})]},t)})]})})}),!i&&e.rows.length>10?_jsx(Button,{variant:"link",size:"sm",label:t.labels.tableShowAll(e.rows.length),onPress:()=>l(!0)}):null]})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{isHandoffTarget}from"@webority/chat-core";import{Markdown,Text}from"@webority/mobile-ui";import{FigureText}from"./FigureText.js";import{jsx as _jsx}from"react/jsx-runtime";const CITATION=/^\d+$/;export function TextPart({part:t,message:e,turn:r}){return"Visitor"===e.author.kind||"Customer"===e.author.kind?r.features.FigureText?_jsx(FigureText,{text:t.text,variant:"body",color:"primary"}):_jsx(Text,{variant:"body",children:t.text}):_jsx(Markdown,{links:"app",headings:"text",resolveLink:t=>r.openTarget&&isHandoffTarget(t,r.handoffHosts)?t:null,onAppLinkPress:t=>r.openTarget?.(t),isCitation:t=>CITATION.test(t),onOpenCitation:r.openCitation?t=>r.openCitation?.(Number(t)):void 0,children:t.text})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{Card,Chip,Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function TicketPart({part:e,turn:t}){const i=useTheme(),{labels:s,openTicket:r}=t,a=s.ticketAria(e.number),n=r?()=>r({ticketId:e.ticketId,number:e.number}):void 0;return _jsx(Card,{variant:"outline",padding:"sm",interactive:void 0!==n,onPress:n,accessibilityLabel:`${a}, ${e.status}`,children:_jsxs(View,{style:{gap:i.space.xs},children:[_jsxs(View,{style:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:i.space.sm},children:[_jsx(Text,{variant:"label",children:a}),_jsx(Chip,{size:"sm",variant:"soft",label:e.status})]}),_jsx(Text,{variant:"bodySmall",numberOfLines:2,children:e.subject}),n?_jsx(Text,{variant:"caption",color:"secondary",children:s.ticketView}):null]})})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{Logger}from"@webority/mobile-core";import{IconButton,ProgressBar,Text,useTheme}from"@webority/mobile-ui";import{useEffect,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{playFile}from"../speech/expoAudio.js";import{discardFile,PhoneSpeechError}from"../speech/phoneSpeech.js";import{audioExtension,formatClipTime}from"../speech/speechText.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const expoFileSystem=()=>{try{return require("expo-file-system")}catch{throw new PhoneSpeechError("Unavailable","Unavailable","Voice files are not available in this app.")}};export function VoiceClipPart({part:e,turn:t}){const r=useTheme(),i=useMemo(()=>buildStyles(r),[r]),s=t.labels,[n,a]=useState(!1),[o,c]=useState(!1),[l,u]=useState(!1),[p,m]=useState(0),h=useRef(null),d=useRef(null),f=useRef(!0);useEffect(()=>(f.current=!0,()=>{f.current=!1,h.current?.stop(),h.current=null,null!==d.current&&discardFile(d.current)}),[]);const startPlayback=e=>{const t=playFile(e,e=>{f.current&&(m(e.positionMs),u(e.playing))});h.current=t;const release=()=>!(!f.current||h.current!==t)&&(h.current=null,u(!1),!0);t.finished.then(()=>{release()&&m(0)},e=>{release()&&(c(!0),Logger.error("[chat] voice clip playback failed",e))})},x=t.features.VoiceClips&&!o,y=null!==e.transcript&&""!==e.transcript.trim()?e.transcript:null,g=e.durationMs>0?Math.min(1,Math.max(0,p/e.durationMs)):0;return _jsxs(View,{accessibilityLabel:s.voiceClip,testID:"chat-voice-clip",style:i.root,children:[x?_jsxs(_Fragment,{children:[_jsxs(View,{style:i.row,children:[_jsx(IconButton,{icon:l?"pause":"play",accessibilityLabel:l?s.voiceClipPause:s.voiceClipPlay,variant:"ghost",tone:"neutral",size:"sm",loading:n,onPress:()=>{const r=h.current;null===r?null===d.current?n||(async()=>{a(!0),c(!1);try{const r=new Uint8Array(await t.readAttachment(e.attachmentId)),{File:i,Paths:s}=expoFileSystem(),n=new i(s.cache,`wchat-clip-${e.attachmentId}${audioExtension(r)}`);if(n.create({overwrite:!0}),n.write(r),!f.current)return void discardFile(n.uri);d.current=n.uri,startPlayback(n.uri)}catch(e){if(!f.current)return;c(!0),Logger.error("[chat] voice clip failed to load",e)}finally{f.current&&a(!1)}})():startPlayback(d.current):l?r.pause():r.resume()},testID:"chat-voice-clip-play"}),_jsx(Text,{variant:"caption",color:"secondary",children:s.voiceClipTime(formatClipTime(p),formatClipTime(e.durationMs))})]}),p>0?_jsx(ProgressBar,{progress:g,height:4}):null]}):null,null!==y?_jsx(Text,{variant:"body",children:y}):null,x||null!==y?null:_jsx(Text,{variant:"caption",color:o?"danger":"secondary",accessibilityLiveRegion:"polite",children:s.voiceClipFailed})]})}const buildStyles=e=>StyleSheet.create({root:{gap:e.space.xs},row:{flexDirection:"row",alignItems:"center",gap:e.space.xs}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{ActionPart}from"./ActionPart.js";import{ChartPart}from"./ChartPart.js";import{FiguresPart}from"./FiguresPart.js";import{FilePart}from"./FilePart.js";import{HandoffPart}from"./HandoffPart.js";import{ImagePart}from"./ImagePart.js";import{InputRequestPart}from"./InputRequestPart.js";import{NoticePart}from"./NoticePart.js";import{QuickRepliesPart}from"./QuickRepliesPart.js";import{RecordCardPart}from"./RecordCardPart.js";import{SourcesPart}from"./SourcesPart.js";import{TablePart}from"./TablePart.js";import{TextPart}from"./TextPart.js";import{TicketPart}from"./TicketPart.js";import{VoiceClipPart}from"./VoiceClipPart.js";export const defaultRenderers={Text:TextPart,Sources:SourcesPart,QuickReplies:QuickRepliesPart,InputRequest:InputRequestPart,Action:ActionPart,Notice:NoticePart,Table:TablePart,Chart:ChartPart,Figures:FiguresPart,RecordCard:RecordCardPart,Image:ImagePart,File:FilePart,Ticket:TicketPart,Handoff:HandoffPart,VoiceClip:VoiceClipPart};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{ChatSpeechError}from"@webority/chat-core";import{buildSsml,clampSpeakText}from"./speechText.js";const TRANSCRIBE_API_VERSION="2024-11-15",TTS_OUTPUT_FORMAT="audio-24khz-48kbitrate-mono-mp3",REQUEST_TIMEOUT_MS=15e3,REGION_PATTERN=/^[a-z0-9]+$/;export class SpeechRequestError extends Error{constructor(e){super(`Speech request failed with status ${e}`),this.name="SpeechRequestError",this.status=e}}const assertRegion=e=>{if(!REGION_PATTERN.test(e))throw new ChatSpeechError("Unavailable","Speech is not available.")},withTimeout=async(e,t)=>{const r=new AbortController,abort=()=>r.abort(),o=setTimeout(abort,15e3);e?.aborted&&r.abort(),e?.addEventListener("abort",abort);try{return await t(r.signal)}finally{clearTimeout(o),e?.removeEventListener("abort",abort)}};export async function transcribeClip(e){const{token:t,uri:r,language:o,signal:a,fetchImpl:i=fetch}=e;assertRegion(t.region);const n=new FormData;return n.append("audio",{uri:r,name:"dictation.m4a",type:"audio/mp4"}),n.append("definition",JSON.stringify({locales:[o]})),withTimeout(a,async e=>{const r=await i(`https://${t.region}.api.cognitive.microsoft.com/speechtotext/transcriptions:transcribe?api-version=2024-11-15`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`},body:n,signal:e});if(!r.ok)throw new SpeechRequestError(r.status);return((await r.json()).combinedPhrases??[]).map(e=>e.text??"").join(" ").trim()})}export async function synthesizeSpeech(e){const{token:t,text:r,language:o,voice:a,signal:i,fetchImpl:n=fetch}=e;return assertRegion(t.region),withTimeout(i,async e=>{const i=await n(`https://${t.region}.tts.speech.microsoft.com/cognitiveservices/v1`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/ssml+xml","X-Microsoft-OutputFormat":TTS_OUTPUT_FORMAT,"User-Agent":"webority-chat"},body:buildSsml(clampSpeakText(r),o,a),signal:e});if(!i.ok)throw new SpeechRequestError(i.status);return new Uint8Array(await i.arrayBuffer())})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{ChatSpeechError}from"@webority/chat-core";import{Logger}from"@webority/mobile-core";const expoAudio=()=>require("expo-audio"),expoFileSystem=()=>{try{return require("expo-file-system")}catch{throw new ChatSpeechError("Unavailable","Voice files are not available in this app.")}},RECORDING_OPTIONS={sampleRate:16e3,numberOfChannels:1,bitRate:48e3},setRecordingMode=e=>expoAudio().setAudioModeAsync({allowsRecording:e,playsInSilentMode:!0});export async function startRecording(){const e=expoAudio();await setRecordingMode(!0);const t=new e.AudioModule.AudioRecorder({...e.RecordingPresets.HIGH_QUALITY,...RECORDING_OPTIONS});let o=0;try{await t.prepareToRecordAsync(),o=Date.now(),t.record()}catch(e){throw await setRecordingMode(!1),e}return{async stop(){try{await t.stop();const e=t.uri;if(null===e)throw new Error("The recorder finished without a file.");const i=t.getStatus().durationMillis;return{uri:e,durationMs:i>0?i:Date.now()-o}}finally{await setRecordingMode(!1)}},async cancel(){try{t.isRecording&&await t.stop();const e=t.uri;if(null!==e){const{File:t}=expoFileSystem();try{new t(e).delete()}catch(e){Logger.warn("Removing a cancelled recording failed:",e)}}}finally{await setRecordingMode(!1)}}}}let active=null;export function playFile(e,t){active?.stop();let o=null,i=null,r=!1,resolveFinished=()=>{},rejectFinished=()=>{};const n=new Promise((e,t)=>{resolveFinished=e,rejectFinished=t}),release=()=>{i?.remove(),i=null,null!==o&&(o.pause(),o.remove(),o=null),active===a&&(active=null)},a={finished:n,pause:()=>o?.pause(),resume:()=>o?.play(),stop:()=>{r||(r=!0,release(),resolveFinished())}};active=a;const l=expoAudio();return l.setAudioModeAsync({playsInSilentMode:!0,allowsRecording:!1}).then(()=>{if(r)return;const n=l.createAudioPlayer({uri:e});o=n,i=n.addListener("playbackStatusUpdate",e=>{t?.({positionMs:1e3*e.currentTime,durationMs:e.duration>0?1e3*e.duration:null,playing:e.playing}),e.didJustFinish&&(r=!0,release(),resolveFinished())}),n.play()}).catch(e=>{r||(r=!0,release(),rejectFinished(e))}),a}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{ChatSpeechError,createSpeechTokenSource}from"@webority/chat-core";import{Logger}from"@webority/mobile-core";import{Permissions}from"@webority/mobile-core/permissions";import{synthesizeSpeech,transcribeClip}from"./azureSpeech.js";import{playFile,startRecording}from"./expoAudio.js";import{clampSpeakText,DEFAULT_SPEECH_LANGUAGE,DEFAULT_SPEECH_VOICE,MAX_DICTATION_MS,MIN_DICTATION_MS}from"./speechText.js";export class PhoneSpeechError extends ChatSpeechError{constructor(e,t,r){super(e,r),this.name="PhoneSpeechError",this.phoneCode=t}}const expoFileSystem=()=>{try{return require("expo-file-system")}catch{throw new PhoneSpeechError("Unavailable","Unavailable","Voice files are not available in this app.")}};export function discardFile(e){try{const{File:t}=expoFileSystem();new t(e).delete()}catch(e){Logger.warn("Removing a temporary audio file failed:",e)}}const failed=e=>e instanceof ChatSpeechError?e:(Logger.error("[chat] speech failed",e),new PhoneSpeechError("Failed","Failed")),waitForDictation=e=>new Promise(t=>{if(e?.aborted)return void t();const done=()=>{clearTimeout(r),e?.removeEventListener("abort",done),t()},r=setTimeout(done,MAX_DICTATION_MS);e?.addEventListener("abort",done)});export function createPhoneSpeech(e){const t=e.language??DEFAULT_SPEECH_LANGUAGE,r=e.voice??DEFAULT_SPEECH_VOICE,o=createSpeechTokenSource(e.getToken);let a=null,n=null,i=Promise.resolve();const token=async()=>{try{return await o.get()}catch(e){throw failed(e)}},dictate=async e=>{n?.abort();const r=i,o=new AbortController,forward=()=>o.abort();e.signal?.aborted&&o.abort(),e.signal?.addEventListener("abort",forward),n=o;const a=r.then(()=>(async(e,r)=>{const o=await Permissions.ensure("microphone").catch(()=>{throw new PhoneSpeechError("Blocked","MicDenied","The microphone permission could not be checked.")});if("blocked"===o)throw new PhoneSpeechError("Blocked","MicBlocked");if("unavailable"===o)throw new PhoneSpeechError("NoMicrophone","MicUnavailable");if("granted"!==o)throw new PhoneSpeechError("Blocked","MicDenied");let a,n;try{a=await startRecording()}catch(e){throw failed(e)}e.onStarted?.(),await waitForDictation(r);try{n=await a.stop()}catch(t){throw e.onEnd?.(),failed(t)}if(n.durationMs<MIN_DICTATION_MS)return discardFile(n.uri),void e.onEnd?.();try{const r=await transcribeClip({token:await token(),uri:n.uri,language:e.language??t});""!==r&&e.onText?.(r,!0),e.onEnd?.()}catch(t){throw e.onEnd?.(),failed(t)}finally{discardFile(n.uri)}})(e,o.signal));i=a.then(()=>{},()=>{});try{await a}finally{e.signal?.removeEventListener("abort",forward),n===o&&(n=null)}};return{dictation:!0,readAloud:!0,streamsText:!1,startDictation:e=>dictate(e),speak:(e,o)=>(async(e,o)=>{a?.abort();const n=new AbortController;a=n;const forward=()=>n.abort();o.signal?.aborted&&n.abort(),o.signal?.addEventListener("abort",forward);const i=n.signal;let c=null,s=null;const onAbort=()=>{s?.stop()};try{const a=clampSpeakText(e);if(""===a)return;const n=await synthesizeSpeech({token:await token(),text:a,language:o.language??t,voice:r,signal:i});if(i.aborted)return;const{File:l,Paths:h}=expoFileSystem();if(c=new l(h.cache,`wchat-read-${Date.now()}.mp3`),c.create({overwrite:!0}),c.write(n),i.aborted)return;s=playFile(c.uri),i.addEventListener("abort",onAbort),i.aborted&&s.stop(),await s.finished}catch(e){if(i.aborted)return;throw failed(e)}finally{i.removeEventListener("abort",onAbort),o.signal?.removeEventListener("abort",forward),a===n&&(a=null),null!==c&&discardFile(c.uri)}})(e,o)}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export const DEFAULT_SPEECH_LANGUAGE="en-IN";export const DEFAULT_SPEECH_VOICE="en-IN-NeerjaNeural";export const MAX_SPEAK_CHARS=4e3;export const MAX_DICTATION_MS=6e4;export const MIN_DICTATION_MS=600;const SENTENCE_END_FLOOR=2e3,ascii=t=>Array.from(t,t=>t.charCodeAt(0)),OGG=ascii("OggS"),RIFF=ascii("RIFF"),EBML=[26,69,223,163],ID3=ascii("ID3"),MPEG_FRAME_HEADERS=[[255,251],[255,243],[255,242]],startsWith=(t,e,r)=>r.every((r,s)=>t[e+s]===r);export function audioExtension(t){return startsWith(t,0,OGG)?".ogg":startsWith(t,0,RIFF)?".wav":startsWith(t,0,EBML)?".webm":startsWith(t,0,ID3)||MPEG_FRAME_HEADERS.some(e=>startsWith(t,0,e))?".mp3":".m4a"}export function escapeSsml(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}export function buildSsml(t,e,r){return`<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="${escapeSsml(e)}"><voice name="${escapeSsml(r)}">${escapeSsml(t)}</voice></speak>`}export function clampSpeakText(t){const e=t.trim();if(e.length<=4e3)return e;const r=e.slice(0,4e3),s=Math.max(r.lastIndexOf("."),r.lastIndexOf("?"),r.lastIndexOf("!"));return s>2e3?r.slice(0,s+1):r}export function formatClipTime(t){if(!Number.isFinite(t)||t<0)return"0:00";const e=Math.floor(t/1e3);return`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`}export function joinDictation(t,e,r){const s=e.trim();if(""===s)return t;return`${t}${t.length>0&&!/\s$/.test(t)?" ":""}${s}`.slice(0,r)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export{};
|
package/lib/module/useChat.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{createChatSession}from"@webority/
|
|
1
|
+
"use strict";import{createChatSession,emptyFeatures}from"@webority/chat-core";import{useCallback,useEffect,useMemo,useRef,useState,useSyncExternalStore}from"react";import{AppState}from"react-native";const requestFrame=e=>{const t=requestAnimationFrame(e);return()=>cancelAnimationFrame(t)},NO_SUBSCRIPTION=()=>()=>{},IDLE_STATE=Object.freeze({profile:null,profileError:null,features:Object.freeze(emptyFeatures()),conversationId:null,conversationState:"Open",title:null,continuesConversationId:null,messages:[],thinking:!1,steps:[],streaming:!1,loading:!1,loadError:null,turnError:null,stopped:!1,messagesLeftToday:null,editing:null,attachments:[],lastConversation:null,open:!1,muted:!1,greeting:null,starters:[],pending:null,agent:null,agentTyping:null,live:"Off",handoffPending:!1,handoffPause:!1,openTickets:[],draft:null}),IDLE_SESSION=new Proxy({},{get:(e,t)=>{if("symbol"!=typeof t&&"client"!==t&&"toJSON"!==t&&!t.startsWith("$$")){if("getState"===t)return()=>IDLE_STATE;if("subscribe"===t)return NO_SUBSCRIPTION;if("then"!==t)return()=>Promise.resolve()}}});export function useChat(e){const{client:t,screen:n,layout:r,narrow:s,conversationId:o,pageContext:a,behaviour:u,prefs:c,getCaptchaToken:i,onEvent:l,onError:f,onNavigate:p}=e,m=JSON.stringify(s??{}),v=useRef(p);v.current=p;const S=useCallback(e=>v.current?.(e),[]),d=useRef(o);d.current=o;const g=useRef(a);g.current=a;const E=useRef(u);E.current=u;const y=useRef(i);y.current=i;const h=useRef(l);h.current=l;const C=useRef(f);C.current=f;const b=useRef(c);b.current=c;const[I,R]=useState(null);useEffect(()=>{const e=createChatSession(t,{screen:n,layout:r,narrow:JSON.parse(m),conversationId:d.current??void 0,pageContext:()=>g.current,behaviour:()=>E.current?.()??null,prefs:b.current,getCaptchaToken:e=>y.current?.(e)??Promise.resolve(null),onEvent:(e,t)=>h.current?.(e,t),onError:e=>C.current?.(e),schedule:requestFrame});return R({client:t,screen:n,layout:r,narrowKey:m,session:e}),()=>e.dispose()},[t,n,r,m]);const A=null!==I&&I.client===t&&I.screen===n&&I.layout===r&&I.narrowKey===m?I.session:IDLE_SESSION,O=useSyncExternalStore(A.subscribe,A.getState),T=useMemo(()=>({load:()=>A.load(),submit:e=>A.submit(e),chooseQuickReply:e=>A.chooseQuickReply(e),answerInput:(e,t)=>A.answerInput(e,t),confirmAction:e=>A.confirmAction(e),rejectAction:(e,t)=>A.rejectAction(e,t),stop:()=>A.stop(),retry:()=>A.retry(),regenerate:()=>A.regenerate(),startEdit:e=>A.startEdit(e),cancelEdit:()=>A.cancelEdit(),attach:e=>A.attach(e),removeAttachment:e=>A.removeAttachment(e),openConversation:e=>A.openConversation(e),resumeLast:()=>A.resumeLast(),newConversation:()=>A.newConversation(),rate:(e,t,n)=>A.rate(e,t,n),reset:()=>A.reset(),requestHandoff:e=>A.requestHandoff(e),notifyTyping:()=>A.notifyTyping(),resumeLive:()=>A.resumeLive()}),[A]),L=useRef(o);useEffect(()=>{A!==IDLE_SESSION&&o&&o!==L.current&&(L.current=o,A.openConversation(o))},[o,A]);const N=useRef("active"===AppState.currentState),k=useRef(!0),w=useCallback(()=>A.setLiveActive(N.current&&k.current),[A]),P=useCallback(e=>{k.current=e,w()},[w]);useEffect(()=>{w();const e=AppState.addEventListener("change",e=>{"active"===e?(N.current=!0,A.endHandoffPause()):N.current=!1,w()});return()=>e.remove()},[w,A]);const _=useCallback((e,t)=>{h.current?.(e,t)},[]);return{...O,...T,session:A,client:t,emit:_,setChatVisible:P,onNavigate:p?S:void 0}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{useEffect,useRef}from"react";import{AppState,Vibration}from"react-native";const isReply=e=>"Assistant"===e.author.kind||"Agent"===e.author.kind&&e.stored;export function useChatHaptics(e){const t=useRef(null),r=e.features.Sounds&&!0===e.profile?.experience.sound.vibrate&&!e.muted,s=e.profile?.experience.sound.vibrateMs??0;useEffect(()=>{if(null!==t.current)for(const i of e.messages){if(!isReply(i)||i.streaming||t.current.has(i.id))continue;if(t.current.add(i.id),i.restored)continue;const e=i.parts.length>0&&i.parts.every(e=>"Notice"===e.kind),n="Agent"!==i.author.kind||"active"===AppState.currentState;r&&!e&&n&&Vibration.vibrate(s)}else t.current=new Set(e.messages.map(e=>e.id))},[e.messages,r,s])}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{useMemo}from"react";import{createPhoneSpeech}from"./speech/phoneSpeech.js";const adapters=new WeakMap;export function useChatSpeech(e){const t=!0===e.profile?.speechAvailable;return useMemo(()=>{if(!t)return null;let r=adapters.get(e.client);return void 0===r&&(r=createPhoneSpeech({getToken:()=>e.client.getSpeechToken()}),adapters.set(e.client,r)),r},[e.client,t])}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{buildTranscript,transcriptToText}from"@webority/chat-core";import{Logger}from"@webority/mobile-core";import{useCallback,useEffect,useRef,useState}from"react";import{Share}from"react-native";const NOTICE_MS=3e3;async function shareMessages(e,r,t,s){const a=buildTranscript(e,r);if(0===a.entries.length)return;const c=transcriptToText(a,{heading:t,speakers:t});try{await Share.share({message:c,title:a.title})}catch(e){Logger.error("[chat] share failed",e),s()}}export default function useTranscriptActions(e,r){const[t,s]=useState(null),a=useRef(null),c=useRef(!1);useEffect(()=>(c.current=!0,()=>{c.current=!1,null!==a.current&&clearTimeout(a.current)}),[]);const u=useCallback(e=>{c.current&&(null!==a.current&&clearTimeout(a.current),s(e),a.current=setTimeout(()=>s(null),3e3))},[]),{messages:i,title:n}=e,l=e.features.FigureText,o=useCallback(e=>shareMessages([e],{labels:r,title:n,figureText:l},!1,()=>u(r.shareFailed)),[r,n,l,u]),f=useCallback(()=>shareMessages(i,{labels:r,title:n,figureText:l},!0,()=>u(r.shareFailed)),[i,r,n,l,u]);return{canShare:e.features.Share,notice:t,shareReply:o,shareConversation:f}}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ChatAuthor, ChatLabels } from "@webority/chat-core";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
export interface AgentBylineProps {
|
|
4
|
+
author: ChatAuthor;
|
|
5
|
+
labels: ChatLabels;
|
|
6
|
+
}
|
|
7
|
+
/** The name and picture of the person who wrote an agent message. The spoken text carries the name instead. */
|
|
8
|
+
export declare function AgentByline({ author, labels }: AgentBylineProps): React.ReactElement;
|
|
9
|
+
//# sourceMappingURL=AgentByline.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ChatLabels, ChatUploadFile } from "@webority/chat-core";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import type { UseChatResult } from "./useChat";
|
|
4
|
+
export interface ChatComposerProps {
|
|
5
|
+
chat: UseChatResult;
|
|
6
|
+
labels: ChatLabels;
|
|
7
|
+
pickAttachments?: () => Promise<ChatUploadFile[]>;
|
|
8
|
+
keyboardOffset?: number;
|
|
9
|
+
keyboardAware?: boolean;
|
|
10
|
+
safeArea?: boolean;
|
|
11
|
+
testID?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function ChatComposer({ chat, labels, pickAttachments, keyboardOffset, keyboardAware, safeArea, testID, }: ChatComposerProps): React.ReactElement;
|
|
14
|
+
//# sourceMappingURL=ChatComposer.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ChatLabels } from "@webority/chat-core";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import type { UseChatResult } from "./useChat";
|
|
4
|
+
export interface ChatConversationActionsProps {
|
|
5
|
+
chat: UseChatResult;
|
|
6
|
+
labels: ChatLabels;
|
|
7
|
+
testID?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function ChatConversationActions({ chat, labels, testID }: ChatConversationActionsProps): React.ReactElement | null;
|
|
10
|
+
//# sourceMappingURL=ChatConversationActions.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ChatLabels } from "@webority/chat-core";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import type { UseChatResult } from "./useChat";
|
|
4
|
+
export interface DictationNotice {
|
|
5
|
+
message: string;
|
|
6
|
+
openSettings: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface ChatDictationButtonProps {
|
|
9
|
+
chat: UseChatResult;
|
|
10
|
+
labels: ChatLabels;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
onText: (text: string) => void;
|
|
13
|
+
onNotice: (notice: DictationNotice | null) => void;
|
|
14
|
+
testID?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function ChatDictationButton({ chat, labels, disabled, onText, onNotice, testID, }: ChatDictationButtonProps): React.ReactElement | null;
|
|
17
|
+
//# sourceMappingURL=ChatDictationButton.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import { type ChatShellProps } from "./ChatFrame";
|
|
3
|
+
import type { UseChatResult } from "./useChat";
|
|
4
|
+
export interface ChatEmbedProps extends ChatShellProps {
|
|
5
|
+
chat: UseChatResult;
|
|
6
|
+
/** The height of the embedded chat. Default 520. */
|
|
7
|
+
height?: number;
|
|
8
|
+
}
|
|
9
|
+
/** The chat drawn inside a bounded area of a screen, with a border and rounded corners. */
|
|
10
|
+
export declare function ChatEmbed({ chat, labels, renderers, layoutParts, loader, motion, pickAttachments, onOpenAttachment, onOpenTarget, onNavigate, openTicket, handoffHosts, keyboardOffset, title, headerActions, height, testID, }: ChatEmbedProps): React.ReactElement | null;
|
|
11
|
+
//# sourceMappingURL=ChatEmbed.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
export interface ChatEntranceProps {
|
|
3
|
+
index?: number;
|
|
4
|
+
animate?: boolean;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare function ChatEntrance({ index, animate, children }: ChatEntranceProps): React.ReactElement;
|
|
8
|
+
//# sourceMappingURL=ChatEntrance.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ChatLabels } from "@webority/chat-core";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import type { UseChatResult } from "./useChat";
|
|
4
|
+
export interface ChatFooterProps {
|
|
5
|
+
chat: UseChatResult;
|
|
6
|
+
labels: ChatLabels;
|
|
7
|
+
}
|
|
8
|
+
export declare function ChatFooter({ chat, labels }: ChatFooterProps): React.ReactElement | null;
|
|
9
|
+
//# sourceMappingURL=ChatFooter.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ChatLabels, ChatLoaderStyle, ChatMotion, ChatPart, ChatUploadFile } from "@webority/chat-core";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import type { ChatLayoutParts, ChatOpenTicketHandler, ChatRenderers } from "./types";
|
|
4
|
+
import type { UseChatResult } from "./useChat";
|
|
5
|
+
export type ChatLayout = "screen" | "sheet" | "embedded";
|
|
6
|
+
/** The props every shell passes down to its frame. */
|
|
7
|
+
export interface ChatCommonProps {
|
|
8
|
+
chat: UseChatResult;
|
|
9
|
+
labels: ChatLabels;
|
|
10
|
+
renderers?: ChatRenderers;
|
|
11
|
+
layoutParts?: ChatLayoutParts;
|
|
12
|
+
loader?: ChatLoaderStyle;
|
|
13
|
+
motion?: ChatMotion;
|
|
14
|
+
pickAttachments?: () => Promise<ChatUploadFile[]>;
|
|
15
|
+
onOpenAttachment?: (part: Extract<ChatPart, {
|
|
16
|
+
kind: "File";
|
|
17
|
+
}>) => void;
|
|
18
|
+
onOpenTarget?: (target: string) => void;
|
|
19
|
+
onNavigate?: (path: string) => void;
|
|
20
|
+
/** Opens a ticket from a Ticket part or the open tickets list; the host shows the ticket. */
|
|
21
|
+
openTicket?: ChatOpenTicketHandler;
|
|
22
|
+
/** Hosts an absolute https link or Navigate chip may open; any other absolute target is not linked. */
|
|
23
|
+
handoffHosts?: readonly string[];
|
|
24
|
+
keyboardOffset?: number;
|
|
25
|
+
testID?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ChatFrameProps extends ChatCommonProps {
|
|
28
|
+
layout: ChatLayout;
|
|
29
|
+
title?: string;
|
|
30
|
+
headerActions?: React.ReactNode;
|
|
31
|
+
}
|
|
32
|
+
/** The props of the three shells: the frame's, with labels as a partial merged over the defaults. */
|
|
33
|
+
export interface ChatShellProps extends Omit<ChatCommonProps, "labels"> {
|
|
34
|
+
labels?: Partial<ChatLabels>;
|
|
35
|
+
title?: string;
|
|
36
|
+
headerActions?: React.ReactNode;
|
|
37
|
+
}
|
|
38
|
+
export declare function ChatFrame({ chat, labels, renderers, layoutParts, loader, motion, pickAttachments, onOpenAttachment, onOpenTarget, onNavigate, openTicket, handoffHosts, keyboardOffset, layout, title, headerActions, testID, }: ChatFrameProps): React.ReactElement | null;
|
|
39
|
+
//# sourceMappingURL=ChatFrame.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ChatLabels } from "@webority/chat-core";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import type { UseChatResult } from "./useChat";
|
|
4
|
+
export interface ChatHistoryProps {
|
|
5
|
+
chat: UseChatResult;
|
|
6
|
+
labels: ChatLabels;
|
|
7
|
+
onOpen: () => void;
|
|
8
|
+
testID?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function ChatHistory({ chat, labels, onOpen, testID }: ChatHistoryProps): React.ReactElement;
|
|
11
|
+
//# sourceMappingURL=ChatHistory.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ChatLabels } from "@webority/chat-core";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import type { UseChatResult } from "./useChat";
|
|
4
|
+
export interface ChatLiveBarProps {
|
|
5
|
+
chat: UseChatResult;
|
|
6
|
+
labels: ChatLabels;
|
|
7
|
+
testID?: string;
|
|
8
|
+
}
|
|
9
|
+
/** The hand-off line under the header. The server decides who may hand off; this bar only draws the state. */
|
|
10
|
+
export declare function ChatLiveBar({ chat, labels, testID }: ChatLiveBarProps): React.ReactElement | null;
|
|
11
|
+
//# sourceMappingURL=ChatLiveBar.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ChatLabels, type ChatLiveMessage } from "@webority/chat-core";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import type { UseChatResult } from "./useChat";
|
|
4
|
+
export interface ChatMessageActionsProps {
|
|
5
|
+
chat: UseChatResult;
|
|
6
|
+
message: ChatLiveMessage;
|
|
7
|
+
labels: ChatLabels;
|
|
8
|
+
/** The newest message in the thread. */
|
|
9
|
+
isLast: boolean;
|
|
10
|
+
/** The last stored visitor message: the one Edit applies to. */
|
|
11
|
+
isLastVisitor: boolean;
|
|
12
|
+
testID?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function ChatMessageActions({ chat, message, labels, isLast, isLastVisitor, testID, }: ChatMessageActionsProps): React.ReactElement | null;
|
|
15
|
+
//# sourceMappingURL=ChatMessageActions.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ChatLabels } from "@webority/chat-core";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import type { UseChatResult } from "./useChat";
|
|
4
|
+
export interface ChatNudgeProps {
|
|
5
|
+
chat: UseChatResult;
|
|
6
|
+
labels: ChatLabels;
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
onActivate: () => void;
|
|
9
|
+
bottomOffset: number;
|
|
10
|
+
position: "end" | "start";
|
|
11
|
+
testID?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function ChatNudge({ chat, labels, enabled, onActivate, bottomOffset, position, testID, }: ChatNudgeProps): React.ReactElement | null;
|
|
14
|
+
//# sourceMappingURL=ChatNudge.d.ts.map
|