@botonic/react 0.29.0 → 0.30.0-alpha.0

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 (112) hide show
  1. package/lib/cjs/contexts.js +14 -8
  2. package/lib/cjs/contexts.js.map +1 -1
  3. package/lib/cjs/index-types.d.ts +12 -6
  4. package/lib/cjs/index-types.js +6 -1
  5. package/lib/cjs/index-types.js.map +1 -1
  6. package/lib/cjs/webchat/components/{persistent-menu.d.ts → opened-persistent-menu.d.ts} +0 -4
  7. package/lib/cjs/webchat/components/{persistent-menu.js → opened-persistent-menu.js} +2 -12
  8. package/lib/cjs/webchat/components/opened-persistent-menu.js.map +1 -0
  9. package/lib/cjs/webchat/trigger-button/styles.js +1 -1
  10. package/lib/cjs/webchat/utils.d.ts +2 -0
  11. package/lib/cjs/webchat/utils.js +12 -0
  12. package/lib/cjs/webchat/utils.js.map +1 -0
  13. package/lib/cjs/webchat/webchat-input-panel/attachment.d.ts +7 -0
  14. package/lib/cjs/webchat/{components → webchat-input-panel}/attachment.js +6 -4
  15. package/lib/cjs/webchat/webchat-input-panel/attachment.js.map +1 -0
  16. package/lib/cjs/webchat/webchat-input-panel/emoji-picker.d.ts +6 -0
  17. package/lib/cjs/webchat/{components → webchat-input-panel}/emoji-picker.js +5 -20
  18. package/lib/cjs/webchat/webchat-input-panel/emoji-picker.js.map +1 -0
  19. package/lib/cjs/webchat/webchat-input-panel/index.d.ts +13 -0
  20. package/lib/cjs/webchat/webchat-input-panel/index.js +53 -0
  21. package/lib/cjs/webchat/webchat-input-panel/index.js.map +1 -0
  22. package/lib/cjs/webchat/webchat-input-panel/opened-emoji-picker.d.ts +6 -0
  23. package/lib/cjs/webchat/webchat-input-panel/opened-emoji-picker.js +15 -0
  24. package/lib/cjs/webchat/webchat-input-panel/opened-emoji-picker.js.map +1 -0
  25. package/lib/cjs/webchat/webchat-input-panel/persistent-menu.d.ts +6 -0
  26. package/lib/cjs/webchat/webchat-input-panel/persistent-menu.js +19 -0
  27. package/lib/cjs/webchat/webchat-input-panel/persistent-menu.js.map +1 -0
  28. package/lib/cjs/webchat/webchat-input-panel/send-button.d.ts +5 -0
  29. package/lib/cjs/webchat/{components → webchat-input-panel}/send-button.js +2 -2
  30. package/lib/cjs/webchat/webchat-input-panel/send-button.js.map +1 -0
  31. package/lib/cjs/webchat/webchat-input-panel/styles.d.ts +3 -0
  32. package/lib/cjs/webchat/webchat-input-panel/styles.js +30 -0
  33. package/lib/cjs/webchat/webchat-input-panel/styles.js.map +1 -0
  34. package/lib/cjs/webchat/webchat-input-panel/textarea.d.ts +12 -0
  35. package/lib/cjs/webchat/webchat-input-panel/textarea.js +57 -0
  36. package/lib/cjs/webchat/webchat-input-panel/textarea.js.map +1 -0
  37. package/lib/cjs/webchat/webchat.d.ts +0 -1
  38. package/lib/cjs/webchat/webchat.js +16 -108
  39. package/lib/cjs/webchat/webchat.js.map +1 -1
  40. package/lib/cjs/webchat-app.js +1 -1
  41. package/lib/cjs/webchat-app.js.map +1 -1
  42. package/lib/esm/contexts.js +14 -8
  43. package/lib/esm/contexts.js.map +1 -1
  44. package/lib/esm/index-types.d.ts +12 -6
  45. package/lib/esm/index-types.js +5 -0
  46. package/lib/esm/index-types.js.map +1 -1
  47. package/lib/esm/webchat/components/{persistent-menu.d.ts → opened-persistent-menu.d.ts} +0 -4
  48. package/lib/esm/webchat/components/{persistent-menu.js → opened-persistent-menu.js} +2 -11
  49. package/lib/esm/webchat/components/opened-persistent-menu.js.map +1 -0
  50. package/lib/esm/webchat/trigger-button/styles.js +1 -1
  51. package/lib/esm/webchat/utils.d.ts +2 -0
  52. package/lib/esm/webchat/utils.js +8 -0
  53. package/lib/esm/webchat/utils.js.map +1 -0
  54. package/lib/esm/webchat/webchat-input-panel/attachment.d.ts +7 -0
  55. package/lib/esm/webchat/{components → webchat-input-panel}/attachment.js +6 -4
  56. package/lib/esm/webchat/webchat-input-panel/attachment.js.map +1 -0
  57. package/lib/esm/webchat/webchat-input-panel/emoji-picker.d.ts +6 -0
  58. package/lib/esm/webchat/{components → webchat-input-panel}/emoji-picker.js +4 -18
  59. package/lib/esm/webchat/webchat-input-panel/emoji-picker.js.map +1 -0
  60. package/lib/esm/webchat/webchat-input-panel/index.d.ts +13 -0
  61. package/lib/esm/webchat/webchat-input-panel/index.js +49 -0
  62. package/lib/esm/webchat/webchat-input-panel/index.js.map +1 -0
  63. package/lib/esm/webchat/webchat-input-panel/opened-emoji-picker.d.ts +6 -0
  64. package/lib/esm/webchat/webchat-input-panel/opened-emoji-picker.js +10 -0
  65. package/lib/esm/webchat/webchat-input-panel/opened-emoji-picker.js.map +1 -0
  66. package/lib/esm/webchat/webchat-input-panel/persistent-menu.d.ts +6 -0
  67. package/lib/esm/webchat/webchat-input-panel/persistent-menu.js +14 -0
  68. package/lib/esm/webchat/webchat-input-panel/persistent-menu.js.map +1 -0
  69. package/lib/esm/webchat/webchat-input-panel/send-button.d.ts +5 -0
  70. package/lib/esm/webchat/{components → webchat-input-panel}/send-button.js +2 -2
  71. package/lib/esm/webchat/webchat-input-panel/send-button.js.map +1 -0
  72. package/lib/esm/webchat/webchat-input-panel/styles.d.ts +3 -0
  73. package/lib/esm/webchat/webchat-input-panel/styles.js +26 -0
  74. package/lib/esm/webchat/webchat-input-panel/styles.js.map +1 -0
  75. package/lib/esm/webchat/webchat-input-panel/textarea.d.ts +12 -0
  76. package/lib/esm/webchat/webchat-input-panel/textarea.js +52 -0
  77. package/lib/esm/webchat/webchat-input-panel/textarea.js.map +1 -0
  78. package/lib/esm/webchat/webchat.d.ts +0 -1
  79. package/lib/esm/webchat/webchat.js +15 -106
  80. package/lib/esm/webchat/webchat.js.map +1 -1
  81. package/lib/esm/webchat-app.js +2 -2
  82. package/lib/esm/webchat-app.js.map +1 -1
  83. package/package.json +3 -5
  84. package/src/contexts.tsx +10 -4
  85. package/src/index-types.ts +13 -6
  86. package/src/webchat/components/{persistent-menu.jsx → opened-persistent-menu.jsx} +0 -29
  87. package/src/webchat/trigger-button/styles.ts +1 -1
  88. package/src/webchat/utils.ts +7 -0
  89. package/src/webchat/{components/attachment.jsx → webchat-input-panel/attachment.tsx} +16 -4
  90. package/src/webchat/{components/emoji-picker.jsx → webchat-input-panel/emoji-picker.tsx} +11 -33
  91. package/src/webchat/webchat-input-panel/index.tsx +116 -0
  92. package/src/webchat/webchat-input-panel/opened-emoji-picker.tsx +34 -0
  93. package/src/webchat/webchat-input-panel/persistent-menu.tsx +41 -0
  94. package/src/webchat/{components/send-button.jsx → webchat-input-panel/send-button.tsx} +6 -2
  95. package/src/webchat/webchat-input-panel/styles.ts +29 -0
  96. package/src/webchat/webchat-input-panel/textarea.tsx +110 -0
  97. package/src/webchat/webchat.jsx +28 -190
  98. package/src/webchat-app.jsx +2 -2
  99. package/lib/cjs/webchat/components/attachment.d.ts +0 -5
  100. package/lib/cjs/webchat/components/attachment.js.map +0 -1
  101. package/lib/cjs/webchat/components/emoji-picker.d.ts +0 -5
  102. package/lib/cjs/webchat/components/emoji-picker.js.map +0 -1
  103. package/lib/cjs/webchat/components/persistent-menu.js.map +0 -1
  104. package/lib/cjs/webchat/components/send-button.d.ts +0 -3
  105. package/lib/cjs/webchat/components/send-button.js.map +0 -1
  106. package/lib/esm/webchat/components/attachment.d.ts +0 -5
  107. package/lib/esm/webchat/components/attachment.js.map +0 -1
  108. package/lib/esm/webchat/components/emoji-picker.d.ts +0 -5
  109. package/lib/esm/webchat/components/emoji-picker.js.map +0 -1
  110. package/lib/esm/webchat/components/persistent-menu.js.map +0 -1
  111. package/lib/esm/webchat/components/send-button.d.ts +0 -3
  112. package/lib/esm/webchat/components/send-button.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachment.js","sourceRoot":"","sources":["../../../../src/webchat/webchat-input-panel/attachment.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAEjD,OAAO,cAAc,MAAM,kCAAkC,CAAA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,CAAC,CAAC,CACnB,KAAC,iBAAiB,KAAG,CACtB,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,IAAC,GAAG,EAAE,cAAc,GAAI,CAC9B,IACK,EACR,gBACE,GAAG,EAAE,YAAY,EACjB,IAAI,EAAC,MAAM,EACX,IAAI,EAAC,MAAM,EACX,EAAE,EAAC,YAAY,EACf,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAC1B,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,MAAM,GACd,KACE,GACe,CACxB,CAAC,CAAC,CAAC,IAAI,GACP,CACJ,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,6 @@
