@elliemae/ds-chat 2.0.0-alpha.10 → 2.0.0-alpha.14

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 (123) hide show
  1. package/cjs/ChatDataTestids.js +27 -0
  2. package/cjs/parts/bubble/ChatBubble.js +15 -12
  3. package/cjs/parts/bubble/ChatBubbleArrow.js +64 -61
  4. package/cjs/parts/bubble/config/useValidateProps.js +5 -6
  5. package/cjs/parts/bubble/props.js +1 -1
  6. package/cjs/parts/bubble/styled.js +2 -31
  7. package/cjs/parts/chat-card/props.js +2 -2
  8. package/cjs/parts/chat-composer/ChatContainerComposer.js +16 -8
  9. package/cjs/parts/chat-composer/props.js +5 -11
  10. package/cjs/parts/chat-composer/styled.js +4 -4
  11. package/cjs/parts/chat-container/ChatContainer.js +67 -20
  12. package/cjs/parts/chat-container/config/useValidateProps.js +2 -2
  13. package/cjs/parts/chat-container/props.js +7 -13
  14. package/cjs/parts/chat-container/styled.js +2 -2
  15. package/cjs/parts/chat-container-header/ChatContainerHeader.js +3 -3
  16. package/cjs/parts/chat-container-header/helpers.js +31 -0
  17. package/cjs/parts/chat-container-header/styled.js +6 -6
  18. package/cjs/parts/chat-container-messages-list/ChatContainerMessagesList.js +156 -40
  19. package/cjs/parts/chat-container-messages-list/config/useValidateProps.js +2 -2
  20. package/cjs/parts/chat-container-messages-list/props.js +5 -13
  21. package/cjs/parts/chat-container-messages-list/styled.js +2 -6
  22. package/cjs/parts/chat-empty-state/ChatEmptyState.js +2 -3
  23. package/cjs/parts/chat-sidebar/SideBarChat.js +57 -29
  24. package/cjs/parts/chat-sidebar/props.js +11 -1
  25. package/cjs/parts/chat-sidebar/styled.js +2 -2
  26. package/cjs/parts/floating-button/FloatingButton.js +18 -10
  27. package/cjs/parts/floating-button/props.js +6 -2
  28. package/cjs/parts/grid-influencer/styled.js +2 -6
  29. package/cjs/parts/message-delimiter/styled.js +1 -1
  30. package/cjs/parts/sidebar-button/SidebarButton.js +6 -1
  31. package/cjs/parts/sidebar-button/props.js +2 -3
  32. package/cjs/parts/system-message/style.js +1 -1
  33. package/cjs/parts/tile-button/TileButton.js +31 -28
  34. package/cjs/parts/tile-button/props.js +12 -8
  35. package/cjs/parts/tile-button/styled.js +12 -5
  36. package/cjs/styled.js +1 -1
  37. package/esm/ChatDataTestids.js +23 -0
  38. package/esm/parts/bubble/ChatBubble.js +14 -11
  39. package/esm/parts/bubble/ChatBubbleArrow.js +64 -61
  40. package/esm/parts/bubble/config/useValidateProps.js +5 -6
  41. package/esm/parts/bubble/props.js +1 -1
  42. package/esm/parts/bubble/styled.js +2 -31
  43. package/esm/parts/chat-card/props.js +2 -2
  44. package/esm/parts/chat-composer/ChatContainerComposer.js +15 -6
  45. package/esm/parts/chat-composer/props.js +5 -11
  46. package/esm/parts/chat-composer/styled.js +2 -2
  47. package/esm/parts/chat-container/ChatContainer.js +65 -18
  48. package/esm/parts/chat-container/config/useValidateProps.js +2 -2
  49. package/esm/parts/chat-container/props.js +7 -13
  50. package/esm/parts/chat-container/styled.js +2 -2
  51. package/esm/parts/chat-container-header/ChatContainerHeader.js +3 -2
  52. package/esm/parts/chat-container-header/helpers.js +23 -0
  53. package/esm/parts/chat-container-header/styled.js +6 -6
  54. package/esm/parts/chat-container-messages-list/ChatContainerMessagesList.js +154 -38
  55. package/esm/parts/chat-container-messages-list/config/useValidateProps.js +2 -2
  56. package/esm/parts/chat-container-messages-list/props.js +5 -13
  57. package/esm/parts/chat-container-messages-list/styled.js +2 -6
  58. package/esm/parts/chat-empty-state/ChatEmptyState.js +1 -1
  59. package/esm/parts/chat-sidebar/SideBarChat.js +57 -28
  60. package/esm/parts/chat-sidebar/props.js +11 -1
  61. package/esm/parts/chat-sidebar/styled.js +2 -2
  62. package/esm/parts/floating-button/FloatingButton.js +18 -9
  63. package/esm/parts/floating-button/props.js +6 -2
  64. package/esm/parts/grid-influencer/styled.js +2 -6
  65. package/esm/parts/message-delimiter/styled.js +1 -1
  66. package/esm/parts/sidebar-button/SidebarButton.js +6 -1
  67. package/esm/parts/sidebar-button/props.js +1 -1
  68. package/esm/parts/system-message/style.js +1 -1
  69. package/esm/parts/tile-button/TileButton.js +32 -27
  70. package/esm/parts/tile-button/props.js +11 -3
  71. package/esm/parts/tile-button/styled.js +12 -7
  72. package/esm/styled.js +1 -1
  73. package/package.json +29 -6
  74. package/types/ChatDataTestids.d.ts +21 -0
  75. package/types/parts/bubble/ChatBubble.d.ts +18 -5
  76. package/types/parts/bubble/props.d.ts +13 -4
  77. package/types/parts/bubble/styled.d.ts +9 -9
  78. package/types/parts/bubble/tests/ChatBubble.test.d.ts +1 -0
  79. package/types/parts/chat-card/ChatCard.d.ts +24 -4
  80. package/types/parts/chat-card/props.d.ts +19 -3
  81. package/types/parts/chat-card/styled.d.ts +6 -6
  82. package/types/parts/chat-composer/ChatContainerComposer.d.ts +48 -13
  83. package/types/parts/chat-composer/styled.d.ts +117 -24
  84. package/types/parts/chat-composer/tests/ChatContainerComposer.test.d.ts +1 -0
  85. package/types/parts/chat-container/ChatContainer.d.ts +54 -13
  86. package/types/parts/chat-container/config/useValidateProps.d.ts +1 -1
  87. package/types/parts/chat-container/styled.d.ts +4 -4
  88. package/types/parts/chat-container/tests/ChatContainer.test.d.ts +1 -0
  89. package/types/parts/chat-container-header/helpers.d.ts +6 -0
  90. package/types/parts/chat-container-header/styled.d.ts +3 -3
  91. package/types/parts/chat-container-messages-list/ChatContainerMessagesList.d.ts +39 -9
  92. package/types/parts/chat-container-messages-list/config/useValidateProps.d.ts +1 -1
  93. package/types/parts/chat-container-messages-list/styled.d.ts +7 -7
  94. package/types/parts/chat-empty-state/ChatEmptyState.d.ts +12 -3
  95. package/types/parts/chat-empty-state/props.d.ts +7 -2
  96. package/types/parts/chat-empty-state/styled.d.ts +2 -2
  97. package/types/parts/chat-sidebar/SideBarChat.d.ts +39 -9
  98. package/types/parts/chat-sidebar/props.d.ts +39 -9
  99. package/types/parts/chat-sidebar/styled.d.ts +2 -2
  100. package/types/parts/floating-button/FloatingButton.d.ts +11 -2
  101. package/types/parts/floating-button/props.d.ts +13 -1
  102. package/types/parts/floating-button/styled.d.ts +1 -1
  103. package/types/parts/floating-container/styled.d.ts +1 -2
  104. package/types/parts/grid-influencer/styled.d.ts +2 -2
  105. package/types/parts/message-delimiter/MessageDelimiter.d.ts +21 -4
  106. package/types/parts/message-delimiter/props.d.ts +16 -3
  107. package/types/parts/message-delimiter/styled.d.ts +3 -3
  108. package/types/parts/sidebar-button/SidebarButton.d.ts +16 -5
  109. package/types/parts/sidebar-button/props.d.ts +16 -5
  110. package/types/parts/sidebar-button/styled.d.ts +3 -3
  111. package/types/parts/system-message/SystemMessage.d.ts +12 -2
  112. package/types/parts/system-message/props.d.ts +7 -1
  113. package/types/parts/system-message/style.d.ts +5 -5
  114. package/types/parts/tile-button/TileButton.d.ts +66 -17
  115. package/types/parts/tile-button/props.d.ts +64 -16
  116. package/types/parts/tile-button/styled.d.ts +9 -8
  117. package/types/prop-types.d.ts +28 -9
  118. package/types/tests/utils.d.ts +27 -0
  119. package/cjs/package.json +0 -4
  120. package/esm/package.json +0 -4
  121. package/types/parts/chat-composer/props.d.ts +0 -35
  122. package/types/parts/chat-container/props.d.ts +0 -39
  123. package/types/parts/chat-container-messages-list/props.d.ts +0 -23
