@n-uf/placement 26.11.18 → 26.11.19

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
@@ -3,6 +3,54 @@
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.19
7
+
8
+ - `@n-uf/placement/scene`, parity with the panels hosts draw today (Revisions 7 and 7b):
9
+ - **`layout.columnRoom`** and the note **`no-column-room`** (`width`, `need`): with `contentMin` and dynamic columns,
10
+ whether one column at its minimum fits beside the content's minimum and the anchors' room (an open anchor's width
11
+ and gutter, a folded one's rail and gutter). A host's narrow fallback reads it.
12
+ - **`Edge.outsideInset`**: an anchor edge (a side edge that takes nothing, a thumbnail strip) lies outside the inset
13
+ and the gutter: at the window's side, the inset after it; inside the side's rail when one shows. It runs into the
14
+ inset above and below only where no reserved bar lies on that side.
15
+ - **`Edge.giveWay`**: a static side edge shrinks toward its minimum, then folds into its side's rail, in give-way
16
+ order with the columns (by its items' ages). It is never deleted.
17
+ - **`setSide(scene, edgeId, side)`**: moves an edge to the other side of its axis as its side's outermost edge (ring
18
+ 0); `readScene` moves a static edge stored on the other side.
19
+ - **`Scene.insetWhen`** (`"always"`, the default, or `"docked"`): with `"docked"` the inset applies only while
20
+ an open column or a rail is beside the content (an anchor alone doesn't count).
21
+ - **Changed:** `handFold: "ride"` rides every column folded by hand, not only a one-panel one: each member a bar over
22
+ the side's first open panel column (never over an anchor), stacked in zone order.
23
+ - **Changed:** the side's rail is its outermost edge (it was placed just outside the first dynamic column).
24
+ - **Changed:** floats are clamped into [pad, W − pad] × full height (the stage less the inset's left and right), and a
25
+ float larger than that region is shrunk to fit it (they were clamped into the whole stage, never resized).
26
+ - **`SceneItem.floatMin`** (`Size`): a float of the item is laid out at `max(floatMin, min(its size, the region))`
27
+ each way. Without it a shrink stops at its form's own minimums (`cross.min` across, `main.min` along). A float
28
+ wider than the region at that floor keeps it and lies at the region's left edge, one taller than the stage keeps it
29
+ at the stage's top and runs past its bottom; a folded float (its header form) keeps its height.
30
+ - Typing: `SceneNote` gains `no-column-room`; an exhaustive `switch` over `SceneNote["code"]` needs it.
31
+ - Affected: scenes with an inset and floats near its sides, scenes riding a hand-folded column of two or more panels
32
+ (they went to the rail), and scenes with a static edge outside a dynamic column on a side whose rail shows.
33
+ - `@n-uf/placement/scene`, **fixed:** an item moved into a new column (`moveTo` with a column or rail place) kept
34
+ only the start zone since 26.11.18; it keeps its own zone (`align` end or center) again where the new column takes
35
+ its kind there, else the first zone that does.
36
+ - `@n-uf/placement/scene`, **fixed:** `homeFor` (and `dockHome`) took a new column that reused a pruned column's id
37
+ for the item's home. A start column is home only while the column under its id holds one of its items; otherwise
38
+ home is a new column at its ring. Static edges still match by id. Conformance row `P14b-dock-after-a-column-id-is-reused`.
39
+ - `@n-uf/placement/scene`, bar alignment zones (**Changed**):
40
+ - A horizontal bar's targets are picked by thirds: the left third is the leading (start) zone's, the middle the
41
+ center zone's, the right the trailing (end) zone's, the nearest of the zone's gaps within. An empty bar's strip is
42
+ three targets, `strip:<bar>:start`, `strip:<bar>:center` and `strip:<bar>:end` (was one `strip:<bar>`).
43
+ - A title bar (a bar with a fixed item that grows) is a constrained host: a toolbar there must land in its first
44
+ form, nothing in the bar may change form for it, and the title keeps its natural width (26.11.18 let it shrink to
45
+ its `min`); otherwise that zone has no target and no slot.
46
+ - In a title bar the zones are laid with the title at its natural width: a leading toolbar sits right after the
47
+ title's natural rect, trailing ones right before the end items, and a center one at the bar's true centre when that
48
+ is clear of both, else centred in the free span between them. The title takes the spare room only when nothing
49
+ follows it in its zone.
50
+ - Affected: bars' hits (a pointer in a bar's middle third now always offers the center zone, unless the toolbar
51
+ doesn't fit there in a title bar), empty bars' strip ids, and the layout of title bars with a toolbar after the
52
+ title (the title no longer grows between them).
53
+
6
54
  ## 26.11.18
7
55
 
8
56
  - `@n-uf/placement/stack`: **`StackForm.wrap`** (`{ widths, row, gap?, lead? }`, a form of the new group kind `wrap`):
package/README.md CHANGED
@@ -786,6 +786,25 @@ least and `cross.max` at most; `resize` sets it.
786
786
  zones (it sums the minimum sizes); when room is spare, start items pack from the start, end items from the end (before
787
787
  the » entry) and center items sit on the edge's middle, moved only as far as they must to stay between the other two.
788
788
 
789
+ **Bar alignment zones.** A horizontal bar picks the zone of a drop by thirds of its length: a pointer in the left third
790
+ is over the leading zone (`start`), in the middle third over the center zone, in the right third over the trailing zone
791
+ (`end`), and within the zone the nearest of its gaps wins, each zone's gaps splitting only that zone's third. A zone whose
792
+ toolbars run past its third spreads its gap lines inside the third, so its last gap keeps a slice of it. An empty bar's
793
+ strip is three targets, `strip:<bar>:start`, `strip:<bar>:center` and `strip:<bar>:end` (it was one `strip:<bar>`), one
794
+ per third. Columns keep their one `strip:<column>`.
795
+
796
+ A **title bar**, a bar with a fixed item that grows (the window title), is a constrained host: a toolbar dropped there
797
+ must land in its first form, nothing else in the bar may change form for it, and the title keeps its natural width (it may
798
+ no longer shrink to its `min` to make room). A zone where that can't hold has no target and no slot, so a bar too full
799
+ takes no drop in that zone. The zones are then laid with the title at its natural width, not at the width it grew to:
800
+
801
+ - a leading toolbar sits right after the title's natural rect;
802
+ - the trailing toolbars sit right before the end items (the window controls);
803
+ - a center toolbar sits at the bar's true centre when that is clear of both, else it is centred in the free span between
804
+ the leading and the trailing ones;
805
+ - the title takes the spare room only when nothing follows it in its zone, so a toolbar after the title is no longer
806
+ separated from it by a stretch of title.
807
+
789
808
  **Fixed items** (a title, window controls, a page readout) never change form, are never reordered, never dragged, and
790
809
  no hit covers them. Their length shrinks toward `main.min` and grows with spare room when the form `grows`; window
791
810
  controls have `min` equal to `natural`. A stage too short for them overflows instead of folding them. A `kept` item with
@@ -833,12 +852,38 @@ first column. A column folds:
833
852
  A member folded by hand in a column with others is a bar in place (its header form). The open members share the height
834
853
  through `grows`. Anchors (a thumbnails column, a fixed drawer) are ring-0 edges with `accepts: []` and fixed items.
835
854
 
855
+ **Side parity options.** For a host with panel columns, anchors and a narrow fallback. All are opt-in; a scene that sets
856
+ none lays out as before.
857
+
858
+ - **`Edge.outsideInset`**: an anchor edge (a left or right edge that takes nothing, such as a thumbnail strip) lies
859
+ outside `Scene.inset` and the gutter: at the window's side, with the inset after it toward the content, and inside its
860
+ side's rail when one shows. It runs into the inset above and below only where no reserved bar lies on that side.
861
+ - **`Edge.giveWay`**: a static left or right edge that gives way like a dynamic column. It shrinks toward its minimum,
862
+ then folds whole into its side's rail, in give-way order with the columns (by its items' ages). It is never deleted.
863
+ - **`Scene.insetWhen`** (`"always"`, the default, or `"docked"`): with `"docked"` the inset applies only while something is
864
+ docked beside the content, that is an open column or a rail (an edge that takes something and holds an item that isn't
865
+ closed). An anchor alone doesn't count; with nothing docked, the content is the whole stage.
866
+ - **`layout.columnRoom`** and the note **`no-column-room`** (`{ width, need }`): with `contentMin` and dynamic columns,
867
+ whether one column at its minimum fits beside the content's minimum and the room the anchors take (an open anchor's
868
+ width and gutter, a folded one's rail and gutter). `false` comes with the note, where `width` is the room the stage
869
+ leaves and `need` the content's minimum plus that column and its gutter. A host shows its narrow fallback (one panel
870
+ over the content) while it is `false`. An exhaustive `switch` over `SceneNote["code"]` needs the new code.
871
+ - **`handFold: "ride"`** rides every column folded by hand, not only a one-panel one: each member is a bar over the
872
+ side's first open panel column (never over an anchor), stacked in zone order. A side's rail is its outermost edge.
873
+
836
874
  **Floats** lie above the content in stage px, last on top. Each is moved inside the stage and clear of every docked
837
875
  item, every bar and every `chrome` rect (`fitFloat`), with `float-clamped`, `float-moved` or `float-covers` notes. With
838
876
  `anchor` (such as `"content-top-right"`) it sits flush with that side or corner of the content and follows it until a
839
877
  drop gives it a real rect. `orient` picks the forms it uses (default `"column"`); folded by hand (`from` over 0) it is its
840
878
  bar: that form's natural length along its orient, its other size kept.
841
879
 
880
+ The **float region** is [pad, W − pad] × the full height: the stage less `Scene.inset`'s left and right (its top and
881
+ bottom don't cut it). A float is clamped into it, and one larger than it is shrunk to fit. **`SceneItem.floatMin`**
882
+ (`Size`) is the floor of that shrink: a float of the item is laid out at `max(floatMin, min(its size, the region))` each
883
+ way. Without it a shrink stops at the form's own minimums (`cross.min` across, `main.min` along), and a float asked for
884
+ smaller than those keeps its size. A float wider than the region even at the floor keeps the floor and lies at the
885
+ region's left edge; a folded float keeps its height.
886
+
842
887
  **`previous`.** `solve(scene, { previous })` hands each edge's fits (`edges[id].free` and `.stack`) to `fitStack`, so a
843
888
  change of ages alone (a press, `use`) or `raise` changes no rect (C23), a form that was only re-measured keeps its place,
844
889
  and one whose kind changed starts over. Whenever `content` isn't the rect `previous.content` was, the layout has a
@@ -874,7 +919,8 @@ edges without `previous`.
874
919
  by is spare room: the drop shrinks it toward its natural size (to its `min` if the room needs it), so a group moved
875
920
  out of a title bar can always go back while the room allows. No slot lies over a fixed item's reserved rect. `slot`
876
921
  is the item's rect after the drop and `marker` the insertion line across the edge.
877
- - `strip:<edge>` (2): an empty accepting edge, a strip `Edge.strip` px deep (default 24) along its side, inside the
922
+ - `strip:<edge>` (2; for an empty horizontal bar three, `strip:<bar>:start`, `:center` and `:end`, one per third, see
923
+ Bar alignment zones): an empty accepting edge, a strip `Edge.strip` px deep (default 24) along its side, inside the
878
924
  content and clear of the other edges (overlay ones included), so never over a docked edge or a panel's body: a
879
925
  full-width empty bar's strip covers only the content between the columns. A compact rail's strip alone stays at the
880
926
  window edge, its own place. A gap hit that spans it across trims its start or end (a bar's strip along the top never
@@ -909,7 +955,12 @@ Each target's `after(point, grab)` is `{ scene, layout }`: the scene to commit (
909
955
 
910
956
  **Changes** are pure and return the scene given when nothing applies: `moveTo(scene, id, { edge, zone?, at })`,
911
957
  `floatAt(scene, id, rect?, orient?)` (with no rect: its last `floatSize`, anchored to the content's top-right), `fold`,
912
- `use`, `keep`, `raise` (a float on top: no use, no reshape), `open`, `close`, `orient` and `resize`. `moveTo` and
958
+ `use`, `keep`, `raise` (a float on top: no use, no reshape), `open`, `close`, `orient`, `resize` and
959
+ `setSide(scene, edgeId, side)`. `setSide` moves an edge to the other side of its axis (left ⇄ right, top ⇄ bottom) as
960
+ its side's outermost edge: ring 0, before that side's other edges, whose rings close up behind it (the side it left
961
+ closes up too). Its items, size and options go with it; the scene is given back unchanged for an unknown edge, the side
962
+ it is already on, or a side across its axis. The stored form keeps the side, and `readScene` moves a static edge stored
963
+ on the other side of `base`'s with `setSide`. `moveTo` and
913
964
  `floatAt` refuse fixed items and kinds the edge or `floatKinds` doesn't list. `moveTo` also takes `{ kind: "column",
914
965
  side, ring }` (`ring: Infinity` is the side's inner end: "Move to › Dock left"), `{ kind: "rail", side, ring }` (docked
915
966
  folded) and `{ kind: "float", rect?, anchor? }`. `homeFor(scene, id, start)` is the place a start scene gives the item
@@ -172,37 +172,53 @@ function solveEdge(scene, edge, ids, length, room, previous) {
172
172
  function zoneStarts(scene, fit, input) {
173
173
  const column = fit.axis === "column";
174
174
  const at = (r) => column ? r.y : r.x;
175
- const len = (r) => column ? r.height : r.width;
176
175
  const out = /* @__PURE__ */ new Map();
176
+ const lengths = /* @__PURE__ */ new Map();
177
177
  const drawn = fit.items.filter((p) => p.kind !== "menu");
178
- for (const p of drawn) out.set(p.id, at(p.rect));
178
+ for (const p of drawn) {
179
+ out.set(p.id, at(p.rect));
180
+ lengths.set(p.id, column ? p.rect.height : p.rect.width);
181
+ }
182
+ const len = (p) => lengths.get(p.id);
179
183
  const gap = px(input.gap);
180
184
  const start = px(input.pad?.start);
181
185
  const end = px(input.pad?.end);
182
- const menu = fit.menu ? len(fit.menu.rect) + (drawn.length > 0 ? gap : 0) : 0;
183
- const used = drawn.reduce((s2, p) => s2 + len(p.rect), 0) + Math.max(0, drawn.length - 1) * gap;
184
- const spare = fit.length - start - end - menu - used;
185
- if (spare <= EPS) return out;
186
+ const menu = fit.menu ? (column ? fit.menu.rect.height : fit.menu.rect.width) + (drawn.length > 0 ? gap : 0) : 0;
186
187
  const zone = (z) => drawn.filter((p) => zoneOf(scene.items[p.id]) === z);
187
- const total = (ps) => ps.reduce((s2, p) => s2 + len(p.rect), 0) + Math.max(0, ps.length - 1) * gap;
188
+ const s = zone("start");
189
+ const c = zone("center");
190
+ const e = zone("end");
191
+ const title = column ? void 0 : s.find((p) => {
192
+ const it = scene.items[p.id];
193
+ const f = formsOf(it, "row")[p.form];
194
+ return it.fixed && f?.main.grows && len(p) > formMain(f, "natural", fit.cross) + EPS;
195
+ });
196
+ if (title) lengths.set(title.id, formMain(formsOf(scene.items[title.id], "row")[title.form], "natural", fit.cross));
197
+ const used = drawn.reduce((sum, p) => sum + len(p), 0) + Math.max(0, drawn.length - 1) * gap;
198
+ const spare = fit.length - start - end - menu - used;
199
+ if (spare <= EPS) return { starts: out, lengths };
200
+ const total = (ps) => ps.reduce((sum, p) => sum + len(p), 0) + Math.max(0, ps.length - 1) * gap;
188
201
  const lay = (ps, from) => {
189
- let c2 = from;
202
+ let x = from;
190
203
  for (const p of ps) {
191
- out.set(p.id, c2);
192
- c2 += len(p.rect) + gap;
204
+ out.set(p.id, x);
205
+ x += len(p) + gap;
193
206
  }
194
207
  };
195
- const s = zone("start");
196
- const c = zone("center");
197
- const e = zone("end");
198
208
  lay(s, start);
199
209
  const endStart = fit.length - end - menu - total(e);
200
210
  lay(e, endStart);
201
211
  const lo = start + total(s) + (s.length > 0 ? gap : 0);
202
212
  const hi = endStart - (e.length > 0 ? gap : 0);
203
213
  const mid = (fit.length - total(c)) / 2;
204
- lay(c, Math.max(lo, Math.min(mid, hi - total(c))));
205
- return out;
214
+ const clear = mid >= lo - EPS && mid + total(c) <= hi + EPS;
215
+ lay(c, title && !clear ? Math.max(lo, (lo + hi - total(c)) / 2) : Math.max(lo, Math.min(mid, hi - total(c))));
216
+ if (title && s[s.length - 1] === title) {
217
+ const next = [...c, ...e].map((p) => out.get(p.id));
218
+ const until = next.length ? Math.min(...next) - gap : fit.length - end - menu;
219
+ lengths.set(title.id, Math.max(len(title), until - out.get(title.id)));
220
+ }
221
+ return { starts: out, lengths };
206
222
  }
207
223
  function anchored(content, w, h, anchor) {
208
224
  const left = content.x;
@@ -264,12 +280,13 @@ function solve(given, options = {}) {
264
280
  const column = axisOf(edge.side) === "column";
265
281
  const { stack } = solved;
266
282
  const thick = column ? r.width : r.height;
267
- const starts = zoneStarts(scene, stack, solved.input);
283
+ const { starts, lengths } = zoneStarts(scene, stack, solved.input);
268
284
  const toStage = (l, id) => {
269
285
  const s = id !== void 0 ? starts.get(id) : void 0;
286
+ const n = id !== void 0 ? lengths.get(id) : void 0;
270
287
  const x = column ? l.x : s ?? l.x;
271
288
  const y = column ? s ?? l.y : l.y;
272
- return rect(r.x + x, r.y + y, l.width, l.height);
289
+ return rect(r.x + x, r.y + y, column ? l.width : n ?? l.width, column ? n ?? l.height : l.height);
273
290
  };
274
291
  const tabs = new Set(solved.tabs);
275
292
  for (const id of solved.leftOut ?? []) notes.push({ code: "no-vertical-form", edge: edge.id, id });
@@ -319,16 +336,22 @@ function solve(given, options = {}) {
319
336
  };
320
337
  const rails = {};
321
338
  const gutter = px(scene.gutter);
339
+ let columnRoom;
322
340
  const isSide = (e) => e.side === "left" || e.side === "right";
341
+ const docked = order.some((e) => isSide(e) && e.accepts.length > 0 && owned.get(e).some((id) => !scene.items[id].closed));
342
+ const inset = scene.insetWhen === "docked" && !docked ? {} : scene.inset ?? {};
323
343
  const laySides = (sideEdges, area3) => {
324
344
  const H = area3.height;
325
345
  const ride = scene.handFold === "ride";
346
+ const upInset = area3.y <= stage.y + px(inset.top) + EPS ? px(inset.top) : 0;
347
+ const downInset = area3.y + area3.height >= stage.y + stage.height - px(inset.bottom) - EPS ? px(inset.bottom) : 0;
348
+ const tall = (edge) => H + (edge.outsideInset === true ? upInset + downInset : 0);
326
349
  const cols = sideEdges.map((edge) => {
327
350
  const side = edge.side;
328
- const solved = solveEdge(scene, edge, owned.get(edge), H, Math.max(0, area3.width), prevEdge(edge));
351
+ const solved = solveEdge(scene, edge, owned.get(edge), tall(edge), Math.max(0, area3.width), prevEdge(edge));
329
352
  const width = solved.stack.items.length === 0 ? 0 : Math.min(solved.stack.cross, area3.width);
330
353
  const visible = owned.get(edge).filter((id) => !scene.items[id].closed);
331
- const dyn = edge.column === true && scene.rails?.[side] !== void 0 && visible.length > 0;
354
+ const dyn = (edge.column === true || edge.giveWay === true) && scene.rails?.[side] !== void 0 && visible.length > 0;
332
355
  const forms = (id) => formsOf(scene.items[id], "column");
333
356
  const setters = solved.free.items.filter((p) => p.kind !== "menu" && formSetsCross(forms(p.id)[p.form]));
334
357
  const min = setters.length > 0 ? Math.min(width, Math.max(px(edge.cross.min), ...setters.map((p) => formCrossMin(forms(p.id)[p.form])))) : width;
@@ -340,7 +363,7 @@ function solve(given, options = {}) {
340
363
  min,
341
364
  visible,
342
365
  dyn,
343
- hand: dyn && visible.every((id) => finite(scene.items[id].from, 0) >= 1),
366
+ hand: dyn && edge.column === true && visible.every((id) => finite(scene.items[id].from, 0) >= 1),
344
367
  kept: visible.some((id) => scene.items[id].kept === true),
345
368
  age: Math.max(-Infinity, ...visible.map((id) => finite(scene.items[id].used, 0)))
346
369
  };
@@ -352,13 +375,13 @@ function solve(given, options = {}) {
352
375
  const shrinkOrder = order2.map((c, i) => ({ c, i })).sort((a, b) => rankOf(a.c) === rankOf(b.c) ? a.i - b.i : rankOf(a.c) < rankOf(b.c) ? -1 : 1).map((x) => x.c);
353
376
  const railW = (side) => px(scene.rails?.[side]?.width);
354
377
  const evaluate = (auto2) => {
355
- const openOn = (side) => cols.some((c) => c.side === side && c.dyn && !c.hand && !auto2.has(c) && c.width > 0);
356
- const riding = (c) => ride && c.hand && c.visible.length === 1 && openOn(c.side);
378
+ const openOn = (side) => cols.some((c) => c.side === side && c.dyn && c.edge.column === true && !c.hand && !auto2.has(c) && c.width > 0);
379
+ const riding = (c) => ride && c.hand && openOn(c.side);
357
380
  const railed = (c) => c.dyn && (auto2.has(c) || c.hand && !riding(c));
358
381
  const widths = new Map(cols.filter((c) => !railed(c) && !riding(c)).map((c) => [c, c.width]));
359
382
  const railSides = ["left", "right"].filter((s) => cols.some((c) => c.side === s && railed(c)));
360
383
  let used = 0;
361
- for (const w of widths.values()) used += w > 0 ? w + gutter : 0;
384
+ for (const [c, w] of widths) used += w > 0 ? w + (c.edge.outsideInset === true ? 0 : gutter) : 0;
362
385
  for (const s of railSides) used += railW(s) + gutter;
363
386
  let excess = cmin === void 0 ? -Infinity : used + cmin - area3.width;
364
387
  for (const c of shrinkOrder) {
@@ -399,6 +422,23 @@ function solve(given, options = {}) {
399
422
  }
400
423
  }
401
424
  const g = evaluate(auto);
425
+ const colMins = cols.filter((c) => c.dyn && c.edge.column === true).map((c) => c.min);
426
+ if (cmin !== void 0 && colMins.length > 0) {
427
+ let fixedRoom = 0;
428
+ const railedSides = /* @__PURE__ */ new Set();
429
+ for (const c of cols) {
430
+ if (c.edge.column === true || c.visible.length === 0) continue;
431
+ if (g.railed(c)) railedSides.add(c.side);
432
+ else if (!g.riding(c)) {
433
+ const w = g.widths.get(c) ?? c.width;
434
+ if (w > 0) fixedRoom += w + (c.edge.outsideInset === true ? 0 : gutter);
435
+ }
436
+ }
437
+ for (const s of railedSides) fixedRoom += railW(s) + gutter;
438
+ const need = cmin + Math.min(...colMins) + gutter + fixedRoom;
439
+ columnRoom = area3.width >= need - EPS;
440
+ if (!columnRoom) notes.push({ code: "no-column-room", width: area3.width, need });
441
+ }
402
442
  for (const c of shrinkOrder) {
403
443
  const w = g.widths.get(c);
404
444
  if (w !== void 0 && w < c.width - EPS) notes.push({ code: "column-shrunk", edge: c.edge.id, from: c.width, to: w });
@@ -410,17 +450,17 @@ function solve(given, options = {}) {
410
450
  const mine = cols.filter((c) => c.side === side);
411
451
  const railed = mine.filter((c) => g.railed(c));
412
452
  const riders = mine.filter((c) => g.riding(c));
413
- const host = mine.find((c) => c.dyn && !c.hand && !g.auto.has(c) && c.width > 0);
414
- const riderBar = (c) => {
415
- const id = c.visible[0];
453
+ const host = mine.find((c) => c.dyn && c.edge.column === true && !c.hand && !g.auto.has(c) && c.width > 0);
454
+ const riderBars = (c) => zoneSorted(scene, c.visible).map((id) => {
416
455
  const forms = formsOf(scene.items[id], "column");
417
456
  const form = forms.length === 0 ? 0 : Math.min(Math.max(0, Math.floor(finite(scene.items[id].from, 0))), forms.length - 1);
418
457
  return { id, form, f: forms[form], h: px(forms[form]?.main.natural) };
419
- };
420
- const ridersTop = riders.reduce((s, c) => s + riderBar(c).h, 0);
458
+ });
459
+ const ridersTop = riders.reduce((s, c) => s + riderBars(c).reduce((t, b) => t + b.h, 0), 0);
421
460
  let railRect = null;
461
+ let gap = px(side === "left" ? inset.left : inset.right);
422
462
  for (const c of mine) {
423
- if (!railRect && railed.length > 0 && c.edge.column === true) {
463
+ if (!railRect && railed.length > 0) {
424
464
  const w2 = railW(side);
425
465
  if (side === "left") {
426
466
  railRect = rect(x0, area3.y, w2, H);
@@ -430,6 +470,7 @@ function solve(given, options = {}) {
430
470
  railRect = rect(x1, area3.y, w2, H);
431
471
  x1 -= gutter;
432
472
  }
473
+ gap = gutter;
433
474
  }
434
475
  const base = { side: c.edge.side, ring: finite(c.edge.ring, 0), cross: 0, menu: null, tabs: [], stack: c.solved.stack, free: c.solved.free };
435
476
  if (g.railed(c)) {
@@ -446,13 +487,30 @@ function solve(given, options = {}) {
446
487
  solved = solveEdge(scene, plain, owned.get(c.edge), H - top, w, prevEdge(c.edge));
447
488
  }
448
489
  let r;
449
- if (side === "left") {
490
+ if (c.edge.outsideInset === true) {
491
+ const y0 = area3.y - upInset;
492
+ const h = tall(c.edge);
493
+ if (side === "left") {
494
+ r = rect(x0 - gap, y0, w, h);
495
+ x0 += w;
496
+ } else {
497
+ r = rect(x1 + gap - w, y0, w, h);
498
+ x1 -= w;
499
+ }
500
+ if (Math.abs(h - H) > EPS || Math.abs(w - c.width) > EPS) {
501
+ const forced = { ...c.edge, cross: { ...c.edge.cross, min: w, max: w } };
502
+ const { size: _s, ...plain } = forced;
503
+ solved = solveEdge(scene, plain, owned.get(c.edge), h, w, prevEdge(c.edge));
504
+ }
505
+ } else if (side === "left") {
450
506
  r = rect(x0, area3.y + top, w, H - top);
451
507
  x0 += w > 0 ? w + gutter : 0;
508
+ if (w > 0) gap = gutter;
452
509
  } else {
453
510
  x1 -= w;
454
511
  r = rect(x1, area3.y + top, w, H - top);
455
512
  x1 -= w > 0 ? gutter : 0;
513
+ if (w > 0) gap = gutter;
456
514
  }
457
515
  emit(c.edge, r, solved, w < c.width - EPS ? { shrunk: true } : {});
458
516
  }
@@ -460,12 +518,15 @@ function solve(given, options = {}) {
460
518
  const hr = edges[host.edge.id].rect;
461
519
  let y = area3.y;
462
520
  for (const c of riders) {
463
- const b = riderBar(c);
464
- const at = rect(hr.x, y, hr.width, b.h);
465
- const it = scene.items[b.id];
466
- items[b.id] = { rect: at, kind: it.kind, form: b.form, formKind: b.f?.kind ?? "header", edge: c.edge.id, zone: zoneOf(it), rides: host.edge.id, folded: "hand" };
467
- edges[c.edge.id] = { side: c.edge.side, ring: finite(c.edge.ring, 0), rect: at, cross: 0, menu: null, tabs: [], stack: c.solved.stack, free: c.solved.free, rides: host.edge.id, folded: "hand" };
468
- y += b.h;
521
+ const bars = riderBars(c);
522
+ const y0 = y;
523
+ for (const b of bars) {
524
+ const at = rect(hr.x, y, hr.width, b.h);
525
+ const it = scene.items[b.id];
526
+ items[b.id] = { rect: at, kind: it.kind, form: b.form, formKind: b.f?.kind ?? "header", edge: c.edge.id, zone: zoneOf(it), rides: host.edge.id, folded: "hand" };
527
+ y += b.h;
528
+ }
529
+ edges[c.edge.id] = { side: c.edge.side, ring: finite(c.edge.ring, 0), rect: rect(hr.x, y0, hr.width, y - y0), cross: 0, menu: null, tabs: [], stack: c.solved.stack, free: c.solved.free, rides: host.edge.id, folded: "hand" };
469
530
  }
470
531
  }
471
532
  if (railRect) {
@@ -489,7 +550,6 @@ function solve(given, options = {}) {
489
550
  }
490
551
  return rect(x0, area3.y, Math.max(0, x1 - x0), H);
491
552
  };
492
- const inset = scene.inset ?? {};
493
553
  let area2 = rect(stage.x + px(inset.left), stage.y + px(inset.top), Math.max(0, stage.width - px(inset.left) - px(inset.right)), Math.max(0, stage.height - px(inset.top) - px(inset.bottom)));
494
554
  const reserved = order.filter((e) => e.mode !== "overlay");
495
555
  for (const e of reserved) if (!isSide(e) && e.span !== "between") area2 = lay(e, area2, true);
@@ -517,6 +577,7 @@ function solve(given, options = {}) {
517
577
  if (e.menu) avoid.push(e.menu.rect);
518
578
  }
519
579
  for (const c of scene.chrome ?? []) avoid.push(c);
580
+ const floatRegion = rect(stage.x + px(inset.left), stage.y, Math.max(0, stage.width - px(inset.left) - px(inset.right)), stage.height);
520
581
  const floats = [];
521
582
  for (const f of scene.floats) {
522
583
  if (!claim(f.id)) continue;
@@ -529,17 +590,24 @@ function solve(given, options = {}) {
529
590
  }
530
591
  const from = shape.form;
531
592
  const form = formsOf(it, f.orient === "row" ? "row" : "column")[from];
532
- const w = shape.width;
533
- const h = shape.height;
593
+ const row = f.orient === "row";
594
+ const floor = {
595
+ width: it.floatMin ? px(it.floatMin.width) : Math.min(shape.width, px(row ? form?.main.min : form?.cross.min)),
596
+ height: it.floatMin ? px(it.floatMin.height) : Math.min(shape.height, px(row ? form?.cross.min : form?.main.min))
597
+ };
598
+ const w = Math.max(floor.width, Math.min(shape.width, floatRegion.width));
599
+ const folded = form?.kind === "header";
600
+ const h = folded ? shape.height : Math.max(floor.height, Math.min(shape.height, floatRegion.height));
534
601
  const want = f.anchor ? anchored(content, w, h, f.anchor) : rect(finite(f.rect.x, stage.x), finite(f.rect.y, stage.y), w, h);
535
- const fit = fitFloat(want, stage, avoid);
602
+ const fit0 = fitFloat(want, floatRegion, avoid);
603
+ const fit = w > floatRegion.width + EPS ? { ...fit0, rect: rect(floatRegion.x, fit0.rect.y, w, fit0.rect.height) } : fit0;
536
604
  if (fit.clamped) notes.push({ code: "float-clamped", id: f.id });
537
605
  if (fit.snapped) notes.push({ code: "float-moved", id: f.id });
538
606
  if (fit.covers.length > 0) notes.push({ code: "float-covers", id: f.id });
539
607
  items[f.id] = { ...shapeOf(form, fit.rect, f.orient === "row" ? "row" : "column", fit.rect.width), rect: fit.rect, kind: it.kind, form: from, formKind: form?.kind ?? "open", floating: true };
540
608
  floats.push(f.id);
541
609
  }
542
- return { items, edges, content, floats, rails, notes };
610
+ return { items, edges, content, floats, rails, ...columnRoom !== void 0 ? { columnRoom } : {}, notes };
543
611
  }
544
612
 
545
613
  // src/scene/changes.ts
@@ -599,8 +667,10 @@ function insertColumn(scene, id, side, ring) {
599
667
  const col = newColumn(scene, side, kind, r, [id]);
600
668
  if (!col) return null;
601
669
  if (!zoneTakes(col, "start", kind)) return null;
602
- const { align: _a, ...plain } = scene.items[id];
603
- const placed = withItem(scene, plain);
670
+ const item = scene.items[id];
671
+ const zone = zoneTakes(col, zoneOf(item), kind) ? zoneOf(item) : zonesTaking(col, kind)[0] ?? "start";
672
+ const { align: _a, ...plain } = item;
673
+ const placed = withItem(scene, zone === "start" ? plain : { ...plain, align: zone });
604
674
  const shifted = placed.edges.map((e) => e.side === side && e.ring >= r ? { ...e, ring: e.ring + 1 } : e);
605
675
  return { ...placed, edges: closeRings([...shifted, col], /* @__PURE__ */ new Set([side])) };
606
676
  }
@@ -627,8 +697,7 @@ function moveTo(scene, id, place) {
627
697
  }
628
698
  if (place.kind === "column" || place.kind === "rail") {
629
699
  if (place.kind === "rail" && !scene.rails?.[place.side]?.accepts.includes(item.kind)) return scene;
630
- const { align: _a, ...plain } = item;
631
- const folded = place.kind === "rail" ? { ...plain, from: Math.max(1, plain.from ?? 0) } : plain;
700
+ const folded = place.kind === "rail" ? { ...item, from: Math.max(1, item.from ?? 0) } : item;
632
701
  const made = insertColumn(withItem(lift(scene, id), folded), id, place.side, place.ring);
633
702
  return made ?? scene;
634
703
  }
@@ -707,12 +776,20 @@ function resize(scene, edgeId, size) {
707
776
  }
708
777
  return { ...scene, edges: scene.edges.map((e) => e === edge ? { ...e, size } : e) };
709
778
  }
779
+ function setSide(scene, edgeId, side) {
780
+ const edge = scene.edges.find((e) => e.id === edgeId);
781
+ if (!edge || edge.side === side || axisOf(edge.side) !== axisOf(side)) return scene;
782
+ const moved = { ...edge, side, ring: 0 };
783
+ const others = scene.edges.filter((e) => e !== edge).map((e) => e.side === side ? { ...e, ring: e.ring + 1 } : e);
784
+ return { ...scene, edges: closeRings([moved, ...others], /* @__PURE__ */ new Set([edge.side, side])) };
785
+ }
710
786
  function homeFor(scene, id, start) {
711
787
  for (const e of start.edges) {
712
788
  const k = e.items.indexOf(id);
713
789
  if (k < 0) continue;
714
790
  const zone = zoneOf(itemOf(start, id) ?? itemOf(scene, id));
715
- const here = scene.edges.find((x) => x.id === e.id);
791
+ const found = scene.edges.find((x) => x.id === e.id);
792
+ const here = found && (e.column !== true || found.items.some((x) => e.items.includes(x))) ? found : void 0;
716
793
  if (here) {
717
794
  const now = here.items.filter((x) => x !== id && zoneOf(itemOf(scene, x)) === zone);
718
795
  const next = e.items.slice(k + 1).find((x) => now.includes(x));
@@ -835,6 +912,7 @@ function read(data, base) {
835
912
  const sizes = /* @__PURE__ */ new Map();
836
913
  const made = [];
837
914
  const rings = /* @__PURE__ */ new Map();
915
+ const moves = /* @__PURE__ */ new Map();
838
916
  if (data.edges !== void 0 && !Array.isArray(data.edges)) drop("edges");
839
917
  for (const e of Array.isArray(data.edges) ? data.edges : []) {
840
918
  if (!isObject(e) || typeof e.id !== "string") {
@@ -853,6 +931,7 @@ function read(data, base) {
853
931
  }
854
932
  if (edge.column === true && isNum(e.ring)) rings.set(edge.id, e.ring);
855
933
  if (e.side !== void 0 && !SIDES.includes(e.side)) drop(`edge:${e.id}:side`);
934
+ else if (edge.column !== true && typeof e.side === "string" && e.side !== edge.side && axisOf(e.side) === axisOf(edge.side)) moves.set(edge.id, e.side);
856
935
  const ids = [];
857
936
  for (const id of Array.isArray(e.items) ? e.items : []) {
858
937
  if (!known(id) || placed.has(id)) drop(`edge:${edge.id}:${String(id)}`);
@@ -908,11 +987,13 @@ function read(data, base) {
908
987
  return { ...plain, ring: rings.get(edge.id) ?? edge.ring, items: items1, ...size !== void 0 ? { size } : {} };
909
988
  });
910
989
  for (const f of base.floats) if (!placed.has(f.id)) floats.push(f);
911
- const scene = prune({ ...base, items, edges: closeRings(edges, new Set(made.length > 0 || rings.size > 0 ? ["left", "right"] : [])), floats });
990
+ let scene = prune({ ...base, items, edges: closeRings(edges, new Set(made.length > 0 || rings.size > 0 ? ["left", "right"] : [])), floats });
991
+ for (const [id, side] of moves) scene = setSide(scene, id, side);
912
992
  return { scene, dropped };
913
993
  }
914
994
 
915
995
  // src/scene/targets.ts
996
+ var ZONE_ORDER = { start: 0, center: 1, end: 2 };
916
997
  var EPS2 = 1e-6;
917
998
  var PLANE = rect(-1e9, -1e9, 2e9, 2e9);
918
999
  var area = (r) => Math.max(0, r.width) * Math.max(0, r.height);
@@ -1201,6 +1282,13 @@ function edgeTargets(scene, rest, now, base, edge, dragged, reach, blockers, chr
1201
1282
  const restEdge = rest.edges.find((e) => e.id === edge.id);
1202
1283
  const fixedIds = restEdge.items.filter((id) => rest.items[id]?.fixed && base.items[id]?.edge === edge.id);
1203
1284
  const tooWideBefore = new Set(base.notes.flatMap((n) => "edge" in n && n.edge === edge.id && n.code === "too-wide" ? [n.id] : []));
1285
+ const thirds = !column && !edge.compact;
1286
+ const natural = (id, form) => {
1287
+ const f = formsOf(scene.items[id], "row")[form];
1288
+ return f ? formMain(f, "natural", el.cross) : 0;
1289
+ };
1290
+ const titles = thirds ? fixedIds.filter((id) => !!formsOf(scene.items[id], "row")[base.items[id].form]?.main.grows) : [];
1291
+ const titled = titles.length > 0;
1204
1292
  const fits = (after) => {
1205
1293
  const me = after.items[dragged];
1206
1294
  if (!me || me.edge !== edge.id || me.inMenu) return false;
@@ -1214,6 +1302,15 @@ function edgeTargets(scene, rest, now, base, edge, dragged, reach, blockers, chr
1214
1302
  const b = base.items[id];
1215
1303
  if (!a || a.form !== b.form || a.formKind !== b.formKind || Math.abs(a.rect.x - b.rect.x) > 0.5 || Math.abs(a.rect.y - b.rect.y) > 0.5) return false;
1216
1304
  }
1305
+ if (titled) {
1306
+ if (me.form !== 0) return false;
1307
+ for (const id of restEdge.items) {
1308
+ const a = after.items[id];
1309
+ const b = base.items[id];
1310
+ if (!a || !b || b.edge !== edge.id) continue;
1311
+ if (titles.includes(id) ? a.rect.width < natural(id, a.form) - 0.5 : a.form !== b.form || !!a.inMenu !== !!b.inMenu) return false;
1312
+ }
1313
+ }
1217
1314
  return !chrome.some((c) => overlaps(me.rect, c));
1218
1315
  };
1219
1316
  const markerOf = (after) => {
@@ -1258,6 +1355,21 @@ function edgeTargets(scene, rest, now, base, edge, dragged, reach, blockers, chr
1258
1355
  const r = el.rect;
1259
1356
  const hit = edge.side === "left" ? rect(r.x, r.y, depth, r.height) : edge.side === "right" ? rect(r.x + r.width - depth, r.y, depth, r.height) : edge.side === "top" ? rect(r.x, r.y, r.width, depth) : rect(r.x, r.y + r.height - depth, r.width, depth);
1260
1357
  const keep2 = { x: hit.x + hit.width / 2, y: hit.y + hit.height / 2 };
1358
+ if (thirds) {
1359
+ const c = base.content;
1360
+ const x0 = Math.max(hit.x, c.x);
1361
+ const x1 = Math.min(hit.x + hit.width, c.x + c.width);
1362
+ if (x1 - x0 <= EPS2) return [];
1363
+ const w = (x1 - x0) / 3;
1364
+ const out2 = [];
1365
+ ZONES.forEach((zone, k) => {
1366
+ if (!zoneTakes(edge, zone, scene.items[dragged].kind)) return;
1367
+ const part = rect(x0 + k * w, hit.y, w, hit.height);
1368
+ const t2 = target(`strip:${edge.id}:${zone}`, { kind: "gap", edge: edge.id, zone, at: 0 }, part, { x: part.x + part.width / 2, y: part.y + part.height / 2 });
1369
+ if (t2) out2.push(t2);
1370
+ });
1371
+ return out2;
1372
+ }
1261
1373
  if (!zoneTakes(edge, "start", scene.items[dragged].kind)) return [];
1262
1374
  const t = target(`strip:${edge.id}`, { kind: "gap", edge: edge.id, zone: "start", at: 0 }, hit, keep2);
1263
1375
  return t ? [t] : [];
@@ -1289,7 +1401,7 @@ function edgeTargets(scene, rest, now, base, edge, dragged, reach, blockers, chr
1289
1401
  gaps.push({ zone, at: k, line });
1290
1402
  }
1291
1403
  }
1292
- const sorted = gaps.map((g, i) => ({ ...g, i })).sort((a, b) => a.line - b.line || a.i - b.i).filter((g, i, all) => i === 0 || Math.abs(g.line - all[i - 1].line) > EPS2);
1404
+ const sorted = gaps.map((g, i) => ({ ...g, i })).sort((a, b) => (thirds ? ZONE_ORDER[a.zone] - ZONE_ORDER[b.zone] : 0) || a.line - b.line || a.i - b.i).filter((g, i, all) => i === 0 || thirds && g.zone !== all[i - 1].zone || Math.abs(g.line - all[i - 1].line) > EPS2);
1293
1405
  const out = [];
1294
1406
  const live = sorted.map((g) => {
1295
1407
  const place = { kind: "gap", edge: edge.id, zone: g.zone, at: g.at };
@@ -1299,9 +1411,30 @@ function edgeTargets(scene, rest, now, base, edge, dragged, reach, blockers, chr
1299
1411
  const band = bandOpt === "middle" ? Infinity : Math.max(0, Number.isFinite(bandOpt) ? bandOpt : DEFAULT_HIT_BAND);
1300
1412
  const bodies = Number.isFinite(band) ? Object.values(base.items).filter((p) => p.edge === edge.id && p.formKind === "open").map((p) => ({ a: at(p.rect), b: at(p.rect) + len(p.rect) })) : [];
1301
1413
  const inward = edge.compact ? RAIL_REACH : 0;
1414
+ const solidSpans = fixedIds.filter((id) => !formsOf(scene.items[id], axisOf(edge.side))[base.items[id].form]?.main.grows).map((id) => ({ a: at(base.items[id].rect), b: at(base.items[id].rect) + len(base.items[id].rect) }));
1302
1415
  live.forEach((g, i) => {
1303
1416
  let from = i === 0 ? -Infinity : (live[i - 1].line + g.line) / 2;
1304
1417
  let to = i === live.length - 1 ? Infinity : (g.line + live[i + 1].line) / 2;
1418
+ if (thirds) {
1419
+ const k = ZONE_ORDER[g.zone];
1420
+ const prev = live[i - 1]?.zone === g.zone ? live[i - 1] : void 0;
1421
+ const next = live[i + 1]?.zone === g.zone ? live[i + 1] : void 0;
1422
+ const a0 = main0 + length * k / 3;
1423
+ const b0 = main0 + length * (k + 1) / 3;
1424
+ const lines = live.filter((x) => x.zone === g.zone).map((x) => x.line);
1425
+ const first = Math.min(...lines);
1426
+ const last = Math.max(...lines);
1427
+ const a1 = Math.max(a0, ...solidSpans.filter((s) => s.b <= first + EPS2).map((s) => s.b));
1428
+ const b1 = Math.min(b0, ...solidSpans.filter((s) => s.a >= last - EPS2).map((s) => s.a));
1429
+ const [a, b] = b1 - a1 > EPS2 ? [a1, b1] : [a0, b0];
1430
+ const span0 = Math.min(a, ...lines);
1431
+ const span1 = Math.max(b, ...lines);
1432
+ const inThird = (x) => span1 - span0 > EPS2 ? a + (x - span0) / (span1 - span0) * (b - a) : x;
1433
+ const lo = k === 0 ? -Infinity : a0;
1434
+ const hi = k === 2 ? Infinity : b0;
1435
+ from = Math.max(lo, prev ? (inThird(prev.line) + inThird(g.line)) / 2 : lo);
1436
+ to = Math.min(hi, next ? (inThird(g.line) + inThird(next.line)) / 2 : hi);
1437
+ }
1305
1438
  for (const p of bodies) {
1306
1439
  if (p.b <= g.line + EPS2 && p.b > from) from = Math.max(from, p.b - band / 2);
1307
1440
  if (p.a >= g.line - EPS2 && p.a < to) to = Math.min(to, p.a + band / 2);
@@ -1342,6 +1475,7 @@ export {
1342
1475
  raise,
1343
1476
  orient,
1344
1477
  resize,
1478
+ setSide,
1345
1479
  homeFor,
1346
1480
  dockHome,
1347
1481
  storeScene,
@@ -1350,4 +1484,4 @@ export {
1350
1484
  reservedRect,
1351
1485
  stops
1352
1486
  };
1353
- //# sourceMappingURL=chunk-HQE2DOWA.js.map
1487
+ //# sourceMappingURL=chunk-NCHRKLT3.js.map