1
+ interface EmojiPickerProps {
2
+ enableEmojiPicker: boolean;
3
+ onClick: () => void;
4
+ }
5
+ export declare const EmojiPicker: ({ enableEmojiPicker, onClick, }: EmojiPickerProps) => JSX.Element;
6
+ export {};
@@ -1,14 +1,11 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
- import Picker from 'emoji-picker-react';
3
- import React, { useContext } from 'react';
4
- import styled from 'styled-components';
2
+ import { useContext } from 'react';
5
3
  import LogoEmoji from '../../assets/emojiButton.svg';
6
4
  import { ROLES, WEBCHAT } from '../../constants';
7
5
  import { WebchatContext } from '../../contexts';
6
+ import { Icon } from '../components/common';
8
7
  import { ConditionalAnimation } from '../components/conditional-animation';
9
- import { useComponentVisible } from '../hooks';
10
- import { Icon } from './common';
11
- export const EmojiPicker = ({ enableEmojiPicker, onClick }) => {
8
+ export const EmojiPicker = ({ enableEmojiPicker, onClick, }) => {
12
9
  const { getThemeProperty } = useContext(WebchatContext);
13
10
  const CustomEmojiPicker = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.customEmojiPicker, undefined);
14
11
  const isEmojiPickerEnabled = () => {
@@ -17,21 +14,10 @@ export const EmojiPicker = ({ enableEmojiPicker, onClick }) => {
17
14
  return ((_a = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.enableEmojiPicker, enableEmojiPicker)) !== null && _a !== void 0 ? _a : hasCustomEmojiPicker);
18
15
  };
19
16
  const emojiPickerEnabled = isEmojiPickerEnabled();
20
- const handleClick = event => {
17
+ const handleClick = (event) => {
21
18
  onClick();
22
19
  event.stopPropagation();
23
20
  };
24
21
  return (_jsx(_Fragment, { children: emojiPickerEnabled ? (_jsx(ConditionalAnimation, { children: _jsx("div", Object.assign({ role: ROLES.EMOJI_PICKER_ICON, onClick: handleClick }, { children: CustomEmojiPicker ? (_jsx(CustomEmojiPicker, {})) : (_jsx(Icon, { src: LogoEmoji })) })) })) : null }));
25
22
  };
26
- const Container = styled.div `
27
- display: flex;
28
- justify-content: flex-end;
29
- position: absolute;
30
- right: 3px;
31
- top: -324px;
32
- `;
33
- export const OpenedEmojiPicker = props => {
34
- const { ref, isComponentVisible } = useComponentVisible(true, props.onClick);
35
- return (_jsx("div", Object.assign({ ref: ref }, { children: isComponentVisible && (_jsx(Container, Object.assign({ role: ROLES.EMOJI_PICKER }, { children: _jsx(Picker, { width: '100%', height: '19rem', previewConfig: { showPreview: false }, onEmojiClick: props.onEmojiClick, disableAutoFocus: true }) }))) })));
36
- };
37
23
  //# sourceMappingURL=emoji-picker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emoji-picker.js","sourceRoot":"","sources":["../../../../src/webchat/webchat-input-panel/emoji-picker.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,SAAS,MAAM,8BAA8B,CAAA;AACpD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAO1E,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAC1B,iBAAiB,EACjB,OAAO,GACU,EAAE,EAAE;IACrB,MAAM,EAAE,gBAAgB,EAAE,GAAG,UAAU,CAAC,cAAc,CAAC,CAAA;IAEvD,MAAM,iBAAiB,GAAG,gBAAgB,CACxC,OAAO,CAAC,iBAAiB,CAAC,iBAAiB,EAC3C,SAAS,CACV,CAAA;IAED,MAAM,oBAAoB,GAAG,GAAG,EAAE;;QAChC,MAAM,oBAAoB,GAAG,CAAC,CAAC,iBAAiB,CAAA;QAChD,OAAO,CACL,MAAA,gBAAgB,CACd,OAAO,CAAC,iBAAiB,CAAC,iBAAiB,EAC3C,iBAAiB,CAClB,mCAAI,oBAAoB,CAC1B,CAAA;IACH,CAAC,CAAA;IACD,MAAM,kBAAkB,GAAG,oBAAoB,EAAE,CAAA;IAEjD,MAAM,WAAW,GAAG,CAAC,KAAU,EAAE,EAAE;QACjC,OAAO,EAAE,CAAA;QACT,KAAK,CAAC,eAAe,EAAE,CAAA;IACzB,CAAC,CAAA;IAED,OAAO,CACL,4BACG,kBAAkB,CAAC,CAAC,CAAC,CACpB,KAAC,oBAAoB,cACnB,4BAAK,IAAI,EAAE,KAAK,CAAC,iBAAiB,EAAE,OAAO,EAAE,WAAW,gBACrD,iBAAiB,CAAC,CAAC,CAAC,CACnB,KAAC,iBAAiB,KAAG,CACtB,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,IAAC,GAAG,EAAE,SAAS,GAAI,CACzB,IACG,GACe,CACxB,CAAC,CAAC,CAAC,IAAI,GACP,CACJ,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { DeviceAdapter } from '../devices/device-adapter';
3
+ interface WebchatInputPanelProps {
4
+ persistentMenu: any;
5
+ enableEmojiPicker: boolean;
6
+ enableAttachments: boolean;
7
+ handleAttachment: (event: any) => void;
8
+ textareaRef: React.MutableRefObject<HTMLTextAreaElement>;
9
+ deviceAdapter: DeviceAdapter;
10
+ onUserInput?: (event: any) => Promise<void>;
11
+ }
12
+ export declare const WebchatInputPanel: ({ persistentMenu, enableEmojiPicker, enableAttachments, handleAttachment, textareaRef, deviceAdapter, onUserInput, }: WebchatInputPanelProps) => JSX.Element;
13
+ export {};
@@ -0,0 +1,49 @@
1
+ import { __awaiter } from "tslib";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { INPUT } from '@botonic/core';
4
+ import { useContext } from 'react';
5
+ import { v4 as uuidv4 } from 'uuid';
6
+ import { WEBCHAT } from '../../constants';
7
+ import { WebchatContext } from '../../contexts';
8
+ import { getFullMimeWhitelist } from '../../message-utils';
9
+ import { Attachment } from './attachment';
10
+ import { EmojiPicker } from './emoji-picker';
11
+ import { OpenedEmojiPicker } from './opened-emoji-picker';
12
+ import { PersistentMenu } from './persistent-menu';
13
+ import { SendButton } from './send-button';
14
+ import { UserInputContainer } from './styles';
15
+ import { Textarea } from './textarea';
16
+ export const WebchatInputPanel = ({ persistentMenu, enableEmojiPicker, enableAttachments, handleAttachment, textareaRef, deviceAdapter, onUserInput, }) => {
17
+ const { getThemeProperty, sendText, togglePersistentMenu, toggleEmojiPicker, webchatState, } = useContext(WebchatContext);
18
+ const handleSelectedEmoji = event => {
19
+ textareaRef.current.value += event.emoji;
20
+ textareaRef.current.focus();
21
+ };
22
+ const handleEmojiClick = () => {
23
+ toggleEmojiPicker(!webchatState.isEmojiPickerOpen);
24
+ };
25
+ const handleMenu = () => {
26
+ togglePersistentMenu(!webchatState.isPersistentMenuOpen);
27
+ };
28
+ const sendTextAreaText = () => __awaiter(void 0, void 0, void 0, function* () {
29
+ yield sendText(textareaRef.current.value);
30
+ textareaRef.current.value = '';
31
+ });
32
+ const sendChatEvent = (chatEvent) => __awaiter(void 0, void 0, void 0, function* () {
33
+ const chatEventInput = {
34
+ id: uuidv4(),
35
+ type: INPUT.CHAT_EVENT,
36
+ data: chatEvent,
37
+ };
38
+ if (onUserInput) {
39
+ onUserInput({
40
+ user: webchatState.session.user,
41
+ input: chatEventInput,
42
+ session: webchatState.session,
43
+ lastRoutePath: webchatState.lastRoutePath,
44
+ });
45
+ }
46
+ });
47
+ return (_jsxs(UserInputContainer, Object.assign({ style: Object.assign({}, getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.userInputStyle)), className: 'user-input-container' }, { children: [webchatState.isEmojiPickerOpen && (_jsx(OpenedEmojiPicker, { onEmojiClick: handleSelectedEmoji, onClick: handleEmojiClick })), _jsx(PersistentMenu, { onClick: handleMenu, persistentMenu: persistentMenu }), _jsx(Textarea, { deviceAdapter: deviceAdapter, persistentMenu: persistentMenu, textareaRef: textareaRef, sendChatEvent: sendChatEvent, sendTextAreaText: sendTextAreaText }), _jsx(EmojiPicker, { enableEmojiPicker: enableEmojiPicker, onClick: handleEmojiClick }), _jsx(Attachment, { enableAttachments: enableAttachments, onChange: handleAttachment, accept: getFullMimeWhitelist().join(',') }), _jsx(SendButton, { onClick: sendTextAreaText })] })));
48
+ };
49
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/webchat/webchat-input-panel/index.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAc,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAA;AAEnC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD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,EAAE,YAAY,CAAC,OAAO,CAAC,IAAI;gBAC/B,KAAK,EAAE,cAAc;gBACrB,OAAO,EAAE,YAAY,CAAC,OAAO;gBAC7B,aAAa,EAAE,YAAY,CAAC,aAAa;aAC1C,CAAC,CAAA;SACH;IACH,CAAC,CAAA,CAAA;IAED,OAAO,CACL,MAAC,kBAAkB,kBACjB,KAAK,oBACA,gBAAgB,CAAC,OAAO,CAAC,iBAAiB,CAAC,cAAc,CAAC,GAE/D,SAAS,EAAC,sBAAsB,iBAE/B,YAAY,CAAC,iBAAiB,IAAI,CACjC,KAAC,iBAAiB,IAChB,YAAY,EAAE,mBAAmB,EACjC,OAAO,EAAE,gBAAgB,GACzB,CACH,EAED,KAAC,cAAc,IAAC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,GAAI,EAEvE,KAAC,QAAQ,IACP,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,EAC9B,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,gBAAgB,GAClC,EAEF,KAAC,WAAW,IACV,iBAAiB,EAAE,iBAAiB,EACpC,OAAO,EAAE,gBAAgB,GACzB,EAEF,KAAC,UAAU,IACT,iBAAiB,EAAE,iBAAiB,EACpC,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,oBAAoB,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GACxC,EAEF,KAAC,UAAU,IAAC,OAAO,EAAE,gBAAgB,GAAI,KACtB,CACtB,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,6 @@
1
+ interface OpenedEmojiPickerProps {
2
+ onClick: () => void;
3
+ onEmojiClick: (event: any) => void;
4
+ }
5
+ export declare const OpenedEmojiPicker: ({ onClick, onEmojiClick, }: OpenedEmojiPickerProps) => JSX.Element;
6
+ export {};
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import Picker from 'emoji-picker-react';
3
+ import { ROLES } from '../../constants';
4
+ import { useComponentVisible } from '../hooks';
5
+ import { OpenedEmojiPickerContainer } from './styles';
6
+ export const OpenedEmojiPicker = ({ onClick, onEmojiClick, }) => {
7
+ const { ref, isComponentVisible } = useComponentVisible(true, onClick);
8
+ return (_jsx("div", Object.assign({ ref: ref }, { children: isComponentVisible && (_jsx(OpenedEmojiPickerContainer, Object.assign({ role: ROLES.EMOJI_PICKER }, { children: _jsx(Picker, { width: '100%', height: '19rem', previewConfig: { showPreview: false }, lazyLoadEmojis: true, onEmojiClick: onEmojiClick, autoFocusSearch: false }) }))) })));
9
+ };
10
+ //# sourceMappingURL=opened-emoji-picker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opened-emoji-picker.js","sourceRoot":"","sources":["../../../../src/webchat/webchat-input-panel/opened-emoji-picker.tsx"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAA;AAGvC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAA;AAOrD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAChC,OAAO,EACP,YAAY,GACW,EAAE,EAAE;IAC3B,MAAM,EAAE,GAAG,EAAE,kBAAkB,EAAE,GAAG,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IACtE,OAAO,CACL,4BAAK,GAAG,EAAE,GAAgC,gBACvC,kBAAkB,IAAI,CACrB,KAAC,0BAA0B,kBAAC,IAAI,EAAE,KAAK,CAAC,YAAY,gBAClD,KAAC,MAAM,IACL,KAAK,EAAC,MAAM,EACZ,MAAM,EAAC,OAAO,EACd,aAAa,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,EACrC,cAAc,EAAE,IAAI,EACpB,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,KAAK,GACtB,IACyB,CAC9B,IACG,CACP,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,6 @@
1
+ interface PersistentMenuProps {
2
+ persistentMenu: any;
3
+ onClick: () => void;
4
+ }
5
+ export declare const PersistentMenu: ({ onClick, persistentMenu, }: PersistentMenuProps) => JSX.Element;
6
+ export {};
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useContext } from 'react';
3
+ import LogoMenu from '../../assets/menuButton.svg';
4
+ import { ROLES, WEBCHAT } from '../../constants';
5
+ import { WebchatContext } from '../../contexts';
6
+ import { Icon } from '../components/common';
7
+ import { ConditionalAnimation } from '../components/conditional-animation';
8
+ export const PersistentMenu = ({ onClick, persistentMenu, }) => {
9
+ const { getThemeProperty } = useContext(WebchatContext);
10
+ const persistentMenuOptions = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.persistentMenu, persistentMenu);
11
+ const CustomMenuButton = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.customMenuButton, undefined);
12
+ return (_jsx(_Fragment, { children: persistentMenuOptions ? (_jsx(ConditionalAnimation, { children: _jsx("div", Object.assign({ role: ROLES.PERSISTENT_MENU_ICON, onClick: onClick }, { children: CustomMenuButton ? _jsx(CustomMenuButton, {}) : _jsx(Icon, { src: LogoMenu }) })) })) : null }));
13
+ };
14
+ //# sourceMappingURL=persistent-menu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persistent-menu.js","sourceRoot":"","sources":["../../../../src/webchat/webchat-input-panel/persistent-menu.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,QAAQ,MAAM,6BAA6B,CAAA;AAClD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAO1E,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAC7B,OAAO,EACP,cAAc,GACM,EAAE,EAAE;IACxB,MAAM,EAAE,gBAAgB,EAAE,GAAG,UAAU,CAAC,cAAc,CAAC,CAAA;IAEvD,MAAM,qBAAqB,GAAG,gBAAgB,CAC5C,OAAO,CAAC,iBAAiB,CAAC,cAAc,EACxC,cAAc,CACf,CAAA;IAED,MAAM,gBAAgB,GAAG,gBAAgB,CACvC,OAAO,CAAC,iBAAiB,CAAC,gBAAgB,EAC1C,SAAS,CACV,CAAA;IAED,OAAO,CACL,4BACG,qBAAqB,CAAC,CAAC,CAAC,CACvB,KAAC,oBAAoB,cACnB,4BAAK,IAAI,EAAE,KAAK,CAAC,oBAAoB,EAAE,OAAO,EAAE,OAAO,gBACpD,gBAAgB,CAAC,CAAC,CAAC,KAAC,gBAAgB,KAAG,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,GAAG,EAAE,QAAQ,GAAI,IAC9D,GACe,CACxB,CAAC,CAAC,CAAC,IAAI,GACP,CACJ,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ interface SendButtonProps {
2
+ onClick: () => Promise<void>;
3
+ }
4
+ export declare const SendButton: ({ onClick }: SendButtonProps) => JSX.Element;
5
+ export {};
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
- import React, { useContext } from 'react';
2
+ import { useContext } from 'react';
3
3
  import SendButtonIcon from '../../assets/send-button.svg';
