@n-uf/docking 26.11.61 → 26.11.62
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 +12 -0
- package/dist/{chunk-Y2IM76RG.js → chunk-AX6OK7XQ.js} +68 -26
- package/dist/chunk-AX6OK7XQ.js.map +1 -0
- package/dist/{drag-B8JbX6Sq.d.ts → drag-CEdu7jFG.d.ts} +11 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-Y2IM76RG.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,18 @@ 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.11.62
|
|
11
|
+
|
|
12
|
+
- **Every drop gives the grab.** `DropResult.grab` is now present on the result of every target's `after()`, from
|
|
13
|
+
`targets()`, `stops()` and a lane's spots (`DockSpot.target`): a fixed slot's, home's, a column's and a rail's
|
|
14
|
+
included, which gave none before (only a float's and a sliding spot's did). It is the drag's grab read in the form
|
|
15
|
+
the drop lays the item in, by the one reading `dockDrag(...).after(held).grab` makes: the grab passed to `after(point,
|
|
16
|
+
grab)`, else `DockDropOptions.grab`, as a float reads it. A host drawing the held copy at the pointer less the
|
|
17
|
+
landing's grab no longer keeps the old grip anchor for a fixed slot, so a bar-to-bar release no longer glides by the
|
|
18
|
+
difference. The type is unchanged (`grab` stays optional on `DropResult`).
|
|
19
|
+
- Documented: the memos of `stops()` and `lanes()` leave `onGrabNote` out of their keys (it changes no output), so the
|
|
20
|
+
first callback a drag's options are remembered with is the one that hears.
|
|
21
|
+
|
|
10
22
|
## 26.11.61
|
|
11
23
|
|
|
12
24
|
No changes in `@n-uf/docking`. Released in step with `@n-uf/motion` and `@n-uf/placement`, which share the version.
|
|
@@ -2297,9 +2297,10 @@ function grabOf(lift, grab, onNote) {
|
|
|
2297
2297
|
}
|
|
2298
2298
|
var LIFT_SLACK = 0.5;
|
|
2299
2299
|
var noted = /* @__PURE__ */ new WeakSet();
|
|
2300
|
-
function grabResolver(lift) {
|
|
2300
|
+
function grabResolver(lift, fallback) {
|
|
2301
2301
|
let last = null;
|
|
2302
|
-
return (
|
|
2302
|
+
return (passed) => {
|
|
2303
|
+
const grab = passed ?? fallback;
|
|
2303
2304
|
if (last && last.grab === grab) return last.fn;
|
|
2304
2305
|
last = { grab, fn: grabOf(lift, grab) };
|
|
2305
2306
|
return last.fn;
|
|
@@ -2314,6 +2315,16 @@ function grabKey(grab) {
|
|
|
2314
2315
|
if (id === void 0) fnIds.set(grab, id = nextFnId++);
|
|
2315
2316
|
return `fn${id}`;
|
|
2316
2317
|
}
|
|
2318
|
+
var ORIGIN = { x: 0, y: 0 };
|
|
2319
|
+
function grabIn(grab, layout, dragged, press, lift = false) {
|
|
2320
|
+
const laid2 = layout.items[dragged];
|
|
2321
|
+
if (laid2) return grab(laid2, sizeOf(laid2.rect), lift ? "lift" : laid2.floating ? "float" : "lane");
|
|
2322
|
+
return press && typeof press !== "function" ? { x: press.x, y: press.y } : ORIGIN;
|
|
2323
|
+
}
|
|
2324
|
+
function readerOf(lift, base, dragged, options) {
|
|
2325
|
+
const resolve = grabResolver(lift, options.grab);
|
|
2326
|
+
return (layout, grab) => grabIn(grab === void 0 || grab === options.grab ? base : resolve(grab), layout, dragged, grab ?? options.grab);
|
|
2327
|
+
}
|
|
2317
2328
|
var samePoint = (a, b) => Math.abs(a.x - b.x) < EPS12 && Math.abs(a.y - b.y) < EPS12;
|
|
2318
2329
|
function aimOnce(fn, rule, first, aim, laidOf, sizeIn) {
|
|
2319
2330
|
const g0 = fn(first.laid, first.size, rule);
|
|
@@ -2665,6 +2676,10 @@ function roomOf2(state, now, prev) {
|
|
|
2665
2676
|
const plain = withoutBarGrowth(state);
|
|
2666
2677
|
return plain === state ? now : solve(plain, prev);
|
|
2667
2678
|
}
|
|
2679
|
+
function liftIn(state, now, dragged, prev) {
|
|
2680
|
+
const own = landedLayout(state, now, dragged, prev).items[dragged];
|
|
2681
|
+
return { own, lift: liftOf(state, now, dragged, own?.rect) };
|
|
2682
|
+
}
|
|
2668
2683
|
function context(state, dragged, options, others = []) {
|
|
2669
2684
|
const item = Object.hasOwn(state.items, dragged) ? state.items[dragged] : void 0;
|
|
2670
2685
|
if (!item || item.fixed || item.closed) return null;
|
|
@@ -2674,8 +2689,7 @@ function context(state, dragged, options, others = []) {
|
|
|
2674
2689
|
const rest = liftItem(state, dragged);
|
|
2675
2690
|
const base = solve(rest, prev);
|
|
2676
2691
|
const here = placeKey(prune(state), dragged);
|
|
2677
|
-
const own =
|
|
2678
|
-
const lift = liftOf(state, now, dragged, own?.rect);
|
|
2692
|
+
const { own, lift } = liftIn(state, now, dragged, prev);
|
|
2679
2693
|
const c = {
|
|
2680
2694
|
state,
|
|
2681
2695
|
others,
|
|
@@ -4030,6 +4044,37 @@ function alongOfSlots(s, tiles) {
|
|
|
4030
4044
|
return out;
|
|
4031
4045
|
}
|
|
4032
4046
|
function generate(state, dragged, options) {
|
|
4047
|
+
const g = generateAll(state, dragged, options);
|
|
4048
|
+
let read2;
|
|
4049
|
+
const lazy = (layout, grab) => (read2 ??= grabReader(state, dragged, options))(layout, grab);
|
|
4050
|
+
return { ...g, targets: g.targets.map((t) => withGrab(t, lazy)), ...g.places ? { places: g.places.map((t) => withGrab(t, lazy)) } : {} };
|
|
4051
|
+
}
|
|
4052
|
+
function grabReader(state, dragged, options) {
|
|
4053
|
+
const prev = options.previous ? { previous: options.previous } : {};
|
|
4054
|
+
const { lift } = liftIn(state, solve(state, prev), dragged, prev);
|
|
4055
|
+
return readerOf(lift, grabOf(lift, options.grab, options.onGrabNote), dragged, options);
|
|
4056
|
+
}
|
|
4057
|
+
var grabbed = /* @__PURE__ */ new WeakSet();
|
|
4058
|
+
function withGrab(drop, read2) {
|
|
4059
|
+
if (grabbed.has(drop)) return drop;
|
|
4060
|
+
const made = /* @__PURE__ */ new WeakMap();
|
|
4061
|
+
const out = {
|
|
4062
|
+
...drop,
|
|
4063
|
+
after: (point, grab) => {
|
|
4064
|
+
const r = drop.after(point, grab);
|
|
4065
|
+
if (r.grab) return r;
|
|
4066
|
+
let byGrab = made.get(r);
|
|
4067
|
+
if (!byGrab) made.set(r, byGrab = /* @__PURE__ */ new Map());
|
|
4068
|
+
const key = JSON.stringify(grabKey(grab));
|
|
4069
|
+
let g = byGrab.get(key);
|
|
4070
|
+
if (!g) byGrab.set(key, g = { ...r, grab: read2(r.layout, grab) });
|
|
4071
|
+
return g;
|
|
4072
|
+
}
|
|
4073
|
+
};
|
|
4074
|
+
grabbed.add(out);
|
|
4075
|
+
return out;
|
|
4076
|
+
}
|
|
4077
|
+
function generateAll(state, dragged, options) {
|
|
4033
4078
|
checkEdgeIds(state);
|
|
4034
4079
|
const { view: shown, lent, rezoned } = viewOf(state);
|
|
4035
4080
|
if (shown === state) return generateShown(state, dragged, options, []);
|
|
@@ -4082,7 +4127,7 @@ function generateShown(state, dragged, options, hidden) {
|
|
|
4082
4127
|
const fo = options.floatOrient ?? was?.orient ?? floatOrientOf(item);
|
|
4083
4128
|
const wasOrient = was?.orient ?? floatOrientOf(item);
|
|
4084
4129
|
const size = options.floatSize ?? (was && wasOrient === fo ? { width: was.rect.width, height: was.rect.height } : floatSizeOf(item, fo));
|
|
4085
|
-
const grabs = grabResolver(c.lift);
|
|
4130
|
+
const grabs = grabResolver(c.lift, options.grab);
|
|
4086
4131
|
let probe = null;
|
|
4087
4132
|
const probeForm = () => (probe ??= { laid: solve(markUsed(floatAt(state, dragged, rect19(0, 0, size.width, size.height), options.floatOrient), dragged), prev).items[dragged] }).laid;
|
|
4088
4133
|
targets2.push({
|
|
@@ -4225,7 +4270,7 @@ var hull2 = (a, b) => {
|
|
|
4225
4270
|
};
|
|
4226
4271
|
var nonNeg2 = (v) => Number.isFinite(v) && v > 0 ? v : 0;
|
|
4227
4272
|
var sameRect = (a, b) => Math.max(Math.abs(a.x - b.x), Math.abs(a.y - b.y), Math.abs(a.width - b.width), Math.abs(a.height - b.height)) < 0.5;
|
|
4228
|
-
var
|
|
4273
|
+
var ORIGIN2 = { x: 0, y: 0 };
|
|
4229
4274
|
function liftedLayout(state, dragged, options) {
|
|
4230
4275
|
return solve(liftItem(state, dragged), options.previous ? { previous: options.previous } : {});
|
|
4231
4276
|
}
|
|
@@ -4308,10 +4353,10 @@ function rawSpot(base, id) {
|
|
|
4308
4353
|
function build(state, dragged, options) {
|
|
4309
4354
|
const seen = solve(state, options.previous ? { previous: options.previous } : {});
|
|
4310
4355
|
const { targets: ts, refusals: rs, places } = targetsAndRefusals(state, dragged, options);
|
|
4311
|
-
const own =
|
|
4356
|
+
const { own, lift } = liftIn(state, seen, dragged, options.previous ? { previous: options.previous } : {});
|
|
4312
4357
|
const ownEdge = own && !own.floating && !own.inMenu ? own.edge : void 0;
|
|
4313
4358
|
const pitch = options.pitch === void 0 ? SPOT_PITCH : options.pitch;
|
|
4314
|
-
const
|
|
4359
|
+
const grab = grabOf(lift, options.grab, options.onGrabNote);
|
|
4315
4360
|
const raws = [];
|
|
4316
4361
|
const axisOfEdge = (id) => {
|
|
4317
4362
|
const e = state.edges.find((x) => x.id === id);
|
|
@@ -4324,7 +4369,7 @@ function build(state, dragged, options) {
|
|
|
4324
4369
|
if (p.kind === "gap" || p.kind === "home" && ownEdge) {
|
|
4325
4370
|
const edge = p.kind === "gap" ? p.edge : ownEdge;
|
|
4326
4371
|
const axis = axisOfEdge(edge);
|
|
4327
|
-
const layout = p.kind === "home" ? seen : t.after(
|
|
4372
|
+
const layout = p.kind === "home" ? seen : t.after(ORIGIN2).layout;
|
|
4328
4373
|
const landing = p.kind === "home" ? own.rect : layout.items[dragged]?.rect;
|
|
4329
4374
|
if (!landing) continue;
|
|
4330
4375
|
const zone = p.kind === "gap" ? p.zone : own?.zone ?? "start";
|
|
@@ -4332,7 +4377,7 @@ function build(state, dragged, options) {
|
|
|
4332
4377
|
const id = n.before === "^" && n.next === "$" ? `${edge}/${zone}` : `${edge}/${zone}/${n.before}|${n.next}`;
|
|
4333
4378
|
raws.push({ lane: edge, edge, axis, id, ...n, landing, layout, target: t, hit: t.hit, ...p.kind === "home" ? { home: true } : {} });
|
|
4334
4379
|
} else if (p.kind === "column" || p.kind === "rail") {
|
|
4335
|
-
const layout = t.after(
|
|
4380
|
+
const layout = t.after(ORIGIN2).layout;
|
|
4336
4381
|
const landing = layout.items[dragged]?.rect;
|
|
4337
4382
|
if (!landing) continue;
|
|
4338
4383
|
const lane = p.kind === "column" ? `column:${p.side}:${columnKey(p.side, p.ring)}` : `rail:${p.side}`;
|
|
@@ -4342,11 +4387,13 @@ function build(state, dragged, options) {
|
|
|
4342
4387
|
}
|
|
4343
4388
|
const lifted = liftedLayout(state, dragged, options);
|
|
4344
4389
|
if (options.stretchPositions !== "pitched") {
|
|
4345
|
-
const { spots, absorbed } = slidingSpots(state, dragged, options, seen, lifted, raws, pitch > 0 ? pitch : SPOT_PITCH, grabResolver(lift));
|
|
4390
|
+
const { spots, absorbed } = slidingSpots(state, dragged, options, seen, lifted, raws, pitch > 0 ? pitch : SPOT_PITCH, grabResolver(lift, options.grab));
|
|
4346
4391
|
for (let i = raws.length - 1; i >= 0; i--) if (absorbed.has(raws[i])) raws.splice(i, 1);
|
|
4347
4392
|
raws.push(...spots);
|
|
4348
4393
|
} else if (pitch > 0) raws.push(...pitchedSpots(state, dragged, options, seen, lifted, raws, pitch));
|
|
4349
4394
|
raws.push(...takeoverSpots(state, dragged, options, seen, lifted, raws, pitch > 0 ? pitch : SPOT_PITCH));
|
|
4395
|
+
const reads = readerOf(lift, grab, dragged, options);
|
|
4396
|
+
raws.forEach((r, i) => raws[i] = { ...r, target: withGrab(r.target, reads) });
|
|
4350
4397
|
const byLane = /* @__PURE__ */ new Map();
|
|
4351
4398
|
for (const r of raws) byLane.set(r.lane, [...byLane.get(r.lane) ?? [], r]);
|
|
4352
4399
|
const halves = new Set(state.edges.filter(cutsByHalves).map((e) => e.id));
|
|
@@ -4360,7 +4407,6 @@ function build(state, dragged, options) {
|
|
|
4360
4407
|
gap: (edge) => nonNeg2(state.edges.find((e) => e.id === edge)?.gap),
|
|
4361
4408
|
crossing: (edge, over2) => state.edges.filter((e) => e.id !== edge && byLane.has(e.id) && (over2.edges[e.id]?.cross ?? 0) > EPS24 && axisOfEdge(e.id) !== axisOfEdge(edge)).map((e) => over2.edges[e.id].rect)
|
|
4362
4409
|
};
|
|
4363
|
-
const grab = grabOf(lift, options.grab, options.onGrabNote);
|
|
4364
4410
|
const heldAt = /* @__PURE__ */ new WeakMap();
|
|
4365
4411
|
const held = (r, end) => {
|
|
4366
4412
|
let both = heldAt.get(r);
|
|
@@ -4830,7 +4876,7 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample, grabs
|
|
|
4830
4876
|
const k = `${r ? "dock " : ""}${Math.round(x0 * 1e3) / 1e3}`;
|
|
4831
4877
|
const known = results.get(k);
|
|
4832
4878
|
if (known) return known;
|
|
4833
|
-
const result = r ? r.target.after(
|
|
4879
|
+
const result = r ? r.target.after(ORIGIN2) : (land(x0) ?? range.nearest(x0)).result;
|
|
4834
4880
|
results.set(k, result);
|
|
4835
4881
|
return result;
|
|
4836
4882
|
};
|
|
@@ -4847,7 +4893,7 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample, grabs
|
|
|
4847
4893
|
const cross = restLaid?.rect ?? landing;
|
|
4848
4894
|
const inStretch = axis === "x" ? { width: w, height: cross.height } : { width: cross.width, height: w };
|
|
4849
4895
|
const aimed = /* @__PURE__ */ new Map();
|
|
4850
|
-
const
|
|
4896
|
+
const withGrab2 = (r, g, x0) => {
|
|
4851
4897
|
const k = `${Math.round(x0 * 1e3) / 1e3} ${g.x} ${g.y}`;
|
|
4852
4898
|
let out = aimed.get(k);
|
|
4853
4899
|
if (!out || out.state !== r.state) aimed.set(k, out = { ...r, grab: g });
|
|
@@ -4867,7 +4913,7 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample, grabs
|
|
|
4867
4913
|
return { x0, r: commitAt(x0) };
|
|
4868
4914
|
};
|
|
4869
4915
|
const { result, grab: g } = aimOnce(grabs(grab), "lane", { laid: restLaid, size: inStretch }, aimAt, (a) => a.r.layout.items[dragged], (l) => sizeOf(l.rect));
|
|
4870
|
-
return
|
|
4916
|
+
return withGrab2(result.r, g, result.x0);
|
|
4871
4917
|
}
|
|
4872
4918
|
};
|
|
4873
4919
|
const zone = zones[0];
|
|
@@ -4928,7 +4974,7 @@ function trimmedBy(marks, cs) {
|
|
|
4928
4974
|
return [{ ...m, rect: pieces.reduce((a, p) => area8(p) > area8(a) ? p : a) }];
|
|
4929
4975
|
});
|
|
4930
4976
|
}
|
|
4931
|
-
var
|
|
4977
|
+
var ORIGIN3 = { x: 0, y: 0 };
|
|
4932
4978
|
function dockDrag(state, dragged, options = {}) {
|
|
4933
4979
|
const base = baseOf(state, dragged, options);
|
|
4934
4980
|
const regions = { ...base.regions, lanes: base.lanes };
|
|
@@ -4937,12 +4983,8 @@ function dockDrag(state, dragged, options = {}) {
|
|
|
4937
4983
|
const fixed = /* @__PURE__ */ new Map();
|
|
4938
4984
|
const axisOf2 = new Map(base.lanes.map((l) => [l.id, l.axis]));
|
|
4939
4985
|
const flat = (ls) => ls.flatMap((l) => l.marks.map((m) => ({ ...m, lane: l.lane })));
|
|
4940
|
-
const
|
|
4941
|
-
|
|
4942
|
-
if (laid2) return base.grab(laid2, sizeOf(laid2.rect), lift ? "lift" : laid2.floating ? "float" : "lane");
|
|
4943
|
-
return grab && typeof grab !== "function" ? { x: grab.x, y: grab.y } : ORIGIN2;
|
|
4944
|
-
};
|
|
4945
|
-
const rest = { state, layout: base.seen, landing: null, grab: grabIn(base.seen, true), marks: flat(base.lanes.map((l) => ({ lane: l.id, axis: l.axis, marks: l.marks }))) };
|
|
4986
|
+
const grabHere = (layout, lift = false) => grabIn(base.grab, layout, dragged, grab, lift);
|
|
4987
|
+
const rest = { state, layout: base.seen, landing: null, grab: grabHere(base.seen, true), marks: flat(base.lanes.map((l) => ({ lane: l.id, axis: l.axis, marks: l.marks }))) };
|
|
4946
4988
|
let lastFloat = null;
|
|
4947
4989
|
const of = (result, spot) => {
|
|
4948
4990
|
const known = byResult.get(result);
|
|
@@ -4950,7 +4992,7 @@ function dockDrag(state, dragged, options = {}) {
|
|
|
4950
4992
|
const it = result.layout.items[dragged];
|
|
4951
4993
|
const landing = it && !it.inMenu && (spot ? !it.floating : it.floating) ? it.rect : null;
|
|
4952
4994
|
const spots = spot ? spotsIn(base, spot.lane, result.layout, dragged) : null;
|
|
4953
|
-
const out = { ...result, landing, grab: result.grab ??
|
|
4995
|
+
const out = { ...result, landing, grab: result.grab ?? grabHere(result.layout), marks: flat(marksIn(base, state, dragged, result.layout, spot ? spot.slide ? "slide" : "spot" : false, options.emptyLanes)), ...spots ? { spots } : {} };
|
|
4954
4996
|
byResult.set(result, out);
|
|
4955
4997
|
return out;
|
|
4956
4998
|
};
|
|
@@ -4968,7 +5010,7 @@ function dockDrag(state, dragged, options = {}) {
|
|
|
4968
5010
|
if (!raw) return rest;
|
|
4969
5011
|
if (raw.slide) return of(raw.target.after(held.point, grab), raw);
|
|
4970
5012
|
let a = fixed.get(held.spot);
|
|
4971
|
-
if (!a) fixed.set(held.spot, a = of(raw.target.after(
|
|
5013
|
+
if (!a) fixed.set(held.spot, a = of(raw.target.after(ORIGIN3), raw));
|
|
4972
5014
|
return a;
|
|
4973
5015
|
};
|
|
4974
5016
|
const createdMemo = /* @__PURE__ */ new Map();
|
|
@@ -4983,7 +5025,7 @@ function dockDrag(state, dragged, options = {}) {
|
|
|
4983
5025
|
const landingOf = (held) => after(held).landing;
|
|
4984
5026
|
const spotsOf = (spot) => {
|
|
4985
5027
|
const raw = rawSpot(base, spot);
|
|
4986
|
-
return raw && !raw.slide ? after({ kind: "spot", spot, point:
|
|
5028
|
+
return raw && !raw.slide ? after({ kind: "spot", spot, point: ORIGIN3 }).spots ?? null : raw ? spotsIn(base, raw.lane, raw.layout, dragged) : null;
|
|
4987
5029
|
};
|
|
4988
5030
|
const screenOf = (frame) => {
|
|
4989
5031
|
const held = after(frame.held);
|
|
@@ -5104,4 +5146,4 @@ export {
|
|
|
5104
5146
|
HATCH_EDGE,
|
|
5105
5147
|
dockDrag
|
|
5106
5148
|
};
|
|
5107
|
-
//# sourceMappingURL=chunk-
|
|
5149
|
+
//# sourceMappingURL=chunk-AX6OK7XQ.js.map
|