@sincpro/web-composer 0.1.0 → 1.1.0

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 (41) hide show
  1. package/README.md +139 -67
  2. package/dist/domain/enums.d.ts +0 -10
  3. package/dist/domain/enums.js +0 -8
  4. package/dist/domain/index.d.ts +4 -4
  5. package/dist/domain/index.js +4 -4
  6. package/dist/domain/layout.d.ts +37 -20
  7. package/dist/domain/layout.js +136 -100
  8. package/dist/domain/registry.d.ts +33 -7
  9. package/dist/domain/url.d.ts +13 -0
  10. package/dist/domain/url.js +43 -5
  11. package/dist/domain/workspace.d.ts +43 -7
  12. package/dist/domain/workspace.js +136 -15
  13. package/dist/index.d.ts +9 -5
  14. package/dist/index.js +8 -4
  15. package/dist/shell/Composer.d.ts +5 -6
  16. package/dist/shell/Composer.js +42 -13
  17. package/dist/shell/Palette.js +11 -10
  18. package/dist/shell/PanelFrame.d.ts +10 -3
  19. package/dist/shell/PanelFrame.js +57 -31
  20. package/dist/shell/PanelHost.js +44 -31
  21. package/dist/shell/Peek.d.ts +26 -0
  22. package/dist/shell/Peek.js +64 -0
  23. package/dist/shell/RecordLink.js +12 -8
  24. package/dist/shell/ViewHost.js +17 -6
  25. package/dist/shell/copy.d.ts +10 -1
  26. package/dist/shell/copy.js +29 -7
  27. package/dist/shell/icons.d.ts +22 -0
  28. package/dist/shell/icons.js +19 -0
  29. package/dist/shell/skin.d.ts +72 -0
  30. package/dist/shell/skin.js +35 -0
  31. package/dist/shell/styles.d.ts +19 -0
  32. package/dist/shell/styles.js +212 -0
  33. package/dist/state/api.d.ts +7 -3
  34. package/dist/state/api.js +109 -63
  35. package/dist/state/store.d.ts +27 -3
  36. package/dist/state/store.js +165 -41
  37. package/dist/state/useKeyboard.d.ts +4 -0
  38. package/dist/state/useKeyboard.js +11 -3
  39. package/dist/state/useWorkspace.d.ts +5 -1
  40. package/dist/state/useWorkspace.js +6 -0
  41. package/package.json +11 -10
package/README.md CHANGED
@@ -1,62 +1,79 @@
1
1
  # @sincpro/web-composer
2
2
 
