@n-uf/placement 26.11.39 → 26.11.41
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 +29 -0
- package/README.md +27 -3
- package/dist/{chunk-US2TGS3W.js → chunk-NRARI4Q2.js} +34 -7
- package/dist/chunk-NRARI4Q2.js.map +1 -0
- package/dist/{model-gUF8juqt.d.ts → model-C-Z5PDBp.d.ts} +24 -3
- package/dist/scene-cases.d.ts +1 -1
- package/dist/scene-cases.js +1 -1
- package/dist/scene.d.ts +23 -17
- package/dist/scene.js +3 -1
- package/package.json +2 -2
- package/dist/chunk-US2TGS3W.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,35 @@
|
|
|
3
3
|
Versions are calendar versions, `YY.M.R` (year, month of the release, counter within the month), shared with
|
|
4
4
|
`@n-uf/motion`: both packages carry the same version, and a release bumps both.
|
|
5
5
|
|
|
6
|
+
## 26.11.41
|
|
7
|
+
|
|
8
|
+
- `./scene`, **`use` is idempotent** (behavior change). `use(scene, id)` on an item whose `used` is already strictly
|
|
9
|
+
greater than every other item's gives back the same scene object, so a press on the newest item stores nothing new;
|
|
10
|
+
any other item, or one tied with another, is bumped to the newest age plus one as before. A drop's result is `use`d
|
|
11
|
+
the same way, so moving the item that was already the newest keeps its `used` (layouts are unchanged: only the
|
|
12
|
+
stored age differs). `raise` already gave back the scene for the top float; `floatAt` and `moveTo` don't bump ages.
|
|
13
|
+
|
|
14
|
+
- `./scene`, **`Edge.zones`** (additive): the zones an edge has, default all three. `zones: ["start"]` makes a side
|
|
15
|
+
rail one stack along its whole length: its whole length offers the start zone's gaps by position, with no center or
|
|
16
|
+
end gaps, ids or refusals for a kind it takes; a drop on it names no zone, so the item keeps its own `align`, and an
|
|
17
|
+
item lent back to a bar through `showIn` lies in its own zone there. A fixed item whose `align` names a zone the
|
|
18
|
+
edge lacks (`align: "end"` on a `zones: ["start"]` edge) lies in the edge's first zone, with its span, its stored
|
|
19
|
+
`align` unchanged. `zoneTakes`, `zonesTaking`, `edgeTakes`,
|
|
20
|
+
`zoneIn` and `namesZone` read it (with `zoneAccepts` too, a zone takes a kind only where both say so). Two zones
|
|
21
|
+
split the length in halves. Never stored; `readScene` takes it from `base`. Scenes without it are unchanged.
|
|
22
|
+
|
|
23
|
+
## 26.11.40
|
|
24
|
+
|
|
25
|
+
- `./scene`, **a drop names a zone only where the edge offers a choice** (behavior change). A gap drop, a strip, or
|
|
26
|
+
`moveTo` with `zone` sets the item's `align` only when more than one zone of that edge takes its kind (`namesZone`,
|
|
27
|
+
new). On a one-zone edge, such as a rail that takes groups at its start only, the item docks in that zone and keeps
|
|
28
|
+
its own `align`. So a group from a bar's end zone, dropped on such a rail while it is drawn and lent back to the bar
|
|
29
|
+
through `showIn` once the rail is hidden, lies in the bar's end zone again, not its start. A rail whose zones all
|
|
30
|
+
take the kind (no `zoneAccepts`) still offers the choice, and a drop on it sets the zone; a host that wants its rail
|
|
31
|
+
to keep the groups' own zones declares `zoneAccepts: { start: [kind] }` on it. That declaration also changes the
|
|
32
|
+
rail's targets: its center and end gaps for that kind go, and those thirds give `not-accepted` refusals instead.
|
|
33
|
+
Layouts, targets and refusals are otherwise as before; only stored `align` after a drop into a one-zone edge changes.
|
|
34
|
+
|
|
6
35
|
## 26.11.39
|
|
7
36
|
|
|
8
37
|
- `./scene/cases`, **conformance row C17 requires the scene's own rail drop.** C17 now carries
|
package/README.md
CHANGED
|
@@ -227,7 +227,9 @@ clamped so that its screen rect at pan 0 fits the view, so it still scrolls with
|
|
|
227
227
|
time and the state keeps the stored rect, so a larger view brings a float back where it was. `"free"` never moves a
|
|
228
228
|
float. A float folded by hand (`toggleFold`) lays out as a title bar: `kind` `"bar"`, `folded` `"hand"`, at its own x,
|
|
229
229
|
y and width and `options.bar` tall, clamped as a bar. It is still a float (`floating: true`) to its targets and drags,
|
|
230
|
-
pinned or not, and unfolding brings its full rect back: the stored rect never changes.
|
|
230
|
+
pinned or not, and unfolding brings its full rect back: the stored rect never changes. That `floating` is a layout
|
|
231
|
+
item's flag; `@n-uf/motion/drag`'s `createDragIntent({ floating })` is an option a host sets from it at lift
|
|
232
|
+
(`floating: layout.items[id]?.floating === true`), so the item's own box loses to a refusal as the float does.
|
|
231
233
|
|
|
232
234
|
**Folded columns** (`options.fold`, default `"rail"`): a column folded by hand goes to its side's rail. With `"ride"`,
|
|
233
235
|
it rides instead while its side still has an open column: its panels become title bars (`kind` `"bar"`, `rides`: the
|
|
@@ -876,7 +878,13 @@ least and `cross.max` at most; `resize` sets it.
|
|
|
876
878
|
edge it lies in. It lies in that zone where its edge takes its kind there (`Edge.zoneAccepts`), else in the first zone
|
|
877
879
|
that does (`zoneIn`, one rule for every edge and for the items a hidden edge lends through `showIn`); its stored
|
|
878
880
|
`align` stays as it was, so it is back in its own zone on an edge that takes it there. A move sets `align` only when the
|
|
879
|
-
drop names a zone: a gap in a zone, a zone's slot, `moveTo` with `zone
|
|
881
|
+
drop names a zone: a gap in a zone, a zone's slot, `moveTo` with `zone`, on an edge that offers a choice (`namesZone`:
|
|
882
|
+
more than one of its zones takes the kind). On a one-zone edge, such as a rail that takes groups at its start only, the
|
|
883
|
+
zone a drop gives is no choice: the item docks there and keeps its own, so a group from a bar's end zone moved onto
|
|
884
|
+
that rail goes back to the bar's end zone when the rail is hidden and lends it back (`showIn`), or when it is moved
|
|
885
|
+
there with no zone. An edge with no `zoneAccepts` takes every kind in every zone, so it offers the choice; declaring
|
|
886
|
+
`zoneAccepts: { start: [kind] }` makes it a one-zone edge for that kind, which also removes its center and end gaps for
|
|
887
|
+
the kind and refuses those thirds (`not-accepted`). A move whose zone is implied keeps it: a rail,
|
|
880
888
|
a new column, home and `dockHome` (which takes the start scene's `align` back), `moveTo` with no `zone`. Give-way is as
|
|
881
889
|
without zones (it sums the minimum sizes); when room is spare, start items pack from the start, end items from the end
|
|
882
890
|
(before the » entry) and center items sit on the edge's middle, moved only as far as they must to stay between the
|
|
@@ -960,6 +968,20 @@ const zoom: SceneItem = {
|
|
|
960
968
|
their `icons` form (and the » menu after it), stacked, each item's grip the divider. An item with no `icons` form is left
|
|
961
969
|
out of it with a `no-icons-form` note.
|
|
962
970
|
|
|
971
|
+
**Edges with fewer zones.** `Edge.zones` lists the zones an edge has (default all three). `zones: ["start"]` makes it
|
|
972
|
+
one stack along its whole length, as a side rail drawn in order: the whole length offers the start zone's gaps, ordered
|
|
973
|
+
by position along it, so a drop anywhere inserts at the pointer's place; there are no center or end gaps, ids or
|
|
974
|
+
refusals, and nothing along it refuses a kind it takes. A drop on it names no zone (`namesZone` counts the zones it
|
|
975
|
+
has), so the item keeps its own `align`; an item whose `align` names a zone the edge lacks lies in its zone (`zoneIn`;
|
|
976
|
+
a fixed item, which the edge takes in no zone, in the edge's first zone), its stored `align` unchanged, and is back in its own zone when the edge is hidden and lends it to a bar (`showIn`).
|
|
977
|
+
Two zones (`["start", "end"]`) split the length between them, the boundary at the middle moved past the cards seen on
|
|
978
|
+
either side, as three split it in thirds; a drop there names its half's zone. Setting `zones`, even to all three,
|
|
979
|
+
always splits the length evenly among its zones (each boundary moved past the cards seen on either side); leaving it
|
|
980
|
+
out keeps the edge kind's own spans, on a column the spans the solver lays out. Entries that aren't zones and repeats are
|
|
981
|
+
ignored, and a list with no zone counts as all three. With `zoneAccepts` as well, a zone takes a kind only where both
|
|
982
|
+
say so (`zoneAccepts: { start: [...] }` alone keeps three zones and refuses the other two thirds). Like `zoneAccepts`,
|
|
983
|
+
`zones` is a declaration: `storeScene` never writes it and `readScene` takes it from `base`.
|
|
984
|
+
|
|
963
985
|
**Column footers.** `Edge.zoneAccepts` (and `ColumnTemplate.zoneAccepts`, for the columns a drop makes) narrows `accepts` per zone:
|
|
964
986
|
the kinds each zone takes, and a zone not listed takes nothing. A panel column with `{ start: ["panel"], end: ["group"] }`
|
|
965
987
|
has its panels at the top and a footer of toolbar groups at its foot (the end zone, one group per row): a group in the footer
|
|
@@ -1355,7 +1377,9 @@ Each target's `after(point, grab)` is `{ scene, layout }`: the scene to commit (
|
|
|
1355
1377
|
|
|
1356
1378
|
**Changes** are pure and return the scene given when nothing applies: `moveTo(scene, id, { edge, zone?, at })`,
|
|
1357
1379
|
`floatAt(scene, id, rect?, orient?)` (with no rect: its last `floatSize`, anchored to the content's top-right), `fold`,
|
|
1358
|
-
`use
|
|
1380
|
+
`use` (idempotent: on an item whose `used` is already strictly greater than every other item's it gives back the same
|
|
1381
|
+
scene object, so a press on the newest item stores nothing new; any other item, or one tied with another, is bumped to
|
|
1382
|
+
the newest age plus one), `keep`, `raise` (a float on top: no use, no reshape), `open`, `close`, `orient`, `resize` and
|
|
1359
1383
|
`setSide(scene, edgeId, side)`. `resize(scene, edgeId, size)` sets the user's size across an edge;
|
|
1360
1384
|
`resize(scene, floatId, rect, moving?)` resizes a float by hand at `fitResize`'s rect (see "Resizing a float by hand";
|
|
1361
1385
|
the scene given back where `fitResize` gives null). `setSide` moves an edge to the other side of its axis (left ⇄ right, top ⇄ bottom) as
|
|
@@ -34,7 +34,12 @@ var DEFAULT_FLOAT_SIZE = { width: 280, height: 360 };
|
|
|
34
34
|
// src/scene/helpers.ts
|
|
35
35
|
var anchorName = (anchor) => typeof anchor === "string" ? anchor : anchor.at;
|
|
36
36
|
var isSince = (x) => typeof x === "number" && x >= 0 && x <= Number.MAX_SAFE_INTEGER;
|
|
37
|
-
var
|
|
37
|
+
var zonesOf = (edge) => {
|
|
38
|
+
if (edge.zones === void 0) return ZONES;
|
|
39
|
+
const has = ZONES.filter((z) => edge.zones.includes(z));
|
|
40
|
+
return has.length > 0 ? has : ZONES;
|
|
41
|
+
};
|
|
42
|
+
var zoneTakes = (edge, zone, kind) => edge.accepts.includes(kind) && (edge.zones === void 0 || zonesOf(edge).includes(zone)) && (edge.zoneAccepts === void 0 || !!edge.zoneAccepts[zone]?.includes(kind));
|
|
38
43
|
var zonesTaking = (edge, kind) => ZONES.filter((z) => zoneTakes(edge, z, kind));
|
|
39
44
|
var edgeTakes = (edge, kind) => zonesTaking(edge, kind).length > 0;
|
|
40
45
|
var hitBandOf = (scene, edge) => edge.hitBand ?? (edge.column === true && (edge.side === "left" || edge.side === "right") ? scene.columns?.[edge.side]?.hitBand : void 0) ?? DEFAULT_HIT_BAND;
|
|
@@ -61,9 +66,14 @@ function railColumnOf(scene, side, kind) {
|
|
|
61
66
|
}
|
|
62
67
|
function zoneIn(edge, item) {
|
|
63
68
|
const own = zoneOf(item);
|
|
64
|
-
if (item.fixed
|
|
69
|
+
if (item.fixed) {
|
|
70
|
+
const has = zonesOf(edge);
|
|
71
|
+
return has.includes(own) ? own : has[0] ?? own;
|
|
72
|
+
}
|
|
73
|
+
if (zoneTakes(edge, own, item.kind)) return own;
|
|
65
74
|
return zonesTaking(edge, item.kind)[0] ?? own;
|
|
66
75
|
}
|
|
76
|
+
var namesZone = (edge, kind) => zonesTaking(edge, kind).length > 1;
|
|
67
77
|
var showInOf = (scene, e) => {
|
|
68
78
|
if (e.hidden !== true || e.showIn === void 0) return void 0;
|
|
69
79
|
const to = scene.edges.find((x) => x.id === e.showIn);
|
|
@@ -1413,7 +1423,7 @@ function moveAmong(scene, id, place, others) {
|
|
|
1413
1423
|
const zone = place.zone ?? zoneIn(edge, item);
|
|
1414
1424
|
if (!zoneTakes(edge, zone, item.kind)) return scene;
|
|
1415
1425
|
const { align: _drop, ...rest } = item;
|
|
1416
|
-
const moved = place.zone === void 0 ? item : zone === "start" ? rest : { ...rest, align: zone };
|
|
1426
|
+
const moved = place.zone === void 0 || !namesZone(edge, item.kind) ? item : zone === "start" ? rest : { ...rest, align: zone };
|
|
1417
1427
|
const lifted = withItem(lift(scene, id), moved);
|
|
1418
1428
|
const target = lifted.edges.find((e) => e.id === place.edge);
|
|
1419
1429
|
if (!target) return scene;
|
|
@@ -1455,6 +1465,8 @@ var nextAge = (scene) => Object.values(scene.items).reduce((m, it) => Math.max(m
|
|
|
1455
1465
|
function use(scene, id) {
|
|
1456
1466
|
const item = itemOf(scene, id);
|
|
1457
1467
|
if (!item) return scene;
|
|
1468
|
+
const age = (it) => Number.isFinite(it.used) ? it.used : 0;
|
|
1469
|
+
if (Number.isFinite(item.used) && Object.values(scene.items).every((it) => it.id === id || age(it) < item.used)) return scene;
|
|
1458
1470
|
return withItem(scene, { ...item, used: nextAge(scene) });
|
|
1459
1471
|
}
|
|
1460
1472
|
function keep(scene, id, on) {
|
|
@@ -1879,9 +1891,21 @@ function zoneSpans(scene, seen, edge, reach, probe) {
|
|
|
1879
1891
|
placed.set(z, was ? [Math.min(was[0], a), Math.max(was[1], b)] : [a, b]);
|
|
1880
1892
|
declared.add(z);
|
|
1881
1893
|
}
|
|
1894
|
+
const lo = (z) => placed.get(z)?.[0] ?? Infinity;
|
|
1895
|
+
const hi = (z) => placed.get(z)?.[1] ?? -Infinity;
|
|
1896
|
+
if (edge.zones !== void 0) {
|
|
1897
|
+
const has = zonesOf(edge);
|
|
1898
|
+
let prev = main0 - reach;
|
|
1899
|
+
return has.map((zone, i) => {
|
|
1900
|
+
const last = i === has.length - 1;
|
|
1901
|
+
const mark = main0 + length * (i + 1) / has.length;
|
|
1902
|
+
const b = last ? main0 + length + reach : Math.max(prev, Math.min(Math.max(mark, ...has.slice(0, i + 1).map(hi)), ...has.slice(i + 1).map(lo)));
|
|
1903
|
+
const span = { zone, a: prev, b };
|
|
1904
|
+
prev = b;
|
|
1905
|
+
return span;
|
|
1906
|
+
});
|
|
1907
|
+
}
|
|
1882
1908
|
if (thirds) {
|
|
1883
|
-
const lo = (z) => placed.get(z)?.[0] ?? Infinity;
|
|
1884
|
-
const hi = (z) => placed.get(z)?.[1] ?? -Infinity;
|
|
1885
1909
|
const b1 = Math.min(Math.max(main0 + length / 3, hi("start")), lo("center"), lo("end"));
|
|
1886
1910
|
const b2 = Math.max(Math.min(main0 + 2 * length / 3, lo("end")), hi("center"), hi("start"), b1);
|
|
1887
1911
|
return [
|
|
@@ -3000,7 +3024,9 @@ function generate(scene, dragged, options) {
|
|
|
3000
3024
|
after: (point, grab) => {
|
|
3001
3025
|
const a = t.after(point, grab);
|
|
3002
3026
|
if (a.scene === shown) return { scene, layout: showsIn ? solve(scene, prev) : a.layout };
|
|
3003
|
-
const
|
|
3027
|
+
const on = t.place.kind === "gap" ? shown.edges.find((e) => t.place.kind === "gap" && e.id === t.place.edge) : void 0;
|
|
3028
|
+
const named = !!on && namesZone(on, scene.items[dragged].kind);
|
|
3029
|
+
const back = withHiddenOf(scene, a.scene, lent, dragged, named, rezoned);
|
|
3004
3030
|
const restored = showsIn ? prune(back) : back;
|
|
3005
3031
|
const ringOf = new Map(a.scene.edges.map((e) => [e.id, e.ring]));
|
|
3006
3032
|
const renumbered = restored.edges.some((e) => e.hidden !== true && ringOf.get(e.id) !== e.ring);
|
|
@@ -3146,6 +3172,7 @@ export {
|
|
|
3146
3172
|
edgeTakes,
|
|
3147
3173
|
railModeOf,
|
|
3148
3174
|
zoneIn,
|
|
3175
|
+
namesZone,
|
|
3149
3176
|
isOutsideSideBar,
|
|
3150
3177
|
isSideBar,
|
|
3151
3178
|
floatOrientOf,
|
|
@@ -3180,4 +3207,4 @@ export {
|
|
|
3180
3207
|
refusalTargets,
|
|
3181
3208
|
stops
|
|
3182
3209
|
};
|
|
3183
|
-
//# sourceMappingURL=chunk-
|
|
3210
|
+
//# sourceMappingURL=chunk-NRARI4Q2.js.map
|