@n-uf/docking 26.12.11 → 26.12.13

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
@@ -7,6 +7,45 @@ package, the docking model shipped as `@n-uf/placement/scene` and `/scene/cases`
7
7
 
8
8
  Unreleased entries live in `changes/` until a release joins them.
9
9
 
10
+ ## 26.12.13
11
+
12
+ - **Added: `givesWayLast`.** A host can name the panels that give way last. A column holding one neither shrinks nor
13
+ folds until every column holding none has folded; then it shrinks, then folds. Within each group the give-way order
14
+ is as before, `kept` included. The room a fold frees goes to the content where no open column is below its width. A
15
+ declaration: re-declared at each build, never stored. Without it nothing changes.
16
+ - **Added (conformance):** the rows `window-a-three-declared-908`, `window-a-pair-declared-908`,
17
+ `window-b-three-declared-840` and `window-b-pair-declared-840`: the widest window rows with every card at a natural
18
+ width above its minimum and Findings declared last. Findings keeps its width while a first-tier column is open, so
19
+ all open fit from 908 in window A (808 without the declaration) and from 840 in window B (720). With them, one pixel
20
+ narrower (`…-declared-907`, `…-declared-839`): the left column folds. A host that declares a panel last plays these;
21
+ the rows without the declaration, whose cards stand at their minimums, are unchanged.
22
+ - **Fixed (conformance):** a host's id map (`CaseHost.ids`) renames the entries of `givesWayLast` too, so a declared
23
+ row keeps its declaration under the host's ids.
24
+
25
+ ## 26.12.12
26
+
27
+ - **`DockState.sideColumns` is a count** (additive): `sideColumns?: number | "one"`, the most columns a side may
28
+ hold, and a side never gains a column past it. One function reads it, the new export
29
+ **`sideColumnCap(state)`** (`Infinity` for no cap): absent or `Infinity`, no cap; a whole number of 1 or more,
30
+ itself; any other number rounded down, never below 1; not a number, 1; nothing throws. A drag offers a new-column
31
+ line on a side exactly when the side would hold fewer columns than its cap with the dragged item dropped on another
32
+ side (folded columns and declared column edges, empty or not, count; a column the lift empties does not, unless
33
+ declared). On a full side a rail stop is offered only where it puts the item into a column that exists, and no
34
+ change function makes a column past the cap: `moveTo` with a column or rail place there, and so `dockHome`, change
35
+ nothing, and `setSide` moves no column onto it. A state that declares nothing gets the targets it had.
36
+ - **`"one"` is deprecated:** it reads as 1. Declare `1`; `"one"` is removed in the first breaking release after hosts
37
+ declare a number.
38
+ - **Changed (behavior) under `"one"`:** a side that keeps a column now takes no second one from anything. A rail
39
+ stop that would make a second, folded column there is no longer offered (26.12.11 offered it: the one way a side
40
+ under `"one"` ended with two columns). And `moveTo` with a column or rail place, `dockHome` (whose home may be a
41
+ column that is gone) and `setSide` (moving a column there) now change nothing on such a side, where 26.12.11 did
42
+ not cap them. From a state within the cap, every other target is as before.
43
+ - **`mergeSideColumns(state, max?)`** (additive): each side's columns past `max` merge into its `max`-th column (by
44
+ ring), which keeps its id and options and takes the inner columns' items after its own, by ring; the `max − 1`
45
+ outermost stay as they are. `max` is read as the cap is; left out, it is the declared cap, or 1 with none, so a host
46
+ that declares a cap of 2 keeps its stored two-column layouts. With `max` 1 it is the function it was. It changes no
47
+ item's `used` or `kept`. Lowering the cap merges nothing: a host that lowers it calls the merge.
48
+
10
49
  ## 26.12.11
11
50
 
12
51
  No changes in `@n-uf/docking`. Released in step with `@n-uf/motion` and `@n-uf/placement`, which share the version.
