@dforge-core/diagram 0.0.1
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/LICENSE +21 -0
- package/README.md +45 -0
- package/dist/EntityNode.svelte +167 -0
- package/dist/EntityNode.svelte.d.ts +8 -0
- package/dist/EntityNode.svelte.d.ts.map +1 -0
- package/dist/IconButton.svelte +83 -0
- package/dist/IconButton.svelte.d.ts +13 -0
- package/dist/IconButton.svelte.d.ts.map +1 -0
- package/dist/SimpleDiagram/DiagramDebug.svelte +499 -0
- package/dist/SimpleDiagram/DiagramDebug.svelte.d.ts +4 -0
- package/dist/SimpleDiagram/DiagramDebug.svelte.d.ts.map +1 -0
- package/dist/SimpleDiagram/ModelDiagram.svelte +569 -0
- package/dist/SimpleDiagram/ModelDiagram.svelte.d.ts +18 -0
- package/dist/SimpleDiagram/ModelDiagram.svelte.d.ts.map +1 -0
- package/dist/SimpleDiagram/NOTE.md +14 -0
- package/dist/SimpleDiagram/SimpleDiagram.svelte +755 -0
- package/dist/SimpleDiagram/SimpleDiagram.svelte.d.ts +13 -0
- package/dist/SimpleDiagram/SimpleDiagram.svelte.d.ts.map +1 -0
- package/dist/SimpleDiagram/diagram-geometry.d.ts +33 -0
- package/dist/SimpleDiagram/diagram-geometry.d.ts.map +1 -0
- package/dist/SimpleDiagram/diagram-geometry.js +137 -0
- package/dist/SimpleDiagram/simple-layout.d.ts +27 -0
- package/dist/SimpleDiagram/simple-layout.d.ts.map +1 -0
- package/dist/SimpleDiagram/simple-layout.js +364 -0
- package/dist/WorkspaceMap/ModuleCard.svelte +165 -0
- package/dist/WorkspaceMap/ModuleCard.svelte.d.ts +8 -0
- package/dist/WorkspaceMap/ModuleCard.svelte.d.ts.map +1 -0
- package/dist/WorkspaceMap/WorkspaceMap.svelte +319 -0
- package/dist/WorkspaceMap/WorkspaceMap.svelte.d.ts +12 -0
- package/dist/WorkspaceMap/WorkspaceMap.svelte.d.ts.map +1 -0
- package/dist/WorkspaceMap/workspace-graph.d.ts +18 -0
- package/dist/WorkspaceMap/workspace-graph.d.ts.map +1 -0
- package/dist/WorkspaceMap/workspace-graph.js +168 -0
- package/dist/WorkspaceMap/workspace-types.d.ts +32 -0
- package/dist/WorkspaceMap/workspace-types.d.ts.map +1 -0
- package/dist/WorkspaceMap/workspace-types.js +1 -0
- package/dist/diagram-types.d.ts +47 -0
- package/dist/diagram-types.d.ts.map +1 -0
- package/dist/diagram-types.js +2 -0
- package/dist/edge-routing.d.ts +82 -0
- package/dist/edge-routing.d.ts.map +1 -0
- package/dist/edge-routing.js +388 -0
- package/dist/i18n.d.ts +13 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/i18n.js +20 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/local-storage-sync.d.ts +10 -0
- package/dist/local-storage-sync.d.ts.map +1 -0
- package/dist/local-storage-sync.js +39 -0
- package/dist/model-graph.d.ts +20 -0
- package/dist/model-graph.d.ts.map +1 -0
- package/dist/model-graph.js +100 -0
- package/dist/model-types.d.ts +55 -0
- package/dist/model-types.d.ts.map +1 -0
- package/dist/model-types.js +11 -0
- package/dist/pan-zoom.svelte.d.ts +34 -0
- package/dist/pan-zoom.svelte.d.ts.map +1 -0
- package/dist/pan-zoom.svelte.js +130 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dForge
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# @dforge-core/diagram
|
|
2
|
+
|
|
3
|
+
Entity-relationship and workspace diagram components for [dForge](https://github.com/iash44/dForge-core) models. A standalone Svelte 5 library — it has **no dForge runtime dependencies** (no SDK, no UI kit), so it can be embedded anywhere, including editor extensions.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @dforge-core/diagram
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Svelte 5 is a peer dependency:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install svelte@^5
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Styling (soft dependency)
|
|
18
|
+
|
|
19
|
+
Components render [Bootstrap Icons](https://icons.getbootstrap.com/) glyphs (`bi-*`) and theme via Bootstrap CSS variables (`--bs-body-color`, `--bs-tertiary-bg`, etc.). To match the dForge look, load Bootstrap Icons and a Bootstrap-compatible CSS-variable theme in the host app, or define those variables yourself.
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
```svelte
|
|
24
|
+
<script>
|
|
25
|
+
import { SimpleDiagram, buildGraph } from '@dforge-core/diagram';
|
|
26
|
+
|
|
27
|
+
// `model` is a metadata.getModel response (ModelGetResponse)
|
|
28
|
+
const graph = buildGraph(model);
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<SimpleDiagram {graph} />
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Exports
|
|
35
|
+
|
|
36
|
+
- **Components**: `SimpleDiagram`, `ModelDiagram`, `EntityNode`, `DiagramDebug`, `WorkspaceMap`, `ModuleCard`
|
|
37
|
+
- **Graph building**: `buildGraph`, `buildEntityMap`, `buildWorkspaceGraph`, `getModuleColor`, `MODULE_COLORS`
|
|
38
|
+
- **Layout & routing**: `simpleLayout`, `moduleLayout`, `routeEdge`, `routeAllEdges`, `computeEdgePath`, geometry helpers
|
|
39
|
+
- **Pan/zoom**: `createPanZoom`, `createLocalStorageSync`
|
|
40
|
+
- **i18n**: `setDiagramTranslations`, `getDiagramTranslations`, `DIAGRAM_TRANSLATIONS_EN`
|
|
41
|
+
- **Types**: diagram types plus the metadata model contract (`ModelGetResponse`, `ModelModule`, `ModelEntity`, `ModelConstraint`, `ModelColumn`) — structurally compatible with the dForge API response shape
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
[MIT](./LICENSE)
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ModelColumn } from './model-types';
|
|
3
|
+
import type { EntityNodeData } from './diagram-types';
|
|
4
|
+
import { getDiagramTranslations } from './i18n';
|
|
5
|
+
|
|
6
|
+
let { data }: { data: EntityNodeData } = $props();
|
|
7
|
+
|
|
8
|
+
const t = getDiagramTranslations();
|
|
9
|
+
const label = $derived(data.resLabel || data.entityCd);
|
|
10
|
+
|
|
11
|
+
function getColumnTypeLabel(col: ModelColumn): string {
|
|
12
|
+
if (col.columnType === 'F') return t.col_type_formula;
|
|
13
|
+
if (col.columnType === 'R') {
|
|
14
|
+
const target = col.refEntityId ? data.entityMap.get(col.refEntityId) : null;
|
|
15
|
+
return target ? `→ ${target}` : `→ ${t.col_type_ref}`;
|
|
16
|
+
}
|
|
17
|
+
if (col.columnType === 'S') return `← ${t.col_type_set}`;
|
|
18
|
+
return col.fieldTypeCd || col.baseDatatypeCd;
|
|
19
|
+
}
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<div class="entity-node" style:--module-color={data.moduleColor}>
|
|
23
|
+
<div class="entity-header">
|
|
24
|
+
{#if data.resIcon}
|
|
25
|
+
<i class={data.resIcon}></i>
|
|
26
|
+
{/if}
|
|
27
|
+
<span class="entity-title">{label}</span>
|
|
28
|
+
<span class="entity-module">{data.moduleCd}</span>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<div class="entity-columns">
|
|
32
|
+
{#each data.columns as col (col.columnCd)}
|
|
33
|
+
<div
|
|
34
|
+
class="entity-col-row"
|
|
35
|
+
class:pk-row={col.isPk}
|
|
36
|
+
class:fk-row={col.columnType === 'R'}
|
|
37
|
+
class:formula-row={col.columnType === 'F'}
|
|
38
|
+
class:set-row={col.columnType === 'S'}
|
|
39
|
+
>
|
|
40
|
+
<span class="col-indicators">
|
|
41
|
+
{#if col.isPk}<span class="col-badge pk">PK</span>{/if}
|
|
42
|
+
{#if col.columnType === 'F'}<span class="col-badge formula">F</span>{/if}
|
|
43
|
+
{#if col.columnType === 'S'}<span class="col-badge set">S</span>{/if}
|
|
44
|
+
</span>
|
|
45
|
+
<span class="col-name">{col.resLabel || col.columnCd}</span>
|
|
46
|
+
<span class="col-type">{getColumnTypeLabel(col)}</span>
|
|
47
|
+
</div>
|
|
48
|
+
{/each}
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<style>
|
|
53
|
+
.entity-node {
|
|
54
|
+
background: var(--bs-body-bg, #fff);
|
|
55
|
+
border: 2px solid var(--module-color, #6c757d);
|
|
56
|
+
border-radius: 6px;
|
|
57
|
+
min-width: 220px;
|
|
58
|
+
max-width: 320px;
|
|
59
|
+
font-size: 0.75rem;
|
|
60
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
61
|
+
user-select: none;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.entity-header {
|
|
65
|
+
display: flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
gap: 0.35rem;
|
|
68
|
+
padding: 0.35rem 0.5rem;
|
|
69
|
+
background: var(--module-color, #6c757d);
|
|
70
|
+
color: #fff;
|
|
71
|
+
border-radius: 3px 3px 0 0;
|
|
72
|
+
font-weight: 600;
|
|
73
|
+
font-size: 0.8rem;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.entity-title {
|
|
77
|
+
flex: 1;
|
|
78
|
+
overflow: hidden;
|
|
79
|
+
text-overflow: ellipsis;
|
|
80
|
+
white-space: nowrap;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.entity-module {
|
|
84
|
+
font-size: 0.65rem;
|
|
85
|
+
opacity: 0.8;
|
|
86
|
+
font-weight: 400;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.entity-columns {
|
|
90
|
+
display: flex;
|
|
91
|
+
flex-direction: column;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.entity-col-row {
|
|
95
|
+
display: flex;
|
|
96
|
+
align-items: center;
|
|
97
|
+
gap: 0.3rem;
|
|
98
|
+
padding: 0.15rem 0.5rem;
|
|
99
|
+
border-bottom: 1px solid var(--bs-border-color-translucent, rgba(0, 0, 0, 0.08));
|
|
100
|
+
position: relative;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.entity-col-row:last-child {
|
|
104
|
+
border-bottom: none;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.entity-col-row.pk-row {
|
|
108
|
+
background-color: rgba(var(--module-color-rgb, 108, 117, 125), 0.06);
|
|
109
|
+
font-weight: 600;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.entity-col-row.fk-row {
|
|
113
|
+
color: var(--bs-info, #0dcaf0);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.entity-col-row.formula-row {
|
|
117
|
+
font-style: italic;
|
|
118
|
+
opacity: 0.85;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.entity-col-row.set-row {
|
|
122
|
+
opacity: 0.7;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.col-indicators {
|
|
126
|
+
display: flex;
|
|
127
|
+
gap: 0.15rem;
|
|
128
|
+
flex-shrink: 0;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.col-badge {
|
|
132
|
+
font-size: 0.55rem;
|
|
133
|
+
font-weight: 700;
|
|
134
|
+
padding: 0 0.2rem;
|
|
135
|
+
border-radius: 2px;
|
|
136
|
+
line-height: 1.3;
|
|
137
|
+
text-transform: uppercase;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.col-badge.pk {
|
|
141
|
+
background: var(--module-color, #6c757d);
|
|
142
|
+
color: #fff;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.col-badge.formula {
|
|
146
|
+
background: var(--bs-warning-bg-subtle, #fff3cd);
|
|
147
|
+
color: var(--bs-warning-text-emphasis, #664d03);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.col-badge.set {
|
|
151
|
+
background: var(--bs-secondary-bg-subtle, #e2e3e5);
|
|
152
|
+
color: var(--bs-secondary-text-emphasis, #41464b);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.col-name {
|
|
156
|
+
flex: 1;
|
|
157
|
+
overflow: hidden;
|
|
158
|
+
text-overflow: ellipsis;
|
|
159
|
+
white-space: nowrap;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.col-type {
|
|
163
|
+
flex-shrink: 0;
|
|
164
|
+
color: var(--bs-secondary-color, #6c757d);
|
|
165
|
+
font-size: 0.65rem;
|
|
166
|
+
}
|
|
167
|
+
</style>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { EntityNodeData } from './diagram-types';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
data: EntityNodeData;
|
|
4
|
+
};
|
|
5
|
+
declare const EntityNode: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
6
|
+
type EntityNode = ReturnType<typeof EntityNode>;
|
|
7
|
+
export default EntityNode;
|
|
8
|
+
//# sourceMappingURL=EntityNode.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityNode.svelte.d.ts","sourceRoot":"","sources":["../src/lib/EntityNode.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGrD,KAAK,gBAAgB,GAAI;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,CAAC;AAkDnD,QAAA,MAAM,UAAU,sDAAwC,CAAC;AACzD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAChD,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Self-contained icon button used by the diagram toolbars.
|
|
3
|
+
|
|
4
|
+
Deliberately minimal (and independent of `@dforge/ui`) so this package
|
|
5
|
+
can be published standalone. Renders a Bootstrap Icons glyph, so the
|
|
6
|
+
consuming app must load the `bootstrap-icons` font/CSS; colors come from
|
|
7
|
+
Bootstrap CSS variables (`--bs-*`) for theme consistency.
|
|
8
|
+
-->
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
interface Props {
|
|
11
|
+
/** Bootstrap Icons class name, e.g. `bi-plus-lg`. */
|
|
12
|
+
icon: string;
|
|
13
|
+
title: string;
|
|
14
|
+
onclick?: (e: MouseEvent) => void;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
size?: 'sm' | 'md' | 'lg';
|
|
17
|
+
class?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let {
|
|
21
|
+
icon,
|
|
22
|
+
title,
|
|
23
|
+
onclick,
|
|
24
|
+
disabled = false,
|
|
25
|
+
size = 'sm',
|
|
26
|
+
class: cls = '',
|
|
27
|
+
}: Props = $props();
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<button
|
|
31
|
+
type="button"
|
|
32
|
+
class="icon-btn icon-btn-{size} {cls}"
|
|
33
|
+
{title}
|
|
34
|
+
aria-label={title}
|
|
35
|
+
{onclick}
|
|
36
|
+
{disabled}
|
|
37
|
+
>
|
|
38
|
+
<i class="bi {icon}"></i>
|
|
39
|
+
</button>
|
|
40
|
+
|
|
41
|
+
<style>
|
|
42
|
+
.icon-btn {
|
|
43
|
+
position: relative;
|
|
44
|
+
display: inline-flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
padding: 0;
|
|
48
|
+
border: none;
|
|
49
|
+
background: none;
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
color: var(--bs-secondary-color);
|
|
52
|
+
border-radius: 4px;
|
|
53
|
+
line-height: 1;
|
|
54
|
+
text-decoration: none;
|
|
55
|
+
}
|
|
56
|
+
.icon-btn:hover {
|
|
57
|
+
background: var(--bs-tertiary-bg);
|
|
58
|
+
color: var(--bs-body-color);
|
|
59
|
+
}
|
|
60
|
+
.icon-btn:disabled {
|
|
61
|
+
opacity: 0.4;
|
|
62
|
+
cursor: default;
|
|
63
|
+
background: none;
|
|
64
|
+
color: var(--bs-secondary-color);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* Size tiers */
|
|
68
|
+
.icon-btn-sm {
|
|
69
|
+
width: 18px;
|
|
70
|
+
height: 18px;
|
|
71
|
+
font-size: 0.85em;
|
|
72
|
+
}
|
|
73
|
+
.icon-btn-md {
|
|
74
|
+
width: 1.5rem;
|
|
75
|
+
height: 1.5rem;
|
|
76
|
+
font-size: 1rem;
|
|
77
|
+
}
|
|
78
|
+
.icon-btn-lg {
|
|
79
|
+
width: 1.75rem;
|
|
80
|
+
height: 1.75rem;
|
|
81
|
+
font-size: 1.125rem;
|
|
82
|
+
}
|
|
83
|
+
</style>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
/** Bootstrap Icons class name, e.g. `bi-plus-lg`. */
|
|
3
|
+
icon: string;
|
|
4
|
+
title: string;
|
|
5
|
+
onclick?: (e: MouseEvent) => void;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
size?: 'sm' | 'md' | 'lg';
|
|
8
|
+
class?: string;
|
|
9
|
+
}
|
|
10
|
+
declare const IconButton: import("svelte").Component<Props, {}, "">;
|
|
11
|
+
type IconButton = ReturnType<typeof IconButton>;
|
|
12
|
+
export default IconButton;
|
|
13
|
+
//# sourceMappingURL=IconButton.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IconButton.svelte.d.ts","sourceRoot":"","sources":["../src/lib/IconButton.svelte.ts"],"names":[],"mappings":"AAGC,UAAU,KAAK;IACd,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAuBF,QAAA,MAAM,UAAU,2CAAwC,CAAC;AACzD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAChD,eAAe,UAAU,CAAC"}
|