@elliemae/ds-chat-container 3.6.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/ChatContainer.js +174 -0
- package/dist/cjs/ChatContainer.js.map +7 -0
- package/dist/cjs/ChatContainerDataTestids.js +42 -0
- package/dist/cjs/ChatContainerDataTestids.js.map +7 -0
- package/dist/cjs/index.js +35 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/parts/chat-composer/ChatContainerComposer.js +195 -0
- package/dist/cjs/parts/chat-composer/ChatContainerComposer.js.map +7 -0
- package/dist/cjs/parts/chat-composer/index.js +33 -0
- package/dist/cjs/parts/chat-composer/index.js.map +7 -0
- package/dist/cjs/parts/chat-composer/styled.js +99 -0
- package/dist/cjs/parts/chat-composer/styled.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/ChatContainerMessagesList.js +146 -0
- package/dist/cjs/parts/chat-container-messages-list/ChatContainerMessagesList.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/index.js +33 -0
- package/dist/cjs/parts/chat-container-messages-list/index.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/styled.js +110 -0
- package/dist/cjs/parts/chat-container-messages-list/styled.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/useActionRef.js +61 -0
- package/dist/cjs/parts/chat-container-messages-list/useActionRef.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/useChatContainerMessageList.js +106 -0
- package/dist/cjs/parts/chat-container-messages-list/useChatContainerMessageList.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/useFocusAndScrollHelpers.js +93 -0
- package/dist/cjs/parts/chat-container-messages-list/useFocusAndScrollHelpers.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/useGetNewMessages.js +46 -0
- package/dist/cjs/parts/chat-container-messages-list/useGetNewMessages.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/useGlobalEventListener.js +59 -0
- package/dist/cjs/parts/chat-container-messages-list/useGlobalEventListener.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/useKeyboard.js +151 -0
- package/dist/cjs/parts/chat-container-messages-list/useKeyboard.js.map +7 -0
- package/dist/cjs/parts/index.js +27 -0
- package/dist/cjs/parts/index.js.map +7 -0
- package/dist/cjs/react-desc-prop-types.js +184 -0
- package/dist/cjs/react-desc-prop-types.js.map +7 -0
- package/dist/cjs/styled.js +109 -0
- package/dist/cjs/styled.js.map +7 -0
- package/dist/esm/ChatContainer.js +153 -0
- package/dist/esm/ChatContainer.js.map +7 -0
- package/dist/esm/ChatContainerDataTestids.js +16 -0
- package/dist/esm/ChatContainerDataTestids.js.map +7 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/parts/chat-composer/ChatContainerComposer.js +175 -0
- package/dist/esm/parts/chat-composer/ChatContainerComposer.js.map +7 -0
- package/dist/esm/parts/chat-composer/index.js +7 -0
- package/dist/esm/parts/chat-composer/index.js.map +7 -0
- package/dist/esm/parts/chat-composer/styled.js +73 -0
- package/dist/esm/parts/chat-composer/styled.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/ChatContainerMessagesList.js +128 -0
- package/dist/esm/parts/chat-container-messages-list/ChatContainerMessagesList.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/index.js +7 -0
- package/dist/esm/parts/chat-container-messages-list/index.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/styled.js +84 -0
- package/dist/esm/parts/chat-container-messages-list/styled.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/useActionRef.js +35 -0
- package/dist/esm/parts/chat-container-messages-list/useActionRef.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/useChatContainerMessageList.js +84 -0
- package/dist/esm/parts/chat-container-messages-list/useChatContainerMessageList.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/useFocusAndScrollHelpers.js +67 -0
- package/dist/esm/parts/chat-container-messages-list/useFocusAndScrollHelpers.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/useGetNewMessages.js +20 -0
- package/dist/esm/parts/chat-container-messages-list/useGetNewMessages.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/useGlobalEventListener.js +33 -0
- package/dist/esm/parts/chat-container-messages-list/useGlobalEventListener.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/useKeyboard.js +125 -0
- package/dist/esm/parts/chat-container-messages-list/useKeyboard.js.map +7 -0
- package/dist/esm/parts/index.js +4 -0
- package/dist/esm/parts/index.js.map +7 -0
- package/dist/esm/react-desc-prop-types.js +158 -0
- package/dist/esm/react-desc-prop-types.js.map +7 -0
- package/dist/esm/styled.js +83 -0
- package/dist/esm/styled.js.map +7 -0
- package/package.json +162 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { styled } from "@elliemae/ds-system";
|
|
3
|
+
import { Grid } from "@elliemae/ds-grid";
|
|
4
|
+
import { DSButtonV2 } from "@elliemae/ds-button";
|
|
5
|
+
const StyledChatContainerContentComposer = styled(Grid)`
|
|
6
|
+
width: 100%;
|
|
7
|
+
min-height: 56px;
|
|
8
|
+
background: ${(props) => props.theme.colors.neutral["050"]};
|
|
9
|
+
padding: ${(props) => props.theme.space.xxs};
|
|
10
|
+
padding-bottom: 3px;
|
|
11
|
+
padding-top: 6px;
|
|
12
|
+
padding-left: ${(props) => props.theme.space.xs};
|
|
13
|
+
max-height: ${(props) => props.maxHeight};
|
|
14
|
+
border-top: 1px solid #cbcfd7;
|
|
15
|
+
`;
|
|
16
|
+
const StyledComposerInput = styled.textarea`
|
|
17
|
+
padding: ${(props) => props.theme.space.xxs};
|
|
18
|
+
resize: none;
|
|
19
|
+
min-height: 32px;
|
|
20
|
+
border-radius: 2px;
|
|
21
|
+
border: solid 1px #cbcfd7;
|
|
22
|
+
color: #25292f;
|
|
23
|
+
height: ${(props) => typeof props.height === "number" ? `${props.height}px` : props.height};
|
|
24
|
+
min-width: 244px;
|
|
25
|
+
overflow-y: auto;
|
|
26
|
+
font-size: 13px;
|
|
27
|
+
font-weight: 400;
|
|
28
|
+
line-height: 1;
|
|
29
|
+
transition: height 0.05s;
|
|
30
|
+
&:focus {
|
|
31
|
+
outline: none;
|
|
32
|
+
border: 1px solid ${(props) => props.theme.colors.brand[600]};
|
|
33
|
+
box-shadow: inset 0 0 0 1px #8cc2ed;
|
|
34
|
+
border-radius: 2px;
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
const StyledComposerButton = styled(DSButtonV2)`
|
|
38
|
+
&:disabled {
|
|
39
|
+
background: none;
|
|
40
|
+
svg {
|
|
41
|
+
fill: #5d6775;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
svg {
|
|
45
|
+
fill: ${(props) => props.theme.colors.brand[600]};
|
|
46
|
+
}
|
|
47
|
+
&:focus {
|
|
48
|
+
background: ${(props) => props.theme.colors.brand[200]};
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
const StyledCounterArea = styled(Grid)`
|
|
52
|
+
text-align: right;
|
|
53
|
+
font-size: 11px;
|
|
54
|
+
height: 15px;
|
|
55
|
+
align-items: center;
|
|
56
|
+
font-style: italic;
|
|
57
|
+
${(props) => props.hasError ? `color:${props.theme.colors.danger[900]};` : ""}
|
|
58
|
+
position:relative;
|
|
59
|
+
`;
|
|
60
|
+
const StyledCounterErrorA11y = styled.span`
|
|
61
|
+
width: 1px;
|
|
62
|
+
height: 1px;
|
|
63
|
+
position: absolute;
|
|
64
|
+
clip: rect(1px, 1px, 1px, 1px);
|
|
65
|
+
`;
|
|
66
|
+
export {
|
|
67
|
+
StyledChatContainerContentComposer,
|
|
68
|
+
StyledComposerButton,
|
|
69
|
+
StyledComposerInput,
|
|
70
|
+
StyledCounterArea,
|
|
71
|
+
StyledCounterErrorA11y
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=styled.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/chat-composer/styled.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { styled } from '@elliemae/ds-system';\nimport { Grid } from '@elliemae/ds-grid';\nimport { DSButtonV2 } from '@elliemae/ds-button';\nimport { TextAreaProps } from '../../react-desc-prop-types';\n\n// Composer\nexport const StyledChatContainerContentComposer = styled(Grid)<{ maxHeight: string }>`\n width: 100%;\n min-height: 56px;\n background: ${(props) => props.theme.colors.neutral['050']};\n padding: ${(props) => props.theme.space.xxs};\n padding-bottom: 3px;\n padding-top: 6px;\n padding-left: ${(props) => props.theme.space.xs};\n max-height: ${(props) => props.maxHeight};\n border-top: 1px solid #cbcfd7;\n`;\n\nexport const StyledComposerInput = styled.textarea`\n padding: ${(props) => props.theme.space.xxs};\n resize: none;\n min-height: 32px;\n border-radius: 2px;\n border: solid 1px #cbcfd7;\n color: #25292f;\n height: ${(props: TextAreaProps) => (typeof props.height === 'number' ? `${props.height}px` : props.height)};\n min-width: 244px;\n overflow-y: auto;\n font-size: 13px;\n font-weight: 400;\n line-height: 1;\n transition: height 0.05s;\n &:focus {\n outline: none;\n border: 1px solid ${(props) => props.theme.colors.brand[600]};\n box-shadow: inset 0 0 0 1px #8cc2ed;\n border-radius: 2px;\n }\n`;\nexport const StyledComposerButton = styled(DSButtonV2)`\n &:disabled {\n background: none;\n svg {\n fill: #5d6775;\n }\n }\n svg {\n fill: ${(props) => props.theme.colors.brand[600]};\n }\n &:focus {\n background: ${(props) => props.theme.colors.brand[200]};\n }\n`;\n\nexport const StyledCounterArea = styled(Grid)<{ hasError: boolean }>`\n text-align: right;\n font-size: 11px;\n height: 15px;\n align-items: center;\n font-style: italic;\n ${(props) => (props.hasError ? `color:${props.theme.colors.danger[900]};` : '')}\n position:relative;\n`;\n\nexport const StyledCounterErrorA11y = styled.span`\n width: 1px;\n height: 1px;\n position: absolute;\n clip: rect(1px, 1px, 1px, 1px);\n`;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAIpB,MAAM,qCAAqC,OAAO,IAAI;AAAA;AAAA;AAAA,gBAG7C,CAAC,UAAU,MAAM,MAAM,OAAO,QAAQ;AAAA,aACzC,CAAC,UAAU,MAAM,MAAM,MAAM;AAAA;AAAA;AAAA,kBAGxB,CAAC,UAAU,MAAM,MAAM,MAAM;AAAA,gBAC/B,CAAC,UAAU,MAAM;AAAA;AAAA;AAI1B,MAAM,sBAAsB,OAAO;AAAA,aAC7B,CAAC,UAAU,MAAM,MAAM,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAM9B,CAAC,UAA0B,OAAO,MAAM,WAAW,WAAW,GAAG,MAAM,aAAa,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAS9E,CAAC,UAAU,MAAM,MAAM,OAAO,MAAM;AAAA;AAAA;AAAA;AAAA;AAKrD,MAAM,uBAAuB,OAAO,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAQzC,CAAC,UAAU,MAAM,MAAM,OAAO,MAAM;AAAA;AAAA;AAAA,kBAG9B,CAAC,UAAU,MAAM,MAAM,OAAO,MAAM;AAAA;AAAA;AAI/C,MAAM,oBAAoB,OAAO,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMxC,CAAC,UAAW,MAAM,WAAW,SAAS,MAAM,MAAM,OAAO,OAAO,UAAU;AAAA;AAAA;AAIvE,MAAM,yBAAyB,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React2 from "react";
|
|
4
|
+
import { describe } from "@elliemae/ds-utilities";
|
|
5
|
+
import DSButton from "@elliemae/ds-button";
|
|
6
|
+
import { ChatBubble, BUBBLE_TYPES } from "@elliemae/ds-chat-bubble";
|
|
7
|
+
import { MessageDelimiter } from "@elliemae/ds-chat-message-delimeter";
|
|
8
|
+
import { SystemMessage } from "@elliemae/ds-chat-system-message";
|
|
9
|
+
import {
|
|
10
|
+
StyledWrapperListItem,
|
|
11
|
+
StyledChatContainerContentList,
|
|
12
|
+
StyledChatContainerContentListScroll,
|
|
13
|
+
StyledWrapper,
|
|
14
|
+
StyledLoadMoreContainer,
|
|
15
|
+
ListItem,
|
|
16
|
+
StyledNewMessagesHiddenContainer
|
|
17
|
+
} from "./styled";
|
|
18
|
+
import { ChatContainerMessagesListPropTypes } from "../../react-desc-prop-types";
|
|
19
|
+
import { useGetNewMessages } from "./useGetNewMessages";
|
|
20
|
+
import { useChatContainerMessageList } from "./useChatContainerMessageList";
|
|
21
|
+
import { ChatContainerDataTestIds } from "../../ChatContainerDataTestids";
|
|
22
|
+
const ChatContainerMessagesList = (props) => {
|
|
23
|
+
const {
|
|
24
|
+
propsWithDefault,
|
|
25
|
+
globalAttributes,
|
|
26
|
+
useVirtualHelpers,
|
|
27
|
+
handleKey,
|
|
28
|
+
handleListKey,
|
|
29
|
+
loadMoreRef,
|
|
30
|
+
virtualListRef
|
|
31
|
+
} = useChatContainerMessageList(props);
|
|
32
|
+
const { sendingText, sendingMessages, messages, getMoreMessages, hasMoreItems, isLoading } = propsWithDefault;
|
|
33
|
+
const { totalSize, virtualItems } = useVirtualHelpers;
|
|
34
|
+
const newMessages = useGetNewMessages(messages);
|
|
35
|
+
const render = React2.useMemo(
|
|
36
|
+
() => virtualItems.map((virtualItem) => {
|
|
37
|
+
const { index, measureRef, start } = virtualItem;
|
|
38
|
+
const row = messages[index];
|
|
39
|
+
const isSending = sendingMessages && sendingMessages.find((m) => m === row.dsId);
|
|
40
|
+
const style = {
|
|
41
|
+
position: "absolute",
|
|
42
|
+
top: 0,
|
|
43
|
+
left: 0,
|
|
44
|
+
transform: `translateY(${start}px)`,
|
|
45
|
+
width: "100%"
|
|
46
|
+
};
|
|
47
|
+
return /* @__PURE__ */ jsx(ListItem, {
|
|
48
|
+
"data-element": "chat-element-list-item",
|
|
49
|
+
"data-index": index,
|
|
50
|
+
style,
|
|
51
|
+
ref: measureRef,
|
|
52
|
+
tabIndex: -1,
|
|
53
|
+
onKeyDown: handleKey,
|
|
54
|
+
role: "listitem",
|
|
55
|
+
children: /* @__PURE__ */ jsxs(StyledWrapperListItem, {
|
|
56
|
+
type: row.type,
|
|
57
|
+
children: [
|
|
58
|
+
row.type === BUBBLE_TYPES.SENDER || row.type === BUBBLE_TYPES.RECIPIENT ? /* @__PURE__ */ jsx(ChatBubble, {
|
|
59
|
+
...row,
|
|
60
|
+
helpMessage: isSending ? sendingText : row.helpMessage
|
|
61
|
+
}) : null,
|
|
62
|
+
row.type === BUBBLE_TYPES.DELIMITER ? /* @__PURE__ */ jsx(MessageDelimiter, {
|
|
63
|
+
...row
|
|
64
|
+
}) : null,
|
|
65
|
+
row.type === BUBBLE_TYPES.SYSTEM ? /* @__PURE__ */ jsx(SystemMessage, {
|
|
66
|
+
...row
|
|
67
|
+
}) : null
|
|
68
|
+
]
|
|
69
|
+
})
|
|
70
|
+
}, `ds-chat-bubble-${index}-${row.dsId}-${row.type}`);
|
|
71
|
+
}),
|
|
72
|
+
[virtualItems, messages, sendingMessages, handleKey, sendingText]
|
|
73
|
+
);
|
|
74
|
+
return /* @__PURE__ */ jsxs(StyledWrapper, {
|
|
75
|
+
...globalAttributes,
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ jsx(StyledChatContainerContentList, {
|
|
78
|
+
"data-testid": ChatContainerDataTestIds.THREAD_CONTAINER,
|
|
79
|
+
tabIndex: 0,
|
|
80
|
+
ref: virtualListRef,
|
|
81
|
+
role: "list",
|
|
82
|
+
onKeyDown: handleListKey,
|
|
83
|
+
children: /* @__PURE__ */ jsxs(StyledChatContainerContentListScroll, {
|
|
84
|
+
height: `${totalSize}px`,
|
|
85
|
+
children: [
|
|
86
|
+
!isLoading && hasMoreItems ? /* @__PURE__ */ jsx(StyledLoadMoreContainer, {
|
|
87
|
+
hasMoreItems,
|
|
88
|
+
children: /* @__PURE__ */ jsx(DSButton, {
|
|
89
|
+
labelText: "Load More",
|
|
90
|
+
buttonType: "secondary",
|
|
91
|
+
onClick: getMoreMessages,
|
|
92
|
+
"data-testid": ChatContainerDataTestIds.LOAD_MORE_BUTTON,
|
|
93
|
+
innerRef: loadMoreRef
|
|
94
|
+
})
|
|
95
|
+
}) : null,
|
|
96
|
+
render
|
|
97
|
+
]
|
|
98
|
+
})
|
|
99
|
+
}),
|
|
100
|
+
/* @__PURE__ */ jsx(StyledNewMessagesHiddenContainer, {
|
|
101
|
+
"aria-live": "polite",
|
|
102
|
+
"aria-hidden": "false",
|
|
103
|
+
children: newMessages.map((newMessage) => /* @__PURE__ */ jsxs("p", {
|
|
104
|
+
children: [
|
|
105
|
+
newMessage.title,
|
|
106
|
+
" ",
|
|
107
|
+
newMessage.time,
|
|
108
|
+
" ",
|
|
109
|
+
newMessage.body,
|
|
110
|
+
" ",
|
|
111
|
+
newMessage.errorMessage,
|
|
112
|
+
" ",
|
|
113
|
+
newMessage.helpMessage
|
|
114
|
+
]
|
|
115
|
+
}, newMessage.dsId))
|
|
116
|
+
})
|
|
117
|
+
]
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
ChatContainerMessagesList.propTypes = ChatContainerMessagesListPropTypes;
|
|
121
|
+
ChatContainerMessagesList.displayName = "ChatContainerMessagesList";
|
|
122
|
+
const ChatContainerMessagesListWithSchema = describe(ChatContainerMessagesList);
|
|
123
|
+
ChatContainerMessagesListWithSchema.propTypes = ChatContainerMessagesListPropTypes;
|
|
124
|
+
export {
|
|
125
|
+
ChatContainerMessagesList,
|
|
126
|
+
ChatContainerMessagesListWithSchema
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=ChatContainerMessagesList.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/chat-container-messages-list/ChatContainerMessagesList.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\n/* eslint-disable jsx-a11y/no-noninteractive-tabindex */\n/* eslint-disable max-lines */\nimport React, { CSSProperties, WeakValidationMap } from 'react';\nimport { describe } from '@elliemae/ds-utilities';\nimport DSButton from '@elliemae/ds-button';\nimport { ChatBubble, BUBBLE_TYPES } from '@elliemae/ds-chat-bubble';\nimport { MessageDelimiter, DSChatMessageDelimeterT } from '@elliemae/ds-chat-message-delimeter';\nimport { SystemMessage, DSChatSystemMessageT } from '@elliemae/ds-chat-system-message';\nimport {\n StyledWrapperListItem,\n StyledChatContainerContentList,\n StyledChatContainerContentListScroll,\n StyledWrapper,\n StyledLoadMoreContainer,\n ListItem,\n StyledNewMessagesHiddenContainer,\n} from './styled';\nimport { DSChatT, ChatContainerMessagesListPropTypes } from '../../react-desc-prop-types';\nimport { useGetNewMessages } from './useGetNewMessages';\nimport { useChatContainerMessageList } from './useChatContainerMessageList';\nimport { ChatContainerDataTestIds } from '../../ChatContainerDataTestids';\n\nconst ChatContainerMessagesList: React.ComponentType<DSChatT.MessagesListProps> = (props) => {\n const {\n propsWithDefault,\n globalAttributes,\n useVirtualHelpers,\n handleKey,\n handleListKey,\n loadMoreRef,\n virtualListRef,\n } = useChatContainerMessageList(props);\n\n const { sendingText, sendingMessages, messages, getMoreMessages, hasMoreItems, isLoading } = propsWithDefault;\n const { totalSize, virtualItems } = useVirtualHelpers;\n\n const newMessages = useGetNewMessages(messages);\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 <ChatBubble {...row} helpMessage={isSending ? sendingText : row.helpMessage} />\n ) : null}\n {row.type === BUBBLE_TYPES.DELIMITER ? (\n <MessageDelimiter {...(row as unknown as DSChatMessageDelimeterT.Props)} />\n ) : null}\n {row.type === BUBBLE_TYPES.SYSTEM ? <SystemMessage {...(row as DSChatSystemMessageT.Props)} /> : null}\n </StyledWrapperListItem>\n </ListItem>\n );\n }),\n [virtualItems, messages, sendingMessages, handleKey, sendingText],\n );\n\n return (\n <StyledWrapper {...globalAttributes}>\n <StyledChatContainerContentList\n data-testid={ChatContainerDataTestIds.THREAD_CONTAINER}\n tabIndex={0}\n ref={virtualListRef as React.RefObject<HTMLDivElement>}\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={ChatContainerDataTestIds.LOAD_MORE_BUTTON}\n innerRef={loadMoreRef}\n />\n </StyledLoadMoreContainer>\n ) : null}\n {render}\n </StyledChatContainerContentListScroll>\n </StyledChatContainerContentList>\n {/* We repeat the render with the new available messages */}\n <StyledNewMessagesHiddenContainer aria-live=\"polite\" aria-hidden=\"false\">\n {newMessages.map((newMessage) => (\n <p key={newMessage.dsId}>\n {newMessage.title} {newMessage.time} {newMessage.body} {newMessage.errorMessage} {newMessage.helpMessage}\n </p>\n ))}\n </StyledNewMessagesHiddenContainer>\n </StyledWrapper>\n );\n};\n\nChatContainerMessagesList.propTypes = ChatContainerMessagesListPropTypes as WeakValidationMap<unknown>;\nChatContainerMessagesList.displayName = 'ChatContainerMessagesList';\nconst ChatContainerMessagesListWithSchema = describe(ChatContainerMessagesList);\nChatContainerMessagesListWithSchema.propTypes = ChatContainerMessagesListPropTypes as WeakValidationMap<unknown>;\n\nexport { ChatContainerMessagesList, ChatContainerMessagesListWithSchema };\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAGA,OAAOA,YAAiD;AACxD,SAAS,gBAAgB;AACzB,OAAO,cAAc;AACrB,SAAS,YAAY,oBAAoB;AACzC,SAAS,wBAAiD;AAC1D,SAAS,qBAA2C;AACpD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAkB,0CAA0C;AAC5D,SAAS,yBAAyB;AAClC,SAAS,mCAAmC;AAC5C,SAAS,gCAAgC;AAEzC,MAAM,4BAA4E,CAAC,UAAU;AAC3F,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,4BAA4B,KAAK;AAErC,QAAM,EAAE,aAAa,iBAAiB,UAAU,iBAAiB,cAAc,UAAU,IAAI;AAC7F,QAAM,EAAE,WAAW,aAAa,IAAI;AAEpC,QAAM,cAAc,kBAAkB,QAAQ;AAE9C,QAAM,SAASA,OAAM;AAAA,IACnB,MACE,aAAa,IAAI,CAAC,gBAAgB;AAChC,YAAM,EAAE,OAAO,YAAY,MAAM,IAAI;AACrC,YAAM,MAAM,SAAS;AACrB,YAAM,YAAY,mBAAmB,gBAAgB,KAAK,CAAC,MAAM,MAAM,IAAI,IAAI;AAC/E,YAAM,QAAuB;AAAA,QAC3B,UAAU;AAAA,QACV,KAAK;AAAA,QACL,MAAM;AAAA,QACN,WAAW,cAAc;AAAA,QACzB,OAAO;AAAA,MACT;AAEA,aACE,oBAAC;AAAA,QACC,gBAAa;AAAA,QACb,cAAY;AAAA,QAEZ;AAAA,QACA,KAAK;AAAA,QACL,UAAU;AAAA,QACV,WAAW;AAAA,QACX,MAAK;AAAA,QAEL,+BAAC;AAAA,UAAsB,MAAM,IAAI;AAAA,UAC9B;AAAA,gBAAI,SAAS,aAAa,UAAU,IAAI,SAAS,aAAa,YAC7D,oBAAC;AAAA,cAAY,GAAG;AAAA,cAAK,aAAa,YAAY,cAAc,IAAI;AAAA,aAAa,IAC3E;AAAA,YACH,IAAI,SAAS,aAAa,YACzB,oBAAC;AAAA,cAAkB,GAAI;AAAA,aAAkD,IACvE;AAAA,YACH,IAAI,SAAS,aAAa,SAAS,oBAAC;AAAA,cAAe,GAAI;AAAA,aAAoC,IAAK;AAAA;AAAA,SACnG;AAAA,SAfK,kBAAkB,SAAS,IAAI,QAAQ,IAAI,MAgBlD;AAAA,IAEJ,CAAC;AAAA,IACH,CAAC,cAAc,UAAU,iBAAiB,WAAW,WAAW;AAAA,EAClE;AAEA,SACE,qBAAC;AAAA,IAAe,GAAG;AAAA,IACjB;AAAA,0BAAC;AAAA,QACC,eAAa,yBAAyB;AAAA,QACtC,UAAU;AAAA,QACV,KAAK;AAAA,QACL,MAAK;AAAA,QACL,WAAW;AAAA,QAEX,+BAAC;AAAA,UAAqC,QAAQ,GAAG;AAAA,UAC9C;AAAA,aAAC,aAAa,eACb,oBAAC;AAAA,cAAwB;AAAA,cACvB,8BAAC;AAAA,gBACC,WAAU;AAAA,gBACV,YAAW;AAAA,gBACX,SAAS;AAAA,gBACT,eAAa,yBAAyB;AAAA,gBACtC,UAAU;AAAA,eACZ;AAAA,aACF,IACE;AAAA,YACH;AAAA;AAAA,SACH;AAAA,OACF;AAAA,MAEA,oBAAC;AAAA,QAAiC,aAAU;AAAA,QAAS,eAAY;AAAA,QAC9D,sBAAY,IAAI,CAAC,eAChB,qBAAC;AAAA,UACE;AAAA,uBAAW;AAAA,YAAM;AAAA,YAAE,WAAW;AAAA,YAAK;AAAA,YAAE,WAAW;AAAA,YAAK;AAAA,YAAE,WAAW;AAAA,YAAa;AAAA,YAAE,WAAW;AAAA;AAAA,WADvF,WAAW,IAEnB,CACD;AAAA,OACH;AAAA;AAAA,GACF;AAEJ;AAEA,0BAA0B,YAAY;AACtC,0BAA0B,cAAc;AACxC,MAAM,sCAAsC,SAAS,yBAAyB;AAC9E,oCAAoC,YAAY;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/chat-container-messages-list/index.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { ChatContainerMessagesList, ChatContainerMessagesListWithSchema } from './ChatContainerMessagesList';\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,2BAA2B,2CAA2C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { styled } from "@elliemae/ds-system";
|
|
3
|
+
import { BUBBLE_TYPES } from "@elliemae/ds-chat-bubble";
|
|
4
|
+
const StyledWrapper = styled.div`
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 100%;
|
|
7
|
+
`;
|
|
8
|
+
const StyledWrapperListItem = styled.div`
|
|
9
|
+
min-width: 100%;
|
|
10
|
+
${(props) => props.type === BUBBLE_TYPES.SENDER && `padding: ${props.theme.space.xxs} ${props.theme.space.xxs} ${props.theme.space.xxs} 13%
|
|
11
|
+
`};
|
|
12
|
+
${(props) => props.type === BUBBLE_TYPES.RECIPIENT && `padding: ${props.theme.space.xxs} 13% ${props.theme.space.xxs}
|
|
13
|
+
${props.theme.space.xxs}
|
|
14
|
+
`};
|
|
15
|
+
${(props) => props.type === BUBBLE_TYPES.SYSTEM && `padding: ${props.theme.space.xxs} 0px
|
|
16
|
+
`};
|
|
17
|
+
`;
|
|
18
|
+
const StyledChatContainerContentList = styled.div`
|
|
19
|
+
width: 100%;
|
|
20
|
+
height: 100%;
|
|
21
|
+
padding: ${(props) => props.theme.space.xs};
|
|
22
|
+
padding-bottom: 0;
|
|
23
|
+
overflow-y: auto;
|
|
24
|
+
overflow-x: hidden;
|
|
25
|
+
`;
|
|
26
|
+
const StyledNewMessagesHiddenContainer = styled.div`
|
|
27
|
+
position: absolute;
|
|
28
|
+
width: 1px;
|
|
29
|
+
height: 1px;
|
|
30
|
+
margin: -1px;
|
|
31
|
+
border: 0;
|
|
32
|
+
padding: 0;
|
|
33
|
+
overflow: hidden;
|
|
34
|
+
clip: rect(0 0 0 0);
|
|
35
|
+
clip-path: inset(100%);
|
|
36
|
+
white-space: nowrap;
|
|
37
|
+
`;
|
|
38
|
+
const StyledChatContainerContentListScroll = styled.div`
|
|
39
|
+
width: 100%;
|
|
40
|
+
height: ${(props) => props.height};
|
|
41
|
+
position: relative;
|
|
42
|
+
`;
|
|
43
|
+
const StyledLoadMoreContainer = styled.div`
|
|
44
|
+
position: absolute;
|
|
45
|
+
width: calc(100% + ${(props) => props.theme.space.xxs});
|
|
46
|
+
padding: ${(props) => props.theme.space.xxs};
|
|
47
|
+
left: -${(props) => props.theme.space.xxs};
|
|
48
|
+
right: -${(props) => props.theme.space.xxs};
|
|
49
|
+
display: grid;
|
|
50
|
+
justify-content: center;
|
|
51
|
+
align-items: center;
|
|
52
|
+
${(props) => props.hasMoreItems === "top" ? "top: 0;" : ""}
|
|
53
|
+
${(props) => props.hasMoreItems === "bottom" ? "bottom: 0;" : ""}
|
|
54
|
+
`;
|
|
55
|
+
const ListItem = styled.div`
|
|
56
|
+
&:focus,
|
|
57
|
+
&:focus-visible {
|
|
58
|
+
outline: none;
|
|
59
|
+
&:after {
|
|
60
|
+
content: '';
|
|
61
|
+
display: block;
|
|
62
|
+
position: absolute;
|
|
63
|
+
top: 0;
|
|
64
|
+
left: -${(props) => props.theme.space.xxs};
|
|
65
|
+
pointer-events: none;
|
|
66
|
+
border-radius: 2px;
|
|
67
|
+
background-color: #ebedf0;
|
|
68
|
+
width: calc(100% + 24px);
|
|
69
|
+
border: 2px solid #1e79c2;
|
|
70
|
+
height: 100%;
|
|
71
|
+
z-index: -1;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
75
|
+
export {
|
|
76
|
+
ListItem,
|
|
77
|
+
StyledChatContainerContentList,
|
|
78
|
+
StyledChatContainerContentListScroll,
|
|
79
|
+
StyledLoadMoreContainer,
|
|
80
|
+
StyledNewMessagesHiddenContainer,
|
|
81
|
+
StyledWrapper,
|
|
82
|
+
StyledWrapperListItem
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=styled.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/chat-container-messages-list/styled.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { styled } from '@elliemae/ds-system';\nimport { BUBBLE_TYPES, DSChatBubbleT } from '@elliemae/ds-chat-bubble';\n\nexport const StyledWrapper = styled.div`\n width: 100%;\n height: 100%;\n`;\n\n// list\nexport const StyledWrapperListItem = styled.div<Partial<DSChatBubbleT.Props>>`\n min-width: 100%;\n ${(props) =>\n props.type === BUBBLE_TYPES.SENDER &&\n `padding: ${props.theme.space.xxs} ${props.theme.space.xxs} ${props.theme.space.xxs} 13%\n `};\n ${(props) =>\n props.type === BUBBLE_TYPES.RECIPIENT &&\n `padding: ${props.theme.space.xxs} 13% ${props.theme.space.xxs}\n ${props.theme.space.xxs}\n `};\n ${(props) =>\n props.type === BUBBLE_TYPES.SYSTEM &&\n `padding: ${props.theme.space.xxs} 0px\n `};\n`;\n\nexport const StyledChatContainerContentList = styled.div`\n width: 100%;\n height: 100%;\n padding: ${(props) => props.theme.space.xs};\n padding-bottom: 0;\n overflow-y: auto;\n overflow-x: hidden;\n`;\n\nexport const StyledNewMessagesHiddenContainer = styled.div`\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n border: 0;\n padding: 0;\n overflow: hidden;\n clip: rect(0 0 0 0);\n clip-path: inset(100%);\n white-space: nowrap;\n`;\n\nexport const StyledChatContainerContentListScroll = styled.div<{ height: string }>`\n width: 100%;\n height: ${(props) => props.height};\n position: relative;\n`;\n\nexport const StyledLoadMoreContainer = styled.div<{ hasMoreItems?: 'top' | 'bottom' }>`\n position: absolute;\n width: calc(100% + ${(props) => props.theme.space.xxs});\n padding: ${(props) => props.theme.space.xxs};\n left: -${(props) => props.theme.space.xxs};\n right: -${(props) => props.theme.space.xxs};\n display: grid;\n justify-content: center;\n align-items: center;\n ${(props) => (props.hasMoreItems === 'top' ? 'top: 0;' : '')}\n ${(props) => (props.hasMoreItems === 'bottom' ? 'bottom: 0;' : '')}\n`;\nexport const ListItem = styled.div`\n &:focus,\n &:focus-visible {\n outline: none;\n &:after {\n content: '';\n display: block;\n position: absolute;\n top: 0;\n left: -${(props) => props.theme.space.xxs};\n pointer-events: none;\n border-radius: 2px;\n background-color: #ebedf0;\n width: calc(100% + 24px);\n border: 2px solid #1e79c2;\n height: 100%;\n z-index: -1;\n }\n }\n`;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,cAAc;AACvB,SAAS,oBAAmC;AAErC,MAAM,gBAAgB,OAAO;AAAA;AAAA;AAAA;AAM7B,MAAM,wBAAwB,OAAO;AAAA;AAAA,IAExC,CAAC,UACD,MAAM,SAAS,aAAa,UAC5B,YAAY,MAAM,MAAM,MAAM,OAAO,MAAM,MAAM,MAAM,OAAO,MAAM,MAAM,MAAM;AAAA;AAAA,IAEhF,CAAC,UACD,MAAM,SAAS,aAAa,aAC5B,YAAY,MAAM,MAAM,MAAM,WAAW,MAAM,MAAM,MAAM;AAAA,MACzD,MAAM,MAAM,MAAM;AAAA;AAAA,IAEpB,CAAC,UACD,MAAM,SAAS,aAAa,UAC5B,YAAY,MAAM,MAAM,MAAM;AAAA;AAAA;AAI3B,MAAM,iCAAiC,OAAO;AAAA;AAAA;AAAA,aAGxC,CAAC,UAAU,MAAM,MAAM,MAAM;AAAA;AAAA;AAAA;AAAA;AAMnC,MAAM,mCAAmC,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAahD,MAAM,uCAAuC,OAAO;AAAA;AAAA,YAE/C,CAAC,UAAU,MAAM;AAAA;AAAA;AAItB,MAAM,0BAA0B,OAAO;AAAA;AAAA,uBAEvB,CAAC,UAAU,MAAM,MAAM,MAAM;AAAA,aACvC,CAAC,UAAU,MAAM,MAAM,MAAM;AAAA,WAC/B,CAAC,UAAU,MAAM,MAAM,MAAM;AAAA,YAC5B,CAAC,UAAU,MAAM,MAAM,MAAM;AAAA;AAAA;AAAA;AAAA,IAIrC,CAAC,UAAW,MAAM,iBAAiB,QAAQ,YAAY;AAAA,IACvD,CAAC,UAAW,MAAM,iBAAiB,WAAW,eAAe;AAAA;AAE1D,MAAM,WAAW,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAShB,CAAC,UAAU,MAAM,MAAM,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2 from "react";
|
|
3
|
+
const useActionRef = ({
|
|
4
|
+
actionRef,
|
|
5
|
+
useVirtualHelpers: { scrollToIndex: vScroll },
|
|
6
|
+
virtualListRef,
|
|
7
|
+
onScrollStop,
|
|
8
|
+
onlyFocus,
|
|
9
|
+
scrollAndFocus
|
|
10
|
+
}) => {
|
|
11
|
+
React2.useEffect(() => {
|
|
12
|
+
if (actionRef && actionRef.current) {
|
|
13
|
+
const scrollToIndex = (index, opts = { align: "center" }) => {
|
|
14
|
+
vScroll(index, opts);
|
|
15
|
+
onScrollStop();
|
|
16
|
+
};
|
|
17
|
+
const focusToIndex = (index, opts = { align: "center" }) => {
|
|
18
|
+
scrollAndFocus(index, opts);
|
|
19
|
+
};
|
|
20
|
+
const focusToList = () => {
|
|
21
|
+
virtualListRef.current?.focus();
|
|
22
|
+
};
|
|
23
|
+
actionRef.current.scrollToIndex = scrollToIndex;
|
|
24
|
+
actionRef.current.getMessagesInView = onScrollStop;
|
|
25
|
+
onScrollStop();
|
|
26
|
+
actionRef.current.focusToIndex = focusToIndex;
|
|
27
|
+
actionRef.current.focusToIndexWithoutScroll = onlyFocus;
|
|
28
|
+
actionRef.current.focusToList = focusToList;
|
|
29
|
+
}
|
|
30
|
+
}, [actionRef, onScrollStop, onlyFocus, scrollAndFocus, vScroll, virtualListRef]);
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
useActionRef
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=useActionRef.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/chat-container-messages-list/useActionRef.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\n/* eslint-disable jsx-a11y/no-noninteractive-tabindex */\n/* eslint-disable max-lines */\nimport React from 'react';\nimport { useVirtual } from 'react-virtual';\nimport { DSChatT } from '../../react-desc-prop-types';\n\ntype UseActionRefArgs = {\n actionRef: DSChatT.ActionRef;\n useVirtualHelpers: ReturnType<typeof useVirtual>;\n virtualListRef: React.MutableRefObject<HTMLDivElement | undefined>;\n onScrollStop: () => string[];\n onlyFocus: (index: string) => void;\n scrollAndFocus: (index: number, opts?: DSChatT.ScrollToIndexOptions) => void;\n};\n\nexport const useActionRef = ({\n actionRef,\n useVirtualHelpers: { scrollToIndex: vScroll },\n virtualListRef,\n onScrollStop,\n onlyFocus,\n scrollAndFocus,\n}: UseActionRefArgs) => {\n React.useEffect(() => {\n if (actionRef && actionRef.current) {\n const scrollToIndex: DSChatT.ActionRef['current']['scrollToIndex'] = (index, opts = { align: 'center' }) => {\n vScroll(index, opts);\n onScrollStop();\n };\n const focusToIndex: DSChatT.ActionRef['current']['focusToIndex'] = (index, opts = { align: 'center' }) => {\n scrollAndFocus(index, opts);\n };\n const focusToList = () => {\n virtualListRef.current?.focus();\n };\n\n actionRef.current.scrollToIndex = scrollToIndex;\n actionRef.current.getMessagesInView = onScrollStop;\n // I have no idea what the next line refeers to\n // keeping this from original code to avoid any possible breaking-change\n onScrollStop(); // init useMemo due to debounce use.\n actionRef.current.focusToIndex = focusToIndex;\n actionRef.current.focusToIndexWithoutScroll = onlyFocus;\n actionRef.current.focusToList = focusToList;\n }\n }, [actionRef, onScrollStop, onlyFocus, scrollAndFocus, vScroll, virtualListRef]);\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACGvB,OAAOA,YAAW;AAaX,MAAM,eAAe,CAAC;AAAA,EAC3B;AAAA,EACA,mBAAmB,EAAE,eAAe,QAAQ;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAwB;AACtB,EAAAA,OAAM,UAAU,MAAM;AACpB,QAAI,aAAa,UAAU,SAAS;AAClC,YAAM,gBAA+D,CAAC,OAAO,OAAO,EAAE,OAAO,SAAS,MAAM;AAC1G,gBAAQ,OAAO,IAAI;AACnB,qBAAa;AAAA,MACf;AACA,YAAM,eAA6D,CAAC,OAAO,OAAO,EAAE,OAAO,SAAS,MAAM;AACxG,uBAAe,OAAO,IAAI;AAAA,MAC5B;AACA,YAAM,cAAc,MAAM;AACxB,uBAAe,SAAS,MAAM;AAAA,MAChC;AAEA,gBAAU,QAAQ,gBAAgB;AAClC,gBAAU,QAAQ,oBAAoB;AAGtC,mBAAa;AACb,gBAAU,QAAQ,eAAe;AACjC,gBAAU,QAAQ,4BAA4B;AAC9C,gBAAU,QAAQ,cAAc;AAAA,IAClC;AAAA,EACF,GAAG,CAAC,WAAW,cAAc,WAAW,gBAAgB,SAAS,cAAc,CAAC;AAClF;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2 from "react";
|
|
3
|
+
import {
|
|
4
|
+
useMemoMergePropsWithDefault,
|
|
5
|
+
useGetGlobalAttributes,
|
|
6
|
+
useValidateTypescriptPropTypes
|
|
7
|
+
} from "@elliemae/ds-utilities";
|
|
8
|
+
import { useVirtual } from "react-virtual";
|
|
9
|
+
import { useActionRef } from "./useActionRef";
|
|
10
|
+
import { useGlobalEventListener } from "./useGlobalEventListener";
|
|
11
|
+
import { useKeyboard } from "./useKeyboard";
|
|
12
|
+
import { useFocusAndScrollHelpers } from "./useFocusAndScrollHelpers";
|
|
13
|
+
import { ChatContainerMessagesListPropTypes, defaultPropsMessagesList } from "../../react-desc-prop-types";
|
|
14
|
+
const getPadding = ({ hasMoreItems, bannerPosition, isLoading }) => {
|
|
15
|
+
const padding = {
|
|
16
|
+
paddingStart: 0,
|
|
17
|
+
paddingEnd: -5
|
|
18
|
+
};
|
|
19
|
+
if ([hasMoreItems, bannerPosition, isLoading].some((item) => item === "top"))
|
|
20
|
+
padding.paddingStart = 42;
|
|
21
|
+
else if ([hasMoreItems, bannerPosition, isLoading].some((item) => item === "bottom"))
|
|
22
|
+
padding.paddingEnd = 42;
|
|
23
|
+
return padding;
|
|
24
|
+
};
|
|
25
|
+
const useChatContainerMessageList = (props) => {
|
|
26
|
+
const propsWithDefault = useMemoMergePropsWithDefault(props, defaultPropsMessagesList);
|
|
27
|
+
useValidateTypescriptPropTypes(propsWithDefault, ChatContainerMessagesListPropTypes);
|
|
28
|
+
const globalAttributes = useGetGlobalAttributes(propsWithDefault);
|
|
29
|
+
const loadMoreRef = React2.useRef();
|
|
30
|
+
const virtualListRef = React2.useRef();
|
|
31
|
+
const pendingOnScroll = React2.useRef(false);
|
|
32
|
+
const { bannerPosition, messages, actionRef, hasMoreItems, isLoading } = propsWithDefault;
|
|
33
|
+
const useVirtualHelpers = useVirtual({
|
|
34
|
+
size: messages?.length,
|
|
35
|
+
parentRef: virtualListRef,
|
|
36
|
+
overscan: 15,
|
|
37
|
+
...getPadding({ hasMoreItems, bannerPosition, isLoading }),
|
|
38
|
+
estimateSize: React2.useCallback(() => 80, [])
|
|
39
|
+
});
|
|
40
|
+
const { onScrollStop, onlyFocus, scrollAndFocus, checkPendingOnScroll } = useFocusAndScrollHelpers({
|
|
41
|
+
propsWithDefault,
|
|
42
|
+
useVirtualHelpers,
|
|
43
|
+
pendingOnScroll,
|
|
44
|
+
virtualListRef
|
|
45
|
+
});
|
|
46
|
+
useActionRef({
|
|
47
|
+
actionRef,
|
|
48
|
+
useVirtualHelpers,
|
|
49
|
+
virtualListRef,
|
|
50
|
+
onScrollStop,
|
|
51
|
+
onlyFocus,
|
|
52
|
+
scrollAndFocus
|
|
53
|
+
});
|
|
54
|
+
useGlobalEventListener({
|
|
55
|
+
propsWithDefault,
|
|
56
|
+
virtualListRef,
|
|
57
|
+
onScrollStop,
|
|
58
|
+
checkPendingOnScroll
|
|
59
|
+
});
|
|
60
|
+
const keyboardMethods = useKeyboard({
|
|
61
|
+
propsWithDefault,
|
|
62
|
+
actionRef,
|
|
63
|
+
virtualListRef,
|
|
64
|
+
loadMoreRef,
|
|
65
|
+
scrollAndFocus,
|
|
66
|
+
onlyFocus,
|
|
67
|
+
onScrollStop
|
|
68
|
+
});
|
|
69
|
+
return React2.useMemo(
|
|
70
|
+
() => ({
|
|
71
|
+
propsWithDefault,
|
|
72
|
+
globalAttributes,
|
|
73
|
+
useVirtualHelpers,
|
|
74
|
+
loadMoreRef,
|
|
75
|
+
virtualListRef,
|
|
76
|
+
...keyboardMethods
|
|
77
|
+
}),
|
|
78
|
+
[globalAttributes, keyboardMethods, propsWithDefault, useVirtualHelpers, loadMoreRef, virtualListRef]
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
export {
|
|
82
|
+
useChatContainerMessageList
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=useChatContainerMessageList.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/chat-container-messages-list/useChatContainerMessageList.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\n/* eslint-disable jsx-a11y/no-noninteractive-tabindex */\n/* eslint-disable max-lines */\nimport React from 'react';\nimport {\n useMemoMergePropsWithDefault,\n useGetGlobalAttributes,\n useValidateTypescriptPropTypes,\n} from '@elliemae/ds-utilities';\nimport { useVirtual } from 'react-virtual';\nimport { useActionRef } from './useActionRef';\nimport { useGlobalEventListener } from './useGlobalEventListener';\nimport { useKeyboard } from './useKeyboard';\nimport { useFocusAndScrollHelpers } from './useFocusAndScrollHelpers';\nimport { DSChatT, ChatContainerMessagesListPropTypes, defaultPropsMessagesList } from '../../react-desc-prop-types';\n\nconst getPadding = ({ hasMoreItems, bannerPosition, isLoading }: DSChatT.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\ntype UseChatContainerMessageList = (props: DSChatT.MessagesListProps) => {\n propsWithDefault: DSChatT.MessagesListProps;\n globalAttributes: ReturnType<typeof useGetGlobalAttributes>;\n useVirtualHelpers: ReturnType<typeof useVirtual>;\n loadMoreRef: React.MutableRefObject<HTMLButtonElement | undefined>;\n virtualListRef: React.MutableRefObject<HTMLDivElement | undefined>;\n} & ReturnType<typeof useKeyboard>;\n\nexport const useChatContainerMessageList: UseChatContainerMessageList = (props) => {\n const propsWithDefault = useMemoMergePropsWithDefault<DSChatT.MessagesListProps>(props, defaultPropsMessagesList);\n useValidateTypescriptPropTypes<DSChatT.MessagesListProps>(propsWithDefault, ChatContainerMessagesListPropTypes);\n const globalAttributes = useGetGlobalAttributes(propsWithDefault);\n const loadMoreRef = React.useRef<HTMLButtonElement>();\n const virtualListRef = React.useRef<HTMLDivElement>();\n\n const pendingOnScroll = React.useRef(false);\n const { bannerPosition, messages, actionRef, hasMoreItems, isLoading } = propsWithDefault;\n const useVirtualHelpers = useVirtual({\n size: messages?.length,\n parentRef: virtualListRef,\n overscan: 15,\n ...getPadding({ hasMoreItems, bannerPosition, isLoading }),\n // estimateSize should not be really required given what was stated on\n // https://github.com/tannerlinsley/react-virtual/issues/23\n estimateSize: React.useCallback(() => 80, []),\n });\n\n const { onScrollStop, onlyFocus, scrollAndFocus, checkPendingOnScroll } = useFocusAndScrollHelpers({\n propsWithDefault,\n useVirtualHelpers,\n pendingOnScroll,\n virtualListRef,\n });\n\n useActionRef({\n actionRef,\n useVirtualHelpers,\n virtualListRef,\n onScrollStop,\n onlyFocus,\n scrollAndFocus,\n });\n\n useGlobalEventListener({\n propsWithDefault,\n virtualListRef,\n onScrollStop,\n checkPendingOnScroll,\n });\n\n const keyboardMethods = useKeyboard({\n propsWithDefault,\n actionRef,\n virtualListRef,\n loadMoreRef,\n scrollAndFocus,\n onlyFocus,\n onScrollStop,\n });\n\n return React.useMemo(\n () => ({\n propsWithDefault,\n globalAttributes,\n useVirtualHelpers,\n loadMoreRef,\n virtualListRef,\n ...keyboardMethods,\n }),\n [globalAttributes, keyboardMethods, propsWithDefault, useVirtualHelpers, loadMoreRef, virtualListRef],\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACGvB,OAAOA,YAAW;AAClB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,8BAA8B;AACvC,SAAS,mBAAmB;AAC5B,SAAS,gCAAgC;AACzC,SAAkB,oCAAoC,gCAAgC;AAEtF,MAAM,aAAa,CAAC,EAAE,cAAc,gBAAgB,UAAU,MAA2B;AACvF,QAAM,UAAU;AAAA,IACd,cAAc;AAAA,IACd,YAAY;AAAA,EACd;AACA,MAAI,CAAC,cAAc,gBAAgB,SAAS,EAAE,KAAK,CAAC,SAAS,SAAS,KAAK;AAAG,YAAQ,eAAe;AAAA,WAC5F,CAAC,cAAc,gBAAgB,SAAS,EAAE,KAAK,CAAC,SAAS,SAAS,QAAQ;AAAG,YAAQ,aAAa;AAC3G,SAAO;AACT;AAUO,MAAM,8BAA2D,CAAC,UAAU;AACjF,QAAM,mBAAmB,6BAAwD,OAAO,wBAAwB;AAChH,iCAA0D,kBAAkB,kCAAkC;AAC9G,QAAM,mBAAmB,uBAAuB,gBAAgB;AAChE,QAAM,cAAcA,OAAM,OAA0B;AACpD,QAAM,iBAAiBA,OAAM,OAAuB;AAEpD,QAAM,kBAAkBA,OAAM,OAAO,KAAK;AAC1C,QAAM,EAAE,gBAAgB,UAAU,WAAW,cAAc,UAAU,IAAI;AACzE,QAAM,oBAAoB,WAAW;AAAA,IACnC,MAAM,UAAU;AAAA,IAChB,WAAW;AAAA,IACX,UAAU;AAAA,IACV,GAAG,WAAW,EAAE,cAAc,gBAAgB,UAAU,CAAC;AAAA,IAGzD,cAAcA,OAAM,YAAY,MAAM,IAAI,CAAC,CAAC;AAAA,EAC9C,CAAC;AAED,QAAM,EAAE,cAAc,WAAW,gBAAgB,qBAAqB,IAAI,yBAAyB;AAAA,IACjG;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,eAAa;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,yBAAuB;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,kBAAkB,YAAY;AAAA,IAClC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,SAAOA,OAAM;AAAA,IACX,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL;AAAA,IACA,CAAC,kBAAkB,iBAAiB,kBAAkB,mBAAmB,aAAa,cAAc;AAAA,EACtG;AACF;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2 from "react";
|
|
3
|
+
import { debounce } from "lodash";
|
|
4
|
+
const useFocusAndScrollHelpers = ({
|
|
5
|
+
propsWithDefault: { onScrollEnds },
|
|
6
|
+
useVirtualHelpers: { scrollToIndex: vScroll },
|
|
7
|
+
pendingOnScroll,
|
|
8
|
+
virtualListRef
|
|
9
|
+
}) => {
|
|
10
|
+
const onScrollStop = React2.useMemo(
|
|
11
|
+
() => debounce(() => {
|
|
12
|
+
if (document.visibilityState === "hidden") {
|
|
13
|
+
pendingOnScroll.current = true;
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
if (!virtualListRef.current)
|
|
17
|
+
return [];
|
|
18
|
+
pendingOnScroll.current = false;
|
|
19
|
+
const { bottom, top } = virtualListRef.current?.getBoundingClientRect() || {};
|
|
20
|
+
const list = virtualListRef.current.querySelectorAll('[data-element="chat-element-list-item"]');
|
|
21
|
+
const indexList = [];
|
|
22
|
+
list.forEach((item) => {
|
|
23
|
+
const { top: itemTop } = item.getBoundingClientRect();
|
|
24
|
+
const itemPadding = 10;
|
|
25
|
+
if (itemTop + itemPadding < bottom && itemTop + itemPadding > top)
|
|
26
|
+
indexList.push(item.dataset.index || "");
|
|
27
|
+
});
|
|
28
|
+
if (onScrollEnds)
|
|
29
|
+
onScrollEnds(indexList);
|
|
30
|
+
return indexList;
|
|
31
|
+
}, 500),
|
|
32
|
+
[onScrollEnds, pendingOnScroll, virtualListRef]
|
|
33
|
+
);
|
|
34
|
+
const onlyFocus = React2.useCallback(
|
|
35
|
+
(index) => {
|
|
36
|
+
virtualListRef.current?.querySelector(`[data-index="${index}"]`)?.focus();
|
|
37
|
+
},
|
|
38
|
+
[virtualListRef]
|
|
39
|
+
);
|
|
40
|
+
const scrollAndFocus = React2.useCallback(
|
|
41
|
+
(index) => {
|
|
42
|
+
vScroll(index, { align: "center" });
|
|
43
|
+
setTimeout(() => {
|
|
44
|
+
onlyFocus(index.toString());
|
|
45
|
+
}, 300);
|
|
46
|
+
onScrollStop();
|
|
47
|
+
},
|
|
48
|
+
[onScrollStop, onlyFocus, vScroll]
|
|
49
|
+
);
|
|
50
|
+
const checkPendingOnScroll = React2.useCallback(() => {
|
|
51
|
+
if (pendingOnScroll.current === true)
|
|
52
|
+
onScrollStop();
|
|
53
|
+
}, [onScrollStop, pendingOnScroll]);
|
|
54
|
+
return React2.useMemo(
|
|
55
|
+
() => ({
|
|
56
|
+
onScrollStop,
|
|
57
|
+
onlyFocus,
|
|
58
|
+
scrollAndFocus,
|
|
59
|
+
checkPendingOnScroll
|
|
60
|
+
}),
|
|
61
|
+
[onScrollStop, onlyFocus, scrollAndFocus, checkPendingOnScroll]
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
export {
|
|
65
|
+
useFocusAndScrollHelpers
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=useFocusAndScrollHelpers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/chat-container-messages-list/useFocusAndScrollHelpers.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\n/* eslint-disable jsx-a11y/no-noninteractive-tabindex */\n/* eslint-disable max-lines */\nimport React from 'react';\nimport { useVirtual } from 'react-virtual';\nimport { debounce } from 'lodash';\nimport { DSChatT } from '../../react-desc-prop-types';\n\ntype UseFocusAndScrollHelpersArgs = {\n propsWithDefault: DSChatT.MessagesListProps;\n useVirtualHelpers: ReturnType<typeof useVirtual>;\n pendingOnScroll: React.MutableRefObject<boolean>;\n virtualListRef: React.MutableRefObject<HTMLDivElement | undefined>;\n};\n\nexport const useFocusAndScrollHelpers = ({\n propsWithDefault: { onScrollEnds },\n useVirtualHelpers: { scrollToIndex: vScroll },\n pendingOnScroll,\n virtualListRef,\n}: UseFocusAndScrollHelpersArgs) => {\n const onScrollStop = React.useMemo(\n () =>\n debounce((): string[] => {\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\n const list = virtualListRef.current.querySelectorAll<HTMLElement>('[data-element=\"chat-element-list-item\"]');\n const indexList: Array<string> = [];\n list.forEach((item: HTMLElement) => {\n const { top: itemTop } = item.getBoundingClientRect();\n\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, pendingOnScroll, virtualListRef],\n ) as () => string[];\n\n const onlyFocus = React.useCallback(\n (index: string) => {\n (virtualListRef.current?.querySelector(`[data-index=\"${index}\"]`) as HTMLDivElement)?.focus();\n },\n [virtualListRef],\n );\n\n const scrollAndFocus = React.useCallback(\n (index: number) => {\n vScroll(index, { align: 'center' });\n setTimeout(() => {\n onlyFocus(index.toString());\n }, 300);\n onScrollStop();\n },\n [onScrollStop, onlyFocus, vScroll],\n );\n\n const checkPendingOnScroll = React.useCallback(() => {\n if (pendingOnScroll.current === true) onScrollStop();\n }, [onScrollStop, pendingOnScroll]);\n\n return React.useMemo(\n () => ({\n onScrollStop,\n onlyFocus,\n scrollAndFocus,\n checkPendingOnScroll,\n }),\n [onScrollStop, onlyFocus, scrollAndFocus, checkPendingOnScroll],\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACGvB,OAAOA,YAAW;AAElB,SAAS,gBAAgB;AAUlB,MAAM,2BAA2B,CAAC;AAAA,EACvC,kBAAkB,EAAE,aAAa;AAAA,EACjC,mBAAmB,EAAE,eAAe,QAAQ;AAAA,EAC5C;AAAA,EACA;AACF,MAAoC;AAClC,QAAM,eAAeA,OAAM;AAAA,IACzB,MACE,SAAS,MAAgB;AACvB,UAAI,SAAS,oBAAoB,UAAU;AACzC,wBAAgB,UAAU;AAC1B,eAAO,CAAC;AAAA,MACV;AACA,UAAI,CAAC,eAAe;AAAS,eAAO,CAAC;AACrC,sBAAgB,UAAU;AAC1B,YAAM,EAAE,QAAQ,IAAI,IAAI,eAAe,SAAS,sBAAsB,KAAK,CAAC;AAE5E,YAAM,OAAO,eAAe,QAAQ,iBAA8B,yCAAyC;AAC3G,YAAM,YAA2B,CAAC;AAClC,WAAK,QAAQ,CAAC,SAAsB;AAClC,cAAM,EAAE,KAAK,QAAQ,IAAI,KAAK,sBAAsB;AAEpD,cAAM,cAAc;AACpB,YAAI,UAAU,cAAc,UAAU,UAAU,cAAc;AAAK,oBAAU,KAAK,KAAK,QAAQ,SAAS,EAAE;AAAA,MAC5G,CAAC;AACD,UAAI;AAAc,qBAAa,SAAS;AACxC,aAAO;AAAA,IACT,GAAG,GAAG;AAAA,IACR,CAAC,cAAc,iBAAiB,cAAc;AAAA,EAChD;AAEA,QAAM,YAAYA,OAAM;AAAA,IACtB,CAAC,UAAkB;AACjB,MAAC,eAAe,SAAS,cAAc,gBAAgB,SAAS,GAAsB,MAAM;AAAA,IAC9F;AAAA,IACA,CAAC,cAAc;AAAA,EACjB;AAEA,QAAM,iBAAiBA,OAAM;AAAA,IAC3B,CAAC,UAAkB;AACjB,cAAQ,OAAO,EAAE,OAAO,SAAS,CAAC;AAClC,iBAAW,MAAM;AACf,kBAAU,MAAM,SAAS,CAAC;AAAA,MAC5B,GAAG,GAAG;AACN,mBAAa;AAAA,IACf;AAAA,IACA,CAAC,cAAc,WAAW,OAAO;AAAA,EACnC;AAEA,QAAM,uBAAuBA,OAAM,YAAY,MAAM;AACnD,QAAI,gBAAgB,YAAY;AAAM,mBAAa;AAAA,EACrD,GAAG,CAAC,cAAc,eAAe,CAAC;AAElC,SAAOA,OAAM;AAAA,IACX,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC,cAAc,WAAW,gBAAgB,oBAAoB;AAAA,EAChE;AACF;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useMemo, useState } from "react";
|
|
3
|
+
const useGetNewMessages = (messages) => {
|
|
4
|
+
const [seenMessages, setSeenMessages] = useState({});
|
|
5
|
+
const newMessages = useMemo(() => {
|
|
6
|
+
const list = [];
|
|
7
|
+
messages.forEach((message) => {
|
|
8
|
+
if (!(message.dsId in seenMessages)) {
|
|
9
|
+
list.push(message);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
setSeenMessages(Object.fromEntries(messages.map((m) => [m.dsId, true])));
|
|
13
|
+
return list;
|
|
14
|
+
}, [messages]);
|
|
15
|
+
return newMessages;
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
useGetNewMessages
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=useGetNewMessages.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/chat-container-messages-list/useGetNewMessages.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useMemo, useState } from 'react';\nimport type { DSChatBubbleT } from '@elliemae/ds-chat-bubble';\n\nexport const useGetNewMessages = (messages: DSChatBubbleT.Props[]) => {\n const [seenMessages, setSeenMessages] = useState<Record<DSChatBubbleT.Props['dsId'], true>>({});\n const newMessages = useMemo(() => {\n const list: DSChatBubbleT.Props[] = [];\n messages.forEach((message) => {\n if (!(message.dsId in seenMessages)) {\n list.push(message);\n }\n });\n setSeenMessages(Object.fromEntries(messages.map((m) => [m.dsId, true])));\n return list;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [messages]);\n\n return newMessages;\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,SAAS,gBAAgB;AAG3B,MAAM,oBAAoB,CAAC,aAAoC;AACpE,QAAM,CAAC,cAAc,eAAe,IAAI,SAAoD,CAAC,CAAC;AAC9F,QAAM,cAAc,QAAQ,MAAM;AAChC,UAAM,OAA8B,CAAC;AACrC,aAAS,QAAQ,CAAC,YAAY;AAC5B,UAAI,EAAE,QAAQ,QAAQ,eAAe;AACnC,aAAK,KAAK,OAAO;AAAA,MACnB;AAAA,IACF,CAAC;AACD,oBAAgB,OAAO,YAAY,SAAS,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC,CAAC;AACvE,WAAO;AAAA,EAET,GAAG,CAAC,QAAQ,CAAC;AAEb,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2 from "react";
|
|
3
|
+
const useGlobalEventListener = ({
|
|
4
|
+
propsWithDefault: { onScrollEnds },
|
|
5
|
+
virtualListRef,
|
|
6
|
+
onScrollStop,
|
|
7
|
+
checkPendingOnScroll
|
|
8
|
+
}) => {
|
|
9
|
+
React2.useEffect(() => {
|
|
10
|
+
let handlerCallback;
|
|
11
|
+
const localVirtualRef = virtualListRef.current;
|
|
12
|
+
const onScroll = () => {
|
|
13
|
+
if (handlerCallback)
|
|
14
|
+
clearTimeout(handlerCallback);
|
|
15
|
+
handlerCallback = setTimeout(onScrollStop, 300);
|
|
16
|
+
};
|
|
17
|
+
if (onScrollEnds) {
|
|
18
|
+
virtualListRef.current?.addEventListener("scroll", onScroll);
|
|
19
|
+
}
|
|
20
|
+
document.addEventListener("visibilitychange", checkPendingOnScroll);
|
|
21
|
+
return () => {
|
|
22
|
+
if (handlerCallback)
|
|
23
|
+
clearTimeout(handlerCallback);
|
|
24
|
+
if (onScrollEnds && localVirtualRef)
|
|
25
|
+
localVirtualRef.removeEventListener("scroll", onScroll);
|
|
26
|
+
document.removeEventListener("visibilitychange", checkPendingOnScroll);
|
|
27
|
+
};
|
|
28
|
+
}, [onScrollStop, onScrollEnds, checkPendingOnScroll, virtualListRef]);
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
useGlobalEventListener
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=useGlobalEventListener.js.map
|