@pega/cosmos-react-cs 2.0.0-dev.2.0 → 2.0.0-dev.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/lib/components/Article/Article.d.ts.map +1 -1
  2. package/lib/components/Article/Article.js +4 -19
  3. package/lib/components/Article/Article.js.map +1 -1
  4. package/lib/components/Article/ArticleFooter.d.ts.map +1 -1
  5. package/lib/components/Article/ArticleFooter.js +6 -7
  6. package/lib/components/Article/ArticleFooter.js.map +1 -1
  7. package/lib/components/Article/ArticleSkeleton.d.ts.map +1 -1
  8. package/lib/components/Article/ArticleSkeleton.js +7 -8
  9. package/lib/components/Article/ArticleSkeleton.js.map +1 -1
  10. package/lib/components/ArticleList/ArticleList.d.ts.map +1 -1
  11. package/lib/components/ArticleList/ArticleList.js +6 -10
  12. package/lib/components/ArticleList/ArticleList.js.map +1 -1
  13. package/lib/components/ArticleList/ArticleListHeader.d.ts +4 -1
  14. package/lib/components/ArticleList/ArticleListHeader.d.ts.map +1 -1
  15. package/lib/components/ArticleList/ArticleListHeader.js +43 -34
  16. package/lib/components/ArticleList/ArticleListHeader.js.map +1 -1
  17. package/lib/components/ArticleList/ArticleSummary.d.ts.map +1 -1
  18. package/lib/components/ArticleList/ArticleSummary.js +10 -7
  19. package/lib/components/ArticleList/ArticleSummary.js.map +1 -1
  20. package/lib/components/ArticleList/SummarySkeleton.d.ts.map +1 -1
  21. package/lib/components/ArticleList/SummarySkeleton.js +3 -11
  22. package/lib/components/ArticleList/SummarySkeleton.js.map +1 -1
  23. package/lib/components/CSCaseView/CSCaseView.d.ts +9 -0
  24. package/lib/components/CSCaseView/CSCaseView.d.ts.map +1 -0
  25. package/lib/components/CSCaseView/CSCaseView.js +16 -0
  26. package/lib/components/CSCaseView/CSCaseView.js.map +1 -0
  27. package/lib/components/CSCaseView/index.d.ts +3 -0
  28. package/lib/components/CSCaseView/index.d.ts.map +1 -0
  29. package/lib/components/CSCaseView/index.js +2 -0
  30. package/lib/components/CSCaseView/index.js.map +1 -0
  31. package/lib/components/CallControlPanel/Call.d.ts +6 -0
  32. package/lib/components/CallControlPanel/Call.d.ts.map +1 -0
  33. package/lib/components/CallControlPanel/Call.js +145 -0
  34. package/lib/components/CallControlPanel/Call.js.map +1 -0
  35. package/lib/components/CallControlPanel/CallControlPanel.d.ts +6 -0
  36. package/lib/components/CallControlPanel/CallControlPanel.d.ts.map +1 -0
  37. package/lib/components/CallControlPanel/CallControlPanel.js +68 -0
  38. package/lib/components/CallControlPanel/CallControlPanel.js.map +1 -0
  39. package/lib/components/CallControlPanel/CallControlPanel.styles.d.ts +15 -0
  40. package/lib/components/CallControlPanel/CallControlPanel.styles.d.ts.map +1 -0
  41. package/lib/components/CallControlPanel/CallControlPanel.styles.js +118 -0
  42. package/lib/components/CallControlPanel/CallControlPanel.styles.js.map +1 -0
  43. package/lib/components/CallControlPanel/CallControlPanel.types.d.ts +112 -0
  44. package/lib/components/CallControlPanel/CallControlPanel.types.d.ts.map +1 -0
  45. package/lib/components/CallControlPanel/CallControlPanel.types.js +2 -0
  46. package/lib/components/CallControlPanel/CallControlPanel.types.js.map +1 -0
  47. package/lib/components/CallControlPanel/CallControlPanelIcon.d.ts +19 -0
  48. package/lib/components/CallControlPanel/CallControlPanelIcon.d.ts.map +1 -0
  49. package/lib/components/CallControlPanel/CallControlPanelIcon.js +74 -0
  50. package/lib/components/CallControlPanel/CallControlPanelIcon.js.map +1 -0
  51. package/lib/components/CallControlPanel/CallTransfer.d.ts +19 -0
  52. package/lib/components/CallControlPanel/CallTransfer.d.ts.map +1 -0
  53. package/lib/components/CallControlPanel/CallTransfer.js +121 -0
  54. package/lib/components/CallControlPanel/CallTransfer.js.map +1 -0
  55. package/lib/components/CallControlPanel/CalleePicker.d.ts +20 -0
  56. package/lib/components/CallControlPanel/CalleePicker.d.ts.map +1 -0
  57. package/lib/components/CallControlPanel/CalleePicker.js +61 -0
  58. package/lib/components/CallControlPanel/CalleePicker.js.map +1 -0
  59. package/lib/components/CallControlPanel/ContactsList.d.ts +23 -0
  60. package/lib/components/CallControlPanel/ContactsList.d.ts.map +1 -0
  61. package/lib/components/CallControlPanel/ContactsList.js +88 -0
  62. package/lib/components/CallControlPanel/ContactsList.js.map +1 -0
  63. package/lib/components/CallControlPanel/DTMFKeypad.d.ts +11 -0
  64. package/lib/components/CallControlPanel/DTMFKeypad.d.ts.map +1 -0
  65. package/lib/components/CallControlPanel/DTMFKeypad.js +23 -0
  66. package/lib/components/CallControlPanel/DTMFKeypad.js.map +1 -0
  67. package/lib/components/CallControlPanel/StopWatch.d.ts +9 -0
  68. package/lib/components/CallControlPanel/StopWatch.d.ts.map +1 -0
  69. package/lib/components/CallControlPanel/StopWatch.js +28 -0
  70. package/lib/components/CallControlPanel/StopWatch.js.map +1 -0
  71. package/lib/components/CallControlPanel/index.d.ts +4 -0
  72. package/lib/components/CallControlPanel/index.d.ts.map +1 -0
  73. package/lib/components/CallControlPanel/index.js +3 -0
  74. package/lib/components/CallControlPanel/index.js.map +1 -0
  75. package/lib/components/CallControlPanel/utils.d.ts +7 -0
  76. package/lib/components/CallControlPanel/utils.d.ts.map +1 -0
  77. package/lib/components/CallControlPanel/utils.js +35 -0
  78. package/lib/components/CallControlPanel/utils.js.map +1 -0
  79. package/lib/components/DialPad/DialPad.d.ts +16 -0
  80. package/lib/components/DialPad/DialPad.d.ts.map +1 -0
  81. package/lib/components/DialPad/DialPad.js +33 -0
  82. package/lib/components/DialPad/DialPad.js.map +1 -0
  83. package/lib/components/DialPad/DialPad.types.d.ts +33 -0
  84. package/lib/components/DialPad/DialPad.types.d.ts.map +1 -0
  85. package/lib/components/DialPad/DialPad.types.js +2 -0
  86. package/lib/components/DialPad/DialPad.types.js.map +1 -0
  87. package/lib/components/DialPad/DialPadKeyboard.d.ts +12 -0
  88. package/lib/components/DialPad/DialPadKeyboard.d.ts.map +1 -0
  89. package/lib/components/DialPad/DialPadKeyboard.js +87 -0
  90. package/lib/components/DialPad/DialPadKeyboard.js.map +1 -0
  91. package/lib/components/DialPad/DialPadKeyboard.styles.d.ts +5 -0
  92. package/lib/components/DialPad/DialPadKeyboard.styles.d.ts.map +1 -0
  93. package/lib/components/DialPad/DialPadKeyboard.styles.js +76 -0
  94. package/lib/components/DialPad/DialPadKeyboard.styles.js.map +1 -0
  95. package/lib/components/DialPad/KeyboardNavigation.d.ts +6 -0
  96. package/lib/components/DialPad/KeyboardNavigation.d.ts.map +1 -0
  97. package/lib/components/DialPad/KeyboardNavigation.js +156 -0
  98. package/lib/components/DialPad/KeyboardNavigation.js.map +1 -0
  99. package/lib/components/DialPad/utils.d.ts +4 -0
  100. package/lib/components/DialPad/utils.d.ts.map +1 -0
  101. package/lib/components/DialPad/utils.js +7 -0
  102. package/lib/components/DialPad/utils.js.map +1 -0
  103. package/lib/components/IntelligentGuidance/IntelligentGuidance.d.ts +6 -0
  104. package/lib/components/IntelligentGuidance/IntelligentGuidance.d.ts.map +1 -0
  105. package/lib/components/IntelligentGuidance/IntelligentGuidance.js +75 -0
  106. package/lib/components/IntelligentGuidance/IntelligentGuidance.js.map +1 -0
  107. package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.d.ts +9 -0
  108. package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.d.ts.map +1 -0
  109. package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.js +142 -0
  110. package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.js.map +1 -0
  111. package/lib/components/IntelligentGuidance/IntelligentGuidance.types.d.ts +31 -0
  112. package/lib/components/IntelligentGuidance/IntelligentGuidance.types.d.ts.map +1 -0
  113. package/lib/components/IntelligentGuidance/IntelligentGuidance.types.js +2 -0
  114. package/lib/components/IntelligentGuidance/IntelligentGuidance.types.js.map +1 -0
  115. package/lib/components/IntelligentGuidance/index.d.ts +3 -0
  116. package/lib/components/IntelligentGuidance/index.d.ts.map +1 -0
  117. package/lib/components/IntelligentGuidance/index.js +2 -0
  118. package/lib/components/IntelligentGuidance/index.js.map +1 -0
  119. package/lib/components/InteractionNotification/InteractionNotification.d.ts.map +1 -1
  120. package/lib/components/InteractionNotification/InteractionNotification.js +19 -26
  121. package/lib/components/InteractionNotification/InteractionNotification.js.map +1 -1
  122. package/lib/components/InteractionTimer/InteractionTimer.d.ts +2 -4
  123. package/lib/components/InteractionTimer/InteractionTimer.d.ts.map +1 -1
  124. package/lib/components/InteractionTimer/InteractionTimer.js +14 -11
  125. package/lib/components/InteractionTimer/InteractionTimer.js.map +1 -1
  126. package/lib/components/TaskManager/Picker/Picker.d.ts.map +1 -1
  127. package/lib/components/TaskManager/Picker/Picker.js +138 -48
  128. package/lib/components/TaskManager/Picker/Picker.js.map +1 -1
  129. package/lib/components/TaskManager/Picker/Picker.types.d.ts +11 -2
  130. package/lib/components/TaskManager/Picker/Picker.types.d.ts.map +1 -1
  131. package/lib/components/TaskManager/Picker/Picker.types.js.map +1 -1
  132. package/lib/components/TaskManager/TaskManager.context.d.ts +1 -0
  133. package/lib/components/TaskManager/TaskManager.context.d.ts.map +1 -1
  134. package/lib/components/TaskManager/TaskManager.d.ts.map +1 -1
  135. package/lib/components/TaskManager/TaskManager.js +54 -83
  136. package/lib/components/TaskManager/TaskManager.js.map +1 -1
  137. package/lib/components/TaskManager/TaskManager.styles.d.ts +15 -20
  138. package/lib/components/TaskManager/TaskManager.styles.d.ts.map +1 -1
  139. package/lib/components/TaskManager/TaskManager.styles.js +173 -166
  140. package/lib/components/TaskManager/TaskManager.styles.js.map +1 -1
  141. package/lib/components/TaskManager/TaskManager.types.d.ts +12 -6
  142. package/lib/components/TaskManager/TaskManager.types.d.ts.map +1 -1
  143. package/lib/components/TaskManager/TaskManager.types.js.map +1 -1
  144. package/lib/components/TaskManager/TaskManagerTabs.d.ts +6 -0
  145. package/lib/components/TaskManager/TaskManagerTabs.d.ts.map +1 -0
  146. package/lib/components/TaskManager/TaskManagerTabs.js +159 -0
  147. package/lib/components/TaskManager/TaskManagerTabs.js.map +1 -0
  148. package/lib/components/TaskManager/TaskView.d.ts.map +1 -1
  149. package/lib/components/TaskManager/TaskView.js +3 -6
  150. package/lib/components/TaskManager/TaskView.js.map +1 -1
  151. package/lib/components/TaskManager/index.d.ts +1 -1
  152. package/lib/components/TaskManager/index.d.ts.map +1 -1
  153. package/lib/components/TaskManager/index.js.map +1 -1
  154. package/lib/index.d.ts +6 -0
  155. package/lib/index.d.ts.map +1 -1
  156. package/lib/index.js +6 -0
  157. package/lib/index.js.map +1 -1
  158. package/package.json +14 -14
  159. package/lib/components/TaskManager/TaskDrawer.d.ts +0 -6
  160. package/lib/components/TaskManager/TaskDrawer.d.ts.map +0 -1
  161. package/lib/components/TaskManager/TaskDrawer.js +0 -84
  162. package/lib/components/TaskManager/TaskDrawer.js.map +0 -1
