mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-19 23:01:36 +00:00
Use shared chat UI in Foundry
This commit is contained in:
parent
b609f1ab2b
commit
0ec470d494
8 changed files with 316 additions and 224 deletions
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
|
||||
import type { KeyboardEvent, ReactNode, TextareaHTMLAttributes } from "react";
|
||||
import type { KeyboardEvent, ReactNode, Ref, TextareaHTMLAttributes } from "react";
|
||||
|
||||
export interface ChatComposerClassNames {
|
||||
root: string;
|
||||
|
|
@ -18,9 +18,11 @@ export interface ChatComposerProps {
|
|||
placeholder?: string;
|
||||
disabled?: boolean;
|
||||
submitDisabled?: boolean;
|
||||
allowEmptySubmit?: boolean;
|
||||
submitLabel?: string;
|
||||
className?: string;
|
||||
classNames?: Partial<ChatComposerClassNames>;
|
||||
inputRef?: Ref<HTMLTextAreaElement>;
|
||||
rows?: number;
|
||||
textareaProps?: Omit<
|
||||
TextareaHTMLAttributes<HTMLTextAreaElement>,
|
||||
|
|
@ -58,15 +60,17 @@ export const ChatComposer = ({
|
|||
placeholder,
|
||||
disabled = false,
|
||||
submitDisabled = false,
|
||||
allowEmptySubmit = false,
|
||||
submitLabel = "Send",
|
||||
className,
|
||||
classNames: classNameOverrides,
|
||||
inputRef,
|
||||
rows = 1,
|
||||
textareaProps,
|
||||
renderSubmitContent,
|
||||
}: ChatComposerProps) => {
|
||||
const resolvedClassNames = mergeClassNames(DEFAULT_CLASS_NAMES, classNameOverrides);
|
||||
const isSubmitDisabled = disabled || submitDisabled || message.trim().length === 0;
|
||||
const isSubmitDisabled = disabled || submitDisabled || (!allowEmptySubmit && message.trim().length === 0);
|
||||
|
||||
return (
|
||||
<div className={cx(resolvedClassNames.root, className)} data-slot="root">
|
||||
|
|
@ -82,6 +86,7 @@ export const ChatComposer = ({
|
|||
>
|
||||
<textarea
|
||||
{...textareaProps}
|
||||
ref={inputRef}
|
||||
className={resolvedClassNames.input}
|
||||
data-slot="input"
|
||||
data-disabled={disabled ? "true" : undefined}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue