@elliemae/ds-chat 1.59.3 → 1.59.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.
- package/cjs/ChatDataTestids.js +2 -1
- package/cjs/ChatDataTestids.js.map +1 -1
- package/cjs/parts/bubble/ChatBubbleArrow.js +3 -3
- package/cjs/parts/bubble/ChatBubbleArrow.js.map +1 -1
- package/cjs/parts/chat-container/ChatContainer.js +3 -2
- package/cjs/parts/chat-container/ChatContainer.js.map +1 -1
- package/cjs/parts/chat-container/props.js +6 -2
- package/cjs/parts/chat-container/props.js.map +1 -1
- package/cjs/parts/chat-container-messages-list/ChatContainerMessagesList.js +3 -7
- package/cjs/parts/chat-container-messages-list/ChatContainerMessagesList.js.map +1 -1
- package/cjs/tests/utils.js +6 -4
- package/cjs/tests/utils.js.map +1 -1
- package/esm/ChatDataTestids.js +2 -1
- package/esm/ChatDataTestids.js.map +1 -1
- package/esm/parts/bubble/ChatBubbleArrow.js +3 -3
- package/esm/parts/bubble/ChatBubbleArrow.js.map +1 -1
- package/esm/parts/chat-container/ChatContainer.js +3 -2
- package/esm/parts/chat-container/ChatContainer.js.map +1 -1
- package/esm/parts/chat-container/props.js +6 -2
- package/esm/parts/chat-container/props.js.map +1 -1
- package/esm/parts/chat-container-messages-list/ChatContainerMessagesList.js +3 -7
- package/esm/parts/chat-container-messages-list/ChatContainerMessagesList.js.map +1 -1
- package/esm/tests/utils.js +6 -4
- package/esm/tests/utils.js.map +1 -1
- package/package.json +9 -9
package/cjs/ChatDataTestids.js
CHANGED
|
@@ -21,7 +21,8 @@ var ChatDataTestIds = {
|
|
|
21
21
|
SYSTEM_MSG_TIME: 'chat-system-message-time',
|
|
22
22
|
BUBBLE: 'ds-chat-bubble',
|
|
23
23
|
BUBBLE_TITLE: 'chat-bubble-title',
|
|
24
|
-
BUBBLE_BODY: 'chat-bubble-body'
|
|
24
|
+
BUBBLE_BODY: 'chat-bubble-body',
|
|
25
|
+
BANNER: 'ds-banner-container'
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
exports.ChatDataTestIds = ChatDataTestIds;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatDataTestids.js","sources":["../../src/ChatDataTestids.tsx"],"sourcesContent":["export const ChatDataTestIds = {\n COMPOSER_TEXTAREA: 'chat-composer-textarea',\n COMPOSER_SEND_BUTTON: 'chat-composer-send-button',\n CARD_TITLE: 'chat-card-title',\n CARD_WRAPPER: 'chat-card-wrapper',\n CARD_TIME: 'chat-card-time',\n CARD_RIGHT_ADDON: 'chat-right-addon',\n CARD_CONTENT: 'chat-card-content',\n LOADING_INDICATOR: 'ds-chat-loading-indicator',\n HEADER_TITLE: 'chat-header-title',\n HEADER_CHILDREN: 'chat-header-children',\n THREAD_CONTAINER: 'chat-thread-container',\n LOAD_MORE_BUTTON: 'ds-chat-load-more-btn',\n FLOATING_BUTTON: 'chat-floating-button',\n SYSTEM_MSG_TITLE: 'chat-system-message-title',\n SYSTEM_MSG_BODY: 'chat-system-message-body',\n SYSTEM_MSG_TIME: 'chat-system-message-time',\n BUBBLE: 'ds-chat-bubble',\n BUBBLE_TITLE: 'chat-bubble-title',\n BUBBLE_BODY: 'chat-bubble-body',\n};\n"],"names":["ChatDataTestIds","COMPOSER_TEXTAREA","COMPOSER_SEND_BUTTON","CARD_TITLE","CARD_WRAPPER","CARD_TIME","CARD_RIGHT_ADDON","CARD_CONTENT","LOADING_INDICATOR","HEADER_TITLE","HEADER_CHILDREN","THREAD_CONTAINER","LOAD_MORE_BUTTON","FLOATING_BUTTON","SYSTEM_MSG_TITLE","SYSTEM_MSG_BODY","SYSTEM_MSG_TIME","BUBBLE","BUBBLE_TITLE","BUBBLE_BODY"],"mappings":";;;;IAAaA,eAAe,GAAG;AAC7BC,EAAAA,iBAAiB,EAAE,wBADU;AAE7BC,EAAAA,oBAAoB,EAAE,2BAFO;AAG7BC,EAAAA,UAAU,EAAE,iBAHiB;AAI7BC,EAAAA,YAAY,EAAE,mBAJe;AAK7BC,EAAAA,SAAS,EAAE,gBALkB;AAM7BC,EAAAA,gBAAgB,EAAE,kBANW;AAO7BC,EAAAA,YAAY,EAAE,mBAPe;AAQ7BC,EAAAA,iBAAiB,EAAE,2BARU;AAS7BC,EAAAA,YAAY,EAAE,mBATe;AAU7BC,EAAAA,eAAe,EAAE,sBAVY;AAW7BC,EAAAA,gBAAgB,EAAE,uBAXW;AAY7BC,EAAAA,gBAAgB,EAAE,uBAZW;AAa7BC,EAAAA,eAAe,EAAE,sBAbY;AAc7BC,EAAAA,gBAAgB,EAAE,2BAdW;AAe7BC,EAAAA,eAAe,EAAE,0BAfY;AAgB7BC,EAAAA,eAAe,EAAE,0BAhBY;AAiB7BC,EAAAA,MAAM,EAAE,gBAjBqB;AAkB7BC,EAAAA,YAAY,EAAE,mBAlBe;AAmB7BC,EAAAA,WAAW,EAAE;
|
|
1
|
+
{"version":3,"file":"ChatDataTestids.js","sources":["../../src/ChatDataTestids.tsx"],"sourcesContent":["export const ChatDataTestIds = {\n COMPOSER_TEXTAREA: 'chat-composer-textarea',\n COMPOSER_SEND_BUTTON: 'chat-composer-send-button',\n CARD_TITLE: 'chat-card-title',\n CARD_WRAPPER: 'chat-card-wrapper',\n CARD_TIME: 'chat-card-time',\n CARD_RIGHT_ADDON: 'chat-right-addon',\n CARD_CONTENT: 'chat-card-content',\n LOADING_INDICATOR: 'ds-chat-loading-indicator',\n HEADER_TITLE: 'chat-header-title',\n HEADER_CHILDREN: 'chat-header-children',\n THREAD_CONTAINER: 'chat-thread-container',\n LOAD_MORE_BUTTON: 'ds-chat-load-more-btn',\n FLOATING_BUTTON: 'chat-floating-button',\n SYSTEM_MSG_TITLE: 'chat-system-message-title',\n SYSTEM_MSG_BODY: 'chat-system-message-body',\n SYSTEM_MSG_TIME: 'chat-system-message-time',\n BUBBLE: 'ds-chat-bubble',\n BUBBLE_TITLE: 'chat-bubble-title',\n BUBBLE_BODY: 'chat-bubble-body',\n BANNER: 'ds-banner-container',\n};\n"],"names":["ChatDataTestIds","COMPOSER_TEXTAREA","COMPOSER_SEND_BUTTON","CARD_TITLE","CARD_WRAPPER","CARD_TIME","CARD_RIGHT_ADDON","CARD_CONTENT","LOADING_INDICATOR","HEADER_TITLE","HEADER_CHILDREN","THREAD_CONTAINER","LOAD_MORE_BUTTON","FLOATING_BUTTON","SYSTEM_MSG_TITLE","SYSTEM_MSG_BODY","SYSTEM_MSG_TIME","BUBBLE","BUBBLE_TITLE","BUBBLE_BODY","BANNER"],"mappings":";;;;IAAaA,eAAe,GAAG;AAC7BC,EAAAA,iBAAiB,EAAE,wBADU;AAE7BC,EAAAA,oBAAoB,EAAE,2BAFO;AAG7BC,EAAAA,UAAU,EAAE,iBAHiB;AAI7BC,EAAAA,YAAY,EAAE,mBAJe;AAK7BC,EAAAA,SAAS,EAAE,gBALkB;AAM7BC,EAAAA,gBAAgB,EAAE,kBANW;AAO7BC,EAAAA,YAAY,EAAE,mBAPe;AAQ7BC,EAAAA,iBAAiB,EAAE,2BARU;AAS7BC,EAAAA,YAAY,EAAE,mBATe;AAU7BC,EAAAA,eAAe,EAAE,sBAVY;AAW7BC,EAAAA,gBAAgB,EAAE,uBAXW;AAY7BC,EAAAA,gBAAgB,EAAE,uBAZW;AAa7BC,EAAAA,eAAe,EAAE,sBAbY;AAc7BC,EAAAA,gBAAgB,EAAE,2BAdW;AAe7BC,EAAAA,eAAe,EAAE,0BAfY;AAgB7BC,EAAAA,eAAe,EAAE,0BAhBY;AAiB7BC,EAAAA,MAAM,EAAE,gBAjBqB;AAkB7BC,EAAAA,YAAY,EAAE,mBAlBe;AAmB7BC,EAAAA,WAAW,EAAE,kBAnBgB;AAoB7BC,EAAAA,MAAM,EAAE;AApBqB;;;;"}
|
|
@@ -23,7 +23,7 @@ var ChatBubbleArrow = function ChatBubbleArrow(_ref) {
|
|
|
23
23
|
viewBox: "0 0 15 14"
|
|
24
24
|
}, /*#__PURE__*/React__default['default'].createElement("defs", null, /*#__PURE__*/React__default['default'].createElement("path", {
|
|
25
25
|
d: "M12,8.5 C12,7.9373169 11.6782751,7.4856453 11.2282104,7.196228 C11.2286673,7.1967363 3,2 3,2 L3,10 L10.5627441,10 L10.5658569,9.9933472 C11.3630371,9.9580688 12,9.3058472 12,8.5 Z",
|
|
26
|
-
id: "path-
|
|
26
|
+
id: "path-chat-bubble"
|
|
27
27
|
}), /*#__PURE__*/React__default['default'].createElement("filter", {
|
|
28
28
|
x: "-55.6%",
|
|
29
29
|
y: "-50.0%",
|
|
@@ -57,11 +57,11 @@ var ChatBubbleArrow = function ChatBubbleArrow(_ref) {
|
|
|
57
57
|
fill: "black",
|
|
58
58
|
fillOpacity: "1",
|
|
59
59
|
filter: "url(#filter-2)",
|
|
60
|
-
xlinkHref: "#path-
|
|
60
|
+
xlinkHref: "#path-chat-bubble"
|
|
61
61
|
}), /*#__PURE__*/React__default['default'].createElement("use", {
|
|
62
62
|
fill: "#FFFFFF",
|
|
63
63
|
fillRule: "evenodd",
|
|
64
|
-
xlinkHref: "#path-
|
|
64
|
+
xlinkHref: "#path-chat-bubble"
|
|
65
65
|
})))) : /*#__PURE__*/React__default['default'].createElement("svg", {
|
|
66
66
|
width: "9px",
|
|
67
67
|
height: "8px",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBubbleArrow.js","sources":["../../../../src/parts/bubble/ChatBubbleArrow.tsx"],"sourcesContent":["import React from 'react';\nimport { StyledBubbleArrow } from './styled';\nimport { BUBBLE_TYPES, BubbleProps, propsArrowBubble } from './props';\n\nexport const ChatBubbleArrow = ({ type }: Pick<BubbleProps, 'type'>): JSX.Element => (\n <StyledBubbleArrow>\n {type === BUBBLE_TYPES.RECIPIENT ? (\n <svg width=\"15px\" height=\"14px\" viewBox=\"0 0 15 14\">\n <defs>\n <path\n d=\"M12,8.5 C12,7.9373169 11.6782751,7.4856453 11.2282104,7.196228 C11.2286673,7.1967363 3,2 3,2 L3,10 L10.5627441,10 L10.5658569,9.9933472 C11.3630371,9.9580688 12,9.3058472 12,8.5 Z\"\n id=\"path-
|
|
1
|
+
{"version":3,"file":"ChatBubbleArrow.js","sources":["../../../../src/parts/bubble/ChatBubbleArrow.tsx"],"sourcesContent":["import React from 'react';\nimport { StyledBubbleArrow } from './styled';\nimport { BUBBLE_TYPES, BubbleProps, propsArrowBubble } from './props';\n\nexport const ChatBubbleArrow = ({ type }: Pick<BubbleProps, 'type'>): JSX.Element => (\n <StyledBubbleArrow>\n {type === BUBBLE_TYPES.RECIPIENT ? (\n <svg width=\"15px\" height=\"14px\" viewBox=\"0 0 15 14\">\n <defs>\n <path\n d=\"M12,8.5 C12,7.9373169 11.6782751,7.4856453 11.2282104,7.196228 C11.2286673,7.1967363 3,2 3,2 L3,10 L10.5627441,10 L10.5658569,9.9933472 C11.3630371,9.9580688 12,9.3058472 12,8.5 Z\"\n id=\"path-chat-bubble\"\n ></path>\n <filter x=\"-55.6%\" y=\"-50.0%\" width=\"211.1%\" height=\"225.0%\" filterUnits=\"objectBoundingBox\" id=\"filter-2\">\n <feOffset dx=\"2.3\" dy=\"1.2\" in=\"SourceAlpha\" result=\"shadowOffsetOuter1\"></feOffset>\n <feGaussianBlur stdDeviation=\"1.5\" in=\"shadowOffsetOuter1\" result=\"shadowBlurOuter1\"></feGaussianBlur>\n <feColorMatrix\n values=\"0 0 0 0 0.207843137 \n 0 0 0 0 0.235294118 \n 0 0 0 0 0.274509804 \n 0 0 0 0.8 0\"\n type=\"matrix\"\n in=\"shadowBlurOuter1\"\n ></feColorMatrix>\n </filter>\n </defs>\n <g id=\"[DSK]-Visual-Design\" stroke=\"none\" strokeWidth=\"1\" fill=\"none\" fillRule=\"evenodd\">\n <g id=\"Path-Copy\" transform=\"translate(7.500000, 6.000000) scale(-1, 1) translate(-7.500000, -6.000000) \">\n <use fill=\"black\" fillOpacity=\"1\" filter=\"url(#filter-2)\" xlinkHref=\"#path-chat-bubble\"></use>\n <use fill=\"#FFFFFF\" fillRule=\"evenodd\" xlinkHref=\"#path-chat-bubble\"></use>\n </g>\n </g>\n </svg>\n ) : (\n <svg width=\"9px\" height=\"8px\" viewBox=\"0 0 9 8\">\n <g stroke=\"none\" strokeWidth=\"1\" fill=\"none\" fillRule=\"evenodd\">\n <path\n d=\"M9,6.5 C9,5.9373169 8.6782751,5.4856453 8.2282104,5.196228 C8.2286673,5.1967363 0,0 0,0 L0,8 L7.5627441,8 L7.5658569,7.9933472 C8.3630371,7.9580688 9,7.3058472 9,6.5 Z\"\n id=\"Path\"\n fill=\"#1E79C2\"\n ></path>\n </g>\n </svg>\n )}\n </StyledBubbleArrow>\n);\n\nChatBubbleArrow.propTypes = propsArrowBubble;\n"],"names":["ChatBubbleArrow","type","React","StyledBubbleArrow","BUBBLE_TYPES","RECIPIENT","propTypes","propsArrowBubble"],"mappings":";;;;;;;;;;;;;;;;;IAIaA,eAAe,GAAG,SAAlBA,eAAkB;AAAA,MAAGC,IAAH,QAAGA,IAAH;AAAA,sBAC7BC,wCAACC,qCAAD,QACGF,IAAI,KAAKG,+BAAY,CAACC,SAAtB,gBACCH;AAAK,IAAA,KAAK,EAAC,MAAX;AAAkB,IAAA,MAAM,EAAC,MAAzB;AAAgC,IAAA,OAAO,EAAC;AAAxC,kBACEA,mEACEA;AACE,IAAA,CAAC,EAAC,qLADJ;AAEE,IAAA,EAAE,EAAC;AAFL,IADF,eAKEA;AAAQ,IAAA,CAAC,EAAC,QAAV;AAAmB,IAAA,CAAC,EAAC,QAArB;AAA8B,IAAA,KAAK,EAAC,QAApC;AAA6C,IAAA,MAAM,EAAC,QAApD;AAA6D,IAAA,WAAW,EAAC,mBAAzE;AAA6F,IAAA,EAAE,EAAC;AAAhG,kBACEA;AAAU,IAAA,EAAE,EAAC,KAAb;AAAmB,IAAA,EAAE,EAAC,KAAtB;AAA4B,IAAA,EAAE,EAAC,aAA/B;AAA6C,IAAA,MAAM,EAAC;AAApD,IADF,eAEEA;AAAgB,IAAA,YAAY,EAAC,KAA7B;AAAmC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Items,
|
|
70
|
-
getMoreMessages = props.getMoreMessages
|
|
70
|
+
getMoreMessages = props.getMoreMessages,
|
|
71
|
+
ariaLabel = props.ariaLabel;
|
|
71
72
|
var bannerRef = React__default['default'].useRef({
|
|
72
73
|
focusOnWrapper: lodash.noop,
|
|
73
74
|
focusOnLink: lodash.noop
|
|
@@ -113,7 +114,7 @@ var ChatContainer = function ChatContainer(props) {
|
|
|
113
114
|
rows: ['minmax(0, 1fr)', 'auto'],
|
|
114
115
|
ref: containerRef,
|
|
115
116
|
role: "region",
|
|
116
|
-
"aria-label":
|
|
117
|
+
"aria-label": ariaLabel
|
|
117
118
|
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
118
119
|
style: {
|
|
119
120
|
position: 'relative',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatContainer.js","sources":["../../../../src/parts/chat-container/ChatContainer.tsx"],"sourcesContent":["/* eslint-disable max-lines */\n/* eslint-disable complexity */\nimport React from 'react';\nimport { noop } from 'lodash';\nimport { describe } from 'react-desc';\nimport DSIndeterminateProgressIndicator from '@elliemae/ds-indeterminate-progress-indicator';\nimport DSBanner, { BANNER_TYPES } from '@elliemae/ds-banner';\nimport { ChatComposer } from '../chat-composer';\nimport { ChatContainerMessagesList } from '../chat-container-messages-list';\nimport { ChatContainerProps, defaultProps, containerProps } from './props';\nimport { StyledChatContainerContent, StyledIndicatorContainer, MobileStyledChatContainerContent } from './styled';\nimport { useValidateProps } from './config/useValidateProps';\n\nconst ChatContainer = (props: ChatContainerProps): JSX.Element => {\n useValidateProps(props, ChatContainerWithSchema.toTypescript());\n\n const {\n sendingText,\n sendingMessages,\n bannerPosition,\n bannerProps,\n messagesListProps,\n composerProps,\n composerProps: { onResize: onComposerResize, onKeyDown: onComposerKeyDown },\n actionRef,\n autoScroll,\n device,\n isLoading,\n hasMoreItems,\n getMoreMessages,\n } = props;\n const bannerRef = React.useRef({ focusOnWrapper: noop, focusOnLink: noop });\n const containerRef = React.useRef<HTMLElement>();\n const listRef = React.useRef({ scrollToIndex: noop });\n const onResize = React.useCallback(\n (height: number) => {\n if (onComposerResize) onComposerResize(height);\n if (autoScroll) {\n listRef.current.scrollToIndex(messagesListProps.messages.length - 1, {\n align: 'end',\n });\n }\n },\n [onComposerResize, messagesListProps.messages, autoScroll],\n );\n const Container = device === 'desktop' ? StyledChatContainerContent : MobileStyledChatContainerContent;\n const handleTabs = React.useCallback(\n (e) => {\n if (onComposerKeyDown) onComposerKeyDown(e);\n else {\n const ref = actionRef || listRef;\n if (e.shiftKey && e.key === 'Tab') {\n e.preventDefault();\n if (['top', 'bottom'].includes(bannerPosition)) {\n bannerRef.current.focusOnWrapper();\n } else {\n const last = ref.current.getMessagesInView().pop();\n ref.current.focusToIndexWithoutScroll(last);\n }\n }\n }\n },\n [actionRef, onComposerKeyDown, bannerPosition],\n );\n\n // Map actions\n React.useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.focusOnBanner = bannerRef.current.focusOnWrapper;\n actionRef.current.focusOnBannerLink = bannerRef.current.focusOnLink;\n }\n }, [actionRef]);\n\n return (\n <Container rows={['minmax(0, 1fr)', 'auto']} ref={containerRef} role=\"region\" aria-label=\"chat window\">\n <div style={{ position: 'relative', overflow: 'hidden' }}>\n <ChatContainerMessagesList\n {...messagesListProps}\n actionRef={actionRef || listRef}\n isLoading={isLoading}\n hasMoreItems={hasMoreItems}\n getMoreMessages={getMoreMessages}\n sendingMessages={sendingMessages}\n sendingText={sendingText}\n bannerPosition={bannerPosition}\n bannerRef={bannerRef}\n />\n {['top', 'bottom'].includes(isLoading) ? (\n <StyledIndicatorContainer isLoading={isLoading} data-testid=\"ds-chat-loading-indicator\">\n <DSIndeterminateProgressIndicator processing title=\"Loading\" />\n </StyledIndicatorContainer>\n ) : null}\n <StyledIndicatorContainer linear isLoading={bannerPosition}>\n <DSBanner\n showCloseButton\n label={bannerProps.label || 'Unread messages'}\n containerProps={{ id: 'ds-chat-banner' }}\n actionLink={{\n label: bannerProps.viewLabel || 'View',\n onClick: bannerProps.onView,\n }}\n onClose={bannerProps.onClose}\n isOpen\n type={bannerProps.type || BANNER_TYPES.INFO}\n actionRef={bannerRef}\n />\n </StyledIndicatorContainer>\n {sendingMessages && sendingMessages.length > 0 ? (\n <StyledIndicatorContainer isLoading=\"bottom\" linear data-testid=\"ds-chat-loading-indicator\">\n <DSIndeterminateProgressIndicator processing title=\"Loading\" lineOnly />\n </StyledIndicatorContainer>\n ) : null}\n </div>\n <ChatComposer\n {...composerProps}\n onKeyDown={handleTabs}\n onResize={onResize}\n maxHeight={(containerRef.current?.clientHeight || 0) / 2}\n actionRef={actionRef || listRef}\n />\n </Container>\n );\n};\n\nChatContainer.propTypes = containerProps;\nChatContainer.defaultProps = defaultProps;\nconst ChatContainerWithSchema = describe(ChatContainer);\nChatContainerWithSchema.propTypes = containerProps;\n\nexport { ChatContainer, ChatContainerWithSchema };\n"],"names":["ChatContainer","props","useValidateProps","ChatContainerWithSchema","toTypescript","sendingText","sendingMessages","bannerPosition","bannerProps","messagesListProps","composerProps","onComposerResize","onResize","onComposerKeyDown","onKeyDown","actionRef","autoScroll","device","isLoading","hasMoreItems","getMoreMessages","bannerRef","React","useRef","focusOnWrapper","noop","focusOnLink","containerRef","listRef","scrollToIndex","useCallback","height","current","messages","length","align","Container","StyledChatContainerContent","MobileStyledChatContainerContent","handleTabs","e","ref","shiftKey","key","preventDefault","includes","last","getMessagesInView","pop","focusToIndexWithoutScroll","useEffect","focusOnBanner","focusOnBannerLink","position","overflow","ChatContainerMessagesList","StyledIndicatorContainer","DSIndeterminateProgressIndicator","DSBanner","label","id","viewLabel","onClick","onView","onClose","type","BANNER_TYPES","INFO","ChatComposer","clientHeight","propTypes","containerProps","defaultProps","describe"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAaMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,KAAD,EAA4C;AAAA;;AAChEC,EAAAA,4D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D,SAAZ,IAAyB,MADtB;AAEVC,MAAAA,OAAO,EAAEtD,WAAW,CAACuD;AAFX,KAJd;AAQE,IAAA,OAAO,EAAEvD,WAAW,CAACwD,OARvB;AASE,IAAA,MAAM,MATR;AAUE,IAAA,IAAI,EAAExD,WAAW,CAACyD,IAAZ,IAAoBC,qBAAY,CAACC,IAVzC;AAWE,IAAA,SAAS,EAAE9C;AAXb,IADF,CAjBF,EAgCGf,eAAe,IAAIA,eAAe,CAAC4B,MAAhB,GAAyB,CAA5C,gBACCZ,wCAACkC,mDAAD;AAA0B,IAAA,SAAS,EAAC,QAApC;AAA6C,IAAA,MAAM,MAAnD;AAAoD,mBAAY;AAAhE,kBACElC,wCAACmC,oDAAD;AAAkC,IAAA,UAAU,MAA5C;AAA6C,IAAA,KAAK,EAAC,SAAnD;AAA6D,IAAA,QAAQ;AAArE,IADF,CADD,GAIG,IApCN,CADF,eAuCEnC,wCAAC8C,qDAAD,mCACM1D,aADN;AAEE,IAAA,SAAS,EAAE6B,UAFb;AAGE,IAAA,QAAQ,EAAE3B,QAHZ;AAIE,IAAA,SAAS,EAAE,CAAC,0BAAAe,YAAY,CAACK,OAAb,gFAAsBqC,YAAtB,KAAsC,CAAvC,IAA4C,CAJzD;AAKE,IAAA,SAAS,EAAEtD,SAAS,IAAIa;AAL1B,KAvCF,CADF;AAiDD;;AAED5B,aAAa,CAACsE,SAAd,GAA0BC,wCAA1B;AACAvE,aAAa,CAACwE,YAAd,GAA6BA,sCAA7B;IACMrE,uBAAuB,GAAGsE,kBAAQ,CAACzE,aAAD;AACxCG,uBAAuB,CAACmE,SAAxB,GAAoCC,wCAApC;;;;;"}
|
|
1
|
+
{"version":3,"file":"ChatContainer.js","sources":["../../../../src/parts/chat-container/ChatContainer.tsx"],"sourcesContent":["/* eslint-disable max-lines */\n/* eslint-disable complexity */\nimport React from 'react';\nimport { noop } from 'lodash';\nimport { describe } from 'react-desc';\nimport DSIndeterminateProgressIndicator from '@elliemae/ds-indeterminate-progress-indicator';\nimport DSBanner, { BANNER_TYPES } from '@elliemae/ds-banner';\nimport { ChatComposer } from '../chat-composer';\nimport { ChatContainerMessagesList } from '../chat-container-messages-list';\nimport { ChatContainerProps, defaultProps, containerProps } from './props';\nimport { StyledChatContainerContent, StyledIndicatorContainer, MobileStyledChatContainerContent } from './styled';\nimport { useValidateProps } from './config/useValidateProps';\n\nconst ChatContainer = (props: ChatContainerProps): JSX.Element => {\n useValidateProps(props, ChatContainerWithSchema.toTypescript());\n\n const {\n sendingText,\n sendingMessages,\n bannerPosition,\n bannerProps,\n messagesListProps,\n composerProps,\n composerProps: { onResize: onComposerResize, onKeyDown: onComposerKeyDown },\n actionRef,\n autoScroll,\n device,\n isLoading,\n hasMoreItems,\n getMoreMessages,\n ariaLabel\n } = props;\n const bannerRef = React.useRef({ focusOnWrapper: noop, focusOnLink: noop });\n const containerRef = React.useRef<HTMLElement>();\n const listRef = React.useRef({ scrollToIndex: noop });\n const onResize = React.useCallback(\n (height: number) => {\n if (onComposerResize) onComposerResize(height);\n if (autoScroll) {\n listRef.current.scrollToIndex(messagesListProps.messages.length - 1, {\n align: 'end',\n });\n }\n },\n [onComposerResize, messagesListProps.messages, autoScroll],\n );\n const Container = device === 'desktop' ? StyledChatContainerContent : MobileStyledChatContainerContent;\n const handleTabs = React.useCallback(\n (e) => {\n if (onComposerKeyDown) onComposerKeyDown(e);\n else {\n const ref = actionRef || listRef;\n if (e.shiftKey && e.key === 'Tab') {\n e.preventDefault();\n if (['top', 'bottom'].includes(bannerPosition)) {\n bannerRef.current.focusOnWrapper();\n } else {\n const last = ref.current.getMessagesInView().pop();\n ref.current.focusToIndexWithoutScroll(last);\n }\n }\n }\n },\n [actionRef, onComposerKeyDown, bannerPosition],\n );\n\n // Map actions\n React.useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.focusOnBanner = bannerRef.current.focusOnWrapper;\n actionRef.current.focusOnBannerLink = bannerRef.current.focusOnLink;\n }\n }, [actionRef]);\n\n return (\n <Container rows={['minmax(0, 1fr)', 'auto']} ref={containerRef} role=\"region\" aria-label={ariaLabel}>\n <div style={{ position: 'relative', overflow: 'hidden' }}>\n <ChatContainerMessagesList\n {...messagesListProps}\n actionRef={actionRef || listRef}\n isLoading={isLoading}\n hasMoreItems={hasMoreItems}\n getMoreMessages={getMoreMessages}\n sendingMessages={sendingMessages}\n sendingText={sendingText}\n bannerPosition={bannerPosition}\n bannerRef={bannerRef}\n />\n {['top', 'bottom'].includes(isLoading) ? (\n <StyledIndicatorContainer isLoading={isLoading} data-testid=\"ds-chat-loading-indicator\">\n <DSIndeterminateProgressIndicator processing title=\"Loading\" />\n </StyledIndicatorContainer>\n ) : null}\n <StyledIndicatorContainer linear isLoading={bannerPosition}>\n <DSBanner\n showCloseButton\n label={bannerProps.label || 'Unread messages'}\n containerProps={{ id: 'ds-chat-banner' }}\n actionLink={{\n label: bannerProps.viewLabel || 'View',\n onClick: bannerProps.onView,\n }}\n onClose={bannerProps.onClose}\n isOpen\n type={bannerProps.type || BANNER_TYPES.INFO}\n actionRef={bannerRef}\n />\n </StyledIndicatorContainer>\n {sendingMessages && sendingMessages.length > 0 ? (\n <StyledIndicatorContainer isLoading=\"bottom\" linear data-testid=\"ds-chat-loading-indicator\">\n <DSIndeterminateProgressIndicator processing title=\"Loading\" lineOnly />\n </StyledIndicatorContainer>\n ) : null}\n </div>\n <ChatComposer\n {...composerProps}\n onKeyDown={handleTabs}\n onResize={onResize}\n maxHeight={(containerRef.current?.clientHeight || 0) / 2}\n actionRef={actionRef || listRef}\n />\n </Container>\n );\n};\n\nChatContainer.propTypes = containerProps;\nChatContainer.defaultProps = defaultProps;\nconst ChatContainerWithSchema = describe(ChatContainer);\nChatContainerWithSchema.propTypes = containerProps;\n\nexport { ChatContainer, ChatContainerWithSchema };\n"],"names":["ChatContainer","props","useValidateProps","ChatContainerWithSchema","toTypescript","sendingText","sendingMessages","bannerPosition","bannerProps","messagesListProps","composerProps","onComposerResize","onResize","onComposerKeyDown","onKeyDown","actionRef","autoScroll","device","isLoading","hasMoreItems","getMoreMessages","ariaLabel","bannerRef","React","useRef","focusOnWrapper","noop","focusOnLink","containerRef","listRef","scrollToIndex","useCallback","height","current","messages","length","align","Container","StyledChatContainerContent","MobileStyledChatContainerContent","handleTabs","e","ref","shiftKey","key","preventDefault","includes","last","getMessagesInView","pop","focusToIndexWithoutScroll","useEffect","focusOnBanner","focusOnBannerLink","position","overflow","ChatContainerMessagesList","StyledIndicatorContainer","DSIndeterminateProgressIndicator","DSBanner","label","id","viewLabel","onClick","onView","onClose","type","BANNER_TYPES","INFO","ChatComposer","clientHeight","propTypes","containerProps","defaultProps","describe"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAaMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,KAAD,EAA4C;AAAA;;AAChEC,EAAAA,4DAAgB,CAACD,KAAD,EAAQE,uBAAuB,CAACC,YAAxB,EAAR,CAAhB;AAEA,MACEC,WADF,GAeIJ,KAfJ,CACEI,WADF;AAAA,MAEEC,eAFF,GAeIL,KAfJ,CAEEK,eAFF;AAAA,MAGEC,cAHF,GAeIN,KAfJ,CAGEM,cAHF;AAAA,MAIEC,WAJF,GAeIP,KAfJ,CAIEO,WAJF;AAAA,MAKEC,iBALF,GAeIR,KAfJ,CAKEQ,iBALF;AAAA,MAMEC,aANF,GAeIT,KAfJ,CAMES,aANF;AAAA,6BAeIT,KAfJ,CAOES,aAPF;AAAA,MAO6BC,gBAP7B,wBAOmBC,QAPnB;AAAA,MAO0DC,iBAP1D,wBAO+CC,SAP/C;AAAA,MAQEC,SARF,GAeId,KAfJ,CAQEc,SARF;AAAA,MASEC,UATF,GAeIf,KAfJ,CASEe,UATF;AAAA,MAUEC,MAVF,GAeIhB,KAfJ,CAUEgB,MAVF;AAAA,MAWEC,SAXF,GAeIjB,KAfJ,CAWEiB,SAXF;AAAA,MAYEC,YAZF,GAeIlB,KAfJ,CAYEkB,Y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AE8B,UAFb;AAGE,IAAA,QAAQ,EAAE5B,QAHZ;AAIE,IAAA,SAAS,EAAE,CAAC,0BAAAgB,YAAY,CAACK,OAAb,gFAAsBqC,YAAtB,KAAsC,CAAvC,IAA4C,CAJzD;AAKE,IAAA,SAAS,EAAEvD,SAAS,IAAIc;AAL1B,KAvCF,CADF;AAiDD;;AAED7B,aAAa,CAACuE,SAAd,GAA0BC,wCAA1B;AACAxE,aAAa,CAACyE,YAAd,GAA6BA,sCAA7B;IACMtE,uBAAuB,GAAGuE,kBAAQ,CAAC1E,aAAD;AACxCG,uBAAuB,CAACoE,SAAxB,GAAoCC,wCAApC;;;;;"}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var reactDesc = require('react-desc');
|
|
6
6
|
var lodash = require('lodash');
|
|
7
|
+
var DSBanner = require('@elliemae/ds-banner');
|
|
7
8
|
var parts_chatContainerMessagesList_props = require('../chat-container-messages-list/props.js');
|
|
8
9
|
var parts_chatComposer_props = require('../chat-composer/props.js');
|
|
9
10
|
|
|
@@ -18,13 +19,15 @@ var defaultProps = {
|
|
|
18
19
|
getMoreMessages: lodash.noop,
|
|
19
20
|
bannerPosition: undefined,
|
|
20
21
|
bannerProps: {
|
|
22
|
+
type: DSBanner.BANNER_TYPES.INFO,
|
|
21
23
|
label: 'Unread Messages',
|
|
22
24
|
viewLabel: 'View',
|
|
23
25
|
onView: lodash.noop,
|
|
24
26
|
onClose: lodash.noop
|
|
25
27
|
},
|
|
26
28
|
sendingMessages: undefined,
|
|
27
|
-
sendingText: 'Sending'
|
|
29
|
+
sendingText: 'Sending',
|
|
30
|
+
ariaLabel: 'Chat window'
|
|
28
31
|
};
|
|
29
32
|
var containerProps = {
|
|
30
33
|
messagesListProps: reactDesc.PropTypes.object.description('ChatMessageList props "messages" / "onScrollEnds"').defaultValue(defaultProps.messagesListProps),
|
|
@@ -38,7 +41,8 @@ var containerProps = {
|
|
|
38
41
|
bannerProps: reactDesc.PropTypes.object.description("Banner configuration:\n label: string;\n viewLabel: string;\n type: BANNER_TYPES;\n onView: () => void;\n onClose: () => void;\n ").defaultValue(defaultProps.bannerProps),
|
|
39
42
|
sendingMessages: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.arrayOf(reactDesc.PropTypes.string), reactDesc.PropTypes.arrayOf(reactDesc.PropTypes.number)]).description('Array of ids of sending messages').defaultValue(defaultProps.sendingMessages),
|
|
40
43
|
sendingText: reactDesc.PropTypes.string.description('Label description for messages in sending status').defaultValue(defaultProps.sendingText),
|
|
41
|
-
actionRef: reactDesc.PropTypes.object.description("Reference: \n { \n scrollToIndex: (n: number) => void,\n getMessagesInView: () => number[],\n focusToIndex: (n: number) => void,\n focusToList: () => void,\n focusToComposer: () => void,\n focusToSend: () => void,\n }\n \n ").defaultValue(defaultProps.actionRef)
|
|
44
|
+
actionRef: reactDesc.PropTypes.object.description("Reference: \n { \n scrollToIndex: (n: number) => void,\n getMessagesInView: () => number[],\n focusToIndex: (n: number) => void,\n focusToList: () => void,\n focusToComposer: () => void,\n focusToSend: () => void,\n }\n \n ").defaultValue(defaultProps.actionRef),
|
|
45
|
+
ariaLabel: reactDesc.PropTypes.string.description('Aria Label description for chat container').defaultValue(defaultProps.ariaLabel)
|
|
42
46
|
};
|
|
43
47
|
|
|
44
48
|
exports.containerProps = containerProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props.js","sources":["../../../../src/parts/chat-container/props.ts"],"sourcesContent":["import { PropTypes } from 'react-desc';\nimport { noop } from 'lodash';\nimport { BANNER_TYPES } from '@elliemae/ds-banner';\nimport {\n ChatContainerMessagesListProps,\n defaultProps as defaultListProps,\n} from '../chat-container-messages-list/props';\nimport { defaultComposerPros, ChatComposerProps } from '../chat-composer/props';\n\ninterface ChatBannerProps {\n label: string;\n viewLabel: string;\n type
|
|
1
|
+
{"version":3,"file":"props.js","sources":["../../../../src/parts/chat-container/props.ts"],"sourcesContent":["import { PropTypes } from 'react-desc';\nimport { noop } from 'lodash';\nimport { BANNER_TYPES } from '@elliemae/ds-banner';\nimport {\n ChatContainerMessagesListProps,\n defaultProps as defaultListProps,\n} from '../chat-container-messages-list/props';\nimport { defaultComposerPros, ChatComposerProps } from '../chat-composer/props';\n\ninterface ChatBannerProps {\n label: string;\n viewLabel: string;\n type?: BANNER_TYPES;\n onView: () => void;\n onClose: () => void;\n}\nexport interface ChatContainerProps {\n messagesListProps: Pick<ChatContainerMessagesListProps, 'messages' | 'onScrollEnds'>;\n composerProps: ChatComposerProps;\n actionRef: PropTypes.func;\n autoScroll: boolean;\n device: 'desktop' | 'mobile';\n isLoading?: 'top' | 'bottom';\n hasMoreItems?: 'top' | 'bottom';\n getMoreMessages: PropTypes.func;\n bannerPosition?: 'top' | 'bottom';\n bannerProps?: ChatBannerProps;\n sendingMessages?: string[] | number[];\n sendingText: string;\n ariaLabel: string;\n}\n\nexport const defaultProps: ChatContainerProps = {\n messagesListProps: defaultListProps,\n composerProps: defaultComposerPros,\n actionRef: undefined,\n autoScroll: false,\n device: 'desktop',\n isLoading: undefined,\n hasMoreItems: undefined,\n getMoreMessages: noop,\n bannerPosition: undefined,\n bannerProps: {\n type: BANNER_TYPES.INFO,\n label: 'Unread Messages',\n viewLabel: 'View',\n onView: noop,\n onClose: noop,\n },\n sendingMessages: undefined,\n sendingText: 'Sending',\n ariaLabel: 'Chat window',\n};\n\nexport const containerProps = {\n messagesListProps: PropTypes.object\n .description('ChatMessageList props \"messages\" / \"onScrollEnds\"')\n .defaultValue(defaultProps.messagesListProps),\n composerProps: PropTypes.object.description('Composer configuration').defaultValue(defaultProps.composerProps),\n autoScroll: PropTypes.bool.description('Auto scroll to bottom on resize').defaultValue(defaultProps.autoScroll),\n device: PropTypes.string\n .description('Option to render mobile or desktop style composer')\n .defaultValue(defaultProps.device),\n isLoading: PropTypes.oneOf(['top', 'bottom', undefined]).description(\n 'Show Loading messages indicator at the `top` or `bottom` of the container',\n ),\n hasMoreItems: PropTypes.oneOf(['top', 'bottom', undefined]).description(\n 'Show Load More button at the `top` or `bottom` of the container',\n ),\n getMoreMessages: PropTypes.func\n .description('Called when the user clicks on load more')\n .defaultValue(defaultProps.getMoreMessages),\n bannerPosition: PropTypes.oneOf(['top', 'bottom', undefined]).description(\n 'Show Loading messages indicator at the `top` or `bottom` of the container',\n ),\n bannerProps: PropTypes.object\n .description(\n `Banner configuration:\n label: string;\n viewLabel: string;\n type: BANNER_TYPES;\n onView: () => void;\n onClose: () => void;\n `,\n )\n .defaultValue(defaultProps.bannerProps),\n sendingMessages: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.arrayOf(PropTypes.number)])\n .description('Array of ids of sending messages')\n .defaultValue(defaultProps.sendingMessages),\n sendingText: PropTypes.string\n .description('Label description for messages in sending status')\n .defaultValue(defaultProps.sendingText),\n actionRef: PropTypes.object\n .description(\n `Reference: \n { \n scrollToIndex: (n: number) => void,\n getMessagesInView: () => number[],\n focusToIndex: (n: number) => void,\n focusToList: () => void,\n focusToComposer: () => void,\n focusToSend: () => void,\n }\n \n `,\n )\n .defaultValue(defaultProps.actionRef),\n ariaLabel: PropTypes.string\n .description('Aria Label description for chat container')\n .defaultValue(defaultProps.ariaLabel),\n};\n"],"names":["defaultProps","messagesListProps","defaultListProps","composerProps","defaultComposerPros","actionRef","undefined","autoScroll","device","isLoading","hasMoreItems","getMoreMessages","noop","bannerPosition","bannerProps","type","BANNER_TYPES","INFO","label","viewLabel","onView","onClose","sendingMessages","sendingText","ariaLabel","containerProps","PropTypes","object","description","defaultValue","bool","string","oneOf","func","oneOfType","arrayOf","number"],"mappings":";;;;;;;;;;IAgCaA,YAAgC,GAAG;AAC9CC,EAAAA,iBAAiB,EAAEC,kDAD2B;AAE9CC,EAAAA,aAAa,EAAEC,4CAF+B;AAG9CC,EAAAA,SAAS,EAAEC,SAHmC;AAI9CC,EAAAA,UAAU,EAAE,KAJkC;AAK9CC,EAAAA,MAAM,EAAE,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1B,SAAlB,CAAhB,EAA8CsB,WAA9C,CACZ,iEADY,CAZc;AAe5BjB,EAAAA,eAAe,EAAEe,mBAAS,CAACO,IAAV,CACdL,WADc,CACF,0CADE,EAEdC,YAFc,CAED7B,YAAY,CAACW,eAFZ,CAfW;AAkB5BE,EAAAA,cAAc,EAAEa,mBAAS,CAACM,KAAV,CAAgB,CAAC,KAAD,EAAQ,QAAR,EAAkB1B,SAAlB,CAAhB,EAA8CsB,WAA9C,CACd,2EADc,CAlBY;AAqB5Bd,EAAAA,WAAW,EAAEY,mBAAS,CAACC,MAAV,CACVC,WADU,4IAUVC,YAVU,CAUG7B,YAAY,CAACc,WAVhB,CArBe;AAgC5BQ,EAAAA,eAAe,EAAEI,mBAAS,CAACQ,SAAV,CAAoB,CAACR,mBAAS,CAACS,OAAV,CAAkBT,mBAAS,CAACK,MAA5B,CAAD,EAAsCL,mBAAS,CAACS,OAAV,CAAkBT,mBAAS,CAACU,MAA5B,CAAtC,CAApB,EACdR,WADc,CACF,kCADE,EAEdC,YAFc,CAED7B,YAAY,CAACsB,eAFZ,CAhCW;AAmC5BC,EAAAA,WAAW,EAAEG,mBAAS,CAACK,MAAV,CACVH,WADU,CACE,kDADF,EAEVC,YAFU,CAEG7B,YAAY,CAACuB,WAFhB,CAnCe;AAsC5BlB,EAAAA,SAAS,EAAEqB,mBAAS,CAACC,MAAV,CACRC,WADQ,oTAcRC,YAdQ,CAcK7B,YAAY,CAACK,SAdlB,CAtCiB;AAqD5BmB,EAAAA,SAAS,EAAEE,mBAAS,CAACK,MAAV,CACRH,WADQ,CACI,2CADJ,EAERC,YAFQ,CAEK7B,YAAY,CAACwB,SAFlB;AArDiB;;;;;"}
|
|
@@ -90,6 +90,7 @@ var ChatContainerMessagesList = function ChatContainerMessagesList(props) {
|
|
|
90
90
|
return [];
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
if (!virtualListRef.current) return [];
|
|
93
94
|
pendingOnScroll.current = false;
|
|
94
95
|
|
|
95
96
|
var _virtualListRef$curre = (_virtualListRef$curre2 = virtualListRef.current) === null || _virtualListRef$curre2 === void 0 ? void 0 : _virtualListRef$curre2.getBoundingClientRect(),
|
|
@@ -206,7 +207,7 @@ var ChatContainerMessagesList = function ChatContainerMessagesList(props) {
|
|
|
206
207
|
|
|
207
208
|
break;
|
|
208
209
|
}
|
|
209
|
-
}, [actionRef, hasMoreItems, messages.length, bannerPosition, scrollAndFocus]);
|
|
210
|
+
}, [actionRef, bannerRef, hasMoreItems, messages.length, bannerPosition, scrollAndFocus]);
|
|
210
211
|
var handleListKey = React__default['default'].useCallback(function (e) {
|
|
211
212
|
var key = e.key;
|
|
212
213
|
|
|
@@ -238,12 +239,7 @@ var ChatContainerMessagesList = function ChatContainerMessagesList(props) {
|
|
|
238
239
|
|
|
239
240
|
e.preventDefault();
|
|
240
241
|
(_loadMoreRef$current3 = loadMoreRef.current) === null || _loadMoreRef$current3 === void 0 ? void 0 : _loadMoreRef$current3.focus();
|
|
241
|
-
} else if (hasMoreItems === 'top' && e.shiftKey) {
|
|
242
|
-
var _loadMoreRef$current4;
|
|
243
|
-
|
|
244
|
-
e.preventDefault();
|
|
245
|
-
(_loadMoreRef$current4 = loadMoreRef.current) === null || _loadMoreRef$current4 === void 0 ? void 0 : _loadMoreRef$current4.focus();
|
|
246
|
-
} else if (!e.shiftKey) {
|
|
242
|
+
} else if (hasMoreItems === 'top' && e.shiftKey) ; else if (!e.shiftKey) {
|
|
247
243
|
e.preventDefault();
|
|
248
244
|
actionRef.current.focusToComposer();
|
|
249
245
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatContainerMessagesList.js","sources":["../../../../src/parts/chat-container-messages-list/ChatContainerMessagesList.tsx"],"sourcesContent":["/* eslint-disable complexity */\n/* eslint-disable jsx-a11y/no-noninteractive-tabindex */\n/* eslint-disable max-lines */\nimport React, { CSSProperties } from 'react';\nimport { describe } from 'react-desc';\nimport { useVirtual } from 'react-virtual';\nimport DSButton from '@elliemae/ds-button';\nimport { debounce } from 'lodash';\nimport { ChatBubble, BUBBLE_TYPES } from '../bubble';\nimport { MessageDelimiter } from '../message-delimiter';\nimport { SystemMessage } from '../system-message';\nimport {\n StyledWrapperListItem,\n StyledChatContainerContentList,\n StyledChatContainerContentListScroll,\n StyledWrapper,\n StyledLoadMoreContainer,\n ListItem,\n} from './styled';\nimport { defaultProps, listProps, ChatContainerMessagesListProps } from './props';\nimport { useValidateProps } from './config/useValidateProps';\n\nconst getPadding = (hasMoreItems) => {\n const padding = {\n paddingStart: 0,\n paddingEnd: -5,\n };\n if (hasMoreItems === 'top') padding.paddingStart = 42;\n else if (hasMoreItems === 'bottom') padding.paddingEnd = 42;\n return padding;\n};\n\nconst ChatContainerMessagesList = (props: ChatContainerMessagesListProps): JSX.Element => {\n useValidateProps(props, ChatContainerMessagesListWithSchema.toTypescript());\n\n const {\n sendingText,\n bannerPosition,\n sendingMessages,\n messages,\n actionRef,\n onScrollEnds,\n getMoreMessages,\n hasMoreItems,\n isLoading,\n bannerRef,\n } = props;\n const pendingOnScroll = React.useRef(false);\n const loadMoreRef = React.useRef(null);\n const virtualListRef = React.useRef<HTMLDivElement>();\n // estimateSize should not be really required given what was stated on\n // https://github.com/tannerlinsley/react-virtual/issues/23\n const {\n scrollToIndex: vScroll,\n totalSize,\n virtualItems,\n } = useVirtual({\n size: messages.length,\n parentRef: virtualListRef,\n overscan: 15,\n ...getPadding(hasMoreItems),\n estimateSize: React.useCallback(() => 80, []),\n });\n\n const debouncedScroll = React.useMemo(\n () =>\n debounce((): number[] => {\n if (document.visibilityState === 'hidden') {\n pendingOnScroll.current = true;\n return [];\n }\n pendingOnScroll.current = false;\n const { bottom, top } = virtualListRef.current?.getBoundingClientRect();\n const list = virtualListRef.current.querySelectorAll(\n '[data-element=\"chat-element-list-item\"]',\n ) as NodeListOf<HTMLDivElement>;\n const indexList = [];\n list.forEach((item: HTMLDivElement) => {\n const { top: itemTop } = item.getBoundingClientRect();\n const itemPadding = 10;\n if (itemTop + itemPadding < bottom && itemTop + itemPadding > top) indexList.push(item.dataset.index);\n });\n if (onScrollEnds) onScrollEnds(indexList);\n return indexList;\n }, 500),\n [onScrollEnds],\n );\n\n const onScrollStop = React.useCallback(debouncedScroll, [debouncedScroll]);\n\n const onlyFocus = React.useCallback((index: number) => {\n setTimeout(() => {\n (virtualListRef.current.querySelector(`[data-index=\"${index}\"]`) as HTMLDivElement).focus();\n }, 300);\n }, []);\n\n const scrollAndFocus = React.useCallback(\n (index: number, b = { align: 'center' }) => {\n vScroll(index, b);\n onlyFocus(index);\n onScrollStop();\n },\n [onScrollStop, onlyFocus, vScroll],\n );\n\n React.useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.scrollToIndex = (a, b = { align: 'center' }) => {\n vScroll(a, b as any);\n onScrollStop();\n };\n actionRef.current.getMessagesInView = onScrollStop;\n actionRef.current.focusToIndex = (a, b = { align: 'center' } as ScrollToOptions) => {\n scrollAndFocus(a, b);\n };\n actionRef.current.focusToIndexWithoutScroll = onlyFocus;\n actionRef.current.focusToList = () => {\n virtualListRef.current?.focus();\n };\n }\n }, [actionRef, onScrollStop, onlyFocus, scrollAndFocus, vScroll]);\n\n const handleKey = React.useCallback(\n (e) => {\n const { key } = e;\n const index = Number(e.currentTarget.dataset.index);\n e.stopPropagation();\n switch (key) {\n case 'ArrowUp':\n e.preventDefault();\n if (index > 0)\n (virtualListRef.current.querySelector(`[data-index=\"${index - 1}\"]`) as HTMLDivElement).focus();\n break;\n case 'ArrowDown':\n e.preventDefault();\n if (index < messages.length - 1) {\n (virtualListRef.current.querySelector(`[data-index=\"${index + 1}\"]`) as HTMLDivElement).focus();\n }\n break;\n case 'Home':\n e.preventDefault();\n scrollAndFocus(0);\n break;\n case 'End':\n e.preventDefault();\n scrollAndFocus(messages.length - 1);\n break;\n case 'Tab':\n e.preventDefault();\n if (hasMoreItems === 'bottom' && !e.shiftKey) {\n loadMoreRef.current?.focus();\n } else if (hasMoreItems === 'top' && e.shiftKey) {\n loadMoreRef.current?.focus();\n } else if (!e.shiftKey) {\n if (bannerPosition) {\n bannerRef.current.focusOnWrapper();\n } else {\n actionRef.current.focusToComposer();\n }\n } else {\n virtualListRef.current?.focus();\n }\n break;\n default:\n break;\n }\n },\n [actionRef, hasMoreItems, messages.length, bannerPosition, scrollAndFocus],\n );\n const handleListKey = React.useCallback(\n (e) => {\n const { key } = e;\n switch (key) {\n case 'ArrowUp':\n e.preventDefault();\n onlyFocus(onScrollStop().shift());\n break;\n case 'ArrowDown':\n e.preventDefault();\n onlyFocus(onScrollStop().pop());\n break;\n case 'Home':\n e.preventDefault();\n scrollAndFocus(0);\n break;\n case 'End':\n e.preventDefault();\n scrollAndFocus(messages.length - 1);\n break;\n case 'Tab':\n if (document.activeElement !== loadMoreRef.current) {\n if (hasMoreItems === 'bottom' && !e.shiftKey) {\n e.preventDefault();\n loadMoreRef.current?.focus();\n } else if (hasMoreItems === 'top' && e.shiftKey) {\n e.preventDefault();\n loadMoreRef.current?.focus();\n } else if (!e.shiftKey) {\n e.preventDefault();\n actionRef.current.focusToComposer();\n }\n } else if (!e.shiftKey) {\n e.preventDefault();\n actionRef.current.focusToComposer();\n } else {\n e.preventDefault();\n virtualListRef.current?.focus();\n }\n break;\n default:\n break;\n }\n },\n [actionRef, hasMoreItems, messages.length, onScrollStop, onlyFocus, scrollAndFocus],\n );\n\n const checkPendingOnScroll = React.useCallback(() => {\n if (pendingOnScroll.current === true) onScrollStop();\n }, [onScrollStop]);\n\n React.useEffect(() => {\n let handlerCallback = null;\n const localVirtualRef = virtualListRef.current;\n const onScroll = () => {\n if (handlerCallback) clearTimeout(handlerCallback);\n handlerCallback = setTimeout(onScrollStop, 300);\n };\n if (onScrollEnds) {\n virtualListRef.current.addEventListener('scroll', onScroll);\n }\n document.addEventListener('visibilitychange', checkPendingOnScroll);\n return () => {\n if (handlerCallback) clearTimeout(handlerCallback);\n if (onScrollEnds) localVirtualRef.removeEventListener('scroll', onScroll);\n document.removeEventListener('visibilitychange', checkPendingOnScroll);\n };\n }, [onScrollStop, onScrollEnds, checkPendingOnScroll]);\n\n const render = React.useMemo(\n () =>\n virtualItems.map((virtualItem) => {\n const { index, measureRef, start } = virtualItem;\n const row = messages[index];\n const isSending = sendingMessages && sendingMessages.find((m) => m === row.dsId);\n const style: CSSProperties = {\n position: 'absolute',\n top: 0,\n left: 0,\n transform: `translateY(${start}px)`,\n width: '100%',\n };\n\n return (\n <ListItem\n data-element=\"chat-element-list-item\"\n data-index={index}\n key={`ds-chat-bubble-${index}-${row.dsId}-${row.type}`}\n style={style}\n ref={measureRef}\n tabIndex={0}\n onKeyDown={handleKey}\n role=\"listitem\"\n >\n <StyledWrapperListItem type={row.type}>\n {row.type === BUBBLE_TYPES.SENDER || row.type === BUBBLE_TYPES.RECIPIENT ? (\n // eslint-disable-next-line\n <ChatBubble {...(row as any)} helpMessage={isSending ? sendingText : row.helpMessage} />\n ) : null}\n {row.type === BUBBLE_TYPES.DELIMITER ? <MessageDelimiter {...(row as any)} /> : null}\n {row.type === BUBBLE_TYPES.SYSTEM ? <SystemMessage {...(row as any)} /> : null}\n </StyledWrapperListItem>\n </ListItem>\n );\n }),\n [virtualItems, messages, sendingMessages, handleKey, sendingText],\n );\n\n return (\n <StyledWrapper>\n <StyledChatContainerContentList\n data-testid=\"chat-thread-container\"\n tabIndex={0}\n aria-live=\"polite\"\n ref={virtualListRef}\n role=\"list\"\n onKeyDown={handleListKey}\n >\n <StyledChatContainerContentListScroll height={`${totalSize}px`}>\n {render}\n {!isLoading && hasMoreItems ? (\n <StyledLoadMoreContainer hasMoreItems={hasMoreItems}>\n <DSButton\n labelText=\"Load More\"\n buttonType=\"secondary\"\n onClick={getMoreMessages}\n data-testid=\"ds-chat-load-more-btn\"\n innerRef={loadMoreRef}\n />\n </StyledLoadMoreContainer>\n ) : null}\n </StyledChatContainerContentListScroll>\n </StyledChatContainerContentList>\n </StyledWrapper>\n );\n};\n\nChatContainerMessagesList.propTypes = listProps;\nChatContainerMessagesList.defaultProps = defaultProps;\nconst ChatContainerMessagesListWithSchema = describe(ChatContainerMessagesList);\nChatContainerMessagesListWithSchema.propTypes = listProps;\n\nexport { ChatContainerMessagesList, ChatContainerMessagesListWithSchema };\n"],"names":["getPadding","hasMoreItems","padding","paddingStart","paddingEnd","ChatContainerMessagesList","props","useValidateProps","ChatContainerMessagesListWithSchema","toTypescript","sendingText","bannerPosition","sendingMessages","messages","actionRef","onScrollEnds","getMoreMessages","isLoading","bannerRef","pendingOnScroll","React","useRef","loadMoreRef","virtualListRef","useVirtual","size","length","parentRef","overscan","estimateSize","useCallback","vScroll","scrollToIndex","totalSize","virtualItems","debouncedScroll","useMemo","debounce","document","visibilityState","current","getBoundingClientRect","bottom","top","list","querySelectorAll","indexList","forEach","item","itemTop","itemPadding","push","dataset","index","onScrollStop","onlyFocus","setTimeout","querySelector","focus","scrollAndFocus","b","align","useEffect","a","getMessagesInView","focusToIndex","focusToIndexWithoutScroll","focusToList","handleKey","e","key","Number","currentTarget","stopPropagation","preventDefault","shiftKey","focusOnWrapper","focusToComposer","handleListKey","shift","pop","activeElement","checkPendingOnScroll","handlerCallback","localVirtualRef","onScroll","clearTimeout","addEventListener","removeEventListener","render","map","virtualItem","measureRef","start","row","isSending","find","m","dsId","style","position","left","transform","width","ListItem","type","StyledWrapperListItem","BUBBLE_TYPES","SENDER","RECIPIENT","ChatBubble","helpMessage","DELIMITER","MessageDelimiter","SYSTEM","SystemMessage","StyledWrapper","StyledChatContainerContentList","StyledChatContainerContentListScroll","StyledLoadMoreContainer","DSButton","propTypes","listProps","defaultProps","describe"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAMA,UAAU,GAAG,SAAbA,UAAa,CAACC,YAAD,EAAkB;AACnC,MAAMC,OAAO,GAAG;AACdC,IAAAA,YAAY,EAAE,CADA;AAEdC,IAAAA,UAAU,EAAE,CAAC;AAFC,GAAhB;AAIA,MAAIH,YAA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G,oDAAD,qBACEhG,wCAACiG,qEAAD;AACE,mBAAY,uBADd;AAEE,IAAA,QAAQ,EAAE,CAFZ;AAGE,iBAAU,QAHZ;AAIE,IAAA,GAAG,EAAE9F,cAJP;AAKE,IAAA,IAAI,EAAC,MALP;AAME,IAAA,SAAS,EAAEuD;AANb,kBAQE1D,wCAACkG,2EAAD;AAAsC,IAAA,MAAM,YAAKrF,SAAL;AAA5C,KACGwD,MADH,EAEG,CAACxE,SAAD,IAAchB,YAAd,gBACCmB,wCAACmG,8DAAD;AAAyB,IAAA,YAAY,EAAEtH;AAAvC,kBACEmB,wCAACoG,4BAAD;AACE,IAAA,SAAS,EAAC,WADZ;AAEE,IAAA,UAAU,EAAC,WAFb;AAGE,IAAA,OAAO,EAAExG,eAHX;AAIE,mBAAY,uBAJd;AAKE,IAAA,QAAQ,EAAEM;AALZ,IADF,CADD,GAUG,IAZN,CARF,CADF,CADF;AA2BD;;AAEDjB,yBAAyB,CAACoH,SAA1B,GAAsCC,+CAAtC;AACArH,yBAAyB,CAACsH,YAA1B,GAAyCA,kDAAzC;IACMnH,mCAAmC,GAAGoH,kBAAQ,CAACvH,yBAAD;AACpDG,mCAAmC,CAACiH,SAApC,GAAgDC,+CAAhD;;;;;"}
|
|
1
|
+
{"version":3,"file":"ChatContainerMessagesList.js","sources":["../../../../src/parts/chat-container-messages-list/ChatContainerMessagesList.tsx"],"sourcesContent":["/* eslint-disable complexity */\n/* eslint-disable jsx-a11y/no-noninteractive-tabindex */\n/* eslint-disable max-lines */\nimport React, { CSSProperties } from 'react';\nimport { describe } from 'react-desc';\nimport { useVirtual } from 'react-virtual';\nimport DSButton from '@elliemae/ds-button';\nimport { debounce } from 'lodash';\nimport { ChatBubble, BUBBLE_TYPES } from '../bubble';\nimport { MessageDelimiter } from '../message-delimiter';\nimport { SystemMessage } from '../system-message';\nimport {\n StyledWrapperListItem,\n StyledChatContainerContentList,\n StyledChatContainerContentListScroll,\n StyledWrapper,\n StyledLoadMoreContainer,\n ListItem,\n} from './styled';\nimport { defaultProps, listProps, ChatContainerMessagesListProps } from './props';\nimport { useValidateProps } from './config/useValidateProps';\n\nconst getPadding = (hasMoreItems) => {\n const padding = {\n paddingStart: 0,\n paddingEnd: -5,\n };\n if (hasMoreItems === 'top') padding.paddingStart = 42;\n else if (hasMoreItems === 'bottom') padding.paddingEnd = 42;\n return padding;\n};\n\nconst ChatContainerMessagesList = (props: ChatContainerMessagesListProps): JSX.Element => {\n useValidateProps(props, ChatContainerMessagesListWithSchema.toTypescript());\n\n const {\n sendingText,\n bannerPosition,\n sendingMessages,\n messages,\n actionRef,\n onScrollEnds,\n getMoreMessages,\n hasMoreItems,\n isLoading,\n bannerRef,\n } = props;\n const pendingOnScroll = React.useRef(false);\n const loadMoreRef = React.useRef(null);\n const virtualListRef = React.useRef<HTMLDivElement>();\n // estimateSize should not be really required given what was stated on\n // https://github.com/tannerlinsley/react-virtual/issues/23\n const {\n scrollToIndex: vScroll,\n totalSize,\n virtualItems,\n } = useVirtual({\n size: messages.length,\n parentRef: virtualListRef,\n overscan: 15,\n ...getPadding(hasMoreItems),\n estimateSize: React.useCallback(() => 80, []),\n });\n\n const debouncedScroll = React.useMemo(\n () =>\n debounce((): number[] => {\n if (document.visibilityState === 'hidden') {\n pendingOnScroll.current = true;\n return [];\n }\n if (!virtualListRef.current) return [];\n pendingOnScroll.current = false;\n const { bottom, top } = virtualListRef.current?.getBoundingClientRect();\n const list = virtualListRef.current.querySelectorAll(\n '[data-element=\"chat-element-list-item\"]',\n ) as NodeListOf<HTMLDivElement>;\n const indexList = [];\n list.forEach((item: HTMLDivElement) => {\n const { top: itemTop } = item.getBoundingClientRect();\n const itemPadding = 10;\n if (itemTop + itemPadding < bottom && itemTop + itemPadding > top) indexList.push(item.dataset.index);\n });\n if (onScrollEnds) onScrollEnds(indexList);\n return indexList;\n }, 500),\n [onScrollEnds],\n );\n\n const onScrollStop = React.useCallback(debouncedScroll, [debouncedScroll]);\n\n const onlyFocus = React.useCallback((index: number) => {\n setTimeout(() => {\n (virtualListRef.current.querySelector(`[data-index=\"${index}\"]`) as HTMLDivElement).focus();\n }, 300);\n }, []);\n\n const scrollAndFocus = React.useCallback(\n (index: number, b = { align: 'center' }) => {\n vScroll(index, b);\n onlyFocus(index);\n onScrollStop();\n },\n [onScrollStop, onlyFocus, vScroll],\n );\n\n React.useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.scrollToIndex = (a, b = { align: 'center' }) => {\n vScroll(a, b as any);\n onScrollStop();\n };\n actionRef.current.getMessagesInView = onScrollStop;\n actionRef.current.focusToIndex = (a, b = { align: 'center' } as ScrollToOptions) => {\n scrollAndFocus(a, b);\n };\n actionRef.current.focusToIndexWithoutScroll = onlyFocus;\n actionRef.current.focusToList = () => {\n virtualListRef.current?.focus();\n };\n }\n }, [actionRef, onScrollStop, onlyFocus, scrollAndFocus, vScroll]);\n\n const handleKey = React.useCallback(\n (e) => {\n const { key } = e;\n const index = Number(e.currentTarget.dataset.index);\n e.stopPropagation();\n switch (key) {\n case 'ArrowUp':\n e.preventDefault();\n if (index > 0)\n (virtualListRef.current.querySelector(`[data-index=\"${index - 1}\"]`) as HTMLDivElement).focus();\n break;\n case 'ArrowDown':\n e.preventDefault();\n if (index < messages.length - 1) {\n (virtualListRef.current.querySelector(`[data-index=\"${index + 1}\"]`) as HTMLDivElement).focus();\n }\n break;\n case 'Home':\n e.preventDefault();\n scrollAndFocus(0);\n break;\n case 'End':\n e.preventDefault();\n scrollAndFocus(messages.length - 1);\n break;\n case 'Tab':\n e.preventDefault();\n if (hasMoreItems === 'bottom' && !e.shiftKey) {\n loadMoreRef.current?.focus();\n } else if (hasMoreItems === 'top' && e.shiftKey) {\n loadMoreRef.current?.focus();\n } else if (!e.shiftKey) {\n if (bannerPosition) {\n bannerRef.current.focusOnWrapper();\n } else {\n actionRef.current.focusToComposer();\n }\n } else {\n virtualListRef.current?.focus();\n }\n break;\n default:\n break;\n }\n },\n [actionRef, bannerRef, hasMoreItems, messages.length, bannerPosition, scrollAndFocus],\n );\n const handleListKey = React.useCallback(\n (e) => {\n const { key } = e;\n switch (key) {\n case 'ArrowUp':\n e.preventDefault();\n onlyFocus(onScrollStop().shift());\n break;\n case 'ArrowDown':\n e.preventDefault();\n onlyFocus(onScrollStop().pop());\n break;\n case 'Home':\n e.preventDefault();\n scrollAndFocus(0);\n break;\n case 'End':\n e.preventDefault();\n scrollAndFocus(messages.length - 1);\n break;\n case 'Tab':\n if (document.activeElement !== loadMoreRef.current) {\n if (hasMoreItems === 'bottom' && !e.shiftKey) {\n e.preventDefault();\n loadMoreRef.current?.focus();\n } else if (hasMoreItems === 'top' && e.shiftKey) {\n // e.preventDefault();\n // loadMoreRef.current?.focus();\n } else if (!e.shiftKey) {\n e.preventDefault();\n actionRef.current.focusToComposer();\n }\n } else if (!e.shiftKey) {\n e.preventDefault();\n actionRef.current.focusToComposer();\n } else {\n e.preventDefault();\n virtualListRef.current?.focus();\n }\n break;\n default:\n break;\n }\n },\n [actionRef, hasMoreItems, messages.length, onScrollStop, onlyFocus, scrollAndFocus],\n );\n\n const checkPendingOnScroll = React.useCallback(() => {\n if (pendingOnScroll.current === true) onScrollStop();\n }, [onScrollStop]);\n\n React.useEffect(() => {\n let handlerCallback = null;\n const localVirtualRef = virtualListRef.current;\n const onScroll = () => {\n if (handlerCallback) clearTimeout(handlerCallback);\n handlerCallback = setTimeout(onScrollStop, 300);\n };\n if (onScrollEnds) {\n virtualListRef.current.addEventListener('scroll', onScroll);\n }\n document.addEventListener('visibilitychange', checkPendingOnScroll);\n return () => {\n if (handlerCallback) clearTimeout(handlerCallback);\n if (onScrollEnds) localVirtualRef.removeEventListener('scroll', onScroll);\n document.removeEventListener('visibilitychange', checkPendingOnScroll);\n };\n }, [onScrollStop, onScrollEnds, checkPendingOnScroll]);\n\n const render = React.useMemo(\n () =>\n virtualItems.map((virtualItem) => {\n const { index, measureRef, start } = virtualItem;\n const row = messages[index];\n const isSending = sendingMessages && sendingMessages.find((m) => m === row.dsId);\n const style: CSSProperties = {\n position: 'absolute',\n top: 0,\n left: 0,\n transform: `translateY(${start}px)`,\n width: '100%',\n };\n\n return (\n <ListItem\n data-element=\"chat-element-list-item\"\n data-index={index}\n key={`ds-chat-bubble-${index}-${row.dsId}-${row.type}`}\n style={style}\n ref={measureRef}\n tabIndex={0}\n onKeyDown={handleKey}\n role=\"listitem\"\n >\n <StyledWrapperListItem type={row.type}>\n {row.type === BUBBLE_TYPES.SENDER || row.type === BUBBLE_TYPES.RECIPIENT ? (\n // eslint-disable-next-line\n <ChatBubble {...(row as any)} helpMessage={isSending ? sendingText : row.helpMessage} />\n ) : null}\n {row.type === BUBBLE_TYPES.DELIMITER ? <MessageDelimiter {...(row as any)} /> : null}\n {row.type === BUBBLE_TYPES.SYSTEM ? <SystemMessage {...(row as any)} /> : null}\n </StyledWrapperListItem>\n </ListItem>\n );\n }),\n [virtualItems, messages, sendingMessages, handleKey, sendingText],\n );\n\n return (\n <StyledWrapper>\n <StyledChatContainerContentList\n data-testid=\"chat-thread-container\"\n tabIndex={0}\n aria-live=\"polite\"\n ref={virtualListRef}\n role=\"list\"\n onKeyDown={handleListKey}\n >\n <StyledChatContainerContentListScroll height={`${totalSize}px`}>\n {render}\n {!isLoading && hasMoreItems ? (\n <StyledLoadMoreContainer hasMoreItems={hasMoreItems}>\n <DSButton\n labelText=\"Load More\"\n buttonType=\"secondary\"\n onClick={getMoreMessages}\n data-testid=\"ds-chat-load-more-btn\"\n innerRef={loadMoreRef}\n />\n </StyledLoadMoreContainer>\n ) : null}\n </StyledChatContainerContentListScroll>\n </StyledChatContainerContentList>\n </StyledWrapper>\n );\n};\n\nChatContainerMessagesList.propTypes = listProps;\nChatContainerMessagesList.defaultProps = defaultProps;\nconst ChatContainerMessagesListWithSchema = describe(ChatContainerMessagesList);\nChatContainerMessagesListWithSchema.propTypes = listProps;\n\nexport { ChatContainerMessagesList, ChatContainerMessagesListWithSchema };\n"],"names":["getPadding","hasMoreItems","padding","paddingStart","paddingEnd","ChatContainerMessagesList","props","useValidateProps","ChatContainerMessagesListWithSchema","toTypescript","sendingText","bannerPosition","sendingMessages","messages","actionRef","onScrollEnds","getMoreMessages","isLoading","bannerRef","pendingOnScroll","React","useRef","loadMoreRef","virtualListRef","useVirtual","size","length","parentRef","overscan","estimateSize","useCallback","vScroll","scrollToIndex","totalSize","virtualItems","debouncedScroll","useMemo","debounce","document","visibilityState","current","getBoundingClientRect","bottom","top","list","querySelectorAll","indexList","forEach","item","itemTop","itemPadding","push","dataset","index","onScrollStop","onlyFocus","setTimeout","querySelector","focus","scrollAndFocus","b","align","useEffect","a","getMessagesInView","focusToIndex","focusToIndexWithoutScroll","focusToList","handleKey","e","key","Number","currentTarget","stopPropagation","preventDefault","shiftKey","focusOnWrapper","focusToComposer","handleListKey","shift","pop","activeElement","checkPendingOnScroll","handlerCallback","localVirtualRef","onScroll","clearTimeout","addEventListener","removeEventListener","render","map","virtualItem","measureRef","start","row","isSending","find","m","dsId","style","position","left","transform","width","ListItem","type","StyledWrapperListItem","BUBBLE_TYPES","SENDER","RECIPIENT","ChatBubble","helpMessage","DELIMITER","MessageDelimiter","SYSTEM","SystemMessage","StyledWrapper","StyledChatContainerContentList","StyledChatContainerContentListScroll","StyledLoadMoreContainer","DSButton","propTypes","listProps","defaultProps","describe"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAMA,UAAU,GAAG,SAAbA,UAAa,CAACC,YAAD,EAAkB;AACnC,MAAMC,OAAO,GAAG;AACdC,IAAAA,YAAY,EAAE,CADA;AAEdC,IAAAA,UAAU,EAAE,CAAC;AAFC,GAAhB;AAIA,MAAIH,YAAY,KAAK,KAArB,EAA4BC,OAAO,CAACC,YAAR,GAAuB,EAAvB,CAA5B,KACK,IAAIF,YAAY,KAAK,QAArB,EAA+BC,OAAO,CAACE,UAAR,GAAqB,EAArB;AACpC,SAAOF,OAAP;AACD,CARD;;IAUMG,yBAAyB,GAAG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1D,wCAACkG,2EAAD;AAAsC,IAAA,MAAM,YAAKrF,SAAL;AAA5C,KACGwD,MADH,EAEG,CAACxE,SAAD,IAAchB,YAAd,gBACCmB,wCAACmG,8DAAD;AAAyB,IAAA,YAAY,EAAEtH;AAAvC,kBACEmB,wCAACoG,4BAAD;AACE,IAAA,SAAS,EAAC,WADZ;AAEE,IAAA,UAAU,EAAC,WAFb;AAGE,IAAA,OAAO,EAAExG,eAHX;AAIE,mBAAY,uBAJd;AAKE,IAAA,QAAQ,EAAEM;AALZ,IADF,CADD,GAUG,IAZN,CARF,CADF,CADF;AA2BD;;AAEDjB,yBAAyB,CAACoH,SAA1B,GAAsCC,+CAAtC;AACArH,yBAAyB,CAACsH,YAA1B,GAAyCA,kDAAzC;IACMnH,mCAAmC,GAAGoH,kBAAQ,CAACvH,yBAAD;AACpDG,mCAAmC,CAACiH,SAApC,GAAgDC,+CAAhD;;;;;"}
|
package/cjs/tests/utils.js
CHANGED
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var dsChat = require('@elliemae/ds-chat');
|
|
6
6
|
|
|
7
|
-
var getRandomMessages = function getRandomMessages(key) {
|
|
8
|
-
return Array(
|
|
7
|
+
var getRandomMessages = function getRandomMessages(q, key) {
|
|
8
|
+
return Array(q).fill().map(function (v, i) {
|
|
9
9
|
if (i > 5 && i % 22 === 0) {
|
|
10
10
|
return {
|
|
11
11
|
dsId: "".concat(i),
|
|
@@ -41,7 +41,9 @@ var getRandomMessages = function getRandomMessages(key) {
|
|
|
41
41
|
});
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
var
|
|
44
|
+
var loadMsgs = function loadMsgs(q) {
|
|
45
|
+
return getRandomMessages(q, 'item_key');
|
|
46
|
+
};
|
|
45
47
|
|
|
46
|
-
exports.
|
|
48
|
+
exports.loadMsgs = loadMsgs;
|
|
47
49
|
//# sourceMappingURL=utils.js.map
|
package/cjs/tests/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../src/tests/utils.tsx"],"sourcesContent":["import { BUBBLE_TYPES } from '@elliemae/ds-chat';\n\nconst getRandomMessages = (key) =>\n Array(
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/tests/utils.tsx"],"sourcesContent":["import { BUBBLE_TYPES } from '@elliemae/ds-chat';\n\nconst getRandomMessages = (q, key) =>\n Array(q)\n .fill()\n .map((v, i) => {\n if (i > 5 && i % 22 === 0) {\n return {\n dsId: `${i}`,\n body: `This is a system message that notifies the user of some important things`,\n type: BUBBLE_TYPES.SYSTEM,\n title: 'System Message',\n time: '4:50 pm',\n };\n }\n if (i > 5 && i % 16 === 0) {\n return {\n dsId: `${i}`,\n type: BUBBLE_TYPES.DELIMITER,\n title: 'Mon, Apr 25, 12:43 PM',\n extraProps: { 'data-testid': 'custom-data-testid' },\n };\n }\n const isSender = i % 2 === 0;\n const chatBubbleType = isSender ? BUBBLE_TYPES.SENDER : BUBBLE_TYPES.RECIPIENT;\n const chatTitle = isSender ? 'Robert Deniro' : 'Al Pacino';\n return {\n dsId: `${i}`,\n body: `Message text ${key} Message text ${i}`,\n type: chatBubbleType,\n title: chatTitle,\n time: '4:50 pm',\n helpMessage: isSender ? 'Delivered' : null,\n };\n });\n\nexport const loadMsgs = (q: number): unknown => getRandomMessages(q, 'item_key');\n"],"names":["getRandomMessages","q","key","Array","fill","map","v","i","dsId","body","type","BUBBLE_TYPES","SYSTEM","title","time","DELIMITER","extraProps","isSender","chatBubbleType","SENDER","RECIPIENT","chatTitle","helpMessage","loadMsgs"],"mappings":";;;;;;AAEA,IAAMA,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,CAAD,EAAIC,GAAJ;AAAA,SACxBC,KAAK,CAACF,CAAD,CAAL,CACGG,IADH,GAEGC,GAFH,CAEO,UAACC,CAAD,EAAIC,CAAJ,EAAU;AACb,QAAIA,CAAC,GAAG,CAAJ,IAASA,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MSG_TIME: 'chat-system-message-time',
|
|
18
18
|
BUBBLE: 'ds-chat-bubble',
|
|
19
19
|
BUBBLE_TITLE: 'chat-bubble-title',
|
|
20
|
-
BUBBLE_BODY: 'chat-bubble-body'
|
|
20
|
+
BUBBLE_BODY: 'chat-bubble-body',
|
|
21
|
+
BANNER: 'ds-banner-container'
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
export { ChatDataTestIds };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatDataTestids.js","sources":["../../src/ChatDataTestids.tsx"],"sourcesContent":["export const ChatDataTestIds = {\n COMPOSER_TEXTAREA: 'chat-composer-textarea',\n COMPOSER_SEND_BUTTON: 'chat-composer-send-button',\n CARD_TITLE: 'chat-card-title',\n CARD_WRAPPER: 'chat-card-wrapper',\n CARD_TIME: 'chat-card-time',\n CARD_RIGHT_ADDON: 'chat-right-addon',\n CARD_CONTENT: 'chat-card-content',\n LOADING_INDICATOR: 'ds-chat-loading-indicator',\n HEADER_TITLE: 'chat-header-title',\n HEADER_CHILDREN: 'chat-header-children',\n THREAD_CONTAINER: 'chat-thread-container',\n LOAD_MORE_BUTTON: 'ds-chat-load-more-btn',\n FLOATING_BUTTON: 'chat-floating-button',\n SYSTEM_MSG_TITLE: 'chat-system-message-title',\n SYSTEM_MSG_BODY: 'chat-system-message-body',\n SYSTEM_MSG_TIME: 'chat-system-message-time',\n BUBBLE: 'ds-chat-bubble',\n BUBBLE_TITLE: 'chat-bubble-title',\n BUBBLE_BODY: 'chat-bubble-body',\n};\n"],"names":["ChatDataTestIds","COMPOSER_TEXTAREA","COMPOSER_SEND_BUTTON","CARD_TITLE","CARD_WRAPPER","CARD_TIME","CARD_RIGHT_ADDON","CARD_CONTENT","LOADING_INDICATOR","HEADER_TITLE","HEADER_CHILDREN","THREAD_CONTAINER","LOAD_MORE_BUTTON","FLOATING_BUTTON","SYSTEM_MSG_TITLE","SYSTEM_MSG_BODY","SYSTEM_MSG_TIME","BUBBLE","BUBBLE_TITLE","BUBBLE_BODY"],"mappings":"IAAaA,eAAe,GAAG;AAC7BC,EAAAA,iBAAiB,EAAE,wBADU;AAE7BC,EAAAA,oBAAoB,EAAE,2BAFO;AAG7BC,EAAAA,UAAU,EAAE,iBAHiB;AAI7BC,EAAAA,YAAY,EAAE,mBAJe;AAK7BC,EAAAA,SAAS,EAAE,gBALkB;AAM7BC,EAAAA,gBAAgB,EAAE,kBANW;AAO7BC,EAAAA,YAAY,EAAE,mBAPe;AAQ7BC,EAAAA,iBAAiB,EAAE,2BARU;AAS7BC,EAAAA,YAAY,EAAE,mBATe;AAU7BC,EAAAA,eAAe,EAAE,sBAVY;AAW7BC,EAAAA,gBAAgB,EAAE,uBAXW;AAY7BC,EAAAA,gBAAgB,EAAE,uBAZW;AAa7BC,EAAAA,eAAe,EAAE,sBAbY;AAc7BC,EAAAA,gBAAgB,EAAE,2BAdW;AAe7BC,EAAAA,eAAe,EAAE,0BAfY;AAgB7BC,EAAAA,eAAe,EAAE,0BAhBY;AAiB7BC,EAAAA,MAAM,EAAE,gBAjBqB;AAkB7BC,EAAAA,YAAY,EAAE,mBAlBe;AAmB7BC,EAAAA,WAAW,EAAE;
|
|
1
|
+
{"version":3,"file":"ChatDataTestids.js","sources":["../../src/ChatDataTestids.tsx"],"sourcesContent":["export const ChatDataTestIds = {\n COMPOSER_TEXTAREA: 'chat-composer-textarea',\n COMPOSER_SEND_BUTTON: 'chat-composer-send-button',\n CARD_TITLE: 'chat-card-title',\n CARD_WRAPPER: 'chat-card-wrapper',\n CARD_TIME: 'chat-card-time',\n CARD_RIGHT_ADDON: 'chat-right-addon',\n CARD_CONTENT: 'chat-card-content',\n LOADING_INDICATOR: 'ds-chat-loading-indicator',\n HEADER_TITLE: 'chat-header-title',\n HEADER_CHILDREN: 'chat-header-children',\n THREAD_CONTAINER: 'chat-thread-container',\n LOAD_MORE_BUTTON: 'ds-chat-load-more-btn',\n FLOATING_BUTTON: 'chat-floating-button',\n SYSTEM_MSG_TITLE: 'chat-system-message-title',\n SYSTEM_MSG_BODY: 'chat-system-message-body',\n SYSTEM_MSG_TIME: 'chat-system-message-time',\n BUBBLE: 'ds-chat-bubble',\n BUBBLE_TITLE: 'chat-bubble-title',\n BUBBLE_BODY: 'chat-bubble-body',\n BANNER: 'ds-banner-container',\n};\n"],"names":["ChatDataTestIds","COMPOSER_TEXTAREA","COMPOSER_SEND_BUTTON","CARD_TITLE","CARD_WRAPPER","CARD_TIME","CARD_RIGHT_ADDON","CARD_CONTENT","LOADING_INDICATOR","HEADER_TITLE","HEADER_CHILDREN","THREAD_CONTAINER","LOAD_MORE_BUTTON","FLOATING_BUTTON","SYSTEM_MSG_TITLE","SYSTEM_MSG_BODY","SYSTEM_MSG_TIME","BUBBLE","BUBBLE_TITLE","BUBBLE_BODY","BANNER"],"mappings":"IAAaA,eAAe,GAAG;AAC7BC,EAAAA,iBAAiB,EAAE,wBADU;AAE7BC,EAAAA,oBAAoB,EAAE,2BAFO;AAG7BC,EAAAA,UAAU,EAAE,iBAHiB;AAI7BC,EAAAA,YAAY,EAAE,mBAJe;AAK7BC,EAAAA,SAAS,EAAE,gBALkB;AAM7BC,EAAAA,gBAAgB,EAAE,kBANW;AAO7BC,EAAAA,YAAY,EAAE,mBAPe;AAQ7BC,EAAAA,iBAAiB,EAAE,2BARU;AAS7BC,EAAAA,YAAY,EAAE,mBATe;AAU7BC,EAAAA,eAAe,EAAE,sBAVY;AAW7BC,EAAAA,gBAAgB,EAAE,uBAXW;AAY7BC,EAAAA,gBAAgB,EAAE,uBAZW;AAa7BC,EAAAA,eAAe,EAAE,sBAbY;AAc7BC,EAAAA,gBAAgB,EAAE,2BAdW;AAe7BC,EAAAA,eAAe,EAAE,0BAfY;AAgB7BC,EAAAA,eAAe,EAAE,0BAhBY;AAiB7BC,EAAAA,MAAM,EAAE,gBAjBqB;AAkB7BC,EAAAA,YAAY,EAAE,mBAlBe;AAmB7BC,EAAAA,WAAW,EAAE,kBAnBgB;AAoB7BC,EAAAA,MAAM,EAAE;AApBqB;;;;"}
|
|
@@ -15,7 +15,7 @@ var ChatBubbleArrow = function ChatBubbleArrow(_ref) {
|
|
|
15
15
|
viewBox: "0 0 15 14"
|
|
16
16
|
}, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("path", {
|
|
17
17
|
d: "M12,8.5 C12,7.9373169 11.6782751,7.4856453 11.2282104,7.196228 C11.2286673,7.1967363 3,2 3,2 L3,10 L10.5627441,10 L10.5658569,9.9933472 C11.3630371,9.9580688 12,9.3058472 12,8.5 Z",
|
|
18
|
-
id: "path-
|
|
18
|
+
id: "path-chat-bubble"
|
|
19
19
|
}), /*#__PURE__*/React.createElement("filter", {
|
|
20
20
|
x: "-55.6%",
|
|
21
21
|
y: "-50.0%",
|
|
@@ -49,11 +49,11 @@ var ChatBubbleArrow = function ChatBubbleArrow(_ref) {
|
|
|
49
49
|
fill: "black",
|
|
50
50
|
fillOpacity: "1",
|
|
51
51
|
filter: "url(#filter-2)",
|
|
52
|
-
xlinkHref: "#path-
|
|
52
|
+
xlinkHref: "#path-chat-bubble"
|
|
53
53
|
}), /*#__PURE__*/React.createElement("use", {
|
|
54
54
|
fill: "#FFFFFF",
|
|
55
55
|
fillRule: "evenodd",
|
|
56
|
-
xlinkHref: "#path-
|
|
56
|
+
xlinkHref: "#path-chat-bubble"
|
|
57
57
|
})))) : /*#__PURE__*/React.createElement("svg", {
|
|
58
58
|
width: "9px",
|
|
59
59
|
height: "8px",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBubbleArrow.js","sources":["../../../../src/parts/bubble/ChatBubbleArrow.tsx"],"sourcesContent":["import React from 'react';\nimport { StyledBubbleArrow } from './styled';\nimport { BUBBLE_TYPES, BubbleProps, propsArrowBubble } from './props';\n\nexport const ChatBubbleArrow = ({ type }: Pick<BubbleProps, 'type'>): JSX.Element => (\n <StyledBubbleArrow>\n {type === BUBBLE_TYPES.RECIPIENT ? (\n <svg width=\"15px\" height=\"14px\" viewBox=\"0 0 15 14\">\n <defs>\n <path\n d=\"M12,8.5 C12,7.9373169 11.6782751,7.4856453 11.2282104,7.196228 C11.2286673,7.1967363 3,2 3,2 L3,10 L10.5627441,10 L10.5658569,9.9933472 C11.3630371,9.9580688 12,9.3058472 12,8.5 Z\"\n id=\"path-
|
|
1
|
+
{"version":3,"file":"ChatBubbleArrow.js","sources":["../../../../src/parts/bubble/ChatBubbleArrow.tsx"],"sourcesContent":["import React from 'react';\nimport { StyledBubbleArrow } from './styled';\nimport { BUBBLE_TYPES, BubbleProps, propsArrowBubble } from './props';\n\nexport const ChatBubbleArrow = ({ type }: Pick<BubbleProps, 'type'>): JSX.Element => (\n <StyledBubbleArrow>\n {type === BUBBLE_TYPES.RECIPIENT ? (\n <svg width=\"15px\" height=\"14px\" viewBox=\"0 0 15 14\">\n <defs>\n <path\n d=\"M12,8.5 C12,7.9373169 11.6782751,7.4856453 11.2282104,7.196228 C11.2286673,7.1967363 3,2 3,2 L3,10 L10.5627441,10 L10.5658569,9.9933472 C11.3630371,9.9580688 12,9.3058472 12,8.5 Z\"\n id=\"path-chat-bubble\"\n ></path>\n <filter x=\"-55.6%\" y=\"-50.0%\" width=\"211.1%\" height=\"225.0%\" filterUnits=\"objectBoundingBox\" id=\"filter-2\">\n <feOffset dx=\"2.3\" dy=\"1.2\" in=\"SourceAlpha\" result=\"shadowOffsetOuter1\"></feOffset>\n <feGaussianBlur stdDeviation=\"1.5\" in=\"shadowOffsetOuter1\" result=\"shadowBlurOuter1\"></feGaussianBlur>\n <feColorMatrix\n values=\"0 0 0 0 0.207843137 \n 0 0 0 0 0.235294118 \n 0 0 0 0 0.274509804 \n 0 0 0 0.8 0\"\n type=\"matrix\"\n in=\"shadowBlurOuter1\"\n ></feColorMatrix>\n </filter>\n </defs>\n <g id=\"[DSK]-Visual-Design\" stroke=\"none\" strokeWidth=\"1\" fill=\"none\" fillRule=\"evenodd\">\n <g id=\"Path-Copy\" transform=\"translate(7.500000, 6.000000) scale(-1, 1) translate(-7.500000, -6.000000) \">\n <use fill=\"black\" fillOpacity=\"1\" filter=\"url(#filter-2)\" xlinkHref=\"#path-chat-bubble\"></use>\n <use fill=\"#FFFFFF\" fillRule=\"evenodd\" xlinkHref=\"#path-chat-bubble\"></use>\n </g>\n </g>\n </svg>\n ) : (\n <svg width=\"9px\" height=\"8px\" viewBox=\"0 0 9 8\">\n <g stroke=\"none\" strokeWidth=\"1\" fill=\"none\" fillRule=\"evenodd\">\n <path\n d=\"M9,6.5 C9,5.9373169 8.6782751,5.4856453 8.2282104,5.196228 C8.2286673,5.1967363 0,0 0,0 L0,8 L7.5627441,8 L7.5658569,7.9933472 C8.3630371,7.9580688 9,7.3058472 9,6.5 Z\"\n id=\"Path\"\n fill=\"#1E79C2\"\n ></path>\n </g>\n </svg>\n )}\n </StyledBubbleArrow>\n);\n\nChatBubbleArrow.propTypes = propsArrowBubble;\n"],"names":["ChatBubbleArrow","type","BUBBLE_TYPES","RECIPIENT","propTypes","propsArrowBubble"],"mappings":";;;;;;;;;IAIaA,eAAe,GAAG,SAAlBA,eAAkB;AAAA,MAAGC,IAAH,QAAGA,IAAH;AAAA,sBAC7B,oBAAC,iBAAD,QACGA,IAAI,KAAKC,YAAY,CAACC,SAAtB,gBACC;AAAK,IAAA,KAAK,EAAC,MAAX;AAAkB,IAAA,MAAM,EAAC,MAAzB;AAAgC,IAAA,OAAO,EAAC;AAAxC,kBACE,+CACE;AACE,IAAA,CAAC,EAAC,qLADJ;AAEE,IAAA,EAAE,EAAC;AAFL,IADF,eAKE;AAAQ,IAAA,CAAC,EAAC,QAAV;AAAmB,IAAA,CAAC,EAAC,QAArB;AAA8B,IAAA,KAAK,EAAC,QAApC;AAA6C,IAAA,MAAM,EAAC,QAApD;AAA6D,IAAA,WAAW,EAAC,mBAAzE;AAA6F,IAAA,EAAE,EAAC;AAAhG,kBACE;AAAU,IAAA,EAAE,EAAC,KAAb;AAAmB,IAAA,EAAE,EAAC,KAAtB;A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ChatContainer = function ChatContainer(props) {
|
|
|
56
56
|
device = props.device,
|
|
57
57
|
isLoading = props.isLoading,
|
|
58
58
|
hasMoreItems = props.hasMoreItems,
|
|
59
|
-
getMoreMessages = props.getMoreMessages
|
|
59
|
+
getMoreMessages = props.getMoreMessages,
|
|
60
|
+
ariaLabel = props.ariaLabel;
|
|
60
61
|
var bannerRef = React.useRef({
|
|
61
62
|
focusOnWrapper: noop,
|
|
62
63
|
focusOnLink: noop
|
|
@@ -102,7 +103,7 @@ var ChatContainer = function ChatContainer(props) {
|
|
|
102
103
|
rows: ['minmax(0, 1fr)', 'auto'],
|
|
103
104
|
ref: containerRef,
|
|
104
105
|
role: "region",
|
|
105
|
-
"aria-label":
|
|
106
|
+
"aria-label": ariaLabel
|
|
106
107
|
}, /*#__PURE__*/React.createElement("div", {
|
|
107
108
|
style: {
|
|
108
109
|
position: 'relative',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatContainer.js","sources":["../../../../src/parts/chat-container/ChatContainer.tsx"],"sourcesContent":["/* eslint-disable max-lines */\n/* eslint-disable complexity */\nimport React from 'react';\nimport { noop } from 'lodash';\nimport { describe } from 'react-desc';\nimport DSIndeterminateProgressIndicator from '@elliemae/ds-indeterminate-progress-indicator';\nimport DSBanner, { BANNER_TYPES } from '@elliemae/ds-banner';\nimport { ChatComposer } from '../chat-composer';\nimport { ChatContainerMessagesList } from '../chat-container-messages-list';\nimport { ChatContainerProps, defaultProps, containerProps } from './props';\nimport { StyledChatContainerContent, StyledIndicatorContainer, MobileStyledChatContainerContent } from './styled';\nimport { useValidateProps } from './config/useValidateProps';\n\nconst ChatContainer = (props: ChatContainerProps): JSX.Element => {\n useValidateProps(props, ChatContainerWithSchema.toTypescript());\n\n const {\n sendingText,\n sendingMessages,\n bannerPosition,\n bannerProps,\n messagesListProps,\n composerProps,\n composerProps: { onResize: onComposerResize, onKeyDown: onComposerKeyDown },\n actionRef,\n autoScroll,\n device,\n isLoading,\n hasMoreItems,\n getMoreMessages,\n } = props;\n const bannerRef = React.useRef({ focusOnWrapper: noop, focusOnLink: noop });\n const containerRef = React.useRef<HTMLElement>();\n const listRef = React.useRef({ scrollToIndex: noop });\n const onResize = React.useCallback(\n (height: number) => {\n if (onComposerResize) onComposerResize(height);\n if (autoScroll) {\n listRef.current.scrollToIndex(messagesListProps.messages.length - 1, {\n align: 'end',\n });\n }\n },\n [onComposerResize, messagesListProps.messages, autoScroll],\n );\n const Container = device === 'desktop' ? StyledChatContainerContent : MobileStyledChatContainerContent;\n const handleTabs = React.useCallback(\n (e) => {\n if (onComposerKeyDown) onComposerKeyDown(e);\n else {\n const ref = actionRef || listRef;\n if (e.shiftKey && e.key === 'Tab') {\n e.preventDefault();\n if (['top', 'bottom'].includes(bannerPosition)) {\n bannerRef.current.focusOnWrapper();\n } else {\n const last = ref.current.getMessagesInView().pop();\n ref.current.focusToIndexWithoutScroll(last);\n }\n }\n }\n },\n [actionRef, onComposerKeyDown, bannerPosition],\n );\n\n // Map actions\n React.useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.focusOnBanner = bannerRef.current.focusOnWrapper;\n actionRef.current.focusOnBannerLink = bannerRef.current.focusOnLink;\n }\n }, [actionRef]);\n\n return (\n <Container rows={['minmax(0, 1fr)', 'auto']} ref={containerRef} role=\"region\" aria-label=\"chat window\">\n <div style={{ position: 'relative', overflow: 'hidden' }}>\n <ChatContainerMessagesList\n {...messagesListProps}\n actionRef={actionRef || listRef}\n isLoading={isLoading}\n hasMoreItems={hasMoreItems}\n getMoreMessages={getMoreMessages}\n sendingMessages={sendingMessages}\n sendingText={sendingText}\n bannerPosition={bannerPosition}\n bannerRef={bannerRef}\n />\n {['top', 'bottom'].includes(isLoading) ? (\n <StyledIndicatorContainer isLoading={isLoading} data-testid=\"ds-chat-loading-indicator\">\n <DSIndeterminateProgressIndicator processing title=\"Loading\" />\n </StyledIndicatorContainer>\n ) : null}\n <StyledIndicatorContainer linear isLoading={bannerPosition}>\n <DSBanner\n showCloseButton\n label={bannerProps.label || 'Unread messages'}\n containerProps={{ id: 'ds-chat-banner' }}\n actionLink={{\n label: bannerProps.viewLabel || 'View',\n onClick: bannerProps.onView,\n }}\n onClose={bannerProps.onClose}\n isOpen\n type={bannerProps.type || BANNER_TYPES.INFO}\n actionRef={bannerRef}\n />\n </StyledIndicatorContainer>\n {sendingMessages && sendingMessages.length > 0 ? (\n <StyledIndicatorContainer isLoading=\"bottom\" linear data-testid=\"ds-chat-loading-indicator\">\n <DSIndeterminateProgressIndicator processing title=\"Loading\" lineOnly />\n </StyledIndicatorContainer>\n ) : null}\n </div>\n <ChatComposer\n {...composerProps}\n onKeyDown={handleTabs}\n onResize={onResize}\n maxHeight={(containerRef.current?.clientHeight || 0) / 2}\n actionRef={actionRef || listRef}\n />\n </Container>\n );\n};\n\nChatContainer.propTypes = containerProps;\nChatContainer.defaultProps = defaultProps;\nconst ChatContainerWithSchema = describe(ChatContainer);\nChatContainerWithSchema.propTypes = containerProps;\n\nexport { ChatContainer, ChatContainerWithSchema };\n"],"names":["ChatContainer","props","useValidateProps","ChatContainerWithSchema","toTypescript","sendingText","sendingMessages","bannerPosition","bannerProps","messagesListProps","composerProps","onComposerResize","onResize","onComposerKeyDown","onKeyDown","actionRef","autoScroll","device","isLoading","hasMoreItems","getMoreMessages","bannerRef","React","useRef","focusOnWrapper","noop","focusOnLink","containerRef","listRef","scrollToIndex","useCallback","height","current","messages","length","align","Container","StyledChatContainerContent","MobileStyledChatContainerContent","handleTabs","e","ref","shiftKey","key","preventDefault","includes","last","getMessagesInView","pop","focusToIndexWithoutScroll","useEffect","focusOnBanner","focusOnBannerLink","position","overflow","label","id","viewLabel","onClick","onView","onClose","type","BANNER_TYPES","INFO","clientHeight","propTypes","containerProps","defaultProps","describe"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAaMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,KAAD,EAA4C;AAAA;;AAChEC,EAAAA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AEVC,MAAAA,OAAO,EAAElD,WAAW,CAACmD;AAFX,KAJd;AAQE,IAAA,OAAO,EAAEnD,WAAW,CAACoD,OARvB;AASE,IAAA,MAAM,MATR;AAUE,IAAA,IAAI,EAAEpD,WAAW,CAACqD,IAAZ,IAAoBC,YAAY,CAACC,IAVzC;AAWE,IAAA,SAAS,EAAE1C;AAXb,IADF,CAjBF,EAgCGf,eAAe,IAAIA,eAAe,CAAC4B,MAAhB,GAAyB,CAA5C,gBACC,oBAAC,wBAAD;AAA0B,IAAA,SAAS,EAAC,QAApC;AAA6C,IAAA,MAAM,MAAnD;AAAoD,mBAAY;AAAhE,kBACE,oBAAC,gCAAD;AAAkC,IAAA,UAAU,MAA5C;AAA6C,IAAA,KAAK,EAAC,SAAnD;AAA6D,IAAA,QAAQ;AAArE,IADF,CADD,GAIG,IApCN,CADF,eAuCE,oBAAC,YAAD,eACMxB,aADN;AAEE,IAAA,SAAS,EAAE6B,UAFb;AAGE,IAAA,QAAQ,EAAE3B,QAHZ;AAIE,IAAA,SAAS,EAAE,CAAC,0BAAAe,YAAY,CAACK,OAAb,gFAAsBgC,YAAtB,KAAsC,CAAvC,IAA4C,CAJzD;AAKE,IAAA,SAAS,EAAEjD,SAAS,IAAIa;AAL1B,KAvCF,CADF;AAiDD;;AAED5B,aAAa,CAACiE,SAAd,GAA0BC,cAA1B;AACAlE,aAAa,CAACmE,YAAd,GAA6BA,YAA7B;IACMhE,uBAAuB,GAAGiE,QAAQ,CAACpE,aAAD;AACxCG,uBAAuB,CAAC8D,SAAxB,GAAoCC,cAApC;;;;"}
|
|
1
|
+
{"version":3,"file":"ChatContainer.js","sources":["../../../../src/parts/chat-container/ChatContainer.tsx"],"sourcesContent":["/* eslint-disable max-lines */\n/* eslint-disable complexity */\nimport React from 'react';\nimport { noop } from 'lodash';\nimport { describe } from 'react-desc';\nimport DSIndeterminateProgressIndicator from '@elliemae/ds-indeterminate-progress-indicator';\nimport DSBanner, { BANNER_TYPES } from '@elliemae/ds-banner';\nimport { ChatComposer } from '../chat-composer';\nimport { ChatContainerMessagesList } from '../chat-container-messages-list';\nimport { ChatContainerProps, defaultProps, containerProps } from './props';\nimport { StyledChatContainerContent, StyledIndicatorContainer, MobileStyledChatContainerContent } from './styled';\nimport { useValidateProps } from './config/useValidateProps';\n\nconst ChatContainer = (props: ChatContainerProps): JSX.Element => {\n useValidateProps(props, ChatContainerWithSchema.toTypescript());\n\n const {\n sendingText,\n sendingMessages,\n bannerPosition,\n bannerProps,\n messagesListProps,\n composerProps,\n composerProps: { onResize: onComposerResize, onKeyDown: onComposerKeyDown },\n actionRef,\n autoScroll,\n device,\n isLoading,\n hasMoreItems,\n getMoreMessages,\n ariaLabel\n } = props;\n const bannerRef = React.useRef({ focusOnWrapper: noop, focusOnLink: noop });\n const containerRef = React.useRef<HTMLElement>();\n const listRef = React.useRef({ scrollToIndex: noop });\n const onResize = React.useCallback(\n (height: number) => {\n if (onComposerResize) onComposerResize(height);\n if (autoScroll) {\n listRef.current.scrollToIndex(messagesListProps.messages.length - 1, {\n align: 'end',\n });\n }\n },\n [onComposerResize, messagesListProps.messages, autoScroll],\n );\n const Container = device === 'desktop' ? StyledChatContainerContent : MobileStyledChatContainerContent;\n const handleTabs = React.useCallback(\n (e) => {\n if (onComposerKeyDown) onComposerKeyDown(e);\n else {\n const ref = actionRef || listRef;\n if (e.shiftKey && e.key === 'Tab') {\n e.preventDefault();\n if (['top', 'bottom'].includes(bannerPosition)) {\n bannerRef.current.focusOnWrapper();\n } else {\n const last = ref.current.getMessagesInView().pop();\n ref.current.focusToIndexWithoutScroll(last);\n }\n }\n }\n },\n [actionRef, onComposerKeyDown, bannerPosition],\n );\n\n // Map actions\n React.useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.focusOnBanner = bannerRef.current.focusOnWrapper;\n actionRef.current.focusOnBannerLink = bannerRef.current.focusOnLink;\n }\n }, [actionRef]);\n\n return (\n <Container rows={['minmax(0, 1fr)', 'auto']} ref={containerRef} role=\"region\" aria-label={ariaLabel}>\n <div style={{ position: 'relative', overflow: 'hidden' }}>\n <ChatContainerMessagesList\n {...messagesListProps}\n actionRef={actionRef || listRef}\n isLoading={isLoading}\n hasMoreItems={hasMoreItems}\n getMoreMessages={getMoreMessages}\n sendingMessages={sendingMessages}\n sendingText={sendingText}\n bannerPosition={bannerPosition}\n bannerRef={bannerRef}\n />\n {['top', 'bottom'].includes(isLoading) ? (\n <StyledIndicatorContainer isLoading={isLoading} data-testid=\"ds-chat-loading-indicator\">\n <DSIndeterminateProgressIndicator processing title=\"Loading\" />\n </StyledIndicatorContainer>\n ) : null}\n <StyledIndicatorContainer linear isLoading={bannerPosition}>\n <DSBanner\n showCloseButton\n label={bannerProps.label || 'Unread messages'}\n containerProps={{ id: 'ds-chat-banner' }}\n actionLink={{\n label: bannerProps.viewLabel || 'View',\n onClick: bannerProps.onView,\n }}\n onClose={bannerProps.onClose}\n isOpen\n type={bannerProps.type || BANNER_TYPES.INFO}\n actionRef={bannerRef}\n />\n </StyledIndicatorContainer>\n {sendingMessages && sendingMessages.length > 0 ? (\n <StyledIndicatorContainer isLoading=\"bottom\" linear data-testid=\"ds-chat-loading-indicator\">\n <DSIndeterminateProgressIndicator processing title=\"Loading\" lineOnly />\n </StyledIndicatorContainer>\n ) : null}\n </div>\n <ChatComposer\n {...composerProps}\n onKeyDown={handleTabs}\n onResize={onResize}\n maxHeight={(containerRef.current?.clientHeight || 0) / 2}\n actionRef={actionRef || listRef}\n />\n </Container>\n );\n};\n\nChatContainer.propTypes = containerProps;\nChatContainer.defaultProps = defaultProps;\nconst ChatContainerWithSchema = describe(ChatContainer);\nChatContainerWithSchema.propTypes = containerProps;\n\nexport { ChatContainer, ChatContainerWithSchema };\n"],"names":["ChatContainer","props","useValidateProps","ChatContainerWithSchema","toTypescript","sendingText","sendingMessages","bannerPosition","bannerProps","messagesListProps","composerProps","onComposerResize","onResize","onComposerKeyDown","onKeyDown","actionRef","autoScroll","device","isLoading","hasMoreItems","getMoreMessages","ariaLabel","bannerRef","React","useRef","focusOnWrapper","noop","focusOnLink","containerRef","listRef","scrollToIndex","useCallback","height","current","messages","length","align","Container","StyledChatContainerContent","MobileStyledChatContainerContent","handleTabs","e","ref","shiftKey","key","preventDefault","includes","last","getMessagesInView","pop","focusToIndexWithoutScroll","useEffect","focusOnBanner","focusOnBannerLink","position","overflow","label","id","viewLabel","onClick","onView","onClose","type","BANNER_TYPES","INFO","clientHeight","propTypes","containerProps","defaultProps","describe"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAaMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,KAAD,EAA4C;AAAA;;AAChEC,EAAAA,gBAAgB,CAACD,KAAD,EAAQE,uBAAuB,CAACC,YAAxB,EAAR,CAAhB;AAEA,MACEC,WADF,GAeIJ,KAfJ,CACEI,WADF;AAAA,MAEEC,eAFF,GAeIL,KAfJ,CAEEK,eAFF;AAAA,MAGEC,cAHF,GAeIN,KAfJ,CAGEM,cAHF;AAAA,MAIEC,WAJF,GAeIP,KAfJ,CAIEO,WAJF;AAAA,MAKEC,iBALF,GAeIR,KAfJ,CAKEQ,iBALF;AAAA,MAMEC,aANF,GAeIT,KAfJ,CAMES,aANF;AAAA,6BAeIT,KAfJ,CAOES,aAPF;AAAA,MAO6BC,gBAP7B,wBAOmBC,QAPnB;AAAA,MAO0DC,iBAP1D,wBAO+CC,SAP/C;AAAA,MAQEC,SARF,GAeId,KAfJ,CAQEc,SARF;AAAA,MASEC,UATF,GAeIf,KAfJ,CASEe,UATF;AAAA,MAUEC,MAVF,GAeIhB,KAfJ,CAUEgB,MAVF;AAAA,MAWEC,SAXF,GAeIjB,KAfJ,CAWEiB,SAXF;AAAA,MAYEC,YAZF,GAeIlB,KAfJ,CAYEkB,YAZF;AAAA,MAaEC,eAbF,GAeInB,KAfJ,CAaEmB,eAbF;AAAA,MAcEC,SAdF,GAeIpB,KAfJ,CAcEoB,SAdF;AAgBA,MAAMC,SAA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S,EAAElD,SAAS,IAAIc;AAL1B,KAvCF,CADF;AAiDD;;AAED7B,aAAa,CAACkE,SAAd,GAA0BC,cAA1B;AACAnE,aAAa,CAACoE,YAAd,GAA6BA,YAA7B;IACMjE,uBAAuB,GAAGkE,QAAQ,CAACrE,aAAD;AACxCG,uBAAuB,CAAC+D,SAAxB,GAAoCC,cAApC;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PropTypes } from 'react-desc';
|
|
2
2
|
import { noop } from 'lodash';
|
|
3
|
+
import { BANNER_TYPES } from '@elliemae/ds-banner';
|
|
3
4
|
import { defaultProps as defaultProps$1 } from '../chat-container-messages-list/props.js';
|
|
4
5
|
import { defaultComposerPros } from '../chat-composer/props.js';
|
|
5
6
|
|
|
@@ -14,13 +15,15 @@ var defaultProps = {
|
|
|
14
15
|
getMoreMessages: noop,
|
|
15
16
|
bannerPosition: undefined,
|
|
16
17
|
bannerProps: {
|
|
18
|
+
type: BANNER_TYPES.INFO,
|
|
17
19
|
label: 'Unread Messages',
|
|
18
20
|
viewLabel: 'View',
|
|
19
21
|
onView: noop,
|
|
20
22
|
onClose: noop
|
|
21
23
|
},
|
|
22
24
|
sendingMessages: undefined,
|
|
23
|
-
sendingText: 'Sending'
|
|
25
|
+
sendingText: 'Sending',
|
|
26
|
+
ariaLabel: 'Chat window'
|
|
24
27
|
};
|
|
25
28
|
var containerProps = {
|
|
26
29
|
messagesListProps: PropTypes.object.description('ChatMessageList props "messages" / "onScrollEnds"').defaultValue(defaultProps.messagesListProps),
|
|
@@ -34,7 +37,8 @@ var containerProps = {
|
|
|
34
37
|
bannerProps: PropTypes.object.description("Banner configuration:\n label: string;\n viewLabel: string;\n type: BANNER_TYPES;\n onView: () => void;\n onClose: () => void;\n ").defaultValue(defaultProps.bannerProps),
|
|
35
38
|
sendingMessages: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.arrayOf(PropTypes.number)]).description('Array of ids of sending messages').defaultValue(defaultProps.sendingMessages),
|
|
36
39
|
sendingText: PropTypes.string.description('Label description for messages in sending status').defaultValue(defaultProps.sendingText),
|
|
37
|
-
actionRef: PropTypes.object.description("Reference: \n { \n scrollToIndex: (n: number) => void,\n getMessagesInView: () => number[],\n focusToIndex: (n: number) => void,\n focusToList: () => void,\n focusToComposer: () => void,\n focusToSend: () => void,\n }\n \n ").defaultValue(defaultProps.actionRef)
|
|
40
|
+
actionRef: PropTypes.object.description("Reference: \n { \n scrollToIndex: (n: number) => void,\n getMessagesInView: () => number[],\n focusToIndex: (n: number) => void,\n focusToList: () => void,\n focusToComposer: () => void,\n focusToSend: () => void,\n }\n \n ").defaultValue(defaultProps.actionRef),
|
|
41
|
+
ariaLabel: PropTypes.string.description('Aria Label description for chat container').defaultValue(defaultProps.ariaLabel)
|
|
38
42
|
};
|
|
39
43
|
|
|
40
44
|
export { containerProps, defaultProps };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props.js","sources":["../../../../src/parts/chat-container/props.ts"],"sourcesContent":["import { PropTypes } from 'react-desc';\nimport { noop } from 'lodash';\nimport { BANNER_TYPES } from '@elliemae/ds-banner';\nimport {\n ChatContainerMessagesListProps,\n defaultProps as defaultListProps,\n} from '../chat-container-messages-list/props';\nimport { defaultComposerPros, ChatComposerProps } from '../chat-composer/props';\n\ninterface ChatBannerProps {\n label: string;\n viewLabel: string;\n type
|
|
1
|
+
{"version":3,"file":"props.js","sources":["../../../../src/parts/chat-container/props.ts"],"sourcesContent":["import { PropTypes } from 'react-desc';\nimport { noop } from 'lodash';\nimport { BANNER_TYPES } from '@elliemae/ds-banner';\nimport {\n ChatContainerMessagesListProps,\n defaultProps as defaultListProps,\n} from '../chat-container-messages-list/props';\nimport { defaultComposerPros, ChatComposerProps } from '../chat-composer/props';\n\ninterface ChatBannerProps {\n label: string;\n viewLabel: string;\n type?: BANNER_TYPES;\n onView: () => void;\n onClose: () => void;\n}\nexport interface ChatContainerProps {\n messagesListProps: Pick<ChatContainerMessagesListProps, 'messages' | 'onScrollEnds'>;\n composerProps: ChatComposerProps;\n actionRef: PropTypes.func;\n autoScroll: boolean;\n device: 'desktop' | 'mobile';\n isLoading?: 'top' | 'bottom';\n hasMoreItems?: 'top' | 'bottom';\n getMoreMessages: PropTypes.func;\n bannerPosition?: 'top' | 'bottom';\n bannerProps?: ChatBannerProps;\n sendingMessages?: string[] | number[];\n sendingText: string;\n ariaLabel: string;\n}\n\nexport const defaultProps: ChatContainerProps = {\n messagesListProps: defaultListProps,\n composerProps: defaultComposerPros,\n actionRef: undefined,\n autoScroll: false,\n device: 'desktop',\n isLoading: undefined,\n hasMoreItems: undefined,\n getMoreMessages: noop,\n bannerPosition: undefined,\n bannerProps: {\n type: BANNER_TYPES.INFO,\n label: 'Unread Messages',\n viewLabel: 'View',\n onView: noop,\n onClose: noop,\n },\n sendingMessages: undefined,\n sendingText: 'Sending',\n ariaLabel: 'Chat window',\n};\n\nexport const containerProps = {\n messagesListProps: PropTypes.object\n .description('ChatMessageList props \"messages\" / \"onScrollEnds\"')\n .defaultValue(defaultProps.messagesListProps),\n composerProps: PropTypes.object.description('Composer configuration').defaultValue(defaultProps.composerProps),\n autoScroll: PropTypes.bool.description('Auto scroll to bottom on resize').defaultValue(defaultProps.autoScroll),\n device: PropTypes.string\n .description('Option to render mobile or desktop style composer')\n .defaultValue(defaultProps.device),\n isLoading: PropTypes.oneOf(['top', 'bottom', undefined]).description(\n 'Show Loading messages indicator at the `top` or `bottom` of the container',\n ),\n hasMoreItems: PropTypes.oneOf(['top', 'bottom', undefined]).description(\n 'Show Load More button at the `top` or `bottom` of the container',\n ),\n getMoreMessages: PropTypes.func\n .description('Called when the user clicks on load more')\n .defaultValue(defaultProps.getMoreMessages),\n bannerPosition: PropTypes.oneOf(['top', 'bottom', undefined]).description(\n 'Show Loading messages indicator at the `top` or `bottom` of the container',\n ),\n bannerProps: PropTypes.object\n .description(\n `Banner configuration:\n label: string;\n viewLabel: string;\n type: BANNER_TYPES;\n onView: () => void;\n onClose: () => void;\n `,\n )\n .defaultValue(defaultProps.bannerProps),\n sendingMessages: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.arrayOf(PropTypes.number)])\n .description('Array of ids of sending messages')\n .defaultValue(defaultProps.sendingMessages),\n sendingText: PropTypes.string\n .description('Label description for messages in sending status')\n .defaultValue(defaultProps.sendingText),\n actionRef: PropTypes.object\n .description(\n `Reference: \n { \n scrollToIndex: (n: number) => void,\n getMessagesInView: () => number[],\n focusToIndex: (n: number) => void,\n focusToList: () => void,\n focusToComposer: () => void,\n focusToSend: () => void,\n }\n \n `,\n )\n .defaultValue(defaultProps.actionRef),\n ariaLabel: PropTypes.string\n .description('Aria Label description for chat container')\n .defaultValue(defaultProps.ariaLabel),\n};\n"],"names":["defaultProps","messagesListProps","defaultListProps","composerProps","defaultComposerPros","actionRef","undefined","autoScroll","device","isLoading","hasMoreItems","getMoreMessages","noop","bannerPosition","bannerProps","type","BANNER_TYPES","INFO","label","viewLabel","onView","onClose","sendingMessages","sendingText","ariaLabel","containerProps","PropTypes","object","description","defaultValue","bool","string","oneOf","func","oneOfType","arrayOf","number"],"mappings":";;;;;;IAgCaA,YAAgC,GAAG;AAC9CC,EAAAA,iBAAiB,EAAEC,cAD2B;AAE9CC,EAAAA,aAAa,EAAEC,mBAF+B;AAG9CC,EAAAA,SAAS,EAAEC,SAHmC;AAI9CC,EAAAA,UAAU,EAAE,KAJkC;AAK9CC,EAAAA,MAAM,EAAE,SALsC;AAM9CC,EAAAA,SAAS,EAAEH,SANmC;AAO9CI,EAAAA,YAAY,EAAEJ,SAPgC;AAQ9CK,EAAAA,eAAe,EAAEC,IAR6B;AAS9CC,EAAAA,cAAc,EAAEP,SAT8B;AAU9CQ,EAAAA,WAAW,EAAE;AACXC,IAAAA,IAAI,EAAEC,YAAY,CAACC,IADR;AAEXC,IAAAA,KAAK,EAAE,iBAFI;AAGXC,IAAAA,SAAS,EAAE,MAHA;AAIXC,IAAAA,MAAM,EAA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AA,WAAW,EAAEY,SAAS,CAACC,MAAV,CACVC,WADU,4IAUVC,YAVU,CAUG7B,YAAY,CAACc,WAVhB,CArBe;AAgC5BQ,EAAAA,eAAe,EAAEI,SAAS,CAACQ,SAAV,CAAoB,CAACR,SAAS,CAACS,OAAV,CAAkBT,SAAS,CAACK,MAA5B,CAAD,EAAsCL,SAAS,CAACS,OAAV,CAAkBT,SAAS,CAACU,MAA5B,CAAtC,CAApB,EACdR,WADc,CACF,kCADE,EAEdC,YAFc,CAED7B,YAAY,CAACsB,eAFZ,CAhCW;AAmC5BC,EAAAA,WAAW,EAAEG,SAAS,CAACK,MAAV,CACVH,WADU,CACE,kDADF,EAEVC,YAFU,CAEG7B,YAAY,CAACuB,WAFhB,CAnCe;AAsC5BlB,EAAAA,SAAS,EAAEqB,SAAS,CAACC,MAAV,CACRC,WADQ,oTAcRC,YAdQ,CAcK7B,YAAY,CAACK,SAdlB,CAtCiB;AAqD5BmB,EAAAA,SAAS,EAAEE,SAAS,CAACK,MAAV,CACRH,WADQ,CACI,2CADJ,EAERC,YAFQ,CAEK7B,YAAY,CAACwB,SAFlB;AArDiB;;;;"}
|
|
@@ -79,6 +79,7 @@ var ChatContainerMessagesList = function ChatContainerMessagesList(props) {
|
|
|
79
79
|
return [];
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
if (!virtualListRef.current) return [];
|
|
82
83
|
pendingOnScroll.current = false;
|
|
83
84
|
|
|
84
85
|
var _virtualListRef$curre = (_virtualListRef$curre2 = virtualListRef.current) === null || _virtualListRef$curre2 === void 0 ? void 0 : _virtualListRef$curre2.getBoundingClientRect(),
|
|
@@ -195,7 +196,7 @@ var ChatContainerMessagesList = function ChatContainerMessagesList(props) {
|
|
|
195
196
|
|
|
196
197
|
break;
|
|
197
198
|
}
|
|
198
|
-
}, [actionRef, hasMoreItems, messages.length, bannerPosition, scrollAndFocus]);
|
|
199
|
+
}, [actionRef, bannerRef, hasMoreItems, messages.length, bannerPosition, scrollAndFocus]);
|
|
199
200
|
var handleListKey = React.useCallback(function (e) {
|
|
200
201
|
var key = e.key;
|
|
201
202
|
|
|
@@ -227,12 +228,7 @@ var ChatContainerMessagesList = function ChatContainerMessagesList(props) {
|
|
|
227
228
|
|
|
228
229
|
e.preventDefault();
|
|
229
230
|
(_loadMoreRef$current3 = loadMoreRef.current) === null || _loadMoreRef$current3 === void 0 ? void 0 : _loadMoreRef$current3.focus();
|
|
230
|
-
} else if (hasMoreItems === 'top' && e.shiftKey) {
|
|
231
|
-
var _loadMoreRef$current4;
|
|
232
|
-
|
|
233
|
-
e.preventDefault();
|
|
234
|
-
(_loadMoreRef$current4 = loadMoreRef.current) === null || _loadMoreRef$current4 === void 0 ? void 0 : _loadMoreRef$current4.focus();
|
|
235
|
-
} else if (!e.shiftKey) {
|
|
231
|
+
} else if (hasMoreItems === 'top' && e.shiftKey) ; else if (!e.shiftKey) {
|
|
236
232
|
e.preventDefault();
|
|
237
233
|
actionRef.current.focusToComposer();
|
|
238
234
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatContainerMessagesList.js","sources":["../../../../src/parts/chat-container-messages-list/ChatContainerMessagesList.tsx"],"sourcesContent":["/* eslint-disable complexity */\n/* eslint-disable jsx-a11y/no-noninteractive-tabindex */\n/* eslint-disable max-lines */\nimport React, { CSSProperties } from 'react';\nimport { describe } from 'react-desc';\nimport { useVirtual } from 'react-virtual';\nimport DSButton from '@elliemae/ds-button';\nimport { debounce } from 'lodash';\nimport { ChatBubble, BUBBLE_TYPES } from '../bubble';\nimport { MessageDelimiter } from '../message-delimiter';\nimport { SystemMessage } from '../system-message';\nimport {\n StyledWrapperListItem,\n StyledChatContainerContentList,\n StyledChatContainerContentListScroll,\n StyledWrapper,\n StyledLoadMoreContainer,\n ListItem,\n} from './styled';\nimport { defaultProps, listProps, ChatContainerMessagesListProps } from './props';\nimport { useValidateProps } from './config/useValidateProps';\n\nconst getPadding = (hasMoreItems) => {\n const padding = {\n paddingStart: 0,\n paddingEnd: -5,\n };\n if (hasMoreItems === 'top') padding.paddingStart = 42;\n else if (hasMoreItems === 'bottom') padding.paddingEnd = 42;\n return padding;\n};\n\nconst ChatContainerMessagesList = (props: ChatContainerMessagesListProps): JSX.Element => {\n useValidateProps(props, ChatContainerMessagesListWithSchema.toTypescript());\n\n const {\n sendingText,\n bannerPosition,\n sendingMessages,\n messages,\n actionRef,\n onScrollEnds,\n getMoreMessages,\n hasMoreItems,\n isLoading,\n bannerRef,\n } = props;\n const pendingOnScroll = React.useRef(false);\n const loadMoreRef = React.useRef(null);\n const virtualListRef = React.useRef<HTMLDivElement>();\n // estimateSize should not be really required given what was stated on\n // https://github.com/tannerlinsley/react-virtual/issues/23\n const {\n scrollToIndex: vScroll,\n totalSize,\n virtualItems,\n } = useVirtual({\n size: messages.length,\n parentRef: virtualListRef,\n overscan: 15,\n ...getPadding(hasMoreItems),\n estimateSize: React.useCallback(() => 80, []),\n });\n\n const debouncedScroll = React.useMemo(\n () =>\n debounce((): number[] => {\n if (document.visibilityState === 'hidden') {\n pendingOnScroll.current = true;\n return [];\n }\n pendingOnScroll.current = false;\n const { bottom, top } = virtualListRef.current?.getBoundingClientRect();\n const list = virtualListRef.current.querySelectorAll(\n '[data-element=\"chat-element-list-item\"]',\n ) as NodeListOf<HTMLDivElement>;\n const indexList = [];\n list.forEach((item: HTMLDivElement) => {\n const { top: itemTop } = item.getBoundingClientRect();\n const itemPadding = 10;\n if (itemTop + itemPadding < bottom && itemTop + itemPadding > top) indexList.push(item.dataset.index);\n });\n if (onScrollEnds) onScrollEnds(indexList);\n return indexList;\n }, 500),\n [onScrollEnds],\n );\n\n const onScrollStop = React.useCallback(debouncedScroll, [debouncedScroll]);\n\n const onlyFocus = React.useCallback((index: number) => {\n setTimeout(() => {\n (virtualListRef.current.querySelector(`[data-index=\"${index}\"]`) as HTMLDivElement).focus();\n }, 300);\n }, []);\n\n const scrollAndFocus = React.useCallback(\n (index: number, b = { align: 'center' }) => {\n vScroll(index, b);\n onlyFocus(index);\n onScrollStop();\n },\n [onScrollStop, onlyFocus, vScroll],\n );\n\n React.useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.scrollToIndex = (a, b = { align: 'center' }) => {\n vScroll(a, b as any);\n onScrollStop();\n };\n actionRef.current.getMessagesInView = onScrollStop;\n actionRef.current.focusToIndex = (a, b = { align: 'center' } as ScrollToOptions) => {\n scrollAndFocus(a, b);\n };\n actionRef.current.focusToIndexWithoutScroll = onlyFocus;\n actionRef.current.focusToList = () => {\n virtualListRef.current?.focus();\n };\n }\n }, [actionRef, onScrollStop, onlyFocus, scrollAndFocus, vScroll]);\n\n const handleKey = React.useCallback(\n (e) => {\n const { key } = e;\n const index = Number(e.currentTarget.dataset.index);\n e.stopPropagation();\n switch (key) {\n case 'ArrowUp':\n e.preventDefault();\n if (index > 0)\n (virtualListRef.current.querySelector(`[data-index=\"${index - 1}\"]`) as HTMLDivElement).focus();\n break;\n case 'ArrowDown':\n e.preventDefault();\n if (index < messages.length - 1) {\n (virtualListRef.current.querySelector(`[data-index=\"${index + 1}\"]`) as HTMLDivElement).focus();\n }\n break;\n case 'Home':\n e.preventDefault();\n scrollAndFocus(0);\n break;\n case 'End':\n e.preventDefault();\n scrollAndFocus(messages.length - 1);\n break;\n case 'Tab':\n e.preventDefault();\n if (hasMoreItems === 'bottom' && !e.shiftKey) {\n loadMoreRef.current?.focus();\n } else if (hasMoreItems === 'top' && e.shiftKey) {\n loadMoreRef.current?.focus();\n } else if (!e.shiftKey) {\n if (bannerPosition) {\n bannerRef.current.focusOnWrapper();\n } else {\n actionRef.current.focusToComposer();\n }\n } else {\n virtualListRef.current?.focus();\n }\n break;\n default:\n break;\n }\n },\n [actionRef, hasMoreItems, messages.length, bannerPosition, scrollAndFocus],\n );\n const handleListKey = React.useCallback(\n (e) => {\n const { key } = e;\n switch (key) {\n case 'ArrowUp':\n e.preventDefault();\n onlyFocus(onScrollStop().shift());\n break;\n case 'ArrowDown':\n e.preventDefault();\n onlyFocus(onScrollStop().pop());\n break;\n case 'Home':\n e.preventDefault();\n scrollAndFocus(0);\n break;\n case 'End':\n e.preventDefault();\n scrollAndFocus(messages.length - 1);\n break;\n case 'Tab':\n if (document.activeElement !== loadMoreRef.current) {\n if (hasMoreItems === 'bottom' && !e.shiftKey) {\n e.preventDefault();\n loadMoreRef.current?.focus();\n } else if (hasMoreItems === 'top' && e.shiftKey) {\n e.preventDefault();\n loadMoreRef.current?.focus();\n } else if (!e.shiftKey) {\n e.preventDefault();\n actionRef.current.focusToComposer();\n }\n } else if (!e.shiftKey) {\n e.preventDefault();\n actionRef.current.focusToComposer();\n } else {\n e.preventDefault();\n virtualListRef.current?.focus();\n }\n break;\n default:\n break;\n }\n },\n [actionRef, hasMoreItems, messages.length, onScrollStop, onlyFocus, scrollAndFocus],\n );\n\n const checkPendingOnScroll = React.useCallback(() => {\n if (pendingOnScroll.current === true) onScrollStop();\n }, [onScrollStop]);\n\n React.useEffect(() => {\n let handlerCallback = null;\n const localVirtualRef = virtualListRef.current;\n const onScroll = () => {\n if (handlerCallback) clearTimeout(handlerCallback);\n handlerCallback = setTimeout(onScrollStop, 300);\n };\n if (onScrollEnds) {\n virtualListRef.current.addEventListener('scroll', onScroll);\n }\n document.addEventListener('visibilitychange', checkPendingOnScroll);\n return () => {\n if (handlerCallback) clearTimeout(handlerCallback);\n if (onScrollEnds) localVirtualRef.removeEventListener('scroll', onScroll);\n document.removeEventListener('visibilitychange', checkPendingOnScroll);\n };\n }, [onScrollStop, onScrollEnds, checkPendingOnScroll]);\n\n const render = React.useMemo(\n () =>\n virtualItems.map((virtualItem) => {\n const { index, measureRef, start } = virtualItem;\n const row = messages[index];\n const isSending = sendingMessages && sendingMessages.find((m) => m === row.dsId);\n const style: CSSProperties = {\n position: 'absolute',\n top: 0,\n left: 0,\n transform: `translateY(${start}px)`,\n width: '100%',\n };\n\n return (\n <ListItem\n data-element=\"chat-element-list-item\"\n data-index={index}\n key={`ds-chat-bubble-${index}-${row.dsId}-${row.type}`}\n style={style}\n ref={measureRef}\n tabIndex={0}\n onKeyDown={handleKey}\n role=\"listitem\"\n >\n <StyledWrapperListItem type={row.type}>\n {row.type === BUBBLE_TYPES.SENDER || row.type === BUBBLE_TYPES.RECIPIENT ? (\n // eslint-disable-next-line\n <ChatBubble {...(row as any)} helpMessage={isSending ? sendingText : row.helpMessage} />\n ) : null}\n {row.type === BUBBLE_TYPES.DELIMITER ? <MessageDelimiter {...(row as any)} /> : null}\n {row.type === BUBBLE_TYPES.SYSTEM ? <SystemMessage {...(row as any)} /> : null}\n </StyledWrapperListItem>\n </ListItem>\n );\n }),\n [virtualItems, messages, sendingMessages, handleKey, sendingText],\n );\n\n return (\n <StyledWrapper>\n <StyledChatContainerContentList\n data-testid=\"chat-thread-container\"\n tabIndex={0}\n aria-live=\"polite\"\n ref={virtualListRef}\n role=\"list\"\n onKeyDown={handleListKey}\n >\n <StyledChatContainerContentListScroll height={`${totalSize}px`}>\n {render}\n {!isLoading && hasMoreItems ? (\n <StyledLoadMoreContainer hasMoreItems={hasMoreItems}>\n <DSButton\n labelText=\"Load More\"\n buttonType=\"secondary\"\n onClick={getMoreMessages}\n data-testid=\"ds-chat-load-more-btn\"\n innerRef={loadMoreRef}\n />\n </StyledLoadMoreContainer>\n ) : null}\n </StyledChatContainerContentListScroll>\n </StyledChatContainerContentList>\n </StyledWrapper>\n );\n};\n\nChatContainerMessagesList.propTypes = listProps;\nChatContainerMessagesList.defaultProps = defaultProps;\nconst ChatContainerMessagesListWithSchema = describe(ChatContainerMessagesList);\nChatContainerMessagesListWithSchema.propTypes = listProps;\n\nexport { ChatContainerMessagesList, ChatContainerMessagesListWithSchema };\n"],"names":["getPadding","hasMoreItems","padding","paddingStart","paddingEnd","ChatContainerMessagesList","props","useValidateProps","ChatContainerMessagesListWithSchema","toTypescript","sendingText","bannerPosition","sendingMessages","messages","actionRef","onScrollEnds","getMoreMessages","isLoading","bannerRef","pendingOnScroll","React","useRef","loadMoreRef","virtualListRef","useVirtual","size","length","parentRef","overscan","estimateSize","useCallback","vScroll","scrollToIndex","totalSize","virtualItems","debouncedScroll","useMemo","debounce","document","visibilityState","current","getBoundingClientRect","bottom","top","list","querySelectorAll","indexList","forEach","item","itemTop","itemPadding","push","dataset","index","onScrollStop","onlyFocus","setTimeout","querySelector","focus","scrollAndFocus","b","align","useEffect","a","getMessagesInView","focusToIndex","focusToIndexWithoutScroll","focusToList","handleKey","e","key","Number","currentTarget","stopPropagation","preventDefault","shiftKey","focusOnWrapper","focusToComposer","handleListKey","shift","pop","activeElement","checkPendingOnScroll","handlerCallback","localVirtualRef","onScroll","clearTimeout","addEventListener","removeEventListener","render","map","virtualItem","measureRef","start","row","isSending","find","m","dsId","style","position","left","transform","width","type","BUBBLE_TYPES","SENDER","RECIPIENT","helpMessage","DELIMITER","SYSTEM","propTypes","listProps","defaultProps","describe"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAMA,UAAU,GAAG,SAAbA,UAAa,CAACC,YAAD,EAAkB;AACnC,MAAMC,OAAO,GAAG;AACdC,IAAAA,YAAY,EAAE,CADA;AAEdC,IAAAA,UAAU,EAAE,CAAC;AAFC,GAAhB;AAIA,MAAIH,YAAY,KAAK,KAArB,EAA4BC,OAAO,CAACC,YAAR,GAAuB,EAAvB,CAA5B,KACK,IAAIF,YAAY,KAAK,QAArB,EAA+BC,OAAO,CAACE,UAAR,GAAqB,EAArB;AACpC,SAAOF,OAAP;AACD,CARD;;IAUMG,yBAAyB,GAAG,SAA5BA,yBAA4B,CAACC,KAAD,EAAwD;AACxFC,EAAAA,gBAAgB,CAACD,KAAD,EAAQE,mCAAmC,CAACC,YAApC,EAAR,CAAhB;AAEA,MACEC,WADF,GAWIJ,KAXJ,CACEI,WADF;AAAA,MAEEC,cAFF,GAWIL,KAXJ,CAEEK,cAFF;AAAA,MAGEC,eAHF,GAWIN,KAXJ,CAGEM,eAHF;AAAA,MAIEC,QAJF,GAWIP,KAXJ,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,CADD,GAUG,IAZN,CARF,CADF,CADF;AA2BD;;AAEDjB,yBAAyB,CAAC0G,SAA1B,GAAsCC,SAAtC;AACA3G,yBAAyB,CAAC4G,YAA1B,GAAyCA,YAAzC;IACMzG,mCAAmC,GAAG0G,QAAQ,CAAC7G,yBAAD;AACpDG,mCAAmC,CAACuG,SAApC,GAAgDC,SAAhD;;;;"}
|
|
1
|
+
{"version":3,"file":"ChatContainerMessagesList.js","sources":["../../../../src/parts/chat-container-messages-list/ChatContainerMessagesList.tsx"],"sourcesContent":["/* eslint-disable complexity */\n/* eslint-disable jsx-a11y/no-noninteractive-tabindex */\n/* eslint-disable max-lines */\nimport React, { CSSProperties } from 'react';\nimport { describe } from 'react-desc';\nimport { useVirtual } from 'react-virtual';\nimport DSButton from '@elliemae/ds-button';\nimport { debounce } from 'lodash';\nimport { ChatBubble, BUBBLE_TYPES } from '../bubble';\nimport { MessageDelimiter } from '../message-delimiter';\nimport { SystemMessage } from '../system-message';\nimport {\n StyledWrapperListItem,\n StyledChatContainerContentList,\n StyledChatContainerContentListScroll,\n StyledWrapper,\n StyledLoadMoreContainer,\n ListItem,\n} from './styled';\nimport { defaultProps, listProps, ChatContainerMessagesListProps } from './props';\nimport { useValidateProps } from './config/useValidateProps';\n\nconst getPadding = (hasMoreItems) => {\n const padding = {\n paddingStart: 0,\n paddingEnd: -5,\n };\n if (hasMoreItems === 'top') padding.paddingStart = 42;\n else if (hasMoreItems === 'bottom') padding.paddingEnd = 42;\n return padding;\n};\n\nconst ChatContainerMessagesList = (props: ChatContainerMessagesListProps): JSX.Element => {\n useValidateProps(props, ChatContainerMessagesListWithSchema.toTypescript());\n\n const {\n sendingText,\n bannerPosition,\n sendingMessages,\n messages,\n actionRef,\n onScrollEnds,\n getMoreMessages,\n hasMoreItems,\n isLoading,\n bannerRef,\n } = props;\n const pendingOnScroll = React.useRef(false);\n const loadMoreRef = React.useRef(null);\n const virtualListRef = React.useRef<HTMLDivElement>();\n // estimateSize should not be really required given what was stated on\n // https://github.com/tannerlinsley/react-virtual/issues/23\n const {\n scrollToIndex: vScroll,\n totalSize,\n virtualItems,\n } = useVirtual({\n size: messages.length,\n parentRef: virtualListRef,\n overscan: 15,\n ...getPadding(hasMoreItems),\n estimateSize: React.useCallback(() => 80, []),\n });\n\n const debouncedScroll = React.useMemo(\n () =>\n debounce((): number[] => {\n if (document.visibilityState === 'hidden') {\n pendingOnScroll.current = true;\n return [];\n }\n if (!virtualListRef.current) return [];\n pendingOnScroll.current = false;\n const { bottom, top } = virtualListRef.current?.getBoundingClientRect();\n const list = virtualListRef.current.querySelectorAll(\n '[data-element=\"chat-element-list-item\"]',\n ) as NodeListOf<HTMLDivElement>;\n const indexList = [];\n list.forEach((item: HTMLDivElement) => {\n const { top: itemTop } = item.getBoundingClientRect();\n const itemPadding = 10;\n if (itemTop + itemPadding < bottom && itemTop + itemPadding > top) indexList.push(item.dataset.index);\n });\n if (onScrollEnds) onScrollEnds(indexList);\n return indexList;\n }, 500),\n [onScrollEnds],\n );\n\n const onScrollStop = React.useCallback(debouncedScroll, [debouncedScroll]);\n\n const onlyFocus = React.useCallback((index: number) => {\n setTimeout(() => {\n (virtualListRef.current.querySelector(`[data-index=\"${index}\"]`) as HTMLDivElement).focus();\n }, 300);\n }, []);\n\n const scrollAndFocus = React.useCallback(\n (index: number, b = { align: 'center' }) => {\n vScroll(index, b);\n onlyFocus(index);\n onScrollStop();\n },\n [onScrollStop, onlyFocus, vScroll],\n );\n\n React.useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.scrollToIndex = (a, b = { align: 'center' }) => {\n vScroll(a, b as any);\n onScrollStop();\n };\n actionRef.current.getMessagesInView = onScrollStop;\n actionRef.current.focusToIndex = (a, b = { align: 'center' } as ScrollToOptions) => {\n scrollAndFocus(a, b);\n };\n actionRef.current.focusToIndexWithoutScroll = onlyFocus;\n actionRef.current.focusToList = () => {\n virtualListRef.current?.focus();\n };\n }\n }, [actionRef, onScrollStop, onlyFocus, scrollAndFocus, vScroll]);\n\n const handleKey = React.useCallback(\n (e) => {\n const { key } = e;\n const index = Number(e.currentTarget.dataset.index);\n e.stopPropagation();\n switch (key) {\n case 'ArrowUp':\n e.preventDefault();\n if (index > 0)\n (virtualListRef.current.querySelector(`[data-index=\"${index - 1}\"]`) as HTMLDivElement).focus();\n break;\n case 'ArrowDown':\n e.preventDefault();\n if (index < messages.length - 1) {\n (virtualListRef.current.querySelector(`[data-index=\"${index + 1}\"]`) as HTMLDivElement).focus();\n }\n break;\n case 'Home':\n e.preventDefault();\n scrollAndFocus(0);\n break;\n case 'End':\n e.preventDefault();\n scrollAndFocus(messages.length - 1);\n break;\n case 'Tab':\n e.preventDefault();\n if (hasMoreItems === 'bottom' && !e.shiftKey) {\n loadMoreRef.current?.focus();\n } else if (hasMoreItems === 'top' && e.shiftKey) {\n loadMoreRef.current?.focus();\n } else if (!e.shiftKey) {\n if (bannerPosition) {\n bannerRef.current.focusOnWrapper();\n } else {\n actionRef.current.focusToComposer();\n }\n } else {\n virtualListRef.current?.focus();\n }\n break;\n default:\n break;\n }\n },\n [actionRef, bannerRef, hasMoreItems, messages.length, bannerPosition, scrollAndFocus],\n );\n const handleListKey = React.useCallback(\n (e) => {\n const { key } = e;\n switch (key) {\n case 'ArrowUp':\n e.preventDefault();\n onlyFocus(onScrollStop().shift());\n break;\n case 'ArrowDown':\n e.preventDefault();\n onlyFocus(onScrollStop().pop());\n break;\n case 'Home':\n e.preventDefault();\n scrollAndFocus(0);\n break;\n case 'End':\n e.preventDefault();\n scrollAndFocus(messages.length - 1);\n break;\n case 'Tab':\n if (document.activeElement !== loadMoreRef.current) {\n if (hasMoreItems === 'bottom' && !e.shiftKey) {\n e.preventDefault();\n loadMoreRef.current?.focus();\n } else if (hasMoreItems === 'top' && e.shiftKey) {\n // e.preventDefault();\n // loadMoreRef.current?.focus();\n } else if (!e.shiftKey) {\n e.preventDefault();\n actionRef.current.focusToComposer();\n }\n } else if (!e.shiftKey) {\n e.preventDefault();\n actionRef.current.focusToComposer();\n } else {\n e.preventDefault();\n virtualListRef.current?.focus();\n }\n break;\n default:\n break;\n }\n },\n [actionRef, hasMoreItems, messages.length, onScrollStop, onlyFocus, scrollAndFocus],\n );\n\n const checkPendingOnScroll = React.useCallback(() => {\n if (pendingOnScroll.current === true) onScrollStop();\n }, [onScrollStop]);\n\n React.useEffect(() => {\n let handlerCallback = null;\n const localVirtualRef = virtualListRef.current;\n const onScroll = () => {\n if (handlerCallback) clearTimeout(handlerCallback);\n handlerCallback = setTimeout(onScrollStop, 300);\n };\n if (onScrollEnds) {\n virtualListRef.current.addEventListener('scroll', onScroll);\n }\n document.addEventListener('visibilitychange', checkPendingOnScroll);\n return () => {\n if (handlerCallback) clearTimeout(handlerCallback);\n if (onScrollEnds) localVirtualRef.removeEventListener('scroll', onScroll);\n document.removeEventListener('visibilitychange', checkPendingOnScroll);\n };\n }, [onScrollStop, onScrollEnds, checkPendingOnScroll]);\n\n const render = React.useMemo(\n () =>\n virtualItems.map((virtualItem) => {\n const { index, measureRef, start } = virtualItem;\n const row = messages[index];\n const isSending = sendingMessages && sendingMessages.find((m) => m === row.dsId);\n const style: CSSProperties = {\n position: 'absolute',\n top: 0,\n left: 0,\n transform: `translateY(${start}px)`,\n width: '100%',\n };\n\n return (\n <ListItem\n data-element=\"chat-element-list-item\"\n data-index={index}\n key={`ds-chat-bubble-${index}-${row.dsId}-${row.type}`}\n style={style}\n ref={measureRef}\n tabIndex={0}\n onKeyDown={handleKey}\n role=\"listitem\"\n >\n <StyledWrapperListItem type={row.type}>\n {row.type === BUBBLE_TYPES.SENDER || row.type === BUBBLE_TYPES.RECIPIENT ? (\n // eslint-disable-next-line\n <ChatBubble {...(row as any)} helpMessage={isSending ? sendingText : row.helpMessage} />\n ) : null}\n {row.type === BUBBLE_TYPES.DELIMITER ? <MessageDelimiter {...(row as any)} /> : null}\n {row.type === BUBBLE_TYPES.SYSTEM ? <SystemMessage {...(row as any)} /> : null}\n </StyledWrapperListItem>\n </ListItem>\n );\n }),\n [virtualItems, messages, sendingMessages, handleKey, sendingText],\n );\n\n return (\n <StyledWrapper>\n <StyledChatContainerContentList\n data-testid=\"chat-thread-container\"\n tabIndex={0}\n aria-live=\"polite\"\n ref={virtualListRef}\n role=\"list\"\n onKeyDown={handleListKey}\n >\n <StyledChatContainerContentListScroll height={`${totalSize}px`}>\n {render}\n {!isLoading && hasMoreItems ? (\n <StyledLoadMoreContainer hasMoreItems={hasMoreItems}>\n <DSButton\n labelText=\"Load More\"\n buttonType=\"secondary\"\n onClick={getMoreMessages}\n data-testid=\"ds-chat-load-more-btn\"\n innerRef={loadMoreRef}\n />\n </StyledLoadMoreContainer>\n ) : null}\n </StyledChatContainerContentListScroll>\n </StyledChatContainerContentList>\n </StyledWrapper>\n );\n};\n\nChatContainerMessagesList.propTypes = listProps;\nChatContainerMessagesList.defaultProps = defaultProps;\nconst ChatContainerMessagesListWithSchema = describe(ChatContainerMessagesList);\nChatContainerMessagesListWithSchema.propTypes = listProps;\n\nexport { ChatContainerMessagesList, ChatContainerMessagesListWithSchema };\n"],"names":["getPadding","hasMoreItems","padding","paddingStart","paddingEnd","ChatContainerMessagesList","props","useValidateProps","ChatContainerMessagesListWithSchema","toTypescript","sendingText","bannerPosition","sendingMessages","messages","actionRef","onScrollEnds","getMoreMessages","isLoading","bannerRef","pendingOnScroll","React","useRef","loadMoreRef","virtualListRef","useVirtual","size","length","parentRef","overscan","estimateSize","useCallback","vScroll","scrollToIndex","totalSize","virtualItems","debouncedScroll","useMemo","debounce","document","visibilityState","current","getBoundingClientRect","bottom","top","list","querySelectorAll","indexList","forEach","item","itemTop","itemPadding","push","dataset","index","onScrollStop","onlyFocus","setTimeout","querySelector","focus","scrollAndFocus","b","align","useEffect","a","getMessagesInView","focusToIndex","focusToIndexWithoutScroll","focusToList","handleKey","e","key","Number","currentTarget","stopPropagation","preventDefault","shiftKey","focusOnWrapper","focusToComposer","handleListKey","shift","pop","activeElement","checkPendingOnScroll","handlerCallback","localVirtualRef","onScroll","clearTimeout","addEventListener","removeEventListener","render","map","virtualItem","measureRef","start","row","isSending","find","m","dsId","style","position","left","transform","width","type","BUBBLE_TYPES","SENDER","RECIPIENT","helpMessage","DELIMITER","SYSTEM","propTypes","listProps","defaultProps","describe"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAMA,UAAU,GAAG,SAAbA,UAAa,CAACC,YAAD,EAAkB;AACnC,MAAMC,OAAO,GAAG;AACdC,IAAAA,YAAY,EAAE,CADA;AAEdC,IAAAA,UAAU,EAAE,CAAC;AAFC,GAAhB;AAIA,MAAIH,YAAY,KAAK,KAArB,EAA4BC,OAAO,CAACC,YAAR,GAAuB,EAAvB,CAA5B,KACK,IAAIF,YAAY,KAAK,QAArB,EAA+BC,OAAO,CAACE,UAAR,GAAqB,EAArB;AACpC,SAAOF,OAAP;AACD,CARD;;IAUMG,yBAAyB,GAAG,SAA5BA,yBAA4B,CAACC,KAAD,EAAwD;AACxFC,EAAAA,gBAAgB,CAACD,KAAD,EAAQE,mCAAmC,CAACC,YAApC,EAAR,CAAhB;AAEA,MACEC,WADF,GAWIJ,KAXJ,CACEI,WADF;AAAA,MAEEC,cAFF,GAWIL,KAXJ,CAEEK,cAFF;AAAA,MAGEC,eAHF,GAWIN,KAXJ,CAGEM,eAHF;AAAA,MAIEC,QAJF,GAWIP,KAXJ,CAIEO,QAJF;AAAA,MAKEC,SALF,GAWIR,KAXJ,CAKEQ,SALF;AAAA,MAMEC,YANF,GAWIT,KAXJ,CAMES,YANF;AAAA,MAOEC,eAPF,GAWIV,KAXJ,CAOEU,eAPF;AAAA,MAQEf,YARF,GAWIK,KAXJ,CAQEL,YARF;AAAA,MASEgB,SATF,GAWIX,KAXJ,CASEW,SATF;AAAA,MAUEC,SAVF,GAWIZ,KAXJ,CAUEY,SAVF;AAYA,MAAMC,eAAe,GAAGC,KAAK,CAACC,MAAN,CAAa,KAAb,CAAxB;AACA,MAAMC,WAAW,GAAGF,KAA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,oBAAC,gBAAD,EAAuBf,GAAvB,CAAtC,GAA+E,IALlF,EAMGA,GAAG,CAACU,IAAJ,KAAaC,YAAY,CAACK,MAA1B,gBAAmC,oBAAC,aAAD,EAAoBhB,GAApB,CAAnC,GAAyE,IAN5E,CAVF,CADF;AAqBD,KAjCD,CADF;AAAA,GADa,EAoCb,CAAC5D,YAAD,EAAerB,QAAf,EAAyBD,eAAzB,EAA0CwD,SAA1C,EAAqD1D,WAArD,CApCa,CAAf;AAuCA,sBACE,oBAAC,aAAD,qBACE,oBAAC,8BAAD;AACE,mBAAY,uBADd;AAEE,IAAA,QAAQ,EAAE,CAFZ;AAGE,iBAAU,QAHZ;AAIE,IAAA,GAAG,EAAEa,cAJP;AAKE,IAAA,IAAI,EAAC,MALP;AAME,IAAA,SAAS,EAAEuD;AANb,kBAQE,oBAAC,oCAAD;AAAsC,IAAA,MAAM,YAAK7C,SAAL;AAA5C,KACGwD,MADH,EAEG,CAACxE,SAAD,IAAchB,YAAd,gBACC,oBAAC,uBAAD;AAAyB,IAAA,YAAY,EAAEA;AAAvC,kBACE,oBAAC,QAAD;AACE,IAAA,SAAS,EAAC,WADZ;AAEE,IAAA,UAAU,EAAC,WAFb;AAGE,IAAA,OAAO,EAAEe,eAHX;AAIE,mBAAY,uBAJd;AAKE,IAAA,QAAQ,EAAEM;AALZ,IADF,CADD,GAUG,IAZN,CARF,CADF,CADF;AA2BD;;AAEDjB,yBAAyB,CAAC0G,SAA1B,GAAsCC,SAAtC;AACA3G,yBAAyB,CAAC4G,YAA1B,GAAyCA,YAAzC;IACMzG,mCAAmC,GAAG0G,QAAQ,CAAC7G,yBAAD;AACpDG,mCAAmC,CAACuG,SAApC,GAAgDC,SAAhD;;;;"}
|
package/esm/tests/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BUBBLE_TYPES } from '@elliemae/ds-chat';
|
|
2
2
|
|
|
3
|
-
var getRandomMessages = function getRandomMessages(key) {
|
|
4
|
-
return Array(
|
|
3
|
+
var getRandomMessages = function getRandomMessages(q, key) {
|
|
4
|
+
return Array(q).fill().map(function (v, i) {
|
|
5
5
|
if (i > 5 && i % 22 === 0) {
|
|
6
6
|
return {
|
|
7
7
|
dsId: "".concat(i),
|
|
@@ -37,7 +37,9 @@ var getRandomMessages = function getRandomMessages(key) {
|
|
|
37
37
|
});
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
var
|
|
40
|
+
var loadMsgs = function loadMsgs(q) {
|
|
41
|
+
return getRandomMessages(q, 'item_key');
|
|
42
|
+
};
|
|
41
43
|
|
|
42
|
-
export {
|
|
44
|
+
export { loadMsgs };
|
|
43
45
|
//# sourceMappingURL=utils.js.map
|
package/esm/tests/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../src/tests/utils.tsx"],"sourcesContent":["import { BUBBLE_TYPES } from '@elliemae/ds-chat';\n\nconst getRandomMessages = (key) =>\n Array(
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/tests/utils.tsx"],"sourcesContent":["import { BUBBLE_TYPES } from '@elliemae/ds-chat';\n\nconst getRandomMessages = (q, key) =>\n Array(q)\n .fill()\n .map((v, i) => {\n if (i > 5 && i % 22 === 0) {\n return {\n dsId: `${i}`,\n body: `This is a system message that notifies the user of some important things`,\n type: BUBBLE_TYPES.SYSTEM,\n title: 'System Message',\n time: '4:50 pm',\n };\n }\n if (i > 5 && i % 16 === 0) {\n return {\n dsId: `${i}`,\n type: BUBBLE_TYPES.DELIMITER,\n title: 'Mon, Apr 25, 12:43 PM',\n extraProps: { 'data-testid': 'custom-data-testid' },\n };\n }\n const isSender = i % 2 === 0;\n const chatBubbleType = isSender ? BUBBLE_TYPES.SENDER : BUBBLE_TYPES.RECIPIENT;\n const chatTitle = isSender ? 'Robert Deniro' : 'Al Pacino';\n return {\n dsId: `${i}`,\n body: `Message text ${key} Message text ${i}`,\n type: chatBubbleType,\n title: chatTitle,\n time: '4:50 pm',\n helpMessage: isSender ? 'Delivered' : null,\n };\n });\n\nexport const loadMsgs = (q: number): unknown => getRandomMessages(q, 'item_key');\n"],"names":["getRandomMessages","q","key","Array","fill","map","v","i","dsId","body","type","BUBBLE_TYPES","SYSTEM","title","time","DELIMITER","extraProps","isSender","chatBubbleType","SENDER","RECIPIENT","chatTitle","helpMessage","loadMsgs"],"mappings":";;AAEA,IAAMA,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,CAAD,EAAIC,GAAJ;AAAA,SACxBC,KAAK,CAACF,CAAD,CAAL,CACGG,IADH,GAEGC,GAFH,CAEO,UAACC,CAAD,EAAIC,CAAJ,EAAU;AACb,QAAIA,CAAC,GAAG,CAAJ,IAASA,CAAC,GAAG,EAAJ,KAAW,CAAxB,EAA2B;AACzB,aAAO;AACLC,QAAAA,IAAI,YAAKD,CAAL,CADC;AAELE,QAAAA,IAAI,4EAFC;AAGLC,QAAAA,IAAI,EAAEC,YAAY,CAACC,MAHd;AAILC,QAAAA,KAAK,EAAE,gBAJF;AAKLC,QAAAA,IAAI,EAAE;AALD,OAAP;AAOD;;AACD,QAAIP,CAAC,GAAG,CAAJ,IAASA,CAAC,GAAG,EAAJ,KAAW,CAAxB,EAA2B;AACzB,aAAO;AACLC,QAAAA,IAAI,YAAKD,CAAL,CADC;AAELG,QAAAA,IAAI,EAAEC,YAAY,CAACI,SAFd;AAGLF,QAAAA,KAAK,EAAE,uBAHF;AAILG,QAAAA,UAAU,EAAE;AAAE,yBAAe;AAAjB;AAJP,OAAP;AAMD;;AACD,QAAMC,QAAQ,GAAGV,CAAC,GAAG,CAAJ,KAAU,CAA3B;AACA,QAAMW,cAAc,GAAGD,QAAQ,GAAGN,YAAY,CAACQ,MAAhB,GAAyBR,YAAY,CAACS,SAArE;AACA,QAAMC,SAAS,GAAGJ,QAAQ,GAAG,eAAH,GAAqB,WAA/C;AACA,WAAO;AACLT,MAAAA,IAAI,YAAKD,CAAL,CADC;AAELE,MAAAA,IAAI,yBAAkBP,GAAlB,2BAAsCK,CAAtC,CAFC;AAGLG,MAAAA,IAAI,EAAEQ,cAHD;AAILL,MAAAA,KAAK,EAAEQ,SAJF;AAKLP,MAAAA,IAAI,EAAE,SALD;AAMLQ,MAAAA,WAAW,EAAEL,QAAQ,GAAG,WAAH,GAAiB;AANjC,KAAP;AAQD,GA/BH,CADwB;AAAA,CAA1B;;IAkCaM,QAAQ,GAAG,SAAXA,QAAW,CAACtB,CAAD;AAAA,SAAwBD,iBAAiB,CAACC,CAAD,EAAI,UAAJ,CAAzC;AAAA;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-chat",
|
|
3
|
-
"version": "1.59.
|
|
3
|
+
"version": "1.59.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Ellie Mae - Dim Sum - Chat",
|
|
6
6
|
"main": "cjs/index.js",
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
"directory": "dist"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@elliemae/ds-banner": "1.59.
|
|
20
|
-
"@elliemae/ds-basic": "1.59.
|
|
21
|
-
"@elliemae/ds-button": "1.59.
|
|
22
|
-
"@elliemae/ds-grid": "1.59.
|
|
23
|
-
"@elliemae/ds-icons": "1.59.
|
|
24
|
-
"@elliemae/ds-props-helpers": "1.59.
|
|
25
|
-
"@elliemae/ds-tooltip": "1.59.
|
|
26
|
-
"@elliemae/ds-truncated-tooltip-text": "1.59.
|
|
19
|
+
"@elliemae/ds-banner": "1.59.7",
|
|
20
|
+
"@elliemae/ds-basic": "1.59.7",
|
|
21
|
+
"@elliemae/ds-button": "1.59.7",
|
|
22
|
+
"@elliemae/ds-grid": "1.59.7",
|
|
23
|
+
"@elliemae/ds-icons": "1.59.7",
|
|
24
|
+
"@elliemae/ds-props-helpers": "1.59.7",
|
|
25
|
+
"@elliemae/ds-tooltip": "1.59.7",
|
|
26
|
+
"@elliemae/ds-truncated-tooltip-text": "1.59.7",
|
|
27
27
|
"prop-types": "~15.7.2",
|
|
28
28
|
"react-desc": "^4.1.2",
|
|
29
29
|
"react-virtual": "^2.3.2"
|