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
+71 -18
View File
@@ -51,7 +51,12 @@ import {
## 示例
### 尺寸变体
### 变体
InputOTP 组件支持两种视觉变体:
- **`primary`**(默认)- 标准样式带阴影,适用于大多数场景
- **`secondary`** - 低强调变体无阴影,适用于 Surface 组件内
<ComponentPreview name="input-otp-variants" />
@@ -103,23 +108,70 @@ import {
`inputClassName` 落在真实 `<input>` 上;视觉槽位用 `class` 落在 `InputOTPSlot` 根节点。二者不会合并到同一节点。
### 全局 CSS
可使用 `@layer components` 指令自定义 InputOTP 组件类;下面的类与状态选择器都来自当前样式表:
```css
@layer components {
.hv-input-otp {
@apply gap-3;
}
.hv-input-otp__slot {
@apply rounded-lg border-accent;
@apply size-12 rounded-xl border-2 font-bold;
}
.hv-input-otp__slot[data-active="true"] {
@apply border-accent ring-2 ring-accent/30;
}
.hv-input-otp__separator {
@apply h-1 w-2 rounded-full bg-border-strong;
}
}
```
## 样式参考
类名前缀为 `hv-`。
HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。类名前缀为 `hv-`。
- `.hv-input-otp` / `.hv-input-otp--primary` / `.hv-input-otp--secondary`
- `.hv-input-otp__group` / `.hv-input-otp__slot` / `.hv-input-otp__slot-value`
- `.hv-input-otp__caret` / `.hv-input-otp__separator` / `.hv-input-otp__input`
### CSS 类
状态:`data-active`、`data-filled`、`data-disabled`、`data-invalid`、`data-complete`。
InputOTP 组件使用以下 CSS 类([查看源码样式](https://github.com/heroui-inc/heroui/blob/v3/packages/styles/components/input-otp.css)):
#### 基础类 [!toc]
- `.hv-input-otp` - 基础容器
- `.hv-input-otp__group` - slot 组
- `.hv-input-otp__slot` - 单个输入 slot
- `.hv-input-otp__slot-value` - slot 内的字符
- `.hv-input-otp__caret` - 闪烁光标指示器
- `.hv-input-otp__separator` - 组之间的视觉分隔符
- `.hv-input-otp__input` - 真实 `<input>` 的透明覆盖层(Reka PinInput 多 input 底座的适配类,替代上游 `input-otp` 库的 `__container`)
#### 变体类 [!toc]
- `.hv-input-otp--primary` - 标准变体(默认)
- `.hv-input-otp--secondary` - 低强调变体
#### 状态类 [!toc]
- `.hv-input-otp__slot[data-active="true"]` - 当前激活的 slot
- `.hv-input-otp__slot[data-filled="true"]` - 含字符的 slot
- `.hv-input-otp__slot[data-disabled="true"]` - 禁用的 slot
- `.hv-input-otp__slot[data-invalid="true"]` - 无效的 slot
- `.hv-input-otp[data-disabled="true"]` / `[data-invalid="true"]` - 根容器的禁用与错误标记
### 交互状态
组件同时支持 CSS 伪类与 data 属性:
- **Hover**:slot 上 `:hover` 或 `[data-hovered="true"]`
- **Active**:slot 上 `[data-active="true"]`(当前聚焦)
- **Filled**:slot 上 `[data-filled="true"]`(含字符)
- **Disabled**:根与 slot 上 `[data-disabled="true"]`
- **Invalid**:根与 slot 上 `[data-invalid="true"]`(slot 另输出 `[data-readonly]`)
## API 参考
@@ -161,14 +213,17 @@ import {
### 上游差异
| 上游 React 能力 | Vue 实现 |
| ----------------------------- | ------------------------------------------ |
| `input-otp` 单隐藏 input | Reka PinInput 多 input + 隐藏提交 input |
| `value` / `onChange` 字符串 | `v-model` / `update:modelValue` / `change` |
| `onComplete` 跨过长度阈值 | `complete` 仅在首次填满触发 |
| `pattern` 整串校验 | 单字符过滤(同样接受导出常量) |
| `render` / `OTPInputContext` | 具名插槽部件;槽位状态经上下文 |
| `pushPasswordManagerStrategy` | 未提供;`otp` 覆盖 one-time-code 自动填充 |
| 上游 React 能力 | Vue 实现 |
| ------------------------------------ | ------------------------------------------------------------------------------------- |
| `input-otp` 单隐藏 input | Reka PinInput 多 input + 隐藏提交 input |
| `value` / `onChange` 字符串 | `v-model` / `update:modelValue` / `change` |
| `onComplete` 跨过长度阈值 | `complete` 仅在首次填满触发 |
| `pattern` 整串校验 | 单字符过滤(同样接受导出常量) |
| `render` / `OTPInputContext` | 具名插槽部件;槽位状态经上下文 |
| `pushPasswordManagerStrategy` | 未提供;`otp` 覆盖 one-time-code 自动填充 |
| `validationDetails`(ValidityState) | 未提供;校验结果为 `string \| string[]` 文本 |
| `textAlign` / `pasteTransformer` | 未提供(能力缺口,见 HD 队列后续能力卡) |
| `autoFocus` / `containerClassName` | 未提供专门 prop;`containerClassName` 被上游公共类型显式 Omit,`autoFocus` 属能力缺口 |
## 字段与表单
@@ -187,6 +242,4 @@ Slot 的 keydown/paste 用户处理器在底座编辑前的 capture 边界协调
## 相关组件
- [TextField 文本输入框](./text-field)
- [Label 标签](./label)
- [FieldError 字段错误](./field-error)
[Input 输入框](./input) · [Form 表单](./form) · [Surface 表面](./surface)