@pega/cosmos-react-demos 3.0.0-dev.24.0 → 3.0.0-dev.27.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 (145) hide show
  1. package/jsx/build/ExpressionBuilder/ExpressionBuilder.mocks.d.ts +51 -2
  2. package/jsx/build/ExpressionBuilder/ExpressionBuilder.mocks.d.ts.map +1 -1
  3. package/jsx/build/ExpressionBuilder/ExpressionBuilder.mocks.js +380 -47
  4. package/jsx/build/ExpressionBuilder/ExpressionBuilder.mocks.js.map +1 -1
  5. package/jsx/build/ExpressionBuilder/ExpressionBuilder.stories.d.ts +3 -1
  6. package/jsx/build/ExpressionBuilder/ExpressionBuilder.stories.d.ts.map +1 -1
  7. package/jsx/build/ExpressionBuilder/ExpressionBuilder.stories.jsx +206 -23
  8. package/jsx/build/ExpressionBuilder/ExpressionBuilder.stories.jsx.map +1 -1
  9. package/jsx/build/ObjectSelect/ObjectSelect.stories.d.ts.map +1 -1
  10. package/jsx/build/ObjectSelect/ObjectSelect.stories.jsx +16 -3
  11. package/jsx/build/ObjectSelect/ObjectSelect.stories.jsx.map +1 -1
  12. package/jsx/core/FieldGroup/FieldGroup.stories.d.ts +2 -0
  13. package/jsx/core/FieldGroup/FieldGroup.stories.d.ts.map +1 -1
  14. package/jsx/core/FieldGroup/FieldGroup.stories.jsx +12 -4
  15. package/jsx/core/FieldGroup/FieldGroup.stories.jsx.map +1 -1
  16. package/jsx/core/Link/Link.stories.d.ts.map +1 -1
  17. package/jsx/core/Link/Link.stories.jsx +2 -1
  18. package/jsx/core/Link/Link.stories.jsx.map +1 -1
  19. package/jsx/core/ListToolbar/ListToolbar.stories.d.ts +3 -1
  20. package/jsx/core/ListToolbar/ListToolbar.stories.d.ts.map +1 -1
  21. package/jsx/core/ListToolbar/ListToolbar.stories.jsx +15 -6
  22. package/jsx/core/ListToolbar/ListToolbar.stories.jsx.map +1 -1
  23. package/jsx/core/Modal/Modal.stories.d.ts +10 -1
  24. package/jsx/core/Modal/Modal.stories.d.ts.map +1 -1
  25. package/jsx/core/Modal/Modal.stories.jsx +33 -6
  26. package/jsx/core/Modal/Modal.stories.jsx.map +1 -1
  27. package/jsx/core/SkipLinks/SkipLinks.stories.d.ts +6 -0
  28. package/jsx/core/SkipLinks/SkipLinks.stories.d.ts.map +1 -0
  29. package/jsx/core/SkipLinks/SkipLinks.stories.jsx +29 -0
  30. package/jsx/core/SkipLinks/SkipLinks.stories.jsx.map +1 -0
  31. package/jsx/core/SkipLinks/SkipLinks.styles.d.ts +2 -0
  32. package/jsx/core/SkipLinks/SkipLinks.styles.d.ts.map +1 -0
  33. package/jsx/core/SkipLinks/SkipLinks.styles.js +16 -0
  34. package/jsx/core/SkipLinks/SkipLinks.styles.js.map +1 -0
  35. package/jsx/core/Tree/Tree.stories.d.ts.map +1 -1
  36. package/jsx/core/Tree/Tree.stories.jsx +14 -0
  37. package/jsx/core/Tree/Tree.stories.jsx.map +1 -1
  38. package/jsx/cs/TaskManager/TaskManager.stories.d.ts.map +1 -1
  39. package/jsx/cs/TaskManager/TaskManager.stories.jsx +17 -10
  40. package/jsx/cs/TaskManager/TaskManager.stories.jsx.map +1 -1
  41. package/jsx/social/Chat/Chat.mocks.d.ts +14 -1
  42. package/jsx/social/Chat/Chat.mocks.d.ts.map +1 -1
  43. package/jsx/social/Chat/Chat.mocks.js +5 -5
  44. package/jsx/social/Chat/Chat.mocks.js.map +1 -1
  45. package/jsx/social/Chat/Chat.stories.d.ts.map +1 -1
  46. package/jsx/social/Chat/Chat.stories.jsx +87 -7
  47. package/jsx/social/Chat/Chat.stories.jsx.map +1 -1
  48. package/jsx/social/Email/Email.mocks.d.ts +10 -1
  49. package/jsx/social/Email/Email.mocks.d.ts.map +1 -1
  50. package/jsx/social/Email/Email.mocks.jsx +12 -15
  51. package/jsx/social/Email/Email.mocks.jsx.map +1 -1
  52. package/jsx/social/Email/Email.stories.d.ts +15 -1
  53. package/jsx/social/Email/Email.stories.d.ts.map +1 -1
  54. package/jsx/social/Email/Email.stories.jsx +279 -108
  55. package/jsx/social/Email/Email.stories.jsx.map +1 -1
  56. package/jsx/tools/Clipboard/Clipboard.mocks.d.ts +2 -2
  57. package/jsx/tools/Clipboard/Clipboard.mocks.d.ts.map +1 -1
  58. package/jsx/tools/Clipboard/Clipboard.mocks.jsx +42 -43
  59. package/jsx/tools/Clipboard/Clipboard.mocks.jsx.map +1 -1
  60. package/jsx/tools/Clipboard/Clipboard.stories.d.ts.map +1 -1
  61. package/jsx/tools/Clipboard/Clipboard.stories.jsx +32 -31
  62. package/jsx/tools/Clipboard/Clipboard.stories.jsx.map +1 -1
  63. package/jsx/work/Details/Details.stories.d.ts.map +1 -1
  64. package/jsx/work/Details/Details.stories.jsx +7 -0
  65. package/jsx/work/Details/Details.stories.jsx.map +1 -1
  66. package/jsx/work/SearchResults/SearchResults.mocks.d.ts +6 -0
  67. package/jsx/work/SearchResults/SearchResults.mocks.d.ts.map +1 -1
  68. package/jsx/work/SearchResults/SearchResults.mocks.jsx +39 -38
  69. package/jsx/work/SearchResults/SearchResults.mocks.jsx.map +1 -1
  70. package/jsx/work/SearchResults/SearchResults.stories.d.ts.map +1 -1
  71. package/jsx/work/SearchResults/SearchResults.stories.jsx +71 -43
  72. package/jsx/work/SearchResults/SearchResults.stories.jsx.map +1 -1
  73. package/lib/build/ExpressionBuilder/ExpressionBuilder.mocks.d.ts +51 -2
  74. package/lib/build/ExpressionBuilder/ExpressionBuilder.mocks.d.ts.map +1 -1
  75. package/lib/build/ExpressionBuilder/ExpressionBuilder.mocks.js +380 -47
  76. package/lib/build/ExpressionBuilder/ExpressionBuilder.mocks.js.map +1 -1
  77. package/lib/build/ExpressionBuilder/ExpressionBuilder.stories.d.ts +3 -1
  78. package/lib/build/ExpressionBuilder/ExpressionBuilder.stories.d.ts.map +1 -1
  79. package/lib/build/ExpressionBuilder/ExpressionBuilder.stories.js +215 -26
  80. package/lib/build/ExpressionBuilder/ExpressionBuilder.stories.js.map +1 -1
  81. package/lib/build/ObjectSelect/ObjectSelect.stories.d.ts.map +1 -1
  82. package/lib/build/ObjectSelect/ObjectSelect.stories.js +16 -3
  83. package/lib/build/ObjectSelect/ObjectSelect.stories.js.map +1 -1
  84. package/lib/core/FieldGroup/FieldGroup.stories.d.ts +2 -0
  85. package/lib/core/FieldGroup/FieldGroup.stories.d.ts.map +1 -1
  86. package/lib/core/FieldGroup/FieldGroup.stories.js +11 -3
  87. package/lib/core/FieldGroup/FieldGroup.stories.js.map +1 -1
  88. package/lib/core/Link/Link.stories.d.ts.map +1 -1
  89. package/lib/core/Link/Link.stories.js +2 -1
  90. package/lib/core/Link/Link.stories.js.map +1 -1
  91. package/lib/core/ListToolbar/ListToolbar.stories.d.ts +3 -1
  92. package/lib/core/ListToolbar/ListToolbar.stories.d.ts.map +1 -1
  93. package/lib/core/ListToolbar/ListToolbar.stories.js +15 -6
  94. package/lib/core/ListToolbar/ListToolbar.stories.js.map +1 -1
  95. package/lib/core/Modal/Modal.stories.d.ts +10 -1
  96. package/lib/core/Modal/Modal.stories.d.ts.map +1 -1
  97. package/lib/core/Modal/Modal.stories.js +33 -6
  98. package/lib/core/Modal/Modal.stories.js.map +1 -1
  99. package/lib/core/SkipLinks/SkipLinks.stories.d.ts +6 -0
  100. package/lib/core/SkipLinks/SkipLinks.stories.d.ts.map +1 -0
  101. package/lib/core/SkipLinks/SkipLinks.stories.js +28 -0
  102. package/lib/core/SkipLinks/SkipLinks.stories.js.map +1 -0
  103. package/lib/core/SkipLinks/SkipLinks.styles.d.ts +2 -0
  104. package/lib/core/SkipLinks/SkipLinks.styles.d.ts.map +1 -0
  105. package/lib/core/SkipLinks/SkipLinks.styles.js +16 -0
  106. package/lib/core/SkipLinks/SkipLinks.styles.js.map +1 -0
  107. package/lib/core/Tree/Tree.stories.d.ts.map +1 -1
  108. package/lib/core/Tree/Tree.stories.js +16 -0
  109. package/lib/core/Tree/Tree.stories.js.map +1 -1
  110. package/lib/cs/TaskManager/TaskManager.stories.d.ts.map +1 -1
  111. package/lib/cs/TaskManager/TaskManager.stories.js +17 -10
  112. package/lib/cs/TaskManager/TaskManager.stories.js.map +1 -1
  113. package/lib/social/Chat/Chat.mocks.d.ts +14 -1
  114. package/lib/social/Chat/Chat.mocks.d.ts.map +1 -1
  115. package/lib/social/Chat/Chat.mocks.js +5 -5
  116. package/lib/social/Chat/Chat.mocks.js.map +1 -1
  117. package/lib/social/Chat/Chat.stories.d.ts.map +1 -1
  118. package/lib/social/Chat/Chat.stories.js +68 -6
  119. package/lib/social/Chat/Chat.stories.js.map +1 -1
  120. package/lib/social/Email/Email.mocks.d.ts +10 -1
  121. package/lib/social/Email/Email.mocks.d.ts.map +1 -1
  122. package/lib/social/Email/Email.mocks.js +12 -15
  123. package/lib/social/Email/Email.mocks.js.map +1 -1
  124. package/lib/social/Email/Email.stories.d.ts +15 -1
  125. package/lib/social/Email/Email.stories.d.ts.map +1 -1
  126. package/lib/social/Email/Email.stories.js +246 -85
  127. package/lib/social/Email/Email.stories.js.map +1 -1
  128. package/lib/tools/Clipboard/Clipboard.mocks.d.ts +2 -2
  129. package/lib/tools/Clipboard/Clipboard.mocks.d.ts.map +1 -1
  130. package/lib/tools/Clipboard/Clipboard.mocks.js +35 -40
  131. package/lib/tools/Clipboard/Clipboard.mocks.js.map +1 -1
  132. package/lib/tools/Clipboard/Clipboard.stories.d.ts.map +1 -1
  133. package/lib/tools/Clipboard/Clipboard.stories.js +40 -31
  134. package/lib/tools/Clipboard/Clipboard.stories.js.map +1 -1
  135. package/lib/work/Details/Details.stories.d.ts.map +1 -1
  136. package/lib/work/Details/Details.stories.js +1 -1
  137. package/lib/work/Details/Details.stories.js.map +1 -1
  138. package/lib/work/SearchResults/SearchResults.mocks.d.ts +6 -0
  139. package/lib/work/SearchResults/SearchResults.mocks.d.ts.map +1 -1
  140. package/lib/work/SearchResults/SearchResults.mocks.js +39 -38
  141. package/lib/work/SearchResults/SearchResults.mocks.js.map +1 -1
  142. package/lib/work/SearchResults/SearchResults.stories.d.ts.map +1 -1
  143. package/lib/work/SearchResults/SearchResults.stories.js +71 -43
  144. package/lib/work/SearchResults/SearchResults.stories.js.map +1 -1
  145. package/package.json +9 -9
