@godxjp/ui 20.2.1 → 22.0.0
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/app/app-provider.js +2 -1
- package/dist/components/data-display/badge.d.ts +28 -1
- package/dist/components/data-display/badge.js +2 -0
- package/dist/components/data-display/chat-bubble.d.ts +30 -0
- package/dist/components/data-display/chat-bubble.js +229 -0
- package/dist/components/data-display/data-table.d.ts +18 -2
- package/dist/components/data-display/data-table.js +4 -0
- package/dist/components/data-display/descriptions.js +4 -1
- package/dist/components/data-display/index.d.ts +5 -3
- package/dist/components/data-display/index.js +5 -2
- package/dist/components/data-display/popover.d.ts +19 -1
- package/dist/components/data-display/popover.js +12 -3
- package/dist/components/data-display/progress.d.ts +37 -0
- package/dist/components/data-display/progress.js +57 -5
- package/dist/components/data-display/scroll-area.js +26 -1
- package/dist/components/data-display/tree.d.ts +8 -0
- package/dist/components/data-display/tree.js +426 -0
- package/dist/components/data-entry/chat-composer.d.ts +50 -0
- package/dist/components/data-entry/chat-composer.js +163 -0
- package/dist/components/data-entry/chat-suggestion.d.ts +28 -0
- package/dist/components/data-entry/chat-suggestion.js +285 -0
- package/dist/components/data-entry/date-picker.d.ts +10 -3
- package/dist/components/data-entry/date-picker.js +503 -238
- package/dist/components/data-entry/form-field.d.ts +1 -1
- package/dist/components/data-entry/form-field.js +4 -1
- package/dist/components/data-entry/form.js +10 -1
- package/dist/components/data-entry/index.d.ts +4 -6
- package/dist/components/data-entry/index.js +4 -6
- package/dist/components/data-entry/label.d.ts +14 -1
- package/dist/components/data-entry/label.js +6 -1
- package/dist/components/data-entry/radio.d.ts +27 -6
- package/dist/components/data-entry/radio.js +88 -43
- package/dist/components/data-entry/search-select.js +8 -1
- package/dist/components/data-entry/select.js +2 -0
- package/dist/components/data-entry/switch.d.ts +6 -3
- package/dist/components/data-entry/switch.js +34 -11
- package/dist/components/data-entry/textarea.js +3 -1
- package/dist/components/data-entry/tree-utils.d.ts +10 -48
- package/dist/components/data-entry/tree-utils.js +1 -154
- package/dist/components/layout/mobile-shell.d.ts +1 -1
- package/dist/components/layout/mobile-shell.js +2 -0
- package/dist/components/navigation/menubar.d.ts +10 -3
- package/dist/components/navigation/steps.d.ts +1 -1
- package/dist/components/navigation/steps.js +3 -1
- package/dist/components/navigation/tabs-scroll.d.ts +27 -0
- package/dist/components/navigation/tabs-scroll.js +52 -1
- package/dist/components/navigation/tabs.d.ts +2 -2
- package/dist/components/navigation/tabs.js +88 -23
- package/dist/components/ui/index.d.ts +0 -1
- package/dist/components/ui/index.js +0 -1
- package/dist/components/ui/segmented.d.ts +15 -1
- package/dist/components/ui/segmented.js +13 -6
- package/dist/i18n/messages/en.json +48 -2
- package/dist/i18n/messages/ja.json +46 -2
- package/dist/i18n/messages/vi.json +47 -2
- package/dist/lib/datetime/picker-format.d.ts +18 -0
- package/dist/lib/datetime/picker-format.js +35 -1
- package/dist/lib/field-a11y.d.ts +12 -0
- package/dist/lib/field-a11y.js +14 -1
- package/dist/lib/tree.d.ts +53 -0
- package/dist/lib/tree.js +155 -0
- package/dist/props/components/data-display.prop.d.ts +194 -1
- package/dist/props/components/data-entry.prop.d.ts +307 -99
- package/dist/props/components/index.d.ts +1 -1
- package/dist/props/components/layout.prop.d.ts +12 -1
- package/dist/props/components/navigation.prop.d.ts +76 -1
- package/dist/props/registry.d.ts +156 -19
- package/dist/props/registry.js +218 -18
- package/dist/props/vocabulary/data.prop.d.ts +12 -0
- package/dist/props/vocabulary/index.d.ts +2 -2
- package/dist/props/vocabulary/layout.prop.d.ts +11 -0
- package/dist/styles/badge-layout.css +4 -0
- package/dist/styles/card-layout.css +6 -6
- package/dist/styles/control.css +22 -6
- package/dist/styles/data-display-layout.css +385 -68
- package/dist/styles/data-entry-layout.css +64 -0
- package/dist/styles/focus-ring.css +4 -2
- package/dist/styles/navigation-layout.css +25 -0
- package/dist/styles/shell-layout.css +7 -1
- package/dist/styles/table-layout.css +34 -0
- package/dist/tokens/base.css +3 -0
- package/dist/tokens/components/chat-bubble.css +36 -0
- package/dist/tokens/components/chat-composer.css +19 -0
- package/dist/tokens/components/data-display.css +9 -6
- package/dist/tokens/components/descriptions.css +4 -0
- package/dist/tokens/components/navigation.css +6 -0
- package/dist/tokens/components/segmented.css +0 -2
- package/dist/tokens/components/shell.css +3 -0
- package/dist/tokens/components/table.css +3 -0
- package/dist/tokens/components/tree.css +27 -0
- package/dist/tokens/foundation.css +7 -0
- package/docs/COMPONENTS.md +14 -14
- package/docs/CONSUMER-RULES.md +24 -1
- package/docs/FRAME-COVERAGE-LEDGER.md +1 -1
- package/docs/FRAME-COVERAGE-REPORT.md +9 -7
- package/docs/TOKENS.md +65 -0
- package/docs/data-display/badge.tsx +37 -0
- package/docs/data-display/chat-bubble.tsx +397 -0
- package/docs/data-display/data-table/index.tsx +18 -0
- package/docs/data-display/popover.tsx +41 -1
- package/docs/data-display/progress.tsx +28 -0
- package/docs/data-display/timeline.tsx +46 -0
- package/docs/data-display/tree.tsx +394 -0
- package/docs/data-entry/calendar.tsx +2 -2
- package/docs/data-entry/chat-composer.tsx +464 -0
- package/docs/data-entry/chat-suggestion.tsx +301 -0
- package/docs/data-entry/date-picker.tsx +143 -3
- package/docs/data-entry/form/examples/invoice-form.tsx +2 -2
- package/docs/data-entry/form-field/examples/a11y-contract.tsx +3 -5
- package/docs/data-entry/form.tsx +4 -4
- package/docs/data-entry/number-input.tsx +31 -0
- package/docs/data-entry/segmented.tsx +103 -1
- package/docs/layout/mobile-shell.tsx +5 -0
- package/docs/navigation/tabs.tsx +149 -0
- package/docs/roadmap/ai-chat-components.md +207 -0
- package/docs/roadmap/antd-parity.md +155 -0
- package/docs/roadmap/badge-tag-chip-count.md +172 -0
- package/docs/roadmap/list-masonry.md +159 -0
- package/docs/roadmap/parity-audit-data-display-feedback.md +567 -0
- package/docs/roadmap/parity-audit-data-entry.md +357 -0
- package/docs/roadmap/parity-audit-layout-navigation-general.md +464 -0
- package/docs/roadmap/parity-backlog.md +78 -0
- package/docs/roadmap/tree-components.md +151 -0
- package/docs/showcase/acme-portal.tsx +7 -0
- package/docs/showcase/table-tree-rows.tsx +4 -4
- package/package.json +13 -23
- package/scripts/ui-audit.mjs +17 -4
- package/dist/components/data-display/tree-list.d.ts +0 -13
- package/dist/components/data-display/tree-list.js +0 -26
- package/dist/components/data-entry/date-range-picker.d.ts +0 -11
- package/dist/components/data-entry/date-range-picker.js +0 -349
- package/dist/components/data-entry/month-picker.d.ts +0 -10
- package/dist/components/data-entry/month-picker.js +0 -241
- package/dist/components/data-entry/month-range-picker.d.ts +0 -10
- package/dist/components/data-entry/month-range-picker.js +0 -301
- package/dist/components/ui/date-range-picker.d.ts +0 -1
- package/dist/components/ui/date-range-picker.js +0 -2
- package/docs/data-display/tree-list.tsx +0 -107
- package/docs/data-entry/date-range-picker.tsx +0 -175
- package/docs/data-entry/month-picker.tsx +0 -101
- package/docs/data-entry/month-range-picker.tsx +0 -115
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Avatar,
|
|
5
|
+
AvatarFallback,
|
|
6
|
+
Badge,
|
|
7
|
+
Card,
|
|
8
|
+
CardContent,
|
|
9
|
+
CardDescription,
|
|
10
|
+
CardHeader,
|
|
11
|
+
CardTitle,
|
|
12
|
+
} from "@godxjp/ui/data-display";
|
|
13
|
+
import {
|
|
14
|
+
ChatComposer,
|
|
15
|
+
ChatSuggestion,
|
|
16
|
+
FormField,
|
|
17
|
+
type ChatSuggestionItemProp,
|
|
18
|
+
} from "@godxjp/ui/data-entry";
|
|
19
|
+
import { Button, Text } from "@godxjp/ui/general";
|
|
20
|
+
import {
|
|
21
|
+
AppShell,
|
|
22
|
+
Flex,
|
|
23
|
+
PageContainer,
|
|
24
|
+
ResponsiveGrid,
|
|
25
|
+
Sidebar,
|
|
26
|
+
type SidebarSectionProp,
|
|
27
|
+
Topbar,
|
|
28
|
+
} from "@godxjp/ui/layout";
|
|
29
|
+
import { Bot, MessageSquare, Paperclip, Settings, Smile, Sparkles, Users } from "lucide-react";
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* ChatComposer — the message input of a conversation, and ChatSuggestion, the trigger-character
|
|
33
|
+
* list over it.
|
|
34
|
+
*
|
|
35
|
+
* The first card is the real screen: a live assistant transcript whose composer sends, streams and
|
|
36
|
+
* cancels, with `/` slash commands and `@` mentions wired to the same draft. Every card after it
|
|
37
|
+
* exists so the whole API is visible AT REST — both `submitType` values, all four `size` steps,
|
|
38
|
+
* every slot, and each non-default state — without having to click anything.
|
|
39
|
+
*
|
|
40
|
+
* Composed only from real @godxjp/ui components.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
const sections: SidebarSectionProp[] = [
|
|
44
|
+
{
|
|
45
|
+
label: "アシスタント",
|
|
46
|
+
items: [
|
|
47
|
+
{ id: "chat", label: "チャット", icon: MessageSquare },
|
|
48
|
+
{ id: "agents", label: "エージェント", icon: Bot },
|
|
49
|
+
{ id: "members", label: "メンバー", icon: Users },
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
{ label: "管理", items: [{ id: "settings", label: "設定", icon: Settings }] },
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
/** Slash commands — one level of `children` on the template row. */
|
|
56
|
+
const COMMANDS: ChatSuggestionItemProp[] = [
|
|
57
|
+
{ value: "summarize", label: "要約する", description: "このスレッドを3行で要約します" },
|
|
58
|
+
{ value: "translate", label: "翻訳する", description: "英語 ⇄ 日本語" },
|
|
59
|
+
{ value: "explain", label: "詳しく説明する" },
|
|
60
|
+
{
|
|
61
|
+
value: "template",
|
|
62
|
+
label: "テンプレート",
|
|
63
|
+
description: "定型文を挿入します",
|
|
64
|
+
children: [
|
|
65
|
+
{ value: "template/meeting", label: "議事録", description: "日時・出席者・決定事項" },
|
|
66
|
+
{ value: "template/report", label: "週報", description: "実績・課題・来週の予定" },
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
{ value: "archive", label: "アーカイブ", description: "権限がありません", disabled: true },
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
/** Mention list — the same component with a different `triggerCharacter`. */
|
|
73
|
+
const MEMBERS: ChatSuggestionItemProp[] = [
|
|
74
|
+
{ value: "sato", label: "佐藤 花子", description: "経理部" },
|
|
75
|
+
{ value: "tanaka", label: "田中 太郎", description: "営業部" },
|
|
76
|
+
{ value: "yamada", label: "山田 一郎", description: "開発部" },
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
interface Message {
|
|
80
|
+
id: number;
|
|
81
|
+
author: "you" | "assistant";
|
|
82
|
+
body: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const OPENING: Message[] = [
|
|
86
|
+
{ id: 1, author: "you", body: "先月の交際費の内訳を教えてください。" },
|
|
87
|
+
{
|
|
88
|
+
id: 2,
|
|
89
|
+
author: "assistant",
|
|
90
|
+
body: "先月の交際費は 342,000 円でした。会食が 210,000 円、贈答が 132,000 円です。",
|
|
91
|
+
},
|
|
92
|
+
];
|
|
93
|
+
|
|
94
|
+
/** One transcript line. The message FEED is ChatBubbleList's job; here it only sets the scene. */
|
|
95
|
+
function Line({ message }: { message: Message }) {
|
|
96
|
+
const mine = message.author === "you";
|
|
97
|
+
return (
|
|
98
|
+
<Flex direction="row" gap="sm" align="start">
|
|
99
|
+
<Avatar>
|
|
100
|
+
<AvatarFallback>{mine ? "私" : "AI"}</AvatarFallback>
|
|
101
|
+
</Avatar>
|
|
102
|
+
<Flex direction="col" gap="xs">
|
|
103
|
+
<Text size="sm" tone="muted">
|
|
104
|
+
{mine ? "あなた" : "アシスタント"}
|
|
105
|
+
</Text>
|
|
106
|
+
<Text>{message.body}</Text>
|
|
107
|
+
</Flex>
|
|
108
|
+
</Flex>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export default function Demo() {
|
|
113
|
+
// ── Card 1: the live screen ───────────────────────────────────────────────────────────────
|
|
114
|
+
const [messages, setMessages] = useState<Message[]>(OPENING);
|
|
115
|
+
const [draft, setDraft] = useState("");
|
|
116
|
+
const [streaming, setStreaming] = useState(false);
|
|
117
|
+
const timer = useRef<number | undefined>(undefined);
|
|
118
|
+
|
|
119
|
+
useEffect(() => () => window.clearTimeout(timer.current), []);
|
|
120
|
+
|
|
121
|
+
function send(text: string) {
|
|
122
|
+
setMessages((current) => [...current, { id: current.length + 1, author: "you", body: text }]);
|
|
123
|
+
setDraft("");
|
|
124
|
+
setStreaming(true);
|
|
125
|
+
// A real delay, so the cancel affordance is reachable instead of resolving instantly.
|
|
126
|
+
timer.current = window.setTimeout(() => {
|
|
127
|
+
setStreaming(false);
|
|
128
|
+
setMessages((current) => [
|
|
129
|
+
...current,
|
|
130
|
+
{ id: current.length + 1, author: "assistant", body: "確認しました。集計を開始します。" },
|
|
131
|
+
]);
|
|
132
|
+
}, 2500);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function cancel() {
|
|
136
|
+
window.clearTimeout(timer.current);
|
|
137
|
+
setStreaming(false);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// ── Card 2: both submitType values, each holding its own draft ────────────────────────────
|
|
141
|
+
const [enterDraft, setEnterDraft] = useState("Enter を押すと送信されます");
|
|
142
|
+
const [shiftDraft, setShiftDraft] = useState("Enter は改行、Shift + Enter で送信");
|
|
143
|
+
const [lastSent, setLastSent] = useState<string>("—");
|
|
144
|
+
|
|
145
|
+
// ── Card 3: the four size steps ───────────────────────────────────────────────────────────
|
|
146
|
+
const [sizeDrafts, setSizeDrafts] = useState<Record<string, string>>({
|
|
147
|
+
xs: "xs",
|
|
148
|
+
sm: "sm",
|
|
149
|
+
md: "md",
|
|
150
|
+
lg: "lg",
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// ── Card 4: every slot filled ─────────────────────────────────────────────────────────────
|
|
154
|
+
const [slotDraft, setSlotDraft] = useState("見積書のドラフトを作成してください");
|
|
155
|
+
|
|
156
|
+
// ── Card 5: the non-default states ────────────────────────────────────────────────────────
|
|
157
|
+
const [errorDraft, setErrorDraft] = useState("");
|
|
158
|
+
const [warningDraft, setWarningDraft] = useState("送信先が未確定です");
|
|
159
|
+
const [countedDraft, setCountedDraft] = useState("最大 120 文字まで入力できます");
|
|
160
|
+
|
|
161
|
+
// ── Card 6: mentions ──────────────────────────────────────────────────────────────────────
|
|
162
|
+
const [mentionDraft, setMentionDraft] = useState("");
|
|
163
|
+
|
|
164
|
+
return (
|
|
165
|
+
<AppShell
|
|
166
|
+
sidebar={
|
|
167
|
+
<Sidebar
|
|
168
|
+
activeId="chat"
|
|
169
|
+
sections={sections}
|
|
170
|
+
onSelect={() => {}}
|
|
171
|
+
product={{ name: "CoreDesk", role: "アシスタント", color: "hsl(var(--primary))" }}
|
|
172
|
+
/>
|
|
173
|
+
}
|
|
174
|
+
topbar={
|
|
175
|
+
<Topbar
|
|
176
|
+
start={
|
|
177
|
+
<Avatar className="rounded-md">
|
|
178
|
+
<AvatarFallback className="bg-primary text-primary-foreground font-bold">
|
|
179
|
+
C
|
|
180
|
+
</AvatarFallback>
|
|
181
|
+
</Avatar>
|
|
182
|
+
}
|
|
183
|
+
/>
|
|
184
|
+
}
|
|
185
|
+
>
|
|
186
|
+
<PageContainer
|
|
187
|
+
title="AI アシスタント"
|
|
188
|
+
subtitle="ChatComposer · ChatSuggestion · 送信 / 停止 / スラッシュコマンド / メンション"
|
|
189
|
+
breadcrumb={[{ label: "アシスタント", to: "#" }, { label: "チャット" }]}
|
|
190
|
+
>
|
|
191
|
+
<Flex direction="col" gap="lg">
|
|
192
|
+
{/* ── 1. The real screen ───────────────────────────────────────────────────────── */}
|
|
193
|
+
<Card>
|
|
194
|
+
<CardHeader>
|
|
195
|
+
<CardTitle level={2}>経理アシスタント</CardTitle>
|
|
196
|
+
<CardDescription>
|
|
197
|
+
送信すると 2.5 秒間ストリーミングします。その間、送信ボタンは停止ボタンに
|
|
198
|
+
置き換わります(同時に2つは出ません)。「/」でコマンド一覧が開きます。
|
|
199
|
+
</CardDescription>
|
|
200
|
+
</CardHeader>
|
|
201
|
+
<CardContent>
|
|
202
|
+
<Flex direction="col" gap="md">
|
|
203
|
+
{messages.map((message) => (
|
|
204
|
+
<Line key={message.id} message={message} />
|
|
205
|
+
))}
|
|
206
|
+
{streaming ? (
|
|
207
|
+
<Badge tone="info">
|
|
208
|
+
<Sparkles aria-hidden="true" />
|
|
209
|
+
生成中…
|
|
210
|
+
</Badge>
|
|
211
|
+
) : null}
|
|
212
|
+
<ChatSuggestion items={COMMANDS} onValueChange={(value) => setDraft(`/${value} `)}>
|
|
213
|
+
{({ onTrigger, onKeyDown }) => (
|
|
214
|
+
<ChatComposer
|
|
215
|
+
id="assistant-composer"
|
|
216
|
+
aria-label="アシスタントへのメッセージ"
|
|
217
|
+
value={draft}
|
|
218
|
+
onValueChange={(next) => {
|
|
219
|
+
setDraft(next);
|
|
220
|
+
onTrigger(next);
|
|
221
|
+
}}
|
|
222
|
+
onKeyDown={onKeyDown}
|
|
223
|
+
onSubmit={send}
|
|
224
|
+
loading={streaming}
|
|
225
|
+
onCancel={cancel}
|
|
226
|
+
placeholder="メッセージを入力"
|
|
227
|
+
prefix={
|
|
228
|
+
<Button size="icon-sm" variant="ghost" aria-label="ファイルを添付">
|
|
229
|
+
<Paperclip aria-hidden="true" />
|
|
230
|
+
</Button>
|
|
231
|
+
}
|
|
232
|
+
footer={
|
|
233
|
+
<Text size="xs" tone="muted">
|
|
234
|
+
Enter で送信 · Shift + Enter で改行
|
|
235
|
+
</Text>
|
|
236
|
+
}
|
|
237
|
+
/>
|
|
238
|
+
)}
|
|
239
|
+
</ChatSuggestion>
|
|
240
|
+
</Flex>
|
|
241
|
+
</CardContent>
|
|
242
|
+
</Card>
|
|
243
|
+
|
|
244
|
+
{/* ── 2. submitType, both values ───────────────────────────────────────────────── */}
|
|
245
|
+
<Card>
|
|
246
|
+
<CardHeader>
|
|
247
|
+
<CardTitle level={2}>submitType · どのキーで送るか</CardTitle>
|
|
248
|
+
<CardDescription>
|
|
249
|
+
左は「enter」(既定)、右は「shiftEnter」。日本語変換中の Enter は
|
|
250
|
+
どちらでも送信になりません。最後に送信された文面:{lastSent}
|
|
251
|
+
</CardDescription>
|
|
252
|
+
</CardHeader>
|
|
253
|
+
<CardContent>
|
|
254
|
+
<ResponsiveGrid columns={{ base: 1, md: 2 }} gap="md">
|
|
255
|
+
<ChatComposer
|
|
256
|
+
aria-label="Enter で送信するメッセージ"
|
|
257
|
+
submitType="enter"
|
|
258
|
+
value={enterDraft}
|
|
259
|
+
onValueChange={setEnterDraft}
|
|
260
|
+
onSubmit={(text) => {
|
|
261
|
+
setLastSent(text);
|
|
262
|
+
setEnterDraft("");
|
|
263
|
+
}}
|
|
264
|
+
footer={
|
|
265
|
+
<Text size="xs" tone="muted">
|
|
266
|
+
Enter で送信 · Shift + Enter で改行
|
|
267
|
+
</Text>
|
|
268
|
+
}
|
|
269
|
+
/>
|
|
270
|
+
<ChatComposer
|
|
271
|
+
aria-label="Shift + Enter で送信するメッセージ"
|
|
272
|
+
submitType="shiftEnter"
|
|
273
|
+
value={shiftDraft}
|
|
274
|
+
onValueChange={setShiftDraft}
|
|
275
|
+
onSubmit={(text) => {
|
|
276
|
+
setLastSent(text);
|
|
277
|
+
setShiftDraft("");
|
|
278
|
+
}}
|
|
279
|
+
footer={
|
|
280
|
+
<Text size="xs" tone="muted">
|
|
281
|
+
Shift + Enter で送信 · Enter で改行
|
|
282
|
+
</Text>
|
|
283
|
+
}
|
|
284
|
+
/>
|
|
285
|
+
</ResponsiveGrid>
|
|
286
|
+
</CardContent>
|
|
287
|
+
</Card>
|
|
288
|
+
|
|
289
|
+
{/* ── 3. Every size step ───────────────────────────────────────────────────────── */}
|
|
290
|
+
<Card>
|
|
291
|
+
<CardHeader>
|
|
292
|
+
<CardTitle level={2}>size · xs / sm / md / lg</CardTitle>
|
|
293
|
+
<CardDescription>
|
|
294
|
+
size は --control-height の段位を切り替えます。送信ボタンの一辺と、下書き欄の
|
|
295
|
+
下限(1行ぶん)・上限(その5倍)がこの段位から決まります。上限を超えると枠は
|
|
296
|
+
伸びず、下書き欄の中でスクロールします。1行だけの状態では下限より本文の行の高さ
|
|
297
|
+
が勝つため、枠の高さは4段とも同じです。これは Textarea と同じ挙動です。
|
|
298
|
+
</CardDescription>
|
|
299
|
+
</CardHeader>
|
|
300
|
+
<CardContent>
|
|
301
|
+
<Flex direction="col" gap="md">
|
|
302
|
+
{(["xs", "sm", "md", "lg"] as const).map((step) => (
|
|
303
|
+
<ChatComposer
|
|
304
|
+
key={step}
|
|
305
|
+
size={step}
|
|
306
|
+
aria-label={`size ${step} のメッセージ`}
|
|
307
|
+
value={sizeDrafts[step]}
|
|
308
|
+
onValueChange={(next) =>
|
|
309
|
+
setSizeDrafts((current) => ({ ...current, [step]: next }))
|
|
310
|
+
}
|
|
311
|
+
placeholder={`size="${step}"`}
|
|
312
|
+
/>
|
|
313
|
+
))}
|
|
314
|
+
</Flex>
|
|
315
|
+
</CardContent>
|
|
316
|
+
</Card>
|
|
317
|
+
|
|
318
|
+
{/* ── 4. Every slot ────────────────────────────────────────────────────────────── */}
|
|
319
|
+
<Card>
|
|
320
|
+
<CardHeader>
|
|
321
|
+
<CardTitle level={2}>スロット · header / prefix / actions / footer</CardTitle>
|
|
322
|
+
<CardDescription>
|
|
323
|
+
header は入力欄の上、prefix は行頭、actions は送信ボタンの手前、footer は下。
|
|
324
|
+
アイコンだけのボタンには必ずアクセシブル名を付けます。
|
|
325
|
+
</CardDescription>
|
|
326
|
+
</CardHeader>
|
|
327
|
+
<CardContent>
|
|
328
|
+
<ChatComposer
|
|
329
|
+
aria-label="スロットを全て使ったメッセージ"
|
|
330
|
+
value={slotDraft}
|
|
331
|
+
onValueChange={setSlotDraft}
|
|
332
|
+
header={
|
|
333
|
+
<Flex direction="row" gap="sm" align="center">
|
|
334
|
+
<Badge tone="neutral">
|
|
335
|
+
<Paperclip aria-hidden="true" />
|
|
336
|
+
見積書_v3.pdf
|
|
337
|
+
</Badge>
|
|
338
|
+
<Text size="xs" tone="muted">
|
|
339
|
+
添付 1件
|
|
340
|
+
</Text>
|
|
341
|
+
</Flex>
|
|
342
|
+
}
|
|
343
|
+
prefix={
|
|
344
|
+
<Button size="icon-sm" variant="ghost" aria-label="ファイルを添付">
|
|
345
|
+
<Paperclip aria-hidden="true" />
|
|
346
|
+
</Button>
|
|
347
|
+
}
|
|
348
|
+
actions={
|
|
349
|
+
<Button size="icon-sm" variant="ghost" aria-label="絵文字を挿入">
|
|
350
|
+
<Smile aria-hidden="true" />
|
|
351
|
+
</Button>
|
|
352
|
+
}
|
|
353
|
+
footer={
|
|
354
|
+
<Text size="xs" tone="muted">
|
|
355
|
+
社外秘の情報は入力しないでください
|
|
356
|
+
</Text>
|
|
357
|
+
}
|
|
358
|
+
/>
|
|
359
|
+
</CardContent>
|
|
360
|
+
</Card>
|
|
361
|
+
|
|
362
|
+
{/* ── 5. Non-default states ────────────────────────────────────────────────────── */}
|
|
363
|
+
<Card>
|
|
364
|
+
<CardHeader>
|
|
365
|
+
<CardTitle level={2}>
|
|
366
|
+
状態 · error / warning / disabled / readOnly / maxLength
|
|
367
|
+
</CardTitle>
|
|
368
|
+
<CardDescription>
|
|
369
|
+
status="error" は色だけでなく aria-invalid も立てます(WCAG 1.4.1)。
|
|
370
|
+
空白だけの下書きでは送信ボタンは無効のまま、名前は保持されます。
|
|
371
|
+
</CardDescription>
|
|
372
|
+
</CardHeader>
|
|
373
|
+
<CardContent>
|
|
374
|
+
<Flex direction="col" gap="md">
|
|
375
|
+
<FormField
|
|
376
|
+
id="error-composer"
|
|
377
|
+
label="お問い合わせ内容"
|
|
378
|
+
helper="送信前に内容をご確認ください"
|
|
379
|
+
error="メッセージを入力してください"
|
|
380
|
+
required
|
|
381
|
+
>
|
|
382
|
+
<ChatComposer
|
|
383
|
+
status="error"
|
|
384
|
+
value={errorDraft}
|
|
385
|
+
onValueChange={setErrorDraft}
|
|
386
|
+
placeholder="必須項目です"
|
|
387
|
+
/>
|
|
388
|
+
</FormField>
|
|
389
|
+
|
|
390
|
+
<ChatComposer
|
|
391
|
+
aria-label="警告状態のメッセージ"
|
|
392
|
+
status="warning"
|
|
393
|
+
value={warningDraft}
|
|
394
|
+
onValueChange={setWarningDraft}
|
|
395
|
+
footer={
|
|
396
|
+
<Text size="xs" tone="muted">
|
|
397
|
+
送信先を選択すると警告は消えます
|
|
398
|
+
</Text>
|
|
399
|
+
}
|
|
400
|
+
/>
|
|
401
|
+
|
|
402
|
+
<ChatComposer
|
|
403
|
+
aria-label="無効なメッセージ"
|
|
404
|
+
disabled
|
|
405
|
+
defaultValue="このスレッドは終了しました"
|
|
406
|
+
/>
|
|
407
|
+
|
|
408
|
+
<ChatComposer
|
|
409
|
+
aria-label="読み取り専用のメッセージ"
|
|
410
|
+
readOnly
|
|
411
|
+
defaultValue="監査ログのため編集できません"
|
|
412
|
+
/>
|
|
413
|
+
|
|
414
|
+
<ChatComposer
|
|
415
|
+
aria-label="文字数制限つきのメッセージ"
|
|
416
|
+
maxLength={120}
|
|
417
|
+
value={countedDraft}
|
|
418
|
+
onValueChange={setCountedDraft}
|
|
419
|
+
footer={
|
|
420
|
+
<Text size="xs" tone="muted">
|
|
421
|
+
{countedDraft.length} / 120
|
|
422
|
+
</Text>
|
|
423
|
+
}
|
|
424
|
+
/>
|
|
425
|
+
</Flex>
|
|
426
|
+
</CardContent>
|
|
427
|
+
</Card>
|
|
428
|
+
|
|
429
|
+
{/* ── 6. ChatSuggestion with a different trigger ───────────────────────────────── */}
|
|
430
|
+
<Card>
|
|
431
|
+
<CardHeader>
|
|
432
|
+
<CardTitle level={2}>ChatSuggestion · triggerCharacter="@"</CardTitle>
|
|
433
|
+
<CardDescription>
|
|
434
|
+
同じコンポーネントで、開くきっかけの文字だけを変えたメンション一覧。
|
|
435
|
+
「@」を単語の先頭で入力すると開き、↑↓ で移動、Enter か Tab で確定、Escape
|
|
436
|
+
で閉じます(入力中の文面は消えません)。
|
|
437
|
+
</CardDescription>
|
|
438
|
+
</CardHeader>
|
|
439
|
+
<CardContent>
|
|
440
|
+
<ChatSuggestion
|
|
441
|
+
items={MEMBERS}
|
|
442
|
+
triggerCharacter="@"
|
|
443
|
+
onValueChange={(value) => setMentionDraft((current) => `${current}${value} `)}
|
|
444
|
+
>
|
|
445
|
+
{({ onTrigger, onKeyDown }) => (
|
|
446
|
+
<ChatComposer
|
|
447
|
+
aria-label="メンション付きのメッセージ"
|
|
448
|
+
value={mentionDraft}
|
|
449
|
+
onValueChange={(next) => {
|
|
450
|
+
setMentionDraft(next);
|
|
451
|
+
onTrigger(next);
|
|
452
|
+
}}
|
|
453
|
+
onKeyDown={onKeyDown}
|
|
454
|
+
placeholder="「@」でメンバー"
|
|
455
|
+
/>
|
|
456
|
+
)}
|
|
457
|
+
</ChatSuggestion>
|
|
458
|
+
</CardContent>
|
|
459
|
+
</Card>
|
|
460
|
+
</Flex>
|
|
461
|
+
</PageContainer>
|
|
462
|
+
</AppShell>
|
|
463
|
+
);
|
|
464
|
+
}
|