@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,12 +1,12 @@
1
1
  import { useState, useRef, useEffect, useCallback, useMemo } from 'react';
2
2
  import { action } from '@storybook/addon-actions';
3
- 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';
3
+ 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';
4
4
  import * as arrowMicroDownIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/arrow-micro-down.icon';
5
5
  import * as replyIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/reply.icon';
6
6
  import * as replyAllIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/reply-all.icon';
7
7
  import * as forwardIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/forward.icon';
8
- import { Chat, ChatHeader, ChatBody, ChatComposer, ChatTranscript, Message, MessageList, NewMessageSeparatorId, SuggestedReplyPicker, SystemMessage, TranscriptMessage, TypeIndicator } from '@pega/cosmos-react-social';
9
- import { ChatMockData, phrasesDisplayNames, phrasesMessages, pagePushList, contextItems as contextItemsMock } from './Chat.mocks';
8
+ import { Chat, ChatHeader, ChatComposer, Message, NewMessageSeparatorId, SuggestedReplyPicker, SystemMessage, TypeIndicator } from '@pega/cosmos-react-social';
9
+ import { ChatMockData, phrasesDisplayNames, phrasesMessages, pagePushList, contextItems as contextItemsMock, BotConversation, ClaimsAgentConversation, LiveChatConversation } from './Chat.mocks';
10
10
  registerIcon(forwardIcon, replyIcon, replyAllIcon, arrowMicroDownIcon);
