feat(combo-box): migrate ComboBox with input-owned focus and filtering
Port the fixed-baseline ComboBox onto the B02a collection protocol: the input keeps real DOM focus, the list only tracks an active row, and filtering reuses the owner filter instead of a second collection kernel. - Five parts: root (field text control, value/input/open models, form value, owner wiring), InputGroup (composes the caller's Input into the combobox control and anchors the popover), Trigger, Value, Popover. - Closed-state metadata is planned from the slot tree, so filtering, the initial value label and form-value="text" work before the list has mounted. - Selection text syncs on selection changes only, so allows-custom-value typing is not overwritten; read-only and disabled are injected onto the composed input because it reads the text-field protocol, not the field context. - 24 baseline previews, the Chinese doc page, navigation, 19 behaviour tests and 6 demo/document contracts. Async demo uses a local async source with abort, loading and incremental append (documented adaptations). Not included: independent tarball consumption (B02d).
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Avatar,
|
||||
AvatarFallback,
|
||||
AvatarImage,
|
||||
ComboBox,
|
||||
ComboBoxInputGroup,
|
||||
ComboBoxPopover,
|
||||
ComboBoxTrigger,
|
||||
Description,
|
||||
Input,
|
||||
Label,
|
||||
ListBox,
|
||||
ListBoxItem,
|
||||
ListBoxItemIndicator,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
const users = [
|
||||
{
|
||||
id: "1",
|
||||
name: "Bob",
|
||||
email: "bob@heroui.com",
|
||||
fallback: "B",
|
||||
avatarUrl:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/blue.jpg",
|
||||
},
|
||||
{
|
||||
id: "2",
|
||||
name: "Fred",
|
||||
email: "fred@heroui.com",
|
||||
fallback: "F",
|
||||
avatarUrl:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/green.jpg",
|
||||
},
|
||||
{
|
||||
id: "3",
|
||||
name: "Martha",
|
||||
email: "martha@heroui.com",
|
||||
fallback: "M",
|
||||
avatarUrl:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/purple.jpg",
|
||||
},
|
||||
{
|
||||
id: "4",
|
||||
name: "John",
|
||||
email: "john@heroui.com",
|
||||
fallback: "J",
|
||||
avatarUrl:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/red.jpg",
|
||||
},
|
||||
{
|
||||
id: "5",
|
||||
name: "Jane",
|
||||
email: "jane@heroui.com",
|
||||
fallback: "J",
|
||||
avatarUrl:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/orange.jpg",
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ComboBox class="w-[256px]">
|
||||
<Label>用户</Label>
|
||||
<ComboBoxInputGroup>
|
||||
<Input placeholder="搜索用户…" />
|
||||
<ComboBoxTrigger />
|
||||
</ComboBoxInputGroup>
|
||||
<ComboBoxPopover>
|
||||
<ListBox>
|
||||
<ListBoxItem
|
||||
v-for="user in users"
|
||||
:id="user.id"
|
||||
:key="user.id"
|
||||
:text-value="user.name"
|
||||
>
|
||||
<Avatar size="sm">
|
||||
<AvatarImage :src="user.avatarUrl" />
|
||||
<AvatarFallback>{{ user.fallback }}</AvatarFallback>
|
||||
</Avatar>
|
||||
<div class="flex flex-col">
|
||||
<Label>{{ user.name }}</Label>
|
||||
<Description>{{ user.email }}</Description>
|
||||
</div>
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
</ListBox>
|
||||
</ComboBoxPopover>
|
||||
</ComboBox>
|
||||
</template>
|
||||
Reference in New Issue
Block a user