@glodon-aiot/dataset-annotation 3.13.0-alpha.29 → 3.14.0-alpha.30

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 (33) hide show
  1. package/dist/es/components/DetectionAnnotation/components/LabelMaker/RectLabel.mjs +151 -135
  2. package/dist/es/components/DetectionAnnotation/components/LabelMaker/index.mjs +244 -218
  3. package/dist/es/components/VLMAnnotation/RegionItem.mjs +135 -59
  4. package/dist/es/components/VLMAnnotation/TextAnnotationPanel.mjs +73 -62
  5. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.mjs +55 -40
  6. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.mjs +291 -162
  7. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRControl.mjs +100 -0
  8. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.mjs +88 -55
  9. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionBoundaryCheck.mjs +103 -0
  10. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.mjs +123 -91
  11. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.mjs +42 -39
  12. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionUpdate.mjs +55 -60
  13. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/ai.svg.mjs +4 -0
  14. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/error.svg.mjs +4 -0
  15. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/loading.svg.mjs +4 -0
  16. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/star.svg.mjs +4 -0
  17. package/dist/es/components/VLMAnnotation/VLMLabelMaker/index.mjs +512 -387
  18. package/dist/es/components/VLMAnnotation/constants.mjs +39 -32
  19. package/dist/es/components/VLMAnnotation/index.mjs +187 -150
  20. package/dist/es/index.mjs +1 -1
  21. package/dist/lib/index.js +4 -4
  22. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.d.ts +1 -0
  23. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.d.ts +3 -1
  24. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRControl.d.ts +16 -0
  25. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.d.ts +3 -2
  26. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionBoundaryCheck.d.ts +31 -0
  27. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.d.ts +5 -1
  28. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.d.ts +2 -1
  29. package/dist/src/components/VLMAnnotation/VLMLabelMaker/index.d.ts +2 -2
  30. package/dist/src/components/VLMAnnotation/constants.d.ts +19 -3
  31. package/dist/src/components/VLMAnnotation/index.d.ts +1 -1
  32. package/dist/src/components/VLMAnnotation/types.d.ts +15 -0
  33. package/package.json +2 -2
@@ -1,350 +1,376 @@
1
- var Q = Math.pow;
2
- import { jsx as c, jsxs as $ } from "react/jsx-runtime";
3
- import { useRef as ae, useState as x, useEffect as d } from "react";
4
- import { fabric as z } from "fabric";
5
- import { useKeyPress as O } from "ahooks";
1
+ var $ = Math.pow;
2
+ import { jsx as u, jsxs as V } from "react/jsx-runtime";
3
+ import { useRef as ee, useState as I, useEffect as h } from "react";
4
+ import { fabric as Y } from "fabric";
5
+ import { useKeyPress as L } from "ahooks";
6
6
  import "./style.less.mjs";
7
- import ce from "react-dom";
8
- import { Spin as le, Space as fe, Tooltip as R, Button as X } from "antd";
9
- import V from "./RectLabel.mjs";
7
+ import le from "react-dom";
8
+ import { Spin as fe, Space as de, Tooltip as _, Button as X } from "antd";
9
+ import te from "./RectLabel.mjs";
10
10
  import { drawable as ue } from "./Drawable.mjs";