11
11
  export default {
12
12
  title: 'Social/Chat',
@@ -17,8 +17,8 @@ export const ChatHeaderDemo = (args) => {
17
17
  const [contextItems, setContextItems] = useState([]);
18
18
  const [loading, setLoading] = useState(false);
19
19
  return (<ChatHeader title={title} icon={icon || 'chat'} actions={[
20
- { id: 'action-1', text: 'Transfer' },
21
- { id: 'action-2', text: 'End chat' }
20
+ { id: 'action-1', primary: 'Transfer' },
21
+ { id: 'action-2', primary: 'End chat' }
22
22
  ]} sentiment={{
23
23
  variant: 'positive',
24
24
  'aria-label': 'Sentiment is positive'
@@ -46,16 +46,6 @@ ChatHeaderDemo.argTypes = {
46
46
  customer: { control: { type: 'text' } },
47
47
  authenticated: { control: { type: 'boolean' }, type: { name: 'string', required: false } }
48
48
  };
49
- export const MessageListDemo = (args) => {
50
- const messages = ChatMockData.chatMessages;
51
- const [unReadMessageCount, setUnReadMessagesCount] = useState(1);
52
- return (<Flex container style={{ height: '80vh' }}>
53
- <MessageList tabIndex={0} messages={messages} unReadMessageCount={unReadMessageCount} onScrollToButtonClick={args.onScrollToButtonClick ||
54
- (() => {
55
- setUnReadMessagesCount(0);
56
- })}/>
57
- </Flex>);
58
- };
59
49
  export const MessageDemo = (args) => {
60
50
  const actions = [
61
51
  {
@@ -90,7 +80,7 @@ export const MessageDemo = (args) => {
90
80
  actions
91
81
  }
92
82
  ];
93
- const pagePushLinks = [
83
+ const mediaPageLinks = [
94
84
  {
95
85
  id: '2499167349',
96
86
  href: 'https://collaborate.pega.com/',
@@ -99,37 +89,64 @@ export const MessageDemo = (args) => {
99
89
  }
100
90
  ];
101
91
  return (<>
102
-
103
- <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}/>
104
- <br />
105
-
106
- <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}/>
107
- <br />
108
-
109
- <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
+ <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}/>
110
100
  </>);
111
101
  };
112
102
  MessageDemo.args = {
113
- variant: 'receiver',
114
- direction: 'in'
103
+ direction: 'in',
104
+ senderType: 'customer',
105
+ agentVariant: 0,
106
+ message: 'Hi, Welcome to u-plus. How can I help you ?',
107
+ showStatus: true,
108
+ status: 'delivered',
109
+ showTimestamp: true,
110
+ timestamp: '1:44 PM',
111
+ showHeader: false,
112
+ headerContent: 'Public Reply',
113
+ headerMeta: 'I-12345',
114
+ showAvatarImage: false,
115
+ showAttachments: false,
116
+ showMediaPageLinks: false
115
117
  };
116
118
  MessageDemo.argTypes = {
117
- variant: { options: ['receiver', 'sender', 'other'], control: { type: 'select' } },
118
- direction: { options: ['in', 'out'], control: { type: 'select' } }
119
+ direction: { options: ['in', 'out'], control: { type: 'inline-radio' } },
120
+ senderType: { options: ['agent', 'customer', 'bot'], control: { type: 'inline-radio' } },
121
+ agentVariant: { type: 'number' },
122
+ message: { type: 'string' },
123
+ showTimestamp: { type: 'boolean' },
124
+ timestamp: { control: 'text' },
125
+ showStatus: { type: 'boolean' },
126
+ status: {
127
+ options: ['delivered', 'opened', 'undeliverable'],
128
+ control: { type: 'inline-radio' }
129
+ },
130
+ showHeader: { control: 'boolean' },
131
+ headerContent: { control: 'text' },
132
+ headerMeta: { control: 'text' },
133
+ showAvatarImage: { control: 'boolean' },
134
+ showAttachments: { control: 'boolean' },
135
+ showMediaPageLinks: { control: 'boolean' }
119
136
  };
120
- export const SystemMessageDemo = (args) => (<SystemMessage message={args.message} timeStamp={args.timeStamp} variant={args.variant}/>);
137
+ export const SystemMessageDemo = (args) => (<SystemMessage message={args.message} timestamp={args.timestamp} variant={args.variant}/>);
121
138
  SystemMessageDemo.args = {
122
139
  message: 'John Brown has joined',
123
140
  variant: 'secondary',
124
- timeStamp: '10:00 AM'
141
+ timestamp: '10:00 AM'
125
142
  };
126
143
  SystemMessageDemo.argTypes = {
127
144
  message: { control: { type: 'text' } },
128
145
  variant: { options: ['primary', 'secondary'], control: { type: 'select' } },
129
- timeStamp: { control: { type: 'text' } }
146
+ timestamp: { control: { type: 'text' } }
130
147
  };
131
148
  export const TypeIndicatorDemo = (args) => {
132
- return <TypeIndicator avatarInfo={{ name: 'John Brown' }} message={args.message}/>;
149
+ return (<TypeIndicator avatarInfo={{ name: 'John Brown' }} message={args.message} senderId='johnBrown' senderType='agent'/>);
133
150
  };
134
151
  TypeIndicatorDemo.args = {
135
152
  message: ''
@@ -137,56 +154,8 @@ TypeIndicatorDemo.args = {
137
154
  TypeIndicatorDemo.argTypes = {
138
155
  message: { control: { type: 'text' } }
139
156
  };
140
- export const ChatTranscriptsDemo = () => {
141
- return (<>
142
- {ChatMockData.transcripts.map((transcript) => {
143
- return (<ChatTranscript tabIndex={0} title={transcript.title} key={transcript.id} transcript={transcript.data}/>);
144
- })}
145
- </>);
146
- };
147
- export const TranscriptMessageDemo = (args) => (<TranscriptMessage timeStamp={args.timeStamp} variant={args.variant} message={args.message} transcriptHeader={args.transcriptHeaderContent || args.transcriptHeaderMeta
148
- ? { content: args.transcriptHeaderContent, meta: args.transcriptHeaderMeta }
149
- : undefined} avatarInfo={args.avatarInfoName
150
- ? {
151
- name: args.avatarInfoName,
152
- imageSrc: args.avatarInfoImageSrc
153
- }
154
- : undefined}/>);
155
- TranscriptMessageDemo.args = {
156
- message: 'Hello… This is bot. How can I help you? Please select your category.',
157
- variant: 'bot',
158
- timeStamp: '01:20 PM',
159
- transcriptHeaderContent: undefined,
160
- transcriptHeaderMeta: undefined,
161
- avatarInfoName: undefined,
162
- avatarInfoImageSrc: undefined
163
- };
164
- TranscriptMessageDemo.argTypes = {
165
- message: { type: { name: 'string', required: true }, control: { type: 'text' } },
166
- variant: {
167
- type: { name: 'string', required: true },
168
- control: { type: 'select', options: ['user', 'bot', 'question'] }
169
- },
170
- timeStamp: { type: { name: 'string', required: true }, control: { type: 'text' } },
171
- transcriptHeaderContent: { type: { name: 'string', required: false }, control: { type: 'text' } },
172
- transcriptHeaderMeta: { type: { name: 'string', required: false }, control: { type: 'text' } },
173
- avatarInfoName: { type: { name: 'string', required: false }, control: { type: 'text' } },
174
- avatarInfoImageSrc: { type: { name: 'string', required: false }, control: { type: 'text' } }
175
- };
176
157
  export const SuggestedReplyPickerDemo = () => {
177
- const suggestedReplies = [
178
- {
179
- id: createUID(),
180
- message: 'Hello, Good morning Sara. How can I help you today',
181
- confidence: 95
182
- },
183
- {
184
- id: createUID(),
185
- 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',
186
- confidence: 75
187
- }
188
- ];
189
- return (<SuggestedReplyPicker replies={suggestedReplies} onSelect={suggestedReply => {
158
+ return (<SuggestedReplyPicker replies={ChatMockData.suggestedReplies} onSelect={suggestedReply => {
190
159
  action(`Suggested reply picked ${suggestedReply.message}`)();
191
160
  }} onDismiss={action('Suggested reply dismissed')}/>);
192
161
  };
@@ -221,28 +190,7 @@ export const StandardChat = (args) => {
221
190
  }
222
191
  }
223
192
  };
224
- const { participants, chatMessages: mockChatMessagesJson, transcripts, defaultAttachments, suggestedReplies } = ChatMockDataClone;
225
- const conversationRatingMessage = {
226
- id: createUID(),
227
- variant: 'receiver',
228
- direction: 'in',
229
- type: 'message',
230
- message: (<Flex container={{
231
- direction: 'column',
232
- gap: 1
233
- }}>
234
- <TextArea placeholder='Please comment…' label='Please comment on our service performance and how we can better serve you. Thank you for your time.'/>
235
- <Select label='Is the problem resolved?'>
236
- <Option>Yes</Option>
237
- <Option>No</Option>
238
- </Select>
239
- <Flex container={{
240
- justify: 'center'
241
- }}>
242
- <Button variant='primary'>Submit</Button>
243
- </Flex>
244
- </Flex>)
245
- };
193
+ const { chatMessages: mockChatMessagesJson, defaultAttachments, suggestedReplies } = ChatMockDataClone;
246
194
  const { create } = useModalManager();
247
195
  const MyModal = () => {
248
196
  const { dismiss } = useModalContext();
@@ -312,8 +260,7 @@ export const StandardChat = (args) => {
312
260
  });
313
261
  }
314
262
  return restMessageData;
315
- }),
316
- conversationRatingMessage
263
+ })
317
264
  ];
318
265
  }, []);