4
4
  import { ROLES, WEBCHAT } from '../../constants';
5
5
  import { WebchatContext } from '../../contexts';
6
+ import { Icon } from '../components/common';
6
7
  import { ConditionalAnimation } from '../components/conditional-animation';
7
- import { Icon } from './common';
8
8
  export const SendButton = ({ onClick }) => {
9
9
  const { getThemeProperty } = useContext(WebchatContext);
10
10
  const sendButtonEnabled = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.enableSendButton, true);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send-button.js","sourceRoot":"","sources":["../../../../src/webchat/webchat-input-panel/send-button.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,cAAc,MAAM,8BAA8B,CAAA;AACzD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAM1E,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EAAE,OAAO,EAAmB,EAAE,EAAE;IACzD,MAAM,EAAE,gBAAgB,EAAE,GAAG,UAAU,CAAC,cAAc,CAAC,CAAA;IAEvD,MAAM,iBAAiB,GAAG,gBAAgB,CACxC,OAAO,CAAC,iBAAiB,CAAC,gBAAgB,EAC1C,IAAI,CACL,CAAA;IAED,MAAM,gBAAgB,GAAG,gBAAgB,CACvC,OAAO,CAAC,iBAAiB,CAAC,gBAAgB,EAC1C,SAAS,CACV,CAAA;IAED,OAAO,CACL,4BACG,iBAAiB,IAAI,gBAAgB,CAAC,CAAC,CAAC,CACvC,KAAC,oBAAoB,cACnB,4BAAK,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,gBAAgB,gBAChD,gBAAgB,CAAC,CAAC,CAAC,CAClB,KAAC,gBAAgB,KAAG,CACrB,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,IAAC,GAAG,EAAE,cAAc,GAAI,CAC9B,IACG,GACe,CACxB,CAAC,CAAC,CAAC,IAAI,GACP,CACJ,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export declare const UserInputContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ export declare const TextAreaContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
