react-image-annotate-master-custom 0.0.1
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.
- package/Annotator/index.js +164 -0
- package/Annotator/reducers/combine-reducers.js +14 -0
- package/Annotator/reducers/convert-expanding-line-to-polygon.js +73 -0
- package/Annotator/reducers/fix-twisted.js +4 -0
- package/Annotator/reducers/general-reducer.js +1073 -0
- package/Annotator/reducers/get-active-image.js +27 -0
- package/Annotator/reducers/get-implied-video-regions.js +180 -0
- package/Annotator/reducers/history-handler.js +38 -0
- package/Annotator/reducers/image-reducer.js +20 -0
- package/Annotator/reducers/video-reducer.js +88 -0
- package/ClassSelectionMenu/index.js +135 -0
- package/Crosshairs/index.js +53 -0
- package/DebugSidebarBox/index.js +20 -0
- package/DemoSite/Editor.js +194 -0
- package/DemoSite/ErrorBoundaryDialog.js +64 -0
- package/DemoSite/index.js +69 -0
- package/FullImageSegmentationAnnotator/index.js +7 -0
- package/HighlightBox/index.js +105 -0
- package/HistorySidebarBox/index.js +71 -0
- package/ImageCanvas/index.js +428 -0
- package/ImageCanvas/region-tools.js +165 -0
- package/ImageCanvas/styles.js +31 -0
- package/ImageCanvas/use-mouse.js +180 -0
- package/ImageCanvas/use-project-box.js +27 -0
- package/ImageCanvas/use-wasd-mode.js +62 -0
- package/ImageMask/index.js +133 -0
- package/ImageMask/load-image.js +25 -0
- package/ImageSelectorSidebarBox/index.js +60 -0
- package/KeyframeTimeline/get-time-string.js +27 -0
- package/KeyframeTimeline/index.js +233 -0
- package/KeyframesSelectorSidebarBox/index.js +93 -0
- package/LandingPage/index.js +159 -0
- package/MainLayout/icon-dictionary.js +104 -0
- package/MainLayout/index.js +359 -0
- package/MainLayout/styles.js +25 -0
- package/MainLayout/types.js +0 -0
- package/MainLayout/use-implied-video-regions.js +13 -0
- package/PointDistances/index.js +73 -0
- package/PreventScrollToParents/index.js +51 -0
- package/README.md +101 -0
- package/RegionLabel/index.js +197 -0
- package/RegionLabel/styles.js +48 -0
- package/RegionSelectAndTransformBoxes/index.js +166 -0
- package/RegionSelectorSidebarBox/index.js +248 -0
- package/RegionSelectorSidebarBox/styles.js +53 -0
- package/RegionShapes/index.js +275 -0
- package/RegionTags/index.js +138 -0
- package/SettingsDialog/index.js +52 -0
- package/SettingsProvider/index.js +53 -0
- package/Shortcuts/ShortcutField.js +46 -0
- package/Shortcuts/index.js +133 -0
- package/ShortcutsManager/index.js +155 -0
- package/Sidebar/index.js +69 -0
- package/SidebarBoxContainer/index.js +93 -0
- package/SmallToolButton/index.js +42 -0
- package/TagsSidebarBox/index.js +105 -0
- package/TaskDescriptionSidebarBox/index.js +58 -0
- package/Theme/index.js +30 -0
- package/VideoOrImageCanvasBackground/index.js +151 -0
- package/colors.js +14 -0
- package/hooks/use-event-callback.js +10 -0
- package/hooks/use-exclude-pattern.js +24 -0
- package/hooks/use-load-image.js +26 -0
- package/hooks/use-window-size.js +46 -0
- package/hooks/xpattern.js +1 -0
- package/index.js +3 -0
- package/lib.js +3 -0
- package/package.json +91 -0
- package/stories.js +5 -0
- package/utils/get-from-local-storage.js +7 -0
- package/utils/get-hotkey-help-text.js +9 -0
- package/utils/get-landmarks-with-transform.js +40 -0
- package/utils/set-in-local-storage.js +3 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import React, { useState, useEffect } from "react";
|
|
4
|
+
import SidebarBoxContainer from "../SidebarBoxContainer";
|
|
5
|
+
import { setIn } from "seamless-immutable";
|
|
6
|
+
import ShortcutField from "./ShortcutField";
|
|
7
|
+
var defaultShortcuts = {
|
|
8
|
+
select: {
|
|
9
|
+
action: {
|
|
10
|
+
type: "SELECT_TOOL"
|
|
11
|
+
},
|
|
12
|
+
name: "Select Region",
|
|
13
|
+
key: "Escape"
|
|
14
|
+
},
|
|
15
|
+
zoom: {
|
|
16
|
+
action: {
|
|
17
|
+
type: "SELECT_TOOL"
|
|
18
|
+
},
|
|
19
|
+
name: "Zoom In/Out",
|
|
20
|
+
key: "z"
|
|
21
|
+
},
|
|
22
|
+
"create-point": {
|
|
23
|
+
action: {
|
|
24
|
+
type: "SELECT_TOOL"
|
|
25
|
+
},
|
|
26
|
+
name: "Create Point"
|
|
27
|
+
},
|
|
28
|
+
"create-box": {
|
|
29
|
+
action: {
|
|
30
|
+
type: "SELECT_TOOL"
|
|
31
|
+
},
|
|
32
|
+
name: "Add Bounding Box",
|
|
33
|
+
key: "b"
|
|
34
|
+
},
|
|
35
|
+
pan: {
|
|
36
|
+
action: {
|
|
37
|
+
type: "SELECT_TOOL"
|
|
38
|
+
},
|
|
39
|
+
name: "Pan"
|
|
40
|
+
},
|
|
41
|
+
"create-polygon": {
|
|
42
|
+
action: {
|
|
43
|
+
type: "SELECT_TOOL"
|
|
44
|
+
},
|
|
45
|
+
name: "Create Polygon"
|
|
46
|
+
},
|
|
47
|
+
"create-pixel": {
|
|
48
|
+
action: {
|
|
49
|
+
type: "SELECT_TOOL"
|
|
50
|
+
},
|
|
51
|
+
name: "Create Pixel"
|
|
52
|
+
},
|
|
53
|
+
"prev-image": {
|
|
54
|
+
action: {
|
|
55
|
+
type: "HEADER_BUTTON_CLICKED",
|
|
56
|
+
buttonName: "Prev"
|
|
57
|
+
},
|
|
58
|
+
name: "Previous Image",
|
|
59
|
+
key: "a"
|
|
60
|
+
},
|
|
61
|
+
"next-image": {
|
|
62
|
+
action: {
|
|
63
|
+
type: "HEADER_BUTTON_CLICKED",
|
|
64
|
+
buttonName: "Next"
|
|
65
|
+
},
|
|
66
|
+
name: "Next Image",
|
|
67
|
+
key: "d" //"ArrowRight"
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
export default (function (_ref) {
|
|
72
|
+
var onShortcutActionDispatched = _ref.onShortcutActionDispatched;
|
|
73
|
+
|
|
74
|
+
var _useState = useState({}),
|
|
75
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
76
|
+
shortcuts = _useState2[0],
|
|
77
|
+
setShortcuts = _useState2[1]; // useLocalStorage
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
useEffect(function () {
|
|
81
|
+
var newShortcuts = _objectSpread({}, shortcuts);
|
|
82
|
+
|
|
83
|
+
for (var _i = 0, _Object$keys = Object.keys(defaultShortcuts); _i < _Object$keys.length; _i++) {
|
|
84
|
+
var actionId = _Object$keys[_i];
|
|
85
|
+
|
|
86
|
+
if (!newShortcuts[actionId]) {
|
|
87
|
+
newShortcuts[actionId] = defaultShortcuts[actionId];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
setShortcuts(newShortcuts);
|
|
92
|
+
}, []);
|
|
93
|
+
|
|
94
|
+
var onChangeShortcut = function onChangeShortcut(actionId, keyName) {
|
|
95
|
+
setShortcuts(setIn(shortcuts, [actionId, "key"], keyName));
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
useEffect(function () {
|
|
99
|
+
var handleKeyPress = function handleKeyPress(e) {
|
|
100
|
+
for (var actionId in shortcuts) {
|
|
101
|
+
var shortcut = shortcuts[actionId];
|
|
102
|
+
|
|
103
|
+
if (!shortcut || !shortcut.key) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (e.key === shortcut.key) {
|
|
108
|
+
onShortcutActionDispatched(_objectSpread({}, shortcut.action, {
|
|
109
|
+
selectedTool: actionId
|
|
110
|
+
}));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
window.addEventListener("keypress", handleKeyPress);
|
|
116
|
+
return function () {
|
|
117
|
+
window.removeEventListener("keypress", handleKeyPress);
|
|
118
|
+
document.activeElement.blur();
|
|
119
|
+
};
|
|
120
|
+
}, [shortcuts]);
|
|
121
|
+
return React.createElement(SidebarBoxContainer, {
|
|
122
|
+
title: "Shortcuts"
|
|
123
|
+
}, Object.keys(shortcuts).map(function (actionId, index) {
|
|
124
|
+
if (!shortcuts[actionId]) return null;
|
|
125
|
+
return React.createElement(ShortcutField, {
|
|
126
|
+
key: actionId,
|
|
127
|
+
actionId: actionId,
|
|
128
|
+
actionName: shortcuts[actionId].name,
|
|
129
|
+
keyName: shortcuts[actionId].key || "",
|
|
130
|
+
onChangeShortcut: onChangeShortcut
|
|
131
|
+
});
|
|
132
|
+
}).filter(Boolean));
|
|
133
|
+
});
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
|
+
import { HotKeys } from "react-hotkeys";
|
|
3
|
+
export var defaultHotkeys = [{
|
|
4
|
+
id: "select_tool",
|
|
5
|
+
description: "Switch to the Select Tool",
|
|
6
|
+
binding: "escape"
|
|
7
|
+
}, {
|
|
8
|
+
id: "zoom_tool",
|
|
9
|
+
description: "Select the Zoom Tool",
|
|
10
|
+
binding: "z"
|
|
11
|
+
}, {
|
|
12
|
+
id: "create_point",
|
|
13
|
+
description: "Create a point"
|
|
14
|
+
}, {
|
|
15
|
+
id: "create_bounding_box",
|
|
16
|
+
description: "Create a bounding box",
|
|
17
|
+
binding: "b"
|
|
18
|
+
}, {
|
|
19
|
+
id: "pan_tool",
|
|
20
|
+
description: "Select the Pan Tool",
|
|
21
|
+
binding: "m"
|
|
22
|
+
}, {
|
|
23
|
+
id: "create_polygon",
|
|
24
|
+
description: "Create a Polygon",
|
|
25
|
+
binding: "p"
|
|
26
|
+
}, {
|
|
27
|
+
id: "create_pixel",
|
|
28
|
+
description: "Create a Pixel Mask"
|
|
29
|
+
}, {
|
|
30
|
+
id: "save_and_previous_sample",
|
|
31
|
+
description: "Save and go to previous sample",
|
|
32
|
+
binding: "ArrowLeft"
|
|
33
|
+
}, {
|
|
34
|
+
id: "save_and_next_sample",
|
|
35
|
+
description: "Save and go to next sample",
|
|
36
|
+
binding: "ArrowRight"
|
|
37
|
+
}, {
|
|
38
|
+
id: "save_and_exit_sample",
|
|
39
|
+
description: "Save and exit current sample"
|
|
40
|
+
}, {
|
|
41
|
+
id: "exit_sample",
|
|
42
|
+
description: "Exit sample without saving"
|
|
43
|
+
}, {
|
|
44
|
+
id: "delete_region",
|
|
45
|
+
description: "Delete selected region",
|
|
46
|
+
binding: "d"
|
|
47
|
+
}, {
|
|
48
|
+
id: "undo",
|
|
49
|
+
description: "Undo latest change",
|
|
50
|
+
binding: "Ctrl+z"
|
|
51
|
+
}];
|
|
52
|
+
export var defaultKeyMap = {};
|
|
53
|
+
|
|
54
|
+
for (var _i = 0, _defaultHotkeys = defaultHotkeys; _i < _defaultHotkeys.length; _i++) {
|
|
55
|
+
var _ref4 = _defaultHotkeys[_i];
|
|
56
|
+
var id = _ref4.id;
|
|
57
|
+
var binding = _ref4.binding;
|
|
58
|
+
defaultKeyMap[id] = binding;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export var useDispatchHotkeyHandlers = function useDispatchHotkeyHandlers(_ref2) {
|
|
62
|
+
var dispatch = _ref2.dispatch;
|
|
63
|
+
var handlers = useMemo(function () {
|
|
64
|
+
return {
|
|
65
|
+
select_tool: function select_tool() {
|
|
66
|
+
dispatch({
|
|
67
|
+
type: "SELECT_TOOL",
|
|
68
|
+
selectedTool: "select"
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
zoom_tool: function zoom_tool() {
|
|
72
|
+
dispatch({
|
|
73
|
+
type: "SELECT_TOOL",
|
|
74
|
+
selectedTool: "zoom"
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
create_point: function create_point() {
|
|
78
|
+
dispatch({
|
|
79
|
+
type: "SELECT_TOOL",
|
|
80
|
+
selectedTool: "create-point"
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
create_bounding_box: function create_bounding_box() {
|
|
84
|
+
dispatch({
|
|
85
|
+
type: "SELECT_TOOL",
|
|
86
|
+
selectedTool: "create-box"
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
pan_tool: function pan_tool() {
|
|
90
|
+
dispatch({
|
|
91
|
+
type: "SELECT_TOOL",
|
|
92
|
+
selectedTool: "pan"
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
create_polygon: function create_polygon() {
|
|
96
|
+
dispatch({
|
|
97
|
+
type: "SELECT_TOOL",
|
|
98
|
+
selectedTool: "create-polygon"
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
create_pixel: function create_pixel() {
|
|
102
|
+
dispatch({
|
|
103
|
+
type: "SELECT_TOOL",
|
|
104
|
+
selectedTool: "create-pixel"
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
save_and_previous_sample: function save_and_previous_sample() {
|
|
108
|
+
dispatch({
|
|
109
|
+
type: "HEADER_BUTTON_CLICKED",
|
|
110
|
+
buttonName: "Prev"
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
save_and_next_sample: function save_and_next_sample() {
|
|
114
|
+
dispatch({
|
|
115
|
+
type: "HEADER_BUTTON_CLICKED",
|
|
116
|
+
buttonName: "Next"
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
save_and_exit_sample: function save_and_exit_sample() {
|
|
120
|
+
dispatch({
|
|
121
|
+
type: "HEADER_BUTTON_CLICKED",
|
|
122
|
+
buttonName: "Save"
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
delete_region: function delete_region() {
|
|
126
|
+
dispatch({
|
|
127
|
+
type: "DELETE_SELECTED_REGION"
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
undo: function undo() {
|
|
131
|
+
dispatch({
|
|
132
|
+
type: "RESTORE_HISTORY"
|
|
133
|
+
});
|
|
134
|
+
} // TODO
|
|
135
|
+
// exit_sample: () => {
|
|
136
|
+
// dispatch({
|
|
137
|
+
// type: "",
|
|
138
|
+
// })
|
|
139
|
+
// }
|
|
140
|
+
|
|
141
|
+
};
|
|
142
|
+
}, [dispatch]);
|
|
143
|
+
return handlers;
|
|
144
|
+
};
|
|
145
|
+
export default (function (_ref3) {
|
|
146
|
+
var children = _ref3.children,
|
|
147
|
+
dispatch = _ref3.dispatch;
|
|
148
|
+
var handlers = useDispatchHotkeyHandlers({
|
|
149
|
+
dispatch: dispatch
|
|
150
|
+
});
|
|
151
|
+
return React.createElement(HotKeys, {
|
|
152
|
+
allowChanges: true,
|
|
153
|
+
handlers: handlers
|
|
154
|
+
}, children);
|
|
155
|
+
});
|
package/Sidebar/index.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { styled } from "@mui/styles";
|
|
3
|
+
import { createTheme, ThemeProvider } from "@mui/material/styles";
|
|
4
|
+
import TaskDescription from "../TaskDescriptionSidebarBox";
|
|
5
|
+
import ImageSelector from "../ImageSelectorSidebarBox";
|
|
6
|
+
import RegionSelector from "../RegionSelectorSidebarBox";
|
|
7
|
+
import History from "../HistorySidebarBox";
|
|
8
|
+
import DebugBox from "../DebugSidebarBox";
|
|
9
|
+
import TagsSidebarBox from "../TagsSidebarBox";
|
|
10
|
+
import KeyframesSelector from "../KeyframesSelectorSidebarBox";
|
|
11
|
+
var theme = createTheme();
|
|
12
|
+
var Container = styled("div")(function (_ref) {
|
|
13
|
+
var theme = _ref.theme;
|
|
14
|
+
return {};
|
|
15
|
+
});
|
|
16
|
+
var emptyArr = [];
|
|
17
|
+
export var Sidebar = function Sidebar(_ref2) {
|
|
18
|
+
var debug = _ref2.debug,
|
|
19
|
+
taskDescription = _ref2.taskDescription,
|
|
20
|
+
keyframes = _ref2.keyframes,
|
|
21
|
+
images = _ref2.images,
|
|
22
|
+
regions = _ref2.regions,
|
|
23
|
+
history = _ref2.history,
|
|
24
|
+
labelImages = _ref2.labelImages,
|
|
25
|
+
currentImage = _ref2.currentImage,
|
|
26
|
+
currentVideoTime = _ref2.currentVideoTime,
|
|
27
|
+
imageClsList = _ref2.imageClsList,
|
|
28
|
+
imageTagList = _ref2.imageTagList,
|
|
29
|
+
onChangeImage = _ref2.onChangeImage,
|
|
30
|
+
onSelectRegion = _ref2.onSelectRegion,
|
|
31
|
+
onSelectImage = _ref2.onSelectImage,
|
|
32
|
+
onChangeRegion = _ref2.onChangeRegion,
|
|
33
|
+
onDeleteRegion = _ref2.onDeleteRegion,
|
|
34
|
+
_onRestoreHistory = _ref2.onRestoreHistory,
|
|
35
|
+
onChangeVideoTime = _ref2.onChangeVideoTime,
|
|
36
|
+
onDeleteKeyframe = _ref2.onDeleteKeyframe,
|
|
37
|
+
onShortcutActionDispatched = _ref2.onShortcutActionDispatched;
|
|
38
|
+
if (!regions) regions = emptyArr;
|
|
39
|
+
return React.createElement(ThemeProvider, {
|
|
40
|
+
theme: theme
|
|
41
|
+
}, React.createElement(Container, null, debug && React.createElement(DebugBox, {
|
|
42
|
+
state: debug,
|
|
43
|
+
lastAction: debug.lastAction
|
|
44
|
+
}), taskDescription && (taskDescription || "").length > 1 && React.createElement(TaskDescription, {
|
|
45
|
+
description: taskDescription
|
|
46
|
+
}), labelImages && React.createElement(TagsSidebarBox, {
|
|
47
|
+
currentImage: currentImage,
|
|
48
|
+
imageClsList: imageClsList,
|
|
49
|
+
imageTagList: imageTagList,
|
|
50
|
+
onChangeImage: onChangeImage,
|
|
51
|
+
expandedByDefault: true
|
|
52
|
+
}), React.createElement(RegionSelector, {
|
|
53
|
+
regions: regions,
|
|
54
|
+
onSelectRegion: onSelectRegion,
|
|
55
|
+
onChangeRegion: onChangeRegion,
|
|
56
|
+
onDeleteRegion: onDeleteRegion
|
|
57
|
+
}), keyframes && React.createElement(KeyframesSelector, {
|
|
58
|
+
currentVideoTime: currentVideoTime,
|
|
59
|
+
keyframes: keyframes,
|
|
60
|
+
onChangeVideoTime: onChangeVideoTime,
|
|
61
|
+
onDeleteKeyframe: onDeleteKeyframe
|
|
62
|
+
}), React.createElement(History, {
|
|
63
|
+
history: history,
|
|
64
|
+
onRestoreHistory: function onRestoreHistory() {
|
|
65
|
+
return _onRestoreHistory();
|
|
66
|
+
}
|
|
67
|
+
})));
|
|
68
|
+
};
|
|
69
|
+
export default Sidebar;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import React, { useState, memo } from "react";
|
|
3
|
+
import Paper from "@mui/material/Paper";
|
|
4
|
+
import { makeStyles } from "@mui/styles";
|
|
5
|
+
import { createTheme, ThemeProvider } from "@mui/material/styles";
|
|
6
|
+
import ExpandIcon from "@mui/icons-material/ExpandMore";
|
|
7
|
+
import IconButton from "@mui/material/IconButton";
|
|
8
|
+
import Collapse from "@mui/material/Collapse";
|
|
9
|
+
import { grey } from "@mui/material/colors";
|
|
10
|
+
import classnames from "classnames";
|
|
11
|
+
import useEventCallback from "use-event-callback";
|
|
12
|
+
import SidebarBox from "react-material-workspace-layout/SidebarBox";
|
|
13
|
+
var theme = createTheme();
|
|
14
|
+
var useStyles = makeStyles(function (theme) {
|
|
15
|
+
return {
|
|
16
|
+
container: {
|
|
17
|
+
margin: 8
|
|
18
|
+
},
|
|
19
|
+
header: {
|
|
20
|
+
display: "flex",
|
|
21
|
+
flexDirection: "row",
|
|
22
|
+
alignItems: "center",
|
|
23
|
+
padding: 8,
|
|
24
|
+
paddingLeft: 16,
|
|
25
|
+
paddingRight: 16
|
|
26
|
+
},
|
|
27
|
+
title: {
|
|
28
|
+
fontSize: 14,
|
|
29
|
+
fontWeight: "bold",
|
|
30
|
+
flexGrow: 1,
|
|
31
|
+
paddingLeft: 8,
|
|
32
|
+
color: grey[800],
|
|
33
|
+
"& span": {
|
|
34
|
+
color: grey[600],
|
|
35
|
+
fontSize: 12
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
expandButton: {
|
|
39
|
+
padding: 0,
|
|
40
|
+
width: 30,
|
|
41
|
+
height: 30,
|
|
42
|
+
"& .icon": {
|
|
43
|
+
marginTop: -6,
|
|
44
|
+
width: 20,
|
|
45
|
+
height: 20,
|
|
46
|
+
transition: "500ms transform",
|
|
47
|
+
"&.expanded": {
|
|
48
|
+
transform: "rotate(180deg)"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
expandedContent: {
|
|
53
|
+
maxHeight: 300,
|
|
54
|
+
overflowY: "auto",
|
|
55
|
+
"&.noScroll": {
|
|
56
|
+
overflowY: "visible",
|
|
57
|
+
overflow: "visible"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
export var SidebarBoxContainer = function SidebarBoxContainer(_ref) {
|
|
63
|
+
var icon = _ref.icon,
|
|
64
|
+
title = _ref.title,
|
|
65
|
+
subTitle = _ref.subTitle,
|
|
66
|
+
children = _ref.children,
|
|
67
|
+
_ref$noScroll = _ref.noScroll,
|
|
68
|
+
noScroll = _ref$noScroll === void 0 ? false : _ref$noScroll,
|
|
69
|
+
_ref$expandedByDefaul = _ref.expandedByDefault,
|
|
70
|
+
expandedByDefault = _ref$expandedByDefaul === void 0 ? false : _ref$expandedByDefaul;
|
|
71
|
+
var classes = useStyles();
|
|
72
|
+
var content = React.createElement("div", {
|
|
73
|
+
className: classnames(classes.expandedContent, noScroll && "noScroll")
|
|
74
|
+
}, children);
|
|
75
|
+
|
|
76
|
+
var _useState = useState(expandedByDefault),
|
|
77
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
78
|
+
expanded = _useState2[0],
|
|
79
|
+
changeExpanded = _useState2[1];
|
|
80
|
+
|
|
81
|
+
var toggleExpanded = useEventCallback(function () {
|
|
82
|
+
return changeExpanded(!expanded);
|
|
83
|
+
});
|
|
84
|
+
return React.createElement(ThemeProvider, {
|
|
85
|
+
theme: theme
|
|
86
|
+
}, React.createElement(SidebarBox, {
|
|
87
|
+
icon: icon,
|
|
88
|
+
title: title
|
|
89
|
+
}, children));
|
|
90
|
+
};
|
|
91
|
+
export default memo(SidebarBoxContainer, function (prev, next) {
|
|
92
|
+
return prev.title === next.title && prev.children === next.children;
|
|
93
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { createContext, useContext, memo } from "react";
|
|
2
|
+
import IconButton from "@mui/material/IconButton";
|
|
3
|
+
import Tooltip from "@mui/material/Tooltip";
|
|
4
|
+
import { blue } from "@mui/material/colors";
|
|
5
|
+
export var SelectedTool = createContext();
|
|
6
|
+
export var SmallToolButton = function SmallToolButton(_ref) {
|
|
7
|
+
var id = _ref.id,
|
|
8
|
+
name = _ref.name,
|
|
9
|
+
icon = _ref.icon,
|
|
10
|
+
selected = _ref.selected,
|
|
11
|
+
togglable = _ref.togglable,
|
|
12
|
+
_ref$alwaysShowing = _ref.alwaysShowing,
|
|
13
|
+
alwaysShowing = _ref$alwaysShowing === void 0 ? false : _ref$alwaysShowing;
|
|
14
|
+
|
|
15
|
+
var _useContext = useContext(SelectedTool),
|
|
16
|
+
enabledTools = _useContext.enabledTools,
|
|
17
|
+
selectedTool = _useContext.selectedTool,
|
|
18
|
+
onClickTool = _useContext.onClickTool;
|
|
19
|
+
|
|
20
|
+
if (!enabledTools.includes(id) && !alwaysShowing) return null;
|
|
21
|
+
selected = selected || selectedTool === id;
|
|
22
|
+
return React.createElement(Tooltip, {
|
|
23
|
+
placement: "right",
|
|
24
|
+
title: name
|
|
25
|
+
}, React.createElement("div", null, React.createElement(IconButton, {
|
|
26
|
+
disabled: !togglable ? selected : undefined,
|
|
27
|
+
"aria-label": name,
|
|
28
|
+
onClick: function onClick() {
|
|
29
|
+
return onClickTool(id);
|
|
30
|
+
},
|
|
31
|
+
size: "small",
|
|
32
|
+
style: {
|
|
33
|
+
width: 50,
|
|
34
|
+
height: 50,
|
|
35
|
+
margin: 1,
|
|
36
|
+
color: selected ? blue[500] : undefined
|
|
37
|
+
}
|
|
38
|
+
}, icon)));
|
|
39
|
+
};
|
|
40
|
+
export default memo(SmallToolButton, function (prevProps, nextProps) {
|
|
41
|
+
return prevProps.togglable === nextProps.togglable && prevProps.selected === nextProps.selected && prevProps.name === nextProps.name && prevProps.id === nextProps.id;
|
|
42
|
+
});
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import React, { useMemo, memo } from "react";
|
|
2
|
+
import SidebarBoxContainer from "../SidebarBoxContainer";
|
|
3
|
+
import StyleIcon from "@mui/icons-material/Style";
|
|
4
|
+
import { grey } from "@mui/material/colors";
|
|
5
|
+
import Select from "react-select";
|
|
6
|
+
import useEventCallback from "use-event-callback";
|
|
7
|
+
import { asMutable } from "seamless-immutable";
|
|
8
|
+
var emptyArr = [];
|
|
9
|
+
|
|
10
|
+
var noop = function noop() {
|
|
11
|
+
return null;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export var TagsSidebarBox = function TagsSidebarBox(_ref) {
|
|
15
|
+
var currentImage = _ref.currentImage,
|
|
16
|
+
_ref$imageClsList = _ref.imageClsList,
|
|
17
|
+
imageClsList = _ref$imageClsList === void 0 ? emptyArr : _ref$imageClsList,
|
|
18
|
+
_ref$imageTagList = _ref.imageTagList,
|
|
19
|
+
imageTagList = _ref$imageTagList === void 0 ? emptyArr : _ref$imageTagList,
|
|
20
|
+
_ref$onChangeImage = _ref.onChangeImage,
|
|
21
|
+
onChangeImage = _ref$onChangeImage === void 0 ? noop : _ref$onChangeImage;
|
|
22
|
+
|
|
23
|
+
var _ref2 = currentImage || {},
|
|
24
|
+
_ref2$tags = _ref2.tags,
|
|
25
|
+
tags = _ref2$tags === void 0 ? [] : _ref2$tags,
|
|
26
|
+
_ref2$cls = _ref2.cls,
|
|
27
|
+
cls = _ref2$cls === void 0 ? null : _ref2$cls;
|
|
28
|
+
|
|
29
|
+
var onChangeClassification = useEventCallback(function (o) {
|
|
30
|
+
return onChangeImage({
|
|
31
|
+
cls: o.value
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
var onChangeTags = useEventCallback(function (o) {
|
|
35
|
+
return onChangeImage({
|
|
36
|
+
tags: o.map(function (a) {
|
|
37
|
+
return a.value;
|
|
38
|
+
})
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
var selectValue = useMemo(function () {
|
|
42
|
+
return cls ? {
|
|
43
|
+
value: cls,
|
|
44
|
+
label: cls
|
|
45
|
+
} : null;
|
|
46
|
+
}, [cls]);
|
|
47
|
+
var memoImgClsList = useMemo(function () {
|
|
48
|
+
return asMutable(imageClsList.map(function (c) {
|
|
49
|
+
return {
|
|
50
|
+
value: c,
|
|
51
|
+
label: c
|
|
52
|
+
};
|
|
53
|
+
}));
|
|
54
|
+
}, [imageClsList]);
|
|
55
|
+
var memoImgTagList = useMemo(function () {
|
|
56
|
+
return asMutable(imageTagList.map(function (c) {
|
|
57
|
+
return {
|
|
58
|
+
value: c,
|
|
59
|
+
label: c
|
|
60
|
+
};
|
|
61
|
+
}));
|
|
62
|
+
}, [imageTagList]);
|
|
63
|
+
var memoCurrentTags = useMemo(function () {
|
|
64
|
+
return tags.map(function (r) {
|
|
65
|
+
return {
|
|
66
|
+
value: r,
|
|
67
|
+
label: r
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
}, [tags]);
|
|
71
|
+
if (!currentImage) return null;
|
|
72
|
+
return React.createElement(SidebarBoxContainer, {
|
|
73
|
+
title: "Image Tags",
|
|
74
|
+
expandedByDefault: true,
|
|
75
|
+
noScroll: true,
|
|
76
|
+
icon: React.createElement(StyleIcon, {
|
|
77
|
+
style: {
|
|
78
|
+
color: grey[700]
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
}, imageClsList.length > 0 && React.createElement("div", {
|
|
82
|
+
style: {
|
|
83
|
+
padding: 8
|
|
84
|
+
}
|
|
85
|
+
}, React.createElement(Select, {
|
|
86
|
+
placeholder: "Image Classification",
|
|
87
|
+
onChange: onChangeClassification,
|
|
88
|
+
value: selectValue,
|
|
89
|
+
options: memoImgClsList
|
|
90
|
+
})), imageTagList.length > 0 && React.createElement("div", {
|
|
91
|
+
style: {
|
|
92
|
+
padding: 8,
|
|
93
|
+
paddingTop: 0
|
|
94
|
+
}
|
|
95
|
+
}, React.createElement(Select, {
|
|
96
|
+
isMulti: true,
|
|
97
|
+
placeholder: "Image Tags",
|
|
98
|
+
onChange: onChangeTags,
|
|
99
|
+
value: memoCurrentTags,
|
|
100
|
+
options: memoImgTagList
|
|
101
|
+
})));
|
|
102
|
+
};
|
|
103
|
+
export default memo(TagsSidebarBox, function (prevProps, nextProps) {
|
|
104
|
+
return prevProps.currentImage.cls === nextProps.currentImage.cls && prevProps.currentImage.tags === nextProps.currentImage.tags && prevProps.imageClsList === nextProps.imageClsList && prevProps.imageTagList === nextProps.imageTagList;
|
|
105
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React, { memo } from "react";
|
|
2
|
+
import SidebarBoxContainer from "../SidebarBoxContainer";
|
|
3
|
+
import DescriptionIcon from "@mui/icons-material/Description";
|
|
4
|
+
import { styled } from "@mui/material/styles";
|
|
5
|
+
import { createTheme, ThemeProvider } from "@mui/material/styles";
|
|
6
|
+
import { grey } from "@mui/material/colors";
|
|
7
|
+
import Markdown from "react-markdown";
|
|
8
|
+
var theme = createTheme();
|
|
9
|
+
var MarkdownContainer = styled("div")(function (_ref) {
|
|
10
|
+
var theme = _ref.theme;
|
|
11
|
+
return {
|
|
12
|
+
paddingLeft: 16,
|
|
13
|
+
paddingRight: 16,
|
|
14
|
+
fontSize: 12,
|
|
15
|
+
"& h1": {
|
|
16
|
+
fontSize: 18
|
|
17
|
+
},
|
|
18
|
+
"& h2": {
|
|
19
|
+
fontSize: 14
|
|
20
|
+
},
|
|
21
|
+
"& h3": {
|
|
22
|
+
fontSize: 12
|
|
23
|
+
},
|
|
24
|
+
"& h4": {
|
|
25
|
+
fontSize: 12
|
|
26
|
+
},
|
|
27
|
+
"& h5": {
|
|
28
|
+
fontSize: 12
|
|
29
|
+
},
|
|
30
|
+
"& h6": {
|
|
31
|
+
fontSize: 12
|
|
32
|
+
},
|
|
33
|
+
"& p": {
|
|
34
|
+
fontSize: 12
|
|
35
|
+
},
|
|
36
|
+
"& a": {},
|
|
37
|
+
"& img": {
|
|
38
|
+
width: "100%"
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
export var TaskDescriptionSidebarBox = function TaskDescriptionSidebarBox(_ref2) {
|
|
43
|
+
var description = _ref2.description;
|
|
44
|
+
return React.createElement(ThemeProvider, {
|
|
45
|
+
theme: theme
|
|
46
|
+
}, React.createElement(SidebarBoxContainer, {
|
|
47
|
+
title: "Task Description",
|
|
48
|
+
icon: React.createElement(DescriptionIcon, {
|
|
49
|
+
style: {
|
|
50
|
+
color: grey[700]
|
|
51
|
+
}
|
|
52
|
+
}),
|
|
53
|
+
expandedByDefault: description && description !== "" ? false : true
|
|
54
|
+
}, React.createElement(MarkdownContainer, null, React.createElement(Markdown, {
|
|
55
|
+
source: description
|
|
56
|
+
}))));
|
|
57
|
+
};
|
|
58
|
+
export default memo(TaskDescriptionSidebarBox);
|
package/Theme/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ThemeProvider, createTheme } from "@mui/material/styles";
|
|
3
|
+
import { makeStyles } from "@mui/styles";
|
|
4
|
+
var useStyles = makeStyles(function (theme) {
|
|
5
|
+
return {
|
|
6
|
+
container: {
|
|
7
|
+
fontFamily: '"Inter", sans-serif'
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
});
|
|
11
|
+
var theme = createTheme({
|
|
12
|
+
typography: {
|
|
13
|
+
fontFamily: '"Inter", "Roboto", sans-serif'
|
|
14
|
+
},
|
|
15
|
+
overrides: {
|
|
16
|
+
MuiButton: {
|
|
17
|
+
root: {
|
|
18
|
+
textTransform: "none"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
export var Theme = function Theme(_ref) {
|
|
24
|
+
var children = _ref.children;
|
|
25
|
+
var classes = useStyles();
|
|
26
|
+
return React.createElement(ThemeProvider, {
|
|
27
|
+
theme: theme
|
|
28
|
+
}, React.createElement("div", null, children));
|
|
29
|
+
};
|
|
30
|
+
export default Theme;
|