145a208687
HD-04 scope, against heroui ce90ea3 cn sources: - stale/fictional content: input.md no longer claims TextField is unmigrated; color-field.md no longer claims ColorPicker is private; header.md drops the fictional Header.Root subcomponent and the stale 'menus not migrated' wording (MenuSection label registration is now documented from HeaderRoot source); radio-group.md drops three copied CheckboxGroup wordings (variant override is Radio's, scalar emits, native single-value submit); input-otp.md drops the fictional data-complete state and lists the real missing upstream props - toggle-button disabled row now matches the real CSS hooks (:disabled / [aria-disabled], with data-disabled as a marker only) - part API / CSS classes / interactive states restored per pinned sources: button (full class lists + real variable-based global CSS), accordion (per-part tables + variant/state lists), card (per-part tables + variant list), switch (SwitchGroup snippet + Switch/ SwitchGroup class lists + states), color-field Group (class list + states), input-otp (variant notes, global CSS, class/state lists); input-group gains the two upstream usage chapters - RelatedComponents restored from the pinned componentRelationships (first-3, filtered against componentsMap): 64 pages rewritten, list-box/slider sections added, 7 empty-mapping pages' fabricated entries removed; RelatedShowcases left unmigrated with its real data inventory recorded (2 cases, showcase-site cards) - defaults unified on implementation evidence: granularity (inferred day/minute) and visibleYears (full min-max span, no "or 20" fallback); HD-03 hand-offs resolved (trigger focus-visible noted for HD-06, width guards kept) - new demos: header-collection-grouping (MenuSection/ListBoxSection label wiring), empty-state-collection (collection empty slot); empty-state page deduplicated with a boundary compatibility note - ComponentPreview minHeight/isBgSolid restored per the 30 upstream marks; tabs-overflow max-w-full kept after measuring internal scroll - tests: +3 header registration/demo cases, +1 empty-state collection case; full suite 110 files / 1630 tests, typecheck and build:docs pass
115 lines
3.8 KiB
Markdown
115 lines
3.8 KiB
Markdown
---
|
||
title: DisclosureGroup 折叠面板组
|
||
description: 管理多个 Disclosure 项展开状态的容器
|
||
component: disclosure-group
|
||
group: 组件
|
||
---
|
||
|
||
## 用法
|
||
|
||
```vue
|
||
<script setup lang="ts">
|
||
import {
|
||
Disclosure,
|
||
DisclosureGroup,
|
||
DisclosureContent,
|
||
DisclosureHeading,
|
||
DisclosureTrigger,
|
||
} from "@heroui-vue/components";
|
||
</script>
|
||
|
||
<template>
|
||
<DisclosureGroup>
|
||
<Disclosure id="item1">
|
||
<DisclosureHeading>
|
||
<DisclosureTrigger>
|
||
标题
|
||
<span>▼</span>
|
||
</DisclosureTrigger>
|
||
</DisclosureHeading>
|
||
<DisclosureContent>内容</DisclosureContent>
|
||
</Disclosure>
|
||
</DisclosureGroup>
|
||
</template>
|
||
```
|
||
|
||
<ComponentPreview name="disclosure-group-basic" minHeight="580px" />
|
||
|
||
## 组件结构
|
||
|
||
```vue
|
||
<script setup lang="ts">
|
||
import { Disclosure, DisclosureGroup } from "@heroui-vue/components";
|
||
</script>
|
||
|
||
<template>
|
||
<DisclosureGroup>
|
||
<Disclosure id="item1">…</Disclosure>
|
||
</DisclosureGroup>
|
||
</template>
|
||
```
|
||
|
||
`DisclosureGroup` 用数组管理展开键(空集合为 `[]`),支持字符串或数字 key(`1` 与 `"1"` 不会碰撞)。
|
||
|
||
## 示例
|
||
|
||
### 受控组件
|
||
|
||
可使用 `expandedKeys` 与 `update:expandedKeys` 配合 `useDisclosureGroupNavigation` 外部导航。
|
||
|
||
<ComponentPreview name="disclosure-group-controlled" minHeight="580px" />
|
||
|
||
`useDisclosureGroupNavigation` 为公开 composable:提供 `currentIndex`、`isPrevDisabled`、`isNextDisabled`、`onPrevious`、`onNext`。单选替换集合,多选增量添加;不修改传入集合。
|
||
|
||
## 自定义样式
|
||
|
||
### Tailwind CSS
|
||
|
||
<ComponentPreview name="disclosure-group-custom-styles" />
|
||
|
||
### 全局 CSS
|
||
|
||
```css
|
||
@layer components {
|
||
.hv-disclosure-group {
|
||
@apply w-full;
|
||
contain: layout style;
|
||
}
|
||
}
|
||
```
|
||
|
||
## 样式参考
|
||
|
||
- `.hv-disclosure-group` - 基础容器样式,含布局 containment
|
||
|
||
## API 参考
|
||
|
||
### DisclosureGroup
|
||
|
||
| 属性 | 类型 | 默认值 | 描述 |
|
||
| ------------------------ | ------------------------------ | ------- | ------------------------------------- |
|
||
| `expandedKeys` | `Array<string \| number>` | - | 受控展开项(`v-model:expanded-keys`) |
|
||
| `defaultExpandedKeys` | `Array<string \| number>` | `[]` | 初始展开项 |
|
||
| `allowsMultipleExpanded` | `boolean` | `false` | 是否允许多项同时展开 |
|
||
| `isDisabled` | `boolean` | `false` | 禁用组内所有 Disclosure |
|
||
| `as` | `string` | `"div"` | 根元素 |
|
||
| `class` | `string \| Array \| Object` | - | 合并到根元素 |
|
||
| 默认插槽 | `{ expandedKeys, isDisabled }` | - | Disclosure 项 |
|
||
|
||
事件:`update:expandedKeys`、`expandedChange`。
|
||
|
||
### useDisclosureGroupNavigation
|
||
|
||
| 属性 | 类型 | 默认值 | 描述 |
|
||
| ------------------------ | ----------------------------------------- | ------- | ------------- |
|
||
| `expandedKeys` | `Array<string \| number>` 或 getter | - | 当前展开键 |
|
||
| `itemIds` | `Array<string \| number>` 或 getter | `[]` | 成员 key 列表 |
|
||
| `onExpandedChange` | `(keys: Array<string \| number>) => void` | - | 提交新集合 |
|
||
| `allowsMultipleExpanded` | `boolean` | `false` | 多选增量 |
|
||
|
||
返回:`currentIndex`、`isPrevDisabled`、`isNextDisabled`、`onPrevious`、`onNext`。
|
||
|
||
## 相关组件
|
||
|
||
[Accordion 手风琴](./accordion) · [Disclosure 折叠面板](./disclosure) · [Button 按钮](./button)
|