@n-uf/placement 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 CHANGED
@@ -5,6 +5,40 @@ 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.56
9
+
10
+ - `./stack`, **added: `fitFloat(want, stage, avoid, { stay: true })`** (`FloatFitOptions`): the float is only moved
11
+ inside the stage, never beside what it covers; `covers` lists every `avoid` rect it covers there and `snapped` is
12
+ false. For a float a person left over content on purpose. Without the option every fit is as before.
13
+ - `./stack`, **added: `StackItem.stepping`**, a fixed item that still takes steps (a page readout with a ladder of its
14
+ own): it keeps its reserved place (`stackGaps` still refuses every gap for it) but steps through its forms and into
15
+ the » menu, gives way and grows back like a movable item with the same forms, `used` and `kept`, and never holds for
16
+ the title rule. `itemSteps(item)` is the one reading (not `fixed`, or `stepping`). A drop beside it may step it, never
17
+ squeeze it under its form's `main.min`. Plain `fixed` is unchanged.
18
+ - `./stack`, **added: the form flags `menu`, `ownCross` and `stepGroup`** (`formMenu`, `formOwnCross`, `formStepGroup`):
19
+ the solver reads a form's kind only through them. `menu` is a form with no room of its own (default the kind `menu`),
20
+ `ownCross` a form drawn at its own size across under the stack's `ownCross` (default the group kinds), `stepGroup` the
21
+ variants a growing title's hold lets come first (default the kind). Each defaults from the kind, so a host that sets
22
+ none sees no change.
23
+ - **Removed (breaking): `pickRank` and `REFUSAL_RANK`.** `@n-uf/motion/drag` owns the pick's rank (it is the one that picks:
24
+ `targetAt`); placement read it nowhere itself. A host that imported them from here imports them from
25
+ `@n-uf/motion/drag` (the same values: a refusal ranks 2.5, a target its priority). `Target` is unchanged, and its
26
+ `refuse` field still marks a refusal.
27
+ - Breaking: **the root `Target` shrinks to a shape of places.** It is now `id`, `priority`, `hit`, `hits`, `slot`, `label`,
28
+ `free`, `refuse` and `bounds`, and carries no time and no timing. Five fields leave it, each now on `@n-uf/docking`'s
29
+ `DockDrop` (and, as before, on `@n-uf/motion/drag`'s `DragTarget`, which is the shape a drag intent reads):
30
+ `arm: "dwell"` (spring-loaded), `armedHit` (its zone once armed), `opensRoom` (its room opens as it shows), `roomHold`
31
+ (ms) and `roomHit` (the zone it holds once its room is open). A host that built a root `Target` with one of them types
32
+ it as a `DragTarget` (or a `DockDrop`) instead; `paneTargets`, `orderTargets` and `stackGaps` never set them. No
33
+ behavior changes: every target, drop, landing frame and fit is as before.
34
+ - `./tiling`, **faster: `layoutSplit` and `layoutSplitTree`**, with the same outputs. A pane's rect and a split's box are
35
+ now made once instead of copied, a divider is built only for a split with an `id`, and `layoutSplit` builds no split
36
+ 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
37
+ layout takes about 4 µs against 7 µs, about 1.1x a hand-written layout that fills a map of rects. With every split
38
+ named, `layoutSplitTree` still builds the geometry and takes about 7 µs against 10 µs (about 1.8x); `layoutSplit` on
39
+ the same tree takes about 5 µs. No option was added: a host that needs only pane rects calls `layoutSplit`. `pnpm
40
+ --filter @n-uf/placement bench` times it.
41
+
8
42
  ## 26.11.55
9
43
 
10
44
  - `./tiling`, **added: canSplitPane, dropFits, paneRegion's paneCenter option, master clamps, Rect**, for a host with its own
package/dist/index.d.ts CHANGED
@@ -6,24 +6,21 @@ export { E as EPS, a as PLANE, P as Point, S as Size, b as area, c as center, d
6
6
  * 2 a slot; 3 a broad area such as floating anywhere), the zone the pointer hits, and optionally where the item
7
7
  * lands, a label and whether it lands freely (no room is made for it). `hits`, when given, is the whole zone as several
8
8
  * 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.
9
+ * 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
10
+ * target's zone is the intent's own, and `@n-uf/docking`'s `DockDrop` carries the fields it reads).
11
11
  */
12
12
  interface Target {
13
13
  readonly id: string;
14
14
  readonly priority: 1 | 2 | 3;
15
15
  readonly hit: Rect;
16
16
  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
17
  readonly slot?: Rect;
22
18
  readonly label?: string;
23
19
  readonly free?: boolean;
24
20
  /**
25
21
  * 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`).
22
+ * and before priority 3 (`@n-uf/motion/drag`'s `REFUSAL_RANK`, whatever its `priority`: the one pick rule's), but
23
+ * nothing lands on it (`refusalTargets`).
27
24
  */
28
25
  readonly refuse?: true;
29
26
  /**
@@ -34,37 +31,6 @@ interface Target {
34
31
  * stage's edge (`x + width`, `y + height`): a host that clamps to `width - 0.5` still picks inside the window.
35
32
  */
36
33
  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
34
  }
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
35
 
70
- export { REFUSAL_RANK, Rect, type Target, pickRank };
36
+ 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":[]}
package/dist/stack.d.ts CHANGED
@@ -46,10 +46,12 @@ declare function cutEdges(stage: Rect, bands: readonly EdgeBand[]): EdgeCut;
46
46
  *
47
47
  * 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
48
  * 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.
49
+ * `header` and `fold` stand for), `compact` (icons only: what `icons` stands for), `menu` (no room of its own: the »
50
+ * entry stands for it), `ownCross` (drawn at its own size across under the stack's `ownCross`: what the group kinds
51
+ * `row`, `stacked`, `wrap`, `icons`, `fold` stand for), `stepGroup` (the variants the title rule steps first: default the
52
+ * kind), `title`, `wrap` and `hides`. Each flag defaults from the kind, so forms that leave them out read as before; the
53
+ * solver reads no kind but through them (a kept fit's form at the same index is matched by its kind, a label compared,
54
+ * never read). Panel and group kinds may be mixed on one item.
53
55
  */
