@n-uf/placement 26.11.28 → 26.11.30
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 +55 -0
- package/README.md +110 -61
- package/dist/{chunk-7ASCUAGV.js → chunk-3ZICYLWL.js} +2 -2
- package/dist/{chunk-7ASCUAGV.js.map → chunk-3ZICYLWL.js.map} +1 -1
- package/dist/{chunk-6GQ3PEZA.js → chunk-5CSWQSH7.js} +197 -18
- package/dist/chunk-5CSWQSH7.js.map +1 -0
- package/dist/{chunk-3RRCKN74.js → chunk-AE3BWTAE.js} +2 -2
- package/dist/chunk-AE3BWTAE.js.map +1 -0
- package/dist/{chunk-3P6VOXA6.js → chunk-AVMZIXGO.js} +2 -2
- package/dist/{chunk-3P6VOXA6.js.map → chunk-AVMZIXGO.js.map} +1 -1
- package/dist/{chunk-WLMJ6JGO.js → chunk-GIBUM6TB.js} +1 -1
- package/dist/chunk-GIBUM6TB.js.map +1 -0
- package/dist/{chunk-OYGOJWAX.js → chunk-JVAR67OL.js} +2 -2
- package/dist/{chunk-WM5FJ3IS.js → chunk-VLTYJHUA.js} +1 -1
- package/dist/{chunk-WM5FJ3IS.js.map → chunk-VLTYJHUA.js.map} +1 -1
- package/dist/{constructions-DSEjvWMP.d.ts → constructions-Cbz7uEAZ.d.ts} +3 -3
- package/dist/desk.d.ts +3 -3
- package/dist/desk.js +3 -3
- package/dist/dock.d.ts +4 -4
- package/dist/dock.js +2 -2
- package/dist/dock.js.map +1 -1
- package/dist/{float-fit-DRSOU_2y.d.ts → float-fit-DCYxRMru.d.ts} +1 -1
- package/dist/{geometry-CkZ6Fcfb.d.ts → geometry-Bf37LbCT.d.ts} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{model-DwojiKKF.d.ts → model-BxFXr9UY.d.ts} +52 -7
- package/dist/{model-CPM1Lv65.d.ts → model-X7eUaKlA.d.ts} +2 -2
- package/dist/panels.d.ts +5 -5
- package/dist/panels.js +3 -3
- package/dist/scene-cases.d.ts +59 -15
- package/dist/scene-cases.js +114 -21
- package/dist/scene-cases.js.map +1 -1
- package/dist/scene.d.ts +7 -7
- package/dist/scene.js +9 -3
- package/dist/stack.d.ts +6 -6
- package/dist/stack.js +2 -2
- package/dist/{target-CEVCfJd-.d.ts → target-2RYYKkd1.d.ts} +7 -1
- package/dist/{targets-BPG7Kf02.d.ts → targets-Du5_4T1u.d.ts} +4 -4
- package/dist/targets.d.ts +14 -14
- package/dist/targets.js +4 -4
- package/dist/targets.js.map +1 -1
- package/dist/toolbar.d.ts +11 -11
- package/dist/toolbar.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-3RRCKN74.js.map +0 -1
- package/dist/chunk-6GQ3PEZA.js.map +0 -1
- package/dist/chunk-WLMJ6JGO.js.map +0 -1
- /package/dist/{chunk-OYGOJWAX.js.map → chunk-JVAR67OL.js.map} +0 -0
package/dist/scene-cases.js
CHANGED
|
@@ -14,13 +14,13 @@ import {
|
|
|
14
14
|
storeScene,
|
|
15
15
|
targets,
|
|
16
16
|
use
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-5CSWQSH7.js";
|
|
18
|
+
import "./chunk-AE3BWTAE.js";
|
|
19
19
|
import {
|
|
20
20
|
centre,
|
|
21
21
|
contains,
|
|
22
22
|
rect
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-VLTYJHUA.js";
|
|
24
24
|
|
|
25
25
|
// src/scene/cases/gestures.ts
|
|
26
26
|
var gap = (edge, at2, zone = "start") => ({ kind: "gap", edge, zone, at: at2 });
|
|
@@ -459,7 +459,7 @@ var DOCKING_ROWS = [
|
|
|
459
459
|
expect: "Dragged away and back over its own place, the item shows that place, and a release puts it back; nothing else moved.",
|
|
460
460
|
group: "drag",
|
|
461
461
|
scene: bench(),
|
|
462
|
-
// Pressed 20 px in and 10 down; the float aimed at the content's
|
|
462
|
+
// Pressed 20 px in and 10 down; the float aimed at the content's center lands at the pointer minus that grab.
|
|
463
463
|
gestures: [g.press("pages", { x: 20, y: 10 }), g.to(g.float), g.hold(), g.to(g.home), g.hold(), g.release()],
|
|
464
464
|
checkpoints: [
|
|
465
465
|
{ at: 2, layout: { items: { pages: { floating: true, rect: rect(520, 260, 200, 190) }, annotations: { formKind: "open", rect: rect(0, 40, 240, 460) } } }, note: "away, over the pages" },
|
|
@@ -494,8 +494,9 @@ var DOCKING_ROWS = [
|
|
|
494
494
|
{
|
|
495
495
|
id: "C7",
|
|
496
496
|
title: "A float over a docked panel",
|
|
497
|
-
expect: "A float never covers a docked item's content: dropped over one, it lands clear of it, and the preview says so.",
|
|
497
|
+
expect: "A float never covers a docked item's content: dropped over one, it lands clear of it, and the preview says so. This assumes the default `hitBand` (an open panel's body is no drop place): a host whose columns use `hitBand: \"middle\"` gets card halves over the panel, and skips or marks this row.",
|
|
498
498
|
group: "floats",
|
|
499
|
+
requires: { hitBand: "default" },
|
|
499
500
|
scene: bench(),
|
|
500
501
|
gestures: [g.press("findings", { x: 200, y: 10 }), g.at(260, 230), g.hold(), g.release()],
|
|
501
502
|
checkpoints: [{ at: 2, layout: { items: { findings: { floating: true, rect: rect(240, 220, 220, 190) } } }, note: "the preview, clear of the column" }],
|
|
@@ -566,7 +567,7 @@ var DOCKING_ROWS = [
|
|
|
566
567
|
{
|
|
567
568
|
id: "C17",
|
|
568
569
|
title: "A drop past the stage's edge",
|
|
569
|
-
expect: "A float dropped with the pointer past the stage's edge is clamped into the stage, and the
|
|
570
|
+
expect: "A float dropped with the pointer past the stage's edge: the pointer is clamped into the stage first (the host contract; the runner clamps every `move` to a point), and the clamped point picks what is there. Nothing is docked at this stage's right edge, so it picks the float, which lands clamped into the stage; the preview shows it clamped, and the drop never cancels. A window with a docked edge there picks that edge's last gap instead.",
|
|
570
571
|
group: "floats",
|
|
571
572
|
scene: bench(),
|
|
572
573
|
gestures: [g.press("findings", { x: 40, y: 10 }), g.at(920, 240), g.hold(), g.release()],
|
|
@@ -735,14 +736,14 @@ var RULE_ROWS = [
|
|
|
735
736
|
expect: "An edge takes only the kinds it lists: a panel held over the toolbar is offered no gap there, it falls through to the float, and the toolbar is as it was.",
|
|
736
737
|
group: "kinds",
|
|
737
738
|
scene: doc(),
|
|
738
|
-
// (600, 50) is a real gap for a group (the toolbar's
|
|
739
|
+
// (600, 50) is a real gap for a group (the toolbar's center gap): the control row below lets a group go there.
|
|
739
740
|
gestures: [g.press("pages", { x: 20, y: 10 }), g.at(600, 50), g.hold()],
|
|
740
741
|
expectLayout: { items: { pages: { floating: true, rect: rect(580, 68, 280, 360) }, views: { rect: rect(8, 32, 200, 36) }, tools: { rect: rect(212, 32, 200, 36) }, zoom: { rect: rect(992, 32, 200, 36) } }, order: { toolbar: ["views", "tools", "zoom"] } }
|
|
741
742
|
},
|
|
742
743
|
{
|
|
743
744
|
id: "C25-control-bar",
|
|
744
745
|
title: "Targets by kind: the toolbar's gap is real for a group",
|
|
745
|
-
expect: "The same point, with a group held, is the toolbar's
|
|
746
|
+
expect: "The same point, with a group held, is the toolbar's center gap: Tools lands in the toolbar's center zone. So the panel's refusal above is the kind's, not an empty spot's.",
|
|
746
747
|
group: "kinds",
|
|
747
748
|
scene: doc(),
|
|
748
749
|
gestures: [g.press("tools"), g.at(600, 50), g.hold(), g.release()],
|
|
@@ -1102,9 +1103,10 @@ var GESTURE_ROWS = [
|
|
|
1102
1103
|
},
|
|
1103
1104
|
{
|
|
1104
1105
|
id: "P5-neighbour-half-facing-it",
|
|
1105
|
-
title: "Over a
|
|
1106
|
-
expect:
|
|
1106
|
+
title: "Over a neighbor's body there is no gap",
|
|
1107
|
+
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.',
|
|
1107
1108
|
group: "gestures",
|
|
1109
|
+
requires: { hitBand: "default" },
|
|
1108
1110
|
scene: win(),
|
|
1109
1111
|
gestures: [g.press("annotations", { x: 20, y: 10 }), g.at(160, 200), g.hold(), g.release()],
|
|
1110
1112
|
expectLayout: { items: { pages: { rect: rect(12, 0, 300, 800) }, annotations: { floating: true, rect: rect(312, 190, 280, 360) } }, floats: ["annotations"], columns: { left: [["pages"]], right: [["findings"]] } }
|
|
@@ -1181,11 +1183,12 @@ var GESTURE_ROWS = [
|
|
|
1181
1183
|
{
|
|
1182
1184
|
id: "P9-to-the-other-rail",
|
|
1183
1185
|
title: "A rail segment docks folded on the other rail",
|
|
1184
|
-
expect: "Annotations dropped on the right
|
|
1186
|
+
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.",
|
|
1185
1187
|
group: "gestures",
|
|
1186
|
-
|
|
1188
|
+
requires: { rails: ["left", "right"] },
|
|
1189
|
+
scene: win({ width: 600, from: { findings: 1 } }),
|
|
1187
1190
|
gestures: g.drag("annotations", g.rail("right")),
|
|
1188
|
-
expectLayout: { items: { pages: { rail: "left", rect: rect(12, 0, 32, 32) },
|
|
1191
|
+
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"] } }
|
|
1189
1192
|
},
|
|
1190
1193
|
{
|
|
1191
1194
|
id: "P10-float-keeps-its-place-and-last-size",
|
|
@@ -1716,6 +1719,82 @@ function createSceneHost(options = {}) {
|
|
|
1716
1719
|
};
|
|
1717
1720
|
}
|
|
1718
1721
|
|
|
1722
|
+
// src/scene/cases/ids.ts
|
|
1723
|
+
function idRenames(ids) {
|
|
1724
|
+
const entries = Object.entries(ids ?? {});
|
|
1725
|
+
if (entries.length === 0) return { to: (id) => id, from: (id) => id, active: false };
|
|
1726
|
+
const back = /* @__PURE__ */ new Map();
|
|
1727
|
+
const fwd = new Map(entries);
|
|
1728
|
+
for (const [row2, host] of entries) {
|
|
1729
|
+
if (back.has(host)) throw new Error(`the id map names the host id "${host}" for both "${back.get(host)}" and "${row2}"`);
|
|
1730
|
+
back.set(host, row2);
|
|
1731
|
+
}
|
|
1732
|
+
return { to: (id) => fwd.get(id) ?? id, from: (id) => back.get(id) ?? id, active: true };
|
|
1733
|
+
}
|
|
1734
|
+
var rekey = (r, f2, v = (x) => x) => {
|
|
1735
|
+
const out = {};
|
|
1736
|
+
for (const [k, x] of Object.entries(r)) out[f2(k)] = v(x, k);
|
|
1737
|
+
return out;
|
|
1738
|
+
};
|
|
1739
|
+
function mapScene(s, f2) {
|
|
1740
|
+
return {
|
|
1741
|
+
...s,
|
|
1742
|
+
edges: s.edges.map((e) => ({ ...e, id: f2(e.id), items: e.items.map(f2) })),
|
|
1743
|
+
items: rekey(s.items, f2, (it) => ({ ...it, id: f2(it.id) })),
|
|
1744
|
+
floats: s.floats.map((x) => ({ ...x, id: f2(x.id) }))
|
|
1745
|
+
};
|
|
1746
|
+
}
|
|
1747
|
+
function mapPlace(p, f2) {
|
|
1748
|
+
return p.kind === "gap" || p.kind === "side" ? { ...p, edge: f2(p.edge) } : p;
|
|
1749
|
+
}
|
|
1750
|
+
function mapGesture(g2, f2) {
|
|
1751
|
+
return { ...g2, ...g2.item !== void 0 ? { item: f2(g2.item) } : {}, ...g2.edge !== void 0 ? { edge: f2(g2.edge) } : {}, ...g2.place ? { place: mapPlace(g2.place, f2) } : {} };
|
|
1752
|
+
}
|
|
1753
|
+
var mapNote = (n, f2) => {
|
|
1754
|
+
const out = { ...n };
|
|
1755
|
+
if ("id" in n && typeof n.id === "string") out.id = f2(n.id);
|
|
1756
|
+
if ("edge" in n && typeof n.edge === "string") out.edge = f2(n.edge);
|
|
1757
|
+
return out;
|
|
1758
|
+
};
|
|
1759
|
+
var mapFit = (fit, f2) => ({
|
|
1760
|
+
...fit,
|
|
1761
|
+
items: fit.items.map((it) => ({ ...it, id: f2(it.id) })),
|
|
1762
|
+
menu: fit.menu ? { ...fit.menu, items: fit.menu.items.map(f2) } : null,
|
|
1763
|
+
notes: fit.notes.map((n) => "id" in n ? { ...n, id: f2(n.id) } : n),
|
|
1764
|
+
...fit.steps ? { steps: fit.steps.map((s) => ({ ...s, id: f2(s.id) })) } : {}
|
|
1765
|
+
});
|
|
1766
|
+
function mapLayout(l, f2) {
|
|
1767
|
+
const edge = (e) => ({
|
|
1768
|
+
...e,
|
|
1769
|
+
stack: mapFit(e.stack, f2),
|
|
1770
|
+
free: mapFit(e.free, f2),
|
|
1771
|
+
menu: e.menu ? { ...e.menu, items: e.menu.items.map(f2) } : null,
|
|
1772
|
+
tabs: e.tabs.map(f2),
|
|
1773
|
+
...e.rides !== void 0 ? { rides: f2(e.rides) } : {}
|
|
1774
|
+
});
|
|
1775
|
+
const rails = {};
|
|
1776
|
+
for (const side of ["left", "right"]) {
|
|
1777
|
+
const r = l.rails[side];
|
|
1778
|
+
if (r) rails[side] = { ...r, segments: r.segments.map((s) => ({ ...s, id: f2(s.id), edge: f2(s.edge) })) };
|
|
1779
|
+
}
|
|
1780
|
+
return {
|
|
1781
|
+
...l,
|
|
1782
|
+
items: rekey(l.items, f2, (it) => ({ ...it, ...it.edge !== void 0 ? { edge: f2(it.edge) } : {}, ...it.rides !== void 0 ? { rides: f2(it.rides) } : {} })),
|
|
1783
|
+
edges: rekey(l.edges, f2, edge),
|
|
1784
|
+
floats: l.floats.map(f2),
|
|
1785
|
+
rails,
|
|
1786
|
+
notes: l.notes.map((n) => mapNote(n, f2))
|
|
1787
|
+
};
|
|
1788
|
+
}
|
|
1789
|
+
function mapStored(s, f2) {
|
|
1790
|
+
return {
|
|
1791
|
+
...s,
|
|
1792
|
+
edges: s.edges.map((e) => ({ ...e, id: f2(e.id), items: e.items.map(f2) })),
|
|
1793
|
+
floats: s.floats.map((x) => ({ ...x, id: f2(x.id) })),
|
|
1794
|
+
items: rekey(s.items, f2)
|
|
1795
|
+
};
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1719
1798
|
// src/scene/cases/run.ts
|
|
1720
1799
|
var DEFAULT_TOLERANCE = 0.5;
|
|
1721
1800
|
var defaultItemSelector = (id) => `[data-dock-item="${id.replace(/["\\]/g, "\\$&")}"]`;
|
|
@@ -1878,7 +1957,8 @@ function* steps(row2, host) {
|
|
|
1878
1957
|
if (at2 === void 0) return;
|
|
1879
1958
|
if (!Number.isInteger(at2) || at2 < 0 || at2 >= n) fail([`${what} is at gesture ${at2}, but the row has ${n} gestures (0 to ${last})`], "");
|
|
1880
1959
|
};
|
|
1881
|
-
const
|
|
1960
|
+
const ids = idRenames(host.ids);
|
|
1961
|
+
const itemSelector = (id) => host.itemSelector ? host.itemSelector(ids.to(id)) : defaultItemSelector(ids.to(id));
|
|
1882
1962
|
const aimed = (c) => c.item !== void 0 && c.select === void 0 ? { ...c, select: itemSelector(c.item) } : c;
|
|
1883
1963
|
for (const cp of row2.checkpoints ?? []) range("a checkpoint", cp.at);
|
|
1884
1964
|
for (const c of row2.expectDom ?? []) {
|
|
@@ -1894,7 +1974,7 @@ function* steps(row2, host) {
|
|
|
1894
1974
|
}
|
|
1895
1975
|
function* layoutOf(when) {
|
|
1896
1976
|
const r = yield () => host.layout();
|
|
1897
|
-
if (r.ok) return r.value;
|
|
1977
|
+
if (r.ok) return ids.active ? mapLayout(r.value, ids.from) : r.value;
|
|
1898
1978
|
fail([`the host couldn't give its layout: ${words(r.error)}`], when);
|
|
1899
1979
|
return null;
|
|
1900
1980
|
}
|
|
@@ -1917,21 +1997,28 @@ function* steps(row2, host) {
|
|
|
1917
1997
|
skipped.push(`the stops of ${s.item}`);
|
|
1918
1998
|
return;
|
|
1919
1999
|
}
|
|
1920
|
-
const have = (yield* must(() => host.stops(s.item))).map(placeKey);
|
|
2000
|
+
const have = (yield* must(() => host.stops(ids.to(s.item)))).map((p) => placeKey(mapPlace(p, ids.from)));
|
|
1921
2001
|
const want = s.places.map(placeKey);
|
|
1922
2002
|
if (have.join("\n") !== want.join("\n")) fail([`${s.item}'s stops are
|
|
1923
2003
|
${have.join("\n ")}
|
|
1924
2004
|
expected
|
|
1925
2005
|
${want.join("\n ")}`], "");
|
|
1926
2006
|
}
|
|
1927
|
-
const loaded = yield () => host.load(row2.scene, row2.settings);
|
|
2007
|
+
const loaded = yield () => host.load(ids.active ? mapScene(row2.scene, ids.to) : row2.scene, row2.settings);
|
|
1928
2008
|
if (!loaded.ok) {
|
|
1929
2009
|
fail([`the host couldn't load the scene: ${words(loaded.error)}`], "");
|
|
1930
2010
|
return { ok: false, failures, skipped };
|
|
1931
2011
|
}
|
|
2012
|
+
let stage = row2.settings?.stage ? { x: 0, y: 0, width: row2.settings.stage.w, height: row2.settings.stage.h } : row2.scene.stage;
|
|
2013
|
+
const inStage = (g2) => {
|
|
2014
|
+
if (g2.type !== "move" || !g2.point) return g2;
|
|
2015
|
+
return { ...g2, point: { x: Math.min(stage.x + stage.width, Math.max(stage.x, g2.point.x)), y: Math.min(stage.y + stage.height, Math.max(stage.y, g2.point.y)) } };
|
|
2016
|
+
};
|
|
1932
2017
|
for (let i = 0; i < n; i++) {
|
|
1933
2018
|
const g2 = row2.gestures[i];
|
|
1934
|
-
const
|
|
2019
|
+
const sent = inStage(g2);
|
|
2020
|
+
if (g2.type === "resize" && g2.edge === void 0 && g2.item === void 0 && g2.point) stage = { x: 0, y: 0, width: g2.point.x, height: g2.point.y };
|
|
2021
|
+
const done = yield () => host.perform(ids.active ? mapGesture(sent, ids.to) : sent);
|
|
1935
2022
|
if (!done.ok) {
|
|
1936
2023
|
fail([`${gestureWords(g2, i)} failed: ${words(done.error)}`], "");
|
|
1937
2024
|
return { ok: false, failures, skipped };
|
|
@@ -1954,7 +2041,7 @@ function* steps(row2, host) {
|
|
|
1954
2041
|
if (!host.stored) skipped.push("the stored form");
|
|
1955
2042
|
else {
|
|
1956
2043
|
const r = yield () => host.stored();
|
|
1957
|
-
if (r.ok) fail(storedIssues(row2.expectStored, r.value), " (the stored form)");
|
|
2044
|
+
if (r.ok) fail(storedIssues(row2.expectStored, ids.active ? mapStored(r.value, ids.from) : r.value), " (the stored form)");
|
|
1958
2045
|
else fail([`the host couldn't give its stored form: ${words(r.error)}`], "");
|
|
1959
2046
|
}
|
|
1960
2047
|
}
|
|
@@ -2011,8 +2098,8 @@ var CASE_GROUPS = [
|
|
|
2011
2098
|
{ id: "bars", title: "Bars give way" },
|
|
2012
2099
|
{ id: "previous", title: "What previous keeps" },
|
|
2013
2100
|
{ id: "kinds", title: "Kinds, chrome and reserved room" },
|
|
2014
|
-
{ id: "bands", title: "Gap
|
|
2015
|
-
{ id: "gestures", title: "
|
|
2101
|
+
{ id: "bands", title: "Gap hit areas, refits and slots" },
|
|
2102
|
+
{ id: "gestures", title: "Panel gestures" },
|
|
2016
2103
|
{ id: "window-a", title: "Window A: width thresholds" },
|
|
2017
2104
|
{ id: "window-b", title: "Window B: width thresholds" }
|
|
2018
2105
|
];
|
|
@@ -2029,7 +2116,13 @@ export {
|
|
|
2029
2116
|
createSceneHost,
|
|
2030
2117
|
defaultItemSelector,
|
|
2031
2118
|
g,
|
|
2119
|
+
idRenames,
|
|
2032
2120
|
layoutIssues,
|
|
2121
|
+
mapGesture,
|
|
2122
|
+
mapLayout,
|
|
2123
|
+
mapPlace,
|
|
2124
|
+
mapScene,
|
|
2125
|
+
mapStored,
|
|
2033
2126
|
pickTarget,
|
|
2034
2127
|
resolvePlace,
|
|
2035
2128
|
runCase,
|