docs: close documentation facts, structure and related-component mapping

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
This commit is contained in:
maoyingjie
2026-10-28 22:32:10 +08:00
parent 2c6d871354
commit 145a208687
76 changed files with 912 additions and 352 deletions
+76 -18
View File
@@ -37,7 +37,7 @@ import {
</template>
```
<ComponentPreview name="accordion-basic" />
<ComponentPreview name="accordion-basic" minHeight="400px" />
## 组件结构
@@ -76,37 +76,37 @@ Accordion 复用 DisclosureGroup 的展开键协议(数组、字符串/数字
### 表面样式
<ComponentPreview name="accordion-surface" />
<ComponentPreview name="accordion-surface" minHeight="400px" />
### 无分隔线
<ComponentPreview name="accordion-without-separator" />
<ComponentPreview name="accordion-without-separator" minHeight="400px" />
### 多项展开
<ComponentPreview name="accordion-multiple" />
<ComponentPreview name="accordion-multiple" minHeight="524px" />
### 禁用状态
<ComponentPreview name="accordion-disabled" />
<ComponentPreview name="accordion-disabled" minHeight="524px" />
### 受控组件
<ComponentPreview name="accordion-controlled" />
<ComponentPreview name="accordion-controlled" minHeight="400px" />
### 自定义指示器
<ComponentPreview name="accordion-custom-indicator" />
<ComponentPreview name="accordion-custom-indicator" minHeight="320px" />
### 渲染函数
上游 `render` 映射为 `as` 与透传属性。
<ComponentPreview name="accordion-render-function" />
<ComponentPreview name="accordion-render-function" minHeight="400px" />
### 常见问题布局
<ComponentPreview name="accordion-faq" />
<ComponentPreview name="accordion-faq" minHeight="720px" />
## 自定义样式
@@ -130,11 +130,40 @@ Accordion 复用 DisclosureGroup 的展开键协议(数组、字符串/数字
## 样式参考
- `.hv-accordion` - 根容器
- `.hv-accordion__item` - 单项与分隔线
- `.hv-accordion__heading` / `.hv-accordion__trigger` / `.hv-accordion__indicator`
- `.hv-accordion__panel` / `.hv-accordion__body` / `.hv-accordion__body-inner`
- `.hv-accordion--surface` - 表面变体
HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。类名前缀为 `hv-`。
### CSS 类
Accordion 组件使用以下 CSS 类([查看源码样式](https://github.com/heroui-inc/heroui/blob/v3/packages/styles/components/accordion.css)):
#### 基础类 [!toc]
- `.hv-accordion` - Accordion 根容器
- `.hv-accordion__item` - 单个 Accordion 项(含分隔线)
- `.hv-accordion__heading` - 标题包裹层
- `.hv-accordion__trigger` - 可点击的触发按钮
- `.hv-accordion__indicator` - 展开/收起指示图标
- `.hv-accordion__panel` - 可折叠面板容器(高度动画宿主)
- `.hv-accordion__body` / `.hv-accordion__body-inner` - 正文外层与内层包裹
#### 变体类 [!toc]
- `.hv-accordion--surface` - 表面变体(边框、背景与分隔线收口)
#### 状态类 [!toc]
- `.hv-accordion__trigger[aria-expanded="true"]` - 展开状态
- `.hv-accordion__trigger[aria-disabled="true"]` - 禁用状态
- `.hv-accordion__panel[data-expanded="true"]` / `.hv-accordion__indicator[data-expanded="true"]` - 面板与指示器的展开标记
### 交互状态
触发器以 CSS 伪类为主(组件不输出 `data-hovered` / `data-focus-visible` 标记,可通过 attrs 传入这些标记作为自定义样式钩子):
- **悬停**:触发器上 `:hover`(仅未展开时上色)
- **聚焦**:触发器上 `:focus-visible`(显示焦点环)
- **禁用**:触发器上 `:disabled` 或 `[aria-disabled="true"]`(同时输出 `[data-disabled="true"]` 标记)
- **展开**:触发器上 `[aria-expanded="true"]`
## API 参考
@@ -161,11 +190,40 @@ Accordion 复用 DisclosureGroup 的展开键协议(数组、字符串/数字
| `isDisabled` | `boolean` | `false` | 禁用该项 |
| `as` | `string` | `"div"` | 项根元素 |
### AccordionHeading / Trigger / Panel / Body / Indicator
### AccordionHeading
与 Disclosure 对应部件语义一致,使用 `hv-accordion__*` 样式;Trigger 为 `type="button"`,Panel 负责高度动画,Indicator 支持自定义图标插槽。
| 属性 | 类型 | 默认值 | 描述 |
| -------- | --------------------------- | ------ | -------------- |
| `as` | `string` | `'h3'` | 标题根元素标签 |
| `level` | `number` | `3` | 语义标题级别 |
| `class` | `string \| Array \| Object` | - | 额外的 CSS 类 |
| 默认插槽 | - | - | 标题内容 |
### AccordionTrigger
| 属性 | 类型 | 默认值 | 描述 |
| -------------- | --------------------------- | ---------- | ------------------------------------------------ |
| `as` | `string` | `'button'` | 触发器根元素;为 `button` 时输出 `type="button"` |
| `asChild` | `boolean` | `false` | 将展开切换与状态合并到默认插槽中唯一的根元素 |
| `class` | `string \| Array \| Object` | - | 额外的 CSS 类 |
| 默认作用域插槽 | - | - | 提供 `isExpanded`、`isDisabled` |
### AccordionPanel / AccordionBody
| 属性 | 类型 | 默认值 | 描述 |
| -------- | --------------------------- | ------- | ---------------------------------------------------------- |
| `as` | `string` | `'div'` | 根元素;Panel 负责高度动画,Body 的 `class` 落在内层包裹上 |
| `class` | `string \| Array \| Object` | - | 额外的 CSS 类 |
| 默认插槽 | - | - | 面板 / 正文内容 |
### AccordionIndicator
| 属性 | 类型 | 默认值 | 描述 |
| -------------- | ---- | ------ | ------------------------------------------------------------------ |
| 默认作用域插槽 | - | - | 自定义指示图标;提供 `isExpanded`。缺省时渲染基线 ChevronDown 图标 |
与 Disclosure 对应部件语义一致,使用 `hv-accordion__*` 样式。
## 相关组件
- [Disclosure 折叠面板](./disclosure)
- [DisclosureGroup 折叠面板组](./disclosure-group)
[DisclosureGroup 折叠面板组](./disclosure-group) · [Disclosure 折叠面板](./disclosure)