@elliemae/ds-chat 2.0.0-alpha.0 → 2.0.0-alpha.12

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.
Files changed (168) hide show
  1. package/cjs/ChatDataTestids.js +27 -0
  2. package/cjs/index.js +1 -0
  3. package/cjs/parts/bubble/ChatBubble.js +33 -20
  4. package/cjs/parts/bubble/ChatBubbleArrow.js +64 -61
  5. package/cjs/parts/bubble/config/useValidateProps.js +31 -0
  6. package/cjs/parts/bubble/index.js +1 -0
  7. package/cjs/parts/bubble/props.js +5 -5
  8. package/cjs/parts/bubble/styled.js +12 -41
  9. package/cjs/parts/chat-card/ChatCard.js +26 -20
  10. package/cjs/parts/chat-card/config/useValidateProps.js +11 -0
  11. package/cjs/parts/chat-card/props.js +3 -3
  12. package/cjs/parts/chat-card/styled.js +6 -6
  13. package/cjs/parts/chat-composer/ChatContainerComposer.js +50 -25
  14. package/cjs/parts/chat-composer/config/useValidateProps.js +11 -0
  15. package/cjs/parts/chat-composer/props.js +10 -4
  16. package/cjs/parts/chat-composer/styled.js +8 -8
  17. package/cjs/parts/chat-container/ChatContainer.js +79 -29
  18. package/cjs/parts/chat-container/config/useValidateProps.js +11 -0
  19. package/cjs/parts/chat-container/props.js +12 -7
  20. package/cjs/parts/chat-container/styled.js +5 -5
  21. package/cjs/parts/chat-container-header/ChatContainerHeader.js +7 -7
  22. package/cjs/parts/chat-container-header/helpers.js +31 -0
  23. package/cjs/parts/chat-container-header/styled.js +6 -6
  24. package/cjs/parts/chat-container-messages-list/ChatContainerMessagesList.js +214 -34
  25. package/cjs/parts/chat-container-messages-list/config/useValidateProps.js +11 -0
  26. package/cjs/parts/chat-container-messages-list/props.js +6 -10
  27. package/cjs/parts/chat-container-messages-list/styled.js +11 -14
  28. package/cjs/parts/chat-empty-state/ChatEmptyState.js +22 -12
  29. package/cjs/parts/chat-empty-state/config/useValidateProps.js +11 -0
  30. package/cjs/parts/chat-empty-state/props.js +2 -1
  31. package/cjs/parts/chat-empty-state/styled.js +2 -2
  32. package/cjs/parts/chat-sidebar/SideBarChat.js +70 -36
  33. package/cjs/parts/chat-sidebar/config/useValidateProps.js +11 -0
  34. package/cjs/parts/chat-sidebar/props.js +11 -1
  35. package/cjs/parts/chat-sidebar/styled.js +4 -4
  36. package/cjs/parts/floating-button/FloatingButton.js +18 -10
  37. package/cjs/parts/floating-button/props.js +6 -2
  38. package/cjs/parts/floating-button/styled.js +1 -1
  39. package/cjs/parts/floating-container/styled.js +1 -1
  40. package/cjs/parts/grid-influencer/InfluencerContainer.js +2 -2
  41. package/cjs/parts/grid-influencer/styled.js +4 -8
  42. package/cjs/parts/message-delimiter/MessageDelimiter.js +18 -12
  43. package/cjs/parts/message-delimiter/config/useValidateProps.js +11 -0
  44. package/cjs/parts/message-delimiter/props.js +1 -1
  45. package/cjs/parts/message-delimiter/styled.js +4 -4
  46. package/cjs/parts/sidebar-button/SidebarButton.js +12 -7
  47. package/cjs/parts/sidebar-button/props.js +3 -4
  48. package/cjs/parts/sidebar-button/styled.js +4 -4
  49. package/cjs/parts/system-message/SystemMessage.js +21 -15
  50. package/cjs/parts/system-message/config/useValidateProps.js +11 -0
  51. package/cjs/parts/system-message/style.js +6 -6
  52. package/cjs/parts/tile-button/TileButton.js +40 -34
  53. package/cjs/parts/tile-button/config/useValidateProps.js +11 -0
  54. package/cjs/parts/tile-button/props.js +15 -13
  55. package/cjs/parts/tile-button/styled.js +22 -15
  56. package/cjs/styled.js +1 -1
  57. package/esm/ChatDataTestids.js +23 -0
  58. package/esm/index.js +1 -1
  59. package/esm/parts/bubble/ChatBubble.js +24 -12
  60. package/esm/parts/bubble/ChatBubbleArrow.js +64 -61
  61. package/esm/parts/bubble/config/useValidateProps.js +27 -0
  62. package/esm/parts/bubble/index.js +1 -1
  63. package/esm/parts/bubble/props.js +4 -4
  64. package/esm/parts/bubble/styled.js +3 -32
  65. package/esm/parts/chat-card/ChatCard.js +26 -20
  66. package/esm/parts/chat-card/config/useValidateProps.js +7 -0
  67. package/esm/parts/chat-card/props.js +3 -3
  68. package/esm/parts/chat-composer/ChatContainerComposer.js +33 -7
  69. package/esm/parts/chat-composer/config/useValidateProps.js +7 -0
  70. package/esm/parts/chat-composer/props.js +10 -4
  71. package/esm/parts/chat-composer/styled.js +2 -2
  72. package/esm/parts/chat-container/ChatContainer.js +68 -18
  73. package/esm/parts/chat-container/config/useValidateProps.js +7 -0
  74. package/esm/parts/chat-container/props.js +12 -7
  75. package/esm/parts/chat-container/styled.js +2 -2
  76. package/esm/parts/chat-container-header/ChatContainerHeader.js +3 -2
  77. package/esm/parts/chat-container-header/helpers.js +23 -0
  78. package/esm/parts/chat-container-header/styled.js +6 -6
  79. package/esm/parts/chat-container-messages-list/ChatContainerMessagesList.js +202 -22
  80. package/esm/parts/chat-container-messages-list/config/useValidateProps.js +7 -0
  81. package/esm/parts/chat-container-messages-list/props.js +6 -10
  82. package/esm/parts/chat-container-messages-list/styled.js +6 -10
  83. package/esm/parts/chat-empty-state/ChatEmptyState.js +16 -6
  84. package/esm/parts/chat-empty-state/config/useValidateProps.js +7 -0
  85. package/esm/parts/chat-empty-state/props.js +2 -1
  86. package/esm/parts/chat-sidebar/SideBarChat.js +69 -34
  87. package/esm/parts/chat-sidebar/config/useValidateProps.js +7 -0
  88. package/esm/parts/chat-sidebar/props.js +11 -1
  89. package/esm/parts/chat-sidebar/styled.js +2 -2
  90. package/esm/parts/floating-button/FloatingButton.js +18 -9
  91. package/esm/parts/floating-button/props.js +6 -2
  92. package/esm/parts/grid-influencer/styled.js +2 -6
  93. package/esm/parts/message-delimiter/MessageDelimiter.js +18 -12
  94. package/esm/parts/message-delimiter/config/useValidateProps.js +7 -0
  95. package/esm/parts/message-delimiter/props.js +1 -1
  96. package/esm/parts/message-delimiter/styled.js +1 -1
  97. package/esm/parts/sidebar-button/SidebarButton.js +6 -1
  98. package/esm/parts/sidebar-button/props.js +1 -1
  99. package/esm/parts/sidebar-button/styled.js +1 -1
  100. package/esm/parts/system-message/SystemMessage.js +21 -15
  101. package/esm/parts/system-message/config/useValidateProps.js +7 -0
  102. package/esm/parts/system-message/style.js +1 -1
  103. package/esm/parts/tile-button/TileButton.js +35 -27
  104. package/esm/parts/tile-button/config/useValidateProps.js +7 -0
  105. package/esm/parts/tile-button/props.js +14 -7
  106. package/esm/parts/tile-button/styled.js +15 -10
  107. package/esm/styled.js +1 -1
  108. package/package.json +69 -6
  109. package/types/ChatDataTestids.d.ts +21 -0
  110. package/types/index.d.ts +1 -1
  111. package/types/parts/bubble/ChatBubble.d.ts +20 -5
  112. package/types/parts/bubble/config/useValidateProps.d.ts +2 -0
  113. package/types/parts/bubble/index.d.ts +1 -1
  114. package/types/parts/bubble/props.d.ts +13 -4
  115. package/types/parts/bubble/styled.d.ts +9 -9
  116. package/types/parts/bubble/tests/ChatBubble.test.d.ts +1 -0
  117. package/types/parts/chat-card/ChatCard.d.ts +25 -5
  118. package/types/parts/chat-card/config/useValidateProps.d.ts +2 -0
  119. package/types/parts/chat-card/props.d.ts +19 -3
  120. package/types/parts/chat-card/styled.d.ts +6 -6
  121. package/types/parts/chat-composer/ChatContainerComposer.d.ts +48 -12
  122. package/types/parts/chat-composer/config/useValidateProps.d.ts +2 -0
  123. package/types/parts/chat-composer/styled.d.ts +117 -24
  124. package/types/parts/chat-composer/tests/ChatContainerComposer.test.d.ts +1 -0
  125. package/types/parts/chat-container/ChatContainer.d.ts +54 -12
  126. package/types/parts/chat-container/config/useValidateProps.d.ts +2 -0
  127. package/types/parts/chat-container/styled.d.ts +4 -4
  128. package/types/parts/chat-container/tests/ChatContainer.test.d.ts +1 -0
  129. package/types/parts/chat-container-header/helpers.d.ts +6 -0
  130. package/types/parts/chat-container-header/styled.d.ts +3 -3
  131. package/types/parts/chat-container-messages-list/ChatContainerMessagesList.d.ts +39 -9
  132. package/types/parts/chat-container-messages-list/config/useValidateProps.d.ts +2 -0
  133. package/types/parts/chat-container-messages-list/styled.d.ts +7 -6
  134. package/types/parts/chat-empty-state/ChatEmptyState.d.ts +19 -1
  135. package/types/parts/chat-empty-state/config/useValidateProps.d.ts +2 -0
  136. package/types/parts/chat-empty-state/props.d.ts +7 -1
  137. package/types/parts/chat-empty-state/styled.d.ts +2 -2
  138. package/types/parts/chat-sidebar/SideBarChat.d.ts +40 -10
  139. package/types/parts/chat-sidebar/config/useValidateProps.d.ts +2 -0
  140. package/types/parts/chat-sidebar/props.d.ts +39 -9
  141. package/types/parts/chat-sidebar/styled.d.ts +2 -2
  142. package/types/parts/floating-button/FloatingButton.d.ts +11 -2
  143. package/types/parts/floating-button/props.d.ts +13 -1
  144. package/types/parts/floating-button/styled.d.ts +1 -1
  145. package/types/parts/floating-container/styled.d.ts +1 -2
  146. package/types/parts/grid-influencer/styled.d.ts +2 -2
  147. package/types/parts/message-delimiter/MessageDelimiter.d.ts +22 -5
  148. package/types/parts/message-delimiter/config/useValidateProps.d.ts +2 -0
  149. package/types/parts/message-delimiter/props.d.ts +16 -3
  150. package/types/parts/message-delimiter/styled.d.ts +3 -3
  151. package/types/parts/sidebar-button/SidebarButton.d.ts +16 -5
  152. package/types/parts/sidebar-button/props.d.ts +16 -5
  153. package/types/parts/sidebar-button/styled.d.ts +3 -3
  154. package/types/parts/system-message/SystemMessage.d.ts +13 -3
  155. package/types/parts/system-message/config/useValidateProps.d.ts +2 -0
  156. package/types/parts/system-message/props.d.ts +7 -1
  157. package/types/parts/system-message/style.d.ts +5 -5
  158. package/types/parts/tile-button/TileButton.d.ts +66 -17
  159. package/types/parts/tile-button/config/useValidateProps.d.ts +2 -0
  160. package/types/parts/tile-button/props.d.ts +64 -16
  161. package/types/parts/tile-button/styled.d.ts +9 -8
  162. package/types/prop-types.d.ts +28 -9
  163. package/types/tests/utils.d.ts +27 -0
  164. package/cjs/package.json +0 -4
  165. package/esm/package.json +0 -4
  166. package/types/parts/chat-composer/props.d.ts +0 -32
  167. package/types/parts/chat-container/props.d.ts +0 -38
  168. package/types/parts/chat-container-messages-list/props.d.ts +0 -31
