Concrete
GuidesSource a value

Bind a slot to a property fact

A value the property already knows — the street, the beds, the agent's name — and nobody should be typing it twice.

Goal

Bind the starter's fact slots properly: read the right fact, decide whether the slot is the fact or only seeded from it, bind a whole table as a list, and read one row's members through a row().

Prerequisites

  • The workspace Start leaves you with.
  • Facts and provenance for why a bound value is never also generated, and where a slot's provenance shows up in the editor.

Steps

1. Read the property root, or one row of a table

fact.property.<field> is a value you pass, not a call you make, and it resolves against the property root. One row of a table is never a fact.* entry: it is held by a row(), and its members are read off that row (steps 4 and 5). A row with no source holds its table's first row, and locked: true keeps a section on it, so the primary unit and the primary contact are each a locked row:

sections/sheet.tsx
import { fact, number, row, text } from "@homepages/concrete";

const street = text.short({ label: "Street", source: fact.property.address.street });

const unit = row({ label: "Unit", from: fact.property.units, locked: true });
const beds = number({ label: "Beds", source: unit.beds });

const contact = row({ label: "Contact", from: fact.property.contacts, locked: true });
const agent = text.short({ label: "Agent", source: contact.name, cap: 40 });

Each entry is a literal, so a misspelled fact is a compile error at the call site rather than a check-time failure.

The property's address is one fact, and its parts are typed members of it: fact.property.address.street, .unit, .city, .state, .postal, and the coordinates .latitude and .longitude. Nothing derived is a member: the address on one line is a formatting you write in a compute() over the parts. Every member is read-only and reads null when the property has no such part, so a slot bound to one renders for an empty value. A slot that holds the whole place, rather than one line of it, is an address() (Add an address slot).

2. Bind the fact, or seed from it

A bound slot is the fact on this page: an edit to it is offered as Update everywhere, and changes the property for every other page that shows it (where an edit goes). That is right where the section is a place a user would go to correct the fact. Where the section only starts from the fact and the user should be free to change the line for this page alone — a headline built on the agent's name — derive it with a compute() instead:

sections/sheet.tsx
import { compute, fact, row, text } from "@homepages/concrete";

const contact = row({ label: "Contact", from: fact.property.contacts, locked: true });

const byline = text.short({
  label: "Byline",
  cap: 40,
  source: compute({ reads: [contact.name] }, (name) => name ?? ""),
});

3. Leave the fill off

A slot declares exactly one origin, and a fact ref and a fill are both a source: — a value baked from a fact is not also generated. If you find yourself wanting both, the question is which one is true. A value the property holds is bound; a value only a model can write is filled (Phrasing a brief).

4. Bind a table as a list

Three entries are tables rather than scalars: fact.property.units, fact.property.contacts and fact.property.comparables. A list takes one as its source and holds every row of it, live. Its item is a function of each row's element: row({ from: fact.property.units, source: el }) holds that row — its from the list's table — and the fields of the item's object() read its members:

sections/sheet.tsx
import { fact, list, number, object, row, text } from "@homepages/concrete";

const homes = list({
  label: "Homes",
  source: fact.property.units,
  max: 12,
  item: (el) => {
    const unit = row({ label: "Unit", from: fact.property.units, source: el });
    const name = text.medium({ label: "Unit", cap: 20, source: unit.label });
    return object({
      label: name,
      fields: {
        unit,
        name,
        beds: number({ label: "Beds", source: unit.beds }),
        baths: number({ label: "Baths", source: unit.baths }),
      },
    });
  },
});

Each field names the member it shows as its source — unit.beds is this row's beds, where a locked row's beds would be the primary unit's in every item, and an edit to it is that row's, exactly as a fact's is. A field the table does not answer reads the row inside its own fill.write() or compute() instead — a member is as legal in reads as it is in source. A property fact is never an item field's source: it is the same value in every item. A list sourced by a table is that table in the content, so adding, removing or reordering an item edits the property's rows. What the list may do is narrow membership — min/max over the rows the property actually carries — and nothing else: binding something that is not a registry table, or widening past it, is contract/record-collection.

Being bound does not exempt it from the marker contract. Render it exactly as any list of objects — one Slot.Object per item of bindItems (Add a list slot) — because the items need their markers however the values got there. Items read off the raw value and printed as plain markup are render/missing-slot-marker.

The fields are the part you can relieve. locked: true on a field is often the truer declaration for a platform-baked row — nothing about it is an editorial choice — and a locked field owes the canvas no marker, so it may be plain markup inside the marked item. The row owes no marker either: it is the item card's bar in the editor, never an element on the canvas.

5. Bind one row with row()

A slot that shows one particular row — the listing agent's phone, the broker's name — reads it through a row(). Its from names the table; with no source, a row holds that table's first row, which the user may re-pick in the editor; its members are read exactly

as an item's are:

sections/sheet.tsx
import { compute, fact, object, row, text } from "@homepages/concrete";

const broker = row({ label: "Broker", from: fact.property.contacts });
const brokerPhone = text.short({ label: "Broker phone", cap: 40, source: broker.phone });

const agent = row({ label: "Agent", from: fact.property.contacts });
const contact = object({
  label: compute(() => "Listing agent"),
  fields: {
    agent,
    name: text.short({ label: "Name", source: agent.name }),
    phone: text.short({ label: "Phone", source: agent.phone }),
  },
});

A row is a slot like any other — broker and brokerPhone are both entries of the section's slots — and its members are read only where its readers can see it: at the section's top level, or as a field of the same object() (contract/row-rule). object() groups fields that belong together into one card, so the agent, their name and their phone are edited side by side; the row among its fields is what the others read. A member is typed exactly as on an item's row, and an edit to its reader goes to that row. A row the property does not have reads null, so render its readers for an empty value. A member is equally legal in a compute() or a fill's reads. What a row holds is its table's row, never a value of its own (contract/row-source).

6. Render it, and leave the fixture alone

sections/sheet.tsx
import { fact, number, row, Section, section, Slot, text } from "@homepages/concrete";

const unit = row({ label: "Unit", from: fact.property.units, locked: true });

export const Sheet = section(
  {
    key: "sheet",
    label: "Fact sheet",
    slots: {
      street: text.short({ label: "Street", source: fact.property.address.street }),
      unit,
      beds: number({ label: "Beds", source: unit.beds }),
    },
  },
  ({ slot }) => (
    <Section>
      <Slot.Text slot={slot.street} as="p" />
      <Slot.Number slot={slot.beds} as="span" format={(value) => `${String(value)} bed`} />
    </Section>
  ),
);

A bound slot is still an ordinary slot: render it at least once or render/missing-slot-marker fires.

A fixture may not state it as a fill's. A content fixture states what a fill would write, and a bound value is resolved from the property — stating one bare is fixtures/document-invalid, and the fix is to edit the property document, which is the thing that decides it. A value the user typed over it is stated with its mark under slot_overrides.scalar (Write a fixture). A row states the identity of the row it holds — the user's re-pick — and a list sourced by a table states only the fields a fill writes, item by item. Stating more items for a bound list than its property carries is fixtures/rows-not-in-property.

Verify

Run concrete dev and select a bound slot: its card carries the fact provenance chip, and a writable binding shows the Update everywhere toggle beside it. Switch fixtures and the value changes with the property — that is the whole proof that nothing here was typed in.

Then run concrete check, whose contracts stage grades every source:

concrete check
concrete check passed: 13 stages.

On this page