lost-sia 2.0.0-alpha1 → 2.0.0-alpha2

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 (87) hide show
  1. package/package.json +20 -3
  2. package/src/AnnoExampleViewer.jsx +61 -48
  3. package/src/AnnoLabelInput.jsx +94 -84
  4. package/src/AnnoToolBar.jsx +118 -97
  5. package/src/Annotation/AnnoBar.jsx +137 -131
  6. package/src/Annotation/Annotation.jsx +364 -328
  7. package/src/Annotation/Annotation.scss +24 -24
  8. package/src/Annotation/BBox.jsx +259 -251
  9. package/src/Annotation/Edge.jsx +79 -69
  10. package/src/Annotation/InfSelectionArea.jsx +56 -55
  11. package/src/Annotation/Line.jsx +60 -52
  12. package/src/Annotation/Node.jsx +242 -238
  13. package/src/Annotation/Point.jsx +175 -171
  14. package/src/Annotation/Polygon.jsx +337 -310
  15. package/src/Canvas.jsx +1910 -1724
  16. package/src/ImgBar.jsx +115 -107
  17. package/src/InfoBoxes/AnnoDetails.jsx +141 -141
  18. package/src/InfoBoxes/AnnoStats.jsx +90 -87
  19. package/src/InfoBoxes/InfoBox.jsx +63 -65
  20. package/src/InfoBoxes/InfoBoxArea.jsx +132 -130
  21. package/src/InfoBoxes/LabelInfo.jsx +103 -83
  22. package/src/LabelInput.jsx +204 -190
  23. package/src/Prompt.jsx +37 -38
  24. package/src/SIA.scss +8 -9
  25. package/src/SIAFilterButton.jsx +178 -169
  26. package/src/SIASettingButton.jsx +112 -107
  27. package/src/Sia.jsx +269 -288
  28. package/src/SiaPopup.jsx +13 -8
  29. package/src/ToolBar.jsx +394 -375
  30. package/src/Toolbar.css +8 -8
  31. package/src/ToolbarItem.jsx +28 -22
  32. package/src/filterTools.js +3 -3
  33. package/src/index.js +9 -10
  34. package/src/scss/_custom.scss +3 -0
  35. package/src/scss/_fixes.scss +6 -0
  36. package/src/scss/_layout.scss +6 -0
  37. package/src/scss/_variables.scss +4 -0
  38. package/src/{style.scss → scss/style-wrapper.scss} +1 -0
  39. package/src/scss/style.scss +13 -0
  40. package/src/siaDummyData.js +241 -243
  41. package/src/stories/Button.jsx +54 -0
  42. package/src/stories/Button.stories.js +48 -0
  43. package/src/stories/Configure.mdx +369 -0
  44. package/src/stories/Header.jsx +69 -0
  45. package/src/stories/Header.stories.js +28 -0
  46. package/src/stories/Page.jsx +87 -0
  47. package/src/stories/Page.stories.js +28 -0
  48. package/src/stories/Sia.stories.jsx +61 -0
  49. package/src/stories/assets/accessibility.png +0 -0
  50. package/src/stories/assets/accessibility.svg +5 -0
  51. package/src/stories/assets/addon-library.png +0 -0
  52. package/src/stories/assets/assets.png +0 -0
  53. package/src/stories/assets/avif-test-image.avif +0 -0
  54. package/src/stories/assets/context.png +0 -0
  55. package/src/stories/assets/discord.svg +15 -0
  56. package/src/stories/assets/docs.png +0 -0
  57. package/src/stories/assets/figma-plugin.png +0 -0
  58. package/src/stories/assets/github.svg +3 -0
  59. package/src/stories/assets/share.png +0 -0
  60. package/src/stories/assets/styling.png +0 -0
  61. package/src/stories/assets/testing.png +0 -0
  62. package/src/stories/assets/theming.png +0 -0
  63. package/src/stories/assets/tutorials.svg +12 -0
  64. package/src/stories/assets/youtube.svg +4 -0
  65. package/src/stories/button.css +30 -0
  66. package/src/stories/header.css +32 -0
  67. package/src/stories/lost.js +54 -0
  68. package/src/stories/page.css +69 -0
  69. package/src/stories/siaDummyData.js +263 -0
  70. package/src/stories/store.js +18 -0
  71. package/src/types/annoStatus.js +4 -4
  72. package/src/types/canvasActions.js +51 -51
  73. package/src/types/cursorstyles.js +3 -3
  74. package/src/types/modes.js +8 -8
  75. package/src/types/notificationType.js +4 -4
  76. package/src/types/toolbarEvents.js +31 -31
  77. package/src/types/tools.js +9 -9
  78. package/src/utils/annoConversion.js +129 -99
  79. package/src/utils/colorlut.js +33 -32
  80. package/src/utils/constraints.js +76 -70
  81. package/src/utils/hist.js +52 -53
  82. package/src/utils/keyActions.js +96 -97
  83. package/src/utils/mouse.js +10 -10
  84. package/src/utils/siaIcons.jsx +106 -67
  85. package/src/utils/transform.js +259 -241
  86. package/src/utils/uiConfig.js +45 -45
  87. package/src/utils/windowViewport.js +26 -27
