@erd-studio/renderer 0.3.0 → 0.4.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 (71) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +7 -3
  3. package/dist/{chunk-DUQ2TTQH.js → chunk-64BVOHOR.js} +4 -3
  4. package/dist/chunk-7VFJNN4P.js +10461 -0
  5. package/dist/{chunk-WOTSQZCQ.js → chunk-YLXBIRPE.js} +132 -2
  6. package/dist/editor.js +43 -3
  7. package/dist/index.js +14 -3
  8. package/dist/sizing.js +2 -2
  9. package/dist/store.js +1 -1
  10. package/dist/styles.css +912 -359
  11. package/dist/types/ErdCanvas.d.ts +29 -1
  12. package/dist/types/canvas/CanvasBackdrop.d.ts +3 -2
  13. package/dist/types/canvas/EdgeRouting.d.ts +56 -0
  14. package/dist/types/canvas/useCanvasGraph.d.ts +7 -1
  15. package/dist/types/canvas/useHoverFocus.d.ts +64 -0
  16. package/dist/types/components/DetailPanel/AliasEditor.d.ts +15 -1
  17. package/dist/types/components/DetailPanel/ColumnEditor.d.ts +18 -2
  18. package/dist/types/components/DetailPanel/DescriptionEditor.d.ts +1 -1
  19. package/dist/types/components/DetailPanel/DetailPanel.d.ts +31 -2
  20. package/dist/types/components/DetailPanel/FieldsSection.d.ts +68 -0
  21. package/dist/types/components/Graph/EdgeFlow.d.ts +55 -0
  22. package/dist/types/components/Graph/EdgeLabels.d.ts +18 -0
  23. package/dist/types/components/Graph/FkEdge.d.ts +8 -1
  24. package/dist/types/components/Graph/ModelNode.d.ts +1 -1
  25. package/dist/types/components/Legend/Legend.d.ts +34 -3
  26. package/dist/types/components/StatusBar/StatusBar.d.ts +45 -0
  27. package/dist/types/components/common/ColumnRowEditor.d.ts +18 -2
  28. package/dist/types/components/common/KeyBadgeGroup.d.ts +5 -1
  29. package/dist/types/editor.d.ts +8 -2
  30. package/dist/types/hooks/usePrefersReducedMotion.d.ts +13 -0
  31. package/dist/types/index.d.ts +2 -1
  32. package/dist/types/lib/badgeLabels.d.ts +6 -0
  33. package/dist/types/lib/canvasContext.d.ts +20 -0
  34. package/dist/types/lib/canvasFocus.d.ts +66 -0
  35. package/dist/types/lib/edgeFlow.d.ts +84 -0
  36. package/dist/types/lib/edgeRouting/index.d.ts +146 -0
  37. package/dist/types/lib/edgeRouting/input.d.ts +35 -0
  38. package/dist/types/lib/edgeRouting/lineStyle.d.ts +16 -0
  39. package/dist/types/lib/edgeRouting/render/corners.d.ts +52 -0
  40. package/dist/types/lib/edgeRouting/render/crossings.d.ts +27 -0
  41. package/dist/types/lib/edgeRouting/render/curveCrossings.d.ts +35 -0
  42. package/dist/types/lib/edgeRouting/render/pathRender.d.ts +74 -0
  43. package/dist/types/lib/edgeRouting/render/tunnels.d.ts +49 -0
  44. package/dist/types/lib/edgeRouting/routeAll.d.ts +20 -0
  45. package/dist/types/lib/edgeRouting/routers/orthogonal/geom.d.ts +58 -0
  46. package/dist/types/lib/edgeRouting/routers/orthogonal/grid.d.ts +77 -0
  47. package/dist/types/lib/edgeRouting/routers/orthogonal/nudge.d.ts +62 -0
  48. package/dist/types/lib/edgeRouting/routers/orthogonal/params.d.ts +152 -0
  49. package/dist/types/lib/edgeRouting/routers/orthogonal/router.d.ts +51 -0
  50. package/dist/types/lib/edgeRouting/routers/orthogonal/search.d.ts +81 -0
  51. package/dist/types/lib/edgeRouting/routers/orthogonalAvoid.d.ts +11 -0
  52. package/dist/types/lib/edgeRouting/types.d.ts +113 -0
  53. package/dist/types/lib/edgeRouting/worker/client.d.ts +23 -0
  54. package/dist/types/lib/edgeRouting/worker/entry.d.ts +1 -0
  55. package/dist/types/lib/edgeRouting/worker/protocol.d.ts +23 -0
  56. package/dist/types/lib/hoverIntent.d.ts +44 -0
  57. package/dist/types/lib/layerCues.d.ts +26 -0
  58. package/dist/types/lib/nodeOverlays.d.ts +6 -0
  59. package/dist/types/lib/nodeSizing.d.ts +1 -1
  60. package/dist/types/lib/pathGeometry.d.ts +45 -0
  61. package/dist/types/lib/reuseUnchanged.d.ts +28 -0
  62. package/dist/types/lib/roleOptions.d.ts +13 -0
  63. package/dist/types/store/editorStore.d.ts +58 -1
  64. package/dist/types/types/graph.d.ts +20 -1
  65. package/package.json +2 -2
  66. package/dist/chunk-HWA32XG5.js +0 -5652
  67. package/dist/types/components/DetailPanel/GrainEditor.d.ts +0 -16
  68. package/dist/types/components/DetailPanel/MetaEditor.d.ts +0 -21
  69. package/dist/types/components/DetailPanel/ModelRationale.d.ts +0 -27
  70. package/dist/types/components/DetailPanel/RationaleField.d.ts +0 -28
  71. package/dist/types/components/DetailPanel/RoleEditor.d.ts +0 -13