@@ -4,16 +4,28 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _jsx = require('@babel/runtime/helpers/jsx');
6
6
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
7
+ require('core-js/modules/esnext.async-iterator.some.js');
8
+ require('core-js/modules/esnext.iterator.constructor.js');
9
+ require('core-js/modules/esnext.iterator.some.js');
10
+ require('core-js/modules/esnext.async-iterator.for-each.js');
11
+ require('core-js/modules/esnext.iterator.for-each.js');
12
+ require('core-js/modules/esnext.async-iterator.map.js');
13
+ require('core-js/modules/esnext.iterator.map.js');
14
+ require('core-js/modules/esnext.async-iterator.find.js');
15
+ require('core-js/modules/esnext.iterator.find.js');
16
+ require('core-js/modules/esnext.async-iterator.filter.js');
17
+ require('core-js/modules/esnext.iterator.filter.js');
7
18
  var React = require('react');
8
19
  var reactDesc = require('react-desc');
9
20
  var reactVirtual = require('react-virtual');
10
- var DSButton = require('@elliemae/ds-basic/Button');
21
+ var DSButton = require('@elliemae/ds-button');
11
22
  var ChatBubble = require('../bubble/ChatBubble.js');
12
23
  var props$1 = require('../bubble/props.js');
13
24
  var MessageDelimiter = require('../message-delimiter/MessageDelimiter.js');
