@n-uf/placement 26.11.12 → 26.11.14
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 +81 -0
- package/README.md +142 -14
- package/dist/stack.d.ts +203 -9
- package/dist/stack.js +377 -31
- package/dist/stack.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,87 @@
|
|
|
3
3
|
Versions are calendar versions, `YY.M.R` (year, month of the release, counter within the month), shared with
|
|
4
4
|
`@n-uf/motion`: both packages carry the same version, and a release bumps both.
|
|
5
5
|
|
|
6
|
+
## 26.11.14
|
|
7
|
+
|
|
8
|
+
- `@n-uf/placement/stack`, the cases a toolbar needs. Additive: no rename, no removed export, no new required field, and
|
|
9
|
+
an input that uses none of the new options gives the 26.11.13 fit, except in the three cases under "Changed
|
|
10
|
+
behaviour". A seeded sweep of 4,000 inputs against a verbatim copy of the 26.11.13 solver
|
|
11
|
+
(`test/stack-compat.test.ts`) checks it: every difference is one of those three.
|
|
12
|
+
- **Type change:** `GroupFormKind` and `StackFormKind` gain `"fold"` (a group's handle with its own » in line). An
|
|
13
|
+
exhaustive `switch` over `StackFormKind` needs a `fold` case; nothing else changes for typing. The solver treats it
|
|
14
|
+
as an ordinary form: it keeps its place and takes its own `main` length; `menu` stays the shared » entry.
|
|
15
|
+
- **Changed behaviour** (fixes the kits asked for):
|
|
16
|
+
1. A give-way step goes only to the first later form that shortens the stack (a smaller `main.min`, the shared »
|
|
17
|
+
entry counted when the form is `menu`). Forms of the same length or longer are skipped, with none shorter the item
|
|
18
|
+
stays and the stack may report `overflow`. Affected: an item whose next form is not shorter than its current one
|
|
19
|
+
(a `stacked` form as long as the `row`, a `fold` longer than the `icons` before it). Before, the item stepped
|
|
20
|
+
into it.
|
|
21
|
+
2. The menu: an item no longer goes into the menu alone when it is not longer than the » entry (a 24 px rail icon,
|
|
22
|
+
the default 28 px entry), unless that shortens the stack. Items stuck that way go in together, in give-way order,
|
|
23
|
+
as few as together shorten the stack (two 24 px icons for one 28 px entry); each one after that saves its whole
|
|
24
|
+
size. Affected: a stack whose items end in a `menu` form that are at most as long as the entry. Before, such a
|
|
25
|
+
step was taken whenever another item could still give way, so an item could end in the menu with room to spare, and
|
|
26
|
+
one that nothing else could help stayed out.
|
|
27
|
+
3. The pass limit: the old limit (as many passes as forms in all) could run out before a long run of cross-fit and
|
|
28
|
+
give-way steps ended and return a stack that doesn't fit with no `overflow` note. It now counts twice the forms.
|
|
29
|
+
Affected: such stacks only (none in the sweep).
|
|
30
|
+
- **Opt-in via `strictCross`** (new optional `StackInput.strictCross`, default false): forms are never drawn thinner than
|
|
31
|
+
their `cross.min` (default their `natural`), so a form that sets the cross size and has a `cross.min` over the limits'
|
|
32
|
+
`max` steps down (an open panel with `cross.min` 120 in a bar with `cross.max` 40 becomes a header), never into the
|
|
33
|
+
menu (`too-wide` if it is the last drawn form). Without it a form that sets the cross size is clamped to `max` whatever
|
|
34
|
+
its `cross.min`, as in 26.11.13 (where `cross.min` already existed; a test holds that).
|
|
35
|
+
- `fitStack(input, { previous })` (new optional second argument, `FitOptions`): keeps the forms of the previous fit while
|
|
36
|
+
they still fit, so a change of `used` ages alone (a press on a header) reshapes nothing. Ages decide only who gives
|
|
37
|
+
way anew (the length shrank, an item was added, a panel was opened). Growing never re-ranks: when the stack got
|
|
38
|
+
wider across (a wider limit: a group that stepped to its stacked form for a narrow column returns to its row, a header
|
|
39
|
+
folded to a rail by its `cross.min` to its header) the largest forms are tried again, as without it; when the forms
|
|
40
|
+
kept leave more spare length than before (`StackFit.need`, optional and always set by the solver, is the length the
|
|
41
|
+
chosen forms need) the fresh fit is taken only if it is a pure gain over them (no item further down, one further up),
|
|
42
|
+
otherwise the kept forms grow back in the reverse of give-way order while the stack fits (so a badge losing a digit
|
|
43
|
+
after a press moves nothing; an item goes back to the nearest larger form the stack fits with, even if that makes it
|
|
44
|
+
shorter, and items in the menu come out together when only all of them leaving fits). Results under `previous` depend
|
|
45
|
+
on history but are never worse: a shrink then a grow may end at a larger arrangement than a fresh solve. Growing back
|
|
46
|
+
is meant for stacks of up to about 50 items (60 small menu items take about 9 ms). An item whose
|
|
47
|
+
form at the kept index is of another kind starts over; one only
|
|
48
|
+
re-measured keeps its place (smaller: room that grows the kept forms; larger: it gives way from them). A lowered `cross.min`, or any
|
|
49
|
+
change of the forms' cross sizes, doesn't bring a form back under `previous`: solve once without it.
|
|
50
|
+
`stackTargets(…, { previous })` solves every gap the same way.
|
|
51
|
+
- `StackForm.rank` (default 0): the step taken is the one into the lowest-ranked form across all items; ties go
|
|
52
|
+
unkept before kept, then the item used longest ago, then the later in the stack.
|
|
53
|
+
- `StackInput.gap` (between neighbouring drawn items, the » entry included) and `StackInput.pad` (`{ start, end }`):
|
|
54
|
+
both count toward the length and every rect includes them.
|
|
55
|
+
- `stackTargets(input, dragged, { endReach })`: the first and last gaps' hits reach `endReach` px past the stack's
|
|
56
|
+
ends. The marker's cross size is the stack's. No pointer hysteresis here: that is `@n-uf/motion/drag` (its band,
|
|
57
|
+
and `placeOf` with `previous`). New export types `StackTargetOptions` and `FitOptions`.
|
|
58
|
+
|
|
59
|
+
## 26.11.13
|
|
60
|
+
|
|
61
|
+
- `@n-uf/placement/stack`, floats (new exports; `fitStack`, `stackTargets` and the stack's stored form are unchanged, and
|
|
62
|
+
so are `./panels`, `./dock` and `./desk`). A float is an item above the pages, in the stage's own px (view space), so
|
|
63
|
+
the pages scrolling under it never move it; it has no pinned flag.
|
|
64
|
+
- `fitFloat(rect, stage, avoid?)`: the float's rect moved (never resized) inside the stage, then beside the docked
|
|
65
|
+
items it would cover, at the nearest clear place; `FloatFit` has `rect`, `clamped` (also when a position that wasn't a
|
|
66
|
+
number was replaced), `snapped`, `covers` (indexes into `avoid` it still covers; empty whenever a clear place exists,
|
|
67
|
+
which it finds, and not empty only when the stage has none) and `searchCapped`. A float larger than the stage keeps
|
|
68
|
+
its top-left corner on the stage's. The x's are tried nearest first and, for each, the stretches of y the rects
|
|
69
|
+
block are merged and skipped. Measured in a test run on a laptop: about 100 `avoid` rects 0.1 ms, 300 a few ms even
|
|
70
|
+
when no place is clear (6 ms median, 15 ms worst), 1,000 about 17 ms. A safety net stops the clear search after 3
|
|
71
|
+
million rect tests and sets `searchCapped` (the place found may then not be the nearest, or a clear place may exist that was not found); with no clear place
|
|
72
|
+
the least covered among the 2,048 nearest places is used.
|
|
73
|
+
- `stackFloatTarget({ id, stage, size, avoid?, label? })`: a free, priority 3 drop target in the shape
|
|
74
|
+
`@n-uf/motion/drag` takes, `kind: "float"`, id `float:<id>` (so it can't collide with `./desk`'s `"float"`; the
|
|
75
|
+
toolbar `floatTarget` in `./targets` keeps its name), whose `hit` covers the whole plane, so a pointer past the
|
|
76
|
+
stage's edge still hits it. `make(point, grab?)` gives the float's rect (clamped, clear of the docked items) for the
|
|
77
|
+
preview and for the drop: one answer, so a drop past the edge lands clamped and never cancels. A gap's `hit`
|
|
78
|
+
thinner than 8 px (twice the intent's 4 px breakthrough) can't take over from it.
|
|
79
|
+
- `storeFloats` / `readFloats`: `{ v: 1, floats: [{ id, x, y, width, height }] }` in stacking order; never throws,
|
|
80
|
+
drops what it can't use and lists it in `dropped`. `storeFloats` leaves out a float with a zero size or a bad number,
|
|
81
|
+
and of a repeated id keeps the last readable entry (the one on top); `readFloats` does the same and words a bad
|
|
82
|
+
version as the stack's reader does. It writes no `pinned`; one an old store has is read and ignored (listed as
|
|
83
|
+
`pinned:<id>`), and the float loads as a plain float.
|
|
84
|
+
- Exports: `fitFloat`, `stackFloatTarget`, `storeFloats`, `readFloats` and the types `StackFloat`, `FloatFit`,
|
|
85
|
+
`FloatTarget`, `StackFloatTargetInput`, `FloatDrop`, `StoredFloats`, `FloatsRead`.
|
|
86
|
+
|
|
6
87
|
## 26.11.12
|
|
7
88
|
|
|
8
89
|
- New entry `@n-uf/placement/stack`: the items along one edge of a stage (a column or a row), each a panel or a control
|
package/README.md
CHANGED
|
@@ -41,9 +41,11 @@ without importing each other: a target list from `@n-uf/placement/targets` is ex
|
|
|
41
41
|
- **`/desk`**: desk presets (`docks`, `docksFull`, `dockTear`, `navigator`) as data on `/panels`: options and a
|
|
42
42
|
start state.
|
|
43
43
|
- **`/stack`**: the items along one edge, a column or a bar, each a panel or a control group with forms from largest to
|
|
44
|
-
smallest (open, header, rail icon, » menu; row, stacked, icons, » menu): one form and rect per item, giving
|
|
45
|
-
age, spare room to the panels that grow, a rail when nothing open
|
|
46
|
-
|
|
44
|
+
smallest (open, header, rail icon, » menu; row, stacked, icons, fold, » menu): one form and rect per item, giving
|
|
45
|
+
way by age and `rank`, only to a form that is shorter, spare room to the panels that grow, a rail when nothing open
|
|
46
|
+
sets the width, `gap` and `pad` in the length; a drop target for every gap, each with the exact solve a drop makes; a
|
|
47
|
+
stored form; and floats (an item above the pages, in the stage's own px, kept inside the stage and clear of the docked
|
|
48
|
+
items, with its drop target and stored form). Not tied to `/panels`.
|
|
47
49
|
|
|
48
50
|
Rendering stays in the app: it draws the rects, measures its groups, and feeds pointer samples to a drag intent.
|
|
49
51
|
|
|
@@ -410,16 +412,28 @@ now.
|
|
|
410
412
|
|
|
411
413
|
`@n-uf/placement/stack` lays out the items along one edge of a stage: a column (`axis: "column"`, a side region) or a
|
|
412
414
|
row (`"row"`, a bar). An item is a panel or a control group and declares its forms, largest first. Each form has a
|
|
413
|
-
structural `kind` (a panel's `open`, `header`, `rail`, `menu`; a group's `row`, `stacked`, `icons`, `menu`), a `main`
|
|
415
|
+
structural `kind` (a panel's `open`, `header`, `rail`, `menu`; a group's `row`, `stacked`, `icons`, `fold`, `menu`), a `main`
|
|
414
416
|
size along the stack (`min`, `natural`, `grows`) and a `cross` size. `fitStack(input)` picks one form per item and
|
|
415
417
|
places them; it is not tied to `./panels` columns, and nothing in it is a word.
|
|
416
418
|
|
|
417
419
|
- Every item starts in its largest form, or at `from` (an index into its forms; a panel the user folded by hand
|
|
418
|
-
starts at its header). While the smallest sizes don't fit the `length`,
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
default 28 px), while any item is in it
|
|
422
|
-
|
|
420
|
+
starts at its header). While the smallest sizes don't fit the `length`, one item takes a smaller form: the step into
|
|
421
|
+
the lowest `rank` (below), and among equals the item used longest ago (`used`: the smaller, the older), unkept
|
|
422
|
+
before `kept`, the later in the stack first on a tie. A `menu` form takes no room: the » entry does (`menu.main`,
|
|
423
|
+
default 28 px), while any item is in it.
|
|
424
|
+
- A give-way step goes only to a later form that shortens the stack: its `main.min` is smaller, counting the » entry
|
|
425
|
+
when the form is the menu and the gaps gained or lost. A form that doesn't (the same length, or longer) is skipped,
|
|
426
|
+
and an item with none stays; when no item can give more way and the stack is still too long, `overflow` says by how
|
|
427
|
+
much. The first item into the menu opens the » entry, so one shorter than the entry (a 24 px icon, a 28 px entry)
|
|
428
|
+
can't go in alone: the items stuck that way go in together, in give-way order, as few as shorten the stack (two
|
|
429
|
+
icons, 48 px, for one entry, 28 px); each item after that saves its whole size. If all of them together don't beat
|
|
430
|
+
the entry, they stay.
|
|
431
|
+
- `StackForm.rank` (default 0) orders the steps: the lowest rank of the form an item would step into goes first, then
|
|
432
|
+
unkept before kept, then the oldest, then the later in the stack. Give a pinned primary's last forms a higher rank
|
|
433
|
+
and every other group gives way before it does.
|
|
434
|
+
- `gap` is the space between neighbouring drawn items (the » entry is a neighbour) and `pad` (`{ start, end }`) the
|
|
435
|
+
space before the first item and after the last (or the » entry). Both count toward the length and every rect
|
|
436
|
+
includes them, so an app draws at the solver's rects and the preview is exact. A non-number or a negative one is 0.
|
|
423
437
|
- Spare length goes to the forms that `grows`, shared by their natural sizes. With none, the items keep their
|
|
424
438
|
natural sizes from the start of the stack.
|
|
425
439
|
- The stack's cross size is the widest `cross.natural` among the forms that set it (a panel's `open`, by default;
|
|
@@ -429,6 +443,28 @@ places them; it is not tied to `./panels` columns, and nothing in it is a word.
|
|
|
429
443
|
header a small `cross.min` and it stays in a column an open panel made narrower. Cross size never puts an item in
|
|
430
444
|
the menu: an item that is still too wide in its last drawn form keeps it, and `too-wide` says so (the app clips it).
|
|
431
445
|
Cross-fit and give-way repeat until nothing changes, because a panel folding can narrow the column.
|
|
446
|
+
- `strictCross: true` (off by default): a form is never drawn thinner than its `cross.min` (default its `natural`), so a
|
|
447
|
+
form that sets the cross size and has a `cross.min` over the limits' `max` steps down too: in a top bar with `cross.max`
|
|
448
|
+
40, an open panel with `cross.min` 120 becomes a header instead of being squeezed to 40. Without it such a form is
|
|
449
|
+
clamped to `max`, whatever its `cross.min`.
|
|
450
|
+
- `fitStack(input, { previous })` keeps the forms of the fit the stack had before, while they still fit: a change of
|
|
451
|
+
`used` ages alone (a press on a header) reshapes nothing. Ages decide only who gives way anew (the length shrank, an
|
|
452
|
+
item was added, or a panel opened: its `from` went down, so it starts over). Growing never re-ranks. When the stack got
|
|
453
|
+
wider across (a group's stacked form returns to its row, a header folded to a rail icon by its `cross.min` to its
|
|
454
|
+
header) the largest forms are tried again, as without `previous`. When the fit's `need` (the length its forms need) left
|
|
455
|
+
more spare length than before (the length grew, a gap or size shrank), the fresh fit is taken only if it is a pure gain
|
|
456
|
+
over the kept forms (no item further down, one further up); otherwise the kept forms grow back in the reverse of give-way
|
|
457
|
+
order (the item that gave way most recently first: highest rank, then `kept`, then the newest used) while the stack
|
|
458
|
+
still fits (an item goes back to the nearest larger form the stack fits with, even if that makes it shorter: the last
|
|
459
|
+
item out of the menu takes the » entry along, and items in the menu come out together when only all of them leaving
|
|
460
|
+
fits), so one px of room, or a badge losing a digit after a press, moves nothing. Results under `previous` depend on
|
|
461
|
+
history but are never worse: a shrink then a grow can end at a larger arrangement than a fresh solve. Growing back is
|
|
462
|
+
meant for stacks of up to about 50 items (60 small menu items take about 9 ms). An item whose form at the kept
|
|
463
|
+
index is of another kind starts over; one only re-measured (a badge changed a digit) keeps its place: a smaller form
|
|
464
|
+
frees room that grows the kept forms, a larger one gives way from them. After changing the forms' cross sizes (a lowered `cross.min`, say)
|
|
465
|
+
solve once without `previous`: that alone doesn't bring a form back. `previous` is the `StackFit` last returned; a
|
|
466
|
+
hand-built one with no `need` is no help. `stackTargets(…, { previous })` solves every gap's preview the same way, so it
|
|
467
|
+
equals the drop solved with the same `previous`.
|
|
432
468
|
- The solver has no open or closed state: it lays out the items it is given. An item with no forms is left out
|
|
433
469
|
(`no-forms`). Panel and group kinds may be mixed on one item; only `menu` and `open` mean anything to the solver.
|
|
434
470
|
|
|
@@ -466,12 +502,14 @@ more way and the stack is still too long; forms that don't end in a `menu` form
|
|
|
466
502
|
`stackTargets(input, dragged)` takes the stack (an item of it with the dragged id is lifted out first, so a reorder
|
|
467
503
|
within a stack works) and gives a target for every gap, before each item and after the last, in the shape
|
|
468
504
|
`@n-uf/motion/drag` takes: `id` `gap:<k>`, priority 2, `place` `{ kind: "gap", at: k }`, `hit` (the stack split at
|
|
469
|
-
its items' middles,
|
|
470
|
-
the last gap has any length) and `slot`, the rect the
|
|
505
|
+
its items' middles, so it covers the gap and padding between its neighbours, as wide across as the larger of the
|
|
506
|
+
stack and the drop's fit; with every item in the menu only the last gap has any length) and `slot`, the rect the
|
|
507
|
+
dragged item gets.
|
|
471
508
|
`fit` is the full solve with the item inserted at k (`input` the stack that was solved), so the preview is exactly the
|
|
472
|
-
rect after the drop; `marker` is the line where the item's leading edge lands (a rect with no thickness
|
|
473
|
-
|
|
474
|
-
fits.
|
|
509
|
+
rect after the drop; `marker` is the line where the item's leading edge lands (a rect with no thickness, the stack's
|
|
510
|
+
cross size long). The dragged item counts as just used, so the others give way before it, and a group lands in the form
|
|
511
|
+
that fits. A third argument, `{ endReach }`, makes the first gap's hit reach that many px before the stack's start
|
|
512
|
+
and the last gap's past its end (default 0), so a pointer just outside a bar still drops at an end.
|
|
475
513
|
|
|
476
514
|
```ts
|
|
477
515
|
const targets = stackTargets({ ...column, items: [panel("pages", 1), panel("findings", 2)] }, tools);
|
|
@@ -479,6 +517,31 @@ console.log(targets.map((t) => t.id), targets[1]!.slot, targets[1]!.fit.items[1]
|
|
|
479
517
|
// [ 'gap:0', 'gap:1', 'gap:2' ] { x: 0, y: 28, width: 240, height: 96 } row (Pages folds to its header to make room)
|
|
480
518
|
```
|
|
481
519
|
|
|
520
|
+
### A toolbar's rows
|
|
521
|
+
|
|
522
|
+
A top bar of control groups uses the same solver, with a few more things it can say:
|
|
523
|
+
|
|
524
|
+
- A group's `fold` form is its handle with its own » in line: it keeps its place in the stack and takes its own `main`
|
|
525
|
+
length. The shared » entry (`menu`) stays a later step: give the `menu` form a higher `rank` than the folds, or
|
|
526
|
+
an older group may go into it before a newer one folds.
|
|
527
|
+
- `rank`, `gap`, `pad`, `cross.max` and `endReach` as above. The kit draws every group at the solver's rect, so there
|
|
528
|
+
is nothing to measure and the drop preview is exact.
|
|
529
|
+
- Hysteresis is not here: a pointer that flickers between two gaps is `@n-uf/motion/drag`'s to calm (the intent's
|
|
530
|
+
band, and `placeOf` with `previous`), and `stackTargets` only says where the gaps are.
|
|
531
|
+
|
|
532
|
+
```ts
|
|
533
|
+
const group = (id: string, used: number): StackItem => ({ id, used, forms: [form("row", 100, 100, 26), form("fold", 36, 36, 26), form("menu", 0, 0, 0)] });
|
|
534
|
+
const bar = { axis: "row", length: 330, cross: { min: 36, max: 40 }, gap: 8, pad: { start: 12, end: 12 }, items: [group("views", 1), group("tools", 2), group("zoom", 3)] } as const;
|
|
535
|
+
|
|
536
|
+
const row = fitStack(bar);
|
|
537
|
+
console.log(row.items.map((p) => [p.kind, p.rect.x, p.rect.width]));
|
|
538
|
+
// [ [ 'fold', 12, 36 ], [ 'row', 56, 100 ], [ 'row', 164, 100 ] ] (three rows need 340: Views, the oldest, folds)
|
|
539
|
+
|
|
540
|
+
const gaps = stackTargets(bar, group("marks", 4), { endReach: 24 });
|
|
541
|
+
console.log(gaps.map((t) => [t.hit.x, t.hit.x + t.hit.width]));
|
|
542
|
+
// [ [ -24, 30 ], [ 30, 106 ], [ 106, 214 ], [ 214, 354 ] ] (split at the groups' middles; the ends reach 24 px past the bar)
|
|
543
|
+
```
|
|
544
|
+
|
|
482
545
|
`storeStack(state)` and `readStack(data, known?)` keep what the user chose, as `{ v: 1, … }`: `order`, `kept`,
|
|
483
546
|
`closed`, `used` (the use order, oldest first, so a reload restores who gives way first) and `forms` (the largest form
|
|
484
547
|
index each item may take, `StackItem.from`; stored only from 1). Reading never throws: anything but an object of
|
|
@@ -494,6 +557,71 @@ console.log(saved); // {"v":1,"order":["pages","tools"],"kept":["pages"],"closed
|
|
|
494
557
|
console.log(readStack(JSON.parse(saved), ["pages", "tools", "findings"]).ok, readStack({ v: 2 }).ok); // true false
|
|
495
558
|
```
|
|
496
559
|
|
|
560
|
+
### Floats
|
|
561
|
+
|
|
562
|
+
An item that isn't docked is a float. It lies above the pages in the stage's own px (view space), so the pages scrolling
|
|
563
|
+
under it never move it, and it has no pinned flag: there is one kind of float, `{ id, rect }`. `./stack` keeps floats
|
|
564
|
+
apart from the stacks (an item is in a stack's order or in the floats, the app's choice) and offers three parts, all
|
|
565
|
+
pure.
|
|
566
|
+
|
|
567
|
+
- `fitFloat(rect, stage, avoid?)` gives the rect a float gets: moved (never resized) to lie inside the `stage`, then
|
|
568
|
+
beside any of the `avoid` rects (the docked items' rects, and the » entries', in the same px) it would cover, at the
|
|
569
|
+
nearest place that is clear and inside the stage. A float larger than the stage keeps its top-left corner on the
|
|
570
|
+
stage's. A clear place is found whenever one exists, and then `covers` is empty. Only when the stage has no clear
|
|
571
|
+
place for it, the float stays where it covers the least (among the 2,048 nearest candidate places) and `covers` lists
|
|
572
|
+
the `avoid` indexes it still covers. `FloatFit`: `rect`, `clamped` (also true when a position that wasn't a number was
|
|
573
|
+
replaced), `snapped`, `covers`, `searchCapped`. Fit the floats again whenever the stacks or the stage change: a stack
|
|
574
|
+
that grew may lie under one.
|
|
575
|
+
Cost: the candidate x's (every edge of the stage and of an `avoid` rect) are tried nearest first; for each, the
|
|
576
|
+
stretches of y the rects block are merged and skipped, so no clear place is missed however many lie between, and the
|
|
577
|
+
search stops when no later x can be nearer. Measured in a test run on a laptop: about 100 `avoid` rects 0.1 ms, 300
|
|
578
|
+
a few ms even when no place is clear (6 ms median, 15 ms worst), 1,000 about 17 ms. A safety net stops the clear
|
|
579
|
+
search after 3 million rect tests (thousands of rects) and sets `searchCapped`: the place found may then not be the
|
|
580
|
+
nearest, or a clear place may exist that was not found. Keep `avoid` to the docked items, not to every pixel.
|
|
581
|
+
- `stackFloatTarget({ id, stage, size, avoid?, label? })` is a drop target in the shape `@n-uf/motion/drag` takes: `id`
|
|
582
|
+
`float:<id>` (not `"float"`, which `./desk` uses) and `kind: "float"`, priority 3 (a stack's gaps, priority 2, win
|
|
583
|
+
where they are), `free` (no room is made for it) and a `hit` that covers the whole plane, so a pointer past the
|
|
584
|
+
stage's edge, above, below or beside it, still hits it and a float drop never cancels. `make(point, grab?)` is the one
|
|
585
|
+
answer for the preview and the drop: the float's rect with the pointer at `point` holding it at `grab` (its offset in
|
|
586
|
+
the float; default the middle), run through `fitFloat`. Draw `make(...).rect` as the preview, and land the float on
|
|
587
|
+
the same call at the release. The intent lets a higher priority target take over from the current one only when the
|
|
588
|
+
pointer is `breakthrough` px (4) inside it, so a gap zone thinner than 8 px (2 × the breakthrough) along either axis
|
|
589
|
+
can never take over from the float target: give the gaps' `hit` at least that much room (the lab widens a thin
|
|
590
|
+
stack's zone across, and the first and last gap's past the stack's ends).
|
|
591
|
+
- `storeFloats(floats)` and `readFloats(data, known?)`: `{ v: 1, floats: [{ id, x, y, width, height }] }`, in stacking
|
|
592
|
+
order (the last is on top). It writes no `pinned`. `storeFloats` leaves out, silently, a float whose position isn't a
|
|
593
|
+
finite number or whose size isn't over 0, and keeps the last readable entry of a repeated id (the one on top, at its
|
|
594
|
+
own place in the order). Reading never throws: anything but an object of version 1 with a `floats` array is
|
|
595
|
+
`{ ok: false, error }` (the version worded as the stack's reader words it, a string quoted); inside one, a float that
|
|
596
|
+
isn't an object, has no string id, isn't one the consumer has (with `known`) or has a position that isn't a finite
|
|
597
|
+
number or a size that isn't over 0 is dropped and listed in `dropped` as `float:<id>`; of a repeated id the last
|
|
598
|
+
readable entry stays and the earlier ones are listed the same way; a field this version doesn't know is listed as
|
|
599
|
+
`"<field>"` (a float's own as `float:<id>:<field>`). A `pinned` key, which an older store may have, is read and
|
|
600
|
+
ignored: the float loads as a plain float, at the rect it was stored with, and `pinned:<id>` is listed.
|
|
601
|
+
|
|
602
|
+
```ts
|
|
603
|
+
import { fitFloat, readFloats, stackFloatTarget, storeFloats } from "@n-uf/placement/stack";
|
|
604
|
+
|
|
605
|
+
const stage = { x: 0, y: 0, width: 900, height: 500 };
|
|
606
|
+
const docked = [{ x: 0, y: 32, width: 240, height: 468 }]; // a column of docked items, in the stage's px
|
|
607
|
+
|
|
608
|
+
const fit = fitFloat({ x: 100, y: 200, width: 200, height: 150 }, stage, docked);
|
|
609
|
+
console.log(fit.rect, fit.snapped); // { x: 240, y: 200, width: 200, height: 150 } true
|
|
610
|
+
|
|
611
|
+
const target = stackFloatTarget({ id: "notes", stage, size: { width: 200, height: 150 }, avoid: docked });
|
|
612
|
+
const drop = target.make({ x: 500, y: -400 }, { x: 20, y: 10 }); // the pointer is above the stage
|
|
613
|
+
console.log(drop.rect, drop.fit.clamped); // { x: 480, y: 0, width: 200, height: 150 } true
|
|
614
|
+
|
|
615
|
+
console.log(JSON.stringify(storeFloats([{ id: "notes", rect: drop.rect }]))); // {"v":1,"floats":[{"id":"notes","x":480,"y":0,"width":200,"height":150}]}
|
|
616
|
+
const old = readFloats({ v: 1, floats: [{ id: "notes", x: 480, y: 0, width: 200, height: 150, pinned: true }] });
|
|
617
|
+
console.log(old.ok && old.dropped); // [ 'pinned:notes' ]
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
Freezing the layout needs nothing from the library: the freeze is the app's flag, and the app reads it once at the press.
|
|
621
|
+
A press on a grip while frozen (and Alt not held) never becomes a drag, so no target is built and nothing is dropped;
|
|
622
|
+
holding Alt shows the grips and everything works, a drag that began finishes. `fitStack` reads sizes, not what an item
|
|
623
|
+
says, so a count or a phase that leaves its forms' sizes alone moves no other item.
|
|
624
|
+
|
|
497
625
|
## Pane zones
|
|
498
626
|
|
|
499
627
|
`paneZone(rect, point, previous, options?)` says which of a pane's five zones a point is in: the centre rectangle
|
package/dist/stack.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as Rect } from './geometry-mL-GTRti.js';
|
|
1
|
+
import { R as Rect, P as Point, S as Size } from './geometry-mL-GTRti.js';
|
|
2
2
|
import { T as Target } from './target-D3PiLg44.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -14,8 +14,11 @@ import { T as Target } from './target-D3PiLg44.js';
|
|
|
14
14
|
type StackAxis = "column" | "row";
|
|
15
15
|
/** How a panel draws: open (header and body), a header only, a rail icon, or an entry in the » menu. */
|
|
16
16
|
type PanelFormKind = "open" | "header" | "rail" | "menu";
|
|
17
|
-
/**
|
|
18
|
-
|
|
17
|
+
/**
|
|
18
|
+
* How a control group draws: a row of words, the words stacked, icons only, `fold` (the group's handle with its own »,
|
|
19
|
+
* in line at its place and with its own length) or an entry in the shared » menu.
|
|
20
|
+
*/
|
|
21
|
+
type GroupFormKind = "row" | "stacked" | "icons" | "fold" | "menu";
|
|
19
22
|
type StackFormKind = PanelFormKind | GroupFormKind;
|
|
20
23
|
/** Along the stack: `min` is the least it can be drawn, `natural` what it asks for; `grows` takes spare length. */
|
|
21
24
|
interface MainSize {
|
|
@@ -42,6 +45,13 @@ interface StackForm {
|
|
|
42
45
|
* panel's `open`, false for everything else (a group never sets a column's width).
|
|
43
46
|
*/
|
|
44
47
|
readonly setsCross?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Give-way order (default 0). When the stack is too long, the step taken is the one into the lowest-ranked next
|
|
50
|
+
* form across all items (the form the item would take, not the one it leaves); ties go unkept before kept, then the
|
|
51
|
+
* item used longest ago, then the later in the stack. A pinned primary's last forms get a higher rank, so every
|
|
52
|
+
* other group collapses before it does.
|
|
53
|
+
*/
|
|
54
|
+
readonly rank?: number;
|
|
45
55
|
}
|
|
46
56
|
interface StackItem {
|
|
47
57
|
readonly id: string;
|
|
@@ -75,6 +85,23 @@ interface StackInput {
|
|
|
75
85
|
readonly menu?: {
|
|
76
86
|
readonly main: number;
|
|
77
87
|
};
|
|
88
|
+
/**
|
|
89
|
+
* The space between neighbouring drawn items, px (default 0). The » entry is a neighbour of the last drawn item. It
|
|
90
|
+
* counts toward the length and the rects include it, so an app draws at the solver's rects.
|
|
91
|
+
*/
|
|
92
|
+
readonly gap?: number;
|
|
93
|
+
/** Space before the first item and after the last (or after the » entry), px (default 0 each). Counts toward the length. */
|
|
94
|
+
readonly pad?: {
|
|
95
|
+
readonly start?: number;
|
|
96
|
+
readonly end?: number;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Strict cross sizes (default false): a form is never drawn thinner than its `cross.min` (default its `natural`), so a
|
|
100
|
+
* form that sets the cross size and has a `cross.min` over `cross.max` steps down to its next form (never into the
|
|
101
|
+
* 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
|
|
102
|
+
* only clamped to `cross.max`, as it always was.
|
|
103
|
+
*/
|
|
104
|
+
readonly strictCross?: boolean;
|
|
78
105
|
}
|
|
79
106
|
/** The width of a stack nothing open holds, px. */
|
|
80
107
|
declare const DEFAULT_RAIL = 30;
|
|
@@ -103,8 +130,9 @@ interface StackMenu {
|
|
|
103
130
|
* - `form-down`: an item took a smaller form than the one it started in (`from`, an index into its forms), by length
|
|
104
131
|
* or by cross size.
|
|
105
132
|
* - `to-menu`: an item is in the » menu.
|
|
106
|
-
* - `too-wide`: an item's form doesn't set the cross size and its `cross.min` is over the stack's
|
|
107
|
-
* puts an item in the menu, so it keeps its last drawn form
|
|
133
|
+
* - `too-wide`: an item's form doesn't set the cross size and its `cross.min` is over the stack's, or (with `strictCross`)
|
|
134
|
+
* 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
|
|
135
|
+
* and the app clips it.
|
|
108
136
|
* - `no-forms`: an item with no forms, left out of `items`.
|
|
109
137
|
* - `overflow`: no item can give more way and the stack is still `over` px too long (forms that don't end in a `menu`
|
|
110
138
|
* form can't give more; neither can a stack where going into the menu would only make it longer).
|
|
@@ -139,9 +167,48 @@ interface StackFit {
|
|
|
139
167
|
readonly menu: StackMenu | null;
|
|
140
168
|
/** `no-forms` first, then `form-down` per item in the order they gave way, `to-menu`, `too-wide`, and `overflow`. */
|
|
141
169
|
readonly notes: readonly StackNote[];
|
|
170
|
+
/**
|
|
171
|
+
* The length the chosen forms need at least: their smallest sizes, the » entry, the gaps and the padding. Over `length`
|
|
172
|
+
* only when the stack overflows. `fitStack`'s `previous` reads it to tell room coming back from a change of ages.
|
|
173
|
+
*/
|
|
174
|
+
readonly need?: number;
|
|
175
|
+
}
|
|
176
|
+
/** What `fitStack` and `stackTargets` take besides the input. */
|
|
177
|
+
interface FitOptions {
|
|
178
|
+
/**
|
|
179
|
+
* The fit the stack had before. While the forms it chose still fit, they are kept: a change of `used` ages alone (a press
|
|
180
|
+
* on a header) reshapes nothing. Ages decide only who gives way anew (the length shrank, an item was added or opened),
|
|
181
|
+
* and room that came back is used, but growing never re-ranks: the fresh fit is taken only if it is a pure gain (no
|
|
182
|
+
* item's form is further down, one is further up) or the stack got wider across; otherwise the kept forms grow back in
|
|
183
|
+
* the reverse of give-way order while the stack still fits (one px of room moves nothing; an item goes back to the
|
|
184
|
+
* nearest larger form the stack fits with, even when that makes the stack shorter: the last item out of the menu takes
|
|
185
|
+
* the » entry with it, and items in the menu come out together when only all of them leaving fits). Results under
|
|
186
|
+
* `previous` depend on history but are never worse: a shrink then a grow may end at a larger arrangement than a fresh
|
|
187
|
+
* solve of the same input. Growing back is meant for stacks of up to about 50 items (60 small menu items take about 9 ms;
|
|
188
|
+
* the cost grows with about the cube of the count). Items it doesn't know start
|
|
189
|
+
* from their largest form; an item whose `from` went down since (a panel opened), or whose form at the kept index is of
|
|
190
|
+
* another kind, starts over. A form that was only re-measured keeps its place: smaller, it frees room that grows the
|
|
191
|
+
* kept forms; larger, it gives way from the kept forms.
|
|
192
|
+
*
|
|
193
|
+
* Not covered: a lowered `cross.min` (or any change of the forms' cross sizes) doesn't bring a form back under
|
|
194
|
+
* `previous`. After changing cross sizes, solve once without `previous`.
|
|
195
|
+
*/
|
|
196
|
+
readonly previous?: StackFit;
|
|
142
197
|
}
|
|
143
198
|
|
|
144
|
-
|
|
199
|
+
/**
|
|
200
|
+
* `fitStack(input, options?)`. With `options.previous` (the fit the stack had before) the forms it chose are kept while
|
|
201
|
+
* they still fit: the solve starts from them instead of from every item's largest form, so a change of ages alone
|
|
202
|
+
* (a press on a header) reshapes nothing, and ages decide only who gives way anew when the length shrank or an item
|
|
203
|
+
* was added or opened. Room that came back is used, but growing never re-ranks. When the stack got wider across (a wider
|
|
204
|
+
* limit lets a panel open wider, and the forms that stepped down for the old width may come back) the fresh fit is
|
|
205
|
+
* taken. When the forms kept leave more spare length than they did (the length grew, a gap or a size shrank; `need` is
|
|
206
|
+
* what each fit says its forms need) the fresh fit is taken only if it is a pure gain over the kept one (no item's form
|
|
207
|
+
* is further down, at least one is further up); otherwise the kept forms grow back in the reverse of give-way order (the
|
|
208
|
+
* item that gave way most recently first, so the newest used, with rank and `kept` respected) while the stack still
|
|
209
|
+
* fits. A `previous` with no `need` (one an app built by hand) is no help and the fresh fit is returned.
|
|
210
|
+
*/
|
|
211
|
+
declare function fitStack(input: StackInput, options?: FitOptions): StackFit;
|
|
145
212
|
|
|
146
213
|
/**
|
|
147
214
|
* The drop targets for dragging an item into a stack, in the shape @n-uf/motion/drag takes. `stackTargets(input,
|
|
@@ -152,7 +219,8 @@ declare function fitStack(input: StackInput): StackFit;
|
|
|
152
219
|
* - `id` `gap:<k>`, priority 2, `place` `{ kind: "gap", at: k }` (k counts the input's items, the dragged one lifted
|
|
153
220
|
* out, including any with no forms; it is not an index into `fit.items`, which leaves those out: look the dragged
|
|
154
221
|
* item up there by its id, as `slot` already does).
|
|
155
|
-
* - `hit`: the gap's zone along the axis, the stack split at its items' middles
|
|
222
|
+
* - `hit`: the gap's zone along the axis, the stack split at its items' middles, so it covers the gap and the padding
|
|
223
|
+
* between its neighbours; the first and the last reach `options.endReach` px past the stack's ends (an item in the menu has no place of
|
|
156
224
|
* its own: the gaps next to it split the stretch where the stack's drawn items end; with every item in the menu only
|
|
157
225
|
* the last gap, "at the end", has any length, and the others are a point at the start). Across, it is the larger of
|
|
158
226
|
* the stack's current size and the size the drop gives it, so the pointer over the preview is over the target.
|
|
@@ -166,6 +234,18 @@ declare function fitStack(input: StackInput): StackFit;
|
|
|
166
234
|
* item with no forms has no targets.
|
|
167
235
|
*/
|
|
168
236
|
|
|
237
|
+
interface StackTargetOptions {
|
|
238
|
+
/**
|
|
239
|
+
* How far the first gap's hit reaches before the stack's start and the last gap's past its end, px (default 0), so a
|
|
240
|
+
* pointer just outside the bar still drops at an end. The marker and the preview don't move.
|
|
241
|
+
*/
|
|
242
|
+
readonly endReach?: number;
|
|
243
|
+
/**
|
|
244
|
+
* The stack's fit before the drag, as `fitStack`'s `previous`: the preview of every gap keeps the other items' forms while
|
|
245
|
+
* they still fit, so it is the fit the drop makes when the app solves with the same `previous`.
|
|
246
|
+
*/
|
|
247
|
+
readonly previous?: StackFit;
|
|
248
|
+
}
|
|
169
249
|
type StackPlace = {
|
|
170
250
|
readonly kind: "gap";
|
|
171
251
|
readonly at: number;
|
|
@@ -182,7 +262,7 @@ interface StackTarget extends Target {
|
|
|
182
262
|
/** Its fit: the preview and the drop are both its rect for the dragged item. */
|
|
183
263
|
readonly fit: StackFit;
|
|
184
264
|
}
|
|
185
|
-
declare function stackTargets(input: StackInput, dragged: StackItem): StackTarget[];
|
|
265
|
+
declare function stackTargets(input: StackInput, dragged: StackItem, options?: StackTargetOptions): StackTarget[];
|
|
186
266
|
|
|
187
267
|
/**
|
|
188
268
|
* The stack's stored form: `storeStack(state)` gives plain JSON-safe data (`{ v: 1, order, kept, closed, used, forms
|
|
@@ -234,4 +314,118 @@ declare const createStack: (order: readonly string[]) => StackState;
|
|
|
234
314
|
declare function storeStack(state: StackState): StoredStack;
|
|
235
315
|
declare function readStack(data: unknown, known?: readonly string[]): StackRead;
|
|
236
316
|
|
|
237
|
-
|
|
317
|
+
/**
|
|
318
|
+
* Floats for the edge stack: an item that isn't docked lies above the pages in the stage's own px (view space), so the
|
|
319
|
+
* pages scrolling under it never move it. A float has no pinned flag: there is one kind of float, and it is in view
|
|
320
|
+
* space. Pure, like the rest of `./stack`.
|
|
321
|
+
*
|
|
322
|
+
* - `fitFloat(rect, stage, avoid)`: the rect a float gets. It is moved (never resized) to lie inside the stage, then
|
|
323
|
+
* beside whatever docked content it would cover: the nearest place inside the stage that is clear of every `avoid`
|
|
324
|
+
* rect (the docked items' rects, in the same px). One larger than the stage keeps its top-left corner on the
|
|
325
|
+
* stage's; if no clear place exists the float stays where it covers the least and `covers` says which rects.
|
|
326
|
+
* A clear place is found whenever one exists: the x's are tried nearest first and, for each, the blocked stretches of
|
|
327
|
+
* y are merged and skipped, so no clear place is missed however many places lie between. Cost (measured in a test
|
|
328
|
+
* run on a laptop): about 100 docked rects 0.1 ms, 300 a few ms even when no place is clear (6 ms median, 15 ms
|
|
329
|
+
* worst), 1,000 about 17 ms; a safety net stops the clear search after 3 million rect tests and says so in
|
|
330
|
+
* `searchCapped`; a stage with no clear place looks at the 2,048 nearest places for the least covered.
|
|
331
|
+
* - `stackFloatTarget(input)`: a drop target in the shape `@n-uf/motion/drag` takes, free (no room is made for it),
|
|
332
|
+
* `kind` `"float"`, id `float:<item>`, whose `hit` covers the whole plane, so a pointer past the stage's edge still
|
|
333
|
+
* hits it (a float drop never cancels), at priority 3 so a docked stack's gaps win where they are. `make(point,
|
|
334
|
+
* grab)` is the one answer for the preview and the drop: the float's rect with the pointer holding it at `grab`,
|
|
335
|
+
* clamped and clear of the docked content.
|
|
336
|
+
* - `storeFloats` / `readFloats`: the stored form, `{ v: 1, floats: [{ id, x, y, width, height }] }`, in stacking
|
|
337
|
+
* order (the last is on top). It writes no `pinned`; one an old store has is read, ignored and listed.
|
|
338
|
+
*/
|
|
339
|
+
|
|
340
|
+
/** A float: the item's id and its rect in view space (the stage's px). */
|
|
341
|
+
interface StackFloat {
|
|
342
|
+
readonly id: string;
|
|
343
|
+
readonly rect: Rect;
|
|
344
|
+
}
|
|
345
|
+
interface FloatFit {
|
|
346
|
+
/** The float's rect: inside the stage and clear of the docked content where a clear place exists. */
|
|
347
|
+
readonly rect: Rect;
|
|
348
|
+
/** It was moved to lie inside the stage. */
|
|
349
|
+
readonly clamped: boolean;
|
|
350
|
+
/** It was moved beside the docked content it would have covered. */
|
|
351
|
+
readonly snapped: boolean;
|
|
352
|
+
/**
|
|
353
|
+
* Indexes into `avoid` of the rects it still covers. Empty whenever a clear place was found, which is whenever one
|
|
354
|
+
* exists (unless `searchCapped`); not empty only when the stage has no clear place for the float, and then it stays
|
|
355
|
+
* where it covers the least among the 2,048 nearest candidate places.
|
|
356
|
+
*/
|
|
357
|
+
readonly covers: readonly number[];
|
|
358
|
+
/** 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. */
|
|
359
|
+
readonly searchCapped: boolean;
|
|
360
|
+
}
|
|
361
|
+
declare function fitFloat(want: Rect, stage: Rect, avoid?: readonly Rect[]): FloatFit;
|
|
362
|
+
/** What a float drop makes: the same answer for the preview and for the release. */
|
|
363
|
+
interface FloatDrop {
|
|
364
|
+
/** The float's rect in view space. */
|
|
365
|
+
readonly rect: Rect;
|
|
366
|
+
readonly fit: FloatFit;
|
|
367
|
+
}
|
|
368
|
+
interface StackFloatTargetInput {
|
|
369
|
+
/** The item dragged. */
|
|
370
|
+
readonly id: string;
|
|
371
|
+
/** The stage, in view space. */
|
|
372
|
+
readonly stage: Rect;
|
|
373
|
+
/** The float's size: it is never resized. */
|
|
374
|
+
readonly size: Size;
|
|
375
|
+
/** The docked content to stay clear of: the docked items' rects (and the » entries'), in view space. */
|
|
376
|
+
readonly avoid?: readonly Rect[];
|
|
377
|
+
/** What the target is called (default "Float here"). */
|
|
378
|
+
readonly label?: string;
|
|
379
|
+
}
|
|
380
|
+
interface FloatTarget extends Target {
|
|
381
|
+
/** What kind of place it is, for a consumer that holds targets of several kinds. */
|
|
382
|
+
readonly kind: "float";
|
|
383
|
+
readonly priority: 3;
|
|
384
|
+
readonly free: true;
|
|
385
|
+
/** The item dragged. */
|
|
386
|
+
readonly item: string;
|
|
387
|
+
/**
|
|
388
|
+
* The drop with the pointer at `point` holding the float at `grab` (its offset from the float's top-left corner,
|
|
389
|
+
* default the middle): `rect` is the preview and the landing, clamped into the stage and clear of the docked content.
|
|
390
|
+
*/
|
|
391
|
+
make(point: Point, grab?: Point): FloatDrop;
|
|
392
|
+
}
|
|
393
|
+
declare function stackFloatTarget(input: StackFloatTargetInput): FloatTarget;
|
|
394
|
+
interface StoredFloats {
|
|
395
|
+
readonly v: 1;
|
|
396
|
+
readonly floats: {
|
|
397
|
+
id: string;
|
|
398
|
+
x: number;
|
|
399
|
+
y: number;
|
|
400
|
+
width: number;
|
|
401
|
+
height: number;
|
|
402
|
+
}[];
|
|
403
|
+
}
|
|
404
|
+
type FloatsRead = {
|
|
405
|
+
readonly ok: true;
|
|
406
|
+
readonly floats: StackFloat[];
|
|
407
|
+
readonly dropped: readonly string[];
|
|
408
|
+
} | {
|
|
409
|
+
readonly ok: false;
|
|
410
|
+
readonly error: string;
|
|
411
|
+
};
|
|
412
|
+
/**
|
|
413
|
+
* The floats as plain JSON-safe data, in the order given (the stacking order, the last on top). Never a `pinned`.
|
|
414
|
+
* 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
|
|
415
|
+
* 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,
|
|
416
|
+
* so it stays, at its own place in the order).
|
|
417
|
+
*/
|
|
418
|
+
declare function storeFloats(floats: readonly StackFloat[]): StoredFloats;
|
|
419
|
+
/**
|
|
420
|
+
* Reads parsed data back; never throws. Anything but an object of version 1 with a `floats` array is `{ ok: false,
|
|
421
|
+
* error }`. Inside one it is lenient: a float that isn't an object, has no string id, isn't one the
|
|
422
|
+
* consumer has (with `known`) or has a position or size that isn't a finite number (a size over 0) is dropped and
|
|
423
|
+
* listed in `dropped` as `float:<id>` (or `a <type> where a float goes`); a top-level field this version doesn't
|
|
424
|
+
* know is listed as `"<field>"`, and so is a float's own (`float:<id>:<field>`) while the float itself is kept.
|
|
425
|
+
* A `pinned` key (an old store's flag, whatever its value) is ignored: the float loads as a plain float, in view
|
|
426
|
+
* space as stored, and `pinned:<id>` is listed. A repeated id keeps its last readable entry (the list is in stacking
|
|
427
|
+
* order, the last on top); the earlier ones are dropped and listed as `float:<id>`.
|
|
428
|
+
*/
|
|
429
|
+
declare function readFloats(data: unknown, known?: readonly string[]): FloatsRead;
|
|
430
|
+
|
|
431
|
+
export { type CrossLimits, DEFAULT_MENU, DEFAULT_RAIL, type FitOptions, type FloatDrop, type FloatFit, type FloatTarget, type FloatsRead, type GroupFormKind, type MainSize, type PanelFormKind, type PlacedStackItem, type StackAxis, type StackFit, type StackFloat, type StackFloatTargetInput, type StackForm, type StackFormKind, type StackInput, type StackItem, type StackMenu, type StackNote, type StackNoteCode, type StackPlace, type StackRead, type StackState, type StackTarget, type StackTargetOptions, type StoredFloats, type StoredStack, createStack, fitFloat, fitStack, formSetsCross, readFloats, readStack, stackFloatTarget, stackTargets, storeFloats, storeStack, withItem };
|