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