ChoicePicker 将选项、搜索和确认组合成一个选择面板。桌面使用浮层,窄屏使用底部面板;选项数据与已保存值共享。
单选
通过 items 提供稳定的 value、可读的 label 和可选说明。v-model 使用值数组,单选保存一个值,空数组表示未选择。默认在激活选项后保存并关闭,方向键移动高亮。
搜索与多选
selectionMode="multiple" 使用草稿选择,点击确认后统一保存。取消会丢弃本次修改。单选也可以使用 commitMode="explicit" 提供确认步骤。
开启 searchable 显示搜索框。搜索匹配名称和 keywords,过滤结果保留已选值。通过 empty 插槽提供适合当前场景的空结果内容。
提交与重试
submit 接收完整候选值、上次保存值以及 signal。返回 Promise 时,组件保留草稿并防止重复提交;成功后更新模型并触发 commit,失败后显示 errorText 并允许重试。
下面的资料目录包含 30 个可搜索选项,首次保存会模拟失败,再次提交即可完成。处理期间保留搜索框和已选草稿;失败后点击“重试”继续。移动端的标题、搜索与操作区保持可见,长选项列表在正文区域内滚动。
远程搜索
远程搜索使用 filter="none"、searchRequest、loading 与 searchError。每个搜索请求携带独立的取消信号,宿主使用最新查询结果更新 items。暂时不在结果中的已选项仍然保留。
呈现与键盘
presentation="auto" 在小于 768px 时使用底部面板,也可固定为 desktop 或 bottom。已打开的面板保持当前呈现方式。
选项列表使用方向键移动高亮,Enter 或 Space 选择。Tab 在搜索、列表和操作按钮间移动。Escape 或取消结束选择,焦点返回打开按钮。
API
QuireChoicePicker Props
Slots 内容位置
triggerOne real button, with task ARIA and native behavior merged in place.
{ open: boolean; disabled: boolean; summary: string; presentation: undefined | "desktop" | "bottom"; }itemReplaces candidate decoration while Listbox retains option semantics.
{ /** Current known item. */ item: { /** Non-empty identity unique in the current collection. */ value: string; /** Visible and accessible item name. */ label: string; /** Optional secondary explanation. */ description?: undefined | string; /** Prevents adding this item while retaining existing committed values. */ disabled?: boolean | undefined; /** Optional visible group name. */ group?: string | undefined; /** Additional terms consumed by local filtering. */ keywords?: undefined | readonly (string)[]; }; /** Whether the item belongs to the current draft. */ selected: boolean; /** Keyboard highlight, independent from selection. */ highlighted: boolean; /** Whether the item is unavailable for activation. */ disabled: boolean; }emptyEmpty result content, optionally including a host recovery action.
anyloadingLoading decoration without replacing the list or query input.
anystatusReplaces the readable message in the single live status lane.
{ busy: boolean; error: undefined | string; selectedCount: number; }
Events 组件事件
update:modelValue更新
modelValue,可通过对应 v-model 绑定。[value: readonly string[]]update:open更新
open,可通过对应 v-model 绑定。[value: boolean]openChange[value: boolean]cancel[details: { readonly reason: QuireKitTaskCancelReason; readonly sessionId: string; }]update:query更新
query,可通过对应 v-model 绑定。[value: string]commit[request: QuireKitChoiceSubmitRequest]error[details: { readonly error: unknown; readonly request: QuireKitChoiceSubmitRequest; }]searchRequest[request: QuireKitTaskSearchRequest]
公开实例成员
requestClose(reason?: QuireKitTaskCloseReason | undefined) => boolean