@homecode/ui 5.9.0 → 5.9.2
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/esm/src/components/Autocomplete/Autocomplete.js +2 -2
- package/dist/esm/src/components/Chat/ChatPrompt.js +13 -5
- package/dist/esm/src/components/Chat/ChatView.js +7 -7
- package/dist/esm/src/components/Chat/ChatView.styl.js +2 -2
- package/dist/esm/src/components/InputFile/InputFile.js +2 -2
- package/dist/esm/types/src/components/Chat/Chat.types.d.ts +1 -0
- package/dist/esm/types/src/components/Chat/ChatView.d.ts +1 -1
- package/package.json +1 -1
|
@@ -36,10 +36,10 @@ import '../Chat/ChatFormattedText.styl.js';
|
|
|
36
36
|
import '../Expand/Expand.styl.js';
|
|
37
37
|
import '../Chat/ChatMessage.styl.js';
|
|
38
38
|
import '../PromptComposer/PromptComposer.js';
|
|
39
|
-
import '../ThinkingOutline/ThinkingOutline.styl.js';
|
|
40
39
|
import '../Chat/ChatPrompt.styl.js';
|
|
41
|
-
import '../
|
|
40
|
+
import '../ThinkingOutline/ThinkingOutline.styl.js';
|
|
42
41
|
import '../Chat/ChatView.styl.js';
|
|
42
|
+
import '../TextShimmer/TextShimmer.js';
|
|
43
43
|
import '../Container/Container.js';
|
|
44
44
|
import '../DatePicker/DatePicker.styl.js';
|
|
45
45
|
import 'moment';
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import cn from 'classnames';
|
|
3
2
|
import { useRef, useState } from 'react';
|
|
4
3
|
import { Button } from '../Button/Button.js';
|
|
5
4
|
import { Icon } from '../Icon/Icon.js';
|
|
6
5
|
import { PromptComposer } from '../PromptComposer/PromptComposer.js';
|
|
6
|
+
import S from './ChatPrompt.styl.js';
|
|
7
7
|
import { Select2 } from '../Select/Select2.js';
|
|
8
8
|
import { ThinkingOutline } from '../ThinkingOutline/ThinkingOutline.js';
|
|
9
9
|
import { Tooltip } from '../Tooltip/Tooltip.js';
|
|
10
|
-
import
|
|
10
|
+
import cn from 'classnames';
|
|
11
11
|
|
|
12
12
|
const DEFAULT_MODELS = [
|
|
13
13
|
{ id: 'auto', label: 'Auto Router' },
|
|
14
14
|
];
|
|
15
15
|
function ChatPrompt({ value, onChange, onSubmit, disabled, isPrompting, placeholder = 'Message', className, showAttach = true, onAttach, attachAccept, showModelSelector = true, models = DEFAULT_MODELS, model, onModelChange, }) {
|
|
16
16
|
const fileInputRef = useRef(null);
|
|
17
|
+
const composerRef = useRef(null);
|
|
17
18
|
const [uncontrolledModel, setUncontrolledModel] = useState(model ?? models[0]?.id ?? 'auto');
|
|
18
19
|
const modelId = model ?? uncontrolledModel;
|
|
19
20
|
const canSubmit = !disabled && Boolean(value.trim());
|
|
@@ -22,17 +23,24 @@ function ChatPrompt({ value, onChange, onSubmit, disabled, isPrompting, placehol
|
|
|
22
23
|
setUncontrolledModel(id);
|
|
23
24
|
onModelChange?.(id);
|
|
24
25
|
};
|
|
25
|
-
|
|
26
|
+
const onButtonsWrapperClick = (e) => {
|
|
27
|
+
const target = e.target;
|
|
28
|
+
if (target instanceof HTMLElement &&
|
|
29
|
+
(target.classList.contains(S.buttons) || target.classList.contains(S.gap))) {
|
|
30
|
+
composerRef.current?.focus();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
return (jsxs("div", { className: cn(S.root, className), children: [jsx(ThinkingOutline, { active: isPrompting }), jsx(PromptComposer, { ref: composerRef, className: S.composer, disabled: disabled, placeholder: placeholder, prefillMessage: value, allowEnterSubmit: true, onChange: onChange, onSubmit: text => {
|
|
26
34
|
const next = text.trim();
|
|
27
35
|
if (!next || disabled)
|
|
28
36
|
return;
|
|
29
37
|
onSubmit(next);
|
|
30
|
-
} }), jsxs("div", { className: S.buttons, children: [jsx(Button, { className: cn(S.button, S.submit), variant: "text", type: "submit", round: true, square: true, disabled: !canSubmit, "aria-label": "Send", onClick: () => {
|
|
38
|
+
} }), jsxs("div", { className: S.buttons, onClick: onButtonsWrapperClick, children: [jsx(Button, { className: cn(S.button, S.submit), variant: "text", type: "submit", round: true, square: true, disabled: !canSubmit, "aria-label": "Send", onClick: () => {
|
|
31
39
|
const next = value.trim();
|
|
32
40
|
if (!next || disabled)
|
|
33
41
|
return;
|
|
34
42
|
onSubmit(next);
|
|
35
|
-
}, children: jsx(Icon, { type: "arrowUp", className: S.submitIcon }) }), showModelSelector && (jsx(Select2, { className: S.promptModelSelector, label: "", size: "s", disableLabel: true, hideRequiredStar: true, round: true, options: models, value: modelId, disabled: disabled, popupProps: {
|
|
43
|
+
}, children: jsx(Icon, { type: "arrowUp", className: S.submitIcon }) }), showModelSelector && (jsx(Select2, { className: S.promptModelSelector, label: "", size: "s", disableLabel: true, hideRequiredStar: true, round: true, options: models, value: modelId, disabled: disabled, triggerProps: { variant: 'clear' }, popupProps: {
|
|
36
44
|
direction: 'top-right',
|
|
37
45
|
round: true,
|
|
38
46
|
}, onChange: next => {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import cn from 'classnames';
|
|
3
2
|
import { useRef, useEffect } from 'react';
|
|
4
|
-
import { Scroll } from '../Scroll/Scroll.js';
|
|
5
|
-
import { TextShimmer } from '../TextShimmer/TextShimmer.js';
|
|
6
|
-
import { scrollTo } from '../../tools/scroll.js';
|
|
7
3
|
import { ChatMessage } from './ChatMessage.js';
|
|
8
4
|
import S from './ChatView.styl.js';
|
|
5
|
+
import { Scroll } from '../Scroll/Scroll.js';
|
|
6
|
+
import { TextShimmer } from '../TextShimmer/TextShimmer.js';
|
|
7
|
+
import cn from 'classnames';
|
|
9
8
|
import { isPlanMessageContent } from './content.js';
|
|
9
|
+
import { scrollTo } from '../../tools/scroll.js';
|
|
10
10
|
|
|
11
|
-
function ChatView({ messages, isPrompting, promptingLabel = 'Thinking…', emptyLabel = 'Start the conversation', className, messagesClassName, footer, onButtonClick, }) {
|
|
11
|
+
function ChatView({ messages, isPrompting, promptingLabel = 'Thinking…', emptyLabel = 'Start the conversation', className, messagesClassName, footer, onButtonClick, footerClassName, }) {
|
|
12
12
|
const listRef = useRef(null);
|
|
13
13
|
const visible = messages.filter(message => !isPlanMessageContent(message.content));
|
|
14
14
|
useEffect(() => {
|
|
@@ -16,7 +16,7 @@ function ChatView({ messages, isPrompting, promptingLabel = 'Thinking…', empty
|
|
|
16
16
|
if (scroller)
|
|
17
17
|
scrollTo(scroller, 0, scroller.scrollHeight + 80);
|
|
18
18
|
}, [visible.length, isPrompting]);
|
|
19
|
-
return (jsxs("div", { className: cn(S.root, className), children: [jsxs(Scroll, { y: true, fadeSize: "l", autoHide: true, className: S.messages, innerClassName: cn(S.messagesInner, messagesClassName), onInnerRef: elem => {
|
|
19
|
+
return (jsxs("div", { className: cn(S.root, className), children: [jsxs(Scroll, { y: true, fadeSize: "l", autoHide: true, offset: { y: { after: 30 } }, className: S.messages, innerClassName: cn(S.messagesInner, footer && S.messagesInnerWithPrompt, messagesClassName), onInnerRef: elem => {
|
|
20
20
|
listRef.current = elem;
|
|
21
21
|
}, children: [visible.length === 0 && jsx("div", { className: S.empty, children: emptyLabel }), visible.map((message, index) => {
|
|
22
22
|
const prev = visible[index - 1];
|
|
@@ -24,7 +24,7 @@ function ChatView({ messages, isPrompting, promptingLabel = 'Thinking…', empty
|
|
|
24
24
|
prev.role === message.role &&
|
|
25
25
|
message.role !== 'SYSTEM';
|
|
26
26
|
return (jsx(ChatMessage, { data: message, isStacked: isStacked, isLastMessage: index === visible.length - 1, onButtonClick: onButtonClick }, message.id || `${message.role}-${index}`));
|
|
27
|
-
})] }), isPrompting && (jsx("div", { className: S.status, children: jsx(TextShimmer, { children: promptingLabel }) })), footer && jsx("div", { className: S.
|
|
27
|
+
})] }), footer && (jsxs("div", { className: cn(S.footer, footerClassName), children: [isPrompting && (jsx("div", { className: S.status, children: jsx(TextShimmer, { children: promptingLabel }) })), footer] })), !footer && isPrompting && (jsx("div", { className: S.status, children: jsx(TextShimmer, { children: promptingLabel }) }))] }));
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export { ChatView };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styleInject from '../../../node_modules/style-inject/dist/style-inject.es.js';
|
|
2
2
|
|
|
3
|
-
var css_248z = ".ChatView_root__fRLUe{display:flex;flex-direction:column;height:100%;min-height:0;width:100%}.ChatView_messages__XjC53{flex:1;min-height:0}.ChatView_messagesInner__oRfmN{display:flex;flex-direction:column;padding:var(--p-10) calc(50% - 300px) 0}.ChatView_empty__5yGXV{margin:auto;opacity:.6;padding:24px;text-align:center}.ChatView_status__PpDvZ{font-size:13px;padding:4px 8px 0}.ChatView_footer__huDww{
|
|
4
|
-
var S = {"root":"ChatView_root__fRLUe","messages":"ChatView_messages__XjC53","messagesInner":"ChatView_messagesInner__oRfmN","empty":"ChatView_empty__5yGXV","status":"ChatView_status__PpDvZ","footer":"ChatView_footer__huDww"};
|
|
3
|
+
var css_248z = ".ChatView_root__fRLUe{--prompt-height:80px;display:flex;flex-direction:column;height:100%;min-height:0;position:relative;width:100%}.ChatView_messages__XjC53{flex:1;min-height:0}.ChatView_messagesInner__oRfmN{display:flex;flex-direction:column;height:-moz-fit-content;height:fit-content;min-height:100%;padding:var(--p-10) calc(50% - 300px) 0}.ChatView_messagesInnerWithPrompt__AuC8M{padding-bottom:20px}.ChatView_empty__5yGXV{margin:auto;opacity:.6;padding:24px;text-align:center}.ChatView_status__PpDvZ{font-size:13px;padding:4px 8px 0}.ChatView_footer__huDww{height:-moz-fit-content;height:fit-content;margin-top:calc(var(--p-5)*-1);overflow:visible;padding:0}.ChatView_footer__huDww .ChatView_status__PpDvZ{display:flex;font-size:12.8px;font-size:calc(12.8px*var(--dialogue-text-scale, 1));justify-content:center;left:0;padding:6px 14px;pointer-events:none;position:absolute;right:0;top:-32px}";
|
|
4
|
+
var S = {"root":"ChatView_root__fRLUe","messages":"ChatView_messages__XjC53","messagesInner":"ChatView_messagesInner__oRfmN","messagesInnerWithPrompt":"ChatView_messagesInnerWithPrompt__AuC8M","empty":"ChatView_empty__5yGXV","status":"ChatView_status__PpDvZ","footer":"ChatView_footer__huDww"};
|
|
5
5
|
styleInject(css_248z);
|
|
6
6
|
|
|
7
7
|
export { S as default };
|
|
@@ -39,10 +39,10 @@ import '../Chat/ChatFormattedText.styl.js';
|
|
|
39
39
|
import '../Expand/Expand.styl.js';
|
|
40
40
|
import '../Chat/ChatMessage.styl.js';
|
|
41
41
|
import '../PromptComposer/PromptComposer.js';
|
|
42
|
-
import '../ThinkingOutline/ThinkingOutline.styl.js';
|
|
43
42
|
import '../Chat/ChatPrompt.styl.js';
|
|
44
|
-
import '../
|
|
43
|
+
import '../ThinkingOutline/ThinkingOutline.styl.js';
|
|
45
44
|
import '../Chat/ChatView.styl.js';
|
|
45
|
+
import '../TextShimmer/TextShimmer.js';
|
|
46
46
|
import '../Container/Container.js';
|
|
47
47
|
import '../DatePicker/DatePicker.styl.js';
|
|
48
48
|
import 'moment';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ChatViewProps } from './types';
|
|
2
|
-
export declare function ChatView({ messages, isPrompting, promptingLabel, emptyLabel, className, messagesClassName, footer, onButtonClick, }: ChatViewProps): import("react").JSX.Element;
|
|
2
|
+
export declare function ChatView({ messages, isPrompting, promptingLabel, emptyLabel, className, messagesClassName, footer, onButtonClick, footerClassName, }: ChatViewProps): import("react").JSX.Element;
|