package reference

Registry keys

An element declaration begins as JSON Schema. Its x-* keys tell Leaf how the element reads, renders, changes, and joins the collaboration loop. Choose a key below to jump to its summary. Longer contracts open in place.

This reference is generated from the registry's $keys, the same entry an agent can query in a page's merged registry.json. Start with the extension guide, or read the complete package contract.

Find a declaration

The index jumps to a summary. Longer entries keep their full contract one click away.

x-ask-context

The element frames the asks inside it: its leading heading gives their prompt, and going to one of those asks lands on the element.

Full contract

lf-ask declares it; a widget that asks on its own needs no frame. Each ask keeps its own id, answer and completion, and where frames nest, it uses the nearest. Leaf calls the element a question unless its x-word module returns another word.

x-awaits

The widget asks the user for input while its authored attributes match when.

Full contract

The ask's id is widget:<source-id> and never changes. value names the x-state verb whose state is the typed answer, and answered says when the ask is complete ($awaits); they are separate because a partial value can exist while the ask is open, and an empty value can be a complete answer. all names the outcome one banner control can give every ask of this kind at once. Once created, an ask stays answered or withdrawn after when stops matching; an element that never matched creates none, and neither does a quoted widget (x-exhibit). A restated event asks again. While the agent owes a reply in a thread about the ask, anchored inside the widget, or inside its x-ask-context but no other ask, the agent is its next actor and the ask stays unanswered. A widget in a thread message keeps its ask after the thread closes. Asks and to-dos are separate records, and the user's On me list reads asks directly.

x-bound

The element has its own height and scrolls inside it, so a long log or feed never grows the page.

Full contract

start opens at the first line; end follows the newest entry while the user is at the end, and stays where the user scrolled back to otherwise. An authored element may set or override it with data-bound=start|end; delivery writes it as data-lf-bound.

x-content

The required content: markup (the author's markup), members (only this element's declared member elements), data (one <pre> holding text in the notation the description names, with & < > escaped as &amp; &lt; &gt;), or empty.

x-data

The widget's named external-data inputs.

Full contract

Each input names a $data.contracts contract and the string attribute whose authored value is the page's source id, and follows that source's current value; where an optional source attribute is absent, a widget reads null. A document binds each source to one contract, and a later document may rebind it; each document reads the value against its own contract and reports a mismatch as a source error. A module subscribes by widget and input name, never by a source name.

x-example

Authored markup exhibiting the widget, valid against the merged registry: an agent reads it with the element declaration, writes from it, and the lint refuses one that does not validate.

x-exhibit

The element shows quoted content: widgets inside it take no input, and their asks stay off the user's On me list. Modules check quoted(el) before enabling input.

x-height

The height in CSS pixels the page reserves for the element before its module draws: the declared number, or an authored data-height, which overrides it; true reserves only where data-height is given.

Full contract

The theme holds the box to it from first paint until the module marks the element drawn (lf-rendered). Declare it on a widget whose drawing can't be sized from its markup. A module that can draw at any height, such as a chart's, draws at this one, so nothing moves; for content with its own height, the reserved height is the author's estimate of it.

x-history

true: the module renders the page's history, so a page that contains one is served the history reading with its state.

Full contract

The reading is the newest 50 logged events, newest first, each with who acted, what they did, the id of the thread it was in, whether a later undo took it back, and, for a widget gesture, the words its ids had when it was made. The module reads it with readHistory.

x-initial

The rooted path of a classic JavaScript bundle that registers the widget's synchronous first drawing with document.documentElement.lfInitial.register(tag, render).

Full contract

Delivery inlines each used bundle once in the head and draws each element as soon as its source is complete, nested elements first. render(host, {tabStore, offer, offerElement}) builds the instance's real markup from authored values and tab-local state, without network or asynchronous work, and returns the structure the behavior module adopts with initialRender(host). For revisions and thread messages that arrive later, the widget loader imports the same bundle before the behavior module. Leaf keeps the original markup before drawing, so comparisons and readings of the source ignore the drawing. Requires x-upgrade: true; excludes x-prepaint.

x-inline

The element sits inline among the surrounding words. The render check therefore requires neither a width of its own nor a place where a block may stand.

x-instructions

Instructions for an author using this widget, read after choosing it and before writing markup. One non-empty string, separate from the short description and the schema.

x-language

The attribute that names a code language. Its value must be one of $languages.names, so a new tag that takes a language needs only this declaration.

x-measured

A value in authored content tied to the data run that produced it.

Full contract

input names the widget's x-data input, and run its required receipt attribute. When the source holds a different run, page check warns that the measurement is stale, and page state reports it. Rewriting the source counts as a new run even with the same value; age alone never makes a measurement stale.

x-name

The attribute that holds the element's title, which the page uses to name the element elsewhere, as the activity feed does.

Full contract

Declare it only where an attribute is the title, as a column's or a tab's label is; a section is already titled by its heading, a disclosure by its summary, and a titled member by its leading <strong>. An attribute the element merely shows first, such as a metric's value, is not its title.

x-owners

