@n-uf/docking 26.11.55 → 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/CHANGELOG.md +72 -0
- package/dist/{chunk-4V35LE5X.js → chunk-FSNFXRYM.js} +226 -144
- package/dist/chunk-FSNFXRYM.js.map +1 -0
- package/dist/{drag-yfr_Ng9Q.d.ts → drag-CbIEY9Zm.d.ts} +71 -9
- package/dist/index.d.ts +5 -3
- package/dist/index.js +1 -1
- package/dist/testing.d.ts +9 -3
- package/dist/testing.js +6 -7
- package/dist/testing.js.map +1 -1
- package/package.json +4 -4
- package/dist/chunk-4V35LE5X.js.map +0 -1
|
@@ -429,7 +429,7 @@ import { cutEdges } from "@n-uf/placement/stack";
|
|
|
429
429
|
|
|
430
430
|
// src/solve/draft.ts
|
|
431
431
|
import { EPS as EPS2, rect } from "@n-uf/placement";
|
|
432
|
-
import { formMain, wrapLines } from "@n-uf/placement/stack";
|
|
432
|
+
import { formMain, itemSteps, wrapLines } from "@n-uf/placement/stack";
|
|
433
433
|
function createDraft(given, options, caps = /* @__PURE__ */ new Map()) {
|
|
434
434
|
const previous = options.previous;
|
|
435
435
|
const opened = /* @__PURE__ */ new Set();
|
|
@@ -483,7 +483,7 @@ function zoneStarts(state, fit, input) {
|
|
|
483
483
|
const at = (r) => column ? r.y : r.x;
|
|
484
484
|
const out = /* @__PURE__ */ new Map();
|
|
485
485
|
const lengths = /* @__PURE__ */ new Map();
|
|
486
|
-
const drawn = fit.items.filter((p) => p.
|
|
486
|
+
const drawn = fit.items.filter((p) => !fit.menu?.items.includes(p.id));
|
|
487
487
|
for (const p of drawn) {
|
|
488
488
|
out.set(p.id, at(p.rect));
|
|
489
489
|
lengths.set(p.id, column ? p.rect.height : p.rect.width);
|
|
@@ -500,7 +500,7 @@ function zoneStarts(state, fit, input) {
|
|
|
500
500
|
const title = column ? void 0 : s.find((p) => {
|
|
501
501
|
const it = state.items[p.id];
|
|
502
502
|
const f = formsOf(it, "row")[p.form];
|
|
503
|
-
return it
|
|
503
|
+
return !itemSteps(it) && f?.main.grows && len2(p) > formMain(f, "natural", fit.cross) + EPS2;
|
|
504
504
|
});
|
|
505
505
|
if (title) lengths.set(title.id, formMain(formsOf(state.items[title.id], "row")[title.form], "natural", fit.cross));
|
|
506
506
|
const used = drawn.reduce((sum, p) => sum + len2(p), 0) + Math.max(0, drawn.length - 1) * gap;
|
|
@@ -557,7 +557,7 @@ function emit(d, edge, r, solved, extra = {}) {
|
|
|
557
557
|
for (const id of solved.leftOutIcons ?? []) notes.push({ code: "no-icons-form", edge: edge.id, id });
|
|
558
558
|
for (const p of stack.items) {
|
|
559
559
|
const it = state.items[p.id];
|
|
560
|
-
const inMenu = p.
|
|
560
|
+
const inMenu = !!stack.menu?.items.includes(p.id);
|
|
561
561
|
const drawnRect2 = toStage(p.rect, inMenu ? void 0 : p.id);
|
|
562
562
|
const f = formsOf(it, column ? "column" : "row")[p.form];
|
|
563
563
|
const shape = inMenu ? {} : shapeOf(f, drawnRect2, column ? "column" : "row", stack.cross);
|
|
@@ -598,7 +598,7 @@ function emit(d, edge, r, solved, extra = {}) {
|
|
|
598
598
|
|
|
599
599
|
// src/solve/edge.ts
|
|
600
600
|
import { EPS as EPS3 } from "@n-uf/placement";
|
|
601
|
-
import { fitStack, formCompact, formCrossMin as formCrossMin2, formSetsCross as formSetsCross2 } from "@n-uf/placement/stack";
|
|
601
|
+
import { fitStack, formCompact, formCrossMin as formCrossMin2, formMenu, formSetsCross as formSetsCross2, itemSteps as itemSteps2 } from "@n-uf/placement/stack";
|
|
602
602
|
var stackItemOf = (item, forms, edge, from) => ({
|
|
603
603
|
id: item.id,
|
|
604
604
|
forms,
|
|
@@ -607,12 +607,13 @@ var stackItemOf = (item, forms, edge, from) => ({
|
|
|
607
607
|
// Where its ladder starts: as asked, else its hand fold resolved on this axis (`startOf`: its folded form).
|
|
608
608
|
...from !== void 0 ? { from } : startOf(item, forms, edge) > 0 ? { from: startOf(item, forms, edge) } : {},
|
|
609
609
|
...item.fixed ? { fixed: true } : {},
|
|
610
|
+
...item.fixed && item.stepping ? { stepping: true } : {},
|
|
610
611
|
...item.lengths ? { lengths: item.lengths } : {}
|
|
611
612
|
});
|
|
612
613
|
var inputs = /* @__PURE__ */ new WeakMap();
|
|
613
614
|
var inputOf = (stack) => inputs.get(stack);
|
|
614
615
|
function hasSetter(fit, forms) {
|
|
615
|
-
return fit.items.some((p) => p.
|
|
616
|
+
return fit.items.some((p) => !formMenu(forms(p.id)[p.form]) && formSetsCross2(forms(p.id)[p.form]));
|
|
616
617
|
}
|
|
617
618
|
var TRAY_RANK = 100;
|
|
618
619
|
var startsOf = (input) => new Map(input.items.map((i) => [i.id, i.from ?? 0]));
|
|
@@ -632,7 +633,7 @@ function compactEdge(f) {
|
|
|
632
633
|
function railEdge(f, free, asStackItem, starts) {
|
|
633
634
|
const { state, edge, formsById } = f;
|
|
634
635
|
const railIndex = (item, forms) => {
|
|
635
|
-
if (item
|
|
636
|
+
if (!itemSteps2(item)) return -1;
|
|
636
637
|
for (let j = startOf(item, forms, edge); j < forms.length; j++) if (forms[j].kind === "rail") return j;
|
|
637
638
|
return -1;
|
|
638
639
|
};
|
|
@@ -717,8 +718,8 @@ function solveEdgeStack(state, edge, ids, length, room, previous) {
|
|
|
717
718
|
let moved = false;
|
|
718
719
|
const items = input.items.map((it) => {
|
|
719
720
|
const from = it.from ?? 0;
|
|
720
|
-
if (it
|
|
721
|
-
const j = it.forms.findIndex((f, k) => k > from && f
|
|
721
|
+
if (!itemSteps2(it) || fits(it.forms[from])) return it;
|
|
722
|
+
const j = it.forms.findIndex((f, k) => k > from && !formMenu(f) && fits(f));
|
|
722
723
|
if (j < 0) return it;
|
|
723
724
|
moved = true;
|
|
724
725
|
return { ...it, from: j };
|
|
@@ -730,7 +731,7 @@ function solveEdgeStack(state, edge, ids, length, room, previous) {
|
|
|
730
731
|
}
|
|
731
732
|
const size = edge.size;
|
|
732
733
|
if (typeof size === "number" && Number.isFinite(size) && hasSetter(free, formsById)) {
|
|
733
|
-
const setters = free.items.filter((p) => p.
|
|
734
|
+
const setters = free.items.filter((p) => !formMenu(formsById(p.id)[p.form]) && formSetsCross2(formsById(p.id)[p.form]));
|
|
734
735
|
const lo2 = Math.max(px(edge.cross.min), ...setters.map((p) => formCrossMin2(formsById(p.id)[p.form])));
|
|
735
736
|
const s = Math.min(Math.max(size, lo2), Math.max(lo2, maxOf), room);
|
|
736
737
|
if (Math.abs(s - free.cross) > EPS3) {
|
|
@@ -743,20 +744,20 @@ function solveEdgeStack(state, edge, ids, length, room, previous) {
|
|
|
743
744
|
}
|
|
744
745
|
|
|
745
746
|
// src/solve/bars.ts
|
|
746
|
-
function cutEdge(d, edge,
|
|
747
|
+
function cutEdge(d, edge, area8, cut2) {
|
|
747
748
|
const column = axisOf(edge.side) === "column";
|
|
748
|
-
const length = column ?
|
|
749
|
-
const room = Math.max(0, column ?
|
|
749
|
+
const length = column ? area8.height : area8.width;
|
|
750
|
+
const room = Math.max(0, column ? area8.width : area8.height);
|
|
750
751
|
const cap = d.caps.get(edge.id);
|
|
751
752
|
const solvedAs = cap === void 0 ? edge : { ...edge, cross: { ...edge.cross, max: Math.min(edge.cross.max, cap) } };
|
|
752
753
|
const solved = solveEdge(d.state, solvedAs, d.owned.get(edge), length, room, d.prevEdge(edge));
|
|
753
|
-
const band = cutEdges(
|
|
754
|
+
const band = cutEdges(area8, [{ id: edge.id, side: edge.side, size: solved.stack.items.length === 0 ? 0 : solved.stack.cross }]);
|
|
754
755
|
emit(d, edge, band.bands[edge.id], solved);
|
|
755
|
-
return cut2 ? band.rest :
|
|
756
|
+
return cut2 ? band.rest : area8;
|
|
756
757
|
}
|
|
757
758
|
|
|
758
759
|
// src/solve/floats.ts
|
|
759
|
-
import { EPS as EPS4, rect as rect2 } from "@n-uf/placement";
|
|
760
|
+
import { EPS as EPS4, clampInto as clampInto2, overlaps, rect as rect2 } from "@n-uf/placement";
|
|
760
761
|
import { fitFloat, formFolded as formFolded2 } from "@n-uf/placement/stack";
|
|
761
762
|
var sinceOf = (f) => isSince(f.since) ? f.since : 0;
|
|
762
763
|
function anchored(content, w, h, given) {
|
|
@@ -813,7 +814,26 @@ function fitBeside(want, region, avoid, earlier) {
|
|
|
813
814
|
const both = fitFloat(want, region, [...avoid, ...earlier]);
|
|
814
815
|
return both.covers.length === 0 ? both : fitFloat(want, region, avoid);
|
|
815
816
|
}
|
|
816
|
-
function
|
|
817
|
+
function clearOfWalls(r, region, walls) {
|
|
818
|
+
const under = (c) => walls.filter((w) => overlaps(c, w, 1e-3));
|
|
819
|
+
if (under(r).length === 0) return r;
|
|
820
|
+
const pushes2 = (c) => under(c).flatMap(
|
|
821
|
+
(w) => [rect2(w.x - c.width, c.y, c.width, c.height), rect2(w.x + w.width, c.y, c.width, c.height), rect2(c.x, w.y - c.height, c.width, c.height), rect2(c.x, w.y + w.height, c.width, c.height)].map((m) => clampInto2(m, region))
|
|
822
|
+
);
|
|
823
|
+
const far = (c) => Math.abs(c.x - r.x) + Math.abs(c.y - r.y);
|
|
824
|
+
let best = null;
|
|
825
|
+
for (const a of pushes2(r))
|
|
826
|
+
for (const c of under(a).length === 0 ? [a] : pushes2(a)) if (under(c).length === 0 && (!best || far(c) < far(best) - 1e-9)) best = c;
|
|
827
|
+
return best;
|
|
828
|
+
}
|
|
829
|
+
function fitStays(want, region, avoid, docked) {
|
|
830
|
+
const walls = avoid.slice(docked).filter((w) => w.width > 0 && w.height > 0);
|
|
831
|
+
const inside = clampInto2(want, region);
|
|
832
|
+
const kept = clearOfWalls(inside, region, walls) ?? fitFloat(want, region, walls).rect;
|
|
833
|
+
const over2 = fitFloat(kept, region, avoid, { stay: true });
|
|
834
|
+
return { rect: kept, clamped: kept.x !== want.x || kept.y !== want.y, snapped: false, covers: over2.covers, searchCapped: false };
|
|
835
|
+
}
|
|
836
|
+
function placeFloat(item, f, region, avoid, content, stage, earlier = [], docked = 0) {
|
|
817
837
|
const shape = floatShape(item, f);
|
|
818
838
|
const from = shape.form;
|
|
819
839
|
const fo = f.orient ?? floatOrientOf(item);
|
|
@@ -825,7 +845,7 @@ function placeFloat(item, f, region, avoid, content, stage, earlier = []) {
|
|
|
825
845
|
const folded = !!form && formFolded2(form);
|
|
826
846
|
const h = folded ? shape.height : Math.max(floor.height, Math.min(shape.height, clear.height, cap.height));
|
|
827
847
|
const want = f.anchor ? anchored(content, w, h, f.anchor) : rect2(finite(f.rect.x, stage.x), finite(f.rect.y, stage.y), w, h);
|
|
828
|
-
const fit0 = f.anchor ? fitBeside(want, region, avoid, earlier) : fitFloat(want, region, avoid);
|
|
848
|
+
const fit0 = f.anchor ? fitBeside(want, region, avoid, earlier) : f.stays ? fitStays(want, region, avoid, docked) : fitFloat(want, region, avoid);
|
|
829
849
|
const fit = w > region.width + EPS4 ? { ...fit0, rect: rect2(region.x, fit0.rect.y, w, fit0.rect.height) } : fit0;
|
|
830
850
|
return { from, fo, form, fit };
|
|
831
851
|
}
|
|
@@ -833,6 +853,7 @@ function layFloats(d, stage, content, inset) {
|
|
|
833
853
|
const { state, notes, items, edges } = d;
|
|
834
854
|
const avoid = [];
|
|
835
855
|
for (const l of Object.values(items)) avoid.push(l.rect);
|
|
856
|
+
const docked = avoid.length;
|
|
836
857
|
for (const e of Object.values(edges)) {
|
|
837
858
|
if (axisOf(e.side) === "row" && e.cross > 0) avoid.push(e.rect);
|
|
838
859
|
if (e.menu) avoid.push(e.menu.rect);
|
|
@@ -850,13 +871,16 @@ function layFloats(d, stage, content, inset) {
|
|
|
850
871
|
}
|
|
851
872
|
const placed = /* @__PURE__ */ new Map();
|
|
852
873
|
const place = (f, earlier = []) => {
|
|
853
|
-
placed.set(f.id, placeFloat(state.items[f.id], f, floatRegion2, avoid, content, stage, earlier));
|
|
874
|
+
placed.set(f.id, placeFloat(state.items[f.id], f, floatRegion2, avoid, content, stage, earlier, docked));
|
|
854
875
|
};
|
|
855
876
|
const live = drawn.filter((f) => !noForm.has(f.id));
|
|
856
|
-
|
|
857
|
-
const
|
|
877
|
+
const own = live.filter((f) => !f.anchor);
|
|
878
|
+
for (const f of own) place(f);
|
|
858
879
|
const anchored2 = live.filter((f) => f.anchor).sort((a, b) => sinceOf(a) - sinceOf(b) || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
859
|
-
anchored2.forEach((f, i) =>
|
|
880
|
+
anchored2.forEach((f, i) => {
|
|
881
|
+
const before = own.filter((o) => sinceOf(o) < sinceOf(f)).map((o) => placed.get(o.id).fit.rect);
|
|
882
|
+
place(f, [...before, ...anchored2.slice(0, i).map((a) => placed.get(a.id).fit.rect)]);
|
|
883
|
+
});
|
|
860
884
|
const floats = [];
|
|
861
885
|
for (const f of drawn) {
|
|
862
886
|
if (noForm.has(f.id)) {
|
|
@@ -884,9 +908,9 @@ function insetOf(d) {
|
|
|
884
908
|
return { inset, docked };
|
|
885
909
|
}
|
|
886
910
|
var insideInset = (outer, inset) => rect3(outer.x + px(inset.left), outer.y + px(inset.top), Math.max(0, outer.width - px(inset.left) - px(inset.right)), Math.max(0, outer.height - px(inset.top) - px(inset.bottom)));
|
|
887
|
-
function insetReach(
|
|
888
|
-
const up =
|
|
889
|
-
const down =
|
|
911
|
+
function insetReach(area8, f) {
|
|
912
|
+
const up = area8.y <= f.outer.y + px(f.inset.top) + EPS5 ? px(f.inset.top) : 0;
|
|
913
|
+
const down = area8.y + area8.height >= f.outer.y + f.outer.height - px(f.inset.bottom) - EPS5 ? px(f.inset.bottom) : 0;
|
|
890
914
|
return { up, down };
|
|
891
915
|
}
|
|
892
916
|
|
|
@@ -913,18 +937,18 @@ import { EPS as EPS8, rect as rect5 } from "@n-uf/placement";
|
|
|
913
937
|
|
|
914
938
|
// src/solve/columns.ts
|
|
915
939
|
import { EPS as EPS7 } from "@n-uf/placement";
|
|
916
|
-
import { formCrossMin as formCrossMin3, formSetsCross as formSetsCross3 } from "@n-uf/placement/stack";
|
|
940
|
+
import { formCrossMin as formCrossMin3, formMenu as formMenu2, formSetsCross as formSetsCross3 } from "@n-uf/placement/stack";
|
|
917
941
|
var isChrome = (state, c) => !c.dyn && isSideBar(state, c.edge);
|
|
918
|
-
function columnsOf(d, sideEdges,
|
|
942
|
+
function columnsOf(d, sideEdges, area8, tall) {
|
|
919
943
|
const { state } = d;
|
|
920
944
|
return sideEdges.map((edge) => {
|
|
921
945
|
const side = edge.side;
|
|
922
|
-
const solved = solveEdge(state, edge, d.owned.get(edge), tall(edge), Math.max(0,
|
|
923
|
-
const width = solved.stack.items.length === 0 ? 0 : Math.min(solved.stack.cross,
|
|
946
|
+
const solved = solveEdge(state, edge, d.owned.get(edge), tall(edge), Math.max(0, area8.width), d.prevEdge(edge));
|
|
947
|
+
const width = solved.stack.items.length === 0 ? 0 : Math.min(solved.stack.cross, area8.width);
|
|
924
948
|
const visible = d.owned.get(edge).filter((id) => !state.items[id].closed);
|
|
925
949
|
const dyn = (edge.column === true || edge.giveWay === true) && state.rails?.[side] !== void 0 && visible.length > 0;
|
|
926
950
|
const forms = (id) => formsOf(state.items[id], "column");
|
|
927
|
-
const setters = solved.free.items.filter((p) => p.
|
|
951
|
+
const setters = solved.free.items.filter((p) => !formMenu2(forms(p.id)[p.form]) && formSetsCross3(forms(p.id)[p.form]));
|
|
928
952
|
const min = setters.length > 0 ? Math.min(width, Math.max(px(edge.cross.min), ...setters.map((p) => formCrossMin3(forms(p.id)[p.form])))) : width;
|
|
929
953
|
return {
|
|
930
954
|
edge,
|
|
@@ -940,7 +964,7 @@ function columnsOf(d, sideEdges, area7, tall) {
|
|
|
940
964
|
};
|
|
941
965
|
});
|
|
942
966
|
}
|
|
943
|
-
function giveWay(d, cols,
|
|
967
|
+
function giveWay(d, cols, area8, gutter) {
|
|
944
968
|
const { state, previous, fresh, opened } = d;
|
|
945
969
|
const ride = state.handFold === "ride";
|
|
946
970
|
const cmin = state.contentMin ? px(state.contentMin.width) : void 0;
|
|
@@ -962,7 +986,7 @@ function giveWay(d, cols, area7, gutter) {
|
|
|
962
986
|
let used = 0;
|
|
963
987
|
for (const [c, w] of widths) used += w > 0 ? w + (c.edge.outsideInset === true ? 0 : gutter) : 0;
|
|
964
988
|
for (const s of railSides) used += railW(s) + gutter;
|
|
965
|
-
let excess = cmin === void 0 ? -Infinity : floor === void 0 ? used + cmin -
|
|
989
|
+
let excess = cmin === void 0 ? -Infinity : floor === void 0 ? used + cmin - area8.width : Math.max(used - chrome + cmin, used + floor) - area8.width;
|
|
966
990
|
for (const c of shrinkOrder) {
|
|
967
991
|
if (excess <= EPS7) break;
|
|
968
992
|
const w = widths.get(c);
|
|
@@ -1002,7 +1026,7 @@ function giveWay(d, cols, area7, gutter) {
|
|
|
1002
1026
|
}
|
|
1003
1027
|
return evaluate(auto);
|
|
1004
1028
|
}
|
|
1005
|
-
function columnRoom(d, cols,
|
|
1029
|
+
function columnRoom(d, cols, area8, f) {
|
|
1006
1030
|
const { state } = d;
|
|
1007
1031
|
const cmin = state.contentMin ? px(state.contentMin.width) : void 0;
|
|
1008
1032
|
const openMin = (ids, least) => Math.max(
|
|
@@ -1023,7 +1047,7 @@ function columnRoom(d, cols, area7, f) {
|
|
|
1023
1047
|
if (cmin === void 0 || colMins.length === 0) return;
|
|
1024
1048
|
const allBars = cols.filter((c) => c.width > 0 && isChrome(state, c)).reduce((s, c) => s + c.width + (c.edge.outsideInset === true ? 0 : f.gutter), 0);
|
|
1025
1049
|
const bars = d.chromeAllowance === void 0 ? allBars : allBars - Math.min(allBars, d.chromeAllowance);
|
|
1026
|
-
const width =
|
|
1050
|
+
const width = area8.width - bars - (state.insetWhen === "docked" && !f.docked ? px(state.inset?.left) + px(state.inset?.right) : 0);
|
|
1027
1051
|
const need = cmin + Math.min(...colMins) + f.gutter;
|
|
1028
1052
|
d.columnRoom = width >= need - EPS7;
|
|
1029
1053
|
if (!d.columnRoom) d.notes.push({ code: "no-column-room", width, need });
|
|
@@ -1130,26 +1154,26 @@ function layRail(d, side, railRect, railed, g) {
|
|
|
1130
1154
|
}
|
|
1131
1155
|
|
|
1132
1156
|
// src/solve/sides.ts
|
|
1133
|
-
function laySides(d, sideEdges,
|
|
1134
|
-
const H =
|
|
1135
|
-
const reach = insetReach(
|
|
1157
|
+
function laySides(d, sideEdges, area8, f) {
|
|
1158
|
+
const H = area8.height;
|
|
1159
|
+
const reach = insetReach(area8, f);
|
|
1136
1160
|
const tall = (edge) => H + (edge.outsideInset === true ? reach.up + reach.down : 0);
|
|
1137
|
-
const cols = columnsOf(d, sideEdges,
|
|
1138
|
-
const g = giveWay(d, cols,
|
|
1139
|
-
columnRoom(d, cols,
|
|
1161
|
+
const cols = columnsOf(d, sideEdges, area8, tall);
|
|
1162
|
+
const g = giveWay(d, cols, area8, f.gutter);
|
|
1163
|
+
columnRoom(d, cols, area8, f);
|
|
1140
1164
|
giveWayNotes(d, g, cols);
|
|
1141
|
-
const walk = { x0:
|
|
1142
|
-
for (const side of ["left", "right"]) laySide(d, side, cols, g,
|
|
1143
|
-
return rect5(walk.x0,
|
|
1165
|
+
const walk = { x0: area8.x, x1: area8.x + area8.width };
|
|
1166
|
+
for (const side of ["left", "right"]) laySide(d, side, cols, g, area8, f, walk, reach.up, tall);
|
|
1167
|
+
return rect5(walk.x0, area8.y, Math.max(0, walk.x1 - walk.x0), H);
|
|
1144
1168
|
}
|
|
1145
1169
|
function forced(d, c, length, w) {
|
|
1146
1170
|
const edge = { ...c.edge, cross: { ...c.edge.cross, min: w, max: w } };
|
|
1147
1171
|
const { size: _s, ...plain } = edge;
|
|
1148
1172
|
return solveEdge(d.state, plain, d.owned.get(c.edge), length, w, d.prevEdge(c.edge));
|
|
1149
1173
|
}
|
|
1150
|
-
function laySide(d, side, cols, g,
|
|
1174
|
+
function laySide(d, side, cols, g, area8, f, walk, upInset, tall) {
|
|
1151
1175
|
const { state, edges } = d;
|
|
1152
|
-
const H =
|
|
1176
|
+
const H = area8.height;
|
|
1153
1177
|
const outsideSideBar = (c) => c.width > 0 && isOutsideSideBar(state, c.edge) && !g.railed(c) && !g.riding(c);
|
|
1154
1178
|
const all = cols.filter((c) => c.side === side);
|
|
1155
1179
|
const mine = [...all.filter(outsideSideBar), ...all.filter((c) => !outsideSideBar(c))];
|
|
@@ -1164,7 +1188,7 @@ function laySide(d, side, cols, g, area7, f, walk, upInset, tall) {
|
|
|
1164
1188
|
let railPlace = null;
|
|
1165
1189
|
const placeRail = () => {
|
|
1166
1190
|
const lead = barLaid ? gap : 0;
|
|
1167
|
-
return side === "left" ? rect5(walk.x0 - lead,
|
|
1191
|
+
return side === "left" ? rect5(walk.x0 - lead, area8.y, railW, H) : rect5(walk.x1 + lead - railW, area8.y, railW, H);
|
|
1168
1192
|
};
|
|
1169
1193
|
for (const c of mine) {
|
|
1170
1194
|
if (!railPlace && !outsideSideBar(c)) {
|
|
@@ -1181,7 +1205,7 @@ function laySide(d, side, cols, g, area7, f, walk, upInset, tall) {
|
|
|
1181
1205
|
if (outsideSideBar(c)) barLaid = true;
|
|
1182
1206
|
const base = { side: c.edge.side, ring: finite(c.edge.ring, 0), cross: 0, menu: null, items: zoneSorted(state, c.visible), tabs: [], stack: c.solved.stack, free: c.solved.free };
|
|
1183
1207
|
if (g.railed(c)) {
|
|
1184
|
-
edges[c.edge.id] = { ...base, rect: rect5(railRect.x,
|
|
1208
|
+
edges[c.edge.id] = { ...base, rect: rect5(railRect.x, area8.y, 0, H), folded: g.auto.has(c) ? "auto" : "hand" };
|
|
1185
1209
|
continue;
|
|
1186
1210
|
}
|
|
1187
1211
|
if (g.riding(c)) continue;
|
|
@@ -1190,7 +1214,7 @@ function laySide(d, side, cols, g, area7, f, walk, upInset, tall) {
|
|
|
1190
1214
|
let solved = top > 0 || Math.abs(w - c.width) > EPS8 ? forced(d, c, H - top, w) : c.solved;
|
|
1191
1215
|
let r;
|
|
1192
1216
|
if (c.edge.outsideInset === true) {
|
|
1193
|
-
const y0 =
|
|
1217
|
+
const y0 = area8.y - upInset;
|
|
1194
1218
|
const h = tall(c.edge);
|
|
1195
1219
|
if (side === "left") {
|
|
1196
1220
|
r = rect5(walk.x0 - gap, y0, w, h);
|
|
@@ -1201,18 +1225,18 @@ function laySide(d, side, cols, g, area7, f, walk, upInset, tall) {
|
|
|
1201
1225
|
}
|
|
1202
1226
|
if (Math.abs(h - H) > EPS8 || Math.abs(w - c.width) > EPS8) solved = forced(d, c, h, w);
|
|
1203
1227
|
} else if (side === "left") {
|
|
1204
|
-
r = rect5(walk.x0,
|
|
1228
|
+
r = rect5(walk.x0, area8.y + top, w, H - top);
|
|
1205
1229
|
walk.x0 += w > 0 ? w + f.gutter : 0;
|
|
1206
1230
|
if (w > 0) gap = f.gutter;
|
|
1207
1231
|
} else {
|
|
1208
1232
|
walk.x1 -= w;
|
|
1209
|
-
r = rect5(walk.x1,
|
|
1233
|
+
r = rect5(walk.x1, area8.y + top, w, H - top);
|
|
1210
1234
|
walk.x1 -= w > 0 ? f.gutter : 0;
|
|
1211
1235
|
if (w > 0) gap = f.gutter;
|
|
1212
1236
|
}
|
|
1213
1237
|
emit(d, c.edge, r, solved, w < c.width - EPS8 ? { shrunk: true } : {});
|
|
1214
1238
|
}
|
|
1215
|
-
if (host && riders.length > 0) layRiders(d, host, riders,
|
|
1239
|
+
if (host && riders.length > 0) layRiders(d, host, riders, area8.y);
|
|
1216
1240
|
if (railRect) layRail(d, side, railRect, railed, g);
|
|
1217
1241
|
if (state.rails?.[side]) d.railPlaces[side] = railPlace ?? placeRail();
|
|
1218
1242
|
}
|
|
@@ -1234,7 +1258,7 @@ function solveState(given, options) {
|
|
|
1234
1258
|
const l = way ? lay(way.caps, way.notes) : first;
|
|
1235
1259
|
return ignored.length === 0 ? l : { ...l, notes: [...l.notes, ...ignored.map((edge) => ({ code: "show-in-ignored", edge }))] };
|
|
1236
1260
|
}
|
|
1237
|
-
var withHeightOf = (
|
|
1261
|
+
var withHeightOf = (area8, over2) => rect6(over2.x, area8.y, over2.width, area8.height);
|
|
1238
1262
|
function layOut(given, options, caps, gave) {
|
|
1239
1263
|
const d = createDraft(given, options, caps);
|
|
1240
1264
|
const { state, order } = d;
|
|
@@ -1244,12 +1268,12 @@ function layOut(given, options, caps, gave) {
|
|
|
1244
1268
|
const outsideBar = (e) => !isSide(e) && e.span !== "between" && e.outsideInset === true;
|
|
1245
1269
|
let outer = stage;
|
|
1246
1270
|
for (const e of reserved) if (outsideBar(e)) outer = cutEdge(d, e, outer, true);
|
|
1247
|
-
let
|
|
1248
|
-
for (const e of reserved) if (!isSide(e) && e.span !== "between" && !outsideBar(e))
|
|
1249
|
-
const wide =
|
|
1250
|
-
|
|
1251
|
-
for (const e of reserved) if (!isSide(e) && e.span === "between")
|
|
1252
|
-
const content =
|
|
1271
|
+
let area8 = insideInset(outer, inset);
|
|
1272
|
+
for (const e of reserved) if (!isSide(e) && e.span !== "between" && !outsideBar(e)) area8 = cutEdge(d, e, area8, true);
|
|
1273
|
+
const wide = area8;
|
|
1274
|
+
area8 = laySides(d, reserved.filter(isSide), area8, { inset, gutter: px(state.gutter), docked, outer });
|
|
1275
|
+
for (const e of reserved) if (!isSide(e) && e.span === "between") area8 = cutEdge(d, e, area8, true);
|
|
1276
|
+
const content = area8;
|
|
1253
1277
|
let over2 = content;
|
|
1254
1278
|
for (const e of order) {
|
|
1255
1279
|
if (e.mode !== "overlay") continue;
|
|
@@ -1319,7 +1343,7 @@ function resetLengths(state, edgeId) {
|
|
|
1319
1343
|
}
|
|
1320
1344
|
|
|
1321
1345
|
// src/changes.ts
|
|
1322
|
-
import { clampInto as
|
|
1346
|
+
import { clampInto as clampInto3 } from "@n-uf/placement";
|
|
1323
1347
|
|
|
1324
1348
|
// src/float-resize.ts
|
|
1325
1349
|
var LIMITS = ["min", "max", "region", "docked"];
|
|
@@ -1327,14 +1351,16 @@ var EPS9 = 0.5;
|
|
|
1327
1351
|
var TOUCH = 1e-3;
|
|
1328
1352
|
var fin = (v, d) => Number.isFinite(v) ? v : d;
|
|
1329
1353
|
function floatObstacles(state, l, id) {
|
|
1330
|
-
const
|
|
1331
|
-
|
|
1354
|
+
const some = (r) => r.width > 0 && r.height > 0;
|
|
1355
|
+
const rects = [];
|
|
1356
|
+
for (const [k, p] of Object.entries(l.items)) if (k !== id && !p.floating && some(p.rect)) rects.push(p.rect);
|
|
1357
|
+
const docked = rects.length;
|
|
1332
1358
|
for (const e of Object.values(l.edges)) {
|
|
1333
|
-
if (axisOf(e.side) === "row" && e.cross > 0)
|
|
1334
|
-
if (e.menu)
|
|
1359
|
+
if (axisOf(e.side) === "row" && e.cross > 0) rects.push(e.rect);
|
|
1360
|
+
if (e.menu) rects.push(e.menu.rect);
|
|
1335
1361
|
}
|
|
1336
|
-
for (const c of keepClearFor(state, "floats"))
|
|
1337
|
-
return
|
|
1362
|
+
for (const c of keepClearFor(state, "floats")) rects.push(c);
|
|
1363
|
+
return { rects: rects.filter(some), docked };
|
|
1338
1364
|
}
|
|
1339
1365
|
function obstacleStop(drawn, obstacles, axis, drag, span) {
|
|
1340
1366
|
const none = drag === "start" ? -Infinity : Infinity;
|
|
@@ -1415,12 +1441,13 @@ function fitResize(state, id, rect19, moving) {
|
|
|
1415
1441
|
const region = floatRegion(state);
|
|
1416
1442
|
const dragX = moving.left ? "start" : moving.right ? "end" : null;
|
|
1417
1443
|
const dragY = moving.top ? "start" : moving.bottom ? "end" : null;
|
|
1418
|
-
const obstacles = floatObstacles(state, l, id);
|
|
1444
|
+
const { rects: obstacles, docked } = floatObstacles(state, l, id);
|
|
1419
1445
|
const hit = /* @__PURE__ */ new Set();
|
|
1420
|
-
const
|
|
1421
|
-
const [
|
|
1446
|
+
const stops2 = f.stays ? obstacles.slice(docked) : obstacles;
|
|
1447
|
+
const [x, width] = fitAxis(rect19.x, rect19.width, { min: min.width, max: max.width, lo: region.x, hi: region.x + region.width, stop: obstacleStop(drawn, stops2, "x", dragX ?? "end", [drawn.y, drawn.y + drawn.height]) }, dragX, hit);
|
|
1448
|
+
const [y, height] = fitAxis(rect19.y, rect19.height, { min: min.height, max: max.height, lo: region.y, hi: region.y + region.height, stop: obstacleStop(drawn, stops2, "y", dragY ?? "end", [x, x + width]) }, dragY, hit);
|
|
1422
1449
|
const { anchor: _a, ...plain } = f;
|
|
1423
|
-
const placed = placeFloat(item, { ...plain, rect: { x, y, width, height } }, region, obstacles, l.content, state.stage).fit.rect;
|
|
1450
|
+
const placed = placeFloat(item, { ...plain, rect: { x, y, width, height } }, region, obstacles, l.content, state.stage, [], docked).fit.rect;
|
|
1424
1451
|
if (Math.abs(placed.x - x) > EPS9 || Math.abs(placed.y - y) > EPS9) hit.add("docked");
|
|
1425
1452
|
if (Math.abs(placed.width - width) > EPS9 || Math.abs(placed.height - height) > EPS9) hit.add("min");
|
|
1426
1453
|
return { rect: placed, limits: LIMITS.filter((k) => hit.has(k)) };
|
|
@@ -1553,8 +1580,9 @@ function moveAmong(state, id, place, others) {
|
|
|
1553
1580
|
if (place.kind === "float") {
|
|
1554
1581
|
const out = floatAt(state, id, place.rect);
|
|
1555
1582
|
const anchor = place.anchor;
|
|
1556
|
-
|
|
1557
|
-
|
|
1583
|
+
const stays = place.stays === true && !anchor && !!place.rect;
|
|
1584
|
+
if (!anchor && !stays || out === state) return out;
|
|
1585
|
+
return { ...out, floats: out.floats.map((f) => f.id === id ? anchor ? { ...f, anchor } : { ...f, stays: true } : f) };
|
|
1558
1586
|
}
|
|
1559
1587
|
const railColumn = place.kind === "rail" ? railColumnOf(state, place.side, item.kind) : void 0;
|
|
1560
1588
|
if (railColumn) {
|
|
@@ -1593,6 +1621,18 @@ function nextSince(state) {
|
|
|
1593
1621
|
const most = state.floats.reduce((m, f) => Math.max(m, isSince(f.since) ? f.since : 0), 0);
|
|
1594
1622
|
return Math.min(most + 1, Number.MAX_SAFE_INTEGER);
|
|
1595
1623
|
}
|
|
1624
|
+
var anchoredDrawn = /* @__PURE__ */ new WeakMap();
|
|
1625
|
+
function overAnchored(state, id, r) {
|
|
1626
|
+
if (!state.floats.some((f) => f.anchor && f.id !== id)) return false;
|
|
1627
|
+
let drawn = anchoredDrawn.get(state);
|
|
1628
|
+
if (!drawn) {
|
|
1629
|
+
const l = solve(state);
|
|
1630
|
+
drawn = state.floats.filter((f) => f.anchor && l.items[f.id]?.floating).map((f) => ({ id: f.id, rect: l.items[f.id].rect }));
|
|
1631
|
+
anchoredDrawn.set(state, drawn);
|
|
1632
|
+
}
|
|
1633
|
+
const touch = 1e-3;
|
|
1634
|
+
return drawn.some((d) => d.id !== id && Math.min(r.x + r.width, d.rect.x + d.rect.width) - Math.max(r.x, d.rect.x) > touch && Math.min(r.y + r.height, d.rect.y + d.rect.height) - Math.max(r.y, d.rect.y) > touch);
|
|
1635
|
+
}
|
|
1596
1636
|
function floatAt(state, id, at, orient) {
|
|
1597
1637
|
const item = itemOf(state, id);
|
|
1598
1638
|
if (!item || item.fixed || !state.floatKinds.includes(item.kind)) return state;
|
|
@@ -1600,7 +1640,7 @@ function floatAt(state, id, at, orient) {
|
|
|
1600
1640
|
const o = orient ?? was?.orient;
|
|
1601
1641
|
const fo = o ?? floatOrientOf(item);
|
|
1602
1642
|
const size = floatSizeOf(item, fo);
|
|
1603
|
-
const since = was ? was.since : nextSince(state);
|
|
1643
|
+
const since = was && !(at && overAnchored(state, id, at)) ? was.since : nextSince(state);
|
|
1604
1644
|
const seq = since !== void 0 ? { since } : {};
|
|
1605
1645
|
const float = at ? { id, rect: { x: at.x, y: at.y, width: at.width, height: at.height }, ...o ? { orient: o } : {}, ...seq } : { id, rect: { x: 0, y: 0, width: size.width, height: size.height }, anchor: "content-top-right", ...o ? { orient: o } : {}, ...seq };
|
|
1606
1646
|
const { space: _space, ...unspaced } = item;
|
|
@@ -1679,7 +1719,8 @@ function resizeFloat(state, floatId, rect19, moving = { right: true, bottom: tru
|
|
|
1679
1719
|
const item = itemOf(state, floatId);
|
|
1680
1720
|
if (!fit || i < 0 || !item) return state;
|
|
1681
1721
|
const { anchor: _a, ...plain } = state.floats[i];
|
|
1682
|
-
const
|
|
1722
|
+
const renew = overAnchored(state, floatId, fit.rect);
|
|
1723
|
+
const float = renew ? { ...plain, rect: fit.rect, since: nextSince(state) } : { ...plain, rect: fit.rect };
|
|
1683
1724
|
const fo = float.orient ?? floatOrientOf(item);
|
|
1684
1725
|
return withItem({ ...state, floats: state.floats.map((g, k) => k === i ? float : g) }, withFloatSizes(item, { orient: fo, size: { width: fit.rect.width, height: fit.rect.height } }));
|
|
1685
1726
|
}
|
|
@@ -1721,7 +1762,7 @@ function homeFor(state, id, start) {
|
|
|
1721
1762
|
return null;
|
|
1722
1763
|
}
|
|
1723
1764
|
const f = start.floats.find((x) => x.id === id);
|
|
1724
|
-
if (f) return { kind: "float", rect: f.rect, ...f.anchor ? { anchor: f.anchor } : {} };
|
|
1765
|
+
if (f) return { kind: "float", rect: f.rect, ...f.anchor ? { anchor: f.anchor } : f.stays ? { stays: true } : {} };
|
|
1725
1766
|
return null;
|
|
1726
1767
|
}
|
|
1727
1768
|
function dockHome(state, id, start) {
|
|
@@ -1744,7 +1785,7 @@ function dockHome(state, id, start) {
|
|
|
1744
1785
|
return out === item ? moved : withItem(moved, out);
|
|
1745
1786
|
}
|
|
1746
1787
|
function clampFloat(r, stage, drawn = r) {
|
|
1747
|
-
const at =
|
|
1788
|
+
const at = clampInto3({ x: r.x, y: r.y, width: drawn.width, height: drawn.height }, stage);
|
|
1748
1789
|
return { x: at.x, y: at.y, width: r.width, height: r.height };
|
|
1749
1790
|
}
|
|
1750
1791
|
function drawnFloatSize(item, f) {
|
|
@@ -1823,7 +1864,7 @@ function storeDockState(state) {
|
|
|
1823
1864
|
edges: state.edges.map((e) => ({ id: e.id, side: e.side, ring: e.ring, items: [...e.items], ...isNum(e.size) ? { size: e.size } : {}, ...e.column === true ? { column: true } : {} })),
|
|
1824
1865
|
floats: state.floats.filter((f) => isNum(f.rect.x) && isNum(f.rect.y) && isSize(f.rect.width) && isSize(f.rect.height)).map((f) => {
|
|
1825
1866
|
const anchor = anchorOf(f.anchor);
|
|
1826
|
-
return { id: f.id, x: f.rect.x, y: f.rect.y, width: f.rect.width, height: f.rect.height, ...f.orient ? { orient: f.orient } : {}, ...anchor ? { anchor } : {}, ...isSince(f.since) ? { since: f.since } : {} };
|
|
1867
|
+
return { id: f.id, x: f.rect.x, y: f.rect.y, width: f.rect.width, height: f.rect.height, ...f.orient ? { orient: f.orient } : {}, ...anchor ? { anchor } : {}, ...isSince(f.since) ? { since: f.since } : {}, ...f.stays === true && !anchor ? { stays: true } : {} };
|
|
1827
1868
|
}),
|
|
1828
1869
|
items,
|
|
1829
1870
|
...modes ? { railModes: modes } : {}
|
|
@@ -1987,16 +2028,18 @@ function read(data, base) {
|
|
|
1987
2028
|
continue;
|
|
1988
2029
|
}
|
|
1989
2030
|
for (const k of Object.keys(f)) if (k === "pinned") drop(`pinned:${id}`);
|
|
1990
|
-
else if (!["id", "x", "y", "width", "height", "orient", "anchor", "since"].includes(k)) drop(`float:${id}:${k}`);
|
|
2031
|
+
else if (!["id", "x", "y", "width", "height", "orient", "anchor", "since", "stays"].includes(k)) drop(`float:${id}:${k}`);
|
|
1991
2032
|
const o = f.orient === "row" || f.orient === "column" ? f.orient : void 0;
|
|
1992
2033
|
if (f.orient !== void 0 && !o) drop(`float:${id}:orient`);
|
|
1993
2034
|
const a = anchorOf(f.anchor, (what) => drop(`float:${id}:anchor${what}`));
|
|
1994
2035
|
const since = isSince(f.since) ? f.since : void 0;
|
|
1995
2036
|
if (f.since !== void 0 && since === void 0) drop(`float:${id}:since`);
|
|
2037
|
+
const stays = f.stays === true && !a;
|
|
2038
|
+
if (f.stays !== void 0 && !stays) drop(`float:${id}:stays`);
|
|
1996
2039
|
placed.add(id);
|
|
1997
2040
|
const r = rect8(f.x, f.y, f.width, f.height);
|
|
1998
2041
|
const drawn = drawnFloatSize(items[id], { rect: r, ...o ? { orient: o } : {} });
|
|
1999
|
-
floats.push({ id, rect: clampFloat(r, base.stage, drawn), ...o ? { orient: o } : {}, ...a ? { anchor: a } : {}, ...since !== void 0 ? { since } : {} });
|
|
2042
|
+
floats.push({ id, rect: clampFloat(r, base.stage, drawn), ...o ? { orient: o } : {}, ...a ? { anchor: a } : {}, ...since !== void 0 ? { since } : {}, ...stays ? { stays: true } : {} });
|
|
2000
2043
|
}
|
|
2001
2044
|
const edges = [...base.edges, ...made].map((edge) => {
|
|
2002
2045
|
const stored = order.get(edge.id) ?? [];
|
|
@@ -2027,7 +2070,7 @@ function read(data, base) {
|
|
|
2027
2070
|
}
|
|
2028
2071
|
|
|
2029
2072
|
// src/targets.ts
|
|
2030
|
-
import { EPS as EPS20, PLANE, area as area6, overlaps as
|
|
2073
|
+
import { EPS as EPS20, PLANE, area as area6, clamp as clamp2, contains, overlaps as overlaps7, rect as rect17 } from "@n-uf/placement";
|
|
2031
2074
|
|
|
2032
2075
|
// src/targets/anchor.ts
|
|
2033
2076
|
import { EPS as EPS11, area, rect as rect9, subtract } from "@n-uf/placement";
|
|
@@ -2060,7 +2103,7 @@ function anchorTargets(state, dragged, options) {
|
|
|
2060
2103
|
|
|
2061
2104
|
// src/targets/edges.ts
|
|
2062
2105
|
import { EPS as EPS12, area as area2, rect as rect10 } from "@n-uf/placement";
|
|
2063
|
-
import { formCrossMin as formCrossMin4,
|
|
2106
|
+
import { formCrossMin as formCrossMin4, formMenu as formMenu3, formSetsCross as formSetsCross4, itemSteps as itemSteps3 } from "@n-uf/placement/stack";
|
|
2064
2107
|
|
|
2065
2108
|
// src/targets/kinds.ts
|
|
2066
2109
|
var COLUMN_REACH = 22;
|
|
@@ -2178,21 +2221,9 @@ function edgeSlots(c, edge, accepts) {
|
|
|
2178
2221
|
const length = len2(el.rect);
|
|
2179
2222
|
const members0 = rest.edges.find((e) => e.id === edge.id)?.items ?? [];
|
|
2180
2223
|
const slotId = (zone, k) => targetId(members0.length === 0 ? { kind: "strip", edge: edge.id, zone } : { kind: "gap", edge: edge.id, zone, at: k });
|
|
2181
|
-
const firstKind = formsOf(state.items[dragged], axisOf(edge.side))[0]?.kind;
|
|
2182
|
-
const titles = edge.items.filter((id) => base.items[id]?.edge === edge.id && base.items[id].fixed && !!formsOf(state.items[id], axisOf(edge.side))[base.items[id].form]?.main.grows);
|
|
2183
2224
|
const lands = ({ layout: after }) => {
|
|
2184
2225
|
const me = after.items[dragged];
|
|
2185
|
-
|
|
2186
|
-
if (titles.length === 0) return true;
|
|
2187
|
-
if (formsOf(state.items[dragged], axisOf(edge.side))[me.form]?.kind !== firstKind) return false;
|
|
2188
|
-
return edge.items.every((id) => {
|
|
2189
|
-
const a = after.items[id];
|
|
2190
|
-
const b = base.items[id];
|
|
2191
|
-
if (!a || !b || b.edge !== edge.id || id === dragged) return true;
|
|
2192
|
-
if (!titles.includes(id)) return a.form === b.form && !!a.inMenu === !!b.inMenu;
|
|
2193
|
-
const f = formsOf(state.items[id], axisOf(edge.side))[a.form];
|
|
2194
|
-
return !f || (column ? a.rect.height : a.rect.width) >= formMain2(f, "natural", after.edges[edge.id].cross) - 0.5;
|
|
2195
|
-
});
|
|
2226
|
+
return me.edge === edge.id && !me.inMenu;
|
|
2196
2227
|
};
|
|
2197
2228
|
const pad = { start: Math.max(0, edge.pad?.start ?? 0), end: Math.max(0, edge.pad?.end ?? 0) };
|
|
2198
2229
|
const menuLen = el.menu ? len2(el.menu.rect) : 0;
|
|
@@ -2232,7 +2263,12 @@ function edgeSlots(c, edge, accepts) {
|
|
|
2232
2263
|
const b = base.items[id];
|
|
2233
2264
|
const a = s.result.layout.items[id];
|
|
2234
2265
|
if (fixedHere(id) && !a) return true;
|
|
2235
|
-
|
|
2266
|
+
if (!isProtected(id)) return false;
|
|
2267
|
+
if (itemSteps3(state.items[id]) && (a.inMenu || b.inMenu)) {
|
|
2268
|
+
const i = members.indexOf(id);
|
|
2269
|
+
return i >= 0 && anchored2.has(id) && (zone === "end" ? k > i : k <= i);
|
|
2270
|
+
}
|
|
2271
|
+
return Math.abs(a.rect.x - b.rect.x) > 0.5 || Math.abs(a.rect.y - b.rect.y) > 0.5;
|
|
2236
2272
|
});
|
|
2237
2273
|
if (!movesFixed) slots.push(s);
|
|
2238
2274
|
}
|
|
@@ -2240,7 +2276,7 @@ function edgeSlots(c, edge, accepts) {
|
|
|
2240
2276
|
return slots;
|
|
2241
2277
|
}
|
|
2242
2278
|
function thickerThan(forms, cross) {
|
|
2243
|
-
const shown = forms.filter((f) => f
|
|
2279
|
+
const shown = forms.filter((f) => !formMenu3(f));
|
|
2244
2280
|
return shown.length > 0 && shown.every((f) => !formSetsCross4(f) && formCrossMin4(f) > cross + EPS12);
|
|
2245
2281
|
}
|
|
2246
2282
|
var roomReason = (spec, zone) => spec.refuse(zone) === "too-thick" ? "too-thick" : "no-room";
|
|
@@ -2253,7 +2289,7 @@ function edgeSpec(c, edge, as) {
|
|
|
2253
2289
|
const column = axisOf(edge.side) === "column";
|
|
2254
2290
|
const at = (r2) => column ? r2.y : r2.x;
|
|
2255
2291
|
const len2 = (r2) => column ? r2.height : r2.width;
|
|
2256
|
-
const empty = el.stack.items.every((p) => p.
|
|
2292
|
+
const empty = el.stack.items.every((p) => el.stack.menu?.items.includes(p.id)) && !el.menu;
|
|
2257
2293
|
const accepts = edgeTakes(edge, kind);
|
|
2258
2294
|
if (!accepts && (empty || area2(el.rect) <= EPS12)) return null;
|
|
2259
2295
|
if (accepts && empty && !opensEmpty(state, edge, kind)) return null;
|
|
@@ -2319,8 +2355,8 @@ function railColumnSpec(c, edge, run) {
|
|
|
2319
2355
|
}
|
|
2320
2356
|
|
|
2321
2357
|
// src/targets/filter.ts
|
|
2322
|
-
import { overlaps } from "@n-uf/placement";
|
|
2323
|
-
import { formMain as
|
|
2358
|
+
import { overlaps as overlaps2 } from "@n-uf/placement";
|
|
2359
|
+
import { formMain as formMain2, itemSteps as itemSteps4 } from "@n-uf/placement/stack";
|
|
2324
2360
|
function placeKey(s, id) {
|
|
2325
2361
|
const it = Object.hasOwn(s.items, id) ? s.items[id] : void 0;
|
|
2326
2362
|
const byZone = (items) => ZONES.flatMap((z) => items.filter((x) => zoneOf(s.items[x]) === z));
|
|
@@ -2344,15 +2380,19 @@ function soundness(state, base, dragged) {
|
|
|
2344
2380
|
if (!b.fixed) continue;
|
|
2345
2381
|
const a = after.items[id];
|
|
2346
2382
|
const e = a?.edge ? after.edges[a.edge] : void 0;
|
|
2347
|
-
if (!a || !e
|
|
2383
|
+
if (!a || !e) return false;
|
|
2384
|
+
const steps = itemSteps4(state.items[id]);
|
|
2385
|
+
if (!steps && (a.form !== b.form || a.formKind !== b.formKind)) return false;
|
|
2386
|
+
if (a.inMenu) continue;
|
|
2348
2387
|
const f = formsOf(state.items[id], axisOf(e.side))[a.form];
|
|
2349
2388
|
const len2 = axisOf(e.side) === "column" ? a.rect.height : a.rect.width;
|
|
2350
|
-
|
|
2389
|
+
const holds = !steps && f?.main.grows === true;
|
|
2390
|
+
if (f && len2 < formMain2(f, holds ? "natural" : "min", e.cross) - 0.5) return false;
|
|
2351
2391
|
}
|
|
2352
2392
|
const me = after.items[dragged];
|
|
2353
2393
|
if (!me) return true;
|
|
2354
|
-
const fixedAfter = Object.entries(after.items).filter(([id, it]) => it.fixed && id !== dragged).map(([id]) => reservedRect(state, after, id));
|
|
2355
|
-
return !chrome.some((c) =>
|
|
2394
|
+
const fixedAfter = Object.entries(after.items).filter(([id, it]) => it.fixed && !(it.inMenu && itemSteps4(state.items[id])) && id !== dragged).map(([id]) => reservedRect(state, after, id));
|
|
2395
|
+
return !chrome.some((c) => overlaps2(me.rect, c)) && !fixedAfter.some((f) => overlaps2(me.rect, f));
|
|
2356
2396
|
};
|
|
2357
2397
|
}
|
|
2358
2398
|
function context(state, dragged, options, others = []) {
|
|
@@ -2382,8 +2422,8 @@ function context(state, dragged, options, others = []) {
|
|
|
2382
2422
|
}
|
|
2383
2423
|
|
|
2384
2424
|
// src/targets/ownership.ts
|
|
2385
|
-
import { EPS as EPS15, area as area3, overlaps as
|
|
2386
|
-
import { formBody } from "@n-uf/placement/stack";
|
|
2425
|
+
import { EPS as EPS15, area as area3, overlaps as overlaps3, rect as rect12, subtract as subtract2 } from "@n-uf/placement";
|
|
2426
|
+
import { formBody, itemSteps as itemSteps5 } from "@n-uf/placement/stack";
|
|
2387
2427
|
|
|
2388
2428
|
// src/targets/meet.ts
|
|
2389
2429
|
import { EPS as EPS13, rect as rect11 } from "@n-uf/placement";
|
|
@@ -2419,7 +2459,21 @@ function ownedRectsOf(s, along2) {
|
|
|
2419
2459
|
return along2.map(([a, b]) => s.vertical ? rect12(o.x, a, o.width, b - a) : rect12(a, o.y, b - a, o.height));
|
|
2420
2460
|
}
|
|
2421
2461
|
function drawnOf(c, live) {
|
|
2422
|
-
|
|
2462
|
+
const edges = Object.entries(c.now.edges).filter(([id, e]) => area3(e.rect) > EPS15 && c.lay.has(id)).map(([id, e]) => ({ spec: live.find((s) => s.edge?.id === id) ?? null, rect: e.rect, lay: c.lay.get(id) }));
|
|
2463
|
+
const rails = ["left", "right"].flatMap((side) => {
|
|
2464
|
+
const rail = c.now.rails[side];
|
|
2465
|
+
if (!rail || rail.segments.length === 0 || area3(rail.rect) <= EPS15) return [];
|
|
2466
|
+
const spec = live.find((s) => s.kind === "railStop" && s.lay.side === side) ?? null;
|
|
2467
|
+
const lay = spec?.lay ?? { phase: EDGE_KINDS.railStop.phase, side, at: -1 };
|
|
2468
|
+
const me = c.now.items[c.dragged];
|
|
2469
|
+
const run = me?.rail === side ? rail.segments.filter((g) => g.edge === me.edge).map((g) => g.rect) : [];
|
|
2470
|
+
if (run.length === 0) return [{ spec, rect: rail.rect, lay }];
|
|
2471
|
+
const top = Math.min(...run.map((r) => r.y));
|
|
2472
|
+
const own = rect12(rail.rect.x, top, rail.rect.width, Math.max(...run.map((r) => r.y + r.height)) - top);
|
|
2473
|
+
const column = live.find((s) => s.kind === "railColumn" && s.edge?.id === me.edge);
|
|
2474
|
+
return [...subtract2(rail.rect, own).map((r) => ({ spec, rect: r, lay })), ...column ? [{ spec: column, rect: own, lay: column.lay }] : []];
|
|
2475
|
+
});
|
|
2476
|
+
return [...edges, ...rails];
|
|
2423
2477
|
}
|
|
2424
2478
|
function homeRectOf(c, ownSpec) {
|
|
2425
2479
|
const own = c.now.items[c.dragged];
|
|
@@ -2534,7 +2588,7 @@ function ownership(c, live, alongOf) {
|
|
|
2534
2588
|
const b = bandOf(s);
|
|
2535
2589
|
const along2 = (r) => s.vertical ? [r.y, r.y + r.height] : [r.x, r.x + r.width];
|
|
2536
2590
|
const across2 = (r) => s.vertical ? [r.x, r.x + r.width] : [r.y, r.y + r.height];
|
|
2537
|
-
const rs = taken.get(s).filter((r) =>
|
|
2591
|
+
const rs = taken.get(s).filter((r) => overlaps3(r, b));
|
|
2538
2592
|
const ends = [.../* @__PURE__ */ new Set([...along2(b), ...rs.flatMap(along2)])].filter((x) => x >= along2(b)[0] && x <= along2(b)[1]).sort((p, q) => p - q);
|
|
2539
2593
|
const owned = [];
|
|
2540
2594
|
for (let k = 1; k < ends.length; k++) {
|
|
@@ -2566,7 +2620,7 @@ function ownership(c, live, alongOf) {
|
|
|
2566
2620
|
const e = it.edge ? now.edges[it.edge] : void 0;
|
|
2567
2621
|
return !!e && !!formsOf(state.items[id], axisOf(e.side))[it.form]?.main.grows;
|
|
2568
2622
|
};
|
|
2569
|
-
const solid = Object.entries(now.items).filter(([id, it]) => it.fixed && !grows(id)).map(([, it]) => it.rect);
|
|
2623
|
+
const solid = Object.entries(now.items).filter(([id, it]) => it.fixed && !grows(id) && !(it.inMenu && itemSteps5(state.items[id]))).map(([, it]) => it.rect);
|
|
2570
2624
|
const bodies = (s) => {
|
|
2571
2625
|
const e = s.edge;
|
|
2572
2626
|
if (!e) return [];
|
|
@@ -2585,7 +2639,7 @@ function ownership(c, live, alongOf) {
|
|
|
2585
2639
|
}
|
|
2586
2640
|
|
|
2587
2641
|
// src/targets/tiles.ts
|
|
2588
|
-
import { EPS as EPS16, area as area4, overlaps as
|
|
2642
|
+
import { EPS as EPS16, area as area4, overlaps as overlaps4, rect as rect13, subtract as subtract3 } from "@n-uf/placement";
|
|
2589
2643
|
function tilerOf(spec) {
|
|
2590
2644
|
const data = EDGE_KINDS[spec.kind];
|
|
2591
2645
|
const v = spec.vertical;
|
|
@@ -2654,7 +2708,7 @@ function reachStrips(c, spec, room, ends) {
|
|
|
2654
2708
|
const [c0, c1] = spec.across();
|
|
2655
2709
|
const bandOf2 = (a, b) => spec.vertical ? rect13(c0, a, c1 - c0, b - a) : rect13(a, c0, b - a, c1 - c0);
|
|
2656
2710
|
const across2 = c.state.edges.filter((e) => axisOf(e.side) === "column" !== spec.vertical).map((e) => c.now.edges[e.id]);
|
|
2657
|
-
const drawnBetween = (a, b) => b - a > EPS16 && across2.some((e) => !!e && e.cross > EPS16 && area4(e.rect) > EPS16 &&
|
|
2711
|
+
const drawnBetween = (a, b) => b - a > EPS16 && across2.some((e) => !!e && e.cross > EPS16 && area4(e.rect) > EPS16 && overlaps4(e.rect, bandOf2(a, b)));
|
|
2658
2712
|
const first = pieces[0][0];
|
|
2659
2713
|
const last = pieces[pieces.length - 1][1];
|
|
2660
2714
|
return {
|
|
@@ -2853,7 +2907,7 @@ function clipTiles(tiles, own, chrome, lost) {
|
|
|
2853
2907
|
}
|
|
2854
2908
|
|
|
2855
2909
|
// src/targets/rail-strip.ts
|
|
2856
|
-
import { EPS as EPS18, overlaps as
|
|
2910
|
+
import { EPS as EPS18, overlaps as overlaps5, rect as rect15, subtract as subtract4 } from "@n-uf/placement";
|
|
2857
2911
|
|
|
2858
2912
|
// src/targets/virtual.ts
|
|
2859
2913
|
import { EPS as EPS17, clamp, rect as rect14 } from "@n-uf/placement";
|
|
@@ -3071,7 +3125,7 @@ function declaredStrip(c, side, policy) {
|
|
|
3071
3125
|
slots: slots.map((s, i) => ({ id: s.id, place: s.place, along: [cuts[i], cuts[i + 1]], result: s.result }))
|
|
3072
3126
|
};
|
|
3073
3127
|
}
|
|
3074
|
-
var outside = (pieces, strips) => strips.reduce((acc, s) => acc.flatMap((p) =>
|
|
3128
|
+
var outside = (pieces, strips) => strips.reduce((acc, s) => acc.flatMap((p) => overlaps5(p, s) ? subtract4(p, s) : [p]), [...pieces]).filter((p) => p.width >= 1 && p.height >= 1);
|
|
3075
3129
|
var largest2 = (rs) => rs.reduce((m, r) => r.width * r.height > m.width * m.height ? r : m);
|
|
3076
3130
|
var sameRects = (a, b) => a.length === b.length && a.every((r, i) => r.x === b[i].x && r.y === b[i].y && r.width === b[i].width && r.height === b[i].height);
|
|
3077
3131
|
function withRailStrips(c, targets2, refusals2) {
|
|
@@ -3180,7 +3234,7 @@ var withoutHits = (t) => {
|
|
|
3180
3234
|
return rest;
|
|
3181
3235
|
};
|
|
3182
3236
|
function insideStrips(r, strips) {
|
|
3183
|
-
const s = strips.find((x) =>
|
|
3237
|
+
const s = strips.find((x) => overlaps5(x.rect, r));
|
|
3184
3238
|
if (!s) return null;
|
|
3185
3239
|
return s.side === "left" ? rect15(s.rect.x + s.rect.width, r.y, r.width, r.height) : rect15(s.rect.x - r.width, r.y, r.width, r.height);
|
|
3186
3240
|
}
|
|
@@ -3194,7 +3248,7 @@ function clearOfStrips(t, dragged, strips) {
|
|
|
3194
3248
|
let dx = 0;
|
|
3195
3249
|
for (const s of strips) {
|
|
3196
3250
|
const r = rect15(at.x + dx, at.y, at.width, at.height);
|
|
3197
|
-
if (!
|
|
3251
|
+
if (!overlaps5(r, s)) continue;
|
|
3198
3252
|
dx += s.x + s.width / 2 < r.x + r.width / 2 ? s.x + s.width - r.x : s.x - (r.x + r.width);
|
|
3199
3253
|
}
|
|
3200
3254
|
return dx === 0 ? first : t.after({ x: at.x + dx + (grab?.x ?? at.width / 2), y: point.y }, grab);
|
|
@@ -3217,7 +3271,7 @@ function kindOf(c, t) {
|
|
|
3217
3271
|
}
|
|
3218
3272
|
var largest3 = (ps) => ps.reduce((a, p) => area5(p) > area5(a) ? p : a);
|
|
3219
3273
|
var keepsMinHit = (r, m) => Math.min(r.width, r.height) >= m.across - EPS19 && Math.max(r.width, r.height) >= m.along - EPS19;
|
|
3220
|
-
var
|
|
3274
|
+
var overlaps6 = (a, b) => Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x) > EPS19 && Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y) > EPS19;
|
|
3221
3275
|
var cut = (ps, g) => ps.flatMap((p) => subtract5(p, g)).filter((p) => p.width >= 1 && p.height >= 1);
|
|
3222
3276
|
var piecesOf = (t) => t.hits ?? [t.hit];
|
|
3223
3277
|
var withPieces2 = (t, ps) => {
|
|
@@ -3239,11 +3293,11 @@ function mayGrow(c, targets2, i, grow, minOf, zone, away) {
|
|
|
3239
3293
|
const s = c.state.stage;
|
|
3240
3294
|
for (const g of grow) {
|
|
3241
3295
|
if (g.x < s.x - EPS19 || g.y < s.y - EPS19 || g.x + g.width > s.x + s.width + EPS19 || g.y + g.height > s.y + s.height + EPS19) return false;
|
|
3242
|
-
if ([...keepClearFor(c.state, "targets"), ...away].some((r) =>
|
|
3296
|
+
if ([...keepClearFor(c.state, "targets"), ...away].some((r) => overlaps6(r, g))) return false;
|
|
3243
3297
|
if (zone.reduce((ps, z) => ps.flatMap((p) => subtract5(p, z)), [g]).some((p) => area5(p) > EPS19)) return false;
|
|
3244
3298
|
}
|
|
3245
3299
|
return targets2.every((o, j) => {
|
|
3246
|
-
if (j === i || o.free || !piecesOf(o).some((p) => grow.some((g) =>
|
|
3300
|
+
if (j === i || o.free || !piecesOf(o).some((p) => grow.some((g) => overlaps6(p, g)))) return true;
|
|
3247
3301
|
if (o.place.kind === "home" || o.place.kind === "none" || o.strip) return false;
|
|
3248
3302
|
const m = minOf(o);
|
|
3249
3303
|
const left = grow.reduce((ps, g) => cut(ps, g), [...piecesOf(o)]);
|
|
@@ -3259,7 +3313,7 @@ function partialGrowth(c, targets2, i, l, axis, d, m, minOf, zone, away) {
|
|
|
3259
3313
|
const cuts = /* @__PURE__ */ new Set([along2[0], along2[1]]);
|
|
3260
3314
|
for (const o of targets2)
|
|
3261
3315
|
for (const p of piecesOf(o))
|
|
3262
|
-
if (
|
|
3316
|
+
if (overlaps6(p, g)) {
|
|
3263
3317
|
for (const v of axis === "x" ? [p.y, p.y + p.height] : [p.x, p.x + p.width]) if (v > along2[0] && v < along2[1]) cuts.add(v);
|
|
3264
3318
|
}
|
|
3265
3319
|
const marks = [...cuts].sort((a, b) => a - b);
|
|
@@ -3314,7 +3368,7 @@ function withMinHit(c, targets2, refusals2, zones) {
|
|
|
3314
3368
|
for (let j = 0; j < out.length; j++) {
|
|
3315
3369
|
if (j === i || out[j].free) continue;
|
|
3316
3370
|
const o = out[j];
|
|
3317
|
-
if (!piecesOf(o).some((p) => grow.some((g) =>
|
|
3371
|
+
if (!piecesOf(o).some((p) => grow.some((g) => overlaps6(p, g)))) continue;
|
|
3318
3372
|
out[j] = withPieces2(o, grow.reduce((ps, g) => cut(ps, g), [...piecesOf(o)]));
|
|
3319
3373
|
}
|
|
3320
3374
|
const g0 = grow[0];
|
|
@@ -3403,7 +3457,7 @@ var touchesSide = (stage, pieces) => pieces.some((r) => r.x <= stage.x + EPS20 |
|
|
|
3403
3457
|
function slotOverMoved(now, lifted, after, slot, dragged, onto) {
|
|
3404
3458
|
const from = now.items[dragged]?.edge;
|
|
3405
3459
|
return Object.entries(now.items).some(([id, was]) => {
|
|
3406
|
-
if (!
|
|
3460
|
+
if (!overlaps7(slot, was.rect) || id === dragged || was.floating || was.edge === onto) return false;
|
|
3407
3461
|
const r = after.items[id]?.rect;
|
|
3408
3462
|
const start = (from !== void 0 && was.edge === from ? lifted.items[id]?.rect : void 0) ?? was.rect;
|
|
3409
3463
|
return !!r && (Math.abs(r.x - start.x) > EPS20 || Math.abs(r.y - start.y) > EPS20 || Math.abs(r.width - start.width) > EPS20 || Math.abs(r.height - start.height) > EPS20);
|
|
@@ -3485,8 +3539,20 @@ function generateShown(state, dragged, options, hidden) {
|
|
|
3485
3539
|
const g = grab ?? { x: size.width / 2, y: size.height / 2 };
|
|
3486
3540
|
const raw = options.floatFromHeld ? heldRect(state, dragged, size, point, g) : rect17(point.x - g.x, point.y - g.y, size.width, size.height);
|
|
3487
3541
|
const first = solve(markUsed(floatAt(state, dragged, raw, options.floatOrient), dragged), prev);
|
|
3488
|
-
const
|
|
3489
|
-
|
|
3542
|
+
const fitted = first.items[dragged]?.rect;
|
|
3543
|
+
const at = fitted ?? raw;
|
|
3544
|
+
const placed2 = (x, y, stays) => {
|
|
3545
|
+
const s = floatAt(state, dragged, rect17(x, y, size.width, size.height), options.floatOrient);
|
|
3546
|
+
return c.settle(markUsed(stays ? { ...s, floats: s.floats.map((f) => f.id === dragged ? { ...f, stays: true } : f) } : s, dragged));
|
|
3547
|
+
};
|
|
3548
|
+
const hand = heldRect(state, dragged, fitted ?? size, point, g);
|
|
3549
|
+
const on = { x: clamp2(point.x, hand.x, hand.x + hand.width), y: clamp2(point.y, hand.y, hand.y + hand.height) };
|
|
3550
|
+
const clear = !first.notes.some((n) => n.code === "float-covers" && n.id === dragged);
|
|
3551
|
+
if (!fitted || clear && contains(fitted, on)) return placed2(at.x, at.y, false);
|
|
3552
|
+
const left = placed2(hand.x, hand.y, true);
|
|
3553
|
+
const covers = left.layout.notes.some((n) => n.code === "float-covers" && n.id === dragged);
|
|
3554
|
+
const kept = left.layout.items[dragged]?.rect ?? hand;
|
|
3555
|
+
return covers ? left : placed2(kept.x, kept.y, false);
|
|
3490
3556
|
}
|
|
3491
3557
|
});
|
|
3492
3558
|
}
|
|
@@ -3573,7 +3639,8 @@ function orderedStops(state, dragged, options) {
|
|
|
3573
3639
|
}
|
|
3574
3640
|
|
|
3575
3641
|
// src/lanes.ts
|
|
3576
|
-
import { EPS as EPS21, clamp as
|
|
3642
|
+
import { EPS as EPS21, area as area7, clamp as clamp3, rect as rect18, subtract as subtract6 } from "@n-uf/placement";
|
|
3643
|
+
import { itemSteps as itemSteps6 } from "@n-uf/placement/stack";
|
|
3577
3644
|
var SPOT_PITCH = 40;
|
|
3578
3645
|
var SNAP_DISTANCE = 8;
|
|
3579
3646
|
var STEP = 1;
|
|
@@ -3737,12 +3804,12 @@ function build(state, dragged, options) {
|
|
|
3737
3804
|
gap: (edge) => nonNeg(state.edges.find((e) => e.id === edge)?.gap),
|
|
3738
3805
|
crossing: (edge, over2) => state.edges.filter((e) => e.id !== edge && byLane.has(e.id) && (over2.edges[e.id]?.cross ?? 0) > EPS21 && axisOfEdge(e.id) !== axisOfEdge(edge)).map((e) => over2.edges[e.id].rect)
|
|
3739
3806
|
};
|
|
3740
|
-
const shareOf = (g, size) => g === void 0 || !Number.isFinite(g) || size <= EPS21 ? 0.5 :
|
|
3807
|
+
const shareOf = (g, size) => g === void 0 || !Number.isFinite(g) || size <= EPS21 ? 0.5 : clamp3(g / size, 0, 1);
|
|
3741
3808
|
const w = own?.rect.width ?? 0;
|
|
3742
3809
|
const h = own?.rect.height ?? 0;
|
|
3743
3810
|
const share = { x: w >= h ? shareOf(options.grab?.x, w) : 0.5, y: h > w ? shareOf(options.grab?.y, h) : 0.5 };
|
|
3744
3811
|
const built = [...byLane].map(([id, list]) => laneFrom(id, list, seen, seen, dragged, rs, halves.has(id), share, marking)).filter((l) => !!l);
|
|
3745
|
-
const laneList = newColumnsGiveWay(built.map((l) => settle(l, seen, state, dragged, built, options.emptyLanes)), (l) => l.id, state);
|
|
3812
|
+
const laneList = newColumnsGiveWay(built.map((l) => settle(l, seen, state, dragged, built, options.emptyLanes)), (l) => l.id, state).map((l) => clearOfRail(l, seen, byLane.get(l.id)));
|
|
3746
3813
|
const onLanes = new Set(laneList.map((l) => l.id));
|
|
3747
3814
|
const rails = Object.values(seen.rails).flatMap((r) => r && r.rect.width > EPS21 && r.rect.height > EPS21 ? [r.rect] : []);
|
|
3748
3815
|
const blocked = [
|
|
@@ -3750,6 +3817,9 @@ function build(state, dragged, options) {
|
|
|
3750
3817
|
...Object.entries(seen.items).filter(([id, it]) => id !== dragged && !it.floating && !it.inMenu).map(([, it]) => it.rect),
|
|
3751
3818
|
...keepClearFor(state, "targets"),
|
|
3752
3819
|
...rails,
|
|
3820
|
+
// A held tile's own rail: every stop is home's in `targets()`, with the new-column lines about its folded column
|
|
3821
|
+
// joined to it (the strip beside the rail). A home place takes no float, so it is blocked as `targets()` has it.
|
|
3822
|
+
...own?.rail ? ts.filter((t) => t.place.kind === "home" && parseTargetId(t.id)?.kind === "rail").flatMap((t) => t.hits ?? [t.hit]) : [],
|
|
3753
3823
|
// Spots where a release cancels (`DockState.blocked`): no float lands there.
|
|
3754
3824
|
...state.blocked ?? []
|
|
3755
3825
|
];
|
|
@@ -3773,6 +3843,15 @@ function build(state, dragged, options) {
|
|
|
3773
3843
|
}
|
|
3774
3844
|
};
|
|
3775
3845
|
}
|
|
3846
|
+
function clearOfRail(lane, seen, raws) {
|
|
3847
|
+
const place = raws?.[0]?.target.place;
|
|
3848
|
+
const rail = place?.kind === "column" ? seen.rails[place.side] : void 0;
|
|
3849
|
+
if (!rail || rail.segments.length === 0) return lane;
|
|
3850
|
+
const pieces = subtract6(lane.rect, rail.rect);
|
|
3851
|
+
if (pieces.length === 0) return lane;
|
|
3852
|
+
const largest4 = pieces.reduce((m, p) => area7(p) > area7(m) ? p : m);
|
|
3853
|
+
return largest4 === lane.rect ? lane : { ...lane, rect: largest4 };
|
|
3854
|
+
}
|
|
3776
3855
|
function laneRectOver(list, over2, marking) {
|
|
3777
3856
|
const first = list[0];
|
|
3778
3857
|
const axis = first.axis;
|
|
@@ -3830,14 +3909,14 @@ function laneFrom(id, list, drawn, seen, dragged, rs, halves, share, marking, sh
|
|
|
3830
3909
|
const across2 = (aEnd + lo(bLanding, axis)) / 2;
|
|
3831
3910
|
const overlap = lo(bLanding, axis) < aEnd - EPS21;
|
|
3832
3911
|
const slack = Math.max(0, marking.pitch) / 2;
|
|
3833
|
-
const atGrab =
|
|
3912
|
+
const atGrab = clamp3(across2 + (held - 0.5) * (len(aLanding, axis) + len(bLanding, axis)) / 2, lo(bLanding, axis) - slack, aEnd + slack);
|
|
3834
3913
|
const raw = shared ? mid(shared, axis) : overlap ? atGrab : across2;
|
|
3835
|
-
cuts.push(
|
|
3914
|
+
cuts.push(clamp3(Math.max(raw, cuts[i - 1] ?? bandStart), bandStart, bandEnd));
|
|
3836
3915
|
}
|
|
3837
3916
|
const spots = unique.flatMap((x, i) => {
|
|
3838
3917
|
const a = i === 0 ? bandStart : cuts[i - 1];
|
|
3839
3918
|
const b = i === unique.length - 1 ? bandEnd : cuts[i];
|
|
3840
|
-
const along2 = [
|
|
3919
|
+
const along2 = [clamp3(a, start, end), clamp3(b, start, end)];
|
|
3841
3920
|
return along2[1] - along2[0] > EPS21 || b - a <= EPS21 || x.home ? [{ x, along: along2 }] : [];
|
|
3842
3921
|
}).map(({ x, along: along2 }) => ({
|
|
3843
3922
|
id: x.id,
|
|
@@ -3850,7 +3929,7 @@ function laneFrom(id, list, drawn, seen, dragged, rs, halves, share, marking, sh
|
|
|
3850
3929
|
others: othersKey(x.layout, dragged)
|
|
3851
3930
|
}));
|
|
3852
3931
|
const itemLen = Math.min(...unique.map((x) => len(x.landing, axis)));
|
|
3853
|
-
const refused = first.edge ? rs.filter((f) => f.edge === first.edge).flatMap((f) => (f.hits ?? [f.hit]).map((h) => ({ along: [
|
|
3932
|
+
const refused = first.edge ? rs.filter((f) => f.edge === first.edge).flatMap((f) => (f.hits ?? [f.hit]).map((h) => ({ along: [clamp3(lo(h, axis), start, end), clamp3(lo(h, axis) + len(h, axis), start, end)], reason: f.reason }))).filter((f) => f.along[1] - f.along[0] >= itemLen - EPS21) : [];
|
|
3854
3933
|
const places = new Set(unique.map((x) => `${x.before}|${x.next}`));
|
|
3855
3934
|
const drawnEdge = first.edge ? drawn.edges[first.edge] : void 0;
|
|
3856
3935
|
const markRect = (first.edge ? drawnRect(drawn, first.edge) : void 0) ?? laneRectOver(list, drawn, marking).band ?? markBand ?? laneRect;
|
|
@@ -3894,8 +3973,8 @@ function edgeMarks(lane, laneRect, axis, items, refused, itemLen, lands, held, m
|
|
|
3894
3973
|
const ends = [{ id: "^", a: start, b: start }, ...items.map((o) => ({ id: o.id, a: lo(o.r, axis), b: lo(o.r, axis) + len(o.r, axis) })), { id: "$", a: end, b: end }];
|
|
3895
3974
|
const isRefused2 = (v) => refused.some((f) => v >= f.along[0] && v <= f.along[1]);
|
|
3896
3975
|
for (let i = 0; i + 1 < ends.length; i++) {
|
|
3897
|
-
const a =
|
|
3898
|
-
const b =
|
|
3976
|
+
const a = clamp3(ends[i].b, start, end);
|
|
3977
|
+
const b = clamp3(ends[i + 1].a, start, end);
|
|
3899
3978
|
const pair = `${ends[i].id}|${ends[i + 1].id}`;
|
|
3900
3979
|
if (ends[i + 1].a < start - EPS21 || ends[i].b > end + EPS21 || !lands(pair)) continue;
|
|
3901
3980
|
const left = ends[i].id === held ? ends[i - 1]?.id ?? "^" : ends[i].id;
|
|
@@ -3937,7 +4016,7 @@ function edgeMarks(lane, laneRect, axis, items, refused, itemLen, lands, held, m
|
|
|
3937
4016
|
function virtualMarks(lane, spots, held) {
|
|
3938
4017
|
return spots.map((s) => {
|
|
3939
4018
|
const l = s.landing;
|
|
3940
|
-
if (!held || held.floating || !
|
|
4019
|
+
if (!held || held.floating || !overlaps8(l, held.rect)) return { id: `${lane}/box/${s.id}`, kind: "box", rect: l };
|
|
3941
4020
|
const x = mid(held.rect, "x") < mid(l, "x") ? l.x + l.width : l.x;
|
|
3942
4021
|
return { id: `${lane}/line/${s.id}`, kind: "line", rect: rect18(x, l.y, 0, l.height) };
|
|
3943
4022
|
});
|
|
@@ -3975,7 +4054,7 @@ function settle(lane, drawn, state, dragged, all, emptyLanes = "real", within =
|
|
|
3975
4054
|
return !!e && (e.side === "top" || e.side === "bottom" || !!e.compact);
|
|
3976
4055
|
};
|
|
3977
4056
|
const stays = empty ? Object.entries(drawn.items).filter(([id, it]) => id !== dragged && it.edge !== l.id && barOrRail(it.edge) && !it.floating && !it.inMenu && it.rect.width > EPS21 && it.rect.height > EPS21).map(([, it]) => it.rect) : [];
|
|
3978
|
-
if (cuts.length === 0 && !(empty && (emptyLanes === "edge" || l.marks.some((m) => m.kind === "box" && stays.some((s) =>
|
|
4057
|
+
if (cuts.length === 0 && !(empty && (emptyLanes === "edge" || l.marks.some((m) => m.kind === "box" && stays.some((s) => overlaps8(m.rect, s)))))) return l;
|
|
3979
4058
|
const cut2 = (r, cs) => piecesLess(r, l.axis, cs);
|
|
3980
4059
|
const marks = [];
|
|
3981
4060
|
for (const m of l.marks) {
|
|
@@ -4020,14 +4099,14 @@ function marksLess(marks, axis, cs, options = {}) {
|
|
|
4020
4099
|
const suffix = options.suffix ?? "~c";
|
|
4021
4100
|
const minBox = options.minBox ?? 0;
|
|
4022
4101
|
return marks.flatMap((m) => {
|
|
4023
|
-
const over2 = cs.filter((c) =>
|
|
4102
|
+
const over2 = cs.filter((c) => overlaps8(m.rect, c));
|
|
4024
4103
|
if (over2.length === 0) return [m];
|
|
4025
4104
|
const kept = piecesLess(m.rect, axis, over2);
|
|
4026
4105
|
if (m.kind === "line") return (options.lines === "covered" ? kept.length > 0 : kept.length === 1 && Math.abs(kept[0][1] - kept[0][0] - len(m.rect, axis)) < EPS21) ? [m] : [];
|
|
4027
4106
|
return kept.filter(([p, q]) => m.kind !== "box" || q - p > minBox).map(([p, q], i) => ({ ...m, id: i ? `${m.id}${suffix}${i}` : m.id, rect: along(m.rect, axis, p, q) }));
|
|
4028
4107
|
});
|
|
4029
4108
|
}
|
|
4030
|
-
var
|
|
4109
|
+
var overlaps8 = (a, b) => a.x < b.x + b.width - EPS21 && b.x < a.x + a.width - EPS21 && a.y < b.y + b.height - EPS21 && b.y < a.y + a.height - EPS21;
|
|
4031
4110
|
function pitchedSpots(state, dragged, options, seen, lifted, raws, pitch) {
|
|
4032
4111
|
const out = [];
|
|
4033
4112
|
stretches(state, dragged, options, seen, lifted, raws, (run) => {
|
|
@@ -4166,10 +4245,12 @@ function landsAt(state, dragged, run, place, x0) {
|
|
|
4166
4245
|
const landed = layout.items[dragged];
|
|
4167
4246
|
const { axis } = run;
|
|
4168
4247
|
if (!landed || landed.inMenu || landed.edge !== run.e.id || Math.abs(lo(landed.rect, axis) - x0) > 1) return null;
|
|
4169
|
-
|
|
4170
|
-
const
|
|
4171
|
-
|
|
4172
|
-
|
|
4248
|
+
const kept = (f) => {
|
|
4249
|
+
const it = layout.items[f.id];
|
|
4250
|
+
if (it?.inMenu && itemSteps6(state.items[f.id])) return true;
|
|
4251
|
+
return !!it && Math.abs(lo(it.rect, axis) - lo(f.r, axis)) <= 1;
|
|
4252
|
+
};
|
|
4253
|
+
if (!run.fixed.every(kept)) return null;
|
|
4173
4254
|
return { next, layout };
|
|
4174
4255
|
}
|
|
4175
4256
|
function slidingSpots(state, dragged, options, seen, lifted, raws, sample) {
|
|
@@ -4251,9 +4332,9 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample) {
|
|
|
4251
4332
|
return best;
|
|
4252
4333
|
};
|
|
4253
4334
|
const startAt = (raw) => {
|
|
4254
|
-
const c =
|
|
4335
|
+
const c = clamp3(raw, from, to);
|
|
4255
4336
|
const s = snapped(c);
|
|
4256
|
-
return snaps.includes(s) ? s :
|
|
4337
|
+
return snaps.includes(s) ? s : clamp3(Math.round(c / STEP) * STEP, from, to);
|
|
4257
4338
|
};
|
|
4258
4339
|
const results = /* @__PURE__ */ new Map();
|
|
4259
4340
|
const commitAt = (x0) => {
|
|
@@ -4265,7 +4346,7 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample) {
|
|
|
4265
4346
|
results.set(k, result);
|
|
4266
4347
|
return result;
|
|
4267
4348
|
};
|
|
4268
|
-
const rest = homeRaw ? lo(homeRaw.landing, axis) : ownEdge === e.id && own ? snapped(
|
|
4349
|
+
const rest = homeRaw ? lo(homeRaw.landing, axis) : ownEdge === e.id && own ? snapped(clamp3(lo(own.rect, axis), from, to)) : from;
|
|
4269
4350
|
const restResult = commitAt(rest);
|
|
4270
4351
|
const ownZone = own?.zone;
|
|
4271
4352
|
const restPlace = (() => {
|
|
@@ -4285,7 +4366,7 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample) {
|
|
|
4285
4366
|
place: { kind: "gap", edge: e.id, zone: restPlace?.zone ?? zones[0], at: restPlace?.at ?? atOf(zones[0]), ...restPlace?.space ? { space: restPlace.space } : {} },
|
|
4286
4367
|
after: (point, grab) => {
|
|
4287
4368
|
const g = grab ? grab[long] : ownLen / 2;
|
|
4288
|
-
const share = axis === long && ownLen > EPS21 && Number.isFinite(g) ?
|
|
4369
|
+
const share = axis === long && ownLen > EPS21 && Number.isFinite(g) ? clamp3(g / ownLen, 0, 1) : 0.5;
|
|
4289
4370
|
return commitAt(startAt((axis === "x" ? point.x : point.y) - share * w));
|
|
4290
4371
|
}
|
|
4291
4372
|
};
|
|
@@ -4409,7 +4490,8 @@ function dockDrag(state, dragged, options = {}) {
|
|
|
4409
4490
|
const cut2 = near.marks.map((m) => m.rect);
|
|
4410
4491
|
return shown.flatMap((s) => s === near ? s.marks : marksLess(s.marks, axis(s.lane), cut2));
|
|
4411
4492
|
};
|
|
4412
|
-
|
|
4493
|
+
const home = base.lanes.flatMap((l) => l.spots.filter((s) => s.home).map((s) => ({ lane: l.id, spot: s.id })))[0];
|
|
4494
|
+
return { regions, ...home ? { home } : {}, after, landingOf, spotsOf, shown: shownLayout, guides };
|
|
4413
4495
|
}
|
|
4414
4496
|
|
|
4415
4497
|
export {
|
|
@@ -4479,4 +4561,4 @@ export {
|
|
|
4479
4561
|
HATCH_EDGE,
|
|
4480
4562
|
dockDrag
|
|
4481
4563
|
};
|
|
4482
|
-
//# sourceMappingURL=chunk-
|
|
4564
|
+
//# sourceMappingURL=chunk-FSNFXRYM.js.map
|