Skip to content

Commit 2feb5cc

Browse files
Merge remote-tracking branch 'origin/feature/fix-react-instances'
2 parents bc6ae80 + b209688 commit 2feb5cc

File tree

33 files changed

+1156
-835
lines changed

33 files changed

+1156
-835
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ dist
2828
secret.*
2929
secret.story.*
3030
*.secret.*
31+
.idea

.idea/react-image-annotate.iml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "react-image-annotate",
2+
"name": "@idapgroup/react-image-annotate",
33
"version": "2.0.0",
44
"type": "module",
55
"main": "dist/react-image-annotate.js",
@@ -13,33 +13,29 @@
1313
"@fortawesome/fontawesome-svg-core": "^6.5.2",
1414
"@fortawesome/free-solid-svg-icons": "^6.5.2",
1515
"@fortawesome/react-fontawesome": "^0.2.0",
16-
"@mui/icons-material": "^5.2.1",
17-
"@mui/material": "^5.2.3",
18-
"@mui/styles": "^5.2.3",
19-
"@vitejs/plugin-react": "^4.2.1",
16+
"@mui/icons-material": "^5.15.14",
17+
"@mui/material": "^5.15.14",
2018
"autoseg": "^0.0.12",
19+
"classnames": "^2.5.1",
2120
"color-alpha": "^2.0.0",
2221
"lodash": "^4.17.21",
23-
"material-survey": "^2.1.0",
2422
"moment": "^2.30.0",
2523
"monaco-editor": "^0.47.0",
26-
"react": "18.2.0",
27-
"react-dom": "18.2.0",
24+
"react": "^18.0.0",
25+
"react-dom": "^18.0.0",
2826
"react-full-screen": "^1.1.1",
2927
"react-hotkeys": "^2.0.0",
3028
"react-markdown": "^9.0.0",
31-
"react-material-workspace-layout": "^1.0.10",
3229
"react-monaco-editor": "^0.55.0",
3330
"react-remove-scroll": "^2.0.4",
3431
"react-select": "^5.8.0",
3532
"react-syntax-highlighter": "^15.5.0",
3633
"react-use": "^17.5.0",
3734
"react-use-measure": "^2.0.0",
3835
"seamless-immutable": "^7.1.4",
39-
"styled-components": "^5.2.1",
4036
"transformation-matrix-js": "^2.7.6",
41-
"use-event-callback": "^0.1.0",
42-
"use-key-hook": "^1.3.0"
37+
"tss-react": "^4.9.6",
38+
"use-event-callback": "^0.1.0"
4339
},
4440
"devDependencies": {
4541
"@rollup/plugin-replace": "^5.0.5",
@@ -50,6 +46,7 @@
5046
"@types/react-select": "^5.0.1",
5147
"@types/react-syntax-highlighter": "^15.5.11",
5248
"@types/seamless-immutable": "^7.1.4",
49+
"@vitejs/plugin-react": "^4.2.1",
5350
"cpy-cli": "^5.0.0",
5451
"cross-env": "^7.0.3",
5552
"gh-pages": "^2.0.1",
@@ -63,17 +60,16 @@
6360
"vite-tsconfig-paths": "^4.3.2"
6461
},
6562
"peerDependencies": {
66-
"react": "18.2.0",
67-
"react-dom": "18.2.0"
63+
"react": "^18.0.0",
64+
"react-dom": "^18.0.0"
6865
},
6966
"repository": {
7067
"type": "git",
71-
"url": "https://github.com/UniversalDataTool/react-image-annotate.git"
68+
"url": "https://github.com/idapgroup/react-image-annotate"
7269
},
7370
"scripts": {
7471
"start": "vite",
7572
"build": "tsc && vite build",
76-
"publish": "npm run build && cd dist && npm publish",
7773
"prettier": "prettier --write \"src/**/*.js\"",
7874
"prettier:test": "prettier --check \"src/**/*.js\""
7975
},

src/DemoSite/Editor.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { useState } from "react";
44
import Button from "@mui/material/Button";
5-
import { makeStyles } from "@mui/styles";
5+
import { tss } from "tss-react/mui";
66
import { createTheme, ThemeProvider } from "@mui/material/styles";
77
import Select from "react-select";
88
import Code from "react-syntax-highlighter";
@@ -14,7 +14,7 @@ import MonacoEditor from "react-monaco-editor";
1414
import { AnnotatorProps } from "../Annotator";
1515

