@pega/cosmos-react-demos 4.0.0-dev.10.1 → 4.0.0-dev.11.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.
Files changed (97) hide show
  1. package/jsx/build/ObjectSelect/ObjectSelect.mocks.d.ts.map +1 -1
  2. package/jsx/build/ObjectSelect/ObjectSelect.mocks.jsx +0 -2
  3. package/jsx/build/ObjectSelect/ObjectSelect.mocks.jsx.map +1 -1
  4. package/jsx/build/PageTemplates/PageTemplates.stories.d.ts.map +1 -1
  5. package/jsx/build/PageTemplates/PageTemplates.stories.jsx +0 -2
  6. package/jsx/build/PageTemplates/PageTemplates.stories.jsx.map +1 -1
  7. package/jsx/core/DateTime/DateTimePicker.stories.jsx +1 -1
  8. package/jsx/core/DateTime/DateTimePicker.stories.jsx.map +1 -1
  9. package/jsx/core/SummaryList/SummaryList.mocks.d.ts.map +1 -1
  10. package/jsx/core/SummaryList/SummaryList.mocks.jsx +3 -1
  11. package/jsx/core/SummaryList/SummaryList.mocks.jsx.map +1 -1
  12. package/jsx/cs/CSAppShell/CSAppShell.stories.jsx +1 -1
  13. package/jsx/cs/CSAppShell/CSAppShell.stories.jsx.map +1 -1
  14. package/jsx/social/Chat/Chat.mocks.d.ts +14 -392
  15. package/jsx/social/Chat/Chat.mocks.d.ts.map +1 -1
  16. package/jsx/social/Chat/Chat.mocks.js +518 -583
  17. package/jsx/social/Chat/Chat.mocks.js.map +1 -1
  18. package/jsx/social/Chat/Chat.stories.d.ts +13 -17
  19. package/jsx/social/Chat/Chat.stories.d.ts.map +1 -1
  20. package/jsx/social/Chat/Chat.stories.jsx +167 -188
  21. package/jsx/social/Chat/Chat.stories.jsx.map +1 -1
  22. package/jsx/social/Email/Email.stories.d.ts.map +1 -1
  23. package/jsx/social/Email/Email.stories.jsx +9 -7
  24. package/jsx/social/Email/Email.stories.jsx.map +1 -1
  25. package/jsx/tools/PreviewShell/PreviewShell.mocks.d.ts +0 -1
  26. package/jsx/tools/PreviewShell/PreviewShell.mocks.d.ts.map +1 -1
  27. package/jsx/tools/PreviewShell/PreviewShell.mocks.jsx +1 -4
  28. package/jsx/tools/PreviewShell/PreviewShell.mocks.jsx.map +1 -1
  29. package/jsx/tools/PreviewShell/PreviewShell.stories.d.ts.map +1 -1
  30. package/jsx/tools/PreviewShell/PreviewShell.stories.jsx +3 -6
  31. package/jsx/tools/PreviewShell/PreviewShell.stories.jsx.map +1 -1
  32. package/jsx/work/CaseView/Attachments.mocks.d.ts.map +1 -1
  33. package/jsx/work/CaseView/Attachments.mocks.jsx +1 -0
  34. package/jsx/work/CaseView/Attachments.mocks.jsx.map +1 -1
  35. package/jsx/work/CaseView/CaseView.mocks.jsx +4 -4
  36. package/jsx/work/CaseView/CaseView.mocks.jsx.map +1 -1
  37. package/lib/build/ObjectSelect/ObjectSelect.mocks.d.ts.map +1 -1
  38. package/lib/build/ObjectSelect/ObjectSelect.mocks.js +0 -2
  39. package/lib/build/ObjectSelect/ObjectSelect.mocks.js.map +1 -1
  40. package/lib/build/PageTemplates/PageTemplates.stories.d.ts.map +1 -1
  41. package/lib/build/PageTemplates/PageTemplates.stories.js +0 -2
  42. package/lib/build/PageTemplates/PageTemplates.stories.js.map +1 -1
  43. package/lib/core/DateTime/DateTimePicker.stories.js +1 -1
  44. package/lib/core/DateTime/DateTimePicker.stories.js.map +1 -1
  45. package/lib/core/SummaryList/SummaryList.mocks.d.ts.map +1 -1
  46. package/lib/core/SummaryList/SummaryList.mocks.js +3 -1
  47. package/lib/core/SummaryList/SummaryList.mocks.js.map +1 -1
  48. package/lib/cs/CSAppShell/CSAppShell.stories.js +1 -1
  49. package/lib/cs/CSAppShell/CSAppShell.stories.js.map +1 -1
  50. package/lib/social/Chat/Chat.mocks.d.ts +14 -392
  51. package/lib/social/Chat/Chat.mocks.d.ts.map +1 -1
  52. package/lib/social/Chat/Chat.mocks.js +518 -583
  53. package/lib/social/Chat/Chat.mocks.js.map +1 -1
  54. package/lib/social/Chat/Chat.stories.d.ts +14 -24
  55. package/lib/social/Chat/Chat.stories.d.ts.map +1 -1
  56. package/lib/social/Chat/Chat.stories.js +177 -173
  57. package/lib/social/Chat/Chat.stories.js.map +1 -1
  58. package/lib/social/Email/Email.stories.d.ts.map +1 -1
  59. package/lib/social/Email/Email.stories.js +9 -7
  60. package/lib/social/Email/Email.stories.js.map +1 -1
  61. package/lib/tools/PreviewShell/PreviewShell.mocks.d.ts +0 -1
  62. package/lib/tools/PreviewShell/PreviewShell.mocks.d.ts.map +1 -1
  63. package/lib/tools/PreviewShell/PreviewShell.mocks.js +1 -2
  64. package/lib/tools/PreviewShell/PreviewShell.mocks.js.map +1 -1
  65. package/lib/tools/PreviewShell/PreviewShell.stories.d.ts.map +1 -1
  66. package/lib/tools/PreviewShell/PreviewShell.stories.js +4 -5
  67. package/lib/tools/PreviewShell/PreviewShell.stories.js.map +1 -1
  68. package/lib/work/CaseView/Attachments.mocks.d.ts.map +1 -1
  69. package/lib/work/CaseView/Attachments.mocks.js +1 -0
  70. package/lib/work/CaseView/Attachments.mocks.js.map +1 -1
  71. package/lib/work/CaseView/CaseView.mocks.js +4 -4
  72. package/lib/work/CaseView/CaseView.mocks.js.map +1 -1
  73. package/package.json +9 -9
  74. package/jsx/social/Chat/RepeatingView.mocks.d.ts +0 -14
  75. package/jsx/social/Chat/RepeatingView.mocks.d.ts.map +0 -1
  76. package/jsx/social/Chat/RepeatingView.mocks.js +0 -11
  77. package/jsx/social/Chat/RepeatingView.mocks.js.map +0 -1
  78. package/jsx/social/Chat/RepeatingView.stories.d.ts +0 -9
  79. package/jsx/social/Chat/RepeatingView.stories.d.ts.map +0 -1
  80. package/jsx/social/Chat/RepeatingView.stories.jsx +0 -60
  81. package/jsx/social/Chat/RepeatingView.stories.jsx.map +0 -1
  82. package/jsx/social/Chat/RepeatingView.styles.d.ts +0 -2
  83. package/jsx/social/Chat/RepeatingView.styles.d.ts.map +0 -1
  84. package/jsx/social/Chat/RepeatingView.styles.js +0 -22
  85. package/jsx/social/Chat/RepeatingView.styles.js.map +0 -1
  86. package/lib/social/Chat/RepeatingView.mocks.d.ts +0 -14
  87. package/lib/social/Chat/RepeatingView.mocks.d.ts.map +0 -1
  88. package/lib/social/Chat/RepeatingView.mocks.js +0 -11
  89. package/lib/social/Chat/RepeatingView.mocks.js.map +0 -1
  90. package/lib/social/Chat/RepeatingView.stories.d.ts +0 -9
  91. package/lib/social/Chat/RepeatingView.stories.d.ts.map +0 -1
  92. package/lib/social/Chat/RepeatingView.stories.js +0 -59
  93. package/lib/social/Chat/RepeatingView.stories.js.map +0 -1
  94. package/lib/social/Chat/RepeatingView.styles.d.ts +0 -2
  95. package/lib/social/Chat/RepeatingView.styles.d.ts.map +0 -1
  96. package/lib/social/Chat/RepeatingView.styles.js +0 -22
  97. package/lib/social/Chat/RepeatingView.styles.js.map +0 -1