@@ -0,0 +1,23 @@
1
+ const ChatDataTestIds = {
2
+ COMPOSER_TEXTAREA: 'chat-composer-textarea',
3
+ COMPOSER_SEND_BUTTON: 'chat-composer-send-button',
4
+ CARD_TITLE: 'chat-card-title',
5
+ CARD_WRAPPER: 'chat-card-wrapper',
6
+ CARD_TIME: 'chat-card-time',
7
+ CARD_RIGHT_ADDON: 'chat-right-addon',
8
+ CARD_CONTENT: 'chat-card-content',
9
+ LOADING_INDICATOR: 'ds-chat-loading-indicator',
10
+ HEADER_TITLE: 'chat-header-title',
11
+ HEADER_CHILDREN: 'chat-header-children',
12
+ THREAD_CONTAINER: 'chat-thread-container',
13
+ LOAD_MORE_BUTTON: 'ds-chat-load-more-btn',
14
+ FLOATING_BUTTON: 'chat-floating-button',
15
+ SYSTEM_MSG_TITLE: 'chat-system-message-title',
16
+ SYSTEM_MSG_BODY: 'chat-system-message-body',
17
+ SYSTEM_MSG_TIME: 'chat-system-message-time',
18
+ BUBBLE: 'ds-chat-bubble',
19
+ BUBBLE_TITLE: 'chat-bubble-title',
20
+ BUBBLE_BODY: 'chat-bubble-body'
21
+ };
22
+
23
+ export { ChatDataTestIds };
@@ -1,14 +1,16 @@
1
1
  import _jsx from '@babel/runtime/helpers/esm/jsx';
2
2
  import 'core-js/modules/web.url.to-json.js';
3
- import 'react';
3
+ import 'core-js/modules/esnext.async-iterator.map.js';
4
+ import 'core-js/modules/esnext.iterator.map.js';
5
+ import React from 'react';
4
6
  import { describe } from 'react-desc';
5
- import Warning from '@elliemae/ds-icons/WarningCircleFill';
7
+ import { WarningCircleFill } from '@elliemae/ds-icons';
6
8
  import { StyledWrapper, StyledColoredBubble, StyledTitleBubble, StyledTitleLeftBubble, StyledTitleRightBubble, StyleBodyWrapper, StyleErrorMessage, StyleHelpMessage } from './styled.js';
7
9
  import { propsBubbles } from './props.js';
8
10
  import { useValidateProps } from './config/useValidateProps.js';
9
11
  import { ChatBubbleArrow } from './ChatBubbleArrow.js';
10
12
 
11
- var _Warning;
13
+ var _br, _WarningCircleFill;
12
14
 
