@n-uf/placement 26.11.55 → 26.11.57

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 CHANGED
@@ -5,6 +5,50 @@ Versions are calendar versions, `YY.M.R` (year, month of the release, counter wi
5
5
 
6
6
  Unreleased entries live in `changes/` until a release joins them.
7
7
 
8
+ ## 26.11.57
9
+
10
+ - **Added: `Side` and `Axis` in the root.** `Side` is `"top" | "right" | "bottom" | "left"` and `Axis` is `"x" | "y"`, the
11
+ two words every entry and `@n-uf/docking` share. `EdgeBand.side`, `MasterOptions.side`, `PaneRegion`, `PANE_SIDES`,
12
+ `canSplitPane`, `DropFitsOptions.side` and `splitPane` take `Side`; a split's `axis` and the `axis` argument of
13
+ `SplitOptions`' `fixed`, `fixedAcross` and `floor` are `Axis`. The values are the same strings as before: no layout,
14
+ place or id changes.
15
+ - **Removed (breaking): `BandSide` (`./stack`) and `PaneSide` (`./tiling`).** Both were `Side` under another name. A host
16
+ that imported either imports `Side` from `@n-uf/placement` instead (one-line rename; the type is the same set).
17
+
18
+ ## 26.11.56
19
+
20
+ - `./stack`, **added: `fitFloat(want, stage, avoid, { stay: true })`** (`FloatFitOptions`): the float is only moved
21
+ inside the stage, never beside what it covers; `covers` lists every `avoid` rect it covers there and `snapped` is
22
+ false. For a float a person left over content on purpose. Without the option every fit is as before.
23
+ - `./stack`, **added: `StackItem.stepping`**, a fixed item that still takes steps (a page readout with a ladder of its
24
+ own): it keeps its reserved place (`stackGaps` still refuses every gap for it) but steps through its forms and into
25
+ the » menu, gives way and grows back like a movable item with the same forms, `used` and `kept`, and never holds for
26
+ the title rule. `itemSteps(item)` is the one reading (not `fixed`, or `stepping`). A drop beside it may step it, never
27
+ squeeze it under its form's `main.min`. Plain `fixed` is unchanged.
28
+ - `./stack`, **added: the form flags `menu`, `ownCross` and `stepGroup`** (`formMenu`, `formOwnCross`, `formStepGroup`):
29
+ the solver reads a form's kind only through them. `menu` is a form with no room of its own (default the kind `menu`),
30
+ `ownCross` a form drawn at its own size across under the stack's `ownCross` (default the group kinds), `stepGroup` the
31
+ variants a growing title's hold lets come first (default the kind). Each defaults from the kind, so a host that sets
32
+ none sees no change.
33
+ - **Removed (breaking): `pickRank` and `REFUSAL_RANK`.** `@n-uf/motion/drag` owns the pick's rank (it is the one that picks:
34
+ `targetAt`); placement read it nowhere itself. A host that imported them from here imports them from
35
+ `@n-uf/motion/drag` (the same values: a refusal ranks 2.5, a target its priority). `Target` is unchanged, and its
36
+ `refuse` field still marks a refusal.
37
+ - Breaking: **the root `Target` shrinks to a shape of places.** It is now `id`, `priority`, `hit`, `hits`, `slot`, `label`,
38
+ `free`, `refuse` and `bounds`, and carries no time and no timing. Five fields leave it, each now on `@n-uf/docking`'s
39
+ `DockDrop` (and, as before, on `@n-uf/motion/drag`'s `DragTarget`, which is the shape a drag intent reads):
40
+ `arm: "dwell"` (spring-loaded), `armedHit` (its zone once armed), `opensRoom` (its room opens as it shows), `roomHold`
41
+ (ms) and `roomHit` (the zone it holds once its room is open). A host that built a root `Target` with one of them types
42
+ it as a `DragTarget` (or a `DockDrop`) instead; `paneTargets`, `orderTargets` and `stackGaps` never set them. No
43
+ behavior changes: every target, drop, landing frame and fit is as before.
44
+ - `./tiling`, **faster: `layoutSplit` and `layoutSplitTree`**, with the same outputs. A pane's rect and a split's box are
45
+ now made once instead of copied, a divider is built only for a split with an `id`, and `layoutSplit` builds no split
46
+ geometry at all (it used to build it for every split with an `id` and drop it). With no named splits, at 100 panes a
47
+ layout takes about 4 µs against 7 µs, about 1.1x a hand-written layout that fills a map of rects. With every split
48
+ named, `layoutSplitTree` still builds the geometry and takes about 7 µs against 10 µs (about 1.8x); `layoutSplit` on
49
+ the same tree takes about 5 µs. No option was added: a host that needs only pane rects calls `layoutSplit`. `pnpm
50
+ --filter @n-uf/placement bench` times it.
51
+
8
52
  ## 26.11.55
9
53
 
10
54
  - `./tiling`, **added: canSplitPane, dropFits, paneRegion's paneCenter option, master clamps, Rect**, for a host with its own
package/dist/index.d.ts CHANGED
@@ -1,29 +1,27 @@
1
1
  import { R as Rect } from './geometry-L5gCoiZV.js';
2
2
  export { E as EPS, a as PLANE, P as Point, S as Size, b as area, c as center, d as clamp, e as clampInto, f as contains, o as overlap, g as overlaps, r as rect, s as subtract } from './geometry-L5gCoiZV.js';
3
+ export { A as Axis, S as Side } from './side-zvoEwBLn.js';
3
4
 
4
5
  /**
5
6
  * A drop target in the shape @n-uf/motion/drag takes: an id, a priority (1 most precise: a rail or a tab strip;
6
7
  * 2 a slot; 3 a broad area such as floating anywhere), the zone the pointer hits, and optionally where the item
7
8
  * lands, a label and whether it lands freely (no room is made for it). `hits`, when given, is the whole zone as several
8
9
  * rects (a zone that isn't one rect), `hit` the largest of them: the pointer is in the zone when it is in any of them.
9
- * `arm: "dwell"` marks a spring-loaded target (the drag intent arms it once the pointer dwells in it), `armedHit` its
10
- * zone once armed.
10
+ * It is a shape of places only: it carries no time and no timing (what a drag intent does as the pointer dwells in a
11
+ * target's zone is the intent's own, and `@n-uf/docking`'s `DockDrop` carries the fields it reads).
11
12
  */
12
13
  interface Target {
13
14
  readonly id: string;
14
15
  readonly priority: 1 | 2 | 3;
15
16
  readonly hit: Rect;
16
17
  readonly hits?: readonly Rect[];
17
- /** Spring-loaded: no target until the pointer dwells in it. */
18
- readonly arm?: "dwell";
19
- /** Its zone once armed (the strip grown by its magnet). */
20
- readonly armedHit?: Rect;
21
18
  readonly slot?: Rect;
22
19
  readonly label?: string;
23
20
  readonly free?: boolean;
24
21
  /**
25
22
  * A refusal, not a target: it takes part in the pick under the pointer, ranked after every target of priority 1 and 2
26
- * and before priority 3 (`REFUSAL_RANK`, whatever its `priority`), but nothing lands on it (`refusalTargets`).
23
+ * and before priority 3 (`@n-uf/motion/drag`'s `REFUSAL_RANK`, whatever its `priority`: the one pick rule's), but
24
+ * nothing lands on it (`refusalTargets`).
27
25
  */
28
26
  readonly refuse?: true;
29
27
  /**
@@ -34,37 +32,6 @@ interface Target {
34
32
  * stage's edge (`x + width`, `y + height`): a host that clamps to `width - 0.5` still picks inside the window.
35
33
  */
36
34
  readonly bounds?: Rect;
37
- /**
38
- * Its room opens as it shows: the docking model sets it on a target whose slot overlaps an item its drop moves (a rail pushing
39
- * a column, a new-column line, a bar's strip over the columns), and on a rail drop strip's targets, whose room opens
40
- * once armed. The drag intent then shows it and makes its room in one frame. Until it shows, a release still lands on
41
- * it.
42
- */
43
- readonly opensRoom?: true;
44
- /**
45
- * With `opensRoom`, how long it holds before it shows with its room, ms, in place of the drag intent's `roomAfter`. The
46
- * docking model sets it to `EDGE_ROOM_HOLD` on a rail target or a new-column line against the window's left or right edge.
47
- */
48
- readonly roomHold?: number;
49
- /**
50
- * With `opensRoom`, the zone it holds once its room is open: while the target shows with its room open, a drag intent
51
- * holds it wherever the pointer is in this rect. The docking model sets it to the smallest rect holding `hit` and the slot (the
52
- * landing rect) on every target whose drop changes an edge's thickness (a side's width or a bar's height): strips,
53
- * new-column lines, rails and gaps. A rail drop strip (`armedHit`) doesn't carry it.
54
- */
55
- readonly roomHit?: Rect;
56
35
  }
57
- /**
58
- * Where a refusal ranks in the pick (the drag intent's `REFUSAL_RANK`, the same value): an ordering rank, not a
59
- * priority. Priorities stay the integers 1, 2 and 3; a refusal's tier is `refuse: true`, ordered by this rank on the
60
- * same scale: after every target of priority 1 and 2, so a real target wins wherever the two meet or overlap, and
61
- * before priority 3 (the float).
62
- */
63
- declare const REFUSAL_RANK = 2.5;
64
- /** A target's rank in the pick: its `priority`, a refusal's {@link REFUSAL_RANK}. Lower wins. */
65
- declare const pickRank: (t: {
66
- readonly priority: number;
67
- readonly refuse?: true;
68
- }) => number;
69
36
 
70
- export { REFUSAL_RANK, Rect, type Target, pickRank };
37
+ export { Rect, type Target };
package/dist/index.js CHANGED
@@ -11,14 +11,9 @@ import {
11
11
  rect,
12
12
  subtract
13
13
  } from "./chunk-2UVUFEBP.js";
14
-
15
- // src/target.ts
16
- var REFUSAL_RANK = 2.5;
17
- var pickRank = (t) => t.refuse === true ? REFUSAL_RANK : t.priority;
18
14
  export {
19
15
  EPS,
20
16
  PLANE,
21
- REFUSAL_RANK,
22
17
  area,
23
18
  center,
24
19
  clamp,
@@ -26,7 +21,6 @@ export {
26
21
  contains,
27
22
  overlap,
28
23
  overlaps,
29
- pickRank,
30
24
  rect,
31
25
  subtract
32
26
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/target.ts"],"sourcesContent":["import type { Rect } from \"./geometry\";\n\n/**\n * A drop target in the shape @n-uf/motion/drag takes: an id, a priority (1 most precise: a rail or a tab strip;\n * 2 a slot; 3 a broad area such as floating anywhere), the zone the pointer hits, and optionally where the item\n * lands, a label and whether it lands freely (no room is made for it). `hits`, when given, is the whole zone as several\n * rects (a zone that isn't one rect), `hit` the largest of them: the pointer is in the zone when it is in any of them.\n * `arm: \"dwell\"` marks a spring-loaded target (the drag intent arms it once the pointer dwells in it), `armedHit` its\n * zone once armed.\n */\nexport interface Target {\n readonly id: string;\n readonly priority: 1 | 2 | 3;\n readonly hit: Rect;\n readonly hits?: readonly Rect[];\n /** Spring-loaded: no target until the pointer dwells in it. */\n readonly arm?: \"dwell\";\n /** Its zone once armed (the strip grown by its magnet). */\n readonly armedHit?: Rect;\n readonly slot?: Rect;\n readonly label?: string;\n readonly free?: boolean;\n /**\n * A refusal, not a target: it takes part in the pick under the pointer, ranked after every target of priority 1 and 2\n * and before priority 3 (`REFUSAL_RANK`, whatever its `priority`), but nothing lands on it (`refusalTargets`).\n */\n readonly refuse?: true;\n /**\n * The drawn space the zone belongs to (the window's stage): the zone, and a drag intent's band and gap grace about\n * it, hold only points strictly inside it. The window's boundary belongs only to the targets drawn against it: the\n * docking model gives `bounds` to every refusal and to the float (whole-plane), never to a gap or a slot, so a pointer clamped\n * onto the window's edge picks a gap that reaches it, else nothing. That relies on the host clamping exactly onto the\n * stage's edge (`x + width`, `y + height`): a host that clamps to `width - 0.5` still picks inside the window.\n */\n readonly bounds?: Rect;\n /**\n * Its room opens as it shows: the docking model sets it on a target whose slot overlaps an item its drop moves (a rail pushing\n * a column, a new-column line, a bar's strip over the columns), and on a rail drop strip's targets, whose room opens\n * once armed. The drag intent then shows it and makes its room in one frame. Until it shows, a release still lands on\n * it.\n */\n readonly opensRoom?: true;\n /**\n * With `opensRoom`, how long it holds before it shows with its room, ms, in place of the drag intent's `roomAfter`. The\n * docking model sets it to `EDGE_ROOM_HOLD` on a rail target or a new-column line against the window's left or right edge.\n */\n readonly roomHold?: number;\n /**\n * With `opensRoom`, the zone it holds once its room is open: while the target shows with its room open, a drag intent\n * holds it wherever the pointer is in this rect. The docking model sets it to the smallest rect holding `hit` and the slot (the\n * landing rect) on every target whose drop changes an edge's thickness (a side's width or a bar's height): strips,\n * new-column lines, rails and gaps. A rail drop strip (`armedHit`) doesn't carry it.\n */\n readonly roomHit?: Rect;\n}\n\n/**\n * Where a refusal ranks in the pick (the drag intent's `REFUSAL_RANK`, the same value): an ordering rank, not a\n * priority. Priorities stay the integers 1, 2 and 3; a refusal's tier is `refuse: true`, ordered by this rank on the\n * same scale: after every target of priority 1 and 2, so a real target wins wherever the two meet or overlap, and\n * before priority 3 (the float).\n */\nexport const REFUSAL_RANK = 2.5;\n\n/** A target's rank in the pick: its `priority`, a refusal's {@link REFUSAL_RANK}. Lower wins. */\nexport const pickRank = (t: { readonly priority: number; readonly refuse?: true }): number => (t.refuse === true ? REFUSAL_RANK : t.priority);\n"],"mappings":";;;;;;;;;;;;;;;AA8DO,IAAM,eAAe;AAGrB,IAAM,WAAW,CAAC,MAAsE,EAAE,WAAW,OAAO,eAAe,EAAE;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The two words every entry (and `@n-uf/docking`) shares for direction: a side of a stage or a pane, and an axis of a
3
+ * split or a lane. Plain string unions; the values are what hosts already write.
4
+ */
5
+ /** A side of a stage or a pane. */
6
+ type Side = "top" | "right" | "bottom" | "left";
7
+ /** An axis: `"x"` runs left to right, `"y"` top to bottom. */
8
+ type Axis = "x" | "y";
9
+
10
+ export type { Axis as A, Side as S };
package/dist/stack.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { R as Rect } from './geometry-L5gCoiZV.js';
2
+ import { S as Side } from './side-zvoEwBLn.js';
2
3
 
3
4
  /**
4
5
  * `cutEdges(stage, bands)`: the stage cut into bands along its sides, in list order. Each band takes its `size` across
@@ -19,12 +20,10 @@ import { R as Rect } from './geometry-L5gCoiZV.js';
19
20
  * See docs/placement.md, Entry: stack.
20
21
  */
21
22
 
22
- /** A side of the stage. */
23
- type BandSide = "top" | "right" | "bottom" | "left";
24
23
  /** One band of the cut. */
25
24
  interface EdgeBand {
26
25
  readonly id: string;
27
- readonly side: BandSide;
26
+ readonly side: Side;
28
27
  /** Its size across (a top band's height, a left band's width), px. */
29
28
  readonly size: number;
30
29
  /** Space after it before the next band on that side, px (default 0); taken only when the band takes some room. */
@@ -46,10 +45,12 @@ declare function cutEdges(stage: Rect, bands: readonly EdgeBand[]): EdgeCut;
46
45
  *
47
46
  * A form's kind is the host's label, the name it draws by. What a solver reads is said by fields: `setsCross` (it sets
48
47
  * the stack's cross size), `body` (it shows its body: what `open` stands for), `folded` (it shows only its bar: what
49
- * `header` and `fold` stand for), `compact` (icons only: what `icons` stands for), `title`, `wrap` and `hides`. Each of
50
- * the three flags defaults from the kind, so forms that leave them out read as before. Two kinds stay structural: a
51
- * `menu` form has no room of its own (the » entry stands for it), and under `ownCross` the group kinds (`row`,
52
- * `stacked`, `wrap`, `icons`, `fold`) are drawn at their own size across. Panel and group kinds may be mixed on one item.
48
+ * `header` and `fold` stand for), `compact` (icons only: what `icons` stands for), `menu` (no room of its own: the »
49
+ * entry stands for it), `ownCross` (drawn at its own size across under the stack's `ownCross`: what the group kinds
50
+ * `row`, `stacked`, `wrap`, `icons`, `fold` stand for), `stepGroup` (the variants the title rule steps first: default the
51
+ * kind), `title`, `wrap` and `hides`. Each flag defaults from the kind, so forms that leave them out read as before; the
52
+ * solver reads no kind but through them (a kept fit's form at the same index is matched by its kind, a label compared,
53
+ * never read). Panel and group kinds may be mixed on one item.
53
54
  */
54
55
 
55
56
  /** `"column"` runs the stack down (its main size is a height, its cross size a width); `"row"` runs it across. */
@@ -161,7 +162,36 @@ interface StackForm {
161
162
  * titles (`DockState.railModes`, default `"titles"`) and reports the side it reads from (`DockItemLayout.railTitle`).
162
163
  */
163
164
  readonly title?: boolean;
165
+ /**
166
+ * It has no room of its own: the » entry stands for it while the item is in it. Default: true for the kind `menu`. A
167
+ * stack's » menu holds exactly the items in such a form (`StackMenu.items`).
168
+ */
169
+ readonly menu?: boolean;
170
+ /**
171
+ * Under `StackInput.ownCross`, it is drawn at its own `cross.natural` (clamped to the stack's cross size; a `wrap` form
172
+ * as wide as its rows need) from the start edge, instead of across the whole stack. Default: true for the group kinds
173
+ * (`row`, `stacked`, `wrap`, `icons`, `fold`), false for the panel kinds and a menu form. Without `ownCross` it is
174
+ * never read.
175
+ */
176
+ readonly ownCross?: boolean;
177
+ /**
178
+ * The step group it belongs to: forms of one item with the same key are variants of one form (a toolbar's full row and
179
+ * its compact rows). The title rule reads it: while a growing item that takes no steps holds its natural length, only
180
+ * steps within a step group are taken (`StackItem.fixed`). Default: the form's kind.
181
+ */
182
+ readonly stepGroup?: string;
164
183
  }
184
+ /** Whether an item takes give-way steps: a movable one, or a fixed one with `stepping`. */
185
+ declare const itemSteps: (item: {
186
+ readonly fixed?: boolean;
187
+ readonly stepping?: boolean;
188
+ }) => boolean;
189
+ /** Whether a form has no room of its own, the » entry standing for it (`menu`, default: the kind `menu`). */
190
+ declare const formMenu: (f: StackForm) => boolean;
191
+ /** Whether a form is drawn at its own size across under `ownCross` (`ownCross`, default: the group kinds). */
192
+ declare const formOwnCross: (f: StackForm) => boolean;
193
+ /** A form's step group (`stepGroup`, default: its kind). */
194
+ declare const formStepGroup: (f: StackForm) => string;
165
195
  /**
166
196
  * The least a form can be drawn across the stack: its `cross.min` (default its `natural`), or for a `wrap` form the
167
197
  * narrowest cross size at which its rows fit (no single word on a row but the last). A window model's size clamp and
@@ -231,9 +261,19 @@ interface StackItem {
231
261
  * unless that is the form it starts in, and it doesn't take part in `previous`'s growing back. It counts toward the
232
262
  * length like any item (the others give way around it, and a stack too short for it overflows). It is never dropped:
233
263
  * `stackGaps` refuses every gap for it, and a drop beside it never squeezes it. Whether it may sit among others (or
234
- * first, or last) is the host's; placement lays out the items it is given.
264
+ * first, or last) is the host's; placement lays out the items it is given. With `stepping` it keeps only the reserved
265
+ * place and takes its steps like any item.
235
266
  */
236
267
  readonly fixed?: boolean;
268
+ /**
269
+ * A fixed item that still takes steps (default false; read only with `fixed`): it keeps its reserved place (never
270
+ * dropped: `stackGaps` refuses every gap for it) but steps through its forms, into the » menu too, gives way by the
271
+ * usual order and grows back in exact reverse: its fit is a movable item's with the same forms, `used` and `kept`. It
272
+ * never holds for the title rule (that is a growing item that takes no steps); to have it shorten last, make it `kept`
273
+ * or rank its forms. A drop beside it may step it, as it may a movable item, but never squeezes it under its form's
274
+ * `main.min`.
275
+ */
276
+ readonly stepping?: boolean;
237
277
  /**
238
278
  * The length asked for along the stack (default none). While the item is in a form that grows (`main.grows`; a `wrap`
239
279
  * form that grows shares spare length too), the solver reads it, for the stack's axis, in place of that form's `main.natural`; the form's
@@ -331,7 +371,7 @@ interface PlacedStackItem {
331
371
  interface StackMenu {
332
372
  /** The » entry's rect. */
333
373
  readonly rect: Rect;
334
- /** The items in it, in the stack's order: exactly the items whose kind is `menu`. */
374
+ /** The items in it, in the stack's order: exactly the items in a menu form (`StackForm.menu`). */
335
375
  readonly items: readonly string[];
336
376
  }
337
377
  /**
@@ -596,7 +636,8 @@ declare function resetLengths(input: StackInput): StackInput;
596
636
  * The item counts as just used: it is newer than every item in the stack, so the others give way before it. It fits a
597
637
  * gap when the drop's fit doesn't put it in the » menu, has no `overflow`, makes no item `too-wide` that wasn't before,
598
638
  * and squeezes no `fixed` item (it keeps its form, is drawn at least its form's `main.min` along the stack and at least
599
- * as wide across as before). A fixed item may shrink down to its `main.min` to make room.
639
+ * as wide across as before). A fixed item may shrink down to its `main.min` to make room; one with `stepping` may also
640
+ * step to a later form, as a movable item may.
600
641
  *
601
642
  * Reasons: `no-forms` (the item has none), `fixed` (a fixed item is never dropped), `not-accepted` (`input.accepts`
602
643
  * refuses it), `not-allowed` (`options.allows` refuses the gap), `to-menu`, `overflow`, `too-wide` and `squeezes-fixed`.
@@ -642,6 +683,9 @@ declare function stackGaps(input: StackInput, item: StackItem, options?: StackGa
642
683
  * about 17 ms; a safety net stops the clear search after 3 million rect tests and says so in `searchCapped`; a stage
643
684
  * with no clear place looks at the 2,048 nearest places for the least covered.
644
685
  *
686
+ * With `{ stay: true }` it is only moved inside the stage: it lies where it is asked, and `covers` says which `avoid`
687
+ * rects it covers there (a float a person left over content on purpose).
688
+ *
645
689
  * A window model fits its floats with it.
646
690
  */
647
691
 
@@ -661,6 +705,13 @@ interface FloatFit {
661
705
  /** The safety net on the clear search was hit (thousands of rects): the place found may not be the nearest, or a clear place may exist that was not found. Normally false. */
662
706
  readonly searchCapped: boolean;
663
707
  }
664
- declare function fitFloat(want: Rect, stage: Rect, avoid?: readonly Rect[]): FloatFit;
708
+ interface FloatFitOptions {
709
+ /**
710
+ * Only moved inside the stage, never beside what it covers: `rect` is the asked rect clamped into the stage, `snapped`
711
+ * is false and `covers` lists every `avoid` rect it covers there. Default false.
712
+ */
713
+ readonly stay?: boolean;
714
+ }
715
+ declare function fitFloat(want: Rect, stage: Rect, avoid?: readonly Rect[], options?: FloatFitOptions): FloatFit;
665
716
 
666
- export { type BandSide, type ControlLadder, type ControlLadderSpec, type CrossLimits, DEFAULT_MENU, DEFAULT_RAIL, type EdgeBand, type EdgeCut, type FitOptions, type FloatFit, type GroupFormKind, type LadderControl, type MainSize, type PanelFormKind, type PlacedStackItem, type StackAxis, type StackDivider, type StackFit, type StackForm, type StackFormKind, type StackGap, type StackGapOptions, type StackGapRefusal, type StackInput, type StackItem, type StackLengths, type StackMenu, type StackNote, type StackNoteCode, type StackStep, type WrapSpec, controlLadder, cutEdges, dividers, fitFloat, fitStack, formBody, formCompact, formCrossMin, formFitsCross, formFolded, formMain, formSetsCross, resetBetween, resetLengths, resizeBetween, stackGaps, withItem, wrapCross, wrapLines, wrapRows };
717
+ export { type ControlLadder, type ControlLadderSpec, type CrossLimits, DEFAULT_MENU, DEFAULT_RAIL, type EdgeBand, type EdgeCut, type FitOptions, type FloatFit, type FloatFitOptions, type GroupFormKind, type LadderControl, type MainSize, type PanelFormKind, type PlacedStackItem, type StackAxis, type StackDivider, type StackFit, type StackForm, type StackFormKind, type StackGap, type StackGapOptions, type StackGapRefusal, type StackInput, type StackItem, type StackLengths, type StackMenu, type StackNote, type StackNoteCode, type StackStep, type WrapSpec, controlLadder, cutEdges, dividers, fitFloat, fitStack, formBody, formCompact, formCrossMin, formFitsCross, formFolded, formMain, formMenu, formOwnCross, formSetsCross, formStepGroup, itemSteps, resetBetween, resetLengths, resizeBetween, stackGaps, withItem, wrapCross, wrapLines, wrapRows };
package/dist/stack.js CHANGED
@@ -50,6 +50,11 @@ function cutEdges(stage, bands) {
50
50
  }
51
51
 
52
52
  // src/stack/model.ts
53
+ var itemSteps = (item) => item.fixed !== true || item.stepping === true;
54
+ var formMenu = (f) => f.menu ?? f.kind === "menu";
55
+ var formOwnCross = (f) => f.ownCross ?? GROUP_KINDS.has(f.kind);
56
+ var formStepGroup = (f) => f.stepGroup ?? f.kind;
57
+ var GROUP_KINDS = /* @__PURE__ */ new Set(["row", "stacked", "wrap", "icons", "fold"]);
53
58
  var nonNeg = (x) => typeof x === "number" && Number.isFinite(x) ? Math.max(0, x) : 0;
54
59
  function formCrossMin(f) {
55
60
  if (f.wrap) return wrapCross(f.wrap).min;
@@ -57,7 +62,7 @@ function formCrossMin(f) {
57
62
  return Number.isFinite(v) ? v : 0;
58
63
  }
59
64
  function formMain(f, which, cross) {
60
- if (f.kind === "menu") return 0;
65
+ if (formMenu(f)) return 0;
61
66
  if (f.wrap) return wrapRows(f.wrap, cross).rows * nonNeg(f.wrap.row);
62
67
  return nonNeg(f.main[which]);
63
68
  }
@@ -148,7 +153,7 @@ var formSetsCross = (f) => f.setsCross ?? formBody(f);
148
153
  function askedLength(item, form, axis) {
149
154
  const v = item.lengths?.[axis];
150
155
  if (v === void 0 || !Number.isFinite(v) || v <= EPS) return void 0;
151
- return form.kind !== "menu" && form.main.grows === true ? v : void 0;
156
+ return !formMenu(form) && form.main.grows === true ? v : void 0;
152
157
  }
153
158
  function withItem(input, item, at) {
154
159
  const k = Math.min(Math.max(0, Math.floor(at)), input.items.length);
@@ -156,8 +161,7 @@ function withItem(input, item, at) {
156
161
  }
157
162
 
158
163
  // src/stack/layout.ts
159
- var isMenu = (f) => f.kind === "menu";
160
- var GROUP_KINDS = /* @__PURE__ */ new Set(["row", "stacked", "wrap", "icons", "fold"]);
164
+ var isMenu = formMenu;
161
165
  var finite2 = (x, fallback = 0) => Number.isFinite(x) ? x : fallback;
162
166
  var mainOf = formMain;
163
167
  var crossMin = formCrossMin;
@@ -166,7 +170,7 @@ var rankOf = (f) => finite2(f.rank ?? 0);
166
170
  function victim(items, to) {
167
171
  let best = -1;
168
172
  for (let i = 0; i < items.length; i++) {
169
- if (to[i] < 0 || items[i].fixed) continue;
173
+ if (to[i] < 0 || !itemSteps(items[i])) continue;
170
174
  if (best < 0) {
171
175
  best = i;
172
176
  continue;
@@ -210,7 +214,7 @@ function solve(input, previous, seed, grow = false) {
210
214
  for (const n of previous.notes) if (n.code === "form-down" && !began.has(n.id)) began.set(n.id, n.from);
211
215
  items.forEach((it, i) => {
212
216
  const p = had.get(it.id);
213
- if (it.fixed || !p || p.form < start[i] || p.form >= it.forms.length || start[i] < (began.get(it.id) ?? p.form)) return;
217
+ if (!itemSteps(it) || !p || p.form < start[i] || p.form >= it.forms.length || start[i] < (began.get(it.id) ?? p.form)) return;
214
218
  const f = it.forms[p.form];
215
219
  if (f.kind === p.kind && offered(f)) at[i] = p.form;
216
220
  });
@@ -263,14 +267,14 @@ function solve(input, previous, seed, grow = false) {
263
267
  const slots = idx.filter((i) => !isMenu(form(i))).length + (inMenu() ? 1 : 0);
264
268
  return slots > 1 ? (slots - 1) * sp.gap : 0;
265
269
  };
266
- const holds = (i) => items[i].fixed === true && form(i).main.grows === true;
270
+ const holds = (i) => !itemSteps(items[i]) && form(i).main.grows === true;
267
271
  let hold = idx.some(holds);
268
272
  const minSumWith = (held) => {
269
273
  const c = items.some((it) => it.forms.some((f) => f.wrap)) ? crossOf() : 0;
270
274
  return idx.reduce((s, i) => s + mainOf(form(i), held && holds(i) ? "natural" : "min", c), 0) + (inMenu() ? menuMain(input) : 0) + gapsOf() + sp.start + sp.end;
271
275
  };
272
276
  const minSum = () => minSumWith(hold);
273
- const sameKind = (i, j) => items[i].forms[j].kind === form(i).kind;
277
+ const sameKind = (i, j) => formStepGroup(items[i].forms[j]) === formStepGroup(form(i));
274
278
  const stepTo = (i) => {
275
279
  const from = at[i];
276
280
  const base = minSum();
@@ -330,7 +334,7 @@ function solve(input, previous, seed, grow = false) {
330
334
  const changed = [...new Set(group.map((s) => index.get(s.id)))];
331
335
  const was = changed.map((i) => at[i]);
332
336
  const forms = (s) => items[index.get(s.id)].forms;
333
- hold = group.every((s) => forms(s)[s.from].kind === forms(s)[s.to].kind) && idx.some(holds);
337
+ hold = group.every((s) => formStepGroup(forms(s)[s.from]) === formStepGroup(forms(s)[s.to])) && idx.some(holds);
334
338
  for (const s of [...group].reverse()) at[index.get(s.id)] = s.from;
335
339
  if (minSum() <= length + EPS && crossOf() === c0 && changed.every((j) => !tooWide(j, c0))) return true;
336
340
  changed.forEach((i, k) => at[i] = was[k]);
@@ -357,7 +361,7 @@ function solve(input, previous, seed, grow = false) {
357
361
  if (stuck) break;
358
362
  const c0 = crossOf();
359
363
  const fitsWith = (changed) => minSum() <= length + EPS && crossOf() === c0 && changed.every((j) => !tooWide(j, c0));
360
- const queue = idx.filter((i) => !items[i].fixed && at[i] > start[i] && !withHistory.has(items[i].id)).sort((a, b) => comesBefore(a, b) ? -1 : 1);
364
+ const queue = idx.filter((i) => itemSteps(items[i]) && at[i] > start[i] && !withHistory.has(items[i].id)).sort((a, b) => comesBefore(a, b) ? -1 : 1);
361
365
  const next = queue[0];
362
366
  if (next === void 0) break;
363
367
  const cur = at[next];
@@ -398,7 +402,7 @@ function solve(input, previous, seed, grow = false) {
398
402
  cross = crossOf();
399
403
  let stepped = false;
400
404
  for (const i of idx) {
401
- if (!items[i].fixed && tooWide(i, cross) && canStep(i) && !isMenu(items[i].forms[nextOffered(i)])) {
405
+ if (itemSteps(items[i]) && tooWide(i, cross) && canStep(i) && !isMenu(items[i].forms[nextOffered(i)])) {
402
406
  step(i, nextOffered(i));
403
407
  stepped = true;
404
408
  }
@@ -406,7 +410,7 @@ function solve(input, previous, seed, grow = false) {
406
410
  if (stepped) continue;
407
411
  const over = minSum() - length;
408
412
  if (over <= EPS) break;
409
- const to = idx.map((i) => items[i].fixed ? -1 : stepTo(i));
413
+ const to = idx.map((i) => itemSteps(items[i]) ? stepTo(i) : -1);
410
414
  if (hold) {
411
415
  const variant = victim(
412
416
  items,
@@ -416,7 +420,7 @@ function solve(input, previous, seed, grow = false) {
416
420
  else hold = false;
417
421
  continue;
418
422
  }
419
- const pool = idx.map((i) => to[i] < 0 && !inMenu() && !items[i].fixed ? menuFormAfter(i) : -1);
423
+ const pool = idx.map((i) => to[i] < 0 && !inMenu() && itemSteps(items[i]) ? menuFormAfter(i) : -1);
420
424
  const v = victim(
421
425
  items,
422
426
  idx.map((i) => to[i] >= 0 ? to[i] : pool[i])
@@ -486,7 +490,7 @@ function solve(input, previous, seed, grow = false) {
486
490
  const rectAt = (from, main, across = cross) => input.axis === "column" ? { x: 0, y: from, width: across, height: main } : { x: from, y: 0, width: main, height: across };
487
491
  const acrossOf = (i) => {
488
492
  const f = form(i);
489
- if (input.ownCross !== true || !GROUP_KINDS.has(f.kind)) return cross;
493
+ if (input.ownCross !== true || !formOwnCross(f)) return cross;
490
494
  if (f.wrap) return Math.min(cross, wrapRows(f.wrap, cross).width);
491
495
  return Math.min(cross, Math.max(0, finite2(f.cross.natural, cross)));
492
496
  };
@@ -569,7 +573,7 @@ function growers(input, fit) {
569
573
  fit.items.forEach((p, at) => {
570
574
  const item = byId.get(p.id);
571
575
  const f = item?.forms[p.form];
572
- if (!item || !f || p.kind === "menu" || f.kind === "menu" || f.main.grows !== true) return;
576
+ if (!item || !f || formMenu(f) || f.main.grows !== true) return;
573
577
  const least = known?.least.get(p.id) ?? formMain(f, "min", fit.cross);
574
578
  out.push({ id: p.id, end: item.fixed !== true && !f.wrap, least, natural: Math.max(least, formMain(f, "natural", fit.cross)), drawn: mainOf2(p.rect, fit.axis), at });
575
579
  });
@@ -625,7 +629,7 @@ function dividers(input, fit) {
625
629
  const a = all[k + 1];
626
630
  if (!b.end || !a.end) continue;
627
631
  let prev = a.at - 1;
628
- while (prev > b.at && fit.items[prev].kind === "menu") prev--;
632
+ while (prev > b.at && fit.menu?.items.includes(fit.items[prev].id)) prev--;
629
633
  const last = fit.items[prev].rect;
630
634
  const from = startOf(last, fit.axis) + mainOf2(last, fit.axis);
631
635
  const thick = Math.max(0, startOf(fit.items[a.at].rect, fit.axis) - from);
@@ -664,7 +668,9 @@ function resetLengths(input) {
664
668
 
665
669
  // src/stack/gaps.ts
666
670
  function refusalOf(base, fit, dragged, fixed, axis, tooWideBefore) {
667
- if (dragged.kind === "menu") return "to-menu";
671
+ const inMenu = new Set(fit.menu?.items ?? []);
672
+ const wasInMenu = new Set(base.menu?.items ?? []);
673
+ if (inMenu.has(dragged.id)) return "to-menu";
668
674
  for (const n of fit.notes) {
669
675
  if (n.code === "overflow") return "overflow";
670
676
  if (n.code === "too-wide" && !tooWideBefore.has(n.id)) return "too-wide";
@@ -675,10 +681,10 @@ function refusalOf(base, fit, dragged, fixed, axis, tooWideBefore) {
675
681
  for (const p of fit.items) {
676
682
  const item = fixed.get(p.id);
677
683
  const q = was.get(p.id);
678
- if (!item || !q || p.kind === "menu" || q.kind === "menu") continue;
679
- if (p.form !== q.form) return "squeezes-fixed";
684
+ if (!item || !q || inMenu.has(p.id) || wasInMenu.has(q.id)) continue;
685
+ if (p.form !== q.form && !itemSteps(item)) return "squeezes-fixed";
680
686
  if (main(p.rect) < formMain(item.forms[p.form], "min", fit.cross) - 1e-6) return "squeezes-fixed";
681
- if (across(p.rect) < across(q.rect) - 1e-6) return "squeezes-fixed";
687
+ if (p.form === q.form && across(p.rect) < across(q.rect) - 1e-6) return "squeezes-fixed";
682
688
  }
683
689
  return null;
684
690
  }
@@ -760,7 +766,7 @@ function* byDistance(xs, ys, fx, fy) {
760
766
  if (j + 1 < sy.length) q.push([i, j + 1, d(i, j + 1)]);
761
767
  }
762
768
  }
763
- function fitFloat(want, stage, avoid = []) {
769
+ function fitFloat(want, stage, avoid = [], options = {}) {
764
770
  const area = clean(stage, rect(0, 0, 0, 0));
765
771
  const r = clean(want, area);
766
772
  const inside = clampInto(r, area);
@@ -773,6 +779,7 @@ function fitFloat(want, stage, avoid = []) {
773
779
  });
774
780
  const under = (cand) => near.filter((n) => overlaps(cand, n.at, EPS2)).map((n) => n.index);
775
781
  const blocked = (cand) => near.some((n) => overlaps(cand, n.at, EPS2));
782
+ if (options.stay) return { rect: inside, clamped, snapped: false, covers: under(inside), searchCapped: false };
776
783
  if (!blocked(inside)) return { rect: inside, clamped, snapped: false, covers: [], searchCapped: false };
777
784
  const lo = (v, from, to) => Math.min(Math.max(v, from), Math.max(from, to));
778
785
  const xs = [inside.x, area.x, area.x + area.width - r.width];
@@ -846,7 +853,11 @@ export {
846
853
  formFitsCross,
847
854
  formFolded,
848
855
  formMain,
856
+ formMenu,
857
+ formOwnCross,
849
858
  formSetsCross,
859
+ formStepGroup,
860
+ itemSteps,
850
861
  resetBetween,
851
862
  resetLengths,
852
863
  resizeBetween,