The element declarations that may directly own this element. An owner's direct children of these kinds are its members, and a gesture on the owner's whole box stops at them.

x-patch

How a revision reaches an upgraded widget the user has open.

Full contract

By default any change to the widget's markup replaces the whole widget, rebuilding whatever the user had open in it. members says the module builds its controls beside its members, leaves the members where the author wrote them, and reads only their attributes; then, while a revision keeps the element's attributes and each member's tag and attributes in order, Leaf edits inside the members in place. Requires x-content: members and x-upgrade.

x-prepaint

Markup the element shows at first paint, before its module draws: one element with the structure the module will draw, holding words that give it the drawing's size.

Full contract

Delivery writes it into every occurrence as the element's first child, marked data-lf-prepaint, so the browser lays the widget out at its real size instead of reserving a computed height. The theme keeps the space but paints none of it. The module removes it in the same step that draws, so nothing moves, and draws by filling a copy of this markup, so the structure is stated only here. {"as": tag} reuses another widget's prepaint, for an element that first appears as that widget will inside it. Declare it on a widget whose drawn structure is fixed while its values come from the log; a widget whose rows depend on the log has no fixed structure to write here.

x-reading-role

The structural role the element plays.

Full contract

The only role is pane: a reading region, named by its required label, whose body scrolls on its own while the workspace is full-height. A pane holds exactly one body element, optionally between a direct header and footer; a visible heading goes in the header. Validation reads this declaration, not tag names, so a package can contribute panes under its own tags.

x-refers

A map from each attribute whose value names another element to the contract its target must meet.

Full contract

An empty contract accepts any element id, as an option's for does. A typed contract names a shared registry map with via and an equality test with where, and page check requires a target whose tag's entry in that map passes the test, so a package can tell a goal reference from a worker reference without Leaf knowing either. With owns: true the referrer fills its target: page check requires the target in the referrer's own document, and requires each element there that the test selects to be named by exactly one referrer. A keyed contract {tag, key} names a member by an attribute instead of an id: the tag element whose key holds the value, inside the referrer's nearest owner in which key is unique (x-unique), as a playground preset's setting names a control by name. In the browser a module passes the attribute to navigateToDatum, or the experimental indicate, to reach the named widget; each looks in the referrer's own document (its message, for a widget in a reply) before the page.

x-resident

How the element sits in a column page's first aside.sidebar.

Full contract

The only value is map, a contents map: where the margin has room and the pointer is precise, it shows as a spine in the left margin whose labels appear over the page. Delivery writes data-lf-resident into the served document, except in a thread message, which has no margin.

x-retired-when

On a member: the outcome of its owner's decision that removes it from the page, as accept removes a suggestion's lf-old.

Full contract

Requires x-owners. The outcome is a value of the outcome field on the owner's one deciding verb. Leaf renders the decision itself, including its undo: it writes data-lf-state="<outcome>" on the owner and data-lf-retired on the removed members, which one theme rule hides. A module may write the same attributes earlier during its own gesture (renderRetired), but code that needs the decision reads it from the widget's state, not the attributes. Once the log decides, page check lets a revision drop the member's ids, and page check --render reports a removed member that still shows words.

x-says

Attributes whose values show as selectable text: after inside the element after its content, before at its start, in declaration order. The runtime writes real text nodes, unlike CSS content: attr(), so the user can select, quote and comment on the words.

x-shadow

The module renders the page's words into an open shadow root, and Leaf's passage reading, selection capture and id lookups reach into it. The render check reports a shadow root on an element whose declaration lacks this key.

x-space

The width past the reading measure the element takes in a column or sidebar Layout: wide takes the shared, capped evidence width; available takes all the width the page shell can give.

Full contract

Without it the element fills its container, as every element does in other Layouts; an element read as lines of text keeps to the measure in its own stylesheet (max-inline-size: var(--lf-measure)). An authored element may override it with data-width=wide|available, which the theme applies without moving the prose.

x-state

Declares each verb of a widget that has state: the unit of state it changes, who writes it, and either its record (how the state reads in markup, $state.record) or the schema of its detail.

Full contract

A verb is the user's, sent from the page as action events, unless it declares writer: "agent"; the agent writes it with leaf page report, as report events. A user verb may create a child element (creates). An agent verb with text: true requires each report to carry a non-empty detail.text, a short note the report feed shows as written. The page marks a reported widget data-lf-reported until a version answers the report ($report). For each [widget, unit, verb] key, the latest action not taken back wins, and different verbs on one unit coexist. Leaf combines those actions with the authored values and hands the widget its complete state, keyed by verb, as this.state, which its render() reads. A past action keeps its key after the widget leaves the page. When an action makes the widget's x-awaits answered condition hold, Leaf records meaning.answer on it: the thread named by the widget's resolves attribute in the document the action came from, which the answer closes, or null. A decision whose outcome is the widget's x-withdrawn-as value also records null, and the page reads as if nothing had been proposed. The detail field outcome is reserved for the one user verb that decides which members leave the page (x-retired-when).

x-text-format

How the element's text is formatted.

Full contract

