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,194 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import React, { useState } from "react";
|
|
3
|
+
import Button from "@mui/material/Button";
|
|
4
|
+
import { makeStyles } from "@mui/styles";
|
|
5
|
+
import { createTheme, ThemeProvider } from "@mui/material/styles";
|
|
6
|
+
import Select from "react-select";
|
|
7
|
+
import Code from "react-syntax-highlighter";
|
|
8
|
+
import Dialog from "@mui/material/Dialog";
|
|
9
|
+
import DialogTitle from "@mui/material/DialogTitle";
|
|
10
|
+
import DialogContent from "@mui/material/DialogContent";
|
|
11
|
+
import DialogActions from "@mui/material/DialogActions";
|
|
12
|
+
import MonacoEditor from "react-monaco-editor";
|
|
13
|
+
var theme = createTheme();
|
|
14
|
+
var useStyles = makeStyles(function (theme) {
|
|
15
|
+
return {
|
|
16
|
+
editBar: {
|
|
17
|
+
padding: 10,
|
|
18
|
+
borderBottom: "1px solid #ccc",
|
|
19
|
+
backgroundColor: "#f8f8f8",
|
|
20
|
+
display: "flex",
|
|
21
|
+
alignItems: "center",
|
|
22
|
+
"& .button": {
|
|
23
|
+
margin: 5
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
select: {
|
|
27
|
+
width: 240,
|
|
28
|
+
fontSize: 14
|
|
29
|
+
},
|
|
30
|
+
contentArea: {
|
|
31
|
+
padding: 10
|
|
32
|
+
},
|
|
33
|
+
specificationArea: {
|
|
34
|
+
padding: 10
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
var loadSavedInput = function loadSavedInput() {
|
|
40
|
+
try {
|
|
41
|
+
return JSON.parse(window.localStorage.getItem("customInput") || "{}");
|
|
42
|
+
} catch (e) {
|
|
43
|
+
return {};
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export var examples = {
|
|
48
|
+
"Simple Bounding Box": function SimpleBoundingBox() {
|
|
49
|
+
return {
|
|
50
|
+
taskDescription: "Annotate each image according to this _markdown_ specification.",
|
|
51
|
+
// regionTagList: [],
|
|
52
|
+
// regionClsList: ["hotdog"],
|
|
53
|
+
regionTagList: ["has-bun"],
|
|
54
|
+
regionClsList: ["hotdog", "not-hotdog"],
|
|
55
|
+
enabledTools: ["select", "create-box"],
|
|
56
|
+
// showTags: true,
|
|
57
|
+
images: [{
|
|
58
|
+
src: "https://images.unsplash.com/photo-1496905583330-eb54c7e5915a?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=634&q=80",
|
|
59
|
+
name: "hot-dogs-1"
|
|
60
|
+
}, {
|
|
61
|
+
src: "https://www.bianchi.com/wp-content/uploads/2019/07/YPB17I555K.jpg",
|
|
62
|
+
name: "bianchi-oltre-xr4"
|
|
63
|
+
}],
|
|
64
|
+
allowComments: true
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
"Simple Segmentation": function SimpleSegmentation() {
|
|
68
|
+
return {
|
|
69
|
+
taskDescription: "Annotate each image according to this _markdown_ specification.",
|
|
70
|
+
regionClsList: ["car", "truck"],
|
|
71
|
+
enabledTools: ["select", "create-polygon"],
|
|
72
|
+
images: [{
|
|
73
|
+
src: "https://images.unsplash.com/photo-1561518776-e76a5e48f731?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80",
|
|
74
|
+
name: "car-image-1"
|
|
75
|
+
}]
|
|
76
|
+
};
|
|
77
|
+
},
|
|
78
|
+
Custom: function Custom() {
|
|
79
|
+
return loadSavedInput();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
var Editor = function Editor(_ref) {
|
|
84
|
+
var onOpenAnnotator = _ref.onOpenAnnotator,
|
|
85
|
+
lastOutput = _ref.lastOutput;
|
|
86
|
+
var c = useStyles();
|
|
87
|
+
|
|
88
|
+
var _useState = useState(),
|
|
89
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
90
|
+
currentError = _useState2[0],
|
|
91
|
+
changeCurrentError = _useState2[1];
|
|
92
|
+
|
|
93
|
+
var _useState3 = useState(window.localStorage.getItem("customInput") ? "Custom" : "Simple Bounding Box"),
|
|
94
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
95
|
+
selectedExample = _useState4[0],
|
|
96
|
+
changeSelectedExample = _useState4[1];
|
|
97
|
+
|
|
98
|
+
var _useState5 = useState(false),
|
|
99
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
100
|
+
outputDialogOpen = _useState6[0],
|
|
101
|
+
changeOutputOpen = _useState6[1];
|
|
102
|
+
|
|
103
|
+
var _useState7 = useState(JSON.stringify(examples[selectedExample](), null, " ")),
|
|
104
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
105
|
+
currentJSONValue = _useState8[0],
|
|
106
|
+
changeCurrentJSONValue = _useState8[1];
|
|
107
|
+
|
|
108
|
+
return React.createElement(ThemeProvider, {
|
|
109
|
+
theme: theme
|
|
110
|
+
}, React.createElement("div", null, React.createElement("div", {
|
|
111
|
+
className: c.editBar
|
|
112
|
+
}, React.createElement("h3", null, "React Image Annotate"), React.createElement("div", {
|
|
113
|
+
style: {
|
|
114
|
+
flexGrow: 1
|
|
115
|
+
}
|
|
116
|
+
}), React.createElement("div", null, React.createElement("div", {
|
|
117
|
+
style: {
|
|
118
|
+
display: "inline-flex"
|
|
119
|
+
}
|
|
120
|
+
}, React.createElement(Select, {
|
|
121
|
+
className: c.select,
|
|
122
|
+
value: {
|
|
123
|
+
label: selectedExample,
|
|
124
|
+
value: selectedExample
|
|
125
|
+
},
|
|
126
|
+
options: Object.keys(examples).map(function (s) {
|
|
127
|
+
return {
|
|
128
|
+
label: s,
|
|
129
|
+
value: s
|
|
130
|
+
};
|
|
131
|
+
}),
|
|
132
|
+
onChange: function onChange(selectedOption) {
|
|
133
|
+
changeSelectedExample(selectedOption.value);
|
|
134
|
+
changeCurrentJSONValue(JSON.stringify(selectedOption.value === "Custom" ? loadSavedInput() : examples[selectedOption.value](), null, " "));
|
|
135
|
+
}
|
|
136
|
+
})), React.createElement(Button, {
|
|
137
|
+
className: "button",
|
|
138
|
+
disabled: !lastOutput,
|
|
139
|
+
onClick: function onClick() {
|
|
140
|
+
return changeOutputOpen(true);
|
|
141
|
+
}
|
|
142
|
+
}, "View Output"), React.createElement(Button, {
|
|
143
|
+
className: "button",
|
|
144
|
+
variant: "outlined",
|
|
145
|
+
disabled: Boolean(currentError),
|
|
146
|
+
onClick: function onClick() {
|
|
147
|
+
onOpenAnnotator(selectedExample === "Custom" ? loadSavedInput() : examples[selectedExample]);
|
|
148
|
+
}
|
|
149
|
+
}, "Open Annotator"))), React.createElement("div", {
|
|
150
|
+
className: c.contentArea,
|
|
151
|
+
style: currentError ? {
|
|
152
|
+
border: "2px solid #f00"
|
|
153
|
+
} : {
|
|
154
|
+
border: "2px solid #fff"
|
|
155
|
+
}
|
|
156
|
+
}, React.createElement("div", null, React.createElement(MonacoEditor, {
|
|
157
|
+
value: currentJSONValue,
|
|
158
|
+
language: "javascript",
|
|
159
|
+
onChange: function onChange(code) {
|
|
160
|
+
try {
|
|
161
|
+
window.localStorage.setItem("customInput", JSON.stringify(JSON.parse(code)));
|
|
162
|
+
changeCurrentError(null);
|
|
163
|
+
} catch (e) {
|
|
164
|
+
changeCurrentError(e.toString());
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
changeCurrentJSONValue(code);
|
|
168
|
+
},
|
|
169
|
+
width: "100%",
|
|
170
|
+
height: "550px"
|
|
171
|
+
}))), React.createElement("div", {
|
|
172
|
+
className: c.specificationArea
|
|
173
|
+
}, React.createElement("h2", null, "React Image Annotate Format"), React.createElement(Code, {
|
|
174
|
+
language: "javascript"
|
|
175
|
+
}, "\n{\n taskDescription?: string, // markdown\n regionTagList?: Array<string>,\n regionClsList?: Array<string>,\n imageTagList?: Array<string>,\n imageClsList?: Array<string>,\n // all tools are enabled by default\n enabledTools?: Array< \"select\" | \"create-point\" | \"create-box\" | \"create-polygon\" | \"create-line\">,\n selectedImage?: string, // initial selected image\n images: Array<{\n src: string,\n thumbnailSrc?: string, // use this if you are using high-res images\n name: string,\n regions?: Array<{\n id: string | number,\n cls?: string,\n color?: string,\n tags?: Array<string>,\n\n // Point\n type: \"point\",\n x: number, // [0-1] % of image width\n y: number, // [0-1] % of image height\n\n // Bounding Box\n type: \"box\",\n x: number, // [0-1] % of image width\n y: number, // [0-1] % of image height\n w: number, // [0-1] % of image width\n h: number, // [0-1] % of image height\n\n // Polygon\n type: \"polygon\",\n open?: boolean, // should last and first points be connected, default: true\n points: Array<[number, number]> // [0-1] % of image width/height\n }>\n }>,\n}\n")), React.createElement(Dialog, {
|
|
176
|
+
fullScreen: true,
|
|
177
|
+
open: outputDialogOpen
|
|
178
|
+
}, React.createElement(DialogTitle, null, "React Image Annotate Output"), React.createElement(DialogContent, {
|
|
179
|
+
style: {
|
|
180
|
+
minWidth: 400
|
|
181
|
+
}
|
|
182
|
+
}, React.createElement(MonacoEditor, {
|
|
183
|
+
value: JSON.stringify(lastOutput, null, " "),
|
|
184
|
+
language: "javascript",
|
|
185
|
+
width: "100%",
|
|
186
|
+
height: "550px"
|
|
187
|
+
})), React.createElement(DialogActions, null, React.createElement(Button, {
|
|
188
|
+
onClick: function onClick() {
|
|
189
|
+
return changeOutputOpen(false);
|
|
190
|
+
}
|
|
191
|
+
}, "Close")))));
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
export default Editor;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
4
|
+
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
|
+
import React, { Component } from "react";
|
|
7
|
+
import Dialog from "@mui/material/Dialog";
|
|
8
|
+
import Button from "@mui/material/Button";
|
|
9
|
+
import DialogTitle from "@mui/material/DialogTitle";
|
|
10
|
+
import DialogContent from "@mui/material/DialogContent";
|
|
11
|
+
import DialogActions from "@mui/material/DialogActions";
|
|
12
|
+
|
|
13
|
+
var ErrorBoundaryDialog =
|
|
14
|
+
/*#__PURE__*/
|
|
15
|
+
function (_Component) {
|
|
16
|
+
_inherits(ErrorBoundaryDialog, _Component);
|
|
17
|
+
|
|
18
|
+
function ErrorBoundaryDialog() {
|
|
19
|
+
var _getPrototypeOf2;
|
|
20
|
+
|
|
21
|
+
var _this;
|
|
22
|
+
|
|
23
|
+
_classCallCheck(this, ErrorBoundaryDialog);
|
|
24
|
+
|
|
25
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
26
|
+
args[_key] = arguments[_key];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(ErrorBoundaryDialog)).call.apply(_getPrototypeOf2, [this].concat(args)));
|
|
30
|
+
_this.state = {
|
|
31
|
+
hasError: false,
|
|
32
|
+
err: ""
|
|
33
|
+
};
|
|
34
|
+
return _this;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
_createClass(ErrorBoundaryDialog, [{
|
|
38
|
+
key: "componentDidCatch",
|
|
39
|
+
value: function componentDidCatch(err, info) {
|
|
40
|
+
this.setState({
|
|
41
|
+
hasError: true,
|
|
42
|
+
err: err.toString() + "\n\n" + info.componentStack
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}, {
|
|
46
|
+
key: "render",
|
|
47
|
+
value: function render() {
|
|
48
|
+
if (this.state.hasError) {
|
|
49
|
+
return React.createElement(Dialog, {
|
|
50
|
+
open: this.state.hasError,
|
|
51
|
+
onClose: this.props.onClose
|
|
52
|
+
}, React.createElement(DialogTitle, null, "Error Loading Annotator"), React.createElement(DialogContent, null, React.createElement("pre", null, this.state.err)), React.createElement(DialogActions, null, React.createElement(Button, {
|
|
53
|
+
onClick: this.props.onClose
|
|
54
|
+
}, "Close")));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return this.props.children;
|
|
58
|
+
}
|
|
59
|
+
}]);
|
|
60
|
+
|
|
61
|
+
return ErrorBoundaryDialog;
|
|
62
|
+
}(Component);
|
|
63
|
+
|
|
64
|
+
export { ErrorBoundaryDialog as default };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import React, { useState } from "react";
|
|
3
|
+
import ReactDOM from "react-dom";
|
|
4
|
+
import Editor, { examples } from "./Editor";
|
|
5
|
+
import Annotator from "../Annotator";
|
|
6
|
+
import ErrorBoundaryDialog from "./ErrorBoundaryDialog.js";
|
|
7
|
+
export default (function () {
|
|
8
|
+
var _useState = useState(false),
|
|
9
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
10
|
+
annotatorOpen = _useState2[0],
|
|
11
|
+
changeAnnotatorOpen = _useState2[1];
|
|
12
|
+
|
|
13
|
+
var _useState3 = useState(examples["Custom"]()),
|
|
14
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
15
|
+
annotatorProps = _useState4[0],
|
|
16
|
+
changeAnnotatorProps = _useState4[1];
|
|
17
|
+
|
|
18
|
+
var _useState5 = useState(),
|
|
19
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
20
|
+
lastOutput = _useState6[0],
|
|
21
|
+
changeLastOutput = _useState6[1];
|
|
22
|
+
|
|
23
|
+
return React.createElement("div", null, annotatorOpen ? React.createElement(ErrorBoundaryDialog, {
|
|
24
|
+
onClose: function onClose() {
|
|
25
|
+
changeAnnotatorOpen(false);
|
|
26
|
+
}
|
|
27
|
+
}, React.createElement("button", {
|
|
28
|
+
onClick: function onClick(e) {
|
|
29
|
+
e.stopPropagation();
|
|
30
|
+
var element = document.getElementById("delete-region-7725661632635865");
|
|
31
|
+
|
|
32
|
+
if (element) {
|
|
33
|
+
var clickEvent = document.createEvent("MouseEvents");
|
|
34
|
+
clickEvent.initEvent("click", true, true);
|
|
35
|
+
element.dispatchEvent(clickEvent);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}, "click"), React.createElement(Annotator //customize
|
|
39
|
+
, Object.assign({}, annotatorProps, {
|
|
40
|
+
onCreateAnno: function onCreateAnno(anno) {
|
|
41
|
+
console.log("Annotator created: ", anno);
|
|
42
|
+
},
|
|
43
|
+
onClickAnno: function onClickAnno(anno) {
|
|
44
|
+
console.log("Annotator click: ", anno);
|
|
45
|
+
},
|
|
46
|
+
onExit: function onExit(output) {
|
|
47
|
+
var checkOutside = false;
|
|
48
|
+
output.images[0].regions.forEach(function (r) {
|
|
49
|
+
if (r.x <= 0 || r.x >= 1 || r.y <= 0 || r.y >= 1.0) {
|
|
50
|
+
checkOutside = true;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
if (checkOutside) {
|
|
55
|
+
alert("Create defect box inside image");
|
|
56
|
+
} else {
|
|
57
|
+
changeLastOutput(output.images[0].regions);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
console.log(output.images[0].regions);
|
|
61
|
+
}
|
|
62
|
+
}))) : React.createElement(Editor, {
|
|
63
|
+
lastOutput: lastOutput,
|
|
64
|
+
onOpenAnnotator: function onOpenAnnotator(props) {
|
|
65
|
+
changeAnnotatorProps(props);
|
|
66
|
+
changeAnnotatorOpen(true);
|
|
67
|
+
}
|
|
68
|
+
}));
|
|
69
|
+
});
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import classnames from "classnames";
|
|
4
|
+
import { makeStyles } from "@mui/styles";
|
|
5
|
+
import { createTheme, ThemeProvider } from "@mui/material/styles";
|
|
6
|
+
var theme = createTheme();
|
|
7
|
+
var useStyles = makeStyles(function (theme) {
|
|
8
|
+
return {
|
|
9
|
+
"@keyframes borderDance": {
|
|
10
|
+
from: {
|
|
11
|
+
strokeDashoffset: 0
|
|
12
|
+
},
|
|
13
|
+
to: {
|
|
14
|
+
strokeDashoffset: 100
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
highlightBox: {
|
|
18
|
+
zIndex: 2,
|
|
19
|
+
transition: "opacity 500ms",
|
|
20
|
+
"&.highlighted": {
|
|
21
|
+
zIndex: 3,
|
|
22
|
+
filter: "invert(40%) sepia(50%) saturate(1928%) hue-rotate(350deg) brightness(94%) contrast(89%)" //customize
|
|
23
|
+
|
|
24
|
+
},
|
|
25
|
+
"&:not(.highlighted)": {
|
|
26
|
+
opacity: 0
|
|
27
|
+
},
|
|
28
|
+
"&:not(.highlighted):hover": {
|
|
29
|
+
opacity: 0.6
|
|
30
|
+
},
|
|
31
|
+
"& path": {
|
|
32
|
+
vectorEffect: "non-scaling-stroke",
|
|
33
|
+
strokeWidth: 2,
|
|
34
|
+
stroke: "#FFF",
|
|
35
|
+
fill: "none",
|
|
36
|
+
strokeDasharray: 5,
|
|
37
|
+
animationName: "$borderDance",
|
|
38
|
+
animationDuration: "4s",
|
|
39
|
+
animationTimingFunction: "linear",
|
|
40
|
+
animationIterationCount: "infinite",
|
|
41
|
+
animationPlayState: "running"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
export var HighlightBox = function HighlightBox(_ref) {
|
|
47
|
+
var mouseEvents = _ref.mouseEvents,
|
|
48
|
+
dragWithPrimary = _ref.dragWithPrimary,
|
|
49
|
+
zoomWithPrimary = _ref.zoomWithPrimary,
|
|
50
|
+
createWithPrimary = _ref.createWithPrimary,
|
|
51
|
+
onBeginMovePoint = _ref.onBeginMovePoint,
|
|
52
|
+
onSelectRegion = _ref.onSelectRegion,
|
|
53
|
+
r = _ref.region,
|
|
54
|
+
pbox = _ref.pbox;
|
|
55
|
+
var classes = useStyles();
|
|
56
|
+
if (!pbox.w || pbox.w === Infinity) return null;
|
|
57
|
+
if (!pbox.h || pbox.h === Infinity) return null;
|
|
58
|
+
if (r.unfinished) return null;
|
|
59
|
+
var styleCoords = r.type === "point" ? {
|
|
60
|
+
left: pbox.x + pbox.w / 2 - 30,
|
|
61
|
+
top: pbox.y + pbox.h / 2 - 30,
|
|
62
|
+
width: 60,
|
|
63
|
+
height: 60
|
|
64
|
+
} : {
|
|
65
|
+
left: pbox.x - 5,
|
|
66
|
+
top: pbox.y - 5,
|
|
67
|
+
width: pbox.w + 10,
|
|
68
|
+
height: pbox.h + 10
|
|
69
|
+
};
|
|
70
|
+
var pathD = r.type === "point" ? "M5,5 L".concat(styleCoords.width - 5, " 5L").concat(styleCoords.width - 5, " ").concat(styleCoords.height - 5, "L5 ").concat(styleCoords.height - 5, "Z") : "M5,5 L".concat(pbox.w + 5, ",5 L").concat(pbox.w + 5, ",").concat(pbox.h + 5, " L5,").concat(pbox.h + 5, " Z");
|
|
71
|
+
return React.createElement(ThemeProvider, {
|
|
72
|
+
theme: theme
|
|
73
|
+
}, React.createElement("svg", Object.assign({
|
|
74
|
+
key: r.id,
|
|
75
|
+
id: r.id,
|
|
76
|
+
className: classnames(classes.highlightBox, {
|
|
77
|
+
highlighted: r.highlighted
|
|
78
|
+
})
|
|
79
|
+
}, mouseEvents, !zoomWithPrimary && !dragWithPrimary ? {
|
|
80
|
+
onMouseDown: function onMouseDown(e) {
|
|
81
|
+
if (!r.locked && r.type === "point" && r.highlighted && e.button === 0) {
|
|
82
|
+
return onBeginMovePoint(r);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (e.button === 0 && !createWithPrimary) {
|
|
86
|
+
return onSelectRegion(r);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
onSelectRegion(r); //mouseEvents.onMouseDown(e)
|
|
90
|
+
}
|
|
91
|
+
} : {}, {
|
|
92
|
+
style: _objectSpread({}, r.highlighted ? {
|
|
93
|
+
pointerEvents: r.type !== "point" ? "none" : undefined,
|
|
94
|
+
cursor: "grab"
|
|
95
|
+
} : {
|
|
96
|
+
cursor: !(zoomWithPrimary || dragWithPrimary || createWithPrimary) ? "pointer" : undefined,
|
|
97
|
+
pointerEvents: zoomWithPrimary || dragWithPrimary || createWithPrimary && !r.highlighted ? "none" : undefined
|
|
98
|
+
}, {
|
|
99
|
+
position: "absolute"
|
|
100
|
+
}, styleCoords)
|
|
101
|
+
}), React.createElement("path", {
|
|
102
|
+
d: pathD
|
|
103
|
+
})));
|
|
104
|
+
};
|
|
105
|
+
export default HighlightBox;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React, { setState, memo } from "react";
|
|
2
|
+
import { makeStyles } from "@mui/styles";
|
|
3
|
+
import { createTheme, ThemeProvider } from "@mui/material/styles";
|
|
4
|
+
import SidebarBoxContainer from "../SidebarBoxContainer";
|
|
5
|
+
import HistoryIcon from "@mui/icons-material/History";
|
|
6
|
+
import List from "@mui/material/List";
|
|
7
|
+
import ListItem from "@mui/material/ListItem";
|
|
8
|
+
import ListItemText from "@mui/material/ListItemText";
|
|
9
|
+
import IconButton from "@mui/material/IconButton";
|
|
10
|
+
import ListItemSecondaryAction from "@mui/material/ListItemSecondaryAction";
|
|
11
|
+
import UndoIcon from "@mui/icons-material/Undo";
|
|
12
|
+
import moment from "moment";
|
|
13
|
+
import { grey } from "@mui/material/colors";
|
|
14
|
+
import isEqual from "lodash/isEqual";
|
|
15
|
+
import Box from "@mui/material/Box";
|
|
16
|
+
var theme = createTheme();
|
|
17
|
+
var useStyles = makeStyles(function (theme) {
|
|
18
|
+
return {
|
|
19
|
+
emptyText: {
|
|
20
|
+
fontSize: 14,
|
|
21
|
+
fontWeight: "bold",
|
|
22
|
+
color: grey[500],
|
|
23
|
+
textAlign: "center",
|
|
24
|
+
padding: 20
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
var listItemTextStyle = {
|
|
29
|
+
paddingLeft: 16
|
|
30
|
+
};
|
|
31
|
+
export var HistorySidebarBox = function HistorySidebarBox(_ref) {
|
|
32
|
+
var history = _ref.history,
|
|
33
|
+
onRestoreHistory = _ref.onRestoreHistory;
|
|
34
|
+
var classes = useStyles();
|
|
35
|
+
return React.createElement(ThemeProvider, {
|
|
36
|
+
theme: theme
|
|
37
|
+
}, React.createElement(SidebarBoxContainer, {
|
|
38
|
+
title: "History",
|
|
39
|
+
icon: React.createElement(HistoryIcon, {
|
|
40
|
+
style: {
|
|
41
|
+
color: grey[700]
|
|
42
|
+
}
|
|
43
|
+
}),
|
|
44
|
+
expandedByDefault: true
|
|
45
|
+
}, React.createElement(List, null, history.length === 0 && React.createElement("div", {
|
|
46
|
+
className: classes.emptyText
|
|
47
|
+
}, "No History Yet"), history.map(function (_ref2, i) {
|
|
48
|
+
var name = _ref2.name,
|
|
49
|
+
time = _ref2.time;
|
|
50
|
+
return React.createElement(ListItem, {
|
|
51
|
+
button: true,
|
|
52
|
+
dense: true,
|
|
53
|
+
key: i
|
|
54
|
+
}, React.createElement(ListItemText, {
|
|
55
|
+
style: listItemTextStyle,
|
|
56
|
+
primary: name,
|
|
57
|
+
secondary: moment(time).format("LT")
|
|
58
|
+
}), i === 0 && React.createElement(ListItemSecondaryAction, {
|
|
59
|
+
onClick: function onClick() {
|
|
60
|
+
return onRestoreHistory();
|
|
61
|
+
}
|
|
62
|
+
}, React.createElement(IconButton, null, React.createElement(UndoIcon, null))));
|
|
63
|
+
}))));
|
|
64
|
+
};
|
|
65
|
+
export default memo(HistorySidebarBox, function (prevProps, nextProps) {
|
|
66
|
+
return isEqual(prevProps.history.map(function (a) {
|
|
67
|
+
return [a.name, a.time];
|
|
68
|
+
}), nextProps.history.map(function (a) {
|
|
69
|
+
return [a.name, a.time];
|
|
70
|
+
}));
|
|
71
|
+
});
|