@n-uf/docking 26.12.11 → 26.12.13

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.
@@ -47,7 +47,8 @@ interface DockItem {
47
47
  };
48
48
  /** How recently it was used: the smaller, the longer ago, the sooner it gives way. */
49
49
  readonly used: number;
50
- /** Kept: gives way after every item that isn't. */
50
+ /** Kept: in each step of give-way it goes after every item that isn't: it shrinks after them and folds after
51
+ * them. It still shrinks before any column folds. */
51
52
  readonly kept?: boolean;
52
53
  /**
53
54
  * Folded by hand when 1 or more (`foldItem` sets it to 1; default unset): it starts at its first folded form (a panel's
@@ -504,12 +505,35 @@ interface DockState {
504
505
  */
505
506
  readonly foldedColumnDrop?: "end";
506
507
  /**
507
- * `"one"`: a side has at most one column (`isSideColumn`). A drag offers a new-column line only on a side with no
508
- * column holding an item once the item is lifted; where the side has one, an item goes into it (by its gaps) or
509
- * nowhere on that side. A stored layout with two columns on a side is merged by `mergeSideColumns`, which a host calls
510
- * as it reads one. Absent: as before. A declaration, like `foldedColumnDrop`: never stored.
508
+ * The cap: the most columns (`isSideColumn`) a side may hold, as `sideColumnCap` reads it (every reader goes through
509
+ * it). A side never gains a column past its cap. The count is the columns the side would hold if the dragged item were
510
+ * dropped on another side: a folded column counts, a declared column edge counts, empty or not, and a column the lift
511
+ * empties does not, unless it is declared. A drag offers a new-column line on a side exactly when that count is below
512
+ * the cap; on a full side an item goes into one of its columns (by its gaps) or nowhere on that side, and a rail stop
513
+ * there is offered only where it puts the item into a column that exists. No change function makes a column past the
514
+ * cap from a state within it. The layout draws what the state holds: lowering the cap merges nothing, and a host that
515
+ * lowers it calls `mergeSideColumns`, as it does when it reads a stored layout. A host declares no more column edges on
516
+ * a side than its cap.
517
+ *
518
+ * Absent or `Infinity`: no cap, as before. A whole number of 1 or more: itself. Any other number: rounded down, never
519
+ * below 1 (a cap computed from a width: 0 reads as 1, 2.5 as 2). Not a number: 1. Nothing throws.
520
+ *
521
+ * `"one"`: 1. **Deprecated:** declare `1`; `"one"` is removed in the first breaking release after hosts declare a
522
+ * number. A declaration, like `foldedColumnDrop`: never stored.
511
523
  */
512
- readonly sideColumns?: "one";
524
+ readonly sideColumns?: number | "one";
525
+ /**
526
+ * The panels that give way last, by id. A column holding one neither shrinks nor folds while a column holding
527
+ * none can still give way; within each group the give-way order is unchanged. Ids not in the state are ignored.
528
+ * Absent or empty: as before. A declaration: never stored.
529
+ *
530
+ * A column holds a declared panel as it holds a kept item: one of the items it shows is one (a column with a
531
+ * declared panel and an undeclared one is in the last group). The columns that can't give way (an anchor, a side
532
+ * toolbar bar or compact rail, a static edge without `giveWay`, a column folded whole by hand, and a column that
533
+ * shows no item) never hold the last group open.
534
+ * Both sides are one group. Width only: bars give way by height as before.
535
+ */
536
+ readonly givesWayLast?: readonly string[];
513
537
  /**
514
538
  * `"nearest"`: a bar's zones (start, center, end) meet halfway between the landing rects either side of each boundary,
515
539
  * so the pointer picks the zone whose landing is nearest it. Absent: at thirds of the bar's length (each boundary moved
@@ -521,9 +545,10 @@ interface DockState {
521
545
  */
522
546
  readonly barZones?: "nearest";
