@elliemae/ds-chat 2.1.0-rc.4 → 2.2.0-alpha.1

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.
@@ -21,7 +21,8 @@ const ChatDataTestIds = {
21
21
  SYSTEM_MSG_TIME: 'chat-system-message-time',
22
22
  BUBBLE: 'ds-chat-bubble',
23
23
  BUBBLE_TITLE: 'chat-bubble-title',
24
- BUBBLE_BODY: 'chat-bubble-body'
24
+ BUBBLE_BODY: 'chat-bubble-body',
25
+ BANNER: 'ds-banner-container'
25
26
  };
26
27
 
27
28
  exports.ChatDataTestIds = ChatDataTestIds;
@@ -52,6 +52,7 @@ const ChatComposer = props => {
52
52
  dataTestid,
53
53
  actionRef
54
54
  } = props;
55
+ const COMPOSER_MIN_HEIGHT = 32;
55
56
  const input = React__default["default"].useRef();
56
57
  const inputSize = React__default["default"].useRef();
57
58
  const inputSend = React__default["default"].useRef();
@@ -62,10 +63,10 @@ const ChatComposer = props => {
62
63
  var _inputSize$current, _inputSize$current2, _inputSize$current3, _inputSize$current4;
63
64
 
64
65
  const newHeight = ((_inputSize$current = inputSize.current) === null || _inputSize$current === void 0 ? void 0 : _inputSize$current.scrollHeight) > internalMaxHeight ? internalMaxHeight : (_inputSize$current2 = inputSize.current) === null || _inputSize$current2 === void 0 ? void 0 : _inputSize$current2.scrollHeight;
65
- onResize(newHeight);
66
+ if (newHeight !== height && newHeight > COMPOSER_MIN_HEIGHT) onResize(newHeight);
66
67
  setHeight(newHeight);
67
68
  setShowScroll(((_inputSize$current3 = inputSize.current) === null || _inputSize$current3 === void 0 ? void 0 : _inputSize$current3.scrollHeight) - ((_inputSize$current4 = inputSize.current) === null || _inputSize$current4 === void 0 ? void 0 : _inputSize$current4.clientHeight) > 5);
68
- }, [inputValue, internalMaxHeight, onResize]);
69
+ }, [inputValue, internalMaxHeight, height, onResize]);
69
70
  React__default["default"].useEffect(() => {
70
71
  if (actionRef && actionRef.current) {
71
72
  actionRef.current.focusToComposer = () => {
@@ -108,7 +109,9 @@ const ChatComposer = props => {
108
109
  onKeyDown: onKeyDown,
109
110
  placeholder: placeholder,
110
111
  "aria-label": "Message to send",
111
- "data-testid": "chat-composer-textarea"
112
+ "data-testid": "chat-composer-textarea",
113
+ name: "chat-composer-textarea",
114
+ id: "chat-composer-textarea"
112
115
  }), /*#__PURE__*/_jsx__default["default"](dsGrid.Grid, {
113
116
  height: "32px",
114
117
  alignItems: "center"
@@ -149,7 +152,7 @@ const ChatComposer = props => {
149
152
  children: [/*#__PURE__*/_jsx__default["default"](styled.StyledCounterErrorA11y, {
150
153
  role: "alert"
151
154
  }, 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. ")]
152
- }) : '', inputMaxLength ? " ".concat(inputLength, " / ").concat(inputMaxLength) : ''), _Grid || (_Grid = /*#__PURE__*/_jsx__default["default"](dsGrid.Grid, {}))));
155
+ }) : '', inputMaxLength && !maxLengthMessage ? " ".concat(inputLength, " / ").concat(inputMaxLength) : ''), _Grid || (_Grid = /*#__PURE__*/_jsx__default["default"](dsGrid.Grid, {}))));
153
156
  };
154
157
 
155
158
  ChatComposer.defaultProps = props.defaultComposerPros;
@@ -36,7 +36,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
36
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
- var _containerRef$current;
39
+ var _messagesListProps$me2, _containerRef$current;
40
40
 
41
41
  useValidateProps.useValidateProps(props$1, props.containerProps);