@@ -2,12 +2,11 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  // cSpell:words calibri Trichy Nagercoil
3
3
  import { useState, useRef, useCallback, useEffect, createRef } from 'react';
4
4
  import { action } from '@storybook/addon-actions';
5
- import { useMemo } from '@storybook/addons';
6
- import { Card, CardContent, createUID, MenuButton, Icon, registerIcon, Flex, Button, menuHelpers, CardHeader, Text, SummaryList, Grid, FieldValueList, StyledLabel, EmptyState, Modal, useModalManager, useModalContext, useToaster } from '@pega/cosmos-react-core';
5
+ import { Card, CardContent, createUID, MenuButton, Icon, registerIcon, Flex, Button, menuHelpers, CardHeader, Text, SummaryList, Grid, FieldValueList, StyledLabel, Modal, useModalManager, useModalContext, useToaster, Banner } from '@pega/cosmos-react-core';
7
6
  import * as filterIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/filter.icon';
8
- import { Email as EmailComponent, EmailConversation, EmailComposer, EmailShell, EmailSummaryItem, EmailSummaryList, EntityList, EmailManager } from '@pega/cosmos-react-social';
7
+ import { Email as EmailComponent, EmailConversation, EmailComposer, EmailShell, EmailSummaryItem, EmailSummaryList, EntityList, EmailManager, EmailCaseView } from '@pega/cosmos-react-social';
9
8
  import { AppShellDemo } from '../../core/AppShell/AppShell.stories';
