@pega/cosmos-react-cs 2.0.0-dev.9.4 → 2.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/Article/Article.js +2 -10
- package/lib/components/Article/Article.js.map +1 -1
- package/lib/components/Article/ArticleFooter.d.ts.map +1 -1
- package/lib/components/Article/ArticleFooter.js +3 -4
- package/lib/components/Article/ArticleFooter.js.map +1 -1
- package/lib/components/Article/ArticleSkeleton.js +4 -4
- package/lib/components/Article/ArticleSkeleton.js.map +1 -1
- package/lib/components/ArticleList/ArticleList.d.ts.map +1 -1
- package/lib/components/ArticleList/ArticleList.js +2 -5
- package/lib/components/ArticleList/ArticleList.js.map +1 -1
- package/lib/components/ArticleList/ArticleListHeader.js +3 -8
- package/lib/components/ArticleList/ArticleListHeader.js.map +1 -1
- package/lib/components/ArticleList/ArticleSummary.js +1 -3
- package/lib/components/ArticleList/ArticleSummary.js.map +1 -1
- package/lib/components/ArticleList/SummarySkeleton.js +2 -7
- package/lib/components/ArticleList/SummarySkeleton.js.map +1 -1
- package/lib/components/CSCaseView/CSCaseView.js +1 -2
- package/lib/components/CSCaseView/CSCaseView.js.map +1 -1
- package/lib/components/CallControlPanel/Call.d.ts +6 -0
- package/lib/components/CallControlPanel/Call.d.ts.map +1 -0
- package/lib/components/CallControlPanel/Call.js +142 -0
- package/lib/components/CallControlPanel/Call.js.map +1 -0
- package/lib/components/CallControlPanel/CallControlPanel.d.ts +6 -0
- package/lib/components/CallControlPanel/CallControlPanel.d.ts.map +1 -0
- package/lib/components/CallControlPanel/CallControlPanel.js +68 -0
- package/lib/components/CallControlPanel/CallControlPanel.js.map +1 -0
- package/lib/components/CallControlPanel/CallControlPanel.styles.d.ts +15 -0
- package/lib/components/CallControlPanel/CallControlPanel.styles.d.ts.map +1 -0
- package/lib/components/CallControlPanel/CallControlPanel.styles.js +118 -0
- package/lib/components/CallControlPanel/CallControlPanel.styles.js.map +1 -0
- package/lib/components/CallControlPanel/CallControlPanel.types.d.ts +112 -0
- package/lib/components/CallControlPanel/CallControlPanel.types.d.ts.map +1 -0
- package/lib/components/CallControlPanel/CallControlPanel.types.js +2 -0
- package/lib/components/CallControlPanel/CallControlPanel.types.js.map +1 -0
- package/lib/components/CallControlPanel/CallControlPanelIcon.d.ts +19 -0
- package/lib/components/CallControlPanel/CallControlPanelIcon.d.ts.map +1 -0
- package/lib/components/CallControlPanel/CallControlPanelIcon.js +74 -0
- package/lib/components/CallControlPanel/CallControlPanelIcon.js.map +1 -0
- package/lib/components/CallControlPanel/CallTransfer.d.ts +19 -0
- package/lib/components/CallControlPanel/CallTransfer.d.ts.map +1 -0
- package/lib/components/CallControlPanel/CallTransfer.js +121 -0
- package/lib/components/CallControlPanel/CallTransfer.js.map +1 -0
- package/lib/components/CallControlPanel/CalleePicker.d.ts +20 -0
- package/lib/components/CallControlPanel/CalleePicker.d.ts.map +1 -0
- package/lib/components/CallControlPanel/CalleePicker.js +61 -0
- package/lib/components/CallControlPanel/CalleePicker.js.map +1 -0
- package/lib/components/CallControlPanel/ContactsList.d.ts +23 -0
- package/lib/components/CallControlPanel/ContactsList.d.ts.map +1 -0
- package/lib/components/CallControlPanel/ContactsList.js +88 -0
- package/lib/components/CallControlPanel/ContactsList.js.map +1 -0
- package/lib/components/CallControlPanel/DTMFKeypad.d.ts +11 -0
- package/lib/components/CallControlPanel/DTMFKeypad.d.ts.map +1 -0
- package/lib/components/CallControlPanel/DTMFKeypad.js +23 -0
- package/lib/components/CallControlPanel/DTMFKeypad.js.map +1 -0
- package/lib/components/CallControlPanel/StopWatch.d.ts +9 -0
- package/lib/components/CallControlPanel/StopWatch.d.ts.map +1 -0
- package/lib/components/CallControlPanel/StopWatch.js +28 -0
- package/lib/components/CallControlPanel/StopWatch.js.map +1 -0
- package/lib/components/CallControlPanel/index.d.ts +4 -0
- package/lib/components/CallControlPanel/index.d.ts.map +1 -0
- package/lib/components/CallControlPanel/index.js +3 -0
- package/lib/components/CallControlPanel/index.js.map +1 -0
- package/lib/components/CallControlPanel/utils.d.ts +7 -0
- package/lib/components/CallControlPanel/utils.d.ts.map +1 -0
- package/lib/components/CallControlPanel/utils.js +35 -0
- package/lib/components/CallControlPanel/utils.js.map +1 -0
- package/lib/components/DialPad/DialPad.d.ts +16 -0
- package/lib/components/DialPad/DialPad.d.ts.map +1 -0
- package/lib/components/DialPad/DialPad.js +33 -0
- package/lib/components/DialPad/DialPad.js.map +1 -0
- package/lib/components/DialPad/DialPad.types.d.ts +33 -0
- package/lib/components/DialPad/DialPad.types.d.ts.map +1 -0
- package/lib/components/DialPad/DialPad.types.js +2 -0
- package/lib/components/DialPad/DialPad.types.js.map +1 -0
- package/lib/components/DialPad/DialPadKeyboard.d.ts +12 -0
- package/lib/components/DialPad/DialPadKeyboard.d.ts.map +1 -0
- package/lib/components/DialPad/DialPadKeyboard.js +87 -0
- package/lib/components/DialPad/DialPadKeyboard.js.map +1 -0
- package/lib/components/DialPad/DialPadKeyboard.styles.d.ts +5 -0
- package/lib/components/DialPad/DialPadKeyboard.styles.d.ts.map +1 -0
- package/lib/components/DialPad/DialPadKeyboard.styles.js +76 -0
- package/lib/components/DialPad/DialPadKeyboard.styles.js.map +1 -0
- package/lib/components/DialPad/KeyboardNavigation.d.ts +6 -0
- package/lib/components/DialPad/KeyboardNavigation.d.ts.map +1 -0
- package/lib/components/DialPad/KeyboardNavigation.js +156 -0
- package/lib/components/DialPad/KeyboardNavigation.js.map +1 -0
- package/lib/components/DialPad/utils.d.ts +4 -0
- package/lib/components/DialPad/utils.d.ts.map +1 -0
- package/lib/components/DialPad/utils.js +7 -0
- package/lib/components/DialPad/utils.js.map +1 -0
- package/lib/components/IntelligentGuidance/IntelligentGuidance.d.ts.map +1 -1
- package/lib/components/IntelligentGuidance/IntelligentGuidance.js +19 -15
- package/lib/components/IntelligentGuidance/IntelligentGuidance.js.map +1 -1
- package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.d.ts +1 -0
- package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.d.ts.map +1 -1
- package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.js +2 -2
- package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.js.map +1 -1
- package/lib/components/InteractionNotification/InteractionNotification.js +2 -6
- package/lib/components/InteractionNotification/InteractionNotification.js.map +1 -1
- package/lib/components/InteractionTimer/InteractionTimer.d.ts +2 -4
- package/lib/components/InteractionTimer/InteractionTimer.d.ts.map +1 -1
- package/lib/components/InteractionTimer/InteractionTimer.js +11 -8
- package/lib/components/InteractionTimer/InteractionTimer.js.map +1 -1
- package/lib/components/TaskManager/Picker/Picker.d.ts.map +1 -1
- package/lib/components/TaskManager/Picker/Picker.js +136 -43
- package/lib/components/TaskManager/Picker/Picker.js.map +1 -1
- package/lib/components/TaskManager/Picker/Picker.types.d.ts +11 -2
- package/lib/components/TaskManager/Picker/Picker.types.d.ts.map +1 -1
- package/lib/components/TaskManager/Picker/Picker.types.js.map +1 -1
- package/lib/components/TaskManager/TaskManager.context.d.ts +1 -0
- package/lib/components/TaskManager/TaskManager.context.d.ts.map +1 -1
- package/lib/components/TaskManager/TaskManager.d.ts.map +1 -1
- package/lib/components/TaskManager/TaskManager.js +49 -63
- package/lib/components/TaskManager/TaskManager.js.map +1 -1
- package/lib/components/TaskManager/TaskManager.styles.d.ts +15 -20
- package/lib/components/TaskManager/TaskManager.styles.d.ts.map +1 -1
- package/lib/components/TaskManager/TaskManager.styles.js +173 -166
- package/lib/components/TaskManager/TaskManager.styles.js.map +1 -1
- package/lib/components/TaskManager/TaskManager.types.d.ts +12 -6
- package/lib/components/TaskManager/TaskManager.types.d.ts.map +1 -1
- package/lib/components/TaskManager/TaskManager.types.js.map +1 -1
- package/lib/components/TaskManager/TaskManagerTabs.d.ts +6 -0
- package/lib/components/TaskManager/TaskManagerTabs.d.ts.map +1 -0
- package/lib/components/TaskManager/TaskManagerTabs.js +159 -0
- package/lib/components/TaskManager/TaskManagerTabs.js.map +1 -0
- package/lib/components/TaskManager/TaskView.js +1 -3
- package/lib/components/TaskManager/TaskView.js.map +1 -1
- package/lib/components/TaskManager/index.d.ts +1 -1
- package/lib/components/TaskManager/index.d.ts.map +1 -1
- package/lib/components/TaskManager/index.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/package.json +12 -12
- package/lib/components/TaskManager/TaskDrawer.d.ts +0 -6
- package/lib/components/TaskManager/TaskDrawer.d.ts.map +0 -1
- package/lib/components/TaskManager/TaskDrawer.js +0 -78
- package/lib/components/TaskManager/TaskDrawer.js.map +0 -1
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useContext, forwardRef, useState, useMemo } from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import { Button, CardContent, CardHeader, Flex, Icon, registerIcon, Text, Card, defaultThemeProp, useI18n, RadioButtonGroup, RadioButton, TextArea, ComboBox, menuHelpers, CardFooter, useUID } from '@pega/cosmos-react-core';
|
|
5
|
+
import { StyledCardHeader } from '@pega/cosmos-react-core/lib/components/Card/CardHeader';
|
|
6
|
+
import { StyledCardContent } from '@pega/cosmos-react-core/lib/components/Card/CardContent';
|
|
7
|
+
import { StyledCardFooter } from '@pega/cosmos-react-core/lib/components/Card/CardFooter';
|
|
8
|
+
import * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';
|
|
9
|
+
import { ContactsContext } from './CalleePicker';
|
|
10
|
+
registerIcon(timesIcon);
|
|
11
|
+
export const StyledTransfer = styled(Card)(({ theme: { base: { spacing }, components: { card } } }) => {
|
|
12
|
+
return css `
|
|
13
|
+
${StyledCardHeader}, ${StyledCardContent}, ${StyledCardFooter} {
|
|
14
|
+
padding: calc(1.25 * ${spacing}) calc(${card.padding} * 2);
|
|
15
|
+
}
|
|
16
|
+
min-width: 28rem;
|
|
17
|
+
`;
|
|
18
|
+
});
|
|
19
|
+
StyledTransfer.defaultProps = defaultThemeProp;
|
|
20
|
+
const CallTransfer = forwardRef(({ onClose, onTransferCall, transferOptions }, ref) => {
|
|
21
|
+
const t = useI18n();
|
|
22
|
+
const { contacts } = useContext(ContactsContext);
|
|
23
|
+
const reasonsList = transferOptions.map(({ id, label }) => {
|
|
24
|
+
return {
|
|
25
|
+
id,
|
|
26
|
+
primary: label
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
const [reasons, setReasons] = useState(() => {
|
|
30
|
+
return menuHelpers.mapTree([...reasonsList], item => ({
|
|
31
|
+
...item,
|
|
32
|
+
selected: item.items ? undefined : !!item.selected
|
|
33
|
+
}));
|
|
34
|
+
});
|
|
35
|
+
const selectedReason = useMemo(() => menuHelpers.getSelected(reasons)[0], [reasons]);
|
|
36
|
+
const contactList = contacts.map(item => {
|
|
37
|
+
return {
|
|
38
|
+
id: item.phoneNumber,
|
|
39
|
+
primary: item.primary
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
const [itemsContacts, setItemsContacts] = useState(() => {
|
|
43
|
+
return menuHelpers.mapTree([...contactList], item => ({
|
|
44
|
+
...item,
|
|
45
|
+
selected: item.items ? undefined : !!item.selected
|
|
46
|
+
}));
|
|
47
|
+
});
|
|
48
|
+
const selectedContact = useMemo(() => menuHelpers.getSelected(itemsContacts)[0], [itemsContacts]);
|
|
49
|
+
const [filterValue, setFilterValue] = useState('');
|
|
50
|
+
const clearSelection = () => {
|
|
51
|
+
setItemsContacts(cur => menuHelpers.mapTree(cur, item => {
|
|
52
|
+
return {
|
|
53
|
+
...item,
|
|
54
|
+
selected: false
|
|
55
|
+
};
|
|
56
|
+
}));
|
|
57
|
+
};
|
|
58
|
+
const escapeChars = /[.*+\-?^${}()|[\]\\]/g;
|
|
59
|
+
const getFilterRegex = (inputValue) => {
|
|
60
|
+
return new RegExp(`^${inputValue.replace(escapeChars, '\\$&')}`, 'i');
|
|
61
|
+
};
|
|
62
|
+
const filterRegex = useMemo(() => getFilterRegex(filterValue), [filterValue]);
|
|
63
|
+
const itemsToRender = useMemo(() => {
|
|
64
|
+
const newItems = filterValue
|
|
65
|
+
? menuHelpers.flatten(itemsContacts).filter(({ primary }) => {
|
|
66
|
+
return filterRegex.test(primary);
|
|
67
|
+
})
|
|
68
|
+
: itemsContacts;
|
|
69
|
+
return menuHelpers.mapTree(newItems, item => ({
|
|
70
|
+
...item,
|
|
71
|
+
selected: item.items ? undefined : !!item.selected
|
|
72
|
+
}));
|
|
73
|
+
}, [filterValue, itemsContacts]);
|
|
74
|
+
const selectItem = (id) => {
|
|
75
|
+
setFilterValue('');
|
|
76
|
+
setItemsContacts(cur => menuHelpers.selectItem(cur, id, 'single-select'));
|
|
77
|
+
};
|
|
78
|
+
const [comments, setComments] = useState('');
|
|
79
|
+
const [interaction, setInteraction] = useState(true);
|
|
80
|
+
return (_jsxs(StyledTransfer, { ref: ref, children: [_jsx(CardHeader, { actions: _jsx(Button, { icon: true, variant: 'simple', "aria-label": t('close'), onClick: onClose, children: _jsx(Icon, { name: 'times' }, void 0) }, void 0), children: _jsx(Flex, { container: { alignItems: 'center', itemGap: 1 }, children: _jsx(Text, { variant: 'h3', children: t('call_panel_transfer_call_heading') }, void 0) }, void 0) }, void 0), _jsxs(CardContent, { container: { itemGap: 1, justify: 'start' }, children: [_jsxs(RadioButtonGroup, { name: t('call_panel_transfer_call_option_label'), children: [_jsx(RadioButton, { label: t('call_panel_transfer_call_and_interaction_option'), id: useUID(), defaultChecked: true, onChange: () => setInteraction(true) }, void 0), _jsx(RadioButton, { label: t('call_panel_transfer_call_only_option'), id: useUID(), onChange: () => setInteraction(false) }, void 0)] }, void 0), _jsx(ComboBox, { label: t('call_panel_transfer_reason_label'), required: true, selected: selectedReason
|
|
81
|
+
? {
|
|
82
|
+
items: {
|
|
83
|
+
id: selectedReason.id,
|
|
84
|
+
text: selectedReason.primary
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
: undefined, menu: {
|
|
88
|
+
items: reasons,
|
|
89
|
+
onItemClick: id => {
|
|
90
|
+
setReasons(cur => menuHelpers.selectItem(cur, id, 'single-select'));
|
|
91
|
+
}
|
|
92
|
+
} }, void 0), _jsx(TextArea, { name: 'comments', required: true, label: t('call_panel_transfer_comments_label'), displayCharCount: true, maxLength: 300, value: comments, onChange: (e) => setComments(e.target.value) }, void 0), _jsx(ComboBox, { label: t('call_panel_transfer_to_label'), required: true, selected: selectedContact
|
|
93
|
+
? {
|
|
94
|
+
items: {
|
|
95
|
+
id: selectedContact.id,
|
|
96
|
+
text: selectedContact.primary
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
: undefined, value: filterValue, onChange: (e) => {
|
|
100
|
+
if (!e.target.value)
|
|
101
|
+
clearSelection();
|
|
102
|
+
setFilterValue(e.target.value);
|
|
103
|
+
}, onBlur: () => {
|
|
104
|
+
setFilterValue('');
|
|
105
|
+
}, menu: {
|
|
106
|
+
items: itemsToRender,
|
|
107
|
+
onItemClick: selectItem,
|
|
108
|
+
accent: filterRegex,
|
|
109
|
+
emptyText: t('no_items')
|
|
110
|
+
} }, void 0)] }, void 0), _jsx(CardFooter, { alignItems: 'right', justify: 'end', children: _jsx(Button, { variant: 'primary', disabled: !(selectedReason && selectedContact && comments !== ''), onClick: () => {
|
|
111
|
+
const transferParam = {
|
|
112
|
+
reason: selectedReason.id,
|
|
113
|
+
comments,
|
|
114
|
+
interaction,
|
|
115
|
+
phoneNumber: selectedContact.id
|
|
116
|
+
};
|
|
117
|
+
onTransferCall(transferParam);
|
|
118
|
+
}, children: t('call_panel_transfer_button_label') }, void 0) }, void 0)] }, void 0));
|
|
119
|
+
});
|
|
120
|
+
export default CallTransfer;
|
|
121
|
+
//# sourceMappingURL=CallTransfer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CallTransfer.js","sourceRoot":"","sources":["../../../src/components/CallControlPanel/CallTransfer.ts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C,CAAC,SAAS,EAEf,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,CAAC,CAAgC,EAAE,EAAE;4BAC7C,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK;gCAAE,cAAc,EAAE,CAAC;4BACtC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;wBACjC,CAAC,EACD,MAAM,EAAE,GAAG,EAAE;4BACX,cAAc,CAAC,EAAE,CAAC,CAAC;wBACrB,CAAC,EACD,IAAI,EAAE;4BACJ,KAAK,EAAE,aAAa;4BACpB,WAAW,EAAE,UAAU;4BACvB,MAAM,EAAE,WAAW;4BACnB,SAAS,EAAE,CAAC,CAAC,UAAU,CAAC;yBACzB,WACD,YACU,EACd,KAAC,UAAU,IAAC,UAAU,EAAC,OAAO,EAAC,OAAO,EAAC,KAAK,YAC1C,KAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,QAAQ,EAAE,CAAC,CAAC,cAAc,IAAI,eAAe,IAAI,QAAQ,KAAK,EAAE,CAAC,EACjE,OAAO,EAAE,GAAG,EAAE;wBACZ,MAAM,aAAa,GAAG;4BACpB,MAAM,EAAE,cAAc,CAAC,EAAE;4BACzB,QAAQ;4BACR,WAAW;4BACX,WAAW,EAAE,eAAe,CAAC,EAAE;yBAChC,CAAC;wBACF,cAAc,CAAC,aAAa,CAAC,CAAC;oBAChC,CAAC,YAEA,CAAC,CAAC,kCAAkC,CAAC,WAC/B,WACE,YACE,CAClB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import {\n useContext,\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n Ref,\n useState,\n useMemo,\n ChangeEvent\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Button,\n CardContent,\n CardHeader,\n Flex,\n Icon,\n registerIcon,\n Text,\n Card,\n ForwardProps,\n defaultThemeProp,\n useI18n,\n RadioButtonGroup,\n RadioButton,\n TextArea,\n ComboBox,\n MenuProps,\n menuHelpers,\n MenuItemProps,\n CardFooter,\n useUID\n} from '@pega/cosmos-react-core';\nimport { StyledCardHeader } from '@pega/cosmos-react-core/lib/components/Card/CardHeader';\nimport { StyledCardContent } from '@pega/cosmos-react-core/lib/components/Card/CardContent';\nimport { StyledCardFooter } from '@pega/cosmos-react-core/lib/components/Card/CardFooter';\nimport * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\n\nimport type { TransferReasonOption, TransferData } from './CallControlPanel.types';\nimport { ContactsContext } from './CalleePicker';\n\nregisterIcon(timesIcon);\n\nexport interface CallTransferProps {\n /**\n * Callback fired on new call made by the user.\n * @param phoneNumber the number chosen.\n */\n onTransferCall: (transferParam: TransferData) => void;\n /** Callback fired on clicking close button. */\n onClose?: () => void;\n\n transferOptions: Readonly<TransferReasonOption[]>;\n /** Reference to the root component. */\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const StyledTransfer = styled(Card)(\n ({\n theme: {\n base: { spacing },\n components: { card }\n }\n }) => {\n return css`\n ${StyledCardHeader}, ${StyledCardContent}, ${StyledCardFooter} {\n padding: calc(1.25 * ${spacing}) calc(${card.padding} * 2);\n }\n min-width: 28rem;\n `;\n }\n);\n\nStyledTransfer.defaultProps = defaultThemeProp;\n\nconst CallTransfer: FunctionComponent<CallTransferProps & ForwardProps> = forwardRef(\n (\n { onClose, onTransferCall, transferOptions }: PropsWithoutRef<CallTransferProps>,\n ref: CallTransferProps['ref']\n ) => {\n const t = useI18n();\n const { contacts } = useContext(ContactsContext);\n\n const reasonsList = transferOptions.map(({ id, label }) => {\n return {\n id,\n primary: label\n };\n });\n\n const [reasons, setReasons] = useState<MenuProps['items']>((): MenuProps['items'] => {\n return menuHelpers.mapTree([...reasonsList], item => ({\n ...item,\n selected: item.items ? undefined : !!item.selected\n }));\n });\n\n const selectedReason = useMemo(() => menuHelpers.getSelected(reasons)[0], [reasons]);\n\n const contactList = contacts.map(item => {\n return {\n id: item.phoneNumber,\n primary: item.primary\n };\n });\n\n const [itemsContacts, setItemsContacts] = useState<MenuProps['items']>(\n (): MenuProps['items'] => {\n return menuHelpers.mapTree([...contactList], item => ({\n ...item,\n selected: item.items ? undefined : !!item.selected\n }));\n }\n );\n\n const selectedContact = useMemo(\n () => menuHelpers.getSelected(itemsContacts)[0],\n [itemsContacts]\n );\n\n const [filterValue, setFilterValue] = useState('');\n\n const clearSelection = () => {\n setItemsContacts(cur =>\n menuHelpers.mapTree(cur, item => {\n return {\n ...item,\n selected: false\n };\n })\n );\n };\n\n const escapeChars = /[.*+\\-?^${}()|[\\]\\\\]/g;\n const getFilterRegex = (inputValue: string) => {\n return new RegExp(`^${inputValue.replace(escapeChars, '\\\\$&')}`, 'i');\n };\n\n const filterRegex = useMemo(() => getFilterRegex(filterValue), [filterValue]);\n\n const itemsToRender = useMemo(() => {\n const newItems = filterValue\n ? menuHelpers.flatten(itemsContacts).filter(({ primary }: MenuItemProps) => {\n return filterRegex.test(primary);\n })\n : itemsContacts;\n\n return menuHelpers.mapTree(newItems, item => ({\n ...item,\n selected: item.items ? undefined : !!item.selected\n }));\n }, [filterValue, itemsContacts]);\n\n const selectItem = (id: MenuItemProps['id']) => {\n setFilterValue('');\n setItemsContacts(cur => menuHelpers.selectItem(cur, id, 'single-select'));\n };\n\n const [comments, setComments] = useState('');\n\n const [interaction, setInteraction] = useState(true);\n\n return (\n <StyledTransfer ref={ref}>\n <CardHeader\n actions={\n <Button icon variant='simple' aria-label={t('close')} onClick={onClose}>\n <Icon name='times' />\n </Button>\n }\n >\n <Flex container={{ alignItems: 'center', itemGap: 1 }}>\n <Text variant='h3'>{t('call_panel_transfer_call_heading')}</Text>\n </Flex>\n </CardHeader>\n <CardContent container={{ itemGap: 1, justify: 'start' }}>\n <RadioButtonGroup name={t('call_panel_transfer_call_option_label')}>\n <RadioButton\n label={t('call_panel_transfer_call_and_interaction_option')}\n id={useUID()}\n defaultChecked\n onChange={() => setInteraction(true)}\n />\n <RadioButton\n label={t('call_panel_transfer_call_only_option')}\n id={useUID()}\n onChange={() => setInteraction(false)}\n />\n </RadioButtonGroup>\n\n <ComboBox\n label={t('call_panel_transfer_reason_label')}\n required\n selected={\n selectedReason\n ? {\n items: {\n id: selectedReason.id,\n text: selectedReason.primary\n }\n }\n : undefined\n }\n menu={{\n items: reasons,\n onItemClick: id => {\n setReasons(cur => menuHelpers.selectItem(cur, id, 'single-select'));\n }\n }}\n />\n\n <TextArea\n name='comments'\n required\n label={t('call_panel_transfer_comments_label')}\n displayCharCount\n maxLength={300}\n value={comments}\n onChange={(e: ChangeEvent<HTMLTextAreaElement>) => setComments(e.target.value)}\n />\n\n <ComboBox\n label={t('call_panel_transfer_to_label')}\n required\n selected={\n selectedContact\n ? {\n items: {\n id: selectedContact.id,\n text: selectedContact.primary\n }\n }\n : undefined\n }\n value={filterValue}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n if (!e.target.value) clearSelection();\n setFilterValue(e.target.value);\n }}\n onBlur={() => {\n setFilterValue('');\n }}\n menu={{\n items: itemsToRender,\n onItemClick: selectItem,\n accent: filterRegex,\n emptyText: t('no_items')\n }}\n />\n </CardContent>\n <CardFooter alignItems='right' justify='end'>\n <Button\n variant='primary'\n disabled={!(selectedReason && selectedContact && comments !== '')}\n onClick={() => {\n const transferParam = {\n reason: selectedReason.id,\n comments,\n interaction,\n phoneNumber: selectedContact.id\n };\n onTransferCall(transferParam);\n }}\n >\n {t('call_panel_transfer_button_label')}\n </Button>\n </CardFooter>\n </StyledTransfer>\n );\n }\n);\n\nexport default CallTransfer;\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FunctionComponent, Ref } from 'react';
|
|
2
|
+
import { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import { ContactsListProps } from './ContactsList';
|
|
4
|
+
export interface CalleePickerProps {
|
|
5
|
+
/** Heading for the new call. */
|
|
6
|
+
heading: string;
|
|
7
|
+
/**
|
|
8
|
+
* Callback fired on new call made by the user.
|
|
9
|
+
* @param phoneNumber the number chosen.
|
|
10
|
+
*/
|
|
11
|
+
onCall: (phoneNumber: string) => void;
|
|
12
|
+
/** Callback fired on clicking close button. */
|
|
13
|
+
onClose?: () => void;
|
|
14
|
+
/** Reference to the root component. */
|
|
15
|
+
ref?: Ref<HTMLDivElement>;
|
|
16
|
+
}
|
|
17
|
+
export declare const ContactsContext: import("react").Context<Pick<ContactsListProps, "onFavoriteToggle" | "contacts">>;
|
|
18
|
+
declare const CalleePicker: FunctionComponent<CalleePickerProps & ForwardProps>;
|
|
19
|
+
export default CalleePicker;
|
|
20
|
+
//# sourceMappingURL=CalleePicker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CalleePicker.d.ts","sourceRoot":"","sources":["../../../src/components/CallControlPanel/CalleePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EAEjB,GAAG,EAIJ,MAAM,OAAO,CAAC;AAGf,OAAO,EAWL,YAAY,EAGb,MAAM,yBAAyB,CAAC;AAQjC,OAAqB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIjE,MAAM,WAAW,iBAAiB;IAChC,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,uCAAuC;IACvC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,eAAO,MAAM,eAAe,mFAK1B,CAAC;AAgBH,QAAA,MAAM,YAAY,EAAE,iBAAiB,CAAC,iBAAiB,GAAG,YAAY,CAsErE,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, forwardRef, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import { Button, CardContent, CardHeader, Flex, Icon, registerIcon, Text, TabPanel, Tabs, Card, defaultThemeProp, useI18n } from '@pega/cosmos-react-core';
|
|
5
|
+
import { StyledCardHeader } from '@pega/cosmos-react-core/lib/components/Card/CardHeader';
|
|
6
|
+
import { StyledCardContent } from '@pega/cosmos-react-core/lib/components/Card/CardContent';
|
|
7
|
+
import { StyledTabPanel } from '@pega/cosmos-react-core/lib/components/Tabs/TabPanel';
|
|
8
|
+
import * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';
|
|
9
|
+
import DialPad from '../DialPad/DialPad';
|
|
10
|
+
import ContactsList from './ContactsList';
|
|
11
|
+
registerIcon(timesIcon);
|
|
12
|
+
export const ContactsContext = createContext({
|
|
13
|
+
contacts: [],
|
|
14
|
+
onFavoriteToggle: () => { }
|
|
15
|
+
});
|
|
16
|
+
const StyledCalleePicker = styled(Card)(({ theme }) => {
|
|
17
|
+
return css `
|
|
18
|
+
${StyledCardHeader}, ${StyledCardContent} {
|
|
19
|
+
padding: calc(1.25 * ${theme.base.spacing}) calc(${theme.components.card.padding} * 2);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
${StyledTabPanel} {
|
|
23
|
+
height: 24rem;
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
});
|
|
27
|
+
StyledCalleePicker.defaultProps = defaultThemeProp;
|
|
28
|
+
const CalleePicker = forwardRef(({ heading, onClose, onCall }, ref) => {
|
|
29
|
+
const t = useI18n();
|
|
30
|
+
const [currentTab, setCurrentTab] = useState('all');
|
|
31
|
+
const tabsRef = useRef(null);
|
|
32
|
+
const { contacts, onFavoriteToggle } = useContext(ContactsContext);
|
|
33
|
+
const favorites = contacts.filter(item => item.favorite);
|
|
34
|
+
const handleTabChange = (id) => {
|
|
35
|
+
setCurrentTab(id);
|
|
36
|
+
};
|
|
37
|
+
const tabsHeaders = [
|
|
38
|
+
{ id: 'all', name: t('call_panel_contacts_list_heading'), count: contacts.length },
|
|
39
|
+
{
|
|
40
|
+
id: 'favorites',
|
|
41
|
+
name: t('call_panel_contacts_favorites_heading'),
|
|
42
|
+
count: contacts.filter(item => item.favorite).length
|
|
43
|
+
},
|
|
44
|
+
{ id: 'dial-pad', name: t('call_panel_contacts_dial_pad_heading') }
|
|
45
|
+
];
|
|
46
|
+
const tabContent = (tabId) => {
|
|
47
|
+
if (tabId === 'dial-pad')
|
|
48
|
+
return _jsx(DialPad, { onCallButtonClick: onCall, mode: 'default' }, void 0);
|
|
49
|
+
return (_jsx(ContactsList, { contacts: tabId === 'favorites' ? favorites : contacts, onFavoriteToggle: onFavoriteToggle, action: {
|
|
50
|
+
label: t('call_panel_contacts_call_button_label'),
|
|
51
|
+
icon: 'phone-solid',
|
|
52
|
+
callback: onCall
|
|
53
|
+
} }, void 0));
|
|
54
|
+
};
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
tabsRef.current?.firstChild.focus();
|
|
57
|
+
}, []);
|
|
58
|
+
return (_jsxs(StyledCalleePicker, { ref: ref, children: [_jsx(CardHeader, { actions: _jsx(Button, { icon: true, variant: 'simple', "aria-label": t('close'), onClick: onClose, children: _jsx(Icon, { name: 'times' }, void 0) }, void 0), children: _jsx(Flex, { container: { alignItems: 'center', itemGap: 1 }, children: _jsx(Text, { variant: 'h3', children: heading }, void 0) }, void 0) }, void 0), _jsxs(CardContent, { container: { itemGap: 2 }, children: [_jsx(Tabs, { ref: tabsRef, tabs: tabsHeaders, type: 'horizontal', onTabClick: handleTabChange, currentTabId: currentTab }, void 0), _jsx(TabPanel, { tabId: currentTab, children: tabContent(currentTab) }, void 0)] }, void 0)] }, void 0));
|
|
59
|
+
});
|
|
60
|
+
export default CalleePicker;
|
|
61
|
+
//# sourceMappingURL=CalleePicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CalleePicker.js","sourceRoot":"","sources":["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BAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE;gBACN,KAAK,EAAE,CAAC,CAAC,uCAAuC,CAAC;gBACjD,IAAI,EAAE,aAAa;gBACnB,QAAQ,EAAE,MAAM;aACjB,WACD,CACH,CAAC;IACJ,CAAC,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACZ,OAAO,CAAC,OAAO,EAAE,UAAgC,CAAC,KAAK,EAAE,CAAC;IAC7D,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,MAAC,kBAAkB,IAAC,GAAG,EAAE,GAAG,aAC1B,KAAC,UAAU,IACT,OAAO,EACL,KAAC,MAAM,IAAC,IAAI,QAAC,OAAO,EAAC,QAAQ,gBAAa,CAAC,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,YACpE,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,WAAG,WACd,YAGX,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,EAAE,YACnD,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,YAAE,OAAO,WAAQ,WAC9B,WACI,EACb,MAAC,WAAW,IAAC,SAAS,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,aACpC,KAAC,IAAI,IACH,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,WAAW,EACjB,IAAI,EAAC,YAAY,EACjB,UAAU,EAAE,eAAe,EAC3B,YAAY,EAAE,UAAU,WACxB,EACF,KAAC,QAAQ,IAAC,KAAK,EAAE,UAAU,YAAG,UAAU,CAAC,UAAU,CAAC,WAAY,YACpD,YACK,CACtB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import {\n createContext,\n useContext,\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n Ref,\n useEffect,\n useRef,\n useState\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Button,\n CardContent,\n CardHeader,\n Flex,\n Icon,\n registerIcon,\n Text,\n TabPanel,\n Tabs,\n Card,\n ForwardProps,\n defaultThemeProp,\n useI18n\n} from '@pega/cosmos-react-core';\nimport { StyledCardHeader } from '@pega/cosmos-react-core/lib/components/Card/CardHeader';\nimport { StyledCardContent } from '@pega/cosmos-react-core/lib/components/Card/CardContent';\nimport { StyledTabPanel } from '@pega/cosmos-react-core/lib/components/Tabs/TabPanel';\nimport * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\n\nimport DialPad from '../DialPad/DialPad';\n\nimport ContactsList, { ContactsListProps } from './ContactsList';\n\nregisterIcon(timesIcon);\n\nexport interface CalleePickerProps {\n /** Heading for the new call. */\n heading: string;\n /**\n * Callback fired on new call made by the user.\n * @param phoneNumber the number chosen.\n */\n onCall: (phoneNumber: string) => void;\n /** Callback fired on clicking close button. */\n onClose?: () => void;\n /** Reference to the root component. */\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const ContactsContext = createContext<\n Pick<ContactsListProps, 'contacts' | 'onFavoriteToggle'>\n>({\n contacts: [],\n onFavoriteToggle: () => {}\n});\n\nconst StyledCalleePicker = styled(Card)(({ theme }) => {\n return css`\n ${StyledCardHeader}, ${StyledCardContent} {\n padding: calc(1.25 * ${theme.base.spacing}) calc(${theme.components.card.padding} * 2);\n }\n\n ${StyledTabPanel} {\n height: 24rem;\n }\n `;\n});\n\nStyledCalleePicker.defaultProps = defaultThemeProp;\n\nconst CalleePicker: FunctionComponent<CalleePickerProps & ForwardProps> = forwardRef(\n (\n { heading, onClose, onCall }: PropsWithoutRef<CalleePickerProps>,\n ref: CalleePickerProps['ref']\n ) => {\n const t = useI18n();\n const [currentTab, setCurrentTab] = useState('all');\n const tabsRef = useRef<HTMLElement>(null);\n const { contacts, onFavoriteToggle } = useContext(ContactsContext);\n const favorites = contacts.filter(item => item.favorite);\n\n const handleTabChange = (id: string) => {\n setCurrentTab(id);\n };\n\n const tabsHeaders = [\n { id: 'all', name: t('call_panel_contacts_list_heading'), count: contacts.length },\n {\n id: 'favorites',\n name: t('call_panel_contacts_favorites_heading'),\n count: contacts.filter(item => item.favorite).length\n },\n { id: 'dial-pad', name: t('call_panel_contacts_dial_pad_heading') }\n ];\n\n const tabContent = (tabId: string) => {\n if (tabId === 'dial-pad') return <DialPad onCallButtonClick={onCall} mode='default' />;\n return (\n <ContactsList\n contacts={tabId === 'favorites' ? favorites : contacts}\n onFavoriteToggle={onFavoriteToggle}\n action={{\n label: t('call_panel_contacts_call_button_label'),\n icon: 'phone-solid',\n callback: onCall\n }}\n />\n );\n };\n\n useEffect(() => {\n (tabsRef.current?.firstChild as HTMLButtonElement).focus();\n }, []);\n\n return (\n <StyledCalleePicker ref={ref}>\n <CardHeader\n actions={\n <Button icon variant='simple' aria-label={t('close')} onClick={onClose}>\n <Icon name='times' />\n </Button>\n }\n >\n <Flex container={{ alignItems: 'center', itemGap: 1 }}>\n <Text variant='h3'>{heading}</Text>\n </Flex>\n </CardHeader>\n <CardContent container={{ itemGap: 2 }}>\n <Tabs\n ref={tabsRef}\n tabs={tabsHeaders}\n type='horizontal'\n onTabClick={handleTabChange}\n currentTabId={currentTab}\n />\n <TabPanel tabId={currentTab}>{tabContent(currentTab)}</TabPanel>\n </CardContent>\n </StyledCalleePicker>\n );\n }\n);\n\nexport default CalleePicker;\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FunctionComponent, Ref } from 'react';
|
|
2
|
+
import { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import type { Contact } from './CallControlPanel.types';
|
|
4
|
+
export interface ContactsListProps {
|
|
5
|
+
/** An array of contacts objects. */
|
|
6
|
+
contacts: Contact[];
|
|
7
|
+
/**
|
|
8
|
+
* Primary action the user may select.
|
|
9
|
+
* @param phoneNumber the number chosen.
|
|
10
|
+
*/
|
|
11
|
+
action: {
|
|
12
|
+
label: string;
|
|
13
|
+
icon: string;
|
|
14
|
+
callback: (phoneNumber: string) => void;
|
|
15
|
+
};
|
|
16
|
+
/** Callback fired on adding/removing contact to/from favorites */
|
|
17
|
+
onFavoriteToggle: (phoneNumber: string, favorites: boolean) => void;
|
|
18
|
+
/** Reference to the root component. */
|
|
19
|
+
ref?: Ref<HTMLDivElement>;
|
|
20
|
+
}
|
|
21
|
+
declare const ContactsList: FunctionComponent<ContactsListProps & ForwardProps>;
|
|
22
|
+
export default ContactsList;
|
|
23
|
+
//# sourceMappingURL=ContactsList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContactsList.d.ts","sourceRoot":"","sources":["../../../src/components/CallControlPanel/ContactsList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAGjB,GAAG,EAGJ,MAAM,OAAO,CAAC;AAGf,OAAO,EAGL,YAAY,EAab,MAAM,yBAAyB,CAAC;AAKjC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAIxD,MAAM,WAAW,iBAAiB;IAChC,oCAAoC;IACpC,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB;;;OAGG;IACH,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;KACzC,CAAC;IACF,kEAAkE;IAClE,gBAAgB,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACpE,uCAAuC;IACvC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAoCD,QAAA,MAAM,YAAY,EAAE,iBAAiB,CAAC,iBAAiB,GAAG,YAAY,CAkFrE,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useCallback, useState } from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import { Button, defaultThemeProp, Icon, registerIcon, Text, StyledGrid, useI18n, ViewAll, StyledSummaryItemActions, StyledPrimary, StyledSecondary, useArrows, useConsolidatedRef, StyledCard } from '@pega/cosmos-react-core';
|
|
5
|
+
import { StyledCardContent } from '@pega/cosmos-react-core/lib/components/Card/CardContent';
|
|
6
|
+
import * as starIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/star.icon';
|
|
7
|
+
import * as starSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/star-solid.icon';
|
|
8
|
+
registerIcon(starIcon, starSolidIcon);
|
|
9
|
+
const StyledContactsList = styled.div(({ theme: { base } }) => {
|
|
10
|
+
return css `
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-flow: column;
|
|
13
|
+
height: 100%;
|
|
14
|
+
overflow-y: auto;
|
|
15
|
+
overflow-x: hidden;
|
|
16
|
+
|
|
17
|
+
${StyledCard} {
|
|
18
|
+
margin: 0 calc(${base.spacing} * -2);
|
|
19
|
+
padding: 0 calc(${base.spacing} * 2);
|
|
20
|
+
|
|
21
|
+
> ${StyledCardContent} {
|
|
22
|
+
padding: 0;
|
|
23
|
+
gap: 0;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
li${StyledGrid} {
|
|
28
|
+
border-bottom: 0.0625rem solid ${base.palette['border-line']};
|
|
29
|
+
padding: 0;
|
|
30
|
+
> ${StyledPrimary}, > ${StyledSecondary} {
|
|
31
|
+
align-self: center;
|
|
32
|
+
font-weight: ${base['font-weight'].normal};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
${StyledSummaryItemActions} {
|
|
36
|
+
color: ${base.palette.interactive};
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
});
|
|
40
|
+
StyledContactsList.defaultProps = defaultThemeProp;
|
|
41
|
+
const ContactsList = forwardRef(({ contacts: items, action, onFavoriteToggle }, ref) => {
|
|
42
|
+
const t = useI18n();
|
|
43
|
+
const [searchText, setSearchText] = useState('');
|
|
44
|
+
const containerRef = useConsolidatedRef(ref);
|
|
45
|
+
const onSearchChange = useCallback((value) => {
|
|
46
|
+
setSearchText(value.trim());
|
|
47
|
+
}, []);
|
|
48
|
+
const favoriteButton = useCallback((phoneNumber, favorite) => (_jsx(Button, { variant: 'simple', icon: true, onClick: (e) => {
|
|
49
|
+
e.stopPropagation();
|
|
50
|
+
onFavoriteToggle(phoneNumber, favorite);
|
|
51
|
+
}, "aria-label": favorite
|
|
52
|
+
? t('call_panel_contacts_add_to_favorites')
|
|
53
|
+
: t('call_panel_contacts_remove_from_favorites'), children: _jsx(Icon, { name: favorite ? 'star-solid' : 'star' }, void 0) }, void 0)), [onFavoriteToggle]);
|
|
54
|
+
const createList = (list) => {
|
|
55
|
+
return list.map(item => {
|
|
56
|
+
return {
|
|
57
|
+
id: item.phoneNumber,
|
|
58
|
+
primary: item.primary,
|
|
59
|
+
secondary: _jsx(Text, { variant: 'secondary', children: item.secondary }, void 0),
|
|
60
|
+
visual: favoriteButton(item.phoneNumber, item.favorite),
|
|
61
|
+
actions: [
|
|
62
|
+
{
|
|
63
|
+
text: action.label,
|
|
64
|
+
id: 'primary',
|
|
65
|
+
icon: action.icon
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
onClick: () => {
|
|
69
|
+
action.callback(item.phoneNumber);
|
|
70
|
+
},
|
|
71
|
+
container: {
|
|
72
|
+
areas: '"visual primary secondary actions"',
|
|
73
|
+
cols: 'auto minmax(0, 2fr) minmax(0, 2fr) auto'
|
|
74
|
+
},
|
|
75
|
+
tabIndex: 0
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
useArrows(containerRef, { selector: ':scope ul > li' });
|
|
80
|
+
return (_jsx(ViewAll, { as: StyledContactsList, ref: containerRef, items: searchText
|
|
81
|
+
? createList(items.filter(({ primary, secondary }) => {
|
|
82
|
+
return (primary.toLowerCase().includes(searchText.toLowerCase()) ||
|
|
83
|
+
secondary.toLowerCase().includes(searchText.toLowerCase()));
|
|
84
|
+
}))
|
|
85
|
+
: createList(items), searchInputProps: { onSearchChange } }, void 0));
|
|
86
|
+
});
|
|
87
|
+
export default ContactsList;
|
|
88
|
+
//# sourceMappingURL=ContactsList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContactsList.js","sourceRoot":"","sources":["../../../src/components/CallControlPanel/ContactsList.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAKV,WAAW,EACX,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,gBAAgB,EAEhB,IAAI,EACJ,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,OAAO,EACP,OAAO,EACP,wBAAwB,EACxB,aAAa,EACb,eAAe,EACf,SAAS,EACT,kBAAkB,EAClB,UAAU,EACX,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAC;AAC5F,OAAO,KAAK,QAAQ,MAAM,6DAA6D,CAAC;AACxF,OAAO,KAAK,aAAa,MAAM,mEAAmE,CAAC;AAInG,YAAY,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;AAoBtC,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE;IAC5D,OAAO,GAAG,CAAA;;;;;;;MAON,UAAU;uBACO,IAAI,CAAC,OAAO;wBACX,IAAI,CAAC,OAAO;;UAE1B,iBAAiB;;;;;;QAMnB,UAAU;uCACqB,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;;UAExD,aAAa,OAAO,eAAe;;uBAEtB,IAAI,CAAC,aAAa,CAAC,CAAC,MAAM;;;MAG3C,wBAAwB;eACf,IAAI,CAAC,OAAO,CAAC,WAAW;;GAEpC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\n forwardRef,\n FunctionComponent,\n MouseEvent,\n PropsWithoutRef,\n Ref,\n useCallback,\n useState\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Button,\n defaultThemeProp,\n ForwardProps,\n Icon,\n registerIcon,\n Text,\n StyledGrid,\n useI18n,\n ViewAll,\n StyledSummaryItemActions,\n StyledPrimary,\n StyledSecondary,\n useArrows,\n useConsolidatedRef,\n StyledCard\n} from '@pega/cosmos-react-core';\nimport { StyledCardContent } from '@pega/cosmos-react-core/lib/components/Card/CardContent';\nimport * as starIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/star.icon';\nimport * as starSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/star-solid.icon';\n\nimport type { Contact } from './CallControlPanel.types';\n\nregisterIcon(starIcon, starSolidIcon);\n\nexport interface ContactsListProps {\n /** An array of contacts objects. */\n contacts: Contact[];\n /**\n * Primary action the user may select.\n * @param phoneNumber the number chosen.\n */\n action: {\n label: string;\n icon: string;\n callback: (phoneNumber: string) => void;\n };\n /** Callback fired on adding/removing contact to/from favorites */\n onFavoriteToggle: (phoneNumber: string, favorites: boolean) => void;\n /** Reference to the root component. */\n ref?: Ref<HTMLDivElement>;\n}\n\nconst StyledContactsList = styled.div(({ theme: { base } }) => {\n return css`\n display: flex;\n flex-flow: column;\n height: 100%;\n overflow-y: auto;\n overflow-x: hidden;\n\n ${StyledCard} {\n margin: 0 calc(${base.spacing} * -2);\n padding: 0 calc(${base.spacing} * 2);\n\n > ${StyledCardContent} {\n padding: 0;\n gap: 0;\n }\n }\n\n li${StyledGrid} {\n border-bottom: 0.0625rem solid ${base.palette['border-line']};\n padding: 0;\n > ${StyledPrimary}, > ${StyledSecondary} {\n align-self: center;\n font-weight: ${base['font-weight'].normal};\n }\n }\n ${StyledSummaryItemActions} {\n color: ${base.palette.interactive};\n }\n `;\n});\n\nStyledContactsList.defaultProps = defaultThemeProp;\n\nconst ContactsList: FunctionComponent<ContactsListProps & ForwardProps> = forwardRef(\n (\n { contacts: items, action, onFavoriteToggle }: PropsWithoutRef<ContactsListProps>,\n ref: ContactsListProps['ref']\n ) => {\n const t = useI18n();\n const [searchText, setSearchText] = useState('');\n const containerRef = useConsolidatedRef(ref);\n\n const onSearchChange = useCallback((value: string) => {\n setSearchText(value.trim());\n }, []);\n\n const favoriteButton = useCallback(\n (phoneNumber: string, favorite: boolean) => (\n <Button\n variant='simple'\n icon\n onClick={(e: MouseEvent) => {\n e.stopPropagation();\n onFavoriteToggle(phoneNumber, favorite);\n }}\n aria-label={\n favorite\n ? t('call_panel_contacts_add_to_favorites')\n : t('call_panel_contacts_remove_from_favorites')\n }\n >\n <Icon name={favorite ? 'star-solid' : 'star'} />\n </Button>\n ),\n [onFavoriteToggle]\n );\n\n const createList = (list: Contact[]) => {\n return list.map(item => {\n return {\n id: item.phoneNumber,\n primary: item.primary,\n secondary: <Text variant='secondary'>{item.secondary}</Text>,\n visual: favoriteButton(item.phoneNumber, item.favorite),\n actions: [\n {\n text: action.label,\n id: 'primary',\n icon: action.icon\n }\n ],\n onClick: () => {\n action.callback(item.phoneNumber);\n },\n container: {\n areas: '\"visual primary secondary actions\"',\n cols: 'auto minmax(0, 2fr) minmax(0, 2fr) auto'\n },\n tabIndex: 0\n };\n });\n };\n\n useArrows(containerRef, { selector: ':scope ul > li' });\n\n return (\n <ViewAll\n as={StyledContactsList}\n ref={containerRef}\n items={\n searchText\n ? createList(\n items.filter(({ primary, secondary }) => {\n return (\n primary.toLowerCase().includes(searchText.toLowerCase()) ||\n secondary.toLowerCase().includes(searchText.toLowerCase())\n );\n })\n )\n : createList(items)\n }\n searchInputProps={{ onSearchChange }}\n />\n );\n }\n);\n\nexport default ContactsList;\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { OmitStrict } from '@pega/cosmos-react-core';
|
|
3
|
+
import { DialPadProps } from '../DialPad/DialPad';
|
|
4
|
+
export declare const StyledDTMFKeypad: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").CardProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
5
|
+
export interface DTMFKeypadProps extends OmitStrict<DialPadProps, 'mode'> {
|
|
6
|
+
/** Callback fired on clicking close button. */
|
|
7
|
+
onClose?: () => void;
|
|
8
|
+
}
|
|
9
|
+
declare const DTMFKeypad: FC<DTMFKeypadProps>;
|
|
10
|
+
export default DTMFKeypad;
|
|
11
|
+
//# sourceMappingURL=DTMFKeypad.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DTMFKeypad.d.ts","sourceRoot":"","sources":["../../../src/components/CallControlPanel/DTMFKeypad.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAG3B,OAAO,EAWL,UAAU,EACX,MAAM,yBAAyB,CAAC;AAKjC,OAAgB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAI3D,eAAO,MAAM,gBAAgB,mOAc5B,CAAC;AAIF,MAAM,WAAW,eAAgB,SAAQ,UAAU,CAAC,YAAY,EAAE,MAAM,CAAC;IACvE,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAqBnC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
import { Card, CardHeader, Button, Icon, registerIcon, Flex, Text, useI18n, CardContent, defaultThemeProp } from '@pega/cosmos-react-core';
|
|
4
|
+
import { StyledCardHeader } from '@pega/cosmos-react-core/lib/components/Card/CardHeader';
|
|
5
|
+
import { StyledCardContent } from '@pega/cosmos-react-core/lib/components/Card/CardContent';
|
|
6
|
+
import * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';
|
|
7
|
+
import DialPad from '../DialPad/DialPad';
|
|
8
|
+
registerIcon(timesIcon);
|
|
9
|
+
export const StyledDTMFKeypad = styled(Card)(({ theme: { base: { spacing }, components: { card } } }) => {
|
|
10
|
+
return css `
|
|
11
|
+
min-width: 15rem;
|
|
12
|
+
${StyledCardHeader}, ${StyledCardContent} {
|
|
13
|
+
padding: calc(1.25 * ${spacing}) calc(${card.padding} * 2);
|
|
14
|
+
}
|
|
15
|
+
`;
|
|
16
|
+
});
|
|
17
|
+
StyledDTMFKeypad.defaultProps = defaultThemeProp;
|
|
18
|
+
const DTMFKeypad = ({ onClose, onDialButtonClick }) => {
|
|
19
|
+
const t = useI18n();
|
|
20
|
+
return (_jsxs(StyledDTMFKeypad, { children: [_jsx(CardHeader, { actions: _jsx(Button, { icon: true, variant: 'simple', "aria-label": t('close'), onClick: onClose, children: _jsx(Icon, { name: 'times' }, void 0) }, void 0), children: _jsx(Flex, { container: { alignItems: 'center', itemGap: 1 }, children: _jsx(Text, { variant: 'h3', children: t('call_panel_send_dtmf_heading') }, void 0) }, void 0) }, void 0), _jsx(CardContent, { container: { itemGap: 1, justify: 'start' }, children: _jsx(DialPad, { onDialButtonClick: onDialButtonClick, mode: 'DTMF' }, void 0) }, void 0)] }, void 0));
|
|
21
|
+
};
|
|
22
|
+
export default DTMFKeypad;
|
|
23
|
+
//# sourceMappingURL=DTMFKeypad.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DTMFKeypad.js","sourceRoot":"","sources":["../../../src/components/CallControlPanel/DTMFKeypad.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,IAAI,EACJ,UAAU,EACV,MAAM,EACN,IAAI,EACJ,YAAY,EACZ,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,WAAW,EACX,gBAAgB,EAEjB,MA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AC,OAAO,IAAC,iBAAiB,EAAE,iBAAiB,EAAE,IAAI,EAAC,MAAM,WAAG,WACjD,YACG,CACpB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { FC } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Card,\n CardHeader,\n Button,\n Icon,\n registerIcon,\n Flex,\n Text,\n useI18n,\n CardContent,\n defaultThemeProp,\n OmitStrict\n} from '@pega/cosmos-react-core';\nimport { StyledCardHeader } from '@pega/cosmos-react-core/lib/components/Card/CardHeader';\nimport { StyledCardContent } from '@pega/cosmos-react-core/lib/components/Card/CardContent';\nimport * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\n\nimport DialPad, { DialPadProps } from '../DialPad/DialPad';\n\nregisterIcon(timesIcon);\n\nexport const StyledDTMFKeypad = styled(Card)(\n ({\n theme: {\n base: { spacing },\n components: { card }\n }\n }) => {\n return css`\n min-width: 15rem;\n ${StyledCardHeader}, ${StyledCardContent} {\n padding: calc(1.25 * ${spacing}) calc(${card.padding} * 2);\n }\n `;\n }\n);\n\nStyledDTMFKeypad.defaultProps = defaultThemeProp;\n\nexport interface DTMFKeypadProps extends OmitStrict<DialPadProps, 'mode'> {\n /** Callback fired on clicking close button. */\n onClose?: () => void;\n}\n\nconst DTMFKeypad: FC<DTMFKeypadProps> = ({ onClose, onDialButtonClick }) => {\n const t = useI18n();\n\n return (\n <StyledDTMFKeypad>\n <CardHeader\n actions={\n <Button icon variant='simple' aria-label={t('close')} onClick={onClose}>\n <Icon name='times' />\n </Button>\n }\n >\n <Flex container={{ alignItems: 'center', itemGap: 1 }}>\n <Text variant='h3'>{t('call_panel_send_dtmf_heading')}</Text>\n </Flex>\n </CardHeader>\n <CardContent container={{ itemGap: 1, justify: 'start' }}>\n <DialPad onDialButtonClick={onDialButtonClick} mode='DTMF' />\n </CardContent>\n </StyledDTMFKeypad>\n );\n};\n\nexport default DTMFKeypad;\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
interface StopWatchProps {
|
|
3
|
+
startTime: number | Date;
|
|
4
|
+
timeout?: number | Date;
|
|
5
|
+
}
|
|
6
|
+
export declare const StyledStopWatch: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, import("@pega/cosmos-react-core").OmitStrict<import("@pega/cosmos-react-core").TextProps, "variant"> & Required<Pick<import("@pega/cosmos-react-core").TextProps, "variant">>, never>;
|
|
7
|
+
declare const StopWatch: FunctionComponent<StopWatchProps>;
|
|
8
|
+
export default StopWatch;
|
|
9
|
+
//# sourceMappingURL=StopWatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StopWatch.d.ts","sourceRoot":"","sources":["../../../src/components/CallControlPanel/StopWatch.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAiC,MAAM,OAAO,CAAC;AAOzE,UAAU,cAAc;IACtB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,eAAO,MAAM,eAAe,qRAG3B,CAAC;AAEF,QAAA,MAAM,SAAS,EAAE,iBAAiB,CAAC,cAAc,CAwBhD,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useRef, useLayoutEffect } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { StyledText, Text } from '@pega/cosmos-react-core';
|
|
5
|
+
import { formatDuration } from './utils';
|
|
6
|
+
export const StyledStopWatch = styled(StyledText) `
|
|
7
|
+
min-width: 8ch;
|
|
8
|
+
text-align: end;
|
|
9
|
+
`;
|
|
10
|
+
const StopWatch = memo(({ startTime, timeout }) => {
|
|
11
|
+
const clockRef = useRef(null);
|
|
12
|
+
const millis = startTime instanceof Date ? startTime.getUTCMilliseconds() : startTime;
|
|
13
|
+
const timeoutMillis = timeout instanceof Date ? timeout.getUTCMilliseconds() : timeout;
|
|
14
|
+
useLayoutEffect(() => {
|
|
15
|
+
const timer = setInterval(() => {
|
|
16
|
+
if (clockRef.current) {
|
|
17
|
+
let content = formatDuration(Date.now() - millis);
|
|
18
|
+
if (timeoutMillis)
|
|
19
|
+
content += ` / ${formatDuration(timeoutMillis)}`;
|
|
20
|
+
clockRef.current.textContent = content;
|
|
21
|
+
}
|
|
22
|
+
}, 1000);
|
|
23
|
+
return () => clearInterval(timer);
|
|
24
|
+
}, [startTime, timeoutMillis]);
|
|
25
|
+
return (_jsxs(Text, { as: StyledStopWatch, ref: clockRef, children: [formatDuration(Date.now() - millis), timeoutMillis && ` / ${formatDuration(timeoutMillis)}`] }, void 0));
|
|
26
|
+
});
|
|
27
|
+
export default StopWatch;
|
|
28
|
+
//# sourceMappingURL=StopWatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StopWatch.js","sourceRoot":"","sources":["../../../src/components/CallControlPanel/StopWatch.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAOzC,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,UAAU,CAAC,CAAA;;;CAGhD,CAAC;AAEF,MAAM,SAAS,GAAsC,IAAI,CACvD,CAAC,EAAE,SAAS,EAAE,OAAO,EAAkB,EAAE,EAAE;IACzC,MAAM,QAAQ,GAAG,MAAM,CAAkB,IAAI,CAAC,CAAC;IAC/C,MAAM,MAAM,GAAG,SAAS,YAAY,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACtF,MAAM,aAAa,GAAG,OAAO,YAAY,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;IAEvF,eAAe,CAAC,GAAG,EAAE;QACnB,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;YAC7B,IAAI,QAAQ,CAAC,OAAO,EAAE;gBACpB,IAAI,OAAO,GAAG,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,CAAC;gBAClD,IAAI,aAAa;oBAAE,OAAO,IAAI,MAAM,cAAc,CAAC,aAAa,CAAC,EAAE,CAAC;gBACpE,QAAQ,CAAC,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC;aACxC;QACH,CAAC,EAAE,IAAI,CAAC,CAAC;QACT,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC;IAE/B,OAAO,CACL,MAAC,IAAI,IAAC,EAAE,EAAE,eAAe,EAAE,GAAG,EAAE,QAAQ,aACrC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,EACnC,aAAa,IAAI,MAAM,cAAc,CAAC,aAAa,CAAC,EAAE,YAClD,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import { FunctionComponent, memo, useRef, useLayoutEffect } from 'react';\nimport styled from 'styled-components';\n\nimport { StyledText, Text } from '@pega/cosmos-react-core';\n\nimport { formatDuration } from './utils';\n\ninterface StopWatchProps {\n startTime: number | Date;\n timeout?: number | Date;\n}\n\nexport const StyledStopWatch = styled(StyledText)`\n min-width: 8ch;\n text-align: end;\n`;\n\nconst StopWatch: FunctionComponent<StopWatchProps> = memo(\n ({ startTime, timeout }: StopWatchProps) => {\n const clockRef = useRef<HTMLSpanElement>(null);\n const millis = startTime instanceof Date ? startTime.getUTCMilliseconds() : startTime;\n const timeoutMillis = timeout instanceof Date ? timeout.getUTCMilliseconds() : timeout;\n\n useLayoutEffect(() => {\n const timer = setInterval(() => {\n if (clockRef.current) {\n let content = formatDuration(Date.now() - millis);\n if (timeoutMillis) content += ` / ${formatDuration(timeoutMillis)}`;\n clockRef.current.textContent = content;\n }\n }, 1000);\n return () => clearInterval(timer);\n }, [startTime, timeoutMillis]);\n\n return (\n <Text as={StyledStopWatch} ref={clockRef}>\n {formatDuration(Date.now() - millis)}\n {timeoutMillis && ` / ${formatDuration(timeoutMillis)}`}\n </Text>\n );\n }\n);\n\nexport default StopWatch;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/CallControlPanel/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/CallControlPanel/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["export { default } from './CallControlPanel';\nexport { CallControlPanelProps } from './CallControlPanel.types';\nexport { default as CallControlPanelIcon } from './CallControlPanelIcon';\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const formatDuration: (millis: number) => string;
|
|
2
|
+
export declare const calculateSla: (callDuration: number, slaConfig?: number[] | undefined) => {
|
|
3
|
+
slaTimeout?: number;
|
|
4
|
+
slaDuration?: number;
|
|
5
|
+
currentSlaLevel?: number;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/CallControlPanel/utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,WAAY,MAAM,KAAG,MAG/C,CAAC;AAEF,eAAO,MAAM,YAAY,iBACT,MAAM,uCAEnB;IACD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CA6B1B,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { triple } from '@pega/cosmos-react-core';
|
|
2
|
+
export const formatDuration = (millis) => {
|
|
3
|
+
const seconds = Math.round(millis / 1000);
|
|
4
|
+
return `${Math.floor(seconds / 60)}:${(seconds % 60).toString().padStart(2, '0')}`;
|
|
5
|
+
};
|
|
6
|
+
export const calculateSla = (callDuration, slaConfig) => {
|
|
7
|
+
let slaLevel = 0;
|
|
8
|
+
let lastSlaTimeout = 0;
|
|
9
|
+
if (!slaConfig) {
|
|
10
|
+
return {
|
|
11
|
+
slaTimeout: undefined,
|
|
12
|
+
slaDuration: undefined,
|
|
13
|
+
currentSlaLevel: undefined
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
17
|
+
for (const { prev: prevSlaTimeout = 0, current: slaTimeoutInSeconds } of triple(slaConfig)) {
|
|
18
|
+
const slaInMillis = slaTimeoutInSeconds * 1000;
|
|
19
|
+
if (callDuration < slaInMillis) {
|
|
20
|
+
return {
|
|
21
|
+
slaTimeout: slaInMillis,
|
|
22
|
+
slaDuration: slaTimeoutInSeconds - prevSlaTimeout,
|
|
23
|
+
currentSlaLevel: slaLevel
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
slaLevel += 1;
|
|
27
|
+
lastSlaTimeout = slaInMillis;
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
slaTimeout: lastSlaTimeout,
|
|
31
|
+
slaDuration: 0,
|
|
32
|
+
currentSlaLevel: slaLevel
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/CallControlPanel/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAc,EAAU,EAAE;IACvD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC1C,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;AACrF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,YAAoB,EACpB,SAAoB,EAKpB,EAAE;IACF,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,IAAI,CAAC,SAAS,EAAE;QACd,OAAO;YACL,UAAU,EAAE,SAAS;YACrB,WAAW,EAAE,SAAS;YACtB,eAAe,EAAE,SAAS;SAC3B,CAAC;KACH;IACD,gDAAgD;IAChD,KAAK,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,CAAC,EAAE,OAAO,EAAE,mBAAmB,EAAE,IAAI,MAAM,CAAC,SAAS,CAAC,EAAE;QAC1F,MAAM,WAAW,GAAG,mBAAmB,GAAG,IAAI,CAAC;QAC/C,IAAI,YAAY,GAAG,WAAW,EAAE;YAC9B,OAAO;gBACL,UAAU,EAAE,WAAW;gBACvB,WAAW,EAAE,mBAAmB,GAAG,cAAc;gBACjD,eAAe,EAAE,QAAQ;aAC1B,CAAC;SACH;QACD,QAAQ,IAAI,CAAC,CAAC;QACd,cAAc,GAAG,WAAW,CAAC;KAC9B;IACD,OAAO;QACL,UAAU,EAAE,cAAc;QAC1B,WAAW,EAAE,CAAC;QACd,eAAe,EAAE,QAAQ;KAC1B,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { triple } from '@pega/cosmos-react-core';\n\nexport const formatDuration = (millis: number): string => {\n const seconds = Math.round(millis / 1000);\n return `${Math.floor(seconds / 60)}:${(seconds % 60).toString().padStart(2, '0')}`;\n};\n\nexport const calculateSla = (\n callDuration: number,\n slaConfig?: number[]\n): {\n slaTimeout?: number;\n slaDuration?: number;\n currentSlaLevel?: number;\n} => {\n let slaLevel = 0;\n let lastSlaTimeout = 0;\n if (!slaConfig) {\n return {\n slaTimeout: undefined,\n slaDuration: undefined,\n currentSlaLevel: undefined\n };\n }\n // eslint-disable-next-line no-restricted-syntax\n for (const { prev: prevSlaTimeout = 0, current: slaTimeoutInSeconds } of triple(slaConfig)) {\n const slaInMillis = slaTimeoutInSeconds * 1000;\n if (callDuration < slaInMillis) {\n return {\n slaTimeout: slaInMillis,\n slaDuration: slaTimeoutInSeconds - prevSlaTimeout,\n currentSlaLevel: slaLevel\n };\n }\n slaLevel += 1;\n lastSlaTimeout = slaInMillis;\n }\n return {\n slaTimeout: lastSlaTimeout,\n slaDuration: 0,\n currentSlaLevel: slaLevel\n };\n};\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FunctionComponent, Ref } from 'react';
|
|
2
|
+
import { ForwardProps, NoChildrenProp } from '@pega/cosmos-react-core';
|
|
3
|
+
import { DialPadKeyboardProps } from './DialPadKeyboard';
|
|
4
|
+
export interface DialPadProps extends NoChildrenProp {
|
|
5
|
+
/** Callback fired on call button click */
|
|
6
|
+
onCallButtonClick?: (phoneNumber: string) => void;
|
|
7
|
+
/** On keypad button press callback */
|
|
8
|
+
onDialButtonClick?: (charCode: number) => void;
|
|
9
|
+
/** Keypad mode, regular or DTMF. */
|
|
10
|
+
mode: DialPadKeyboardProps['mode'];
|
|
11
|
+
/** Ref for the wrapping element. */
|
|
12
|
+
ref?: Ref<HTMLDivElement>;
|
|
13
|
+
}
|
|
14
|
+
declare const DialPad: FunctionComponent<DialPadProps & ForwardProps>;
|
|
15
|
+
export default DialPad;
|
|
16
|
+
//# sourceMappingURL=DialPad.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DialPad.d.ts","sourceRoot":"","sources":["../../../src/components/DialPad/DialPad.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAEjB,GAAG,EAGJ,MAAM,OAAO,CAAC;AAGf,OAAO,EACL,YAAY,EAQZ,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,OAAwB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE1E,MAAM,WAAW,YAAa,SAAQ,cAAc;IAClD,0CAA0C;IAC1C,iBAAiB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,sCAAsC;IACtC,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,oCAAoC;IACpC,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC,CAAC;IACnC,oCAAoC;IACpC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAiBD,QAAA,MAAM,OAAO,EAAE,iBAAiB,CAAC,YAAY,GAAG,YAAY,CA+C3D,CAAC;AAEF,eAAe,OAAO,CAAC"}
|