Skip to content
Web App

Factory options

makeTreeFactory<V>(options) accepts:

OptionDefaultDescription
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.
createLeafidentity(value) => leaf — formats data leaves (joined arrays included). Headers, indexes, corners and filler never pass here.
joinArrayValuesundefined(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".
isProportionalResizeallows 100% growth(lcm, max) => boolean — guards LCM-scaling of sibling heights. Use makeProportionalResizeGuard(threshold); when it rejects, short columns are padded with filler instead.
collapseIndexesfalseFlatten nested arrays into dotted index paths (1.2, …) instead of nested index columns.
stabilizeOrderOfPropertiesInArraysOfObjectstrueReorder keys of objects inside an array by stable first-seen position, so columns line up.
deduplicateHeaderstrueLift the header band common to all array items on top of the table. Set false to keep per-row headers.
isHeaderEqualObject.is(a, b) => boolean — custom equality for header values during band lifting. Needed when headers carry objects (see below).
  • Objects with a toJSON() method are unwrapped via toJSON() first.
  • Objects exposing a [TO_TABLE]() method (import TO_TABLE from @json-table/core) bypass parsing with their prebuilt Tree.
  • Every array level renders its index column — no special cases, so [x] stays distinguishable from x and [{ ... }] from { ... }. joinArrayValues runs before that, uniformly (empty arrays never reach it: they render as the emptyCellValue filler). In collapseIndexes mode 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-array filler cell, empty objects as one empty-object filler cell (see emptyCellValue).
  • Headers carrying objects never lift by identity alone: pass isHeaderEqual to compare them (e.g. by label).