@@ -1,13 +1,13 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState, useRef, useEffect, useCallback, useMemo } from 'react';
3
3
  import { action } from '@storybook/addon-actions';
4
- import { Button, Icon, registerIcon, Text, MenuButton, Flex, Popover, Link, Status, EmojiContext, createUID, useOuterEvent, TextArea, Select, Option, useElement, useModalManager, useModalContext, Modal, SummaryItem, useToaster, SearchInput, menuHelpers, VisuallyHiddenText, Menu, useEscape } from '@pega/cosmos-react-core';
4
+ import { Button, Icon, registerIcon, Text, MenuButton, Flex, Popover, Link, EmojiContext, createUID, useOuterEvent, Select, Option, useElement, useModalManager, useModalContext, Modal, SummaryItem, useToaster, SearchInput, menuHelpers, VisuallyHiddenText, Menu, useEscape } from '@pega/cosmos-react-core';
5
5
  import * as arrowMicroDownIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/arrow-micro-down.icon';
6
6
  import * as replyIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/reply.icon';
7
7
  import * as replyAllIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/reply-all.icon';
8
8
  import * as forwardIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/forward.icon';
9
- import { Chat, ChatHeader, ChatBody, ChatComposer, ChatTranscript, Message, MessageList, NewMessageSeparatorId, SuggestedReplyPicker, SystemMessage, TranscriptMessage, TypeIndicator } from '@pega/cosmos-react-social';
10
- import { ChatMockData, phrasesDisplayNames, phrasesMessages, pagePushList, contextItems as contextItemsMock } from './Chat.mocks';
9
+ import { Chat, ChatHeader, ChatComposer, Message, NewMessageSeparatorId, SuggestedReplyPicker, SystemMessage, TypeIndicator } from '@pega/cosmos-react-social';
10
+ import { ChatMockData, phrasesDisplayNames, phrasesMessages, pagePushList, contextItems as contextItemsMock, BotConversation, ClaimsAgentConversation, LiveChatConversation } from './Chat.mocks';
11
11
  registerIcon(forwardIcon, replyIcon, replyAllIcon, arrowMicroDownIcon);
