Tree
Navigazione da tastiera per un albero di righe: frecce, espandi e comprimi, ricerca durante la digitazione e una sola fermata di Tab, secondo il pattern tree di WAI-ARIA.
Angular: disponibile Vue: disponibile React: disponibile React Native: non ancora disponibile
Utilizzo
Opened: roadmap
<sone-sidebar style="width: 18rem">
<div soneTree aria-label="Workspace">
@for (line of visibleLines(); track line.id) {
<sone-tree-row
[label]="line.label"
[icon]="line.icon"
[depth]="line.depth"
[expandable]="line.expandable"
[expanded]="expanded().has(line.id)"
[selected]="selectedId() === line.id"
(activate)="selectedId.set(line.id)"
(toggleExpand)="toggle(line.id)"
/>
}
</div>
</sone-sidebar>
<p style="margin: var(--space-3) 0 0; color: var(--text-secondary)">Opened: {{ selectedId() }}</p>Importazione
import {
SoneTreeDirective,
SoneTreeItemDirective,
} from "@surface-one/angular/tree";Riferimento API
SoneTreeDirectiveDirettiva
`[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.
SoneTreeItemDirectiveDirettiva
`[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`.
| Nome | Tipo | Predefinito |
|---|---|---|
level1-based nesting level. | number | 1 |
hasChildren | boolean | false |
expandedbidirezionale | boolean | false |
selected | boolean | false |