523
547
  /**
524
- * The least the content may be. While the content is narrower than `width`, dynamic columns shrink toward their
525
- * minimum, then fold whole into their side's rail: unkept before kept, the one whose newest use is oldest first, the
526
- * outer first, the left first. Under `height`, a `content-short` note.
548
+ * The least the content may be. While the content is narrower than `width`, columns give way a tier at a time: first
549
+ * the columns holding no panel the host declared last (`givesWayLast`), then the ones that do. Within a tier the
550
+ * columns shrink toward their minimum, then fold whole into their side's rail: unkept before kept, the one whose
551
+ * newest use is oldest first, the outer first, the left first. Under `height`, a `content-short` note.
527
552
  *
528
553
  * `chromeWidth` (optional, px, at most `width`): a lower floor for chrome. The side edges that hold toolbars, not
529
554
  * panels (compact rails and side toolbar bars, `isSideBar`), may take the content down to it while the columns keep
@@ -893,7 +918,8 @@ declare function fitResize(state: DockState, id: string, rect: Rect, moving: Res
893
918
  * shows in the rail (on a side with no declared rail, `DockState.rails`, its rail is its outermost column that takes the
894
919
  * kind, "the column drawn as a rail": the item docks at the end of its start zone as a collapsed header, folded by
895
920
  * hand, a rail tile once nothing there sets the width); `{ kind: "float", rect?, anchor? }` floats it. A dynamic column an item leaves empty is deleted
896
- * and its side's rings are closed up.
921
+ * and its side's rings are closed up. A column or rail place on a side that holds its cap of columns with the item
922
+ * lifted (`DockState.sideColumns`) changes nothing: no change makes a column past the cap.
897
923
  * - `homeFor(state, id, start)`: the place a start state gives the item, for `moveTo`.
898
924
  * - `floatAt(state, id, rect?, orient?)`: floats it on top at `rect` (its size becomes its `floatSizes` for the orient
899
925
  * it floats in); with no rect, at its `floatSizeOf` size anchored to the content's top-right corner: its `floatSizes`
@@ -950,12 +976,21 @@ interface FloatPlace {
950
976
  }
951
977
  type Place = DockPlace | ColumnPlace | RailPlace | FloatPlace;
952
978
  /**
953
- * Each side's columns (`isSideColumn`) merged into one, for `DockState.sideColumns: "one"`: the outermost column (by ring)
954
- * keeps its id and takes every other column's items after its own, in ring order; the others are deleted and the side's
955
- * rings closed up. A side with one column or none is unchanged; the same state comes back when nothing merges. A host
956
- * calls it as it reads a stored layout, so what it stores is what it shows and what a drag reads.
979
+ * Each side's columns (`isSideColumn`) past `max` merged into its `max`-th column (by ring), for the cap
980
+ * (`DockState.sideColumns`): the `max − 1` outermost stay as they are; the `max`-th keeps its id and its options (its
981
+ * `size` among them) and takes the inner columns' items after its own, by ring, each column's order kept; the others are
982
+ * deleted and the side's rings closed up. It goes by position only, never by use, so it gives the same result each time.
983
+ * Items move whole: no item's `used` or `kept` changes. A side with `max` columns or fewer is unchanged; the same state
984
+ * comes back when nothing merges.
985
+ *
986
+ * `max` is read as the cap is (`sideColumnCap`); left out, it is the cap the state declares, or 1 with none declared.
987
+ * With `max` 1 it merges each side into its outermost column. A host calls it as it reads a stored layout, so what it
988
+ * stores is what it shows and what a drag reads, and again when it lowers the cap: lowering it merges nothing by itself.
989
+ *
990
+ * The merged column is drawn as any column is: at its `size` where the user set one, else as wide as its widest open
991
+ * item asks (its stack's width), so with no `size` it can draw wider than it did before the merge.
957
992
  */