@@ -182,6 +182,19 @@ function isSideBar(state, e) {
182
182
  return !e.accepts.some((k) => panelKinds.includes(k));
183
183
  }
184
184
  var isSideColumn = (state, e) => (e.side === "left" || e.side === "right") && !e.compact && e.accepts.length > 0 && !isSideBar(state, e);
185
+ function sideColumnCap(state) {
186
+ return capOf(state.sideColumns);
187
+ }
188
+ function capOf(v) {
189
+ if (v === void 0 || v === Infinity) return Infinity;
190
+ if (v === "one") return 1;
191
+ if (typeof v !== "number" || Number.isNaN(v)) return 1;
192
+ return Math.max(1, Math.floor(v));
193
+ }
194
+ function sideColumnCount(state, side) {
195
+ return state.edges.filter((e) => e.side === side && isSideColumn(state, e) && (e.items.length > 0 || e.column !== true)).length;
196
+ }
197
+ var columnRoom = (state, side) => sideColumnCount(state, side) < sideColumnCap(state);
185
198
  var keepsLengths = (state, e) => e.compact === true || e.side === "top" || e.side === "bottom" || isSideBar(state, e);
186
199
  function growsOnBar(state, e, id, form) {
187
200
  const it = Object.hasOwn(state.items, id) ? state.items[id] : void 0;
@@ -370,6 +383,7 @@ import { formCrossMin, formSetsCross } from "@n-uf/placement/stack";
370
383
  var finite = (x, fallback) => typeof x === "number" && Number.isFinite(x) ? x : fallback;
371
384
  var px = (x) => Math.max(0, finite(x, 0));
372
385
  var isSide = (e) => e.side === "left" || e.side === "right";
386
+ var holds = (state, ids, test) => ids.some((id) => test(state.items[id], id));
373
387
  var giveWayOrder = (a, b) => Number(a.kept) - Number(b.kept) || a.age - b.age || finite(a.edge.ring, 0) - finite(b.edge.ring, 0);
374
388
  function cutOrder(edges) {
375
389
  const phase = (e) => e.side === "left" || e.side === "right" ? 1 : e.span === "between" ? 2 : 0;
@@ -1090,6 +1104,7 @@ import { formCrossMin as formCrossMin3, formMenu as formMenu5, formSetsCross as
1090
1104
  var isChrome = (state, c) => !c.dyn && isSideBar(state, c.edge);
1091
1105
  function columnsOf(d, sideEdges, area9, tall) {
1092
1106
  const { state } = d;
1107
+ const declared = new Set(Array.isArray(state.givesWayLast) ? state.givesWayLast.filter((id) => typeof id === "string") : []);
1093
1108
  return sideEdges.map((edge) => {
1094
1109
  const side = edge.side;
1095
1110
  const solved = solveEdge(state, edge, d.owned.get(edge), tall(edge), Math.max(0, area9.width), d.prevEdge(edge));
@@ -1108,7 +1123,8 @@ function columnsOf(d, sideEdges, area9, tall) {
1108
1123
  visible,
1109
1124
  dyn,
1110
1125
  hand: dyn && edge.column === true && visible.every((id) => startOf(state.items[id], formsOf(state.items[id], "column")) > 0),
1111
- kept: visible.some((id) => state.items[id].kept === true),
1126
+ kept: holds(state, visible, (item) => item.kept === true),
1127
+ last: holds(state, visible, (_, id) => declared.has(id)),
1112
1128
  age: Math.max(-Infinity, ...visible.map((id) => finite(state.items[id].used, 0)))
1113
1129
  };
1114
1130
  });
@@ -1121,7 +1137,8 @@ function giveWay(d, cols, area9, gutter) {
1121
1137
  const floor = cmin !== void 0 && typeof chromeWidth === "number" && Number.isFinite(chromeWidth) ? Math.min(cmin, px(chromeWidth)) : void 0;
1122
1138
  const chrome = floor === void 0 ? 0 : cols.filter((c) => isChrome(state, c) && c.width > 0).reduce((s, c) => s + c.width + (c.edge.outsideInset === true ? 0 : gutter), 0);
1123
1139
  if (floor !== void 0) d.chromeAllowance = Math.min(chrome, cmin - floor);
1124
- const foldOrder = cols.filter((c) => c.dyn && !c.hand && c.width > 0).sort((a, b) => giveWayOrder(a, b) || (a.side === b.side ? 0 : a.side === "left" ? -1 : 1));
1140
+ const foldOrder = cols.filter((c) => c.dyn && !c.hand && c.width > 0).sort((a, b) => Number(a.last) - Number(b.last) || giveWayOrder(a, b) || (a.side === b.side ? 0 : a.side === "left" ? -1 : 1));
1141
+ const firstOpen = (auto2) => foldOrder.some((c) => !c.last && !auto2.has(c));
1125
1142
  const shrunkBefore = (previous?.notes ?? []).flatMap((n) => n.code === "column-shrunk" ? [n.edge] : []);
1126
1143
  const rankOf = (c) => shrunkBefore.includes(c.edge.id) ? shrunkBefore.indexOf(c.edge.id) : Infinity;
1127
1144
  const shrinkOrder = foldOrder.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);
@@ -1136,8 +1153,10 @@ function giveWay(d, cols, area9, gutter) {
1136
1153
  for (const [c, w] of widths) used += w > 0 ? w + (c.edge.outsideInset === true ? 0 : gutter) : 0;
1137
1154
  for (const s of railSides) used += railW(s) + gutter;
1138
1155
  let excess = cmin === void 0 ? -Infinity : floor === void 0 ? used + cmin - area9.width : Math.max(used - chrome + cmin, used + floor) - area9.width;
1156
+ const tierOpen = firstOpen(auto2);
1139
1157
  for (const c of shrinkOrder) {
1140
1158
  if (excess <= EPS7) break;
1159
+ if (tierOpen && c.last) continue;
1141
1160
  const w = widths.get(c);
1142
1161
  if (w === void 0) continue;
1143
1162
  const take = Math.min(excess, w - c.min);
@@ -1161,7 +1180,8 @@ function giveWay(d, cols, area9, gutter) {
1161
1180
  const byId = new Map(foldOrder.map((c) => [c.edge.id, c]));
1162
1181
  const anew = (c) => fresh.has(c.edge.id) || c.visible.some((id) => fresh.has(id)) || c.visible.some((id) => opened.has(id)) && c.visible.some((id) => !opened.has(id));
1163
1182
  const was = previous.notes.flatMap((n) => (n.code === "column-folded" || n.code === "kept-folded") && byId.has(n.edge) && !anew(byId.get(n.edge)) ? [byId.get(n.edge)] : []);
1164
- auto = new Set(was);
1183
+ const stays = was.some((c) => c.last) && firstOpen(new Set(was)) ? was.filter((c) => !c.last) : was;
1184
+ auto = /* @__PURE__ */ new Set([...stays.filter((c) => !c.last), ...stays.filter((c) => c.last)]);
1165
1185
  if (evaluate(auto).excess <= EPS7) unfold();
1166
1186
  }
1167
1187
  for (const c of foldOrder) {
@@ -1175,7 +1195,7 @@ function giveWay(d, cols, area9, gutter) {
1175
1195
  }
1176
1196
  return evaluate(auto);
1177
1197
  }
1178
- function columnRoom(d, cols, area9, f) {
1198
+ function columnRoom2(d, cols, area9, f) {
1179
1199
  const { state } = d;
1180
1200
  const cmin = state.contentMin ? px(state.contentMin.width) : void 0;
1181
1201
  const openMin = (ids, least) => Math.max(
@@ -1332,7 +1352,7 @@ function laySides(d, sideEdges, area9, f) {
1332
1352
  const tall = (edge) => H + (edge.outsideInset === true ? reach.up + reach.down : 0);
1333
1353
  const cols = columnsOf(d, sideEdges, area9, tall);
1334
1354
  const g = giveWay(d, cols, area9, f.gutter);
1335
- columnRoom(d, cols, area9, f);
1355
+ columnRoom2(d, cols, area9, f);
1336
1356
  giveWayNotes(d, g, cols);
1337
1357
  const walk = { x0: area9.x, x1: area9.x + area9.width };
1338
1358
  for (const side of ["left", "right"]) laySide(d, side, cols, g, area9, f, walk, reach.up, tall);
@@ -1462,8 +1482,8 @@ function layOut(given, options, caps, gave) {
1462
1482
  contentNotes(d, content);
1463
1483
  const keepClear = resolveKeepClear(state, content);
1464
1484
  const floats = layFloats(d, stage, content, inset, keepClearFor(state, { keepClear }, "floats"));
1465
- const { items, edges, rails, railPlaces, columnRoom: columnRoom2, notes } = d;
1466
- return { items, edges, content, floats, rails, railPlaces, ...columnRoom2 !== void 0 ? { columnRoom: columnRoom2 } : {}, ...keepClear ? { keepClear } : {}, notes };
1485
+ const { items, edges, rails, railPlaces, columnRoom: columnRoom3, notes } = d;
1486
+ return { items, edges, content, floats, rails, railPlaces, ...columnRoom3 !== void 0 ? { columnRoom: columnRoom3 } : {}, ...keepClear ? { keepClear } : {}, notes };
1467
1487
  }
1468
1488
 
1469
1489
  // src/dividers.ts
@@ -1646,13 +1666,16 @@ function prune(state) {
1646
1666
  const sides = new Set(gone.map((e) => e.side));
1647
1667
  return { ...state, edges: closeRings(state.edges.filter((e) => !gone.includes(e)), sides) };
1648
1668
  }
1649
- function mergeSideColumns(state) {
1669
+ function mergeSideColumns(state, max) {
1670
+ const declared = sideColumnCap(state);
1671
+ const cap = max === void 0 ? declared === Infinity ? 1 : declared : capOf(max);
1650
1672
  let edges = [...state.edges];
1651
1673
  const sides = /* @__PURE__ */ new Set();
1652
1674
  for (const side of ["left", "right"]) {
1653
1675
  const cols = edges.filter((e) => e.side === side && isSideColumn(state, e)).sort((a, b) => a.ring - b.ring);
1654
- if (cols.length < 2) continue;
1655
- const [keep, ...rest] = cols;
1676
+ if (cols.length <= cap) continue;
1677
+ const keep = cols[cap - 1];
1678
+ const rest = cols.slice(cap);
1656
1679
  const merged = { ...keep, items: [...keep.items, ...rest.flatMap((e) => e.items)] };
1657
1680
  edges = edges.filter((e) => !rest.includes(e)).map((e) => e === keep ? merged : e);
1658
1681
  sides.add(side);
@@ -1717,6 +1740,7 @@ function columnFloor(edges, side) {
1717
1740
  return n;
1718
1741
  }
1719
1742
  function insertColumn(state0, id, side, ring, others) {
1743
+ if (!columnRoom(state0, side)) return null;
1720
1744
  const state = { ...state0, edges: closeRings(state0.edges, /* @__PURE__ */ new Set([side])) };
1721
1745
  const kind = state.items[id].kind;
1722
1746
  const mine = state.edges.filter((e) => e.side === side);
@@ -1916,7 +1940,9 @@ function setSide(state, edgeId, side) {
1916
1940
  if (!edge || edge.side === side || axisOf(edge.side) !== axisOf(side)) return state;
1917
1941
  const moved = { ...edge, side, ring: 0 };
1918
1942
  const others = state.edges.filter((e) => e !== edge).map((e) => e.side === side ? { ...e, ring: e.ring + 1 } : e);
1919
- return { ...state, edges: closeRings([moved, ...others], /* @__PURE__ */ new Set([edge.side, side])) };
1943
+ const after = { ...state, edges: closeRings([moved, ...others], /* @__PURE__ */ new Set([edge.side, side])) };
1944
+ if ((side === "left" || side === "right") && sideColumnCount(after, side) > sideColumnCount(state, side) && !columnRoom(state, side)) return state;
1945
+ return after;
1920
1946
  }
1921
1947
  function homeFor(state, id, start) {
1922
1948
  for (const e of start.edges) {
@@ -2731,10 +2757,10 @@ function soundness(state, base, dragged) {
2731
2757
  if (a.inMenu) continue;
2732
2758
  const f = formsOf(state.items[id], axisOf(e.side))[a.form];
2733
2759
  const len2 = axisOf(e.side) === "column" ? a.rect.height : a.rect.width;
2734
- const holds = !steps && f?.main.grows === true;
2760
+ const holds2 = !steps && f?.main.grows === true;
2735
2761
  const be = b.edge === a.edge && !b.inMenu ? base.edges[b.edge] : void 0;
2736
2762
  const had = be ? axisOf(be.side) === "column" ? b.rect.height : b.rect.width : Infinity;
2737
- if (f && len2 < Math.min(formMain2(f, holds ? "natural" : "min", e.cross), had) - 0.5) return false;
2763
+ if (f && len2 < Math.min(formMain2(f, holds2 ? "natural" : "min", e.cross), had) - 0.5) return false;
2738
2764
  }
2739
2765
  const me = after.items[dragged];
2740
2766
  if (!me) return true;
@@ -3583,7 +3609,7 @@ function collapsesAt(c, result, side) {
3583
3609
  }
3584
3610
  function columnLines(c, side, railLands) {
3585
3611
  const { state, now, dragged } = c;
3586
- if (state.sideColumns === "one" && c.rest.edges.some((e) => e.side === side && isSideColumn(c.rest, e) && (e.items.length > 0 || e.column !== true))) return [];
3612
+ if (!columnRoom(c.rest, side)) return [];
3587
3613
  const cols = state.edges.filter((e) => e.side === side && e.column === true).map((edge) => ({ edge, l: now.edges[edge.id] })).filter((x) => x.l && !x.l.folded && !x.l.rides && x.l.cross > 0).sort((a, b) => a.edge.ring - b.edge.ring).map((x) => ({ edge: x.edge, r: x.l.rect }));
3588
3614
  const own = Object.values(now.edges).filter((e) => e.side === side && e.rect.height > 0);
3589
3615
  const span = own[0]?.rect ?? now.content;
@@ -3724,6 +3750,7 @@ function railStops(c, side) {
3724
3750
  const arriving = state.foldedColumnDrop === "end" && !ownRail;
3725
3751
  const end = arriving && shown ? railEnd(c, side, railColumns(c, side), rail.menu ? rail.menu.rect.y : at.y + at.height) : null;
3726
3752
  if (arriving && (shown ? !end : !isHandFolded(state, dragged))) return null;
3753
+ if (!end && !ownRail && !columnRoom(c.rest, side)) return null;
3727
3754
  const width = state.rails?.[side]?.width;
3728
3755
  const tooThick = width !== void 0 && thickerThan(formsOf(state.items[dragged], "column"), width);
3729
3756
  return {
@@ -5212,6 +5239,7 @@ export {
5212
5239
  isOutsideSideBar,
5213
5240
  isSideBar,
5214
5241
  isSideColumn,
5242
+ sideColumnCap,
5215
5243
  floatOrientOf,
5216
5244
  declaresFloatSizes,
5217
5245
  floatSizeOf,
@@ -5256,4 +5284,4 @@ export {
5256
5284
  HATCH_EDGE,
5257
5285
  dockDrag
5258
5286
  };
5259
- //# sourceMappingURL=chunk-367B5WJT.js.map
5287
+ //# sourceMappingURL=chunk-NPBJJJWS.js.map