@sincpro/web-composer 0.1.0 → 1.0.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.
- package/README.md +135 -64
- package/dist/domain/enums.d.ts +0 -10
- package/dist/domain/enums.js +0 -8
- package/dist/domain/index.d.ts +4 -4
- package/dist/domain/index.js +4 -4
- package/dist/domain/layout.d.ts +37 -20
- package/dist/domain/layout.js +136 -100
- package/dist/domain/registry.d.ts +30 -7
- package/dist/domain/url.d.ts +13 -0
- package/dist/domain/url.js +43 -5
- package/dist/domain/workspace.d.ts +43 -7
- package/dist/domain/workspace.js +136 -15
- package/dist/index.d.ts +8 -4
- package/dist/index.js +7 -3
- package/dist/shell/Composer.d.ts +5 -6
- package/dist/shell/Composer.js +42 -13
- package/dist/shell/Palette.js +11 -10
- package/dist/shell/PanelFrame.d.ts +10 -3
- package/dist/shell/PanelFrame.js +57 -31
- package/dist/shell/PanelHost.js +44 -31
- package/dist/shell/Peek.d.ts +26 -0
- package/dist/shell/Peek.js +64 -0
- package/dist/shell/RecordLink.js +12 -8
- package/dist/shell/ViewHost.js +17 -6
- package/dist/shell/copy.d.ts +10 -1
- package/dist/shell/copy.js +29 -7
- package/dist/shell/icons.d.ts +22 -0
- package/dist/shell/icons.js +19 -0
- package/dist/shell/skin.d.ts +72 -0
- package/dist/shell/skin.js +35 -0
- package/dist/shell/styles.d.ts +19 -0
- package/dist/shell/styles.js +212 -0
- package/dist/state/api.d.ts +7 -3
- package/dist/state/api.js +93 -63
- package/dist/state/store.d.ts +27 -3
- package/dist/state/store.js +165 -41
- package/dist/state/useKeyboard.d.ts +4 -0
- package/dist/state/useKeyboard.js +11 -3
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -1,62 +1,79 @@
|
|
|
1
1
|
# @sincpro/web-composer
|
|
2
2
|
|
|
3
|
-
**
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
9
|
+
yarn add @sincpro/web-composer react react-dom
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
- **
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
- **
|
|
59
|
-
|
|
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"
|
|
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
|
|
77
96
|
api.crumbs(); // the breadcrumb, ready for List.Crumbs / Record.Crumbs
|
|
78
|
-
api.back(); // one page
|
|
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,7 +160,8 @@ 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
167
|
import { RecordLink, type ViewProps } from "@sincpro/web-composer";
|
|
@@ -163,19 +192,61 @@ export function Entries({ api }: ViewProps) {
|
|
|
163
192
|
}
|
|
164
193
|
```
|
|
165
194
|
|
|
166
|
-
The Storybook in this repository is the long version:
|
|
195
|
+
The Storybook in this repository is the long version: eleven accounting use cases — journal
|
|
167
196
|
entries, journal items, bank reconciliation, a form with relations, an audit where the detail
|
|
168
|
-
follows the selection, ⌘K, the keyboard,
|
|
197
|
+
follows the selection, ⌘K, the keyboard, what happens when something fails, and your own
|
|
198
|
+
design over the composer.
|
|
199
|
+
|
|
200
|
+
## Your design over it
|
|
201
|
+
|
|
202
|
+
### Colors
|
|
203
|
+
|
|
204
|
+
Every color, radius and shadow is a CSS variable with a default (light and dark). Set them
|
|
205
|
+
anywhere above the workspace — no stylesheet to import:
|
|
206
|
+
|
|
207
|
+
```css
|
|
208
|
+
:root {
|
|
209
|
+
--sc-surface: var(--my-surface);
|
|
210
|
+
--sc-accent: var(--my-brand);
|
|
211
|
+
/* --sc-ground --sc-line --sc-line-strong --sc-ink --sc-muted --sc-danger --sc-scrim
|
|
212
|
+
--sc-shadow --sc-radius --sc-radius-control --sc-text --sc-text-small */
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Three levels
|
|
217
|
+
|
|
218
|
+
The composer owns the behaviour; the look is yours. Take only what you need:
|
|
219
|
+
|
|
220
|
+
1. **Colors** — the `--sc-*` variables above.
|
|
221
|
+
2. **Pieces** — `skin` swaps icons and parts one at a time; what you do not pass stays default:
|
|
222
|
+
|
|
223
|
+
```tsx
|
|
224
|
+
<Composer
|
|
225
|
+
workspace={workspace}
|
|
226
|
+
registry={registry}
|
|
227
|
+
skin={{
|
|
228
|
+
icons: { close: X, more: Ellipsis }, // any component taking className / strokeWidth
|
|
229
|
+
Peek: MyDrawer, // ({ title, onClose, actions, children })
|
|
230
|
+
Confirm: MyConfirm, // ({ open, title, detail, keep, discard, onAnswer })
|
|
231
|
+
Notice: MyNotice, // ({ heading, detail, bad })
|
|
232
|
+
}}
|
|
233
|
+
/>
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
3. **Everything** — `skin={{ styles: false }}` drops the default sheet; style the stable `sc-*`
|
|
237
|
+
classes from scratch.
|
|
238
|
+
|
|
239
|
+
The story «11 · Tu diseño sobre el composer» plugs web-ui's `Peek` and lucide's icons this way —
|
|
240
|
+
the composer imports neither.
|
|
169
241
|
|
|
170
242
|
## Development
|
|
171
243
|
|
|
172
244
|
```bash
|
|
173
245
|
nvm use # Node 26, from .nvmrc
|
|
174
246
|
make init # pre-commit + yarn install
|
|
175
|
-
make test
|
|
247
|
+
make test # vitest: the model's rules (Node) + every story with its play (Chrome)
|
|
176
248
|
make build
|
|
177
|
-
make dev # Storybook on :6007 — one story per use case
|
|
178
|
-
make smoke # every story in headless Chrome, play functions included
|
|
249
|
+
make dev # Storybook on :6007 — one story per use case; «Run tests» in the sidebar
|
|
179
250
|
```
|
|
180
251
|
|
|
181
252
|
Every operation — local or CI — goes through the `Makefile`; run `make` to list the targets.
|
|
@@ -183,9 +254,9 @@ Every operation — local or CI — goes through the `Makefile`; run `make` to l
|
|
|
183
254
|
```text
|
|
184
255
|
src/domain/ the model: pure TypeScript, no browser state, tested in Node
|
|
185
256
|
src/state/ the store and the API views receive
|
|
186
|
-
src/shell/ the React shell,
|
|
187
|
-
tests/
|
|
188
|
-
stories/ the use cases, over a fake accounting
|
|
257
|
+
src/shell/ the React shell, with its own minimal skin (sc-* classes, --sc-* variables)
|
|
258
|
+
tests/ the model's rules, vitest in Node
|
|
259
|
+
stories/ the use cases, over a fake accounting app drawn with web-ui (dev only)
|
|
189
260
|
```
|
|
190
261
|
|
|
191
262
|
## CI/CD
|
package/dist/domain/enums.d.ts
CHANGED
|
@@ -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";
|
package/dist/domain/enums.js
CHANGED
|
@@ -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",
|
package/dist/domain/index.d.ts
CHANGED
|
@@ -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,
|
|
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";
|
package/dist/domain/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/** The model: no React, no CSS. Tested in Node; survives any change of skin. */
|
|
2
|
-
export { Axis,
|
|
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";
|
package/dist/domain/layout.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Axis,
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
51
|
-
kind: typeof HandleKind.Zone;
|
|
52
|
-
zone: Dock;
|
|
68
|
+
type Measure = {
|
|
53
69
|
axis: Axis;
|
|
54
|
-
at:
|
|
55
|
-
origin:
|
|
56
|
-
span:
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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 {};
|