12
12
  export default {
13
13
  title: 'Social/Chat',
@@ -18,8 +18,8 @@ export const ChatHeaderDemo = (args) => {
18
18
  const [contextItems, setContextItems] = useState([]);
19
19
  const [loading, setLoading] = useState(false);
20
20
  return (_jsx(ChatHeader, { title: title, icon: icon || 'chat', actions: [
21
- { id: 'action-1', text: 'Transfer' },
22
- { id: 'action-2', text: 'End chat' }
21
+ { id: 'action-1', primary: 'Transfer' },
22
+ { id: 'action-2', primary: 'End chat' }
23
23
  ], sentiment: {
24
24
  variant: 'positive',
25
25
  'aria-label': 'Sentiment is positive'
@@ -47,16 +47,6 @@ ChatHeaderDemo.argTypes = {
47
47
  customer: { control: { type: 'text' } },
48
48
  authenticated: { control: { type: 'boolean' }, type: { name: 'string', required: false } }
49
49
  };
50
- export const MessageListDemo = (args) => {
51
- const messages = ChatMockData.chatMessages;
52
- const [unReadMessageCount, setUnReadMessagesCount] = useState(1);
53
- return (_jsx(Flex, { container: true, style: { height: '80vh' }, children: _jsx(MessageList, { tabIndex: 0, messages: messages, unReadMessageCount: unReadMessageCount, onScrollToButtonClick: args.onScrollToButtonClick ||
54
- (() => {
55
- setUnReadMessagesCount(0);
56
- }) }) }));
57
- };
58
- /** **************************** MessageList component - END **************************** */
59
- /** ***************************** Message component - START ********************** */
60
50
  export const MessageDemo = (args) => {
61
51
  const actions = [
62
52
  {
@@ -91,7 +81,7 @@ export const MessageDemo = (args) => {
91
81
  actions
92
82
  }
93
83
  ];
94
- const pagePushLinks = [
84
+ const mediaPageLinks = [
95
85
  {
96
86
  id: '2499167349',
97
87
  href: 'https://collaborate.pega.com/',
@@ -99,31 +89,65 @@ export const MessageDemo = (args) => {
99
89
  title: 'Ask the expert'
100
90
  }
101
91
  ];
102
- return (_jsxs(_Fragment, { children: [_jsx(Message, { type: 'message', attachments: attachments, avatarInfo: { name: 'John Brown' }, timeStamp: '1:44 PM', message: 'Hi, Welcome to u-plus. How can I help you ?', variant: args.variant, direction: args.direction }), _jsx("br", {}), _jsx(Message, { type: 'message', message: 'Hi, Welcome to u-plus. How can I help you ?', avatarInfo: { name: 'John Brown' }, pagePushLinks: pagePushLinks, variant: args.variant, direction: args.direction }), _jsx("br", {}), _jsx(Message, { type: 'message', message: 'Hi, Welcome to u-plus. How can I help you ?', avatarInfo: { name: 'John Brown' }, variant: 'sender', direction: 'out', status: 'undelivered' })] }));
92
+ return (_jsx(_Fragment, { children: _jsx(Message, { attachments: args.showAttachments ? attachments : undefined, mediaPageLinks: args.showMediaPageLinks ? mediaPageLinks : undefined, avatarInfo: args.direction === 'in' && args.senderType !== 'bot'
93
+ ? {
94
+ name: 'John Brown',
95
+ imageSrc: args.showAvatarImage
96
+ ? 'https://pegasystems.github.io/uplus-wss/insurance/img/option-1.jpg'
97
+ : undefined
98
+ }
99
+ : undefined, timestamp: args.showTimestamp ? args.timestamp : undefined, status: args.showStatus ? args.status : undefined, message: args.message, direction: args.direction, senderType: args.senderType, senderId: createUID(), agentVariant: args.agentVariant, messageHeader: args.showHeader ? { content: args.headerContent, meta: args.headerMeta } : undefined }) }));
103
100
  };
104
101
  MessageDemo.args = {
105
- variant: 'receiver',
106
- direction: 'in'
102
+ direction: 'in',
103
+ senderType: 'customer',
104
+ agentVariant: 0,
105
+ message: 'Hi, Welcome to u-plus. How can I help you ?',
106
+ showStatus: true,
107
+ status: 'delivered',
108
+ showTimestamp: true,
109
+ timestamp: '1:44 PM',
110
+ showHeader: false,
111
+ headerContent: 'Public Reply',
112
+ headerMeta: 'I-12345',
113
+ showAvatarImage: false,
114
+ showAttachments: false,
115
+ showMediaPageLinks: false
107
116
  };
108
117
  MessageDemo.argTypes = {
109
- variant: { options: ['receiver', 'sender', 'other'], control: { type: 'select' } },
110
- direction: { options: ['in', 'out'], control: { type: 'select' } }
118
+ direction: { options: ['in', 'out'], control: { type: 'inline-radio' } },
119
+ senderType: { options: ['agent', 'customer', 'bot'], control: { type: 'inline-radio' } },
120
+ agentVariant: { type: 'number' },
121
+ message: { type: 'string' },
122
+ showTimestamp: { type: 'boolean' },
123
+ timestamp: { control: 'text' },
124
+ showStatus: { type: 'boolean' },
125
+ status: {
126
+ options: ['delivered', 'opened', 'undeliverable'],
127
+ control: { type: 'inline-radio' }
128
+ },
129
+ showHeader: { control: 'boolean' },
130
+ headerContent: { control: 'text' },
131
+ headerMeta: { control: 'text' },
132
+ showAvatarImage: { control: 'boolean' },
133
+ showAttachments: { control: 'boolean' },
134
+ showMediaPageLinks: { control: 'boolean' }
111
135
  };
112
136
  /** ***************************** Message component - END *********************** */
113
137
  /** **************************** SystemMessage component - START ***************** */
114
- export const SystemMessageDemo = (args) => (_jsx(SystemMessage, { message: args.message, timeStamp: args.timeStamp, variant: args.variant }));
138
+ export const SystemMessageDemo = (args) => (_jsx(SystemMessage, { message: args.message, timestamp: args.timestamp, variant: args.variant }));
115
139
  SystemMessageDemo.args = {
116
140
  message: 'John Brown has joined',
117
141
  variant: 'secondary',
118
- timeStamp: '10:00 AM'
142
+ timestamp: '10:00 AM'
119
143
  };
120
144
  SystemMessageDemo.argTypes = {
121
145
  message: { control: { type: 'text' } },
122
146
  variant: { options: ['primary', 'secondary'], control: { type: 'select' } },
123
- timeStamp: { control: { type: 'text' } }
147
+ timestamp: { control: { type: 'text' } }
124
148
  };
125
149
  export const TypeIndicatorDemo = (args) => {
126
- return _jsx(TypeIndicator, { avatarInfo: { name: 'John Brown' }, message: args.message });
150
+ return (_jsx(TypeIndicator, { avatarInfo: { name: 'John Brown' }, message: args.message, senderId: 'johnBrown', senderType: 'agent' }));
127
151
  };
128
152
  TypeIndicatorDemo.args = {
129
153
  message: ''
@@ -132,57 +156,9 @@ TypeIndicatorDemo.argTypes = {
132
156
  message: { control: { type: 'text' } }
133
157
  };
134
158
  /** *************************** TypeIndicator component - END *********************** */
135
- /** ************************** ChatTranscripts component - START ********************* */
136
- export const ChatTranscriptsDemo = () => {
137
- return (_jsx(_Fragment, { children: ChatMockData.transcripts.map((transcript) => {
138
- return (_jsx(ChatTranscript, { tabIndex: 0, title: transcript.title, transcript: transcript.data }, transcript.id));
139
- }) }));
140
- };
141
- export const TranscriptMessageDemo = (args) => (_jsx(TranscriptMessage, { timeStamp: args.timeStamp, variant: args.variant, message: args.message, transcriptHeader: args.transcriptHeaderContent || args.transcriptHeaderMeta
142
- ? { content: args.transcriptHeaderContent, meta: args.transcriptHeaderMeta }
143
- : undefined, avatarInfo: args.avatarInfoName
144
- ? {
145
- name: args.avatarInfoName,
146
- imageSrc: args.avatarInfoImageSrc
147
- }
148
- : undefined }));
149
- TranscriptMessageDemo.args = {
150
- message: 'Hello… This is bot. How can I help you? Please select your category.',
151
- variant: 'bot',
152
- timeStamp: '01:20 PM',
153
- transcriptHeaderContent: undefined,
154
- transcriptHeaderMeta: undefined,
155
- avatarInfoName: undefined,
156
- avatarInfoImageSrc: undefined
157
- };
158
- TranscriptMessageDemo.argTypes = {
159
- message: { type: { name: 'string', required: true }, control: { type: 'text' } },
160
- variant: {
161
- type: { name: 'string', required: true },
162
- control: { type: 'select', options: ['user', 'bot', 'question'] }
163
- },
164
- timeStamp: { type: { name: 'string', required: true }, control: { type: 'text' } },
165
- transcriptHeaderContent: { type: { name: 'string', required: false }, control: { type: 'text' } },
166
- transcriptHeaderMeta: { type: { name: 'string', required: false }, control: { type: 'text' } },
167
- avatarInfoName: { type: { name: 'string', required: false }, control: { type: 'text' } },
168
- avatarInfoImageSrc: { type: { name: 'string', required: false }, control: { type: 'text' } }
169
- };
170
- /** *************************** TranscriptMessage component - END ******************** */
171
159
  /** *************************** SuggestedReplyPicker component - START ****************** */
172
160
  export const SuggestedReplyPickerDemo = () => {
173
- const suggestedReplies = [
174
- {
175
- id: createUID(),
176
- message: 'Hello, Good morning Sara. How can I help you today',
177
- confidence: 95
178
- },
179
- {
180
- id: createUID(),
181
- message: 'Sorry to hear that. I will surely help you resolve the issue. Can you please provide the policy id, so that I can get more details',
182
- confidence: 75
183
- }
184
- ];
185
- return (_jsx(SuggestedReplyPicker, { replies: suggestedReplies, onSelect: suggestedReply => {
161
+ return (_jsx(SuggestedReplyPicker, { replies: ChatMockData.suggestedReplies, onSelect: suggestedReply => {
186
162
  action(`Suggested reply picked ${suggestedReply.message}`)();
187
163
  }, onDismiss: action('Suggested reply dismissed') }));
188
164
  };
@@ -214,19 +190,7 @@ export const StandardChat = (args) => {
214
190
  }
215
191
  }
216
192
  };
217
- const { participants, chatMessages: mockChatMessagesJson, transcripts, defaultAttachments, suggestedReplies } = ChatMockDataClone;
218
- const conversationRatingMessage = {
219
- id: createUID(),
220
- variant: 'receiver',
221
- direction: 'in',
222
- type: 'message',
223
- message: (_jsxs(Flex, { container: {
224
- direction: 'column',
225
- gap: 1
226
- }, children: [_jsx(TextArea, { placeholder: 'Please comment\u2026', label: 'Please comment on our service performance and how we can better serve you. Thank you for your time.' }), _jsxs(Select, { label: 'Is the problem resolved?', children: [_jsx(Option, { children: "Yes" }), _jsx(Option, { children: "No" })] }), _jsx(Flex, { container: {
227
- justify: 'center'
228
- }, children: _jsx(Button, { variant: 'primary', children: "Submit" }) })] }))
229
- };
193
+ const { chatMessages: mockChatMessagesJson, defaultAttachments, suggestedReplies } = ChatMockDataClone;
230
194
  const { create } = useModalManager();
231
195
  const MyModal = () => {
232
196
  const { dismiss } = useModalContext();
@@ -278,8 +242,7 @@ export const StandardChat = (args) => {
278
242
  });
279
243
  }
280
244
  return restMessageData;
281
- }),
282
- conversationRatingMessage
245
+ })
283
246
  ];
284
247
  }, []);
285
248
  const conversationRef = useRef(null);
@@ -290,10 +253,21 @@ export const StandardChat = (args) => {
290
253
  };
291
254
  }, []);
292
255
  const [showSuggestedReplies, setShowSuggestedReplies] = useState(true);
293
- const [showTranscripts, setShowTranscripts] = useState(false);
294
256
  const [attachments, setAttachments] = useState(defaultAttachments);
295
- const [unreadMessagesCount, setUnreadMessagesCount] = useState(0);
296
- const [chatMessages, setChatMessages] = useState(args.simulateConversation ? mockChatMessages.slice(0, 0) : mockChatMessages);
257
+ const [unreadMessageCount, setUnreadMessageCount] = useState(0);
258
+ const [chatMessages, setChatMessages] = useState(LiveChatConversation.map(message => {
259
+ if (message.type === 'message' && message.attachments) {
260
+ message.attachments = message.attachments.map((item) => {
261
+ return {
262
+ ...item,
263
+ actions
264
+ };
265
+ });
266
+ }
267
+ return message;
268
+ }));
269
+ const [contextItems, setContextItems] = useState([]);
270
+ const [contextLoading, setContextLoading] = useState(false);
297
271
  const onDeleteAttachment = useCallback((name) => {
298
272
  setAttachments(prevAttachments => prevAttachments.filter(item => item.name !== name));
299
273
  }, [setAttachments]);
@@ -328,7 +302,7 @@ export const StandardChat = (args) => {
328
302
  return [...prevChatMessages, newMockMessage];
329
303
  });
330
304
  if (!incrementUnreadMessageCount) {
331
- setUnreadMessagesCount(prevCount => prevCount + 1);
305
+ setUnreadMessageCount(prevCount => prevCount + 1);
332
306
  }
333
307
  };