14
25
  var SystemMessage = require('../system-message/SystemMessage.js');
15
26
  var styled = require('./styled.js');
16
27
  var props = require('./props.js');
28
+ var useValidateProps = require('./config/useValidateProps.js');
17
29
  var jsxRuntime = require('react/jsx-runtime');
18
30
 
19
31
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -25,29 +37,38 @@ var DSButton__default = /*#__PURE__*/_interopDefaultLegacy(DSButton);
25
37
 
26
38
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
27
39
 
28
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default['default'](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
40
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
29
41
 
30
- const getPadding = hasMoreItems => {
42
+ const getPadding = _ref => {
43
+ let {
44
+ hasMoreItems,
45
+ bannerPosition,
46
+ isLoading
47
+ } = _ref;
31
48
  const padding = {
32
49
  paddingStart: 0,
33
50
  paddingEnd: -5
34
51
  };
35
- if (hasMoreItems === 'top') padding.paddingStart = 42;else if (hasMoreItems === 'bottom') padding.paddingEnd = 42;
52
+ if ([hasMoreItems, bannerPosition, isLoading].some(item => item === 'top')) padding.paddingStart = 42;else if ([hasMoreItems, bannerPosition, isLoading].some(item => item === 'bottom')) padding.paddingEnd = 42;
36
53
  return padding;
37
54
  };
38
55
 
39
- const ChatContainerMessagesList = props => {
56
+ const ChatContainerMessagesList = props$2 => {
57
+ useValidateProps.useValidateProps(props$2, props.listProps);
40
58
  const {
41
59
  sendingText,
60
+ bannerPosition,
42
61
  sendingMessages,
43
62
  messages,
44
63
  actionRef,
45
64
  onScrollEnds,
46
65
  getMoreMessages,
47
66
  hasMoreItems,
48
- isLoading
49
- } = props;
50
- const virtualListRef = React__default['default'].useRef(); // estimateSize should not be really required given what was stated on
67
+ isLoading,
68
+ bannerRef
69
+ } = props$2;
70
+ const loadMoreRef = React__default["default"].useRef(null);
71
+ const virtualListRef = React__default["default"].useRef(); // estimateSize should not be really required given what was stated on
51
72
  // https://github.com/tannerlinsley/react-virtual/issues/23
52
73
 
53
74
  const {
@@ -58,34 +79,186 @@ const ChatContainerMessagesList = props => {
58
79
  size: messages.length,
59
80
  parentRef: virtualListRef,
60
81
  overscan: 15
61
- }, getPadding(hasMoreItems)), {}, {
62
- estimateSize: React__default['default'].useCallback(() => 80, [])
82
+ }, getPadding({
83
+ hasMoreItems,
84
+ bannerPosition,
85
+ isLoading
86
+ })), {}, {
87
+ estimateSize: React__default["default"].useCallback(() => 80, [])
63
88
  }));