319
266
  const conversationRef = useRef(null);
@@ -324,10 +271,21 @@ export const StandardChat = (args) => {
324
271
  };
325
272
  }, []);
326
273
  const [showSuggestedReplies, setShowSuggestedReplies] = useState(true);
327
- const [showTranscripts, setShowTranscripts] = useState(false);
328
274
  const [attachments, setAttachments] = useState(defaultAttachments);
329
- const [unreadMessagesCount, setUnreadMessagesCount] = useState(0);
330
- const [chatMessages, setChatMessages] = useState(args.simulateConversation ? mockChatMessages.slice(0, 0) : mockChatMessages);
275
+ const [unreadMessageCount, setUnreadMessageCount] = useState(0);
276
+ const [chatMessages, setChatMessages] = useState(LiveChatConversation.map(message => {
277
+ if (message.type === 'message' && message.attachments) {
278
+ message.attachments = message.attachments.map((item) => {
279
+ return {
280
+ ...item,
281
+ actions
282
+ };
283
+ });
284
+ }
285
+ return message;
286
+ }));
287
+ const [contextItems, setContextItems] = useState([]);
288
+ const [contextLoading, setContextLoading] = useState(false);
331
289
  const onDeleteAttachment = useCallback((name) => {
332
290
  setAttachments(prevAttachments => prevAttachments.filter(item => item.name !== name));
333
291
  }, [setAttachments]);