10
- import { bccParticipants, ccParticipants, emailBodyContent, participants, toParticipants, emailAttachments, EntityListMockData, viewAnalysisEmailHeaderMock, topicListMock, emailActions, generateEmailConversationParticipants, templates, handleExternalEntry, emailDemoActions, LaunchAction, baseComposerProps, sentiment, emailSummaryItems, mockEmails, mockSuggestedReplies, mockEmailBodyTemplates, forwardedContent, getCompositeId, emptyFieldErrorMessage, fieldValidation, emailWorklistItemsMock, contextMenuItemsMock, highlightedEntitiesMock, mockUploadImage } from './Email.mocks';
9
+ import { bccParticipants, ccParticipants, emailBodyContent, participants, toParticipants, emailAttachments, EntityListMockData, viewAnalysisEmailHeaderMock, topicListMock, generateEmailConversationParticipants, templates, handleExternalEntry, emailDemoActions, LaunchAction, baseComposerProps, sentiment, emailSummaryItems, mockEmails, mockSuggestedReplies, mockEmailBodyTemplates, forwardedContent, getCompositeId, emptyFieldErrorMessage, fieldValidation, emailWorklistItemsMock, contextMenuItemsMock, highlightedEntitiesMock, mockUploadImage, mailDeliverySystemEmail, supportTeamEmail } from './Email.mocks';
11
10
  import { StyledEmailCardContent } from './Email.styles';
12
11
  registerIcon(filterIcon);
