@searpent/react-image-annotate 2.0.4 → 2.0.7

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 (195) hide show
  1. package/Annotator/examplePhotos.js +6976 -0
  2. package/Annotator/index.js +262 -0
  3. package/Annotator/reducers/combine-reducers.js +14 -0
  4. package/Annotator/reducers/convert-expanding-line-to-polygon.js +73 -0
  5. package/{src/Annotator → Annotator}/reducers/fix-twisted.js +3 -5
  6. package/Annotator/reducers/general-reducer.js +1152 -0
  7. package/Annotator/reducers/get-active-image.js +27 -0
  8. package/Annotator/reducers/get-implied-video-regions.js +180 -0
  9. package/Annotator/reducers/history-handler.js +38 -0
  10. package/Annotator/reducers/image-reducer.js +20 -0
  11. package/Annotator/reducers/video-reducer.js +88 -0
  12. package/ClassSelectionMenu/index.js +135 -0
  13. package/Crosshairs/index.js +53 -0
  14. package/DebugSidebarBox/index.js +20 -0
  15. package/DemoSite/Editor.js +194 -0
  16. package/DemoSite/ErrorBoundaryDialog.js +64 -0
  17. package/DemoSite/index.js +40 -0
  18. package/{src/Editor → Editor}/annotation-plugin/annotation.css +0 -0
  19. package/Editor/annotation-plugin/annotation.js +613 -0
  20. package/Editor/index.js +57 -0
  21. package/{src/Editor → Editor}/tools.js +2 -3
  22. package/FullImageSegmentationAnnotator/index.js +7 -0
  23. package/GroupSelectorSidebarBox/index.js +63 -0
  24. package/HighlightBox/index.js +99 -0
  25. package/HistorySidebarBox/index.js +71 -0
  26. package/ImageCanvas/index.js +429 -0
  27. package/ImageCanvas/region-tools.js +165 -0
  28. package/{src/ImageCanvas → ImageCanvas}/styles.js +12 -8
  29. package/ImageCanvas/use-mouse.js +180 -0
  30. package/ImageCanvas/use-project-box.js +27 -0
  31. package/ImageCanvas/use-wasd-mode.js +62 -0
  32. package/ImageMask/index.js +133 -0
  33. package/ImageMask/load-image.js +25 -0
  34. package/ImageSelectorSidebarBox/index.js +60 -0
  35. package/KeyframeTimeline/get-time-string.js +27 -0
  36. package/KeyframeTimeline/index.js +233 -0
  37. package/KeyframesSelectorSidebarBox/index.js +93 -0
  38. package/LandingPage/index.js +159 -0
  39. package/MainLayout/icon-dictionary.js +104 -0
  40. package/MainLayout/index.js +469 -0
  41. package/{src/MainLayout → MainLayout}/styles.js +6 -7
  42. package/MainLayout/types.js +0 -0
  43. package/MainLayout/use-implied-video-regions.js +13 -0
  44. package/MetadataEditorSidebarBox/index.js +126 -0
  45. package/PageSelector/index.js +67 -0
  46. package/{src/PageSelector → PageSelector}/page-selector.css +0 -0
  47. package/PointDistances/index.js +73 -0
  48. package/PreventScrollToParents/index.js +51 -0
  49. package/RegionLabel/index.js +205 -0
  50. package/{src/RegionLabel → RegionLabel}/styles.js +12 -15
  51. package/RegionSelectAndTransformBoxes/index.js +167 -0
  52. package/RegionSelectorSidebarBox/index.js +248 -0
  53. package/{src/RegionSelectorSidebarBox → RegionSelectorSidebarBox}/styles.js +13 -14
  54. package/RegionShapes/index.js +294 -0
  55. package/RegionTags/index.js +142 -0
  56. package/SettingsDialog/index.js +52 -0
  57. package/SettingsProvider/index.js +58 -0
  58. package/Shortcuts/ShortcutField.js +46 -0
  59. package/Shortcuts/index.js +133 -0
  60. package/ShortcutsManager/index.js +155 -0
  61. package/Sidebar/index.js +69 -0
  62. package/SidebarBoxContainer/index.js +93 -0
  63. package/SmallToolButton/index.js +42 -0
  64. package/TagsSidebarBox/index.js +105 -0
  65. package/TaskDescriptionSidebarBox/index.js +58 -0
  66. package/Theme/index.js +30 -0
  67. package/VideoOrImageCanvasBackground/index.js +151 -0
  68. package/colors.js +14 -0
  69. package/hooks/use-colors.js +101 -0
  70. package/hooks/use-event-callback.js +10 -0
  71. package/hooks/use-exclude-pattern.js +24 -0
  72. package/hooks/use-load-image.js +26 -0
  73. package/hooks/use-window-size.js +46 -0
  74. package/{src/hooks → hooks}/xpattern.js +1 -1
  75. package/index.js +3 -0
  76. package/lib.js +3 -0
  77. package/package.json +1 -1
  78. package/stories.js +5 -0
  79. package/{src/utils → utils}/filter-only-unique.js +1 -1
  80. package/utils/get-from-local-storage.js +7 -0
  81. package/utils/get-hotkey-help-text.js +9 -0
  82. package/utils/get-landmarks-with-transform.js +40 -0
  83. package/utils/photosToImages.js +53 -0
  84. package/utils/regions-to-blocks.js +16 -0
  85. package/utils/set-in-local-storage.js +3 -0
  86. package/.babelrc +0 -6
  87. package/.env +0 -1
  88. package/.flowconfig +0 -2
  89. package/.github/workflows/release-on-master.yml +0 -32
  90. package/.github/workflows/test.yml +0 -16
  91. package/.prettierrc +0 -3
  92. package/.releaserc.js +0 -18
  93. package/.storybook/addons.js +0 -2
  94. package/.storybook/config.js +0 -16
  95. package/LICENSE +0 -21
  96. package/public/favicon.ico +0 -0
  97. package/public/index.html +0 -38
  98. package/src/Annotator/bike-pic.png +0 -0
  99. package/src/Annotator/bike-pic2.png +0 -0
  100. package/src/Annotator/dab-keyframes.story.json +0 -1
  101. package/src/Annotator/examplePhotos.js +0 -7601
  102. package/src/Annotator/index.js +0 -291
  103. package/src/Annotator/index.story.js +0 -807
  104. package/src/Annotator/poses.story.js +0 -150
  105. package/src/Annotator/reducers/combine-reducers.js +0 -7
  106. package/src/Annotator/reducers/convert-expanding-line-to-polygon.js +0 -53
  107. package/src/Annotator/reducers/general-reducer.js +0 -996
  108. package/src/Annotator/reducers/get-active-image.js +0 -21
  109. package/src/Annotator/reducers/get-implied-video-regions.js +0 -115
  110. package/src/Annotator/reducers/history-handler.js +0 -60
  111. package/src/Annotator/reducers/image-reducer.js +0 -23
  112. package/src/Annotator/reducers/video-reducer.js +0 -85
  113. package/src/Annotator/video.story.js +0 -51
  114. package/src/ClassSelectionMenu/index.js +0 -108
  115. package/src/Crosshairs/index.js +0 -64
  116. package/src/DebugSidebarBox/index.js +0 -36
  117. package/src/DemoSite/Editor.js +0 -235
  118. package/src/DemoSite/ErrorBoundaryDialog.js +0 -34
  119. package/src/DemoSite/index.js +0 -41
  120. package/src/DemoSite/index.story.js +0 -10
  121. package/src/DemoSite/simple-segmentation-example.json +0 -572
  122. package/src/Editor/annotation-plugin/annotation.js +0 -515
  123. package/src/Editor/index.js +0 -24
  124. package/src/FullImageSegmentationAnnotator/hard1.story.jpg +0 -0
  125. package/src/FullImageSegmentationAnnotator/hard2.story.jpg +0 -0
  126. package/src/FullImageSegmentationAnnotator/hard3.story.jpg +0 -0
  127. package/src/FullImageSegmentationAnnotator/index.js +0 -7
  128. package/src/FullImageSegmentationAnnotator/index.story.js +0 -177
  129. package/src/FullImageSegmentationAnnotator/orange.story.png +0 -0
  130. package/src/GroupSelectorSidebarBox/index.js +0 -48
  131. package/src/HighlightBox/index.js +0 -143
  132. package/src/HistorySidebarBox/index.js +0 -78
  133. package/src/ImageCanvas/dancing-man.story.jpg +0 -0
  134. package/src/ImageCanvas/index.js +0 -494
  135. package/src/ImageCanvas/index.story.js +0 -314
  136. package/src/ImageCanvas/mouse_mask.story.png +0 -0
  137. package/src/ImageCanvas/region-tools.js +0 -171
  138. package/src/ImageCanvas/seves_desk.story.jpg +0 -0
  139. package/src/ImageCanvas/use-mouse.js +0 -168
  140. package/src/ImageCanvas/use-project-box.js +0 -23
  141. package/src/ImageCanvas/use-wasd-mode.js +0 -50
  142. package/src/ImageMask/index.js +0 -127
  143. package/src/ImageMask/load-image.js +0 -32
  144. package/src/ImageSelectorSidebarBox/index.js +0 -54
  145. package/src/KeyframeTimeline/get-time-string.js +0 -25
  146. package/src/KeyframeTimeline/index.js +0 -223
  147. package/src/KeyframesSelectorSidebarBox/index.js +0 -93
  148. package/src/LandingPage/content.md +0 -57
  149. package/src/LandingPage/github-markdown.css +0 -964
  150. package/src/LandingPage/index.js +0 -147
  151. package/src/MainLayout/icon-dictionary.js +0 -79
  152. package/src/MainLayout/index.js +0 -510
  153. package/src/MainLayout/index.story.js +0 -240
  154. package/src/MainLayout/types.js +0 -164
  155. package/src/MainLayout/use-implied-video-regions.js +0 -17
  156. package/src/MetadataEditorSidebarBox/index.js +0 -98
  157. package/src/PageSelector/index.js +0 -76
  158. package/src/PointDistances/index.js +0 -90
  159. package/src/PreventScrollToParents/index.js +0 -48
  160. package/src/PreventScrollToParents/index.story.js +0 -23
  161. package/src/RegionLabel/index.js +0 -222
  162. package/src/RegionSelectAndTransformBoxes/index.js +0 -234
  163. package/src/RegionSelectorSidebarBox/index.js +0 -216
  164. package/src/RegionShapes/index.js +0 -254
  165. package/src/RegionTags/index.js +0 -134
  166. package/src/SettingsDialog/index.js +0 -58
  167. package/src/SettingsProvider/index.js +0 -48
  168. package/src/Shortcuts/ShortcutField.js +0 -44
  169. package/src/Shortcuts/index.js +0 -129
  170. package/src/ShortcutsManager/index.js +0 -162
  171. package/src/Sidebar/index.js +0 -117
  172. package/src/SidebarBoxContainer/index.js +0 -93
  173. package/src/SmallToolButton/index.js +0 -57
  174. package/src/TagsSidebarBox/index.js +0 -93
  175. package/src/TaskDescriptionSidebarBox/index.js +0 -43
  176. package/src/Theme/index.js +0 -36
  177. package/src/VideoOrImageCanvasBackground/index.js +0 -170
  178. package/src/colors.js +0 -32
  179. package/src/hooks/use-colors.js +0 -74
  180. package/src/hooks/use-event-callback.js +0 -11
  181. package/src/hooks/use-exclude-pattern.js +0 -27
  182. package/src/hooks/use-load-image.js +0 -21
  183. package/src/hooks/use-window-size.js +0 -46
  184. package/src/hooks/xpattern.png +0 -0
  185. package/src/index.js +0 -18
  186. package/src/lib.js +0 -7
  187. package/src/screenshot.png +0 -0
  188. package/src/site.css +0 -5
  189. package/src/stories.js +0 -2
  190. package/src/utils/get-from-local-storage.js +0 -7
  191. package/src/utils/get-hotkey-help-text.js +0 -11
  192. package/src/utils/get-landmarks-with-transform.js +0 -23
  193. package/src/utils/photosToImages.js +0 -40
  194. package/src/utils/regions-to-blocks.js +0 -14
  195. package/src/utils/set-in-local-storage.js +0 -6
