lost-sia 2.0.1-alpha8 → 3.0.0

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 (280) hide show
  1. package/README.md +4 -0
  2. package/dist/Annotation/logic/Annotation.d.ts +17 -0
  3. package/dist/Annotation/logic/Annotation.js +1 -0
  4. package/dist/Annotation/ui/AnnotationComponent.d.ts +24 -0
  5. package/dist/Annotation/ui/AnnotationComponent.js +1 -0
  6. package/dist/Annotation/ui/atoms/AnnoBar.d.ts +15 -0
  7. package/dist/Annotation/ui/atoms/AnnoBar.js +1 -0
  8. package/dist/Annotation/ui/atoms/DaviIcon.d.ts +9 -0
  9. package/dist/Annotation/ui/atoms/DaviIcon.js +19 -0
  10. package/dist/Annotation/ui/atoms/Edge.d.ts +17 -0
  11. package/dist/Annotation/ui/atoms/Edge.js +1 -0
  12. package/dist/Annotation/ui/atoms/Node.d.ts +17 -0
  13. package/dist/Annotation/ui/atoms/Node.js +1 -0
  14. package/dist/Annotation/ui/atoms/PolygonArea.d.ts +16 -0
  15. package/dist/Annotation/ui/atoms/PolygonArea.js +1 -0
  16. package/dist/Annotation/ui/tools/BBox.d.ts +21 -0
  17. package/dist/Annotation/ui/tools/BBox.js +1 -0
  18. package/dist/Annotation/ui/tools/Line.d.ts +21 -0
  19. package/dist/Annotation/ui/tools/Line.js +1 -0
  20. package/dist/Annotation/ui/tools/Point.d.ts +16 -0
  21. package/dist/Annotation/ui/tools/Point.js +1 -0
  22. package/dist/Annotation/ui/tools/Polygon.d.ts +23 -0
  23. package/dist/Annotation/ui/tools/Polygon.js +1 -0
  24. package/dist/Canvas/Canvas.d.ts +31 -0
  25. package/dist/Canvas/Canvas.js +1 -0
  26. package/dist/Canvas/LabelInput.d.ts +11 -0
  27. package/dist/Canvas/LabelInput.js +1 -0
  28. package/dist/IconButton.d.ts +25 -0
  29. package/dist/IconButton.js +1 -0
  30. package/dist/Sia.d.ts +33 -0
  31. package/dist/Sia.js +1 -0
  32. package/dist/Toolbar/Toolbar.d.ts +21 -0
  33. package/dist/Toolbar/Toolbar.js +1 -0
  34. package/dist/Toolbar/ToolbarItems/AccessibilityTools.d.ts +7 -0
  35. package/dist/Toolbar/ToolbarItems/AccessibilityTools.js +1 -0
  36. package/dist/Toolbar/ToolbarItems/AnnoToolSelector.d.ts +11 -0
  37. package/dist/Toolbar/ToolbarItems/AnnoToolSelector.js +1 -0
  38. package/dist/Toolbar/ToolbarItems/ImageToolItems/ImageLabelInput.d.ts +11 -0
  39. package/dist/Toolbar/ToolbarItems/ImageToolItems/ImageLabelInput.js +1 -0
  40. package/dist/Toolbar/ToolbarItems/ImageToolItems/TagLabel.d.ts +11 -0
  41. package/dist/Toolbar/ToolbarItems/ImageToolItems/TagLabel.js +1 -0
  42. package/dist/Toolbar/ToolbarItems/ImageTools.d.ts +13 -0
  43. package/dist/Toolbar/ToolbarItems/ImageTools.js +1 -0
  44. package/dist/Toolbar/ToolbarItems/Instructions.d.ts +2 -0
  45. package/dist/Toolbar/ToolbarItems/Instructions.js +1 -0
  46. package/dist/Toolbar/ToolbarItems/InstructionsModal.d.ts +6 -0
  47. package/dist/Toolbar/ToolbarItems/InstructionsModal.js +1 -0
  48. package/dist/assets/SIA-BV1tYu3P.css +1 -0
  49. package/dist/assets/brand-icons-Cu_C0hZ4.svg +1008 -0
  50. package/dist/assets/brand-icons-F3SPCeH1.woff +0 -0
  51. package/dist/assets/brand-icons-XL9sxUpA.woff2 +0 -0
  52. package/dist/assets/brand-icons-sqJ2Pg7a.eot +0 -0
  53. package/dist/assets/brand-icons-ubhWoxly.ttf +0 -0
  54. package/dist/assets/flags-DOLqOU7Y.png +0 -0
  55. package/dist/assets/icons-BOCtAERH.woff +0 -0
  56. package/dist/assets/icons-CHzK1VD9.eot +0 -0
  57. package/dist/assets/icons-D29ZQHHw.ttf +0 -0
  58. package/dist/assets/icons-Du6TOHnR.woff2 +0 -0
  59. package/dist/assets/icons-RwhydX30.svg +1518 -0
  60. package/dist/assets/node_modules/semantic-ui-css/semantic.min-Bvulf91l.css +346 -0
  61. package/dist/assets/outline-icons-BfdLr8tr.svg +366 -0
  62. package/dist/assets/outline-icons-DD8jm0uy.ttf +0 -0
  63. package/dist/assets/outline-icons-DInHoiqI.woff2 +0 -0
  64. package/dist/assets/outline-icons-LX8adJ4n.eot +0 -0
  65. package/dist/assets/outline-icons-aQ88nltS.woff +0 -0
  66. package/dist/index.d.ts +5 -0
  67. package/dist/index.js +1 -0
  68. package/dist/models/AnnotationMode.d.ts +11 -0
  69. package/dist/models/AnnotationMode.js +1 -0
  70. package/dist/models/AnnotationStatus.d.ts +8 -0
  71. package/dist/models/AnnotationStatus.js +1 -0
  72. package/dist/models/AnnotationTool.d.ts +7 -0
  73. package/dist/models/AnnotationTool.js +1 -0
  74. package/dist/models/CanvasAction.d.ts +28 -0
  75. package/dist/models/CanvasAction.js +1 -0
  76. package/dist/models/Direction.d.ts +7 -0
  77. package/dist/models/Direction.js +1 -0
  78. package/dist/models/EditorModes.d.ts +11 -0
  79. package/dist/models/EditorModes.js +1 -0
  80. package/dist/models/KeyAction.d.ts +22 -0
  81. package/dist/models/KeyAction.js +1 -0
  82. package/dist/models/NotificationType.d.ts +7 -0
  83. package/dist/models/NotificationType.js +1 -0
  84. package/dist/models/index.d.ts +6 -0
  85. package/dist/models/index.js +1 -0
  86. package/dist/stories/AnnotationTools.stories.d.ts +40 -0
  87. package/dist/stories/Canvas/Canvas.stories.d.ts +50 -0
  88. package/dist/stories/Canvas/CanvasOffset.d.ts +13 -0
  89. package/dist/stories/Canvas/CanvasWithOffset.stories.d.ts +36 -0
  90. package/dist/stories/FilterDropdown.stories.d.ts +19 -0
  91. package/dist/stories/MinimalSia.stories.d.ts +66 -0
  92. package/dist/stories/SIA/DemoWrapper.d.ts +8 -0
  93. package/dist/stories/SIA/DemoWrapper.stories.d.ts +27 -0
  94. package/dist/stories/SIA/SIA.stories.d.ts +72 -0
  95. package/dist/stories/Toolbar/ImageTools/TagLabel.stories.d.ts +21 -0
  96. package/dist/stories/Toolbar/Instructions.stories.d.ts +11 -0
  97. package/dist/stories/Toolbar/Toolbar.stories.d.ts +37 -0
  98. package/dist/stories/exampleData/exampleAnnotations.d.ts +8 -0
  99. package/dist/stories/exampleData/exampleExternalAnnotations.d.ts +8 -0
  100. package/dist/stories/exampleData/exampleImage.d.ts +2 -0
  101. package/dist/stories/exampleData/exampleLabels.d.ts +6 -0
  102. package/dist/types.d.ts +57 -0
  103. package/dist/types.js +1 -0
  104. package/dist/utils/KeyMapper.d.ts +9 -0
  105. package/dist/utils/KeyMapper.js +1 -0
  106. package/dist/utils/TimeUtils.d.ts +4 -0
  107. package/dist/utils/TimeUtils.js +1 -0
  108. package/dist/utils/color.d.ts +2 -0
  109. package/dist/utils/color.js +1 -0
  110. package/dist/utils/index.d.ts +2 -0
  111. package/dist/utils/index.js +1 -0
  112. package/dist/utils/mouse.d.ts +6 -0
  113. package/dist/utils/mouse.js +1 -0
  114. package/dist/utils/siaIcons.js +12 -0
  115. package/dist/utils/transform.d.ts +28 -0
  116. package/dist/utils/transform.js +1 -0
  117. package/dist/utils/uiConfig.js +1 -0
  118. package/dist/utils/windowViewport.d.ts +22 -0
  119. package/dist/utils/windowViewport.js +1 -0
  120. package/package.json +19 -16
  121. package/src/AnnoExampleViewer.jsx +18 -18
  122. package/src/Annotation/logic/Annotation.ts +24 -26
  123. package/src/Annotation/ui/AnnotationComponent.tsx +115 -86
  124. package/src/Annotation/ui/atoms/AnnoBar.tsx +51 -53
  125. package/src/Annotation/ui/atoms/DaviIcon.tsx +12 -22
  126. package/src/Annotation/ui/atoms/Edge.tsx +25 -22
  127. package/src/Annotation/ui/atoms/Node.tsx +56 -50
  128. package/src/Annotation/ui/atoms/PolygonArea.tsx +30 -35
  129. package/src/Annotation/ui/tools/BBox.tsx +136 -150
  130. package/src/Annotation/ui/tools/Line.tsx +94 -91
  131. package/src/Annotation/ui/tools/Point.tsx +19 -17
  132. package/src/Annotation/ui/tools/Polygon.tsx +126 -95
  133. package/src/Canvas/Canvas.tsx +748 -594
  134. package/src/Canvas/LabelInput.tsx +68 -45
  135. package/src/IconButton.tsx +119 -0
  136. package/src/InfoBoxes/AnnoDetails.jsx +53 -53
  137. package/src/InfoBoxes/AnnoStats.jsx +41 -41
  138. package/src/InfoBoxes/InfoBox.jsx +16 -16
  139. package/src/InfoBoxes/InfoBoxArea.jsx +32 -34
  140. package/src/InfoBoxes/LabelInfo.jsx +30 -30
  141. package/src/SIASettingButton.jsx +25 -25
  142. package/src/Sia.tsx +484 -0
  143. package/src/Toolbar/Toolbar.tsx +38 -31
  144. package/src/Toolbar/ToolbarItems/AccessibilityTools.tsx +26 -46
  145. package/src/Toolbar/ToolbarItems/AnnoToolSelector.tsx +53 -46
  146. package/src/Toolbar/ToolbarItems/ImageToolItems/ImageLabelInput.tsx +127 -0
  147. package/src/Toolbar/ToolbarItems/ImageToolItems/TagLabel.tsx +29 -28
  148. package/src/Toolbar/ToolbarItems/ImageTools.tsx +43 -40
  149. package/src/Toolbar/ToolbarItems/Instructions.tsx +47 -50
  150. package/src/Toolbar/ToolbarItems/InstructionsModal.tsx +8 -8
  151. package/src/index.ts +9 -13
  152. package/src/models/{AnnotationMode.tsx → AnnotationMode.ts} +1 -1
  153. package/src/models/{AnnotationStatus.tsx → AnnotationStatus.ts} +1 -1
  154. package/src/models/{AnnotationTool.tsx → AnnotationTool.ts} +1 -1
  155. package/src/models/{CanvasAction.tsx → CanvasAction.ts} +1 -1
  156. package/src/models/{Direction.tsx → Direction.ts} +1 -1
  157. package/src/models/{EditorModes.tsx → EditorModes.ts} +1 -1
  158. package/src/models/{KeyAction.tsx → KeyAction.ts} +3 -1
  159. package/src/models/NotificationType.ts +8 -0
  160. package/src/models/index.ts +6 -7
  161. package/src/siaDummyData.js +71 -71
  162. package/src/stories/AnnotationTools.mdx +27 -0
  163. package/src/stories/AnnotationTools.stories.tsx +104 -0
  164. package/src/stories/Canvas/Canvas.stories.tsx +59 -113
  165. package/src/stories/Canvas/CanvasOffset.tsx +54 -38
  166. package/src/stories/Canvas/CanvasWithOffset.stories.tsx +42 -113
  167. package/src/stories/FilterDropdown.stories.ts +13 -11
  168. package/src/stories/MinimalSIA.mdx +20 -0
  169. package/src/stories/MinimalSia.stories.tsx +90 -0
  170. package/src/stories/SIA/DemoWrapper.stories.tsx +71 -0
  171. package/src/stories/SIA/DemoWrapper.tsx +55 -0
  172. package/src/stories/SIA/SIA.stories.tsx +79 -45
  173. package/src/stories/Toolbar/ImageTools/TagLabel.stories.tsx +11 -12
  174. package/src/stories/Toolbar/Instructions.stories.tsx +11 -11
  175. package/src/stories/Toolbar/Toolbar.stories.tsx +32 -47
  176. package/src/stories/Welcome.mdx +5 -0
  177. package/src/stories/development/CoordinateSystems.mdx +25 -0
  178. package/src/stories/exampleData/exampleAnnotations.ts +65 -0
  179. package/src/stories/exampleData/exampleExternalAnnotations.ts +115 -0
  180. package/src/stories/{siaDummyData2.ts → exampleData/exampleImage.ts} +3 -264
  181. package/src/stories/exampleData/exampleLabels.ts +146 -0
  182. package/src/stories/main.scss +6 -0
  183. package/src/styles/style.scss +1 -26
  184. package/src/types.ts +67 -0
  185. package/src/utils/KeyMapper.ts +76 -74
  186. package/src/utils/TimeUtils.ts +11 -0
  187. package/src/utils/color.ts +25 -25
  188. package/src/utils/hist.js +22 -22
  189. package/src/utils/index.ts +2 -3
  190. package/src/utils/mouse.ts +45 -0
  191. package/src/utils/siaIcons.jsx +5 -7
  192. package/src/utils/transform.ts +186 -0
  193. package/src/utils/uiConfig.js +19 -22
  194. package/src/utils/windowViewport.ts +34 -0
  195. package/src/AnnoLabelInput.jsx +0 -109
  196. package/src/AnnoToolBar.jsx +0 -153
  197. package/src/Annotation/AnnoBar.jsx +0 -154
  198. package/src/Annotation/Annotation.jsx +0 -395
  199. package/src/Annotation/Annotation.scss +0 -47
  200. package/src/Annotation/BBox.jsx +0 -299
  201. package/src/Annotation/Edge.jsx +0 -92
  202. package/src/Annotation/InfSelectionArea.jsx +0 -72
  203. package/src/Annotation/Line.jsx +0 -68
  204. package/src/Annotation/Node.jsx +0 -282
  205. package/src/Annotation/Point.jsx +0 -200
  206. package/src/Annotation/Polygon.jsx +0 -404
  207. package/src/Annotation/logic/AnnotationUtils.ts +0 -30
  208. package/src/Canvas.jsx +0 -2194
  209. package/src/ImgBar.jsx +0 -131
  210. package/src/LabelInput.jsx +0 -238
  211. package/src/Prompt.jsx +0 -45
  212. package/src/SIAFilterButton.jsx +0 -186
  213. package/src/Sia.jsx +0 -478
  214. package/src/Sia2.tsx +0 -392
  215. package/src/SiaPopup.jsx +0 -15
  216. package/src/ToolBar.jsx +0 -463
  217. package/src/Toolbar/NavigationButtons.tsx +0 -21
  218. package/src/Toolbar/ToolbarItem.jsx +0 -30
  219. package/src/Toolbar/ToolbarItems/ImageToolItems/ImageLabel.tsx +0 -62
  220. package/src/Toolbar.css +0 -13
  221. package/src/ToolbarItem.jsx +0 -31
  222. package/src/filterTools.js +0 -5
  223. package/src/models/AllowedTools.tsx +0 -9
  224. package/src/models/AnnotationSettings.tsx +0 -9
  225. package/src/models/ExternalAnnotation.ts +0 -15
  226. package/src/models/Label.tsx +0 -8
  227. package/src/models/UiConfig.tsx +0 -6
  228. package/src/stories/Button.jsx +0 -54
  229. package/src/stories/Button.stories.js +0 -48
  230. package/src/stories/Header.jsx +0 -69
  231. package/src/stories/Header.stories.js +0 -28
  232. package/src/stories/Page.jsx +0 -87
  233. package/src/stories/Page.stories.js +0 -28
  234. package/src/stories/SIA2/DemoWrapper.stories.tsx +0 -167
  235. package/src/stories/SIA2/DemoWrapper.tsx +0 -54
  236. package/src/stories/SIA2/Sia2.stories.tsx +0 -62
  237. package/src/stories/Toolbar/ImageTools/ImageLabel.stories.tsx +0 -32
  238. package/src/stories/assets/accessibility.png +0 -0
  239. package/src/stories/assets/accessibility.svg +0 -5
  240. package/src/stories/assets/addon-library.png +0 -0
  241. package/src/stories/assets/assets.png +0 -0
  242. package/src/stories/assets/avif-test-image.avif +0 -0
  243. package/src/stories/assets/context.png +0 -0
  244. package/src/stories/assets/discord.svg +0 -15
  245. package/src/stories/assets/docs.png +0 -0
  246. package/src/stories/assets/figma-plugin.png +0 -0
  247. package/src/stories/assets/github.svg +0 -3
  248. package/src/stories/assets/share.png +0 -0
  249. package/src/stories/assets/styling.png +0 -0
  250. package/src/stories/assets/testing.png +0 -0
  251. package/src/stories/assets/theming.png +0 -0
  252. package/src/stories/assets/tutorials.svg +0 -12
  253. package/src/stories/assets/youtube.svg +0 -4
  254. package/src/stories/button.css +0 -30
  255. package/src/stories/header.css +0 -32
  256. package/src/stories/lost.js +0 -54
  257. package/src/stories/page.css +0 -69
  258. package/src/stories/siaDummyData.js +0 -263
  259. package/src/stories/store.js +0 -18
  260. package/src/test.js +0 -7
  261. package/src/types/annoStatus.js +0 -4
  262. package/src/types/canvasActions.js +0 -58
  263. package/src/types/cursorstyles.js +0 -3
  264. package/src/types/modes.js +0 -9
  265. package/src/types/notificationType.js +0 -11
  266. package/src/types/toolbarEvents.js +0 -35
  267. package/src/types/tools.js +0 -17
  268. package/src/types.tsx +0 -11
  269. package/src/utils/annoConversion.js +0 -145
  270. package/src/utils/annoConversion2.ts +0 -145
  271. package/src/utils/colorlut.js +0 -68
  272. package/src/utils/constraints.js +0 -81
  273. package/src/utils/index.js +0 -1
  274. package/src/utils/keyActions.js +0 -113
  275. package/src/utils/mouse.js +0 -14
  276. package/src/utils/mouse2.ts +0 -35
  277. package/src/utils/transform.js +0 -336
  278. package/src/utils/transform2.ts +0 -343
  279. package/src/utils/windowViewport.js +0 -34
  280. package/src/utils/windowViewport2.ts +0 -50
