@n-uf/placement 26.11.53 → 26.11.54

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.
Files changed (62) hide show
  1. package/CHANGELOG.md +75 -1
  2. package/README.md +27 -58
  3. package/dist/{chunk-VLTYJHUA.js → chunk-2UVUFEBP.js} +4 -8
  4. package/dist/{chunk-VLTYJHUA.js.map → chunk-2UVUFEBP.js.map} +1 -1
  5. package/dist/{geometry-Bf37LbCT.d.ts → geometry-L5gCoiZV.d.ts} +2 -8
  6. package/dist/index.d.ts +64 -42
  7. package/dist/index.js +6 -66
  8. package/dist/index.js.map +1 -1
  9. package/dist/popup.d.ts +49 -0
  10. package/dist/popup.js +58 -0
  11. package/dist/popup.js.map +1 -0
  12. package/dist/stack.d.ts +529 -228
  13. package/dist/stack.js +701 -28
  14. package/dist/stack.js.map +1 -1
  15. package/dist/tiling.d.ts +48 -5
  16. package/dist/tiling.js +198 -19
  17. package/dist/tiling.js.map +1 -1
  18. package/package.json +9 -36
  19. package/dist/chunk-2GGJ4GVR.js +0 -9
  20. package/dist/chunk-2GGJ4GVR.js.map +0 -1
  21. package/dist/chunk-3ZICYLWL.js +0 -791
  22. package/dist/chunk-3ZICYLWL.js.map +0 -1
  23. package/dist/chunk-AE3BWTAE.js +0 -838
  24. package/dist/chunk-AE3BWTAE.js.map +0 -1
  25. package/dist/chunk-JVAR67OL.js +0 -172
  26. package/dist/chunk-JVAR67OL.js.map +0 -1
  27. package/dist/chunk-NF7RYK3U.js +0 -429
  28. package/dist/chunk-NF7RYK3U.js.map +0 -1
  29. package/dist/chunk-R3AAANRY.js +0 -220
  30. package/dist/chunk-R3AAANRY.js.map +0 -1
  31. package/dist/chunk-TWI644JK.js +0 -221
  32. package/dist/chunk-TWI644JK.js.map +0 -1
  33. package/dist/chunk-ZTH5FCUO.js +0 -4190
  34. package/dist/chunk-ZTH5FCUO.js.map +0 -1
  35. package/dist/constructions-Cbz7uEAZ.d.ts +0 -251
  36. package/dist/desk.d.ts +0 -51
  37. package/dist/desk.js +0 -111
  38. package/dist/desk.js.map +0 -1
  39. package/dist/dock.d.ts +0 -25
  40. package/dist/dock.js +0 -397
  41. package/dist/dock.js.map +0 -1
  42. package/dist/float-fit-DCYxRMru.d.ts +0 -37
  43. package/dist/lanes-DIwUqchd.d.ts +0 -1321
  44. package/dist/model-X7eUaKlA.d.ts +0 -337
  45. package/dist/panels.d.ts +0 -60
  46. package/dist/panels.js +0 -99
  47. package/dist/panels.js.map +0 -1
  48. package/dist/regions-Db_RyT4P.d.ts +0 -48
  49. package/dist/scene-cases.d.ts +0 -888
  50. package/dist/scene-cases.js +0 -3149
  51. package/dist/scene-cases.js.map +0 -1
  52. package/dist/scene.d.ts +0 -290
  53. package/dist/scene.js +0 -128
  54. package/dist/scene.js.map +0 -1
  55. package/dist/target-BBOCeez2.d.ts +0 -69
  56. package/dist/targets-C9ZVhmCl.d.ts +0 -621
  57. package/dist/targets.d.ts +0 -212
  58. package/dist/targets.js +0 -447
  59. package/dist/targets.js.map +0 -1
  60. package/dist/toolbar.d.ts +0 -167
  61. package/dist/toolbar.js +0 -55
  62. package/dist/toolbar.js.map +0 -1
