@n-uf/placement 26.11.34 → 26.11.37
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 +163 -0
- package/README.md +147 -20
- package/dist/{chunk-VKB3UWKX.js → chunk-2PWDUBPG.js} +520 -97
- package/dist/chunk-2PWDUBPG.js.map +1 -0
- package/dist/{chunk-AVMZIXGO.js → chunk-NF7RYK3U.js} +9 -49
- package/dist/chunk-NF7RYK3U.js.map +1 -0
- package/dist/chunk-R3AAANRY.js +220 -0
- package/dist/chunk-R3AAANRY.js.map +1 -0
- package/dist/desk.d.ts +2 -2
- package/dist/dock.js +2 -1
- package/dist/dock.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/{model-BSIKmANw.d.ts → model-CuE-ML-f.d.ts} +111 -19
- package/dist/panels.d.ts +3 -3
- package/dist/regions-Db_RyT4P.d.ts +48 -0
- package/dist/scene-cases.d.ts +42 -10
- package/dist/scene-cases.js +109 -10
- package/dist/scene-cases.js.map +1 -1
- package/dist/scene.d.ts +100 -6
- package/dist/scene.js +11 -1
- package/dist/stack.d.ts +1 -1
- package/dist/{target-2RYYKkd1.d.ts → target-fhD5UVlt.d.ts} +2 -0
- package/dist/{targets-Du5_4T1u.d.ts → targets-DnVNZVQW.d.ts} +1 -1
- package/dist/targets.d.ts +17 -32
- package/dist/targets.js +20 -54
- package/dist/targets.js.map +1 -1
- package/dist/tiling.d.ts +114 -0
- package/dist/tiling.js +40 -0
- package/dist/tiling.js.map +1 -0
- package/package.json +6 -2
- package/dist/chunk-AVMZIXGO.js.map +0 -1
- package/dist/chunk-VKB3UWKX.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,169 @@
|
|
|
3
3
|
Versions are calendar versions, `YY.M.R` (year, month of the release, counter within the month), shared with
|
|
4
4
|
`@n-uf/motion`: both packages carry the same version, and a release bumps both.
|
|
5
5
|
|
|
6
|
+
## 26.11.37
|
|
7
|
+
|
|
8
|
+
- `./scene`, **`Edge.hidden`** (additive): an edge kept in the scene with its items but not in the window, such as a
|
|
9
|
+
bar the host doesn't draw or a rail it has turned off. It is view state, the host's each time it builds the scene. It
|
|
10
|
+
takes no room, and the rest lays out as if it and its items weren't there: `solve` leaves both out of the layout, with
|
|
11
|
+
no give-way or folds for them. It has no targets, refusals or stops, and neither do its items. A drop elsewhere keeps
|
|
12
|
+
it as it was, a target that commits nothing gives back the scene itself, and `moveTo` into it is refused.
|
|
13
|
+
`storeScene` keeps its items but never writes `hidden`; `readScene` takes `hidden` from `base` (a stored one is
|
|
14
|
+
ignored, `edge:<id>:hidden`). A column a drop makes never takes a hidden edge's id, and a side where a drop makes or
|
|
15
|
+
removes a column is numbered again with the hidden edge at its own place. Scenes without it lay out and target exactly
|
|
16
|
+
as before.
|
|
17
|
+
|
|
18
|
+
## 26.11.36
|
|
19
|
+
|
|
20
|
+
- `./tiling`, fixed: **a split with no room for its gap keeps its panes inside its rect.** When a split's rect was
|
|
21
|
+
narrower than the gap, `layoutSplit` laid its second side a gap past the split's start, past the rect's end and even
|
|
22
|
+
outside the area (at no size, so it drew nothing, but its rect lay outside). It now lies at the rect's end. Wherever
|
|
23
|
+
the room is above the gap, every rect is exactly as before.
|
|
24
|
+
|
|
25
|
+
- `./scene`, **`SceneFloat.since`** (additive): when a float was floated, as a sequence. `floatAt` and
|
|
26
|
+
`moveTo(…, { kind: "float" })` give a newly floated item one more than the largest `since` among the scene's floats
|
|
27
|
+
(1 when there are none); moving a float that already floats, `raise`, `use` and `resize` keep it, and an item docked
|
|
28
|
+
and floated again gets a new one. `storeScene` / `readScene` round-trip it; `readScene` drops a value that isn't a
|
|
29
|
+
number from 0 to `Number.MAX_SAFE_INTEGER` as `float:<id>:since` (past it, one more is the same number), and a new
|
|
30
|
+
`since` never goes past it. Scenes without it lay out as before.
|
|
31
|
+
|
|
32
|
+
- `./scene`, **an anchor with an offset** (additive). A float's `anchor` (in `SceneFloat`, `moveTo`'s float place and
|
|
33
|
+
the stored form) also takes `{ at, dx?, dy? }`: flush with `at`'s side or corner of the content, then `dx` px right and
|
|
34
|
+
`dy` px down, still following the content. A host stores "the top-right corner, 12 px down" instead of a pixel x that
|
|
35
|
+
the clamp on reload moves. `storeScene` / `readScene` round-trip it; `readScene` keeps it as stored and drops a bad
|
|
36
|
+
offset field as `float:<id>:anchor:dx` (or `:dy`, or the field's name). New types `FloatAnchorAt` and
|
|
37
|
+
`FloatAnchorOffset`, and `FLOAT_ANCHORS` lists the names. The string form is unchanged. **Source break for hosts
|
|
38
|
+
that read `anchor`:** it is now `FloatAnchorAt`, not `FloatAnchor`, so code that reads it into a `FloatAnchor`,
|
|
39
|
+
indexes a `Record<FloatAnchor, …>` with it or switches over its names no longer type-checks. Hosts that read `anchor`
|
|
40
|
+
as a name now narrow first: `typeof a === "string" ? a : a.at`, or the new `anchorName(a)`. Hosts that only write
|
|
41
|
+
names are unaffected.
|
|
42
|
+
|
|
43
|
+
- `./scene`, fixed: **an anchored float keeps clear of the other floats.** Floats were kept clear of docked items,
|
|
44
|
+
bars and chrome only, never of each other, so Float from a menu (`moveTo(scene, id, { kind: "float" })` with no rect,
|
|
45
|
+
anchored to the content's top-right) laid a group exactly on a float already at that corner, and a second group
|
|
46
|
+
exactly on the first. An anchored float is now also kept clear of every float with a rect of its own and of the
|
|
47
|
+
anchored floats floated before it (smaller `since`, a missing one counting as 0, then smaller id), by the same
|
|
48
|
+
nearest-clear-place search (`fitFloat`): a float already at a corner stays there. The stacking order plays no part,
|
|
49
|
+
so `raise` still reshapes nothing. With no place clear of them all, it lies where it did before. A float with a
|
|
50
|
+
rect of its own keeps it. Scenes with no anchored float, or whose anchored floats covered no float that wins over
|
|
51
|
+
them, lay out exactly as before. Conformance row C14b's expected answer changed: its float now lies beside the float
|
|
52
|
+
already at that corner, at x 240, so a host that runs the cases suite on an older library fails C14b until it
|
|
53
|
+
upgrades.
|
|
54
|
+
|
|
55
|
+
- The older entries `./dock`, `./desk`, `./panels`, `./toolbar` and `./targets` still ship: superseded by `./scene` and
|
|
56
|
+
`./tiling`, removed in the next breaking release.
|
|
57
|
+
|
|
58
|
+
- `./scene`, **bars give way by height** (additive). A top or bottom bar with `Edge.giveWay` (which already made a
|
|
59
|
+
static side edge give way like a column) now gives way to `contentMin.height`: while the content is shorter (overlay
|
|
60
|
+
bars counted), such bars shrink across toward their minimum, then fold one by one, their items stepping to the next
|
|
61
|
+
form that fits across (a panel's title bar), unkept before kept, the oldest first. New notes `bar-shrunk`
|
|
62
|
+
`{ edge, from, to }` and `bar-folded` `{ edge }`; the edge's `shrunk` is set. A bar with `giveWay` never draws an item
|
|
63
|
+
thinner across than its form's `cross.min`. Scenes without `giveWay` on a bar lay out as before.
|
|
64
|
+
|
|
65
|
+
- `./scene`, fixed: **an overlay bar honours an explicit `span: "full"`.** An overlay top or bottom bar lay over the
|
|
66
|
+
content only, between the columns, whatever its `span`. One that sets `span: "full"` by name now runs across the
|
|
67
|
+
full bars' width, over the side columns too, at the content's top or bottom; the columns keep their height. An
|
|
68
|
+
overlay bar with no `span` keeps exactly its old layout, content-wide (an undrawn bar marked overlay changes nothing),
|
|
69
|
+
and so does one with `span: "between"`.
|
|
70
|
+
|
|
71
|
+
- `./scene`, fixed: **an edge whose zones take nothing for a kind is no drop place for it, and no refusal.** A side
|
|
72
|
+
rail that lists toolbars but takes them in no zone (`zoneAccepts: {}`, a rail a host doesn't draw at a narrow width,
|
|
73
|
+
keeping its stored items) still gave a toolbar drag a "not accepted" refusal band 12–24 px wide along the window's
|
|
74
|
+
edge, where nothing is drawn. Drop targets and refusals now ask one test, `accepts` listing the kind and at least one
|
|
75
|
+
zone taking it: such an edge counts exactly as one whose `accepts` lacks the kind. Empty, it gives nothing; drawn
|
|
76
|
+
with its stored items, it gives that edge's one refusal over its drawn rect, as before for any edge that doesn't
|
|
77
|
+
take the kind. The stored form and `readScene` still read `accepts`. The test is exported as `edgeTakes(edge, kind)`
|
|
78
|
+
(beside `zoneTakes` and `zonesTaking`), so a host can ask it too. New row R9.
|
|
79
|
+
|
|
80
|
+
- `./scene`, **chrome with a scope** (additive). A `chrome` entry is now a `SceneChrome`: a rect with an optional
|
|
81
|
+
`for`. The default, `"all"`, is the chrome as it was: floats keep clear of it and no drop target lies on it. With
|
|
82
|
+
`for: "floats"`, only floats keep clear of it (a drop, opening one, a window resize, a resize by hand), and the
|
|
83
|
+
edges, give-way and every docked target ignore it, so a kit's 24 px spine over the right column keeps that column's
|
|
84
|
+
gaps, lines and rail. Plain rects work as before. Chrome is not part of the stored form.
|
|
85
|
+
|
|
86
|
+
- `./scene`, fixed: **a grip's double-click folds, it never steps to a variant** (host note). A toolbar group with
|
|
87
|
+
forms full, compact, minimal and a menu went to compact when folded by hand: `fold` set `from: 1`, "one step down",
|
|
88
|
+
which is a fold only for panels whose second form is their header. A hand fold now always goes to the folded form on
|
|
89
|
+
the axis the item lies along: a panel's `header`, a group's `fold` (its grip and »); a thumbnail anchor (a fixed item
|
|
90
|
+
on a `foldable` edge) with neither folds to its `rail` tile as before. Give-way still steps down from there (rail,
|
|
91
|
+
menu), and unfolding brings back the form the room allows. An item with no folded form there can't be folded by
|
|
92
|
+
hand: new `canFold(scene, id)` is false, `fold(on)` changes nothing (a host leaves the double-click off), and it draws
|
|
93
|
+
unfolded. `from` keeps its stored meaning, "folded by hand" (1 or more), so stored scenes read as before: panels
|
|
94
|
+
whose second form is their header behave exactly as before (a panel with another form before its header now folds
|
|
95
|
+
to the header); a group's old `from: 1` now folds it. `foldedBy`, the rail drop strips and the new-column lines read
|
|
96
|
+
the fold as it shows. New row R8 and a sweep property.
|
|
97
|
+
|
|
98
|
+
## 26.11.35
|
|
99
|
+
|
|
100
|
+
Not published: its release run failed on a test timeout. Everything below ships in 26.11.36.
|
|
101
|
+
|
|
102
|
+
- `./scene`, fixed: **a target left too thin to reach.** The new-column line beside a 28 px rail drop strip was left a
|
|
103
|
+
6 px sliver (a kit saw 18 × 12): the column lines take only what the other edges leave. Now every target keeps a
|
|
104
|
+
reachable hit of at least 12 px across by 24 px along, taken from the space beside it in its own zone where nothing
|
|
105
|
+
else is aimed at, or from a neighbor's surplus that still keeps its own minimum (the lower-ranked one first). Home,
|
|
106
|
+
a drop strip, a refusal, the chrome and the stage's edge never give way, and a gap never grows over another drawn
|
|
107
|
+
edge; where nothing can spare the space, the target stays as it was (still a stop and in "Move to"). Some hits move
|
|
108
|
+
by a few px as a result: beside a 30 px column its gaps now take 12 px and the outer column line 18. The column line
|
|
109
|
+
at the seam between two touching columns is now 12 px wide and overlays the outer column's edge by 6 px (only a
|
|
110
|
+
column line may grow over another drawn edge). No case row changed.
|
|
111
|
+
|
|
112
|
+
- `./scene`, **refusals for the drag intent** (additive; host note). `refusalTargets(refusals)` gives each refusal as a
|
|
113
|
+
target marked `refuse: true` (the root `Target` gains the optional `refuse`; `refusal` holds the `SceneRefusal`).
|
|
114
|
+
Pass them to `@n-uf/motion/drag`'s intent with the targets and read the frame's `refused`: a kit's rail stop, held
|
|
115
|
+
by its band, used to hide the refusal under it. `./scene/cases`' `withRefusals`, and so the reference host, picks the
|
|
116
|
+
same way. A host that doesn't pass refusals keeps working as before. `PickRule` is now generic over what it reads
|
|
117
|
+
(`PickCandidate`: `id`, `priority`, `hit`, `hits`), so one rule picks among targets and refusal targets alike;
|
|
118
|
+
`@n-uf/motion/drag`'s `targetAt` fits it as before.
|
|
119
|
+
|
|
120
|
+
- `./scene`, fixed: **a toolbar dropped next to a movable item behind fixed ones was refused.** In a title bar whose
|
|
121
|
+
end zone holds two fixed readouts and then a movable toolbar, packed from the end, every drop in the zone after the
|
|
122
|
+
readouts was turned away, because it pushed them, and the stretch over the toolbar showed "No room here". Now only
|
|
123
|
+
the fixed items at a zone's anchor (from the start zone's first item, or the end zone's last, up to the first movable
|
|
124
|
+
one) keep their place against a drop in that zone; a fixed item behind a movable one is placed by that movable's size
|
|
125
|
+
and may be pushed. Every fixed item of the center zone, and of the other zones, keeps its place as before. A gap
|
|
126
|
+
between two fixed items has no place to aim at and is not offered, so a movable item's leading half is the gap before
|
|
127
|
+
it and its trailing half the gap after it. New rows R7 (two pushed, one where the anchored readouts stay) and a
|
|
128
|
+
property test over fixed items in all three zones.
|
|
129
|
+
|
|
130
|
+
- `./scene`, **refusals match the drawn edge** (host note). An edge that takes the dragged kind in no zone (a title
|
|
131
|
+
bar or toolbar for a panel) now gives one refusal, `refuse:<edge>:start` (`n = 0`), per wholly refused edge: its
|
|
132
|
+
drawn rect, fixed items included, in the stage, less what targets own; where a target splits it, every piece of 1 px
|
|
133
|
+
and more is in the new `SceneRefusal.hits` (`hit` the largest; the pointer is in the refusal in any piece, and the
|
|
134
|
+
reference host's `withRefusals` reads them). It used to give a refusal per zone, reaching
|
|
135
|
+
`endReach` (24 px) past the edge's ends and leaving its fixed items uncovered, so a host's tint and "Can't go here"
|
|
136
|
+
tag didn't match the drawn bar. A refused zone of an edge that takes the kind elsewhere keeps its slot's tile, now
|
|
137
|
+
inside the edge's ends. No refusal reaches past the stage any more. A host that keyed on `refuse:<edge>:<zone>` for
|
|
138
|
+
the other zones of such an edge reads the one id instead: rows C25 and P13-kinds now expect `refuse:toolbar:start`
|
|
139
|
+
and `refuse:tools-bar:start` at the pointer. A new property category, `refused-edge-drawn`, holds it in every mode.
|
|
140
|
+
|
|
141
|
+
- `./scene/cases`, **a host-declared docking width** (additive): `CaseHost.dockMinWidth` (and `AsyncCaseHost`'s) is
|
|
142
|
+
the narrowest stage width at which the host docks panels (absent: every width). The 110 rows whose expected outcome
|
|
143
|
+
depends on docked panels (the content beside a docked column included) carry `requires: { docks: true }`, set by one
|
|
144
|
+
rule from each row's expectations when `CASES` is built (a row may state `docks`, true or false, to override), and
|
|
145
|
+
the runner skips such a row when its stage is narrower than that at any point: the result is `ok` with one `skipped`
|
|
146
|
+
entry that says why. `CaseRequires.docks` is the one requirement the runner reads.
|
|
147
|
+
|
|
148
|
+
- `./scene/cases`, **the three P16 rows that aim at the window's edge pixels** (first px, last px, 9 px in) carry
|
|
149
|
+
`requires: { railDrop: "scene" }`, as P6-outer-line-at-11-px does: a host that lays its own rail drop strips skips
|
|
150
|
+
them.
|
|
151
|
+
|
|
152
|
+
- **New entry `@n-uf/placement/tiling`**: panes that divide an area with no overlap, on the root geometry and `Target`
|
|
153
|
+
alone. Order layouts (`masterStack` with a `ratio`, `columns`, `grid`) and `orderTargets` (one target per index a
|
|
154
|
+
dragged pane could be inserted at); the split tree (`Split`, `layoutSplit`, `splitPane`, `removePane`, `swapPanes`,
|
|
155
|
+
`panesOf`, and `splitFromOrder` for dwindle, split along the longer side), where a split may carry an `axis` and a
|
|
156
|
+
`ratio`; a pane's drop regions (`paneRegion`, `paneCenter`, `PANE_SIDES`, `PANE_REGION_DEFAULTS`: the center and
|
|
157
|
+
four sides), `dropOnPane` (the center swaps, a side splits with that side's axis and ratio 0.5; a drop on a pane
|
|
158
|
+
that isn't there, or on itself, changes nothing) and `paneTargets` (`{ except, key }`: ids `pane:<key>`, keys
|
|
159
|
+
unique); and `giveWay`, which floats the newest pane while one breaks its minimum. `layoutSplit` clamps a ratio to
|
|
160
|
+
0..1 and never gives a negative size. README: Tiling.
|
|
161
|
+
- `./targets`, **deprecated: the pane drop zones.** `paneZone`, `paneCentre`, `PaneZone`, `PaneCentre`,
|
|
162
|
+
`PaneZoneOptions`, `PANE_EDGES` and `PANE_ZONE_DEFAULTS` now wrap `./tiling`'s `paneRegion`, `paneCenter`,
|
|
163
|
+
`PaneRegion`, `PaneCenter`, `PaneRegionOptions`, `PANE_SIDES` and `PANE_REGION_DEFAULTS` (same results; the old
|
|
164
|
+
option names are mapped). They stay until the legacy entries go. `./dock` lays out its documents and its tiling tree
|
|
165
|
+
with `./tiling` (the same rects, to the bit).
|
|
166
|
+
- `./dock`, **no negative tile sizes**: where a tiling tree's center held more documents than its gaps leave room
|
|
167
|
+
for, a tile's width or height went below 0; it is now 0.
|
|
168
|
+
|
|
6
169
|
## 26.11.34
|
|
7
170
|
|
|
8
171
|
- `./scene`, **over an unarmed strip** (docs and a property test, no behavior change). A kit reported that at 700 px
|
package/README.md
CHANGED
|
@@ -11,8 +11,8 @@ Site and live demos: [motion.n-uf.com](https://motion.n-uf.com)
|
|
|
11
11
|
|
|
12
12
|
Where things go. State in, rects and drop targets out: a workspace of docks, rails and floating panels, panels in
|
|
13
13
|
columns per side that give way least recently used first, toolbar groups in toolbar areas and zones, and the drop
|
|
14
|
-
targets for each
|
|
15
|
-
motion, no dependencies.
|
|
14
|
+
targets for each, and tiling: panes that divide an area between them. Pure functions over plain data: no DOM, no
|
|
15
|
+
framework, no motion, no dependencies.
|
|
16
16
|
|
|
17
17
|
```sh
|
|
18
18
|
npm i @n-uf/placement
|
|
@@ -22,6 +22,9 @@ Its sibling [`@n-uf/motion`](https://www.npmjs.com/package/@n-uf/motion) owns ho
|
|
|
22
22
|
without importing each other: a target list from `@n-uf/placement/targets` is exactly what
|
|
23
23
|
`@n-uf/motion/drag`'s drag intent takes, and a rect from any layout here is what `@n-uf/motion/layout` glides to.
|
|
24
24
|
|
|
25
|
+
The older entries `./dock`, `./desk`, `./panels`, `./toolbar` and `./targets` still ship: superseded by `./scene` and
|
|
26
|
+
`./tiling`, removed in the next breaking release.
|
|
27
|
+
|
|
25
28
|
- **`@n-uf/placement`**: the shapes (`Rect`, `Size`, `Point`), the geometry every entry shares, and a popup positioner,
|
|
26
29
|
as Wayland's xdg-positioner: an anchor point, gravity and offset, then flip, slide and resize, each only when the
|
|
27
30
|
rule allows it. The geometry is `rect`, `overlap`, `clampInto`, `centre`, `EPS`, `PLANE`, `area`, `overlaps`,
|
|
@@ -58,6 +61,9 @@ without importing each other: a target list from `@n-uf/placement/targets` is ex
|
|
|
58
61
|
result), pure changes and a stored form.
|
|
59
62
|
- **`/scene/cases`**: the Scene's behavior as data: conformance rows (a scene, what a user does, the layout and DOM
|
|
60
63
|
expected after) and `runCase`, which plays one on a host, so an integrating app's test suite and the lab run the same rows.
|
|
64
|
+
- **`/tiling`**: panes that divide an area with no overlap: order layouts (master and stack, columns, a grid), the
|
|
65
|
+
split tree (dwindle, split along the longer side, or splits with an axis and a ratio), a pane's drop regions, and
|
|
66
|
+
their drop targets (see Tiling).
|
|
61
67
|
|
|
62
68
|
Rendering stays in the app: it draws the rects, measures its groups, and feeds pointer samples to a drag intent.
|
|
63
69
|
|
|
@@ -745,6 +751,11 @@ preview equals result) has one owner. A `Scene` is the stage (the window's inner
|
|
|
745
751
|
`floats` and the `chrome` they keep clear of. `solve(scene)` gives every rect the host draws; `targets(scene, id)` gives
|
|
746
752
|
every drop target for one item. Nothing is module-global, so two windows on a page are two scenes.
|
|
747
753
|
|
|
754
|
+
A `chrome` entry (`SceneChrome`) is a rect with a scope. By default (`for: "all"`) floats keep clear of it and no drop
|
|
755
|
+
target, slot or landing lies on it (a title the host draws itself). With `for: "floats"` only floats keep clear of it,
|
|
756
|
+
in every way they are placed (a drop, opening one, a window resize, a resize by hand), while the edges, give-way and
|
|
757
|
+
every docked target ignore it: a spine the host draws over a column keeps the column's gaps, lines and rail.
|
|
758
|
+
|
|
748
759
|
```ts
|
|
749
760
|
import { readScene, solve, storeScene, targets, type Scene, type SceneItem } from "@n-uf/placement/scene";
|
|
750
761
|
import type { StackForm } from "@n-uf/placement/stack";
|
|
@@ -794,9 +805,24 @@ console.log(readScene(JSON.parse(JSON.stringify(storeScene(drop.scene))), scene)
|
|
|
794
805
|
**The cut.** Reserved edges cut the stage from the outside in: the full bars first (top then bottom, each by `ring`,
|
|
795
806
|
0 outermost), across the whole width; then the columns (left then right, by ring), down the height the full bars
|
|
796
807
|
leave; then the `span: "between"` bars, across the width the columns leave. What remains is `layout.content`. Edges
|
|
797
|
-
with `mode: "overlay"` are cut the same way from a copy of the content: they lie over it and leave it as it is. An
|
|
808
|
+
with `mode: "overlay"` are cut the same way from a copy of the content: they lie over it and leave it as it is. An overlay
|
|
809
|
+
bar that sets `span: "full"` by name runs across the full bars' width instead (the window's whole width with
|
|
810
|
+
`outsideInset`), over the side columns too, at the
|
|
811
|
+
content's top or bottom; one with `span: "between"`, or with no `span`, lies over the content only. An edge
|
|
798
812
|
with nothing drawn in it takes no room.
|
|
799
813
|
|
|
814
|
+
**Hidden edges.** `Edge.hidden: true` keeps an edge and its items in the scene but out of the window: a bar the host
|
|
815
|
+
doesn't draw, a rail it has turned off. It is view state: the host decides it each time it builds the scene (from the
|
|
816
|
+
window's width, say). It takes no room, and everything else lays out exactly as if it and its items were not in the
|
|
817
|
+
scene: `solve` leaves it and its items out of the layout (no `edges[id]`, no `items[id]`, as for an item placed
|
|
818
|
+
nowhere), and they take no part in give-way or folds. It has no targets and no refusals for any kind and no keyboard
|
|
819
|
+
stops; its items have none either. A drop elsewhere keeps the hidden edge as it was, and one that commits nothing (home,
|
|
820
|
+
a blocked rect) gives back the scene itself. `moveTo` into it is refused, as into an edge that doesn't take the kind.
|
|
821
|
+
`storeScene` keeps its items like any edge's but never writes `hidden`; `readScene` takes `hidden` from `base` only
|
|
822
|
+
(a stored one is ignored and listed as `edge:<id>:hidden`). A column a drop makes never takes a hidden edge's id, and
|
|
823
|
+
where a drop makes or removes a column on its side, the side is numbered again from 0 with the hidden edge back where its
|
|
824
|
+
ring put it in the order. Side columns, rails and bars alike.
|
|
825
|
+
|
|
800
826
|
**Each edge is a stack.** Left and right edges are columns (`forms.column`), top and bottom ones bars (`forms.row`),
|
|
801
827
|
each solved by `fitStack` along the length it gets, with `gap`, `pad` and `menu` passed through, its cross limits never
|
|
802
828
|
wider than the room the cut leaves. Group forms in a column take their own width (`ownCross`); open panels and headers
|
|
@@ -951,6 +977,12 @@ none lays out as before.
|
|
|
951
977
|
between such bars, and an anchor runs through the inset beside them. Without it nothing changes.
|
|
952
978
|
- **`Edge.giveWay`**: a static left or right edge that gives way like a dynamic column. It shrinks toward its minimum,
|
|
953
979
|
then folds whole into its side's rail, in give-way order with the columns (by its items' ages). It is never deleted.
|
|
980
|
+
On a top or bottom bar, reserved or overlay, it gives way by height, the same way: while the content is shorter than
|
|
981
|
+
`contentMin.height` (overlay bars counted), such bars shrink across toward their minimum (`cross.min` and each open
|
|
982
|
+
item's form's `cross.min`), then fold one by one, their items stepping to the next form that fits across (a panel's
|
|
983
|
+
title bar, `foldedBy: "auto"`), each fold letting the others take back what they can; unkept before kept, the oldest
|
|
984
|
+
newest use first, the outer first (`bar-shrunk` `{ edge, from, to }`, `bar-folded` `{ edge }`, and the edge's
|
|
985
|
+
`shrunk`). Room coming back undoes it in reverse. Still too short: `content-short`.
|
|
954
986
|
- **`Edge.moves: "side"`**: a static edge whose fixed item (an anchor, such as page thumbnails) the user may drag to the
|
|
955
987
|
other side of the edge's axis. `targets` then gives that item one target, `side:<other side>`, over the place the edge
|
|
956
988
|
takes there, landing as `setSide` puts it; its own place is home. Left out, a fixed item has no targets. `readScene`
|
|
@@ -1003,6 +1035,29 @@ its first form's natural size along that orient (**`floatSizeOf(item, orient?)`*
|
|
|
1003
1035
|
panel's card) keeps `DEFAULT_FLOAT_SIZE` (280 × 360), so panels float as before. Give a float `orient: "column"` (or the
|
|
1004
1036
|
item `floatOrient: "column"`) to keep a row-first group vertical.
|
|
1005
1037
|
|
|
1038
|
+
**Anchored floats keep clear of the other floats.** An anchored float (Float from a menu: `moveTo(scene, id,
|
|
1039
|
+
{ kind: "float" })` with no rect, or any float with `anchor`) is also kept clear of every float with a rect of its own
|
|
1040
|
+
and of the anchored floats floated before it, by the same nearest-clear-place search that keeps it clear of docked
|
|
1041
|
+
items, so a second group sent to Float lies beside the first instead of on it. Which float wins never depends on the
|
|
1042
|
+
stacking order, so `raise` reshapes nothing: a float with its own rect always wins, and among anchored floats the one
|
|
1043
|
+
floated first does, by `since` (`SceneFloat.since`, a missing one counting as 0, so floats from older stored scenes
|
|
1044
|
+
win; ties by id). A float already at a corner stays there when another is sent to Float beside it. Where no
|
|
1045
|
+
place is clear of them all, it lies where it would with no other float (it may cover a float, never a docked item it
|
|
1046
|
+
could stay clear of). A float with a rect of its own (a drop, a resize) keeps that rect as before, over another float
|
|
1047
|
+
or not. Scenes with no anchored float, or whose anchored floats cover no float that wins over them, lay out exactly as
|
|
1048
|
+
before.
|
|
1049
|
+
|
|
1050
|
+
**An anchor with an offset.** `anchor` also takes `{ at, dx?, dy? }`: flush with `at`'s side or corner of the content,
|
|
1051
|
+
then `dx` px to the right and `dy` px down (negative: left, up; default 0), still following the content as the window
|
|
1052
|
+
changes. So a host stores "the content's top-right corner, 12 px down" instead of a pixel position that a smaller window
|
|
1053
|
+
would clamp on reload. The string form is unchanged, and `FLOAT_ANCHORS` lists the names. A host that reads `anchor`
|
|
1054
|
+
as a name narrows it first: `anchorName(a)` is `a` for a name and `a.at` for one with an offset.
|
|
1055
|
+
|
|
1056
|
+
```ts
|
|
1057
|
+
const s = moveTo(scene, "tools", { kind: "float", anchor: { at: "content-top-right", dy: 12 } });
|
|
1058
|
+
storeScene(s).floats; // [{ id: "tools", x, y, width, height, anchor: { at: "content-top-right", dy: 12 } }]
|
|
1059
|
+
```
|
|
1060
|
+
|
|
1006
1061
|
The **float region** is [pad, W − pad] × the full height: the stage less `Scene.inset`'s left and right (its top and
|
|
1007
1062
|
bottom don't cut it). A float is clamped into it, and one larger than it is shrunk to fit. **`SceneItem.floatMin`**
|
|
1008
1063
|
(`Size`) is the floor of that shrink: a float of the item is laid out at `max(floatMin, min(its size, the region))` each
|
|
@@ -1070,10 +1125,14 @@ and on an empty zone or edge, the zone extents (thirds, or the solved spans) say
|
|
|
1070
1125
|
so a drop there can move the item to another zone with its order kept. A slot whose whole hit region lies over its neighbors'
|
|
1071
1126
|
facing halves is home's, and is no target of its own. The slot is where the item lands, at its size in that edge's form.
|
|
1072
1127
|
|
|
1073
|
-
- `gap:<edge>:<zone>:<at>` (priority 2) for every edge whose `accepts` lists the item's kind (deny by default)
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1128
|
+
- `gap:<edge>:<zone>:<at>` (priority 2) for every edge whose `accepts` lists the item's kind (deny by default) and one of
|
|
1129
|
+
whose zones takes it (`edgeTakes`; an edge with `zoneAccepts: {}` takes it nowhere, as one that doesn't list it), in
|
|
1130
|
+
each zone that takes it, before each item of the zone and at its end, so an empty center or end zone can be opened; only where the item
|
|
1131
|
+
fits: not in the » menu, no `overflow`, nothing newly `too-wide`, every fixed item of the edge keeping its form, every
|
|
1132
|
+
protected one its place, and no chrome under its slot. Protected: the fixed items at a zone's anchor (from the start
|
|
1133
|
+
zone's first member, or the end zone's last, up to the first movable one), every fixed item of the center zone, and
|
|
1134
|
+
the fixed items of the other zones. A fixed item behind a movable one is placed by that movable's size, so a drop in
|
|
1135
|
+
its zone may push it; a gap between two fixed items has no place to aim at and is not offered. Along the edge the gaps tile it: neighboring gaps meet at the midpoint of the
|
|
1077
1136
|
item between them (see Aim order), else halfway between their lines, so an edge of a few short items (a bar, a rail,
|
|
1078
1137
|
a column's footer) is covered from end to end. Only over an
|
|
1079
1138
|
open item's body (a panel) the hit narrows to `Edge.hitBand` px around its line (default 24), so the middle of a
|
|
@@ -1118,7 +1177,20 @@ facing halves is home's, and is no target of its own. The slot is where the item
|
|
|
1118
1177
|
that was folded by width reopen; the slot is that landing. With no rail showing, the stop keeps its place only while
|
|
1119
1178
|
one of its slots lands in the rail (home's counts): where every drop there is refused (a panel would ride over an
|
|
1120
1179
|
open column), the outermost column line runs from the window's edge. Draw `refusals()` as well as the targets, so a
|
|
1121
|
-
place that refuses a drop never looks like a dead band.
|
|
1180
|
+
place that refuses a drop never looks like a dead band. A refusal matches what is drawn: an edge that takes the
|
|
1181
|
+
dragged kind in no zone is one refusal, `refuse:<edge>:start` (`n = 0`), over its drawn rect (the `SceneEdgeLayout`
|
|
1182
|
+
rect, fixed items included) less what targets own, so a host's tint and "Can't go here" cover the bar as drawn
|
|
1183
|
+
(where a target splits it, every piece of 1 px and more is in `hits`, `hit` the largest: the pointer is in the
|
|
1184
|
+
refusal in any piece); a
|
|
1185
|
+
refused zone of an edge that takes the kind elsewhere keeps its slot's tile, inside the edge's ends. No refusal
|
|
1186
|
+
reaches past the stage. Hand them to the drag intent with the targets: `refusalTargets(refusals(scene, id))` gives
|
|
1187
|
+
each one as a target marked `refuse: true` (its `refusal` the `SceneRefusal`), which the intent never holds or
|
|
1188
|
+
shows, so a held target's band never covers a refusal; read "No room here" from the frame's `refused`.
|
|
1189
|
+
Every target keeps a reachable hit: its largest piece is at least 12 px across by 24 px along (`minHit`, data per
|
|
1190
|
+
edge kind), taken from the space beside it in its own zone (a column line's band, a gap's tile) where nothing else is
|
|
1191
|
+
aimed at, or from a neighbor that keeps its own minimum. Home, a drop strip, a refusal, the chrome and the stage's
|
|
1192
|
+
edge never give way, and a gap never grows over another drawn edge; where nothing can spare the space the target
|
|
1193
|
+
stays as it is, still a stop.
|
|
1122
1194
|
For a kind with a rail drop policy, the rail is a spring-loaded drop strip instead (below).
|
|
1123
1195
|
- `none:<i>` (1) over each `scene.blocked` rect, and `home:<id>` (1) over a docked item's own rect: a release there
|
|
1124
1196
|
commits nothing. A floating item has no home, so a move inside its own rect is a float move. A gap, column line or rail
|
|
@@ -1259,7 +1331,12 @@ its side's outermost edge: ring 0, before that side's other edges, whose rings c
|
|
|
1259
1331
|
closes up too). Its items, size and options go with it; the scene is given back unchanged for an unknown edge, the side
|
|
1260
1332
|
it is already on, or a side across its axis. Like every change it ticks no use clock: a host that moves an edge by hand
|
|
1261
1333
|
calls `use()` on its items afterwards, as a drop does. The stored form keeps the side, and `readScene` moves a static edge stored
|
|
1262
|
-
on the other side of `base`'s with `setSide`. `
|
|
1334
|
+
on the other side of `base`'s with `setSide`. `fold(scene, id, on)` is a grip's double-click: folded by hand, an item
|
|
1335
|
+
takes its folded form on the axis it lies along (a panel's `header`, a group's `fold`, its grip and »; else its `rail`
|
|
1336
|
+
tile), never the next variant (a group's `stacked` or `icons` are for give-way only), and give-way steps down from
|
|
1337
|
+
there; unfolded, it takes the form the room allows again. `canFold(scene, id)` says whether a hand fold means anything
|
|
1338
|
+
where the item lies (false: no folded form on that axis, and `fold(on)` changes nothing), so a host can leave the
|
|
1339
|
+
double-click off. `moveTo` and
|
|
1263
1340
|
`floatAt` refuse fixed items and kinds the edge or `floatKinds` doesn't list. `moveTo` also takes `{ kind: "column",
|
|
1264
1341
|
side, ring }` (`ring: Infinity` is the side's inner end: "Move to › Dock left"), `{ kind: "rail", side, ring }` (docked
|
|
1265
1342
|
folded) and `{ kind: "float", rect?, anchor? }`. `homeFor(scene, id, start)` is the place a start scene gives the item
|
|
@@ -1274,8 +1351,11 @@ item's place left empty and nothing else moved (a release there commits nothing)
|
|
|
1274
1351
|
`solve(lift(scene, id), { previous })`, which would show a result no drop gives.
|
|
1275
1352
|
|
|
1276
1353
|
**Stored form.** `storeScene(scene)` gives `{ v: 1, edges: [{ id, side, ring, items, size?, column? }], floats: [{ id, x, y,
|
|
1277
|
-
width, height, orient?, anchor? }], items: { [id]: { used, kept?, from?, closed?, align?, floatSize? } } }`; no float has a
|
|
1278
|
-
pinned field. `
|
|
1354
|
+
width, height, orient?, anchor?, since? }], items: { [id]: { used, kept?, from?, closed?, align?, floatSize? } } }`; no float has a
|
|
1355
|
+
pinned field. A float's `since` (when it was floated) is kept as stored; one that isn't a number from 0 to
|
|
1356
|
+
`Number.MAX_SAFE_INTEGER` is dropped and listed (`float:<id>:since`), and a new `since` never goes past that. A float's `anchor` is stored as given, a name or `{ at, dx?, dy? }`, and read back as stored: the clamp
|
|
1357
|
+
on read moves only its rect, which an anchored float doesn't lie by (an unusable anchor or offset field is dropped and
|
|
1358
|
+
listed, `float:<id>:anchor`, `float:<id>:anchor:dx`). `readScene(data, base)` takes kinds, forms, limits and edges from `base` and order, sizes and states from
|
|
1279
1359
|
the store, never throws, and lists what it drops: unknown edges and items, kinds an edge doesn't accept, fixed items
|
|
1280
1360
|
stored in another edge than `base`'s, bad fields, an old `pinned`. A stored edge's order is kept exactly, fixed items
|
|
1281
1361
|
where the store put them, so a drop after a fixed item round-trips; a fixed item the store lacks goes back to its base
|
|
@@ -1312,7 +1392,13 @@ host contract: a pointer past the window's edge means its nearest point of the w
|
|
|
1312
1392
|
under a hand that overshoots it), so every host plays the same point, and a row such as C17 means what the clamped point
|
|
1313
1393
|
picks. A row may carry `requires`, what its scene needs of the host's window (`hitBand: "default"`: an open panel's body
|
|
1314
1394
|
is no drop place, as in C7 and P5-neighbour-half-facing-it, so a host whose columns use `hitBand: "middle"` skips or marks
|
|
1315
|
-
the row; `rails`: the sides whose rail the scene shows at the start, as in P9-to-the-other-rail); the runner reads none of it
|
|
1395
|
+
the row; `rails`: the sides whose rail the scene shows at the start, as in P9-to-the-other-rail); the runner reads none of it
|
|
1396
|
+
but `docks`.
|
|
1397
|
+
|
|
1398
|
+
**A host-declared docking width.** A host that docks panels only from some stage width gives `dockMinWidth` (px; absent:
|
|
1399
|
+
it docks at every width). A row whose expected outcome depends on docked panels carries `requires: { docks: true }`, and
|
|
1400
|
+
the runner skips it when its stage is narrower than that at any point (its start, or a window `resize`): the result is
|
|
1401
|
+
`ok`, with one `skipped` entry, "the row: it needs docked panels at 540 px, and the host docks from 720 px".
|
|
1316
1402
|
|
|
1317
1403
|
A host that names things differently gives `ids`, a row id to its own id (`{ views: "panels", tools: "commands" }`, items and
|
|
1318
1404
|
edges, one to one; an id left out keeps its name). The runner hands the host its own ids (the scene, the gestures, `stops`,
|
|
@@ -1400,12 +1486,53 @@ declare function pageHost(): Promise<AsyncCaseHost>;
|
|
|
1400
1486
|
const results = await runCasesAsync(CASES, pageHost, { onResult: (id, r) => console.log(id, r.ok) });
|
|
1401
1487
|
```
|
|
1402
1488
|
|
|
1403
|
-
##
|
|
1489
|
+
## Tiling
|
|
1490
|
+
|
|
1491
|
+
`@n-uf/placement/tiling` divides an area among panes, with no overlap and no hole. It has two models; **use an order
|
|
1492
|
+
layout when panes only reorder, and the split tree when a drop splits a pane on a side.**
|
|
1493
|
+
|
|
1494
|
+
- **Order layouts**: `masterStack`, `columns` and `grid` take panes in order and an area (`{ gap, ratio }`), and give a
|
|
1495
|
+
rect per pane. A drop inserts the dragged pane at an index: `orderTargets(arrange, panes, dragged, area)` gives one
|
|
1496
|
+
target per index (`at:<index>`), its slot the dragged pane's rect there and `layout` every pane's rect with it there.
|
|
1497
|
+
- **The split tree**: a `Split` is a pane or `{ a, b, axis?, ratio? }`. `layoutSplit(tree, area, { gap })` lays it
|
|
1498
|
+
out, the ratio clamped to 0..1 and no size below 0 however wide the gap; a split with no axis divides along the
|
|
1499
|
+
longer side in halves, so `splitFromOrder(panes)` is dwindle (split along the longer
|
|
1500
|
+
side). `splitPane`, `removePane` and `swapPanes` change it. A drop on a pane goes by the pane's drop region:
|
|
1501
|
+
`paneRegion(rect, point, previous)` is the center (34 % of each axis, at least 24 px) or one of four side trapezoids,
|
|
1502
|
+
and holds the previous region for 6 px past its boundary. `dropOnPane(tree, dragged, at, region)` swaps for the
|
|
1503
|
+
center and splits `at` on a side, writing that side's axis and ratio 0.5, so a side means the same on any pane.
|
|
1504
|
+
`paneTargets(layout, { except?, key? })` gives one target per pane, its id `pane:<key>` (`key` defaults to `String`;
|
|
1505
|
+
keys must be unique, since a drag intent follows targets by id). A drop on a pane that isn't in the tree, or on the
|
|
1506
|
+
dragged pane itself, changes nothing.
|
|
1507
|
+
- `giveWay(panes, layout, min, age)` floats the newest pane while any pane is laid out below its minimum.
|
|
1508
|
+
|
|
1509
|
+
Both kinds of target are the root `Target`, so a drag intent from `@n-uf/motion/drag` takes them as they are; for the
|
|
1510
|
+
split tree its `placeOf` is the pane's region:
|
|
1511
|
+
|
|
1512
|
+
```ts
|
|
1513
|
+
import { dropOnPane, layoutSplit, paneRegion, paneTargets, splitFromOrder, type PaneRegion, type PaneTarget } from "@n-uf/placement/tiling";
|
|
1514
|
+
|
|
1515
|
+
const area = { x: 0, y: 0, width: 800, height: 400 };
|
|
1516
|
+
const tree = splitFromOrder(["a", "b"]);
|
|
1517
|
+
const after = dropOnPane(tree, "c", "b", "top");
|
|
1518
|
+
console.log(layoutSplit(after, area).get("c")); // { x: 400, y: 0, width: 400, height: 200 }
|
|
1519
|
+
|
|
1520
|
+
const targets = paneTargets(layoutSplit(tree, area));
|
|
1521
|
+
const placeOf = (t: PaneTarget<string>, p: { x: number; y: number }, previous: string | null): string =>
|
|
1522
|
+
`${t.id}:${paneRegion(t.hit, p, (previous?.split(":")[2] as PaneRegion | undefined) ?? null)}`;
|
|
1523
|
+
console.log(placeOf(targets[1]!, { x: 600, y: 10 }, null)); // pane:b:top
|
|
1524
|
+
```
|
|
1525
|
+
|
|
1526
|
+
## Pane drop regions (old names)
|
|
1527
|
+
|
|
1528
|
+
**Deprecated**: `@n-uf/placement/targets` still exports the pane drop regions under their old names (`paneZone`,
|
|
1529
|
+
`paneCentre`, `PaneZone`, `PaneCentre`, `PaneZoneOptions`, `PANE_EDGES`, `PANE_ZONE_DEFAULTS`), as wrappers of
|
|
1530
|
+
`./tiling`'s `paneRegion`, `paneCenter` and their types and defaults, until the legacy entries go. Use `./tiling`.
|
|
1404
1531
|
|
|
1405
|
-
`paneZone(rect, point, previous, options?)` says which of a pane's five drop
|
|
1406
|
-
(34 % of each axis, at least 24 px) or one of four
|
|
1407
|
-
boundary. It fits `@n-uf/motion/drag`'s `placeOf(target, point, previous)`: one target per pane, the
|
|
1408
|
-
place, and a null place for a
|
|
1532
|
+
`paneZone(rect, point, previous, options?)` says which of a pane's five drop regions a point is in: the center
|
|
1533
|
+
rectangle (34 % of each axis, at least 24 px) or one of four side trapezoids. The previous region holds for 6 px past
|
|
1534
|
+
its boundary. It fits `@n-uf/motion/drag`'s `placeOf(target, point, previous)`: one target per pane, the region as the
|
|
1535
|
+
place, and a null place for a region that takes no drop.
|
|
1409
1536
|
|
|
1410
1537
|
```ts
|
|
1411
1538
|
import { paneZone, type PaneZone } from "@n-uf/placement/targets";
|
|
@@ -1414,11 +1541,11 @@ const pane = { x: 0, y: 0, width: 200, height: 200 };
|
|
|
1414
1541
|
console.log(paneZone(pane, { x: 100, y: 100 }), paneZone(pane, { x: 190, y: 100 })); // center right
|
|
1415
1542
|
console.log(paneZone(pane, { x: 137, y: 100 }, "center")); // center: 3 px past the line, it holds
|
|
1416
1543
|
|
|
1417
|
-
// As a placeOf: the pane's id and
|
|
1544
|
+
// As a placeOf: the pane's id and region, none where this pane can't take a drop beside it.
|
|
1418
1545
|
const canSplit = false;
|
|
1419
1546
|
const placeOf = (t: { id: string; hit: typeof pane }, p: { x: number; y: number }, previous: string | null): string | null => {
|
|
1420
|
-
const
|
|
1421
|
-
return
|
|
1547
|
+
const region = paneZone(t.hit, p, (previous?.split(":")[1] as PaneZone | undefined) ?? null);
|
|
1548
|
+
return region === "center" || canSplit ? `${t.id}:${region}` : null;
|
|
1422
1549
|
};
|
|
1423
1550
|
console.log(placeOf({ id: "a", hit: pane }, { x: 100, y: 100 }, null), placeOf({ id: "a", hit: pane }, { x: 10, y: 100 }, null)); // a:center null
|
|
1424
1551
|
```
|