@elliemae/ds-chat 1.61.2 → 1.61.6
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/parts/chat-composer/ChatContainerComposer.js +6 -4
- package/cjs/parts/chat-composer/ChatContainerComposer.js.map +1 -1
- package/cjs/parts/chat-container/ChatContainer.js +19 -17
- package/cjs/parts/chat-container/ChatContainer.js.map +1 -1
- package/cjs/parts/chat-container/styled.js +1 -1
- package/cjs/parts/chat-container/styled.js.map +1 -1
- package/cjs/parts/chat-container-messages-list/ChatContainerMessagesList.js +33 -13
- package/cjs/parts/chat-container-messages-list/ChatContainerMessagesList.js.map +1 -1
- package/esm/parts/chat-composer/ChatContainerComposer.js +6 -4
- package/esm/parts/chat-composer/ChatContainerComposer.js.map +1 -1
- package/esm/parts/chat-container/ChatContainer.js +19 -17
- package/esm/parts/chat-container/ChatContainer.js.map +1 -1
- package/esm/parts/chat-container/styled.js +1 -1
- package/esm/parts/chat-container/styled.js.map +1 -1
- package/esm/parts/chat-container-messages-list/ChatContainerMessagesList.js +33 -13
- package/esm/parts/chat-container-messages-list/ChatContainerMessagesList.js.map +1 -1
- package/package.json +9 -9
|
@@ -99,6 +99,9 @@ var ChatComposer = function ChatComposer(props) {
|
|
|
99
99
|
"data-testid": dataTestid
|
|
100
100
|
}, /*#__PURE__*/React__default['default'].createElement(dsGrid.Grid, {
|
|
101
101
|
cols: ['1fr', '24px'],
|
|
102
|
+
style: {
|
|
103
|
+
height: heightProps.height
|
|
104
|
+
},
|
|
102
105
|
justifyContent: "center",
|
|
103
106
|
alignItems: "flex-end",
|
|
104
107
|
gutter: "xxs"
|
|
@@ -139,8 +142,7 @@ var ChatComposer = function ChatComposer(props) {
|
|
|
139
142
|
width: (_input$current = input.current) === null || _input$current === void 0 ? void 0 : _input$current.clientWidth
|
|
140
143
|
},
|
|
141
144
|
onChange: handleChange,
|
|
142
|
-
value: inputValue
|
|
143
|
-
|
|
145
|
+
value: inputValue
|
|
144
146
|
}), /*#__PURE__*/React__default['default'].createElement(dsGrid.Grid, {
|
|
145
147
|
cols: ['1fr', '24px'],
|
|
146
148
|
justifyContent: "flex-end",
|
|
@@ -150,9 +152,9 @@ var ChatComposer = function ChatComposer(props) {
|
|
|
150
152
|
}, /*#__PURE__*/React__default['default'].createElement(parts_chatComposer_styled.StyledCounterArea, {
|
|
151
153
|
hasError: hasError,
|
|
152
154
|
"data-testid": "composer-counter-area"
|
|
153
|
-
}, inputMaxLength && hasError ? /*#__PURE__*/React__default['default'].createElement(parts_chatComposer_styled.StyledCounterErrorA11y, {
|
|
155
|
+
}, inputMaxLength && hasError ? /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(parts_chatComposer_styled.StyledCounterErrorA11y, {
|
|
154
156
|
role: "alert"
|
|
155
|
-
}, maxLengthMessage || "You have entered ".concat(inputLength, " characters and have exceeded the limit by ").concat(inputLength - inputMaxLength, ". Please limit to less than ").concat(inputMaxLength, " characters. ")) : '', inputMaxLength ? " ".concat(inputLength, " / ").concat(inputMaxLength) : ''), /*#__PURE__*/React__default['default'].createElement(dsGrid.Grid, null)));
|
|
157
|
+
}, maxLengthMessage || "You have entered ".concat(inputLength, " characters and have exceeded the limit by ").concat(inputLength - inputMaxLength, ". Please limit to less than ").concat(inputMaxLength, " characters. ")), maxLengthMessage || "Please limit to less than ".concat(inputMaxLength, " characters. ")) : '', inputMaxLength ? " ".concat(inputLength, " / ").concat(inputMaxLength) : ''), /*#__PURE__*/React__default['default'].createElement(dsGrid.Grid, null)));
|
|
156
158
|
};
|
|
157
159
|
|
|
158
160
|
ChatComposer.propTypes = parts_chatComposer_props.composerProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatContainerComposer.js","sources":["../../../../src/parts/chat-composer/ChatContainerComposer.tsx"],"sourcesContent":["/* eslint-disable max-lines */\nimport React from 'react';\nimport { Grid } from '@elliemae/ds-grid';\nimport { describe } from 'react-desc';\nimport { PaperAirplane } from '@elliemae/ds-icons';\nimport {\n StyledChatContainerContentComposer,\n StyledComposerInput,\n StyledComposerButton,\n StyledCounterArea,\n StyledCounterErrorA11y,\n} from './styled';\nimport { useValidateProps } from './config/useValidateProps';\n\nimport { defaultComposerPros, composerProps, ChatComposerProps } from './props';\n\nconst ChatComposer = (props: ChatComposerProps): JSX.Element => {\n useValidateProps(props, ChatComposerWithSchema.toJSON());\n\n const {\n inputValue,\n onChange,\n onResize,\n onSend,\n onFocus,\n onBlur,\n onKeyDown,\n maxHeight = 300,\n placeholder,\n inputMaxLength,\n maxLengthMessage,\n buttonDisabled,\n dataTestid,\n actionRef,\n } = props;\n\n const input = React.useRef<HTMLTextAreaElement>();\n const inputSize = React.useRef<HTMLTextAreaElement>();\n const inputSend = React.useRef<HTMLButtonElement>();\n const [height, setHeight] = React.useState(32);\n const internalMaxHeight = React.useMemo(() => maxHeight - 24, [maxHeight]);\n const [showScroll, setShowScroll] = React.useState(true);\n\n React.useEffect(() => {\n const newHeight =\n inputSize.current?.scrollHeight > internalMaxHeight ? internalMaxHeight : inputSize.current?.scrollHeight;\n onResize(newHeight);\n setHeight(newHeight);\n setShowScroll(inputSize.current?.scrollHeight - inputSize.current?.clientHeight > 5);\n }, [inputValue, internalMaxHeight, onResize]);\n\n React.useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.focusToComposer = () => {\n input.current.focus();\n };\n actionRef.current.focusToSend = () => {\n inputSend.current.focus();\n };\n }\n }, [actionRef]);\n\n const handleChange = React.useCallback(\n (e) => {\n onChange(e.target.value);\n },\n [onChange],\n );\n const heightProps = { height, overflow: showScroll ? 'auto' : 'hidden' };\n\n const inputLength = String(inputValue || '').length;\n const hasError = React.useMemo(() => inputLength > inputMaxLength, [inputLength, inputMaxLength]);\n\n return (\n <StyledChatContainerContentComposer rows={['auto', '15px']} maxHeight={`${maxHeight}px`} data-testid={dataTestid}>\n <Grid cols={['1fr', '24px']} justifyContent=\"center\" alignItems=\"flex-end\" gutter=\"xxs\">\n <StyledComposerInput\n ref={input}\n onChange={handleChange}\n style={{ ...heightProps }}\n value={inputValue}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n aria-label=\"Message to send\"\n data-testid=\"chat-composer-textarea\"\n />\n\n <Grid height=\"32px\" alignItems=\"center\">\n <StyledComposerButton\n buttonType=\"text\"\n icon={<PaperAirplane width={18} height={18} />}\n onClick={onSend}\n size=\"s\"\n disabled={!inputValue || buttonDisabled || hasError}\n data-testid=\"chat-composer-send-button\"\n aria-label=\"Send\"\n innerRef={inputSend}\n />\n </Grid>\n </Grid>\n <StyledComposerInput\n ref={inputSize}\n style={{\n height: 32,\n visibility: 'hidden',\n pointerEvents: 'none',\n position: 'absolute',\n top: 0,\n width: input.current?.clientWidth,\n }}\n onChange={handleChange}\n value={inputValue}\n // maxLength={inputMaxLength}\n />\n <Grid cols={['1fr', '24px']} justifyContent=\"flex-end\" alignItems=\"center\" gutter=\"xxs\" pb=\"xxs\">\n <StyledCounterArea hasError={hasError} data-testid=\"composer-counter-area\">\n {inputMaxLength && hasError ? (\n <StyledCounterErrorA11y role=\"alert\">\n {maxLengthMessage ||\n `You have entered ${inputLength} characters and have exceeded the limit by ${\n inputLength - inputMaxLength\n }. Please limit to less than ${inputMaxLength} characters. `}\n </StyledCounterErrorA11y>\n ) : (\n ''\n )}\n {inputMaxLength ? ` ${inputLength} / ${inputMaxLength}` : ''}\n </StyledCounterArea>\n <Grid />\n </Grid>\n </StyledChatContainerContentComposer>\n );\n};\n\nChatComposer.propTypes = composerProps;\nChatComposer.defaultProps = defaultComposerPros;\nconst ChatComposerWithSchema = describe(ChatComposer);\nChatComposerWithSchema.propTypes = composerProps;\n\nexport { ChatComposer, ChatComposerWithSchema };\n"],"names":["ChatComposer","props","useValidateProps","ChatComposerWithSchema","toJSON","inputValue","onChange","onResize","onSend","onFocus","onBlur","onKeyDown","maxHeight","placeholder","inputMaxLength","maxLengthMessage","buttonDisabled","dataTestid","actionRef","input","React","useRef","inputSize","inputSend","useState","height","setHeight","internalMaxHeight","useMemo","showScroll","setShowScroll","useEffect","newHeight","current","scrollHeight","clientHeight","focusToComposer","focus","focusToSend","handleChange","useCallback","e","target","value","heightProps","overflow","inputLength","String","length","hasError","StyledChatContainerContentComposer","Grid","StyledComposerInput","StyledComposerButton","PaperAirplane","visibility","pointerEvents","position","top","width","clientWidth","StyledCounterArea","StyledCounterErrorA11y","propTypes","composerProps","defaultProps","defaultComposerPros","describe"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgBMA,YAAY,GAAG,SAAfA,YAAe,CAACC,KAAD,EAA2C;AAAA;;AAC9DC,EAAAA,2DAAgB,CAACD,KAAD,EAAQE,sBAAsB,CAACC,MAAvB,EAAR,CAAhB;AAEA,MACEC,UADF,GAeIJ,KAfJ,CACEI,UADF;AAAA,MAEEC,QAFF,GAeIL,KAfJ,CAEEK,QAFF;AAAA,MAGEC,QAHF,GAeIN,KAfJ,CAGEM,QAHF;AAAA,MAIEC,MAJF,GAeIP,KAfJ,CAIEO,MAJF;AAAA,MAKEC,OALF,GAeIR,KAfJ,CAKEQ,OALF;AAAA,MAMEC,MANF,GAeIT,KAfJ,CAMES,MANF;AAAA,MAOEC,SAPF,GAeIV,KAfJ,CAOEU,SAPF;AAAA,yBAeIV,KAfJ,CAQEW,SARF;AAAA,MAQEA,SARF,iCAQc,GARd;AAAA,MASEC,WATF,GAeIZ,KAfJ,CASEY,WATF;AAAA,MAUEC,cAVF,GAeIb,KAfJ,CAUEa,cAVF;AAAA,MAWEC,gBAXF,GAeId,KAfJ,CAWEc,gBAXF;AAAA,MAYEC,cAZF,GAeIf,KAfJ,CAYEe,cAZF;AAAA,MAaEC,UAbF,GAeIhB,KAfJ,CAaEgB,UAbF;AAAA,MAcEC,SAdF,GAeIjB,KAfJ,CAcEiB,SAdF;AAiBA,MAAMC,KAAK,GAAGC,yBAAK,CAACC,MAA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7B,wCAAC0C,gDAAD;AAAwB,IAAA,IAAI,EAAC;AAA7B,KACG/C,gBAAgB,+BACK+B,WADL,wDAEbA,WAAW,GAAGhC,cAFD,yCAGgBA,cAHhB,kBADnB,CADD,GAQC,EATJ,EAWGA,cAAc,cAAOgC,WAAP,gBAAwBhC,cAAxB,IAA2C,EAX5D,CADF,eAcEM,wCAAC+B,WAAD,OAdF,CA1CF,CADF;AA6DD;;AAEDnD,YAAY,CAAC+D,SAAb,GAAyBC,sCAAzB;AACAhE,YAAY,CAACiE,YAAb,GAA4BC,4CAA5B;IACM/D,sBAAsB,GAAGgE,kBAAQ,CAACnE,YAAD;AACvCG,sBAAsB,CAAC4D,SAAvB,GAAmCC,sCAAnC;;;;;"}
|
|
1
|
+
{"version":3,"file":"ChatContainerComposer.js","sources":["../../../../src/parts/chat-composer/ChatContainerComposer.tsx"],"sourcesContent":["/* eslint-disable max-lines */\nimport React from 'react';\nimport { Grid } from '@elliemae/ds-grid';\nimport { describe } from 'react-desc';\nimport { PaperAirplane } from '@elliemae/ds-icons';\nimport {\n StyledChatContainerContentComposer,\n StyledComposerInput,\n StyledComposerButton,\n StyledCounterArea,\n StyledCounterErrorA11y,\n} from './styled';\nimport { useValidateProps } from './config/useValidateProps';\n\nimport { defaultComposerPros, composerProps, ChatComposerProps } from './props';\n\nconst ChatComposer = (props: ChatComposerProps): JSX.Element => {\n useValidateProps(props, ChatComposerWithSchema.toJSON());\n\n const {\n inputValue,\n onChange,\n onResize,\n onSend,\n onFocus,\n onBlur,\n onKeyDown,\n maxHeight = 300,\n placeholder,\n inputMaxLength,\n maxLengthMessage,\n buttonDisabled,\n dataTestid,\n actionRef,\n } = props;\n\n const input = React.useRef<HTMLTextAreaElement>();\n const inputSize = React.useRef<HTMLTextAreaElement>();\n const inputSend = React.useRef<HTMLButtonElement>();\n const [height, setHeight] = React.useState(32);\n const internalMaxHeight = React.useMemo(() => maxHeight - 24, [maxHeight]);\n const [showScroll, setShowScroll] = React.useState(true);\n\n React.useEffect(() => {\n const newHeight =\n inputSize.current?.scrollHeight > internalMaxHeight ? internalMaxHeight : inputSize.current?.scrollHeight;\n onResize(newHeight);\n setHeight(newHeight);\n setShowScroll(inputSize.current?.scrollHeight - inputSize.current?.clientHeight > 5);\n }, [inputValue, internalMaxHeight, onResize]);\n\n React.useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.focusToComposer = () => {\n input.current.focus();\n };\n actionRef.current.focusToSend = () => {\n inputSend.current.focus();\n };\n }\n }, [actionRef]);\n\n const handleChange = React.useCallback(\n (e) => {\n onChange(e.target.value);\n },\n [onChange],\n );\n const heightProps = { height, overflow: showScroll ? 'auto' : 'hidden' };\n\n const inputLength = String(inputValue || '').length;\n const hasError = React.useMemo(() => inputLength > inputMaxLength, [inputLength, inputMaxLength]);\n return (\n <StyledChatContainerContentComposer rows={['auto', '15px']} maxHeight={`${maxHeight}px`} data-testid={dataTestid}>\n <Grid\n cols={['1fr', '24px']}\n style={{ height: heightProps.height }}\n justifyContent=\"center\"\n alignItems=\"flex-end\"\n gutter=\"xxs\"\n >\n <StyledComposerInput\n ref={input}\n onChange={handleChange}\n style={{ ...heightProps }}\n value={inputValue}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n aria-label=\"Message to send\"\n data-testid=\"chat-composer-textarea\"\n />\n\n <Grid height=\"32px\" alignItems=\"center\">\n <StyledComposerButton\n buttonType=\"text\"\n icon={<PaperAirplane width={18} height={18} />}\n onClick={onSend}\n size=\"s\"\n disabled={!inputValue || buttonDisabled || hasError}\n data-testid=\"chat-composer-send-button\"\n aria-label=\"Send\"\n innerRef={inputSend}\n />\n </Grid>\n </Grid>\n <StyledComposerInput\n ref={inputSize}\n style={{\n height: 32,\n visibility: 'hidden',\n pointerEvents: 'none',\n position: 'absolute',\n top: 0,\n width: input.current?.clientWidth,\n }}\n onChange={handleChange}\n value={inputValue}\n />\n <Grid cols={['1fr', '24px']} justifyContent=\"flex-end\" alignItems=\"center\" gutter=\"xxs\" pb=\"xxs\">\n <StyledCounterArea hasError={hasError} data-testid=\"composer-counter-area\">\n {inputMaxLength && hasError ? (\n <>\n <StyledCounterErrorA11y role=\"alert\">\n {maxLengthMessage ||\n `You have entered ${inputLength} characters and have exceeded the limit by ${\n inputLength - inputMaxLength\n }. Please limit to less than ${inputMaxLength} characters. `}\n </StyledCounterErrorA11y>\n {maxLengthMessage || `Please limit to less than ${inputMaxLength} characters. `}\n </>\n ) : (\n ''\n )}\n {inputMaxLength ? ` ${inputLength} / ${inputMaxLength}` : ''}\n </StyledCounterArea>\n <Grid />\n </Grid>\n </StyledChatContainerContentComposer>\n );\n};\n\nChatComposer.propTypes = composerProps;\nChatComposer.defaultProps = defaultComposerPros;\nconst ChatComposerWithSchema = describe(ChatComposer);\nChatComposerWithSchema.propTypes = composerProps;\n\nexport { ChatComposer, ChatComposerWithSchema };\n"],"names":["ChatComposer","props","useValidateProps","ChatComposerWithSchema","toJSON","inputValue","onChange","onResize","onSend","onFocus","onBlur","onKeyDown","maxHeight","placeholder","inputMaxLength","maxLengthMessage","buttonDisabled","dataTestid","actionRef","input","React","useRef","inputSize","inputSend","useState","height","setHeight","internalMaxHeight","useMemo","showScroll","setShowScroll","useEffect","newHeight","current","scrollHeight","clientHeight","focusToComposer","focus","focusToSend","handleChange","useCallback","e","target","value","heightProps","overflow","inputLength","String","length","hasError","StyledChatContainerContentComposer","Grid","StyledComposerInput","StyledComposerButton","PaperAirplane","visibility","pointerEvents","position","top","width","clientWidth","StyledCounterArea","StyledCounterErrorA11y","propTypes","composerProps","defaultProps","defaultComposerPros","describe"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgBMA,YAAY,GAAG,SAAfA,YAAe,CAACC,KAAD,EAA2C;AAAA;;AAC9DC,EAAAA,2DAAgB,CAACD,KAAD,EAAQE,sBAAsB,CAACC,MAAvB,EAAR,CAAhB;AAEA,MACEC,UADF,GAeIJ,KAfJ,CACEI,UADF;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AnC;;;;;"}
|
|
@@ -78,18 +78,16 @@ var ChatContainer = function ChatContainer(props) {
|
|
|
78
78
|
});
|
|
79
79
|
var onResize = React__default['default'].useCallback(function (height) {
|
|
80
80
|
if (onComposerResize) onComposerResize(height);
|
|
81
|
-
|
|
82
|
-
if (height > 30) {
|
|
83
|
-
/*
|
|
81
|
+
/*
|
|
84
82
|
setTimeout is used to equal the animation duration from the
|
|
85
83
|
composer text area when increase its size
|
|
86
84
|
*/
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
}
|
|
85
|
+
|
|
86
|
+
setTimeout(function () {
|
|
87
|
+
actionRef.current.scrollToIndex(messagesListProps.messages.length - 1, {
|
|
88
|
+
align: 'start'
|
|
89
|
+
});
|
|
90
|
+
}, 50);
|
|
93
91
|
}, [onComposerResize, messagesListProps.messages, actionRef]);
|
|
94
92
|
var Container = device === 'desktop' ? parts_chatContainer_styled.StyledChatContainerContent : parts_chatContainer_styled.MobileStyledChatContainerContent;
|
|
95
93
|
var handleTabs = React__default['default'].useCallback(function (e) {
|
|
@@ -97,17 +95,21 @@ var ChatContainer = function ChatContainer(props) {
|
|
|
97
95
|
var ref = actionRef || listRef;
|
|
98
96
|
|
|
99
97
|
if (e.shiftKey && e.key === 'Tab') {
|
|
100
|
-
|
|
98
|
+
if (messagesListProps.messages.length > 0) {
|
|
99
|
+
e.preventDefault();
|
|
100
|
+
|
|
101
|
+
if (['top', 'bottom'].includes(bannerPosition)) {
|
|
102
|
+
bannerRef.current.focusOnWrapper();
|
|
103
|
+
} else {
|
|
104
|
+
var _ref$current;
|
|
101
105
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
var last = ref.current.getMessagesInView().pop();
|
|
106
|
-
ref.current.focusToIndexWithoutScroll(last);
|
|
106
|
+
var last = ref.current.getMessagesInView().pop();
|
|
107
|
+
(_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focusToIndexWithoutScroll(last);
|
|
108
|
+
}
|
|
107
109
|
}
|
|
108
110
|
}
|
|
109
111
|
}
|
|
110
|
-
}, [actionRef, onComposerKeyDown, bannerPosition]); // Map actions
|
|
112
|
+
}, [actionRef, onComposerKeyDown, bannerPosition, messagesListProps.messages.length]); // Map actions
|
|
111
113
|
|
|
112
114
|
React__default['default'].useEffect(function () {
|
|
113
115
|
if (actionRef && actionRef.current) {
|
|
@@ -163,7 +165,7 @@ var ChatContainer = function ChatContainer(props) {
|
|
|
163
165
|
"data-testid": "ds-chat-loading-indicator"
|
|
164
166
|
}, /*#__PURE__*/React__default['default'].createElement(DSIndeterminateProgressIndicator__default['default'], {
|
|
165
167
|
processing: true,
|
|
166
|
-
title:
|
|
168
|
+
title: sendingText,
|
|
167
169
|
lineOnly: true
|
|
168
170
|
})) : null), /*#__PURE__*/React__default['default'].createElement(parts_chatComposer_ChatContainerComposer.ChatComposer, _extends__default['default']({}, composerProps, {
|
|
169
171
|
onKeyDown: handleTabs,
|
|
@@ -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 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 (height > 30) {\n /*\n setTimeout is used to equal the animation duration from the \n composer text area when increase its size\n */\n setTimeout(() => {\n actionRef.current.scrollToIndex(messagesListProps.messages.length - 1, {\n align: 'start',\n });\n }, 50);\n }\n },\n [onComposerResize, messagesListProps.messages, actionRef],\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","device","isLoading","hasMoreItems","getMoreMessages","ariaLabel","bannerRef","React","useRef","focusOnWrapper","noop","focusOnLink","containerRef","listRef","scrollToIndex","useCallback","height","setTimeout","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,GAcIJ,KAdJ,CACEI,WADF;AAAA,MAEEC,eAFF,GAcIL,KAdJ,CAEEK,eAFF;AAAA,MAGEC,cAHF,GAcIN,KAdJ,CAGEM,cAHF;AAAA,MAIEC,WAJF,GAcIP,KAdJ,CAIEO,WAJF;AAAA,MAKEC,iBALF,GAcIR,KAdJ,CAKEQ,iBALF;AAAA,MAMEC,aANF,GAcIT,KAdJ,CAMES,aANF;AAAA,6BAcIT,KAdJ,CAOES,aAPF;AAAA,MAO6BC,gBAP7B,wBAOmBC,QAPnB;AAAA,MAO0DC,iBAP1D,wBAO+CC,SAP/C;AAAA,MAQEC,SARF,GAcId,KAdJ,CAQEc,SARF;AAAA,MASEC,MATF,GAcIf,KAdJ,CASEe,MATF;AAAA,MAUEC,SAVF,GAcIhB,KAdJ,CAUEgB,SAVF;AAAA,MAWEC,YAXF,GAcIjB,KAdJ,CAWEiB,YAXF;AAAA,MAYEC,eAZF,GAcIlB,KAdJ,CAYEkB,eAZF;AAAA,MAaEC,SAbF,GAcInB,KAdJ,CAaEmB,SAbF;AAeA,MAAMC,SAAS,GAAGC,yBAAK,CAACC,MAAN,CAAa;AAAEC,IAAAA,cAAc,EAAEC,WAAlB;AAAwBC,IAAAA,WAAW,EAAED;AAArC,GAAb,CAAlB;AACA,MAAME,YAAY,GAAGL,yBAAK,CAACC,MAAN,EAArB;AACA,MAAMK,OAAO,GAAGN,yBAAK,CAACC,MAAN,CAAa;AAAEM,IAAAA,aAAa,EAAEJ;AAAjB,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Ad,GAA6BA,sCAA7B;IACMtE,uBAAuB,GAAGuE,kBAAQ,CAAC1E,aAAD;AACxCG,uBAAuB,CAACoE,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 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 /*\n setTimeout is used to equal the animation duration from the \n composer text area when increase its size\n */\n setTimeout(() => {\n actionRef.current.scrollToIndex(messagesListProps.messages.length - 1, {\n align: 'start',\n });\n }, 50);\n },\n [onComposerResize, messagesListProps.messages, actionRef],\n );\n const Container = device === 'desktop' ? StyledChatContainerContent : MobileStyledChatContainerContent;\n const handleTabs = React.useCallback(\n (e: React.KeyboardEvent) => {\n if (onComposerKeyDown) onComposerKeyDown(e);\n else {\n const ref = actionRef || listRef;\n if (e.shiftKey && e.key === 'Tab') {\n if (messagesListProps.messages.length > 0) {\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 },\n [actionRef, onComposerKeyDown, bannerPosition, messagesListProps.messages.length],\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={sendingText} 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","device","isLoading","hasMoreItems","getMoreMessages","ariaLabel","bannerRef","React","useRef","focusOnWrapper","noop","focusOnLink","containerRef","listRef","scrollToIndex","useCallback","height","setTimeout","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,GAcIJ,KAdJ,CACEI,WADF;AAAA,MAEEC,eAFF,GAcIL,KAdJ,CAEEK,eAFF;AAAA,MAGEC,cAHF,GAcIN,KAdJ,CAGEM,cAHF;AAAA,MAIEC,WAJF,GAcIP,KAdJ,CAIEO,WAJF;AAAA,MA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D;AAFX,KAJd;AAQE,IAAA,OAAO,EAAExD,WAAW,CAACyD,OARvB;AASE,IAAA,MAAM,MATR;AAUE,IAAA,IAAI,EAAEzD,WAAW,CAAC0D,IAAZ,IAAoBC,qBAAY,CAACC,IAVzC;AAWE,IAAA,SAAS,EAAE/C;AAXb,IADF,CAjBF,EAgCGf,eAAe,IAAIA,eAAe,CAAC6B,MAAhB,GAAyB,CAA5C,gBACCb,wCAACmC,mDAAD;AAA0B,IAAA,SAAS,EAAC,QAApC;AAA6C,IAAA,MAAM,MAAnD;AAAoD,mBAAY;AAAhE,kBACEnC,wCAACoC,oDAAD;AAAkC,IAAA,UAAU,MAA5C;AAA6C,IAAA,KAAK,EAAErD,WAApD;AAAiE,IAAA,QAAQ;AAAzE,IADF,CADD,GAIG,IApCN,CADF,eAuCEiB,wCAAC+C,qDAAD,mCACM3D,aADN;AAEE,IAAA,SAAS,EAAE8B,UAFb;AAGE,IAAA,QAAQ,EAAE5B,QAHZ;AAIE,IAAA,SAAS,EAAE,CAAC,0BAAAe,YAAY,CAACM,OAAb,gFAAsBqC,YAAtB,KAAsC,CAAvC,IAA4C,CAJzD;AAKE,IAAA,SAAS,EAAEvD,SAAS,IAAIa;AAL1B,KAvCF,CADF;AAiDD;;AAED5B,aAAa,CAACuE,SAAd,GAA0BC,wCAA1B;AACAxE,aAAa,CAACyE,YAAd,GAA6BA,sCAA7B;IACMtE,uBAAuB,GAAGuE,kBAAQ,CAAC1E,aAAD;AACxCG,uBAAuB,CAACoE,SAAxB,GAAoCC,wCAApC;;;;;"}
|
|
@@ -30,7 +30,7 @@ var StyledIndicatorContainer = /*#__PURE__*/styled__default['default'].div.withC
|
|
|
30
30
|
}, function (props) {
|
|
31
31
|
return props.theme.colors.neutral['000'];
|
|
32
32
|
}, function (props) {
|
|
33
|
-
return props.isLoading === 'top' ? "\n top: -41px;\n transform: translate(0, 41px);\n visibility: visible;\n pointer-events: auto
|
|
33
|
+
return props.isLoading === 'top' ? "\n top: -41px;\n transform: translate(0, 41px);\n visibility: visible;\n pointer-events: auto;\n " : '';
|
|
34
34
|
}, function (props) {
|
|
35
35
|
return props.isLoading === 'bottom' ? "\n bottom: -41px;\n transform: translate(0, -41px);\n visibility: visible;\n pointer-events: auto;\n " : '';
|
|
36
36
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.js","sources":["../../../../src/parts/chat-container/styled.ts"],"sourcesContent":["import styled from 'styled-components';\nimport { Grid } from '@elliemae/ds-grid';\nimport { StyledTitleRightBubble, StyledTitleLeftBubble, StyleBodyWrapper } from '../bubble/styled';\nimport { StyledComposerInput } from '../chat-composer/styled';\nimport { Wrapper, Title, Time, Message } from '../system-message/style';\nexport const CONTAINER_WIDTH = 300;\n\nexport const StyledChatContainerContent = styled(Grid)`\n height: 100%;\n min-width: ${CONTAINER_WIDTH}px;\n overflow: hidden;\n background: ${(props) => props.theme.colors.neutral['050']};\n position: relative;\n`;\nexport const StyledIndicatorContainer = styled.div<{\n isLoading?: 'top' | 'bottom';\n linear?: boolean;\n}>`\n transition: 0.4s ease-in-out;\n position: absolute;\n visibility: hidden;\n pointer-events: none;\n width: 100%;\n padding: 0 ${(props) => (!props.linear ? props.theme.space.xxs : 0)};\n left: 0;\n right: 0;\n background: ${(props) => props.theme.colors.neutral['000']};\n ${(props) =>\n props.isLoading === 'top'\n ? `\n top: -41px;\n transform: translate(0, 41px);\n visibility: visible;\n pointer-events: auto
|
|
1
|
+
{"version":3,"file":"styled.js","sources":["../../../../src/parts/chat-container/styled.ts"],"sourcesContent":["import styled from 'styled-components';\nimport { Grid } from '@elliemae/ds-grid';\nimport { StyledTitleRightBubble, StyledTitleLeftBubble, StyleBodyWrapper } from '../bubble/styled';\nimport { StyledComposerInput } from '../chat-composer/styled';\nimport { Wrapper, Title, Time, Message } from '../system-message/style';\nexport const CONTAINER_WIDTH = 300;\n\nexport const StyledChatContainerContent = styled(Grid)`\n height: 100%;\n min-width: ${CONTAINER_WIDTH}px;\n overflow: hidden;\n background: ${(props) => props.theme.colors.neutral['050']};\n position: relative;\n`;\nexport const StyledIndicatorContainer = styled.div<{\n isLoading?: 'top' | 'bottom';\n linear?: boolean;\n}>`\n transition: 0.4s ease-in-out;\n position: absolute;\n visibility: hidden;\n pointer-events: none;\n width: 100%;\n padding: 0 ${(props) => (!props.linear ? props.theme.space.xxs : 0)};\n left: 0;\n right: 0;\n background: ${(props) => props.theme.colors.neutral['000']};\n ${(props) =>\n props.isLoading === 'top'\n ? `\n top: -41px;\n transform: translate(0, 41px);\n visibility: visible;\n pointer-events: auto;\n `\n : ''}\n ${(props) =>\n props.isLoading === 'bottom'\n ? `\n bottom: -41px;\n transform: translate(0, -41px);\n visibility: visible;\n pointer-events: auto;\n `\n : ''}\n\n & div,a {\n font-size: 13px;\n }\n`;\n\nexport const MobileStyledChatContainerContent = styled(StyledChatContainerContent)`\n ${StyledTitleLeftBubble},\n ${StyleBodyWrapper} {\n font-size: 16px;\n }\n\n ${StyledTitleRightBubble} {\n font-size: 13px;\n }\n\n ${Wrapper} {\n background-color: #fff;\n box-shadow: -0 1px 3px rgba(53, 60, 70, 0.8);\n }\n\n ${Title},\n ${Message} {\n font-size: 16px;\n text-align: left;\n }\n\n ${Time} {\n font-size: 13px;\n }\n\n ${StyledComposerInput} {\n font-size: 16px;\n }\n\n ${StyledIndicatorContainer} {\n font-size: 16px;\n }\n`;\n"],"names":["CONTAINER_WIDTH","StyledChatContainerContent","styled","Grid","props","theme","colors","neutral","StyledIndicatorContainer","div","linear","space","xxs","isLoading","MobileStyledChatContainerContent","StyledTitleLeftBubble","StyleBodyWrapper","StyledTitleRightBubble","Wrapper","Title","Message","Time","StyledComposerInput"],"mappings":";;;;;;;;;;;;;;;;;;;IAKaA,eAAe,GAAG;IAElBC,0BAA0B,gBAAGC,0BAAM,CAACC,WAAD,CAAT;AAAA;AAAA,wFAExBH,eAFwB,EAIvB,UAACI,KAAD;AAAA,SAAWA,KAAK,CAACC,KAAN,CAAYC,MAAZ,CAAmBC,OAAnB,CAA2B,KAA3B,CAAX;AAAA,CAJuB;IAO1BC,wBAAwB,gBAAGN,0BAAM,CAACO,GAAV;AAAA;AAAA,wLAStB,UAACL,KAAD;AAAA,SAAY,CAACA,KAAK,CAACM,MAAP,GAAgBN,KAAK,CAACC,KAAN,CAAYM,KAAZ,CAAkBC,GAAlC,GAAwC,CAApD;AAAA,CATsB,EAYrB,UAACR,KAAD;AAAA,SAAWA,KAAK,CAACC,KAAN,CAAYC,MAAZ,CAAmBC,OAAnB,CAA2B,KAA3B,CAAX;AAAA,CAZqB,EAajC,UAACH,KAAD;AAAA,SACAA,KAAK,CAACS,SAAN,KAAoB,KAApB,8GAOI,EARJ;AAAA,CAbiC,EAsBjC,UAACT,KAAD;AAAA,SACAA,KAAK,CAACS,SAAN,KAAoB,QAApB,kHAOI,EARJ;AAAA,CAtBiC;IAqCxBC,gCAAgC,gBAAGZ,0BAAM,CAACD,0BAAD,CAAT;AAAA;AAAA,sOACzCc,yCADyC,EAEzCC,oCAFyC,EAMzCC,0CANyC,EAUzCC,iCAVyC,EAezCC,+BAfyC,EAgBzCC,iCAhByC,EAqBzCC,8BArByC,EAyBzCC,6CAzByC,EA6BzCd,wBA7ByC;;;;;;;"}
|
|
@@ -171,7 +171,17 @@ var ChatContainerMessagesList = function ChatContainerMessagesList(props) {
|
|
|
171
171
|
switch (key) {
|
|
172
172
|
case 'ArrowUp':
|
|
173
173
|
e.preventDefault();
|
|
174
|
-
|
|
174
|
+
|
|
175
|
+
if (index > 0) {
|
|
176
|
+
var _virtualListRef$curre4;
|
|
177
|
+
|
|
178
|
+
((_virtualListRef$curre4 = virtualListRef.current) === null || _virtualListRef$curre4 === void 0 ? void 0 : _virtualListRef$curre4.querySelector("[data-index=\"".concat(index - 1, "\"]"))).focus();
|
|
179
|
+
} else if (hasMoreItems === 'top') {
|
|
180
|
+
var _loadMoreRef$current;
|
|
181
|
+
|
|
182
|
+
(_loadMoreRef$current = loadMoreRef.current) === null || _loadMoreRef$current === void 0 ? void 0 : _loadMoreRef$current.focus();
|
|
183
|
+
}
|
|
184
|
+
|
|
175
185
|
break;
|
|
176
186
|
|
|
177
187
|
case 'ArrowDown':
|
|
@@ -195,25 +205,25 @@ var ChatContainerMessagesList = function ChatContainerMessagesList(props) {
|
|
|
195
205
|
|
|
196
206
|
case 'Tab':
|
|
197
207
|
if (hasMoreItems === 'bottom' && !e.shiftKey) {
|
|
198
|
-
var _loadMoreRef$
|
|
208
|
+
var _loadMoreRef$current2;
|
|
199
209
|
|
|
200
210
|
e.preventDefault();
|
|
201
|
-
(_loadMoreRef$
|
|
211
|
+
(_loadMoreRef$current2 = loadMoreRef.current) === null || _loadMoreRef$current2 === void 0 ? void 0 : _loadMoreRef$current2.focus();
|
|
202
212
|
} else if (hasMoreItems === 'top' && e.shiftKey) {
|
|
203
|
-
var _loadMoreRef$
|
|
213
|
+
var _loadMoreRef$current3;
|
|
204
214
|
|
|
205
215
|
e.preventDefault();
|
|
206
|
-
(_loadMoreRef$
|
|
216
|
+
(_loadMoreRef$current3 = loadMoreRef.current) === null || _loadMoreRef$current3 === void 0 ? void 0 : _loadMoreRef$current3.focus();
|
|
207
217
|
} else if (!e.shiftKey) {
|
|
208
218
|
if (bannerPosition) {
|
|
209
219
|
e.preventDefault();
|
|
210
220
|
bannerRef.current.focusOnWrapper();
|
|
211
221
|
}
|
|
212
222
|
} else {
|
|
213
|
-
var _virtualListRef$
|
|
223
|
+
var _virtualListRef$curre5;
|
|
214
224
|
|
|
215
225
|
e.preventDefault();
|
|
216
|
-
(_virtualListRef$
|
|
226
|
+
(_virtualListRef$curre5 = virtualListRef.current) === null || _virtualListRef$curre5 === void 0 ? void 0 : _virtualListRef$curre5.focus();
|
|
217
227
|
}
|
|
218
228
|
|
|
219
229
|
break;
|
|
@@ -225,12 +235,22 @@ var ChatContainerMessagesList = function ChatContainerMessagesList(props) {
|
|
|
225
235
|
switch (key) {
|
|
226
236
|
case 'ArrowUp':
|
|
227
237
|
e.preventDefault();
|
|
228
|
-
|
|
238
|
+
|
|
239
|
+
if (document.activeElement !== loadMoreRef.current) {
|
|
240
|
+
onlyFocus(onScrollStop().shift());
|
|
241
|
+
}
|
|
242
|
+
|
|
229
243
|
break;
|
|
230
244
|
|
|
231
245
|
case 'ArrowDown':
|
|
232
246
|
e.preventDefault();
|
|
233
|
-
|
|
247
|
+
|
|
248
|
+
if (document.activeElement === loadMoreRef.current) {
|
|
249
|
+
virtualListRef.current.querySelector("[data-index=\"0\"]").focus();
|
|
250
|
+
} else {
|
|
251
|
+
onlyFocus(onScrollStop().pop());
|
|
252
|
+
}
|
|
253
|
+
|
|
234
254
|
break;
|
|
235
255
|
|
|
236
256
|
case 'Home':
|
|
@@ -246,10 +266,10 @@ var ChatContainerMessagesList = function ChatContainerMessagesList(props) {
|
|
|
246
266
|
case 'Tab':
|
|
247
267
|
if (document.activeElement !== loadMoreRef.current) {
|
|
248
268
|
if (hasMoreItems === 'bottom' && !e.shiftKey) {
|
|
249
|
-
var _loadMoreRef$
|
|
269
|
+
var _loadMoreRef$current4;
|
|
250
270
|
|
|
251
271
|
e.preventDefault();
|
|
252
|
-
(_loadMoreRef$
|
|
272
|
+
(_loadMoreRef$current4 = loadMoreRef.current) === null || _loadMoreRef$current4 === void 0 ? void 0 : _loadMoreRef$current4.focus();
|
|
253
273
|
} else if (hasMoreItems === 'top' && e.shiftKey) ; else if (!e.shiftKey) {
|
|
254
274
|
e.preventDefault();
|
|
255
275
|
actionRef.current.focusToComposer();
|
|
@@ -258,10 +278,10 @@ var ChatContainerMessagesList = function ChatContainerMessagesList(props) {
|
|
|
258
278
|
e.preventDefault();
|
|
259
279
|
actionRef.current.focusToComposer();
|
|
260
280
|
} else {
|
|
261
|
-
var _virtualListRef$
|
|
281
|
+
var _virtualListRef$curre6;
|
|
262
282
|
|
|
263
283
|
e.preventDefault();
|
|
264
|
-
(_virtualListRef$
|
|
284
|
+
(_virtualListRef$curre6 = virtualListRef.current) === null || _virtualListRef$curre6 === void 0 ? void 0 : _virtualListRef$curre6.focus();
|
|
265
285
|
}
|
|
266
286
|
|
|
267
287
|
break;
|
|
@@ -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\ntype getPaddingT = {\n hasMoreItems: string | undefined;\n bannerPosition: string | undefined;\n isLoading: string | undefined;\n};\nconst getPadding = ({ hasMoreItems, bannerPosition, isLoading }: getPaddingT) => {\n const padding = {\n paddingStart: 0,\n paddingEnd: -5,\n };\n if ([hasMoreItems, bannerPosition, isLoading].some((item) => item === 'top')) padding.paddingStart = 42;\n else if ([hasMoreItems, bannerPosition, isLoading].some((item) => item === '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, bannerPosition, isLoading }),\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 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 if (bannerPosition) {\n e.preventDefault();\n bannerRef.current.focusOnWrapper();\n }\n } else {\n e.preventDefault();\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={-1}\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 aria-relevant=\"additions\"\n ref={virtualListRef}\n role=\"list\"\n onKeyDown={handleListKey}\n >\n <StyledChatContainerContentListScroll height={`${totalSize}px`}>\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 {render}\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","bannerPosition","isLoading","padding","paddingStart","paddingEnd","some","item","ChatContainerMessagesList","props","useValidateProps","ChatContainerMessagesListWithSchema","toTypescript","sendingText","sendingMessages","messages","actionRef","onScrollEnds","getMoreMessages","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","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","handleListKey","shift","pop","activeElement","focusToComposer","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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,IAAMA,UAAU,GAAG,SAAbA,UAAa,OAA8D;AAAA,MAA3DC,YAA2D,QAA3DA,YAA2D;AAAA,MAA7CC,cAA6C,QAA7CA,cAA6C;AAAA,MAA7BC,SAA6B,QAA7BA,SAA6B;AAC/E,MAAMC,OAAO,GAAG;AACdC,IAAAA,YAAY,EAAE,CADA;AAEdC,IAAAA,UAAU,EAAE,CAAC;AAFC,GAAhB;AAIA,MAAI,CAACL,YAAD,EAAeC,cAAf,EAA+BC,SAA/B,EAA0CI,IAA1C,CAA+C,UAACC,IAAD;AAAA,WAAUA,IAAI,KAAK,KAAnB;AAAA,GAA/C,CAAJ,EAA8EJ,OAAO,CAACC,YAAR,GAAuB,EAAvB,CAA9E,KACK,IAAI,CAACJ,YAAD,EAAeC,cAAf,EAA+BC,SAA/B,EAA0CI,IAA1C,CAA+C,UAACC,IAAD;AAAA,WAAUA,IAAI,KAAK,QAAnB;AAAA,GAA/C,CAAJ,EAAiFJ,OAAO,CAACE,UAAR,GAAqB,EAArB;AACtF,SAAOF,OAAP;AACD,CARD;;IAUMK,yBAAyB,GAAG,SAA5BA,yBAA4B,CAACC,KAAD,EAAwD;AACxFC,EAAAA,wEAAgB,CAACD,KAAD,EAAQE,mCAAmC,CAACC,YAApC,EAAR,CAAhB;AAEA,MACEC,WADF,GAWIJ,KAXJ,CACEI,W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,wCAACiG,2EAAD;AAAsC,IAAA,MAAM,YAAKpF,SAAL;AAA5C,KACG,CAAChC,SAAD,IAAcF,YAAd,gBACCqB,wCAACkG,8DAAD;AAAyB,IAAA,YAAY,EAAEvH;AAAvC,kBACEqB,wCAACmG,4BAAD;AACE,IAAA,SAAS,EAAC,WADZ;AAEE,IAAA,UAAU,EAAC,WAFb;AAGE,IAAA,OAAO,EAAEtG,eAHX;AAIE,mBAAY,uBAJd;AAKE,IAAA,QAAQ,EAAEK;AALZ,IADF,CADD,GAUG,IAXN,EAYGkE,MAZH,CATF,CADF,CADF;AA4BD;;AAEDjF,yBAAyB,CAACiH,SAA1B,GAAsCC,+CAAtC;AACAlH,yBAAyB,CAACmH,YAA1B,GAAyCA,kDAAzC;IACMhH,mCAAmC,GAAGiH,kBAAQ,CAACpH,yBAAD;AACpDG,mCAAmC,CAAC8G,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\ntype getPaddingT = {\n hasMoreItems: string | undefined;\n bannerPosition: string | undefined;\n isLoading: string | undefined;\n};\nconst getPadding = ({ hasMoreItems, bannerPosition, isLoading }: getPaddingT) => {\n const padding = {\n paddingStart: 0,\n paddingEnd: -5,\n };\n if ([hasMoreItems, bannerPosition, isLoading].some((item) => item === 'top')) padding.paddingStart = 42;\n else if ([hasMoreItems, bannerPosition, isLoading].some((item) => item === '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, bannerPosition, isLoading }),\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: React.KeyboardEvent) => {\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 } else if (hasMoreItems === 'top') {\n loadMoreRef.current?.focus();\n }\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 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 if (bannerPosition) {\n e.preventDefault();\n bannerRef.current.focusOnWrapper();\n }\n } else {\n e.preventDefault();\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: React.KeyboardEvent) => {\n const { key } = e;\n switch (key) {\n case 'ArrowUp':\n e.preventDefault();\n if (document.activeElement !== loadMoreRef.current) {\n onlyFocus(onScrollStop().shift());\n }\n break;\n case 'ArrowDown':\n e.preventDefault();\n if (document.activeElement === loadMoreRef.current) {\n (virtualListRef.current.querySelector(`[data-index=\"0\"]`) as HTMLDivElement).focus();\n } else {\n onlyFocus(onScrollStop().pop());\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 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={-1}\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 aria-relevant=\"additions\"\n ref={virtualListRef}\n role=\"list\"\n onKeyDown={handleListKey}\n >\n <StyledChatContainerContentListScroll height={`${totalSize}px`}>\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 {render}\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","bannerPosition","isLoading","padding","paddingStart","paddingEnd","some","item","ChatContainerMessagesList","props","useValidateProps","ChatContainerMessagesListWithSchema","toTypescript","sendingText","sendingMessages","messages","actionRef","onScrollEnds","getMoreMessages","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","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","handleListKey","activeElement","shift","pop","focusToComposer","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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,IAAMA,UAAU,GAAG,SAAbA,UAAa,OAA8D;AAAA,MAA3DC,YAA2D,QAA3DA,YAA2D;AAAA,MAA7CC,cAA6C,QAA7CA,cAA6C;AAAA,MAA7BC,SAA6B,QAA7BA,SAA6B;AAC/E,M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mG,4BAAD;AACE,IAAA,SAAS,EAAC,WADZ;AAEE,IAAA,UAAU,EAAC,WAFb;AAGE,IAAA,OAAO,EAAEtG,eAHX;AAIE,mBAAY,uBAJd;AAKE,IAAA,QAAQ,EAAEK;AALZ,IADF,CADD,GAUG,IAXN,EAYGkE,MAZH,CATF,CADF,CADF;AA4BD;;AAEDjF,yBAAyB,CAACiH,SAA1B,GAAsCC,+CAAtC;AACAlH,yBAAyB,CAACmH,YAA1B,GAAyCA,kDAAzC;IACMhH,mCAAmC,GAAGiH,kBAAQ,CAACpH,yBAAD;AACpDG,mCAAmC,CAAC8G,SAApC,GAAgDC,+CAAhD;;;;;"}
|
|
@@ -89,6 +89,9 @@ var ChatComposer = function ChatComposer(props) {
|
|
|
89
89
|
"data-testid": dataTestid
|
|
90
90
|
}, /*#__PURE__*/React.createElement(Grid, {
|
|
91
91
|
cols: ['1fr', '24px'],
|
|
92
|
+
style: {
|
|
93
|
+
height: heightProps.height
|
|
94
|
+
},
|
|
92
95
|
justifyContent: "center",
|
|
93
96
|
alignItems: "flex-end",
|
|
94
97
|
gutter: "xxs"
|
|
@@ -129,8 +132,7 @@ var ChatComposer = function ChatComposer(props) {
|
|
|
129
132
|
width: (_input$current = input.current) === null || _input$current === void 0 ? void 0 : _input$current.clientWidth
|
|
130
133
|
},
|
|
131
134
|
onChange: handleChange,
|
|
132
|
-
value: inputValue
|
|
133
|
-
|
|
135
|
+
value: inputValue
|
|
134
136
|
}), /*#__PURE__*/React.createElement(Grid, {
|
|
135
137
|
cols: ['1fr', '24px'],
|
|
136
138
|
justifyContent: "flex-end",
|
|
@@ -140,9 +142,9 @@ var ChatComposer = function ChatComposer(props) {
|
|
|
140
142
|
}, /*#__PURE__*/React.createElement(StyledCounterArea, {
|
|
141
143
|
hasError: hasError,
|
|
142
144
|
"data-testid": "composer-counter-area"
|
|
143
|
-
}, inputMaxLength && hasError ? /*#__PURE__*/React.createElement(StyledCounterErrorA11y, {
|
|
145
|
+
}, inputMaxLength && hasError ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StyledCounterErrorA11y, {
|
|
144
146
|
role: "alert"
|
|
145
|
-
}, maxLengthMessage || "You have entered ".concat(inputLength, " characters and have exceeded the limit by ").concat(inputLength - inputMaxLength, ". Please limit to less than ").concat(inputMaxLength, " characters. ")) : '', inputMaxLength ? " ".concat(inputLength, " / ").concat(inputMaxLength) : ''), /*#__PURE__*/React.createElement(Grid, null)));
|
|
147
|
+
}, maxLengthMessage || "You have entered ".concat(inputLength, " characters and have exceeded the limit by ").concat(inputLength - inputMaxLength, ". Please limit to less than ").concat(inputMaxLength, " characters. ")), maxLengthMessage || "Please limit to less than ".concat(inputMaxLength, " characters. ")) : '', inputMaxLength ? " ".concat(inputLength, " / ").concat(inputMaxLength) : ''), /*#__PURE__*/React.createElement(Grid, null)));
|
|
146
148
|
};
|
|
147
149
|
|
|
148
150
|
ChatComposer.propTypes = composerProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatContainerComposer.js","sources":["../../../../src/parts/chat-composer/ChatContainerComposer.tsx"],"sourcesContent":["/* eslint-disable max-lines */\nimport React from 'react';\nimport { Grid } from '@elliemae/ds-grid';\nimport { describe } from 'react-desc';\nimport { PaperAirplane } from '@elliemae/ds-icons';\nimport {\n StyledChatContainerContentComposer,\n StyledComposerInput,\n StyledComposerButton,\n StyledCounterArea,\n StyledCounterErrorA11y,\n} from './styled';\nimport { useValidateProps } from './config/useValidateProps';\n\nimport { defaultComposerPros, composerProps, ChatComposerProps } from './props';\n\nconst ChatComposer = (props: ChatComposerProps): JSX.Element => {\n useValidateProps(props, ChatComposerWithSchema.toJSON());\n\n const {\n inputValue,\n onChange,\n onResize,\n onSend,\n onFocus,\n onBlur,\n onKeyDown,\n maxHeight = 300,\n placeholder,\n inputMaxLength,\n maxLengthMessage,\n buttonDisabled,\n dataTestid,\n actionRef,\n } = props;\n\n const input = React.useRef<HTMLTextAreaElement>();\n const inputSize = React.useRef<HTMLTextAreaElement>();\n const inputSend = React.useRef<HTMLButtonElement>();\n const [height, setHeight] = React.useState(32);\n const internalMaxHeight = React.useMemo(() => maxHeight - 24, [maxHeight]);\n const [showScroll, setShowScroll] = React.useState(true);\n\n React.useEffect(() => {\n const newHeight =\n inputSize.current?.scrollHeight > internalMaxHeight ? internalMaxHeight : inputSize.current?.scrollHeight;\n onResize(newHeight);\n setHeight(newHeight);\n setShowScroll(inputSize.current?.scrollHeight - inputSize.current?.clientHeight > 5);\n }, [inputValue, internalMaxHeight, onResize]);\n\n React.useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.focusToComposer = () => {\n input.current.focus();\n };\n actionRef.current.focusToSend = () => {\n inputSend.current.focus();\n };\n }\n }, [actionRef]);\n\n const handleChange = React.useCallback(\n (e) => {\n onChange(e.target.value);\n },\n [onChange],\n );\n const heightProps = { height, overflow: showScroll ? 'auto' : 'hidden' };\n\n const inputLength = String(inputValue || '').length;\n const hasError = React.useMemo(() => inputLength > inputMaxLength, [inputLength, inputMaxLength]);\n\n return (\n <StyledChatContainerContentComposer rows={['auto', '15px']} maxHeight={`${maxHeight}px`} data-testid={dataTestid}>\n <Grid cols={['1fr', '24px']} justifyContent=\"center\" alignItems=\"flex-end\" gutter=\"xxs\">\n <StyledComposerInput\n ref={input}\n onChange={handleChange}\n style={{ ...heightProps }}\n value={inputValue}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n aria-label=\"Message to send\"\n data-testid=\"chat-composer-textarea\"\n />\n\n <Grid height=\"32px\" alignItems=\"center\">\n <StyledComposerButton\n buttonType=\"text\"\n icon={<PaperAirplane width={18} height={18} />}\n onClick={onSend}\n size=\"s\"\n disabled={!inputValue || buttonDisabled || hasError}\n data-testid=\"chat-composer-send-button\"\n aria-label=\"Send\"\n innerRef={inputSend}\n />\n </Grid>\n </Grid>\n <StyledComposerInput\n ref={inputSize}\n style={{\n height: 32,\n visibility: 'hidden',\n pointerEvents: 'none',\n position: 'absolute',\n top: 0,\n width: input.current?.clientWidth,\n }}\n onChange={handleChange}\n value={inputValue}\n // maxLength={inputMaxLength}\n />\n <Grid cols={['1fr', '24px']} justifyContent=\"flex-end\" alignItems=\"center\" gutter=\"xxs\" pb=\"xxs\">\n <StyledCounterArea hasError={hasError} data-testid=\"composer-counter-area\">\n {inputMaxLength && hasError ? (\n <StyledCounterErrorA11y role=\"alert\">\n {maxLengthMessage ||\n `You have entered ${inputLength} characters and have exceeded the limit by ${\n inputLength - inputMaxLength\n }. Please limit to less than ${inputMaxLength} characters. `}\n </StyledCounterErrorA11y>\n ) : (\n ''\n )}\n {inputMaxLength ? ` ${inputLength} / ${inputMaxLength}` : ''}\n </StyledCounterArea>\n <Grid />\n </Grid>\n </StyledChatContainerContentComposer>\n );\n};\n\nChatComposer.propTypes = composerProps;\nChatComposer.defaultProps = defaultComposerPros;\nconst ChatComposerWithSchema = describe(ChatComposer);\nChatComposerWithSchema.propTypes = composerProps;\n\nexport { ChatComposer, ChatComposerWithSchema };\n"],"names":["ChatComposer","props","useValidateProps","ChatComposerWithSchema","toJSON","inputValue","onChange","onResize","onSend","onFocus","onBlur","onKeyDown","maxHeight","placeholder","inputMaxLength","maxLengthMessage","buttonDisabled","dataTestid","actionRef","input","React","useRef","inputSize","inputSend","useState","height","setHeight","internalMaxHeight","useMemo","showScroll","setShowScroll","useEffect","newHeight","current","scrollHeight","clientHeight","focusToComposer","focus","focusToSend","handleChange","useCallback","e","target","value","heightProps","overflow","inputLength","String","length","hasError","visibility","pointerEvents","position","top","width","clientWidth","propTypes","composerProps","defaultProps","defaultComposerPros","describe"],"mappings":";;;;;;;;;;;;;;;;;;IAgBMA,YAAY,GAAG,SAAfA,YAAe,CAACC,KAAD,EAA2C;AAAA;;AAC9DC,EAAAA,gBAAgB,CAACD,KAAD,EAAQE,sBAAsB,CAACC,MAAvB,EAAR,CAAhB;AAEA,MACEC,UADF,GAeIJ,KAfJ,CACEI,UADF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,MAAM,EAAE,EADH;AAELyB,MAAAA,UAAU,EAAE,QAFP;AAGLC,MAAAA,aAAa,EAAE,MAHV;AAILC,MAAAA,QAAQ,EAAE,UAJL;AAKLC,MAAAA,GAAG,EAAE,CALA;AAMLC,MAAAA,KAAK,oBAAEnC,KAAK,CAACc,OAAR,mDAAE,eAAesB;AANjB,KAFT;AAUE,IAAA,QAAQ,EAAEhB,YAVZ;AAWE,IAAA,KAAK,EAAElC,UAXT;;AAAA,IA5BF,eA0CE,oBAAC,IAAD;AAAM,IAAA,IAAI,EAAE,CAAC,KAAD,EAAQ,MAAR,CAAZ;AAA6B,IAAA,cAAc,EAAC,UAA5C;AAAuD,IAAA,UAAU,EAAC,QAAlE;AAA2E,IAAA,MAAM,EAAC,KAAlF;AAAwF,IAAA,EAAE,EAAC;AAA3F,kBACE,oBAAC,iBAAD;AAAmB,IAAA,QAAQ,EAAE4C,QAA7B;AAAuC,mBAAY;AAAnD,KACGnC,cAAc,IAAImC,QAAlB,gBACC,oBAAC,sBAAD;AAAwB,IAAA,IAAI,EAAC;AAA7B,KACGlC,gBAAgB,+BACK+B,WADL,wDAEbA,WAAW,GAAGhC,cAFD,yCAGgBA,cAHhB,kBADnB,CADD,GAQC,EATJ,EAWGA,cAAc,cAAOgC,WAAP,gBAAwBhC,cAAxB,IAA2C,EAX5D,CADF,eAcE,oBAAC,IAAD,OAdF,CA1CF,CADF;AA6DD;;AAEDd,YAAY,CAACwD,SAAb,GAAyBC,aAAzB;AACAzD,YAAY,CAAC0D,YAAb,GAA4BC,mBAA5B;IACMxD,sBAAsB,GAAGyD,QAAQ,CAAC5D,YAAD;AACvCG,sBAAsB,CAACqD,SAAvB,GAAmCC,aAAnC;;;;"}
|
|
1
|
+
{"version":3,"file":"ChatContainerComposer.js","sources":["../../../../src/parts/chat-composer/ChatContainerComposer.tsx"],"sourcesContent":["/* eslint-disable max-lines */\nimport React from 'react';\nimport { Grid } from '@elliemae/ds-grid';\nimport { describe } from 'react-desc';\nimport { PaperAirplane } from '@elliemae/ds-icons';\nimport {\n StyledChatContainerContentComposer,\n StyledComposerInput,\n StyledComposerButton,\n StyledCounterArea,\n StyledCounterErrorA11y,\n} from './styled';\nimport { useValidateProps } from './config/useValidateProps';\n\nimport { defaultComposerPros, composerProps, ChatComposerProps } from './props';\n\nconst ChatComposer = (props: ChatComposerProps): JSX.Element => {\n useValidateProps(props, ChatComposerWithSchema.toJSON());\n\n const {\n inputValue,\n onChange,\n onResize,\n onSend,\n onFocus,\n onBlur,\n onKeyDown,\n maxHeight = 300,\n placeholder,\n inputMaxLength,\n maxLengthMessage,\n buttonDisabled,\n dataTestid,\n actionRef,\n } = props;\n\n const input = React.useRef<HTMLTextAreaElement>();\n const inputSize = React.useRef<HTMLTextAreaElement>();\n const inputSend = React.useRef<HTMLButtonElement>();\n const [height, setHeight] = React.useState(32);\n const internalMaxHeight = React.useMemo(() => maxHeight - 24, [maxHeight]);\n const [showScroll, setShowScroll] = React.useState(true);\n\n React.useEffect(() => {\n const newHeight =\n inputSize.current?.scrollHeight > internalMaxHeight ? internalMaxHeight : inputSize.current?.scrollHeight;\n onResize(newHeight);\n setHeight(newHeight);\n setShowScroll(inputSize.current?.scrollHeight - inputSize.current?.clientHeight > 5);\n }, [inputValue, internalMaxHeight, onResize]);\n\n React.useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.focusToComposer = () => {\n input.current.focus();\n };\n actionRef.current.focusToSend = () => {\n inputSend.current.focus();\n };\n }\n }, [actionRef]);\n\n const handleChange = React.useCallback(\n (e) => {\n onChange(e.target.value);\n },\n [onChange],\n );\n const heightProps = { height, overflow: showScroll ? 'auto' : 'hidden' };\n\n const inputLength = String(inputValue || '').length;\n const hasError = React.useMemo(() => inputLength > inputMaxLength, [inputLength, inputMaxLength]);\n return (\n <StyledChatContainerContentComposer rows={['auto', '15px']} maxHeight={`${maxHeight}px`} data-testid={dataTestid}>\n <Grid\n cols={['1fr', '24px']}\n style={{ height: heightProps.height }}\n justifyContent=\"center\"\n alignItems=\"flex-end\"\n gutter=\"xxs\"\n >\n <StyledComposerInput\n ref={input}\n onChange={handleChange}\n style={{ ...heightProps }}\n value={inputValue}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n aria-label=\"Message to send\"\n data-testid=\"chat-composer-textarea\"\n />\n\n <Grid height=\"32px\" alignItems=\"center\">\n <StyledComposerButton\n buttonType=\"text\"\n icon={<PaperAirplane width={18} height={18} />}\n onClick={onSend}\n size=\"s\"\n disabled={!inputValue || buttonDisabled || hasError}\n data-testid=\"chat-composer-send-button\"\n aria-label=\"Send\"\n innerRef={inputSend}\n />\n </Grid>\n </Grid>\n <StyledComposerInput\n ref={inputSize}\n style={{\n height: 32,\n visibility: 'hidden',\n pointerEvents: 'none',\n position: 'absolute',\n top: 0,\n width: input.current?.clientWidth,\n }}\n onChange={handleChange}\n value={inputValue}\n />\n <Grid cols={['1fr', '24px']} justifyContent=\"flex-end\" alignItems=\"center\" gutter=\"xxs\" pb=\"xxs\">\n <StyledCounterArea hasError={hasError} data-testid=\"composer-counter-area\">\n {inputMaxLength && hasError ? (\n <>\n <StyledCounterErrorA11y role=\"alert\">\n {maxLengthMessage ||\n `You have entered ${inputLength} characters and have exceeded the limit by ${\n inputLength - inputMaxLength\n }. Please limit to less than ${inputMaxLength} characters. `}\n </StyledCounterErrorA11y>\n {maxLengthMessage || `Please limit to less than ${inputMaxLength} characters. `}\n </>\n ) : (\n ''\n )}\n {inputMaxLength ? ` ${inputLength} / ${inputMaxLength}` : ''}\n </StyledCounterArea>\n <Grid />\n </Grid>\n </StyledChatContainerContentComposer>\n );\n};\n\nChatComposer.propTypes = composerProps;\nChatComposer.defaultProps = defaultComposerPros;\nconst ChatComposerWithSchema = describe(ChatComposer);\nChatComposerWithSchema.propTypes = composerProps;\n\nexport { ChatComposer, ChatComposerWithSchema };\n"],"names":["ChatComposer","props","useValidateProps","ChatComposerWithSchema","toJSON","inputValue","onChange","onResize","onSend","onFocus","onBlur","onKeyDown","maxHeight","placeholder","inputMaxLength","maxLengthMessage","buttonDisabled","dataTestid","actionRef","input","React","useRef","inputSize","inputSend","useState","height","setHeight","internalMaxHeight","useMemo","showScroll","setShowScroll","useEffect","newHeight","current","scrollHeight","clientHeight","focusToComposer","focus","focusToSend","handleChange","useCallback","e","target","value","heightProps","overflow","inputLength","String","length","hasError","visibility","pointerEvents","position","top","width","clientWidth","propTypes","composerProps","defaultProps","defaultComposerPros","describe"],"mappings":";;;;;;;;;;;;;;;;;;IAgBMA,YAAY,GAAG,SAAfA,YAAe,CAACC,KAAD,EAA2C;AAAA;;AAC9DC,EAAAA,gBAAgB,CAACD,KAAD,EAAQE,sBAAsB,CAACC,MAAvB,EAAR,CAAhB;AAEA,MACEC,UADF,GAeIJ,KAfJ,CACEI,UADF;AAAA,MAEEC,QAFF,GAeIL,KAfJ,CAEEK,QAFF;AAAA,MAGEC,QAHF,GAeIN,KAfJ,CAGEM,QAHF;AAAA,MAIEC,MAJF,GAeIP,KAfJ,CAIEO,MAJF;AAAA,MAKEC,OALF,GAeIR,KAfJ,CAKEQ,OALF;AAAA,MAMEC,MANF,GAeIT,KAfJ,CAMES,MANF;AAAA,MAOEC,SAPF,GAeIV,KAfJ,CAOEU,SAPF;AAAA,yBAeIV,KAfJ,CAQEW,SARF;AAAA,MAQEA,SARF,iCAQc,GARd;AAAA,MASEC,WATF,GAeIZ,KAfJ,CASEY,WATF;AAAA,MAUEC,cAVF,GAeIb,KAfJ,CAUEa,cAVF;AAAA,MAWEC,gBAXF,GAeId,KAfJ,CAWEc,gBAXF;AAAA,MAYEC,cAZF,GAeIf,KAfJ,CAYEe,cAZF;AAAA,MAaEC,UAbF,GAeIhB,KAfJ,CAaEgB,UAbF;AAAA,MAcEC,SAdF,GAeIjB,KAfJ,CAcEiB,SAdF;AAiBA,MAAMC,KAAK,GAAGC,KAAK,CAACC,MAAN,EAAd;AACA,MAAMC,SAAS,GAAGF,KAAK,CAACC,MAAN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IAAI,EAAC;AAA7B,KACGlC,gBAAgB,+BACK+B,WADL,wDAEbA,WAAW,GAAGhC,cAFD,yCAGgBA,cAHhB,kBADnB,CADF,EAOGC,gBAAgB,wCAAiCD,cAAjC,kBAPnB,CADD,GAWC,EAZJ,EAcGA,cAAc,cAAOgC,WAAP,gBAAwBhC,cAAxB,IAA2C,EAd5D,CADF,eAiBE,oBAAC,IAAD,OAjBF,CA/CF,CADF;AAqED;;AAEDd,YAAY,CAACwD,SAAb,GAAyBC,aAAzB;AACAzD,YAAY,CAAC0D,YAAb,GAA4BC,mBAA5B;IACMxD,sBAAsB,GAAGyD,QAAQ,CAAC5D,YAAD;AACvCG,sBAAsB,CAACqD,SAAvB,GAAmCC,aAAnC;;;;"}
|
|
@@ -67,18 +67,16 @@ var ChatContainer = function ChatContainer(props) {
|
|
|
67
67
|
});
|
|
68
68
|
var onResize = React.useCallback(function (height) {
|
|
69
69
|
if (onComposerResize) onComposerResize(height);
|
|
70
|
-
|
|
71
|
-
if (height > 30) {
|
|
72
|
-
/*
|
|
70
|
+
/*
|
|
73
71
|
setTimeout is used to equal the animation duration from the
|
|
74
72
|
composer text area when increase its size
|
|
75
73
|
*/
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
}
|
|
74
|
+
|
|
75
|
+
setTimeout(function () {
|
|
76
|
+
actionRef.current.scrollToIndex(messagesListProps.messages.length - 1, {
|
|
77
|
+
align: 'start'
|
|
78
|
+
});
|
|
79
|
+
}, 50);
|
|
82
80
|
}, [onComposerResize, messagesListProps.messages, actionRef]);
|
|
83
81
|
var Container = device === 'desktop' ? StyledChatContainerContent : MobileStyledChatContainerContent;
|
|
84
82
|
var handleTabs = React.useCallback(function (e) {
|
|
@@ -86,17 +84,21 @@ var ChatContainer = function ChatContainer(props) {
|
|
|
86
84
|
var ref = actionRef || listRef;
|
|
87
85
|
|
|
88
86
|
if (e.shiftKey && e.key === 'Tab') {
|
|
89
|
-
|
|
87
|
+
if (messagesListProps.messages.length > 0) {
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
|
|
90
|
+
if (['top', 'bottom'].includes(bannerPosition)) {
|
|
91
|
+
bannerRef.current.focusOnWrapper();
|
|
92
|
+
} else {
|
|
93
|
+
var _ref$current;
|
|
90
94
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
var last = ref.current.getMessagesInView().pop();
|
|
95
|
-
ref.current.focusToIndexWithoutScroll(last);
|
|
95
|
+
var last = ref.current.getMessagesInView().pop();
|
|
96
|
+
(_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focusToIndexWithoutScroll(last);
|
|
97
|
+
}
|
|
96
98
|
}
|
|
97
99
|
}
|
|
98
100
|
}
|
|
99
|
-
}, [actionRef, onComposerKeyDown, bannerPosition]); // Map actions
|
|
101
|
+
}, [actionRef, onComposerKeyDown, bannerPosition, messagesListProps.messages.length]); // Map actions
|
|
100
102
|
|
|
101
103
|
React.useEffect(function () {
|
|
102
104
|
if (actionRef && actionRef.current) {
|
|
@@ -152,7 +154,7 @@ var ChatContainer = function ChatContainer(props) {
|
|
|
152
154
|
"data-testid": "ds-chat-loading-indicator"
|
|
153
155
|
}, /*#__PURE__*/React.createElement(DSIndeterminateProgressIndicator, {
|
|
154
156
|
processing: true,
|
|
155
|
-
title:
|
|
157
|
+
title: sendingText,
|
|
156
158
|
lineOnly: true
|
|
157
159
|
})) : null), /*#__PURE__*/React.createElement(ChatComposer, _extends({}, composerProps, {
|
|
158
160
|
onKeyDown: handleTabs,
|
|
@@ -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 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 (height > 30) {\n /*\n setTimeout is used to equal the animation duration from the \n composer text area when increase its size\n */\n setTimeout(() => {\n actionRef.current.scrollToIndex(messagesListProps.messages.length - 1, {\n align: 'start',\n });\n }, 50);\n }\n },\n [onComposerResize, messagesListProps.messages, actionRef],\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","device","isLoading","hasMoreItems","getMoreMessages","ariaLabel","bannerRef","React","useRef","focusOnWrapper","noop","focusOnLink","containerRef","listRef","scrollToIndex","useCallback","height","setTimeout","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,GAcIJ,KAdJ,CACEI,WADF;AAAA,MAEEC,eAFF,GAcIL,KAdJ,CAEEK,eAFF;AAAA,MAGEC,cAHF,GAcIN,KAdJ,CAGEM,cAHF;AAAA,MAIEC,WAJF,GAcIP,KAdJ,CAIEO,WAJF;AAAA,MAKEC,iBALF,GAcIR,KAdJ,CAKEQ,iBALF;AAAA,MAMEC,aANF,GAcIT,KAdJ,CAMES,aANF;AAAA,6BAcIT,KAdJ,CAOES,aAPF;AAAA,MAO6BC,gBAP7B,wBAOmBC,QAPnB;AAAA,MAO0DC,iBAP1D,wBAO+CC,SAP/C;AAAA,MAQEC,SARF,GAcId,KAdJ,CAQEc,SARF;AAAA,MASEC,MATF,GAcIf,KAdJ,CASEe,MATF;AAAA,MAUEC,SAVF,GAcIhB,KAdJ,CAUEgB,SAVF;AAAA,MAWEC,YAXF,GAcIjB,KAdJ,CAWEiB,YAXF;AAAA,MAYEC,eAZF,GAcIlB,KAdJ,CAYEkB,eAZF;AAAA,MAaEC,SAbF,GAcInB,KAdJ,CAaEm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IE,IAAA,SAAS,EAAE,CAAC,0BAAAe,YAAY,CAACM,OAAb,gFAAsBgC,YAAtB,KAAsC,CAAvC,IAA4C,CAJzD;AAKE,IAAA,SAAS,EAAElD,SAAS,IAAIa;AAL1B,KAvCF,CADF;AAiDD;;AAED5B,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
|
+
{"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 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 /*\n setTimeout is used to equal the animation duration from the \n composer text area when increase its size\n */\n setTimeout(() => {\n actionRef.current.scrollToIndex(messagesListProps.messages.length - 1, {\n align: 'start',\n });\n }, 50);\n },\n [onComposerResize, messagesListProps.messages, actionRef],\n );\n const Container = device === 'desktop' ? StyledChatContainerContent : MobileStyledChatContainerContent;\n const handleTabs = React.useCallback(\n (e: React.KeyboardEvent) => {\n if (onComposerKeyDown) onComposerKeyDown(e);\n else {\n const ref = actionRef || listRef;\n if (e.shiftKey && e.key === 'Tab') {\n if (messagesListProps.messages.length > 0) {\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 },\n [actionRef, onComposerKeyDown, bannerPosition, messagesListProps.messages.length],\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={sendingText} 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","device","isLoading","hasMoreItems","getMoreMessages","ariaLabel","bannerRef","React","useRef","focusOnWrapper","noop","focusOnLink","containerRef","listRef","scrollToIndex","useCallback","height","setTimeout","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,GAcIJ,KAdJ,CACEI,WADF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IE,IAAA,UAAU,EAAE;AACVD,MAAAA,KAAK,EAAEhD,WAAW,CAACkD,SAAZ,IAAyB,MADtB;AAEVC,MAAAA,OAAO,EAAEnD,WAAW,CAACoD;AAFX,KAJd;AAQE,IAAA,OAAO,EAAEpD,WAAW,CAACqD,OARvB;AASE,IAAA,MAAM,MATR;AAUE,IAAA,IAAI,EAAErD,WAAW,CAACsD,IAAZ,IAAoBC,YAAY,CAACC,IAVzC;AAWE,IAAA,SAAS,EAAE3C;AAXb,IADF,CAjBF,EAgCGf,eAAe,IAAIA,eAAe,CAAC6B,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,EAAE9B,WAApD;AAAiE,IAAA,QAAQ;AAAzE,IADF,CADD,GAIG,IApCN,CADF,eAuCE,oBAAC,YAAD,eACMK,aADN;AAEE,IAAA,SAAS,EAAE8B,UAFb;AAGE,IAAA,QAAQ,EAAE5B,QAHZ;AAIE,IAAA,SAAS,EAAE,CAAC,0BAAAe,YAAY,CAACM,OAAb,gFAAsBgC,YAAtB,KAAsC,CAAvC,IAA4C,CAJzD;AAKE,IAAA,SAAS,EAAElD,SAAS,IAAIa;AAL1B,KAvCF,CADF;AAiDD;;AAED5B,aAAa,CAACkE,SAAd,GAA0BC,cAA1B;AACAnE,aAAa,CAACoE,YAAd,GAA6BA,YAA7B;IACMjE,uBAAuB,GAAGkE,QAAQ,CAACrE,aAAD;AACxCG,uBAAuB,CAAC+D,SAAxB,GAAoCC,cAApC;;;;"}
|
|
@@ -22,7 +22,7 @@ var StyledIndicatorContainer = /*#__PURE__*/styled.div.withConfig({
|
|
|
22
22
|
}, function (props) {
|
|
23
23
|
return props.theme.colors.neutral['000'];
|
|
24
24
|
}, function (props) {
|
|
25
|
-
return props.isLoading === 'top' ? "\n top: -41px;\n transform: translate(0, 41px);\n visibility: visible;\n pointer-events: auto
|
|
25
|
+
return props.isLoading === 'top' ? "\n top: -41px;\n transform: translate(0, 41px);\n visibility: visible;\n pointer-events: auto;\n " : '';
|
|
26
26
|
}, function (props) {
|
|
27
27
|
return props.isLoading === 'bottom' ? "\n bottom: -41px;\n transform: translate(0, -41px);\n visibility: visible;\n pointer-events: auto;\n " : '';
|
|
28
28
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.js","sources":["../../../../src/parts/chat-container/styled.ts"],"sourcesContent":["import styled from 'styled-components';\nimport { Grid } from '@elliemae/ds-grid';\nimport { StyledTitleRightBubble, StyledTitleLeftBubble, StyleBodyWrapper } from '../bubble/styled';\nimport { StyledComposerInput } from '../chat-composer/styled';\nimport { Wrapper, Title, Time, Message } from '../system-message/style';\nexport const CONTAINER_WIDTH = 300;\n\nexport const StyledChatContainerContent = styled(Grid)`\n height: 100%;\n min-width: ${CONTAINER_WIDTH}px;\n overflow: hidden;\n background: ${(props) => props.theme.colors.neutral['050']};\n position: relative;\n`;\nexport const StyledIndicatorContainer = styled.div<{\n isLoading?: 'top' | 'bottom';\n linear?: boolean;\n}>`\n transition: 0.4s ease-in-out;\n position: absolute;\n visibility: hidden;\n pointer-events: none;\n width: 100%;\n padding: 0 ${(props) => (!props.linear ? props.theme.space.xxs : 0)};\n left: 0;\n right: 0;\n background: ${(props) => props.theme.colors.neutral['000']};\n ${(props) =>\n props.isLoading === 'top'\n ? `\n top: -41px;\n transform: translate(0, 41px);\n visibility: visible;\n pointer-events: auto
|
|
1
|
+
{"version":3,"file":"styled.js","sources":["../../../../src/parts/chat-container/styled.ts"],"sourcesContent":["import styled from 'styled-components';\nimport { Grid } from '@elliemae/ds-grid';\nimport { StyledTitleRightBubble, StyledTitleLeftBubble, StyleBodyWrapper } from '../bubble/styled';\nimport { StyledComposerInput } from '../chat-composer/styled';\nimport { Wrapper, Title, Time, Message } from '../system-message/style';\nexport const CONTAINER_WIDTH = 300;\n\nexport const StyledChatContainerContent = styled(Grid)`\n height: 100%;\n min-width: ${CONTAINER_WIDTH}px;\n overflow: hidden;\n background: ${(props) => props.theme.colors.neutral['050']};\n position: relative;\n`;\nexport const StyledIndicatorContainer = styled.div<{\n isLoading?: 'top' | 'bottom';\n linear?: boolean;\n}>`\n transition: 0.4s ease-in-out;\n position: absolute;\n visibility: hidden;\n pointer-events: none;\n width: 100%;\n padding: 0 ${(props) => (!props.linear ? props.theme.space.xxs : 0)};\n left: 0;\n right: 0;\n background: ${(props) => props.theme.colors.neutral['000']};\n ${(props) =>\n props.isLoading === 'top'\n ? `\n top: -41px;\n transform: translate(0, 41px);\n visibility: visible;\n pointer-events: auto;\n `\n : ''}\n ${(props) =>\n props.isLoading === 'bottom'\n ? `\n bottom: -41px;\n transform: translate(0, -41px);\n visibility: visible;\n pointer-events: auto;\n `\n : ''}\n\n & div,a {\n font-size: 13px;\n }\n`;\n\nexport const MobileStyledChatContainerContent = styled(StyledChatContainerContent)`\n ${StyledTitleLeftBubble},\n ${StyleBodyWrapper} {\n font-size: 16px;\n }\n\n ${StyledTitleRightBubble} {\n font-size: 13px;\n }\n\n ${Wrapper} {\n background-color: #fff;\n box-shadow: -0 1px 3px rgba(53, 60, 70, 0.8);\n }\n\n ${Title},\n ${Message} {\n font-size: 16px;\n text-align: left;\n }\n\n ${Time} {\n font-size: 13px;\n }\n\n ${StyledComposerInput} {\n font-size: 16px;\n }\n\n ${StyledIndicatorContainer} {\n font-size: 16px;\n }\n`;\n"],"names":["CONTAINER_WIDTH","StyledChatContainerContent","styled","Grid","props","theme","colors","neutral","StyledIndicatorContainer","div","linear","space","xxs","isLoading","MobileStyledChatContainerContent","StyledTitleLeftBubble","StyleBodyWrapper","StyledTitleRightBubble","Wrapper","Title","Message","Time","StyledComposerInput"],"mappings":";;;;;;;;;;;IAKaA,eAAe,GAAG;IAElBC,0BAA0B,gBAAGC,MAAM,CAACC,IAAD,CAAT;AAAA;AAAA,wFAExBH,eAFwB,EAIvB,UAACI,KAAD;AAAA,SAAWA,KAAK,CAACC,KAAN,CAAYC,MAAZ,CAAmBC,OAAnB,CAA2B,KAA3B,CAAX;AAAA,CAJuB;IAO1BC,wBAAwB,gBAAGN,MAAM,CAACO,GAAV;AAAA;AAAA,wLAStB,UAACL,KAAD;AAAA,SAAY,CAACA,KAAK,CAACM,MAAP,GAAgBN,KAAK,CAACC,KAAN,CAAYM,KAAZ,CAAkBC,GAAlC,GAAwC,CAApD;AAAA,CATsB,EAYrB,UAACR,KAAD;AAAA,SAAWA,KAAK,CAACC,KAAN,CAAYC,MAAZ,CAAmBC,OAAnB,CAA2B,KAA3B,CAAX;AAAA,CAZqB,EAajC,UAACH,KAAD;AAAA,SACAA,KAAK,CAACS,SAAN,KAAoB,KAApB,8GAOI,EARJ;AAAA,CAbiC,EAsBjC,UAACT,KAAD;AAAA,SACAA,KAAK,CAACS,SAAN,KAAoB,QAApB,kHAOI,EARJ;AAAA,CAtBiC;IAqCxBC,gCAAgC,gBAAGZ,MAAM,CAACD,0BAAD,CAAT;AAAA;AAAA,sOACzCc,qBADyC,EAEzCC,gBAFyC,EAMzCC,sBANyC,EAUzCC,OAVyC,EAezCC,KAfyC,EAgBzCC,OAhByC,EAqBzCC,IArByC,EAyBzCC,mBAzByC,EA6BzCd,wBA7ByC;;;;"}
|
|
@@ -160,7 +160,17 @@ var ChatContainerMessagesList = function ChatContainerMessagesList(props) {
|
|
|
160
160
|
switch (key) {
|
|
161
161
|
case 'ArrowUp':
|
|
162
162
|
e.preventDefault();
|
|
163
|
-
|
|
163
|
+
|
|
164
|
+
if (index > 0) {
|
|
165
|
+
var _virtualListRef$curre4;
|
|
166
|
+
|
|
167
|
+
((_virtualListRef$curre4 = virtualListRef.current) === null || _virtualListRef$curre4 === void 0 ? void 0 : _virtualListRef$curre4.querySelector("[data-index=\"".concat(index - 1, "\"]"))).focus();
|
|
168
|
+
} else if (hasMoreItems === 'top') {
|
|
169
|
+
var _loadMoreRef$current;
|
|
170
|
+
|
|
171
|
+
(_loadMoreRef$current = loadMoreRef.current) === null || _loadMoreRef$current === void 0 ? void 0 : _loadMoreRef$current.focus();
|
|
172
|
+
}
|
|
173
|
+
|
|
164
174
|
break;
|
|
165
175
|
|
|
166
176
|
case 'ArrowDown':
|
|
@@ -184,25 +194,25 @@ var ChatContainerMessagesList = function ChatContainerMessagesList(props) {
|
|
|
184
194
|
|
|
185
195
|
case 'Tab':
|
|
186
196
|
if (hasMoreItems === 'bottom' && !e.shiftKey) {
|
|
187
|
-
var _loadMoreRef$
|
|
197
|
+
var _loadMoreRef$current2;
|
|
188
198
|
|
|
189
199
|
e.preventDefault();
|
|
190
|
-
(_loadMoreRef$
|
|
200
|
+
(_loadMoreRef$current2 = loadMoreRef.current) === null || _loadMoreRef$current2 === void 0 ? void 0 : _loadMoreRef$current2.focus();
|
|
191
201
|
} else if (hasMoreItems === 'top' && e.shiftKey) {
|
|
192
|
-
var _loadMoreRef$
|
|
202
|
+
var _loadMoreRef$current3;
|
|
193
203
|
|
|
194
204
|
e.preventDefault();
|
|
195
|
-
(_loadMoreRef$
|
|
205
|
+
(_loadMoreRef$current3 = loadMoreRef.current) === null || _loadMoreRef$current3 === void 0 ? void 0 : _loadMoreRef$current3.focus();
|
|
196
206
|
} else if (!e.shiftKey) {
|
|
197
207
|
if (bannerPosition) {
|
|
198
208
|
e.preventDefault();
|
|
199
209
|
bannerRef.current.focusOnWrapper();
|
|
200
210
|
}
|
|
201
211
|
} else {
|
|
202
|
-
var _virtualListRef$
|
|
212
|
+
var _virtualListRef$curre5;
|
|
203
213
|
|
|
204
214
|
e.preventDefault();
|
|
205
|
-
(_virtualListRef$
|
|
215
|
+
(_virtualListRef$curre5 = virtualListRef.current) === null || _virtualListRef$curre5 === void 0 ? void 0 : _virtualListRef$curre5.focus();
|
|
206
216
|
}
|
|
207
217
|
|
|
208
218
|
break;
|
|
@@ -214,12 +224,22 @@ var ChatContainerMessagesList = function ChatContainerMessagesList(props) {
|
|
|
214
224
|
switch (key) {
|
|
215
225
|
case 'ArrowUp':
|
|
216
226
|
e.preventDefault();
|
|
217
|
-
|
|
227
|
+
|
|
228
|
+
if (document.activeElement !== loadMoreRef.current) {
|
|
229
|
+
onlyFocus(onScrollStop().shift());
|
|
230
|
+
}
|
|
231
|
+
|
|
218
232
|
break;
|
|
219
233
|
|
|
220
234
|
case 'ArrowDown':
|
|
221
235
|
e.preventDefault();
|
|
222
|
-
|
|
236
|
+
|
|
237
|
+
if (document.activeElement === loadMoreRef.current) {
|
|
238
|
+
virtualListRef.current.querySelector("[data-index=\"0\"]").focus();
|
|
239
|
+
} else {
|
|
240
|
+
onlyFocus(onScrollStop().pop());
|
|
241
|
+
}
|
|
242
|
+
|
|
223
243
|
break;
|
|
224
244
|
|
|
225
245
|
case 'Home':
|
|
@@ -235,10 +255,10 @@ var ChatContainerMessagesList = function ChatContainerMessagesList(props) {
|
|
|
235
255
|
case 'Tab':
|
|
236
256
|
if (document.activeElement !== loadMoreRef.current) {
|
|
237
257
|
if (hasMoreItems === 'bottom' && !e.shiftKey) {
|
|
238
|
-
var _loadMoreRef$
|
|
258
|
+
var _loadMoreRef$current4;
|
|
239
259
|
|
|
240
260
|
e.preventDefault();
|
|
241
|
-
(_loadMoreRef$
|
|
261
|
+
(_loadMoreRef$current4 = loadMoreRef.current) === null || _loadMoreRef$current4 === void 0 ? void 0 : _loadMoreRef$current4.focus();
|
|
242
262
|
} else if (hasMoreItems === 'top' && e.shiftKey) ; else if (!e.shiftKey) {
|
|
243
263
|
e.preventDefault();
|
|
244
264
|
actionRef.current.focusToComposer();
|
|
@@ -247,10 +267,10 @@ var ChatContainerMessagesList = function ChatContainerMessagesList(props) {
|
|
|
247
267
|
e.preventDefault();
|
|
248
268
|
actionRef.current.focusToComposer();
|
|
249
269
|
} else {
|
|
250
|
-
var _virtualListRef$
|
|
270
|
+
var _virtualListRef$curre6;
|
|
251
271
|
|
|
252
272
|
e.preventDefault();
|
|
253
|
-
(_virtualListRef$
|
|
273
|
+
(_virtualListRef$curre6 = virtualListRef.current) === null || _virtualListRef$curre6 === void 0 ? void 0 : _virtualListRef$curre6.focus();
|
|
254
274
|
}
|
|
255
275
|
|
|
256
276
|
break;
|
|
@@ -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\ntype getPaddingT = {\n hasMoreItems: string | undefined;\n bannerPosition: string | undefined;\n isLoading: string | undefined;\n};\nconst getPadding = ({ hasMoreItems, bannerPosition, isLoading }: getPaddingT) => {\n const padding = {\n paddingStart: 0,\n paddingEnd: -5,\n };\n if ([hasMoreItems, bannerPosition, isLoading].some((item) => item === 'top')) padding.paddingStart = 42;\n else if ([hasMoreItems, bannerPosition, isLoading].some((item) => item === '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, bannerPosition, isLoading }),\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 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 if (bannerPosition) {\n e.preventDefault();\n bannerRef.current.focusOnWrapper();\n }\n } else {\n e.preventDefault();\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={-1}\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 aria-relevant=\"additions\"\n ref={virtualListRef}\n role=\"list\"\n onKeyDown={handleListKey}\n >\n <StyledChatContainerContentListScroll height={`${totalSize}px`}>\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 {render}\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","bannerPosition","isLoading","padding","paddingStart","paddingEnd","some","item","ChatContainerMessagesList","props","useValidateProps","ChatContainerMessagesListWithSchema","toTypescript","sendingText","sendingMessages","messages","actionRef","onScrollEnds","getMoreMessages","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","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","handleListKey","shift","pop","activeElement","focusToComposer","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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,IAAMA,UAAU,GAAG,SAAbA,UAAa,OAA8D;AAAA,MAA3DC,YAA2D,QAA3DA,YAA2D;AAAA,MAA7CC,cAA6C,QAA7CA,cAA6C;AAAA,MAA7BC,SAA6B,QAA7BA,SAA6B;AAC/E,MAAMC,OAAO,GAAG;AACdC,IAAAA,YAAY,EAAE,CADA;AAEdC,IAAAA,UAAU,EAAE,CAAC;AAFC,GAAhB;AAIA,MAAI,CAACL,YAAD,EAAeC,cAAf,EAA+BC,SAA/B,EAA0CI,IAA1C,CAA+C,UAACC,IAAD;AAAA,WAAUA,IAAI,KAAK,KAAnB;AAAA,GAA/C,CAAJ,EAA8EJ,OAAO,CAACC,YAAR,GAAuB,EAAvB,CAA9E,KACK,IAAI,CAACJ,YAAD,EAAeC,cAAf,EAA+BC,SAA/B,EAA0CI,IAA1C,CAA+C,UAACC,IAAD;AAAA,WAAUA,IAAI,KAAK,QAAnB;AAAA,GAA/C,CAAJ,EAAiFJ,OAAO,CAACE,UAAR,GAAqB,EAArB;AACtF,SAAOF,OAAP;AACD,CARD;;IAUMK,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,MAEEZ,cAFF,GAWIQ,KAXJ,CAEER,cA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;AAAyB,IAAA,YAAY,EAAEA;AAAvC,kBACE,oBAAC,QAAD;AACE,IAAA,SAAS,EAAC,WADZ;AAEE,IAAA,UAAU,EAAC,WAFb;AAGE,IAAA,OAAO,EAAEkB,eAHX;AAIE,mBAAY,uBAJd;AAKE,IAAA,QAAQ,EAAEK;AALZ,IADF,CADD,GAUG,IAXN,EAYGkE,MAZH,CATF,CADF,CADF;AA4BD;;AAEDjF,yBAAyB,CAACuG,SAA1B,GAAsCC,SAAtC;AACAxG,yBAAyB,CAACyG,YAA1B,GAAyCA,YAAzC;IACMtG,mCAAmC,GAAGuG,QAAQ,CAAC1G,yBAAD;AACpDG,mCAAmC,CAACoG,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\ntype getPaddingT = {\n hasMoreItems: string | undefined;\n bannerPosition: string | undefined;\n isLoading: string | undefined;\n};\nconst getPadding = ({ hasMoreItems, bannerPosition, isLoading }: getPaddingT) => {\n const padding = {\n paddingStart: 0,\n paddingEnd: -5,\n };\n if ([hasMoreItems, bannerPosition, isLoading].some((item) => item === 'top')) padding.paddingStart = 42;\n else if ([hasMoreItems, bannerPosition, isLoading].some((item) => item === '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, bannerPosition, isLoading }),\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: React.KeyboardEvent) => {\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 } else if (hasMoreItems === 'top') {\n loadMoreRef.current?.focus();\n }\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 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 if (bannerPosition) {\n e.preventDefault();\n bannerRef.current.focusOnWrapper();\n }\n } else {\n e.preventDefault();\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: React.KeyboardEvent) => {\n const { key } = e;\n switch (key) {\n case 'ArrowUp':\n e.preventDefault();\n if (document.activeElement !== loadMoreRef.current) {\n onlyFocus(onScrollStop().shift());\n }\n break;\n case 'ArrowDown':\n e.preventDefault();\n if (document.activeElement === loadMoreRef.current) {\n (virtualListRef.current.querySelector(`[data-index=\"0\"]`) as HTMLDivElement).focus();\n } else {\n onlyFocus(onScrollStop().pop());\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 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={-1}\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 aria-relevant=\"additions\"\n ref={virtualListRef}\n role=\"list\"\n onKeyDown={handleListKey}\n >\n <StyledChatContainerContentListScroll height={`${totalSize}px`}>\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 {render}\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","bannerPosition","isLoading","padding","paddingStart","paddingEnd","some","item","ChatContainerMessagesList","props","useValidateProps","ChatContainerMessagesListWithSchema","toTypescript","sendingText","sendingMessages","messages","actionRef","onScrollEnds","getMoreMessages","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","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","handleListKey","activeElement","shift","pop","focusToComposer","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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,IAAMA,UAAU,GAAG,SAAbA,UAAa,OAA8D;AAAA,MAA3DC,YAA2D,QAA3DA,YAA2D;AAAA,MAA7CC,cAA6C,QAA7CA,cAA6C;AAAA,MAA7BC,SAA6B,QAA7BA,SAA6B;AAC/E,MAAMC,OAAO,GAAG;AACdC,IAAAA,YAAY,EAAE,CADA;AAEdC,IAAAA,UAAU,EAAE,CAAC;AAFC,GAAhB;AAIA,MAAI,CAACL,YAAD,EAAeC,cAAf,EAA+BC,SAA/B,EAA0CI,IAA1C,CAA+C,UAACC,IAAD;AAAA,WAAUA,IAAI,KAAK,KAAnB;AAAA,GAA/C,CAAJ,EAA8EJ,OAA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AmC,GAAGuG,QAAQ,CAAC1G,yBAAD;AACpDG,mCAAmC,CAACoG,SAApC,GAAgDC,SAAhD;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-chat",
|
|
3
|
-
"version": "1.61.
|
|
3
|
+
"version": "1.61.6",
|
|
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.61.
|
|
20
|
-
"@elliemae/ds-basic": "1.61.
|
|
21
|
-
"@elliemae/ds-button": "1.61.
|
|
22
|
-
"@elliemae/ds-grid": "1.61.
|
|
23
|
-
"@elliemae/ds-icons": "1.61.
|
|
24
|
-
"@elliemae/ds-props-helpers": "1.61.
|
|
25
|
-
"@elliemae/ds-tooltip": "1.61.
|
|
26
|
-
"@elliemae/ds-truncated-tooltip-text": "1.61.
|
|
19
|
+
"@elliemae/ds-banner": "1.61.6",
|
|
20
|
+
"@elliemae/ds-basic": "1.61.6",
|
|
21
|
+
"@elliemae/ds-button": "1.61.6",
|
|
22
|
+
"@elliemae/ds-grid": "1.61.6",
|
|
23
|
+
"@elliemae/ds-icons": "1.61.6",
|
|
24
|
+
"@elliemae/ds-props-helpers": "1.61.6",
|
|
25
|
+
"@elliemae/ds-tooltip": "1.61.6",
|
|
26
|
+
"@elliemae/ds-truncated-tooltip-text": "1.61.6",
|
|
27
27
|
"prop-types": "~15.7.2",
|
|
28
28
|
"react-desc": "^4.1.2",
|
|
29
29
|
"react-virtual": "^2.3.2"
|