3
- **How enterprise screens are put together.** A workspace for React where a person opens a
4
- record, checks another one beside it, peeks at a third, and keeps a fourth floating while they
5
- work — without losing their place, and without any screen knowing about the others. By
6
- [Sincpro](https://github.com/Sincpro-SRL), open source.
3
+ **A window manager for enterprise web apps.** A person opens a record, checks another beside
4
+ it, peeks at a third and keeps a fourth floating while they work — without losing their place,
5
+ and without any screen knowing about the others. A rich API for views, standalone: it depends
6
+ on nothing but React. By [Sincpro](https://github.com/Sincpro-SRL), open source.
7
7
 
8
8
  ```bash
9
- yarn add @sincpro/web-composer @sincpro/web-ui react react-dom
9
+ yarn add @sincpro/web-composer react react-dom
10
10
  ```
11
11
 
12
- Requires React 19 or newer and [`@sincpro/web-ui`](https://github.com/Sincpro-SRL/sincpro_web_ui).
13
-
14
- ## Why
15
-
16
- People who work in an ERP spend the day **between records**. An accountant reconciles a bank
17
- statement against invoices. An auditor walks journal items and checks the entry each one came
18
- from. Somebody filling an order needs to look at the customer, the stock and last month's
19
- invoice — now, not after closing the form.
20
-
21
- Most business software answers that with one of two bad options:
22
-
23
- - **Navigate away.** You open the invoice, and the list you were working on is gone. You come
24
- back and the filters, the scroll and the selection are gone too.
25
- - **Open another browser tab.** Now the context lives in your head: which tab had what, and
26
- which one is stale.
27
-
28
- Both make people do the remembering. The composer makes the workspace do it.
29
-
30
- ## The vision
31
-
32
- Sincpro builds enterprise interfaces with two packages, and each one owns a different question:
33
-
34
- | Package | The question it answers |
35
- | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ |
36
- | [`@sincpro/web-ui`](https://github.com/Sincpro-SRL/sincpro_web_ui) | **What a screen looks like** — tokens, primitives, `List` (N records), `Record` (one) |
37
- | `@sincpro/web-composer` | **How screens are put together** — where a record opens, how two of them sit side by side, how one follows another |
38
- | Your application | **What a record is** — invoices, payments, journal entries |
39
-
40
- Neither package knows your domain. Together they are how we build business software: web-ui
41
- draws the screens, the composer arranges them, and the application only declares its records.
42
-
43
- ### Principles
44
-
45
- - **A click does the predictable thing.** Opening a record replaces the page, and the
46
- breadcrumb keeps the way back. Everything else — a peek, a window, a side panel — is one
47
- gesture away, never forced on anyone. Someone who never opens a panel just sees pages and
48
- breadcrumbs.
49
- - **References, not data.** The workspace stores `domain:kind/id`. A support case can point at
50
- an invoice and the workspace opens it, while the support code never imports accounting.
51
- - **Each domain declares itself.** Register a `ViewSpec` and it works: in pages, panels, the
52
- peek and ⌘K. Adding a domain changes no file in this package — and the view can be a module
53
- another team deploys.
54
- - **Nothing a person arranges can break it.** A view that throws stays in its own panel. A
55
- reference nobody can resolve says so. A broken link loads what is valid. Sizes are clamped.
56
- - **Moving is not remounting.** Every surface is a sibling on one layer; only its box changes.
57
- A panel moved to another edge keeps its scroll, its filters and what was typed in it.
58
- - **Views stay apart.** A view can open things and publish what it selected, but it cannot read
59
- the workspace — two domains talk through references, never through each other.
12
+ ## Manifesto
13
+
14
+ ### Purpose
15
+
16
+ The composer defines **how work between records behaves**: where each thing opens, how you get
17
+ back, what is remembered, and what the others see. One behaviour, reviewed by Sincpro, for
18
+ every application.
19
+
20
+ UI libraries prefer «one screen, one context» because it is clean. But people who work in
21
+ accounting, audit or support spend the day **between** records: the bank statement against the
22
+ invoices, the journal item against its entry, the customer while the order is half filled.
23
+ Without a window manager, every app either navigates away (the list, its filters and its
24
+ selection are gone) or sends people to browser tabs (the context lives in their head) — and
25
+ each app reinvents peeks, breadcrumbs and panels its own way. The composer solves it once.
26
+
27
+ | Who | The question it answers |
28
+ | ---------------- | ------------------------------------------------------------------------ |
29
+ | **The composer** | Where each view lives and how it moves: page, peek, side panel, window |
30
+ | **Your app** | What a record is and how it looks — drawn with web-ui, or anything else |
31
+ | **A framework** | Puts both together (`@sincpro/web-framework` does, over server metadata) |
32
+
33
+ ### Principles — the contract
34
+
35
+ - **One gesture, one destination.** A click opens the page and the breadcrumb keeps the way
36
+ back; a peek, a window, a side panel are one gesture away, never forced on anyone. Someone
37
+ who never opens a panel just sees pages and breadcrumbs.
38
+ - **References, not data.** The workspace stores `domain:kind/id`. A support case points at an
39
+ invoice and the workspace opens it, while the support code never imports accounting. Views
40
+ can open things and publish what they selected, but cannot read the workspace.
41
+ - **Never lose the place, nor what was typed.** The breadcrumb, the URL, the browser's Back,
42
+ asking before discarding. Moving a panel does not remount it; neither does changing only a
43
+ reference's `params`. The peek belongs to its page: when the page becomes another record, it
44
+ closes.
45
+ - **Opinionated defaults, open doors.** Good practice comes built in, and everything is
46
+ replaceable without forks: the look (`--sc-*`, `skin`), the discard question
47
+ (`confirmDiscard`), where a click goes (`defaultOpen`), any reducer (`apply`).
48
+ - **Standalone.** Only React. The design belongs to whoever uses it; the composer ships a
49
+ minimal skin so it works alone, and nothing else.
50
+ - **Each domain declares itself.** Register a `ViewSpec` and it works in pages, panels, the
51
+ peek and ⌘K. Adding a domain changes no file here — the view can be a module another team
52
+ deploys.
53
+ - **Nothing a person arranges can break it.** A view that throws stays in its own panel; a
54
+ reference nobody resolves says so; a broken link loads what is valid; sizes are clamped.
55
+ - **Addressable by people and agents.** The place lives in the URL and in references, so the
56
+ same API (`context`, `open`, `peek`, `select`) serves a person and an AI agent. An MCP or
57
+ WebMCP adapter fits here — as a separate module, not in the core.
58
+ - **A rule comes with its story.** Every behaviour is a Storybook story with its `play`.
59
+
60
+ ### What it is not
61
+
62
+ - **Not a component library.** No form controls, tables or lists — that is your app (web-ui).
63
+ - **Not a data layer.** No fetching, permissions, entities or sessions.
64
+ - **Not a router** of URL paths, and not a free dashboard layout.
65
+ - **No tabs, no multiple workspaces.** One page, its trail, and what is around it.
66
+ - **No design system, no icon library** as a dependency.
67
+
68
+ ### How something new gets in
69
+
70
+ All three, or it belongs in another package:
71
+
72
+ 1. It answers **where does it open? how do I get back? what is remembered? what does the other
73
+ one see** (a panel following the selection, an agent)?
74
+ 2. It serves **any domain** the same way — if it only makes sense for accounting, it is the
75
+ app's.
76
+ 3. It comes from **real use** (forge, web-framework) and arrives with its story.
60
77
 
61
78
  ## The model
62
79
 
@@ -72,16 +89,26 @@ One **page**, with its **trail** (the breadcrumb), and around it:
72
89
  A view opens anything with one call and lets the workspace decide the rest:
73
90
 
74
91
  ```ts
75
- api.open(ref); // the page
92
+ api.open(ref); // the page — inside the peek, a step IN the drawer
76
93
  api.open(ref, { to: "peek" }); // or "window", or "side"
77
- api.crumbs(); // the breadcrumb, ready for List.Crumbs / Record.Crumbs
78
- api.back(); // one page back
94
+ api.replace(ref); // show it HERE without a step back: the record a form just created
95
+ api.setParams({ tenant }); // a filter that lives in the reference: survives reload and links
96
+ useCrumbs(api); // the breadcrumb, ready for List.Crumbs / Record.Crumbs — follows setTitle
97
+ api.back(); // one step back: the page's breadcrumb, or the peek's own trail
98
+ api.close(); // leave: closes the panel or the peek; on the page, goes back — «Cancel» anywhere
79
99
  api.expand(); // a window, a side panel or the peek grows into the page
100
+ api.setTitle(name); // the record's real name, for the crumbs and the frames, once loaded
101
+ api.setDirty(true); // unsaved: a crumb, a close or the browser's Back ask first
80
102
  api.select(refs); // publish what this view has selected
81
103
  api.context; // read what the user is on and what is selected — references only
82
104
  api.pick(ref, onPick); // open a chooser (a many2one search); its view calls api.answer(ref)
83
105
  ```
84
106
 
107
+ From the app, around the workspace: `workspace.start(ref)` starts over from a menu (no
108
+ breadcrumb behind, no peek, the panels stay), and `useWorkspace({ hash: true })` puts the
109
+ workspace in the URL with the browser's Back working. Unsaved changes are asked with the
110
+ composer's own dialog; `useWorkspace({ confirmDiscard })` replaces it.
111
+
85
112
  ## Where each behaviour lives
86
113
 
87
114
  The same gesture means the same thing on every screen:
@@ -89,6 +116,7 @@ The same gesture means the same thing on every screen:
89
116
  | Where | Gesture | Destination |
90
117
  | --------------------------------------------------- | ------------------------ | ------------------------------------------- |
91
118
  | A row of a list | click | **page**, with breadcrumb |
119
+ | A record's name INSIDE the peek | click | a step **in the peek**; ← comes back |
92
120
  | The record's name in a column (`RecordLink`) | hover icons, Space, ⇧, ⌘ | **peek**, **side**, **window** |
93
121
  | A many2one field | open · search | **window** · a window that **answers** |
94
122
  | A record's buttons that _lead_ (see its items) | click | **side** |
@@ -132,17 +160,19 @@ export function App() {
132
160
  }
133
161
  ```
134
162
 
135
- Write a view — it receives its reference and the API, nothing else:
163
+ Write a view — it receives its reference and the API, nothing else. It is drawn with whatever
164
+ your app uses; here, web-ui:
136
165
 
137
166
  ```tsx
138
- import { RecordLink, type ViewProps } from "@sincpro/web-composer";
167
+ import { RecordLink, useCrumbs, type ViewProps } from "@sincpro/web-composer";
139
168
  import { List } from "@sincpro/web-ui";
140
169
 
141
170
  export function Entries({ api }: ViewProps) {
171
+ const crumbs = useCrumbs(api);
142
172
  return (
143
173
  <List items={entries} keyOf={(e) => e.id} onOpen={(e) => api.open(entryRef(e.id))}>
144
174
  <List.Bar>
145
- <List.Crumbs crumbs={api.crumbs()} />
175
+ <List.Crumbs crumbs={crumbs} />
146
176
  </List.Bar>
147
177
  <List.Table
148
178
  columns={[
@@ -163,19 +193,61 @@ export function Entries({ api }: ViewProps) {
163
193
  }
164
194
  ```
165
195
 
166
- The Storybook in this repository is the long version: ten accounting use cases — journal
196
+ The Storybook in this repository is the long version: eleven accounting use cases — journal
167
197
  entries, journal items, bank reconciliation, a form with relations, an audit where the detail
168
- follows the selection, ⌘K, the keyboard, and what happens when something fails.
198
+ follows the selection, ⌘K, the keyboard, what happens when something fails, and your own
199
+ design over the composer.
200
+
201
+ ## Your design over it
202
+
203
+ ### Colors
204
+
205
+ Every color, radius and shadow is a CSS variable with a default (light and dark). Set them
206
+ anywhere above the workspace — no stylesheet to import:
207
+
208
+ ```css
209
+ :root {
210
+ --sc-surface: var(--my-surface);
211
+ --sc-accent: var(--my-brand);
212
+ /* --sc-ground --sc-line --sc-line-strong --sc-ink --sc-muted --sc-danger --sc-scrim
213
+ --sc-shadow --sc-radius --sc-radius-control --sc-text --sc-text-small */
214
+ }
215
+ ```
216
+
217
+ ### Three levels
218
+
219
+ The composer owns the behaviour; the look is yours. Take only what you need:
220
+
221
+ 1. **Colors** — the `--sc-*` variables above.
222
+ 2. **Pieces** — `skin` swaps icons and parts one at a time; what you do not pass stays default:
223
+
224
+ ```tsx
225
+ <Composer
226
+ workspace={workspace}
227
+ registry={registry}
228
+ skin={{
229
+ icons: { close: X, more: Ellipsis }, // any component taking className / strokeWidth
230
+ Peek: MyDrawer, // ({ title, onClose, actions, children })
231
+ Confirm: MyConfirm, // ({ open, title, detail, keep, discard, onAnswer })
232
+ Notice: MyNotice, // ({ heading, detail, bad })
233
+ }}
234
+ />
235
+ ```
236
+
237
+ 3. **Everything** — `skin={{ styles: false }}` drops the default sheet; style the stable `sc-*`
238
+ classes from scratch.
239
+
240
+ The story «11 · Tu diseño sobre el composer» plugs web-ui's `Peek` and lucide's icons this way —
241
+ the composer imports neither.
169
242
 
170
243
  ## Development
171
244
 
172
245
  ```bash
173
246
  nvm use # Node 26, from .nvmrc
174
247
  make init # pre-commit + yarn install
175
- make test
248
+ make test # vitest: the model's rules (Node) + every story with its play (Chrome)
176
249
  make build
177
- make dev # Storybook on :6007 — one story per use case
178
- make smoke # every story in headless Chrome, play functions included
250
+ make dev # Storybook on :6007 — one story per use case; «Run tests» in the sidebar
179
251
  ```
180
252
 
181
253
  Every operation — local or CI — goes through the `Makefile`; run `make` to list the targets.
@@ -183,9 +255,9 @@ Every operation — local or CI — goes through the `Makefile`; run `make` to l
183
255
  ```text
184
256
  src/domain/ the model: pure TypeScript, no browser state, tested in Node
185
257
  src/state/ the store and the API views receive
186
- src/shell/ the React shell, drawn with @sincpro/web-ui
187
- tests/ node --test over the TypeScript sources
188
- stories/ the use cases, over a fake accounting domain in stories/contabilidad/
258
+ src/shell/ the React shell, with its own minimal skin (sc-* classes, --sc-* variables)
259
+ tests/ the model's rules, vitest in Node
260
+ stories/ the use cases, over a fake accounting app drawn with web-ui (dev only)
189
261
  ```
190
262
 
191
263
  ## CI/CD
@@ -35,11 +35,6 @@ export declare const Surface: {
35
35
  readonly Peek: "peek";
36
36
  };
37
37
  export type Surface = (typeof Surface)[keyof typeof Surface];
38
- export declare const BoxUnit: {
39
- readonly Fraction: "fraction";
40
- readonly Pixel: "pixel";
41
- };
42
- export type BoxUnit = (typeof BoxUnit)[keyof typeof BoxUnit];
43
38
  export declare const HandleKind: {
44
39
  readonly Zone: "zone";
45
40
  readonly Panel: "panel";
@@ -50,11 +45,6 @@ export declare const Axis: {
50
45
  readonly Y: "y";
51
46
  };
52
47
  export type Axis = (typeof Axis)[keyof typeof Axis];
53
- export declare const Split: {
54
- readonly Vertical: "vertical";
55
- readonly Horizontal: "horizontal";
56
- };
57
- export type Split = (typeof Split)[keyof typeof Split];
58
48
  export declare const DragKind: {
59
49
  /** A docked panel dragged by its header, to be dropped on another edge. */
60
50
  readonly Panel: "panel";
@@ -31,10 +31,6 @@ export const Surface = {
31
31
  Panel: "panel",
32
32
  Peek: "peek",
33
33
  };
34
- export const BoxUnit = {
35
- Fraction: "fraction",
36
- Pixel: "pixel",
37
- };
38
34
  export const HandleKind = {
39
35
  Zone: "zone",
40
36
  Panel: "panel",
@@ -43,10 +39,6 @@ export const Axis = {
43
39
  X: "x",
44
40
  Y: "y",
45
41
  };
46
- export const Split = {
47
- Vertical: "vertical",
48
- Horizontal: "horizontal",
49
- };
50
42
  export const DragKind = {
51
43
  /** A docked panel dragged by its header, to be dropped on another edge. */
52
44
  Panel: "panel",
@@ -1,9 +1,9 @@
1
1
  /** The model: no React, no CSS. Tested in Node; survives any change of skin. */
2
2
  export type { Dock } from "./enums.js";
3
- export { Axis, BoxUnit, Destination, DOCKS, DragKind, HandleKind, Split, Surface, Zone, } from "./enums.js";
4
- export { type Box, type Handle, handles, KEYBOARD_STEP, layout, sizeAt, type Slot, stableOrder, ZONE_LIMITS, } from "./layout.js";
3
+ export { Axis, Destination, DOCKS, DragKind, HandleKind, Surface, Zone, } from "./enums.js";
4
+ export { type Box, type Handle, handles, KEYBOARD_STEP, layout, type Length, resolve, sizeAt, type Slot, stableOrder, STRIP, ZONE_LIMITS, } from "./layout.js";
5
5
  export { localEntries, matches, MIN_QUERY, type PaletteEntry, PaletteSection, searchEntries, } from "./palette.js";
6
6
  export { type Action, createRegistry, type Crumb, loadView, type OpenOptions, type PickOptions, type Registry, type SearchHit, type ViewProps, type ViewSpec, type WorkspaceApi, } from "./registry.js";
7
7
  export { formatRef, isRef, parseRef, type ResourceRef, rootRef, sameRef, withParams, } from "./resource.js";
8
- export { fromHash, toHash } from "./url.js";
9
- export { back, closePanel, closePeek, collapsePanel, cycleFocus, DEFAULT_ZONES, EMPTY, expandPanel, findPanel, floatPanel, focusedRef, focusPanel, goTo, MAX_ZONE, maximize, MIN_SHARE, MIN_ZONE, movePanel, navigatePanel, openPanel, type OpenPanelOptions, PAGE, type Panel, panelsIn, peek, peekToPage, peekToSide, type Placement, push, raisePanel, resizePanel, resizeZone, select, type Selected, selectionOf, type WindowBox, type Workspace, type Zones, } from "./workspace.js";
8
+ export { fromHash, restore, type SessionMemory, toHash, } from "./url.js";
9
+ export { back, closePanel, closePeek, collapsePanel, cycleFocus, DEFAULT_ZONES, drillPeek, EMPTY, expandPanel, findPanel, floatPanel, focusedRef, focusPanel, goTo, MAX_ZONE, maximize, MIN_SHARE, MIN_ZONE, movePanel, nameOf, nameRef, navigatePanel, openPanel, type OpenPanelOptions, PAGE, type Panel, panelsIn, PEEK, peek, peekBack, peekGoTo, peekToPage, peekToSide, type Placement, push, raisePanel, refOn, replace, replacePeek, resizePanel, resizeZone, select, type Selected, selectionOf, start, type WindowBox, type Workspace, type Zones, } from "./workspace.js";
@@ -1,8 +1,8 @@
1
1
  /** The model: no React, no CSS. Tested in Node; survives any change of skin. */
2
- export { Axis, BoxUnit, Destination, DOCKS, DragKind, HandleKind, Split, Surface, Zone, } from "./enums.js";
3
- export { handles, KEYBOARD_STEP, layout, sizeAt, stableOrder, ZONE_LIMITS, } from "./layout.js";
2
+ export { Axis, Destination, DOCKS, DragKind, HandleKind, Surface, Zone, } from "./enums.js";
3
+ export { handles, KEYBOARD_STEP, layout, resolve, sizeAt, stableOrder, STRIP, ZONE_LIMITS, } from "./layout.js";
4
4
  export { localEntries, matches, MIN_QUERY, PaletteSection, searchEntries, } from "./palette.js";
5
5
  export { createRegistry, loadView, } from "./registry.js";
6
6
  export { formatRef, isRef, parseRef, rootRef, sameRef, withParams, } from "./resource.js";
7
- export { fromHash, toHash } from "./url.js";
8
- export { back, closePanel, closePeek, collapsePanel, cycleFocus, DEFAULT_ZONES, EMPTY, expandPanel, findPanel, floatPanel, focusedRef, focusPanel, goTo, MAX_ZONE, maximize, MIN_SHARE, MIN_ZONE, movePanel, navigatePanel, openPanel, PAGE, panelsIn, peek, peekToPage, peekToSide, push, raisePanel, resizePanel, resizeZone, select, selectionOf, } from "./workspace.js";
7
+ export { fromHash, restore, toHash, } from "./url.js";
8
+ export { back, closePanel, closePeek, collapsePanel, cycleFocus, DEFAULT_ZONES, drillPeek, EMPTY, expandPanel, findPanel, floatPanel, focusedRef, focusPanel, goTo, MAX_ZONE, maximize, MIN_SHARE, MIN_ZONE, movePanel, nameOf, nameRef, navigatePanel, openPanel, PAGE, panelsIn, PEEK, peek, peekBack, peekGoTo, peekToPage, peekToSide, push, raisePanel, refOn, replace, replacePeek, resizePanel, resizeZone, select, selectionOf, start, } from "./workspace.js";
@@ -1,4 +1,4 @@
1
- import { Axis, BoxUnit, type Dock, HandleKind } from "./enums.js";
1
+ import { Axis, type Dock, HandleKind } from "./enums.js";
2
2
  import type { ResourceRef } from "./resource.js";
3
3
  import { type Panel, type Workspace } from "./workspace.js";
4
4
  /**
@@ -13,12 +13,20 @@ import { type Panel, type Workspace } from "./workspace.js";
13
13
  * │ │ bottom │ │
14
14
  * └──────────┴───────────────────┴──────────┘
15
15
  */
16
+ /**
17
+ * A fraction of the container plus pixels — `calc(fr·100% + px)`. A minimized panel is a fixed
18
+ * strip while its neighbours are still a share, and neither unit alone can say «the zone minus
19
+ * two headers».
20
+ */
21
+ export type Length = {
22
+ fr: number;
23
+ px: number;
24
+ };
16
25
  export type Box = {
17
- unit: BoxUnit;
18
- left: number;
19
- top: number;
20
- width: number;
21
- height: number;
26
+ left: Length;
27
+ top: Length;
28
+ width: Length;
29
+ height: Length;
22
30
  };
23
31
  export type Slot = {
24
32
  /** `PAGE` for the page; the panel id for everything else. */
@@ -33,7 +41,14 @@ export type Slot = {
33
41
  * unmount them. */
34
42
  visible: boolean;
35
43
  collapsed: boolean;
44
+ /** Minimized into a strip that is NARROW, not short: a left or right zone with every panel
45
+ * minimized, or one minimized among open ones at the bottom. Its title reads vertically. */
46
+ rail: boolean;
36
47
  };
48
+ /** A length measured on a container `size` pixels long. */
49
+ export declare const resolve: (l: Length, size: number) => number;
50
+ /** What a minimized panel keeps: its title bar. It matches the frame's header. */
51
+ export declare const STRIP = 36;
37
52
  export declare function layout(w: Workspace): readonly Slot[];
38
53
  /** Sorted by id so sibling order does not change when a panel changes zone — reordering
39
54
  * siblings is what unmounts. */
@@ -44,27 +59,28 @@ export declare function stableOrder(slots: readonly Slot[]): readonly Slot[];
44
59
  * `zone` the edge between a zone and the page. Mutates `Workspace.zones`.
45
60
  * `panel` the edge between two panels in the SAME zone. What one gains, the neighbour loses.
46
61
  *
62
+ * A zone shrunk to its strip has no handle, and neither does the edge of a minimized panel:
63
+ * there is nothing to resize until it is restored.
64
+ *
47
65
  * Nested split containers (`react-resizable-panels`) are out: they unmount a panel when it
48
66
  * changes zone.
49
67
  */
50
- export type Handle = {
51
- kind: typeof HandleKind.Zone;
52
- zone: Dock;
68
+ type Measure = {
53
69
  axis: Axis;
54
- at: number;
55
- origin: number;
56
- span: number;
70
+ at: Length;
71
+ origin: Length;
72
+ span: Length;
57
73
  invert: boolean;
58
- } | {
74
+ };
75
+ export type Handle = ({
76
+ kind: typeof HandleKind.Zone;
77
+ zone: Dock;
78
+ } & Measure) | ({
59
79
  kind: typeof HandleKind.Panel;
60
80
  panelId: string;
61
- axis: Axis;
62
- at: number;
63
- origin: number;
64
- span: number;
65
- invert: boolean;
66
- };
67
- export declare function sizeAt(handle: Handle, p: number): number;
81
+ } & Measure);
82
+ /** The stored size a pointer `p` pixels into a container `size` pixels long asks for. */
83
+ export declare function sizeAt(handle: Handle, p: number, size: number): number;
68
84
  export declare function handles(w: Workspace): readonly Handle[];
69
85
  /** How far an arrow key moves a handle. A mouse-only handle leaves the workspace
70
86
  * half-assembled for anyone who does not use a pointer. */
@@ -73,3 +89,4 @@ export declare const ZONE_LIMITS: {
73
89
  min: number;
74
90
  max: number;
75
91
  };
92
+ export {};