@grafloria/element 0.1.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/package.json +41 -0
- package/src/index.d.ts +87 -0
- package/src/index.js +547 -0
- package/src/index.js.map +1 -0
- package/src/lib/dashboard-kit/dashboard.d.ts +345 -0
- package/src/lib/dashboard-kit/dashboard.js +594 -0
- package/src/lib/dashboard-kit/dashboard.js.map +1 -0
- package/src/lib/dashboard-kit/grid-binder.d.ts +277 -0
- package/src/lib/dashboard-kit/grid-binder.js +1635 -0
- package/src/lib/dashboard-kit/grid-binder.js.map +1 -0
- package/src/lib/dashboard-kit/grid-mapping.d.ts +141 -0
- package/src/lib/dashboard-kit/grid-mapping.js +176 -0
- package/src/lib/dashboard-kit/grid-mapping.js.map +1 -0
- package/src/lib/dashboard-kit/index.d.ts +5 -0
- package/src/lib/dashboard-kit/index.js +33 -0
- package/src/lib/dashboard-kit/index.js.map +1 -0
- package/src/lib/dashboard-kit/styles.d.ts +25 -0
- package/src/lib/dashboard-kit/styles.js +203 -0
- package/src/lib/dashboard-kit/styles.js.map +1 -0
- package/src/lib/dashboard-kit/widgets.d.ts +112 -0
- package/src/lib/dashboard-kit/widgets.js +389 -0
- package/src/lib/dashboard-kit/widgets.js.map +1 -0
- package/src/lib/diagram-kit/card.d.ts +75 -0
- package/src/lib/diagram-kit/card.js +209 -0
- package/src/lib/diagram-kit/card.js.map +1 -0
- package/src/lib/diagram-kit/editing.d.ts +54 -0
- package/src/lib/diagram-kit/editing.js +289 -0
- package/src/lib/diagram-kit/editing.js.map +1 -0
- package/src/lib/diagram-kit/er.d.ts +73 -0
- package/src/lib/diagram-kit/er.js +163 -0
- package/src/lib/diagram-kit/er.js.map +1 -0
- package/src/lib/diagram-kit/handles.d.ts +181 -0
- package/src/lib/diagram-kit/handles.js +325 -0
- package/src/lib/diagram-kit/handles.js.map +1 -0
- package/src/lib/diagram-kit/index.d.ts +8 -0
- package/src/lib/diagram-kit/index.js +38 -0
- package/src/lib/diagram-kit/index.js.map +1 -0
- package/src/lib/diagram-kit/rows.d.ts +53 -0
- package/src/lib/diagram-kit/rows.js +147 -0
- package/src/lib/diagram-kit/rows.js.map +1 -0
- package/src/lib/diagram-kit/styles.d.ts +18 -0
- package/src/lib/diagram-kit/styles.js +114 -0
- package/src/lib/diagram-kit/styles.js.map +1 -0
- package/src/lib/diagram-kit/uml.d.ts +59 -0
- package/src/lib/diagram-kit/uml.js +138 -0
- package/src/lib/diagram-kit/uml.js.map +1 -0
- package/src/lib/diagram-kit/update.d.ts +133 -0
- package/src/lib/diagram-kit/update.js +251 -0
- package/src/lib/diagram-kit/update.js.map +1 -0
- package/src/lib/grafloria-flow-element.d.ts +48 -0
- package/src/lib/grafloria-flow-element.js +271 -0
- package/src/lib/grafloria-flow-element.js.map +1 -0
- package/src/lib/grafloria.d.ts +61 -0
- package/src/lib/grafloria.js +72 -0
- package/src/lib/grafloria.js.map +1 -0
- package/src/lib/load.d.ts +72 -0
- package/src/lib/load.js +255 -0
- package/src/lib/load.js.map +1 -0
- package/src/lib/node-type-registry.d.ts +39 -0
- package/src/lib/node-type-registry.js +50 -0
- package/src/lib/node-type-registry.js.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uml.js","sourceRoot":"","sources":["../../../../../../libs/element/src/lib/diagram-kit/uml.ts"],"names":[],"mappings":";;AA0IA,gCA0EC;AApND;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qCAAkD;AAClD,iCAA6C;AAC7C,iCAA2D;AAC3D,uCAA4C;AAE5C,MAAM,aAAa,GAAG,GAAG,CAAC;AAoE1B,MAAM,MAAM,GAAG,SAAS,CAAC;AACzB,MAAM,IAAI,GAAG,KAAK,CAAC;AAEnB;;;;GAIG;AACH,SAAS,YAAY,CAAC,IAAqB;IACzC,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,K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AG,uBAAH,GAAG,CAAkG,QAAQ,mDAAI,CAAC;QACjI,IAAI,CAAC,KAAK;YAAE,OAAO;QACnB,IAAI,KAAK,GAAG,KAAK,CAAC;QAClB,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;YACtB,IAAI,CAAC,GAAG,CAAC,YAAY;gBAAE,OAAO;YAC9B,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAE,KAAK,CAAC,CAAC,CAAoB,CAAC,EAAE,CAAC,CAAC;YAC5D,IAAI,CAAC,IAAI;gBAAE,OAAO;YAClB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;YAClD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;YAChD,KAAK,GAAG,IAAI,CAAC;QACf,CAAC,CAAC,CAAC;QACH,IAAI,KAAK;YAAE,MAAC,GAAkC,aAAlC,GAAG,uBAAH,GAAG,CAAiC,SAAS,mDAAI,CAAC;IAChE,CAAC,CAAC;IAEF,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Live editing — `updateEntity` / `updateClass` mutate a rendered kit card in
|
|
3
|
+
* place (P3, the foundation the in-canvas editing chrome is built on).
|
|
4
|
+
*
|
|
5
|
+
* A delta changes the DATA (a table's name, its columns; a class's name,
|
|
6
|
+
* attributes, methods, width/height) and this module:
|
|
7
|
+
* 1. reads the stored spec (`kitEntity` / `kitClass`) — the source of truth;
|
|
8
|
+
* 2. applies the delta to a NEW spec (the caller's objects are never mutated,
|
|
9
|
+
* so undo can restore the old one cleanly);
|
|
10
|
+
* 3. regenerates the card html from the SAME builder er.ts/uml.ts use
|
|
11
|
+
* (`card.ts`), so an edited card is identical to a freshly-built one;
|
|
12
|
+
* 4. recomputes the node size;
|
|
13
|
+
* 5. RECONCILES the field ports — every port pinned to a surviving column
|
|
14
|
+
* moves to that column's new row (`erRowCenterY`), ports on a removed
|
|
15
|
+
* column are dropped along with their edges. Port ids never change, so an
|
|
16
|
+
* edge stays glued to its row across inserts/removes/reorders (the exact
|
|
17
|
+
* failure this solves: a port frozen at the old row while the rows shifted
|
|
18
|
+
* under it);
|
|
19
|
+
* 6. repaints — as ONE undoable step.
|
|
20
|
+
*
|
|
21
|
+
* ONE UNDO STEP. The change is applied through `api.getEngine().commandManager`
|
|
22
|
+
* — the same public seam `renderer/ext/public-api.ts` uses — wrapped in a
|
|
23
|
+
* single kit-local {@link Command}. There is no `SetNodeMetadataCommand` in the
|
|
24
|
+
* engine (the html/kit-spec mutation has no built-in command), so rather than
|
|
25
|
+
* reach into engine internals or compose a half-undoable macro, the whole edit
|
|
26
|
+
* lives in one Command subclass here (subclassing `Command` is the engine's
|
|
27
|
+
* intended extension point — every basic command does it). When no engine is
|
|
28
|
+
* present the edit still applies, just non-undoably.
|
|
29
|
+
*/
|
|
30
|
+
import type { ErColumn } from './er';
|
|
31
|
+
/** What an ER table edit can change. Omitted fields are left as they were. */
|
|
32
|
+
export interface ErEntityDelta {
|
|
33
|
+
name?: string;
|
|
34
|
+
width?: number;
|
|
35
|
+
height?: number;
|
|
36
|
+
/**
|
|
37
|
+
* The NEW full column list. Survivors are matched to the old columns to move
|
|
38
|
+
* their ports (object identity → name → positional remainder), so a rename,
|
|
39
|
+
* a retype, a reorder, an insert and a delete are all understood without the
|
|
40
|
+
* caller preserving object references. See {@link matchColumns}.
|
|
41
|
+
*/
|
|
42
|
+
columns?: ErColumn[];
|
|
43
|
+
}
|
|
44
|
+
/** What a UML class edit can change. */
|
|
45
|
+
export interface UmlClassDelta {
|
|
46
|
+
name?: string;
|
|
47
|
+
stereotype?: string;
|
|
48
|
+
abstract?: boolean;
|
|
49
|
+
width?: number;
|
|
50
|
+
height?: number;
|
|
51
|
+
attributes?: string[];
|
|
52
|
+
methods?: string[];
|
|
53
|
+
}
|
|
54
|
+
interface LivePort {
|
|
55
|
+
id: string;
|
|
56
|
+
offset?: {
|
|
57
|
+
x: number;
|
|
58
|
+
y: number;
|
|
59
|
+
};
|
|
60
|
+
alignment?: {
|
|
61
|
+
side?: string;
|
|
62
|
+
};
|
|
63
|
+
layout?: {
|
|
64
|
+
strategy?: string;
|
|
65
|
+
args?: {
|
|
66
|
+
units?: string;
|
|
67
|
+
x?: number;
|
|
68
|
+
y?: number;
|
|
69
|
+
dy?: number;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
serialize(): Record<string, unknown>;
|
|
73
|
+
setOffset(o: {
|
|
74
|
+
x: number;
|
|
75
|
+
y: number;
|
|
76
|
+
}): void;
|
|
77
|
+
}
|
|
78
|
+
interface LiveLink {
|
|
79
|
+
id: string;
|
|
80
|
+
sourcePortId?: string;
|
|
81
|
+
targetPortId?: string;
|
|
82
|
+
serialize(): Record<string, unknown>;
|
|
83
|
+
}
|
|
84
|
+
interface LiveNode {
|
|
85
|
+
size: {
|
|
86
|
+
width: number;
|
|
87
|
+
height: number;
|
|
88
|
+
};
|
|
89
|
+
getMetadata(key: string): unknown;
|
|
90
|
+
setMetadata(key: string, value: unknown): void;
|
|
91
|
+
setSize(w: number, h: number): void;
|
|
92
|
+
getPorts(): LivePort[];
|
|
93
|
+
getPort(id: string): LivePort | undefined;
|
|
94
|
+
addPort(p: unknown): void;
|
|
95
|
+
removePort(id: string): unknown;
|
|
96
|
+
}
|
|
97
|
+
interface LiveModel {
|
|
98
|
+
getNode(id: string): LiveNode | undefined;
|
|
99
|
+
getLinks(): LiveLink[];
|
|
100
|
+
getLink(id: string): LiveLink | undefined;
|
|
101
|
+
removeLink(id: string): unknown;
|
|
102
|
+
addLink(l: unknown): void;
|
|
103
|
+
}
|
|
104
|
+
interface KitApi {
|
|
105
|
+
getModel?: () => LiveModel;
|
|
106
|
+
getEngine?: () => {
|
|
107
|
+
commandManager?: {
|
|
108
|
+
execute: (c: unknown) => Promise<void>;
|
|
109
|
+
};
|
|
110
|
+
} | undefined;
|
|
111
|
+
renderNow?: () => void;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Edit a rendered ER table in place. `delta` may change the name, the column
|
|
115
|
+
* list (add / remove / reorder / rename / retype), and the width/height. Field
|
|
116
|
+
* ports and their edges are reconciled so the diagram stays correct, as ONE
|
|
117
|
+
* undoable step.
|
|
118
|
+
*
|
|
119
|
+
* @returns whether the node existed and the edit was applied.
|
|
120
|
+
*/
|
|
121
|
+
export declare function updateEntity(api: KitApi, entityId: string, delta: ErEntityDelta): Promise<boolean>;
|
|
122
|
+
/**
|
|
123
|
+
* Edit a rendered UML class in place. `delta` may change the name, stereotype,
|
|
124
|
+
* abstract flag, attributes, methods, and width/height. One undoable step.
|
|
125
|
+
*/
|
|
126
|
+
export declare function updateClass(api: KitApi, classId: string, delta: UmlClassDelta): Promise<boolean>;
|
|
127
|
+
/** Append a column (immutably) — returns the new column array. */
|
|
128
|
+
export declare function addColumnAt(columns: ErColumn[], column: ErColumn, at?: number): ErColumn[];
|
|
129
|
+
/** Remove the column at `index` — returns the new column array. */
|
|
130
|
+
export declare function removeColumnAt(columns: ErColumn[], index: number): ErColumn[];
|
|
131
|
+
/** Rename the column at `index` — returns a new array with a NEW object there. */
|
|
132
|
+
export declare function renameColumnAt(columns: ErColumn[], index: number, name: string): ErColumn[];
|
|
133
|
+
export {};
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Live editing — `updateEntity` / `updateClass` mutate a rendered kit card in
|
|
4
|
+
* place (P3, the foundation the in-canvas editing chrome is built on).
|
|
5
|
+
*
|
|
6
|
+
* A delta changes the DATA (a table's name, its columns; a class's name,
|
|
7
|
+
* attributes, methods, width/height) and this module:
|
|
8
|
+
* 1. reads the stored spec (`kitEntity` / `kitClass`) — the source of truth;
|
|
9
|
+
* 2. applies the delta to a NEW spec (the caller's objects are never mutated,
|
|
10
|
+
* so undo can restore the old one cleanly);
|
|
11
|
+
* 3. regenerates the card html from the SAME builder er.ts/uml.ts use
|
|
12
|
+
* (`card.ts`), so an edited card is identical to a freshly-built one;
|
|
13
|
+
* 4. recomputes the node size;
|
|
14
|
+
* 5. RECONCILES the field ports — every port pinned to a surviving column
|
|
15
|
+
* moves to that column's new row (`erRowCenterY`), ports on a removed
|
|
16
|
+
* column are dropped along with their edges. Port ids never change, so an
|
|
17
|
+
* edge stays glued to its row across inserts/removes/reorders (the exact
|
|
18
|
+
* failure this solves: a port frozen at the old row while the rows shifted
|
|
19
|
+
* under it);
|
|
20
|
+
* 6. repaints — as ONE undoable step.
|
|
21
|
+
*
|
|
22
|
+
* ONE UNDO STEP. The change is applied through `api.getEngine().commandManager`
|
|
23
|
+
* — the same public seam `renderer/ext/public-api.ts` uses — wrapped in a
|
|
24
|
+
* single kit-local {@link Command}. There is no `SetNodeMetadataCommand` in the
|
|
25
|
+
* engine (the html/kit-spec mutation has no built-in command), so rather than
|
|
26
|
+
* reach into engine internals or compose a half-undoable macro, the whole edit
|
|
27
|
+
* lives in one Command subclass here (subclassing `Command` is the engine's
|
|
28
|
+
* intended extension point — every basic command does it). When no engine is
|
|
29
|
+
* present the edit still applies, just non-undoably.
|
|
30
|
+
*/
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.updateEntity = updateEntity;
|
|
33
|
+
exports.updateClass = updateClass;
|
|
34
|
+
exports.addColumnAt = addColumnAt;
|
|
35
|
+
exports.removeColumnAt = removeColumnAt;
|
|
36
|
+
exports.renameColumnAt = renameColumnAt;
|
|
37
|
+
const tslib_1 = require("tslib");
|
|
38
|
+
const engine_1 = require("@grafloria/engine");
|
|
39
|
+
const card_1 = require("./card");
|
|
40
|
+
/**
|
|
41
|
+
* The single undoable edit. Captures the card's whole before-state on first
|
|
42
|
+
* execute and restores it on undo, so an edit — however many rows and edges it
|
|
43
|
+
* touched — is one Ctrl+Z.
|
|
44
|
+
*/
|
|
45
|
+
class UpdateCardCommand extends engine_1.Command {
|
|
46
|
+
constructor(nodeId, kind, build) {
|
|
47
|
+
super(kind === 'er' ? 'Edit table' : 'Edit class');
|
|
48
|
+
this.nodeId = nodeId;
|
|
49
|
+
this.kind = kind;
|
|
50
|
+
this.build = build;
|
|
51
|
+
this.captured = false;
|
|
52
|
+
}
|
|
53
|
+
execute(context) {
|
|
54
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
55
|
+
const model = context.diagram;
|
|
56
|
+
const node = model.getNode(this.nodeId);
|
|
57
|
+
if (!node)
|
|
58
|
+
return;
|
|
59
|
+
const kitKey = this.kind === 'er' ? 'kitEntity' : 'kitClass';
|
|
60
|
+
const oldKit = ((_a = node.getMetadata(kitKey)) !== null && _a !== void 0 ? _a : {});
|
|
61
|
+
if (!this.captured) {
|
|
62
|
+
this.captured = true;
|
|
63
|
+
this.before = {
|
|
64
|
+
html: node.getMetadata('html'),
|
|
65
|
+
kit: oldKit,
|
|
66
|
+
size: Object.assign({}, node.size),
|
|
67
|
+
ports: node.getPorts().map((p) => p.serialize()),
|
|
68
|
+
links: [],
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const result = this.build(oldKit);
|
|
72
|
+
const newWidth = (_b = result.width) !== null && _b !== void 0 ? _b : node.size.width;
|
|
73
|
+
const removedLinks = [];
|
|
74
|
+
if (this.kind === 'er') {
|
|
75
|
+
const oldCols = ((_c = oldKit['columns']) !== null && _c !== void 0 ? _c : []);
|
|
76
|
+
const newCols = ((_d = result.newKit['columns']) !== null && _d !== void 0 ? _d : []);
|
|
77
|
+
const map = (0, card_1.matchColumns)(oldCols, newCols);
|
|
78
|
+
for (const port of [...node.getPorts()]) {
|
|
79
|
+
const args = (_e = port.layout) === null || _e === void 0 ? void 0 : _e.args;
|
|
80
|
+
if (((_f = port.layout) === null || _f === void 0 ? void 0 : _f.strategy) !== 'absolute' || !args || args.units !== 'px' || args.y == null)
|
|
81
|
+
continue;
|
|
82
|
+
const oldIdx = (0, card_1.rowIndexFromY)(args.y);
|
|
83
|
+
if (oldIdx < 0 || oldIdx >= oldCols.length)
|
|
84
|
+
continue; // not a row-pinned field port
|
|
85
|
+
const newIdx = map.get(oldIdx);
|
|
86
|
+
if (newIdx === undefined) {
|
|
87
|
+
// The column is gone — drop the port and every edge riding it.
|
|
88
|
+
for (const link of model.getLinks()) {
|
|
89
|
+
if (link.sourcePortId === port.id || link.targetPortId === port.id)
|
|
90
|
+
removedLinks.push(link.serialize());
|
|
91
|
+
}
|
|
92
|
+
for (const link of model.getLinks().filter((l) => l.sourcePortId === port.id || l.targetPortId === port.id)) {
|
|
93
|
+
model.removeLink(link.id);
|
|
94
|
+
}
|
|
95
|
+
node.removePort(port.id);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
// Move the port to its column's NEW row; keep the ±dy spread. x tracks
|
|
99
|
+
// the (possibly changed) width by side, so a widened table stays pinned.
|
|
100
|
+
args.y = (0, card_1.erRowCenterY)(newIdx);
|
|
101
|
+
const side = (_g = port.alignment) === null || _g === void 0 ? void 0 : _g.side;
|
|
102
|
+
args.x = side === 'left' ? 0 : side === 'right' ? newWidth : newWidth / 2;
|
|
103
|
+
// A nested-arg mutation is not tracked — nudge the port so the model
|
|
104
|
+
// marks it dirty and the renderer repositions it this frame.
|
|
105
|
+
port.setOffset(Object.assign({}, ((_h = port.offset) !== null && _h !== void 0 ? _h : { x: 0, y: 0 })));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
node.setMetadata('html', { content: result.content, interactive: true });
|
|
110
|
+
node.setMetadata(kitKey, result.newKit);
|
|
111
|
+
node.setSize(newWidth, result.height);
|
|
112
|
+
if (this.before)
|
|
113
|
+
this.before.links = removedLinks;
|
|
114
|
+
}
|
|
115
|
+
undo(context) {
|
|
116
|
+
var _a;
|
|
117
|
+
const model = context.diagram;
|
|
118
|
+
const node = model.getNode(this.nodeId);
|
|
119
|
+
if (!node || !this.before)
|
|
120
|
+
return;
|
|
121
|
+
node.setMetadata('html', this.before.html);
|
|
122
|
+
node.setMetadata(this.kind === 'er' ? 'kitEntity' : 'kitClass', this.before.kit);
|
|
123
|
+
node.setSize(this.before.size.width, this.before.size.height);
|
|
124
|
+
const beforeIds = new Set(this.before.ports.map((p) => p['id']));
|
|
125
|
+
for (const p of [...node.getPorts()])
|
|
126
|
+
if (!beforeIds.has(p.id))
|
|
127
|
+
node.removePort(p.id);
|
|
128
|
+
for (const sp of this.before.ports) {
|
|
129
|
+
const live = node.getPort(sp['id']);
|
|
130
|
+
if (live) {
|
|
131
|
+
live.layout = sp['layout'];
|
|
132
|
+
live.setOffset(Object.assign({}, ((_a = sp['offset']) !== null && _a !== void 0 ? _a : { x: 0, y: 0 })));
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
node.addPort(engine_1.PortModel.fromJSON(sp));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
for (const sl of this.before.links) {
|
|
139
|
+
if (!model.getLink(sl['id']))
|
|
140
|
+
model.addLink(engine_1.LinkModel.fromJSON(sl));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
canExecute(context) {
|
|
144
|
+
var _a;
|
|
145
|
+
return !!((_a = context.diagram) === null || _a === void 0 ? void 0 : _a.getNode(this.nodeId));
|
|
146
|
+
}
|
|
147
|
+
serialize() {
|
|
148
|
+
return { id: this.id, name: this.name, timestamp: this.timestamp, data: { nodeId: this.nodeId, kind: this.kind } };
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/** Route a build through the engine's command stack (one undo step) or apply it directly. */
|
|
152
|
+
function runUpdate(api, nodeId, kind, build) {
|
|
153
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
var _a, _b, _c, _d, _e;
|
|
155
|
+
const model = (_a = api.getModel) === null || _a === void 0 ? void 0 : _a.call(api);
|
|
156
|
+
const node = (_b = model === null || model === void 0 ? void 0 : model.getNode) === null || _b === void 0 ? void 0 : _b.call(model, nodeId);
|
|
157
|
+
if (!model || !node)
|
|
158
|
+
return false;
|
|
159
|
+
const command = new UpdateCardCommand(nodeId, kind, build);
|
|
160
|
+
const cm = (_d = (_c = api.getEngine) === null || _c === void 0 ? void 0 : _c.call(api)) === null || _d === void 0 ? void 0 : _d.commandManager;
|
|
161
|
+
if (cm === null || cm === void 0 ? void 0 : cm.execute) {
|
|
162
|
+
yield cm.execute(command); // ONE undoable step (Command enters history once)
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
command.execute({ diagram: model }); // no engine — apply, non-undoably
|
|
166
|
+
}
|
|
167
|
+
(_e = api.renderNow) === null || _e === void 0 ? void 0 : _e.call(api);
|
|
168
|
+
return true;
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
const isEditable = (node) => (node === null || node === void 0 ? void 0 : node.getMetadata('kitEditable')) === true;
|
|
172
|
+
/**
|
|
173
|
+
* Edit a rendered ER table in place. `delta` may change the name, the column
|
|
174
|
+
* list (add / remove / reorder / rename / retype), and the width/height. Field
|
|
175
|
+
* ports and their edges are reconciled so the diagram stays correct, as ONE
|
|
176
|
+
* undoable step.
|
|
177
|
+
*
|
|
178
|
+
* @returns whether the node existed and the edit was applied.
|
|
179
|
+
*/
|
|
180
|
+
function updateEntity(api, entityId, delta) {
|
|
181
|
+
var _a, _b, _c;
|
|
182
|
+
const editable = isEditable((_c = (_b = (_a = api.getModel) === null || _a === void 0 ? void 0 : _a.call(api)) === null || _b === void 0 ? void 0 : _b.getNode) === null || _c === void 0 ? void 0 : _c.call(_b, entityId));
|
|
183
|
+
const build = (oldKit) => {
|
|
184
|
+
const newEntity = Object.assign({}, oldKit);
|
|
185
|
+
if (delta.name !== undefined)
|
|
186
|
+
newEntity.name = delta.name;
|
|
187
|
+
if (delta.width !== undefined)
|
|
188
|
+
newEntity.width = delta.width;
|
|
189
|
+
if (delta.height !== undefined)
|
|
190
|
+
newEntity.height = delta.height;
|
|
191
|
+
if (delta.columns !== undefined)
|
|
192
|
+
newEntity.columns = delta.columns;
|
|
193
|
+
return {
|
|
194
|
+
newKit: newEntity,
|
|
195
|
+
content: (0, card_1.entityCardContent)(newEntity, editable),
|
|
196
|
+
height: (0, card_1.entityAutoHeight)(newEntity, editable),
|
|
197
|
+
width: newEntity.width,
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
return runUpdate(api, entityId, 'er', build);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Edit a rendered UML class in place. `delta` may change the name, stereotype,
|
|
204
|
+
* abstract flag, attributes, methods, and width/height. One undoable step.
|
|
205
|
+
*/
|
|
206
|
+
function updateClass(api, classId, delta) {
|
|
207
|
+
var _a, _b, _c;
|
|
208
|
+
const editable = isEditable((_c = (_b = (_a = api.getModel) === null || _a === void 0 ? void 0 : _a.call(api)) === null || _b === void 0 ? void 0 : _b.getNode) === null || _c === void 0 ? void 0 : _c.call(_b, classId));
|
|
209
|
+
const build = (oldKit) => {
|
|
210
|
+
const newClass = Object.assign({}, oldKit);
|
|
211
|
+
if (delta.name !== undefined)
|
|
212
|
+
newClass.name = delta.name;
|
|
213
|
+
if (delta.stereotype !== undefined)
|
|
214
|
+
newClass.stereotype = delta.stereotype;
|
|
215
|
+
if (delta.abstract !== undefined)
|
|
216
|
+
newClass.abstract = delta.abstract;
|
|
217
|
+
if (delta.width !== undefined)
|
|
218
|
+
newClass.width = delta.width;
|
|
219
|
+
if (delta.height !== undefined)
|
|
220
|
+
newClass.height = delta.height;
|
|
221
|
+
if (delta.attributes !== undefined)
|
|
222
|
+
newClass.attributes = delta.attributes;
|
|
223
|
+
if (delta.methods !== undefined)
|
|
224
|
+
newClass.methods = delta.methods;
|
|
225
|
+
return {
|
|
226
|
+
newKit: newClass,
|
|
227
|
+
content: (0, card_1.classCardContent)(newClass, editable),
|
|
228
|
+
height: (0, card_1.classAutoHeight)(newClass, editable),
|
|
229
|
+
width: newClass.width,
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
return runUpdate(api, classId, 'uml', build);
|
|
233
|
+
}
|
|
234
|
+
// -- small column helpers, for the editing chrome and embedders --------------
|
|
235
|
+
/** Append a column (immutably) — returns the new column array. */
|
|
236
|
+
function addColumnAt(columns, column, at = columns.length) {
|
|
237
|
+
const next = columns.slice();
|
|
238
|
+
next.splice(Math.max(0, Math.min(at, next.length)), 0, column);
|
|
239
|
+
return next;
|
|
240
|
+
}
|
|
241
|
+
/** Remove the column at `index` — returns the new column array. */
|
|
242
|
+
function removeColumnAt(columns, index) {
|
|
243
|
+
const next = columns.slice();
|
|
244
|
+
next.splice(index, 1);
|
|
245
|
+
return next;
|
|
246
|
+
}
|
|
247
|
+
/** Rename the column at `index` — returns a new array with a NEW object there. */
|
|
248
|
+
function renameColumnAt(columns, index, name) {
|
|
249
|
+
return columns.map((c, i) => (i === index ? Object.assign(Object.assign({}, c), { name }) : c));
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../../../libs/element/src/lib/diagram-kit/update.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;AAyOH,oCAgBC;AAMD,kCAmBC;AAKD,kCAIC;AAGD,wCAIC;AAGD,wCAEC;;AArSD,8CAAkE;AAGlE,iCASgB;AA4EhB;;;;GAIG;AACH,MAAM,iBAAkB,SAAQ,gBAAO;IAUrC,YACU,MAAc,EACd,IAAU,EACV,KAAuD;QAE/D,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;QAJ3C,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAM;QACV,UAAK,GAAL,KAAK,C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1,48 @@
|
|
|
1
|
+
import type { DiagramInstance, EdgeSpec, NodeSpec } from '@grafloria/renderer';
|
|
2
|
+
/** Events emitted on the element. All bubble and cross shadow boundaries. */
|
|
3
|
+
export declare const GRAFLORIA_EVENTS: {
|
|
4
|
+
readonly ready: "grafloria-ready";
|
|
5
|
+
readonly nodesChange: "grafloria-nodes-change";
|
|
6
|
+
readonly edgesChange: "grafloria-edges-change";
|
|
7
|
+
readonly selectionChange: "grafloria-selection-change";
|
|
8
|
+
readonly connect: "grafloria-connect";
|
|
9
|
+
readonly nodeClick: "grafloria-node-click";
|
|
10
|
+
readonly edgeClick: "grafloria-edge-click";
|
|
11
|
+
readonly viewportChange: "grafloria-viewport-change";
|
|
12
|
+
};
|
|
13
|
+
declare const HTMLElementBase: typeof HTMLElement;
|
|
14
|
+
export declare class GrafloriaFlowElement extends HTMLElementBase {
|
|
15
|
+
static get observedAttributes(): string[];
|
|
16
|
+
private instance;
|
|
17
|
+
private canvas;
|
|
18
|
+
private _nodes;
|
|
19
|
+
private _edges;
|
|
20
|
+
private connected;
|
|
21
|
+
get nodes(): NodeSpec[];
|
|
22
|
+
set nodes(value: NodeSpec[]);
|
|
23
|
+
get edges(): EdgeSpec[];
|
|
24
|
+
set edges(value: EdgeSpec[]);
|
|
25
|
+
/** The headless instance — the escape hatch to everything else. */
|
|
26
|
+
get diagram(): DiagramInstance | null;
|
|
27
|
+
connectedCallback(): void;
|
|
28
|
+
disconnectedCallback(): void;
|
|
29
|
+
attributeChangedCallback(name: string, previous: string | null, next: string | null): void;
|
|
30
|
+
fitView(padding?: number): void;
|
|
31
|
+
private buildOptions;
|
|
32
|
+
/**
|
|
33
|
+
* Custom nodes, two ways and no framework: a registered renderer
|
|
34
|
+
* (`Grafloria.registerNodeType`), or a slotted `<template data-node-type="…">`.
|
|
35
|
+
*/
|
|
36
|
+
private renderCustomNode;
|
|
37
|
+
private resolveTheme;
|
|
38
|
+
private readAttributeModel;
|
|
39
|
+
/** Instance events → DOM CustomEvents. `composed` so they escape a shadow root. */
|
|
40
|
+
private wireEvents;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Register the element. Idempotent, and safe to call on the server (where
|
|
44
|
+
* `customElements` does not exist) — which is what lets a bundle be imported
|
|
45
|
+
* from an SSR entry point without a `typeof window` dance at every call site.
|
|
46
|
+
*/
|
|
47
|
+
export declare function defineGrafloriaFlow(tagName?: string): void;
|
|
48
|
+
export {};
|