@@ -0,0 +1,27 @@
1
+ import { Canvas, Meta, Source, Story } from "@storybook/addon-docs/blocks";
2
+ import * as SiaStories from "./AnnotationTools.stories.tsx";
3
+
4
+ <Meta of={SiaStories} />
5
+
6
+ # Annotation Tools
7
+
8
+ The `allowedTools` parameter allows configuring which annotation tools are permitted.
9
+ For example, you could let the user only annotate bounding boxes with the following:
10
+
11
+ <Source of={SiaStories.BBoxOnly} language="tsx" />
12
+
13
+ This will get you the following:
14
+
15
+ <Canvas>
16
+ <Story of={SiaStories.BBoxOnly} />
17
+ </Canvas>
18
+
19
+ ## Control Junk
20
+
21
+ You can also restrict the user from using the junk functionality:
22
+
23
+ <Source of={SiaStories.NoJunk} language="tsx" />
24
+
25
+ <Canvas>
26
+ <Story of={SiaStories.NoJunk} />
27
+ </Canvas>
@@ -0,0 +1,104 @@
1
+ import type { Meta, StoryObj } from '@storybook/react'
2
+
3
+ import Sia from '../Sia'
4
+ import exampleImage from './exampleData/exampleImage'
5
+ import { AllowedTools } from '../types'
6
+
7
+ export const ActionsData = {}
8
+
9
+ const meta = {
10
+ title: 'Annotation Tools',
11
+ component: Sia,
12
+ parameters: {
13
+ // More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
14
+ layout: 'fullscreen',
15
+ },
16
+ tags: ['!autodocs'],
17
+ excludeStories: /.*Data$/,
18
+ args: {
19
+ ...ActionsData,
20
+ },
21
+ } satisfies Meta<typeof Sia>
22
+
23
+ export default meta
24
+ type Story = StoryObj<typeof meta>
25
+
26
+ const allowedTools: AllowedTools = {
27
+ bbox: true,
28
+ line: false,
29
+ point: false,
30
+ polygon: false,
31
+ junk: true,
32
+ }
33
+
34
+ export const BBoxOnly: Story = {
35
+ args: {
36
+ ...ActionsData,
37
+ image: exampleImage,
38
+ possibleLabels: [],
39
+ allowedTools,
40
+ },
41
+ parameters: {
42
+ docs: {
43
+ source: {
44
+ code: `
45
+ const imageBlob: string = "data:image/jpeg;base64,/9j/4AAQSkZ..."
46
+ const allowedTools: AllowedTools = {
47
+ bbox: true,
48
+ line: false,
49
+ point: false,
50
+ polygon: false,
51
+ junk: true,
52
+ };
53
+
54
+ ...
55
+
56
+ <Sia
57
+ allowedTools={allowedTools}
58
+ image={imageBlob}
59
+ possibleLabels={[]}
60
+ />`,
61
+ },
62
+ },
63
+ },
64
+ }
65
+
66
+ const noJunkTools = {
67
+ bbox: true,
68
+ line: true,
69
+ point: true,
70
+ polygon: true,
71
+ junk: false,
72
+ }
73
+
74
+ export const NoJunk: Story = {
75
+ args: {
76
+ ...ActionsData,
77
+ image: exampleImage,
78
+ possibleLabels: [],
79
+ allowedTools: noJunkTools,
80
+ },
81
+ parameters: {
82
+ docs: {
83
+ source: {
84
+ code: `
85
+ const imageBlob: string = "data:image/jpeg;base64,/9j/4AAQSkZ..."
86
+ const allowedTools: AllowedTools = {
87
+ bbox: true,
88
+ line: true,
89
+ point: true,
90
+ polygon: true,
91
+ junk: false,
92
+ };
93
+
94
+ ...
95
+
96
+ <Sia
97
+ allowedTools={allowedTools}
98
+ image={imageBlob}
99
+ possibleLabels={[]}
100
+ />`,
101
+ },
102
+ },
103
+ },
104
+ }
@@ -1,156 +1,102 @@
1
- import type { Meta, StoryObj } from "@storybook/react";
2
- import { fn } from "@storybook/test";
3
- import { imgBlob } from "../siaDummyData";
1
+ import type { Meta, StoryObj } from '@storybook/react'
2
+ import { fn } from '@storybook/test'
3
+ import exampleImage from '../exampleData/exampleImage'
4
4
 
