32 lines
782 B
TypeScript
32 lines
782 B
TypeScript
|
import { useEffect, useRef, useState } from "preact/hooks";
|
||
|
import { msg_style } from "style";
|
||
|
import { Conversation, Database, Message } from "types";
|
||
|
|
||
|
export default function InputMsg({
|
||
|
msg,
|
||
|
db,
|
||
|
conversation,
|
||
|
onInput,
|
||
|
onSubmit,
|
||
|
...props
|
||
|
}: {
|
||
|
msg: Message;
|
||
|
db: Database;
|
||
|
conversation?: Conversation;
|
||
|
onInput: (e: any) => void;
|
||
|
onSubmit: () => void;
|
||
|
}) {
|
||
|
return (
|
||
|
<input
|
||
|
// className={class_list("message", `preset-${msg.preset}`)}
|
||
|
value={msg.content}
|
||
|
style={msg_style(msg, db, conversation)}
|
||
|
className="add-msg"
|
||
|
onInput={onInput}
|
||
|
onKeyPress={e => e.key == "Enter" && onSubmit()}
|
||
|
type="text"
|
||
|
{...props}
|
||
|
></input>
|
||
|
);
|
||
|
}
|