@repzo/widget-react-native 1.0.5 → 1.0.7
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/api/client.js +8 -0
- package/lib/commonjs/api/client.js.map +1 -1
- package/lib/commonjs/i18n.js +15 -0
- package/lib/commonjs/i18n.js.map +1 -1
- package/lib/commonjs/locales.js +14 -0
- package/lib/commonjs/locales.js.map +1 -1
- package/lib/commonjs/state/widget-store.js +25 -0
- package/lib/commonjs/state/widget-store.js.map +1 -1
- package/lib/commonjs/types.js +3 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/ui/WidgetProvider.js +14 -0
- package/lib/commonjs/ui/WidgetProvider.js.map +1 -1
- package/lib/commonjs/ui/components/RatingCard.js +351 -0
- package/lib/commonjs/ui/components/RatingCard.js.map +1 -0
- package/lib/commonjs/ui/screens/chat/ChatView.js +22 -1
- package/lib/commonjs/ui/screens/chat/ChatView.js.map +1 -1
- package/lib/module/api/client.js +8 -0
- package/lib/module/api/client.js.map +1 -1
- package/lib/module/i18n.js +15 -0
- package/lib/module/i18n.js.map +1 -1
- package/lib/module/locales.js +14 -0
- package/lib/module/locales.js.map +1 -1
- package/lib/module/state/widget-store.js +25 -0
- package/lib/module/state/widget-store.js.map +1 -1
- package/lib/module/types.js +3 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/ui/WidgetProvider.js +14 -0
- package/lib/module/ui/WidgetProvider.js.map +1 -1
- package/lib/module/ui/components/RatingCard.js +345 -0
- package/lib/module/ui/components/RatingCard.js.map +1 -0
- package/lib/module/ui/screens/chat/ChatView.js +22 -1
- package/lib/module/ui/screens/chat/ChatView.js.map +1 -1
- package/lib/typescript/commonjs/api/client.d.ts +7 -1
- package/lib/typescript/commonjs/api/client.d.ts.map +1 -1
- package/lib/typescript/commonjs/i18n.d.ts +14 -0
- package/lib/typescript/commonjs/i18n.d.ts.map +1 -1
- package/lib/typescript/commonjs/locales.d.ts.map +1 -1
- package/lib/typescript/commonjs/state/widget-store.d.ts +11 -1
- package/lib/typescript/commonjs/state/widget-store.d.ts.map +1 -1
- package/lib/typescript/commonjs/types.d.ts +17 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/WidgetProvider.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/RatingCard.d.ts +59 -0
- package/lib/typescript/commonjs/ui/components/RatingCard.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts +1 -1
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts +11 -1
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts.map +1 -1
- package/lib/typescript/module/api/client.d.ts +7 -1
- package/lib/typescript/module/api/client.d.ts.map +1 -1
- package/lib/typescript/module/i18n.d.ts +14 -0
- package/lib/typescript/module/i18n.d.ts.map +1 -1
- package/lib/typescript/module/locales.d.ts.map +1 -1
- package/lib/typescript/module/state/widget-store.d.ts +11 -1
- package/lib/typescript/module/state/widget-store.d.ts.map +1 -1
- package/lib/typescript/module/types.d.ts +17 -0
- package/lib/typescript/module/types.d.ts.map +1 -1
- package/lib/typescript/module/ui/WidgetProvider.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/RatingCard.d.ts +59 -0
- package/lib/typescript/module/ui/components/RatingCard.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/chat/ChatView.d.ts +1 -1
- package/lib/typescript/module/ui/screens/chat/ChatView.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts +11 -1
- package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/api/client.ts +13 -0
- package/src/i18n.ts +15 -0
- package/src/locales.ts +14 -0
- package/src/state/widget-store.ts +34 -0
- package/src/types.ts +19 -0
- package/src/ui/WidgetProvider.tsx +14 -0
- package/src/ui/components/RatingCard.tsx +362 -0
- package/src/ui/screens/chat/ChatView.tsx +26 -0
- package/src/ui/screens/chat/ChatView.types.ts +11 -0
|
@@ -45,6 +45,7 @@ import { AttachmentChips } from '../../components/AttachmentChips';
|
|
|
45
45
|
import { AttachmentMenu, showNativeAttachmentMenu } from '../../components/AttachmentMenu';
|
|
46
46
|
import { Avatar } from '../../components/Avatar';
|
|
47
47
|
import { ImageViewer } from '../../components/ImageViewer';
|
|
48
|
+
import { getRatingRequest, RatingCard } from '../../components/RatingCard';
|
|
48
49
|
import { WidgetErrorBoundary } from '../../components/ErrorBoundary';
|
|
49
50
|
import { GradientBackground } from '../../components/Gradient';
|
|
50
51
|
import { ArrowUpIcon, ChatOutlineIcon, ChevronIcon, ClockIcon, PaperclipIcon } from '../../components/icons';
|
|
@@ -82,6 +83,8 @@ export function ChatView({
|
|
|
82
83
|
onPickAttachments,
|
|
83
84
|
onSendMessage,
|
|
84
85
|
onIdentifyVisitor,
|
|
86
|
+
onRateConversation,
|
|
87
|
+
defaultLocale,
|
|
85
88
|
onLoadMore,
|
|
86
89
|
onTyping,
|
|
87
90
|
onBack,
|
|
@@ -489,6 +492,8 @@ export function ChatView({
|
|
|
489
492
|
color={color}
|
|
490
493
|
labels={labels}
|
|
491
494
|
onOpenImage={setViewerImage}
|
|
495
|
+
onRateConversation={onRateConversation}
|
|
496
|
+
locales={[locale, defaultLocale]}
|
|
492
497
|
senderLabel={
|
|
493
498
|
isAgentMessage && (startsRun || startsDay)
|
|
494
499
|
? message.senderName || agentName || labels.team
|
|
@@ -640,6 +645,8 @@ function MessageBubble({
|
|
|
640
645
|
onSubmitProcedureForm,
|
|
641
646
|
onAgentUiAction,
|
|
642
647
|
onOpenImage,
|
|
648
|
+
onRateConversation,
|
|
649
|
+
locales,
|
|
643
650
|
}: {
|
|
644
651
|
message: Message;
|
|
645
652
|
color: string;
|
|
@@ -650,6 +657,8 @@ function MessageBubble({
|
|
|
650
657
|
onSubmitProcedureForm?: (body: string) => void;
|
|
651
658
|
onAgentUiAction?: (action: AgentUiAction) => void | Promise<void>;
|
|
652
659
|
onOpenImage: (image: { url: string; name: string }) => void;
|
|
660
|
+
onRateConversation?: ChatViewProps['onRateConversation'];
|
|
661
|
+
locales: Array<string | null | undefined>;
|
|
653
662
|
}) {
|
|
654
663
|
const joinedName = message.metadata?.event === 'agent_joined' ? message.metadata?.agentName : null;
|
|
655
664
|
if (message.messageType === 'system' && typeof joinedName === 'string' && joinedName) {
|
|
@@ -668,6 +677,23 @@ function MessageBubble({
|
|
|
668
677
|
);
|
|
669
678
|
}
|
|
670
679
|
|
|
680
|
+
const ratingRequest = message.messageType === 'system' ? getRatingRequest(message.metadata) : null;
|
|
681
|
+
if (ratingRequest) {
|
|
682
|
+
return (
|
|
683
|
+
<RatingCard
|
|
684
|
+
ratingId={ratingRequest.ratingId}
|
|
685
|
+
initialRating={ratingRequest.rating}
|
|
686
|
+
initialComment={ratingRequest.comment}
|
|
687
|
+
initialReason={ratingRequest.reason}
|
|
688
|
+
reasons={ratingRequest.reasons}
|
|
689
|
+
locales={locales}
|
|
690
|
+
color={color}
|
|
691
|
+
labels={labels.rating}
|
|
692
|
+
onRate={onRateConversation ? (ratingId, data) => onRateConversation(message.id, ratingId, data) : undefined}
|
|
693
|
+
/>
|
|
694
|
+
);
|
|
695
|
+
}
|
|
696
|
+
|
|
671
697
|
if (message.messageType === 'system') {
|
|
672
698
|
const text = message.bodyPlain || stripHtml(message.body || '') || labels.conversationUpdated;
|
|
673
699
|
return (
|
|
@@ -5,11 +5,13 @@ import type { DraftAttachment, PickResult } from '../../../attachments/pickers';
|
|
|
5
5
|
import type {
|
|
6
6
|
AgentUiAction,
|
|
7
7
|
AttachmentSource,
|
|
8
|
+
ConversationRatingResult,
|
|
8
9
|
Message,
|
|
9
10
|
OutgoingAttachment,
|
|
10
11
|
} from '../../../types';
|
|
11
12
|
import type { AgentUiBlockLabels } from '../../components/AgentUiBlocks';
|
|
12
13
|
import type { ImageViewerLabels } from '../../components/ImageViewer';
|
|
14
|
+
import type { RatingCardLabels } from '../../components/RatingCard';
|
|
13
15
|
|
|
14
16
|
export interface ChatLabels {
|
|
15
17
|
back: string;
|
|
@@ -34,6 +36,7 @@ export interface ChatLabels {
|
|
|
34
36
|
procedureSend: string;
|
|
35
37
|
procedureSent: string;
|
|
36
38
|
blocks: AgentUiBlockLabels;
|
|
39
|
+
rating: RatingCardLabels;
|
|
37
40
|
attach: AttachLabels;
|
|
38
41
|
viewer: ImageViewerLabels;
|
|
39
42
|
}
|
|
@@ -88,6 +91,14 @@ export interface ChatViewProps {
|
|
|
88
91
|
action?: AgentUiAction
|
|
89
92
|
) => Promise<void>;
|
|
90
93
|
onIdentifyVisitor?: (data: { email?: string; name?: string; phone?: string }) => Promise<void>;
|
|
94
|
+
/** Answers a rating card; rejects with the server error (409 locked, 410 expired). */
|
|
95
|
+
onRateConversation?: (
|
|
96
|
+
messageId: string,
|
|
97
|
+
ratingId: string,
|
|
98
|
+
data: { rating: number; reason?: string; comment?: string }
|
|
99
|
+
) => Promise<ConversationRatingResult>;
|
|
100
|
+
/** The widget's default language — rating reasons fall back to it. */
|
|
101
|
+
defaultLocale?: string;
|
|
91
102
|
onLoadMore: () => void;
|
|
92
103
|
onTyping: (isTyping: boolean) => void;
|
|
93
104
|
onBack: () => void;
|