42
42
  const {
@@ -84,7 +84,9 @@ const ChatContainer = props$1 => {
84
84
  const ref = actionRef || listRef;
85
85
 
86
86
  if (e.shiftKey && e.key === 'Tab') {
87
- if (messagesListProps.messages.length > 0) {
87
+ var _messagesListProps$me;
88
+
89
+ if (((_messagesListProps$me = messagesListProps.messages) === null || _messagesListProps$me === void 0 ? void 0 : _messagesListProps$me.length) > 0) {
88
90
  e.preventDefault();
89
91
 
90
92
  if (['top', 'bottom'].includes(bannerPosition)) {
@@ -98,7 +100,7 @@ const ChatContainer = props$1 => {
98
100
  }
99
101
  }
100
102
  }
101
- }, [actionRef, onComposerKeyDown, bannerPosition, messagesListProps.messages.length]); // Map actions
103
+ }, [actionRef, onComposerKeyDown, bannerPosition, (_messagesListProps$me2 = messagesListProps.messages) === null || _messagesListProps$me2 === void 0 ? void 0 : _messagesListProps$me2.length]); // Map actions
102
104
 
103
105
  React__default["default"].useEffect(() => {
104
106
  if (actionRef && actionRef.current) {
@@ -26,7 +26,6 @@ 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 useValidateProps = require('./config/useValidateProps.js');
30
29
  var jsxRuntime = require('react/jsx-runtime');
31
30
 
32
31
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -54,8 +53,7 @@ const getPadding = _ref => {
54
53
  return padding;
55
54
  };
56
55
 
57
- const ChatContainerMessagesList = props$2 => {
58
- useValidateProps.useValidateProps(props$2, props.listProps);
56
+ const ChatContainerMessagesList = props => {
59
57
  const {
60
58
  sendingText,
61
59
  bannerPosition,
@@ -67,7 +65,7 @@ const ChatContainerMessagesList = props$2 => {
67
65
  hasMoreItems,
68
66
  isLoading,
69
67
  bannerRef
70
- } = props$2;
68
+ } = props;
71
69
  const pendingOnScroll = React__default["default"].useRef(false);
72
70
  const loadMoreRef = React__default["default"].useRef(null);
73
71
  const virtualListRef = React__default["default"].useRef(); // estimateSize should not be really required given what was stated on
@@ -96,6 +94,7 @@ const ChatContainerMessagesList = props$2 => {
96
94
  return [];
97
95
  }
98
96
 
97
+ if (!virtualListRef.current) return [];
99
98
  pendingOnScroll.current = false;
100
99
  const {
101
100
  bottom,
@@ -138,6 +137,7 @@ const ChatContainerMessagesList = props$2 => {
138
137
  };
139
138
 
140
139
  actionRef.current.getMessagesInView = onScrollStop;
140
+ onScrollStop(); // init useMemo due to debounce use.
141
141
 
142
142
  actionRef.current.focusToIndex = function (a) {
143
143
  let b = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
@@ -203,12 +203,7 @@ const ChatContainerMessagesList = props$2 => {
203
203
 
204
204
  e.preventDefault();
205
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();
211
- } else if (!e.shiftKey) {
206
+ } else if (hasMoreItems === 'top' && e.shiftKey) ; else if (!e.shiftKey) {
212
207
  if (bannerPosition) {
213
208
  e.preventDefault();
214
209
  bannerRef.current.focusOnWrapper();
@@ -222,7 +217,7 @@ const ChatContainerMessagesList = props$2 => {
222
217
 
223
218
  break;
224
219
  }
225
- }, [actionRef, bannerRef, hasMoreItems, messages.length, bannerPosition, scrollAndFocus]);
220
+ }, [bannerRef, hasMoreItems, messages.length, bannerPosition, scrollAndFocus]);
226
221
  const handleListKey = React__default["default"].useCallback(e => {
227
222
  const {
228
223
  key
@@ -262,15 +257,15 @@ const ChatContainerMessagesList = props$2 => {
262
257
  case 'Tab':
263
258
  if (document.activeElement !== loadMoreRef.current) {
264
259
  if (hasMoreItems === 'bottom' && !e.shiftKey) {
265
- var _loadMoreRef$current4;
260
+ var _loadMoreRef$current3;
266
261
 
267
262
  e.preventDefault();
268
- (_loadMoreRef$current4 = loadMoreRef.current) === null || _loadMoreRef$current4 === void 0 ? void 0 : _loadMoreRef$current4.focus();
263
+ (_loadMoreRef$current3 = loadMoreRef.current) === null || _loadMoreRef$current3 === void 0 ? void 0 : _loadMoreRef$current3.focus();
269
264
  } else if (hasMoreItems === 'top' && e.shiftKey) {
270
- var _loadMoreRef$current5;
265
+ var _loadMoreRef$current4;
271
266
 
272
267
  e.preventDefault();
273
- (_loadMoreRef$current5 = loadMoreRef.current) === null || _loadMoreRef$current5 === void 0 ? void 0 : _loadMoreRef$current5.focus();
268
+ (_loadMoreRef$current4 = loadMoreRef.current) === null || _loadMoreRef$current4 === void 0 ? void 0 : _loadMoreRef$current4.focus();
274
269
  } else if (!e.shiftKey) {
275
270
  e.preventDefault();
276
271
  actionRef.current.focusToComposer();
@@ -17,7 +17,8 @@ const ChatDataTestIds = {
17
17
  SYSTEM_MSG_TIME: 'chat-system-message-time',
18
18
  BUBBLE: 'ds-chat-bubble',
19
19
  BUBBLE_TITLE: 'chat-bubble-title',
20
- BUBBLE_BODY: 'chat-bubble-body'
20
+ BUBBLE_BODY: 'chat-bubble-body',
21
+ BANNER: 'ds-banner-container'
21
22
  };
22
23
 
23
24
  export { ChatDataTestIds };
@@ -42,6 +42,7 @@ const ChatComposer = props => {
42
42
  dataTestid,
43
43
  actionRef
44
44
  } = props;
45
+ const COMPOSER_MIN_HEIGHT = 32;
45
46
  const input = React.useRef();
46
47
  const inputSize = React.useRef();
47
48
  const inputSend = React.useRef();
@@ -52,10 +53,10 @@ const ChatComposer = props => {
52
53
  var _inputSize$current, _inputSize$current2, _inputSize$current3, _inputSize$current4;
53
54
 
54
55
  const newHeight = ((_inputSize$current = inputSize.current) === null || _inputSize$current === void 0 ? void 0 : _inputSize$current.scrollHeight) > internalMaxHeight ? internalMaxHeight : (_inputSize$current2 = inputSize.current) === null || _inputSize$current2 === void 0 ? void 0 : _inputSize$current2.scrollHeight;
55
- onResize(newHeight);
56
+ if (newHeight !== height && newHeight > COMPOSER_MIN_HEIGHT) onResize(newHeight);
56
57
  setHeight(newHeight);
57
58
  setShowScroll(((_inputSize$current3 = inputSize.current) === null || _inputSize$current3 === void 0 ? void 0 : _inputSize$current3.scrollHeight) - ((_inputSize$current4 = inputSize.current) === null || _inputSize$current4 === void 0 ? void 0 : _inputSize$current4.clientHeight) > 5);
58
- }, [inputValue, internalMaxHeight, onResize]);
59
+ }, [inputValue, internalMaxHeight, height, onResize]);
59
60
  React.useEffect(() => {
60
61
  if (actionRef && actionRef.current) {
61
62
  actionRef.current.focusToComposer = () => {
@@ -98,7 +99,9 @@ const ChatComposer = props => {
98
99
  onKeyDown: onKeyDown,
99
100
  placeholder: placeholder,
100
101
  "aria-label": "Message to send",
101
- "data-testid": "chat-composer-textarea"
102
+ "data-testid": "chat-composer-textarea",
103
+ name: "chat-composer-textarea",
104
+ id: "chat-composer-textarea"
102
105
  }), /*#__PURE__*/_jsx(Grid, {
103
106
  height: "32px",
104
107
  alignItems: "center"
@@ -139,7 +142,7 @@ const ChatComposer = props => {
139
142
  children: [/*#__PURE__*/_jsx(StyledCounterErrorA11y, {
140
143
  role: "alert"
141
144
  }, 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. ")]
142
- }) : '', inputMaxLength ? " ".concat(inputLength, " / ").concat(inputMaxLength) : ''), _Grid || (_Grid = /*#__PURE__*/_jsx(Grid, {}))));
145
+ }) : '', inputMaxLength && !maxLengthMessage ? " ".concat(inputLength, " / ").concat(inputMaxLength) : ''), _Grid || (_Grid = /*#__PURE__*/_jsx(Grid, {}))));
143
146
  };
144
147
 
145
148
  ChatComposer.defaultProps = defaultComposerPros;
@@ -24,7 +24,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
24
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
- var _containerRef$current;
27
+ var _messagesListProps$me2, _containerRef$current;
28
28
 
29
29
  useValidateProps(props, containerProps);
30
30
  const {
@@ -72,7 +72,9 @@ const ChatContainer = props => {
72
72
  const ref = actionRef || listRef;
73
73
 
74
74
  if (e.shiftKey && e.key === 'Tab') {
75
- if (messagesListProps.messages.length > 0) {
75
+ var _messagesListProps$me;
76
+
77
+ if (((_messagesListProps$me = messagesListProps.messages) === null || _messagesListProps$me === void 0 ? void 0 : _messagesListProps$me.length) > 0) {
76
78
  e.preventDefault();
77
79
 
78
80
  if (['top', 'bottom'].includes(bannerPosition)) {
@@ -86,7 +88,7 @@ const ChatContainer = props => {
86
88
  }
87
89
  }
88
90
  }
89
- }, [actionRef, onComposerKeyDown, bannerPosition, messagesListProps.messages.length]); // Map actions
91
+ }, [actionRef, onComposerKeyDown, bannerPosition, (_messagesListProps$me2 = messagesListProps.messages) === null || _messagesListProps$me2 === void 0 ? void 0 : _messagesListProps$me2.length]); // Map actions
90
92
 
91
93
  React.useEffect(() => {
92
94
  if (actionRef && actionRef.current) {
@@ -22,7 +22,6 @@ import { MessageDelimiter } from '../message-delimiter/MessageDelimiter.js';
22
22
  import { SystemMessage } from '../system-message/SystemMessage.js';
23
23
  import { ListItem, StyledWrapperListItem, StyledWrapper, StyledChatContainerContentList, StyledChatContainerContentListScroll, StyledLoadMoreContainer } from './styled.js';
24
24
  import { listProps, defaultProps } from './props.js';
25
- import { useValidateProps } from './config/useValidateProps.js';
26
25
  import { jsx } from 'react/jsx-runtime';
27
26
 
28
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; }
@@ -44,7 +43,6 @@ const getPadding = _ref => {
44
43
  };
45
44
 
46
45
  const ChatContainerMessagesList = props => {
47
- useValidateProps(props, listProps);
48
46
  const {
49
47
  sendingText,
50
48
  bannerPosition,
@@ -85,6 +83,7 @@ const ChatContainerMessagesList = props => {
85
83
  return [];
86
84
  }
87
85
 
86
+ if (!virtualListRef.current) return [];
88
87
  pendingOnScroll.current = false;
89
88
  const {
90
89
  bottom,
@@ -127,6 +126,7 @@ const ChatContainerMessagesList = props => {
127
126
  };
128
127
 
129
128
  actionRef.current.getMessagesInView = onScrollStop;
129
+ onScrollStop(); // init useMemo due to debounce use.
130
130
 
131
131
  actionRef.current.focusToIndex = function (a) {
132
132
  let b = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
@@ -192,12 +192,7 @@ const ChatContainerMessagesList = props => {
192
192
 
193
193
  e.preventDefault();
194
194
  (_loadMoreRef$current2 = loadMoreRef.current) === null || _loadMoreRef$current2 === void 0 ? void 0 : _loadMoreRef$current2.focus();
195
- } else if (hasMoreItems === 'top' && e.shiftKey) {
196
- var _loadMoreRef$current3;
197
-
198
- e.preventDefault();
199
- (_loadMoreRef$current3 = loadMoreRef.current) === null || _loadMoreRef$current3 === void 0 ? void 0 : _loadMoreRef$current3.focus();
200
- } else if (!e.shiftKey) {
195
+ } else if (hasMoreItems === 'top' && e.shiftKey) ; else if (!e.shiftKey) {
201
196
  if (bannerPosition) {
202
197
  e.preventDefault();
203
198
  bannerRef.current.focusOnWrapper();
@@ -211,7 +206,7 @@ const ChatContainerMessagesList = props => {
211
206
 
212
207
  break;
213
208
  }
214
- }, [actionRef, bannerRef, hasMoreItems, messages.length, bannerPosition, scrollAndFocus]);
209
+ }, [bannerRef, hasMoreItems, messages.length, bannerPosition, scrollAndFocus]);
215
210
  const handleListKey = React.useCallback(e => {
216
211
  const {
217
212
  key
@@ -251,15 +246,15 @@ const ChatContainerMessagesList = props => {
251
246
  case 'Tab':
252
247
  if (document.activeElement !== loadMoreRef.current) {
253
248
  if (hasMoreItems === 'bottom' && !e.shiftKey) {
254
- var _loadMoreRef$current4;
249
+ var _loadMoreRef$current3;
255
250
 
256
251
  e.preventDefault();
257
- (_loadMoreRef$current4 = loadMoreRef.current) === null || _loadMoreRef$current4 === void 0 ? void 0 : _loadMoreRef$current4.focus();
252
+ (_loadMoreRef$current3 = loadMoreRef.current) === null || _loadMoreRef$current3 === void 0 ? void 0 : _loadMoreRef$current3.focus();
258
253
  } else if (hasMoreItems === 'top' && e.shiftKey) {
259
- var _loadMoreRef$current5;
254
+ var _loadMoreRef$current4;
260
255
 
261
256
  e.preventDefault();
262
- (_loadMoreRef$current5 = loadMoreRef.current) === null || _loadMoreRef$current5 === void 0 ? void 0 : _loadMoreRef$current5.focus();
257
+ (_loadMoreRef$current4 = loadMoreRef.current) === null || _loadMoreRef$current4 === void 0 ? void 0 : _loadMoreRef$current4.focus();
263
258
  } else if (!e.shiftKey) {
264
259
  e.preventDefault();
265
260
  actionRef.current.focusToComposer();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-chat",
3
- "version": "2.1.0-rc.4",
3
+ "version": "2.2.0-alpha.1",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Chat",
6
6
  "module": "./esm/index.js",
@@ -305,15 +305,15 @@
305
305
  "generateSubmodules": true
306
306
  },
307
307
  "dependencies": {
308
- "@elliemae/ds-banner": "2.1.0-rc.4",
309
- "@elliemae/ds-button": "2.1.0-rc.4",
310
- "@elliemae/ds-grid": "2.1.0-rc.4",
311
- "@elliemae/ds-icons": "2.1.0-rc.4",
312
- "@elliemae/ds-indeterminate-progress-indicator": "2.1.0-rc.4",
313
- "@elliemae/ds-props-helpers": "2.1.0-rc.4",
314
- "@elliemae/ds-system": "2.1.0-rc.4",
315
- "@elliemae/ds-tooltip": "2.1.0-rc.4",
316
- "@elliemae/ds-truncated-tooltip-text": "2.1.0-rc.4",
308
+ "@elliemae/ds-banner": "2.2.0-alpha.1",
309
+ "@elliemae/ds-button": "2.2.0-alpha.1",
310
+ "@elliemae/ds-grid": "2.2.0-alpha.1",
311
+ "@elliemae/ds-icons": "2.2.0-alpha.1",
312
+ "@elliemae/ds-indeterminate-progress-indicator": "2.2.0-alpha.1",
313
+ "@elliemae/ds-props-helpers": "2.2.0-alpha.1",
314
+ "@elliemae/ds-system": "2.2.0-alpha.1",
315
+ "@elliemae/ds-tooltip": "2.2.0-alpha.1",
316
+ "@elliemae/ds-truncated-tooltip-text": "2.2.0-alpha.1",
317
317
  "prop-types": "~15.7.2",
318
318
  "react-desc": "~4.1.2",
319
319
  "react-virtual": "~2.3.2"
@@ -18,4 +18,5 @@ export declare const ChatDataTestIds: {
18
18
  BUBBLE: string;
19
19
  BUBBLE_TITLE: string;
20
20
  BUBBLE_BODY: string;
21
+ BANNER: string;
21
22
  };
@@ -1,27 +1 @@
1
- export declare const preLoadMessages2: ({
2
- dsId: string;
3
- body: string;
4
- type: string;
5
- title: string;
6
- time: string;
7
- extraProps?: undefined;
8
- helpMessage?: undefined;
9
- } | {
10
- dsId: string;
11
- type: string;
12
- title: string;
13
- extraProps: {
14
- 'data-testid': string;
15
- };
16
- body?: undefined;
17
- time?: undefined;
18
- helpMessage?: undefined;
19
- } | {
20
- dsId: string;
21
- body: string;
22
- type: string;
23
- title: string;
24
- time: string;
25
- helpMessage: string | null;
26
- extraProps?: undefined;
27
- })[];
1
+ export declare const loadMsgs: (q: number) => unknown;