3e9be13b19
The CSS port prefixed data-slot attribute values with hv-, so the compiled selectors never matched the DOM and the ComboBox trigger chevron never rotated. Only class names get the prefix; slot values stay byte-identical. Also commit typed text as the value when allowsCustomValue finds no record, restore the baseline search-field shell in all 24 Autocomplete demos, and correct both doc pages against the pinned upstream sources.
73 lines
1.9 KiB
Vue
73 lines
1.9 KiB
Vue
<script setup lang="ts">
|
|
import { ref } from "vue";
|
|
import {
|
|
Button,
|
|
ComboBox,
|
|
ComboBoxInputGroup,
|
|
ComboBoxPopover,
|
|
ComboBoxTrigger,
|
|
FieldError,
|
|
Form,
|
|
Input,
|
|
Label,
|
|
ListBox,
|
|
ListBoxItem,
|
|
ListBoxItemIndicator,
|
|
Surface,
|
|
} from "@heroui-vue/components";
|
|
|
|
const message = ref("");
|
|
|
|
function onSubmit(event: Event) {
|
|
event.preventDefault();
|
|
message.value = "表单提交成功!";
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<Surface class="w-[320px] rounded-3xl p-6">
|
|
<Form class="flex w-full flex-col gap-4" @submit="onSubmit">
|
|
<ComboBox is-required class="w-full" name="animal" variant="secondary">
|
|
<Label>最喜欢的动物</Label>
|
|
<ComboBoxInputGroup>
|
|
<Input placeholder="搜索动物…" />
|
|
<ComboBoxTrigger />
|
|
</ComboBoxInputGroup>
|
|
<ComboBoxPopover>
|
|
<ListBox>
|
|
<ListBoxItem id="aardvark" text-value="土豚">
|
|
土豚
|
|
<ListBoxItemIndicator />
|
|
</ListBoxItem>
|
|
<ListBoxItem id="cat" text-value="猫">
|
|
猫
|
|
<ListBoxItemIndicator />
|
|
</ListBoxItem>
|
|
<ListBoxItem id="dog" text-value="狗">
|
|
狗
|
|
<ListBoxItemIndicator />
|
|
</ListBoxItem>
|
|
<ListBoxItem id="kangaroo" text-value="袋鼠">
|
|
袋鼠
|
|
<ListBoxItemIndicator />
|
|
</ListBoxItem>
|
|
<ListBoxItem id="panda" text-value="熊猫">
|
|
熊猫
|
|
<ListBoxItemIndicator />
|
|
</ListBoxItem>
|
|
<ListBoxItem id="snake" text-value="蛇">
|
|
蛇
|
|
<ListBoxItemIndicator />
|
|
</ListBoxItem>
|
|
</ListBox>
|
|
</ComboBoxPopover>
|
|
<FieldError />
|
|
</ComboBox>
|
|
<Button type="submit">提交</Button>
|
|
<p v-if="message" class="text-sm text-muted" role="status">
|
|
{{ message }}
|
|
</p>
|
|
</Form>
|
|
</Surface>
|
|
</template>
|