Move the auto-growing textarea into ui-primitives as InlineEditor and use it for both the queued-message and goal editors. It also refits when its width changes and treats keyCode 229 as IME composition.
25 lines
956 B
TypeScript
25 lines
956 B
TypeScript
// Input: single-line text input atom (search boxes, inline forms). Multi-line
|
|
// inline edits use InlineEditor; the composer is owned by the conversation package.
|
|
|
|
import { forwardRef, type InputHTMLAttributes, type ReactNode } from 'react'
|
|
import clsx from 'clsx'
|
|
import css from './Input.module.css'
|
|
|
|
/**
|
|
* Render a text input with an optional leading icon.
|
|
* @param props.icon - optional 16px leading icon node.
|
|
* @param ref - the native input, cleared when it unmounts.
|
|
* @returns wrapper span containing the native input; input attributes pass through.
|
|
*/
|
|
export const Input = forwardRef<HTMLInputElement, {
|
|
icon?: ReactNode
|
|
className?: string
|
|
} & InputHTMLAttributes<HTMLInputElement>>(function Input({ icon, className, ...rest }, ref) {
|
|
return (
|
|
<span className={clsx(css.wrap, className)}>
|
|
{icon != null && <span className={css.icon}>{icon}</span>}
|
|
<input ref={ref} className={css.input} {...rest} />
|
|
</span>
|
|
)
|
|
})
|