Factory options
makeTreeFactory<V>(options) accepts:
| Option | Default | Description |
|---|---|---|
cornerCellValue | — (required) | Value of the top-left corner cell above lifted header bands. |
createHeader | — (required) | (key, record) => leaf — header cell for an object key. |
createIndex | — (required) | (i, array) => leaf — index cell for array item i. |
createLeaf | identity | (value) => leaf — formats data leaves (joined arrays included). Headers, indexes, corners and filler never pass here. |
joinArrayValues | undefined | (values) => leaf | undefined — merges an array into one leaf; return undefined to render it as a table. Receives raw input order, before key stabilization. Use joinPrimitiveArrayValues to comma-join all-primitive arrays. |
emptyCellValue | () => "" | ({ type, width, height }) => leaf — placeholder for content-less cells. type is "gap" (sizing filler), "empty-array" or "empty-object". |
isProportionalResize | allows 100% growth | (lcm, max) => boolean — guards LCM-scaling of sibling heights. Use makeProportionalResizeGuard(threshold); when it rejects, short columns are padded with filler instead. |
collapseIndexes | false | Flatten nested arrays into dotted index paths (1.2, …) instead of nested index columns. |
stabilizeOrderOfPropertiesInArraysOfObjects | true | Reorder keys of objects inside an array by stable first-seen position, so columns line up. |
deduplicateHeaders | true | Lift the header band common to all array items on top of the table. Set false to keep per-row headers. |
isHeaderEqual | Object.is | (a, b) => boolean — custom equality for header values during band lifting. Needed when headers carry objects (see below). |
Input handling
Section titled “Input handling”- Objects with a
toJSON()method are unwrapped viatoJSON()first. - Objects exposing a
[TO_TABLE]()method (importTO_TABLEfrom@json-table/core) bypass parsing with their prebuiltTree. - Every array level renders its index column — no special cases, so
[x]stays distinguishable fromxand[{ ... }]from{ ... }.joinArrayValuesruns before that, uniformly (empty arrays never reach it: they render as theemptyCellValuefiller). IncollapseIndexesmode nested levels flatten into dotted paths ([[123]]→1.1 | 123); a flat singleton ([x]) flattened nothing and renders bare, as do empty arrays. - Empty arrays render as one
empty-arrayfiller cell, empty objects as oneempty-objectfiller cell (seeemptyCellValue). - Headers carrying objects never lift by identity alone: pass
isHeaderEqualto compare them (e.g. by label).