13
15
  const ChatBubble = props => {
14
16
  useValidateProps(props, ChatBubbleWithSchema.toJSON());
@@ -21,8 +23,9 @@ const ChatBubble = props => {
21
23
  errorMessage,
22
24
  helpMessage
23
25
  } = props;
26
+ const bodyParts = React.useMemo(() => typeof body === 'string' ? body.split('\n') : [body], [body]);
24
27
  return /*#__PURE__*/_jsx(StyledWrapper, {
25
- "data-testid": `ds-chat-bubble-${dsId}`,
28
+ "data-testid": "ds-chat-bubble-".concat(dsId),
26
29
  type: type
27
30
  }, void 0, /*#__PURE__*/_jsx(StyledColoredBubble, {
28
31
  type: type
@@ -33,22 +36,22 @@ const ChatBubble = props => {
33
36
  className: "sr-only"
34
37
  }, void 0, /*#__PURE__*/_jsx(StyledTitleLeftBubble, {
35
38
  alignItems: "center",
36
- "data-testid": `chat-bubble-title-${dsId}`
39
+ "data-testid": "chat-bubble-title-".concat(dsId)
37
40
  }, void 0, title), /*#__PURE__*/_jsx(StyledTitleRightBubble, {
38
41
  alignItems: "center",
39
42
  type: type,
40
- "data-testid": `chat-bubble-time-${dsId}`
43
+ "data-testid": "chat-bubble-time-".concat(dsId)
41
44
  }, void 0, time)), /*#__PURE__*/_jsx(StyleBodyWrapper, {
42
- "data-testid": `chat-bubble-body-${dsId}`
43
- }, void 0, body), /*#__PURE__*/_jsx(ChatBubbleArrow, {
45
+ "data-testid": "chat-bubble-body-".concat(dsId)
46
+ }, void 0, bodyParts.map((item, index) => /*#__PURE__*/_jsx(React.Fragment, {}, "".concat(item, "-").concat(index), item, index < bodyParts.length - 1 ? _br || (_br = /*#__PURE__*/_jsx("br", {})) : null))), /*#__PURE__*/_jsx(ChatBubbleArrow, {
44
47
  type: type
45
48
  })), errorMessage ? /*#__PURE__*/_jsx(StyleErrorMessage, {
46
- "data-testid": `chat-bubble-error-message-${dsId}`,
49
+ "data-testid": "chat-bubble-error-message-".concat(dsId),
47
50
  p: "xxs",
48
51
  gutter: "xxs",
49
52
  cols: [1, 'auto']
50
- }, void 0, /*#__PURE__*/_jsx("span", {}, void 0, errorMessage), _Warning || (_Warning = /*#__PURE__*/_jsx(Warning, {}))) : null, helpMessage ? /*#__PURE__*/_jsx(StyleHelpMessage, {
51
- "data-testid": `chat-bubble-help-message-${dsId}`,
53
+ }, void 0, /*#__PURE__*/_jsx("span", {}, void 0, errorMessage), _WarningCircleFill || (_WarningCircleFill = /*#__PURE__*/_jsx(WarningCircleFill, {}))) : null, helpMessage ? /*#__PURE__*/_jsx(StyleHelpMessage, {
54
+ "data-testid": "chat-bubble-help-message-".concat(dsId),
52
55
  p: "xxs",
53
56
  gutter: "xxs",
54
57
  cols: [1, 'auto']
@@ -4,66 +4,69 @@ import { StyledBubbleArrow } from './styled.js';
4
4
  import { BUBBLE_TYPES } from './props.js';
5
5
 
6
6
  var _svg, _svg2;
7
- const ChatBubbleArrow = ({
8
- type
9
- }) => /*#__PURE__*/_jsx(StyledBubbleArrow, {}, void 0, type === BUBBLE_TYPES.RECIPIENT ? _svg || (_svg = /*#__PURE__*/_jsx("svg", {
10
- width: "15px",
11
- height: "14px",
12
- viewBox: "0 0 15 14"
13
- }, void 0, /*#__PURE__*/_jsx("defs", {}, void 0, /*#__PURE__*/_jsx("path", {
14
- d: "M12,8.5 C12,7.9373169 11.6782751,7.4856453 11.2282104,7.196228 C11.2286673,7.1967363 3,2 3,2 L3,10 L10.5627441,10 L10.5658569,9.9933472 C11.3630371,9.9580688 12,9.3058472 12,8.5 Z",
15
- id: "path-1"
16
- }), /*#__PURE__*/_jsx("filter", {
17
- x: "-55.6%",
18
- y: "-50.0%",
19
- width: "211.1%",
20
- height: "225.0%",
21
- filterUnits: "objectBoundingBox",
22
- id: "filter-2"
23
- }, void 0, /*#__PURE__*/_jsx("feOffset", {
24
- dx: "2.3",
25
- dy: "1.2",
26
- in: "SourceAlpha",
27
- result: "shadowOffsetOuter1"
28
- }), /*#__PURE__*/_jsx("feGaussianBlur", {
29
- stdDeviation: "1.5",
30
- in: "shadowOffsetOuter1",
31
- result: "shadowBlurOuter1"
32
- }), /*#__PURE__*/_jsx("feColorMatrix", {
33
- values: "0 0 0 0 0.207843137 0 0 0 0 0.235294118 0 0 0 0 0.274509804 0 0 0 0.8 0",
34
- type: "matrix",
35
- in: "shadowBlurOuter1"
36
- }))), /*#__PURE__*/_jsx("g", {
37
- id: "[DSK]-Visual-Design",
38
- stroke: "none",
39
- strokeWidth: "1",
40
- fill: "none",
41
- fillRule: "evenodd"
42
- }, void 0, /*#__PURE__*/_jsx("g", {
43
- id: "Path-Copy",
44
- transform: "translate(7.500000, 6.000000) scale(-1, 1) translate(-7.500000, -6.000000) "
45
- }, void 0, /*#__PURE__*/_jsx("use", {
46
- fill: "black",
47
- fillOpacity: "1",
48
- filter: "url(#filter-2)",
49
- xlinkHref: "#path-1"
50
- }), /*#__PURE__*/_jsx("use", {
51
- fill: "#FFFFFF",
52
- fillRule: "evenodd",
53
- xlinkHref: "#path-1"
54
- }))))) : _svg2 || (_svg2 = /*#__PURE__*/_jsx("svg", {
55
- width: "9px",
56
- height: "8px",
57
- viewBox: "0 0 9 8"
58
- }, void 0, /*#__PURE__*/_jsx("g", {
59
- stroke: "none",
60
- strokeWidth: "1",
61
- fill: "none",
62
- fillRule: "evenodd"
63
- }, void 0, /*#__PURE__*/_jsx("path", {
64
- d: "M9,6.5 C9,5.9373169 8.6782751,5.4856453 8.2282104,5.196228 C8.2286673,5.1967363 0,0 0,0 L0,8 L7.5627441,8 L7.5658569,7.9933472 C8.3630371,7.9580688 9,7.3058472 9,6.5 Z",
65
- id: "Path",
66
- fill: "#1E79C2"
67
- })))));
7
+ const ChatBubbleArrow = _ref => {
8
+ let {
9
+ type
10
+ } = _ref;
11
+ return /*#__PURE__*/_jsx(StyledBubbleArrow, {}, void 0, type === BUBBLE_TYPES.RECIPIENT ? _svg || (_svg = /*#__PURE__*/_jsx("svg", {
12
+ width: "15px",
13
+ height: "14px",
14
+ viewBox: "0 0 15 14"
15
+ }, void 0, /*#__PURE__*/_jsx("defs", {}, void 0, /*#__PURE__*/_jsx("path", {
16
+ d: "M12,8.5 C12,7.9373169 11.6782751,7.4856453 11.2282104,7.196228 C11.2286673,7.1967363 3,2 3,2 L3,10 L10.5627441,10 L10.5658569,9.9933472 C11.3630371,9.9580688 12,9.3058472 12,8.5 Z",
17
+ id: "path-chat-bubble"
18
+ }), /*#__PURE__*/_jsx("filter", {
19
+ x: "-55.6%",
20
+ y: "-50.0%",
21
+ width: "211.1%",
22
+ height: "225.0%",
23
+ filterUnits: "objectBoundingBox",
24
+ id: "filter-2"
25
+ }, void 0, /*#__PURE__*/_jsx("feOffset", {
26
+ dx: "2.3",
27
+ dy: "1.2",
28
+ in: "SourceAlpha",
29
+ result: "shadowOffsetOuter1"
30
+ }), /*#__PURE__*/_jsx("feGaussianBlur", {
31
+ stdDeviation: "1.5",
32
+ in: "shadowOffsetOuter1",
33
+ result: "shadowBlurOuter1"
34
+ }), /*#__PURE__*/_jsx("feColorMatrix", {
35
+ values: "0 0 0 0 0.207843137 0 0 0 0 0.235294118 0 0 0 0 0.274509804 0 0 0 0.8 0",
36
+ type: "matrix",
37
+ in: "shadowBlurOuter1"
38
+ }))), /*#__PURE__*/_jsx("g", {
39
+ id: "[DSK]-Visual-Design",
40
+ stroke: "none",
41
+ strokeWidth: "1",
42
+ fill: "none",
43
+ fillRule: "evenodd"
44
+ }, void 0, /*#__PURE__*/_jsx("g", {
45
+ id: "Path-Copy",
46
+ transform: "translate(7.500000, 6.000000) scale(-1, 1) translate(-7.500000, -6.000000) "
47
+ }, void 0, /*#__PURE__*/_jsx("use", {
48
+ fill: "black",
49
+ fillOpacity: "1",
50
+ filter: "url(#filter-2)",
51
+ xlinkHref: "#path-chat-bubble"
52
+ }), /*#__PURE__*/_jsx("use", {
53
+ fill: "#FFFFFF",
54
+ fillRule: "evenodd",
55
+ xlinkHref: "#path-chat-bubble"
56
+ }))))) : _svg2 || (_svg2 = /*#__PURE__*/_jsx("svg", {
57
+ width: "9px",
58
+ height: "8px",
59
+ viewBox: "0 0 9 8"
60
+ }, void 0, /*#__PURE__*/_jsx("g", {
61
+ stroke: "none",
62
+ strokeWidth: "1",
63
+ fill: "none",
64
+ fillRule: "evenodd"
65
+ }, void 0, /*#__PURE__*/_jsx("path", {
66
+ d: "M9,6.5 C9,5.9373169 8.6782751,5.4856453 8.2282104,5.196228 C8.2286673,5.1967363 0,0 0,0 L0,8 L7.5627441,8 L7.5658569,7.9933472 C8.3630371,7.9580688 9,7.3058472 9,6.5 Z",
67
+ id: "Path",
68
+ fill: "#1E79C2"
69
+ })))));
70
+ };
68
71
 
69
72
  export { ChatBubbleArrow };
@@ -1,27 +1,26 @@
1
1
  import { useValidatePropTypes } from '@elliemae/ds-props-helpers';
2
2
 
3
3
  const throwError = message => {
4
- throw new Error(`Bubble:: ${message}
5
- `);
4
+ throw new Error("Bubble:: ".concat(message, "\n "));
6
5
  };
7
6
 
8
7
  const useValidateProps = (props, schema) => {
9
8
  useValidatePropTypes(props, schema);
10
9
 
11
10
  if (typeof props.title === 'undefined') {
12
- throwError(`Please provide a title property to use this component.`);
11
+ throwError("Please provide a title property to use this component.");
13
12
  }
14
13
 
15
14
  if (typeof props.time === 'undefined') {
16
- throwError(`Please provide a time property to use this component.`);
15
+ throwError("Please provide a time property to use this component.");
17
16
  }
18
17
 
19
18
  if (typeof props.body === 'undefined') {
20
- throwError(`Please provide a body property to use this component.`);
19
+ throwError("Please provide a body property to use this component.");
21
20
  }
22
21
 
23
22
  if (typeof props.type === 'undefined') {
24
- throwError(`Please provide a type property to use this component.`);
23
+ throwError("Please provide a type property to use this component.");
25
24
  }
26
25
  };
27
26
 
@@ -28,7 +28,7 @@ const propsBubbles = {
28
28
  type: PropTypes.oneOf([BUBBLE_TYPES.RECIPIENT, BUBBLE_TYPES.SENDER]).isRequired.description('Define bubble type ').defaultValue(defaultBubbleProps.type),
29
29
  title: PropTypes.string.isRequired.description('Title of the bubble').defaultValue(defaultBubbleProps.title),
30
30
  time: PropTypes.string.isRequired.description('Time of the bubble').defaultValue(defaultBubbleProps.title),
31
- body: PropTypes.oneOf(['string', 'element']).isRequired.description('Bubble content').defaultValue(defaultBubbleProps.body),
31
+ body: PropTypes.oneOfType([PropTypes.string, PropTypes.element]).isRequired.description('Bubble content').defaultValue(defaultBubbleProps.body),
32
32
  onClick: PropTypes.string.description('Callback when the bubble is tapped').defaultValue(defaultBubbleProps.onClick),
33
33
  errorMessage: PropTypes.oneOfType([PropTypes.string, PropTypes.element]).description('Error message to display at bottom of the bubble').defaultValue(defaultBubbleProps.onClick),
34
34
  helpMessage: PropTypes.oneOfType([PropTypes.string, PropTypes.element]).description('Help message to display at bottom of the bubble').defaultValue(defaultBubbleProps.onClick)
@@ -22,7 +22,7 @@ const StyleBodyWrapper = /*#__PURE__*/styled.div.withConfig({
22
22
  })(["font-size:13px;font-weight:400;line-height:15px;min-height:18px;padding:0px 10px 8px 10px;"]);
23
23
  const StyleErrorMessage = /*#__PURE__*/styled.div.withConfig({
24
24
  componentId: "sc-fe8e9o-5"
25
- })(["font-size:12px;font-weight:400;padding-top:", ";padding-bottom:", ";color:", ";align-items:flex-end;justify-content:center;text-align:right;line-height:15px;svg{fill:", ";}a{font-size:12px;color:", ";}.em-ds-icon{margin-left:8px;}"], props => props.theme.space.xxxs, props => props.theme.space.xxxs, props => props.theme.colors.danger[900], props => props.theme.colors.danger[900], props => props.theme.colors.danger[900]);
25
+ })(["font-size:12px;font-weight:400;padding-top:", ";color:", ";align-items:flex-end;justify-content:center;text-align:right;line-height:15px;svg{fill:", ";}a{font-size:12px;color:", ";}.em-ds-icon{margin-left:8px;}"], props => props.theme.space.xxxs, props => props.theme.colors.danger[900], props => props.theme.colors.danger[900], props => props.theme.colors.danger[900]);
26
26
  const StyleHelpMessage = /*#__PURE__*/styled(StyleErrorMessage).withConfig({
27
27
  componentId: "sc-fe8e9o-6"
28
28
  })(["font-size:12px;line-height:15px;color:", ";svg{fill:", ";}a{font-size:12px;color:", ";}"], props => props.theme.colors.neutral[500], props => props.theme.colors.danger[500], props => props.theme.colors.danger[500]); // bubble sender/ recipient
@@ -32,35 +32,6 @@ const StyledBubbleArrow = /*#__PURE__*/styled.div.withConfig({
32
32
  })(["display:block;content:'';position:absolute;bottom:10px;height:15px;"]);
33
33
  const StyledColoredBubble = /*#__PURE__*/styled.div.withConfig({
34
34
  componentId: "sc-fe8e9o-8"
35
- })(["min-width:224px;border-radius:10px;position:relative;", ""], props => props.type === BUBBLE_TYPES.SENDER ? `
36
- border: 1px solid ${props.theme.colors.brand['700']};
37
- background: ${props.theme.colors.brand[600]};
38
- color: ${props.theme.colors.neutral['000']};
39
- ${StyledBubbleArrow}{
40
- right: -9px;
41
- bottom: 6px;
42
- svg{
43
- fill: ${props.theme.colors.brand[600]};
44
- }
45
- }
46
-
47
- a {
48
- color: #FFF;
49
- }
50
-
51
- ` : `
52
- box-shadow: 0 1px 3px 0 rgba(53,60,70,0.80);
53
- background: ${props.theme.colors.neutral['000']};
54
- color: ${props.theme.colors.neutral[700]};
55
-
56
- ${StyledBubbleArrow}{
57
- left: -11px;
58
- bottom: 6px;
59
- svg{
60
- fill: ${props.theme.colors.neutral['000']};
61
- }
62
- }
63
-
64
- `);
35
+ })(["min-width:224px;border-radius:10px;position:relative;", ""], props => props.type === BUBBLE_TYPES.SENDER ? "\n border: 1px solid ".concat(props.theme.colors.brand['700'], ";\n background: ").concat(props.theme.colors.brand[600], ";\n color: ").concat(props.theme.colors.neutral['000'], ";\n ").concat(StyledBubbleArrow, "{ \n right: -9px;\n bottom: 6px;\n svg{\n fill: ").concat(props.theme.colors.brand[600], ";\n }\n }\n\n a {\n color: #FFF;\n }\n\n ") : "\n box-shadow: 0 1px 3px 0 rgba(53,60,70,0.80);\n background: ".concat(props.theme.colors.neutral['000'], ";\n color: ").concat(props.theme.colors.neutral[700], ";\n\n ").concat(StyledBubbleArrow, "{ \n left: -11px;\n bottom: 6px;\n svg{\n fill: ").concat(props.theme.colors.neutral['000'], ";\n }\n }\n\n "));
65
36
 
66
37
  export { StyleBodyWrapper, StyleErrorMessage, StyleHelpMessage, StyledBubbleArrow, StyledColoredBubble, StyledTitleBubble, StyledTitleLeftBubble, StyledTitleRightBubble, StyledWrapper };
@@ -1,8 +1,8 @@
1
1
  import { PropTypes } from 'react-desc';
2
2
 
3
3
  const propTypes = {
4
- title: PropTypes.string.isRequired.description(`Card's title`),
5
- content: PropTypes.string.description(`Card's content`),
4
+ title: PropTypes.string.isRequired.description("Card's title"),
5
+ content: PropTypes.string.description("Card's content"),
6
6
  time: PropTypes.string.description('Time'),
7
7
  rightAddon: PropTypes.element.description('Right addon, badge or icon')
8
8
  };
@@ -1,10 +1,16 @@
1
1
  import _jsx from '@babel/runtime/helpers/esm/jsx';
2
2
  import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
3
3
  import 'core-js/modules/web.url.to-json.js';
4
+ import 'core-js/modules/web.dom-collections.iterator.js';
5
+ import 'core-js/modules/esnext.async-iterator.filter.js';
6
+ import 'core-js/modules/esnext.iterator.constructor.js';
7
+ import 'core-js/modules/esnext.iterator.filter.js';
8
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
9
+ import 'core-js/modules/esnext.iterator.for-each.js';
4
10
  import React from 'react';
5
11
  import { Grid } from '@elliemae/ds-grid';
6
12
  import { describe } from 'react-desc';
7
- import PaperAirplane from '@elliemae/ds-icons/PaperAirplane';
13
+ import { PaperAirplane } from '@elliemae/ds-icons';
8
14
  import { StyledChatContainerContentComposer, StyledComposerInput, StyledComposerButton, StyledCounterArea, StyledCounterErrorA11y } from './styled.js';
9
15
  import { useValidateProps } from './config/useValidateProps.js';
10
16
  import { composerProps, defaultComposerPros } from './props.js';
@@ -27,9 +33,11 @@ const ChatComposer = props => {
27
33
  onSend,
28
34
  onFocus,
29
35
  onBlur,
36
+ onKeyDown,
30
37
  maxHeight = 300,
31
38
  placeholder,
32
39
  inputMaxLength,
40
+ maxLengthMessage,
33
41
  buttonDisabled,
34
42
  dataTestid,
35
43
  actionRef
@@ -47,7 +55,7 @@ const ChatComposer = props => {
47
55
  onResize(newHeight);
48
56
  setHeight(newHeight);
49
57
  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);
50
- }, [inputValue, internalMaxHeight]);
58
+ }, [inputValue, internalMaxHeight, onResize]);
51
59
  React.useEffect(() => {
52
60
  if (actionRef && actionRef.current) {
53
61
  actionRef.current.focusToComposer = () => {
@@ -58,7 +66,7 @@ const ChatComposer = props => {
58
66
  inputSend.current.focus();
59
67
  };
60
68
  }
61
- }, [actionRef.current]);
69
+ }, [actionRef]);
62
70
  const handleChange = React.useCallback(e => {
63
71
  onChange(e.target.value);
64
72
  }, [onChange]);
