@erd-studio/renderer 0.1.4 → 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.
- package/CHANGELOG.md +70 -0
- package/README.md +13 -9
- package/dist/{chunk-DUQ2TTQH.js → chunk-64BVOHOR.js} +4 -3
- package/dist/chunk-7VFJNN4P.js +10461 -0
- package/dist/{chunk-WOTSQZCQ.js → chunk-YLXBIRPE.js} +132 -2
- package/dist/editor.js +51 -11
- package/dist/index.js +16 -5
- package/dist/sizing.js +2 -2
- package/dist/store.js +1 -1
- package/dist/styles.css +901 -292
- package/dist/types/ErdCanvas.d.ts +33 -5
- package/dist/types/canvas/CanvasBackdrop.d.ts +3 -2
- package/dist/types/canvas/EdgeRouting.d.ts +56 -0
- package/dist/types/canvas/useCanvasGraph.d.ts +11 -5
- package/dist/types/canvas/useHoverFocus.d.ts +64 -0
- package/dist/types/components/DetailPanel/AliasEditor.d.ts +16 -2
- package/dist/types/components/DetailPanel/ColumnEditor.d.ts +20 -4
- package/dist/types/components/DetailPanel/DescriptionEditor.d.ts +1 -1
- package/dist/types/components/DetailPanel/DetailPanel.d.ts +31 -2
- package/dist/types/components/DetailPanel/FieldsSection.d.ts +68 -0
- package/dist/types/components/Graph/ColumnTooltip.d.ts +1 -1
- package/dist/types/components/Graph/EdgeFlow.d.ts +55 -0
- package/dist/types/components/Graph/EdgeLabels.d.ts +18 -0
- package/dist/types/components/Graph/FkEdge.d.ts +8 -1
- package/dist/types/components/Graph/ModelNode.d.ts +4 -4
- package/dist/types/components/Legend/Legend.d.ts +35 -4
- package/dist/types/components/StatusBar/StatusBar.d.ts +45 -0
- package/dist/types/components/common/ColumnRowEditor.d.ts +20 -4
- package/dist/types/components/common/KeyBadgeGroup.d.ts +5 -1
- package/dist/types/editor.d.ts +10 -4
- package/dist/types/hooks/useColumnReorder.d.ts +1 -1
- package/dist/types/hooks/usePrefersReducedMotion.d.ts +13 -0
- package/dist/types/index.d.ts +5 -4
- package/dist/types/lib/badgeLabels.d.ts +7 -1
- package/dist/types/lib/canvasContext.d.ts +20 -0
- package/dist/types/lib/canvasFocus.d.ts +66 -0
- package/dist/types/lib/dragHandleSides.d.ts +2 -2
- package/dist/types/lib/edgeFlow.d.ts +84 -0
- package/dist/types/lib/edgeRouting/index.d.ts +146 -0
- package/dist/types/lib/edgeRouting/input.d.ts +35 -0
- package/dist/types/lib/edgeRouting/lineStyle.d.ts +16 -0
- package/dist/types/lib/edgeRouting/render/corners.d.ts +52 -0
- package/dist/types/lib/edgeRouting/render/crossings.d.ts +27 -0
- package/dist/types/lib/edgeRouting/render/curveCrossings.d.ts +35 -0
- package/dist/types/lib/edgeRouting/render/pathRender.d.ts +74 -0
- package/dist/types/lib/edgeRouting/render/tunnels.d.ts +49 -0
- package/dist/types/lib/edgeRouting/routeAll.d.ts +20 -0
- package/dist/types/lib/edgeRouting/routers/orthogonal/geom.d.ts +58 -0
- package/dist/types/lib/edgeRouting/routers/orthogonal/grid.d.ts +77 -0
- package/dist/types/lib/edgeRouting/routers/orthogonal/nudge.d.ts +62 -0
- package/dist/types/lib/edgeRouting/routers/orthogonal/params.d.ts +152 -0
- package/dist/types/lib/edgeRouting/routers/orthogonal/router.d.ts +51 -0
- package/dist/types/lib/edgeRouting/routers/orthogonal/search.d.ts +81 -0
- package/dist/types/lib/edgeRouting/routers/orthogonalAvoid.d.ts +11 -0
- package/dist/types/lib/edgeRouting/types.d.ts +113 -0
- package/dist/types/lib/edgeRouting/worker/client.d.ts +23 -0
- package/dist/types/lib/edgeRouting/worker/entry.d.ts +1 -0
- package/dist/types/lib/edgeRouting/worker/protocol.d.ts +23 -0
- package/dist/types/lib/graphTransformer.d.ts +7 -7
- package/dist/types/lib/hoverIntent.d.ts +44 -0
- package/dist/types/lib/layerCues.d.ts +26 -0
- package/dist/types/lib/modelLabels.d.ts +3 -3
- package/dist/types/lib/nodeOverlays.d.ts +10 -4
- package/dist/types/lib/nodeSizing.d.ts +6 -6
- package/dist/types/lib/pathGeometry.d.ts +45 -0
- package/dist/types/lib/reuseUnchanged.d.ts +28 -0
- package/dist/types/lib/roleOptions.d.ts +13 -0
- package/dist/types/store/editorStore.d.ts +65 -8
- package/dist/types/types/graph.d.ts +38 -14
- package/package.json +3 -2
- package/dist/chunk-IAFK7ZZV.js +0 -5576
- package/dist/types/components/DetailPanel/GrainEditor.d.ts +0 -16
- package/dist/types/components/DetailPanel/MetaEditor.d.ts +0 -21
- package/dist/types/components/DetailPanel/ModelRationale.d.ts +0 -27
- package/dist/types/components/DetailPanel/RationaleField.d.ts +0 -28
- package/dist/types/components/DetailPanel/RoleEditor.d.ts +0 -13
|
@@ -14,8 +14,11 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { type ReactNode } from 'react';
|
|
16
16
|
import { type StoreApi } from 'zustand';
|
|
17
|
-
import type {
|
|
18
|
-
import type {
|
|
17
|
+
import type { CanvasContext, DisplaySubjectArea, ExistingTablePreview } from '@erd-studio/core';
|
|
18
|
+
import type { TableFlowNode, FkFlowEdge, FkEdgeData, AnnotationFlowNode, AnnotationFlowEdge } from '../types/graph.js';
|
|
19
|
+
import { type CanvasFocus } from '../lib/canvasFocus.js';
|
|
20
|
+
import type { RoutedEdge } from '../lib/edgeRouting/types.js';
|
|
21
|
+
import { type LineStyle } from '../lib/edgeRouting/lineStyle.js';
|
|
19
22
|
/** Context menu state for edge right-click. */
|
|
20
23
|
export interface EdgeContextMenu {
|
|
21
24
|
type: 'edge';
|
|
@@ -70,15 +73,15 @@ export interface CanvasState {
|
|
|
70
73
|
/** Whether a delete confirmation is pending (triggered by Delete key). */
|
|
71
74
|
pendingDeleteConfirmation: boolean;
|
|
72
75
|
/** The loaded domain data from the extension host (already reconciled with manifest). */
|
|
73
|
-
domain:
|
|
76
|
+
domain: DisplaySubjectArea | null;
|
|
74
77
|
/** React Flow nodes (local state for selection/drag). */
|
|
75
|
-
nodes: (
|
|
78
|
+
nodes: (TableFlowNode | AnnotationFlowNode)[];
|
|
76
79
|
/** React Flow edges. */
|
|
77
80
|
edges: (FkFlowEdge | AnnotationFlowEdge)[];
|
|
78
81
|
/** Annotation currently being edited (auto-focus textarea), or null. */
|
|
79
82
|
editingAnnotationId: string | null;
|
|
80
83
|
/** Models available to add from logical-models/ and manifest. */
|
|
81
|
-
existingModels:
|
|
84
|
+
existingModels: ExistingTablePreview[];
|
|
82
85
|
/** Context menu state (position and target), or null if closed. */
|
|
83
86
|
contextMenu: ContextMenuState;
|
|
84
87
|
/** Whether the legend panel is visible. */
|
|
@@ -101,6 +104,44 @@ export interface CanvasState {
|
|
|
101
104
|
editingColumn: string | null;
|
|
102
105
|
/** Currently selected annotation ID, or null. */
|
|
103
106
|
selectedAnnotation: string | null;
|
|
107
|
+
/**
|
|
108
|
+
* Hover preview focus: the table the pointer rests on, its related tables
|
|
109
|
+
* and lines (`useHoverFocus`). Ephemeral UI state: never persisted, never
|
|
110
|
+
* posted to the host, never written to a file.
|
|
111
|
+
*/
|
|
112
|
+
hoverFocus: CanvasFocus | null;
|
|
113
|
+
/**
|
|
114
|
+
* What carries the moving relationship arrows: `hoverFocus`, else the
|
|
115
|
+
* focus of the clicked table or line. Ephemeral, like `hoverFocus`.
|
|
116
|
+
*/
|
|
117
|
+
flowFocus: CanvasFocus | null;
|
|
118
|
+
/**
|
|
119
|
+
* The project has no dbt project, so there is one stage only: the canvas
|
|
120
|
+
* drops the stage colours (`editor-canvas--neutral`) and the legend its
|
|
121
|
+
* Physical, ghost and comparison entries. Default false, today's look. The
|
|
122
|
+
* extension's store sets it from the host's `logicalOnly` flag; ErdCanvas
|
|
123
|
+
* from its `logicalOnly` prop.
|
|
124
|
+
*/
|
|
125
|
+
logicalOnly: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* What the editing host knows beyond the diagram (`CanvasContext`): each
|
|
128
|
+
* table's file, its relationships to tables not on the diagram, who reviews
|
|
129
|
+
* it. Logical stage only. Null by default and in the viewer, which never
|
|
130
|
+
* gets one: then the detail panel has no File line or "Not on this
|
|
131
|
+
* diagram" list and no node shows a "+n" chip.
|
|
132
|
+
*/
|
|
133
|
+
canvasContext: CanvasContext | null;
|
|
134
|
+
/**
|
|
135
|
+
* How FK lines are drawn (`curved` or `hops`), a reader's view preference.
|
|
136
|
+
* The extension's store sets it from the host's `lineStyle` message (the
|
|
137
|
+
* `erdStudio.canvas.lineStyle` setting); ErdCanvas from its `lineStyle` prop.
|
|
138
|
+
*/
|
|
139
|
+
lineStyle: LineStyle;
|
|
140
|
+
/**
|
|
141
|
+
* The routed FK lines by edge id, from `EdgeRouter`'s last pass. Null (or
|
|
142
|
+
* a line missing from it) means `FkEdge` draws its smooth-step fallback.
|
|
143
|
+
*/
|
|
144
|
+
edgeRoutes: Map<string, RoutedEdge> | null;
|
|
104
145
|
}
|
|
105
146
|
export interface CanvasActions {
|
|
106
147
|
setSearchQuery: (query: string) => void;
|
|
@@ -110,12 +151,12 @@ export interface CanvasActions {
|
|
|
110
151
|
setDetailPanelOpen: (open: boolean) => void;
|
|
111
152
|
/** Set pending delete confirmation state (triggered by Delete key). */
|
|
112
153
|
setPendingDeleteConfirmation: (pending: boolean) => void;
|
|
113
|
-
setDomain: (domain:
|
|
114
|
-
setNodes: (nodes: (
|
|
154
|
+
setDomain: (domain: DisplaySubjectArea) => void;
|
|
155
|
+
setNodes: (nodes: (TableFlowNode | AnnotationFlowNode)[]) => void;
|
|
115
156
|
setEdges: (edges: (FkFlowEdge | AnnotationFlowEdge)[]) => void;
|
|
116
157
|
/** Set the annotation currently being edited (auto-focus). */
|
|
117
158
|
setEditingAnnotationId: (id: string | null) => void;
|
|
118
|
-
setExistingModels: (models:
|
|
159
|
+
setExistingModels: (models: ExistingTablePreview[]) => void;
|
|
119
160
|
/** Open context menu for an edge at the given position. */
|
|
120
161
|
openEdgeContextMenu: (x: number, y: number, data: FkEdgeData) => void;
|
|
121
162
|
/** Open context menu for a node at the given position. */
|
|
@@ -162,6 +203,16 @@ export interface CanvasActions {
|
|
|
162
203
|
setEditingColumn: (name: string | null) => void;
|
|
163
204
|
/** Select an annotation (clears model selection). */
|
|
164
205
|
selectAnnotation: (annotationId: string | null) => void;
|
|
206
|
+
/** Set the hover preview focus; a focus equal by value is not written. */
|
|
207
|
+
setHoverFocus: (focus: CanvasFocus | null) => void;
|
|
208
|
+
/** Set the flowing focus; a focus equal by value is not written. */
|
|
209
|
+
setFlowFocus: (focus: CanvasFocus | null) => void;
|
|
210
|
+
/** Store the host's canvas context, or clear it (null). */
|
|
211
|
+
setCanvasContext: (context: CanvasContext | null) => void;
|
|
212
|
+
/** Change how FK lines are drawn. */
|
|
213
|
+
setLineStyle: (lineStyle: LineStyle) => void;
|
|
214
|
+
/** Store the router's latest routes (null: every line on the fallback). */
|
|
215
|
+
setEdgeRoutes: (routes: Map<string, RoutedEdge> | null) => void;
|
|
165
216
|
}
|
|
166
217
|
export type CanvasStore = CanvasState & CanvasActions;
|
|
167
218
|
export type CanvasStoreApi = StoreApi<CanvasStore>;
|
|
@@ -183,3 +234,9 @@ export declare function CanvasStoreProvider({ store, children }: {
|
|
|
183
234
|
export declare function useEditorStoreApi(): CanvasStoreApi;
|
|
184
235
|
/** Select a value from the nearest canvas store; re-renders when it changes. */
|
|
185
236
|
export declare function useEditorStore<T>(selector: (s: CanvasStore) => T): T;
|
|
237
|
+
/**
|
|
238
|
+
* Like `useEditorStore`, but returns `fallback` instead of throwing when no
|
|
239
|
+
* `CanvasStoreProvider` is above. For presentation-only reads in components
|
|
240
|
+
* that are also rendered on their own (an `FkEdge` in a unit test).
|
|
241
|
+
*/
|
|
242
|
+
export declare function useEditorStoreOr<T>(selector: (s: CanvasStore) => T, fallback: T): T;
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
* Types for React Flow graph nodes and edges.
|
|
3
3
|
*
|
|
4
4
|
* These types define the data payloads for custom React Flow node and edge
|
|
5
|
-
* components. The graph transformer converts
|
|
5
|
+
* components. The graph transformer converts DisplaySubjectArea data into
|
|
6
6
|
* these shapes.
|
|
7
7
|
*/
|
|
8
8
|
import type { Node, Edge } from '@xyflow/react';
|
|
9
|
-
import type { AnnotationColor, Cardinality, ColumnPair, DbtKeyHint, Layer, Meta,
|
|
9
|
+
import type { AnnotationColor, Cardinality, ColumnPair, DbtKeyHint, Layer, Meta, TableLoadError, TableLoadWarning, TableRole, Stage } from '@erd-studio/core';
|
|
10
10
|
import type { LayerConfig } from '@erd-studio/core';
|
|
11
|
-
import type {
|
|
11
|
+
import type { TableDiscrepancy } from '@erd-studio/core';
|
|
12
12
|
import type { PhysicalProvenance } from '@erd-studio/core';
|
|
13
|
-
/** Column data enriched with PK/FK/NK indicators for display in
|
|
13
|
+
/** Column data enriched with PK/FK/NK indicators for display in TableNode. */
|
|
14
14
|
export interface ColumnDisplay {
|
|
15
15
|
name: string;
|
|
16
16
|
dataType: string;
|
|
@@ -30,24 +30,43 @@ export interface ColumnDisplay {
|
|
|
30
30
|
/** What dbt's tests say about the column (editable logical canvas only) — one line of its hover text. */
|
|
31
31
|
dbtKey?: DbtKeyHint;
|
|
32
32
|
}
|
|
33
|
-
/** Data payload for a
|
|
34
|
-
export type
|
|
33
|
+
/** Data payload for a TableNode React Flow node. */
|
|
34
|
+
export type TableNodeData = {
|
|
35
35
|
/** Model name (unique within a domain). */
|
|
36
36
|
modelName: string;
|
|
37
37
|
/**
|
|
38
38
|
* Header label when it differs from `modelName`: the model's table name
|
|
39
39
|
* (`alias`), qualified by schema when another model on the canvas would read
|
|
40
|
-
* the same. See `
|
|
40
|
+
* the same. See `computeTableLabels`.
|
|
41
41
|
*/
|
|
42
42
|
label?: string;
|
|
43
43
|
/** The active design stage. */
|
|
44
44
|
stage: Stage;
|
|
45
45
|
/** Data warehouse layer. */
|
|
46
46
|
layer: Layer;
|
|
47
|
-
/** Database schema the model materializes in (
|
|
47
|
+
/** Database schema the model materializes in (named in the badge's hover card). */
|
|
48
48
|
schema?: string;
|
|
49
49
|
/** Layer configuration for dynamic badge styling (color, abbreviation). */
|
|
50
50
|
layerConfig?: LayerConfig;
|
|
51
|
+
/**
|
|
52
|
+
* The layer the table itself belongs to (`DisplayTable.layer`), when known.
|
|
53
|
+
* The header's badge always names the layer the table lives in: this one,
|
|
54
|
+
* else the diagram's `layer`. A known layer also draws the colour strip.
|
|
55
|
+
*/
|
|
56
|
+
tableLayer?: Layer;
|
|
57
|
+
/** {@link tableLayer}'s config (its colour and abbreviation). */
|
|
58
|
+
tableLayerConfig?: LayerConfig;
|
|
59
|
+
/** Set when {@link tableLayer} is not the diagram's layer: a table this diagram borrows. */
|
|
60
|
+
otherLayer?: true;
|
|
61
|
+
/** The schema as a prefix of the name (`sales.fct_order`): set only when it is not the badge's layer id. */
|
|
62
|
+
shownSchema?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Set when the project has one layer and every table is in it
|
|
65
|
+
* (`isSingleLayerProject`): the layer badge and colour strip are left off.
|
|
66
|
+
*/
|
|
67
|
+
singleLayer?: true;
|
|
68
|
+
/** The warehouse name when it differs from the model name (`alias`), shown after it: `gold_orders as orders`. */
|
|
69
|
+
alias?: string;
|
|
51
70
|
/** Columns to display, enriched with PK/FK flags. */
|
|
52
71
|
columns: ColumnDisplay[];
|
|
53
72
|
/** Whether the node is dimmed (doesn't match current search query). */
|
|
@@ -65,7 +84,7 @@ export type ModelNodeData = {
|
|
|
65
84
|
/** Grain statement — "One row per ___". Shown as subtitle on node. */
|
|
66
85
|
grain?: string;
|
|
67
86
|
/** Model's role in the data warehouse architecture. Shown as badge on node. */
|
|
68
|
-
modelRole?:
|
|
87
|
+
modelRole?: TableRole;
|
|
69
88
|
/** Structured metadata (`meta:`) — shown in the name's hover tip. Absent when empty. */
|
|
70
89
|
meta?: Meta;
|
|
71
90
|
/** Whether this stage is read-only (physical). */
|
|
@@ -93,16 +112,16 @@ export type ModelNodeData = {
|
|
|
93
112
|
* The model's file exists but could not be read (logical stage only): the
|
|
94
113
|
* node shows the error and an "Open file" button instead of "No columns".
|
|
95
114
|
*/
|
|
96
|
-
loadError?:
|
|
115
|
+
loadError?: TableLoadError;
|
|
97
116
|
/**
|
|
98
117
|
* The model's file was read but needs fixing (logical stage only): a key
|
|
99
118
|
* written twice, whose last value is shown (#164). Absent from an older core.
|
|
100
119
|
*/
|
|
101
|
-
loadWarning?:
|
|
120
|
+
loadWarning?: TableLoadWarning;
|
|
102
121
|
/** Whether this model is in stub display mode (PK/NK columns only). */
|
|
103
122
|
isStub: boolean;
|
|
104
123
|
/** Per-model discrepancy data when a cross-stage comparison report is active. */
|
|
105
|
-
discrepancy?:
|
|
124
|
+
discrepancy?: TableDiscrepancy;
|
|
106
125
|
/** The stage currently being viewed (set when discrepancy overlay is active). */
|
|
107
126
|
discrepancySourceStage?: Stage;
|
|
108
127
|
/** The stage being compared against (set when discrepancy overlay is active). */
|
|
@@ -111,14 +130,14 @@ export type ModelNodeData = {
|
|
|
111
130
|
* Index signature required by React Flow's Node generic.
|
|
112
131
|
*
|
|
113
132
|
* It also means an unknown or misspelled key type-checks, and a field written
|
|
114
|
-
* here but never destructured in
|
|
133
|
+
* here but never destructured in TableNode ships as dead payload — which is
|
|
115
134
|
* exactly how `hasRationale` and `modelRole` gained matching dead CSS. Add a
|
|
116
135
|
* field here only together with the code that reads it.
|
|
117
136
|
*/
|
|
118
137
|
[key: string]: unknown;
|
|
119
138
|
};
|
|
120
139
|
/** Typed React Flow node for a semantic model. */
|
|
121
|
-
export type
|
|
140
|
+
export type TableFlowNode = Node<TableNodeData, 'model'>;
|
|
122
141
|
/** Data payload for an FkEdge React Flow edge. */
|
|
123
142
|
export type FkEdgeData = {
|
|
124
143
|
fromModel: string;
|
|
@@ -135,6 +154,11 @@ export type FkEdgeData = {
|
|
|
135
154
|
pairs?: ColumnPair[];
|
|
136
155
|
/** The composite's `compositeKey` name, alongside `pairs`. */
|
|
137
156
|
compositeKey?: string;
|
|
157
|
+
/**
|
|
158
|
+
* The keys contradict its direction (`DisplayRelationship.keysContradict`,
|
|
159
|
+
* #163): drawn with a ⚠ and Turn round, except for viewers.
|
|
160
|
+
*/
|
|
161
|
+
keysContradict?: true;
|
|
138
162
|
/** Stage of the owning domain canvas — drives CSS colour class. */
|
|
139
163
|
stage?: Stage;
|
|
140
164
|
/** Discrepancy status for ghost/extra/mismatch edges. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@erd-studio/renderer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "ERD Studio's React Flow canvas: the entity-relationship diagram renderer shared by the VS Code extension, with a read-only viewer mode.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"repository": {
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"files": [
|
|
38
38
|
"dist",
|
|
39
|
+
"CHANGELOG.md",
|
|
39
40
|
"LICENSE",
|
|
40
41
|
"README.md"
|
|
41
42
|
],
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
"prepack": "npm run build"
|
|
47
48
|
},
|
|
48
49
|
"dependencies": {
|
|
49
|
-
"@erd-studio/core": "0.
|
|
50
|
+
"@erd-studio/core": "0.4.0",
|
|
50
51
|
"zustand": "^5.0.0"
|
|
51
52
|
},
|
|
52
53
|
"peerDependencies": {
|