@pega/cosmos-react-cs 5.0.0-dev.1.0 → 5.0.0-dev.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/CTIPanel/CTIPanel.d.ts +4 -4
- package/lib/components/CTIPanel/CTIPanel.d.ts.map +1 -1
- package/lib/components/CTIPanel/CTIPanel.js.map +1 -1
- package/lib/components/CTIPanel/index.d.ts +2 -1
- package/lib/components/CTIPanel/index.d.ts.map +1 -1
- package/lib/components/CTIPanel/index.js.map +1 -1
- package/lib/components/CallControlPanel/AttachInteractionDialog.d.ts +5 -3
- package/lib/components/CallControlPanel/AttachInteractionDialog.d.ts.map +1 -1
- package/lib/components/CallControlPanel/AttachInteractionDialog.js.map +1 -1
- package/lib/components/CallControlPanel/Call.d.ts +2 -2
- package/lib/components/CallControlPanel/Call.d.ts.map +1 -1
- package/lib/components/CallControlPanel/Call.js +2 -2
- package/lib/components/CallControlPanel/Call.js.map +1 -1
- package/lib/components/CallControlPanel/CallControlPanel.d.ts +2 -2
- package/lib/components/CallControlPanel/CallControlPanel.d.ts.map +1 -1
- package/lib/components/CallControlPanel/CallControlPanel.js.map +1 -1
- package/lib/components/CallControlPanel/CallControlPanel.styles.d.ts +4 -2
- package/lib/components/CallControlPanel/CallControlPanel.styles.d.ts.map +1 -1
- package/lib/components/CallControlPanel/CallControlPanel.styles.js +2 -3
- package/lib/components/CallControlPanel/CallControlPanel.styles.js.map +1 -1
- package/lib/components/CallControlPanel/CallControlPanel.types.d.ts +1 -1
- 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/CallControlPanelIcon.d.ts +2 -2
- package/lib/components/CallControlPanel/CallControlPanelIcon.d.ts.map +1 -1
- package/lib/components/CallControlPanel/CallControlPanelIcon.js.map +1 -1
- package/lib/components/CallControlPanel/CallHandover/CallHandoverDialog.d.ts +1 -1
- package/lib/components/CallControlPanel/CallHandover/CallHandoverDialog.d.ts.map +1 -1
- package/lib/components/CallControlPanel/CallHandover/CallHandoverDialog.js.map +1 -1
- package/lib/components/CallControlPanel/CallHandover/CallHandoverForm.d.ts +4 -2
- package/lib/components/CallControlPanel/CallHandover/CallHandoverForm.d.ts.map +1 -1
- package/lib/components/CallControlPanel/CallHandover/CallHandoverForm.js.map +1 -1
- package/lib/components/CallControlPanel/ContactList/CalleePicker.d.ts +2 -2
- package/lib/components/CallControlPanel/ContactList/CalleePicker.d.ts.map +1 -1
- package/lib/components/CallControlPanel/ContactList/CalleePicker.js.map +1 -1
- package/lib/components/CallControlPanel/ContactList/ContactList.d.ts +2 -2
- package/lib/components/CallControlPanel/ContactList/ContactList.d.ts.map +1 -1
- package/lib/components/CallControlPanel/ContactList/ContactList.js.map +1 -1
- package/lib/components/CallControlPanel/ContactList/ContactList.types.d.ts +1 -1
- package/lib/components/CallControlPanel/ContactList/ContactList.types.d.ts.map +1 -1
- package/lib/components/CallControlPanel/ContactList/ContactList.types.js.map +1 -1
- package/lib/components/CallControlPanel/ExternalCTI.d.ts +4 -4
- package/lib/components/CallControlPanel/ExternalCTI.d.ts.map +1 -1
- package/lib/components/CallControlPanel/ExternalCTI.js.map +1 -1
- package/lib/components/CallControlPanel/FloatingPanel.d.ts +2 -2
- package/lib/components/CallControlPanel/FloatingPanel.d.ts.map +1 -1
- package/lib/components/CallControlPanel/FloatingPanel.js.map +1 -1
- package/lib/components/CallControlPanel/IncomingCall.d.ts +2 -2
- package/lib/components/CallControlPanel/IncomingCall.d.ts.map +1 -1
- package/lib/components/CallControlPanel/IncomingCall.js.map +1 -1
- package/lib/components/CallControlPanel/StopWatch.d.ts +1 -1
- package/lib/components/CallControlPanel/StopWatch.d.ts.map +1 -1
- package/lib/components/CallControlPanel/StopWatch.js.map +1 -1
- package/lib/components/DialPad/DialPad.d.ts +3 -3
- package/lib/components/DialPad/DialPad.d.ts.map +1 -1
- package/lib/components/DialPad/DialPad.js.map +1 -1
- package/lib/components/DialPad/DialPad.types.d.ts +1 -1
- package/lib/components/DialPad/DialPad.types.d.ts.map +1 -1
- package/lib/components/DialPad/DialPad.types.js.map +1 -1
- package/lib/components/DialPad/DialPadDialog.d.ts +1 -1
- package/lib/components/DialPad/DialPadDialog.d.ts.map +1 -1
- package/lib/components/DialPad/DialPadDialog.js.map +1 -1
- package/lib/components/DialPad/DialPadKeyboard.d.ts +2 -2
- package/lib/components/DialPad/DialPadKeyboard.d.ts.map +1 -1
- package/lib/components/DialPad/DialPadKeyboard.js.map +1 -1
- package/lib/components/DialPad/KeyboardNavigation.d.ts +1 -1
- package/lib/components/DialPad/KeyboardNavigation.d.ts.map +1 -1
- package/lib/components/DialPad/KeyboardNavigation.js.map +1 -1
- package/lib/components/DialPad/utils.d.ts +1 -1
- package/lib/components/DialPad/utils.d.ts.map +1 -1
- package/lib/components/DialPad/utils.js.map +1 -1
- package/lib/components/InteractionTimer/InteractionTimer.d.ts +3 -3
- package/lib/components/InteractionTimer/InteractionTimer.d.ts.map +1 -1
- package/lib/components/InteractionTimer/InteractionTimer.js +2 -2
- package/lib/components/InteractionTimer/InteractionTimer.js.map +1 -1
- package/lib/components/Picker/Picker.d.ts +3 -3
- package/lib/components/Picker/Picker.d.ts.map +1 -1
- package/lib/components/Picker/Picker.js +1 -1
- package/lib/components/Picker/Picker.js.map +1 -1
- package/lib/components/Picker/Picker.styles.d.ts +3 -1
- package/lib/components/Picker/Picker.styles.d.ts.map +1 -1
- package/lib/components/Picker/Picker.types.d.ts +3 -3
- package/lib/components/Picker/Picker.types.d.ts.map +1 -1
- package/lib/components/Picker/Picker.types.js.map +1 -1
- package/lib/components/TaskManager/ConversationAI.d.ts +3 -3
- package/lib/components/TaskManager/ConversationAI.d.ts.map +1 -1
- package/lib/components/TaskManager/ConversationAI.js.map +1 -1
- package/lib/components/TaskManager/Dialogue.d.ts +3 -3
- package/lib/components/TaskManager/Dialogue.d.ts.map +1 -1
- package/lib/components/TaskManager/Dialogue.js.map +1 -1
- package/lib/components/TaskManager/TaskManager.context.d.ts +1 -1
- package/lib/components/TaskManager/TaskManager.context.d.ts.map +1 -1
- package/lib/components/TaskManager/TaskManager.context.js.map +1 -1
- package/lib/components/TaskManager/TaskManager.d.ts +3 -3
- package/lib/components/TaskManager/TaskManager.d.ts.map +1 -1
- package/lib/components/TaskManager/TaskManager.js.map +1 -1
- package/lib/components/TaskManager/TaskManager.styles.d.ts +5 -5
- package/lib/components/TaskManager/TaskManager.styles.d.ts.map +1 -1
- package/lib/components/TaskManager/TaskManager.styles.js.map +1 -1
- package/lib/components/TaskManager/TaskManager.types.d.ts +3 -3
- 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 +3 -3
- package/lib/components/TaskManager/TaskManagerTabs.d.ts.map +1 -1
- package/lib/components/TaskManager/TaskManagerTabs.js.map +1 -1
- package/lib/components/TaskManager/TaskPicker.d.ts +4 -4
- package/lib/components/TaskManager/TaskPicker.d.ts.map +1 -1
- package/lib/components/TaskManager/TaskPicker.js.map +1 -1
- package/lib/components/TaskManager/TaskView.d.ts +3 -3
- package/lib/components/TaskManager/TaskView.d.ts.map +1 -1
- package/lib/components/TaskManager/TaskView.js.map +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/package.json +10 -20
- package/lib/components/InteractionNotification/CountdownButton.d.ts +0 -15
- package/lib/components/InteractionNotification/CountdownButton.d.ts.map +0 -1
- package/lib/components/InteractionNotification/CountdownButton.js +0 -42
- package/lib/components/InteractionNotification/CountdownButton.js.map +0 -1
- package/lib/components/InteractionNotification/InteractionNotification.d.ts +0 -35
- package/lib/components/InteractionNotification/InteractionNotification.d.ts.map +0 -1
- package/lib/components/InteractionNotification/InteractionNotification.js +0 -110
- package/lib/components/InteractionNotification/InteractionNotification.js.map +0 -1
- package/lib/components/InteractionNotification/index.d.ts +0 -2
- package/lib/components/InteractionNotification/index.d.ts.map +0 -1
- package/lib/components/InteractionNotification/index.js +0 -2
- package/lib/components/InteractionNotification/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pega/cosmos-react-cs",
|
|
3
|
-
"version": "5.0.0-dev.
|
|
3
|
+
"version": "5.0.0-dev.10.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
|
-
"url": "https://github.com/pegasystems/cosmos-react.git",
|
|
6
|
+
"url": "git+https://github.com/pegasystems/cosmos-react.git",
|
|
7
7
|
"directory": "packages/cosmos-cs"
|
|
8
8
|
},
|
|
9
9
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -12,33 +12,23 @@
|
|
|
12
12
|
"main": "lib/index.js",
|
|
13
13
|
"types": "lib/index.d.ts",
|
|
14
14
|
"files": [
|
|
15
|
-
"LICENSE",
|
|
16
|
-
"README.md",
|
|
17
15
|
"lib"
|
|
18
16
|
],
|
|
19
17
|
"scripts": {
|
|
20
|
-
"build": "tsc -b"
|
|
18
|
+
"build": "tsc -b tsconfig.build.json"
|
|
21
19
|
},
|
|
22
20
|
"dependencies": {
|
|
23
|
-
"@pega/cosmos-react-core": "5.0.0-dev.
|
|
24
|
-
"@pega/cosmos-react-dnd": "5.0.0-dev.
|
|
25
|
-
"@types/react": "^
|
|
26
|
-
"@types/react-dom": "^
|
|
21
|
+
"@pega/cosmos-react-core": "5.0.0-dev.10.0",
|
|
22
|
+
"@pega/cosmos-react-dnd": "5.0.0-dev.10.0",
|
|
23
|
+
"@types/react": "^17.0.62",
|
|
24
|
+
"@types/react-dom": "^17.0.20",
|
|
27
25
|
"@types/styled-components": "^5.1.26",
|
|
28
26
|
"polished": "^4.1.0",
|
|
29
|
-
"react": "^
|
|
30
|
-
"react-dom": "^
|
|
27
|
+
"react": "^17.0.0",
|
|
28
|
+
"react-dom": "^17.0.0",
|
|
31
29
|
"styled-components": "^5.2.0"
|
|
32
30
|
},
|
|
33
31
|
"devDependencies": {
|
|
34
|
-
"
|
|
35
|
-
"@storybook/addon-actions": "^7.0.24",
|
|
36
|
-
"@storybook/addon-storysource": "^7.0.24",
|
|
37
|
-
"@storybook/addon-toolbars": "^7.0.24",
|
|
38
|
-
"@storybook/react": "^7.0.24",
|
|
39
|
-
"@storybook/theming": "^7.0.24",
|
|
40
|
-
"@testing-library/react": "^12.1.3",
|
|
41
|
-
"@testing-library/user-event": "^13.5.0",
|
|
42
|
-
"typescript": "~5.0.2"
|
|
32
|
+
"typescript": "~5.2.2"
|
|
43
33
|
}
|
|
44
34
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { FunctionComponent, ReactNode } from 'react';
|
|
2
|
-
import { ButtonProps, ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
-
export interface CountdownButtonProps extends ButtonProps {
|
|
4
|
-
/** Text or content for the Button. */
|
|
5
|
-
children: ReactNode;
|
|
6
|
-
/** Start time of incoming Interaction. */
|
|
7
|
-
startTime: Date | number;
|
|
8
|
-
/** The time the user has to accept the call in seconds. */
|
|
9
|
-
timeout: number;
|
|
10
|
-
/** Callback invoked when timeout ends. */
|
|
11
|
-
onTimerEnd?: () => void;
|
|
12
|
-
}
|
|
13
|
-
declare const CountdownButton: FunctionComponent<CountdownButtonProps & ForwardProps>;
|
|
14
|
-
export default CountdownButton;
|
|
15
|
-
//# sourceMappingURL=CountdownButton.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CountdownButton.d.ts","sourceRoot":"","sources":["../../../src/components/InteractionNotification/CountdownButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAE,SAAS,EAA4B,MAAM,OAAO,CAAC;AAG3F,OAAO,EAOL,WAAW,EACX,YAAY,EACb,MAAM,yBAAyB,CAAC;AAIjC,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IACvD,sCAAsC;IACtC,QAAQ,EAAE,SAAS,CAAC;IACpB,0CAA0C;IAC1C,SAAS,EAAE,IAAI,GAAG,MAAM,CAAC;IACzB,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB;AAUD,QAAA,MAAM,eAAe,EAAE,iBAAiB,CAAC,oBAAoB,GAAG,YAAY,CAqD3E,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useEffect, useState } from 'react';
|
|
3
|
-
import styled, { css } from 'styled-components';
|
|
4
|
-
import { useI18n, Text, VisuallyHiddenText, useUID, Button, defaultThemeProp } from '@pega/cosmos-react-core';
|
|
5
|
-
import { formatDuration } from '../CallControlPanel/utils';
|
|
6
|
-
const StyledAcceptButton = styled(Button)(({ theme }) => css `
|
|
7
|
-
gap: ${theme.base.spacing};
|
|
8
|
-
`);
|
|
9
|
-
StyledAcceptButton.defaultProps = defaultThemeProp;
|
|
10
|
-
const CountdownButton = forwardRef(function CountdownButton({ startTime, timeout, onTimerEnd, children, ...restProps }, ref) {
|
|
11
|
-
const timeoutMs = timeout * 1000;
|
|
12
|
-
const start = Number(startTime);
|
|
13
|
-
const endTime = start + timeoutMs;
|
|
14
|
-
const [msRemaining, setMsRemaining] = useState(() => endTime - Date.now());
|
|
15
|
-
const secondsRemaining = Math.round(msRemaining / 1000);
|
|
16
|
-
const t = useI18n();
|
|
17
|
-
const descriptionId = useUID();
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
let timeoutId;
|
|
20
|
-
if (msRemaining > 0) {
|
|
21
|
-
timeoutId = window.setTimeout(() => {
|
|
22
|
-
setMsRemaining(endTime - Date.now());
|
|
23
|
-
}, 1000);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
onTimerEnd?.();
|
|
27
|
-
}
|
|
28
|
-
return () => clearTimeout(timeoutId);
|
|
29
|
-
},
|
|
30
|
-
// Omitting onTimerEnd as an effect trigger on purpose.
|
|
31
|
-
// An unstable function definition in the prop causes the effect to run more than necessary.
|
|
32
|
-
// The proper definition will be captured and used with any changes to msRemaining.
|
|
33
|
-
[msRemaining]);
|
|
34
|
-
const timer = msRemaining > 0 ? formatDuration(msRemaining) : '0:00';
|
|
35
|
-
return (_jsxs(_Fragment, { children: [_jsxs(StyledAcceptButton, { ...restProps, "aria-describedby": descriptionId, ref: ref, children: [children, _jsx(Text, { "aria-hidden": 'true', children: timer })] }), _jsx(VisuallyHiddenText, { "aria-hidden": 'true', id: descriptionId, children: msRemaining > 0
|
|
36
|
-
? t('interaction_time_remaining', [secondsRemaining], {
|
|
37
|
-
count: secondsRemaining
|
|
38
|
-
})
|
|
39
|
-
: t('interaction_time_expired') })] }));
|
|
40
|
-
});
|
|
41
|
-
export default CountdownButton;
|
|
42
|
-
//# sourceMappingURL=CountdownButton.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CountdownButton.js","sourceRoot":"","sources":["../../../src/components/InteractionNotification/CountdownButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAqC,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3F,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,OAAO,EACP,IAAI,EACJ,kBAAkB,EAClB,MAAM,EACN,MAAM,EACN,gBAAgB,EAGjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAa3D,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,CACvC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,GAAG,CAAA;WACT,KAAK,CAAC,I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AErE,OAAO,CACL,8BACE,MAAC,kBAAkB,OAAK,SAAS,sBAAoB,aAAa,EAAE,GAAG,EAAE,GAAG,aACzE,QAAQ,EACT,KAAC,IAAI,mBAAa,MAAM,YAAE,KAAK,GAAQ,IACpB,EACrB,KAAC,kBAAkB,mBAAa,MAAM,EAAC,EAAE,EAAE,aAAa,YACrD,WAAW,GAAG,CAAC;oBACd,CAAC,CAAC,CAAC,CAAC,4BAA4B,EAAE,CAAC,gBAAgB,CAAC,EAAE;wBAClD,KAAK,EAAE,gBAAgB;qBACxB,CAAC;oBACJ,CAAC,CAAC,CAAC,CAAC,0BAA0B,CAAC,GACd,IACpB,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, ReactNode, Ref, useEffect, useState } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n useI18n,\n Text,\n VisuallyHiddenText,\n useUID,\n Button,\n defaultThemeProp,\n ButtonProps,\n ForwardProps\n} from '@pega/cosmos-react-core';\n\nimport { formatDuration } from '../CallControlPanel/utils';\n\nexport interface CountdownButtonProps extends ButtonProps {\n /** Text or content for the Button. */\n children: ReactNode;\n /** Start time of incoming Interaction. */\n startTime: Date | number;\n /** The time the user has to accept the call in seconds. */\n timeout: number;\n /** Callback invoked when timeout ends. */\n onTimerEnd?: () => void;\n}\n\nconst StyledAcceptButton = styled(Button)(\n ({ theme }) => css`\n gap: ${theme.base.spacing};\n `\n);\n\nStyledAcceptButton.defaultProps = defaultThemeProp;\n\nconst CountdownButton: FunctionComponent<CountdownButtonProps & ForwardProps> = forwardRef(\n function CountdownButton(\n { startTime, timeout, onTimerEnd, children, ...restProps }: CountdownButtonProps & ForwardProps,\n ref: Ref<HTMLButtonElement>\n ) {\n const timeoutMs = timeout * 1000;\n const start = Number(startTime);\n const endTime = start + timeoutMs;\n const [msRemaining, setMsRemaining] = useState(() => endTime - Date.now());\n\n const secondsRemaining = Math.round(msRemaining / 1000);\n\n const t = useI18n();\n const descriptionId = useUID();\n\n useEffect(\n () => {\n let timeoutId: number;\n\n if (msRemaining > 0) {\n timeoutId = window.setTimeout(() => {\n setMsRemaining(endTime - Date.now());\n }, 1000);\n } else {\n onTimerEnd?.();\n }\n\n return () => clearTimeout(timeoutId);\n },\n // Omitting onTimerEnd as an effect trigger on purpose.\n // An unstable function definition in the prop causes the effect to run more than necessary.\n // The proper definition will be captured and used with any changes to msRemaining.\n [msRemaining]\n );\n\n const timer = msRemaining > 0 ? formatDuration(msRemaining) : '0:00';\n\n return (\n <>\n <StyledAcceptButton {...restProps} aria-describedby={descriptionId} ref={ref}>\n {children}\n <Text aria-hidden='true'>{timer}</Text>\n </StyledAcceptButton>\n <VisuallyHiddenText aria-hidden='true' id={descriptionId}>\n {msRemaining > 0\n ? t('interaction_time_remaining', [secondsRemaining], {\n count: secondsRemaining\n })\n : t('interaction_time_expired')}\n </VisuallyHiddenText>\n </>\n );\n }\n);\n\nexport default CountdownButton;\n"]}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { FunctionComponent, Ref } from 'react';
|
|
2
|
-
import { StatusProps, ForwardProps, FieldValueListProps, NoChildrenProp } from '@pega/cosmos-react-core';
|
|
3
|
-
import { CountdownButtonProps } from './CountdownButton';
|
|
4
|
-
export interface InteractionNotificationProps extends NoChildrenProp {
|
|
5
|
-
/** Ref to Component. */
|
|
6
|
-
ref?: Ref<HTMLDivElement>;
|
|
7
|
-
/** Name of the icon used in header. */
|
|
8
|
-
icon: string;
|
|
9
|
-
/** Interaction title. */
|
|
10
|
-
title: string;
|
|
11
|
-
/** Primary information of the notification. For example caller name . */
|
|
12
|
-
primaryText: string;
|
|
13
|
-
/** Secondary information of the notification. For example phone number of the caller */
|
|
14
|
-
secondaryText?: string;
|
|
15
|
-
/** Represents the current status of interaction. */
|
|
16
|
-
status: {
|
|
17
|
-
variant: StatusProps['variant'];
|
|
18
|
-
text: string;
|
|
19
|
-
};
|
|
20
|
-
/** Information structured as field values to be displayed below main section. */
|
|
21
|
-
fields?: FieldValueListProps['fields'];
|
|
22
|
-
/** Timeout definition */
|
|
23
|
-
incomingNotificationTimeout?: {
|
|
24
|
-
startTime: CountdownButtonProps['startTime'];
|
|
25
|
-
answerTimeout: CountdownButtonProps['timeout'];
|
|
26
|
-
onTimerEnd?: CountdownButtonProps['onTimerEnd'];
|
|
27
|
-
};
|
|
28
|
-
/** Callback when accept button is clicked. */
|
|
29
|
-
onAccept: () => void;
|
|
30
|
-
/** Callback when decline button is clicked. */
|
|
31
|
-
onDecline?: () => void;
|
|
32
|
-
}
|
|
33
|
-
declare const InteractionNotification: FunctionComponent<InteractionNotificationProps & ForwardProps>;
|
|
34
|
-
export default InteractionNotification;
|
|
35
|
-
//# sourceMappingURL=InteractionNotification.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InteractionNotification.d.ts","sourceRoot":"","sources":["../../../src/components/InteractionNotification/InteractionNotification.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAmB,GAAG,EAAqB,MAAM,OAAO,CAAC;AAG/F,OAAO,EAOL,WAAW,EACX,YAAY,EAOZ,mBAAmB,EAEnB,cAAc,EASf,MAAM,yBAAyB,CAAC;AAGjC,OAAwB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE1E,MAAM,WAAW,4BAA6B,SAAQ,cAAc;IAClE,wBAAwB;IACxB,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IAC1B,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,yEAAyE;IACzE,WAAW,EAAE,MAAM,CAAC;IACpB,wFAAwF;IACxF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,MAAM,EAAE;QAAE,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1D,iFAAiF;IACjF,MAAM,CAAC,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACvC,yBAAyB;IACzB,2BAA2B,CAAC,EAAE;QAC5B,SAAS,EAAE,oBAAoB,CAAC,WAAW,CAAC,CAAC;QAC7C,aAAa,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;QAC/C,UAAU,CAAC,EAAE,oBAAoB,CAAC,YAAY,CAAC,CAAC;KACjD,CAAC;IACF,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAgFD,QAAA,MAAM,uBAAuB,EAAE,iBAAiB,CAAC,4BAA4B,GAAG,YAAY,CAmGxF,CAAC;AAEL,eAAe,uBAAuB,CAAC"}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useEffect, useRef } from 'react';
|
|
3
|
-
import styled, { css } from 'styled-components';
|
|
4
|
-
import { Button, Card, CardContent, CardHeader, Status, Text, defaultThemeProp, Flex, StyledText, FieldValueList, StyledFieldValueList, useI18n, useDirection, Icon, StyledLabel, useLiveLog, registerAction, useShortcut, useConsolidatedRef, useEscape, CardFooter } from '@pega/cosmos-react-core';
|
|
5
|
-
import { StyledCardContent } from '@pega/cosmos-react-core/lib/components/Card/CardContent';
|
|
6
|
-
import CountdownButton from './CountdownButton';
|
|
7
|
-
const StyledInteractionNotification = styled(Card)(({ theme: { base } }) => {
|
|
8
|
-
const { rtl } = useDirection();
|
|
9
|
-
return css `
|
|
10
|
-
position: fixed;
|
|
11
|
-
inset-block-start: calc(2 * ${base.spacing});
|
|
12
|
-
inset-inline-end: calc(2 * ${base.spacing});
|
|
13
|
-
width: min(calc(100% - 2rem), ${base['content-width'].md});
|
|
14
|
-
max-height: calc(100vh - 2rem);
|
|
15
|
-
z-index: ${base['z-index'].modal};
|
|
16
|
-
color: ${base.colors.white};
|
|
17
|
-
animation: SlideIn calc(4 * ${base.animation.speed});
|
|
18
|
-
padding: calc(0.75 * ${base.spacing}) 0;
|
|
19
|
-
box-shadow: ${base.shadow.low};
|
|
20
|
-
|
|
21
|
-
&&& {
|
|
22
|
-
background-color: ${base.colors.slate['extra-dark']};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@keyframes SlideIn {
|
|
26
|
-
0% {
|
|
27
|
-
${rtl
|
|
28
|
-
? css `
|
|
29
|
-
transform: translateX(calc(-100% - 1rem));
|
|
30
|
-
`
|
|
31
|
-
: css `
|
|
32
|
-
transform: translateX(calc(100% + 1rem));
|
|
33
|
-
`}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
100% {
|
|
37
|
-
transform: translateX(0);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
${StyledCardContent} {
|
|
42
|
-
margin: calc(2 * ${base.spacing}) 0;
|
|
43
|
-
overflow: auto;
|
|
44
|
-
|
|
45
|
-
${StyledText} {
|
|
46
|
-
color: ${base.colors.white};
|
|
47
|
-
white-space: nowrap;
|
|
48
|
-
overflow: hidden;
|
|
49
|
-
text-overflow: ellipsis;
|
|
50
|
-
width: 100%;
|
|
51
|
-
text-align: center;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
${StyledFieldValueList} {
|
|
56
|
-
border-block-start: solid 0.0625rem ${base.palette['border-line']};
|
|
57
|
-
padding-block-start: calc(2 * ${base.spacing});
|
|
58
|
-
color: ${base.colors.white};
|
|
59
|
-
|
|
60
|
-
${StyledLabel} {
|
|
61
|
-
color: ${base.colors.white};
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
@media (min-width: calc(${base.breakpoints.md})) {
|
|
66
|
-
inset-block-start: calc(8 * ${base.spacing});
|
|
67
|
-
max-height: initial;
|
|
68
|
-
}
|
|
69
|
-
`;
|
|
70
|
-
});
|
|
71
|
-
StyledInteractionNotification.defaultProps = defaultThemeProp;
|
|
72
|
-
registerAction({
|
|
73
|
-
id: 'GoToIncomingInteraction',
|
|
74
|
-
defaultKeyBinding: 'Alt+Enter'
|
|
75
|
-
}, {
|
|
76
|
-
id: 'DismissIncomingInteraction',
|
|
77
|
-
defaultKeyBinding: 'Alt+Q'
|
|
78
|
-
});
|
|
79
|
-
const InteractionNotification = forwardRef(function InteractionNotification({ icon, title, primaryText, secondaryText, status, fields, incomingNotificationTimeout, onAccept, onDecline }, ref) {
|
|
80
|
-
const t = useI18n();
|
|
81
|
-
const { announceAssertive } = useLiveLog();
|
|
82
|
-
const containerRef = useConsolidatedRef(ref);
|
|
83
|
-
const returnRef = useRef();
|
|
84
|
-
const acceptButtonRef = useRef(null);
|
|
85
|
-
const { binding: goToBinding } = useShortcut('GoToIncomingInteraction', () => {
|
|
86
|
-
if (containerRef.current) {
|
|
87
|
-
returnRef.current = document.activeElement ?? undefined;
|
|
88
|
-
acceptButtonRef.current?.focus();
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
const { binding: dismissBinding } = useShortcut('DismissIncomingInteraction', () => {
|
|
92
|
-
onDecline?.();
|
|
93
|
-
});
|
|
94
|
-
useEscape(() => {
|
|
95
|
-
returnRef.current?.focus();
|
|
96
|
-
onDecline?.();
|
|
97
|
-
}, containerRef.current, [onDecline]);
|
|
98
|
-
useEffect(() => {
|
|
99
|
-
announceAssertive({
|
|
100
|
-
message: `${title} ${primaryText} ${t('status')} ${status.text}. ${goToBinding ? t('interaction_shortcut_goto_info', [goToBinding]) : ''}${dismissBinding && onDecline
|
|
101
|
-
? t('interaction_shortcut_dismiss_info', [dismissBinding])
|
|
102
|
-
: ''}`,
|
|
103
|
-
type: 'alert'
|
|
104
|
-
});
|
|
105
|
-
}, []);
|
|
106
|
-
const acceptButton = incomingNotificationTimeout ? (_jsx(CountdownButton, { variant: 'primary', onClick: onAccept, startTime: incomingNotificationTimeout.startTime, timeout: incomingNotificationTimeout.answerTimeout, onTimerEnd: incomingNotificationTimeout.onTimerEnd ?? onDecline, ref: acceptButtonRef, children: t('accept') })) : (_jsx(Button, { variant: 'primary', onClick: onAccept, ref: acceptButtonRef, children: t('accept') }));
|
|
107
|
-
return (_jsxs(StyledInteractionNotification, { ref: containerRef, "data-app-region": true, children: [_jsx(CardHeader, { children: _jsxs(Flex, { container: { alignItems: 'center', gap: 1 }, children: [_jsx(Icon, { name: icon }), _jsx(Text, { variant: 'h2', children: title })] }) }), _jsxs(CardContent, { container: { gap: 2 }, children: [_jsxs(Flex, { container: { direction: 'column', alignItems: 'center', gap: 1 }, children: [_jsx(Text, { variant: 'h1', as: 'span', children: primaryText }), secondaryText && (_jsx(Text, { variant: 'h5', as: 'span', children: secondaryText })), _jsx(Status, { variant: status.variant, children: status.text })] }), fields && fields.length !== 0 && _jsx(FieldValueList, { variant: 'inline', fields: fields })] }), _jsxs(CardFooter, { justify: onDecline ? 'between' : 'end', children: [onDecline && _jsx(Button, { onClick: onDecline, children: t('decline') }), acceptButton] })] }));
|
|
108
|
-
});
|
|
109
|
-
export default InteractionNotification;
|
|
110
|
-
//# sourceMappingURL=InteractionNotification.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InteractionNotification.js","sourceRoot":"","sources":["../../../src/components/InteractionNotification/InteractionNotification.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA2C,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/F,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,IAAI,EACJ,WAAW,EACX,UAAU,EACV,MAAM,EACN,IAAI,EAGJ,gBAAgB,EAChB,IAAI,EACJ,UAAU,EACV,cAAc,EACd,oBAAoB,EACpB,OAAO,EAEP,YAAY,EAEZ,IAAI,EACJ,WAAW,EACX,UAAU,EACV,cAAc,EACd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S,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,aACpE,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,EAAC,EAAE,EAAC,MAAM,YACzB,WAAW,GACP,EACN,aAAa,IAAI,CAChB,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,EAAC,EAAE,EAAC,MAAM,YACzB,aAAa,GACT,CACR,EACD,KAAC,MAAM,IAAC,OAAO,EAAE,MAAM,CAAC,OAAO,YAAG,MAAM,CAAC,IAAI,GAAU,IAClD,EACN,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,KAAC,cAAc,IAAC,OAAO,EAAC,QAAQ,EAAC,MAAM,EAAE,MAAM,GAAI,IACzE,EAEd,MAAC,UAAU,IAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,aAC/C,SAAS,IAAI,KAAC,MAAM,IAAC,OAAO,EAAE,SAAS,YAAG,CAAC,CAAC,SAAS,CAAC,GAAU,EAChE,YAAY,IACF,IACiB,CACjC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEL,eAAe,uBAAuB,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, Ref, useEffect, useRef } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Button,\n Card,\n CardContent,\n CardHeader,\n Status,\n Text,\n StatusProps,\n ForwardProps,\n defaultThemeProp,\n Flex,\n StyledText,\n FieldValueList,\n StyledFieldValueList,\n useI18n,\n FieldValueListProps,\n useDirection,\n NoChildrenProp,\n Icon,\n StyledLabel,\n useLiveLog,\n registerAction,\n useShortcut,\n useConsolidatedRef,\n useEscape,\n CardFooter\n} from '@pega/cosmos-react-core';\nimport { StyledCardContent } from '@pega/cosmos-react-core/lib/components/Card/CardContent';\n\nimport CountdownButton, { CountdownButtonProps } from './CountdownButton';\n\nexport interface InteractionNotificationProps extends NoChildrenProp {\n /** Ref to Component. */\n ref?: Ref<HTMLDivElement>;\n /** Name of the icon used in header. */\n icon: string;\n /** Interaction title. */\n title: string;\n /** Primary information of the notification. For example caller name . */\n primaryText: string;\n /** Secondary information of the notification. For example phone number of the caller */\n secondaryText?: string;\n /** Represents the current status of interaction. */\n status: { variant: StatusProps['variant']; text: string };\n /** Information structured as field values to be displayed below main section. */\n fields?: FieldValueListProps['fields'];\n /** Timeout definition */\n incomingNotificationTimeout?: {\n startTime: CountdownButtonProps['startTime'];\n answerTimeout: CountdownButtonProps['timeout'];\n onTimerEnd?: CountdownButtonProps['onTimerEnd'];\n };\n /** Callback when accept button is clicked. */\n onAccept: () => void;\n /** Callback when decline button is clicked. */\n onDecline?: () => void;\n}\n\nconst StyledInteractionNotification = styled(Card)(({ theme: { base } }) => {\n const { rtl } = useDirection();\n return css`\n position: fixed;\n inset-block-start: calc(2 * ${base.spacing});\n inset-inline-end: calc(2 * ${base.spacing});\n width: min(calc(100% - 2rem), ${base['content-width'].md});\n max-height: calc(100vh - 2rem);\n z-index: ${base['z-index'].modal};\n color: ${base.colors.white};\n animation: SlideIn calc(4 * ${base.animation.speed});\n padding: calc(0.75 * ${base.spacing}) 0;\n box-shadow: ${base.shadow.low};\n\n &&& {\n background-color: ${base.colors.slate['extra-dark']};\n }\n\n @keyframes SlideIn {\n 0% {\n ${rtl\n ? css`\n transform: translateX(calc(-100% - 1rem));\n `\n : css`\n transform: translateX(calc(100% + 1rem));\n `}\n }\n\n 100% {\n transform: translateX(0);\n }\n }\n\n ${StyledCardContent} {\n margin: calc(2 * ${base.spacing}) 0;\n overflow: auto;\n\n ${StyledText} {\n color: ${base.colors.white};\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n width: 100%;\n text-align: center;\n }\n }\n\n ${StyledFieldValueList} {\n border-block-start: solid 0.0625rem ${base.palette['border-line']};\n padding-block-start: calc(2 * ${base.spacing});\n color: ${base.colors.white};\n\n ${StyledLabel} {\n color: ${base.colors.white};\n }\n }\n\n @media (min-width: calc(${base.breakpoints.md})) {\n inset-block-start: calc(8 * ${base.spacing});\n max-height: initial;\n }\n `;\n});\n\nStyledInteractionNotification.defaultProps = defaultThemeProp;\n\nregisterAction(\n {\n id: 'GoToIncomingInteraction',\n defaultKeyBinding: 'Alt+Enter'\n },\n {\n id: 'DismissIncomingInteraction',\n defaultKeyBinding: 'Alt+Q'\n }\n);\n\nconst InteractionNotification: FunctionComponent<InteractionNotificationProps & ForwardProps> =\n forwardRef(function InteractionNotification(\n {\n icon,\n title,\n primaryText,\n secondaryText,\n status,\n fields,\n incomingNotificationTimeout,\n onAccept,\n onDecline\n }: PropsWithoutRef<InteractionNotificationProps>,\n ref: InteractionNotificationProps['ref']\n ) {\n const t = useI18n();\n const { announceAssertive } = useLiveLog();\n const containerRef = useConsolidatedRef(ref);\n const returnRef = useRef<HTMLElement>();\n const acceptButtonRef = useRef<HTMLButtonElement>(null);\n\n const { binding: goToBinding } = useShortcut('GoToIncomingInteraction', () => {\n if (containerRef.current) {\n returnRef.current = (document.activeElement as HTMLElement) ?? undefined;\n acceptButtonRef.current?.focus();\n }\n });\n const { binding: dismissBinding } = useShortcut('DismissIncomingInteraction', () => {\n onDecline?.();\n });\n\n useEscape(\n () => {\n returnRef.current?.focus();\n onDecline?.();\n },\n containerRef.current,\n [onDecline]\n );\n\n useEffect(() => {\n announceAssertive({\n message: `${title} ${primaryText} ${t('status')} ${status.text}. ${\n goToBinding ? t('interaction_shortcut_goto_info', [goToBinding]) : ''\n }${\n dismissBinding && onDecline\n ? t('interaction_shortcut_dismiss_info', [dismissBinding])\n : ''\n }`,\n type: 'alert'\n });\n }, []);\n\n const acceptButton = incomingNotificationTimeout ? (\n <CountdownButton\n variant='primary'\n onClick={onAccept}\n startTime={incomingNotificationTimeout.startTime}\n timeout={incomingNotificationTimeout.answerTimeout}\n onTimerEnd={incomingNotificationTimeout.onTimerEnd ?? onDecline}\n ref={acceptButtonRef}\n >\n {t('accept')}\n </CountdownButton>\n ) : (\n <Button variant='primary' onClick={onAccept} ref={acceptButtonRef}>\n {t('accept')}\n </Button>\n );\n\n return (\n <StyledInteractionNotification ref={containerRef} data-app-region>\n <CardHeader>\n <Flex container={{ alignItems: 'center', gap: 1 }}>\n <Icon name={icon} />\n <Text variant='h2'>{title}</Text>\n </Flex>\n </CardHeader>\n <CardContent container={{ gap: 2 }}>\n <Flex container={{ direction: 'column', alignItems: 'center', gap: 1 }}>\n <Text variant='h1' as='span'>\n {primaryText}\n </Text>\n {secondaryText && (\n <Text variant='h5' as='span'>\n {secondaryText}\n </Text>\n )}\n <Status variant={status.variant}>{status.text}</Status>\n </Flex>\n {fields && fields.length !== 0 && <FieldValueList variant='inline' fields={fields} />}\n </CardContent>\n\n <CardFooter justify={onDecline ? 'between' : 'end'}>\n {onDecline && <Button onClick={onDecline}>{t('decline')}</Button>}\n {acceptButton}\n </CardFooter>\n </StyledInteractionNotification>\n );\n });\n\nexport default InteractionNotification;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/InteractionNotification/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/InteractionNotification/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC","sourcesContent":["export { default } from './InteractionNotification';\n"]}
|