@n-uf/placement 26.12.6 → 26.12.8

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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,69 @@ Versions are calendar versions, `YY.M.R` (year, month of the release, counter wi
5
5
 
6
6
  Unreleased entries live in `changes/` until a release joins them.
7
7
 
8
+ ## 26.12.8
9
+
10
+ - **Changed:** `tilingDrag`, `tilingConformance` and `tilingHitConformance` take a `fold` key; in 26.12.7 they threw
11
+ on one. `layoutSplit`, `splitNeed`, `canDropOnPane`, `canSplitPane` and `dropFits` still throw when their options
12
+ hold a `fold` key ("use layoutSplitTree").
13
+ - **Added:** the drag over a folding split tree. `tilingDrag(tree, subject, { ...options, fold })` lays the lift, the
14
+ base and every `after` out with `layoutSplitTree` and the fold, each with its own order: the lift with `fold.order`
15
+ (the host's), the base with the panes open at the lift first (a tab torn out of a stack leaves its stack mates in
16
+ its place), a change with the subject first, then those. For
17
+ consumers: pass the `fold` you draw with, draw what the drag gives, and when a release commits `after.tree`, store
18
+ `after.order` with it in the same step, so the next frame draws the layout the preview showed. A pane the base folds
19
+ is refused `folded`; a pane open at the lift that the base folds keeps its target on the lift basis with every place
20
+ refused. Under a fold there is no room rule (`room-along`, `room-across`): an accepted place lands the subject open
21
+ and at least `min`, and the pane it was dropped on may fold. A subject folded at the lift (a pane carried in) has its
22
+ spine segment as its lift rect and no `home`. `dropFits` takes `folded`, the panes a folding layout folds (an `at`
23
+ among them is not judged); `canSplitPane` and `dropFits` read no fold (under a fold the drag has no room rule).
24
+ Without `fold`, the drag gives what it gave.
25
+ - **Added:** `TilingLaidOut.order`, `.spines` and `.folds`, `TilingAfter.opened` and `.closed` (the panes a change
26
+ opens and folds against the lift), `DropFitsOptions.folded`; `TilingDragOptions` takes `fold`
27
+ (`FoldingSplitOptions`). All empty or absent without a fold.
28
+ - **Changed (breaking, types):** `TilingRefusal` has a new code, `folded`, so an exhaustive `switch` over refusal codes
29
+ stops compiling until it handles it, whether or not the host passes a fold. `TilingLaidOut` and `TilingAfter` have
30
+ new required fields (`order`, `spines`, `folds`; `opened`, `closed`), so code that builds one itself (a test double)
31
+ must add them: `order: [], spines: new Map(), folds: []`, `opened: [], closed: []`.
32
+ - **Added:** the hit over a folding split tree. Every point of a rail's box takes no place and holds nothing;
33
+ `TilingHitRead.folded` and `hit.foldedAt(point)` (`TilingFolded`, `{ rail, pane }`) give the rail under the pointer
34
+ and the pane painted there, null in a gap. `tilingConformance` and `tilingHitConformance` take a fold, with new
35
+ properties `folded-refused`, `spine-no-place` and `named-case-refused`. For consumers: pass the same `fold` to the
36
+ conformance runs as to the drag.
37
+ - **Added:** the strip option. `SplitFold.segmentFloor`, a spine segment's least length: the floor used is the smaller
38
+ of it and the rail box's length, and on a rail whose shortest segment would fall under it every segment is that
39
+ long, so the rail's content may run past its box; it moves nothing but segments. `SplitFoldGeometry.railContentLength`,
40
+ the rail's content length. `paintedSpines(layout, railOffset?)` (with `RailOffset` and `FoldedLayout`), each segment
41
+ as painted at the host's offsets, cut to its rail's box. `TilingDragOptions.railOffset`, the host's offset per rail,
42
+ read by the hit at every read. For consumers: `spines` are content positions; where a rail's content runs past its
43
+ box, draw `paintedSpines` and pass the same offsets to the drag.
44
+ - **Changed (breaking, types):** `SplitFoldGeometry` has a new required field, `railContentLength`, `TilingHitRead`
45
+ a new required field, `folded`, and `TilingHit` a new method, `foldedAt(point)`, so code that builds one itself (a
46
+ test double) must add them (`railContentLength`: the rail's length along its edge; `folded: null`;
47
+ `foldedAt: () => null`). `TILING_PROPERTIES` and
48
+ `TILING_HIT_PROPERTIES` have new names, so a host that keys a table by them sees the new rows.
49
+
50
+ ## 26.12.7
51
+
52
+ - **Added:** a folding split tree. `layoutSplitTree(tree, area, { ...options, fold })` folds a split that cannot keep
53
+ its panes on their fold floors: one side stays open, the other is drawn as a spine on the edge where it sits.
54
+ `fold` (`SplitFold`) holds each pane's fold floor, the spine's thickness, the order of panes to keep open, and
55
+ optionally `targetOrder` and `weight`. The layout's new `spines` give each folded pane's segment of its spine and
56
+ `folds` each folded split (`SplitFoldGeometry`); a kept split's `needs` are the pair the fold chose. What folds
57
+ depends on the tree, the area and the host's answers only, never on the order. Every split outside a master split
58
+ needs an `axis` with `fold`. For consumers: lay out with `fold` and draw `panes` and `spines`; without `fold`,
59
+ nothing changes. A folded pane that shows nothing (weight 0) stays in its fold's `panes` with no segment in
60
+ `spines`. A repeated split `id` does not turn folding off. Where nothing folds, the layout equals the one without
61
+ the fold only on the same `options.floor`: with `fold`, a kept split's net is on where there is no `floor`. See
62
+ docs/decisions/0023-a-folding-split-tree-has-one-layout.md.
63
+ - **Added:** `SplitLayout.spines` and `SplitLayout.folds`, empty without `fold`; `FoldingSplitOptions`, the options
64
+ `layoutSplitTree` takes.
65
+ - **Changed (breaking, types):** `SplitLayout` has two new required fields, `spines` and `folds`, so code that builds
66
+ a `SplitLayout` itself (a test double, a host's own layout) must add them: `spines: new Map(), folds: []`.
67
+ - **Changed (breaking, behavior):** `layoutSplit`, `splitNeed`, `canDropOnPane`, `canSplitPane`, `dropFits`,
68
+ `tilingDrag`, `tilingConformance` and `tilingHitConformance` throw when their options hold a `fold` key ("use
69
+ layoutSplitTree"), so a fold is never ignored in silence: the drag and its rules do not read spines yet.
70
+
8
71
  ## 26.12.6
9
72
 
10
73
  No changes in `@n-uf/placement`. Released in step with `@n-uf/motion` and `@n-uf/docking`, which share the version.
package/dist/tiling.d.ts CHANGED
@@ -156,6 +156,83 @@ declare function splitFromOrder<K>(panes: readonly K[]): Split<K> | null;
156
156
  */
157
157
  declare function dropOnPane<K>(tree: Split<K> | null, dragged: K, at: K, region: PaneRegion): Split<K>;
158
158
 
159
+ /**
160
+ * Folding a split tree, as a host passes it: where a split cannot keep both sides on their floors, one side stays
161
+ * open and the other is drawn as a spine, a thin strip on the edge where it sits. A tiling fold, not a stack's `fold`
162
+ * form or `folded` flag, nor a docked item's short form. Types only.
163
+ */
164
+
165
+ /** Folding: where a split cannot keep both sides on their floors, one side stays open and the other is a spine. */
166
+ interface SplitFold<K> {
167
+ /**
168
+ * A pane's whole fold floor along `axis`, measured at `split`, the nearest split above it that runs along `axis`
169
+ * (null: none does, or the count starts at a split that measures nothing above it). A pane here is a `{ pane }` node
170
+ * or a master split, which never folds and counts as one. The host's floor chain, its pins included, is its own:
171
+ * placement takes the larger of it and 1 px, and nothing else.
172
+ */
173
+ readonly floor: (node: Split<K>, axis: Axis, split: Split<K> | null) => number;
174
+ /** A spine's thickness across its split, px. */
175
+ readonly spine: number;
176
+ /** Panes to keep open first, in order: a folded split shows the side holding the first of them. */
177
+ readonly order: readonly K[];
178
+ /** The order a spine's pane to open is chosen by; default `order`. */
179
+ readonly targetOrder?: readonly K[];
180
+ /** What a pane counts when panes kept open are counted: 1, or 0 for a pane that shows nothing. Default 1. */
181
+ readonly weight?: (pane: K) => 0 | 1;
182
+ /**
183
+ * A spine segment's least length along its rail, px. Absent or 0: a rail's segments share its box, however short.
184
+ * Above 0, the floor used is the smaller of it and the rail box's length; where a rail's shortest segment would fall
185
+ * under it, every segment on that rail is that floor long, 2 px apart, and the rail's content runs past its box
186
+ * (`SplitFoldGeometry.railContentLength`; the host shows a part of it, `paintedSpines`). A fold on the rail whose
187
+ * panes all show nothing takes one floor length and has no segment. The floor moves nothing but segments.
188
+ */
189
+ readonly segmentFloor?: number;
190
+ }
191
+ /** One folded split of a laid-out tree (`SplitLayout.folds`). */
192
+ interface SplitFoldGeometry<K> {
193
+ /** The folded split's `id`, if it has one. */
194
+ readonly id: string | undefined;
195
+ /** The folded split's axis: `"x"` folds sideways (spine left or right), `"y"` up or down. */
196
+ readonly axis: Axis;
197
+ /** The side that stays open. */
198
+ readonly open: "a" | "b";
199
+ /** The edge the spine sits on: where the folded side is. */
200
+ readonly edge: Side;
201
+ /** The split's box. */
202
+ readonly rect: Rect;
203
+ /**
204
+ * The open side's box: the split's box less the spine and the split's gap; a fold whose spine joined an enclosing
205
+ * fold's rail gives up nothing, so its open side is the split's whole box.
206
+ */
207
+ readonly openRect: Rect;
208
+ /**
209
+ * The spine: its part of the rail's content, the whole rail when the rail holds this fold alone. A content position:
210
+ * placed from the rail box's top or left as if the content were not moved; it is where the spine is painted only
211
+ * where the content fits the box (`railContentLength`) and the host's offset is 0, else see `paintedSpines`.
212
+ */
213
+ readonly spine: Rect;
214
+ /** The whole rail's box, on `edge`, the spine's thickness across the split's axis: where its content is painted. */
215
+ readonly rail: Rect;
216
+ /**
217
+ * The rail's content length along its edge: the box's length, unless a segment floor (`SplitFold.segmentFloor`)
218
+ * lengthened it. The same on every fold of one rail. A host that moves the content by hand moves it by 0 to this
219
+ * length less the box's.
220
+ */
221
+ readonly railContentLength: number;
222
+ /**
223
+ * The index in `folds` of the fold heading the rail this spine is drawn in: its own, or that of the enclosing fold on
224
+ * the same edge whose rail it joined (a fold whose box starts where that fold's open side starts on the edge, and
225
+ * spans the same length along it).
226
+ */
227
+ readonly railOf: number;
228
+ /** The index in `folds` of the nearest enclosing fold; null for an outermost fold. */
229
+ readonly parent: number | null;
230
+ /** The panes the spine stands for, in reading order. */
231
+ readonly panes: readonly K[];
232
+ /** The pane to open the spine with: the first of `targetOrder` among those that show (weight 1), else the first that shows; null if none shows. */
233
+ readonly target: K | null;
234
+ }
235
+
159
236
  /**
160
237
  * One split's decision: given its extent, its gutter, its stored ratio and what each side needs, how long each side
161
238
  * is along the split, and the ratio in effect. `layoutSplit` makes it for every split; a host that draws or stores a
@@ -291,10 +368,19 @@ interface SplitGeometry {
291
368
  */
292
369
  readonly needs: readonly [number, number] | null;
293
370
  }
294
- /** A tree laid out: every pane's rect, and the geometry of each split that has an `id`. */
371
+ /**
372
+ * A tree laid out: every open pane's rect, the geometry of each split that has an `id` and is drawn with its two sides,
373
+ * and, under a fold (`layoutSplitTree`'s `fold`), each folded pane's segment of its spine and the folds, outermost
374
+ * first. Without a fold, `spines` and `folds` are empty. A segment in `spines` is a content position, placed from its
375
+ * rail box's top or left: it is where the segment is painted only where the rail's content fits its box
376
+ * (`SplitFoldGeometry.railContentLength`) and the host's offset is 0; `paintedSpines` gives where each is painted at a
377
+ * rail offset.
378
+ */
295
379
  interface SplitLayout<K> {
296
380
  readonly panes: Map<K, Rect>;
297
381
  readonly splits: Map<string, SplitGeometry>;
382
+ readonly spines: Map<K, Rect>;
383
+ readonly folds: readonly SplitFoldGeometry<K>[];
298
384
  }
299
385
  /**
300
386
  * The least length `tree` lands at along `axis`, laid out alone in an area with `options`: where the area is at
@@ -322,12 +408,6 @@ declare function splitNeed<K>(tree: Split<K> | null, axis: Axis, options?: Split
322
408
  * is, so pass an area with no negative side.
323
409
  */
324
410
  declare function layoutSplit<K>(tree: Split<K> | null, area: Rect, options?: SplitOptions<K>): Map<K, Rect>;
325
- /**
326
- * `layoutSplit` and the geometry of every split that has an `id` (a repeated id keeps the one laid out last: a split under another, or a later one beside it): the box it divides,
327
- * its axis and ratio in effect (after the floors), and its divider, the gutter strip between its two sides. A split
328
- * that lays out as master and stack is reported too, its nested splits are not.
329
- */
330
- declare function layoutSplitTree<K>(tree: Split<K> | null, area: Rect, options?: SplitOptions<K>): SplitLayout<K>;
331
411
 
332
412
  /**
333
413
  * Whether a drop on a pane leaves room: the rule a host asks before it offers a side of a pane as a drop place. See
@@ -364,21 +444,86 @@ interface SplitRoomOptions {
364
444
  * The room rule: whether a pane of rect `target` can take another on `side`, both at least `options.min` wide and
365
445
  * high. Along the split (width for left and right, height for top and bottom) the pane needs `2 * min` plus the
366
446
  * gutter (`gap` plus `handle`), across it `min`. The rect is the pane's as the host measures it, where it will be
367
- * when the dragged pane is lifted out. `canDropOnPane`'s first rule, for a side.
447
+ * when the dragged pane is lifted out. `canDropOnPane`'s first rule, for a side. Reads no fold: throws when `options`
448
+ * holds a `fold` key (under a fold the drag has no room rule).
368
449
  */
369
450
  declare function canSplitPane(target: Rect, side: Side, options: SplitRoomOptions): DropVerdict;
370
- /** What `dropFits` reads: the `min` (as in `DropOptions`) and the `side` of `at` the drop is on, for the reason. */
371
- interface DropFitsOptions {
451
+ /**
452
+ * What `dropFits` reads: the `min` (as in `DropOptions`), the `side` of `at` the drop is on, for the reason, and under
453
+ * a fold the panes the projected layout folds.
454
+ */
455
+ interface DropFitsOptions<K = unknown> {
372
456
  readonly min: number;
373
457
  readonly side: Side;
458
+ /**
459
+ * The panes the projected layout folds (a folding layout's `folds`, their `panes`): a folded `at` is not judged, as
460
+ * the drop may fold it. `dragged` is judged whatever this holds: it must be drawn open. Default: none.
461
+ */
462
+ readonly folded?: ReadonlySet<K>;
374
463
  }
375
464
  /**
376
- * The fit rule: in `projected`, the rect of every pane in the layout the drop makes (the host's own projection of
377
- * `dropOnPane`'s tree), whether `dragged` and `at` are both there and at least `options.min` wide and high, to within
378
- * `EPS` (a floor of `min` lands at `min` up to float error). Fine when `area` has no width or no height (there is
379
- * nothing to measure). `canDropOnPane`'s last rule.
465
+ * The fit rule: in `projected`, the rect of every pane drawn open in the layout the drop makes (the host's own
466
+ * projection of `dropOnPane`'s tree), whether `dragged` and `at` are both there and at least `options.min` wide and
467
+ * high, to within `EPS` (a floor of `min` lands at `min` up to float error); an `at` in `options.folded` is not judged.
468
+ * Fine when `area` has no width or no height (there is nothing to measure). `canDropOnPane`'s last rule. Reads no fold
469
+ * (a folding host passes the folded panes as `folded`): throws when `options` holds a `fold` key.
470
+ */
471
+ declare function dropFits<K>(projected: ReadonlyMap<K, Rect>, dragged: K, at: K, area: Rect, options: DropFitsOptions<K>): DropVerdict;
472
+
473
+ /**
474
+ * `layoutSplitTree`: the split tree laid out, folding or not. One function lays the tree out, so what a host draws,
475
+ * what a drag hits and what is judged to fit all come from it. See docs/placement.md, Entry: tiling.
380
476
  */
381
- declare function dropFits<K>(projected: ReadonlyMap<K, Rect>, dragged: K, at: K, area: Rect, options: DropFitsOptions): DropVerdict;
477
+
478
+ /**
479
+ * `SplitOptions` plus the fold, which only `layoutSplitTree` (and the drag and its conformance runs) takes:
480
+ * `layoutSplit`, `splitNeed`, `canDropOnPane`, `canSplitPane` and `dropFits` throw on it.
481
+ */
482
+ interface FoldingSplitOptions<K> extends SplitOptions<K> {
483
+ readonly fold?: SplitFold<K>;
484
+ }
485
+ /**
486
+ * `layoutSplit` and the geometry of every split that has an `id` (a repeated id keeps the one laid out last: a split
487
+ * under another, or a later one beside it): the box it divides, its axis and ratio in effect (after the floors), and its
488
+ * divider, the gutter strip between its two sides. A split that lays out as master and stack is reported too, its
489
+ * nested splits are not.
490
+ *
491
+ * With `fold`, a split that cannot keep its panes on their fold floors may fold: one side stays open and the other is
492
+ * drawn as a spine (`spines`, `folds`); a folded split is not in `splits`, and a kept split's `needs` are the pair the
493
+ * fold chose. Every split outside a master split then needs an `axis` (throws otherwise); a master split never folds.
494
+ * Where nothing folds and no boundary moves, the panes and splits are those without the fold on the same
495
+ * `options.floor`: with `fold`, a kept split's net is on where there is no `floor` (a ratio of 0.02 lays out at 20 px of
496
+ * 1000 without the fold, 50 px with it). A spine has a segment per folded pane that shows (weight 1), at a content
497
+ * position (`paintedSpines` gives where it is painted). `tilingDrag` takes the fold too and lays every tree of a drag
498
+ * out here, and so do the conformance runs. See `SplitFold`.
499
+ */
500
+ declare function layoutSplitTree<K>(tree: Split<K> | null, area: Rect, options?: FoldingSplitOptions<K>): SplitLayout<K>;
501
+
502
+ /**
503
+ * Where a folding layout's spine segments are painted: `paintedSpines(layout, railOffset)`. A rail whose content runs
504
+ * past its box (a segment floor, `SplitFold.segmentFloor`) shows a part of it, moved by the host's offset; the layout's
505
+ * `spines` are content positions, this is what is painted. The drag's hit reads it too, so a point over a rail answers
506
+ * the pane painted there. Pure. See docs/placement.md, Entry: tiling, "A folding split tree".
507
+ */
508
+
509
+ /** What a painted rail reads of a layout: its segments and its folds (a `SplitLayout`, or a drag's `TilingLaidOut`). */
510
+ interface FoldedLayout<K> {
511
+ readonly spines: ReadonlyMap<K, Rect>;
512
+ readonly folds: readonly SplitFoldGeometry<K>[];
513
+ }
514
+ /**
515
+ * How far a rail's content is moved along its edge, px, from the rail box's top or left (on a right-to-left page too:
516
+ * the host converts). Asked with the fold heading the rail (`folds[railOf]`) and its index in `folds`, the host's key
517
+ * for the rail. Not clamped: a segment moved past the box is cut, or not painted. A value that is not a finite number
518
+ * reads 0.
519
+ */
520
+ type RailOffset<K> = (rail: SplitFoldGeometry<K>, index: number) => number;
521
+ /**
522
+ * Each spine segment of `layout` as it is painted: moved by its rail's offset along the rail (`railOffset`, default 0
523
+ * everywhere) and cut to the rail's box; a segment wholly off the box is absent. Where a rail's content fits its box
524
+ * and the offset is 0, this is `layout.spines`. Pure: every call reads the offsets anew.
525
+ */
526
+ declare function paintedSpines<K>(layout: FoldedLayout<K>, railOffset?: RailOffset<K>): Map<K, Rect>;
382
527
 
383
528
  /**
384
529
  * The shapes a tiling drag's two halves share: the host's tree as an adapter (`TilingTree`) with its stacks, parts and
@@ -464,7 +609,7 @@ interface TilingTree<T, K> {
464
609
  */
465
610
  parts?(tree: T, pane: K, rect: Rect): readonly TilingPart[];
466
611
  }
467
- /** A held place of a drag: where a release now lands. `at` is always a pane drawn in the base. */
612
+ /** A held place of a drag: where a release now lands. `at` is a pane drawn in the base (or, under a fold, one the base folds: refused `folded`). */
468
613
  type TilingHeld<K> = {
469
614
  readonly kind: "home";
470
615
  } | {
@@ -484,16 +629,18 @@ type TilingHeld<K> = {
484
629
  * - `self`: the place is the subject's own (a swap or side of the subject itself, a swap with its own stack, a whole
485
630
  * stack joined to itself);
486
631
  * - `still`: `at` is a still pane;
487
- * - `missing`: `at` is not a pane drawn in the base;
632
+ * - `missing`: `at` is not a pane drawn in the base, nor one the base folds;
633
+ * - `folded`: under a fold, `at` is a pane the base folds (a spine's, or one that shows nothing);
488
634
  * - `join`: the adapter has no `join`;
489
635
  * - `room-along`, `room-across`: `at` is too short for two panes along the split, or too narrow across it, in the base
490
- * (`canSplitPane`): `need` and `have` px;
636
+ * (`canSplitPane`): `need` and `have` px. Never under a fold: there the one verdict on room is `fit`;
491
637
  * - `fit`: in the layout the release makes (a side, a swap or a join), `pane` (the subject's drawn key or `at`'s) is
492
638
  * below `min` wide or high, the fit rule of `dropFits`. A swap hands each pane the other's rect, so either may fall
493
- * below it; a join is judged on the stack's rect.
639
+ * below it; a join is judged on the stack's rect. Under a fold the subject must also be drawn open, and `at` may fold
640
+ * there (then it is not judged).
494
641
  */
495
642
  type TilingRefusal<K> = {
496
- readonly code: "self" | "still" | "missing" | "join";
643
+ readonly code: "self" | "still" | "missing" | "folded" | "join";
497
644
  } | {
498
645
  readonly code: "room-along" | "room-across";
499
646
  readonly need: number;
@@ -502,11 +649,25 @@ type TilingRefusal<K> = {
502
649
  readonly code: "fit";
503
650
  readonly pane: K;
504
651
  };
505
- /** A tree laid out: every drawn pane's rect, and the geometry of each split that has an id. */
652
+ /**
653
+ * A tree laid out: every pane drawn open and its rect, and the geometry of each split that has an id; under a fold
654
+ * (`TilingDragOptions.fold`), each folded pane's spine segment, the folds, and the order the layout was made with.
655
+ */
506
656
  interface TilingLaidOut<T, K> {
507
657
  readonly tree: T;
658
+ /** Every pane drawn open, and its rect (`SplitLayout.panes`). */
508
659
  readonly layout: ReadonlyMap<K, Rect>;
509
660
  readonly splits: ReadonlyMap<string, SplitGeometry>;
661
+ /** Each folded pane that shows, and its spine segment (`SplitLayout.spines`); empty without a fold. */
662
+ readonly spines: ReadonlyMap<K, Rect>;
663
+ /** The folded splits, outermost first (`SplitLayout.folds`); empty without a fold. */
664
+ readonly folds: readonly SplitFoldGeometry<K>[];
665
+ /**
666
+ * The order this layout was made with: `layoutSplitTree(split(tree), area, { ...options, fold: { ...fold, order } })`
667
+ * is this layout. The lift's is the host's `fold.order`; the base's the panes open at the lift (in the lift's order),
668
+ * then the rest; a change's the subject, then the panes open at the lift, then the rest. Empty without a fold.
669
+ */
670
+ readonly order: readonly K[];
510
671
  }
511
672
  /** A pane a commit moves, from where it was drawn at the lift to where the commit puts it. */
512
673
  interface TilingMove<K> {
@@ -524,8 +685,12 @@ interface TilingAfter<T, K> extends TilingLaidOut<T, K> {
524
685
  readonly refusal: TilingRefusal<K> | null;
525
686
  /** The subject's rect in `layout`: its own when it is drawn, else its stack's. Null when refused. */
526
687
  readonly landing: Rect | null;
527
- /** Every other drawn pane whose rect differs from the lift's (the swap partner, the panes that give room), in `layout`'s order. */
688
+ /** Every other pane drawn open here and at the lift whose rect differs from the lift's (the swap partner, the panes that give room), in `layout`'s order. */
528
689
  readonly moved: readonly TilingMove<K>[];
690
+ /** Under a fold, the panes folded at the lift and drawn open here (the subject included), in `layout`'s order; else empty. */
691
+ readonly opened: readonly K[];
692
+ /** Under a fold, the panes drawn open at the lift and folded here, in the lift layout's order; else empty. */
693
+ readonly closed: readonly K[];
529
694
  }
530
695
 
531
696
  /**
@@ -632,6 +797,15 @@ type TilingMark<K> = {
632
797
  readonly rect: Rect;
633
798
  readonly slot: Rect | null;
634
799
  };
800
+ /**
801
+ * A point over a rail of a folding layout (`SplitLayout.folds`): the rail (the index in the basis's `folds` of the fold
802
+ * heading it) and the pane whose spine segment is painted there (`paintedSpines`), null in a gap or past the last
803
+ * segment. A rail takes no drop: the whole of its box is refused.
804
+ */
805
+ interface TilingFolded<K> {
806
+ readonly rail: number;
807
+ readonly pane: K | null;
808
+ }
635
809
  /** What a frame reads off the hit. */
636
810
  interface TilingHitRead<K> {
637
811
  /** The held place, home included; null when nothing is held outside home. */
@@ -640,6 +814,8 @@ interface TilingHitRead<K> {
640
814
  readonly refused: TilingHeld<K> | null;
641
815
  /** The lift basis's mark for the held place; null on the base basis, at home, and with nothing held. */
642
816
  readonly mark: TilingMark<K> | null;
817
+ /** Under a fold, the rail under the pointer and the pane painted there (`hit.foldedAt`); null off every rail. Nothing is held over a rail. */
818
+ readonly folded: TilingFolded<K> | null;
643
819
  }
644
820
  /**
645
821
  * The options a `@n-uf/motion/drag` intent takes to read the hit: no home (home is a place of the hit, held by the one
@@ -684,8 +860,14 @@ interface TilingHit<T, K> {
684
860
  * over home the intent may pick the part; its `placeOf` then answers null, and home wins.
685
861
  */
686
862
  placeOf(target: TilingHitTarget<K>, point: Point, previous?: string | null): string | null;
687
- /** The intent's frame at `point`, read: the held place, the refused one, and the lift basis's mark. */
863
+ /** The intent's frame at `point`, read: the held place, the refused one, the lift basis's mark, and the rail under the pointer. */
688
864
  read(frame: TilingHitFrame<TilingHitTarget<K>>, point: Point): TilingHitRead<K>;
865
+ /**
866
+ * Under a fold, the rail of the basis's layout whose box holds `point`, and the pane painted there; null off every
867
+ * rail. On the lift basis the rails are painted at the drag's `railOffset`, read anew at every call; on the base
868
+ * basis at none. Pure.
869
+ */
870
+ foldedAt(point: Point): TilingFolded<K> | null;
689
871
  /** What a frame draws: the lift on the lift basis; on the base basis `after(held)`, the lift at home, the base with nothing held. */
690
872
  drawn(read: TilingHitRead<K>): TilingLaidOut<T, K>;
691
873
  /** What a release commits: `after(held)`, else home's. */
@@ -743,19 +925,33 @@ declare function giveWay<K>(panes: readonly K[], layout: (kept: readonly K[]) =>
743
925
  * The host keeps its own tree type and its own changes; it hands them over as a `TilingTree` adapter. The library owns
744
926
  * the rules: what is released and when, which tree each change takes, home, the refusals, and the one layout per held
745
927
  * place. Geometry has one source: the adapter gives the tree as a `Split` (`split`), and the library lays it out with
746
- * `layoutSplitTree` under the drag's options (`SplitOptions` plus `min`, as `canDropOnPane` takes them).
928
+ * `layoutSplitTree` under the drag's options (`SplitOptions` plus `min`, as `canDropOnPane` takes them, and the host's
929
+ * `fold`). Under a fold every layout of the drag is folded with its own order (`TilingLaidOut.order`), so the drag hits
930
+ * and judges the rects the host draws.
747
931
  *
748
932
  * The hit half, which place the pointer is over, is `hit(basis)`: built once per drag on one fixed layout (./hit).
749
933
  * See docs/placement.md, Entry: tiling.
750
934
  */
751
935
 
752
- /** What `tilingDrag` reads: the adapter, the stage, and the layout options (`SplitOptions` plus `min`, the least pane width and height a drop keeps). */
753
- interface TilingDragOptions<T, K> extends DropOptions<K> {
936
+ /**
937
+ * What `tilingDrag` reads: the adapter, the stage, and the layout options (`SplitOptions` plus `min`, the least pane
938
+ * width and height a drop keeps, and `fold`, as `layoutSplitTree` takes it). `fold.order` is the lift's order: the
939
+ * drag derives the base's and each change's from it.
940
+ */
941
+ interface TilingDragOptions<T, K> extends DropOptions<K>, FoldingSplitOptions<K> {
754
942
  readonly ops: TilingTree<T, K>;
755
943
  /** The stage the tree is laid out in, px. */
756
944
  readonly area: Rect;
757
945
  /** Panes that take no drop (a swap, a side or a join on one is refused `"still"`). Default: none. */
758
946
  readonly still?: (pane: K) => boolean;
947
+ /**
948
+ * Under a fold whose rails' content runs past their boxes (`SplitFold.segmentFloor`), how far the host has moved each
949
+ * rail of the lift layout (`RailOffset`): asked only with the lift's folds, the fold heading the rail and its index
950
+ * (the lift is `layoutSplitTree`'s answer for the same input, so the index is the host's key, not the fold's `id`,
951
+ * which may be undefined). Read at every hit read (`hit.read`, `hit.foldedAt`), never kept: an offset change is a
952
+ * reason to read again. Not clamped; a value that is not a finite number reads 0. Default: 0 everywhere.
953
+ */
954
+ readonly railOffset?: RailOffset<K>;
759
955
  }
760
956
  /**
761
957
  * A drag of one subject: its base, its home, and the one layout of each held place. Built per drag: its `after` and its
@@ -769,7 +965,8 @@ interface TilingDrag<T, K> {
769
965
  readonly base: TilingLaidOut<T, K>;
770
966
  /**
771
967
  * The gap the release leaves: the subject's lift rect when releasing it takes a drawn pane away (a pane alone, a
772
- * whole stack), null when it takes none (a member torn out of a stack that stays drawn).
968
+ * whole stack), null when it takes none (a member torn out of a stack that stays drawn) or when the lift folds the
969
+ * subject (its spine segment is no gap: the pointer over it reads the spine).
773
970
  */
774
971
  readonly home: Rect | null;
775
972
  /** THE layout of `held`. Remembered per held place: the same place gives the same object. */
@@ -789,9 +986,17 @@ interface TilingDrag<T, K> {
789
986
  * - **`after(held).tree`** is what a release commits: `normalize(change)`, where the change is `beside` or `join` on
790
987
  * the released tree, or `swap` on the lift tree (see `TilingTree` for why). Home's is the lift tree, never normalized.
791
988
  * - **`layout`** is that tree laid out, so a frame that draws it draws exactly what the release stores.
792
- * - **Refusals** are judged on the base (room) and on the change's own layout (fit), never on another tree.
989
+ * - **Refusals** are judged on the base (room, and whether `at` is drawn open there) and on the change's own layout
990
+ * (fit), never on another tree.
991
+ * - **Under a fold** (`options.fold`) every layout is folded with its own order: the lift with the host's, the base
992
+ * with the panes open at the lift first (a torn tab's stack mates in its place), each change with the subject first,
993
+ * then the panes open at the lift. A pane
994
+ * the base folds is refused `folded`; there is no room rule (the one verdict on room is `fit` on the change's
995
+ * layout, where the subject must be drawn open and `at` may fold). The subject may be folded at the lift (a pane
996
+ * carried in): its lift rect is then its spine segment and `home` is null.
793
997
  *
794
- * Throws when the subject is not in `tree` (neither drawn nor a member of a drawn stack): a drag has nothing to lift.
998
+ * Throws when the subject is not in `tree` (neither drawn, open or on a spine, nor a member of a drawn stack): a drag
999
+ * has nothing to lift.
795
1000
  */
796
1001
  declare function tilingDrag<T, K>(tree: T, subject: TilingSubject<K>, options: TilingDragOptions<T, K>): TilingDrag<T, K>;
797
1002
 
@@ -826,7 +1031,7 @@ interface StackedSplit<K> {
826
1031
  declare function splitTreeOps<K>(options?: SplitTreeOpsOptions<K>): TilingTree<StackedSplit<K>, K>;
827
1032
 
828
1033
  /** The properties, by name (each is a key of `TilingConformance.counts`). */
829
- declare const TILING_PROPERTIES: readonly ["home-is-lift", "home-is-the-gap", "home-over-changed", "one-layout", "swap-exchanges", "swap-trades-slots", "swap-keeps-stack-mates", "subject-once", "release-first", "stack-moves-whole", "normalize-idempotent", "nothing-changes"];
1034
+ declare const TILING_PROPERTIES: readonly ["home-is-lift", "home-is-the-gap", "home-over-changed", "one-layout", "folded-refused", "swap-exchanges", "swap-trades-slots", "swap-keeps-stack-mates", "subject-once", "release-first", "stack-moves-whole", "normalize-idempotent", "nothing-changes"];
830
1035
  type TilingProperty = (typeof TILING_PROPERTIES)[number];
831
1036
  /** A conformance run: whether every property held, the first failures (in words), and per property how many checks ran and failed. */
832
1037
  interface TilingConformance {
@@ -847,7 +1052,7 @@ declare function tilingSubjects<T, K>(tree: T, options: Pick<TilingDragOptions<T
847
1052
  declare function tilingConformance<T, K>(trees: Iterable<T>, options: TilingDragOptions<T, K>, limit?: number): TilingConformance;
848
1053
 
849
1054
  /** The properties, by name (each is a key of `TilingHitConformance.counts`). */
850
- declare const TILING_HIT_PROPERTIES: readonly ["fixed-map", "zone-rule", "stillness", "hold-measures", "one-pass", "existence", "lift-equals-home", "shown-under-pointer", "shown-equals-landed", "new-arrangement-sides", "zones-convex", "room-free-map"];
1055
+ declare const TILING_HIT_PROPERTIES: readonly ["fixed-map", "zone-rule", "stillness", "hold-measures", "one-pass", "existence", "lift-equals-home", "shown-under-pointer", "shown-equals-landed", "new-arrangement-sides", "zones-convex", "room-free-map", "spine-no-place", "named-case-refused"];
851
1056
  type TilingHitProperty = (typeof TILING_HIT_PROPERTIES)[number];
852
1057
  /** A conformance run, as `tilingConformance`'s, and the rows the ruling counts rather than fails. */
853
1058
  interface TilingHitConformance {
@@ -896,4 +1101,4 @@ type Direction = "left" | "right" | "up" | "down";
896
1101
  */
897
1102
  declare function neighbor<K>(rects: ReadonlyMap<K, Rect>, from: K, direction: Direction): K | null;
898
1103
 
899
- export { type Direction, type DropFitsOptions, type DropOptions, type DropVerdict, type FixedLength, type MasterOptions, type MinLength, type OrderLayout, type OrderOptions, type OrderTarget, PANE_REGION_DEFAULTS, PANE_SIDES, type PaneCenter, type PaneRegion, type PaneRegionOptions, type PaneTarget, type PaneTargetsOptions, Rect, type Split, type SplitDecision, type SplitGeometry, type SplitLayout, type SplitOptions, type SplitRoomOptions, type SplitSide, type SplitStep, type SplitTreeOpsOptions, type StackedSplit, TILING_HIT_DEFAULTS, TILING_HIT_PROPERTIES, TILING_PROPERTIES, type TileOptions, type TilingAfter, type TilingBasis, type TilingConformance, type TilingDrag, type TilingDragOptions, type TilingHeld, type TilingHit, type TilingHitConformance, type TilingHitFrame, type TilingHitIntent, type TilingHitOptions, type TilingHitProperty, type TilingHitRead, type TilingHitRegions, type TilingHitTarget, type TilingHold, type TilingLaidOut, type TilingMark, type TilingMove, type TilingPart, type TilingProperty, type TilingRefusal, type TilingSize, type TilingStack, type TilingSubject, type TilingTree, canDropOnPane, canSplitPane, columns, decideSplit, dropFits, dropOnPane, giveWay, grid, layoutSplit, layoutSplitTree, masterCount, masterRatio, masterStack, neighbor, orderTargets, paneCenter, paneRegion, paneRegionShapes, paneTargets, panesOf, removePane, splitFromOrder, splitNeed, splitPane, splitTreeOps, swapPanes, tilingConformance, tilingDrag, tilingHitConformance, tilingSubjects };
1104
+ export { type Direction, type DropFitsOptions, type DropOptions, type DropVerdict, type FixedLength, type FoldedLayout, type FoldingSplitOptions, type MasterOptions, type MinLength, type OrderLayout, type OrderOptions, type OrderTarget, PANE_REGION_DEFAULTS, PANE_SIDES, type PaneCenter, type PaneRegion, type PaneRegionOptions, type PaneTarget, type PaneTargetsOptions, type RailOffset, Rect, type Split, type SplitDecision, type SplitFold, type SplitFoldGeometry, type SplitGeometry, type SplitLayout, type SplitOptions, type SplitRoomOptions, type SplitSide, type SplitStep, type SplitTreeOpsOptions, type StackedSplit, TILING_HIT_DEFAULTS, TILING_HIT_PROPERTIES, TILING_PROPERTIES, type TileOptions, type TilingAfter, type TilingBasis, type TilingConformance, type TilingDrag, type TilingDragOptions, type TilingFolded, type TilingHeld, type TilingHit, type TilingHitConformance, type TilingHitFrame, type TilingHitIntent, type TilingHitOptions, type TilingHitProperty, type TilingHitRead, type TilingHitRegions, type TilingHitTarget, type TilingHold, type TilingLaidOut, type TilingMark, type TilingMove, type TilingPart, type TilingProperty, type TilingRefusal, type TilingSize, type TilingStack, type TilingSubject, type TilingTree, canDropOnPane, canSplitPane, columns, decideSplit, dropFits, dropOnPane, giveWay, grid, layoutSplit, layoutSplitTree, masterCount, masterRatio, masterStack, neighbor, orderTargets, paintedSpines, paneCenter, paneRegion, paneRegionShapes, paneTargets, panesOf, removePane, splitFromOrder, splitNeed, splitPane, splitTreeOps, swapPanes, tilingConformance, tilingDrag, tilingHitConformance, tilingSubjects };