@@ -362,7 +320,7 @@ export const StandardChat = (args) => {
362
320
  return [...prevChatMessages, newMockMessage];
363
321
  });
364
322
  if (!incrementUnreadMessageCount) {
365
- setUnreadMessagesCount(prevCount => prevCount + 1);
323
+ setUnreadMessageCount(prevCount => prevCount + 1);
366
324
  }
367
325
  };
368
326
  useEffect(() => {
@@ -377,48 +335,31 @@ export const StandardChat = (args) => {
377
335
  };
378
336
  }
379
337
  }, [chatMessages, args.simulateConversation]);
380
- const header = (<ChatHeaderDemo title={Channels.options[args.selectedChannel || 'LiveChat'].title} icon={Channels.options[args.selectedChannel || 'LiveChat'].icon} customer='Ginger Ventura' authenticated/>);
381
- const [showEarlierTranscripts, setShowEarlierTranscripts] = useState(false);
382
- const transcriptsContainerRef = useRef(null);
383
- useOuterEvent('mousedown', [transcriptsContainerRef], () => {
384
- setShowTranscripts(false);
385
- });
386
- const utilityComp = useMemo(() => {
387
- return showTranscripts ? (<div ref={transcriptsContainerRef}>
388
- {!showEarlierTranscripts && (<Flex container={{
389
- direction: 'column',
390
- alignItems: 'center',
391
- gap: 1
392
- }}>
393
- <Button icon aria-label='Show earlier transcripts' variant='secondary' onClick={() => {
394
- setShowEarlierTranscripts(!showEarlierTranscripts);
395
- }}>
396
- <Icon name='caret-up'/>
397
- </Button>
398
- </Flex>)}
399
- {transcripts
400
- .sort((transcript) => transcript.earlierTranscripts)
401
- .filter((transcript) => showEarlierTranscripts ? true : !transcript.earlierTranscripts)
402
- .map((transcript) => {
403
- const transcriptData = transcript.data.map((message) => {
404
- if (message.messagePrivacy) {
405
- message.transcriptHeader = {
406
- content: <Status variant='warn'>{message.messagePrivacy.privacy}</Status>,
407
- meta: <Link href='/'>I-12345</Link>
408
- };
409
- }
410
- return message;
411
- });
412
- return (<ChatTranscript tabIndex={0} title={transcript.title} key={transcript.id} transcript={transcriptData}/>);
413
- })}
414
- </div>) : undefined;
415
- }, [showTranscripts, setShowTranscripts, showEarlierTranscripts, setShowEarlierTranscripts]);
416
338
  const chatBanner = {
417
339
  messages: ['This is a public interaction and any responses will be public and visible'],
418
340
  variant: 'warning'
419
341
  };