@@ -70,7 +78,7 @@ const ChatComposer = props => {
70
78
  const hasError = React.useMemo(() => inputLength > inputMaxLength, [inputLength, inputMaxLength]);
71
79
  return /*#__PURE__*/_jsx(StyledChatContainerContentComposer, {
72
80
  rows: ['auto', '15px'],
73
- maxHeight: `${maxHeight}px`,
81
+ maxHeight: "".concat(maxHeight, "px"),
74
82
  "data-testid": dataTestid
75
83
  }, void 0, /*#__PURE__*/_jsx(Grid, {
76
84
  cols: ['1fr', '24px'],
@@ -84,6 +92,7 @@ const ChatComposer = props => {
84
92
  value: inputValue,
85
93
  onFocus: onFocus,
86
94
  onBlur: onBlur,
95
+ onKeyDown: onKeyDown,
87
96
  placeholder: placeholder,
88
97
  "aria-label": "Message to send",
89
98
  "data-testid": "chat-composer-textarea"
@@ -127,8 +136,8 @@ const ChatComposer = props => {
127
136
  }, void 0, inputMaxLength && hasError ? /*#__PURE__*/jsxs(Fragment, {
128
137
  children: [/*#__PURE__*/_jsx(StyledCounterErrorA11y, {
129
138
  role: "alert"
130
- }, void 0, "You have exceeded the character limit by ", inputLength - inputMaxLength), "Please limit to less than ", inputMaxLength, " characters.", ' ']
131
- }) : '', inputMaxLength ? `${inputLength} / ${inputMaxLength}` : ''), _Grid || (_Grid = /*#__PURE__*/_jsx(Grid, {}))));
139
+ }, void 0, maxLengthMessage || "You have exceeded the character limit by ".concat(inputLength - inputMaxLength)), maxLengthMessage || "Please limit to less than ".concat(inputMaxLength, " characters. ")]
140
+ }) : '', inputMaxLength ? " ".concat(inputLength, " / ").concat(inputMaxLength) : ''), _Grid || (_Grid = /*#__PURE__*/_jsx(Grid, {}))));
132
141
  };