3
+ export declare const OpenedEmojiPickerContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -0,0 +1,26 @@
1
+ import styled from 'styled-components';
2
+ import { COLORS } from '../../constants';
3
+ export const UserInputContainer = styled.div `
4
+ min-height: 52px;
5
+ position: relative;
6
+ display: flex;
7
+ align-items: center;
8
+ justify-content: flex-start;
9
+ gap: 16px;
10
+ padding: 0px 16px;
11
+ z-index: 1;
12
+ border-top: 1px solid ${COLORS.SOLID_BLACK_ALPHA_0_5};
13
+ `;
14
+ export const TextAreaContainer = styled.div `
15
+ display: flex;
16
+ flex: 1 1 auto;
17
+ align-items: center;
18
+ `;
19
+ export const OpenedEmojiPickerContainer = styled.div `
20
+ display: flex;
21
+ justify-content: flex-end;
22
+ position: absolute;
23
+ right: 3px;
24
+ top: -324px;
25
+ `;
26
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../../src/webchat/webchat-input-panel/styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAEtC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAExC,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;0BASlB,MAAM,CAAC,qBAAqB;CACrD,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;CAI1C,CAAA;AAED,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;CAMnD,CAAA"}
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { PersistentMenuTheme } from '../../components/index-types';
3
+ import { DeviceAdapter } from '../devices/device-adapter';
4
+ interface TextareaProps {
5
+ deviceAdapter: DeviceAdapter;
6
+ persistentMenu: PersistentMenuTheme;
7
+ textareaRef: React.MutableRefObject<HTMLTextAreaElement>;
8
+ sendChatEvent: (event: string) => Promise<void>;
9
+ sendTextAreaText: () => Promise<void>;
10
+ }
11
+ export declare const Textarea: ({ deviceAdapter, persistentMenu, textareaRef, sendChatEvent, sendTextAreaText, }: TextareaProps) => JSX.Element;
12
+ export {};
@@ -0,0 +1,52 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useContext } from 'react';
3
+ import TextareaAutosize from 'react-textarea-autosize';
4
+ import { WEBCHAT } from '../../constants';
5
+ import { WebchatContext } from '../../contexts';
6
+ import { Typing } from '../../index-types';
7
+ import { TextAreaContainer } from './styles';
8
+ export const Textarea = ({ deviceAdapter, persistentMenu, textareaRef, sendChatEvent, sendTextAreaText, }) => {
9
+ const { getThemeProperty } = useContext(WebchatContext);
10
+ let isTyping = false;
11
+ let typingTimeout;
12
+ const persistentMenuOptions = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.persistentMenu, persistentMenu);
13
+ const onKeyDown = event => {
14
+ if (event.keyCode === 13 && event.shiftKey === false) {
15
+ event.preventDefault();
16
+ sendTextAreaText();
17
+ stopTyping();
18
+ }
19
+ };
20
+ const onKeyUp = () => {
21
+ if (textareaRef.current.value === '') {
22
+ stopTyping();
23
+ return;
24
+ }
25
+ if (!isTyping) {
26
+ startTyping();
27
+ }
28
+ clearTimeoutWithReset(true);
29
+ };
30
+ const clearTimeoutWithReset = (reset) => {
31
+ const waitTime = 20 * 1000;
32
+ if (typingTimeout)
33
+ clearTimeout(typingTimeout);
34
+ if (reset)
35
+ typingTimeout = setTimeout(stopTyping, waitTime);
36
+ };
37
+ const startTyping = () => {
38
+ isTyping = true;
39
+ sendChatEvent(Typing.On);
40
+ };
41
+ const stopTyping = () => {
42
+ clearTimeoutWithReset(false);
43
+ isTyping = false;
44
+ sendChatEvent(Typing.Off);
45
+ };
46
+ return (_jsx(TextAreaContainer, { children: _jsx(TextareaAutosize, { ref: (ref) => (textareaRef.current = ref), name: 'text', onFocus: () => {
47
+ deviceAdapter.onFocus();
48
+ }, onBlur: () => {
49
+ deviceAdapter.onBlur();
50
+ }, maxRows: 4, wrap: 'soft', maxLength: 1000, placeholder: getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.textPlaceholder, WEBCHAT.DEFAULTS.PLACEHOLDER), autoFocus: false, onKeyDown: e => onKeyDown(e), onKeyUp: onKeyUp, style: Object.assign({ display: 'flex', fontSize: deviceAdapter.fontSize(14), width: '100%', border: 'none', resize: 'none', overflow: 'auto', outline: 'none', flex: '1 1 auto', padding: 10, paddingLeft: persistentMenuOptions ? 0 : 10, fontFamily: 'inherit' }, getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.userInputBoxStyle)) }) }));
51
+ };
52
+ //# sourceMappingURL=textarea.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textarea.js","sourceRoot":"","sources":["../../../../src/webchat/webchat-input-panel/textarea.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,gBAAgB,MAAM,yBAAyB,CAAA;AAGtD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAU5C,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EACvB,aAAa,EACb,cAAc,EACd,WAAW,EACX,aAAa,EACb,gBAAgB,GACF,EAAE,EAAE;IAClB,MAAM,EAAE,gBAAgB,EAAE,GAAG,UAAU,CAAC,cAAc,CAAC,CAAA;IAEvD,IAAI,QAAQ,GAAG,KAAK,CAAA;IACpB,IAAI,aAAa,CAAA;IAEjB,MAAM,qBAAqB,GAAG,gBAAgB,CAC5C,OAAO,CAAC,iBAAiB,CAAC,cAAc,EACxC,cAAc,CACf,CAAA;IAED,MAAM,SAAS,GAAG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CAAC,OAAO,EAAE,CAAA;YACzB,CAAC,EACD,MAAM,EAAE,GAAG,EAAE;gBACX,aAAa,CAAC,MAAM,EAAE,CAAA;YACxB,CAAC,EACD,OAAO,EAAE,CAAC,EACV,IAAI,EAAC,MAAM,EACX,SAAS,EAAE,IAAI,EACf,WAAW,EAAE,gBAAgB,CAC3B,OAAO,CAAC,iBAAiB,CAAC,eAAe,EACzC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAC7B,EACD,SAAS,EAAE,KAAK,EAChB,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,EAC5B,OAAO,EAAE,OAAO,EAChB,KAAK,kBACH,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC,EACpC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,EAAE,EACX,WAAW,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAC3C,UAAU,EAAE,SAAS,IAClB,gBAAgB,CAAC,OAAO,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,IAElE,GACgB,CACrB,CAAA;AACH,CAAC,CAAA"}
@@ -1,3 +1,2 @@
1
- export function getParsedAction(botonicAction: any): any;
2
1
  export const Webchat: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
