@pega/cosmos-react-social 5.0.0-dev.4.9 → 5.0.0-dev.5.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.
Files changed (237) hide show
  1. package/lib/components/Autopilot/Autopilot.d.ts +15 -0
  2. package/lib/components/Autopilot/Autopilot.d.ts.map +1 -0
  3. package/lib/components/Autopilot/Autopilot.js +50 -0
  4. package/lib/components/Autopilot/Autopilot.js.map +1 -0
  5. package/lib/components/Autopilot/AutopilotAvatar.d.ts +8 -0
  6. package/lib/components/Autopilot/AutopilotAvatar.d.ts.map +1 -0
  7. package/lib/components/Autopilot/AutopilotAvatar.js +11 -0
  8. package/lib/components/Autopilot/AutopilotAvatar.js.map +1 -0
  9. package/lib/components/Autopilot/AutopilotGlimpse.d.ts +9 -0
  10. package/lib/components/Autopilot/AutopilotGlimpse.d.ts.map +1 -0
  11. package/lib/components/Autopilot/AutopilotGlimpse.js +24 -0
  12. package/lib/components/Autopilot/AutopilotGlimpse.js.map +1 -0
  13. package/lib/components/Autopilot/index.d.ts +4 -0
  14. package/lib/components/Autopilot/index.d.ts.map +1 -0
  15. package/lib/components/Autopilot/index.js +3 -0
  16. package/lib/components/Autopilot/index.js.map +1 -0
  17. package/lib/components/Chat/Chat.d.ts +29 -0
  18. package/lib/components/Chat/Chat.d.ts.map +1 -0
  19. package/lib/components/Chat/Chat.js +64 -0
  20. package/lib/components/Chat/Chat.js.map +1 -0
  21. package/lib/components/Chat/Chat.types.d.ts +136 -0
  22. package/lib/components/Chat/Chat.types.d.ts.map +1 -0
  23. package/lib/components/Chat/Chat.types.js +10 -0
  24. package/lib/components/Chat/Chat.types.js.map +1 -0
  25. package/lib/components/Chat/ChatBody.d.ts +7 -0
  26. package/lib/components/Chat/ChatBody.d.ts.map +1 -0
  27. package/lib/components/Chat/ChatBody.js +292 -0
  28. package/lib/components/Chat/ChatBody.js.map +1 -0
  29. package/lib/components/Chat/ChatComposer.d.ts +50 -0
  30. package/lib/components/Chat/ChatComposer.d.ts.map +1 -0
  31. package/lib/components/Chat/ChatComposer.js +221 -0
  32. package/lib/components/Chat/ChatComposer.js.map +1 -0
  33. package/lib/components/Chat/ChatHeader.d.ts +29 -0
  34. package/lib/components/Chat/ChatHeader.d.ts.map +1 -0
  35. package/lib/components/Chat/ChatHeader.js +44 -0
  36. package/lib/components/Chat/ChatHeader.js.map +1 -0
  37. package/lib/components/Chat/ChatSettingsPanel.d.ts +7 -0
  38. package/lib/components/Chat/ChatSettingsPanel.d.ts.map +1 -0
  39. package/lib/components/Chat/ChatSettingsPanel.js +15 -0
  40. package/lib/components/Chat/ChatSettingsPanel.js.map +1 -0
  41. package/lib/components/Chat/ChatSettingsPanel.styles.d.ts +16 -0
  42. package/lib/components/Chat/ChatSettingsPanel.styles.d.ts.map +1 -0
  43. package/lib/components/Chat/ChatSettingsPanel.styles.js +47 -0
  44. package/lib/components/Chat/ChatSettingsPanel.styles.js.map +1 -0
  45. package/lib/components/Chat/Message.d.ts +6 -0
  46. package/lib/components/Chat/Message.d.ts.map +1 -0
  47. package/lib/components/Chat/Message.js +98 -0
  48. package/lib/components/Chat/Message.js.map +1 -0
  49. package/lib/components/Chat/Message.styles.d.ts +43 -0
  50. package/lib/components/Chat/Message.styles.d.ts.map +1 -0
  51. package/lib/components/Chat/Message.styles.js +270 -0
  52. package/lib/components/Chat/Message.styles.js.map +1 -0
  53. package/lib/components/Chat/SuggestedReplyPicker.d.ts +42 -0
  54. package/lib/components/Chat/SuggestedReplyPicker.d.ts.map +1 -0
  55. package/lib/components/Chat/SuggestedReplyPicker.js +143 -0
  56. package/lib/components/Chat/SuggestedReplyPicker.js.map +1 -0
  57. package/lib/components/Chat/SystemMessage.d.ts +8 -0
  58. package/lib/components/Chat/SystemMessage.d.ts.map +1 -0
  59. package/lib/components/Chat/SystemMessage.js +50 -0
  60. package/lib/components/Chat/SystemMessage.js.map +1 -0
  61. package/lib/components/Chat/TypeIndicator.d.ts +6 -0
  62. package/lib/components/Chat/TypeIndicator.d.ts.map +1 -0
  63. package/lib/components/Chat/TypeIndicator.js +12 -0
  64. package/lib/components/Chat/TypeIndicator.js.map +1 -0
  65. package/lib/components/Chat/index.d.ts +15 -0
  66. package/lib/components/Chat/index.d.ts.map +1 -0
  67. package/lib/components/Chat/index.js +10 -0
  68. package/lib/components/Chat/index.js.map +1 -0
  69. package/lib/components/Email/ContextMenuPopover.d.ts +5 -0
  70. package/lib/components/Email/ContextMenuPopover.d.ts.map +1 -0
  71. package/lib/components/Email/ContextMenuPopover.js +53 -0
  72. package/lib/components/Email/ContextMenuPopover.js.map +1 -0
  73. package/lib/components/Email/Email.d.ts +7 -0
  74. package/lib/components/Email/Email.d.ts.map +1 -0
  75. package/lib/components/Email/Email.js +244 -0
  76. package/lib/components/Email/Email.js.map +1 -0
  77. package/lib/components/Email/Email.styles.d.ts +67 -0
  78. package/lib/components/Email/Email.styles.d.ts.map +1 -0
  79. package/lib/components/Email/Email.styles.js +392 -0
  80. package/lib/components/Email/Email.styles.js.map +1 -0
  81. package/lib/components/Email/Email.types.d.ts +394 -0
  82. package/lib/components/Email/Email.types.d.ts.map +1 -0
  83. package/lib/components/Email/Email.types.js +2 -0
  84. package/lib/components/Email/Email.types.js.map +1 -0
  85. package/lib/components/Email/EmailCaseView.d.ts +6 -0
  86. package/lib/components/Email/EmailCaseView.d.ts.map +1 -0
  87. package/lib/components/Email/EmailCaseView.js +36 -0
  88. package/lib/components/Email/EmailCaseView.js.map +1 -0
  89. package/lib/components/Email/EmailComposer.d.ts +10 -0
  90. package/lib/components/Email/EmailComposer.d.ts.map +1 -0
  91. package/lib/components/Email/EmailComposer.js +255 -0
  92. package/lib/components/Email/EmailComposer.js.map +1 -0
  93. package/lib/components/Email/EmailConversation.d.ts +17 -0
  94. package/lib/components/Email/EmailConversation.d.ts.map +1 -0
  95. package/lib/components/Email/EmailConversation.js +174 -0
  96. package/lib/components/Email/EmailConversation.js.map +1 -0
  97. package/lib/components/Email/EmailEntity.d.ts +11 -0
  98. package/lib/components/Email/EmailEntity.d.ts.map +1 -0
  99. package/lib/components/Email/EmailEntity.js +51 -0
  100. package/lib/components/Email/EmailEntity.js.map +1 -0
  101. package/lib/components/Email/EmailManager.d.ts +6 -0
  102. package/lib/components/Email/EmailManager.d.ts.map +1 -0
  103. package/lib/components/Email/EmailManager.js +21 -0
  104. package/lib/components/Email/EmailManager.js.map +1 -0
  105. package/lib/components/Email/EmailNotificationPanel.d.ts +7 -0
  106. package/lib/components/Email/EmailNotificationPanel.d.ts.map +1 -0
  107. package/lib/components/Email/EmailNotificationPanel.js +15 -0
  108. package/lib/components/Email/EmailNotificationPanel.js.map +1 -0
  109. package/lib/components/Email/EmailSelector.d.ts +22 -0
  110. package/lib/components/Email/EmailSelector.d.ts.map +1 -0
  111. package/lib/components/Email/EmailSelector.js +121 -0
  112. package/lib/components/Email/EmailSelector.js.map +1 -0
  113. package/lib/components/Email/EmailShell.d.ts +6 -0
  114. package/lib/components/Email/EmailShell.d.ts.map +1 -0
  115. package/lib/components/Email/EmailShell.js +46 -0
  116. package/lib/components/Email/EmailShell.js.map +1 -0
  117. package/lib/components/Email/EmailSummaryItem.d.ts +11 -0
  118. package/lib/components/Email/EmailSummaryItem.d.ts.map +1 -0
  119. package/lib/components/Email/EmailSummaryItem.js +118 -0
  120. package/lib/components/Email/EmailSummaryItem.js.map +1 -0
  121. package/lib/components/Email/EmailSummaryList.d.ts +6 -0
  122. package/lib/components/Email/EmailSummaryList.d.ts.map +1 -0
  123. package/lib/components/Email/EmailSummaryList.js +95 -0
  124. package/lib/components/Email/EmailSummaryList.js.map +1 -0
  125. package/lib/components/Email/EntityList.d.ts +6 -0
  126. package/lib/components/Email/EntityList.d.ts.map +1 -0
  127. package/lib/components/Email/EntityList.js +74 -0
  128. package/lib/components/Email/EntityList.js.map +1 -0
  129. package/lib/components/Email/index.d.ts +13 -0
  130. package/lib/components/Email/index.d.ts.map +1 -0
  131. package/lib/components/Email/index.js +12 -0
  132. package/lib/components/Email/index.js.map +1 -0
  133. package/lib/components/Email/utils/EntityHighlighter.d.ts +10 -0
  134. package/lib/components/Email/utils/EntityHighlighter.d.ts.map +1 -0
  135. package/lib/components/Email/utils/EntityHighlighter.js +260 -0
  136. package/lib/components/Email/utils/EntityHighlighter.js.map +1 -0
  137. package/lib/components/Feed/Feed.context.d.ts +51 -0
  138. package/lib/components/Feed/Feed.context.d.ts.map +1 -0
  139. package/lib/components/Feed/Feed.context.js +10 -0
  140. package/lib/components/Feed/Feed.context.js.map +1 -0
  141. package/lib/components/Feed/Feed.d.ts +6 -0
  142. package/lib/components/Feed/Feed.d.ts.map +1 -0
  143. package/lib/components/Feed/Feed.js +149 -0
  144. package/lib/components/Feed/Feed.js.map +1 -0
  145. package/lib/components/Feed/Feed.types.d.ts +334 -0
  146. package/lib/components/Feed/Feed.types.d.ts.map +1 -0
  147. package/lib/components/Feed/Feed.types.js +2 -0
  148. package/lib/components/Feed/Feed.types.js.map +1 -0
  149. package/lib/components/Feed/FeedAnnouncer.d.ts +6 -0
  150. package/lib/components/Feed/FeedAnnouncer.d.ts.map +1 -0
  151. package/lib/components/Feed/FeedAnnouncer.js +11 -0
  152. package/lib/components/Feed/FeedAnnouncer.js.map +1 -0
  153. package/lib/components/Feed/FeedAttachments.d.ts +8 -0
  154. package/lib/components/Feed/FeedAttachments.d.ts.map +1 -0
  155. package/lib/components/Feed/FeedAttachments.js +97 -0
  156. package/lib/components/Feed/FeedAttachments.js.map +1 -0
  157. package/lib/components/Feed/FeedButton.d.ts +5 -0
  158. package/lib/components/Feed/FeedButton.d.ts.map +1 -0
  159. package/lib/components/Feed/FeedButton.js +15 -0
  160. package/lib/components/Feed/FeedButton.js.map +1 -0
  161. package/lib/components/Feed/FeedContent.d.ts +6 -0
  162. package/lib/components/Feed/FeedContent.d.ts.map +1 -0
  163. package/lib/components/Feed/FeedContent.js +46 -0
  164. package/lib/components/Feed/FeedContent.js.map +1 -0
  165. package/lib/components/Feed/FeedContentFooter.d.ts +5 -0
  166. package/lib/components/Feed/FeedContentFooter.d.ts.map +1 -0
  167. package/lib/components/Feed/FeedContentFooter.js +34 -0
  168. package/lib/components/Feed/FeedContentFooter.js.map +1 -0
  169. package/lib/components/Feed/FeedContentHeader.d.ts +5 -0
  170. package/lib/components/Feed/FeedContentHeader.d.ts.map +1 -0
  171. package/lib/components/Feed/FeedContentHeader.js +107 -0
  172. package/lib/components/Feed/FeedContentHeader.js.map +1 -0
  173. package/lib/components/Feed/FeedEditRegion.d.ts +6 -0
  174. package/lib/components/Feed/FeedEditRegion.d.ts.map +1 -0
  175. package/lib/components/Feed/FeedEditRegion.js +57 -0
  176. package/lib/components/Feed/FeedEditRegion.js.map +1 -0
  177. package/lib/components/Feed/FeedInputRegion.d.ts +8 -0
  178. package/lib/components/Feed/FeedInputRegion.d.ts.map +1 -0
  179. package/lib/components/Feed/FeedInputRegion.js +86 -0
  180. package/lib/components/Feed/FeedInputRegion.js.map +1 -0
  181. package/lib/components/Feed/FeedLikeButton.d.ts +7 -0
  182. package/lib/components/Feed/FeedLikeButton.d.ts.map +1 -0
  183. package/lib/components/Feed/FeedLikeButton.js +102 -0
  184. package/lib/components/Feed/FeedLikeButton.js.map +1 -0
  185. package/lib/components/Feed/FeedModalList.d.ts +5 -0
  186. package/lib/components/Feed/FeedModalList.d.ts.map +1 -0
  187. package/lib/components/Feed/FeedModalList.js +39 -0
  188. package/lib/components/Feed/FeedModalList.js.map +1 -0
  189. package/lib/components/Feed/FeedNewPost.d.ts +7 -0
  190. package/lib/components/Feed/FeedNewPost.d.ts.map +1 -0
  191. package/lib/components/Feed/FeedNewPost.js +30 -0
  192. package/lib/components/Feed/FeedNewPost.js.map +1 -0
  193. package/lib/components/Feed/FeedNewPostTypeMenu.d.ts +6 -0
  194. package/lib/components/Feed/FeedNewPostTypeMenu.d.ts.map +1 -0
  195. package/lib/components/Feed/FeedNewPostTypeMenu.js +375 -0
  196. package/lib/components/Feed/FeedNewPostTypeMenu.js.map +1 -0
  197. package/lib/components/Feed/FeedPost.d.ts +8 -0
  198. package/lib/components/Feed/FeedPost.d.ts.map +1 -0
  199. package/lib/components/Feed/FeedPost.js +85 -0
  200. package/lib/components/Feed/FeedPost.js.map +1 -0
  201. package/lib/components/Feed/FeedReply.d.ts +7 -0
  202. package/lib/components/Feed/FeedReply.d.ts.map +1 -0
  203. package/lib/components/Feed/FeedReply.js +36 -0
  204. package/lib/components/Feed/FeedReply.js.map +1 -0
  205. package/lib/components/Feed/FeedReplyInput.d.ts +7 -0
  206. package/lib/components/Feed/FeedReplyInput.d.ts.map +1 -0
  207. package/lib/components/Feed/FeedReplyInput.js +21 -0
  208. package/lib/components/Feed/FeedReplyInput.js.map +1 -0
  209. package/lib/components/Feed/FeedRichText.d.ts +6 -0
  210. package/lib/components/Feed/FeedRichText.d.ts.map +1 -0
  211. package/lib/components/Feed/FeedRichText.js +163 -0
  212. package/lib/components/Feed/FeedRichText.js.map +1 -0
  213. package/lib/components/Feed/index.d.ts +7 -0
  214. package/lib/components/Feed/index.d.ts.map +1 -0
  215. package/lib/components/Feed/index.js +6 -0
  216. package/lib/components/Feed/index.js.map +1 -0
  217. package/lib/components/HashtagButton/HashtagButton.d.ts +23 -0
  218. package/lib/components/HashtagButton/HashtagButton.d.ts.map +1 -0
  219. package/lib/components/HashtagButton/HashtagButton.js +44 -0
  220. package/lib/components/HashtagButton/HashtagButton.js.map +1 -0
  221. package/lib/components/HashtagButton/index.d.ts +3 -0
  222. package/lib/components/HashtagButton/index.d.ts.map +1 -0
  223. package/lib/components/HashtagButton/index.js +3 -0
  224. package/lib/components/HashtagButton/index.js.map +1 -0
  225. package/lib/components/MentionButton/MentionButton.d.ts +35 -0
  226. package/lib/components/MentionButton/MentionButton.d.ts.map +1 -0
  227. package/lib/components/MentionButton/MentionButton.js +94 -0
  228. package/lib/components/MentionButton/MentionButton.js.map +1 -0
  229. package/lib/components/MentionButton/index.d.ts +3 -0
  230. package/lib/components/MentionButton/index.d.ts.map +1 -0
  231. package/lib/components/MentionButton/index.js +3 -0
  232. package/lib/components/MentionButton/index.js.map +1 -0
  233. package/lib/index.d.ts +12 -0
  234. package/lib/index.d.ts.map +1 -0
  235. package/lib/index.js +13 -0
  236. package/lib/index.js.map +1 -0
  237. package/package.json +4 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmailEntity.js","sourceRoot":"","sources":["../../../src/components/Email/EmailEntity.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsC,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAE3D,OAAO,EAEL,OAAO,EACP,kBAAkB,EAClB,UAAU,EACV,OAAO,EACP,gBAAgB,EAChB,wBAAwB,EACxB,IAAI,EACL,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGnD,MAAM,WAAW,GAAuD,UAAU,CAChF,SAAS,WAAW,CAClB,EAAE,MAAM,EAAE,GAAG,SAAS,EAAqC,EAC3D,GAA4B;IAE5B,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,GAAG,UAAU,EAAe,CAAC;IAC9C,MAAM,UAAU,GAAG,kBAAkB,CAAc,KAAK,EAAE,GAAG,CAAC,CAAC;IAC/D,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,EAAE,CAAC;IACtC,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAChD,OAAO,CACL,MAAC,iBAAiB,OACZ,SAAS,EACb,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,UAAU,gBAEb,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC;YAC/B,CAAC,CAAC,wBAAwB,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,MAAM,CAAC;YACzD,CAAC,CAAC,MAAM,CAAC,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S,CAAC;QACnF,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QAClD,MAAM,CACJ,KAAC,WAAW,IACV,MAAM,EAAE;gBACN,KAAK,EAAE,KAAK;gBACZ,IAAI;gBACJ,OAAO;gBACP,WAAW;aACZ,GACD,EACF,IAAI,CACL,CAAC;IACJ,CAAC;IAED,oBAAoB;QAClB,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF;AAED,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAE;IAC5C,cAAc,CAAC,MAAM,CAAC,mBAAmB,EAAE,cAAc,CAAC,CAAC;CAC5D;AAED,eAAe,WAAW,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, useRef } from 'react';\nimport { render, unmountComponentAtNode } from 'react-dom';\n\nimport {\n ForwardProps,\n Tooltip,\n useConsolidatedRef,\n useElement,\n useI18n,\n useConfiguration,\n formatListToLocaleString,\n Icon\n} from '@pega/cosmos-react-core';\n\nimport { StyledEmailEntity } from './Email.styles';\nimport { EmailEntityProps } from './Email.types';\n\nconst EmailEntity: FunctionComponent<EmailEntityProps & ForwardProps> = forwardRef(\n function EmailEntity(\n { entity, ...restProps }: PropsWithoutRef<EmailEntityProps>,\n ref: EmailEntityProps['ref']\n ) {\n const [el, setEl] = useElement<HTMLElement>();\n const elementRef = useConsolidatedRef<HTMLElement>(setEl, ref);\n const t = useI18n();\n const { locale } = useConfiguration();\n const tooltipRef = useRef<HTMLDivElement>(null);\n return (\n <StyledEmailEntity\n {...restProps}\n entity={entity}\n ref={elementRef}\n aria-label={\n Array.isArray(entity.description)\n ? formatListToLocaleString(entity.description, t, locale)\n : entity.description\n }\n onContextMenu={() => {\n if (tooltipRef.current) tooltipRef.current.hidden = true;\n }}\n contentEditable={false}\n >\n {entity.value}\n {entity.icon && <Icon name={entity.icon} />}\n {entity.description && entity.description.length > 0 && (\n <Tooltip target={el} ref={tooltipRef} hideDelay='short'>\n {Array.isArray(entity.description)\n ? formatListToLocaleString(entity.description, t, locale, {\n separator: '\\n'\n })\n : entity.description}\n </Tooltip>\n )}\n </StyledEmailEntity>\n );\n }\n);\n\nexport class EmailEntityWeb extends HTMLElement {\n removeElements() {\n while (this.firstChild) {\n this.removeChild(this.firstChild);\n }\n }\n\n connectedCallback() {\n const inner = this.innerHTML;\n this.removeElements();\n const variant = Number(this.getAttribute('data-variant'));\n const descAttribute = this.getAttribute('data-description');\n const description = descAttribute !== null ? JSON.parse(descAttribute) : undefined;\n const type = this.getAttribute('data-type') || '';\n render(\n <EmailEntity\n entity={{\n value: inner,\n type,\n variant,\n description\n }}\n />,\n this\n );\n }\n\n disconnectedCallback() {\n unmountComponentAtNode(this);\n }\n}\n\nif (!customElements.get('pega-email-entity')) {\n customElements.define('pega-email-entity', EmailEntityWeb);\n}\n\nexport default EmailEntity;\n"]}