420
- const body = (<ChatBody>
421
- <MessageList unReadMessageCount={unreadMessagesCount} onScrollToButtonClick={() => {
342
+ const bodyProps = {
343
+ unreadMessageCount,
344
+ handle: conversationRef,
345
+ transcripts: [
346
+ { id: createUID(), messages: BotConversation },
347
+ { id: createUID(), messages: ClaimsAgentConversation }
348
+ ],
349
+ liveChat: [
350
+ ...chatMessages,
351
+ {
352
+ id: 'typingMessage',
353
+ type: 'typing',
354
+ avatarInfo: {
355
+ name: 'Ginger Ventura'
356
+ },
357
+ message: args.message,
358
+ senderId: 'gingerVentura',
359
+ senderType: 'customer'
360
+ }
361
+ ],
362
+ onScrollToButtonClick: () => {
422
363
  const newRandomMessageId = Math.random().toString(36).substr(2, 9);
423
364
  setChatMessages(prevChatMessages => prevChatMessages.map(message => {
424
365
  if (message.id === NewMessageSeparatorId) {
@@ -431,21 +372,12 @@ export const StandardChat = (args) => {
431
372
  timers.current = timers.current.filter(id => id !== timeOutId);
432
373
  }, 5000);
433
374
  timers.current.push(timeOutId);
434
- setUnreadMessagesCount(0);
435
- }} ref={conversationRef} messages={[
436
- ...chatMessages,
437
- {
438
- id: 'Pegasystems',
439
- type: 'typing',
440
- avatarInfo: {
441
- name: 'Pegasystems',
442
- imageSrc: 'https://www.pega.com/sites/default/files/media/images/2018-12/Pega.com-og.png'
443
- },
444
- message: args.message,
445
- ariaLabel: 'Pegasystems is typing'
446
- }
447
- ]}/>
448
- </ChatBody>);
375
+ setUnreadMessageCount(0);
376
+ },
377
+ loadMore: action('Load more'),
378
+ offset: 5,
379
+ loading: args.loading
380
+ };
449
381
  const chatComposerImperativeHandleRef = useRef(null);
450
382
  const [mountPopover, setMountPopover] = useState(false);
451
383
  const specialKeysConfig = {
@@ -507,24 +439,7 @@ export const StandardChat = (args) => {
507
439
  return { id: item.id, primary: item.message };
508
440
  });
509
441
  }, [pagePushList]);
510
- const footer = (<ChatComposer ref={chatComposerImperativeHandleRef} maxAttachments={args.maxAttachments} attachments={attachments} specialKeysConfig={specialKeysConfig} showEmoji disabled={args.disableChat} onAddAttachment={() => {
511
- setAttachments([
512
- ...attachments,
513
- {
514
- id: `${attachments.length} statement.pdf`,
515
- name: `${attachments.length} statement.pdf`,
516
- onDelete: onDeleteAttachment
517
- }
518
- ]);
519
- }} maxLength={args.maxLength} placeholder={args.placeholder} defaultMessage={args.defaultMessage} onSend={message => {
520
- action(`onAppendMessage: ${message}`)();
521
- appendMessage({
522
- ...participants.sender,
523
- type: 'message',
524
- message,
525
- timeStamp: '1:45 PM'
526
- });
527
- }}>
442
+ const composerChildren = (<>
528
443
  <Button ref={setButtonEl} onClick={() => setIsOpen(cur => !cur)} variant='secondary' disabled={args.disableChat}>
529
444
  <Flex container={{ alignItems: 'center', gap: 1 }}>
530
445
  <Text>Phrases</Text>
@@ -562,13 +477,52 @@ export const StandardChat = (args) => {
562
477
  setAnnouncement('Phrase inserted');
563
478
  }} focusControlEl={chatComposerImperativeHandleRef?.current?.textAreaRef?.current}/>
564
479
  </Popover>
565
- </ChatComposer>);
566
- const suggestedReplyPicker = suggestedReplies.length > 0 && showSuggestedReplies ? (<SuggestedReplyPicker replies={suggestedReplies} onSelect={(suggestedReply) => {
480
+ </>);
481
+ const composerProps = {
482
+ ref: chatComposerImperativeHandleRef,
483
+ maxAttachments: args.maxAttachments,
484
+ attachments,
485
+ specialKeysConfig,
486
+ showEmoji: true,
487
+ disabled: args.disableChat,
488
+ onAddAttachment: () => {
489
+ setAttachments([
490
+ ...attachments,
491
+ {
492
+ id: `${attachments.length} statement.pdf`,
493
+ name: `${attachments.length} statement.pdf`,
494
+ onDelete: onDeleteAttachment
495
+ }
496
+ ]);
497
+ },
498
+ maxLength: args.maxLength,
499
+ placeholder: args.placeholder,
500
+ defaultMessage: args.defaultMessage,
501
+ onSend: (message) => {
502
+ action(`onAppendMessage: ${message}`)();
503
+ appendMessage({
504
+ senderType: 'agent',
505
+ direction: 'out',
506
+ avatarInfo: {
507
+ name: 'Edward Green'
508
+ },
509
+ type: 'message',
510
+ message,
511
+ timeStamp: '2:08'
512
+ });
513
+ },
514
+ children: composerChildren
515
+ };
516
+ const suggestedReplyPickerProps = {
517
+ replies: suggestedReplies,
518
+ onSelect: (suggestedReply) => {
567
519
  chatComposerImperativeHandleRef.current?.appendToMessage(suggestedReply.message, 'cursor');
568
520
  setShowSuggestedReplies(false);
569
- }} onDismiss={() => {
521
+ },
522
+ onDismiss: () => {
570
523
  setShowSuggestedReplies(false);
571
- }}/>) : undefined;
524
+ }
525
+ };
572
526
  const fetchGoogleSprite = () => {
573
527
  return 'https://unpkg.com/emoji-datasource-google@5.0.1/img/google/sheets-256/64.png';
574
528
  };
