@n-uf/docking 26.12.0 → 26.12.2

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,36 @@ 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.2
11
+
12
+ - **Changed (breaking, behavior): an item lifted from a bar's » is held at its last drawn form.** Lifting from any »
13
+ (a bar's, a column's or a rail's) now holds the item at the nearest form at or before its `form` that isn't a menu
14
+ form: its least length (a movable grower on a bar, its natural), as thick across as the » entry. It was held at the
15
+ entry's size. An item with no such form is still held at the entry's size.
16
+ - **Added: a rail's ».** Tiles that don't fit in a rail go into a » at the rail's end, by the same give-way as a bar's
17
+ items, in both rail modes and for both kinds of rail (a side's rail strip and a column drawn as a rail). The tile that
18
+ gives way first goes in first: the lowest rank, then unkept before kept, then the item used longest ago; room that
19
+ comes back brings tiles out in exact reverse. In icons mode a side's rail used to run its tiles past its end; it now
20
+ fits them. A pin or a priority moves its own item and nothing else. A rail member's host form with a negative `rank`
21
+ is refused (`solve` throws a `RangeError`): a rank is its base, 0 or more, plus `RANK_LEVEL` per pin level.
22
+ - **Added: `RailSpec.menu`** (`{ main }`), the size of a side's rail's » entry.
23
+ - **Changed (breaking, type and behavior): `DockRailLayout.segments` lists only the drawn tiles.** A new
24
+ `DockRailLayout.menu` is `{ rect, items }` (the entry and the ids in the », in order) or null; a member is in one or
25
+ the other, never both. An item in a rail's » reports `inMenu: true`, its tile as its `form` and `formKind: "rail"`.
26
+ - **Changed (breaking, type only): `DockRailLayout.stack` is required.** A host that builds a `DockRailLayout` by hand
27
+ (a test fixture) passes the rail's `StackFit`.
28
+ - **Changed (behavior): a panel in a column drawn as a rail goes into the column's » at its tile.** Its `form` is its
29
+ tile and its `formKind` is `"rail"`, never its own menu form; panel tiles go into the » before the column's
30
+ toolbars, after their fold.
31
+ - **Changed (behavior): drops at a rail with a ».** The rail's last stop lies after the last drawn tile and is last in
32
+ ring order (after a column wholly in the » too); a drop over the » takes it and lands drawn. Under
33
+ `foldedColumnDrop: "end"` the rail's one place has its line at the entry's start. A home drop changes nothing, the use
34
+ order included. A drop never adds to a rail's overflow.
35
+
36
+ ## 26.12.1
37
+
38
+ No changes in `@n-uf/docking`. Released in step with `@n-uf/motion` and `@n-uf/placement`, which share the version.
39
+
10
40
  ## 26.12.0
11
41
 
12
42
  - **Changed (breaking, behavior):** drop targets: a drop is refused when it makes an edge overflow by more than it did with the item lifted (an edge that
@@ -634,17 +634,20 @@ function emit(d, edge, r, solved, extra = {}) {
634
634
  const it = state.items[p.id];
635
635
  const inMenu = !!stack.menu?.items.includes(p.id);
636
636
  const drawnRect2 = toStage(p.rect, inMenu ? void 0 : p.id);
637
- const f = formsOf(it, column ? "column" : "row")[p.form];
637
+ const tile = solved.railTiles?.get(p.id);
638
+ const past = tile !== void 0 && p.form > tile;
639
+ const form = past ? tile : p.form;
640
+ const f = formsOf(it, column ? "column" : "row")[form];
638
641
  const shape = inMenu ? {} : shapeOf(f, drawnRect2, column ? "column" : "row", stack.cross);
639
- const foldedBy = foldedByOf(it, formsOf(it, column ? "column" : "row"), p.form, solved.starts.get(p.id), edge);
642
+ const foldedBy = foldedByOf(it, formsOf(it, column ? "column" : "row"), form, solved.starts.get(p.id), edge);
640
643
  items[p.id] = {
641
644
  ...shape,
642
645
  ...controlsOf(inMenu ? void 0 : f),
643
646
  rect: drawnRect2,
644
647
  kind: it.kind,
645
648
  axis: column ? "column" : "row",
646
- form: p.form,
647
- formKind: p.kind,
649
+ form,
650
+ formKind: past ? "rail" : p.kind,
648
651
  edge: edge.id,
649
652
  zone: zoneOf(it),
650
653
  ...inMenu ? { inMenu: true } : {},
@@ -673,7 +676,24 @@ function emit(d, edge, r, solved, extra = {}) {
673
676
 
674
677
  // src/solve/edge.ts
675
678
  import { EPS as EPS3 } from "@n-uf/placement";
676
- import { fitStack, formCompact, formCrossMin as formCrossMin2, formMenu as formMenu3, formSetsCross as formSetsCross2, itemSteps as itemSteps2 } from "@n-uf/placement/stack";
679
+ import { fitStack, formCompact, formCrossMin as formCrossMin2, formMenu as formMenu4, formSetsCross as formSetsCross2, itemSteps as itemSteps2 } from "@n-uf/placement/stack";
680
+
681
+ // src/solve/rail-menu.ts
682
+ import { RANK_LEVEL, formMenu as formMenu3 } from "@n-uf/placement/stack";
683
+ var withinLevel = (rank) => {
684
+ const r = finite(rank ?? 0, 0);
685
+ if (r < 0) throw new RangeError(`a rail member's form has rank ${r}: a host form's rank is 0 or more (its base, plus RANK_LEVEL per pin level)`);
686
+ return r % RANK_LEVEL;
687
+ };
688
+ function railMenuRank(forms) {
689
+ let top = 0;
690
+ for (const list of forms) for (const f of list) if (!formMenu3(f)) top = Math.max(top, withinLevel(f.rank));
691
+ return top + 1;
692
+ }
693
+ var railMenuForm = (rank) => ({ kind: "menu", main: { min: 0, natural: 0 }, cross: { natural: 0 }, rank });
694
+ var tileFrom = (forms, from) => forms.findIndex((f, k) => k >= from && f.kind === "rail" && f.title !== true);
695
+
696
+ // src/solve/edge.ts
677
697
  var stackItemOf = (item, forms, edge, from) => ({
678
698
  id: item.id,
679
699
  forms,
@@ -687,8 +707,11 @@ var stackItemOf = (item, forms, edge, from) => ({
687
707
  });
688
708
  var inputs = /* @__PURE__ */ new WeakMap();
689
709
  var inputOf = (stack) => inputs.get(stack);
710
+ var keepInput = (fit, input) => {
711
+ inputs.set(fit, input);
712
+ };
690
713
  function hasSetter(fit, forms) {
691
- return fit.items.some((p) => !formMenu3(forms(p.id)[p.form]) && formSetsCross2(forms(p.id)[p.form]));
714
+ return fit.items.some((p) => !formMenu4(forms(p.id)[p.form]) && formSetsCross2(forms(p.id)[p.form]));
692
715
  }
693
716
  var TRAY_RANK = 100;
694
717
  var startsOf = (input) => new Map(input.items.map((i) => [i.id, i.from ?? 0]));
@@ -721,6 +744,19 @@ function railEdge(f, free, asStackItem, starts) {
721
744
  const leftOut = f.ordered.filter((id) => !state.items[id].closed && wrapOnly(id));
722
745
  const anyRail = shown.some((id) => railIndex(state.items[id], formsById(id)) >= 0);
723
746
  if (!anyRail) return null;
747
+ const offered = (id) => {
748
+ const p = f.priorityOf(id);
749
+ const forms = asStackItem(id).forms;
750
+ return p === 0 ? forms : forms.map((x) => ({ ...x, rank: finite(x.rank ?? 0, 0) - p }));
751
+ };
752
+ const railTiles = /* @__PURE__ */ new Map();
753
+ for (const id of shown) {
754
+ const j = railIndex(state.items[id], formsById(id));
755
+ if (j < 0) continue;
756
+ const t = tileFrom(formsById(id), j);
757
+ railTiles.set(id, t >= 0 ? t : j);
758
+ }
759
+ const menuRank = railMenuRank(shown.map((id) => railTiles.has(id) ? offered(id).slice(0, railTiles.get(id) + 1) : offered(id)));
724
760
  const railInput = {
725
761
  ...f.base,
726
762
  // The side's rail mode: a title rail form is offered only while the side shows titles.
@@ -729,13 +765,15 @@ function railEdge(f, free, asStackItem, starts) {
729
765
  const it = state.items[id];
730
766
  const j = railIndex(it, formsById(id));
731
767
  const forms = asStackItem(id).forms;
732
- return stackItemOf(it, forms, edge, j >= 0 ? j : pastWrap(forms, startOf(it, forms, edge)));
768
+ if (j < 0) return stackItemOf(it, forms, edge, pastWrap(forms, startOf(it, forms, edge)));
769
+ const tile = railTiles.get(id);
770
+ return stackItemOf(it, [...forms.slice(0, tile + 1), railMenuForm(menuRank + f.priorityOf(id))], edge, j);
733
771
  })
734
772
  };
735
773
  const stack = fitStack(railInput, f.previous ? { previous: f.previous.stack } : {});
736
774
  const tabs = stack.items.filter((p) => p.kind === "rail").map((p) => p.id);
737
775
  const closedTabs = new Set(shown.filter((id) => state.items[id].closed));
738
- return { stack, free, tabs, closedTabs, input: railInput, starts, leftOut };
776
+ return { stack, free, tabs, closedTabs, input: railInput, starts, leftOut, railTiles };
739
777
  }
740
778
  function solveEdge(state, edge, ids, length, room, previous) {
741
779
  const solved = solveEdgeStack(state, edge, ids, length, room, previous);
@@ -763,7 +801,7 @@ function solveEdgeStack(state, edge, ids, length, room, previous) {
763
801
  ...edge.pad ? { pad: edge.pad } : {},
764
802
  ...column ? { ownCross: true } : {}
765
803
  };
766
- const frame = { state, edge, column, ordered, formsById, base, previous };
804
+ const frame = { state, edge, column, ordered, formsById, priorityOf, base, previous };
767
805
  if (edge.compact) return compactEdge(frame);
768
806
  const open = ordered.filter((id) => !state.items[id].closed);
769
807
  const asStackItem = (id) => {
@@ -794,7 +832,7 @@ function solveEdgeStack(state, edge, ids, length, room, previous) {
794
832
  const items = input.items.map((it) => {
795
833
  const from = it.from ?? 0;
796
834
  if (!itemSteps2(it) || fits(it.forms[from])) return it;
797
- const j = it.forms.findIndex((f, k) => k > from && !formMenu3(f) && fits(f));
835
+ const j = it.forms.findIndex((f, k) => k > from && !formMenu4(f) && fits(f));
798
836
  if (j < 0) return it;
799
837
  moved = true;
800
838
  return { ...it, from: j };
@@ -806,7 +844,7 @@ function solveEdgeStack(state, edge, ids, length, room, previous) {
806
844
  }
807
845
  const size = edge.size;
808
846
  if (typeof size === "number" && Number.isFinite(size) && hasSetter(free, formsById)) {
809
- const setters = free.items.filter((p) => !formMenu3(formsById(p.id)[p.form]) && formSetsCross2(formsById(p.id)[p.form]));
847
+ const setters = free.items.filter((p) => !formMenu4(formsById(p.id)[p.form]) && formSetsCross2(formsById(p.id)[p.form]));
810
848
  const lo2 = Math.max(px(edge.cross.min), ...setters.map((p) => formCrossMin2(formsById(p.id)[p.form])));
811
849
  const s = Math.min(Math.max(size, lo2), Math.max(lo2, maxOf), room);
812
850
  if (Math.abs(s - free.cross) > EPS3) {
@@ -1049,7 +1087,7 @@ import { EPS as EPS8, rect as rect6 } from "@n-uf/placement";
1049
1087
 
1050
1088
  // src/solve/columns.ts
1051
1089
  import { EPS as EPS7 } from "@n-uf/placement";
1052
- import { formCrossMin as formCrossMin3, formMenu as formMenu4, formSetsCross as formSetsCross3 } from "@n-uf/placement/stack";
1090
+ import { formCrossMin as formCrossMin3, formMenu as formMenu5, formSetsCross as formSetsCross3 } from "@n-uf/placement/stack";
1053
1091
  var isChrome = (state, c) => !c.dyn && isSideBar(state, c.edge);
1054
1092
  function columnsOf(d, sideEdges, area9, tall) {
1055
1093
  const { state } = d;
@@ -1060,7 +1098,7 @@ function columnsOf(d, sideEdges, area9, tall) {
1060
1098
  const visible = d.owned.get(edge).filter((id) => !state.items[id].closed);
1061
1099
  const dyn = (edge.column === true || edge.giveWay === true) && state.rails?.[side] !== void 0 && visible.length > 0;
1062
1100
  const forms = (id) => formsOf(state.items[id], "column");
1063
- const setters = solved.free.items.filter((p) => !formMenu4(forms(p.id)[p.form]) && formSetsCross3(forms(p.id)[p.form]));
1101
+ const setters = solved.free.items.filter((p) => !formMenu5(forms(p.id)[p.form]) && formSetsCross3(forms(p.id)[p.form]));
1064
1102
  const min = setters.length > 0 ? Math.min(width, Math.max(px(edge.cross.min), ...setters.map((p) => formCrossMin3(forms(p.id)[p.form])))) : width;
1065
1103
  return {
1066
1104
  edge,
@@ -1224,45 +1262,67 @@ function layRail(d, side, railRect, railed, g) {
1224
1262
  const segments = [];
1225
1263
  const members = railed.flatMap((c) => zoneSorted(state, c.visible).map((id) => ({ id, c })));
1226
1264
  const formsById = (id) => formsOf(state.items[id], "column");
1227
- const tileOf = (id) => formsById(id).findIndex((f) => f.kind === "rail" && f.title !== true);
1265
+ const tileOf = (id) => tileFrom(formsById(id), 0);
1228
1266
  const titleOf = (id) => {
1229
1267
  const t = tileOf(id);
1230
1268
  return t > 0 && formsById(id)[t - 1].kind === "rail" && formsById(id)[t - 1].title === true ? t - 1 : -1;
1231
1269
  };
1232
1270
  const titles = railModeOf(state, side) === "titles" && members.some((m) => titleOf(m.id) >= 0) && members.every((m) => tileOf(m.id) >= 0);
1233
- let fit;
1234
- if (titles) {
1235
- const input = {
1236
- axis: "column",
1237
- length: railRect.height,
1238
- cross: { min: railRect.width, max: railRect.width, rail: railRect.width },
1239
- titles: true,
1240
- items: members.map(({ id }) => {
1241
- const it = state.items[id];
1242
- const p = finite(it.priority ?? 0, 0);
1243
- const forms = formsById(id).slice(0, tileOf(id) + 1).map((f) => p === 0 ? f : { ...f, rank: finite(f.rank ?? 0, 0) + p });
1244
- return { id, forms, used: finite(it.used, 0), ...it.kept ? { kept: true } : {}, from: titleOf(id) >= 0 ? titleOf(id) : tileOf(id) };
1245
- })
1246
- };
1247
- const fresh = members.some((m) => d.fresh.has(m.id) || d.fresh.has(m.c.edge.id));
1248
- const previous = d.previous && !fresh ? d.previous.rails[side]?.stack : void 0;
1249
- fit = fitStack2(input, previous ? { previous } : {});
1250
- }
1251
- const placed = new Map(fit?.items.map((p) => [p.id, p]) ?? []);
1252
- let y = railRect.y;
1271
+ const w = railRect.width;
1272
+ const square = { kind: "rail", main: { min: w, natural: w }, cross: { natural: w } };
1273
+ const own = (id) => tileOf(id) >= 0 ? formsById(id).slice(0, tileOf(id) + 1) : [square];
1274
+ const menuRank = railMenuRank(members.map((m) => own(m.id)));
1275
+ const spec = state.rails?.[side];
1276
+ const input = {
1277
+ axis: "column",
1278
+ length: railRect.height,
1279
+ cross: { min: w, max: w, rail: w },
1280
+ ...titles ? { titles: true } : {},
1281
+ ...spec?.menu ? { menu: spec.menu } : {},
1282
+ items: members.map(({ id }) => {
1283
+ const it = state.items[id];
1284
+ const p = finite(it.priority ?? 0, 0);
1285
+ const forms = [...own(id), railMenuForm(menuRank)].map((f) => p === 0 ? f : { ...f, rank: finite(f.rank ?? 0, 0) + p });
1286
+ const t = tileOf(id);
1287
+ const from = t < 0 ? 0 : titles && titleOf(id) >= 0 ? titleOf(id) : t;
1288
+ return { id, forms, used: finite(it.used, 0), ...it.kept ? { kept: true } : {}, from };
1289
+ })
1290
+ };
1291
+ const fresh = members.some((m) => d.fresh.has(m.id) || d.fresh.has(m.c.edge.id));
1292
+ const previous = d.previous && !fresh ? d.previous.rails[side]?.stack : void 0;
1293
+ const fit = fitStack2(input, previous ? { previous } : {});
1294
+ keepInput(fit, input);
1295
+ const toStage = (r) => rect5(railRect.x, railRect.y + r.y, w, r.height);
1296
+ const menuRect = fit.menu ? toStage(fit.menu.rect) : null;
1297
+ const inMenu = new Set(fit.menu?.items ?? []);
1298
+ const placed = new Map(fit.items.map((p) => [p.id, p]));
1253
1299
  for (const { id, c } of members) {
1254
1300
  const it = state.items[id];
1255
1301
  const forms = formsById(id);
1256
- const ri = tileOf(id);
1302
+ const t = tileOf(id);
1257
1303
  const p = placed.get(id);
1258
- const form = p ? p.form : ri >= 0 ? ri : forms.length === 0 ? 0 : startOf(it, forms);
1259
- const at = p ? rect5(railRect.x, railRect.y + p.rect.y, railRect.width, p.rect.height) : rect5(railRect.x, y, railRect.width, ri >= 0 ? px(forms[ri].main.natural) : railRect.width);
1260
- const title = forms[form]?.title === true;
1261
- items[id] = { rect: at, ...controlsOf(forms[form]), kind: it.kind, axis: "column", form, formKind: "rail", edge: c.edge.id, zone: zoneOf(it), rail: side, ...title ? { railTitle: side } : {}, folded: g.auto.has(c) ? "auto" : "hand", foldedBy: startOf(it, forms) > 0 ? "hand" : "auto" };
1262
- segments.push({ id, edge: c.edge.id, rect: at });
1263
- y += at.height;
1304
+ const menu = inMenu.has(id) && menuRect !== null;
1305
+ const form = t < 0 ? forms.length === 0 ? 0 : startOf(it, forms) : menu ? t : p.form;
1306
+ const at = menu ? menuRect : toStage(p.rect);
1307
+ const title = !menu && forms[form]?.title === true;
1308
+ items[id] = {
1309
+ rect: at,
1310
+ ...controlsOf(menu ? void 0 : forms[form]),
1311
+ kind: it.kind,
1312
+ axis: "column",
1313
+ form,
1314
+ formKind: "rail",
1315
+ edge: c.edge.id,
1316
+ zone: zoneOf(it),
1317
+ ...menu ? { inMenu: true } : {},
1318
+ rail: side,
1319
+ ...title ? { railTitle: side } : {},
1320
+ folded: g.auto.has(c) ? "auto" : "hand",
1321
+ foldedBy: startOf(it, forms) > 0 ? "hand" : "auto"
1322
+ };
1323
+ if (!menu) segments.push({ id, edge: c.edge.id, rect: at });
1264
1324
  }
1265
- d.rails[side] = { rect: railRect, segments, ...fit ? { stack: fit } : {} };
1325
+ d.rails[side] = { rect: railRect, segments, menu: menuRect ? { rect: menuRect, items: fit.menu.items } : null, stack: fit };
1266
1326
  }
1267
1327
 
1268
1328
  // src/solve/sides.ts
@@ -2371,7 +2431,7 @@ function anchorTargets(state, dragged, options) {
2371
2431
 
2372
2432
  // src/targets/edges.ts
2373
2433
  import { EPS as EPS14, area as area2, rect as rect11 } from "@n-uf/placement";
2374
- import { formCrossMin as formCrossMin4, formMenu as formMenu5, formSetsCross as formSetsCross4, itemSteps as itemSteps3 } from "@n-uf/placement/stack";
2434
+ import { formCrossMin as formCrossMin4, formMenu as formMenu6, formSetsCross as formSetsCross4, itemSteps as itemSteps3 } from "@n-uf/placement/stack";
2375
2435
 
2376
2436
  // src/targets/kinds.ts
2377
2437
  var COLUMN_REACH = 22;
@@ -2553,7 +2613,7 @@ function edgeSlots(c, edge, accepts) {
2553
2613
  return slots;
2554
2614
  }
2555
2615
  function thickerThan(forms, cross) {
2556
- const shown = forms.filter((f) => !formMenu5(f));
2616
+ const shown = forms.filter((f) => !formMenu6(f));
2557
2617
  return shown.length > 0 && shown.every((f) => !formSetsCross4(f) && formCrossMin4(f) > cross + EPS14);
2558
2618
  }
2559
2619
  var roomReason = (spec, zone) => spec.refuse(zone) === "too-thick" ? "too-thick" : "no-room";
@@ -2633,7 +2693,7 @@ function railColumnSpec(c, edge, run) {
2633
2693
 
2634
2694
  // src/targets/filter.ts
2635
2695
  import { EPS as EPS15, overlaps as overlaps2 } from "@n-uf/placement";
2636
- import { formMain as formMain2, itemSteps as itemSteps4 } from "@n-uf/placement/stack";
2696
+ import { formMain as formMain2, formMenu as formMenu7, itemSteps as itemSteps4 } from "@n-uf/placement/stack";
2637
2697
  function placeKey(s, id) {
2638
2698
  const it = Object.hasOwn(s.items, id) ? s.items[id] : void 0;
2639
2699
  const byZone = (items) => ZONES.flatMap((z) => items.filter((x) => zoneOf(s.items[x]) === z));
@@ -2650,6 +2710,7 @@ function soundness(state, base, dragged) {
2650
2710
  const overOf = (l) => {
2651
2711
  const m = /* @__PURE__ */ new Map();
2652
2712
  for (const n of l.notes) if ("edge" in n && n.code === "overflow") m.set(n.edge, (m.get(n.edge) ?? 0) + n.over);
2713
+ for (const side of ["left", "right"]) for (const n of l.rails[side]?.stack.notes ?? []) if (n.code === "overflow") m.set(`rail:${side}`, (m.get(`rail:${side}`) ?? 0) + n.over);
2653
2714
  return m;
2654
2715
  };
2655
2716
  const overBefore = overOf(base);
@@ -2693,6 +2754,7 @@ function liftIn(state, now, dragged, prev) {
2693
2754
  }
2694
2755
  function heldRect2(state, l, dragged) {
2695
2756
  const laid2 = l.items[dragged];
2757
+ if (laid2?.inMenu) return heldInMenu(state, l, dragged, laid2);
2696
2758
  const edge = laid2?.edge && !laid2.inMenu && !laid2.floating ? state.edges.find((x) => x.id === laid2.edge) : void 0;
2697
2759
  const e = edge ? l.edges[edge.id] : void 0;
2698
2760
  const f = e ? formsOf(state.items[dragged], axisOf(e.side))[laid2.form] : void 0;
@@ -2703,6 +2765,16 @@ function heldRect2(state, l, dragged) {
2703
2765
  const held = Math.max(least, growsOnBar(state, edge, dragged, laid2.form) ? formMain2(f, "natural", e.cross) : least);
2704
2766
  return column ? { ...laid2.rect, height: held } : { ...laid2.rect, width: held };
2705
2767
  }
2768
+ function heldInMenu(state, l, dragged, laid2) {
2769
+ const forms = formsOf(state.items[dragged], laid2.axis);
2770
+ let j = Math.min(laid2.form, forms.length - 1);
2771
+ while (j >= 0 && formMenu7(forms[j])) j--;
2772
+ if (j < 0) return laid2.rect;
2773
+ const edge = laid2.edge ? state.edges.find((x) => x.id === laid2.edge) : void 0;
2774
+ const cross = laid2.rail ? l.rails[laid2.rail]?.rect.width ?? 0 : laid2.edge ? l.edges[laid2.edge]?.cross ?? 0 : 0;
2775
+ const held = formMain2(forms[j], !laid2.rail && edge && growsOnBar(state, edge, dragged, j) ? "natural" : "min", cross);
2776
+ return laid2.axis === "column" ? { ...laid2.rect, height: held } : { ...laid2.rect, width: held };
2777
+ }
2706
2778
  function context(state, dragged, options, others = []) {
2707
2779
  const item = Object.hasOwn(state.items, dragged) ? state.items[dragged] : void 0;
2708
2780
  if (!item || item.fixed || item.closed) return null;
@@ -3569,9 +3641,17 @@ function columnLines(c, side, railLands) {
3569
3641
  };
3570
3642
  });
3571
3643
  }
3572
- function railEnd(c, side, segments, y) {
3644
+ function railColumns(c, side) {
3645
+ const out = [];
3646
+ for (const p of c.now.rails[side]?.stack.items ?? []) {
3647
+ const e = c.now.items[p.id]?.edge;
3648
+ if (e !== void 0 && !out.includes(e)) out.push(e);
3649
+ }
3650
+ return out;
3651
+ }
3652
+ function railEnd(c, side, columns, y) {
3573
3653
  const { state, rest, dragged } = c;
3574
- const edge = [...segments].reverse().map((s) => rest.edges.find((e) => e.id === s.edge)).find((e) => !!e);
3654
+ const edge = [...columns].reverse().map((id) => rest.edges.find((e) => e.id === id)).find((e) => !!e);
3575
3655
  if (!edge) return null;
3576
3656
  const at = edge.items.filter((id) => zoneOf(rest.items[id]) === "start").length;
3577
3657
  const place = { kind: "gap", edge: edge.id, zone: "start", at };
@@ -3626,7 +3706,7 @@ function railStops(c, side) {
3626
3706
  }
3627
3707
  for (const g of groups) stops2.push({ y: g.y0, ring: ringBefore(g.edge) });
3628
3708
  const last = groups[groups.length - 1];
3629
- stops2.push({ y: last.y1, ring: ringAfter(last.edge) });
3709
+ stops2.push({ y: last.y1, ring: ringAfter(railColumns(c, side).at(-1) ?? last.edge) });
3630
3710
  } else {
3631
3711
  const firstCol = mine.find((e) => e.column === true);
3632
3712
  const outer = railOuter(c, side);
@@ -3635,10 +3715,10 @@ function railStops(c, side) {
3635
3715
  }
3636
3716
  const ownRail = now.items[dragged]?.rail === side;
3637
3717
  const shown = !!rail && rail.segments.length > 0;
3638
- const lands = (r) => shown ? collapsesAt(c, r, side) : r.layout.items[dragged].rail === side && r.state !== c.state;
3718
+ const lands = (r) => shown ? collapsesAt(c, r, side) : r.layout.items[dragged].rail === side && !r.layout.items[dragged].inMenu && r.state !== c.state;
3639
3719
  const at = zone;
3640
3720
  const arriving = state.foldedColumnDrop === "end" && !ownRail;
3641
- const end = arriving && shown ? railEnd(c, side, rail.segments, at.y + at.height) : null;
3721
+ const end = arriving && shown ? railEnd(c, side, railColumns(c, side), rail.menu ? rail.menu.rect.y : at.y + at.height) : null;
3642
3722
  if (arriving && (shown ? !end : !isHandFolded(state, dragged))) return null;
3643
3723
  const width = state.rails?.[side]?.width;
3644
3724
  const tooThick = width !== void 0 && thickerThan(formsOf(state.items[dragged], "column"), width);
@@ -5170,4 +5250,4 @@ export {
5170
5250
  HATCH_EDGE,
5171
5251
  dockDrag
5172
5252
  };
5173
- //# sourceMappingURL=chunk-GWRE7UD7.js.map
5253
+ //# sourceMappingURL=chunk-2SIB26V3.js.map