3
2
  import React from "react";
@@ -1,11 +1,9 @@
1
1
  import { __awaiter } from "tslib";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { INPUT, isMobile, params2queryString } from '@botonic/core';
3
+ import { BotonicAction, INPUT, isMobile, params2queryString, } from '@botonic/core';
4
4
  import merge from 'lodash.merge';
5
5
  import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState, } from 'react';
6
- import Textarea from 'react-textarea-autosize';
7
6
  import styled, { StyleSheetManager } from 'styled-components';
8
- import { useAsyncEffect } from 'use-async-effect';
9
7
  import { v4 as uuidv4 } from 'uuid';
10
8
  import { Audio, Document, Image, Text, Video } from '../components';
11
9
  import { Handoff } from '../components/handoff';
@@ -13,16 +11,13 @@ import { normalizeWebchatSettings } from '../components/webchat-settings';
13
11
  import { COLORS, MAX_ALLOWED_SIZE_MB, ROLES, WEBCHAT } from '../constants';
14
12
  import { WebchatContext, WebviewRequestContext } from '../contexts';
15
13
  import { SENDERS } from '../index-types';
16
- import { getFullMimeWhitelist, getMediaType, isAllowedSize, isAudio, isDocument, isImage, isMedia, isText, isVideo, readDataURL, } from '../message-utils';
14
+ import { getMediaType, isAllowedSize, isAudio, isDocument, isImage, isMedia, isText, isVideo, readDataURL, } from '../message-utils';
17
15
  import { msgToBotonic } from '../msg-to-botonic';
