@linkurious/ogma-linkurious-parser 3.1.13 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/captions/captions.js +42 -54
  2. package/dist/captions/captions.js.map +1 -1
  3. package/dist/filters/filters.d.ts +1 -1
  4. package/dist/filters/filters.js +55 -76
  5. package/dist/filters/filters.js.map +1 -1
  6. package/dist/index.js +34 -33
  7. package/dist/index.js.map +1 -1
  8. package/dist/ogma/features/OgmaStore.js +16 -30
  9. package/dist/ogma/features/OgmaStore.js.map +1 -1
  10. package/dist/ogma/features/captions.js +43 -87
  11. package/dist/ogma/features/captions.js.map +1 -1
  12. package/dist/ogma/features/reactive.js +58 -75
  13. package/dist/ogma/features/reactive.js.map +1 -1
  14. package/dist/ogma/features/selectors.d.ts +5 -5
  15. package/dist/ogma/features/selectors.js +25 -16
  16. package/dist/ogma/features/selectors.js.map +1 -1
  17. package/dist/ogma/features/styles.js +115 -137
  18. package/dist/ogma/features/styles.js.map +1 -1
  19. package/dist/ogma/features/transformations.js +39 -87
  20. package/dist/ogma/features/transformations.js.map +1 -1
  21. package/dist/ogma/index.js +140 -230
  22. package/dist/ogma/index.js.map +1 -1
  23. package/dist/styles/edgeAttributes.js +31 -47
  24. package/dist/styles/edgeAttributes.js.map +1 -1
  25. package/dist/styles/itemAttributes.js +33 -42
  26. package/dist/styles/itemAttributes.js.map +1 -1
  27. package/dist/styles/nodeAttributes.js +49 -71
  28. package/dist/styles/nodeAttributes.js.map +1 -1
  29. package/dist/styles/styleRule.js +57 -68
  30. package/dist/styles/styleRule.js.map +1 -1
  31. package/dist/styles/styleRules.js +150 -192
  32. package/dist/styles/styleRules.js.map +1 -1
  33. package/dist/tools/colorPalette.js +1 -0
  34. package/dist/tools/colorPalette.js.map +1 -1
  35. package/dist/tools/ogmaTool.js +28 -30
  36. package/dist/tools/ogmaTool.js.map +1 -1
  37. package/dist/tools/tools.js +88 -91
  38. package/dist/tools/tools.js.map +1 -1
  39. package/package.json +7 -7
@@ -1,16 +1,18 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var rest_client_1 = require("@linkurious/rest-client");
3
+ exports.hasSelectionProperties = exports.getSelectionProperties = exports.getUniqSelectionEntity = exports.getUniqSelectionTypes = exports.getUniqSelection = exports.getSelectionEntity = exports.getSelectionState = exports.getSelectionSize = void 0;
4
+ const rest_client_1 = require("@linkurious/rest-client");
4
5
  /**
5
6
  * Return the current size of the selection
6
7
  */
