@n-uf/placement 26.11.52 → 26.11.54

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.
Files changed (62) hide show
  1. package/CHANGELOG.md +89 -1
  2. package/README.md +27 -58
  3. package/dist/{chunk-VLTYJHUA.js → chunk-2UVUFEBP.js} +4 -8
  4. package/dist/{chunk-VLTYJHUA.js.map → chunk-2UVUFEBP.js.map} +1 -1
  5. package/dist/{geometry-Bf37LbCT.d.ts → geometry-L5gCoiZV.d.ts} +2 -8
  6. package/dist/index.d.ts +64 -42
  7. package/dist/index.js +6 -66
  8. package/dist/index.js.map +1 -1
  9. package/dist/popup.d.ts +49 -0
  10. package/dist/popup.js +58 -0
  11. package/dist/popup.js.map +1 -0
  12. package/dist/stack.d.ts +529 -228
  13. package/dist/stack.js +701 -28
  14. package/dist/stack.js.map +1 -1
  15. package/dist/tiling.d.ts +48 -5
  16. package/dist/tiling.js +198 -19
  17. package/dist/tiling.js.map +1 -1
  18. package/package.json +9 -36
  19. package/dist/chunk-2GGJ4GVR.js +0 -9
  20. package/dist/chunk-2GGJ4GVR.js.map +0 -1
  21. package/dist/chunk-3ZICYLWL.js +0 -791
  22. package/dist/chunk-3ZICYLWL.js.map +0 -1
  23. package/dist/chunk-67D32MZ4.js +0 -4178
  24. package/dist/chunk-67D32MZ4.js.map +0 -1
  25. package/dist/chunk-AE3BWTAE.js +0 -838
  26. package/dist/chunk-AE3BWTAE.js.map +0 -1
  27. package/dist/chunk-JVAR67OL.js +0 -172
  28. package/dist/chunk-JVAR67OL.js.map +0 -1
  29. package/dist/chunk-NF7RYK3U.js +0 -429
  30. package/dist/chunk-NF7RYK3U.js.map +0 -1
  31. package/dist/chunk-R3AAANRY.js +0 -220
  32. package/dist/chunk-R3AAANRY.js.map +0 -1
  33. package/dist/chunk-TWI644JK.js +0 -221
  34. package/dist/chunk-TWI644JK.js.map +0 -1
  35. package/dist/constructions-Cbz7uEAZ.d.ts +0 -251
  36. package/dist/desk.d.ts +0 -51
  37. package/dist/desk.js +0 -111
  38. package/dist/desk.js.map +0 -1
  39. package/dist/dock.d.ts +0 -25
  40. package/dist/dock.js +0 -397
  41. package/dist/dock.js.map +0 -1
  42. package/dist/float-fit-DCYxRMru.d.ts +0 -37
  43. package/dist/lanes-DIwUqchd.d.ts +0 -1321
  44. package/dist/model-X7eUaKlA.d.ts +0 -337
  45. package/dist/panels.d.ts +0 -60
  46. package/dist/panels.js +0 -99
  47. package/dist/panels.js.map +0 -1
  48. package/dist/regions-Db_RyT4P.d.ts +0 -48
  49. package/dist/scene-cases.d.ts +0 -888
  50. package/dist/scene-cases.js +0 -3149
  51. package/dist/scene-cases.js.map +0 -1
  52. package/dist/scene.d.ts +0 -290
  53. package/dist/scene.js +0 -128
  54. package/dist/scene.js.map +0 -1
  55. package/dist/target-BBOCeez2.d.ts +0 -69
  56. package/dist/targets-C9ZVhmCl.d.ts +0 -621
  57. package/dist/targets.d.ts +0 -212
  58. package/dist/targets.js +0 -447
  59. package/dist/targets.js.map +0 -1
  60. package/dist/toolbar.d.ts +0 -167
  61. package/dist/toolbar.js +0 -55
  62. package/dist/toolbar.js.map +0 -1