5
- import Canvas from "../../Canvas/Canvas";
6
- import AnnotationTool from "../../models/AnnotationTool";
7
- import Annotation from "../../Annotation/logic/Annotation";
5
+ import Canvas from '../../Canvas/Canvas'
6
+ import AnnotationTool from '../../models/AnnotationTool'
8
7
 
9
- import { possibleLabels } from "../siaDummyData2";
10
- import UiConfig from "../../models/UiConfig";
8
+ import { AnnotationSettings, UiConfig } from '../../types'
9
+ import exampleAnnotations from '../exampleData/exampleAnnotations'
10
+ import exampleLabels from '../exampleData/exampleLabels'
11
11
 
12
12
  export const ActionsData = {
13
13
  onAnnoEvent: fn(),
14
14
  onKeyDown: fn(),
15
15
  onKeyUp: fn(),
16
- };
16
+ }
17
17
 
18
18
  const meta = {
19
- title: "Components/Canvas",
19
+ title: 'Components/Canvas',
20
20
  component: Canvas,
21
21
  parameters: {
22
22
  // More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
23
- layout: "fullscreen",
23
+ layout: 'fullscreen',
24
24
  },
25
- tags: ["autodocs"],
25
+ tags: ['!autodocs'],
26
26
  excludeStories: /.*Data$/,
27
27
  args: {
28
- ...ActionsData,
28
+ // ...ActionsData,
29
29
  },
30
- } satisfies Meta<typeof Canvas>;
30
+ } satisfies Meta<typeof Canvas>
31
31
 
