@linkurious/ogma-linkurious-parser 3.1.13 → 4.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/dist/captions/captions.js +42 -54
- package/dist/captions/captions.js.map +1 -1
- package/dist/filters/filters.d.ts +1 -1
- package/dist/filters/filters.js +55 -76
- package/dist/filters/filters.js.map +1 -1
- package/dist/index.js +34 -33
- package/dist/index.js.map +1 -1
- package/dist/ogma/features/OgmaStore.js +16 -30
- package/dist/ogma/features/OgmaStore.js.map +1 -1
- package/dist/ogma/features/captions.js +43 -87
- package/dist/ogma/features/captions.js.map +1 -1
- package/dist/ogma/features/reactive.js +58 -75
- package/dist/ogma/features/reactive.js.map +1 -1
- package/dist/ogma/features/selectors.d.ts +5 -5
- package/dist/ogma/features/selectors.js +25 -16
- package/dist/ogma/features/selectors.js.map +1 -1
- package/dist/ogma/features/styles.js +115 -137
- package/dist/ogma/features/styles.js.map +1 -1
- package/dist/ogma/features/transformations.js +39 -87
- package/dist/ogma/features/transformations.js.map +1 -1
- package/dist/ogma/index.js +140 -230
- package/dist/ogma/index.js.map +1 -1
- package/dist/styles/edgeAttributes.js +31 -47
- package/dist/styles/edgeAttributes.js.map +1 -1
- package/dist/styles/itemAttributes.js +33 -42
- package/dist/styles/itemAttributes.js.map +1 -1
- package/dist/styles/nodeAttributes.js +49 -71
- package/dist/styles/nodeAttributes.js.map +1 -1
- package/dist/styles/styleRule.js +57 -68
- package/dist/styles/styleRule.js.map +1 -1
- package/dist/styles/styleRules.js +150 -192
- package/dist/styles/styleRules.js.map +1 -1
- package/dist/tools/colorPalette.js +1 -0
- package/dist/tools/colorPalette.js.map +1 -1
- package/dist/tools/ogmaTool.js +28 -30
- package/dist/tools/ogmaTool.js.map +1 -1
- package/dist/tools/tools.js +88 -91
- package/dist/tools/tools.js.map +1 -1
- package/package.json +7 -7
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,yCAsB0B;AArBxB,4FAAA,IAAI,OAAA;AACJ,gGAAA,QAAQ,OAAA;AACR,4FAAA,IAAI,OAAA;AACJ,gGAAA,QAAQ,OAAA;AAoBV,gDAA6C;AAArC,oGAAA,QAAQ,OAAA;AAChB,0DAA2E;AAAnE,gHAAA,cAAc,OAAA;AAAE,2GAAA,SAAS,OAAA;AAAE,yGAAA,OAAO,OAAA;AAC1C,0DAAuD;AAA/C,gHAAA,cAAc,OAAA;AACtB,0DAAuD;AAA/C,gHAAA,cAAc,OAAA;AACtB,gDAA4D;AAApD,sGAAA,SAAS,OAAA;AAAE,0GAAA,aAAa,OAAA;AAChC,kDAAkE;AAA1D,wGAAA,UAAU,OAAA;AAAE,uGAAA,SAAS,OAAA;AAC7B,iDAA+E;AAAvE,mGAAA,SAAS,OAAA;AAAgB,wGAAA,cAAc,OAAA;AAC/C,mEAAmE;AAA3D,qHAAA,kBAAkB,OAAA;AAC1B,qDAAmE;AAA3D,uGAAA,WAAW,OAAA;AAEnB,6CAA2C;AAAnC,qGAAA,SAAS,OAAA;AACjB,qDAAiD;AAAzC,2GAAA,WAAW,OAAA;AACnB,6CAA0C;AAAlC,kGAAA,OAAO,OAAA;AACf,uDAAoD;AAA5C,sGAAA,SAAS,OAAA;AACjB,uDASmC;AARjC,6GAAA,gBAAgB,OAAA;AAChB,8GAAA,iBAAiB,OAAA;AACjB,+GAAA,kBAAkB,OAAA;AAClB,6GAAA,gBAAgB,OAAA;AAChB,kHAAA,qBAAqB,OAAA;AACrB,mHAAA,sBAAsB,OAAA;AACtB,mHAAA,sBAAsB,OAAA;AACtB,mHAAA,sBAAsB,OAAA;AAExB,+BAAkD;AAA1C,8FAAA,MAAM,OAAA;AAAE,0GAAA,kBAAkB,OAAA;AAClC,uCAAoC;AAA5B,8FAAA,KAAK,OAAA","sourcesContent":["'use strict';\n\nexport {\n Edge,\n EdgeList,\n Node,\n NodeList,\n EdgeId,\n NodeId,\n RawEdge,\n RawItem,\n RawNode,\n PropertyPath,\n Item,\n ItemId,\n EdgeStyle,\n PixelSize,\n EdgeExtremity,\n EdgeType,\n GeoModeOptions,\n EdgesDataEvent,\n NodesDataEvent,\n NodesDragEndEvent,\n NodesEvent\n} from '@linkurious/ogma';\n\nexport {Captions} from './captions/captions';\nexport {ItemAttributes, BASE_GREY, PALETTE} from './styles/itemAttributes';\nexport {EdgeAttributes} from './styles/edgeAttributes';\nexport {NodeAttributes} from './styles/nodeAttributes';\nexport {StyleRule, StyleRuleType} from './styles/styleRule';\nexport {StyleRules, StyleType, Legend} from './styles/styleRules';\nexport {StylesViz, StylesConfig, FILTER_OPACITY} from './ogma/features/styles';\nexport {TransformationsViz} from './ogma/features/transformations';\nexport {CaptionsViz, CaptionState} from './ogma/features/captions';\nexport {OgmaState} from './ogma/features/reactive';\nexport {OgmaTools} from './tools/ogmaTool';\nexport {HTML_COLORS} from './tools/colorPalette';\nexport {Filters} from './filters/filters';\nexport {OgmaStore} from './ogma/features/OgmaStore';\nexport {\n getSelectionSize,\n getSelectionState,\n getSelectionEntity,\n getUniqSelection,\n getUniqSelectionTypes,\n getUniqSelectionEntity,\n getSelectionProperties,\n hasSelectionProperties\n} from './ogma/features/selectors';\nexport {LKOgma, ANIMATION_DURATION} from './ogma';\nexport {Tools} from './tools/tools';\n"]}
|
|
@@ -1,51 +1,37 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
3
|
+
exports.OgmaStore = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const tools_1 = require("../../tools/tools");
|
|
7
|
+
const reactive_1 = require("./reactive");
|
|
8
|
+
class OgmaStore extends rxjs_1.BehaviorSubject {
|
|
9
|
+
constructor(d) {
|
|
10
|
+
super(d);
|
|
24
11
|
}
|
|
25
12
|
/**
|
|
26
13
|
* Modify Ogma state based on a method
|
|
27
14
|
*/
|
|
28
|
-
|
|
15
|
+
dispatch(mapFn) {
|
|
29
16
|
this.next(mapFn(this.value));
|
|
30
|
-
}
|
|
17
|
+
}
|
|
31
18
|
/**
|
|
32
19
|
* Return a piece of state
|
|
33
20
|
*/
|
|
34
|
-
|
|
35
|
-
return this.pipe(operators_1.map(mapFn), operators_1.distinctUntilChanged(
|
|
36
|
-
}
|
|
21
|
+
selectStore(mapFn) {
|
|
22
|
+
return this.pipe((0, operators_1.map)(mapFn), (0, operators_1.distinctUntilChanged)((p, n) => tools_1.Tools.isEqual(p, n)));
|
|
23
|
+
}
|
|
37
24
|
/**
|
|
38
25
|
* Clear the state of Ogma
|
|
39
26
|
*/
|
|
40
|
-
|
|
27
|
+
clear() {
|
|
41
28
|
this.next({
|
|
42
29
|
selection: new reactive_1.DummyNodeList(),
|
|
43
30
|
items: { node: [], edge: [] },
|
|
44
31
|
changes: undefined,
|
|
45
32
|
animation: false
|
|
46
33
|
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
}(rxjs_1.BehaviorSubject));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
50
36
|
exports.OgmaStore = OgmaStore;
|
|
51
37
|
//# sourceMappingURL=OgmaStore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OgmaStore.js","sourceRoot":"","sources":["../../../src/ogma/features/OgmaStore.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"OgmaStore.js","sourceRoot":"","sources":["../../../src/ogma/features/OgmaStore.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,+BAAiD;AACjD,8CAAyD;AAEzD,6CAAwC;AAExC,yCAAoD;AAEpD,MAAa,SAAU,SAAQ,sBAA0B;IACvD,YAAY,CAAY;QACtB,KAAK,CAAC,CAAC,CAAC,CAAC;IACX,CAAC;IAED;;OAEG;IACI,QAAQ,CAAC,KAAsC;QACpD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACI,WAAW,CAAI,KAA8B;QAClD,OAAO,IAAI,CAAC,IAAI,CACd,IAAA,eAAG,EAAC,KAAK,CAAC,EACV,IAAA,gCAAoB,EAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,aAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CACpD,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,KAAK;QACV,IAAI,CAAC,IAAI,CAAC;YACR,SAAS,EAAE,IAAI,wBAAa,EAAS;YACrC,KAAK,EAAE,EAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAC;YAC3B,OAAO,EAAE,SAAS;YAClB,SAAS,EAAE,KAAK;SACjB,CAAC,CAAC;IACL,CAAC;CACF;AAjCD,8BAiCC","sourcesContent":["'use strict';\n\nimport {BehaviorSubject, Observable} from 'rxjs';\nimport {distinctUntilChanged, map} from 'rxjs/operators';\n\nimport {Tools} from '../../tools/tools';\n\nimport {DummyNodeList, OgmaState} from './reactive';\n\nexport class OgmaStore extends BehaviorSubject<OgmaState> {\n constructor(d: OgmaState) {\n super(d);\n }\n\n /**\n * Modify Ogma state based on a method\n */\n public dispatch(mapFn: (state: OgmaState) => OgmaState): void {\n this.next(mapFn(this.value));\n }\n\n /**\n * Return a piece of state\n */\n public selectStore<K>(mapFn: (state: OgmaState) => K): Observable<K> {\n return this.pipe(\n map(mapFn),\n distinctUntilChanged((p, n) => Tools.isEqual(p, n))\n );\n }\n\n /**\n * Clear the state of Ogma\n */\n public clear(): void {\n this.next({\n selection: new DummyNodeList() as any,\n items: {node: [], edge: []},\n changes: undefined,\n animation: false\n });\n }\n}\n"]}
|
|
@@ -8,94 +8,52 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
12
|
+
exports.CaptionsViz = void 0;
|
|
13
|
+
const __1 = require("../..");
|
|
14
|
+
const tools_1 = require("../../tools/tools");
|
|
15
|
+
class CaptionsViz {
|
|
16
|
+
constructor(ogma, _nodeMaxTextLength, _edgeMaxTextLength) {
|
|
43
17
|
this._nodeMaxTextLength = _nodeMaxTextLength;
|
|
44
18
|
this._edgeMaxTextLength = _edgeMaxTextLength;
|
|
45
19
|
this._captionSchema = { node: {}, edge: {} };
|
|
46
20
|
this._graphSchema = { node: [], edge: [] };
|
|
47
21
|
this._ogma = ogma;
|
|
48
22
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
},
|
|
53
|
-
enumerable: true,
|
|
54
|
-
configurable: true
|
|
55
|
-
});
|
|
23
|
+
set graphSchema(graphSchema) {
|
|
24
|
+
this._graphSchema = graphSchema;
|
|
25
|
+
}
|
|
56
26
|
/**
|
|
57
27
|
* Refresh the schema
|
|
58
28
|
*/
|
|
59
|
-
|
|
29
|
+
refreshSchema(schema) {
|
|
60
30
|
this._captionSchema = schema;
|
|
61
|
-
}
|
|
31
|
+
}
|
|
62
32
|
/**
|
|
63
33
|
* Refresh visualization captions rules
|
|
64
34
|
*/
|
|
65
|
-
|
|
66
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
this._ogma.LKCaptions.refreshSchema(schema);
|
|
82
|
-
return [4 /*yield*/, this._ogma.LKCaptions.updateEdgeCaptions()];
|
|
83
|
-
case 4:
|
|
84
|
-
_a.sent();
|
|
85
|
-
return [3 /*break*/, 6];
|
|
86
|
-
case 5:
|
|
87
|
-
this._ogma.LKCaptions.updateEdgeCaptions(schema.edge);
|
|
88
|
-
_a.label = 6;
|
|
89
|
-
case 6: return [2 /*return*/];
|
|
90
|
-
}
|
|
91
|
-
});
|
|
35
|
+
initVizCaptions(schema) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
if (this._ogma.LKCaptions.nodesCaptionsRule) {
|
|
38
|
+
this._ogma.LKCaptions.refreshSchema(schema);
|
|
39
|
+
yield this._ogma.LKCaptions.updateNodeCaptions();
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this._ogma.LKCaptions.updateNodeCaptions(schema.node);
|
|
43
|
+
}
|
|
44
|
+
if (this._ogma.LKCaptions.edgesCaptionsRule) {
|
|
45
|
+
this._ogma.LKCaptions.refreshSchema(schema);
|
|
46
|
+
yield this._ogma.LKCaptions.updateEdgeCaptions();
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
this._ogma.LKCaptions.updateEdgeCaptions(schema.edge);
|
|
50
|
+
}
|
|
92
51
|
});
|
|
93
|
-
}
|
|
52
|
+
}
|
|
94
53
|
/**
|
|
95
54
|
* Create or update nodeCaptionRule
|
|
96
55
|
*/
|
|
97
|
-
|
|
98
|
-
var _this = this;
|
|
56
|
+
updateNodeCaptions(schema) {
|
|
99
57
|
if (schema) {
|
|
100
58
|
this._captionSchema.node = schema;
|
|
101
59
|
}
|
|
@@ -103,13 +61,13 @@ var CaptionsViz = /** @class */ (function () {
|
|
|
103
61
|
this.nodesCaptionsRule = this._ogma.styles.addRule({
|
|
104
62
|
nodeAttributes: {
|
|
105
63
|
text: {
|
|
106
|
-
content:
|
|
64
|
+
content: (node) => {
|
|
107
65
|
if (node === undefined) {
|
|
108
|
-
return
|
|
66
|
+
return ``;
|
|
109
67
|
}
|
|
110
|
-
|
|
111
|
-
return tools_1.Tools.isDefined(
|
|
112
|
-
? tools_1.Tools.truncate(value, 'middle',
|
|
68
|
+
const value = __1.Captions.getText(node.getData(), this._captionSchema.node, this._graphSchema.node);
|
|
69
|
+
return tools_1.Tools.isDefined(this._nodeMaxTextLength)
|
|
70
|
+
? tools_1.Tools.truncate(value, 'middle', this._nodeMaxTextLength)
|
|
113
71
|
: value;
|
|
114
72
|
}
|
|
115
73
|
}
|
|
@@ -120,12 +78,11 @@ var CaptionsViz = /** @class */ (function () {
|
|
|
120
78
|
else {
|
|
121
79
|
return this.nodesCaptionsRule.refresh();
|
|
122
80
|
}
|
|
123
|
-
}
|
|
81
|
+
}
|
|
124
82
|
/**
|
|
125
83
|
* Create or update edgeCaptionRule
|
|
126
84
|
*/
|
|
127
|
-
|
|
128
|
-
var _this = this;
|
|
85
|
+
updateEdgeCaptions(schema) {
|
|
129
86
|
if (schema) {
|
|
130
87
|
this._captionSchema.edge = schema;
|
|
131
88
|
}
|
|
@@ -133,18 +90,18 @@ var CaptionsViz = /** @class */ (function () {
|
|
|
133
90
|
this.edgesCaptionsRule = this._ogma.styles.addRule({
|
|
134
91
|
edgeAttributes: {
|
|
135
92
|
text: {
|
|
136
|
-
content:
|
|
93
|
+
content: (edge) => {
|
|
137
94
|
if (edge === undefined || edge.getData() === undefined) {
|
|
138
|
-
return
|
|
95
|
+
return ``;
|
|
139
96
|
}
|
|
140
|
-
|
|
141
|
-
return tools_1.Tools.isDefined(
|
|
142
|
-
? tools_1.Tools.truncate(value, 'middle',
|
|
97
|
+
const value = __1.Captions.getText(edge.getData(), this._captionSchema.edge, this._graphSchema.edge);
|
|
98
|
+
return tools_1.Tools.isDefined(this._edgeMaxTextLength)
|
|
99
|
+
? tools_1.Tools.truncate(value, 'middle', this._edgeMaxTextLength)
|
|
143
100
|
: value;
|
|
144
101
|
}
|
|
145
102
|
}
|
|
146
103
|
},
|
|
147
|
-
edgeSelector:
|
|
104
|
+
edgeSelector: (edge) => !edge.isVirtual() && edge.isVisible(),
|
|
148
105
|
// ogma will trigger the rendering if data change or the shape change (to trigger the rendering when edges are grouped)
|
|
149
106
|
edgeDependencies: { self: { data: true, attributes: ['shape.style'] } }
|
|
150
107
|
});
|
|
@@ -152,8 +109,7 @@ var CaptionsViz = /** @class */ (function () {
|
|
|
152
109
|
else {
|
|
153
110
|
return this.edgesCaptionsRule.refresh();
|
|
154
111
|
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
}());
|
|
112
|
+
}
|
|
113
|
+
}
|
|
158
114
|
exports.CaptionsViz = CaptionsViz;
|
|
159
115
|
//# sourceMappingURL=captions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"captions.js","sourceRoot":"","sources":["../../../src/ogma/features/captions.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"captions.js","sourceRoot":"","sources":["../../../src/ogma/features/captions.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;AAKb,6BAAuC;AACvC,6CAAwC;AAOxC,MAAa,W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AAc,EAAE;oBACd,IAAI,EAAE;wBACJ,OAAO,EAAE,CAAC,IAA2B,EAAE,EAAE;4BACvC,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,OAAO,EAAE,KAAK,SAAS,EAAE;gCACtD,OAAO,EAAE,CAAC;6BACX;4BACD,MAAM,KAAK,GAAG,YAAQ,CAAC,OAAO,CAC5B,IAAI,CAAC,OAAO,EAAE,EACd,IAAI,CAAC,cAAc,CAAC,IAAI,EACxB,IAAI,CAAC,YAAY,CAAC,IAAI,CACvB,CAAC;4BACF,OAAO,aAAK,CAAC,SAAS,CAAC,IAAI,CAAC,kBAAkB,CAAC;gCAC7C,CAAC,CAAC,aAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,kBAAkB,CAAC;gCAC1D,CAAC,CAAC,KAAK,CAAC;wBACZ,CAAC;qBACF;iBACF;gBACD,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,IAAI,CAAC,SAAS,EAAE;gBAC7D,uHAAuH;gBACvH,gBAAgB,EAAE,EAAC,IAAI,EAAE,EAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,aAAa,CAAC,EAAC,EAAC;aACpE,CAAC,CAAC;SACJ;aAAM;YACL,OAAO,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC;SACzC;IACH,CAAC;CACF;AArHD,kCAqHC","sourcesContent":["'use strict';\n\nimport * as Ogma from '@linkurious/ogma';\nimport {GraphSchemaTypeWithAccess, ItemFieldsCaptions} from '@linkurious/rest-client';\n\nimport {Captions, LKOgma} from '../..';\nimport {Tools} from '../../tools/tools';\n\nexport interface CaptionState {\n node: ItemFieldsCaptions;\n edge: ItemFieldsCaptions;\n}\n\nexport class CaptionsViz {\n public nodesCaptionsRule!: Ogma.StyleRule;\n public edgesCaptionsRule!: Ogma.StyleRule;\n private _ogma: LKOgma;\n private _captionSchema: CaptionState = {node: {}, edge: {}};\n private _graphSchema: {\n node: Array<GraphSchemaTypeWithAccess>;\n edge: Array<GraphSchemaTypeWithAccess>;\n } = {node: [], edge: []};\n\n constructor(\n ogma: LKOgma,\n private _nodeMaxTextLength: number | undefined,\n private _edgeMaxTextLength: number | undefined\n ) {\n this._ogma = ogma;\n }\n\n public set graphSchema(graphSchema: {\n node: Array<GraphSchemaTypeWithAccess>;\n edge: Array<GraphSchemaTypeWithAccess>;\n }) {\n this._graphSchema = graphSchema;\n }\n\n /**\n * Refresh the schema\n */\n public refreshSchema(schema: CaptionState): void {\n this._captionSchema = schema;\n }\n\n /**\n * Refresh visualization captions rules\n */\n public async initVizCaptions(schema: CaptionState): Promise<void> {\n if (this._ogma.LKCaptions.nodesCaptionsRule) {\n this._ogma.LKCaptions.refreshSchema(schema);\n await this._ogma.LKCaptions.updateNodeCaptions();\n } else {\n this._ogma.LKCaptions.updateNodeCaptions(schema.node);\n }\n if (this._ogma.LKCaptions.edgesCaptionsRule) {\n this._ogma.LKCaptions.refreshSchema(schema);\n await this._ogma.LKCaptions.updateEdgeCaptions();\n } else {\n this._ogma.LKCaptions.updateEdgeCaptions(schema.edge);\n }\n }\n\n /**\n * Create or update nodeCaptionRule\n */\n public updateNodeCaptions(schema?: ItemFieldsCaptions): Promise<void> | void {\n if (schema) {\n this._captionSchema.node = schema;\n }\n if (!Tools.isDefined(this.nodesCaptionsRule)) {\n this.nodesCaptionsRule = this._ogma.styles.addRule({\n nodeAttributes: {\n text: {\n content: (node: Ogma.Node | undefined) => {\n if (node === undefined) {\n return ``;\n }\n const value = Captions.getText(\n node.getData(),\n this._captionSchema.node,\n this._graphSchema.node\n );\n return Tools.isDefined(this._nodeMaxTextLength)\n ? Tools.truncate(value, 'middle', this._nodeMaxTextLength)\n : value;\n }\n }\n },\n nodeDependencies: {self: {data: true}}\n });\n } else {\n return this.nodesCaptionsRule.refresh();\n }\n }\n\n /**\n * Create or update edgeCaptionRule\n */\n public updateEdgeCaptions(schema?: ItemFieldsCaptions): Promise<void> | void {\n if (schema) {\n this._captionSchema.edge = schema;\n }\n if (!Tools.isDefined(this.edgesCaptionsRule)) {\n this.edgesCaptionsRule = this._ogma.styles.addRule({\n edgeAttributes: {\n text: {\n content: (edge: Ogma.Edge | undefined) => {\n if (edge === undefined || edge.getData() === undefined) {\n return ``;\n }\n const value = Captions.getText(\n edge.getData(),\n this._captionSchema.edge,\n this._graphSchema.edge\n );\n return Tools.isDefined(this._edgeMaxTextLength)\n ? Tools.truncate(value, 'middle', this._edgeMaxTextLength)\n : value;\n }\n }\n },\n edgeSelector: (edge) => !edge.isVirtual() && edge.isVisible(),\n // ogma will trigger the rendering if data change or the shape change (to trigger the rendering when edges are grouped)\n edgeDependencies: {self: {data: true, attributes: ['shape.style']}}\n });\n } else {\n return this.edgesCaptionsRule.refresh();\n }\n }\n}\n"]}
|
|
@@ -1,20 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
3
|
+
exports.DummyNodeList = exports.RxViz = void 0;
|
|
4
|
+
const index_1 = require("../index");
|
|
5
|
+
const OgmaStore_1 = require("./OgmaStore");
|
|
6
|
+
class RxViz {
|
|
7
|
+
constructor(ogma) {
|
|
18
8
|
this._store = new OgmaStore_1.OgmaStore({
|
|
19
9
|
selection: new DummyNodeList(),
|
|
20
10
|
items: { node: [], edge: [] },
|
|
@@ -24,112 +14,105 @@ var RxViz = /** @class */ (function () {
|
|
|
24
14
|
this._ogma = ogma;
|
|
25
15
|
this.listenToSelectionEvents();
|
|
26
16
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
},
|
|
31
|
-
enumerable: true,
|
|
32
|
-
configurable: true
|
|
33
|
-
});
|
|
17
|
+
get store() {
|
|
18
|
+
return this._store;
|
|
19
|
+
}
|
|
34
20
|
/**
|
|
35
21
|
* Listen to ogma events and update the state
|
|
36
22
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
_this._animationThrottle = setTimeout(function () {
|
|
23
|
+
listenToSelectionEvents() {
|
|
24
|
+
let count = 0;
|
|
25
|
+
this._ogma.events.on('animate', (e) => {
|
|
26
|
+
const animationEnd = ++count;
|
|
27
|
+
this._store.dispatch((state) => (Object.assign(Object.assign({}, state), { animation: true })));
|
|
28
|
+
clearTimeout(this._animationThrottle);
|
|
29
|
+
this._animationThrottle = setTimeout(() => {
|
|
45
30
|
if (count === animationEnd) {
|
|
46
|
-
|
|
31
|
+
this._store.dispatch((state) => (Object.assign(Object.assign({}, state), { animation: false })));
|
|
47
32
|
}
|
|
48
33
|
}, e.duration + index_1.ANIMATION_DURATION + 100);
|
|
49
34
|
});
|
|
50
|
-
this._ogma.events.on('dragStart',
|
|
51
|
-
|
|
35
|
+
this._ogma.events.on('dragStart', () => {
|
|
36
|
+
this._store.dispatch((state) => (Object.assign(Object.assign({}, state), { animation: true })));
|
|
52
37
|
});
|
|
53
|
-
this._ogma.events.on('dragEnd',
|
|
54
|
-
|
|
38
|
+
this._ogma.events.on('dragEnd', () => {
|
|
39
|
+
this._store.dispatch((state) => (Object.assign(Object.assign({}, state), { animation: false })));
|
|
55
40
|
});
|
|
56
|
-
this._ogma.events.on('addNodes',
|
|
57
|
-
|
|
41
|
+
this._ogma.events.on('addNodes', () => {
|
|
42
|
+
this._store.dispatch(this.storeItems.bind(this));
|
|
58
43
|
});
|
|
59
|
-
this._ogma.events.on('removeNodes',
|
|
60
|
-
|
|
44
|
+
this._ogma.events.on('removeNodes', () => {
|
|
45
|
+
this._store.dispatch(this.storeItems.bind(this));
|
|
61
46
|
});
|
|
62
|
-
this._ogma.events.on('addEdges',
|
|
63
|
-
|
|
47
|
+
this._ogma.events.on('addEdges', () => {
|
|
48
|
+
this._store.dispatch(this.storeItems.bind(this));
|
|
64
49
|
});
|
|
65
|
-
this._ogma.events.on('removeEdges',
|
|
66
|
-
|
|
50
|
+
this._ogma.events.on('removeEdges', () => {
|
|
51
|
+
this._store.dispatch(this.storeItems.bind(this));
|
|
67
52
|
});
|
|
68
|
-
this._ogma.events.on('nodesSelected',
|
|
69
|
-
|
|
53
|
+
this._ogma.events.on('nodesSelected', () => {
|
|
54
|
+
this._store.dispatch(this.storeNodeSelection.bind(this));
|
|
70
55
|
});
|
|
71
|
-
this._ogma.events.on('edgesSelected',
|
|
72
|
-
|
|
56
|
+
this._ogma.events.on('edgesSelected', () => {
|
|
57
|
+
this._store.dispatch(this.storeEdgeSelection.bind(this));
|
|
73
58
|
});
|
|
74
|
-
this._ogma.events.on('nodesUnselected',
|
|
75
|
-
|
|
59
|
+
this._ogma.events.on('nodesUnselected', () => {
|
|
60
|
+
this._store.dispatch(this.storeNodeSelection.bind(this));
|
|
76
61
|
});
|
|
77
|
-
this._ogma.events.on('edgesUnselected',
|
|
78
|
-
|
|
62
|
+
this._ogma.events.on('edgesUnselected', () => {
|
|
63
|
+
this._store.dispatch(this.storeEdgeSelection.bind(this));
|
|
79
64
|
});
|
|
80
|
-
this._ogma.events.on('updateNodeData',
|
|
65
|
+
this._ogma.events.on('updateNodeData', (evt) => {
|
|
81
66
|
if (evt !== undefined) {
|
|
82
|
-
evt.changes.forEach(
|
|
83
|
-
|
|
67
|
+
evt.changes.forEach((change) => {
|
|
68
|
+
this._store.dispatch((state) => (Object.assign(Object.assign({}, state), { changes: {
|
|
84
69
|
entityType: 'node',
|
|
85
70
|
input: change.property,
|
|
86
71
|
value: change.newValues[0]
|
|
87
|
-
} }))
|
|
72
|
+
} })));
|
|
88
73
|
});
|
|
89
74
|
}
|
|
90
75
|
});
|
|
91
|
-
this._ogma.events.on('updateEdgeData',
|
|
76
|
+
this._ogma.events.on('updateEdgeData', (evt) => {
|
|
92
77
|
if (evt !== undefined) {
|
|
93
|
-
evt.changes.forEach(
|
|
94
|
-
|
|
78
|
+
evt.changes.forEach((change) => {
|
|
79
|
+
this._store.dispatch((state) => (Object.assign(Object.assign({}, state), { changes: {
|
|
95
80
|
entityType: 'edge',
|
|
96
81
|
input: change.property,
|
|
97
82
|
value: change.newValues[0]
|
|
98
|
-
} }))
|
|
83
|
+
} })));
|
|
99
84
|
});
|
|
100
85
|
}
|
|
101
86
|
});
|
|
102
|
-
}
|
|
87
|
+
}
|
|
103
88
|
/**
|
|
104
89
|
* Store new items in state
|
|
105
90
|
*/
|
|
106
|
-
|
|
107
|
-
return
|
|
91
|
+
storeItems(state) {
|
|
92
|
+
return Object.assign(Object.assign({}, state), { items: {
|
|
108
93
|
node: this._ogma.getNodes().getId(),
|
|
109
94
|
edge: this._ogma.getEdges().getId()
|
|
110
95
|
} });
|
|
111
|
-
}
|
|
96
|
+
}
|
|
112
97
|
/**
|
|
113
98
|
* Store new node selection in state
|
|
114
99
|
*/
|
|
115
|
-
|
|
116
|
-
return
|
|
117
|
-
}
|
|
100
|
+
storeNodeSelection(state) {
|
|
101
|
+
return Object.assign(Object.assign({}, state), { selection: this._ogma.getSelectedNodes() });
|
|
102
|
+
}
|
|
118
103
|
/**
|
|
119
104
|
* store new edge selection in state
|
|
120
105
|
*/
|
|
121
|
-
|
|
122
|
-
return
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
}());
|
|
106
|
+
storeEdgeSelection(state) {
|
|
107
|
+
return Object.assign(Object.assign({}, state), { selection: this._ogma.getSelectedEdges() });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
126
110
|
exports.RxViz = RxViz;
|
|
127
|
-
|
|
128
|
-
|
|
111
|
+
class DummyNodeList {
|
|
112
|
+
constructor() {
|
|
129
113
|
this.size = 0;
|
|
130
114
|
this.isNode = true;
|
|
131
115
|
}
|
|
132
|
-
|
|
133
|
-
}());
|
|
116
|
+
}
|
|
134
117
|
exports.DummyNodeList = DummyNodeList;
|
|
135
118
|
//# sourceMappingURL=reactive.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactive.js","sourceRoot":"","sources":["../../../src/ogma/features/reactive.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"reactive.js","sourceRoot":"","sources":["../../../src/ogma/features/reactive.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAKb,oCAAoD;AAEpD,2CAAsC;AAStC,MAAa,KAAK;IAUhB,YAAY,IAAY;QARhB,WAAM,GAAc,IAAI,qBAAS,CAAC;YACxC,SAAS,EAAE,IAAI,aAAa,EAAS;YACrC,KAAK,EAAE,EAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAC;YAC3B,OAAO,EAAE,SAAS;YAClB,SAAS,EAAE,KAAK;SACjB,CAAC,CAAC;QAID,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAED,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;OAEG;IACI,uBAAuB;QAC5B,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,CAAqB,EAAE,EAAE;YACxD,MAAM,YAAY,GAAG,EAAE,KAAK,CAAC;YAC7B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCAAK,KAAK,KAAE,SAA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E;gBACnC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE;aACpC,IACD;IACJ,CAAC;IAED;;OAEG;IACK,kBAAkB,CAAC,KAAgB;QACzC,uCACK,KAAK,KACR,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,IACxC;IACJ,CAAC;IAED;;OAEG;IACK,kBAAkB,CAAC,KAAgB;QACzC,uCACK,KAAK,KACR,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,IACxC;IACJ,CAAC;CACF;AAvID,sBAuIC;AAED,MAAa,aAAa;IAA1B;QACS,SAAI,GAAG,CAAC,CAAC;QACT,WAAM,GAAG,IAAI,CAAC;IACvB,CAAC;CAAA;AAHD,sCAGC","sourcesContent":["'use strict';\n\nimport Ogma, {NodeList, EdgeList} from '@linkurious/ogma';\nimport {LkEdgeData, LkNodeData} from '@linkurious/rest-client';\n\nimport {ANIMATION_DURATION, LKOgma} from '../index';\n\nimport {OgmaStore} from './OgmaStore';\n\nexport interface OgmaState {\n selection: NodeList<LkNodeData, LkEdgeData> | EdgeList<LkEdgeData, LkNodeData>;\n items: {node: Array<string | number>; edge: Array<string | number>};\n changes: {entityType: 'node' | 'edge'; input: string | string[] | null; value: any} | undefined;\n animation: boolean;\n}\n\nexport class RxViz {\n private _ogma: Ogma;\n private _store: OgmaStore = new OgmaStore({\n selection: new DummyNodeList() as any,\n items: {node: [], edge: []},\n changes: undefined,\n animation: false\n });\n private _animationThrottle: any;\n\n constructor(ogma: LKOgma) {\n this._ogma = ogma;\n this.listenToSelectionEvents();\n }\n\n public get store(): OgmaStore {\n return this._store;\n }\n\n /**\n * Listen to ogma events and update the state\n */\n public listenToSelectionEvents(): void {\n let count = 0;\n this._ogma.events.on('animate', (e: {duration: number}) => {\n const animationEnd = ++count;\n this._store.dispatch((state) => ({...state, animation: true}));\n clearTimeout(this._animationThrottle);\n this._animationThrottle = setTimeout(() => {\n if (count === animationEnd) {\n this._store.dispatch((state) => ({...state, animation: false}));\n }\n }, e.duration + ANIMATION_DURATION + 100);\n });\n\n this._ogma.events.on('dragStart', () => {\n this._store.dispatch((state) => ({...state, animation: true}));\n });\n\n this._ogma.events.on('dragEnd', () => {\n this._store.dispatch((state) => ({...state, animation: false}));\n });\n\n this._ogma.events.on('addNodes', () => {\n this._store.dispatch(this.storeItems.bind(this));\n });\n this._ogma.events.on('removeNodes', () => {\n this._store.dispatch(this.storeItems.bind(this));\n });\n this._ogma.events.on('addEdges', () => {\n this._store.dispatch(this.storeItems.bind(this));\n });\n this._ogma.events.on('removeEdges', () => {\n this._store.dispatch(this.storeItems.bind(this));\n });\n\n this._ogma.events.on('nodesSelected', () => {\n this._store.dispatch(this.storeNodeSelection.bind(this));\n });\n\n this._ogma.events.on('edgesSelected', () => {\n this._store.dispatch(this.storeEdgeSelection.bind(this));\n });\n\n this._ogma.events.on('nodesUnselected', () => {\n this._store.dispatch(this.storeNodeSelection.bind(this));\n });\n\n this._ogma.events.on('edgesUnselected', () => {\n this._store.dispatch(this.storeEdgeSelection.bind(this));\n });\n\n this._ogma.events.on('updateNodeData', (evt) => {\n if (evt !== undefined) {\n evt.changes.forEach((change) => {\n this._store.dispatch((state) => ({\n ...state,\n changes: {\n entityType: 'node',\n input: change.property,\n value: change.newValues[0]\n }\n }));\n });\n }\n });\n\n this._ogma.events.on('updateEdgeData', (evt) => {\n if (evt !== undefined) {\n evt.changes.forEach((change) => {\n this._store.dispatch((state) => ({\n ...state,\n changes: {\n entityType: 'edge',\n input: change.property,\n value: change.newValues[0]\n }\n }));\n });\n }\n });\n }\n\n /**\n * Store new items in state\n */\n private storeItems(state: OgmaState): OgmaState {\n return {\n ...state,\n items: {\n node: this._ogma.getNodes().getId(),\n edge: this._ogma.getEdges().getId()\n }\n };\n }\n\n /**\n * Store new node selection in state\n */\n private storeNodeSelection(state: OgmaState): OgmaState {\n return {\n ...state,\n selection: this._ogma.getSelectedNodes()\n };\n }\n\n /**\n * store new edge selection in state\n */\n private storeEdgeSelection(state: OgmaState): OgmaState {\n return {\n ...state,\n selection: this._ogma.getSelectedEdges()\n };\n }\n}\n\nexport class DummyNodeList {\n public size = 0;\n public isNode = true;\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EntityType, LkEdgeData, LkNodeData } from '@linkurious/rest-client';
|
|
2
2
|
import { Edge, Node } from '@linkurious/ogma';
|
|
3
3
|
import { OgmaState } from './reactive';
|
|
4
|
-
export
|
|
4
|
+
export type SelectionState = 'selection' | 'multiSelection' | 'noSelection';
|
|
5
5
|
/**
|
|
6
6
|
* Return the current size of the selection
|
|
7
7
|
*/
|
|
@@ -21,18 +21,18 @@ export declare const getUniqSelection: (state: OgmaState) => Node<LkNodeData, Lk
|
|
|
21
21
|
/**
|
|
22
22
|
* Return the types of the current selection (if only one item is selected)
|
|
23
23
|
*/
|
|
24
|
-
export declare const getUniqSelectionTypes: (state: OgmaState) => string
|
|
24
|
+
export declare const getUniqSelectionTypes: (state: OgmaState) => Array<string> | undefined;
|
|
25
25
|
/**
|
|
26
26
|
* Return the entityType of the current selection if there's only one item selected
|
|
27
27
|
*/
|
|
28
|
-
export declare const getUniqSelectionEntity: (state: OgmaState) =>
|
|
28
|
+
export declare const getUniqSelectionEntity: (state: OgmaState) => 'node' | 'edge' | undefined;
|
|
29
29
|
/**
|
|
30
30
|
* Return the properties of the current selection if there's only one item selected
|
|
31
31
|
*/
|
|
32
|
-
export declare const getSelectionProperties: (state: OgmaState) => {
|
|
32
|
+
export declare const getSelectionProperties: (state: OgmaState) => Array<{
|
|
33
33
|
key: string;
|
|
34
34
|
value: any;
|
|
35
|
-
}
|
|
35
|
+
}>;
|
|
36
36
|
/**
|
|
37
37
|
* Return true if the current selection has properties
|
|
38
38
|
*/
|