@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.
Files changed (51) hide show
  1. package/README.md +11 -2
  2. package/dist/composites.css +1 -1
  3. package/dist/composites.js +399 -254
  4. package/dist/composites.js.map +1 -1
  5. package/dist/graph.css +1 -1
  6. package/dist/graph.js +593 -286
  7. package/dist/graph.js.map +1 -1
  8. package/dist/hooks.js.map +1 -1
  9. package/dist/primitives.css +1 -1
  10. package/dist/primitives.js +143 -126
  11. package/dist/primitives.js.map +1 -1
  12. package/dist/shell.css +1 -1
  13. package/dist/shell.js +96 -71
  14. package/dist/shell.js.map +1 -1
  15. package/dist/types/composites/banner/Banner.d.ts +2 -2
  16. package/dist/types/composites/change-list/ChangeList.d.ts +44 -0
  17. package/dist/types/composites/change-list/index.d.ts +2 -0
  18. package/dist/types/composites/diagnostic-list/DiagnosticList.d.ts +23 -0
  19. package/dist/types/composites/diagnostic-list/index.d.ts +2 -0
  20. package/dist/types/composites/index.d.ts +2 -0
  21. package/dist/types/composites/status-words/StatusWords.d.ts +1 -1
  22. package/dist/types/graph/add-at/useAddAt.d.ts +11 -5
  23. package/dist/types/graph/canvas-tools/CanvasTools.d.ts +7 -2
  24. package/dist/types/graph/connect-hints/connectTargets.d.ts +22 -0
  25. package/dist/types/graph/connect-hints/index.d.ts +3 -1
  26. package/dist/types/graph/connect-hints/useConnectHints.d.ts +9 -0
  27. package/dist/types/graph/connect-status/ConnectStatus.d.ts +30 -0
  28. package/dist/types/graph/connect-status/index.d.ts +2 -0
  29. package/dist/types/graph/context-at/index.d.ts +2 -0
  30. package/dist/types/graph/context-at/useContextAt.d.ts +43 -0
  31. package/dist/types/graph/empty-canvas-hint/EmptyCanvasHint.d.ts +33 -0
  32. package/dist/types/graph/empty-canvas-hint/index.d.ts +2 -0
  33. package/dist/types/graph/follow-fit/useFollowFit.d.ts +1 -0
  34. package/dist/types/graph/ghost-node/GhostNode.d.ts +32 -0
  35. package/dist/types/graph/ghost-node/index.d.ts +2 -0
  36. package/dist/types/graph/ghost-wire/GhostWire.d.ts +1 -1
  37. package/dist/types/graph/index.d.ts +4 -0
  38. package/dist/types/graph/meter/Meter.d.ts +8 -1
  39. package/dist/types/graph/meter/index.d.ts +1 -1
  40. package/dist/types/graph/wire/Wire.d.ts +4 -4
  41. package/dist/types/hooks/use-toasts/toastQueue.d.ts +1 -1
  42. package/dist/types/primitives/glyph/Glyph.d.ts +14 -0
  43. package/dist/types/primitives/glyph/index.d.ts +2 -0
  44. package/dist/types/primitives/icon-button/index.d.ts +1 -0
  45. package/dist/types/primitives/index.d.ts +1 -0
  46. package/dist/types/primitives/key-value/KeyValue.d.ts +3 -3
  47. package/dist/types/primitives/sheet/Sheet.d.ts +9 -3
  48. package/dist/types/primitives/spinner/Spinner.d.ts +1 -1
  49. package/dist/types/shell/app-shell/AppShell.d.ts +9 -1
  50. package/package.json +1 -1
  51. /package/dist/types/primitives/{dialog → icon-button}/CloseGlyph.d.ts +0 -0
