@searpent/react-image-annotate 2.0.37 → 2.0.39

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.
@@ -420,7 +420,7 @@ var examplePhotos = [{
420
420
  "Y2": 0.8037425
421
421
  },
422
422
  "text": "[{\"label\":\"title\",\"text\":\"Fotbal. Remíza s Ukrajinou\"}]",
423
- "groupId": "0",
423
+ "groupId": "42ba09e0-b2f5-439d-bdae-201e7c37787b",
424
424
  "id": "346807503780052992"
425
425
  }, {
426
426
  "label": "text",
@@ -432,7 +432,7 @@ var examplePhotos = [{
432
432
  "Y2": 0.95930564
433
433
  },
434
434
  "text": "[{\"label\":\"text\",\"text\":\"\"}]",
435
- "groupId": "0",
435
+ "groupId": "42ba09e0-b2f5-439d-bdae-201e7c37787b",
436
436
  "id": "346807503780052993"
437
437
  }, {
438
438
  "label": "author",
@@ -444,7 +444,7 @@ var examplePhotos = [{
444
444
  "Y2": 0.95930564
445
445
  },
446
446
  "text": "[{\"label\":\"author\",\"text\":\"ČTK\"}]",
447
- "groupId": "0",
447
+ "groupId": "42ba09e0-b2f5-439d-bdae-201e7c37787b",
448
448
  "id": "346807503780052994"
449
449
  }, {
450
450
  "label": "title",
@@ -784,7 +784,7 @@ var examplePhotos = [{
784
784
  "Y2": 1
785
785
  },
786
786
  "text": "[{\"key\":\"articleType\",\"value\":\"news\"}, {\"key\":\"section\",\"value\":\"editorial\"}]",
787
- "groupId": "0",
787
+ "groupId": "42ba09e0-b2f5-439d-bdae-201e7c37787b",
788
788
  "id": "aba453dd-f870-4510-ae40-a19eb52eb7d6"
789
789
  }, {
790
790
  "label": "metadata",
@@ -211,7 +211,7 @@ export var Annotator = function Annotator(_ref) {
211
211
 
212
212
 
213
213
  useEffect(function () {
214
- if (!state.lastAction || !["BEGIN_BOX_TRANSFORM", "CHANGE_REGION", "DELETE_REGION", "UPDATE_METADATA", "SELECT_CLASSIFICATION"].includes(state.lastAction.type)) {
214
+ if (!state.lastAction || !["BEGIN_BOX_TRANSFORM", "CHANGE_REGION", "DELETE_REGION", "DELETE_SELECTED_REGION", "UPDATE_METADATA", "SELECT_CLASSIFICATION"].includes(state.lastAction.type)) {
215
215
  return;
216
216
  }
217
217
 
@@ -50,6 +50,16 @@ function defaultClsColor(cls) {
50
50
  }
51
51
  }
52
52
 
53
+ function stringToNumber(str) {
54
+ var sum = 0;
55
+
56
+ for (var index = 0; index < str.length; index++) {
57
+ sum += str.charCodeAt(index);
58
+ }
59
+
60
+ return sum;
61
+ }
62
+
53
63
  var useColors = function useColors() {
54
64
  var _useSettings = useSettings(),
55
65
  clsColors = _useSettings.clsColors,
@@ -68,7 +78,11 @@ var useColors = function useColors() {
68
78
  };
69
79
 
70
80
  var groupColor = function groupColor(idx) {
71
- return groupColors[idx % groupColors.length] || DEFAULT_GROUP_COLOR;
81
+ if (isNaN(idx)) {
82
+ return groupColors[stringToNumber(idx) % groupColors.length] || DEFAULT_GROUP_COLOR;
83
+ } else {
84
+ return groupColors[idx % groupColors.length] || DEFAULT_GROUP_COLOR;
85
+ }
72
86
  };
73
87
 
74
88
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@searpent/react-image-annotate",
3
- "version": "2.0.37",
3
+ "version": "2.0.39",
4
4
  "dependencies": {
5
5
  "@editorjs/editorjs": "^2.25.0",
6
6
  "@editorjs/paragraph": "^2.8.0",