@n-uf/placement 26.11.57 → 26.11.59
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 +48 -0
- package/dist/tiling.d.ts +469 -2
- package/dist/tiling.js +1263 -11
- package/dist/tiling.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,54 @@ 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.11.59
|
|
9
|
+
|
|
10
|
+
- **Added: `tilingDrag(...).hit(basis)` in `./tiling`, which place the pointer is over in a tiling drag.** Ask for it at
|
|
11
|
+
the lift, with `"lift"` (the layout at the lift, the dragged pane's slot open: a host that draws a mark over it) or
|
|
12
|
+
`"base"` (the tree with the dragged pane released: a host that draws the landed layout); it is remembered per drag and
|
|
13
|
+
basis, like `after`, so a second call gives the same hit and its hold. It builds one zone map that does not change
|
|
14
|
+
during the drag, so what a frame draws never moves what the pointer is over. A host needs no motion for it:
|
|
15
|
+
`hit.placeAt(point)` is the place id at a point, `hit.heldOf(id)` the place it names, and `hit.hold(state, point)` the
|
|
16
|
+
pure step of the hold. For a host on `@n-uf/motion/drag` it gives the targets in its shape (one per pane, one per
|
|
17
|
+
pane part, and home), the intent's options (`hit.intent`, with no home: `createDragIntent({ ...hit.intent })` is the
|
|
18
|
+
wiring), and a reader: `hit.read(frame, point)` gives `{ held, refused, mark }` (a mark of the held place's kind:
|
|
19
|
+
`beside`, `swap` or `join`), `hit.drawn(read)` what a frame draws and `hit.release(read)` what a release commits. A
|
|
20
|
+
place exists when `after(place).refusal` is null; a refused zone holds nothing and falls to the zone beneath it. One
|
|
21
|
+
hold rule keeps the held place: until the pointer is 6 px past the edge of the part of its zone that shows (home wins
|
|
22
|
+
over what lies beneath it), and inside one pane until it is 24 px from where the place was taken (`TilingHold.from`),
|
|
23
|
+
each at most a quarter of the zone (`TILING_HIT_DEFAULTS`; `edge`, `travel` and `cap` are options, and `regions`
|
|
24
|
+
takes the five region options the hit reads, `TilingHitRegions`). A place that gives back the arrangement at the lift
|
|
25
|
+
counts as home. New API only: nothing that exists changes.
|
|
26
|
+
- **Added: a side of a pane takes an insert only for a new arrangement.** For the pane next to the dragged one in the same
|
|
27
|
+
run (whole children of one run, with the same bounds across it), the side that gives back the lift's order and the side
|
|
28
|
+
that repeats the swap are gone, and their strips belong to the center: it is a strip, one swap rectangle and a strip,
|
|
29
|
+
each the full length of the pane along the run, the swap 0.56 across it (the hit's option `neighborSwap`). A tab group
|
|
30
|
+
next to the dragged pane loses only the side facing it. Every other pane keeps its five regions. Two 2×2 grids that
|
|
31
|
+
look alike differ: built as two columns, the pane below the dragged one is swap-only; built as two rows, it is not.
|
|
32
|
+
- **Added: `TilingTree.parts(tree, pane, rect)`** (optional) for the parts of a pane that take a join (`TilingPart`: a
|
|
33
|
+
title bar, a tab strip with its slots), and `splitTreeOps({ bar, tab })` as the reference. A host that leaves it out
|
|
34
|
+
has no join under the pointer.
|
|
35
|
+
- **Added: `tilingHitConformance(trees, options)`** with the properties of `TILING_HIT_PROPERTIES` (a fixed map, the
|
|
36
|
+
zone rule, stillness, the hold's measures, one pass, existence, lift equals home, shown under the pointer, shown equals
|
|
37
|
+
landed, sides only for a new arrangement, convex zones, a map room does not move), run on a host's own adapter, with
|
|
38
|
+
the rows that are counted and not failed (`swapsBeside`, `insertsMoveOthers`, `insertsMoveOthersBeside`).
|
|
39
|
+
- **Added: `paneRegionShapes(rect, options)`** (the five regions as convex polygons) and the option `sides` of
|
|
40
|
+
`paneRegion` (which sides exist; a side left out gives its whole strip to the center). Without `sides`, every region
|
|
41
|
+
and place is as before.
|
|
42
|
+
|
|
43
|
+
## 26.11.58
|
|
44
|
+
|
|
45
|
+
- **Added: `tilingDrag` in `./tiling`, the layout half of a tiling drag.** `tilingDrag(tree, subject, { ops, area, min, ...splitOptions, still? })`
|
|
46
|
+
works over a `TilingTree` adapter (the host's own tree and changes; geometry from its `split(tree)`, laid out with
|
|
47
|
+
`layoutSplitTree`) and gives the lift and base layouts (the base is the tree with the subject released), `home` (the
|
|
48
|
+
gap the release leaves: the subject's lift rect, or null for a member torn out of a stack that stays drawn), and
|
|
49
|
+
`after(held)` for home, a swap, a side or a join: the tree a release commits, its layout, the landing, the panes it
|
|
50
|
+
moves, or a refusal code (`self`, `still`, `missing`, `join`, `room-along`, `room-across`, `fit`). What a frame holding
|
|
51
|
+
a place draws is what its release commits. `beside` and `join` act on the released tree, `swap` on the tree with the
|
|
52
|
+
subject still in it, so a swap's partner lands in the subject's old place; home commits the lift tree itself, never
|
|
53
|
+
normalized. `splitTreeOps` is the reference adapter over `StackedSplit` (a `Split` with stacks), and
|
|
54
|
+
`tilingConformance` runs the drag's properties on any adapter. New API only: no existing output changes.
|
|
55
|
+
|
|
8
56
|
## 26.11.57
|
|
9
57
|
|
|
10
58
|
- **Added: `Side` and `Axis` in the root.** `Side` is `"top" | "right" | "bottom" | "left"` and `Axis` is `"x" | "y"`, the
|
package/dist/tiling.d.ts
CHANGED
|
@@ -77,8 +77,13 @@ interface PaneRegionOptions {
|
|
|
77
77
|
* reads it; its `width` and `height` are the pane's own size for the hold toward the middle.
|
|
78
78
|
*/
|
|
79
79
|
readonly paneCenter?: PaneCenter;
|
|
80
|
+
/**
|
|
81
|
+
* The sides that exist (default: all four). A point is in the center unless it lies past the center's edge toward a
|
|
82
|
+
* side that exists: a side left out gives its whole strip to the center, which then reaches the pane's edge there.
|
|
83
|
+
*/
|
|
84
|
+
readonly sides?: readonly Side[];
|
|
80
85
|
}
|
|
81
|
-
declare const PANE_REGION_DEFAULTS: Required<Omit<PaneRegionOptions, "centerX" | "centerY" | "paneCenter">>;
|
|
86
|
+
declare const PANE_REGION_DEFAULTS: Required<Omit<PaneRegionOptions, "centerX" | "centerY" | "paneCenter" | "sides">>;
|
|
82
87
|
/** The center rectangle of a pane of `size`, in pane-local px (origin at the pane's top-left corner). */
|
|
83
88
|
interface PaneCenter {
|
|
84
89
|
readonly width: number;
|
|
@@ -90,6 +95,14 @@ interface PaneCenter {
|
|
|
90
95
|
}
|
|
91
96
|
/** Where the center rectangle of a pane of `size` lies, by these options. */
|
|
92
97
|
declare function paneCenter(size: Size, options?: PaneRegionOptions): PaneCenter;
|
|
98
|
+
/**
|
|
99
|
+
* The regions of `pane` as convex polygons, in the same coordinates as `pane`: the center rectangle, and each side's
|
|
100
|
+
* trapezoid from the pane's two corners on that side to the center's two nearest corners. They are the regions
|
|
101
|
+
* `paneRegion` names (no hysteresis): a point inside one, off its shared edges, is in that region. A side left out of
|
|
102
|
+
* `options.sides` has no polygon (empty); the center reaches the pane's edge there, and a neighboring side's polygon
|
|
103
|
+
* takes the corner toward it.
|
|
104
|
+
*/
|
|
105
|
+
declare function paneRegionShapes(pane: Rect, options?: PaneRegionOptions): Readonly<Record<PaneRegion, readonly Point[]>>;
|
|
93
106
|
/**
|
|
94
107
|
* The drop region of `pane` (in the same coordinates as `point`) the point is in. With a `previous` region, the point
|
|
95
108
|
* has to be `hysteresis` px past that region's boundary before the region changes: no time-based debounce, only
|
|
@@ -269,6 +282,318 @@ interface DropFitsOptions {
|
|
|
269
282
|
*/
|
|
270
283
|
declare function dropFits<K>(projected: ReadonlyMap<K, Rect>, dragged: K, at: K, area: Rect, options: DropFitsOptions): DropVerdict;
|
|
271
284
|
|
|
285
|
+
/**
|
|
286
|
+
* The shapes a tiling drag's two halves share: the host's tree as an adapter (`TilingTree`) with its stacks, parts and
|
|
287
|
+
* subjects, a held place (`TilingHeld`) and the layout it gives (`TilingAfter`). The layout half (./drag) and the hit
|
|
288
|
+
* half (./hit) both read them, so they live apart from either. Types only.
|
|
289
|
+
* See docs/placement.md, Entry: tiling.
|
|
290
|
+
*/
|
|
291
|
+
|
|
292
|
+
/** A stack as the adapter reports it: its id, its members in order, and the member it is drawn as. */
|
|
293
|
+
interface TilingStack<K> {
|
|
294
|
+
readonly id: string;
|
|
295
|
+
readonly members: readonly K[];
|
|
296
|
+
readonly active: K;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* What a drag moves: one pane (a member of a stack is torn out of it), or a whole stack, every member as one. A stack
|
|
300
|
+
* subject carries the stack as the adapter reported it at the lift (`stackOf`), so the changes that place it after its
|
|
301
|
+
* release (`beside`, `join`) have its members.
|
|
302
|
+
*/
|
|
303
|
+
type TilingSubject<K> = {
|
|
304
|
+
readonly kind: "pane";
|
|
305
|
+
readonly pane: K;
|
|
306
|
+
} | {
|
|
307
|
+
readonly kind: "stack";
|
|
308
|
+
readonly stack: TilingStack<K>;
|
|
309
|
+
};
|
|
310
|
+
/**
|
|
311
|
+
* How a side drop sizes the split it makes. One kind today: the two panes take half each (the split `splitPane`
|
|
312
|
+
* writes). A later rule may size the subject by its own length; it will be a new kind here, never an option.
|
|
313
|
+
*/
|
|
314
|
+
type TilingSize = {
|
|
315
|
+
readonly kind: "half";
|
|
316
|
+
};
|
|
317
|
+
/**
|
|
318
|
+
* A part of a pane that takes a join, as the adapter declares it on the pane's rect (`TilingTree.parts`): a title bar,
|
|
319
|
+
* a tab strip. `slots`, when given, are rects within it; the slot under the pointer gives the join's index: slot `i`
|
|
320
|
+
* stands before the `i`-th member of the pane's stack in the tree the part was declared on (the pane itself when it
|
|
321
|
+
* is alone). Over the part but no slot, the join has no index (the adapter's default: last).
|
|
322
|
+
*/
|
|
323
|
+
interface TilingPart {
|
|
324
|
+
readonly key: string;
|
|
325
|
+
readonly rect: Rect;
|
|
326
|
+
readonly slots?: readonly Rect[];
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* The host's tree, as a drag reads and changes it. Every function is pure: it never changes the tree it is given, and
|
|
330
|
+
* returns a new tree (or the same one when nothing changes).
|
|
331
|
+
*
|
|
332
|
+
* Which tree each change takes, and why:
|
|
333
|
+
* - `beside` and `join` take the **released** tree (`release`'s result): the subject leaves its old place first, so the
|
|
334
|
+
* place it lands in is measured, and changed, without it. A pane beside its own old sibling then lands as if it were
|
|
335
|
+
* new there, and a stack never holds the subject twice.
|
|
336
|
+
* - `swap` takes the tree **with the subject still in it**: a swap exchanges two places, and the subject's old place is
|
|
337
|
+
* exactly where the partner goes. With the subject released there would be no old place to give the partner.
|
|
338
|
+
*/
|
|
339
|
+
interface TilingTree<T, K> {
|
|
340
|
+
/** The tree as panes divide the area: a `Split` of the drawn panes (a stack stands in it as its active member's key). */
|
|
341
|
+
split(tree: T): Split<K> | null;
|
|
342
|
+
/** The stack `pane` is a member of, or null; leave it out when the tree has no stacks. */
|
|
343
|
+
stackOf?(tree: T, pane: K): TilingStack<K> | null;
|
|
344
|
+
/** `tree` without the subject: a pane leaves its place (or its stack), a stack leaves with every member. */
|
|
345
|
+
release(tree: T, subject: TilingSubject<K>): T;
|
|
346
|
+
/** The released tree with the subject placed on `side` of the drawn pane `at`, sized by `size`. */
|
|
347
|
+
beside(released: T, subject: TilingSubject<K>, at: K, side: Side, size: TilingSize): T;
|
|
348
|
+
/**
|
|
349
|
+
* `tree` (the subject still in it) with the subject and the drawn pane `at` in each other's place.
|
|
350
|
+
* - A pane subject and `at` each take the other's slot, in the split or in a stack. The swap moves `at` alone, never
|
|
351
|
+
* the stack it stands for: when `at` is a stack's drawn member, the subject takes its place in that stack (drawn,
|
|
352
|
+
* as `at` was) and the stack's other members stay; `at` goes to the subject's old slot (alone, or in the subject's
|
|
353
|
+
* stack, at its index, when the subject is a member torn out of one).
|
|
354
|
+
* - A whole stack subject trades its drawn slot in the split with `at`'s; when `at` is a stack's drawn member, the
|
|
355
|
+
* two stacks trade places, each whole.
|
|
356
|
+
*/
|
|
357
|
+
swap(tree: T, subject: TilingSubject<K>, at: K): T;
|
|
358
|
+
/** The released tree with the subject joined to the drawn pane `at`'s stack (made one when `at` is alone), at `index` (default: last). Leave it out when the tree has no stacks: every join is refused `"join"`. */
|
|
359
|
+
join?(released: T, subject: TilingSubject<K>, at: K, index?: number): T;
|
|
360
|
+
/** Commit-time reconciliation: part of every `after` but home's, so what a frame draws is what a release stores. Default: none. */
|
|
361
|
+
normalize?(tree: T): T;
|
|
362
|
+
/**
|
|
363
|
+
* The parts of the drawn pane `pane` that take a join (a title bar, a tab strip), laid on `rect`, its rect in `tree`
|
|
364
|
+
* laid out: declared geometry, with any size the host measured once at the lift (a tab's width, by member). Read once
|
|
365
|
+
* per drag by `TilingDrag.hit`. Leave it out when no pane has one: a join is then never under the pointer.
|
|
366
|
+
*/
|
|
367
|
+
parts?(tree: T, pane: K, rect: Rect): readonly TilingPart[];
|
|
368
|
+
}
|
|
369
|
+
/** A held place of a drag: where a release now lands. `at` is always a pane drawn in the base. */
|
|
370
|
+
type TilingHeld<K> = {
|
|
371
|
+
readonly kind: "home";
|
|
372
|
+
} | {
|
|
373
|
+
readonly kind: "swap";
|
|
374
|
+
readonly at: K;
|
|
375
|
+
} | {
|
|
376
|
+
readonly kind: "beside";
|
|
377
|
+
readonly at: K;
|
|
378
|
+
readonly side: Side;
|
|
379
|
+
} | {
|
|
380
|
+
readonly kind: "join";
|
|
381
|
+
readonly at: K;
|
|
382
|
+
readonly index?: number;
|
|
383
|
+
};
|
|
384
|
+
/**
|
|
385
|
+
* Why a held place takes no release, as a code:
|
|
386
|
+
* - `self`: the place is the subject's own (a swap or side of the subject itself, a swap with its own stack, a whole
|
|
387
|
+
* stack joined to itself);
|
|
388
|
+
* - `still`: `at` is a still pane;
|
|
389
|
+
* - `missing`: `at` is not a pane drawn in the base;
|
|
390
|
+
* - `join`: the adapter has no `join`;
|
|
391
|
+
* - `room-along`, `room-across`: `at` is too short for two panes along the split, or too narrow across it, in the base
|
|
392
|
+
* (`canSplitPane`): `need` and `have` px;
|
|
393
|
+
* - `fit`: in the layout the release makes (a side, a swap or a join), `pane` (the subject's drawn key or `at`'s) is
|
|
394
|
+
* below `min` wide or high, the fit rule of `dropFits`. A swap hands each pane the other's rect, so either may fall
|
|
395
|
+
* below it; a join is judged on the stack's rect.
|
|
396
|
+
*/
|
|
397
|
+
type TilingRefusal<K> = {
|
|
398
|
+
readonly code: "self" | "still" | "missing" | "join";
|
|
399
|
+
} | {
|
|
400
|
+
readonly code: "room-along" | "room-across";
|
|
401
|
+
readonly need: number;
|
|
402
|
+
readonly have: number;
|
|
403
|
+
} | {
|
|
404
|
+
readonly code: "fit";
|
|
405
|
+
readonly pane: K;
|
|
406
|
+
};
|
|
407
|
+
/** A tree laid out: every drawn pane's rect, and the geometry of each split that has an id. */
|
|
408
|
+
interface TilingLaidOut<T, K> {
|
|
409
|
+
readonly tree: T;
|
|
410
|
+
readonly layout: ReadonlyMap<K, Rect>;
|
|
411
|
+
readonly splits: ReadonlyMap<string, SplitGeometry>;
|
|
412
|
+
}
|
|
413
|
+
/** A pane a commit moves, from where it was drawn at the lift to where the commit puts it. */
|
|
414
|
+
interface TilingMove<K> {
|
|
415
|
+
readonly pane: K;
|
|
416
|
+
readonly from: Rect;
|
|
417
|
+
readonly to: Rect;
|
|
418
|
+
}
|
|
419
|
+
/** THE layout of a held place: what a release commits, and what a frame holding it draws. */
|
|
420
|
+
interface TilingAfter<T, K> extends TilingLaidOut<T, K> {
|
|
421
|
+
readonly held: TilingHeld<K>;
|
|
422
|
+
/**
|
|
423
|
+
* Why a release here commits nothing, or null. A refused place's tree and layout are the lift's (what its release
|
|
424
|
+
* keeps), its landing null and nothing moved; a frame holding it draws rest (the base).
|
|
425
|
+
*/
|
|
426
|
+
readonly refusal: TilingRefusal<K> | null;
|
|
427
|
+
/** The subject's rect in `layout`: its own when it is drawn, else its stack's. Null when refused. */
|
|
428
|
+
readonly landing: Rect | null;
|
|
429
|
+
/** Every other drawn pane whose rect differs from the lift's (the swap partner, the panes that give room), in `layout`'s order. */
|
|
430
|
+
readonly moved: readonly TilingMove<K>[];
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* The hit half of a tiling drag: which place the pointer is over. `tilingDrag(...).hit(basis)` builds it once per drag,
|
|
435
|
+
* at the lift, from one layout that never changes during the drag: `"lift"` (the tree at the lift, the subject's slot
|
|
436
|
+
* open) for a host that draws only marks over it, `"base"` (the subject released, the gap closed) for a host that draws
|
|
437
|
+
* the landed layout of the held place. Nothing is measured or laid out anew per frame.
|
|
438
|
+
*
|
|
439
|
+
* - **Targets**, in `@n-uf/motion/drag`'s target shape: one body target per pane the basis draws (not the subject's own
|
|
440
|
+
* slot, not a still pane), its places the five regions of `paneRegion` (the center swaps, a side goes beside); one
|
|
441
|
+
* target per part the adapter declares on that pane (`TilingTree.parts`: a title bar, a tab strip), its place a join,
|
|
442
|
+
* a slot under the pointer giving the index; and home, the subject's lift rect, which wins over everything beneath it.
|
|
443
|
+
* A side exists only for a new arrangement: on a run neighbor of the subject (next to it as a whole child of one run
|
|
444
|
+
* on the lift tree, with the same bounds across), a side whose insert gives the lift's arrangement or the swap's is
|
|
445
|
+
* gone and its strip belongs to the center; the swap then spans `neighborSwap` (0.56) across the run. The run-neighbor
|
|
446
|
+
* rule removes sides first; home then takes what remains that gives the lift back.
|
|
447
|
+
* - **Places**: a place exists when `after(place).refusal` is null. A refused zone holds nothing and falls to the target
|
|
448
|
+
* beneath it (a refused part to the pane's body), never sideways. A place whose `after` equals the lift is home.
|
|
449
|
+
* - **One hold rule, two measures**: the held place keeps its zone until the pointer is `edge` px past the edge of that
|
|
450
|
+
* zone's visible part (the part no zone above it covers: home, a part over a body, a slot over its part; home wins over
|
|
451
|
+
* what lies beneath it), home included; inside one pane, not over home, it also keeps until the pointer is `travel` px
|
|
452
|
+
* from where the place was taken. Any change of place takes the point anew. Each measure is at most `cap` of the held
|
|
453
|
+
* zone's extent on each axis: the edge measure per axis (a box around the zone, rounded at its corners), the travel
|
|
454
|
+
* measure as an ellipse with those two radii.
|
|
455
|
+
* - **The reader**: `read(frame, point)` turns a drag intent's frame into `{ held, refused, mark }`: the held place (home
|
|
456
|
+
* included, null when nothing is held outside home), the refused place under the pointer when nothing is held, and, on
|
|
457
|
+
* the lift basis, the mark: a region of the lift layout (the target's half for a side, its outline for a swap or a
|
|
458
|
+
* join, and for a swap the wash in the open slot), never an `after` rect.
|
|
459
|
+
*
|
|
460
|
+
* See docs/placement.md, Entry: tiling, "A tiling drag's hit half".
|
|
461
|
+
*/
|
|
462
|
+
|
|
463
|
+
/** Which layout a drag hit-tests, fixed at the lift: the lift (a host that draws marks) or the base (a host that draws the landed layout). */
|
|
464
|
+
type TilingBasis = "lift" | "base";
|
|
465
|
+
/** A hit target, in `@n-uf/motion/drag`'s target shape. */
|
|
466
|
+
interface TilingHitTarget<K> extends Target {
|
|
467
|
+
/** The pane the basis draws under it (for home, the subject's own). */
|
|
468
|
+
readonly pane: K;
|
|
469
|
+
/** The pane its places name (`at`), as the base draws it. */
|
|
470
|
+
readonly at: K;
|
|
471
|
+
/** The part's key, on a part's target. */
|
|
472
|
+
readonly part?: string;
|
|
473
|
+
/** Home's target: the subject's lift rect. */
|
|
474
|
+
readonly home?: true;
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* The region options the hit reads: the center's share of each pane axis (`center`, or `centerX` / `centerY`), its
|
|
478
|
+
* floor and the pixel grid. The sides and a run neighbor's share are the hit's own, and the hold is its own rule.
|
|
479
|
+
*/
|
|
480
|
+
type TilingHitRegions = Pick<PaneRegionOptions, "center" | "centerX" | "centerY" | "centerMin" | "pixelRatio">;
|
|
481
|
+
/** The hit's options. */
|
|
482
|
+
interface TilingHitOptions<K> {
|
|
483
|
+
/** The pane regions (`TilingHitRegions`). */
|
|
484
|
+
readonly regions?: TilingHitRegions;
|
|
485
|
+
/** A pane's key in target and place ids; default `String`. Keys must be unique across panes. */
|
|
486
|
+
readonly key?: (pane: K) => string;
|
|
487
|
+
/** The edge measure, px (default 6). */
|
|
488
|
+
readonly edge?: number;
|
|
489
|
+
/** The travel measure inside one pane, px (default 24). */
|
|
490
|
+
readonly travel?: number;
|
|
491
|
+
/** The most either measure is of the held zone's extent, per axis (default 0.25). */
|
|
492
|
+
readonly cap?: number;
|
|
493
|
+
/** A run neighbor's swap across the run, a share of its extent there (default 0.56): each side strip is half the rest. */
|
|
494
|
+
readonly neighborSwap?: number;
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* The hit's defaults: 6 px past the edge, 24 px of travel inside one pane, each at most a quarter of the zone (`cap`);
|
|
498
|
+
* a run neighbor's swap spans 56 % across the run, each side strip 22 %, so a strip is about as large as a normal side
|
|
499
|
+
* band (a side insert is as easy to hit there as on any other pane).
|
|
500
|
+
*/
|
|
501
|
+
declare const TILING_HIT_DEFAULTS: {
|
|
502
|
+
readonly edge: number;
|
|
503
|
+
readonly travel: number;
|
|
504
|
+
readonly cap: number;
|
|
505
|
+
readonly neighborSwap: number;
|
|
506
|
+
};
|
|
507
|
+
/** What the hold rule keeps: the held place's id, and the point the place was taken from. */
|
|
508
|
+
interface TilingHold {
|
|
509
|
+
readonly place: string;
|
|
510
|
+
readonly from: Point;
|
|
511
|
+
}
|
|
512
|
+
/** The part of a drag intent's frame the reader reads. */
|
|
513
|
+
interface TilingHitFrame<T> {
|
|
514
|
+
readonly shown: T | null;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* A lift-basis mark: a region of the lift layout, of the held place's kind. Beside: the target pane's half on that
|
|
518
|
+
* side, as drawn. A swap: the target's outline, and the wash in the open slot (home; none when the release leaves no
|
|
519
|
+
* slot). A join: the target's outline, and its slot when the join has an index.
|
|
520
|
+
*/
|
|
521
|
+
type TilingMark<K> = {
|
|
522
|
+
readonly kind: "beside";
|
|
523
|
+
readonly at: K;
|
|
524
|
+
readonly side: Side;
|
|
525
|
+
readonly rect: Rect;
|
|
526
|
+
} | {
|
|
527
|
+
readonly kind: "swap";
|
|
528
|
+
readonly at: K;
|
|
529
|
+
readonly rect: Rect;
|
|
530
|
+
readonly wash: Rect | null;
|
|
531
|
+
} | {
|
|
532
|
+
readonly kind: "join";
|
|
533
|
+
readonly at: K;
|
|
534
|
+
readonly rect: Rect;
|
|
535
|
+
readonly slot: Rect | null;
|
|
536
|
+
};
|
|
537
|
+
/** What a frame reads off the hit. */
|
|
538
|
+
interface TilingHitRead<K> {
|
|
539
|
+
/** The held place, home included; null when nothing is held outside home. */
|
|
540
|
+
readonly held: TilingHeld<K> | null;
|
|
541
|
+
/** The refused place under the pointer, when nothing is held (nothing is drawn for it). */
|
|
542
|
+
readonly refused: TilingHeld<K> | null;
|
|
543
|
+
/** The lift basis's mark for the held place; null on the base basis, at home, and with nothing held. */
|
|
544
|
+
readonly mark: TilingMark<K> | null;
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* 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
|
|
548
|
+
* rule; the intent's own home test would cut it at the plain edge), no time-based gate or hold, and a band as wide as
|
|
549
|
+
* the edge measure so the intent keeps every target the hit still holds. The hit decides; the intent shows it. A host
|
|
550
|
+
* adds no time gate of its own (a dwell): the hold is the hit's, by distance.
|
|
551
|
+
*/
|
|
552
|
+
interface TilingHitIntent<K> {
|
|
553
|
+
readonly tuning: {
|
|
554
|
+
readonly aimSpeed: number;
|
|
555
|
+
readonly dwell: number;
|
|
556
|
+
readonly switchHold: number;
|
|
557
|
+
readonly roomAfter: number;
|
|
558
|
+
readonly band: number;
|
|
559
|
+
readonly bandShare: number;
|
|
560
|
+
readonly breakthrough: number;
|
|
561
|
+
readonly gapGrace: number;
|
|
562
|
+
};
|
|
563
|
+
readonly placeOf: (target: TilingHitTarget<K>, point: Point, previous: string | null) => string | null;
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* A drag's hit: built once per drag and basis (`drag.hit(basis)` gives the same one again), its targets and zones fixed
|
|
567
|
+
* for the drag. It hit-tests `drag[hit.basis]`, the lift or the base.
|
|
568
|
+
*/
|
|
569
|
+
interface TilingHit<T, K> {
|
|
570
|
+
readonly basis: TilingBasis;
|
|
571
|
+
/** Home: the subject's lift rect, or null when the release leaves no slot. */
|
|
572
|
+
readonly home: Rect | null;
|
|
573
|
+
/** Every target, fixed for the drag. */
|
|
574
|
+
readonly targets: readonly TilingHitTarget<K>[];
|
|
575
|
+
/** The options for a drag intent (`createDragIntent({ ...hit.intent })`). */
|
|
576
|
+
readonly intent: TilingHitIntent<K>;
|
|
577
|
+
/** The zone map: the place id at `point` with nothing held (`"home"` for home), or null. Pure. */
|
|
578
|
+
placeAt(point: Point): string | null;
|
|
579
|
+
/** The hold rule: what is held at `point` after `state` (null: nothing held yet). Pure: a host with no intent steps it itself. */
|
|
580
|
+
hold(state: TilingHold | null, point: Point): TilingHold | null;
|
|
581
|
+
/** The place an id names (hosts never parse ids). */
|
|
582
|
+
heldOf(id: string): TilingHeld<K> | null;
|
|
583
|
+
/**
|
|
584
|
+
* The intent's `placeOf`: the held place at `point` when it is on `target`, else null. Steps the drag's one hold, once
|
|
585
|
+
* per point. `previous` is not read: the hold is the hit's. Home and a part are both priority 1, so where a part lies
|
|
586
|
+
* over home the intent may pick the part; its `placeOf` then answers null, and home wins.
|
|
587
|
+
*/
|
|
588
|
+
placeOf(target: TilingHitTarget<K>, point: Point, previous?: string | null): string | null;
|
|
589
|
+
/** The intent's frame at `point`, read: the held place, the refused one, and the lift basis's mark. */
|
|
590
|
+
read(frame: TilingHitFrame<TilingHitTarget<K>>, point: Point): TilingHitRead<K>;
|
|
591
|
+
/** 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. */
|
|
592
|
+
drawn(read: TilingHitRead<K>): TilingLaidOut<T, K>;
|
|
593
|
+
/** What a release commits: `after(held)`, else home's. */
|
|
594
|
+
release(read: TilingHitRead<K>): TilingAfter<T, K>;
|
|
595
|
+
}
|
|
596
|
+
|
|
272
597
|
/**
|
|
273
598
|
* Drop targets for tiling, in the root `Target` shape (what `@n-uf/motion/drag` takes). Both kinds come from one
|
|
274
599
|
* helper: a pane target (`pane:<id>`, its hit the pane, the place in it its drop region) for the split tree, and an
|
|
@@ -312,6 +637,148 @@ declare function giveWay<K>(panes: readonly K[], layout: (kept: readonly K[]) =>
|
|
|
312
637
|
floats: K[];
|
|
313
638
|
};
|
|
314
639
|
|
|
640
|
+
/**
|
|
641
|
+
* One layout for a tiling drag's held frame and its commit, the layout half: `tilingDrag(tree, subject, options)` gives
|
|
642
|
+
* the drag's base (the tree with the subject released, laid out), its home (the gap the release leaves) and
|
|
643
|
+
* `after(held)`, THE layout of each held place: what a release there commits, and what a frame holding it draws.
|
|
644
|
+
*
|
|
645
|
+
* The host keeps its own tree type and its own changes; it hands them over as a `TilingTree` adapter. The library owns
|
|
646
|
+
* the rules: what is released and when, which tree each change takes, home, the refusals, and the one layout per held
|
|
647
|
+
* place. Geometry has one source: the adapter gives the tree as a `Split` (`split`), and the library lays it out with
|
|
648
|
+
* `layoutSplitTree` under the drag's options (`SplitOptions` plus `min`, as `canDropOnPane` takes them).
|
|
649
|
+
*
|
|
650
|
+
* The hit half, which place the pointer is over, is `hit(basis)`: built once per drag on one fixed layout (./hit).
|
|
651
|
+
* See docs/placement.md, Entry: tiling.
|
|
652
|
+
*/
|
|
653
|
+
|
|
654
|
+
/** What `tilingDrag` reads: the adapter, the stage, and the layout options (`SplitOptions` plus `min`, the least pane width and height a drop keeps). */
|
|
655
|
+
interface TilingDragOptions<T, K> extends DropOptions<K> {
|
|
656
|
+
readonly ops: TilingTree<T, K>;
|
|
657
|
+
/** The stage the tree is laid out in, px. */
|
|
658
|
+
readonly area: Rect;
|
|
659
|
+
/** Panes that take no drop (a swap, a side or a join on one is refused `"still"`). Default: none. */
|
|
660
|
+
readonly still?: (pane: K) => boolean;
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* A drag of one subject: its base, its home, and the one layout of each held place. Built per drag: its `after` and its
|
|
664
|
+
* hits (with their hold) are remembered for that drag alone, so a drag cancelled and lifted again takes a new one.
|
|
665
|
+
*/
|
|
666
|
+
interface TilingDrag<T, K> {
|
|
667
|
+
readonly subject: TilingSubject<K>;
|
|
668
|
+
/** The tree at the lift, laid out: what is drawn before the drag, and what a release on home commits. */
|
|
669
|
+
readonly lift: TilingLaidOut<T, K>;
|
|
670
|
+
/** The hit basis, fixed for the drag: the tree with the subject released, laid out. What a frame draws at rest (nothing held, or a refused place). */
|
|
671
|
+
readonly base: TilingLaidOut<T, K>;
|
|
672
|
+
/**
|
|
673
|
+
* The gap the release leaves: the subject's lift rect when releasing it takes a drawn pane away (a pane alone, a
|
|
674
|
+
* whole stack), null when it takes none (a member torn out of a stack that stays drawn).
|
|
675
|
+
*/
|
|
676
|
+
readonly home: Rect | null;
|
|
677
|
+
/** THE layout of `held`. Remembered per held place: the same place gives the same object. */
|
|
678
|
+
after(held: TilingHeld<K>): TilingAfter<T, K>;
|
|
679
|
+
/**
|
|
680
|
+
* The drag's hit half on `basis`, built from that one layout and fixed for the drag: `"lift"` for a host that draws
|
|
681
|
+
* marks over the lift, `"base"` for one that draws the held place's landed layout. Remembered per basis, as `after` is
|
|
682
|
+
* per place: every call on one basis gives the same hit, with its one hold, and the first call's options stand. A
|
|
683
|
+
* fresh hold is the pure `hit.hold(state, point)`.
|
|
684
|
+
*/
|
|
685
|
+
hit(basis: TilingBasis, options?: TilingHitOptions<K>): TilingHit<T, K>;
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* The drag of `subject` in `tree`: its lift and base layouts, its home, and `after(held)`, the one layout of each held
|
|
689
|
+
* place. `tree` is never changed; `after({ kind: "home" }).tree` is `tree` itself.
|
|
690
|
+
*
|
|
691
|
+
* - **`after(held).tree`** is what a release commits: `normalize(change)`, where the change is `beside` or `join` on
|
|
692
|
+
* the released tree, or `swap` on the lift tree (see `TilingTree` for why). Home's is the lift tree, never normalized.
|
|
693
|
+
* - **`layout`** is that tree laid out, so a frame that draws it draws exactly what the release stores.
|
|
694
|
+
* - **Refusals** are judged on the base (room) and on the change's own layout (fit), never on another tree.
|
|
695
|
+
*
|
|
696
|
+
* Throws when the subject is not in `tree` (neither drawn nor a member of a drawn stack): a drag has nothing to lift.
|
|
697
|
+
*/
|
|
698
|
+
declare function tilingDrag<T, K>(tree: T, subject: TilingSubject<K>, options: TilingDragOptions<T, K>): TilingDrag<T, K>;
|
|
699
|
+
|
|
700
|
+
/** The reference adapter's parts: none by default. */
|
|
701
|
+
interface SplitTreeOpsOptions<K> {
|
|
702
|
+
/** A title bar's height along each pane's top, px: its one part (a join). Default 0: no parts. */
|
|
703
|
+
readonly bar?: number;
|
|
704
|
+
/** A stack's tab width per member, px (default 80): its bar's slots. */
|
|
705
|
+
readonly tab?: (member: K) => number;
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* A split tree with stacks: `split` divides the area among the drawn panes, and each stack stands in it as its
|
|
709
|
+
* `active` member's key. A pane in no stack is drawn alone. A stack of one is kept until `normalize` makes it a pane.
|
|
710
|
+
*/
|
|
711
|
+
interface StackedSplit<K> {
|
|
712
|
+
readonly split: Split<K> | null;
|
|
713
|
+
readonly stacks?: readonly TilingStack<K>[];
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* The reference adapter over `StackedSplit<K>`:
|
|
717
|
+
* - `release`: a whole stack leaves the split (its drawn key, `removePane`) and the stack list; a pane in a stack leaves
|
|
718
|
+
* its members (the next member, else the one before, is drawn when it was the active one); a pane alone leaves the split;
|
|
719
|
+
* - `beside`: `splitPane` on `at`'s side (a half split), a whole stack drawn as its active member and kept whole;
|
|
720
|
+
* - `swap`: a pane trades keys with `at` wherever each is (the split, a stack's members), so each takes the other's
|
|
721
|
+
* place; a whole stack trades its drawn place in the split with `at`'s;
|
|
722
|
+
* - `join`: the subject's members go into `at`'s stack at `index` (default last; clamped), the first of them drawn; a
|
|
723
|
+
* pane `at` alone becomes a stack, its id `stack:<at>` (made unique);
|
|
724
|
+
* - `normalize`: a stack of fewer than two members becomes its pane; the same object when there is none;
|
|
725
|
+
* - `parts` (with `options.bar`): a title bar along each pane's top, `bar` px high; a stack's bar has a slot per member,
|
|
726
|
+
* left to right, each `tab(member)` px wide (default 80), cut at the bar's end.
|
|
727
|
+
*/
|
|
728
|
+
declare function splitTreeOps<K>(options?: SplitTreeOpsOptions<K>): TilingTree<StackedSplit<K>, K>;
|
|
729
|
+
|
|
730
|
+
/** The properties, by name (each is a key of `TilingConformance.counts`). */
|
|
731
|
+
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"];
|
|
732
|
+
type TilingProperty = (typeof TILING_PROPERTIES)[number];
|
|
733
|
+
/** A conformance run: whether every property held, the first failures (in words), and per property how many checks ran and failed. */
|
|
734
|
+
interface TilingConformance {
|
|
735
|
+
readonly ok: boolean;
|
|
736
|
+
readonly failures: readonly string[];
|
|
737
|
+
readonly counts: Readonly<Record<TilingProperty, {
|
|
738
|
+
readonly checked: number;
|
|
739
|
+
readonly failed: number;
|
|
740
|
+
}>>;
|
|
741
|
+
}
|
|
742
|
+
/** Every subject a tree offers: each pane drawn alone, each stack whole, and each member of a stack torn out of it. */
|
|
743
|
+
declare function tilingSubjects<T, K>(tree: T, options: Pick<TilingDragOptions<T, K>, "ops">): TilingSubject<K>[];
|
|
744
|
+
/**
|
|
745
|
+
* Runs every property on every subject of every tree (`tilingSubjects`) and every held place of its drag: home, and for
|
|
746
|
+
* each pane drawn in the base a swap, the four sides and a join (last and first). Trees are taken as committed ones,
|
|
747
|
+
* so `normalize` (if any) must leave them as they are. Gives the first `limit` failures (default 20) in words.
|
|
748
|
+
*/
|
|
749
|
+
declare function tilingConformance<T, K>(trees: Iterable<T>, options: TilingDragOptions<T, K>, limit?: number): TilingConformance;
|
|
750
|
+
|
|
751
|
+
/** The properties, by name (each is a key of `TilingHitConformance.counts`). */
|
|
752
|
+
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"];
|
|
753
|
+
type TilingHitProperty = (typeof TILING_HIT_PROPERTIES)[number];
|
|
754
|
+
/** A conformance run, as `tilingConformance`'s, and the rows the ruling counts rather than fails. */
|
|
755
|
+
interface TilingHitConformance {
|
|
756
|
+
readonly ok: boolean;
|
|
757
|
+
readonly failures: readonly string[];
|
|
758
|
+
readonly counts: Readonly<Record<TilingHitProperty, {
|
|
759
|
+
readonly checked: number;
|
|
760
|
+
readonly failed: number;
|
|
761
|
+
}>>;
|
|
762
|
+
/**
|
|
763
|
+
* The rows the ruling counts rather than fails, all on the base basis, where a frame draws the landed layout. Two
|
|
764
|
+
* kinds of row, three counters: a swap whose landing lies beside the pointer, and an insert or join that moves other
|
|
765
|
+
* panes, of which some also land beside the pointer.
|
|
766
|
+
*/
|
|
767
|
+
readonly reported: {
|
|
768
|
+
/** A held swap whose landing does not contain the pointer: the partner moved at the lift, and the swap is hit at its base rect. */
|
|
769
|
+
readonly swapsBeside: number;
|
|
770
|
+
/** An insert or join whose layout moves a pane other than its target (a floor, a fixed length, a master split laid out anew). */
|
|
771
|
+
readonly insertsMoveOthers: number;
|
|
772
|
+
/** Of `insertsMoveOthers`, the ones whose landing does not contain the pointer. */
|
|
773
|
+
readonly insertsMoveOthersBeside: number;
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Runs every property on every subject of every tree (`tilingSubjects`), on both bases, over seeded points,
|
|
778
|
+
* walks and sweeps. Gives the first `limit` failures (default 20) in words.
|
|
779
|
+
*/
|
|
780
|
+
declare function tilingHitConformance<T, K>(trees: Iterable<T>, options: TilingDragOptions<T, K>, hitOptions?: TilingHitOptions<K>, limit?: number): TilingHitConformance;
|
|
781
|
+
|
|
315
782
|
/**
|
|
316
783
|
* The nearest pane in a direction: the rule a host moves focus by. See docs/placement.md, Entry: tiling.
|
|
317
784
|
*/
|
|
@@ -332,4 +799,4 @@ type Direction = "left" | "right" | "up" | "down";
|
|
|
332
799
|
*/
|
|
333
800
|
declare function neighbor<K>(rects: ReadonlyMap<K, Rect>, from: K, direction: Direction): K | null;
|
|
334
801
|
|
|
335
|
-
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 SplitGeometry, type SplitLayout, type SplitOptions, type SplitRoomOptions, type TileOptions, canDropOnPane, canSplitPane, columns, dropFits, dropOnPane, giveWay, grid, layoutSplit, layoutSplitTree, masterCount, masterRatio, masterStack, neighbor, orderTargets, paneCenter, paneRegion, paneTargets, panesOf, removePane, splitFromOrder, splitPane, swapPanes };
|
|
802
|
+
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 SplitGeometry, type SplitLayout, type SplitOptions, type SplitRoomOptions, 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, dropFits, dropOnPane, giveWay, grid, layoutSplit, layoutSplitTree, masterCount, masterRatio, masterStack, neighbor, orderTargets, paneCenter, paneRegion, paneRegionShapes, paneTargets, panesOf, removePane, splitFromOrder, splitPane, splitTreeOps, swapPanes, tilingConformance, tilingDrag, tilingHitConformance, tilingSubjects };
|