@n-uf/placement 26.11.53 → 26.11.54

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