@n-uf/docking 26.12.11 → 26.12.12

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,30 @@ 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.12
11
+
12
+ - **`DockState.sideColumns` is a count** (additive): `sideColumns?: number | "one"`, the most columns a side may
13
+ hold, and a side never gains a column past it. One function reads it, the new export
14
+ **`sideColumnCap(state)`** (`Infinity` for no cap): absent or `Infinity`, no cap; a whole number of 1 or more,
15
+ itself; any other number rounded down, never below 1; not a number, 1; nothing throws. A drag offers a new-column
16
+ line on a side exactly when the side would hold fewer columns than its cap with the dragged item dropped on another
17
+ side (folded columns and declared column edges, empty or not, count; a column the lift empties does not, unless
18
+ declared). On a full side a rail stop is offered only where it puts the item into a column that exists, and no
19
+ change function makes a column past the cap: `moveTo` with a column or rail place there, and so `dockHome`, change
20
+ nothing, and `setSide` moves no column onto it. A state that declares nothing gets the targets it had.
21
+ - **`"one"` is deprecated:** it reads as 1. Declare `1`; `"one"` is removed in the first breaking release after hosts
22
+ declare a number.
23
+ - **Changed (behavior) under `"one"`:** a side that keeps a column now takes no second one from anything. A rail
24
+ stop that would make a second, folded column there is no longer offered (26.12.11 offered it: the one way a side
25
+ under `"one"` ended with two columns). And `moveTo` with a column or rail place, `dockHome` (whose home may be a
26
+ column that is gone) and `setSide` (moving a column there) now change nothing on such a side, where 26.12.11 did
27
+ not cap them. From a state within the cap, every other target is as before.
28
+ - **`mergeSideColumns(state, max?)`** (additive): each side's columns past `max` merge into its `max`-th column (by
29
+ ring), which keeps its id and options and takes the inner columns' items after its own, by ring; the `max − 1`
30
+ 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
31
+ that declares a cap of 2 keeps its stored two-column layouts. With `max` 1 it is the function it was. It changes no
32
+ item's `used` or `kept`. Lowering the cap merges nothing: a host that lowers it calls the merge.
33
+
10
34
  ## 26.12.11
11
35
 
12
36
  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;
@@ -1175,7 +1188,7 @@ function giveWay(d, cols, area9, gutter) {
1175
1188
  }
1176
1189
  return evaluate(auto);
1177
1190
  }
