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.
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
Label,
|
||||
ListBox,
|
||||
SearchField,
|
||||
SearchFieldClearButton,
|
||||
SearchFieldGroup,
|
||||
SearchFieldInput,
|
||||
SearchFieldSearchIcon,
|
||||
@@ -32,15 +33,21 @@ import {
|
||||
</AutocompleteTrigger>
|
||||
<AutocompletePopover>
|
||||
<AutocompleteFilter>
|
||||
<SearchField aria-label="搜索州名">
|
||||
<SearchField
|
||||
auto-focus
|
||||
name="search"
|
||||
variant="secondary"
|
||||
aria-label="搜索州名"
|
||||
>
|
||||
<SearchFieldGroup>
|
||||
<SearchFieldSearchIcon />
|
||||
<SearchFieldInput placeholder="搜索州名…" />
|
||||
<SearchFieldClearButton />
|
||||
</SearchFieldGroup>
|
||||
</SearchField>
|
||||
<ListBox>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到结果</EmptyState>
|
||||
<EmptyState>未找到结果</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
|
||||
@@ -29,19 +29,20 @@ type Character = {
|
||||
|
||||
const SEARCH_DELAY = 300;
|
||||
|
||||
// SWAPI 返回的角色名(源示例直接用 item.name 作为 id 与文本)。
|
||||
const characters: Character[] = [
|
||||
{ id: "luke-skywalker", name: "卢克·天行者" },
|
||||
{ id: "princess-leia", name: "莱娅公主" },
|
||||
{ id: "han-solo", name: "汉·索罗" },
|
||||
{ id: "darth-vader", name: "达斯·维达" },
|
||||
{ id: "yoda", name: "尤达" },
|
||||
{ id: "obi-wan-kenobi", name: "欧比旺·克诺比" },
|
||||
{ id: "palpatine", name: "帕尔帕廷" },
|
||||
{ id: "lando-calrissian", name: "兰多·卡瑞辛" },
|
||||
{ id: "chewbacca", name: "楚巴卡" },
|
||||
{ id: "r2-d2", name: "R2-D2" },
|
||||
{ id: "c-3po", name: "C-3PO" },
|
||||
{ id: "boba-fett", name: "波巴·费特" },
|
||||
{ id: "Luke Skywalker", name: "Luke Skywalker" },
|
||||
{ id: "Princess Leia", name: "Princess Leia" },
|
||||
{ id: "Han Solo", name: "Han Solo" },
|
||||
{ id: "Darth Vader", name: "Darth Vader" },
|
||||
{ id: "Yoda", name: "Yoda" },
|
||||
{ id: "Obi-Wan Kenobi", name: "Obi-Wan Kenobi" },
|
||||
{ id: "Palpatine", name: "Palpatine" },
|
||||
{ id: "Lando Calrissian", name: "Lando Calrissian" },
|
||||
{ id: "Chewbacca", name: "Chewbacca" },
|
||||
{ id: "R2-D2", name: "R2-D2" },
|
||||
{ id: "C-3PO", name: "C-3PO" },
|
||||
{ id: "Boba Fett", name: "Boba Fett" },
|
||||
];
|
||||
|
||||
const query = ref("");
|
||||
@@ -144,7 +145,7 @@ const keepResults = () => true;
|
||||
</ListBoxItem>
|
||||
</template>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到结果</EmptyState>
|
||||
<EmptyState>未找到结果</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
ListBoxItem,
|
||||
ListBoxItemIndicator,
|
||||
SearchField,
|
||||
SearchFieldClearButton,
|
||||
SearchFieldGroup,
|
||||
SearchFieldInput,
|
||||
SearchFieldSearchIcon,
|
||||
@@ -48,10 +49,16 @@ const selected = ref<TagKey[]>(["california", "texas"]);
|
||||
</AutocompleteTrigger>
|
||||
<AutocompletePopover>
|
||||
<AutocompleteFilter>
|
||||
<SearchField aria-label="搜索州名">
|
||||
<SearchField
|
||||
auto-focus
|
||||
name="search"
|
||||
variant="secondary"
|
||||
aria-label="搜索州名"
|
||||
>
|
||||
<SearchFieldGroup>
|
||||
<SearchFieldSearchIcon />
|
||||
<SearchFieldInput placeholder="搜索州名…" />
|
||||
<SearchFieldClearButton />
|
||||
</SearchFieldGroup>
|
||||
</SearchField>
|
||||
<ListBox>
|
||||
@@ -65,7 +72,7 @@ const selected = ref<TagKey[]>(["california", "texas"]);
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到结果</EmptyState>
|
||||
<EmptyState>未找到结果</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
ListBoxItem,
|
||||
ListBoxItemIndicator,
|
||||
SearchField,
|
||||
SearchFieldClearButton,
|
||||
SearchFieldGroup,
|
||||
SearchFieldInput,
|
||||
SearchFieldSearchIcon,
|
||||
@@ -49,10 +50,16 @@ const isOpen = ref(false);
|
||||
</AutocompleteTrigger>
|
||||
<AutocompletePopover>
|
||||
<AutocompleteFilter>
|
||||
<SearchField aria-label="搜索州名">
|
||||
<SearchField
|
||||
auto-focus
|
||||
name="search"
|
||||
variant="secondary"
|
||||
aria-label="搜索州名"
|
||||
>
|
||||
<SearchFieldGroup>
|
||||
<SearchFieldSearchIcon />
|
||||
<SearchFieldInput placeholder="搜索州名…" />
|
||||
<SearchFieldClearButton />
|
||||
</SearchFieldGroup>
|
||||
</SearchField>
|
||||
<ListBox>
|
||||
@@ -66,7 +73,7 @@ const isOpen = ref(false);
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到结果</EmptyState>
|
||||
<EmptyState>未找到结果</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
ListBoxItem,
|
||||
ListBoxItemIndicator,
|
||||
SearchField,
|
||||
SearchFieldClearButton,
|
||||
SearchFieldGroup,
|
||||
SearchFieldInput,
|
||||
SearchFieldSearchIcon,
|
||||
@@ -51,10 +52,16 @@ const selectedState = computed(() =>
|
||||
</AutocompleteTrigger>
|
||||
<AutocompletePopover>
|
||||
<AutocompleteFilter>
|
||||
<SearchField aria-label="搜索州名">
|
||||
<SearchField
|
||||
auto-focus
|
||||
name="search"
|
||||
variant="secondary"
|
||||
aria-label="搜索州名"
|
||||
>
|
||||
<SearchFieldGroup>
|
||||
<SearchFieldSearchIcon />
|
||||
<SearchFieldInput placeholder="搜索州名…" />
|
||||
<SearchFieldClearButton />
|
||||
</SearchFieldGroup>
|
||||
</SearchField>
|
||||
<ListBox>
|
||||
@@ -68,7 +75,7 @@ const selectedState = computed(() =>
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到结果</EmptyState>
|
||||
<EmptyState>未找到结果</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
ListBoxItem,
|
||||
ListBoxItemIndicator,
|
||||
SearchField,
|
||||
SearchFieldClearButton,
|
||||
SearchFieldGroup,
|
||||
SearchFieldInput,
|
||||
SearchFieldSearchIcon,
|
||||
@@ -43,16 +44,22 @@ const selectedKey = ref<string | null>(null);
|
||||
<AutocompleteTrigger>
|
||||
<AutocompleteValue />
|
||||
<AutocompleteClearButton />
|
||||
<AutocompleteIndicator>
|
||||
<IconSelector class="size-3" aria-hidden="true" />
|
||||
<AutocompleteIndicator class="size-3">
|
||||
<IconSelector aria-hidden="true" />
|
||||
</AutocompleteIndicator>
|
||||
</AutocompleteTrigger>
|
||||
<AutocompletePopover>
|
||||
<AutocompleteFilter>
|
||||
<SearchField aria-label="搜索州名">
|
||||
<SearchField
|
||||
auto-focus
|
||||
name="search"
|
||||
variant="secondary"
|
||||
aria-label="搜索州名"
|
||||
>
|
||||
<SearchFieldGroup>
|
||||
<SearchFieldSearchIcon />
|
||||
<SearchFieldInput placeholder="搜索州名…" />
|
||||
<SearchFieldClearButton />
|
||||
</SearchFieldGroup>
|
||||
</SearchField>
|
||||
<ListBox>
|
||||
@@ -66,7 +73,7 @@ const selectedKey = ref<string | null>(null);
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到结果</EmptyState>
|
||||
<EmptyState>未找到结果</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
|
||||
@@ -116,7 +116,7 @@ function onRemoveTags(keys: TagKey[]) {
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到团队成员</EmptyState>
|
||||
<EmptyState>未找到团队成员</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
|
||||
@@ -89,7 +89,7 @@ const currencyOf = (key: unknown) =>
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到结果</EmptyState>
|
||||
<EmptyState>未找到结果</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
import { ref } from "vue";
|
||||
import {
|
||||
Autocomplete,
|
||||
AutocompleteClearButton,
|
||||
AutocompleteFilter,
|
||||
AutocompleteIndicator,
|
||||
AutocompletePopover,
|
||||
@@ -14,6 +13,7 @@ import {
|
||||
ListBoxItem,
|
||||
ListBoxItemIndicator,
|
||||
SearchField,
|
||||
SearchFieldClearButton,
|
||||
SearchFieldGroup,
|
||||
SearchFieldInput,
|
||||
SearchFieldSearchIcon,
|
||||
@@ -71,10 +71,16 @@ function onRemoveTags(keys: TagKey[]) {
|
||||
</AutocompleteTrigger>
|
||||
<AutocompletePopover>
|
||||
<AutocompleteFilter>
|
||||
<SearchField aria-label="搜索选项">
|
||||
<SearchField
|
||||
auto-focus
|
||||
name="search"
|
||||
variant="secondary"
|
||||
aria-label="搜索选项"
|
||||
>
|
||||
<SearchFieldGroup>
|
||||
<SearchFieldSearchIcon />
|
||||
<SearchFieldInput placeholder="搜索…" />
|
||||
<SearchFieldClearButton />
|
||||
</SearchFieldGroup>
|
||||
</SearchField>
|
||||
<ListBox>
|
||||
@@ -88,7 +94,7 @@ function onRemoveTags(keys: TagKey[]) {
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到结果</EmptyState>
|
||||
<EmptyState>未找到结果</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
ListBoxItem,
|
||||
ListBoxItemIndicator,
|
||||
SearchField,
|
||||
SearchFieldClearButton,
|
||||
SearchFieldGroup,
|
||||
SearchFieldInput,
|
||||
SearchFieldSearchIcon,
|
||||
@@ -54,10 +55,16 @@ const countries = [
|
||||
</AutocompleteTrigger>
|
||||
<AutocompletePopover>
|
||||
<AutocompleteFilter>
|
||||
<SearchField aria-label="搜索州名">
|
||||
<SearchField
|
||||
auto-focus
|
||||
name="search"
|
||||
variant="secondary"
|
||||
aria-label="搜索州名"
|
||||
>
|
||||
<SearchFieldGroup>
|
||||
<SearchFieldSearchIcon />
|
||||
<SearchFieldInput placeholder="搜索州名…" />
|
||||
<SearchFieldClearButton />
|
||||
</SearchFieldGroup>
|
||||
</SearchField>
|
||||
<ListBox>
|
||||
@@ -71,7 +78,7 @@ const countries = [
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到结果</EmptyState>
|
||||
<EmptyState>未找到结果</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
@@ -92,10 +99,16 @@ const countries = [
|
||||
</AutocompleteTrigger>
|
||||
<AutocompletePopover>
|
||||
<AutocompleteFilter>
|
||||
<SearchField aria-label="搜索国家">
|
||||
<SearchField
|
||||
auto-focus
|
||||
name="search"
|
||||
variant="secondary"
|
||||
aria-label="搜索国家"
|
||||
>
|
||||
<SearchFieldGroup>
|
||||
<SearchFieldSearchIcon />
|
||||
<SearchFieldInput placeholder="搜索国家…" />
|
||||
<SearchFieldClearButton />
|
||||
</SearchFieldGroup>
|
||||
</SearchField>
|
||||
<ListBox>
|
||||
@@ -109,7 +122,7 @@ const countries = [
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到结果</EmptyState>
|
||||
<EmptyState>未找到结果</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
|
||||
@@ -107,7 +107,7 @@ function onRemoveTags(keys: TagKey[]) {
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到收件人</EmptyState>
|
||||
<EmptyState>未找到收件人</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
ListBoxItem,
|
||||
ListBoxItemIndicator,
|
||||
SearchField,
|
||||
SearchFieldClearButton,
|
||||
SearchFieldGroup,
|
||||
SearchFieldInput,
|
||||
SearchFieldSearchIcon,
|
||||
@@ -49,10 +50,16 @@ const selectedKey = ref<string | null>(null);
|
||||
</AutocompleteTrigger>
|
||||
<AutocompletePopover>
|
||||
<AutocompleteFilter>
|
||||
<SearchField aria-label="搜索州名">
|
||||
<SearchField
|
||||
auto-focus
|
||||
name="search"
|
||||
variant="secondary"
|
||||
aria-label="搜索州名"
|
||||
>
|
||||
<SearchFieldGroup>
|
||||
<SearchFieldSearchIcon />
|
||||
<SearchFieldInput placeholder="搜索州名…" />
|
||||
<SearchFieldClearButton />
|
||||
</SearchFieldGroup>
|
||||
</SearchField>
|
||||
<ListBox>
|
||||
@@ -66,7 +73,7 @@ const selectedKey = ref<string | null>(null);
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到结果</EmptyState>
|
||||
<EmptyState>未找到结果</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
|
||||
@@ -103,7 +103,7 @@ onBeforeUnmount(() => clearTimeout(timer));
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">
|
||||
<EmptyState>
|
||||
{{ loading ? "搜索中…" : "未找到城市" }}
|
||||
</EmptyState>
|
||||
</template>
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
ListBoxItem,
|
||||
ListBoxItemIndicator,
|
||||
SearchField,
|
||||
SearchFieldClearButton,
|
||||
SearchFieldGroup,
|
||||
SearchFieldInput,
|
||||
SearchFieldSearchIcon,
|
||||
@@ -72,10 +73,16 @@ function onRemoveTags(keys: TagKey[]) {
|
||||
</AutocompleteTrigger>
|
||||
<AutocompletePopover>
|
||||
<AutocompleteFilter>
|
||||
<SearchField aria-label="搜索选项">
|
||||
<SearchField
|
||||
auto-focus
|
||||
name="search"
|
||||
variant="secondary"
|
||||
aria-label="搜索选项"
|
||||
>
|
||||
<SearchFieldGroup>
|
||||
<SearchFieldSearchIcon />
|
||||
<SearchFieldInput placeholder="搜索…" />
|
||||
<SearchFieldClearButton />
|
||||
</SearchFieldGroup>
|
||||
</SearchField>
|
||||
<ListBox>
|
||||
@@ -89,7 +96,7 @@ function onRemoveTags(keys: TagKey[]) {
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到结果</EmptyState>
|
||||
<EmptyState>未找到结果</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
|
||||
@@ -73,7 +73,7 @@ const selectedKey = ref<string | null>(null);
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到结果</EmptyState>
|
||||
<EmptyState>未找到结果</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
ListBoxItem,
|
||||
ListBoxItemIndicator,
|
||||
SearchField,
|
||||
SearchFieldClearButton,
|
||||
SearchFieldGroup,
|
||||
SearchFieldInput,
|
||||
SearchFieldSearchIcon,
|
||||
@@ -45,7 +46,8 @@ const message = ref<string | null>(null);
|
||||
function onSubmit(event: Event) {
|
||||
event.preventDefault();
|
||||
const formData = new FormData(event.currentTarget as HTMLFormElement);
|
||||
message.value = `表单提交成功!州:${formData.get("state")},国家:${formData.get("country")}`;
|
||||
void formData;
|
||||
message.value = "表单提交成功!";
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -66,10 +68,16 @@ function onSubmit(event: Event) {
|
||||
</AutocompleteTrigger>
|
||||
<AutocompletePopover>
|
||||
<AutocompleteFilter>
|
||||
<SearchField aria-label="搜索州名">
|
||||
<SearchField
|
||||
auto-focus
|
||||
name="search"
|
||||
variant="secondary"
|
||||
aria-label="搜索州名"
|
||||
>
|
||||
<SearchFieldGroup>
|
||||
<SearchFieldSearchIcon />
|
||||
<SearchFieldInput placeholder="搜索州名…" />
|
||||
<SearchFieldClearButton />
|
||||
</SearchFieldGroup>
|
||||
</SearchField>
|
||||
<ListBox>
|
||||
@@ -83,7 +91,7 @@ function onSubmit(event: Event) {
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到结果</EmptyState>
|
||||
<EmptyState>未找到结果</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
@@ -105,10 +113,16 @@ function onSubmit(event: Event) {
|
||||
</AutocompleteTrigger>
|
||||
<AutocompletePopover>
|
||||
<AutocompleteFilter>
|
||||
<SearchField aria-label="搜索国家">
|
||||
<SearchField
|
||||
auto-focus
|
||||
name="search"
|
||||
variant="secondary"
|
||||
aria-label="搜索国家"
|
||||
>
|
||||
<SearchFieldGroup>
|
||||
<SearchFieldSearchIcon />
|
||||
<SearchFieldInput placeholder="搜索国家…" />
|
||||
<SearchFieldClearButton />
|
||||
</SearchFieldGroup>
|
||||
</SearchField>
|
||||
<ListBox>
|
||||
@@ -122,7 +136,7 @@ function onSubmit(event: Event) {
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到结果</EmptyState>
|
||||
<EmptyState>未找到结果</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
@@ -130,7 +144,7 @@ function onSubmit(event: Event) {
|
||||
<FieldError />
|
||||
</Autocomplete>
|
||||
<Button type="submit">提交</Button>
|
||||
<p v-if="message" role="status" class="text-sm text-success">
|
||||
<p v-if="message" role="status" class="text-sm text-muted">
|
||||
{{ message }}
|
||||
</p>
|
||||
</Form>
|
||||
|
||||
@@ -98,7 +98,7 @@ function onRemoveTags(keys: TagKey[]) {
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到标签</EmptyState>
|
||||
<EmptyState>未找到标签</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
|
||||
@@ -149,7 +149,7 @@ function onRemoveTags(keys: TagKey[]) {
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到结果</EmptyState>
|
||||
<EmptyState>未找到结果</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
|
||||
@@ -137,7 +137,7 @@ const userOf = (key: unknown) => users.find((user) => user.id === key);
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到结果</EmptyState>
|
||||
<EmptyState>未找到结果</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
ListBoxItem,
|
||||
ListBoxItemIndicator,
|
||||
SearchField,
|
||||
SearchFieldClearButton,
|
||||
SearchFieldGroup,
|
||||
SearchFieldInput,
|
||||
SearchFieldSearchIcon,
|
||||
@@ -68,10 +69,16 @@ function onRemoveTags2(keys: TagKey[]) {
|
||||
</AutocompleteTrigger>
|
||||
<AutocompletePopover>
|
||||
<AutocompleteFilter>
|
||||
<SearchField aria-label="搜索选项">
|
||||
<SearchField
|
||||
auto-focus
|
||||
name="search"
|
||||
variant="secondary"
|
||||
aria-label="搜索选项"
|
||||
>
|
||||
<SearchFieldGroup>
|
||||
<SearchFieldSearchIcon />
|
||||
<SearchFieldInput placeholder="搜索…" />
|
||||
<SearchFieldClearButton />
|
||||
</SearchFieldGroup>
|
||||
</SearchField>
|
||||
<ListBox>
|
||||
@@ -85,7 +92,7 @@ function onRemoveTags2(keys: TagKey[]) {
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到结果</EmptyState>
|
||||
<EmptyState>未找到结果</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
@@ -106,10 +113,16 @@ function onRemoveTags2(keys: TagKey[]) {
|
||||
</AutocompleteTrigger>
|
||||
<AutocompletePopover>
|
||||
<AutocompleteFilter>
|
||||
<SearchField aria-label="搜索选项">
|
||||
<SearchField
|
||||
auto-focus
|
||||
name="search"
|
||||
variant="secondary"
|
||||
aria-label="搜索选项"
|
||||
>
|
||||
<SearchFieldGroup>
|
||||
<SearchFieldSearchIcon />
|
||||
<SearchFieldInput placeholder="搜索…" />
|
||||
<SearchFieldClearButton />
|
||||
</SearchFieldGroup>
|
||||
</SearchField>
|
||||
<ListBox>
|
||||
@@ -123,7 +136,7 @@ function onRemoveTags2(keys: TagKey[]) {
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到结果</EmptyState>
|
||||
<EmptyState>未找到结果</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
@@ -169,10 +182,16 @@ function onRemoveTags2(keys: TagKey[]) {
|
||||
</AutocompleteTrigger>
|
||||
<AutocompletePopover>
|
||||
<AutocompleteFilter>
|
||||
<SearchField aria-label="搜索选项">
|
||||
<SearchField
|
||||
auto-focus
|
||||
name="search"
|
||||
variant="secondary"
|
||||
aria-label="搜索选项"
|
||||
>
|
||||
<SearchFieldGroup>
|
||||
<SearchFieldSearchIcon />
|
||||
<SearchFieldInput placeholder="搜索…" />
|
||||
<SearchFieldClearButton />
|
||||
</SearchFieldGroup>
|
||||
</SearchField>
|
||||
<ListBox>
|
||||
@@ -186,7 +205,7 @@ function onRemoveTags2(keys: TagKey[]) {
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到结果</EmptyState>
|
||||
<EmptyState>未找到结果</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
@@ -232,10 +251,16 @@ function onRemoveTags2(keys: TagKey[]) {
|
||||
</AutocompleteTrigger>
|
||||
<AutocompletePopover>
|
||||
<AutocompleteFilter>
|
||||
<SearchField aria-label="搜索选项">
|
||||
<SearchField
|
||||
auto-focus
|
||||
name="search"
|
||||
variant="secondary"
|
||||
aria-label="搜索选项"
|
||||
>
|
||||
<SearchFieldGroup>
|
||||
<SearchFieldSearchIcon />
|
||||
<SearchFieldInput placeholder="搜索…" />
|
||||
<SearchFieldClearButton />
|
||||
</SearchFieldGroup>
|
||||
</SearchField>
|
||||
<ListBox>
|
||||
@@ -249,7 +274,7 @@ function onRemoveTags2(keys: TagKey[]) {
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到结果</EmptyState>
|
||||
<EmptyState>未找到结果</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
|
||||
@@ -166,7 +166,7 @@ const keepResults = () => true;
|
||||
</ListBoxItem>
|
||||
</template>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到结果</EmptyState>
|
||||
<EmptyState>未找到结果</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
ListBoxItem,
|
||||
ListBoxItemIndicator,
|
||||
SearchField,
|
||||
SearchFieldClearButton,
|
||||
SearchFieldGroup,
|
||||
SearchFieldInput,
|
||||
SearchFieldSearchIcon,
|
||||
@@ -47,10 +48,16 @@ const selectedKey = ref<string | null>(null);
|
||||
</AutocompleteTrigger>
|
||||
<AutocompletePopover>
|
||||
<AutocompleteFilter>
|
||||
<SearchField aria-label="搜索州名">
|
||||
<SearchField
|
||||
auto-focus
|
||||
name="search"
|
||||
variant="secondary"
|
||||
aria-label="搜索州名"
|
||||
>
|
||||
<SearchFieldGroup>
|
||||
<SearchFieldSearchIcon />
|
||||
<SearchFieldInput placeholder="搜索州名…" />
|
||||
<SearchFieldClearButton />
|
||||
</SearchFieldGroup>
|
||||
</SearchField>
|
||||
<ListBox>
|
||||
@@ -64,7 +71,7 @@ const selectedKey = ref<string | null>(null);
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到结果</EmptyState>
|
||||
<EmptyState>未找到结果</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
ListBoxItem,
|
||||
ListBoxItemIndicator,
|
||||
SearchField,
|
||||
SearchFieldClearButton,
|
||||
SearchFieldGroup,
|
||||
SearchFieldInput,
|
||||
SearchFieldSearchIcon,
|
||||
@@ -47,10 +48,16 @@ const selectedKey = ref<string | null>(null);
|
||||
</AutocompleteTrigger>
|
||||
<AutocompletePopover>
|
||||
<AutocompleteFilter>
|
||||
<SearchField aria-label="搜索动物">
|
||||
<SearchField
|
||||
auto-focus
|
||||
name="search"
|
||||
variant="secondary"
|
||||
aria-label="搜索动物"
|
||||
>
|
||||
<SearchFieldGroup>
|
||||
<SearchFieldSearchIcon />
|
||||
<SearchFieldInput placeholder="搜索动物…" />
|
||||
<SearchFieldClearButton />
|
||||
</SearchFieldGroup>
|
||||
</SearchField>
|
||||
<ListBox>
|
||||
@@ -64,7 +71,7 @@ const selectedKey = ref<string | null>(null);
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到结果</EmptyState>
|
||||
<EmptyState>未找到结果</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
ListBoxItemIndicator,
|
||||
ListBoxSection,
|
||||
SearchField,
|
||||
SearchFieldClearButton,
|
||||
SearchFieldGroup,
|
||||
SearchFieldInput,
|
||||
SearchFieldSearchIcon,
|
||||
@@ -40,10 +41,16 @@ const selectedKey = ref<string | null>(null);
|
||||
</AutocompleteTrigger>
|
||||
<AutocompletePopover>
|
||||
<AutocompleteFilter>
|
||||
<SearchField aria-label="搜索国家">
|
||||
<SearchField
|
||||
auto-focus
|
||||
name="search"
|
||||
variant="secondary"
|
||||
aria-label="搜索国家"
|
||||
>
|
||||
<SearchFieldGroup>
|
||||
<SearchFieldSearchIcon />
|
||||
<SearchFieldInput placeholder="搜索国家…" />
|
||||
<SearchFieldClearButton />
|
||||
</SearchFieldGroup>
|
||||
</SearchField>
|
||||
<ListBox>
|
||||
@@ -107,7 +114,7 @@ const selectedKey = ref<string | null>(null);
|
||||
</ListBoxItem>
|
||||
</ListBoxSection>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">未找到结果</EmptyState>
|
||||
<EmptyState>未找到结果</EmptyState>
|
||||
</template>
|
||||
</ListBox>
|
||||
</AutocompleteFilter>
|
||||
|
||||
@@ -25,18 +25,18 @@ const PAGE_SIZE = 4;
|
||||
const PAGE_DELAY = 300;
|
||||
|
||||
const characters: Character[] = [
|
||||
{ id: "luke-skywalker", name: "卢克·天行者" },
|
||||
{ id: "princess-leia", name: "莱娅公主" },
|
||||
{ id: "han-solo", name: "汉·索罗" },
|
||||
{ id: "darth-vader", name: "达斯·维达" },
|
||||
{ id: "yoda", name: "尤达" },
|
||||
{ id: "obi-wan-kenobi", name: "欧比旺·克诺比" },
|
||||
{ id: "palpatine", name: "帕尔帕廷" },
|
||||
{ id: "lando-calrissian", name: "兰多·卡瑞辛" },
|
||||
{ id: "chewbacca", name: "楚巴卡" },
|
||||
{ id: "r2-d2", name: "R2-D2" },
|
||||
{ id: "c-3po", name: "C-3PO" },
|
||||
{ id: "boba-fett", name: "波巴·费特" },
|
||||
{ id: "Luke Skywalker", name: "Luke Skywalker" },
|
||||
{ id: "Princess Leia", name: "Princess Leia" },
|
||||
{ id: "Han Solo", name: "Han Solo" },
|
||||
{ id: "Darth Vader", name: "Darth Vader" },
|
||||
{ id: "Yoda", name: "Yoda" },
|
||||
{ id: "Obi-Wan Kenobi", name: "Obi-Wan Kenobi" },
|
||||
{ id: "Palpatine", name: "Palpatine" },
|
||||
{ id: "Lando Calrissian", name: "Lando Calrissian" },
|
||||
{ id: "Chewbacca", name: "Chewbacca" },
|
||||
{ id: "R2-D2", name: "R2-D2" },
|
||||
{ id: "C-3PO", name: "C-3PO" },
|
||||
{ id: "Boba Fett", name: "Boba Fett" },
|
||||
];
|
||||
|
||||
const inputValue = ref("");
|
||||
@@ -139,9 +139,7 @@ onBeforeUnmount(() => {
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
<template #empty>
|
||||
<EmptyState class="p-1">
|
||||
{{ loading ? "正在加载…" : "没有找到角色" }}
|
||||
</EmptyState>
|
||||
<EmptyState />
|
||||
</template>
|
||||
</ListBox>
|
||||
<div v-if="hasMore" class="flex items-center justify-center gap-2 py-2">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import {
|
||||
Button,
|
||||
ComboBox,
|
||||
@@ -35,8 +36,10 @@ function validate(value: string | number | (string | number)[] | null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const message = ref("");
|
||||
|
||||
function onSubmit() {
|
||||
alert("表单提交成功!");
|
||||
message.value = "表单提交成功!";
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -64,5 +67,6 @@ function onSubmit() {
|
||||
<FieldError />
|
||||
</ComboBox>
|
||||
<Button class="w-fit" type="submit">提交</Button>
|
||||
<p v-if="message" class="text-sm text-muted" role="status">{{ message }}</p>
|
||||
</Form>
|
||||
</template>
|
||||
|
||||
@@ -81,6 +81,6 @@ function onSubmit(event: Event) {
|
||||
<FieldError />
|
||||
</ComboBox>
|
||||
<Button class="w-fit" type="submit">提交</Button>
|
||||
<p v-if="message" class="text-sm text-muted">{{ message }}</p>
|
||||
<p v-if="message" class="text-sm text-muted" role="status">{{ message }}</p>
|
||||
</Form>
|
||||
</template>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import {
|
||||
Button,
|
||||
ComboBox,
|
||||
@@ -15,9 +16,11 @@ import {
|
||||
Surface,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
const message = ref("");
|
||||
|
||||
function onSubmit(event: Event) {
|
||||
event.preventDefault();
|
||||
alert("表单提交成功!");
|
||||
message.value = "表单提交成功!";
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -61,6 +64,9 @@ function onSubmit(event: Event) {
|
||||
<FieldError />
|
||||
</ComboBox>
|
||||
<Button type="submit">提交</Button>
|
||||
<p v-if="message" class="text-sm text-muted" role="status">
|
||||
{{ message }}
|
||||
</p>
|
||||
</Form>
|
||||
</Surface>
|
||||
</template>
|
||||
|
||||
@@ -18,14 +18,9 @@ import {
|
||||
const submitted = ref(false);
|
||||
|
||||
function submit(event: Event) {
|
||||
const formData = new FormData(event.currentTarget as HTMLFormElement);
|
||||
const data: Record<string, string> = {};
|
||||
|
||||
formData.forEach((value, key) => {
|
||||
data[key] = value.toString();
|
||||
});
|
||||
|
||||
submitted.value = "animal" in data;
|
||||
// The Form guard already blocks invalid submits, so a reached handler is valid.
|
||||
void new FormData(event.currentTarget as HTMLFormElement);
|
||||
submitted.value = true;
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -68,7 +63,7 @@ function submit(event: Event) {
|
||||
<FieldError />
|
||||
</ComboBox>
|
||||
<Button type="submit">提交</Button>
|
||||
<p v-if="submitted" role="status" class="text-sm text-success">
|
||||
<p v-if="submitted" role="status" class="text-sm text-muted">
|
||||
表单提交成功!
|
||||
</p>
|
||||
</Form>
|
||||
|
||||
@@ -70,7 +70,9 @@ function submitAria(event: Event) {
|
||||
<FieldError />
|
||||
</ComboBox>
|
||||
<Button class="w-fit" type="submit">提交</Button>
|
||||
<p v-if="nativeMessage" class="text-sm text-muted">{{ nativeMessage }}</p>
|
||||
<p v-if="nativeMessage" class="text-sm text-muted" role="status">
|
||||
{{ nativeMessage }}
|
||||
</p>
|
||||
</Form>
|
||||
<Form class="flex w-[256px] flex-col gap-4" @submit="submitAria">
|
||||
<ComboBox
|
||||
@@ -101,7 +103,9 @@ function submitAria(event: Event) {
|
||||
<FieldError />
|
||||
</ComboBox>
|
||||
<Button class="w-fit" type="submit">提交</Button>
|
||||
<p v-if="ariaMessage" class="text-sm text-muted">{{ ariaMessage }}</p>
|
||||
<p v-if="ariaMessage" class="text-sm text-muted" role="status">
|
||||
{{ ariaMessage }}
|
||||
</p>
|
||||
</Form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user