inline-markdown formats its direct text nodes; markdown renders its data body as safe block Markdown. A body record keeps the Markdown source, while passages read the visible words. Child elements stay HTML. In a generated child, the user's line breaks are hard breaks.

x-thread-seat

The module puts a thread box (threadBox) in each element that matches when on authored attributes, not on attributes an x-state record writes.

Full contract

The box shows, as text, the threads anchored exactly to that element; the Threads panel keeps the full view. An element inside thread markup or quoted content gets no box. On a widget that also asks (x-awaits), the box is where the user answers in words: while a thread there waits on the agent, the ask leaves the user's On me list, but it is still unanswered and the widget's controls still work. hold labels a second send button whose comment carries holds, naming the widget. The widget is held while that thread is open; resolving the thread releases it. Removing the widget removes only the box, not its threads.

x-thread-surface

The upgraded widget can show Leaf's comment box and threads inside itself, beside the data items they are about.

Full contract

On each pass, Leaf calls the element's threadOutlets(targets, {signal, collection, onCommit}) with the targets anchored exactly to its items, in order, and the method returns for each an element to place it in (an outlet), or null. The widget reads its registration with threadSurface(element): update() says its outlets changed, and open(datum) opens Comment on one item. Leaf still owns anchors, drafts, sending, thread rendering, replies, reactions and focus, and decides placement inside each outlet. An item that isn't shown (not loaded, filtered out, collapsed or outdated) gets no outlet, and its threads stay in the Threads panel and the margin.

x-tone

The attribute that names one of the layer's semantic tints, held to $tones.names, which the theme has a rule for.

x-unique

A map from each attribute whose value must differ between members of one owner to that owner's tag.

Full contract

page check and message markup refuse a repeat inside the same nearest owner, such as two controls of one playground sharing a name. A keyed x-refers contract names members by such an attribute.

x-upgrade

A module at widgets/<tag>.js enhances the element in the browser, loaded only where a page's markup uses the tag. page init refuses a layer that declares it without the module, and the render check refuses a module that defines no element for a widget on the page. Required.

x-verbatim

The upgraded element keeps its authored words, and its nested upgraded widgets in authored order, so the passage reader can quote those words; each nested widget's own declarations cover the words it generates.

Full contract

Without this key the passage reader treats the widget as opaque, since its module may insert or replace words. The render check refuses a page where the wrapper's own words changed or a nested widget was removed or reordered.

x-views

true: the element shows one member at a time, as a tab set shows one panel.

Full contract

Its module opens the member the runtime names (openingView) and records each member it shows (keepView). The runtime opens the member holding the element the URL fragment names, else the member this tab last showed, else the first; a reload prefers the member last shown. Before first paint Leaf marks the member it will open data-lf-opening, so the package theme can show that member alone until the module upgrades.

x-visual

How a rendered picture offers Comment targets.

Full contract

whole makes the picture one target. With {parts: ATTR} or {prefixes: [PREFIX, …]}, the module calls registerVisualParts(source, read) once, and read returns the current list of {id, element, label, surface?}; a comment on a part stores its id as anchor.visual. Under parts, ATTR names an attribute of the widget, as in <lf-diagram parts="all">: the registered parts become targets where the widget carries it, and without it the picture stays one target. Under prefixes, Leaf accepts any longer id starting with one of them, such as commit:3f2a under commit:. surface may name a descendant whose own paint, without decoration, gives the outline Leaf marks; element stays the target for hits and travel. A comment whose part is gone detaches on replay instead of widening to the whole picture. A visual that draws its parts over time also passes {reveal}: reveal(id) must synchronously show a state that holds that part, cancelling any pending change that would remove it, and Leaf calls it before going to the part from a thread or navigateToDatum. While a declared part is missing from the current state, its threads sit on the whole picture. Call the registration's update() after any change to rendering or geometry, including an attribute or style change in place. The render check validates each registered record.

x-withdrawn-as

The deciding outcome that declines the proposal.

Full contract

It answers the ask without closing the widget's resolves thread. A revision may also remove an unanswered proposal outright, whether or not it has retirable members; ids from earlier versions don't prevent it.

x-within

The regions (element declarations) inside which a member may sit at any depth instead of as its owner's direct child.

Full contract

It belongs to the nearest owner x-owners names around that region, and page check refuses it anywhere else. A playground control written inside lf-playground-preview stays where it is written, beside the item it changes, instead of in the rail.

x-word

The module gives a word for the widget's kind through lfWord(), as lf-suggestion returns "insertion", "deletion" or "rewrite" depending on its children.

Full contract

Leaf uses it when naming the widget in a panel row or comment anchor; without one, it calls an x-ask-context widget a question and anything else by its tag name without the prefix. The module may also describe the widget through lfSays(), where its text alone doesn't convey its structure, such as a rewrite's old and new text; otherwise Leaf reads the element's text.

x-work

true: the agent may open its own to-do on this widget with leaf task open even when no update on it is open, and the to-do shows beside the widget.

Full contract

Only a block widget whose x-content is markup may declare it, and markup content does not imply it: markup can itself be a control, or sit in a hidden panel.