32
- export default meta;
33
- type Story = StoryObj<typeof meta>;
32
+ export default meta
33
+ type Story = StoryObj<typeof meta>
34
34
 
35
35
  const uiConfig: UiConfig = {
36
36
  nodeRadius: 4,
37
37
  strokeWidth: 4,
38
- };
38
+ imageCentered: false,
39
+ }
39
40
 
40
- export const Default: Story = {
41
- args: {
42
- ...ActionsData,
43
- image: imgBlob,
44
- selectedAnnoTool: AnnotationTool.Point,
45
- possibleLabels,
46
- preventScrolling: true,
47
- uiConfig,
48
- },
49
- };
41
+ const annotationSettings: AnnotationSettings = {
42
+ canHaveMultipleLabels: true,
43
+ canCreate: true,
44
+ canLabel: true,
45
+ }
50
46
 
51
- const samplePointAnnotations: Annotation[] = [
52
- new Annotation(AnnotationTool.Point, [{ x: 10, y: 10 }]),
53
- new Annotation(AnnotationTool.Point, [{ x: 50, y: 50 }]),
54
- new Annotation(AnnotationTool.Point, [{ x: 100, y: 100 }]),
55
- new Annotation(AnnotationTool.Point, [{ x: 150, y: 150 }]),
56
- new Annotation(AnnotationTool.Point, [{ x: 200, y: 200 }]),
57
- new Annotation(AnnotationTool.Point, [{ x: 250, y: 250 }]),
58
- new Annotation(AnnotationTool.Point, [{ x: 300, y: 300 }]),
59
- new Annotation(AnnotationTool.Point, [{ x: 350, y: 350 }]),
60
- ];
47
+ const defaultArgs = {
48
+ ...ActionsData,
49
+ annotations: [],
50
+ annotationSettings,
51
+ image: exampleImage,
52
+ selectedAnnotation: undefined,
53
+ selectedAnnoTool: AnnotationTool.Point,
54
+ possibleLabels: exampleLabels.voc,
55
+ preventScrolling: true,
56
+ uiConfig,
57
+ onAnnoCreated: () => {},
58
+ onAnnoChanged: () => {},
59
+ onAnnoCreationFinished: () => {},
60
+ onAnnoEditing: () => {},
61
+ onRequestNewAnnoId: () => 1,
62
+ onSelectAnnotation: () => {},
63
+ onSetIsImageJunk: () => {},
64
+ onSetSelectedTool: () => {},
65
+ onShouldDeleteAnno: () => {},
66
+ }
67
+
68
+ export const Default: Story = {
69
+ args: defaultArgs,
70
+ }
61
71
 