334
308
  useEffect(() => {
@@ -343,66 +317,49 @@ export const StandardChat = (args) => {
343
317
  };
344
318
  }
345
319
  }, [chatMessages, args.simulateConversation]);
346
- const header = (_jsx(ChatHeaderDemo, { title: Channels.options[args.selectedChannel || 'LiveChat'].title, icon: Channels.options[args.selectedChannel || 'LiveChat'].icon, customer: 'Ginger Ventura', authenticated: true }));
347
- const [showEarlierTranscripts, setShowEarlierTranscripts] = useState(false);
348
- const transcriptsContainerRef = useRef(null);
349
- useOuterEvent('mousedown', [transcriptsContainerRef], () => {
350
- setShowTranscripts(false);
351
- });
352
- const utilityComp = useMemo(() => {
353
- return showTranscripts ? (_jsxs("div", { ref: transcriptsContainerRef, children: [!showEarlierTranscripts && (_jsx(Flex, { container: {
354
- direction: 'column',
355
- alignItems: 'center',
356
- gap: 1
357
- }, children: _jsx(Button, { icon: true, "aria-label": 'Show earlier transcripts', variant: 'secondary', onClick: () => {
358
- setShowEarlierTranscripts(!showEarlierTranscripts);
359
- }, children: _jsx(Icon, { name: 'caret-up' }) }) })), transcripts
360
- .sort((transcript) => transcript.earlierTranscripts)
361
- .filter((transcript) => showEarlierTranscripts ? true : !transcript.earlierTranscripts)
362
- .map((transcript) => {
363
- const transcriptData = transcript.data.map((message) => {
364
- if (message.messagePrivacy) {
365
- message.transcriptHeader = {
366
- content: _jsx(Status, { variant: 'warn', children: message.messagePrivacy.privacy }),
367
- meta: _jsx(Link, { href: '/', children: "I-12345" })
368
- };
369
- }
370
- return message;
371
- });
372
- return (_jsx(ChatTranscript, { tabIndex: 0, title: transcript.title, transcript: transcriptData }, transcript.id));
373
- })] })) : undefined;
374
- }, [showTranscripts, setShowTranscripts, showEarlierTranscripts, setShowEarlierTranscripts]);
375
320
  const chatBanner = {
376
321
  messages: ['This is a public interaction and any responses will be public and visible'],
377
322
  variant: 'warning'
378
323
  };