1178
- function columnRoom(d, cols, area9, f) {
1191
+ function columnRoom2(d, cols, area9, f) {
1179
1192
  const { state } = d;
1180
1193
  const cmin = state.contentMin ? px(state.contentMin.width) : void 0;
1181
1194
  const openMin = (ids, least) => Math.max(
@@ -1332,7 +1345,7 @@ function laySides(d, sideEdges, area9, f) {
1332
1345
  const tall = (edge) => H + (edge.outsideInset === true ? reach.up + reach.down : 0);
1333
1346
  const cols = columnsOf(d, sideEdges, area9, tall);
1334
1347
  const g = giveWay(d, cols, area9, f.gutter);
1335
- columnRoom(d, cols, area9, f);
1348
+ columnRoom2(d, cols, area9, f);
1336
1349
  giveWayNotes(d, g, cols);
1337
1350
  const walk = { x0: area9.x, x1: area9.x + area9.width };
1338
1351
  for (const side of ["left", "right"]) laySide(d, side, cols, g, area9, f, walk, reach.up, tall);
@@ -1462,8 +1475,8 @@ function layOut(given, options, caps, gave) {
1462
1475
  contentNotes(d, content);
1463
1476
  const keepClear = resolveKeepClear(state, content);
1464
1477
  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 };
1478
+ const { items, edges, rails, railPlaces, columnRoom: columnRoom3, notes } = d;
1479
+ return { items, edges, content, floats, rails, railPlaces, ...columnRoom3 !== void 0 ? { columnRoom: columnRoom3 } : {}, ...keepClear ? { keepClear } : {}, notes };
1467
1480
  }
1468
1481
 
1469
1482
  // src/dividers.ts
@@ -1646,13 +1659,16 @@ function prune(state) {
1646
1659
  const sides = new Set(gone.map((e) => e.side));
1647
1660
  return { ...state, edges: closeRings(state.edges.filter((e) => !gone.includes(e)), sides) };
1648
1661
  }
1649
- function mergeSideColumns(state) {
1662
+ function mergeSideColumns(state, max) {
1663
+ const declared = sideColumnCap(state);
1664
+ const cap = max === void 0 ? declared === Infinity ? 1 : declared : capOf(max);
1650
1665
  let edges = [...state.edges];
1651
1666
  const sides = /* @__PURE__ */ new Set();
1652
1667
  for (const side of ["left", "right"]) {
1653
1668
  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;
1669
+ if (cols.length <= cap) continue;
1670
+ const keep = cols[cap - 1];
1671
+ const rest = cols.slice(cap);
1656
1672
  const merged = { ...keep, items: [...keep.items, ...rest.flatMap((e) => e.items)] };
1657
1673
  edges = edges.filter((e) => !rest.includes(e)).map((e) => e === keep ? merged : e);
1658
1674
  sides.add(side);
@@ -1717,6 +1733,7 @@ function columnFloor(edges, side) {
1717
1733
  return n;
1718
1734
  }
1719
1735
  function insertColumn(state0, id, side, ring, others) {
1736
+ if (!columnRoom(state0, side)) return null;
1720
1737
  const state = { ...state0, edges: closeRings(state0.edges, /* @__PURE__ */ new Set([side])) };
1721
1738
  const kind = state.items[id].kind;
1722
1739
  const mine = state.edges.filter((e) => e.side === side);
@@ -1916,7 +1933,9 @@ function setSide(state, edgeId, side) {
1916
1933
  if (!edge || edge.side === side || axisOf(edge.side) !== axisOf(side)) return state;
1917
1934
  const moved = { ...edge, side, ring: 0 };
1918
1935
  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])) };
1936
+ const after = { ...state, edges: closeRings([moved, ...others], /* @__PURE__ */ new Set([edge.side, side])) };
1937
+ if ((side === "left" || side === "right") && sideColumnCount(after, side) > sideColumnCount(state, side) && !columnRoom(state, side)) return state;
1938
+ return after;
1920
1939
  }
1921
1940
  function homeFor(state, id, start) {
1922
1941
  for (const e of start.edges) {
@@ -3583,7 +3602,7 @@ function collapsesAt(c, result, side) {
3583
3602
  }
3584
3603
  function columnLines(c, side, railLands) {
3585
3604
  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 [];
3605
+ if (!columnRoom(c.rest, side)) return [];
3587
3606
  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
3607
  const own = Object.values(now.edges).filter((e) => e.side === side && e.rect.height > 0);
3589
3608
  const span = own[0]?.rect ?? now.content;
@@ -3724,6 +3743,7 @@ function railStops(c, side) {
3724
3743
  const arriving = state.foldedColumnDrop === "end" && !ownRail;
3725
3744
  const end = arriving && shown ? railEnd(c, side, railColumns(c, side), rail.menu ? rail.menu.rect.y : at.y + at.height) : null;
3726
3745
  if (arriving && (shown ? !end : !isHandFolded(state, dragged))) return null;
3746
+ if (!end && !ownRail && !columnRoom(c.rest, side)) return null;
3727
3747
  const width = state.rails?.[side]?.width;
3728
3748
  const tooThick = width !== void 0 && thickerThan(formsOf(state.items[dragged], "column"), width);
3729
3749
  return {
@@ -5212,6 +5232,7 @@ export {
5212
5232
  isOutsideSideBar,
5213
5233
  isSideBar,
5214
5234
  isSideColumn,
5235
+ sideColumnCap,
5215
5236
  floatOrientOf,
5216
5237
  declaresFloatSizes,
5217
5238
  floatSizeOf,
@@ -5256,4 +5277,4 @@ export {
5256
5277
  HATCH_EDGE,
5257
5278
  dockDrag
5258
5279
  };
5259
- //# sourceMappingURL=chunk-367B5WJT.js.map
5280
+ //# sourceMappingURL=chunk-NYMM2UDJ.js.map