@n-uf/placement 26.11.16 → 26.11.18
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 +67 -0
- package/README.md +133 -21
- package/dist/chunk-HQE2DOWA.js +1353 -0
- package/dist/chunk-HQE2DOWA.js.map +1 -0
- package/dist/{chunk-RYFQKQPQ.js → chunk-RUITEOZ7.js} +100 -9
- package/dist/chunk-RUITEOZ7.js.map +1 -0
- package/dist/{model-CMH_27_g.d.ts → model-irGEua8T.d.ts} +73 -4
- package/dist/scene-cases.d.ts +409 -0
- package/dist/scene-cases.js +2004 -0
- package/dist/scene-cases.js.map +1 -0
- package/dist/scene.d.ts +6 -535
- package/dist/scene.js +34 -1129
- package/dist/scene.js.map +1 -1
- package/dist/stack.d.ts +2 -2
- package/dist/stack.js +16 -4
- package/dist/stack.js.map +1 -1
- package/dist/targets-CZOYu8mG.d.ts +595 -0
- package/package.json +5 -1
- package/dist/chunk-RYFQKQPQ.js.map +0 -1
package/dist/scene.d.ts
CHANGED
|
@@ -1,317 +1,8 @@
|
|
|
1
|
-
import { S as
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* The scene's shapes: one model of a whole window. A scene is a stage (the window's inner rect), the edges along its
|
|
7
|
-
* sides (bars and columns, each a stack of items), the items, the floats above the content, and the chrome that
|
|
8
|
-
* floats and drop zones keep clear of. `solve(scene)` turns it into a `SceneLayout`: every rect a host draws.
|
|
9
|
-
*
|
|
10
|
-
* Plain data in and out, nothing module-global: two windows on one page are two scenes. No words, no time, no DOM.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/** The host's kinds of item, such as "panel" and "group". An edge takes only the kinds it lists. */
|
|
14
|
-
type Kind = string;
|
|
15
|
-
/** A side of the stage. Left and right edges are columns (they run down); top and bottom edges are bars (they run across). */
|
|
16
|
-
type Side = "top" | "right" | "bottom" | "left";
|
|
17
|
-
declare const SIDES: readonly Side[];
|
|
18
|
-
/** Where an item sits along its edge: packed from the start, centred in the spare length, or packed from the end. */
|
|
19
|
-
type Zone = "start" | "center" | "end";
|
|
20
|
-
declare const ZONES: readonly Zone[];
|
|
21
|
-
/** A float that follows the content: flush with that side or corner of `layout.content` until a drop gives it a real rect. */
|
|
22
|
-
type FloatAnchor = "content-top-left" | "content-top" | "content-top-right" | "content-right" | "content-bottom-right" | "content-bottom" | "content-bottom-left" | "content-left";
|
|
23
|
-
/** Along which axis an item lies: a column runs down, a row (a bar) runs across. */
|
|
24
|
-
type Orient = "column" | "row";
|
|
25
|
-
interface SceneItem {
|
|
26
|
-
readonly id: string;
|
|
27
|
-
readonly kind: Kind;
|
|
28
|
-
/**
|
|
29
|
-
* Its forms along a column and along a row (a bar), largest first, as `./stack` takes them. An item with no forms for
|
|
30
|
-
* an axis can't be laid out along it (`no-forms`).
|
|
31
|
-
*/
|
|
32
|
-
readonly forms: {
|
|
33
|
-
readonly column?: readonly StackForm[];
|
|
34
|
-
readonly row?: readonly StackForm[];
|
|
35
|
-
};
|
|
36
|
-
/** How recently it was used: the smaller, the longer ago, the sooner it gives way. */
|
|
37
|
-
readonly used: number;
|
|
38
|
-
/** Kept: gives way after every item that isn't. */
|
|
39
|
-
readonly kept?: boolean;
|
|
40
|
-
/**
|
|
41
|
-
* The first form it may take, an index into the forms of the axis it lies along (default 0). Folding by hand sets it
|
|
42
|
-
* (`fold`). A float with `from` over 0 is drawn as its bar: that form's natural length, at the float's place.
|
|
43
|
-
*/
|
|
44
|
-
readonly from?: number;
|
|
45
|
-
/**
|
|
46
|
-
* Reserved room: a title, window controls, a page readout. It never changes form (it keeps `forms[from]`), is never
|
|
47
|
-
* reordered, never dragged, and no hit or slot covers it. Its length may shrink to its form's `main.min` and grow
|
|
48
|
-
* with spare room when the form `grows`; window controls have `min` equal to `natural`.
|
|
49
|
-
*/
|
|
50
|
-
readonly fixed?: boolean;
|
|
51
|
-
/** Closed: it keeps its place in its edge (or its float rect) but takes no room and has no targets. */
|
|
52
|
-
readonly closed?: boolean;
|
|
53
|
-
/** Its zone in its edge (default start). */
|
|
54
|
-
readonly align?: Zone;
|
|
55
|
-
/** Its size as a float: `floatAt` with no rect uses it, and a float drop sets it. */
|
|
56
|
-
readonly floatSize?: Size;
|
|
57
|
-
}
|
|
58
|
-
interface Edge {
|
|
59
|
-
readonly id: string;
|
|
60
|
-
readonly side: Side;
|
|
61
|
-
/** 0 is the outermost on its side (a title bar outside a toolbar). */
|
|
62
|
-
readonly ring: number;
|
|
63
|
-
/**
|
|
64
|
-
* Top and bottom bars only: across the whole stage (`"full"`, the default) or between the side columns
|
|
65
|
-
* (`"between"`). Left and right edges ignore it.
|
|
66
|
-
*/
|
|
67
|
-
readonly span?: "full" | "between";
|
|
68
|
-
/** The kinds a drop may bring here. Deny by default: an empty list takes nothing (an anchor). */
|
|
69
|
-
readonly accepts: readonly Kind[];
|
|
70
|
-
/** Ids in order, fixed and closed items included. */
|
|
71
|
-
readonly items: readonly string[];
|
|
72
|
-
/** The size it may take across (a column's width, a bar's height), and the rail width when nothing sets it. */
|
|
73
|
-
readonly cross: CrossLimits;
|
|
74
|
-
/** `"overlay"` lies over the content instead of shortening it (default `"reserved"`). */
|
|
75
|
-
readonly mode?: "reserved" | "overlay";
|
|
76
|
-
readonly gap?: number;
|
|
77
|
-
readonly pad?: {
|
|
78
|
-
readonly start?: number;
|
|
79
|
-
readonly end?: number;
|
|
80
|
-
};
|
|
81
|
-
/** The » entry's length along the edge. */
|
|
82
|
-
readonly menu?: {
|
|
83
|
-
readonly main: number;
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* The user's size across (a column dragged wider), clamped to `[max(cross.min, the widest open setter's cross.min),
|
|
87
|
-
* cross.max]`, so an open item's `cross.min` wins over a smaller size. Used only while an item sets the cross size.
|
|
88
|
-
*/
|
|
89
|
-
readonly size?: number;
|
|
90
|
-
/** A column drawn as a rail (nothing in it sets its width) shows its closed items too, as tabs marked `closed`. */
|
|
91
|
-
readonly railShowsClosed?: boolean;
|
|
92
|
-
/** The drop strip's depth while the edge is empty, px (default {@link DEFAULT_STRIP}). */
|
|
93
|
-
readonly strip?: number;
|
|
94
|
-
/**
|
|
95
|
-
* How a gap's hit runs along the edge. A number: a band that many px around the gap's insertion line (the first and
|
|
96
|
-
* last also reach `endReach` past the edge's ends), clamped so neighbouring bands never overlap, so the body of an item
|
|
97
|
-
* away from its edges is no gap and the pointer falls through to the float target, or to none. `"middle"`: the edge
|
|
98
|
-
* split halfway between neighbouring lines, so every point of it is some gap. Default {@link DEFAULT_HIT_BAND} for left
|
|
99
|
-
* and right edges, `"middle"` for bars.
|
|
100
|
-
*/
|
|
101
|
-
readonly hitBand?: number | "middle";
|
|
102
|
-
/**
|
|
103
|
-
* A dynamic column (left and right only): made by a drop on a column line, deleted when it holds no item, folded whole
|
|
104
|
-
* into its side's rail by give-way (`Scene.contentMin`) or when every member is folded by hand. Its `accepts`,
|
|
105
|
-
* `cross`, `gap`, `pad` and `menu` come from `Scene.columns[side]` when the changes make it.
|
|
106
|
-
*/
|
|
107
|
-
readonly column?: boolean;
|
|
108
|
-
}
|
|
109
|
-
/** What a side's new columns are made from. */
|
|
110
|
-
interface ColumnTemplate {
|
|
111
|
-
readonly accepts: readonly Kind[];
|
|
112
|
-
readonly cross: CrossLimits;
|
|
113
|
-
readonly gap?: number;
|
|
114
|
-
readonly pad?: {
|
|
115
|
-
readonly start?: number;
|
|
116
|
-
readonly end?: number;
|
|
117
|
-
};
|
|
118
|
-
readonly menu?: {
|
|
119
|
-
readonly main: number;
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
/** A side's one rail strip: folded columns show in it as segments, in ring order. */
|
|
123
|
-
interface RailSpec {
|
|
124
|
-
/** Its width, px. */
|
|
125
|
-
readonly width: number;
|
|
126
|
-
/** The kinds a drop on the rail may bring (it docks folded). */
|
|
127
|
-
readonly accepts: readonly Kind[];
|
|
128
|
-
}
|
|
129
|
-
interface SceneFloat {
|
|
130
|
-
readonly id: string;
|
|
131
|
-
/** Its rect in stage px (it never scrolls with the content). With `anchor`, only its size counts. */
|
|
132
|
-
readonly rect: Rect;
|
|
133
|
-
/** Follow the content's side or corner until a drop gives it a real rect. */
|
|
134
|
-
readonly anchor?: FloatAnchor;
|
|
135
|
-
/** Which of the item's forms it uses (default `"column"`). */
|
|
136
|
-
readonly orient?: Orient;
|
|
137
|
-
}
|
|
138
|
-
interface Scene {
|
|
139
|
-
/** The window's inner rect. */
|
|
140
|
-
readonly stage: Rect;
|
|
141
|
-
readonly edges: readonly Edge[];
|
|
142
|
-
readonly items: Readonly<Record<string, SceneItem>>;
|
|
143
|
-
/** Stacking order: the last is on top. */
|
|
144
|
-
readonly floats: readonly SceneFloat[];
|
|
145
|
-
/** The kinds that may float. Deny by default. */
|
|
146
|
-
readonly floatKinds: readonly Kind[];
|
|
147
|
-
/** Rects that floats and drop zones keep clear of (a title the host draws itself, a status line). */
|
|
148
|
-
readonly chrome?: readonly Rect[];
|
|
149
|
-
/** Spots where a release cancels: `targets` gives a `none` target over each. */
|
|
150
|
-
readonly blocked?: readonly Rect[];
|
|
151
|
-
/** Per side (left, right): what a new column is made from. A side without one gets no new columns. */
|
|
152
|
-
readonly columns?: Partial<Record<"left" | "right", ColumnTemplate>>;
|
|
153
|
-
/** Per side (left, right): its rail. A side without one keeps folded columns as columns. */
|
|
154
|
-
readonly rails?: Partial<Record<"left" | "right", RailSpec>>;
|
|
155
|
-
/**
|
|
156
|
-
* The least the content may be. While the content is narrower than `width`, dynamic columns shrink toward their
|
|
157
|
-
* minimum, then fold whole into their side's rail: unkept before kept, the one whose newest use is oldest first, the
|
|
158
|
-
* outer first, the left first. Under `height`, a `content-short` note.
|
|
159
|
-
*/
|
|
160
|
-
readonly contentMin?: {
|
|
161
|
-
readonly width: number;
|
|
162
|
-
readonly height: number;
|
|
163
|
-
};
|
|
164
|
-
/**
|
|
165
|
-
* How a one-panel column folded by hand shows (default `"bar"`): `"bar"` sends it to its side's rail; `"ride"` draws it
|
|
166
|
-
* as a title bar over the first open column of its side, at that column's width, taking no width of its own.
|
|
167
|
-
*/
|
|
168
|
-
readonly handFold?: "bar" | "ride";
|
|
169
|
-
/** Space kept clear inside the stage's edges, px (default 0 each). */
|
|
170
|
-
readonly inset?: {
|
|
171
|
-
readonly top?: number;
|
|
172
|
-
readonly right?: number;
|
|
173
|
-
readonly bottom?: number;
|
|
174
|
-
readonly left?: number;
|
|
175
|
-
};
|
|
176
|
-
/** Space after each left or right edge and each rail that takes room, toward the content, px (default 0). */
|
|
177
|
-
readonly gutter?: number;
|
|
178
|
-
}
|
|
179
|
-
/** An item as laid out. */
|
|
180
|
-
interface SceneItemLayout {
|
|
181
|
-
/** Stage px. An item in the » menu has the menu entry's rect. */
|
|
182
|
-
readonly rect: Rect;
|
|
183
|
-
readonly kind: Kind;
|
|
184
|
-
/** The form it took: an index into the forms of its axis. */
|
|
185
|
-
readonly form: number;
|
|
186
|
-
readonly formKind: StackFormKind;
|
|
187
|
-
/** Docked: its edge and zone. */
|
|
188
|
-
readonly edge?: string;
|
|
189
|
-
readonly zone?: Zone;
|
|
190
|
-
readonly floating?: boolean;
|
|
191
|
-
readonly inMenu?: boolean;
|
|
192
|
-
/** A rail tab (its column is a rail). */
|
|
193
|
-
readonly tab?: boolean;
|
|
194
|
-
/** A closed item shown as a rail tab (`railShowsClosed`). */
|
|
195
|
-
readonly closed?: boolean;
|
|
196
|
-
readonly fixed?: boolean;
|
|
197
|
-
/** Drawn as a segment of this side's rail (its column is folded). */
|
|
198
|
-
readonly rail?: "left" | "right";
|
|
199
|
-
/** Drawn as a title bar riding on this column (`handFold: "ride"`). */
|
|
200
|
-
readonly rides?: string;
|
|
201
|
-
/** Its column folded: by hand (every member folded) or by give-way. */
|
|
202
|
-
readonly folded?: "hand" | "auto";
|
|
203
|
-
}
|
|
204
|
-
/** An edge as laid out. */
|
|
205
|
-
interface SceneEdgeLayout {
|
|
206
|
-
readonly side: Side;
|
|
207
|
-
readonly ring: number;
|
|
208
|
-
/** Stage px: the strip it takes (zero across when nothing is drawn in it). */
|
|
209
|
-
readonly rect: Rect;
|
|
210
|
-
/** Its size across. */
|
|
211
|
-
readonly cross: number;
|
|
212
|
-
/** Its » entry and the items in it, or null. */
|
|
213
|
-
readonly menu: {
|
|
214
|
-
readonly rect: Rect;
|
|
215
|
-
readonly items: readonly string[];
|
|
216
|
-
} | null;
|
|
217
|
-
/** The ids drawn as rail tabs, in order (empty unless the column is a rail). */
|
|
218
|
-
readonly tabs: readonly string[];
|
|
219
|
-
/**
|
|
220
|
-
* The stack fits behind it, in stack-local px: `stack` is the one drawn, `free` the first fit (before `size` or the
|
|
221
|
-
* rail re-solved it). `solve`'s `previous` reads both; a host needs neither.
|
|
222
|
-
*/
|
|
223
|
-
readonly stack: StackFit;
|
|
224
|
-
readonly free: StackFit;
|
|
225
|
-
/** A dynamic column folded into its side's rail (its rect is zero wide there): by hand or by give-way. */
|
|
226
|
-
readonly folded?: "hand" | "auto";
|
|
227
|
-
/** Shrunk by give-way below the width it asks for. */
|
|
228
|
-
readonly shrunk?: boolean;
|
|
229
|
-
/** Riding on this column (its rect is the bars'). */
|
|
230
|
-
readonly rides?: string;
|
|
231
|
-
}
|
|
232
|
-
/** A side's rail as laid out. */
|
|
233
|
-
interface SceneRailLayout {
|
|
234
|
-
readonly rect: Rect;
|
|
235
|
-
/** One per member of each folded column, in ring order. */
|
|
236
|
-
readonly segments: readonly {
|
|
237
|
-
readonly id: string;
|
|
238
|
-
readonly edge: string;
|
|
239
|
-
readonly rect: Rect;
|
|
240
|
-
}[];
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Why the layout looks as it does:
|
|
244
|
-
* - a stack's note with its `edge` (`form-down`, `to-menu`, `too-wide`, `no-forms`, `overflow`);
|
|
245
|
-
* - `unknown-item`: an id in an edge or a float that `items` lacks (left out);
|
|
246
|
-
* - `twice`: an item placed in two places (the first in cut order wins, edges before floats);
|
|
247
|
-
* - `float-clamped`, `float-moved`: a float was moved into the stage, or clear of what it would cover;
|
|
248
|
-
* - `float-covers`: no clear place exists, and it covers the least it can.
|
|
249
|
-
* - `column-shrunk`, `column-folded`, `kept-folded`: give-way by `contentMin.width`, in give-way order;
|
|
250
|
-
* - `content-narrow`, `content-short`: the content is still under `contentMin` (overlay bars count against the height).
|
|
251
|
-
* - `content-changed`: under `previous`, `content` is not the rect `previous.content` was (`from`, `to`). A host refits
|
|
252
|
-
* its zoom only on this note.
|
|
253
|
-
*/
|
|
254
|
-
type SceneNote = ({
|
|
255
|
-
readonly edge: string;
|
|
256
|
-
} & StackNote) | {
|
|
257
|
-
readonly code: "unknown-item";
|
|
258
|
-
readonly id: string;
|
|
259
|
-
} | {
|
|
260
|
-
readonly code: "twice";
|
|
261
|
-
readonly id: string;
|
|
262
|
-
} | {
|
|
263
|
-
readonly code: "float-clamped" | "float-moved" | "float-covers";
|
|
264
|
-
readonly id: string;
|
|
265
|
-
} | {
|
|
266
|
-
readonly code: "column-shrunk";
|
|
267
|
-
readonly edge: string;
|
|
268
|
-
readonly from: number;
|
|
269
|
-
readonly to: number;
|
|
270
|
-
} | {
|
|
271
|
-
readonly code: "column-folded" | "kept-folded";
|
|
272
|
-
readonly edge: string;
|
|
273
|
-
} | {
|
|
274
|
-
readonly code: "content-narrow";
|
|
275
|
-
readonly width: number;
|
|
276
|
-
readonly min: number;
|
|
277
|
-
} | {
|
|
278
|
-
readonly code: "content-short";
|
|
279
|
-
readonly height: number;
|
|
280
|
-
readonly min: number;
|
|
281
|
-
} | {
|
|
282
|
-
readonly code: "content-changed";
|
|
283
|
-
readonly from: Rect;
|
|
284
|
-
readonly to: Rect;
|
|
285
|
-
};
|
|
286
|
-
type SceneNoteCode = SceneNote["code"];
|
|
287
|
-
interface SceneLayout {
|
|
288
|
-
/** Every item drawn (closed items only when shown as rail tabs). */
|
|
289
|
-
readonly items: Readonly<Record<string, SceneItemLayout>>;
|
|
290
|
-
readonly edges: Readonly<Record<string, SceneEdgeLayout>>;
|
|
291
|
-
/** What is left for the content (the pages). Overlay edges lie over it. */
|
|
292
|
-
readonly content: Rect;
|
|
293
|
-
/** The floats drawn, in stacking order (the last on top). */
|
|
294
|
-
readonly floats: readonly string[];
|
|
295
|
-
/** The rails shown (a side with a folded column). */
|
|
296
|
-
readonly rails: Readonly<Partial<Record<"left" | "right", SceneRailLayout>>>;
|
|
297
|
-
readonly notes: readonly SceneNote[];
|
|
298
|
-
}
|
|
299
|
-
interface SolveOptions {
|
|
300
|
-
/**
|
|
301
|
-
* The layout the scene had before: each edge's fit goes to `fitStack` as `previous`, so a press reshapes nothing. An
|
|
302
|
-
* item docked now that was closed or absent then has just opened: it counts as the newest (its largest form while it
|
|
303
|
-
* fits; the others give way by the usual rules), and its column is weighed anew by give-way.
|
|
304
|
-
*/
|
|
305
|
-
readonly previous?: SceneLayout;
|
|
306
|
-
/** Edge or item ids solved without `previous` (an edge, or the edges holding the item; a column weighed anew). */
|
|
307
|
-
readonly fresh?: readonly string[];
|
|
308
|
-
}
|
|
309
|
-
/** A drop strip's depth inside the content while an edge is empty, px. */
|
|
310
|
-
declare const DEFAULT_STRIP = 24;
|
|
311
|
-
/** A column's gap hit: a band this many px around each gap's insertion line. */
|
|
312
|
-
declare const DEFAULT_HIT_BAND = 24;
|
|
313
|
-
/** A float's size when neither the item nor the call gives one, px. */
|
|
314
|
-
declare const DEFAULT_FLOAT_SIZE: Size;
|
|
1
|
+
import { S as Scene, g as SolveOptions, d as SceneLayout } from './targets-CZOYu8mG.js';
|
|
2
|
+
export { C as ColumnPlace, h as ColumnTemplate, D as DEFAULT_FLOAT_SIZE, i as DEFAULT_HIT_BAND, j as DEFAULT_STRIP, k as DockPlace, E as Edge, F as FloatAnchor, l as FloatPlace, K as Kind, O as Orient, P as Place, R as RailPlace, m as RailSpec, n as SIDES, o as SceneAfter, p as SceneEdgeLayout, q as SceneFloat, r as SceneItem, s as SceneItemLayout, t as SceneNote, c as SceneNoteCode, a as ScenePlace, u as SceneRailLayout, v as SceneRead, f as SceneTarget, w as SceneTargetOptions, b as Side, e as StoredScene, x as StoredSceneEdge, y as StoredSceneFloat, z as StoredSceneItem, A as ZONES, Z as Zone, B as ZoneAccepts, G as close, H as dockHome, I as floatAt, J as fold, L as homeFor, M as keep, N as lift, Q as moveTo, T as open, U as orient, V as raise, W as readScene, X as reservedRect, Y as resize, _ as stops, $ as storeScene, a0 as targets, a1 as use, a2 as zoneTakes, a3 as zonesTaking } from './targets-CZOYu8mG.js';
|
|
3
|
+
import './geometry-mL-GTRti.js';
|
|
4
|
+
import './target-D3PiLg44.js';
|
|
5
|
+
import './model-irGEua8T.js';
|
|
315
6
|
|
|
316
7
|
/**
|
|
317
8
|
* `solve(scene, { previous })`: the whole window's layout from one scene.
|
|
@@ -349,224 +40,4 @@ declare const DEFAULT_FLOAT_SIZE: Size;
|
|
|
349
40
|
|
|
350
41
|
declare function solve(given: Scene, options?: SolveOptions): SceneLayout;
|
|
351
42
|
|
|
352
|
-
|
|
353
|
-
* The scene's pure changes. Each returns a new scene and leaves the one it was given as it was; a change that can't
|
|
354
|
-
* apply (an unknown item or edge, a fixed item, a kind the edge or the float layer doesn't take) returns the scene
|
|
355
|
-
* given, the same object, so `after === before` says nothing changed.
|
|
356
|
-
*
|
|
357
|
-
* - `moveTo(scene, id, { edge, zone?, at })`: docks the item in that edge, before the `at`-th item of the zone (counting
|
|
358
|
-
* the zone's items without it, closed ones included), or at the zone's end. The zone becomes the item's `align`.
|
|
359
|
-
* `{ kind: "column", side, ring }` makes a new column from `scene.columns[side]` at that ring (`Infinity`: the side's
|
|
360
|
-
* inner end, "Move to › Dock left"); `{ kind: "rail", side, ring }` does the same with the item folded by hand, so it
|
|
361
|
-
* shows in the rail; `{ kind: "float", rect?, anchor? }` floats it. A dynamic column an item leaves empty is deleted
|
|
362
|
-
* and its side's rings are closed up.
|
|
363
|
-
* - `homeFor(scene, id, start)`: the place a start scene gives the item, for `moveTo`.
|
|
364
|
-
* - `floatAt(scene, id, rect?, orient?)`: floats it on top at `rect` (its size becomes `floatSize`); with no rect, at
|
|
365
|
-
* its `floatSize` (or the default size) anchored to the content's top-right corner.
|
|
366
|
-
* - `fold(scene, id, on)`: folded by hand starts it at its second form (`from: 1`); unfolding clears `from`.
|
|
367
|
-
* - `use(scene, id)`: the newest age. Under `previous` it reshapes nothing.
|
|
368
|
-
* - `keep(scene, id, on)`, `open(scene, id)`, `close(scene, id)`.
|
|
369
|
-
* - `raise(scene, id)`: a float to the top of the stack; no use, no reshape.
|
|
370
|
-
* - `orient(scene, id, orient)`: a float's axis.
|
|
371
|
-
* - `resize(scene, edge, size)`: the user's size across; a size that isn't a finite number clears it.
|
|
372
|
-
*/
|
|
373
|
-
|
|
374
|
-
/** Where a docked item goes: before the `at`-th item of `zone` (default the item's own zone) in `edge`. */
|
|
375
|
-
interface DockPlace {
|
|
376
|
-
readonly kind?: "gap";
|
|
377
|
-
readonly edge: string;
|
|
378
|
-
readonly zone?: Zone;
|
|
379
|
-
readonly at: number;
|
|
380
|
-
}
|
|
381
|
-
/** A new column on `side` at `ring` (the edges at that ring and inward move in one); `Infinity` is the side's inner end. */
|
|
382
|
-
interface ColumnPlace {
|
|
383
|
-
readonly kind: "column";
|
|
384
|
-
readonly side: "left" | "right";
|
|
385
|
-
readonly ring: number;
|
|
386
|
-
}
|
|
387
|
-
/** Docked folded: a new column at `ring` holding the item folded by hand, so it shows in the side's rail. */
|
|
388
|
-
interface RailPlace {
|
|
389
|
-
readonly kind: "rail";
|
|
390
|
-
readonly side: "left" | "right";
|
|
391
|
-
readonly ring: number;
|
|
392
|
-
}
|
|
393
|
-
/** Floating at `rect` (or, with none, at its last size anchored to the content). */
|
|
394
|
-
interface FloatPlace {
|
|
395
|
-
readonly kind: "float";
|
|
396
|
-
readonly rect?: Rect;
|
|
397
|
-
/** Following the content (only its size counts then). */
|
|
398
|
-
readonly anchor?: FloatAnchor;
|
|
399
|
-
}
|
|
400
|
-
type Place = DockPlace | ColumnPlace | RailPlace | FloatPlace;
|
|
401
|
-
/** The scene with the item out of every edge and every float (a dynamic column it leaves empty is deleted). */
|
|
402
|
-
declare function lift(scene: Scene, id: string): Scene;
|
|
403
|
-
declare function moveTo(scene: Scene, id: string, place: Place): Scene;
|
|
404
|
-
declare function floatAt(scene: Scene, id: string, at?: Rect, orient?: Orient): Scene;
|
|
405
|
-
declare function fold(scene: Scene, id: string, on: boolean): Scene;
|
|
406
|
-
declare function use(scene: Scene, id: string): Scene;
|
|
407
|
-
declare function keep(scene: Scene, id: string, on: boolean): Scene;
|
|
408
|
-
declare function open(scene: Scene, id: string): Scene;
|
|
409
|
-
declare function close(scene: Scene, id: string): Scene;
|
|
410
|
-
declare function raise(scene: Scene, id: string): Scene;
|
|
411
|
-
declare function orient(scene: Scene, id: string, to: Orient): Scene;
|
|
412
|
-
declare function resize(scene: Scene, edgeId: string, size: number): Scene;
|
|
413
|
-
/**
|
|
414
|
-
* The place `start` (a scene as it began: the host's start or reset scene) gives an item, for Dock, Put back and Reset
|
|
415
|
-
* position: its zone and place in the same edge (before the first item that followed it there and is still there), a
|
|
416
|
-
* new column at its ring when its column is gone, or its float rect (and anchor). Null when `start` places it nowhere
|
|
417
|
-
* or in an edge `scene` no longer has that isn't a column. `moveTo(scene, id, place)` puts it there.
|
|
418
|
-
*/
|
|
419
|
-
declare function homeFor(scene: Scene, id: string, start: Scene): Place | null;
|
|
420
|
-
|
|
421
|
-
/**
|
|
422
|
-
* The scene's stored form. `storeScene(scene)` gives plain JSON-safe data; `readScene(data, base)` reads it back over
|
|
423
|
-
* `base` (the host's scene as it starts: its item definitions, edges, kinds and stage) and never throws.
|
|
424
|
-
*
|
|
425
|
-
* ```ts
|
|
426
|
-
* interface StoredScene {
|
|
427
|
-
* v: 1;
|
|
428
|
-
* edges: { id: string; side: Side; ring: number; items: string[]; size?: number; column?: true }[];
|
|
429
|
-
* floats: { id: string; x: number; y: number; width: number; height: number; orient?: "row" | "column"; anchor?: FloatAnchor }[];
|
|
430
|
-
* items: Record<string, { used: number; kept?: true; from?: number; closed?: true; align?: "center" | "end"; floatSize?: { width: number; height: number } }>;
|
|
431
|
-
* }
|
|
432
|
-
* ```
|
|
433
|
-
*
|
|
434
|
-
* Nothing about kinds, forms or limits is stored: those are the host's (`base`). An edge is matched by its id: its
|
|
435
|
-
* side, ring and limits come from `base`, its order of items and its `size` from the store. Dynamic columns
|
|
436
|
-
* (`column: true`) are the store's: one `base` lacks is made from `base.columns[side]`, its ring is the stored one, and
|
|
437
|
-
* columns left empty are deleted, the rings closed up. No float has a pinned field: one an old store has is listed and
|
|
438
|
-
* ignored.
|
|
439
|
-
*
|
|
440
|
-
* Reading is lenient: anything but an object of version 1 gives `base` back with the reason in `error`. Inside one,
|
|
441
|
-
* whatever can't be used is dropped and listed in `dropped` (an unknown edge `edge:<id>`, an unknown or repeated item,
|
|
442
|
-
* an item an edge doesn't accept `edge:<edge>:<id>`, a fixed item in another edge than `base`'s `edge:<edge>:<id>`, a
|
|
443
|
-
* float of a kind that doesn't float `float:<id>`, a bad field `item:<id>:<field>`, an unknown top-level field
|
|
444
|
-
* `<field>`). A stored edge's order is kept exactly, fixed items where the store put them (in their own edge); a fixed
|
|
445
|
-
* item the store lacks goes back to its base place (trailing ones last). An item the store places nowhere goes where
|
|
446
|
-
* `base` has it, before a stored trailing run of fixed items.
|
|
447
|
-
* A float's rect is clamped into the stage on read.
|
|
448
|
-
*/
|
|
449
|
-
|
|
450
|
-
interface StoredSceneEdge {
|
|
451
|
-
readonly id: string;
|
|
452
|
-
readonly side: Side;
|
|
453
|
-
readonly ring: number;
|
|
454
|
-
readonly items: readonly string[];
|
|
455
|
-
readonly size?: number;
|
|
456
|
-
/** A dynamic column: read back from `base.columns[side]` even when `base` doesn't have it. */
|
|
457
|
-
readonly column?: true;
|
|
458
|
-
}
|
|
459
|
-
interface StoredSceneFloat {
|
|
460
|
-
readonly id: string;
|
|
461
|
-
readonly x: number;
|
|
462
|
-
readonly y: number;
|
|
463
|
-
readonly width: number;
|
|
464
|
-
readonly height: number;
|
|
465
|
-
readonly orient?: Orient;
|
|
466
|
-
readonly anchor?: FloatAnchor;
|
|
467
|
-
}
|
|
468
|
-
interface StoredSceneItem {
|
|
469
|
-
readonly used: number;
|
|
470
|
-
readonly kept?: true;
|
|
471
|
-
readonly from?: number;
|
|
472
|
-
readonly closed?: true;
|
|
473
|
-
readonly align?: "center" | "end";
|
|
474
|
-
readonly floatSize?: Size;
|
|
475
|
-
}
|
|
476
|
-
interface StoredScene {
|
|
477
|
-
readonly v: 1;
|
|
478
|
-
readonly edges: readonly StoredSceneEdge[];
|
|
479
|
-
readonly floats: readonly StoredSceneFloat[];
|
|
480
|
-
readonly items: Readonly<Record<string, StoredSceneItem>>;
|
|
481
|
-
}
|
|
482
|
-
interface SceneRead {
|
|
483
|
-
readonly scene: Scene;
|
|
484
|
-
/** What was left out, as listed in the module's docs. */
|
|
485
|
-
readonly dropped: readonly string[];
|
|
486
|
-
/** Set when nothing could be read: `scene` is `base`. */
|
|
487
|
-
readonly error?: string;
|
|
488
|
-
}
|
|
489
|
-
declare function storeScene(scene: Scene): StoredScene;
|
|
490
|
-
declare function readScene(data: unknown, base: Scene): SceneRead;
|
|
491
|
-
|
|
492
|
-
/**
|
|
493
|
-
* `targets(scene, dragged, { previous, endReach, floatSize })`: every drop target for one dragged item, in the shape
|
|
494
|
-
* `@n-uf/motion/drag` takes (`id`, `priority`, `hit`, `slot?`, `free?`). Each target's `after(point, grab)` is the scene
|
|
495
|
-
* a release there commits and its layout, `solve(after.scene, { previous })`: the host draws every item from that layout
|
|
496
|
-
* during the preview (C22), so the preview is the result by construction.
|
|
497
|
-
*
|
|
498
|
-
* - `gap:<edge>:<zone>:<at>` (priority 2): for every edge whose `accepts` lists the dragged item's kind (deny by
|
|
499
|
-
* default, C25), a target before the `at`-th item of each zone (start, center, end) and at each zone's end, so an
|
|
500
|
-
* empty center or end zone can be opened. Only where the item fits (C29): after the drop it isn't in the » menu, the
|
|
501
|
-
* edge doesn't overflow, nothing in the edge is newly `too-wide`, every fixed item of the edge keeps its form and its
|
|
502
|
-
* place (a growing one may give up its spare length), and its slot covers no chrome. The hit is the edge's stretch
|
|
503
|
-
* between the neighbouring gaps (split halfway between their insertion lines), across the larger of the edge's
|
|
504
|
-
* thickness before and after the drop, the first and last reaching `endReach` px past the edge's ends; it is cut
|
|
505
|
-
* clear of the edge's fixed items and the chrome rects (a gap whose line lies inside one has no target). `marker`
|
|
506
|
-
* is the insertion line after the drop, across the edge; `slot` the item's rect after the drop.
|
|
507
|
-
* - `strip:<edge>` (2): an empty edge that accepts the kind: a strip `Edge.strip` px (default 24) deep along its side,
|
|
508
|
-
* inside the content. `after` shows the edge holding the item.
|
|
509
|
-
* - `float:<id>` (3, free): when `floatKinds` lists the kind. The hit covers the whole plane; the landing is the float
|
|
510
|
-
* with the pointer holding it at `grab` (default its middle), in the stage and clear of the docked items, the bars
|
|
511
|
-
* and the chrome. Its size: `options.floatSize`, else its float's size, else the item's `floatSize`, else the default.
|
|
512
|
-
* - `column:<side>:<ring>` (2): a new column on each column line of a side whose `scene.columns[side]` takes the kind
|
|
513
|
-
* (outside the outermost open column, between two, inside the innermost; on a side with none, at the content's
|
|
514
|
-
* edge), `COLUMN_REACH` px each way, only where the new column shows open.
|
|
515
|
-
* - `rail:<side>:<ring>` (1): docking folded into a side's rail (its rail and its template take the kind), before each
|
|
516
|
-
* folded column's segments and after the last, or a strip `RAIL_EDGE` px deep at the side's outer edge when no rail
|
|
517
|
-
* shows.
|
|
518
|
-
* - `none:<i>` (1): over each `scene.blocked` rect. It takes the pointer, and a release there commits nothing.
|
|
519
|
-
* - `home:<id>` (1): over a docked item's own rect (or its » entry); a floating item has none, so a move inside its own
|
|
520
|
-
* rect is a float move. A release there commits nothing. A gap, column line or rail drop that
|
|
521
|
-
* would put the item back where it is (the gap beside it, its own column's line, its own side's rail) keeps its id but
|
|
522
|
-
* is a home too: place `home`, no slot, nothing committed.
|
|
523
|
-
*
|
|
524
|
-
* `stops(scene, id)` orders the same targets (no home, no none) for "Move to ›" and the arrow keys.
|
|
525
|
-
*
|
|
526
|
-
* A dropped item counts as just used (`use`). An unknown, fixed or closed item has no targets.
|
|
527
|
-
*/
|
|
528
|
-
|
|
529
|
-
type ScenePlace = {
|
|
530
|
-
readonly kind: "gap";
|
|
531
|
-
readonly edge: string;
|
|
532
|
-
readonly zone: Zone;
|
|
533
|
-
readonly at: number;
|
|
534
|
-
} | ColumnPlace | RailPlace | {
|
|
535
|
-
readonly kind: "float";
|
|
536
|
-
} | {
|
|
537
|
-
readonly kind: "home";
|
|
538
|
-
} | {
|
|
539
|
-
readonly kind: "none";
|
|
540
|
-
};
|
|
541
|
-
interface SceneAfter {
|
|
542
|
-
readonly scene: Scene;
|
|
543
|
-
readonly layout: SceneLayout;
|
|
544
|
-
}
|
|
545
|
-
interface SceneTarget extends Target {
|
|
546
|
-
/** The item dragged. */
|
|
547
|
-
readonly item: string;
|
|
548
|
-
readonly place: ScenePlace;
|
|
549
|
-
/** Gaps and strips: the line where the item's leading edge lands, zero thick, across the edge after the drop. */
|
|
550
|
-
readonly marker?: Rect;
|
|
551
|
-
/** The scene a release here commits and its layout. Only a float's depends on the pointer. */
|
|
552
|
-
after(point: Point, grab?: Point): SceneAfter;
|
|
553
|
-
}
|
|
554
|
-
interface SceneTargetOptions {
|
|
555
|
-
/** The layout before the drag: every `after` is solved with it, as the drop will be. */
|
|
556
|
-
readonly previous?: SceneLayout;
|
|
557
|
-
/** How far the first and last gaps of an edge reach past its ends, px (default 0). */
|
|
558
|
-
readonly endReach?: number;
|
|
559
|
-
/** The float's size for the float target. */
|
|
560
|
-
readonly floatSize?: Size;
|
|
561
|
-
/** As `solve`'s: edge or item ids solved without `previous`, in every `after` too. */
|
|
562
|
-
readonly fresh?: readonly string[];
|
|
563
|
-
}
|
|
564
|
-
declare function targets(scene: Scene, dragged: string, options?: SceneTargetOptions): SceneTarget[];
|
|
565
|
-
/**
|
|
566
|
-
* `stops(scene, id, options?)`: the places for "Move to ›" and the arrow keys, in reading order, from the same targets
|
|
567
|
-
* (`home` and `none` left out): the left side outer to inner, the top bars, the bottom bars, the right side inner to
|
|
568
|
-
* outer, floating last. Each stop is a target, so its `after` is the move.
|
|
569
|
-
*/
|
|
570
|
-
declare function stops(scene: Scene, dragged: string, options?: SceneTargetOptions): SceneTarget[];
|
|
571
|
-
|
|
572
|
-
export { type ColumnPlace, type ColumnTemplate, DEFAULT_FLOAT_SIZE, DEFAULT_HIT_BAND, DEFAULT_STRIP, type DockPlace, type Edge, type FloatAnchor, type FloatPlace, type Kind, type Orient, type Place, type RailPlace, type RailSpec, SIDES, type Scene, type SceneAfter, type SceneEdgeLayout, type SceneFloat, type SceneItem, type SceneItemLayout, type SceneLayout, type SceneNote, type SceneNoteCode, type ScenePlace, type SceneRailLayout, type SceneRead, type SceneTarget, type SceneTargetOptions, type Side, type SolveOptions, type StoredScene, type StoredSceneEdge, type StoredSceneFloat, type StoredSceneItem, ZONES, type Zone, close, floatAt, fold, homeFor, keep, lift, moveTo, open, orient, raise, readScene, resize, solve, stops, storeScene, targets, use };
|
|
43
|
+
export { Scene, SceneLayout, SolveOptions, solve };
|