11
- import { ZoomInOutlined as de, ZoomOutOutlined as me, DragOutlined as ge } from "@ant-design/icons";
12
- import he from "classnames";
13
- import { approxeq as L } from "../../../../utils/index.mjs";
14
- const ee = (s) => {
15
- s.off("mouse:down"), s.off("mouse:up");
16
- }, E = (s) => {
17
- var i, j, f;
18
- let a = [];
19
- (i = s.object) != null && i.aCoords && (a = [s.object.aCoords.tl, s.object.aCoords.tr, s.object.aCoords.br, s.object.aCoords.bl]);
20
- const l = {
11
+ import { ZoomInOutlined as me, ZoomOutOutlined as ge, DragOutlined as he } from "@ant-design/icons";
12
+ import pe from "classnames";
13
+ import { approxeq as R } from "../../../../utils/index.mjs";
14
+ const oe = (a) => {
15
+ a.off("mouse:down"), a.off("mouse:up");
16
+ }, O = (a) => {
17
+ var c, E, f;
18
+ let l = [];
19
+ (c = a.object) != null && c.aCoords && (l = [a.object.aCoords.tl, a.object.aCoords.tr, a.object.aCoords.br, a.object.aCoords.bl]);
20
+ const m = {
21
21
  x: 0,
22
22
  y: 0
23
- }, m = {
23
+ }, p = {
24
24
  width: 0,
25
25
  height: 0
26
26
  };
27
- return s.canvas.backgroundImage && typeof s.canvas.backgroundImage != "string" && (l.x = ((j = s.canvas.backgroundImage.aCoords) == null ? void 0 : j.tl.x) || 0, l.y = ((f = s.canvas.backgroundImage.aCoords) == null ? void 0 : f.tl.y) || 0, m.width = s.canvas.backgroundImage.width || 0, m.height = s.canvas.backgroundImage.height || 0), {
28
- id: s.config.id,
29
- label: s.config.name,
30
- color: s.config.color,
31
- box: (a == null ? void 0 : a.map((h) => [L(h.x - l.x, 0) ? 0 : L(h.x - l.x, m.width) ? m.width : h.x - l.x, L(h.y - l.y, 0) ? 0 : L(h.y - l.y, m.height) ? m.height : h.y - l.y])) || []
27
+ return a.canvas.backgroundImage && typeof a.canvas.backgroundImage != "string" && (m.x = ((E = a.canvas.backgroundImage.aCoords) == null ? void 0 : E.tl.x) || 0, m.y = ((f = a.canvas.backgroundImage.aCoords) == null ? void 0 : f.tl.y) || 0, p.width = a.canvas.backgroundImage.width || 0, p.height = a.canvas.backgroundImage.height || 0), {
28
+ id: a.config.id,
29
+ label: a.config.name,
30
+ color: a.config.color,
31
+ box: (l == null ? void 0 : l.map((b) => [R(b.x - m.x, 0) ? 0 : R(b.x - m.x, p.width) ? p.width : b.x - m.x, R(b.y - m.y, 0) ? 0 : R(b.y - m.y, p.height) ? p.height : b.y - m.y])) || []
32
32
  };
33
- }, Le = (s) => {
34
- const a = ae(null), {
35
- labels: l,
36
- imageUrl: m,
37
- pen: i,
38
- onImageLoad: j,
33
+ }, Re = (a) => {
34
+ const l = ee(null), {
35
+ labels: m,
36
+ imageUrl: p,
37
+ pen: c,
38
+ onImageLoad: E,
39
39
  onChange: f,
40
- isPreLabel: h,
40
+ isPreLabel: b,
41
41
  disabled: k,
42
- renderLabelItem: N
43
- } = s, [S, B] = x(!0), [e, Z] = x(), [pe, te] = x({}), [I, _] = x(), [W, oe] = x({
42
+ renderLabelItem: S
43
+ } = a, [T, B] = I(!0), [e, Z] = I(), [be, ne] = I({}), [C, K] = I(), [W, re] = I({
44
44
  left: 0,
45
45
  top: 0
46
- }), [re, A] = x([1, 1]), [M, H] = x(), [b, v] = x([]), [y, P] = x(k || !1), T = (t, o) => {
46
+ }), [ie, A] = I([1, 1]), [M, H] = I(), [y, D] = I([]), j = ee(/* @__PURE__ */ new Set()), [x, P] = I(k || !1), N = (o, t) => {
47
47
  if (!e)
48
48
  return;
49
- o || (o = {
49
+ t || (t = {
50
50
  x: e.getCenter().left,
51
51
  y: e.getCenter().top
52
52
  });
53
- let r = e.getZoom();
54
- r *= Q(0.999, t), r > 20 && (r = 20), r < 0.01 && (r = 0.01), e.zoomToPoint(
55
- o,
56
- r
53
+ let n = e.getZoom();
54
+ n *= $(0.999, o), n > 20 && (n = 20), n < 0.01 && (n = 0.01), e.zoomToPoint(
55
+ t,
56
+ n
57
57
  // 传入修改后的缩放级别
58
- ), A([r, r]);
58
+ ), A([n, n]);
59
59
  };
60
- d(() => {
61
- b.forEach((t) => {
62
- t.renderLabel();
60
+ h(() => {
61
+ y.forEach((o) => {
62
+ o.renderLabel();
63
63
  });
64
- }, [re, b, e]);
65
- const K = (t) => {
66
- var r;
67
- if (((r = t.target) == null ? void 0 : r.tagName) === "INPUT" || !e)
64
+ }, [ie, y, e]);
65
+ const q = (o) => {
66
+ var n;
67
+ if (((n = o.target) == null ? void 0 : n.tagName) === "INPUT" || !e)
68
68
  return;
69
- const o = e == null ? void 0 : e.getActiveObject();
70
- o && v((n) => {
71
- const g = n.findIndex((C) => C.object === o);
72
- return n[g] && (n[g].destroy(), n.splice(g, 1)), f && f(n.map(E)), [...n];
69
+ const t = e == null ? void 0 : e.getActiveObject();
70
+ t && D((r) => {
71
+ let d = r.findIndex((s) => s.object === t);
72
+ if (d === -1 && t && (d = r.findIndex((s) => {
73
+ const i = s._fabricRect;
74
+ return i && i === t;
75
+ })), d >= 0 && r[d]) {
76
+ const s = r[d];
77
+ j.current.add(s.config.id), s.destroy(), r.splice(d, 1), f && f(r.map(O)), setTimeout(() => {
78
+ j.current.delete(s.config.id);
79
+ }, 100);
80
+ } else if (t && e) {
81
+ const s = r.findIndex((i) => {
82
+ const v = i._fabricRect;
83
+ return v && v === t;
84
+ });
85
+ if (s >= 0 && r[s]) {
86
+ const i = r[s];
87
+ j.current.add(i.config.id), i.destroy(), r.splice(s, 1), f && f(r.map(O)), setTimeout(() => {
88
+ j.current.delete(i.config.id);
89
+ }, 100);
90
+ } else
91
+ e.remove(t), e.discardActiveObject(), e.renderAll();
92
+ }
93
+ return [...r];
73
94
  });
74
95
  };
75
- O("Delete", K), O("Backspace", K), O("ctrl", () => {
96
+ L("Delete", q), L("Backspace", q), L("ctrl", () => {
76
97
  P(!0);
77
98
  }, {
78
99
  events: ["keydown"]
79
- }), O("ctrl", () => {
100
+ }), L("ctrl", () => {
80
101
  k || P(!1);
81
102
  }, {
82
103
  events: ["keyup"]
83
- }), d(() => {
104
+ }), h(() => {
84
105
  P(k || !1);
85
106
  }, [k]);
86
- const q = (t) => {
87
- e && ee(e), v((o) => {
88
- const r = o.findIndex((n) => n === t);
89
- return r > -1 && (o.splice(r, 1), f && f(o.map(E)), U()), [...o];
107
+ const F = (o) => {
108
+ e && oe(e), D((t) => {
109
+ const n = t.findIndex((r) => r === o);
110
+ return n > -1 && (t.splice(n, 1), f && f(t.map(O)), z()), [...t];
90
111
  });
91
- }, F = (t) => {
92
- v((o) => {
93
- const r = o.findIndex((n) => n === t);
94
- return r > -1 && (o[r] = t, f && f(o.map(E))), [...o];
112
+ }, G = (o) => {
113
+ D((t) => {
114
+ const n = t.findIndex((r) => r === o);
115
+ return n > -1 && (t[n] = o, f && f(t.map(O))), [...t];
95
116
  });
96
117
  };
97
- d(() => {
118
+ h(() => {
98
119
  if (!e)
99
120
  return;
100
- const t = [];
101
- return l.filter((o) => o.color).forEach((o) => {
102
- t.push(new V({
103
- id: o.id,
104
- name: o.label,
105
- color: o.color,
106
- points: o.box.map((r) => [r[0] + W.left, r[1] + W.top]),
107
- hideDelete: h
121
+ const o = [];
122
+ return m.filter((t) => t.color).forEach((t) => {
123
+ o.push(new te({
124
+ id: t.id,
125
+ name: t.label,
126
+ color: t.color,
127
+ points: t.box.map((n) => [n[0] + W.left, n[1] + W.top]),
128
+ hideDelete: b
108
129
  }, e, {
109
- onChange: F,
110
- onDelete: q,
111
- renderLabelItem: N ? (r) => N ? N(o) : r.name : void 0
130
+ onChange: G,
131
+ onDelete: F,
132
+ renderLabelItem: S ? (n) => S ? S(t) : n.name : void 0
112
133
  }));
113
- }), v(t), t.forEach((o) => {
114
- o.render(e);
134
+ }), D(o), o.forEach((t) => {
135
+ t.render(e);
115
136
  }), () => {
116
- t.forEach((o) => {
117
- o.canvas !== e && o.destroy();
137
+ o.forEach((t) => {
138
+ t.canvas !== e && t.destroy();
118
139
  });
119
140
  };
120
- }, [e, m]);
121
- const U = () => {
122
- e && ue(e, (t) => {
123
- const o = new V({
124
- id: (i == null ? void 0 : i.id) || t.id,
125
- name: (i == null ? void 0 : i.label) || t.label,
126
- color: (i == null ? void 0 : i.color) || t.color,
127
- points: t.box.map((r) => [r[0], r[1]]),
128
- hideDelete: h
141
+ }, [e, p]);
142
+ const z = () => {
143
+ e && ue(e, (o) => {
144
+ const t = new te({
145
+ id: (c == null ? void 0 : c.id) || o.id,
146
+ name: (c == null ? void 0 : c.label) || o.label,
147
+ color: (c == null ? void 0 : c.color) || o.color,
148
+ points: o.box.map((n) => [n[0], n[1]]),
149
+ hideDelete: b
129
150
  }, e, {
130
- onChange: F,
131
- onDelete: q
151
+ onChange: G,
152
+ onDelete: F
132
153
  });
133
- o.active = !0, b.push(o), f && f(b.map(E)), v([...b]);
134
- }, h);
135
- }, ne = () => {
136
- let t = !1;
137
- e && (e.on("mouse:down", (o) => {
138
- t = !0, e.selection = !1;
139
- }), e.on("mouse:move", (o) => {
140
- if (t && o && o.e) {
141
- const r = new z.Point(o.e.movementX, o.e.movementY);
142
- e.relativePan(r);
154
+ t.active = !0, y.push(t), f && f(y.map(O)), D([...y]);
155
+ }, b);
156
+ }, se = () => {
157
+ let o = !1;
158
+ e && (e.on("mouse:down", (t) => {
159
+ o = !0, e.selection = !1;
160
+ }), e.on("mouse:move", (t) => {
161
+ if (o && t && t.e) {
162
+ const n = new Y.Point(t.e.movementX, t.e.movementY);
163
+ e.relativePan(n);
143
164
  }
144
- }), e.on("mouse:up", (o) => {
145
- t = !1, e.selection = !0;
165
+ }), e.on("mouse:up", (t) => {
166
+ o = !1, e.selection = !0;
146
167
  }));
147
- }, se = () => {
168
+ }, ae = () => {
148
169
  e && (e.off("mouse:down"), e.off("mouse:move"), e.off("mouse:up"));
149
170
  };
150
- d(() => {
171
+ h(() => {
151
172
  if (!e)
152
173
  return;
153
- const t = (o) => {
154
- const r = e, n = r == null ? void 0 : r._currentTransform;
155
- if (!n)
174
+ const o = (t) => {
175
+ const n = e, r = n == null ? void 0 : n._currentTransform;
176
+ if (!r)
156
177
  return;
157
- const g = n.action;
158
- if (!g || !g.startsWith("scale"))
178
+ const d = r.action;
179
+ if (!d || !d.startsWith("scale"))
159
180
  return;
160
- const C = e.backgroundImage, u = C == null ? void 0 : C.aCoords;
161
- if (!u)
181
+ const s = e.backgroundImage, i = s == null ? void 0 : s.aCoords;
182
+ if (!i)
162
183
  return;
163
- const D = e.getPointer(o.e);
164
- if (D.x < u.tl.x || D.x > u.br.x || D.y < u.tl.y || D.y > u.br.y) {
165
- const w = r == null ? void 0 : r._onMouseUp;
166
- typeof w == "function" && w(o.e);
184
+ const v = e.getPointer(t.e);
185
+ if (v.x < i.tl.x || v.x > i.br.x || v.y < i.tl.y || v.y > i.br.y) {
186
+ const w = n == null ? void 0 : n._onMouseUp;
187
+ typeof w == "function" && w(t.e);
167
188
  }
168
189
  };
169
- return e.on("mouse:move", t), () => {
170
- e.off("mouse:move", t);
190
+ return e.on("mouse:move", o), () => {
191
+ e.off("mouse:move", o);
171
192
  };
172
- }, [e]), d(() => {
193
+ }, [e]), h(() => {
173
194
  if (!e)
174
195
  return;
175
- const t = (o) => {
176
- const r = e;
177
- if (!!!(r != null && r._currentTransform))
196
+ const o = (t) => {
197
+ const n = e;
198
+ if (!!!(n != null && n._currentTransform))
178
199
  return;
179
- const g = r == null ? void 0 : r._onMouseUp;
180
- typeof g == "function" && g(o.e);
200
+ const d = n == null ? void 0 : n._onMouseUp;
201
+ typeof d == "function" && d(t.e);
181
202
  };
182
- return e.on("mouse:out", t), () => {
183
- e.off("mouse:out", t);
203
+ return e.on("mouse:out", o), () => {
204
+ e.off("mouse:out", o);
184
205
  };
185
- }, [e]), d(() => {
206
+ }, [e]), h(() => {
186
207
  if (e)
187
- return y ? (ne(), e.defaultCursor = "grab", e.on("mouse:down:before", () => {
208
+ return x ? (se(), e.defaultCursor = "grab", e.on("mouse:down:before", () => {
188
209
  e.setCursor("grabbing");
189
210
  }), e.on("mouse:up", () => {
190
211
  e.defaultCursor = "grab";
191
- }), e.getObjects(), v((t) => (t.forEach((o) => {
192
- var r;
193
- return (r = o.object) == null ? void 0 : r.set("evented", !1);
194
- }), t))) : (e.defaultCursor = "default", e.off("mouse:down:before"), e.off("mouse:up"), e.setCursor("default"), v((t) => (t.forEach((o) => {
195
- var r;
196
- return (r = o.object) == null ? void 0 : r.set("evented", !0);
197
- }), t)), U()), () => {
198
- se();
212
+ }), e.getObjects(), D((o) => (o.forEach((t) => {
213
+ var n;
214
+ return (n = t.object) == null ? void 0 : n.set("evented", !1);
215
+ }), o))) : (e.defaultCursor = "default", e.off("mouse:down:before"), e.off("mouse:up"), e.setCursor("default"), D((o) => (o.forEach((t) => {
216
+ var n;
217
+ return (n = t.object) == null ? void 0 : n.set("evented", !0);
218
+ }), o)), z()), () => {
219
+ ae();
199
220
  };
200
- }, [e, y]), d(() => {
201
- if (e == null || e.on("mouse:wheel", (t) => {
202
- const o = t.e.deltaY;
203
- T(o, {
204
- x: t.e.offsetX,
205
- y: t.e.offsetY
206
- }), b.forEach((r) => {
207
- r.renderLabel();
221
+ }, [e, x]), h(() => {
222
+ if (e == null || e.on("mouse:wheel", (o) => {
223
+ const t = o.e.deltaY;
224
+ N(t, {
225
+ x: o.e.offsetX,
226
+ y: o.e.offsetY
227
+ }), y.forEach((n) => {
228
+ n.renderLabel();
208
229
  });
209
- }), !y)
210
- return U(), () => {
211
- e && (ee(e), e.off("mouse:wheel"));
230
+ }), !x)
231
+ return z(), () => {
232
+ e && (oe(e), e.off("mouse:wheel"));
212
233
  };
213
- }, [e, i, b, y]);
214
- const ie = () => {
215
- te({}), _(void 0), A([1, 1]), e == null || e.dispose(), Z(void 0);
234
+ }, [e, c, y, x]);
235
+ const ce = () => {
236
+ ne({}), K(void 0), A([1, 1]), e == null || e.dispose(), Z(void 0);
216
237
  };
217
- return d(() => {
218
- B(!0), ie(), !(!a.current || !m) && z.Image.fromURL(m, (t) => {
219
- t.set({
238
+ return h(() => {
239
+ B(!0), ce(), !(!l.current || !p) && Y.Image.fromURL(p, (o) => {
240
+ o.set({
220
241
  originX: "center",
221
242
  originY: "center"
222
- }), _(t), B(!1);
243
+ }), K(o), B(!1);
223
244
  }, {
224
245
  crossOrigin: "anonymous"
225
246
  });
226
- }, [m]), d(() => {
227
- if (!I && e) {
247
+ }, [p]), h(() => {
248
+ if (!C && e) {
228
249
  try {
229
250
  e.clear();
230
- } catch (Y) {
251
+ } catch (U) {
231
252
  }
232
253
  return;
233
254
  }
234
- if (!a.current || !a.current.parentElement)
255
+ if (!l.current || !l.current.parentElement)
235
256
  return;
236
- const t = I == null ? void 0 : I.getElement();
237
- if (!(t != null && t.width) || !(t != null && t.height))
257
+ const o = C == null ? void 0 : C.getElement();
258
+ if (!(o != null && o.width) || !(o != null && o.height))
238
259
  return;
239
- const o = t.width / t.height, r = a.current.parentElement.offsetWidth, n = a.current.parentElement.offsetHeight, g = r / t.width, C = n / t.height;
240
- let u = [r, n];
241
- g > C ? u = [n * o, n] : u = [r, r / o];
242
- const D = u[0] / t.width, G = u[1] / t.height, w = Math.min(D, G);
260
+ const t = o.width / o.height, n = l.current.parentElement.offsetWidth, r = l.current.parentElement.offsetHeight, d = n / o.width, s = r / o.height;
261
+ let i = [n, r];
262
+ d > s ? i = [r * t, r] : i = [n, n / t];
263
+ const v = i[0] / o.width, J = i[1] / o.height, w = Math.min(v, J);
243
264
  A([w, w]);
244
- const p = new z.Canvas(a.current, {
265
+ const g = new Y.Canvas(l.current, {
245
266
  containerClass: "marking-canvas",
246
- width: r,
247
- height: n
267
+ width: n,
268
+ height: r
248
269
  });
249
- if (p == null || p.setZoom(w), p == null || p.renderAll(), p && I) {
250
- const Y = (r - u[0]) / w / 2, J = (n - u[1]) / w / 2;
251
- p.setBackgroundImage(
252
- I,
270
+ if (g.uniScaleKey = "", g.uniformScaling = !1, g == null || g.setZoom(w), g == null || g.renderAll(), g && C) {
271
+ const U = (n - i[0]) / w / 2, Q = (r - i[1]) / w / 2;
272
+ g.setBackgroundImage(
273
+ C,
253
274
  () => {
254
- p.renderAll(), oe({
255
- left: Y,
256
- top: J
257
- }), Z(p), j && j();
275
+ g.renderAll(), re({
276
+ left: U,
277
+ top: Q
278
+ }), Z(g), E && E();
258
279
  },
259
280
  // 刷新画布
260
281
  {
261
282
  originX: "left",
262
283
  originY: "top",
263
- left: Y,
264
- top: J
284
+ left: U,
285
+ top: Q
265
286
  }
266
287
  );
267
288
  }
268
- }, [I]), d(() => {
269
- b.length > l.length && b.forEach((t) => {
270
- l.find((o) => o.id === t.config.id) || t.destroy();
271
- });
272
- }, [l.length]), d(() => {
273
- e && (y || v((t) => {
274
- const o = e == null ? void 0 : e.getActiveObject(), r = t.find((n) => n.object === o);
275
- return r && i && (r.labelConfig = {
276
- id: i.id,
277
- name: i.label,
278
- color: i.color
279
- }, f && f(t.map(E))), e && (i ? e.defaultCursor = "copy" : e.defaultCursor = "default"), [...t];
289
+ }, [C]), h(() => {
290
+ if (y.length > m.length) {
291
+ if (j.current.size > 0)
292
+ return;
293
+ y.forEach((t) => {
294
+ const n = j.current.has(t.config.id), r = t._isDestroying;
295
+ !m.find((s) => s.id === t.config.id) && !r && !n && t.destroy();
296
+ });
297
+ }
298
+ }, [m.length]), h(() => {
299
+ e && (x || D((o) => {
300
+ const t = e == null ? void 0 : e.getActiveObject(), n = o.find((r) => r.object === t);
301
+ return n && c && (n.labelConfig = {
302
+ id: c.id,
303
+ name: c.label,
304
+ color: c.color
305
+ }, f && f(o.map(O))), e && (c ? e.defaultCursor = "copy" : e.defaultCursor = "default"), [...o];
280
306
  }));
281
- }, [i, e, y]), d(() => {
282
- var t;
283
- if (S && a.current && !M) {
284
- const o = document.createElement("div");
285
- o.setAttribute("style", "width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: absolute;top: 0;"), (t = a.current.parentElement) == null || t.appendChild(o), ce.render(/* @__PURE__ */ c(le, {}), o), H(o);
307
+ }, [c, e, x]), h(() => {
308
+ var o;
309
+ if (T && l.current && !M) {
310
+ const t = document.createElement("div");
311
+ t.setAttribute("style", "width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: absolute;top: 0;"), (o = l.current.parentElement) == null || o.appendChild(t), le.render(/* @__PURE__ */ u(fe, {}), t), H(t);
286
312
  } else
287
- !S && M && (M.remove(), H(null));
288
- }, [S, a.current, M]), /* @__PURE__ */ $("div", {
313
+ !T && M && (M.remove(), H(null));
314
+ }, [T, l.current, M]), /* @__PURE__ */ V("div", {
289
315
  style: {
290
316
  width: "100%",
291
317
  height: "100%",
292
318
  display: "flex"
293
319
  },
294
- children: [/* @__PURE__ */ c("div", {
320
+ children: [/* @__PURE__ */ u("div", {
295
321
  className: "marker-toolbar",
296
- children: /* @__PURE__ */ c("div", {
322
+ children: /* @__PURE__ */ u("div", {
297
323
  className: "create-mode-select",
298
- children: /* @__PURE__ */ $(fe, {
324
+ children: /* @__PURE__ */ V(de, {
299
325
  direction: "vertical",
300
326
  size: 16,
301
- children: [/* @__PURE__ */ c(R, {
327
+ children: [/* @__PURE__ */ u(_, {
302
328
  title: "放大-鼠标滚轮前滑",
303
329
  placement: "right",
304
- children: /* @__PURE__ */ c(X, {
305
- icon: /* @__PURE__ */ c(de, {}),
330
+ children: /* @__PURE__ */ u(X, {
331
+ icon: /* @__PURE__ */ u(me, {}),
306
332
  onClick: () => {
307
- T(-100);
333
+ N(-100);
308
334
  }
309
335
  })
310
- }), /* @__PURE__ */ c(R, {
336
+ }), /* @__PURE__ */ u(_, {
311
337
  title: "缩小-鼠标滚轮后滑",
312
338
  placement: "right",
313
- children: /* @__PURE__ */ c(X, {
314
- icon: /* @__PURE__ */ c(me, {}),
339
+ children: /* @__PURE__ */ u(X, {
340
+ icon: /* @__PURE__ */ u(ge, {}),
315
341
  onClick: () => {
316
- T(100);
342
+ N(100);
317
343
  }
318
344
  })
319
- }), !k && /* @__PURE__ */ c(R, {
345
+ }), !k && /* @__PURE__ */ u(_, {
320
346
  title: "拖动-按住ctrl",
321
347
  placement: "right",
322
- children: /* @__PURE__ */ c(X, {
348
+ children: /* @__PURE__ */ u(X, {
323
349
  disabled: k,
324
- icon: /* @__PURE__ */ c(ge, {}),
325
- className: y ? "active" : "",
350
+ icon: /* @__PURE__ */ u(he, {}),
351
+ className: x ? "active" : "",
326
352
  onClick: () => {
327
- P(!y);
353
+ P(!x);
328
354
  }
329
355
  })
330
356
  })]
331
357
  })
332
358
  })
333
- }), /* @__PURE__ */ c("div", {
334
- className: he({
359
+ }), /* @__PURE__ */ u("div", {
360
+ className: pe({
335
361
  "label-maker-wrap": !0,
336
- draggable: y
362
+ draggable: x
337
363
  }),
338
- onContextMenu: (t) => {
339
- t.preventDefault();
364
+ onContextMenu: (o) => {
365
+ o.preventDefault();
340
366
  },
341
- children: /* @__PURE__ */ c("canvas", {
367
+ children: /* @__PURE__ */ u("canvas", {
342
368
  className: "label-maker-canvas",
343
- ref: a
369
+ ref: l
344
370
  })
345
371
  })]
346
372
  });
347
373
  };
348
374
  export {
349
- Le as default
375
+ Re as default
350
376
  };