List parameters
A list holds a variable number of flat items, such as the GPX tracks of one map, each with its own colour and label:
tsx
const mapParameters = {
tracks: p.list({
label: 'Tracks',
item: {
track: p.file({ label: 'GPX track', accept: ['.gpx'] }),
colour: p.color({ label: 'Colour', default: '#c0392b' }),
label: p.string({ label: 'Label', default: '' }),
},
min: 0, max: 12,
}),
};
// render: ctx.elements.map.params.tracks is { id: string; track: string; colour: string; label: string }[]- Items are flat.
itemdeclares the fields with the otherp.*helpers: file, string, number, integer, colour, date, enum and boolean. There are no nested lists.idis not a field name: it is the item's own ID. - Saved value: a JSON array in
project.json. Each item has a stableid, generated by the app when the user adds or duplicates an item, so reordering, Undo and editor drafts address the item, not its position. Use it as the Reactkey. A missing field takes its default. - Default:
[], ordefaultitems valid againstitem.p.listgives default items without anidone from their position (item1,item2, …), skipping IDs other default items already use. - Validation: each item is checked with the field's own rules, and
min/maxbound the count. Inrender, a field with a value it does not allow takes its default, an item without a unique valididis left out, and a count outsidemin/max(or a value that is not a list) uses the list's default. Each problem is reported per item; the saved data is never rewritten. A list's file fields are checked like file parameters: a missing or unreadable file is a Book check error naming the item. - Generated control: a compact list with add, remove, duplicate and reordering (drag, or the arrows), where each row shows a one-line summary (the file name, the first text, a colour swatch) and opens to the item's fields on click. Every change is one Undo step. In the inline editor's toolbar the list is a Tracks (3) button that opens it in a popover, so the toolbar stays one row.
controlscan name the list like any parameter. - Custom editors receive and
setthe whole array; ImageFlow validates it like any other value, so items need theirid.<Control parameter="tracks" />renders the generated list control, and<Control parameter="tracks" itemId={track.id} field="track" />renders one field of one item, such as an import per track.itemIdandfieldgo together and only lists take them; the types checkfieldagainst the item fields. AnitemIdthe list never had is an error; once the item is removed, the control renders nothing. - Agents set the whole array with
set_parameter, or change one item withinsert_list_item,update_list_item,remove_list_itemandmove_list_item, addressed by itsid(docs/mcp.md). ctx.Text,ctx.editconditions andcontrolswhencannot compare a list; show its items with your own markup.
The starter's Map layout draws every track of its tracks list; Fit tracks frames all of them. It replaces the map's earlier single track and trackColor; books saved with those are not migrated (no released books use them).