62
72
  export const WithPoints: Story = {
63
73
  args: {
64
- ...ActionsData,
65
- annotations: samplePointAnnotations,
66
- image: imgBlob,
74
+ ...defaultArgs,
75
+ annotations: exampleAnnotations.point,
67
76
  selectedAnnoTool: AnnotationTool.Point,
68
- possibleLabels,
69
- preventScrolling: true,
70
- uiConfig,
71
77
  },
72
- };
73
-
74
- const sampleLineAnnotations: Annotation[] = [
75
- new Annotation(AnnotationTool.Line, [
76
- { x: 10, y: 10 },
77
- { x: 100, y: 100 },
78
- ]),
79
- new Annotation(AnnotationTool.Line, [
80
- { x: 50, y: 50 },
81
- { x: 200, y: 100 },
82
- { x: 300, y: 100 },
83
- { x: 450, y: 120 },
84
- { x: 400, y: 200 },
85
- { x: 200, y: 200 },
86
- ]),
87
- new Annotation(AnnotationTool.Line, [{ x: 150, y: 150 }]),
88
- new Annotation(AnnotationTool.Line, [{ x: 200, y: 200 }]),
89
- ];
78
+ }
90
79
 
91
80
  export const WithLines: Story = {
92
81
  args: {
93
- ...ActionsData,
94
- annotations: sampleLineAnnotations,
95
- image: imgBlob,
82
+ ...defaultArgs,
83
+ annotations: exampleAnnotations.line,
96
84
  selectedAnnoTool: AnnotationTool.Line,
97
- possibleLabels,
98
- preventScrolling: true,
99
- uiConfig,
100
85
  },
101
- };
102
-
103
- const sampleBBoxAnnotations: Annotation[] = [
104
- new Annotation(AnnotationTool.BBox, [
105
- { x: 50, y: 50 },
106
- { x: 200, y: 100 },
107
- ]),
108
- new Annotation(AnnotationTool.BBox, [
109
- { x: 150, y: 150 },
110
- { x: 200, y: 200 },
111
- ]),
112
- new Annotation(AnnotationTool.BBox, [
113
- { x: 400, y: 325 },
114
- { x: 500, y: 375 },
115
- ]),
116
- ];
86
+ }
117
87
 
