@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.
Files changed (39) hide show
  1. package/dist/captions/captions.js +42 -54
  2. package/dist/captions/captions.js.map +1 -1
  3. package/dist/filters/filters.d.ts +1 -1
  4. package/dist/filters/filters.js +55 -76
  5. package/dist/filters/filters.js.map +1 -1
  6. package/dist/index.js +34 -33
  7. package/dist/index.js.map +1 -1
  8. package/dist/ogma/features/OgmaStore.js +16 -30
  9. package/dist/ogma/features/OgmaStore.js.map +1 -1
  10. package/dist/ogma/features/captions.js +43 -87
  11. package/dist/ogma/features/captions.js.map +1 -1
  12. package/dist/ogma/features/reactive.js +58 -75
  13. package/dist/ogma/features/reactive.js.map +1 -1
  14. package/dist/ogma/features/selectors.d.ts +5 -5
  15. package/dist/ogma/features/selectors.js +25 -16
  16. package/dist/ogma/features/selectors.js.map +1 -1
  17. package/dist/ogma/features/styles.js +115 -137
  18. package/dist/ogma/features/styles.js.map +1 -1
  19. package/dist/ogma/features/transformations.js +39 -87
  20. package/dist/ogma/features/transformations.js.map +1 -1
  21. package/dist/ogma/index.js +140 -230
  22. package/dist/ogma/index.js.map +1 -1
  23. package/dist/styles/edgeAttributes.js +31 -47
  24. package/dist/styles/edgeAttributes.js.map +1 -1
  25. package/dist/styles/itemAttributes.js +33 -42
  26. package/dist/styles/itemAttributes.js.map +1 -1
  27. package/dist/styles/nodeAttributes.js +49 -71
  28. package/dist/styles/nodeAttributes.js.map +1 -1
  29. package/dist/styles/styleRule.js +57 -68
  30. package/dist/styles/styleRule.js.map +1 -1
  31. package/dist/styles/styleRules.js +150 -192
  32. package/dist/styles/styleRules.js.map +1 -1
  33. package/dist/tools/colorPalette.js +1 -0
  34. package/dist/tools/colorPalette.js.map +1 -1
  35. package/dist/tools/ogmaTool.js +28 -30
  36. package/dist/tools/ogmaTool.js.map +1 -1
  37. package/dist/tools/tools.js +88 -91
  38. package/dist/tools/tools.js.map +1 -1
  39. 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;;AAEb,yCAsB0B;AArBxB,sBAAA,IAAI,CAAA;AACJ,0BAAA,QAAQ,CAAA;AACR,sBAAA,IAAI,CAAA;AACJ,0BAAA,QAAQ,CAAA;AAoBV,gDAA6C;AAArC,8BAAA,QAAQ,CAAA;AAChB,0DAA2E;AAAnE,0CAAA,cAAc,CAAA;AAAE,qCAAA,SAAS,CAAA;AAAE,mCAAA,OAAO,CAAA;AAC1C,0DAAuD;AAA/C,0CAAA,cAAc,CAAA;AACtB,0DAAuD;AAA/C,0CAAA,cAAc,CAAA;AACtB,gDAA4D;AAApD,gCAAA,SAAS,CAAA;AAAE,oCAAA,aAAa,CAAA;AAChC,kDAAkE;AAA1D,kCAAA,UAAU,CAAA;AAAE,iCAAA,SAAS,CAAA;AAC7B,iDAA+E;AAAvE,6BAAA,SAAS,CAAA;AAAgB,kCAAA,cAAc,CAAA;AAC/C,mEAAmE;AAA3D,+CAAA,kBAAkB,CAAA;AAC1B,qDAAmE;AAA3D,iCAAA,WAAW,CAAA;AAEnB,6CAA2C;AAAnC,+BAAA,SAAS,CAAA;AACjB,qDAAiD;AAAzC,qCAAA,WAAW,CAAA;AACnB,6CAA0C;AAAlC,4BAAA,OAAO,CAAA;AACf,uDAAoD;AAA5C,gCAAA,SAAS,CAAA;AACjB,uDASmC;AARjC,uCAAA,gBAAgB,CAAA;AAChB,wCAAA,iBAAiB,CAAA;AACjB,yCAAA,kBAAkB,CAAA;AAClB,uCAAA,gBAAgB,CAAA;AAChB,4CAAA,qBAAqB,CAAA;AACrB,6CAAA,sBAAsB,CAAA;AACtB,6CAAA,sBAAsB,CAAA;AACtB,6CAAA,sBAAsB,CAAA;AAExB,+BAAkD;AAA1C,wBAAA,MAAM,CAAA;AAAE,oCAAA,kBAAkB,CAAA;AAClC,uCAAoC;AAA5B,wBAAA,KAAK,CAAA","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