54
56
 
55
57
  /** `"column"` runs the stack down (its main size is a height, its cross size a width); `"row"` runs it across. */
@@ -161,7 +163,36 @@ interface StackForm {
161
163
  * titles (`DockState.railModes`, default `"titles"`) and reports the side it reads from (`DockItemLayout.railTitle`).
162
164
  */
163
165
  readonly title?: boolean;
166
+ /**
167
+ * 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
168
+ * stack's » menu holds exactly the items in such a form (`StackMenu.items`).
169
+ */
170
+ readonly menu?: boolean;
171
+ /**
172
+ * Under `StackInput.ownCross`, it is drawn at its own `cross.natural` (clamped to the stack's cross size; a `wrap` form
173
+ * as wide as its rows need) from the start edge, instead of across the whole stack. Default: true for the group kinds
174
+ * (`row`, `stacked`, `wrap`, `icons`, `fold`), false for the panel kinds and a menu form. Without `ownCross` it is
175
+ * never read.
176
+ */
177
+ readonly ownCross?: boolean;
178
+ /**
179
+ * 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
180
+ * its compact rows). The title rule reads it: while a growing item that takes no steps holds its natural length, only
181
+ * steps within a step group are taken (`StackItem.fixed`). Default: the form's kind.
182
+ */
183
+ readonly stepGroup?: string;
164
184
  }
