Something went wrong

Thank you for being patient! We're working hard on resolving the issue

Alias Templates - Lona Docs Log in

Alias Templates

An alias is a declarative row that hydrates into a tree of layout

  • renderer descendants. Authors define a template once; any sheet that adds an AliasRow referencing the template gets the expanded subtree.

Built-in aliases

TemplateHydrates into
weathercolumn layout + column.weather renderer + optional column.logs child
timezonecolumn layout + column.timezone renderer
datacolumn layout + data-renderer children based on the source's data preset
taskcolumn layout + column.task renderer
task-listcolumn layout + cascading task renderers across days
calendarcolumn layout + column.calendar (list mode) + timeline[row].event (all-day) + timeline[column].event (timed)
calendar-listcolumn layout + column.calendar list mode only
calendar-alldaycolumn layout + column.calendar + timeline[row].event

Each template is an entry in ALIAS_TEMPLATES:

import { ALIAS_TEMPLATES } from "@tento-lona/sheets";

const weather = ALIAS_TEMPLATES.weather;
weather.props;       // PropSchema entries the alias accepts
weather.staticRules; // unconditional child specs
weather.dynamicTail; // child-spec generator (data-driven)

Hydrating an alias

import { expandAliasInstance } from "@tento-lona/sheets";

// Called automatically by Sheet.from / sheet.addRow when an alias
// row enters the tree. Re-call after a prop change:
expandAliasInstance(sheet, aliasRow);

Re-expansion is idempotent — instance.hydrated short-circuits if nothing has changed.

Resolving the active layout

Most consumers only need to know which layout child the alias is currently rendering through:

import { resolveAliasActiveLayout } from "@tento-lona/sheets";

const activeLayout = resolveAliasActiveLayout(sheet, aliasRow);
// → the LayoutRow descendant the alias points its render binding at

This is the function platform implementors reach for via @tento-lona/platform (re-exported from this barrel).

Defining a custom alias

import { AliasTemplate, BuiltinAliasFactory } from "@tento-lona/sheets";

const myTemplate: AliasTemplate = {
  name: "my-alias",
  props: { /* PropSchema entries */ },
  staticRules: [ /* StaticRule entries */ ],
  dynamicTail: { /* DynamicTail generator */ },
};

const myFactory: BuiltinAliasFactory = {
  template: myTemplate,
  defaults: () => ({ /* default props */ }),
};

// Register at client startup:
defaultBuiltinAliasFactories.register(myFactory);

After registration, any sheet adding an alias row with template: "my-alias" hydrates through the new factory.

Prop propagation

Alias children can read parent-alias props via propagateChildAttrToAlias. When a child mutates an attribute the parent template wants to track (e.g. weather.location set on a child renderer), the call walks up to the alias and re-applies its dynamicTail.

Initial props

import { resolveInitialAliasProps } from "@tento-lona/sheets";

const props = resolveInitialAliasProps(template, descriptorOverrides);

Combines the template's defaults with any descriptor-level overrides (AliasDescriptor.props).

See also