@@ -1,251 +0,0 @@
1
- import { R as Rect, S as Size } from './geometry-Bf37LbCT.js';
2
-
3
- /**
4
- * The desk's model: panels and documents, the options, the state every construction keeps, and what a layout
5
- * returns (a placed rect per item). The panels themselves (their titles and natural heights) come from the
6
- * consumer as a catalog; see `createDesk`.
7
- */
8
-
9
- type Side = "left" | "right";
10
- /** Gaps and sizes, in stage px. */
11
- declare const G = 6;
12
- /** Items are keyed "panel:<id>" and "doc:<id>". */
13
- declare const panelKey: (id: number) => string;
14
- declare const docKey: (id: number) => string;
15
- declare const isPanelKey: (key: string) => boolean;
16
- declare const isDocKey: (key: string) => boolean;
17
- declare const idOf: (key: string) => number;
18
- /** A tool panel: its title and the height its content needs (its natural height, title bar included). */
19
- interface PanelSpec {
20
- readonly id: number;
21
- readonly title: string;
22
- readonly natural: number;
23
- }
24
- /** Where the panels start. Unset parts follow from the sides (see `createDesk`). */
25
- interface DeskStart {
26
- readonly left: readonly number[];
27
- readonly right: readonly number[];
28
- readonly bottom: readonly number[];
29
- readonly active?: {
30
- readonly left: number | null;
31
- readonly right: number | null;
32
- };
33
- readonly tree?: DeskState["tree"];
34
- readonly cols?: DeskState["cols"];
35
- readonly stacks?: DeskState["stacks"];
36
- }
37
- /** What a desk is made of: its panels, its documents' titles and where the panels start. */
38
- interface DeskSpec {
39
- readonly panels: readonly PanelSpec[];
40
- /** A document's title (default "Document <id>"). */
41
- readonly docTitle?: (id: number) => string;
42
- readonly start: DeskStart;
43
- /** The panels in the order they were opened (default: as listed); the tiling tree floats the newest first. */
44
- readonly opened?: readonly number[];
45
- }
46
- /** The catalog every part reads: a panel's natural height, an item's title and age. */
47
- interface Catalog {
48
- readonly panelIds: readonly number[];
49
- readonly natural: (id: number) => number;
50
- /** An item's title by key ("panel:<id>", "doc:<id>"); any other key is its own title. */
51
- readonly title: (key: string) => string;
52
- /** An item's age: higher is newer (panels in the order they were opened, then the documents). */
53
- readonly born: (key: string) => number;
54
- readonly start: Required<DeskStart>;
55
- }
56
- /** Where the toolbar floats (top or bottom) and whether the documents keep a band clear for it; the bottom dock's mode. */
57
- interface Options {
58
- readonly toolbar: "top" | "bottom";
59
- readonly toolbarSpace: "reserved" | "overlay";
60
- readonly bottom: "reserved" | "overlay" | "off";
61
- /** The pill's width when its contents need more than the default; unset: the default. */
62
- readonly toolbarWidth?: number;
63
- /** The pill holds nothing: it takes no space and isn't shown. */
64
- readonly toolbarHidden?: boolean;
65
- }
66
- declare const DEFAULT_OPTIONS: Options;
67
- /** A panel placed freely (torn off, or a palette out of its stack): its top-left corner, null for the default spot. */
68
- interface Free {
69
- readonly id: number;
70
- readonly at: {
71
- readonly x: number;
72
- readonly y: number;
73
- } | null;
74
- }
75
- /**
76
- * Everything any construction keeps. Each construction has its own copy (its own arrangement) and reads only what
77
- * it uses; the open documents are the same in all of them.
78
- */
79
- interface DeskState {
80
- /** Open document ids, in open order. */
81
- readonly docs: readonly number[];
82
- readonly focus: number | null;
83
- /** Panel ids, least recently used first: what folds or shades first when height runs out. */
84
- readonly recent: readonly number[];
85
- /** Sections folded (palettes shaded) by hand. */
86
- readonly folded: readonly number[];
87
- /** Docks, navigator sides and drawers: the panels on each side, top to bottom (tabs: left to right). */
88
- readonly left: readonly number[];
89
- readonly right: readonly number[];
90
- /** The bottom dock's panels (edge docks only). */
91
- readonly bottom: readonly number[];
92
- /** Docks or drawers folded to their rail by hand. */
93
- readonly closed: readonly Side[];
94
- /** The side opened last by hand: when width runs out it folds last. */
95
- readonly opened: Side | null;
96
- /** The panel showing on each side (navigator, drawers). */
97
- readonly active: {
98
- readonly left: number | null;
99
- readonly right: number | null;
100
- };
101
- /** Panels torn off a dock, floating (edge docks + tear-off). */
102
- readonly torn: readonly Free[];
103
- /** The tiling tree: item keys in the left column, the right column and the center (dwindle order). */
104
- readonly tree: {
105
- readonly L: readonly string[];
106
- readonly R: readonly string[];
107
- readonly C: readonly string[];
108
- };
109
- /** The scrolling strip: its columns, left to right, each a list of item keys top to bottom. */
110
- readonly cols: readonly (readonly string[])[];
111
- /** The strip scrolled by hand, or null: it scrolls to the focus. */
112
- readonly stripScroll: number | null;
113
- /** Palettes: the corner stacks, top to bottom, and the ones placed anywhere. */
114
- readonly stacks: {
115
- readonly left: readonly number[];
116
- readonly right: readonly number[];
117
- };
118
- readonly free: readonly Free[];
119
- }
120
- /** How an item is drawn. */
121
- type Look = "pill" | "bar" | "section" | "header" | "float" | "palette" | "tile" | "bare" | "doc" | "rail" | "tabs" | "track" | "thumb";
122
- /** Stacking layers, bottom to top. */
123
- declare const LAYER: {
124
- readonly doc: 1;
125
- readonly dock: 2;
126
- readonly palette: 3;
127
- readonly overlay: 4;
128
- readonly float: 5;
129
- readonly toolbar: 6;
130
- };
131
- /** One item as a layout places it. */
132
- interface Placed {
133
- readonly rect: Rect;
134
- readonly look: Look;
135
- readonly layer: number;
136
- /** Folded away (into a rail, behind a tab): it goes to `rect`, hidden. */
137
- readonly hidden?: boolean;
138
- /** Never laid out below this (where the construction promises it). */
139
- readonly min?: Partial<Size>;
140
- /** It may lie outside the stage (the strip scrolls). */
141
- readonly offStage?: boolean;
142
- /** A rail's icons or a tab row's tabs (panel ids), and the active tab. */
143
- readonly icons?: readonly number[];
144
- readonly tabs?: readonly number[];
145
- readonly active?: number | null;
146
- /** Drawn with an accent outline (the bottom dock). */
147
- readonly accent?: boolean;
148
- /** Drawn with a shadow (it floats over something). */
149
- readonly shadow?: boolean;
150
- }
151
- /**
152
- * How a layout gave way (or what it is worth knowing about it):
153
- *
154
- * - `bottom-folded`: the bottom dock folded to its header; `dock-folded`: a side dock folded to its rail (`side`);
155
- * - `sections-folded`: sections folded to their headers by themselves, least recently used first;
156
- * - `torn-floating`: panels torn off a dock float (`items`); `torn-shaded`: some shade because they don't fit;
157
- * - `columns-railed`: the tiling tree's side columns are folded to rails (`side` when only one);
158
- * - `tiles-float`: tiles that broke a minimum float, newest first (`items`);
159
- * - `tabs-folded`: a tabbed side folded to icon tabs (`side`); `drawer-over`: a drawer slides over the
160
- * documents (`side`);
161
- * - `column-split`: a strip column split in two (`items`); `strip-scrolls`: the strip is wider than the stage;
162
- * - `stacks-merged`: both palette stacks share one corner; `palettes-shaded`: palettes shaded to title bars;
163
- * - `palettes-cover`, `docs-room`: how much of the documents palettes cover, and how much room they leave.
164
- */
165
- type NoteCode = "bottom-folded" | "dock-folded" | "sections-folded" | "torn-floating" | "torn-shaded" | "columns-railed" | "tiles-float" | "tabs-folded" | "drawer-over" | "column-split" | "strip-scrolls" | "stacks-merged" | "palettes-shaded" | "palettes-cover" | "docs-room";
166
- /**
167
- * One note on a layout. `code` (and `side`, `items` where they apply) is the contract; `text` says it in English for
168
- * people, and its wording may change in any release.
169
- */
170
- interface Note {
171
- readonly code: NoteCode;
172
- readonly text: string;
173
- readonly side?: Side;
174
- /** The item keys it is about. */
175
- readonly items?: readonly string[];
176
- }
177
- /** Where everything is ("toolbar", "panel:<id>", "doc:<id>", "rail:<side>", "tabs:<side>", "track", "thumb"), and how it gave way. */
178
- interface Layout {
179
- readonly items: ReadonlyMap<string, Placed>;
180
- readonly notes: readonly Note[];
181
- }
182
- /**
183
- * The same state with these documents open: new ones join the tiling tree's center (the first one at its front)
184
- * and get a strip column of their own after the last document column; closed ones leave both.
185
- */
186
- declare function withDocs(s: DeskState, docs: readonly number[], focus: number | null): DeskState;
187
- /** Panel `id` was used: it is the last to fold when height runs out. */
188
- declare const touch: (s: DeskState, id: number) => DeskState;
189
- /** Fold or unfold a section (shade or unshade a palette) by hand; unfolding is a use. */
190
- declare function toggleFold(s: DeskState, id: number): DeskState;
191
- /** Fold a dock (or drawer) to its rail by hand, or open it again (then it folds last when width runs out). */
192
- declare function toggleClosed(s: DeskState, side: Side): DeskState;
193
- /** Show panel `id` on its side (navigator, drawers). */
194
- declare const withActive: (s: DeskState, side: Side, id: number) => DeskState;
195
- /** The state with `key` lifted out of wherever it is (before a drop puts it somewhere). */
196
- declare function liftOut(s: DeskState, key: string): DeskState;
197
-
198
- /**
199
- * The nine desk constructions, presets built from the parts: a state, the stage size and the options in, a placed
200
- * rect per item out, plus notes saying how it gave way. How each one gives way when width or height runs out:
201
- *
202
- * - Edge docks (`docks`): sections fold to headers (least recently used first), the bottom dock folds to its
203
- * header, the docks fold to their rails (right first). `docksFull` runs the bottom dock across the full width.
204
- * - One tiling tree (`tree`): the newest tile that breaks a minimum floats.
205
- * - Navigator + inspector (`navigator`): the sides fold to icon tabs; height never matters.
206
- * - Scrolling strip (`strip`): a column whose minimums don't fit splits in two; the strip scrolls to the focus.
207
- * - Drawers (`drawers`): below a width a drawer slides over the documents instead of pushing them.
208
- * - Palettes over the documents (`floatOver`), and palettes with the documents tiled around them (`floatAround`):
209
- * the least recently used shade to their title bars; narrow, the stacks merge in one corner.
210
- * - Edge docks + tear-off (`dockTear`): as the edge docks, and torn-off panels float (and shade when they don't fit).
211
- */
212
-
213
- type ConstructionId = "docks" | "docksFull" | "tree" | "navigator" | "strip" | "drawers" | "floatOver" | "floatAround" | "dockTear";
214
- interface Construction {
215
- readonly id: ConstructionId;
216
- readonly title: string;
217
- readonly idea: string;
218
- /** It has a floating toolbar pill (top or bottom, reserved or overlay). */
219
- readonly pill: boolean;
220
- /** It has a bottom dock (reserved, floating or off). */
221
- readonly bottom: boolean;
222
- /** The arrangement it starts from (at this stage size, when it depends on one). */
223
- readonly initial: (docs: readonly number[], size?: Size) => DeskState;
224
- readonly layout: (s: DeskState, size: Size, opt: Options) => Layout;
225
- /** The desk it belongs to (its catalog). */
226
- readonly desk: Desk;
227
- }
228
- /** A desk: the catalog, its nine constructions, and the catalog-bound helpers. */
229
- interface Desk {
230
- readonly catalog: Catalog;
231
- readonly constructions: readonly Construction[];
232
- readonly constructionOf: (id: ConstructionId) => Construction;
233
- /** The arrangement every construction starts from, with these documents open (none by default). */
234
- readonly initialState: (docs?: readonly number[]) => DeskState;
235
- readonly natural: (id: number) => number;
236
- readonly titleOf: (key: string) => string;
237
- }
238
- /**
239
- * A desk for these panels: the nine constructions as presets, each a pure layout over the shared state.
240
- *
241
- * ```ts
242
- * const desk = createDesk({ panels: [{ id: 1, title: "Files", natural: 160 }], start: { left: [1], right: [], bottom: [] } });
243
- * const c = desk.constructionOf("docks");
244
- * const { items, notes } = c.layout(c.initial([1, 2]), { width: 960, height: 560 }, DEFAULT_OPTIONS);
245
- * ```
246
- */
247
- declare function createDesk(spec: DeskSpec): Desk;
248
- /** Which items a construction lets the pointer drag: panels everywhere, documents in the tree and the strip. */
249
- declare const draggable: (c: Construction, key: string) => boolean;
250
-
251
- export { type Catalog as C, type DeskState as D, type Free as F, G, LAYER as L, type Note as N, type Options as O, type PanelSpec as P, type Side as S, type Construction as a, type ConstructionId as b, DEFAULT_OPTIONS as c, type Desk as d, type DeskSpec as e, type DeskStart as f, type Layout as g, type Look as h, type NoteCode as i, type Placed as j, createDesk as k, docKey as l, draggable as m, idOf as n, isDocKey as o, isPanelKey as p, liftOut as q, panelKey as r, toggleFold as s, toggleClosed as t, touch as u, withDocs as v, withActive as w };
package/dist/desk.d.ts DELETED
@@ -1,51 +0,0 @@
1
- import { P as PanelsOptions, a as PanelDef, b as PanelsState, c as PanelTargetInput, d as PanelTarget, p as panelDrop, e as PanelDrop, l as layoutPanels, f as PanelsLayout } from './targets-C9ZVhmCl.js';
2
- import './geometry-Bf37LbCT.js';
3
- import './target-BBOCeez2.js';
4
-
5
- /**
6
- * @n-uf/placement/desk: desk presets as data on `@n-uf/placement/panels`. A preset is options for the panels engine
7
- * and a start state; it carries no titles, no words and no toolbar wiring (the app names presets and wires its
8
- * toolbar). It imports only the panels entry's public index, so an app that imports only `./panels` loads none of it.
9
- *
10
- * - `docks`: one stack column per side and a bottom band between them (reserved: it shortens the pages); sections at
11
- * their natural heights when the defs give `height`; short of width a column folds to its side's rail, short of
12
- * height the band folds to a bar. No floats.
13
- * - `docksFull`: as docks, with the bottom band full width (the columns stand on it).
14
- * - `dockTear`: as docks, and panels may float (tear-off and dock-back); one panel floats in the start state.
15
- * - `navigator`: a tabbed column on the left, a stack column on the right. No band, no floats.
16
- *
17
- * The bottom band starts with the hint's `bottom` panels, else the last def whose `sides` names "bottom" (a def
18
- * without `sides` may be dropped there, but doesn't start there).
19
- *
20
- * A legacy entry. See docs/placement.md, Entry: desk.
21
- */
22
-
23
- type PresetId = "docks" | "docksFull" | "dockTear" | "navigator";
24
- /** Which panels start on which side (ids in order), and in the bottom band (a preset with one); the others are placed by the preset. */
25
- interface DeskHint {
26
- readonly left?: readonly string[];
27
- readonly right?: readonly string[];
28
- readonly bottom?: readonly string[];
29
- }
30
- interface DeskPreset {
31
- readonly id: PresetId;
32
- /** The panels options the preset lays out with (the caller's own options go over them). */
33
- readonly options: Partial<PanelsOptions>;
34
- /** Whether its panels may float: when not, `presetTargets` offers no float target. */
35
- readonly floats: boolean;
36
- /** Its start state for these panels. */
37
- start(defs: readonly PanelDef[], hint?: DeskHint): PanelsState;
38
- }
39
- type Stage = Parameters<typeof layoutPanels>[2];
40
- type Point = Parameters<typeof panelDrop>[2];
41
- declare const PRESETS: Readonly<Record<PresetId, DeskPreset>>;
42
- /** `layoutPanels` with the preset's options under the caller's. */
43
- declare function presetLayout(preset: DeskPreset, defs: readonly PanelDef[], state: PanelsState, stage: Stage, options?: Partial<PanelsOptions>): PanelsLayout;
44
- /** The target input with the preset's options under the caller's, and only the places the preset allows. */
45
- declare function presetInput(preset: DeskPreset, input: PanelTargetInput): PanelTargetInput;
46
- /** `panelTargets` with the preset's options under the caller's, and only the places the preset allows. */
47
- declare function presetTargets(preset: DeskPreset, input: PanelTargetInput): PanelTarget[];
48
- /** `panelDrop` laid out with the preset's options (so the slot is where the preset lays the panel). */
49
- declare function presetDrop(preset: DeskPreset, input: PanelTargetInput, target: PanelTarget, point: Point, grab: Point): PanelDrop;
50
-
51
- export { type DeskHint, type DeskPreset, PRESETS, type PresetId, presetDrop, presetInput, presetLayout, presetTargets };
package/dist/desk.js DELETED
@@ -1,111 +0,0 @@
1
- import "./chunk-JVAR67OL.js";
2
- import {
3
- createPanels,
4
- floatSize,
5
- layoutPanels,
6
- panelDrop,
7
- panelTargets,
8
- showTabs
9
- } from "./chunk-3ZICYLWL.js";
10
- import "./chunk-VLTYJHUA.js";
11
-
12
- // src/desk/index.ts
13
- function split(defs, hint = {}) {
14
- const known = new Set(defs.map((d) => d.id));
15
- const left = (hint.left ?? []).filter((id) => known.has(id));
16
- const right = (hint.right ?? []).filter((id) => known.has(id) && !left.includes(id));
17
- const rest = defs.filter((d) => !left.includes(d.id) && !right.includes(d.id));
18
- const half = Math.ceil(defs.length / 2);
19
- for (const d of rest) {
20
- const mayL = !d.sides || d.sides.includes("left");
21
- const mayR = !d.sides || d.sides.includes("right");
22
- if (mayL && (left.length < half || !mayR)) left.push(d.id);
23
- else if (mayR) right.push(d.id);
24
- else left.push(d.id);
25
- }
26
- return { left, right };
27
- }
28
- var columns = (ids) => ids.length ? [[...ids]] : [];
29
- function bottomOf(defs, hint = {}) {
30
- const known = new Set(defs.map((d) => d.id));
31
- if (hint.bottom) return hint.bottom.filter((id) => known.has(id));
32
- const last = [...defs].reverse().find((d) => d.sides?.includes("bottom"));
33
- return last ? [last.id] : [];
34
- }
35
- var sidesOnly = (defs, hint, band) => [
36
- defs.filter((d) => !band.includes(d.id)),
37
- hint && { ...hint, left: hint.left?.filter((id) => !band.includes(id)), right: hint.right?.filter((id) => !band.includes(id)) }
38
- ];
39
- var banded = (start) => (defs, hint) => {
40
- const bottom = bottomOf(defs, hint);
41
- const [rest, h] = sidesOnly(defs, hint, bottom);
42
- const s = start(rest, h);
43
- return bottom.length ? createPanels(defs, { ...startOf(s), bottom }) : s;
44
- };
45
- function startOf(s) {
46
- return {
47
- left: s.sides.left.map((c) => c.panels),
48
- right: s.sides.right.map((c) => c.panels),
49
- floats: s.floats.map((f) => ({ id: f.id, x: f.rect.x, y: f.rect.y, width: f.rect.width, height: f.rect.height, ...f.pinned ? { pinned: true } : {} })),
50
- folded: s.folded,
51
- kept: s.kept,
52
- closed: s.closed
53
- };
54
- }
55
- var docksStart = (defs, hint) => {
56
- const { left, right } = split(defs, hint);
57
- return createPanels(defs, { left: columns(left), right: columns(right) });
58
- };
59
- var BOTTOM = { mode: "reserved", span: "between" };
60
- var docks = { id: "docks", options: { fold: "rail", bands: { bottom: BOTTOM } }, floats: false, start: banded(docksStart) };
61
- var docksFull = { id: "docksFull", options: { fold: "rail", bands: { bottom: { ...BOTTOM, span: "full" } } }, floats: false, start: banded(docksStart) };
62
- var dockTear = {
63
- id: "dockTear",
64
- options: { fold: "rail", floats: "clamp", bands: { bottom: BOTTOM } },
65
- floats: true,
66
- // As docks, with the right side's last panel that may float torn off, next to the left column.
67
- start: banded((defs, hint) => {
68
- const { left, right } = split(defs, hint);
69
- const can = (id) => defs.find((d) => d.id === id)?.floats !== false;
70
- const torn = [...right].reverse().find(can) ?? [...left].reverse().find(can);
71
- const keep = (ids) => ids.filter((id) => id !== torn);
72
- const leftW = Math.max(0, ...keep(left).map((id) => defs.find((d) => d.id === id).width.natural));
73
- const size = floatSize(defs.find((d) => d.id === torn));
74
- return createPanels(defs, {
75
- left: columns(keep(left)),
76
- right: columns(keep(right)),
77
- ...torn ? { floats: [{ id: torn, x: leftW + 24, y: 24, width: size.natural.width, height: size.natural.height }] } : {}
78
- });
79
- })
80
- };
81
- var navigator = {
82
- id: "navigator",
83
- options: { fold: "rail" },
84
- floats: false,
85
- start(defs, hint) {
86
- const s = docksStart(defs, hint);
87
- return s.sides.left.length ? showTabs(s, "left", 0, true) : s;
88
- }
89
- };
90
- var PRESETS = { docks, docksFull, dockTear, navigator };
91
- function presetLayout(preset, defs, state, stage, options = {}) {
92
- return layoutPanels(defs, state, stage, { ...preset.options, ...options });
93
- }
94
- function presetInput(preset, input) {
95
- const allows = (id, place) => (place.kind !== "float" || preset.floats) && (input.allows?.(id, place) ?? true);
96
- return { ...input, options: { ...preset.options, ...input.options }, allows };
97
- }
98
- function presetTargets(preset, input) {
99
- return panelTargets(presetInput(preset, input));
100
- }
101
- function presetDrop(preset, input, target, point, grab) {
102
- return panelDrop(presetInput(preset, input), target, point, grab);
103
- }
104
- export {
105
- PRESETS,
106
- presetDrop,
107
- presetInput,
108
- presetLayout,
109
- presetTargets
110
- };
111
- //# sourceMappingURL=desk.js.map
package/dist/desk.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/desk/index.ts"],"sourcesContent":["/**\n * @n-uf/placement/desk: desk presets as data on `@n-uf/placement/panels`. A preset is options for the panels engine\n * and a start state; it carries no titles, no words and no toolbar wiring (the app names presets and wires its\n * toolbar). It imports only the panels entry's public index, so an app that imports only `./panels` loads none of it.\n *\n * - `docks`: one stack column per side and a bottom band between them (reserved: it shortens the pages); sections at\n * their natural heights when the defs give `height`; short of width a column folds to its side's rail, short of\n * height the band folds to a bar. No floats.\n * - `docksFull`: as docks, with the bottom band full width (the columns stand on it).\n * - `dockTear`: as docks, and panels may float (tear-off and dock-back); one panel floats in the start state.\n * - `navigator`: a tabbed column on the left, a stack column on the right. No band, no floats.\n *\n * The bottom band starts with the hint's `bottom` panels, else the last def whose `sides` names \"bottom\" (a def\n * without `sides` may be dropped there, but doesn't start there).\n *\n * A legacy entry. See docs/placement.md, Entry: desk.\n */\nimport {\n createPanels,\n floatSize,\n layoutPanels,\n panelDrop,\n panelTargets,\n showTabs,\n type PanelDef,\n type PanelDrop,\n type PanelPlace,\n type PanelTarget,\n type PanelTargetInput,\n type PanelsLayout,\n type PanelsOptions,\n type PanelsState,\n} from \"../panels\";\n\nexport type PresetId = \"docks\" | \"docksFull\" | \"dockTear\" | \"navigator\";\n\n/** Which panels start on which side (ids in order), and in the bottom band (a preset with one); the others are placed by the preset. */\nexport interface DeskHint {\n readonly left?: readonly string[];\n readonly right?: readonly string[];\n readonly bottom?: readonly string[];\n}\n\nexport interface DeskPreset {\n readonly id: PresetId;\n /** The panels options the preset lays out with (the caller's own options go over them). */\n readonly options: Partial<PanelsOptions>;\n /** Whether its panels may float: when not, `presetTargets` offers no float target. */\n readonly floats: boolean;\n /** Its start state for these panels. */\n start(defs: readonly PanelDef[], hint?: DeskHint): PanelsState;\n}\n\ntype Stage = Parameters<typeof layoutPanels>[2];\ntype Point = Parameters<typeof panelDrop>[2];\n\n/**\n * Split the panels between the sides: the hint's first, then the rest in order, each to a side it may dock on, the\n * left side taking the first half of them.\n */\nfunction split(defs: readonly PanelDef[], hint: DeskHint = {}): { left: string[]; right: string[] } {\n const known = new Set(defs.map((d) => d.id));\n const left = (hint.left ?? []).filter((id) => known.has(id));\n const right = (hint.right ?? []).filter((id) => known.has(id) && !left.includes(id));\n const rest = defs.filter((d) => !left.includes(d.id) && !right.includes(d.id));\n const half = Math.ceil(defs.length / 2);\n for (const d of rest) {\n const mayL = !d.sides || d.sides.includes(\"left\");\n const mayR = !d.sides || d.sides.includes(\"right\");\n if (mayL && (left.length < half || !mayR)) left.push(d.id);\n else if (mayR) right.push(d.id);\n else left.push(d.id);\n }\n return { left, right };\n}\n\nconst columns = (ids: readonly string[]): string[][] => (ids.length ? [[...ids]] : []);\n\n/** The bottom band's start: the hint's, else the last def whose `sides` names \"bottom\". */\nfunction bottomOf(defs: readonly PanelDef[], hint: DeskHint = {}): string[] {\n const known = new Set(defs.map((d) => d.id));\n if (hint.bottom) return hint.bottom.filter((id) => known.has(id));\n const last = [...defs].reverse().find((d) => d.sides?.includes(\"bottom\"));\n return last ? [last.id] : [];\n}\n\n/** The defs and hint with the band's panels taken out, so the sides split the rest. */\nconst sidesOnly = (defs: readonly PanelDef[], hint: DeskHint | undefined, band: readonly string[]): [PanelDef[], DeskHint | undefined] => [\n defs.filter((d) => !band.includes(d.id)),\n hint && { ...hint, left: hint.left?.filter((id) => !band.includes(id)), right: hint.right?.filter((id) => !band.includes(id)) },\n];\n\nconst banded = (start: (defs: readonly PanelDef[], hint?: DeskHint) => PanelsState) => (defs: readonly PanelDef[], hint?: DeskHint): PanelsState => {\n const bottom = bottomOf(defs, hint);\n const [rest, h] = sidesOnly(defs, hint, bottom);\n const s = start(rest, h);\n return bottom.length ? createPanels(defs, { ...startOf(s), bottom }) : s;\n};\n\n/** A plain start back from a state (columns, floats and lists; the clock is rebuilt in listing order). */\nfunction startOf(s: PanelsState): Parameters<typeof createPanels>[1] {\n return {\n left: s.sides.left.map((c) => c.panels),\n right: s.sides.right.map((c) => c.panels),\n floats: s.floats.map((f) => ({ id: f.id, x: f.rect.x, y: f.rect.y, width: f.rect.width, height: f.rect.height, ...(f.pinned ? { pinned: true } : {}) })),\n folded: s.folded,\n kept: s.kept,\n closed: s.closed,\n };\n}\n\nconst docksStart = (defs: readonly PanelDef[], hint?: DeskHint): PanelsState => {\n const { left, right } = split(defs, hint);\n return createPanels(defs, { left: columns(left), right: columns(right) });\n};\n\nconst BOTTOM = { mode: \"reserved\", span: \"between\" } as const;\n\nconst docks: DeskPreset = { id: \"docks\", options: { fold: \"rail\", bands: { bottom: BOTTOM } }, floats: false, start: banded(docksStart) };\n\nconst docksFull: DeskPreset = { id: \"docksFull\", options: { fold: \"rail\", bands: { bottom: { ...BOTTOM, span: \"full\" } } }, floats: false, start: banded(docksStart) };\n\nconst dockTear: DeskPreset = {\n id: \"dockTear\",\n options: { fold: \"rail\", floats: \"clamp\", bands: { bottom: BOTTOM } },\n floats: true,\n // As docks, with the right side's last panel that may float torn off, next to the left column.\n start: banded((defs, hint) => {\n const { left, right } = split(defs, hint);\n const can = (id: string): boolean => defs.find((d) => d.id === id)?.floats !== false;\n const torn = [...right].reverse().find(can) ?? [...left].reverse().find(can);\n const keep = (ids: readonly string[]): string[] => ids.filter((id) => id !== torn);\n const leftW = Math.max(0, ...keep(left).map((id) => defs.find((d) => d.id === id)!.width.natural));\n const size = floatSize(defs.find((d) => d.id === torn));\n return createPanels(defs, {\n left: columns(keep(left)),\n right: columns(keep(right)),\n ...(torn ? { floats: [{ id: torn, x: leftW + 24, y: 24, width: size.natural.width, height: size.natural.height }] } : {}),\n });\n }),\n};\n\nconst navigator: DeskPreset = {\n id: \"navigator\",\n options: { fold: \"rail\" },\n floats: false,\n start(defs, hint) {\n const s = docksStart(defs, hint);\n return s.sides.left.length ? showTabs(s, \"left\", 0, true) : s;\n },\n};\n\nexport const PRESETS: Readonly<Record<PresetId, DeskPreset>> = { docks, docksFull, dockTear, navigator };\n\n/** `layoutPanels` with the preset's options under the caller's. */\nexport function presetLayout(preset: DeskPreset, defs: readonly PanelDef[], state: PanelsState, stage: Stage, options: Partial<PanelsOptions> = {}): PanelsLayout {\n return layoutPanels(defs, state, stage, { ...preset.options, ...options });\n}\n\n/** The target input with the preset's options under the caller's, and only the places the preset allows. */\nexport function presetInput(preset: DeskPreset, input: PanelTargetInput): PanelTargetInput {\n const allows = (id: string, place: PanelPlace): boolean => (place.kind !== \"float\" || preset.floats) && (input.allows?.(id, place) ?? true);\n return { ...input, options: { ...preset.options, ...input.options }, allows };\n}\n\n/** `panelTargets` with the preset's options under the caller's, and only the places the preset allows. */\nexport function presetTargets(preset: DeskPreset, input: PanelTargetInput): PanelTarget[] {\n return panelTargets(presetInput(preset, input));\n}\n\n/** `panelDrop` laid out with the preset's options (so the slot is where the preset lays the panel). */\nexport function presetDrop(preset: DeskPreset, input: PanelTargetInput, target: PanelTarget, point: Point, grab: Point): PanelDrop {\n return panelDrop(presetInput(preset, input), target, point, grab);\n}\n"],"mappings":";;;;;;;;;;;;AA4DA,SAAS,MAAM,MAA2B,OAAiB,CAAC,GAAwC;AAClG,QAAM,QAAQ,IAAI,IAAI,KAAK,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;AAC3C,QAAM,QAAQ,KAAK,QAAQ,CAAC,GAAG,OAAO,CAAC,OAAO,MAAM,IAAI,EAAE,CAAC;AAC3D,QAAM,SAAS,KAAK,SAAS,CAAC,GAAG,OAAO,CAAC,OAAO,MAAM,IAAI,EAAE,KAAK,CAAC,KAAK,SAAS,EAAE,CAAC;AACnF,QAAM,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC,KAAK,SAAS,EAAE,EAAE,KAAK,CAAC,MAAM,SAAS,EAAE,EAAE,CAAC;AAC7E,QAAM,OAAO,KAAK,KAAK,KAAK,SAAS,CAAC;AACtC,aAAW,KAAK,MAAM;AACpB,UAAM,OAAO,CAAC,EAAE,SAAS,EAAE,MAAM,SAAS,MAAM;AAChD,UAAM,OAAO,CAAC,EAAE,SAAS,EAAE,MAAM,SAAS,OAAO;AACjD,QAAI,SAAS,KAAK,SAAS,QAAQ,CAAC,MAAO,MAAK,KAAK,EAAE,EAAE;AAAA,aAChD,KAAM,OAAM,KAAK,EAAE,EAAE;AAAA,QACzB,MAAK,KAAK,EAAE,EAAE;AAAA,EACrB;AACA,SAAO,EAAE,MAAM,MAAM;AACvB;AAEA,IAAM,UAAU,CAAC,QAAwC,IAAI,SAAS,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC;AAGpF,SAAS,SAAS,MAA2B,OAAiB,CAAC,G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S,cAAc,QAAoB,OAAwC;AACxF,SAAO,aAAa,YAAY,QAAQ,KAAK,CAAC;AAChD;AAGO,SAAS,WAAW,QAAoB,OAAyB,QAAqB,OAAc,MAAwB;AACjI,SAAO,UAAU,YAAY,QAAQ,KAAK,GAAG,QAAQ,OAAO,IAAI;AAClE;","names":[]}
package/dist/dock.d.ts DELETED
@@ -1,25 +0,0 @@
1
- import { C as Catalog, D as DeskState, N as Note } from './constructions-Cbz7uEAZ.js';
2
- export { a as Construction, b as ConstructionId, c as DEFAULT_OPTIONS, d as Desk, e as DeskSpec, f as DeskStart, F as Free, G, L as LAYER, g as Layout, h as Look, i as NoteCode, O as Options, P as PanelSpec, j as Placed, S as Side, k as createDesk, l as docKey, m as draggable, n as idOf, o as isDocKey, p as isPanelKey, q as liftOut, r as panelKey, t as toggleClosed, s as toggleFold, u as touch, w as withActive, v as withDocs } from './constructions-Cbz7uEAZ.js';
3
- import { S as Size } from './geometry-Bf37LbCT.js';
4
-
5
- /**
6
- * The parts the desk constructions are built from, each pure: the toolbar pill, the documents' tiles, natural-height
7
- * sections (the last open one takes the rest; the least recently used fold to headers), rails, the edge docks'
8
- * geometry, the tiling tree's columns, the scrolling strip, tabbed sides and floating palettes.
9
- */
10
-
11
- interface StripGeometry {
12
- readonly cols: string[][];
13
- /** Each column's left edge on the stage (scroll applied) and width. */
14
- readonly xs: number[];
15
- readonly widths: number[];
16
- readonly y: number;
17
- readonly h: number;
18
- /** The whole strip's width, and how far it is scrolled. */
19
- readonly total: number;
20
- readonly scroll: number;
21
- }
22
- /** The strip's columns and scroll: scrolled by hand, else to center the focused document's column. */
23
- declare function stripGeometry(cat: Catalog, s: DeskState, size: Size, notes?: Note[]): StripGeometry;
24
-
25
- export { Catalog, DeskState, Note, type StripGeometry, stripGeometry };