@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.
- package/jsx/build/ExpressionBuilder/ExpressionBuilder.mocks.d.ts +51 -2
- package/jsx/build/ExpressionBuilder/ExpressionBuilder.mocks.d.ts.map +1 -1
- package/jsx/build/ExpressionBuilder/ExpressionBuilder.mocks.js +380 -47
- package/jsx/build/ExpressionBuilder/ExpressionBuilder.mocks.js.map +1 -1
- package/jsx/build/ExpressionBuilder/ExpressionBuilder.stories.d.ts +3 -1
- package/jsx/build/ExpressionBuilder/ExpressionBuilder.stories.d.ts.map +1 -1
- package/jsx/build/ExpressionBuilder/ExpressionBuilder.stories.jsx +206 -23
- package/jsx/build/ExpressionBuilder/ExpressionBuilder.stories.jsx.map +1 -1
- package/jsx/build/ObjectSelect/ObjectSelect.stories.d.ts.map +1 -1
- package/jsx/build/ObjectSelect/ObjectSelect.stories.jsx +16 -3
- package/jsx/build/ObjectSelect/ObjectSelect.stories.jsx.map +1 -1
- package/jsx/core/FieldGroup/FieldGroup.stories.d.ts +2 -0
- package/jsx/core/FieldGroup/FieldGroup.stories.d.ts.map +1 -1
- package/jsx/core/FieldGroup/FieldGroup.stories.jsx +12 -4
- package/jsx/core/FieldGroup/FieldGroup.stories.jsx.map +1 -1
- package/jsx/core/Link/Link.stories.d.ts.map +1 -1
- package/jsx/core/Link/Link.stories.jsx +2 -1
- package/jsx/core/Link/Link.stories.jsx.map +1 -1
- package/jsx/core/ListToolbar/ListToolbar.stories.d.ts +3 -1
- package/jsx/core/ListToolbar/ListToolbar.stories.d.ts.map +1 -1
- package/jsx/core/ListToolbar/ListToolbar.stories.jsx +15 -6
- package/jsx/core/ListToolbar/ListToolbar.stories.jsx.map +1 -1
- package/jsx/core/Modal/Modal.stories.d.ts +10 -1
- package/jsx/core/Modal/Modal.stories.d.ts.map +1 -1
- package/jsx/core/Modal/Modal.stories.jsx +33 -6
- package/jsx/core/Modal/Modal.stories.jsx.map +1 -1
- package/jsx/core/SkipLinks/SkipLinks.stories.d.ts +6 -0
- package/jsx/core/SkipLinks/SkipLinks.stories.d.ts.map +1 -0
- package/jsx/core/SkipLinks/SkipLinks.stories.jsx +29 -0
- package/jsx/core/SkipLinks/SkipLinks.stories.jsx.map +1 -0
- package/jsx/core/SkipLinks/SkipLinks.styles.d.ts +2 -0
- package/jsx/core/SkipLinks/SkipLinks.styles.d.ts.map +1 -0
- package/jsx/core/SkipLinks/SkipLinks.styles.js +16 -0
- package/jsx/core/SkipLinks/SkipLinks.styles.js.map +1 -0
- package/jsx/core/Tree/Tree.stories.d.ts.map +1 -1
- package/jsx/core/Tree/Tree.stories.jsx +14 -0
- package/jsx/core/Tree/Tree.stories.jsx.map +1 -1
- package/jsx/cs/TaskManager/TaskManager.stories.d.ts.map +1 -1
- package/jsx/cs/TaskManager/TaskManager.stories.jsx +17 -10
- package/jsx/cs/TaskManager/TaskManager.stories.jsx.map +1 -1
- package/jsx/social/Chat/Chat.mocks.d.ts +14 -1
- package/jsx/social/Chat/Chat.mocks.d.ts.map +1 -1
- package/jsx/social/Chat/Chat.mocks.js +5 -5
- package/jsx/social/Chat/Chat.mocks.js.map +1 -1
- package/jsx/social/Chat/Chat.stories.d.ts.map +1 -1
- package/jsx/social/Chat/Chat.stories.jsx +87 -7
- package/jsx/social/Chat/Chat.stories.jsx.map +1 -1
- package/jsx/social/Email/Email.mocks.d.ts +10 -1
- package/jsx/social/Email/Email.mocks.d.ts.map +1 -1
- package/jsx/social/Email/Email.mocks.jsx +12 -15
- package/jsx/social/Email/Email.mocks.jsx.map +1 -1
- package/jsx/social/Email/Email.stories.d.ts +15 -1
- package/jsx/social/Email/Email.stories.d.ts.map +1 -1
- package/jsx/social/Email/Email.stories.jsx +279 -108
- package/jsx/social/Email/Email.stories.jsx.map +1 -1
- package/jsx/tools/Clipboard/Clipboard.mocks.d.ts +2 -2
- package/jsx/tools/Clipboard/Clipboard.mocks.d.ts.map +1 -1
- package/jsx/tools/Clipboard/Clipboard.mocks.jsx +42 -43
- package/jsx/tools/Clipboard/Clipboard.mocks.jsx.map +1 -1
- package/jsx/tools/Clipboard/Clipboard.stories.d.ts.map +1 -1
- package/jsx/tools/Clipboard/Clipboard.stories.jsx +32 -31
- package/jsx/tools/Clipboard/Clipboard.stories.jsx.map +1 -1
- package/jsx/work/Details/Details.stories.d.ts.map +1 -1
- package/jsx/work/Details/Details.stories.jsx +7 -0
- package/jsx/work/Details/Details.stories.jsx.map +1 -1
- package/jsx/work/SearchResults/SearchResults.mocks.d.ts +6 -0
- package/jsx/work/SearchResults/SearchResults.mocks.d.ts.map +1 -1
- package/jsx/work/SearchResults/SearchResults.mocks.jsx +39 -38
- package/jsx/work/SearchResults/SearchResults.mocks.jsx.map +1 -1
- package/jsx/work/SearchResults/SearchResults.stories.d.ts.map +1 -1
- package/jsx/work/SearchResults/SearchResults.stories.jsx +71 -43
- package/jsx/work/SearchResults/SearchResults.stories.jsx.map +1 -1
- package/lib/build/ExpressionBuilder/ExpressionBuilder.mocks.d.ts +51 -2
- package/lib/build/ExpressionBuilder/ExpressionBuilder.mocks.d.ts.map +1 -1
- package/lib/build/ExpressionBuilder/ExpressionBuilder.mocks.js +380 -47
- package/lib/build/ExpressionBuilder/ExpressionBuilder.mocks.js.map +1 -1
- package/lib/build/ExpressionBuilder/ExpressionBuilder.stories.d.ts +3 -1
- package/lib/build/ExpressionBuilder/ExpressionBuilder.stories.d.ts.map +1 -1
- package/lib/build/ExpressionBuilder/ExpressionBuilder.stories.js +215 -26
- package/lib/build/ExpressionBuilder/ExpressionBuilder.stories.js.map +1 -1
- package/lib/build/ObjectSelect/ObjectSelect.stories.d.ts.map +1 -1
- package/lib/build/ObjectSelect/ObjectSelect.stories.js +16 -3
- package/lib/build/ObjectSelect/ObjectSelect.stories.js.map +1 -1
- package/lib/core/FieldGroup/FieldGroup.stories.d.ts +2 -0
- package/lib/core/FieldGroup/FieldGroup.stories.d.ts.map +1 -1
- package/lib/core/FieldGroup/FieldGroup.stories.js +11 -3
- package/lib/core/FieldGroup/FieldGroup.stories.js.map +1 -1
- package/lib/core/Link/Link.stories.d.ts.map +1 -1
- package/lib/core/Link/Link.stories.js +2 -1
- package/lib/core/Link/Link.stories.js.map +1 -1
- package/lib/core/ListToolbar/ListToolbar.stories.d.ts +3 -1
- package/lib/core/ListToolbar/ListToolbar.stories.d.ts.map +1 -1
- package/lib/core/ListToolbar/ListToolbar.stories.js +15 -6
- package/lib/core/ListToolbar/ListToolbar.stories.js.map +1 -1
- package/lib/core/Modal/Modal.stories.d.ts +10 -1
- package/lib/core/Modal/Modal.stories.d.ts.map +1 -1
- package/lib/core/Modal/Modal.stories.js +33 -6
- package/lib/core/Modal/Modal.stories.js.map +1 -1
- package/lib/core/SkipLinks/SkipLinks.stories.d.ts +6 -0
- package/lib/core/SkipLinks/SkipLinks.stories.d.ts.map +1 -0
- package/lib/core/SkipLinks/SkipLinks.stories.js +28 -0
- package/lib/core/SkipLinks/SkipLinks.stories.js.map +1 -0
- package/lib/core/SkipLinks/SkipLinks.styles.d.ts +2 -0
- package/lib/core/SkipLinks/SkipLinks.styles.d.ts.map +1 -0
- package/lib/core/SkipLinks/SkipLinks.styles.js +16 -0
- package/lib/core/SkipLinks/SkipLinks.styles.js.map +1 -0
- package/lib/core/Tree/Tree.stories.d.ts.map +1 -1
- package/lib/core/Tree/Tree.stories.js +16 -0
- package/lib/core/Tree/Tree.stories.js.map +1 -1
- package/lib/cs/TaskManager/TaskManager.stories.d.ts.map +1 -1
- package/lib/cs/TaskManager/TaskManager.stories.js +17 -10
- package/lib/cs/TaskManager/TaskManager.stories.js.map +1 -1
- package/lib/social/Chat/Chat.mocks.d.ts +14 -1
- package/lib/social/Chat/Chat.mocks.d.ts.map +1 -1
- package/lib/social/Chat/Chat.mocks.js +5 -5
- package/lib/social/Chat/Chat.mocks.js.map +1 -1
- package/lib/social/Chat/Chat.stories.d.ts.map +1 -1
- package/lib/social/Chat/Chat.stories.js +68 -6
- package/lib/social/Chat/Chat.stories.js.map +1 -1
- package/lib/social/Email/Email.mocks.d.ts +10 -1
- package/lib/social/Email/Email.mocks.d.ts.map +1 -1
- package/lib/social/Email/Email.mocks.js +12 -15
- package/lib/social/Email/Email.mocks.js.map +1 -1
- package/lib/social/Email/Email.stories.d.ts +15 -1
- package/lib/social/Email/Email.stories.d.ts.map +1 -1
- package/lib/social/Email/Email.stories.js +246 -85
- package/lib/social/Email/Email.stories.js.map +1 -1
- package/lib/tools/Clipboard/Clipboard.mocks.d.ts +2 -2
- package/lib/tools/Clipboard/Clipboard.mocks.d.ts.map +1 -1
- package/lib/tools/Clipboard/Clipboard.mocks.js +35 -40
- package/lib/tools/Clipboard/Clipboard.mocks.js.map +1 -1
- package/lib/tools/Clipboard/Clipboard.stories.d.ts.map +1 -1
- package/lib/tools/Clipboard/Clipboard.stories.js +40 -31
- package/lib/tools/Clipboard/Clipboard.stories.js.map +1 -1
- package/lib/work/Details/Details.stories.d.ts.map +1 -1
- package/lib/work/Details/Details.stories.js +1 -1
- package/lib/work/Details/Details.stories.js.map +1 -1
- package/lib/work/SearchResults/SearchResults.mocks.d.ts +6 -0
- package/lib/work/SearchResults/SearchResults.mocks.d.ts.map +1 -1
- package/lib/work/SearchResults/SearchResults.mocks.js +39 -38
- package/lib/work/SearchResults/SearchResults.mocks.js.map +1 -1
- package/lib/work/SearchResults/SearchResults.stories.d.ts.map +1 -1
- package/lib/work/SearchResults/SearchResults.stories.js +71 -43
- package/lib/work/SearchResults/SearchResults.stories.js.map +1 -1
- 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 {
|
|
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,
|
|
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
|
|
17
|
+
const contextMenuHandle = useRef(null);
|
|
19
18
|
const timeout = useRef(null);
|
|
20
|
-
const handleRightClick = () => {
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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,
|
|
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
|
|
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(
|
|
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
|
-
|
|
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
|
-
[
|
|
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
|
-
|
|
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:
|
|
669
|
-
emails: [
|
|
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
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
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:
|
|
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
|
|
794
|
+
const contextMenuHandle = useRef(null);
|
|
696
795
|
const headerProps = {
|
|
697
796
|
icon: 'list-number',
|
|
698
797
|
text: 'Entities'
|
|
699
798
|
};
|
|
700
|
-
const handleRightClick = () => {
|
|
701
|
-
|
|
702
|
-
if (
|
|
703
|
-
|
|
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
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
handle: imperativeHandle
|
|
821
|
+
useEffect(() => {
|
|
822
|
+
return () => {
|
|
823
|
+
if (timeout.current) {
|
|
824
|
+
window.clearTimeout(timeout.current);
|
|
714
825
|
}
|
|
715
|
-
|
|
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
|
|
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, {
|
|
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
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
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'
|