@glodon-aiot/dataset-annotation 3.24.0-alpha.6 → 3.25.0-alpha.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.
- package/dist/es/components/ClassificationAnnotation/index.mjs +374 -325
- package/dist/es/components/DetectionAnnotation/components/ImageDetail/index.mjs +82 -78
- package/dist/es/components/DetectionAnnotation/components/ImageModal/index.mjs +28 -26
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/index.mjs +173 -166
- package/dist/es/components/DetectionAnnotation/index.mjs +478 -473
- package/dist/es/components/OcrAnnotation/OCRBoxDetail/index.mjs +249 -230
- package/dist/es/components/OcrAnnotation/OcrModal/index.mjs +103 -98
- package/dist/es/components/OcrAnnotation/index.mjs +281 -248
- package/dist/es/components/VLMAnnotationDetail/VLMDetail/index.mjs +277 -272
- package/dist/es/components/VLMAnnotationDetail/VlmModal/index.mjs +42 -40
- package/dist/es/components/VLMAnnotationDetail/index.mjs +331 -278
- package/dist/es/index.mjs +1 -1
- package/dist/es/utils/checkVlmSampleLabeled.mjs +7 -0
- package/dist/es/utils/scrollSampleIntoView.mjs +16 -0
- package/dist/lib/index.js +4 -4
- package/dist/src/components/DetectionAnnotation/components/ImageDetail/index.d.ts +2 -0
- package/dist/src/components/DetectionAnnotation/components/ImageModal/index.d.ts +2 -0
- package/dist/src/components/OcrAnnotation/OCRBoxDetail/index.d.ts +2 -0
- package/dist/src/components/OcrAnnotation/OcrModal/index.d.ts +1 -0
- package/dist/src/components/VLMAnnotationDetail/VLMDetail/index.d.ts +6 -0
- package/dist/src/components/VLMAnnotationDetail/VlmModal/index.d.ts +5 -0
- package/dist/src/utils/checkVlmSampleLabeled.d.ts +8 -0
- package/dist/src/utils/scrollSampleIntoView.d.ts +9 -0
- package/package.json +2 -2
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
var
|
|
2
|
-
import { jsx as u, jsxs as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { fabric as
|
|
1
|
+
var re = Math.pow;
|
|
2
|
+
import { jsx as u, jsxs as ce } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as G, useState as C, useEffect as p } from "react";
|
|
4
|
+
import { fabric as J } from "fabric";
|
|
5
5
|
import { useKeyPress as N } from "ahooks";
|
|
6
6
|
import "./style.less.mjs";
|
|
7
|
-
import
|
|
8
|
-
import { Spin as
|
|
9
|
-
import
|
|
10
|
-
import { drawable as
|
|
11
|
-
import { ZoomInOutlined as
|
|
7
|
+
import he from "react-dom";
|
|
8
|
+
import { Spin as me, Space as ge, Tooltip as U, Button as z } from "antd";
|
|
9
|
+
import ie from "./RectLabel.mjs";
|
|
10
|
+
import { drawable as be } from "./Drawable.mjs";
|
|
11
|
+
import { ZoomInOutlined as pe, ZoomOutOutlined as ye, DragOutlined as xe, ClearOutlined as De } from "@ant-design/icons";
|
|
12
12
|
import ve from "classnames";
|
|
13
13
|
import { approxeq as Y } from "../../../../utils/index.mjs";
|
|
14
|
-
const
|
|
14
|
+
const R = (l) => {
|
|
15
15
|
l.off("mouse:down"), l.off("mouse:up");
|
|
16
16
|
}, A = (l) => {
|
|
17
17
|
var f, P, k;
|
|
@@ -30,8 +30,8 @@ const T = (l) => {
|
|
|
30
30
|
color: l.config.color,
|
|
31
31
|
box: (h == null ? void 0 : h.map((a) => [Y(a.x - g.x, 0) ? 0 : Y(a.x - g.x, y.width) ? y.width : a.x - g.x, Y(a.y - g.y, 0) ? 0 : Y(a.y - g.y, y.height) ? y.height : a.y - g.y])) || []
|
|
32
32
|
};
|
|
33
|
-
},
|
|
34
|
-
const h =
|
|
33
|
+
}, ze = (l) => {
|
|
34
|
+
const h = G(null), {
|
|
35
35
|
labels: g,
|
|
36
36
|
imageUrl: y,
|
|
37
37
|
pen: f,
|
|
@@ -41,61 +41,61 @@ const T = (l) => {
|
|
|
41
41
|
isPreLabel: _,
|
|
42
42
|
disabled: w,
|
|
43
43
|
renderLabelItem: X
|
|
44
|
-
} = l, [B, W] =
|
|
44
|
+
} = l, [B, W] = C(!0), [e, Q] = C(), [je, se] = C({}), [j, $] = C(), [Z, ae] = C({
|
|
45
45
|
left: 0,
|
|
46
46
|
top: 0
|
|
47
|
-
}), [
|
|
48
|
-
if (!
|
|
47
|
+
}), [le, K] = C([1, 1]), [T, V] = C(), [I, D] = C([]), v = G(/* @__PURE__ */ new Set()), ee = G(0), [x, L] = C(w || !1), s = (n) => {
|
|
48
|
+
if (!n)
|
|
49
49
|
return !1;
|
|
50
50
|
try {
|
|
51
|
-
return !!
|
|
51
|
+
return !!n.getContext();
|
|
52
52
|
} catch (t) {
|
|
53
53
|
return !1;
|
|
54
54
|
}
|
|
55
|
-
}, H = (
|
|
55
|
+
}, H = (n, t) => {
|
|
56
56
|
if (!e || !s(e))
|
|
57
57
|
return;
|
|
58
58
|
t || (t = {
|
|
59
59
|
x: e.getCenter().left,
|
|
60
60
|
y: e.getCenter().top
|
|
61
61
|
});
|
|
62
|
-
let
|
|
63
|
-
|
|
62
|
+
let o = e.getZoom();
|
|
63
|
+
o *= re(0.999, n), o > 20 && (o = 20), o < 0.01 && (o = 0.01);
|
|
64
64
|
try {
|
|
65
65
|
e.zoomToPoint(
|
|
66
66
|
t,
|
|
67
|
-
|
|
67
|
+
o
|
|
68
68
|
// 传入修改后的缩放级别
|
|
69
|
-
), K([
|
|
69
|
+
), K([o, o]);
|
|
70
70
|
} catch (r) {
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
p(() => {
|
|
74
|
-
!e || !s(e) ||
|
|
74
|
+
!e || !s(e) || I.forEach((n) => {
|
|
75
75
|
try {
|
|
76
|
-
|
|
76
|
+
n.renderLabel();
|
|
77
77
|
} catch (t) {
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
|
-
}, [
|
|
81
|
-
const
|
|
82
|
-
var
|
|
83
|
-
if (((
|
|
80
|
+
}, [le, I, e]);
|
|
81
|
+
const te = (n) => {
|
|
82
|
+
var o;
|
|
83
|
+
if (((o = n.target) == null ? void 0 : o.tagName) === "INPUT" || !e || !s(e))
|
|
84
84
|
return;
|
|
85
85
|
const t = e == null ? void 0 : e.getActiveObject();
|
|
86
|
-
t &&
|
|
86
|
+
t && D((r) => {
|
|
87
87
|
let d = r.findIndex((i) => i.object === t);
|
|
88
88
|
if (d === -1 && t && (d = r.findIndex((i) => {
|
|
89
89
|
const c = i._fabricRect;
|
|
90
90
|
return c && c === t;
|
|
91
91
|
})), d >= 0 && r[d]) {
|
|
92
92
|
const i = r[d];
|
|
93
|
-
|
|
93
|
+
v.current.add(i.config.id);
|
|
94
94
|
const c = i.handlers.onDelete;
|
|
95
95
|
i.handlers.onDelete = void 0, i.destroy(), i.handlers.onDelete = c, r.splice(d, 1);
|
|
96
96
|
const m = r.map(A);
|
|
97
97
|
a && a(m), setTimeout(() => {
|
|
98
|
-
|
|
98
|
+
v.current.delete(i.config.id);
|
|
99
99
|
}, 100);
|
|
100
100
|
} else if (t && e) {
|
|
101
101
|
const i = r.findIndex((c) => {
|
|
@@ -104,12 +104,12 @@ const T = (l) => {
|
|
|
104
104
|
});
|
|
105
105
|
if (i >= 0 && r[i]) {
|
|
106
106
|
const c = r[i];
|
|
107
|
-
|
|
107
|
+
v.current.add(c.config.id);
|
|
108
108
|
const m = c.handlers.onDelete;
|
|
109
109
|
c.handlers.onDelete = void 0, c.destroy(), c.handlers.onDelete = m, r.splice(i, 1);
|
|
110
110
|
const S = r.map(A);
|
|
111
111
|
a && a(S), setTimeout(() => {
|
|
112
|
-
|
|
112
|
+
v.current.delete(c.config.id);
|
|
113
113
|
}, 100);
|
|
114
114
|
} else
|
|
115
115
|
e.remove(t), e.discardActiveObject(), e.renderAll();
|
|
@@ -117,7 +117,7 @@ const T = (l) => {
|
|
|
117
117
|
return [...r];
|
|
118
118
|
});
|
|
119
119
|
};
|
|
120
|
-
N("Delete",
|
|
120
|
+
N("Delete", te), N("Backspace", te), N("ctrl", () => {
|
|
121
121
|
L(!0);
|
|
122
122
|
}, {
|
|
123
123
|
events: ["keydown"]
|
|
@@ -128,20 +128,20 @@ const T = (l) => {
|
|
|
128
128
|
}), p(() => {
|
|
129
129
|
L(w || !1);
|
|
130
130
|
}, [w]);
|
|
131
|
-
const
|
|
132
|
-
e &&
|
|
133
|
-
const
|
|
134
|
-
if (
|
|
135
|
-
t.splice(
|
|
131
|
+
const oe = (n) => {
|
|
132
|
+
e && R(e), D((t) => {
|
|
133
|
+
const o = t.findIndex((r) => r === n);
|
|
134
|
+
if (o > -1) {
|
|
135
|
+
t.splice(o, 1);
|
|
136
136
|
const r = t.map(A);
|
|
137
137
|
a && a(r), M();
|
|
138
138
|
}
|
|
139
139
|
return [...t];
|
|
140
140
|
});
|
|
141
|
-
},
|
|
142
|
-
|
|
143
|
-
const
|
|
144
|
-
return
|
|
141
|
+
}, ne = (n) => {
|
|
142
|
+
D((t) => {
|
|
143
|
+
const o = t.findIndex((r) => r === n);
|
|
144
|
+
return o > -1 && (t[o] = n, a && a(t.map(A))), [...t];
|
|
145
145
|
});
|
|
146
146
|
};
|
|
147
147
|
p(() => {
|
|
@@ -155,49 +155,52 @@ const T = (l) => {
|
|
|
155
155
|
}
|
|
156
156
|
if (!j)
|
|
157
157
|
return;
|
|
158
|
-
const
|
|
158
|
+
const n = [];
|
|
159
159
|
return g.filter((t) => t.color).forEach((t) => {
|
|
160
|
-
|
|
160
|
+
n.push(new ie({
|
|
161
161
|
id: t.id,
|
|
162
162
|
name: t.label,
|
|
163
163
|
color: t.color,
|
|
164
|
-
points: t.box.map((
|
|
164
|
+
points: t.box.map((o) => [o[0] + Z.left, o[1] + Z.top]),
|
|
165
165
|
hideDelete: _
|
|
166
166
|
}, e, {
|
|
167
|
-
onChange:
|
|
168
|
-
onDelete:
|
|
169
|
-
renderLabelItem: X ? (
|
|
167
|
+
onChange: ne,
|
|
168
|
+
onDelete: oe,
|
|
169
|
+
renderLabelItem: X ? (o) => X ? X(t) : o.name : void 0
|
|
170
170
|
}));
|
|
171
|
-
}),
|
|
171
|
+
}), D(n), n.forEach((t) => {
|
|
172
172
|
try {
|
|
173
173
|
t.render(e);
|
|
174
|
-
} catch (
|
|
174
|
+
} catch (o) {
|
|
175
175
|
}
|
|
176
176
|
}), () => {
|
|
177
|
-
|
|
177
|
+
n.forEach((t) => {
|
|
178
178
|
try {
|
|
179
|
-
t.canvas !== e
|
|
180
|
-
|
|
179
|
+
if (t.canvas !== e) {
|
|
180
|
+
const o = t.handlers.onDelete;
|
|
181
|
+
t.handlers.onDelete = void 0, t.destroy(), t.handlers.onDelete = o;
|
|
182
|
+
}
|
|
183
|
+
} catch (o) {
|
|
181
184
|
}
|
|
182
185
|
});
|
|
183
186
|
};
|
|
184
187
|
}, [e, y, j, Z]);
|
|
185
188
|
const M = () => {
|
|
186
|
-
!e || !s(e) ||
|
|
189
|
+
!e || !s(e) || be(e, (n) => {
|
|
187
190
|
if (!e || !s(e))
|
|
188
191
|
return;
|
|
189
|
-
const t = new
|
|
190
|
-
id: (f == null ? void 0 : f.id) ||
|
|
191
|
-
name: (f == null ? void 0 : f.label) ||
|
|
192
|
-
color: (f == null ? void 0 : f.color) ||
|
|
193
|
-
points:
|
|
192
|
+
const t = new ie({
|
|
193
|
+
id: (f == null ? void 0 : f.id) || n.id,
|
|
194
|
+
name: (f == null ? void 0 : f.label) || n.label,
|
|
195
|
+
color: (f == null ? void 0 : f.color) || n.color,
|
|
196
|
+
points: n.box.map((o) => [o[0], o[1]]),
|
|
194
197
|
hideDelete: _
|
|
195
198
|
}, e, {
|
|
196
|
-
onChange:
|
|
197
|
-
onDelete:
|
|
199
|
+
onChange: ne,
|
|
200
|
+
onDelete: oe
|
|
198
201
|
});
|
|
199
|
-
t.active = !0,
|
|
200
|
-
const r = [...
|
|
202
|
+
t.active = !0, D((o) => {
|
|
203
|
+
const r = [...o, t];
|
|
201
204
|
return a && a(r.map(A)), setTimeout(() => {
|
|
202
205
|
if (t.object && e && s(e))
|
|
203
206
|
try {
|
|
@@ -208,28 +211,28 @@ const T = (l) => {
|
|
|
208
211
|
}, 0), r;
|
|
209
212
|
});
|
|
210
213
|
}, _);
|
|
211
|
-
},
|
|
212
|
-
let
|
|
214
|
+
}, fe = () => {
|
|
215
|
+
let n = !1;
|
|
213
216
|
e && (e.on("mouse:down", (t) => {
|
|
214
|
-
|
|
217
|
+
n = !0, e.selection = !1;
|
|
215
218
|
}), e.on("mouse:move", (t) => {
|
|
216
|
-
if (
|
|
217
|
-
const
|
|
218
|
-
e.relativePan(
|
|
219
|
+
if (n && t && t.e) {
|
|
220
|
+
const o = new J.Point(t.e.movementX, t.e.movementY);
|
|
221
|
+
e.relativePan(o);
|
|
219
222
|
}
|
|
220
223
|
}), e.on("mouse:up", (t) => {
|
|
221
|
-
|
|
224
|
+
n = !1, e.selection = !0;
|
|
222
225
|
}));
|
|
223
|
-
},
|
|
226
|
+
}, de = () => {
|
|
224
227
|
e && (e.off("mouse:down"), e.off("mouse:move"), e.off("mouse:up"));
|
|
225
228
|
};
|
|
226
229
|
p(() => {
|
|
227
230
|
if (!e || !s(e))
|
|
228
231
|
return;
|
|
229
|
-
const
|
|
232
|
+
const n = (t) => {
|
|
230
233
|
if (!s(e))
|
|
231
234
|
return;
|
|
232
|
-
const
|
|
235
|
+
const o = e, r = o == null ? void 0 : o._currentTransform;
|
|
233
236
|
if (!r)
|
|
234
237
|
return;
|
|
235
238
|
const d = r.action;
|
|
@@ -240,146 +243,150 @@ const T = (l) => {
|
|
|
240
243
|
try {
|
|
241
244
|
const m = e.getPointer(t.e);
|
|
242
245
|
if (m.x < c.tl.x || m.x > c.br.x || m.y < c.tl.y || m.y > c.br.y) {
|
|
243
|
-
const O =
|
|
246
|
+
const O = o == null ? void 0 : o._onMouseUp;
|
|
244
247
|
typeof O == "function" && O(t.e);
|
|
245
248
|
}
|
|
246
249
|
} catch (m) {
|
|
247
250
|
}
|
|
248
251
|
};
|
|
249
|
-
return e.on("mouse:move",
|
|
252
|
+
return e.on("mouse:move", n), () => {
|
|
250
253
|
if (e && s(e))
|
|
251
254
|
try {
|
|
252
|
-
e.off("mouse:move",
|
|
255
|
+
e.off("mouse:move", n);
|
|
253
256
|
} catch (t) {
|
|
254
257
|
}
|
|
255
258
|
};
|
|
256
259
|
}, [e]), p(() => {
|
|
257
260
|
if (!e || !s(e))
|
|
258
261
|
return;
|
|
259
|
-
const
|
|
262
|
+
const n = (t) => {
|
|
260
263
|
if (!s(e))
|
|
261
264
|
return;
|
|
262
|
-
const
|
|
263
|
-
if (!!!(
|
|
265
|
+
const o = e;
|
|
266
|
+
if (!!!(o != null && o._currentTransform))
|
|
264
267
|
return;
|
|
265
|
-
const d =
|
|
268
|
+
const d = o == null ? void 0 : o._onMouseUp;
|
|
266
269
|
typeof d == "function" && d(t.e);
|
|
267
270
|
};
|
|
268
|
-
return e.on("mouse:out",
|
|
271
|
+
return e.on("mouse:out", n), () => {
|
|
269
272
|
if (e && s(e))
|
|
270
273
|
try {
|
|
271
|
-
e.off("mouse:out",
|
|
274
|
+
e.off("mouse:out", n);
|
|
272
275
|
} catch (t) {
|
|
273
276
|
}
|
|
274
277
|
};
|
|
275
278
|
}, [e]), p(() => {
|
|
276
279
|
if (!(!e || !s(e))) {
|
|
277
280
|
if (x) {
|
|
278
|
-
|
|
281
|
+
fe();
|
|
279
282
|
try {
|
|
280
283
|
e.defaultCursor = "grab";
|
|
281
|
-
const
|
|
284
|
+
const n = () => {
|
|
282
285
|
s(e) && e.setCursor("grabbing");
|
|
283
286
|
}, t = () => {
|
|
284
287
|
s(e) && (e.defaultCursor = "grab");
|
|
285
288
|
};
|
|
286
|
-
e.on("mouse:down:before",
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
+
e.on("mouse:down:before", n), e.on("mouse:up", t);
|
|
290
|
+
const o = e.getObjects();
|
|
291
|
+
D((r) => (r.forEach((d) => {
|
|
289
292
|
var i;
|
|
290
293
|
try {
|
|
291
294
|
(i = d.object) == null || i.set("evented", !1);
|
|
292
295
|
} catch (c) {
|
|
293
296
|
}
|
|
294
297
|
}), r));
|
|
295
|
-
} catch (
|
|
298
|
+
} catch (n) {
|
|
296
299
|
}
|
|
297
300
|
} else
|
|
298
301
|
try {
|
|
299
|
-
e.defaultCursor = "default", e.off("mouse:down:before"), e.off("mouse:up"), e.setCursor("default"),
|
|
300
|
-
var
|
|
302
|
+
e.defaultCursor = "default", e.off("mouse:down:before"), e.off("mouse:up"), e.setCursor("default"), D((n) => (n.forEach((t) => {
|
|
303
|
+
var o;
|
|
301
304
|
try {
|
|
302
|
-
(
|
|
305
|
+
(o = t.object) == null || o.set("evented", !0);
|
|
303
306
|
} catch (r) {
|
|
304
307
|
}
|
|
305
|
-
}),
|
|
306
|
-
} catch (
|
|
308
|
+
}), n)), M();
|
|
309
|
+
} catch (n) {
|
|
307
310
|
}
|
|
308
311
|
return () => {
|
|
309
|
-
|
|
312
|
+
de();
|
|
310
313
|
};
|
|
311
314
|
}
|
|
312
315
|
}, [e, x]), p(() => {
|
|
313
316
|
if (!e || !s(e))
|
|
314
317
|
return;
|
|
315
|
-
const
|
|
318
|
+
const n = (t) => {
|
|
316
319
|
if (!s(e))
|
|
317
320
|
return;
|
|
318
|
-
const
|
|
319
|
-
H(
|
|
321
|
+
const o = t.e.deltaY;
|
|
322
|
+
H(o, {
|
|
320
323
|
x: t.e.offsetX,
|
|
321
324
|
y: t.e.offsetY
|
|
322
|
-
}),
|
|
325
|
+
}), I.forEach((r) => {
|
|
323
326
|
try {
|
|
324
327
|
r.renderLabel();
|
|
325
328
|
} catch (d) {
|
|
326
329
|
}
|
|
327
330
|
});
|
|
328
331
|
};
|
|
329
|
-
return e.on("mouse:wheel",
|
|
332
|
+
return e.on("mouse:wheel", n), x ? () => {
|
|
330
333
|
if (e && s(e))
|
|
331
334
|
try {
|
|
332
|
-
e.off("mouse:wheel",
|
|
335
|
+
e.off("mouse:wheel", n);
|
|
333
336
|
} catch (t) {
|
|
334
337
|
}
|
|
335
338
|
} : (M(), () => {
|
|
336
339
|
if (e && s(e))
|
|
337
340
|
try {
|
|
338
|
-
|
|
341
|
+
R(e), e.off("mouse:wheel", n);
|
|
339
342
|
} catch (t) {
|
|
340
343
|
}
|
|
341
344
|
});
|
|
342
|
-
}, [e, f,
|
|
343
|
-
const
|
|
345
|
+
}, [e, f, I, x]);
|
|
346
|
+
const ue = () => {
|
|
344
347
|
if (e)
|
|
345
348
|
try {
|
|
346
|
-
|
|
347
|
-
} catch (
|
|
349
|
+
R(e), e.discardActiveObject();
|
|
350
|
+
} catch (n) {
|
|
348
351
|
}
|
|
349
|
-
if (
|
|
352
|
+
if (D((n) => (n.forEach((t) => {
|
|
350
353
|
try {
|
|
351
|
-
|
|
352
|
-
const
|
|
353
|
-
t.handlers.onDelete = void 0, t.destroy(), t.handlers.onDelete =
|
|
354
|
-
} catch (
|
|
354
|
+
v.current.add(t.config.id);
|
|
355
|
+
const o = t.handlers.onDelete;
|
|
356
|
+
t.handlers.onDelete = void 0, t.destroy(), t.handlers.onDelete = o;
|
|
357
|
+
} catch (o) {
|
|
355
358
|
}
|
|
356
359
|
}), setTimeout(() => {
|
|
357
|
-
|
|
358
|
-
}, 100), [])),
|
|
360
|
+
v.current.clear();
|
|
361
|
+
}, 100), [])), se({}), $(void 0), K([1, 1]), e)
|
|
359
362
|
try {
|
|
360
363
|
e.getObjects().forEach((t) => {
|
|
361
364
|
try {
|
|
362
365
|
e.remove(t);
|
|
363
|
-
} catch (
|
|
366
|
+
} catch (o) {
|
|
364
367
|
}
|
|
365
368
|
}), e.dispose();
|
|
366
|
-
} catch (
|
|
369
|
+
} catch (n) {
|
|
367
370
|
}
|
|
368
|
-
|
|
371
|
+
Q(void 0);
|
|
369
372
|
};
|
|
370
373
|
return p(() => {
|
|
371
|
-
W(!0),
|
|
374
|
+
W(!0), ue();
|
|
375
|
+
const n = ++ee.current;
|
|
376
|
+
!h.current || !y || J.Image.fromURL(
|
|
372
377
|
y,
|
|
373
378
|
// @types/fabric 的回调签名缺少第二个参数 isError,运行时确实存在,用 any 规避类型错误
|
|
374
|
-
(
|
|
375
|
-
if (
|
|
376
|
-
|
|
377
|
-
|
|
379
|
+
(t, o) => {
|
|
380
|
+
if (n === ee.current) {
|
|
381
|
+
if (o) {
|
|
382
|
+
W(!1), k == null || k();
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
t.set({
|
|
386
|
+
originX: "center",
|
|
387
|
+
originY: "center"
|
|
388
|
+
}), $(t), W(!1);
|
|
378
389
|
}
|
|
379
|
-
o.set({
|
|
380
|
-
originX: "center",
|
|
381
|
-
originY: "center"
|
|
382
|
-
}), Q(o), W(!1);
|
|
383
390
|
},
|
|
384
391
|
{
|
|
385
392
|
crossOrigin: "anonymous"
|
|
@@ -395,12 +402,12 @@ const T = (l) => {
|
|
|
395
402
|
}
|
|
396
403
|
if (!h.current || !h.current.parentElement)
|
|
397
404
|
return;
|
|
398
|
-
const
|
|
399
|
-
if (!(
|
|
405
|
+
const n = j == null ? void 0 : j.getElement();
|
|
406
|
+
if (!(n != null && n.width) || !(n != null && n.height))
|
|
400
407
|
return;
|
|
401
408
|
if (e)
|
|
402
409
|
try {
|
|
403
|
-
e.getContext() && (
|
|
410
|
+
e.getContext() && (R(e), e.discardActiveObject(), e.getObjects().forEach((F) => {
|
|
404
411
|
try {
|
|
405
412
|
e.remove(F);
|
|
406
413
|
} catch (Ce) {
|
|
@@ -408,28 +415,28 @@ const T = (l) => {
|
|
|
408
415
|
}), e.dispose());
|
|
409
416
|
} catch (E) {
|
|
410
417
|
}
|
|
411
|
-
const t =
|
|
412
|
-
let c = [
|
|
413
|
-
d > i ? c = [r * t, r] : c = [
|
|
414
|
-
const m = c[0] /
|
|
418
|
+
const t = n.width / n.height, o = h.current.parentElement.offsetWidth, r = h.current.parentElement.offsetHeight, d = o / n.width, i = r / n.height;
|
|
419
|
+
let c = [o, r];
|
|
420
|
+
d > i ? c = [r * t, r] : c = [o, o / t];
|
|
421
|
+
const m = c[0] / n.width, S = c[1] / n.height, O = Math.min(m, S);
|
|
415
422
|
K([O, O]);
|
|
416
|
-
const b = new
|
|
423
|
+
const b = new J.Canvas(h.current, {
|
|
417
424
|
containerClass: "marking-canvas",
|
|
418
|
-
width:
|
|
425
|
+
width: o,
|
|
419
426
|
height: r
|
|
420
427
|
});
|
|
421
428
|
if (b.uniScaleKey = "", b.uniformScaling = !1, b == null || b.setZoom(O), b == null || b.renderAll(), b && j) {
|
|
422
|
-
const E = (
|
|
429
|
+
const E = (o - c[0]) / O / 2, q = (r - c[1]) / O / 2;
|
|
423
430
|
b.setBackgroundImage(
|
|
424
431
|
j,
|
|
425
432
|
() => {
|
|
426
433
|
try {
|
|
427
434
|
if (!b.getContext())
|
|
428
435
|
return;
|
|
429
|
-
b.renderAll(),
|
|
436
|
+
b.renderAll(), ae({
|
|
430
437
|
left: E,
|
|
431
438
|
top: q
|
|
432
|
-
}),
|
|
439
|
+
}), Q(b), P && P();
|
|
433
440
|
} catch (F) {
|
|
434
441
|
}
|
|
435
442
|
},
|
|
@@ -443,35 +450,35 @@ const T = (l) => {
|
|
|
443
450
|
);
|
|
444
451
|
}
|
|
445
452
|
}, [j]), p(() => {
|
|
446
|
-
if (
|
|
447
|
-
if (
|
|
453
|
+
if (I.length > g.length) {
|
|
454
|
+
if (v.current.size > 0)
|
|
448
455
|
return;
|
|
449
|
-
|
|
450
|
-
const
|
|
451
|
-
!g.find((i) => i.id === t.config.id) && !r && !
|
|
456
|
+
I.forEach((t) => {
|
|
457
|
+
const o = v.current.has(t.config.id), r = t._isDestroying;
|
|
458
|
+
!g.find((i) => i.id === t.config.id) && !r && !o && t.destroy();
|
|
452
459
|
});
|
|
453
460
|
}
|
|
454
461
|
}, [g.length]), p(() => {
|
|
455
|
-
!e || !s(e) || x ||
|
|
462
|
+
!e || !s(e) || x || D((n) => {
|
|
456
463
|
try {
|
|
457
|
-
const t = e == null ? void 0 : e.getActiveObject(),
|
|
458
|
-
|
|
464
|
+
const t = e == null ? void 0 : e.getActiveObject(), o = n.find((r) => r.object === t);
|
|
465
|
+
o && f && (o.labelConfig = {
|
|
459
466
|
id: f.id,
|
|
460
467
|
name: f.label,
|
|
461
468
|
color: f.color
|
|
462
|
-
}, a && a(
|
|
469
|
+
}, a && a(n.map(A))), e && s(e) && (f ? e.defaultCursor = "copy" : e.defaultCursor = "default");
|
|
463
470
|
} catch (t) {
|
|
464
471
|
}
|
|
465
|
-
return [...
|
|
472
|
+
return [...n];
|
|
466
473
|
});
|
|
467
474
|
}, [f, e, x]), p(() => {
|
|
468
|
-
var
|
|
469
|
-
if (B && h.current && !
|
|
475
|
+
var n;
|
|
476
|
+
if (B && h.current && !T) {
|
|
470
477
|
const t = document.createElement("div");
|
|
471
|
-
t.setAttribute("style", "width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: absolute;top: 0;"), (
|
|
478
|
+
t.setAttribute("style", "width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: absolute;top: 0;"), (n = h.current.parentElement) == null || n.appendChild(t), he.render(/* @__PURE__ */ u(me, {}), t), V(t);
|
|
472
479
|
} else
|
|
473
|
-
!B &&
|
|
474
|
-
}, [B, h.current,
|
|
480
|
+
!B && T && (T.remove(), V(null));
|
|
481
|
+
}, [B, h.current, T]), /* @__PURE__ */ ce("div", {
|
|
475
482
|
style: {
|
|
476
483
|
width: "100%",
|
|
477
484
|
height: "100%",
|
|
@@ -481,14 +488,14 @@ const T = (l) => {
|
|
|
481
488
|
className: "marker-toolbar",
|
|
482
489
|
children: /* @__PURE__ */ u("div", {
|
|
483
490
|
className: "create-mode-select",
|
|
484
|
-
children: /* @__PURE__ */
|
|
491
|
+
children: /* @__PURE__ */ ce(ge, {
|
|
485
492
|
direction: "vertical",
|
|
486
493
|
size: 16,
|
|
487
494
|
children: [/* @__PURE__ */ u(U, {
|
|
488
495
|
title: "放大-鼠标滚轮前滑",
|
|
489
496
|
placement: "right",
|
|
490
497
|
children: /* @__PURE__ */ u(z, {
|
|
491
|
-
icon: /* @__PURE__ */ u(
|
|
498
|
+
icon: /* @__PURE__ */ u(pe, {}),
|
|
492
499
|
onClick: () => {
|
|
493
500
|
H(-100);
|
|
494
501
|
}
|
|
@@ -497,7 +504,7 @@ const T = (l) => {
|
|
|
497
504
|
title: "缩小-鼠标滚轮后滑",
|
|
498
505
|
placement: "right",
|
|
499
506
|
children: /* @__PURE__ */ u(z, {
|
|
500
|
-
icon: /* @__PURE__ */ u(
|
|
507
|
+
icon: /* @__PURE__ */ u(ye, {}),
|
|
501
508
|
onClick: () => {
|
|
502
509
|
H(100);
|
|
503
510
|
}
|
|
@@ -507,7 +514,7 @@ const T = (l) => {
|
|
|
507
514
|
placement: "right",
|
|
508
515
|
children: /* @__PURE__ */ u(z, {
|
|
509
516
|
disabled: w,
|
|
510
|
-
icon: /* @__PURE__ */ u(
|
|
517
|
+
icon: /* @__PURE__ */ u(xe, {}),
|
|
511
518
|
className: x ? "active" : "",
|
|
512
519
|
onClick: () => {
|
|
513
520
|
L(!x);
|
|
@@ -517,23 +524,23 @@ const T = (l) => {
|
|
|
517
524
|
title: "一键清空全部标注",
|
|
518
525
|
placement: "right",
|
|
519
526
|
children: /* @__PURE__ */ u(z, {
|
|
520
|
-
icon: /* @__PURE__ */ u(
|
|
521
|
-
disabled: !(
|
|
527
|
+
icon: /* @__PURE__ */ u(De, {}),
|
|
528
|
+
disabled: !(I != null && I.length),
|
|
522
529
|
onClick: () => {
|
|
523
530
|
if (!(!e || !s(e)))
|
|
524
531
|
try {
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
const r =
|
|
528
|
-
|
|
532
|
+
R(e), e.discardActiveObject(), D((t) => (t.forEach((o) => {
|
|
533
|
+
v.current.add(o.config.id);
|
|
534
|
+
const r = o.handlers.onDelete;
|
|
535
|
+
o.handlers.onDelete = void 0, o.destroy(), o.handlers.onDelete = r;
|
|
529
536
|
}), setTimeout(() => {
|
|
530
|
-
|
|
537
|
+
v.current.clear();
|
|
531
538
|
}, 100), [])), e.getObjects().forEach((t) => {
|
|
532
539
|
t !== e.backgroundImage && e.remove(t);
|
|
533
540
|
}), a && a([]), s(e) && (e.renderAll(), setTimeout(() => {
|
|
534
541
|
e && s(e) && !x && M();
|
|
535
542
|
}, 0));
|
|
536
|
-
} catch (
|
|
543
|
+
} catch (n) {
|
|
537
544
|
}
|
|
538
545
|
}
|
|
539
546
|
})
|
|
@@ -545,8 +552,8 @@ const T = (l) => {
|
|
|
545
552
|
"label-maker-wrap": !0,
|
|
546
553
|
draggable: x
|
|
547
554
|
}),
|
|
548
|
-
onContextMenu: (
|
|
549
|
-
|
|
555
|
+
onContextMenu: (n) => {
|
|
556
|
+
n.preventDefault();
|
|
550
557
|
},
|
|
551
558
|
children: /* @__PURE__ */ u("canvas", {
|
|
552
559
|
className: "label-maker-canvas",
|
|
@@ -556,5 +563,5 @@ const T = (l) => {
|
|
|
556
563
|
});
|
|
557
564
|
};
|
|
558
565
|
export {
|
|
559
|
-
|
|
566
|
+
ze as default
|
|
560
567
|
};
|