@n-uf/docking 26.12.12 → 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,21 @@ 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
+
10
25
  ## 26.12.12
11
26
 
12
27
  - **`DockState.sideColumns` is a count** (additive): `sideColumns?: number | "one"`, the most columns a side may
@@ -383,6 +383,7 @@ import { formCrossMin, formSetsCross } from "@n-uf/placement/stack";
383
383
  var finite = (x, fallback) => typeof x === "number" && Number.isFinite(x) ? x : fallback;
384
384
  var px = (x) => Math.max(0, finite(x, 0));
385
385
  var isSide = (e) => e.side === "left" || e.side === "right";
386
+ var holds = (state, ids, test) => ids.some((id) => test(state.items[id], id));
386
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);
387
388
  function cutOrder(edges) {
388
389
  const phase = (e) => e.side === "left" || e.side === "right" ? 1 : e.span === "between" ? 2 : 0;
@@ -1103,6 +1104,7 @@ import { formCrossMin as formCrossMin3, formMenu as formMenu5, formSetsCross as
1103
1104
  var isChrome = (state, c) => !c.dyn && isSideBar(state, c.edge);
1104
1105
  function columnsOf(d, sideEdges, area9, tall) {
1105
1106
  const { state } = d;
1107
+ const declared = new Set(Array.isArray(state.givesWayLast) ? state.givesWayLast.filter((id) => typeof id === "string") : []);
1106
1108
  return sideEdges.map((edge) => {
1107
1109
  const side = edge.side;
1108
1110
  const solved = solveEdge(state, edge, d.owned.get(edge), tall(edge), Math.max(0, area9.width), d.prevEdge(edge));
@@ -1121,7 +1123,8 @@ function columnsOf(d, sideEdges, area9, tall) {
1121
1123
  visible,
1122
1124
  dyn,
1123
1125
  hand: dyn && edge.column === true && visible.every((id) => startOf(state.items[id], formsOf(state.items[id], "column")) > 0),
1124
- 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)),
1125
1128
  age: Math.max(-Infinity, ...visible.map((id) => finite(state.items[id].used, 0)))
1126
1129
  };
1127
1130
  });
@@ -1134,7 +1137,8 @@ function giveWay(d, cols, area9, gutter) {
1134
1137
  const floor = cmin !== void 0 && typeof chromeWidth === "number" && Number.isFinite(chromeWidth) ? Math.min(cmin, px(chromeWidth)) : void 0;
1135
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);
1136
1139
  if (floor !== void 0) d.chromeAllowance = Math.min(chrome, cmin - floor);
1137
- 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));
1138
1142
  const shrunkBefore = (previous?.notes ?? []).flatMap((n) => n.code === "column-shrunk" ? [n.edge] : []);
1139
1143
  const rankOf = (c) => shrunkBefore.includes(c.edge.id) ? shrunkBefore.indexOf(c.edge.id) : Infinity;
1140
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);
@@ -1149,8 +1153,10 @@ function giveWay(d, cols, area9, gutter) {
1149
1153
  for (const [c, w] of widths) used += w > 0 ? w + (c.edge.outsideInset === true ? 0 : gutter) : 0;
1150
1154
  for (const s of railSides) used += railW(s) + gutter;
1151
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);
1152
1157
  for (const c of shrinkOrder) {
1153
1158
  if (excess <= EPS7) break;
1159
+ if (tierOpen && c.last) continue;
1154
1160
  const w = widths.get(c);
1155
1161
  if (w === void 0) continue;
1156
1162
  const take = Math.min(excess, w - c.min);
@@ -1174,7 +1180,8 @@ function giveWay(d, cols, area9, gutter) {
1174
1180
  const byId = new Map(foldOrder.map((c) => [c.edge.id, c]));
1175
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));
1176
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)] : []);
1177
- 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)]);
1178
1185
  if (evaluate(auto).excess <= EPS7) unfold();
1179
1186
  }
1180
1187
  for (const c of foldOrder) {
@@ -2750,10 +2757,10 @@ function soundness(state, base, dragged) {
2750
2757
  if (a.inMenu) continue;
2751
2758
  const f = formsOf(state.items[id], axisOf(e.side))[a.form];
2752
2759
  const len2 = axisOf(e.side) === "column" ? a.rect.height : a.rect.width;
2753
- const holds = !steps && f?.main.grows === true;
2760
+ const holds2 = !steps && f?.main.grows === true;
2754
2761
  const be = b.edge === a.edge && !b.inMenu ? base.edges[b.edge] : void 0;
2755
2762
  const had = be ? axisOf(be.side) === "column" ? b.rect.height : b.rect.width : Infinity;
2756
- 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;
2757
2764
  }
2758
2765
  const me = after.items[dragged];
2759
2766
  if (!me) return true;
@@ -5277,4 +5284,4 @@ export {
5277
5284
  HATCH_EDGE,
5278
5285
  dockDrag
5279
5286
  };
5280
- //# sourceMappingURL=chunk-NYMM2UDJ.js.map
5287
+ //# sourceMappingURL=chunk-NPBJJJWS.js.map