@@ -1,3 +1,96 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+
5
+ // src/lib/canvasFocus.ts
6
+ var FLOW_ANIMATION_LIMIT = 40;
7
+ function fkData(edge) {
8
+ return edge.type === "fk" ? edge.data : void 0;
9
+ }
10
+ function computeCanvasFocus(edges, target, nodeIds, options) {
11
+ const node = target.node ?? null;
12
+ if (node !== null) {
13
+ if (nodeIds && !nodeIds.has(node)) return null;
14
+ const nodes = /* @__PURE__ */ new Set([node]);
15
+ const own = /* @__PURE__ */ new Set();
16
+ const flowEdges2 = /* @__PURE__ */ new Set();
17
+ for (const edge2 of edges) {
18
+ const fk2 = fkData(edge2);
19
+ if (!fk2) continue;
20
+ if (fk2.fromModel !== node && fk2.toModel !== node) continue;
21
+ nodes.add(fk2.fromModel);
22
+ nodes.add(fk2.toModel);
23
+ own.add(edge2.id);
24
+ if (fk2.discrepancyStatus !== "missing") flowEdges2.add(edge2.id);
25
+ }
26
+ let bright = own;
27
+ if (!options?.ownLinesOnly) {
28
+ bright = /* @__PURE__ */ new Set();
29
+ for (const edge2 of edges) {
30
+ const fk2 = fkData(edge2);
31
+ if (fk2 && nodes.has(fk2.fromModel) && nodes.has(fk2.toModel)) bright.add(edge2.id);
32
+ }
33
+ }
34
+ return {
35
+ node,
36
+ edge: null,
37
+ nodes,
38
+ edges: bright,
39
+ flowEdges: flowEdges2,
40
+ animate: flowEdges2.size <= FLOW_ANIMATION_LIMIT
41
+ };
42
+ }
43
+ const edgeId = target.edge ?? null;
44
+ if (edgeId === null) return null;
45
+ const edge = edges.find((e) => e.id === edgeId);
46
+ const fk = edge ? fkData(edge) : void 0;
47
+ if (!fk) return null;
48
+ const flowEdges = new Set(fk.discrepancyStatus === "missing" ? [] : [edgeId]);
49
+ return {
50
+ node: null,
51
+ edge: edgeId,
52
+ nodes: /* @__PURE__ */ new Set([fk.fromModel, fk.toModel]),
53
+ edges: /* @__PURE__ */ new Set([edgeId]),
54
+ flowEdges,
55
+ animate: flowEdges.size <= FLOW_ANIMATION_LIMIT
56
+ };
57
+ }
58
+ function sameSet(a, b) {
59
+ if (a === b) return true;
60
+ if (a.size !== b.size) return false;
61
+ for (const v of a) if (!b.has(v)) return false;
62
+ return true;
63
+ }
64
+ function sameFocus(a, b) {
65
+ if (a === b) return true;
66
+ if (!a || !b) return false;
67
+ return a.node === b.node && a.edge === b.edge && a.animate === b.animate && a.nodes.size === b.nodes.size && a.edges.size === b.edges.size && a.flowEdges.size === b.flowEdges.size && sameSet(a.nodes, b.nodes) && sameSet(a.edges, b.edges) && sameSet(a.flowEdges, b.flowEdges);
68
+ }
69
+ function tableFocusRole(focus, id) {
70
+ if (!focus) return null;
71
+ if (focus.node === id) return "origin";
72
+ return focus.nodes.has(id) ? "related" : null;
73
+ }
74
+ function edgeFocusRole(flow, hover, id) {
75
+ if (flow && flow.flowEdges.has(id)) return flow.animate ? "flow" : "flow-static";
76
+ if (hover && hover.edges.has(id)) return "lit";
77
+ return null;
78
+ }
79
+
80
+ // src/lib/edgeRouting/lineStyle.ts
81
+ var LINE_STYLES = ["curved", "hops"];
82
+ var DEFAULT_LINE_STYLE = "curved";
83
+ function isLineStyle(value) {
84
+ return value === "curved" || value === "hops";
85
+ }
86
+ var LINE_STYLE_OPTIONS = {
87
+ curved: { crossings: "halo", underTables: "xray", corners: "curved" },
88
+ hops: { crossings: "hops", underTables: "hidden", corners: "rounded" }
89
+ };
90
+ function lineStyleOptions(style) {
91
+ return LINE_STYLE_OPTIONS[isLineStyle(style) ? style : DEFAULT_LINE_STYLE];
92
+ }
93
+
1
94
  // src/store/editorStore.ts
