@pega/cosmos-react-social 2.1.6 → 2.1.7

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 (197) hide show
  1. package/lib/components/Chat/Chat.d.ts +31 -0
  2. package/lib/components/Chat/Chat.d.ts.map +1 -0
  3. package/lib/components/Chat/Chat.js +67 -0
  4. package/lib/components/Chat/Chat.js.map +1 -0
  5. package/lib/components/Chat/Chat.types.d.ts +23 -0
  6. package/lib/components/Chat/Chat.types.d.ts.map +1 -0
  7. package/lib/components/Chat/Chat.types.js +2 -0
  8. package/lib/components/Chat/Chat.types.js.map +1 -0
  9. package/lib/components/Chat/ChatBody.d.ts +12 -0
  10. package/lib/components/Chat/ChatBody.d.ts.map +1 -0
  11. package/lib/components/Chat/ChatBody.js +18 -0
  12. package/lib/components/Chat/ChatBody.js.map +1 -0
  13. package/lib/components/Chat/ChatComposer.d.ts +51 -0
  14. package/lib/components/Chat/ChatComposer.d.ts.map +1 -0
  15. package/lib/components/Chat/ChatComposer.js +213 -0
  16. package/lib/components/Chat/ChatComposer.js.map +1 -0
  17. package/lib/components/Chat/ChatHeader.d.ts +15 -0
  18. package/lib/components/Chat/ChatHeader.d.ts.map +1 -0
  19. package/lib/components/Chat/ChatHeader.js +28 -0
  20. package/lib/components/Chat/ChatHeader.js.map +1 -0
  21. package/lib/components/Chat/ChatTranscript.d.ts +23 -0
  22. package/lib/components/Chat/ChatTranscript.d.ts.map +1 -0
  23. package/lib/components/Chat/ChatTranscript.js +45 -0
  24. package/lib/components/Chat/ChatTranscript.js.map +1 -0
  25. package/lib/components/Chat/Message.d.ts +46 -0
  26. package/lib/components/Chat/Message.d.ts.map +1 -0
  27. package/lib/components/Chat/Message.js +59 -0
  28. package/lib/components/Chat/Message.js.map +1 -0
  29. package/lib/components/Chat/Message.styles.d.ts +29 -0
  30. package/lib/components/Chat/Message.styles.d.ts.map +1 -0
  31. package/lib/components/Chat/Message.styles.js +193 -0
  32. package/lib/components/Chat/Message.styles.js.map +1 -0
  33. package/lib/components/Chat/MessageList.d.ts +35 -0
  34. package/lib/components/Chat/MessageList.d.ts.map +1 -0
  35. package/lib/components/Chat/MessageList.js +123 -0
  36. package/lib/components/Chat/MessageList.js.map +1 -0
  37. package/lib/components/Chat/RepeatingView.d.ts +31 -0
  38. package/lib/components/Chat/RepeatingView.d.ts.map +1 -0
  39. package/lib/components/Chat/RepeatingView.js +47 -0
  40. package/lib/components/Chat/RepeatingView.js.map +1 -0
  41. package/lib/components/Chat/SuggestedReplyPicker.d.ts +26 -0
  42. package/lib/components/Chat/SuggestedReplyPicker.d.ts.map +1 -0
  43. package/lib/components/Chat/SuggestedReplyPicker.js +78 -0
  44. package/lib/components/Chat/SuggestedReplyPicker.js.map +1 -0
  45. package/lib/components/Chat/SystemMessage.d.ts +19 -0
  46. package/lib/components/Chat/SystemMessage.d.ts.map +1 -0
  47. package/lib/components/Chat/SystemMessage.js +40 -0
  48. package/lib/components/Chat/SystemMessage.js.map +1 -0
  49. package/lib/components/Chat/TranscriptMessage.d.ts +25 -0
  50. package/lib/components/Chat/TranscriptMessage.d.ts.map +1 -0
  51. package/lib/components/Chat/TranscriptMessage.js +47 -0
  52. package/lib/components/Chat/TranscriptMessage.js.map +1 -0
  53. package/lib/components/Chat/TypeIndicator.d.ts +13 -0
  54. package/lib/components/Chat/TypeIndicator.d.ts.map +1 -0
  55. package/lib/components/Chat/TypeIndicator.js +9 -0
  56. package/lib/components/Chat/TypeIndicator.js.map +1 -0
  57. package/lib/components/Chat/index.d.ts +14 -0
  58. package/lib/components/Chat/index.d.ts.map +1 -0
  59. package/lib/components/Chat/index.js +13 -0
  60. package/lib/components/Chat/index.js.map +1 -0
  61. package/lib/components/Email/Email.d.ts +6 -0
  62. package/lib/components/Email/Email.d.ts.map +1 -0
  63. package/lib/components/Email/Email.js +153 -0
  64. package/lib/components/Email/Email.js.map +1 -0
  65. package/lib/components/Email/Email.styles.d.ts +18 -0
  66. package/lib/components/Email/Email.styles.d.ts.map +1 -0
  67. package/lib/components/Email/Email.styles.js +131 -0
  68. package/lib/components/Email/Email.styles.js.map +1 -0
  69. package/lib/components/Email/Email.types.d.ts +237 -0
  70. package/lib/components/Email/Email.types.d.ts.map +1 -0
  71. package/lib/components/Email/Email.types.js +2 -0
  72. package/lib/components/Email/Email.types.js.map +1 -0
  73. package/lib/components/Email/EmailComposer.d.ts +9 -0
  74. package/lib/components/Email/EmailComposer.d.ts.map +1 -0
  75. package/lib/components/Email/EmailComposer.js +185 -0
  76. package/lib/components/Email/EmailComposer.js.map +1 -0
  77. package/lib/components/Email/EmailConversation.d.ts +14 -0
  78. package/lib/components/Email/EmailConversation.d.ts.map +1 -0
  79. package/lib/components/Email/EmailConversation.js +179 -0
  80. package/lib/components/Email/EmailConversation.js.map +1 -0
  81. package/lib/components/Email/EmailEntity.d.ts +6 -0
  82. package/lib/components/Email/EmailEntity.d.ts.map +1 -0
  83. package/lib/components/Email/EmailEntity.js +19 -0
  84. package/lib/components/Email/EmailEntity.js.map +1 -0
  85. package/lib/components/Email/EmailSelector.d.ts +19 -0
  86. package/lib/components/Email/EmailSelector.d.ts.map +1 -0
  87. package/lib/components/Email/EmailSelector.js +103 -0
  88. package/lib/components/Email/EmailSelector.js.map +1 -0
  89. package/lib/components/Email/EmailShell.d.ts +9 -0
  90. package/lib/components/Email/EmailShell.d.ts.map +1 -0
  91. package/lib/components/Email/EmailShell.js +56 -0
  92. package/lib/components/Email/EmailShell.js.map +1 -0
  93. package/lib/components/Email/EmailSummaryItem.d.ts +10 -0
  94. package/lib/components/Email/EmailSummaryItem.d.ts.map +1 -0
  95. package/lib/components/Email/EmailSummaryItem.js +93 -0
  96. package/lib/components/Email/EmailSummaryItem.js.map +1 -0
  97. package/lib/components/Email/EmailSummaryList.d.ts +6 -0
  98. package/lib/components/Email/EmailSummaryList.d.ts.map +1 -0
  99. package/lib/components/Email/EmailSummaryList.js +115 -0
  100. package/lib/components/Email/EmailSummaryList.js.map +1 -0
  101. package/lib/components/Email/ViewAnalysis.d.ts +6 -0
  102. package/lib/components/Email/ViewAnalysis.d.ts.map +1 -0
  103. package/lib/components/Email/ViewAnalysis.js +20 -0
  104. package/lib/components/Email/ViewAnalysis.js.map +1 -0
  105. package/lib/components/Email/index.d.ts +9 -0
  106. package/lib/components/Email/index.d.ts.map +1 -0
  107. package/lib/components/Email/index.js +8 -0
  108. package/lib/components/Email/index.js.map +1 -0
  109. package/lib/components/Feed/Feed.context.d.ts +35 -0
  110. package/lib/components/Feed/Feed.context.d.ts.map +1 -0
  111. package/lib/components/Feed/Feed.context.js +8 -0
  112. package/lib/components/Feed/Feed.context.js.map +1 -0
  113. package/lib/components/Feed/Feed.d.ts +52 -0
  114. package/lib/components/Feed/Feed.d.ts.map +1 -0
  115. package/lib/components/Feed/Feed.js +143 -0
  116. package/lib/components/Feed/Feed.js.map +1 -0
  117. package/lib/components/Feed/FeedAnnouncer.d.ts +7 -0
  118. package/lib/components/Feed/FeedAnnouncer.d.ts.map +1 -0
  119. package/lib/components/Feed/FeedAnnouncer.js +11 -0
  120. package/lib/components/Feed/FeedAnnouncer.js.map +1 -0
  121. package/lib/components/Feed/FeedAttachments.d.ts +14 -0
  122. package/lib/components/Feed/FeedAttachments.d.ts.map +1 -0
  123. package/lib/components/Feed/FeedAttachments.js +94 -0
  124. package/lib/components/Feed/FeedAttachments.js.map +1 -0
  125. package/lib/components/Feed/FeedButton.d.ts +6 -0
  126. package/lib/components/Feed/FeedButton.d.ts.map +1 -0
  127. package/lib/components/Feed/FeedButton.js +23 -0
  128. package/lib/components/Feed/FeedButton.js.map +1 -0
  129. package/lib/components/Feed/FeedContent.d.ts +14 -0
  130. package/lib/components/Feed/FeedContent.d.ts.map +1 -0
  131. package/lib/components/Feed/FeedContent.js +39 -0
  132. package/lib/components/Feed/FeedContent.js.map +1 -0
  133. package/lib/components/Feed/FeedLikeButton.d.ts +19 -0
  134. package/lib/components/Feed/FeedLikeButton.d.ts.map +1 -0
  135. package/lib/components/Feed/FeedLikeButton.js +87 -0
  136. package/lib/components/Feed/FeedLikeButton.js.map +1 -0
  137. package/lib/components/Feed/FeedModalList.d.ts +15 -0
  138. package/lib/components/Feed/FeedModalList.d.ts.map +1 -0
  139. package/lib/components/Feed/FeedModalList.js +49 -0
  140. package/lib/components/Feed/FeedModalList.js.map +1 -0
  141. package/lib/components/Feed/FeedNewPost.d.ts +36 -0
  142. package/lib/components/Feed/FeedNewPost.d.ts.map +1 -0
  143. package/lib/components/Feed/FeedNewPost.js +108 -0
  144. package/lib/components/Feed/FeedNewPost.js.map +1 -0
  145. package/lib/components/Feed/FeedNewPostTypeMenu.d.ts +35 -0
  146. package/lib/components/Feed/FeedNewPostTypeMenu.d.ts.map +1 -0
  147. package/lib/components/Feed/FeedNewPostTypeMenu.js +387 -0
  148. package/lib/components/Feed/FeedNewPostTypeMenu.js.map +1 -0
  149. package/lib/components/Feed/FeedPost.d.ts +10 -0
  150. package/lib/components/Feed/FeedPost.d.ts.map +1 -0
  151. package/lib/components/Feed/FeedPost.js +185 -0
  152. package/lib/components/Feed/FeedPost.js.map +1 -0
  153. package/lib/components/Feed/FeedPost.types.d.ts +101 -0
  154. package/lib/components/Feed/FeedPost.types.d.ts.map +1 -0
  155. package/lib/components/Feed/FeedPost.types.js +2 -0
  156. package/lib/components/Feed/FeedPost.types.js.map +1 -0
  157. package/lib/components/Feed/FeedReply.d.ts +10 -0
  158. package/lib/components/Feed/FeedReply.d.ts.map +1 -0
  159. package/lib/components/Feed/FeedReply.js +131 -0
  160. package/lib/components/Feed/FeedReply.js.map +1 -0
  161. package/lib/components/Feed/FeedReply.types.d.ts +68 -0
  162. package/lib/components/Feed/FeedReply.types.d.ts.map +1 -0
  163. package/lib/components/Feed/FeedReply.types.js +2 -0
  164. package/lib/components/Feed/FeedReply.types.js.map +1 -0
  165. package/lib/components/Feed/FeedReplyInput.d.ts +32 -0
  166. package/lib/components/Feed/FeedReplyInput.d.ts.map +1 -0
  167. package/lib/components/Feed/FeedReplyInput.js +105 -0
  168. package/lib/components/Feed/FeedReplyInput.js.map +1 -0
  169. package/lib/components/Feed/FeedRichText.d.ts +9 -0
  170. package/lib/components/Feed/FeedRichText.d.ts.map +1 -0
  171. package/lib/components/Feed/FeedRichText.js +96 -0
  172. package/lib/components/Feed/FeedRichText.js.map +1 -0
  173. package/lib/components/Feed/index.d.ts +10 -0
  174. package/lib/components/Feed/index.d.ts.map +1 -0
  175. package/lib/components/Feed/index.js +6 -0
  176. package/lib/components/Feed/index.js.map +1 -0
  177. package/lib/components/HashtagButton/HashtagButton.d.ts +16 -0
  178. package/lib/components/HashtagButton/HashtagButton.d.ts.map +1 -0
  179. package/lib/components/HashtagButton/HashtagButton.js +31 -0
  180. package/lib/components/HashtagButton/HashtagButton.js.map +1 -0
  181. package/lib/components/HashtagButton/index.d.ts +3 -0
  182. package/lib/components/HashtagButton/index.d.ts.map +1 -0
  183. package/lib/components/HashtagButton/index.js +3 -0
  184. package/lib/components/HashtagButton/index.js.map +1 -0
  185. package/lib/components/MentionButton/MentionButton.d.ts +20 -0
  186. package/lib/components/MentionButton/MentionButton.d.ts.map +1 -0
  187. package/lib/components/MentionButton/MentionButton.js +58 -0
  188. package/lib/components/MentionButton/MentionButton.js.map +1 -0
  189. package/lib/components/MentionButton/index.d.ts +3 -0
  190. package/lib/components/MentionButton/index.d.ts.map +1 -0
  191. package/lib/components/MentionButton/index.js +3 -0
  192. package/lib/components/MentionButton/index.js.map +1 -0
  193. package/lib/index.d.ts +11 -0
  194. package/lib/index.d.ts.map +1 -0
  195. package/lib/index.js +12 -0
  196. package/lib/index.js.map +1 -0
  197. package/package.json +4 -4