958
- declare function mergeSideColumns(state: DockState): DockState;
993
+ declare function mergeSideColumns(state: DockState, max?: number): DockState;
959
994
  /**
960
995
  * The state with the item out of every edge and every float (a dynamic column it leaves empty is deleted). The room it
961
996
  * held goes back to its stretch: the first placed item past it, away from its zone's own end (`DockItem.space`), takes
@@ -1001,7 +1036,8 @@ declare function setRailMode(state: DockState, side: "left" | "right", mode: Rai
1001
1036
  /**
1002
1037
  * The edge moved to the other side of its axis (left ⇄ right, top ⇄ bottom), as its side's outermost edge: ring 0, before
1003
1038
  * that side's other edges (whose rings close up behind it; the side it left closes up too). Its items, size and options
1004
- * go with it. Unchanged for an unknown edge, the side it is on, or a side across its axis. Like every change it does not
1039
+ * go with it. Unchanged for an unknown edge, the side it is on, or a side across its axis, and for an edge that would be
1040
+ * a column there (`isSideColumn`) on a side that holds its cap of columns already (`DockState.sideColumns`). Like every change it does not
1005
1041
  * tick the use clock: a host that moves an edge by hand calls `markUsed()` on its items afterwards, as a drop does.
1006
1042
  */
1007
1043
  declare function setSide(state: DockState, edgeId: string, side: Side): DockState;
@@ -1010,7 +1046,8 @@ declare function setSide(state: DockState, edgeId: string, side: Side): DockStat
1010
1046
  * position: its zone and place in the same edge (before the first item that followed it there and is still there), a
1011
1047
  * new column at its ring when its column is gone (a column under the same id that holds none of the start column's
1012
1048
  * items is another column), or its float rect (and anchor). Null when `start` places it nowhere
1013
- * or in an edge `state` no longer has that isn't a column. `moveTo(state, id, place)` puts it there.
1049
+ * or in an edge `state` no longer has that isn't a column. `moveTo(state, id, place)` puts it there; a new column on a
1050
+ * side at its cap (`DockState.sideColumns`) it refuses, so Dock then leaves the item where it is.
1014
1051
  */
1015
1052
  declare function homeFor(state: DockState, id: string, start: DockState): Place | null;
