@homecode/ui 5.9.1 → 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/Chat/ChatPrompt.js +10 -2
- package/dist/esm/src/components/Chat/ChatView.js +2 -2
- package/dist/esm/src/components/Chat/ChatView.styl.js +1 -1
- 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
|
@@ -14,6 +14,7 @@ const DEFAULT_MODELS = [
|
|
|
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,12 +23,19 @@ 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;
|
|
@@ -8,7 +8,7 @@ import cn from 'classnames';
|
|
|
8
8
|
import { isPlanMessageContent } from './content.js';
|
|
9
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(() => {
|
|
@@ -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
|
-
})] }), footer && (jsxs("div", { className: S.footer, 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 }) }))] }));
|
|
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,6 +1,6 @@
|
|
|
1
1
|
import styleInject from '../../../node_modules/style-inject/dist/style-inject.es.js';
|
|
2
2
|
|
|
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
|
|
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
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
|
|
|
@@ -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;
|