18
16
  import { scrollToBottom } from '../util/dom';
19
17
  import { isDev } from '../util/environment';
20
18
  import { deserializeRegex, stringifyWithRegexs } from '../util/regexs';
21
19
  import { _getThemeProperty, getServerErrorMessage, initSession, shouldKeepSessionOnReload, } from '../util/webchat';
22
- import { Attachment } from './components/attachment';
23
- import { EmojiPicker, OpenedEmojiPicker } from './components/emoji-picker';
24
- import { OpenedPersistentMenu, PersistentMenu, } from './components/persistent-menu';
25
- import { SendButton } from './components/send-button';
20
+ import { OpenedPersistentMenu } from './components/opened-persistent-menu';
26
21
  import { DeviceAdapter } from './devices/device-adapter';
27
22
  import { StyledWebchatHeader } from './header';
28
23
  import { useComponentWillMount, usePrevious, useTyping, useWebchat, } from './hooks';
@@ -30,13 +25,9 @@ import { WebchatMessageList } from './message-list';
30
25
  import { WebchatReplies } from './replies';
31
26
  import { TriggerButton } from './trigger-button';
32
27
  import { useStorageState } from './use-storage-state-hook';
28
+ import { getParsedAction } from './utils';
29
+ import { WebchatInputPanel } from './webchat-input-panel';
33
30
  import { WebviewContainer } from './webview';