13
12
  export default {
@@ -15,25 +14,54 @@ export default {
15
14
  component: EmailComponent
16
15
  };
17
16
  export const Email = (args) => {
18
- const emailImperativeHandle = useRef(null);
17
+ const contextMenuHandle = useRef(null);
19
18
  const timeout = useRef(null);
20
- const handleRightClick = () => {
21
- if (timeout.current) {
22
- clearTimeout(timeout.current);
19
+ const handleRightClick = (id, e) => {
20
+ action('onContextMenu')(id, e);
21
+ if (contextMenuHandle.current && args.enableContextMenu) {
22
+ const { setItems, setOpen, setLoading } = contextMenuHandle.current;
23
+ // Deciding not to show browser context menu
24
+ // This should be synchronus
25
+ e.preventDefault();
26
+ // Now open the custom context menu using the handle and show loader
27
+ setLoading(true);
28
+ setItems([]);
29
+ setOpen(true);
30
+ if (timeout.current) {
31
+ clearTimeout(timeout.current);
32
+ }
33
+ timeout.current = window.setTimeout(() => {
34
+ setItems(contextMenuItemsMock);
35
+ // Hide the loader
36
+ setLoading(false);
37
+ }, 1000);
23
38
  }
24
- timeout.current = window.setTimeout(() => {
25
- emailImperativeHandle.current?.setContextMenuItems(contextMenuItemsMock);
26
- }, 1000);
27
39
  };
28
- return (_jsx(Card, { children: _jsx(StyledEmailCardContent, { children: _jsx(EmailComponent, { id: createUID(), timeStamp: '2021-01-05T09:12', from: mockEmails['Laura Stevens'], cc: [mockEmails['Adam Gillchrist'], mockEmails['John Paul']], bcc: [mockEmails['Anton, Randy'], mockEmails['Hugh Phillips']], to: [mockEmails['Sara Davis'], mockEmails['John Brown'], mockEmails['Joe Stevens']], body: '<div>Hi,<br/><p>I am one of the customer of Indian Overseas Bank, <b><i>Nagercoil</i></b> branch, with code <b><a href="www.google.com"><i>3967</i></a></b>. I have a saving bank account here. My account number is <i>6785420965476</i>.</p><br/><p>I have been given a debit cum ATM card from this bank and the same has been lost when I was traveling from Nagercoil to Trichy by Bus on Jan 04, 2021. I remember that my ATM card number was 1920 6746 8653 1256.</p><br/>I hereby request you to block my debit card immediately to prevent misuse of the same by some others. Also I request you to give me an new debit card as early as possible.<br/><br/>Regards,<br/>Laura Stevens</div>', forwardedContent: args.forwardedContent, entityHighlightMapping: args.enableEntityHighlighting ? highlightedEntitiesMock : undefined, subject: 'I lost my debit card', onReply: action('On reply'), onReplyAll: action('On reply all'), onForward: action('On forward'), onSuggestionClick: action('On Suggested reply clicked'), sentiment: {
29
- variant: 'neutral'
30
- }, actions: emailActions, suggestions: mockSuggestedReplies, contextMenu: args.enableContextMenu
40
+ useEffect(() => {
41
+ return () => {
42
+ if (timeout.current) {
43
+ window.clearTimeout(timeout.current);
44
+ }
45
+ };
46
+ }, []);
47
+ return (_jsx(Card, { children: _jsx(StyledEmailCardContent, { children: _jsx(EmailComponent, { id: createUID(), timeStamp: '2021-01-05T09:12', from: mockEmails['Laura Stevens'], cc: [mockEmails['Adam Gillchrist'], mockEmails['John Paul']], bcc: [mockEmails['Anton, Randy'], mockEmails['Hugh Phillips']], to: [mockEmails['Sara Davis'], mockEmails['John Brown'], mockEmails['Joe Stevens']], body: '<div>Hi,<br/><p>I am one of the customer of Indian Overseas Bank, <b><i>Nagercoil</i></b> branch, with code <b><a href="www.google.com"><i>3967</i></a></b>. I have a saving bank account here. My account number is <i>6785420965476</i>.</p><br/><p>I have been given a debit cum ATM card from this bank and the same has been lost when I was traveling from Nagercoil to Trichy by Bus on Jan 04, 2021. I remember that my ATM card number was 1920 6746 8653 1256.</p><br/>I hereby request you to block my debit card immediately to prevent misuse of the same by some others. Also I request you to give me an new debit card as early as possible.<br/><br/>Regards,<br/>Laura Stevens</div>', forwardedContent: args.forwardedContent, entityHighlightMapping: args.enableEntityHighlighting ? highlightedEntitiesMock : undefined, subject: 'I lost my debit card', banner: args.showEmailBanner
31
48
  ? {
32
- onItemClick: action('onItemClick'),
33
- onContextMenu: handleRightClick,
34
- handle: emailImperativeHandle
49
+ id: 'banner_1',
50
+ heading: 'Address not found ',
51
+ messages: [
52
+ '550 5.1.1 The email account that you tried to reach does not exist. Please try double-checking the recipients email address for typos or unnecessary spaces. Learn more at https://support.google.com/mail/?p=NoSuchUser k24-20020aa790d8000000b0050dd7e3b84csor451330pfk.28'
53
+ ]
35
54
  }
36
- : undefined, attachments: [
55
+ : undefined, onReply: args.showDraft ? undefined : action('On reply'), onReplyAll: args.showDraft ? undefined : action('On reply all'), onForward: args.showDraft ? undefined : action('On forward'), onEditDraft: args.showDraft ? action('On forward') : undefined, onDeleteDraft: args.showDraft ? action('On forward') : undefined, onSuggestionClick: action('On Suggested reply clicked'), sentiment: {
56
+ variant: 'neutral'
57
+ }, status: args.showDraft ? 'draft' : undefined, suggestions: mockSuggestedReplies, contextMenu: {
58
+ onItemClick: (selectedValue) => {
59
+ action('onItemClick')(selectedValue);
60
+ contextMenuHandle.current?.setOpen(false);
61
+ },
62
+ onContextMenu: handleRightClick,
63
+ handle: contextMenuHandle
64
+ }, attachments: [
37
65
  {
38
66
  id: 'attachment_0',
39
67
  value: 'https://pega.com/media/document.doc',
@@ -56,12 +84,16 @@ Email.args = {
56
84
  enableEntityHighlighting: false,
57
85
  enableContextMenu: false,
58
86
  // eslint-disable-next-line demo-patterns/literal-args
59
- forwardedContent
87
+ forwardedContent,
88
+ showEmailBanner: false,
89
+ showDraft: false
60
90
  };
61
91
  Email.argTypes = {
62
92
  enableEntityHighlighting: { control: { type: 'boolean' } },
63
93
  enableContextMenu: { control: { type: 'boolean' } },
64
- forwardedContent: { control: { type: 'text' } }
94
+ forwardedContent: { control: { type: 'text' } },
95
+ showEmailBanner: { control: { type: 'boolean' } },
96
+ showDraft: { control: { type: 'boolean' } }
65
97
  };
66
98
  // ______ ______ .___ ___. .______ ______ _______. _______ .______
67
99
  // / | / __ \ | \/ | | _ \ / __ \ / || ____|| _ \
@@ -243,7 +275,6 @@ export const Conversation = () => {
243
275
  onReply: action('On reply'),
244
276
  onForward: action('On forward'),
245
277
  onSuggestionClick: action('On Suggested reply clicked'),
246
- actions: emailActions,
247
278
  suggestions: mockSuggestedReplies
248
279
  },
249
280
  {
@@ -256,8 +287,7 @@ export const Conversation = () => {
256
287
  body: '<div> Hi, <br /> <br /> <div>I’m still at the airport, I need help now!! </div> <br /><br /> Regards, <br /> Sara Davis </div>',
257
288
  onReply: action('On reply'),
258
289
  onForward: action('On forward'),
259
- onSuggestionClick: action('On Suggested reply clicked'),
260
- actions: emailActions
290
+ onSuggestionClick: action('On Suggested reply clicked')
261
291
  }
262
292
  ];
263
293
  return (_jsx(EmailConversation, { participants: generateEmailConversationParticipants(emailArr), from: generateEmailConversationParticipants(emailArr, ['from'])[0], to: generateEmailConversationParticipants(emailArr, ['to']), id: createUID(), timeStamp: emailArr[0].timeStamp, unReadEmailCount: emailArr.filter(item => item.unRead).length, emails: emailArr }));
@@ -392,7 +422,7 @@ export const EmailShellDemo = (args) => {
392
422
  };
393
423
  const MyModal = ({ currentID }) => {
394
424
  const { dismiss } = useModalContext();
395
- return (_jsx(Modal, { heading: 'Discard unsaved changes?', actions: _jsxs(_Fragment, { children: [_jsxs(Flex, { children: [_jsx(Button, { onClick: () => {
425
+ return (_jsx(Modal, { heading: 'Discard unsaved changes?', actions: _jsxs(_Fragment, { children: [_jsx(Button, { onClick: dismiss, children: "Go back" }), _jsxs(Flex, { children: [_jsx(Button, { onClick: () => {
396
426
  dismiss();
397
427
  setComposersData(prev => {
398
428
  return {
@@ -411,16 +441,14 @@ export const EmailShellDemo = (args) => {
411
441
  });
412
442
  push({ content: 'Draft Saved' });
413
443
  }, 1000);
414
- }, children: "Save as draft" }), _jsx(Button, { onClick: () => {
444
+ }, children: "Save & close" }), _jsx(Button, { variant: 'primary', onClick: () => {
415
445
  dismiss();
416
446
  setComposersData(prev => {
417
447
  const newComposersData = { ...prev };
418
448
  delete newComposersData[currentID];
419
449
  return newComposersData;
420
450
  });
421
- }, children: "Discard" })] }), _jsx(Button, { variant: 'primary', onClick: () => {
422
- dismiss();
423
- }, children: "Cancel" })] }), center: true, children: _jsx(Text, { variant: 'primary', children: "You have unsaved changes. You can discard them or go back to keep working." }) }));
451
+ }, children: "Discard" })] })] }), children: _jsx(Text, { variant: 'primary', children: "You have unsaved changes. You can discard them or go back to keep working." }) }));
424
452
  };
425
453
  const handleCancel = (uid) => {
426
454
  create(MyModal, { currentID: uid }, { alert: true });
@@ -579,27 +607,64 @@ export const EmailShellDemo = (args) => {
579
607
  }
580
608
  };
581
609
  });
610
+ const DeleteDraft = ({ currentID }) => {
611
+ const { dismiss } = useModalContext();
612
+ return (_jsx(Modal, { heading: 'Delete draft?', actions: _jsxs(_Fragment, { children: [_jsx(Button, { onClick: dismiss, children: "Go back" }), _jsx(Button, { variant: 'primary', onClick: () => {
613
+ dismiss();
614
+ setConversationEmails(prev => {
615
+ const newEmailConversation = [];
616
+ prev.forEach(arr => {
617
+ const newArr = arr.filter(index => index.id !== currentID);
618
+ if (newArr.length !== 0)
619
+ newEmailConversation.push(newArr);
620
+ });
621
+ return newEmailConversation;
622
+ });
623
+ }, children: "Delete" })] }), children: _jsx(Text, { children: "Are you sure that you want to permanently delete the selected message?" }) }));
624
+ };
582
625
  const deleteEmail = (id) => {
583
- setConversationEmails(prev => {
584
- const newEmailConversation = [];
585
- prev.forEach(arr => {
586
- const newArr = arr.filter(index => index.id !== id);
587
- if (newArr.length !== 0)
588
- newEmailConversation.push(newArr);
589
- });
590
- return newEmailConversation;
591
- });
626
+ create(DeleteDraft, { currentID: id }, { alert: true });
592
627
  };
593
628
  useEffect(() => {
594
629
  setConversationEmails([
595
- [{ ...emailsData[0] }, { ...emailsData[1], status: 'undelivered' }],
630
+ [
631
+ {
632
+ ...emailsData[1],
633
+ id: 'item0',
634
+ from: mailDeliverySystemEmail,
635
+ to: [supportTeamEmail],
636
+ body: '<div>Hi, <br /> <br /><div>Your address change request is approved.</div> <br /> <br />Regards, <br />Support team </div>',
637
+ banner: {
638
+ id: 'banner_1',
639
+ heading: 'Address not found ',
640
+ messages: [
641
+ '550 5.1.1 The email account that you tried to reach does not exist. Please try double-checking the recipients email address for typos or unnecessary spaces. Learn more at https://support.google.com/mail/?p=NoSuchUser k24-20020aa790d8000000b0050dd7e3b84csor451330pfk.28'
642
+ ]
643
+ },
644
+ onReply: undefined,
645
+ onForward: undefined
646
+ },
647
+ { ...emailsData[1], unRead: false }
648
+ ],
596
649
  [
597
650
  {
598
651
  ...emailsData[0],
599
652
  id: 'item2',
600
653
  status: 'draft',
654
+ onEditDraft: (id) => createOrActivateComposer(id, LaunchAction.REPLY, {
655
+ ...baseComposerProps,
656
+ data: {
657
+ ...baseComposerProps.data,
658
+ responseType: 'reply',
659
+ subject: { value: `Re-${emailsData[0].subject}` || '' },
660
+ bodyContent: { defaultValue: emailsData[0].body || '' }
661
+ }
662
+ }),
663
+ onDeleteDraft: (id) => deleteEmail(id),
664
+ onReply: undefined,
665
+ onForward: undefined,
666
+ suggestions: undefined,
601
667
  unRead: false,
602
- actions: emailDemoActions('item2', emailsData[0].subject, createOrActivateComposer, true, '<div>Hi, <br /> <br /><div>Sure, Our executive will come and check your connection in 24hrs. </div> <br />Regards, <br />Hugh Phillips </div>', deleteEmail),
603
668
  timeStamp: '2021-01-03T17:15',
604
669
  from: mockEmails['Hugh Phillips'],
605
670
  to: [mockEmails['Mystery Rey'], ...emailsData[0].to],
@@ -611,7 +676,19 @@ export const EmailShellDemo = (args) => {
611
676
  ...emailsData[1],
612
677
  id: 'item3',
613
678
  status: 'draft',
614
- actions: emailDemoActions('item3', emailsData[0].subject, createOrActivateComposer, true, '<div>Hi, <br /> <br /><div>Can you fix my internet connection. </div> <br /> <br />Regards, <br />Rey Mystery </div>', deleteEmail),
679
+ onEditDraft: (id) => createOrActivateComposer(id, LaunchAction.REPLY, {
680
+ ...baseComposerProps,
681
+ data: {
682
+ ...baseComposerProps.data,
683
+ responseType: 'reply',
684
+ subject: { value: `Re-${emailsData[0].subject}` || '' },
685
+ bodyContent: { defaultValue: emailsData[0].body || '' }
686
+ }
687
+ }),
688
+ onDeleteDraft: (id) => deleteEmail(id),
689
+ onReply: undefined,
690
+ onForward: undefined,
691
+ suggestions: undefined,
615
692
  unRead: false,
616
693
  timeStamp: '2021-01-02T14:16',
617
694
  from: mockEmails['Mystery Rey'],
@@ -646,8 +723,8 @@ export const EmailShellDemo = (args) => {
646
723
  }, []);
647
724
  const emailConversations = conversationEmails.map((emails, i) => {
648
725
  return {
649
- from: generateEmailConversationParticipants(emails, ['from'])[0],
650
- to: emails[0].to,
726
+ from: i === 0 ? emails[1].from : generateEmailConversationParticipants(emails, ['from'])[0],
727
+ to: i === 0 ? emails[1].to : emails[0].to,
651
728
  id: `item_${i}`,
652
729
  timeStamp: emails[0].timeStamp,
653
730
  unReadEmailCount: emails.filter(item => item.unRead).length,
@@ -665,54 +742,94 @@ export const EmailShellDemo = (args) => {
665
742
  to: generateEmailConversationParticipants(emailsData, ['to']),
666
743
  id: 'item_0',
667
744
  timeStamp: new Date(emailsData[0].timeStamp),
668
- unReadEmailCount: emailsData.filter(item => item.unRead).length,
669
- emails: [{ ...emailsData[0], status: 'undelivered' }, { ...emailsData[1] }]
745
+ unReadEmailCount: 1,
746
+ emails: [
747
+ {
748
+ ...emailsData[1],
749
+ id: 'item0',
750
+ from: mailDeliverySystemEmail,
751
+ to: [supportTeamEmail],
752
+ body: '<div>Hi, <br /> <br /><div>Your address change request is approved.</div> <br /> <br />Regards, <br />Support team </div>',
753
+ banner: {
754
+ id: 'banner_1',
755
+ heading: 'Address not found ',
756
+ messages: [
757
+ '550 5.1.1 The email account that you tried to reach does not exist. Please try double-checking the recipients email address for typos or unnecessary spaces. Learn more at https://support.google.com/mail/?p=NoSuchUser k24-20020aa790d8000000b0050dd7e3b84csor451330pfk.28'
758
+ ]
759
+ },
760
+ onReply: undefined,
761
+ onForward: undefined
762
+ },
763
+ { ...emailsData[1], unRead: false }
764
+ ]
670
765
  }
671
766
  ];
672
- return (_jsxs(_Fragment, { children: [_jsx(EmailShell, { headerProps: {
673
- actions: (_jsxs(Flex, { container: {
674
- alignItems: 'center',
675
- gap: 0
676
- }, children: [_jsx(Button, { variant: 'simple', icon: true, children: _jsx(Icon, { name: 'filter' }) }), _jsx(MenuButton, { variant: 'simple', text: 'More actions', icon: 'more', iconOnly: true, portal: true, menu: { items: actions } })] })),
677
- subject: 'Pause service'
678
- }, autoCollapse: args.autoCollapse, conversations: args.singleConversation ? singleEmailConversation : emailConversations }), _jsx(_Fragment, { children: Object.keys(composersData).map(guid => {
767
+ return (_jsxs(_Fragment, { children: [_jsx(EmailShell, { headerProps: args.showHeader
768
+ ? {
769
+ actions: (_jsxs(Flex, { container: {
770
+ alignItems: 'center',
771
+ gap: 0
772
+ }, children: [_jsx(Button, { variant: 'simple', icon: true, children: _jsx(Icon, { name: 'filter' }) }), _jsx(MenuButton, { variant: 'simple', text: 'More actions', icon: 'more', iconOnly: true, portal: true, menu: { items: actions } })] })),
773
+ subject: 'Pause service'
774
+ }
775
+ : undefined, autoCollapse: args.autoCollapse, conversations: args.singleConversation ? singleEmailConversation : emailConversations }), _jsx(_Fragment, { children: Object.keys(composersData).map(guid => {
679
776
  return _jsx(EmailComposer, { ...composersData[guid] }, guid);
680
777
  }) })] }));
681
778
  };
682
779
  EmailShellDemo.args = {
683
780
  autoCollapse: true,
684
781
  hideSuggestions: false,
685
- singleConversation: true
782
+ singleConversation: false,
783
+ showHeader: true
686
784
  };
687
785
  EmailShellDemo.argTypes = {
688
786
  autoCollapse: { control: { type: 'boolean' } },
689
787
  hideSuggestions: { control: { type: 'boolean' } },
690
- singleConversation: { control: { type: 'boolean' } }
788
+ singleConversation: { control: { type: 'boolean' } },
789
+ showHeader: { control: { type: 'boolean' } }
691
790
  };
692
791
  export const EntityListDemo = (args) => {
693
792
  const itemCounter = useRef(3);
694
793
  const timeout = useRef(null);
695
- const imperativeHandle = useRef(null);
794
+ const contextMenuHandle = useRef(null);
696
795
  const headerProps = {
697
796
  icon: 'list-number',
698
797
  text: 'Entities'
699
798
  };
700
- const handleRightClick = () => {
701
- itemCounter.current += 1;
702
- if (timeout.current) {
703
- clearTimeout(timeout.current);
799
+ const handleRightClick = (e) => {
800
+ action('onContextMenu')(e);
801
+ if (contextMenuHandle.current && args.enableContextMenu) {
802
+ itemCounter.current += 1;
803
+ const { setItems, setOpen, setLoading } = contextMenuHandle.current;
804
+ // Deciding not to show browser context menu
805
+ // This should be synchronus
806
+ e.preventDefault();
807
+ // Now open the custom context menu using the handle and show loader
808
+ setLoading(true);
809
+ setItems([]);
810
+ setOpen(true);
811
+ if (timeout.current) {
812
+ window.clearTimeout(timeout.current);
813
+ }
814
+ timeout.current = window.setTimeout(() => {
815
+ setItems(contextMenuItemsMock);
816
+ // Hide the loader
817
+ setLoading(false);
818
+ }, 1000);
704
819
  }
705
- timeout.current = window.setTimeout(() => {
706
- imperativeHandle.current?.setContextMenuItems(contextMenuItemsMock);
707
- }, 1000);
708
820
  };
709
- return (_jsx(EntityList, { header: headerProps, content: EntityListMockData, contextMenu: args.enableContextMenu
710
- ? {
711
- onItemClick: action('onItemClick'),
712
- onContextMenu: args.onContextMenu || handleRightClick,
713
- handle: imperativeHandle
821
+ useEffect(() => {
822
+ return () => {
823
+ if (timeout.current) {
824
+ window.clearTimeout(timeout.current);
714
825
  }
715
- : undefined }));
826
+ };
827
+ }, []);
828
+ return (_jsx(EntityList, { header: headerProps, content: EntityListMockData, contextMenu: {
829
+ onItemClick: action('onItemClick'),
830
+ onContextMenu: args.onContextMenu || handleRightClick,
831
+ handle: contextMenuHandle
832
+ } }));
716
833
  };
717
834
  EntityListDemo.args = {
718
835
  enableContextMenu: true
@@ -781,15 +898,48 @@ export const EmailSummaryListDemo = (args) => {
781
898
  }, [loading]);
782
899
  return (_jsx(EmailSummaryList, { ref: emailSummaryListRef, unreadEmailCount: 99, categories: categories, items: args.items || allEmailItems, onItemClick: args.onItemClick || handleItemClick, onCategoryClick: onCategoryClick, onLoadMore: args.onLoadMore || (hasMore ? loadMore : undefined), loading: args.loading || loading, emptyMessage: 'No emails.' }));
783
900
  };
901
+ export const EmailCaseViewDemo = (args) => {
902
+ const content = _jsx(EmailShellDemo, {});
903
+ const utilities = (
904
+ // View analysis utility
905
+ _jsxs(Grid, { container: { rowGap: 2 }, children: [_jsx(EntityListDemo, {}), _jsxs(Card, { children: [_jsxs(CardHeader, { container: { alignItems: 'center', gap: 1 }, children: [_jsx(Icon, { name: 'document-doc' }), _jsx(Text, { variant: 'h3', children: "Email header" })] }), _jsx(CardContent, { children: _jsx(FieldValueList, { fields: viewAnalysisEmailHeaderMock, variant: 'stacked' }) })] }), _jsx(SummaryList, { name: 'Topics', icon: 'headline', items: topicListMock.map(items => ({
906
+ ...items,
907
+ primary: _jsx(StyledLabel, { children: items.primary }),
908
+ secondary: (_jsxs(Flex, { container: { direction: 'row', justify: 'between' }, children: [_jsx(Text, { variant: 'primary', children: items.secondary.indicator }), _jsx(StyledLabel, { children: items.secondary.value })] }))
909
+ })), noItemsText: 'No items' })] }));
910
+ return (_jsx(AppShellDemo, { appHeader: true, main: _jsx(EmailCaseView, { header: args.showHeader
911
+ ? {
912
+ icon: 'mail',
913
+ title: 'ET-5432'
914
+ }
915
+ : undefined, banners: args.showBanners && (_jsx(Banner, { id: 'error', variant: 'urgent', heading: 'Error', messages: ['Your email could not be delivered due to poor network connection.'] })), content: content, utilities: !args.noUtilityView && utilities, utilitiesSummaryItems: !args.noUtilityView
916
+ ? [
917
+ { iconName: 'list-number', count: 7 },
918
+ { iconName: 'document-doc', count: 1 },
919
+ { iconName: 'headline', count: 4 }
920
+ ]
921
+ : undefined, defaultUtilitiesExpanded: true }) }));
922
+ };
923
+ EmailCaseViewDemo.args = {
924
+ showBanners: false,
925
+ noUtilityView: false,
926
+ showHeader: true
927
+ };
928
+ EmailCaseViewDemo.argTypes = {
929
+ showBanners: { control: { type: 'boolean' } },
930
+ noUtilityView: { control: { type: 'boolean' } },
931
+ showHeader: { control: { type: 'boolean' } }
932
+ };
933
+ EmailCaseViewDemo.parameters = {
934
+ layout: 'fullscreen'
935
+ };
784
936
  export const EmailManagerAppShell = (args) => {
785
937
  const INITIAL_CHUNK_SIZE = 9;
786
938
  const APPEND_CHUNK_SIZE = 1;
787
- const [activeItemId, setActiveItemId] = useState();
788
939
  const [emailList, setEmailList] = useState(emailSummaryItems.slice(0, INITIAL_CHUNK_SIZE));
789
940
  const [loading, setLoading] = useState(false);
790
941
  const [hasMore, setHasMore] = useState(true);
791
942
  const handleEmailItemClick = (id) => {
792
- setActiveItemId(id);
793
943
  const index = emailList.findIndex(emailItem => {
794
944
  return emailItem.id === id;
795
945
  });
@@ -813,31 +963,42 @@ export const EmailManagerAppShell = (args) => {
813
963
  }, 1500);
814
964
  }
815
965
  }, [loading]);
816
- const activeItemIndex = useMemo(() => emailList.findIndex(emailItem => emailItem.id === activeItemId), [activeItemId, emailList]);
817
- const content = activeItemId === undefined ? (_jsx(EmptyState, { message: 'No item selected!' })) : (_jsx(EmailShellDemo, { singleConversation: activeItemIndex % 2 !== 0 }));
818
- const utilities = activeItemId === undefined ? null : (
966
+ const utilities = (
819
967
  // View analysis utility
820
- _jsxs(Grid, { container: { rowGap: 2 }, children: [_jsx(EntityListDemo, { onContextMenu: args.onContextMenu, enableContextMenu: args.enableContextMenu }), _jsxs(Card, { children: [_jsxs(CardHeader, { container: { alignItems: 'center', gap: 1 }, children: [_jsx(Icon, { name: 'document-doc' }), _jsx(Text, { variant: 'h3', children: "Email header" })] }), _jsx(CardContent, { children: _jsx(FieldValueList, { fields: viewAnalysisEmailHeaderMock, variant: 'stacked' }) })] }), _jsx(SummaryList, { name: 'Topics', icon: 'headline', items: topicListMock.map(items => ({
968
+ _jsxs(Grid, { container: { rowGap: 2 }, children: [_jsx(EntityListDemo, {}), _jsxs(Card, { children: [_jsxs(CardHeader, { container: { alignItems: 'center', gap: 1 }, children: [_jsx(Icon, { name: 'document-doc' }), _jsx(Text, { variant: 'h3', children: "Email header" })] }), _jsx(CardContent, { children: _jsx(FieldValueList, { fields: viewAnalysisEmailHeaderMock, variant: 'stacked' }) })] }), _jsx(SummaryList, { name: 'Topics', icon: 'headline', items: topicListMock.map(items => ({
821
969
  ...items,
822
970
  primary: _jsx(StyledLabel, { children: items.primary }),
823
971
  secondary: (_jsxs(Flex, { container: { direction: 'row', justify: 'between' }, children: [_jsx(Text, { variant: 'primary', children: items.secondary.indicator }), _jsx(StyledLabel, { children: items.secondary.value })] }))
824
972
  })), noItemsText: 'No items' })] }));
825
- return (_jsx(AppShellDemo, { appHeader: true, main: _jsx(EmailManager, { header: {
826
- icon: 'mail',
827
- title: 'Inbox'
828
- }, list: _jsx(EmailSummaryListDemo, { onItemClick: handleEmailItemClick, items: emailList, onLoadMore: hasMore ? onLoadMore : undefined, loading: loading }), content: content, utilities: utilities, utilitiesSummaryItems: utilities
829
- ? [
830
- { iconName: 'list-number', count: 7 },
831
- { iconName: 'document-doc', count: 1 },
832
- { iconName: 'headline', count: 4 }
833
- ]
834
- : undefined, defaultCollapsedUtilities: !!utilities }) }));
973
+ const content = _jsx(EmailShellDemo, { showHeader: false });
974
+ return (_jsx(AppShellDemo, { appHeader: true, main: _jsx(EmailManager, { header: args.showHeader
975
+ ? {
976
+ icon: 'mail',
977
+ title: 'Inbox'
978
+ }
979
+ : undefined, list: _jsx(EmailSummaryListDemo, { onItemClick: handleEmailItemClick, items: emailList, onLoadMore: hasMore ? onLoadMore : undefined, loading: loading }), emailCaseDetails: !args.showEmptyView && (_jsx(EmailCaseView, { banners: args.showCaseViewBanners && (_jsx(Banner, { id: 'error', variant: 'urgent', heading: 'Error', messages: [
980
+ 'Your email could not be delivered due to poor network connection.'
981
+ ] })), content: content, utilities: args.showUtilities && utilities, utilitiesSummaryItems: args.showUtilities
982
+ ? [
983
+ { iconName: 'list-number', count: 7 },
984
+ { iconName: 'document-doc', count: 1 },
985
+ { iconName: 'headline', count: 4 }
986
+ ]
987
+ : undefined, defaultUtilitiesExpanded: false })) }) }));
835
988
  };
836
989
  EmailManagerAppShell.args = {
837
- enableContextMenu: true
990
+ enableContextMenu: true,
991
+ showEmptyView: false,
992
+ showHeader: true,
993
+ showCaseViewBanners: false,
994
+ showUtilities: true
838
995
  };
839
996
  EmailManagerAppShell.argTypes = {
840
- enableContextMenu: { control: { type: 'boolean' } }
997
+ enableContextMenu: { control: { type: 'boolean' } },
998
+ showEmptyView: { control: { type: 'boolean' } },
999
+ showHeader: { control: { type: 'boolean' } },
1000
+ showCaseViewBanners: { control: { type: 'boolean' } },
1001
+ showUtilities: { control: { type: 'boolean' } }
841
1002
  };
842
1003
  EmailManagerAppShell.parameters = {
843
1004
  layout: 'fullscreen'