64
- const onScrollStop = React__default['default'].useCallback(() => {
89
+ const onScrollStop = React__default["default"].useCallback(() => {
90
+ var _virtualListRef$curre;
91
+
65
92
  const {
66
93
  bottom,
67
94
  top
68
- } = virtualListRef.current.getBoundingClientRect();
95
+ } = (_virtualListRef$curre = virtualListRef.current) === null || _virtualListRef$curre === void 0 ? void 0 : _virtualListRef$curre.getBoundingClientRect();
69
96
  const list = virtualListRef.current.querySelectorAll('[data-element="chat-element-list-item"]');
70
97
  const indexList = [];
71
98
  list.forEach(item => {
72
99
  const {
73
- top: itemTop
100
+ top: itemTop,
101
+ bottom: itemBottom
74
102
  } = item.getBoundingClientRect();
75
- if (itemTop < bottom && itemTop > top) indexList.push(item.dataset.index);
103
+ const itemPadding = 10;
104
+ if (itemTop + itemPadding < bottom && itemBottom - itemPadding > top) indexList.push(item.dataset.index);
76
105
  });
77
106
  if (onScrollEnds) onScrollEnds(indexList);
78
107
  return indexList;
79
108
  }, [onScrollEnds]);
80
- React__default['default'].useImperativeHandle(actionRef, () => ({
81
- scrollToIndex: (a, b = {
109
+ const onlyFocus = React__default["default"].useCallback(index => {
110
+ setTimeout(() => {
111
+ virtualListRef.current.querySelector("[data-index=\"".concat(index, "\"]")).focus();
112
+ }, 300);
113
+ }, []);
114
+ const scrollAndFocus = React__default["default"].useCallback(function (index) {
115
+ let b = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
82
116
  align: 'center'
83
- }) => {
84
- vScroll(a, b);
85
- },
86
- getMessagesInView: onScrollStop
87
- }));
88
- React__default['default'].useEffect(() => {
117
+ };
118
+ vScroll(index, b);
119
+ onlyFocus(index);
120
+ }, [onlyFocus, vScroll]);
121
+ React__default["default"].useEffect(() => {
122
+ if (actionRef && actionRef.current) {
123
+ actionRef.current.scrollToIndex = function (a) {
124
+ let b = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
125
+ align: 'center'
126
+ };
127
+ vScroll(a, b);
128
+ };
129
+
130
+ actionRef.current.getMessagesInView = onScrollStop;
131
+
132
+ actionRef.current.focusToIndex = function (a) {
133
+ let b = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
134
+ align: 'center'
135
+ };
136
+ scrollAndFocus(a, b);
137
+ };
138
+
139
+ actionRef.current.focusToIndexWithoutScroll = onlyFocus;
140
+
141
+ actionRef.current.focusToList = a => {
142
+ var _virtualListRef$curre2;
143
+
144
+ (_virtualListRef$curre2 = virtualListRef.current) === null || _virtualListRef$curre2 === void 0 ? void 0 : _virtualListRef$curre2.focus();
145
+ };
146
+ }
147
+ }, [actionRef, onScrollStop, onlyFocus, scrollAndFocus, vScroll]);
148
+ const handleKey = React__default["default"].useCallback(e => {
149
+ const {
150
+ key
151
+ } = e;
152
+ const index = Number(e.currentTarget.dataset.index);
153
+ e.stopPropagation();
154
+
155
+ switch (key) {
156
+ case 'ArrowUp':
157
+ e.preventDefault();
158
+ if (index > 0) virtualListRef.current.querySelector("[data-index=\"".concat(index - 1, "\"]")).focus();
159
+ break;
160
+
161
+ case 'ArrowDown':
162
+ e.preventDefault();
163
+
164
+ if (index < messages.length - 1) {
165
+ virtualListRef.current.querySelector("[data-index=\"".concat(index + 1, "\"]")).focus();
166
+ }
167
+
168
+ break;
169
+
170
+ case 'Home':
171
+ e.preventDefault();
172
+ scrollAndFocus(0);
173
+ break;
174
+
175
+ case 'End':
176
+ e.preventDefault();
177
+ scrollAndFocus(messages.length - 1);
178
+ break;
179
+
180
+ case 'Tab':
181
+ e.preventDefault();
182
+
183
+ 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
+ var _loadMoreRef$current2;
189
+
190
+ (_loadMoreRef$current2 = loadMoreRef.current) === null || _loadMoreRef$current2 === void 0 ? void 0 : _loadMoreRef$current2.focus();
191
+ } else if (!e.shiftKey) {
192
+ if (bannerPosition) {
193
+ bannerRef.current.focusOnWrapper();
194
+ } else {
195
+ actionRef.current.focusToComposer();
196
+ }
197
+ } else {
198
+ var _virtualListRef$curre3;
199
+
200
+ (_virtualListRef$curre3 = virtualListRef.current) === null || _virtualListRef$curre3 === void 0 ? void 0 : _virtualListRef$curre3.focus();
201
+ }
202
+
203
+ break;
204
+ }
205
+ }, [actionRef, hasMoreItems, messages.length, bannerPosition, scrollAndFocus]);
206
+ const handleListKey = React__default["default"].useCallback(e => {
207
+ const {
208
+ key
209
+ } = e;
210
+
211
+ switch (key) {
212
+ case 'ArrowUp':
213
+ e.preventDefault();
214
+ onlyFocus(onScrollStop().shift());
215
+ break;
216
+
217
+ case 'ArrowDown':
218
+ e.preventDefault();
219
+ onlyFocus(onScrollStop().pop());
220
+ break;
221
+
222
+ case 'Home':
223
+ e.preventDefault();
224
+ scrollAndFocus(0);
225
+ break;
226
+
227
+ case 'End':
228
+ e.preventDefault();
229
+ scrollAndFocus(messages.length - 1);
230
+ break;
231
+
232
+ case 'Tab':
233
+ if (document.activeElement !== loadMoreRef.current) {
234
+ if (hasMoreItems === 'bottom' && !e.shiftKey) {
235
+ var _loadMoreRef$current3;
236
+
237
+ e.preventDefault();
238
+ (_loadMoreRef$current3 = loadMoreRef.current) === null || _loadMoreRef$current3 === void 0 ? void 0 : _loadMoreRef$current3.focus();
239
+ } else if (hasMoreItems === 'top' && e.shiftKey) {
240
+ var _loadMoreRef$current4;
241
+
242
+ e.preventDefault();
243
+ (_loadMoreRef$current4 = loadMoreRef.current) === null || _loadMoreRef$current4 === void 0 ? void 0 : _loadMoreRef$current4.focus();
244
+ } else if (!e.shiftKey) {
245
+ e.preventDefault();
246
+ actionRef.current.focusToComposer();
247
+ }
248
+ } else if (!e.shiftKey) {
249
+ e.preventDefault();
250
+ actionRef.current.focusToComposer();
251
+ } else {
252
+ var _virtualListRef$curre4;
253
+
254
+ e.preventDefault();
255
+ (_virtualListRef$curre4 = virtualListRef.current) === null || _virtualListRef$curre4 === void 0 ? void 0 : _virtualListRef$curre4.focus();
256
+ }
257
+
258
+ break;
259
+ }
260
+ }, [actionRef, hasMoreItems, messages.length, onScrollStop, onlyFocus, scrollAndFocus]);
261
+ React__default["default"].useEffect(() => {
89
262
  let handlerCallback = null;
90
263
  const localVirtualRef = virtualListRef.current;
91
264
 
@@ -103,7 +276,7 @@ const ChatContainerMessagesList = props => {
103
276
  if (onScrollEnds) localVirtualRef.removeEventListener('scroll', onScroll);
104
277
  };
105
278
  }, [onScrollStop, onScrollEnds]);