379
- const body = (_jsx(ChatBody, { children: _jsx(MessageList, { unReadMessageCount: unreadMessagesCount, onScrollToButtonClick: () => {
380
- const newRandomMessageId = Math.random().toString(36).substr(2, 9);
381
- setChatMessages(prevChatMessages => prevChatMessages.map(message => {
382
- if (message.id === NewMessageSeparatorId) {
383
- message.id = newRandomMessageId;
384
- }
385
- return message;
386
- }));
387
- const timeOutId = window.setTimeout(() => {
388
- setChatMessages(prevChatMessages => prevChatMessages.filter(({ id }) => id !== newRandomMessageId));
389
- timers.current = timers.current.filter(id => id !== timeOutId);
390
- }, 5000);
391
- timers.current.push(timeOutId);
392
- setUnreadMessagesCount(0);
393
- }, ref: conversationRef, messages: [
394
- ...chatMessages,
395
- {
396
- id: 'Pegasystems',
397
- type: 'typing',
398
- avatarInfo: {
399
- name: 'Pegasystems',
400
- imageSrc: 'https://www.pega.com/sites/default/files/media/images/2018-12/Pega.com-og.png'
401
- },
402
- message: args.message,
403
- ariaLabel: 'Pegasystems is typing'
324
+ const bodyProps = {
325
+ unreadMessageCount,
326
+ handle: conversationRef,
327
+ transcripts: [
328
+ { id: createUID(), messages: BotConversation },
329
+ { id: createUID(), messages: ClaimsAgentConversation }
330
+ ],
331
+ liveChat: [
332
+ ...chatMessages,
333
+ {
334
+ id: 'typingMessage',
335
+ type: 'typing',
336
+ avatarInfo: {
337
+ name: 'Ginger Ventura'
338
+ },
339
+ message: args.message,
340
+ senderId: 'gingerVentura',
341
+ senderType: 'customer'
342
+ }
343
+ ],
344
+ onScrollToButtonClick: () => {
345
+ const newRandomMessageId = Math.random().toString(36).substr(2, 9);
346
+ setChatMessages(prevChatMessages => prevChatMessages.map(message => {
347
+ if (message.id === NewMessageSeparatorId) {
348
+ message.id = newRandomMessageId;
404
349
  }
405
- ] }) }));
350
+ return message;
351
+ }));
352
+ const timeOutId = window.setTimeout(() => {
353
+ setChatMessages(prevChatMessages => prevChatMessages.filter(({ id }) => id !== newRandomMessageId));
354
+ timers.current = timers.current.filter(id => id !== timeOutId);
355
+ }, 5000);
356
+ timers.current.push(timeOutId);
357
+ setUnreadMessageCount(0);
358
+ },
359
+ loadMore: action('Load more'),
360
+ offset: 5,
361
+ loading: args.loading
362
+ };
406
363
  const chatComposerImperativeHandleRef = useRef(null);
407
364
  const [mountPopover, setMountPopover] = useState(false);
408
365
  const specialKeysConfig = {
@@ -464,24 +421,7 @@ export const StandardChat = (args) => {
464
421
  return { id: item.id, primary: item.message };
465
422
  });
466
423
  }, [pagePushList]);
