@n-uf/placement 26.11.33 → 26.11.34

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.
@@ -177,6 +177,12 @@ interface CaseRequires {
177
177
  * rests there). A host that picks at the point alone, the in-memory reference host among them, skips the row.
178
178
  */
179
179
  readonly intent?: true;
180
+ /**
181
+ * The scene's own rail drop policy (`Scene.railDrop`, as the row gives it, often none): the row aims at a pixel whose
182
+ * meaning depends on whether a rail drop strip lies over the window's edge. A host that lays its own strips (its own
183
+ * `railDrop`) skips the row; rows that only mean a place aim by place and need no such precondition.
184
+ */
185
+ readonly railDrop?: "scene";
180
186
  }
181
187
  interface CaseRow {
182
188
  /** Generic and stable: an integrating app's suite names rows by it. */
@@ -325,12 +331,18 @@ declare function withRefusals(pick: PickRule, refused: readonly SceneRefusal[]):
325
331
  interface AimArea {
326
332
  readonly stage: Rect;
327
333
  readonly content?: Rect;
334
+ /**
335
+ * The dragged item's own rect as drawn (a float's too): a point outside it is preferred, as a person aims, so a drag
336
+ * intent's home gate never holds the aim. Default: the hit of the list's `home` target, if any.
337
+ */
338
+ readonly own?: Rect;
328
339
  }
329
340
  /**
330
341
  * A pointer position that reaches the target at `place`: inside its hit and not covered by a more precise target
331
342
  * (`pick` finds it there: the host's pick rule, `@n-uf/motion/drag`'s `targetAt`; default the same rule, `pickTarget`).
332
343
  * It tries the hit's center, then a grid across the hit; a target over the whole plane (the float) is aimed at the
333
- * content's center, then the stage's, then a grid across the stage. Null when no point reaches it (a gap that a home or
344
+ * content's center, then the stage's, then a grid across the stage. Of the points that reach it, the first outside the
345
+ * dragged item's own rect (`AimArea.own`) wins whenever one exists. Null when no point reaches it (a gap that a home or
334
346
  * a blocked spot covers entirely).
335
347
  */
336
348
  declare function resolvePlace(list: readonly SceneTarget[], place: ScenePlace, item: string, area_: AimArea, pick?: PickRule): Point | null;
@@ -15,7 +15,7 @@ import {
15
15
  storeScene,
16
16
  targets,
17
17
  use
18
- } from "./chunk-IOTKOYKW.js";
18
+ } from "./chunk-VKB3UWKX.js";
19
19
  import "./chunk-AE3BWTAE.js";