@@ -1,148 +1,154 @@
1
- import React, { Component } from 'react'
2
- import * as transform from '../utils/transform'
3
- import * as modes from '../types/modes'
1
+ import React, { Component } from "react";
2
+ import * as transform from "../utils/transform";
3
+ import * as modes from "../types/modes";
4
4
 
5
- const defaultFontSize = 10
6
- const defaultRectHeight = 15
5
+ const defaultFontSize = 10;
6
+ const defaultRectHeight = 15;
7
7
 
8
8
  class AnnoBar extends Component {
9
+ constructor(props) {
10
+ super(props);
11
+ this.state = {
12
+ top: 0,
13
+ left: 0,
14
+ width: 50,
15
+ height: defaultRectHeight,
16
+ fontSize: defaultFontSize,
17
+ };
18
+ this.textRef = React.createRef();
19
+ }
9
20
 
10
- constructor(props) {
11
- super(props)
12
- this.state = {
13
- top: 0,
14
- left: 0,
15
- width: 50,
16
- height: defaultRectHeight,
17
- fontSize: defaultFontSize,
18
- }
19
- this.textRef = React.createRef()
20
- }
21
+ /*************
22
+ * EVENTS *
23
+ **************/
24
+ componentWillMount() {
25
+ if (this.props.mode !== modes.CREATE) this.setPosition();
26
+ }
21
27
 
22
- /*************
23
- * EVENTS *
24
- **************/
25
- componentWillMount() {
26
- if (this.props.mode !== modes.CREATE) this.setPosition()
28
+ componentDidUpdate() {
29
+ if (this.props.mode !== modes.CREATE) {
30
+ this.setPosition();
27
31
  }
32
+ }
28
33
 
29
- componentDidUpdate() {
30
- if (this.props.mode !== modes.CREATE) {
31
- this.setPosition()
32
- }
34
+ handleClick(e) {
35
+ e.preventDefault();
36
+ if (this.props.onClick) {
37
+ this.props.onClick(e);
33
38
  }
34
-
35
- handleClick(e) {
36
- e.preventDefault()
37
- if (this.props.onClick) {
38
- this.props.onClick(e)
39
- }
39
+ }
40
+ /*************
41
+ * LOGIC *
42
+ *************/
43
+ setPosition() {
44
+ // const center = transform.getCenter(this.props.anno.data, this.props.anno.type)
45
+ // const top = center.y
46
+ // const left = center.x
47
+ // if (this.state.top !== top || this.state.left !== left){
48
+ // this.setState({
49
+ // top,
50
+ // left
51
+ // })
52
+ // }
53
+ let topPoint = transform.getTopPoint(this.props.anno.data);
54
+ topPoint = transform.getMostLeftPoint(topPoint)[0];
55
+ if (this.textRef.current) {
56
+ const text = this.textRef.current.getBoundingClientRect();
57
+ const textPadding = 2;
58
+ let rectWidth = (text.width + textPadding) / this.props.svg.scale;
59
+ if (rectWidth !== this.state.width) {
60
+ this.setState({
61
+ width: rectWidth,
62
+ fontSize: Math.ceil(defaultFontSize / this.props.svg.scale),
63
+ // height: Math.ceil(defaultFontSize/this.props.svg.scale)
64
+ });
65
+ }
40
66
  }
41
- /*************
42
- * LOGIC *
43
- *************/
44
- setPosition() {
45
- // const center = transform.getCenter(this.props.anno.data, this.props.anno.type)
46
- // const top = center.y
47
- // const left = center.x
48
- // if (this.state.top !== top || this.state.left !== left){
49
- // this.setState({
50
- // top,
51
- // left
52
- // })
53
- // }
54
- let topPoint = transform.getTopPoint(this.props.anno.data)
55
- topPoint = transform.getMostLeftPoint(topPoint)[0]
56
- if (this.textRef.current) {
57
- const text = this.textRef.current.getBoundingClientRect()
58
- const textPadding = 2
59
- let rectWidth = (text.width + textPadding) / this.props.svg.scale
60
- if (rectWidth !== this.state.width) {
61
- this.setState({
62
- width: rectWidth,
63
- fontSize: Math.ceil(defaultFontSize / this.props.svg.scale),
64
- // height: Math.ceil(defaultFontSize/this.props.svg.scale)
65
- })
66
- }
67
- }
68
- let top = topPoint.y - 10
69
- let left = topPoint.x + 7
70
- if (top < 0) top = topPoint.y + 10
71
- if (this.state.top !== top || this.state.left !== left) {
72
- this.setState({
73
- top,
74
- left,
75
- // width: annoBox[1].x - annoBox[0].x
76
- })
77
- }
67
+ let top = topPoint.y - 10;
68
+ let left = topPoint.x + 7;
69
+ if (top < 0) top = topPoint.y + 10;
70
+ if (this.state.top !== top || this.state.left !== left) {
71
+ this.setState({
72
+ top,
73
+ left,
74
+ // width: annoBox[1].x - annoBox[0].x
75
+ });
78
76
  }
77
+ }
79
78
 
80
- /*************
81
- * RENDERING *
82
- **************/
83
-
79
+ /*************
80
+ * RENDERING *
81
+ **************/
84
82
 
85
- render() {
86
- let label = ''
87
- if (!this.props.possibleLabels) return null
88
- let labelObject
89
- if (this.props.anno.labelIds && this.props.anno.labelIds.length > 0) {
90
- this.props.anno.labelIds.forEach((lbl, idx) => {
91
- labelObject = this.props.possibleLabels.find(el => {
92
- return el.id === lbl
93
- })
94
- if (idx > 0) label += ', '
95
- label += labelObject.label
96
- })
83
+ render() {
84
+ let label = "";
85
+ if (!this.props.possibleLabels) return null;
86
+ let labelObject;
87
+ if (this.props.anno.labelIds && this.props.anno.labelIds.length > 0) {
88
+ this.props.anno.labelIds.forEach((lbl, idx) => {
89
+ labelObject = this.props.possibleLabels.find((el) => {
90
+ return el.id === lbl;
91
+ });
92
+ if (idx > 0) label += ", ";
93
+ label += labelObject.label;
94
+ });
95
+ } else {
96
+ if (this.props.defaultLabel) {
97
+ if (Number.isInteger(this.props.defaultLabel)) {
98
+ labelObject = this.props.possibleLabels.find((el) => {
99
+ return el.id === this.props.defaultLabel;
100
+ });
101
+ label = labelObject.label;
97
102
  } else {
98
- if (this.props.defaultLabel) {
99
- if (Number.isInteger(this.props.defaultLabel)) {
100
- labelObject = this.props.possibleLabels.find(el => {
101
- return el.id === this.props.defaultLabel
102
- })
103
- label = labelObject.label
104
- } else {
105
- label = this.props.defaultLabel
106
- }
107
- } else {
108
- label = 'no label'
109
- }
110
- }
111
- switch (this.props.mode) {
112
- case modes.VIEW:
113
- return (<g>
114
- <rect x={this.state.left} y={this.state.top - 6}
115
- width={this.state.width} height={this.state.height} rx="5"
116
- opacity='0.5'
117
- style={this.props.style}
118
- />
119
- <text x={this.state.left} y={this.state.top}
120
- fill="white"
121
- onClick={e => this.handleClick(e)}
122
- textAnchor="start"
123
- alignmentBaseline="central"
124
- ref={this.textRef}
125
- fontSize={this.state.fontSize + "pt"}
126
- // textLength="50"
127
- // style={{...this.props.style, strokeWidth:1}}
128
- >
129
- {label}
130
- </text>
131
- {/* This second rect is to prevent text from getting marked */}
132
- <rect x={this.state.left} y={this.state.top - 6}
133
- width={this.state.width}
134
- height={this.state.height} rx="5"
135
- opacity='0.01'
136
- style={this.props.style}
137
- />
138
- </g>
139
- )
140
- default:
141
- return null
103
+ label = this.props.defaultLabel;
142
104
  }
143
-
105
+ } else {
106
+ label = "no label";
107
+ }
144
108
  }
145
-
109
+ switch (this.props.mode) {
110
+ case modes.VIEW:
111
+ return (
112
+ <g>
113
+ <rect
114
+ x={this.state.left}
115
+ y={this.state.top - 6}
116
+ width={this.state.width}
117
+ height={this.state.height}
118
+ rx="5"
119
+ opacity="0.5"
120
+ style={this.props.style}
121
+ />
122
+ <text
123
+ x={this.state.left}
124
+ y={this.state.top}
125
+ fill="white"
126
+ onClick={(e) => this.handleClick(e)}
127
+ textAnchor="start"
128
+ alignmentBaseline="central"
129
+ ref={this.textRef}
130
+ fontSize={this.state.fontSize + "pt"}
131
+ // textLength="50"
132
+ // style={{...this.props.style, strokeWidth:1}}
133
+ >
134
+ {label}
135
+ </text>
136
+ {/* This second rect is to prevent text from getting marked */}
137
+ <rect
138
+ x={this.state.left}
139
+ y={this.state.top - 6}
140
+ width={this.state.width}
141
+ height={this.state.height}
142
+ rx="5"
143
+ opacity="0.01"
144
+ style={this.props.style}
145
+ />
146
+ </g>
147
+ );
148
+ default:
149
+ return null;
150
+ }
151
+ }
146
152
  }
147
153
 
148
- export default AnnoBar
154
+ export default AnnoBar;