# HierarchyContributor

> _Since v3.9.0_

A plugin that contributes structure to the hierarchy.

Contributors never call each other: the HierarchyPlugin runs every attached
contributor on each natural sibling list — `structure` contributors first
(discover children, order siblings), then `transform` contributors
(re-shape the list, e.g. insert group nodes).

## Properties

| Property | Type | Description |
| -------- | ---- | ----------- |
| <span id="hierarchystage"></span>`hierarchyStage` | <code>structure &#124; transform</code> | `structure` contributors run before `transform` contributors on every list. |

## Methods

### beginHierarchy()

Called once per row-model rebuild with the root rows. Return `false` to sit
out this rebuild (e.g. the data is not a tree).

```ts
beginHierarchy(rows: readonly unknown[]): boolean
```

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `rows` | <code>readonly unknown[]</code> |  |

***

### processSiblings()

Re-shape one natural sibling list. Return the input array when nothing changes.

```ts
processSiblings(nodes: HierarchyNode[], context: HierarchySiblingContext): HierarchyNode[]
```

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `nodes` | <code><a href="/grid/plugins/hierarchy/interfaces/hierarchynode/">HierarchyNode</a>[]</code> |  |
| `context` | <code><a href="/grid/plugins/hierarchy/interfaces/hierarchysiblingcontext/">HierarchySiblingContext</a></code> |  |

***

### endHierarchy()

Called once per rebuild (only if beginHierarchy returned `true`) with the flattened
rows. `positionOf` returns a row's final position — its depth can exceed the
`context.depth` seen in processSiblings when a transform inserted levels above it.

Return `false` when this rebuild produced no structure from this contributor (e.g. no
list was grouped). When every contributor returns `false`, the rows are announced as a
flat `grid` — no `treegrid` role, no `aria-level` / `aria-setsize` / `aria-posinset`.

```ts
endHierarchy(rows: readonly unknown[], positionOf: (row: unknown) => HierarchyRowMeta | undefined): boolean
```

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `rows` | <code>readonly unknown[]</code> |  |
| `positionOf` | <code>(row: unknown) =&gt; <a href="/grid/plugins/hierarchy/interfaces/hierarchyrowmeta/">HierarchyRowMeta</a> &#124; undefined</code> |  |

***
