@elliemae/ds-chat 2.0.4 → 2.0.5
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 +6 -1
- 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 +7 -2
- 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 SystemMessage = require('../system-message/SystemMessage.js');
|
|
|
26
26
|
var styled = require('./styled.js');
|
|
27
27
|
var props = require('./props.js');
|
|
28
28
|
var useValidateProps = require('./config/useValidateProps.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$2 => {
|
|
|
86
87
|
})), {}, {
|
|
87
88
|
estimateSize: React__default["default"].useCallback(() => 80, [])
|
|
88
89
|
}));
|
|
90
|
+
const newMessages = useGetNewMessages.useGetNewMessages(messages);
|
|
89
91
|
const onScrollStop = React__default["default"].useCallback(() => {
|
|
90
92
|
var _virtualListRef$curre;
|
|
91
93
|
|
|
@@ -328,7 +330,10 @@ const ChatContainerMessagesList = props$2 => {
|
|
|
328
330
|
"data-testid": "ds-chat-load-more-btn",
|
|
329
331
|
innerRef: loadMoreRef
|
|
330
332
|
})) : null)
|
|
331
|
-
})
|
|
333
|
+
}), /*#__PURE__*/_jsx__default["default"](styled.StyledNewMessagesHiddenContainer, {
|
|
334
|
+
"aria-live": "polite",
|
|
335
|
+
"aria-hidden": "false"
|
|
336
|
+
}, void 0, newMessages.map(newMessage => /*#__PURE__*/_jsx__default["default"]("p", {}, void 0, newMessage.title, " ", newMessage.time, " ", newMessage.body, " ", newMessage.errorMessage, " ", newMessage.helpMessage))));
|
|
332
337
|
};
|
|
333
338
|
|
|
334
339
|
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;
|
|
@@ -19,9 +19,10 @@ import { ChatBubble } from '../bubble/ChatBubble.js';
|
|
|
19
19
|
import { BUBBLE_TYPES } from '../bubble/props.js';
|
|
20
20
|
import { MessageDelimiter } from '../message-delimiter/MessageDelimiter.js';
|
|
21
21
|
import { SystemMessage } from '../system-message/SystemMessage.js';
|
|
22
|
-
import { ListItem, StyledWrapperListItem, StyledWrapper, StyledChatContainerContentList, StyledChatContainerContentListScroll, StyledLoadMoreContainer } from './styled.js';
|
|
22
|
+
import { ListItem, StyledWrapperListItem, StyledWrapper, StyledChatContainerContentList, StyledChatContainerContentListScroll, StyledLoadMoreContainer, StyledNewMessagesHiddenContainer } from './styled.js';
|
|
23
23
|
import { listProps, defaultProps } from './props.js';
|
|
24
24
|
import { useValidateProps } from './config/useValidateProps.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 onScrollStop = React.useCallback(() => {
|
|
79
81
|
var _virtualListRef$curre;
|
|
80
82
|
|
|
@@ -317,7 +319,10 @@ const ChatContainerMessagesList = props => {
|
|
|
317
319
|
"data-testid": "ds-chat-load-more-btn",
|
|
318
320
|
innerRef: loadMoreRef
|
|
319
321
|
})) : null)
|
|
320
|
-
})
|
|
322
|
+
}), /*#__PURE__*/_jsx(StyledNewMessagesHiddenContainer, {
|
|
323
|
+
"aria-live": "polite",
|
|
324
|
+
"aria-hidden": "false"
|
|
325
|
+
}, void 0, newMessages.map(newMessage => /*#__PURE__*/_jsx("p", {}, void 0, newMessage.title, " ", newMessage.time, " ", newMessage.body, " ", newMessage.errorMessage, " ", newMessage.helpMessage))));
|
|
321
326
|
};
|
|
322
327
|
|
|
323
328
|
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.0.
|
|
3
|
+
"version": "2.0.5",
|
|
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.0.
|
|
309
|
-
"@elliemae/ds-button": "2.0.
|
|
310
|
-
"@elliemae/ds-grid": "2.0.
|
|
311
|
-
"@elliemae/ds-icons": "2.0.
|
|
312
|
-
"@elliemae/ds-indeterminate-progress-indicator": "2.0.
|
|
313
|
-
"@elliemae/ds-props-helpers": "2.0.
|
|
314
|
-
"@elliemae/ds-system": "2.0.
|
|
315
|
-
"@elliemae/ds-tooltip": "2.0.
|
|
316
|
-
"@elliemae/ds-truncated-tooltip-text": "2.0.
|
|
312
|
+
"@elliemae/ds-banner": "2.0.5",
|
|
313
|
+
"@elliemae/ds-button": "2.0.5",
|
|
314
|
+
"@elliemae/ds-grid": "2.0.5",
|
|
315
|
+
"@elliemae/ds-icons": "2.0.5",
|
|
316
|
+
"@elliemae/ds-indeterminate-progress-indicator": "2.0.5",
|
|
317
|
+
"@elliemae/ds-props-helpers": "2.0.5",
|
|
318
|
+
"@elliemae/ds-system": "2.0.5",
|
|
319
|
+
"@elliemae/ds-tooltip": "2.0.5",
|
|
320
|
+
"@elliemae/ds-truncated-tooltip-text": "2.0.5",
|
|
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>;
|