@@ -1,621 +0,0 @@
1
- import { S as Size, R as Rect, P as Point } from './geometry-Bf37LbCT.js';
2
- import { T as Target } from './target-BBOCeez2.js';
3
-
4
- /**
5
- * The panels model: plain data and the pure changes on it.
6
- *
7
- * Panels have string ids. Each side holds full-height columns (outer edge first), each column one or more panels
8
- * top to bottom and its own width. Opt-in, the top and bottom edges hold a band each: its panels side by side, left to
9
- * right, sharing its width, at its own height. A panel may instead float, in page space (it moves with the page) or pinned in
10
- * view space (it stays put). A logical clock per panel (opened, used) is what give-way reads; every change here that
11
- * counts as a use moves it on. Nothing here reads a host clock: the next tick is one past the latest in the state.
12
- */
13
-
14
- type Side = "left" | "right";
15
- declare const SIDES: readonly Side[];
16
- /** A band's edge: a horizontal dock along the stage's top or bottom (opt-in, `PanelsOptions.bands`). */
17
- type Edge = "top" | "bottom";
18
- declare const EDGES: readonly Edge[];
19
- /** Where a panel may dock: a side's columns or an edge's band. */
20
- type Place = Side | Edge;
21
- /** A band's height limits and natural height when a def gives none. */
22
- declare const BAND_SIZE: {
23
- readonly min: number;
24
- readonly max: number;
25
- readonly natural: number;
26
- };
27
- /** How an edge's band lies: "reserved" shortens the pages, "overlay" lies over them; between the columns, or full width. */
28
- interface BandOption {
29
- readonly mode: "reserved" | "overlay";
30
- readonly span: "between" | "full";
31
- }
32
- /** Room kept clear along the pages' edges, px. */
33
- type Reserve = Readonly<Partial<Record<"top" | "right" | "bottom" | "left", number>>>;
34
- /**
35
- * What a consumer says about a panel: its width limits docked, its size limits floating, and where it may go. No
36
- * words: names and titles are the consumer's.
37
- */
38
- interface PanelDef {
39
- readonly id: string;
40
- /** A docked column's width limits and its natural width. */
41
- readonly width: {
42
- readonly min: number;
43
- readonly max: number;
44
- readonly natural: number;
45
- };
46
- /**
47
- * Its height as a section of a stack column (opt-in): it gets its natural height, the column's last open section
48
- * takes the rest, and when the column is short sections fold to bars by give-way. Without it a section shares the
49
- * column's height equally with the others, as before.
50
- */
51
- readonly height?: {
52
- readonly min: number;
53
- readonly natural: number;
54
- };
55
- /** A float's size limits and natural size (default: its natural width, 360 px tall, no smaller than 160 × 120). */
56
- readonly float?: {
57
- readonly min: Size;
58
- readonly natural: Size;
59
- };
60
- /** Where it may dock (default: both sides, and every edge that has a band). */
61
- readonly sides?: readonly Place[];
62
- /** A band's height limits and natural height (default `BAND_SIZE`: min 120, max 480, natural 200). */
63
- readonly band?: {
64
- readonly min: number;
65
- readonly max: number;
66
- readonly natural: number;
67
- };
68
- /** May it float (default: yes). */
69
- readonly floats?: boolean;
70
- }
71
- /**
72
- * A full-height column: its panels top to bottom, and its stored width (the layout clamps it to its panels' limits).
73
- * `show` "tabs" shows one panel at a time under a strip of tabs: `active` (default, or when `active` isn't one of
74
- * them: the first panel in the column that isn't closed).
75
- */
76
- interface Column {
77
- readonly panels: readonly string[];
78
- readonly width: number;
79
- readonly show?: "stack" | "tabs";
80
- readonly active?: string;
81
- }
82
- /** A floating panel: `rect` in page space, or in view space when `pinned`. */
83
- interface FloatAt {
84
- readonly id: string;
85
- readonly rect: Rect;
86
- readonly pinned?: boolean;
87
- }
88
- /** A band: its panels left to right, sharing its width, and its stored height (the layout clamps it to their limits). */
89
- interface Band {
90
- readonly panels: readonly string[];
91
- readonly height: number;
92
- }
93
- /** Logical times: when a panel was last opened, and last used (opened, focused, moved or unfolded). */
94
- interface Clock {
95
- readonly opened: number;
96
- readonly used: number;
97
- }
98
- interface PanelsState {
99
- /** Each side's columns, from the outer edge inward. */
100
- readonly sides: Readonly<Record<Side, readonly Column[]>>;
101
- /** Floating panels; a later one is on top. */
102
- readonly floats: readonly FloatAt[];
103
- /** Folded by hand (give-way never writes this). */
104
- readonly folded: readonly string[];
105
- /** Docked panels kept open: their columns give way last. */
106
- readonly kept: readonly string[];
107
- /** Not shown at all (they keep their place, for when they open again). */
108
- readonly closed: readonly string[];
109
- readonly clock: Readonly<Record<string, Clock>>;
110
- /** Each edge's band (absent: no band panels). An emptied band goes from the state. */
111
- readonly bands?: Readonly<Partial<Record<Edge, Band>>>;
112
- }
113
- /** The page's offset and scale in the view: a page point p shows at `x + p.x * scale`, `y + p.y * scale`. */
114
- interface View {
115
- readonly x: number;
116
- readonly y: number;
117
- readonly scale: number;
118
- }
119
- declare const IDENTITY_VIEW: View;
120
- /** Who gives way first: the oldest or the newest, by when they were last used or last opened. */
121
- interface GiveWay {
122
- readonly order: "oldest" | "newest";
123
- readonly by: "used" | "opened";
124
- }
125
- interface PanelsOptions {
126
- /** Default: `{ order: "oldest", by: "used" }`, so the panel used longest ago gives way first. */
127
- readonly giveWay: GiveWay;
128
- /** "clamp" keeps floats in the view at layout time; "free" never moves them. Default "clamp". */
129
- readonly floats: "clamp" | "free";
130
- /**
131
- * Where a column folded by hand goes (default "rail"): to its side's rail, or ("ride") as title bars on top of the
132
- * side's first open column, until every column on that side is folded. Give-way's folds always go to the rail.
133
- */
134
- readonly fold: "rail" | "ride";
135
- /** How much of a float wider than the view stays in it, px (default 48). */
136
- readonly floatVisible: number;
137
- /** The pages' minimum width (default 320). */
138
- readonly pagesMin: number;
139
- /** The page's offset and scale (default: identity). */
140
- readonly view: View;
141
- /**
142
- * A title bar's height: a panel folded in a column, a folded float, a riding column, and the part of a float the
143
- * clamp keeps in the view (default 28).
144
- */
145
- readonly bar: number;
146
- /** A rail's width (default 36). */
147
- readonly rail: number;
148
- /** A rail segment's height, and the gap above the first one (defaults 36 and 4). */
149
- readonly segment: number;
150
- readonly railInset: number;
151
- /** A tabbed column's strip height (default 28). */
152
- readonly tabs: number;
153
- /** Which edges have a band, and how it lies (default: none). */
154
- readonly bands: Readonly<Partial<Record<Edge, BandOption>>>;
155
- /** The pages' minimum height; only bands give way to it (default 240). */
156
- readonly pagesMinHeight: number;
157
- /** Room kept clear at the pages' edges for a toolbar the app draws, px (default: none). */
158
- readonly reserve: Reserve;
159
- }
160
- declare const DEFAULT_PANELS_OPTIONS: PanelsOptions;
161
- /** A float's size when its def gives none: this tall, and never smaller than FLOAT_MIN. */
162
- declare const FLOAT_HEIGHT = 360;
163
- declare const FLOAT_MIN: Size;
164
- /** Where a panel is: a column (side and index), a band (edge and index, left to right), floating, or nowhere. */
165
- type Where = {
166
- readonly kind: "column";
167
- readonly side: Side;
168
- readonly index: number;
169
- } | {
170
- readonly kind: "band";
171
- readonly edge: Edge;
172
- readonly index: number;
173
- } | {
174
- readonly kind: "float";
175
- readonly float: FloatAt;
176
- } | {
177
- readonly kind: "none";
178
- };
179
- declare function whereIs(state: PanelsState, id: string): Where;
180
- /** One past the latest logical time in the state. */
181
- declare const tick: (state: PanelsState) => number;
182
- declare const defOf: (defs: readonly PanelDef[], id: string) => PanelDef | undefined;
183
- /** A float's size limits and natural size from its def. */
184
- declare function floatSize(def: PanelDef | undefined): {
185
- min: Size;
186
- natural: Size;
187
- };
188
- /** A band's height limits and natural height from a def (`BAND_SIZE` when it gives none). */
189
- declare const bandSize: (def: PanelDef | undefined) => {
190
- min: number;
191
- max: number;
192
- natural: number;
193
- };
194
- /** A band's height as the layout takes it: its stored height clamped to its panels' limits (the largest min, the smallest max). */
195
- declare function bandHeight(defs: readonly PanelDef[] | undefined, band: Band): number;
196
- /**
197
- * A panel's own width, for a new column made for it: the width of the column it is in, clamped to its own limits;
198
- * in a band, floating or nowhere, its natural width.
199
- */
200
- declare function ownWidth(defs: readonly PanelDef[], state: PanelsState, id: string): number;
201
- interface PanelsStart {
202
- /** Each side's columns from the outer edge inward, each a list of panel ids top to bottom. */
203
- readonly left?: readonly (readonly string[])[];
204
- readonly right?: readonly (readonly string[])[];
205
- /** Each edge's band, its panels left to right (it takes the tallest natural band height, within their limits). */
206
- readonly top?: readonly string[];
207
- readonly bottom?: readonly string[];
208
- /** Floating panels: where (page space, or view space when pinned); the size defaults to the def's natural size. */
209
- readonly floats?: readonly {
210
- readonly id: string;
211
- readonly x: number;
212
- readonly y: number;
213
- readonly width?: number;
214
- readonly height?: number;
215
- readonly pinned?: boolean;
216
- }[];
217
- readonly folded?: readonly string[];
218
- readonly kept?: readonly string[];
219
- readonly closed?: readonly string[];
220
- }
221
- /**
222
- * A state from a plain start: each column as wide as the widest natural width of its panels (within their limits),
223
- * each float its natural size. The clock counts up in the order the panels are listed (left, right, top, bottom,
224
- * floats), so the last one listed is the newest.
225
- */
226
- declare function createPanels(defs: readonly PanelDef[], start: PanelsStart): PanelsState;
227
- /**
228
- * The state with `id` taken out of its column (an emptied column goes), its band (an emptied band goes, and its height
229
- * is forgotten) or the floats. Nothing else changes.
230
- */
231
- declare function liftPanel(state: PanelsState, id: string): PanelsState;
232
- /**
233
- * Open a panel: it shows again where it was, and it is the newest opened and used. A panel placed nowhere goes into
234
- * a new innermost column on `at.side`, `at.width` wide, or with `at.edge` at the right end of that edge's band (a new
235
- * band is `at.height` tall, default `BAND_SIZE.natural`; the layout clamps it); without `at` it stays placed nowhere.
236
- * In a tabbed column it becomes the tab that shows, as a drop into the column does.
237
- */
238
- declare function open(state: PanelsState, id: string, at?: {
239
- readonly side: Side;
240
- readonly width: number;
241
- } | {
242
- readonly edge: Edge;
243
- readonly height?: number;
244
- }): PanelsState;
245
- /** Close a panel: it isn't shown, keeps its place, and is no longer kept open. */
246
- declare const close: (state: PanelsState, id: string) => PanelsState;
247
- /** Focus a panel: it is the newest used; a float comes to the top. */
248
- declare function focus(state: PanelsState, id: string): PanelsState;
249
- /**
250
- * Fold a panel to its title bar by hand, or unfold it (unfolding is a use). A band folds as a whole: on a band panel
251
- * all its panels go into `folded`, or (when every shown panel of the band is folded) all come out.
252
- */
253
- declare function toggleFold(state: PanelsState, id: string): PanelsState;
254
- /** Keep a docked panel open (its column or band gives way last), or stop keeping it. A floating panel isn't kept. */
255
- declare function keep(state: PanelsState, id: string, on: boolean): PanelsState;
256
- /**
257
- * Dock a panel in the band on `edge`, at `index` (0 the leftmost; past the end, the rightmost). A new band takes the
258
- * panel's natural band height (with `defs`; else `BAND_SIZE.natural`). It shows (a band folded by hand unfolds), it is
259
- * the newest used, and it keeps whether it is kept open.
260
- */
261
- declare function dockBand(state: PanelsState, id: string, edge: Edge, index: number, defs?: readonly PanelDef[]): PanelsState;
262
- /** Store a band's height (the layout clamps it to its panels' limits). Resizing is a use, as for a column. */
263
- declare function resizeBand(state: PanelsState, edge: Edge, height: number): PanelsState;
264
- interface DockOptions {
265
- /** Stack into the column at `index` (at its bottom) instead of making a new column there. */
266
- readonly into?: boolean;
267
- /**
268
- * With `into`: the panel goes before the column's member at this index (0 the top; past the end, or left out, the
269
- * bottom), counted once the panel is lifted out.
270
- */
271
- readonly at?: number;
272
- /**
273
- * A new column's width (default: the width of the column the panel leaves, else 0, which the layout clamps to the
274
- * minimum; from a band, pass `ownWidth` for its natural width, as the drop targets do).
275
- */
276
- readonly width?: number;
277
- }
278
- /**
279
- * Dock a panel on `side`: a new column at `index` (0 the outer edge; past the end, innermost), or with `into` in the
280
- * column at `index` (counted once the panel is lifted out), at its bottom or before the member `at`. It shows, it is
281
- * the newest used, and it keeps whether it is kept open.
282
- */
283
- declare function dock(state: PanelsState, id: string, side: Side, index: number, options?: DockOptions): PanelsState;
284
- /** Show a column's panels as tabs (one at a time under a strip), or as a stack again. */
285
- declare function showTabs(state: PanelsState, side: Side, index: number, on: boolean): PanelsState;
286
- /** Make a docked panel the one its column shows (its tab), and the newest used. */
287
- declare function activate(state: PanelsState, id: string): PanelsState;
288
- /**
289
- * Float a panel at `rect` (page space; view space when pinned). A float stays pinned or not unless `pinned` says;
290
- * a docked panel floats unpinned. It shows, it is the newest used and on top, and it is no longer kept open.
291
- */
292
- declare function float(state: PanelsState, id: string, rect: Rect, pinned?: boolean): PanelsState;
293
- /** A page-space rect in view space, and back. */
294
- declare const toView: (r: Rect, v: View) => Rect;
295
- declare const toPage: (r: Rect, v: View) => Rect;
296
- /**
297
- * Pin a float to the view, or unpin it to the page. `view` is where the page is now (default: identity): the float
298
- * doesn't jump, its rect is converted between the two spaces. A float's size is never scaled.
299
- *
300
- * `shown` is where the float shows now, in view space (the layout's placed rect for it). When given, its position is
301
- * converted instead of the stored one, so a float the clamp moved stays where it shows rather than jumping to its
302
- * stored place. The size stays the stored one: a float folded to a bar, or shrunk by the clamp, keeps its full size.
303
- */
304
- declare function pin(state: PanelsState, id: string, on: boolean, view?: View, shown?: Rect): PanelsState;
305
- /**
306
- * Store a column's width (the layout clamps it to its panels' limits). Resizing is a use: the column's panels are
307
- * the newest used, so give-way takes room from the other columns, not from the one being resized.
308
- */
309
- declare function resizeColumn(state: PanelsState, side: Side, index: number, width: number): PanelsState;
310
- /** Store a float's rect (its own space). Resizing is a use. */
311
- declare function resizeFloat(state: PanelsState, id: string, rect: Rect): PanelsState;
312
- /** A column's width as the layout takes it: its stored width clamped to its panels' limits (with `defs`). */
313
- declare function columnWidth(defs: readonly PanelDef[] | undefined, col: Column): number;
314
- /**
315
- * Two states place the panels the same (columns, their panels and widths, floats and their rects; the clock aside).
316
- * With `defs`, widths compare as the layout takes them (clamped to the panels' limits), so a stored width past a
317
- * column's max is the same place as that max.
318
- */
319
- declare function samePlaces(a: PanelsState, b: PanelsState, defs?: readonly PanelDef[]): boolean;
320
-
321
- /**
322
- * `layoutPanels`: the panels' state, a stage and options in; geometry and structure out: every panel's rect, layer
323
- * and kind, the columns, the rails, the pages' rect, and coded notes on how it gave way. Pure: the same input always
324
- * lays out the same. How anything looks is the consumer's.
325
- *
326
- * - A column is full height and as wide as its stored width, clamped to its panels' limits. Inside it, a panel
327
- * folded by hand is a title bar (`options.bar` tall) and the open ones share the rest of the height equally.
328
- * - A column whose panels are all folded is railed: its panels become segments of its side's rail (one rail per
329
- * side, `options.rail` wide at the outer edge, segments in side order).
330
- * - With `options.fold` "ride", a column folded by hand on a side that still has an open column rides instead: its
331
- * panels become title bars stacked on top of the side's first open column (outer edge first), as wide as that
332
- * column, and its open panels share the rest of the height. The folded column keeps its stored place and width, and
333
- * the open columns lie as if it were gone. Only when every column on the side is folded does the side show its rail.
334
- * Give-way's folds always go to the rail.
335
- * - A float folded by hand is a title bar: its own x, y and width, `options.bar` tall, still a float (clamped as a
336
- * bar, `floating`); unfolding brings its full rect back, as the stored rect never changes.
337
- * - Give-way: when the open columns, the rails and `pagesMin` don't fit the stage width, columns shrink toward their
338
- * minimum, then whole columns fold to the rail, in the policy's order, until the pages fit. Columns holding a kept
339
- * panel come after every other column; if the pages still don't fit, they fold too (`kept-folded`). Folding by
340
- * give-way never writes `folded`, so a wider stage brings the column back.
341
- * - Floats: "clamp" keeps a float in the view at layout time (the state keeps the stored rect, so a larger view
342
- * brings it back where it was); "free" never moves one. A float's size is never scaled. A pinned float is in view
343
- * space and clamped against the view; an unpinned one has its position in page space, clamped so that its screen
344
- * rect at pan 0 fits the view, then moved by the view's offset and scale, so it scrolls with the page.
345
- */
346
-
347
- /**
348
- * Where a panel is, structurally: an open part of a column, an open part of a band, a folded title bar (in a column,
349
- * riding on one, in a folded band, or a folded float), a segment of a rail (the panel itself isn't laid out), or a
350
- * float.
351
- */
352
- type PanelKind = "column" | "band" | "bar" | "segment" | "float";
353
- interface PlacedPanel {
354
- /** Stage px; for a segment, the segment's rect in its rail. */
355
- readonly rect: Rect;
356
- readonly kind: PanelKind;
357
- /** Columns, rails and reserved bands 0, overlay bands 5, floats 10 and up (a later float on top). */
358
- readonly layer: number;
359
- /** Not drawn as a panel: in a rail (only its segment shows), or a tab that isn't showing (only its `tab`). */
360
- readonly hidden: boolean;
361
- /** Folded by hand (a bar, or a segment of a column folded by hand), or by give-way (a segment). */
362
- readonly folded: null | "hand" | "auto";
363
- /** Kept open. */
364
- readonly kept: boolean;
365
- /** A pinned float. */
366
- readonly pinned: boolean;
367
- /** It floats (open, or folded to a bar). */
368
- readonly floating: boolean;
369
- /** Docked: its side and column index (the state's). */
370
- readonly side?: Side;
371
- readonly column?: number;
372
- /** A riding bar: the index of the column it rides on (`options.fold` "ride"). */
373
- readonly rides?: number;
374
- /** In a tabbed column: its tab's rect in the strip (panel order, equal widths). */
375
- readonly tab?: Rect;
376
- /** A float the clamp moved or resized. */
377
- readonly clamped?: boolean;
378
- /** In a band: its edge and its index in the state's band (left to right). */
379
- readonly edge?: Edge;
380
- readonly index?: number;
381
- }
382
- /** A band as laid out. */
383
- interface PlacedBand {
384
- readonly edge: Edge;
385
- /** The band's rect (a bar when folded). */
386
- readonly rect: Rect;
387
- /** Its stored height clamped to its panels' limits, and those limits. */
388
- readonly height: number;
389
- readonly min: number;
390
- readonly max: number;
391
- /** null: open; "hand": its panels folded by hand; "auto": folded by give-way. */
392
- readonly folded: null | "hand" | "auto";
393
- /** Shrunk by give-way below its height. */
394
- readonly shrunk: boolean;
395
- /** It holds a kept panel. */
396
- readonly kept: boolean;
397
- readonly mode: "reserved" | "overlay";
398
- readonly span: "between" | "full";
399
- /** The shown panels, left to right. */
400
- readonly panels: readonly string[];
401
- }
402
- /** A reserve's edge. */
403
- type ReserveEdge = "top" | "right" | "bottom" | "left";
404
- interface PlacedColumn {
405
- readonly side: Side;
406
- /** The column's index in the state. */
407
- readonly index: number;
408
- /** Its rect (zero wide when railed). */
409
- readonly rect: Rect;
410
- /** Its stored width clamped to its panels' limits, and those limits. */
411
- readonly width: number;
412
- readonly min: number;
413
- readonly max: number;
414
- /** null: open; "hand": all its panels folded by hand; "auto": folded by give-way. */
415
- readonly folded: null | "hand" | "auto";
416
- /** Shrunk by give-way below its width. */
417
- readonly shrunk: boolean;
418
- /** It holds a kept panel. */
419
- readonly kept: boolean;
420
- /** The shown panels, top to bottom. */
421
- readonly panels: readonly string[];
422
- /** Riding: the index of the column its bars ride on; its rect is the bars'. */
423
- readonly rides?: number;
424
- /** How it shows its panels (default "stack"). */
425
- readonly show?: "stack" | "tabs";
426
- /** Tabbed and laid out: its strip of tabs, and the panel it shows. */
427
- readonly strip?: Rect;
428
- readonly active?: string;
429
- }
430
- interface PlacedRail {
431
- readonly side: Side;
432
- readonly rect: Rect;
433
- readonly segments: readonly {
434
- readonly id: string;
435
- readonly rect: Rect;
436
- }[];
437
- }
438
- type PanelsNoteCode = "column-shrunk" | "column-folded" | "kept-folded" | "section-folded" | "pages-under-min" | "float-clamped" | "float-resized" | "band-shrunk" | "band-folded" | "band-off" | "pages-short";
439
- /** One note on a layout: a code and its data. `kept-folded` carries `side` and `column` for a column, `edge` for a band. */
440
- type PanelsNote = {
441
- readonly code: "column-shrunk";
442
- readonly side: Side;
443
- readonly column: number;
444
- readonly items: readonly string[];
445
- readonly from: number;
446
- readonly to: number;
447
- } | {
448
- readonly code: "column-folded" | "kept-folded" | "section-folded";
449
- readonly side: Side;
450
- readonly column: number;
451
- readonly items: readonly string[];
452
- } | {
453
- readonly code: "pages-under-min";
454
- readonly width: number;
455
- readonly min: number;
456
- } | {
457
- readonly code: "float-clamped" | "float-resized";
458
- readonly items: readonly string[];
459
- } | {
460
- readonly code: "band-shrunk";
461
- readonly edge: Edge;
462
- readonly items: readonly string[];
463
- readonly from: number;
464
- readonly to: number;
465
- } | {
466
- readonly code: "band-folded" | "kept-folded" | "band-off";
467
- readonly edge: Edge;
468
- readonly items: readonly string[];
469
- } | {
470
- readonly code: "pages-short";
471
- readonly height: number;
472
- readonly min: number;
473
- };
474
- interface PanelsLayout {
475
- readonly items: Map<string, PlacedPanel>;
476
- /** The shown columns in side order (left outer → inner, then right outer → inner). */
477
- readonly columns: readonly PlacedColumn[];
478
- readonly rails: Partial<Record<Side, PlacedRail>>;
479
- readonly notes: readonly PanelsNote[];
480
- /** What is left for the documents. */
481
- readonly pages: Rect;
482
- /** The bands laid out (an enabled edge with shown panels). */
483
- readonly bands: Readonly<Partial<Record<Edge, PlacedBand>>>;
484
- /** The room kept clear along the pages' edges (an edge with a reserve over 0). */
485
- readonly reserved: Readonly<Partial<Record<ReserveEdge, Rect>>>;
486
- }
487
- /** The order columns give way in: unkept before kept, then the policy (oldest or newest), outer first, left first. */
488
- declare function giveWayOrder<C extends {
489
- readonly side: Side;
490
- readonly index: number;
491
- readonly kept: boolean;
492
- readonly age: number;
493
- }>(cols: readonly C[], order: "oldest" | "newest"): C[];
494
- declare function layoutPanels(defs: readonly PanelDef[], state: PanelsState, stage: Size, options?: Partial<PanelsOptions>): PanelsLayout;
495
-
496
- /**
497
- * The drop targets for dragging a panel, in the shape @n-uf/motion/drag takes (`{ id, priority, hit, slot?, free? }`),
498
- * worked out from the state with the panel lifted out:
499
- *
500
- * - `column:<side>:<i>` (priority 2): a band across the line between two columns (or a side's edge): a new column
501
- * there, as wide as the panel's own width.
502
- * - `into:<side>:<i>` (2): a column's area: the panel stacks at its bottom.
503
- * - `into:<side>:<i>:<k>` (2), opt-in (`stackSlots`): before the stacked column's member k. The column's area is split
504
- * at its members' middles: the top half of member k (and the lower half of the one above) goes before k, and
505
- * `into:<side>:<i>` keeps only what lies below the last member's middle. `marker` is the line where the panel's top
506
- * lands after the drop, for the app to draw. k counts closed members too (they keep their place in the column's
507
- * list); only the members shown get slots. A tabbed column keeps its one `into` target.
508
- * - `rail:<side>` (1): the side's rail, or its outer edge: the panel docks folded.
509
- * - `float` (3, free): anywhere; it floats where it is let go, kept in the view as the float option says.
510
- * - `band:<edge>:<i>` (2), for each edge with a band (`options.bands`): the slots between a band's panels and at both
511
- * ends (the band's area split at its panels' middles). `band:<edge>` (2): an empty enabled edge, a strip `2 × bar`
512
- * tall along it inside the pages' area.
513
- *
514
- * A place the panel may not take (its def's `sides` and `floats`, and `allows`) is no target, and neither is its own
515
- * place (a drop there changes nothing). Targets carry a structured `place`, never words: the consumer names them.
516
- */
517
-
518
- /** Where a drop puts a panel. `index` is a column (or band panel) index in the state with the panel lifted out. */
519
- type PanelPlace = {
520
- readonly kind: "column";
521
- readonly side: Side;
522
- readonly index: number;
523
- } | {
524
- readonly kind: "into";
525
- readonly side: Side;
526
- readonly index: number;
527
- /** Before the column's member at this index (in the state with the panel lifted out); left out: at its bottom. */
528
- readonly at?: number;
529
- } | {
530
- readonly kind: "rail";
531
- readonly side: Side;
532
- } | {
533
- readonly kind: "band";
534
- readonly edge: Edge;
535
- readonly index: number;
536
- } | {
537
- readonly kind: "float";
538
- };
539
- interface PanelTarget extends Target {
540
- /** The panel dragged. */
541
- readonly panel: string;
542
- readonly place: PanelPlace;
543
- /** Its rank in reading order (left to right across the stage, floating last). */
544
- readonly order: number;
545
- /** The state a drop here makes, with the pointer at `p` holding the panel at `grab` from its top-left corner. */
546
- readonly make: (p: Point, grab: Point) => PanelsState;
547
- /**
548
- * With `stackSlots`, on `into` targets of a stacked column: the line where the panel's top lands after the drop (the
549
- * column re-shares its height, so this is the drop's layout, not today's gap), as a rect zero tall and as wide as
550
- * the column. `panelDrop(...).slot` is the whole rect.
551
- */
552
- readonly marker?: Rect;
553
- }
554
- interface PanelTargetInput {
555
- readonly defs: readonly PanelDef[];
556
- /** The state as it is, the panel still in its place. */
557
- readonly state: PanelsState;
558
- readonly id: string;
559
- readonly stage: Size;
560
- readonly options?: Partial<PanelsOptions>;
561
- /** Places the panel may go beyond its def's rules (default: all of them). */
562
- readonly allows?: (id: string, place: PanelPlace) => boolean;
563
- /** Drops into a stacked column may go before any of its members (`into` targets with `at`); default: the bottom only. */
564
- readonly stackSlots?: boolean;
565
- }
566
-
567
- /**
568
- * A place's rank in reading order: the left side outer to inner, the right side inner to outer, then the top band and
569
- * the bottom band left to right, floating last.
570
- */
571
- declare function placeRank(place: PanelPlace): number;
572
- /**
573
- * Where a panel is now, as a place (a float, a column of its own, or stacked in one); null when placed nowhere. With
574
- * `stackSlots`, a panel stacked in a column says its position there as `at` (a tabbed column's panel never does).
575
- */
576
- declare function homePlace(state: PanelsState, id: string, options?: {
577
- readonly stackSlots?: boolean;
578
- }): PanelPlace | null;
579
- /** The targets for dragging `input.id`, in reading order. */
580
- declare function panelTargets(input: PanelTargetInput): PanelTarget[];
581
- /** A target's drop, laid out: where the panel lands. */
582
- interface PanelDrop {
583
- readonly target: string;
584
- readonly place: PanelPlace;
585
- /** Same key, same place (a float's key carries where it lands). */
586
- readonly key: string;
587
- readonly state: PanelsState;
588
- readonly layout: PanelsLayout;
589
- /** Where the panel lands (its rail segment when it docks folded). */
590
- readonly slot: Rect;
591
- /** It lands in a rail. */
592
- readonly hidden: boolean;
593
- /** It floats where it is let go: no room is made for it. */
594
- readonly free: boolean;
595
- }
596
- /** The drop on `target` with the pointer at `p` holding the panel at `grab`, laid out. */
597
- declare function panelDrop(input: PanelTargetInput, target: PanelTarget, p: Point, grab: Point): PanelDrop;
598
- interface PanelStop {
599
- /** The target's id ("home" for the panel's place when the drag started). */
600
- readonly id: string;
601
- readonly place: PanelPlace;
602
- /** The state a move here makes (the current one for home). */
603
- readonly state: PanelsState;
604
- readonly home: boolean;
605
- }
606
- interface PanelStopsOptions {
607
- /** The panel's home (`homePlace`) and the state as it is: a stop of its own in its reading-order position. */
608
- readonly home?: {
609
- readonly place: PanelPlace;
610
- readonly state: PanelsState;
611
- };
612
- /** Floating as a stop at the end (default: left out); `at` and `grab` as for a drop (default: the stage's middle, the corner). */
613
- readonly floats?: boolean | {
614
- readonly at: Point;
615
- readonly grab?: Point;
616
- };
617
- }
618
- /** The panel's places in reading order, for the arrow keys and a "Move to" menu (`keyboardStops` calls this). */
619
- declare function panelStops(targets: readonly PanelTarget[], options?: PanelStopsOptions): PanelStop[];
620
-
621
- export { giveWayOrder as $, type PlacedRail as A, BAND_SIZE as B, type Clock as C, DEFAULT_PANELS_OPTIONS as D, type Edge as E, FLOAT_HEIGHT as F, type GiveWay as G, type ReserveEdge as H, IDENTITY_VIEW as I, SIDES as J, activate as K, bandHeight as L, bandSize as M, close as N, columnWidth as O, type PanelsOptions as P, createPanels as Q, type Reserve as R, type Side as S, defOf as T, dock as U, type View as V, type Where as W, dockBand as X, float as Y, floatSize as Z, focus as _, type PanelDef as a, homePlace as a0, keep as a1, liftPanel as a2, open as a3, ownWidth as a4, panelStops as a5, panelTargets as a6, pin as a7, placeRank as a8, resizeBand as a9, resizeColumn as aa, resizeFloat as ab, samePlaces as ac, showTabs as ad, tick as ae, toPage as af, toView as ag, toggleFold as ah, whereIs as ai, type PanelsState as b, type PanelTargetInput as c, type PanelTarget as d, type PanelDrop as e, type PanelsLayout as f, type Band as g, type BandOption as h, type Column as i, type DockOptions as j, EDGES as k, layoutPanels as l, FLOAT_MIN as m, type FloatAt as n, type PanelKind as o, panelDrop as p, type PanelPlace as q, type PanelStop as r, type PanelStopsOptions as s, type PanelsNote as t, type PanelsNoteCode as u, type PanelsStart as v, type Place as w, type PlacedBand as x, type PlacedColumn as y, type PlacedPanel as z };