Files
heroui-vue/apps/docs/demos/autocomplete-with-disabled-options.vue
T
maoyingjie 3e9be13b19 fix(pickers): repair data-slot selectors and align demos with the baseline
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.
2026-10-25 17:46:32 +08:00

81 lines
1.9 KiB
Vue

<script setup lang="ts">
import { ref } from "vue";
import {
Autocomplete,
AutocompleteClearButton,
AutocompleteFilter,
AutocompleteIndicator,
AutocompletePopover,
AutocompleteTrigger,
AutocompleteValue,
EmptyState,
Label,
ListBox,
ListBoxItem,
ListBoxItemIndicator,
SearchField,
SearchFieldClearButton,
SearchFieldGroup,
SearchFieldInput,
SearchFieldSearchIcon,
} from "@heroui-vue/components";
const animals = [
{ id: "dog", name: "狗" },
{ id: "cat", name: "猫" },
{ id: "bird", name: "鸟" },
{ id: "kangaroo", name: "袋鼠" },
{ id: "elephant", name: "象" },
{ id: "tiger", name: "老虎" },
];
const selectedKey = ref<string | null>(null);
</script>
<template>
<Autocomplete
v-model="selectedKey"
class="w-[256px]"
:disabled-keys="['cat', 'kangaroo']"
placeholder="选择一种动物"
selection-mode="single"
>
<Label>动物</Label>
<AutocompleteTrigger>
<AutocompleteValue />
<AutocompleteClearButton />
<AutocompleteIndicator />
</AutocompleteTrigger>
<AutocompletePopover>
<AutocompleteFilter>
<SearchField
auto-focus
name="search"
variant="secondary"
aria-label="搜索动物"
>
<SearchFieldGroup>
<SearchFieldSearchIcon />
<SearchFieldInput placeholder="搜索动物…" />
<SearchFieldClearButton />
</SearchFieldGroup>
</SearchField>
<ListBox>
<ListBoxItem
v-for="animal in animals"
:id="animal.id"
:key="animal.id"
:text-value="animal.name"
>
{{ animal.name }}
<ListBoxItemIndicator />
</ListBoxItem>
<template #empty>
<EmptyState>未找到结果</EmptyState>
</template>
</ListBox>
</AutocompleteFilter>
</AutocompletePopover>
</Autocomplete>
</template>