@n-uf/placement 26.12.6 → 26.12.7

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,27 @@ 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.7
9
+
10
+ - **Added:** a folding split tree. `layoutSplitTree(tree, area, { ...options, fold })` folds a split that cannot keep
11
+ its panes on their fold floors: one side stays open, the other is drawn as a spine on the edge where it sits.
12
+ `fold` (`SplitFold`) holds each pane's fold floor, the spine's thickness, the order of panes to keep open, and
13
+ optionally `targetOrder` and `weight`. The layout's new `spines` give each folded pane's segment of its spine and
14
+ `folds` each folded split (`SplitFoldGeometry`); a kept split's `needs` are the pair the fold chose. What folds
15
+ depends on the tree, the area and the host's answers only, never on the order. Every split outside a master split
16
+ needs an `axis` with `fold`. For consumers: lay out with `fold` and draw `panes` and `spines`; without `fold`,
17
+ nothing changes. A folded pane that shows nothing (weight 0) stays in its fold's `panes` with no segment in
18
+ `spines`. A repeated split `id` does not turn folding off. Where nothing folds, the layout equals the one without
19
+ the fold only on the same `options.floor`: with `fold`, a kept split's net is on where there is no `floor`. See
20
+ docs/decisions/0023-a-folding-split-tree-has-one-layout.md.
21
+ - **Added:** `SplitLayout.spines` and `SplitLayout.folds`, empty without `fold`; `FoldingSplitOptions`, the options
22
+ `layoutSplitTree` takes.
23
+ - **Changed (breaking, types):** `SplitLayout` has two new required fields, `spines` and `folds`, so code that builds
24
+ a `SplitLayout` itself (a test double, a host's own layout) must add them: `spines: new Map(), folds: []`.
25
+ - **Changed (breaking, behavior):** `layoutSplit`, `splitNeed`, `canDropOnPane`, `canSplitPane`, `dropFits`,
26
+ `tilingDrag`, `tilingConformance` and `tilingHitConformance` throw when their options hold a `fold` key ("use
27
+ layoutSplitTree"), so a fold is never ignored in silence: the drag and its rules do not read spines yet.
28
+
8
29
  ## 26.12.6
9
30
 
10
31
  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,65 @@ 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
+ /** One folded split of a laid-out tree (`SplitLayout.folds`). */
184
+ interface SplitFoldGeometry<K> {
185
+ /** The folded split's `id`, if it has one. */
186
+ readonly id: string | undefined;
187
+ /** The folded split's axis: `"x"` folds sideways (spine left or right), `"y"` up or down. */
188
+ readonly axis: Axis;
189
+ /** The side that stays open. */
190
+ readonly open: "a" | "b";
191
+ /** The edge the spine sits on: where the folded side is. */
192
+ readonly edge: Side;
193
+ /** The split's box. */
194
+ readonly rect: Rect;
195
+ /**
196
+ * The open side's box: the split's box less the spine and the split's gap; a fold whose spine joined an enclosing
197
+ * fold's rail gives up nothing, so its open side is the split's whole box.
198
+ */
199
+ readonly openRect: Rect;
200
+ /** The spine's box: its part of the rail, the whole rail when the rail holds this fold alone. */
201
+ readonly spine: Rect;
202
+ /** The whole rail's box, on `edge`, the spine's thickness across the split's axis. */
203
+ readonly rail: Rect;
204
+ /**
205
+ * The index in `folds` of the fold heading the rail this spine is drawn in: its own, or that of the enclosing fold on
206
+ * the same edge whose rail it joined (a fold whose box starts where that fold's open side starts on the edge, and
207
+ * spans the same length along it).
208
+ */
209
+ readonly railOf: number;
210
+ /** The index in `folds` of the nearest enclosing fold; null for an outermost fold. */
211
+ readonly parent: number | null;
212
+ /** The panes the spine stands for, in reading order. */
213
+ readonly panes: readonly K[];
214
+ /** 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. */
215
+ readonly target: K | null;
216
+ }
217
+
159
218
  /**
160
219
  * One split's decision: given its extent, its gutter, its stored ratio and what each side needs, how long each side
161
220
  * is along the split, and the ratio in effect. `layoutSplit` makes it for every split; a host that draws or stores a
@@ -291,10 +350,16 @@ interface SplitGeometry {
291
350
  */
292
351
  readonly needs: readonly [number, number] | null;
293
352
  }
294
- /** A tree laid out: every pane's rect, and the geometry of each split that has an `id`. */
353
+ /**
354
+ * 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,
355
+ * and, under a fold (`layoutSplitTree`'s `fold`), each folded pane's segment of its spine and the folds, outermost
356
+ * first. Without a fold, `spines` and `folds` are empty.
357
+ */
295
358
  interface SplitLayout<K> {
296
359
  readonly panes: Map<K, Rect>;
297
360
  readonly splits: Map<string, SplitGeometry>;
361
+ readonly spines: Map<K, Rect>;
362
+ readonly folds: readonly SplitFoldGeometry<K>[];
298
363
  }
299
364
  /**
300
365
  * The least length `tree` lands at along `axis`, laid out alone in an area with `options`: where the area is at
@@ -322,12 +387,6 @@ declare function splitNeed<K>(tree: Split<K> | null, axis: Axis, options?: Split
322
387
  * is, so pass an area with no negative side.
323
388
  */
324
389
  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
390
 
332
391
  /**
333
392
  * 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
@@ -380,6 +439,31 @@ interface DropFitsOptions {
380
439
  */
381
440
  declare function dropFits<K>(projected: ReadonlyMap<K, Rect>, dragged: K, at: K, area: Rect, options: DropFitsOptions): DropVerdict;
382
441
 
442
+ /**
443
+ * `layoutSplitTree`: the split tree laid out, folding or not. One function lays the tree out, so what a host draws,
444
+ * what a drag hits and what is judged to fit all come from it. See docs/placement.md, Entry: tiling.
445
+ */
446
+
447
+ /** `SplitOptions` plus the fold, which only `layoutSplitTree` takes: `layoutSplit`, `splitNeed` and `canDropOnPane` throw on it. */
448
+ interface FoldingSplitOptions<K> extends SplitOptions<K> {
449
+ readonly fold?: SplitFold<K>;
450
+ }
451
+ /**
452
+ * `layoutSplit` and the geometry of every split that has an `id` (a repeated id keeps the one laid out last: a split
453
+ * under another, or a later one beside it): the box it divides, its axis and ratio in effect (after the floors), and its
454
+ * divider, the gutter strip between its two sides. A split that lays out as master and stack is reported too, its
455
+ * nested splits are not.
456
+ *
457
+ * With `fold`, a split that cannot keep its panes on their fold floors may fold: one side stays open and the other is
458
+ * drawn as a spine (`spines`, `folds`); a folded split is not in `splits`, and a kept split's `needs` are the pair the
459
+ * fold chose. Every split outside a master split then needs an `axis` (throws otherwise); a master split never folds.
460
+ * Where nothing folds and no boundary moves, the panes and splits are those without the fold on the same
461
+ * `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
462
+ * 1000 without the fold, 50 px with it). A spine has a segment per folded pane that shows (weight 1). The drag and its
463
+ * rules (`tilingDrag`, `canSplitPane`, `dropFits`, the conformance runs) refuse a fold. See `SplitFold`.
464
+ */
465
+ declare function layoutSplitTree<K>(tree: Split<K> | null, area: Rect, options?: FoldingSplitOptions<K>): SplitLayout<K>;
466
+
383
467
  /**
384
468
  * The shapes a tiling drag's two halves share: the host's tree as an adapter (`TilingTree`) with its stacks, parts and
385
469
  * subjects, a held place (`TilingHeld`) and the layout it gives (`TilingAfter`). The layout half (./drag) and the hit
@@ -896,4 +980,4 @@ type Direction = "left" | "right" | "up" | "down";
896
980
  */
897
981
  declare function neighbor<K>(rects: ReadonlyMap<K, Rect>, from: K, direction: Direction): K | null;
898
982
 
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 };
983
+ export { type Direction, type DropFitsOptions, type DropOptions, type DropVerdict, type FixedLength, 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, 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 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 };