@@ -1,44 +0,0 @@
1
- import React from "react"
2
- import TextField from "@mui/material/TextField"
3
- import { makeStyles } from "@mui/styles"
4
- import { createTheme, ThemeProvider } from "@mui/material/styles"
5
-
6
- const theme = createTheme()
7
- const useStyles = makeStyles((theme) => ({
8
- shortcutKeyFieldWrapper: {
9
- paddingTop: 8,
10
- display: "inline-flex",
11
- width: "100%",
12
- },
13
- shortcutKeyText: {
14
- lineHeight: 0,
15
- },
16
- shortcutTextfield: {
17
- width: "100%",
18
- boxSizing: "border-box",
19
- textAlign: "center",
20
- },
21
- }))
22
-
23
- const ShortcutField = ({ actionId, actionName, keyName, onChangeShortcut }) => {
24
- const classes = useStyles()
25
-
26
- return (
27
- <ThemeProvider theme={theme}>
28
- <div className={classes.shortcutKeyFieldWrapper}>
29
- <TextField
30
- variant="outlined"
31
- label={actionName}
32
- className={classes.shortcutTextfield}
33
- value={keyName}
34
- onKeyPress={(e) => {
35
- onChangeShortcut(actionId, e.key)
36
- e.stopPropagation()
37
- }}
38
- />
39
- </div>
40
- </ThemeProvider>
41
- )
42
- }
43
-
44
- export default ShortcutField
@@ -1,129 +0,0 @@
1
- import React, { useState, useEffect } from "react"
2
- import SidebarBoxContainer from "../SidebarBoxContainer"
3
- import { setIn } from "seamless-immutable"
4
- import ShortcutField from "./ShortcutField"
5
-
6
- const defaultShortcuts = {
7
- select: {
8
- action: {
9
- type: "SELECT_TOOL",
10
- },
11
- name: "Select Region",
12
- key: "Escape",
13
- },
14
- zoom: {
15
- action: {
16
- type: "SELECT_TOOL",
17
- },
18
- name: "Zoom In/Out",
19
- key: "z",
20
- },
21
- "create-point": {
22
- action: {
23
- type: "SELECT_TOOL",
24
- },
25
- name: "Create Point",
26
- },
27
- "create-box": {
28
- action: {
29
- type: "SELECT_TOOL",
30
- },
31
- name: "Add Bounding Box",
32
- key: "b",
33
- },
34
- pan: {
35
- action: {
36
- type: "SELECT_TOOL",
37
- },
38
- name: "Pan",
39
- },
40
- "create-polygon": {
41
- action: {
42
- type: "SELECT_TOOL",
43
- },
44
- name: "Create Polygon",
45
- },
46
- "create-pixel": {
47
- action: {
48
- type: "SELECT_TOOL",
49
- },
50
- name: "Create Pixel",
51
- },
52
- "prev-image": {
53
- action: {
54
- type: "HEADER_BUTTON_CLICKED",
55
- buttonName: "Prev",
56
- },
57
- name: "Previous Image",
58
- key: "a",
59
- },
60
- "next-image": {
61
- action: {
62
- type: "HEADER_BUTTON_CLICKED",
63
- buttonName: "Next",
64
- },
65
- name: "Next Image",
66
- key: "d", //"ArrowRight"
67
- },
68
- }
69
-
70
- export default ({ onShortcutActionDispatched }) => {
71
- const [shortcuts, setShortcuts] = useState({}) // useLocalStorage
72
-
73
- useEffect(() => {
74
- const newShortcuts = { ...shortcuts }
75
- for (const actionId of Object.keys(defaultShortcuts)) {
76
- if (!newShortcuts[actionId]) {
77
- newShortcuts[actionId] = defaultShortcuts[actionId]
78
- }
79
- }
80
- setShortcuts(newShortcuts)
81
- }, [])
82
-
83
- const onChangeShortcut = (actionId, keyName) => {
84
- setShortcuts(setIn(shortcuts, [actionId, "key"], keyName))
85
- }
86
-
87
- useEffect(() => {
88
- const handleKeyPress = (e) => {
89
- for (const actionId in shortcuts) {
90
- const shortcut = shortcuts[actionId]
91
- if (!shortcut || !shortcut.key) {
92
- continue
93
- }
94
- if (e.key === shortcut.key) {
95
- onShortcutActionDispatched({
96
- ...shortcut.action,
97
- selectedTool: actionId,
98
- })
99
- }
100
- }
101
- }
102
-
103
- window.addEventListener("keypress", handleKeyPress)
104
-
105
- return () => {
106
- window.removeEventListener("keypress", handleKeyPress)
107
- document.activeElement.blur()
108
- }
109
- }, [shortcuts])
110
-
111
- return (
112
- <SidebarBoxContainer title="Shortcuts">
113
- {Object.keys(shortcuts)
114
- .map((actionId, index) => {
115
- if (!shortcuts[actionId]) return null
116
- return (
117
- <ShortcutField
118
- key={actionId}
119
- actionId={actionId}
120
- actionName={shortcuts[actionId].name}
121
- keyName={shortcuts[actionId].key || ""}
122
- onChangeShortcut={onChangeShortcut}
123
- />
124
- )
125
- })
126
- .filter(Boolean)}
127
- </SidebarBoxContainer>
128
- )
129
- }
@@ -1,162 +0,0 @@
1
- import React, { useMemo } from "react"
2
- import { HotKeys } from "react-hotkeys"
3
-
4
- export const defaultHotkeys = [
5
- {
6
- id: "select_tool",
7
- description: "Switch to the Select Tool",
8
- binding: "escape",
9
- },
10
- {
11
- id: "zoom_tool",
12
- description: "Select the Zoom Tool",
13
- binding: "z",
14
- },
15
- {
16
- id: "create_point",
17
- description: "Create a point",
18
- },
19
- {
20
- id: "create_bounding_box",
21
- description: "Create a bounding box",
22
- binding: "b",
23
- },
24
- {
25
- id: "pan_tool",
26
- description: "Select the Pan Tool",
27
- binding: "m",
28
- },
29
- {
30
- id: "create_polygon",
31
- description: "Create a Polygon",
32
- binding: "p",
33
- },
34
- {
35
- id: "create_pixel",
36
- description: "Create a Pixel Mask",
37
- },
38
- {
39
- id: "save_and_previous_sample",
40
- description: "Save and go to previous sample",
41
- binding: "ArrowLeft",
42
- },
43
- {
44
- id: "save_and_next_sample",
45
- description: "Save and go to next sample",
46
- binding: "ArrowRight",
47
- },
48
- {
49
- id: "save_and_exit_sample",
50
- description: "Save and exit current sample",
51
- },
52
- {
53
- id: "exit_sample",
54
- description: "Exit sample without saving",
55
- },
56
- {
57
- id: "delete_region",
58
- description: "Delete selected region",
59
- binding: "d",
60
- },
61
- {
62
- id: "undo",
63
- description: "Undo latest change",
64
- binding: "Ctrl+z",
65
- },
66
- ]
67
- export const defaultKeyMap = {}
68
- for (const { id, binding } of defaultHotkeys) defaultKeyMap[id] = binding
69
-
70
- export const useDispatchHotkeyHandlers = ({ dispatch }) => {
71
- const handlers = useMemo(
72
- () => ({
73
- select_tool: () => {
74
- dispatch({
75
- type: "SELECT_TOOL",
76
- selectedTool: "select",
77
- })
78
- },
79
- zoom_tool: () => {
80
- dispatch({
81
- type: "SELECT_TOOL",
82
- selectedTool: "zoom",
83
- })
84
- },
85
- create_point: () => {
86
- dispatch({
87
- type: "SELECT_TOOL",
88
- selectedTool: "create-point",
89
- })
90
- },
91
- create_bounding_box: () => {
92
- dispatch({
93
- type: "SELECT_TOOL",
94
- selectedTool: "create-box",
95
- })
96
- },
97
- pan_tool: () => {
98
- dispatch({
99
- type: "SELECT_TOOL",
100
- selectedTool: "pan",
101
- })
102
- },
103
- create_polygon: () => {
104
- dispatch({
105
- type: "SELECT_TOOL",
106
- selectedTool: "create-polygon",
107
- })
108
- },
109
- create_pixel: () => {
110
- dispatch({
111
- type: "SELECT_TOOL",
112
- selectedTool: "create-pixel",
113
- })
114
- },
115
- save_and_previous_sample: () => {
116
- dispatch({
117
- type: "HEADER_BUTTON_CLICKED",
118
- buttonName: "Prev",
119
- })
120
- },
121
- save_and_next_sample: () => {
122
- dispatch({
123
- type: "HEADER_BUTTON_CLICKED",
124
- buttonName: "Next",
125
- })
126
- },
127
- save_and_exit_sample: () => {
128
- dispatch({
129
- type: "HEADER_BUTTON_CLICKED",
130
- buttonName: "Save",
131
- })
132
- },
133
- delete_region: () => {
134
- dispatch({
135
- type: "DELETE_SELECTED_REGION",
136
- })
137
- },
138
- undo: () => {
139
- dispatch({
140
- type: "RESTORE_HISTORY",
141
- })
142
- },
143
- // TODO
144
- // exit_sample: () => {
145
- // dispatch({
146
- // type: "",
147
- // })
148
- // }
149
- }),
150
- [dispatch]
151
- )
152
- return handlers
153
- }
154
-
155
- export default ({ children, dispatch }) => {
156
- const handlers = useDispatchHotkeyHandlers({ dispatch })
157
- return (
158
- <HotKeys allowChanges handlers={handlers}>
159
- {children}
160
- </HotKeys>
161
- )
162
- }
@@ -1,117 +0,0 @@
1
- // @flow
2
-
3
- import React from "react"
4
- import { styled } from "@mui/styles"
5
- import { createTheme, ThemeProvider } from "@mui/material/styles"
6
- import TaskDescription from "../TaskDescriptionSidebarBox"
7
- import ImageSelector from "../ImageSelectorSidebarBox"
8
- import RegionSelector from "../RegionSelectorSidebarBox"
9
- import History from "../HistorySidebarBox"
10
- import DebugBox from "../DebugSidebarBox"
11
- import TagsSidebarBox from "../TagsSidebarBox"
12
- import KeyframesSelector from "../KeyframesSelectorSidebarBox"
13
- import type { Region } from "../ImageCanvas/region-tools.js"
14
-
15
- const theme = createTheme()
16
- const Container = styled("div")(({ theme }) => ({}))
17
-
18
- type Image = {
19
- name: string,
20
- src: string,
21
- cls?: string,
22
- tags?: Array<string>,
23
- thumbnailSrc?: string,
24
- regions?: Array<Region>,
25
- }
26
-
27
- type Props = {
28
- debug: any,
29
- taskDescription: string,
30
- images?: Array<Image>,
31
- regions: Array<Region>,
32
- history: Array<{ state: Object, name: string, time: Date }>,
33
-
34
- labelImages?: boolean,
35
- currentImage?: Image,
36
- imageClsList?: Array<string>,
37
- imageTagList?: Array<string>,
38
-
39
- onChangeImage: (Image) => any,
40
- onSelectRegion: (Region) => any,
41
- onSelectImage: (Image) => any,
42
- onChangeRegion: (Region) => any,
43
- onDeleteRegion: (Region) => any,
44
- onRestoreHistory: () => any,
45
- onShortcutActionDispatched: (action: any) => any,
46
- }
47
-
48
- const emptyArr = []
49
-
50
- export const Sidebar = ({
51
- debug,
52
- taskDescription,
53
- keyframes,
54
- images,
55
- regions,
56
- history,
57
- labelImages,
58
- currentImage,
59
- currentVideoTime,
60
- imageClsList,
61
- imageTagList,
62
- onChangeImage,
63
- onSelectRegion,
64
- onSelectImage,
65
- onChangeRegion,
66
- onDeleteRegion,
67
- onRestoreHistory,
68
- onChangeVideoTime,
69
- onDeleteKeyframe,
70
- onShortcutActionDispatched,
71
- }: Props) => {
72
- if (!regions) regions = emptyArr
73
-
74
- return (
75
- <ThemeProvider theme={theme}>
76
- <Container>
77
- {debug && <DebugBox state={debug} lastAction={debug.lastAction} />}
78
- {taskDescription && (taskDescription || "").length > 1 && (
79
- <TaskDescription description={taskDescription} />
80
- )}
81
- {labelImages && (
82
- <TagsSidebarBox
83
- currentImage={currentImage}
84
- imageClsList={imageClsList}
85
- imageTagList={imageTagList}
86
- onChangeImage={onChangeImage}
87
- expandedByDefault
88
- />
89
- )}
90
- {/* {images && images.length > 1 && (
91
- <ImageSelector onSelect={onSelectImage} images={images} />
92
- )} */}
93
- <RegionSelector
94
- regions={regions}
95
- onSelectRegion={onSelectRegion}
96
- onChangeRegion={onChangeRegion}
97
- onDeleteRegion={onDeleteRegion}
98
- />
99
- {keyframes && (
100
- <KeyframesSelector
101
- currentVideoTime={currentVideoTime}
102
- keyframes={keyframes}
103
- onChangeVideoTime={onChangeVideoTime}
104
- onDeleteKeyframe={onDeleteKeyframe}
105
- />
106
- )}
107
- <History
108
- history={history}
109
- onRestoreHistory={() => onRestoreHistory()}
110
- />
111
- {/* <Shortcuts onShortcutActionDispatched={onShortcutActionDispatched} /> */}
112
- </Container>
113
- </ThemeProvider>
114
- )
115
- }
116
-
117
- export default Sidebar
@@ -1,93 +0,0 @@
1
- // @flow
2
-
3
- import React, { useState, memo } from "react"
4
- import Paper from "@mui/material/Paper"
5
- import { makeStyles } from "@mui/styles"
6
- import { createTheme, ThemeProvider } from "@mui/material/styles"
7
- import ExpandIcon from "@mui/icons-material/ExpandMore"
8
- import IconButton from "@mui/material/IconButton"
9
- import Collapse from "@mui/material/Collapse"
10
- import { grey } from "@mui/material/colors"
11
- import classnames from "classnames"
12
- import useEventCallback from "use-event-callback"
13
- import SidebarBox from "react-material-workspace-layout/SidebarBox"
14
-
15
- const theme = createTheme()
16
- const useStyles = makeStyles((theme) => ({
17
- container: { margin: 8 },
18
- header: {
19
- display: "flex",
20
- flexDirection: "row",
21
- alignItems: "center",
22
- padding: 8,
23
- paddingLeft: 16,
24
- paddingRight: 16,
25
- },
26
- title: {
27
- fontSize: 14,
28
- fontWeight: "bold",
29
- flexGrow: 1,
30
- paddingLeft: 8,
31
- color: grey[800],
32
- "& span": {
33
- color: grey[600],
34
- fontSize: 12,
35
- },
36
- },
37
- expandButton: {
38
- padding: 0,
39
- width: 30,
40
- height: 30,
41
- "& .icon": {
42
- marginTop: -6,
43
- width: 20,
44
- height: 20,
45
- transition: "500ms transform",
46
- "&.expanded": {
47
- transform: "rotate(180deg)",
48
- },
49
- },
50
- },
51
- expandedContent: {
52
- maxHeight: 300,
53
- overflowY: "auto",
54
- "&.noScroll": {
55
- overflowY: "visible",
56
- overflow: "visible",
57
- },
58
- },
59
- }))
60
-
61
- export const SidebarBoxContainer = ({
62
- icon,
63
- title,
64
- subTitle,
65
- children,
66
- noScroll = false,
67
- expandedByDefault = false,
68
- }) => {
69
- const classes = useStyles()
70
- const content = (
71
- <div
72
- className={classnames(classes.expandedContent, noScroll && "noScroll")}
73
- >
74
- {children}
75
- </div>
76
- )
77
-
78
- const [expanded, changeExpanded] = useState(expandedByDefault)
79
- const toggleExpanded = useEventCallback(() => changeExpanded(!expanded))
80
-
81
- return (
82
- <ThemeProvider theme={theme}>
83
- <SidebarBox icon={icon} title={title}>
84
- {children}
85
- </SidebarBox>
86
- </ThemeProvider>
87
- )
88
- }
89
-
90
- export default memo(
91
- SidebarBoxContainer,
92
- (prev, next) => prev.title === next.title && prev.children === next.children
93
- )
@@ -1,57 +0,0 @@
1
- // @flow
2
-
3
- import React, { createContext, useContext, memo } from "react"
4
- import IconButton from "@mui/material/IconButton"
5
- import Tooltip from "@mui/material/Tooltip"
6
- import { blue } from "@mui/material/colors"
7
-
8
- export const SelectedTool = createContext()
9
-
10
- export const SmallToolButton = ({
11
- id,
12
- name,
13
- icon,
14
- selected,
15
- togglable,
16
- alwaysShowing = false,
17
- }: {
18
- id: string,
19
- name: string,
20
- icon: any,
21
- alwaysShowing?: boolean,
22
- selected?: boolean,
23
- togglable?: boolean,
24
- }) => {
25
- const { enabledTools, selectedTool, onClickTool } = useContext(SelectedTool)
26
- if (!enabledTools.includes(id) && !alwaysShowing) return null
27
- selected = selected || selectedTool === id
28
- return (
29
- <Tooltip placement="right" title={name}>
30
- <div>
31
- <IconButton
32
- disabled={!togglable ? selected : undefined}
33
- aria-label={name}
34
- onClick={() => onClickTool(id)}
35
- size="small"
36
- style={{
37
- width: 50,
38
- height: 50,
39
- margin: 1,
40
- color: selected ? blue[500] : undefined,
41
- }}
42
- >
43
- {icon}
44
- </IconButton>
45
- </div>
46
- </Tooltip>
47
- )
48
- }
49
-
50
- export default memo(
51
- SmallToolButton,
52
- (prevProps, nextProps) =>
53
- prevProps.togglable === nextProps.togglable &&
54
- prevProps.selected === nextProps.selected &&
55
- prevProps.name === nextProps.name &&
56
- prevProps.id === nextProps.id
57
- )
@@ -1,93 +0,0 @@
1
- // @flow
2
-
3
- import React, { useMemo, memo } from "react"
4
- import SidebarBoxContainer from "../SidebarBoxContainer"
5
- import StyleIcon from "@mui/icons-material/Style"
6
- import { grey } from "@mui/material/colors"
7
- import Select from "react-select"
8
- import useEventCallback from "use-event-callback"
9
- import { asMutable } from "seamless-immutable"
10
-
11
- type Props = {
12
- tags: Array<string>,
13
- currentImage: { cls?: string, tags?: Array<string> },
14
- imageClsList?: Array<string>,
15
- imageTagList?: Array<string>,
16
- onChangeImage: (Array<string>) => any,
17
- }
18
-
19
- const emptyArr = []
20
- const noop = () => null
21
-
22
- export const TagsSidebarBox = ({
23
- currentImage,
24
- imageClsList = emptyArr,
25
- imageTagList = emptyArr,
26
- onChangeImage = noop,
27
- }: Props) => {
28
- const { tags = [], cls = null } = currentImage || {}
29
- const onChangeClassification = useEventCallback((o) =>
30
- onChangeImage({ cls: o.value })
31
- )
32
- const onChangeTags = useEventCallback((o) =>
33
- onChangeImage({ tags: o.map((a) => a.value) })
34
- )
35
- const selectValue = useMemo(
36
- () => (cls ? { value: cls, label: cls } : null),
37
- [cls]
38
- )
39
- const memoImgClsList = useMemo(
40
- () => asMutable(imageClsList.map((c) => ({ value: c, label: c }))),
41
- [imageClsList]
42
- )
43
- const memoImgTagList = useMemo(
44
- () => asMutable(imageTagList.map((c) => ({ value: c, label: c }))),
45
- [imageTagList]
46
- )
47
- const memoCurrentTags = useMemo(
48
- () => tags.map((r) => ({ value: r, label: r })),
49
- [tags]
50
- )
51
-
52
- if (!currentImage) return null
53
-
54
- return (
55
- <SidebarBoxContainer
56
- title="Image Tags"
57
- expandedByDefault
58
- noScroll
59
- icon={<StyleIcon style={{ color: grey[700] }} />}
60
- >
61
- {imageClsList.length > 0 && (
62
- <div style={{ padding: 8 }}>
63
- <Select
64
- placeholder="Image Classification"
65
- onChange={onChangeClassification}
66
- value={selectValue}
67
- options={memoImgClsList}
68
- />
69
- </div>
70
- )}
71
- {imageTagList.length > 0 && (
72
- <div style={{ padding: 8, paddingTop: 0 }}>
73
- <Select
74
- isMulti
75
- placeholder="Image Tags"
76
- onChange={onChangeTags}
77
- value={memoCurrentTags}
78
- options={memoImgTagList}
79
- />
80
- </div>
81
- )}
82
- </SidebarBoxContainer>
83
- )
84
- }
85
-
86
- export default memo(
87
- TagsSidebarBox,
88
- (prevProps, nextProps) =>
89
- prevProps.currentImage.cls === nextProps.currentImage.cls &&
90
- prevProps.currentImage.tags === nextProps.currentImage.tags &&
91
- prevProps.imageClsList === nextProps.imageClsList &&
92
- prevProps.imageTagList === nextProps.imageTagList
93
- )