1616
const theme = createTheme();
17-
const useStyles = makeStyles(() => ({
17+
const useStyles = tss.create(() => ({
1818
editBar: {
1919
padding: 10,
2020
borderBottom: "1px solid #ccc",
@@ -132,7 +132,7 @@ export const examples: Record<string, () => Omit<AnnotatorProps, "onExit">> = {
132132
};
133133

134134
const Editor = ({ onOpenAnnotator, lastOutput }: any) => {
135-
const c = useStyles();
135+
const { classes } = useStyles();
136136
const [currentError, changeCurrentError] = useState<string | null>(null);
137137
const [selectedExample, changeSelectedExample] = useState(
138138
window.localStorage.getItem("customInput") ? "Custom" : "FULL"
@@ -144,13 +144,13 @@ const Editor = ({ onOpenAnnotator, lastOutput }: any) => {
144144
return (
145145
<ThemeProvider theme={theme}>
146146
<div>
147-
<div className={c.editBar}>
147+
<div className={classes.editBar}>
148148
<h3>React Image Annotate</h3>
149149
<div style={{ flexGrow: 1 }} />
150150
<div>
151151
<div style={{ display: "inline-flex" }}>
152152
<Select
153-
className={c.select}
153+
className={classes.select}
154154
value={{ label: selectedExample, value: selectedExample }}
155155
options={Object.keys(examples).map((s) => ({
156156
label: s,
@@ -196,7 +196,7 @@ const Editor = ({ onOpenAnnotator, lastOutput }: any) => {
196196
</div>
197197
</div>
198198
<div
199-
className={c.contentArea}
199+
className={classes.contentArea}
200200
style={
201201
currentError
202202
? { border: "2px solid #f00" }
@@ -224,7 +224,7 @@ const Editor = ({ onOpenAnnotator, lastOutput }: any) => {
224224
/>
225225
</div>
226226
</div>
227-
<div className={c.specificationArea}>
227+
<div className={classes.specificationArea}>
228228
<h2>React Image Annotate Format</h2>
229229
<Code language="javascript">{`
230230
{

src/HighlightBox/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// @flow
22

33
import classnames from "classnames";
4-
import { makeStyles } from "@mui/styles";
54
import { createTheme, ThemeProvider } from "@mui/material/styles";
65
import type { Point, Region } from "../ImageCanvas/region-tools.tsx";
76
import { MouseEvents } from "../ImageCanvas/use-mouse.ts";
7+
import { tss } from "tss-react/mui";
88

99
const theme = createTheme();
10-
const useStyles = makeStyles(() => ({
10+
const useStyles = tss.create(() => ({
1111
"@keyframes borderDance": {
1212
from: { strokeDashoffset: 0 },
1313
to: { strokeDashoffset: 100 },
@@ -58,7 +58,7 @@ export const HighlightBox = ({
5858
region: Region;
5959
pbox: { x: number; y: number; w: number; h: number };
6060
}) => {
61-
const classes = useStyles();
61+
const { classes } = useStyles();
6262
if (!pbox.w || pbox.w === Infinity) return null;
6363
if (!pbox.h || pbox.h === Infinity) return null;
6464
if (r.type === "expanding-line" && r.unfinished) return null;

src/HistorySidebarBox/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// @flow
22

33
import { memo } from "react";
4-
import { makeStyles } from "@mui/styles";
54
import { createTheme, ThemeProvider } from "@mui/material/styles";
65
import SidebarBoxContainer from "../SidebarBoxContainer";
76
import HistoryIcon from "@mui/icons-material/History";
@@ -14,17 +13,18 @@ import UndoIcon from "@mui/icons-material/Undo";
1413
import moment from "moment";
1514
import { grey } from "@mui/material/colors";
1615
import isEqual from "lodash/isEqual";
16+
import { tss } from "tss-react/mui";
1717

1818
const theme = createTheme();
19-
const useStyles = makeStyles(() => ({
19+
const useStyles = tss.create({
2020
emptyText: {
2121
fontSize: 14,
2222
fontWeight: "bold",
2323
color: grey[500],
2424
textAlign: "center",
2525
padding: 20,
2626
},
27-
}));
27+
});
2828

2929
const listItemTextStyle = { paddingLeft: 16 };
3030

@@ -35,7 +35,7 @@ export const HistorySidebarBox = ({
3535
history: Array<{ name: string; time: Date }>;
3636
onRestoreHistory: () => void;
3737
}) => {
38-
const classes = useStyles();
38+
const { classes } = useStyles();
3939

4040
return (
4141
<ThemeProvider theme={theme}>

src/ImageCanvas/index.tsx

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ import type {
1919
Polygon,
2020
Region,
2121
} from "./region-tools";
22-
import { makeStyles } from "@mui/styles";
2322
import { createTheme, ThemeProvider } from "@mui/material/styles";
24-
import styles from "./styles";
2523
import PreventScrollToParents from "../PreventScrollToParents";
2624
import useWindowSize from "../hooks/use-window-size.tsx";
2725
import useMouse from "./use-mouse";
@@ -39,9 +37,34 @@ import RegionShapes from "../RegionShapes";
3937
import useWasdMode from "./use-wasd-mode";
4038
import { ImagePosition } from "../types/common.ts";
4139
import { AutosegOptions } from "autoseg/webworker";
40+
import { tss } from "tss-react/mui";
4241

4342
const theme = createTheme();
44-
const useStyles = makeStyles(styles);
43+
const useStyles = tss.create({
44+
canvas: { width: "100%", height: "100%", position: "relative", zIndex: 1 },
45+
zoomIndicator: {
46+
position: "absolute",
47+
bottom: 16,
48+
right: 0,
49+
backgroundColor: "rgba(0,0,0,0.4)",
50+
color: "#fff",
51+
opacity: 0.5,
52+
fontWeight: "bolder",
53+
fontSize: 14,
54+
padding: 4,
55+
},
56+
fixedRegionLabel: {
57+
position: "absolute",
58+
zIndex: 10,
59+
top: 10,
60+
left: 10,
61+
opacity: 0.5,
62+
transition: "opacity 500ms",
63+
"&:hover": {
64+
opacity: 1,
65+
},
66+
},
67+
});
4568

4669
type Props = {
4770
regions: Array<Region>;
@@ -163,7 +186,7 @@ export const ImageCanvas = ({
163186
keypointDefinitions,
164187
allowComments,
165188
}: Props) => {
166-
const classes = useStyles();
189+
const { classes } = useStyles();
167190
const canvasEl = useRef<HTMLCanvasElement | null>(null);
168191
const layoutParams = useRef<CanvasLayoutParams | null>(null);
169192
const [dragging, changeDragging] = useRafState(false);

src/ImageCanvas/styles.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/MainLayout/all-tools-list.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import getHotkeyHelpText from "../utils/get-hotkey-help-text.ts";
2-
import { ToolEnum } from "./types.ts";
2+
import { IconSidebarItem } from "../types/common.ts";
33

4-
export const ALL_TOOLS: {
5-
name: ToolEnum;
6-
helperText: string;
7-
alwaysShowing?: boolean;
8-
}[] = [
4+
export const ALL_TOOLS: IconSidebarItem[] = [
95
{
106
name: "select",
117
helperText: "Select" + getHotkeyHelpText("select_tool"),

src/MainLayout/icon-dictionary.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ import {
1616
faTag,
1717
faVectorSquare,
1818
} from "@fortawesome/free-solid-svg-icons";
19-
import { ReactElement } from "react";
19+
import { OverridableComponent } from "@mui/material/OverridableComponent";
20+
import { SvgIconTypeMap } from "@mui/material";
2021

2122
const faStyle = { marginTop: 4, width: 16, height: 16, marginBottom: 4 };
2223

23-
export const iconDictionary: Record<string, () => ReactElement> = {
24+
export const iconDictionary: Record<
25+
string,
26+
OverridableComponent<SvgIconTypeMap>
27+
> = {
2428
select: () => (
2529
<FontAwesomeIcon
2630
style={faStyle}

0 commit comments

Comments
 (0)