133
142
 
134
143
  ChatComposer.defaultProps = defaultComposerPros;
@@ -9,8 +9,10 @@ const defaultComposerPros = {
9
9
  onSend: noop,
10
10
  onFocus: noop,
11
11
  onBlur: noop,
12
+ onKeyDown: noop,
12
13
  maxHeight: 0,
13
14
  inputMaxLength: undefined,
15
+ maxLengthMessage: undefined,
14
16
  buttonDisabled: false,
15
17
  dataTestid: 'ds-chat-composer',
16
18
  actionRef: noop
@@ -18,26 +20,18 @@ const defaultComposerPros = {
18
20
  const composerProps = {
19
21
  placeholder: PropTypes.string.description('Input Placeholder').defaultValue(defaultComposerPros.placeholder),
20
22
  inputValue: PropTypes.string.description('Input value').defaultValue(defaultComposerPros.inputValue),
23
+ maxLengthMessage: PropTypes.string.description('Max length message').defaultValue(defaultComposerPros.maxLengthMessage),
21
24
  onChange: PropTypes.func.description('Called when the user types').defaultValue(defaultComposerPros.onChange),
22
25
  onResize: PropTypes.func.description('Called the input changes his height').defaultValue(defaultComposerPros.onResize),
23
26
  onSend: PropTypes.func.description('Called when the click send').defaultValue(defaultComposerPros.onSend),
24
27
  onFocus: PropTypes.func.description('Input focus').defaultValue(defaultComposerPros.onFocus),
25
28
  onBlur: PropTypes.func.description('Input blur').defaultValue(defaultComposerPros.onBlur),
29
+ onKeyDown: PropTypes.func.description('Input on key down').defaultValue(defaultComposerPros.onKeyDown),
26
30
  maxHeight: PropTypes.number.description('Max height of the composer. Use 0 for no limit').defaultValue(defaultComposerPros.onBlur),
27
31
  inputMaxLength: PropTypes.number.description('Max length of the composer. `undefined` for no limit').defaultValue(defaultComposerPros.inputMaxLength),
28
32
  buttonDisabled: PropTypes.bool.description('Control the disabled for the send button').defaultValue(defaultComposerPros.buttonDisabled),
29
33
  dataTestid: PropTypes.string.description('Data testid').defaultValue(defaultComposerPros.placeholder),
30
- actionRef: PropTypes.object.description(`Reference:
31
- {
32
- scrollToIndex: (n: number) => void,
33
- getMessagesInView: () => number[],
34
- focusToIndex: (n: number) => void,
35
- focusToList: () => void,
36
- focusToComposer: () => void,
37
- focusToSend: () => void,
38
- }
39
-
40
- `).defaultValue(defaultComposerPros.actionRef)
34
+ actionRef: PropTypes.object.description("Reference: \n { \n scrollToIndex: (n: number) => void,\n getMessagesInView: () => number[],\n focusToIndex: (n: number) => void,\n focusToList: () => void,\n focusToComposer: () => void,\n focusToSend: () => void,\n }\n \n ").defaultValue(defaultComposerPros.actionRef)
41
35
  };
42
36
 
43
37
  export { composerProps, defaultComposerPros };
@@ -8,13 +8,13 @@ const StyledChatContainerContentComposer = /*#__PURE__*/styled(Grid).withConfig(
8
8
  })(["width:100%;min-height:56px;background:", ";padding:", ";padding-bottom:3px;padding-top:6px;padding-left:", ";max-height:", ";border-top:1px solid #cbcfd7;"], props => props.theme.colors.neutral['050'], props => props.theme.space.xxs, props => props.theme.space.xs, props => props.maxHeight);
9
9
  const StyledComposerInput = /*#__PURE__*/styled.textarea.withConfig({
10
10
  componentId: "sc-1ahwpce-1"
11
- })(["padding:", ";resize:none;min-height:32px;border-radius:2px;border:solid 1px #cbcfd7;color:#25292f;height:", ";min-width:244px;overflow-y:auto;font-size:13px;font-weight:400;line-height:1;transition:height 0.3s;&:focus{outline:none;border:1px solid ", ";box-shadow:inset 0 0 0 1px #8cc2ed;border-radius:2px;}"], props => props.theme.space.xxs, props => typeof props.height === 'number' ? `${props.height}px` : props.height, props => props.theme.colors.brand[600]);
11
+ })(["padding:", ";resize:none;min-height:32px;border-radius:2px;border:solid 1px #cbcfd7;color:#25292f;height:", ";min-width:244px;overflow-y:auto;font-size:13px;font-weight:400;line-height:1;transition:height 0.05s;&:focus{outline:none;border:1px solid ", ";box-shadow:inset 0 0 0 1px #8cc2ed;border-radius:2px;}"], props => props.theme.space.xxs, props => typeof props.height === 'number' ? "".concat(props.height, "px") : props.height, props => props.theme.colors.brand[600]);
12
12
  const StyledComposerButton = /*#__PURE__*/styled(DSButton).withConfig({
13
13
  componentId: "sc-1ahwpce-2"
14
14
  })(["&:disabled{background:none;svg{fill:#5d6775;}}svg{fill:", ";}&:focus{background:", ";}"], props => props.theme.colors.brand[600], props => props.theme.colors.brand[200]);