@@ -0,0 +1,28 @@
1
+ import { jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { memo, useRef, useLayoutEffect } from 'react';
3
+ import styled from 'styled-components';
4
+ import { StyledText, Text } from '@pega/cosmos-react-core';
5
+ import { formatDuration } from './utils';
6
+ export const StyledStopWatch = styled(StyledText) `
7
+ min-width: 8ch;
8
+ text-align: end;
9
+ `;
10
+ const StopWatch = memo(({ startTime, timeout }) => {
11
+ const clockRef = useRef(null);
12
+ const millis = startTime instanceof Date ? startTime.getUTCMilliseconds() : startTime;
13
+ const timeoutMillis = timeout instanceof Date ? timeout.getUTCMilliseconds() : timeout;
14
+ useLayoutEffect(() => {
15
+ const timer = setInterval(() => {
16
+ if (clockRef.current) {
17
+ let content = formatDuration(Date.now() - millis);
18
+ if (timeoutMillis)
19
+ content += ` / ${formatDuration(timeoutMillis)}`;
20
+ clockRef.current.textContent = content;
21
+ }
22
+ }, 1000);
23
+ return () => clearInterval(timer);
24
+ }, [startTime, timeoutMillis]);
25
+ return (_jsxs(Text, { as: StyledStopWatch, ref: clockRef, children: [formatDuration(Date.now() - millis), timeoutMillis && ` / ${formatDuration(timeoutMillis)}`] }, void 0));
26
+ });
27
+ export default StopWatch;
28
+ //# sourceMappingURL=StopWatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StopWatch.js","sourceRoot":"","sources":["../../../src/components/CallControlPanel/StopWatch.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAOzC,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,UAAU,CAAC,CAAA;;;CAGhD,CAAC;AAEF,MAAM,SAAS,GAAsC,IAAI,CACvD,CAAC,EAAE,SAAS,EAAE,OAAO,EAAkB,EAAE,EAAE;IACzC,MAAM,QAAQ,GAAG,MAAM,CAAkB,IAAI,CAAC,CAAC;IAC/C,MAAM,MAAM,GAAG,SAAS,YAAY,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACtF,MAAM,aAAa,GAAG,OAAO,YAAY,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;IAEvF,eAAe,CAAC,GAAG,EAAE;QACnB,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;YAC7B,IAAI,QAAQ,CAAC,OAAO,EAAE;gBACpB,IAAI,OAAO,GAAG,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,CAAC;gBAClD,IAAI,aAAa;oBAAE,OAAO,IAAI,MAAM,cAAc,CAAC,aAAa,CAAC,EAAE,CAAC;gBACpE,QAAQ,CAAC,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC;aACxC;QACH,CAAC,EAAE,IAAI,CAAC,CAAC;QACT,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC;IAE/B,OAAO,CACL,MAAC,IAAI,IAAC,EAAE,EAAE,eAAe,EAAE,GAAG,EAAE,QAAQ,aACrC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,EACnC,aAAa,IAAI,MAAM,cAAc,CAAC,aAAa,CAAC,EAAE,YAClD,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import { FunctionComponent, memo, useRef, useLayoutEffect } from 'react';\nimport styled from 'styled-components';\n\nimport { StyledText, Text } from '@pega/cosmos-react-core';\n\nimport { formatDuration } from './utils';\n\ninterface StopWatchProps {\n startTime: number | Date;\n timeout?: number | Date;\n}\n\nexport const StyledStopWatch = styled(StyledText)`\n min-width: 8ch;\n text-align: end;\n`;\n\nconst StopWatch: FunctionComponent<StopWatchProps> = memo(\n ({ startTime, timeout }: StopWatchProps) => {\n const clockRef = useRef<HTMLSpanElement>(null);\n const millis = startTime instanceof Date ? startTime.getUTCMilliseconds() : startTime;\n const timeoutMillis = timeout instanceof Date ? timeout.getUTCMilliseconds() : timeout;\n\n useLayoutEffect(() => {\n const timer = setInterval(() => {\n if (clockRef.current) {\n let content = formatDuration(Date.now() - millis);\n if (timeoutMillis) content += ` / ${formatDuration(timeoutMillis)}`;\n clockRef.current.textContent = content;\n }\n }, 1000);\n return () => clearInterval(timer);\n }, [startTime, timeoutMillis]);\n\n return (\n <Text as={StyledStopWatch} ref={clockRef}>\n {formatDuration(Date.now() - millis)}\n {timeoutMillis && ` / ${formatDuration(timeoutMillis)}`}\n </Text>\n );\n }\n);\n\nexport default StopWatch;\n"]}
@@ -0,0 +1,4 @@
1
+ export { default } from './CallControlPanel';
2
+ export { CallControlPanelProps } from './CallControlPanel.types';
3
+ export { default as CallControlPanelIcon } from './CallControlPanelIcon';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/CallControlPanel/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { default } from './CallControlPanel';
2
+ export { default as CallControlPanelIcon } from './CallControlPanelIcon';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/CallControlPanel/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["export { default } from './CallControlPanel';\nexport { CallControlPanelProps } from './CallControlPanel.types';\nexport { default as CallControlPanelIcon } from './CallControlPanelIcon';\n"]}
@@ -0,0 +1,7 @@
1
+ export declare const formatDuration: (millis: number) => string;
2
+ export declare const calculateSla: (callDuration: number, slaConfig?: number[] | undefined) => {
3
+ slaTimeout?: number;
4
+ slaDuration?: number;
5
+ currentSlaLevel?: number;
6
+ };
7
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/CallControlPanel/utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,WAAY,MAAM,KAAG,MAG/C,CAAC;AAEF,eAAO,MAAM,YAAY,iBACT,MAAM,uCAEnB;IACD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CA6B1B,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { triple } from '@pega/cosmos-react-core';
2
+ export const formatDuration = (millis) => {
3
+ const seconds = Math.round(millis / 1000);
4
+ return `${Math.floor(seconds / 60)}:${(seconds % 60).toString().padStart(2, '0')}`;
5
+ };
6
+ export const calculateSla = (callDuration, slaConfig) => {
7
+ let slaLevel = 0;
8
+ let lastSlaTimeout = 0;
9
+ if (!slaConfig) {
10
+ return {
11
+ slaTimeout: undefined,
12
+ slaDuration: undefined,
13
+ currentSlaLevel: undefined
14
+ };
15
+ }
16
+ // eslint-disable-next-line no-restricted-syntax
17
+ for (const { prev: prevSlaTimeout = 0, current: slaTimeoutInSeconds } of triple(slaConfig)) {
18
+ const slaInMillis = slaTimeoutInSeconds * 1000;
19
+ if (callDuration < slaInMillis) {
20
+ return {
21
+ slaTimeout: slaInMillis,
22
+ slaDuration: slaTimeoutInSeconds - prevSlaTimeout,
23
+ currentSlaLevel: slaLevel
24
+ };
25
+ }
26
+ slaLevel += 1;
27
+ lastSlaTimeout = slaInMillis;
28
+ }
29
+ return {
30
+ slaTimeout: lastSlaTimeout,
31
+ slaDuration: 0,
32
+ currentSlaLevel: slaLevel
33
+ };
34
+ };
35
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/CallControlPanel/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAc,EAAU,EAAE;IACvD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC1C,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;AACrF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,YAAoB,EACpB,SAAoB,EAKpB,EAAE;IACF,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,IAAI,CAAC,SAAS,EAAE;QACd,OAAO;YACL,UAAU,EAAE,SAAS;YACrB,WAAW,EAAE,SAAS;YACtB,eAAe,EAAE,SAAS;SAC3B,CAAC;KACH;IACD,gDAAgD;IAChD,KAAK,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,CAAC,EAAE,OAAO,EAAE,mBAAmB,EAAE,IAAI,MAAM,CAAC,SAAS,CAAC,EAAE;QAC1F,MAAM,WAAW,GAAG,mBAAmB,GAAG,IAAI,CAAC;QAC/C,IAAI,YAAY,GAAG,WAAW,EAAE;YAC9B,OAAO;gBACL,UAAU,EAAE,WAAW;gBACvB,WAAW,EAAE,mBAAmB,GAAG,cAAc;gBACjD,eAAe,EAAE,QAAQ;aAC1B,CAAC;SACH;QACD,QAAQ,IAAI,CAAC,CAAC;QACd,cAAc,GAAG,WAAW,CAAC;KAC9B;IACD,OAAO;QACL,UAAU,EAAE,cAAc;QAC1B,WAAW,EAAE,CAAC;QACd,eAAe,EAAE,QAAQ;KAC1B,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { triple } from '@pega/cosmos-react-core';\n\nexport const formatDuration = (millis: number): string => {\n const seconds = Math.round(millis / 1000);\n return `${Math.floor(seconds / 60)}:${(seconds % 60).toString().padStart(2, '0')}`;\n};\n\nexport const calculateSla = (\n callDuration: number,\n slaConfig?: number[]\n): {\n slaTimeout?: number;\n slaDuration?: number;\n currentSlaLevel?: number;\n} => {\n let slaLevel = 0;\n let lastSlaTimeout = 0;\n if (!slaConfig) {\n return {\n slaTimeout: undefined,\n slaDuration: undefined,\n currentSlaLevel: undefined\n };\n }\n // eslint-disable-next-line no-restricted-syntax\n for (const { prev: prevSlaTimeout = 0, current: slaTimeoutInSeconds } of triple(slaConfig)) {\n const slaInMillis = slaTimeoutInSeconds * 1000;\n if (callDuration < slaInMillis) {\n return {\n slaTimeout: slaInMillis,\n slaDuration: slaTimeoutInSeconds - prevSlaTimeout,\n currentSlaLevel: slaLevel\n };\n }\n slaLevel += 1;\n lastSlaTimeout = slaInMillis;\n }\n return {\n slaTimeout: lastSlaTimeout,\n slaDuration: 0,\n currentSlaLevel: slaLevel\n };\n};\n"]}
@@ -0,0 +1,16 @@
1
+ import { FunctionComponent, Ref } from 'react';
2
+ import { ForwardProps, NoChildrenProp } from '@pega/cosmos-react-core';
3
+ import { DialPadKeyboardProps } from './DialPadKeyboard';
4
+ export interface DialPadProps extends NoChildrenProp {
5
+ /** Callback fired on call button click */
6
+ onCallButtonClick?: (phoneNumber: string) => void;
7
+ /** On keypad button press callback */
8
+ onDialButtonClick?: (charCode: number) => void;
9
+ /** Keypad mode, regular or DTMF. */
10
+ mode: DialPadKeyboardProps['mode'];
11
+ /** Ref for the wrapping element. */
12
+ ref?: Ref<HTMLDivElement>;
13
+ }
14
+ declare const DialPad: FunctionComponent<DialPadProps & ForwardProps>;
15
+ export default DialPad;
16
+ //# sourceMappingURL=DialPad.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialPad.d.ts","sourceRoot":"","sources":["../../../src/components/DialPad/DialPad.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAEjB,GAAG,EAGJ,MAAM,OAAO,CAAC;AAGf,OAAO,EACL,YAAY,EAQZ,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,OAAwB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE1E,MAAM,WAAW,YAAa,SAAQ,cAAc;IAClD,0CAA0C;IAC1C,iBAAiB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,sCAAsC;IACtC,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,oCAAoC;IACpC,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC,CAAC;IACnC,oCAAoC;IACpC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAiBD,QAAA,MAAM,OAAO,EAAE,iBAAiB,CAAC,YAAY,GAAG,YAAY,CA+C3D,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useCallback, useState } from 'react';
3
+ import styled, { css } from 'styled-components';
4
+ import { defaultThemeProp, Input, Button, useI18n, Flex, StyledIcon, StyledFlex } from '@pega/cosmos-react-core';
5
+ import DialPadKeyboard from './DialPadKeyboard';
6
+ const StyledDialPad = styled.div(({ theme: { base } }) => {
7
+ return css `
8
+ ${StyledFlex} {
9
+ margin: 0 auto ${base.spacing} auto;
10
+ padding: ${base.spacing} 0;
11
+ }
12
+
13
+ ${StyledFlex} ${StyledIcon} {
14
+ color: ${base.palette.interactive};
15
+ }
16
+ `;
17
+ });
18
+ StyledDialPad.defaultProps = defaultThemeProp;
19
+ const DialPad = forwardRef(({ onCallButtonClick, onDialButtonClick: onDialButtonClickProp, mode }, ref) => {
20
+ const t = useI18n();
21
+ const [number, setNumber] = useState('');
22
+ const onDialButtonClick = useCallback((charCode) => {
23
+ setNumber((prevNumber) => {
24
+ if (charCode === 127)
25
+ return prevNumber.slice(0, -1);
26
+ return prevNumber + String.fromCharCode(charCode);
27
+ });
28
+ onDialButtonClickProp?.(charCode);
29
+ }, [onDialButtonClickProp]);
30
+ return (_jsxs(StyledDialPad, { ref: ref, children: [_jsxs(Flex, { container: { alignItems: 'center', justify: 'center', itemGap: 1 }, children: [_jsx(Input, { value: number, onChange: (e) => setNumber(e.target.value), "aria-label": t('dial_pad_phone_number_input_label'), readOnly: mode === 'DTMF' }, void 0), mode !== 'DTMF' && (_jsx(Button, { variant: 'primary', onClick: () => onCallButtonClick?.(number), "aria-label": t('dial_pad_call_button_label', [number]), disabled: number.length === 0, children: t('dial_pad_call_button_label') }, void 0))] }, void 0), _jsx(DialPadKeyboard, { onDialButtonClick: onDialButtonClick, mode: mode }, void 0)] }, void 0));
31
+ });
32
+ export default DialPad;
33
+ //# sourceMappingURL=DialPad.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialPad.js","sourceRoot":"","sources":["../../../src/components/DialPad/DialPad.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,UAAU,EAIV,WAAW,EACX,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAEL,gBAAgB,EAChB,KAAK,EACL,MAAM,EACN,OAAO,EACP,IAAI,EACJ,UAAU,EACV,UAAU,EAEX,MAAM,yBAAyB,CAAC;AAEjC,OAAO,eAAyC,MAAM,mBAAmB,CAAC;AAa1E,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE;IACvD,OAAO,GAAG,CAAA;MACN,UAAU;uBACO,IAAI,CAAC,OAAO;iBAClB,IAAI,CAAC,OAAO;;;MAGvB,UAAU,IAAI,UAAU;eACf,IAAI,CAAC,OAAO,CAAC,WAAW;;GAEpC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,aAAa,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE9C,MAAM,OAAO,GAAmD,UAAU,CACxE,CACE,EACE,iBAAiB,EACjB,iBAAiB,EAAE,qBAAqB,EACxC,IAAI,EAC0B,EAChC,GAAwB,EACxB,EAAE;IACF,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAEzC,MAAM,iBAAiB,GAAG,WAAW,CACnC,CAAC,QAAgB,EAAE,EAAE;QACnB,SA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n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n ForwardProps,\n defaultThemeProp,\n Input,\n Button,\n useI18n,\n Flex,\n StyledIcon,\n StyledFlex,\n NoChildrenProp\n} from '@pega/cosmos-react-core';\n\nimport DialPadKeyboard, { DialPadKeyboardProps } from './DialPadKeyboard';\n\nexport interface DialPadProps extends NoChildrenProp {\n /** Callback fired on call button click */\n onCallButtonClick?: (phoneNumber: string) => void;\n /** On keypad button press callback */\n onDialButtonClick?: (charCode: number) => void;\n /** Keypad mode, regular or DTMF. */\n mode: DialPadKeyboardProps['mode'];\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nconst StyledDialPad = styled.div(({ theme: { base } }) => {\n return css`\n ${StyledFlex} {\n margin: 0 auto ${base.spacing} auto;\n padding: ${base.spacing} 0;\n }\n\n ${StyledFlex} ${StyledIcon} {\n color: ${base.palette.interactive};\n }\n `;\n});\n\nStyledDialPad.defaultProps = defaultThemeProp;\n\nconst DialPad: FunctionComponent<DialPadProps & ForwardProps> = forwardRef(\n (\n {\n onCallButtonClick,\n onDialButtonClick: onDialButtonClickProp,\n mode\n }: PropsWithoutRef<DialPadProps>,\n ref: Ref<HTMLDivElement>\n ) => {\n const t = useI18n();\n const [number, setNumber] = useState('');\n\n const onDialButtonClick = useCallback(\n (charCode: number) => {\n setNumber((prevNumber: string) => {\n if (charCode === 127) return prevNumber.slice(0, -1);\n return prevNumber + String.fromCharCode(charCode);\n });\n onDialButtonClickProp?.(charCode);\n },\n [onDialButtonClickProp]\n );\n\n return (\n <StyledDialPad ref={ref}>\n <Flex container={{ alignItems: 'center', justify: 'center', itemGap: 1 }}>\n <Input\n value={number}\n onChange={(e: ChangeEvent<HTMLInputElement>) => setNumber(e.target.value)}\n aria-label={t('dial_pad_phone_number_input_label')}\n readOnly={mode === 'DTMF'}\n />\n {mode !== 'DTMF' && (\n <Button\n variant='primary'\n onClick={() => onCallButtonClick?.(number)}\n aria-label={t('dial_pad_call_button_label', [number])}\n disabled={number.length === 0}\n >\n {t('dial_pad_call_button_label')}\n </Button>\n )}\n </Flex>\n <DialPadKeyboard onDialButtonClick={onDialButtonClick} mode={mode} />\n </StyledDialPad>\n );\n }\n);\n\nexport default DialPad;\n"]}
@@ -0,0 +1,33 @@
1
+ import { RefObject } from 'react';
2
+ export interface DialButton {
3
+ id: number;
4
+ digit?: number;
5
+ subdigit?: string;
6
+ special?: string;
7
+ icon?: string;
8
+ }
9
+ export interface DialButtonRow {
10
+ rowId: number;
11
+ dialButtons: DialButton[];
12
+ }
13
+ export declare type KeyDownNavigateOptions = {
14
+ [key: string]: (previousId: number) => number;
15
+ };
16
+ export declare type KeyDownDialButtonOptions = {
17
+ [key: string]: DialButton;
18
+ };
19
+ export declare type Index = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
20
+ export interface NavigationGraphElement {
21
+ sign?: string;
22
+ alt?: string;
23
+ special?: string;
24
+ keyCode: number;
25
+ altKeyCode?: number;
26
+ ref?: RefObject<HTMLButtonElement>;
27
+ icon?: string;
28
+ up?: Index;
29
+ left?: Index;
30
+ down?: Index;
31
+ right?: Index;
32
+ }
33
+ //# sourceMappingURL=DialPad.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialPad.types.d.ts","sourceRoot":"","sources":["../../../src/components/DialPad/DialPad.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B;AAED,oBAAY,sBAAsB,GAAG;IACnC,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC;CAC/C,CAAC;AAEF,oBAAY,wBAAwB,GAAG;IACrC,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;CAC3B,CAAC;AAEF,oBAAY,KAAK,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAEzE,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,SAAS,CAAC,iBAAiB,CAAC,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,KAAK,CAAC;IACX,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,KAAK,CAAC,EAAE,KAAK,CAAC;CACf"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=DialPad.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialPad.types.js","sourceRoot":"","sources":["../../../src/components/DialPad/DialPad.types.ts"],"names":[],"mappings":"","sourcesContent":["import { RefObject } from 'react';\n\nexport interface DialButton {\n id: number;\n digit?: number;\n subdigit?: string;\n special?: string;\n icon?: string;\n}\n\nexport interface DialButtonRow {\n rowId: number;\n dialButtons: DialButton[];\n}\n\nexport type KeyDownNavigateOptions = {\n [key: string]: (previousId: number) => number;\n};\n\nexport type KeyDownDialButtonOptions = {\n [key: string]: DialButton;\n};\n\nexport type Index = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;\n\nexport interface NavigationGraphElement {\n sign?: string;\n alt?: string;\n special?: string;\n keyCode: number;\n altKeyCode?: number;\n ref?: RefObject<HTMLButtonElement>;\n icon?: string;\n up?: Index;\n left?: Index;\n down?: Index;\n right?: Index;\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { ForwardProps } from '@pega/cosmos-react-core';
3
+ export declare type DialPadKeyboardMode = 'default' | 'DTMF';
4
+ export interface DialPadKeyboardProps {
5
+ /** Callback fired on dial button click */
6
+ onDialButtonClick: (charCode: number) => void;
7
+ /** Dial Pad Keyboard mode */
8
+ mode?: DialPadKeyboardMode;
9
+ }
10
+ declare const DialPadKeyboard: FunctionComponent<DialPadKeyboardProps & ForwardProps>;
11
+ export default DialPadKeyboard;
12
+ //# sourceMappingURL=DialPadKeyboard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialPadKeyboard.d.ts","sourceRoot":"","sources":["../../../src/components/DialPad/DialPadKeyboard.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAOlB,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,YAAY,EAA+B,MAAM,yBAAyB,CAAC;AAOpF,oBAAY,mBAAmB,GAAG,SAAS,GAAG,MAAM,CAAC;AAErD,MAAM,WAAW,oBAAoB;IACnC,0CAA0C;IAC1C,iBAAiB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,6BAA6B;IAC7B,IAAI,CAAC,EAAE,mBAAmB,CAAC;CAC5B;AAED,QAAA,MAAM,eAAe,EAAE,iBAAiB,CAAC,oBAAoB,GAAG,YAAY,CAgJ3E,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,87 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useRef, useCallback } from 'react';
3
+ import { Icon, useI18n, useLongPress } from '@pega/cosmos-react-core';
4
+ import { StyledDialButton, StyledDialPadKeyboard, StyledSpecial } from './DialPadKeyboard.styles';
5
+ import { dtmfGraph, defaultGraph, defaultButtonGrid, dtmfButtonGrid } from './KeyboardNavigation';
6
+ import { getDialButtonIndex, isNavigationEvent } from './utils';
7
+ const DialPadKeyboard = forwardRef(({ onDialButtonClick, mode = 'default' }, ref) => {
8
+ const buttonNavGraph = mode === 'DTMF' ? dtmfGraph : defaultGraph;
9
+ const buttonGrid = mode === 'DTMF' ? dtmfButtonGrid : defaultButtonGrid;
10
+ const t = useI18n();
11
+ const zeroButtonLongPress = useLongPress(() => onDialButtonClick(buttonNavGraph[10].altKeyCode || 43), () => onDialButtonClick(buttonNavGraph[10].keyCode));
12
+ // This is not a violation of the rules, as the array length is constant and order the always the same.
13
+ buttonNavGraph.forEach(element => {
14
+ // eslint-disable-next-line react-hooks/rules-of-hooks
15
+ element.ref = useRef(null);
16
+ });
17
+ const handleDialButtonEvent = (e, index) => {
18
+ e.preventDefault();
19
+ e.stopPropagation();
20
+ const buttonEl = buttonNavGraph[index];
21
+ if (!buttonEl || (mode === 'DTMF' && index === 12))
22
+ return;
23
+ buttonEl.ref?.current?.focus();
24
+ onDialButtonClick(buttonEl.keyCode);
25
+ };
26
+ const handlePlusDialButton = (e) => {
27
+ e.preventDefault();
28
+ e.stopPropagation();
29
+ const buttonEl = buttonNavGraph[10];
30
+ if (!buttonEl || !buttonEl.altKeyCode)
31
+ return;
32
+ buttonEl.ref?.current?.focus();
33
+ onDialButtonClick(buttonEl.altKeyCode);
34
+ };
35
+ const handleEnterEvent = useCallback((e) => {
36
+ if (e.key === 'Enter') {
37
+ e.preventDefault();
38
+ onDialButtonClick(Number(e.target.value));
39
+ }
40
+ }, [onDialButtonClick]);
41
+ const findButtonInGraph = (e) => {
42
+ return buttonNavGraph.find(el => el.keyCode === Number(e.target.value));
43
+ };
44
+ const getTargetIndexOnNavigationEvent = (btnEl, e) => {
45
+ return {
46
+ ArrowUp: btnEl.up,
47
+ ArrowLeft: btnEl.left,
48
+ ArrowDown: btnEl.down,
49
+ ArrowRight: btnEl.right
50
+ }[e.key];
51
+ };
52
+ const handleNavigationEvent = (e) => {
53
+ e.preventDefault();
54
+ const btnEl = findButtonInGraph(e);
55
+ if (!btnEl)
56
+ return;
57
+ const targetIndex = getTargetIndexOnNavigationEvent(btnEl, e);
58
+ if (targetIndex !== undefined)
59
+ buttonNavGraph[targetIndex].ref?.current?.focus();
60
+ };
61
+ const handleKeyboardNavigation = useCallback((e) => {
62
+ const index = getDialButtonIndex(e);
63
+ if (index !== -1) {
64
+ handleDialButtonEvent(e, index);
65
+ }
66
+ else if (e.key === '+') {
67
+ handlePlusDialButton(e);
68
+ }
69
+ else if (isNavigationEvent(e)) {
70
+ handleNavigationEvent(e);
71
+ }
72
+ }, [onDialButtonClick]);
73
+ return (_jsx(StyledDialPadKeyboard, { ref: ref, onKeyDown: handleKeyboardNavigation, dir: 'ltr', role: 'grid', "aria-label": t('dial_pad_keyboard'), container: {
74
+ cols: '1fr',
75
+ rowGap: 1,
76
+ justifyItems: 'center'
77
+ }, children: buttonGrid.map((row, index) => {
78
+ if (mode === 'default' || (mode === 'DTMF' && index < 4)) {
79
+ return (
80
+ // eslint-disable-next-line react/no-array-index-key
81
+ _jsx("div", { role: 'row', children: row.map((dialButton) => dialButton.alt === '+' ? (_jsxs(StyledDialButton, { role: 'gridcell', tabIndex: -1, ref: dialButton.ref, value: dialButton.keyCode, ...zeroButtonLongPress, children: [dialButton.sign && _jsx("span", { children: dialButton.sign }, void 0), dialButton.alt && _jsx("span", { children: dialButton.alt }, void 0)] }, dialButton.keyCode)) : (_jsxs(StyledDialButton, { role: 'gridcell', onClick: () => onDialButtonClick(dialButton.keyCode), onKeyDown: handleEnterEvent, tabIndex: dialButton.sign === '1' ? 0 : -1, "aria-label": dialButton.icon ? dialButton.icon : undefined, ref: dialButton.ref, value: dialButton.keyCode, children: [dialButton.sign && _jsx("span", { children: dialButton.sign }, void 0), dialButton.alt && _jsx("span", { children: dialButton.alt }, void 0), dialButton.special && _jsx(StyledSpecial, { children: dialButton.special }, void 0), dialButton.icon && _jsx(Icon, { name: dialButton.icon }, void 0)] }, dialButton.keyCode))) }, `row-${index}`));
82
+ }
83
+ return undefined;
84
+ }) }, void 0));
85
+ });
86
+ export default DialPadKeyboard;
87
+ //# sourceMappingURL=DialPadKeyboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialPadKeyboard.js","sourceRoot":"","sources":["../../../src/components/DialPad/DialPadKeyboard.tsx"],"names":[],"mappings":";AAAA,OAAO,EAKL,UAAU,EACV,MAAM,EACN,WAAW,EACZ,MAAM,OAAO,CAAC;AAEf,OAAO,EAAgB,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEpF,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAClG,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAElG,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAWhE,MAAM,eAAe,GAA2D,UAAU,CACxF,CACE,EAAE,iBAAiB,EAAE,IAAI,GAAG,SAAS,EAAyC,EAC9E,GAAqB,EACrB,EAAE;IACF,MAAM,cAAc,GAAG,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC;IAClE,MAAM,UAAU,GAAG,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,iBAAiB,CAAC;IAExE,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,MAAM,mBAAmB,GAAG,YAAY,CACtC,GAAG,EAAE,CAAC,iBAAiB,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,UAAU,IAAI,EAAE,CAAC,EA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,CAAC,OAAO,CAAC,EACpD,SAAS,EAAE,gBAAgB,EAC3B,QAAQ,EAAE,UAAU,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,gBAC9B,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EACzD,GAAG,EAAE,UAAU,CAAC,GAAG,EACnB,KAAK,EAAE,UAAU,CAAC,OAAO,aAExB,UAAU,CAAC,IAAI,IAAI,yBAAO,UAAU,CAAC,IAAI,WAAQ,EACjD,UAAU,CAAC,GAAG,IAAI,yBAAO,UAAU,CAAC,GAAG,WAAQ,EAC/C,UAAU,CAAC,OAAO,IAAI,KAAC,aAAa,cAAE,UAAU,CAAC,OAAO,WAAiB,EACzE,UAAU,CAAC,IAAI,IAAI,KAAC,IAAI,IAAC,IAAI,EAAE,UAAU,CAAC,IAAI,WAAI,KAZ9C,UAAU,CAAC,OAAO,CAaN,CACpB,CACF,IA/BkB,OAAO,KAAK,EAAE,CAgC7B,CACP,CAAC;aACH;YACD,OAAO,SAAS,CAAC;QACnB,CAAC,CAAC,WACoB,CACzB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import {\n FunctionComponent,\n PropsWithoutRef,\n Ref,\n KeyboardEvent,\n forwardRef,\n useRef,\n useCallback\n} from 'react';\n\nimport { ForwardProps, Icon, useI18n, useLongPress } from '@pega/cosmos-react-core';\n\nimport { StyledDialButton, StyledDialPadKeyboard, StyledSpecial } from './DialPadKeyboard.styles';\nimport { dtmfGraph, defaultGraph, defaultButtonGrid, dtmfButtonGrid } from './KeyboardNavigation';\nimport { Index, NavigationGraphElement } from './DialPad.types';\nimport { getDialButtonIndex, isNavigationEvent } from './utils';\n\nexport type DialPadKeyboardMode = 'default' | 'DTMF';\n\nexport interface DialPadKeyboardProps {\n /** Callback fired on dial button click */\n onDialButtonClick: (charCode: number) => void;\n /** Dial Pad Keyboard mode */\n mode?: DialPadKeyboardMode;\n}\n\nconst DialPadKeyboard: FunctionComponent<DialPadKeyboardProps & ForwardProps> = forwardRef(\n (\n { onDialButtonClick, mode = 'default' }: PropsWithoutRef<DialPadKeyboardProps>,\n ref: Ref<HTMLElement>\n ) => {\n const buttonNavGraph = mode === 'DTMF' ? dtmfGraph : defaultGraph;\n const buttonGrid = mode === 'DTMF' ? dtmfButtonGrid : defaultButtonGrid;\n\n const t = useI18n();\n const zeroButtonLongPress = useLongPress<HTMLButtonElement>(\n () => onDialButtonClick(buttonNavGraph[10].altKeyCode || 43),\n () => onDialButtonClick(buttonNavGraph[10].keyCode)\n );\n // This is not a violation of the rules, as the array length is constant and order the always the same.\n buttonNavGraph.forEach(element => {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n element.ref = useRef<HTMLButtonElement>(null);\n });\n\n const handleDialButtonEvent = (e: React.KeyboardEvent<HTMLButtonElement>, index: number) => {\n e.preventDefault();\n e.stopPropagation();\n const buttonEl = buttonNavGraph[index];\n if (!buttonEl || (mode === 'DTMF' && index === 12)) return;\n buttonEl.ref?.current?.focus();\n onDialButtonClick(buttonEl.keyCode);\n };\n\n const handlePlusDialButton = (e: React.KeyboardEvent<HTMLButtonElement>) => {\n e.preventDefault();\n e.stopPropagation();\n const buttonEl = buttonNavGraph[10];\n if (!buttonEl || !buttonEl.altKeyCode) return;\n buttonEl.ref?.current?.focus();\n onDialButtonClick(buttonEl.altKeyCode);\n };\n\n const handleEnterEvent = useCallback(\n (e: React.KeyboardEvent<HTMLButtonElement>) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n onDialButtonClick(Number((e.target as HTMLButtonElement).value));\n }\n },\n [onDialButtonClick]\n );\n\n const findButtonInGraph = (e: React.KeyboardEvent<HTMLElement>) => {\n return buttonNavGraph.find(\n el => el.keyCode === Number((e.target as HTMLButtonElement).value)\n );\n };\n\n const getTargetIndexOnNavigationEvent = (\n btnEl: NavigationGraphElement,\n e: React.KeyboardEvent<HTMLButtonElement>\n ): Index | undefined => {\n return {\n ArrowUp: btnEl.up,\n ArrowLeft: btnEl.left,\n ArrowDown: btnEl.down,\n ArrowRight: btnEl.right\n }[e.key];\n };\n\n const handleNavigationEvent = (e: React.KeyboardEvent<HTMLButtonElement>) => {\n e.preventDefault();\n const btnEl = findButtonInGraph(e);\n if (!btnEl) return;\n const targetIndex = getTargetIndexOnNavigationEvent(btnEl, e);\n if (targetIndex !== undefined) buttonNavGraph[targetIndex].ref?.current?.focus();\n };\n\n const handleKeyboardNavigation = useCallback(\n (e: KeyboardEvent<HTMLButtonElement>) => {\n const index = getDialButtonIndex(e);\n if (index !== -1) {\n handleDialButtonEvent(e, index);\n } else if (e.key === '+') {\n handlePlusDialButton(e);\n } else if (isNavigationEvent(e)) {\n handleNavigationEvent(e);\n }\n },\n [onDialButtonClick]\n );\n\n return (\n <StyledDialPadKeyboard\n ref={ref}\n onKeyDown={handleKeyboardNavigation}\n dir='ltr'\n role='grid'\n aria-label={t('dial_pad_keyboard')}\n container={{\n cols: '1fr',\n rowGap: 1,\n justifyItems: 'center'\n }}\n >\n {buttonGrid.map((row: NavigationGraphElement[], index: number) => {\n if (mode === 'default' || (mode === 'DTMF' && index < 4)) {\n return (\n // eslint-disable-next-line react/no-array-index-key\n <div role='row' key={`row-${index}`}>\n {row.map((dialButton: NavigationGraphElement) =>\n dialButton.alt === '+' ? (\n <StyledDialButton\n key={dialButton.keyCode}\n role='gridcell'\n tabIndex={-1}\n ref={dialButton.ref}\n value={dialButton.keyCode}\n {...zeroButtonLongPress}\n >\n {dialButton.sign && <span>{dialButton.sign}</span>}\n {dialButton.alt && <span>{dialButton.alt}</span>}\n </StyledDialButton>\n ) : (\n <StyledDialButton\n key={dialButton.keyCode}\n role='gridcell'\n onClick={() => onDialButtonClick(dialButton.keyCode)}\n onKeyDown={handleEnterEvent}\n tabIndex={dialButton.sign === '1' ? 0 : -1}\n aria-label={dialButton.icon ? dialButton.icon : undefined}\n ref={dialButton.ref}\n value={dialButton.keyCode}\n >\n {dialButton.sign && <span>{dialButton.sign}</span>}\n {dialButton.alt && <span>{dialButton.alt}</span>}\n {dialButton.special && <StyledSpecial>{dialButton.special}</StyledSpecial>}\n {dialButton.icon && <Icon name={dialButton.icon} />}\n </StyledDialButton>\n )\n )}\n </div>\n );\n }\n return undefined;\n })}\n </StyledDialPadKeyboard>\n );\n }\n);\n\nexport default DialPadKeyboard;\n"]}
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ export declare const StyledDialPadKeyboard: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").GridProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
3
+ export declare const StyledSpecial: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, {}, never>;
4
+ export declare const StyledDialButton: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, {}, never>;
5
+ //# sourceMappingURL=DialPadKeyboard.styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialPadKeyboard.styles.d.ts","sourceRoot":"","sources":["../../../src/components/DialPad/DialPadKeyboard.styles.ts"],"names":[],"mappings":";AAWA,eAAO,MAAM,qBAAqB,mOAYjC,CAAC;AAIF,eAAO,MAAM,aAAa,0GAAgB,CAAC;AAE3C,eAAO,MAAM,gBAAgB,4GAqE5B,CAAC"}
@@ -0,0 +1,76 @@
1
+ import { mix, readableColor } from 'polished';
2
+ import styled, { css } from 'styled-components';
3
+ import { calculateFontSize, defaultThemeProp, Grid, StyledIcon, tryCatch } from '@pega/cosmos-react-core';
4
+ export const StyledDialPadKeyboard = styled(Grid)(({ theme: { base: { spacing } } }) => {
5
+ return css `
6
+ max-width: calc(25 * ${spacing});
7
+ margin: auto;
8
+ padding: ${spacing};
9
+ `;
10
+ });
11
+ StyledDialPadKeyboard.defaultProps = defaultThemeProp;
12
+ export const StyledSpecial = styled.span ``;
13
+ export const StyledDialButton = styled.button(({ theme: { base, components: { button, input } } }) => {
14
+ const secondaryHoverColor = tryCatch(() => mix(0.85, button['secondary-color'], button.color));
15
+ const fontSize = calculateFontSize(base['font-size'], base['font-scale']);
16
+ const color = tryCatch(() => readableColor(button['secondary-color']));
17
+ return css `
18
+ background: transparent;
19
+ width: calc(7 * ${base.spacing});
20
+ height: calc(7 * ${base.spacing});
21
+ cursor: pointer;
22
+ color: ${color};
23
+ border: 0.0625rem solid ${input['border-color']};
24
+ border-radius: calc(${base['border-radius']} * ${button['border-radius']});
25
+ position: relative;
26
+ outline: none;
27
+ margin-inline-end: ${base.spacing};
28
+
29
+ &:last-child {
30
+ grid-column-end: 3;
31
+ margin-inline-end: 0;
32
+ }
33
+
34
+ &:hover {
35
+ background-color: ${secondaryHoverColor};
36
+ border-color: ${base.palette.dark};
37
+ text-decoration: none;
38
+ }
39
+
40
+ &:not([disabled]):focus,
41
+ &:enabled:focus {
42
+ box-shadow: 0 0 0.5rem ${base.palette.interactive};
43
+ }
44
+
45
+ ${StyledIcon} {
46
+ width: 1.5rem;
47
+ height: 1.5rem;
48
+ }
49
+
50
+ span {
51
+ font-size: ${fontSize.l};
52
+ transform: translateY(-125%);
53
+ line-height: 1;
54
+ position: absolute;
55
+ left: 0;
56
+ right: 0;
57
+ }
58
+
59
+ span,
60
+ ${StyledIcon} {
61
+ color: ${color};
62
+ }
63
+
64
+ span + span {
65
+ font-size: ${fontSize.xxs};
66
+ transform: translateY(-30%);
67
+ }
68
+
69
+ ${StyledSpecial} {
70
+ font-size: ${fontSize.l};
71
+ transform: translateY(-50%);
72
+ }
73
+ `;
74
+ });
75
+ StyledDialButton.defaultProps = defaultThemeProp;
76
+ //# sourceMappingURL=DialPadKeyboard.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialPadKeyboard.styles.js","sourceRoot":"","sources":["../../../src/components/DialPad/DialPadKeyboard.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM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M,MAAM,CAAC,eAAe,CAAC;;;2BAGnD,IAAI,CAAC,OAAO;;;;;;;;4BAQX,mBAAmB;wBACvB,IAAI,CAAC,OAAO,CAAC,IAAI;;;;;;iCAMR,IAAI,CAAC,OAAO,CAAC,WAAW;;;QAGjD,UAAU;;;;;;qBAMG,QAAQ,CAAC,CAAC;;;;;;;;;QASvB,UAAU;iBACD,KAAK;;;;qBAID,QAAQ,CAAC,GAAG;;;;QAIzB,aAAa;qBACA,QAAQ,CAAC,CAAC;;;KAG1B,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import { mix, readableColor } from 'polished';\nimport styled, { css } from 'styled-components';\n\nimport {\n calculateFontSize,\n defaultThemeProp,\n Grid,\n StyledIcon,\n tryCatch\n} from '@pega/cosmos-react-core';\n\nexport const StyledDialPadKeyboard = styled(Grid)(\n ({\n theme: {\n base: { spacing }\n }\n }) => {\n return css`\n max-width: calc(25 * ${spacing});\n margin: auto;\n padding: ${spacing};\n `;\n }\n);\n\nStyledDialPadKeyboard.defaultProps = defaultThemeProp;\n\nexport const StyledSpecial = styled.span``;\n\nexport const StyledDialButton = styled.button(\n ({\n theme: {\n base,\n components: { button, input }\n }\n }) => {\n const secondaryHoverColor = tryCatch(() => mix(0.85, button['secondary-color'], button.color));\n const fontSize = calculateFontSize(base['font-size'], base['font-scale']);\n const color = tryCatch(() => readableColor(button['secondary-color']));\n\n return css`\n background: transparent;\n width: calc(7 * ${base.spacing});\n height: calc(7 * ${base.spacing});\n cursor: pointer;\n color: ${color};\n border: 0.0625rem solid ${input['border-color']};\n border-radius: calc(${base['border-radius']} * ${button['border-radius']});\n position: relative;\n outline: none;\n margin-inline-end: ${base.spacing};\n\n &:last-child {\n grid-column-end: 3;\n margin-inline-end: 0;\n }\n\n &:hover {\n background-color: ${secondaryHoverColor};\n border-color: ${base.palette.dark};\n text-decoration: none;\n }\n\n &:not([disabled]):focus,\n &:enabled:focus {\n box-shadow: 0 0 0.5rem ${base.palette.interactive};\n }\n\n ${StyledIcon} {\n width: 1.5rem;\n height: 1.5rem;\n }\n\n span {\n font-size: ${fontSize.l};\n transform: translateY(-125%);\n line-height: 1;\n position: absolute;\n left: 0;\n right: 0;\n }\n\n span,\n ${StyledIcon} {\n color: ${color};\n }\n\n span + span {\n font-size: ${fontSize.xxs};\n transform: translateY(-30%);\n }\n\n ${StyledSpecial} {\n font-size: ${fontSize.l};\n transform: translateY(-50%);\n }\n `;\n }\n);\n\nStyledDialButton.defaultProps = defaultThemeProp;\n"]}
@@ -0,0 +1,6 @@
1
+ import { NavigationGraphElement } from './DialPad.types';
2
+ export declare const dtmfGraph: NavigationGraphElement[];
3
+ export declare const defaultGraph: NavigationGraphElement[];
4
+ export declare const defaultButtonGrid: NavigationGraphElement[][];
5
+ export declare const dtmfButtonGrid: NavigationGraphElement[][];
6
+ //# sourceMappingURL=KeyboardNavigation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KeyboardNavigation.d.ts","sourceRoot":"","sources":["../../../src/components/DialPad/KeyboardNavigation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AA6FzD,eAAO,MAAM,SAAS,0BAwBpB,CAAC;AAEH,eAAO,MAAM,YAAY,0BA0BvB,CAAC;AAEH,eAAO,MAAM,iBAAiB,4BAM7B,CAAC;AAEF,eAAO,MAAM,cAAc,4BAK1B,CAAC"}
@@ -0,0 +1,156 @@
1
+ const baseGraph = [
2
+ {
3
+ sign: '1',
4
+ keyCode: 49,
5
+ ref: undefined,
6
+ right: 1,
7
+ down: 3
8
+ },
9
+ {
10
+ sign: '2',
11
+ alt: 'ABC',
12
+ keyCode: 50,
13
+ ref: undefined,
14
+ right: 2,
15
+ down: 4,
16
+ left: 0
17
+ },
18
+ {
19
+ sign: '3',
20
+ alt: 'DEF',
21
+ keyCode: 51,
22
+ ref: undefined,
23
+ down: 5,
24
+ left: 1
25
+ },
26
+ {
27
+ sign: '4',
28
+ alt: 'GHI',
29
+ keyCode: 52,
30
+ ref: undefined,
31
+ up: 0,
32
+ right: 4,
33
+ down: 6
34
+ },
35
+ {
36
+ sign: '5',
37
+ alt: 'JKL',
38
+ keyCode: 53,
39
+ ref: undefined,
40
+ up: 1,
41
+ right: 5,
42
+ down: 7,
43
+ left: 3
44
+ },
45
+ {
46
+ sign: '6',
47
+ alt: 'MNO',
48
+ keyCode: 54,
49
+ ref: undefined,
50
+ up: 2,
51
+ down: 8,
52
+ left: 4
53
+ },
54
+ {
55
+ sign: '7',
56
+ alt: 'PQRS',
57
+ keyCode: 55,
58
+ ref: undefined,
59
+ up: 3,
60
+ right: 7,
61
+ down: 9
62
+ },
63
+ {
64
+ sign: '8',
65
+ alt: 'TUV',
66
+ keyCode: 56,
67
+ ref: undefined,
68
+ up: 4,
69
+ right: 8,
70
+ down: 10,
71
+ left: 6
72
+ },
73
+ {
74
+ sign: '9',
75
+ alt: 'WXYZ',
76
+ keyCode: 57,
77
+ ref: undefined,
78
+ up: 5,
79
+ down: 11,
80
+ left: 7
81
+ },
82
+ {
83
+ special: '*',
84
+ keyCode: 42,
85
+ ref: undefined,
86
+ up: 6,
87
+ right: 10,
88
+ down: 12
89
+ }
90
+ ];
91
+ export const dtmfGraph = baseGraph.concat([
92
+ {
93
+ sign: '0',
94
+ alt: '+',
95
+ keyCode: 48,
96
+ altKeyCode: 43,
97
+ ref: undefined,
98
+ up: 7,
99
+ right: 11,
100
+ left: 9
101
+ },
102
+ {
103
+ special: '#',
104
+ keyCode: 35,
105
+ ref: undefined,
106
+ up: 8,
107
+ left: 10
108
+ },
109
+ {
110
+ icon: 'backspace',
111
+ keyCode: 127,
112
+ ref: undefined,
113
+ up: 10
114
+ }
115
+ ]);
116
+ export const defaultGraph = baseGraph.concat([
117
+ {
118
+ sign: '0',
119
+ alt: '+',
120
+ keyCode: 48,
121
+ altKeyCode: 43,
122
+ ref: undefined,
123
+ up: 7,
124
+ right: 11,
125
+ down: 12,
126
+ left: 9
127
+ },
128
+ {
129
+ special: '#',
130
+ keyCode: 35,
131
+ ref: undefined,
132
+ up: 8,
133
+ down: 12,
134
+ left: 10
135
+ },
136
+ {
137
+ icon: 'backspace',
138
+ keyCode: 127,
139
+ ref: undefined,
140
+ up: 10
141
+ }
142
+ ]);
143
+ export const defaultButtonGrid = [
144
+ [defaultGraph[0], defaultGraph[1], defaultGraph[2]],
145
+ [defaultGraph[3], defaultGraph[4], defaultGraph[5]],
146
+ [defaultGraph[6], defaultGraph[7], defaultGraph[8]],
147
+ [defaultGraph[9], defaultGraph[10], defaultGraph[11]],
148
+ [defaultGraph[12]]
149
+ ];
150
+ export const dtmfButtonGrid = [
151
+ [dtmfGraph[0], dtmfGraph[1], dtmfGraph[2]],
152
+ [dtmfGraph[3], dtmfGraph[4], dtmfGraph[5]],
153
+ [dtmfGraph[6], dtmfGraph[7], dtmfGraph[8]],
154
+ [dtmfGraph[9], dtmfGraph[10], dtmfGraph[11]]
155
+ ];
156
+ //# sourceMappingURL=KeyboardNavigation.js.map