@n-uf/docking 0.0.0-stage → 26.11.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +174 -0
- package/LICENSE +129 -0
- package/README.md +96 -2
- package/dist/chunk-4V35LE5X.js +4482 -0
- package/dist/chunk-4V35LE5X.js.map +1 -0
- package/dist/drag-yfr_Ng9Q.d.ts +1439 -0
- package/dist/index.d.ts +339 -0
- package/dist/index.js +135 -0
- package/dist/index.js.map +1 -0
- package/dist/testing.d.ts +817 -0
- package/dist/testing.js +3087 -0
- package/dist/testing.js.map +1 -0
- package/package.json +74 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# @n-uf/docking
|
|
2
|
+
|
|
3
|
+
Versions are calendar versions, `YY.M.R` (year, month of the release, counter within the month), shared with
|
|
4
|
+
`@n-uf/motion` and `@n-uf/placement`: the packages carry the same version, and a release bumps them all. Before this
|
|
5
|
+
package, the docking model shipped as `@n-uf/placement/scene` and `/scene/cases`; their history is in
|
|
6
|
+
[placement's CHANGELOG](https://github.com/n-uf/motion/blob/main/packages/placement/CHANGELOG.md).
|
|
7
|
+
|
|
8
|
+
Unreleased entries live in `changes/` until a release joins them.
|
|
9
|
+
|
|
10
|
+
## 26.11.55
|
|
11
|
+
|
|
12
|
+
- Added: **`DockItem.lengths`** (`{ column?, row? }`, px along the edge, per axis), the length a person asked an item to
|
|
13
|
+
have, read by the edge's stack in place of a growing form's natural, and the verbs on it: **`dividers(state, layout?)`**
|
|
14
|
+
(`DockDivider`), **`resizeBetween`**, **`resetBetween`** and **`resetLengths(state, edgeId)`**. `storeDockState` keeps
|
|
15
|
+
the length and `readDockState` reads it back (a bad entry is dropped as `item:<id>:lengths:<axis>`; a store without it
|
|
16
|
+
reads with none). Additive: a state that declares no length lays out exactly as before. A layout passed to a verb is used
|
|
17
|
+
only when it was solved from that very state object; otherwise the verb solves the state again.
|
|
18
|
+
- Fixed: **`resizeBetween` and `resetBetween` write `DockItem.lengths` for the pair only, in ask units** (not drawn px; with
|
|
19
|
+
room to spare a drawn size is the ask times the shared scale, or its least when that is more), as placement's do. A
|
|
20
|
+
bystander of a drag gets no length, so an item moved to another edge after a drag next to it is laid out as an item
|
|
21
|
+
nobody resized, not at a length inflated by the column's scale.
|
|
22
|
+
- Behavior change (from `@n-uf/placement`): **a length under its least now reads as a weight with room**: the item is drawn
|
|
23
|
+
at its least and the others share the rest by their asks. Short of room an ask under the least still reads as the least.
|
|
24
|
+
A length of 0 is no length: the item asks its natural, `storeDockState` does not write one (and drops the `lengths`
|
|
25
|
+
object when nothing is left), and `readDockState` drops a stored one like any bad entry (`item:<id>:lengths:<axis>`).
|
|
26
|
+
- Fixed: **a tile keeps its place among its own rail's tiles.** With `rails` declared, a column folded whole into its
|
|
27
|
+
side's rail drew its members as the rail's tiles, but the rail's stops lay only between folded columns, so a tile held
|
|
28
|
+
from it had no place among its own column's tiles (without `rails`, the same column drawn as a rail offered its gaps,
|
|
29
|
+
and `foldedColumnDrop`'s documented contract said it would). A held tile now also has that column's gaps
|
|
30
|
+
(`gap:<edge>:<zone>:<at>`, before each other tile and after the last, wherever it would stay a tile in the rail), over
|
|
31
|
+
its own column's run of tiles only: over the tiles of the rail's other columns, and past the last tile, the place is
|
|
32
|
+
the rail's, home for it, as before. A tile of another column, or the only tile of its column, gets the places it had.
|
|
33
|
+
A host tells a home by `place.kind === "home"`, never by its id (`rail:<side>:<ring>` stays a home's id). The lanes
|
|
34
|
+
agree: a column folded into a declared rail is a lane drawn where its run of tiles lies (the hull of its rail
|
|
35
|
+
segments), so its hit rect, its spots' stretches and its marks stop at the run, where they took the whole rail (a spot
|
|
36
|
+
over another column's tiles that reordered the held tile, a stretch past the rail's last tile); a column created folded
|
|
37
|
+
draws no mark beyond its own tile. `lanes()` and `targets()` decide the same at every point of a rail, except the pending new-column-line cases
|
|
38
|
+
(a new-column line over a rail where the lanes stay, in a narrow window and in one with a tray of toolbars, and with a
|
|
39
|
+
second column holding the held tile the lanes' new-column lane over the rail's first pixels where `targets()` floats),
|
|
40
|
+
which the sweep lists by name.
|
|
41
|
+
- Fixed: **a float pressed inside an empty lane's band no longer takes that lane when the drag starts** (the landing
|
|
42
|
+
model gives a float's lift, one with no `home` and no spot marked home, the lift zone a docked item has; `@n-uf/motion`'s change of the
|
|
43
|
+
same name). `dockDrag` has nothing new to pass: a float's drag has no home spot, and a host passes `home` only for a
|
|
44
|
+
docked item.
|
|
45
|
+
|
|
46
|
+
### One layout for the held frame and the commit (breaking; with `@n-uf/motion`'s held place)
|
|
47
|
+
|
|
48
|
+
- **New: `dockDrag(state, dragged, options)`** (`DockDrag`): `regions` (hit-testing, as seen), `after(held)`
|
|
49
|
+
(`DockAfter`: the `state` a release commits, its `layout` solved with the drag's one `previous`, the `landing`, every
|
|
50
|
+
lane's `marks` in that one layout as `DockLaneMark`s, and for a spot its lane's `spots`), `landingOf(held)`,
|
|
51
|
+
`spotsOf(spot)` and `guides(frame)` (`DockGuideFrame`, whose `guides` are `DockGuideRef`s `{ lane, held }`, →
|
|
52
|
+
`DockGuide[]`, rule B: a lane on screen less the would-land
|
|
53
|
+
landing; a lane the screen doesn't draw in the layout that creates it, giving way to whatever the screen draws: another
|
|
54
|
+
lane's marks, a drawn bar or rail, the landing; the Near lane's marks win). `DockHeld` (a held place) is
|
|
55
|
+
`{ kind: "spot", spot, point }` or `{ kind: "float", point }`. It fits `@n-uf/motion/drag`'s
|
|
56
|
+
`LandingGeometry` as it is; `./testing` adds `AssertGeometry`.
|
|
57
|
+
- **Removed (breaking): the held-frame path of `lanes()`.** `DockLaneOptions.spot` and `lanes(…, { spot })`,
|
|
58
|
+
`DockLane.entry` and `corners` (the prediction of an empty lane's marks): a held frame is `after(held)`, and a
|
|
59
|
+
frame's guides `guides(frame)`. `lanes()` gives the regions and each lane's marks as seen.
|
|
60
|
+
- **Changed.** A held lane's marks follow its edge as drawn in that held place's layout, corners included (decision 0002:
|
|
61
|
+
with both side rails holding a toolbar, a toolbar held in the empty top bar draws the bar full width, as the
|
|
62
|
+
commit does). A neighbor's giving way (a striped end) is judged in the layout drawn, not the lifted one. Held on a
|
|
63
|
+
sliding spot, the item is drawn where it lands and the room beside it is a box from 8 px; the bar keeps the corner
|
|
64
|
+
between two empty lanes in a held frame. `./testing`'s `LandingRule` takes `{ regions, landingOf, spotsOf, home?,
|
|
65
|
+
placeGuides? }`, and its host draws guides with `guides(frame)` and commits `after(release).state`.
|
|
66
|
+
- Added: **`DockDrag.shown(frame)`**, the layout a landing frame draws (`after(frame.held).layout` while the frame's room
|
|
67
|
+
is open, else the window at rest), and **`DockGuideFrame.room`** (required; the landing model's `LandingFrame.room`, so a
|
|
68
|
+
landing frame still fits; a host that builds its own frame passes it, and passes false where it draws no room for a spot).
|
|
69
|
+
- Fixed: **a float frame's guides are cut in the window as drawn.** `guides(frame)` took the screen from
|
|
70
|
+
`after(frame.held)`, so on a float frame (whose room is not open: the gap closes on release) the marks were cut in
|
|
71
|
+
the float's commit layout, the column closed up, while the host drew the window at rest. `guides(frame)` now cuts in
|
|
72
|
+
`shown(frame)`. A frame whose room is open (every spot frame the landing model gives) gives the guides it gave before.
|
|
73
|
+
|
|
74
|
+
### Docs only
|
|
75
|
+
|
|
76
|
+
- **The design page and the reference catch up with the code.** No behavior, type or export change. The draw rule is
|
|
77
|
+
stated once: a held frame draws `after(held).layout` while its room is open, and a float frame whose room is not
|
|
78
|
+
open, and the Outline mode, draw the window at rest (the gap closes on release). `dockDrag` is in the page's
|
|
79
|
+
paragraph, diagram, contents and SDK table, the landing model is named as the docking drag with `targets()` as the
|
|
80
|
+
list of places for menus, keys and the conformance pick, and a panel drag's marks are written up here. The
|
|
81
|
+
reference covers behavior, with the exported types as the contract, and adds entries for `Place` and its four kinds,
|
|
82
|
+
`SolveOptions`, `DockLaneOptions`, `EmptyLanes` and the stored types.
|
|
83
|
+
|
|
84
|
+
## 26.11.54
|
|
85
|
+
|
|
86
|
+
The first release. The window's docking model moves here from `@n-uf/placement/scene`, and its conformance rows from
|
|
87
|
+
`@n-uf/placement/scene/cases` to `@n-uf/docking/testing`. Behavior is unchanged: for the same input, `solve`,
|
|
88
|
+
`targets`, `refusals`, `stops` and `lanes` give the same answers as `@n-uf/placement/scene` at its last state (26.11.53
|
|
89
|
+
and the fix below, unreleased there), and a stored state reads back to the same layout: the one exception is in form,
|
|
90
|
+
not in frames (a stored `floatSize` becomes `floatSizes`, see Removed). Each edge is fitted by `@n-uf/placement/stack`,
|
|
91
|
+
now this package's one dependency.
|
|
92
|
+
|
|
93
|
+
Fixed since `./scene` 26.11.53, on its release line when the model moved:
|
|
94
|
+
- **`endReach` only adds** (fix). With any `endReach` and an empty bar across a compact rail's end, the rail's end
|
|
95
|
+
target shrank to the reach strip past the stage and its own end third was refused; with an inset (rail outside it, or
|
|
96
|
+
the bar inside it) the predicted `entry` also stopped at the two-thirds line. A reach strip cut off from its zone's own
|
|
97
|
+
room now takes no slot line and joins the zone's outermost slot (past a drawn bar it stops at the bar), and an edge's
|
|
98
|
+
reach never takes another edge's own span. A column's footer gap under an empty bar no longer vanishes with reach:
|
|
99
|
+
the panel bodies' cut places its line within the column's drawn ends, as the tiler does. The start side and both rails
|
|
100
|
+
alike. New tests `rail-end-reach` and `end-reach-targets`; the pinned marks fixture's rail and bar boxes now run to
|
|
101
|
+
the edge's end.
|
|
102
|
+
|
|
103
|
+
Host notes: install `@n-uf/docking`, change the imports, and apply the renames below (each a rename only, with the
|
|
104
|
+
same shape and meaning). A stored state from `storeScene` reads back with `readDockState` unchanged (the stored form
|
|
105
|
+
and its version are the same), but for one field: a stored `floatSize` reads back as `floatSizes` (see `floatSize`
|
|
106
|
+
under Removed). `@n-uf/docking/testing`'s types name `@n-uf/motion/drag`'s: `@n-uf/motion` is an optional peer
|
|
107
|
+
dependency, needed only by a suite that runs the landing rows. The edge-id error's prefix is `docking:` (it was
|
|
108
|
+
`placement:`): a host that matches the message changes the prefix.
|
|
109
|
+
|
|
110
|
+
Entries:
|
|
111
|
+
- `@n-uf/placement/scene` → `@n-uf/docking`.
|
|
112
|
+
- `@n-uf/placement/scene/cases` → `@n-uf/docking/testing`.
|
|
113
|
+
|
|
114
|
+
The model's types:
|
|
115
|
+
- `Scene` → `DockState`; `Edge` → `DockEdge`; `SceneItem` → `DockItem`; `SceneFloat` → `DockFloat`.
|
|
116
|
+
- `SceneChrome` → `KeepClear`, and the dock state's field `chrome` → `keepClear` (same rects, same `for` scope).
|
|
117
|
+
- The fields 26.11.52 added keep their names on the renamed types: `DockItem.pushable`, `DockItem.floatSizes`,
|
|
118
|
+
`DockItemLayout.axis`.
|
|
119
|
+
- Added: **`DockItemLayout.tiers`**, the chosen form's `StackForm.tiers` (`@n-uf/placement/stack`'s `controlLadder`
|
|
120
|
+
sets them), beside `hidden`: each shown control's tier by id, so a host draws each control at `tiers[id]` without
|
|
121
|
+
knowing the ladder's order. Absent for a hand-written form, a `fold`, a `menu` and a » menu entry.
|
|
122
|
+
- Removed: **`SceneItem.floatSize`**, deprecated in 26.11.52. `floatSize` → `floatSizes[orient]`: declare the size for
|
|
123
|
+
the orient the item floats in (both orients where it floats either way). A state stored with it still reads, and
|
|
124
|
+
`storeDockState` writes `floatSizes` only. `readDockState` takes a stored `floatSize` as:
|
|
125
|
+
- on an item the store docks: `floatSizes[floatOrientOf(item)]`, unless the store sizes that orient itself, so the
|
|
126
|
+
user's float size survives the upgrade for the next float-out (a float target, `floatAt` with no rect);
|
|
127
|
+
- on a float whose store gives `floatSizes`: the size for the orient the float is in, unless the store sizes it;
|
|
128
|
+
- on a float whose store gives no `floatSizes`: nothing. It is dropped (`item:<id>:floatSize`), and the float stays
|
|
129
|
+
framed at its stored rect, as before (a size there would replace that frame).
|
|
130
|
+
- `floatSizeOf(item, orient?)` and `floatSizesOf(item)` lose the orient the old size was set in (it was the legacy
|
|
131
|
+
`floatSize`'s).
|
|
132
|
+
- `SceneLayout` → `DockLayout`; `SceneItemLayout` → `DockItemLayout`; `SceneEdgeLayout` → `DockEdgeLayout`;
|
|
133
|
+
`SceneRailLayout` → `DockRailLayout`; `SceneNote` → `DockNote`; `SceneNoteCode` → `DockNoteCode`.
|
|
134
|
+
- `StoredScene` → `StoredDockState`; `StoredSceneEdge` → `StoredDockStateEdge`; `StoredSceneFloat` →
|
|
135
|
+
`StoredDockStateFloat`; `StoredSceneItem` → `StoredDockStateItem`; `SceneRead` → `DockStateRead`, whose field
|
|
136
|
+
`scene` is now `state` (`readDockState(data, base).state`).
|
|
137
|
+
|
|
138
|
+
Targets and lanes:
|
|
139
|
+
- `SceneTarget` → `DockDrop`; `SceneTargetOptions` → `DockDropOptions`; `ScenePlace` → `DropPlace`; `SceneAfter` →
|
|
140
|
+
`DropResult`, whose field `scene` is now `state` (`after(point, grab).state`).
|
|
141
|
+
- `SceneRefusal` → `DockRefusal`; `SceneRefusalTarget` → `DockRefusalTarget`.
|
|
142
|
+
- `Regions` → `DockRegions`; `Lane` → `DockLane`; `LaneSpot` → `DockSpot`; `LaneMark` → `DockMark`; `LaneOptions` →
|
|
143
|
+
`DockLaneOptions`. `LaneRefusal` and `LaneSlide` keep their names, and `Lane.entry` and `Lane.corners` are
|
|
144
|
+
`DockLane.entry` and `DockLane.corners`.
|
|
145
|
+
|
|
146
|
+
Functions:
|
|
147
|
+
- `storeScene` → `storeDockState`; `readScene` → `readDockState`.
|
|
148
|
+
- `fold` → `foldItem`; `use` → `markUsed`; `keep` → `keepItem`; `open` → `openItem`; `close` → `closeItem`; `lift` →
|
|
149
|
+
`liftItem`; `raise` → `raiseFloat`; `orient` → `orientFloat`.
|
|
150
|
+
- `resize` splits in two by what it resizes: `resize(state, edgeId, size)` → `resizeEdge(state, edgeId, size)`, and
|
|
151
|
+
`resize(state, floatId, rect, moving?)` → `resizeFloat(state, floatId, rect, moving?)`.
|
|
152
|
+
- `fitFloat` and `FloatFit` are no longer re-exported here: import them from `@n-uf/placement/stack`.
|
|
153
|
+
|
|
154
|
+
What the model reads of a form: the form flags `body`, `folded` and `compact` from `@n-uf/placement/stack` (each
|
|
155
|
+
defaulting from the kind as before: `open`; `header` and `fold`; `icons`). A host that sets none sees no change.
|
|
156
|
+
|
|
157
|
+
Testing (`@n-uf/docking/testing`):
|
|
158
|
+
- `createSceneHost` → `createReferenceHost`; `SceneHost` → `ReferenceHost`, whose method `scene()` is now `state()`;
|
|
159
|
+
`SceneHostOptions` → `ReferenceHostOptions`.
|
|
160
|
+
- `resizeStep(state, start, layout, gesture)` returns `{ state, start }` (its field `scene` is now `state`).
|
|
161
|
+
- `mapScene` → `mapState`; `winScene` → `winState`.
|
|
162
|
+
- A row's field `scene` → `state` (`CaseRow.state`, `LandingCase.state`), and a `CaseHost` loads with
|
|
163
|
+
`load(state, settings)`. `CaseRequires.railDrop`'s one value is now `"state"`.
|
|
164
|
+
- Added: **`AssertLanding<R>`**, a type that compiles only while `R` fits `@n-uf/motion/drag`'s `LandingRegions`
|
|
165
|
+
(`AssertLanding<DockRegions>` is checked in this package's tests). A type only: no runtime import of motion.
|
|
166
|
+
- Removed: `pickTarget`, the deprecated default pick. Pass `@n-uf/motion/drag`'s `targetAt` as `pick` (the reference
|
|
167
|
+
host's default stays the same rule).
|
|
168
|
+
- Kept as 26.11.52 shipped them: the hand rule (`handBound`, `HAND_TRAIL`, `HAND_TRAIL_BEFORE_HOP`, `HAND_MARGIN`,
|
|
169
|
+
`HAND_FAST`, a row's `moving.hand`) and the Near guides' rule (`nearGuideIssues`, `NEAR_REACH`, a row's
|
|
170
|
+
`moving.nearGuides` and `moving.guideSwitches`, `end.pending`, `end.landing`, `LandingCaseFrame.pending`).
|
|
171
|
+
- Removed: the release bookkeeping, `LANES_SINCE`, `GRAB_SINCE`, `GRIP_SINCE`, `ROOM_SINCE`, `STEP_SINCE`, `NEAR_SINCE`, `LAST_WITHOUT_LANES`,
|
|
172
|
+
`LANES_DEADLINE` and `lanesRatchet`, with `CaseRequires.lanes` (`requires.lanes.since`), `LandingCaseHost.version`
|
|
173
|
+
and `createLandingHost`'s `version` option. Every landing row runs on every host: drop the ratchet from your suite
|
|
174
|
+
and assert that no row fails.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# PolyForm Perimeter License 1.0.1
|
|
2
|
+
|
|
3
|
+
Required Notice: Copyright (c) 2026 n-uf
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
In order to get any license under these terms, you must agree
|
|
8
|
+
to them as both strict obligations and conditions to all
|
|
9
|
+
your licenses.
|
|
10
|
+
|
|
11
|
+
## Copyright License
|
|
12
|
+
|
|
13
|
+
The licensor grants you a copyright license for the
|
|
14
|
+
software to do everything you might do with the software
|
|
15
|
+
that would otherwise infringe the licensor's copyright
|
|
16
|
+
in it for any permitted purpose. However, you may
|
|
17
|
+
only distribute the software according to [Distribution
|
|
18
|
+
License](#distribution-license) and make changes or new works
|
|
19
|
+
based on the software according to [Changes and New Works
|
|
20
|
+
License](#changes-and-new-works-license).
|
|
21
|
+
|
|
22
|
+
## Distribution License
|
|
23
|
+
|
|
24
|
+
The licensor grants you an additional copyright license
|
|
25
|
+
to distribute copies of the software. Your license
|
|
26
|
+
to distribute covers distributing the software with
|
|
27
|
+
changes and new works permitted by [Changes and New Works
|
|
28
|
+
License](#changes-and-new-works-license).
|
|
29
|
+
|
|
30
|
+
## Notices
|
|
31
|
+
|
|
32
|
+
You must ensure that anyone who gets a copy of any part of
|
|
33
|
+
the software from you also gets a copy of these terms or the
|
|
34
|
+
URL for them above, as well as copies of any plain-text lines
|
|
35
|
+
beginning with `Required Notice:` that the licensor provided
|
|
36
|
+
with the software. For example:
|
|
37
|
+
|
|
38
|
+
> Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
|
|
39
|
+
|
|
40
|
+
## Changes and New Works License
|
|
41
|
+
|
|
42
|
+
The licensor grants you an additional copyright license to
|
|
43
|
+
make changes and new works based on the software for any
|
|
44
|
+
permitted purpose.
|
|
45
|
+
|
|
46
|
+
## Patent License
|
|
47
|
+
|
|
48
|
+
The licensor grants you a patent license for the software that
|
|
49
|
+
covers patent claims the licensor can license, or becomes able
|
|
50
|
+
to license, that you would infringe by using the software.
|
|
51
|
+
|
|
52
|
+
## Noncompete
|
|
53
|
+
|
|
54
|
+
Any purpose is a permitted purpose, except for providing to
|
|
55
|
+
others any product that competes with the software.
|
|
56
|
+
|
|
57
|
+
## Competition
|
|
58
|
+
|
|
59
|
+
If you use this software to market a product as a substitute
|
|
60
|
+
for the functionality or value of the software, it competes
|
|
61
|
+
with the software. A product may compete regardless how it
|
|
62
|
+
is designed or deployed. For example, a product may compete
|
|
63
|
+
even if it provides its functionality via any kind of interface
|
|
64
|
+
(including services, libraries or plug-ins), even if it is
|
|
65
|
+
ported to a different platform or programming language, and
|
|
66
|
+
even if it is provided free of charge.
|
|
67
|
+
|
|
68
|
+
## Fair Use
|
|
69
|
+
|
|
70
|
+
You may have "fair use" rights for the software under the
|
|
71
|
+
law. These terms do not limit them.
|
|
72
|
+
|
|
73
|
+
## No Other Rights
|
|
74
|
+
|
|
75
|
+
These terms do not allow you to sublicense or transfer any of
|
|
76
|
+
your licenses to anyone else, or prevent the licensor from
|
|
77
|
+
granting licenses to anyone else. These terms do not imply
|
|
78
|
+
any other licenses.
|
|
79
|
+
|
|
80
|
+
## Patent Defense
|
|
81
|
+
|
|
82
|
+
If you make any written claim that the software infringes or
|
|
83
|
+
contributes to infringement of any patent, your patent license
|
|
84
|
+
for the software granted under these terms ends immediately. If
|
|
85
|
+
your company makes such a claim, your patent license ends
|
|
86
|
+
immediately for work on behalf of your company.
|
|
87
|
+
|
|
88
|
+
## Violations
|
|
89
|
+
|
|
90
|
+
The first time you are notified in writing that you have
|
|
91
|
+
violated any of these terms, or done anything with the software
|
|
92
|
+
not covered by your licenses, your licenses can nonetheless
|
|
93
|
+
continue if you come into full compliance with these terms,
|
|
94
|
+
and take practical steps to correct past violations, within
|
|
95
|
+
32 days of receiving notice. Otherwise, all your licenses
|
|
96
|
+
end immediately.
|
|
97
|
+
|
|
98
|
+
## No Liability
|
|
99
|
+
|
|
100
|
+
***As far as the law allows, the software comes as is, without
|
|
101
|
+
any warranty or condition, and the licensor will not be liable
|
|
102
|
+
to you for any damages arising out of these terms or the use
|
|
103
|
+
or nature of the software, under any kind of legal claim.***
|
|
104
|
+
|
|
105
|
+
## Definitions
|
|
106
|
+
|
|
107
|
+
The **licensor** is the individual or entity offering these
|
|
108
|
+
terms, and the **software** is the software the licensor makes
|
|
109
|
+
available under these terms.
|
|
110
|
+
|
|
111
|
+
A **product** can be a good or service, or a combination
|
|
112
|
+
of them.
|
|
113
|
+
|
|
114
|
+
**You** refers to the individual or entity agreeing to these
|
|
115
|
+
terms.
|
|
116
|
+
|
|
117
|
+
**Your company** is any legal entity, sole proprietorship,
|
|
118
|
+
or other kind of organization that you work for, plus all
|
|
119
|
+
organizations that have control over, are under the control of,
|
|
120
|
+
or are under common control with that organization. **Control**
|
|
121
|
+
means ownership of substantially all the assets of an entity,
|
|
122
|
+
or the power to direct its management and policies by vote,
|
|
123
|
+
contract, or otherwise. Control can be direct or indirect.
|
|
124
|
+
|
|
125
|
+
**Your licenses** are all the licenses granted to you for the
|
|
126
|
+
software under these terms.
|
|
127
|
+
|
|
128
|
+
**Use** means anything you do with the software requiring one
|
|
129
|
+
of your licenses.
|
package/README.md
CHANGED
|
@@ -1,3 +1,97 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @n-uf/docking
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> [!CAUTION]
|
|
4
|
+
> ## Not yet stable
|
|
5
|
+
>
|
|
6
|
+
> **@n-uf/docking is young and still changing. Its API (the dock state and its solver, the drop targets and lanes, the conformance rows) is not final.**
|
|
7
|
+
>
|
|
8
|
+
> Version numbers are dates (YY.M.R), not semantic versions, so any release may break things. Pin an exact version and read the [CHANGELOG](https://github.com/n-uf/motion/blob/main/packages/docking/CHANGELOG.md) before you upgrade.
|
|
9
|
+
|
|
10
|
+
Where panels and toolbars dock. A window's edges (bars, rails and columns), items and floats are one plain-data model, a dock state, solved into a layout; every drag gets its drop targets, refusals and lanes, each target carrying the state and layout a release there makes, so the preview is the result. Pure functions over plain data, with no DOM, no framework and no motion; one dependency, [`@n-uf/placement`](https://www.npmjs.com/package/@n-uf/placement), which fits each edge. Rendering stays in the app: it draws the rects, measures its items and feeds pointer samples to a drag intent.
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm i @n-uf/docking @n-uf/placement
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Entry points
|
|
17
|
+
|
|
18
|
+
| Entry | What it gives |
|
|
19
|
+
|---|---|
|
|
20
|
+
| `@n-uf/docking` | One model of a whole window: `solve` for every rect, `targets` and `refusals` for every drag, `dockDrag` for a landing model (its `after(held)`: the one layout a held frame draws while its room is open, and its release commits; `lanes` for hit-testing), pure changes (`moveTo`, `foldItem`, `floatAt`, `resizeEdge`, ...) and a stored form (`storeDockState`, `readDockState`). |
|
|
21
|
+
| `@n-uf/docking/testing` | Conformance rows (`CASES`, `LANDING_CASES`), runners (`runCase`, `runLandingCases`) and reference hosts (`createReferenceHost`, `createLandingHost`) that a host's test suite plays against the model, and `AssertLanding`, a type check that the lanes fit `@n-uf/motion/drag`'s landing model. |
|
|
22
|
+
|
|
23
|
+
Items declare their forms in `@n-uf/placement/stack`'s vocabulary (`StackForm`).
|
|
24
|
+
|
|
25
|
+
## A window
|
|
26
|
+
|
|
27
|
+
A dock state is the stage, its edges, the items with their forms, the floats and the rects they keep clear of. `solve` gives every rect to draw; `targets` gives every drop target for one item, and a drop's `after()` is the state to store and the layout to draw.
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { readDockState, solve, storeDockState, targets, type DockItem, type DockState } from "@n-uf/docking";
|
|
31
|
+
import type { StackForm } from "@n-uf/placement/stack";
|
|
32
|
+
|
|
33
|
+
const f = (kind: StackForm["kind"], min: number, natural: number, cross: number, more: Partial<StackForm> = {}): StackForm => ({ kind, main: { min, natural }, cross: { natural: cross }, ...more });
|
|
34
|
+
const panel = (id: string, used: number): DockItem => ({
|
|
35
|
+
id, kind: "panel", used,
|
|
36
|
+
forms: { column: [f("open", 120, 240, 260, { main: { min: 120, natural: 240, grows: true }, cross: { natural: 260, min: 180 } }), f("header", 28, 28, 260, { cross: { natural: 260, min: 60 } }), f("rail", 28, 28, 30), f("menu", 0, 0, 0)] },
|
|
37
|
+
});
|
|
38
|
+
const group = (id: string, used: number, align?: "end"): DockItem => ({
|
|
39
|
+
id, kind: "group", used, ...(align ? { align } : {}),
|
|
40
|
+
forms: { row: [f("row", 180, 200, 28), f("icons", 84, 84, 28), f("menu", 0, 0, 0)], column: [f("stacked", 96, 96, 84), f("icons", 84, 84, 28), f("menu", 0, 0, 0)] },
|
|
41
|
+
});
|
|
42
|
+
const fixed = (id: string, kind: string, form: StackForm, align?: "center" | "end"): DockItem => ({ id, kind, used: 0, fixed: true, forms: { row: [form] }, ...(align ? { align } : {}) });
|
|
43
|
+
const bar = { accepts: ["group"], cross: { min: 36, max: 36, rail: 36 }, gap: 4, pad: { start: 8, end: 8 } };
|
|
44
|
+
const column = { accepts: ["panel", "group"], cross: { min: 160, max: 480, rail: 30 } };
|
|
45
|
+
const items = [
|
|
46
|
+
fixed("title", "title", f("row", 80, 160, 32, { main: { min: 80, natural: 160, grows: true } })),
|
|
47
|
+
fixed("controls", "controls", f("row", 84, 84, 32), "end"),
|
|
48
|
+
fixed("readout", "readout", f("row", 72, 72, 28), "center"),
|
|
49
|
+
panel("pages", 1), panel("findings", 2), panel("notes", 3),
|
|
50
|
+
group("views", 4), group("tools", 5), group("zoom", 6, "end"), group("search", 7, "end"), group("marks", 8),
|
|
51
|
+
];
|
|
52
|
+
const state: DockState = {
|
|
53
|
+
stage: { x: 0, y: 0, width: 1200, height: 800 },
|
|
54
|
+
edges: [
|
|
55
|
+
{ id: "titlebar", side: "top", ring: 0, accepts: ["group"], items: ["title", "controls"], cross: { min: 32, max: 32, rail: 32 } },
|
|
56
|
+
{ id: "toolbar", side: "top", ring: 1, items: ["views", "tools", "zoom"], ...bar },
|
|
57
|
+
{ id: "status", side: "bottom", ring: 0, span: "between", items: ["readout", "search"], ...bar, cross: { min: 28, max: 28, rail: 28 } },
|
|
58
|
+
{ id: "left", side: "left", ring: 0, items: ["pages"], ...column },
|
|
59
|
+
{ id: "right", side: "right", ring: 0, items: ["findings", "marks"], ...column },
|
|
60
|
+
],
|
|
61
|
+
items: Object.fromEntries(items.map((it) => [it.id, it])),
|
|
62
|
+
floats: [{ id: "notes", rect: { x: 500, y: 200, width: 280, height: 320 } }],
|
|
63
|
+
floatKinds: ["panel", "group"],
|
|
64
|
+
};
|
|
65
|
+
const layout = solve(state);
|
|
66
|
+
console.log(layout.content); // { x: 260, y: 68, width: 680, height: 704 }
|
|
67
|
+
const drops = targets(state, "views", { previous: layout });
|
|
68
|
+
const drop = drops.find((t) => t.id === "gap:right:start:2")!.after({ x: 0, y: 0 });
|
|
69
|
+
console.log(JSON.stringify(solve(drop.state, { previous: layout })) === JSON.stringify(drop.layout)); // true
|
|
70
|
+
console.log(readDockState(JSON.parse(JSON.stringify(storeDockState(drop.state))), state).dropped); // []
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Testing a host
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
import { targetAt } from "@n-uf/motion/drag";
|
|
77
|
+
import { CASES, createReferenceHost, runCases } from "@n-uf/docking/testing";
|
|
78
|
+
|
|
79
|
+
const results = runCases(CASES, () => createReferenceHost({ pick: targetAt })); // a page's host plays the same rows
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The landing rows (`LANDING_CASES`, `runLandingCases`) check a host that drags with `@n-uf/motion/drag`'s landing model,
|
|
83
|
+
the hand rule included: while a lane holds, the landing is the nearest in its lane to the pointer, within
|
|
84
|
+
`handBound(g)` = `max(48, g / 2 + 6)` px of it ([decision 0001](https://github.com/n-uf/motion/blob/main/docs/decisions/0001-the-hand-rule.md)).
|
|
85
|
+
|
|
86
|
+
## Documentation
|
|
87
|
+
|
|
88
|
+
- [Design page](https://motion.n-uf.com/docs/docking/): the concept, the parts, the rules a consumer relies on, and the SDK entry by entry.
|
|
89
|
+
- [Reference](https://github.com/n-uf/motion/blob/main/docs/docking-reference.md): every rule, id, option and longer examples.
|
|
90
|
+
- [CHANGELOG](https://github.com/n-uf/motion/blob/main/packages/docking/CHANGELOG.md): what changed, and how to move from `@n-uf/placement/scene`.
|
|
91
|
+
- Site and live demos: [motion.n-uf.com](https://motion.n-uf.com)
|
|
92
|
+
|
|
93
|
+
Its siblings: [`@n-uf/placement`](https://www.npmjs.com/package/@n-uf/placement) fits one edge, [`@n-uf/motion`](https://www.npmjs.com/package/@n-uf/motion) owns how things move.
|
|
94
|
+
|
|
95
|
+
## License
|
|
96
|
+
|
|
97
|
+
[PolyForm Perimeter 1.0.1](https://github.com/n-uf/motion/blob/main/LICENSE).
|