@n-uf/docking 26.11.54 → 26.11.56

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/dist/testing.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  closeItem,
3
+ dockDrag,
3
4
  dockHome,
4
5
  floatAt,
5
6
  foldItem,
@@ -17,7 +18,7 @@ import {
17
18
  stops,
18
19
  storeDockState,
19
20
  targets
20
- } from "./chunk-KGNFLHSC.js";
21
+ } from "./chunk-FSNFXRYM.js";
21
22
 
22
23
  // src/testing/rows-docking.ts
23
24
  import { rect as r } from "@n-uf/placement";
@@ -1280,12 +1281,12 @@ var GESTURE_ROWS = [
1280
1281
  {
1281
1282
  id: "P5-neighbour-half-facing-it",
1282
1283
  title: "Over a neighbor's body there is no gap",
1283
- expect: 'Annotations let go over Pages\' body, away from its edges, finds no gap (over a panel\'s body a gap is a band around a boundary), so it falls through to the float target: it floats, where the pointer let go. The older rule "the neighbor half that faces it is its home" no longer holds. This assumes the default `hitBand` (an open panel\'s body is no drop place): a host whose columns use `hitBand: "middle"` gets card halves there, and skips or marks this row.',
1284
+ expect: 'Annotations let go over Pages\' body, away from its edges, finds no gap (over a panel\'s body a gap is a band around a boundary), so it falls through to the float target: it floats, where the pointer let go, over Pages (the clear place beside Pages would put the pointer off it, so it lies at the hand). The older rule "the neighbor half that faces it is its home" no longer holds. This assumes the default `hitBand` (an open panel\'s body is no drop place): a host whose columns use `hitBand: "middle"` gets card halves there, and skips or marks this row.',
1284
1285
  group: "gestures",
1285
1286
  requires: { hitBand: "default" },
1286
1287
  state: win(),
1287
1288
  gestures: [g.press("annotations", { x: 20, y: 10 }), g.at(160, 200), g.hold(), g.release()],
1288
- expectLayout: { items: { pages: { rect: r4(12, 0, 300, 800) }, annotations: { floating: true, rect: r4(312, 190, 280, 360) } }, floats: ["annotations"], columns: { left: [["pages"]], right: [["findings"]] } }
1289
+ expectLayout: { items: { pages: { rect: r4(12, 0, 300, 800) }, annotations: { floating: true, rect: r4(140, 190, 280, 360) } }, floats: ["annotations"], columns: { left: [["pages"]], right: [["findings"]] } }
1289
1290
  },
1290
1291
  {
1291
1292
  id: "P6-new-outer-column-from-outside",
@@ -1379,7 +1380,7 @@ var GESTURE_ROWS = [
1379
1380
  {
1380
1381
  id: "P9-rail-segment-on-its-own-rail",
1381
1382
  title: "A rail segment dropped on its own rail changes nothing",
1382
- expect: "In a narrow window, a rail segment dropped on its own side's rail (even below the last segment) never splits or reorders it.",
1383
+ expect: "In a narrow window, a rail segment dropped on a rail stop (`rail:<side>:<ring>`) of its own side, even below the last segment, is home: it never splits the rail, reorders it or opens a column. It moves among its own column's tiles only through that column's gaps (`gap:<edge>:<zone>:<at>`).",
1383
1384
  group: "gestures",
1384
1385
  state: win({ width: 700 }),
1385
1386
  gestures: g.drag("annotations", g.rail("left")),
@@ -1742,9 +1743,10 @@ var withDocks = (rows) => rows.map((row2) => row2.requires?.docks === void 0 &&
1742
1743
 
1743
1744
  // src/testing/host.ts
1744
1745
  import { center, contains as inside } from "@n-uf/placement";
1745
- import { pickRank } from "@n-uf/placement";
1746
1746
  var LIFT_THRESHOLD = 4;
1747
1747
  var END_REACH = 24;
1748
+ var REFUSAL_RANK = 2.5;
1749
+ var pickRank = (t) => t.refuse === true ? REFUSAL_RANK : t.priority;
1748
1750
  function referencePick(list, point) {
1749
1751
  const holds = (r5) => point.x >= r5.x && point.x <= r5.x + r5.width && point.y >= r5.y && point.y <= r5.y + r5.height;
1750
1752
  const within = (o) => !o || point.x > o.x && point.x < o.x + o.width && point.y > o.y && point.y < o.y + o.height;
@@ -2408,12 +2410,7 @@ function handRule(row2, before, stretchPositions) {
2408
2410
  const own = previous.items[row2.item];
2409
2411
  const press = row2.path[0];
2410
2412
  const options = { previous, ...own ? { grab: { x: press.x - own.rect.x, y: press.y - own.rect.y } } : {}, ...stretchPositions ? { stretchPositions } : {} };
2411
- const bySpot = /* @__PURE__ */ new Map();
2412
- const regionsOf = (spot) => {
2413
- let r5 = bySpot.get(spot);
2414
- if (!r5) bySpot.set(spot, r5 = lanes(row2.state, row2.item, spot ? { ...options, spot } : options));
2415
- return r5;
2416
- };
2413
+ const drag = dockDrag(row2.state, row2.item, options);
2417
2414
  return {
2418
2415
  /**
2419
2416
  * The grab's share along the lane, as the landing model takes it: of the item's longer side along the lane when it
@@ -2426,10 +2423,11 @@ function handRule(row2, before, stretchPositions) {
2426
2423
  const g2 = long === "x" ? press.x - own.rect.x : press.y - own.rect.y;
2427
2424
  return axis === long && size > 0 && Number.isFinite(g2) ? Math.min(1, Math.max(0, g2 / size)) : 0.5;
2428
2425
  },
2429
- /** The lane `lane` as drawn with `spot` held; as seen when the lane has no such spot (another host's ids). */
2426
+ /** The lane `lane` with `spot` held (its stretches in that spot's layout, `spotsOf`); as seen when the lane has no such spot (another host's ids). */
2430
2427
  laneOf(lane, spot) {
2431
- const held = regionsOf(spot).lanes.find((l) => l.id === lane);
2432
- return held?.spots.some((s) => s.id === spot) ? held : regionsOf("").lanes.find((l) => l.id === lane);
2428
+ const seen = drag.regions.lanes.find((l) => l.id === lane);
2429
+ const spots = seen?.spots.some((s) => s.id === spot) ? drag.spotsOf(spot) : null;
2430
+ return seen && spots ? { ...seen, spots } : seen;
2433
2431
  },
2434
2432
  /**
2435
2433
  * `g`, px: the gap along the lane between the facing edges of the two adjacent landings the pointer `p` lies between
@@ -2605,14 +2603,13 @@ function createLandingHost(o) {
2605
2603
  const press = row2.path[0];
2606
2604
  const grab = { x: press.x - own.rect.x, y: press.y - own.rect.y };
2607
2605
  const laneOptions = { previous, grab, ...o.stretchPositions ? { stretchPositions: o.stretchPositions } : {} };
2608
- const regions = lanes(s, row2.item, laneOptions);
2609
- const regionsFor = (spot2) => lanes(s, row2.item, { ...laneOptions, spot: spot2 });
2610
- const home = regions.lanes.flatMap((l) => l.spots.filter((x) => x.home).map((x) => ({ lane: l.id, spot: x.id })))[0];
2611
- const model = o.landing({ regions, regionsFor, grab, floatLanding: (p) => regions.float?.after(p, grab).layout.items[row2.item]?.rect ?? null, ...home ? { home } : {}, placeGuides: "near" });
2606
+ const drag = dockDrag(s, row2.item, laneOptions);
2607
+ const model = o.landing({ ...drag, preview: { mode: "placeholder", placeGuides: "near" } });
2612
2608
  const frames = [];
2613
2609
  const play = (p, t2, moving) => {
2614
2610
  const f2 = model.update(p, t2);
2615
- frames.push({ t: t2, point: p, moving, region: f2.region, lane: f2.lane, spot: f2.spot, landing: f2.landing, room: f2.room, ...f2.guides ? { guides: f2.guides } : {}, ...f2.pending ? { pending: f2.pending } : {} });
2611
+ const guides = drag.guides(f2).map((g2) => ({ id: g2.id, lane: g2.lane, kind: g2.kind, rect: g2.rect }));
2612
+ frames.push({ t: t2, point: p, moving, region: f2.region, lane: f2.lane, spot: f2.spot, landing: f2.landing, room: f2.room, guides, ...f2.pending ? { pending: f2.pending } : {} });
2616
2613
  };
2617
2614
  let t = 0;
2618
2615
  let at2 = press;
@@ -2624,9 +2621,7 @@ function createLandingHost(o) {
2624
2621
  }
2625
2622
  for (let r5 = SAMPLE; r5 <= (row2.rest ?? 0); r5 += SAMPLE) play(at2, t += SAMPLE, false);
2626
2623
  const out = model.release(at2, t);
2627
- const spot = out?.kind === "spot" ? [...regions.lanes, ...regionsFor(out.spot).lanes].flatMap((l) => l.spots).find((x) => x.id === out.spot) : void 0;
2628
- const target = out?.kind === "float" ? regions.float : spot && out?.kind === "spot" && !out.home ? spot.target : null;
2629
- const next = target ? target.after(at2, grab).state : s;
2624
+ const next = out && !(out.kind === "spot" && out.home) ? drag.after(out).state : s;
2630
2625
  return { frames, layout: solve(next, { previous }), before: previous, ...o.stretchPositions ? { stretchPositions: o.stretchPositions } : {} };
2631
2626
  }
2632
2627
  };