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,196 +1,200 @@
1
- import React, {Component} from 'react'
2
- import InfSelectionArea from './InfSelectionArea'
3
- import Node from './Node'
4
- import * as modes from '../types/modes'
5
- import * as transform from '../utils/transform'
6
- import * as canvasActions from '../types/canvasActions'
7
-
8
- class Point extends Component{
9
-
10
- /*************
11
- * LIFECYCLE *
12
- **************/
13
- constructor(props){
14
- super(props)
15
- this.state = {
16
- anno: undefined,
17
- }
18
- }
1
+ import React, { Component } from "react";
2
+ import InfSelectionArea from "./InfSelectionArea";
3
+ import Node from "./Node";
4
+ import * as modes from "../types/modes";
5
+ import * as transform from "../utils/transform";
6
+ import * as canvasActions from "../types/canvasActions";
19
7
 
20
- componentDidMount(prevProps){
21
- if (this.props.anno.mode === modes.CREATE){
22
- const data = this.props.anno.data[0]
23
- const newAnno = {
24
- ...this.props.anno,
25
- data: [
26
- {x: data.x, y: data.y}
27
- ],
28
- selectedNode: 0
29
- }
30
- this.setState({
31
- anno: newAnno
32
- })
33
- } else {
34
- this.setState({anno: {...this.props.anno}})
35
- }
36
- }
8
+ class Point extends Component {
9
+ /*************
10
+ * LIFECYCLE *
11
+ **************/
12
+ constructor(props) {
13
+ super(props);
14
+ this.state = {
15
+ anno: undefined,
16
+ };
17
+ }
37
18
 
38
- componentDidUpdate(prevProps){
39
- if (prevProps.anno !== this.props.anno){
40
- this.setState({anno: {...this.props.anno}})
41
- }
19
+ componentDidMount(prevProps) {
20
+ if (this.props.anno.mode === modes.CREATE) {
21
+ const data = this.props.anno.data[0];
22
+ const newAnno = {
23
+ ...this.props.anno,
24
+ data: [{ x: data.x, y: data.y }],
25
+ selectedNode: 0,
26
+ };
27
+ this.setState({
28
+ anno: newAnno,
29
+ });
30
+ } else {
31
+ this.setState({ anno: { ...this.props.anno } });
42
32
  }
43
-
44
- /**************
45
- * ANNO EVENTS *
46
- ***************/
47
- onMouseMove(e){
48
- switch (this.state.anno.mode){
49
- case modes.MOVE:
50
- this.move(
51
- e.movementX/this.props.svg.scale,
52
- e.movementY/this.props.svg.scale
53
- )
54
- break
55
- default:
56
- break
57
- }
33
+ }
34
+
35
+ componentDidUpdate(prevProps) {
36
+ if (prevProps.anno !== this.props.anno) {
37
+ this.setState({ anno: { ...this.props.anno } });
58
38
  }
39
+ }
59
40
 
60
- onMouseUp(e){
61
- switch (this.state.anno.mode){
62
- case modes.MOVE:
63
- if (e.button === 0){
64
- this.requestModeChange(this.state.anno, modes.VIEW)
65
- this.performedAction(this.state.anno, canvasActions.ANNO_MOVED)
66
- }
67
- break
68
- case modes.CREATE:
69
- this.requestModeChange(this.state.anno, modes.VIEW)
70
-
71
- this.performedAction(this.state.anno, canvasActions.ANNO_CREATED)
72
- break
73
- default:
74
- break
75
- }
41
+ /**************
42
+ * ANNO EVENTS *
43
+ ***************/
44
+ onMouseMove(e) {
45
+ switch (this.state.anno.mode) {
46
+ case modes.MOVE:
47
+ this.move(
48
+ e.movementX / this.props.svg.scale,
49
+ e.movementY / this.props.svg.scale,
50
+ );
51
+ break;
52
+ default:
53
+ break;
76
54
  }
55
+ }
77
56
 
78
- onNodeMouseDown(e, idx){
79
- switch (this.state.anno.mode){
80
- case modes.VIEW:
81
- if (e.button === 0){
82
- if (this.props.isSelected){
83
- this.requestModeChange(this.state.anno, modes.MOVE)
84
- }
85
- }
86
- break
87
- default:
88
- break
57
+ onMouseUp(e) {
58
+ switch (this.state.anno.mode) {
59
+ case modes.MOVE:
60
+ if (e.button === 0) {
61
+ this.requestModeChange(this.state.anno, modes.VIEW);
62
+ this.performedAction(this.state.anno, canvasActions.ANNO_MOVED);
89
63
  }
90
- }
64
+ break;
65
+ case modes.CREATE:
66
+ this.requestModeChange(this.state.anno, modes.VIEW);
91
67
 
92
- /*************
93
- * LOGIC *
94
- **************/
95
- getResult(){
96
- return this.state.anno
68
+ this.performedAction(this.state.anno, canvasActions.ANNO_CREATED);
69
+ break;
70
+ default:
71
+ break;
97
72
  }
98
-
99
- performedAction(anno, pAction){
100
- if (this.props.onAction){
101
- this.props.onAction(anno, pAction)
73
+ }
74
+
75
+ onNodeMouseDown(e, idx) {
76
+ switch (this.state.anno.mode) {
77
+ case modes.VIEW:
78
+ if (e.button === 0) {
79
+ if (this.props.isSelected) {
80
+ this.requestModeChange(this.state.anno, modes.MOVE);
81
+ }
102
82
  }
83
+ break;
84
+ default:
85
+ break;
103
86
  }
87
+ }
104
88
 
105
- requestModeChange(anno, mode){
106
- this.props.onModeChangeRequest(anno, mode)
107
- }
89
+ /*************
90
+ * LOGIC *
91
+ **************/
92
+ getResult() {
93
+ return this.state.anno;
94
+ }
108
95
 
109
- move(movementX, movementY){
110
- this.setState({
111
- anno : {
112
- ...this.state.anno,
113
- data: transform.move(this.state.anno.data, movementX, movementY)
114
- }
115
- })
96
+ performedAction(anno, pAction) {
97
+ if (this.props.onAction) {
98
+ this.props.onAction(anno, pAction);
116
99
  }
100
+ }
117
101
 
118
- renderInfSelectionArea(){
119
- switch (this.state.anno.mode){
120
- case modes.MOVE:
121
- return <InfSelectionArea enable={true}
122
- svg={this.props.svg}
123
- />
124
- default:
125
- return null
126
- }
127
- }
102
+ requestModeChange(anno, mode) {
103
+ this.props.onModeChangeRequest(anno, mode);
104
+ }
128
105
 
129
- renderNode(){
130
- if (!this.props.isSelected) return null
131
- switch(this.state.anno.mode){
132
- case modes.EDIT_LABEL:
133
- case modes.MOVE:
134
- return null
135
- case modes.EDIT:
136
- case modes.CREATE:
137
- return <Node anno={this.state.anno.data}
138
- key={this.state.selectedNode}
139
- idx={this.state.anno.selectedNode}
140
- style={this.props.style}
141
- className={this.props.className}
142
- isSelected={this.props.isSelected}
143
- mode={this.state.anno.mode}
144
- svg={this.props.svg}
145
- onMouseDown={(e, idx) => this.onNodeMouseDown(e,idx)}
146
- isPoint={true}
147
- />
148
- default:
149
- return this.state.anno.data.map((e, idx) => {
150
- return <Node anno={this.state.anno.data} idx={idx}
151
- key={idx} style={this.props.style}
152
- className={this.props.className}
153
- isSelected={this.props.isSelected}
154
- mode={this.state.anno.mode}
155
- svg={this.props.svg}
156
- onMouseDown={(e, idx) => this.onNodeMouseDown(e,idx)}
157
- isPoint={true}
158
- />
159
- })
160
- }
106
+ move(movementX, movementY) {
107
+ this.setState({
108
+ anno: {
109
+ ...this.state.anno,
110
+ data: transform.move(this.state.anno.data, movementX, movementY),
111
+ },
112
+ });
113
+ }
114
+
115
+ renderInfSelectionArea() {
116
+ switch (this.state.anno.mode) {
117
+ case modes.MOVE:
118
+ return <InfSelectionArea enable={true} svg={this.props.svg} />;
119
+ default:
120
+ return null;
161
121
  }
122
+ }
162
123
 
163
- renderPoint(){
124
+ renderNode() {
125
+ if (!this.props.isSelected) return null;
126
+ switch (this.state.anno.mode) {
127
+ case modes.EDIT_LABEL:
128
+ case modes.MOVE:
129
+ return null;
130
+ case modes.EDIT:
131
+ case modes.CREATE:
132
+ return (
133
+ <Node
134
+ anno={this.state.anno.data}
135
+ key={this.state.selectedNode}
136
+ idx={this.state.anno.selectedNode}
137
+ style={this.props.style}
138
+ className={this.props.className}
139
+ isSelected={this.props.isSelected}
140
+ mode={this.state.anno.mode}
141
+ svg={this.props.svg}
142
+ onMouseDown={(e, idx) => this.onNodeMouseDown(e, idx)}
143
+ isPoint={true}
144
+ />
145
+ );
146
+ default:
164
147
  return this.state.anno.data.map((e, idx) => {
165
- return (
166
- <circle key={idx}
167
- cx={e.x}
168
- cy={e.y}
169
- r={10} fill="red"
170
- style={this.props.style}
171
- className={this.props.className}
172
- />
173
- )
174
- })
175
-
148
+ return (
149
+ <Node
150
+ anno={this.state.anno.data}
151
+ idx={idx}
152
+ key={idx}
153
+ style={this.props.style}
154
+ className={this.props.className}
155
+ isSelected={this.props.isSelected}
156
+ mode={this.state.anno.mode}
157
+ svg={this.props.svg}
158
+ onMouseDown={(e, idx) => this.onNodeMouseDown(e, idx)}
159
+ isPoint={true}
160
+ />
161
+ );
162
+ });
176
163
  }
164
+ }
177
165
 
178
- render(){
179
- if (this.state.anno){
180
- return(
181
- <g
182
- onMouseMove={e => this.onMouseMove(e)}
183
- onMouseUp={e => this.onMouseUp(e)}
184
- >
185
- {this.renderPoint()}
186
- {this.renderNode()}
187
- {this.renderInfSelectionArea()}
188
- </g>
189
- )
190
- } else {
191
- return null
192
- }
166
+ renderPoint() {
167
+ return this.state.anno.data.map((e, idx) => {
168
+ return (
169
+ <circle
170
+ key={idx}
171
+ cx={e.x}
172
+ cy={e.y}
173
+ r={10}
174
+ fill="red"
175
+ style={this.props.style}
176
+ className={this.props.className}
177
+ />
178
+ );
179
+ });
180
+ }
181
+
182
+ render() {
183
+ if (this.state.anno) {
184
+ return (
185
+ <g
186
+ onMouseMove={(e) => this.onMouseMove(e)}
187
+ onMouseUp={(e) => this.onMouseUp(e)}
188
+ >
189
+ {this.renderPoint()}
190
+ {this.renderNode()}
191
+ {this.renderInfSelectionArea()}
192
+ </g>
193
+ );
194
+ } else {
195
+ return null;
193
196
  }
197
+ }
194
198
  }
195
199
 
196
- export default Point;
200
+ export default Point;