+ {"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
- var rxjs_1 = require("rxjs");
17
- var operators_1 = require("rxjs/operators");
18
- var tools_1 = require("../../tools/tools");
19
- var reactive_1 = require("./reactive");
20
- var OgmaStore = /** @class */ (function (_super) {
21
- __extends(OgmaStore, _super);
22
- function OgmaStore(d) {
23
- return _super.call(this, d) || this;
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
- OgmaStore.prototype.dispatch = function (mapFn) {
15
+ dispatch(mapFn) {
29
16
  this.next(mapFn(this.value));
30
- };
17
+ }
31
18
  /**
32
19
  * Return a piece of state
33
20
  */
34
- OgmaStore.prototype.selectStore = function (mapFn) {
35
- return this.pipe(operators_1.map(mapFn), operators_1.distinctUntilChanged(function (p, n) { return tools_1.Tools.isEqual(p, n); }));
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
- OgmaStore.prototype.clear = function () {
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
- return OgmaStore;
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;;;;;;;;;;;;;;;AAEb,6BAAiD;AACjD,4CAAyD;AAEzD,2CAAwC;AAExC,uCAAoD;AAEpD;IAA+B,6BAA0B;IACvD,mBAAY,CAAY;eACtB,kBAAM,CAAC,CAAC;IACV,CAAC;IAED;;OAEG;IACI,4BAAQ,GAAf,UAAgB,KAAsC;QACpD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACI,+BAAW,GAAlB,UAAsB,KAA8B;QAClD,OAAO,IAAI,CAAC,IAAI,CACd,eAAG,CAAC,KAAK,CAAC,EACV,gCAAoB,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,aAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAnB,CAAmB,CAAC,CACpD,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,yBAAK,GAAZ;QACE,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;IACH,gBAAC;AAAD,CAAC,AAjCD,CAA+B,sBAAe,GAiC7C;AAjCY,8BAAS","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"]}
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
- var __1 = require("../..");
40
- var tools_1 = require("../../tools/tools");
41
- var CaptionsViz = /** @class */ (function () {
42
- function CaptionsViz(ogma, _nodeMaxTextLength, _edgeMaxTextLength) {
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
- Object.defineProperty(CaptionsViz.prototype, "graphSchema", {
50
- set: function (graphSchema) {
51
- this._graphSchema = graphSchema;
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
- CaptionsViz.prototype.refreshSchema = function (schema) {
29
+ refreshSchema(schema) {
60
30
  this._captionSchema = schema;
61
- };
31
+ }
62
32
  /**
63
33
  * Refresh visualization captions rules
64
34
  */
65
- CaptionsViz.prototype.initVizCaptions = function (schema) {
66
- return __awaiter(this, void 0, void 0, function () {
67
- return __generator(this, function (_a) {
68
- switch (_a.label) {
69
- case 0:
70
- if (!this._ogma.LKCaptions.nodesCaptionsRule) return [3 /*break*/, 2];
71
- this._ogma.LKCaptions.refreshSchema(schema);
72
- return [4 /*yield*/, this._ogma.LKCaptions.updateNodeCaptions()];
73
- case 1:
74
- _a.sent();
75
- return [3 /*break*/, 3];
76
- case 2:
77
- this._ogma.LKCaptions.updateNodeCaptions(schema.node);
78
- _a.label = 3;
79
- case 3:
80
- if (!this._ogma.LKCaptions.edgesCaptionsRule) return [3 /*break*/, 5];
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
- CaptionsViz.prototype.updateNodeCaptions = function (schema) {
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: function (node) {
64
+ content: (node) => {
107
65
  if (node === undefined) {
108
- return "";
66
+ return ``;
109
67
  }
110
- var value = __1.Captions.getText(node.getData(), _this._captionSchema.node, _this._graphSchema.node);
111
- return tools_1.Tools.isDefined(_this._nodeMaxTextLength)
112
- ? tools_1.Tools.truncate(value, 'middle', _this._nodeMaxTextLength)
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
- CaptionsViz.prototype.updateEdgeCaptions = function (schema) {
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: function (edge) {
93
+ content: (edge) => {
137
94
  if (edge === undefined || edge.getData() === undefined) {
138
- return "";
95
+ return ``;
139
96
  }
140
- var value = __1.Captions.getText(edge.getData(), _this._captionSchema.edge, _this._graphSchema.edge);
141
- return tools_1.Tools.isDefined(_this._edgeMaxTextLength)
142
- ? tools_1.Tools.truncate(value, 'middle', _this._edgeMaxTextLength)
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: function (edge) { return !edge.isVirtual() && edge.isVisible(); },
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
- return CaptionsViz;
157
- }());
112
+ }
113
+ }
158
114
  exports.CaptionsViz = CaptionsViz;
159
115
  //# sourceMappingURL=captions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"captions.js","sourceRoot":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import {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
+ {"version":3,"file":"captions.js","sourceRoot":"","sources":["../../../src/ogma/features/captions.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;AAKb,6BAAuC;AACvC,6CAAwC;AAOxC,MAAa,WAAW;IAUtB,YACE,IAAY,EACJ,kBAAsC,EACtC,kBAAsC;QADtC,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,uBAAkB,GAAlB,kBAAkB,CAAoB;QATxC,mBAAc,GAAiB,EAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAC,CAAC;QACpD,iBAAY,GAGhB,EAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EA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AC,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
- var index_1 = require("../index");
15
- var OgmaStore_1 = require("./OgmaStore");
16
- var RxViz = /** @class */ (function () {
17
- function RxViz(ogma) {
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
- Object.defineProperty(RxViz.prototype, "store", {
28
- get: function () {
29
- return this._store;
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
- RxViz.prototype.listenToSelectionEvents = function () {
38
- var _this = this;
39
- var count = 0;
40
- this._ogma.events.on('animate', function (e) {
41
- var animationEnd = ++count;
42
- _this._store.dispatch(function (state) { return (__assign(__assign({}, state), { animation: true })); });
43
- clearTimeout(_this._animationThrottle);
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
- _this._store.dispatch(function (state) { return (__assign(__assign({}, state), { animation: false })); });
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', function () {
51
- _this._store.dispatch(function (state) { return (__assign(__assign({}, state), { animation: true })); });
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', function () {
54
- _this._store.dispatch(function (state) { return (__assign(__assign({}, state), { animation: false })); });
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', function () {
57
- _this._store.dispatch(_this.storeItems.bind(_this));
41
+ this._ogma.events.on('addNodes', () => {
42
+ this._store.dispatch(this.storeItems.bind(this));
58
43
  });
59
- this._ogma.events.on('removeNodes', function () {
60
- _this._store.dispatch(_this.storeItems.bind(_this));
44
+ this._ogma.events.on('removeNodes', () => {
45
+ this._store.dispatch(this.storeItems.bind(this));
61
46
  });
62
- this._ogma.events.on('addEdges', function () {
63
- _this._store.dispatch(_this.storeItems.bind(_this));
47
+ this._ogma.events.on('addEdges', () => {
48
+ this._store.dispatch(this.storeItems.bind(this));
64
49
  });
65
- this._ogma.events.on('removeEdges', function () {
66
- _this._store.dispatch(_this.storeItems.bind(_this));
50
+ this._ogma.events.on('removeEdges', () => {
51
+ this._store.dispatch(this.storeItems.bind(this));
67
52
  });
68
- this._ogma.events.on('nodesSelected', function () {
69
- _this._store.dispatch(_this.storeNodeSelection.bind(_this));
53
+ this._ogma.events.on('nodesSelected', () => {
54
+ this._store.dispatch(this.storeNodeSelection.bind(this));
70
55
  });
71
- this._ogma.events.on('edgesSelected', function () {
72
- _this._store.dispatch(_this.storeEdgeSelection.bind(_this));
56
+ this._ogma.events.on('edgesSelected', () => {
57
+ this._store.dispatch(this.storeEdgeSelection.bind(this));
73
58
  });
74
- this._ogma.events.on('nodesUnselected', function () {
75
- _this._store.dispatch(_this.storeNodeSelection.bind(_this));
59
+ this._ogma.events.on('nodesUnselected', () => {
60
+ this._store.dispatch(this.storeNodeSelection.bind(this));
76
61
  });
77
- this._ogma.events.on('edgesUnselected', function () {
78
- _this._store.dispatch(_this.storeEdgeSelection.bind(_this));
62
+ this._ogma.events.on('edgesUnselected', () => {
63
+ this._store.dispatch(this.storeEdgeSelection.bind(this));
79
64
  });
80
- this._ogma.events.on('updateNodeData', function (evt) {
65
+ this._ogma.events.on('updateNodeData', (evt) => {
81
66
  if (evt !== undefined) {
82
- evt.changes.forEach(function (change) {
83
- _this._store.dispatch(function (state) { return (__assign(__assign({}, state), { changes: {
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', function (evt) {
76
+ this._ogma.events.on('updateEdgeData', (evt) => {
92
77
  if (evt !== undefined) {
93
- evt.changes.forEach(function (change) {
94
- _this._store.dispatch(function (state) { return (__assign(__assign({}, state), { changes: {
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
- RxViz.prototype.storeItems = function (state) {
107
- return __assign(__assign({}, state), { items: {
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
- RxViz.prototype.storeNodeSelection = function (state) {
116
- return __assign(__assign({}, state), { selection: this._ogma.getSelectedNodes() });
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
- RxViz.prototype.storeEdgeSelection = function (state) {
122
- return __assign(__assign({}, state), { selection: this._ogma.getSelectedEdges() });
123
- };
124
- return RxViz;
125
- }());
106
+ storeEdgeSelection(state) {
107
+ return Object.assign(Object.assign({}, state), { selection: this._ogma.getSelectedEdges() });
108
+ }
109
+ }
126
110
  exports.RxViz = RxViz;
127
- var DummyNodeList = /** @class */ (function () {
128
- function DummyNodeList() {
111
+ class DummyNodeList {
112
+ constructor() {
129
113
  this.size = 0;
130
114
  this.isNode = true;
131
115
  }
132
- return DummyNodeList;
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;;;;;;;;;;;;;AAKb,kCAAoD;AAEpD,yCAAsC;AAStC;IAUE,eAAY,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,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R,OAAO,EAAE;4BACP,UAAU,EAAE,MAAM;4BAClB,KAAK,EAAE,MAAM,CAAC,QAAQ;4BACtB,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;yBAC3B,IACD,EAP8B,CAO9B,CAAC,CAAC;gBACN,CAAC,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,0BAAU,GAAlB,UAAmB,KAAgB;QACjC,6BACK,KAAK,KACR,KAAK,EAAE;gBACL,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE;gBACnC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE;aACpC,IACD;IACJ,CAAC;IAED;;OAEG;IACK,kCAAkB,GAA1B,UAA2B,KAAgB;QACzC,6BACK,KAAK,KACR,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,IACxC;IACJ,CAAC;IAED;;OAEG;IACK,kCAAkB,GAA1B,UAA2B,KAAgB;QACzC,6BACK,KAAK,KACR,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,IACxC;IACJ,CAAC;IACH,YAAC;AAAD,CAAC,AAvID,IAuIC;AAvIY,sBAAK;AAyIlB;IAAA;QACS,SAAI,GAAG,CAAC,CAAC;QACT,WAAM,GAAG,IAAI,CAAC;IACvB,CAAC;IAAD,oBAAC;AAAD,CAAC,AAHD,IAGC;AAHY,sCAAa","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
+ {"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,MAA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AC,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,UAAU,CAAC,KAAgB;QACjC,uCACK,KAAK,KACR,KAAK,EAAE;gBACL,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE;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 declare type SelectionState = 'selection' | 'multiSelection' | 'noSelection';
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[] | undefined;
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) => "node" | "edge" | undefined;
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
  */