@pega/cosmos-react-cs 3.0.0-dev.22.0 → 3.0.0-dev.23.2
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/CallControlPanel/Call.d.ts.map +1 -1
- package/lib/components/CallControlPanel/Call.js +87 -72
- package/lib/components/CallControlPanel/Call.js.map +1 -1
- package/lib/components/CallControlPanel/CallControlPanel.d.ts.map +1 -1
- package/lib/components/CallControlPanel/CallControlPanel.js +20 -12
- package/lib/components/CallControlPanel/CallControlPanel.js.map +1 -1
- package/lib/components/CallControlPanel/CallControlPanel.styles.d.ts +2 -0
- package/lib/components/CallControlPanel/CallControlPanel.styles.d.ts.map +1 -1
- package/lib/components/CallControlPanel/CallControlPanel.styles.js +8 -1
- package/lib/components/CallControlPanel/CallControlPanel.styles.js.map +1 -1
- package/lib/components/CallControlPanel/CallControlPanel.types.d.ts +15 -29
- package/lib/components/CallControlPanel/CallControlPanel.types.d.ts.map +1 -1
- package/lib/components/CallControlPanel/CallControlPanel.types.js.map +1 -1
- package/lib/components/CallControlPanel/CallHandover/CallHandover.types.d.ts +15 -0
- package/lib/components/CallControlPanel/CallHandover/CallHandover.types.d.ts.map +1 -0
- package/lib/components/CallControlPanel/CallHandover/CallHandover.types.js +2 -0
- package/lib/components/CallControlPanel/CallHandover/CallHandover.types.js.map +1 -0
- package/lib/components/CallControlPanel/CallHandover/CallHandoverDialog.d.ts +13 -0
- package/lib/components/CallControlPanel/CallHandover/CallHandoverDialog.d.ts.map +1 -0
- package/lib/components/CallControlPanel/CallHandover/CallHandoverDialog.js +51 -0
- package/lib/components/CallControlPanel/CallHandover/CallHandoverDialog.js.map +1 -0
- package/lib/components/CallControlPanel/{CallHandoverForm.d.ts → CallHandover/CallHandoverForm.d.ts} +7 -3
- package/lib/components/CallControlPanel/CallHandover/CallHandoverForm.d.ts.map +1 -0
- package/lib/components/CallControlPanel/CallHandover/CallHandoverForm.js +46 -0
- package/lib/components/CallControlPanel/CallHandover/CallHandoverForm.js.map +1 -0
- package/lib/components/CallControlPanel/CallHandover/index.d.ts +4 -0
- package/lib/components/CallControlPanel/CallHandover/index.d.ts.map +1 -0
- package/lib/components/CallControlPanel/CallHandover/index.js +4 -0
- package/lib/components/CallControlPanel/CallHandover/index.js.map +1 -0
- package/lib/components/CallControlPanel/{CalleePicker.d.ts → ContactList/CalleePicker.d.ts} +5 -7
- package/lib/components/CallControlPanel/ContactList/CalleePicker.d.ts.map +1 -0
- package/lib/components/CallControlPanel/ContactList/CalleePicker.js +52 -0
- package/lib/components/CallControlPanel/ContactList/CalleePicker.js.map +1 -0
- package/lib/components/CallControlPanel/ContactList/ContactList.d.ts +10 -0
- package/lib/components/CallControlPanel/ContactList/ContactList.d.ts.map +1 -0
- package/lib/components/CallControlPanel/ContactList/ContactList.js +129 -0
- package/lib/components/CallControlPanel/ContactList/ContactList.js.map +1 -0
- package/lib/components/CallControlPanel/ContactList/ContactList.types.d.ts +30 -0
- package/lib/components/CallControlPanel/ContactList/ContactList.types.d.ts.map +1 -0
- package/lib/components/CallControlPanel/ContactList/ContactList.types.js +2 -0
- package/lib/components/CallControlPanel/ContactList/ContactList.types.js.map +1 -0
- package/lib/components/CallControlPanel/ContactList/index.d.ts +3 -0
- package/lib/components/CallControlPanel/ContactList/index.d.ts.map +1 -0
- package/lib/components/CallControlPanel/ContactList/index.js +2 -0
- package/lib/components/CallControlPanel/ContactList/index.js.map +1 -0
- package/lib/components/CallControlPanel/index.d.ts +2 -1
- package/lib/components/CallControlPanel/index.d.ts.map +1 -1
- package/lib/components/CallControlPanel/index.js.map +1 -1
- package/lib/components/DialPad/DialPad.js +1 -1
- package/lib/components/DialPad/DialPad.js.map +1 -1
- package/lib/components/DialPad/DialPadDialog.d.ts +10 -0
- package/lib/components/DialPad/DialPadDialog.d.ts.map +1 -0
- package/lib/components/DialPad/DialPadDialog.js +28 -0
- package/lib/components/DialPad/DialPadDialog.js.map +1 -0
- package/lib/components/DialPad/DialPadKeyboard.d.ts.map +1 -1
- package/lib/components/DialPad/DialPadKeyboard.js +1 -1
- package/lib/components/DialPad/DialPadKeyboard.js.map +1 -1
- package/lib/components/DialPad/index.d.ts +1 -0
- package/lib/components/DialPad/index.d.ts.map +1 -1
- package/lib/components/DialPad/index.js +1 -0
- package/lib/components/DialPad/index.js.map +1 -1
- package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.d.ts.map +1 -1
- package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.js +3 -2
- package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.js.map +1 -1
- package/lib/components/InteractionNotification/InteractionNotification.d.ts.map +1 -1
- package/lib/components/InteractionNotification/InteractionNotification.js +1 -1
- package/lib/components/InteractionNotification/InteractionNotification.js.map +1 -1
- package/package.json +3 -3
- package/lib/components/CallControlPanel/CallHandoverForm.d.ts.map +0 -1
- package/lib/components/CallControlPanel/CallHandoverForm.js +0 -78
- package/lib/components/CallControlPanel/CallHandoverForm.js.map +0 -1
- package/lib/components/CallControlPanel/CalleePicker.d.ts.map +0 -1
- package/lib/components/CallControlPanel/CalleePicker.js +0 -61
- package/lib/components/CallControlPanel/CalleePicker.js.map +0 -1
- package/lib/components/CallControlPanel/ContactsList.d.ts +0 -23
- package/lib/components/CallControlPanel/ContactsList.d.ts.map +0 -1
- package/lib/components/CallControlPanel/ContactsList.js +0 -88
- package/lib/components/CallControlPanel/ContactsList.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CallControlPanel.types.js","sourceRoot":"","sources":["../../../src/components/CallControlPanel/CallControlPanel.types.ts"],"names":[],"mappings":"","sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"CallControlPanel.types.js","sourceRoot":"","sources":["../../../src/components/CallControlPanel/CallControlPanel.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Ref } from 'react';\n\nimport type { BannerProps, BaseProps, NoChildrenProp } from '@pega/cosmos-react-core';\n\nimport type { FloatingPanelProps } from './FloatingPanel';\nimport { Contact } from './ContactList/ContactList.types';\nimport type { TransferData, TransferReasonOption } from './CallHandover';\n\nexport interface CallParticipant {\n /** Caller id. */\n id: string;\n /** Caller's name. */\n name: string;\n /** Additional caller's info. */\n info?: string;\n /** Callback fired when the user ends the call. */\n onHangUp?: (id: CallProps['id'], participantId: CallParticipant['id']) => void;\n}\n\nexport interface CallProps {\n /** Call identifier. */\n id: string;\n /** Timestamp when the call has begun. */\n startedAt: number | Date;\n /** Timestamp when the call has been put on hold. */\n onHoldSince?: number | Date;\n /** SLA configuration timeups. Array of numbers of seconds after which the particular SLA level\n * time is up.\n */\n slaConfig?: number[];\n /** Call participants. */\n participants: CallParticipant[];\n /** The flag whether the mic is muted on this call. */\n muted?: boolean;\n /** Callback fired when 'pause' icon has been clicked. */\n onPauseToggle?: (id: CallProps['id']) => void;\n /** Callback fired when 'mute' icon has been clicked. */\n onMuteToggle: (id: CallProps['id']) => void;\n /** Callback fired when 'Consult' action has been clicked. */\n onConsultAction?: (id: CallProps['id'], transferData: TransferData) => void;\n /** Callback fired when 'Conference' action has been clicked. */\n onConferenceAction?: (id: CallProps['id'], transferData: TransferData) => void;\n /** Callback fired when 'Merge call' action has been chosen. */\n onMergeCall?: (id: CallProps['id']) => void;\n /** Callback fired for every dial pad key press. */\n onDTMFPress?: (id: CallProps['id'], key: string) => void;\n /** Callback fired when 'Transfer' action has been clicked. */\n onTransferAction?: (id: CallProps['id'], transferData: TransferData) => void;\n /** Callback fired when 'Transfer' action has been clicked. */\n onHandOffCall?: (id: CallProps['id']) => void;\n /** Callback fired when the user ends the call. */\n onEndCall?: (id: CallProps['id']) => void;\n /**\n * Transfer reason options\n */\n transferOptions: Readonly<TransferReasonOption[]>;\n}\n\nexport type UserAvailabilityStatus = 'available' | 'unavailable' | 'busy' | 'after_work' | 'logout';\n\nexport interface UserAvailabilityStatusOption {\n readonly id: string;\n readonly label: string;\n readonly status: UserAvailabilityStatus;\n readonly disabled?: boolean;\n}\n\nexport interface InteractionTransferData {\n onCancel: () => void;\n onComplete: () => void;\n}\n\nexport interface CallControlPanelProps extends BaseProps, NoChildrenProp {\n /** The heading rendered. */\n heading: string;\n /**\n * User availability statuses.\n */\n statusOptions: Readonly<UserAvailabilityStatusOption[]>;\n /** User current status. */\n status: UserAvailabilityStatusOption['id'];\n /** Timestamp since the user is in the current status. */\n inStatusSince: number | Date;\n /** If true, the component will be draggable */\n draggable?: boolean;\n /**\n * Region for messages: errors, notifications, etc.\n */\n message?: Pick<BannerProps, 'id' | 'variant' | 'heading' | 'messages' | 'onDismiss'>;\n /**\n * Callback fired when user changes their status.\n * @param value new chosen status.\n */\n onStatusChange: (value: UserAvailabilityStatusOption['id']) => void;\n /**\n * List of current calls. Having two or more not declared as \"on hold\" (onHoldSince defined) means there's\n * a conference call.\n */\n calls: CallProps[];\n /**\n * Callback fired on new call made by the user. 'Add call' button is not present if callback is not passed.\n * @param phoneNumber the number chosen.\n */\n onAddCall?: (phoneNumber: string) => void;\n /**\n * Intraction transfer popup options.\n */\n interactionTransfer?: InteractionTransferData;\n /** An array of contacts objects. */\n contactsList: Contact[];\n /** Callback fired on adding/removing contact to/from favorites */\n onFavoriteToggle: (phoneNumber: string, favorite: boolean) => void;\n /** Flag driving panel visibility. */\n visible?: FloatingPanelProps['visible'];\n /** Reference to the root component. */\n ref?: Ref<HTMLDivElement>;\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface TransferReasonOption {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
}
|
|
5
|
+
export interface TransferData {
|
|
6
|
+
/** Selected reason option identifier. */
|
|
7
|
+
reason?: TransferReasonOption['id'];
|
|
8
|
+
/** Transfer comments. */
|
|
9
|
+
comments?: string;
|
|
10
|
+
/** Flag determining where interaction should be transferred along the call. */
|
|
11
|
+
interaction: boolean;
|
|
12
|
+
/** Phone number to transfer the call to. */
|
|
13
|
+
phoneNumber: string;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=CallHandover.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CallHandover.types.d.ts","sourceRoot":"","sources":["../../../../src/components/CallControlPanel/CallHandover/CallHandover.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,yCAAyC;IACzC,MAAM,CAAC,EAAE,oBAAoB,CAAC,IAAI,CAAC,CAAC;IACpC,yBAAyB;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,WAAW,EAAE,OAAO,CAAC;IACrB,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CallHandover.types.js","sourceRoot":"","sources":["../../../../src/components/CallControlPanel/CallHandover/CallHandover.types.ts"],"names":[],"mappings":"","sourcesContent":["export interface TransferReasonOption {\n id: string;\n label: string;\n}\n\nexport interface TransferData {\n /** Selected reason option identifier. */\n reason?: TransferReasonOption['id'];\n /** Transfer comments. */\n comments?: string;\n /** Flag determining where interaction should be transferred along the call. */\n interaction: boolean;\n /** Phone number to transfer the call to. */\n phoneNumber: string;\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import type { TransferData, TransferReasonOption } from './CallHandover.types';
|
|
3
|
+
export declare type HandoverType = 'conference' | 'transferWithInteractions' | 'transferCallOnly' | 'consultWithInteractions' | 'consultCallOnly';
|
|
4
|
+
export interface CallHandoverDialogProps {
|
|
5
|
+
target: HTMLElement | null;
|
|
6
|
+
type: HandoverType;
|
|
7
|
+
onCancel: () => void;
|
|
8
|
+
onSubmit: (data: TransferData) => void;
|
|
9
|
+
transferOptions: Readonly<TransferReasonOption[]>;
|
|
10
|
+
}
|
|
11
|
+
declare const CallHandoverDialog: FunctionComponent<CallHandoverDialogProps>;
|
|
12
|
+
export default CallHandoverDialog;
|
|
13
|
+
//# sourceMappingURL=CallHandoverDialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CallHandoverDialog.d.ts","sourceRoot":"","sources":["../../../../src/components/CallControlPanel/CallHandover/CallHandoverDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAgC,MAAM,OAAO,CAAC;AAkBxE,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE/E,oBAAY,YAAY,GACpB,YAAY,GACZ,0BAA0B,GAC1B,kBAAkB,GAClB,yBAAyB,GACzB,iBAAiB,CAAC;AAEtB,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3B,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;IACvC,eAAe,EAAE,QAAQ,CAAC,oBAAoB,EAAE,CAAC,CAAC;CACnD;AAED,QAAA,MAAM,kBAAkB,EAAE,iBAAiB,CAAC,uBAAuB,CAkHlE,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
import { Text, Button, Card, CardContent, CardHeader, Icon, Popover, useEscape, useFocusTrap, useI18n, useOuterEvent, getFocusables } from '@pega/cosmos-react-core';
|
|
4
|
+
import CallHandoverForm from './CallHandoverForm';
|
|
5
|
+
const CallHandoverDialog = ({ target, type, onSubmit, onCancel, transferOptions }) => {
|
|
6
|
+
const popoverRef = useRef(null);
|
|
7
|
+
const t = useI18n();
|
|
8
|
+
useOuterEvent('mousedown', [popoverRef], onCancel);
|
|
9
|
+
useEscape(onCancel, popoverRef);
|
|
10
|
+
useFocusTrap(popoverRef);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
getFocusables(popoverRef)[0]?.focus();
|
|
13
|
+
}, []);
|
|
14
|
+
let dialogContent;
|
|
15
|
+
let dialogHeading;
|
|
16
|
+
switch (type) {
|
|
17
|
+
case 'conference':
|
|
18
|
+
dialogHeading = t('call_panel_conference_heading');
|
|
19
|
+
dialogContent = (_jsx(CallHandoverForm, { onCancel: onCancel, variant: 'call', submitButtonText: t('call_panel_conference_submit'), onSubmit: onSubmit, transferOptions: transferOptions }));
|
|
20
|
+
break;
|
|
21
|
+
case 'consultCallOnly':
|
|
22
|
+
dialogHeading = t('call_panel_consult_with_call_heading');
|
|
23
|
+
dialogContent = (_jsx(CallHandoverForm, { onCancel: onCancel, variant: 'call', submitButtonText: t('call_panel_consult_call_submit'), onSubmit: onSubmit, transferOptions: transferOptions }));
|
|
24
|
+
break;
|
|
25
|
+
case 'consultWithInteractions':
|
|
26
|
+
dialogHeading = t('call_panel_consult_with_call_and_interactions_heading');
|
|
27
|
+
dialogContent = (_jsx(CallHandoverForm, { onCancel: onCancel, variant: 'call+interaction', submitButtonText: t('call_panel_consult_call_submit'), onSubmit: onSubmit, transferOptions: transferOptions }));
|
|
28
|
+
break;
|
|
29
|
+
case 'transferCallOnly':
|
|
30
|
+
dialogHeading = t('call_panel_transfer_with_call_heading');
|
|
31
|
+
dialogContent = (_jsx(CallHandoverForm, { submitButtonText: t('call_panel_transfer_call_submit'), onCancel: onCancel, variant: 'call', onSubmit: onSubmit, transferOptions: transferOptions }));
|
|
32
|
+
break;
|
|
33
|
+
case 'transferWithInteractions':
|
|
34
|
+
dialogHeading = t('call_panel_transfer_with_call_and_interactions_heading');
|
|
35
|
+
dialogContent = (_jsx(CallHandoverForm, { submitButtonText: t('call_panel_transfer_call_submit'), onCancel: onCancel, variant: 'call+interaction', onSubmit: onSubmit, transferOptions: transferOptions }));
|
|
36
|
+
break;
|
|
37
|
+
default:
|
|
38
|
+
dialogHeading = '';
|
|
39
|
+
dialogContent = null;
|
|
40
|
+
}
|
|
41
|
+
return (_jsx(Popover, { target: target, ref: popoverRef, placement: 'top-end', modifiers: [
|
|
42
|
+
{
|
|
43
|
+
name: 'flip',
|
|
44
|
+
options: {
|
|
45
|
+
fallbackPlacements: ['bottom-end', 'left', 'right']
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
], children: _jsxs(Card, { children: [_jsx(CardHeader, { actions: _jsx(Button, { icon: true, variant: 'simple', "aria-label": t('close'), onClick: onCancel, children: _jsx(Icon, { name: 'times' }) }), children: _jsx(Text, { variant: 'h3', children: dialogHeading }) }), _jsx(CardContent, { children: dialogContent })] }) }));
|
|
49
|
+
};
|
|
50
|
+
export default CallHandoverDialog;
|
|
51
|
+
//# sourceMappingURL=CallHandoverDialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CallHandoverDialog.js","sourceRoot":"","sources":["../../../../src/components/CallControlPanel/CallHandover/CallHandoverDialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAgC,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAExE,OAAO,EACL,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,WAAW,EACX,UAAU,EACV,IAAI,EACJ,OAAO,EACP,SAAS,EACT,YAAY,EACZ,OAAO,EACP,aAAa,EACb,aAAa,EACd,MAAM,yBAAyB,CAAC;AAEjC,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAkBlD,MAAM,kBAAkB,GAA+C,CAAC,EACtE,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,eAAe,EACS,EAAE,EAAE;IAC5B,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAChD,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IAEpB,aAAa,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,EA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, useRef } from 'react';\n\nimport {\n Text,\n Button,\n Card,\n CardContent,\n CardHeader,\n Icon,\n Popover,\n useEscape,\n useFocusTrap,\n useI18n,\n useOuterEvent,\n getFocusables\n} from '@pega/cosmos-react-core';\n\nimport CallHandoverForm from './CallHandoverForm';\nimport type { TransferData, TransferReasonOption } from './CallHandover.types';\n\nexport type HandoverType =\n | 'conference'\n | 'transferWithInteractions'\n | 'transferCallOnly'\n | 'consultWithInteractions'\n | 'consultCallOnly';\n\nexport interface CallHandoverDialogProps {\n target: HTMLElement | null;\n type: HandoverType;\n onCancel: () => void;\n onSubmit: (data: TransferData) => void;\n transferOptions: Readonly<TransferReasonOption[]>;\n}\n\nconst CallHandoverDialog: FunctionComponent<CallHandoverDialogProps> = ({\n target,\n type,\n onSubmit,\n onCancel,\n transferOptions\n}: CallHandoverDialogProps) => {\n const popoverRef = useRef<HTMLDivElement>(null);\n const t = useI18n();\n\n useOuterEvent('mousedown', [popoverRef], onCancel);\n useEscape(onCancel, popoverRef);\n useFocusTrap(popoverRef);\n\n useEffect(() => {\n getFocusables(popoverRef)[0]?.focus();\n }, []);\n\n let dialogContent: ReactNode;\n let dialogHeading: string;\n switch (type) {\n case 'conference':\n dialogHeading = t('call_panel_conference_heading');\n dialogContent = (\n <CallHandoverForm\n onCancel={onCancel}\n variant='call'\n submitButtonText={t('call_panel_conference_submit')}\n onSubmit={onSubmit}\n transferOptions={transferOptions}\n />\n );\n break;\n case 'consultCallOnly':\n dialogHeading = t('call_panel_consult_with_call_heading');\n dialogContent = (\n <CallHandoverForm\n onCancel={onCancel}\n variant='call'\n submitButtonText={t('call_panel_consult_call_submit')}\n onSubmit={onSubmit}\n transferOptions={transferOptions}\n />\n );\n break;\n case 'consultWithInteractions':\n dialogHeading = t('call_panel_consult_with_call_and_interactions_heading');\n dialogContent = (\n <CallHandoverForm\n onCancel={onCancel}\n variant='call+interaction'\n submitButtonText={t('call_panel_consult_call_submit')}\n onSubmit={onSubmit}\n transferOptions={transferOptions}\n />\n );\n break;\n case 'transferCallOnly':\n dialogHeading = t('call_panel_transfer_with_call_heading');\n dialogContent = (\n <CallHandoverForm\n submitButtonText={t('call_panel_transfer_call_submit')}\n onCancel={onCancel}\n variant='call'\n onSubmit={onSubmit}\n transferOptions={transferOptions}\n />\n );\n break;\n case 'transferWithInteractions':\n dialogHeading = t('call_panel_transfer_with_call_and_interactions_heading');\n dialogContent = (\n <CallHandoverForm\n submitButtonText={t('call_panel_transfer_call_submit')}\n onCancel={onCancel}\n variant='call+interaction'\n onSubmit={onSubmit}\n transferOptions={transferOptions}\n />\n );\n break;\n default:\n dialogHeading = '';\n dialogContent = null;\n }\n\n return (\n <Popover\n target={target}\n ref={popoverRef}\n placement='top-end'\n modifiers={[\n {\n name: 'flip',\n options: {\n fallbackPlacements: ['bottom-end', 'left', 'right']\n }\n }\n ]}\n >\n <Card>\n <CardHeader\n actions={\n <Button icon variant='simple' aria-label={t('close')} onClick={onCancel}>\n <Icon name='times' />\n </Button>\n }\n >\n <Text variant='h3'>{dialogHeading}</Text>\n </CardHeader>\n <CardContent>{dialogContent}</CardContent>\n </Card>\n </Popover>\n );\n};\n\nexport default CallHandoverDialog;\n"]}
|
package/lib/components/CallControlPanel/{CallHandoverForm.d.ts → CallHandover/CallHandoverForm.d.ts}
RENAMED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { FunctionComponent, Ref } from 'react';
|
|
2
|
-
import type { TransferReasonOption, TransferData } from './
|
|
2
|
+
import type { TransferReasonOption, TransferData } from './CallHandover.types';
|
|
3
3
|
export interface CallHandoverFormProps {
|
|
4
4
|
/**
|
|
5
5
|
* Callback fired on handover submission.
|
|
6
|
-
* @param
|
|
6
|
+
* @param data the transfer parameters.
|
|
7
7
|
*/
|
|
8
|
-
onSubmit: (
|
|
8
|
+
onSubmit: (data: TransferData) => void;
|
|
9
9
|
/** Callback fired on clicking Cancel button. */
|
|
10
10
|
onCancel: () => void;
|
|
11
11
|
/** Transfer reason options. */
|
|
12
12
|
transferOptions: Readonly<TransferReasonOption[]>;
|
|
13
13
|
/** Reference to the root component. */
|
|
14
14
|
ref?: Ref<HTMLDivElement>;
|
|
15
|
+
/** Variant of component. */
|
|
16
|
+
variant?: 'call' | 'call+interaction';
|
|
17
|
+
/** Label of the submit button. */
|
|
18
|
+
submitButtonText: string;
|
|
15
19
|
}
|
|
16
20
|
export declare const StyledCallHandoverForm: import("styled-components").StyledComponent<import("react").FC<import("@pega/cosmos-react-core").FormProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
17
21
|
declare const CallHandoverForm: FunctionComponent<CallHandoverFormProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CallHandoverForm.d.ts","sourceRoot":"","sources":["../../../../src/components/CallControlPanel/CallHandover/CallHandoverForm.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,GAAG,EAAyB,MAAM,OAAO,CAAC;AAkBtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAI/E,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;IACvC,gDAAgD;IAChD,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,+BAA+B;IAC/B,eAAe,EAAE,QAAQ,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAClD,uCAAuC;IACvC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IAC1B,4BAA4B;IAC5B,OAAO,CAAC,EAAE,MAAM,GAAG,kBAAkB,CAAC;IACtC,kCAAkC;IAClC,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,eAAO,MAAM,sBAAsB,oNAMlC,CAAC;AAIF,QAAA,MAAM,gBAAgB,EAAE,iBAAiB,CAAC,qBAAqB,CAiF9D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { Button, registerIcon, defaultThemeProp, useI18n, TextArea, ComboBox, Form } from '@pega/cosmos-react-core';
|
|
5
|
+
import { StyledTabPanel } from '@pega/cosmos-react-core/lib/components/Tabs/TabPanel';
|
|
6
|
+
import * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';
|
|
7
|
+
import CalleePicker from '../ContactList/CalleePicker';
|
|
8
|
+
registerIcon(timesIcon);
|
|
9
|
+
export const StyledCallHandoverForm = styled(Form) `
|
|
10
|
+
min-width: 50ch;
|
|
11
|
+
|
|
12
|
+
${StyledTabPanel} {
|
|
13
|
+
height: 24rem;
|
|
14
|
+
}
|
|
15
|
+
`;
|
|
16
|
+
StyledCallHandoverForm.defaultProps = defaultThemeProp;
|
|
17
|
+
const CallHandoverForm = ({ onCancel, onSubmit, transferOptions, variant, submitButtonText }) => {
|
|
18
|
+
const t = useI18n();
|
|
19
|
+
const [selectedReason, setSelectedReason] = useState();
|
|
20
|
+
const [selectedContact, setSelectedContact] = useState();
|
|
21
|
+
const [comments, setComments] = useState('');
|
|
22
|
+
return (_jsxs(StyledCallHandoverForm, { actions: _jsxs(_Fragment, { children: [_jsx(Button, { variant: 'secondary', onClick: onCancel, children: t('cancel') }), _jsx(Button, { variant: 'primary', disabled: !(selectedContact &&
|
|
23
|
+
(variant === 'call+interaction' ? selectedReason && comments : true)), onClick: () => {
|
|
24
|
+
if (!selectedContact)
|
|
25
|
+
return;
|
|
26
|
+
onSubmit({
|
|
27
|
+
reason: selectedReason?.id,
|
|
28
|
+
comments,
|
|
29
|
+
interaction: variant === 'call+interaction',
|
|
30
|
+
phoneNumber: selectedContact
|
|
31
|
+
});
|
|
32
|
+
}, children: submitButtonText })] }), children: [variant === 'call+interaction' && (_jsxs(_Fragment, { children: [_jsx(ComboBox, { label: t('call_panel_handover_reason_label'), required: true, selected: {
|
|
33
|
+
items: selectedReason
|
|
34
|
+
? { id: selectedReason.id, text: selectedReason.label }
|
|
35
|
+
: undefined
|
|
36
|
+
}, menu: {
|
|
37
|
+
items: transferOptions.map(({ id, label }) => ({
|
|
38
|
+
id,
|
|
39
|
+
primary: label,
|
|
40
|
+
selected: id === selectedReason?.id
|
|
41
|
+
})),
|
|
42
|
+
onItemClick: id => setSelectedReason(transferOptions.find(option => option.id === id))
|
|
43
|
+
} }), _jsx(TextArea, { name: 'comments', required: true, label: t('call_panel_handover_comments_label'), displayCharCount: true, maxLength: 300, value: comments, onChange: (e) => setComments(e.target.value) })] })), _jsx(CalleePicker, { selectedContact: selectedContact, onSelection: setSelectedContact, variant: 'select' })] }));
|
|
44
|
+
};
|
|
45
|
+
export default CallHandoverForm;
|
|
46
|
+
//# sourceMappingURL=CallHandoverForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CallHandoverForm.js","sourceRoot":"","sources":["../../../../src/components/CallControlPanel/CallHandover/CallHandoverForm.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA0B,QAAQ,EAAe,MAAM,OAAO,CAAC;AACtE,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EACL,MAAM,EACN,YAAY,EACZ,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,IAAI,EACL,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAC;AACtF,OAAO,KAAK,SAAS,MAAM,8DAA8D,CAAC;AAG1F,OAAO,YAAY,MAAM,6BAA6B,CAAC;AAIvD,YAAY,CAAC,SAAS,CAAC,CAAC;AAoBxB,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;;IAG9C,cAAc;;;CAGjB,CAAC;AAEF,sBAAsB,CAAC,YAAY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cAAc,CAAC,KAAK,EAAE;gCACvD,CAAC,CAAC,SAAS;yBACd,EACD,IAAI,EAAE;4BACJ,KAAK,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;gCAC7C,EAAE;gCACF,OAAO,EAAE,KAAK;gCACd,QAAQ,EAAE,EAAE,KAAK,cAAc,EAAE,EAAE;6BACpC,CAAC,CAAC;4BACH,WAAW,EAAE,EAAE,CAAC,EAAE,CAAC,iBAAiB,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;yBACvF,GACD,EAEF,KAAC,QAAQ,IACP,IAAI,EAAC,UAAU,EACf,QAAQ,QACR,KAAK,EAAE,CAAC,CAAC,oCAAoC,CAAC,EAC9C,gBAAgB,QAChB,SAAS,EAAE,GAAG,EACd,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,CAAC,CAAmC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GAC9E,IACD,CACJ,EACD,KAAC,YAAY,IACX,eAAe,EAAE,eAAe,EAChC,WAAW,EAAE,kBAAkB,EAC/B,OAAO,EAAC,QAAQ,GAChB,IACqB,CAC1B,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import { FunctionComponent, Ref, useState, ChangeEvent } from 'react';\nimport styled from 'styled-components';\n\nimport {\n Button,\n registerIcon,\n defaultThemeProp,\n useI18n,\n TextArea,\n ComboBox,\n Form\n} from '@pega/cosmos-react-core';\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 type { Contact } from '../ContactList';\nimport CalleePicker from '../ContactList/CalleePicker';\n\nimport type { TransferReasonOption, TransferData } from './CallHandover.types';\n\nregisterIcon(timesIcon);\n\nexport interface CallHandoverFormProps {\n /**\n * Callback fired on handover submission.\n * @param data the transfer parameters.\n */\n onSubmit: (data: TransferData) => void;\n /** Callback fired on clicking Cancel button. */\n onCancel: () => void;\n /** Transfer reason options. */\n transferOptions: Readonly<TransferReasonOption[]>;\n /** Reference to the root component. */\n ref?: Ref<HTMLDivElement>;\n /** Variant of component. */\n variant?: 'call' | 'call+interaction';\n /** Label of the submit button. */\n submitButtonText: string;\n}\n\nexport const StyledCallHandoverForm = styled(Form)`\n min-width: 50ch;\n\n ${StyledTabPanel} {\n height: 24rem;\n }\n`;\n\nStyledCallHandoverForm.defaultProps = defaultThemeProp;\n\nconst CallHandoverForm: FunctionComponent<CallHandoverFormProps> = ({\n onCancel,\n onSubmit,\n transferOptions,\n variant,\n submitButtonText\n}: CallHandoverFormProps) => {\n const t = useI18n();\n\n const [selectedReason, setSelectedReason] = useState<TransferReasonOption>();\n const [selectedContact, setSelectedContact] = useState<Contact['phoneNumber']>();\n const [comments, setComments] = useState('');\n\n return (\n <StyledCallHandoverForm\n actions={\n <>\n <Button variant='secondary' onClick={onCancel}>\n {t('cancel')}\n </Button>\n <Button\n variant='primary'\n disabled={\n !(\n selectedContact &&\n (variant === 'call+interaction' ? selectedReason && comments : true)\n )\n }\n onClick={() => {\n if (!selectedContact) return;\n onSubmit({\n reason: selectedReason?.id,\n comments,\n interaction: variant === 'call+interaction',\n phoneNumber: selectedContact\n });\n }}\n >\n {submitButtonText}\n </Button>\n </>\n }\n >\n {variant === 'call+interaction' && (\n <>\n <ComboBox\n label={t('call_panel_handover_reason_label')}\n required\n selected={{\n items: selectedReason\n ? { id: selectedReason.id, text: selectedReason.label }\n : undefined\n }}\n menu={{\n items: transferOptions.map(({ id, label }) => ({\n id,\n primary: label,\n selected: id === selectedReason?.id\n })),\n onItemClick: id => setSelectedReason(transferOptions.find(option => option.id === id))\n }}\n />\n\n <TextArea\n name='comments'\n required\n label={t('call_panel_handover_comments_label')}\n displayCharCount\n maxLength={300}\n value={comments}\n onChange={(e: ChangeEvent<HTMLTextAreaElement>) => setComments(e.target.value)}\n />\n </>\n )}\n <CalleePicker\n selectedContact={selectedContact}\n onSelection={setSelectedContact}\n variant='select'\n />\n </StyledCallHandoverForm>\n );\n};\n\nexport default CallHandoverForm;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/CallControlPanel/CallHandover/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjE,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/CallControlPanel/CallHandover/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjE,cAAc,sBAAsB,CAAC","sourcesContent":["export { default } from './CallHandoverDialog';\nexport { default as CallHandoverForm } from './CallHandoverForm';\nexport * from './CallHandover.types';\n"]}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { FunctionComponent, Ref } from 'react';
|
|
2
2
|
import { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
-
import { ContactsListProps } from './ContactsList';
|
|
4
3
|
export interface CalleePickerProps {
|
|
5
|
-
/**
|
|
6
|
-
|
|
4
|
+
/** Currently selected number. */
|
|
5
|
+
selectedContact?: string;
|
|
7
6
|
/**
|
|
8
7
|
* Callback fired on new call made by the user.
|
|
9
8
|
* @param phoneNumber the number chosen.
|
|
10
9
|
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
|
|
10
|
+
onSelection: (phoneNumber: string) => void;
|
|
11
|
+
/** Variant of the list. */
|
|
12
|
+
variant: 'action' | 'select';
|
|
14
13
|
/** Reference to the root component. */
|
|
15
14
|
ref?: Ref<HTMLDivElement>;
|
|
16
15
|
}
|
|
17
|
-
export declare const ContactsContext: import("react").Context<Pick<ContactsListProps, "onFavoriteToggle" | "contacts">>;
|
|
18
16
|
declare const CalleePicker: FunctionComponent<CalleePickerProps & ForwardProps>;
|
|
19
17
|
export default CalleePicker;
|
|
20
18
|
//# sourceMappingURL=CalleePicker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CalleePicker.d.ts","sourceRoot":"","sources":["../../../../src/components/CallControlPanel/ContactList/CalleePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAEjB,GAAG,EAGJ,MAAM,OAAO,CAAC;AAGf,OAAO,EAIL,YAAY,EAGb,MAAM,yBAAyB,CAAC;AAUjC,MAAM,WAAW,iBAAiB;IAChC,iCAAiC;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,WAAW,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,2BAA2B;IAC3B,OAAO,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC7B,uCAAuC;IACvC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAYD,QAAA,MAAM,YAAY,EAAE,iBAAiB,CAAC,iBAAiB,GAAG,YAAY,CAkErE,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useContext, forwardRef, useRef, useState } from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import { registerIcon, TabPanel, Tabs, defaultThemeProp, useI18n } from '@pega/cosmos-react-core';
|
|
5
|
+
import { StyledTabPanel } from '@pega/cosmos-react-core/lib/components/Tabs/TabPanel';
|
|
6
|
+
import * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';
|
|
7
|
+
import DialPad from '../../DialPad/DialPad';
|
|
8
|
+
import ContactList, { ContactsContext } from './ContactList';
|
|
9
|
+
registerIcon(timesIcon);
|
|
10
|
+
const StyledCalleePicker = styled.div(() => {
|
|
11
|
+
return css `
|
|
12
|
+
${StyledTabPanel} {
|
|
13
|
+
height: 24rem;
|
|
14
|
+
}
|
|
15
|
+
`;
|
|
16
|
+
});
|
|
17
|
+
StyledCalleePicker.defaultProps = defaultThemeProp;
|
|
18
|
+
const CalleePicker = forwardRef(({ selectedContact, onSelection, variant }, ref) => {
|
|
19
|
+
const t = useI18n();
|
|
20
|
+
const [currentTab, setCurrentTab] = useState('all');
|
|
21
|
+
const tabsRef = useRef(null);
|
|
22
|
+
const { contacts, onFavoriteToggle } = useContext(ContactsContext);
|
|
23
|
+
const favorites = contacts.filter(item => item.favorite);
|
|
24
|
+
const tabs = [
|
|
25
|
+
{ id: 'all', name: t('call_panel_contacts_list_heading'), count: contacts.length },
|
|
26
|
+
{
|
|
27
|
+
id: 'favorites',
|
|
28
|
+
name: t('call_panel_contacts_favorites_heading'),
|
|
29
|
+
count: contacts.filter(item => item.favorite).length
|
|
30
|
+
},
|
|
31
|
+
{ id: 'dial-pad', name: t('call_panel_contacts_dial_pad_heading') }
|
|
32
|
+
];
|
|
33
|
+
const tabContent = (tabId) => {
|
|
34
|
+
if (tabId === 'dial-pad')
|
|
35
|
+
return (_jsx(DialPad, { mode: 'default', ...(variant === 'action'
|
|
36
|
+
? {
|
|
37
|
+
onCallButtonClick: onSelection
|
|
38
|
+
}
|
|
39
|
+
: {
|
|
40
|
+
onDialButtonClick: charCode => onSelection(charCode === 127
|
|
41
|
+
? selectedContact?.slice(0, -1) ?? ''
|
|
42
|
+
: (selectedContact ?? '') + String.fromCharCode(charCode))
|
|
43
|
+
}) }));
|
|
44
|
+
return (_jsx(ContactList, { contacts: (tabId === 'favorites' ? favorites : contacts).map(contact => ({
|
|
45
|
+
...contact,
|
|
46
|
+
selected: contact.phoneNumber === selectedContact
|
|
47
|
+
})), onFavoriteToggle: onFavoriteToggle, onItemClick: onSelection, variant: variant }));
|
|
48
|
+
};
|
|
49
|
+
return (_jsxs(StyledCalleePicker, { ref: ref, children: [_jsx(Tabs, { ref: tabsRef, tabs: tabs, type: 'horizontal', onTabClick: setCurrentTab, currentTabId: currentTab }), _jsx(TabPanel, { tabId: currentTab, children: tabContent(currentTab) })] }));
|
|
50
|
+
});
|
|
51
|
+
export default CalleePicker;
|
|
52
|
+
//# sourceMappingURL=CalleePicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CalleePicker.js","sourceRoot":"","sources":["../../../../src/components/CallControlPanel/ContactList/CalleePicker.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,UAAU,EAIV,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,IAAI,EAEJ,gBAAgB,EAChB,OAAO,EACR,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAC;AACtF,OAAO,KAAK,SAAS,MAAM,8DAA8D,CAAC;AAE1F,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAE5C,OAAO,WAAW,EAAE,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAE7D,YAAY,CAAC,SAAS,CAAC,CAAC;AAgBxB,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE;IACzC,OAAO,GAAG,CAAA;MACN,cAAc;;;GAGjB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,kBAAkB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEnD,MAAM,YAAY,GAAwD,UAAU,CAClF,CACE,E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AI,EAAE;4BACrC,CAAC,CAAC,CAAC,eAAe,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAC5D;qBACJ,CAAC,GACN,CACH,CAAC;QACJ,OAAO,CACL,KAAC,WAAW,IACV,QAAQ,EAAE,CAAC,KAAK,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;gBACvE,GAAG,OAAO;gBACV,QAAQ,EAAE,OAAO,CAAC,WAAW,KAAK,eAAe;aAClD,CAAC,CAAC,EACH,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,OAAO,GAChB,CACH,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CACL,MAAC,kBAAkB,IAAC,GAAG,EAAE,GAAG,aAC1B,KAAC,IAAI,IACH,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,IAAI,EACV,IAAI,EAAC,YAAY,EACjB,UAAU,EAAE,aAAa,EACzB,YAAY,EAAE,UAAU,GACxB,EACF,KAAC,QAAQ,IAAC,KAAK,EAAE,UAAU,YAAG,UAAU,CAAC,UAAU,CAAC,GAAY,IAC7C,CACtB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import {\n useContext,\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n Ref,\n useRef,\n useState\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n registerIcon,\n TabPanel,\n Tabs,\n ForwardProps,\n defaultThemeProp,\n useI18n\n} from '@pega/cosmos-react-core';\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 ContactList, { ContactsContext } from './ContactList';\n\nregisterIcon(timesIcon);\n\nexport interface CalleePickerProps {\n /** Currently selected number. */\n selectedContact?: string;\n /**\n * Callback fired on new call made by the user.\n * @param phoneNumber the number chosen.\n */\n onSelection: (phoneNumber: string) => void;\n /** Variant of the list. */\n variant: 'action' | 'select';\n /** Reference to the root component. */\n ref?: Ref<HTMLDivElement>;\n}\n\nconst StyledCalleePicker = styled.div(() => {\n return css`\n ${StyledTabPanel} {\n height: 24rem;\n }\n `;\n});\n\nStyledCalleePicker.defaultProps = defaultThemeProp;\n\nconst CalleePicker: FunctionComponent<CalleePickerProps & ForwardProps> = forwardRef(\n (\n { selectedContact, onSelection, variant }: 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 tabs = [\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')\n return (\n <DialPad\n mode='default'\n {...(variant === 'action'\n ? {\n onCallButtonClick: onSelection\n }\n : {\n onDialButtonClick: charCode =>\n onSelection(\n charCode === 127\n ? selectedContact?.slice(0, -1) ?? ''\n : (selectedContact ?? '') + String.fromCharCode(charCode)\n )\n })}\n />\n );\n return (\n <ContactList\n contacts={(tabId === 'favorites' ? favorites : contacts).map(contact => ({\n ...contact,\n selected: contact.phoneNumber === selectedContact\n }))}\n onFavoriteToggle={onFavoriteToggle}\n onItemClick={onSelection}\n variant={variant}\n />\n );\n };\n\n return (\n <StyledCalleePicker ref={ref}>\n <Tabs\n ref={tabsRef}\n tabs={tabs}\n type='horizontal'\n onTabClick={setCurrentTab}\n currentTabId={currentTab}\n />\n <TabPanel tabId={currentTab}>{tabContent(currentTab)}</TabPanel>\n </StyledCalleePicker>\n );\n }\n);\n\nexport default CalleePicker;\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import type { Contact, ContactListProps } from './ContactList.types';
|
|
4
|
+
export declare const ContactsContext: import("react").Context<{
|
|
5
|
+
contacts: Contact[];
|
|
6
|
+
onFavoriteToggle: ContactListProps['onFavoriteToggle'];
|
|
7
|
+
}>;
|
|
8
|
+
declare const ContactList: FunctionComponent<ContactListProps & ForwardProps>;
|
|
9
|
+
export default ContactList;
|
|
10
|
+
//# sourceMappingURL=ContactList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContactList.d.ts","sourceRoot":"","sources":["../../../../src/components/CallControlPanel/ContactList/ContactList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAKlB,MAAM,OAAO,CAAC;AAGf,OAAO,EAGL,YAAY,EAkBb,MAAM,yBAAyB,CAAC;AASjC,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAqB,MAAM,qBAAqB,CAAC;AAiExF,eAAO,MAAM,eAAe;cAChB,OAAO,EAAE;sBACD,gBAAgB,CAAC,kBAAkB,CAAC;EAItD,CAAC;AAgDH,QAAA,MAAM,WAAW,EAAE,iBAAiB,CAAC,gBAAgB,GAAG,YAAY,CAoFnE,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, forwardRef, useCallback, useState } from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import { Button, defaultThemeProp, Icon, registerIcon, Text, useI18n, ViewAll, StyledSummaryItemActions, StyledPrimary, StyledSecondary, useArrows, useConsolidatedRef, StyledCard, RadioButton, SummaryItem, StyledSummaryItem, StyledLabel } 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
|
+
import { StyledRadioCheckCard } from '@pega/cosmos-react-core/lib/components/RadioCheck/RadioCheck';
|
|
9
|
+
import BareRoleButton from '@pega/cosmos-react-core/lib/components/Button/BareRoleButton';
|
|
10
|
+
registerIcon(starIcon, starSolidIcon);
|
|
11
|
+
const StyledContactList = styled.div(({ theme: { base, components } }) => {
|
|
12
|
+
return css `
|
|
13
|
+
height: 100%;
|
|
14
|
+
overflow-y: auto;
|
|
15
|
+
overflow-x: hidden;
|
|
16
|
+
padding: 0 calc(0.5 * ${base.spacing}) calc(0.5 * ${base.spacing});
|
|
17
|
+
|
|
18
|
+
> ${StyledCard} > ${StyledCardContent} {
|
|
19
|
+
padding: 0;
|
|
20
|
+
gap: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
ul {
|
|
24
|
+
list-style: none;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
${StyledRadioCheckCard} {
|
|
28
|
+
background-color: transparent;
|
|
29
|
+
border: 0;
|
|
30
|
+
padding: 0 calc(0.5 * ${base.spacing});
|
|
31
|
+
height: ${components.button.height};
|
|
32
|
+
align-items: center;
|
|
33
|
+
border-radius: 0;
|
|
34
|
+
|
|
35
|
+
> ${StyledLabel} {
|
|
36
|
+
max-width: 100%;
|
|
37
|
+
width: 100%;
|
|
38
|
+
margin: 0;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
li {
|
|
43
|
+
padding: 0;
|
|
44
|
+
height: calc(${components.button.height} + 0.125rem);
|
|
45
|
+
|
|
46
|
+
:not(:last-child) {
|
|
47
|
+
border-bottom: 0.0625rem solid ${base.palette['border-line']};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
${StyledSummaryItem} {
|
|
52
|
+
> ${StyledPrimary}, > ${StyledSecondary} {
|
|
53
|
+
align-self: center;
|
|
54
|
+
font-weight: ${base['font-weight'].normal};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
${StyledSummaryItemActions} {
|
|
59
|
+
color: ${base.palette.interactive};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@media (pointer: 'coarse') {
|
|
63
|
+
li {
|
|
64
|
+
height: ${components.button.touch.height};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
});
|
|
69
|
+
StyledContactList.defaultProps = defaultThemeProp;
|
|
70
|
+
export const ContactsContext = createContext({
|
|
71
|
+
contacts: [],
|
|
72
|
+
onFavoriteToggle: () => { }
|
|
73
|
+
});
|
|
74
|
+
const SelectableContactItem = ({ id, primary, secondary, checked, container, onChange }) => {
|
|
75
|
+
return (_jsx("li", { children: _jsx(RadioButton, { card: true, variant: 'card', label: _jsx(SummaryItem, { id: id, primary: primary, secondary: secondary, container: container }), checked: checked, onChange: onChange, name: `${id}-contact` }) }, id));
|
|
76
|
+
};
|
|
77
|
+
const CallableContactItem = ({ visual, primary, secondary, onClick, container }) => {
|
|
78
|
+
return (_jsx("li", { children: _jsx(BareRoleButton, { onClick: onClick, children: _jsx(SummaryItem, { visual: visual, primary: primary, secondary: secondary, container: container, actions: _jsx(Icon, { name: 'phone-solid' }) }) }) }));
|
|
79
|
+
};
|
|
80
|
+
const ContactList = forwardRef(({ contacts: items, onItemClick, onFavoriteToggle, variant }, ref) => {
|
|
81
|
+
const t = useI18n();
|
|
82
|
+
const [searchText, setSearchText] = useState('');
|
|
83
|
+
const containerRef = useConsolidatedRef(ref);
|
|
84
|
+
const onSearchChange = useCallback((value) => {
|
|
85
|
+
setSearchText(value.trim());
|
|
86
|
+
}, []);
|
|
87
|
+
const favoriteButton = useCallback((phoneNumber, favorite) => (_jsx(Button, { variant: 'simple', icon: true, onClick: (e) => {
|
|
88
|
+
e.stopPropagation();
|
|
89
|
+
onFavoriteToggle(phoneNumber, favorite);
|
|
90
|
+
}, "aria-label": favorite
|
|
91
|
+
? t('call_panel_contacts_add_to_favorites')
|
|
92
|
+
: t('call_panel_contacts_remove_from_favorites'), children: _jsx(Icon, { name: favorite ? 'star-solid' : 'star' }) })), [onFavoriteToggle]);
|
|
93
|
+
const createList = (list) => {
|
|
94
|
+
return list.map(item => {
|
|
95
|
+
const commonOpts = {
|
|
96
|
+
id: item.phoneNumber,
|
|
97
|
+
primary: item.primary,
|
|
98
|
+
secondary: _jsx(Text, { variant: 'secondary', children: item.secondary }),
|
|
99
|
+
container: {
|
|
100
|
+
areas: '"visual primary secondary actions"',
|
|
101
|
+
cols: 'auto minmax(0, 2fr) minmax(0, 2fr) auto'
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
return variant === 'select'
|
|
105
|
+
? {
|
|
106
|
+
...commonOpts,
|
|
107
|
+
as: SelectableContactItem,
|
|
108
|
+
checked: item.selected,
|
|
109
|
+
onChange: () => onItemClick(item.phoneNumber)
|
|
110
|
+
}
|
|
111
|
+
: {
|
|
112
|
+
...commonOpts,
|
|
113
|
+
as: CallableContactItem,
|
|
114
|
+
visual: favoriteButton(item.phoneNumber, item.favorite),
|
|
115
|
+
onClick: () => onItemClick(item.phoneNumber)
|
|
116
|
+
};
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
useArrows(containerRef, { selector: ':scope ul [role="button"]' });
|
|
120
|
+
return (_jsx(ViewAll, { as: StyledContactList, ref: containerRef, items: searchText
|
|
121
|
+
? createList(items.filter(({ phoneNumber, primary, secondary }) => {
|
|
122
|
+
return (primary.toLowerCase().includes(searchText.toLowerCase()) ||
|
|
123
|
+
secondary.toLowerCase().includes(searchText.toLowerCase()) ||
|
|
124
|
+
phoneNumber.toLowerCase().includes(searchText.toLowerCase()));
|
|
125
|
+
}))
|
|
126
|
+
: createList(items), searchInputProps: { onSearchChange } }));
|
|
127
|
+
});
|
|
128
|
+
export default ContactList;
|
|
129
|
+
//# sourceMappingURL=ContactList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContactList.js","sourceRoot":"","sources":["../../../../src/components/CallControlPanel/ContactList/ContactList.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EACb,UAAU,EAIV,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,OAAO,EACP,OAAO,EACP,wBAAwB,EACxB,aAAa,EACb,eAAe,EACf,SAAS,EACT,kBAAkB,EAClB,UAAU,EACV,WAAW,EAGX,WAAW,EACX,iBAAiB,EACjB,WAAW,EACZ,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;AACnG,OAAO,EAAE,oBAAoB,EAAE,MAAM,8DAA8D,CAAC;AACpG,OAAO,cAEN,MAAM,8DAA8D,CAAC;AAItE,YAAY,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;AAEtC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE;IACvE,OAAO,GAAG,CAAA;;;;4BAIgB,IAAI,CAAC,OAAO,gBAAgB,IAAI,CAAC,OAAO;;QAE5D,UAAU,MAAM,iBAAiB;;;;;;;;;MASnC,oBAAoB;;;8BAGI,IAAI,CAAC,OAAO;gB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AC,QAAQ,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;oBAC1D,WAAW,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,CAC7D,CAAC;YACJ,CAAC,CAAC,CACH;YACH,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,EAEvB,gBAAgB,EAAE,EAAE,cAAc,EAAE,GACpC,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import {\n createContext,\n forwardRef,\n FunctionComponent,\n MouseEvent,\n PropsWithoutRef,\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 useI18n,\n ViewAll,\n StyledSummaryItemActions,\n StyledPrimary,\n StyledSecondary,\n useArrows,\n useConsolidatedRef,\n StyledCard,\n RadioButton,\n RadioButtonProps,\n SummaryItemProps,\n SummaryItem,\n StyledSummaryItem,\n StyledLabel\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';\nimport { StyledRadioCheckCard } from '@pega/cosmos-react-core/lib/components/RadioCheck/RadioCheck';\nimport BareRoleButton, {\n BareRoleButtonProps\n} from '@pega/cosmos-react-core/lib/components/Button/BareRoleButton';\n\nimport type { Contact, ContactListProps, SelectableContact } from './ContactList.types';\n\nregisterIcon(starIcon, starSolidIcon);\n\nconst StyledContactList = styled.div(({ theme: { base, components } }) => {\n return css`\n height: 100%;\n overflow-y: auto;\n overflow-x: hidden;\n padding: 0 calc(0.5 * ${base.spacing}) calc(0.5 * ${base.spacing});\n\n > ${StyledCard} > ${StyledCardContent} {\n padding: 0;\n gap: 0;\n }\n\n ul {\n list-style: none;\n }\n\n ${StyledRadioCheckCard} {\n background-color: transparent;\n border: 0;\n padding: 0 calc(0.5 * ${base.spacing});\n height: ${components.button.height};\n align-items: center;\n border-radius: 0;\n\n > ${StyledLabel} {\n max-width: 100%;\n width: 100%;\n margin: 0;\n }\n }\n\n li {\n padding: 0;\n height: calc(${components.button.height} + 0.125rem);\n\n :not(:last-child) {\n border-bottom: 0.0625rem solid ${base.palette['border-line']};\n }\n }\n\n ${StyledSummaryItem} {\n > ${StyledPrimary}, > ${StyledSecondary} {\n align-self: center;\n font-weight: ${base['font-weight'].normal};\n }\n }\n\n ${StyledSummaryItemActions} {\n color: ${base.palette.interactive};\n }\n\n @media (pointer: 'coarse') {\n li {\n height: ${components.button.touch.height};\n }\n }\n `;\n});\n\nStyledContactList.defaultProps = defaultThemeProp;\n\nexport const ContactsContext = createContext<{\n contacts: Contact[];\n onFavoriteToggle: ContactListProps['onFavoriteToggle'];\n}>({\n contacts: [],\n onFavoriteToggle: () => {}\n});\n\nconst SelectableContactItem = ({\n id,\n primary,\n secondary,\n checked,\n container,\n onChange\n}: SummaryItemProps & RadioButtonProps) => {\n return (\n <li key={id}>\n <RadioButton\n card\n variant='card'\n label={\n <SummaryItem id={id} primary={primary} secondary={secondary} container={container} />\n }\n checked={checked}\n onChange={onChange}\n name={`${id}-contact`}\n />\n </li>\n );\n};\n\nconst CallableContactItem = ({\n visual,\n primary,\n secondary,\n onClick,\n container\n}: SummaryItemProps & { onClick: BareRoleButtonProps['onClick'] }) => {\n return (\n <li>\n <BareRoleButton onClick={onClick}>\n <SummaryItem\n visual={visual}\n primary={primary}\n secondary={secondary}\n container={container}\n actions={<Icon name='phone-solid' />}\n />\n </BareRoleButton>\n </li>\n );\n};\n\nconst ContactList: FunctionComponent<ContactListProps & ForwardProps> = forwardRef(\n (\n { contacts: items, onItemClick, onFavoriteToggle, variant }: PropsWithoutRef<ContactListProps>,\n ref: ContactListProps['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: SelectableContact[]) => {\n return list.map(item => {\n const commonOpts = {\n id: item.phoneNumber,\n primary: item.primary,\n secondary: <Text variant='secondary'>{item.secondary}</Text>,\n container: {\n areas: '\"visual primary secondary actions\"',\n cols: 'auto minmax(0, 2fr) minmax(0, 2fr) auto'\n }\n };\n return variant === 'select'\n ? {\n ...commonOpts,\n as: SelectableContactItem,\n checked: item.selected,\n onChange: () => onItemClick(item.phoneNumber)\n }\n : {\n ...commonOpts,\n as: CallableContactItem,\n visual: favoriteButton(item.phoneNumber, item.favorite),\n onClick: () => onItemClick(item.phoneNumber)\n };\n });\n };\n\n useArrows(containerRef, { selector: ':scope ul [role=\"button\"]' });\n\n return (\n <ViewAll\n as={StyledContactList}\n ref={containerRef}\n items={\n searchText\n ? createList(\n items.filter(({ phoneNumber, primary, secondary }) => {\n return (\n primary.toLowerCase().includes(searchText.toLowerCase()) ||\n secondary.toLowerCase().includes(searchText.toLowerCase()) ||\n phoneNumber.toLowerCase().includes(searchText.toLowerCase())\n );\n })\n )\n : createList(items)\n }\n searchInputProps={{ onSearchChange }}\n />\n );\n }\n);\n\nexport default ContactList;\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Ref } from 'react';
|
|
2
|
+
export interface Contact {
|
|
3
|
+
/** Contact phone number */
|
|
4
|
+
phoneNumber: string;
|
|
5
|
+
/** Contact name */
|
|
6
|
+
primary: string;
|
|
7
|
+
/** Additional contact information */
|
|
8
|
+
secondary: string;
|
|
9
|
+
/** Determines if contact is favorite */
|
|
10
|
+
favorite: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface SelectableContact extends Contact {
|
|
13
|
+
selected?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface ContactListProps {
|
|
16
|
+
/** An array of contacts objects. */
|
|
17
|
+
contacts: SelectableContact[];
|
|
18
|
+
/**
|
|
19
|
+
* The click handler for the items.
|
|
20
|
+
* @param phoneNumber the number chosen.
|
|
21
|
+
*/
|
|
22
|
+
onItemClick: (phoneNumber: string) => void;
|
|
23
|
+
/** Callback fired on adding/removing contact to/from favorites */
|
|
24
|
+
onFavoriteToggle: (phoneNumber: string, favorites: boolean) => void;
|
|
25
|
+
/** Variant of the list. */
|
|
26
|
+
variant: 'action' | 'select';
|
|
27
|
+
/** Reference to the root component. */
|
|
28
|
+
ref?: Ref<HTMLDivElement>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=ContactList.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContactList.types.d.ts","sourceRoot":"","sources":["../../../../src/components/CallControlPanel/ContactList/ContactList.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,MAAM,WAAW,OAAO;IACtB,2BAA2B;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,wCAAwC;IACxC,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,iBAAkB,SAAQ,OAAO;IAChD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,oCAAoC;IACpC,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B;;;OAGG;IACH,WAAW,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,kEAAkE;IAClE,gBAAgB,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACpE,2BAA2B;IAC3B,OAAO,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC7B,uCAAuC;IACvC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContactList.types.js","sourceRoot":"","sources":["../../../../src/components/CallControlPanel/ContactList/ContactList.types.ts"],"names":[],"mappings":"","sourcesContent":["import { Ref } from 'react';\n\nexport interface Contact {\n /** Contact phone number */\n phoneNumber: string;\n /** Contact name */\n primary: string;\n /** Additional contact information */\n secondary: string;\n /** Determines if contact is favorite */\n favorite: boolean;\n}\n\nexport interface SelectableContact extends Contact {\n selected?: boolean;\n}\n\nexport interface ContactListProps {\n /** An array of contacts objects. */\n contacts: SelectableContact[];\n /**\n * The click handler for the items.\n * @param phoneNumber the number chosen.\n */\n onItemClick: (phoneNumber: string) => void;\n /** Callback fired on adding/removing contact to/from favorites */\n onFavoriteToggle: (phoneNumber: string, favorites: boolean) => void;\n /** Variant of the list. */\n variant: 'action' | 'select';\n /** Reference to the root component. */\n ref?: Ref<HTMLDivElement>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/CallControlPanel/ContactList/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACzD,YAAY,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/CallControlPanel/ContactList/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC","sourcesContent":["export { default, ContactsContext } from './ContactList';\nexport type { ContactListProps, Contact } from './ContactList.types';\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { CallProps, CallParticipant, CallControlPanelProps, UserAvailabilityStatusOption
|
|
1
|
+
export { CallProps, CallParticipant, CallControlPanelProps, UserAvailabilityStatusOption } from './CallControlPanel.types';
|
|
2
2
|
export { default as ExternalCTI } from './ExternalCTI';
|
|
3
3
|
export { default } from './CallControlPanel';
|
|
4
|
+
export type { TransferData } from './CallHandover/CallHandover.types';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|