15
15
  const StyledCounterArea = /*#__PURE__*/styled(Grid).withConfig({
16
16
  componentId: "sc-1ahwpce-3"
17
- })(["text-align:right;font-size:11px;height:15px;align-items:center;font-style:italic;", " position:relative;"], props => props.hasError ? `color:${props.theme.colors.danger[900]};` : '');
17
+ })(["text-align:right;font-size:11px;height:15px;align-items:center;font-style:italic;", " position:relative;"], props => props.hasError ? "color:".concat(props.theme.colors.danger[900], ";") : '');
18
18
  const StyledCounterErrorA11y = /*#__PURE__*/styled.span.withConfig({
19
19
  componentId: "sc-1ahwpce-4"
20
20
  })(["width:1px;height:1px;position:absolute;clip:rect(1px,1px,1px,1px);"]);
@@ -1,9 +1,14 @@
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.filter.js';
4
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
5
+ import 'core-js/modules/esnext.iterator.for-each.js';
1
6
  import _jsx from '@babel/runtime/helpers/esm/jsx';
2
7
  import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
3
8
  import React from 'react';
4
9
  import { noop } from 'lodash';
5
10
  import { describe } from 'react-desc';
6
- import DSIndeterminateProgressIndicator from '@elliemae/ds-basic/IndeterminateProgressIndicator';
11
+ import DSIndeterminateProgressIndicator from '@elliemae/ds-indeterminate-progress-indicator';
7
12
  import DSBanner, { BANNER_TYPES } from '@elliemae/ds-banner';
