@n-uf/placement 26.11.25 → 26.11.27
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 +163 -0
- package/README.md +152 -27
- package/dist/chunk-3GIUOVQH.js +2345 -0
- package/dist/chunk-3GIUOVQH.js.map +1 -0
- package/dist/{chunk-KGZCYLQN.js → chunk-IHU6IOZH.js} +126 -10
- package/dist/chunk-IHU6IOZH.js.map +1 -0
- package/dist/desk.d.ts +2 -2
- package/dist/float-fit-DRSOU_2y.d.ts +37 -0
- package/dist/index.d.ts +1 -1
- package/dist/{model-mm16NrSX.d.ts → model-Bd0oELzF.d.ts} +8 -0
- package/dist/{targets-CDR5Towj.d.ts → model-Cxg_ySz6.d.ts} +92 -104
- package/dist/panels.d.ts +3 -3
- package/dist/scene-cases.d.ts +45 -15
- package/dist/scene-cases.js +24 -35
- package/dist/scene-cases.js.map +1 -1
- package/dist/scene.d.ts +150 -6
- package/dist/scene.js +15 -2
- package/dist/stack.d.ts +52 -32
- package/dist/stack.js +4 -98
- package/dist/stack.js.map +1 -1
- package/dist/{target-C-HJjPcz.d.ts → target-CEVCfJd-.d.ts} +3 -1
- package/dist/{targets-CBpO_LEy.d.ts → targets-BPG7Kf02.d.ts} +1 -1
- package/dist/targets.d.ts +2 -2
- package/package.json +3 -2
- package/dist/chunk-KGZCYLQN.js.map +0 -1
- package/dist/chunk-SZKU7CRX.js +0 -1745
- package/dist/chunk-SZKU7CRX.js.map +0 -1
package/dist/scene.d.ts
CHANGED
|
@@ -1,9 +1,153 @@
|
|
|
1
|
-
import { S as Scene,
|
|
2
|
-
export { C as ColumnPlace,
|
|
3
|
-
import './geometry-CkZ6Fcfb.js';
|
|
4
|
-
|
|
5
|
-
import './
|
|
1
|
+
import { g as SceneItem, O as Orient, S as Scene, E as Edge, K as Kind, h as ZoneAccepts, Z as Zone, i as SolveOptions, b as SceneLayout, e as Side, j as SceneTargetOptions, k as SceneRefusal, d as SceneTarget } from './model-Cxg_ySz6.js';
|
|
2
|
+
export { C as ColumnPlace, l as ColumnTemplate, D as DEFAULT_FLOAT_SIZE, m as DEFAULT_HIT_BAND, n as DEFAULT_STRIP, o as DockPlace, F as FloatAnchor, p as FloatPlace, q as FloatResize, P as Place, R as RailPlace, r as RailSpec, s as ResizeEdges, t as ResizeLimit, u as SIDES, v as SceneAfter, w as SceneEdgeLayout, x as SceneFloat, y as SceneItemLayout, z as SceneNote, f as SceneNoteCode, a as ScenePlace, A as SceneRailLayout, B as SceneRead, c as StoredScene, G as StoredSceneEdge, H as StoredSceneFloat, I as StoredSceneItem, J as ZONES, L as close, M as dockHome, N as fitResize, Q as floatAt, T as fold, U as homeFor, V as keep, W as lift, X as moveTo, Y as open, _ as orient, $ as raise, a0 as readScene, a1 as resize, a2 as setSide, a3 as storeScene, a4 as use } from './model-Cxg_ySz6.js';
|
|
3
|
+
import { S as Size, R as Rect } from './geometry-CkZ6Fcfb.js';
|
|
4
|
+
export { F as FloatFit, f as fitFloat } from './float-fit-DRSOU_2y.js';
|
|
5
|
+
import './target-CEVCfJd-.js';
|
|
6
|
+
import './model-Bd0oELzF.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* What the scene's shapes (`./model`) tell on their own: which zones of an edge take a kind, an edge's axis, an item's
|
|
10
|
+
* zone and forms, whether a side edge is a toolbar bar, and how an item floats (its orient, size and form). Pure.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** Whether `edge` takes kind `kind` in `zone`: its `accepts`, narrowed by `zoneAccepts` when given (a zone not listed takes nothing). */
|
|
14
|
+
declare const zoneTakes: (edge: {
|
|
15
|
+
readonly accepts: readonly Kind[];
|
|
16
|
+
readonly zoneAccepts?: ZoneAccepts;
|
|
17
|
+
}, zone: Zone, kind: Kind) => boolean;
|
|
18
|
+
/** The zones of `edge` that take `kind`, in order. */
|
|
19
|
+
declare const zonesTaking: (edge: {
|
|
20
|
+
readonly accepts: readonly Kind[];
|
|
21
|
+
readonly zoneAccepts?: ZoneAccepts;
|
|
22
|
+
}, kind: Kind) => Zone[];
|
|
23
|
+
/**
|
|
24
|
+
* A left or right toolbar bar outside the inset (`isSideBar` with `outsideInset`). It lies outermost on its side,
|
|
25
|
+
* before the side's rail.
|
|
26
|
+
*/
|
|
27
|
+
declare function isOutsideSideBar(scene: Scene, e: Edge): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* A left or right toolbar bar: told from a column edge by its kinds, it takes something and nothing the side's columns
|
|
30
|
+
* or its rail take (`Scene.columns[side].accepts`, `Scene.rails[side].accepts`); an anchor takes nothing. A side with
|
|
31
|
+
* neither a column template nor a rail has nothing to tell them apart by, so no edge there is a bar.
|
|
32
|
+
*/
|
|
33
|
+
declare function isSideBar(scene: Scene, e: Edge): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The orient a float of `item` takes when it names none: its `floatOrient`, else the axis of its first form (the first
|
|
36
|
+
* of `forms.row` / `forms.column` it declares with any form), else column.
|
|
37
|
+
*/
|
|
38
|
+
declare const floatOrientOf: (item: SceneItem) => Orient;
|
|
39
|
+
/**
|
|
40
|
+
* A float's size when nothing gives one: the item's `floatSize`, else its first form's natural size along `orient`
|
|
41
|
+
* (default `floatOrientOf`), else `DEFAULT_FLOAT_SIZE` when that form grows (a panel's card has no natural float length)
|
|
42
|
+
* or the item has no form there.
|
|
43
|
+
*/
|
|
44
|
+
declare function floatSizeOf(item: SceneItem, orient?: Orient): Size;
|
|
6
45
|
|
|
7
46
|
declare function solve(given: Scene, options?: SolveOptions): SceneLayout;
|
|
8
47
|
|
|
9
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Generation, the real edges: each edge's zones and their extents, its slots (insertion lines, each with the drop it
|
|
50
|
+
* makes, settled), its reserved stretches and its band across, as the tiler reads them (`EdgeSpec`).
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* What a fixed item reserves in `l`: its drawn rect, or for a form that grows only its natural length, placed by its
|
|
55
|
+
* zone (from its start, from its end in the end zone, centred in the centre zone). No hit or slot ever lies there, so a
|
|
56
|
+
* host that draws "no drop" areas reads them from here.
|
|
57
|
+
*/
|
|
58
|
+
declare function reservedRect(scene: Scene, l: SceneLayout, id: string): Rect;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The one id scheme of the Scene's targets and refusals: every id `targets`, `refusals` and `stops` give is built here,
|
|
62
|
+
* and a host reads one back with `parseTargetId` instead of splitting strings.
|
|
63
|
+
*
|
|
64
|
+
* | Id | What it names | Priority |
|
|
65
|
+
* |---|---|---|
|
|
66
|
+
* | `gap:<edge>:<zone>:<at>` | a slot before the `at`-th item of an edge's zone | 2 |
|
|
67
|
+
* | `strip:<edge>:<zone>` | a zone's one slot on an edge with no members at all | 2 |
|
|
68
|
+
* | `column:<side>:<ring>` | a new column on a side's column line | 2 |
|
|
69
|
+
* | `rail:<side>:<ring>` | docking folded into a side's rail | 1 |
|
|
70
|
+
* | `side:<side>` | a fixed anchor's edge moved to the other side of its axis (`Edge.moves: "side"`) | 2 |
|
|
71
|
+
* | `home:<item>` | the item's own place (a release there puts it back) | 1 |
|
|
72
|
+
* | `float:<item>` | floating anywhere | 3 |
|
|
73
|
+
* | `none:<i>` | the `i`-th `blocked` rect | 1 |
|
|
74
|
+
* | `refuse:<edge>:<zone>[:<n>]` | a refusal; `:<n>` from a zone's second refused tile on, by where it lies | — |
|
|
75
|
+
*
|
|
76
|
+
* An edge id may hold `:` (the zone and the numbers are read from the right). The virtual edges a refusal can name are
|
|
77
|
+
* `column:<side>` (a side's column lines) and `rail:<side>` (its rail): `virtualEdgeId`.
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
type ColumnSide = "left" | "right";
|
|
81
|
+
/** A `ScenePlace`, as much of it as an id reads (this module imports no more of the scene, so `solve` may use it). */
|
|
82
|
+
type PlaceLike = {
|
|
83
|
+
readonly kind: "gap";
|
|
84
|
+
readonly edge: string;
|
|
85
|
+
readonly zone: Zone;
|
|
86
|
+
readonly at: number;
|
|
87
|
+
} | {
|
|
88
|
+
readonly kind: "column" | "rail";
|
|
89
|
+
readonly side: ColumnSide;
|
|
90
|
+
readonly ring: number;
|
|
91
|
+
} | {
|
|
92
|
+
readonly kind: "side";
|
|
93
|
+
readonly side: Side;
|
|
94
|
+
} | {
|
|
95
|
+
readonly kind: "float" | "home" | "none";
|
|
96
|
+
};
|
|
97
|
+
/** A target or refusal id, read. */
|
|
98
|
+
type TargetIdParts = {
|
|
99
|
+
readonly kind: "gap";
|
|
100
|
+
readonly edge: string;
|
|
101
|
+
readonly zone: Zone;
|
|
102
|
+
readonly at: number;
|
|
103
|
+
} | {
|
|
104
|
+
readonly kind: "strip";
|
|
105
|
+
readonly edge: string;
|
|
106
|
+
readonly zone: Zone;
|
|
107
|
+
} | {
|
|
108
|
+
readonly kind: "column" | "rail";
|
|
109
|
+
readonly side: ColumnSide;
|
|
110
|
+
readonly ring: number;
|
|
111
|
+
} | {
|
|
112
|
+
readonly kind: "side";
|
|
113
|
+
readonly side: Side;
|
|
114
|
+
} | {
|
|
115
|
+
readonly kind: "home" | "float";
|
|
116
|
+
readonly item: string;
|
|
117
|
+
} | {
|
|
118
|
+
readonly kind: "none";
|
|
119
|
+
readonly index: number;
|
|
120
|
+
} | {
|
|
121
|
+
readonly kind: "refuse";
|
|
122
|
+
readonly edge: string;
|
|
123
|
+
readonly zone: Zone;
|
|
124
|
+
readonly n: number;
|
|
125
|
+
};
|
|
126
|
+
/** The id of the target or refusal `parts` names. */
|
|
127
|
+
declare function targetId(parts: TargetIdParts): string;
|
|
128
|
+
/** What `id` names, or null when it is no id of the scheme. `targetId(parseTargetId(id)!) === id` for every id it reads. */
|
|
129
|
+
declare function parseTargetId(id: string): TargetIdParts | null;
|
|
130
|
+
/** The id of a side's virtual edge: its column lines (`column:<side>`) or its rail (`rail:<side>`), as a refusal names it. */
|
|
131
|
+
declare const virtualEdgeId: (kind: "column" | "rail", side: ColumnSide) => string;
|
|
132
|
+
/**
|
|
133
|
+
* The id `targets` gives the target at `place` for `item`, or null for a place with no fixed id (`none`). A gap's id is
|
|
134
|
+
* its `gap:` one; on an edge with no members its slot is `strip:<edge>:<zone>`.
|
|
135
|
+
*/
|
|
136
|
+
declare function placeTargetId(place: PlaceLike, item: string): string | null;
|
|
137
|
+
|
|
138
|
+
declare function targets(scene: Scene, dragged: string, options?: SceneTargetOptions): SceneTarget[];
|
|
139
|
+
/**
|
|
140
|
+
* `refusals(scene, dragged, options?)`: the places a drop of `dragged` is refused, so a host can say so at the pointer
|
|
141
|
+
* (a tint and "No room here") instead of showing a slot elsewhere: each slot the filter removed, over its own tile,
|
|
142
|
+
* `not-accepted` where the edge or zone doesn't take the kind, `no-room` where the drop wouldn't fit. A release over a
|
|
143
|
+
* refusal commits nothing: the item goes home.
|
|
144
|
+
*/
|
|
145
|
+
declare function refusals(scene: Scene, dragged: string, options?: SceneTargetOptions): SceneRefusal[];
|
|
146
|
+
/**
|
|
147
|
+
* `stops(scene, id, options?)`: the places for "Move to ›" and the arrow keys, in reading order, from the same targets
|
|
148
|
+
* (`home` and `none` left out): the left side outer to inner, the top bars, the bottom bars, the right side inner to
|
|
149
|
+
* outer, floating last. Each stop is a target, so its `after` is the move.
|
|
150
|
+
*/
|
|
151
|
+
declare function stops(scene: Scene, dragged: string, options?: SceneTargetOptions): SceneTarget[];
|
|
152
|
+
|
|
153
|
+
export { Edge, Kind, Orient, Scene, SceneItem, SceneLayout, SceneRefusal, SceneTarget, SceneTargetOptions, Side, SolveOptions, type TargetIdParts, Zone, ZoneAccepts, floatOrientOf, floatSizeOf, isOutsideSideBar, isSideBar, parseTargetId, placeTargetId, refusals, reservedRect, solve, stops, targetId, targets, virtualEdgeId, zoneTakes, zonesTaking };
|
package/dist/scene.js
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
ZONES,
|
|
7
7
|
close,
|
|
8
8
|
dockHome,
|
|
9
|
+
fitResize,
|
|
9
10
|
floatAt,
|
|
10
11
|
floatOrientOf,
|
|
11
12
|
floatSizeOf,
|
|
@@ -18,6 +19,8 @@ import {
|
|
|
18
19
|
moveTo,
|
|
19
20
|
open,
|
|
20
21
|
orient,
|
|
22
|
+
parseTargetId,
|
|
23
|
+
placeTargetId,
|
|
21
24
|
raise,
|
|
22
25
|
readScene,
|
|
23
26
|
refusals,
|
|
@@ -27,12 +30,16 @@ import {
|
|
|
27
30
|
solve,
|
|
28
31
|
stops,
|
|
29
32
|
storeScene,
|
|
33
|
+
targetId,
|
|
30
34
|
targets,
|
|
31
35
|
use,
|
|
36
|
+
virtualEdgeId,
|
|
32
37
|
zoneTakes,
|
|
33
38
|
zonesTaking
|
|
34
|
-
} from "./chunk-
|
|
35
|
-
import
|
|
39
|
+
} from "./chunk-3GIUOVQH.js";
|
|
40
|
+
import {
|
|
41
|
+
fitFloat
|
|
42
|
+
} from "./chunk-IHU6IOZH.js";
|
|
36
43
|
import "./chunk-WM5FJ3IS.js";
|
|
37
44
|
export {
|
|
38
45
|
DEFAULT_FLOAT_SIZE,
|
|
@@ -42,6 +49,8 @@ export {
|
|
|
42
49
|
ZONES,
|
|
43
50
|
close,
|
|
44
51
|
dockHome,
|
|
52
|
+
fitFloat,
|
|
53
|
+
fitResize,
|
|
45
54
|
floatAt,
|
|
46
55
|
floatOrientOf,
|
|
47
56
|
floatSizeOf,
|
|
@@ -54,6 +63,8 @@ export {
|
|
|
54
63
|
moveTo,
|
|
55
64
|
open,
|
|
56
65
|
orient,
|
|
66
|
+
parseTargetId,
|
|
67
|
+
placeTargetId,
|
|
57
68
|
raise,
|
|
58
69
|
readScene,
|
|
59
70
|
refusals,
|
|
@@ -63,8 +74,10 @@ export {
|
|
|
63
74
|
solve,
|
|
64
75
|
stops,
|
|
65
76
|
storeScene,
|
|
77
|
+
targetId,
|
|
66
78
|
targets,
|
|
67
79
|
use,
|
|
80
|
+
virtualEdgeId,
|
|
68
81
|
zoneTakes,
|
|
69
82
|
zonesTaking
|
|
70
83
|
};
|
package/dist/stack.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { d as StackInput, F as FitOptions, b as StackFit, e as StackItem } from './model-
|
|
2
|
-
export { C as CrossLimits, D as DEFAULT_MENU, f as DEFAULT_RAIL, G as GroupFormKind, M as MainSize, P as PanelFormKind, g as PlacedStackItem, h as StackAxis, a as StackForm, S as StackFormKind, i as StackMenu, c as StackNote, j as StackNoteCode, k as StackStep, W as WrapSpec, l as formCrossMin, m as formFitsCross, n as formMain, o as formSetsCross, w as withItem, p as wrapCross, q as wrapLines, r as wrapRows } from './model-
|
|
1
|
+
import { d as StackInput, F as FitOptions, b as StackFit, e as StackItem } from './model-Bd0oELzF.js';
|
|
2
|
+
export { C as CrossLimits, D as DEFAULT_MENU, f as DEFAULT_RAIL, G as GroupFormKind, M as MainSize, P as PanelFormKind, g as PlacedStackItem, h as StackAxis, a as StackForm, S as StackFormKind, i as StackMenu, c as StackNote, j as StackNoteCode, k as StackStep, W as WrapSpec, l as formCrossMin, m as formFitsCross, n as formMain, o as formSetsCross, w as withItem, p as wrapCross, q as wrapLines, r as wrapRows } from './model-Bd0oELzF.js';
|
|
3
3
|
import { R as Rect, P as Point, S as Size } from './geometry-CkZ6Fcfb.js';
|
|
4
|
-
import { T as Target } from './target-
|
|
4
|
+
import { T as Target } from './target-CEVCfJd-.js';
|
|
5
|
+
import { F as FloatFit$1 } from './float-fit-DRSOU_2y.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* `fitStack(input, options?)`. With `options.previous` (the fit the stack had before) the forms it chose are kept while
|
|
@@ -45,8 +46,13 @@ declare function fitStack(input: StackInput, options?: FitOptions): StackFit;
|
|
|
45
46
|
* inside it: the gaps before and after it stay, but the hit of a gap ends where the fixed item starts and the next one
|
|
46
47
|
* begins where it ends, so no hit overlaps it. Nor has one the stack doesn't accept (`input.accepts`); `options.allows` leaves out
|
|
47
48
|
* single gaps.
|
|
49
|
+
*
|
|
50
|
+
* Deprecated: drop targets belong to the window. `targets(scene, id)` from `@n-uf/placement/scene` gives every gap of
|
|
51
|
+
* every edge (and the column lines, the rail, the float), each with the layout a release there makes. These names
|
|
52
|
+
* stay until the next breaking release.
|
|
48
53
|
*/
|
|
49
54
|
|
|
55
|
+
/** @deprecated Use `SceneTargetOptions` and `targets(scene, id)` from `@n-uf/placement/scene`. */
|
|
50
56
|
interface StackTargetOptions {
|
|
51
57
|
/**
|
|
52
58
|
* 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
|
|
@@ -75,10 +81,12 @@ interface StackTargetOptions {
|
|
|
75
81
|
*/
|
|
76
82
|
readonly onlyFits?: boolean;
|
|
77
83
|
}
|
|
84
|
+
/** @deprecated Use `ScenePlace` from `@n-uf/placement/scene` (a gap is `{ kind: "gap", edge, zone, at }`). */
|
|
78
85
|
type StackPlace = {
|
|
79
86
|
readonly kind: "gap";
|
|
80
87
|
readonly at: number;
|
|
81
88
|
};
|
|
89
|
+
/** @deprecated Use `SceneTarget` and `targets(scene, id)` from `@n-uf/placement/scene`. */
|
|
82
90
|
interface StackTarget extends Target {
|
|
83
91
|
readonly priority: 2;
|
|
84
92
|
/** The item dragged. */
|
|
@@ -91,6 +99,7 @@ interface StackTarget extends Target {
|
|
|
91
99
|
/** Its fit: the preview and the drop are both its rect for the dragged item. */
|
|
92
100
|
readonly fit: StackFit;
|
|
93
101
|
}
|
|
102
|
+
/** @deprecated Use `targets(scene, id)` from `@n-uf/placement/scene`: every edge's gaps, each with the layout a release makes. */
|
|
94
103
|
declare function stackTargets(input: StackInput, dragged: StackItem, options?: StackTargetOptions): StackTarget[];
|
|
95
104
|
|
|
96
105
|
/**
|
|
@@ -109,7 +118,12 @@ declare function stackTargets(input: StackInput, dragged: StackItem, options?: S
|
|
|
109
118
|
* it; one the list lacks is older than all). An id listed twice counts at its last place: the newest use wins.
|
|
110
119
|
* - `forms`: the user's chosen form per item, the index of the largest form it may take (`StackItem.from`). 0, the
|
|
111
120
|
* first, is not stored.
|
|
121
|
+
*
|
|
122
|
+
* Deprecated: the stored form belongs to the window. `storeScene` / `readScene` from `@n-uf/placement/scene` keep every
|
|
123
|
+
* edge's order, kept, closed and chosen forms, the use order and the floats. These names stay until the next breaking
|
|
124
|
+
* release.
|
|
112
125
|
*/
|
|
126
|
+
/** @deprecated Use `Scene` and `storeScene` / `readScene` from `@n-uf/placement/scene`. */
|
|
113
127
|
interface StackState {
|
|
114
128
|
/** The items' order along the stack. */
|
|
115
129
|
readonly order: readonly string[];
|
|
@@ -122,6 +136,7 @@ interface StackState {
|
|
|
122
136
|
/** The form index the user chose per item (only those that chose one; absent means the first). */
|
|
123
137
|
readonly forms: Readonly<Record<string, number>>;
|
|
124
138
|
}
|
|
139
|
+
/** @deprecated Use `StoredScene` from `@n-uf/placement/scene`. */
|
|
125
140
|
interface StoredStack {
|
|
126
141
|
readonly v: 1;
|
|
127
142
|
readonly order: string[];
|
|
@@ -130,6 +145,7 @@ interface StoredStack {
|
|
|
130
145
|
readonly used: string[];
|
|
131
146
|
readonly forms: Record<string, number>;
|
|
132
147
|
}
|
|
148
|
+
/** @deprecated Use `SceneRead` from `@n-uf/placement/scene`. */
|
|
133
149
|
type StackRead = {
|
|
134
150
|
readonly ok: true;
|
|
135
151
|
readonly state: StackState;
|
|
@@ -138,9 +154,14 @@ type StackRead = {
|
|
|
138
154
|
readonly ok: false;
|
|
139
155
|
readonly error: string;
|
|
140
156
|
};
|
|
141
|
-
/**
|
|
157
|
+
/**
|
|
158
|
+
* A state with these items in this order, none kept or closed, used in that order, every form the first.
|
|
159
|
+
* @deprecated A Scene's edge holds its items in order (`Edge.items`); see `@n-uf/placement/scene`.
|
|
160
|
+
*/
|
|
142
161
|
declare const createStack: (order: readonly string[]) => StackState;
|
|
162
|
+
/** @deprecated Use `storeScene` from `@n-uf/placement/scene`. */
|
|
143
163
|
declare function storeStack(state: StackState): StoredStack;
|
|
164
|
+
/** @deprecated Use `readScene` from `@n-uf/placement/scene`. */
|
|
144
165
|
declare function readStack(data: unknown, known?: readonly string[]): StackRead;
|
|
145
166
|
|
|
146
167
|
/**
|
|
@@ -148,15 +169,11 @@ declare function readStack(data: unknown, known?: readonly string[]): StackRead;
|
|
|
148
169
|
* pages scrolling under it never move it. A float has no pinned flag: there is one kind of float, and it is in view
|
|
149
170
|
* space. Pure, like the rest of `./stack`.
|
|
150
171
|
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* y are merged and skipped, so no clear place is missed however many places lie between. Cost (measured in a test
|
|
157
|
-
* 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
|
|
158
|
-
* worst), 1,000 about 17 ms; a safety net stops the clear search after 3 million rect tests and says so in
|
|
159
|
-
* `searchCapped`; a stage with no clear place looks at the 2,048 nearest places for the least covered.
|
|
172
|
+
* Deprecated: floats belong to the window. The Scene fits them (`solve`, `Scene.floats`), offers the float target
|
|
173
|
+
* (`targets()`, `float:<id>`) and stores them (`storeScene` / `readScene`); `fitFloat` is exported by `./scene`. These
|
|
174
|
+
* names stay until the next breaking release.
|
|
175
|
+
*
|
|
176
|
+
* - `fitFloat(rect, stage, avoid)`: the rect a float gets, moved inside the stage and clear of the docked content.
|
|
160
177
|
* - `stackFloatTarget(input)`: a drop target in the shape `@n-uf/motion/drag` takes, free (no room is made for it),
|
|
161
178
|
* `kind` `"float"`, id `float:<item>`, whose `hit` covers the whole plane, so a pointer past the stage's edge still
|
|
162
179
|
* hits it (a float drop never cancels), at priority 3 so a docked stack's gaps win where they are. `make(point,
|
|
@@ -166,34 +183,31 @@ declare function readStack(data: unknown, known?: readonly string[]): StackRead;
|
|
|
166
183
|
* order (the last is on top). It writes no `pinned`; one an old store has is read, ignored and listed.
|
|
167
184
|
*/
|
|
168
185
|
|
|
169
|
-
/**
|
|
186
|
+
/**
|
|
187
|
+
* A float: the item's id and its rect in view space (the stage's px).
|
|
188
|
+
* @deprecated A Scene's floats are `SceneFloat`s (`Scene.floats`), from `@n-uf/placement/scene`.
|
|
189
|
+
*/
|
|
170
190
|
interface StackFloat {
|
|
171
191
|
readonly id: string;
|
|
172
192
|
readonly rect: Rect;
|
|
173
193
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
*/
|
|
186
|
-
readonly covers: readonly number[];
|
|
187
|
-
/** 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. */
|
|
188
|
-
readonly searchCapped: boolean;
|
|
189
|
-
}
|
|
190
|
-
declare function fitFloat(want: Rect, stage: Rect, avoid?: readonly Rect[]): FloatFit;
|
|
191
|
-
/** What a float drop makes: the same answer for the preview and for the release. */
|
|
194
|
+
/** @deprecated Use `FloatFit` from `@n-uf/placement/scene`. */
|
|
195
|
+
type FloatFit = FloatFit$1;
|
|
196
|
+
/**
|
|
197
|
+
* The rect a float gets: inside the stage, clear of the docked content where a clear place exists.
|
|
198
|
+
* @deprecated Use `fitFloat` from `@n-uf/placement/scene`; a Scene's floats are fitted by `solve`.
|
|
199
|
+
*/
|
|
200
|
+
declare const fitFloat: (want: Rect, stage: Rect, avoid?: readonly Rect[]) => FloatFit;
|
|
201
|
+
/**
|
|
202
|
+
* What a float drop makes: the same answer for the preview and for the release.
|
|
203
|
+
* @deprecated A Scene's float target is `float:<id>` from `targets()` in `@n-uf/placement/scene`.
|
|
204
|
+
*/
|
|
192
205
|
interface FloatDrop {
|
|
193
206
|
/** The float's rect in view space. */
|
|
194
207
|
readonly rect: Rect;
|
|
195
208
|
readonly fit: FloatFit;
|
|
196
209
|
}
|
|
210
|
+
/** @deprecated A Scene's float target is `float:<id>` from `targets()` in `@n-uf/placement/scene`. */
|
|
197
211
|
interface StackFloatTargetInput {
|
|
198
212
|
/** The item dragged. */
|
|
199
213
|
readonly id: string;
|
|
@@ -206,6 +220,7 @@ interface StackFloatTargetInput {
|
|
|
206
220
|
/** What the target is called (default "Float here"). */
|
|
207
221
|
readonly label?: string;
|
|
208
222
|
}
|
|
223
|
+
/** @deprecated A Scene's float target is `float:<id>` from `targets()` in `@n-uf/placement/scene`. */
|
|
209
224
|
interface FloatTarget extends Target {
|
|
210
225
|
/** What kind of place it is, for a consumer that holds targets of several kinds. */
|
|
211
226
|
readonly kind: "float";
|
|
@@ -219,7 +234,9 @@ interface FloatTarget extends Target {
|
|
|
219
234
|
*/
|
|
220
235
|
make(point: Point, grab?: Point): FloatDrop;
|
|
221
236
|
}
|
|
237
|
+
/** @deprecated Use `targets(scene, id)` from `@n-uf/placement/scene`: its `float:<id>` target (`floatKinds`). */
|
|
222
238
|
declare function stackFloatTarget(input: StackFloatTargetInput): FloatTarget;
|
|
239
|
+
/** @deprecated Use `storeScene` / `readScene` from `@n-uf/placement/scene`: a stored scene holds its floats. */
|
|
223
240
|
interface StoredFloats {
|
|
224
241
|
readonly v: 1;
|
|
225
242
|
readonly floats: {
|
|
@@ -230,6 +247,7 @@ interface StoredFloats {
|
|
|
230
247
|
height: number;
|
|
231
248
|
}[];
|
|
232
249
|
}
|
|
250
|
+
/** @deprecated Use `storeScene` / `readScene` from `@n-uf/placement/scene`: a stored scene holds its floats. */
|
|
233
251
|
type FloatsRead = {
|
|
234
252
|
readonly ok: true;
|
|
235
253
|
readonly floats: StackFloat[];
|
|
@@ -243,6 +261,7 @@ type FloatsRead = {
|
|
|
243
261
|
* What it can't read back is left out, silently: a float whose position isn't a finite number or whose size isn't over
|
|
244
262
|
* 0 (a zero-size float), and an earlier entry of a repeated id (the last readable entry of an id is the one on top,
|
|
245
263
|
* so it stays, at its own place in the order).
|
|
264
|
+
* @deprecated Use `storeScene` from `@n-uf/placement/scene`: a stored scene holds its floats.
|
|
246
265
|
*/
|
|
247
266
|
declare function storeFloats(floats: readonly StackFloat[]): StoredFloats;
|
|
248
267
|
/**
|
|
@@ -254,6 +273,7 @@ declare function storeFloats(floats: readonly StackFloat[]): StoredFloats;
|
|
|
254
273
|
* A `pinned` key (an old store's flag, whatever its value) is ignored: the float loads as a plain float, in view
|
|
255
274
|
* space as stored, and `pinned:<id>` is listed. A repeated id keeps its last readable entry (the list is in stacking
|
|
256
275
|
* order, the last on top); the earlier ones are dropped and listed as `float:<id>`.
|
|
276
|
+
* @deprecated Use `readScene` from `@n-uf/placement/scene`: a stored scene holds its floats.
|
|
257
277
|
*/
|
|
258
278
|
declare function readFloats(data: unknown, known?: readonly string[]): FloatsRead;
|
|
259
279
|
|
package/dist/stack.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
DEFAULT_MENU,
|
|
3
3
|
DEFAULT_RAIL,
|
|
4
4
|
createStack,
|
|
5
|
-
fitFloat,
|
|
5
|
+
fitFloat2 as fitFloat,
|
|
6
6
|
fitStack,
|
|
7
7
|
formCrossMin,
|
|
8
8
|
formFitsCross,
|
|
@@ -11,109 +11,15 @@ import {
|
|
|
11
11
|
readFloats,
|
|
12
12
|
readStack,
|
|
13
13
|
stackFloatTarget,
|
|
14
|
+
stackTargets,
|
|
14
15
|
storeFloats,
|
|
15
16
|
storeStack,
|
|
16
17
|
withItem,
|
|
17
18
|
wrapCross,
|
|
18
19
|
wrapLines,
|
|
19
20
|
wrapRows
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import
|
|
22
|
-
rect
|
|
23
|
-
} from "./chunk-WM5FJ3IS.js";
|
|
24
|
-
|
|
25
|
-
// src/stack/targets.ts
|
|
26
|
-
function bounds(input, fit, reach) {
|
|
27
|
-
const column = input.axis === "column";
|
|
28
|
-
const start = (r) => column ? r.y : r.x;
|
|
29
|
-
const size = (r) => column ? r.height : r.width;
|
|
30
|
-
const placed = new Map(fit.items.map((p) => [p.id, p]));
|
|
31
|
-
const c = [0];
|
|
32
|
-
let end = 0;
|
|
33
|
-
let cap = fit.length;
|
|
34
|
-
for (const it of input.items) {
|
|
35
|
-
const p = placed.get(it.id);
|
|
36
|
-
if (!p || p.kind === "menu") {
|
|
37
|
-
c.push(end, end);
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
const s = start(p.rect);
|
|
41
|
-
const mid = s + size(p.rect) / 2;
|
|
42
|
-
c.push(it.fixed ? s : mid, it.fixed ? s + size(p.rect) : mid);
|
|
43
|
-
end = s + size(p.rect);
|
|
44
|
-
if (it.fixed) cap = Math.max(cap, end);
|
|
45
|
-
}
|
|
46
|
-
c.push(fit.length);
|
|
47
|
-
for (let i = 1; i < c.length; i++) c[i] = Math.min(Math.max(c[i], c[i - 1]), cap);
|
|
48
|
-
c[0] = 0 - reach;
|
|
49
|
-
c[c.length - 1] = Math.max(fit.length + reach, c[c.length - 2]);
|
|
50
|
-
const from = [];
|
|
51
|
-
const to = [];
|
|
52
|
-
for (let k = 0; k <= input.items.length; k++) {
|
|
53
|
-
from.push(c[2 * k]);
|
|
54
|
-
to.push(c[2 * k + 1]);
|
|
55
|
-
}
|
|
56
|
-
return { from, to };
|
|
57
|
-
}
|
|
58
|
-
function fitsBeside(base, fit, dragged, fixed, axis, tooWideBefore) {
|
|
59
|
-
if (dragged.kind === "menu") return false;
|
|
60
|
-
for (const n of fit.notes) {
|
|
61
|
-
if (n.code === "overflow") return false;
|
|
62
|
-
if (n.code === "too-wide" && !tooWideBefore.has(n.id)) return false;
|
|
63
|
-
}
|
|
64
|
-
const main = (r) => axis === "column" ? r.height : r.width;
|
|
65
|
-
const across = (r) => axis === "column" ? r.width : r.height;
|
|
66
|
-
const was = new Map(base.items.map((p) => [p.id, p]));
|
|
67
|
-
for (const p of fit.items) {
|
|
68
|
-
const item = fixed.get(p.id);
|
|
69
|
-
const q = was.get(p.id);
|
|
70
|
-
if (!item || !q || p.kind === "menu" || q.kind === "menu") continue;
|
|
71
|
-
if (p.form !== q.form) return false;
|
|
72
|
-
if (main(p.rect) < formMain(item.forms[p.form], "min", fit.cross) - 1e-6) return false;
|
|
73
|
-
if (across(p.rect) < across(q.rect) - 1e-6) return false;
|
|
74
|
-
}
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
function stackTargets(input, dragged, options = {}) {
|
|
78
|
-
if (dragged.forms.length === 0) return [];
|
|
79
|
-
if (dragged.fixed) return [];
|
|
80
|
-
if (input.accepts && !input.accepts(dragged)) return [];
|
|
81
|
-
const rest = { ...input, items: input.items.filter((it) => it.id !== dragged.id) };
|
|
82
|
-
const fitOptions = options.previous ? { previous: options.previous } : {};
|
|
83
|
-
const base = fitStack(rest, fitOptions);
|
|
84
|
-
const reach = Math.max(0, Number.isFinite(options.endReach) ? options.endReach : 0);
|
|
85
|
-
const b = bounds(rest, base, reach);
|
|
86
|
-
const column = rest.axis === "column";
|
|
87
|
-
const fixedItems = new Map(rest.items.filter((it) => it.fixed).map((it) => [it.id, it]));
|
|
88
|
-
const tooWideBefore = new Set(base.notes.flatMap((n) => n.code === "too-wide" ? [n.id] : []));
|
|
89
|
-
const newest = rest.items.reduce((m, it) => Math.max(m, it.used), dragged.used) + 1;
|
|
90
|
-
const item = { ...dragged, used: newest };
|
|
91
|
-
const out = [];
|
|
92
|
-
for (let k = 0; k <= rest.items.length; k++) {
|
|
93
|
-
if (options.allows && !options.allows(dragged, k)) continue;
|
|
94
|
-
const solved = withItem(rest, item, k);
|
|
95
|
-
const fit = fitStack(solved, fitOptions);
|
|
96
|
-
const placed = fit.items.find((p) => p.id === dragged.id);
|
|
97
|
-
const slot = placed.rect;
|
|
98
|
-
if (options.onlyFits && !fitsBeside(base, fit, placed, fixedItems, rest.axis, tooWideBefore)) continue;
|
|
99
|
-
const from = b.from[k];
|
|
100
|
-
const to = b.to[k];
|
|
101
|
-
const across = Math.max(base.cross, fit.cross);
|
|
102
|
-
out.push({
|
|
103
|
-
id: `gap:${k}`,
|
|
104
|
-
priority: 2,
|
|
105
|
-
item: dragged.id,
|
|
106
|
-
place: { kind: "gap", at: k },
|
|
107
|
-
hit: column ? rect(0, from, across, to - from) : rect(from, 0, to - from, across),
|
|
108
|
-
slot,
|
|
109
|
-
// The line spans the stack's cross size (the drop's fit: the bar's height, the column's width).
|
|
110
|
-
marker: column ? rect(0, slot.y, fit.cross, 0) : rect(slot.x, 0, 0, fit.cross),
|
|
111
|
-
input: solved,
|
|
112
|
-
fit
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
return out;
|
|
116
|
-
}
|
|
21
|
+
} from "./chunk-IHU6IOZH.js";
|
|
22
|
+
import "./chunk-WM5FJ3IS.js";
|
|
117
23
|
export {
|
|
118
24
|
DEFAULT_MENU,
|
|
119
25
|
DEFAULT_RAIL,
|
package/dist/stack.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/stack/targets.ts"],"sourcesContent":["/**\n * The drop targets for dragging an item into a stack, in the shape @n-uf/motion/drag takes. `stackTargets(input,\n * dragged)` gives one target for every gap of the stack without the dragged item (an item of the input with its id\n * is lifted out first, so a reorder within a stack works): before each item and after the last, so an empty stack has\n * one. An item with no forms has no place of its own, but its gaps count.\n *\n * - `id` `gap:<k>`, priority 2, `place` `{ kind: \"gap\", at: k }` (k counts the input's items, the dragged one lifted\n * out, including any with no forms; it is not an index into `fit.items`, which leaves those out: look the dragged\n * item up there by its id, as `slot` already does).\n * - `hit`: the gap's zone along the axis, the stack split at its items' middles, so it covers the gap and the padding\n * 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\n * its own: the gaps next to it split the stretch where the stack's drawn items end; with every item in the menu only\n * the last gap, \"at the end\", has any length, and the others are a point at the start). Across, it is the larger of\n * the stack's current size and the size the drop gives it, so the pointer over the preview is over the target.\n * - `fit`: the full `fitStack` of the stack with the dragged item inserted at k, and `input` the stack that was\n * solved. The preview is `slot`, the dragged item's rect in `fit`: exactly the rect it gets after the drop, because\n * the drop is that same solve. `marker` is the line where its leading edge lands: a rect with no thickness across\n * the stack's cross size (the app draws it with one).\n *\n * The dragged item counts as just used: it is newer than every item in the stack, so the others give way before it.\n * A group lands in the form that fits; a panel that would set a wider column makes room by that solve too. A dragged\n * item with no forms has no targets, nor has a `fixed` one (it is never dragged). A fixed item in the stack has no slot\n * inside it: the gaps before and after it stay, but the hit of a gap ends where the fixed item starts and the next one\n * begins where it ends, so no hit overlaps it. Nor has one the stack doesn't accept (`input.accepts`); `options.allows` leaves out\n * single gaps.\n */\nimport { rect, type Rect } from \"../geometry\";\nimport type { Target } from \"../target\";\nimport { fitStack } from \"./layout\";\nimport { formMain, withItem, type FitOptions, type PlacedStackItem, type StackFit, type StackInput, type StackItem } from \"./model\";\n\nexport interface StackTargetOptions {\n /**\n * 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\n * pointer just outside the bar still drops at an end. The marker and the preview don't move.\n */\n readonly endReach?: number;\n /**\n * The stack's fit before the drag, as `fitStack`'s `previous`: the preview of every gap keeps the other items' forms while\n * they still fit, so it is the fit the drop makes when the app solves with the same `previous`.\n */\n readonly previous?: StackFit;\n /**\n * Whether a gap takes the dragged item (default: every gap does). Called with the dragged item and the gap's `at`\n * (`place.at`: the gap before the k-th item of the input with the dragged one lifted out). A gap it refuses has no\n * target; the others keep their ids, places and hits. The stack's own `accepts` is asked first, for the whole stack.\n */\n readonly allows?: (dragged: StackItem, at: number) => boolean;\n /**\n * Offer a gap only where the dragged item fits beside the others (default false: every gap is offered, the dragged item\n * landing in the » menu or the stack overflowing if need be). With it a gap has no target when its fit puts the dragged\n * item into the menu, has an `overflow` note, has a `too-wide` note that the stack without the dragged item didn't have,\n * or squeezes a `fixed` item: it is in another form, shorter along the stack than its form's `main.min`, or narrower\n * across than before the drop. A fixed item may shrink down to its `main.min` to make room, so the room for the others\n * is the length less the fixed items' minimum sizes. The gaps left keep their ids, hits and fits. With no room anywhere\n * the result is `[]`.\n */\n readonly onlyFits?: boolean;\n}\n\nexport type StackPlace = { readonly kind: \"gap\"; readonly at: number };\n\nexport interface StackTarget extends Target {\n readonly priority: 2;\n /** The item dragged. */\n readonly item: string;\n readonly place: StackPlace;\n /** The line where the dragged item's leading edge lands. */\n readonly marker: Rect;\n /** The stack with the dragged item inserted: what a drop here makes. */\n readonly input: StackInput;\n /** Its fit: the preview and the drop are both its rect for the dragged item. */\n readonly fit: StackFit;\n}\n\n/**\n * Where each gap's zone runs along the axis: gap k from `from[k]` to `to[k]`. The stack is split at its items' middles,\n * so gap k reaches from the middle of item k - 1 to the middle of item k; `from[0]` is `reach` before the start, `to[n]`\n * `reach` past the length. A fixed item has no middle to split at: the gap before it ends where it starts and the gap\n * after it begins where it ends, so its own area is in no gap's zone.\n */\nfunction bounds(input: StackInput, fit: StackFit, reach: number): { from: number[]; to: number[] } {\n const column = input.axis === \"column\";\n const start = (r: Rect): number => (column ? r.y : r.x);\n const size = (r: Rect): number => (column ? r.height : r.width);\n const placed = new Map(fit.items.map((p) => [p.id, p]));\n // from[0], to[0], from[1], to[1], …, from[n], to[n], in the order along the stack.\n const c = [0];\n // Where the drawn items have ended so far: an item in the menu (or with no forms) sits there.\n let end = 0;\n let cap = fit.length;\n for (const it of input.items) {\n const p = placed.get(it.id);\n if (!p || p.kind === \"menu\") {\n c.push(end, end);\n continue;\n }\n const s = start(p.rect);\n const mid = s + size(p.rect) / 2;\n c.push(it.fixed ? s : mid, it.fixed ? s + size(p.rect) : mid);\n end = s + size(p.rect);\n // A fixed item that runs past the stack (an overflowing one) keeps its own area out of the zones.\n if (it.fixed) cap = Math.max(cap, end);\n }\n c.push(fit.length);\n // Monotone, whatever the sizes did (a stack that overflows).\n for (let i = 1; i < c.length; i++) c[i] = Math.min(Math.max(c[i]!, c[i - 1]!), cap);\n // The first and last gaps reach past the stack's ends (the last never starts before a fixed item ends).\n c[0] = 0 - reach;\n c[c.length - 1] = Math.max(fit.length + reach, c[c.length - 2]!);\n const from: number[] = [];\n const to: number[] = [];\n for (let k = 0; k <= input.items.length; k++) {\n from.push(c[2 * k]!);\n to.push(c[2 * k + 1]!);\n }\n return { from, to };\n}\n\n/**\n * Whether a drop's fit leaves room for the dragged item: it isn't in the » menu, the stack doesn't `overflow`, no item\n * is `too-wide` that wasn't before (the dragged one, or one the drop made too wide), and no fixed item is squeezed: it\n * keeps its form, is drawn at least as long along the stack as its form's `main.min` and at least as wide across as before\n * the drop. A fixed item may shrink down to its `main.min` to make room (a title that grows gives back what it took).\n */\nfunction fitsBeside(\n base: StackFit,\n fit: StackFit,\n dragged: PlacedStackItem,\n fixed: ReadonlyMap<string, StackItem>,\n axis: StackInput[\"axis\"],\n tooWideBefore: ReadonlySet<string>,\n): boolean {\n if (dragged.kind === \"menu\") return false;\n for (const n of fit.notes) {\n if (n.code === \"overflow\") return false;\n if (n.code === \"too-wide\" && !tooWideBefore.has(n.id)) return false;\n }\n const main = (r: Rect): number => (axis === \"column\" ? r.height : r.width);\n const across = (r: Rect): number => (axis === \"column\" ? r.width : r.height);\n const was = new Map(base.items.map((p) => [p.id, p]));\n for (const p of fit.items) {\n const item = fixed.get(p.id);\n const q = was.get(p.id);\n if (!item || !q || p.kind === \"menu\" || q.kind === \"menu\") continue;\n if (p.form !== q.form) return false;\n // Its least length: `main.min`, or a wrap form's rows at the stack's cross size.\n if (main(p.rect) < formMain(item.forms[p.form]!, \"min\", fit.cross) - 1e-6) return false;\n if (across(p.rect) < across(q.rect) - 1e-6) return false;\n }\n return true;\n}\n\nexport function stackTargets(input: StackInput, dragged: StackItem, options: StackTargetOptions = {}): StackTarget[] {\n if (dragged.forms.length === 0) return [];\n if (dragged.fixed) return [];\n if (input.accepts && !input.accepts(dragged)) return [];\n const rest: StackInput = { ...input, items: input.items.filter((it) => it.id !== dragged.id) };\n const fitOptions: FitOptions = options.previous ? { previous: options.previous } : {};\n const base = fitStack(rest, fitOptions);\n const reach = Math.max(0, Number.isFinite(options.endReach) ? options.endReach! : 0);\n const b = bounds(rest, base, reach);\n const column = rest.axis === \"column\";\n const fixedItems = new Map(rest.items.filter((it) => it.fixed).map((it) => [it.id, it]));\n const tooWideBefore = new Set(base.notes.flatMap((n) => (n.code === \"too-wide\" ? [n.id] : [])));\n const newest = rest.items.reduce((m, it) => Math.max(m, it.used), dragged.used) + 1;\n const item: StackItem = { ...dragged, used: newest };\n const out: StackTarget[] = [];\n for (let k = 0; k <= rest.items.length; k++) {\n if (options.allows && !options.allows(dragged, k)) continue;\n const solved = withItem(rest, item, k);\n const fit = fitStack(solved, fitOptions);\n const placed = fit.items.find((p) => p.id === dragged.id)!;\n const slot = placed.rect;\n if (options.onlyFits && !fitsBeside(base, fit, placed, fixedItems, rest.axis, tooWideBefore)) continue;\n const from = b.from[k]!;\n const to = b.to[k]!;\n const across = Math.max(base.cross, fit.cross);\n out.push({\n id: `gap:${k}`,\n priority: 2,\n item: dragged.id,\n place: { kind: \"gap\", at: k },\n hit: column ? rect(0, from, across, to - from) : rect(from, 0, to - from, across),\n slot,\n // The line spans the stack's cross size (the drop's fit: the bar's height, the column's width).\n marker: column ? rect(0, slot.y, fit.cross, 0) : rect(slot.x, 0, 0, fit.cross),\n input: solved,\n fit,\n });\n }\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAiFA,SAAS,OAAO,OAAmB,KAAe,OAAiD;AACjG,QAAM,SAAS,MAAM,SAAS;AAC9B,QAAM,QAAQ,CAAC,MAAqB,SAAS,EAAE,IAAI,EAAE;AACrD,QAAM,OAAO,CAAC,MAAqB,SAAS,EAAE,SAAS,EAAE;AACzD,QAAM,SAAS,IAAI,IAAI,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AAEtD,QAAM,IAAI,CAAC,CAAC;AAEZ,MAAI,MAAM;AACV,MAAI,MAAM,IAAI;AACd,aAAW,MAAM,MAAM,OAAO;AAC5B,UAAM,IAAI,OAAO,IAAI,GAAG,EAAE;AAC1B,QAAI,CAAC,KAAK,EAAE,SAAS,QAAQ;AAC3B,QAAE,KAAK,KAAK,GAAG;AACf;AAAA,IACF;AACA,UAAM,IAAI,MAAM,EAAE,IAAI;A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"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -3,12 +3,14 @@ import { R as Rect } from './geometry-CkZ6Fcfb.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* A drop target in the shape @n-uf/motion/drag takes: an id, a priority (1 most precise: a rail or a tab strip;
|
|
5
5
|
* 2 a slot; 3 a broad area such as floating anywhere), the zone the pointer hits, and optionally where the item
|
|
6
|
-
* lands, a label and whether it lands freely (no room is made for it).
|
|
6
|
+
* lands, a label and whether it lands freely (no room is made for it). `hits`, when given, is the whole zone as several
|
|
7
|
+
* rects (a zone that isn't one rect), `hit` the largest of them: the pointer is in the zone when it is in any of them.
|
|
7
8
|
*/
|
|
8
9
|
interface Target {
|
|
9
10
|
readonly id: string;
|
|
10
11
|
readonly priority: 1 | 2 | 3;
|
|
11
12
|
readonly hit: Rect;
|
|
13
|
+
readonly hits?: readonly Rect[];
|
|
12
14
|
readonly slot?: Rect;
|
|
13
15
|
readonly label?: string;
|
|
14
16
|
readonly free?: boolean;
|
package/dist/targets.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { T as Target } from './target-
|
|
1
|
+
import { T as Target } from './target-CEVCfJd-.js';
|
|
2
2
|
import { R as Rect, P as Point, S as Size } from './geometry-CkZ6Fcfb.js';
|
|
3
3
|
import { D as DeskState, g as Layout, a as Construction, O as Options } from './constructions-DSEjvWMP.js';
|
|
4
4
|
import { Place, Arrangement, HostId, HostSpec, GroupSize } from './toolbar.js';
|
|
5
|
-
import { d as PanelTarget, s as PanelStopsOptions, r as PanelStop } from './targets-
|
|
5
|
+
import { d as PanelTarget, s as PanelStopsOptions, r as PanelStop } from './targets-BPG7Kf02.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Each desk construction's drop targets, as pure functions: from the state with the dragged item lifted out, a list
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n-uf/placement",
|
|
3
|
-
"version": "26.11.
|
|
3
|
+
"version": "26.11.27",
|
|
4
4
|
"description": "Where things go: desk docks, rails and palettes, panel columns, toolbar groups, and the drop targets for each. Pure state in, rects out. No DOM, no framework, no motion.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"layout",
|
|
@@ -79,7 +79,8 @@
|
|
|
79
79
|
"@types/node": "^25.5.0",
|
|
80
80
|
"tsup": "^8.5.1",
|
|
81
81
|
"typescript": "^6.0.3",
|
|
82
|
-
"vitest": "^4.1.12"
|
|
82
|
+
"vitest": "^4.1.12",
|
|
83
|
+
"@n-uf/motion": "26.11.27"
|
|
83
84
|
},
|
|
84
85
|
"scripts": {
|
|
85
86
|
"build": "tsup && node ./scripts/check-dist.mjs",
|