@vendorflow/components 2.0.40 → 2.0.41
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/lib/components/InfiniteScroll/InfiniteScroll.js +0 -6
- package/lib/components/material-ui/ChatInterface/ChatInterface.d.ts +3 -2
- package/lib/components/material-ui/ChatInterface/ChatInterface.js +2 -2
- package/lib/components/material-ui/ChatInterface/ChatInterface.story.js +2 -2
- package/lib/components/material-ui/ChatInterface/MessageInput.d.ts +2 -3
- package/lib/components/material-ui/ChatInterface/MessageInput.js +2 -2
- package/package.json +1 -1
|
@@ -89,11 +89,7 @@ function useInfiniteScroll(_a) {
|
|
|
89
89
|
return false;
|
|
90
90
|
}, [(_b = scrollParent.current) === null || _b === void 0 ? void 0 : _b.clientHeight, (_c = scrollBody.current) === null || _c === void 0 ? void 0 : _c.clientHeight]);
|
|
91
91
|
(0, react_2.useEffect)(function () {
|
|
92
|
-
var _a, _b;
|
|
93
92
|
if (!isLoading && hasScrollbar) {
|
|
94
|
-
console.log('scrolling to start!');
|
|
95
|
-
console.log('scroll parent height: ', (_a = scrollParent.current) === null || _a === void 0 ? void 0 : _a.clientHeight);
|
|
96
|
-
console.log('scroll body height: ', (_b = scrollBody.current) === null || _b === void 0 ? void 0 : _b.clientHeight);
|
|
97
93
|
prevPosition.current = null;
|
|
98
94
|
scrollToStart();
|
|
99
95
|
}
|
|
@@ -118,7 +114,6 @@ function useInfiniteScroll(_a) {
|
|
|
118
114
|
if (scrollBody.current && isReverse && isScrollInit) {
|
|
119
115
|
// save the last element, so that we can scroll to it after the new data loads in
|
|
120
116
|
prevPosition.current = scrollBody.current.clientHeight;
|
|
121
|
-
console.log('saving prev position: ', prevPosition.current);
|
|
122
117
|
}
|
|
123
118
|
// load the next page
|
|
124
119
|
fetchNextPage();
|
|
@@ -129,7 +124,6 @@ function useInfiniteScroll(_a) {
|
|
|
129
124
|
});
|
|
130
125
|
if (node) {
|
|
131
126
|
if (isReverse && scrollParent.current && prevPosition.current != null) {
|
|
132
|
-
console.log('scrolling to prev position: ', prevPosition.current);
|
|
133
127
|
// If we had a prev position, then we want to scroll to it
|
|
134
128
|
scrollParent.current.scrollTo(0, scrollBody.current.clientHeight - prevPosition.current);
|
|
135
129
|
prevPosition.current = null;
|
|
@@ -12,7 +12,6 @@ export interface ChatInterfaceProps {
|
|
|
12
12
|
handleSend: (message: string) => Promise<boolean>;
|
|
13
13
|
className?: string;
|
|
14
14
|
style?: any;
|
|
15
|
-
submitting: boolean;
|
|
16
15
|
placeholder?: string;
|
|
17
16
|
hasNextPage?: boolean;
|
|
18
17
|
fetchNextPage?: () => Promise<any> | any;
|
|
@@ -20,6 +19,8 @@ export interface ChatInterfaceProps {
|
|
|
20
19
|
isLoading: boolean;
|
|
21
20
|
/** Determines if a data fetch is happening */
|
|
22
21
|
isFetching: boolean;
|
|
22
|
+
/** Determines if a message submission is happening */
|
|
23
|
+
isSubmitting: boolean;
|
|
23
24
|
colors?: {
|
|
24
25
|
user: string;
|
|
25
26
|
others: string;
|
|
@@ -27,4 +28,4 @@ export interface ChatInterfaceProps {
|
|
|
27
28
|
/** Needs to take a ref that is used to determine the height of the input component */
|
|
28
29
|
renderInputComponent?: (ref: Ref<HTMLDivElement>) => ReactNode;
|
|
29
30
|
}
|
|
30
|
-
export default function ChatInterface({ userId, messages, fetchNextPage, handleSend, hasNextPage, className, style,
|
|
31
|
+
export default function ChatInterface({ userId, messages, fetchNextPage, handleSend, hasNextPage, className, style, isSubmitting, placeholder, isLoading, isFetching, colors, renderInputComponent, }: ChatInterfaceProps): JSX.Element;
|
|
@@ -67,7 +67,7 @@ var react_measure_1 = __importDefault(require("react-measure"));
|
|
|
67
67
|
var MessageInput_1 = __importDefault(require("./MessageInput"));
|
|
68
68
|
var MessageThread_1 = __importDefault(require("./MessageThread"));
|
|
69
69
|
function ChatInterface(_a) {
|
|
70
|
-
var userId = _a.userId, messages = _a.messages, fetchNextPage = _a.fetchNextPage, handleSend = _a.handleSend, hasNextPage = _a.hasNextPage, className = _a.className, style = _a.style,
|
|
70
|
+
var userId = _a.userId, messages = _a.messages, fetchNextPage = _a.fetchNextPage, handleSend = _a.handleSend, hasNextPage = _a.hasNextPage, className = _a.className, style = _a.style, isSubmitting = _a.isSubmitting, placeholder = _a.placeholder, isLoading = _a.isLoading, isFetching = _a.isFetching, colors = _a.colors, renderInputComponent = _a.renderInputComponent;
|
|
71
71
|
var _b = __read((0, react_2.useState)(''), 2), message = _b[0], setMessage = _b[1];
|
|
72
72
|
var _c = __read((0, react_2.useState)(-1), 2), inputHeight = _c[0], setInputHeight = _c[1];
|
|
73
73
|
function handleClickSend() {
|
|
@@ -102,7 +102,7 @@ function ChatInterface(_a) {
|
|
|
102
102
|
var measureRef = _a.measureRef;
|
|
103
103
|
return ((0, react_1.jsx)(react_2.Fragment, null,
|
|
104
104
|
(0, react_1.jsx)(MessageThread_1.default, { userId: userId, messages: messages, inputHeight: inputHeight, hasNextPage: hasNextPage, fetchNextPage: fetchNextPage, isLoading: isLoading, isFetching: isFetching, colors: colors }),
|
|
105
|
-
renderInputComponent ? (renderInputComponent(measureRef)) : ((0, react_1.jsx)(MessageInput_1.default, { ref: measureRef, handleClickSend: handleClickSend, message: message, setMessage: setMessage,
|
|
105
|
+
renderInputComponent ? (renderInputComponent(measureRef)) : ((0, react_1.jsx)(MessageInput_1.default, { ref: measureRef, handleClickSend: handleClickSend, message: message, setMessage: setMessage, isSubmitting: isSubmitting, placeholder: placeholder }))));
|
|
106
106
|
})));
|
|
107
107
|
}
|
|
108
108
|
exports.default = ChatInterface;
|
|
@@ -44,7 +44,7 @@ var ChatInterface_1 = __importDefault(require("./ChatInterface"));
|
|
|
44
44
|
function ChatInterface() {
|
|
45
45
|
var _a = __read((0, react_2.useState)(true), 2), isLoading = _a[0], setLoading = _a[1];
|
|
46
46
|
var _b = __read((0, react_2.useState)(true), 2), isFetching = _b[0], setFetching = _b[1];
|
|
47
|
-
var _c = __read((0, react_2.useState)(false), 2),
|
|
47
|
+
var _c = __read((0, react_2.useState)(false), 2), isSubmitting = _c[0], setSubmitting = _c[1];
|
|
48
48
|
var _d = __read((0, react_2.useState)([]), 2), messages = _d[0], setMessages = _d[1];
|
|
49
49
|
var _e = __read((0, react_2.useState)(true), 2), hasMore = _e[0], setHasMore = _e[1];
|
|
50
50
|
(0, react_2.useEffect)(function () {
|
|
@@ -106,7 +106,7 @@ function ChatInterface() {
|
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
108
|
return ((0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border: 1px solid #ededed;\n height: 50rem;\n "], ["\n border: 1px solid #ededed;\n height: 50rem;\n "]))) },
|
|
109
|
-
(0, react_1.jsx)(ChatInterface_1.default, { userId: "user1", messages: messages, handleSend: handleSend,
|
|
109
|
+
(0, react_1.jsx)(ChatInterface_1.default, { userId: "user1", messages: messages, handleSend: handleSend, fetchNextPage: loadMore, hasNextPage: hasMore, isLoading: isLoading, isFetching: isFetching, isSubmitting: isSubmitting })));
|
|
110
110
|
}
|
|
111
111
|
exports.ChatInterface = ChatInterface;
|
|
112
112
|
var templateObject_1;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
-
|
|
2
|
+
import { ChatInterfaceProps } from './ChatInterface';
|
|
3
|
+
interface Props extends Pick<ChatInterfaceProps, 'isSubmitting' | 'placeholder'> {
|
|
3
4
|
handleClickSend: () => Promise<void>;
|
|
4
5
|
message: string;
|
|
5
|
-
placeholder?: string;
|
|
6
6
|
setMessage: Dispatch<SetStateAction<string>>;
|
|
7
|
-
submitting: boolean;
|
|
8
7
|
}
|
|
9
8
|
declare const MessageInput: import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<HTMLDivElement>>;
|
|
10
9
|
export default MessageInput;
|
|
@@ -15,7 +15,7 @@ var react_textarea_autosize_1 = __importDefault(require("react-textarea-autosize
|
|
|
15
15
|
var material_1 = require("@mui/material");
|
|
16
16
|
var icons_material_1 = require("@mui/icons-material");
|
|
17
17
|
var MessageInput = (0, react_2.forwardRef)(function (_a, ref) {
|
|
18
|
-
var handleClickSend = _a.handleClickSend, message = _a.message, placeholder = _a.placeholder, setMessage = _a.setMessage,
|
|
18
|
+
var handleClickSend = _a.handleClickSend, message = _a.message, placeholder = _a.placeholder, setMessage = _a.setMessage, isSubmitting = _a.isSubmitting;
|
|
19
19
|
function handleOnChange(_a) {
|
|
20
20
|
var value = _a.target.value;
|
|
21
21
|
setMessage(value);
|
|
@@ -42,7 +42,7 @@ var MessageInput = (0, react_2.forwardRef)(function (_a, ref) {
|
|
|
42
42
|
var _a, _b;
|
|
43
43
|
return (0, react_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell',\n 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n resize: none;\n width: calc(100% - 3.5rem);\n outline: 0 none transparent;\n font-size: 16px;\n margin: 0.5rem;\n padding: 0.5rem;\n box-sizing: border-box;\n border-radius: 5px;\n border-color: ", ";\n "], ["\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell',\n 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n resize: none;\n width: calc(100% - 3.5rem);\n outline: 0 none transparent;\n font-size: 16px;\n margin: 0.5rem;\n padding: 0.5rem;\n box-sizing: border-box;\n border-radius: 5px;\n border-color: ", ";\n "])), ((_b = (_a = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _a === void 0 ? void 0 : _a.primary) === null || _b === void 0 ? void 0 : _b.main) || 'hsl(0, 0%, 89%)');
|
|
44
44
|
}, placeholder: placeholder || 'Type your message here...', value: message, onChange: handleOnChange, onKeyDown: handleOnKeyDown, minRows: 3, maxRows: 8 }),
|
|
45
|
-
(0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n height: 2rem;\n width: 2rem;\n padding-right: ", ";\n "], ["\n height: 2rem;\n width: 2rem;\n padding-right: ", ";\n "])),
|
|
45
|
+
(0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n height: 2rem;\n width: 2rem;\n padding-right: ", ";\n "], ["\n height: 2rem;\n width: 2rem;\n padding-right: ", ";\n "])), isSubmitting ? '0.5rem' : '0.25rem') }, isSubmitting ? ((0, react_1.jsx)(material_1.CircularProgress, { size: "2rem" })) : ((0, react_1.jsx)(material_1.IconButton, { css: (0, react_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n height: 100%;\n width: 100%;\n "], ["\n height: 100%;\n width: 100%;\n "]))), onClick: handleOnClickSend, disabled: isSubmitting },
|
|
46
46
|
(0, react_1.jsx)(icons_material_1.Send, null))))));
|
|
47
47
|
});
|
|
48
48
|
exports.default = MessageInput;
|