@n-uf/docking 0.0.0-stage → 26.11.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1439 @@
1
+ import { Size, Rect, Target, Point } from '@n-uf/placement';
2
+ import { CrossLimits, StackForm, StackFormKind, StackFit, StackNote } from '@n-uf/placement/stack';
3
+
4
+ /**
5
+ * The state's shapes: one model of a whole window. A state is a stage (the window's inner rect), the edges along its
6
+ * sides (bars and columns, each a stack of items), the items, the floats above the content, and the rects (`keepClear`) that
7
+ * floats and drop zones keep clear of. `solve(state)` turns it into a `DockLayout`: every rect a host draws.
8
+ *
9
+ * Plain data in and out, nothing module-global: two windows on one page are two states. No words, no time, no DOM.
10
+ * What the shapes tell on their own (an edge's axis, an item's zone and forms, how it floats) is in `./helpers`.
11
+ */
12
+
13
+ /** The host's kinds of item, such as "panel" and "group". An edge takes only the kinds it lists. */
14
+ type Kind = string;
15
+ /** A side of the stage. Left and right edges are columns (they run down); top and bottom edges are bars (they run across). */
16
+ type Side = "top" | "right" | "bottom" | "left";
17
+ declare const SIDES: readonly Side[];
18
+ /** Where an item sits along its edge: packed from the start, centered in the spare length, or packed from the end. */
19
+ type Zone = "start" | "center" | "end";
20
+ declare const ZONES: readonly Zone[];
21
+ /** A float that follows the content: flush with that side or corner of `layout.content` until a drop gives it a real rect. */
22
+ type FloatAnchor = "content-top-left" | "content-top" | "content-top-right" | "content-right" | "content-bottom-right" | "content-bottom" | "content-bottom-left" | "content-left";
23
+ declare const FLOAT_ANCHORS: readonly FloatAnchor[];
24
+ /**
25
+ * An anchor with an offset: flush with `at`'s side or corner of the content, then `dx` px to the right and `dy` px down
26
+ * (negative: left, up; default 0). It still follows the content, so a host stores "the top-right corner, 12 px down"
27
+ * rather than a pixel position.
28
+ */
29
+ interface FloatAnchorOffset {
30
+ readonly at: FloatAnchor;
31
+ readonly dx?: number;
32
+ readonly dy?: number;
33
+ }
34
+ /** Where an anchored float sits: an anchor's name, or one with an offset. */
35
+ type FloatAnchorAt = FloatAnchor | FloatAnchorOffset;
36
+ /** Along which axis an item lies: a column runs down, a row (a bar) runs across. */
37
+ type Orient = "column" | "row";
38
+ interface DockItem {
39
+ readonly id: string;
40
+ readonly kind: Kind;
41
+ /**
42
+ * Its forms along a column and along a row (a bar), largest first, as `./stack` takes them. An item with no forms for
43
+ * an axis can't be laid out along it (`no-forms`).
44
+ */
45
+ readonly forms: {
46
+ readonly column?: readonly StackForm[];
47
+ readonly row?: readonly StackForm[];
48
+ };
49
+ /** How recently it was used: the smaller, the longer ago, the sooner it gives way. */
50
+ readonly used: number;
51
+ /** Kept: gives way after every item that isn't. */
52
+ readonly kept?: boolean;
53
+ /**
54
+ * Folded by hand when 1 or more (`foldItem` sets it to 1; default unset): it starts at its first folded form (a panel's
55
+ * `header`, a group's `fold`) among the forms of the axis it lies along, never one step down the ladder, and give-way
56
+ * steps down from there. A stored value past that form keeps its place (a state stored with a later form). With no
57
+ * folded form on that axis it draws unfolded (`canFold`). A float folded by hand is drawn as its bar: that form's
58
+ * natural length, at the float's place.
59
+ */
60
+ readonly from?: number;
61
+ /**
62
+ * Reserved room: a title, window controls, a page readout. It never changes form (it keeps `forms[from]`), is never
63
+ * reordered, never dragged, and no hit or slot covers it. Its length may shrink to its form's `main.min` and grow
64
+ * with spare room when the form `grows`; window controls have `min` equal to `natural`.
65
+ */
66
+ readonly fixed?: boolean;
67
+ /**
68
+ * A fixed item that yields: a movable item dropped after it in its zone may push it inward along the zone. Left out,
69
+ * a fixed item at a zone's anchor (window controls at a bar's end) keeps its place, so no gap after it is offered; a
70
+ * fixed item with `pushable` at the anchor (a state or page cell at a title bar's end) lets the gap after the run be a
71
+ * stop, a place a toolbar homed after it can be put back in. It keeps its order among the fixed items: no gap is
72
+ * offered between two `pushable` items. The rule is "a movable item dropped beside me, on my anchor's side, may push
73
+ * me inward", so in the start zone it is the mirror: the gap before a run of `pushable` items at the edge's start (a
74
+ * title at a title bar's start) is a stop, and a drop there pushes them inward. A declaration of the state like
75
+ * `DockEdge.zoneAccepts`: `readDockState` takes it from `base`, `storeDockState` never writes it.
76
+ */
77
+ readonly pushable?: boolean;
78
+ /** Closed: it keeps its place in its edge (or its float rect) but takes no room and has no targets. */
79
+ readonly closed?: boolean;
80
+ /**
81
+ * Its zone (default start): the item's own, not its edge's. It lies there where its edge takes its kind there, else in
82
+ * the first zone that does (`zoneIn`). Only a drop that names a zone (a gap in a zone, `moveTo` with `zone`) on an edge
83
+ * offering a choice (`namesZone`: more than one of its zones takes the kind) sets it.
84
+ */
85
+ readonly align?: Zone;
86
+ /**
87
+ * Free space it keeps on its zone's open side, px: before it in a start zone, after it in an end zone (none in a center
88
+ * zone), out of the edge's spare length, so an item dropped partway along a free stretch of a bar stays there. When
89
+ * items ask for more than the spare length, each gets its share. A dock move sets it (`DockPlace.space`) or clears it.
90
+ */
91
+ readonly space?: number;
92
+ /**
93
+ * Its give-way priority in its edge (default: the edge's `priority`, else 0). When an edge runs short, items step down
94
+ * their forms (row, wrap in a column, icons, then the edge's » menu) lowest priority first, ties to the one used longest
95
+ * ago; room coming back brings them up in the exact reverse order, each to its remembered form. It adds to every one
96
+ * of its forms' `rank` (`./stack`), so a host may still rank single forms. Give the controls that must stay out of the
97
+ * menu the highest priority.
98
+ */
99
+ readonly priority?: number;
100
+ /**
101
+ * The length a person asked it to have along its edge, px, per axis: `column` for an item in a side column, `row` for
102
+ * one in a bar (default none; `StackLengths` in `@n-uf/placement/stack`). While it is in a form that grows, `solve`
103
+ * hands it to the edge's stack, which reads it in place of the form's natural: spare length goes in proportion to the
104
+ * asked lengths, a short edge interpolates toward the least. It is per axis, so an item moved to an edge of the other
105
+ * axis never reads it, and it travels with the item when it moves, closes and reopens. It is in ask units, not drawn
106
+ * px: with room to spare a drawn size is the ask times the shared scale, or its least when that is more (a 0 is no length). `resizeBetween` and `resetBetween` set it for
107
+ * the pair only; `resetLengths` clears it; `storeDockState` keeps it. A state that declares none lays
108
+ * out exactly as before.
109
+ */
110
+ readonly lengths?: {
111
+ readonly column?: number;
112
+ readonly row?: number;
113
+ };
114
+ /**
115
+ * Its size as a float, per orient: `floatAt` with no rect uses the one for the orient it floats in, and a float drop or
116
+ * a hand resize sets it for the orient the float is in, so a float turned to the other orient (`orientFloat`) takes that
117
+ * orient's size and, turned back, its own again. Without one for an orient, a float takes its first form's natural size
118
+ * along that orient (`floatSizeOf`), or `DEFAULT_FLOAT_SIZE` when that form grows (a panel's card).
119
+ */
120
+ readonly floatSizes?: {
121
+ readonly row?: Size;
122
+ readonly column?: Size;
123
+ };
124
+ /**
125
+ * Which of its forms it uses as a float when the float names no `orient` (`floatOrientOf`). Default: the axis of its
126
+ * first form, the first of `forms.row` / `forms.column` it declares (a group declared row first floats as a row).
127
+ */
128
+ readonly floatOrient?: Orient;
129
+ /**
130
+ * The least a float of it is shrunk to: a float larger than the region floats lie in is laid out at
131
+ * `max(floatMin, min(its size, the region))` each way. A floor wider than the region keeps it at the region's left
132
+ * edge; one taller than the stage keeps it at the stage's top and runs past its bottom. A folded float (its header
133
+ * form) keeps its height. Without it, a shrink stops at the form's own minimums.
134
+ */
135
+ readonly floatMin?: Size;
136
+ /**
137
+ * The most a float of it is laid out at, each way (optional, the same shape as `floatMin`, never under it): a larger
138
+ * float rect is drawn at this size, its top-left corner kept (a folded float keeps its bar's height), and `fitResize`
139
+ * stops a resize here (`"max"`).
140
+ */
141
+ readonly floatMax?: Size;
142
+ }
143
+ interface DockEdge {
144
+ readonly id: string;
145
+ readonly side: Side;
146
+ /** 0 is the outermost on its side (a title bar outside a toolbar). */
147
+ readonly ring: number;
148
+ /**
149
+ * Top and bottom bars only: across the whole stage (`"full"`, the default) or between the side columns
150
+ * (`"between"`). Left and right edges ignore it. An overlay bar (`mode: "overlay"`) lies over the content, between
151
+ * the columns, unless it sets `span: "full"` by name: then it runs across the full bars' width, over the side columns
152
+ * too. Left out on an overlay bar, it means the content's width, as it always has.
153
+ */
154
+ readonly span?: "full" | "between";
155
+ /** The kinds a drop may bring here. Deny by default: an empty list takes nothing (an anchor). */
156
+ readonly accepts: readonly Kind[];
157
+ /** Ids in order, fixed and closed items included. */
158
+ readonly items: readonly string[];
159
+ /** The size it may take across (a column's width, a bar's height), and the rail width when nothing sets it. */
160
+ readonly cross: CrossLimits;
161
+ /** `"overlay"` lies over the content instead of shortening it (default `"reserved"`). */
162
+ readonly mode?: "reserved" | "overlay";
163
+ readonly gap?: number;
164
+ readonly pad?: {
165
+ readonly start?: number;
166
+ readonly end?: number;
167
+ };
168
+ /** The » entry's length along the edge. */
169
+ readonly menu?: {
170
+ readonly main: number;
171
+ };
172
+ /**
173
+ * The user's size across (a column dragged wider), clamped to `[max(cross.min, the widest open setter's cross.min),
174
+ * cross.max]`, so an open item's `cross.min` wins over a smaller size. Used only while an item sets the cross size.
175
+ */
176
+ readonly size?: number;
177
+ /** A column drawn as a rail (nothing in it sets its width) shows its closed items too, as tabs marked `closed`. */
178
+ readonly railShowsClosed?: boolean;
179
+ /**
180
+ * An icons-only edge (a thin rail of vertical toolbars along a window side): its items take only their `icons` form
181
+ * (and the » menu after it), stacked, each grip the divider. An item with no `icons` form is left out
182
+ * (`no-icons-form`).
183
+ */
184
+ readonly compact?: boolean;
185
+ /**
186
+ * The kinds each zone takes, narrowing `accepts`: with it, a zone not listed takes nothing. A panel column with
187
+ * `{ start: ["panel"], end: ["group"] }` has its panels at the top and a tray of toolbars at its foot (the end zone, one
188
+ * toolbar per row): a toolbar in the tray takes only its `wrap` or `icons` form (never the menu), and the panels give
189
+ * way first. An empty edge offers each third of its strip only to the kinds that third's zone takes (the others are
190
+ * refusals). A group never opens such a column on its own: an empty side column offers its strip only to the kinds
191
+ * its start zone takes (a panel gets its top third; a group none, the rail's instead).
192
+ */
193
+ readonly zoneAccepts?: ZoneAccepts;
194
+ /**
195
+ * The zones the edge has, in any order (default all three). `["start"]` makes it one stack along its whole length, as
196
+ * a side rail drawn in order: its whole length offers the start zone's gaps, ordered by position along it, with no
197
+ * center or end gaps and no refusal of a kind it takes; a drop on it names no zone (`namesZone`), so the item keeps
198
+ * its own `align`; and an item whose `align` names a zone it doesn't have lies in its zone (`zoneIn`), its stored
199
+ * `align` unchanged (so it is back in its own zone when lent to a bar through `showIn`). Two zones (`["start", "end"]`)
200
+ * split the length between them as three split it in thirds, the boundary at the middle, moved past the cards seen in
201
+ * them. Setting `zones`, even to all three, always splits the length evenly among its zones (each boundary then moved
202
+ * past the cards seen on either side); leaving it out keeps the edge kind's own spans, a column's as the solver lays
203
+ * its zones out. Entries that aren't zones and repeats are ignored; a list with no zone counts as all three. With
204
+ * `zoneAccepts`, a zone takes a kind only where both say so. Like `zoneAccepts`, a declaration: never stored, from
205
+ * `base` on `readDockState`.
206
+ */
207
+ readonly zones?: readonly Zone[];
208
+ /** The drop strip's depth while the edge is empty, px (default {@link DEFAULT_STRIP}). */
209
+ readonly strip?: number;
210
+ /**
211
+ * How a gap's hit runs along the edge. The gaps always split the edge halfway between neighboring insertion lines, so
212
+ * free space and short items (a toolbar, a closed or folded panel) are covered end to end. A number: over an open
213
+ * item's body only (a panel), the hit narrows to a band that many px around the line, so the middle of a panel is no
214
+ * gap and the pointer falls through to the float target, or to none. `"middle"`: no band, so panels are split too.
215
+ * Default {@link DEFAULT_HIT_BAND}.
216
+ */
217
+ readonly hitBand?: number | "middle";
218
+ /**
219
+ * `"side"`: a static edge whose fixed item (an anchor: page thumbnails) the user may drag to the other side of the
220
+ * edge's axis. `targets` then offers that item one target, `side:<other side>`, over the place the edge takes there
221
+ * (`setSide`); its own place is home. Left out, a fixed item has no targets.
222
+ */
223
+ readonly moves?: "side";
224
+ /**
225
+ * `true`: the user may fold this edge's fixed items (an anchor) by hand, like a panel: `foldItem(state, id, true)` shows
226
+ * it in its rail form, `foldItem(state, id, false)` reopens it, and `storeDockState` / `readDockState` keep it folded.
227
+ * Left out, `foldItem` leaves a fixed item as it is.
228
+ */
229
+ readonly foldable?: boolean;
230
+ /**
231
+ * A dynamic column (left and right only): made by a drop on a column line, deleted when it holds no item, folded whole
232
+ * into its side's rail by give-way (`DockState.contentMin`) or when every member is folded by hand. Its `accepts`,
233
+ * `cross`, `gap`, `pad`, `menu`, `zoneAccepts` and `hitBand` come from `DockState.columns[side]` when the changes make it;
234
+ * with no `hitBand` of its own it reads the template's.
235
+ */
236
+ readonly column?: boolean;
237
+ /**
238
+ * An anchor edge (a left or right edge that takes nothing, holding a fixed item such as a thumbnail strip) lies outside
239
+ * `DockState.inset` and the gutter: at the window's side, the inset after it, toward the content. A full top or bottom bar
240
+ * with it lies at the window's edge, full width, the inset after it; the side edges then run between such bars (an
241
+ * anchor through the inset beside them). On a left or right side, from the window's side inward: its toolbar bars
242
+ * with it (`isOutsideSideBar`), the side's rail, its anchors, the inset, the columns.
243
+ */
244
+ readonly outsideInset?: boolean;
245
+ /**
246
+ * A static left or right edge that gives way like a dynamic column: it shrinks toward its minimum, then folds whole
247
+ * into its side's rail, in give-way order with the columns (its items' ages). It is never deleted.
248
+ *
249
+ * On a top or bottom bar (reserved or overlay), it gives way by height: while the content is shorter than
250
+ * `contentMin.height` (overlay bars counted), such bars shrink across toward their minimum (`cross.min`, and each
251
+ * open item's form's `cross.min`), then fold, their items stepping to the next form that fits across (a panel's
252
+ * title bar), unkept before kept, the oldest newest use first, the outer first (`bar-shrunk`, `bar-folded`). Room
253
+ * coming back undoes it in reverse. A bar never draws an item thinner across than its form's `cross.min`.
254
+ */
255
+ readonly giveWay?: boolean;
256
+ /**
257
+ * The default give-way priority of its items (`DockItem.priority` wins; default 0): a title bar given a lower one has
258
+ * its toolbars step down before an item moved in from another bar would.
259
+ */
260
+ readonly priority?: number;
261
+ /**
262
+ * Hidden: kept in the state with its items, but not in the window (a bar a host doesn't draw, a rail it has turned
263
+ * off). View state: the host decides it each time it builds the state, and the store never writes it. A hidden edge
264
+ * takes no room, and everything else lays out exactly as if it weren't in the state; `solve` leaves it and its items
265
+ * out of the layout (no `edges[id]`, no `items[id]`, as for an item placed nowhere), so nothing reads a rect of it.
266
+ * Its items take no part in give-way or folds. It has no targets and no refusals for any kind, no keyboard stops, and
267
+ * its items have none either (dragging one gives nothing); `moveTo` into it is refused as into an edge that doesn't
268
+ * take the kind. Its items stay in it, and `storeDockState` / `readDockState` keep them. A column a drop makes never takes a
269
+ * hidden edge's id; where a drop makes or removes a column on its side, the side is numbered again with the hidden
270
+ * edge back at its own place. Side columns, rails and bars alike. With `showIn`, its items show elsewhere instead.
271
+ */
272
+ readonly hidden?: boolean;
273
+ /**
274
+ * Where a hidden edge's items show while it is hidden: the id of another static edge, shown. Its items are laid out, targeted
275
+ * and stopped as if they sat in that edge after its own items (`solve` reports them there), each that edge takes the
276
+ * kind of, in its own zone where that edge takes it there, else in the first that does; a fixed item, or one whose
277
+ * kind that edge takes nowhere, is left out as without `showIn`. They stay in the hidden edge in the state: a drop that
278
+ * commits a move of one takes it out, to the drop's place; its home, and any drop of another item, leaves them where
279
+ * they are. A moved item keeps its stored zone, unless the drop names one (a gap). `canFold`, `foldItem` and the hand
280
+ * fold read a lent item along the edge it is drawn in. View state like `hidden`: the store never writes it. Naming the
281
+ * edge itself, no edge, another hidden edge or a dynamic column (`column: true`: drops make and delete those) is
282
+ * ignored (`show-in-ignored`). No effect on an edge that isn't hidden.
283
+ */
284
+ readonly showIn?: string;
285
+ }
286
+ /** What a side's new columns are made from. */
287
+ interface ColumnTemplate {
288
+ readonly accepts: readonly Kind[];
289
+ readonly cross: CrossLimits;
290
+ readonly gap?: number;
291
+ readonly pad?: {
292
+ readonly start?: number;
293
+ readonly end?: number;
294
+ };
295
+ readonly menu?: {
296
+ readonly main: number;
297
+ };
298
+ /** The kinds each zone takes in the columns made from it (`DockEdge.zoneAccepts`). */
299
+ readonly zoneAccepts?: ZoneAccepts;
300
+ /**
301
+ * How a gap's hit runs over the open panels of the columns made from it (`DockEdge.hitBand`): a band that many px about
302
+ * each line, or `"middle"` (a drop on a panel's upper or lower half means the gap before or after it). Default
303
+ * {@link DEFAULT_HIT_BAND}.
304
+ */
305
+ readonly hitBand?: number | "middle";
306
+ }
307
+ /** Per zone, the kinds it takes. */
308
+ type ZoneAccepts = Readonly<Partial<Record<Zone, readonly Kind[]>>>;
309
+ /** How a side's rails show their items: their titles while they fit (the default), or their tiles only. */
310
+ type RailMode = "titles" | "icons";
311
+ declare const RAIL_MODES: readonly RailMode[];
312
+ /** A side's one rail strip: folded columns show in it as segments, in ring order. */
313
+ interface RailSpec {
314
+ /** Its width, px. */
315
+ readonly width: number;
316
+ /** The kinds a drop on the rail may bring (it docks folded). */
317
+ readonly accepts: readonly Kind[];
318
+ }
319
+ /** When a host draws a side's rail drop strip: while an item of the kind is held (the default), always, or never. */
320
+ type RailVisibility = "whileDragging" | "always" | "never";
321
+ declare const RAIL_VISIBILITIES: readonly RailVisibility[];
322
+ /** The least width of a rail drop strip, px: a target at the window's edge stays easy to hit (Fitts's law). */
323
+ declare const RAIL_STRIP_MIN = 24;
324
+ /** How far an armed rail drop strip grows inward by default, px, so a hand that wobbles once armed keeps it. */
325
+ declare const DEFAULT_RAIL_MAGNET = 6;
326
+ /**
327
+ * How long a rail target or a new-column line against the window's left or right edge holds before it shows with its
328
+ * room, ms (`Target.roomHold`): none. It shows, with its room, on the frame the pointer enters it (an aiming pointer),
329
+ * so a toolbar held at the window's edge never jumps away across the column and back. The cost: grazing the window's
330
+ * edge with a held item opens its rail.
331
+ */
332
+ declare const EDGE_ROOM_HOLD = 0;
333
+ /**
334
+ * How an item of one kind drops into a side's rail (`DockState.railDrop[kind]`): the geometry of its drop strip. Each kind
335
+ * has its own; a kind with none keeps the rail targets as they were (immediate, no strip).
336
+ *
337
+ * With a policy, each side whose rail can take the kind shows one drop strip at the window's side, at the rail's real
338
+ * width, even while the rail is empty: its targets are `rail:<side>:<ring>` with `arm: "dwell"` (spring-loading: the
339
+ * drag intent arms them on a dwell), `armedHit` (the strip grown by `magnet`) and `strip` (the rect to draw). The strip
340
+ * owns its rect: a drop there is the rail's once armed, the float's before. The side's rail is `DockState.rails[side]`
341
+ * where the state declares one, else the side's outermost column that takes the kind in its start zone ("the column
342
+ * drawn as a rail"): a drop there docks the item in it as a collapsed header, a rail tile once nothing in it sets its
343
+ * width. The strip means "collapse it at this side": the drop is `moveTo` that side's rail, and lands wherever the
344
+ * state shows a collapsed panel there (a rail tile, a rider bar under `handFold: "ride"`, a header); the slot is that.
345
+ */
346
+ interface RailDropPolicy {
347
+ /**
348
+ * The strip's width, px, from the window's side inward (default: the rail's drawn width). At least
349
+ * {@link RAIL_STRIP_MIN}; 0 turns the kind's rail docking off.
350
+ */
351
+ readonly railStripWidth?: number;
352
+ /** When the host draws the strip (default `"whileDragging"`); `"never"` turns the kind's rail docking off. */
353
+ readonly railVisibility?: RailVisibility;
354
+ /**
355
+ * How far the strip grows inward once armed, px (default {@link DEFAULT_RAIL_MAGNET}): the armed target's band
356
+ * (`armedHit`). Moving out past its outer edge disarms it, and re-entering the strip needs a new full dwell.
357
+ */
358
+ readonly magnet?: number;
359
+ /** Whether a float may sit inside the strip's area (default true); false keeps a float's rect clear of every strip. */
360
+ readonly floatNearEdge?: boolean;
361
+ }
362
+ interface DockFloat {
363
+ readonly id: string;
364
+ /** Its rect in stage px (it never scrolls with the content). With `anchor`, only its size counts. */
365
+ readonly rect: Rect;
366
+ /** Follow the content's side or corner (with an offset, `{ at, dx?, dy? }`) until a drop gives it a real rect. */
367
+ readonly anchor?: FloatAnchorAt;
368
+ /** Which of the item's forms it uses (default: the item's `floatOrientOf`). */
369
+ readonly orient?: Orient;
370
+ /**
371
+ * When it was floated, as a sequence: `floatAt` and `moveTo(…, { kind: "float" })` give a newly floated item one more
372
+ * than the largest `since` among the state's floats (1 when there are none); moving a float that already floats,
373
+ * `raiseFloat`, `markUsed` and `resizeFloat` keep it. Among anchored floats the earlier (smaller `since`, missing counting as 0, then
374
+ * the smaller id) wins the place both want.
375
+ */
376
+ readonly since?: number;
377
+ }
378
+ /**
379
+ * A rect the state keeps clear of, and who keeps clear: `"all"` (the default) for floats and drop targets alike (a
380
+ * slot or a target's landing never lies on it), `"floats"` for floats alone: their placement, drops, opening, a
381
+ * window resize and a resize by hand keep clear of it, while the edges, give-way and every docked target ignore it (a
382
+ * spine the host draws over a column).
383
+ */
384
+ type KeepClear = Rect & {
385
+ readonly for?: "all" | "floats";
386
+ };
387
+ interface DockState {
388
+ /** The window's inner rect. */
389
+ readonly stage: Rect;
390
+ readonly edges: readonly DockEdge[];
391
+ readonly items: Readonly<Record<string, DockItem>>;
392
+ /** Stacking order: the last is on top. */
393
+ readonly floats: readonly DockFloat[];
394
+ /** The kinds that may float. Deny by default. */
395
+ readonly floatKinds: readonly Kind[];
396
+ /**
397
+ * Rects the state keeps clear of (a title the host draws itself, a status line): by default floats and drop targets
398
+ * both; an entry with `for: "floats"` (a spine drawn over a column) only floats. See {@link KeepClear}.
399
+ */
400
+ readonly keepClear?: readonly KeepClear[];
401
+ /** Spots where a release cancels: `targets` gives a `none` target over each. */
402
+ readonly blocked?: readonly Rect[];
403
+ /** Per side (left, right): what a new column is made from. A side without one gets no new columns. */
404
+ readonly columns?: Partial<Record<"left" | "right", ColumnTemplate>>;
405
+ /** Per side (left, right): its rail. A side without one keeps folded columns as columns. */
406
+ readonly rails?: Partial<Record<"left" | "right", RailSpec>>;
407
+ /**
408
+ * Per side (left, right): how its rails show their items (default `"titles"`). It covers every rail on the side: a
409
+ * column drawn as a rail (nothing in it sets its width) and the side's rail strip (`rails`). `"titles"` offers the
410
+ * items' title rail forms (`StackForm.title`), each stepping down to its tile by the ladder when the rail runs short;
411
+ * `"icons"` passes them over, so every item shows its tile. An item with no title form shows its tile either way. A
412
+ * side needs no `rails` entry to have a mode: a column drawn as a rail reads it too. `storeDockState` keeps it.
413
+ */
414
+ readonly railModes?: Partial<Record<"left" | "right", RailMode>>;
415
+ /**
416
+ * Per item kind: how it drops into a side's rail ({@link RailDropPolicy}), keyed by the state's own kind strings.
417
+ * Tuning one kind never changes another; a kind left out keeps the rail targets it had.
418
+ */
419
+ readonly railDrop?: Readonly<Partial<Record<Kind, RailDropPolicy>>>;
420
+ /**
421
+ * `"end"`: no drop changes an item's collapsed state. For an item arriving from elsewhere, collapsed titles are one
422
+ * drop place over their whole length, their tiles included, after the last member: a column drawn as a rail, or on a
423
+ * side with a declared `rails` entry the rail itself (the end of its last folded column). An open item opens that
424
+ * column at full size, a collapsed one becomes the last tile. A tile keeps its place among its own rail's tiles. No
425
+ * rail drop strip (`railDrop`) is offered, and on a declared rail no stop folds an open item. Absent: as before. A
426
+ * declaration, like `zoneAccepts`: never stored.
427
+ */
428
+ readonly foldedColumnDrop?: "end";
429
+ /**
430
+ * `"one"`: a side has at most one column (`isSideColumn`). A drag offers a new-column line only on a side with no
431
+ * column holding an item once the item is lifted; where the side has one, an item goes into it (by its gaps) or
432
+ * nowhere on that side. A stored layout with two columns on a side is merged by `mergeSideColumns`, which a host calls
433
+ * as it reads one. Absent: as before. A declaration, like `foldedColumnDrop`: never stored.
434
+ */
435
+ readonly sideColumns?: "one";
436
+ /**
437
+ * `"nearest"`: a bar's zones (start, center, end) meet halfway between the landing rects either side of each boundary,
438
+ * so the pointer picks the zone whose landing is nearest it. Absent: at thirds of the bar's length (each boundary moved
439
+ * past the cards seen beside it, as now). A declaration, like `foldedColumnDrop`: never stored. It moves each zone's
440
+ * extent, so it changes which zone a pointer picks among `targets()` (the hit areas a drag intent reads), and, since a
441
+ * zone left with no room gets no drop, which of a bar's drops exist and where its refused stretches lie. Under a
442
+ * landing model `lanes()` cuts between spots by their landings, not by zones: there it changes which spots and
443
+ * refused stretches a bar has, never the rule that cuts between spots (the cuts follow whichever spots exist).
444
+ */
445
+ readonly barZones?: "nearest";
446
+ /**
447
+ * The least the content may be. While the content is narrower than `width`, dynamic columns shrink toward their
448
+ * minimum, then fold whole into their side's rail: unkept before kept, the one whose newest use is oldest first, the
449
+ * outer first, the left first. Under `height`, a `content-short` note.
450
+ *
451
+ * `chromeWidth` (optional, px, at most `width`): a lower floor for chrome. The side edges that hold toolbars, not
452
+ * panels (compact rails and side toolbar bars, `isSideBar`), may take the content down to it while the columns keep
453
+ * their width. A compact rail or side toolbar bar counts only where its side has a column template or a declared rail
454
+ * to tell it from a panel column (`isSideBar`): on a side with neither it is not chrome and gets no floor benefit.
455
+ * A floor of 0 or less lets chrome take all the content. The columns only move aside: a toolbar rail added at an edge
456
+ * narrows the content, not the column. Below the floor a
457
+ * column shrinks, then folds, as without it. The columns alone still leave `width`. Chrome within that allowance is
458
+ * quiet: a content it narrows between the two floors carries no `content-narrow`, and `columnRoom` stays true, so a
459
+ * toolbar rail never flips a host to its narrow layout. `content-narrow` fires when the columns' own need takes the
460
+ * content under `width` (its `min`: `width` less what chrome takes within the allowance), or once it is under the
461
+ * floor. Width only: bars give way by `height` as before.
462
+ */
463
+ readonly contentMin?: {
464
+ readonly width: number;
465
+ readonly height: number;
466
+ readonly chromeWidth?: number;
467
+ };
468
+ /**
469
+ * How a column folded by hand shows (default `"bar"`): `"bar"` sends it to its side's rail; `"ride"` draws each of its
470
+ * members as a title bar over the first open column of its side (stacked, in zone order), at that column's width,
471
+ * taking no width of their own.
472
+ */
473
+ readonly handFold?: "bar" | "ride";
474
+ /**
475
+ * Space kept clear inside the stage's edges, px (default 0 each). Floats are clamped into the stage less its left and
476
+ * right (the stage's full height), and shrunk to fit that region when larger.
477
+ */
478
+ readonly inset?: {
479
+ readonly top?: number;
480
+ readonly right?: number;
481
+ readonly bottom?: number;
482
+ readonly left?: number;
483
+ };
484
+ /**
485
+ * When `inset` applies (default `"always"`): `"docked"` keeps it only while a panel is docked beside the content (an
486
+ * open panel column or a rail showing panels: a left or right edge that takes something, with an item that isn't
487
+ * closed or fixed and whose first column form is `open`, `header` or `rail`). Bars, toolbar groups and an anchor
488
+ * never count, wherever they sit; with no panel there, the content is the whole stage.
489
+ */
490
+ readonly insetWhen?: "always" | "docked";
491
+ /** Space after each left or right edge and each rail that takes room, toward the content, px (default 0). */
492
+ readonly gutter?: number;
493
+ }
494
+ /** An item as laid out. */
495
+ interface DockItemLayout {
496
+ /** Stage px. An item in the » menu has the menu entry's rect. */
497
+ readonly rect: Rect;
498
+ readonly kind: Kind;
499
+ /**
500
+ * The axis it lies along, for every item: a placed item's edge's (a bar's items lie along a row, a column's and a
501
+ * rail's along a column, whatever form they took: a bar's icons form is a row), a float's orient. `form` indexes the
502
+ * forms of this axis. Hosts read it here, never from `formKind`.
503
+ */
504
+ readonly axis: Orient;
505
+ /** The form it took: an index into the forms of its axis. */
506
+ readonly form: number;
507
+ readonly formKind: StackFormKind;
508
+ /** Docked: its edge and zone. */
509
+ readonly edge?: string;
510
+ readonly zone?: Zone;
511
+ readonly floating?: boolean;
512
+ readonly inMenu?: boolean;
513
+ /** A rail tab (its column is a rail). */
514
+ readonly tab?: boolean;
515
+ /** A closed item shown as a rail tab (`railShowsClosed`). */
516
+ readonly closed?: boolean;
517
+ readonly fixed?: boolean;
518
+ /** Drawn as a segment of this side's rail (its column is folded). */
519
+ readonly rail?: "left" | "right";
520
+ /**
521
+ * Drawn in its title rail form (`StackForm.title`) on a rail of this side: a column drawn as a rail or the side's rail
522
+ * strip. The host turns the title to run along the rail and reads it toward the content: on the left from bottom to
523
+ * top (turned −90°), on the right from top to bottom (+90°), the count at the title's end.
524
+ */
525
+ readonly railTitle?: "left" | "right";
526
+ /** Drawn as a title bar riding on this column (`handFold: "ride"`). */
527
+ readonly rides?: string;
528
+ /** Its column folded: by hand (every member folded) or by give-way. */
529
+ readonly folded?: "hand" | "auto";
530
+ /**
531
+ * Why this item is drawn smaller than its first form, read from the state's own state, never inferred from the rects:
532
+ * `"hand"` when it is folded by hand (`DockItem.from` over 0, which `foldItem` sets), `"auto"` when it gave way (a form
533
+ * below the one it started in, by length or width, a » menu entry included: the same word `folded` uses for a column
534
+ * folded by give-way). Absent when the item shows its first form, is closed, or lies in an icons-only edge in the form
535
+ * that edge gives it. By hand wins: a hand-folded item that gave way further is `"hand"`, since expanding it
536
+ * (`foldItem(state, id, false)`) is the user's to do, so a host shows "Expand" for `"hand"` only. A float is only ever
537
+ * folded by hand. `folded` is about the item's column; this one is about the item.
538
+ */
539
+ readonly foldedBy?: "hand" | "auto";
540
+ /** A `wrap` form: the word indexes per row (the words wrap beside the grip, a hanging indent). */
541
+ readonly rows?: readonly (readonly number[])[];
542
+ /** Its grip: a `wrap` form's lead cell at the start of row one, or a form's `grip` strip (an icons strip's, on top). */
543
+ readonly grip?: Rect;
544
+ /**
545
+ * The control ids the form it took leaves out (`StackForm.hides`), empty when it hides none or sits in a » menu: a host
546
+ * draws a "+N" control with them. `form` already names the variant.
547
+ */
548
+ readonly hidden: readonly string[];
549
+ /**
550
+ * The chosen form's `StackForm.tiers`: each shown control's tier by control id, for a group whose forms `controlLadder`
551
+ * generated; absent for a hand-written form, a `fold`, a `menu` and a » menu entry. Each is always a valid index into
552
+ * the control's own `tiers`. A host draws each control at `tiers[id]` and leaves out the `hidden` ones.
553
+ */
554
+ readonly tiers?: Readonly<Record<string, number>>;
555
+ }
556
+ /** An edge as laid out. */
557
+ interface DockEdgeLayout {
558
+ readonly side: Side;
559
+ readonly ring: number;
560
+ /** Stage px: the strip it takes (zero across when nothing is drawn in it). */
561
+ readonly rect: Rect;
562
+ /** Its size across. */
563
+ readonly cross: number;
564
+ /** Its » entry and the items in it, or null. */
565
+ readonly menu: {
566
+ readonly rect: Rect;
567
+ readonly items: readonly string[];
568
+ } | null;
569
+ /**
570
+ * Its items in the edge's order: the zones in order (start, center, end), then the order within each zone, the order
571
+ * `solve` lays them in. Exactly the ids `DockLayout.items` draws for this edge (`DockItemLayout.edge`): an item in the
572
+ * » menu keeps its place (`menu.items` names those, so a host wanting the docked ones filters them out), a rail tab is
573
+ * listed, and a closed item is left out (unless it shows as a rail tab). A column folded into its rail or riding lists
574
+ * its members in zone order. Never sort rects to learn it.
575
+ */
576
+ readonly items: readonly string[];
577
+ /** The ids drawn as rail tabs, in order (empty unless the column is a rail). */
578
+ readonly tabs: readonly string[];
579
+ /**
580
+ * The stack fits behind it, in stack-local px: `stack` is the one drawn, `free` the first fit (before `size` or the
581
+ * rail re-solved it). `solve`'s `previous` reads both; a host needs neither.
582
+ */
583
+ readonly stack: StackFit;
584
+ readonly free: StackFit;
585
+ /** A dynamic column folded into its side's rail (its rect is zero wide there): by hand or by give-way. */
586
+ readonly folded?: "hand" | "auto";
587
+ /** Shrunk by give-way below the size across it asks for: a column's width, a bar's height (`DockEdge.giveWay`). */
588
+ readonly shrunk?: boolean;
589
+ /** Riding on this column (its rect is the bars'). */
590
+ readonly rides?: string;
591
+ }
592
+ /** A side's rail as laid out. */
593
+ interface DockRailLayout {
594
+ readonly rect: Rect;
595
+ /** One per member of each folded column, in ring order. */
596
+ readonly segments: readonly {
597
+ readonly id: string;
598
+ readonly edge: string;
599
+ readonly rect: Rect;
600
+ }[];
601
+ /**
602
+ * The segments' fit along the rail, in rail-local px, while any of them offers a title form (titles step down to
603
+ * tiles by the ladder and come back in exact reverse): `solve`'s `previous` reads it; a host needs it not.
604
+ */
605
+ readonly stack?: StackFit;
606
+ }
607
+ /**
608
+ * Why the layout looks as it does:
609
+ * - a stack's note with its `edge` (`form-down`, `to-menu`, `too-wide`, `no-forms`, `overflow`);
610
+ * - `unknown-item`: an id in an edge or a float that `items` lacks (left out);
611
+ * - `twice`: an item placed in two places (the first in cut order wins, edges before floats);
612
+ * - `float-clamped`, `float-moved`: a float was moved into the stage, or clear of what it would cover;
613
+ * - `float-covers`: no clear place exists, and it covers the least it can.
614
+ * - `column-shrunk`, `column-folded`, `kept-folded`: give-way by `contentMin.width`, in give-way order;
615
+ * - `bar-shrunk`, `bar-folded`: give-way by `contentMin.height`, in give-way order: a top or bottom bar with `giveWay`
616
+ * shrank across (`from`, `to`), or its items stepped to the next form that fits (a panel's title bar);
617
+ * - `content-narrow`, `content-short`: the content is still under `contentMin` (overlay bars count against the height).
618
+ * With `contentMin.chromeWidth`, `content-narrow`'s `min` is `contentMin.width` less what chrome takes within its
619
+ * allowance; a host that says "needs at least …" reads `contentMin.width`, not the note's `min`.
620
+ * - `no-column-room`: not even one column at its minimum fits beside `contentMin.width` (`layout.columnRoom` false):
621
+ * `width` is the room the stage leaves, `need` the content's minimum plus that column and its gutter.
622
+ * - `content-changed`: under `previous`, `content` is not the rect `previous.content` was (`from`, `to`). A host refits
623
+ * its zoom only on this note.
624
+ * - `no-vertical-form`: an item left out of a vertical place (a rail, a vertical float) because only `wrap` forms are
625
+ * left to it (vertical means icons: give a word group an `icons` form).
626
+ * - `show-in-ignored`: a hidden edge's `showIn` names the edge itself, no edge, another hidden edge or a dynamic
627
+ * column; its items are left out as if it named none.
628
+ */
629
+ type DockNote = ({
630
+ readonly edge: string;
631
+ } & StackNote) | {
632
+ readonly code: "unknown-item";
633
+ readonly id: string;
634
+ } | {
635
+ readonly code: "twice";
636
+ readonly id: string;
637
+ } | {
638
+ readonly code: "float-clamped" | "float-moved" | "float-covers";
639
+ readonly id: string;
640
+ } | {
641
+ readonly code: "column-shrunk";
642
+ readonly edge: string;
643
+ readonly from: number;
644
+ readonly to: number;
645
+ } | {
646
+ readonly code: "column-folded" | "kept-folded";
647
+ readonly edge: string;
648
+ } | {
649
+ readonly code: "bar-shrunk";
650
+ readonly edge: string;
651
+ readonly from: number;
652
+ readonly to: number;
653
+ } | {
654
+ readonly code: "bar-folded";
655
+ readonly edge: string;
656
+ } | {
657
+ readonly code: "no-column-room";
658
+ readonly width: number;
659
+ readonly need: number;
660
+ } | {
661
+ readonly code: "content-narrow";
662
+ readonly width: number;
663
+ readonly min: number;
664
+ } | {
665
+ readonly code: "content-short";
666
+ readonly height: number;
667
+ readonly min: number;
668
+ } | {
669
+ readonly code: "content-changed";
670
+ readonly from: Rect;
671
+ readonly to: Rect;
672
+ } | {
673
+ readonly code: "no-vertical-form";
674
+ readonly id: string;
675
+ readonly edge?: string;
676
+ } | {
677
+ readonly code: "no-icons-form";
678
+ readonly id: string;
679
+ readonly edge: string;
680
+ } | {
681
+ readonly code: "show-in-ignored";
682
+ readonly edge: string;
683
+ };
684
+ type DockNoteCode = DockNote["code"];
685
+ interface DockLayout {
686
+ /** Every item drawn (closed items only when shown as rail tabs). */
687
+ readonly items: Readonly<Record<string, DockItemLayout>>;
688
+ readonly edges: Readonly<Record<string, DockEdgeLayout>>;
689
+ /** What is left for the content (the pages). Overlay edges lie over it. */
690
+ readonly content: Rect;
691
+ /** The floats drawn, in stacking order (the last on top). */
692
+ readonly floats: readonly string[];
693
+ /** The rails shown (a side with a folded column). Hosts draw these. */
694
+ readonly rails: Readonly<Partial<Record<"left" | "right", DockRailLayout>>>;
695
+ /**
696
+ * Where each side's rail lies, or would lie were one shown, for every side that has a rail (`DockState.rails`), drawn or
697
+ * not: the place a drop into the rail lands (`targets` reads it). Hosts draw `rails`, never `railPlaces`.
698
+ */
699
+ readonly railPlaces: Readonly<Partial<Record<"left" | "right", Rect>>>;
700
+ /**
701
+ * With `contentMin` and a dynamic column (or, before any exists, a `columns` template): whether one column at its
702
+ * minimum fits beside the content's minimum (`false` with a `no-column-room` note). Anchors and rails don't count:
703
+ * every column can fold into its rail. A host shows its narrow fallback (one panel over the content) while it is `false`.
704
+ */
705
+ readonly columnRoom?: boolean;
706
+ readonly notes: readonly DockNote[];
707
+ }
708
+ interface SolveOptions {
709
+ /**
710
+ * The layout the state had before: each edge's fit goes to `fitStack` as `previous`, so a press reshapes nothing. An
711
+ * item docked now that was closed or absent then has just opened. Opened beside items that stayed open in its edge, it
712
+ * counts as the newest (its largest form while it fits; the others give way by the usual rules) and its column is
713
+ * weighed anew. A closed item is not a removed one: opened into an edge whose items were all closed, it comes back as
714
+ * it was, with its age, and its column's folds (kept while it was closed) apply again.
715
+ */
716
+ readonly previous?: DockLayout;
717
+ /** Edge or item ids solved without `previous` (an edge, or the edges holding the item; a column weighed anew). */
718
+ readonly fresh?: readonly string[];
719
+ }
720
+ /** A drop strip's depth inside the content while an edge is empty, px. */
721
+ declare const DEFAULT_STRIP = 24;
722
+ /** A gap's hit over an open item's body (a panel): a band this many px around the gap's insertion line. */
723
+ declare const DEFAULT_HIT_BAND = 24;
724
+ /** A float's size when neither the item nor the call gives one, px. */
725
+ declare const DEFAULT_FLOAT_SIZE: Size;
726
+
727
+ /**
728
+ * `fitResize(state, id, rect, moving)`: the rect a float takes when the user drags some of its edges, clamped in one
729
+ * pass (no iteration) and with the limits that bound it. Hosts call it on every pointer move for the preview; the
730
+ * state change `resizeFloat(state, id, rect, moving)` commits the same rect, so the preview is the commit.
731
+ *
732
+ * It is not `fitFloat`: that one moves a float (never resizes it) to a clear place; this one resizes it with the edges
733
+ * not dragged kept put, and stops a dragged edge before anything `fitFloat` would move it off, so `solve` lays the
734
+ * result exactly where it is asked.
735
+ */
736
+
737
+ /** The edges of a float a resize drags; the others stay put. Left beats right, top beats bottom, when both are set. */
738
+ interface ResizeEdges {
739
+ readonly left?: boolean;
740
+ readonly right?: boolean;
741
+ readonly top?: boolean;
742
+ readonly bottom?: boolean;
743
+ }
744
+ /**
745
+ * Why a resized float isn't the rect asked for: `"min"` its least size (`floatMin`, else its open form's minimums),
746
+ * `"max"` its `floatMax`, `"region"` the region floats lie in (the stage less the inset at its left and right, its full
747
+ * height), `"docked"` what floats are kept clear of (a bar, a docked item, the chrome).
748
+ */
749
+ type ResizeLimit = "min" | "max" | "region" | "docked";
750
+ interface FloatResize {
751
+ /** The float's rect: what `resizeFloat` stores and `solve` draws. */
752
+ readonly rect: Rect;
753
+ /** The limits that bound it, in this order: min, max, region, docked. Empty when it is the rect asked for. */
754
+ readonly limits: readonly ResizeLimit[];
755
+ }
756
+ /**
757
+ * The rect float `id` takes for a resize: `rect` is the rect asked for in stage px (the float as drawn, with the
758
+ * `moving` edges where the pointer put them). In one pass: the edges not moving stay put; the size is at least the
759
+ * item's `floatMin` (else its open form's minimums, which only stop a shrink below the size drawn now, as `solve` lays
760
+ * it) and at most its `floatMax`; the float stays in the region floats lie in; every growing edge (a moving one, or the
761
+ * end of an axis not moving) stops at what floats are kept clear of, as drawn now (across first, over its height now;
762
+ * then along, over its new width), and such a stop beats the minimum. The rect is then laid by the one clamp `solve`
763
+ * lays floats with, so `solve(resizeFloat(...))` draws exactly this rect. A float that already covers something (no clear
764
+ * place at its size) may move to a clear place once a resize opens one; the preview is still the commit, and
765
+ * `"docked"` says so. Such a float never grows over what it covers: a dragged edge that lies inside an obstacle stays
766
+ * where it is drawn (`"docked"`), so a resize never covers more than the float did. `limits` says which of these bound it.
767
+ *
768
+ * Null for anything but a float drawn at its first form when that form grows (a panel's card): a toolbar group's size
769
+ * comes from its forms, and so does a folded float's bar. Pure: it solves the state once, for what is drawn now.
770
+ */
771
+ declare function fitResize(state: DockState, id: string, rect: Rect, moving: ResizeEdges): FloatResize | null;
772
+
773
+ /**
774
+ * The state's pure changes. Each returns a new state and leaves the one it was given as it was; a change that can't
775
+ * apply (an unknown item or edge, a fixed item, a kind the edge or the float layer doesn't take) returns the state
776
+ * given, the same object, so `after === before` says nothing changed.
777
+ *
778
+ * - `moveTo(state, id, { edge, zone?, at })`: docks the item in that edge, before the `at`-th item of the zone (counting
779
+ * the zone's items without it, closed ones included), or at the zone's end. A zone named becomes the item's `align`
780
+ * where the edge offers a choice (`namesZone`: more than one zone takes the kind); on a one-zone edge, or with none
781
+ * named, the item keeps its own and docks in the zone it lies in there (`zoneIn`: its own where the edge takes it
782
+ * there, else the first that does). A new column, a rail and `dockHome` name none either: the item's zone is its own.
783
+ * `{ kind: "column", side, ring }` makes a new column from `state.columns[side]` at that ring (`Infinity`: the side's
784
+ * inner end, "Move to › Dock left"); `{ kind: "rail", side, ring }` does the same with the item folded by hand, so it
785
+ * shows in the rail (on a side with no declared rail, `DockState.rails`, its rail is its outermost column that takes the
786
+ * kind, "the column drawn as a rail": the item docks at the end of its start zone as a collapsed header, folded by
787
+ * hand, a rail tile once nothing there sets the width); `{ kind: "float", rect?, anchor? }` floats it. A dynamic column an item leaves empty is deleted
788
+ * and its side's rings are closed up.
789
+ * - `homeFor(state, id, start)`: the place a start state gives the item, for `moveTo`.
790
+ * - `floatAt(state, id, rect?, orient?)`: floats it on top at `rect` (its size becomes its `floatSizes` for the orient
791
+ * it floats in); with no rect, at its `floatSizeOf` size anchored to the content's top-right corner: its `floatSizes`
792
+ * for that orient, else its form's natural size along it (the float's, `orient`, else `floatOrientOf`), else the
793
+ * default size.
794
+ * - `foldItem(state, id, on)`: folded by hand (`from: 1`) draws it in its folded form on the axis it lies along (a
795
+ * panel's `header`, a group's `fold`), and give-way steps down from there; unfolding clears `from`. Where it has no
796
+ * folded form (`canFold` false), folding changes nothing.
797
+ * - `markUsed(state, id)`: the newest age. Under `previous` it reshapes nothing.
798
+ * - `keepItem(state, id, on)`, `openItem(state, id)`, `closeItem(state, id)`, `liftItem(state, id)` (out of every edge
799
+ * and float).
800
+ * - `raiseFloat(state, id)`: a float to the top of the stack; no use, no reshape.
801
+ * - `orientFloat(state, id, orient)`: a float's axis. Its frame takes the size the new orient draws it at
802
+ * (`floatSizeOf`: the size kept for that orient, else the form's natural size), its place and anchor kept; turned
803
+ * back, it has its first orient's size again. An item that declares no `floatSizes` turns keeping its rect, as before
804
+ * the per-orient sizes.
805
+ * - `resizeEdge(state, edge, size)`: the user's size across; a size that isn't a finite number clears it.
806
+ * - `resizeFloat(state, id, rect, moving?)`: a float resized by hand, at `fitResize`'s rect (./float-resize).
807
+ */
808
+
809
+ /**
810
+ * Where a docked item goes: before the `at`-th item of `zone` (default the item's own zone) in `edge`, keeping `space`
811
+ * px free on its zone's open side (`DockItem.space`; absent or 0: none). Docked into the room a placed neighbor keeps,
812
+ * it consumes that room: the neighbor keeps what is left and moves only by what the room lacks. (While the edge has
813
+ * spare length to give every room; a squeezed edge shares its spare out, and its items may shift by a few px.)
814
+ */
815
+ interface DockPlace {
816
+ readonly kind?: "gap";
817
+ readonly edge: string;
818
+ readonly zone?: Zone;
819
+ readonly at: number;
820
+ readonly space?: number;
821
+ }
822
+ /** A new column on `side` at `ring` (the edges at that ring and inward move in one); `Infinity` is the side's inner end. */
823
+ interface ColumnPlace {
824
+ readonly kind: "column";
825
+ readonly side: "left" | "right";
826
+ readonly ring: number;
827
+ }
828
+ /** Docked folded: a new column at `ring` holding the item folded by hand, so it shows in the side's rail. */
829
+ interface RailPlace {
830
+ readonly kind: "rail";
831
+ readonly side: "left" | "right";
832
+ readonly ring: number;
833
+ }
834
+ /** Floating at `rect` (or, with none, at its last size anchored to the content). */
835
+ interface FloatPlace {
836
+ readonly kind: "float";
837
+ readonly rect?: Rect;
838
+ /** Following the content (only its size counts then), at an anchor's name or `{ at, dx?, dy? }`. */
839
+ readonly anchor?: FloatAnchorAt;
840
+ }
841
+ type Place = DockPlace | ColumnPlace | RailPlace | FloatPlace;
842
+ /**
843
+ * Each side's columns (`isSideColumn`) merged into one, for `DockState.sideColumns: "one"`: the outermost column (by ring)
844
+ * keeps its id and takes every other column's items after its own, in ring order; the others are deleted and the side's
845
+ * rings closed up. A side with one column or none is unchanged; the same state comes back when nothing merges. A host
846
+ * calls it as it reads a stored layout, so what it stores is what it shows and what a drag reads.
847
+ */
848
+ declare function mergeSideColumns(state: DockState): DockState;
849
+ /**
850
+ * The state with the item out of every edge and every float (a dynamic column it leaves empty is deleted). The room it
851
+ * held goes back to its stretch: the first placed item past it, away from its zone's own end (`DockItem.space`), takes
852
+ * it back, so it stays where it was drawn; the flush items between close up toward the zone's own end. (While the edge
853
+ * has spare length to give every room; a squeezed edge, or items stepping up to wider forms, may shift it by a few px.)
854
+ */
855
+ declare function liftItem(state: DockState, id: string): DockState;
856
+ declare function moveTo(state: DockState, id: string, place: Place): DockState;
857
+ declare function floatAt(state: DockState, id: string, at?: Rect, orient?: Orient): DockState;
858
+ /**
859
+ * Whether a hand fold of `id` means anything where it lies now: it has a folded form (a panel's `header`, a group's
860
+ * `fold`; a fixed item on a `foldable` edge, a thumbnail anchor, its `rail` tile) among the forms of the axis it lies
861
+ * along (its edge's, its float's orient; either when it lies nowhere). Where it is false, `foldItem(on)` changes nothing: a
862
+ * host leaves the grip's double-click off. An item folded by hand can always be unfolded.
863
+ */
864
+ declare function canFold(state: DockState, id: string): boolean;
865
+ declare function foldItem(state: DockState, id: string, on: boolean): DockState;
866
+ /**
867
+ * The item made the newest (`used`: the newest age plus one). Idempotent: an item already strictly newer than every
868
+ * other gives back the state itself, so a press on it changes nothing (a tie with another item is not newest, and
869
+ * bumps). A drop's result is marked used the same way.
870
+ */
871
+ declare function markUsed(state: DockState, id: string): DockState;
872
+ declare function keepItem(state: DockState, id: string, on: boolean): DockState;
873
+ declare function openItem(state: DockState, id: string): DockState;
874
+ declare function closeItem(state: DockState, id: string): DockState;
875
+ declare function raiseFloat(state: DockState, id: string): DockState;
876
+ declare function orientFloat(state: DockState, id: string, to: Orient): DockState;
877
+ /**
878
+ * A float resized by hand: the rect `fitResize(state, floatId, rect, moving)` gives (default `moving`: right and
879
+ * bottom), so a host's preview from `fitResize` is what this commits. The float keeps its stacking order and orient,
880
+ * loses its anchor, and the size becomes the item's `floatSizes` for that orient (stored with the state). The state
881
+ * given back where `fitResize` refuses (a toolbar group, a folded float, anything not floating).
882
+ */
883
+ declare function resizeFloat(state: DockState, floatId: string, rect: Rect, moving?: ResizeEdges): DockState;
884
+ /** The user's size across an edge; a size that isn't finite clears it. */
885
+ declare function resizeEdge(state: DockState, edgeId: string, size: number): DockState;
886
+ /**
887
+ * The side's rails show their items as `mode` (`DockState.railModes`): their titles while they fit, or their tiles only.
888
+ * Unchanged for a side other than left or right, an unknown mode, or the mode the side has already.
889
+ */
890
+ declare function setRailMode(state: DockState, side: "left" | "right", mode: RailMode): DockState;
891
+ /**
892
+ * The edge moved to the other side of its axis (left ⇄ right, top ⇄ bottom), as its side's outermost edge: ring 0, before
893
+ * that side's other edges (whose rings close up behind it; the side it left closes up too). Its items, size and options
894
+ * go with it. Unchanged for an unknown edge, the side it is on, or a side across its axis. Like every change it does not
895
+ * tick the use clock: a host that moves an edge by hand calls `markUsed()` on its items afterwards, as a drop does.
896
+ */
897
+ declare function setSide(state: DockState, edgeId: string, side: Side): DockState;
898
+ /**
899
+ * The place `start` (a state as it began: the host's start or reset state) gives an item, for Dock, Put back and Reset
900
+ * position: its zone and place in the same edge (before the first item that followed it there and is still there), a
901
+ * new column at its ring when its column is gone (a column under the same id that holds none of the start column's
902
+ * items is another column), or its float rect (and anchor). Null when `start` places it nowhere
903
+ * or in an edge `state` no longer has that isn't a column. `moveTo(state, id, place)` puts it there.
904
+ */
905
+ declare function homeFor(state: DockState, id: string, start: DockState): Place | null;
906
+ /**
907
+ * Dock, Put back and Reset position: the item where `start` (the loaded state) has it, fold included. It goes to
908
+ * `homeFor`'s place and takes `start`'s `from` (unfolded when `start` has none), so a "Move to › rail" (which folds it)
909
+ * followed by Dock brings it back open. The state given back unchanged when `start` places it nowhere.
910
+ */
911
+ declare function dockHome(state: DockState, id: string, start: DockState): DockState;
912
+
913
+ /**
914
+ * The state's stored form. `storeDockState(state)` gives plain JSON-safe data; `readDockState(data, base)` reads it back over
915
+ * `base` (the host's state as it starts: its item definitions, edges, kinds and stage) and never throws.
916
+ *
917
+ * ```ts
918
+ * interface StoredDockState {
919
+ * v: 1;
920
+ * edges: { id: string; side: Side; ring: number; items: string[]; size?: number; column?: true }[];
921
+ * floats: { id: string; x: number; y: number; width: number; height: number; orient?: "row" | "column"; anchor?: FloatAnchor | { at: FloatAnchor; dx?: number; dy?: number }; since?: number }[];
922
+ * items: Record<string, { used: number; kept?: true; from?: number; closed?: true; align?: "center" | "end"; space?: number; lengths?: { column?: number; row?: number }; floatSizes?: { row?: { width: number; height: number }; column?: { width: number; height: number } } }>;
923
+ * railModes?: { left?: "titles" | "icons"; right?: "titles" | "icons" };
924
+ * }
925
+ * ```
926
+ *
927
+ * Nothing about kinds, forms or limits is stored: those are the host's (`base`). An edge is matched by its id: its
928
+ * side, ring and limits come from `base`, its order of items and its `size` from the store; a static edge stored on
929
+ * the other side of its axis is moved there (`setSide`, as its side's outermost edge). Dynamic columns
930
+ * (`column: true`) are the store's: one `base` lacks is made from `base.columns[side]`, its ring is the stored one, and
931
+ * columns left empty are deleted, the rings closed up. `DockEdge.hidden` is view state, not stored: the host decides it
932
+ * each time it builds the state (from the window's width, say). A hidden edge's items are stored like any edge's;
933
+ * `hidden` itself is not written, and read back it comes from `base` only (a stored `hidden` is ignored and listed as
934
+ * `edge:<id>:hidden`). `DockEdge.showIn` is the same: never written, from `base` only, a stored one listed as
935
+ * `edge:<id>:showIn`; the items a hidden edge lends are stored in it, as they are. No float has a pinned field: one
936
+ * an old store has is listed and ignored.
937
+ *
938
+ * Reading is lenient: anything but an object of version 1 gives `base` back with the reason in `error`. Inside one,
939
+ * whatever can't be used is dropped and listed in `dropped` (an unknown edge `edge:<id>`, an unknown or repeated item,
940
+ * an item an edge doesn't accept `edge:<edge>:<id>`, a fixed item in another edge than `base`'s `edge:<edge>:<id>`, a
941
+ * float of a kind that doesn't float `float:<id>`, a bad field `item:<id>:<field>`, an unknown top-level field
942
+ * `<field>`). A stored edge's order is kept exactly, fixed items where the store put them (in their own edge); a fixed
943
+ * item the store lacks goes back to its base place (trailing ones last). An item the store places nowhere goes where
944
+ * `base` has it, before a stored trailing run of fixed items.
945
+ * A float's rect is clamped into the stage on read; its anchor, with any offset, is kept as stored (an anchored float
946
+ * lies by its anchor, so the clamp never turns it into a pixel position). An unusable anchor is dropped
947
+ * (`float:<id>:anchor`), and so is a bad offset field (`float:<id>:anchor:dx`, `float:<id>:anchor:<field>`). A float's
948
+ * `since` is kept as stored; one that isn't a number from 0 to `Number.MAX_SAFE_INTEGER` is dropped (`float:<id>:since`).
949
+ * An item's asked lengths (`DockItem.lengths`) are stored per axis; one entry that isn't a number over 0 (a 0 is no length, so it is not stored), or an axis that
950
+ * isn't `row` or `column`, is dropped (`item:<id>:lengths:<axis>`), a `lengths` that isn't an object too
951
+ * (`item:<id>:lengths`). A store from before has none, and an item then reads with none whatever `base` had: the store
952
+ * is the state's own.
953
+ * A float's size is stored per orient (`floatSizes`); one entry that isn't a size, or an orient that isn't `row` or
954
+ * `column`, is dropped (`item:<id>:floatSizes:<orient>`). A store from before that, with one `floatSize` on an item,
955
+ * reads as `floatSizes` for the orient its float is in (the item's own orient where it floats nowhere), so the size
956
+ * never follows the float to the other orient; a docked item keeps it for its next float-out. On a float whose store
957
+ * declares no `floatSizes` it is dropped (`item:<id>:floatSize`): such a float is framed at its stored rect, which the
958
+ * size would replace.
959
+ */
960
+
961
+ interface StoredDockStateEdge {
962
+ readonly id: string;
963
+ readonly side: Side;
964
+ readonly ring: number;
965
+ readonly items: readonly string[];
966
+ readonly size?: number;
967
+ /** A dynamic column: read back from `base.columns[side]` even when `base` doesn't have it. */
968
+ readonly column?: true;
969
+ }
970
+ interface StoredDockStateFloat {
971
+ readonly id: string;
972
+ readonly x: number;
973
+ readonly y: number;
974
+ readonly width: number;
975
+ readonly height: number;
976
+ readonly orient?: Orient;
977
+ /** An anchor's name, or `{ at, dx?, dy? }`: an anchor with an offset in px. */
978
+ readonly anchor?: FloatAnchorAt;
979
+ /** When it was floated (`DockFloat.since`). */
980
+ readonly since?: number;
981
+ }
982
+ interface StoredDockStateItem {
983
+ readonly used: number;
984
+ readonly kept?: true;
985
+ readonly from?: number;
986
+ readonly closed?: true;
987
+ readonly align?: "center" | "end";
988
+ /** `DockItem.space`, px. */
989
+ readonly space?: number;
990
+ /** `DockItem.lengths`: the length asked for, per axis. */
991
+ readonly lengths?: {
992
+ readonly column?: number;
993
+ readonly row?: number;
994
+ };
995
+ /** `DockItem.floatSizes`: its float size per orient. */
996
+ readonly floatSizes?: {
997
+ readonly row?: Size;
998
+ readonly column?: Size;
999
+ };
1000
+ /**
1001
+ * The old single float size, from a state stored before sizes were kept per orient: `readDockState` reads it as
1002
+ * `floatSizes` for the orient its float is in (the item's own where it floats nowhere). `storeDockState` never writes
1003
+ * it.
1004
+ */
1005
+ readonly floatSize?: Size;
1006
+ }
1007
+ interface StoredDockState {
1008
+ readonly v: 1;
1009
+ readonly edges: readonly StoredDockStateEdge[];
1010
+ readonly floats: readonly StoredDockStateFloat[];
1011
+ readonly items: Readonly<Record<string, StoredDockStateItem>>;
1012
+ /** Per side, how its rails show their items (`DockState.railModes`), when the state sets one. */
1013
+ readonly railModes?: Readonly<Partial<Record<"left" | "right", RailMode>>>;
1014
+ }
1015
+ interface DockStateRead {
1016
+ readonly state: DockState;
1017
+ /** What was left out, as listed in the module's docs. */
1018
+ readonly dropped: readonly string[];
1019
+ /** Set when nothing could be read: `state` is `base`. */
1020
+ readonly error?: string;
1021
+ }
1022
+ declare function storeDockState(state: DockState): StoredDockState;
1023
+ declare function readDockState(data: unknown, base: DockState): DockStateRead;
1024
+
1025
+ /**
1026
+ * The targets' shapes: the public ones (`DockDrop`, `DockRefusal`, `DropPlace`, …) and the tiler's own (an edge
1027
+ * as the tiler reads it, its slots and tiles, the context every generator shares).
1028
+ */
1029
+
1030
+ type DropPlace = {
1031
+ readonly kind: "gap";
1032
+ readonly edge: string;
1033
+ readonly zone: Zone;
1034
+ readonly at: number;
1035
+ } | ColumnPlace | RailPlace | {
1036
+ readonly kind: "side";
1037
+ readonly edge: string;
1038
+ readonly side: Side;
1039
+ } | {
1040
+ readonly kind: "float";
1041
+ } | {
1042
+ readonly kind: "home";
1043
+ } | {
1044
+ readonly kind: "none";
1045
+ };
1046
+ interface DropResult {
1047
+ readonly state: DockState;
1048
+ readonly layout: DockLayout;
1049
+ }
1050
+ interface DockDrop extends Target {
1051
+ /** The item dragged. */
1052
+ readonly item: string;
1053
+ /**
1054
+ * Where a release here puts the item. A host tells a home (nothing committed) by `place.kind === "home"`, never by the
1055
+ * id: a home keeps the id of the first of its edge's places that puts the item back (`gap:<edge>:<zone>:<at>` on a
1056
+ * real edge, `rail:<side>:<ring>` on its rail), and `home:<id>` alone covers the item's own rect.
1057
+ */
1058
+ readonly place: DropPlace;
1059
+ /** Gaps and strips: the line where the item's leading edge lands, zero thick, across the edge after the drop. */
1060
+ readonly marker?: Rect;
1061
+ /** A rail target under a kind's `DockState.railDrop` policy: the side's whole drop strip, for the host to draw. */
1062
+ readonly strip?: Rect;
1063
+ /** The state a release here commits and its layout. Only a float's depends on the pointer. */
1064
+ after(point: Point, grab?: Point): DropResult;
1065
+ }
1066
+ interface DockDropOptions {
1067
+ /** The layout before the drag: every `after` is solved with it, as the drop will be. */
1068
+ readonly previous?: DockLayout;
1069
+ /** How far the first and last gaps of an edge reach past its ends, px (default 0). */
1070
+ readonly endReach?: number;
1071
+ /** The float's size for the float target. */
1072
+ readonly floatSize?: Size;
1073
+ /**
1074
+ * The float target starts from the held item's rect (`heldRect`), kept inside the float region, before it is fitted, so
1075
+ * a host that draws the held item there sees what lands. Default: from the pointer's rect, wherever that lies.
1076
+ */
1077
+ readonly floatFromHeld?: boolean;
1078
+ /** The float's orient for the float target (default: its float's, else the item's `floatOrientOf`). */
1079
+ readonly floatOrient?: Orient;
1080
+ /** As `solve`'s: edge or item ids solved without `previous`, in every `after` too. */
1081
+ readonly fresh?: readonly string[];
1082
+ }
1083
+ /** Where a drop of the dragged item is refused: a host draws nothing there and may say "Can't go here" at the pointer. */
1084
+ interface DockRefusal {
1085
+ /**
1086
+ * `refuse:<edge>:<zone>`, with `:<n>` after it for a zone's second refused tile and on, numbered by where they lie
1087
+ * along the edge (then across it), so an id is stable from one frame to the next.
1088
+ */
1089
+ readonly id: string;
1090
+ readonly edge: string;
1091
+ readonly zone: Zone;
1092
+ /**
1093
+ * Where the pointer means it, never over a target's hit and never past the stage. An edge that takes the kind in no
1094
+ * zone gives one refusal (`n = 0`, zone `start`): its drawn rect, fixed items included, less what targets own. A
1095
+ * refused zone of an edge that takes the kind elsewhere: the refused slot's tile, inside the edge's ends.
1096
+ */
1097
+ readonly hit: Rect;
1098
+ /**
1099
+ * A wholly refused edge left in pieces by what targets own (a target in the middle of a bar): every piece, each at
1100
+ * least 1 px each way, `hit` the largest. Absent when the refusal is one rect. The pointer is in the refusal when it is
1101
+ * in any piece.
1102
+ */
1103
+ readonly hits?: readonly Rect[];
1104
+ /**
1105
+ * `no-room`: the zone takes the kind, but the drop there doesn't fit along the edge (a title bar at the title's
1106
+ * natural width, say): no length would be enough. `too-thick`: the zone takes the kind, but no form of the item
1107
+ * (the » menu aside) fits across the edge: each sets no cross size and has a `cross.min` over the edge's thickness
1108
+ * (a 30 px toolbar on a 28 px bar), so no length would help. `own-place`: the stretch beside an item alone in its
1109
+ * zone: there is room, but the zone's only place is the item's own (a release there puts it back). `not-accepted`:
1110
+ * the edge or zone doesn't take the kind.
1111
+ */
1112
+ readonly reason: "no-room" | "too-thick" | "own-place" | "not-accepted";
1113
+ /**
1114
+ * The stage: the refusal holds only points strictly inside it (`Target.bounds`), so a pointer a host clamps exactly
1115
+ * onto the window's edge is never in it. Set by `refusals()`; `refusalTargets` passes it on.
1116
+ */
1117
+ readonly bounds?: Rect;
1118
+ }
1119
+
1120
+ /**
1121
+ * Lanes: the geometry of a docking drag for a landing model (`@n-uf/motion/drag`'s `createLandingModel`).
1122
+ *
1123
+ * A lane is one edge that takes the held item (a bar, a rail, a column) or a virtual one (a new column's line, a
1124
+ * declared rail). Its spots are the places a drop there lands, in order along it: before, between and after its items,
1125
+ * and, on a bar or a toolbar rail, one sliding spot per free stretch between items, which lands exactly where the hand
1126
+ * holds it (`DockSpot.slide`; `stretchPositions: "free"`, the default); with `stretchPositions: "pitched"`, spots at a
1127
+ * fixed pitch over those stretches instead (`SPOT_PITCH`), so a toolbar lands close to the hand. Each spot keys where its drop draws the other items (a change between two spots
1128
+ * with the same key moves only the held item), and each lane carries its place guides' marks in the layout as drawn.
1129
+ * Each spot has a stretch of the lane that picks it. In a panel column, between two spots that share a neighbor (the
1130
+ * item `Y` in `X|Y` and `Y|Z`), the boundary is that item's middle as drawn (with a spot held, in that spot's own layout:
1131
+ * `dockDrag`'s `spotsOf`, so a column takes a panel by halves of what is seen). On a bar or a toolbar rail, and between any two
1132
+ * other spots, it is halfway across the gap between their landings, each in its own layout, so the pointer is at the
1133
+ * landing it picks and a toolbar moved along an occupied lane stays at the hand. On a bar or a toolbar rail, two landings
1134
+ * that overlap (spots a pitch apart, the pointer inside both) are cut where the item is held (`options.grab`): halfway
1135
+ * between the points the pointer would hold in each, so a pointer back at its press point picks the item's own place
1136
+ * however far from its middle it was pressed; landings apart are cut halfway across their gap whatever the grab. Cuts are
1137
+ * kept inside the lane and in order. The spots come from the same generation and filter as `targets()`, so a spot's
1138
+ * landing is exactly what its drop commits. Spot ids are keyed by the lane, zone and neighboring items, so they survive
1139
+ * the window resizing and most items opening or moving; virtual lanes are keyed by the column they lie beside, not
1140
+ * their ring. Remembered per state and options. The one layout of each held place of the drag (a held frame and its commit)
1141
+ * is `dockDrag`'s (./drag), built on these.
1142
+ */
1143
+
1144
+ /** The pitch of the spots over a bar's free stretches, px: a quarter of a typical toolbar's length (158 px in the lab). */
1145
+ declare const SPOT_PITCH = 40;
1146
+ /**
1147
+ * A sliding spot's range (`DockLaneOptions.stretchPositions: "free"`): where the landing's start may lie along the lane,
1148
+ * from flush against the neighbor before the stretch to flush against the one after it, and the starts it snaps to.
1149
+ */
1150
+ interface LaneSlide {
1151
+ readonly from: number;
1152
+ readonly to: number;
1153
+ /**
1154
+ * Its two ends, the item's own place where it lies here, and every other dock that lands inside, in order. Each is a
1155
+ * start that commits what lies there (a taken-over dock as it is), so none is dropped for lying near another, except
1156
+ * within twice the snap distance of the item's own place, where home wins.
1157
+ */
1158
+ readonly snaps: readonly number[];
1159
+ /** How near a snap point the landing's start snaps to it, px (`DockLaneOptions.snapDistance`). */
1160
+ readonly snapDistance: number;
1161
+ /**
1162
+ * The grain of a start that snaps to nothing, px: a multiple of `step` (whole px, 1) within `[from, to]`. The one rule
1163
+ * `target.after`, a landing model's frame and its release all read, so the frame shows what the drop commits:
1164
+ * with `c = clamp(raw, from, to)`, the start is the nearest snap point within `snapDistance` of `c`, else
1165
+ * `clamp(round(c / step) * step, from, to)`.
1166
+ */
1167
+ readonly step: number;
1168
+ }
1169
+ /** One place a drop in a lane lands. */
1170
+ interface DockSpot {
1171
+ /**
1172
+ * Stable across solves: `<lane>/<zone>/<item before or ^>|<item after or $>`; an empty edge's `<lane>/<zone>`; a
1173
+ * pitched spot `…@<pitches from its neighbor>`; a sliding spot `<lane>/<zone>/<before>|<after>@slide`, named by the
1174
+ * stretch; a virtual lane's `<lane>/line` or `<lane>/end`.
1175
+ */
1176
+ readonly id: string;
1177
+ /** Its stretch of the lane, along the lane's axis, inside the lane's range. */
1178
+ readonly along: readonly [number, number];
1179
+ /** Where the item lands (its rect after the drop). */
1180
+ readonly landing: Rect;
1181
+ /** The drop: its place and `after()` (the layout after it, the room). */
1182
+ readonly target: DockDrop;
1183
+ /**
1184
+ * The item's own place (a release there changes nothing). A spot's `target.place` is the dock at the spot's listed
1185
+ * landing (on the item's own sliding spot its own zone, index and `space`); a sliding spot commits through
1186
+ * `target.after(point, grab)`, and the landing release's `home` and `at` say where, never the place kind.
1187
+ */
1188
+ readonly home?: true;
1189
+ /** A spot at a pitch over a free stretch (`DockItem.space`). */
1190
+ readonly pitched?: true;
1191
+ /**
1192
+ * A free stretch as one sliding spot (`stretchPositions: "free"`): its drop lands where the pointer holds it, the
1193
+ * landing's start at the pointer less the grab, clamped to `[from, to]` and snapped within `snapDistance`, and
1194
+ * `target.after(point, grab)` commits that (a dock keeping the `space` that puts it there). Its `landing` is the one at
1195
+ * the stretch's point nearest the item's own place (that place where it lies here), else at its start.
1196
+ */
1197
+ readonly slide?: LaneSlide;
1198
+ /**
1199
+ * Where its drop draws every item other than the held one, as a key: a change between two spots with the same key
1200
+ * moves only the held item; between two with different keys it reflows the window.
1201
+ */
1202
+ readonly others: string;
1203
+ }
1204
+ /** A stretch of a lane that takes no drop of the item, at least the item's length (a shorter one joins its spots). */
1205
+ interface LaneRefusal {
1206
+ readonly along: readonly [number, number];
1207
+ readonly reason: DockRefusal["reason"];
1208
+ }
1209
+ /**
1210
+ * A place guide's mark, in the lane's layout as drawn: a `line` across the lane between two items that touch (no room
1211
+ * between them but the edge's own gap; as thick as their gap allows, up to 2 px, so zero where they meet and the host
1212
+ * strokes it), a `box` over free room the item lands in, and a `hatch` over the part of a neighbor that gives way.
1213
+ * Where the free room is shorter than the item (a lane's end, a gap between items wider than the edge's gap), the spot
1214
+ * there is drawn as it lands: a box over the free room and a hatch over the rest of its landing (the edge of the
1215
+ * neighbor that will move), the two together the landing; with no free room at a lane's end, the hatch alone. A box
1216
+ * over another edge's docked items (an empty side rail over a column's outer strip) is a hatch there too: they move
1217
+ * aside when the lane opens. Never a box or a line over an item drawn there, nor anything over the held one; nothing in
1218
+ * a refused stretch; no two edge lanes' marks overlap (at a corner a lane not drawn gives way to a drawn one, and
1219
+ * between two not drawn the bar owns it; a virtual lane, a new column's line or a declared rail, is drawn over what it
1220
+ * would push). Marks lie in one layout: as seen the lifted item is drawn nowhere, so its own place is free room in its
1221
+ * lane; in a held place's layout (`after(held)`) every lane's marks lie in that layout, the held item where it draws it.
1222
+ */
1223
+ interface DockMark {
1224
+ /**
1225
+ * Stable while the items either side stay: `<lane>/line/<before>|<after>`, `<lane>/box/<before>|<after>` (`#<n>` for a
1226
+ * stretch's later pieces; `:before` or `:after` for the room beside the held item), `<lane>/hatch/<before>|<after>`
1227
+ * (`~2` for the second side), `^` and `$` at the lane's ends; a virtual lane's `<lane>/box/<spot id>`. Key a drawing by
1228
+ * it.
1229
+ */
1230
+ readonly id: string;
1231
+ readonly kind: "line" | "box" | "hatch";
1232
+ readonly rect: Rect;
1233
+ /**
1234
+ * A box's striped end (`hatch`, `HATCH_END`): the neighbor at that end that gives way when the item lands in the room
1235
+ * (it moves away, leaves the lane, or steps down to a shorter form). Data for a host and tests; nothing to show.
1236
+ */
1237
+ readonly givesWay?: string;
1238
+ }
1239
+ interface DockLane {
1240
+ /** The edge's id, or a virtual lane's: `column:<side>:<the column it lies outside, or $>`, `rail:<side>`. */
1241
+ readonly id: string;
1242
+ readonly rect: Rect;
1243
+ /** The axis its spots run along. */
1244
+ readonly axis: "x" | "y";
1245
+ readonly spots: readonly DockSpot[];
1246
+ readonly refused: readonly LaneRefusal[];
1247
+ /**
1248
+ * Its place guides' marks as seen: in the window as seen, the held item drawn nowhere (its own place is free room).
1249
+ * A held frame's marks, and the guides of a frame, are `dockDrag(...).after(held)` and `guides(frame)`'s (./drag).
1250
+ */
1251
+ readonly marks: readonly DockMark[];
1252
+ /**
1253
+ * Its rect is its own: a rail drop strip at the window's side (`DockState.railDrop`), which every other target of the drag
1254
+ * gives up. A landing model gives it the pointer inside it over any lane it overlaps (a flush column's edge).
1255
+ */
1256
+ readonly owns?: true;
1257
+ }
1258
+ /** Everything a landing model reads for one drag. */
1259
+ interface DockRegions {
1260
+ readonly lanes: readonly DockLane[];
1261
+ /** Refused places outside every lane ("Can't go here"). */
1262
+ readonly refused: readonly Rect[];
1263
+ /**
1264
+ * Where a float can land (`floatRegion`: the stage less the float insets), as a landing model's `content`: the open
1265
+ * space is it less `blocked`. So the gutter between a column and the pages is open (a release there floats), while
1266
+ * every drawn edge, docked item, chrome and drawn rail stays out of it.
1267
+ */
1268
+ readonly content: Rect;
1269
+ /** What the open space excludes: drawn edges, docked items, the chrome, a drawn declared rail, `DockState.blocked`. */
1270
+ readonly blocked: readonly Rect[];
1271
+ readonly stage: Rect;
1272
+ /** Where a float of the item may lie: the stage less the inset at its left and right (`heldRect`'s region). */
1273
+ readonly floatRegion: Rect;
1274
+ /** The held item's size as it is now. */
1275
+ readonly item: Size;
1276
+ /** The float target (its `after(point, grab)` is the float landing), or null where the item doesn't float. */
1277
+ readonly float: DockDrop | null;
1278
+ /** The drag's refusals, from the same generation as the spots (what `refusals()` gives), for a host that shows them. */
1279
+ readonly refusals: readonly DockRefusal[];
1280
+ }
1281
+ interface DockLaneOptions extends DockDropOptions {
1282
+ /**
1283
+ * The pitch of a bar's free-stretch spots, px (default `SPOT_PITCH`). 0 or less turns pitched spots off. Under `"free"` it only sets the sampling step that checks a
1284
+ * stretch's range (every `pitch` px; `SPOT_PITCH` when 0 or less), never a spot of its own.
1285
+ */
1286
+ readonly pitch?: number;
1287
+ /**
1288
+ * How a free stretch on a bar or a toolbar rail offers its range of landings, from flush against the neighbor before
1289
+ * it to flush against the one after it: `"free"` (the default), one sliding spot (`DockSpot.slide`) that lands where
1290
+ * the pointer holds the item, snapped to its ends and the item's own place within `snapDistance`; `"pitched"`, a
1291
+ * spot every `pitch` px, its ends included. Either way a step comes only where the order changes (passing a
1292
+ * neighbor), cut as between any two spots.
1293
+ */
1294
+ readonly stretchPositions?: "free" | "pitched";
1295
+ /** Under `"free"`, how near a snap point a landing snaps to it, px (default 8). */
1296
+ readonly snapDistance?: number;
1297
+ /**
1298
+ * Where the pointer holds the item, from its top left corner as it is now, px (what a target's `after(point, grab)`
1299
+ * takes): the press's, constant for the drag (each grab is remembered as its own options). It counts along the item's own length only (its longer side as it is now): on a bar or a toolbar rail
1300
+ * along that axis the cut between two overlapping landings lies halfway between the points the pointer would hold in
1301
+ * each (with landings of one length; at the same share of each), kept within half a pitch of their overlap, so a
1302
+ * pointer back at its press point picks the item's own place; landings with a gap between them (either side of a long
1303
+ * neighbor) are cut halfway across it whatever the grab, so the pointer is at the landing it picks (R12). Across the
1304
+ * item, and in a lane across its length (a rail toolbar over a bar), it is the item's middle, as without a grab. Panel columns take a panel by halves of what is drawn either way. Where another lane's band
1305
+ * overlaps the press point (an empty bar's band over a rail's end) that lane can still take the pointer first.
1306
+ */
1307
+ readonly grab?: {
1308
+ readonly x: number;
1309
+ readonly y: number;
1310
+ };
1311
+ /**
1312
+ * How an empty lane's marks draw it (an empty bar or side rail, or a virtual lane, its room not open): `"real"` (the
1313
+ * default), boxes at the size it will take, lying over what moves aside (the page, a column); `"edge"`, each a thin
1314
+ * striped strip (`HATCH_EDGE`) on its window side. Where it lands is the same either way.
1315
+ */
1316
+ readonly emptyLanes?: EmptyLanes;
1317
+ }
1318
+ /**
1319
+ * How a place guide draws an empty lane (an empty bar or side rail, its room not open yet): `"real"`, a box at the size
1320
+ * the lane will take, over what moves aside; `"edge"`, a thin striped strip on the lane's window side. The landing is
1321
+ * the same either way ({@link DockLaneOptions.emptyLanes}).
1322
+ */
1323
+ type EmptyLanes = "real" | "edge";
1324
+ /**
1325
+ * The lanes and regions of a drag of `dragged`: every lane that takes it with its spots and stretches, the refused
1326
+ * places outside lanes, the content and what blocks it, the stage, the float region, the item's size and the float
1327
+ * target, each lane's marks as seen (at rest, the held item drawn nowhere). Remembered per state and options (`previous`
1328
+ * by identity). A held frame's lanes are `dockDrag(...).after(held)`'s (./drag).
1329
+ */
1330
+ declare function lanes(state: DockState, dragged: string, options?: DockLaneOptions): DockRegions;
1331
+ /**
1332
+ * The striped end inside a box whose room partly fits, px: a cue that the neighbor there gives way, never a measure
1333
+ * (about 6 px drawn, inside a box a host insets 2 px).
1334
+ */
1335
+ declare const HATCH_END = 8;
1336
+ /**
1337
+ * A striped column edge's thickness, px: where an empty lane's band lies over items that move aside when it opens
1338
+ * (about 6 px drawn, 2 px clear of the window's edge).
1339
+ */
1340
+ declare const HATCH_EDGE = 8;
1341
+
1342
+ /**
1343
+ * One layout for a drag's held frame and its commit: `dockDrag(state, dragged, options)` gives the drag's hit-testing
1344
+ * data (`regions`, as seen) and `after(held)`, THE layout of a held place of the drag. While its room is open, a held frame
1345
+ * draws every item, the landing and every guide from `after(held)` (docs/docking.md, "What a held frame draws"), and a
1346
+ * release commits exactly `after(held).state`.
1347
+ *
1348
+ * - **A held place** (`DockHeld`) is where a release now lands: a lane's spot with the pointer (`point`; a sliding spot
1349
+ * lands where the hand holds it, the one sliding rule `LaneSlide` states), or the float at the pointer. No held place
1350
+ * (`null`) is rest: the drag lands nowhere (home, refused, nowhere), and the layout is the window as seen, the held item
1351
+ * drawn nowhere.
1352
+ * - **`after(held)`**: the dock state a release commits and its layout (`solve` with the drag's `previous`, as the commit
1353
+ * solves it), the held item's rect there (`landing`, null at rest), every lane's marks in that one layout (`marks`),
1354
+ * and for a spot the held lane's spots with their stretches in that layout (`spots`: a panel column by halves of what
1355
+ * it draws, the hit data along a held lane). Remembered per held place.
1356
+ * - **`shown(frame)`**: the layout a landing frame draws: `after(frame.held).layout` while `frame.room` is open, else
1357
+ * the window at rest.
1358
+ * - **`guides(frame)`**: the place guides of a landing frame, each lane's from the held place it names (rule B): a lane's
1359
+ * guide is drawn in the layout on screen (`shown(frame)`), less the landing the pointer would take there; only a lane
1360
+ * that isn't drawn on screen takes the layout that creates it (its would-land held place's for the Near lane, its one
1361
+ * spot's for any other), and gives up where it meets a lane drawn on screen (between two such, the bar keeps the
1362
+ * corner). Under "all", the Near lane's marks win where they meet another lane's: the others are cut there.
1363
+ *
1364
+ * The shapes fit `@n-uf/motion/drag`'s landing model as they are (`regions`, `landingOf`, `spotsOf`; the frame's
1365
+ * `held` and `guides`), though neither package imports the other.
1366
+ */
1367
+
1368
+ /** A held place of a drag: where a release now lands (`@n-uf/motion/drag`'s `LandingHeld` fits it). `null` is rest (it lands nowhere). */
1369
+ type DockHeld = {
1370
+ readonly kind: "spot";
1371
+ /** The spot's id (`DockSpot.id`). */
1372
+ readonly spot: string;
1373
+ /** The pointer, in the regions' space: where a sliding spot's landing starts (`LaneSlide`); a fixed spot ignores it. */
1374
+ readonly point: Point;
1375
+ } | {
1376
+ readonly kind: "float";
1377
+ /** The pointer: the float lands where it holds the item (`DockDrop.after(point, grab)`). */
1378
+ readonly point: Point;
1379
+ };
1380
+ /** A lane's mark in one layout, with its lane. */
1381
+ interface DockLaneMark extends DockMark {
1382
+ readonly lane: string;
1383
+ }
1384
+ /** THE layout of a held place of a drag: what a release commits, and what its held frame draws while its room is open. */
1385
+ interface DockAfter extends DropResult {
1386
+ /** The held item's rect in `layout`, or null at rest (and where a float can't land). */
1387
+ readonly landing: Rect | null;
1388
+ /** Every lane's marks in `layout`: no two lanes' overlap, none covers an item drawn there or the landing. */
1389
+ readonly marks: readonly DockLaneMark[];
1390
+ /** A spot's: its lane's spots with their stretches cut in `layout` (along a held lane, the spot ranges as drawn). */
1391
+ readonly spots?: readonly DockSpot[];
1392
+ }
1393
+ /** A place guide as a frame draws it: a lane's mark in the layout its guide stands for. */
1394
+ type DockGuide = DockLaneMark;
1395
+ /** One lane a frame shows guides for, with the held place its guide stands for (`@n-uf/motion/drag`'s `LandingGuideRef`). */
1396
+ interface DockGuideRef {
1397
+ readonly lane: string;
1398
+ readonly held: DockHeld | null;
1399
+ }
1400
+ /** What `guides` reads of a landing frame: the held place on screen, whether its room is open, and each lane shown with the held place its guide stands for. */
1401
+ interface DockGuideFrame {
1402
+ readonly held: DockHeld | null;
1403
+ /**
1404
+ * The room is open (`@n-uf/motion/drag`'s `LandingFrame.room`, a boolean): the host draws the window as `held` lays it
1405
+ * out. A host that draws the window at rest while a spot is held (a mode that never makes room) passes false.
1406
+ */
1407
+ readonly room: boolean;
1408
+ readonly guides: readonly DockGuideRef[];
1409
+ }
1410
+ /** A drag of one item: its hit-testing data as seen, and the one layout of each of its held places. */
1411
+ interface DockDrag {
1412
+ /** Hit-testing only: lanes (hit rect, spots' stretches, refused stretches), refused places, blocked, content, as seen. */
1413
+ readonly regions: DockRegions;
1414
+ /** THE layout of `held` (rest for null): the dock state it commits, its layout, landing, marks and, for a spot, its lane's spots. */
1415
+ after(held: DockHeld | null): DockAfter;
1416
+ /** `after(held).landing`: the one rect a landing model reads (its trail gate, its frame's landing). */
1417
+ landingOf(held: DockHeld): Rect | null;
1418
+ /** `after({ spot }).spots` of a spot: its lane's spots with their stretches in the spot's layout, or null. */
1419
+ spotsOf(spot: string): readonly DockSpot[] | null;
1420
+ /**
1421
+ * The layout a frame draws, the one every guide of the frame is cut in: `after(frame.held).layout` while
1422
+ * `frame.room` is open, else the window at rest (what the host draws at rest). Only a spot held in a lane has a room
1423
+ * (`LandingFrame.room`: a docked item's gap opens as the item lands there); a float has none: its gap closes on
1424
+ * release (decision 0003's float exception), so the window stays at rest and `after(float)` is only what a release
1425
+ * commits. A null held place is rest. A host that draws no room for a spot (a mode that never makes one) passes room false.
1426
+ */
1427
+ shown(frame: Pick<DockGuideFrame, "held" | "room">): DockLayout;
1428
+ /** The guides of a frame, cut in `shown(frame)`: each lane's marks from the held place it names, the Near lane's winning where they meet. */
1429
+ guides(frame: DockGuideFrame): DockGuide[];
1430
+ }
1431
+ /**
1432
+ * The drag of `dragged` in `state`: `lanes()`'s regions as seen, and `after(held)`, THE layout of each held place. The
1433
+ * options are `lanes()`'s (`previous` is the committed layout at the lift, the one every solve and the commit read;
1434
+ * `grab` the press's). The work at the lift is remembered per dock state and options, as `lanes()`'s is; each held place's layout
1435
+ * is remembered by the drag.
1436
+ */
1437
+ declare function dockDrag(state: DockState, dragged: string, options?: DockLaneOptions): DockDrag;
1438
+
1439
+ export { type LaneRefusal as $, type DockMark as A, type DockNote as B, type ColumnPlace as C, type DockItem as D, type DockNoteCode as E, type FloatAnchorAt as F, type DockPlace as G, type DockRailLayout as H, type DockRegions as I, type DockSpot as J, type Kind as K, type DockStateRead as L, type DropPlace as M, type DropResult as N, type Orient as O, EDGE_ROOM_HOLD as P, type EmptyLanes as Q, type RailMode as R, type Side as S, FLOAT_ANCHORS as T, type FloatAnchorOffset as U, type FloatPlace as V, type FloatResize as W, HATCH_EDGE as X, HATCH_END as Y, type ZoneAccepts as Z, type KeepClear as _, type FloatAnchor as a, type LaneSlide as a0, type Place as a1, RAIL_MODES as a2, RAIL_STRIP_MIN as a3, RAIL_VISIBILITIES as a4, type RailDropPolicy as a5, type RailPlace as a6, type RailSpec as a7, type RailVisibility as a8, type ResizeEdges as a9, resizeEdge as aA, resizeFloat as aB, setRailMode as aC, setSide as aD, storeDockState as aE, type ResizeLimit as aa, SIDES as ab, SPOT_PITCH as ac, type StoredDockState as ad, type StoredDockStateEdge as ae, type StoredDockStateFloat as af, type StoredDockStateItem as ag, ZONES as ah, canFold as ai, closeItem as aj, dockDrag as ak, dockHome as al, fitResize as am, floatAt as an, foldItem as ao, homeFor as ap, keepItem as aq, lanes as ar, liftItem as as, markUsed as at, mergeSideColumns as au, moveTo as av, openItem as aw, orientFloat as ax, raiseFloat as ay, readDockState as az, type Zone as b, type DockState as c, type DockEdge as d, type SolveOptions as e, type DockLayout as f, type DockRefusal as g, type DockDropOptions as h, type DockDrop as i, type ColumnTemplate as j, DEFAULT_FLOAT_SIZE as k, DEFAULT_HIT_BAND as l, DEFAULT_RAIL_MAGNET as m, DEFAULT_STRIP as n, type DockAfter as o, type DockDrag as p, type DockEdgeLayout as q, type DockFloat as r, type DockGuide as s, type DockGuideFrame as t, type DockGuideRef as u, type DockHeld as v, type DockItemLayout as w, type DockLane as x, type DockLaneMark as y, type DockLaneOptions as z };