AgentCharacterPicker
先暂存、确认后才生效的 CharacterPicker。
已提交 hex、blue——写入 0 次
形状
配色
一次点击是一个提议
普通选择器是受控的:每次点击都由宿主去应用。这在设置表单里是对的,在对话框里就错了——那里一次点击只是提议,取消必须有意义。这个组件把提议留在本地,确认时只交出一个值,于是宿主对存储的写入是每个对话框一次,而不是每次点击一次——页头的头像也不会在某人犹豫时闪过五种形状。
onCommit 在确认时收到暂存的 CharacterChoice;onCancel 在放弃时触发,暂存的修改重置回 value。immediate 关掉暂存、每次选择立即提交,供设置表单的场合使用,宿主不必换组件。
图片与操作按钮
hasPicture 表示智能体有自己的照片。此时网格不显示选中环,因为下面的角色并不是屏幕上显示的东西——给一个没人看得见的六边形打高亮是在说谎。选中状态仍会播报给辅助技术。
actions={false} 隐藏确认和放弃按钮,给把按钮放在对话框底栏的宿主用;保持 immediate 关闭、把选择器放进你自己控制提交的表单里,就能用自己的按钮完成提交。
API
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
value* | CharacterChoice | — | The committed appearance. Staged edits start from here and reset to it on cancel. |
actions | boolean | true | Show the confirm and discard buttons. Off when a host supplies its own. |
className | string | — | — |
colors | readonly ("black" | "brown" | "red" | "orange" | "yellow" | "green" | "cyan" | "blue" | "violet" | "magenta" | "pink" | "gray")[] | — | — |
hasPicture | boolean | false | The agent has a picture of its own. The grid then shows no selection ring, because the character underneath is not what is on screen — highlighting a shape would claim the avatar is something it is not. Picking still stages a choice, so confirming swaps the picture out for the character. |
immediate | boolean | false | Commit on every pick instead of waiting for confirmation. |
layout | "grid" | "row" | 'grid' | — |
lineWeight | number | — | — |
onCancel | (() => void) | — | Called when the staged appearance is discarded. |
onCommit | ((choice: CharacterChoice) => void) | — | Called with the staged appearance when it is confirmed. |
shapes | readonly ("mochi" | "circle" | "blob" | "pebble" | "egg" | "bun" | "tofu" | "pill" | "hex" | "onigiri" | "gem" | "cloud" | "drop" | "leaf" | "flower" | "clover" | "sprout" | "mushroom" | "acorn" | "cactus" | "pear" | "apple" | "strawberry" | "cherry" | "star" | "heart" | "flame" | "bell" | "ghost" | "bot" | "crescent" | "boba" | "fish" | "octopus" | "cat" | "bunny" | "bear" | "chick" | "penguin" | "pig" | "fox" | "bob" | "topknot" | "spiky" | "curly" | "twinbuns")[] | — | — |
style | CSSProperties | — | — |
接下来
- CompactCharacterPicker——注册表单用的精简版
- 角色设置——挑选智能体的外观