2
95
  import { createContext, createElement, useContext } from "react";
3
96
  import { createStore, useStore } from "zustand";
@@ -26,6 +119,12 @@ function createCanvasSlice(set) {
26
119
  lastSelectedColumn: null,
27
120
  editingColumn: null,
28
121
  selectedAnnotation: null,
122
+ hoverFocus: null,
123
+ flowFocus: null,
124
+ logicalOnly: false,
125
+ canvasContext: null,
126
+ lineStyle: DEFAULT_LINE_STYLE,
127
+ edgeRoutes: null,
29
128
  // Actions
30
129
  setSearchQuery: (query) => set({ searchQuery: query }),
31
130
  selectNode: (nodeName) => set({ selectedNode: nodeName, selectedAnnotation: null, selectedColumns: [], lastSelectedColumn: null, editingColumn: null }),
@@ -118,7 +217,15 @@ function createCanvasSlice(set) {
118
217
  selectedColumns: [],
119
218
  lastSelectedColumn: null,
120
219
  editingColumn: null
121
- })
220
+ }),
221
+ // Hover focus and relationship flow (ephemeral, see useHoverFocus)
222
+ setHoverFocus: (focus) => set((s) => sameFocus(s.hoverFocus, focus) ? s : { hoverFocus: focus }),
223
+ setFlowFocus: (focus) => set((s) => sameFocus(s.flowFocus, focus) ? s : { flowFocus: focus }),
224
+ // Host context (editing hosts only)
225
+ setCanvasContext: (context) => set({ canvasContext: context }),
226
+ // Line routing (EdgeRouter writes the routes; FkEdge and EdgeOverlay read them)
227
+ setLineStyle: (lineStyle) => set((s) => s.lineStyle === lineStyle ? s : { lineStyle }),
228
+ setEdgeRoutes: (routes) => set((s) => s.edgeRoutes === routes ? s : { edgeRoutes: routes })
122
229
  };
123
230
  }