118
88
  export const WithBBoxes: Story = {
119
89
  args: {
120
- ...ActionsData,
121
- annotations: sampleBBoxAnnotations,
122
- image: imgBlob,
90
+ ...defaultArgs,
91
+ annotations: exampleAnnotations.bbox,
123
92
  selectedAnnoTool: AnnotationTool.BBox,
124
- possibleLabels,
125
- preventScrolling: true,
126
- uiConfig,
127
93
  },
128
- };
129
-
130
- const samplePolygonAnnotations: Annotation[] = [
131
- new Annotation(AnnotationTool.Polygon, [
132
- { x: 50, y: 50 },
133
- { x: 200, y: 100 },
134
- { x: 250, y: 100 },
135
- { x: 250, y: 200 },
136
- ]),
137
- new Annotation(AnnotationTool.Polygon, [
138
- { x: 500, y: 300 },
139
- { x: 500, y: 320 },
140
- { x: 550, y: 370 },
141
- { x: 600, y: 350 },
142
- { x: 550, y: 450 },
143
- ]),
144
- ];
94
+ }
145
95
 
146
96
  export const WithPolygonAnnotations: Story = {
147
97
  args: {
148
- ...ActionsData,
149
- annotations: samplePolygonAnnotations,
150
- image: imgBlob,
98
+ ...defaultArgs,
99
+ annotations: exampleAnnotations.polygon,
151
100
  selectedAnnoTool: AnnotationTool.Polygon,
152
- possibleLabels,
153
- preventScrolling: true,
154
- uiConfig,
155
101
  },
156
- };
102
+ }
@@ -1,58 +1,74 @@
1
- import Annotation from "../../Annotation/logic/Annotation";
2
- import Canvas from "../../Canvas/Canvas";
3
- import AnnotationTool from "../../models/AnnotationTool";
4
- import CanvasAction from "../../models/CanvasAction";
5
- import Label from "../../models/Label";
6
- import UiConfig from "../../models/UiConfig";
1
+ import { CSSProperties } from 'react'
2
+ import Annotation from '../../Annotation/logic/Annotation'
3
+ import Canvas from '../../Canvas/Canvas'
4
+ import AnnotationTool from '../../models/AnnotationTool'
5
+ import type { AnnotationSettings, Label, UiConfig } from '../../types'
7
6
 