34
- export const getParsedAction = botonicAction => {
35
- const splittedAction = botonicAction.split('create_case:');
36
- if (splittedAction.length <= 1)
37
- return undefined;
38
- return JSON.parse(splittedAction[1]);
39
- };
40
31
  const StyledWebchat = styled.div `
41
32
  position: fixed;
42
33
  right: 20px;
@@ -50,22 +41,6 @@ const StyledWebchat = styled.div `
50
41
  display: flex;
51
42
  flex-direction: column;
52
43
  `;
53
- const UserInputContainer = styled.div `
54
- min-height: 52px;
55
- position: relative;
56
- display: flex;
57
- align-items: center;
58
- justify-content: flex-start;
59
- gap: 16px;
60
- padding: 0px 16px;
61
- z-index: 1;
62
- border-top: 1px solid ${COLORS.SOLID_BLACK_ALPHA_0_5};
63
- `;
64
- const TextAreaContainer = styled.div `
65
- display: flex;
66
- flex: 1 1 auto;
67
- align-items: center;
68
- `;
69
44
  const ErrorMessageContainer = styled.div `
70
45
  position: relative;
71
46
  display: flex;
@@ -154,20 +129,6 @@ export const Webchat = forwardRef((props, ref) => {
154
129
  });
155
130
  }
156
131
  });
157
- const sendChatEvent = (chatEvent) => __awaiter(void 0, void 0, void 0, function* () {
158
- const chatEventInput = {
159
- id: uuidv4(),
160
- type: INPUT.CHAT_EVENT,
161
- data: chatEvent,
162
- };
163
- props.onUserInput &&
164
- props.onUserInput({
165
- user: webchatState.session.user,
166
- input: chatEventInput,
167
- session: webchatState.session,
168
- lastRoutePath: webchatState.lastRoutePath,
169
- });
170
- });
171
132
  // Load styles stored in window._botonicInsertStyles by Webpack
