@n-uf/placement 26.11.34 → 26.11.37
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 +147 -20
- package/dist/{chunk-VKB3UWKX.js → chunk-2PWDUBPG.js} +520 -97
- package/dist/chunk-2PWDUBPG.js.map +1 -0
- package/dist/{chunk-AVMZIXGO.js → chunk-NF7RYK3U.js} +9 -49
- package/dist/chunk-NF7RYK3U.js.map +1 -0
- package/dist/chunk-R3AAANRY.js +220 -0
- package/dist/chunk-R3AAANRY.js.map +1 -0
- package/dist/desk.d.ts +2 -2
- package/dist/dock.js +2 -1
- package/dist/dock.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/{model-BSIKmANw.d.ts → model-CuE-ML-f.d.ts} +111 -19
- package/dist/panels.d.ts +3 -3
- package/dist/regions-Db_RyT4P.d.ts +48 -0
- package/dist/scene-cases.d.ts +42 -10
- package/dist/scene-cases.js +109 -10
- package/dist/scene-cases.js.map +1 -1
- package/dist/scene.d.ts +100 -6
- package/dist/scene.js +11 -1
- package/dist/stack.d.ts +1 -1
- package/dist/{target-2RYYKkd1.d.ts → target-fhD5UVlt.d.ts} +2 -0
- package/dist/{targets-Du5_4T1u.d.ts → targets-DnVNZVQW.d.ts} +1 -1
- package/dist/targets.d.ts +17 -32
- package/dist/targets.js +20 -54
- package/dist/targets.js.map +1 -1
- package/dist/tiling.d.ts +114 -0
- package/dist/tiling.js +40 -0
- package/dist/tiling.js.map +1 -0
- package/package.json +6 -2
- package/dist/chunk-AVMZIXGO.js.map +0 -1
- package/dist/chunk-VKB3UWKX.js.map +0 -1
package/dist/targets.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/targets/desk.ts","../src/targets/toolbar.ts","../src/targets/stops.ts","../src/targets/zones.ts"],"sourcesContent":["/**\n * Each desk construction's drop targets, as pure functions: from the state with the dragged item lifted out, a list\n * of zones with a priority, each able to make the state with the item dropped there.\n *\n * - Edge docks (`docks`, `docksFull`, `dockTear`): a rail (priority 1) takes the panel at the end of its dock (a\n * folded dock keeps it in the rail); a slot between sections (2) and the bottom dock (2) take it at that place;\n * with tear-off, the documents area (3) tears it off to float there.\n * - Tiling tree (`tree`): each slot an insertion produces (2), a side column's row or a dwindle region of the\n * center; an empty side column's edge (2).\n * - Strip (`strip`): between two columns (2) makes a new column; a gap inside a column (2) puts it there.\n * - Navigator, drawers (`navigator`, `drawers`): a tab strip (1) at the tab under the pointer, a folded side's rail\n * (1), a side's panel (3); the panel becomes the side's showing one.\n * - Palettes (`floatOver`, `floatAround`): a corner stack's column (2) at the place under the pointer; anywhere\n * else in the area (3), snapped to the area's edges (over the documents, also to other palettes' edges).\n */\nimport { centre, clamp, overlap, rect, type Point, type Rect, type Size } from \"../geometry\";\nimport type { Construction } from \"../dock/constructions\";\nimport { BAR, G, RAIL, TITLE, idOf, isDocKey, isPanelKey, panelKey, touch, type DeskState, type Layout, type Options, type Side } from \"../dock/model\";\nimport {\n DOCK,\n OVER_MARGIN,\n PALETTE_NARROW,\n TORN_W,\n TREE_COLUMN,\n dockGeometry,\n paletteArea,\n paletteWidth,\n stripColumns,\n stripGeometry,\n treeArea,\n treeFloats,\n treeRails,\n treeShown,\n treeTiles,\n} from \"../dock/parts\";\nimport type { Target } from \"../target\";\n\n/** A target's drop for a pointer: the state with the item there, a label, and a key (same key, same place). */\nexport interface Made {\n readonly state: DeskState;\n readonly label: string;\n readonly key: string;\n}\n\nexport interface DeskTarget extends Target {\n /** The drop with the pointer at `p`, holding the item at `grab` from its top-left corner. */\n readonly make: (p: Point, grab: Point) => Made;\n /** Where the keyboard stops in this target, in order (default: its zone's center). */\n readonly stops?: readonly Point[];\n}\n\n/** A made drop, laid out. */\nexport interface DeskDrop extends Made {\n readonly target: string;\n readonly layout: Layout;\n /** Where the item lands. */\n readonly slot: Rect;\n /** It lands hidden (folded into a rail). */\n readonly hidden: boolean;\n /** It floats where it is dropped: no room is made for it. */\n readonly free: boolean;\n}\n\nexport interface DeskTargetInput {\n readonly c: Construction;\n /** The state with the dragged item lifted out (`liftOut`). */\n readonly s0: DeskState;\n readonly key: string;\n readonly size: Size;\n readonly opt: Options;\n}\n\n/** How close (stage px) a free drop has to come to an edge to snap to it. */\nexport const SNAP = 18;\n\nconst insert = <T>(list: readonly T[], i: number, x: T): T[] => [...list.slice(0, i), x, ...list.slice(i)];\nconst Cap = (s: Side): string => (s === \"left\" ? \"Left\" : \"Right\");\nconst fixed = (state: DeskState, label: string) => (): Made => ({ state, label, key: label });\n\n/** Zones `count + 1` slots split between items at `mids` (their centers), from `lo` to `hi`: slot i's span. */\nconst slotSpan = (mids: readonly number[], lo: number, hi: number, i: number): [number, number] => [i === 0 ? lo : mids[i - 1]!, i === mids.length ? hi : mids[i]!];\n\n// --- edge docks ----------------------------------------------------------------------------------------------------\n\nfunction dockTargets({ c, s0, key, size, opt }: DeskTargetInput): DeskTarget[] {\n const cat = c.desk.catalog;\n const out: DeskTarget[] = [];\n const id = idOf(key);\n const mode = c.id === \"docksFull\" ? \"full\" : \"between\";\n const d = dockGeometry(cat, s0, size, opt, mode);\n const l0 = c.layout(s0, size, opt);\n const W = size.width;\n const H = size.height;\n for (const side of [\"left\", \"right\"] as const) {\n const railed = l0.items.get(`rail:${side}`);\n if (!railed) continue;\n const label = `${Cap(side)} rail: into the ${side} dock`;\n out.push({ id: `rail:${side}`, priority: 1, hit: railed.rect, make: fixed(touch({ ...s0, [side]: [...s0[side], id] }, id), label) });\n if (side === \"left\" ? !d.lOpen : !d.rOpen) continue;\n // The dock's slots: each section's halves belong to the slots above and below it.\n const shown = side === \"left\" ? s0.left : d.right;\n const mids = shown.map((p) => centre(l0.items.get(panelKey(p))!.rect).y);\n const x = side === \"left\" ? RAIL : W - RAIL - DOCK;\n for (let i = 0; i <= shown.length; i++) {\n const [y0, y1] = slotSpan(mids, 0, d.h, i);\n // Past the side list (the bottom dock is off and its panels show here): into the bottom list.\n const state = i <= s0[side].length ? { ...s0, [side]: insert(s0[side], i, id) } : { ...s0, bottom: insert(s0.bottom, i - s0[side].length, id) };\n out.push({ id: `dock:${side}:${i}`, priority: 2, hit: rect(x, y0, DOCK, y1 - y0), make: fixed(touch(state, id), `${Cap(side)} dock · slot ${i + 1}`) });\n }\n }\n if (opt.bottom !== \"off\") {\n const b = d.bottomRect ?? rect(d.x0, H - 40 - G, d.x1 - d.x0, 40);\n const mids = s0.bottom.map((p) => centre(l0.items.get(panelKey(p))!.rect).x);\n for (let i = 0; i <= s0.bottom.length; i++) {\n const [x0, x1] = slotSpan(mids, b.x, b.x + b.width, i);\n out.push({ id: `bottom:${i}`, priority: 2, hit: rect(x0, b.y - 24, x1 - x0, H - b.y + 24), make: fixed(touch({ ...s0, bottom: insert(s0.bottom, i, id) }, id), `Bottom dock · slot ${i + 1}`) });\n }\n }\n if (c.id === \"dockTear\") {\n // Torn off, floating where it is dropped; snapped to the documents' edges, kept on the stage.\n out.push({\n id: \"float\",\n priority: 3,\n free: true,\n hit: rect(d.x0, 0, d.x1 - d.x0, H),\n make: (p, grab) => {\n let x = p.x - grab.x;\n let y = p.y - grab.y;\n if (Math.abs(x - d.x0) < SNAP) x = d.x0;\n if (Math.abs(x + TORN_W - d.x1) < SNAP) x = d.x1 - TORN_W;\n if (Math.abs(y - G) < SNAP) y = G;\n x = clamp(x, 0, W - TORN_W);\n y = clamp(y, 0, H - Math.min(cat.natural(id), H));\n return { state: touch({ ...s0, torn: [...s0.torn, { id, at: { x, y } }] }, id), label: \"Float here\", key: `float:${Math.round(x)},${Math.round(y)}` };\n },\n });\n }\n return out;\n}\n\n// --- tiling tree ---------------------------------------------------------------------------------------------------\n\n/**\n * The tree's targets are the slots an insertion produces: inserting at place i of a side column gives row i of its\n * n + 1 rows, inserting at place i of the center gives dwindle's region i of n + 1. Those regions tile the column and\n * the center, so a zone is where the item lands (unless that makes the newest tile float, which reshapes the rest);\n * the label says where it lands in the tree as laid out, and what floats.\n */\nfunction treeTargets({ c, s0, key, size }: DeskTargetInput): DeskTarget[] {\n const cat = c.desk.catalog;\n const out: DeskTarget[] = [];\n const area = treeArea(size, s0);\n // The tree as tiled: a column folded to its rail offers its rail instead of its rows.\n const t = treeShown(s0);\n const rails = treeRails(s0);\n // A side column is narrower than a document's minimum: a document dropped into one would only float.\n const sides = !isDocKey(key);\n for (const [side, group] of [[\"left\", \"L\"], [\"right\", \"R\"]] as const) {\n if (!sides || !rails[side]) continue;\n const hit = rect(side === \"left\" ? 0 : size.width - RAIL, BAR, RAIL, size.height - BAR);\n out.push({ id: `rail:${side}`, priority: 1, hit, make: fixed({ ...s0, tree: { ...s0.tree, [group]: [...s0.tree[group], key] } }, `${Cap(side)} rail: into the ${side} column`) });\n }\n if (sides && s0.tree.L.length === 0) out.push({ id: \"edge:L\", priority: 2, hit: rect(area.x, area.y, 30, area.height), make: fixed({ ...s0, tree: { ...s0.tree, L: [key] } }, \"New left column\") });\n if (sides && s0.tree.R.length === 0) out.push({ id: \"edge:R\", priority: 2, hit: rect(area.x + area.width - 30, area.y, 30, area.height), make: fixed({ ...s0, tree: { ...s0.tree, R: [key] } }, \"New right column\") });\n const x0 = area.x + (t.L.length ? TREE_COLUMN + G : 0);\n const x1 = area.x + area.width - (t.R.length ? TREE_COLUMN + G : 0);\n const middle = rect(x0, area.y, x1 - x0, area.height);\n const NAME = { L: \"Left column\", R: \"Right column\", C: \"Centre\" } as const;\n const seen: { label: string; hit: Rect }[] = [];\n const sameZone = (a: Rect, b: Rect): boolean => Math.max(Math.abs(a.x - b.x), Math.abs(a.y - b.y), Math.abs(a.width - b.width), Math.abs(a.height - b.height)) < 0.5;\n for (const group of [\"L\", \"R\", \"C\"] as const) {\n const list = t[group];\n if (group !== \"C\" && list.length === 0) continue;\n if (group !== \"C\" && !sides) continue;\n for (let i = 0; i <= list.length; i++) {\n const state = { ...s0, tree: { ...s0.tree, [group]: insert(list, i, key) } };\n const shown = treeShown(state);\n // The slot as laid out once the tiles that break a minimum have floated (as laid out without them if it floats).\n const tiled = treeFloats(cat, shown, area);\n const zone = treeTiles(cat, tiled.floats.includes(key) ? shown : tiled.tree, area).get(key)!;\n const label = `${NAME[group]}, ${landing(c, shown, area, key, group, middle)}`;\n // Places that come out the same (around a floating tile) are one target: the keyboard stops there once.\n if (seen.some((o) => o.label === label && sameZone(o.hit, zone))) continue;\n seen.push({ label, hit: zone });\n out.push({ id: `tile:${group}:${i}`, priority: 2, hit: zone, make: fixed(state, label) });\n }\n }\n return out;\n}\n\n/**\n * Where `key` lands in the tree as laid out (after the newest tiles that break a minimum float): its row of its\n * column, or its region of the center; or that it floats, or what floats because of it.\n */\nfunction landing(c: Construction, tree: DeskState[\"tree\"], area: Rect, key: string, group: \"L\" | \"R\" | \"C\", middle: Rect): string {\n const cat = c.desk.catalog;\n const { tree: tiled, floats } = treeFloats(cat, tree, area);\n if (floats.includes(key)) return \"it floats there (too small)\";\n const others = floats.length ? `; ${floats.map(cat.title).join(\", \")} ${floats.length > 1 ? \"float\" : \"floats\"}` : \"\";\n if (group !== \"C\") return `row ${tiled[group].indexOf(key) + 1} of ${tiled[group].length}${others}`;\n const x0 = tiled.L.length ? middle.x : area.x;\n const x1 = tiled.R.length ? middle.x + middle.width : area.x + area.width;\n return `${regionName(treeTiles(cat, tiled, area).get(key)!, rect(x0, area.y, x1 - x0, area.height))}${others}`;\n}\n\n/** Where a region lies in `whole`, in words: \"all of it\", \"left half\", \"top right\"… */\nfunction regionName(r: Rect, whole: Rect): string {\n const near = (a: number, b: number): boolean => Math.abs(a - b) < 1;\n const h = near(r.width, whole.width) ? \"\" : near(r.x, whole.x) ? \"left\" : near(r.x + r.width, whole.x + whole.width) ? \"right\" : \"middle\";\n const v = near(r.height, whole.height) ? \"\" : near(r.y, whole.y) ? \"top\" : near(r.y + r.height, whole.y + whole.height) ? \"bottom\" : \"middle\";\n if (!h && !v) return \"all of it\";\n if (!v) return `${h} part`;\n if (!h) return `${v} part`;\n return `${v} ${h}`;\n}\n\n// --- scrolling strip -----------------------------------------------------------------------------------------------\n\nfunction stripTargets({ c, s0, key, size, opt }: DeskTargetInput): DeskTarget[] {\n const cat = c.desk.catalog;\n const out: DeskTarget[] = [];\n const g = stripGeometry(cat, s0, size);\n const l0 = c.layout(s0, size, opt);\n // The laid-out columns, each with the state column it comes from and where in it it starts.\n const parts: { owner: number; start: number; keys: string[] }[] = [];\n s0.cols.forEach((col, owner) => {\n let start = 0;\n for (const keys of stripColumns(cat, [col], g.h)) {\n parts.push({ owner, start, keys });\n start += keys.length;\n }\n });\n const newColumn = (at: number, label: string): Made => ({ state: { ...s0, cols: insert(s0.cols, at, [key]) }, label, key: label });\n if (parts.length === 0) return [{ id: \"strip\", priority: 3, hit: rect(0, g.y, size.width, g.h), make: () => newColumn(0, \"The strip\") }];\n // Between columns: a band across each boundary where a state column starts or ends.\n for (let k = 0; k <= parts.length; k++) {\n if (k < parts.length && parts[k]!.start !== 0) continue;\n const x = k < parts.length ? g.xs[k]! - G / 2 : g.xs[parts.length - 1]! + g.widths[parts.length - 1]! + G / 2;\n const at = k < parts.length ? parts[k]!.owner : s0.cols.length;\n const label = k === 0 ? \"New column at the start\" : k === parts.length ? \"New column at the end\" : `New column before ${cat.title(parts[k]!.keys[0]!)}`;\n out.push({ id: `between:${at}`, priority: 2, hit: rect(x - 28, g.y, 56, g.h), make: () => newColumn(at, label) });\n }\n // Inside a column: each item's halves belong to the gaps above and below it.\n parts.forEach((part, k) => {\n const mids = part.keys.map((pk) => centre(l0.items.get(pk)!.rect).y);\n for (let j = 0; j <= part.keys.length; j++) {\n const [y0, y1] = slotSpan(mids, g.y, g.y + g.h, j);\n const at = part.start + j;\n const cols = s0.cols.map((col, ci) => (ci === part.owner ? insert(col, at, key) : col));\n const label = `Into the column with ${cat.title(s0.cols[part.owner]![0]!)} · ${at + 1}`;\n out.push({ id: `into:${part.owner}:${at}`, priority: 2, hit: rect(g.xs[k]!, y0, g.widths[k]!, y1 - y0), make: fixed({ ...s0, cols }, label) });\n }\n });\n return out;\n}\n\n// --- navigator and drawers -----------------------------------------------------------------------------------------\n\nfunction tabTargets({ c, s0, key, size, opt }: DeskTargetInput): DeskTarget[] {\n const out: DeskTarget[] = [];\n const id = idOf(key);\n const l0 = c.layout(s0, size, opt);\n const onSide = (side: Side, i: number): DeskState => touch({ ...s0, [side]: insert(s0[side], i, id), active: { ...s0.active, [side]: id } }, id);\n for (const side of [\"left\", \"right\"] as const) {\n const list = s0[side];\n const tabs = l0.items.get(`tabs:${side}`);\n const railed = l0.items.get(`rail:${side}`);\n if (tabs && !tabs.hidden) {\n const r = tabs.rect;\n const tw = r.width / (list.length + 1);\n out.push({\n id: `tabs:${side}`,\n priority: 1,\n hit: rect(r.x, r.y - 4, r.width, r.height + 8),\n make: (p) => {\n const i = clamp(Math.floor((p.x - r.x) / tw), 0, list.length);\n const label = `${Cap(side)} tab strip · tab ${i + 1}`;\n return { state: onSide(side, i), label, key: label };\n },\n stops: Array.from({ length: list.length + 1 }, (_, i) => ({ x: r.x + tw * (i + 0.5), y: r.y + r.height / 2 })),\n });\n const panel = list.map((p) => l0.items.get(panelKey(p))).find((pl) => pl && !pl.hidden);\n if (panel) out.push({ id: `side:${side}`, priority: 3, hit: panel.rect, make: fixed(onSide(side, list.length), `${Cap(side)} side`) });\n }\n if (railed && !railed.hidden) out.push({ id: `rail:${side}`, priority: 1, hit: railed.rect, make: fixed(onSide(side, list.length), `${Cap(side)} rail`) });\n if (list.length === 0 && (!railed || railed.hidden)) {\n const hit = side === \"left\" ? rect(0, 0, 40, size.height) : rect(size.width - 40, 0, 40, size.height);\n out.push({ id: `edge:${side}`, priority: 2, hit, make: fixed(onSide(side, 0), `${Cap(side)} side`) });\n }\n }\n return out;\n}\n\n// --- palettes ------------------------------------------------------------------------------------------------------\n\nfunction paletteTargets({ c, s0, key, size, opt }: DeskTargetInput): DeskTarget[] {\n const cat = c.desk.catalog;\n const out: DeskTarget[] = [];\n const id = idOf(key);\n const { area } = paletteArea(size, opt);\n const m = c.id === \"floatOver\" ? OVER_MARGIN : 0;\n const pw = paletteWidth(size.width);\n const ph = s0.folded.includes(id) ? TITLE : cat.natural(id);\n const narrow = size.width < PALETTE_NARROW;\n const anchor = { left: area.x + m, right: area.x + area.width - m - pw };\n const l0 = c.layout(s0, size, opt);\n const rectOf = (pid: number): Rect => l0.items.get(panelKey(pid))!.rect;\n const tb = l0.items.get(\"toolbar\");\n const pillRect = tb?.look === \"pill\" ? tb.rect : null;\n // A corner stack's column, down to just under its last palette: it joins the stack at the place under the pointer.\n for (const side of narrow ? ([\"right\"] as const) : ([\"left\", \"right\"] as const)) {\n const ids = narrow ? [...s0.stacks.left, ...s0.stacks.right] : [...s0.stacks[side]];\n const bottom = ids.length ? Math.max(...ids.map((pid) => rectOf(pid).y + rectOf(pid).height)) : area.y + m;\n const at = (y: number): number => ids.filter((pid) => centre(rectOf(pid)).y < y).length;\n const join = (i: number): Made => {\n let stacks = s0.stacks;\n if (!narrow) stacks = { ...stacks, [side]: insert(stacks[side], i, id) };\n else if (i <= s0.stacks.left.length) stacks = { ...stacks, left: insert(stacks.left, i, id) };\n else stacks = { ...stacks, right: insert(stacks.right, i - s0.stacks.left.length, id) };\n const label = `${narrow ? \"The\" : Cap(side)} corner stack · ${i + 1}`;\n return { state: touch({ ...s0, stacks }, id), label, key: label };\n };\n out.push({\n id: `stack:${side}`,\n priority: 2,\n hit: rect(anchor[side], area.y, pw, bottom + 30 - area.y),\n make: (p) => join(at(p.y)),\n stops: [area.y + m, ...ids.map((pid) => rectOf(pid).y + rectOf(pid).height + G / 2)].map((y) => ({ x: anchor[side] + pw / 2, y })),\n });\n }\n // Anywhere: snapped to the area's edges (over the documents also to other palettes' edges), kept inside the area.\n out.push({\n id: \"free\",\n priority: 3,\n free: true,\n hit: area,\n make: (p, grab) => {\n let x = p.x - grab.x;\n let y = p.y - grab.y;\n const snaps: string[] = [];\n if (Math.abs(x - anchor.left) < SNAP) [x, snaps[0]] = [anchor.left, \"left edge\"];\n else if (Math.abs(x - anchor.right) < SNAP) [x, snaps[0]] = [anchor.right, \"right edge\"];\n if (Math.abs(y - (area.y + m)) < SNAP) [y, snaps[1]] = [area.y + m, \"top\"];\n else if (Math.abs(y + ph - (area.y + area.height - m)) < SNAP) [y, snaps[1]] = [area.y + area.height - m - ph, \"bottom\"];\n if (c.id === \"floatOver\") {\n for (const [k, pl] of l0.items) {\n if (!isPanelKey(k) || pl.hidden) continue;\n const o = pl.rect;\n if (snaps[0] === undefined && Math.abs(x - o.x) < SNAP) [x, snaps[0]] = [o.x, `${cat.title(k)}'s edge`];\n if (snaps[1] === undefined && Math.abs(y - (o.y + o.height + G)) < SNAP && x < o.x + o.width && x + pw > o.x) [y, snaps[1]] = [o.y + o.height + G, `under ${cat.title(k)}`];\n }\n }\n x = clamp(x, area.x, area.x + area.width - pw);\n y = clamp(y, area.y, area.y + area.height - ph);\n // Never under a floating pill: it moves clear, below a pill at the top, above one at the bottom.\n if (pillRect && overlap(rect(x, y, pw, ph), pillRect) > 0) {\n y = pillRect.y < size.height / 2 ? pillRect.y + pillRect.height + G : pillRect.y - G - ph;\n y = clamp(y, 0, size.height - ph);\n snaps[1] = \"clear of the toolbar\";\n }\n const how = snaps.filter(Boolean).join(\", \");\n return { state: touch({ ...s0, free: [...s0.free, { id, at: { x, y } }] }, id), label: how ? `Here · snapped to the ${how}` : \"Here\", key: `free:${Math.round(x)},${Math.round(y)}` };\n },\n });\n return out;\n}\n\n/** The drop targets for dragging `key` in construction `c`, in a fixed order (the keyboard's). */\nexport function deskTargets(input: DeskTargetInput): DeskTarget[] {\n switch (input.c.id) {\n case \"docks\":\n case \"docksFull\":\n case \"dockTear\":\n return dockTargets(input);\n case \"tree\":\n return treeTargets(input);\n case \"strip\":\n return stripTargets(input);\n case \"navigator\":\n case \"drawers\":\n return tabTargets(input);\n case \"floatOver\":\n case \"floatAround\":\n return paletteTargets(input);\n }\n}\n\n/** A target's drop for a pointer at `p` holding the item at `grab`, laid out: where the item lands. */\nexport function deskDrop(input: DeskTargetInput, target: DeskTarget, p: Point, grab: Point): DeskDrop {\n const made = target.make(p, grab);\n const layout = input.c.layout(made.state, input.size, input.opt);\n const placed = layout.items.get(input.key)!;\n return { ...made, key: `${target.id}|${made.key}`, target: target.id, layout, slot: placed.rect, hidden: !!placed.hidden, free: !!target.free };\n}\n","/**\n * Toolbar group targets: a host's insertion points (lines between groups, priority 2) and empty zones (priority 1),\n * and floating over the content (priority 3). A group's own place is home, never a target: its stretch comes back\n * in `own`, for the consumer to join to the drag's home. A place `allows` forbids is no host target either.\n */\nimport { rect, type Point, type Rect } from \"../geometry\";\nimport { ZONES, floatGroup, insertGroup, insertions, isOwnPlace, layoutHost, vertical, withoutGroup, type Arrangement, type GroupSize, type HostId, type HostSpec, type Place } from \"../toolbar\";\nimport type { Target } from \"../target\";\n\n/** How far a line's hit reaches beyond the host's thickness on each side; an empty zone's. */\nexport const LINE_REACH = 12;\nexport const ZONE_REACH = 4;\n\nexport interface ToolbarTarget<G extends string = string> extends Target {\n readonly label: string;\n readonly kind: \"line\" | \"zone\";\n readonly place: Place;\n /** It lands in a side edge's column. */\n readonly vertical: boolean;\n /** The insertion line (3 px, inset 4 px from the host's sides) in stage coordinates; for an empty zone, at its middle. */\n readonly line: Rect;\n /** Where the group lands, in stage coordinates: its rect in the host once the drop is made. */\n readonly slot: Rect;\n /** The arrangement a drop here makes. */\n readonly arrangement: Arrangement<G>;\n}\n\n/**\n * Where a group may go: a host's place, or floating. `hostTargets` leaves out a place it refuses; for floating, the\n * consumer adds `floatTarget` only when `allows(group, \"float\")`, so one rule covers both. `place.index` counts the\n * groups in that zone without the dragged one (as `insertGroup` does): 0 is before all of the others.\n */\nexport type Allows<G extends string> = (group: G, place: Place | \"float\") => boolean;\n\nexport interface HostTargetsInput<G extends string> {\n readonly group: G;\n /** The arrangement as it is, the group still in its place. */\n readonly arrangement: Arrangement<G>;\n readonly host: HostId;\n /** The host's top-left corner in stage coordinates. */\n readonly origin: Point;\n readonly spec: HostSpec<G>;\n readonly size: GroupSize<G>;\n /** A group's name in the labels (default: its id). */\n readonly label?: (g: G) => string;\n /** Where the group may go (default: anywhere). A place it may not go is left out. */\n readonly allows?: Allows<G>;\n /**\n * Where this host is, and how long, once a drop has made `arrangement` (a host may grow or appear when it gets a\n * group); default: where it is now. The targets' `slot`s are laid out there.\n */\n readonly hostAfter?: (arrangement: Arrangement<G>) => { readonly origin: Point; readonly spec: HostSpec<G> };\n}\n\n/** The targets a host offers a dragged group, zone by zone in order, and the stretches that are its own place. */\nexport function hostTargets<G extends string>(input: HostTargetsInput<G>): { targets: ToolbarTarget<G>[]; own: Rect[] } {\n const { group, arrangement: a, host: h, origin: o, spec } = input;\n const slotIn = (after: Arrangement<G>): Rect => {\n const at = input.hostAfter?.(after) ?? { origin: o, spec };\n const r = layoutHost(after[h], h, at.spec, input.size, after.collapsed).slots.get(group)!;\n return rect(at.origin.x + r.x, at.origin.y + r.y, r.width, r.height);\n };\n const a0 = withoutGroup(a, group);\n const l = layoutHost(a0[h], h, spec, input.size, a0.collapsed);\n const v = vertical(h);\n const T = spec.thickness;\n const across = (s0: number, s1: number, reach: number): Rect => (v ? rect(o.x - reach, o.y + s0, T + 2 * reach, s1 - s0) : rect(o.x + s0, o.y - reach, s1 - s0, T + 2 * reach));\n const targets: ToolbarTarget<G>[] = [];\n const own: Rect[] = [];\n const pts = insertions(a0[h], h, spec, l, input.label).sort((p, q) => ZONES.indexOf(p.zone) - ZONES.indexOf(q.zone) || p.index - q.index);\n for (const p of pts) {\n const [s0, s1] = p.span;\n const place: Place = { host: h, zone: p.zone, index: p.index };\n if (isOwnPlace(a, group, place)) {\n own.push(across(s0, s1, LINE_REACH));\n continue;\n }\n if (input.allows && !input.allows(group, place)) continue;\n const after = insertGroup(a, group, h, p.zone, p.index);\n targets.push({\n id: `g:${h}:${p.zone}:${p.index}`,\n priority: p.empty ? 1 : 2,\n hit: p.empty ? across(s0, s1, ZONE_REACH) : across(s0, s1, LINE_REACH),\n label: p.label,\n kind: p.empty ? \"zone\" : \"line\",\n place,\n vertical: v,\n line: v ? rect(o.x + 4, o.y + p.at - 1.5, T - 8, 3) : rect(o.x + p.at - 1.5, o.y + 4, 3, T - 8),\n slot: slotIn(after),\n arrangement: after,\n });\n }\n return { targets, own };\n}\n\nexport interface ToolbarFloatTarget<G extends string = string> extends Target {\n readonly label: string;\n readonly kind: \"float\";\n /** The group's top-left corner relative to the stage, and the arrangement, for a drop with the pointer at `p`. */\n readonly make: (p: Point, grab: Point) => Arrangement<G>;\n}\n\nexport interface FloatTargetInput<G extends string> {\n readonly group: G;\n readonly arrangement: Arrangement<G>;\n /** The content the group floats over, in stage coordinates. */\n readonly stage: Rect;\n /** The group's size as it floats. */\n readonly width: number;\n readonly height: number;\n}\n\n/**\n * Floating over the content (`stage`, in stage coordinates): the group's top-left corner kept on the stage. A\n * group that may not float simply gets no float target: add it only when your rule allows it, with the same\n * `allows` you give `hostTargets`: `...(allows(group, \"float\") ? [floatTarget(input)] : [])`.\n */\nexport function floatTarget<G extends string>(input: FloatTargetInput<G>): ToolbarFloatTarget<G> {\n const { group, arrangement, stage } = input;\n return {\n id: \"g:float\",\n priority: 3,\n free: true,\n hit: stage,\n label: \"Float here\",\n kind: \"float\",\n // Kept on the stage; a group larger than the stage keeps its top-left corner on the stage's.\n make: (p, grab) => {\n const x = Math.max(0, Math.min(p.x - grab.x - stage.x, stage.width - input.width));\n const y = Math.max(0, Math.min(p.y - grab.y - stage.y, stage.height - input.height));\n return floatGroup(arrangement, group, x, y);\n },\n };\n}\n","/**\n * Keyboard stops: every place a toolbar group can go, in one list in reading order, for the arrow keys and a\n * \"Move to\" menu alike. A consumer steps through the list; it never parses target ids.\n */\nimport { centre, type Point } from \"../geometry\";\nimport { panelStops, type PanelStop, type PanelStopsOptions, type PanelTarget } from \"../panels/targets\";\nimport { HOST_LABEL, ZONES, zoneLabel, type Arrangement, type HostId, type Place } from \"../toolbar\";\nimport type { ToolbarFloatTarget, ToolbarTarget } from \"./toolbar\";\n\n/** The hosts in reading order: the title bar, the top bar, the left edge, the right edge, the bottom bar. */\nexport const HOST_READING_ORDER: readonly HostId[] = [\"title\", \"top\", \"left\", \"right\", \"bottom\"];\n\nexport interface KeyboardStop<G extends string = string> {\n /** The target's id (\"home\" for the group's own place). */\n readonly id: string;\n readonly label: string;\n /** Where in a host it is; null for floating. */\n readonly place: Place | null;\n /** The arrangement a move here makes (the current one for home). */\n readonly arrangement: Arrangement<G>;\n /** The group's own place: where the keyboard starts, and a move there changes nothing. */\n readonly home: boolean;\n}\n\nexport interface KeyboardStopsOptions<G extends string> {\n /** The group's own place, as a stop of its own in its reading-order position (the targets leave it out). */\n readonly home?: { readonly place: Place; readonly arrangement: Arrangement<G>; readonly label?: string };\n /**\n * Floating targets as stops at the end (default: left out). `at` is where the pointer would drop it and `grab`\n * where it holds the group (default: the float target's middle, the group's top-left corner).\n */\n readonly floats?: boolean | { readonly at: Point; readonly grab?: Point };\n}\n\nconst isFloat = <G extends string>(t: ToolbarTarget<G> | ToolbarFloatTarget<G>): t is ToolbarFloatTarget<G> => t.kind === \"float\";\n\n/** Reading order of a place: host, then zone, then index. */\nconst rank = (p: Place): number => HOST_READING_ORDER.indexOf(p.host) * 3000 + ZONES.indexOf(p.zone) * 1000 + p.index;\n\nconst isPanelTargets = (targets: readonly object[], options: { readonly home?: object }): boolean => targets.some((t) => \"panel\" in t) || (targets.length === 0 && !!options.home && \"state\" in options.home);\n\n/**\n * The places a group can go, in reading order: toolbar areas title → top → left → right → bottom, zones start → center →\n * end, then each insertion point in order; the group's own place among them when `home` is given; floating targets\n * at the end only when `floats` asks for them. One list serves the arrow keys and a \"Move to\" menu.\n *\n * Given panel targets (`@n-uf/placement/panels`' `panelTargets`), the same for a panel: left to right across the\n * stage (the left rail, the left side's lines and columns outer to inner, the right side's inner to outer, the right\n * rail), floating last when asked; each stop carries the state a move there makes (`panelStops`).\n */\nexport function keyboardStops(targets: readonly PanelTarget[], options?: PanelStopsOptions): PanelStop[];\nexport function keyboardStops<G extends string>(targets: readonly (ToolbarTarget<G> | ToolbarFloatTarget<G>)[], options?: KeyboardStopsOptions<G>): KeyboardStop<G>[];\nexport function keyboardStops<G extends string>(\n targets: readonly (ToolbarTarget<G> | ToolbarFloatTarget<G>)[] | readonly PanelTarget[],\n options: KeyboardStopsOptions<G> | PanelStopsOptions = {},\n): KeyboardStop<G>[] | PanelStop[] {\n if (isPanelTargets(targets, options)) return panelStops(targets as readonly PanelTarget[], options as PanelStopsOptions);\n return toolbarStops(targets as readonly (ToolbarTarget<G> | ToolbarFloatTarget<G>)[], options as KeyboardStopsOptions<G>);\n}\n\nfunction toolbarStops<G extends string>(targets: readonly (ToolbarTarget<G> | ToolbarFloatTarget<G>)[], options: KeyboardStopsOptions<G>): KeyboardStop<G>[] {\n const placed: KeyboardStop<G>[] = [];\n const floating: KeyboardStop<G>[] = [];\n for (const t of targets) {\n if (!isFloat(t)) {\n placed.push({ id: t.id, label: t.label, place: t.place, arrangement: t.arrangement, home: false });\n continue;\n }\n if (!options.floats) continue;\n const at = options.floats === true ? centre(t.hit) : options.floats.at;\n const grab = options.floats === true ? { x: 0, y: 0 } : (options.floats.grab ?? { x: 0, y: 0 });\n floating.push({ id: t.id, label: t.label, place: null, arrangement: t.make(at, grab), home: false });\n }\n const h = options.home;\n if (h) placed.push({ id: \"home\", label: h.label ?? `${HOST_LABEL[h.place.host]} · ${zoneLabel(h.place.host, h.place.zone)} · current place`, place: h.place, arrangement: h.arrangement, home: true });\n placed.sort((a, b) => rank(a.place!) - rank(b.place!));\n return [...placed, ...floating];\n}\n","/**\n * A pane's drop zones: a center rectangle (put it in the pane's place, merge or swap) and four edge trapezoids (put\n * it beside the pane on that side), formed by the diagonals from each pane corner to the nearest corner of the\n * center. The five zones tile the pane with no gaps and no overlaps.\n *\n * Meant for `@n-uf/motion/drag`'s `placeOf(target, point, previous)`: one target per pane, its place the zone under\n * the pointer, the previous zone held for `hysteresis` px past its boundary so a pointer resting on a boundary\n * doesn't flicker. A zone that takes no drop is the consumer's to answer with a null place.\n */\nimport { clamp, type Point, type Rect, type Size } from \"../geometry\";\n\nexport type PaneZone = \"center\" | \"top\" | \"right\" | \"bottom\" | \"left\";\n\n/** The edge zones in their tie-break order: at an exact diagonal the first wins (a corner resolves to `top`). */\nexport const PANE_EDGES: readonly Exclude<PaneZone, \"center\">[] = [\"top\", \"right\", \"bottom\", \"left\"];\n\nexport interface PaneZoneOptions {\n /** The center rectangle's share of each pane axis (0.05 to 0.95); `centreX` / `centreY` override one axis. */\n readonly centre?: number;\n readonly centreX?: number;\n readonly centreY?: number;\n /** The least the center spans on either axis, px (a small pane keeps a usable center). */\n readonly centreMin?: number;\n /** How far past its boundary the previous zone holds, px. */\n readonly hysteresis?: number;\n /** Device pixels per px: the center's edges snap to that grid, as the browser draws them. */\n readonly pixelRatio?: number;\n}\n\nexport const PANE_ZONE_DEFAULTS: Required<Omit<PaneZoneOptions, \"centreX\" | \"centreY\">> = { centre: 0.34, centreMin: 24, hysteresis: 6, pixelRatio: 1 };\n\n/** The center rectangle of a pane of `size`, in pane-local px (origin at the pane's top-left corner). */\nexport interface PaneCentre {\n readonly width: number;\n readonly height: number;\n readonly left: number;\n readonly top: number;\n readonly right: number;\n readonly bottom: number;\n}\n\nconst snap = (v: number, ratio: number): number => Math.round(v * ratio) / ratio;\n\n/** Where the center rectangle of a pane of `size` lies, by these options. */\nexport function paneCentre(size: Size, options: PaneZoneOptions = {}): PaneCentre {\n const o = { ...PANE_ZONE_DEFAULTS, ...options };\n const width = Math.max(0, size.width);\n const height = Math.max(0, size.height);\n const ratio = o.pixelRatio > 0 ? o.pixelRatio : 1;\n const rx = clamp(o.centreX ?? o.centre, 0.05, 0.95);\n const ry = clamp(o.centreY ?? o.centre, 0.05, 0.95);\n const cw = Math.min(width, Math.max(width * rx, Math.min(o.centreMin, width)));\n const ch = Math.min(height, Math.max(height * ry, Math.min(o.centreMin, height)));\n 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) };\n}\n\n/** How deep past the center a point is toward each edge, as a share of that edge's band (positive: in that band). */\nfunction depths(p: Point, c: PaneCentre): { zone: Exclude<PaneZone, \"center\">; depth: number }[] {\n return [\n { zone: \"top\", depth: (c.top - p.y) / Math.max(c.top, 1) },\n { zone: \"right\", depth: (p.x - c.right) / Math.max(c.width - c.right, 1) },\n { zone: \"bottom\", depth: (p.y - c.bottom) / Math.max(c.height - c.bottom, 1) },\n { zone: \"left\", depth: (c.left - p.x) / Math.max(c.left, 1) },\n ];\n}\n\n/** The zone a pane-local point is in, by position alone. */\nfunction rawZone(p: Point, c: PaneCentre): PaneZone {\n if (p.x >= c.left && p.x <= c.right && p.y >= c.top && p.y <= c.bottom) return \"center\";\n let best: PaneZone = \"center\";\n let deepest = 0;\n for (const d of depths(p, c)) {\n if (d.depth > deepest) {\n deepest = d.depth;\n best = d.zone;\n }\n }\n return best;\n}\n\n/** `p` moved `by` px into `zone` (toward the pane's middle for the center). */\nfunction toward(p: Point, zone: PaneZone, by: number, c: PaneCentre): Point {\n if (zone === \"left\") return { x: p.x - by, y: p.y };\n if (zone === \"right\") return { x: p.x + by, y: p.y };\n if (zone === \"top\") return { x: p.x, y: p.y - by };\n if (zone === \"bottom\") return { x: p.x, y: p.y + by };\n const dx = c.width / 2 - p.x;\n const dy = c.height / 2 - p.y;\n const len = Math.hypot(dx, dy);\n if (len <= by || len === 0) return { x: c.width / 2, y: c.height / 2 };\n return { x: p.x + (dx / len) * by, y: p.y + (dy / len) * by };\n}\n\n/**\n * The zone of `rect` (a pane, in the same coordinates as `point`) the point is in. With a `previous` zone, the point\n * has to be `hysteresis` px past that zone's boundary before the zone changes: no time-based debounce, only geometry.\n */\nexport function paneZone(rect: Rect, point: Point, previous: PaneZone | null = null, options: PaneZoneOptions = {}): PaneZone {\n const c = paneCentre(rect, options);\n const p = { x: point.x - rect.x, y: point.y - rect.y };\n const raw = rawZone(p, c);\n const by = Math.max(0, options.hysteresis ?? PANE_ZONE_DEFAULTS.hysteresis);\n if (previous === null || by === 0 || previous === raw) return raw;\n return rawZone(toward(p, previous, by, c), c) === previous ? previous : raw;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEO,IAAM,OAAO;AAEpB,IAAM,SAAS,CAAI,MAAoB,GAAW,MAAc,CAAC,GAAG,KAAK,MAAM,GAAG,CAAC,GAAG,GAAG,GAAG,KAAK,MAAM,CAAC,CAAC;AACzG,IAAM,MAAM,CAAC,MAAqB,MAAM,SAAS,SAAS;AAC1D,IAAM,QAAQ,CAAC,OAAkB,UAAkB,OAAa,EAAE,OAAO,OAAO,KAAK,MAAM;AAG3F,IAAM,WAAW,CAAC,MAAyB,IAAY,IAAY,MAAgC,CAAC,MAAM,IAAI,KAAK,KAAK,IAAI,CAAC,GAAI,MAAM,KAAK,SAAS,KAAK,KAAK,CAAC,CAAE;AAIlK,SAAS,YAAY,EAAE,GAAG,IAAI,KAAK,MAAM,IAAI,GAAkC;AAC7E,QAAM,MAAM,EAAE,KAAK;AACnB,QAAM,MAAoB,CAAC;AAC3B,QAAM,KAAK,KAAK,GAAG;AACnB,QAAM,OAAO,EAAE,OAAO,cAAc,SAAS;AAC7C,QAAM,IAAI,aAAa,KAAK,IAAI,MAAM,KAAK,IAAI;AAC/C,QAAM,KAAK,EAAE,OAAO,IAAI,MAAM,GAAG;AACjC,QAAM,IAAI,KAAK;AACf,QAAM,IAAI,KAAK;AACf,aAAW,QAAQ,CAAC,QAAQ,OAAO,GAAY;AAC7C,UAAM,SAAS,GAAG,MAAM,IAAI,QAAQ,IAAI,EAAE;AAC1C,QAAI,CAAC,OAAQ;AACb,UAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,mBAAmB,IAAI;AACjD,QAAI,KAAK,EAAE,IAAI,QAAQ,IAAI,IAAI,UAAU,GAAG,KAAK,OAAO,MAAM,MAA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GAAG;AACjD,MAAI,SAAS,SAAU,QAAO,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,IAAI,GAAG;AACpD,QAAM,KAAK,EAAE,QAAQ,IAAI,EAAE;AAC3B,QAAM,KAAK,EAAE,SAAS,IAAI,EAAE;AAC5B,QAAM,MAAM,KAAK,MAAM,IAAI,EAAE;AAC7B,MAAI,OAAO,MAAM,QAAQ,EAAG,QAAO,EAAE,GAAG,EAAE,QAAQ,GAAG,GAAG,EAAE,SAAS,EAAE;AACrE,SAAO,EAAE,GAAG,EAAE,IAAK,KAAK,MAAO,IAAI,GAAG,EAAE,IAAK,KAAK,MAAO,GAAG;AAC9D;AAMO,SAAS,SAASA,OAAY,OAAc,WAA4B,MAAM,UAA2B,CAAC,GAAa;AAC5H,QAAM,IAAI,WAAWA,OAAM,OAAO;AAClC,QAAM,IAAI,EAAE,GAAG,MAAM,IAAIA,MAAK,GAAG,GAAG,MAAM,IAAIA,MAAK,EAAE;AACrD,QAAM,MAAM,QAAQ,GAAG,CAAC;AACxB,QAAM,KAAK,KAAK,IAAI,GAAG,QAAQ,cAAc,mBAAmB,UAAU;AAC1E,MAAI,aAAa,QAAQ,OAAO,KAAK,aAAa,IAAK,QAAO;AAC9D,SAAO,QAAQ,OAAO,GAAG,UAAU,IAAI,CAAC,GAAG,CAAC,MAAM,WAAW,WAAW;AAC1E;","names":["rect"]}
|
|
1
|
+
{"version":3,"sources":["../src/targets/desk.ts","../src/targets/toolbar.ts","../src/targets/stops.ts","../src/targets/zones.ts"],"sourcesContent":["/**\n * Each desk construction's drop targets, as pure functions: from the state with the dragged item lifted out, a list\n * of zones with a priority, each able to make the state with the item dropped there.\n *\n * - Edge docks (`docks`, `docksFull`, `dockTear`): a rail (priority 1) takes the panel at the end of its dock (a\n * folded dock keeps it in the rail); a slot between sections (2) and the bottom dock (2) take it at that place;\n * with tear-off, the documents area (3) tears it off to float there.\n * - Tiling tree (`tree`): each slot an insertion produces (2), a side column's row or a dwindle region of the\n * center; an empty side column's edge (2).\n * - Strip (`strip`): between two columns (2) makes a new column; a gap inside a column (2) puts it there.\n * - Navigator, drawers (`navigator`, `drawers`): a tab strip (1) at the tab under the pointer, a folded side's rail\n * (1), a side's panel (3); the panel becomes the side's showing one.\n * - Palettes (`floatOver`, `floatAround`): a corner stack's column (2) at the place under the pointer; anywhere\n * else in the area (3), snapped to the area's edges (over the documents, also to other palettes' edges).\n */\nimport { centre, clamp, overlap, rect, type Point, type Rect, type Size } from \"../geometry\";\nimport type { Construction } from \"../dock/constructions\";\nimport { BAR, G, RAIL, TITLE, idOf, isDocKey, isPanelKey, panelKey, touch, type DeskState, type Layout, type Options, type Side } from \"../dock/model\";\nimport {\n DOCK,\n OVER_MARGIN,\n PALETTE_NARROW,\n TORN_W,\n TREE_COLUMN,\n dockGeometry,\n paletteArea,\n paletteWidth,\n stripColumns,\n stripGeometry,\n treeArea,\n treeFloats,\n treeRails,\n treeShown,\n treeTiles,\n} from \"../dock/parts\";\nimport type { Target } from \"../target\";\n\n/** A target's drop for a pointer: the state with the item there, a label, and a key (same key, same place). */\nexport interface Made {\n readonly state: DeskState;\n readonly label: string;\n readonly key: string;\n}\n\nexport interface DeskTarget extends Target {\n /** The drop with the pointer at `p`, holding the item at `grab` from its top-left corner. */\n readonly make: (p: Point, grab: Point) => Made;\n /** Where the keyboard stops in this target, in order (default: its zone's center). */\n readonly stops?: readonly Point[];\n}\n\n/** A made drop, laid out. */\nexport interface DeskDrop extends Made {\n readonly target: string;\n readonly layout: Layout;\n /** Where the item lands. */\n readonly slot: Rect;\n /** It lands hidden (folded into a rail). */\n readonly hidden: boolean;\n /** It floats where it is dropped: no room is made for it. */\n readonly free: boolean;\n}\n\nexport interface DeskTargetInput {\n readonly c: Construction;\n /** The state with the dragged item lifted out (`liftOut`). */\n readonly s0: DeskState;\n readonly key: string;\n readonly size: Size;\n readonly opt: Options;\n}\n\n/** How close (stage px) a free drop has to come to an edge to snap to it. */\nexport const SNAP = 18;\n\nconst insert = <T>(list: readonly T[], i: number, x: T): T[] => [...list.slice(0, i), x, ...list.slice(i)];\nconst Cap = (s: Side): string => (s === \"left\" ? \"Left\" : \"Right\");\nconst fixed = (state: DeskState, label: string) => (): Made => ({ state, label, key: label });\n\n/** Zones `count + 1` slots split between items at `mids` (their centers), from `lo` to `hi`: slot i's span. */\nconst slotSpan = (mids: readonly number[], lo: number, hi: number, i: number): [number, number] => [i === 0 ? lo : mids[i - 1]!, i === mids.length ? hi : mids[i]!];\n\n// --- edge docks ----------------------------------------------------------------------------------------------------\n\nfunction dockTargets({ c, s0, key, size, opt }: DeskTargetInput): DeskTarget[] {\n const cat = c.desk.catalog;\n const out: DeskTarget[] = [];\n const id = idOf(key);\n const mode = c.id === \"docksFull\" ? \"full\" : \"between\";\n const d = dockGeometry(cat, s0, size, opt, mode);\n const l0 = c.layout(s0, size, opt);\n const W = size.width;\n const H = size.height;\n for (const side of [\"left\", \"right\"] as const) {\n const railed = l0.items.get(`rail:${side}`);\n if (!railed) continue;\n const label = `${Cap(side)} rail: into the ${side} dock`;\n out.push({ id: `rail:${side}`, priority: 1, hit: railed.rect, make: fixed(touch({ ...s0, [side]: [...s0[side], id] }, id), label) });\n if (side === \"left\" ? !d.lOpen : !d.rOpen) continue;\n // The dock's slots: each section's halves belong to the slots above and below it.\n const shown = side === \"left\" ? s0.left : d.right;\n const mids = shown.map((p) => centre(l0.items.get(panelKey(p))!.rect).y);\n const x = side === \"left\" ? RAIL : W - RAIL - DOCK;\n for (let i = 0; i <= shown.length; i++) {\n const [y0, y1] = slotSpan(mids, 0, d.h, i);\n // Past the side list (the bottom dock is off and its panels show here): into the bottom list.\n const state = i <= s0[side].length ? { ...s0, [side]: insert(s0[side], i, id) } : { ...s0, bottom: insert(s0.bottom, i - s0[side].length, id) };\n out.push({ id: `dock:${side}:${i}`, priority: 2, hit: rect(x, y0, DOCK, y1 - y0), make: fixed(touch(state, id), `${Cap(side)} dock · slot ${i + 1}`) });\n }\n }\n if (opt.bottom !== \"off\") {\n const b = d.bottomRect ?? rect(d.x0, H - 40 - G, d.x1 - d.x0, 40);\n const mids = s0.bottom.map((p) => centre(l0.items.get(panelKey(p))!.rect).x);\n for (let i = 0; i <= s0.bottom.length; i++) {\n const [x0, x1] = slotSpan(mids, b.x, b.x + b.width, i);\n out.push({ id: `bottom:${i}`, priority: 2, hit: rect(x0, b.y - 24, x1 - x0, H - b.y + 24), make: fixed(touch({ ...s0, bottom: insert(s0.bottom, i, id) }, id), `Bottom dock · slot ${i + 1}`) });\n }\n }\n if (c.id === \"dockTear\") {\n // Torn off, floating where it is dropped; snapped to the documents' edges, kept on the stage.\n out.push({\n id: \"float\",\n priority: 3,\n free: true,\n hit: rect(d.x0, 0, d.x1 - d.x0, H),\n make: (p, grab) => {\n let x = p.x - grab.x;\n let y = p.y - grab.y;\n if (Math.abs(x - d.x0) < SNAP) x = d.x0;\n if (Math.abs(x + TORN_W - d.x1) < SNAP) x = d.x1 - TORN_W;\n if (Math.abs(y - G) < SNAP) y = G;\n x = clamp(x, 0, W - TORN_W);\n y = clamp(y, 0, H - Math.min(cat.natural(id), H));\n return { state: touch({ ...s0, torn: [...s0.torn, { id, at: { x, y } }] }, id), label: \"Float here\", key: `float:${Math.round(x)},${Math.round(y)}` };\n },\n });\n }\n return out;\n}\n\n// --- tiling tree ---------------------------------------------------------------------------------------------------\n\n/**\n * The tree's targets are the slots an insertion produces: inserting at place i of a side column gives row i of its\n * n + 1 rows, inserting at place i of the center gives dwindle's region i of n + 1. Those regions tile the column and\n * the center, so a zone is where the item lands (unless that makes the newest tile float, which reshapes the rest);\n * the label says where it lands in the tree as laid out, and what floats.\n */\nfunction treeTargets({ c, s0, key, size }: DeskTargetInput): DeskTarget[] {\n const cat = c.desk.catalog;\n const out: DeskTarget[] = [];\n const area = treeArea(size, s0);\n // The tree as tiled: a column folded to its rail offers its rail instead of its rows.\n const t = treeShown(s0);\n const rails = treeRails(s0);\n // A side column is narrower than a document's minimum: a document dropped into one would only float.\n const sides = !isDocKey(key);\n for (const [side, group] of [[\"left\", \"L\"], [\"right\", \"R\"]] as const) {\n if (!sides || !rails[side]) continue;\n const hit = rect(side === \"left\" ? 0 : size.width - RAIL, BAR, RAIL, size.height - BAR);\n out.push({ id: `rail:${side}`, priority: 1, hit, make: fixed({ ...s0, tree: { ...s0.tree, [group]: [...s0.tree[group], key] } }, `${Cap(side)} rail: into the ${side} column`) });\n }\n if (sides && s0.tree.L.length === 0) out.push({ id: \"edge:L\", priority: 2, hit: rect(area.x, area.y, 30, area.height), make: fixed({ ...s0, tree: { ...s0.tree, L: [key] } }, \"New left column\") });\n if (sides && s0.tree.R.length === 0) out.push({ id: \"edge:R\", priority: 2, hit: rect(area.x + area.width - 30, area.y, 30, area.height), make: fixed({ ...s0, tree: { ...s0.tree, R: [key] } }, \"New right column\") });\n const x0 = area.x + (t.L.length ? TREE_COLUMN + G : 0);\n const x1 = area.x + area.width - (t.R.length ? TREE_COLUMN + G : 0);\n const middle = rect(x0, area.y, x1 - x0, area.height);\n const NAME = { L: \"Left column\", R: \"Right column\", C: \"Centre\" } as const;\n const seen: { label: string; hit: Rect }[] = [];\n const sameZone = (a: Rect, b: Rect): boolean => Math.max(Math.abs(a.x - b.x), Math.abs(a.y - b.y), Math.abs(a.width - b.width), Math.abs(a.height - b.height)) < 0.5;\n for (const group of [\"L\", \"R\", \"C\"] as const) {\n const list = t[group];\n if (group !== \"C\" && list.length === 0) continue;\n if (group !== \"C\" && !sides) continue;\n for (let i = 0; i <= list.length; i++) {\n const state = { ...s0, tree: { ...s0.tree, [group]: insert(list, i, key) } };\n const shown = treeShown(state);\n // The slot as laid out once the tiles that break a minimum have floated (as laid out without them if it floats).\n const tiled = treeFloats(cat, shown, area);\n const zone = treeTiles(cat, tiled.floats.includes(key) ? shown : tiled.tree, area).get(key)!;\n const label = `${NAME[group]}, ${landing(c, shown, area, key, group, middle)}`;\n // Places that come out the same (around a floating tile) are one target: the keyboard stops there once.\n if (seen.some((o) => o.label === label && sameZone(o.hit, zone))) continue;\n seen.push({ label, hit: zone });\n out.push({ id: `tile:${group}:${i}`, priority: 2, hit: zone, make: fixed(state, label) });\n }\n }\n return out;\n}\n\n/**\n * Where `key` lands in the tree as laid out (after the newest tiles that break a minimum float): its row of its\n * column, or its region of the center; or that it floats, or what floats because of it.\n */\nfunction landing(c: Construction, tree: DeskState[\"tree\"], area: Rect, key: string, group: \"L\" | \"R\" | \"C\", middle: Rect): string {\n const cat = c.desk.catalog;\n const { tree: tiled, floats } = treeFloats(cat, tree, area);\n if (floats.includes(key)) return \"it floats there (too small)\";\n const others = floats.length ? `; ${floats.map(cat.title).join(\", \")} ${floats.length > 1 ? \"float\" : \"floats\"}` : \"\";\n if (group !== \"C\") return `row ${tiled[group].indexOf(key) + 1} of ${tiled[group].length}${others}`;\n const x0 = tiled.L.length ? middle.x : area.x;\n const x1 = tiled.R.length ? middle.x + middle.width : area.x + area.width;\n return `${regionName(treeTiles(cat, tiled, area).get(key)!, rect(x0, area.y, x1 - x0, area.height))}${others}`;\n}\n\n/** Where a region lies in `whole`, in words: \"all of it\", \"left half\", \"top right\"… */\nfunction regionName(r: Rect, whole: Rect): string {\n const near = (a: number, b: number): boolean => Math.abs(a - b) < 1;\n const h = near(r.width, whole.width) ? \"\" : near(r.x, whole.x) ? \"left\" : near(r.x + r.width, whole.x + whole.width) ? \"right\" : \"middle\";\n const v = near(r.height, whole.height) ? \"\" : near(r.y, whole.y) ? \"top\" : near(r.y + r.height, whole.y + whole.height) ? \"bottom\" : \"middle\";\n if (!h && !v) return \"all of it\";\n if (!v) return `${h} part`;\n if (!h) return `${v} part`;\n return `${v} ${h}`;\n}\n\n// --- scrolling strip -----------------------------------------------------------------------------------------------\n\nfunction stripTargets({ c, s0, key, size, opt }: DeskTargetInput): DeskTarget[] {\n const cat = c.desk.catalog;\n const out: DeskTarget[] = [];\n const g = stripGeometry(cat, s0, size);\n const l0 = c.layout(s0, size, opt);\n // The laid-out columns, each with the state column it comes from and where in it it starts.\n const parts: { owner: number; start: number; keys: string[] }[] = [];\n s0.cols.forEach((col, owner) => {\n let start = 0;\n for (const keys of stripColumns(cat, [col], g.h)) {\n parts.push({ owner, start, keys });\n start += keys.length;\n }\n });\n const newColumn = (at: number, label: string): Made => ({ state: { ...s0, cols: insert(s0.cols, at, [key]) }, label, key: label });\n if (parts.length === 0) return [{ id: \"strip\", priority: 3, hit: rect(0, g.y, size.width, g.h), make: () => newColumn(0, \"The strip\") }];\n // Between columns: a band across each boundary where a state column starts or ends.\n for (let k = 0; k <= parts.length; k++) {\n if (k < parts.length && parts[k]!.start !== 0) continue;\n const x = k < parts.length ? g.xs[k]! - G / 2 : g.xs[parts.length - 1]! + g.widths[parts.length - 1]! + G / 2;\n const at = k < parts.length ? parts[k]!.owner : s0.cols.length;\n const label = k === 0 ? \"New column at the start\" : k === parts.length ? \"New column at the end\" : `New column before ${cat.title(parts[k]!.keys[0]!)}`;\n out.push({ id: `between:${at}`, priority: 2, hit: rect(x - 28, g.y, 56, g.h), make: () => newColumn(at, label) });\n }\n // Inside a column: each item's halves belong to the gaps above and below it.\n parts.forEach((part, k) => {\n const mids = part.keys.map((pk) => centre(l0.items.get(pk)!.rect).y);\n for (let j = 0; j <= part.keys.length; j++) {\n const [y0, y1] = slotSpan(mids, g.y, g.y + g.h, j);\n const at = part.start + j;\n const cols = s0.cols.map((col, ci) => (ci === part.owner ? insert(col, at, key) : col));\n const label = `Into the column with ${cat.title(s0.cols[part.owner]![0]!)} · ${at + 1}`;\n out.push({ id: `into:${part.owner}:${at}`, priority: 2, hit: rect(g.xs[k]!, y0, g.widths[k]!, y1 - y0), make: fixed({ ...s0, cols }, label) });\n }\n });\n return out;\n}\n\n// --- navigator and drawers -----------------------------------------------------------------------------------------\n\nfunction tabTargets({ c, s0, key, size, opt }: DeskTargetInput): DeskTarget[] {\n const out: DeskTarget[] = [];\n const id = idOf(key);\n const l0 = c.layout(s0, size, opt);\n const onSide = (side: Side, i: number): DeskState => touch({ ...s0, [side]: insert(s0[side], i, id), active: { ...s0.active, [side]: id } }, id);\n for (const side of [\"left\", \"right\"] as const) {\n const list = s0[side];\n const tabs = l0.items.get(`tabs:${side}`);\n const railed = l0.items.get(`rail:${side}`);\n if (tabs && !tabs.hidden) {\n const r = tabs.rect;\n const tw = r.width / (list.length + 1);\n out.push({\n id: `tabs:${side}`,\n priority: 1,\n hit: rect(r.x, r.y - 4, r.width, r.height + 8),\n make: (p) => {\n const i = clamp(Math.floor((p.x - r.x) / tw), 0, list.length);\n const label = `${Cap(side)} tab strip · tab ${i + 1}`;\n return { state: onSide(side, i), label, key: label };\n },\n stops: Array.from({ length: list.length + 1 }, (_, i) => ({ x: r.x + tw * (i + 0.5), y: r.y + r.height / 2 })),\n });\n const panel = list.map((p) => l0.items.get(panelKey(p))).find((pl) => pl && !pl.hidden);\n if (panel) out.push({ id: `side:${side}`, priority: 3, hit: panel.rect, make: fixed(onSide(side, list.length), `${Cap(side)} side`) });\n }\n if (railed && !railed.hidden) out.push({ id: `rail:${side}`, priority: 1, hit: railed.rect, make: fixed(onSide(side, list.length), `${Cap(side)} rail`) });\n if (list.length === 0 && (!railed || railed.hidden)) {\n const hit = side === \"left\" ? rect(0, 0, 40, size.height) : rect(size.width - 40, 0, 40, size.height);\n out.push({ id: `edge:${side}`, priority: 2, hit, make: fixed(onSide(side, 0), `${Cap(side)} side`) });\n }\n }\n return out;\n}\n\n// --- palettes ------------------------------------------------------------------------------------------------------\n\nfunction paletteTargets({ c, s0, key, size, opt }: DeskTargetInput): DeskTarget[] {\n const cat = c.desk.catalog;\n const out: DeskTarget[] = [];\n const id = idOf(key);\n const { area } = paletteArea(size, opt);\n const m = c.id === \"floatOver\" ? OVER_MARGIN : 0;\n const pw = paletteWidth(size.width);\n const ph = s0.folded.includes(id) ? TITLE : cat.natural(id);\n const narrow = size.width < PALETTE_NARROW;\n const anchor = { left: area.x + m, right: area.x + area.width - m - pw };\n const l0 = c.layout(s0, size, opt);\n const rectOf = (pid: number): Rect => l0.items.get(panelKey(pid))!.rect;\n const tb = l0.items.get(\"toolbar\");\n const pillRect = tb?.look === \"pill\" ? tb.rect : null;\n // A corner stack's column, down to just under its last palette: it joins the stack at the place under the pointer.\n for (const side of narrow ? ([\"right\"] as const) : ([\"left\", \"right\"] as const)) {\n const ids = narrow ? [...s0.stacks.left, ...s0.stacks.right] : [...s0.stacks[side]];\n const bottom = ids.length ? Math.max(...ids.map((pid) => rectOf(pid).y + rectOf(pid).height)) : area.y + m;\n const at = (y: number): number => ids.filter((pid) => centre(rectOf(pid)).y < y).length;\n const join = (i: number): Made => {\n let stacks = s0.stacks;\n if (!narrow) stacks = { ...stacks, [side]: insert(stacks[side], i, id) };\n else if (i <= s0.stacks.left.length) stacks = { ...stacks, left: insert(stacks.left, i, id) };\n else stacks = { ...stacks, right: insert(stacks.right, i - s0.stacks.left.length, id) };\n const label = `${narrow ? \"The\" : Cap(side)} corner stack · ${i + 1}`;\n return { state: touch({ ...s0, stacks }, id), label, key: label };\n };\n out.push({\n id: `stack:${side}`,\n priority: 2,\n hit: rect(anchor[side], area.y, pw, bottom + 30 - area.y),\n make: (p) => join(at(p.y)),\n stops: [area.y + m, ...ids.map((pid) => rectOf(pid).y + rectOf(pid).height + G / 2)].map((y) => ({ x: anchor[side] + pw / 2, y })),\n });\n }\n // Anywhere: snapped to the area's edges (over the documents also to other palettes' edges), kept inside the area.\n out.push({\n id: \"free\",\n priority: 3,\n free: true,\n hit: area,\n make: (p, grab) => {\n let x = p.x - grab.x;\n let y = p.y - grab.y;\n const snaps: string[] = [];\n if (Math.abs(x - anchor.left) < SNAP) [x, snaps[0]] = [anchor.left, \"left edge\"];\n else if (Math.abs(x - anchor.right) < SNAP) [x, snaps[0]] = [anchor.right, \"right edge\"];\n if (Math.abs(y - (area.y + m)) < SNAP) [y, snaps[1]] = [area.y + m, \"top\"];\n else if (Math.abs(y + ph - (area.y + area.height - m)) < SNAP) [y, snaps[1]] = [area.y + area.height - m - ph, \"bottom\"];\n if (c.id === \"floatOver\") {\n for (const [k, pl] of l0.items) {\n if (!isPanelKey(k) || pl.hidden) continue;\n const o = pl.rect;\n if (snaps[0] === undefined && Math.abs(x - o.x) < SNAP) [x, snaps[0]] = [o.x, `${cat.title(k)}'s edge`];\n if (snaps[1] === undefined && Math.abs(y - (o.y + o.height + G)) < SNAP && x < o.x + o.width && x + pw > o.x) [y, snaps[1]] = [o.y + o.height + G, `under ${cat.title(k)}`];\n }\n }\n x = clamp(x, area.x, area.x + area.width - pw);\n y = clamp(y, area.y, area.y + area.height - ph);\n // Never under a floating pill: it moves clear, below a pill at the top, above one at the bottom.\n if (pillRect && overlap(rect(x, y, pw, ph), pillRect) > 0) {\n y = pillRect.y < size.height / 2 ? pillRect.y + pillRect.height + G : pillRect.y - G - ph;\n y = clamp(y, 0, size.height - ph);\n snaps[1] = \"clear of the toolbar\";\n }\n const how = snaps.filter(Boolean).join(\", \");\n return { state: touch({ ...s0, free: [...s0.free, { id, at: { x, y } }] }, id), label: how ? `Here · snapped to the ${how}` : \"Here\", key: `free:${Math.round(x)},${Math.round(y)}` };\n },\n });\n return out;\n}\n\n/** The drop targets for dragging `key` in construction `c`, in a fixed order (the keyboard's). */\nexport function deskTargets(input: DeskTargetInput): DeskTarget[] {\n switch (input.c.id) {\n case \"docks\":\n case \"docksFull\":\n case \"dockTear\":\n return dockTargets(input);\n case \"tree\":\n return treeTargets(input);\n case \"strip\":\n return stripTargets(input);\n case \"navigator\":\n case \"drawers\":\n return tabTargets(input);\n case \"floatOver\":\n case \"floatAround\":\n return paletteTargets(input);\n }\n}\n\n/** A target's drop for a pointer at `p` holding the item at `grab`, laid out: where the item lands. */\nexport function deskDrop(input: DeskTargetInput, target: DeskTarget, p: Point, grab: Point): DeskDrop {\n const made = target.make(p, grab);\n const layout = input.c.layout(made.state, input.size, input.opt);\n const placed = layout.items.get(input.key)!;\n return { ...made, key: `${target.id}|${made.key}`, target: target.id, layout, slot: placed.rect, hidden: !!placed.hidden, free: !!target.free };\n}\n","/**\n * Toolbar group targets: a host's insertion points (lines between groups, priority 2) and empty zones (priority 1),\n * and floating over the content (priority 3). A group's own place is home, never a target: its stretch comes back\n * in `own`, for the consumer to join to the drag's home. A place `allows` forbids is no host target either.\n */\nimport { rect, type Point, type Rect } from \"../geometry\";\nimport { ZONES, floatGroup, insertGroup, insertions, isOwnPlace, layoutHost, vertical, withoutGroup, type Arrangement, type GroupSize, type HostId, type HostSpec, type Place } from \"../toolbar\";\nimport type { Target } from \"../target\";\n\n/** How far a line's hit reaches beyond the host's thickness on each side; an empty zone's. */\nexport const LINE_REACH = 12;\nexport const ZONE_REACH = 4;\n\nexport interface ToolbarTarget<G extends string = string> extends Target {\n readonly label: string;\n readonly kind: \"line\" | \"zone\";\n readonly place: Place;\n /** It lands in a side edge's column. */\n readonly vertical: boolean;\n /** The insertion line (3 px, inset 4 px from the host's sides) in stage coordinates; for an empty zone, at its middle. */\n readonly line: Rect;\n /** Where the group lands, in stage coordinates: its rect in the host once the drop is made. */\n readonly slot: Rect;\n /** The arrangement a drop here makes. */\n readonly arrangement: Arrangement<G>;\n}\n\n/**\n * Where a group may go: a host's place, or floating. `hostTargets` leaves out a place it refuses; for floating, the\n * consumer adds `floatTarget` only when `allows(group, \"float\")`, so one rule covers both. `place.index` counts the\n * groups in that zone without the dragged one (as `insertGroup` does): 0 is before all of the others.\n */\nexport type Allows<G extends string> = (group: G, place: Place | \"float\") => boolean;\n\nexport interface HostTargetsInput<G extends string> {\n readonly group: G;\n /** The arrangement as it is, the group still in its place. */\n readonly arrangement: Arrangement<G>;\n readonly host: HostId;\n /** The host's top-left corner in stage coordinates. */\n readonly origin: Point;\n readonly spec: HostSpec<G>;\n readonly size: GroupSize<G>;\n /** A group's name in the labels (default: its id). */\n readonly label?: (g: G) => string;\n /** Where the group may go (default: anywhere). A place it may not go is left out. */\n readonly allows?: Allows<G>;\n /**\n * Where this host is, and how long, once a drop has made `arrangement` (a host may grow or appear when it gets a\n * group); default: where it is now. The targets' `slot`s are laid out there.\n */\n readonly hostAfter?: (arrangement: Arrangement<G>) => { readonly origin: Point; readonly spec: HostSpec<G> };\n}\n\n/** The targets a host offers a dragged group, zone by zone in order, and the stretches that are its own place. */\nexport function hostTargets<G extends string>(input: HostTargetsInput<G>): { targets: ToolbarTarget<G>[]; own: Rect[] } {\n const { group, arrangement: a, host: h, origin: o, spec } = input;\n const slotIn = (after: Arrangement<G>): Rect => {\n const at = input.hostAfter?.(after) ?? { origin: o, spec };\n const r = layoutHost(after[h], h, at.spec, input.size, after.collapsed).slots.get(group)!;\n return rect(at.origin.x + r.x, at.origin.y + r.y, r.width, r.height);\n };\n const a0 = withoutGroup(a, group);\n const l = layoutHost(a0[h], h, spec, input.size, a0.collapsed);\n const v = vertical(h);\n const T = spec.thickness;\n const across = (s0: number, s1: number, reach: number): Rect => (v ? rect(o.x - reach, o.y + s0, T + 2 * reach, s1 - s0) : rect(o.x + s0, o.y - reach, s1 - s0, T + 2 * reach));\n const targets: ToolbarTarget<G>[] = [];\n const own: Rect[] = [];\n const pts = insertions(a0[h], h, spec, l, input.label).sort((p, q) => ZONES.indexOf(p.zone) - ZONES.indexOf(q.zone) || p.index - q.index);\n for (const p of pts) {\n const [s0, s1] = p.span;\n const place: Place = { host: h, zone: p.zone, index: p.index };\n if (isOwnPlace(a, group, place)) {\n own.push(across(s0, s1, LINE_REACH));\n continue;\n }\n if (input.allows && !input.allows(group, place)) continue;\n const after = insertGroup(a, group, h, p.zone, p.index);\n targets.push({\n id: `g:${h}:${p.zone}:${p.index}`,\n priority: p.empty ? 1 : 2,\n hit: p.empty ? across(s0, s1, ZONE_REACH) : across(s0, s1, LINE_REACH),\n label: p.label,\n kind: p.empty ? \"zone\" : \"line\",\n place,\n vertical: v,\n line: v ? rect(o.x + 4, o.y + p.at - 1.5, T - 8, 3) : rect(o.x + p.at - 1.5, o.y + 4, 3, T - 8),\n slot: slotIn(after),\n arrangement: after,\n });\n }\n return { targets, own };\n}\n\nexport interface ToolbarFloatTarget<G extends string = string> extends Target {\n readonly label: string;\n readonly kind: \"float\";\n /** The group's top-left corner relative to the stage, and the arrangement, for a drop with the pointer at `p`. */\n readonly make: (p: Point, grab: Point) => Arrangement<G>;\n}\n\nexport interface FloatTargetInput<G extends string> {\n readonly group: G;\n readonly arrangement: Arrangement<G>;\n /** The content the group floats over, in stage coordinates. */\n readonly stage: Rect;\n /** The group's size as it floats. */\n readonly width: number;\n readonly height: number;\n}\n\n/**\n * Floating over the content (`stage`, in stage coordinates): the group's top-left corner kept on the stage. A\n * group that may not float simply gets no float target: add it only when your rule allows it, with the same\n * `allows` you give `hostTargets`: `...(allows(group, \"float\") ? [floatTarget(input)] : [])`.\n */\nexport function floatTarget<G extends string>(input: FloatTargetInput<G>): ToolbarFloatTarget<G> {\n const { group, arrangement, stage } = input;\n return {\n id: \"g:float\",\n priority: 3,\n free: true,\n hit: stage,\n label: \"Float here\",\n kind: \"float\",\n // Kept on the stage; a group larger than the stage keeps its top-left corner on the stage's.\n make: (p, grab) => {\n const x = Math.max(0, Math.min(p.x - grab.x - stage.x, stage.width - input.width));\n const y = Math.max(0, Math.min(p.y - grab.y - stage.y, stage.height - input.height));\n return floatGroup(arrangement, group, x, y);\n },\n };\n}\n","/**\n * Keyboard stops: every place a toolbar group can go, in one list in reading order, for the arrow keys and a\n * \"Move to\" menu alike. A consumer steps through the list; it never parses target ids.\n */\nimport { centre, type Point } from \"../geometry\";\nimport { panelStops, type PanelStop, type PanelStopsOptions, type PanelTarget } from \"../panels/targets\";\nimport { HOST_LABEL, ZONES, zoneLabel, type Arrangement, type HostId, type Place } from \"../toolbar\";\nimport type { ToolbarFloatTarget, ToolbarTarget } from \"./toolbar\";\n\n/** The hosts in reading order: the title bar, the top bar, the left edge, the right edge, the bottom bar. */\nexport const HOST_READING_ORDER: readonly HostId[] = [\"title\", \"top\", \"left\", \"right\", \"bottom\"];\n\nexport interface KeyboardStop<G extends string = string> {\n /** The target's id (\"home\" for the group's own place). */\n readonly id: string;\n readonly label: string;\n /** Where in a host it is; null for floating. */\n readonly place: Place | null;\n /** The arrangement a move here makes (the current one for home). */\n readonly arrangement: Arrangement<G>;\n /** The group's own place: where the keyboard starts, and a move there changes nothing. */\n readonly home: boolean;\n}\n\nexport interface KeyboardStopsOptions<G extends string> {\n /** The group's own place, as a stop of its own in its reading-order position (the targets leave it out). */\n readonly home?: { readonly place: Place; readonly arrangement: Arrangement<G>; readonly label?: string };\n /**\n * Floating targets as stops at the end (default: left out). `at` is where the pointer would drop it and `grab`\n * where it holds the group (default: the float target's middle, the group's top-left corner).\n */\n readonly floats?: boolean | { readonly at: Point; readonly grab?: Point };\n}\n\nconst isFloat = <G extends string>(t: ToolbarTarget<G> | ToolbarFloatTarget<G>): t is ToolbarFloatTarget<G> => t.kind === \"float\";\n\n/** Reading order of a place: host, then zone, then index. */\nconst rank = (p: Place): number => HOST_READING_ORDER.indexOf(p.host) * 3000 + ZONES.indexOf(p.zone) * 1000 + p.index;\n\nconst isPanelTargets = (targets: readonly object[], options: { readonly home?: object }): boolean => targets.some((t) => \"panel\" in t) || (targets.length === 0 && !!options.home && \"state\" in options.home);\n\n/**\n * The places a group can go, in reading order: toolbar areas title → top → left → right → bottom, zones start → center →\n * end, then each insertion point in order; the group's own place among them when `home` is given; floating targets\n * at the end only when `floats` asks for them. One list serves the arrow keys and a \"Move to\" menu.\n *\n * Given panel targets (`@n-uf/placement/panels`' `panelTargets`), the same for a panel: left to right across the\n * stage (the left rail, the left side's lines and columns outer to inner, the right side's inner to outer, the right\n * rail), floating last when asked; each stop carries the state a move there makes (`panelStops`).\n */\nexport function keyboardStops(targets: readonly PanelTarget[], options?: PanelStopsOptions): PanelStop[];\nexport function keyboardStops<G extends string>(targets: readonly (ToolbarTarget<G> | ToolbarFloatTarget<G>)[], options?: KeyboardStopsOptions<G>): KeyboardStop<G>[];\nexport function keyboardStops<G extends string>(\n targets: readonly (ToolbarTarget<G> | ToolbarFloatTarget<G>)[] | readonly PanelTarget[],\n options: KeyboardStopsOptions<G> | PanelStopsOptions = {},\n): KeyboardStop<G>[] | PanelStop[] {\n if (isPanelTargets(targets, options)) return panelStops(targets as readonly PanelTarget[], options as PanelStopsOptions);\n return toolbarStops(targets as readonly (ToolbarTarget<G> | ToolbarFloatTarget<G>)[], options as KeyboardStopsOptions<G>);\n}\n\nfunction toolbarStops<G extends string>(targets: readonly (ToolbarTarget<G> | ToolbarFloatTarget<G>)[], options: KeyboardStopsOptions<G>): KeyboardStop<G>[] {\n const placed: KeyboardStop<G>[] = [];\n const floating: KeyboardStop<G>[] = [];\n for (const t of targets) {\n if (!isFloat(t)) {\n placed.push({ id: t.id, label: t.label, place: t.place, arrangement: t.arrangement, home: false });\n continue;\n }\n if (!options.floats) continue;\n const at = options.floats === true ? centre(t.hit) : options.floats.at;\n const grab = options.floats === true ? { x: 0, y: 0 } : (options.floats.grab ?? { x: 0, y: 0 });\n floating.push({ id: t.id, label: t.label, place: null, arrangement: t.make(at, grab), home: false });\n }\n const h = options.home;\n if (h) placed.push({ id: \"home\", label: h.label ?? `${HOST_LABEL[h.place.host]} · ${zoneLabel(h.place.host, h.place.zone)} · current place`, place: h.place, arrangement: h.arrangement, home: true });\n placed.sort((a, b) => rank(a.place!) - rank(b.place!));\n return [...placed, ...floating];\n}\n","/**\n * A pane's drop zones, the old names of `@n-uf/placement/tiling`'s pane drop regions. Each wraps the tiling function\n * and maps the old option names; all are deprecated and go when this entry does.\n */\nimport type { Point, Rect, Size } from \"../geometry\";\nimport { PANE_REGION_DEFAULTS, PANE_SIDES, paneCenter, paneRegion, type PaneCenter, type PaneRegion, type PaneRegionOptions, type PaneSide } from \"../tiling\";\n\n/** @deprecated Use `PaneRegion` from `@n-uf/placement/tiling`. */\nexport type PaneZone = PaneRegion;\n\n/** @deprecated Use `PANE_SIDES` from `@n-uf/placement/tiling`. */\nexport const PANE_EDGES: readonly PaneSide[] = PANE_SIDES;\n\n/** @deprecated Use `PaneRegionOptions` from `@n-uf/placement/tiling` (`center`, `centerX`, `centerY`, `centerMin`). */\nexport interface PaneZoneOptions {\n readonly centre?: number;\n readonly centreX?: number;\n readonly centreY?: number;\n readonly centreMin?: number;\n readonly hysteresis?: number;\n readonly pixelRatio?: number;\n}\n\nconst R = PANE_REGION_DEFAULTS;\n/** @deprecated Use `PANE_REGION_DEFAULTS` from `@n-uf/placement/tiling`. */\nexport const PANE_ZONE_DEFAULTS: Required<Omit<PaneZoneOptions, \"centreX\" | \"centreY\">> = { centre: R.center, centreMin: R.centerMin, hysteresis: R.hysteresis, pixelRatio: R.pixelRatio };\n\n/** @deprecated Use `PaneCenter` from `@n-uf/placement/tiling`. */\nexport type PaneCentre = PaneCenter;\n\n/** The old option names as the new ones. */\nconst regionOptions = (o: PaneZoneOptions): PaneRegionOptions => ({\n ...(o.centre === undefined ? {} : { center: o.centre }),\n ...(o.centreX === undefined ? {} : { centerX: o.centreX }),\n ...(o.centreY === undefined ? {} : { centerY: o.centreY }),\n ...(o.centreMin === undefined ? {} : { centerMin: o.centreMin }),\n ...(o.hysteresis === undefined ? {} : { hysteresis: o.hysteresis }),\n ...(o.pixelRatio === undefined ? {} : { pixelRatio: o.pixelRatio }),\n});\n\n/** @deprecated Use `paneCenter` from `@n-uf/placement/tiling`. */\nexport const paneCentre = (size: Size, options: PaneZoneOptions = {}): PaneCenter => paneCenter(size, regionOptions(options));\n\n/** @deprecated Use `paneRegion` from `@n-uf/placement/tiling`. */\nexport const paneZone = (rect: Rect, point: Point, previous: PaneZone | null = null, options: PaneZoneOptions = {}): PaneZone => paneRegion(rect, point, previous, regionOptions(options));\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEO,IAAM,OAAO;AAEpB,IAAM,SAAS,CAAI,MAAoB,GAAW,MAAc,CAAC,GAAG,KAAK,MAAM,GAAG,CAAC,GAAG,GAAG,GAAG,KAAK,MAAM,CAAC,CAAC;AACzG,IAAM,MAAM,CAAC,MAAqB,MAAM,SAAS,SAAS;AAC1D,IAAM,Q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IAAM,IAAI;AAEH,IAAM,qBAA6E,EAAE,QAAQ,EAAE,QAAQ,WAAW,EAAE,WAAW,YAAY,EAAE,YAAY,YAAY,EAAE,WAAW;AAMzL,IAAM,gBAAgB,CAAC,OAA2C;AAAA,EAChE,GAAI,EAAE,WAAW,SAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO;AAAA,EACrD,GAAI,EAAE,YAAY,SAAY,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ;AAAA,EACxD,GAAI,EAAE,YAAY,SAAY,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ;AAAA,EACxD,GAAI,EAAE,cAAc,SAAY,CAAC,IAAI,EAAE,WAAW,EAAE,UAAU;AAAA,EAC9D,GAAI,EAAE,eAAe,SAAY,CAAC,IAAI,EAAE,YAAY,EAAE,WAAW;AAAA,EACjE,GAAI,EAAE,eAAe,SAAY,CAAC,IAAI,EAAE,YAAY,EAAE,WAAW;AACnE;AAGO,IAAM,aAAa,CAAC,MAAY,UAA2B,CAAC,MAAkB,WAAW,MAAM,cAAc,OAAO,CAAC;AAGrH,IAAM,WAAW,CAACA,OAAY,OAAc,WAA4B,MAAM,UAA2B,CAAC,MAAgB,WAAWA,OAAM,OAAO,UAAU,cAAc,OAAO,CAAC;","names":["rect"]}
|
package/dist/tiling.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { R as Rect, S as Size } from './geometry-Bf37LbCT.js';
|
|
2
|
+
import { b as PaneRegion, P as PaneSide } from './regions-Db_RyT4P.js';
|
|
3
|
+
export { c as PANE_REGION_DEFAULTS, d as PANE_SIDES, a as PaneCenter, e as PaneRegionOptions, p as paneCenter, f as paneRegion } from './regions-Db_RyT4P.js';
|
|
4
|
+
import { T as Target } from './target-fhD5UVlt.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The order layouts: panes in order and an area in, a rect per pane out. Pure rect functions; a drop on one reorders
|
|
8
|
+
* (the dragged pane inserted at an index, see `orderTargets`).
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** How a layout spaces its panes: `gap` px between neighbors (default 0), `ratio` the master's share (default 0.5). */
|
|
12
|
+
interface TileOptions {
|
|
13
|
+
readonly gap?: number;
|
|
14
|
+
readonly ratio?: number;
|
|
15
|
+
}
|
|
16
|
+
/** An order layout: `masterStack`, `columns`, `grid`, or the app's own of the same shape. */
|
|
17
|
+
type OrderLayout = <K>(panes: readonly K[], area: Rect, options?: TileOptions) => Map<K, Rect>;
|
|
18
|
+
/**
|
|
19
|
+
* Master and stack: the first pane takes the left part (`ratio` of the width less the gap), the rest stack on the
|
|
20
|
+
* right in equal rows. One pane takes the whole area.
|
|
21
|
+
*/
|
|
22
|
+
declare function masterStack<K>(panes: readonly K[], area: Rect, options?: TileOptions): Map<K, Rect>;
|
|
23
|
+
/** Equal columns, full height. */
|
|
24
|
+
declare function columns<K>(panes: readonly K[], area: Rect, options?: TileOptions): Map<K, Rect>;
|
|
25
|
+
/** A grid as square as the count allows; the last row's cells widen to fill it. */
|
|
26
|
+
declare function grid<K>(panes: readonly K[], area: Rect, options?: TileOptions): Map<K, Rect>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The split tree: how panes divide an area. A node is a pane, or a split of its rect in two (`a` then `b`). A split
|
|
30
|
+
* with an `axis` divides along it (`"x"`: `a` left of `b`; `"y"`: `a` above `b`) at `ratio`; one without divides
|
|
31
|
+
* along the rect's longer side in halves, which is dwindle (split along the longer side). Pure: trees in, trees out.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
type Split<K> = {
|
|
35
|
+
readonly pane: K;
|
|
36
|
+
} | {
|
|
37
|
+
readonly a: Split<K>;
|
|
38
|
+
readonly b: Split<K>;
|
|
39
|
+
readonly axis?: "x" | "y";
|
|
40
|
+
readonly ratio?: number;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* The rect of every pane of `tree` in `area`, `gap` px between the two sides of each split. A split's `ratio` is
|
|
44
|
+
* clamped to 0..1; each side gets its share of the room the gap leaves (none when the gap is wider than the rect), so
|
|
45
|
+
* no size is ever negative, and at ratio 0.5 both sides are exactly equal. A split with no room lays both sides at no
|
|
46
|
+
* size inside its rect: the first at its start, the second at its end, never past it.
|
|
47
|
+
*/
|
|
48
|
+
declare function layoutSplit<K>(tree: Split<K> | null, area: Rect, options?: TileOptions): Map<K, Rect>;
|
|
49
|
+
/** The panes of `tree` in order (`a` before `b`). */
|
|
50
|
+
declare const panesOf: <K>(tree: Split<K> | null) => K[];
|
|
51
|
+
/**
|
|
52
|
+
* `tree` with pane `at` split in two, `pane` on its `side`. A side writes an explicit axis and ratio 0.5, so the side
|
|
53
|
+
* means the same whatever the pane's shape; no side splits along the longer side, `pane` second (dwindle). An empty
|
|
54
|
+
* tree becomes `pane` alone; an `at` that isn't in the tree (or null) splits the whole tree, so no pane is lost.
|
|
55
|
+
*/
|
|
56
|
+
declare function splitPane<K>(tree: Split<K> | null, at: K | null, pane: K, side?: PaneSide): Split<K>;
|
|
57
|
+
/** `tree` without `pane`: its sibling takes their parent's place. */
|
|
58
|
+
declare function removePane<K>(tree: Split<K> | null, pane: K): Split<K> | null;
|
|
59
|
+
/** `tree` with panes `x` and `y` in each other's place; unchanged unless both are in it. */
|
|
60
|
+
declare function swapPanes<K>(tree: Split<K> | null, x: K, y: K): Split<K> | null;
|
|
61
|
+
/** A dwindle tree for `panes`: each one splits the one before it along the longer side. */
|
|
62
|
+
declare function splitFromOrder<K>(panes: readonly K[]): Split<K> | null;
|
|
63
|
+
/**
|
|
64
|
+
* A drop of `dragged` on pane `at`'s `region`. A side splits `at` on that side (`dragged` taken out of its old place
|
|
65
|
+
* first). The center swaps the two when `dragged` is in the tree; a pane from outside takes `at`'s place, with `at`
|
|
66
|
+
* split off after it along the longer side. An `at` that isn't in the tree (or is `dragged` itself) changes nothing
|
|
67
|
+
* but adding `dragged` when it is missing, as `splitPane` does. The set of panes is kept: the tree's, plus `dragged`.
|
|
68
|
+
*/
|
|
69
|
+
declare function dropOnPane<K>(tree: Split<K> | null, dragged: K, at: K, region: PaneRegion): Split<K>;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Drop targets for tiling, in the root `Target` shape (what `@n-uf/motion/drag` takes). Both kinds come from one
|
|
73
|
+
* helper: a pane target (`pane:<id>`, its hit the pane, the place in it its drop region) for the split tree, and an
|
|
74
|
+
* insertion target (`at:<index>`, its hit and slot the dragged pane's rect with it inserted there) for an order layout.
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
/** A split tree's target: drop on pane `pane` (the region under the pointer says how). */
|
|
78
|
+
interface PaneTarget<K> extends Target {
|
|
79
|
+
readonly pane: K;
|
|
80
|
+
}
|
|
81
|
+
/** An order layout's target: insert the dragged pane at `index`; `layout` is every pane's rect with it there. */
|
|
82
|
+
interface OrderTarget<K> extends Target {
|
|
83
|
+
readonly index: number;
|
|
84
|
+
readonly layout: ReadonlyMap<K, Rect>;
|
|
85
|
+
}
|
|
86
|
+
interface PaneTargetsOptions<K> {
|
|
87
|
+
/** A pane left out: the dragged one, when it is still laid out. */
|
|
88
|
+
readonly except?: K;
|
|
89
|
+
/**
|
|
90
|
+
* A pane's key in its target's id (`pane:<key>`); default `String`. Keys must be unique across the panes: a drag
|
|
91
|
+
* intent follows its targets by id, so two panes with one key would be one target.
|
|
92
|
+
*/
|
|
93
|
+
readonly key?: (pane: K) => string;
|
|
94
|
+
}
|
|
95
|
+
/** One target per pane of `layout`, its id `pane:<key>`. */
|
|
96
|
+
declare function paneTargets<K>(layout: ReadonlyMap<K, Rect>, options?: PaneTargetsOptions<K>): PaneTarget<K>[];
|
|
97
|
+
/**
|
|
98
|
+
* One target per index `dragged` could be inserted at among `panes` (which don't hold it), laid out by `arrange` in
|
|
99
|
+
* `area`. Each target's hit and slot is `dragged`'s rect with it there, so the targets cover the area as the layout
|
|
100
|
+
* does. Ids are `at:<index>`, unique whatever the panes are.
|
|
101
|
+
*/
|
|
102
|
+
declare function orderTargets<K>(arrange: OrderLayout, panes: readonly K[], dragged: K, area: Rect, options?: TileOptions): OrderTarget<K>[];
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The minimum-size give-way: while a pane is laid out below its minimum, the newest pane (highest `age`) floats and
|
|
106
|
+
* the rest are laid out again. Stops when every pane keeps its minimum or one pane is left. `layout` lays out the
|
|
107
|
+
* kept panes; the result says which are kept (in their order) and which float (newest first).
|
|
108
|
+
*/
|
|
109
|
+
declare function giveWay<K>(panes: readonly K[], layout: (kept: readonly K[]) => ReadonlyMap<K, Rect>, min: (pane: K) => Size, age: (pane: K) => number): {
|
|
110
|
+
kept: K[];
|
|
111
|
+
floats: K[];
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export { type OrderLayout, type OrderTarget, PaneRegion, PaneSide, type PaneTarget, type PaneTargetsOptions, type Split, type TileOptions, columns, dropOnPane, giveWay, grid, layoutSplit, masterStack, orderTargets, paneTargets, panesOf, removePane, splitFromOrder, splitPane, swapPanes };
|
package/dist/tiling.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PANE_REGION_DEFAULTS,
|
|
3
|
+
PANE_SIDES,
|
|
4
|
+
columns,
|
|
5
|
+
dropOnPane,
|
|
6
|
+
giveWay,
|
|
7
|
+
grid,
|
|
8
|
+
layoutSplit,
|
|
9
|
+
masterStack,
|
|
10
|
+
orderTargets,
|
|
11
|
+
paneCenter,
|
|
12
|
+
paneRegion,
|
|
13
|
+
paneTargets,
|
|
14
|
+
panesOf,
|
|
15
|
+
removePane,
|
|
16
|
+
splitFromOrder,
|
|
17
|
+
splitPane,
|
|
18
|
+
swapPanes
|
|
19
|
+
} from "./chunk-R3AAANRY.js";
|
|
20
|
+
import "./chunk-VLTYJHUA.js";
|
|
21
|
+
export {
|
|
22
|
+
PANE_REGION_DEFAULTS,
|
|
23
|
+
PANE_SIDES,
|
|
24
|
+
columns,
|
|
25
|
+
dropOnPane,
|
|
26
|
+
giveWay,
|
|
27
|
+
grid,
|
|
28
|
+
layoutSplit,
|
|
29
|
+
masterStack,
|
|
30
|
+
orderTargets,
|
|
31
|
+
paneCenter,
|
|
32
|
+
paneRegion,
|
|
33
|
+
paneTargets,
|
|
34
|
+
panesOf,
|
|
35
|
+
removePane,
|
|
36
|
+
splitFromOrder,
|
|
37
|
+
splitPane,
|
|
38
|
+
swapPanes
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=tiling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n-uf/placement",
|
|
3
|
-
"version": "26.11.
|
|
3
|
+
"version": "26.11.37",
|
|
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",
|
|
@@ -64,6 +64,10 @@
|
|
|
64
64
|
"types": "./dist/scene-cases.d.ts",
|
|
65
65
|
"default": "./dist/scene-cases.js"
|
|
66
66
|
},
|
|
67
|
+
"./tiling": {
|
|
68
|
+
"types": "./dist/tiling.d.ts",
|
|
69
|
+
"default": "./dist/tiling.js"
|
|
70
|
+
},
|
|
67
71
|
"./package.json": "./package.json"
|
|
68
72
|
},
|
|
69
73
|
"publishConfig": {
|
|
@@ -80,7 +84,7 @@
|
|
|
80
84
|
"tsup": "^8.5.1",
|
|
81
85
|
"typescript": "^6.0.3",
|
|
82
86
|
"vitest": "^4.1.12",
|
|
83
|
-
"@n-uf/motion": "26.11.
|
|
87
|
+
"@n-uf/motion": "26.11.37"
|
|
84
88
|
},
|
|
85
89
|
"scripts": {
|
|
86
90
|
"build": "tsup && node ./scripts/check-dist.mjs",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dock/model.ts","../src/dock/arrange.ts","../src/dock/parts.ts"],"sourcesContent":["/**\n * The desk's model: panels and documents, the options, the state every construction keeps, and what a layout\n * returns (a placed rect per item). The panels themselves (their titles and natural heights) come from the\n * consumer as a catalog; see `createDesk`.\n */\nimport type { Rect, Size } from \"../geometry\";\n\nexport type Side = \"left\" | \"right\";\n\n/** Gaps and sizes, in stage px. */\nexport const G = 6;\n/** A toolbar bar's height (the pill is 4 px thinner). */\nexport const BAR = 34;\n/** A rail's width. */\nexport const RAIL = 34;\n/** A folded section's (or a shaded palette's) height: its title bar. */\nexport const TITLE = 22;\n/** A tab row's height (navigator sides and drawers). */\nexport const TABS = 28;\n/** The smallest a tiled document may be where a construction promises it (the tiling tree, the strip). */\nexport const DOC_MIN: Size = { width: 240, height: 160 };\n\n/** Items are keyed \"panel:<id>\" and \"doc:<id>\". */\nexport const panelKey = (id: number): string => `panel:${id}`;\nexport const docKey = (id: number): string => `doc:${id}`;\nexport const isPanelKey = (key: string): boolean => key.startsWith(\"panel:\");\nexport const isDocKey = (key: string): boolean => key.startsWith(\"doc:\");\nexport const idOf = (key: string): number => Number(key.slice(key.indexOf(\":\") + 1));\n\n/** A tool panel: its title and the height its content needs (its natural height, title bar included). */\nexport interface PanelSpec {\n readonly id: number;\n readonly title: string;\n readonly natural: number;\n}\n\n/** Where the panels start. Unset parts follow from the sides (see `createDesk`). */\nexport interface DeskStart {\n readonly left: readonly number[];\n readonly right: readonly number[];\n readonly bottom: readonly number[];\n readonly active?: { readonly left: number | null; readonly right: number | null };\n readonly tree?: DeskState[\"tree\"];\n readonly cols?: DeskState[\"cols\"];\n readonly stacks?: DeskState[\"stacks\"];\n}\n\n/** What a desk is made of: its panels, its documents' titles and where the panels start. */\nexport interface DeskSpec {\n readonly panels: readonly PanelSpec[];\n /** A document's title (default \"Document <id>\"). */\n readonly docTitle?: (id: number) => string;\n readonly start: DeskStart;\n /** The panels in the order they were opened (default: as listed); the tiling tree floats the newest first. */\n readonly opened?: readonly number[];\n}\n\n/** The catalog every part reads: a panel's natural height, an item's title and age. */\nexport interface Catalog {\n readonly panelIds: readonly number[];\n readonly natural: (id: number) => number;\n /** An item's title by key (\"panel:<id>\", \"doc:<id>\"); any other key is its own title. */\n readonly title: (key: string) => string;\n /** An item's age: higher is newer (panels in the order they were opened, then the documents). */\n readonly born: (key: string) => number;\n readonly start: Required<DeskStart>;\n}\n\n/** The catalog for a spec (unset start parts filled in). */\nexport function catalogOf(spec: DeskSpec): Catalog {\n const byId = new Map(spec.panels.map((p) => [p.id, p]));\n const opened = spec.opened ?? spec.panels.map((p) => p.id);\n const docTitle = spec.docTitle ?? ((id: number) => `Document ${id}`);\n const { left, right, bottom } = spec.start;\n const rest = [...right, ...bottom];\n const start: Required<DeskStart> = {\n left,\n right,\n bottom,\n active: spec.start.active ?? { left: left[0] ?? null, right: right.at(-1) ?? null },\n tree: spec.start.tree ?? { L: left.map(panelKey), R: rest.map(panelKey), C: [] },\n cols: spec.start.cols ?? [left.map(panelKey), rest.map(panelKey)].filter((c) => c.length > 0),\n stacks: spec.start.stacks ?? { left, right: rest },\n };\n return {\n panelIds: spec.panels.map((p) => p.id),\n natural: (id) => byId.get(id)?.natural ?? TITLE,\n title: (key) => (isPanelKey(key) ? (byId.get(idOf(key))?.title ?? key) : isDocKey(key) ? docTitle(idOf(key)) : key),\n born: (key) => (isDocKey(key) ? 1000 + idOf(key) : opened.indexOf(idOf(key)) + 1),\n start,\n };\n}\n\n/** Where the toolbar floats (top or bottom) and whether the documents keep a band clear for it; the bottom dock's mode. */\nexport interface Options {\n readonly toolbar: \"top\" | \"bottom\";\n readonly toolbarSpace: \"reserved\" | \"overlay\";\n readonly bottom: \"reserved\" | \"overlay\" | \"off\";\n /** The pill's width when its contents need more than the default; unset: the default. */\n readonly toolbarWidth?: number;\n /** The pill holds nothing: it takes no space and isn't shown. */\n readonly toolbarHidden?: boolean;\n}\nexport const DEFAULT_OPTIONS: Options = { toolbar: \"top\", toolbarSpace: \"reserved\", bottom: \"reserved\" };\n\n/** A panel placed freely (torn off, or a palette out of its stack): its top-left corner, null for the default spot. */\nexport interface Free {\n readonly id: number;\n readonly at: { readonly x: number; readonly y: number } | null;\n}\n\n/**\n * Everything any construction keeps. Each construction has its own copy (its own arrangement) and reads only what\n * it uses; the open documents are the same in all of them.\n */\nexport interface DeskState {\n /** Open document ids, in open order. */\n readonly docs: readonly number[];\n readonly focus: number | null;\n /** Panel ids, least recently used first: what folds or shades first when height runs out. */\n readonly recent: readonly number[];\n /** Sections folded (palettes shaded) by hand. */\n readonly folded: readonly number[];\n /** Docks, navigator sides and drawers: the panels on each side, top to bottom (tabs: left to right). */\n readonly left: readonly number[];\n readonly right: readonly number[];\n /** The bottom dock's panels (edge docks only). */\n readonly bottom: readonly number[];\n /** Docks or drawers folded to their rail by hand. */\n readonly closed: readonly Side[];\n /** The side opened last by hand: when width runs out it folds last. */\n readonly opened: Side | null;\n /** The panel showing on each side (navigator, drawers). */\n readonly active: { readonly left: number | null; readonly right: number | null };\n /** Panels torn off a dock, floating (edge docks + tear-off). */\n readonly torn: readonly Free[];\n /** The tiling tree: item keys in the left column, the right column and the center (dwindle order). */\n readonly tree: { readonly L: readonly string[]; readonly R: readonly string[]; readonly C: readonly string[] };\n /** The scrolling strip: its columns, left to right, each a list of item keys top to bottom. */\n readonly cols: readonly (readonly string[])[];\n /** The strip scrolled by hand, or null: it scrolls to the focus. */\n readonly stripScroll: number | null;\n /** Palettes: the corner stacks, top to bottom, and the ones placed anywhere. */\n readonly stacks: { readonly left: readonly number[]; readonly right: readonly number[] };\n readonly free: readonly Free[];\n}\n\n/** How an item is drawn. */\nexport type Look =\n | \"pill\" // the toolbar floating as a rounded pill\n | \"bar\" // the toolbar as a bar across the top\n | \"section\" // a panel open in a dock\n | \"header\" // a section folded (or a palette shaded) to its title bar\n | \"float\" // a panel floating over the documents\n | \"palette\" // a floating panel that reserves its footprint\n | \"tile\" // a panel tiled like a document\n | \"bare\" // a panel under a tab row: no title bar of its own\n | \"doc\"\n | \"rail\"\n | \"tabs\"\n | \"track\"\n | \"thumb\";\n\n/** Stacking layers, bottom to top. */\nexport const LAYER = { doc: 1, dock: 2, palette: 3, overlay: 4, float: 5, toolbar: 6 } as const;\n\n/** One item as a layout places it. */\nexport interface Placed {\n readonly rect: Rect;\n readonly look: Look;\n readonly layer: number;\n /** Folded away (into a rail, behind a tab): it goes to `rect`, hidden. */\n readonly hidden?: boolean;\n /** Never laid out below this (where the construction promises it). */\n readonly min?: Partial<Size>;\n /** It may lie outside the stage (the strip scrolls). */\n readonly offStage?: boolean;\n /** A rail's icons or a tab row's tabs (panel ids), and the active tab. */\n readonly icons?: readonly number[];\n readonly tabs?: readonly number[];\n readonly active?: number | null;\n /** Drawn with an accent outline (the bottom dock). */\n readonly accent?: boolean;\n /** Drawn with a shadow (it floats over something). */\n readonly shadow?: boolean;\n}\n\n/**\n * How a layout gave way (or what it is worth knowing about it):\n *\n * - `bottom-folded`: the bottom dock folded to its header; `dock-folded`: a side dock folded to its rail (`side`);\n * - `sections-folded`: sections folded to their headers by themselves, least recently used first;\n * - `torn-floating`: panels torn off a dock float (`items`); `torn-shaded`: some shade because they don't fit;\n * - `columns-railed`: the tiling tree's side columns are folded to rails (`side` when only one);\n * - `tiles-float`: tiles that broke a minimum float, newest first (`items`);\n * - `tabs-folded`: a tabbed side folded to icon tabs (`side`); `drawer-over`: a drawer slides over the\n * documents (`side`);\n * - `column-split`: a strip column split in two (`items`); `strip-scrolls`: the strip is wider than the stage;\n * - `stacks-merged`: both palette stacks share one corner; `palettes-shaded`: palettes shaded to title bars;\n * - `palettes-cover`, `docs-room`: how much of the documents palettes cover, and how much room they leave.\n */\nexport type NoteCode =\n | \"bottom-folded\"\n | \"dock-folded\"\n | \"sections-folded\"\n | \"torn-floating\"\n | \"torn-shaded\"\n | \"columns-railed\"\n | \"tiles-float\"\n | \"tabs-folded\"\n | \"drawer-over\"\n | \"column-split\"\n | \"strip-scrolls\"\n | \"stacks-merged\"\n | \"palettes-shaded\"\n | \"palettes-cover\"\n | \"docs-room\";\n\n/**\n * One note on a layout. `code` (and `side`, `items` where they apply) is the contract; `text` says it in English for\n * people, and its wording may change in any release.\n */\nexport interface Note {\n readonly code: NoteCode;\n readonly text: string;\n readonly side?: Side;\n /** The item keys it is about. */\n readonly items?: readonly string[];\n}\n\n/** Where everything is (\"toolbar\", \"panel:<id>\", \"doc:<id>\", \"rail:<side>\", \"tabs:<side>\", \"track\", \"thumb\"), and how it gave way. */\nexport interface Layout {\n readonly items: ReadonlyMap<string, Placed>;\n readonly notes: readonly Note[];\n}\n\n// --- state changes -------------------------------------------------------------------------------------------------\n\n/** The arrangement a catalog starts from, with these documents open (none by default). */\nexport function startState(cat: Catalog, docs: readonly number[] = []): DeskState {\n const st = cat.start;\n const base: DeskState = {\n docs: [],\n focus: null,\n recent: [...cat.panelIds],\n folded: [],\n left: [...st.left],\n right: [...st.right],\n bottom: [...st.bottom],\n closed: [],\n opened: null,\n active: st.active,\n torn: [],\n tree: st.tree,\n cols: st.cols,\n stripScroll: null,\n stacks: st.stacks,\n free: [],\n };\n return withDocs(base, docs, docs.at(-1) ?? null);\n}\n\n/**\n * The same state with these documents open: new ones join the tiling tree's center (the first one at its front)\n * and get a strip column of their own after the last document column; closed ones leave both.\n */\nexport function withDocs(s: DeskState, docs: readonly number[], focus: number | null): DeskState {\n const keys = docs.map(docKey);\n const gone = (k: string): boolean => isDocKey(k) && !keys.includes(k);\n let C = s.tree.C.filter((k) => !gone(k));\n let cols = s.cols.map((c) => c.filter((k) => !gone(k))).filter((c) => c.length > 0);\n const has = (k: string): boolean => [...s.tree.L, ...s.tree.R, ...C].includes(k);\n for (const k of keys) {\n if (!has(k)) C = C.some(isDocKey) || C.length === 0 ? [...C, k] : [k, ...C];\n if (!cols.some((c) => c.includes(k))) {\n const lastDoc = cols.map((c) => c.some(isDocKey)).lastIndexOf(true);\n const at = lastDoc >= 0 ? lastDoc + 1 : Math.min(1, cols.length);\n cols = [...cols.slice(0, at), [k], ...cols.slice(at)];\n }\n }\n const L = s.tree.L.filter((k) => !gone(k));\n const R = s.tree.R.filter((k) => !gone(k));\n const f = focus !== null && docs.includes(focus) ? focus : (docs.at(-1) ?? null);\n // A new focus: the strip scrolls to it again.\n return { ...s, docs: [...docs], focus: f, tree: { L, R, C }, cols, stripScroll: f === s.focus ? s.stripScroll : null };\n}\n\n/** Panel `id` was used: it is the last to fold when height runs out. */\nexport const touch = (s: DeskState, id: number): DeskState => ({ ...s, recent: [...s.recent.filter((x) => x !== id), id] });\n\n/** Fold or unfold a section (shade or unshade a palette) by hand; unfolding is a use. */\nexport function toggleFold(s: DeskState, id: number): DeskState {\n const folded = s.folded.includes(id);\n const next = { ...s, folded: folded ? s.folded.filter((x) => x !== id) : [...s.folded, id] };\n return folded ? touch(next, id) : next;\n}\n\n/** Fold a dock (or drawer) to its rail by hand, or open it again (then it folds last when width runs out). */\nexport function toggleClosed(s: DeskState, side: Side): DeskState {\n const closed = s.closed.includes(side);\n return closed ? { ...s, closed: s.closed.filter((x) => x !== side), opened: side } : { ...s, closed: [...s.closed, side] };\n}\n\n/** Show panel `id` on its side (navigator, drawers). */\nexport const withActive = (s: DeskState, side: Side, id: number): DeskState => touch({ ...s, active: { ...s.active, [side]: id } }, id);\n\n/** The state with `key` lifted out of wherever it is (before a drop puts it somewhere). */\nexport function liftOut(s: DeskState, key: string): DeskState {\n const dropK = (l: readonly string[]): string[] => l.filter((k) => k !== key);\n const base: DeskState = { ...s, tree: { L: dropK(s.tree.L), R: dropK(s.tree.R), C: dropK(s.tree.C) }, cols: s.cols.map(dropK).filter((c) => c.length > 0) };\n if (!isPanelKey(key)) return base;\n const id = idOf(key);\n const drop = (l: readonly number[]): number[] => l.filter((x) => x !== id);\n return {\n ...base,\n left: drop(s.left),\n right: drop(s.right),\n bottom: drop(s.bottom),\n torn: s.torn.filter((f) => f.id !== id),\n free: s.free.filter((f) => f.id !== id),\n stacks: { left: drop(s.stacks.left), right: drop(s.stacks.right) },\n active: { left: s.active.left === id ? null : s.active.left, right: s.active.right === id ? null : s.active.right },\n };\n}\n","/**\n * The arrangers the desk constructions build on, internal to `./dock`: master and stack for the documents, dwindle\n * for the tiling tree's center, stacked columns at natural heights, and the minimum-size give-way (the newest tile\n * that breaks a minimum floats). A public `./tiling` will come from a merge with a full split-tree model; these stay\n * the dock's own until then.\n */\nimport type { Rect, Size } from \"../geometry\";\n\n/**\n * Master and stack: the first id takes the left part (`ratio` of the width less the gap), the rest stack on the\n * right in equal rows. One id takes the whole area.\n */\nexport function masterStack<K>(ids: readonly K[], area: Rect, gap: number, ratio = 0.5): Map<K, Rect> {\n const out = new Map<K, Rect>();\n if (ids.length === 0) return out;\n if (ids.length === 1) {\n out.set(ids[0]!, { ...area });\n return out;\n }\n const mw = (area.width - gap) * ratio;\n out.set(ids[0]!, { x: area.x, y: area.y, width: mw, height: area.height });\n const k = ids.length - 1;\n const sh = (area.height - gap * (k - 1)) / k;\n ids.slice(1).forEach((id, i) => out.set(id, { x: area.x + mw + gap, y: area.y + i * (sh + gap), width: area.width - mw - gap, height: sh }));\n return out;\n}\n\n/** Dwindle over an order: each tile but the last splits the space left in two along its longer side. */\nexport function dwindle(area: Rect, n: number, gap: number): Rect[] {\n const out: Rect[] = [];\n let cur = { ...area };\n for (let i = 0; i < n; i++) {\n if (i === n - 1) {\n out.push(cur);\n break;\n }\n if (cur.width >= cur.height) {\n const w = (cur.width - gap) / 2;\n out.push({ x: cur.x, y: cur.y, width: w, height: cur.height });\n cur = { x: cur.x + w + gap, y: cur.y, width: w, height: cur.height };\n } else {\n const h = (cur.height - gap) / 2;\n out.push({ x: cur.x, y: cur.y, width: cur.width, height: h });\n cur = { x: cur.x, y: cur.y + h + gap, width: cur.width, height: h };\n }\n }\n return out;\n}\n\n/**\n * Heights for a column of items stacked in `avail` with gaps: each at its minimum (its natural height), the last\n * taking the rest. When the minimums don't fit, an even share instead, so the ones that break their minimum show.\n */\nexport function columnHeights(avail: number, mins: readonly number[], gap: number): number[] {\n const room = avail - gap * (mins.length - 1);\n const need = mins.reduce((a, b) => a + b, 0);\n if (need > room) return mins.map(() => room / mins.length);\n return mins.map((m, i) => (i === mins.length - 1 ? room - need + m : m));\n}\n\n/**\n * Lengths for items sharing `avail`: each gets at least its minimum, the rest of the room is shared in proportion\n * to the minimums (when the minimums don't fit, each gets its minimum).\n */\nexport function share(avail: number, mins: readonly number[]): number[] {\n const need = mins.reduce((a, b) => a + b, 0);\n const spare = Math.max(0, avail - need);\n return mins.map((m) => m + (need > 0 ? (spare * m) / need : spare / mins.length));\n}\n\n/**\n * The minimum-size give-way: while a tile is laid out below its minimum, the newest tile (highest `age`) floats and\n * the rest are laid out again. Stops when every tile keeps its minimum or one tile is left. `layout` lays out the\n * kept keys; the result says which are kept (in their order) and which float (newest first).\n */\nexport function giveWay<K>(keys: readonly K[], layout: (kept: readonly K[]) => ReadonlyMap<K, Rect>, min: (key: K) => Size, age: (key: K) => number): { kept: K[]; floats: K[] } {\n let kept = [...keys];\n const floats: K[] = [];\n for (;;) {\n const res = layout(kept);\n const broken = [...res].some(([k, r]) => r.width < min(k).width - 0.5 || r.height < min(k).height - 0.5);\n if (!broken || kept.length <= 1) return { kept, floats };\n const newest = kept.reduce((a, b) => (age(b) > age(a) ? b : a));\n kept = kept.filter((k) => k !== newest);\n floats.push(newest);\n }\n}\n","/**\n * The parts the desk constructions are built from, each pure: the toolbar pill, the documents' tiles, natural-height\n * sections (the last open one takes the rest; the least recently used fold to headers), rails, the edge docks'\n * geometry, the tiling tree's columns, the scrolling strip, tabbed sides and floating palettes.\n */\nimport { clampInto, rect, type Rect, type Size } from \"../geometry\";\nimport { columnHeights, dwindle, giveWay, masterStack } from \"./arrange\";\nimport { BAR, DOC_MIN, G, LAYER, RAIL, TABS, TITLE, docKey, idOf, isDocKey, panelKey, type Catalog, type DeskState, type Note, type Options, type Placed, type Side } from \"./model\";\n\nexport type Out = Map<string, Placed>;\n\nexport const plural = (n: number, one: string, many: string): string => `${n} ${n > 1 ? many : one}`;\n\n// --- the toolbar pill and the documents ----------------------------------------------------------------------------\n\n/** The shortest a pill gets (unless there is less room than that). */\nexport const PILL_MIN = 60;\n\n/**\n * The toolbar pill, floating at the top or the bottom of the band [y0, y1] above a region `cx`..`cx + cw`; returns\n * the pill and the band left for the documents (reserved: they keep clear of it; overlay: it floats over them).\n */\nexport function pill(opt: Options, cx: number, cw: number, y0: number, y1: number): { placed: Placed; top: number; bottom: number } {\n const pw = Math.max(PILL_MIN, Math.min(opt.toolbarWidth ?? 320, cw - 24));\n const ph = BAR - 4;\n const atTop = opt.toolbar === \"top\";\n // A hidden pill keeps no band clear, as if it floated.\n const overlay = opt.toolbarSpace === \"overlay\" || !!opt.toolbarHidden;\n return {\n placed: { rect: rect(cx + cw / 2 - pw / 2, atTop ? y0 + G : y1 - G - ph, pw, ph), look: \"pill\", layer: LAYER.toolbar, shadow: overlay, ...(opt.toolbarHidden ? { hidden: true } : {}) },\n top: atTop && !overlay ? y0 + BAR + 2 * G : y0 + G,\n bottom: !atTop && !overlay ? y1 - BAR - 2 * G : y1 - G,\n };\n}\n\n/** The toolbar as a bar across the top of the stage. */\nexport const bar = (W: number): Placed => ({ rect: rect(0, 0, W, BAR), look: \"bar\", layer: LAYER.toolbar });\n\n/** The documents in `r`, master and stack: the first takes 56 % of the width, the rest stack on the right. */\nexport function tiles(out: Out, r: Rect, ids: readonly number[], min?: Size): void {\n for (const [id, rr] of masterStack(ids, r, G, 0.56)) out.set(docKey(id), { rect: rr, look: \"doc\", layer: LAYER.doc, ...(min ? { min } : {}) });\n}\n\n// --- sections and rails --------------------------------------------------------------------------------------------\n\n/**\n * The ones of `ids` to fold, least recently used first, until what stays open fits `avail`. An accordion keeps one\n * section open whatever (`keepOne`); a palette stack shades even its last palette rather than run off the stage.\n */\nfunction lruFold(s: DeskState, ids: readonly number[], avail: number, open: (id: number) => number, closed: number, keepOne = true): number[] {\n const byHand = ids.filter((id) => s.folded.includes(id));\n const auto: number[] = [];\n const isOpen = (id: number): boolean => !byHand.includes(id) && !auto.includes(id);\n const need = (): number => ids.reduce((sum, id) => sum + (isOpen(id) ? open(id) : closed), 0) + G * (ids.length - 1);\n const order = [...s.recent].filter((id) => ids.includes(id));\n for (const id of order) {\n if (need() <= avail || (keepOne && ids.filter(isOpen).length <= 1)) break;\n if (isOpen(id)) auto.push(id);\n }\n return [...byHand, ...auto];\n}\n\n/**\n * Natural-height sections in x, y, w, h: each open section takes its natural height and the last open one takes\n * the rest; the least recently used fold to headers until the open ones fit. Returns how many folded by themselves.\n */\nexport function accordion(cat: Catalog, out: Out, s: DeskState, x: number, y: number, w: number, h: number, ids: readonly number[]): number {\n const folded = lruFold(s, ids, h, cat.natural, TITLE);\n const open = ids.filter((id) => !folded.includes(id));\n const room = h - G * (ids.length - 1) - TITLE * (ids.length - open.length);\n const last = open.at(-1);\n const rest = room - open.reduce((sum, id) => sum + (id === last ? 0 : cat.natural(id)), 0);\n let cy = y;\n for (const id of ids) {\n const i = open.indexOf(id);\n const n = cat.natural(id);\n const hh = i < 0 ? TITLE : id === last ? Math.max(n, rest) : n;\n out.set(panelKey(id), { rect: rect(x, cy, w, hh), look: i >= 0 ? \"section\" : \"header\", layer: LAYER.dock, ...(i >= 0 ? { min: { height: n } } : {}) });\n cy += hh + G;\n }\n return folded.filter((id) => !s.folded.includes(id)).length;\n}\n\n/** A rail of icons at x, y; the rect of its icon `i`. */\nconst railIcon =(x: number, y: number, i: number): Rect => rect(x + 6, y + 10 + i * 32, RAIL - 12, 24);\n\n/** A rail (a column whose panels are all folded) at x, y, h: one icon per panel. */\nexport function rail(out: Out, side: Side, x: number, y: number, h: number, ids: readonly number[], hidden = false): void {\n out.set(`rail:${side}`, { rect: rect(x, y, RAIL, h), look: \"rail\", layer: LAYER.dock, icons: ids, ...(hidden ? { hidden } : {}) });\n}\n\n/** Panels folded into a rail: hidden, each at its icon at `w` × its natural height. */\nexport function intoRail(cat: Catalog, out: Out, x: number, y: number, w: number, ids: readonly number[], side: Side): void {\n ids.forEach((id, i) => {\n const icon = railIcon(x, y, i);\n out.set(panelKey(id), { rect: rect(side === \"left\" ? icon.x : icon.x + icon.width - w, icon.y, w, cat.natural(id)), look: \"section\", layer: LAYER.dock, hidden: true });\n });\n}\n\n// --- edge docks ----------------------------------------------------------------------------------------------------\n\n/**\n * The dock width (rail excluded, its sections 240 px wide after the gap) and the narrowest the documents may get\n * before a dock folds.\n */\nexport const DOCK = 246;\nconst WORK_MIN = 380;\n/** The bottom dock's height when open, and the most of the stage's height it takes. */\nconst BOTTOM = 190;\nconst BOTTOM_SHARE = 0.36;\n\n/** What the edge docks put where: shared by their layouts and their drop targets. */\nexport interface DockGeometry {\n /** The side docks' height (less the bottom dock's in full-width mode). */\n readonly h: number;\n /** The bottom dock's height (its header's when folded; 0 when off). */\n readonly bh: number;\n readonly lOpen: boolean;\n readonly rOpen: boolean;\n /** The right dock's panels (the bottom dock's join them when it is off). */\n readonly right: readonly number[];\n readonly bottomOn: boolean;\n readonly bottomRect: Rect | null;\n /** The documents' band, left to right. */\n readonly x0: number;\n readonly x1: number;\n}\n\n/**\n * The edge docks' give-way: the bottom dock folds to its header when the stage is short, and a whole side dock\n * folds to its rail when the documents would get narrower than WORK_MIN (the right one first, unless it was opened\n * last by hand). `mode`: the bottom dock between the side docks, or across the full width under them.\n */\nexport function dockGeometry(cat: Catalog, s: DeskState, size: Size, opt: Options, mode: \"between\" | \"full\", notes: Note[] = []): DockGeometry {\n const { width: W, height: H } = size;\n const bottomOn = opt.bottom !== \"off\" && s.bottom.length > 0;\n const right = bottomOn ? s.right : [...s.right, ...s.bottom];\n const bottomFolded = bottomOn && (H < 480 || s.bottom.every((id) => s.folded.includes(id)));\n // Open, it is BOTTOM tall, never more than BOTTOM_SHARE of the stage (but never below what its panels need).\n const bh = !bottomOn ? 0 : bottomFolded ? TITLE : Math.max(...s.bottom.map(cat.natural), Math.min(BOTTOM, BOTTOM_SHARE * H));\n if (bottomOn && H < 480) notes.push({ code: \"bottom-folded\", text: \"bottom dock folded to its header\" });\n const full = mode === \"full\";\n const h = full && bottomOn ? H - bh - G : H;\n let lOpen = s.left.length > 0 && !s.closed.includes(\"left\");\n let rOpen = right.length > 0 && !s.closed.includes(\"right\");\n const work = (): number => W - 2 * RAIL - (lOpen ? DOCK : 0) - (rOpen ? DOCK : 0) - 2 * G;\n for (const side of s.opened === \"right\" ? ([\"left\", \"right\"] as const) : ([\"right\", \"left\"] as const)) {\n if (work() >= WORK_MIN) break;\n if (side === \"right\" && rOpen) {\n rOpen = false;\n notes.push({ code: \"dock-folded\", side: \"right\", text: \"right dock folded to its rail\" });\n } else if (side === \"left\" && lOpen) {\n lOpen = false;\n notes.push({ code: \"dock-folded\", side: \"left\", text: \"left dock folded to its rail\" });\n }\n }\n const x0 = RAIL + (lOpen ? DOCK : 0) + G;\n const x1 = W - RAIL - (rOpen ? DOCK : 0) - G;\n const bottomRect = bottomOn ? (full ? rect(G, H - G - bh, W - 2 * G, bh) : rect(x0, H - G - bh, x1 - x0, bh)) : null;\n return { h, bh, lOpen, rOpen, right, bottomOn, bottomRect, x0, x1 };\n}\n\n/** The width of a torn-off panel (its height is its natural height). */\nexport const TORN_W = 200;\n\n// --- the tiling tree -----------------------------------------------------------------------------------------------\n\n/** The smallest a tile may be: a document's minimum, or a panel at its natural height. */\nexport const tileMin = (cat: Catalog, key: string): Size => (isDocKey(key) ? DOC_MIN : { width: 150, height: cat.natural(idOf(key)) });\n/** A side column's width. */\nexport const TREE_COLUMN = 180;\n\n/** The tree's tiles laid out (no floating): the left and right columns, the center by dwindle. */\nexport function treeTiles(cat: Catalog, tree: DeskState[\"tree\"], area: Rect): Map<string, Rect> {\n const res = new Map<string, Rect>();\n let x0 = area.x;\n let x1 = area.x + area.width;\n // A side column's tiles take their natural height, the last one the rest.\n const column = (list: readonly string[], x: number): void => {\n const heights = columnHeights(area.height, list.map((k) => tileMin(cat, k).height), G);\n let y = area.y;\n list.forEach((k, i) => {\n res.set(k, rect(x, y, TREE_COLUMN, heights[i]!));\n y += heights[i]! + G;\n });\n };\n if (tree.L.length) {\n column(tree.L, x0);\n x0 += TREE_COLUMN + G;\n }\n if (tree.R.length) {\n column(tree.R, x1 - TREE_COLUMN);\n x1 -= TREE_COLUMN + G;\n }\n dwindle(rect(x0, area.y, x1 - x0, area.height), tree.C.length, G).forEach((r, i) => res.set(tree.C[i]!, r));\n return res;\n}\n\n/** The sides of the tree whose column is folded to a rail at the stage's edge (closed by hand, or at a narrow start). */\nexport const treeRails = (s: DeskState): { readonly left: boolean; readonly right: boolean } => ({\n left: s.closed.includes(\"left\") && s.tree.L.length > 0,\n right: s.closed.includes(\"right\") && s.tree.R.length > 0,\n});\n\n/** The area the tree tiles: the stage under the bar, less the rails of folded columns. */\nexport const treeArea = (size: Size, s?: DeskState): Rect => {\n const r = s ? treeRails(s) : { left: false, right: false };\n const x0 = r.left ? RAIL + G : G;\n const x1 = size.width - (r.right ? RAIL + G : G);\n return rect(x0, BAR + G, x1 - x0, size.height - BAR - 2 * G);\n};\n\n/** The tree as tiled: a column folded to its rail tiles nothing. */\nexport const treeShown = (s: DeskState): DeskState[\"tree\"] => {\n const r = treeRails(s);\n return { L: r.left ? [] : s.tree.L, R: r.right ? [] : s.tree.R, C: s.tree.C };\n};\n\n/** Which tiles float: the newest tile that breaks a minimum floats, then the tree is laid out again. */\nexport function treeFloats(cat: Catalog, tree: DeskState[\"tree\"], area: Rect): { tree: DeskState[\"tree\"]; floats: string[] } {\n const only = (kept: readonly string[]): DeskState[\"tree\"] => ({ L: tree.L.filter((k) => kept.includes(k)), R: tree.R.filter((k) => kept.includes(k)), C: tree.C.filter((k) => kept.includes(k)) });\n const { kept, floats } = giveWay(\n [...tree.L, ...tree.R, ...tree.C],\n (k) => treeTiles(cat, only(k), area),\n (k) => tileMin(cat, k),\n cat.born,\n );\n return { tree: only(kept), floats };\n}\n\n// --- tabbed sides --------------------------------------------------------------------------------------------------\n\n/**\n * One side with tabs: the tab row on top, the active panel under it, the others hidden behind it. `float` puts\n * them over the documents (a drawer that slides over).\n */\nexport function tabbed(out: Out, side: Side, ids: readonly number[], active: number | null, x: number, y: number, w: number, h: number, float: boolean): void {\n const shown = active !== null && ids.includes(active) ? active : (ids[0] ?? null);\n out.set(`tabs:${side}`, { rect: rect(x, y, w, TABS), look: \"tabs\", layer: float ? LAYER.float : LAYER.dock, tabs: ids, active: shown, ...(float ? { shadow: true } : {}) });\n for (const id of ids) {\n const r = rect(x, y + TABS, w, h - TABS);\n out.set(panelKey(id), { rect: r, look: \"bare\", layer: float ? LAYER.float : LAYER.dock, ...(id === shown ? {} : { hidden: true }), ...(float ? { shadow: true } : {}) });\n }\n}\n\n/** A side folded to its rail: the tab row and the panels hidden into it. */\nexport function tabbedIntoRail(cat: Catalog, out: Out, side: Side, ids: readonly number[], x: number, y: number, w: number): void {\n out.set(`tabs:${side}`, { rect: rect(side === \"left\" ? x : x + RAIL - w, y, w, TABS), look: \"tabs\", layer: LAYER.dock, tabs: ids, active: null, hidden: true });\n intoRail(cat, out, x, y, w, ids, side);\n}\n\n/** Below these widths a drawer slides over the documents instead of pushing them. */\nexport const DRAWER_DOCK = { left: 760, right: 1040 } as const;\n\n// --- the scrolling strip -------------------------------------------------------------------------------------------\n\nconst STRIP_PANEL_W = 180;\nconst stripDocW =(W: number): number => Math.max(360, Math.min(520, W * 0.5));\nexport const stripMin = (cat: Catalog, k: string): number => (isDocKey(k) ? DOC_MIN.height : cat.natural(idOf(k)));\n\n/** The strip's columns as laid out: a column whose minimums don't fit the height splits in two, recursively. */\nexport function stripColumns(cat: Catalog, cols: readonly (readonly string[])[], h: number, notes: Note[] = []): string[][] {\n const split = (keys: readonly string[]): string[][] => {\n const need = keys.reduce((sum, k) => sum + stripMin(cat, k), 0) + G * (keys.length - 1);\n if (need <= h || keys.length === 1) return [[...keys]];\n const half = Math.ceil(keys.length / 2);\n notes.push({ code: \"column-split\", items: [...keys], text: `${keys.map(cat.title).join(\" + \")} split into two columns` });\n return [...split(keys.slice(0, half)), ...split(keys.slice(half))];\n };\n return cols.flatMap(split);\n}\n\nexport interface StripGeometry {\n readonly cols: string[][];\n /** Each column's left edge on the stage (scroll applied) and width. */\n readonly xs: number[];\n readonly widths: number[];\n readonly y: number;\n readonly h: number;\n /** The whole strip's width, and how far it is scrolled. */\n readonly total: number;\n readonly scroll: number;\n}\n\n/** The strip's columns and scroll: scrolled by hand, else to center the focused document's column. */\nexport function stripGeometry(cat: Catalog, s: DeskState, size: Size, notes: Note[] = []): StripGeometry {\n const { width: W, height: H } = size;\n const y = BAR + G;\n const h = H - BAR - 2 * G;\n const cols = stripColumns(cat, s.cols, h, notes);\n const widths = cols.map((c) => (c.some(isDocKey) ? stripDocW(W) : STRIP_PANEL_W));\n const total = widths.reduce((a, b) => a + b, 0) + G * (cols.length + 1);\n const want = s.focus !== null ? docKey(s.focus) : null;\n let fi = cols.findIndex((c) => want !== null && c.includes(want));\n if (fi < 0) fi = cols.findIndex((c) => c.some(isDocKey));\n const xsAbs: number[] = [];\n let x = G;\n for (const w of widths) {\n xsAbs.push(x);\n x += w + G;\n }\n const focusX = fi >= 0 ? xsAbs[fi]! + widths[fi]! / 2 : 0;\n const scroll = Math.max(0, Math.min(total - W, s.stripScroll ?? focusX - W / 2));\n return { cols, xs: xsAbs.map((v) => v - scroll), widths, y, h, total, scroll };\n}\n\n// --- floating palettes ---------------------------------------------------------------------------------------------\n\nexport const paletteWidth = (W: number): number => Math.min(200, Math.max(140, W * 0.22));\n/** Narrower than this, both stacks share the right corner. */\nexport const PALETTE_NARROW = 640;\n/** The margin palettes keep from the area's edges when they float over the documents. */\nexport const OVER_MARGIN = 14;\n\n/**\n * Palettes at their natural size, stacked in the top corners of `area` (`m` in from its edges), and the free ones\n * where they were put; a stack too tall for the area shades its least recently used palettes to their title bars.\n */\nexport function palettes(cat: Catalog, s: DeskState, area: Rect, W: number, m: number, notes: Note[] = []): Map<number, { rect: Rect; shaded: boolean }> {\n const pw = paletteWidth(W);\n const avail = area.height - 2 * m;\n const narrow = W < PALETTE_NARROW;\n const stacks = narrow ? [[...s.stacks.left, ...s.stacks.right]] : [s.stacks.left, s.stacks.right];\n if (narrow && s.stacks.left.length && s.stacks.right.length) notes.push({ code: \"stacks-merged\", text: \"both stacks share the right corner\" });\n const out = new Map<number, { rect: Rect; shaded: boolean }>();\n let shaded = 0;\n stacks.forEach((ids, si) => {\n const folded = lruFold(s, ids, avail, cat.natural, TITLE, false);\n shaded += folded.filter((id) => !s.folded.includes(id)).length;\n const x = narrow || si === 1 ? area.x + area.width - m - pw : area.x + m;\n let y = area.y + m;\n for (const id of ids) {\n const h = folded.includes(id) ? TITLE : cat.natural(id);\n out.set(id, { rect: rect(x, y, pw, h), shaded: folded.includes(id) });\n y += h + G;\n }\n });\n for (const f of s.free) {\n const shade = s.folded.includes(f.id);\n const at = f.at ?? { x: area.x + m, y: area.y + m };\n out.set(f.id, { rect: clampInto(rect(at.x, at.y, pw, shade ? TITLE : cat.natural(f.id)), area), shaded: shade });\n }\n if (shaded) notes.push({ code: \"palettes-shaded\", text: `${plural(shaded, \"palette\", \"palettes\")} shaded to ${shaded > 1 ? \"title bars\" : \"a title bar\"}` });\n return out;\n}\n\n/** The stage area palettes and documents share (below or above the pill when it keeps its band). */\nexport function paletteArea(size: Size, opt: Options): { area: Rect } {\n const p = pill(opt, G, size.width - 2 * G, 0, size.height);\n return { area: rect(G, p.top, size.width - 2 * G, p.bottom - p.top) };\n}\n\n/**\n * A floating pill among palettes: in a stretch of its band that no palette crosses, so it never covers one. Of the\n * stretches wide enough for a full-width pill (its minimum plus margins), the one nearest the center; with none, the\n * widest, the pill shrunk to fit it.\n */\nexport function pillBetween(opt: Options, size: Size, blocks: readonly Rect[]): Placed {\n const band = pill(opt, G, size.width - 2 * G, 0, size.height).placed.rect;\n const spans = blocks\n .filter((r) => r.y < band.y + band.height && r.y + r.height > band.y)\n .map((r) => [r.x - G, r.x + r.width + G] as const)\n .sort((a, b) => a[0] - b[0]);\n const stretches: [number, number][] = [];\n let x = G;\n for (const [b0, b1] of spans) {\n if (b0 > x) stretches.push([x, b0]);\n x = Math.max(x, b1);\n }\n if (size.width - G > x) stretches.push([x, size.width - G]);\n const roomy = stretches.filter(([a, b]) => b - a >= PILL_MIN + 24);\n const mid = size.width / 2;\n const pick =\n roomy.sort((p, q) => Math.abs((p[0] + p[1]) / 2 - mid) - Math.abs((q[0] + q[1]) / 2 - mid))[0] ??\n stretches.sort((p, q) => q[1] - q[0] - (p[1] - p[0]))[0] ??\n ([G, G] as [number, number]);\n const placed = pill(opt, pick[0], pick[1] - pick[0], 0, size.height).placed;\n const room = pick[1] - pick[0];\n // Too little room for even the shortest pill: it shrinks to the room rather than cover a palette.\n return placed.rect.width <= room ? placed : { ...placed, rect: { ...placed.rect, x: pick[0], width: Math.max(0, room) } };\n}\n\n/** The documents' band between the palettes on the left half and those on the right half. */\nexport function aroundDocs(pals: ReadonlyMap<number, { rect: Rect }>, area: Rect): Rect {\n const mid = area.x + area.width / 2;\n const rects = [...pals.values()].map((p) => p.rect);\n const left = rects.filter((r) => r.x + r.width / 2 < mid);\n const right = rects.filter((r) => r.x + r.width / 2 >= mid);\n const x0 = left.length ? Math.max(...left.map((r) => r.x + r.width)) + G : area.x;\n const x1 = right.length ? Math.min(...right.map((r) => r.x)) - G : area.x + area.width;\n return rect(x0, area.y, Math.max(0, x1 - x0), area.height);\n}\n"],"mappings":";;;;;;AAUO,IAAM,IAAI;AAEV,IAAM,MAAM;AAEZ,IAAM,OAAO;AAEb,IAAM,QAAQ;AAEd,IAAM,OAAO;AAEb,IAAM,UAAgB,EAAE,OAAO,KAAK,QAAQ,IAAI;AAGhD,IAAM,WAAW,CAAC,OAAuB,SAAS,EAAE;AACpD,IAAM,SAAS,CAAC,OAAuB,OAAO,EAAE;AAChD,IAAM,aAAa,CAAC,QAAyB,IAAI,WAAW,QAAQ;AACpE,IAAM,WAAW,CAAC,QAAyB,IAAI,WAAW,MAAM;AAChE,IAAM,OAAO,CAAC,QAAwB,OAAO,IAAI,MAAM,IAA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