467
- const footer = (_jsxs(ChatComposer, { ref: chatComposerImperativeHandleRef, maxAttachments: args.maxAttachments, attachments: attachments, specialKeysConfig: specialKeysConfig, showEmoji: true, disabled: args.disableChat, onAddAttachment: () => {
468
- setAttachments([
469
- ...attachments,
470
- {
471
- id: `${attachments.length} statement.pdf`,
472
- name: `${attachments.length} statement.pdf`,
473
- onDelete: onDeleteAttachment
474
- }
475
- ]);
476
- }, maxLength: args.maxLength, placeholder: args.placeholder, defaultMessage: args.defaultMessage, onSend: message => {
477
- action(`onAppendMessage: ${message}`)();
478
- appendMessage({
479
- ...participants.sender,
480
- type: 'message',
481
- message,
482
- timeStamp: '1:45 PM'
483
- });
484
- }, children: [_jsx(Button, { ref: setButtonEl, onClick: () => setIsOpen(cur => !cur), variant: 'secondary', disabled: args.disableChat, children: _jsxs(Flex, { container: { alignItems: 'center', gap: 1 }, children: [_jsx(Text, { children: "Phrases" }), _jsx(Icon, { name: 'arrow-micro-down' })] }) }), _jsx(Popover, { show: isOpen, ref: setPopoverEl, target: buttonEl, children: _jsx(Menu, { id: menuID, listId: menuListID, mode: 'action', variant: 'flyout', items: itemsToRender, role: 'listbox', onItemClick: id => {
424
+ const composerChildren = (_jsxs(_Fragment, { children: [_jsx(Button, { ref: setButtonEl, onClick: () => setIsOpen(cur => !cur), variant: 'secondary', disabled: args.disableChat, children: _jsxs(Flex, { container: { alignItems: 'center', gap: 1 }, children: [_jsx(Text, { children: "Phrases" }), _jsx(Icon, { name: 'arrow-micro-down' })] }) }), _jsx(Popover, { show: isOpen, ref: setPopoverEl, target: buttonEl, children: _jsx(Menu, { id: menuID, listId: menuListID, mode: 'action', variant: 'flyout', items: itemsToRender, role: 'listbox', onItemClick: id => {
485
425
  insertPhrasesMessage(phrasesMessages.filter(message => message.id === id)[0].message);
486
426
  setAnnouncement('Phrase inserted');
487
427
  setIsOpen(false);
@@ -504,22 +444,84 @@ export const StandardChat = (args) => {
504
444
  insertPhrasesMessage(phrasesMessages.filter(message => message.id === id)[0].message);
505
445
  setAnnouncement('Phrase inserted');
506
446
  }, focusControlEl: chatComposerImperativeHandleRef?.current?.textAreaRef?.current }) })] }));
507
- const suggestedReplyPicker = suggestedReplies.length > 0 && showSuggestedReplies ? (_jsx(SuggestedReplyPicker, { replies: suggestedReplies, onSelect: (suggestedReply) => {
447
+ const composerProps = {
448
+ ref: chatComposerImperativeHandleRef,
449
+ maxAttachments: args.maxAttachments,
450
+ attachments,
451
+ specialKeysConfig,
452
+ showEmoji: true,
453
+ disabled: args.disableChat,
454
+ onAddAttachment: () => {
455
+ setAttachments([
456
+ ...attachments,
457
+ {
458
+ id: `${attachments.length} statement.pdf`,
459
+ name: `${attachments.length} statement.pdf`,
460
+ onDelete: onDeleteAttachment
461
+ }
462
+ ]);
463
+ },
464
+ maxLength: args.maxLength,
465
+ placeholder: args.placeholder,
466
+ defaultMessage: args.defaultMessage,
467
+ onSend: (message) => {
468
+ action(`onAppendMessage: ${message}`)();
469
+ appendMessage({
470
+ senderType: 'agent',
471
+ direction: 'out',
472
+ avatarInfo: {
473
+ name: 'Edward Green'
474
+ },
475
+ type: 'message',
476
+ message,
477
+ timeStamp: '2:08'
478
+ });
479
+ },
480
+ children: composerChildren
481
+ };
482
+ const suggestedReplyPickerProps = {
483
+ replies: suggestedReplies,
484
+ onSelect: (suggestedReply) => {
508
485
  chatComposerImperativeHandleRef.current?.appendToMessage(suggestedReply.message, 'cursor');
509
486
  setShowSuggestedReplies(false);
510
- }, onDismiss: () => {
487
+ },
488
+ onDismiss: () => {
511
489
  setShowSuggestedReplies(false);
512
- } })) : undefined;
490
+ }
491
+ };
513
492
  const fetchGoogleSprite = () => {
514
493
  return 'https://unpkg.com/emoji-datasource-google@5.0.1/img/google/sheets-256/64.png';
515
494
  };
516
495
  return (_jsx(EmojiContext.Provider, { value: { set: 'google', spriteSrcResolver: fetchGoogleSprite }, children: _jsxs(Flex, { container: {
517
496
  justify: 'center'
518
497
  }, style: {
519
- height: 'calc(100vh)',
498
+ height: args.chatHeight || 'calc(100vh)',
520
499
  width: args.chatWidth || '30rem',
521
500
  margin: 'auto'
522
- }, children: [_jsx(VisuallyHiddenText, { "aria-live": 'assertive', children: announcement }), _jsx(Chat, { utility: utilityComp, header: header, banner: args.showChatBanner ? chatBanner : undefined, body: body, footer: footer, suggestedReplyPicker: suggestedReplyPicker })] }) }));
501
+ }, children: [_jsx(VisuallyHiddenText, { "aria-live": 'assertive', children: announcement }), _jsx(Chat, { header: {
502
+ title: Channels.options[args.selectedChannel || 'LiveChat'].title,
503
+ icon: Channels.options[args.selectedChannel || 'LiveChat'].icon,
504
+ customer: 'Ginger Ventura',
505
+ authenticated: true,
506
+ sentiment: { variant: 'positive' },
507
+ context: {
508
+ items: contextItems,
509
+ onClick: () => {
510
+ setContextLoading(true);
511
+ setTimeout(() => {
512
+ setContextItems(contextItemsMock);
513
+ setContextLoading(false);
514
+ }, 1000);
515
+ },
516
+ loading: contextLoading
517
+ },
518
+ actions: [
519
+ { id: 'action-1', primary: 'Transfer' },
520
+ { id: 'action-2', primary: 'End chat' }
521
+ ]
522
+ }, banner: args.showChatBanner ? chatBanner : undefined, body: bodyProps, suggestedReplyPicker: suggestedReplies.length > 0 && showSuggestedReplies
523
+ ? suggestedReplyPickerProps
524
+ : undefined, composer: composerProps })] }) }));
523
525
  };
524
526
  StandardChat.args = {
525
527
  maxAttachments: 2,
@@ -530,7 +532,8 @@ StandardChat.args = {
530
532
  message: '',
531
533
  placeholder: 'Enter message',
532
534
  defaultMessage: 'Greetings! Hope you are having a great time, Please reach out to us for any help, Thanks!',
533
- maxLength: 280
535
+ maxLength: 280,
536
+ loading: false
534
537
  };
535
538
  StandardChat.argTypes = {
536
539
  maxAttachments: { control: { type: 'number' } },
@@ -541,7 +544,8 @@ StandardChat.argTypes = {
541
544
  message: { control: { type: 'text' } },
542
545
  placeholder: { control: { type: 'text' } },
543
546
  defaultMessage: { control: { type: 'text' } },
544
- maxLength: { control: { type: 'number' } }
547
+ maxLength: { control: { type: 'number' } },
548
+ loading: { control: { type: 'boolean' } }
545
549
  };
546
550
  StandardChat.parameters = {
547
551
  layout: 'fullscreen'