fix: preserve nested search names and add browser consumption fixture
This commit is contained in:
@@ -0,0 +1,165 @@
|
||||
import { createApp, defineComponent, h } from "vue";
|
||||
import {
|
||||
Autocomplete,
|
||||
AutocompleteTrigger,
|
||||
AutocompleteValue,
|
||||
AutocompleteClearButton,
|
||||
AutocompleteIndicator,
|
||||
AutocompletePopover,
|
||||
AutocompleteFilter,
|
||||
SearchField,
|
||||
SearchFieldInput,
|
||||
ComboBox,
|
||||
ComboBoxInputGroup,
|
||||
ComboBoxTrigger,
|
||||
ComboBoxPopover,
|
||||
Input,
|
||||
ListBox,
|
||||
ListBoxItem,
|
||||
Button,
|
||||
Modal,
|
||||
ModalBackdrop,
|
||||
ModalContainer,
|
||||
ModalDialog,
|
||||
ModalHeading,
|
||||
} from "@heroui-vue/components";
|
||||
import "@heroui-vue/styles/css";
|
||||
import "./style.css";
|
||||
const animals = [
|
||||
{ id: "cat", textValue: "猫" },
|
||||
{ id: "dog", textValue: "狗" },
|
||||
{ id: "bird", textValue: "鸟" },
|
||||
];
|
||||
const states = [
|
||||
{ id: "california", textValue: "California" },
|
||||
{ id: "texas", textValue: "Texas" },
|
||||
{ id: "florida", textValue: "Florida" },
|
||||
];
|
||||
const rows = (items) =>
|
||||
h(
|
||||
ListBox,
|
||||
{ items },
|
||||
{
|
||||
default: ({ item }) =>
|
||||
h(
|
||||
ListBoxItem,
|
||||
{ id: item.id, textValue: item.textValue, key: item.id },
|
||||
() => item.textValue,
|
||||
),
|
||||
},
|
||||
);
|
||||
function combo(label, long = false) {
|
||||
const items = long
|
||||
? Array.from({ length: 100 }, (_, i) => ({ id: i, textValue: `Row ${i}` }))
|
||||
: animals;
|
||||
return h(
|
||||
ComboBox,
|
||||
{ "aria-label": label, items, style: { width: "280px" } },
|
||||
{
|
||||
default: () => [
|
||||
h(ComboBoxInputGroup, null, {
|
||||
default: () => [h(Input, { placeholder: label }), h(ComboBoxTrigger)],
|
||||
}),
|
||||
h(
|
||||
ComboBoxPopover,
|
||||
{ style: { maxHeight: "180px", overflowY: "auto" } },
|
||||
{ default: () => rows(items) },
|
||||
),
|
||||
],
|
||||
},
|
||||
);
|
||||
}
|
||||
function autocomplete() {
|
||||
return h(
|
||||
Autocomplete,
|
||||
{
|
||||
"aria-label": "独立 Autocomplete",
|
||||
name: "state",
|
||||
items: states,
|
||||
defaultValue: "california",
|
||||
style: { width: "280px" },
|
||||
},
|
||||
{
|
||||
default: () => [
|
||||
h(AutocompleteTrigger, null, {
|
||||
default: () => [
|
||||
h(AutocompleteValue),
|
||||
h(AutocompleteClearButton),
|
||||
h(AutocompleteIndicator),
|
||||
],
|
||||
}),
|
||||
h(AutocompletePopover, null, {
|
||||
default: () =>
|
||||
h(AutocompleteFilter, null, {
|
||||
default: () => [
|
||||
h(
|
||||
SearchField,
|
||||
{ "aria-label": "独立搜索" },
|
||||
{
|
||||
default: () =>
|
||||
h(SearchFieldInput, { placeholder: "搜索州" }),
|
||||
},
|
||||
),
|
||||
rows(states),
|
||||
],
|
||||
}),
|
||||
}),
|
||||
],
|
||||
},
|
||||
);
|
||||
}
|
||||
createApp(
|
||||
defineComponent({
|
||||
setup() {
|
||||
return () =>
|
||||
h("main", [
|
||||
h("h1", "B02 独立产物验收"),
|
||||
h(
|
||||
"p",
|
||||
"Vue 组件和 CSS 来自两份最终 tarball;没有指向工作区源码的 alias。",
|
||||
),
|
||||
h("section", [
|
||||
h("h2", "ComboBox:点击、选择、关闭和焦点"),
|
||||
combo("独立 ComboBox"),
|
||||
]),
|
||||
h("section", [
|
||||
h("h2", "Autocomplete:搜索、单选和清空"),
|
||||
autocomplete(),
|
||||
]),
|
||||
h("section", [
|
||||
h("h2", "长列表:End 后活动项应可见"),
|
||||
combo("长列表", true),
|
||||
]),
|
||||
h(Modal, null, {
|
||||
default: () => [
|
||||
h(Button, null, () => "打开嵌套验收"),
|
||||
h(ModalBackdrop, null, {
|
||||
default: () =>
|
||||
h(ModalContainer, null, {
|
||||
default: () =>
|
||||
h(
|
||||
ModalDialog,
|
||||
{
|
||||
"aria-label": "嵌套选择验收",
|
||||
style: { width: "400px" },
|
||||
},
|
||||
{
|
||||
default: () => [
|
||||
h(ModalHeading, null, () => "嵌套选择验收"),
|
||||
combo("模态框内 ComboBox"),
|
||||
h(
|
||||
"p",
|
||||
"第一次 Escape 关闭列表,第二次关闭模态框。",
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
}),
|
||||
}),
|
||||
],
|
||||
}),
|
||||
h("button", { type: "button", id: "outside" }, "外部焦点目标"),
|
||||
]);
|
||||
},
|
||||
}),
|
||||
).mount("#app");
|
||||
Reference in New Issue
Block a user