@@ -0,0 +1,6 @@
1
+ import { FC } from 'react';
2
+ import { ForwardProps } from '@pega/cosmos-react-core';
3
+ import { EmailManagerProps } from './Email.types';
4
+ declare const EmailManager: FC<EmailManagerProps & ForwardProps>;
5
+ export default EmailManager;
6
+ //# sourceMappingURL=EmailManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmailManager.d.ts","sourceRoot":"","sources":["../../../src/components/Email/EmailManager.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAsD,MAAM,OAAO,CAAC;AAE/E,OAAO,EAGL,YAAY,EAKb,MAAM,yBAAyB,CAAC;AAKjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAUlD,QAAA,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,GAAG,YAAY,CA4CtD,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState, useRef, useLayoutEffect } from 'react';
3
+ import { EmptyState, Flex, Grid, Icon, registerIcon, Text } from '@pega/cosmos-react-core';
4
+ import { StyledPageIcon } from '@pega/cosmos-react-core/lib/components/PageTemplates/PageTemplates';
5
+ import * as moveRightSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/move-right-solid.icon';
6
+ import * as moveLeftSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/move-left-solid.icon';
7
+ import { StyledEmailManagerContainer, StyledGridContainer, StyledHeader, StyledList } from './Email.styles';
8
+ registerIcon(moveRightSolidIcon, moveLeftSolidIcon);
9
+ const EmailManager = ({ header, list, emailCaseDetails, ...restProps }) => {
10
+ const headerRef = useRef(null);
11
+ const [headerOffsetHeight, setHeaderOffsetHeight] = useState(0);
12
+ useLayoutEffect(() => {
13
+ setHeaderOffsetHeight(headerRef?.current?.offsetHeight || 0);
14
+ }, []);
15
+ return (_jsxs(StyledEmailManagerContainer, { ...restProps, children: [header && (_jsxs(Flex, { container: { alignItems: 'center', pad: [0, 0, 0, 2], gap: 1 }, as: StyledHeader, ref: headerRef, children: [header.icon && (_jsx(StyledPageIcon, { container: { alignItems: 'center', justify: 'center' }, children: _jsx(Icon, { name: header.icon }) })), _jsx(Text, { variant: 'h1', children: header.title })] })), _jsxs(Grid, { as: StyledGridContainer, container: {
16
+ cols: 'minmax(20rem, 1fr) minmax(0, 3fr)',
17
+ gap: 2
18
+ }, style: { '--headerOffsetHeight': `${headerOffsetHeight}px` }, item: { area: 'container' }, hasHeader: !!header, children: [_jsx(StyledList, { children: list }), _jsx("div", { children: emailCaseDetails || _jsx(EmptyState, {}) })] })] }));
19
+ };
20
+ export default EmailManager;
21
+ //# sourceMappingURL=EmailManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmailManager.js","sourceRoot":"","sources":["../../../src/components/Email/EmailManager.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAmB,MAAM,OAAO,CAAC;AAE/E,OAAO,EACL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,CAClB,EACD,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,YAAE,MAAM,CAAC,KAAK,GAAQ,IACnC,CACR,EACD,MAAC,IAAI,IACH,EAAE,EAAE,mBAAmB,EACvB,SAAS,EAAE;oBACT,IAAI,EAAE,mCAAmC;oBACzC,GAAG,EAAE,CAAC;iBACP,EACD,KAAK,EAAE,EAAE,sBAAsB,EAAE,GAAG,kBAAkB,IAAI,EAAE,EAC5D,IAAI,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,EAC3B,SAAS,EAAE,CAAC,CAAC,MAAM,aAEnB,KAAC,UAAU,cAAE,IAAI,GAAc,EAC/B,wBAAM,gBAAgB,IAAI,KAAC,UAAU,KAAG,GAAO,IAC1C,IACqB,CAC/B,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { FC, useState, useRef, useLayoutEffect, PropsWithoutRef } from 'react';\n\nimport {\n EmptyState,\n Flex,\n ForwardProps,\n Grid,\n Icon,\n registerIcon,\n Text\n} from '@pega/cosmos-react-core';\nimport { StyledPageIcon } from '@pega/cosmos-react-core/lib/components/PageTemplates/PageTemplates';\nimport * as moveRightSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/move-right-solid.icon';\nimport * as moveLeftSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/move-left-solid.icon';\n\nimport { EmailManagerProps } from './Email.types';\nimport {\n StyledEmailManagerContainer,\n StyledGridContainer,\n StyledHeader,\n StyledList\n} from './Email.styles';\n\nregisterIcon(moveRightSolidIcon, moveLeftSolidIcon);\n\nconst EmailManager: FC<EmailManagerProps & ForwardProps> = ({\n header,\n list,\n emailCaseDetails,\n ...restProps\n}: PropsWithoutRef<EmailManagerProps>) => {\n const headerRef = useRef<HTMLDivElement>(null);\n const [headerOffsetHeight, setHeaderOffsetHeight] = useState(0);\n\n useLayoutEffect(() => {\n setHeaderOffsetHeight(headerRef?.current?.offsetHeight || 0);\n }, []);\n\n return (\n <StyledEmailManagerContainer {...restProps}>\n {header && (\n <Flex\n container={{ alignItems: 'center', pad: [0, 0, 0, 2], gap: 1 }}\n as={StyledHeader}\n ref={headerRef}\n >\n {header.icon && (\n <StyledPageIcon container={{ alignItems: 'center', justify: 'center' }}>\n <Icon name={header.icon} />\n </StyledPageIcon>\n )}\n <Text variant='h1'>{header.title}</Text>\n </Flex>\n )}\n <Grid\n as={StyledGridContainer}\n container={{\n cols: 'minmax(20rem, 1fr) minmax(0, 3fr)',\n gap: 2\n }}\n style={{ '--headerOffsetHeight': `${headerOffsetHeight}px` }}\n item={{ area: 'container' }}\n hasHeader={!!header}\n >\n <StyledList>{list}</StyledList>\n <div>{emailCaseDetails || <EmptyState />}</div>\n </Grid>\n </StyledEmailManagerContainer>\n );\n};\n\nexport default EmailManager;\n"]}
@@ -0,0 +1,7 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { ForwardProps, OmitStrict } from '@pega/cosmos-react-core';
3
+ import type { EmailNotificationPanelProps } from './Email.types';
4
+ export declare const EmailNotificationPanelIcon: FunctionComponent<OmitStrict<EmailNotificationPanelProps, 'onClick'> & ForwardProps>;
5
+ declare const EmailNotificationPanel: FunctionComponent<EmailNotificationPanelProps & ForwardProps>;
6
+ export default EmailNotificationPanel;
7
+ //# sourceMappingURL=EmailNotificationPanel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmailNotificationPanel.d.ts","sourceRoot":"","sources":["../../../src/components/Email/EmailNotificationPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EACL,YAAY,EAEZ,UAAU,EAKX,MAAM,yBAAyB,CAAC;AAIjC,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAKjE,eAAO,MAAM,0BAA0B,EAAE,iBAAiB,CACxD,UAAU,CAAC,2BAA2B,EAAE,SAAS,CAAC,GAAG,YAAY,CAclE,CAAC;AAEF,QAAA,MAAM,sBAAsB,EAAE,iBAAiB,CAAC,2BAA2B,GAAG,YAAY,CAazF,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Icon, registerIcon, StyledAvatar, useTheme, VisuallyHiddenText } from '@pega/cosmos-react-core';
3
+ import * as mailIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/mail-solid.icon';
4
+ import { NavigationListItem } from '@pega/cosmos-react-core/lib/components/AppShell/NavigationList';
5
+ import { StyledEmailCountIcon } from './Email.styles';
6
+ registerIcon(mailIcon);
7
+ export const EmailNotificationPanelIcon = ({ status, label, count, ...restProps }) => {
8
+ const { base: { colors } } = useTheme();
9
+ return (_jsxs(StyledAvatar, { as: StyledAvatar, ...restProps, size: 'm', backgroundColor: colors.white, children: [_jsx(Icon, { name: 'mail-solid' }), _jsx(StyledEmailCountIcon, { variant: 'urgent', children: count }), _jsx(VisuallyHiddenText, { children: label })] }));
10
+ };
11
+ const EmailNotificationPanel = ({ label, onClick, count, ...restProps }) => {
12
+ return (_jsx(NavigationListItem, { primary: label, visual: _jsx(EmailNotificationPanelIcon, { ...restProps, count: count, label: label }), onClick: onClick }));
13
+ };
14
+ export default EmailNotificationPanel;
15
+ //# sourceMappingURL=EmailNotificationPanel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmailNotificationPanel.js","sourceRoot":"","sources":["../../../src/components/Email/EmailNotificationPanel.tsx"],"names":[],"mappings":";AAEA,OAAO,EAEL,IAAI,EAEJ,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,kBAAkB,EACnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,QAAQ,MAAM,mEAAmE,CAAC;AAC9F,OAAO,EAAE,kBAAkB,EAAE,MAAM,gEAAgE,CAAC;AAGpG,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,YAAY,CAAC,QAAQ,CAAC,CAAC;AAEvB,MAAM,CAAC,MAAM,0BAA0B,GAEnC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,SAAS,EAAE,EAAE,EAAE;IAC7C,MAAM,EACJ,IAAI,EAAE,EAAE,MAAM,EAAE,EACjB,GAAG,QAAQ,EAAE,CAAC;IACf,OAAO,CACL,MAAC,YAAY,IAAC,EAAE,EAAE,YAAY,KAAM,SAAS,EAAE,IAAI,EAAC,GAAG,EAAC,eAAe,EAAE,MAAM,CAAC,KAAK,aACnF,KAAC,IAAI,IAAC,IAAI,EAAC,YAAY,GAAG,EAE1B,KAAC,oBAAoB,IAAC,OAAO,EAAC,QAAQ,YAAE,KAAK,GAAwB,EAErE,KAAC,kBAAkB,cAAE,KAAK,GAAsB,IACnC,CAChB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,sBAAsB,GAAkE,CAAC,EAC7F,KAAK,EACL,OAAO,EACP,KAAK,EACL,GAAG,SAAS,EACb,EAAE,EAAE;IACH,OAAO,CACL,KAAC,kBAAkB,IACjB,OAAO,EAAE,KAAK,EACd,MAAM,EAAE,KAAC,0BAA0B,OAAK,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,GAAI,EACjF,OAAO,EAAE,OAAO,GAChB,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,sBAAsB,CAAC","sourcesContent":["import { FunctionComponent } from 'react';\n\nimport {\n ForwardProps,\n Icon,\n OmitStrict,\n registerIcon,\n StyledAvatar,\n useTheme,\n VisuallyHiddenText\n} from '@pega/cosmos-react-core';\nimport * as mailIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/mail-solid.icon';\nimport { NavigationListItem } from '@pega/cosmos-react-core/lib/components/AppShell/NavigationList';\n\nimport type { EmailNotificationPanelProps } from './Email.types';\nimport { StyledEmailCountIcon } from './Email.styles';\n\nregisterIcon(mailIcon);\n\nexport const EmailNotificationPanelIcon: FunctionComponent<\n OmitStrict<EmailNotificationPanelProps, 'onClick'> & ForwardProps\n> = ({ status, label, count, ...restProps }) => {\n const {\n base: { colors }\n } = useTheme();\n return (\n <StyledAvatar as={StyledAvatar} {...restProps} size='m' backgroundColor={colors.white}>\n <Icon name='mail-solid' />\n\n <StyledEmailCountIcon variant='urgent'>{count}</StyledEmailCountIcon>\n\n <VisuallyHiddenText>{label}</VisuallyHiddenText>\n </StyledAvatar>\n );\n};\n\nconst EmailNotificationPanel: FunctionComponent<EmailNotificationPanelProps & ForwardProps> = ({\n label,\n onClick,\n count,\n ...restProps\n}) => {\n return (\n <NavigationListItem\n primary={label}\n visual={<EmailNotificationPanelIcon {...restProps} count={count} label={label} />}\n onClick={onClick}\n />\n );\n};\n\nexport default EmailNotificationPanel;\n"]}
@@ -0,0 +1,22 @@
1
+ import { FunctionComponent, ReactNode } from 'react';
2
+ import { ComboBoxProps, NoChildrenProp, FormControlProps } from '@pega/cosmos-react-core';
3
+ import { EmailComposerProps, EmailUser } from './Email.types';
4
+ export interface EmailSelectorProps extends NoChildrenProp {
5
+ /** participants */
6
+ participants: EmailComposerProps['participants'];
7
+ /** default selections */
8
+ selectedItems: EmailUser['emailAddress'][];
9
+ /** selectedItems */
10
+ onSelectedItemChange: (selectedItems: EmailUser['emailAddress'][], label: ReactNode) => void;
11
+ /**
12
+ * Callback to handle external entry validation
13
+ * If returned true considers the entry to be a valid entry
14
+ */
15
+ externalValidator?: EmailComposerProps['externalValidator'];
16
+ status?: FormControlProps['status'];
17
+ info?: FormControlProps['info'];
18
+ compose?: boolean;
19
+ }
20
+ declare const EmailSelector: FunctionComponent<EmailSelectorProps & Pick<ComboBoxProps, 'label' | 'mode' | 'required'>>;
21
+ export default EmailSelector;
22
+ //# sourceMappingURL=EmailSelector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmailSelector.d.ts","sourceRoot":"","sources":["../../../src/components/Email/EmailSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAkC,SAAS,EAAE,MAAM,OAAO,CAAC;AAErF,OAAO,EAEL,aAAa,EAGb,cAAc,EAEd,gBAAgB,EAEjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE9D,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,mBAAmB;IACnB,YAAY,EAAE,kBAAkB,CAAC,cAAc,CAAC,CAAC;IACjD,yBAAyB;IACzB,aAAa,EAAE,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC;IAC3C,oBAAoB;IACpB,oBAAoB,EAAE,CAAC,aAAa,EAAE,SAAS,CAAC,cAAc,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IAC7F;;;OAGG;IACH,iBAAiB,CAAC,EAAE,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAC5D,MAAM,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACpC,IAAI,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,QAAA,MAAM,aAAa,EAAE,iBAAiB,CACpC,kBAAkB,GAAG,IAAI,CAAC,aAAa,EAAE,OAAO,GAAG,MAAM,GAAG,UAAU,CAAC,CA4IxE,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -0,0 +1,121 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useMemo, useState } from 'react';
3
+ import { ComboBox, createStringMatcher, menuHelpers, useI18n, useAfterInitialEffect } from '@pega/cosmos-react-core';
4
+ const EmailSelector = ({ participants, selectedItems, label, mode, required, onSelectedItemChange, externalValidator, status, info, compose }) => {
5
+ const [filterValue, setFilterValue] = useState('');
6
+ const [emailParticipants, setEmailParticipants] = useState(participants);
7
+ const t = useI18n();
8
+ useAfterInitialEffect(() => {
9
+ setEmailParticipants(participants);
10
+ }, [participants]);
11
+ const filterRegex = createStringMatcher(filterValue, 'contains');
12
+ const emailsToRender = useMemo(() => {
13
+ const filteredItems = (filterValue
14
+ ? emailParticipants.filter(({ emailAddress, fullName, shortName }) => {
15
+ return (filterRegex.test(emailAddress) ||
16
+ filterRegex.test(fullName) ||
17
+ filterRegex.test(shortName));
18
+ })
19
+ : emailParticipants).map(({ emailAddress, fullName }) => {
20
+ return {
21
+ id: emailAddress,
22
+ primary: fullName,
23
+ secondary: [emailAddress],
24
+ selected: selectedItems.includes(emailAddress)
25
+ };
26
+ });
27
+ const isValid = externalValidator?.(filterValue);
28
+ return ((filterValue && externalValidator && isValid) || (filterValue && !externalValidator)) &&
29
+ !compose
30
+ ? [
31
+ {
32
+ id: filterValue,
33
+ primary: `${t('use')}: ${filterValue}`,
34
+ selected: selectedItems.includes(filterValue)
35
+ },
36
+ ...filteredItems
37
+ ]
38
+ : filteredItems;
39
+ }, [emailParticipants, selectedItems, filterRegex]);
40
+ const toggleSelectedItems = (id) => {
41
+ let newSelectedItems = mode === 'single-select' ? [] : [...selectedItems];
42
+ if (selectedItems.includes(id)) {
43
+ // Unselect an already selected item
44
+ newSelectedItems = newSelectedItems.filter(value => value !== id);
45
+ }
46
+ else {
47
+ setFilterValue('');
48
+ const filteredItem = menuHelpers.getItem(emailsToRender, id);
49
+ if (!filteredItem?.secondary) {
50
+ // New value addition to the list
51
+ if (!externalValidator) {
52
+ setEmailParticipants([
53
+ ...emailParticipants,
54
+ {
55
+ shortName: '',
56
+ fullName: '',
57
+ emailAddress: filterValue
58
+ }
59
+ ]);
60
+ newSelectedItems = [...newSelectedItems, id];
61
+ }
62
+ else {
63
+ const isValid = externalValidator?.(filterValue);
64
+ if (isValid) {
65
+ setEmailParticipants([
66
+ ...emailParticipants,
67
+ {
68
+ shortName: '',
69
+ fullName: '',
70
+ emailAddress: filterValue
71
+ }
72
+ ]);
73
+ newSelectedItems = [...newSelectedItems, id];
74
+ }
75
+ }
76
+ }
77
+ else {
78
+ // Existing value to be selected
79
+ newSelectedItems = [...newSelectedItems, id];
80
+ }
81
+ }
82
+ onSelectedItemChange(newSelectedItems, label);
83
+ };
84
+ const getSelectedItems = () => {
85
+ if (mode === 'single-select') {
86
+ return { id: selectedItems[0], text: selectedItems[0] };
87
+ }
88
+ return selectedItems.map(value => ({ id: value, text: value }));
89
+ };
90
+ const clearSelection = () => {
91
+ onSelectedItemChange([], label);
92
+ };
93
+ const comboBoxProps = {
94
+ value: filterValue,
95
+ onChange: (e) => {
96
+ if (!e.target.value)
97
+ clearSelection();
98
+ setFilterValue(e.target.value);
99
+ },
100
+ onBlur: () => {
101
+ setFilterValue('');
102
+ },
103
+ menu: {
104
+ items: emailsToRender,
105
+ accent: filterRegex,
106
+ onItemClick: toggleSelectedItems
107
+ },
108
+ selected: {
109
+ items: getSelectedItems(),
110
+ onRemove: toggleSelectedItems
111
+ },
112
+ label,
113
+ mode,
114
+ required,
115
+ status,
116
+ info
117
+ };
118
+ return _jsx(ComboBox, { ...comboBoxProps });
119
+ };
120
+ export default EmailSelector;
121
+ //# sourceMappingURL=EmailSelector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmailSelector.js","sourceRoot":"","sources":["../../../src/components/Email/EmailSelector.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkC,OAAO,EAAE,QAAQ,EAAa,MAAM,OAAO,CAAC;AAErF,OAAO,EACL,QAAQ,EAER,mBAAmB,EACnB,WAAW,EAEX,OAAO,EAEP,qBAAqB,EACtB,MAAM,yBAAyB,CAAC;AAqBjC,MAAM,aAAa,GAEf,CAAC,EACH,YAAY,EACZ,aAAa,EACb,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,oBAAoB,EACpB,iBAAiB,EACjB,MAAM,EACN,IAAI,EACJ,OAAO,EACR,EAAE,EAAE;IACH,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACnD,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAG,QA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R,MAAM;QACN,IAAI;KACL,CAAC;IAEF,OAAO,KAAC,QAAQ,OAAK,aAAa,GAAI,CAAC;AACzC,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { FunctionComponent, ChangeEvent, useMemo, useState, ReactNode } from 'react';\n\nimport {\n ComboBox,\n ComboBoxProps,\n createStringMatcher,\n menuHelpers,\n NoChildrenProp,\n useI18n,\n FormControlProps,\n useAfterInitialEffect\n} from '@pega/cosmos-react-core';\n\nimport { EmailComposerProps, EmailUser } from './Email.types';\n\nexport interface EmailSelectorProps extends NoChildrenProp {\n /** participants */\n participants: EmailComposerProps['participants'];\n /** default selections */\n selectedItems: EmailUser['emailAddress'][];\n /** selectedItems */\n onSelectedItemChange: (selectedItems: EmailUser['emailAddress'][], label: ReactNode) => void;\n /**\n * Callback to handle external entry validation\n * If returned true considers the entry to be a valid entry\n */\n externalValidator?: EmailComposerProps['externalValidator'];\n status?: FormControlProps['status'];\n info?: FormControlProps['info'];\n compose?: boolean;\n}\n\nconst EmailSelector: FunctionComponent<\n EmailSelectorProps & Pick<ComboBoxProps, 'label' | 'mode' | 'required'>\n> = ({\n participants,\n selectedItems,\n label,\n mode,\n required,\n onSelectedItemChange,\n externalValidator,\n status,\n info,\n compose\n}) => {\n const [filterValue, setFilterValue] = useState('');\n const [emailParticipants, setEmailParticipants] = useState(participants);\n const t = useI18n();\n\n useAfterInitialEffect(() => {\n setEmailParticipants(participants);\n }, [participants]);\n\n const filterRegex = createStringMatcher(filterValue, 'contains');\n\n const emailsToRender = useMemo(() => {\n const filteredItems = (\n filterValue\n ? emailParticipants.filter(({ emailAddress, fullName, shortName }) => {\n return (\n filterRegex.test(emailAddress) ||\n filterRegex.test(fullName) ||\n filterRegex.test(shortName)\n );\n })\n : emailParticipants\n ).map(({ emailAddress, fullName }) => {\n return {\n id: emailAddress,\n primary: fullName,\n secondary: [emailAddress],\n selected: selectedItems.includes(emailAddress)\n };\n });\n\n const isValid = externalValidator?.(filterValue);\n\n return ((filterValue && externalValidator && isValid) || (filterValue && !externalValidator)) &&\n !compose\n ? [\n {\n id: filterValue,\n primary: `${t('use')}: ${filterValue}`,\n selected: selectedItems.includes(filterValue)\n },\n ...filteredItems\n ]\n : filteredItems;\n }, [emailParticipants, selectedItems, filterRegex]);\n\n const toggleSelectedItems = (id: string) => {\n let newSelectedItems = mode === 'single-select' ? [] : [...selectedItems];\n\n if (selectedItems.includes(id)) {\n // Unselect an already selected item\n newSelectedItems = newSelectedItems.filter(value => value !== id);\n } else {\n setFilterValue('');\n const filteredItem = menuHelpers.getItem(emailsToRender, id);\n\n if (!filteredItem?.secondary) {\n // New value addition to the list\n if (!externalValidator) {\n setEmailParticipants([\n ...emailParticipants,\n {\n shortName: '',\n fullName: '',\n emailAddress: filterValue\n }\n ]);\n newSelectedItems = [...newSelectedItems, id];\n } else {\n const isValid = externalValidator?.(filterValue);\n if (isValid) {\n setEmailParticipants([\n ...emailParticipants,\n {\n shortName: '',\n fullName: '',\n emailAddress: filterValue\n }\n ]);\n newSelectedItems = [...newSelectedItems, id];\n }\n }\n } else {\n // Existing value to be selected\n newSelectedItems = [...newSelectedItems, id];\n }\n }\n\n onSelectedItemChange(newSelectedItems, label);\n };\n\n const getSelectedItems = () => {\n if (mode === 'single-select') {\n return { id: selectedItems[0], text: selectedItems[0] };\n }\n return selectedItems.map(value => ({ id: value, text: value }));\n };\n\n const clearSelection = () => {\n onSelectedItemChange([], label);\n };\n\n const comboBoxProps = {\n value: filterValue,\n onChange: (e: ChangeEvent<HTMLInputElement>) => {\n if (!e.target.value) clearSelection();\n setFilterValue(e.target.value);\n },\n onBlur: () => {\n setFilterValue('');\n },\n menu: {\n items: emailsToRender,\n accent: filterRegex,\n onItemClick: toggleSelectedItems\n },\n selected: {\n items: getSelectedItems(),\n onRemove: toggleSelectedItems\n },\n label,\n mode,\n required,\n status,\n info\n };\n\n return <ComboBox {...comboBoxProps} />;\n};\n\nexport default EmailSelector;\n"]}
@@ -0,0 +1,6 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { ForwardProps } from '@pega/cosmos-react-core';
3
+ import { EmailShellProps } from './Email.types';
4
+ declare const EmailShell: FunctionComponent<EmailShellProps & ForwardProps>;
5
+ export default EmailShell;
6
+ //# sourceMappingURL=EmailShell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmailShell.d.ts","sourceRoot":"","sources":["../../../src/components/Email/EmailShell.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAyC,MAAM,OAAO,CAAC;AAEjF,OAAO,EAAQ,YAAY,EAAqC,MAAM,yBAAyB,CAAC;AAGhG,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAchD,QAAA,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,GAAG,YAAY,CAwFjE,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useState } from 'react';
3
+ import { Flex, Icon, registerIcon, Text, useI18n } from '@pega/cosmos-react-core';
4
+ import * as mailIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/mail.icon';
5
+ import EmailConversation, { StyledEmailConversation, StyledEmailInConversation, StyledUnReadCount } from './EmailConversation';
6
+ import { StyledEmailConversationList, StyledEmailShell, StyledEmailShellHeader } from './Email.styles';
7
+ registerIcon(mailIcon);
8
+ const EmailShell = forwardRef(function EmailShell(props, ref) {
9
+ const { conversations, headerProps, autoCollapse = false, ...restProps } = props;
10
+ const t = useI18n();
11
+ const [activeIndex, setActiveIndex] = useState(0);
12
+ const singleConversation = conversations?.length === 1;
13
+ const renderConversations = () => {
14
+ if (!conversations)
15
+ return;
16
+ if (singleConversation) {
17
+ const conversation = conversations[0];
18
+ return (_jsxs(StyledEmailConversation, { singleConversation: singleConversation, showHeader: !!headerProps, children: [!!conversation.unReadEmailCount && (_jsx(Text, { as: StyledUnReadCount, variant: 'secondary', children: t('new_emails_count', [conversation.unReadEmailCount], {
19
+ count: conversation.unReadEmailCount
20
+ }) })), conversation.emails?.map(email => {
21
+ return _jsx(StyledEmailInConversation, { ...email }, email.id);
22
+ })] }));
23
+ }
24
+ // Multiple conversations
25
+ return autoCollapse
26
+ ? conversations?.map((conversation, index) => {
27
+ const { onExpand, isCollapsed, ...rest } = conversation;
28
+ const collapsed = index !== activeIndex;
29
+ return (_jsx(EmailConversation, { onExpand: () => {
30
+ setActiveIndex(index);
31
+ if (onExpand)
32
+ onExpand();
33
+ }, isCollapsed: collapsed, ...rest }, conversation.id));
34
+ })
35
+ : conversations?.map(conversation => {
36
+ return _jsx(EmailConversation, { ...conversation }, conversation.id);
37
+ });
38
+ };
39
+ return (_jsxs(Flex, { ...restProps, as: StyledEmailShell, container: { direction: 'column', gap: singleConversation ? undefined : 1 }, ref: ref, singleConversation: singleConversation, children: [headerProps && (_jsxs(Flex, { container: {
40
+ alignItems: 'center',
41
+ justify: 'between',
42
+ pad: 1
43
+ }, as: StyledEmailShellHeader, children: [_jsxs(Flex, { container: { gap: 1, alignItems: 'center' }, children: [_jsx(Icon, { name: 'mail' }), _jsx(Text, { variant: 'h3', children: headerProps?.subject ? `${t('subject')}: ${headerProps?.subject} ` : t('email') })] }), headerProps?.actions] })), _jsx(StyledEmailConversationList, { "aria-multiselectable": !autoCollapse, children: renderConversations() })] }));
44
+ });
45
+ export default EmailShell;
46
+ //# sourceMappingURL=EmailShell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmailShell.js","sourceRoot":"","sources":["../../../src/components/Email/EmailShell.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,UAAU,EAAmB,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjF,OAAO,EAAE,IAAI,EAAgB,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAChG,OAAO,KAAK,QAAQ,MAAM,6DAA6D,CAAC;AAGxF,OAAO,iBAA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AAG,EACpB,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,YACf,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,KAAK,WAAW,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAC3E,IACF,EACN,WAAW,EAAE,OAAO,IAChB,CACR,EACD,KAAC,2BAA2B,4BAAuB,CAAC,YAAY,YAC7D,mBAAmB,EAAE,GACM,IACzB,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { FunctionComponent, forwardRef, PropsWithoutRef, useState } from 'react';\n\nimport { Flex, ForwardProps, Icon, registerIcon, Text, useI18n } from '@pega/cosmos-react-core';\nimport * as mailIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/mail.icon';\n\nimport { EmailShellProps } from './Email.types';\nimport EmailConversation, {\n StyledEmailConversation,\n StyledEmailInConversation,\n StyledUnReadCount\n} from './EmailConversation';\nimport {\n StyledEmailConversationList,\n StyledEmailShell,\n StyledEmailShellHeader\n} from './Email.styles';\n\nregisterIcon(mailIcon);\n\nconst EmailShell: FunctionComponent<EmailShellProps & ForwardProps> = forwardRef(\n function EmailShell(props: PropsWithoutRef<EmailShellProps>, ref: EmailShellProps['ref']) {\n const { conversations, headerProps, autoCollapse = false, ...restProps } = props;\n\n const t = useI18n();\n\n const [activeIndex, setActiveIndex] = useState(0);\n\n const singleConversation = conversations?.length === 1;\n\n const renderConversations = () => {\n if (!conversations) return;\n\n if (singleConversation) {\n const conversation = conversations[0];\n return (\n <StyledEmailConversation\n singleConversation={singleConversation}\n showHeader={!!headerProps}\n >\n {!!conversation.unReadEmailCount && (\n <Text as={StyledUnReadCount} variant='secondary'>\n {t('new_emails_count', [conversation.unReadEmailCount], {\n count: conversation.unReadEmailCount\n })}\n </Text>\n )}\n {conversation.emails?.map(email => {\n return <StyledEmailInConversation key={email.id} {...email} />;\n })}\n </StyledEmailConversation>\n );\n }\n\n // Multiple conversations\n return autoCollapse\n ? conversations?.map((conversation, index) => {\n const { onExpand, isCollapsed, ...rest } = conversation;\n const collapsed = index !== activeIndex;\n return (\n <EmailConversation\n key={conversation.id}\n onExpand={() => {\n setActiveIndex(index);\n if (onExpand) onExpand();\n }}\n isCollapsed={collapsed}\n {...rest}\n />\n );\n })\n : conversations?.map(conversation => {\n return <EmailConversation key={conversation.id} {...conversation} />;\n });\n };\n\n return (\n <Flex\n {...restProps}\n as={StyledEmailShell}\n container={{ direction: 'column', gap: singleConversation ? undefined : 1 }}\n ref={ref}\n singleConversation={singleConversation}\n >\n {headerProps && (\n <Flex\n container={{\n alignItems: 'center',\n justify: 'between',\n pad: 1\n }}\n as={StyledEmailShellHeader}\n >\n <Flex container={{ gap: 1, alignItems: 'center' }}>\n <Icon name='mail' />\n <Text variant='h3'>\n {headerProps?.subject ? `${t('subject')}: ${headerProps?.subject} ` : t('email')}\n </Text>\n </Flex>\n {headerProps?.actions}\n </Flex>\n )}\n <StyledEmailConversationList aria-multiselectable={!autoCollapse}>\n {renderConversations()}\n </StyledEmailConversationList>\n </Flex>\n );\n }\n);\n\nexport default EmailShell;\n"]}
@@ -0,0 +1,11 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { ForwardProps } from '@pega/cosmos-react-core';
3
+ import { EmailSummaryItemProps } from './Email.types';
4
+ export declare const StyledMessageAndDate: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
5
+ interface StyledEmailSummaryItemProps extends EmailSummaryItemProps {
6
+ isEmailItemActive: boolean;
7
+ }
8
+ export declare const StyledEmailSummaryItem: import("styled-components").StyledComponent<"li", import("styled-components").DefaultTheme, StyledEmailSummaryItemProps & ForwardProps, never>;
9
+ declare const EmailSummaryItem: FunctionComponent<EmailSummaryItemProps & ForwardProps>;
10
+ export default EmailSummaryItem;
11
+ //# sourceMappingURL=EmailSummaryItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmailSummaryItem.d.ts","sourceRoot":"","sources":["../../../src/components/Email/EmailSummaryItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAsB,MAAM,OAAO,CAAC;AAI1E,OAAO,EAEL,YAAY,EAab,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAkBtD,eAAO,MAAM,oBAAoB,yGAEhC,CAAC;AAqBF,UAAU,2BAA4B,SAAQ,qBAAqB;IACjE,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAID,eAAO,MAAM,sBAAsB,gJAiClC,CAAC;AAMF,QAAA,MAAM,gBAAgB,EAAE,iBAAiB,CAAC,qBAAqB,GAAG,YAAY,CAqH7E,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,118 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useMemo } from 'react';
3
+ import styled, { css } from 'styled-components';
4
+ import { mix } from 'polished';
5
+ import { defaultThemeProp, Text, Flex, Count, Sentiment, MetaList, DateTimeDisplay, Status, tryCatch, useI18n, replaceMatchWithElement, Mark, createStringMatcher } from '@pega/cosmos-react-core';
6
+ import { StyledMetaList } from '@pega/cosmos-react-core/lib/components/MetaList/MetaList';
7
+ const StyledMessage = styled(Flex)(({ unreadEmailCount, theme }) => {
8
+ return css `
9
+ width: ${theme.base['content-width'].md};
10
+ text-align: start;
11
+ text-overflow: ellipsis;
12
+ overflow: hidden;
13
+ margin-inline-end: ${theme.base.spacing};
14
+ margin-block-end: ${theme.base.spacing};
15
+ ${unreadEmailCount !== undefined &&
16
+ unreadEmailCount > 0 &&
17
+ css `
18
+ color: ${theme.base.palette.interactive};
19
+ `}
20
+ `;
21
+ });
22
+ export const StyledMessageAndDate = styled.div `
23
+ white-space: nowrap;
24
+ `;
25
+ const StyledParticipants = styled(Flex)(({ unreadEmailCount, theme }) => {
26
+ return css `
27
+ ${unreadEmailCount !== undefined &&
28
+ unreadEmailCount > 0 &&
29
+ css `
30
+ position: relative;
31
+ &::before {
32
+ content: '';
33
+ position: absolute;
34
+ inset-inline: calc(-1.5 * ${theme.base.spacing});
35
+ inset-block-start: calc(0.8 * ${theme.base.spacing});
36
+ width: 0.5rem;
37
+ height: 0.5rem;
38
+ border-radius: 50%;
39
+ background-color: ${theme.base.palette.interactive};
40
+ }
41
+ `}
42
+ `;
43
+ });
44
+ const StyledStatuses = styled.div ``;
45
+ export const StyledEmailSummaryItem = styled.li(({ theme }) => {
46
+ const hoverColor = tryCatch(() => mix(0.85, theme.base.palette['primary-background'], theme.base.palette.interactive));
47
+ return css `
48
+ width: 100%;
49
+ color: ${theme.base.palette['foreground-color']};
50
+ background-color: ${theme.base.palette['primary-background']};
51
+ padding: ${theme.base.spacing} calc(2 * ${theme.base.spacing});
52
+ outline: none;
53
+ cursor: pointer;
54
+ ${StyledMetaList}, ${StyledMessageAndDate}, ${StyledStatuses} {
55
+ margin-block-start: ${theme.base.spacing};
56
+ }
57
+ & + & {
58
+ margin-inline-start: 0;
59
+ }
60
+
61
+ &[aria-selected='true'],
62
+ &[data-current='true'] {
63
+ background-color: ${theme.base.palette['secondary-background']};
64
+ }
65
+
66
+ &:hover,
67
+ &:focus-within {
68
+ background-color: ${hoverColor};
69
+ }
70
+ &:not(:last-child) {
71
+ border-block-end: 0.0625rem solid ${theme.base.palette['border-line']};
72
+ }
73
+ `;
74
+ });
75
+ StyledEmailSummaryItem.defaultProps = defaultThemeProp;
76
+ StyledParticipants.defaultProps = defaultThemeProp;
77
+ StyledMessage.defaultProps = defaultThemeProp;
78
+ const EmailSummaryItem = forwardRef(function EmailSummaryItem({ id, activeParticipants, sentiment, message, timeStamp, topic, urgency, active = false, onSelect, unreadEmailCount, drafts, undelivered, searchQuery, ...restProps }, ref) {
79
+ const t = useI18n();
80
+ const items = useMemo(() => {
81
+ const itemList = [];
82
+ if (typeof topic === 'string' && topic.length > 0) {
83
+ itemList.push(_jsx(Status, { variant: 'info', children: topic }, 'info'));
84
+ }
85
+ if (sentiment) {
86
+ itemList.push(_jsx(Sentiment, { variant: sentiment.variant, labelHidden: true }));
87
+ }
88
+ if (typeof urgency === 'number') {
89
+ itemList.push(_jsx(Text, { variant: 'secondary', children: `${t('priority')} ${urgency}` }));
90
+ }
91
+ return itemList;
92
+ }, [sentiment, topic, urgency]);
93
+ const emailParticipants = useMemo(() => {
94
+ let participants = '';
95
+ if (activeParticipants.length > 0) {
96
+ participants =
97
+ activeParticipants.length === 1
98
+ ? activeParticipants[0].fullName
99
+ : activeParticipants.map(participant => `${participant.shortName}`).join(', ');
100
+ }
101
+ return participants;
102
+ }, [activeParticipants]);
103
+ const itemStatus = `${unreadEmailCount ? `${t('unread')}, ` : ''}${undelivered ? `${t('undelivered')}, ` : ''}${drafts ? `${t('drafts')}, ` : ''}`;
104
+ return (_jsxs(StyledEmailSummaryItem, { ref: ref, ...restProps, id: id, onClick: () => onSelect(id), onKeyDown: (e) => {
105
+ if (e.key === 'Enter') {
106
+ onSelect(id);
107
+ }
108
+ }, "aria-selected": active, "aria-label": `${itemStatus}${emailParticipants}, ${message} ${timeStamp} ${topic} ${sentiment?.variant} ${t('priority')} ${urgency}`, tabIndex: active ? 0 : -1, children: [_jsxs(StyledParticipants, { unreadEmailCount: unreadEmailCount, container: { justify: 'between', alignItems: 'center' }, children: [_jsx(Text, { variant: 'h4', children: searchQuery
109
+ ? replaceMatchWithElement(emailParticipants, createStringMatcher(searchQuery, 'contains', 'ig'), match => _jsx(Mark, { children: match }))
110
+ : emailParticipants }), typeof unreadEmailCount === 'number' && unreadEmailCount > 0 && (_jsx(Count, { children: unreadEmailCount }))] }), _jsxs(Flex, { container: {
111
+ justify: 'between'
112
+ }, as: StyledMessageAndDate, children: [_jsx(StyledMessage, { unreadEmailCount: unreadEmailCount, children: message }), _jsx(DateTimeDisplay, { value: timeStamp, variant: 'date', format: 'short' })] }), _jsx(MetaList, { items: items }), (undelivered || drafts) && (_jsxs(Flex, { container: {
113
+ justify: 'start',
114
+ gap: 1
115
+ }, as: StyledStatuses, children: [undelivered && _jsx(Status, { variant: 'urgent', children: t('undelivered') }), drafts && _jsx(Status, { variant: 'pending', children: t('draft', [], { count: Infinity }) })] }))] }));
116
+ });
117
+ export default EmailSummaryItem;
118
+ //# sourceMappingURL=EmailSummaryItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmailSummaryItem.js","sourceRoot":"","sources":["../../../src/components/Email/EmailSummaryItem.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAgC,OAAO,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,OAAO,EACL,gBAAgB,EAEhB,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,SAAS,EACT,QAAQ,EACR,eAAe,EACf,MAAM,EACN,QAAQ,EACR,OAAO,EACP,uBAAuB,EACvB,IAAI,EACJ,mBAAmB,EACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,0DAA0D,CAAC;AAI1F,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,CAAwB,CAAC,EAAE,gBAAgB,EAAE,KAAK,EAAE,EAAE,EAAE;IACxF,OAAO,GAAG,CAAA;aACC,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE;;;;yBAIlB,KAAK,CAAC,IAAI,CAAC,OAAO;wBACnB,KAAK,CAAC,IAAI,CAAC,OAAO;MACpC,gBAAgB,KAAK,SAAS;QAChC,gBAAgB,GAAG,CAAC;QACpB,GAAG,CAAA;eACQ,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW;KACxC;GACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAA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AC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, ReactNode, useMemo } from 'react';\nimport styled, { css } from 'styled-components';\nimport { mix } from 'polished';\n\nimport {\n defaultThemeProp,\n ForwardProps,\n Text,\n Flex,\n Count,\n Sentiment,\n MetaList,\n DateTimeDisplay,\n Status,\n tryCatch,\n useI18n,\n replaceMatchWithElement,\n Mark,\n createStringMatcher\n} from '@pega/cosmos-react-core';\nimport { StyledMetaList } from '@pega/cosmos-react-core/lib/components/MetaList/MetaList';\n\nimport { EmailSummaryItemProps } from './Email.types';\n\nconst StyledMessage = styled(Flex)<EmailSummaryItemProps>(({ unreadEmailCount, theme }) => {\n return css`\n width: ${theme.base['content-width'].md};\n text-align: start;\n text-overflow: ellipsis;\n overflow: hidden;\n margin-inline-end: ${theme.base.spacing};\n margin-block-end: ${theme.base.spacing};\n ${unreadEmailCount !== undefined &&\n unreadEmailCount > 0 &&\n css`\n color: ${theme.base.palette.interactive};\n `}\n `;\n});\n\nexport const StyledMessageAndDate = styled.div`\n white-space: nowrap;\n`;\n\nconst StyledParticipants = styled(Flex)<EmailSummaryItemProps>(({ unreadEmailCount, theme }) => {\n return css`\n ${unreadEmailCount !== undefined &&\n unreadEmailCount > 0 &&\n css`\n position: relative;\n &::before {\n content: '';\n position: absolute;\n inset-inline: calc(-1.5 * ${theme.base.spacing});\n inset-block-start: calc(0.8 * ${theme.base.spacing});\n width: 0.5rem;\n height: 0.5rem;\n border-radius: 50%;\n background-color: ${theme.base.palette.interactive};\n }\n `}\n `;\n});\ninterface StyledEmailSummaryItemProps extends EmailSummaryItemProps {\n isEmailItemActive: boolean;\n}\n\nconst StyledStatuses = styled.div``;\n\nexport const StyledEmailSummaryItem = styled.li<StyledEmailSummaryItemProps & ForwardProps>(\n ({ theme }) => {\n const hoverColor = tryCatch(() =>\n mix(0.85, theme.base.palette['primary-background'], theme.base.palette.interactive)\n );\n return css`\n width: 100%;\n color: ${theme.base.palette['foreground-color']};\n background-color: ${theme.base.palette['primary-background']};\n padding: ${theme.base.spacing} calc(2 * ${theme.base.spacing});\n outline: none;\n cursor: pointer;\n ${StyledMetaList}, ${StyledMessageAndDate}, ${StyledStatuses} {\n margin-block-start: ${theme.base.spacing};\n }\n & + & {\n margin-inline-start: 0;\n }\n\n &[aria-selected='true'],\n &[data-current='true'] {\n background-color: ${theme.base.palette['secondary-background']};\n }\n\n &:hover,\n &:focus-within {\n background-color: ${hoverColor};\n }\n &:not(:last-child) {\n border-block-end: 0.0625rem solid ${theme.base.palette['border-line']};\n }\n `;\n }\n);\n\nStyledEmailSummaryItem.defaultProps = defaultThemeProp;\nStyledParticipants.defaultProps = defaultThemeProp;\nStyledMessage.defaultProps = defaultThemeProp;\n\nconst EmailSummaryItem: FunctionComponent<EmailSummaryItemProps & ForwardProps> = forwardRef(\n function EmailSummaryItem(\n {\n id,\n activeParticipants,\n sentiment,\n message,\n timeStamp,\n topic,\n urgency,\n active = false,\n onSelect,\n unreadEmailCount,\n drafts,\n undelivered,\n searchQuery,\n ...restProps\n },\n ref: EmailSummaryItemProps['ref']\n ) {\n const t = useI18n();\n const items = useMemo(() => {\n const itemList: ReactNode[] = [];\n\n if (typeof topic === 'string' && topic.length > 0) {\n itemList.push(\n <Status variant='info' key='info'>\n {topic}\n </Status>\n );\n }\n\n if (sentiment) {\n itemList.push(<Sentiment variant={sentiment.variant} labelHidden />);\n }\n\n if (typeof urgency === 'number') {\n itemList.push(<Text variant='secondary'>{`${t('priority')} ${urgency}`}</Text>);\n }\n\n return itemList;\n }, [sentiment, topic, urgency]);\n\n const emailParticipants = useMemo(() => {\n let participants = '';\n if (activeParticipants.length > 0) {\n participants =\n activeParticipants.length === 1\n ? activeParticipants[0].fullName\n : activeParticipants.map(participant => `${participant.shortName}`).join(', ');\n }\n return participants;\n }, [activeParticipants]);\n const itemStatus = `${unreadEmailCount ? `${t('unread')}, ` : ''}${\n undelivered ? `${t('undelivered')}, ` : ''\n }${drafts ? `${t('drafts')}, ` : ''}`;\n return (\n <StyledEmailSummaryItem\n ref={ref}\n {...restProps}\n id={id}\n onClick={() => onSelect(id)}\n onKeyDown={(e: KeyboardEvent) => {\n if (e.key === 'Enter') {\n onSelect(id);\n }\n }}\n aria-selected={active}\n aria-label={`${itemStatus}${emailParticipants}, ${message} ${timeStamp} ${topic} ${\n sentiment?.variant\n } ${t('priority')} ${urgency}`}\n tabIndex={active ? 0 : -1}\n >\n <StyledParticipants\n unreadEmailCount={unreadEmailCount}\n container={{ justify: 'between', alignItems: 'center' }}\n >\n <Text variant='h4'>\n {searchQuery\n ? replaceMatchWithElement(\n emailParticipants,\n createStringMatcher(searchQuery, 'contains', 'ig'),\n match => <Mark>{match}</Mark>\n )\n : emailParticipants}\n </Text>\n {typeof unreadEmailCount === 'number' && unreadEmailCount > 0 && (\n <Count>{unreadEmailCount}</Count>\n )}\n </StyledParticipants>\n <Flex\n container={{\n justify: 'between'\n }}\n as={StyledMessageAndDate}\n >\n <StyledMessage unreadEmailCount={unreadEmailCount}>{message}</StyledMessage>\n <DateTimeDisplay value={timeStamp} variant='date' format='short' />\n </Flex>\n <MetaList items={items} />\n {(undelivered || drafts) && (\n <Flex\n container={{\n justify: 'start',\n gap: 1\n }}\n as={StyledStatuses}\n >\n {undelivered && <Status variant='urgent'>{t('undelivered')}</Status>}\n {/* Passing count as infinity so that translation engine select correct form of draft,\n with [](second argument) as empty so that count is not shown */}\n {drafts && <Status variant='pending'>{t('draft', [], { count: Infinity })}</Status>}\n </Flex>\n )}\n </StyledEmailSummaryItem>\n );\n }\n);\n\nexport default EmailSummaryItem;\n"]}
@@ -0,0 +1,6 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { ForwardProps } from '@pega/cosmos-react-core';
3
+ import { EmailSummaryListProps } from './Email.types';
4
+ declare const EmailSummaryList: FunctionComponent<EmailSummaryListProps & ForwardProps>;
5
+ export default EmailSummaryList;
6
+ //# sourceMappingURL=EmailSummaryList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmailSummaryList.d.ts","sourceRoot":"","sources":["../../../src/components/Email/EmailSummaryList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,iBAAiB,EAElB,MAAM,OAAO,CAAC;AAGf,OAAO,EAKL,YAAY,EAgBb,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAyB,qBAAqB,EAAE,MAAM,eAAe,CAAC;AA6C7E,QAAA,MAAM,gBAAgB,EAAE,iBAAiB,CAAC,qBAAqB,GAAG,YAAY,CAsJ7E,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,95 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createRef, useMemo, useState, useEffect, forwardRef, useCallback } from 'react';
3
+ import styled, { css } from 'styled-components';
4
+ import { Button, Count, defaultThemeProp, Flex, Icon, registerIcon, MenuButton, useConsolidatedRef, useI18n, menuHelpers, Progress, useItemIntersection, usePrevious, VisuallyHiddenText, EmptyState, calculateFontSize, StyledText, useArrows, debounce } from '@pega/cosmos-react-core';
5
+ import * as filterIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/filter.icon';
6
+ import EmailSummaryItem from './EmailSummaryItem';
7
+ import { StyledEmailSummaryList, StyledLoadMore } from './Email.styles';
8
+ registerIcon(filterIcon);
9
+ const StyledEmailSummaryListContainer = styled(Flex)(({ theme }) => {
10
+ return css `
11
+ height: 100%;
12
+ background-color: ${theme.base.palette['primary-background']};
13
+ `;
14
+ });
15
+ StyledEmailSummaryListContainer.defaultProps = defaultThemeProp;
16
+ const StyledEmailSummaryListHeader = styled.div(({ theme }) => {
17
+ return css `
18
+ padding: calc(2 * ${theme.base.spacing}) calc(2 * ${theme.base.spacing}) ${theme.base.spacing};
19
+ `;
20
+ });
21
+ StyledEmailSummaryListHeader.defaultProps = defaultThemeProp;
22
+ const StyledActionWrapper = styled(Flex)(({ theme }) => {
23
+ return css `
24
+ padding-block-start: ${theme.base.spacing};
25
+ `;
26
+ });
27
+ StyledActionWrapper.defaultProps = defaultThemeProp;
28
+ const StyledFilterButton = styled(Button) `
29
+ margin-inline-start: auto;
30
+ `;
31
+ const StyledWorklist = styled(MenuButton)(({ theme }) => {
32
+ const { 'font-size': fontSize, 'font-scale': fontScale } = theme.base;
33
+ const fontSizes = calculateFontSize(fontSize, fontScale);
34
+ return css `
35
+ ${StyledText} {
36
+ font-weight: ${theme.base['font-weight']['semi-bold']};
37
+ font-size: ${fontSizes.m};
38
+ }
39
+ `;
40
+ });
41
+ StyledWorklist.defaultProps = defaultThemeProp;
42
+ const EmailSummaryList = forwardRef(function EmailSummaryList({ loading = false, onLoadMore, categories, onCategoryClick, items, unreadEmailCount, filters, onFilterChange, onItemClick, emptyMessage, currentItemId, selectable = true, searchQuery, ...restProps }, ref) {
43
+ const t = useI18n();
44
+ const tablistRef = useConsolidatedRef(ref);
45
+ const tabRefs = items.map(() => createRef());
46
+ const prevEmail = usePrevious(items);
47
+ const [announcement, setAnnouncement] = useState('');
48
+ useArrows(tablistRef, {
49
+ cycle: true,
50
+ selector: ':scope > li',
51
+ dir: 'up-down',
52
+ updateTabIndex: false
53
+ }, [items]);
54
+ const buttonText = useMemo(() => {
55
+ if (categories)
56
+ return (menuHelpers.getSelected(categories)[0]?.primary ??
57
+ menuHelpers.flatten(categories)[0].primary);
58
+ }, [categories]);
59
+ const handleLoadMore = useCallback(debounce(() => {
60
+ if (!loading) {
61
+ onLoadMore?.();
62
+ }
63
+ }, 200), [loading]);
64
+ useItemIntersection(tablistRef, items.length - 1, handleLoadMore, ':scope > li');
65
+ useEffect(() => {
66
+ if (loading)
67
+ setAnnouncement(t('loading_email'));
68
+ }, [loading]);
69
+ useEffect(() => {
70
+ if (prevEmail) {
71
+ const difference = items.length - prevEmail.length;
72
+ if (difference)
73
+ setAnnouncement(t('new_emails_count', [difference], { count: difference }));
74
+ }
75
+ }, [items]);
76
+ useEffect(() => {
77
+ if (tabRefs.length > 0 && currentItemId) {
78
+ tabRefs[items.findIndex(item => item.id === currentItemId)]?.current?.focus();
79
+ }
80
+ }, [currentItemId]);
81
+ return (_jsxs(StyledEmailSummaryListContainer, { container: { direction: 'column' }, ...restProps, children: [!!(categories?.length || searchQuery) && (_jsx(StyledEmailSummaryListHeader, { children: _jsxs(StyledActionWrapper, { container: { justify: 'space-between', alignItems: 'center', gap: 0.5 }, children: [_jsx(Flex, { item: { shrink: 1 }, children: searchQuery ? (_jsx(StyledText, { variant: 'h3', children: t('search_results') })) : (_jsx(StyledWorklist, { text: buttonText, variant: 'text', popover: { portal: true }, menu: {
82
+ mode: 'single-select',
83
+ items: categories,
84
+ onItemClick: onCategoryClick
85
+ } })) }), !searchQuery && typeof unreadEmailCount === 'number' && (_jsx(Count, { "aria-label": t('unread_email_count', [unreadEmailCount], {
86
+ count: unreadEmailCount
87
+ }), children: unreadEmailCount })), filters && (_jsx(StyledFilterButton, { variant: 'simple', label: t('email_filters'), icon: true, children: _jsx(Icon, { name: 'filter' }) }))] }) })), items.length > 0 ? (_jsxs(Flex, { role: selectable ? 'tablist' : undefined, container: { direction: 'column' }, as: StyledEmailSummaryList, ref: tablistRef, children: [_jsx(VisuallyHiddenText, { "aria-live": 'polite', children: announcement }), items.map((emailItem, i) => {
88
+ const { id, ...emailItemProps } = emailItem;
89
+ return (_jsx(EmailSummaryItem, { searchQuery: searchQuery, ref: tabRefs[i], id: id, ...emailItemProps, onSelect: (selectedItemId) => {
90
+ onItemClick(selectedItemId);
91
+ }, role: selectable ? 'tab' : undefined, active: selectable ? currentItemId === id : undefined }, id));
92
+ }), loading && (_jsx(Flex, { container: { justify: 'center' }, as: StyledLoadMore, children: _jsx(Progress, { placement: 'inline' }) }))] })) : (_jsx(EmptyState, { message: emptyMessage }))] }));
93
+ });
94
+ export default EmailSummaryList;
95
+ //# sourceMappingURL=EmailSummaryList.js.map