af6bfda3ee
Port the fixed HeroUI baseline tag/tag-group/error-message components onto the existing collection selection/registry protocols instead of a second state model. - TagGroup owns selection, disabled scope, removal requests and name/description wiring; TagGroupList renders the role=grid node and Tag renders role=row. - Removal has one path: a press inside the remove subtree is a removal request, so custom remove buttons work without a second event source; focus follows the next neighbour only after the item is actually gone. - ErrorMessage keeps the baseline slot marker and reuses the field part ids without gaining validation or aria-invalid semantics. - Ship the 12 tag-group and 2 error-message previews, both doc pages, navigation, a 35-case behavioural suite and independent tarball consumption checks.
30 lines
760 B
Vue
30 lines
760 B
Vue
<script setup lang="ts">
|
|
import { computed, ref } from "vue";
|
|
import {
|
|
Description,
|
|
ErrorMessage,
|
|
Label,
|
|
Tag,
|
|
TagGroup,
|
|
TagGroupList,
|
|
type TagKey,
|
|
} from "@heroui-vue/components";
|
|
|
|
const selected = ref<TagKey[]>([]);
|
|
const isInvalid = computed(() => selected.value.length === 0);
|
|
</script>
|
|
|
|
<template>
|
|
<TagGroup v-model="selected" selection-mode="multiple">
|
|
<Label>必选分类</Label>
|
|
<TagGroupList>
|
|
<Tag id="news">新闻</Tag>
|
|
<Tag id="travel">旅游</Tag>
|
|
<Tag id="gaming">游戏</Tag>
|
|
<Tag id="shopping">购物</Tag>
|
|
</TagGroupList>
|
|
<Description>请至少选择一个分类</Description>
|
|
<ErrorMessage>{{ isInvalid ? "请至少选择一个分类" : "" }}</ErrorMessage>
|
|
</TagGroup>
|
|
</template>
|