@elliemae/ds-chat 2.2.3-rc.0 → 2.2.3-rc.4
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-container-messages-list/ChatContainerMessagesList.js +7 -9
- package/cjs/parts/chat-container-messages-list/styled.js +7 -3
- package/cjs/parts/chat-container-messages-list/useGetNewMessages.js +28 -0
- package/esm/parts/chat-container-messages-list/ChatContainerMessagesList.js +8 -10
- package/esm/parts/chat-container-messages-list/styled.js +7 -4
- package/esm/parts/chat-container-messages-list/useGetNewMessages.js +24 -0
- package/package.json +14 -10
- package/types/parts/chat-container-messages-list/styled.d.ts +1 -0
- package/types/parts/chat-container-messages-list/useGetNewMessages.d.ts +2 -0
|
@@ -26,6 +26,7 @@ var MessageDelimiter = require('../message-delimiter/MessageDelimiter.js');
|
|
|
26
26
|
var SystemMessage = require('../system-message/SystemMessage.js');
|
|
27
27
|
var styled = require('./styled.js');
|
|
28
28
|
var props = require('./props.js');
|
|
29
|
+
var useGetNewMessages = require('./useGetNewMessages.js');
|
|
29
30
|
var jsxRuntime = require('react/jsx-runtime');
|
|
30
31
|
|
|
31
32
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -86,6 +87,7 @@ const ChatContainerMessagesList = props => {
|
|
|
86
87
|
})), {}, {
|
|
87
88
|
estimateSize: React__default["default"].useCallback(() => 80, [])
|
|
88
89
|
}));
|
|
90
|
+
const newMessages = useGetNewMessages.useGetNewMessages(messages);
|
|
89
91
|
const debouncedScroll = React__default["default"].useMemo(() => lodash.debounce(() => {
|
|
90
92
|
var _virtualListRef$curre;
|
|
91
93
|
|
|
@@ -203,7 +205,7 @@ const ChatContainerMessagesList = props => {
|
|
|
203
205
|
|
|
204
206
|
e.preventDefault();
|
|
205
207
|
(_loadMoreRef$current2 = loadMoreRef.current) === null || _loadMoreRef$current2 === void 0 ? void 0 : _loadMoreRef$current2.focus();
|
|
206
|
-
} else if (
|
|
208
|
+
} else if (!e.shiftKey) {
|
|
207
209
|
if (bannerPosition) {
|
|
208
210
|
e.preventDefault();
|
|
209
211
|
bannerRef.current.focusOnWrapper();
|
|
@@ -261,11 +263,6 @@ const ChatContainerMessagesList = props => {
|
|
|
261
263
|
|
|
262
264
|
e.preventDefault();
|
|
263
265
|
(_loadMoreRef$current3 = loadMoreRef.current) === null || _loadMoreRef$current3 === void 0 ? void 0 : _loadMoreRef$current3.focus();
|
|
264
|
-
} else if (hasMoreItems === 'top' && e.shiftKey) {
|
|
265
|
-
var _loadMoreRef$current4;
|
|
266
|
-
|
|
267
|
-
e.preventDefault();
|
|
268
|
-
(_loadMoreRef$current4 = loadMoreRef.current) === null || _loadMoreRef$current4 === void 0 ? void 0 : _loadMoreRef$current4.focus();
|
|
269
266
|
} else if (!e.shiftKey) {
|
|
270
267
|
e.preventDefault();
|
|
271
268
|
actionRef.current.focusToComposer();
|
|
@@ -342,8 +339,6 @@ const ChatContainerMessagesList = props => {
|
|
|
342
339
|
return /*#__PURE__*/_jsx__default["default"](styled.StyledWrapper, {}, void 0, /*#__PURE__*/jsxRuntime.jsx(styled.StyledChatContainerContentList, {
|
|
343
340
|
"data-testid": "chat-thread-container",
|
|
344
341
|
tabIndex: 0,
|
|
345
|
-
"aria-live": "polite",
|
|
346
|
-
"aria-relevant": "additions",
|
|
347
342
|
ref: virtualListRef,
|
|
348
343
|
role: "list",
|
|
349
344
|
onKeyDown: handleListKey,
|
|
@@ -358,7 +353,10 @@ const ChatContainerMessagesList = props => {
|
|
|
358
353
|
"data-testid": "ds-chat-load-more-btn",
|
|
359
354
|
innerRef: loadMoreRef
|
|
360
355
|
})) : null, render)
|
|
361
|
-
})
|
|
356
|
+
}), /*#__PURE__*/_jsx__default["default"](styled.StyledNewMessagesHiddenContainer, {
|
|
357
|
+
"aria-live": "polite",
|
|
358
|
+
"aria-hidden": "false"
|
|
359
|
+
}, void 0, newMessages.map(newMessage => /*#__PURE__*/_jsx__default["default"]("p", {}, void 0, newMessage.title, " ", newMessage.time, " ", newMessage.body, " ", newMessage.errorMessage, " ", newMessage.helpMessage))));
|
|
362
360
|
};
|
|
363
361
|
|
|
364
362
|
ChatContainerMessagesList.defaultProps = props.defaultProps;
|
|
@@ -20,19 +20,23 @@ const StyledWrapperListItem = /*#__PURE__*/styled__default["default"].div.withCo
|
|
|
20
20
|
const StyledChatContainerContentList = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
21
21
|
componentId: "sc-1jhprzr-2"
|
|
22
22
|
})(["width:100%;height:100%;padding:", ";padding-bottom:0;overflow-y:auto;overflow-x:hidden;"], props => props.theme.space.xs);
|
|
23
|
-
const
|
|
23
|
+
const StyledNewMessagesHiddenContainer = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
24
24
|
componentId: "sc-1jhprzr-3"
|
|
25
|
+
})(["position:absolute;width:1px;height:1px;margin:-1px;border:0;padding:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(100%);white-space:nowrap;"]);
|
|
26
|
+
const StyledChatContainerContentListScroll = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
27
|
+
componentId: "sc-1jhprzr-4"
|
|
25
28
|
})(["width:100%;height:", ";position:relative;"], props => props.height);
|
|
26
29
|
const StyledLoadMoreContainer = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
27
|
-
componentId: "sc-1jhprzr-
|
|
30
|
+
componentId: "sc-1jhprzr-5"
|
|
28
31
|
})(["position:absolute;width:calc(100% + ", ");padding:", ";left:-", ";right:-", ";display:grid;justify-content:center;align-items:center;", " ", ""], props => props.theme.space.xxs, props => props.theme.space.xxs, props => props.theme.space.xxs, props => props.theme.space.xxs, props => props.hasMoreItems === 'top' ? 'top: 0;' : '', props => props.hasMoreItems === 'bottom' ? 'bottom: 0;' : '');
|
|
29
32
|
const ListItem = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
30
|
-
componentId: "sc-1jhprzr-
|
|
33
|
+
componentId: "sc-1jhprzr-6"
|
|
31
34
|
})(["&:focus,&:focus-visible{outline:none;&:after{content:'';display:block;position:absolute;top:0;left:-", ";pointer-events:none;border-radius:2px;background-color:#ebedf0;width:calc(100% + 24px);border:2px solid #1e79c2;height:100%;z-index:-1;}}"], props => props.theme.space.xxs);
|
|
32
35
|
|
|
33
36
|
exports.ListItem = ListItem;
|
|
34
37
|
exports.StyledChatContainerContentList = StyledChatContainerContentList;
|
|
35
38
|
exports.StyledChatContainerContentListScroll = StyledChatContainerContentListScroll;
|
|
36
39
|
exports.StyledLoadMoreContainer = StyledLoadMoreContainer;
|
|
40
|
+
exports.StyledNewMessagesHiddenContainer = StyledNewMessagesHiddenContainer;
|
|
37
41
|
exports.StyledWrapper = StyledWrapper;
|
|
38
42
|
exports.StyledWrapperListItem = StyledWrapperListItem;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
6
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
8
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
9
|
+
require('core-js/modules/esnext.async-iterator.map.js');
|
|
10
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
11
|
+
var React = require('react');
|
|
12
|
+
|
|
13
|
+
const useGetNewMessages = messages => {
|
|
14
|
+
const [seenMessages, setSeenMessages] = React.useState({});
|
|
15
|
+
const newMessages = React.useMemo(() => {
|
|
16
|
+
const list = [];
|
|
17
|
+
messages.forEach(message => {
|
|
18
|
+
if (!(message.dsId in seenMessages)) {
|
|
19
|
+
list.push(message);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
setSeenMessages(Object.fromEntries(messages.map(m => [m.dsId, true])));
|
|
23
|
+
return list; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
|
+
}, [messages]);
|
|
25
|
+
return newMessages;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.useGetNewMessages = useGetNewMessages;
|
|
@@ -20,8 +20,9 @@ import { ChatBubble } from '../bubble/ChatBubble.js';
|
|
|
20
20
|
import { BUBBLE_TYPES } from '../bubble/props.js';
|
|
21
21
|
import { MessageDelimiter } from '../message-delimiter/MessageDelimiter.js';
|
|
22
22
|
import { SystemMessage } from '../system-message/SystemMessage.js';
|
|
23
|
-
import { ListItem, StyledWrapperListItem, StyledWrapper, StyledChatContainerContentList, StyledChatContainerContentListScroll, StyledLoadMoreContainer } from './styled.js';
|
|
23
|
+
import { ListItem, StyledWrapperListItem, StyledWrapper, StyledChatContainerContentList, StyledChatContainerContentListScroll, StyledLoadMoreContainer, StyledNewMessagesHiddenContainer } from './styled.js';
|
|
24
24
|
import { listProps, defaultProps } from './props.js';
|
|
25
|
+
import { useGetNewMessages } from './useGetNewMessages.js';
|
|
25
26
|
import { jsx } from 'react/jsx-runtime';
|
|
26
27
|
|
|
27
28
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -75,6 +76,7 @@ const ChatContainerMessagesList = props => {
|
|
|
75
76
|
})), {}, {
|
|
76
77
|
estimateSize: React.useCallback(() => 80, [])
|
|
77
78
|
}));
|
|
79
|
+
const newMessages = useGetNewMessages(messages);
|
|
78
80
|
const debouncedScroll = React.useMemo(() => debounce(() => {
|
|
79
81
|
var _virtualListRef$curre;
|
|
80
82
|
|
|
@@ -192,7 +194,7 @@ const ChatContainerMessagesList = props => {
|
|
|
192
194
|
|
|
193
195
|
e.preventDefault();
|
|
194
196
|
(_loadMoreRef$current2 = loadMoreRef.current) === null || _loadMoreRef$current2 === void 0 ? void 0 : _loadMoreRef$current2.focus();
|
|
195
|
-
} else if (
|
|
197
|
+
} else if (!e.shiftKey) {
|
|
196
198
|
if (bannerPosition) {
|
|
197
199
|
e.preventDefault();
|
|
198
200
|
bannerRef.current.focusOnWrapper();
|
|
@@ -250,11 +252,6 @@ const ChatContainerMessagesList = props => {
|
|
|
250
252
|
|
|
251
253
|
e.preventDefault();
|
|
252
254
|
(_loadMoreRef$current3 = loadMoreRef.current) === null || _loadMoreRef$current3 === void 0 ? void 0 : _loadMoreRef$current3.focus();
|
|
253
|
-
} else if (hasMoreItems === 'top' && e.shiftKey) {
|
|
254
|
-
var _loadMoreRef$current4;
|
|
255
|
-
|
|
256
|
-
e.preventDefault();
|
|
257
|
-
(_loadMoreRef$current4 = loadMoreRef.current) === null || _loadMoreRef$current4 === void 0 ? void 0 : _loadMoreRef$current4.focus();
|
|
258
255
|
} else if (!e.shiftKey) {
|
|
259
256
|
e.preventDefault();
|
|
260
257
|
actionRef.current.focusToComposer();
|
|
@@ -331,8 +328,6 @@ const ChatContainerMessagesList = props => {
|
|
|
331
328
|
return /*#__PURE__*/_jsx(StyledWrapper, {}, void 0, /*#__PURE__*/jsx(StyledChatContainerContentList, {
|
|
332
329
|
"data-testid": "chat-thread-container",
|
|
333
330
|
tabIndex: 0,
|
|
334
|
-
"aria-live": "polite",
|
|
335
|
-
"aria-relevant": "additions",
|
|
336
331
|
ref: virtualListRef,
|
|
337
332
|
role: "list",
|
|
338
333
|
onKeyDown: handleListKey,
|
|
@@ -347,7 +342,10 @@ const ChatContainerMessagesList = props => {
|
|
|
347
342
|
"data-testid": "ds-chat-load-more-btn",
|
|
348
343
|
innerRef: loadMoreRef
|
|
349
344
|
})) : null, render)
|
|
350
|
-
})
|
|
345
|
+
}), /*#__PURE__*/_jsx(StyledNewMessagesHiddenContainer, {
|
|
346
|
+
"aria-live": "polite",
|
|
347
|
+
"aria-hidden": "false"
|
|
348
|
+
}, void 0, newMessages.map(newMessage => /*#__PURE__*/_jsx("p", {}, void 0, newMessage.title, " ", newMessage.time, " ", newMessage.body, " ", newMessage.errorMessage, " ", newMessage.helpMessage))));
|
|
351
349
|
};
|
|
352
350
|
|
|
353
351
|
ChatContainerMessagesList.defaultProps = defaultProps;
|
|
@@ -12,14 +12,17 @@ const StyledWrapperListItem = /*#__PURE__*/styled.div.withConfig({
|
|
|
12
12
|
const StyledChatContainerContentList = /*#__PURE__*/styled.div.withConfig({
|
|
13
13
|
componentId: "sc-1jhprzr-2"
|
|
14
14
|
})(["width:100%;height:100%;padding:", ";padding-bottom:0;overflow-y:auto;overflow-x:hidden;"], props => props.theme.space.xs);
|
|
15
|
-
const
|
|
15
|
+
const StyledNewMessagesHiddenContainer = /*#__PURE__*/styled.div.withConfig({
|
|
16
16
|
componentId: "sc-1jhprzr-3"
|
|
17
|
+
})(["position:absolute;width:1px;height:1px;margin:-1px;border:0;padding:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(100%);white-space:nowrap;"]);
|
|
18
|
+
const StyledChatContainerContentListScroll = /*#__PURE__*/styled.div.withConfig({
|
|
19
|
+
componentId: "sc-1jhprzr-4"
|
|
17
20
|
})(["width:100%;height:", ";position:relative;"], props => props.height);
|
|
18
21
|
const StyledLoadMoreContainer = /*#__PURE__*/styled.div.withConfig({
|
|
19
|
-
componentId: "sc-1jhprzr-
|
|
22
|
+
componentId: "sc-1jhprzr-5"
|
|
20
23
|
})(["position:absolute;width:calc(100% + ", ");padding:", ";left:-", ";right:-", ";display:grid;justify-content:center;align-items:center;", " ", ""], props => props.theme.space.xxs, props => props.theme.space.xxs, props => props.theme.space.xxs, props => props.theme.space.xxs, props => props.hasMoreItems === 'top' ? 'top: 0;' : '', props => props.hasMoreItems === 'bottom' ? 'bottom: 0;' : '');
|
|
21
24
|
const ListItem = /*#__PURE__*/styled.div.withConfig({
|
|
22
|
-
componentId: "sc-1jhprzr-
|
|
25
|
+
componentId: "sc-1jhprzr-6"
|
|
23
26
|
})(["&:focus,&:focus-visible{outline:none;&:after{content:'';display:block;position:absolute;top:0;left:-", ";pointer-events:none;border-radius:2px;background-color:#ebedf0;width:calc(100% + 24px);border:2px solid #1e79c2;height:100%;z-index:-1;}}"], props => props.theme.space.xxs);
|
|
24
27
|
|
|
25
|
-
export { ListItem, StyledChatContainerContentList, StyledChatContainerContentListScroll, StyledLoadMoreContainer, StyledWrapper, StyledWrapperListItem };
|
|
28
|
+
export { ListItem, StyledChatContainerContentList, StyledChatContainerContentListScroll, StyledLoadMoreContainer, StyledNewMessagesHiddenContainer, StyledWrapper, StyledWrapperListItem };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
7
|
+
import { useState, useMemo } from 'react';
|
|
8
|
+
|
|
9
|
+
const useGetNewMessages = messages => {
|
|
10
|
+
const [seenMessages, setSeenMessages] = useState({});
|
|
11
|
+
const newMessages = useMemo(() => {
|
|
12
|
+
const list = [];
|
|
13
|
+
messages.forEach(message => {
|
|
14
|
+
if (!(message.dsId in seenMessages)) {
|
|
15
|
+
list.push(message);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
setSeenMessages(Object.fromEntries(messages.map(m => [m.dsId, true])));
|
|
19
|
+
return list; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
20
|
+
}, [messages]);
|
|
21
|
+
return newMessages;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { useGetNewMessages };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-chat",
|
|
3
|
-
"version": "2.2.3-rc.
|
|
3
|
+
"version": "2.2.3-rc.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Chat",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -183,6 +183,10 @@
|
|
|
183
183
|
"import": "./esm/parts/chat-container/ChatContainer.js",
|
|
184
184
|
"require": "./cjs/parts/chat-container/ChatContainer.js"
|
|
185
185
|
},
|
|
186
|
+
"./parts/chat-container-messages-list/useGetNewMessages": {
|
|
187
|
+
"import": "./esm/parts/chat-container-messages-list/useGetNewMessages.js",
|
|
188
|
+
"require": "./cjs/parts/chat-container-messages-list/useGetNewMessages.js"
|
|
189
|
+
},
|
|
186
190
|
"./parts/chat-container-messages-list/styled": {
|
|
187
191
|
"import": "./esm/parts/chat-container-messages-list/styled.js",
|
|
188
192
|
"require": "./cjs/parts/chat-container-messages-list/styled.js"
|
|
@@ -305,15 +309,15 @@
|
|
|
305
309
|
"generateSubmodules": true
|
|
306
310
|
},
|
|
307
311
|
"dependencies": {
|
|
308
|
-
"@elliemae/ds-banner": "2.2.3-rc.
|
|
309
|
-
"@elliemae/ds-button": "2.2.3-rc.
|
|
310
|
-
"@elliemae/ds-grid": "2.2.3-rc.
|
|
311
|
-
"@elliemae/ds-icons": "2.2.3-rc.
|
|
312
|
-
"@elliemae/ds-indeterminate-progress-indicator": "2.2.3-rc.
|
|
313
|
-
"@elliemae/ds-props-helpers": "2.2.3-rc.
|
|
314
|
-
"@elliemae/ds-system": "2.2.3-rc.
|
|
315
|
-
"@elliemae/ds-tooltip": "2.2.3-rc.
|
|
316
|
-
"@elliemae/ds-truncated-tooltip-text": "2.2.3-rc.
|
|
312
|
+
"@elliemae/ds-banner": "2.2.3-rc.4",
|
|
313
|
+
"@elliemae/ds-button": "2.2.3-rc.4",
|
|
314
|
+
"@elliemae/ds-grid": "2.2.3-rc.4",
|
|
315
|
+
"@elliemae/ds-icons": "2.2.3-rc.4",
|
|
316
|
+
"@elliemae/ds-indeterminate-progress-indicator": "2.2.3-rc.4",
|
|
317
|
+
"@elliemae/ds-props-helpers": "2.2.3-rc.4",
|
|
318
|
+
"@elliemae/ds-system": "2.2.3-rc.4",
|
|
319
|
+
"@elliemae/ds-tooltip": "2.2.3-rc.4",
|
|
320
|
+
"@elliemae/ds-truncated-tooltip-text": "2.2.3-rc.4",
|
|
317
321
|
"prop-types": "~15.7.2",
|
|
318
322
|
"react-desc": "~4.1.2",
|
|
319
323
|
"react-virtual": "~2.3.2"
|
|
@@ -2,6 +2,7 @@ import { BubbleProps } from '../bubble/props';
|
|
|
2
2
|
export declare const StyledWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
3
3
|
export declare const StyledWrapperListItem: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, Partial<BubbleProps>, never>;
|
|
4
4
|
export declare const StyledChatContainerContentList: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
5
|
+
export declare const StyledNewMessagesHiddenContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
5
6
|
export declare const StyledChatContainerContentListScroll: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
6
7
|
height: string;
|
|
7
8
|
}, never>;
|