feat: migrate ListBox with virtual collection and accessible parts
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Avatar,
|
||||
AvatarImage,
|
||||
AvatarFallback,
|
||||
Description,
|
||||
Label,
|
||||
ListBox,
|
||||
ListBoxItem,
|
||||
ListBoxItemIndicator,
|
||||
Surface,
|
||||
} from "@heroui-vue/components";
|
||||
const users = [
|
||||
{
|
||||
id: "1",
|
||||
name: "Bob",
|
||||
email: "bob@heroui.com",
|
||||
src: "https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/blue.jpg",
|
||||
},
|
||||
{
|
||||
id: "2",
|
||||
name: "Fred",
|
||||
email: "fred@heroui.com",
|
||||
src: "https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/green.jpg",
|
||||
},
|
||||
{
|
||||
id: "3",
|
||||
name: "Martha",
|
||||
email: "martha@heroui.com",
|
||||
src: "https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/purple.jpg",
|
||||
},
|
||||
];
|
||||
</script>
|
||||
<template>
|
||||
<Surface class="w-[256px] rounded-3xl shadow-surface">
|
||||
<ListBox
|
||||
:items="users"
|
||||
v-slot="{ item: user }"
|
||||
aria-label="用户"
|
||||
selection-mode="multiple"
|
||||
>
|
||||
<ListBoxItem :id="user.id" :text-value="user.name">
|
||||
<Avatar size="sm">
|
||||
<AvatarImage :alt="user.name" :src="user.src" />
|
||||
<AvatarFallback>{{ user.name[0] }}</AvatarFallback>
|
||||
</Avatar>
|
||||
<div class="flex flex-col">
|
||||
<Label>{{ user.name }}</Label>
|
||||
<Description>{{ user.email }}</Description>
|
||||
</div>
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
</ListBox>
|
||||
</Surface>
|
||||
</template>
|
||||
Reference in New Issue
Block a user