@@ -0,0 +1,31 @@
1
+ import { ReactElement, FunctionComponent, Ref, ReactNode } from 'react';
2
+ import { BannerProps, ForwardProps, NoChildrenProp } from '@pega/cosmos-react-core';
3
+ import ChatBody from './ChatBody';
4
+ import ChatComposer from './ChatComposer';
5
+ import ChatHeader from './ChatHeader';
6
+ import SuggestedReplyPicker from './SuggestedReplyPicker';
7
+ export declare type ChatBannerProps = {
8
+ /** Content */
9
+ content: string;
10
+ /** Name of the icon */
11
+ icon: string;
12
+ };
13
+ export interface ChatProps extends NoChildrenProp {
14
+ /** ref to the element */
15
+ ref?: Ref<HTMLElement>;
16
+ /** Header of conversation pane */
17
+ header: ReactElement<typeof ChatHeader>;
18
+ /** Utility - This is used by utility container internally. It has predefined styles and visible conditionally based on utility prop is */
19
+ utility?: ReactNode;
20
+ /** Wrapper of message groups, system messages, type ahead */
21
+ body: ReactElement<typeof ChatBody>;
22
+ /** Wrapper of suggested replies */
23
+ suggestedReplyPicker?: ReactElement<typeof SuggestedReplyPicker>;
24
+ /** chat banner */
25
+ banner?: BannerProps;
26
+ /** Wrapper of conversation input, emojis, attachments */
27
+ footer: ReactElement<typeof ChatComposer>;
28
+ }
29
+ declare const Chat: FunctionComponent<ChatProps & ForwardProps>;
30
+ export default Chat;
31
+ //# sourceMappingURL=Chat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/Chat.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,iBAAiB,EAGjB,GAAG,EACH,SAAS,EAGV,MAAM,OAAO,CAAC;AAGf,OAAO,EAGL,WAAW,EAEX,YAAY,EACZ,cAAc,EACf,MAAM,yBAAyB,CAAC;AAGjC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D,oBAAY,eAAe,GAAG;IAC5B,cAAc;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,WAAW,SAAU,SAAQ,cAAc;IAC/C,yBAAyB;IACzB,GAAG,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;IACvB,kCAAkC;IAClC,MAAM,EAAE,YAAY,CAAC,OAAO,UAAU,CAAC,CAAC;IACxC,0IAA0I;IAC1I,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,6DAA6D;IAC7D,IAAI,EAAE,YAAY,CAAC,OAAO,QAAQ,CAAC,CAAC;IACpC,mCAAmC;IACnC,oBAAoB,CAAC,EAAE,YAAY,CAAC,OAAO,oBAAoB,CAAC,CAAC;IACjE,kBAAkB;IAClB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,yDAAyD;IACzD,MAAM,EAAE,YAAY,CAAC,OAAO,YAAY,CAAC,CAAC;CAC3C;AA8DD,QAAA,MAAM,IAAI,EAAE,iBAAiB,CAAC,SAAS,GAAG,YAAY,CAqDrD,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,67 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useRef, useEffect } from 'react';
3
+ import styled, { css } from 'styled-components';
4
+ import { Flex, Banner, defaultThemeProp } from '@pega/cosmos-react-core';
5
+ import { StyledBanner } from '@pega/cosmos-react-core/lib/components/Banner/Banner';
6
+ const StyledUtilityContainer = styled.div ``;
7
+ const StyledUtilityMerger = styled.div ``;
8
+ const StyledUtilityContent = styled.div ``;
9
+ const StyledChatContainer = styled.section(props => {
10
+ const { theme: { base: { spacing, shadow: { high: shadowHigh }, palette: { 'primary-background': primaryBackground, 'secondary-background': secondaryBackground } } } } = props;
11
+ return css `
12
+ height: 100%;
13
+ background: ${primaryBackground};
14
+ width: 100%;
15
+ ${StyledUtilityMerger} {
16
+ min-height: 15rem;
17
+ position: relative;
18
+ height: 100%;
19
+ overflow-y: hidden;
20
+ }
21
+ ${StyledUtilityContainer} {
22
+ position: absolute;
23
+ top: 0;
24
+ left: 0;
25
+ z-index: 2;
26
+ max-height: 60%;
27
+ width: 100%;
28
+ background-color: ${secondaryBackground};
29
+ > ${StyledUtilityContent} {
30
+ padding: ${spacing} 0;
31
+ box-shadow: ${shadowHigh};
32
+ height: auto;
33
+ width: 100%;
34
+ overflow-y: auto;
35
+ background: linear-gradient(${secondaryBackground} 10%, rgba(255, 255, 255, 0)),
36
+ linear-gradient(rgba(255, 255, 255, 0), ${secondaryBackground} 10%) 0 100%,
37
+ radial-gradient(farthest-side at 50% 0, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0)),
38
+ radial-gradient(farthest-side at 50% 100%, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0)) 0 100%;
39
+ background-repeat: no-repeat;
40
+ background-size: 100% 1rem, 100% 1rem, 100% 0.25rem, 100% 0.25rem;
41
+ background-attachment: local, local, scroll, scroll;
42
+ }
43
+ }
44
+ ${StyledBanner} {
45
+ padding: calc(2 * ${spacing});
46
+ margin-bottom: 0;
47
+ flex-shrink: 0;
48
+ }
49
+ `;
50
+ });
51
+ StyledChatContainer.defaultProps = defaultThemeProp;
52
+ const Chat = forwardRef((props, ref) => {
53
+ const { header, body, footer, utility, banner, suggestedReplyPicker, ...restProps } = props;
54
+ const utilityContentRef = useRef(null);
55
+ useEffect(() => {
56
+ utilityContentRef.current?.focus();
57
+ }, [utility]);
58
+ return (_jsxs(Flex, { ref: ref, as: StyledChatContainer, container: {
59
+ direction: 'column'
60
+ }, ...restProps, children: [header, _jsxs(Flex, { container: {
61
+ direction: 'column'
62
+ }, as: StyledUtilityMerger, children: [utility && (_jsx(Flex, { tabIndex: 0, as: StyledUtilityContainer, container: {
63
+ direction: 'column'
64
+ }, children: _jsx(StyledUtilityContent, { ref: utilityContentRef, children: utility }, void 0) }, void 0)), banner && (_jsx(Banner, { id: banner.id, variant: banner.variant, heading: banner.heading, messages: banner.messages }, void 0)), body] }, void 0), suggestedReplyPicker, footer] }, void 0));
65
+ });
66
+ export default Chat;
67
+ //# sourceMappingURL=Chat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Chat.js","sourceRoot":"","sources":["../../../src/components/Chat/Chat.tsx"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AAS,EAAE,GAAG,KAAK,CAAC;IAE5F,MAAM,iBAAiB,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAEvD,SAAS,CAAC,GAAG,EAAE;QACb,iBAAiB,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;IACrC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,OAAO,CACL,MAAC,IAAI,IACH,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,mBAAmB,EACvB,SAAS,EAAE;YACT,SAAS,EAAE,QAAQ;SACpB,KACG,SAAS,aAEZ,MAAM,EACP,MAAC,IAAI,IACH,SAAS,EAAE;oBACT,SAAS,EAAE,QAAQ;iBACpB,EACD,EAAE,EAAE,mBAAmB,aAEtB,OAAO,IAAI,CACV,KAAC,IAAI,IACH,QAAQ,EAAE,CAAC,EACX,EAAE,EAAE,sBAAsB,EAC1B,SAAS,EAAE;4BACT,SAAS,EAAE,QAAQ;yBACpB,YAED,KAAC,oBAAoB,IAAC,GAAG,EAAE,iBAAiB,YAAG,OAAO,WAAwB,WACzE,CACR,EAEA,MAAM,IAAI,CACT,KAAC,MAAM,IACL,EAAE,EAAE,MAAM,CAAC,EAAE,EACb,OAAO,EAAE,MAAM,CAAC,OAAO,EACvB,OAAO,EAAE,MAAM,CAAC,OAAO,EACvB,QAAQ,EAAE,MAAM,CAAC,QAAQ,WACzB,CACH,EACA,IAAI,YACA,EACN,oBAAoB,EACpB,MAAM,YACF,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import {\n ReactElement,\n FunctionComponent,\n forwardRef,\n PropsWithoutRef,\n Ref,\n ReactNode,\n useRef,\n useEffect\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Flex,\n Banner,\n BannerProps,\n defaultThemeProp,\n ForwardProps,\n NoChildrenProp\n} from '@pega/cosmos-react-core';\nimport { StyledBanner } from '@pega/cosmos-react-core/lib/components/Banner/Banner';\n\nimport ChatBody from './ChatBody';\nimport ChatComposer from './ChatComposer';\nimport ChatHeader from './ChatHeader';\nimport SuggestedReplyPicker from './SuggestedReplyPicker';\n\nexport type ChatBannerProps = {\n /** Content */\n content: string;\n /** Name of the icon */\n icon: string;\n};\n\nexport interface ChatProps extends NoChildrenProp {\n /** ref to the element */\n ref?: Ref<HTMLElement>;\n /** Header of conversation pane */\n header: ReactElement<typeof ChatHeader>;\n /** Utility - This is used by utility container internally. It has predefined styles and visible conditionally based on utility prop is */\n utility?: ReactNode;\n /** Wrapper of message groups, system messages, type ahead */\n body: ReactElement<typeof ChatBody>;\n /** Wrapper of suggested replies */\n suggestedReplyPicker?: ReactElement<typeof SuggestedReplyPicker>;\n /** chat banner */\n banner?: BannerProps;\n /** Wrapper of conversation input, emojis, attachments */\n footer: ReactElement<typeof ChatComposer>;\n}\n\nconst StyledUtilityContainer = styled.div``;\nconst StyledUtilityMerger = styled.div``;\nconst StyledUtilityContent = styled.div``;\n\nconst StyledChatContainer = styled.section(props => {\n const {\n theme: {\n base: {\n spacing,\n shadow: { high: shadowHigh },\n palette: {\n 'primary-background': primaryBackground,\n 'secondary-background': secondaryBackground\n }\n }\n }\n } = props;\n return css`\n height: 100%;\n background: ${primaryBackground};\n width: 100%;\n ${StyledUtilityMerger} {\n min-height: 15rem;\n position: relative;\n height: 100%;\n overflow-y: hidden;\n }\n ${StyledUtilityContainer} {\n position: absolute;\n top: 0;\n left: 0;\n z-index: 2;\n max-height: 60%;\n width: 100%;\n background-color: ${secondaryBackground};\n > ${StyledUtilityContent} {\n padding: ${spacing} 0;\n box-shadow: ${shadowHigh};\n height: auto;\n width: 100%;\n overflow-y: auto;\n background: linear-gradient(${secondaryBackground} 10%, rgba(255, 255, 255, 0)),\n linear-gradient(rgba(255, 255, 255, 0), ${secondaryBackground} 10%) 0 100%,\n radial-gradient(farthest-side at 50% 0, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0)),\n radial-gradient(farthest-side at 50% 100%, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0)) 0 100%;\n background-repeat: no-repeat;\n background-size: 100% 1rem, 100% 1rem, 100% 0.25rem, 100% 0.25rem;\n background-attachment: local, local, scroll, scroll;\n }\n }\n ${StyledBanner} {\n padding: calc(2 * ${spacing});\n margin-bottom: 0;\n flex-shrink: 0;\n }\n `;\n});\n\nStyledChatContainer.defaultProps = defaultThemeProp;\n\nconst Chat: FunctionComponent<ChatProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ChatProps>, ref: ChatProps['ref']) => {\n const { header, body, footer, utility, banner, suggestedReplyPicker, ...restProps } = props;\n\n const utilityContentRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n utilityContentRef.current?.focus();\n }, [utility]);\n\n return (\n <Flex\n ref={ref}\n as={StyledChatContainer}\n container={{\n direction: 'column'\n }}\n {...restProps}\n >\n {header}\n <Flex\n container={{\n direction: 'column'\n }}\n as={StyledUtilityMerger}\n >\n {utility && (\n <Flex\n tabIndex={0}\n as={StyledUtilityContainer}\n container={{\n direction: 'column'\n }}\n >\n <StyledUtilityContent ref={utilityContentRef}>{utility}</StyledUtilityContent>\n </Flex>\n )}\n\n {banner && (\n <Banner\n id={banner.id}\n variant={banner.variant}\n heading={banner.heading}\n messages={banner.messages}\n />\n )}\n {body}\n </Flex>\n {suggestedReplyPicker}\n {footer}\n </Flex>\n );\n }\n);\n\nexport default Chat;\n"]}
@@ -0,0 +1,23 @@
1
+ import { BaseProps } from '@pega/cosmos-react-core';
2
+ export interface AttachmentItemProps extends BaseProps {
3
+ /** Unique Id for this attachment */
4
+ id: string;
5
+ /** Name of the attachment. */
6
+ name: string;
7
+ /**
8
+ * A Cosmos icon name identifier to use for a attachment. Will serve as a fallback to a broken thumbnail.
9
+ * @default "document-doc"
10
+ */
11
+ icon?: string;
12
+ /** A string to be used as an image src for a attachment thumbnail. Falls back to a provided icon or the default attachment icon. */
13
+ thumbnail?: string;
14
+ /** Additional information about the attachment. If progress prop is passed and its value is less than 100, this region is instead used for the upload progress indicator. */
15
+ meta?: string;
16
+ /** When passed, previews the attachment on click */
17
+ onPreview?: (id: string) => void;
18
+ /** When passed, this will render a single icon button or within a MenuButton if onDownload is defined. */
19
+ onDownload?: (id: string) => void;
20
+ /** When passed, this will render a single icon button or within a MenuButton if onDelete is defined. */
21
+ onDelete?: (id: string) => void;
22
+ }
23
+ //# sourceMappingURL=Chat.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Chat.types.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/Chat.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,MAAM,WAAW,mBAAoB,SAAQ,SAAS;IACpD,oCAAoC;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oIAAoI;IACpI,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6KAA6K;IAC7K,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,SAAS,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,0GAA0G;IAC1G,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,wGAAwG;IACxG,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Chat.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Chat.types.js","sourceRoot":"","sources":["../../../src/components/Chat/Chat.types.ts"],"names":[],"mappings":"","sourcesContent":["import { BaseProps } from '@pega/cosmos-react-core';\n\nexport interface AttachmentItemProps extends BaseProps {\n /** Unique Id for this attachment */\n id: string;\n /** Name of the attachment. */\n name: string;\n /**\n * A Cosmos icon name identifier to use for a attachment. Will serve as a fallback to a broken thumbnail.\n * @default \"document-doc\"\n */\n icon?: string;\n /** A string to be used as an image src for a attachment thumbnail. Falls back to a provided icon or the default attachment icon. */\n thumbnail?: string;\n /** Additional information about the attachment. If progress prop is passed and its value is less than 100, this region is instead used for the upload progress indicator. */\n meta?: string;\n /** When passed, previews the attachment on click */\n onPreview?: (id: string) => void;\n /** When passed, this will render a single icon button or within a MenuButton if onDownload is defined. */\n onDownload?: (id: string) => void;\n /** When passed, this will render a single icon button or within a MenuButton if onDelete is defined. */\n onDelete?: (id: string) => void;\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { FunctionComponent, Ref, ReactElement } from 'react';
2
+ import { ForwardProps } from '@pega/cosmos-react-core';
3
+ import MessageList from './MessageList';
4
+ export interface ChatBodyProps {
5
+ /** ref to the element */
6
+ ref?: Ref<HTMLDivElement>;
7
+ /** Message data Array */
8
+ children: ReactElement<typeof MessageList>;
9
+ }
10
+ declare const ChatBody: FunctionComponent<ChatBodyProps & ForwardProps>;
11
+ export default ChatBody;
12
+ //# sourceMappingURL=ChatBody.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatBody.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/ChatBody.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA+B,GAAG,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1F,OAAO,EAAQ,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,MAAM,WAAW,aAAa;IAC5B,yBAAyB;IACzB,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IAC1B,yBAAyB;IACzB,QAAQ,EAAE,YAAY,CAAC,OAAO,WAAW,CAAC,CAAC;CAC5C;AAOD,QAAA,MAAM,QAAQ,EAAE,iBAAiB,CAAC,aAAa,GAAG,YAAY,CAqB7D,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from 'react';
3
+ import styled from 'styled-components';
4
+ import { Flex } from '@pega/cosmos-react-core';
5
+ const StyledChatBodyContainer = styled.div `
6
+ position: relative;
7
+ overflow-y: hidden;
8
+ `;
9
+ const ChatBody = forwardRef((props, ref) => {
10
+ const { children, ...restProps } = props;
11
+ return (_jsx(Flex, { as: StyledChatBodyContainer, item: {
12
+ grow: 1
13
+ }, container: {
14
+ direction: 'column'
15
+ }, "aria-live": 'polite', ref: ref, ...restProps, children: children }, void 0));
16
+ });
17
+ export default ChatBody;
18
+ //# sourceMappingURL=ChatBody.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatBody.js","sourceRoot":"","sources":["../../../src/components/Chat/ChatBody.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,UAAU,EAAsC,MAAM,OAAO,CAAC;AAC1F,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,IAAI,EAAgB,MAAM,yBAAyB,CAAC;AAW7D,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAA;;;CAGzC,CAAC;AAEF,MAAM,QAAQ,GAAoD,UAAU,CAC1E,CAAC,KAAqC,EAAE,GAAyB,EAAE,EAAE;IACnE,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IAEzC,OAAO,CACL,KAAC,IAAI,IACH,EAAE,EAAE,uBAAuB,EAC3B,IAAI,EAAE;YACJ,IAAI,EAAE,CAAC;SACR,EACD,SAAS,EAAE;YACT,SAAS,EAAE,QAAQ;SACpB,eACS,QAAQ,EAClB,GAAG,EAAE,GAAG,KACJ,SAAS,YAEZ,QAAQ,WACJ,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import { FunctionComponent, forwardRef, PropsWithoutRef, Ref, ReactElement } from 'react';\nimport styled from 'styled-components';\n\nimport { Flex, ForwardProps } from '@pega/cosmos-react-core';\n\nimport MessageList from './MessageList';\n\nexport interface ChatBodyProps {\n /** ref to the element */\n ref?: Ref<HTMLDivElement>;\n /** Message data Array */\n children: ReactElement<typeof MessageList>;\n}\n\nconst StyledChatBodyContainer = styled.div`\n position: relative;\n overflow-y: hidden;\n`;\n\nconst ChatBody: FunctionComponent<ChatBodyProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ChatBodyProps>, ref: ChatBodyProps['ref']) => {\n const { children, ...restProps } = props;\n\n return (\n <Flex\n as={StyledChatBodyContainer}\n item={{\n grow: 1\n }}\n container={{\n direction: 'column'\n }}\n aria-live='polite'\n ref={ref}\n {...restProps}\n >\n {children}\n </Flex>\n );\n }\n);\n\nexport default ChatBody;\n"]}
@@ -0,0 +1,51 @@
1
+ import { FunctionComponent, Ref, ReactNode, RefObject, KeyboardEvent } from 'react';
2
+ import { ForwardProps } from '@pega/cosmos-react-core';
3
+ import { AttachmentItemProps } from './Chat.types';
4
+ export declare type SpecialKeysConfig = {
5
+ /** Collection of specialKeys */
6
+ keys: string[];
7
+ /** onSpecialKey is fired when a special key is typed in Textarea */
8
+ onSpecialKey: (e: KeyboardEvent<HTMLTextAreaElement>, key: string) => void;
9
+ };
10
+ export interface ChatComposerProps {
11
+ /** Place holder */
12
+ placeholder?: string;
13
+ /** Default message to populate on load */
14
+ defaultMessage?: string;
15
+ /** Max character limit */
16
+ maxLength?: number;
17
+ /** Callback when send button is clicked */
18
+ onSend: (message: string) => void;
19
+ /** Enter / Return key sends message */
20
+ enterKeySendsMessage?: boolean;
21
+ /** Max number of attachments to be allowed in chat composer.
22
+ * If zero is passed, add attachments icon will be hidden. same rule applies if prop is not passed.
23
+ * If attachments added are >= maxAttachments, add attachments icon will be disabled.
24
+ */
25
+ maxAttachments?: number;
26
+ /** show/hide emoji */
27
+ showEmoji?: boolean;
28
+ /** Attachments list */
29
+ attachments?: AttachmentItemProps[];
30
+ /** Callback when attachment icon is clicked */
31
+ onAddAttachment?: () => void;
32
+ /** Special Keys configuration */
33
+ specialKeysConfig?: SpecialKeysConfig;
34
+ /** Disables the composer area */
35
+ disabled?: boolean;
36
+ /** Children */
37
+ children?: ReactNode;
38
+ /** Ref to the Imperative handle */
39
+ ref?: Ref<ChatComposerImperativeHandleProps>;
40
+ }
41
+ export declare const StyledAttachmentsListContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
42
+ export interface ChatComposerImperativeHandleProps {
43
+ /** Function to append a message */
44
+ appendToMessage: (appendMessage: string, position?: 'cursor' | 'start' | 'end' | 'specialKey') => void;
45
+ /** Actual ref to Chat composer component */
46
+ chatComposerRef: RefObject<HTMLDivElement | undefined>;
47
+ textAreaRef: RefObject<HTMLTextAreaElement | undefined>;
48
+ }
49
+ declare const ChatComposer: FunctionComponent<ChatComposerProps & ForwardProps>;
50
+ export default ChatComposer;
51
+ //# sourceMappingURL=ChatComposer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatComposer.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/ChatComposer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EACjB,GAAG,EAEH,SAAS,EAOT,SAAS,EACT,aAAa,EACd,MAAM,OAAO,CAAC;AAGf,OAAO,EAeL,YAAY,EAIb,MAAM,yBAAyB,CAAC;AAMjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAInD,oBAAY,iBAAiB,GAAG;IAC9B,gCAAgC;IAChC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,oEAAoE;IACpE,YAAY,EAAE,CAAC,CAAC,EAAE,aAAa,CAAC,mBAAmB,CAAC,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5E,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,mBAAmB;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0BAA0B;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,uCAAuC;IACvC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sBAAsB;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,uBAAuB;IACvB,WAAW,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACpC,+CAA+C;IAC/C,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,iCAAiC;IACjC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,iCAAiC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe;IACf,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,mCAAmC;IACnC,GAAG,CAAC,EAAE,GAAG,CAAC,iCAAiC,CAAC,CAAC;CAC9C;AAkFD,eAAO,MAAM,8BAA8B,yGAG1C,CAAC;AAEF,MAAM,WAAW,iCAAiC;IAChD,mCAAmC;IACnC,eAAe,EAAE,CACf,aAAa,EAAE,MAAM,EACrB,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,KAAK,GAAG,YAAY,KACjD,IAAI,CAAC;IACV,4CAA4C;IAC5C,eAAe,EAAE,SAAS,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;IACvD,WAAW,EAAE,SAAS,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAAC;CACzD;AAED,QAAA,MAAM,YAAY,EAAE,iBAAiB,CAAC,iBAAiB,GAAG,YAAY,CAwTrE,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,213 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { forwardRef, useState, useEffect, useCallback, useImperativeHandle, useRef } from 'react';
3
+ import styled, { css } from 'styled-components';
4
+ import { Flex, TextArea, Button, Icon, registerIcon, Popover, EmojiPicker, hasProp, useI18n, useAutoResize, useElement, defaultThemeProp, Tooltip, useOuterEvent, calculateFontSize } from '@pega/cosmos-react-core';
5
+ import BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';
6
+ import * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';
7
+ import * as faceHappyIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/face-happy.icon';
8
+ import * as paperClipIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/paper-clip.icon';
9
+ registerIcon(timesIcon, faceHappyIcon, paperClipIcon);
10
+ const StyledAttachmentItem = styled.div ``;
11
+ const StyledAttachmentElementContainer = styled.div(({ disabled, theme }) => {
12
+ return (disabled &&
13
+ css `
14
+ &:focus {
15
+ box-shadow: ${theme.base.shadow.focus};
16
+ border-radius: 50%;
17
+ outline: none;
18
+ }
19
+ `);
20
+ });
21
+ const StyledPreviewButton = styled(BareButton) ``;
22
+ const StyledDeleteButton = styled(BareButton) ``;
23
+ const StyledChatComposer = styled.footer(({ theme, disabled, theme: { base: { 'font-size': fontSize, 'font-scale': fontScale, 'disabled-opacity': transparentBg }, components: { link: { color: linkColor } } } }) => {
24
+ const { xxs: fontSizeXXS } = calculateFontSize(fontSize, fontScale);
25
+ return css `
26
+ padding: calc(2 * ${theme.base.spacing});
27
+ background-color: ${theme.base.palette['secondary-background']};
28
+ textarea {
29
+ border-radius: ${theme.base['border-radius']};
30
+ height: 2.4rem;
31
+ min-height: 2.4rem;
32
+ border: 0.0625rem solid ${theme.base.colors.gray['extra-light']};
33
+ max-width: 100%;
34
+ }
35
+ ${StyledAttachmentItem} {
36
+ color: ${linkColor};
37
+ background-color: ${theme.base.palette['primary-background']};
38
+ padding: calc(0.5 * ${theme.base.spacing});
39
+ border-radius: calc(0.25 * ${theme.base['border-radius']});
40
+ font-size: ${fontSizeXXS};
41
+ font-weight: bold;
42
+ margin-bottom: calc(0.5 * ${theme.base.spacing});
43
+ opacity: ${disabled ? transparentBg : 1};
44
+ }
45
+
46
+ ${StyledAttachmentElementContainer} {
47
+ ${disabled &&
48
+ css `
49
+ pointer-events: none;
50
+ `}
51
+ }
52
+
53
+ ${StyledPreviewButton} {
54
+ color: ${theme.base.palette.interactive};
55
+ font-weight: bold;
56
+ &:hover {
57
+ text-decoration: underline;
58
+ }
59
+ }
60
+
61
+ ${StyledDeleteButton} {
62
+ color: ${theme.base.palette.interactive};
63
+ }
64
+ `;
65
+ });
66
+ StyledChatComposer.defaultProps = defaultThemeProp;
67
+ StyledAttachmentElementContainer.defaultProps = defaultThemeProp;
68
+ export const StyledAttachmentsListContainer = styled.div `
69
+ max-height: 4rem;
70
+ overflow-y: auto;
71
+ `;
72
+ const ChatComposer = forwardRef((props, ref) => {
73
+ const { children, attachments = [], maxAttachments = 0, onAddAttachment, maxLength, placeholder: defaultPlaceHolder, defaultMessage = '', onSend, specialKeysConfig, disabled = false, enterKeySendsMessage = true, showEmoji, ...restProps } = props;
74
+ const [message, setMessage] = useState(defaultMessage);
75
+ useEffect(() => {
76
+ setMessage(defaultMessage);
77
+ }, [defaultMessage]);
78
+ const t = useI18n();
79
+ const [textAreaRef, resizeTextArea] = useAutoResize(75.1);
80
+ const [showEmojiPicker, setShowEmojiPicker] = useState(false);
81
+ const [emojiBtnEl, setEmojiBtnEl] = useElement();
82
+ const [attachmentsBtnEl, setAttachmentsBtnEl] = useElement();
83
+ const lastEnteredSpecialKey = useRef(null);
84
+ const appendToMessage = useCallback((appendMessage, position, selectText = true) => {
85
+ let selectionStart;
86
+ let selectionEnd;
87
+ if (textAreaRef.current) {
88
+ if (position === 'start') {
89
+ textAreaRef.current.value = appendMessage + textAreaRef.current.value;
90
+ selectionStart = 0;
91
+ selectionEnd = appendMessage.length;
92
+ }
93
+ else if (position === 'end') {
94
+ const initialEnd = textAreaRef.current.value.length;
95
+ textAreaRef.current.value += appendMessage;
96
+ selectionStart = initialEnd;
97
+ selectionEnd = initialEnd + appendMessage.length;
98
+ }
99
+ else if (position === 'specialKey' && lastEnteredSpecialKey.current) {
100
+ const replaceChars = lastEnteredSpecialKey.current.length;
101
+ const currentSelectionStart = textAreaRef.current.selectionStart;
102
+ textAreaRef.current.value =
103
+ textAreaRef.current.value.substring(0, textAreaRef.current.selectionStart - replaceChars) +
104
+ appendMessage +
105
+ textAreaRef.current.value.substring(textAreaRef.current.selectionStart, textAreaRef.current.value.length);
106
+ selectionStart = currentSelectionStart - replaceChars;
107
+ selectionEnd = currentSelectionStart + appendMessage.length - replaceChars;
108
+ lastEnteredSpecialKey.current = null;
109
+ }
110
+ else {
111
+ const currentSelectionStart = textAreaRef.current.selectionStart;
112
+ textAreaRef.current.value =
113
+ textAreaRef.current.value.substring(0, textAreaRef.current.selectionStart) +
114
+ appendMessage +
115
+ textAreaRef.current.value.substring(textAreaRef.current.selectionStart, textAreaRef.current.value.length);
116
+ selectionStart = currentSelectionStart;
117
+ selectionEnd = currentSelectionStart + appendMessage.length;
118
+ }
119
+ textAreaRef.current.selectionStart = selectText ? selectionStart : selectionEnd;
120
+ textAreaRef.current.selectionEnd = selectionEnd;
121
+ textAreaRef.current.focus();
122
+ setMessage(textAreaRef.current.value);
123
+ }
124
+ }, [setMessage, textAreaRef.current]);
125
+ const chatComposerRef = useRef(null);
126
+ useImperativeHandle(ref, () => ({ appendToMessage, chatComposerRef, textAreaRef }), [
127
+ appendToMessage,
128
+ chatComposerRef.current,
129
+ textAreaRef.current
130
+ ]);
131
+ const sendMessage = useCallback((newMessage) => {
132
+ if (onSend) {
133
+ onSend(newMessage);
134
+ setMessage('');
135
+ resizeTextArea();
136
+ }
137
+ }, [onSend, resizeTextArea]);
138
+ const handleEnterKeyDown = useCallback((e) => {
139
+ if (enterKeySendsMessage && e.keyCode === 13 && !e.shiftKey) {
140
+ if (!maxLength || message.length <= maxLength) {
141
+ sendMessage(message);
142
+ }
143
+ e.preventDefault();
144
+ e.stopPropagation();
145
+ }
146
+ }, [onSend, message, maxLength]);
147
+ const handleTextAreaChange = useCallback((e) => {
148
+ setMessage(e.currentTarget.value);
149
+ resizeTextArea();
150
+ }, [setMessage, resizeTextArea]);
151
+ const handleSpecialKey = useCallback((e) => {
152
+ if (!specialKeysConfig)
153
+ return;
154
+ const { keys, onSpecialKey } = specialKeysConfig;
155
+ if (specialKeysConfig && keys.length > 0) {
156
+ const composerValue = e.currentTarget.value.substring(0, e.currentTarget.selectionStart);
157
+ const specialKey = keys.find(key => composerValue.endsWith(key));
158
+ if (specialKey) {
159
+ lastEnteredSpecialKey.current = specialKey;
160
+ onSpecialKey(e, specialKey);
161
+ }
162
+ }
163
+ }, [specialKeysConfig]);
164
+ const toggleEmoji = () => {
165
+ setShowEmojiPicker(!showEmojiPicker);
166
+ };
167
+ const onEmojiSelect = emojiElem => {
168
+ // Check that it is not a custom emoji
169
+ if (hasProp(emojiElem, 'native')) {
170
+ appendToMessage(emojiElem.native, 'cursor', false);
171
+ }
172
+ setShowEmojiPicker(false);
173
+ };
174
+ const EmojiPickerRef = useRef(null);
175
+ useOuterEvent('mousedown', [emojiBtnEl, EmojiPickerRef], () => {
176
+ setShowEmojiPicker(false);
177
+ });
178
+ useEffect(() => {
179
+ resizeTextArea();
180
+ }, []);
181
+ return (_jsxs(_Fragment, { children: [_jsxs(Flex, { as: StyledChatComposer, disabled: disabled, container: {
182
+ direction: 'column',
183
+ gap: 2
184
+ }, item: {
185
+ shrink: 0
186
+ }, ...restProps, ref: chatComposerRef, children: [_jsxs(Flex, { container: {
187
+ direction: 'column',
188
+ gap: 0.5
189
+ }, children: [_jsx(Flex, { container: {
190
+ wrap: 'wrap',
191
+ gap: 0.5
192
+ }, as: StyledAttachmentsListContainer, children: attachments.map(attachment => {
193
+ return (_jsxs(Flex, { container: {
194
+ gap: 1,
195
+ alignItems: 'center'
196
+ }, as: StyledAttachmentItem, children: [_jsx(BareButton, { as: StyledPreviewButton, disabled: disabled, onClick: () => {
197
+ attachment.onPreview?.(attachment.name);
198
+ }, children: attachment.name }, void 0), _jsx(BareButton, { as: StyledDeleteButton, disabled: disabled, "aria-label": t('email_remove_attachment'), onClick: () => {
199
+ attachment.onDelete?.(attachment.name);
200
+ }, children: _jsx(Icon, { name: 'times' }, void 0) }, void 0)] }, attachment.name));
201
+ }) }, void 0), _jsx(TextArea, { ref: textAreaRef, maxLength: maxLength, displayCharCount: maxLength !== undefined, hardStop: false, placeholder: defaultPlaceHolder, value: message, disabled: disabled, onKeyUp: handleSpecialKey, onKeyDown: handleEnterKeyDown, onChange: handleTextAreaChange, onFocus: handleTextAreaChange, "aria-label": t('enter_message') }, void 0)] }, void 0), _jsxs(Flex, { container: { gap: 0.5 }, children: [showEmoji && (_jsx(Button, { ref: setEmojiBtnEl, onClick: toggleEmoji, variant: 'simple', disabled: disabled, icon: true, "aria-label": t('add_emoji'), children: _jsx(Icon, { name: 'face-happy' }, void 0) }, void 0)), maxAttachments > 0 && (_jsxs(StyledAttachmentElementContainer, { disabled: attachments.length >= maxAttachments, ref: setAttachmentsBtnEl, tabIndex: attachments.length >= maxAttachments ? 0 : undefined, role: 'button', children: [_jsx(Button, { onClick: onAddAttachment, variant: 'simple', disabled: !!(disabled || attachments.length >= maxAttachments), icon: true, "aria-label": attachments.length >= maxAttachments
202
+ ? t('email_disable_attachment', [maxAttachments])
203
+ : t('email_add_attachment', [maxAttachments]), children: _jsx(Icon, { name: 'paper-clip' }, void 0) }, void 0), attachments.length >= maxAttachments && (_jsx(Tooltip, { target: attachmentsBtnEl, showDelay: 'none', hideDelay: 'none', ...restProps, children: t('email_disable_attachment', [maxAttachments]) }, void 0))] }, void 0)), _jsx(Flex, { item: { grow: 1 }, children: children }, void 0), _jsx(Button, { variant: 'primary', disabled: disabled || (!!maxLength && message.length > maxLength), onClick: () => {
204
+ sendMessage(message);
205
+ }, children: t('send_label') }, void 0)] }, void 0)] }, void 0), _jsx(Popover, { show: showEmojiPicker, target: emojiBtnEl, placement: 'bottom-start', modifiers: [
206
+ {
207
+ name: 'flip',
208
+ enabled: true
209
+ }
210
+ ], children: _jsx(EmojiPicker, { ref: EmojiPickerRef, onSelect: onEmojiSelect }, void 0) }, void 0)] }, void 0));
211
+ });
212
+ export default ChatComposer;
213
+ //# sourceMappingURL=ChatComposer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatComposer.js","sourceRoot":"","sources":["../../../src/components/Chat/ChatComposer.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAKV,QAAQ,EACR,SAAS,EACT,WAAW,EAEX,mBAAmB,EACnB,MAAM,EAGP,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,WAAW,EAEX,OAAO,EACP,OAAO,EACP,aAAa,EACb,UAAU,EACV,gBAAgB,EAGhB,OAAO,EACP,aAAa,EACb,iBAAiB,EAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,UAAU,MAAM,0DAA0D,CAAC;AAClF,OAAO,KAAK,SAAS,MAAM,8DAA8D,CAAC;AAC1F,OAAO,KAAK,aAAa,MAAM,mEAAmE,CAAC;AACnG,OAAO,KAAK,aAAa,MAAM,mEAAmE,CAAC;AAInG,YAAY,CAAC,SAAS,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC;AAyCtD,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC;AAK1C,MAAM,gCAAgC,GAAG,MAAM,CAAC,GAAG,CACjD,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE;IACtB,OAAO,CACL,QAAQ;QACR,GAAG,CAAA;;wBAEe,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK;;;;OAIxC,CACF,CAAC;AACJ,CAAC,CACF,CAAC;AACF,MAAM,mBAAmB,GAAG,MAAM,C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oCACZ,WAAW,CAAC,OAAO,CAAC,CAAC;gCACvB,CAAC,YAEA,CAAC,CAAC,YAAY,CAAC,WACT,YACJ,YACF,EACP,KAAC,OAAO,IACN,IAAI,EAAE,eAAe,EACrB,MAAM,EAAE,UAAU,EAClB,SAAS,EAAC,cAAc,EACxB,SAAS,EAAE;oBACT;wBACE,IAAI,EAAE,MAAM;wBACZ,OAAO,EAAE,IAAI;qBACd;iBACF,YAED,KAAC,WAAW,IAAC,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,WAAI,WACrD,YACT,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n Ref,\n PropsWithoutRef,\n ReactNode,\n useState,\n useEffect,\n useCallback,\n ChangeEvent,\n useImperativeHandle,\n useRef,\n RefObject,\n KeyboardEvent\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Flex,\n TextArea,\n Button,\n Icon,\n registerIcon,\n Popover,\n EmojiPicker,\n EmojiPickerProps,\n hasProp,\n useI18n,\n useAutoResize,\n useElement,\n defaultThemeProp,\n PropsWithDefaults,\n ForwardProps,\n Tooltip,\n useOuterEvent,\n calculateFontSize\n} from '@pega/cosmos-react-core';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\nimport * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\nimport * as faceHappyIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/face-happy.icon';\nimport * as paperClipIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/paper-clip.icon';\n\nimport { AttachmentItemProps } from './Chat.types';\n\nregisterIcon(timesIcon, faceHappyIcon, paperClipIcon);\n\nexport type SpecialKeysConfig = {\n /** Collection of specialKeys */\n keys: string[];\n /** onSpecialKey is fired when a special key is typed in Textarea */\n onSpecialKey: (e: KeyboardEvent<HTMLTextAreaElement>, key: string) => void;\n};\n\nexport interface ChatComposerProps {\n /** Place holder */\n placeholder?: string;\n /** Default message to populate on load */\n defaultMessage?: string;\n /** Max character limit */\n maxLength?: number;\n /** Callback when send button is clicked */\n onSend: (message: string) => void;\n /** Enter / Return key sends message */\n enterKeySendsMessage?: boolean;\n /** Max number of attachments to be allowed in chat composer.\n * If zero is passed, add attachments icon will be hidden. same rule applies if prop is not passed.\n * If attachments added are >= maxAttachments, add attachments icon will be disabled.\n */\n maxAttachments?: number;\n /** show/hide emoji */\n showEmoji?: boolean;\n /** Attachments list */\n attachments?: AttachmentItemProps[];\n /** Callback when attachment icon is clicked */\n onAddAttachment?: () => void;\n /** Special Keys configuration */\n specialKeysConfig?: SpecialKeysConfig;\n /** Disables the composer area */\n disabled?: boolean;\n /** Children */\n children?: ReactNode;\n /** Ref to the Imperative handle */\n ref?: Ref<ChatComposerImperativeHandleProps>;\n}\n\nconst StyledAttachmentItem = styled.div``;\n\ninterface DisableAttachmentProps {\n disabled?: boolean;\n}\nconst StyledAttachmentElementContainer = styled.div<DisableAttachmentProps>(\n ({ disabled, theme }) => {\n return (\n disabled &&\n css`\n &:focus {\n box-shadow: ${theme.base.shadow.focus};\n border-radius: 50%;\n outline: none;\n }\n `\n );\n }\n);\nconst StyledPreviewButton = styled(BareButton)``;\nconst StyledDeleteButton = styled(BareButton)``;\n\nconst StyledChatComposer = styled.footer<PropsWithDefaults<ChatComposerProps, 'disabled'>>(\n ({\n theme,\n disabled,\n theme: {\n base: { 'font-size': fontSize, 'font-scale': fontScale, 'disabled-opacity': transparentBg },\n components: {\n link: { color: linkColor }\n }\n }\n }) => {\n const { xxs: fontSizeXXS } = calculateFontSize(fontSize, fontScale);\n return css`\n padding: calc(2 * ${theme.base.spacing});\n background-color: ${theme.base.palette['secondary-background']};\n textarea {\n border-radius: ${theme.base['border-radius']};\n height: 2.4rem;\n min-height: 2.4rem;\n border: 0.0625rem solid ${theme.base.colors.gray['extra-light']};\n max-width: 100%;\n }\n ${StyledAttachmentItem} {\n color: ${linkColor};\n background-color: ${theme.base.palette['primary-background']};\n padding: calc(0.5 * ${theme.base.spacing});\n border-radius: calc(0.25 * ${theme.base['border-radius']});\n font-size: ${fontSizeXXS};\n font-weight: bold;\n margin-bottom: calc(0.5 * ${theme.base.spacing});\n opacity: ${disabled ? transparentBg : 1};\n }\n\n ${StyledAttachmentElementContainer} {\n ${disabled &&\n css`\n pointer-events: none;\n `}\n }\n\n ${StyledPreviewButton} {\n color: ${theme.base.palette.interactive};\n font-weight: bold;\n &:hover {\n text-decoration: underline;\n }\n }\n\n ${StyledDeleteButton} {\n color: ${theme.base.palette.interactive};\n }\n `;\n }\n);\n\nStyledChatComposer.defaultProps = defaultThemeProp;\nStyledAttachmentElementContainer.defaultProps = defaultThemeProp;\n\nexport const StyledAttachmentsListContainer = styled.div`\n max-height: 4rem;\n overflow-y: auto;\n`;\n\nexport interface ChatComposerImperativeHandleProps {\n /** Function to append a message */\n appendToMessage: (\n appendMessage: string,\n position?: 'cursor' | 'start' | 'end' | 'specialKey'\n ) => void;\n /** Actual ref to Chat composer component */\n chatComposerRef: RefObject<HTMLDivElement | undefined>;\n textAreaRef: RefObject<HTMLTextAreaElement | undefined>;\n}\n\nconst ChatComposer: FunctionComponent<ChatComposerProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ChatComposerProps>, ref: ChatComposerProps['ref']) => {\n const {\n children,\n attachments = [],\n maxAttachments = 0,\n onAddAttachment,\n maxLength,\n placeholder: defaultPlaceHolder,\n defaultMessage = '',\n onSend,\n specialKeysConfig,\n disabled = false,\n enterKeySendsMessage = true,\n showEmoji,\n ...restProps\n } = props;\n const [message, setMessage] = useState(defaultMessage);\n useEffect(() => {\n setMessage(defaultMessage);\n }, [defaultMessage]);\n\n const t = useI18n();\n\n const [textAreaRef, resizeTextArea] = useAutoResize<HTMLTextAreaElement>(75.1);\n const [showEmojiPicker, setShowEmojiPicker] = useState(false);\n const [emojiBtnEl, setEmojiBtnEl] = useElement();\n const [attachmentsBtnEl, setAttachmentsBtnEl] = useElement();\n\n const lastEnteredSpecialKey = useRef<string | null>(null);\n\n const appendToMessage = useCallback(\n (\n appendMessage: string,\n position?: 'cursor' | 'start' | 'end' | 'specialKey',\n selectText: boolean = true\n ) => {\n let selectionStart;\n let selectionEnd;\n if (textAreaRef.current) {\n if (position === 'start') {\n textAreaRef.current.value = appendMessage + textAreaRef.current.value;\n selectionStart = 0;\n selectionEnd = appendMessage.length;\n } else if (position === 'end') {\n const initialEnd = textAreaRef.current.value.length;\n textAreaRef.current.value += appendMessage;\n selectionStart = initialEnd;\n selectionEnd = initialEnd + appendMessage.length;\n } else if (position === 'specialKey' && lastEnteredSpecialKey.current) {\n const replaceChars = lastEnteredSpecialKey.current.length;\n const currentSelectionStart = textAreaRef.current.selectionStart;\n textAreaRef.current.value =\n textAreaRef.current.value.substring(\n 0,\n textAreaRef.current.selectionStart - replaceChars\n ) +\n appendMessage +\n textAreaRef.current.value.substring(\n textAreaRef.current.selectionStart,\n textAreaRef.current.value.length\n );\n selectionStart = currentSelectionStart - replaceChars;\n selectionEnd = currentSelectionStart + appendMessage.length - replaceChars;\n lastEnteredSpecialKey.current = null;\n } else {\n const currentSelectionStart = textAreaRef.current.selectionStart;\n textAreaRef.current.value =\n textAreaRef.current.value.substring(0, textAreaRef.current.selectionStart) +\n appendMessage +\n textAreaRef.current.value.substring(\n textAreaRef.current.selectionStart,\n textAreaRef.current.value.length\n );\n selectionStart = currentSelectionStart;\n selectionEnd = currentSelectionStart + appendMessage.length;\n }\n textAreaRef.current.selectionStart = selectText ? selectionStart : selectionEnd;\n textAreaRef.current.selectionEnd = selectionEnd;\n textAreaRef.current.focus();\n setMessage(textAreaRef.current.value);\n }\n },\n [setMessage, textAreaRef.current]\n );\n\n const chatComposerRef = useRef<HTMLDivElement>(null);\n\n useImperativeHandle(ref, () => ({ appendToMessage, chatComposerRef, textAreaRef }), [\n appendToMessage,\n chatComposerRef.current,\n textAreaRef.current\n ]);\n\n const sendMessage = useCallback(\n (newMessage: string) => {\n if (onSend) {\n onSend(newMessage);\n setMessage('');\n resizeTextArea();\n }\n },\n [onSend, resizeTextArea]\n );\n\n const handleEnterKeyDown = useCallback(\n (e: KeyboardEvent) => {\n if (enterKeySendsMessage && e.keyCode === 13 && !e.shiftKey) {\n if (!maxLength || message.length <= maxLength) {\n sendMessage(message);\n }\n e.preventDefault();\n e.stopPropagation();\n }\n },\n [onSend, message, maxLength]\n );\n\n const handleTextAreaChange = useCallback(\n (e: ChangeEvent<HTMLTextAreaElement>) => {\n setMessage(e.currentTarget.value);\n resizeTextArea();\n },\n [setMessage, resizeTextArea]\n );\n\n const handleSpecialKey = useCallback(\n (e: KeyboardEvent<HTMLTextAreaElement>) => {\n if (!specialKeysConfig) return;\n const { keys, onSpecialKey } = specialKeysConfig;\n if (specialKeysConfig && keys.length > 0) {\n const composerValue = e.currentTarget.value.substring(0, e.currentTarget.selectionStart);\n const specialKey = keys.find(key => composerValue.endsWith(key));\n if (specialKey) {\n lastEnteredSpecialKey.current = specialKey;\n onSpecialKey(e, specialKey);\n }\n }\n },\n [specialKeysConfig]\n );\n\n const toggleEmoji = () => {\n setShowEmojiPicker(!showEmojiPicker);\n };\n const onEmojiSelect: EmojiPickerProps['onSelect'] = emojiElem => {\n // Check that it is not a custom emoji\n if (hasProp(emojiElem, 'native')) {\n appendToMessage(emojiElem.native, 'cursor', false);\n }\n setShowEmojiPicker(false);\n };\n\n const EmojiPickerRef = useRef<HTMLDivElement>(null);\n\n useOuterEvent('mousedown', [emojiBtnEl, EmojiPickerRef], () => {\n setShowEmojiPicker(false);\n });\n\n useEffect(() => {\n resizeTextArea();\n }, []);\n\n return (\n <>\n <Flex\n as={StyledChatComposer}\n disabled={disabled}\n container={{\n direction: 'column',\n gap: 2\n }}\n item={{\n shrink: 0\n }}\n {...restProps}\n ref={chatComposerRef}\n >\n <Flex\n container={{\n direction: 'column',\n gap: 0.5\n }}\n >\n <Flex\n container={{\n wrap: 'wrap',\n gap: 0.5\n }}\n as={StyledAttachmentsListContainer}\n >\n {attachments.map(attachment => {\n return (\n <Flex\n key={attachment.name}\n container={{\n gap: 1,\n alignItems: 'center'\n }}\n as={StyledAttachmentItem}\n >\n <BareButton\n as={StyledPreviewButton}\n disabled={disabled}\n onClick={() => {\n attachment.onPreview?.(attachment.name);\n }}\n >\n {attachment.name}\n </BareButton>\n <BareButton\n as={StyledDeleteButton}\n disabled={disabled}\n aria-label={t('email_remove_attachment')}\n onClick={() => {\n attachment.onDelete?.(attachment.name);\n }}\n >\n <Icon name='times' />\n </BareButton>\n </Flex>\n );\n })}\n </Flex>\n <TextArea\n ref={textAreaRef}\n maxLength={maxLength}\n displayCharCount={maxLength !== undefined}\n hardStop={false}\n placeholder={defaultPlaceHolder}\n value={message}\n disabled={disabled}\n onKeyUp={handleSpecialKey}\n onKeyDown={handleEnterKeyDown}\n onChange={handleTextAreaChange}\n onFocus={handleTextAreaChange}\n aria-label={t('enter_message')}\n />\n </Flex>\n <Flex container={{ gap: 0.5 }}>\n {showEmoji && (\n <Button\n ref={setEmojiBtnEl}\n onClick={toggleEmoji}\n variant='simple'\n disabled={disabled}\n icon\n aria-label={t('add_emoji')}\n >\n <Icon name='face-happy' />\n </Button>\n )}\n {maxAttachments > 0 && (\n <StyledAttachmentElementContainer\n disabled={attachments.length >= maxAttachments}\n ref={setAttachmentsBtnEl}\n tabIndex={attachments.length >= maxAttachments ? 0 : undefined}\n role='button'\n >\n <Button\n onClick={onAddAttachment}\n variant='simple'\n disabled={!!(disabled || attachments.length >= maxAttachments)}\n icon\n aria-label={\n attachments.length >= maxAttachments\n ? t('email_disable_attachment', [maxAttachments])\n : t('email_add_attachment', [maxAttachments])\n }\n >\n <Icon name='paper-clip' />\n </Button>\n {attachments.length >= maxAttachments && (\n <Tooltip\n target={attachmentsBtnEl}\n showDelay='none'\n hideDelay='none'\n {...restProps}\n >\n {t('email_disable_attachment', [maxAttachments])}\n </Tooltip>\n )}\n </StyledAttachmentElementContainer>\n )}\n <Flex item={{ grow: 1 }}>{children}</Flex>\n <Button\n variant='primary'\n disabled={disabled || (!!maxLength && message.length > maxLength)}\n onClick={() => {\n sendMessage(message);\n }}\n >\n {t('send_label')}\n </Button>\n </Flex>\n </Flex>\n <Popover\n show={showEmojiPicker}\n target={emojiBtnEl}\n placement='bottom-start'\n modifiers={[\n {\n name: 'flip',\n enabled: true\n }\n ]}\n >\n <EmojiPicker ref={EmojiPickerRef} onSelect={onEmojiSelect} />\n </Popover>\n </>\n );\n }\n);\n\nexport default ChatComposer;\n"]}
@@ -0,0 +1,15 @@
1
+ import { FunctionComponent, Ref, ReactNode } from 'react';
2
+ import { ForwardProps, NoChildrenProp } from '@pega/cosmos-react-core';
3
+ export interface ChatHeaderProps extends NoChildrenProp {
4
+ /** ref to the element */
5
+ ref?: Ref<HTMLElement>;
6
+ /** Title: Used to show username || channel || group name */
7
+ title: string;
8
+ /** Icon: Used to show the channel icons, pass the icon name from the cosmos library to render */
9
+ icon?: string;
10
+ /** Primary actions: Used to show frequent user actions to be performed */
11
+ actions?: ReactNode;
12
+ }
13
+ declare const ChatHeader: FunctionComponent<ChatHeaderProps & ForwardProps>;
14
+ export default ChatHeader;
15
+ //# sourceMappingURL=ChatHeader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatHeader.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/ChatHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAE,GAAG,EAAmB,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvF,OAAO,EAKL,YAAY,EACZ,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,MAAM,WAAW,eAAgB,SAAQ,cAAc;IACrD,yBAAyB;IACzB,GAAG,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;IACvB,4DAA4D;IAC5D,KAAK,EAAE,MAAM,CAAC;IACd,iGAAiG;IACjG,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB;AAwBD,QAAA,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,GAAG,YAAY,CA8BjE,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef } from 'react';
3
+ import styled, { css } from 'styled-components';
4
+ import { Text, Flex, Icon, defaultThemeProp } from '@pega/cosmos-react-core';
5
+ const StyledChatPrimaryInfoContainer = styled.div ``;
6
+ const StyledChatHeader = styled.header(({ theme: { base: { spacing, colors: { gray } } } }) => {
7
+ return css `
8
+ padding: ${spacing} calc(2 * ${spacing});
9
+ border-bottom: 0.0625rem solid ${gray.light};
10
+ ${StyledChatPrimaryInfoContainer} {
11
+ font-size: 1rem;
12
+ }
13
+ `;
14
+ });
15
+ StyledChatHeader.defaultProps = defaultThemeProp;
16
+ const ChatHeader = forwardRef((props, ref) => {
17
+ const { title, actions, icon, ...restProps } = props;
18
+ return (_jsxs(Flex, { ref: ref, as: StyledChatHeader, container: true, item: {
19
+ shrink: 0
20
+ }, ...restProps, children: [_jsxs(Flex, { item: {
21
+ grow: 1
22
+ }, container: {
23
+ gap: 2,
24
+ alignItems: 'center'
25
+ }, as: StyledChatPrimaryInfoContainer, children: [icon && _jsx(Icon, { name: icon }, void 0), _jsx(Text, { variant: 'h3', children: title }, void 0)] }, void 0), actions] }, void 0));
26
+ });
27
+ export default ChatHeader;
28
+ //# sourceMappingURL=ChatHeader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatHeader.js","sourceRoot":"","sources":["../../../src/components/Chat/ChatHeader.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsD,MAAM,OAAO,CAAC;AACvF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,gBAAgB,EAGjB,MAAM,yBAAyB,CAAC;AAajC,MAAM,8BAA8B,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC;AAEpD,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CACpC,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EACJ,OAAO,EACP,MAAM,EAAE,EAAE,IAAI,EAAE,EACjB,EACF,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;iBACG,OAAO,aAAa,OAAO;uCACL,IAAI,CAAC,KAAK;QACzC,8BAA8B;;;KAGjC,CAAC;AACJ,CAAC,CACF,CAAC;AACF,gBAAgB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEjD,MAAM,UAAU,GAAsD,UAAU,CAC9E,CAAC,KAAuC,EAAE,GAA2B,EAAE,EAAE;IACvE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IACrD,OAAO,CACL,MAAC,IAAI,IACH,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,gBAAgB,EACpB,SAAS,QACT,IAAI,EAAE;YACJ,MAAM,EAAE,CAAC;SACV,KACG,SAAS,aAEb,MAAC,IAAI,IACH,IAAI,EAAE;oBACJ,IAAI,EAAE,CAAC;iBACR,EACD,SAAS,EAAE;oBACT,GAAG,EAAE,CAAC;oBACN,UAAU,EAAE,QAAQ;iBACrB,EACD,EAAE,EAAE,8BAA8B,aAEjC,IAAI,IAAI,KAAC,IAAI,IAAC,IAAI,EAAE,IAAI,WAAI,EAC7B,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,YAAE,KAAK,WAAQ,YAC5B,EACN,OAAO,YACH,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, Ref, PropsWithoutRef, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Text,\n Flex,\n Icon,\n defaultThemeProp,\n ForwardProps,\n NoChildrenProp\n} from '@pega/cosmos-react-core';\n\nexport interface ChatHeaderProps extends NoChildrenProp {\n /** ref to the element */\n ref?: Ref<HTMLElement>;\n /** Title: Used to show username || channel || group name */\n title: string;\n /** Icon: Used to show the channel icons, pass the icon name from the cosmos library to render */\n icon?: string;\n /** Primary actions: Used to show frequent user actions to be performed */\n actions?: ReactNode;\n}\n\nconst StyledChatPrimaryInfoContainer = styled.div``;\n\nconst StyledChatHeader = styled.header(\n ({\n theme: {\n base: {\n spacing,\n colors: { gray }\n }\n }\n }) => {\n return css`\n padding: ${spacing} calc(2 * ${spacing});\n border-bottom: 0.0625rem solid ${gray.light};\n ${StyledChatPrimaryInfoContainer} {\n font-size: 1rem;\n }\n `;\n }\n);\nStyledChatHeader.defaultProps = defaultThemeProp;\n\nconst ChatHeader: FunctionComponent<ChatHeaderProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ChatHeaderProps>, ref: ChatHeaderProps['ref']) => {\n const { title, actions, icon, ...restProps } = props;\n return (\n <Flex\n ref={ref}\n as={StyledChatHeader}\n container\n item={{\n shrink: 0\n }}\n {...restProps}\n >\n <Flex\n item={{\n grow: 1\n }}\n container={{\n gap: 2,\n alignItems: 'center'\n }}\n as={StyledChatPrimaryInfoContainer}\n >\n {icon && <Icon name={icon} />}\n <Text variant='h3'>{title}</Text>\n </Flex>\n {actions}\n </Flex>\n );\n }\n);\n\nexport default ChatHeader;\n"]}
@@ -0,0 +1,23 @@
1
+ import { FunctionComponent, Ref } from 'react';
2
+ import { ForwardProps } from '@pega/cosmos-react-core';
3
+ import { RepeatingViewRow } from './RepeatingView';
4
+ import { TranscriptMessageProps } from './TranscriptMessage';
5
+ import { SystemMessageProps } from './SystemMessage';
6
+ export declare type ChatTranscriptItem = (TranscriptMessageProps & {
7
+ type: 'transcript';
8
+ id: RepeatingViewRow['id'];
9
+ }) | (SystemMessageProps & {
10
+ type: 'system';
11
+ id: RepeatingViewRow['id'];
12
+ });
13
+ export interface ChatTranscriptProps {
14
+ /** ref to the element */
15
+ ref?: Ref<HTMLDivElement>;
16
+ /** Title for transcript's body */
17
+ title?: string;
18
+ /** Transcript messages array */
19
+ transcript: ChatTranscriptItem[];
20
+ }
21
+ declare const ChatTranscript: FunctionComponent<ChatTranscriptProps & ForwardProps>;
22
+ export default ChatTranscript;
23
+ //# sourceMappingURL=ChatTranscript.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatTranscript.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/ChatTranscript.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAmB,GAAG,EAAE,MAAM,OAAO,CAAC;AAG5E,OAAO,EAA0B,YAAY,EAAQ,MAAM,yBAAyB,CAAC;AAErF,OAAsB,EAAE,gBAAgB,EAA2B,MAAM,iBAAiB,CAAC;AAC3F,OAA0B,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAsB,EAAE,kBAAkB,EAAuB,MAAM,iBAAiB,CAAC;AAEzF,oBAAY,kBAAkB,GAC1B,CAAC,sBAAsB,GAAG;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,EAAE,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC,GAC7E,CAAC,kBAAkB,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,EAAE,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC,CAAC;AAE1E,MAAM,WAAW,mBAAmB;IAClC,yBAAyB;IACzB,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IAC1B,kCAAkC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,UAAU,EAAE,kBAAkB,EAAE,CAAC;CAClC;AAgCD,QAAA,MAAM,cAAc,EAAE,iBAAiB,CAAC,mBAAmB,GAAG,YAAY,CAwCzE,CAAC;AAEF,eAAe,cAAc,CAAC"}