8
7
  type CanvasProps = {
9
- annotations?: Annotation[];
10
- image: string;
11
- selectedAnnoTool: AnnotationTool;
12
- possibleLabels: Label[];
13
- preventScrolling: boolean;
14
- uiConfig: UiConfig;
15
- onAnnoEvent?: (
16
- annotation: Annotation,
17
- canvasAction: CanvasAction,
18
- ) => void | undefined;
19
- onKeyDown?: (e) => void | undefined;
20
- onKeyUp?: (e) => void | undefined;
21
- };
8
+ annotations?: Annotation[]
9
+ image: string
10
+ selectedAnnoTool: AnnotationTool
11
+ possibleLabels: Label[]
12
+ preventScrolling: boolean
13
+ uiConfig: UiConfig
14
+ }
15
+
16
+ const annotationSettings: AnnotationSettings = {
17
+ canHaveMultipleLabels: true,
18
+ canCreate: true,
19
+ canLabel: true,
20
+ }
22
21
 
23
22
  const CanvasWithOffset = ({
24
- annotations = [],
23
+ annotations = undefined,
25
24
  image,
26
25
  selectedAnnoTool,
27
26
  possibleLabels,
28
27
  preventScrolling,
29
28
  uiConfig,
30
- onAnnoEvent: propsOnAnnoEvent,
31
- onKeyDown: propOnKeyDown,
32
- onKeyUp: propsOnKeyUp,
33
29
  }: CanvasProps) => {
30
+ const forwardFlex: CSSProperties = {
31
+ display: 'flex',
32
+ flexDirection: 'column',
33
+
34
+ flex: '1 1 auto',
35
+ minHeight: 0,
36
+ }
37
+
34
38
  return (
35
39
  <>
36
40
  <h1>A line to generate offset</h1>
37
41
  <div
38
42
  style={{
39
- width: "100%",
40
- height: "100%",
41
- padding: 200,
42
- background: "green",
43
+ ...forwardFlex,
44
+ background: 'green',
45
+ padding: 100,
43
46
  }}
44
47
  >
45
- <Canvas
46
- annotations={annotations}
47
- image={image}
48
- selectedAnnoTool={selectedAnnoTool}
49
- possibleLabels={possibleLabels}
50
- preventScrolling={preventScrolling}
51
- uiConfig={uiConfig}
52
- />
48
+ <div style={{ ...forwardFlex, background: 'white' }}>
49
+ <Canvas
50
+ annotations={annotations}
51
+ annotationSettings={annotationSettings}
52
+ image={image}
53
+ selectedAnnotation={undefined}
54
+ selectedAnnoTool={selectedAnnoTool}
55
+ possibleLabels={possibleLabels}
56
+ preventScrolling={preventScrolling}
57
+ uiConfig={uiConfig}
58
+ onAnnoCreated={() => {}}
59
+ onAnnoChanged={() => {}}
60
+ onAnnoCreationFinished={() => {}}
61
+ onAnnoEditing={() => {}}
62
+ onRequestNewAnnoId={() => 1}
63
+ onSelectAnnotation={() => {}}
64
+ onSetIsImageJunk={() => {}}
65
+ onSetSelectedTool={() => {}}
66
+ onShouldDeleteAnno={() => {}}
67
+ />
68
+ </div>
53
69
  </div>
54
70
  </>
55
- );
56
- };
71
+ )
72
+ }
57
73
 
58
- export default CanvasWithOffset;
74
+ export default CanvasWithOffset
@@ -1,156 +1,85 @@
1
- import type { Meta, StoryObj } from "@storybook/react";
2
- import { fn } from "@storybook/test";
3
- import { imgBlob } from "../siaDummyData";
1
+ import type { Meta, StoryObj } from '@storybook/react'
2
+ import { fn } from '@storybook/test'
3
+ import exampleImage from '../exampleData/exampleImage'
4
4
 
5
- import AnnotationTool from "../../models/AnnotationTool";
6
- import Annotation from "../../Annotation/logic/Annotation";
5
+ import AnnotationTool from '../../models/AnnotationTool'
7
6
 
8
- import { possibleLabels } from "../siaDummyData2";
9
- import UiConfig from "../../models/UiConfig";
10
- import CanvasWithOffset from "./CanvasOffset";
7
+ import { UiConfig } from '../../types'
8
+ import CanvasWithOffset from './CanvasOffset'
9
+
10
+ import exampleAnnotations from '../exampleData/exampleAnnotations'
11
+ import exampleLabels from '../exampleData/exampleLabels'
11
12
 
12
13
  export const ActionsData = {
13
14
  onAnnoEvent: fn(),
14
15
  onKeyDown: fn(),
15
16
  onKeyUp: fn(),
16
- };
17
+ }
17
18
 
18
19
  const meta = {
19
- title: "Components/CanvasWithOffset",
20
+ title: 'Components/CanvasWithOffset',
20
21
  component: CanvasWithOffset,
21
22
  parameters: {
22
23
  // More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
23
- layout: "fullscreen",
24
+ layout: 'fullscreen',
24
25
  },
25
- tags: ["autodocs"],
26
+ tags: ['!autodocs'],
26
27
  excludeStories: /.*Data$/,
27
28
  args: {
28
29
  ...ActionsData,
29
30
  },
30
- } satisfies Meta<typeof CanvasWithOffset>;
31
+ } satisfies Meta<typeof CanvasWithOffset>
31
32
 
32
- export default meta;
33
- type Story = StoryObj<typeof meta>;
33
+ export default meta
34
+ type Story = StoryObj<typeof meta>
34
35
 
