@elliemae/ds-chat-container 3.6.0-next.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.
- package/dist/cjs/ChatContainer.js +174 -0
- package/dist/cjs/ChatContainer.js.map +7 -0
- package/dist/cjs/ChatContainerDataTestids.js +42 -0
- package/dist/cjs/ChatContainerDataTestids.js.map +7 -0
- package/dist/cjs/index.js +35 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/parts/chat-composer/ChatContainerComposer.js +195 -0
- package/dist/cjs/parts/chat-composer/ChatContainerComposer.js.map +7 -0
- package/dist/cjs/parts/chat-composer/index.js +33 -0
- package/dist/cjs/parts/chat-composer/index.js.map +7 -0
- package/dist/cjs/parts/chat-composer/styled.js +99 -0
- package/dist/cjs/parts/chat-composer/styled.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/ChatContainerMessagesList.js +146 -0
- package/dist/cjs/parts/chat-container-messages-list/ChatContainerMessagesList.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/index.js +33 -0
- package/dist/cjs/parts/chat-container-messages-list/index.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/styled.js +110 -0
- package/dist/cjs/parts/chat-container-messages-list/styled.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/useActionRef.js +61 -0
- package/dist/cjs/parts/chat-container-messages-list/useActionRef.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/useChatContainerMessageList.js +106 -0
- package/dist/cjs/parts/chat-container-messages-list/useChatContainerMessageList.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/useFocusAndScrollHelpers.js +93 -0
- package/dist/cjs/parts/chat-container-messages-list/useFocusAndScrollHelpers.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/useGetNewMessages.js +46 -0
- package/dist/cjs/parts/chat-container-messages-list/useGetNewMessages.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/useGlobalEventListener.js +59 -0
- package/dist/cjs/parts/chat-container-messages-list/useGlobalEventListener.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/useKeyboard.js +151 -0
- package/dist/cjs/parts/chat-container-messages-list/useKeyboard.js.map +7 -0
- package/dist/cjs/parts/index.js +27 -0
- package/dist/cjs/parts/index.js.map +7 -0
- package/dist/cjs/react-desc-prop-types.js +184 -0
- package/dist/cjs/react-desc-prop-types.js.map +7 -0
- package/dist/cjs/styled.js +109 -0
- package/dist/cjs/styled.js.map +7 -0
- package/dist/esm/ChatContainer.js +153 -0
- package/dist/esm/ChatContainer.js.map +7 -0
- package/dist/esm/ChatContainerDataTestids.js +16 -0
- package/dist/esm/ChatContainerDataTestids.js.map +7 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/parts/chat-composer/ChatContainerComposer.js +175 -0
- package/dist/esm/parts/chat-composer/ChatContainerComposer.js.map +7 -0
- package/dist/esm/parts/chat-composer/index.js +7 -0
- package/dist/esm/parts/chat-composer/index.js.map +7 -0
- package/dist/esm/parts/chat-composer/styled.js +73 -0
- package/dist/esm/parts/chat-composer/styled.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/ChatContainerMessagesList.js +128 -0
- package/dist/esm/parts/chat-container-messages-list/ChatContainerMessagesList.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/index.js +7 -0
- package/dist/esm/parts/chat-container-messages-list/index.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/styled.js +84 -0
- package/dist/esm/parts/chat-container-messages-list/styled.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/useActionRef.js +35 -0
- package/dist/esm/parts/chat-container-messages-list/useActionRef.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/useChatContainerMessageList.js +84 -0
- package/dist/esm/parts/chat-container-messages-list/useChatContainerMessageList.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/useFocusAndScrollHelpers.js +67 -0
- package/dist/esm/parts/chat-container-messages-list/useFocusAndScrollHelpers.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/useGetNewMessages.js +20 -0
- package/dist/esm/parts/chat-container-messages-list/useGetNewMessages.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/useGlobalEventListener.js +33 -0
- package/dist/esm/parts/chat-container-messages-list/useGlobalEventListener.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/useKeyboard.js +125 -0
- package/dist/esm/parts/chat-container-messages-list/useKeyboard.js.map +7 -0
- package/dist/esm/parts/index.js +4 -0
- package/dist/esm/parts/index.js.map +7 -0
- package/dist/esm/react-desc-prop-types.js +158 -0
- package/dist/esm/react-desc-prop-types.js.map +7 -0
- package/dist/esm/styled.js +83 -0
- package/dist/esm/styled.js.map +7 -0
- package/package.json +162 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var ChatContainer_exports = {};
|
|
26
|
+
__export(ChatContainer_exports, {
|
|
27
|
+
ChatContainer: () => ChatContainer,
|
|
28
|
+
ChatContainerWithSchema: () => ChatContainerWithSchema
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(ChatContainer_exports);
|
|
31
|
+
var React = __toESM(require("react"));
|
|
32
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
|
+
var import_react = __toESM(require("react"));
|
|
34
|
+
var import_lodash = require("lodash");
|
|
35
|
+
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
36
|
+
var import_ds_indeterminate_progress_indicator = __toESM(require("@elliemae/ds-indeterminate-progress-indicator"));
|
|
37
|
+
var import_ds_banner = __toESM(require("@elliemae/ds-banner"));
|
|
38
|
+
var import_chat_composer = require("./parts/chat-composer");
|
|
39
|
+
var import_chat_container_messages_list = require("./parts/chat-container-messages-list");
|
|
40
|
+
var import_react_desc_prop_types = require("./react-desc-prop-types");
|
|
41
|
+
var import_ChatContainerDataTestids = require("./ChatContainerDataTestids");
|
|
42
|
+
var import_styled = require("./styled");
|
|
43
|
+
const ChatContainer = (props) => {
|
|
44
|
+
const propsWithDefault = (0, import_ds_utilities.useMemoMergePropsWithDefault)(props, import_react_desc_prop_types.defaultProps);
|
|
45
|
+
(0, import_ds_utilities.useValidateTypescriptPropTypes)(propsWithDefault, import_react_desc_prop_types.ChatContainerPropTypes);
|
|
46
|
+
const globalAttributes = (0, import_ds_utilities.useGetGlobalAttributes)(propsWithDefault);
|
|
47
|
+
const {
|
|
48
|
+
sendingText,
|
|
49
|
+
sendingMessages,
|
|
50
|
+
bannerPosition,
|
|
51
|
+
bannerProps,
|
|
52
|
+
messagesListProps,
|
|
53
|
+
composerProps,
|
|
54
|
+
composerProps: { onResize: onComposerResize, onKeyDown: onComposerKeyDown },
|
|
55
|
+
actionRef,
|
|
56
|
+
device,
|
|
57
|
+
isLoading,
|
|
58
|
+
hasMoreItems,
|
|
59
|
+
getMoreMessages
|
|
60
|
+
} = propsWithDefault;
|
|
61
|
+
const bannerRef = import_react.default.useRef({ focusOnWrapper: import_lodash.noop, focusOnLink: import_lodash.noop });
|
|
62
|
+
const containerRef = import_react.default.useRef();
|
|
63
|
+
const listRef = import_react.default.useRef({ scrollToIndex: import_lodash.noop });
|
|
64
|
+
const onResize = import_react.default.useCallback(
|
|
65
|
+
(height) => {
|
|
66
|
+
if (onComposerResize)
|
|
67
|
+
onComposerResize(height);
|
|
68
|
+
setTimeout(() => {
|
|
69
|
+
if (actionRef?.current?.scrollToIndex) {
|
|
70
|
+
actionRef.current.scrollToIndex(messagesListProps.messages.length - 1, {
|
|
71
|
+
align: "start"
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}, 50);
|
|
75
|
+
},
|
|
76
|
+
[onComposerResize, messagesListProps.messages, actionRef]
|
|
77
|
+
);
|
|
78
|
+
const Container = device === "desktop" ? import_styled.StyledChatContainerContent : import_styled.MobileStyledChatContainerContent;
|
|
79
|
+
const handleTabs = import_react.default.useCallback(
|
|
80
|
+
(e) => {
|
|
81
|
+
if (onComposerKeyDown)
|
|
82
|
+
onComposerKeyDown(e);
|
|
83
|
+
else if (e.shiftKey && e.key === "Tab" && messagesListProps.messages?.length > 0) {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
if (bannerPosition && ["top", "bottom"].includes(bannerPosition)) {
|
|
86
|
+
bannerRef.current.focusOnWrapper();
|
|
87
|
+
}
|
|
88
|
+
if (actionRef?.current && actionRef.current.getMessagesInView) {
|
|
89
|
+
const last = actionRef.current.getMessagesInView().pop();
|
|
90
|
+
if (last && actionRef.current.focusToIndexWithoutScroll)
|
|
91
|
+
actionRef.current?.focusToIndexWithoutScroll(last);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
[actionRef, onComposerKeyDown, bannerPosition, messagesListProps.messages?.length]
|
|
96
|
+
);
|
|
97
|
+
import_react.default.useEffect(() => {
|
|
98
|
+
if (actionRef && actionRef.current) {
|
|
99
|
+
actionRef.current.focusOnBanner = bannerRef.current.focusOnWrapper;
|
|
100
|
+
actionRef.current.focusOnBannerLink = bannerRef.current.focusOnLink;
|
|
101
|
+
}
|
|
102
|
+
}, [actionRef]);
|
|
103
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Container, {
|
|
104
|
+
...globalAttributes,
|
|
105
|
+
rows: ["minmax(0, 1fr)", "auto"],
|
|
106
|
+
ref: containerRef,
|
|
107
|
+
role: "region",
|
|
108
|
+
children: [
|
|
109
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
110
|
+
style: { position: "relative", overflow: "hidden" },
|
|
111
|
+
children: [
|
|
112
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_chat_container_messages_list.ChatContainerMessagesList, {
|
|
113
|
+
...messagesListProps,
|
|
114
|
+
actionRef: actionRef || listRef,
|
|
115
|
+
isLoading,
|
|
116
|
+
hasMoreItems,
|
|
117
|
+
getMoreMessages,
|
|
118
|
+
sendingMessages,
|
|
119
|
+
sendingText,
|
|
120
|
+
bannerPosition,
|
|
121
|
+
bannerRef
|
|
122
|
+
}),
|
|
123
|
+
isLoading && ["top", "bottom"].includes(isLoading) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled.StyledIndicatorContainer, {
|
|
124
|
+
isLoading,
|
|
125
|
+
"data-testid": import_ChatContainerDataTestids.ChatContainerDataTestIds.LOADING_INDICATOR,
|
|
126
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_indeterminate_progress_indicator.default, {
|
|
127
|
+
processing: true,
|
|
128
|
+
title: "Loading"
|
|
129
|
+
})
|
|
130
|
+
}) : null,
|
|
131
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled.StyledIndicatorContainer, {
|
|
132
|
+
linear: true,
|
|
133
|
+
isLoading: bannerPosition,
|
|
134
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_banner.default, {
|
|
135
|
+
showCloseButton: true,
|
|
136
|
+
label: bannerProps?.label || "Unread messages",
|
|
137
|
+
containerProps: { id: "ds-chat-banner" },
|
|
138
|
+
actionLink: {
|
|
139
|
+
label: bannerProps?.viewLabel || "View",
|
|
140
|
+
onClick: bannerProps?.onView
|
|
141
|
+
},
|
|
142
|
+
onClose: bannerProps?.onClose,
|
|
143
|
+
isOpen: true,
|
|
144
|
+
type: bannerProps?.type || import_ds_banner.BANNER_TYPES.INFO,
|
|
145
|
+
actionRef: bannerRef
|
|
146
|
+
})
|
|
147
|
+
}),
|
|
148
|
+
sendingMessages && sendingMessages.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled.StyledIndicatorContainer, {
|
|
149
|
+
isLoading: "bottom",
|
|
150
|
+
linear: true,
|
|
151
|
+
"data-testid": import_ChatContainerDataTestids.ChatContainerDataTestIds.LOADING_INDICATOR,
|
|
152
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_indeterminate_progress_indicator.default, {
|
|
153
|
+
processing: true,
|
|
154
|
+
title: sendingText,
|
|
155
|
+
lineOnly: true
|
|
156
|
+
})
|
|
157
|
+
}) : null
|
|
158
|
+
]
|
|
159
|
+
}),
|
|
160
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_chat_composer.ChatComposer, {
|
|
161
|
+
...composerProps,
|
|
162
|
+
onKeyDown: handleTabs,
|
|
163
|
+
onResize,
|
|
164
|
+
maxHeight: (containerRef.current?.clientHeight || 0) / 2,
|
|
165
|
+
actionRef: actionRef || listRef
|
|
166
|
+
})
|
|
167
|
+
]
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
ChatContainer.propTypes = import_react_desc_prop_types.ChatContainerPropTypes;
|
|
171
|
+
ChatContainer.displayName = "ChatContainer";
|
|
172
|
+
const ChatContainerWithSchema = (0, import_ds_utilities.describe)(ChatContainer);
|
|
173
|
+
ChatContainerWithSchema.propTypes = import_react_desc_prop_types.ChatContainerPropTypes;
|
|
174
|
+
//# sourceMappingURL=ChatContainer.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/ChatContainer.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable complexity */\nimport React, { WeakValidationMap } from 'react';\nimport { noop } from 'lodash';\nimport {\n useMemoMergePropsWithDefault,\n useGetGlobalAttributes,\n useValidateTypescriptPropTypes,\n describe,\n} from '@elliemae/ds-utilities';\n\nimport DSIndeterminateProgressIndicator from '@elliemae/ds-indeterminate-progress-indicator';\nimport DSBanner, { BANNER_TYPES } from '@elliemae/ds-banner';\nimport { ChatComposer } from './parts/chat-composer';\nimport { ChatContainerMessagesList } from './parts/chat-container-messages-list';\nimport { DSChatT, defaultProps, ChatContainerPropTypes } from './react-desc-prop-types';\nimport { ChatContainerDataTestIds } from './ChatContainerDataTestids';\nimport { StyledChatContainerContent, StyledIndicatorContainer, MobileStyledChatContainerContent } from './styled';\n\nconst ChatContainer: React.ComponentType<DSChatT.ContainerProps> = (props) => {\n const propsWithDefault = useMemoMergePropsWithDefault<DSChatT.ContainerProps>(props, defaultProps);\n useValidateTypescriptPropTypes<DSChatT.ContainerProps>(propsWithDefault, ChatContainerPropTypes);\n const globalAttributes = useGetGlobalAttributes(propsWithDefault);\n\n const {\n sendingText,\n sendingMessages,\n bannerPosition,\n bannerProps,\n messagesListProps,\n composerProps,\n composerProps: { onResize: onComposerResize, onKeyDown: onComposerKeyDown },\n actionRef,\n device,\n isLoading,\n hasMoreItems,\n getMoreMessages,\n } = propsWithDefault;\n const bannerRef = React.useRef({ focusOnWrapper: noop, focusOnLink: noop });\n const containerRef = React.useRef<HTMLElement>();\n const listRef = React.useRef({ scrollToIndex: noop });\n\n const onResize = React.useCallback(\n (height: number) => {\n if (onComposerResize) onComposerResize(height);\n /*\n setTimeout is used to equal the animation duration from the \n composer text area when increase its size\n */\n setTimeout(() => {\n if (actionRef?.current?.scrollToIndex) {\n actionRef.current.scrollToIndex(messagesListProps.messages.length - 1, {\n align: 'start',\n });\n }\n }, 50);\n },\n [onComposerResize, messagesListProps.messages, actionRef],\n );\n const Container = device === 'desktop' ? StyledChatContainerContent : MobileStyledChatContainerContent;\n const handleTabs = React.useCallback(\n (e: React.KeyboardEvent) => {\n if (onComposerKeyDown) onComposerKeyDown(e);\n else if (e.shiftKey && e.key === 'Tab' && messagesListProps.messages?.length > 0) {\n e.preventDefault();\n if (bannerPosition && ['top', 'bottom'].includes(bannerPosition)) {\n bannerRef.current.focusOnWrapper();\n }\n if (actionRef?.current && actionRef.current.getMessagesInView) {\n const last = actionRef.current.getMessagesInView().pop();\n if (last && actionRef.current.focusToIndexWithoutScroll) actionRef.current?.focusToIndexWithoutScroll(last);\n }\n }\n },\n [actionRef, onComposerKeyDown, bannerPosition, messagesListProps.messages?.length],\n );\n\n // Map actions\n React.useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.focusOnBanner = bannerRef.current.focusOnWrapper;\n actionRef.current.focusOnBannerLink = bannerRef.current.focusOnLink;\n }\n }, [actionRef]);\n return (\n <Container {...globalAttributes} rows={['minmax(0, 1fr)', 'auto']} ref={containerRef} role=\"region\">\n <div style={{ position: 'relative', overflow: 'hidden' }}>\n <ChatContainerMessagesList\n {...messagesListProps}\n actionRef={actionRef || listRef}\n isLoading={isLoading}\n hasMoreItems={hasMoreItems}\n getMoreMessages={getMoreMessages}\n sendingMessages={sendingMessages}\n sendingText={sendingText}\n bannerPosition={bannerPosition}\n bannerRef={bannerRef}\n />\n {isLoading && ['top', 'bottom'].includes(isLoading) ? (\n <StyledIndicatorContainer isLoading={isLoading} data-testid={ChatContainerDataTestIds.LOADING_INDICATOR}>\n <DSIndeterminateProgressIndicator processing title=\"Loading\" />\n </StyledIndicatorContainer>\n ) : null}\n <StyledIndicatorContainer linear isLoading={bannerPosition}>\n <DSBanner\n showCloseButton\n label={bannerProps?.label || 'Unread messages'}\n containerProps={{ id: 'ds-chat-banner' }}\n actionLink={{\n label: bannerProps?.viewLabel || 'View',\n onClick: bannerProps?.onView,\n }}\n onClose={bannerProps?.onClose}\n isOpen\n type={bannerProps?.type || BANNER_TYPES.INFO}\n actionRef={bannerRef}\n />\n </StyledIndicatorContainer>\n {sendingMessages && sendingMessages.length > 0 ? (\n <StyledIndicatorContainer isLoading=\"bottom\" linear data-testid={ChatContainerDataTestIds.LOADING_INDICATOR}>\n <DSIndeterminateProgressIndicator processing title={sendingText} lineOnly />\n </StyledIndicatorContainer>\n ) : null}\n </div>\n <ChatComposer\n {...composerProps}\n onKeyDown={handleTabs}\n onResize={onResize}\n maxHeight={(containerRef.current?.clientHeight || 0) / 2}\n actionRef={actionRef || listRef}\n />\n </Container>\n );\n};\n\nChatContainer.propTypes = ChatContainerPropTypes as WeakValidationMap<unknown>;\nChatContainer.displayName = 'ChatContainer';\nconst ChatContainerWithSchema = describe(ChatContainer);\nChatContainerWithSchema.propTypes = ChatContainerPropTypes as WeakValidationMap<unknown>;\n\nexport { ChatContainer, ChatContainerWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AAEA,mBAAyC;AACzC,oBAAqB;AACrB,0BAKO;AAEP,iDAA6C;AAC7C,uBAAuC;AACvC,2BAA6B;AAC7B,0CAA0C;AAC1C,mCAA8D;AAC9D,sCAAyC;AACzC,oBAAuG;AAEvG,MAAM,gBAA6D,CAAC,UAAU;AAC5E,QAAM,uBAAmB,kDAAqD,OAAO,yCA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AAa;AAAA,cACxC,WAAW;AAAA,aACb;AAAA,WACF;AAAA,UACC,mBAAmB,gBAAgB,SAAS,IAC3C,4CAAC;AAAA,YAAyB,WAAU;AAAA,YAAS,QAAM;AAAA,YAAC,eAAa,yDAAyB;AAAA,YACxF,sDAAC,2CAAAD,SAAA;AAAA,cAAiC,YAAU;AAAA,cAAC,OAAO;AAAA,cAAa,UAAQ;AAAA,aAAC;AAAA,WAC5E,IACE;AAAA;AAAA,OACN;AAAA,MACA,4CAAC;AAAA,QACE,GAAG;AAAA,QACJ,WAAW;AAAA,QACX;AAAA,QACA,YAAY,aAAa,SAAS,gBAAgB,KAAK;AAAA,QACvD,WAAW,aAAa;AAAA,OAC1B;AAAA;AAAA,GACF;AAEJ;AAEA,cAAc,YAAY;AAC1B,cAAc,cAAc;AAC5B,MAAM,8BAA0B,8BAAS,aAAa;AACtD,wBAAwB,YAAY;",
|
|
6
|
+
"names": ["React", "DSIndeterminateProgressIndicator", "DSBanner"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var ChatContainerDataTestids_exports = {};
|
|
26
|
+
__export(ChatContainerDataTestids_exports, {
|
|
27
|
+
ChatContainerDataTestIds: () => ChatContainerDataTestIds
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(ChatContainerDataTestids_exports);
|
|
30
|
+
var React = __toESM(require("react"));
|
|
31
|
+
const ChatContainerDataTestIds = {
|
|
32
|
+
COMPOSER: "chat-composer",
|
|
33
|
+
COMPOSER_TEXTAREA: "chat-composer-textarea",
|
|
34
|
+
COMPOSER_SEND_BUTTON: "chat-composer-send-button",
|
|
35
|
+
COMPOSER_COUNTER_AREA: "composer-counter-area",
|
|
36
|
+
LOADING_INDICATOR: "ds-chat-loading-indicator",
|
|
37
|
+
THREAD_CONTAINER: "chat-thread-container",
|
|
38
|
+
LOAD_MORE_BUTTON: "ds-chat-load-more-btn",
|
|
39
|
+
FLOATING_BUTTON: "chat-floating-button",
|
|
40
|
+
BANNER: "ds-banner-container"
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=ChatContainerDataTestids.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/ChatContainerDataTestids.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["export const ChatContainerDataTestIds = {\n COMPOSER: 'chat-composer',\n COMPOSER_TEXTAREA: 'chat-composer-textarea',\n COMPOSER_SEND_BUTTON: 'chat-composer-send-button',\n COMPOSER_COUNTER_AREA: 'composer-counter-area',\n LOADING_INDICATOR: 'ds-chat-loading-indicator',\n THREAD_CONTAINER: 'chat-thread-container',\n LOAD_MORE_BUTTON: 'ds-chat-load-more-btn',\n FLOATING_BUTTON: 'chat-floating-button',\n BANNER: 'ds-banner-container',\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAhB,MAAM,2BAA2B;AAAA,EACtC,UAAU;AAAA,EACV,mBAAmB;AAAA,EACnB,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,QAAQ;AACV;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var src_exports = {};
|
|
26
|
+
__export(src_exports, {
|
|
27
|
+
ChatContainer: () => import_ChatContainer.ChatContainer,
|
|
28
|
+
ChatContainerDataTestIds: () => import_ChatContainerDataTestids.ChatContainerDataTestIds,
|
|
29
|
+
ChatContainerWithSchema: () => import_ChatContainer.ChatContainerWithSchema
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(src_exports);
|
|
32
|
+
var React = __toESM(require("react"));
|
|
33
|
+
var import_ChatContainer = require("./ChatContainer");
|
|
34
|
+
var import_ChatContainerDataTestids = require("./ChatContainerDataTestids");
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["export { ChatContainer, ChatContainerWithSchema } from './ChatContainer';\nexport { ChatContainerDataTestIds } from './ChatContainerDataTestids';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,2BAAuD;AACvD,sCAAyC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var ChatContainerComposer_exports = {};
|
|
26
|
+
__export(ChatContainerComposer_exports, {
|
|
27
|
+
ChatComposer: () => ChatComposer,
|
|
28
|
+
ChatComposerWithSchema: () => ChatComposerWithSchema
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(ChatContainerComposer_exports);
|
|
31
|
+
var React = __toESM(require("react"));
|
|
32
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
|
+
var import_react = __toESM(require("react"));
|
|
34
|
+
var import_ds_grid = require("@elliemae/ds-grid");
|
|
35
|
+
var import_ds_icons = require("@elliemae/ds-icons");
|
|
36
|
+
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
37
|
+
var import_styled = require("./styled");
|
|
38
|
+
var import_ChatContainerDataTestids = require("../../ChatContainerDataTestids");
|
|
39
|
+
var import_react_desc_prop_types = require("../../react-desc-prop-types");
|
|
40
|
+
const ChatComposer = (props) => {
|
|
41
|
+
const propsWithDefault = (0, import_ds_utilities.useMemoMergePropsWithDefault)(props, import_react_desc_prop_types.defaultPropsComposer);
|
|
42
|
+
(0, import_ds_utilities.useValidateTypescriptPropTypes)(propsWithDefault, import_react_desc_prop_types.ChatComposerPropTypes);
|
|
43
|
+
const {
|
|
44
|
+
inputValue,
|
|
45
|
+
onChange,
|
|
46
|
+
onResize,
|
|
47
|
+
onSend,
|
|
48
|
+
onFocus,
|
|
49
|
+
onBlur,
|
|
50
|
+
onKeyDown,
|
|
51
|
+
maxHeight = 300,
|
|
52
|
+
placeholder,
|
|
53
|
+
inputMaxLength,
|
|
54
|
+
maxLengthMessage,
|
|
55
|
+
ariaMaxLengthMessage,
|
|
56
|
+
buttonDisabled,
|
|
57
|
+
dataTestid,
|
|
58
|
+
actionRef
|
|
59
|
+
} = propsWithDefault;
|
|
60
|
+
const COMPOSER_MIN_HEIGHT = 32;
|
|
61
|
+
const input = import_react.default.useRef();
|
|
62
|
+
const inputSize = import_react.default.useRef();
|
|
63
|
+
const inputSend = import_react.default.useRef(null);
|
|
64
|
+
const [height, setHeight] = import_react.default.useState(32);
|
|
65
|
+
const internalMaxHeight = import_react.default.useMemo(() => maxHeight - 24, [maxHeight]);
|
|
66
|
+
const [showScroll, setShowScroll] = import_react.default.useState(true);
|
|
67
|
+
import_react.default.useEffect(() => {
|
|
68
|
+
if (inputSize?.current?.scrollHeight) {
|
|
69
|
+
const newHeight = inputSize.current.scrollHeight > internalMaxHeight ? internalMaxHeight : inputSize.current?.scrollHeight;
|
|
70
|
+
if (newHeight !== height && newHeight > COMPOSER_MIN_HEIGHT && onResize)
|
|
71
|
+
onResize(newHeight);
|
|
72
|
+
setHeight(newHeight);
|
|
73
|
+
setShowScroll(inputSize.current.scrollHeight - inputSize.current.clientHeight > 5);
|
|
74
|
+
}
|
|
75
|
+
}, [inputValue, internalMaxHeight, height, onResize]);
|
|
76
|
+
import_react.default.useEffect(() => {
|
|
77
|
+
if (actionRef && actionRef.current) {
|
|
78
|
+
actionRef.current.focusToComposer = () => {
|
|
79
|
+
input?.current?.focus?.();
|
|
80
|
+
};
|
|
81
|
+
actionRef.current.focusToSend = () => {
|
|
82
|
+
input?.current?.focus?.();
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}, [actionRef]);
|
|
86
|
+
const handleChange = import_react.default.useCallback(
|
|
87
|
+
(e) => {
|
|
88
|
+
onChange(e.target.value);
|
|
89
|
+
},
|
|
90
|
+
[onChange]
|
|
91
|
+
);
|
|
92
|
+
const heightProps = { height, overflow: showScroll ? "auto" : "hidden" };
|
|
93
|
+
const inputLength = String(inputValue || "").length;
|
|
94
|
+
const hasError = import_react.default.useMemo(() => {
|
|
95
|
+
if (!inputMaxLength)
|
|
96
|
+
return false;
|
|
97
|
+
return inputLength > inputMaxLength;
|
|
98
|
+
}, [inputLength, inputMaxLength]);
|
|
99
|
+
const isSendButtonDisabled = (0, import_react.useMemo)(
|
|
100
|
+
() => !inputValue || buttonDisabled || hasError,
|
|
101
|
+
[inputValue, buttonDisabled, hasError]
|
|
102
|
+
);
|
|
103
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_styled.StyledChatContainerContentComposer, {
|
|
104
|
+
rows: ["auto", "15px"],
|
|
105
|
+
maxHeight: `${maxHeight}px`,
|
|
106
|
+
"data-testid": dataTestid ?? import_ChatContainerDataTestids.ChatContainerDataTestIds.COMPOSER,
|
|
107
|
+
children: [
|
|
108
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ds_grid.Grid, {
|
|
109
|
+
cols: ["1fr", "24px"],
|
|
110
|
+
style: { height: heightProps.height },
|
|
111
|
+
justifyContent: "center",
|
|
112
|
+
alignItems: "flex-end",
|
|
113
|
+
gutter: "xxs",
|
|
114
|
+
children: [
|
|
115
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled.StyledComposerInput, {
|
|
116
|
+
ref: input,
|
|
117
|
+
onChange: handleChange,
|
|
118
|
+
style: { ...heightProps },
|
|
119
|
+
value: inputValue,
|
|
120
|
+
onFocus,
|
|
121
|
+
onBlur,
|
|
122
|
+
onKeyDown,
|
|
123
|
+
placeholder,
|
|
124
|
+
"aria-label": "Message to send",
|
|
125
|
+
"data-testid": import_ChatContainerDataTestids.ChatContainerDataTestIds.COMPOSER_TEXTAREA,
|
|
126
|
+
name: "chat-composer-textarea",
|
|
127
|
+
id: "chat-composer-textarea"
|
|
128
|
+
}),
|
|
129
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_grid.Grid, {
|
|
130
|
+
height: "32px",
|
|
131
|
+
alignItems: "center",
|
|
132
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled.StyledComposerButton, {
|
|
133
|
+
buttonType: "icon",
|
|
134
|
+
onClick: onSend,
|
|
135
|
+
size: "s",
|
|
136
|
+
disabled: isSendButtonDisabled,
|
|
137
|
+
"aria-disabled": isSendButtonDisabled,
|
|
138
|
+
"data-testid": import_ChatContainerDataTestids.ChatContainerDataTestIds.COMPOSER_SEND_BUTTON,
|
|
139
|
+
"aria-label": "Send",
|
|
140
|
+
innerRef: inputSend,
|
|
141
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_icons.PaperAirplane, {
|
|
142
|
+
width: 18,
|
|
143
|
+
height: 18
|
|
144
|
+
})
|
|
145
|
+
})
|
|
146
|
+
})
|
|
147
|
+
]
|
|
148
|
+
}),
|
|
149
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled.StyledComposerInput, {
|
|
150
|
+
ref: inputSize,
|
|
151
|
+
style: {
|
|
152
|
+
height: 32,
|
|
153
|
+
visibility: "hidden",
|
|
154
|
+
pointerEvents: "none",
|
|
155
|
+
position: "absolute",
|
|
156
|
+
top: 0,
|
|
157
|
+
width: input.current?.clientWidth
|
|
158
|
+
},
|
|
159
|
+
onChange: handleChange,
|
|
160
|
+
value: inputValue
|
|
161
|
+
}),
|
|
162
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ds_grid.Grid, {
|
|
163
|
+
cols: ["1fr", "24px"],
|
|
164
|
+
justifyContent: "flex-end",
|
|
165
|
+
alignItems: "center",
|
|
166
|
+
gutter: "xxs",
|
|
167
|
+
pb: "xxs",
|
|
168
|
+
children: [
|
|
169
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_styled.StyledCounterArea, {
|
|
170
|
+
hasError,
|
|
171
|
+
"data-testid": import_ChatContainerDataTestids.ChatContainerDataTestIds.COMPOSER_COUNTER_AREA,
|
|
172
|
+
children: [
|
|
173
|
+
inputMaxLength && hasError ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
174
|
+
children: [
|
|
175
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled.StyledCounterErrorA11y, {
|
|
176
|
+
role: "alert",
|
|
177
|
+
children: ariaMaxLengthMessage || `You have entered ${inputLength} characters and have exceeded the limit by ${inputLength - inputMaxLength}. Please limit to less than ${inputMaxLength} characters. `
|
|
178
|
+
}),
|
|
179
|
+
maxLengthMessage || `Please limit to less than ${inputMaxLength} characters. `
|
|
180
|
+
]
|
|
181
|
+
}) : "",
|
|
182
|
+
inputMaxLength ? ` ${inputLength} / ${inputMaxLength}` : ""
|
|
183
|
+
]
|
|
184
|
+
}),
|
|
185
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_grid.Grid, {})
|
|
186
|
+
]
|
|
187
|
+
})
|
|
188
|
+
]
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
ChatComposer.propTypes = import_react_desc_prop_types.ChatComposerPropTypes;
|
|
192
|
+
ChatComposer.displayName = "ChatComposer";
|
|
193
|
+
const ChatComposerWithSchema = (0, import_ds_utilities.describe)(ChatComposer);
|
|
194
|
+
ChatComposerWithSchema.propTypes = import_react_desc_prop_types.ChatComposerPropTypes;
|
|
195
|
+
//# sourceMappingURL=ChatContainerComposer.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/parts/chat-composer/ChatContainerComposer.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-lines */\nimport React, { WeakValidationMap, useMemo } from 'react';\nimport { Grid } from '@elliemae/ds-grid';\nimport { PaperAirplane } from '@elliemae/ds-icons';\nimport { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes, describe } from '@elliemae/ds-utilities';\nimport {\n StyledChatContainerContentComposer,\n StyledComposerInput,\n StyledComposerButton,\n StyledCounterArea,\n StyledCounterErrorA11y,\n} from './styled';\nimport { ChatContainerDataTestIds } from '../../ChatContainerDataTestids';\n\nimport { DSChatT, ChatComposerPropTypes, defaultPropsComposer } from '../../react-desc-prop-types';\n// eslint-disable-next-line complexity\nconst ChatComposer: React.ComponentType<DSChatT.ComposerProps> = (props) => {\n const propsWithDefault = useMemoMergePropsWithDefault<DSChatT.ComposerProps>(props, defaultPropsComposer);\n useValidateTypescriptPropTypes<DSChatT.ComposerProps>(propsWithDefault, ChatComposerPropTypes);\n const {\n inputValue,\n onChange,\n onResize,\n onSend,\n onFocus,\n onBlur,\n onKeyDown,\n maxHeight = 300,\n placeholder,\n inputMaxLength,\n maxLengthMessage,\n ariaMaxLengthMessage,\n buttonDisabled,\n dataTestid,\n actionRef,\n } = propsWithDefault;\n\n const COMPOSER_MIN_HEIGHT = 32;\n const input = React.useRef<HTMLTextAreaElement>();\n const inputSize = React.useRef<HTMLTextAreaElement>();\n const inputSend = React.useRef<HTMLButtonElement>(null);\n const [height, setHeight] = React.useState(32);\n const internalMaxHeight = React.useMemo(() => maxHeight - 24, [maxHeight]);\n const [showScroll, setShowScroll] = React.useState(true);\n\n React.useEffect(() => {\n if (inputSize?.current?.scrollHeight) {\n const newHeight =\n inputSize.current.scrollHeight > internalMaxHeight ? internalMaxHeight : inputSize.current?.scrollHeight;\n if (newHeight !== height && newHeight > COMPOSER_MIN_HEIGHT && onResize) onResize(newHeight);\n setHeight(newHeight);\n setShowScroll(inputSize.current.scrollHeight - inputSize.current.clientHeight > 5);\n }\n }, [inputValue, internalMaxHeight, height, onResize]);\n\n React.useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.focusToComposer = () => {\n input?.current?.focus?.();\n };\n actionRef.current.focusToSend = () => {\n input?.current?.focus?.();\n };\n }\n }, [actionRef]);\n\n const handleChange: React.ChangeEventHandler<HTMLInputElement> = React.useCallback(\n (e) => {\n onChange(e.target.value);\n },\n [onChange],\n );\n const heightProps = { height, overflow: showScroll ? 'auto' : 'hidden' };\n\n const inputLength = String(inputValue || '').length;\n const hasError = React.useMemo(() => {\n if (!inputMaxLength) return false;\n return inputLength > inputMaxLength;\n }, [inputLength, inputMaxLength]);\n\n const isSendButtonDisabled = useMemo(\n () => !inputValue || buttonDisabled || hasError,\n [inputValue, buttonDisabled, hasError],\n );\n return (\n <StyledChatContainerContentComposer\n rows={['auto', '15px']}\n maxHeight={`${maxHeight}px`}\n data-testid={dataTestid ?? ChatContainerDataTestIds.COMPOSER}\n >\n <Grid\n cols={['1fr', '24px']}\n style={{ height: heightProps.height }}\n justifyContent=\"center\"\n alignItems=\"flex-end\"\n gutter=\"xxs\"\n >\n <StyledComposerInput\n ref={input}\n onChange={handleChange}\n style={{ ...heightProps }}\n value={inputValue}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n aria-label=\"Message to send\"\n data-testid={ChatContainerDataTestIds.COMPOSER_TEXTAREA}\n name=\"chat-composer-textarea\"\n id=\"chat-composer-textarea\"\n />\n\n <Grid height=\"32px\" alignItems=\"center\">\n <StyledComposerButton\n buttonType=\"icon\"\n onClick={onSend}\n size=\"s\"\n disabled={isSendButtonDisabled}\n aria-disabled={isSendButtonDisabled}\n data-testid={ChatContainerDataTestIds.COMPOSER_SEND_BUTTON}\n aria-label=\"Send\"\n innerRef={inputSend}\n >\n <PaperAirplane width={18} height={18} />\n </StyledComposerButton>\n </Grid>\n </Grid>\n <StyledComposerInput\n ref={inputSize}\n style={{\n height: 32,\n visibility: 'hidden',\n pointerEvents: 'none',\n position: 'absolute',\n top: 0,\n width: input.current?.clientWidth,\n }}\n onChange={handleChange}\n value={inputValue}\n />\n <Grid cols={['1fr', '24px']} justifyContent=\"flex-end\" alignItems=\"center\" gutter=\"xxs\" pb=\"xxs\">\n <StyledCounterArea hasError={hasError} data-testid={ChatContainerDataTestIds.COMPOSER_COUNTER_AREA}>\n {inputMaxLength && hasError ? (\n <>\n <StyledCounterErrorA11y role=\"alert\">\n {ariaMaxLengthMessage ||\n `You have entered ${inputLength} characters and have exceeded the limit by ${\n inputLength - inputMaxLength\n }. Please limit to less than ${inputMaxLength} characters. `}\n </StyledCounterErrorA11y>\n {maxLengthMessage || `Please limit to less than ${inputMaxLength} characters. `}\n </>\n ) : (\n ''\n )}\n {inputMaxLength ? ` ${inputLength} / ${inputMaxLength}` : ''}\n </StyledCounterArea>\n <Grid />\n </Grid>\n </StyledChatContainerContentComposer>\n );\n};\n\nChatComposer.propTypes = ChatComposerPropTypes as WeakValidationMap<unknown>;\nChatComposer.displayName = 'ChatComposer';\nconst ChatComposerWithSchema = describe(ChatComposer);\nChatComposerWithSchema.propTypes = ChatComposerPropTypes as WeakValidationMap<unknown>;\n\nexport { ChatComposer, ChatComposerWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AACA,mBAAkD;AAClD,qBAAqB;AACrB,sBAA8B;AAC9B,0BAAuF;AACvF,oBAMO;AACP,sCAAyC;AAEzC,mCAAqE;AAErE,MAAM,eAA2D,CAAC,UAAU;AAC1E,QAAM,uBAAmB,kDAAoD,OA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AA,aACxC;AAAA,WACF;AAAA;AAAA,OACF;AAAA,MACA,4CAAC;AAAA,QACC,KAAK;AAAA,QACL,OAAO;AAAA,UACL,QAAQ;AAAA,UACR,YAAY;AAAA,UACZ,eAAe;AAAA,UACf,UAAU;AAAA,UACV,KAAK;AAAA,UACL,OAAO,MAAM,SAAS;AAAA,QACxB;AAAA,QACA,UAAU;AAAA,QACV,OAAO;AAAA,OACT;AAAA,MACA,6CAAC;AAAA,QAAK,MAAM,CAAC,OAAO,MAAM;AAAA,QAAG,gBAAe;AAAA,QAAW,YAAW;AAAA,QAAS,QAAO;AAAA,QAAM,IAAG;AAAA,QACzF;AAAA,uDAAC;AAAA,YAAkB;AAAA,YAAoB,eAAa,yDAAyB;AAAA,YAC1E;AAAA,gCAAkB,WACjB;AAAA,gBACE;AAAA,8DAAC;AAAA,oBAAuB,MAAK;AAAA,oBAC1B,kCACC,oBAAoB,yDAClB,cAAc,6CACe;AAAA,mBACnC;AAAA,kBACC,oBAAoB,6BAA6B;AAAA;AAAA,eACpD,IAEA;AAAA,cAED,iBAAiB,IAAI,iBAAiB,mBAAmB;AAAA;AAAA,WAC5D;AAAA,UACA,4CAAC,uBAAK;AAAA;AAAA,OACR;AAAA;AAAA,GACF;AAEJ;AAEA,aAAa,YAAY;AACzB,aAAa,cAAc;AAC3B,MAAM,6BAAyB,8BAAS,YAAY;AACpD,uBAAuB,YAAY;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var chat_composer_exports = {};
|
|
26
|
+
__export(chat_composer_exports, {
|
|
27
|
+
ChatComposer: () => import_ChatContainerComposer.ChatComposer,
|
|
28
|
+
ChatComposerWithSchema: () => import_ChatContainerComposer.ChatComposerWithSchema
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(chat_composer_exports);
|
|
31
|
+
var React = __toESM(require("react"));
|
|
32
|
+
var import_ChatContainerComposer = require("./ChatContainerComposer");
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/parts/chat-composer/index.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["export { ChatComposer, ChatComposerWithSchema } from './ChatContainerComposer';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mCAAqD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|