@linkurious/ogma-linkurious-parser 4.0.28 → 4.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/dist/ogma/features/nodeGrouping.d.ts +8 -3
- package/dist/ogma/features/nodeGrouping.js +36 -22
- package/dist/ogma/features/nodeGrouping.js.map +1 -1
- package/dist/ogma/features/styles.d.ts +21 -0
- package/dist/ogma/features/styles.js +51 -8
- package/dist/ogma/features/styles.js.map +1 -1
- package/dist/styles/itemAttributes.d.ts +1 -1
- package/dist/styles/itemAttributes.js.map +1 -1
- package/dist/styles/styleRule.d.ts +1 -1
- package/dist/styles/styleRule.js.map +1 -1
- package/package.json +4 -3
|
@@ -37,6 +37,11 @@ export declare class NodeGroupingTransformation {
|
|
|
37
37
|
* @param subNodes nodes part of a virtual node
|
|
38
38
|
*/
|
|
39
39
|
runSubNodesLayout(subNodes: NodeList<LkNodeData, LkEdgeData>): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Get the virtual nodes of the transformation
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
44
|
+
getVirtualNodesOfTransformation(): NodeList<LkNodeData, LkEdgeData>;
|
|
40
45
|
/**
|
|
41
46
|
* Return the caption of a virtual node
|
|
42
47
|
* @param node reference to the virtual node
|
|
@@ -60,9 +65,9 @@ export declare class NodeGroupingTransformation {
|
|
|
60
65
|
* @private
|
|
61
66
|
*/
|
|
62
67
|
private _getAllTransformationRawNodes;
|
|
68
|
+
private _findGroupingPropertyValue;
|
|
63
69
|
/**
|
|
64
|
-
*
|
|
65
|
-
* @private
|
|
70
|
+
* Return a hashed string that represents the group id
|
|
66
71
|
*/
|
|
67
|
-
private
|
|
72
|
+
private _findNodeGroupId;
|
|
68
73
|
}
|
|
@@ -8,8 +8,12 @@ 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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.NodeGroupingTransformation = exports.LKE_NODE_GROUPING_NODE = exports.LKE_NODE_GROUPING_EDGE = void 0;
|
|
16
|
+
const sha1_1 = __importDefault(require("sha1"));
|
|
13
17
|
const index_1 = require("../index");
|
|
14
18
|
const tools_1 = require("../../tools/tools");
|
|
15
19
|
exports.LKE_NODE_GROUPING_EDGE = 'LKE_NODE_GROUPING_EDGE';
|
|
@@ -35,22 +39,15 @@ class NodeGroupingTransformation {
|
|
|
35
39
|
if (this.transformation === undefined) {
|
|
36
40
|
this.transformation = this._ogma.transformations.addNodeGrouping({
|
|
37
41
|
groupIdFunction: (node) => {
|
|
38
|
-
var _a
|
|
42
|
+
var _a;
|
|
39
43
|
if (this._isRuleNotApplicableToNode(node)) {
|
|
40
44
|
return undefined;
|
|
41
45
|
}
|
|
42
46
|
else {
|
|
43
|
-
const propertyValue =
|
|
44
|
-
'properties',
|
|
45
|
-
(_b = (_a = this.groupRule) === null || _a === void 0 ? void 0 : _a.groupingOptions.propertyKey) !== null && _b !== void 0 ? _b : ''
|
|
46
|
-
]);
|
|
47
|
-
// if the property value is of type conflict or invalid value we use the original value
|
|
48
|
-
const originalValue = typeof propertyValue === 'object'
|
|
49
|
-
? propertyValue.original
|
|
50
|
-
: propertyValue;
|
|
47
|
+
const propertyValue = this._findGroupingPropertyValue(node);
|
|
51
48
|
// groupRule is defined if not we returned undefined
|
|
52
49
|
// node with same value will be part of the same group
|
|
53
|
-
return `${(
|
|
50
|
+
return `${(_a = this.groupRule) === null || _a === void 0 ? void 0 : _a.groupingOptions.itemType}-${propertyValue}`
|
|
54
51
|
.toLowerCase()
|
|
55
52
|
.trim();
|
|
56
53
|
}
|
|
@@ -58,11 +55,9 @@ class NodeGroupingTransformation {
|
|
|
58
55
|
nodeGenerator: (nodes) => {
|
|
59
56
|
return {
|
|
60
57
|
data: {
|
|
61
|
-
// groupRule is defined as a virtual node only exist if the rule is defined
|
|
62
58
|
categories: [exports.LKE_NODE_GROUPING_NODE],
|
|
63
|
-
properties: {
|
|
64
|
-
|
|
65
|
-
}
|
|
59
|
+
properties: {},
|
|
60
|
+
nodeGroupId: this._findNodeGroupId(nodes)
|
|
66
61
|
}
|
|
67
62
|
};
|
|
68
63
|
},
|
|
@@ -123,7 +118,9 @@ class NodeGroupingTransformation {
|
|
|
123
118
|
}
|
|
124
119
|
},
|
|
125
120
|
nodeSelector: (node) => {
|
|
126
|
-
|
|
121
|
+
// TODO: Tools.isDefined(node.getSubNodes()) is a work around for an ogma issue visible when using image export plugin with Node grouping
|
|
122
|
+
// remove when updating to Ogma v5.1.x
|
|
123
|
+
return node.isVirtual() && tools_1.Tools.isDefined(node.getSubNodes());
|
|
127
124
|
},
|
|
128
125
|
// the style will be updated when data object is updated
|
|
129
126
|
nodeDependencies: { self: { data: true } }
|
|
@@ -163,6 +160,14 @@ class NodeGroupingTransformation {
|
|
|
163
160
|
}
|
|
164
161
|
});
|
|
165
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Get the virtual nodes of the transformation
|
|
165
|
+
* @private
|
|
166
|
+
*/
|
|
167
|
+
getVirtualNodesOfTransformation() {
|
|
168
|
+
// @ts-ignore getContext exists on the transformation but hidden by the types
|
|
169
|
+
return this.transformation.getContext().virtualNodes;
|
|
170
|
+
}
|
|
166
171
|
/**
|
|
167
172
|
* Return the caption of a virtual node
|
|
168
173
|
* @param node reference to the virtual node
|
|
@@ -170,10 +175,11 @@ class NodeGroupingTransformation {
|
|
|
170
175
|
_getNodeGroupingCaption(node) {
|
|
171
176
|
if (node !== undefined && node.isVirtual()) {
|
|
172
177
|
// get the property value of the first node of the group (all nodes share the same property value)
|
|
173
|
-
const
|
|
178
|
+
const lkPropertyValue = node
|
|
174
179
|
.getSubNodes()
|
|
175
180
|
.get(0)
|
|
176
181
|
.getData(['properties', this.groupRule.groupingOptions.propertyKey]);
|
|
182
|
+
const propertyValue = tools_1.Tools.getValueFromLkProperty(lkPropertyValue);
|
|
177
183
|
const size = node.getSubNodes().filter((e) => !e.hasClass('filtered')).size;
|
|
178
184
|
return `${propertyValue} (${size})`;
|
|
179
185
|
}
|
|
@@ -231,16 +237,24 @@ class NodeGroupingTransformation {
|
|
|
231
237
|
* @private
|
|
232
238
|
*/
|
|
233
239
|
_getAllTransformationRawNodes() {
|
|
234
|
-
const virtualNodes = this.
|
|
240
|
+
const virtualNodes = this.getVirtualNodesOfTransformation();
|
|
235
241
|
return virtualNodes.getSubNodes();
|
|
236
242
|
}
|
|
243
|
+
_findGroupingPropertyValue(node) {
|
|
244
|
+
var _a, _b;
|
|
245
|
+
const propertyValue = node.getData([
|
|
246
|
+
'properties',
|
|
247
|
+
(_b = (_a = this.groupRule) === null || _a === void 0 ? void 0 : _a.groupingOptions.propertyKey) !== null && _b !== void 0 ? _b : ''
|
|
248
|
+
]);
|
|
249
|
+
return `${tools_1.Tools.getValueFromLkProperty(propertyValue)}`;
|
|
250
|
+
}
|
|
237
251
|
/**
|
|
238
|
-
*
|
|
239
|
-
* @private
|
|
252
|
+
* Return a hashed string that represents the group id
|
|
240
253
|
*/
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
254
|
+
_findNodeGroupId(nodes) {
|
|
255
|
+
var _a, _b;
|
|
256
|
+
const propertyValue = this._findGroupingPropertyValue(nodes.get(0));
|
|
257
|
+
return (0, sha1_1.default)(`${(_a = this.groupRule) === null || _a === void 0 ? void 0 : _a.name}-${(_b = this.groupRule) === null || _b === void 0 ? void 0 : _b.groupingOptions.itemType}-${propertyValue}`);
|
|
244
258
|
}
|
|
245
259
|
}
|
|
246
260
|
exports.NodeGroupingTransformation = NodeGroupingTransformation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeGrouping.js","sourceRoot":"","sources":["../../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a,CAAC;YAC/B,mCAAmC;YACnC,CAAC,OAAO,aAAa,KAAK,QAAQ,IAAK,aAA8B,CAAC,MAAM,KAAK,SAAS,CAAC,CAC5F,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACW,WAAW,CAAC,KAA6B;;YACrD,MAAM,OAAO,CAAC,GAAG,CACf,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;gBACrB,IAAI,QAAQ,KAAK,IAAI,EAAE;oBACrB,OAAO,QAAQ,CAAC,YAAY,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;iBAClD;YACH,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;KAAA;IAED;;;OAGG;IACK,6BAA6B;QACnC,MAAM,YAAY,GAAG,IAAI,CAAC,gCAAgC,EAAE,CAAC;QAC7D,OAAO,YAAY,CAAC,WAAW,EAAE,CAAC;IACpC,CAAC;IAED;;;OAGG;IACK,gCAAgC;QACtC,6EAA6E;QAC7E,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC,YAAY,CAAC;IACvD,CAAC;CACF;AAzOD,gEAyOC","sourcesContent":["import {Transformation, Node, NodeList} from '@linkurious/ogma';\nimport {\n ConflictValue,\n LkEdgeData,\n LkNodeData,\n MissingValue,\n NodeGroupingRule\n} from '@linkurious/rest-client';\n\nimport {FORCE_LAYOUT_CONFIG, LKOgma} from '../index';\nimport {Tools} from '../../tools/tools';\n\nexport const LKE_NODE_GROUPING_EDGE = 'LKE_NODE_GROUPING_EDGE';\nexport const LKE_NODE_GROUPING_NODE = 'LKE_NODE_GROUPING_NODE';\n\nexport class NodeGroupingTransformation {\n public transformation?: Transformation<LkNodeData, LkEdgeData>;\n public groupRule?: NodeGroupingRule;\n private _ogma: LKOgma;\n\n constructor(ogma: LKOgma) {\n this._ogma = ogma;\n }\n\n /**\n * Set the grouping rule\n * @param rule of grouping\n */\n public setGroupingRule(rule: NodeGroupingRule | undefined): void {\n this.groupRule = rule;\n }\n\n /**\n * create a node grouping transformation\n * It uses groupRule to define the rule\n * Group the nodes based on a category type and a property value\n */\n public async initTransformation(): Promise<void> {\n if (this.transformation === undefined) {\n this.transformation = this._ogma.transformations.addNodeGrouping({\n groupIdFunction: (node) => {\n if (this._isRuleNotApplicableToNode(node)) {\n return undefined;\n } else {\n const propertyValue = node.getData([\n 'properties',\n this.groupRule?.groupingOptions.propertyKey ?? ''\n ]);\n // if the property value is of type conflict or invalid value we use the original value\n const originalValue =\n typeof propertyValue === 'object'\n ? (propertyValue as ConflictValue).original\n : propertyValue;\n // groupRule is defined if not we returned undefined\n // node with same value will be part of the same group\n return `${this.groupRule?.groupingOptions.itemType}-${originalValue}`\n .toLowerCase()\n .trim();\n }\n },\n nodeGenerator: (nodes) => {\n return {\n data: {\n // groupRule is defined as a virtual node only exist if the rule is defined\n categories: [LKE_NODE_GROUPING_NODE],\n properties: {\n size: nodes.size\n }\n }\n };\n },\n edgeGenerator: () => {\n return {\n data: {\n type: LKE_NODE_GROUPING_EDGE\n }\n };\n },\n showContents: true,\n duration: 300,\n padding: 10\n });\n // TODO remove setTimeout when LKE-10453 is fixed\n setTimeout(() => {\n this.transformation!.refresh();\n }, 200);\n } else {\n await this.refreshTransformation();\n }\n }\n\n /**\n * refresh the transformation\n * Called when there is a change in the rule\n */\n public async refreshTransformation(): Promise<void> {\n if (this.transformation !== undefined) {\n await this.transformation.refresh();\n await this._unpinNodes(this._getAllTransformationRawNodes());\n } else {\n await this.initTransformation();\n }\n }\n\n /**\n * init node grouping style\n */\n public initNodeGroupingStyle(): void {\n this._ogma.styles.addRule({\n nodeAttributes: {\n // Any default style will go here\n text: {\n content: (node: Node<LkNodeData> | undefined): string | undefined => {\n return this._getNodeGroupingCaption(node);\n },\n style: 'bold'\n },\n layer: -1,\n color: 'rgba(240, 240, 240)',\n innerStroke: {\n color: '#7f7f7f',\n width: 2\n }\n },\n nodeSelector: (node) => {\n return node.isVirtual();\n },\n // the style will be updated when data object is updated\n nodeDependencies: {self: {data: true}}\n });\n }\n\n /**\n * run layout on all subnodes of virtual nodes\n */\n public async runLayoutOnAllSubNodes(): Promise<void> {\n await this._ogma.transformations.afterNextUpdate();\n const rawNodesList = this._getAllTransformationRawNodes();\n const promisesList: Promise<void>[] = [];\n for (let i = 0; i < rawNodesList.length; i++) {\n // rawNodesList[i] is not null because each group has at least one node\n const subNodes = rawNodesList[i]!;\n promisesList.push(this.runSubNodesLayout(subNodes));\n }\n await Promise.all(promisesList);\n }\n\n /**\n * Run the layout on the subnodes of the virtual node\n * @param subNodes nodes part of a virtual node\n */\n public async runSubNodesLayout(subNodes: NodeList<LkNodeData, LkEdgeData>): Promise<void> {\n if (subNodes.size === 0) {\n return;\n }\n\n const noEdges = subNodes.getAdjacentEdges({bothExtremities: true}).size === 0;\n if (noEdges) {\n await this._runCirclePack(subNodes);\n } else {\n await this._runForceLayout(subNodes);\n }\n }\n\n /**\n * Return the caption of a virtual node\n * @param node reference to the virtual node\n */\n private _getNodeGroupingCaption(node: Node<LkNodeData> | undefined): string | undefined {\n if (node !== undefined && node.isVirtual()) {\n // get the property value of the first node of the group (all nodes share the same property value)\n const propertyValue = node\n .getSubNodes()!\n .get(0)\n .getData(['properties', this.groupRule!.groupingOptions.propertyKey]);\n const size = node.getSubNodes()!.filter((e) => !e.hasClass('filtered')).size;\n return `${propertyValue} (${size})`;\n }\n }\n\n /**\n * Run the circle pack layout on the subnodes\n * @param subNodes\n */\n private async _runCirclePack(subNodes: NodeList<LkNodeData, LkEdgeData>): Promise<void> {\n await this._ogma.algorithms.circlePack({\n nodes: subNodes,\n margin: 10,\n sort: 'asc'\n });\n }\n\n private async _runForceLayout(subNodes: NodeList<LkNodeData, LkEdgeData>): Promise<void> {\n await this._ogma.layouts.force({\n nodes: subNodes,\n ...FORCE_LAYOUT_CONFIG\n });\n }\n\n private _isRuleNotApplicableToNode(node: Node<LkNodeData>): boolean {\n const propertyValue = node.getData([\n 'properties',\n this.groupRule?.groupingOptions.propertyKey ?? ''\n ]);\n return (\n // if the group rule is not defined\n this.groupRule === undefined ||\n // if rule is applied to a different category\n !node.getData('categories').includes(this.groupRule.groupingOptions.itemType) ||\n // if the property value is not defined\n !Tools.isDefined(propertyValue) ||\n // if the property value is missing\n (typeof propertyValue === 'object' && (propertyValue as MissingValue).status === 'missing')\n );\n }\n\n /**\n * Unpin list of nodes\n * @param nodes\n * @private\n */\n private async _unpinNodes(nodes: Array<NodeList | null>): Promise<void> {\n await Promise.all(\n nodes.map((nodeList) => {\n if (nodeList !== null) {\n return nodeList.setAttribute('layoutable', true);\n }\n })\n );\n }\n\n /**\n * Get all the raw nodes part of the transformation\n * @private\n */\n private _getAllTransformationRawNodes(): Array<NodeList | null> {\n const virtualNodes = this._getVirtualNodesOfTransformation();\n return virtualNodes.getSubNodes();\n }\n\n /**\n * Get the virtual nodes of the transformation\n * @private\n */\n private _getVirtualNodesOfTransformation(): NodeList<LkNodeData, LkEdgeData> {\n // @ts-ignore getContext exists on the transformation but hidden by the types\n return this.transformation.getContext().virtualNodes;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"nodeGrouping.js","sourceRoot":"","sources":["../../../src/ogma/features/nodeGrouping.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,gDAAwB;AAExB,oCAAqD;AACrD,6CAAwC;AAE3B,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAClD,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAE/D,MAAa,0BAA0B;IAKrC,YAAY,IAAY;QACtB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED;;;OAGG;IACI,eAAe,CAAC,IAAkC;QACvD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACU,kBAAkB;;YAC7B,IAAI,IAAI,CAAC,cAAc,KAAK,SAAS,EAAE;gBACrC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,eAAe,CAAC;oBAC/D,e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,GAAG,IAAI,CAAC,+BAA+B,EAAE,CAAC;QAC5D,OAAO,YAAY,CAAC,WAAW,EAAE,CAAC;IACpC,CAAC;IAEO,0BAA0B,CAAC,IAAsB;;QACvD,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC;YACjC,YAAY;YACZ,MAAA,MAAA,IAAI,CAAC,SAAS,0CAAE,eAAe,CAAC,WAAW,mCAAI,EAAE;SAClD,CAAC,CAAC;QACH,OAAO,GAAG,aAAK,CAAC,sBAAsB,CAAC,aAAa,CAAC,EAAE,CAAC;IAC1D,CAAC;IAED;;OAEG;IACK,gBAAgB,CAAC,KAAuC;;QAC9D,MAAM,aAAa,GAAG,IAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACpE,OAAO,IAAA,cAAI,EACT,GAAG,MAAA,IAAI,CAAC,SAAS,0CAAE,IAAI,IAAI,MAAA,IAAI,CAAC,SAAS,0CAAE,eAAe,CAAC,QAAQ,IAAI,aAAa,EAAE,CACvF,CAAC;IACJ,CAAC;CACF;AApPD,gEAoPC","sourcesContent":["import {Transformation, Node, NodeList} from '@linkurious/ogma';\nimport {LkEdgeData, LkNodeData, MissingValue, NodeGroupingRule} from '@linkurious/rest-client';\nimport sha1 from 'sha1';\n\nimport {FORCE_LAYOUT_CONFIG, LKOgma} from '../index';\nimport {Tools} from '../../tools/tools';\n\nexport const LKE_NODE_GROUPING_EDGE = 'LKE_NODE_GROUPING_EDGE';\nexport const LKE_NODE_GROUPING_NODE = 'LKE_NODE_GROUPING_NODE';\n\nexport class NodeGroupingTransformation {\n public transformation?: Transformation<LkNodeData, LkEdgeData>;\n public groupRule?: NodeGroupingRule;\n private _ogma: LKOgma;\n\n constructor(ogma: LKOgma) {\n this._ogma = ogma;\n }\n\n /**\n * Set the grouping rule\n * @param rule of grouping\n */\n public setGroupingRule(rule: NodeGroupingRule | undefined): void {\n this.groupRule = rule;\n }\n\n /**\n * create a node grouping transformation\n * It uses groupRule to define the rule\n * Group the nodes based on a category type and a property value\n */\n public async initTransformation(): Promise<void> {\n if (this.transformation === undefined) {\n this.transformation = this._ogma.transformations.addNodeGrouping({\n groupIdFunction: (node) => {\n if (this._isRuleNotApplicableToNode(node)) {\n return undefined;\n } else {\n const propertyValue = this._findGroupingPropertyValue(node);\n // groupRule is defined if not we returned undefined\n // node with same value will be part of the same group\n return `${this.groupRule?.groupingOptions.itemType}-${propertyValue}`\n .toLowerCase()\n .trim();\n }\n },\n nodeGenerator: (nodes) => {\n return {\n data: {\n categories: [LKE_NODE_GROUPING_NODE],\n properties: {},\n nodeGroupId: this._findNodeGroupId(nodes)\n }\n };\n },\n edgeGenerator: () => {\n return {\n data: {\n type: LKE_NODE_GROUPING_EDGE\n }\n };\n },\n showContents: true,\n duration: 300,\n padding: 10\n });\n // TODO remove setTimeout when LKE-10453 is fixed\n setTimeout(() => {\n this.transformation!.refresh();\n }, 200);\n } else {\n await this.refreshTransformation();\n }\n }\n\n /**\n * refresh the transformation\n * Called when there is a change in the rule\n */\n public async refreshTransformation(): Promise<void> {\n if (this.transformation !== undefined) {\n await this.transformation.refresh();\n await this._unpinNodes(this._getAllTransformationRawNodes());\n } else {\n await this.initTransformation();\n }\n }\n\n /**\n * init node grouping style\n */\n public initNodeGroupingStyle(): void {\n this._ogma.styles.addRule({\n nodeAttributes: {\n // Any default style will go here\n text: {\n content: (node: Node<LkNodeData> | undefined): string | undefined => {\n return this._getNodeGroupingCaption(node);\n },\n style: 'bold'\n },\n layer: -1,\n color: 'rgba(240, 240, 240)',\n innerStroke: {\n color: '#7f7f7f',\n width: 2\n }\n },\n nodeSelector: (node) => {\n // TODO: Tools.isDefined(node.getSubNodes()) is a work around for an ogma issue visible when using image export plugin with Node grouping\n // remove when updating to Ogma v5.1.x\n return node.isVirtual() && Tools.isDefined(node.getSubNodes());\n },\n // the style will be updated when data object is updated\n nodeDependencies: {self: {data: true}}\n });\n }\n\n /**\n * run layout on all subnodes of virtual nodes\n */\n public async runLayoutOnAllSubNodes(): Promise<void> {\n await this._ogma.transformations.afterNextUpdate();\n const rawNodesList = this._getAllTransformationRawNodes();\n const promisesList: Promise<void>[] = [];\n for (let i = 0; i < rawNodesList.length; i++) {\n // rawNodesList[i] is not null because each group has at least one node\n const subNodes = rawNodesList[i]!;\n promisesList.push(this.runSubNodesLayout(subNodes));\n }\n await Promise.all(promisesList);\n }\n\n /**\n * Run the layout on the subnodes of the virtual node\n * @param subNodes nodes part of a virtual node\n */\n public async runSubNodesLayout(subNodes: NodeList<LkNodeData, LkEdgeData>): Promise<void> {\n if (subNodes.size === 0) {\n return;\n }\n\n const noEdges = subNodes.getAdjacentEdges({bothExtremities: true}).size === 0;\n if (noEdges) {\n await this._runCirclePack(subNodes);\n } else {\n await this._runForceLayout(subNodes);\n }\n }\n\n /**\n * Get the virtual nodes of the transformation\n * @private\n */\n public getVirtualNodesOfTransformation(): NodeList<LkNodeData, LkEdgeData> {\n // @ts-ignore getContext exists on the transformation but hidden by the types\n return this.transformation.getContext().virtualNodes;\n }\n\n /**\n * Return the caption of a virtual node\n * @param node reference to the virtual node\n */\n private _getNodeGroupingCaption(node: Node<LkNodeData> | undefined): string | undefined {\n if (node !== undefined && node.isVirtual()) {\n // get the property value of the first node of the group (all nodes share the same property value)\n const lkPropertyValue = node\n .getSubNodes()!\n .get(0)\n .getData(['properties', this.groupRule!.groupingOptions.propertyKey]);\n const propertyValue = Tools.getValueFromLkProperty(lkPropertyValue);\n const size = node.getSubNodes()!.filter((e) => !e.hasClass('filtered')).size;\n return `${propertyValue} (${size})`;\n }\n }\n\n /**\n * Run the circle pack layout on the subnodes\n * @param subNodes\n */\n private async _runCirclePack(subNodes: NodeList<LkNodeData, LkEdgeData>): Promise<void> {\n await this._ogma.algorithms.circlePack({\n nodes: subNodes,\n margin: 10,\n sort: 'asc'\n });\n }\n\n private async _runForceLayout(subNodes: NodeList<LkNodeData, LkEdgeData>): Promise<void> {\n await this._ogma.layouts.force({\n nodes: subNodes,\n ...FORCE_LAYOUT_CONFIG\n });\n }\n\n private _isRuleNotApplicableToNode(node: Node<LkNodeData>): boolean {\n const propertyValue = node.getData([\n 'properties',\n this.groupRule?.groupingOptions.propertyKey ?? ''\n ]);\n return (\n // if the group rule is not defined\n this.groupRule === undefined ||\n // if rule is applied to a different category\n !node.getData('categories').includes(this.groupRule.groupingOptions.itemType) ||\n // if the property value is not defined\n !Tools.isDefined(propertyValue) ||\n // if the property value is missing\n (typeof propertyValue === 'object' && (propertyValue as MissingValue).status === 'missing')\n );\n }\n\n /**\n * Unpin list of nodes\n * @param nodes\n * @private\n */\n private async _unpinNodes(nodes: Array<NodeList | null>): Promise<void> {\n await Promise.all(\n nodes.map((nodeList) => {\n if (nodeList !== null) {\n return nodeList.setAttribute('layoutable', true);\n }\n })\n );\n }\n\n /**\n * Get all the raw nodes part of the transformation\n * @private\n */\n private _getAllTransformationRawNodes(): Array<NodeList | null> {\n const virtualNodes = this.getVirtualNodesOfTransformation();\n return virtualNodes.getSubNodes();\n }\n\n private _findGroupingPropertyValue(node: Node<LkNodeData>): string {\n const propertyValue = node.getData([\n 'properties',\n this.groupRule?.groupingOptions.propertyKey ?? ''\n ]);\n return `${Tools.getValueFromLkProperty(propertyValue)}`;\n }\n\n /**\n * Return a hashed string that represents the group id\n */\n private _findNodeGroupId(nodes: NodeList<LkNodeData, LkEdgeData>): string {\n const propertyValue = this._findGroupingPropertyValue(nodes.get(0));\n return sha1(\n `${this.groupRule?.name}-${this.groupRule?.groupingOptions.itemType}-${propertyValue}`\n );\n }\n}\n"]}
|
|
@@ -150,4 +150,25 @@ export declare class StylesViz {
|
|
|
150
150
|
* @param {Array<LKStyleRule>} shapeStyleRules
|
|
151
151
|
*/
|
|
152
152
|
refreshEdgeShape(shapeStyleRules: Array<LKStyleRule<IEdgeStyle>>): void;
|
|
153
|
+
/**
|
|
154
|
+
* Get node radius
|
|
155
|
+
* This is a workaround for an ogma issue where the radius of virtual nodes is always set to 5
|
|
156
|
+
* TODO: check if this is still needed after ogma release the new improvement for transformation v5.X
|
|
157
|
+
*/
|
|
158
|
+
private _getNodeRadius;
|
|
159
|
+
/**
|
|
160
|
+
* Calculate the scale of the pin badge related to the node radius
|
|
161
|
+
* This is useful when dealing wih huge nodes, and we don't want the badge to be big
|
|
162
|
+
* If the node is small enough, the badge will be 0.46 of the node radius
|
|
163
|
+
* Else it will be 5 / radius
|
|
164
|
+
*/
|
|
165
|
+
private _findPinBadgeScale;
|
|
166
|
+
/**
|
|
167
|
+
* Find the color of the pin badge text
|
|
168
|
+
*/
|
|
169
|
+
private _findPinBadgeTextColor;
|
|
170
|
+
/**
|
|
171
|
+
* Find the color of the pin badge background
|
|
172
|
+
*/
|
|
173
|
+
private _findPinBadgeBackgroundColor;
|
|
153
174
|
}
|
|
@@ -380,15 +380,10 @@ class StylesViz {
|
|
|
380
380
|
badges: {
|
|
381
381
|
bottomRight: (node) => {
|
|
382
382
|
if (node !== undefined && !node.getAttribute('layoutable')) {
|
|
383
|
-
const nodeColor = Array.isArray(node.getAttribute('color'))
|
|
384
|
-
? node.getAttribute('color')[0]
|
|
385
|
-
: node.getAttribute('color');
|
|
386
|
-
const textColor = __1.OgmaTools.isBright(nodeColor)
|
|
387
|
-
? DARK_FONT_COLOR
|
|
388
|
-
: CLEAR_FONT_COLOR;
|
|
389
383
|
return {
|
|
390
|
-
color:
|
|
384
|
+
color: this._findPinBadgeBackgroundColor(node),
|
|
391
385
|
minVisibleSize: 20,
|
|
386
|
+
scale: this._findPinBadgeScale(node),
|
|
392
387
|
stroke: {
|
|
393
388
|
width: 0,
|
|
394
389
|
color: null
|
|
@@ -396,7 +391,7 @@ class StylesViz {
|
|
|
396
391
|
text: {
|
|
397
392
|
font: 'FontAwesome',
|
|
398
393
|
scale: 0.4,
|
|
399
|
-
color:
|
|
394
|
+
color: this._findPinBadgeTextColor(node),
|
|
400
395
|
content: node.getAttribute('layoutable') ? null : '\uf08d'
|
|
401
396
|
}
|
|
402
397
|
};
|
|
@@ -641,6 +636,54 @@ class StylesViz {
|
|
|
641
636
|
this._ogmaEdgeShape.refresh();
|
|
642
637
|
}
|
|
643
638
|
}
|
|
639
|
+
/**
|
|
640
|
+
* Get node radius
|
|
641
|
+
* This is a workaround for an ogma issue where the radius of virtual nodes is always set to 5
|
|
642
|
+
* TODO: check if this is still needed after ogma release the new improvement for transformation v5.X
|
|
643
|
+
*/
|
|
644
|
+
_getNodeRadius(node) {
|
|
645
|
+
var _a;
|
|
646
|
+
if (!node.isVirtual()) {
|
|
647
|
+
return node.getAttribute('radius');
|
|
648
|
+
}
|
|
649
|
+
else {
|
|
650
|
+
// get the width and height of the box that contains the nodes inside the virtual node
|
|
651
|
+
const { width, height } = (_a = node.getSubNodes()) === null || _a === void 0 ? void 0 : _a.getBoundingBox();
|
|
652
|
+
return Math.max(width, height);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Calculate the scale of the pin badge related to the node radius
|
|
657
|
+
* This is useful when dealing wih huge nodes, and we don't want the badge to be big
|
|
658
|
+
* If the node is small enough, the badge will be 0.46 of the node radius
|
|
659
|
+
* Else it will be 5 / radius
|
|
660
|
+
*/
|
|
661
|
+
_findPinBadgeScale(node) {
|
|
662
|
+
// the maximum radius for the badge
|
|
663
|
+
const MAX = 5;
|
|
664
|
+
const defaultRatio = 0.46;
|
|
665
|
+
const bigNodeRatio = 0.17;
|
|
666
|
+
const radius = this._getNodeRadius(node);
|
|
667
|
+
return radius * defaultRatio > MAX ? bigNodeRatio : defaultRatio;
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Find the color of the pin badge text
|
|
671
|
+
*/
|
|
672
|
+
_findPinBadgeTextColor(node) {
|
|
673
|
+
if (node.isVirtual()) {
|
|
674
|
+
return CLEAR_FONT_COLOR;
|
|
675
|
+
}
|
|
676
|
+
const nodeColor = Array.isArray(node.getAttribute('color'))
|
|
677
|
+
? node.getAttribute('color')[0]
|
|
678
|
+
: node.getAttribute('color');
|
|
679
|
+
return __1.OgmaTools.isBright(nodeColor) ? DARK_FONT_COLOR : CLEAR_FONT_COLOR;
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* Find the color of the pin badge background
|
|
683
|
+
*/
|
|
684
|
+
_findPinBadgeBackgroundColor(node) {
|
|
685
|
+
return node.isVirtual() ? __1.BASE_GREY : 'inherit';
|
|
686
|
+
}
|
|
644
687
|
}
|
|
645
688
|
exports.StylesViz = StylesViz;
|
|
646
689
|
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/ogma/features/styles.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAuBb,6BASe;AACf,6CAAwC;AAaxC,MAAM,2BAA2B,GAAgD;IAC/E,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM;QACb,eAAe,EAAE,MAAM;QACvB,cAAc,EAAE,CAAC;KAClB;IACD,WAAW,EAAE,EAAC,KAAK,EAAE,CAAC,EAAC;IACvB,OAAO,EAAE,KAAK;CACf,CAAC;AAEF,MAAM,2BAA2B,GAAgD;IAC/E,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM;QACb,eAAe,EAAE,MAAM;QACvB,cAAc,EAAE,CAAC;KAClB;IACD,OAAO,EAAE,KAAK;CACf,CAAC;AAEF,MAAM,uBAAuB,GAAG;IAC9B,KAAK,EAAE,MAAM;IACb,KAAK,EAAE,CAAC;IACR,aAAa,EAAE,QAAQ;IACvB,WAAW,EAAE,CAAC;IACd,oBAAoB,EAAE,KAAK;CAK5B,CAAC;AAEF,MAAM,uBAAuB,GAAG;IAC9B,KAAK,EAAE,MAAM;IACb,aAAa,EAAE,QAAQ;IACvB,KAAK,EAAE,CAAC;CAIT,CAAC;AAEF,MAAM,iBAAiB,GAAG,sBAAsB,CAAC;AACjD,MAAM,eAAe,GAAG,MAAM,CAAC;AAC/B,MAAM,gBAAgB,GAAG,MAAM,CAAC;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AE;oBACd,KAAK,EAAE,CAAC,IAAwB,EAAE,EAAE;wBAClC,IAAI,IAAI,KAAK,SAAS,EAAE;4BACtB,OAAO,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;yBACnD;oBACH,CAAC;iBACF;gBACD,gBAAgB,EAAE,EAAC,IAAI,EAAE,EAAC,IAAI,EAAE,IAAI,EAAC,EAAC;aACvC,CAAC,CAAC;SACJ;aAAM;YACL,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,eAAe,EAAC,CAAC,CAAC;YACvD,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;SAC/B;IACH,CAAC;CACF;AAhtBD,8BAgtBC","sourcesContent":["'use strict';\n\nimport * as o from '@linkurious/ogma';\nimport {\n Edge,\n EdgeAttributesValue,\n NodeAttributesValue,\n StyleClass,\n StyleRule\n} from '@linkurious/ogma';\nimport {\n GenericObject,\n IEdgeStyle,\n INodeStyle,\n IStyleIcon,\n IStyleRule,\n LkEdgeData,\n LkNodeData,\n OgmaEdgeShape,\n OgmaNodeShape,\n TextOptions\n} from '@linkurious/rest-client';\n\nimport {\n BASE_GREY,\n EdgeAttributes,\n LKOgma,\n NodeAttributes,\n OgmaTools,\n StyleRule as LKStyleRule,\n StyleRules,\n StyleType\n} from '../..';\nimport {Tools} from '../../tools/tools';\nimport {OgmaImage} from '../../styles/nodeAttributes';\n\nexport interface StylesConfig {\n nodeColorStyleRules: Array<LKStyleRule>;\n nodeIconStyleRules: Array<LKStyleRule>;\n nodeSizeStyleRules: Array<LKStyleRule>;\n nodeShapeStyleRules?: Array<LKStyleRule>;\n edgeColorStyleRules: Array<LKStyleRule>;\n edgeWidthStyleRules: Array<LKStyleRule>;\n edgeShapeStyleRules?: Array<LKStyleRule>;\n}\n\nconst HOVERED_SELECTED_NODE_STYLE: NodeAttributesValue<LkNodeData, LkEdgeData> = {\n text: {\n style: 'bold',\n backgroundColor: '#fff',\n minVisibleSize: 0\n },\n outerStroke: {width: 2},\n outline: false\n};\n\nconst HOVERED_SELECTED_EDGE_STYLE: EdgeAttributesValue<LkEdgeData, LkNodeData> = {\n text: {\n style: 'bold',\n backgroundColor: '#fff',\n minVisibleSize: 0\n },\n outline: false\n};\n\nconst NODE_HALO_CONFIGURATION = {\n color: '#FFF',\n width: 7,\n scalingMethod: 'scaled',\n strokeWidth: 0,\n hideNonAdjacentEdges: false\n} as {\n color: '#FFF';\n width: 7;\n strokeWidth: 0;\n};\n\nconst EDGE_HALO_CONFIGURATION = {\n color: '#FFF',\n scalingMethod: 'scaled',\n width: 4\n} as {\n color: '#FFF';\n width: 4;\n};\n\nconst DEFAULT_OGMA_FONT = \"'roboto', sans-serif\";\nconst DARK_FONT_COLOR = '#000';\nconst CLEAR_FONT_COLOR = '#FFF';\nconst ITEM_DEFAULT_COLOR = '#7f7f7f';\nexport const FILTER_OPACITY = 0.2;\n\nexport class StylesViz {\n private _ogma: LKOgma;\n private _exportClass!: StyleClass;\n private _nodeDefaultStylesRules!: StyleRule<LkNodeData, LkEdgeData>;\n // @ts-ignore\n private _nodeDefaultHaloRules!: StyleRule<LkNodeData, LkEdgeData>;\n private _edgeDefaultStylesRules!: StyleRule<LkNodeData, LkEdgeData>;\n // @ts-ignore\n private _edgeDefaultHaloRules!: StyleRule<LkNodeData, LkEdgeData>;\n\n private _nodeAttributes: NodeAttributes = new NodeAttributes({});\n private _edgeAttributes: EdgeAttributes = new EdgeAttributes({});\n\n private _ogmaNodeColor!: StyleRule;\n private _ogmaNodeIcon!: StyleRule;\n private _ogmaNodeSize!: StyleRule;\n private _ogmaNodeShape!: StyleRule;\n private _ogmaEdgeColor!: StyleRule;\n private _ogmaEdgeWidth!: StyleRule;\n private _ogmaEdgeShape!: StyleRule;\n private _defaultConfiguration: {\n node: {\n nodeRadius?: number;\n shape?: OgmaNodeShape;\n text?: TextOptions & {\n nodePosition?: 'right' | 'left' | 'top' | 'bottom' | 'center';\n };\n };\n edge: {\n edgeWidth?: number;\n shape?: OgmaEdgeShape;\n text?: TextOptions;\n };\n };\n\n constructor(\n ogma: LKOgma,\n configuration: {\n node: {\n nodeRadius?: number;\n shape?: OgmaNodeShape;\n text?: TextOptions & {\n nodePosition?: 'right' | 'left' | 'top' | 'bottom' | 'center';\n };\n };\n edge: {\n edgeWidth?: number;\n shape?: OgmaEdgeShape;\n text?: TextOptions;\n };\n baseUrl?: string;\n }\n ) {\n this._ogma = ogma;\n this._defaultConfiguration = configuration;\n this._nodeAttributes.setBaseUrl(configuration.baseUrl);\n }\n\n /**\n * Set nodes default styles based on the configuration\n */\n public setNodesDefaultStyles(): void {\n // setting selection and hover attributes\n this._ogma.styles.setHoveredNodeAttributes(HOVERED_SELECTED_NODE_STYLE);\n this._ogma.styles.setSelectedNodeAttributes(HOVERED_SELECTED_NODE_STYLE);\n // setting default styles\n this._nodeDefaultStylesRules = this._ogma.styles.addRule({\n nodeAttributes: {\n text: {\n padding: 5,\n minVisibleSize:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.minVisibleSize\n ? this._defaultConfiguration.node.text.minVisibleSize\n : 12,\n maxLineLength:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.maxLineLength !== undefined\n ? this._defaultConfiguration.node.text.maxLineLength\n : 30,\n position:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.nodePosition !== undefined\n ? this._defaultConfiguration.node.text.nodePosition\n : 'bottom',\n backgroundColor:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.backgroundColor !== undefined\n ? this._defaultConfiguration.node.text.backgroundColor\n : undefined,\n font:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.font !== undefined\n ? this._defaultConfiguration.node.text.font\n : \"'roboto', sans-serif\",\n color:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.color !== undefined\n ? this._defaultConfiguration.node.text.color\n : 'black',\n size:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.size !== undefined\n ? this._defaultConfiguration.node.text.size\n : 14,\n margin: 5\n },\n radius: this.defaultNodeRadius(this._defaultConfiguration.node),\n icon: {\n minVisibleSize: 15\n },\n color: ITEM_DEFAULT_COLOR,\n shape:\n this._defaultConfiguration.node.shape !== undefined\n ? this._defaultConfiguration.node.shape\n : ('circle' as OgmaNodeShape),\n innerStroke: {\n width: 3\n },\n outline: false\n }\n });\n }\n\n /**\n * Set edges default styles based on the configuration\n */\n public setEdgesDefaultStyles(): void {\n // setting selection and hover attributes\n this._ogma.styles.setHoveredEdgeAttributes(HOVERED_SELECTED_EDGE_STYLE);\n this._ogma.styles.setSelectedEdgeAttributes(HOVERED_SELECTED_EDGE_STYLE);\n // setting default styles\n this._edgeDefaultStylesRules = this._ogma.styles.addRule({\n edgeAttributes: {\n text: {\n minVisibleSize:\n this._defaultConfiguration.edge.text !== undefined &&\n this._defaultConfiguration.edge.text.minVisibleSize\n ? this._defaultConfiguration.edge.text.minVisibleSize\n : 3,\n maxLineLength:\n this._defaultConfiguration.edge.text !== undefined &&\n this._defaultConfiguration.edge.text.maxLineLength !== undefined\n ? this._defaultConfiguration.edge.text.maxLineLength\n : 30,\n backgroundColor:\n this._defaultConfiguration.edge.text !== undefined &&\n this._defaultConfiguration.edge.text.backgroundColor !== undefined\n ? this._defaultConfiguration.edge.text.backgroundColor\n : undefined,\n font:\n this._defaultConfiguration.edge.text !== undefined &&\n this._defaultConfiguration.edge.text.font !== undefined\n ? this._defaultConfiguration.edge.text.font\n : \"'roboto', sans-serif\",\n color:\n this._defaultConfiguration.edge?.text !== undefined &&\n this._defaultConfiguration.edge.text.color !== undefined\n ? this._defaultConfiguration.edge.text.color\n : 'black',\n size:\n this._defaultConfiguration.edge.text !== undefined &&\n this._defaultConfiguration.edge.text.size !== undefined\n ? this._defaultConfiguration.edge.text.size\n : 14\n },\n width: this.defaultEdgeWidth(this._defaultConfiguration.edge),\n shape:\n this._defaultConfiguration.edge.shape !== undefined\n ? this._defaultConfiguration.edge.shape\n : 'arrow',\n color: ITEM_DEFAULT_COLOR\n }\n });\n }\n\n /**\n * Set nodes default styles based on the configuration\n */\n public setNodesDefaultHalo(): void {\n // setting default halo style\n this._nodeDefaultHaloRules = this._ogma.styles.addRule({\n nodeSelector: (node) => node && !node.hasClass('filtered'),\n nodeAttributes: {\n halo: (node) => {\n if (\n node !== undefined &&\n !node.hasClass('filtered') &&\n (node.isSelected() ||\n node.getAdjacentNodes({}).isSelected().includes(true) ||\n node.getAdjacentEdges().isSelected().includes(true))\n ) {\n return {\n ...NODE_HALO_CONFIGURATION,\n scalingMethod: this._ogma.geo.enabled() ? 'fixed' : 'scaled'\n };\n }\n return null;\n }\n },\n // recalculate the rule *only* when itself or adjacent\n // elements change their selection status\n nodeDependencies: {\n self: {\n selection: true\n },\n adjacentNodes: {\n selection: true\n },\n adjacentEdges: {\n selection: true\n }\n }\n });\n }\n\n /**\n * Set edges default styles based on the configuration\n */\n public setEdgesDefaultHalo(): void {\n // setting default halo styles\n this._edgeDefaultHaloRules = this._ogma.styles.addRule({\n edgeSelector: (edge: Edge) =>\n edge && edge.getSource() && edge.getTarget() && !edge.hasClass('filtered'),\n edgeAttributes: {\n halo: (edge) => {\n if (\n edge &&\n !edge.hasClass('filtered') &&\n (edge.isSelected() || edge.getSource().isSelected() || edge.getTarget().isSelected())\n ) {\n return {\n ...EDGE_HALO_CONFIGURATION,\n scalingMethod: this._ogma.geo.enabled() ? 'fixed' : 'scaled'\n };\n }\n return null;\n }\n },\n // this rule will only be invoked when the selection status\n // of the edge or it's extremities is changed\n edgeDependencies: {\n self: {\n selection: true\n },\n extremities: {\n selection: true\n }\n }\n });\n }\n\n /**\n * Return the default node radius set in configuration or 5\n *\n * @returns {number}\n */\n private defaultNodeRadius(styles: any): number {\n return this.defaultStylesHas(styles, ['nodeRadius']) ? styles.nodeRadius : 5;\n }\n\n /**\n * Return the default edge width set in configuration or 1\n *\n * @returns {number}\n */\n private defaultEdgeWidth(styles: any): number {\n return this.defaultStylesHas(styles, ['edgeWidth']) ? styles.edgeWidth : 1;\n }\n\n /**\n * Check if a style property exists in the default styles object\n */\n private defaultStylesHas(styles: GenericObject<unknown>, propertyPath: Array<string>): boolean {\n if (!Tools.isDefined(styles)) {\n return false;\n }\n return Tools.getIn(styles, propertyPath) !== undefined;\n }\n\n /**\n * Set styles for the class \"filtered\"\n */\n public setFilterClass(): void {\n this._ogma.styles.createClass({\n name: 'filtered',\n nodeAttributes: {\n opacity: FILTER_OPACITY,\n layer: (node): number => {\n // if the node is part of a virtual node, it should be on top\n if (node.getMetaNode() !== undefined) {\n return 1;\n }\n return -1;\n },\n detectable: false,\n badges: {\n topRight: {\n text: null\n },\n bottomRight: {\n text: null\n }\n },\n text: null,\n color: 'rgb(240, 240, 240)',\n innerStroke: {\n width: 1,\n color: BASE_GREY,\n minVisibleSize: 1\n },\n shape: 'circle',\n image: null,\n icon: null,\n radius: '100%'\n },\n edgeAttributes: {\n opacity: FILTER_OPACITY,\n layer: (edge): number => {\n const isEdgeInsideNodeGroup = edge\n .getExtremities()\n .getMetaNode()\n .some((node) => node !== null);\n // if the edge is part of a virtual node, it should be on top\n if (!edge.isVirtual() && isEdgeInsideNodeGroup) {\n return 1;\n }\n return -1;\n },\n detectable: false,\n text: null,\n color: BASE_GREY,\n shape: 'line',\n width: 0.2\n }\n });\n }\n\n /**\n * Set the class for exported nodes and edges\n */\n public setExportClass(textWrappingLength?: boolean): void {\n if (!this._exportClass) {\n this._exportClass = this._ogma.styles.createClass({\n name: 'exported',\n nodeAttributes: {\n text: {\n minVisibleSize: 0,\n size: 12,\n maxLineLength: textWrappingLength ? 30 : 0\n },\n halo: null\n },\n edgeAttributes: {\n text: {\n minVisibleSize: 0,\n size: 12\n },\n halo: null\n }\n });\n } else {\n this._exportClass.update({\n nodeAttributes: {\n text: {\n maxLineLength: textWrappingLength ? 30 : 0\n },\n halo: null\n }\n });\n }\n }\n\n /**\n * Set the rule to display badges\n */\n public setBadgeRule() {\n this._ogma.styles.createClass({\n name: 'degreeIndicator',\n nodeAttributes: {\n badges: {\n topRight: (node) => {\n if (node !== undefined) {\n const degree = Tools.getHiddenNeighbors(node.toList());\n const badgeContent = Tools.formatNumber(degree);\n if (degree > 0) {\n const nodeColor = Array.isArray(node.getAttribute('color'))\n ? node.getAttribute('color')![0]\n : node.getAttribute('color');\n const textColor = OgmaTools.isBright(nodeColor as o.Color)\n ? DARK_FONT_COLOR\n : CLEAR_FONT_COLOR;\n const isSupernode = node.getData(['statistics', 'supernode']);\n let content = null;\n if (+badgeContent !== 0) {\n content = isSupernode ? badgeContent + '+' : badgeContent;\n }\n return {\n color: 'inherit',\n minVisibleSize: 20,\n stroke: {\n width: 0,\n color: null\n },\n text: {\n font:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.font !== undefined\n ? this._defaultConfiguration.node.text.font\n : DEFAULT_OGMA_FONT,\n scale: 0.4,\n color: textColor,\n content: content\n }\n };\n }\n }\n }\n }\n }\n });\n this._ogma.styles.createClass({\n name: 'pinnedIndicator',\n nodeAttributes: {\n badges: {\n bottomRight: (node) => {\n if (node !== undefined && !node.getAttribute('layoutable')) {\n const nodeColor = Array.isArray(node.getAttribute('color'))\n ? node.getAttribute('color')![0]\n : node.getAttribute('color');\n const textColor = OgmaTools.isBright(nodeColor as o.Color)\n ? DARK_FONT_COLOR\n : CLEAR_FONT_COLOR;\n return {\n color: 'inherit',\n minVisibleSize: 20,\n stroke: {\n width: 0,\n color: null\n },\n text: {\n font: 'FontAwesome',\n scale: 0.4,\n color: textColor,\n content: node.getAttribute('layoutable') ? null : '\\uf08d'\n }\n };\n }\n }\n }\n },\n nodeDependencies: {\n self: {attributes: ['layoutable']}\n }\n });\n this._ogma.events.on('addNodes', (nodesEvent) => nodesEvent.nodes.addClass('degreeIndicator'));\n this._ogma.events.on('addNodes', (nodesEvent) => nodesEvent.nodes.addClass('pinnedIndicator'));\n }\n\n /**\n * Delete the rule to display badges\n */\n public deleteBadgeRule() {\n this._ogma.getNodes().removeClasses(['degreeIndicator', 'pinnedIndicator'], 0);\n }\n\n /**\n * set text overlap to true or false\n *\n * @param {boolean} overlap\n */\n public toggleTextOverlap(overlap?: boolean): void {\n this._ogma.setOptions({texts: {preventOverlap: overlap}});\n }\n\n /**\n * refresh nodes and edge rules\n *\n */\n public refreshRules(): void {\n this._nodeDefaultStylesRules.refresh();\n this._edgeDefaultStylesRules.refresh();\n }\n\n /**\n * Create / refresh an ogma rule for node colors\n */\n public refreshNodeColors(colorStyleRules: Array<LKStyleRule<INodeStyle>>): void {\n if (!Tools.isDefined(this._ogmaNodeColor)) {\n this._nodeAttributes.refresh({color: colorStyleRules});\n this._ogmaNodeColor = this._ogma.styles.addRule({\n nodeAttributes: {\n color: (node: o.Node | undefined) => {\n if (node !== undefined) {\n return this._nodeAttributes.color(node.getData());\n }\n }\n },\n nodeDependencies: {self: {data: true}}\n });\n } else {\n this._nodeAttributes.refresh({color: colorStyleRules});\n this._ogmaNodeColor.refresh();\n // TODO refresh node icons when moving the code from LKE\n // this.refreshIconsColor();\n }\n }\n\n /**\n * Return an array of StyleRules with only the style that need to be applied\n */\n public getStyleRule(\n state: Array<IStyleRule<INodeStyle | IEdgeStyle>>,\n styleType: StyleType\n ): LKStyleRule[] {\n return new StyleRules(state)[styleType];\n }\n\n public initNodeColors(nodeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>): void {\n const nodeColorRules = this.getStyleRule(\n nodeRules,\n StyleType.COLOR\n ) as LKStyleRule<INodeStyle>[];\n this.refreshNodeColors(nodeColorRules);\n }\n\n public initNodesIcons(nodeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>) {\n const nodeIconsRules = this.getStyleRule(\n nodeRules,\n StyleType.ICON\n ) as LKStyleRule<INodeStyle>[];\n this.refreshNodeIcons(nodeIconsRules);\n }\n\n public initNodesSizes(nodeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>): void {\n const nodeSizeRules = this.getStyleRule(nodeRules, StyleType.SIZE) as LKStyleRule<INodeStyle>[];\n this.refreshNodeSize(nodeSizeRules);\n }\n\n public initNodesShapes(nodeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>) {\n const nodeShapesRules = this.getStyleRule(\n nodeRules,\n StyleType.SHAPE\n ) as LKStyleRule<INodeStyle>[];\n this.refreshNodeShape(nodeShapesRules);\n }\n\n public initEdgesWidth(edgeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>) {\n const edgesWidthRules = this.getStyleRule(\n edgeRules,\n StyleType.WIDTH\n ) as LKStyleRule<IEdgeStyle>[];\n this.refreshEdgeWidth(edgesWidthRules);\n }\n\n public initEdgesShape(edgeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>) {\n const edgesShapeRules = this.getStyleRule(\n edgeRules,\n StyleType.SHAPE\n ) as LKStyleRule<IEdgeStyle>[];\n this.refreshEdgeShape(edgesShapeRules);\n }\n\n public initEdgesColor(edgeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>): void {\n const edgesColorRules = this.getStyleRule(\n edgeRules,\n StyleType.COLOR\n ) as LKStyleRule<IEdgeStyle>[];\n this.refreshEdgeColors(edgesColorRules);\n }\n\n /**\n * Create / refresh an ogma rule for node icons\n *\n * @param {Array<any>} iconStyleRules\n */\n public refreshNodeIcons(iconStyleRules: Array<LKStyleRule<INodeStyle>>): void {\n if (!Tools.isDefined(this._ogmaNodeIcon)) {\n this._nodeAttributes.refresh({icon: iconStyleRules});\n this._ogmaNodeIcon = this._ogma.styles.addRule({\n nodeAttributes: {\n icon: (node: o.Node | undefined): IStyleIcon | undefined => {\n if (node !== undefined) {\n return this._nodeAttributes.icon(node.getData()).icon;\n }\n },\n image: (node: o.Node | undefined): OgmaImage | null | undefined => {\n if (node !== undefined && !node.isVirtual()) {\n return this._nodeAttributes.icon(node.getData()).image;\n }\n }\n },\n nodeDependencies: {self: {data: true}}\n });\n } else {\n this._nodeAttributes.refresh({icon: iconStyleRules});\n void this._ogmaNodeIcon.refresh();\n }\n }\n\n /**\n * Create / refresh an ogma rule for node sizes\n *\n * @param {Array<any>} sizeStyleRules\n */\n public refreshNodeSize(sizeStyleRules: Array<LKStyleRule<INodeStyle>>): void {\n if (!Tools.isDefined(this._ogmaNodeSize)) {\n this._nodeAttributes.refresh({size: sizeStyleRules});\n this._ogmaNodeSize = this._ogma.styles.addRule({\n nodeAttributes: {\n radius: (node: o.Node | undefined) => {\n if (node !== undefined) {\n return this._nodeAttributes.size(node.getData());\n }\n }\n },\n nodeDependencies: {self: {data: true}}\n });\n } else {\n this._nodeAttributes.refresh({size: sizeStyleRules});\n this._ogmaNodeSize.refresh();\n }\n }\n\n /**\n * Create / refresh an ogma rule for node images\n *\n * @param {Array<any>} shapeStyleRules\n */\n public refreshNodeShape(shapeStyleRules: Array<LKStyleRule<INodeStyle>>): void {\n if (!Tools.isDefined(this._ogmaNodeShape)) {\n this._nodeAttributes.refresh({shape: shapeStyleRules});\n this._ogmaNodeShape = this._ogma.styles.addRule({\n nodeAttributes: {\n shape: (node: o.Node | undefined) => {\n if (node !== undefined) {\n return this._nodeAttributes.shape(node.getData());\n }\n }\n },\n nodeSelector: (node: o.Node | undefined) => node !== undefined && !node.isVirtual(),\n nodeDependencies: {self: {data: true}}\n });\n } else {\n this._nodeAttributes.refresh({shape: shapeStyleRules});\n this._ogmaNodeShape.refresh();\n }\n }\n\n /**\n * Create / refresh an ogma rule for edge colors\n */\n public refreshEdgeColors(colorStyleRules: Array<LKStyleRule<IEdgeStyle>>): void {\n if (!Tools.isDefined(this._ogmaEdgeColor)) {\n this._edgeAttributes.refresh({color: colorStyleRules});\n this._ogmaEdgeColor = this._ogma.styles.addRule({\n edgeAttributes: {\n color: (edge: o.Edge | undefined) => {\n if (edge !== undefined) {\n return this._edgeAttributes.color(edge.getData());\n }\n }\n },\n edgeDependencies: {self: {data: true}}\n });\n } else {\n this._edgeAttributes.refresh({color: colorStyleRules});\n this._ogmaEdgeColor.refresh();\n }\n }\n\n /**\n * Create / refresh an ogma rule for edge width\n *\n * @param {Array<LKStyleRule>} widthStyleRules\n */\n public refreshEdgeWidth(widthStyleRules: Array<LKStyleRule<IEdgeStyle>>): void {\n if (!Tools.isDefined(this._ogmaEdgeWidth)) {\n this._edgeAttributes.refresh({width: widthStyleRules});\n this._ogmaEdgeWidth = this._ogma.styles.addRule({\n edgeAttributes: {\n width: (edge: o.Edge | undefined) => {\n if (edge !== undefined) {\n return this._edgeAttributes.width(edge.getData());\n }\n }\n },\n edgeDependencies: {\n self: {data: true}\n }\n });\n } else {\n this._edgeAttributes.refresh({width: widthStyleRules});\n this._ogmaEdgeWidth.refresh();\n }\n }\n\n /**\n * Create / refresh an ogma rule for edge width\n *\n * @param {Array<LKStyleRule>} shapeStyleRules\n */\n public refreshEdgeShape(shapeStyleRules: Array<LKStyleRule<IEdgeStyle>>): void {\n if (!Tools.isDefined(this._ogmaEdgeShape)) {\n this._edgeAttributes.refresh({shape: shapeStyleRules});\n this._ogmaEdgeShape = this._ogma.styles.addRule({\n edgeAttributes: {\n shape: (edge: o.Edge | undefined) => {\n if (edge !== undefined) {\n return this._edgeAttributes.shape(edge.getData());\n }\n }\n },\n edgeDependencies: {self: {data: true}}\n });\n } else {\n this._edgeAttributes.refresh({shape: shapeStyleRules});\n this._ogmaEdgeShape.refresh();\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/ogma/features/styles.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAyBb,6BASe;AACf,6CAAwC;AAaxC,MAAM,2BAA2B,GAAgD;IAC/E,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM;QACb,eAAe,EAAE,MAAM;QACvB,cAAc,EAAE,CAAC;KAClB;IACD,WAAW,EAAE,EAAC,KAAK,EAAE,CAAC,EAAC;IACvB,OAAO,EAAE,KAAK;CACf,CAAC;AAEF,MAAM,2BAA2B,GAAgD;I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1B,MAAM,YAAY,GAAG,IAAI,CAAC;QAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QACzC,OAAO,MAAM,GAAG,YAAY,GAAG,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC;IACnE,CAAC;IAED;;OAEG;IACK,sBAAsB,CAAC,IAAkC;QAC/D,IAAI,IAAI,CAAC,SAAS,EAAE,EAAE;YACpB,OAAO,gBAAgB,CAAC;SACzB;QACD,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;YACzD,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAE,CAAC,CAAC,CAAC;YAChC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAC/B,OAAO,aAAS,CAAC,QAAQ,CAAC,SAAoB,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,gBAAgB,CAAC;IACvF,CAAC;IAED;;OAEG;IACK,4BAA4B,CAAC,IAAkC;QACrE,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,aAAS,CAAC,CAAC,CAAC,SAAS,CAAC;IAClD,CAAC;CACF;AA7vBD,8BA6vBC","sourcesContent":["'use strict';\n\nimport * as o from '@linkurious/ogma';\nimport {\n Badge,\n Edge,\n EdgeAttributesValue,\n Node,\n NodeAttributesValue,\n StyleClass,\n StyleRule\n} from '@linkurious/ogma';\nimport {\n GenericObject,\n IEdgeStyle,\n INodeStyle,\n IStyleIcon,\n IStyleRule,\n LkEdgeData,\n LkNodeData,\n OgmaEdgeShape,\n OgmaNodeShape,\n TextOptions\n} from '@linkurious/rest-client';\n\nimport {\n BASE_GREY,\n EdgeAttributes,\n LKOgma,\n NodeAttributes,\n OgmaTools,\n StyleRule as LKStyleRule,\n StyleRules,\n StyleType\n} from '../..';\nimport {Tools} from '../../tools/tools';\nimport {OgmaImage} from '../../styles/nodeAttributes';\n\nexport interface StylesConfig {\n nodeColorStyleRules: Array<LKStyleRule>;\n nodeIconStyleRules: Array<LKStyleRule>;\n nodeSizeStyleRules: Array<LKStyleRule>;\n nodeShapeStyleRules?: Array<LKStyleRule>;\n edgeColorStyleRules: Array<LKStyleRule>;\n edgeWidthStyleRules: Array<LKStyleRule>;\n edgeShapeStyleRules?: Array<LKStyleRule>;\n}\n\nconst HOVERED_SELECTED_NODE_STYLE: NodeAttributesValue<LkNodeData, LkEdgeData> = {\n text: {\n style: 'bold',\n backgroundColor: '#fff',\n minVisibleSize: 0\n },\n outerStroke: {width: 2},\n outline: false\n};\n\nconst HOVERED_SELECTED_EDGE_STYLE: EdgeAttributesValue<LkEdgeData, LkNodeData> = {\n text: {\n style: 'bold',\n backgroundColor: '#fff',\n minVisibleSize: 0\n },\n outline: false\n};\n\nconst NODE_HALO_CONFIGURATION = {\n color: '#FFF',\n width: 7,\n scalingMethod: 'scaled',\n strokeWidth: 0,\n hideNonAdjacentEdges: false\n} as {\n color: '#FFF';\n width: 7;\n strokeWidth: 0;\n};\n\nconst EDGE_HALO_CONFIGURATION = {\n color: '#FFF',\n scalingMethod: 'scaled',\n width: 4\n} as {\n color: '#FFF';\n width: 4;\n};\n\nconst DEFAULT_OGMA_FONT = \"'roboto', sans-serif\";\nconst DARK_FONT_COLOR = '#000';\nconst CLEAR_FONT_COLOR = '#FFF';\nconst ITEM_DEFAULT_COLOR = '#7f7f7f';\nexport const FILTER_OPACITY = 0.2;\n\nexport class StylesViz {\n private _ogma: LKOgma;\n private _exportClass!: StyleClass;\n private _nodeDefaultStylesRules!: StyleRule<LkNodeData, LkEdgeData>;\n // @ts-ignore\n private _nodeDefaultHaloRules!: StyleRule<LkNodeData, LkEdgeData>;\n private _edgeDefaultStylesRules!: StyleRule<LkNodeData, LkEdgeData>;\n // @ts-ignore\n private _edgeDefaultHaloRules!: StyleRule<LkNodeData, LkEdgeData>;\n\n private _nodeAttributes: NodeAttributes = new NodeAttributes({});\n private _edgeAttributes: EdgeAttributes = new EdgeAttributes({});\n\n private _ogmaNodeColor!: StyleRule;\n private _ogmaNodeIcon!: StyleRule;\n private _ogmaNodeSize!: StyleRule;\n private _ogmaNodeShape!: StyleRule;\n private _ogmaEdgeColor!: StyleRule;\n private _ogmaEdgeWidth!: StyleRule;\n private _ogmaEdgeShape!: StyleRule;\n private _defaultConfiguration: {\n node: {\n nodeRadius?: number;\n shape?: OgmaNodeShape;\n text?: TextOptions & {\n nodePosition?: 'right' | 'left' | 'top' | 'bottom' | 'center';\n };\n };\n edge: {\n edgeWidth?: number;\n shape?: OgmaEdgeShape;\n text?: TextOptions;\n };\n };\n\n constructor(\n ogma: LKOgma,\n configuration: {\n node: {\n nodeRadius?: number;\n shape?: OgmaNodeShape;\n text?: TextOptions & {\n nodePosition?: 'right' | 'left' | 'top' | 'bottom' | 'center';\n };\n };\n edge: {\n edgeWidth?: number;\n shape?: OgmaEdgeShape;\n text?: TextOptions;\n };\n baseUrl?: string;\n }\n ) {\n this._ogma = ogma;\n this._defaultConfiguration = configuration;\n this._nodeAttributes.setBaseUrl(configuration.baseUrl);\n }\n\n /**\n * Set nodes default styles based on the configuration\n */\n public setNodesDefaultStyles(): void {\n // setting selection and hover attributes\n this._ogma.styles.setHoveredNodeAttributes(HOVERED_SELECTED_NODE_STYLE);\n this._ogma.styles.setSelectedNodeAttributes(HOVERED_SELECTED_NODE_STYLE);\n // setting default styles\n this._nodeDefaultStylesRules = this._ogma.styles.addRule({\n nodeAttributes: {\n text: {\n padding: 5,\n minVisibleSize:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.minVisibleSize\n ? this._defaultConfiguration.node.text.minVisibleSize\n : 12,\n maxLineLength:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.maxLineLength !== undefined\n ? this._defaultConfiguration.node.text.maxLineLength\n : 30,\n position:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.nodePosition !== undefined\n ? this._defaultConfiguration.node.text.nodePosition\n : 'bottom',\n backgroundColor:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.backgroundColor !== undefined\n ? this._defaultConfiguration.node.text.backgroundColor\n : undefined,\n font:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.font !== undefined\n ? this._defaultConfiguration.node.text.font\n : \"'roboto', sans-serif\",\n color:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.color !== undefined\n ? this._defaultConfiguration.node.text.color\n : 'black',\n size:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.size !== undefined\n ? this._defaultConfiguration.node.text.size\n : 14,\n margin: 5\n },\n radius: this.defaultNodeRadius(this._defaultConfiguration.node),\n icon: {\n minVisibleSize: 15\n },\n color: ITEM_DEFAULT_COLOR,\n shape:\n this._defaultConfiguration.node.shape !== undefined\n ? this._defaultConfiguration.node.shape\n : ('circle' as OgmaNodeShape),\n innerStroke: {\n width: 3\n },\n outline: false\n }\n });\n }\n\n /**\n * Set edges default styles based on the configuration\n */\n public setEdgesDefaultStyles(): void {\n // setting selection and hover attributes\n this._ogma.styles.setHoveredEdgeAttributes(HOVERED_SELECTED_EDGE_STYLE);\n this._ogma.styles.setSelectedEdgeAttributes(HOVERED_SELECTED_EDGE_STYLE);\n // setting default styles\n this._edgeDefaultStylesRules = this._ogma.styles.addRule({\n edgeAttributes: {\n text: {\n minVisibleSize:\n this._defaultConfiguration.edge.text !== undefined &&\n this._defaultConfiguration.edge.text.minVisibleSize\n ? this._defaultConfiguration.edge.text.minVisibleSize\n : 3,\n maxLineLength:\n this._defaultConfiguration.edge.text !== undefined &&\n this._defaultConfiguration.edge.text.maxLineLength !== undefined\n ? this._defaultConfiguration.edge.text.maxLineLength\n : 30,\n backgroundColor:\n this._defaultConfiguration.edge.text !== undefined &&\n this._defaultConfiguration.edge.text.backgroundColor !== undefined\n ? this._defaultConfiguration.edge.text.backgroundColor\n : undefined,\n font:\n this._defaultConfiguration.edge.text !== undefined &&\n this._defaultConfiguration.edge.text.font !== undefined\n ? this._defaultConfiguration.edge.text.font\n : \"'roboto', sans-serif\",\n color:\n this._defaultConfiguration.edge?.text !== undefined &&\n this._defaultConfiguration.edge.text.color !== undefined\n ? this._defaultConfiguration.edge.text.color\n : 'black',\n size:\n this._defaultConfiguration.edge.text !== undefined &&\n this._defaultConfiguration.edge.text.size !== undefined\n ? this._defaultConfiguration.edge.text.size\n : 14\n },\n width: this.defaultEdgeWidth(this._defaultConfiguration.edge),\n shape:\n this._defaultConfiguration.edge.shape !== undefined\n ? this._defaultConfiguration.edge.shape\n : 'arrow',\n color: ITEM_DEFAULT_COLOR\n }\n });\n }\n\n /**\n * Set nodes default styles based on the configuration\n */\n public setNodesDefaultHalo(): void {\n // setting default halo style\n this._nodeDefaultHaloRules = this._ogma.styles.addRule({\n nodeSelector: (node) => node && !node.hasClass('filtered'),\n nodeAttributes: {\n halo: (node) => {\n if (\n node !== undefined &&\n !node.hasClass('filtered') &&\n (node.isSelected() ||\n node.getAdjacentNodes({}).isSelected().includes(true) ||\n node.getAdjacentEdges().isSelected().includes(true))\n ) {\n return {\n ...NODE_HALO_CONFIGURATION,\n scalingMethod: this._ogma.geo.enabled() ? 'fixed' : 'scaled'\n };\n }\n return null;\n }\n },\n // recalculate the rule *only* when itself or adjacent\n // elements change their selection status\n nodeDependencies: {\n self: {\n selection: true\n },\n adjacentNodes: {\n selection: true\n },\n adjacentEdges: {\n selection: true\n }\n }\n });\n }\n\n /**\n * Set edges default styles based on the configuration\n */\n public setEdgesDefaultHalo(): void {\n // setting default halo styles\n this._edgeDefaultHaloRules = this._ogma.styles.addRule({\n edgeSelector: (edge: Edge) =>\n edge && edge.getSource() && edge.getTarget() && !edge.hasClass('filtered'),\n edgeAttributes: {\n halo: (edge) => {\n if (\n edge &&\n !edge.hasClass('filtered') &&\n (edge.isSelected() || edge.getSource().isSelected() || edge.getTarget().isSelected())\n ) {\n return {\n ...EDGE_HALO_CONFIGURATION,\n scalingMethod: this._ogma.geo.enabled() ? 'fixed' : 'scaled'\n };\n }\n return null;\n }\n },\n // this rule will only be invoked when the selection status\n // of the edge or it's extremities is changed\n edgeDependencies: {\n self: {\n selection: true\n },\n extremities: {\n selection: true\n }\n }\n });\n }\n\n /**\n * Return the default node radius set in configuration or 5\n *\n * @returns {number}\n */\n private defaultNodeRadius(styles: any): number {\n return this.defaultStylesHas(styles, ['nodeRadius']) ? styles.nodeRadius : 5;\n }\n\n /**\n * Return the default edge width set in configuration or 1\n *\n * @returns {number}\n */\n private defaultEdgeWidth(styles: any): number {\n return this.defaultStylesHas(styles, ['edgeWidth']) ? styles.edgeWidth : 1;\n }\n\n /**\n * Check if a style property exists in the default styles object\n */\n private defaultStylesHas(styles: GenericObject<unknown>, propertyPath: Array<string>): boolean {\n if (!Tools.isDefined(styles)) {\n return false;\n }\n return Tools.getIn(styles, propertyPath) !== undefined;\n }\n\n /**\n * Set styles for the class \"filtered\"\n */\n public setFilterClass(): void {\n this._ogma.styles.createClass({\n name: 'filtered',\n nodeAttributes: {\n opacity: FILTER_OPACITY,\n layer: (node): number => {\n // if the node is part of a virtual node, it should be on top\n if (node.getMetaNode() !== undefined) {\n return 1;\n }\n return -1;\n },\n detectable: false,\n badges: {\n topRight: {\n text: null\n },\n bottomRight: {\n text: null\n }\n },\n text: null,\n color: 'rgb(240, 240, 240)',\n innerStroke: {\n width: 1,\n color: BASE_GREY,\n minVisibleSize: 1\n },\n shape: 'circle',\n image: null,\n icon: null,\n radius: '100%'\n },\n edgeAttributes: {\n opacity: FILTER_OPACITY,\n layer: (edge): number => {\n const isEdgeInsideNodeGroup = edge\n .getExtremities()\n .getMetaNode()\n .some((node) => node !== null);\n // if the edge is part of a virtual node, it should be on top\n if (!edge.isVirtual() && isEdgeInsideNodeGroup) {\n return 1;\n }\n return -1;\n },\n detectable: false,\n text: null,\n color: BASE_GREY,\n shape: 'line',\n width: 0.2\n }\n });\n }\n\n /**\n * Set the class for exported nodes and edges\n */\n public setExportClass(textWrappingLength?: boolean): void {\n if (!this._exportClass) {\n this._exportClass = this._ogma.styles.createClass({\n name: 'exported',\n nodeAttributes: {\n text: {\n minVisibleSize: 0,\n size: 12,\n maxLineLength: textWrappingLength ? 30 : 0\n },\n halo: null\n },\n edgeAttributes: {\n text: {\n minVisibleSize: 0,\n size: 12\n },\n halo: null\n }\n });\n } else {\n this._exportClass.update({\n nodeAttributes: {\n text: {\n maxLineLength: textWrappingLength ? 30 : 0\n },\n halo: null\n }\n });\n }\n }\n\n /**\n * Set the rule to display badges\n */\n public setBadgeRule() {\n this._ogma.styles.createClass({\n name: 'degreeIndicator',\n nodeAttributes: {\n badges: {\n topRight: (node) => {\n if (node !== undefined) {\n const degree = Tools.getHiddenNeighbors(node.toList());\n const badgeContent = Tools.formatNumber(degree);\n if (degree > 0) {\n const nodeColor = Array.isArray(node.getAttribute('color'))\n ? node.getAttribute('color')![0]\n : node.getAttribute('color');\n const textColor = OgmaTools.isBright(nodeColor as o.Color)\n ? DARK_FONT_COLOR\n : CLEAR_FONT_COLOR;\n const isSupernode = node.getData(['statistics', 'supernode']);\n let content = null;\n if (+badgeContent !== 0) {\n content = isSupernode ? badgeContent + '+' : badgeContent;\n }\n return {\n color: 'inherit',\n minVisibleSize: 20,\n stroke: {\n width: 0,\n color: null\n },\n text: {\n font:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.font !== undefined\n ? this._defaultConfiguration.node.text.font\n : DEFAULT_OGMA_FONT,\n scale: 0.4,\n color: textColor,\n content: content\n }\n };\n }\n }\n }\n }\n }\n });\n this._ogma.styles.createClass({\n name: 'pinnedIndicator',\n nodeAttributes: {\n badges: {\n bottomRight: (node): Badge | undefined => {\n if (node !== undefined && !node.getAttribute('layoutable')) {\n return {\n color: this._findPinBadgeBackgroundColor(node),\n minVisibleSize: 20,\n scale: this._findPinBadgeScale(node),\n stroke: {\n width: 0,\n color: null\n },\n text: {\n font: 'FontAwesome',\n scale: 0.4,\n color: this._findPinBadgeTextColor(node),\n content: node.getAttribute('layoutable') ? null : '\\uf08d'\n }\n };\n }\n }\n }\n },\n nodeDependencies: {\n self: {attributes: ['layoutable']}\n }\n });\n this._ogma.events.on('addNodes', (nodesEvent) => nodesEvent.nodes.addClass('degreeIndicator'));\n this._ogma.events.on('addNodes', (nodesEvent) => nodesEvent.nodes.addClass('pinnedIndicator'));\n }\n\n /**\n * Delete the rule to display badges\n */\n public deleteBadgeRule() {\n this._ogma.getNodes().removeClasses(['degreeIndicator', 'pinnedIndicator'], 0);\n }\n\n /**\n * set text overlap to true or false\n *\n * @param {boolean} overlap\n */\n public toggleTextOverlap(overlap?: boolean): void {\n this._ogma.setOptions({texts: {preventOverlap: overlap}});\n }\n\n /**\n * refresh nodes and edge rules\n *\n */\n public refreshRules(): void {\n this._nodeDefaultStylesRules.refresh();\n this._edgeDefaultStylesRules.refresh();\n }\n\n /**\n * Create / refresh an ogma rule for node colors\n */\n public refreshNodeColors(colorStyleRules: Array<LKStyleRule<INodeStyle>>): void {\n if (!Tools.isDefined(this._ogmaNodeColor)) {\n this._nodeAttributes.refresh({color: colorStyleRules});\n this._ogmaNodeColor = this._ogma.styles.addRule({\n nodeAttributes: {\n color: (node: o.Node | undefined) => {\n if (node !== undefined) {\n return this._nodeAttributes.color(node.getData());\n }\n }\n },\n nodeDependencies: {self: {data: true}}\n });\n } else {\n this._nodeAttributes.refresh({color: colorStyleRules});\n this._ogmaNodeColor.refresh();\n // TODO refresh node icons when moving the code from LKE\n // this.refreshIconsColor();\n }\n }\n\n /**\n * Return an array of StyleRules with only the style that need to be applied\n */\n public getStyleRule(\n state: Array<IStyleRule<INodeStyle | IEdgeStyle>>,\n styleType: StyleType\n ): LKStyleRule[] {\n return new StyleRules(state)[styleType];\n }\n\n public initNodeColors(nodeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>): void {\n const nodeColorRules = this.getStyleRule(\n nodeRules,\n StyleType.COLOR\n ) as LKStyleRule<INodeStyle>[];\n this.refreshNodeColors(nodeColorRules);\n }\n\n public initNodesIcons(nodeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>) {\n const nodeIconsRules = this.getStyleRule(\n nodeRules,\n StyleType.ICON\n ) as LKStyleRule<INodeStyle>[];\n this.refreshNodeIcons(nodeIconsRules);\n }\n\n public initNodesSizes(nodeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>): void {\n const nodeSizeRules = this.getStyleRule(nodeRules, StyleType.SIZE) as LKStyleRule<INodeStyle>[];\n this.refreshNodeSize(nodeSizeRules);\n }\n\n public initNodesShapes(nodeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>) {\n const nodeShapesRules = this.getStyleRule(\n nodeRules,\n StyleType.SHAPE\n ) as LKStyleRule<INodeStyle>[];\n this.refreshNodeShape(nodeShapesRules);\n }\n\n public initEdgesWidth(edgeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>) {\n const edgesWidthRules = this.getStyleRule(\n edgeRules,\n StyleType.WIDTH\n ) as LKStyleRule<IEdgeStyle>[];\n this.refreshEdgeWidth(edgesWidthRules);\n }\n\n public initEdgesShape(edgeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>) {\n const edgesShapeRules = this.getStyleRule(\n edgeRules,\n StyleType.SHAPE\n ) as LKStyleRule<IEdgeStyle>[];\n this.refreshEdgeShape(edgesShapeRules);\n }\n\n public initEdgesColor(edgeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>): void {\n const edgesColorRules = this.getStyleRule(\n edgeRules,\n StyleType.COLOR\n ) as LKStyleRule<IEdgeStyle>[];\n this.refreshEdgeColors(edgesColorRules);\n }\n\n /**\n * Create / refresh an ogma rule for node icons\n *\n * @param {Array<any>} iconStyleRules\n */\n public refreshNodeIcons(iconStyleRules: Array<LKStyleRule<INodeStyle>>): void {\n if (!Tools.isDefined(this._ogmaNodeIcon)) {\n this._nodeAttributes.refresh({icon: iconStyleRules});\n this._ogmaNodeIcon = this._ogma.styles.addRule({\n nodeAttributes: {\n icon: (node: o.Node | undefined): IStyleIcon | undefined => {\n if (node !== undefined) {\n return this._nodeAttributes.icon(node.getData()).icon;\n }\n },\n image: (node: o.Node | undefined): OgmaImage | null | undefined => {\n if (node !== undefined && !node.isVirtual()) {\n return this._nodeAttributes.icon(node.getData()).image;\n }\n }\n },\n nodeDependencies: {self: {data: true}}\n });\n } else {\n this._nodeAttributes.refresh({icon: iconStyleRules});\n void this._ogmaNodeIcon.refresh();\n }\n }\n\n /**\n * Create / refresh an ogma rule for node sizes\n *\n * @param {Array<any>} sizeStyleRules\n */\n public refreshNodeSize(sizeStyleRules: Array<LKStyleRule<INodeStyle>>): void {\n if (!Tools.isDefined(this._ogmaNodeSize)) {\n this._nodeAttributes.refresh({size: sizeStyleRules});\n this._ogmaNodeSize = this._ogma.styles.addRule({\n nodeAttributes: {\n radius: (node: o.Node | undefined) => {\n if (node !== undefined) {\n return this._nodeAttributes.size(node.getData());\n }\n }\n },\n nodeDependencies: {self: {data: true}}\n });\n } else {\n this._nodeAttributes.refresh({size: sizeStyleRules});\n this._ogmaNodeSize.refresh();\n }\n }\n\n /**\n * Create / refresh an ogma rule for node images\n *\n * @param {Array<any>} shapeStyleRules\n */\n public refreshNodeShape(shapeStyleRules: Array<LKStyleRule<INodeStyle>>): void {\n if (!Tools.isDefined(this._ogmaNodeShape)) {\n this._nodeAttributes.refresh({shape: shapeStyleRules});\n this._ogmaNodeShape = this._ogma.styles.addRule({\n nodeAttributes: {\n shape: (node: o.Node | undefined) => {\n if (node !== undefined) {\n return this._nodeAttributes.shape(node.getData());\n }\n }\n },\n nodeSelector: (node: o.Node | undefined) => node !== undefined && !node.isVirtual(),\n nodeDependencies: {self: {data: true}}\n });\n } else {\n this._nodeAttributes.refresh({shape: shapeStyleRules});\n this._ogmaNodeShape.refresh();\n }\n }\n\n /**\n * Create / refresh an ogma rule for edge colors\n */\n public refreshEdgeColors(colorStyleRules: Array<LKStyleRule<IEdgeStyle>>): void {\n if (!Tools.isDefined(this._ogmaEdgeColor)) {\n this._edgeAttributes.refresh({color: colorStyleRules});\n this._ogmaEdgeColor = this._ogma.styles.addRule({\n edgeAttributes: {\n color: (edge: o.Edge | undefined) => {\n if (edge !== undefined) {\n return this._edgeAttributes.color(edge.getData());\n }\n }\n },\n edgeDependencies: {self: {data: true}}\n });\n } else {\n this._edgeAttributes.refresh({color: colorStyleRules});\n this._ogmaEdgeColor.refresh();\n }\n }\n\n /**\n * Create / refresh an ogma rule for edge width\n *\n * @param {Array<LKStyleRule>} widthStyleRules\n */\n public refreshEdgeWidth(widthStyleRules: Array<LKStyleRule<IEdgeStyle>>): void {\n if (!Tools.isDefined(this._ogmaEdgeWidth)) {\n this._edgeAttributes.refresh({width: widthStyleRules});\n this._ogmaEdgeWidth = this._ogma.styles.addRule({\n edgeAttributes: {\n width: (edge: o.Edge | undefined) => {\n if (edge !== undefined) {\n return this._edgeAttributes.width(edge.getData());\n }\n }\n },\n edgeDependencies: {\n self: {data: true}\n }\n });\n } else {\n this._edgeAttributes.refresh({width: widthStyleRules});\n this._ogmaEdgeWidth.refresh();\n }\n }\n\n /**\n * Create / refresh an ogma rule for edge width\n *\n * @param {Array<LKStyleRule>} shapeStyleRules\n */\n public refreshEdgeShape(shapeStyleRules: Array<LKStyleRule<IEdgeStyle>>): void {\n if (!Tools.isDefined(this._ogmaEdgeShape)) {\n this._edgeAttributes.refresh({shape: shapeStyleRules});\n this._ogmaEdgeShape = this._ogma.styles.addRule({\n edgeAttributes: {\n shape: (edge: o.Edge | undefined) => {\n if (edge !== undefined) {\n return this._edgeAttributes.shape(edge.getData());\n }\n }\n },\n edgeDependencies: {self: {data: true}}\n });\n } else {\n this._edgeAttributes.refresh({shape: shapeStyleRules});\n this._ogmaEdgeShape.refresh();\n }\n }\n\n /**\n * Get node radius\n * This is a workaround for an ogma issue where the radius of virtual nodes is always set to 5\n * TODO: check if this is still needed after ogma release the new improvement for transformation v5.X\n */\n private _getNodeRadius(node: Node<LkNodeData, LkEdgeData>): number {\n if (!node.isVirtual()) {\n return node.getAttribute('radius') as number;\n } else {\n // get the width and height of the box that contains the nodes inside the virtual node\n const {width, height} = node.getSubNodes()?.getBoundingBox()!;\n return Math.max(width, height);\n }\n }\n\n /**\n * Calculate the scale of the pin badge related to the node radius\n * This is useful when dealing wih huge nodes, and we don't want the badge to be big\n * If the node is small enough, the badge will be 0.46 of the node radius\n * Else it will be 5 / radius\n */\n private _findPinBadgeScale(node: Node<LkNodeData, LkEdgeData>): number {\n // the maximum radius for the badge\n const MAX = 5;\n const defaultRatio = 0.46;\n const bigNodeRatio = 0.17;\n const radius = this._getNodeRadius(node);\n return radius * defaultRatio > MAX ? bigNodeRatio : defaultRatio;\n }\n\n /**\n * Find the color of the pin badge text\n */\n private _findPinBadgeTextColor(node: Node<LkNodeData, LkEdgeData>): string {\n if (node.isVirtual()) {\n return CLEAR_FONT_COLOR;\n }\n const nodeColor = Array.isArray(node.getAttribute('color'))\n ? node.getAttribute('color')![0]\n : node.getAttribute('color');\n return OgmaTools.isBright(nodeColor as o.Color) ? DARK_FONT_COLOR : CLEAR_FONT_COLOR;\n }\n\n /**\n * Find the color of the pin badge background\n */\n private _findPinBadgeBackgroundColor(node: Node<LkNodeData, LkEdgeData>): string {\n return node.isVirtual() ? BASE_GREY : 'inherit';\n }\n}\n"]}
|
|
@@ -37,7 +37,7 @@ export declare class ItemAttributes<T extends INodeStyle | IEdgeStyle> {
|
|
|
37
37
|
/**
|
|
38
38
|
* Return the color for a node when style color is auto
|
|
39
39
|
*/
|
|
40
|
-
static autoColor(value: string, ignoreCase?: boolean): string;
|
|
40
|
+
static autoColor(value: string | undefined, ignoreCase?: boolean): string;
|
|
41
41
|
/**
|
|
42
42
|
* Return a number from 0 to number of occurrence in a palette based on a property
|
|
43
43
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"itemAttributes.js","sourceRoot":"","sources":["../../src/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AI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YAC7F,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;YAEjD,OAAO,GAAG,IAAI,GAAG,CAAC;SACnB;IACH,CAAC;IAEM,WAAW,CAAC,KAAwC;QACzD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,WAAW,CAAC;IAClE,CAAC;CACF;AAxJD,wCAwJC","sourcesContent":["'use strict';\n\nimport sha1 from 'sha1';\nimport {Color} from '@linkurious/ogma';\nimport {IEdgeStyle, INodeStyle, IStyleAutoRange} from '@linkurious/rest-client';\n\nimport {Tools} from '../tools/tools';\n\nimport {StyleRule} from './styleRule';\nimport {NodeSizeExtrema} from './nodeAttributes';\nimport {EdgeWidthExtrema} from './edgeAttributes';\n\nexport const BASE_GREY = '#7f7f7f';\nexport const PALETTE = [\n '#9467bd',\n '#e377c2',\n '#1f77b4',\n '#17becf',\n '#2ca02c',\n '#bcbd22',\n '#d62728',\n '#ff7f0e',\n '#8c564b',\n '#c5b0d5',\n '#f7b6d2',\n '#aec7e8',\n '#9edae5',\n '#98df8a',\n '#dbdb8d',\n '#ff9896',\n '#ffbb78',\n '#c49c94'\n];\n\nexport class ItemAttributes<T extends INodeStyle | IEdgeStyle> {\n protected colorsCache: Map<string, Color | Array<Color>> = new Map();\n protected _rulesMap: {\n color?: Array<StyleRule<T>>;\n icon?: Array<StyleRule<T>>;\n image?: Array<StyleRule<T>>;\n shape?: Array<StyleRule<T>>;\n size?: Array<StyleRule<T>>;\n width?: Array<StyleRule<T>>;\n } = {};\n\n constructor(rulesMap: {\n color?: Array<StyleRule<T>>;\n icon?: Array<StyleRule<T>>;\n image?: Array<StyleRule<T>>;\n shape?: Array<StyleRule<T>>;\n size?: Array<StyleRule<T>>;\n width?: Array<StyleRule<T>>;\n }) {\n this.refresh(rulesMap);\n }\n\n /**\n * Refresh the rules\n */\n public refresh(rulesMap: {\n color?: Array<StyleRule<T>>;\n icon?: Array<StyleRule<T>>;\n image?: Array<StyleRule<T>>;\n shape?: Array<StyleRule<T>>;\n size?: Array<StyleRule<T>>;\n width?: Array<StyleRule<T>>;\n }): void {\n if (rulesMap.color !== undefined) {\n this.colorsCache = new Map();\n }\n this._rulesMap = {\n color: rulesMap.color ? [...rulesMap.color].reverse() : this._rulesMap.color,\n icon: rulesMap.icon ? [...rulesMap.icon].reverse() : this._rulesMap.icon,\n image: rulesMap.image ? [...rulesMap.image].reverse() : this._rulesMap.image,\n shape: rulesMap.shape ? [...rulesMap.shape].reverse() : this._rulesMap.shape,\n size: rulesMap.size ? [...rulesMap.size].reverse() : this._rulesMap.size,\n width: rulesMap.width ? [...rulesMap.width].reverse() : this._rulesMap.width\n };\n }\n\n /**\n * Return the color for a node when style color is auto\n */\n public static autoColor(value: string | undefined, ignoreCase?: boolean): string {\n if (!Tools.isDefined(value)) {\n return BASE_GREY;\n }\n return PALETTE[\n ItemAttributes.getRandomUniqueColorPaletteIndex(value, PALETTE.length, ignoreCase)\n ];\n }\n\n /**\n * Return a number from 0 to number of occurrence in a palette based on a property\n */\n private static getRandomUniqueColorPaletteIndex(\n input: string,\n modulo: number,\n ignoreCase: boolean | undefined\n ): number {\n if (ignoreCase) {\n input = input.toLowerCase();\n }\n return +('0x' + sha1(input).substr(-4)) % modulo;\n }\n\n /**\n * Get color of a type\n */\n public static getTypeColor(\n rule: StyleRule<IEdgeStyle | INodeStyle>,\n type: string\n ): string | undefined | null {\n if (typeof rule.style.color === 'object' && rule.style.color.input[0] !== 'properties') {\n return ItemAttributes.autoColor(type, rule.style.color.ignoreCase);\n }\n if (!Tools.isDefined(rule.input) && typeof rule.style.color !== 'object') {\n return rule.style.color;\n }\n return null;\n }\n\n /**\n * return the corresponding size to the value with a linear function\n * @param value\n * @param lower\n * @param higher\n * @param extrema\n */\n public static getAutomaticRangeStyleLinear(\n value: number,\n {max, min}: IStyleAutoRange,\n lower: EdgeWidthExtrema | NodeSizeExtrema,\n higher: EdgeWidthExtrema | NodeSizeExtrema\n ): string | undefined {\n if (max !== undefined && min !== undefined) {\n // apply default style when min equal max\n if (max === min || isNaN(value)) {\n return '100%';\n }\n\n // calculate the linear function f(x) = ax + b\n const a = (higher - lower) / (max - min);\n const b = (lower * max - higher * min) / (max - min);\n const size = Math.floor(value * a + b);\n\n return `${size}%`;\n }\n }\n\n /**\n * return the corresponding size to the value with a logarithmic function\n * @param value\n * @param lower\n * @param higher\n * @param extrema\n */\n public static getAutomaticRangeStyleLog(\n value: number,\n {max, min}: IStyleAutoRange,\n lower: EdgeWidthExtrema | NodeSizeExtrema,\n higher: EdgeWidthExtrema | NodeSizeExtrema\n ): string | undefined {\n if (min !== undefined && max !== undefined) {\n // apply default style when min equal max\n if (max === min || isNaN(value)) {\n return '100%';\n }\n // apply an offset for all the values (including min and max)\n if (min < 1) {\n value += Math.abs(min) + 1;\n max += Math.abs(min) + 1;\n min += Math.abs(min) + 1;\n }\n // calculate the logarithmic function f(x) = Math.floor(a*log(x) + b)\n const a = (higher - lower) / (Math.log(max) - Math.log(min));\n const b = (lower * Math.log(max) - higher * Math.log(min)) / (Math.log(max) - Math.log(min));\n const size = Math.floor(a * Math.log(value) + b);\n\n return `${size}%`;\n }\n }\n\n public isAutoRange(value: string | number | IStyleAutoRange): value is IStyleAutoRange {\n return typeof value === 'object' && value?.type === 'autoRange';\n }\n}\n"]}
|
|
@@ -20,7 +20,7 @@ export declare class StyleRule<T extends INodeStyle | IEdgeStyle = INodeStyle |
|
|
|
20
20
|
/**
|
|
21
21
|
* Return true if this style match values
|
|
22
22
|
*/
|
|
23
|
-
matchValues(itemType: string | undefined, input: Array<string> | undefined, value: string): boolean;
|
|
23
|
+
matchValues(itemType: string | undefined, input: Array<string> | undefined, value: string | undefined): boolean;
|
|
24
24
|
static inputExists(type: SelectorType, input: Array<string> | undefined): input is Array<string>;
|
|
25
25
|
/**
|
|
26
26
|
* Return true if a style can apply to a node
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styleRule.js","sourceRoot":"","sources":["../../src/styles/styleRule.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,yDASiC;AAEjC,0BAAkC;AAClC,0CAAqC;AAErC,IAAY,aAEX;AAFD,WAAY,aAAa;IACvB,yCAAwB,CAAA;AAC1B,CAAC,EAFW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAExB;AAED,MAAa,SAAS;IASpB,YAAY,KAAoB;QAC9B,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QACzB,qCAAqC;QACrC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAiD,CAAC;IACvE,CAAC;IAEM,MAAM,CAAC,gBAAgB,CAAC,IAAyC;QACtE,OAAO,CACL,IAAI,CAAC,KAAK,KAAK,SAAS;YACxB,CAAC,CAAE,IAAI,CAAC,KAAoB,CAAC,KAAK,KAAK,SAAS;gBAC5C,IAAI,CAAC,KAAoB,CAAC,KAAyB,CAAC,IAAI,KAAK,aAAa,CAAC,UAAU,CAAC;gBACxF,CAAE,IAAI,CAAC,KAAoB,CAAC,IAAI,KAAK,SAAS;oBAC1C,IAAI,CAAC,KAAoB,CAAC,IAAwB,CAAC,IAAI,KAAK,aAAa,CAAC,UAAU,CAAC,CAAC,CAC7F,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,IAAI,WAAW;QACb,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,IAAI,IAAI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,OAAO,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAClF,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,aAAa,CACzB,KAA6B,EAC7B,QAA4B;QAE5B,OAAO,CACL,aAAK,CAAC,SAAS,CAAC,QAAQ,CAAC;YACzB,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,aAAK,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CACnF,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,QAAQ,CAAC,QAAmC;QACxD,OAAO,QAAQ,KAAK,SAAS,CAAC;IAChC,CAAC;IAED;;OAEG;IACI,YAAY,CAAC,IAAY;QAC9B,IAAI,KAAK,CAAC;QACV,IACE,SAAS,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;YAC9C,IAAI,CAAC,IAAI,KAAK,0BAAY,CAAC,GAAG;YAC9B,CAAC,aAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAC5B;YACA,KAAK,GAAG,kBAAc,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SACjD;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AArPD,8BAqPC","sourcesContent":["'use strict';\n\nimport {\n IEdgeStyle,\n IStyleRule,\n LkEdgeData,\n LkNodeData,\n INodeStyle,\n IRangeValues,\n SelectorType,\n IStyleAutoRange\n} from '@linkurious/rest-client';\n\nimport {ItemAttributes} from '..';\nimport {Tools} from '../tools/tools';\n\nexport enum StyleRuleType {\n AUTO_RANGE = 'autoRange'\n}\n\nexport class StyleRule<T extends INodeStyle | IEdgeStyle = INodeStyle | IEdgeStyle>\n implements IStyleRule<T> {\n public type: SelectorType;\n public input: string[] | undefined;\n public index: number;\n public style: T;\n public itemType?: string;\n public value: IRangeValues | number | string | boolean;\n\n constructor(model: IStyleRule<T>) {\n this.type = model.type;\n this.input = model.input;\n this.index = model.index;\n this.itemType = model.itemType;\n this.style = model.style;\n // cast to remove undefined from type\n this.value = model.value as IRangeValues | number | string | boolean;\n }\n\n public static isAutomaticRange(rule: IStyleRule<IEdgeStyle | INodeStyle>): boolean {\n return (\n rule.style !== undefined &&\n (((rule.style as IEdgeStyle).width !== undefined &&\n ((rule.style as IEdgeStyle).width as IStyleAutoRange).type === StyleRuleType.AUTO_RANGE) ||\n ((rule.style as INodeStyle).size !== undefined &&\n ((rule.style as INodeStyle).size as IStyleAutoRange).type === StyleRuleType.AUTO_RANGE))\n );\n }\n\n /**\n * Return an int describing specificity of the style. 4 = very specific / 1 = not specific\n *\n * @return {number}\n */\n get specificity(): 1 | 2 | 3 | 4 {\n if (this.itemType !== undefined && this.input !== undefined) {\n return 4;\n }\n if (this.itemType === undefined && this.input !== undefined) {\n return 3;\n }\n if (this.itemType !== undefined && this.input === undefined) {\n return 2;\n }\n return 1;\n }\n\n /**\n * Return true if this style match values\n */\n public matchValues(\n itemType: string | undefined,\n input: Array<string> | undefined,\n value: string\n ): boolean {\n if (Tools.isDefined(input)) {\n return (\n ((itemType === this.itemType || !Tools.isDefined(this.itemType)) &&\n Tools.isEqual(['properties', ...input], this.input) &&\n Tools.isEqual(value, this.value)) ||\n (this.type === 'any' &&\n !Tools.isDefined(this.input) &&\n typeof this.style.color === 'object' &&\n this.style.color.input[1] === input[0])\n );\n }\n\n if (Tools.isDefined(this.itemType)) {\n return itemType === this.itemType && !Tools.isDefined(this.input);\n }\n\n return !Tools.isDefined(this.input);\n }\n\n public static inputExists(\n type: SelectorType,\n input: Array<string> | undefined\n ): input is Array<string> {\n return type !== SelectorType.ANY;\n }\n\n /**\n * Return true if a style can apply to a node\n */\n public canApplyTo(data: LkNodeData | LkEdgeData): boolean {\n const types = 'categories' in data ? data.categories : [data.type];\n let typePredicate = false;\n switch (this.type) {\n case SelectorType.ANY:\n typePredicate = StyleRule.checkAny(data, this.style);\n break;\n\n case SelectorType.NO_VALUE:\n if (StyleRule.inputExists(this.type, this.input)) {\n typePredicate = StyleRule.checkNoValue(data, this.input);\n }\n break;\n\n case SelectorType.NAN:\n if (StyleRule.inputExists(this.type, this.input)) {\n typePredicate = StyleRule.checkNan(data, this.input);\n }\n break;\n\n case SelectorType.RANGE:\n if (StyleRule.inputExists(this.type, this.input)) {\n typePredicate = StyleRule.checkRange(\n Tools.getIn(data, this.input),\n this.value as IRangeValues\n );\n }\n break;\n\n case SelectorType.IS:\n if (StyleRule.inputExists(this.type, this.input)) {\n typePredicate = StyleRule.checkIs(data, this.input, this.value);\n }\n break;\n }\n return typePredicate && StyleRule.checkItemType(types, this.itemType);\n }\n\n /**\n * Return true or false on rule type 'any' if the current node match the rule\n */\n public static checkAny(data: LkNodeData | LkEdgeData, style: INodeStyle | IEdgeStyle): boolean {\n // return true if autoColor by a property and this property exists in node\n if (typeof style.color === 'object') {\n return Tools.isDefined(Tools.getIn(data, style.color.input));\n }\n return true;\n }\n\n /**\n * Return true or false on rule type 'noValue' if the current node match the rule\n */\n public static checkNoValue(data: LkNodeData | LkEdgeData, input: Array<string>): boolean {\n return !Tools.valueExists(Tools.getIn(data, input));\n }\n\n /**\n * Return true or false on rule type 'NaN' if the current node match the rule\n */\n public static checkNan(data: LkNodeData | LkEdgeData, input: Array<string>): boolean {\n return !Tools.isNumber(Tools.getIn(data, input));\n }\n\n /**\n * Return true if predicate is true for the node value\n *\n * @param value\n * @param comparator\n * @return {boolean}\n */\n public static checkRange(\n value: number,\n comparator: {[key in '<=' | '<' | '>' | '>=']?: number}\n ): boolean {\n return (\n (comparator['<='] === undefined || value <= comparator['<=']) &&\n (comparator['<'] === undefined || value < comparator['<']) &&\n (comparator['>'] === undefined || value > comparator['>']) &&\n (comparator['>='] === undefined || value >= comparator['>='])\n );\n }\n\n /**\n * Return true or false on rule type 'is' if the current node match the rule\n */\n public static checkIs(\n data: LkNodeData | LkEdgeData,\n input: Array<string>,\n value: IRangeValues | number | string | boolean\n ): boolean {\n if (!Tools.isDefined(input)) {\n return false;\n }\n const itemValue = Tools.getIn(data, input);\n let formattedValue = itemValue;\n if (\n Tools.isDefined(itemValue) &&\n typeof itemValue === 'object' &&\n (itemValue.type === 'date' || itemValue.type === 'datetime')\n ) {\n let timezone = itemValue.timezone;\n if (itemValue.timezone === 'Z') {\n timezone = '+00:00';\n }\n formattedValue = Tools.formatDate(\n itemValue.value,\n itemValue.type === 'datetime',\n Tools.timezoneToMilliseconds(timezone) / 1000\n );\n }\n return Tools.isEqual(formattedValue, value);\n }\n\n /**\n * Check that value of itemType match for the node\n */\n public static checkItemType(types: Array<string>, itemType: string | undefined): boolean {\n return StyleRule.matchCategory(types, itemType) || StyleRule.matchAny(itemType);\n }\n\n /**\n * Return true if itemType is defined and category exists in an array of categories\n *\n * @param {Array<string> | string} types\n * @param {string} itemType\n * @return {boolean}\n */\n public static matchCategory(\n types: Array<string> | string,\n itemType: string | undefined\n ): boolean {\n return (\n Tools.isDefined(itemType) &&\n (Array.isArray(types) ? types.includes(itemType) : Tools.isEqual(types, itemType))\n );\n }\n\n /**\n * Return true if itemType is undefined\n *\n * @param {string} itemType\n * @return {boolean}\n */\n public static matchAny(itemType: string | null | undefined): boolean {\n return itemType === undefined;\n }\n\n /**\n * Return the color for a type\n */\n public getTypeColor(type: string): string | undefined | null {\n let color;\n if (\n StyleRule.checkItemType([type], this.itemType) &&\n this.type === SelectorType.ANY &&\n !Tools.isDefined(this.input)\n ) {\n color = ItemAttributes.getTypeColor(this, type);\n }\n return color;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"styleRule.js","sourceRoot":"","sources":["../../src/styles/styleRule.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,yDASiC;AAEjC,0BAAkC;AAClC,0CAAqC;AAErC,IAAY,aA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AC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,aAAK,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CACnF,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,QAAQ,CAAC,QAAmC;QACxD,OAAO,QAAQ,KAAK,SAAS,CAAC;IAChC,CAAC;IAED;;OAEG;IACI,YAAY,CAAC,IAAY;QAC9B,IAAI,KAAK,CAAC;QACV,IACE,SAAS,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;YAC9C,IAAI,CAAC,IAAI,KAAK,0BAAY,CAAC,GAAG;YAC9B,CAAC,aAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAC5B;YACA,KAAK,GAAG,kBAAc,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SACjD;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AArPD,8BAqPC","sourcesContent":["'use strict';\n\nimport {\n IEdgeStyle,\n IStyleRule,\n LkEdgeData,\n LkNodeData,\n INodeStyle,\n IRangeValues,\n SelectorType,\n IStyleAutoRange\n} from '@linkurious/rest-client';\n\nimport {ItemAttributes} from '..';\nimport {Tools} from '../tools/tools';\n\nexport enum StyleRuleType {\n AUTO_RANGE = 'autoRange'\n}\n\nexport class StyleRule<T extends INodeStyle | IEdgeStyle = INodeStyle | IEdgeStyle>\n implements IStyleRule<T> {\n public type: SelectorType;\n public input: string[] | undefined;\n public index: number;\n public style: T;\n public itemType?: string;\n public value: IRangeValues | number | string | boolean;\n\n constructor(model: IStyleRule<T>) {\n this.type = model.type;\n this.input = model.input;\n this.index = model.index;\n this.itemType = model.itemType;\n this.style = model.style;\n // cast to remove undefined from type\n this.value = model.value as IRangeValues | number | string | boolean;\n }\n\n public static isAutomaticRange(rule: IStyleRule<IEdgeStyle | INodeStyle>): boolean {\n return (\n rule.style !== undefined &&\n (((rule.style as IEdgeStyle).width !== undefined &&\n ((rule.style as IEdgeStyle).width as IStyleAutoRange).type === StyleRuleType.AUTO_RANGE) ||\n ((rule.style as INodeStyle).size !== undefined &&\n ((rule.style as INodeStyle).size as IStyleAutoRange).type === StyleRuleType.AUTO_RANGE))\n );\n }\n\n /**\n * Return an int describing specificity of the style. 4 = very specific / 1 = not specific\n *\n * @return {number}\n */\n get specificity(): 1 | 2 | 3 | 4 {\n if (this.itemType !== undefined && this.input !== undefined) {\n return 4;\n }\n if (this.itemType === undefined && this.input !== undefined) {\n return 3;\n }\n if (this.itemType !== undefined && this.input === undefined) {\n return 2;\n }\n return 1;\n }\n\n /**\n * Return true if this style match values\n */\n public matchValues(\n itemType: string | undefined,\n input: Array<string> | undefined,\n value: string | undefined\n ): boolean {\n if (Tools.isDefined(input)) {\n return (\n ((itemType === this.itemType || !Tools.isDefined(this.itemType)) &&\n Tools.isEqual(['properties', ...input], this.input) &&\n Tools.isEqual(value, this.value)) ||\n (this.type === 'any' &&\n !Tools.isDefined(this.input) &&\n typeof this.style.color === 'object' &&\n this.style.color.input[1] === input[0])\n );\n }\n\n if (Tools.isDefined(this.itemType)) {\n return itemType === this.itemType && !Tools.isDefined(this.input);\n }\n\n return !Tools.isDefined(this.input);\n }\n\n public static inputExists(\n type: SelectorType,\n input: Array<string> | undefined\n ): input is Array<string> {\n return type !== SelectorType.ANY;\n }\n\n /**\n * Return true if a style can apply to a node\n */\n public canApplyTo(data: LkNodeData | LkEdgeData): boolean {\n const types = 'categories' in data ? data.categories : [data.type];\n let typePredicate = false;\n switch (this.type) {\n case SelectorType.ANY:\n typePredicate = StyleRule.checkAny(data, this.style);\n break;\n\n case SelectorType.NO_VALUE:\n if (StyleRule.inputExists(this.type, this.input)) {\n typePredicate = StyleRule.checkNoValue(data, this.input);\n }\n break;\n\n case SelectorType.NAN:\n if (StyleRule.inputExists(this.type, this.input)) {\n typePredicate = StyleRule.checkNan(data, this.input);\n }\n break;\n\n case SelectorType.RANGE:\n if (StyleRule.inputExists(this.type, this.input)) {\n typePredicate = StyleRule.checkRange(\n Tools.getIn(data, this.input),\n this.value as IRangeValues\n );\n }\n break;\n\n case SelectorType.IS:\n if (StyleRule.inputExists(this.type, this.input)) {\n typePredicate = StyleRule.checkIs(data, this.input, this.value);\n }\n break;\n }\n return typePredicate && StyleRule.checkItemType(types, this.itemType);\n }\n\n /**\n * Return true or false on rule type 'any' if the current node match the rule\n */\n public static checkAny(data: LkNodeData | LkEdgeData, style: INodeStyle | IEdgeStyle): boolean {\n // return true if autoColor by a property and this property exists in node\n if (typeof style.color === 'object') {\n return Tools.isDefined(Tools.getIn(data, style.color.input));\n }\n return true;\n }\n\n /**\n * Return true or false on rule type 'noValue' if the current node match the rule\n */\n public static checkNoValue(data: LkNodeData | LkEdgeData, input: Array<string>): boolean {\n return !Tools.valueExists(Tools.getIn(data, input));\n }\n\n /**\n * Return true or false on rule type 'NaN' if the current node match the rule\n */\n public static checkNan(data: LkNodeData | LkEdgeData, input: Array<string>): boolean {\n return !Tools.isNumber(Tools.getIn(data, input));\n }\n\n /**\n * Return true if predicate is true for the node value\n *\n * @param value\n * @param comparator\n * @return {boolean}\n */\n public static checkRange(\n value: number,\n comparator: {[key in '<=' | '<' | '>' | '>=']?: number}\n ): boolean {\n return (\n (comparator['<='] === undefined || value <= comparator['<=']) &&\n (comparator['<'] === undefined || value < comparator['<']) &&\n (comparator['>'] === undefined || value > comparator['>']) &&\n (comparator['>='] === undefined || value >= comparator['>='])\n );\n }\n\n /**\n * Return true or false on rule type 'is' if the current node match the rule\n */\n public static checkIs(\n data: LkNodeData | LkEdgeData,\n input: Array<string>,\n value: IRangeValues | number | string | boolean\n ): boolean {\n if (!Tools.isDefined(input)) {\n return false;\n }\n const itemValue = Tools.getIn(data, input);\n let formattedValue = itemValue;\n if (\n Tools.isDefined(itemValue) &&\n typeof itemValue === 'object' &&\n (itemValue.type === 'date' || itemValue.type === 'datetime')\n ) {\n let timezone = itemValue.timezone;\n if (itemValue.timezone === 'Z') {\n timezone = '+00:00';\n }\n formattedValue = Tools.formatDate(\n itemValue.value,\n itemValue.type === 'datetime',\n Tools.timezoneToMilliseconds(timezone) / 1000\n );\n }\n return Tools.isEqual(formattedValue, value);\n }\n\n /**\n * Check that value of itemType match for the node\n */\n public static checkItemType(types: Array<string>, itemType: string | undefined): boolean {\n return StyleRule.matchCategory(types, itemType) || StyleRule.matchAny(itemType);\n }\n\n /**\n * Return true if itemType is defined and category exists in an array of categories\n *\n * @param {Array<string> | string} types\n * @param {string} itemType\n * @return {boolean}\n */\n public static matchCategory(\n types: Array<string> | string,\n itemType: string | undefined\n ): boolean {\n return (\n Tools.isDefined(itemType) &&\n (Array.isArray(types) ? types.includes(itemType) : Tools.isEqual(types, itemType))\n );\n }\n\n /**\n * Return true if itemType is undefined\n *\n * @param {string} itemType\n * @return {boolean}\n */\n public static matchAny(itemType: string | null | undefined): boolean {\n return itemType === undefined;\n }\n\n /**\n * Return the color for a type\n */\n public getTypeColor(type: string): string | undefined | null {\n let color;\n if (\n StyleRule.checkItemType([type], this.itemType) &&\n this.type === SelectorType.ANY &&\n !Tools.isDefined(this.input)\n ) {\n color = ItemAttributes.getTypeColor(this, type);\n }\n return color;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linkurious/ogma-linkurious-parser",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"author": "Linkurious SAS",
|
|
5
5
|
"description": "Parse and load a Linkurious visualization in Ogma with one line of code ",
|
|
6
6
|
"files": [
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"main": "./dist/index.js",
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"engines": {
|
|
16
|
-
"node": "
|
|
16
|
+
"node": "20.12.1"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
19
|
"build": "tsc -b",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"latest:master-maintenance": "npm install --save-exact @linkurious/rest-client@lk-master-maintenance",
|
|
34
34
|
"latest:master-stable": "npm install --save-exact @linkurious/rest-client@lk-master-stable",
|
|
35
35
|
"latest:master": "npm install --save-exact @linkurious/rest-client@lk-master",
|
|
36
|
+
"latest:generic": "npm install --save-exact @linkurious/rest-client@${npm_config_lk_tag}",
|
|
36
37
|
"bump:patch": "bump2version patch && npm version --no-git-tag-version patch",
|
|
37
38
|
"bump:minor": "bump2version minor && npm version --no-git-tag-version minor",
|
|
38
39
|
"bump:major": "bump2version major && npm version --no-git-tag-version major"
|
|
@@ -53,7 +54,7 @@
|
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
56
|
"@linkurious/ogma": "4.5.9",
|
|
56
|
-
"@linkurious/rest-client": "4.0
|
|
57
|
+
"@linkurious/rest-client": "4.1.0",
|
|
57
58
|
"@rollup/plugin-buble": "0.21.3",
|
|
58
59
|
"@rollup/plugin-commonjs": "17.0.0",
|
|
59
60
|
"@rollup/plugin-json": "4.1.0",
|