lost-sia 2.0.0-alpha0 → 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 -1720
  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 +272 -285
  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 -11
  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/scss/style-wrapper.scss +4 -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,278 +1,282 @@
1
- import React, { Component } from 'react'
2
- import './Annotation.scss'
3
- import * as modes from '../types/modes'
4
- import * as cursorstyles from '../types/cursorstyles'
5
-
1
+ import React, { Component } from "react";
2
+ import "./Annotation.scss";
3
+ import * as modes from "../types/modes";
4
+ import * as cursorstyles from "../types/cursorstyles";
6
5
 
7
6
  class Node extends Component {
7
+ /*************
8
+ * LIFECYCLE *
9
+ **************/
10
+ constructor(props) {
11
+ super(props);
12
+ this.state = {
13
+ haloCss: "node-halo-off",
14
+ selAreaCss: "sel-area-off",
15
+ // anno: undefined,
16
+ nodeSelected: false,
17
+ style: {},
18
+ };
19
+ }
20
+
21
+ componentDidMount() {
22
+ this.setState({
23
+ // anno: this.props.anno,
24
+ style: {
25
+ ...this.props.style,
26
+ cursor: this.getCursorStyle(this.props.mode),
27
+ },
28
+ });
29
+ // switch (this.props.mode){
30
+ // case modes.CREATE:
31
+ // if (this.props.idx !== 0){
32
+ // this.turnSelAreaOn()
33
+ // }
34
+ // default:
35
+ // break
36
+ // }
37
+ }
8
38
 
9
- /*************
10
- * LIFECYCLE *
11
- **************/
12
- constructor(props) {
13
- super(props)
14
- this.state = {
15
- haloCss: 'node-halo-off',
16
- selAreaCss: 'sel-area-off',
17
- // anno: undefined,
18
- nodeSelected: false,
19
- style: {}
39
+ componentDidUpdate(prevProps) {
40
+ switch (this.props.mode) {
41
+ case modes.CREATE:
42
+ if (this.props.idx !== 0 || this.props.isPoint) {
43
+ this.turnSelAreaOn();
20
44
  }
45
+ break;
46
+ case modes.EDIT:
47
+ this.turnSelAreaOn();
48
+ break;
49
+ default:
50
+ break;
21
51
  }
22
-
23
- componentDidMount() {
24
- this.setState({
25
- // anno: this.props.anno,
26
- style: {
27
- ...this.props.style,
28
- cursor: this.getCursorStyle(this.props.mode)
29
- }
30
- })
31
- // switch (this.props.mode){
32
- // case modes.CREATE:
33
- // if (this.props.idx !== 0){
34
- // this.turnSelAreaOn()
35
- // }
36
- // default:
37
- // break
38
- // }
52
+ //on mode change
53
+ if (prevProps.mode !== this.props.mode) {
54
+ this.setState({
55
+ style: {
56
+ ...this.state.style,
57
+ cursor: this.getCursorStyle(this.props.mode),
58
+ },
59
+ });
39
60
  }
40
-
41
- componentDidUpdate(prevProps) {
42
- switch (this.props.mode) {
43
- case modes.CREATE:
44
- if (this.props.idx !== 0 || this.props.isPoint) {
45
- this.turnSelAreaOn()
46
- }
47
- break
48
- case modes.EDIT:
49
- this.turnSelAreaOn()
50
- break
51
- default:
52
- break
53
- }
54
- //on mode change
55
- if (prevProps.mode !== this.props.mode) {
56
- this.setState({
57
- style: {
58
- ...this.state.style,
59
- cursor: this.getCursorStyle(this.props.mode)
60
- }
61
- })
62
- }
63
- if (prevProps.style !== this.props.style) {
64
- this.setState({
65
- style:
66
- {
67
- ...this.state.style,
68
- ...this.props.style,
69
- cursor: this.getCursorStyle(this.props.mode)
70
- }
71
- })
72
- }
61
+ if (prevProps.style !== this.props.style) {
62
+ this.setState({
63
+ style: {
64
+ ...this.state.style,
65
+ ...this.props.style,
66
+ cursor: this.getCursorStyle(this.props.mode),
67
+ },
68
+ });
73
69
  }
70
+ }
74
71
 
75
- /*************
76
- * EVENTS *
77
- **************/
72
+ /*************
73
+ * EVENTS *
74
+ **************/
78
75
 
79
- onClick(e) {
80
- this.turnHaloOn()
81
- if (this.props.onClick) {
82
- this.props.onClick(e, this.props.idx)
83
- }
76
+ onClick(e) {
77
+ this.turnHaloOn();
78
+ if (this.props.onClick) {
79
+ this.props.onClick(e, this.props.idx);
84
80
  }
81
+ }
85
82
 
86
- onMouseMove(e) {
87
- if (this.props.onMouseMove) {
88
- this.props.onMouseMove(e, this.props.idx)
89
- }
90
- // switch (this.props.mode){
91
- // case modes.CREATE:
92
- // let newAnno = [...this.state.anno]
93
- // const mousePos = mouse.getMousePosition(e, this.props.svg)
94
- // newAnno[this.props.idx].x = mousePos.x
95
- // newAnno[this.props.idx].y = mousePos.y
96
- // this.setState({
97
- // anno: newAnno
98
- // })
99
- // if (this.props.onAnnoUpdate){
100
- // this.props.onAnnoUpdate(e, this.props.idx, newAnno)
101
- // }
102
- // default:
103
- // break
104
- // }
83
+ onMouseMove(e) {
84
+ if (this.props.onMouseMove) {
85
+ this.props.onMouseMove(e, this.props.idx);
105
86
  }
87
+ // switch (this.props.mode){
88
+ // case modes.CREATE:
89
+ // let newAnno = [...this.state.anno]
90
+ // const mousePos = mouse.getMousePosition(e, this.props.svg)
91
+ // newAnno[this.props.idx].x = mousePos.x
92
+ // newAnno[this.props.idx].y = mousePos.y
93
+ // this.setState({
94
+ // anno: newAnno
95
+ // })
96
+ // if (this.props.onAnnoUpdate){
97
+ // this.props.onAnnoUpdate(e, this.props.idx, newAnno)
98
+ // }
99
+ // default:
100
+ // break
101
+ // }
102
+ }
106
103
 
107
- onContextMenu(e) {
108
- e.preventDefault()
109
- }
104
+ onContextMenu(e) {
105
+ e.preventDefault();
106
+ }
110
107
 
111
- onMouseUp(e) {
112
- switch (this.props.mode) {
113
- case modes.EDIT:
114
- switch (e.button) {
115
- case 0:
116
- this.turnSelAreaOff()
117
- break
118
- default:
119
- break
120
- }
121
- break
122
- default:
123
- break
124
- }
125
- if (this.props.onMouseUp) {
126
- this.props.onMouseUp(e, this.props.idx)
108
+ onMouseUp(e) {
109
+ switch (this.props.mode) {
110
+ case modes.EDIT:
111
+ switch (e.button) {
112
+ case 0:
113
+ this.turnSelAreaOff();
114
+ break;
115
+ default:
116
+ break;
127
117
  }
118
+ break;
119
+ default:
120
+ break;
128
121
  }
129
-
130
- onMouseDown(e) {
131
- e.stopPropagation()
132
- if (this.props.onMouseDown) {
133
- this.props.onMouseDown(e, this.props.idx)
134
- }
135
- switch (this.props.mode) {
136
- case modes.CREATE:
137
- switch (e.button) {
138
- case 0:
139
- this.turnSelAreaOff()
140
- break
141
- case 2:
142
- this.turnSelAreaOff()
143
- break
144
- default:
145
- break
146
- }
147
- // case modes.EDIT:
148
- // switch (e.button){
149
- // case 0:
150
- // this.turnSelAreaOn()
151
- // break
152
- // default:
153
- // break
154
- // }
155
- break
156
- default:
157
- break
158
- }
122
+ if (this.props.onMouseUp) {
123
+ this.props.onMouseUp(e, this.props.idx);
159
124
  }
125
+ }
160
126
 
161
- onMouseOver(e) {
162
- if (this.props.isSelected) {
163
- this.turnHaloOn()
164
- }
127
+ onMouseDown(e) {
128
+ e.stopPropagation();
129
+ if (this.props.onMouseDown) {
130
+ this.props.onMouseDown(e, this.props.idx);
165
131
  }
166
-
167
- onMouseLeave(e) {
168
- if (this.props.isSelected) {
169
- this.turnHaloOff()
132
+ switch (this.props.mode) {
133
+ case modes.CREATE:
134
+ switch (e.button) {
135
+ case 0:
136
+ this.turnSelAreaOff();
137
+ break;
138
+ case 2:
139
+ this.turnSelAreaOff();
140
+ break;
141
+ default:
142
+ break;
170
143
  }
144
+ // case modes.EDIT:
145
+ // switch (e.button){
146
+ // case 0:
147
+ // this.turnSelAreaOn()
148
+ // break
149
+ // default:
150
+ // break
151
+ // }
152
+ break;
153
+ default:
154
+ break;
171
155
  }
156
+ }
172
157
 
173
- onDoubleClick(e) {
174
- if (this.props.onDoubleClick) {
175
- this.props.onDoubleClick(e, this.props.idx)
176
- }
158
+ onMouseOver(e) {
159
+ if (this.props.isSelected) {
160
+ this.turnHaloOn();
177
161
  }
162
+ }
178
163
 
179
- handleMouseLeave(e) {
180
- if (this.props.onMouseLeave) {
181
- this.props.onMouseLeave(e, this.props.idx)
182
- }
164
+ onMouseLeave(e) {
165
+ if (this.props.isSelected) {
166
+ this.turnHaloOff();
183
167
  }
168
+ }
184
169
 
185
-
186
- /*************
187
- * LOGIC *
188
- **************/
189
- getCursorStyle(mode) {
190
- switch (mode) {
191
- case modes.CREATE:
192
- return cursorstyles.CREATE_NODE
193
- case modes.EDIT:
194
- return cursorstyles.EDIT_NODE
195
- case modes.VIEW:
196
- return cursorstyles.NORMAL_NODE
197
- default:
198
- break
199
- }
170
+ onDoubleClick(e) {
171
+ if (this.props.onDoubleClick) {
172
+ this.props.onDoubleClick(e, this.props.idx);
200
173
  }
174
+ }
201
175
 
202
- turnSelAreaOn() {
203
- if (this.state.selAreaCss !== 'sel-area-on') {
204
- this.setState({
205
- selAreaCss: 'sel-area-on'
206
- })
207
- }
176
+ handleMouseLeave(e) {
177
+ if (this.props.onMouseLeave) {
178
+ this.props.onMouseLeave(e, this.props.idx);
208
179
  }
180
+ }
209
181
 
210
- turnSelAreaOff() {
211
- if (this.state.selAreaCss !== 'sel-area-off') {
212
- this.setState({
213
- selAreaCss: 'sel-area-off'
214
- })
215
- }
182
+ /*************
183
+ * LOGIC *
184
+ **************/
185
+ getCursorStyle(mode) {
186
+ switch (mode) {
187
+ case modes.CREATE:
188
+ return cursorstyles.CREATE_NODE;
189
+ case modes.EDIT:
190
+ return cursorstyles.EDIT_NODE;
191
+ case modes.VIEW:
192
+ return cursorstyles.NORMAL_NODE;
193
+ default:
194
+ break;
216
195
  }
196
+ }
217
197
 
218
- turnHaloOn() {
219
- this.setState({
220
- haloCss: 'node-halo-on'
221
- })
198
+ turnSelAreaOn() {
199
+ if (this.state.selAreaCss !== "sel-area-on") {
200
+ this.setState({
201
+ selAreaCss: "sel-area-on",
202
+ });
222
203
  }
204
+ }
223
205
 
224
- turnHaloOff() {
225
- this.setState({
226
- haloCss: 'node-halo-off'
227
- })
206
+ turnSelAreaOff() {
207
+ if (this.state.selAreaCss !== "sel-area-off") {
208
+ this.setState({
209
+ selAreaCss: "sel-area-off",
210
+ });
228
211
  }
212
+ }
229
213
 
230
- /*************
231
- * RENDERING *
232
- **************/
233
- renderHalo() {
234
- if (this.state.haloCss === 'node-halo-off') return null
235
- const data = this.props.anno[this.props.idx]
214
+ turnHaloOn() {
215
+ this.setState({
216
+ haloCss: "node-halo-on",
217
+ });
218
+ }
236
219
 
237
- return <circle cx={data.x} cy={data.y} r={this.props.style.r * 3}
238
- className={this.state.haloCss}
239
- onMouseLeave={e => this.onMouseLeave(e)}
240
- />
241
- }
242
- renderNodes() {
243
- const data = this.props.anno[this.props.idx]
244
- if (data === undefined) { return }
245
- return (
246
- <g
247
- onClick={(e) => this.onClick(e)}
248
- onMouseMove={e => this.onMouseMove(e)}
249
- onContextMenu={e => this.onContextMenu(e)}
250
- onMouseUp={e => this.onMouseUp(e)}
251
- onMouseDown={e => this.onMouseDown(e)}
252
- onDoubleClick={e => this.onDoubleClick(e)}
253
- onMouseLeave={e => this.handleMouseLeave(e)}
254
- >
255
- <circle cx={data.x} cy={data.y} r={'100%'}
256
- className={this.state.selAreaCss}
257
- />
258
- {this.renderHalo()}
259
- <circle cx={data.x}
260
- cy={data.y}
261
- r={3} fill="red"
262
- style={this.state.style}
263
- className={this.props.className}
264
- onMouseOver={e => this.onMouseOver(e)}
265
- />
266
- </g>
267
- )
268
- }
269
- render() {
270
- return (
271
- <g>
272
- {this.renderNodes()}
273
- </g>
274
- )
220
+ turnHaloOff() {
221
+ this.setState({
222
+ haloCss: "node-halo-off",
223
+ });
224
+ }
225
+
226
+ /*************
227
+ * RENDERING *
228
+ **************/
229
+ renderHalo() {
230
+ if (this.state.haloCss === "node-halo-off") return null;
231
+ const data = this.props.anno[this.props.idx];
232
+
233
+ return (
234
+ <circle
235
+ cx={data.x}
236
+ cy={data.y}
237
+ r={this.props.style.r * 3}
238
+ className={this.state.haloCss}
239
+ onMouseLeave={(e) => this.onMouseLeave(e)}
240
+ />
241
+ );
242
+ }
243
+ renderNodes() {
244
+ const data = this.props.anno[this.props.idx];
245
+ if (data === undefined) {
246
+ return;
275
247
  }
248
+ return (
249
+ <g
250
+ onClick={(e) => this.onClick(e)}
251
+ onMouseMove={(e) => this.onMouseMove(e)}
252
+ onContextMenu={(e) => this.onContextMenu(e)}
253
+ onMouseUp={(e) => this.onMouseUp(e)}
254
+ onMouseDown={(e) => this.onMouseDown(e)}
255
+ onDoubleClick={(e) => this.onDoubleClick(e)}
256
+ onMouseLeave={(e) => this.handleMouseLeave(e)}
257
+ >
258
+ <circle
259
+ cx={data.x}
260
+ cy={data.y}
261
+ r={"100%"}
262
+ className={this.state.selAreaCss}
263
+ />
264
+ {this.renderHalo()}
265
+ <circle
266
+ cx={data.x}
267
+ cy={data.y}
268
+ r={3}
269
+ fill="red"
270
+ style={this.state.style}
271
+ className={this.props.className}
272
+ onMouseOver={(e) => this.onMouseOver(e)}
273
+ />
274
+ </g>
275
+ );
276
+ }
277
+ render() {
278
+ return <g>{this.renderNodes()}</g>;
279
+ }
276
280
  }
277
281
 
278
- export default Node;
282
+ export default Node;