import * as React from "react";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@godxjp/ui/data-display";
import { FormField, Textarea } from "@godxjp/ui/data-entry";
import { Button } from "@godxjp/ui/general";
import { Flex, PageContainer } from "@godxjp/ui/layout";
/**
* Textarea — styled wrapper around the native textarea. Pair with FormField for
* a labelled field. Composed only from real @godxjp/ui components.
*/
type Message = { id: number; author: string; body: string };
const SEED_MESSAGES: Message[] = [
{ id: 1, author: "佐藤", body: "月次の締め、明日の10時までにお願いします。" },
{ id: 2, author: "Trần", body: "承知しました。INV-2024-0312 の差異だけ確認中です。" },
];
/**
* The godx-chatter composer. One line at rest, grows line by line, scrolls itself past
* eight rows, and collapses back to one line the moment the post is sent — the send button just
* resets the controlled value, and `autoGrow` follows it without a single line of layout code.
*/
function Composer() {
const [messages, setMessages] = React.useState(SEED_MESSAGES);
const [draft, setDraft] = React.useState("");
const send = () => {
const body = draft.trim();
if (!body) return;
setMessages((current) => [...current, { id: current.length + 1, author: "自分", body }]);
setDraft("");
};
return (
{messages.map((message) => (
{message.author}{message.body}
))}
);
}
export default function Demo() {
return (
StatesPlaceholder, filled, and disabled.Embedded in a surface · variant="ghost"
The Card already draws the box, so the field must not draw a second one. Focus moves
to the surface via focus-within.
Chat composer · autoGrow
一行から始まり、入力と貼り付けに合わせて行単位で伸び、8行を超えると内部でスクロールし、送信すると一行に戻ります。高さを書くコードはありません。
autoGrow の下限と上限 · minRows / maxRows
下限・上限は「行」で指定します。行数なら密度切替や --font-size-base
の再テーマでも見た目の行数がずれません。上限を超えた分は箱がスクロールします。
Ant Design axes · status, variant, size, count, autoSize
variant carries five accepted spellings for three states: outlined / filled /
borderless are Ant Design's, and this library's older default / ghost
resolve onto the first and the last. autoSize is autoGrow plus its row bounds in one
prop.
In FormFieldLabelled with a helper hint.
);
}