@miadi/stateloom-canvas 0.1.2 → 0.1.4

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 CHANGED
@@ -1,6 +1,8 @@
1
1
  # @miadi/stateloom-canvas
2
2
 
3
- The SMDF design surface, as a component anyone can mount.
3
+ The stateloom design surfaces, as components anyone can mount: `<StateMachineCanvas>` for
4
+ a `.smdf.json` state machine and `<EntityRelationshipCanvas>` for a `.erdf.json`
5
+ entity-relationship diagram.
4
6
 
5
7
  This is the stateloom designer's board with its store taken out: pan, zoom,
6
8
  drill into composites, drag boxes, routed edges, settled event labels, touch
@@ -37,6 +39,35 @@ export function Board({ definition }) {
37
39
  }
38
40
  ```
39
41
 
42
+ ## `<EntityRelationshipCanvas>`
43
+
44
+ The ERD sibling, with the same contract — props in, callbacks out, the host owns the
45
+ definition, the positions and the viewport — the same gestures, and the same `--slc-*` theme.
46
+
47
+ ```tsx
48
+ import { EntityRelationshipCanvas, erdAutoLayout, IDENTITY_VIEWPORT } from "@miadi/stateloom-canvas";
49
+
50
+ const [notation, setNotation] = useState<"crowsfoot" | "chen">("crowsfoot");
51
+ const positions = useMemo(() => erdAutoLayout(definition, { notation }), [definition, notation]);
52
+
53
+ <EntityRelationshipCanvas
54
+ definition={definition}
55
+ notation={notation}
56
+ positions={positions}
57
+ viewport={viewport}
58
+ onViewportChange={setViewport}
59
+ readOnly={locked} // a drag on a shape pans instead of moving it; a tap still selects
60
+ onEntityMove={(name, box) => …}
61
+ onOpenMachine={(machine) => …} // an attribute with `stateOf` was activated
62
+ />
63
+ ```
64
+
65
+ `notation` chooses the drawing, never the data: **crow's foot** lists attributes as rows in
66
+ the entity box with `PK` / `UK` / `FK` badges; **Chen** draws a rectangle (double when
67
+ `weak`), an oval per attribute with the primary key underlined, a diamond per relationship
68
+ and `1` / `N` / `M` beside the line. A shape that carries `notes` shows a small tab on its
69
+ top edge, in both canvases.
70
+
40
71
  ## Navigation
41
72
 
42
73
  | Gesture | What it does |
@@ -16,9 +16,16 @@
16
16
  * Relationship lines reuse the state canvas's edge router, so several lines on
17
17
  * one box face each get a port of their own. Each end carries its cardinality
18
18
  * mark: a bar for "one", a crow's foot for "many".
19
+ *
20
+ * `notation` chooses the drawing, never the data. "crowsfoot" (the default) is
21
+ * the above. "chen" draws the same definition the way Chen did: the entity is a
22
+ * rectangle (double when `weak`), each attribute an oval beside it with the
23
+ * primary key underlined, each relationship a diamond carrying its verb, and
24
+ * the cardinality written as 1 / N / M beside the line. An oval shows the name
25
+ * only; its tooltip carries everything else the document says about it.
19
26
  */
20
27
  import { type CSSProperties, type ReactNode } from "react";
21
- import { type EntityRelationshipDefinition, type LayoutBox, type Viewport } from "@miadi/stateloom-protocol";
28
+ import { type EntityRelationshipDefinition, type ErdNotation, type LayoutBox, type Viewport } from "@miadi/stateloom-protocol";
22
29
  import { type CanvasTheme } from "./theme.js";
23
30
  export interface ErdCanvasTarget {
24
31
  kind: "entity" | "canvas";
@@ -26,6 +33,8 @@ export interface ErdCanvasTarget {
26
33
  }
27
34
  export interface EntityRelationshipCanvasProps {
28
35
  definition: EntityRelationshipDefinition;
36
+ /** How to draw it. The host lays `positions` out for the same notation (`erdAutoLayout(def, { notation })`). */
37
+ notation?: ErdNotation;
29
38
  /** Entity name → box. The host owns these; `erdAutoLayout` seeds them. */
30
39
  positions: Record<string, LayoutBox>;
31
40
  viewport: Viewport;
@@ -49,5 +58,5 @@ export interface EntityRelationshipCanvasProps {
49
58
  style?: CSSProperties;
50
59
  svgId?: string;
51
60
  }
52
- export declare function EntityRelationshipCanvas({ definition, positions, viewport, onViewportChange, selection, errorElements, readOnly, fitKey, onSelect, onClearSelection, onEntityMove, onOpenMachine, onContextMenu, emptyHint, theme, className, style, svgId, }: EntityRelationshipCanvasProps): import("react").JSX.Element;
61
+ export declare function EntityRelationshipCanvas({ definition, notation, positions, viewport, onViewportChange, selection, errorElements, readOnly, fitKey, onSelect, onClearSelection, onEntityMove, onOpenMachine, onContextMenu, emptyHint, theme, className, style, svgId, }: EntityRelationshipCanvasProps): import("react").JSX.Element;
53
62
  export default EntityRelationshipCanvas;
@@ -17,9 +17,16 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
17
  * Relationship lines reuse the state canvas's edge router, so several lines on
18
18
  * one box face each get a port of their own. Each end carries its cardinality
19
19
  * mark: a bar for "one", a crow's foot for "many".
20
+ *
21
+ * `notation` chooses the drawing, never the data. "crowsfoot" (the default) is
22
+ * the above. "chen" draws the same definition the way Chen did: the entity is a
23
+ * rectangle (double when `weak`), each attribute an oval beside it with the
24
+ * primary key underlined, each relationship a diamond carrying its verb, and
25
+ * the cardinality written as 1 / N / M beside the line. An oval shows the name
26
+ * only; its tooltip carries everything else the document says about it.
20
27
  */
21
28
  import { useCallback, useEffect, useMemo, useRef, } from "react";
22
- import { ERD_BOX, erdRowText, fitToBoxes, panBy, placeLabels, routeEdges, screenDeltaToWorld, stateOfList, viewportTransform, zoomAt, } from "@miadi/stateloom-protocol";
29
+ import { CHEN, ERD_BOX, chenCardinalityText, chenDiamondHalfWidth, erdChenGeometry, erdRowText, fitToBoxes, panBy, placeLabels, routeEdges, screenDeltaToWorld, stateOfList, viewportTransform, zoomAt, } from "@miadi/stateloom-protocol";
23
30
  import { themeStyle } from "./theme.js";
24
31
  const WHEEL_LINE_HEIGHT = 16;
25
32
  const WHEEL_PAGE_HEIGHT = 400;
@@ -57,8 +64,36 @@ function endMark(tip, toward, kind) {
57
64
  return `M ${at(9, 6)} L ${at(9, -6)}`;
58
65
  return `M ${at(13, 0)} L ${at(0, 7)} M ${at(13, 0)} L ${at(0, -7)} M ${at(13, 0)} L ${at(0, 0)}`;
59
66
  }
67
+ /** Everything the document says about an attribute, for a tooltip — what a Chen oval does not have room to show. */
68
+ function attributeTitle(attr) {
69
+ const machines = stateOfList(attr);
70
+ return [
71
+ `${erdRowText(attr)}${attr.nullable ? " ?" : ""}`,
72
+ attr.key === "pk" ? "primary key" : attr.key === "uk" ? "unique" : "",
73
+ attr.references ? `references ${attr.references}` : "",
74
+ machines.length ? `stores the state of ${machines.join(", ")}` : "",
75
+ attr.description ?? "",
76
+ ]
77
+ .filter(Boolean)
78
+ .join(" — ");
79
+ }
80
+ /** What hovering an entity says: what it is, then what was said about it. */
81
+ function entityTitle(entity) {
82
+ return [entity.description ?? "", entity.notes?.trim() ? `Notes: ${entity.notes}` : ""].filter(Boolean).join("\n\n");
83
+ }
84
+ /**
85
+ * Chen only: the short segment from where a routed line ends (on the corridor
86
+ * above or below the rectangle) to the rectangle's own edge.
87
+ */
88
+ function stubTo(rect, end) {
89
+ if (!rect)
90
+ return "";
91
+ const x = Math.min(rect.x + rect.width, Math.max(rect.x, end.x));
92
+ const y = Math.min(rect.y + rect.height, Math.max(rect.y, end.y));
93
+ return x === end.x && y === end.y ? "" : `M ${end.x} ${end.y} L ${x} ${y}`;
94
+ }
60
95
  const keyBadges = (attr) => [attr.key === "pk" ? "PK" : attr.key === "uk" ? "UK" : "", attr.references ? "FK" : ""].filter(Boolean).join(" ");
61
- export function EntityRelationshipCanvas({ definition, positions, viewport, onViewportChange, selection = null, errorElements, readOnly = false, fitKey, onSelect, onClearSelection, onEntityMove, onOpenMachine, onContextMenu, emptyHint, theme, className, style, svgId, }) {
96
+ export function EntityRelationshipCanvas({ definition, notation = "crowsfoot", positions, viewport, onViewportChange, selection = null, errorElements, readOnly = false, fitKey, onSelect, onClearSelection, onEntityMove, onOpenMachine, onContextMenu, emptyHint, theme, className, style, svgId, }) {
62
97
  const svgRef = useRef(null);
63
98
  const viewportRef = useRef(viewport);
64
99
  viewportRef.current = viewport;
@@ -74,22 +109,31 @@ export function EntityRelationshipCanvas({ definition, positions, viewport, onVi
74
109
  return true;
75
110
  });
76
111
  }, [definition.entities, positions]);
112
+ const chen = notation === "chen";
113
+ const geometry = useMemo(() => new Map(chen ? entities.map((e) => [e.name, erdChenGeometry(e, positions[e.name])]) : []), [chen, entities, positions]);
77
114
  // Routed by index, not by name: the router keys its faces on a space-joined
78
115
  // string, and an entity may be called "Order Line".
79
116
  const edges = useMemo(() => {
80
117
  const indexOf = new Map(entities.map((e, i) => [e.name, `e${i}`]));
81
118
  const drawn = (definition.relationships ?? []).filter((r) => r && indexOf.has(r.from) && indexOf.has(r.to));
82
- const curves = routeEdges(drawn.map((r) => ({ from: indexOf.get(r.from), to: indexOf.get(r.to) })), (id) => positions[entities[Number(id.slice(1))].name]);
119
+ const curves = routeEdges(drawn.map((r) => ({ from: indexOf.get(r.from), to: indexOf.get(r.to) })),
120
+ // In Chen a line attaches to the corridor above and below the rectangle,
121
+ // so it starts clear of the attribute ovals standing at its sides.
122
+ (id) => {
123
+ const name = entities[Number(id.slice(1))].name;
124
+ return geometry.get(name)?.routingBox ?? positions[name];
125
+ });
83
126
  return drawn.map((rel, i) => ({ rel, curve: curves[i] }));
84
- }, [definition.relationships, entities, positions]);
127
+ }, [definition.relationships, entities, positions, geometry]);
85
128
  // The state canvas's chip placer: each label tries spots along its own line
86
129
  // until it is clear of every box and of the labels already down.
87
130
  const labels = useMemo(() => {
88
131
  const pending = edges
89
- .filter(({ rel }) => rel.label)
90
- .map(({ rel, curve }) => ({ event: rel.label, at: curve.at }));
132
+ // Chen gives every relationship its diamond, named or not; a crow's foot line only carries a chip when it has a verb.
133
+ .filter(({ rel }) => chen || rel.label)
134
+ .map(({ rel, curve }) => ({ event: rel.label || " ", at: curve.at, rel }));
91
135
  return placeLabels(pending, entities.map((e) => positions[e.name]));
92
- }, [edges, entities, positions]);
136
+ }, [chen, edges, entities, positions]);
93
137
  const toCanvasPoint = useCallback((clientX, clientY) => {
94
138
  const rect = svgRef.current?.getBoundingClientRect();
95
139
  return { x: clientX - (rect?.left ?? 0), y: clientY - (rect?.top ?? 0) };
@@ -217,6 +261,12 @@ export function EntityRelationshipCanvas({ definition, positions, viewport, onVi
217
261
  e.preventDefault();
218
262
  onContextMenu(e.clientX, e.clientY, { kind: "canvas" });
219
263
  }, children: _jsxs("g", { transform: viewportTransform(viewport), children: [edges.map(({ rel, curve }, i) => {
264
+ if (chen) {
265
+ const [fromText, toText] = chenCardinalityText(rel.cardinality);
266
+ const a = curve.at(0.12);
267
+ const b = curve.at(0.88);
268
+ return (_jsxs("g", { className: "slc-erd-rel", children: [_jsx("path", { d: stubTo(geometry.get(rel.from)?.rect, curve.p0), className: "slc-erd-line" }), _jsx("path", { d: stubTo(geometry.get(rel.to)?.rect, curve.p3), className: "slc-erd-line" }), _jsx("path", { d: curve.path, className: "slc-erd-line" }), _jsx("text", { x: a.x + 9, y: a.y + 4, className: "slc-erd-card", children: fromText }), _jsx("text", { x: b.x + 9, y: b.y + 4, className: "slc-erd-card", children: toText })] }, `r${i}`));
269
+ }
220
270
  const [fromEnd, toEnd] = ENDS[rel.cardinality] ?? ENDS["1:N"];
221
271
  return (_jsxs("g", { className: "slc-erd-rel", children: [_jsx("path", { d: curve.path, className: "slc-erd-line" }), _jsx("path", { d: endMark(curve.p0, curve.p1, fromEnd), className: "slc-erd-mark" }), _jsx("path", { d: endMark(curve.p3, curve.p2, toEnd), className: "slc-erd-mark" })] }, `r${i}`));
222
272
  }), entities.map((entity) => {
@@ -230,13 +280,30 @@ export function EntityRelationshipCanvas({ definition, positions, viewport, onVi
230
280
  ]
231
281
  .filter(Boolean)
232
282
  .join(" ");
283
+ const shape = geometry.get(entity.name);
284
+ if (shape) {
285
+ const { rect, ovals } = shape;
286
+ return (_jsxs("g", { className: readOnly ? "slc-node--static" : "slc-node--draggable", onPointerDown: (e) => onPointerDown(e, entity.name), onContextMenu: (e) => {
287
+ if (!onContextMenu)
288
+ return;
289
+ e.preventDefault();
290
+ e.stopPropagation();
291
+ onContextMenu(e.clientX, e.clientY, { kind: "entity", id: entity.name });
292
+ }, children: [ovals.map((o) => (_jsx("path", { d: `M ${o.from.x} ${o.from.y} L ${o.to.x} ${o.to.y}`, className: "slc-erd-attr-line" }, `l-${o.attribute.name}`))), ovals.map((o) => {
293
+ const machines = stateOfList(o.attribute);
294
+ const opens = machines.length > 0 && !!onOpenMachine;
295
+ return (_jsxs("g", { className: opens ? "slc-erd-state" : undefined, onPointerDown: opens ? (e) => e.stopPropagation() : undefined, onClick: opens ? () => onOpenMachine(machines[0]) : undefined, children: [_jsx("title", { children: attributeTitle(o.attribute) }), _jsx("ellipse", { cx: o.cx, cy: o.cy, rx: o.rx, ry: o.ry, className: "slc-erd-oval" }), _jsxs("text", { x: o.cx, y: o.cy + 4, textAnchor: "middle", className: `slc-erd-oval-text${o.attribute.key === "pk" ? " slc-erd-oval-text--pk" : ""}${machines.length ? " slc-erd-row--state" : ""}`, children: [machines.length ? "◉ " : "", o.attribute.name] })] }, o.attribute.name));
296
+ }), entityTitle(entity) && _jsx("title", { children: entityTitle(entity) }), _jsx("rect", { x: rect.x, y: rect.y, width: rect.width, height: rect.height, rx: 2, className: boxClass }), entity.notes?.trim() && (_jsx("rect", { x: rect.x + rect.width - 24, y: rect.y - 5, width: 13, height: 5, rx: 1.5, className: "slc-note-mark" })), entity.weak && (_jsx("rect", { x: rect.x + 4, y: rect.y + 4, width: rect.width - 8, height: rect.height - 8, rx: 1, className: "slc-erd-weak" })), _jsx("text", { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 + 5, textAnchor: "middle", className: "slc-node-name", children: entity.name })] }, entity.name));
297
+ }
233
298
  return (_jsxs("g", { className: readOnly ? "slc-node--static" : "slc-node--draggable", onPointerDown: (e) => onPointerDown(e, entity.name), onContextMenu: (e) => {
234
299
  if (!onContextMenu)
235
300
  return;
236
301
  e.preventDefault();
237
302
  e.stopPropagation();
238
303
  onContextMenu(e.clientX, e.clientY, { kind: "entity", id: entity.name });
239
- }, children: [entity.description && _jsx("title", { children: entity.description }), _jsx("rect", { x: box.x, y: box.y, width: box.width, height: box.height, rx: 6, className: boxClass }), _jsx("path", { d: `M ${box.x} ${box.y + ERD_BOX.headerHeight} h ${box.width}`, className: "slc-erd-rule" }), _jsx("text", { x: box.x + box.width / 2, y: box.y + ERD_BOX.headerHeight / 2 + 5, textAnchor: "middle", className: "slc-node-name", children: entity.name }), rows.length === 0 && (_jsx("text", { x: box.x + ERD_BOX.padX, y: box.y + ERD_BOX.headerHeight + 15, className: "slc-erd-row slc-erd-row--empty", children: "no attributes" })), rows.map((attr, r) => {
304
+ }, children: [entityTitle(entity) && _jsx("title", { children: entityTitle(entity) }), _jsx("rect", { x: box.x, y: box.y, width: box.width, height: box.height, rx: 6, className: boxClass }), entity.notes?.trim() && (
305
+ // A small tab on the top edge: somebody left notes on this entity.
306
+ _jsx("rect", { x: box.x + box.width - 24, y: box.y - 5, width: 13, height: 5, rx: 1.5, className: "slc-note-mark" })), _jsx("path", { d: `M ${box.x} ${box.y + ERD_BOX.headerHeight} h ${box.width}`, className: "slc-erd-rule" }), _jsx("text", { x: box.x + box.width / 2, y: box.y + ERD_BOX.headerHeight / 2 + 5, textAnchor: "middle", className: "slc-node-name", children: entity.name }), rows.length === 0 && (_jsx("text", { x: box.x + ERD_BOX.padX, y: box.y + ERD_BOX.headerHeight + 15, className: "slc-erd-row slc-erd-row--empty", children: "no attributes" })), rows.map((attr, r) => {
240
307
  const y = box.y + ERD_BOX.headerHeight + r * ERD_BOX.rowHeight + 15;
241
308
  const machines = stateOfList(attr);
242
309
  const badges = keyBadges(attr);
@@ -244,7 +311,15 @@ export function EntityRelationshipCanvas({ definition, positions, viewport, onVi
244
311
  .filter(Boolean)
245
312
  .join(" — ") })), _jsxs("text", { x: box.x + ERD_BOX.padX, y: y, className: `slc-erd-row${machines.length ? " slc-erd-row--state" : ""}${attr.key === "pk" ? " slc-erd-row--pk" : ""}`, children: [machines.length ? "◉ " : "", erdRowText(attr), attr.nullable ? " ?" : ""] }), badges && (_jsx("text", { x: box.x + box.width - ERD_BOX.padX, y: y, textAnchor: "end", className: "slc-erd-badge", children: badges }))] }, attr.name));
246
313
  })] }, entity.name));
247
- }), labels.map((spot, i) => (_jsxs("g", { pointerEvents: "none", children: [_jsx("rect", { x: spot.x, y: spot.y, width: spot.width, height: spot.height, rx: 4, className: "slc-chip-plate" }), _jsx("text", { x: spot.cx, y: spot.cy - 5, textAnchor: "middle", className: "slc-erd-rel-label", children: spot.label.event })] }, `l${i}`)))] }) }), entities.length === 0 && emptyHint && _jsx("div", { className: "slc-erd-empty", children: emptyHint })] }));
314
+ }), labels.map((spot, i) => {
315
+ if (!chen)
316
+ return null;
317
+ const cx = spot.x + spot.width / 2;
318
+ const cy = spot.y + spot.height / 2;
319
+ const hw = chenDiamondHalfWidth(spot.label.rel.label ?? "");
320
+ const hh = CHEN.diamondHalfHeight;
321
+ return (_jsxs("g", { pointerEvents: "none", children: [_jsx("path", { d: `M ${cx - hw} ${cy} L ${cx} ${cy - hh} L ${cx + hw} ${cy} L ${cx} ${cy + hh} Z`, className: "slc-erd-diamond" }), _jsx("text", { x: cx, y: cy + 4, textAnchor: "middle", className: "slc-erd-rel-label", children: spot.label.rel.label ?? "" })] }, `d${i}`));
322
+ }), !chen && labels.map((spot, i) => (_jsxs("g", { pointerEvents: "none", children: [_jsx("rect", { x: spot.x, y: spot.y, width: spot.width, height: spot.height, rx: 4, className: "slc-chip-plate" }), _jsx("text", { x: spot.cx, y: spot.cy - 5, textAnchor: "middle", className: "slc-erd-rel-label", children: spot.label.event })] }, `l${i}`)))] }) }), entities.length === 0 && emptyHint && _jsx("div", { className: "slc-erd-empty", children: emptyHint })] }));
248
323
  }
249
324
  export default EntityRelationshipCanvas;
250
325
  //# sourceMappingURL=EntityRelationshipCanvas.js.map
@@ -898,7 +898,11 @@ export const StateMachineCanvas = forwardRef(function StateMachineCanvas(props,
898
898
  isActive ? "slc-node--active" : "",
899
899
  ]
900
900
  .filter(Boolean)
901
- .join(" ") }), _jsx("text", { x: pos.x + pos.width / 2, y: pos.y + (hasEntry || hasExit ? pos.height / 2 : pos.height / 2 + 5), textAnchor: "middle", className: "slc-node-name", children: state.name }), state.kind && state.kind !== "normal" && (_jsx("text", { x: pos.x + pos.width - 8, y: pos.y + 14, textAnchor: "end", className: "slc-node-kind", children: state.kind })), hasEntry && (_jsx("text", { x: pos.x + 6, y: pos.y + pos.height - 6, className: "slc-node-entry", children: "\u25B8entry" })), hasExit && (_jsx("text", { x: pos.x + pos.width - 6, y: pos.y + pos.height - 6, textAnchor: "end", className: "slc-node-exit", children: "exit\u25C2" })), errored && (_jsx("text", { x: pos.x + 6, y: pos.y + 14, className: "slc-node-warn", children: "\u26A0" })), composite && (_jsxs("text", { x: pos.x + pos.width / 2, y: pos.y + pos.height - 6, textAnchor: "middle", className: "slc-node-drill", children: ["\u25BC ", childCount(state), " children \u2014 ", coarsePointer ? "double-tap" : "double-click", " to enter"] }))] })] }, state.name));
901
+ .join(" ") }), _jsx("text", { x: pos.x + pos.width / 2, y: pos.y + (hasEntry || hasExit ? pos.height / 2 : pos.height / 2 + 5), textAnchor: "middle", className: "slc-node-name", children: state.name }), state.kind && state.kind !== "normal" && (_jsx("text", { x: pos.x + pos.width - 8, y: pos.y + 14, textAnchor: "end", className: "slc-node-kind", children: state.kind })), hasEntry && (_jsx("text", { x: pos.x + 6, y: pos.y + pos.height - 6, className: "slc-node-entry", children: "\u25B8entry" })), hasExit && (_jsx("text", { x: pos.x + pos.width - 6, y: pos.y + pos.height - 6, textAnchor: "end", className: "slc-node-exit", children: "exit\u25C2" })), errored && (
902
+ // Drawn, not typed: "⚠" is a full-colour emoji on iOS and ignores the danger ink.
903
+ _jsx("path", { d: `M ${pos.x + 6} ${pos.y + 15} l 5.5 -9.5 l 5.5 9.5 Z M ${pos.x + 11.5} ${pos.y + 9.5} v 2.6`, className: "slc-node-warn-mark" })), state.notes?.trim() && (
904
+ // A small tab on the top edge: somebody left notes on this state.
905
+ _jsxs("g", { children: [_jsx("title", { children: `Notes: ${state.notes}` }), _jsx("rect", { x: pos.x + pos.width - 24, y: pos.y - 5, width: 13, height: 5, rx: 1.5, className: "slc-note-mark" })] })), composite && (_jsxs("text", { x: pos.x + pos.width / 2, y: pos.y + pos.height - 6, textAnchor: "middle", className: "slc-node-drill", children: ["\u25BC ", childCount(state), " children \u2014 ", coarsePointer ? "double-tap" : "double-click", " to enter"] }))] })] }, state.name));
902
906
  }), Array.from(exitingNodes.entries()).map(([name, { state, pos }]) => {
903
907
  const exFinal = state.kind === "final";
904
908
  const exComposite = isComposite(state);
package/dist/styles.css CHANGED
@@ -107,6 +107,11 @@
107
107
  .slc-node-entry { fill: var(--slc-entry); font-size: 9px; pointer-events: none; user-select: none; }
108
108
  .slc-node-exit { fill: var(--slc-exit); font-size: 9px; pointer-events: none; user-select: none; }
109
109
  .slc-node-warn { fill: var(--slc-danger); font-size: 12px; pointer-events: none; user-select: none; }
110
+ /* Somebody left notes on this shape — a small tab on its top edge, in both canvases. */
111
+ .slc-note-mark { fill: var(--slc-accent-ink); opacity: 0.75; }
112
+
113
+ .slc-node-warn-mark { fill: none; stroke: var(--slc-danger); stroke-width: 1.4; stroke-linejoin: round; stroke-linecap: round; pointer-events: none; }
114
+
110
115
  .slc-node-drill { fill: var(--slc-composite); font-size: 9px; pointer-events: none; user-select: none; }
111
116
 
112
117
  /* What the pointer says a box will do. */
@@ -456,6 +461,56 @@
456
461
  user-select: none;
457
462
  }
458
463
 
464
+ /* Chen notation: ovals, diamonds, and the cardinality written beside the line. */
465
+
466
+ .slc-erd-oval {
467
+ fill: var(--slc-node-fill);
468
+ stroke: var(--slc-node-stroke);
469
+ stroke-width: 1.2;
470
+ }
471
+
472
+ .slc-erd-oval-text {
473
+ fill: var(--slc-muted);
474
+ font-size: 11px;
475
+ pointer-events: none;
476
+ user-select: none;
477
+ }
478
+
479
+ .slc-erd-oval-text--pk {
480
+ fill: var(--slc-label);
481
+ font-weight: 600;
482
+ text-decoration: underline;
483
+ }
484
+
485
+ .slc-erd-attr-line {
486
+ fill: none;
487
+ stroke: var(--slc-chip-stroke);
488
+ stroke-width: 1;
489
+ }
490
+
491
+ .slc-erd-diamond {
492
+ fill: var(--slc-chip-fill);
493
+ stroke: var(--slc-edge);
494
+ stroke-width: 1.5;
495
+ }
496
+
497
+ .slc-erd-weak {
498
+ fill: none;
499
+ stroke: var(--slc-node-stroke);
500
+ stroke-width: 1.2;
501
+ pointer-events: none;
502
+ }
503
+
504
+ .slc-erd-card {
505
+ fill: var(--slc-label);
506
+ font-size: 12px;
507
+ font-weight: 700;
508
+ pointer-events: none;
509
+ user-select: none;
510
+ }
511
+
512
+ .slc-erd-state:hover .slc-erd-oval { stroke: var(--slc-accent); }
513
+
459
514
  .slc-erd-empty {
460
515
  position: absolute;
461
516
  inset: 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miadi/stateloom-canvas",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "The reusable SMDF design surface: a pannable, zoomable, drillable React SVG canvas with routed edges, settled labels and a navigation HUD",
5
5
  "repository": {
6
6
  "type": "git",
@@ -43,7 +43,7 @@
43
43
  "node": ">=20"
44
44
  },
45
45
  "dependencies": {
46
- "@miadi/stateloom-protocol": "^0.1.6"
46
+ "@miadi/stateloom-protocol": "^0.1.8"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "react": "^19"