@@ -0,0 +1,43 @@
1
+ import { type Node, type NodeMouseHandler } from "@xyflow/react";
2
+ import { type MouseEvent as ReactMouseEvent, type PointerEvent as ReactPointerEvent } from "react";
3
+ import type { FlowPoint } from "../add-at";
4
+ /** How long a touch is held still to count as a long-press, in ms. */
5
+ export declare const LONG_PRESS_MS = 500;
6
+ /** How far, in px, a held touch may move and still count: one that moves further is a pan or a drag. */
7
+ export declare const LONG_PRESS_SLOP = 10;
8
+ /** Where a context menu was asked for, and on what. */
9
+ export type ContextAt = {
10
+ /** The point in flow coordinates, as `useAddAt` gives it. */
11
+ point: FlowPoint;
12
+ /** The same point in the window's coordinates, as `CommandPalette`'s `at` takes it. */
13
+ at: {
14
+ x: number;
15
+ y: number;
16
+ };
17
+ /** The node pressed, as React Flow holds it; absent on empty canvas. */
18
+ node?: Node;
19
+ /** How it was asked: a right-click, or a long-press on touch. */
20
+ by: "contextmenu" | "long-press";
21
+ };
22
+ /** Called with where a context menu was asked for. */
23
+ export type OnContextAt = (context: ContextAt) => void;
24
+ /** The props `useContextAt` gives `<ReactFlow>`. */
25
+ export type ContextAtFlowProps = {
26
+ onPaneContextMenu: (event: ReactMouseEvent | MouseEvent) => void;
27
+ onNodeContextMenu: NodeMouseHandler;
28
+ onPointerDown: (event: ReactPointerEvent<HTMLDivElement>) => void;
29
+ onPointerMove: (event: ReactPointerEvent<HTMLDivElement>) => void;
30
+ onPointerUp: (event: ReactPointerEvent<HTMLDivElement>) => void;
31
+ onPointerCancel: (event: ReactPointerEvent<HTMLDivElement>) => void;
32
+ };
33
+ export type ContextAtOptions = {
34
+ /** false switches it off: a right-click is the browser's again, and a long-press nothing; true by default. */
35
+ enabled?: boolean;
36
+ };
37
+ /**
38
+ * Calls `onContextAt` for a right-click and for a long-press on touch, on a node or on empty canvas; its `flowProps`
39
+ * go to `<ReactFlow>` (through `mergeFlowProps` with others). The browser's own menu is prevented where it asks.
40
+ */
41
+ export declare function useContextAt(onContextAt: OnContextAt, options?: ContextAtOptions): {
42
+ flowProps: ContextAtFlowProps;
43
+ };
@@ -0,0 +1,33 @@
1
+ import { type PanelPosition } from "@xyflow/react";
2
+ import type { ReactNode } from "react";
3
+ import { type Platform } from "../../hooks";
4
+ import "./EmptyCanvasHint.css";
5
+ /** The hint's own words, each replaceable. */
6
+ export interface EmptyCanvasHintLabels {
7
+ /**
8
+ * The add gestures: "Double-click to add a node" with a pointer, "Double-tap to add a node" on a touch screen, then
9
+ * ", or press A" with the app's add key as people read it.
10
+ */
11
+ add: (gesture: "pointer" | "touch", keys: string | undefined) => string;
12
+ }
13
+ export declare const defaultEmptyCanvasHintLabels: EmptyCanvasHintLabels;
14
+ export type EmptyCanvasHintProps = {
15
+ /** The app's own words above the gestures ("This graph has no nodes yet"); none by default. */
16
+ children?: ReactNode;
17
+ /** Whether the graph is empty; without it, while React Flow holds no nodes. An app drawing a ghost node passes it. */
18
+ empty?: boolean;
19
+ /** Whether adding is on, so the gestures are said (`useAddAt`'s `enabled`); true by default. */
20
+ add?: boolean;
21
+ /** The app's add key (a key string, `"A"`), drawn through `keyLabel` after the gestures; the hint binds nothing. */
22
+ keys?: string;
23
+ /** The platform the key is written for; the browser's by default. */
24
+ platform?: Platform;
25
+ /** Where it sits on the canvas, React Flow's `PanelPosition`: "top-center" by default. */
26
+ position?: PanelPosition | (string & {});
27
+ /** Words to replace; the rest keep their defaults. */
28
+ labels?: Partial<EmptyCanvasHintLabels>;
29
+ /** Added to the panel's own `pb-empty-canvas` class. */
30
+ className?: string;
31
+ };
32
+ /** Says, on an empty canvas, what to do; draws nothing once the graph has a node. */
33
+ export declare function EmptyCanvasHint({ children, empty, add, keys, platform, position, labels, className, }: EmptyCanvasHintProps): import("react").JSX.Element | null;
@@ -0,0 +1,2 @@
1
+ export { defaultEmptyCanvasHintLabels, EmptyCanvasHint } from "./EmptyCanvasHint";
2
+ export type { EmptyCanvasHintLabels, EmptyCanvasHintProps } from "./EmptyCanvasHint";
@@ -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 = {
@@ -0,0 +1,32 @@
1
+ import type { Node, NodeProps } from "@xyflow/react";
2
+ import type { ReactNode } from "react";
3
+ import { type NodePorts } from "../node-box";
4
+ import "./GhostNode.css";
5
+ /** A ghost node's look, as React Flow's node `data`: the words and the shape of the node being added. */
6
+ export type GhostNodeData = {
7
+ /** The node's name, as it will be (`type 2`); one line, cut with an ellipsis. */
8
+ title: ReactNode;
9
+ /** The second header line in the muted colour (its type). */
10
+ subtitle?: ReactNode;
11
+ /** One row under the header ("Adding"); none by default. */
12
+ line?: ReactNode;
13
+ /** The input ports the node will have, so the ghost takes its room; none by default. */
14
+ inputs?: number;
15
+ /** The output ports the node will have; none by default. */
16
+ outputs?: number;
17
+ /** How its ports will be laid out; stacked by default. */
18
+ ports?: NodePorts;
19
+ /** Whether it will have a footer; no by default. */
20
+ footer?: boolean;
21
+ /** Its width in px; `NODE_WIDTH` by default. */
22
+ width?: number;
23
+ };
24
+ /** A node drawn by `GhostNode`: register it as `nodeTypes={{ ghost: GhostNode }}`. */
25
+ export type GhostNodeNode = Node<GhostNodeData, "ghost">;
26
+ /** The ghost's size in px: `nodeBoxSize` of the node it stands for, its `line` counting as the node's line row. */
27
+ export declare function ghostNodeSize(data: GhostNodeData): {
28
+ width: number;
29
+ height: number;
30
+ };
31
+ /** Draws an add's node at its point while the request is on its way. */
32
+ export declare function GhostNode({ data }: NodeProps<GhostNodeNode>): import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export { GhostNode, ghostNodeSize } from "./GhostNode";
2
+ export type { GhostNodeData, GhostNodeNode } from "./GhostNode";
@@ -1,7 +1,7 @@
1
1
  import { type Edge, type EdgeProps } from "@xyflow/react";
2
2
  import { type ReactNode } from "react";
3
3
  import "./GhostWire.css";
4
- /** `pending` (the default) or `refused`; any other string is drawn as `pending`. */
4
+ /** `pending` (the default) or `refused`; any other string is drawn in the muted stroke, dashed and dimmed. */
5
5
  export type GhostWireTone = "pending" | "refused" | (string & {});
6
6
  /** A ghost wire's look, as React Flow's edge `data`. */
7
7
  export type GhostWireData = {
@@ -1,7 +1,11 @@
1
1
  export * from "./add-at";
2
2
  export * from "./canvas-tools";
3
3
  export * from "./connect-hints";
4
+ export * from "./connect-status";
5
+ export * from "./context-at";
6
+ export * from "./empty-canvas-hint";
4
7
  export * from "./follow-fit";
8
+ export * from "./ghost-node";
5
9
  export * from "./ghost-wire";
6
10
  export * from "./meter";
7
11
  export * from "./node-box";
@@ -29,7 +29,7 @@ export type MeterProps = Omit<ComponentPropsWithoutRef<"div">, "children" | "tit
29
29
  clipAt?: number;
30
30
  /** How long the lamp stays lit after the last such peak, in ms. 2000 by default. */
31
31
  clipHoldMs?: number;
32
- /** The accessible name ("Level" by default); the numbers are never announced. */
32
+ /** The accessible name: what the meter measures ("Left output"). Without it, `labels.name`; the numbers are never announced. */
33
33
  label?: string;
34
34
  /** Words to replace; the rest keep their defaults. */
35
35
  labels?: Partial<MeterLabels>;
@@ -51,10 +51,17 @@ export declare const meterTitleEveryMs = 250;
51
51
  export declare function toDb(linear: number): number;
52
52
  /** Where a level in dBFS sits on a bar from `floor` (0) to 0 dBFS (1), clamped. */
53
53
  export declare function meterFraction(db: number, floor: number): number;
54
+ /**
55
+ * A level in dBFS as the tooltip writes it: one decimal ("-12.0"), and "−∞" for silence. An app writing a meter's
56
+ * numbers in words (the inspector) uses it, with `toDb`, so they read as the tooltip's.
57
+ */
58
+ export declare function formatMeterDb(db: number): string;
54
59
  /** The English tooltip: "peak -12.0 dB, rms -18.3 dB", with −∞ for silence. */
55
60
  export declare const defaultMeterTitle: MeterTitle;
56
61
  /** The meter's own words, each replaceable. */
57
62
  export interface MeterLabels {
63
+ /** The accessible name when the app gives no `label`: "Level". */
64
+ name: string;
58
65
  /** Writes the tooltip from the level: `defaultMeterTitle`, "peak -12.0 dB, rms -18.3 dB". */
59
66
  title: MeterTitle;
60
67
  }
@@ -1,2 +1,2 @@
1
- export { defaultMeterLabels, defaultMeterScale, defaultMeterTitle, Meter, meterFraction, meterTitleEveryMs, toDb, } from "./Meter";
1
+ export { defaultMeterLabels, defaultMeterScale, defaultMeterTitle, formatMeterDb, Meter, meterFraction, meterTitleEveryMs, toDb, } from "./Meter";
2
2
  export type { MeterHandle, MeterLabels, MeterOrientation, MeterProps, MeterTitle } from "./Meter";
@@ -2,15 +2,15 @@ import { type Edge, type EdgeProps } from "@xyflow/react";
2
2
  import { type ReactNode } from "react";
3
3
  import type { PillTone } from "../../primitives";
4
4
  import "./Wire.css";
5
- /** Pill's tones, the changes, `pending` and `refused`; any other string is drawn in the edge stroke. */
6
- export type WireTone = PillTone | "added" | "removed" | "changed" | "pending" | "refused" | (string & {});
5
+ /** Pill's tones, the changes and `refused`; any other string is drawn in the muted stroke. */
6
+ export type WireTone = PillTone | "added" | "removed" | "renamed" | "changed" | "refused" | (string & {});
7
7
  /** A wire's look, as React Flow's edge `data`. */
8
8
  export type WireData = {
9
- /** The stroke's tone; none, or one it does not know, is React Flow's edge stroke. */
9
+ /** The stroke's tone; none is React Flow's edge stroke, and one it does not know the muted one. */
10
10
  tone?: WireTone;
11
11
  /** The signal's level, 0 to 1 (clamped; not a number is 0): thickness and brightness. None is the plain wire. */
12
12
  emphasis?: number;
13
- /** Dashes: an edit not yet saved. */
13
+ /** Dashes. A change tone is always dashed, whatever this says. */
14
14
  dashed?: boolean;
15
15
  /** Dots moving along the wire toward the input; not drawn under reduced motion. */
16
16
  flow?: boolean;
@@ -1,6 +1,6 @@
1
1
  import type { ReactNode } from "react";
2
2
  /** The tones a toast is drawn in; any other string is drawn neutrally. An `err` toast is an alert, the rest status. */
3
- export type ToastTone = "ok" | "warn" | "err" | "quiet" | "off" | (string & {});
3
+ export type ToastTone = "ok" | "warn" | "err" | "quiet" | "off" | "accent" | "muted" | (string & {});
4
4
  /** A button on a toast that acts on its news. Pressing it runs `run`, then dismisses the toast. */
5
5
  export type ToastAction = {
6
6
  /** The button's words. */
@@ -0,0 +1,14 @@
1
+ import type { ComponentPropsWithRef, ReactNode } from "react";
2
+ import "./Glyph.css";
3
+ /** The glyph's box, in px: its width, its height and its viewBox's size. */
4
+ export declare const GLYPH_BOX = 16;
5
+ /** The part of the box a glyph's lines are drawn in, in px, centred: from 2 to 14 in the viewBox. */
6
+ export declare const GLYPH_DRAWN = 12;
7
+ /** The stroke every glyph is drawn at, in the box's units. */
8
+ export declare const GLYPH_STROKE = 1.75;
9
+ export type GlyphProps = Omit<ComponentPropsWithRef<"svg">, "viewBox" | "width" | "height"> & {
10
+ /** The glyph's shapes (paths, circles) in a 16 by 16 viewBox, within 2 to 14; stroked unless a shape says otherwise. */
11
+ children: ReactNode;
12
+ };
13
+ /** Draws a glyph on the one grid: a 16 px SVG box, stroked at 1.75 with round caps in the current colour. */
14
+ export declare function Glyph({ children, className, ...rest }: GlyphProps): import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export { Glyph, GLYPH_BOX, GLYPH_DRAWN, GLYPH_STROKE } from "./Glyph";
2
+ export type { GlyphProps } from "./Glyph";
@@ -1,2 +1,3 @@
1
+ export { CloseGlyph } from "./CloseGlyph";
1
2
  export { IconButton } from "./IconButton";
2
3
  export type { IconButtonProps } from "./IconButton";
@@ -3,6 +3,7 @@ export * from "./button";
3
3
  export * from "./checkbox";
4
4
  export * from "./dialog";
5
5
  export * from "./field";
6
+ export * from "./glyph";
6
7
  export * from "./icon-button";
7
8
  export * from "./key-value";
8
9
  export * from "./panel";
@@ -1,13 +1,13 @@
1
1
  import type { ReactNode } from "react";
2
2
  import "./KeyValue.css";
3
- /** The tones a value draws in; any other string leaves it plain. */
4
- export type KeyValueTone = "ok" | "warn" | "err" | "quiet" | "off" | (string & {});
3
+ /** The tones a value draws in; any other string draws it muted. */
4
+ export type KeyValueTone = "ok" | "warn" | "err" | "quiet" | "off" | "accent" | "muted" | (string & {});
5
5
  export type KeyValueRow = {
6
6
  /** The fact's name. */
7
7
  key: string;
8
8
  /** Its value. */
9
9
  value: ReactNode;
10
- /** Colours the value: a fact that is wrong or worth a look. */
10
+ /** Colours the value and adds a dot before it: a fact that is wrong or worth a look. */
11
11
  tone?: KeyValueTone;
12
12
  /** Shown on hover over the key: what the fact means. */
13
13
  title?: string;
@@ -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>;
@@ -1,4 +1,4 @@
1
- import type { ComponentPropsWithRef } from "react";
1
+ import { type ComponentPropsWithRef } from "react";
2
2
  import "./Spinner.css";
3
3
  export type SpinnerProps = Omit<ComponentPropsWithRef<"span">, "children"> & {
4
4
  /** What is being waited for, read by screen readers; without it the spinner is hidden from them. */
@@ -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.10.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",