@mcurcio/patchbay 0.8.0 → 0.9.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/dist/shell.css CHANGED
@@ -1 +1 @@
1
- .pb-shell{box-sizing:border-box;height:100vh;height:100dvh;font-family:var(--pb-font-ui);font-size:var(--pb-text-md);color:var(--pb-text);background:var(--pb-surface);flex-direction:column;display:flex;overflow:hidden}.pb-shell:not([data-bar]){padding-top:env(safe-area-inset-top)}.pb-shell-bar{align-items:center;gap:var(--pb-space-3);box-sizing:content-box;min-height:var(--pb-bar);padding-top:env(safe-area-inset-top);padding-left:calc(var(--pb-space-3) + env(safe-area-inset-left));padding-right:calc(var(--pb-space-3) + env(safe-area-inset-right));background:var(--pb-raised);border-bottom:1px solid var(--pb-line);flex:none;display:flex}.pb-shell-brand,.pb-shell-status,.pb-shell-end{align-items:center;gap:var(--pb-space-2);flex:none;display:flex}.pb-shell-brand{font-weight:600}.pb-shell-start{align-items:center;gap:var(--pb-space-2);flex:auto;min-width:0;display:flex}.pb-shell-main{min-height:0;padding-left:env(safe-area-inset-left);padding-right:env(safe-area-inset-right);flex:auto;display:flex}.pb-shell:not([data-drawer]) .pb-shell-main{padding-bottom:env(safe-area-inset-bottom)}.pb-shell-workspace{flex-direction:column;flex:auto;min-width:0;display:flex;position:relative;overflow:hidden}.pb-shell-workspace>:not(.pb-sheet){flex:auto;min-height:0}.pb-shell-inspector{box-sizing:border-box;background:var(--pb-raised);border-inline-start:1px solid var(--pb-line);flex-direction:column;flex:none;min-height:0;display:flex;position:relative}.pb-shell-inspector-body{flex-direction:column;flex:auto;min-height:0;display:flex;overflow:auto}.pb-shell-drawer{box-sizing:border-box;min-height:0;padding-bottom:env(safe-area-inset-bottom);background:var(--pb-raised);border-top:1px solid var(--pb-line);flex-direction:column;flex:none;display:flex;position:relative}.pb-shell-drawer-head{align-items:center;gap:var(--pb-space-3);box-sizing:border-box;min-height:var(--pb-bar);padding-left:calc(var(--pb-space-3) + env(safe-area-inset-left));padding-right:calc(var(--pb-space-3) + env(safe-area-inset-right));flex:none;display:flex}.pb-shell-drawer[data-open] .pb-shell-drawer-head{border-bottom:1px solid var(--pb-line)}.pb-shell-drawer-header{align-items:center;gap:var(--pb-space-2);flex:auto;min-width:0;display:flex}.pb-button.pb-shell-drawer-toggle{color:var(--pb-muted);flex:none}.pb-button.pb-shell-drawer-toggle:hover{color:var(--pb-text)}.pb-shell-drawer-body{min-height:0;padding-left:env(safe-area-inset-left);padding-right:env(safe-area-inset-right);flex-direction:column;flex:auto;display:flex;overflow:auto}.pb-shell-drawer-body[hidden]{display:none}@media (forced-colors:active){.pb-shell-bar,.pb-shell-inspector,.pb-shell-drawer,.pb-shell-drawer[data-open] .pb-shell-drawer-head{border-color:canvastext}}
1
+ .pb-shell{box-sizing:border-box;height:100vh;height:100dvh;font-family:var(--pb-font-ui);font-size:var(--pb-text-md);color:var(--pb-text);background:var(--pb-surface);flex-direction:column;display:flex;overflow:hidden}.pb-shell:not([data-bar]){padding-top:env(safe-area-inset-top)}.pb-shell-bar{align-items:center;gap:var(--pb-space-3);box-sizing:content-box;min-height:var(--pb-bar);padding-top:env(safe-area-inset-top);padding-left:calc(var(--pb-space-3) + env(safe-area-inset-left));padding-right:calc(var(--pb-space-3) + env(safe-area-inset-right));background:var(--pb-raised);border-bottom:1px solid var(--pb-line);flex:none;display:flex}.pb-shell-brand,.pb-shell-status,.pb-shell-end{align-items:center;gap:var(--pb-space-2);flex:none;display:flex}.pb-shell-brand{font-weight:600}.pb-shell-start{align-items:center;gap:var(--pb-space-2);flex:auto;min-width:0;display:flex}.pb-shell-main{min-height:0;padding-left:env(safe-area-inset-left);padding-right:env(safe-area-inset-right);flex:auto;display:flex}.pb-shell:not([data-drawer]) .pb-shell-main{padding-bottom:env(safe-area-inset-bottom)}.pb-shell-workspace{flex-direction:column;flex:auto;min-width:0;display:flex;position:relative;overflow:hidden}.pb-shell-workspace>:not(.pb-sheet){flex:auto;min-height:0}.pb-shell-inspector{box-sizing:border-box;background:var(--pb-raised);border-inline-start:1px solid var(--pb-line);flex-direction:column;flex:none;min-height:0;display:flex;position:relative}.pb-shell-inspector-body{flex-direction:column;flex:auto;min-height:0;display:flex;overflow:auto}.pb-shell-inspector-panel{flex:auto}.pb-shell-drawer{box-sizing:border-box;min-height:0;padding-bottom:env(safe-area-inset-bottom);background:var(--pb-raised);border-top:1px solid var(--pb-line);flex-direction:column;flex:none;display:flex;position:relative}.pb-shell-drawer-head{align-items:center;gap:var(--pb-space-3);box-sizing:border-box;min-height:var(--pb-bar);padding-left:calc(var(--pb-space-3) + env(safe-area-inset-left));padding-right:calc(var(--pb-space-3) + env(safe-area-inset-right));flex:none;display:flex}.pb-shell-drawer[data-open] .pb-shell-drawer-head{border-bottom:1px solid var(--pb-line)}.pb-shell-drawer-header{align-items:center;gap:var(--pb-space-2);flex:auto;min-width:0;display:flex}.pb-button.pb-shell-drawer-toggle{color:var(--pb-muted);flex:none}.pb-button.pb-shell-drawer-toggle:hover{color:var(--pb-text)}.pb-shell-drawer-body{min-height:0;padding-left:env(safe-area-inset-left);padding-right:env(safe-area-inset-right);flex-direction:column;flex:auto;display:flex;overflow:auto}.pb-shell-drawer-body[hidden]{display:none}@media (forced-colors:active){.pb-shell-bar,.pb-shell-inspector,.pb-shell-drawer,.pb-shell-drawer[data-open] .pb-shell-drawer-head{border-color:canvastext}}
package/dist/shell.js CHANGED
@@ -1,30 +1,30 @@
1
1
  import "./shell.css";import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
