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.
Files changed (73) hide show
  1. package/Annotator/index.js +164 -0
  2. package/Annotator/reducers/combine-reducers.js +14 -0
  3. package/Annotator/reducers/convert-expanding-line-to-polygon.js +73 -0
  4. package/Annotator/reducers/fix-twisted.js +4 -0
  5. package/Annotator/reducers/general-reducer.js +1073 -0
  6. package/Annotator/reducers/get-active-image.js +27 -0
  7. package/Annotator/reducers/get-implied-video-regions.js +180 -0
  8. package/Annotator/reducers/history-handler.js +38 -0
  9. package/Annotator/reducers/image-reducer.js +20 -0
  10. package/Annotator/reducers/video-reducer.js +88 -0
  11. package/ClassSelectionMenu/index.js +135 -0
  12. package/Crosshairs/index.js +53 -0
  13. package/DebugSidebarBox/index.js +20 -0
  14. package/DemoSite/Editor.js +194 -0
  15. package/DemoSite/ErrorBoundaryDialog.js +64 -0
  16. package/DemoSite/index.js +69 -0
  17. package/FullImageSegmentationAnnotator/index.js +7 -0
  18. package/HighlightBox/index.js +105 -0
  19. package/HistorySidebarBox/index.js +71 -0
  20. package/ImageCanvas/index.js +428 -0
  21. package/ImageCanvas/region-tools.js +165 -0
  22. package/ImageCanvas/styles.js +31 -0
  23. package/ImageCanvas/use-mouse.js +180 -0
  24. package/ImageCanvas/use-project-box.js +27 -0
  25. package/ImageCanvas/use-wasd-mode.js +62 -0
  26. package/ImageMask/index.js +133 -0
  27. package/ImageMask/load-image.js +25 -0
  28. package/ImageSelectorSidebarBox/index.js +60 -0
  29. package/KeyframeTimeline/get-time-string.js +27 -0
  30. package/KeyframeTimeline/index.js +233 -0
  31. package/KeyframesSelectorSidebarBox/index.js +93 -0
  32. package/LandingPage/index.js +159 -0
  33. package/MainLayout/icon-dictionary.js +104 -0
  34. package/MainLayout/index.js +359 -0
  35. package/MainLayout/styles.js +25 -0
  36. package/MainLayout/types.js +0 -0
  37. package/MainLayout/use-implied-video-regions.js +13 -0
  38. package/PointDistances/index.js +73 -0
  39. package/PreventScrollToParents/index.js +51 -0
  40. package/README.md +101 -0
  41. package/RegionLabel/index.js +197 -0
  42. package/RegionLabel/styles.js +48 -0
  43. package/RegionSelectAndTransformBoxes/index.js +166 -0
  44. package/RegionSelectorSidebarBox/index.js +248 -0
  45. package/RegionSelectorSidebarBox/styles.js +53 -0
  46. package/RegionShapes/index.js +275 -0
  47. package/RegionTags/index.js +138 -0
  48. package/SettingsDialog/index.js +52 -0
  49. package/SettingsProvider/index.js +53 -0
  50. package/Shortcuts/ShortcutField.js +46 -0
  51. package/Shortcuts/index.js +133 -0
  52. package/ShortcutsManager/index.js +155 -0
  53. package/Sidebar/index.js +69 -0
  54. package/SidebarBoxContainer/index.js +93 -0
  55. package/SmallToolButton/index.js +42 -0
  56. package/TagsSidebarBox/index.js +105 -0
  57. package/TaskDescriptionSidebarBox/index.js +58 -0
  58. package/Theme/index.js +30 -0
  59. package/VideoOrImageCanvasBackground/index.js +151 -0
  60. package/colors.js +14 -0
  61. package/hooks/use-event-callback.js +10 -0
  62. package/hooks/use-exclude-pattern.js +24 -0
  63. package/hooks/use-load-image.js +26 -0
  64. package/hooks/use-window-size.js +46 -0
  65. package/hooks/xpattern.js +1 -0
  66. package/index.js +3 -0
  67. package/lib.js +3 -0
  68. package/package.json +91 -0
  69. package/stories.js +5 -0
  70. package/utils/get-from-local-storage.js +7 -0
  71. package/utils/get-hotkey-help-text.js +9 -0
  72. package/utils/get-landmarks-with-transform.js +40 -0
  73. package/utils/set-in-local-storage.js +3 -0