@@ -576,12 +530,35 @@ export const StandardChat = (args) => {
576
530
  <Flex container={{
577
531
  justify: 'center'
578
532
  }} style={{
579
- height: 'calc(100vh)',
533
+ height: args.chatHeight || 'calc(100vh)',
580
534
  width: args.chatWidth || '30rem',
581
535
  margin: 'auto'
582
536
  }}>
583
537
  <VisuallyHiddenText aria-live='assertive'>{announcement}</VisuallyHiddenText>
584
- <Chat utility={utilityComp} header={header} banner={args.showChatBanner ? chatBanner : undefined} body={body} footer={footer} suggestedReplyPicker={suggestedReplyPicker}/>
538
+ <Chat header={{
539
+ title: Channels.options[args.selectedChannel || 'LiveChat'].title,
540
+ icon: Channels.options[args.selectedChannel || 'LiveChat'].icon,
541
+ customer: 'Ginger Ventura',
542
+ authenticated: true,
543
+ sentiment: { variant: 'positive' },
544
+ context: {
545
+ items: contextItems,
546
+ onClick: () => {
547
+ setContextLoading(true);
548
+ setTimeout(() => {
549
+ setContextItems(contextItemsMock);
550
+ setContextLoading(false);
551
+ }, 1000);
552
+ },
553
+ loading: contextLoading
554
+ },
555
+ actions: [
556
+ { id: 'action-1', primary: 'Transfer' },
557
+ { id: 'action-2', primary: 'End chat' }
558
+ ]
559
+ }} banner={args.showChatBanner ? chatBanner : undefined} body={bodyProps} suggestedReplyPicker={suggestedReplies.length > 0 && showSuggestedReplies
560
+ ? suggestedReplyPickerProps
561
+ : undefined} composer={composerProps}/>
585
562
  </Flex>
586
563
  </EmojiContext.Provider>);
587
564
  };
@@ -594,7 +571,8 @@ StandardChat.args = {
594
571
  message: '',
595
572
  placeholder: 'Enter message',
596
573
  defaultMessage: 'Greetings! Hope you are having a great time, Please reach out to us for any help, Thanks!',
597
- maxLength: 280
574
+ maxLength: 280,
575
+ loading: false
598
576
  };
599
577
  StandardChat.argTypes = {
600
578
  maxAttachments: { control: { type: 'number' } },
@@ -605,7 +583,8 @@ StandardChat.argTypes = {
605
583
  message: { control: { type: 'text' } },
606
584
  placeholder: { control: { type: 'text' } },
607
585
  defaultMessage: { control: { type: 'text' } },
608
- maxLength: { control: { type: 'number' } }
586
+ maxLength: { control: { type: 'number' } },
587
+ loading: { control: { type: 'boolean' } }
609
588
  };
610
589
  StandardChat.parameters = {
611
590
  layout: 'fullscreen'