Tree

为树形行提供键盘导航——方向键、展开与折叠、输入跳转和单一 Tab 停靠点,遵循 WAI-ARIA tree 模式。

可用框架
  • Angular: 可用
  • Vue: 可用
  • React: 可用
  • React Native: 暂不可用

用法

Opened: roadmap

导入

ts
import {
  SoneTreeDirective,
  SoneTreeItemDirective,
} from "@surface-one/angular/tree";

API 参考

SoneTreeDirective指令

`[soneTree]` — the WAI-ARIA tree pattern over FLAT rows (`sone-tree-row`, or any element with `[soneTreeItem]`): `role="tree"`, one Tab stop (roving tabindex), ↑ / ↓ move, → expands or enters the first child, ← collapses or goes to the parent, Home / End, typeahead, Enter / Space activate and `*` expands every sibling. Rows keep rendering only what is expanded; the tree reads their order from the DOM and their level from `aria-level`. Expand / collapse only change state; the rows they add or remove appear on the next render. A navigation key that lands before it (key repeat, a fast typist) would walk the stale rows, so it is held and replayed on the row once that render is done.

选择器
[soneTree]
导出为
soneTree

SoneTreeItemDirective指令

`[soneTreeItem]` — makes any element a row of the enclosing `[soneTree]` (for rows that are not `sone-tree-row`, such as a "View all" link): `role="treeitem"`, `aria-level`, `aria-expanded`, `aria-selected` and the roving tabindex. Enter / Space click it; →/← emit `expandedChange`.

选择器
[soneTreeItem]
输入
名称类型 默认值
level

1-based nesting level.

number1
hasChildrenbooleanfalse
expanded双向booleanfalse
selectedbooleanfalse