20
20
  import {
21
21
  centre,
@@ -1075,6 +1075,8 @@ function winScene(spec, o = {}) {
1075
1075
 
1076
1076
  // src/scene/cases/rows-gestures.ts
1077
1077
  var win = (o = {}) => winScene(WINDOW_A, { size: 300, ...o });
1078
+ var foldsBelow = (w) => 2 * w.pad + w.card.min + 2 * w.gap + w.contentMin.width + w.rail;
1079
+ var BOTH_RAILS_W = Math.min(foldsBelow(WINDOW_A), foldsBelow(WINDOW_B)) - 12;
1078
1080
  var FLUSH_W = 1440;
1079
1081
  var flush = () => winScene(WINDOW_B, { width: FLUSH_W, height: 900, handFold: "ride" });
1080
1082
  function withTitle(s) {
@@ -1167,16 +1169,23 @@ var GESTURE_ROWS = [
1167
1169
  },
1168
1170
  {
1169
1171
  id: "P6-new-outer-column-from-outside",
1170
- title: "A new outer column from outside the right column",
1171
- expect: "Let go 1 px outside the right column's outer edge (11 px from the window's edge, past the rail stop's 10), at 5%, 50% or 95% of the stage's height, Annotations makes the outermost column, on the slot's rect.",
1172
+ title: "A new outer column, reached from the content",
1173
+ expect: "Annotations held over the pages (the float) and then moved to the new outermost right column's line (aimed by its place, so it holds with or without a rail strip) makes the outermost column, on the slot's rect.",
1172
1174
  group: "gestures",
1173
1175
  scene: win(),
1176
+ gestures: [g.press("annotations"), g.at(560, 400), g.hold(), g.to(g.column("right", 0)), g.hold(), g.release()],
1177
+ checkpoints: [{ at: 4, layout: { items: { pages: { rect: rect(12, 0, 220, 800) }, annotations: { edge: "right-1", rect: rect(888, 0, 220, 800) }, findings: { edge: "right-0", rect: rect(576, 0, 300, 800) } }, columns: { left: [["pages"]], right: [["annotations"], ["findings"]] }, notes: { has: ["column-shrunk"] } }, note: "the preview" }],
1178
+ expectLayout: { items: { pages: { rect: rect(12, 0, 220, 800) }, annotations: { edge: "right-1", rect: rect(888, 0, 220, 800) }, findings: { edge: "right-0", rect: rect(576, 0, 300, 800) } }, columns: { left: [["pages"]], right: [["annotations"], ["findings"]] }, notes: { has: ["column-shrunk"] } }
1179
+ },
1180
+ {
1181
+ id: "P6-outer-line-at-11-px",
1182
+ title: "With no rail strip, 11 px from the window's edge is the new-column line",
1183
+ expect: "Precondition: no rail drop strip (the scene's `railDrop` as given: none), so the rail's own stop owns the window's outer 10 px. Let go 1 px outside the right column's outer edge (11 px from the window's edge), at 5%, 50% or 95% of the stage's height, Annotations makes the outermost column.",
1184
+ group: "gestures",
1185
+ scene: win(),
1186
+ requires: { railDrop: "scene" },
1174
1187
  gestures: [g.press("annotations"), g.at(RIGHT_EDGE + LINE_OUT, 40), g.hold(), g.at(RIGHT_EDGE + LINE_OUT, 400), g.hold(), g.at(RIGHT_EDGE + LINE_OUT, 760), g.hold(), g.release()],
1175
- checkpoints: [
1176
- { at: 2, layout: { items: { pages: { rect: rect(12, 0, 220, 800) }, annotations: { edge: "right-1", rect: rect(888, 0, 220, 800) }, findings: { edge: "right-0", rect: rect(576, 0, 300, 800) } }, columns: { left: [["pages"]], right: [["annotations"], ["findings"]] }, notes: { has: ["column-shrunk"] } }, note: "5%" },
1177
- { at: 4, layout: { items: { pages: { rect: rect(12, 0, 220, 800) }, annotations: { edge: "right-1", rect: rect(888, 0, 220, 800) }, findings: { edge: "right-0", rect: rect(576, 0, 300, 800) } }, columns: { left: [["pages"]], right: [["annotations"], ["findings"]] }, notes: { has: ["column-shrunk"] } }, note: "50%" },
1178
- { at: 6, layout: { items: { pages: { rect: rect(12, 0, 220, 800) }, annotations: { edge: "right-1", rect: rect(888, 0, 220, 800) }, findings: { edge: "right-0", rect: rect(576, 0, 300, 800) } }, columns: { left: [["pages"]], right: [["annotations"], ["findings"]] }, notes: { has: ["column-shrunk"] } }, note: "95%" }
1179
- ],
1188
+ checkpoints: [2, 4, 6].map((at2, i) => ({ at: at2, layout: { items: { annotations: { edge: "right-1", rect: rect(888, 0, 220, 800) } }, columns: { right: [["annotations"], ["findings"]] } }, note: ["5%", "50%", "95%"][i] })),
1180
1189
  expectLayout: { items: { pages: { rect: rect(12, 0, 220, 800) }, annotations: { edge: "right-1", rect: rect(888, 0, 220, 800) }, findings: { edge: "right-0", rect: rect(576, 0, 300, 800) } }, columns: { left: [["pages"]], right: [["annotations"], ["findings"]] }, notes: { has: ["column-shrunk"] } }
1181
1190
  },
1182
1191
  {
@@ -1191,10 +1200,10 @@ var GESTURE_ROWS = [
1191
1200
  {
1192
1201
  id: "P6-left-outer-edge",
1193
1202
  title: "A new outer column on the left",
1194
- expect: "Findings let go 1 px outside the left column's outer edge (11 px from the window's edge, past the rail stop's 10) makes the outermost left column; the right side is then empty.",
1203
+ expect: "Findings let go on the new outermost left column's line (aimed by its place, so it holds with or without a rail strip) makes the outermost left column; the right side is then empty.",
1195
1204
  group: "gestures",
1196
1205
  scene: win(),
1197
- gestures: [g.press("findings"), g.at(12 - LINE_OUT, 400), g.hold(), g.release()],
1206
+ gestures: g.drag("findings", g.column("left", 0)),
1198
1207
  expectLayout: { items: { findings: { edge: "left-1", rect: rect(12, 0, 220, 800) }, pages: { rect: rect(244, 0, 300, 394) }, annotations: { rect: rect(244, 406, 300, 394) } }, columns: { left: [["findings"], ["pages", "annotations"]], right: [] } }
1199
1208
  },
1200
1209
  {
@@ -1237,12 +1246,12 @@ var GESTURE_ROWS = [
1237
1246
  {
1238
1247
  id: "P9-to-the-other-rail",
1239
1248
  title: "A rail segment docks folded on the other rail",
1240
- expect: "At 600 px the left column is folded by width into the left rail (Pages and Annotations), and Findings is folded by hand into the right rail, so both rails show. Annotations dropped on the right rail docks folded there, as a segment before Findings; Pages stays in the left rail.",
1249
+ expect: `At ${BOTH_RAILS_W} px (narrow enough for both windows, A and B) the left column is folded by width into the left rail (Pages and Annotations), and Findings is folded by hand into the right rail, so both rails show. Annotations dropped on the right rail docks folded there, as a segment before Findings; Pages stays in the left rail.`,
1241
1250
  group: "gestures",
1242
1251
  requires: { rails: ["left", "right"] },
1243
- scene: win({ width: 600, from: { findings: 1 } }),
1252
+ scene: win({ width: BOTH_RAILS_W, from: { findings: 1 } }),
1244
1253
  gestures: g.drag("annotations", g.rail("right")),
1245
- expectLayout: { items: { pages: { rail: "left", rect: rect(12, 0, 32, 32) }, annotations: { rail: "right", folded: "hand", rect: rect(556, 0, 32, 32) }, findings: { rail: "right", rect: rect(556, 32, 32, 32) } }, rails: { left: ["pages"], right: ["annotations", "findings"] } }
1254
+ expectLayout: { items: { pages: { rail: "left", rect: rect(12, 0, 32, 32) }, annotations: { rail: "right", folded: "hand", rect: rect(BOTH_RAILS_W - 44, 0, 32, 32) }, findings: { rail: "right", rect: rect(BOTH_RAILS_W - 44, 32, 32, 32) } }, rails: { left: ["pages"], right: ["annotations", "findings"] } }
1246
1255
  },
1247
1256
  {
1248
1257
  id: "P10-float-keeps-its-place-and-last-size",
@@ -1607,7 +1616,9 @@ function resolvePlace(list, place, item, area_, pick = pickTarget) {
1607
1616
  for (const fy of [0.5, 0.25, 0.75, 0.1, 0.9, 0.4, 0.6, 0, 1]) {
1608
1617
  for (const fx of [0.5, 0.25, 0.75, 0.1, 0.9, 0.4, 0.6, 0, 1]) candidates.push({ x: region.x + region.width * fx, y: region.y + region.height * fy });
1609
1618
  }
1610
- return candidates.find((p) => contains(t.hit, p) && pick(list, p) === t) ?? null;
1619
+ const reach = candidates.filter((p) => contains(t.hit, p) && pick(list, p) === t);
1620
+ const own = area_.own ?? list.find((x) => x.place.kind === "home" && x.id.startsWith("home:"))?.hit;
1621
+ return (own ? reach.find((p) => !contains(own, p)) : void 0) ?? reach[0] ?? null;
1611
1622
  }
1612
1623
  function resizeStep(scene, start, layout, g2) {
1613
1624
  if (g2.edge !== void 0) {
@@ -1683,7 +1694,7 @@ function createSceneHost(options = {}) {
1683
1694
  if (!s) return;
1684
1695
  if (g2.place) {
1685
1696
  if (!s.lifted) liftNow(s);
1686
- const p = resolvePlace(s.list, g2.place, s.item, aim(), s.pickAt);
1697
+ const p = resolvePlace(s.list, g2.place, s.item, { ...aim(), ...prev().items[s.item] ? { own: prev().items[s.item].rect } : {} }, s.pickAt);
1687
1698
  if (!p) throw new Error(`no point reaches the target at ${JSON.stringify(g2.place)} (targets: ${s.list.map((t) => t.id).join(", ") || "none"})`);
1688
1699
  s.point = p;
1689
1700
  s.target = s.pickAt(s.list, p);