172
133
  useComponentWillMount(() => {
173
134
  if (window._botonicInsertStyles && window._botonicInsertStyles.length) {
@@ -246,7 +207,7 @@ export const Webchat = forwardRef((props, ref) => {
246
207
  webchatState.devSettings,
247
208
  webchatState.lastMessageUpdate,
248
209
  ]);
249
- useAsyncEffect(() => __awaiter(void 0, void 0, void 0, function* () {
210
+ useEffect(() => {
250
211
  if (!webchatState.online) {
251
212
  setError({
252
213
  message: getServerErrorMessage(props.server),
@@ -257,20 +218,19 @@ export const Webchat = forwardRef((props, ref) => {
257
218
  setError(undefined);
258
219
  }
259
220
  }
260
- }), [webchatState.online]);
221
+ }, [webchatState.online]);
261
222
  useTyping({ webchatState, updateTyping, updateMessage, host });
262
223
  useEffect(() => {
263
224
  updateTheme(merge(props.theme, theme, webchatState.themeUpdates));
264
225
  }, [props.theme, webchatState.themeUpdates]);
265
- const openWebview = (webviewComponent, params) => updateWebview(webviewComponent, params);
266
- const handleSelectedEmoji = event => {
267
- textArea.current.value += event.emoji;
268
- textArea.current.focus();
226
+ const openWebview = (webviewComponent, params) => {
227
+ updateWebview(webviewComponent, params);
269
228
  };
229
+ const textareaRef = useRef(null);
270
230
  const closeWebview = options => {
271
231
  updateWebview();
272
232
  if (userInputEnabled) {
273
- textArea.current.focus();
233
+ textareaRef.current.focus();
274
234
  }
275
235
  if (options === null || options === void 0 ? void 0 : options.payload) {
276
236
  sendPayload(options.payload);
@@ -280,12 +240,6 @@ export const Webchat = forwardRef((props, ref) => {
280
240
  sendPayload(`__PATH_PAYLOAD__${options.path}?${params}`);
281
241
  }
282
242
  };
283
- const handleMenu = () => {
284
- togglePersistentMenu(!webchatState.isPersistentMenuOpen);
285
- };
286
- const handleEmojiClick = () => {
287
- toggleEmojiPicker(!webchatState.isEmojiPickerOpen);
288
- };
289
243
  const persistentMenuOptions = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.persistentMenu, props.persistentMenu);
290
244
  const darkBackgroundMenu = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.darkBackgroundMenu, false);
291
245
  const getBlockInputs = (rule, inputData) => {
@@ -408,7 +362,7 @@ export const Webchat = forwardRef((props, ref) => {
408
362
  if (session) {
409
363
  updateSession(merge(session, { user: webchatState.session.user }));
410
364
  const action = session._botonic_action || '';
411
- const handoff = action.startsWith('create_case');
365
+ const handoff = action.startsWith(BotonicAction.CreateCase);
412
366
  if (handoff && isDev)
413
367
  addMessageComponent(_jsx(Handoff, {}));
414
368
  updateHandoff(handoff);
@@ -498,45 +452,6 @@ export const Webchat = forwardRef((props, ref) => {
498
452
  setCurrentAttachment(undefined);
499
453
  }
500
454
  });
501
- const sendTextAreaText = () => {
502
- sendText(textArea.current.value);
503
- textArea.current.value = '';
504
- };
505
- let isTyping = false;
506
- let typingTimeout = null;
507
- function clearTimeoutWithReset(reset) {
508
- const waitTime = 20 * 1000;
509
- if (typingTimeout)
510
- clearTimeout(typingTimeout);
511
- if (reset)
512
- typingTimeout = setTimeout(stopTyping, waitTime);
513
- }
514
- function startTyping() {
515
- isTyping = true;
516
- sendChatEvent('typing_on');
517
- }
518
- function stopTyping() {
519
- clearTimeoutWithReset(false);
520
- isTyping = false;
521
- sendChatEvent('typing_off');
522
- }
523
- const onKeyDown = event => {
524
- if (event.keyCode === 13 && event.shiftKey === false) {
525
- event.preventDefault();
526
- sendTextAreaText();
527
- stopTyping();
528
- }
529
- };
530
- const onKeyUp = () => {
531
- if (textArea.current.value === '') {
532
- stopTyping();
533
- return;
534
- }
535
- if (!isTyping) {
536
- startTyping();
537
- }
538
- clearTimeoutWithReset(true);
539
- };
540
455
  const webviewRequestContext = {
541
456
  closeWebview: closeWebview,
542
457
  getString: stringId => props.getString(stringId, webchatState.session),
@@ -561,14 +476,6 @@ export const Webchat = forwardRef((props, ref) => {
561
476
  return isUserInputEnabled && !webchatState.isCoverComponentOpen;
562
477
  };
563
478
  const userInputEnabled = isUserInputEnabled();
564
- const textArea = useRef(null);
565
- const userInputArea = () => {
566
- return (userInputEnabled && (_jsxs(UserInputContainer, Object.assign({ style: Object.assign({}, getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.userInputStyle)), className: 'user-input-container' }, { children: [webchatState.isEmojiPickerOpen && (_jsx(OpenedEmojiPicker, { height: webchatState.theme.style.height, onEmojiClick: handleSelectedEmoji, onClick: handleEmojiClick })), _jsx(PersistentMenu, { onClick: handleMenu, persistentMenu: props.persistentMenu }), _jsx(TextAreaContainer, { children: _jsx(Textarea, { inputRef: textArea, name: 'text', onFocus: () => {
567
- deviceAdapter.onFocus();
568
- }, onBlur: () => {
569
- deviceAdapter.onBlur();
570
- }, maxRows: 4, wrap: 'soft', maxLength: '1000', placeholder: getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.textPlaceholder, WEBCHAT.DEFAULTS.PLACEHOLDER), autoFocus: false, onKeyDown: e => onKeyDown(e), onKeyUp: onKeyUp, style: Object.assign({ display: 'flex', fontSize: deviceAdapter.fontSize(14), width: '100%', border: 'none', resize: 'none', overflow: 'auto', outline: 'none', flex: '1 1 auto', padding: 10, paddingLeft: persistentMenuOptions ? 0 : 10, fontFamily: 'inherit' }, getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.userInputBoxStyle)) }) }), _jsx(EmojiPicker, { enableEmojiPicker: props.enableEmojiPicker, onClick: handleEmojiClick }), _jsx(Attachment, { enableAttachments: props.enableAttachments, onChange: handleAttachment, accept: getFullMimeWhitelist().join(',') }), _jsx(SendButton, { onClick: sendTextAreaText })] }))));
571
- };
572
479
  const webchatWebview = () => (_jsx(WebviewRequestContext.Provider, Object.assign({ value: webviewRequestContext }, { children: _jsx(WebviewContainer, { style: Object.assign(Object.assign({}, getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.webviewStyle)), mobileStyle), webview: webchatState.webview }) })));
573
480
  let mobileStyle = {};
574
481
  if (isMobile(getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.mobileBreakpoint))) {
@@ -615,6 +522,8 @@ export const Webchat = forwardRef((props, ref) => {
615
522
  sendPayload,
616
523
  sendText,
617
524
  toggleWebchat,
525
+ toggleEmojiPicker,
526
+ togglePersistentMenu,
618
527
  updateLatestInput,
619
528
  updateMessage,
620
529
  updateReplies,
@@ -629,7 +538,7 @@ export const Webchat = forwardRef((props, ref) => {
629
538
  role: ROLES.WEBCHAT, id: WEBCHAT.DEFAULTS.ID, width: webchatState.width, height: webchatState.height, style: Object.assign(Object.assign({}, webchatState.theme.style), mobileStyle) }, { children: [_jsx(StyledWebchatHeader, { onCloseClick: () => {
630
539
  toggleWebchat(false);
631
540
  } }), webchatState.error.message && (_jsx(ErrorMessageContainer, { children: _jsx(ErrorMessage, { children: webchatState.error.message }) })), _jsx(WebchatMessageList, {}), webchatState.replies &&
632
- Object.keys(webchatState.replies).length > 0 && (_jsx(WebchatReplies, { replies: webchatState.replies })), webchatState.isPersistentMenuOpen && (_jsx(DarkenBackground, { component: persistentMenu() })), !webchatState.handoff && userInputArea(), webchatState.webview && webchatWebview(), webchatState.isCoverComponentOpen && coverComponent(), webchatState.isCustomComponentRendered &&
541
+ Object.keys(webchatState.replies).length > 0 && (_jsx(WebchatReplies, { replies: webchatState.replies })), webchatState.isPersistentMenuOpen && (_jsx(DarkenBackground, { component: persistentMenu() })), !webchatState.handoff && userInputEnabled && (_jsx(WebchatInputPanel, { persistentMenu: props.persistentMenu, enableEmojiPicker: props.enableEmojiPicker, enableAttachments: props.enableAttachments, handleAttachment: handleAttachment, textareaRef: textareaRef, deviceAdapter: deviceAdapter, onUserInput: props.onUserInput })), webchatState.webview && webchatWebview(), webchatState.isCoverComponentOpen && coverComponent(), webchatState.isCustomComponentRendered &&
633
542
  customComponent &&
634
543
  _renderCustomComponent()] })))] })));
635
544
  return props.shadowDOM ? (_jsx(StyleSheetManager, Object.assign({ target: host }, { children: WebchatComponent }))) : (WebchatComponent);