@godxjp/ui 20.2.0 → 21.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.
Files changed (60) hide show
  1. package/dist/components/data-display/chat-bubble.d.ts +30 -0
  2. package/dist/components/data-display/chat-bubble.js +229 -0
  3. package/dist/components/data-display/descriptions.js +4 -1
  4. package/dist/components/data-display/index.d.ts +4 -2
  5. package/dist/components/data-display/index.js +5 -2
  6. package/dist/components/data-display/popover.js +3 -2
  7. package/dist/components/data-display/scroll-area.js +26 -1
  8. package/dist/components/data-display/tree.d.ts +8 -0
  9. package/dist/components/data-display/tree.js +426 -0
  10. package/dist/components/data-entry/chat-composer.d.ts +50 -0
  11. package/dist/components/data-entry/chat-composer.js +163 -0
  12. package/dist/components/data-entry/chat-suggestion.d.ts +28 -0
  13. package/dist/components/data-entry/chat-suggestion.js +285 -0
  14. package/dist/components/data-entry/index.d.ts +4 -0
  15. package/dist/components/data-entry/index.js +4 -0
  16. package/dist/components/data-entry/textarea.js +3 -1
  17. package/dist/components/data-entry/tree-utils.d.ts +10 -48
  18. package/dist/components/data-entry/tree-utils.js +1 -154
  19. package/dist/components/layout/org-switcher.js +22 -2
  20. package/dist/i18n/messages/en.json +50 -0
  21. package/dist/i18n/messages/ja.json +48 -0
  22. package/dist/i18n/messages/vi.json +49 -0
  23. package/dist/lib/tree.d.ts +53 -0
  24. package/dist/lib/tree.js +155 -0
  25. package/dist/props/components/data-display.prop.d.ts +187 -1
  26. package/dist/props/components/data-entry.prop.d.ts +127 -0
  27. package/dist/props/registry.d.ts +140 -3
  28. package/dist/props/registry.js +202 -3
  29. package/dist/styles/control.css +7 -0
  30. package/dist/styles/data-display-layout.css +309 -55
  31. package/dist/styles/data-entry-layout.css +64 -0
  32. package/dist/styles/shell-layout.css +41 -11
  33. package/dist/tokens/base.css +3 -0
  34. package/dist/tokens/components/chat-bubble.css +36 -0
  35. package/dist/tokens/components/chat-composer.css +19 -0
  36. package/dist/tokens/components/data-display.css +0 -6
  37. package/dist/tokens/components/descriptions.css +4 -0
  38. package/dist/tokens/components/shell.css +13 -3
  39. package/dist/tokens/components/tree.css +27 -0
  40. package/docs/FRAME-COVERAGE-LEDGER.md +1 -1
  41. package/docs/FRAME-COVERAGE-REPORT.md +8 -3
  42. package/docs/data-display/chat-bubble.tsx +397 -0
  43. package/docs/data-display/timeline.tsx +46 -0
  44. package/docs/data-display/tree.tsx +394 -0
  45. package/docs/data-entry/chat-composer.tsx +464 -0
  46. package/docs/data-entry/chat-suggestion.tsx +301 -0
  47. package/docs/roadmap/ai-chat-components.md +207 -0
  48. package/docs/roadmap/antd-parity.md +154 -0
  49. package/docs/roadmap/badge-tag-chip-count.md +172 -0
  50. package/docs/roadmap/list-masonry.md +159 -0
  51. package/docs/roadmap/parity-audit-data-display-feedback.md +567 -0
  52. package/docs/roadmap/parity-audit-data-entry.md +344 -0
  53. package/docs/roadmap/parity-audit-layout-navigation-general.md +464 -0
  54. package/docs/roadmap/parity-backlog.md +79 -0
  55. package/docs/roadmap/tree-components.md +151 -0
  56. package/docs/showcase/table-tree-rows.tsx +4 -4
  57. package/package.json +5 -3
  58. package/dist/components/data-display/tree-list.d.ts +0 -13
  59. package/dist/components/data-display/tree-list.js +0 -26
  60. package/docs/data-display/tree-list.tsx +0 -107
@@ -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=&quot;error&quot; は色だけでなく 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=&quot;@&quot;</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
+ }