@n-uf/placement 26.11.53 → 26.11.55
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 +149 -1
- package/README.md +38 -58
- package/dist/{chunk-VLTYJHUA.js → chunk-2UVUFEBP.js} +4 -8
- package/dist/{chunk-VLTYJHUA.js.map → chunk-2UVUFEBP.js.map} +1 -1
- package/dist/{geometry-Bf37LbCT.d.ts → geometry-L5gCoiZV.d.ts} +2 -8
- package/dist/index.d.ts +64 -42
- package/dist/index.js +6 -66
- package/dist/index.js.map +1 -1
- package/dist/popup.d.ts +49 -0
- package/dist/popup.js +58 -0
- package/dist/popup.js.map +1 -0
- package/dist/stack.d.ts +611 -225
- package/dist/stack.js +843 -28
- package/dist/stack.js.map +1 -1
- package/dist/tiling.d.ts +239 -18
- package/dist/tiling.js +372 -19
- package/dist/tiling.js.map +1 -1
- package/package.json +9 -36
- package/dist/chunk-2GGJ4GVR.js +0 -9
- package/dist/chunk-2GGJ4GVR.js.map +0 -1
- package/dist/chunk-3ZICYLWL.js +0 -791
- package/dist/chunk-3ZICYLWL.js.map +0 -1
- package/dist/chunk-AE3BWTAE.js +0 -838
- package/dist/chunk-AE3BWTAE.js.map +0 -1
- package/dist/chunk-JVAR67OL.js +0 -172
- package/dist/chunk-JVAR67OL.js.map +0 -1
- package/dist/chunk-NF7RYK3U.js +0 -429
- package/dist/chunk-NF7RYK3U.js.map +0 -1
- package/dist/chunk-R3AAANRY.js +0 -220
- package/dist/chunk-R3AAANRY.js.map +0 -1
- package/dist/chunk-TWI644JK.js +0 -221
- package/dist/chunk-TWI644JK.js.map +0 -1
- package/dist/chunk-ZTH5FCUO.js +0 -4190
- package/dist/chunk-ZTH5FCUO.js.map +0 -1
- package/dist/constructions-Cbz7uEAZ.d.ts +0 -251
- package/dist/desk.d.ts +0 -51
- package/dist/desk.js +0 -111
- package/dist/desk.js.map +0 -1
- package/dist/dock.d.ts +0 -25
- package/dist/dock.js +0 -397
- package/dist/dock.js.map +0 -1
- package/dist/float-fit-DCYxRMru.d.ts +0 -37
- package/dist/lanes-DIwUqchd.d.ts +0 -1321
- package/dist/model-X7eUaKlA.d.ts +0 -337
- package/dist/panels.d.ts +0 -60
- package/dist/panels.js +0 -99
- package/dist/panels.js.map +0 -1
- package/dist/regions-Db_RyT4P.d.ts +0 -48
- package/dist/scene-cases.d.ts +0 -888
- package/dist/scene-cases.js +0 -3149
- package/dist/scene-cases.js.map +0 -1
- package/dist/scene.d.ts +0 -290
- package/dist/scene.js +0 -128
- package/dist/scene.js.map +0 -1
- package/dist/target-BBOCeez2.d.ts +0 -69
- package/dist/targets-C9ZVhmCl.d.ts +0 -621
- package/dist/targets.d.ts +0 -212
- package/dist/targets.js +0 -447
- package/dist/targets.js.map +0 -1
- package/dist/toolbar.d.ts +0 -167
- package/dist/toolbar.js +0 -55
- package/dist/toolbar.js.map +0 -1
package/dist/stack.d.ts
CHANGED
|
@@ -1,8 +1,428 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { R as Rect } from './geometry-L5gCoiZV.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `cutEdges(stage, bands)`: the stage cut into bands along its sides, in list order. Each band takes its `size` across
|
|
5
|
+
* at its side of what the bands before it left, so the order decides the corners: a top band cut before a left one runs
|
|
6
|
+
* across the whole width and the left one starts below it; cut after it, the left one runs the whole height. Pure: no
|
|
7
|
+
* edges, items or forms, only rects.
|
|
8
|
+
*
|
|
9
|
+
* - A `reserve` band (the default) shortens the leftover: what follows is cut from what it leaves.
|
|
10
|
+
* - An `over` band lies over the leftover without shortening it. The `over` bands are cut after every reserved band,
|
|
11
|
+
* whatever the list order, from the final leftover less the `over` bands before them, so each lies inside the
|
|
12
|
+
* leftover, two on one side lie side by side, and the leftover stays whole.
|
|
13
|
+
* - A band is never thicker than the room left across it (a negative or missing size is 0). `gap` is space after it,
|
|
14
|
+
* taken only when the band takes some room, and never more than the room left. A stage of negative size is cut as
|
|
15
|
+
* one of size 0.
|
|
16
|
+
*
|
|
17
|
+
* Returns each band's rect by id and the leftover rect (`rest`). Band ids are unique: a repeat throws.
|
|
18
|
+
*
|
|
19
|
+
* See docs/placement.md, Entry: stack.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/** A side of the stage. */
|
|
23
|
+
type BandSide = "top" | "right" | "bottom" | "left";
|
|
24
|
+
/** One band of the cut. */
|
|
25
|
+
interface EdgeBand {
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly side: BandSide;
|
|
28
|
+
/** Its size across (a top band's height, a left band's width), px. */
|
|
29
|
+
readonly size: number;
|
|
30
|
+
/** Space after it before the next band on that side, px (default 0); taken only when the band takes some room. */
|
|
31
|
+
readonly gap?: number;
|
|
32
|
+
/** `"reserve"` (default) shortens the leftover; `"over"` lies over it. */
|
|
33
|
+
readonly mode?: "reserve" | "over";
|
|
34
|
+
}
|
|
35
|
+
/** The cut: each band's rect by id, and what is left. */
|
|
36
|
+
interface EdgeCut {
|
|
37
|
+
readonly bands: Readonly<Record<string, Rect>>;
|
|
38
|
+
readonly rest: Rect;
|
|
39
|
+
}
|
|
40
|
+
declare function cutEdges(stage: Rect, bands: readonly EdgeBand[]): EdgeCut;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The edge stack's shapes. A stack is the items along one edge of a stage: a column (vertical, a side region) or a
|
|
44
|
+
* row (horizontal, a bar). An item is a panel or a control group; it declares its forms, largest first, and the
|
|
45
|
+
* solver (`fitStack`) picks one per item. Plain data in and out: no words, no time, no DOM.
|
|
46
|
+
*
|
|
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
|
+
* 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.
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/** `"column"` runs the stack down (its main size is a height, its cross size a width); `"row"` runs it across. */
|
|
56
|
+
type StackAxis = "column" | "row";
|
|
57
|
+
/** How a panel draws: open (header and body), a header only, a rail icon, or an entry in the » menu. */
|
|
58
|
+
type PanelFormKind = "open" | "header" | "rail" | "menu";
|
|
59
|
+
/**
|
|
60
|
+
* How a control group draws: a row of words, the words stacked, `wrap` (the words in rows that wrap to the cross size
|
|
61
|
+
* the item gets; its length follows from {@link StackForm.wrap}), icons only, `fold` (the group's handle with its own »,
|
|
62
|
+
* in line at its place and with its own length) or an entry in the shared » menu.
|
|
63
|
+
*/
|
|
64
|
+
type GroupFormKind = "row" | "stacked" | "wrap" | "icons" | "fold" | "menu";
|
|
65
|
+
/**
|
|
66
|
+
* Words that wrap: their widths in order, the row height, the gap between words on a row (default 0) and the lead (the
|
|
67
|
+
* grip's cell at the start of row one, default 0). The words wrap in their own box beside the lead, a hanging indent:
|
|
68
|
+
* every row starts after it, so the grip never has a row of its own. Words flow onto a row while they fit; with two
|
|
69
|
+
* words or more, every row but the last must hold at least two, or the form doesn't fit that cross size.
|
|
70
|
+
*/
|
|
71
|
+
interface WrapSpec {
|
|
72
|
+
readonly widths: readonly number[];
|
|
73
|
+
readonly row: number;
|
|
74
|
+
readonly gap?: number;
|
|
75
|
+
readonly lead?: number;
|
|
76
|
+
}
|
|
77
|
+
type StackFormKind = PanelFormKind | GroupFormKind;
|
|
78
|
+
/** Along the stack: `min` is the least it can be drawn, `natural` what it asks for; `grows` takes spare length. */
|
|
79
|
+
interface MainSize {
|
|
80
|
+
readonly min: number;
|
|
81
|
+
readonly natural: number;
|
|
82
|
+
readonly grows?: boolean;
|
|
83
|
+
}
|
|
84
|
+
/** One way to draw an item. A `menu` form takes no room in the stack (the » entry stands for it). */
|
|
85
|
+
interface StackForm {
|
|
86
|
+
readonly kind: StackFormKind;
|
|
87
|
+
readonly main: MainSize;
|
|
88
|
+
/**
|
|
89
|
+
* Across the stack: `natural` is what this form asks for (it sets the stack's cross size when `setsCross`); `min`
|
|
90
|
+
* is the least it can be drawn across (default `natural`). A form that doesn't set the cross size takes its next
|
|
91
|
+
* form only when its `min` is over the stack's cross size, so a header stays in a column an open panel made
|
|
92
|
+
* narrow when it has a small `min`.
|
|
93
|
+
*/
|
|
94
|
+
readonly cross: {
|
|
95
|
+
readonly natural: number;
|
|
96
|
+
readonly min?: number;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Whether this form sets the stack's cross size (the column's width, the bar's height). Default: true for a
|
|
100
|
+
* panel's `open`, false for everything else (a group never sets a column's width).
|
|
101
|
+
*/
|
|
102
|
+
readonly setsCross?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* It shows its body: an open panel. Default: true for the kind `open`. It sets the cross size unless `setsCross` says
|
|
105
|
+
* otherwise, and a window model reads it as the item being open.
|
|
106
|
+
*/
|
|
107
|
+
readonly body?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* It shows only its bar: a panel folded to its header, a group folded to its grip and ». Default: true for the kinds
|
|
110
|
+
* `header` and `fold`. A window model reads it as folded: a hand fold takes the first such form, and a float in it
|
|
111
|
+
* keeps its bar's height.
|
|
112
|
+
*/
|
|
113
|
+
readonly folded?: boolean;
|
|
114
|
+
/** Icons only. Default: true for the kind `icons`. A window model's compact (icons-only) edge takes it. */
|
|
115
|
+
readonly compact?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Give-way order (default 0). When the stack is too long, the step taken is the one into the lowest-ranked next
|
|
118
|
+
* form across all items (the form the item would take, not the one it leaves); ties go unkept before kept, then the
|
|
119
|
+
* item used longest ago, then the later in the stack. A pinned primary's last forms get a higher rank, so every
|
|
120
|
+
* other group collapses before it does.
|
|
121
|
+
*/
|
|
122
|
+
readonly rank?: number;
|
|
123
|
+
/**
|
|
124
|
+
* A form whose length depends on the cross size it gets (meant for a column of words). With it, `main` and `cross` are
|
|
125
|
+
* computed and the given ones ignored: the rows are laid once the stack's cross size is known (beside the lead, a
|
|
126
|
+
* hanging indent), and `main.min` and `main.natural` are rows × `row`. It fits a cross size only when no row but the
|
|
127
|
+
* last holds a single word (`formFitsCross`); below that it is too wide and takes its next form, and `cross.min` is the
|
|
128
|
+
* narrowest cross where it fits (`formCrossMin`). Its one-row width (lead, words and gaps) counts as `cross.natural` only
|
|
129
|
+
* with `setsCross: true`; such a setter is clamped to the stack's limits like any setter and, without `strictCross`,
|
|
130
|
+
* never goes to its next form. Give-way, fits, `previous` and growth use the computed length; under `ownCross` the item
|
|
131
|
+
* is drawn as wide as its rows need. A word group needs an `icons` form after it: vertical places skip `wrap` forms.
|
|
132
|
+
*/
|
|
133
|
+
readonly wrap?: WrapSpec;
|
|
134
|
+
/**
|
|
135
|
+
* A grip at the form's start along the stack, this long (an icons strip's horizontal grip on top). A window model (`@n-uf/docking`)
|
|
136
|
+
* reports its rect; a `wrap` form's grip is its lead cell instead.
|
|
137
|
+
*/
|
|
138
|
+
readonly grip?: number;
|
|
139
|
+
/**
|
|
140
|
+
* The control ids this form leaves out, against the item's first form: a compact variant of a toolbar (a row form
|
|
141
|
+
* between the full row and its wrap, smaller, its "+N" cell counted in its size) hides some controls a "+N" control
|
|
142
|
+
* reaches. Any form may set it (a wrap, icons or menu form too). The ladder reads it nowhere: a variant is a form like
|
|
143
|
+
* any other, taken in order, giving way and coming back by the usual rules. `@n-uf/docking` reports the chosen form's ids
|
|
144
|
+
* as `hidden`.
|
|
145
|
+
*/
|
|
146
|
+
readonly hides?: readonly string[];
|
|
147
|
+
/**
|
|
148
|
+
* Each shown control's tier, by control id (0 the longest), set by `controlLadder` on every row form it generates (not
|
|
149
|
+
* on `fold` and `menu`): a host draws each control at its tier from it, with no knowledge of the ladder's order. It is
|
|
150
|
+
* always a valid index into the control's own `tiers` (a control with fewer tiers than the group stays on its last; a
|
|
151
|
+
* control with no tiers reports 0). A
|
|
152
|
+
* hand-written form leaves it out. `@n-uf/docking` reports the chosen form's as the item layout's `tiers`.
|
|
153
|
+
*/
|
|
154
|
+
readonly tiers?: Readonly<Record<string, number>>;
|
|
155
|
+
/**
|
|
156
|
+
* A `rail` form that draws the item's title along the rail (its name and count, turned to run along it) instead of
|
|
157
|
+
* its tile. Put it just before the item's tile `rail` form: in a rail the two are steps on the ladder, the title giving
|
|
158
|
+
* way to the tile by the usual rules and coming back in exact reverse. Its `main` is the title's length along the rail,
|
|
159
|
+
* measured by the host. A stack offers it only with `StackInput.titles`; otherwise it is passed over like a form that
|
|
160
|
+
* isn't there (never started in, stepped into or grown back to). `@n-uf/docking` offers it in a rail whose side shows
|
|
161
|
+
* titles (`DockState.railModes`, default `"titles"`) and reports the side it reads from (`DockItemLayout.railTitle`).
|
|
162
|
+
*/
|
|
163
|
+
readonly title?: boolean;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* The least a form can be drawn across the stack: its `cross.min` (default its `natural`), or for a `wrap` form the
|
|
167
|
+
* narrowest cross size at which its rows fit (no single word on a row but the last). A window model's size clamp and
|
|
168
|
+
* column shrink read it too.
|
|
169
|
+
*/
|
|
170
|
+
declare function formCrossMin(f: StackForm): number;
|
|
171
|
+
/** A form's length along the stack: its `main` size, or for a `wrap` form its rows at cross size `cross` times the row height. */
|
|
172
|
+
declare function formMain(f: StackForm, which: "min" | "natural", cross: number): number;
|
|
173
|
+
/**
|
|
174
|
+
* Whether a `wrap` form fits cross size `cross`: every word fits beside the lead, and no row but the last holds a single
|
|
175
|
+
* word. True for any other form (their `cross.min` decides).
|
|
176
|
+
*/
|
|
177
|
+
declare function formFitsCross(f: StackForm, cross: number): boolean;
|
|
178
|
+
/**
|
|
179
|
+
* A wrap form's rows at cross size `cross`: the word indexes per row, how wide the widest row is (the lead included),
|
|
180
|
+
* and whether the form fits (with two words or more, no row but the last holds a single word). Greedy rows can leave a
|
|
181
|
+
* single word on a row at one width and not at a narrower one, so when the rows at `cross` don't fit they are laid at
|
|
182
|
+
* the widest narrower width that fits: a form that fits a cross size fits every wider one, and widening never turns
|
|
183
|
+
* its words into icons.
|
|
184
|
+
*/
|
|
185
|
+
declare function wrapLines(spec: WrapSpec, cross: number): {
|
|
186
|
+
lines: number[][];
|
|
187
|
+
width: number;
|
|
188
|
+
fits: boolean;
|
|
189
|
+
};
|
|
190
|
+
/** A wrap form's rows at cross size `cross`: how many, how wide the widest is, and whether it fits. */
|
|
191
|
+
declare function wrapRows(spec: WrapSpec, cross: number): {
|
|
192
|
+
rows: number;
|
|
193
|
+
width: number;
|
|
194
|
+
fits: boolean;
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* A wrap form's one-row width, and the narrowest cross size at which it fits: its rows hold no single word on a row but
|
|
198
|
+
* the last (with one word, the lead and that word). Looked for among the widths a row can take (the lead and a run of
|
|
199
|
+
* words), the narrowest that fits.
|
|
200
|
+
*/
|
|
201
|
+
declare function wrapCross(spec: WrapSpec): {
|
|
202
|
+
natural: number;
|
|
203
|
+
min: number;
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* The length a person asked an item to have, px along a stack, per axis: a flex basis. `column` is read by a stack that
|
|
207
|
+
* runs down, `row` by one that runs across, so an item that moves to a stack of the other axis never reads a length
|
|
208
|
+
* meant for this one.
|
|
209
|
+
*/
|
|
210
|
+
interface StackLengths {
|
|
211
|
+
readonly column?: number;
|
|
212
|
+
readonly row?: number;
|
|
213
|
+
}
|
|
214
|
+
interface StackItem {
|
|
215
|
+
readonly id: string;
|
|
216
|
+
/** Largest first. The solver starts at `from` and steps down one at a time. An item with none is left out. */
|
|
217
|
+
readonly forms: readonly StackForm[];
|
|
218
|
+
/** How recently it was used: the smaller, the longer ago, the sooner it gives way. */
|
|
219
|
+
readonly used: number;
|
|
220
|
+
/** Kept: gives way after every item that isn't. */
|
|
221
|
+
readonly kept?: boolean;
|
|
222
|
+
/**
|
|
223
|
+
* The first form the item may take, an index into `forms` (default 0; a panel folded by hand starts at its header).
|
|
224
|
+
* The solver never goes above it. `form` in the result and in the notes are indexes into `forms`, not into what is
|
|
225
|
+
* left after `from`.
|
|
226
|
+
*/
|
|
227
|
+
readonly from?: number;
|
|
228
|
+
/**
|
|
229
|
+
* A fixed item is a reserved room, such as the title and the window controls of a title bar. It never gives way:
|
|
230
|
+
* it keeps its first allowed form (`forms[from]`) whatever the length or the cross size, so it is never in the » menu
|
|
231
|
+
* unless that is the form it starts in, and it doesn't take part in `previous`'s growing back. It counts toward the
|
|
232
|
+
* length like any item (the others give way around it, and a stack too short for it overflows). It is never dropped:
|
|
233
|
+
* `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.
|
|
235
|
+
*/
|
|
236
|
+
readonly fixed?: boolean;
|
|
237
|
+
/**
|
|
238
|
+
* The length asked for along the stack (default none). While the item is in a form that grows (`main.grows`; a `wrap`
|
|
239
|
+
* 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
|
|
240
|
+
* `main.min` stays the least, a floor on the drawn size and not on the ask, and a value that isn't a finite number over
|
|
241
|
+
* 0 is no asked length (a 0 asks nothing: the item reads its natural). There is no new formula: with spare length the sized items share it in proportion to their
|
|
242
|
+
* lengths (one whose share would be under its least is drawn at its least, the others share the rest), short of length
|
|
243
|
+
* they interpolate between their least (an ask under it reads as the least) and their length, so a stack too short for
|
|
244
|
+
* all of them still trades room between them. A form that doesn't grow ignores it (the length is kept for when the item grows again), and so does a
|
|
245
|
+
* stack of the other axis. A stack whose items declare none is laid out exactly as before. What gives way and in
|
|
246
|
+
* which order never reads it. It is in ask units, not drawn px: with room to spare a drawn size is the ask times the
|
|
247
|
+
* shared scale, or its least when that is more. `resizeBetween` and `resetBetween` write it for the pair only; `resetLengths` clears it.
|
|
248
|
+
*/
|
|
249
|
+
readonly lengths?: StackLengths;
|
|
250
|
+
}
|
|
251
|
+
/** The cross size a stack may take. With no form setting it, the stack is a `rail` wide (default {@link DEFAULT_RAIL}). */
|
|
252
|
+
interface CrossLimits {
|
|
253
|
+
readonly min: number;
|
|
254
|
+
readonly max: number;
|
|
255
|
+
readonly rail?: number;
|
|
256
|
+
}
|
|
257
|
+
interface StackInput {
|
|
258
|
+
readonly axis: StackAxis;
|
|
259
|
+
/** The stack's length along the axis. */
|
|
260
|
+
readonly length: number;
|
|
261
|
+
readonly cross: CrossLimits;
|
|
262
|
+
/** In order, from the start of the stack. */
|
|
263
|
+
readonly items: readonly StackItem[];
|
|
264
|
+
/** The » menu entry's size along the stack, taken only while an item is in the menu (default {@link DEFAULT_MENU}). */
|
|
265
|
+
readonly menu?: {
|
|
266
|
+
readonly main: number;
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* The space between neighboring drawn items, px (default 0). The » entry is a neighbor of the last drawn item. It
|
|
270
|
+
* counts toward the length and the rects include it, so an app draws at the solver's rects.
|
|
271
|
+
*/
|
|
272
|
+
readonly gap?: number;
|
|
273
|
+
/** Space before the first item and after the last (or after the » entry), px (default 0 each). Counts toward the length. */
|
|
274
|
+
readonly pad?: {
|
|
275
|
+
readonly start?: number;
|
|
276
|
+
readonly end?: number;
|
|
277
|
+
};
|
|
278
|
+
/**
|
|
279
|
+
* Strict cross sizes (default false): a form is never drawn thinner than its `cross.min` (default its `natural`), so a
|
|
280
|
+
* form that sets the cross size and has a `cross.min` over `cross.max` steps down to its next form (never into the
|
|
281
|
+
* menu: with only the menu left it keeps its last drawn form and a `too-wide` note says so). Without it such a form is
|
|
282
|
+
* only clamped to `cross.max`, as it always was.
|
|
283
|
+
*/
|
|
284
|
+
readonly strictCross?: boolean;
|
|
285
|
+
/**
|
|
286
|
+
* Which items this stack takes (default: every item). `stackGaps` refuses every gap for an item it doesn't accept, so
|
|
287
|
+
* a toolbar-only stack takes no panel and a panel-only one no group. What an item's kind is
|
|
288
|
+
* stays the host's: placement only calls this, on the dragged item, and `fitStack` never does (items already in the
|
|
289
|
+
* stack are laid out as given).
|
|
290
|
+
*/
|
|
291
|
+
readonly accepts?: (item: StackItem) => boolean;
|
|
292
|
+
/**
|
|
293
|
+
* Groups take their own size across (default false: every item spans the stack's cross size). With it, an item whose
|
|
294
|
+
* current form is a group kind (`row`, `stacked`, `wrap`, `icons`, `fold`; a `wrap` form as wide as its rows need) is drawn `cross.natural` across, clamped to the
|
|
295
|
+
* stack's cross size, from the stack's start edge across (the left of a column, the top of a bar), so a group in a
|
|
296
|
+
* side column is as wide as its own form asks, not as the column. Panel kinds (`open`, `header`, `rail`) and the »
|
|
297
|
+
* entry still span it: every open panel and header fills the column. The kind decides, not `setsCross`, which still
|
|
298
|
+
* decides the stack's cross size as before: a group's form that sets it (words in a column: `stacked` with
|
|
299
|
+
* `setsCross: true`) widens the column to the widest such group but is drawn at its own width. The stack's cross
|
|
300
|
+
* size, the forms, the notes and the lengths are as without it; only the rects of group forms are narrower.
|
|
301
|
+
*/
|
|
302
|
+
readonly ownCross?: boolean;
|
|
303
|
+
/**
|
|
304
|
+
* Offer the forms marked `title` (default false: they are passed over, so a stack without it lays out as if they
|
|
305
|
+
* weren't declared). A rail showing titles sets it.
|
|
306
|
+
*/
|
|
307
|
+
readonly titles?: boolean;
|
|
308
|
+
}
|
|
309
|
+
/** The width of a stack nothing open holds, px. */
|
|
310
|
+
declare const DEFAULT_RAIL = 30;
|
|
311
|
+
/** The » menu entry's size along the stack, px. */
|
|
312
|
+
declare const DEFAULT_MENU = 28;
|
|
313
|
+
/** Whether a form shows its body (`body`, default: the kind `open`). */
|
|
314
|
+
declare const formBody: (f: StackForm) => boolean;
|
|
315
|
+
/** Whether a form shows only its bar (`folded`, default: the kinds `header` and `fold`). */
|
|
316
|
+
declare const formFolded: (f: StackForm) => boolean;
|
|
317
|
+
/** Whether a form is icons only (`compact`, default: the kind `icons`). */
|
|
318
|
+
declare const formCompact: (f: StackForm) => boolean;
|
|
319
|
+
/** Whether a form sets the stack's cross size: its own say, else whether it shows its body. */
|
|
320
|
+
declare const formSetsCross: (f: StackForm) => boolean;
|
|
321
|
+
/** `input` with `item` inserted at index `at` (clamped to the items' range). */
|
|
322
|
+
declare function withItem(input: StackInput, item: StackItem, at: number): StackInput;
|
|
323
|
+
/** An item drawn: the form it took, its kind and its rect (stack-local px). One in the menu has the menu entry's rect. */
|
|
324
|
+
interface PlacedStackItem {
|
|
325
|
+
readonly id: string;
|
|
326
|
+
/** Index into the item's `forms`. */
|
|
327
|
+
readonly form: number;
|
|
328
|
+
readonly kind: StackFormKind;
|
|
329
|
+
readonly rect: Rect;
|
|
330
|
+
}
|
|
331
|
+
interface StackMenu {
|
|
332
|
+
/** The » entry's rect. */
|
|
333
|
+
readonly rect: Rect;
|
|
334
|
+
/** The items in it, in the stack's order: exactly the items whose kind is `menu`. */
|
|
335
|
+
readonly items: readonly string[];
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Why a stack looks as it does:
|
|
339
|
+
* - `form-down`: an item took a smaller form than the one it started in (`from`, an index into its forms), by length
|
|
340
|
+
* or by cross size.
|
|
341
|
+
* - `to-menu`: an item is in the » menu.
|
|
342
|
+
* - `too-wide`: an item's form doesn't set the cross size and its `cross.min` is over the stack's, or (with `strictCross`)
|
|
343
|
+
* it does and its `cross.min` is over the limits' `max`. Cross size never puts an item in the menu, so it keeps its last drawn form
|
|
344
|
+
* and the app clips it.
|
|
345
|
+
* - `no-forms`: an item with no forms, left out of `items`.
|
|
346
|
+
* - `overflow`: no item can give more way and the stack is still `over` px too long (forms that don't end in a `menu`
|
|
347
|
+
* form can't give more; neither can a stack where going into the menu would only make it longer).
|
|
348
|
+
*/
|
|
349
|
+
type StackNote = {
|
|
350
|
+
readonly code: "form-down";
|
|
351
|
+
readonly id: string;
|
|
352
|
+
readonly from: number;
|
|
353
|
+
readonly to: number;
|
|
354
|
+
} | {
|
|
355
|
+
readonly code: "to-menu";
|
|
356
|
+
readonly id: string;
|
|
357
|
+
} | {
|
|
358
|
+
readonly code: "too-wide";
|
|
359
|
+
readonly id: string;
|
|
360
|
+
} | {
|
|
361
|
+
readonly code: "no-forms";
|
|
362
|
+
readonly id: string;
|
|
363
|
+
} | {
|
|
364
|
+
readonly code: "overflow";
|
|
365
|
+
readonly over: number;
|
|
366
|
+
};
|
|
367
|
+
type StackNoteCode = StackNote["code"];
|
|
368
|
+
interface StackFit {
|
|
369
|
+
readonly axis: StackAxis;
|
|
370
|
+
readonly length: number;
|
|
371
|
+
/** The stack's size across: the widest `open` (clamped to the limits), or the rail. */
|
|
372
|
+
readonly cross: number;
|
|
373
|
+
/** One per input item that has forms, in order. */
|
|
374
|
+
readonly items: readonly PlacedStackItem[];
|
|
375
|
+
/** The » entry, or null while no item is in the menu. */
|
|
376
|
+
readonly menu: StackMenu | null;
|
|
377
|
+
/** `no-forms` first, then `form-down` per item in the order they gave way, `to-menu`, `too-wide`, and `overflow`. */
|
|
378
|
+
readonly notes: readonly StackNote[];
|
|
379
|
+
/**
|
|
380
|
+
* The length the chosen forms need at least: their smallest sizes, the » entry, the gaps and the padding. Over `length`
|
|
381
|
+
* only when the stack overflows. `fitStack`'s `previous` reads it to tell room coming back from a change of ages.
|
|
382
|
+
*/
|
|
383
|
+
readonly need?: number;
|
|
384
|
+
/**
|
|
385
|
+
* The give-way history: every step down from the items' starting forms to the forms chosen, in the order taken (items
|
|
386
|
+
* that went into the » menu together share a `batch`). `fitStack`'s `previous` carries it on, and room coming back
|
|
387
|
+
* undoes it from the last step: growing back is exactly the reverse of giving way.
|
|
388
|
+
*/
|
|
389
|
+
readonly steps?: readonly StackStep[];
|
|
390
|
+
}
|
|
391
|
+
/** One give-way step: item `id` went from form `from` to form `to`; steps sharing a `batch` were taken together. */
|
|
392
|
+
interface StackStep {
|
|
393
|
+
readonly id: string;
|
|
394
|
+
readonly from: number;
|
|
395
|
+
readonly to: number;
|
|
396
|
+
readonly batch?: number;
|
|
397
|
+
}
|
|
398
|
+
/** What `fitStack` takes besides the input. */
|
|
399
|
+
interface FitOptions {
|
|
400
|
+
/**
|
|
401
|
+
* The fit the stack had before. While the forms it chose still fit, they are kept: a change of `used` ages alone (a press
|
|
402
|
+
* on a header) reshapes nothing. Ages decide only who gives way anew (the length shrank, an item was added or opened),
|
|
403
|
+
* and room that came back is used, but growing never re-ranks: the fresh fit is taken when the stack got wider across;
|
|
404
|
+
* otherwise room comes back by undoing the give-way history (`StackFit.steps`, carried on from fit to fit) from its
|
|
405
|
+
* last step: a batch that went into the » menu together comes out together, an item goes back to the nearest earlier
|
|
406
|
+
* form the stack fits with (the last item out of the menu takes the » entry with it), and the first step that can't
|
|
407
|
+
* be undone stops all growth. Growing back is exactly the reverse of giving way, the menu included: at every length
|
|
408
|
+
* the way back holds what the way down held, whatever presses changed the ages since; an item made `kept` after its
|
|
409
|
+
* step comes back in step order, it doesn't jump ahead. A `previous` without a history
|
|
410
|
+
* (built by hand, or by an older version) grows the old way: a fresh fit that is a pure gain, else the item that gave
|
|
411
|
+
* way most recently (highest rank, then `kept`, the newest used, the earlier in the stack) first, menu items out only
|
|
412
|
+
* while that keeps the order.
|
|
413
|
+
* One px of room moves nothing. Results under `previous` depend on history: a shrink then a grow may end at another
|
|
414
|
+
* arrangement than a fresh solve of the same input, and more room never undoes a growth along successive solves.
|
|
415
|
+
* Growing back is meant for stacks of up to about 50 items (60 small menu items take about 9 ms; the cost grows with
|
|
416
|
+
* about the cube of the count). Items it doesn't know start from their largest form; an item whose `from` went down
|
|
417
|
+
* since (a panel opened), or whose form at the kept index is of another kind, starts over. A form that was only
|
|
418
|
+
* re-measured keeps its place: smaller, it frees room that grows the kept forms; larger, it gives way from the kept
|
|
419
|
+
* forms.
|
|
420
|
+
*
|
|
421
|
+
* Not covered: a lowered `cross.min` (or any change of the forms' cross sizes) doesn't bring a form back under
|
|
422
|
+
* `previous`. After changing cross sizes, solve once without `previous`.
|
|
423
|
+
*/
|
|
424
|
+
readonly previous?: StackFit;
|
|
425
|
+
}
|
|
6
426
|
|
|
7
427
|
/**
|
|
8
428
|
* `fitStack(input, options?)`. With `options.previous` (the fit the stack had before) the forms it chose are kept while
|
|
@@ -22,259 +442,225 @@ import { F as FloatFit$1 } from './float-fit-DCYxRMru.js';
|
|
|
22
442
|
declare function fitStack(input: StackInput, options?: FitOptions): StackFit;
|
|
23
443
|
|
|
24
444
|
/**
|
|
25
|
-
*
|
|
26
|
-
* dragged)` gives one target for every gap of the stack without the dragged item (an item of the input with its id
|
|
27
|
-
* is lifted out first, so a reorder within a stack works): before each item and after the last, so an empty stack has
|
|
28
|
-
* one. An item with no forms has no place of its own, but its gaps count.
|
|
445
|
+
* `controlLadder`: a control group's forms, generated from its controls.
|
|
29
446
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* its own: the gaps next to it split the stretch where the stack's drawn items end; with every item in the menu only
|
|
36
|
-
* the last gap, "at the end", has any length, and the others are a point at the start). Across, it is the larger of
|
|
37
|
-
* the stack's current size and the size the drop gives it, so the pointer over the preview is over the target.
|
|
38
|
-
* - `fit`: the full `fitStack` of the stack with the dragged item inserted at k, and `input` the stack that was
|
|
39
|
-
* solved. The preview is `slot`, the dragged item's rect in `fit`: exactly the rect it gets after the drop, because
|
|
40
|
-
* the drop is that same solve. `marker` is the line where its leading edge lands: a rect with no thickness across
|
|
41
|
-
* the stack's cross size (the app draws it with one).
|
|
447
|
+
* A host that hand-writes a group's forms gives a few coarse steps (a row, icons, a fold). A host that declares what the
|
|
448
|
+
* group holds (its controls, each with its lengths per tier) gets the fine ladder instead, so a bar runs short control
|
|
449
|
+
* by control and not group by group. Nothing here is a solver rule: the result is an ordinary `StackForm[]` with `rank`
|
|
450
|
+
* and `hides` set, and `fitStack` takes it like any other (the lowest-ranked next form across all items, its tie-breaks,
|
|
451
|
+
* the way back by `previous`).
|
|
42
452
|
*
|
|
43
|
-
* The
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
453
|
+
* The ladder, in order, for `n` controls and `T` tiers (a tier is one length per control, longest first):
|
|
454
|
+
* 1. The first form: every control at tier 0, a `row`.
|
|
455
|
+
* 2. The tier steps, one control at a time in fold order: the control that folds first takes tier 1, then the next, then
|
|
456
|
+
* the first takes tier 2, and so on to tier `T - 1` for all. Each is a `row` with every control shown. Step `i`
|
|
457
|
+
* (0-based, within tier `t`) has rank `100 * t + i / n` for tiers 1 and 2, so groups of different sizes level within
|
|
458
|
+
* a tier; tiers 3 and later share the band from 300 in tier order, rank `300 + (t - 3 + i / n) / (T - 3)`, so the
|
|
459
|
+
* ranks strictly increase along the group and stay under 400 for any `T`.
|
|
460
|
+
* 3. The partial folds, at the last tier: for `k = 1 … n - 1`, a `row` that hides the first `k` controls in fold order
|
|
461
|
+
* (`hides` lists them) and shows a `more` cell for them. Rank `400 + k / n`: the group with the fewest hidden controls
|
|
462
|
+
* folds next.
|
|
463
|
+
* 4. `fold` (the grip and the `more` cell in line, `hides` every control), rank 500, then `menu`, rank 600.
|
|
49
464
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
465
|
+
* Every row form carries `tiers`, each shown control's tier index (`StackForm.tiers`; `fold` and `menu` have none), so a
|
|
466
|
+
* host draws a control from the form the layout chose, with no knowledge of this order.
|
|
467
|
+
*
|
|
468
|
+
* Every form is always emitted, even when it is no shorter than the one before: the solver passes over a form that
|
|
469
|
+
* doesn't shorten the stack, and the shape (`n * T + 2` forms, `0` with no controls) depends on the control and tier
|
|
470
|
+
* counts alone, so a form index stays valid when a length changes. When the control set itself changes, solve the group
|
|
471
|
+
* fresh (no `previous`).
|
|
472
|
+
*
|
|
473
|
+
* Ranks are spaced by step type in fixed bands whatever a group's tier count: tier steps in [100, 400), partial folds
|
|
474
|
+
* 400 + k / n, fold 500, menu 600. So the same-tier steps of several groups interleave, and a partial fold never comes
|
|
475
|
+
* before another group's tier step, even when the groups have different tier counts.
|
|
53
476
|
*/
|
|
54
477
|
|
|
55
|
-
/**
|
|
56
|
-
interface
|
|
478
|
+
/** One control of a group: an id and its length along the stack per tier. */
|
|
479
|
+
interface LadderControl {
|
|
480
|
+
readonly id: string;
|
|
57
481
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
482
|
+
* Its lengths per tier, longest first, in the host's order of presentation (full, shorter, shortest). A tier the
|
|
483
|
+
* control doesn't list keeps its last length; a control with none is 0 long. A group's tier count is its longest list.
|
|
60
484
|
*/
|
|
61
|
-
readonly
|
|
485
|
+
readonly tiers: readonly number[];
|
|
62
486
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
487
|
+
* Folds before the controls with a lower number (default: its index, so the last control folds first). Ties go to the
|
|
488
|
+
* later control. The same order sets which control a tier step shortens first.
|
|
65
489
|
*/
|
|
66
|
-
readonly
|
|
490
|
+
readonly foldOrder?: number;
|
|
491
|
+
}
|
|
492
|
+
/** A control group, declared by its controls. All lengths are along the stack, px. */
|
|
493
|
+
interface ControlLadderSpec {
|
|
494
|
+
/** In drawing order. */
|
|
495
|
+
readonly controls: readonly LadderControl[];
|
|
496
|
+
/** Between two neighboring controls (default 0). The grip and the `more` cell are the cells' own widths, with no gap. */
|
|
497
|
+
readonly gap?: number;
|
|
498
|
+
/** The grip cell at the group's start (default 0); every form but the menu carries it as `StackForm.grip`. */
|
|
499
|
+
readonly grip?: number;
|
|
500
|
+
/** The group's own » cell, drawn once any control is hidden. */
|
|
501
|
+
readonly more: number;
|
|
502
|
+
/** The group's thickness across the stack (a bar's height). */
|
|
503
|
+
readonly cross: number;
|
|
67
504
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* target; the others keep their ids, places and hits. The stack's own `accepts` is asked first, for the whole stack.
|
|
505
|
+
* The group's form in a column (a rail): an `icons` strip `icons` long, then the menu. `cross` is its width (default
|
|
506
|
+
* the group's `cross`). Without it the group has no column forms.
|
|
71
507
|
*/
|
|
72
|
-
readonly
|
|
508
|
+
readonly column?: {
|
|
509
|
+
readonly icons: number;
|
|
510
|
+
readonly cross?: number;
|
|
511
|
+
};
|
|
73
512
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* item into the menu, has an `overflow` note, has a `too-wide` note that the stack without the dragged item didn't have,
|
|
77
|
-
* or squeezes a `fixed` item: it is in another form, shorter along the stack than its form's `main.min`, or narrower
|
|
78
|
-
* across than before the drop. A fixed item may shrink down to its `main.min` to make room, so the room for the others
|
|
79
|
-
* is the length less the fixed items' minimum sizes. The gaps left keep their ids, hits and fits. With no room anywhere
|
|
80
|
-
* the result is `[]`.
|
|
513
|
+
* A pinned primary's level (default 0): its partial folds, fold and menu rank `keep * 1000` higher, so every group of a
|
|
514
|
+
* lower level gives way entirely before it folds a control. Tier steps are unchanged.
|
|
81
515
|
*/
|
|
82
|
-
readonly
|
|
516
|
+
readonly keep?: number;
|
|
83
517
|
}
|
|
84
|
-
/**
|
|
85
|
-
|
|
86
|
-
readonly
|
|
87
|
-
readonly
|
|
88
|
-
};
|
|
89
|
-
/** @deprecated Use `SceneTarget` and `targets(scene, id)` from `@n-uf/placement/scene`. */
|
|
90
|
-
interface StackTarget extends Target {
|
|
91
|
-
readonly priority: 2;
|
|
92
|
-
/** The item dragged. */
|
|
93
|
-
readonly item: string;
|
|
94
|
-
readonly place: StackPlace;
|
|
95
|
-
/** The line where the dragged item's leading edge lands. */
|
|
96
|
-
readonly marker: Rect;
|
|
97
|
-
/** The stack with the dragged item inserted: what a drop here makes. */
|
|
98
|
-
readonly input: StackInput;
|
|
99
|
-
/** Its fit: the preview and the drop are both its rect for the dragged item. */
|
|
100
|
-
readonly fit: StackFit;
|
|
518
|
+
/** A group's forms along a bar (`row`) and, when declared, down a column; assignable to `@n-uf/docking`'s `DockItem.forms`. */
|
|
519
|
+
interface ControlLadder {
|
|
520
|
+
readonly row: readonly StackForm[];
|
|
521
|
+
readonly column?: readonly StackForm[];
|
|
101
522
|
}
|
|
102
|
-
/**
|
|
103
|
-
declare function
|
|
523
|
+
/** `spec`'s forms: the row ladder, and the column ladder when `spec.column` is given. Pure. */
|
|
524
|
+
declare function controlLadder(spec: ControlLadderSpec): ControlLadder;
|
|
104
525
|
|
|
105
526
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* `
|
|
109
|
-
*
|
|
110
|
-
* `forms` entry for an id that isn't in `order` is dropped; a form that isn't a whole number from 1 up is dropped;
|
|
111
|
-
* the key `__proto__` in `forms` is dropped (the other keys, `constructor` and `prototype` included, are ids like any
|
|
112
|
-
* other: `forms` is an object with no prototype, written and read); a field this version doesn't know is skipped and
|
|
113
|
-
* reported as `"<field>"`. An item the consumer has that the stored order lacks is no error: the consumer places it.
|
|
114
|
-
*
|
|
115
|
-
* - `kept`: items kept open (they give way last).
|
|
116
|
-
* - `closed`: items the user closed; their place in `order` is kept for when they open.
|
|
117
|
-
* - `used`: the use order, oldest to newest, so a reload restores who gives way first (an item's `used` is its index in
|
|
118
|
-
* it; one the list lacks is older than all). An id listed twice counts at its last place: the newest use wins.
|
|
119
|
-
* - `forms`: the user's chosen form per item, the index of the largest form it may take (`StackItem.from`). 0, the
|
|
120
|
-
* first, is not stored.
|
|
527
|
+
* Stacked items that share a draggable divider: one makes its neighbor longer and the other shorter by the same
|
|
528
|
+
* amount, and nothing else in the stack moves. A divider's state is the asked length of the items on both sides
|
|
529
|
+
* (`StackItem.lengths`), which `fitStack` reads in place of a growing form's natural; these are the functions that read and
|
|
530
|
+
* write it. Pure: a state in, a state out (the same object when nothing changed).
|
|
121
531
|
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
532
|
+
* A growing item is one drawn in a form that grows (`main.grows`, not in the » menu): the items that share spare length,
|
|
533
|
+
* and so the items whose length is written. The two ends of a divider are neighboring growing items, neither `fixed` nor a
|
|
534
|
+
* `wrap` form. A header, a rail icon, a group or a folded item between them isn't growing, so it has no divider of its own
|
|
535
|
+
* and doesn't kill the divider across it; a growing item that is not an end (a fixed one, a `wrap` form that grows) ends
|
|
536
|
+
* the chain: there is no divider across it.
|
|
125
537
|
*/
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
readonly
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
readonly
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
readonly used: string[];
|
|
146
|
-
readonly forms: Record<string, number>;
|
|
538
|
+
|
|
539
|
+
/** One divider: between the open growing items `before` and `after` (ids), drawn at `rect`. */
|
|
540
|
+
interface StackDivider {
|
|
541
|
+
readonly before: string;
|
|
542
|
+
readonly after: string;
|
|
543
|
+
/**
|
|
544
|
+
* The strip the divider sits on, stack-local: it starts where the last item drawn before `after` ends (the far edge of
|
|
545
|
+
* the last collapsed item between the two, or of `before`), and is as thick as the gap to `after` (0 with no gap).
|
|
546
|
+
* Across, it is `before`'s extent. A host draws its grab zone around it.
|
|
547
|
+
*/
|
|
548
|
+
readonly rect: Rect;
|
|
549
|
+
/**
|
|
550
|
+
* How far the divider may move each way, px along the stack (`min` ≤ 0 ≤ `max`): the delta `resizeBetween` takes, a
|
|
551
|
+
* negative one moving it toward `before`. Where either end reaches its least.
|
|
552
|
+
*/
|
|
553
|
+
readonly range: {
|
|
554
|
+
readonly min: number;
|
|
555
|
+
readonly max: number;
|
|
556
|
+
};
|
|
147
557
|
}
|
|
148
|
-
/** @deprecated Use `SceneRead` from `@n-uf/placement/scene`. */
|
|
149
|
-
type StackRead = {
|
|
150
|
-
readonly ok: true;
|
|
151
|
-
readonly state: StackState;
|
|
152
|
-
readonly dropped: readonly string[];
|
|
153
|
-
} | {
|
|
154
|
-
readonly ok: false;
|
|
155
|
-
readonly error: string;
|
|
156
|
-
};
|
|
157
558
|
/**
|
|
158
|
-
*
|
|
159
|
-
*
|
|
559
|
+
* The dividers of a stack laid out as `fit`, one per pair of neighboring growing items that are both ends, in the stack's
|
|
560
|
+
* order. A collapsed item has none of its own; where collapsed items sit between two open ones there is one divider
|
|
561
|
+
* between the open ones, on the far edge of the last collapsed one. A growing item that isn't an end (a fixed one, a
|
|
562
|
+
* `wrap` form) has none and ends the chain.
|
|
563
|
+
*/
|
|
564
|
+
declare function dividers(input: StackInput, fit: StackFit): StackDivider[];
|
|
565
|
+
/**
|
|
566
|
+
* Move the divider between the open growing items `before` and `after` by `delta` px along the stack: `before` gets
|
|
567
|
+
* longer by `delta` and `after` shorter (a negative `delta` the other way), so the stack's total is the same and only the
|
|
568
|
+
* two move. It writes the length of the two only, in ask units (see `written`), so nothing else shifts and the others
|
|
569
|
+
* stay as they were, sized or not. Neither goes
|
|
570
|
+
* under its least: `delta` is clamped to the divider's `range`, no item collapses and none is pushed. Returns the same
|
|
571
|
+
* object when nothing changes (not neighbors, an unknown id, a `delta` that isn't a number, or one clamped to 0).
|
|
572
|
+
* `options.previous` is the fit the stack had, as for `fitStack`.
|
|
573
|
+
*/
|
|
574
|
+
declare function resizeBetween(input: StackInput, before: string, after: string, delta: number, options?: FitOptions): StackInput;
|
|
575
|
+
/**
|
|
576
|
+
* Give the two items of a divider back the split they would be drawn at if both asked for their natural, their combined
|
|
577
|
+
* drawn length kept and nothing else moving: in proportion to their naturals (their forms' `main.natural`, the least at
|
|
578
|
+
* most) with room for both, and `least + (natural - least) * s` with one shared `s` when short, as `fitStack` shares a
|
|
579
|
+
* short length. The double-click action. Returns the same object when the two are at that split already (a pair nobody
|
|
580
|
+
* resized always is, in every regime), or are not neighbors. Like a drag it writes the lengths of the two only.
|
|
581
|
+
*/
|
|
582
|
+
declare function resetBetween(input: StackInput, before: string, after: string, options?: FitOptions): StackInput;
|
|
583
|
+
/**
|
|
584
|
+
* `input` with every asked length of the stack's axis deleted, back to the split a stack with none has. An item's length
|
|
585
|
+
* for the other axis stays. Returns the same object when no item had one.
|
|
160
586
|
*/
|
|
161
|
-
declare
|
|
162
|
-
/** @deprecated Use `storeScene` from `@n-uf/placement/scene`. */
|
|
163
|
-
declare function storeStack(state: StackState): StoredStack;
|
|
164
|
-
/** @deprecated Use `readScene` from `@n-uf/placement/scene`. */
|
|
165
|
-
declare function readStack(data: unknown, known?: readonly string[]): StackRead;
|
|
587
|
+
declare function resetLengths(input: StackInput): StackInput;
|
|
166
588
|
|
|
167
589
|
/**
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
590
|
+
* `stackGaps(input, item)`: one edge's drop places for `item`, fit only. Every gap of the stack without the item (an
|
|
591
|
+
* item of the input with its id is lifted out first, so a reorder within the stack works) is one entry, in order: before
|
|
592
|
+
* each item and after the last, so an empty stack has one. A gap where the item fits beside the others gives the stack
|
|
593
|
+
* after the drop (`input`) and its fit (`fit`), with the item's rect there (`slot`): the drop is that same solve. A gap
|
|
594
|
+
* where it doesn't fit is a refusal with its reason.
|
|
595
|
+
*
|
|
596
|
+
* 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
|
+
* 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
|
+
* 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.
|
|
171
600
|
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
601
|
+
* Reasons: `no-forms` (the item has none), `fixed` (a fixed item is never dropped), `not-accepted` (`input.accepts`
|
|
602
|
+
* refuses it), `not-allowed` (`options.allows` refuses the gap), `to-menu`, `overflow`, `too-wide` and `squeezes-fixed`.
|
|
603
|
+
* The first three refuse every gap. Pure: no hit zones, no time; where the pointer is is the host's.
|
|
175
604
|
*
|
|
176
|
-
*
|
|
177
|
-
* - `stackFloatTarget(input)`: a drop target in the shape `@n-uf/motion/drag` takes, free (no room is made for it),
|
|
178
|
-
* `kind` `"float"`, id `float:<item>`, whose `hit` covers the whole plane, so a pointer past the stage's edge still
|
|
179
|
-
* hits it (a float drop never cancels), at priority 3 so a docked stack's gaps win where they are. `make(point,
|
|
180
|
-
* grab)` is the one answer for the preview and the drop: the float's rect with the pointer holding it at `grab`,
|
|
181
|
-
* clamped and clear of the docked content.
|
|
182
|
-
* - `storeFloats` / `readFloats`: the stored form, `{ v: 1, floats: [{ id, x, y, width, height }] }`, in stacking
|
|
183
|
-
* order (the last is on top). It writes no `pinned`; one an old store has is read, ignored and listed.
|
|
605
|
+
* See docs/placement.md, Entry: stack.
|
|
184
606
|
*/
|
|
185
607
|
|
|
186
|
-
/**
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
readonly
|
|
192
|
-
|
|
608
|
+
/** Why a gap doesn't take the item. */
|
|
609
|
+
type StackGapRefusal = "no-forms" | "fixed" | "not-accepted" | "not-allowed" | "to-menu" | "overflow" | "too-wide" | "squeezes-fixed";
|
|
610
|
+
/** One gap: before the `at`-th item of the stack without the dragged one (`at` = their count: after the last). */
|
|
611
|
+
type StackGap = {
|
|
612
|
+
readonly at: number;
|
|
613
|
+
readonly fits: true;
|
|
614
|
+
/** The stack with the item inserted at `at`: what the drop makes. */
|
|
615
|
+
readonly input: StackInput;
|
|
616
|
+
/** Its fit: the layout after the drop. */
|
|
617
|
+
readonly fit: StackFit;
|
|
618
|
+
/** The item's rect in `fit` (stack-local px). */
|
|
619
|
+
readonly slot: Rect;
|
|
620
|
+
} | {
|
|
621
|
+
readonly at: number;
|
|
622
|
+
readonly fits: false;
|
|
623
|
+
readonly reason: StackGapRefusal;
|
|
624
|
+
};
|
|
625
|
+
interface StackGapOptions {
|
|
626
|
+
/** The stack's fit before the drag, as `fitStack`'s `previous`: each gap's fit keeps the others' forms while they still fit. */
|
|
627
|
+
readonly previous?: StackFit;
|
|
628
|
+
/** Whether a gap takes the item (default: every gap does), asked with the item and the gap's `at`. */
|
|
629
|
+
readonly allows?: (item: StackItem, at: number) => boolean;
|
|
193
630
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* The rect a float gets: inside the stage, clear of the docked content where a clear place exists.
|
|
198
|
-
* @deprecated Use `fitFloat` from `@n-uf/placement/scene`; a Scene's floats are fitted by `solve`.
|
|
199
|
-
*/
|
|
200
|
-
declare const fitFloat: (want: Rect, stage: Rect, avoid?: readonly Rect[]) => FloatFit;
|
|
631
|
+
declare function stackGaps(input: StackInput, item: StackItem, options?: StackGapOptions): StackGap[];
|
|
632
|
+
|
|
201
633
|
/**
|
|
202
|
-
*
|
|
203
|
-
*
|
|
634
|
+
* `fitFloat(rect, stage, avoid)`: the rect a float gets. It is moved (never resized) to lie inside the stage, then beside
|
|
635
|
+
* whatever docked content it would cover: the nearest place inside the stage that is clear of every `avoid` rect (the
|
|
636
|
+
* docked items' rects, in the same px). One larger than the stage keeps its top-left corner on the stage's; if no clear
|
|
637
|
+
* place exists the float stays where it covers the least and `covers` says which rects.
|
|
638
|
+
*
|
|
639
|
+
* A clear place is found whenever one exists: the x's are tried nearest first and, for each, the blocked stretches of y
|
|
640
|
+
* are merged and skipped, so no clear place is missed however many places lie between. Cost (measured in a test run on
|
|
641
|
+
* a laptop): about 100 docked rects 0.1 ms, 300 a few ms even when no place is clear (6 ms median, 15 ms worst), 1,000
|
|
642
|
+
* about 17 ms; a safety net stops the clear search after 3 million rect tests and says so in `searchCapped`; a stage
|
|
643
|
+
* with no clear place looks at the 2,048 nearest places for the least covered.
|
|
644
|
+
*
|
|
645
|
+
* A window model fits its floats with it.
|
|
204
646
|
*/
|
|
205
|
-
|
|
206
|
-
|
|
647
|
+
|
|
648
|
+
interface FloatFit {
|
|
649
|
+
/** The float's rect: inside the stage and clear of the docked content where a clear place exists. */
|
|
207
650
|
readonly rect: Rect;
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
|
|
212
|
-
/** The item dragged. */
|
|
213
|
-
readonly id: string;
|
|
214
|
-
/** The stage, in view space. */
|
|
215
|
-
readonly stage: Rect;
|
|
216
|
-
/** The float's size: it is never resized. */
|
|
217
|
-
readonly size: Size;
|
|
218
|
-
/** The docked content to stay clear of: the docked items' rects (and the » entries'), in view space. */
|
|
219
|
-
readonly avoid?: readonly Rect[];
|
|
220
|
-
/** What the target is called (default "Float here"). */
|
|
221
|
-
readonly label?: string;
|
|
222
|
-
}
|
|
223
|
-
/** @deprecated A Scene's float target is `float:<id>` from `targets()` in `@n-uf/placement/scene`. */
|
|
224
|
-
interface FloatTarget extends Target {
|
|
225
|
-
/** What kind of place it is, for a consumer that holds targets of several kinds. */
|
|
226
|
-
readonly kind: "float";
|
|
227
|
-
readonly priority: 3;
|
|
228
|
-
readonly free: true;
|
|
229
|
-
/** The item dragged. */
|
|
230
|
-
readonly item: string;
|
|
651
|
+
/** It was moved to lie inside the stage. */
|
|
652
|
+
readonly clamped: boolean;
|
|
653
|
+
/** It was moved beside the docked content it would have covered. */
|
|
654
|
+
readonly snapped: boolean;
|
|
231
655
|
/**
|
|
232
|
-
*
|
|
233
|
-
*
|
|
656
|
+
* Indexes into `avoid` of the rects it still covers. Empty whenever a clear place was found, which is whenever one
|
|
657
|
+
* exists (unless `searchCapped`); not empty only when the stage has no clear place for the float, and then it stays
|
|
658
|
+
* where it covers the least among the 2,048 nearest candidate places.
|
|
234
659
|
*/
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
declare function stackFloatTarget(input: StackFloatTargetInput): FloatTarget;
|
|
239
|
-
/** @deprecated Use `storeScene` / `readScene` from `@n-uf/placement/scene`: a stored scene holds its floats. */
|
|
240
|
-
interface StoredFloats {
|
|
241
|
-
readonly v: 1;
|
|
242
|
-
readonly floats: {
|
|
243
|
-
id: string;
|
|
244
|
-
x: number;
|
|
245
|
-
y: number;
|
|
246
|
-
width: number;
|
|
247
|
-
height: number;
|
|
248
|
-
}[];
|
|
660
|
+
readonly covers: readonly number[];
|
|
661
|
+
/** 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
|
+
readonly searchCapped: boolean;
|
|
249
663
|
}
|
|
250
|
-
|
|
251
|
-
type FloatsRead = {
|
|
252
|
-
readonly ok: true;
|
|
253
|
-
readonly floats: StackFloat[];
|
|
254
|
-
readonly dropped: readonly string[];
|
|
255
|
-
} | {
|
|
256
|
-
readonly ok: false;
|
|
257
|
-
readonly error: string;
|
|
258
|
-
};
|
|
259
|
-
/**
|
|
260
|
-
* The floats as plain JSON-safe data, in the order given (the stacking order, the last on top). Never a `pinned`.
|
|
261
|
-
* What it can't read back is left out, silently: a float whose position isn't a finite number or whose size isn't over
|
|
262
|
-
* 0 (a zero-size float), and an earlier entry of a repeated id (the last readable entry of an id is the one on top,
|
|
263
|
-
* so it stays, at its own place in the order).
|
|
264
|
-
* @deprecated Use `storeScene` from `@n-uf/placement/scene`: a stored scene holds its floats.
|
|
265
|
-
*/
|
|
266
|
-
declare function storeFloats(floats: readonly StackFloat[]): StoredFloats;
|
|
267
|
-
/**
|
|
268
|
-
* Reads parsed data back; never throws. Anything but an object of version 1 with a `floats` array is `{ ok: false,
|
|
269
|
-
* error }`. Inside one it is lenient: a float that isn't an object, has no string id, isn't one the
|
|
270
|
-
* consumer has (with `known`) or has a position or size that isn't a finite number (a size over 0) is dropped and
|
|
271
|
-
* listed in `dropped` as `float:<id>` (or `a <type> where a float goes`); a top-level field this version doesn't
|
|
272
|
-
* know is listed as `"<field>"`, and so is a float's own (`float:<id>:<field>`) while the float itself is kept.
|
|
273
|
-
* A `pinned` key (an old store's flag, whatever its value) is ignored: the float loads as a plain float, in view
|
|
274
|
-
* space as stored, and `pinned:<id>` is listed. A repeated id keeps its last readable entry (the list is in stacking
|
|
275
|
-
* order, the last on top); the earlier ones are dropped and listed as `float:<id>`.
|
|
276
|
-
* @deprecated Use `readScene` from `@n-uf/placement/scene`: a stored scene holds its floats.
|
|
277
|
-
*/
|
|
278
|
-
declare function readFloats(data: unknown, known?: readonly string[]): FloatsRead;
|
|
664
|
+
declare function fitFloat(want: Rect, stage: Rect, avoid?: readonly Rect[]): FloatFit;
|
|
279
665
|
|
|
280
|
-
export {
|
|
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 };
|