@@ -0,0 +1,53 @@
1
+ import { grey, blue, orange, purple } from "@mui/material/colors";
2
+ export default {
3
+ container: {
4
+ fontSize: 11,
5
+ fontWeight: "bold",
6
+ color: grey[700],
7
+ "& .icon": {
8
+ marginTop: 4,
9
+ width: 16,
10
+ height: 16
11
+ },
12
+ "& .icon2": {
13
+ opacity: 0.5,
14
+ width: 16,
15
+ height: 16,
16
+ transition: "200ms opacity",
17
+ "&:hover": {
18
+ cursor: "pointer",
19
+ opacity: 1
20
+ }
21
+ }
22
+ },
23
+ row: {
24
+ padding: 4,
25
+ cursor: "pointer",
26
+ "&.header:hover": {
27
+ backgroundColor: "#fff"
28
+ },
29
+ "&.highlighted": {
30
+ backgroundColor: blue[100]
31
+ },
32
+ "&:hover": {
33
+ backgroundColor: blue[50],
34
+ color: grey[800]
35
+ }
36
+ },
37
+ chip: {
38
+ display: "flex",
39
+ flexDirection: "row",
40
+ padding: 2,
41
+ borderRadius: 2,
42
+ paddingLeft: 4,
43
+ paddingRight: 4,
44
+ alignItems: "center",
45
+ "& .color": {
46
+ borderRadius: 5,
47
+ width: 10,
48
+ height: 10,
49
+ marginRight: 4
50
+ },
51
+ "& .text": {}
52
+ }
53
+ };
@@ -0,0 +1,275 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import React, { memo } from "react";
3
+ import colorAlpha from "color-alpha";
4
+
5
+ function clamp(num, min, max) {
6
+ return num <= min ? min : num >= max ? max : num;
7
+ }
8
+
9
+ var RegionComponents = {
10
+ //customize
11
+ point: memo(function (_ref) {
12
+ var region = _ref.region,
13
+ iw = _ref.iw,
14
+ ih = _ref.ih;
15
+ return React.createElement("g", {
16
+ transform: "translate(".concat(region.x * iw, " ").concat(region.y * ih, ")")
17
+ }, React.createElement("path", {
18
+ d: "M 1.866 12.7018 C 4.234 9.7951 9.486 2.7501 9.486 -1.207 C 9.486 -6.0063 5.5922 -9.9 0.793 -9.9 S -7.9 -6.0063 -7.9 -1.207 c 0 3.9571 5.2973 11.0021 7.62 13.9088 c 0.5569 0.6927 1.5892 0.6927 2.1461 0 z M 0.793 -4.1047 A 2.8977 2.8977 90 1 1 0.793 1.6907 a 2.8977 2.8977 90 1 1 0 -5.7953 z",
19
+ strokeWidth: 2,
20
+ stroke: region.color,
21
+ fill: region.color
22
+ }));
23
+ }),
24
+ line: memo(function (_ref2) {
25
+ var region = _ref2.region,
26
+ iw = _ref2.iw,
27
+ ih = _ref2.ih;
28
+ return React.createElement("g", {
29
+ transform: "translate(".concat(region.x1 * iw, " ").concat(region.y1 * ih, ")")
30
+ }, React.createElement("line", {
31
+ strokeWidth: 2,
32
+ x1: 0,
33
+ y1: 0,
34
+ x2: (region.x2 - region.x1) * iw,
35
+ y2: (region.y2 - region.y1) * ih,
36
+ stroke: colorAlpha(region.color, 0.75),
37
+ fill: colorAlpha(region.color, 0.25)
38
+ }));
39
+ }),
40
+ box: memo(function (_ref3) {
41
+ var region = _ref3.region,
42
+ iw = _ref3.iw,
43
+ ih = _ref3.ih;
44
+ return React.createElement("g", {
45
+ transform: "translate(".concat(region.x * iw, " ").concat(region.y * ih, ")")
46
+ }, React.createElement("rect", {
47
+ strokeWidth: 2,
48
+ x: 0,
49
+ y: 0,
50
+ width: Math.max(region.w * iw, 0),
51
+ height: Math.max(region.h * ih, 0),
52
+ stroke: colorAlpha(region.color, 0.75),
53
+ fill: colorAlpha(region.color, 0.25)
54
+ }));
55
+ }),
56
+ polygon: memo(function (_ref4) {
57
+ var region = _ref4.region,
58
+ iw = _ref4.iw,
59
+ ih = _ref4.ih,
60
+ fullSegmentationMode = _ref4.fullSegmentationMode;
61
+ var Component = region.open ? "polyline" : "polygon";
62
+ var alphaBase = fullSegmentationMode ? 0.5 : 1;
63
+ return React.createElement(Component, {
64
+ points: region.points.map(function (_ref5) {
65
+ var _ref6 = _slicedToArray(_ref5, 2),
66
+ x = _ref6[0],
67
+ y = _ref6[1];
68
+
69
+ return [x * iw, y * ih];
70
+ }).map(function (a) {
71
+ return a.join(" ");
72
+ }).join(" "),
73
+ strokeWidth: 2,
74
+ stroke: colorAlpha(region.color, 0.75),
75
+ fill: colorAlpha(region.color, 0.25)
76
+ });
77
+ }),
78
+ keypoints: function keypoints(_ref7) {
79
+ var region = _ref7.region,
80
+ iw = _ref7.iw,
81
+ ih = _ref7.ih,
82
+ keypointDefinitions = _ref7.keypointDefinitions;
83
+ var points = region.points,
84
+ keypointsDefinitionId = region.keypointsDefinitionId;
85
+
86
+ if (!keypointDefinitions[keypointsDefinitionId]) {
87
+ throw new Error("No definition for keypoint configuration \"".concat(keypointsDefinitionId, "\""));
88
+ }
89
+
90
+ var _keypointDefinitions$ = keypointDefinitions[keypointsDefinitionId],
91
+ landmarks = _keypointDefinitions$.landmarks,
92
+ connections = _keypointDefinitions$.connections;
93
+ return React.createElement("g", null, Object.entries(points).map(function (_ref8, i) {
94
+ var _ref9 = _slicedToArray(_ref8, 2),
95
+ keypointId = _ref9[0],
96
+ _ref9$ = _ref9[1],
97
+ x = _ref9$.x,
98
+ y = _ref9$.y;
99
+
100
+ return React.createElement("g", {
101
+ key: i,
102
+ transform: "translate(".concat(x * iw, " ").concat(y * ih, ")")
103
+ }, React.createElement("path", {
104
+ d: "M0 8L8 0L0 -8L-8 0Z",
105
+ strokeWidth: 2,
106
+ stroke: landmarks[keypointId].color,
107
+ fill: "transparent"
108
+ }));
109
+ }), connections.map(function (_ref10) {
110
+ var _ref11 = _slicedToArray(_ref10, 2),
111
+ kp1Id = _ref11[0],
112
+ kp2Id = _ref11[1];
113
+
114
+ var kp1 = points[kp1Id];
115
+ var kp2 = points[kp2Id];
116
+ var midPoint = {
117
+ x: (kp1.x + kp2.x) / 2,
118
+ y: (kp1.y + kp2.y) / 2
119
+ };
120
+ return React.createElement("g", {
121
+ key: "".concat(kp1.x, ",").concat(kp1.y, ".").concat(kp2.x, ",").concat(kp2.y)
122
+ }, React.createElement("line", {
123
+ x1: kp1.x * iw,
124
+ y1: kp1.y * ih,
125
+ x2: midPoint.x * iw,
126
+ y2: midPoint.y * ih,
127
+ strokeWidth: 2,
128
+ stroke: landmarks[kp1Id].color
129
+ }), React.createElement("line", {
130
+ x1: kp2.x * iw,
131
+ y1: kp2.y * ih,
132
+ x2: midPoint.x * iw,
133
+ y2: midPoint.y * ih,
134
+ strokeWidth: 2,
135
+ stroke: landmarks[kp2Id].color
136
+ }));
137
+ }));
138
+ },
139
+ "expanding-line": memo(function (_ref12) {
140
+ var region = _ref12.region,
141
+ iw = _ref12.iw,
142
+ ih = _ref12.ih;
143
+ var _region$expandingWidt = region.expandingWidth,
144
+ expandingWidth = _region$expandingWidt === void 0 ? 0.005 : _region$expandingWidt,
145
+ points = region.points;
146
+ expandingWidth = points.slice(-1)[0].width || expandingWidth;
147
+ var pointPairs = points.map(function (_ref13, i) {
148
+ var x = _ref13.x,
149
+ y = _ref13.y,
150
+ angle = _ref13.angle,
151
+ width = _ref13.width;
152
+
153
+ if (!angle) {
154
+ var n = points[clamp(i + 1, 0, points.length - 1)];
155
+ var p = points[clamp(i - 1, 0, points.length - 1)];
156
+ angle = Math.atan2(p.x - n.x, p.y - n.y) + Math.PI / 2;
157
+ }
158
+
159
+ var dx = Math.sin(angle) * (width || expandingWidth) / 2;
160
+ var dy = Math.cos(angle) * (width || expandingWidth) / 2;
161
+ return [{
162
+ x: x + dx,
163
+ y: y + dy
164
+ }, {
165
+ x: x - dx,
166
+ y: y - dy
167
+ }];
168
+ });
169
+ var firstSection = pointPairs.map(function (_ref14) {
170
+ var _ref15 = _slicedToArray(_ref14, 2),
171
+ p1 = _ref15[0],
172
+ p2 = _ref15[1];
173
+
174
+ return p1;
175
+ });
176
+ var secondSection = pointPairs.map(function (_ref16) {
177
+ var _ref17 = _slicedToArray(_ref16, 2),
178
+ p1 = _ref17[0],
179
+ p2 = _ref17[1];
180
+
181
+ return p2;
182
+ }).asMutable();
183
+ secondSection.reverse();
184
+ var lastPoint = points.slice(-1)[0];
185
+ return React.createElement(React.Fragment, null, React.createElement("polygon", {
186
+ points: firstSection.concat(region.candidatePoint ? [region.candidatePoint] : []).concat(secondSection).map(function (p) {
187
+ return "".concat(p.x * iw, " ").concat(p.y * ih);
188
+ }).join(" "),
189
+ strokeWidth: 2,
190
+ stroke: colorAlpha(region.color, 0.75),
191
+ fill: colorAlpha(region.color, 0.25)
192
+ }), points.map(function (_ref18, i) {
193
+ var x = _ref18.x,
194
+ y = _ref18.y,
195
+ angle = _ref18.angle;
196
+ return React.createElement("g", {
197
+ key: i,
198
+ transform: "translate(".concat(x * iw, " ").concat(y * ih, ") rotate(").concat(-(angle || 0) * 180 / Math.PI, ")")
199
+ }, React.createElement("g", null, React.createElement("rect", {
200
+ x: -5,
201
+ y: -5,
202
+ width: 10,
203
+ height: 10,
204
+ strokeWidth: 2,
205
+ stroke: colorAlpha(region.color, 0.75),
206
+ fill: colorAlpha(region.color, 0.25)
207
+ })));
208
+ }), React.createElement("rect", {
209
+ x: lastPoint.x * iw - 8,
210
+ y: lastPoint.y * ih - 8,
211
+ width: 16,
212
+ height: 16,
213
+ strokeWidth: 4,
214
+ stroke: colorAlpha(region.color, 0.5),
215
+ fill: "transparent"
216
+ }));
217
+ }),
218
+ pixel: function pixel() {
219
+ return null;
220
+ }
221
+ };
222
+ export var WrappedRegionList = memo(function (_ref19) {
223
+ var regions = _ref19.regions,
224
+ keypointDefinitions = _ref19.keypointDefinitions,
225
+ iw = _ref19.iw,
226
+ ih = _ref19.ih,
227
+ fullSegmentationMode = _ref19.fullSegmentationMode;
228
+ return regions.filter(function (r) {
229
+ return r.visible !== false;
230
+ }).map(function (r) {
231
+ var Component = RegionComponents[r.type];
232
+ return React.createElement(Component, {
233
+ key: r.regionId,
234
+ region: r,
235
+ iw: iw,
236
+ ih: ih,
237
+ keypointDefinitions: keypointDefinitions,
238
+ fullSegmentationMode: fullSegmentationMode
239
+ });
240
+ });
241
+ }, function (n, p) {
242
+ return n.regions === p.regions && n.iw === p.iw && n.ih === p.ih;
243
+ });
244
+ export var RegionShapes = function RegionShapes(_ref20) {
245
+ var mat = _ref20.mat,
246
+ imagePosition = _ref20.imagePosition,
247
+ _ref20$regions = _ref20.regions,
248
+ regions = _ref20$regions === void 0 ? [] : _ref20$regions,
249
+ keypointDefinitions = _ref20.keypointDefinitions,
250
+ fullSegmentationMode = _ref20.fullSegmentationMode;
251
+ var iw = imagePosition.bottomRight.x - imagePosition.topLeft.x;
252
+ var ih = imagePosition.bottomRight.y - imagePosition.topLeft.y;
253
+ if (isNaN(iw) || isNaN(ih)) return null;
254
+ return React.createElement("svg", {
255
+ width: iw,
256
+ height: ih,
257
+ style: {
258
+ position: "absolute",
259
+ zIndex: 2,
260
+ left: imagePosition.topLeft.x,
261
+ top: imagePosition.topLeft.y,
262
+ pointerEvents: "none",
263
+ width: iw,
264
+ height: ih
265
+ }
266
+ }, React.createElement(WrappedRegionList, {
267
+ key: "wrapped-region-list",
268
+ regions: regions,
269
+ iw: iw,
270
+ ih: ih,
271
+ keypointDefinitions: keypointDefinitions,
272
+ fullSegmentationMode: fullSegmentationMode
273
+ }));
274
+ };
275
+ export default RegionShapes;
@@ -0,0 +1,138 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";
2
+ import React from "react";
3
+ import Paper from "@mui/material/Paper";
4
+ import DefaultRegionLabel from "../RegionLabel";
5
+ import LockIcon from "@mui/icons-material/Lock";
6
+
7
+ var copyWithout = function copyWithout(obj) {
8
+ var newObj = _objectSpread({}, obj);
9
+
10
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
11
+ args[_key - 1] = arguments[_key];
12
+ }
13
+
14
+ for (var _i = 0, _args = args; _i < _args.length; _i++) {
15
+ var arg = _args[_i];
16
+ delete newObj[arg];
17
+ }
18
+
19
+ return newObj;
20
+ };
21
+
22
+ export var RegionTags = function RegionTags(_ref) {
23
+ var regions = _ref.regions,
24
+ projectRegionBox = _ref.projectRegionBox,
25
+ mouseEvents = _ref.mouseEvents,
26
+ regionClsList = _ref.regionClsList,
27
+ regionTagList = _ref.regionTagList,
28
+ onBeginRegionEdit = _ref.onBeginRegionEdit,
29
+ onChangeRegion = _ref.onChangeRegion,
30
+ onCloseRegionEdit = _ref.onCloseRegionEdit,
31
+ onDeleteRegion = _ref.onDeleteRegion,
32
+ layoutParams = _ref.layoutParams,
33
+ imageSrc = _ref.imageSrc,
34
+ RegionEditLabel = _ref.RegionEditLabel,
35
+ onRegionClassAdded = _ref.onRegionClassAdded,
36
+ allowComments = _ref.allowComments;
37
+ var RegionLabel = RegionEditLabel != null ? RegionEditLabel : DefaultRegionLabel;
38
+ return regions.filter(function (r) {
39
+ return r.visible || r.visible === undefined;
40
+ }).map(function (region) {
41
+ var pbox = projectRegionBox(region);
42
+ var _layoutParams$current = layoutParams.current,
43
+ iw = _layoutParams$current.iw,
44
+ ih = _layoutParams$current.ih;
45
+ var margin = 8;
46
+ if (region.highlighted && region.type === "box") margin += 6;
47
+ var labelBoxHeight = region.editingLabels && !region.locked ? 300 : region.tags ? 60 : 50;
48
+ var displayOnTop = pbox.y > labelBoxHeight;
49
+ var coords = displayOnTop ? {
50
+ left: pbox.x,
51
+ top: pbox.y - margin / 2
52
+ } : {
53
+ left: pbox.x,
54
+ top: pbox.y + pbox.h + margin / 2
55
+ };
56
+
57
+ if (region.locked) {
58
+ return React.createElement("div", {
59
+ key: region.id,
60
+ style: _objectSpread({
61
+ position: "absolute"
62
+ }, coords, {
63
+ zIndex: 10 + (region.editingLabels ? 5 : 0)
64
+ })
65
+ }, React.createElement(Paper, {
66
+ style: _objectSpread({
67
+ position: "absolute",
68
+ left: 0
69
+ }, displayOnTop ? {
70
+ bottom: 0
71
+ } : {
72
+ top: 0
73
+ }, {
74
+ zIndex: 10,
75
+ backgroundColor: "#fff",
76
+ borderRadius: 4,
77
+ padding: 2,
78
+ paddingBottom: 0,
79
+ opacity: 0.5,
80
+ pointerEvents: "none"
81
+ })
82
+ }, React.createElement(LockIcon, {
83
+ style: {
84
+ width: 16,
85
+ height: 16,
86
+ color: "#333"
87
+ }
88
+ })));
89
+ }
90
+
91
+ return React.createElement("div", {
92
+ key: region.id,
93
+ style: _objectSpread({
94
+ position: "absolute"
95
+ }, coords, {
96
+ zIndex: 10 + (region.editingLabels ? 5 : 0),
97
+ width: 200
98
+ }),
99
+ onMouseDown: function onMouseDown(e) {
100
+ return e.preventDefault();
101
+ },
102
+ onMouseUp: function onMouseUp(e) {
103
+ return e.preventDefault();
104
+ },
105
+ onMouseEnter: function onMouseEnter(e) {
106
+ if (region.editingLabels) {
107
+ mouseEvents.onMouseUp(e);
108
+ e.button = 1;
109
+ mouseEvents.onMouseUp(e);
110
+ }
111
+ }
112
+ }, React.createElement("div", Object.assign({
113
+ style: _objectSpread({
114
+ position: "absolute",
115
+ zIndex: 20,
116
+ left: 0
117
+ }, displayOnTop ? {
118
+ bottom: 0
119
+ } : {
120
+ top: 0
121
+ })
122
+ }, !region.editingLabels ? copyWithout(mouseEvents, "onMouseDown", "onMouseUp") : {}), React.createElement(RegionLabel, {
123
+ allowedClasses: regionClsList,
124
+ allowedTags: regionTagList,
125
+ onOpen: onBeginRegionEdit,
126
+ onChange: onChangeRegion,
127
+ onClose: onCloseRegionEdit,
128
+ onDelete: onDeleteRegion,
129
+ editing: region.editingLabels,
130
+ region: region,
131
+ regions: regions,
132
+ imageSrc: imageSrc,
133
+ onRegionClassAdded: onRegionClassAdded,
134
+ allowComments: allowComments
135
+ })));
136
+ });
137
+ };
138
+ export default RegionTags;
@@ -0,0 +1,52 @@
1
+ import React from "react";
2
+ import Dialog from "@mui/material/Dialog";
3
+ import DialogTitle from "@mui/material/DialogTitle";
4
+ import DialogContent from "@mui/material/DialogContent";
5
+ import DialogActions from "@mui/material/DialogActions";
6
+ import Button from "@mui/material/Button";
7
+ import Survey from "material-survey/components/Survey";
8
+ import { useSettings } from "../SettingsProvider";
9
+ export var SettingsDialog = function SettingsDialog(_ref) {
10
+ var open = _ref.open,
11
+ onClose = _ref.onClose;
12
+ var settings = useSettings();
13
+ return React.createElement(Dialog, {
14
+ open: open || false,
15
+ onClose: onClose
16
+ }, React.createElement(DialogTitle, null, "Settings"), React.createElement(DialogContent, {
17
+ style: {
18
+ minWidth: 400
19
+ }
20
+ }, React.createElement(Survey, {
21
+ variant: "flat",
22
+ noActions: true,
23
+ defaultAnswers: settings,
24
+ onQuestionChange: function onQuestionChange(q, a, answers) {
25
+ return settings.changeSetting(q, a);
26
+ },
27
+ form: {
28
+ questions: [{
29
+ type: "boolean",
30
+ title: "Show Crosshairs",
31
+ name: "showCrosshairs"
32
+ }, {
33
+ type: "boolean",
34
+ title: "Show Highlight Box",
35
+ name: "showHighlightBox"
36
+ }, {
37
+ type: "boolean",
38
+ title: "WASD Mode",
39
+ name: "wasdMode"
40
+ }, {
41
+ type: "dropdown",
42
+ title: "Video Playback Speed",
43
+ name: "videoPlaybackSpeed",
44
+ defaultValue: "1x",
45
+ choices: ["0.25x", "0.5x", "1x", "2x"]
46
+ }]
47
+ }
48
+ })), React.createElement(DialogActions, null, React.createElement(Button, {
49
+ onClick: onClose
50
+ }, "Close")));
51
+ };
52
+ export default SettingsDialog;
@@ -0,0 +1,53 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";
3
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
+ import React, { createContext, useContext, useState } from "react";
5
+ var defaultSettings = {
6
+ showCrosshairs: false,
7
+ showHighlightBox: true,
8
+ wasdMode: true
9
+ };
10
+ export var SettingsContext = createContext(defaultSettings);
11
+
12
+ var pullSettingsFromLocalStorage = function pullSettingsFromLocalStorage() {
13
+ if (!window || !window.localStorage) return {};
14
+ var settings = {};
15
+
16
+ for (var i = 0; i < window.localStorage.length; i++) {
17
+ var key = window.localStorage.key(i);
18
+
19
+ if (key.startsWith("settings_")) {
20
+ try {
21
+ settings[key.replace("settings_", "")] = JSON.parse(window.localStorage.getItem(key));
22
+ } catch (e) {}
23
+ }
24
+ }
25
+
26
+ return settings;
27
+ };
28
+
29
+ export var useSettings = function useSettings() {
30
+ return useContext(SettingsContext);
31
+ };
32
+ export var SettingsProvider = function SettingsProvider(_ref) {
33
+ var children = _ref.children;
34
+
35
+ var _useState = useState(function () {
36
+ return pullSettingsFromLocalStorage();
37
+ }),
38
+ _useState2 = _slicedToArray(_useState, 2),
39
+ state = _useState2[0],
40
+ changeState = _useState2[1];
41
+
42
+ var changeSetting = function changeSetting(setting, value) {
43
+ changeState(_objectSpread({}, state, _defineProperty({}, setting, value)));
44
+ window.localStorage.setItem("settings_".concat(setting), JSON.stringify(value));
45
+ };
46
+
47
+ return React.createElement(SettingsContext.Provider, {
48
+ value: _objectSpread({}, state, {
49
+ changeSetting: changeSetting
50
+ })
51
+ }, children);
52
+ };
53
+ export default SettingsProvider;
@@ -0,0 +1,46 @@
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
+ var theme = createTheme();
6
+ var useStyles = makeStyles(function (theme) {
7
+ return {
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
+
24
+ var ShortcutField = function ShortcutField(_ref) {
25
+ var actionId = _ref.actionId,
26
+ actionName = _ref.actionName,
27
+ keyName = _ref.keyName,
28
+ onChangeShortcut = _ref.onChangeShortcut;
29
+ var classes = useStyles();
30
+ return React.createElement(ThemeProvider, {
31
+ theme: theme
32
+ }, React.createElement("div", {
33
+ className: classes.shortcutKeyFieldWrapper
34
+ }, React.createElement(TextField, {
35
+ variant: "outlined",
36
+ label: actionName,
37
+ className: classes.shortcutTextfield,
38
+ value: keyName,
39
+ onKeyPress: function onKeyPress(e) {
40
+ onChangeShortcut(actionId, e.key);
41
+ e.stopPropagation();
42
+ }
43
+ })));
44
+ };
45
+
46
+ export default ShortcutField;