35
36
  const uiConfig: UiConfig = {
36
37
  nodeRadius: 4,
37
38
  strokeWidth: 4,
38
- };
39
+ imageCentered: false,
40
+ }
39
41
 
40
- export const Default: Story = {
41
- args: {
42
- ...ActionsData,
43
- image: imgBlob,
44
- selectedAnnoTool: AnnotationTool.Point,
45
- possibleLabels,
46
- preventScrolling: true,
47
- uiConfig,
48
- },
49
- };
42
+ const defaultArgs = {
43
+ ...ActionsData,
44
+ selectedAnnotation: undefined,
45
+ image: exampleImage,
46
+ selectedAnnoTool: AnnotationTool.Point,
47
+ possibleLabels: exampleLabels.voc,
48
+ preventScrolling: true,
49
+ uiConfig,
50
+ }
50
51
 
51
- const samplePointAnnotations: Annotation[] = [
52
- new Annotation(AnnotationTool.Point, [{ x: 10, y: 10 }]),
53
- new Annotation(AnnotationTool.Point, [{ x: 50, y: 50 }]),
54
- new Annotation(AnnotationTool.Point, [{ x: 100, y: 100 }]),
55
- new Annotation(AnnotationTool.Point, [{ x: 150, y: 150 }]),
56
- new Annotation(AnnotationTool.Point, [{ x: 200, y: 200 }]),
57
- new Annotation(AnnotationTool.Point, [{ x: 250, y: 250 }]),
58
- new Annotation(AnnotationTool.Point, [{ x: 300, y: 300 }]),
59
- new Annotation(AnnotationTool.Point, [{ x: 350, y: 350 }]),
60
- ];
52
+ export const Default: Story = {
53
+ args: defaultArgs,
54
+ }
61
55
 
62
56
  export const WithPoints: Story = {
63
57
  args: {
64
- ...ActionsData,
65
- annotations: samplePointAnnotations,
66
- image: imgBlob,
67
- selectedAnnoTool: AnnotationTool.Point,
68
- possibleLabels,
69
- preventScrolling: true,
70
- uiConfig,
58
+ ...defaultArgs,
59
+ annotations: exampleAnnotations.point,
71
60
  },
72
- };
73
-
74
- const sampleLineAnnotations: Annotation[] = [
75
- new Annotation(AnnotationTool.Line, [
76
- { x: 10, y: 10 },
77
- { x: 100, y: 100 },
78
- ]),
79
- new Annotation(AnnotationTool.Line, [
80
- { x: 50, y: 50 },
81
- { x: 200, y: 100 },
82
- { x: 300, y: 100 },
83
- { x: 450, y: 120 },
84
- { x: 400, y: 200 },
85
- { x: 200, y: 200 },
86
- ]),
87
- new Annotation(AnnotationTool.Line, [{ x: 150, y: 150 }]),
88
- new Annotation(AnnotationTool.Line, [{ x: 200, y: 200 }]),
89
- ];
61
+ }
90
62
 
91
63
  export const WithLines: Story = {
92
64
  args: {
93
- ...ActionsData,
94
- annotations: sampleLineAnnotations,
95
- image: imgBlob,
65
+ ...defaultArgs,
66
+ annotations: exampleAnnotations.line,
96
67
  selectedAnnoTool: AnnotationTool.Line,
97
- possibleLabels,
98
- preventScrolling: true,
99
- uiConfig,
100
68
  },
101
- };
102
-
103
- const sampleBBoxAnnotations: Annotation[] = [
104
- new Annotation(AnnotationTool.BBox, [
105
- { x: 50, y: 50 },
106
- { x: 200, y: 100 },
107
- ]),
108
- new Annotation(AnnotationTool.BBox, [
109
- { x: 150, y: 150 },
110
- { x: 200, y: 200 },
111
- ]),
112
- new Annotation(AnnotationTool.BBox, [
113
- { x: 400, y: 325 },
114
- { x: 500, y: 375 },
115
- ]),
116
- ];
69
+ }
117
70
 
118
71
  export const WithBBoxes: Story = {
119
72
  args: {
120
- ...ActionsData,
121
- annotations: sampleBBoxAnnotations,
122
- image: imgBlob,
73
+ ...defaultArgs,
74
+ annotations: exampleAnnotations.bbox,
123
75
  selectedAnnoTool: AnnotationTool.BBox,
124
- possibleLabels,
125
- preventScrolling: true,
126
- uiConfig,
127
76
  },
128
- };
129
-
130
- const samplePolygonAnnotations: Annotation[] = [
131
- new Annotation(AnnotationTool.Polygon, [
132
- { x: 50, y: 50 },
133
- { x: 200, y: 100 },
134
- { x: 250, y: 100 },
135
- { x: 250, y: 200 },
136
- ]),
137
- new Annotation(AnnotationTool.Polygon, [
138
- { x: 500, y: 300 },
139
- { x: 500, y: 320 },
140
- { x: 550, y: 370 },
141
- { x: 600, y: 350 },
142
- { x: 550, y: 450 },
143
- ]),
144
- ];
77
+ }
145
78
 
146
79
  export const WithPolygonAnnotations: Story = {
147
80
  args: {
148
- ...ActionsData,
149
- annotations: samplePolygonAnnotations,
150
- image: imgBlob,
81
+ ...defaultArgs,
82
+ annotations: exampleAnnotations.polygon,
151
83
  selectedAnnoTool: AnnotationTool.Polygon,
152
- possibleLabels,
153
- preventScrolling: true,
154
- uiConfig,
155
84
  },
156
- };
85
+ }