46e4df7e85
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).
49 lines
1.5 KiB
Vue
49 lines
1.5 KiB
Vue
<script setup lang="ts">
|
|
import {
|
|
ComboBox,
|
|
ComboBoxInputGroup,
|
|
ComboBoxPopover,
|
|
ComboBoxTrigger,
|
|
Input,
|
|
Label,
|
|
ListBox,
|
|
ListBoxItem,
|
|
ListBoxItemIndicator,
|
|
} from "@heroui-vue/components";
|
|
|
|
const itemClass =
|
|
"rounded-lg data-[focused=true]:bg-muted/70 data-[selected=true]:font-medium data-[selected=true]:text-foreground";
|
|
</script>
|
|
|
|
<template>
|
|
<ComboBox class="w-64 gap-1.5">
|
|
<Label class="font-medium text-neutral-800 dark:text-neutral-100">
|
|
框架
|
|
</Label>
|
|
<ComboBoxInputGroup
|
|
class="rounded-xl border border-border/80 bg-surface shadow-sm ring-1 ring-black/5 transition-[box-shadow,border-color] focus-within:ring-2 focus-within:ring-neutral-400/25 dark:ring-white/10 dark:focus-within:ring-neutral-500/30"
|
|
>
|
|
<Input placeholder="搜索…" />
|
|
<ComboBoxTrigger class="text-muted" />
|
|
</ComboBoxInputGroup>
|
|
<ComboBoxPopover
|
|
class="rounded-xl border border-border/80 bg-surface p-1 shadow-lg ring-1 ring-black/5 dark:ring-white/10"
|
|
>
|
|
<ListBox>
|
|
<ListBoxItem :class="itemClass" id="react" text-value="React">
|
|
React
|
|
<ListBoxItemIndicator />
|
|
</ListBoxItem>
|
|
<ListBoxItem :class="itemClass" id="vue" text-value="Vue">
|
|
Vue
|
|
<ListBoxItemIndicator />
|
|
</ListBoxItem>
|
|
<ListBoxItem :class="itemClass" id="svelte" text-value="Svelte">
|
|
Svelte
|
|
<ListBoxItemIndicator />
|
|
</ListBoxItem>
|
|
</ListBox>
|
|
</ComboBoxPopover>
|
|
</ComboBox>
|
|
</template>
|