8
13
  import { ChatComposer } from '../chat-composer/ChatContainerComposer.js';
9
14
  import { ChatContainerMessagesList } from '../chat-container-messages-list/ChatContainerMessagesList.js';
@@ -21,7 +26,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
21
26
  const ChatContainer = props => {
22
27
  var _containerRef$current;
23
28
 
24
- useValidateProps(props, ChatContainerWithSchema.toTypescript());
29
+ useValidateProps(props, containerProps);
25
30
  const {
26
31
  sendingText,
27
32
  sendingMessages,
@@ -30,15 +35,20 @@ const ChatContainer = props => {
30
35
  messagesListProps,
31
36
  composerProps,
32
37
  composerProps: {
33
- onResize: onComposerResize
38
+ onResize: onComposerResize,
39
+ onKeyDown: onComposerKeyDown
34
40
  },
35
41
  actionRef,
36
- autoScroll,
37
42
  device,
38
43
  isLoading,
39
44
  hasMoreItems,
40
- getMoreMessages
45
+ getMoreMessages,
46
+ ariaLabel
41
47
  } = props;
48
+ const bannerRef = React.useRef({
49
+ focusOnWrapper: noop,
50
+ focusOnLink: noop
51
+ });
42
52
  const containerRef = React.useRef();
43
53
  const listRef = React.useRef({
44
54
  scrollToIndex: noop
@@ -46,21 +56,51 @@ const ChatContainer = props => {
46
56
  const onResize = React.useCallback(height => {
47
57
  if (onComposerResize) onComposerResize(height);
48
58
 
49
- if (autoScroll) {
50
- listRef.current.scrollToIndex(messagesListProps.messages.length - 1, {
51
- align: 'end'
52
- });
59
+ if (height > 30) {
60
+ /*
61
+ setTimeout is used to equal the animation duration from the
62
+ composer text area when increase its size
63
+ */
64
+ setTimeout(() => {
65
+ actionRef.current.scrollToIndex(messagesListProps.messages.length - 1, {
66
+ align: 'start'
67
+ });
68
+ }, 50);
53
69
  }
54
- }, [onComposerResize, messagesListProps.messages, autoScroll]);
70
+ }, [onComposerResize, messagesListProps.messages, actionRef]);
55
71
  const Container = device === 'desktop' ? StyledChatContainerContent : MobileStyledChatContainerContent;
72
+ const handleTabs = React.useCallback(e => {
73
+ if (onComposerKeyDown) onComposerKeyDown(e);else {
74
+ const ref = actionRef || listRef;
75
+
76
+ if (e.shiftKey && e.key === 'Tab') {
77
+ e.preventDefault();
78
+
79
+ if (['top', 'bottom'].includes(bannerPosition)) {
80
+ bannerRef.current.focusOnWrapper();
81
+ } else {
82
+ const last = ref.current.getMessagesInView().pop();
83
+ ref.current.focusToIndexWithoutScroll(last);
84
+ }
85
+ }
86
+ }
87
+ }, [actionRef, onComposerKeyDown, bannerPosition]); // Map actions
88
+
89
+ React.useEffect(() => {
90
+ if (actionRef && actionRef.current) {
91
+ actionRef.current.focusOnBanner = bannerRef.current.focusOnWrapper;
92
+ actionRef.current.focusOnBannerLink = bannerRef.current.focusOnLink;
93
+ }
94
+ }, [actionRef]);
56
95
  return /*#__PURE__*/jsxs(Container, {
57
96
  rows: ['minmax(0, 1fr)', 'auto'],
58
97
  ref: containerRef,
59
98
  role: "region",
60
- "aria-label": "chat window",
99
+ "aria-label": ariaLabel,
61
100
  children: [/*#__PURE__*/_jsx("div", {
62
101
  style: {
63
- position: 'relative'
102
+ position: 'relative',
103
+ overflow: 'hidden'
64
104
  }
65
105
  }, void 0, /*#__PURE__*/jsx(ChatContainerMessagesList, _objectSpread(_objectSpread({}, messagesListProps), {}, {
66
106
  actionRef: actionRef || listRef,
@@ -68,13 +108,17 @@ const ChatContainer = props => {
68
108
  hasMoreItems: hasMoreItems,
69
109
  getMoreMessages: getMoreMessages,
70
110
  sendingMessages: sendingMessages,
71
- sendingText: sendingText
111
+ sendingText: sendingText,
112
+ bannerPosition: bannerPosition,
113
+ bannerRef: bannerRef
72
114
  })), ['top', 'bottom'].includes(isLoading) ? /*#__PURE__*/_jsx(StyledIndicatorContainer, {
73
- isLoading: isLoading
115
+ isLoading: isLoading,
116
+ "data-testid": "ds-chat-loading-indicator"
74
117
  }, void 0, _DSIndeterminateProgr || (_DSIndeterminateProgr = /*#__PURE__*/_jsx(DSIndeterminateProgressIndicator, {
75
118
  processing: true,
76
119
  title: "Loading"
77
- }))) : null, ['top', 'bottom'].includes(bannerPosition) ? /*#__PURE__*/_jsx(StyledIndicatorContainer, {
120
+ }))) : null, /*#__PURE__*/_jsx(StyledIndicatorContainer, {
121
+ linear: true,
78
122
  isLoading: bannerPosition
79
123
  }, void 0, /*#__PURE__*/_jsx(DSBanner, {
80
124
  showCloseButton: true,
@@ -88,15 +132,18 @@ const ChatContainer = props => {
88
132
  },
89
133
  onClose: bannerProps.onClose,
90
134
  isOpen: true,
91
- type: BANNER_TYPES.INFO
92
- })) : null, sendingMessages && sendingMessages.length > 0 ? _StyledIndicatorConta || (_StyledIndicatorConta = /*#__PURE__*/_jsx(StyledIndicatorContainer, {
135
+ type: bannerProps.type || BANNER_TYPES.INFO,
136
+ actionRef: bannerRef
137
+ })), sendingMessages && sendingMessages.length > 0 ? _StyledIndicatorConta || (_StyledIndicatorConta = /*#__PURE__*/_jsx(StyledIndicatorContainer, {
93
138
  isLoading: "bottom",
94
- linear: true
139
+ linear: true,
140
+ "data-testid": "ds-chat-loading-indicator"
95
141
  }, void 0, /*#__PURE__*/_jsx(DSIndeterminateProgressIndicator, {
96
142
  processing: true,
97
143
  title: "Loading",
98
144
  lineOnly: true
99
145
  }))) : null), /*#__PURE__*/jsx(ChatComposer, _objectSpread(_objectSpread({}, composerProps), {}, {
146
+ onKeyDown: handleTabs,
100
147
  onResize: onResize,
101
148
  maxHeight: (((_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.clientHeight) || 0) / 2,
102
149
  actionRef: actionRef || listRef
@@ -1,7 +1,7 @@
1
1
  import { useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';
2
2
 
3
- const useValidateProps = (props, schema) => {
4
- useValidateTypescriptPropTypes(props, schema);
3
+ const useValidateProps = (props, propTypes) => {
4
+ useValidateTypescriptPropTypes(props, propTypes);
5
5
  };
6
6
 
7
7
  export { useValidateProps };