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
+53 -51
View File
@@ -174,22 +174,22 @@ ColorSwatchPicker 组件使用以下 CSS 类([查看源码样式](https://gith
对应固定源的 [React Aria ColorSwatchPicker](https://react-spectrum.adobe.com/react-aria/ColorSwatchPicker.html)(`listbox` / `option` 语义,单项选择且不允许清空)。
| Prop | 类型 | 默认值 | 描述 |
| ------------ | ------------------------------------------ | ---------- | ------------------------------------------------------------------------ |
| `modelValue` | `string \| Color \| null` | - | 当前接受颜色(`v-model`;受控) |
| `value` | `string \| Color \| null` | - | 低优先级受控别名,与共享颜色模型一致 |
| `defaultValue` | `string \| Color \| null` | `"#000000"` | 非受控初值;未提供时使用固定源默认黑值,不会自动选中第一个候选 |
| `layout` | `"grid" \| "stack"` | `"grid"` | 布局方向(视觉 flex 布局,ARIA 方向固定为 vertical) |
| `size` | `"xs" \| "sm" \| "md" \| "lg" \| "xl"` | `"md"` | swatch 尺寸 |
| `variant` | `"circle" \| "square"` | `"circle"` | swatch 形状 |
| `isDisabled` | `boolean` | `false` | 禁用整个选择器(库扩展) |
| `disabled` | `boolean` | `false` | `isDisabled` 别名 |
| `isReadOnly` | `boolean` | `false` | 只读:保留选择与焦点,阻止新的选择(库扩展) |
| `dir` | `"ltr" \| "rtl"` | - | 方向;影响水平方向键映射 |
| `as` | `string` | `"div"` | 自定义根元素标签;对应上游 `render` 的元素替换 |
| `aria-label` | `string` | - | 列表名称;省略且没有 `aria-labelledby` 时使用本地化默认名称 |
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定) |
| 默认作用域插槽 | `({ color, isEmpty, isDisabled, isReadOnly, isFocused, layout }) => VNodeChild` | - | 根渲染状态 |
| Prop | 类型 | 默认值 | 描述 |
| -------------- | ------------------------------------------------------------------------------- | ----------- | -------------------------------------------------------------- |
| `modelValue` | `string \| Color \| null` | - | 当前接受颜色(`v-model`;受控) |
| `value` | `string \| Color \| null` | - | 低优先级受控别名,与共享颜色模型一致 |
| `defaultValue` | `string \| Color \| null` | `"#000000"` | 非受控初值;未提供时使用固定源默认黑值,不会自动选中第一个候选 |
| `layout` | `"grid" \| "stack"` | `"grid"` | 布局方向(视觉 flex 布局,ARIA 方向固定为 vertical) |
| `size` | `"xs" \| "sm" \| "md" \| "lg" \| "xl"` | `"md"` | swatch 尺寸 |
| `variant` | `"circle" \| "square"` | `"circle"` | swatch 形状 |
| `isDisabled` | `boolean` | `false` | 禁用整个选择器(库扩展) |
| `disabled` | `boolean` | `false` | `isDisabled` 别名 |
| `isReadOnly` | `boolean` | `false` | 只读:保留选择与焦点,阻止新的选择(库扩展) |
| `dir` | `"ltr" \| "rtl"` | - | 方向;影响水平方向键映射 |
| `as` | `string` | `"div"` | 自定义根元素标签;对应上游 `render` 的元素替换 |
| `aria-label` | `string` | - | 列表名称;省略且没有 `aria-labelledby` 时使用本地化默认名称 |
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定) |
| 默认作用域插槽 | `({ color, isEmpty, isDisabled, isReadOnly, isFocused, layout }) => VNodeChild` | - | 根渲染状态 |
`change` 事件与 `update:modelValue` 一起在选择被接受时触发,参数为本库 `Color`,保留候选色自身的颜色空间与精度。选择比较使用固定源的 hexa 键(8 位 RGB + alpha):等价格式(hex/rgb/hsl)视为同一颜色,alpha 按 1/255 量化比较,灰色的色相在比较中折叠;接受值本身不会被反写或量化。
@@ -197,57 +197,57 @@ ColorSwatchPicker 组件使用以下 CSS 类([查看源码样式](https://gith
### ColorSwatchPicker.Item
| Prop | 类型 | 默认值 | 描述 |
| ------------ | -------------------------------- | ------ | -------------------------------------------------------- |
| `color` | `string \| Color \| null` | - | 候选颜色;省略或空字符串渲染透明色块(对应固定源 `#0000`) |
| `isDisabled` | `boolean` | `false` | 禁用该项(不可聚焦、不可选择、方向键跳过) |
| `as` | `string` | `"div"` | 自定义根元素标签 |
| `aria-label` | `string` | - | 覆盖自动生成的项名称 |
| 默认作用域插槽 | `(state) => VNodeChild` | - | 项状态,见下方 Render Props |
| Prop | 类型 | 默认值 | 描述 |
| -------------- | ------------------------- | ------- | ---------------------------------------------------------- |
| `color` | `string \| Color \| null` | - | 候选颜色;省略或空字符串渲染透明色块(对应固定源 `#0000`) |
| `isDisabled` | `boolean` | `false` | 禁用该项(不可聚焦、不可选择、方向键跳过) |
| `as` | `string` | `"div"` | 自定义根元素标签 |
| `aria-label` | `string` | - | 覆盖自动生成的项名称 |
| 默认作用域插槽 | `(state) => VNodeChild` | - | 项状态,见下方 Render Props |
### ColorSwatchPicker.Swatch
| Prop | 类型 | 默认值 | 描述 |
| ----------- | ------------------------- | ------ | ------------------------------------------ |
| `color` | `string \| Color \| null` | - | 覆盖颜色;省略时使用所属项的颜色 |
| `colorName` | `string` | - | 颜色的可访问名称(覆盖自动生成的描述) |
| `as` | `string` | `"div"` | 自定义根元素标签 |
| Prop | 类型 | 默认值 | 描述 |
| ----------- | ------------------------- | ------- | -------------------------------------- |
| `color` | `string \| Color \| null` | - | 覆盖颜色;省略时使用所属项的颜色 |
| `colorName` | `string` | - | 颜色的可访问名称(覆盖自动生成的描述) |
| `as` | `string` | `"div"` | 自定义根元素标签 |
### ColorSwatchPicker.Indicator
| Prop | 类型 | 默认值 | 描述 |
| ---- | ---------------- | --------- | ------------------------ |
| `as` | `string` | `"span"` | 自定义根元素标签 |
| 默认作用域插槽 | `(state) => VNodeChild` | - | 替换默认勾选图标,接收项状态 |
| Prop | 类型 | 默认值 | 描述 |
| -------------- | ----------------------- | -------- | ---------------------------- |
| `as` | `string` | `"span"` | 自定义根元素标签 |
| 默认作用域插槽 | `(state) => VNodeChild` | - | 替换默认勾选图标,接收项状态 |
默认图标是固定源的勾选 SVG;`[data-light-color="true"]` 由色块相对亮度(> 0.5)决定,浅色背景使用黑色勾选。指示器始终渲染在 DOM 中,由 CSS 在选中时缩放显示。
### Render Props
| 插槽状态 | 类型 | 含义 |
| --------------------------------------------------- | --------- | -------------------------------------- |
| `color`(项) | `Color` | 该项的候选颜色 |
| `isSelected` / `isDisabled` / `isFocused` / `isFocusVisible` / `isPressed` / `isHovered` | `boolean` | 项的真实状态 |
| `color`(根) | `Color \| null` | 当前接受颜色 |
| `isEmpty` / `isDisabled` / `isReadOnly` / `isFocused` | `boolean` | 根的真实状态 |
| `layout`(根) | `"grid" \| "stack"` | 当前布局 |
| 插槽状态 | 类型 | 含义 |
| ---------------------------------------------------------------------------------------- | ------------------- | -------------- |
| `color`(项) | `Color` | 该项的候选颜色 |
| `isSelected` / `isDisabled` / `isFocused` / `isFocusVisible` / `isPressed` / `isHovered` | `boolean` | 项的真实状态 |
| `color`(根) | `Color \| null` | 当前接受颜色 |
| `isEmpty` / `isDisabled` / `isReadOnly` / `isFocused` | `boolean` | 根的真实状态 |
| `layout`(根) | `"grid" \| "stack"` | 当前布局 |
Root 实例通过 `defineExpose` 提供 `element`(真实根 DOM)与 `focus()`(按入口规则聚焦项);Item 提供 `element`。不暴露颜色 owner、事务 token 或内部集合键。
### 选择与焦点
| 操作 | 行为 |
| ----------------------- | ----------------------------------------------------------------------- |
| 鼠标主键按下 | 选择该项;仅主键(`button === 0`)激活,右键/中键保留原生行为;可取消的 `mousedown`(`preventDefault`)会阻止选择 |
| `Enter` / `Space` | 选择当前聚焦项(按下即选中) |
| `Tab` / `Shift+Tab` | 整个列表是一个 tab 停靠点;进入时聚焦已选项或首/末可用项 |
| `↑` / `↓` | 只移动焦点不选择;grid 按几何在换行行间移动,stack 按顺序移动 |
| `←` / `→` | grid 按顺序移动(RTL 反向);stack 交给浏览器滚动 |
| `Home` / `End` | 聚焦首/末可用项 |
| `PageUp` / `PageDown` | 容器不可滚动时跳到首/末项,可滚动时按页移动 |
| `click`(`detail=0`) | 辅助技术/程序化的 click-only 激活选择当前项;正常鼠标/键盘的兼容 click 不重复提案 |
| 输入字符 | 按项名称前缀匹配并聚焦(名称差异见下) |
| 边界 | 不循环;到边界后保持当前项 |
| 操作 | 行为 |
| --------------------- | ----------------------------------------------------------------------------------------------------------------- |
| 鼠标主键按下 | 选择该项;仅主键(`button === 0`)激活,右键/中键保留原生行为;可取消的 `mousedown`(`preventDefault`)会阻止选择 |
| `Enter` / `Space` | 选择当前聚焦项(按下即选中) |
| `Tab` / `Shift+Tab` | 整个列表是一个 tab 停靠点;进入时聚焦已选项或首/末可用项 |
| `↑` / `↓` | 只移动焦点不选择;grid 按几何在换行行间移动,stack 按顺序移动 |
| `←` / `→` | grid 按顺序移动(RTL 反向);stack 交给浏览器滚动 |
| `Home` / `End` | 聚焦首/末可用项 |
| `PageUp` / `PageDown` | 容器不可滚动时跳到首/末项,可滚动时按页移动 |
| `click`(`detail=0`) | 辅助技术/程序化的 click-only 激活选择当前项;正常鼠标/键盘的兼容 click 不重复提案 |
| 输入字符 | 按项名称前缀匹配并聚焦(名称差异见下) |
| 边界 | 不循环;到边界后保持当前项 |
焦点与选择分离:方向键只移动焦点,`aria-selected` 与指示器只反映接受颜色。父级拒绝提案后,选择样式、`aria-selected` 与 DOM 保持接受状态,同一手势可重试。窗口失焦或指针取消会清除按压状态与点击去重归属,恢复后可以立即重试。
@@ -265,4 +265,6 @@ Root 实例通过 `defineExpose` 提供 `element`(真实根 DOM)与 `focus()
## 相关组件
[ColorSwatch 颜色色块](./color-swatch) · [ColorField 颜色输入框](./color-field) · [ColorArea 颜色区域](./color-area)
已公开 [ColorField 颜色输入框](/components/color-field)(含 ColorInputGroup)、[ColorArea 颜色区域](/components/color-area)、[ColorSlider 颜色滑块](/components/color-slider)、[ColorSwatch 颜色色块](/components/color-swatch)、[ColorSwatchPicker 颜色色块选择器](/components/color-swatch-picker) 与 [ColorPicker 颜色选择器](/components/color-picker)。颜色家族共用同一颜色 owner,Picker 的 Trigger/Popover 组合可嵌套上述任意子组件。