124
231
  function createCanvasStore(initial) {
@@ -141,11 +248,34 @@ function useEditorStoreApi() {
141
248
  function useEditorStore(selector) {
142
249
  return useStore(useEditorStoreApi(), selector);
143
250
  }
251
+ var NO_STORE = {
252
+ getState: () => void 0,
253
+ getInitialState: () => void 0,
254
+ subscribe: () => () => {
255
+ }
256
+ };
257
+ function useEditorStoreOr(selector, fallback) {
258
+ const store = useContext(CanvasStoreContext);
259
+ return useStore(
260
+ store ?? NO_STORE,
261
+ store ? selector : () => fallback
262
+ );
263
+ }
144
264
 
145
265
  export {
266
+ __publicField,
267
+ computeCanvasFocus,
268
+ sameFocus,
269
+ tableFocusRole,
270
+ edgeFocusRole,
271
+ LINE_STYLES,
272
+ DEFAULT_LINE_STYLE,
273
+ isLineStyle,
274
+ lineStyleOptions,
146
275
  createCanvasSlice,
147
276
  createCanvasStore,
148
277
  CanvasStoreProvider,
149
278
  useEditorStoreApi,
150
- useEditorStore
279
+ useEditorStore,
280
+ useEditorStoreOr
151
281
  };
package/dist/editor.js CHANGED
@@ -8,24 +8,32 @@ import {
8
8
  CanvasBackdrop,
9
9
  CanvasEnvironmentProvider,
10
10
  ColumnRowEditor,
11
+ DBML_RICH_EXPORT_HEADER,
11
12
  DIAGRAM_EXPORT_FILE_EXTENSIONS,
12
13
  DIAGRAM_EXPORT_FORMATS,
13
14
  DISCREPANCY_PHRASE,
14
15
  DataTypeSelect,
15
16
  DetailPanel,
17
+ EdgeFlow,
18
+ EdgeFlowGlyphs,
16
19
  ErdCanvas,
17
20
  FkEdge,
18
21
  KeyBadge,
19
22
  KeyBadgeGroup,
23
+ LAYER_BADGE_FALLBACK,
20
24
  Legend,
21
25
  NOOP_CANVAS_HOST,
22
26
  SCD_BADGE,
23
27
  SCD_TITLE,
24
28
  SOURCE_LABEL,
29
+ SOURCE_LABEL_NEUTRAL,
25
30
  SOURCE_LEGEND_DESC,
31
+ SOURCE_LEGEND_DESC_NEUTRAL,
26
32
  SOURCE_ORDER,
27
33
  SOURCE_PHRASE,
34
+ SOURCE_PHRASE_NEUTRAL,
28
35
  STAGE_HEX,
36
+ StatusBar,
29
37
  TableNode,
30
38
  applyNodeOverlays,
31
39
  canvasEdgeTypes,
@@ -37,6 +45,9 @@ import {
37
45
  exportDiagram,
38
46
  foldComposites,
39
47
  getDataTypeColor,
48
+ isSingleLayerProject,
49
+ layerAbbreviation,
50
+ legendEntries,
40
51
  matchesTableSearch,
41
52
  nodeRect,
42
53
  pickHandleSides,
@@ -44,18 +55,22 @@ import {
44
55
  relationshipEdgeId,
45
56
  repickHandleSides,
46
57
  stageNodeColor,
58
+ statusBarStats,
47
59
  swapCardinality,
48
60
  toDbml,
61
+ toDbmlRich,
49
62
  toMermaid,
50
63
  transformSubjectArea,
51
64
  useCanvasGraph,
52
65
  useCanvasHost,
53
66
  useColumnReorder,
54
67
  useFocusWithinRow,
68
+ useHoverFocus,
55
69
  useIsViewer,
56
70
  useLongPressDrag,
71
+ usePrefersReducedMotion,
57
72
  useSend
58
- } from "./chunk-HWA32XG5.js";
73
+ } from "./chunk-7VFJNN4P.js";
59
74
  import "./chunk-QZGU5NZH.js";
60
75
  import "./chunk-6XQXDZ4R.js";
61
76
  import {
@@ -67,14 +82,19 @@ import {
67
82
  estimateNodeWidth,
68
83
  resolveNodeDimensions,
69
84
  useColumnExpansion
70
- } from "./chunk-DUQ2TTQH.js";
85
+ } from "./chunk-64BVOHOR.js";
71
86
  import {
72
87
  CanvasStoreProvider,
88
+ DEFAULT_LINE_STYLE,
89
+ LINE_STYLES,
90
+ computeCanvasFocus,
73
91
  createCanvasSlice,
74
92
  createCanvasStore,
93
+ isLineStyle,
94
+ sameFocus,
75
95
  useEditorStore,
76
96
  useEditorStoreApi
77
- } from "./chunk-WOTSQZCQ.js";
97
+ } from "./chunk-YLXBIRPE.js";
78
98
  export {
79
99
  ADDITIVE_BADGE,
80
100
  ADDITIVE_TITLE,
@@ -87,15 +107,21 @@ export {
87
107
  CanvasEnvironmentProvider,
88
108
  CanvasStoreProvider,
89
109
  ColumnRowEditor,
110
+ DBML_RICH_EXPORT_HEADER,
111
+ DEFAULT_LINE_STYLE,
90
112
  DIAGRAM_EXPORT_FILE_EXTENSIONS,
91
113
  DIAGRAM_EXPORT_FORMATS,
92
114
  DISCREPANCY_PHRASE,
93
115
  DataTypeSelect,
94
116
  DetailPanel,
117
+ EdgeFlow,
118
+ EdgeFlowGlyphs,
95
119
  ErdCanvas,
96
120
  FkEdge,
97
121
  KeyBadge,
98
122
  KeyBadgeGroup,
123
+ LAYER_BADGE_FALLBACK,
124
+ LINE_STYLES,
99
125
  Legend,
100
126
  NODE_THRESHOLD,
101
127
  NODE_WIDTH,
@@ -103,15 +129,20 @@ export {
103
129
  SCD_BADGE,
104
130
  SCD_TITLE,
105
131
  SOURCE_LABEL,
132
+ SOURCE_LABEL_NEUTRAL,
106
133
  SOURCE_LEGEND_DESC,
134
+ SOURCE_LEGEND_DESC_NEUTRAL,
107
135
  SOURCE_ORDER,
108
136
  SOURCE_PHRASE,
137
+ SOURCE_PHRASE_NEUTRAL,
109
138
  STAGE_HEX,
139
+ StatusBar,
110
140
  TableNode,
111
141
  applyNodeOverlays,
112
142
  canvasEdgeTypes,
113
143
  canvasNodeTypes,
114
144
  columnPairs,
145
+ computeCanvasFocus,
115
146
  computeTableLabels,
116
147
  countVisibleColumnRows,
117
148
  createCanvasSlice,
@@ -123,6 +154,10 @@ export {
123
154
  exportDiagram,
124
155
  foldComposites,
125
156
  getDataTypeColor,
157
+ isLineStyle,
158
+ isSingleLayerProject,
159
+ layerAbbreviation,
160
+ legendEntries,
126
161
  matchesTableSearch,
127
162
  nodeRect,
128
163
  pickHandleSides,
@@ -130,9 +165,12 @@ export {
130
165
  relationshipEdgeId,
131
166
  repickHandleSides,
132
167
  resolveNodeDimensions,
168
+ sameFocus,
133
169
  stageNodeColor,
170
+ statusBarStats,
134
171
  swapCardinality,
135
172
  toDbml,
173
+ toDbmlRich,
136
174
  toMermaid,
137
175
  transformSubjectArea,
138
176
  useCanvasGraph,
@@ -142,7 +180,9 @@ export {
142
180
  useEditorStore,
143
181
  useEditorStoreApi,
144
182
  useFocusWithinRow,
183
+ useHoverFocus,
145
184
  useIsViewer,
146
185
  useLongPressDrag,
186
+ usePrefersReducedMotion,
147
187
  useSend
148
188
  };
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import {
2
+ DBML_RICH_EXPORT_HEADER,
2
3
  DIAGRAM_EXPORT_FILE_EXTENSIONS,
3
4
  DIAGRAM_EXPORT_FORMATS,
4
5
  ErdCanvas,
@@ -8,21 +9,31 @@ import {
8
9
  pickHandleSides,
9
10
  repickHandleSides,
10
11
  toDbml,
12
+ toDbmlRich,
11
13
  toMermaid,
12
14
  transformSubjectArea
13
- } from "./chunk-HWA32XG5.js";
14
- import "./chunk-DUQ2TTQH.js";
15
- import "./chunk-WOTSQZCQ.js";
15
+ } from "./chunk-7VFJNN4P.js";
16
+ import "./chunk-64BVOHOR.js";
17
+ import {
18
+ DEFAULT_LINE_STYLE,
19
+ LINE_STYLES,
20
+ isLineStyle
21
+ } from "./chunk-YLXBIRPE.js";
16
22
  export {
23
+ DBML_RICH_EXPORT_HEADER,
24
+ DEFAULT_LINE_STYLE,
17
25
  DIAGRAM_EXPORT_FILE_EXTENSIONS,
18
26
  DIAGRAM_EXPORT_FORMATS,
19
27
  ErdCanvas,
28
+ LINE_STYLES,
20
29
  diagramExportFileName,
21
30
  exportDiagram,
31
+ isLineStyle,
22
32
  nodeRect,
23
33
  pickHandleSides,
24
34
  repickHandleSides,
25
35
  toDbml,
36
+ toDbmlRich,
26
37
  toMermaid,
27
38
  transformSubjectArea
28
39
  };
package/dist/sizing.js CHANGED
@@ -5,8 +5,8 @@ import {
5
5
  estimateNodeHeight,
6
6
  estimateNodeWidth,
7
7
  resolveNodeDimensions
8
- } from "./chunk-DUQ2TTQH.js";
9
- import "./chunk-WOTSQZCQ.js";
8
+ } from "./chunk-64BVOHOR.js";
9
+ import "./chunk-YLXBIRPE.js";
10
10
  export {
11
11
  NODE_WIDTH,
12
12
  countVisibleColumnRows,
package/dist/store.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  createCanvasStore,
6
6
  useEditorStore,
7
7
  useEditorStoreApi
8
- } from "./chunk-WOTSQZCQ.js";
8
+ } from "./chunk-YLXBIRPE.js";
9
9
  export {
10
10
  CanvasStoreProvider,
11
11
  createCanvasSlice,