185
+ /** Whether an item takes give-way steps: a movable one, or a fixed one with `stepping`. */
186
+ declare const itemSteps: (item: {
187
+ readonly fixed?: boolean;
188
+ readonly stepping?: boolean;
189
+ }) => boolean;
190
+ /** Whether a form has no room of its own, the » entry standing for it (`menu`, default: the kind `menu`). */
191
+ declare const formMenu: (f: StackForm) => boolean;
192
+ /** Whether a form is drawn at its own size across under `ownCross` (`ownCross`, default: the group kinds). */
193
+ declare const formOwnCross: (f: StackForm) => boolean;
194
+ /** A form's step group (`stepGroup`, default: its kind). */
195
+ declare const formStepGroup: (f: StackForm) => string;
165
196
  /**
166
197
  * The least a form can be drawn across the stack: its `cross.min` (default its `natural`), or for a `wrap` form the
167
198
  * 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 +262,19 @@ interface StackItem {
231
262
  * unless that is the form it starts in, and it doesn't take part in `previous`'s growing back. It counts toward the
232
263
  * length like any item (the others give way around it, and a stack too short for it overflows). It is never dropped:
233
264
  * `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.
265
+ * first, or last) is the host's; placement lays out the items it is given. With `stepping` it keeps only the reserved
266
+ * place and takes its steps like any item.
235
267
  */
236
268
  readonly fixed?: boolean;
269
+ /**
270
+ * A fixed item that still takes steps (default false; read only with `fixed`): it keeps its reserved place (never
271
+ * dropped: `stackGaps` refuses every gap for it) but steps through its forms, into the » menu too, gives way by the
272
+ * usual order and grows back in exact reverse: its fit is a movable item's with the same forms, `used` and `kept`. It
273
+ * never holds for the title rule (that is a growing item that takes no steps); to have it shorten last, make it `kept`
274
+ * 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
275
+ * `main.min`.
276
+ */
277
+ readonly stepping?: boolean;
237
278
  /**
238
279
  * The length asked for along the stack (default none). While the item is in a form that grows (`main.grows`; a `wrap`
239
280
  * 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 +372,7 @@ interface PlacedStackItem {
331
372
  interface StackMenu {
332
373
  /** The » entry's rect. */
333
374
  readonly rect: Rect;
334
- /** The items in it, in the stack's order: exactly the items whose kind is `menu`. */
375
+ /** The items in it, in the stack's order: exactly the items in a menu form (`StackForm.menu`). */
335
376
  readonly items: readonly string[];
336
377
  }
337
378
  /**
@@ -596,7 +637,8 @@ declare function resetLengths(input: StackInput): StackInput;
596
637
  * 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
638
  * 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
639
  * 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.
640
+ * as wide across as before). A fixed item may shrink down to its `main.min` to make room; one with `stepping` may also
641
+ * step to a later form, as a movable item may.
600
642
  *
601
643
  * Reasons: `no-forms` (the item has none), `fixed` (a fixed item is never dropped), `not-accepted` (`input.accepts`
602
644
  * refuses it), `not-allowed` (`options.allows` refuses the gap), `to-menu`, `overflow`, `too-wide` and `squeezes-fixed`.
@@ -642,6 +684,9 @@ declare function stackGaps(input: StackInput, item: StackItem, options?: StackGa
642
684
  * about 17 ms; a safety net stops the clear search after 3 million rect tests and says so in `searchCapped`; a stage
643
685
  * with no clear place looks at the 2,048 nearest places for the least covered.
644
686
  *
687
+ * With `{ stay: true }` it is only moved inside the stage: it lies where it is asked, and `covers` says which `avoid`
688
+ * rects it covers there (a float a person left over content on purpose).
689
+ *
645
690
  * A window model fits its floats with it.
646
691
  */
647
692
 
@@ -661,6 +706,13 @@ interface FloatFit {
661
706
  /** 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
707
  readonly searchCapped: boolean;
663
708
  }
664
- declare function fitFloat(want: Rect, stage: Rect, avoid?: readonly Rect[]): FloatFit;
709
+ interface FloatFitOptions {
710
+ /**
711
+ * Only moved inside the stage, never beside what it covers: `rect` is the asked rect clamped into the stage, `snapped`
712
+ * is false and `covers` lists every `avoid` rect it covers there. Default false.
713
+ */
714
+ readonly stay?: boolean;
715
+ }
716
+ declare function fitFloat(want: Rect, stage: Rect, avoid?: readonly Rect[], options?: FloatFitOptions): FloatFit;
665
717
 
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 };
718
+ export { type BandSide, 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,