1016
1053
  /**
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as FloatAnchorAt, a as FloatAnchor, D as DockItem, K as Kind, Z as ZoneAccepts, b as Zone, O as Orient, c as DockState, d as KeepClear, A as AnchoredKeepClear, e as DockEdge, f as DockRailLayout, R as RailMode, S as SolveOptions, g as DockLayout, h as DockRefusal, i as DockDropOptions, j as DockDrop } from './drag-ITlooERH.js';
2
- export { C as ColumnPlace, k as ColumnTemplate, l as DEFAULT_FLOAT_SIZE, m as DEFAULT_HIT_BAND, n as DEFAULT_RAIL_MAGNET, o as DEFAULT_STRIP, p as DockAfter, q as DockDrag, r as DockEdgeLayout, s as DockFloat, t as DockGrab, u as DockGrabForm, v as DockGrabNote, w as DockGrabPlace, x as DockGuideFrame, y as DockGuideRef, z as DockHeld, B as DockItemLayout, E as DockKeepClearLayout, G as DockLane, H as DockLaneMark, I as DockLaneOptions, J as DockMark, L as DockNote, M as DockNoteCode, N as DockPlace, P as DockRegions, Q as DockSpot, T as DockStateRead, U as DropPlace, V as DropResult, W as EDGE_ROOM_HOLD, X as EmptyLanes, Y as FLOAT_ANCHORS, _ as FloatAnchorOffset, $ as FloatPlace, a0 as FloatResize, a1 as HATCH_EDGE, a2 as HATCH_END, a3 as KeepClearRegion, a4 as LaneRefusal, a5 as LaneSlide, a6 as Place, a7 as RAIL_MODES, a8 as RAIL_STRIP_MIN, a9 as RAIL_VISIBILITIES, aa as RailDropPolicy, ab as RailPlace, ac as RailSpec, ad as RailVisibility, ae as ResizeEdges, af as ResizeLimit, ag as SIDES, ah as StoredDockState, ai as StoredDockStateEdge, aj as StoredDockStateFloat, ak as StoredDockStateItem, al as ZONES, am as canFold, an as closeItem, ao as dockDrag, ap as dockHome, aq as fitResize, ar as floatAt, as as foldItem, at as homeFor, au as keepItem, av as lanes, aw as liftItem, ax as markUsed, ay as mergeSideColumns, az as moveTo, aA as openItem, aB as orientFloat, aC as raiseFloat, aD as readDockState, aE as resizeEdge, aF as resizeFloat, aG as setRailMode, aH as setSide, aI as storeDockState } from './drag-ITlooERH.js';
1
+ import { F as FloatAnchorAt, a as FloatAnchor, D as DockItem, K as Kind, Z as ZoneAccepts, b as Zone, O as Orient, c as DockState, d as KeepClear, A as AnchoredKeepClear, e as DockEdge, f as DockRailLayout, R as RailMode, S as SolveOptions, g as DockLayout, h as DockRefusal, i as DockDropOptions, j as DockDrop } from './drag-DzPpzGfq.js';
2
+ export { C as ColumnPlace, k as ColumnTemplate, l as DEFAULT_FLOAT_SIZE, m as DEFAULT_HIT_BAND, n as DEFAULT_RAIL_MAGNET, o as DEFAULT_STRIP, p as DockAfter, q as DockDrag, r as DockEdgeLayout, s as DockFloat, t as DockGrab, u as DockGrabForm, v as DockGrabNote, w as DockGrabPlace, x as DockGuideFrame, y as DockGuideRef, z as DockHeld, B as DockItemLayout, E as DockKeepClearLayout, G as DockLane, H as DockLaneMark, I as DockLaneOptions, J as DockMark, L as DockNote, M as DockNoteCode, N as DockPlace, P as DockRegions, Q as DockSpot, T as DockStateRead, U as DropPlace, V as DropResult, W as EDGE_ROOM_HOLD, X as EmptyLanes, Y as FLOAT_ANCHORS, _ as FloatAnchorOffset, $ as FloatPlace, a0 as FloatResize, a1 as HATCH_EDGE, a2 as HATCH_END, a3 as KeepClearRegion, a4 as LaneRefusal, a5 as LaneSlide, a6 as Place, a7 as RAIL_MODES, a8 as RAIL_STRIP_MIN, a9 as RAIL_VISIBILITIES, aa as RailDropPolicy, ab as RailPlace, ac as RailSpec, ad as RailVisibility, ae as ResizeEdges, af as ResizeLimit, ag as SIDES, ah as StoredDockState, ai as StoredDockStateEdge, aj as StoredDockStateFloat, ak as StoredDockStateItem, al as ZONES, am as canFold, an as closeItem, ao as dockDrag, ap as dockHome, aq as fitResize, ar as floatAt, as as foldItem, at as homeFor, au as keepItem, av as lanes, aw as liftItem, ax as markUsed, ay as mergeSideColumns, az as moveTo, aA as openItem, aB as orientFloat, aC as raiseFloat, aD as readDockState, aE as resizeEdge, aF as resizeFloat, aG as setRailMode, aH as setSide, aI as storeDockState } from './drag-DzPpzGfq.js';
3
3
  import { Size, Point, Rect, Side, Target } from '@n-uf/placement';
4
4
  export { Axis, Side } from '@n-uf/placement';
5
5
  import '@n-uf/placement/stack';
@@ -74,6 +74,12 @@ declare function isOutsideSideBar(state: DockState, e: DockEdge): boolean;
74
74
  declare function isSideBar(state: DockState, e: DockEdge): boolean;
75
75
  /** A left or right column: a side edge that takes something, not a compact rail and not a toolbar bar (`isSideBar`). */
76
76
  declare const isSideColumn: (state: DockState, e: DockEdge) => boolean;
77
+ /**
78
+ * The most columns a side may hold (`DockState.sideColumns`), the one reading every reader goes through: the target
79
+ * rule, `mergeSideColumns`'s default and a host. `Infinity` for no cap (absent or `Infinity`); `"one"`: 1; a whole number
80
+ * of 1 or more: itself; any other number rounded down, never below 1; not a number: 1. Never throws.
81
+ */
82
+ declare function sideColumnCap(state: Pick<DockState, "sideColumns">): number;
77
83
  /**
78
84
  * The orient a float of `item` takes when it names none: its `floatOrient`, else the axis of its first form (the first
79
85
  * of `forms.row` / `forms.column` it declares with any form), else column.
@@ -371,4 +377,4 @@ declare function stops(state: DockState, dragged: string, options?: DockDropOpti
371
377
  /** The pitch of the spots over a bar's free stretches, px: a quarter of a typical toolbar's length (158 px in the lab). */
