@webority/mobile-chat 0.8.2 → 0.9.1
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatMessage=ChatMessage;var _mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_labels=require("../labels.js"),_ActionCard=require("./ActionCard.js"),_ChatMarkdown=require("./ChatMarkdown.js"),_ReplyRating=require("./ReplyRating.js"),_jsxRuntime=require("react/jsx-runtime");function ChatMessage({turn:e,onRate:i,resolveLink:s,onLinkPress:t,confirmAction:a,onViewTicket:n,renderReply:r,labels:l,testID:o="chat-message"}){const c=(0,_labels.mergeLabels)(l),m=(0,_mobileUi.useTheme)(),u=e.streaming&&!e.answer;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:m.spacing.sm},testID:o,children:[""!==e.question&&(0,_jsxRuntime.jsx)(_reactNative.View,{accessible:!0,accessibilityLabel:`${c.you}: ${e.question}`,style:{alignSelf:"flex-end",maxWidth:"85%",backgroundColor:m.colors.primaryMuted,borderRadius:m.radius.lg,paddingHorizontal:m.spacing.md,paddingVertical:m.spacing.sm},children:(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"body",children:e.question})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:m.spacing.sm},children:[(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityLabel:u?c.thinking:void 0,accessibilityLiveRegion:"polite",accessibilityState:{busy:e.streaming},children:u?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:m.spacing.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Spinner,{size:"sm",accessibilityLabel:c.thinking}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:c.thinking})]}):""!==e.answer?r?r(e,{streaming:e.streaming}):(0,_jsxRuntime.jsx)(_ChatMarkdown.ChatMarkdown,{text:e.answer,resolveLink:s,onLinkPress:t}):null}),e.error&&(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"error",accessibilityLiveRegion:"polite",children:e.error.message}),a&&!e.streaming&&e.actions.map(e=>(0,_jsxRuntime.jsx)(_ActionCard.ActionCard,{action:e,confirmAction:a,onViewTicket:n,labels:l},e.token)),i&&e.messageId&&!e.streaming&&(0,_jsxRuntime.jsx)(_ReplyRating.ReplyRating,{rating:e.rating,onRate:(s,t)=>i(e.id,s,t),labels:l})]})]})}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatMessage=ChatMessage;var _mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_labels=require("../labels.js"),_ActionCard=require("./ActionCard.js"),_ChatMarkdown=require("./ChatMarkdown.js"),_ReplyRating=require("./ReplyRating.js"),_jsxRuntime=require("react/jsx-runtime");function ChatMessage({turn:e,onRate:i,resolveLink:s,onLinkPress:t,confirmAction:a,onViewTicket:n,renderReply:r,labels:l,testID:o="chat-message"}){const c=(0,_labels.mergeLabels)(l),m=(0,_mobileUi.useTheme)(),u=e.streaming&&!e.answer;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:m.spacing.sm},testID:o,children:[""!==e.question&&(0,_jsxRuntime.jsx)(_reactNative.View,{accessible:!0,accessibilityLabel:`${c.you}: ${e.question}`,style:{alignSelf:"flex-end",maxWidth:"85%",backgroundColor:m.colors.primaryMuted,borderRadius:m.radius.lg,paddingHorizontal:m.spacing.md,paddingVertical:m.spacing.sm},children:(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"body",children:e.question})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:m.spacing.sm},children:[(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityLabel:u?c.thinking:void 0,accessibilityLiveRegion:"polite",accessibilityState:{busy:e.streaming},"aria-busy":e.streaming,children:u?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center",gap:m.spacing.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Spinner,{size:"sm",accessibilityLabel:c.thinking}),(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"secondary",children:c.thinking})]}):""!==e.answer?r?r(e,{streaming:e.streaming}):(0,_jsxRuntime.jsx)(_ChatMarkdown.ChatMarkdown,{text:e.answer,resolveLink:s,onLinkPress:t}):null}),e.error&&(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"error",accessibilityLiveRegion:"polite",children:e.error.message}),a&&!e.streaming&&e.actions.map(e=>(0,_jsxRuntime.jsx)(_ActionCard.ActionCard,{action:e,confirmAction:a,onViewTicket:n,labels:l},e.token)),i&&e.messageId&&!e.streaming&&(0,_jsxRuntime.jsx)(_ReplyRating.ReplyRating,{rating:e.rating,onRate:(s,t)=>i(e.id,s,t),labels:l})]})]})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ReplyRating=void 0;var _mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_labels=require("../labels.js"),_jsxRuntime=require("react/jsx-runtime");const ReplyRating=({rating:e=null,onRate:t,noteMaxLength:i=1e3,labels:s,testID:a="chat-rating"})=>{const n=(0,_labels.mergeLabels)(s),l=(0,_mobileUi.useTheme)(),[r,o]=(0,_react.useState)(!1),[c,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ReplyRating=void 0;var _mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_labels=require("../labels.js"),_jsxRuntime=require("react/jsx-runtime");const ReplyRating=({rating:e=null,onRate:t,noteMaxLength:i=1e3,labels:s,testID:a="chat-rating"})=>{const n=(0,_labels.mergeLabels)(s),l=(0,_mobileUi.useTheme)(),[r,o]=(0,_react.useState)(!1),[c,d]=(0,_react.useState)(!1),[u,x]=(0,_react.useState)(""),[m,_]=(0,_react.useState)(""),[p,b]=(0,_react.useState)(!1),save=async(e,i)=>{o(!0),_("");try{await t(e,i),d("Down"===e&&void 0===i),b("Up"===e||void 0!==i),void 0!==i&&x("")}catch{_(n.ratingFailed)}finally{o(!1)}};return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:l.spacing.sm},testID:a,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:l.spacing.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{title:n.rateUp,size:"sm",leftIcon:"like",variant:"Up"===e?"soft":"ghost",accessibilityState:{selected:"Up"===e,disabled:r},"aria-selected":"Up"===e,"aria-disabled":r,disabled:r,onPress:()=>{save("Up")},testID:`${a}-up`}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{title:n.rateDown,size:"sm",leftIcon:"dislike",variant:"Down"===e?"soft":"ghost",accessibilityState:{selected:"Down"===e,disabled:r},"aria-selected":"Down"===e,"aria-disabled":r,disabled:r,onPress:()=>{save("Down")},testID:`${a}-down`}),p&&!c&&(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",accessibilityLiveRegion:"polite",children:n.rated})]}),""!==m&&(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"error",accessibilityLiveRegion:"polite",children:m}),c&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:l.spacing.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Input,{label:n.ratingNote,helperText:n.ratingNoteHint,multiline:!0,maxLength:i,value:u,onChangeText:x,testID:`${a}-note`}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",gap:l.spacing.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{title:n.ratingNoteSend,size:"sm",loading:r,disabled:r,onPress:()=>{save("Down",u)},testID:`${a}-note-send`}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{title:n.ratingNoteSkip,size:"sm",variant:"outline",disabled:r,onPress:()=>{d(!1),b(!0)},testID:`${a}-note-skip`})]})]})]})};exports.ReplyRating=ReplyRating;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Spinner,Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{mergeLabels}from"../labels.js";import{ActionCard}from"./ActionCard.js";import{ChatMarkdown}from"./ChatMarkdown.js";import{ReplyRating}from"./ReplyRating.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function ChatMessage({turn:e,onRate:i,resolveLink:s,onLinkPress:r,confirmAction:n,onViewTicket:t,renderReply:a,labels:o,testID:l="chat-message"}){const c=mergeLabels(o),m=useTheme(),g=e.streaming&&!e.answer;return _jsxs(View,{style:{gap:m.spacing.sm},testID:l,children:[""!==e.question&&_jsx(View,{accessible:!0,accessibilityLabel:`${c.you}: ${e.question}`,style:{alignSelf:"flex-end",maxWidth:"85%",backgroundColor:m.colors.primaryMuted,borderRadius:m.radius.lg,paddingHorizontal:m.spacing.md,paddingVertical:m.spacing.sm},children:_jsx(Text,{variant:"body",children:e.question})}),_jsxs(View,{style:{gap:m.spacing.sm},children:[_jsx(View,{accessibilityLabel:g?c.thinking:void 0,accessibilityLiveRegion:"polite",accessibilityState:{busy:e.streaming},children:g?_jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:m.spacing.sm},children:[_jsx(Spinner,{size:"sm",accessibilityLabel:c.thinking}),_jsx(Text,{variant:"bodySmall",color:"secondary",children:c.thinking})]}):""!==e.answer?a?a(e,{streaming:e.streaming}):_jsx(ChatMarkdown,{text:e.answer,resolveLink:s,onLinkPress:r}):null}),e.error&&_jsx(Text,{variant:"bodySmall",color:"error",accessibilityLiveRegion:"polite",children:e.error.message}),n&&!e.streaming&&e.actions.map(e=>_jsx(ActionCard,{action:e,confirmAction:n,onViewTicket:t,labels:o},e.token)),i&&e.messageId&&!e.streaming&&_jsx(ReplyRating,{rating:e.rating,onRate:(s,r)=>i(e.id,s,r),labels:o})]})]})}
|
|
1
|
+
"use strict";import{Spinner,Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{mergeLabels}from"../labels.js";import{ActionCard}from"./ActionCard.js";import{ChatMarkdown}from"./ChatMarkdown.js";import{ReplyRating}from"./ReplyRating.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function ChatMessage({turn:e,onRate:i,resolveLink:s,onLinkPress:r,confirmAction:n,onViewTicket:t,renderReply:a,labels:o,testID:l="chat-message"}){const c=mergeLabels(o),m=useTheme(),g=e.streaming&&!e.answer;return _jsxs(View,{style:{gap:m.spacing.sm},testID:l,children:[""!==e.question&&_jsx(View,{accessible:!0,accessibilityLabel:`${c.you}: ${e.question}`,style:{alignSelf:"flex-end",maxWidth:"85%",backgroundColor:m.colors.primaryMuted,borderRadius:m.radius.lg,paddingHorizontal:m.spacing.md,paddingVertical:m.spacing.sm},children:_jsx(Text,{variant:"body",children:e.question})}),_jsxs(View,{style:{gap:m.spacing.sm},children:[_jsx(View,{accessibilityLabel:g?c.thinking:void 0,accessibilityLiveRegion:"polite",accessibilityState:{busy:e.streaming},"aria-busy":e.streaming,children:g?_jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:m.spacing.sm},children:[_jsx(Spinner,{size:"sm",accessibilityLabel:c.thinking}),_jsx(Text,{variant:"bodySmall",color:"secondary",children:c.thinking})]}):""!==e.answer?a?a(e,{streaming:e.streaming}):_jsx(ChatMarkdown,{text:e.answer,resolveLink:s,onLinkPress:r}):null}),e.error&&_jsx(Text,{variant:"bodySmall",color:"error",accessibilityLiveRegion:"polite",children:e.error.message}),n&&!e.streaming&&e.actions.map(e=>_jsx(ActionCard,{action:e,confirmAction:n,onViewTicket:t,labels:o},e.token)),i&&e.messageId&&!e.streaming&&_jsx(ReplyRating,{rating:e.rating,onRate:(s,r)=>i(e.id,s,r),labels:o})]})]})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Button,Input,Text,useTheme}from"@webority/mobile-ui";import{useState}from"react";import{View}from"react-native";import{mergeLabels}from"../labels.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const ReplyRating=({rating:e=null,onRate:t,noteMaxLength:s=1e3,labels:i,testID:a="chat-rating"})=>{const n=mergeLabels(i),o=useTheme(),[l,r]=useState(!1),[c,d]=useState(!1),[p,x]=useState(""),[g,m]=useState(""),[u,b]=useState(!1),save=async(e,s)=>{r(!0),m("");try{await t(e,s),d("Down"===e&&void 0===s),b("Up"===e||void 0!==s),void 0!==s&&x("")}catch{m(n.ratingFailed)}finally{r(!1)}};return _jsxs(View,{style:{gap:o.spacing.sm},testID:a,children:[_jsxs(View,{style:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:o.spacing.xs},children:[_jsx(Button,{title:n.rateUp,size:"sm",leftIcon:"like",variant:"Up"===e?"soft":"ghost",accessibilityState:{selected:"Up"===e,disabled:l},disabled:l,onPress:()=>{save("Up")},testID:`${a}-up`}),_jsx(Button,{title:n.rateDown,size:"sm",leftIcon:"dislike",variant:"Down"===e?"soft":"ghost",accessibilityState:{selected:"Down"===e,disabled:l},disabled:l,onPress:()=>{save("Down")},testID:`${a}-down`}),u&&!c&&_jsx(Text,{variant:"caption",color:"secondary",accessibilityLiveRegion:"polite",children:n.rated})]}),""!==g&&_jsx(Text,{variant:"bodySmall",color:"error",accessibilityLiveRegion:"polite",children:g}),c&&_jsxs(View,{style:{gap:o.spacing.sm},children:[_jsx(Input,{label:n.ratingNote,helperText:n.ratingNoteHint,multiline:!0,maxLength:s,value:p,onChangeText:x,testID:`${a}-note`}),_jsxs(View,{style:{flexDirection:"row",gap:o.spacing.sm},children:[_jsx(Button,{title:n.ratingNoteSend,size:"sm",loading:l,disabled:l,onPress:()=>{save("Down",p)},testID:`${a}-note-send`}),_jsx(Button,{title:n.ratingNoteSkip,size:"sm",variant:"outline",disabled:l,onPress:()=>{d(!1),b(!0)},testID:`${a}-note-skip`})]})]})]})};
|
|
1
|
+
"use strict";import{Button,Input,Text,useTheme}from"@webority/mobile-ui";import{useState}from"react";import{View}from"react-native";import{mergeLabels}from"../labels.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const ReplyRating=({rating:e=null,onRate:t,noteMaxLength:s=1e3,labels:i,testID:a="chat-rating"})=>{const n=mergeLabels(i),o=useTheme(),[l,r]=useState(!1),[c,d]=useState(!1),[p,x]=useState(""),[g,m]=useState(""),[u,b]=useState(!1),save=async(e,s)=>{r(!0),m("");try{await t(e,s),d("Down"===e&&void 0===s),b("Up"===e||void 0!==s),void 0!==s&&x("")}catch{m(n.ratingFailed)}finally{r(!1)}};return _jsxs(View,{style:{gap:o.spacing.sm},testID:a,children:[_jsxs(View,{style:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:o.spacing.xs},children:[_jsx(Button,{title:n.rateUp,size:"sm",leftIcon:"like",variant:"Up"===e?"soft":"ghost",accessibilityState:{selected:"Up"===e,disabled:l},"aria-selected":"Up"===e,"aria-disabled":l,disabled:l,onPress:()=>{save("Up")},testID:`${a}-up`}),_jsx(Button,{title:n.rateDown,size:"sm",leftIcon:"dislike",variant:"Down"===e?"soft":"ghost",accessibilityState:{selected:"Down"===e,disabled:l},"aria-selected":"Down"===e,"aria-disabled":l,disabled:l,onPress:()=>{save("Down")},testID:`${a}-down`}),u&&!c&&_jsx(Text,{variant:"caption",color:"secondary",accessibilityLiveRegion:"polite",children:n.rated})]}),""!==g&&_jsx(Text,{variant:"bodySmall",color:"error",accessibilityLiveRegion:"polite",children:g}),c&&_jsxs(View,{style:{gap:o.spacing.sm},children:[_jsx(Input,{label:n.ratingNote,helperText:n.ratingNoteHint,multiline:!0,maxLength:s,value:p,onChangeText:x,testID:`${a}-note`}),_jsxs(View,{style:{flexDirection:"row",gap:o.spacing.sm},children:[_jsx(Button,{title:n.ratingNoteSend,size:"sm",loading:l,disabled:l,onPress:()=>{save("Down",p)},testID:`${a}-note-send`}),_jsx(Button,{title:n.ratingNoteSkip,size:"sm",variant:"outline",disabled:l,onPress:()=>{d(!1),b(!0)},testID:`${a}-note-skip`})]})]})]})};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/mobile-chat",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "AI assistant chat for Webority React Native apps: a streaming chat client, a store-agnostic chat hook, and the chat screen, thread, composer, past chats, reply rating and support action cards, built on @webority/mobile-ui.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"!**/*.map"
|
|
43
43
|
],
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@webority/mobile-core": ">=0.
|
|
46
|
-
"@webority/mobile-ui": ">=0.
|
|
45
|
+
"@webority/mobile-core": ">=0.9.0 <0.10.0",
|
|
46
|
+
"@webority/mobile-ui": ">=0.9.0 <0.10.0",
|
|
47
47
|
"react": "^19.1.0",
|
|
48
48
|
"react-native": ">=0.81.0",
|
|
49
49
|
"react-native-keyboard-controller": ">=1.21.9",
|
|
@@ -81,8 +81,8 @@
|
|
|
81
81
|
]
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@webority/mobile-core": "0.
|
|
85
|
-
"@webority/mobile-ui": "0.
|
|
84
|
+
"@webority/mobile-core": "0.9.1",
|
|
85
|
+
"@webority/mobile-ui": "0.9.1"
|
|
86
86
|
},
|
|
87
87
|
"scripts": {
|
|
88
88
|
"build": "bob build && node ../../scripts/minify-lib.mjs",
|