import { ContentItem, ContentType, CustomFieldDef, FieldRuleContext, PopupModal } from '../schema/index.ts'; import { DropEdge } from '../dragSort'; /** The items in render order. */ export declare function sortedItems(popup: PopupModal): ContentItem[]; /** Submit buttons always sink to the bottom; everything else keeps its order. */ export declare function normalizeItems(items: ContentItem[]): ContentItem[]; /** * A new item of `type`, added to the form. Shared by the two places an element * is added — the layout list's "+ Add item" and the toolbar's Add menu — so * both land it in the same spot, normalized the same way. */ export declare function appendType(popup: PopupModal, type: ContentType, ruleCtx: FieldRuleContext, atStep?: number): ContentItem[]; /** One of the host's own fields, added to the form. Counterpart to {@link appendType}. */ export declare function appendField(popup: PopupModal, field: CustomFieldDef, atStep?: number): ContentItem[]; /** * A new item dropped onto a spot the author picked on the canvas, rather than * appended. `make` builds it (a built-in type, or one of the host's fields) and * `at` is where the drop landed: beside an item, or above or below it. * * The item joins the list at the end and is then *moved* into place by the same * {@link dropItem} a reorder goes through, so an element dragged in obeys every * rule one dragged around already does — rows split evenly, a side drop onto a * full row falls back to its own line, and a step break keeps its line to * itself. Without a landing spot (`at` null: dropped on the form but not on any * item, which is what an empty step looks like) it appends, exactly as the * picker's click does. */ export declare function insertItem(popup: PopupModal, make: (items: ContentItem[]) => ContentItem, at: { targetId: string; edge: DropEdge; } | null, atStep?: number): ContentItem[]; /** * Start a new step at the end of the form. The break goes after every other * item, so the step it opens is the new last one — and since `normalizeItems` * sinks the submit button past the break, that new step is the one the button * lands on. Which is the rule the whole feature rests on: however the steps are * cut, the form is sent from the last of them. */ export declare function addStep(popup: PopupModal): ContentItem[]; /** * Drop the break that opens `atStep`, merging that step's items into the one * before it. Removing a step never removes what was on it: the author asked for * one fewer screen, not for their fields to be thrown away. Step 0 has no break * of its own, so it can't be removed. */ export declare function removeStep(popup: PopupModal, atStep: number): ContentItem[]; export declare function patchItem(items: ContentItem[], id: string, patch: Partial): ContentItem[]; /** Move `fromIndex` to `toIndex`, leaving the rest in order. */ export declare function moveItem(items: ContentItem[], fromIndex: number, toIndex: number): ContentItem[]; /** Move the item with `draggedId` onto the slot the item with `targetId` holds. */ export declare function moveItemBefore(items: ContentItem[], draggedId: string, targetId: string): ContentItem[]; /** * Take `id` out of the form and let the line it stood on close up. * * A field's width is not its own: it is the share of a line handed out by how * many fields are standing on it. Dragging one out of a pair already gives the * other its full width back — a delete has to do the same, or the survivor is * stranded at half the form with nothing beside it and nothing in the editor * that would widen it again. Both surfaces that delete (the canvas tool and the * sidebar row) come through here, so neither can drift from the other. */ export declare function removeContentItem(items: ContentItem[], id: string): ContentItem[]; /** * Apply a canvas drop: `draggedId` lands on `edge` of `targetId`. * * A side edge puts it on the target's line, and everything there splits the * width evenly. Above or below gives it a line of its own. Either way the rows * it left behind close up and re-spread, so pulling one of two halves away * leaves the other at full width rather than stranded at half. */ export declare function dropItem(items: ContentItem[], draggedId: string, targetId: string, edge: DropEdge): ContentItem[];