@mcurcio/patchbay 0.8.0 → 0.10.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 +11 -2
- package/dist/composites.css +1 -1
- package/dist/composites.js +399 -254
- package/dist/composites.js.map +1 -1
- package/dist/graph.css +1 -1
- package/dist/graph.js +593 -286
- package/dist/graph.js.map +1 -1
- package/dist/hooks.js.map +1 -1
- package/dist/primitives.css +1 -1
- package/dist/primitives.js +143 -126
- package/dist/primitives.js.map +1 -1
- package/dist/shell.css +1 -1
- package/dist/shell.js +96 -71
- package/dist/shell.js.map +1 -1
- package/dist/types/composites/banner/Banner.d.ts +2 -2
- package/dist/types/composites/change-list/ChangeList.d.ts +44 -0
- package/dist/types/composites/change-list/index.d.ts +2 -0
- package/dist/types/composites/diagnostic-list/DiagnosticList.d.ts +23 -0
- package/dist/types/composites/diagnostic-list/index.d.ts +2 -0
- package/dist/types/composites/index.d.ts +2 -0
- package/dist/types/composites/status-words/StatusWords.d.ts +1 -1
- package/dist/types/graph/add-at/useAddAt.d.ts +11 -5
- package/dist/types/graph/canvas-tools/CanvasTools.d.ts +7 -2
- package/dist/types/graph/connect-hints/connectTargets.d.ts +22 -0
- package/dist/types/graph/connect-hints/index.d.ts +3 -1
- package/dist/types/graph/connect-hints/useConnectHints.d.ts +9 -0
- package/dist/types/graph/connect-status/ConnectStatus.d.ts +30 -0
- package/dist/types/graph/connect-status/index.d.ts +2 -0
- package/dist/types/graph/context-at/index.d.ts +2 -0
- package/dist/types/graph/context-at/useContextAt.d.ts +43 -0
- package/dist/types/graph/empty-canvas-hint/EmptyCanvasHint.d.ts +33 -0
- package/dist/types/graph/empty-canvas-hint/index.d.ts +2 -0
- package/dist/types/graph/follow-fit/useFollowFit.d.ts +1 -0
- package/dist/types/graph/ghost-node/GhostNode.d.ts +32 -0
- package/dist/types/graph/ghost-node/index.d.ts +2 -0
- package/dist/types/graph/ghost-wire/GhostWire.d.ts +1 -1
- package/dist/types/graph/index.d.ts +4 -0
- package/dist/types/graph/meter/Meter.d.ts +8 -1
- package/dist/types/graph/meter/index.d.ts +1 -1
- package/dist/types/graph/wire/Wire.d.ts +4 -4
- package/dist/types/hooks/use-toasts/toastQueue.d.ts +1 -1
- package/dist/types/primitives/glyph/Glyph.d.ts +14 -0
- package/dist/types/primitives/glyph/index.d.ts +2 -0
- package/dist/types/primitives/icon-button/index.d.ts +1 -0
- package/dist/types/primitives/index.d.ts +1 -0
- package/dist/types/primitives/key-value/KeyValue.d.ts +3 -3
- package/dist/types/primitives/sheet/Sheet.d.ts +9 -3
- package/dist/types/primitives/spinner/Spinner.d.ts +1 -1
- package/dist/types/shell/app-shell/AppShell.d.ts +9 -1
- package/package.json +1 -1
- /package/dist/types/primitives/{dialog → icon-button}/CloseGlyph.d.ts +0 -0
package/dist/shell.js
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
import "./shell.css";import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
|
-
import { useId as n,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { useId as n, useLayoutEffect as r, useRef as i, useState as a, useSyncExternalStore as o } from "react";
|
|
3
|
+
import { createPortal as s } from "react-dom";
|
|
4
|
+
import { Glyph as c, IconButton as l, Panel as u, Sheet as d, Splitter as f } from "./primitives.js";
|
|
5
|
+
import { useMediaBreakpoint as p } from "./hooks.js";
|
|
5
6
|
// src/shell/app-shell/bounds.ts
|
|
6
|
-
var
|
|
7
|
+
var m = {
|
|
7
8
|
min: 280,
|
|
8
9
|
max: 560
|
|
9
|
-
},
|
|
10
|
+
}, h = {
|
|
10
11
|
min: 120,
|
|
11
12
|
maxShare: .7
|
|
12
13
|
};
|
|
13
|
-
function
|
|
14
|
+
function g(e, t, n) {
|
|
14
15
|
return Number.isFinite(e) ? Math.min(n, Math.max(t, Math.round(e))) : t;
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
-
return
|
|
17
|
+
function _(e) {
|
|
18
|
+
return g(e, m.min, m.max);
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
-
let t = Number.isFinite(e) ? Math.floor(e *
|
|
21
|
-
return Math.max(
|
|
20
|
+
function v(e) {
|
|
21
|
+
let t = Number.isFinite(e) ? Math.floor(e * h.maxShare) : 0;
|
|
22
|
+
return Math.max(h.min, t);
|
|
22
23
|
}
|
|
23
|
-
function
|
|
24
|
-
return
|
|
24
|
+
function y(e, t) {
|
|
25
|
+
return g(e, h.min, v(t));
|
|
25
26
|
}
|
|
26
27
|
// src/shell/app-shell/AppShell.tsx
|
|
27
|
-
var
|
|
28
|
+
var b = {
|
|
28
29
|
inspector: "Inspector",
|
|
29
30
|
drawer: "Drawer",
|
|
30
31
|
resizeInspector: "Resize the inspector",
|
|
@@ -33,29 +34,35 @@ var m = {
|
|
|
33
34
|
hideDrawer: "Hide the drawer",
|
|
34
35
|
close: "Close"
|
|
35
36
|
};
|
|
36
|
-
function
|
|
37
|
+
function x(e) {
|
|
37
38
|
return window.addEventListener("resize", e), () => {
|
|
38
39
|
window.removeEventListener("resize", e);
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
|
-
function
|
|
42
|
-
return
|
|
42
|
+
function S() {
|
|
43
|
+
return o(x, () => window.innerHeight, () => 0);
|
|
43
44
|
}
|
|
44
|
-
function
|
|
45
|
-
return /* @__PURE__ */ e("
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
})
|
|
45
|
+
function C({ open: t }) {
|
|
46
|
+
return /* @__PURE__ */ e(c, { children: /* @__PURE__ */ e("path", { d: t ? "M4 6l4 4 4-4" : "M4 10l4-4 4 4" }) });
|
|
47
|
+
}
|
|
48
|
+
var w = /* @__PURE__ */ new WeakMap();
|
|
49
|
+
function T({ holder: t }) {
|
|
50
|
+
let n = i(null);
|
|
51
|
+
return r(() => {
|
|
52
|
+
let e = n.current;
|
|
53
|
+
if (e === null) return;
|
|
54
|
+
e.appendChild(t);
|
|
55
|
+
let r = w.get(t);
|
|
56
|
+
return w.delete(t), r !== void 0 && t.contains(r) && document.activeElement !== r && r.focus({ preventScroll: !0 }), () => {
|
|
57
|
+
let n = document.activeElement;
|
|
58
|
+
n instanceof HTMLElement && t.contains(n) && w.set(t, n), t.parentNode === e && e.removeChild(t);
|
|
59
|
+
};
|
|
60
|
+
}, [t]), /* @__PURE__ */ e("div", {
|
|
61
|
+
ref: n,
|
|
62
|
+
className: "pb-shell-inspector-slot"
|
|
56
63
|
});
|
|
57
64
|
}
|
|
58
|
-
function
|
|
65
|
+
function E({ brand: n, status: r, start: i, end: a }) {
|
|
59
66
|
return /* @__PURE__ */ t("header", {
|
|
60
67
|
className: "pb-shell-bar",
|
|
61
68
|
children: [
|
|
@@ -78,100 +85,118 @@ function v({ brand: n, status: r, start: i, end: a }) {
|
|
|
78
85
|
]
|
|
79
86
|
});
|
|
80
87
|
}
|
|
81
|
-
function
|
|
82
|
-
let
|
|
88
|
+
function D({ drawer: r, words: i }) {
|
|
89
|
+
let a = n(), o = S(), s = y(r.height, o);
|
|
83
90
|
return /* @__PURE__ */ t("section", {
|
|
84
91
|
className: "pb-shell-drawer",
|
|
85
|
-
"aria-label":
|
|
92
|
+
"aria-label": i.drawer,
|
|
86
93
|
"data-open": r.open ? "" : void 0,
|
|
87
|
-
style: r.open ? { height: `${
|
|
94
|
+
style: r.open ? { height: `${s}px` } : void 0,
|
|
88
95
|
children: [
|
|
89
|
-
r.open && /* @__PURE__ */ e(
|
|
96
|
+
r.open && /* @__PURE__ */ e(f, {
|
|
90
97
|
orientation: "horizontal",
|
|
91
98
|
edge: "start",
|
|
92
|
-
value:
|
|
93
|
-
min:
|
|
94
|
-
max:
|
|
99
|
+
value: s,
|
|
100
|
+
min: h.min,
|
|
101
|
+
max: v(o),
|
|
95
102
|
onChange: r.onHeight,
|
|
96
|
-
label:
|
|
103
|
+
label: i.resizeDrawer
|
|
97
104
|
}),
|
|
98
105
|
/* @__PURE__ */ t("div", {
|
|
99
106
|
className: "pb-shell-drawer-head",
|
|
100
107
|
children: [/* @__PURE__ */ e("div", {
|
|
101
108
|
className: "pb-shell-drawer-header",
|
|
102
109
|
children: r.header
|
|
103
|
-
}), /* @__PURE__ */ e(
|
|
110
|
+
}), /* @__PURE__ */ e(l, {
|
|
104
111
|
className: "pb-shell-drawer-toggle",
|
|
105
|
-
label: r.open ?
|
|
112
|
+
label: r.open ? i.hideDrawer : i.showDrawer,
|
|
106
113
|
"aria-expanded": r.open,
|
|
107
|
-
"aria-controls":
|
|
114
|
+
"aria-controls": a,
|
|
108
115
|
onClick: () => {
|
|
109
116
|
r.onOpen(!r.open);
|
|
110
117
|
},
|
|
111
|
-
children: /* @__PURE__ */ e(
|
|
118
|
+
children: /* @__PURE__ */ e(C, { open: r.open })
|
|
112
119
|
})]
|
|
113
120
|
}),
|
|
114
121
|
/* @__PURE__ */ e("div", {
|
|
115
122
|
className: "pb-shell-drawer-body",
|
|
116
|
-
id:
|
|
123
|
+
id: a,
|
|
117
124
|
hidden: !r.open,
|
|
118
125
|
children: r.content
|
|
119
126
|
})
|
|
120
127
|
]
|
|
121
128
|
});
|
|
122
129
|
}
|
|
123
|
-
function
|
|
124
|
-
let
|
|
125
|
-
...
|
|
126
|
-
...
|
|
127
|
-
}, { width:
|
|
130
|
+
function O({ topBar: n, inspector: r, drawer: i, children: o, labels: c, className: l }) {
|
|
131
|
+
let h = {
|
|
132
|
+
...b,
|
|
133
|
+
...c
|
|
134
|
+
}, { width: g } = p(), v = r === void 0 ? 0 : _(r.width), y = g === "wide", x = r !== void 0 && (r.title !== void 0 || r.actions !== void 0), [S] = a(() => {
|
|
135
|
+
if (typeof document > "u") return null;
|
|
136
|
+
let e = document.createElement("div");
|
|
137
|
+
return e.className = "pb-shell-inspector-content", e;
|
|
138
|
+
}), C = r?.open === !0, w = r === void 0 ? null : S === null ? r.content : /* @__PURE__ */ e(T, { holder: S }), O = (e) => {
|
|
139
|
+
y || r === void 0 || e.defaultPrevented || e.nativeEvent.isComposing || e.key !== "Escape" || (e.preventDefault(), e.stopPropagation(), r.onOpen(!1));
|
|
140
|
+
};
|
|
128
141
|
return /* @__PURE__ */ t("div", {
|
|
129
|
-
className:
|
|
130
|
-
"data-layout":
|
|
142
|
+
className: l === void 0 ? "pb-shell" : `pb-shell ${l}`,
|
|
143
|
+
"data-layout": g,
|
|
131
144
|
"data-bar": n === void 0 ? void 0 : "",
|
|
132
145
|
"data-drawer": i === void 0 ? void 0 : "",
|
|
133
146
|
children: [
|
|
134
|
-
n !== void 0 && /* @__PURE__ */ e(
|
|
147
|
+
n !== void 0 && /* @__PURE__ */ e(E, { ...n }),
|
|
135
148
|
/* @__PURE__ */ t("div", {
|
|
136
149
|
className: "pb-shell-main",
|
|
137
150
|
children: [/* @__PURE__ */ t("main", {
|
|
138
151
|
className: "pb-shell-workspace",
|
|
139
|
-
children: [
|
|
152
|
+
children: [o, r !== void 0 && !y && /* @__PURE__ */ e(d, {
|
|
140
153
|
open: r.open,
|
|
141
154
|
onClose: () => {
|
|
142
155
|
r.onOpen(!1);
|
|
143
156
|
},
|
|
144
|
-
side:
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
157
|
+
side: g === "phone" ? "bottom" : "end",
|
|
158
|
+
title: r.title,
|
|
159
|
+
label: h.inspector,
|
|
160
|
+
actions: r.actions,
|
|
161
|
+
width: v,
|
|
162
|
+
labels: { close: h.close },
|
|
163
|
+
children: w
|
|
149
164
|
})]
|
|
150
|
-
}), r !== void 0 &&
|
|
165
|
+
}), r !== void 0 && y && r.open && /* @__PURE__ */ t("aside", {
|
|
151
166
|
className: "pb-shell-inspector",
|
|
152
|
-
"aria-label":
|
|
153
|
-
style: { width: `${
|
|
154
|
-
children: [/* @__PURE__ */ e(
|
|
167
|
+
"aria-label": h.inspector,
|
|
168
|
+
style: { width: `${v}px` },
|
|
169
|
+
children: [/* @__PURE__ */ e(f, {
|
|
155
170
|
orientation: "vertical",
|
|
156
171
|
edge: "start",
|
|
157
|
-
value:
|
|
158
|
-
min:
|
|
159
|
-
max:
|
|
172
|
+
value: v,
|
|
173
|
+
min: m.min,
|
|
174
|
+
max: m.max,
|
|
160
175
|
onChange: r.onWidth,
|
|
161
|
-
label:
|
|
176
|
+
label: h.resizeInspector
|
|
162
177
|
}), /* @__PURE__ */ e("div", {
|
|
163
178
|
className: "pb-shell-inspector-body",
|
|
164
|
-
children:
|
|
179
|
+
children: x ? /* @__PURE__ */ e(u, {
|
|
180
|
+
className: "pb-shell-inspector-panel",
|
|
181
|
+
title: r.title,
|
|
182
|
+
actions: r.actions,
|
|
183
|
+
children: w
|
|
184
|
+
}) : w
|
|
165
185
|
})]
|
|
166
186
|
})]
|
|
167
187
|
}),
|
|
168
|
-
i !== void 0 && /* @__PURE__ */ e(
|
|
188
|
+
i !== void 0 && /* @__PURE__ */ e(D, {
|
|
169
189
|
drawer: i,
|
|
170
|
-
words:
|
|
171
|
-
})
|
|
190
|
+
words: h
|
|
191
|
+
}),
|
|
192
|
+
r !== void 0 && S !== null && C && s(/* @__PURE__ */ e("div", {
|
|
193
|
+
className: "pb-shell-inspector-events",
|
|
194
|
+
onKeyDown: O,
|
|
195
|
+
children: r.content
|
|
196
|
+
}), S)
|
|
172
197
|
]
|
|
173
198
|
});
|
|
174
199
|
}
|
|
175
|
-
export {
|
|
200
|
+
export { O as AppShell, y as clampDrawerHeight, _ as clampInspectorWidth, b as defaultAppShellLabels, h as drawerBounds, v as drawerMaxHeight, m as inspectorBounds };
|
|
176
201
|
|
|
177
202
|
//# sourceMappingURL=shell.js.map
|
package/dist/shell.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.js","names":["inspectorBounds","drawerBounds","clamp","px","max","min","clampInspectorWidth","drawerMaxHeight","share","windowHeight","clampDrawerHeight","defaultAppShellLabels","subscribeToResize","onChange","useWindowHeight","useSyncExternalStore","DrawerGlyph","open","TopBar","brand","status","start","end","Drawer","bodyId","useId","height","drawer","words","Splitter","IconButton","AppShell","labels","layout","useMediaBreakpoint","width","inspector","wide","className","topBar","children","Sheet"],"sources":["../src/shell/app-shell/bounds.ts","../src/shell/app-shell/AppShell.tsx"],"sourcesContent":["// The sizes the shell holds its panes to (docs/components.md#appshell): an inspector 280–560 px wide, and a drawer\n// from 120 px to 70 % of the window's height. Pure, so an app can check a kept size with the same rules before it\n// draws (as usePersistentState's check).\n\n/** The inspector's width in px. */\nexport const inspectorBounds = { min: 280, max: 560 } as const;\n\n/** The drawer's height: at least `min` px, at most `maxShare` of the window's height. */\nexport const drawerBounds = { min: 120, maxShare: 0.7 } as const;\n\n/** `px` as whole px within `min` and `max`; a value that is not a finite number is `min`. */\nfunction clamp(px: number, min: number, max: number): number {\n if (!Number.isFinite(px)) return min;\n return Math.min(max, Math.max(min, Math.round(px)));\n}\n\n/** The inspector's width as drawn for an asked `px`: whole px within 280–560. */\nexport function clampInspectorWidth(px: number): number {\n return clamp(px, inspectorBounds.min, inspectorBounds.max);\n}\n\n/** The tallest the drawer may be in a window `windowHeight` px high: 70 % of it, and never below the least. */\nexport function drawerMaxHeight(windowHeight: number): number {\n const share = Number.isFinite(windowHeight) ? Math.floor(windowHeight * drawerBounds.maxShare) : 0;\n return Math.max(drawerBounds.min, share);\n}\n\n/** The drawer's height as drawn for an asked `px` in a window `windowHeight` px high. */\nexport function clampDrawerHeight(px: number, windowHeight: number): number {\n return clamp(px, drawerBounds.min, drawerMaxHeight(windowHeight));\n}\n","// The layout of a graph-editing app (docs/components.md#appshell): a top bar of slots, the canvas, an inspector on the\n// right and a drawer along the bottom, filling the screen (100dvh) inside the safe-area insets. It keeps no data: the\n// inspector's width, the drawer's height and whether each is open are the app's props, drawn within the shell's bounds\n// (bounds.ts) and changed through callbacks. Below 760 px the inspector is a Sheet over the canvas's right edge, below\n// 600 px one rising from the bottom (useMediaBreakpoint's widths). The drawer's body stays mounted while it is closed,\n// so what it holds (a draft, a caret, a scroll position) is still there when it opens.\nimport { type ReactNode, useId, useSyncExternalStore } from \"react\";\nimport { useMediaBreakpoint } from \"../../hooks\";\nimport { IconButton, Sheet, Splitter } from \"../../primitives\";\nimport { clampDrawerHeight, clampInspectorWidth, drawerBounds, drawerMaxHeight, inspectorBounds } from \"./bounds\";\nimport \"./AppShell.css\";\n\n/**\n * The top bar's slots, drawn in reading order (left to right in left-to-right text): the brand, a status, the app's\n * controls, and controls at the far end.\n */\nexport type AppShellTopBar = {\n /** The app's mark or name, first. */\n brand?: ReactNode;\n /** A short state after the brand (a connection's Pill). */\n status?: ReactNode;\n /** The app's controls, taking the free width. */\n start?: ReactNode;\n /** Controls at the far end (a theme switch, a menu). */\n end?: ReactNode;\n};\n\nexport type AppShellInspector = {\n /** What the inspector shows: usually a Panel, which scrolls on its own. */\n content: ReactNode;\n /** Whether it is shown; the app holds it. */\n open: boolean;\n /** Asked for with false when the person closes the narrow window's sheet (its close button, or Escape inside it). */\n onOpen: (open: boolean) => void;\n /** Its width in px, drawn within 280–560 px (`inspectorBounds`); a narrow window's sheet takes it too. */\n width: number;\n /** A new width from its splitter, in whole px within the bounds. */\n onWidth: (px: number) => void;\n};\n\nexport type AppShellDrawer = {\n /** The drawer's header, beside its show and hide button; shown while it is closed too. */\n header: ReactNode;\n /** The drawer's body, mounted while it is closed. */\n content: ReactNode;\n /** Whether its body is shown; the app holds it. */\n open: boolean;\n /** Asked for by its show and hide button. */\n onOpen: (open: boolean) => void;\n /** Its height in px while open, header included, drawn within 120 px and 70 % of the window (`drawerBounds`). */\n height: number;\n /** A new height from its splitter, in whole px within the bounds. */\n onHeight: (px: number) => void;\n};\n\n/** The shell's own words, each replaceable. */\nexport interface AppShellLabels {\n /** The inspector's name, as a region and as a sheet: \"Inspector\". */\n inspector: string;\n /** The drawer's name as a region: \"Drawer\". */\n drawer: string;\n /** The inspector's splitter: \"Resize the inspector\". */\n resizeInspector: string;\n /** The drawer's splitter: \"Resize the drawer\". */\n resizeDrawer: string;\n /** The drawer's button while it is closed: \"Show the drawer\". */\n showDrawer: string;\n /** The drawer's button while it is open: \"Hide the drawer\". */\n hideDrawer: string;\n /** The inspector sheet's close button: \"Close\". */\n close: string;\n}\n\nexport const defaultAppShellLabels: AppShellLabels = {\n inspector: \"Inspector\",\n drawer: \"Drawer\",\n resizeInspector: \"Resize the inspector\",\n resizeDrawer: \"Resize the drawer\",\n showDrawer: \"Show the drawer\",\n hideDrawer: \"Hide the drawer\",\n close: \"Close\",\n};\n\nexport type AppShellProps = {\n /** The top bar's slots; without them there is no bar. */\n topBar?: AppShellTopBar;\n /** The inspector; without it there is none. */\n inspector?: AppShellInspector;\n /** The drawer; without it there is none. */\n drawer?: AppShellDrawer;\n /** The canvas, filling the workspace. */\n children: ReactNode;\n /** Words to replace; the rest keep their defaults. */\n labels?: Partial<AppShellLabels>;\n /** A class added to the shell. */\n className?: string;\n};\n\nfunction subscribeToResize(onChange: () => void): () => void {\n window.addEventListener(\"resize\", onChange);\n return () => {\n window.removeEventListener(\"resize\", onChange);\n };\n}\n\n/** The window's height in px, kept current as it resizes; 0 with no window (the drawer then holds to its least). */\nfunction useWindowHeight(): number {\n return useSyncExternalStore(\n subscribeToResize,\n () => window.innerHeight,\n () => 0,\n );\n}\n\n/** A chevron pointing up (show) or down (hide), in the current text colour. */\nfunction DrawerGlyph({ open }: { open: boolean }) {\n return (\n <svg viewBox=\"0 0 16 16\" width=\"12\" height=\"12\" aria-hidden=\"true\">\n <path d={open ? \"M3 6l5 5 5-5\" : \"M3 10l5-5 5 5\"} fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.75\" />\n </svg>\n );\n}\n\nfunction TopBar({ brand, status, start, end }: AppShellTopBar) {\n return (\n <header className=\"pb-shell-bar\">\n {brand !== undefined && <div className=\"pb-shell-brand\">{brand}</div>}\n {status !== undefined && <div className=\"pb-shell-status\">{status}</div>}\n <div className=\"pb-shell-start\">{start}</div>\n {end !== undefined && <div className=\"pb-shell-end\">{end}</div>}\n </header>\n );\n}\n\nfunction Drawer({ drawer, words }: { drawer: AppShellDrawer; words: AppShellLabels }) {\n const bodyId = useId();\n const windowHeight = useWindowHeight();\n const height = clampDrawerHeight(drawer.height, windowHeight);\n return (\n <section\n className=\"pb-shell-drawer\"\n aria-label={words.drawer}\n data-open={drawer.open ? \"\" : undefined}\n style={drawer.open ? { height: `${height}px` } : undefined}\n >\n {drawer.open && (\n <Splitter\n orientation=\"horizontal\"\n edge=\"start\"\n value={height}\n min={drawerBounds.min}\n max={drawerMaxHeight(windowHeight)}\n onChange={drawer.onHeight}\n label={words.resizeDrawer}\n />\n )}\n <div className=\"pb-shell-drawer-head\">\n <div className=\"pb-shell-drawer-header\">{drawer.header}</div>\n <IconButton\n className=\"pb-shell-drawer-toggle\"\n label={drawer.open ? words.hideDrawer : words.showDrawer}\n aria-expanded={drawer.open}\n aria-controls={bodyId}\n onClick={() => {\n drawer.onOpen(!drawer.open);\n }}\n >\n <DrawerGlyph open={drawer.open} />\n </IconButton>\n </div>\n <div className=\"pb-shell-drawer-body\" id={bodyId} hidden={!drawer.open}>\n {drawer.content}\n </div>\n </section>\n );\n}\n\n/** Lays out a graph editor: top bar, canvas, inspector and drawer, with a sheet for the inspector on narrow windows. */\nexport function AppShell({ topBar, inspector, drawer, children, labels, className }: AppShellProps) {\n const words = { ...defaultAppShellLabels, ...labels };\n const { width: layout } = useMediaBreakpoint();\n const width = inspector === undefined ? 0 : clampInspectorWidth(inspector.width);\n const wide = layout === \"wide\";\n return (\n <div\n className={className === undefined ? \"pb-shell\" : `pb-shell ${className}`}\n data-layout={layout}\n data-bar={topBar === undefined ? undefined : \"\"}\n data-drawer={drawer === undefined ? undefined : \"\"}\n >\n {topBar !== undefined && <TopBar {...topBar} />}\n <div className=\"pb-shell-main\">\n <main className=\"pb-shell-workspace\">\n {children}\n {inspector !== undefined && !wide && (\n <Sheet\n open={inspector.open}\n onClose={() => {\n inspector.onOpen(false);\n }}\n side={layout === \"phone\" ? \"bottom\" : \"right\"}\n label={words.inspector}\n width={width}\n labels={{ close: words.close }}\n >\n {inspector.content}\n </Sheet>\n )}\n </main>\n {inspector !== undefined && wide && inspector.open && (\n <aside className=\"pb-shell-inspector\" aria-label={words.inspector} style={{ width: `${width}px` }}>\n <Splitter\n orientation=\"vertical\"\n edge=\"start\"\n value={width}\n min={inspectorBounds.min}\n max={inspectorBounds.max}\n onChange={inspector.onWidth}\n label={words.resizeInspector}\n />\n <div className=\"pb-shell-inspector-body\">{inspector.content}</div>\n </aside>\n )}\n </div>\n {drawer !== undefined && <Drawer drawer={drawer} words={words} />}\n </div>\n );\n}\n"],"mappings":";;;;;AAKA,IAAaA,IAAkB;CAAE,KAAK;CAAK,KAAK;AAAI,GAGvCC,IAAe;CAAE,KAAK;CAAK,UAAU;AAAI;AAGtD,SAASC,EAAM,GAAY,GAAa,GAAqB;CAE3D,OADK,OAAO,SAASC,CAAE,IAChB,KAAK,IAAIC,GAAK,KAAK,IAAIC,GAAK,KAAK,MAAMF,CAAE,CAAC,CAAC,IADjBE;AAEnC;AAGA,SAAgBC,EAAoB,GAAoB;CACtD,OAAOJ,EAAMC,GAAIH,EAAgB,KAAKA,EAAgB,GAAG;AAC3D;AAGA,SAAgBO,EAAgB,GAA8B;CAC5D,IAAMC,IAAQ,OAAO,SAASC,CAAY,IAAI,KAAK,MAAMA,IAAeR,EAAa,QAAQ,IAAI;CACjG,OAAO,KAAK,IAAIA,EAAa,KAAKO,CAAK;AACzC;AAGA,SAAgBE,EAAkB,GAAY,GAA8B;CAC1E,OAAOR,EAAMC,GAAIF,EAAa,KAAKM,EAAgBE,CAAY,CAAC;AAClE;;AC2CA,IAAaE,IAAwC;CACnD,WAAW;CACX,QAAQ;CACR,iBAAiB;CACjB,cAAc;CACd,YAAY;CACZ,YAAY;CACZ,OAAO;AACT;AAiBA,SAASC,EAAkB,GAAkC;CAE3D,OADA,OAAO,iBAAiB,UAAUC,CAAQ,SAC7B;EACX,OAAO,oB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,EAAU;KACN,CAAA,CAEL;IACL,CAAA,GAAAA,MAAc,KAAA,KAAaC,KAAQD,EAAU,QAC5C,kBAAC,SAAD;KAAO,WAAU;KAAqB,cAAYR,EAAM;KAAW,OAAO,EAAE,OAAO,GAAGO,EAAM,IAAI;KAAhG,UAAA,CACE,kBAACN,GAAD;MACE,aAAY;MACZ,MAAK;MACL,OAAOM;MACP,KAAKnC,EAAgB;MACrB,KAAKA,EAAgB;MACrB,UAAUoC,EAAU;MACpB,OAAOR,EAAM;KACd,CAAA,GACD,kBAAC,OAAD;MAAK,WAAU;MAA2B,UAAAQ,EAAU;KAAa,CAAA,CAC5D;IAEN,CAAA,CAAA;;GACJT,MAAW,KAAA,KAAa,kBAACJ,GAAD;IAAgB;IAAe;GAAQ,CAAA;EAC7D;;AAET"}
|
|
1
|
+
{"version":3,"file":"shell.js","names":["inspectorBounds","drawerBounds","clamp","px","max","min","clampInspectorWidth","drawerMaxHeight","share","windowHeight","clampDrawerHeight","defaultAppShellLabels","subscribeToResize","onChange","useWindowHeight","useSyncExternalStore","DrawerGlyph","Glyph","open","focusedIn","InspectorSlot","slot","useRef","useLayoutEffect","here","holder","back","active","TopBar","brand","status","start","end","Drawer","bodyId","useId","height","drawer","words","Splitter","IconButton","AppShell","labels","layout","useMediaBreakpoint","width","inspector","wide","headed","useState","element","shown","body","onContentKeyDown","event","className","topBar","children","Sheet","Panel","createPortal"],"sources":["../src/shell/app-shell/bounds.ts","../src/shell/app-shell/AppShell.tsx"],"sourcesContent":["// The sizes the shell holds its panes to (docs/components.md#appshell): an inspector 280–560 px wide, and a drawer\n// from 120 px to 70 % of the window's height. Pure, so an app can check a kept size with the same rules before it\n// draws (as usePersistentState's check).\n\n/** The inspector's width in px. */\nexport const inspectorBounds = { min: 280, max: 560 } as const;\n\n/** The drawer's height: at least `min` px, at most `maxShare` of the window's height. */\nexport const drawerBounds = { min: 120, maxShare: 0.7 } as const;\n\n/** `px` as whole px within `min` and `max`; a value that is not a finite number is `min`. */\nfunction clamp(px: number, min: number, max: number): number {\n if (!Number.isFinite(px)) return min;\n return Math.min(max, Math.max(min, Math.round(px)));\n}\n\n/** The inspector's width as drawn for an asked `px`: whole px within 280–560. */\nexport function clampInspectorWidth(px: number): number {\n return clamp(px, inspectorBounds.min, inspectorBounds.max);\n}\n\n/** The tallest the drawer may be in a window `windowHeight` px high: 70 % of it, and never below the least. */\nexport function drawerMaxHeight(windowHeight: number): number {\n const share = Number.isFinite(windowHeight) ? Math.floor(windowHeight * drawerBounds.maxShare) : 0;\n return Math.max(drawerBounds.min, share);\n}\n\n/** The drawer's height as drawn for an asked `px` in a window `windowHeight` px high. */\nexport function clampDrawerHeight(px: number, windowHeight: number): number {\n return clamp(px, drawerBounds.min, drawerMaxHeight(windowHeight));\n}\n","// The layout of a graph-editing app (docs/components.md#appshell): a top bar of slots, the canvas, an inspector at the\n// inline end and a drawer along the bottom, filling the screen (100dvh) inside the safe-area insets. It keeps no data:\n// the inspector's width, the drawer's height and whether each is open are the app's props, drawn within the shell's\n// bounds (bounds.ts) and changed through callbacks. Below 760 px the inspector is a Sheet over the canvas's inline\n// end, below 600 px one rising from the bottom (useMediaBreakpoint's widths). With the inspector's title or actions,\n// the shell draws its one header row: a Panel's when wide, the sheet's own when narrow. The inspector's content is drawn\n// once, into an element of its own that moves between the region and the sheet, so a draft held in it survives the\n// window crossing a width (docs/components.md#appshell). The drawer's body stays mounted while it is closed, so what it\n// holds (a draft, a caret, a scroll position) is still there when it opens.\nimport {\n type KeyboardEvent,\n type ReactNode,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n useSyncExternalStore,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { useMediaBreakpoint } from \"../../hooks\";\nimport { Glyph, IconButton, Panel, Sheet, Splitter } from \"../../primitives\";\nimport { clampDrawerHeight, clampInspectorWidth, drawerBounds, drawerMaxHeight, inspectorBounds } from \"./bounds\";\nimport \"./AppShell.css\";\n\n/**\n * The top bar's slots, drawn in reading order (left to right in left-to-right text): the brand, a status, the app's\n * controls, and controls at the far end.\n */\nexport type AppShellTopBar = {\n /** The app's mark or name, first. */\n brand?: ReactNode;\n /** A short state after the brand (a connection's Pill). */\n status?: ReactNode;\n /** The app's controls, taking the free width. */\n start?: ReactNode;\n /** Controls at the far end (a theme switch, a menu). */\n end?: ReactNode;\n};\n\nexport type AppShellInspector = {\n /**\n * The inspector's heading (the selection's name). With it, or with `actions`, the shell draws the inspector's one\n * header row itself: a Panel's on a wide window, the sheet's own beside its close button on a narrow one, and\n * `content` is the body under it. Without either, `content` is drawn as given (usually a Panel).\n */\n title?: ReactNode;\n /** Slot at the far end of the inspector's header row (buttons, a count), before the sheet's close button. */\n actions?: ReactNode;\n /** What the inspector shows: its body under `title` and `actions`, or without them usually a Panel. */\n content: ReactNode;\n /** Whether it is shown; the app holds it. */\n open: boolean;\n /** Asked for with false when the person closes the narrow window's sheet (its close button, or Escape inside it). */\n onOpen: (open: boolean) => void;\n /** Its width in px, drawn within 280–560 px (`inspectorBounds`); a narrow window's sheet takes it too. */\n width: number;\n /** A new width from its splitter, in whole px within the bounds. */\n onWidth: (px: number) => void;\n};\n\nexport type AppShellDrawer = {\n /** The drawer's header, beside its show and hide button; shown while it is closed too. */\n header: ReactNode;\n /** The drawer's body, mounted while it is closed. */\n content: ReactNode;\n /** Whether its body is shown; the app holds it. */\n open: boolean;\n /** Asked for by its show and hide button. */\n onOpen: (open: boolean) => void;\n /** Its height in px while open, header included, drawn within 120 px and 70 % of the window (`drawerBounds`). */\n height: number;\n /** A new height from its splitter, in whole px within the bounds. */\n onHeight: (px: number) => void;\n};\n\n/** The shell's own words, each replaceable. */\nexport interface AppShellLabels {\n /** The inspector's name, as a region and as a sheet: \"Inspector\". */\n inspector: string;\n /** The drawer's name as a region: \"Drawer\". */\n drawer: string;\n /** The inspector's splitter: \"Resize the inspector\". */\n resizeInspector: string;\n /** The drawer's splitter: \"Resize the drawer\". */\n resizeDrawer: string;\n /** The drawer's button while it is closed: \"Show the drawer\". */\n showDrawer: string;\n /** The drawer's button while it is open: \"Hide the drawer\". */\n hideDrawer: string;\n /** The inspector sheet's close button: \"Close\". */\n close: string;\n}\n\nexport const defaultAppShellLabels: AppShellLabels = {\n inspector: \"Inspector\",\n drawer: \"Drawer\",\n resizeInspector: \"Resize the inspector\",\n resizeDrawer: \"Resize the drawer\",\n showDrawer: \"Show the drawer\",\n hideDrawer: \"Hide the drawer\",\n close: \"Close\",\n};\n\nexport type AppShellProps = {\n /** The top bar's slots; without them there is no bar. */\n topBar?: AppShellTopBar;\n /** The inspector; without it there is none. */\n inspector?: AppShellInspector;\n /** The drawer; without it there is none. */\n drawer?: AppShellDrawer;\n /** The canvas, filling the workspace. */\n children: ReactNode;\n /** Words to replace; the rest keep their defaults. */\n labels?: Partial<AppShellLabels>;\n /** A class added to the shell. */\n className?: string;\n};\n\nfunction subscribeToResize(onChange: () => void): () => void {\n window.addEventListener(\"resize\", onChange);\n return () => {\n window.removeEventListener(\"resize\", onChange);\n };\n}\n\n/** The window's height in px, kept current as it resizes; 0 with no window (the drawer then holds to its least). */\nfunction useWindowHeight(): number {\n return useSyncExternalStore(\n subscribeToResize,\n () => window.innerHeight,\n () => 0,\n );\n}\n\n/** A chevron pointing up (show) or down (hide), in the current text colour. */\nfunction DrawerGlyph({ open }: { open: boolean }) {\n return (\n <Glyph>\n <path d={open ? \"M4 6l4 4 4-4\" : \"M4 10l4-4 4 4\"} />\n </Glyph>\n );\n}\n\n/** The element focused inside a content's holder as it left one slot, focused again in the next. */\nconst focusedIn = new WeakMap<HTMLElement, HTMLElement>();\n\n/**\n * Where the inspector's content shows: it moves the content's own element (the `holder`) in here while mounted, and out\n * again when it goes. A focus inside the content is kept across the move, as a moved element loses it.\n */\nfunction InspectorSlot({ holder }: { holder: HTMLElement }) {\n const slot = useRef<HTMLDivElement>(null);\n useLayoutEffect(() => {\n const here = slot.current;\n if (here === null) return;\n here.appendChild(holder);\n const back = focusedIn.get(holder);\n focusedIn.delete(holder);\n if (back !== undefined && holder.contains(back) && document.activeElement !== back)\n back.focus({ preventScroll: true });\n return () => {\n const active = document.activeElement;\n if (active instanceof HTMLElement && holder.contains(active)) focusedIn.set(holder, active);\n if (holder.parentNode === here) here.removeChild(holder);\n };\n }, [holder]);\n return <div ref={slot} className=\"pb-shell-inspector-slot\" />;\n}\n\nfunction TopBar({ brand, status, start, end }: AppShellTopBar) {\n return (\n <header className=\"pb-shell-bar\">\n {brand !== undefined && <div className=\"pb-shell-brand\">{brand}</div>}\n {status !== undefined && <div className=\"pb-shell-status\">{status}</div>}\n <div className=\"pb-shell-start\">{start}</div>\n {end !== undefined && <div className=\"pb-shell-end\">{end}</div>}\n </header>\n );\n}\n\nfunction Drawer({ drawer, words }: { drawer: AppShellDrawer; words: AppShellLabels }) {\n const bodyId = useId();\n const windowHeight = useWindowHeight();\n const height = clampDrawerHeight(drawer.height, windowHeight);\n return (\n <section\n className=\"pb-shell-drawer\"\n aria-label={words.drawer}\n data-open={drawer.open ? \"\" : undefined}\n style={drawer.open ? { height: `${height}px` } : undefined}\n >\n {drawer.open && (\n <Splitter\n orientation=\"horizontal\"\n edge=\"start\"\n value={height}\n min={drawerBounds.min}\n max={drawerMaxHeight(windowHeight)}\n onChange={drawer.onHeight}\n label={words.resizeDrawer}\n />\n )}\n <div className=\"pb-shell-drawer-head\">\n <div className=\"pb-shell-drawer-header\">{drawer.header}</div>\n <IconButton\n className=\"pb-shell-drawer-toggle\"\n label={drawer.open ? words.hideDrawer : words.showDrawer}\n aria-expanded={drawer.open}\n aria-controls={bodyId}\n onClick={() => {\n drawer.onOpen(!drawer.open);\n }}\n >\n <DrawerGlyph open={drawer.open} />\n </IconButton>\n </div>\n <div className=\"pb-shell-drawer-body\" id={bodyId} hidden={!drawer.open}>\n {drawer.content}\n </div>\n </section>\n );\n}\n\n/** Lays out a graph editor: top bar, canvas, inspector and drawer, with a sheet for the inspector on narrow windows. */\nexport function AppShell({ topBar, inspector, drawer, children, labels, className }: AppShellProps) {\n const words = { ...defaultAppShellLabels, ...labels };\n const { width: layout } = useMediaBreakpoint();\n const width = inspector === undefined ? 0 : clampInspectorWidth(inspector.width);\n const wide = layout === \"wide\";\n const headed = inspector !== undefined && (inspector.title !== undefined || inspector.actions !== undefined);\n // The content's own element, made once (none without a document, where the content is drawn in place).\n const [holder] = useState(() => {\n if (typeof document === \"undefined\") return null;\n const element = document.createElement(\"div\");\n element.className = \"pb-shell-inspector-content\";\n return element;\n });\n const shown = inspector?.open === true;\n const body = inspector === undefined ? null : holder === null ? inspector.content : <InspectorSlot holder={holder} />;\n // The content's events reach React through the shell, not the sheet around it, so the sheet's Escape is taken here:\n // the press is the sheet's when the window is narrow and not already handled (docs/ux-rules.md#escape, U14, U19).\n const onContentKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (wide || inspector === undefined) return;\n if (event.defaultPrevented || event.nativeEvent.isComposing || event.key !== \"Escape\") return;\n event.preventDefault();\n event.stopPropagation();\n inspector.onOpen(false);\n };\n return (\n <div\n className={className === undefined ? \"pb-shell\" : `pb-shell ${className}`}\n data-layout={layout}\n data-bar={topBar === undefined ? undefined : \"\"}\n data-drawer={drawer === undefined ? undefined : \"\"}\n >\n {topBar !== undefined && <TopBar {...topBar} />}\n <div className=\"pb-shell-main\">\n <main className=\"pb-shell-workspace\">\n {children}\n {inspector !== undefined && !wide && (\n <Sheet\n open={inspector.open}\n onClose={() => {\n inspector.onOpen(false);\n }}\n side={layout === \"phone\" ? \"bottom\" : \"end\"}\n title={inspector.title}\n label={words.inspector}\n actions={inspector.actions}\n width={width}\n labels={{ close: words.close }}\n >\n {body}\n </Sheet>\n )}\n </main>\n {inspector !== undefined && wide && inspector.open && (\n <aside className=\"pb-shell-inspector\" aria-label={words.inspector} style={{ width: `${width}px` }}>\n <Splitter\n orientation=\"vertical\"\n edge=\"start\"\n value={width}\n min={inspectorBounds.min}\n max={inspectorBounds.max}\n onChange={inspector.onWidth}\n label={words.resizeInspector}\n />\n <div className=\"pb-shell-inspector-body\">\n {headed ? (\n <Panel className=\"pb-shell-inspector-panel\" title={inspector.title} actions={inspector.actions}>\n {body}\n </Panel>\n ) : (\n body\n )}\n </div>\n </aside>\n )}\n </div>\n {drawer !== undefined && <Drawer drawer={drawer} words={words} />}\n {inspector !== undefined &&\n holder !== null &&\n shown &&\n createPortal(\n // A wrapper with no box of its own (display: contents), for the sheet's Escape.\n <div className=\"pb-shell-inspector-events\" onKeyDown={onContentKeyDown}>\n {inspector.content}\n </div>,\n holder,\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;AAKA,IAAaA,IAAkB;CAAE,KAAK;CAAK,KAAK;AAAI,GAGvCC,IAAe;CAAE,KAAK;CAAK,UAAU;AAAI;AAGtD,SAASC,EAAM,GAAY,GAAa,GAAqB;CAE3D,OADK,OAAO,SAASC,CAAE,IAChB,KAAK,IAAIC,GAAK,KAAK,IAAIC,GAAK,KAAK,MAAMF,CAAE,CAAC,CAAC,IADjBE;AAEnC;AAGA,SAAgBC,EAAoB,GAAoB;CACtD,OAAOJ,EAAMC,GAAIH,EAAgB,KAAKA,EAAgB,GAAG;AAC3D;AAGA,SAAgBO,EAAgB,GAA8B;CAC5D,IAAMC,IAAQ,OAAO,SAASC,CAAY,IAAI,KAAK,MAAMA,IAAeR,EAAa,QAAQ,IAAI;CACjG,OAAO,KAAK,IAAIA,EAAa,KAAKO,CAAK;AACzC;AAGA,SAAgBE,EAAkB,GAAY,GAA8B;CAC1E,OAAOR,EAAMC,GAAIF,EAAa,KAAKM,EAAgBE,CAAY,CAAC;AAClE;;AC+DA,IAAaE,IAAwC;CACnD,WAAW;CACX,QAAQ;CACR,iBAAiB;CACjB,cAAc;CACd,YAAY;CACZ,YAAY;CACZ,OAAO;AACT;AAiBA,SAASC,EAAkB,GAAkC;CAE3D,OADA,OAAO,iBAAiB,UAAUC,CAAQ,SAC7B;EACX,OAAO,oBAAoB,UAAUA,CAAQ;CAC/C;AACF;AAGA,SAASC,IAA0B;CACjC,OAAOC,EACLH,SAC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AhG,UAAA,CACE,kBAACN,GAAD;MACE,aAAY;MACZ,MAAK;MACL,OAAOM;MACP,KAAK7C,EAAgB;MACrB,KAAKA,EAAgB;MACrB,UAAU8C,EAAU;MACpB,OAAOR,EAAM;KACd,CAAA,GACD,kBAAC,OAAD;MAAK,WAAU;MACZ,UAAAU,IACC,kBAACW,GAAD;OAAO,WAAU;OAA2B,OAAOb,EAAU;OAAO,SAASA,EAAU;OACpF,UAAAM;MACI,CAAA,IAEPA;KAEC,CAAA,CACA;IAEN,CAAA,CAAA;;GACJf,MAAW,KAAA,KAAa,kBAACJ,GAAD;IAAgB;IAAe;GAAQ,CAAA;GAC/Da,MAAc,KAAA,KACbrB,MAAW,QACX0B,KACAS,EAEE,kBAAC,OAAD;IAAK,WAAU;IAA4B,WAAWP;IACnD,UAAAP,EAAU;GACR,CAAA,GACLrB,CACF;EACC;;AAET"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ComponentPropsWithRef, type ReactNode } from "react";
|
|
2
2
|
import "./Banner.css";
|
|
3
3
|
/** The tones a banner draws; any other string is drawn neutrally. */
|
|
4
|
-
export type BannerTone = "ok" | "warn" | "err" | "quiet" | "off" | (string & {});
|
|
4
|
+
export type BannerTone = "ok" | "warn" | "err" | "quiet" | "off" | "accent" | "muted" | (string & {});
|
|
5
5
|
/** The banner's own words, each replaceable. */
|
|
6
6
|
export interface BannerLabels {
|
|
7
7
|
/** The close button's name: "Dismiss". */
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type ComponentPropsWithRef, type ReactNode } from "react";
|
|
2
|
+
import "./ChangeList.css";
|
|
3
|
+
/** What a queued change does; any other word is drawn neutrally, by itself. */
|
|
4
|
+
export type ChangeKind = "added" | "removed" | "renamed" | "changed" | (string & {});
|
|
5
|
+
/** One queued change. */
|
|
6
|
+
export type QueuedChange = {
|
|
7
|
+
/** The app's id for the change, passed to `onDrop`. */
|
|
8
|
+
id: string;
|
|
9
|
+
/** What it does: its Badge's tone and word. */
|
|
10
|
+
change: ChangeKind;
|
|
11
|
+
/** What it changes, in the app's words ("mix-2", "Tone 1: left → mix-2: in"). */
|
|
12
|
+
label: ReactNode;
|
|
13
|
+
/** A second, quieter line: what changes ("gain 0.8 → 1.2", "was tone 1"). */
|
|
14
|
+
detail?: ReactNode;
|
|
15
|
+
/** Why a check refused it, in words; the row is marked until the queue changes. */
|
|
16
|
+
refused?: string;
|
|
17
|
+
};
|
|
18
|
+
/** The list's own words, each replaceable. */
|
|
19
|
+
export interface ChangeListLabels {
|
|
20
|
+
/** The Badge's word for each change it knows: "added", "removed", "renamed", "changed". */
|
|
21
|
+
added: string;
|
|
22
|
+
removed: string;
|
|
23
|
+
renamed: string;
|
|
24
|
+
changed: string;
|
|
25
|
+
/** The count: "No changes", "1 change", "3 changes". */
|
|
26
|
+
count: (count: number) => string;
|
|
27
|
+
/** Each row's drop button: "Drop". It is described by the row's words, so several read apart. */
|
|
28
|
+
drop: string;
|
|
29
|
+
/** A refused row's reason: "Refused: " and the reason. */
|
|
30
|
+
refused: (reason: string) => string;
|
|
31
|
+
}
|
|
32
|
+
export declare const defaultChangeListLabels: ChangeListLabels;
|
|
33
|
+
export type ChangeListProps = Omit<ComponentPropsWithRef<"section">, "children"> & {
|
|
34
|
+
/** The queued changes, in the order the app holds them (the newest last). */
|
|
35
|
+
changes: readonly QueuedChange[];
|
|
36
|
+
/** Asked for by a row's drop button, with its change's id. Without it, the rows have no drop button. */
|
|
37
|
+
onDrop?: (id: string) => void;
|
|
38
|
+
/** Slot at the header's far end: the app's Check, Save and Discard. */
|
|
39
|
+
actions?: ReactNode;
|
|
40
|
+
/** Words to replace; the rest keep their defaults. */
|
|
41
|
+
labels?: Partial<ChangeListLabels>;
|
|
42
|
+
};
|
|
43
|
+
/** Lists the queued changes in words, each with its Badge and a drop button, under their count and the app's actions. */
|
|
44
|
+
export declare function ChangeList({ changes, onDrop, actions, labels, className, ...rest }: ChangeListProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ComponentPropsWithRef, type RefObject } from "react";
|
|
2
|
+
import { type CodeDiagnostic } from "../code-editor";
|
|
3
|
+
import "./DiagnosticList.css";
|
|
4
|
+
/** The list's own words, each replaceable. */
|
|
5
|
+
export interface DiagnosticListLabels {
|
|
6
|
+
/** How a diagnostic is shown and read, CodeEditor's own: "Line 3, column 5: error E1: message". */
|
|
7
|
+
diagnostic: (diagnostic: CodeDiagnostic) => string;
|
|
8
|
+
/** The count in the status line: "No problems", "1 problem", "3 problems". */
|
|
9
|
+
count: (count: number) => string;
|
|
10
|
+
}
|
|
11
|
+
export declare const defaultDiagnosticListLabels: DiagnosticListLabels;
|
|
12
|
+
export type DiagnosticListProps = Omit<ComponentPropsWithRef<"div">, "children"> & {
|
|
13
|
+
/** What the app found in the text, as it gives `CodeEditor`, listed in the order given. */
|
|
14
|
+
diagnostics: readonly CodeDiagnostic[];
|
|
15
|
+
/** The editor's textarea (the `ref` given to `CodeEditor`): a row's press focuses it and puts the caret there. */
|
|
16
|
+
editor?: RefObject<HTMLTextAreaElement | null>;
|
|
17
|
+
/** Called after a row's press with its diagnostic, as when the app must first show the editor. */
|
|
18
|
+
onGo?: (diagnostic: CodeDiagnostic) => void;
|
|
19
|
+
/** Words to replace; the rest keep their defaults. */
|
|
20
|
+
labels?: Partial<DiagnosticListLabels>;
|
|
21
|
+
};
|
|
22
|
+
/** Lists an editor's diagnostics in words, each a button to its place, under a count. */
|
|
23
|
+
export declare function DiagnosticList({ diagnostics, editor, onGo, labels, className, ...rest }: DiagnosticListProps): import("react").JSX.Element;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from "./banner";
|
|
2
|
+
export * from "./change-list";
|
|
2
3
|
export * from "./code-editor";
|
|
3
4
|
export * from "./command-palette";
|
|
5
|
+
export * from "./diagnostic-list";
|
|
4
6
|
export * from "./diff-view";
|
|
5
7
|
export * from "./shortcut-sheet";
|
|
6
8
|
export * from "./status-words";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ComponentPropsWithRef } from "react";
|
|
2
2
|
import "./StatusWords.css";
|
|
3
3
|
/** The tones a word draws; any other string is drawn neutrally. */
|
|
4
|
-
export type StatusWordTone = "ok" | "warn" | "err" | "quiet" | "off" | (string & {});
|
|
4
|
+
export type StatusWordTone = "ok" | "warn" | "err" | "quiet" | "off" | "accent" | "muted" | (string & {});
|
|
5
5
|
export type StatusWord = {
|
|
6
6
|
tone: StatusWordTone;
|
|
7
7
|
/** The state in words. */
|
|
@@ -11,21 +11,27 @@ export type FlowPoint = {
|
|
|
11
11
|
export type OnAddAt = (point: FlowPoint, from?: PortRef & {
|
|
12
12
|
side: PortSide;
|
|
13
13
|
}) => void;
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* The props `useAddAt` gives `<ReactFlow>`. `zoomOnDoubleClick` is false while adding is on, as the double-click is
|
|
16
|
+
* the add, and absent while it is off, so React Flow's own zoom on double-click (or the app's choice) holds.
|
|
17
|
+
*/
|
|
15
18
|
export type AddAtFlowProps = {
|
|
16
19
|
onDoubleClick: (event: ReactMouseEvent<HTMLDivElement>) => void;
|
|
17
20
|
onConnectStart: OnConnectStart;
|
|
18
21
|
onConnectEnd: OnConnectEnd;
|
|
19
|
-
zoomOnDoubleClick
|
|
22
|
+
zoomOnDoubleClick?: false;
|
|
20
23
|
};
|
|
21
24
|
export type AddAtOptions = {
|
|
22
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* false switches adding off (as while the graph is read-only), and gives double-click back to React Flow's zoom;
|
|
27
|
+
* true by default.
|
|
28
|
+
*/
|
|
23
29
|
enabled?: boolean;
|
|
24
30
|
};
|
|
25
31
|
/**
|
|
26
32
|
* Calls `onAddAt` for a double-click on empty canvas and for a wire dropped there where no handle took it. Its
|
|
27
|
-
* `flowProps` go to `<ReactFlow>` (through `mergeFlowProps` with others); it turns React Flow's
|
|
28
|
-
* off, as the double-click is the add.
|
|
33
|
+
* `flowProps` go to `<ReactFlow>` (through `mergeFlowProps` with others); while adding is on it turns React Flow's
|
|
34
|
+
* zoom on double-click off, as the double-click is the add.
|
|
29
35
|
*/
|
|
30
36
|
export declare function useAddAt(onAddAt: OnAddAt, options?: AddAtOptions): {
|
|
31
37
|
flowProps: AddAtFlowProps;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type FitViewOptions, type Node, type PanelPosition } from "@xyflow/react";
|
|
2
|
-
import type
|
|
2
|
+
import { type ReactNode } from "react";
|
|
3
3
|
import "./CanvasTools.css";
|
|
4
4
|
/** The tools' words, each replaceable. */
|
|
5
5
|
export interface CanvasToolsLabels {
|
|
@@ -21,6 +21,11 @@ export type CanvasToolsProps<NodeType extends Node = Node> = {
|
|
|
21
21
|
fitOptions?: FitViewOptions<NodeType>;
|
|
22
22
|
/** Replaces the fit tool's own fit (pass useFollowFit's `fit`, so the tool also resumes following). */
|
|
23
23
|
onFit?: () => void;
|
|
24
|
+
/**
|
|
25
|
+
* The person moved the view through the tools: a press of a zoom tool, or a drag or wheel on the minimap that moved
|
|
26
|
+
* it. Pass useFollowFit's `stop`, so these moves stop following as a pan or a wheel on the canvas does.
|
|
27
|
+
*/
|
|
28
|
+
onViewMove?: () => void;
|
|
24
29
|
/** The tidy tool, shown only when given: the layout is the app's. */
|
|
25
30
|
onTidy?: () => void;
|
|
26
31
|
/** Whether the minimap is on: the minimap tool is pressed and React Flow's <MiniMap> is drawn. */
|
|
@@ -37,4 +42,4 @@ export type CanvasToolsProps<NodeType extends Node = Node> = {
|
|
|
37
42
|
/** More tools (IconButtons) after patchbay's. */
|
|
38
43
|
children?: ReactNode;
|
|
39
44
|
};
|
|
40
|
-
export declare function CanvasTools<NodeType extends Node = Node>({ position, fitOptions, onFit, onTidy, minimap, onMinimap, minimapNodeClassName, keyShortcuts, labels, className, children, }: CanvasToolsProps<NodeType>): import("react").JSX.Element;
|
|
45
|
+
export declare function CanvasTools<NodeType extends Node = Node>({ position, fitOptions, onFit, onViewMove, onTidy, minimap, onMinimap, minimapNodeClassName, keyShortcuts, labels, className, children, }: CanvasToolsProps<NodeType>): import("react").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PortSide } from "../port-row";
|
|
2
|
+
import type { CanConnect, PortRef } from "./useConnectHints";
|
|
3
|
+
/** A port that might be joined: its handle and its side. The app may carry more (a label, a type) on it. */
|
|
4
|
+
export type ConnectCandidate = PortRef & {
|
|
5
|
+
side: PortSide;
|
|
6
|
+
};
|
|
7
|
+
/** The candidates the rule accepts for one port, and those it refuses with its reason when it gave one. */
|
|
8
|
+
export type ConnectTargets<T extends ConnectCandidate> = {
|
|
9
|
+
/** The accepted candidates, in the order given: what a "Connect to" choice lists. */
|
|
10
|
+
accepted: T[];
|
|
11
|
+
/** The refused candidates on the other side, in the order given, each with the rule's string when it gave one. */
|
|
12
|
+
refused: {
|
|
13
|
+
port: T;
|
|
14
|
+
reason?: string;
|
|
15
|
+
}[];
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Judges each candidate on the other side of `port` by `canConnect`, the output always first, as a drag would:
|
|
19
|
+
* `true` accepts; `false` or a string refuses, the string being the reason. Candidates on `port`'s own side are not
|
|
20
|
+
* candidates (React Flow's strict connection mode), and are in neither list. Each pair is asked of the rule once.
|
|
21
|
+
*/
|
|
22
|
+
export declare function connectTargets<T extends ConnectCandidate>(port: PortRef, side: PortSide, candidates: readonly T[], canConnect: CanConnect): ConnectTargets<T>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
export { connectTargets } from "./connectTargets";
|
|
2
|
+
export type { ConnectCandidate, ConnectTargets } from "./connectTargets";
|
|
1
3
|
export { mergeFlowProps } from "./mergeFlowProps";
|
|
2
4
|
export type { MergedFlowProps } from "./mergeFlowProps";
|
|
3
5
|
export { ConnectHints, useConnectHints } from "./useConnectHints";
|
|
4
|
-
export type { CanConnect, ConnectHintsFlowProps, ConnectHintsValue, PortHintOf, PortRef } from "./useConnectHints";
|
|
6
|
+
export type { CanConnect, ConnectHintsFlowProps, ConnectHintsValue, ConnectRefusal, PortHintOf, PortRef, } from "./useConnectHints";
|
|
@@ -25,6 +25,13 @@ export type ConnectHintsValue = {
|
|
|
25
25
|
/** The hint for one handle: `origin`, `ok` or `no` (with its reason) on the other side, `null` on the origin's. */
|
|
26
26
|
hintFor: (port: PortRef, side: PortSide) => PortHintOf;
|
|
27
27
|
} | null;
|
|
28
|
+
/** A drop on a handle the rule refused: that handle, its side, and the rule's reason when it gave one. */
|
|
29
|
+
export type ConnectRefusal = {
|
|
30
|
+
port: PortRef & {
|
|
31
|
+
side: PortSide;
|
|
32
|
+
};
|
|
33
|
+
reason?: string;
|
|
34
|
+
};
|
|
28
35
|
/** The handlers `useConnectHints` gives `<ReactFlow>`. */
|
|
29
36
|
export type ConnectHintsFlowProps = {
|
|
30
37
|
onConnectStart: OnConnectStart;
|
|
@@ -44,5 +51,7 @@ export declare function useConnectHintsValue(): ConnectHintsValue;
|
|
|
44
51
|
*/
|
|
45
52
|
export declare function useConnectHints(canConnect: CanConnect): {
|
|
46
53
|
value: ConnectHintsValue;
|
|
54
|
+
/** The last drop the rule refused, until the next drag begins; `null` when the last drag ended otherwise. */
|
|
55
|
+
refused: ConnectRefusal | null;
|
|
47
56
|
flowProps: ConnectHintsFlowProps;
|
|
48
57
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type PanelPosition } from "@xyflow/react";
|
|
2
|
+
import type { ConnectHintsValue, ConnectRefusal } from "../connect-hints";
|
|
3
|
+
import "./ConnectStatus.css";
|
|
4
|
+
/** The status line's words, each replaceable. */
|
|
5
|
+
export interface ConnectStatusLabels {
|
|
6
|
+
/** Over a port that refuses the wire: the rule's reason, or "This port refuses the wire" when it gave none. */
|
|
7
|
+
refuses: (reason: string | undefined) => string;
|
|
8
|
+
/** After a drop the rule refused: "Not connected: " and the reason, or "Not connected: that port refuses the wire". */
|
|
9
|
+
notConnected: (reason: string | undefined) => string;
|
|
10
|
+
}
|
|
11
|
+
export declare const defaultConnectStatusLabels: ConnectStatusLabels;
|
|
12
|
+
export type ConnectStatusProps = {
|
|
13
|
+
/** `useConnectHints`'s `value`: the drag in progress, or `null`. */
|
|
14
|
+
value: ConnectHintsValue;
|
|
15
|
+
/** `useConnectHints`'s `refused`: the last drop the rule refused, or `null`. */
|
|
16
|
+
refused: ConnectRefusal | null;
|
|
17
|
+
/** Where the line sits on the canvas, React Flow's `PanelPosition`: "bottom-center" by default. */
|
|
18
|
+
position?: PanelPosition | (string & {});
|
|
19
|
+
/** Words to replace; the rest keep their defaults. */
|
|
20
|
+
labels?: Partial<ConnectStatusLabels>;
|
|
21
|
+
/** Added to the panel's own `pb-connect-status` class. */
|
|
22
|
+
className?: string;
|
|
23
|
+
};
|
|
24
|
+
/** What the line says now: why the port under the drag refuses, else a refused drop's verdict, else nothing. */
|
|
25
|
+
export declare function connectStatusWords(value: ConnectHintsValue, refused: ConnectRefusal | null, over: {
|
|
26
|
+
nodeId: string;
|
|
27
|
+
handleId: string | null;
|
|
28
|
+
side: "input" | "output";
|
|
29
|
+
} | null, labels?: ConnectStatusLabels): string;
|
|
30
|
+
export declare function ConnectStatus({ value, refused, position, labels, className }: ConnectStatusProps): import("react").JSX.Element;
|