106
- const render = React__default['default'].useMemo(() => virtualItems.map(virtualItem => {
279
+ const render = React__default["default"].useMemo(() => virtualItems.map(virtualItem => {
107
280
  const {
108
281
  index,
109
282
  measureRef,
@@ -115,15 +288,18 @@ const ChatContainerMessagesList = props => {
115
288
  position: 'absolute',
116
289
  top: 0,
117
290
  left: 0,
118
- transform: `translateY(${start}px)`,
291
+ transform: "translateY(".concat(start, "px)"),
119
292
  width: '100%'
120
293
  };
121
- return /*#__PURE__*/jsxRuntime.jsx("div", {
294
+ return /*#__PURE__*/jsxRuntime.jsx(styled.ListItem, {
122
295
  "data-element": "chat-element-list-item",
123
296
  "data-index": index,
124
297
  style: style,
125
298
  ref: measureRef,
126
- children: /*#__PURE__*/_jsx__default['default'](styled.StyledWrapperListItem, {
299
+ tabIndex: 0,
300
+ onKeyDown: handleKey,
301
+ role: "listitem",
302
+ children: /*#__PURE__*/_jsx__default["default"](styled.StyledWrapperListItem, {
127
303
  type: row.type
128
304
  }, void 0, row.type === props$1.BUBBLE_TYPES.SENDER || row.type === props$1.BUBBLE_TYPES.RECIPIENT ?
129
305
  /*#__PURE__*/
@@ -131,21 +307,25 @@ const ChatContainerMessagesList = props => {
131
307
  jsxRuntime.jsx(ChatBubble.ChatBubble, _objectSpread(_objectSpread({}, row), {}, {
132
308
  helpMessage: isSending ? sendingText : row.helpMessage
133
309
  })) : 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)
134
- }, `ds-chat-bubble-${index}`);
135
- }), [virtualItems, messages, sendingMessages]);
136
- return /*#__PURE__*/_jsx__default['default'](styled.StyledWrapper, {}, void 0, /*#__PURE__*/jsxRuntime.jsx(styled.StyledChatContainerContentList, {
310
+ }, "ds-chat-bubble-".concat(index, "-").concat(row.dsId, "-").concat(row.type));
311
+ }), [virtualItems, messages, sendingMessages, handleKey, sendingText]);
312
+ return /*#__PURE__*/_jsx__default["default"](styled.StyledWrapper, {}, void 0, /*#__PURE__*/jsxRuntime.jsx(styled.StyledChatContainerContentList, {
137
313
  "data-testid": "chat-thread-container",
138
314
  tabIndex: 0,
139
315
  "aria-live": "polite",
140
316
  ref: virtualListRef,
141
- children: /*#__PURE__*/_jsx__default['default'](styled.StyledChatContainerContentListScroll, {
142
- height: `${totalSize}px`
143
- }, void 0, render, !isLoading && hasMoreItems ? /*#__PURE__*/_jsx__default['default'](styled.StyledLoadMoreContainer, {
317
+ role: "list",
318
+ onKeyDown: handleListKey,
319
+ children: /*#__PURE__*/_jsx__default["default"](styled.StyledChatContainerContentListScroll, {
320
+ height: "".concat(totalSize, "px")
321
+ }, void 0, render, !isLoading && hasMoreItems ? /*#__PURE__*/_jsx__default["default"](styled.StyledLoadMoreContainer, {
144
322
  hasMoreItems: hasMoreItems
145
- }, void 0, /*#__PURE__*/_jsx__default['default'](DSButton__default['default'], {
323
+ }, void 0, /*#__PURE__*/_jsx__default["default"](DSButton__default["default"], {
146
324
  labelText: "Load More",
147
325
  buttonType: "secondary",
148
- onClick: getMoreMessages
326
+ onClick: getMoreMessages,
327
+ "data-testid": "ds-chat-load-more-btn",
328
+ innerRef: loadMoreRef
149
329
  })) : null)
150
330
  }));
151
331
  };
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var dsPropsHelpers = require('@elliemae/ds-props-helpers');
6
+
7
+ const useValidateProps = (props, propTypes) => {
8
+ dsPropsHelpers.useValidateTypescriptPropTypes(props, propTypes);
9
+ };
10
+
11
+ exports.useValidateProps = useValidateProps;
@@ -11,22 +11,18 @@ const defaultProps = {
11
11
  onScrollEnds: () => [],
12
12
  getMoreMessages: lodash.noop,
13
13
  sendingMessages: undefined,
14
- sendingText: 'Sending'
14
+ sendingText: 'Sending',
15
+ bannerPosition: undefined,
16
+ bannerRef: undefined
15
17
  };
16
18
  const listProps = {
17
19
  messages: reactDesc.PropTypes.arrayOf(reactDesc.PropTypes.object).description('The array of out-of-the-box items you want to render inside the ChatMessageList').defaultValue(defaultProps.messages),
18
- actionRef: reactDesc.PropTypes.func.description(`Reference:
19
- {
20
- scrollToIndex: (n: number) => void,
21
- getMessagesInView: () => number[],
22
- }
23
-
24
- `).defaultValue(defaultProps.messages),
25
- onScrollEnds: reactDesc.PropTypes.func.description(`Called when the scroll stops.`),
20
+ actionRef: reactDesc.PropTypes.object.description("Reference: \n { \n scrollToIndex: (n: number) => void,\n getMessagesInView: () => number[],\n focusToIndex: (n: number) => void,\n focusToIndexWithoutScroll: (n: number) => void,\n focusToList: () => void,\n focusToComposer: () => void,\n focusToSend: () => void,\n }\n \n ").defaultValue(defaultProps.actionRef),
21
+ onScrollEnds: reactDesc.PropTypes.func.description("Called when the scroll stops."),
26
22
  isLoading: reactDesc.PropTypes.oneOf(['top', 'bottom', undefined]).description('Keeps the load more space while the loading is in progress'),
27
23
  hasMoreItems: reactDesc.PropTypes.oneOf(['top', 'bottom', undefined]).description('Show Load More button at the `top` or `bottom` of the container'),
28
24
  getMoreMessages: reactDesc.PropTypes.func.description('Called when the user clicks on load more').defaultValue(defaultProps.getMoreMessages),
29
- sendingMessages: reactDesc.PropTypes.arrayOf(reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.string, reactDesc.PropTypes.number])).description('Array of ids of sending messages').defaultValue(defaultProps.sendingMessages),
25
+ sendingMessages: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.arrayOf(reactDesc.PropTypes.string), reactDesc.PropTypes.arrayOf(reactDesc.PropTypes.number)]).description('Array of ids of sending messages').defaultValue(defaultProps.sendingMessages),
30
26
  sendingText: reactDesc.PropTypes.string.description('Label description for messages in sending status').defaultValue(defaultProps.sendingText)
31
27
  };
32
28
 
@@ -3,37 +3,34 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var styled = require('styled-components');
6
- require('@babel/runtime/helpers/jsx');
7
- require('react');
8
- require('@elliemae/ds-icons/WarningCircleFill');
9
- require('@elliemae/ds-grid');
6
+ require('../bubble/ChatBubble.js');
10
7
  var props = require('../bubble/props.js');
11
8
 
12
9
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
10
 
14
11
  var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
15
12
 
16
- const StyledWrapper = /*#__PURE__*/styled__default['default'].div.withConfig({
13
+ const StyledWrapper = /*#__PURE__*/styled__default["default"].div.withConfig({
17
14
  componentId: "sc-1jhprzr-0"
18
15
  })(["width:100%;height:100%;"]); // list
19
16
 
20
- const StyledWrapperListItem = /*#__PURE__*/styled__default['default'].div.withConfig({
17
+ const StyledWrapperListItem = /*#__PURE__*/styled__default["default"].div.withConfig({
21
18
  componentId: "sc-1jhprzr-1"
22
- })(["min-width:100%;", ";", ";", ";"], props$1 => props$1.type === props.BUBBLE_TYPES.SENDER && `padding: ${props$1.theme.space.xxs} ${props$1.theme.space.xxs} 0px 13%
23
- `, props$1 => props$1.type === props.BUBBLE_TYPES.RECIPIENT && `padding: ${props$1.theme.space.xxs} 13% ${props$1.theme.space.xxs}
24
- ${props$1.theme.space.xxs}
25
- `, props$1 => props$1.type === props.BUBBLE_TYPES.SYSTEM && `padding: ${props$1.theme.space.xxs} 0px
26
- `);
27
- const StyledChatContainerContentList = /*#__PURE__*/styled__default['default'].div.withConfig({
19
+ })(["min-width:100%;", ";", ";", ";"], props$1 => props$1.type === props.BUBBLE_TYPES.SENDER && "padding: ".concat(props$1.theme.space.xxs, " ").concat(props$1.theme.space.xxs, " ").concat(props$1.theme.space.xxs, " 13%\n "), props$1 => props$1.type === props.BUBBLE_TYPES.RECIPIENT && "padding: ".concat(props$1.theme.space.xxs, " 13% ").concat(props$1.theme.space.xxs, "\n ").concat(props$1.theme.space.xxs, "\n "), props$1 => props$1.type === props.BUBBLE_TYPES.SYSTEM && "padding: ".concat(props$1.theme.space.xxs, " 0px\n "));
20
+ const StyledChatContainerContentList = /*#__PURE__*/styled__default["default"].div.withConfig({
28
21
  componentId: "sc-1jhprzr-2"
29
22
  })(["width:100%;height:100%;padding:", ";padding-bottom:0;overflow-y:auto;overflow-x:hidden;"], props => props.theme.space.xs);
30
- const StyledChatContainerContentListScroll = /*#__PURE__*/styled__default['default'].div.withConfig({
23
+ const StyledChatContainerContentListScroll = /*#__PURE__*/styled__default["default"].div.withConfig({
31
24
  componentId: "sc-1jhprzr-3"
32
25
  })(["width:100%;height:", ";position:relative;"], props => props.height);
33
- const StyledLoadMoreContainer = /*#__PURE__*/styled__default['default'].div.withConfig({
26
+ const StyledLoadMoreContainer = /*#__PURE__*/styled__default["default"].div.withConfig({
34
27
  componentId: "sc-1jhprzr-4"
35
28
  })(["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
+ const ListItem = /*#__PURE__*/styled__default["default"].div.withConfig({
30
+ componentId: "sc-1jhprzr-5"
31
+ })(["&: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);
36
32
 
33
+ exports.ListItem = ListItem;
37
34
  exports.StyledChatContainerContentList = StyledChatContainerContentList;
38
35
  exports.StyledChatContainerContentListScroll = StyledChatContainerContentListScroll;
39
36
  exports.StyledLoadMoreContainer = StyledLoadMoreContainer;
@@ -3,42 +3,52 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _jsx = require('@babel/runtime/helpers/jsx');
6
+ require('core-js/modules/web.url.to-json.js');
6
7
  var React = require('react');
8
+ var reactDesc = require('react-desc');
7
9
  var dsGrid = require('@elliemae/ds-grid');
8
- var Communications = require('@elliemae/ds-icons/Communications');
10
+ var dsIcons = require('@elliemae/ds-icons');
11
+ var props = require('./props.js');
9
12
  var styled = require('./styled.js');
13
+ var useValidateProps = require('./config/useValidateProps.js');
10
14
 
11
15
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
16
 
13
17
  var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
14
- var Communications__default = /*#__PURE__*/_interopDefaultLegacy(Communications);
15
18
 
16
- const ChatEmptyState = ({
17
- label,
18
- action
19
- }) => {
19
+ const ChatEmptyState = props => {
20
20
  var _Grid, _Grid2;
21
21
 
22
- const MainContent = React.useMemo(() => /*#__PURE__*/_jsx__default['default'](dsGrid.Grid, {
22
+ useValidateProps.useValidateProps(props, ChatEmptyStateListWithSchema.toJSON());
23
+ const {
24
+ label,
25
+ action
26
+ } = props;
27
+ const MainContent = React.useMemo(() => /*#__PURE__*/_jsx__default["default"](dsGrid.Grid, {
23
28
  alignItems: "center",
24
29
  justifyContent: "center"
25
- }, void 0, /*#__PURE__*/_jsx__default['default'](dsGrid.Grid, {
30
+ }, void 0, /*#__PURE__*/_jsx__default["default"](dsGrid.Grid, {
26
31
  alignItems: "center",
27
32
  justifyContent: "center"
28
- }, void 0, /*#__PURE__*/_jsx__default['default'](Communications__default['default'], {
33
+ }, void 0, /*#__PURE__*/_jsx__default["default"](dsIcons.Communications, {
29
34
  size: "xxl",
30
35
  color: ['neutral', 400]
31
- })), _Grid || (_Grid = /*#__PURE__*/_jsx__default['default'](dsGrid.Grid, {
36
+ })), _Grid || (_Grid = /*#__PURE__*/_jsx__default["default"](dsGrid.Grid, {
32
37
  alignItems: "center",
33
38
  justifyContent: "center"
34
- }, void 0, /*#__PURE__*/_jsx__default['default'](styled.MessageWrapper, {}, void 0, label))), _Grid2 || (_Grid2 = /*#__PURE__*/_jsx__default['default'](dsGrid.Grid, {
39
+ }, void 0, /*#__PURE__*/_jsx__default["default"](styled.MessageWrapper, {}, void 0, label))), _Grid2 || (_Grid2 = /*#__PURE__*/_jsx__default["default"](dsGrid.Grid, {
35
40
  alignItems: "center",
36
41
  justifyContent: "center"
37
42
  }, void 0, action))), [label, action]);
38
- return /*#__PURE__*/_jsx__default['default'](styled.ChatEmptyStateWrapper, {
43
+ return /*#__PURE__*/_jsx__default["default"](styled.ChatEmptyStateWrapper, {
39
44
  alignItems: "center",
40
45
  justifyContent: "center"
41
46
  }, void 0, MainContent);
42
47
  };
43
48
 
49
+ ChatEmptyState.defaultProps = props.defaultProps;
50
+ const ChatEmptyStateListWithSchema = reactDesc.describe(ChatEmptyState);
51
+ ChatEmptyStateListWithSchema.propTypes = props.emptyStateProps;
52
+
44
53
  exports.ChatEmptyState = ChatEmptyState;
54
+ exports.ChatEmptyStateListWithSchema = ChatEmptyStateListWithSchema;
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var dsPropsHelpers = require('@elliemae/ds-props-helpers');
6
+
7
+ const useValidateProps = (props, schema) => {
8
+ dsPropsHelpers.useValidatePropTypes(props, schema);
9
+ };
10
+
11
+ exports.useValidateProps = useValidateProps;
@@ -9,7 +9,8 @@ const defaultProps = {
9
9
  action: null
10
10
  };
11
11
  const emptyStateProps = {
12
- label: reactDesc.PropTypes.arrayOf(reactDesc.PropTypes.string).description('No Message to show text helper').defaultValue(defaultProps.label)
12
+ label: reactDesc.PropTypes.arrayOf(reactDesc.PropTypes.string).description('No Message to show text helper').defaultValue(defaultProps.label),
13
+ action: reactDesc.PropTypes.node.description('action element').defaultValue(defaultProps.action)
13
14
  };
14
15
 
15
16
  exports.defaultProps = defaultProps;
@@ -10,10 +10,10 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
10
10
  var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
11
11
 
12
12
  const CONTAINER_WIDTH = 300;
13
- const ChatEmptyStateWrapper = /*#__PURE__*/styled__default['default'](dsGrid.Grid).withConfig({
13
+ const ChatEmptyStateWrapper = /*#__PURE__*/styled__default["default"](dsGrid.Grid).withConfig({
14
14
  componentId: "sc-1tutmen-0"
15
15
  })(["height:100%;min-width:", "px;overflow:hidden;background:", ";"], CONTAINER_WIDTH, props => props.theme.colors.neutral['050']);
16
- const MessageWrapper = /*#__PURE__*/styled__default['default'].p.withConfig({
16
+ const MessageWrapper = /*#__PURE__*/styled__default["default"].p.withConfig({
17
17
  componentId: "sc-1tutmen-1"
18
18
  })(["font-size:18px;"]);
19
19