372
378
  declare const SPOT_PITCH = 40;
373
379
 
374
- export { AnchoredKeepClear, type DockDivider, DockDrop, DockDropOptions, DockEdge, DockItem, DockLayout, DockRailLayout, DockRefusal, type DockRefusalTarget, DockState, FloatAnchor, FloatAnchorAt, KeepClear, Kind, Orient, RailMode, SPOT_PITCH, SolveOptions, type TargetIdParts, Zone, ZoneAccepts, anchorName, declaresFloatSizes, dividers, edgeTakes, floatOrientOf, floatSizeOf, heldRect, isAnchoredKeepClear, isOutsideSideBar, isSideBar, isSideColumn, namesZone, parseTargetId, placeTargetId, railDrawn, railModeOf, refusalTargets, refusals, reservedRect, resetBetween, resetLengths, resizeBetween, solve, stops, targetId, targets, virtualEdgeId, zoneIn, zoneTakes, zonesTaking };
380
+ export { AnchoredKeepClear, type DockDivider, DockDrop, DockDropOptions, DockEdge, DockItem, DockLayout, DockRailLayout, DockRefusal, type DockRefusalTarget, DockState, FloatAnchor, FloatAnchorAt, KeepClear, Kind, Orient, RailMode, SPOT_PITCH, SolveOptions, type TargetIdParts, Zone, ZoneAccepts, anchorName, declaresFloatSizes, dividers, edgeTakes, floatOrientOf, floatSizeOf, heldRect, isAnchoredKeepClear, isOutsideSideBar, isSideBar, isSideColumn, namesZone, parseTargetId, placeTargetId, railDrawn, railModeOf, refusalTargets, refusals, reservedRect, resetBetween, resetLengths, resizeBetween, sideColumnCap, solve, stops, targetId, targets, virtualEdgeId, zoneIn, zoneTakes, zonesTaking };
package/dist/index.js CHANGED
@@ -57,6 +57,7 @@ import {
57
57
  resizeFloat,
58
58
  setRailMode,
59
59
  setSide,
60
+ sideColumnCap,
60
61
  solve,
61
62
  stops,
62
63
  storeDockState,
@@ -66,7 +67,7 @@ import {
66
67
  zoneIn,
67
68
  zoneTakes,
68
69
  zonesTaking
69
- } from "./chunk-367B5WJT.js";
70
+ } from "./chunk-NPBJJJWS.js";
70
71
  export {
71
72
  DEFAULT_FLOAT_SIZE,
72
73
  DEFAULT_HIT_BAND,
@@ -126,6 +127,7 @@ export {
126
127
  resizeFloat,
127
128
  setRailMode,
128
129
  setSide,
130
+ sideColumnCap,
129
131
  solve,
130
132
  stops,
131
133
  storeDockState,
package/dist/testing.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Point, Rect, Side } from '@n-uf/placement';
2
2
  import { StackFormKind } from '@n-uf/placement/stack';
3
- import { c as DockState, U as DropPlace, g as DockLayout, ah as StoredDockState, b as Zone, M as DockNoteCode, j as DockDrop, h as DockRefusal, I as DockLaneOptions, z as DockHeld, y as DockGuideRef, P as DockRegions, Q as DockSpot } from './drag-ITlooERH.js';
3
+ import { c as DockState, U as DropPlace, g as DockLayout, ah as StoredDockState, b as Zone, M as DockNoteCode, j as DockDrop, h as DockRefusal, I as DockLaneOptions, z as DockHeld, y as DockGuideRef, P as DockRegions, Q as DockSpot } from './drag-DzPpzGfq.js';
4
4
  import { LandingGeometry, LandingRegions } from '@n-uf/motion/drag';
5
5
 
6
6
  /**
package/dist/testing.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  stops,
19
19
  storeDockState,
20
20
  targets
21
- } from "./chunk-367B5WJT.js";
21
+ } from "./chunk-NPBJJJWS.js";
22
22
 
23
23
  // src/testing/rows-docking.ts
24
24
  import { rect as r } from "@n-uf/placement";
@@ -1639,6 +1639,8 @@ function at(id, title2, group3, spec, o, width, columns, rails, atLeast, walk) {
1639
1639
  }
1640
1640
  var ALL_THREE = { left: ["pages", "annotations"], right: ["findings"] };
1641
1641
  var PAIR = { columns: { left: [["annotations"]], right: [["findings"]] } };
1642
+ var NATURALS_A = { pages: { natural: 300, min: 110 }, annotations: { natural: 320, min: 220 }, findings: { natural: 320, min: 220 } };
1643
+ var NATURALS_B = { pages: { natural: 280, min: 118 }, annotations: { natural: 320, min: 200 }, findings: { natural: 320, min: 200 } };
1642
1644
  function windowRows() {
1643
1645
  const rows = [];
1644
1646
  const A = (name, o, w, c, r5, min, walk) => {
@@ -1683,6 +1685,26 @@ function windowRows() {
1683
1685
  B("pair", PAIR, 590, { right: [["findings"]] }, { left: ["annotations"] });
1684
1686
  B("pair", PAIR, 552, { right: [["findings"]] }, { left: ["annotations"] });
1685
1687
  B("pair", PAIR, 551, {}, { left: ["annotations"], right: ["findings"] });
1688
+ const declared = (spec, naturals, name, o, width, c, min, r5 = {}) => {
1689
+ const w = spec === WINDOW_A ? "a" : "b";
1690
+ const row2 = at(`window-${w}-${name}-declared-${width}`, `Window ${w.toUpperCase()}, ${name}, natural widths, Findings declared last, ${width} px`, `window-${w}`, spec, o, width, c, r5, min);
1691
+ const items = Object.fromEntries(
1692
+ Object.entries(row2.state.items).map(([id, it]) => {
1693
+ const cross = naturals[id];
1694
+ const forms = it.forms.column ?? [];
1695
+ return [id, cross && forms[0] ? { ...it, forms: { ...it.forms, column: [{ ...forms[0], cross }, ...forms.slice(1)] } } : it];
1696
+ })
1697
+ );
1698
+ rows.push({ ...row2, expect: `${row2.expect} Every card at its natural width, Findings declared last.`, state: { ...row2.state, items, givesWayLast: ["findings"] } });
1699
+ };
1700
+ declared(WINDOW_A, NATURALS_A, "three", {}, 908, open3, 320);
1701
+ declared(WINDOW_A, NATURALS_A, "pair", PAIR, 908, { left: [["annotations"]], right: [["findings"]] });
1702
+ declared(WINDOW_B, NATURALS_B, "three", {}, 840, open3, 320);
1703
+ declared(WINDOW_B, NATURALS_B, "pair", PAIR, 840, { left: [["annotations"]], right: [["findings"]] });
1704
+ declared(WINDOW_A, NATURALS_A, "three", {}, 907, leftFolded3, void 0, railsLeft3);
1705
+ declared(WINDOW_A, NATURALS_A, "pair", PAIR, 907, { right: [["findings"]] }, void 0, { left: ["annotations"] });
1706
+ declared(WINDOW_B, NATURALS_B, "three", {}, 839, leftFolded3, void 0, railsLeft3);
1707
+ declared(WINDOW_B, NATURALS_B, "pair", PAIR, 839, { right: [["findings"]] }, void 0, { left: ["annotations"] });
1686
1708
  return rows;
1687
1709
  }
1688
1710
  var HAND = [
@@ -2037,7 +2059,10 @@ function mapState(s, f2) {
2037
2059
  ...s,
2038
2060
  edges: s.edges.map((e) => ({ ...e, id: f2(e.id), items: e.items.map(f2) })),
2039
2061
  items: rekey(s.items, f2, (it) => ({ ...it, id: f2(it.id) })),
2040
- floats: s.floats.map((x) => ({ ...x, id: f2(x.id) }))
2062
+ floats: s.floats.map((x) => ({ ...x, id: f2(x.id) })),
2063
+ // The declaration names items too; a value that isn't a list passes as it is (the solver reads it leniently), and an
2064
+ // entry the map doesn't name passes through.
2065
+ ...Array.isArray(s.givesWayLast) ? { givesWayLast: s.givesWayLast.map(f2) } : {}
2041
2066
  };
2042
2067
  }
2043
2068
  function mapPlace(p, f2) {