7
- exports.getSelectionSize = function (state) {
8
+ const getSelectionSize = (state) => {
8
9
  return state.selection.size;
9
10
  };
11
+ exports.getSelectionSize = getSelectionSize;
10
12
  /**
11
13
  * Return the current state of the selection
12
14
  */
13
- exports.getSelectionState = function (state) {
15
+ const getSelectionState = (state) => {
14
16
  switch (state.selection.size) {
15
17
  case 1:
16
18
  return 'selection';
@@ -20,26 +22,29 @@ exports.getSelectionState = function (state) {
20
22
  return 'multiSelection';
21
23
  }
22
24
  };
25
+ exports.getSelectionState = getSelectionState;
23
26
  /**
24
27
  * Get the entityType of the current selection
25
28
  */
26
- exports.getSelectionEntity = function (state) {
29
+ const getSelectionEntity = (state) => {
27
30
  if (state.selection.size === 0) {
28
31
  return undefined;
29
32
  }
30
33
  return state.selection.isNode ? rest_client_1.EntityType.NODE : rest_client_1.EntityType.EDGE;
31
34
  };
35
+ exports.getSelectionEntity = getSelectionEntity;
32
36
  /**
33
37
  * Return the item selection if there's only one item selected
34
38
  */
35
- exports.getUniqSelection = function (state) {
39
+ const getUniqSelection = (state) => {
36
40
  return state.selection.size === 1 ? state.selection.get(0) : undefined;
37
41
  };
42
+ exports.getUniqSelection = getUniqSelection;
38
43
  /**
39
44
  * Return the types of the current selection (if only one item is selected)
40
45
  */
41
- exports.getUniqSelectionTypes = function (state) {
42
- var uniqSelection = exports.getUniqSelection(state);
46
+ const getUniqSelectionTypes = (state) => {
47
+ const uniqSelection = (0, exports.getUniqSelection)(state);
43
48
  if (uniqSelection === undefined) {
44
49
  return undefined;
45
50
  }
@@ -50,11 +55,12 @@ exports.getUniqSelectionTypes = function (state) {
50
55
  return [uniqSelection.getData('type')];
51
56
  }
52
57
  };
58
+ exports.getUniqSelectionTypes = getUniqSelectionTypes;
53
59
  /**
54
60
  * Return the entityType of the current selection if there's only one item selected
55
61
  */
56
- exports.getUniqSelectionEntity = function (state) {
57
- var uniqSelection = exports.getUniqSelection(state);
62
+ const getUniqSelectionEntity = (state) => {
63
+ const uniqSelection = (0, exports.getUniqSelection)(state);
58
64
  if (uniqSelection === undefined) {
59
65
  return undefined;
60
66
  }
@@ -63,26 +69,29 @@ exports.getUniqSelectionEntity = function (state) {
63
69
  }
64
70
  return 'edge';
65
71
  };
72
+ exports.getUniqSelectionEntity = getUniqSelectionEntity;
66
73
  /**
67
74
  * Return the properties of the current selection if there's only one item selected
68
75
  */
69
- exports.getSelectionProperties = function (state) {
70
- var uniqSelection = exports.getUniqSelection(state);
76
+ const getSelectionProperties = (state) => {
77
+ const uniqSelection = (0, exports.getUniqSelection)(state);
71
78
  if (uniqSelection !== undefined) {
72
- var properties_1 = uniqSelection.getData().properties;
73
- return Object.keys(properties_1).map(function (propKey) {
79
+ const properties = uniqSelection.getData().properties;
80
+ return Object.keys(properties).map((propKey) => {
74
81
  return {
75
82
  key: propKey,
76
- value: properties_1[propKey]
83
+ value: properties[propKey]
77
84
  };
78
85
  });
79
86
  }
80
87
  return [];
81
88
  };
89
+ exports.getSelectionProperties = getSelectionProperties;
82
90
  /**
83
91
  * Return true if the current selection has properties
84
92
  */
85
- exports.hasSelectionProperties = function (state) {
86
- return exports.getSelectionProperties(state).length > 0;
93
+ const hasSelectionProperties = (state) => {
94
+ return (0, exports.getSelectionProperties)(state).length > 0;
87
95
  };
96
+ exports.hasSelectionProperties = hasSelectionProperties;
88
97
  //# sourceMappingURL=selectors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"selectors.js","sourceRoot":"","sources":["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,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;KACxC;AACH,CAAC,CAAC;AAEF;;GAEG;AACU,QAAA,sBAAsB,GAAG,UAAC,KAAgB;IACrD,IAAM,aAAa,GAAG,wBAAgB,CAAC,KAAK,CAAC,CAAC;IAC9C,IAAI,aAAa,KAAK,SAAS,EAAE;QAC/B,OAAO,SAAS,CAAC;KAClB;IACD,IAAI,aAAa,CAAC,MAAM,EAAE;QACxB,OAAO,MAAM,CAAC;KACf;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF;;GAEG;AACU,QAAA,sBAAsB,GAAG,UAAC,KAAgB;IACrD,IAAM,aAAa,GAAG,wBAAgB,CAAC,KAAK,CAAC,CAAC;IAC9C,IAAI,aAAa,KAAK,SAAS,EAAE;QAC/B,IAAM,YAAU,GAAG,aAAa,CAAC,OAAO,EAAE,CAAC,UAAU,CAAC;QACtD,OAAO,MAAM,CAAC,IAAI,CAAC,YAAU,CAAC,CAAC,GAAG,CAAC,UAAC,OAAO;YACzC,OAAO;gBACL,GAAG,EAAE,OAAO;gBACZ,KAAK,EAAE,YAAU,CAAC,OAAO,CAAC;aAC3B,CAAC;QACJ,CAAC,CAAC,CAAC;KACJ;IACD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF;;GAEG;AACU,QAAA,sBAAsB,GAAG,UAAC,KAAgB;IACrD,OAAO,8BAAsB,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AAClD,CAAC,CAAC","sourcesContent":["'use strict';\n\nimport {EntityType, LkEdgeData, LkNodeData} from '@linkurious/rest-client';\nimport {Edge, ItemList, Node} from '@linkurious/ogma';\n\nimport {OgmaState} from './reactive';\n\nexport type SelectionState = 'selection' | 'multiSelection' | 'noSelection';\n\n/**\n * Return the current size of the selection\n */\nexport const getSelectionSize = (state: OgmaState): number => {\n return (state.selection as ItemList<LkNodeData>).size;\n};\n\n/**\n * Return the current state of the selection\n */\nexport const getSelectionState = (state: OgmaState): SelectionState => {\n switch ((state.selection as ItemList<LkNodeData>).size) {\n case 1:\n return 'selection';\n\n case 0:\n return 'noSelection';\n\n default:\n return 'multiSelection';\n }\n};\n\n/**\n * Get the entityType of the current selection\n */\nexport const getSelectionEntity = (state: OgmaState): EntityType | undefined => {\n if (state.selection.size === 0) {\n return undefined;\n }\n return (state.selection as ItemList<LkNodeData>).isNode ? EntityType.NODE : EntityType.EDGE;\n};\n\n/**\n * Return the item selection if there's only one item selected\n */\nexport const getUniqSelection = (\n state: OgmaState\n): Node<LkNodeData, LkEdgeData> | Edge<LkEdgeData, LkNodeData> | undefined => {\n return state.selection.size === 1 ? state.selection.get(0) : undefined;\n};\n\n/**\n * Return the types of the current selection (if only one item is selected)\n */\nexport const getUniqSelectionTypes = (state: OgmaState): Array<string> | undefined => {\n const uniqSelection = getUniqSelection(state);\n if (uniqSelection === undefined) {\n return undefined;\n }\n if (uniqSelection.isNode) {\n return uniqSelection.getData('categories');\n } else {\n return [uniqSelection.getData('type')];\n }\n};\n\n/**\n * Return the entityType of the current selection if there's only one item selected\n */\nexport const getUniqSelectionEntity = (state: OgmaState): 'node' | 'edge' | undefined => {\n const uniqSelection = getUniqSelection(state);\n if (uniqSelection === undefined) {\n return undefined;\n }\n if (uniqSelection.isNode) {\n return 'node';\n }\n return 'edge';\n};\n\n/**\n * Return the properties of the current selection if there's only one item selected\n */\nexport const getSelectionProperties = (state: OgmaState): Array<{key: string; value: any}> => {\n const uniqSelection = getUniqSelection(state);\n if (uniqSelection !== undefined) {\n const properties = uniqSelection.getData().properties;\n return Object.keys(properties).map((propKey) => {\n return {\n key: propKey,\n value: properties[propKey]\n };\n });\n }\n return [];\n};\n\n/**\n * Return true if the current selection has properties\n */\nexport const hasSelectionProperties = (state: OgmaState): boolean => {\n return getSelectionProperties(state).length > 0;\n};\n"]}
1
+ {"version":3,"file":"selectors.js","sourceRoot":"","sources":["../../../src/ogma/features/selectors.ts"],"names":[],"mappings":"AA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CAAC;AAClD,CAAC,CAAC;AAFW,QAAA,sBAAsB,0BAEjC","sourcesContent":["'use strict';\n\nimport {EntityType, LkEdgeData, LkNodeData} from '@linkurious/rest-client';\nimport {Edge, ItemList, Node} from '@linkurious/ogma';\n\nimport {OgmaState} from './reactive';\n\nexport type SelectionState = 'selection' | 'multiSelection' | 'noSelection';\n\n/**\n * Return the current size of the selection\n */\nexport const getSelectionSize = (state: OgmaState): number => {\n return (state.selection as ItemList<LkNodeData>).size;\n};\n\n/**\n * Return the current state of the selection\n */\nexport const getSelectionState = (state: OgmaState): SelectionState => {\n switch ((state.selection as ItemList<LkNodeData>).size) {\n case 1:\n return 'selection';\n\n case 0:\n return 'noSelection';\n\n default:\n return 'multiSelection';\n }\n};\n\n/**\n * Get the entityType of the current selection\n */\nexport const getSelectionEntity = (state: OgmaState): EntityType | undefined => {\n if (state.selection.size === 0) {\n return undefined;\n }\n return (state.selection as ItemList<LkNodeData>).isNode ? EntityType.NODE : EntityType.EDGE;\n};\n\n/**\n * Return the item selection if there's only one item selected\n */\nexport const getUniqSelection = (\n state: OgmaState\n): Node<LkNodeData, LkEdgeData> | Edge<LkEdgeData, LkNodeData> | undefined => {\n return state.selection.size === 1 ? state.selection.get(0) : undefined;\n};\n\n/**\n * Return the types of the current selection (if only one item is selected)\n */\nexport const getUniqSelectionTypes = (state: OgmaState): Array<string> | undefined => {\n const uniqSelection = getUniqSelection(state);\n if (uniqSelection === undefined) {\n return undefined;\n }\n if (uniqSelection.isNode) {\n return uniqSelection.getData('categories');\n } else {\n return [uniqSelection.getData('type')];\n }\n};\n\n/**\n * Return the entityType of the current selection if there's only one item selected\n */\nexport const getUniqSelectionEntity = (state: OgmaState): 'node' | 'edge' | undefined => {\n const uniqSelection = getUniqSelection(state);\n if (uniqSelection === undefined) {\n return undefined;\n }\n if (uniqSelection.isNode) {\n return 'node';\n }\n return 'edge';\n};\n\n/**\n * Return the properties of the current selection if there's only one item selected\n */\nexport const getSelectionProperties = (state: OgmaState): Array<{key: string; value: any}> => {\n const uniqSelection = getUniqSelection(state);\n if (uniqSelection !== undefined) {\n const properties = uniqSelection.getData().properties;\n return Object.keys(properties).map((propKey) => {\n return {\n key: propKey,\n value: properties[propKey]\n };\n });\n }\n return [];\n};\n\n/**\n * Return true if the current selection has properties\n */\nexport const hasSelectionProperties = (state: OgmaState): boolean => {\n return getSelectionProperties(state).length > 0;\n};\n"]}