@elliemae/ds-chat 2.0.1 → 2.1.0-rc.2
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 +7 -5
- package/cjs/parts/chat-container/ChatContainer.js +24 -22
- package/cjs/parts/chat-container/styled.js +1 -1
- package/cjs/parts/chat-container-messages-list/ChatContainerMessagesList.js +69 -34
- package/cjs/parts/chat-sidebar/SideBarChat.js +2 -2
- package/cjs/parts/sidebar-button/SidebarButton.js +2 -2
- package/esm/parts/chat-composer/ChatContainerComposer.js +7 -5
- package/esm/parts/chat-container/ChatContainer.js +24 -22
- package/esm/parts/chat-container/styled.js +1 -1
- package/esm/parts/chat-container-messages-list/ChatContainerMessagesList.js +69 -34
- package/esm/parts/chat-sidebar/SideBarChat.js +2 -2
- package/esm/parts/sidebar-button/SidebarButton.js +2 -2
- package/package.json +11 -11
- package/types/parts/chat-card/ChatCard.d.ts +6 -6
- package/types/parts/chat-card/props.d.ts +6 -6
- package/types/parts/chat-composer/styled.d.ts +3 -155
- package/types/parts/chat-container/ChatContainer.d.ts +6 -6
- package/types/parts/chat-container-messages-list/ChatContainerMessagesList.d.ts +6 -6
- package/types/parts/message-delimiter/MessageDelimiter.d.ts +4 -4
- package/types/parts/message-delimiter/props.d.ts +4 -4
- package/types/parts/system-message/SystemMessage.d.ts +2 -2
- package/types/parts/system-message/props.d.ts +2 -2
- package/types/parts/tile-button/TileButton.d.ts +2 -2
- package/types/parts/tile-button/props.d.ts +2 -2
|
@@ -28,9 +28,9 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
28
28
|
|
|
29
29
|
var _PaperAirplane, _Grid;
|
|
30
30
|
|
|
31
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
31
|
+
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; }
|
|
32
32
|
|
|
33
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
33
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
34
34
|
|
|
35
35
|
const ChatComposer = props => {
|
|
36
36
|
var _input$current;
|
|
@@ -92,6 +92,9 @@ const ChatComposer = props => {
|
|
|
92
92
|
"data-testid": dataTestid
|
|
93
93
|
}, void 0, /*#__PURE__*/_jsx__default["default"](dsGrid.Grid, {
|
|
94
94
|
cols: ['1fr', '24px'],
|
|
95
|
+
style: {
|
|
96
|
+
height: heightProps.height
|
|
97
|
+
},
|
|
95
98
|
justifyContent: "center",
|
|
96
99
|
alignItems: "flex-end",
|
|
97
100
|
gutter: "xxs"
|
|
@@ -132,8 +135,7 @@ const ChatComposer = props => {
|
|
|
132
135
|
width: (_input$current = input.current) === null || _input$current === void 0 ? void 0 : _input$current.clientWidth
|
|
133
136
|
},
|
|
134
137
|
onChange: handleChange,
|
|
135
|
-
value: inputValue
|
|
136
|
-
|
|
138
|
+
value: inputValue
|
|
137
139
|
}), /*#__PURE__*/_jsx__default["default"](dsGrid.Grid, {
|
|
138
140
|
cols: ['1fr', '24px'],
|
|
139
141
|
justifyContent: "flex-end",
|
|
@@ -146,7 +148,7 @@ const ChatComposer = props => {
|
|
|
146
148
|
}, void 0, inputMaxLength && hasError ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
147
149
|
children: [/*#__PURE__*/_jsx__default["default"](styled.StyledCounterErrorA11y, {
|
|
148
150
|
role: "alert"
|
|
149
|
-
}, void 0, maxLengthMessage || "You have exceeded the
|
|
151
|
+
}, void 0, 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. ")]
|
|
150
152
|
}) : '', inputMaxLength ? " ".concat(inputLength, " / ").concat(inputMaxLength) : ''), _Grid || (_Grid = /*#__PURE__*/_jsx__default["default"](dsGrid.Grid, {}))));
|
|
151
153
|
};
|
|
152
154
|
|
|
@@ -29,11 +29,11 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
29
29
|
var DSIndeterminateProgressIndicator__default = /*#__PURE__*/_interopDefaultLegacy(DSIndeterminateProgressIndicator);
|
|
30
30
|
var DSBanner__default = /*#__PURE__*/_interopDefaultLegacy(DSBanner);
|
|
31
31
|
|
|
32
|
-
var _DSIndeterminateProgr
|
|
32
|
+
var _DSIndeterminateProgr;
|
|
33
33
|
|
|
34
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
34
|
+
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; }
|
|
35
35
|
|
|
36
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
36
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
37
37
|
|
|
38
38
|
const ChatContainer = props$1 => {
|
|
39
39
|
var _containerRef$current;
|
|
@@ -67,18 +67,16 @@ const ChatContainer = props$1 => {
|
|
|
67
67
|
});
|
|
68
68
|
const onResize = React__default["default"].useCallback(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(() => {
|
|
76
|
+
actionRef.current.scrollToIndex(messagesListProps.messages.length - 1, {
|
|
77
|
+
align: 'start'
|
|
78
|
+
});
|
|
79
|
+
}, 50);
|
|
82
80
|
}, [onComposerResize, messagesListProps.messages, actionRef]);
|
|
83
81
|
const Container = device === 'desktop' ? styled.StyledChatContainerContent : styled.MobileStyledChatContainerContent;
|
|
84
82
|
const handleTabs = React__default["default"].useCallback(e => {
|
|
@@ -86,17 +84,21 @@ const ChatContainer = props$1 => {
|
|
|
86
84
|
const 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
|
-
const last = ref.current.getMessagesInView().pop();
|
|
95
|
-
ref.current.focusToIndexWithoutScroll(last);
|
|
95
|
+
const 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__default["default"].useEffect(() => {
|
|
102
104
|
if (actionRef && actionRef.current) {
|
|
@@ -146,15 +148,15 @@ const ChatContainer = props$1 => {
|
|
|
146
148
|
isOpen: true,
|
|
147
149
|
type: bannerProps.type || DSBanner.BANNER_TYPES.INFO,
|
|
148
150
|
actionRef: bannerRef
|
|
149
|
-
})), sendingMessages && sendingMessages.length > 0 ?
|
|
151
|
+
})), sendingMessages && sendingMessages.length > 0 ? /*#__PURE__*/_jsx__default["default"](styled.StyledIndicatorContainer, {
|
|
150
152
|
isLoading: "bottom",
|
|
151
153
|
linear: true,
|
|
152
154
|
"data-testid": "ds-chat-loading-indicator"
|
|
153
155
|
}, void 0, /*#__PURE__*/_jsx__default["default"](DSIndeterminateProgressIndicator__default["default"], {
|
|
154
156
|
processing: true,
|
|
155
|
-
title:
|
|
157
|
+
title: sendingText,
|
|
156
158
|
lineOnly: true
|
|
157
|
-
}))
|
|
159
|
+
})) : null), /*#__PURE__*/jsxRuntime.jsx(ChatContainerComposer.ChatComposer, _objectSpread(_objectSpread({}, composerProps), {}, {
|
|
158
160
|
onKeyDown: handleTabs,
|
|
159
161
|
onResize: onResize,
|
|
160
162
|
maxHeight: (((_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.clientHeight) || 0) / 2,
|
|
@@ -18,7 +18,7 @@ const StyledChatContainerContent = /*#__PURE__*/styled__default["default"](dsGri
|
|
|
18
18
|
})(["height:100%;min-width:", "px;overflow:hidden;background:", ";position:relative;"], CONTAINER_WIDTH, props => props.theme.colors.neutral['050']);
|
|
19
19
|
const StyledIndicatorContainer = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
20
20
|
componentId: "sc-d732wo-1"
|
|
21
|
-
})(["transition:0.4s ease-in-out;position:absolute;visibility:hidden;pointer-events:none;width:100%;padding:0 ", ";left:0;right:0;background:", ";", " ", " & div,a{font-size:13px;}"], props => !props.linear ? props.theme.space.xxs : 0, props => props.theme.colors.neutral['000'], props => props.isLoading === 'top' ? "\n top: -41px;\n transform: translate(0, 41px);\n visibility: visible;\n pointer-events: auto
|
|
21
|
+
})(["transition:0.4s ease-in-out;position:absolute;visibility:hidden;pointer-events:none;width:100%;padding:0 ", ";left:0;right:0;background:", ";", " ", " & div,a{font-size:13px;}"], props => !props.linear ? props.theme.space.xxs : 0, props => props.theme.colors.neutral['000'], props => props.isLoading === 'top' ? "\n top: -41px;\n transform: translate(0, 41px);\n visibility: visible;\n pointer-events: auto;\n " : '', props => props.isLoading === 'bottom' ? "\n bottom: -41px;\n transform: translate(0, -41px);\n visibility: visible;\n pointer-events: auto;\n " : '');
|
|
22
22
|
const MobileStyledChatContainerContent = /*#__PURE__*/styled__default["default"](StyledChatContainerContent).withConfig({
|
|
23
23
|
componentId: "sc-d732wo-2"
|
|
24
24
|
})(["", ",", "{font-size:16px;}", "{font-size:13px;}", "{background-color:#fff;box-shadow:-0 1px 3px rgba(53,60,70,0.8);}", ",", "{font-size:16px;text-align:left;}", "{font-size:13px;}", "{font-size:16px;}", "{font-size:16px;}"], styled$1.StyledTitleLeftBubble, styled$1.StyleBodyWrapper, styled$1.StyledTitleRightBubble, style.Wrapper, style.Title, style.Message, style.Time, styled$2.StyledComposerInput, StyledIndicatorContainer);
|
|
@@ -19,6 +19,7 @@ var React = require('react');
|
|
|
19
19
|
var reactDesc = require('react-desc');
|
|
20
20
|
var reactVirtual = require('react-virtual');
|
|
21
21
|
var DSButton = require('@elliemae/ds-button');
|
|
22
|
+
var lodash = require('lodash');
|
|
22
23
|
var ChatBubble = require('../bubble/ChatBubble.js');
|
|
23
24
|
var props$1 = require('../bubble/props.js');
|
|
24
25
|
var MessageDelimiter = require('../message-delimiter/MessageDelimiter.js');
|
|
@@ -35,9 +36,9 @@ var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_definePropert
|
|
|
35
36
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
36
37
|
var DSButton__default = /*#__PURE__*/_interopDefaultLegacy(DSButton);
|
|
37
38
|
|
|
38
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
39
|
+
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; }
|
|
39
40
|
|
|
40
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
41
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
41
42
|
|
|
42
43
|
const getPadding = _ref => {
|
|
43
44
|
let {
|
|
@@ -67,6 +68,7 @@ const ChatContainerMessagesList = props$2 => {
|
|
|
67
68
|
isLoading,
|
|
68
69
|
bannerRef
|
|
69
70
|
} = props$2;
|
|
71
|
+
const pendingOnScroll = React__default["default"].useRef(false);
|
|
70
72
|
const loadMoreRef = React__default["default"].useRef(null);
|
|
71
73
|
const virtualListRef = React__default["default"].useRef(); // estimateSize should not be really required given what was stated on
|
|
72
74
|
// https://github.com/tannerlinsley/react-virtual/issues/23
|
|
@@ -86,9 +88,15 @@ const ChatContainerMessagesList = props$2 => {
|
|
|
86
88
|
})), {}, {
|
|
87
89
|
estimateSize: React__default["default"].useCallback(() => 80, [])
|
|
88
90
|
}));
|
|
89
|
-
const
|
|
91
|
+
const debouncedScroll = React__default["default"].useMemo(() => lodash.debounce(() => {
|
|
90
92
|
var _virtualListRef$curre;
|
|
91
93
|
|
|
94
|
+
if (document.visibilityState === 'hidden') {
|
|
95
|
+
pendingOnScroll.current = true;
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
pendingOnScroll.current = false;
|
|
92
100
|
const {
|
|
93
101
|
bottom,
|
|
94
102
|
top
|
|
@@ -97,15 +105,15 @@ const ChatContainerMessagesList = props$2 => {
|
|
|
97
105
|
const indexList = [];
|
|
98
106
|
list.forEach(item => {
|
|
99
107
|
const {
|
|
100
|
-
top: itemTop
|
|
101
|
-
bottom: itemBottom
|
|
108
|
+
top: itemTop
|
|
102
109
|
} = item.getBoundingClientRect();
|
|
103
110
|
const itemPadding = 10;
|
|
104
|
-
if (itemTop + itemPadding < bottom &&
|
|
111
|
+
if (itemTop + itemPadding < bottom && itemTop + itemPadding > top) indexList.push(item.dataset.index);
|
|
105
112
|
});
|
|
106
113
|
if (onScrollEnds) onScrollEnds(indexList);
|
|
107
114
|
return indexList;
|
|
108
|
-
}, [onScrollEnds]);
|
|
115
|
+
}, 500), [onScrollEnds]);
|
|
116
|
+
const onScrollStop = React__default["default"].useCallback(debouncedScroll, [debouncedScroll]);
|
|
109
117
|
const onlyFocus = React__default["default"].useCallback(index => {
|
|
110
118
|
setTimeout(() => {
|
|
111
119
|
virtualListRef.current.querySelector("[data-index=\"".concat(index, "\"]")).focus();
|
|
@@ -117,7 +125,8 @@ const ChatContainerMessagesList = props$2 => {
|
|
|
117
125
|
};
|
|
118
126
|
vScroll(index, b);
|
|
119
127
|
onlyFocus(index);
|
|
120
|
-
|
|
128
|
+
onScrollStop();
|
|
129
|
+
}, [onScrollStop, onlyFocus, vScroll]);
|
|
121
130
|
React__default["default"].useEffect(() => {
|
|
122
131
|
if (actionRef && actionRef.current) {
|
|
123
132
|
actionRef.current.scrollToIndex = function (a) {
|
|
@@ -125,6 +134,7 @@ const ChatContainerMessagesList = props$2 => {
|
|
|
125
134
|
align: 'center'
|
|
126
135
|
};
|
|
127
136
|
vScroll(a, b);
|
|
137
|
+
onScrollStop();
|
|
128
138
|
};
|
|
129
139
|
|
|
130
140
|
actionRef.current.getMessagesInView = onScrollStop;
|
|
@@ -138,7 +148,7 @@ const ChatContainerMessagesList = props$2 => {
|
|
|
138
148
|
|
|
139
149
|
actionRef.current.focusToIndexWithoutScroll = onlyFocus;
|
|
140
150
|
|
|
141
|
-
actionRef.current.focusToList =
|
|
151
|
+
actionRef.current.focusToList = () => {
|
|
142
152
|
var _virtualListRef$curre2;
|
|
143
153
|
|
|
144
154
|
(_virtualListRef$curre2 = virtualListRef.current) === null || _virtualListRef$curre2 === void 0 ? void 0 : _virtualListRef$curre2.focus();
|
|
@@ -155,7 +165,17 @@ const ChatContainerMessagesList = props$2 => {
|
|
|
155
165
|
switch (key) {
|
|
156
166
|
case 'ArrowUp':
|
|
157
167
|
e.preventDefault();
|
|
158
|
-
|
|
168
|
+
|
|
169
|
+
if (index > 0) {
|
|
170
|
+
var _virtualListRef$curre3;
|
|
171
|
+
|
|
172
|
+
((_virtualListRef$curre3 = virtualListRef.current) === null || _virtualListRef$curre3 === void 0 ? void 0 : _virtualListRef$curre3.querySelector("[data-index=\"".concat(index - 1, "\"]"))).focus();
|
|
173
|
+
} else if (hasMoreItems === 'top') {
|
|
174
|
+
var _loadMoreRef$current;
|
|
175
|
+
|
|
176
|
+
(_loadMoreRef$current = loadMoreRef.current) === null || _loadMoreRef$current === void 0 ? void 0 : _loadMoreRef$current.focus();
|
|
177
|
+
}
|
|
178
|
+
|
|
159
179
|
break;
|
|
160
180
|
|
|
161
181
|
case 'ArrowDown':
|
|
@@ -178,31 +198,31 @@ const ChatContainerMessagesList = props$2 => {
|
|
|
178
198
|
break;
|
|
179
199
|
|
|
180
200
|
case 'Tab':
|
|
181
|
-
e.preventDefault();
|
|
182
|
-
|
|
183
201
|
if (hasMoreItems === 'bottom' && !e.shiftKey) {
|
|
184
|
-
var _loadMoreRef$current;
|
|
185
|
-
|
|
186
|
-
(_loadMoreRef$current = loadMoreRef.current) === null || _loadMoreRef$current === void 0 ? void 0 : _loadMoreRef$current.focus();
|
|
187
|
-
} else if (hasMoreItems === 'top' && e.shiftKey) {
|
|
188
202
|
var _loadMoreRef$current2;
|
|
189
203
|
|
|
204
|
+
e.preventDefault();
|
|
190
205
|
(_loadMoreRef$current2 = loadMoreRef.current) === null || _loadMoreRef$current2 === void 0 ? void 0 : _loadMoreRef$current2.focus();
|
|
206
|
+
} else if (hasMoreItems === 'top' && e.shiftKey) {
|
|
207
|
+
var _loadMoreRef$current3;
|
|
208
|
+
|
|
209
|
+
e.preventDefault();
|
|
210
|
+
(_loadMoreRef$current3 = loadMoreRef.current) === null || _loadMoreRef$current3 === void 0 ? void 0 : _loadMoreRef$current3.focus();
|
|
191
211
|
} else if (!e.shiftKey) {
|
|
192
212
|
if (bannerPosition) {
|
|
213
|
+
e.preventDefault();
|
|
193
214
|
bannerRef.current.focusOnWrapper();
|
|
194
|
-
} else {
|
|
195
|
-
actionRef.current.focusToComposer();
|
|
196
215
|
}
|
|
197
216
|
} else {
|
|
198
|
-
var _virtualListRef$
|
|
217
|
+
var _virtualListRef$curre4;
|
|
199
218
|
|
|
200
|
-
|
|
219
|
+
e.preventDefault();
|
|
220
|
+
(_virtualListRef$curre4 = virtualListRef.current) === null || _virtualListRef$curre4 === void 0 ? void 0 : _virtualListRef$curre4.focus();
|
|
201
221
|
}
|
|
202
222
|
|
|
203
223
|
break;
|
|
204
224
|
}
|
|
205
|
-
}, [actionRef, hasMoreItems, messages.length, bannerPosition, scrollAndFocus]);
|
|
225
|
+
}, [actionRef, bannerRef, hasMoreItems, messages.length, bannerPosition, scrollAndFocus]);
|
|
206
226
|
const handleListKey = React__default["default"].useCallback(e => {
|
|
207
227
|
const {
|
|
208
228
|
key
|
|
@@ -211,12 +231,22 @@ const ChatContainerMessagesList = props$2 => {
|
|
|
211
231
|
switch (key) {
|
|
212
232
|
case 'ArrowUp':
|
|
213
233
|
e.preventDefault();
|
|
214
|
-
|
|
234
|
+
|
|
235
|
+
if (document.activeElement !== loadMoreRef.current) {
|
|
236
|
+
onlyFocus(onScrollStop().shift());
|
|
237
|
+
}
|
|
238
|
+
|
|
215
239
|
break;
|
|
216
240
|
|
|
217
241
|
case 'ArrowDown':
|
|
218
242
|
e.preventDefault();
|
|
219
|
-
|
|
243
|
+
|
|
244
|
+
if (document.activeElement === loadMoreRef.current) {
|
|
245
|
+
virtualListRef.current.querySelector("[data-index=\"0\"]").focus();
|
|
246
|
+
} else {
|
|
247
|
+
onlyFocus(onScrollStop().pop());
|
|
248
|
+
}
|
|
249
|
+
|
|
220
250
|
break;
|
|
221
251
|
|
|
222
252
|
case 'Home':
|
|
@@ -232,15 +262,15 @@ const ChatContainerMessagesList = props$2 => {
|
|
|
232
262
|
case 'Tab':
|
|
233
263
|
if (document.activeElement !== loadMoreRef.current) {
|
|
234
264
|
if (hasMoreItems === 'bottom' && !e.shiftKey) {
|
|
235
|
-
var _loadMoreRef$
|
|
265
|
+
var _loadMoreRef$current4;
|
|
236
266
|
|
|
237
267
|
e.preventDefault();
|
|
238
|
-
(_loadMoreRef$
|
|
268
|
+
(_loadMoreRef$current4 = loadMoreRef.current) === null || _loadMoreRef$current4 === void 0 ? void 0 : _loadMoreRef$current4.focus();
|
|
239
269
|
} else if (hasMoreItems === 'top' && e.shiftKey) {
|
|
240
|
-
var _loadMoreRef$
|
|
270
|
+
var _loadMoreRef$current5;
|
|
241
271
|
|
|
242
272
|
e.preventDefault();
|
|
243
|
-
(_loadMoreRef$
|
|
273
|
+
(_loadMoreRef$current5 = loadMoreRef.current) === null || _loadMoreRef$current5 === void 0 ? void 0 : _loadMoreRef$current5.focus();
|
|
244
274
|
} else if (!e.shiftKey) {
|
|
245
275
|
e.preventDefault();
|
|
246
276
|
actionRef.current.focusToComposer();
|
|
@@ -249,15 +279,18 @@ const ChatContainerMessagesList = props$2 => {
|
|
|
249
279
|
e.preventDefault();
|
|
250
280
|
actionRef.current.focusToComposer();
|
|
251
281
|
} else {
|
|
252
|
-
var _virtualListRef$
|
|
282
|
+
var _virtualListRef$curre5;
|
|
253
283
|
|
|
254
284
|
e.preventDefault();
|
|
255
|
-
(_virtualListRef$
|
|
285
|
+
(_virtualListRef$curre5 = virtualListRef.current) === null || _virtualListRef$curre5 === void 0 ? void 0 : _virtualListRef$curre5.focus();
|
|
256
286
|
}
|
|
257
287
|
|
|
258
288
|
break;
|
|
259
289
|
}
|
|
260
290
|
}, [actionRef, hasMoreItems, messages.length, onScrollStop, onlyFocus, scrollAndFocus]);
|
|
291
|
+
const checkPendingOnScroll = React__default["default"].useCallback(() => {
|
|
292
|
+
if (pendingOnScroll.current === true) onScrollStop();
|
|
293
|
+
}, [onScrollStop]);
|
|
261
294
|
React__default["default"].useEffect(() => {
|
|
262
295
|
let handlerCallback = null;
|
|
263
296
|
const localVirtualRef = virtualListRef.current;
|
|
@@ -271,11 +304,13 @@ const ChatContainerMessagesList = props$2 => {
|
|
|
271
304
|
virtualListRef.current.addEventListener('scroll', onScroll);
|
|
272
305
|
}
|
|
273
306
|
|
|
307
|
+
document.addEventListener('visibilitychange', checkPendingOnScroll);
|
|
274
308
|
return () => {
|
|
275
309
|
if (handlerCallback) clearTimeout(handlerCallback);
|
|
276
310
|
if (onScrollEnds) localVirtualRef.removeEventListener('scroll', onScroll);
|
|
311
|
+
document.removeEventListener('visibilitychange', checkPendingOnScroll);
|
|
277
312
|
};
|
|
278
|
-
}, [onScrollStop, onScrollEnds]);
|
|
313
|
+
}, [onScrollStop, onScrollEnds, checkPendingOnScroll]);
|
|
279
314
|
const render = React__default["default"].useMemo(() => virtualItems.map(virtualItem => {
|
|
280
315
|
const {
|
|
281
316
|
index,
|
|
@@ -296,14 +331,14 @@ const ChatContainerMessagesList = props$2 => {
|
|
|
296
331
|
"data-index": index,
|
|
297
332
|
style: style,
|
|
298
333
|
ref: measureRef,
|
|
299
|
-
tabIndex:
|
|
334
|
+
tabIndex: -1,
|
|
300
335
|
onKeyDown: handleKey,
|
|
301
336
|
role: "listitem",
|
|
302
337
|
children: /*#__PURE__*/_jsx__default["default"](styled.StyledWrapperListItem, {
|
|
303
338
|
type: row.type
|
|
304
339
|
}, void 0, row.type === props$1.BUBBLE_TYPES.SENDER || row.type === props$1.BUBBLE_TYPES.RECIPIENT ?
|
|
305
340
|
/*#__PURE__*/
|
|
306
|
-
// eslint-disable-next-line
|
|
341
|
+
// eslint-disable-next-line eslint-comments/no-unlimited-disable
|
|
307
342
|
jsxRuntime.jsx(ChatBubble.ChatBubble, _objectSpread(_objectSpread({}, row), {}, {
|
|
308
343
|
helpMessage: isSending ? sendingText : row.helpMessage
|
|
309
344
|
})) : null, row.type === props$1.BUBBLE_TYPES.DELIMITER ? /*#__PURE__*/jsxRuntime.jsx(MessageDelimiter.MessageDelimiter, _objectSpread({}, row)) : null, row.type === props$1.BUBBLE_TYPES.SYSTEM ? /*#__PURE__*/jsxRuntime.jsx(SystemMessage.SystemMessage, _objectSpread({}, row)) : null)
|
|
@@ -319,7 +354,7 @@ const ChatContainerMessagesList = props$2 => {
|
|
|
319
354
|
onKeyDown: handleListKey,
|
|
320
355
|
children: /*#__PURE__*/_jsx__default["default"](styled.StyledChatContainerContentListScroll, {
|
|
321
356
|
height: "".concat(totalSize, "px")
|
|
322
|
-
}, void 0,
|
|
357
|
+
}, void 0, !isLoading && hasMoreItems ? /*#__PURE__*/_jsx__default["default"](styled.StyledLoadMoreContainer, {
|
|
323
358
|
hasMoreItems: hasMoreItems
|
|
324
359
|
}, void 0, /*#__PURE__*/_jsx__default["default"](DSButton__default["default"], {
|
|
325
360
|
labelText: "Load More",
|
|
@@ -327,7 +362,7 @@ const ChatContainerMessagesList = props$2 => {
|
|
|
327
362
|
onClick: getMoreMessages,
|
|
328
363
|
"data-testid": "ds-chat-load-more-btn",
|
|
329
364
|
innerRef: loadMoreRef
|
|
330
|
-
})) : null)
|
|
365
|
+
})) : null, render)
|
|
331
366
|
}));
|
|
332
367
|
};
|
|
333
368
|
|
|
@@ -28,9 +28,9 @@ var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_definePropert
|
|
|
28
28
|
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
29
29
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
30
30
|
|
|
31
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
31
|
+
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; }
|
|
32
32
|
|
|
33
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
33
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
34
34
|
|
|
35
35
|
const FooterChat = _ref => {
|
|
36
36
|
let {
|
|
@@ -24,9 +24,9 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
24
24
|
|
|
25
25
|
const _excluded = ["label", "dsId", "onClick", "Icon"];
|
|
26
26
|
|
|
27
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
27
|
+
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; }
|
|
28
28
|
|
|
29
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
29
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
30
30
|
const SidebarButton = _ref => {
|
|
31
31
|
let {
|
|
32
32
|
label,
|
|
@@ -18,9 +18,9 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
18
18
|
|
|
19
19
|
var _PaperAirplane, _Grid;
|
|
20
20
|
|
|
21
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
21
|
+
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; }
|
|
22
22
|
|
|
23
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
23
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
24
24
|
|
|
25
25
|
const ChatComposer = props => {
|
|
26
26
|
var _input$current;
|
|
@@ -82,6 +82,9 @@ const ChatComposer = props => {
|
|
|
82
82
|
"data-testid": dataTestid
|
|
83
83
|
}, void 0, /*#__PURE__*/_jsx(Grid, {
|
|
84
84
|
cols: ['1fr', '24px'],
|
|
85
|
+
style: {
|
|
86
|
+
height: heightProps.height
|
|
87
|
+
},
|
|
85
88
|
justifyContent: "center",
|
|
86
89
|
alignItems: "flex-end",
|
|
87
90
|
gutter: "xxs"
|
|
@@ -122,8 +125,7 @@ const ChatComposer = props => {
|
|
|
122
125
|
width: (_input$current = input.current) === null || _input$current === void 0 ? void 0 : _input$current.clientWidth
|
|
123
126
|
},
|
|
124
127
|
onChange: handleChange,
|
|
125
|
-
value: inputValue
|
|
126
|
-
|
|
128
|
+
value: inputValue
|
|
127
129
|
}), /*#__PURE__*/_jsx(Grid, {
|
|
128
130
|
cols: ['1fr', '24px'],
|
|
129
131
|
justifyContent: "flex-end",
|
|
@@ -136,7 +138,7 @@ const ChatComposer = props => {
|
|
|
136
138
|
}, void 0, inputMaxLength && hasError ? /*#__PURE__*/jsxs(Fragment, {
|
|
137
139
|
children: [/*#__PURE__*/_jsx(StyledCounterErrorA11y, {
|
|
138
140
|
role: "alert"
|
|
139
|
-
}, void 0, maxLengthMessage || "You have exceeded the
|
|
141
|
+
}, void 0, 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. ")]
|
|
140
142
|
}) : '', inputMaxLength ? " ".concat(inputLength, " / ").concat(inputMaxLength) : ''), _Grid || (_Grid = /*#__PURE__*/_jsx(Grid, {}))));
|
|
141
143
|
};
|
|
142
144
|
|
|
@@ -17,11 +17,11 @@ import { StyledIndicatorContainer, StyledChatContainerContent, MobileStyledChatC
|
|
|
17
17
|
import { useValidateProps } from './config/useValidateProps.js';
|
|
18
18
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
19
19
|
|
|
20
|
-
var _DSIndeterminateProgr
|
|
20
|
+
var _DSIndeterminateProgr;
|
|
21
21
|
|
|
22
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
22
|
+
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; }
|
|
23
23
|
|
|
24
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
24
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
25
25
|
|
|
26
26
|
const ChatContainer = props => {
|
|
27
27
|
var _containerRef$current;
|
|
@@ -55,18 +55,16 @@ const ChatContainer = props => {
|
|
|
55
55
|
});
|
|
56
56
|
const onResize = React.useCallback(height => {
|
|
57
57
|
if (onComposerResize) onComposerResize(height);
|
|
58
|
-
|
|
59
|
-
if (height > 30) {
|
|
60
|
-
/*
|
|
58
|
+
/*
|
|
61
59
|
setTimeout is used to equal the animation duration from the
|
|
62
60
|
composer text area when increase its size
|
|
63
61
|
*/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
}
|
|
62
|
+
|
|
63
|
+
setTimeout(() => {
|
|
64
|
+
actionRef.current.scrollToIndex(messagesListProps.messages.length - 1, {
|
|
65
|
+
align: 'start'
|
|
66
|
+
});
|
|
67
|
+
}, 50);
|
|
70
68
|
}, [onComposerResize, messagesListProps.messages, actionRef]);
|
|
71
69
|
const Container = device === 'desktop' ? StyledChatContainerContent : MobileStyledChatContainerContent;
|
|
72
70
|
const handleTabs = React.useCallback(e => {
|
|
@@ -74,17 +72,21 @@ const ChatContainer = props => {
|
|
|
74
72
|
const ref = actionRef || listRef;
|
|
75
73
|
|
|
76
74
|
if (e.shiftKey && e.key === 'Tab') {
|
|
77
|
-
|
|
75
|
+
if (messagesListProps.messages.length > 0) {
|
|
76
|
+
e.preventDefault();
|
|
77
|
+
|
|
78
|
+
if (['top', 'bottom'].includes(bannerPosition)) {
|
|
79
|
+
bannerRef.current.focusOnWrapper();
|
|
80
|
+
} else {
|
|
81
|
+
var _ref$current;
|
|
78
82
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const last = ref.current.getMessagesInView().pop();
|
|
83
|
-
ref.current.focusToIndexWithoutScroll(last);
|
|
83
|
+
const last = ref.current.getMessagesInView().pop();
|
|
84
|
+
(_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focusToIndexWithoutScroll(last);
|
|
85
|
+
}
|
|
84
86
|
}
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
|
-
}, [actionRef, onComposerKeyDown, bannerPosition]); // Map actions
|
|
89
|
+
}, [actionRef, onComposerKeyDown, bannerPosition, messagesListProps.messages.length]); // Map actions
|
|
88
90
|
|
|
89
91
|
React.useEffect(() => {
|
|
90
92
|
if (actionRef && actionRef.current) {
|
|
@@ -134,15 +136,15 @@ const ChatContainer = props => {
|
|
|
134
136
|
isOpen: true,
|
|
135
137
|
type: bannerProps.type || BANNER_TYPES.INFO,
|
|
136
138
|
actionRef: bannerRef
|
|
137
|
-
})), sendingMessages && sendingMessages.length > 0 ?
|
|
139
|
+
})), sendingMessages && sendingMessages.length > 0 ? /*#__PURE__*/_jsx(StyledIndicatorContainer, {
|
|
138
140
|
isLoading: "bottom",
|
|
139
141
|
linear: true,
|
|
140
142
|
"data-testid": "ds-chat-loading-indicator"
|
|
141
143
|
}, void 0, /*#__PURE__*/_jsx(DSIndeterminateProgressIndicator, {
|
|
142
144
|
processing: true,
|
|
143
|
-
title:
|
|
145
|
+
title: sendingText,
|
|
144
146
|
lineOnly: true
|
|
145
|
-
}))
|
|
147
|
+
})) : null), /*#__PURE__*/jsx(ChatComposer, _objectSpread(_objectSpread({}, composerProps), {}, {
|
|
146
148
|
onKeyDown: handleTabs,
|
|
147
149
|
onResize: onResize,
|
|
148
150
|
maxHeight: (((_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.clientHeight) || 0) / 2,
|
|
@@ -10,7 +10,7 @@ const StyledChatContainerContent = /*#__PURE__*/styled(Grid).withConfig({
|
|
|
10
10
|
})(["height:100%;min-width:", "px;overflow:hidden;background:", ";position:relative;"], CONTAINER_WIDTH, props => props.theme.colors.neutral['050']);
|
|
11
11
|
const StyledIndicatorContainer = /*#__PURE__*/styled.div.withConfig({
|
|
12
12
|
componentId: "sc-d732wo-1"
|
|
13
|
-
})(["transition:0.4s ease-in-out;position:absolute;visibility:hidden;pointer-events:none;width:100%;padding:0 ", ";left:0;right:0;background:", ";", " ", " & div,a{font-size:13px;}"], props => !props.linear ? props.theme.space.xxs : 0, props => props.theme.colors.neutral['000'], props => props.isLoading === 'top' ? "\n top: -41px;\n transform: translate(0, 41px);\n visibility: visible;\n pointer-events: auto
|
|
13
|
+
})(["transition:0.4s ease-in-out;position:absolute;visibility:hidden;pointer-events:none;width:100%;padding:0 ", ";left:0;right:0;background:", ";", " ", " & div,a{font-size:13px;}"], props => !props.linear ? props.theme.space.xxs : 0, props => props.theme.colors.neutral['000'], props => props.isLoading === 'top' ? "\n top: -41px;\n transform: translate(0, 41px);\n visibility: visible;\n pointer-events: auto;\n " : '', props => props.isLoading === 'bottom' ? "\n bottom: -41px;\n transform: translate(0, -41px);\n visibility: visible;\n pointer-events: auto;\n " : '');
|
|
14
14
|
const MobileStyledChatContainerContent = /*#__PURE__*/styled(StyledChatContainerContent).withConfig({
|
|
15
15
|
componentId: "sc-d732wo-2"
|
|
16
16
|
})(["", ",", "{font-size:16px;}", "{font-size:13px;}", "{background-color:#fff;box-shadow:-0 1px 3px rgba(53,60,70,0.8);}", ",", "{font-size:16px;text-align:left;}", "{font-size:13px;}", "{font-size:16px;}", "{font-size:16px;}"], StyledTitleLeftBubble, StyleBodyWrapper, StyledTitleRightBubble, Wrapper, Title, Message, Time, StyledComposerInput, StyledIndicatorContainer);
|