@n-uf/placement 26.11.24 → 26.11.25
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 +74 -0
- package/README.md +66 -28
- package/dist/{chunk-LPMZ2FFR.js → chunk-3P6VOXA6.js} +2 -2
- package/dist/chunk-3P6VOXA6.js.map +1 -0
- package/dist/{chunk-CJA6LRHN.js → chunk-7ASCUAGV.js} +5 -7
- package/dist/chunk-7ASCUAGV.js.map +1 -0
- package/dist/{chunk-RL3QB5SM.js → chunk-KGZCYLQN.js} +10 -10
- package/dist/chunk-KGZCYLQN.js.map +1 -0
- package/dist/{chunk-2H3CSPEH.js → chunk-OYGOJWAX.js} +2 -2
- package/dist/{chunk-XUC5BU4N.js → chunk-SZKU7CRX.js} +575 -499
- package/dist/chunk-SZKU7CRX.js.map +1 -0
- package/dist/chunk-WM5FJ3IS.js +47 -0
- package/dist/chunk-WM5FJ3IS.js.map +1 -0
- package/dist/{constructions-VDK_mwmz.d.ts → constructions-DSEjvWMP.d.ts} +1 -1
- package/dist/desk.d.ts +3 -3
- package/dist/desk.js +3 -3
- package/dist/dock.d.ts +3 -3
- package/dist/dock.js +2 -2
- package/dist/geometry-CkZ6Fcfb.d.ts +48 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +21 -3
- package/dist/index.js.map +1 -1
- package/dist/{model-DPTu2EtG.d.ts → model-mm16NrSX.d.ts} +1 -1
- package/dist/panels.d.ts +5 -4
- package/dist/panels.js +6 -5
- package/dist/scene-cases.d.ts +4 -4
- package/dist/scene-cases.js +15 -16
- package/dist/scene-cases.js.map +1 -1
- package/dist/scene.d.ts +5 -39
- package/dist/scene.js +3 -3
- package/dist/stack.d.ts +4 -4
- package/dist/stack.js +2 -2
- package/dist/stack.js.map +1 -1
- package/dist/{target-D3PiLg44.d.ts → target-C-HJjPcz.d.ts} +1 -1
- package/dist/{targets-B6eLC-52.d.ts → targets-CBpO_LEy.d.ts} +4 -6
- package/dist/{targets-DwwIWPpN.d.ts → targets-CDR5Towj.d.ts} +74 -60
- package/dist/targets.d.ts +4 -4
- package/dist/targets.js +6 -7
- package/dist/targets.js.map +1 -1
- package/dist/toolbar.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunk-CJA6LRHN.js.map +0 -1
- package/dist/chunk-LPMZ2FFR.js.map +0 -1
- package/dist/chunk-QMTNB2C3.js +0 -17
- package/dist/chunk-QMTNB2C3.js.map +0 -1
- package/dist/chunk-RL3QB5SM.js.map +0 -1
- package/dist/chunk-XUC5BU4N.js.map +0 -1
- package/dist/geometry-mL-GTRti.d.ts +0 -28
- /package/dist/{chunk-2H3CSPEH.js.map → chunk-OYGOJWAX.js.map} +0 -0
package/dist/scene.d.ts
CHANGED
|
@@ -1,42 +1,8 @@
|
|
|
1
|
-
import { S as Scene, g as SolveOptions, b as SceneLayout } from './targets-
|
|
2
|
-
export { C as ColumnPlace, h as ColumnTemplate, D as DEFAULT_FLOAT_SIZE, i as DEFAULT_HIT_BAND, j as DEFAULT_STRIP, k as DockPlace, E as Edge, F as FloatAnchor, l as FloatPlace, K as Kind, O as Orient, P as Place, R as RailPlace, m as RailSpec, n as SIDES, o as SceneAfter, p as SceneEdgeLayout, q as SceneFloat, r as SceneItem, s as SceneItemLayout, t as SceneNote, e as SceneNoteCode, a as ScenePlace, u as SceneRailLayout, v as SceneRead, w as SceneRefusal, f as SceneTarget, x as SceneTargetOptions, d as Side, c as StoredScene, y as StoredSceneEdge, z as StoredSceneFloat, A as StoredSceneItem, B as ZONES, Z as Zone, G as ZoneAccepts, H as close, I as dockHome, J as floatAt, L as floatOrientOf, M as floatSizeOf, N as fold, Q as homeFor, T as isOutsideSideBar, U as isSideBar, V as keep, W as lift, X as moveTo, Y as open, _ as orient, $ as raise, a0 as readScene, a1 as refusals, a2 as reservedRect, a3 as resize, a4 as setSide, a5 as stops, a6 as storeScene, a7 as targets, a8 as use, a9 as zoneTakes, aa as zonesTaking } from './targets-
|
|
3
|
-
import './geometry-
|
|
4
|
-
import './target-
|
|
5
|
-
import './model-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* `solve(scene, { previous })`: the whole window's layout from one scene.
|
|
9
|
-
*
|
|
10
|
-
* 1. **The cut.** Reserved edges cut the stage from the outside in: first the full-span bars (top, then bottom, each
|
|
11
|
-
* by ring), across the stage's whole width; then the columns (left, then right, by ring), down the height the full
|
|
12
|
-
* bars left; then the `between` bars, across the width the columns left. What remains is `content`. Overlay edges
|
|
13
|
-
* are cut the same way from a copy of the content, so they lie over it without shortening it.
|
|
14
|
-
* 2. **Each edge is a stack** (`fitStack`): a column along the height it gets, a bar along the width, with each item's
|
|
15
|
-
* `forms.column` or `forms.row`. Items are taken in zone order (start, center, end); `fixed` items keep their form;
|
|
16
|
-
* closed items take no room. In a column, group forms take their own width (`ownCross`). The edge's thickness is
|
|
17
|
-
* the stack's cross size; an edge with nothing in it takes none.
|
|
18
|
-
* 3. **Rail and size.** A column in which nothing sets the width is a rail: its items with a `rail` form are re-solved
|
|
19
|
-
* in it and listed as `tabs` (closed ones too with `railShowsClosed`). Otherwise, with `Edge.size`, the column is
|
|
20
|
-
* re-solved at the user's size, clamped to `[max(cross.min, the widest open setter's cross.min), cross.max]`.
|
|
21
|
-
* 4. **Zones.** When the items leave spare length (nothing grows), start items pack from the start, end items from the
|
|
22
|
-
* end (before the » entry) and center items sit centred on the edge's middle, moved only as far as they must to
|
|
23
|
-
* stay between the other two zones.
|
|
24
|
-
* 5. **Floats** are fitted inside the stage, clear of every docked item (fixed ones and » entries included), every bar
|
|
25
|
-
* and the chrome rects (`fitFloat`). An anchored float sits flush with that side or corner of `content` first. A
|
|
26
|
-
* float with `from` over 0 is its bar: its form's natural length along its `orient`, its other size kept.
|
|
27
|
-
*
|
|
28
|
-
* 6. **Dynamic columns** (`Edge.column`, on a side with `Scene.rails[side]`): while the content is narrower than
|
|
29
|
-
* `contentMin.width` (after `inset` and a `gutter` after each side edge and rail), they shrink toward their minimum
|
|
30
|
-
* (the edge's `cross.min` and the widest open setter's), then fold whole into their side's one rail, unkept before
|
|
31
|
-
* kept, the oldest newest use first, the outer first, the left first. A column whose members are all folded by hand
|
|
32
|
-
* goes to the rail too, or with `handFold: "ride"` and one member it rides as a title bar over the side's first open
|
|
33
|
-
* column, at its width, taking none. The rail lies just outside the side's first column, its segments (each member's
|
|
34
|
-
* `rail` form) in ring order.
|
|
35
|
-
*
|
|
36
|
-
* `previous` (the layout before) gives each edge's fits to `fitStack` as `previous`, so a change of ages alone (a press)
|
|
37
|
-
* changes no rect; columns folded or shrunk by give-way stay so while the content still fits, and room coming back
|
|
38
|
-
* unfolds them in the reverse of give-way order. Pure: the same scene always lays out the same.
|
|
39
|
-
*/
|
|
1
|
+
import { S as Scene, g as SolveOptions, b as SceneLayout } from './targets-CDR5Towj.js';
|
|
2
|
+
export { C as ColumnPlace, h as ColumnTemplate, D as DEFAULT_FLOAT_SIZE, i as DEFAULT_HIT_BAND, j as DEFAULT_STRIP, k as DockPlace, E as Edge, F as FloatAnchor, l as FloatPlace, K as Kind, O as Orient, P as Place, R as RailPlace, m as RailSpec, n as SIDES, o as SceneAfter, p as SceneEdgeLayout, q as SceneFloat, r as SceneItem, s as SceneItemLayout, t as SceneNote, e as SceneNoteCode, a as ScenePlace, u as SceneRailLayout, v as SceneRead, w as SceneRefusal, f as SceneTarget, x as SceneTargetOptions, d as Side, c as StoredScene, y as StoredSceneEdge, z as StoredSceneFloat, A as StoredSceneItem, B as ZONES, Z as Zone, G as ZoneAccepts, H as close, I as dockHome, J as floatAt, L as floatOrientOf, M as floatSizeOf, N as fold, Q as homeFor, T as isOutsideSideBar, U as isSideBar, V as keep, W as lift, X as moveTo, Y as open, _ as orient, $ as raise, a0 as readScene, a1 as refusals, a2 as reservedRect, a3 as resize, a4 as setSide, a5 as stops, a6 as storeScene, a7 as targets, a8 as use, a9 as zoneTakes, aa as zonesTaking } from './targets-CDR5Towj.js';
|
|
3
|
+
import './geometry-CkZ6Fcfb.js';
|
|
4
|
+
import './target-C-HJjPcz.js';
|
|
5
|
+
import './model-mm16NrSX.js';
|
|
40
6
|
|
|
41
7
|
declare function solve(given: Scene, options?: SolveOptions): SceneLayout;
|
|
42
8
|
|
package/dist/scene.js
CHANGED
|
@@ -31,9 +31,9 @@ import {
|
|
|
31
31
|
use,
|
|
32
32
|
zoneTakes,
|
|
33
33
|
zonesTaking
|
|
34
|
-
} from "./chunk-
|
|
35
|
-
import "./chunk-
|
|
36
|
-
import "./chunk-
|
|
34
|
+
} from "./chunk-SZKU7CRX.js";
|
|
35
|
+
import "./chunk-KGZCYLQN.js";
|
|
36
|
+
import "./chunk-WM5FJ3IS.js";
|
|
37
37
|
export {
|
|
38
38
|
DEFAULT_FLOAT_SIZE,
|
|
39
39
|
DEFAULT_HIT_BAND,
|
package/dist/stack.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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-
|
|
3
|
-
import { R as Rect, P as Point, S as Size } from './geometry-
|
|
4
|
-
import { T as Target } from './target-
|
|
1
|
+
import { d as StackInput, F as FitOptions, b as StackFit, e as StackItem } from './model-mm16NrSX.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-mm16NrSX.js';
|
|
3
|
+
import { R as Rect, P as Point, S as Size } from './geometry-CkZ6Fcfb.js';
|
|
4
|
+
import { T as Target } from './target-C-HJjPcz.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* `fitStack(input, options?)`. With `options.previous` (the fit the stack had before) the forms it chose are kept while
|
package/dist/stack.js
CHANGED
|
@@ -17,10 +17,10 @@ import {
|
|
|
17
17
|
wrapCross,
|
|
18
18
|
wrapLines,
|
|
19
19
|
wrapRows
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-KGZCYLQN.js";
|
|
21
21
|
import {
|
|
22
22
|
rect
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-WM5FJ3IS.js";
|
|
24
24
|
|
|
25
25
|
// src/stack/targets.ts
|
|
26
26
|
function bounds(input, fit, reach) {
|
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 \"../targets/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,M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G,KAAK,GAAG,IAAI,OAAO,CAAC,IAAI,KAAK,KAAK,GAAG,GAAG,GAAG,IAAI,KAAK;AAAA,MAC7E,OAAO;AAAA,MACP;AAAA,IACF,CAAC;AAAA,EACH;AACA,SAAO;AACT;","names":[]}
|
|
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;AACtB,UAAM,MAAM,IAAI,KAAK,EAAE,IAAI,IAAI;AAC/B,MAAE,KAAK,GAAG,QAAQ,IAAI,KAAK,GAAG,QAAQ,IAAI,KAAK,EAAE,IAAI,IAAI,GAAG;AAC5D,UAAM,IAAI,KAAK,EAAE,IAAI;AAErB,QAAI,GAAG,MAAO,OAAM,KAAK,IAAI,KAAK,GAAG;AAAA,EACvC;AACA,IAAE,KAAK,IAAI,MAA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AAK,KAAK,MAAM,QAAQ,KAAK;AAC3C,QAAI,QAAQ,UAAU,CAAC,QAAQ,OAAO,SAAS,CAAC,EAAG;AACnD,UAAM,SAAS,SAAS,MAAM,MAAM,CAAC;AACrC,UAAM,MAAM,SAAS,QAAQ,UAAU;AACvC,UAAM,SAAS,IAAI,MAAM,KAAK,CAAC,MAAM,EAAE,OAAO,QAAQ,EAAE;AACxD,UAAM,OAAO,OAAO;AACpB,QAAI,QAAQ,YAAY,CAAC,WAAW,MAAM,KAAK,QAAQ,YAAY,KAAK,MAAM,aAAa,EAAG;AAC9F,UAAM,OAAO,EAAE,KAAK,CAAC;AACrB,UAAM,KAAK,EAAE,GAAG,CAAC;AACjB,UAAM,SAAS,KAAK,IAAI,KAAK,OAAO,IAAI,KAAK;AAC7C,QAAI,KAAK;AAAA,MACP,IAAI,OAAO,CAAC;AAAA,MACZ,UAAU;AAAA,MACV,MAAM,QAAQ;AAAA,MACd,OAAO,EAAE,MAAM,OAAO,IAAI,EAAE;AAAA,MAC5B,KAAK,SAAS,KAAK,GAAG,MAAM,QAAQ,KAAK,IAAI,IAAI,KAAK,MAAM,GAAG,KAAK,MAAM,MAAM;AAAA,MAChF;AAAA;AAAA,MAEA,QAAQ,SAAS,KAAK,GAAG,KAAK,GAAG,IAAI,OAAO,CAAC,IAAI,KAAK,KAAK,GAAG,GAAG,GAAG,IAAI,KAAK;AAAA,MAC7E,OAAO;AAAA,MACP;AAAA,IACF,CAAC;AAAA,EACH;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as Size, R as Rect, P as Point } from './geometry-
|
|
2
|
-
import { T as Target } from './target-
|
|
1
|
+
import { S as Size, R as Rect, P as Point } from './geometry-CkZ6Fcfb.js';
|
|
2
|
+
import { T as Target } from './target-C-HJjPcz.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The panels model: plain data and the pure changes on it.
|
|
@@ -563,9 +563,7 @@ interface PanelTargetInput {
|
|
|
563
563
|
/** Drops into a stacked column may go before any of its members (`into` targets with `at`); default: the bottom only. */
|
|
564
564
|
readonly stackSlots?: boolean;
|
|
565
565
|
}
|
|
566
|
-
|
|
567
|
-
declare const COLUMN_REACH = 22;
|
|
568
|
-
declare const RAIL_EDGE = 10;
|
|
566
|
+
|
|
569
567
|
/**
|
|
570
568
|
* A place's rank in reading order: the left side outer to inner, the right side inner to outer, then the top band and
|
|
571
569
|
* the bottom band left to right, floating last.
|
|
@@ -620,4 +618,4 @@ interface PanelStopsOptions {
|
|
|
620
618
|
/** The panel's places in reading order, for the arrow keys and a "Move to" menu (`keyboardStops` calls this). */
|
|
621
619
|
declare function panelStops(targets: readonly PanelTarget[], options?: PanelStopsOptions): PanelStop[];
|
|
622
620
|
|
|
623
|
-
export {
|
|
621
|
+
export { giveWayOrder as $, type PlacedRail as A, BAND_SIZE as B, type Clock as C, DEFAULT_PANELS_OPTIONS as D, type Edge as E, FLOAT_HEIGHT as F, type GiveWay as G, type ReserveEdge as H, IDENTITY_VIEW as I, SIDES as J, activate as K, bandHeight as L, bandSize as M, close as N, columnWidth as O, type PanelsOptions as P, createPanels as Q, type Reserve as R, type Side as S, defOf as T, dock as U, type View as V, type Where as W, dockBand as X, float as Y, floatSize as Z, focus as _, type PanelDef as a, homePlace as a0, keep as a1, liftPanel as a2, open as a3, ownWidth as a4, panelStops as a5, panelTargets as a6, pin as a7, placeRank as a8, resizeBand as a9, resizeColumn as aa, resizeFloat as ab, samePlaces as ac, showTabs as ad, tick as ae, toPage as af, toView as ag, toggleFold as ah, whereIs as ai, type PanelsState as b, type PanelTargetInput as c, type PanelTarget as d, type PanelDrop as e, type PanelsLayout as f, type Band as g, type BandOption as h, type Column as i, type DockOptions as j, EDGES as k, layoutPanels as l, FLOAT_MIN as m, type FloatAt as n, type PanelKind as o, panelDrop as p, type PanelPlace as q, type PanelStop as r, type PanelStopsOptions as s, type PanelsNote as t, type PanelsNoteCode as u, type PanelsStart as v, type Place as w, type PlacedBand as x, type PlacedColumn as y, type PlacedPanel as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { R as Rect, S as Size, P as Point } from './geometry-
|
|
2
|
-
import { T as Target } from './target-
|
|
3
|
-
import { C as CrossLimits, a as StackForm, S as StackFormKind, b as StackFit, c as StackNote } from './model-
|
|
1
|
+
import { R as Rect, S as Size, P as Point } from './geometry-CkZ6Fcfb.js';
|
|
2
|
+
import { T as Target } from './target-C-HJjPcz.js';
|
|
3
|
+
import { C as CrossLimits, a as StackForm, S as StackFormKind, b as StackFit, c as StackNote } from './model-mm16NrSX.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The scene's shapes: one model of a whole window. A scene is a stage (the window's inner rect), the edges along its
|
|
@@ -122,8 +122,9 @@ interface Edge {
|
|
|
122
122
|
* The kinds each zone takes, narrowing `accepts`: with it, a zone not listed takes nothing. A panel column with
|
|
123
123
|
* `{ start: ["panel"], end: ["group"] }` has its panels at the top and a tray of toolbars at its foot (the end zone, one
|
|
124
124
|
* toolbar per row): a toolbar in the tray takes only its `wrap` or `icons` form (never the menu), and the panels give
|
|
125
|
-
* way first.
|
|
126
|
-
*
|
|
125
|
+
* way first. An empty edge offers each third of its strip only to the kinds that third's zone takes (the others are
|
|
126
|
+
* refusals). A group never opens such a column on its own: an empty side column offers its strip only to the kinds
|
|
127
|
+
* its start zone takes (a panel gets its top third; a group none, the rail's instead).
|
|
127
128
|
*/
|
|
128
129
|
readonly zoneAccepts?: ZoneAccepts;
|
|
129
130
|
/** The drop strip's depth while the edge is empty, px (default {@link DEFAULT_STRIP}). */
|
|
@@ -392,8 +393,13 @@ interface SceneLayout {
|
|
|
392
393
|
readonly content: Rect;
|
|
393
394
|
/** The floats drawn, in stacking order (the last on top). */
|
|
394
395
|
readonly floats: readonly string[];
|
|
395
|
-
/** The rails shown (a side with a folded column). */
|
|
396
|
+
/** The rails shown (a side with a folded column). Hosts draw these. */
|
|
396
397
|
readonly rails: Readonly<Partial<Record<"left" | "right", SceneRailLayout>>>;
|
|
398
|
+
/**
|
|
399
|
+
* Where each side's rail lies, or would lie were one shown, for every side that has a rail (`Scene.rails`), drawn or
|
|
400
|
+
* not: the place a drop into the rail lands (`targets` reads it). Hosts draw `rails`, never `railPlaces`.
|
|
401
|
+
*/
|
|
402
|
+
readonly railPlaces: Readonly<Partial<Record<"left" | "right", Rect>>>;
|
|
397
403
|
/**
|
|
398
404
|
* With `contentMin` and a dynamic column (or, before any exists, a `columns` template): whether one column at its
|
|
399
405
|
* minimum fits beside the content's minimum (`false` with a `no-column-room` note). Anchors and rails don't count:
|
|
@@ -603,46 +609,49 @@ declare function readScene(data: unknown, base: Scene): SceneRead;
|
|
|
603
609
|
* a release there commits and its layout, `solve(after.scene, { previous })`: the host draws every item from that layout
|
|
604
610
|
* during the preview (C22), so the preview is the result by construction.
|
|
605
611
|
*
|
|
606
|
-
*
|
|
607
|
-
*
|
|
608
|
-
*
|
|
609
|
-
*
|
|
610
|
-
*
|
|
611
|
-
*
|
|
612
|
-
*
|
|
613
|
-
*
|
|
614
|
-
*
|
|
615
|
-
*
|
|
616
|
-
*
|
|
617
|
-
*
|
|
618
|
-
*
|
|
619
|
-
*
|
|
620
|
-
*
|
|
621
|
-
*
|
|
622
|
-
* its
|
|
623
|
-
*
|
|
624
|
-
*
|
|
625
|
-
*
|
|
626
|
-
*
|
|
627
|
-
*
|
|
628
|
-
*
|
|
629
|
-
*
|
|
630
|
-
*
|
|
631
|
-
*
|
|
632
|
-
*
|
|
633
|
-
*
|
|
634
|
-
*
|
|
635
|
-
*
|
|
612
|
+
* One model makes every docked target and refusal: **edge → zones → slots → tiles**, then one ordered
|
|
613
|
+
* filter.
|
|
614
|
+
*
|
|
615
|
+
* - **Edges.** Every edge, empty or occupied, and two virtual edges per side: the column lines and the rail.
|
|
616
|
+
* - **Zones.** Each edge's start, center and end zones have an extent along it. Where items keep their length and the
|
|
617
|
+
* zones only align them (bars, compact rails, side toolbar bars) the extents are the edge's thirds; where items fill
|
|
618
|
+
* the edge (panel columns) a zone's extent is the span the solver gives it: a plain column is one zone, a tray column
|
|
619
|
+
* its panels' span and its tray's (`EDGE_KINDS`, the only data keyed on the kind of edge). The outer extents reach
|
|
620
|
+
* `endReach` past the edge's ends.
|
|
621
|
+
* - **Slots.** A zone's insertion lines, from the layout with the item lifted (`gap:<edge>:<zone>:<at>`; on an edge with
|
|
622
|
+
* no members at all a zone has one, `strip:<edge>:<zone>`). The item's own place is an interval, its own rect along the edge: home.
|
|
623
|
+
* - **Tiles.** A zone's extent split halfway between its slots' lines (lines that lie past the extent are spread into
|
|
624
|
+
* it); the own interval keeps exactly its length, its neighbours meeting it, and a stretch of a zone with no other
|
|
625
|
+
* slot is home's. Across: the edge's thickness (the larger of now and after the drop), an empty edge's strip depth
|
|
626
|
+
* (`Edge.strip`, default 24, inward), a compact rail's `RAIL_REACH` further inward.
|
|
627
|
+
* - **Filter**, in order: (i) the edge and zone take the kind (`accepts`, `zoneAccepts`), and an empty side column opens
|
|
628
|
+
* only through its start zone; (ii) the drop fits (C29: no » entry, no new overflow or `too-wide`, every fixed item
|
|
629
|
+
* keeps its form, place and least length, a title bar's title its natural width with the toolbar in its first form;
|
|
630
|
+
* the slot covers no chrome or reserved rect). A slot (i) or (ii) removes is a refusal over its own tile, with that
|
|
631
|
+
* reason (`refusals()`). (iii) Space ownership and clipping (`EDGE_KINDS`): owned > virtual > overreach. A zone's
|
|
632
|
+
* room loses its panel bodies, its reserved rects and what edges ranked before it own (in `solve`'s laying order); a
|
|
633
|
+
* zone with no room, or a slot with none in reach, isn't offered. Each tile's owned part is cut clear of the tiles
|
|
634
|
+
* before it, of what outranks its edge, of every fixed item that doesn't grow and of the chrome, keeping the part
|
|
635
|
+
* that holds its slot's line (its other parts refused); then the virtual edges take what no edge owns; then each
|
|
636
|
+
* overreach takes what is left and joins its owned part where it meets it whole. Slots that are the same move are
|
|
637
|
+
* one. (iv) `blocked` rects are `none:<i>`.
|
|
638
|
+
*
|
|
639
|
+
* Ids: `gap:<edge>:<zone>:<at>` (priority 2), `strip:<edge>:<zone>` (2), `column:<side>:<ring>` (2), `rail:<side>:<ring>`
|
|
640
|
+
* (1), `none:<i>` (1), `float:<id>` (3, free). A slot that would put the item back where it is keeps its id with place
|
|
641
|
+
* `home` (no slot, nothing committed); `home:<id>` (1) is emitted too, over the same tile (its own rect when no slot is
|
|
642
|
+
* its home), for hosts that read it. A floating item has no home: a move inside its own rect is a float move.
|
|
643
|
+
*
|
|
644
|
+
* - `column:<side>:<ring>`: a new column on each column line of a side whose `scene.columns[side]` takes the kind
|
|
636
645
|
* (outside the outermost open column, between two, inside the innermost; on a side with none, at the content's
|
|
637
|
-
* edge), `COLUMN_REACH` px each way, only where the new column shows
|
|
638
|
-
*
|
|
639
|
-
*
|
|
640
|
-
*
|
|
641
|
-
*
|
|
642
|
-
* - `
|
|
643
|
-
*
|
|
644
|
-
*
|
|
645
|
-
*
|
|
646
|
+
* edge), up to `COLUMN_REACH` px each way (two lines nearer than that meet halfway), only where the new column shows
|
|
647
|
+
* open (elsewhere refused).
|
|
648
|
+
* - `rail:<side>:<ring>`: docking folded into a side's rail (its rail and its template take the kind), before each
|
|
649
|
+
* folded column's segments and after the last, or, with no rail shown, `RAIL_EDGE` px deep where the rail lands
|
|
650
|
+
* (`SceneLayout.railPlaces`).
|
|
651
|
+
* - `float:<id>`: when `floatKinds` lists the kind, the whole plane: the landing is the float with the pointer holding
|
|
652
|
+
* it at `grab` (default its middle), in the stage and clear of the docked items, the bars and the chrome. Its orient:
|
|
653
|
+
* `options.floatOrient`, else its float's, else the item's (`floatOrientOf`). Its size: `options.floatSize`, else its
|
|
654
|
+
* float's size, else `floatSizeOf`.
|
|
646
655
|
*
|
|
647
656
|
* `stops(scene, id)` orders the same targets (no home, no none) for "Move to ›" and the arrow keys.
|
|
648
657
|
*
|
|
@@ -686,30 +695,35 @@ interface SceneTargetOptions {
|
|
|
686
695
|
/** As `solve`'s: edge or item ids solved without `previous`, in every `after` too. */
|
|
687
696
|
readonly fresh?: readonly string[];
|
|
688
697
|
}
|
|
689
|
-
declare function targets(scene: Scene, dragged: string, options?: SceneTargetOptions): SceneTarget[];
|
|
690
|
-
/**
|
|
691
|
-
* What a fixed item reserves in `l`: its drawn rect, or for a form that grows only its natural length, placed by its
|
|
692
|
-
* 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
|
|
693
|
-
* host that draws "no drop" areas reads them from here.
|
|
694
|
-
*/
|
|
695
|
-
declare function reservedRect(scene: Scene, l: SceneLayout, id: string): Rect;
|
|
696
698
|
/** Where a drop of the dragged item is refused: a host shows "no room here" at the pointer, with no slot anywhere. */
|
|
697
699
|
interface SceneRefusal {
|
|
698
|
-
/**
|
|
700
|
+
/**
|
|
701
|
+
* `refuse:<edge>:<zone>`, with `:<n>` after it for a zone's second refused tile and on, numbered by where they lie
|
|
702
|
+
* along the edge (then across it), so an id is stable from one frame to the next.
|
|
703
|
+
*/
|
|
699
704
|
readonly id: string;
|
|
700
705
|
readonly edge: string;
|
|
701
706
|
readonly zone: Zone;
|
|
702
|
-
/** Where the pointer means it
|
|
707
|
+
/** Where the pointer means it: the refused slot's tile, never over a target's hit. */
|
|
703
708
|
readonly hit: Rect;
|
|
704
|
-
/**
|
|
705
|
-
|
|
709
|
+
/**
|
|
710
|
+
* `no-room`: the zone takes the kind, but the drop there doesn't fit (a title bar at the title's natural width, say).
|
|
711
|
+
* `own-place`: the stretch beside an item alone in its zone: there is room, but the zone's only place is the item's
|
|
712
|
+
* own (a release there puts it back). `not-accepted`: the edge or zone doesn't take the kind.
|
|
713
|
+
*/
|
|
714
|
+
readonly reason: "no-room" | "own-place" | "not-accepted";
|
|
706
715
|
}
|
|
716
|
+
/**
|
|
717
|
+
* What a fixed item reserves in `l`: its drawn rect, or for a form that grows only its natural length, placed by its
|
|
718
|
+
* 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
|
|
719
|
+
* host that draws "no drop" areas reads them from here.
|
|
720
|
+
*/
|
|
721
|
+
declare function reservedRect(scene: Scene, l: SceneLayout, id: string): Rect;
|
|
722
|
+
declare function targets(scene: Scene, dragged: string, options?: SceneTargetOptions): SceneTarget[];
|
|
707
723
|
/**
|
|
708
724
|
* `refusals(scene, dragged, options?)`: the places a drop of `dragged` is refused, so a host can say so at the pointer
|
|
709
|
-
* (a tint and "No room here") instead of showing a slot elsewhere
|
|
710
|
-
*
|
|
711
|
-
* left or right edge that doesn't take the kind is refused as a whole (zone `start`). Each hit is cut clear of every
|
|
712
|
-
* target's hit (the float target aside), so a pointer over one has no target there but the float. A release over a
|
|
725
|
+
* (a tint and "No room here") instead of showing a slot elsewhere: each slot the filter removed, over its own tile,
|
|
726
|
+
* `not-accepted` where the edge or zone doesn't take the kind, `no-room` where the drop wouldn't fit. A release over a
|
|
713
727
|
* refusal commits nothing: the item goes home.
|
|
714
728
|
*/
|
|
715
729
|
declare function refusals(scene: Scene, dragged: string, options?: SceneTargetOptions): SceneRefusal[];
|
package/dist/targets.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { T as Target } from './target-
|
|
2
|
-
import { R as Rect, P as Point, S as Size } from './geometry-
|
|
3
|
-
import { D as DeskState, g as Layout, a as Construction, O as Options } from './constructions-
|
|
1
|
+
import { T as Target } from './target-C-HJjPcz.js';
|
|
2
|
+
import { R as Rect, P as Point, S as Size } from './geometry-CkZ6Fcfb.js';
|
|
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,
|
|
5
|
+
import { d as PanelTarget, s as PanelStopsOptions, r as PanelStop } from './targets-CBpO_LEy.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/dist/targets.js
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
treeRails,
|
|
24
24
|
treeShown,
|
|
25
25
|
treeTiles
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-3P6VOXA6.js";
|
|
27
27
|
import {
|
|
28
28
|
HOST_LABEL,
|
|
29
29
|
ZONES,
|
|
@@ -38,17 +38,17 @@ import {
|
|
|
38
38
|
} from "./chunk-WLMJ6JGO.js";
|
|
39
39
|
import {
|
|
40
40
|
panelStops
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-7ASCUAGV.js";
|
|
42
42
|
import {
|
|
43
43
|
centre,
|
|
44
|
+
clamp,
|
|
44
45
|
overlap,
|
|
45
46
|
rect
|
|
46
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-WM5FJ3IS.js";
|
|
47
48
|
|
|
48
49
|
// src/targets/desk.ts
|
|
49
50
|
var SNAP = 18;
|
|
50
51
|
var insert = (list, i, x) => [...list.slice(0, i), x, ...list.slice(i)];
|
|
51
|
-
var clamp = (v, lo, hi) => Math.min(Math.max(v, lo), Math.max(lo, hi));
|
|
52
52
|
var Cap = (s) => s === "left" ? "Left" : "Right";
|
|
53
53
|
var fixed = (state, label) => () => ({ state, label, key: label });
|
|
54
54
|
var slotSpan = (mids, lo, hi, i) => [i === 0 ? lo : mids[i - 1], i === mids.length ? hi : mids[i]];
|
|
@@ -412,15 +412,14 @@ function toolbarStops(targets, options) {
|
|
|
412
412
|
// src/targets/zones.ts
|
|
413
413
|
var PANE_EDGES = ["top", "right", "bottom", "left"];
|
|
414
414
|
var PANE_ZONE_DEFAULTS = { centre: 0.34, centreMin: 24, hysteresis: 6, pixelRatio: 1 };
|
|
415
|
-
var clamp2 = (v, lo, hi) => Math.min(Math.max(v, lo), hi);
|
|
416
415
|
var snap = (v, ratio) => Math.round(v * ratio) / ratio;
|
|
417
416
|
function paneCentre(size, options = {}) {
|
|
418
417
|
const o = { ...PANE_ZONE_DEFAULTS, ...options };
|
|
419
418
|
const width = Math.max(0, size.width);
|
|
420
419
|
const height = Math.max(0, size.height);
|
|
421
420
|
const ratio = o.pixelRatio > 0 ? o.pixelRatio : 1;
|
|
422
|
-
const rx =
|
|
423
|
-
const ry =
|
|
421
|
+
const rx = clamp(o.centreX ?? o.centre, 0.05, 0.95);
|
|
422
|
+
const ry = clamp(o.centreY ?? o.centre, 0.05, 0.95);
|
|
424
423
|
const cw = Math.min(width, Math.max(width * rx, Math.min(o.centreMin, width)));
|
|
425
424
|
const ch = Math.min(height, Math.max(height * ry, Math.min(o.centreMin, height)));
|
|
426
425
|
return { width, height, left: snap((width - cw) / 2, ratio), top: snap((height - ch) / 2, ratio), right: snap((width + cw) / 2, ratio), bottom: snap((height + ch) / 2, ratio) };
|