2
  import { useId as n, useSyncExternalStore as r } from "react";
3
- import { IconButton as i, Sheet as a, Splitter as o } from "./primitives.js";
4
- import { useMediaBreakpoint as s } from "./hooks.js";
3
+ import { IconButton as i, Panel as a, Sheet as o, Splitter as s } from "./primitives.js";
4
+ import { useMediaBreakpoint as c } from "./hooks.js";
5
5
  // src/shell/app-shell/bounds.ts
6
- var c = {
6
+ var l = {
7
7
  min: 280,
8
8
  max: 560
9
- }, l = {
9
+ }, u = {
10
10
  min: 120,
11
11
  maxShare: .7
12
12
  };
13
- function u(e, t, n) {
13
+ function d(e, t, n) {
14
14
  return Number.isFinite(e) ? Math.min(n, Math.max(t, Math.round(e))) : t;
15
15
  }
16
- function d(e) {
17
- return u(e, c.min, c.max);
18
- }
19
16
  function f(e) {
20
- let t = Number.isFinite(e) ? Math.floor(e * l.maxShare) : 0;
21
- return Math.max(l.min, t);
17
+ return d(e, l.min, l.max);
18
+ }
19
+ function p(e) {
20
+ let t = Number.isFinite(e) ? Math.floor(e * u.maxShare) : 0;
21
+ return Math.max(u.min, t);
22
22
  }
23
- function p(e, t) {
24
- return u(e, l.min, f(t));
23
+ function m(e, t) {
24
+ return d(e, u.min, p(t));
25
25
  }
26
26
  // src/shell/app-shell/AppShell.tsx
27
- var m = {
27
+ var h = {
28
28
  inspector: "Inspector",
29
29
  drawer: "Drawer",
30
30
  resizeInspector: "Resize the inspector",
@@ -33,15 +33,15 @@ var m = {
33
33
  hideDrawer: "Hide the drawer",
34
34
  close: "Close"
35
35
  };
36
- function h(e) {
36
+ function g(e) {
37
37
  return window.addEventListener("resize", e), () => {
38
38
  window.removeEventListener("resize", e);
39
39
  };
40
40
  }
41
- function g() {
42
- return r(h, () => window.innerHeight, () => 0);
41
+ function _() {
42
+ return r(g, () => window.innerHeight, () => 0);
43
43
  }
44
- function _({ open: t }) {
44
+ function v({ open: t }) {
45
45
  return /* @__PURE__ */ e("svg", {
46
46
  viewBox: "0 0 16 16",
47
47
  width: "12",
@@ -55,7 +55,7 @@ function _({ open: t }) {
55
55
  })
56
56
  });
57
57
  }
58
- function v({ brand: n, status: r, start: i, end: a }) {
58
+ function y({ brand: n, status: r, start: i, end: a }) {
59
59
  return /* @__PURE__ */ t("header", {
60
60
  className: "pb-shell-bar",
61
61
  children: [
@@ -78,20 +78,20 @@ function v({ brand: n, status: r, start: i, end: a }) {
78
78
  ]
79
79
  });
80
80
  }
81
- function y({ drawer: r, words: a }) {
82
- let s = n(), c = g(), u = p(r.height, c);
81
+ function b({ drawer: r, words: a }) {
82
+ let o = n(), c = _(), l = m(r.height, c);
83
83
  return /* @__PURE__ */ t("section", {
84
84
  className: "pb-shell-drawer",
85
85
  "aria-label": a.drawer,
86
86
  "data-open": r.open ? "" : void 0,
87
- style: r.open ? { height: `${u}px` } : void 0,
87
+ style: r.open ? { height: `${l}px` } : void 0,
88
88
  children: [
89
- r.open && /* @__PURE__ */ e(o, {
89
+ r.open && /* @__PURE__ */ e(s, {
90
90
  orientation: "horizontal",
91
91
  edge: "start",
92
- value: u,
93
- min: l.min,
94
- max: f(c),
92
+ value: l,
93
+ min: u.min,
94
+ max: p(c),
95
95
  onChange: r.onHeight,
96
96
  label: a.resizeDrawer
97
97
  }),
@@ -104,74 +104,81 @@ function y({ drawer: r, words: a }) {
104
104
  className: "pb-shell-drawer-toggle",
105
105
  label: r.open ? a.hideDrawer : a.showDrawer,
106
106
  "aria-expanded": r.open,
107
- "aria-controls": s,
107
+ "aria-controls": o,
108
108
  onClick: () => {
109
109
  r.onOpen(!r.open);
110
110
  },
111
- children: /* @__PURE__ */ e(_, { open: r.open })
111
+ children: /* @__PURE__ */ e(v, { open: r.open })
112
112
  })]
113
113
  }),
114
114
  /* @__PURE__ */ e("div", {
115
115
  className: "pb-shell-drawer-body",
116
- id: s,
116
+ id: o,
117
117
  hidden: !r.open,
118
118
  children: r.content
119
119
  })
120
120
  ]
121
121
  });
122
122
  }
123
- function b({ topBar: n, inspector: r, drawer: i, children: l, labels: u, className: f }) {
124
- let p = {
125
- ...m,
126
- ...u
127
- }, { width: h } = s(), g = r === void 0 ? 0 : d(r.width), _ = h === "wide";
123
+ function x({ topBar: n, inspector: r, drawer: i, children: u, labels: d, className: p }) {
124
+ let m = {
125
+ ...h,
126
+ ...d
127
+ }, { width: g } = c(), _ = r === void 0 ? 0 : f(r.width), v = g === "wide", x = r !== void 0 && (r.title !== void 0 || r.actions !== void 0);
128
128
  return /* @__PURE__ */ t("div", {
129
- className: f === void 0 ? "pb-shell" : `pb-shell ${f}`,
130
- "data-layout": h,
129
+ className: p === void 0 ? "pb-shell" : `pb-shell ${p}`,
130
+ "data-layout": g,
131
131
  "data-bar": n === void 0 ? void 0 : "",
132
132
  "data-drawer": i === void 0 ? void 0 : "",
133
133
  children: [
134
- n !== void 0 && /* @__PURE__ */ e(v, { ...n }),
134
+ n !== void 0 && /* @__PURE__ */ e(y, { ...n }),
135
135
  /* @__PURE__ */ t("div", {
136
136
  className: "pb-shell-main",
137
137
  children: [/* @__PURE__ */ t("main", {
138
138
  className: "pb-shell-workspace",
139
- children: [l, r !== void 0 && !_ && /* @__PURE__ */ e(a, {
139
+ children: [u, r !== void 0 && !v && /* @__PURE__ */ e(o, {
140
140
  open: r.open,
141
141
  onClose: () => {
142
142
  r.onOpen(!1);
143
143
  },
144
- side: h === "phone" ? "bottom" : "right",
145
- label: p.inspector,
146
- width: g,
147
- labels: { close: p.close },
144
+ side: g === "phone" ? "bottom" : "end",
145
+ title: r.title,
146
+ label: m.inspector,
147
+ actions: r.actions,
148
+ width: _,
149
+ labels: { close: m.close },
148
150
  children: r.content
149
151
  })]
150
- }), r !== void 0 && _ && r.open && /* @__PURE__ */ t("aside", {
152
+ }), r !== void 0 && v && r.open && /* @__PURE__ */ t("aside", {
151
153
  className: "pb-shell-inspector",
152
- "aria-label": p.inspector,
153
- style: { width: `${g}px` },
154
- children: [/* @__PURE__ */ e(o, {
154
+ "aria-label": m.inspector,
155
+ style: { width: `${_}px` },
156
+ children: [/* @__PURE__ */ e(s, {
155
157
  orientation: "vertical",
156
158
  edge: "start",
157
- value: g,
158
- min: c.min,
159
- max: c.max,
159
+ value: _,
160
+ min: l.min,
161
+ max: l.max,
160
162
  onChange: r.onWidth,
161
- label: p.resizeInspector
163
+ label: m.resizeInspector
162
164
  }), /* @__PURE__ */ e("div", {
163
165
  className: "pb-shell-inspector-body",
164
- children: r.content
166
+ children: x ? /* @__PURE__ */ e(a, {
167
+ className: "pb-shell-inspector-panel",
168
+ title: r.title,
169
+ actions: r.actions,
170
+ children: r.content
171
+ }) : r.content
165
172
  })]
166
173
  })]
167
174
  }),
168
- i !== void 0 && /* @__PURE__ */ e(y, {
175
+ i !== void 0 && /* @__PURE__ */ e(b, {
169
176
  drawer: i,
170
- words: p
177
+ words: m
171
178
  })
172
179
  ]
173
180
  });
174
181
  }
175
- export { b as AppShell, p as clampDrawerHeight, d as clampInspectorWidth, m as defaultAppShellLabels, l as drawerBounds, f as drawerMaxHeight, c as inspectorBounds };
182
+ export { x as AppShell, m as clampDrawerHeight, f as clampInspectorWidth, h as defaultAppShellLabels, u as drawerBounds, p as drawerMaxHeight, l as inspectorBounds };
176
183
 
177
184
  //# 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,IAAI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IAAQC,MAAc,KAAA,IAAY,IAAI9B,EAAoB8B,EAAU,KAAK,GACzEC,IAAOJ,MAAW;CACxB,OACE,kBAAC,OAAD;EACE,WAAWK,MAAc,KAAA,IAAY,aAAa,YAAYA;EAC9D,eAAaL;EACb,YAAUM,MAAW,KAAA,IAAY,KAAA,IAAY;EAC7C,eAAaZ,MAAW,KAAA,IAAY,KAAA,IAAY;EAJlD,UAAA;GAMGY,MAAW,KAAA,KAAa,kBAACrB,GAAD,EAAQ,GAAIqB,EAAS,CAAA;GAC9C,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CACGC,GACAJ,MAAc,KAAA,KAAa,CAACC,KAC3B,kBAACI,GAAD;MACE,MAAML,EAAU;MAChB,eAAe;OACb,EAAU,OAAO,EAAK;MACxB;MACA,MAAMH,MAAW,UAAU,WAAW;MACtC,OAAOL,EAAM;MACN;MACP,QAAQ,EAAE,OAAOA,EAAM,MAAM;MAE5B,UAAAQ,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","open","TopBar","brand","status","start","end","Drawer","bodyId","useId","height","drawer","words","Splitter","IconButton","AppShell","labels","layout","useMediaBreakpoint","width","inspector","wide","headed","className","topBar","children","Sheet","Panel"],"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 drawer's body stays\n// mounted while it is closed, 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, 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 <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 const headed = inspector !== undefined && (inspector.title !== undefined || inspector.actions !== undefined);\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 {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\">\n {headed ? (\n <Panel className=\"pb-shell-inspector-panel\" title={inspector.title} actions={inspector.actions}>\n {inspector.content}\n </Panel>\n ) : (\n inspector.content\n )}\n </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,E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@ export type FlowPoint = {
11
11
  export type OnAddAt = (point: FlowPoint, from?: PortRef & {
12
12
  side: PortSide;
13
13
  }) => void;
14
- /** The props `useAddAt` gives `<ReactFlow>`. */
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: false;
22
+ zoomOnDoubleClick?: false;
20
23
  };
21
24
  export type AddAtOptions = {
22
- /** false switches adding off (as while the graph is read-only); true by default. */
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 zoom on double-click
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;
@@ -10,6 +10,7 @@ export type FollowFitOptions<NodeType extends Node = Node> = {
10
10
  /** The props `useFollowFit` gives `<ReactFlow>`. */
11
11
  export type FollowFitFlowProps = {
12
12
  onMoveStart: OnMove;
13
+ onMove: OnMove;
13
14
  onMoveEnd: OnMove;
14
15
  };
15
16
  export type FollowFit = {
@@ -1,6 +1,10 @@
1
1
  import { type ReactNode } from "react";
2
2
  import "./Sheet.css";
3
- export type SheetSide = "right" | "bottom";
3
+ /**
4
+ * The edge the sheet is drawn from, in the text's direction: end is its container's inline end (the right, or the left
5
+ * in right-to-left text), start the inline start, bottom the bottom.
6
+ */
7
+ export type SheetSide = "start" | "end" | "bottom";
4
8
  /** The sheet's own words, each replaceable. */
5
9
  export interface SheetLabels {
6
10
  /** The close button's name: "Close". */
@@ -12,14 +16,16 @@ export type SheetProps = {
12
16
  open: boolean;
13
17
  /** Asked for on Escape inside the sheet and on its close button. */
14
18
  onClose: () => void;
15
- /** The edge it is drawn from: the right edge (the default) or the bottom. */
19
+ /** The edge it is drawn from: the inline end (the default), the inline start or the bottom. */
16
20
  side?: SheetSide;
17
21
  /** The sheet's title, which also names it for screen readers; without one, name it with `label`. */
18
22
  title?: ReactNode;
19
23
  /** The sheet's name for screen readers when it has no title. */
20
24
  label?: string;
25
+ /** Slot in the header row, at its far end before the close button: buttons, a count. */
26
+ actions?: ReactNode;
21
27
  children: ReactNode;
22
- /** A right sheet's width in px, held to 280–560 px and to 48 px short of its container. */
28
+ /** An inline sheet's width in px, held to 280–560 px and to 48 px short of its container. */
23
29
  width?: number;
24
30
  /** Words to replace; the rest keep their defaults. */
25
31
  labels?: Partial<SheetLabels>;
@@ -15,7 +15,15 @@ export type AppShellTopBar = {
15
15
  end?: ReactNode;
16
16
  };
17
17
  export type AppShellInspector = {
18
- /** What the inspector shows: usually a Panel, which scrolls on its own. */
18
+ /**
19
+ * The inspector's heading (the selection's name). With it, or with `actions`, the shell draws the inspector's one
20
+ * header row itself: a Panel's on a wide window, the sheet's own beside its close button on a narrow one, and
21
+ * `content` is the body under it. Without either, `content` is drawn as given (usually a Panel).
22
+ */
23
+ title?: ReactNode;
24
+ /** Slot at the far end of the inspector's header row (buttons, a count), before the sheet's close button. */
25
+ actions?: ReactNode;
26
+ /** What the inspector shows: its body under `title` and `actions`, or without them usually a Panel. */
19
27
  content: ReactNode;
20
28
  /** Whether it is shown; the app holds it. */
21
29
  open: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcurcio/patchbay",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "A React component library for graph-based editors and live dashboards: design tokens and themes, primitives, and React Flow graph components",
5
5
  "keywords": [
6
6
  "react",