@glodon-aiot/dataset-annotation 3.11.1-shapshot.1765331459 → 3.13.0-alpha.28

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