@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,20 +1,20 @@
1
- var A = Object.defineProperty, B = Object.defineProperties;
2
- var T = Object.getOwnPropertyDescriptors;
3
- var U = Object.getOwnPropertySymbols;
4
- var H = Object.prototype.hasOwnProperty, D = Object.prototype.propertyIsEnumerable;
5
- var C = (r, e, s) => e in r ? A(r, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[e] = s, d = (r, e) => {
1
+ var p = Object.defineProperty, m = Object.defineProperties;
2
+ var u = Object.getOwnPropertyDescriptors;
3
+ var b = Object.getOwnPropertySymbols;
4
+ var w = Object.prototype.hasOwnProperty, C = Object.prototype.propertyIsEnumerable;
5
+ var g = (l, e, s) => e in l ? p(l, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : l[e] = s, n = (l, e) => {
6
6
  for (var s in e || (e = {}))
7
- H.call(e, s) && C(r, s, e[s]);
8
- if (U)
9
- for (var s of U(e))
10
- D.call(e, s) && C(r, s, e[s]);
11
- return r;
12
- }, m = (r, e) => B(r, T(e));
13
- var b = (r, e, s) => (C(r, typeof e != "symbol" ? e + "" : e, s), s);
14
- import { fabric as v } from "fabric";
15
- import I from "./FabricCustomize.mjs";
16
- import { formatColorToArray as X } from "../../../../utils/color.mjs";
17
- const O = {
7
+ w.call(e, s) && g(l, s, e[s]);
8
+ if (b)
9
+ for (var s of b(e))
10
+ C.call(e, s) && g(l, s, e[s]);
11
+ return l;
12
+ }, v = (l, e) => m(l, u(e));
13
+ var f = (l, e, s) => (g(l, typeof e != "symbol" ? e + "" : e, s), s);
14
+ import { fabric as d } from "fabric";
15
+ import y from "./FabricCustomize.mjs";
16
+ import { formatColorToArray as _ } from "../../../../utils/color.mjs";
17
+ const $ = {
18
18
  borderWidth: 2,
19
19
  controls: ["TL", "BL", "TR", "BR"],
20
20
  cornerStrokeColor: "#84868C",
@@ -22,16 +22,16 @@ const O = {
22
22
  visible: !0,
23
23
  active: !1
24
24
  };
25
- class M {
26
- constructor(e, s, c) {
27
- b(this, "config");
28
- b(this, "color");
29
- b(this, "_active", !1);
30
- b(this, "_fabricRect", null);
31
- b(this, "_label", null);
32
- b(this, "_hover", !1);
33
- b(this, "_strokeRect");
34
- this._canvas = s, this.handlers = c, v.Rect.prototype.cornerColor = "blue", this.config = d(d({}, O), e), this.color = X(e.color), this._active = this.config.active || !1, s && this.render(s);
25
+ class F {
26
+ constructor(e, s, h) {
27
+ f(this, "config");
28
+ f(this, "color");
29
+ f(this, "_active", !1);
30
+ f(this, "_fabricRect", null);
31
+ f(this, "_label", null);
32
+ f(this, "_hover", !1);
33
+ f(this, "_strokeRect");
34
+ this._canvas = s, this.handlers = h, d.Rect.prototype.cornerColor = "blue", this.config = n(n({}, $), e), this.color = _(e.color), this._active = this.config.active || !1, s && this.render(s);
35
35
  }
36
36
  get object() {
37
37
  return this._fabricRect;
@@ -41,16 +41,14 @@ class M {
41
41
  }
42
42
  set active(e) {
43
43
  var s;
44
- this._active = e, (s = this._fabricRect) != null && s.canvas && (e && !this.config.hideDelete ? (this._fabricRect.set(m(d({}, this.activeStyle), {
45
- lockUniScaling: !1
46
- })), this._fabricRect.uniformScaling = !1, this.canvas.setActiveObject(this._fabricRect)) : (this.canvas.discardActiveObject(), this.hover || this._fabricRect.set(this.normalStyle)), this.canvas.requestRenderAll());
44
+ this._active = e, (s = this._fabricRect) != null && s.canvas && (e && !this.config.hideDelete ? (this._fabricRect.set(this.activeStyle), this.canvas.setActiveObject(this._fabricRect)) : (this.canvas.discardActiveObject(), this.hover || this._fabricRect.set(this.normalStyle)), this.canvas.requestRenderAll());
47
45
  }
48
46
  get hover() {
49
47
  return this._hover;
50
48
  }
51
49
  set hover(e) {
52
- var s, c;
53
- this._hover = e, e ? (s = this._fabricRect) == null || s.set(this.hoverStyle) : this.active || (c = this._fabricRect) == null || c.set(this.normalStyle), this.canvas.requestRenderAll();
50
+ var s, h;
51
+ this._hover = e, e ? (s = this._fabricRect) == null || s.set(this.hoverStyle) : this.active || (h = this._fabricRect) == null || h.set(this.normalStyle), this.canvas.requestRenderAll();
54
52
  }
55
53
  get canvas() {
56
54
  return this._canvas;
@@ -70,7 +68,7 @@ class M {
70
68
  };
71
69
  }
72
70
  get activeStyle() {
73
- return m(d({}, this.normalStyle), {
71
+ return v(n({}, this.normalStyle), {
74
72
  content: `<svg height="500" width="500"><text fill="#ffffff" font-size="45" x="50" y="86">${this.config.name}</text></svg>`,
75
73
  fill: `rgba(${this.color[0]},${this.color[1]}, ${this.color[2]}, 0.1)`
76
74
  });
@@ -85,33 +83,28 @@ class M {
85
83
  cornerStrokeColor: "#84868C",
86
84
  cornerColor: "#FFFFFF",
87
85
  transparentCorners: !1
88
- }, s = 0, c = new v.Rect(
86
+ }, s = 0, h = new d.Rect(
89
87
  // this.config.points?.map((p) => ({ x: p[0], y: p[1] })),
90
- m(d(d({
88
+ n(n({
91
89
  left: this.config.points[0][0],
92
90
  top: this.config.points[0][1],
93
91
  width: this.config.points[2][0] - this.config.points[0][0] - s,
94
92
  height: this.config.points[2][1] - this.config.points[0][1] - s
95
- }, e), this.normalStyle), {
96
- // 禁止缩放时翻转
97
- lockScalingFlip: !0,
98
- // 允许不保持比例调整(可以自由调整宽高)
99
- lockUniScaling: !1
100
- })
93
+ }, e), this.normalStyle)
101
94
  );
102
- c.setControlsVisibility({
95
+ h.setControlsVisibility({
103
96
  mtr: !1
104
97
  });
105
- const l = () => {
106
- if (c.canvas !== this.canvas) {
107
- this.canvas.off("after:render", l);
98
+ const a = () => {
99
+ if (h.canvas !== this.canvas) {
100
+ this.canvas.off("after:render", a);
108
101
  return;
109
102
  }
110
103
  this.canvas.contextContainer.strokeStyle = `rgb(${this.color[0]},${this.color[1]}, ${this.color[2]})`;
111
- const o = c.getBoundingRect();
104
+ const o = h.getBoundingRect();
112
105
  this._strokeRect = this.canvas.contextContainer.strokeRect(o.left + 0.5, o.top + 0.5, o.width, o.height);
113
106
  };
114
- return this.canvas.on("after:render", l), c;
107
+ return this.canvas.on("after:render", a), h;
115
108
  }
116
109
  scaledNumber(e) {
117
110
  return e / this.canvas.getZoom();
@@ -137,28 +130,25 @@ class M {
137
130
  // });
138
131
  // }
139
132
  createLabelName() {
140
- const [e, s, c] = this.color, l = new v.Text(this.handlers.renderLabelItem ? this.handlers.renderLabelItem(this.config) : this.config.name, {
133
+ const [e, s, h] = this.color, a = new d.Text(this.handlers.renderLabelItem ? this.handlers.renderLabelItem(this.config) : this.config.name, {
141
134
  fill: "#FFFFFF",
142
135
  fontSize: 12,
143
136
  selectable: !1,
144
- evented: !1,
145
137
  top: 4,
146
138
  left: 8
147
- }), o = new v.Rect({
139
+ }), o = new d.Rect({
148
140
  selectable: !1,
149
- evented: !1,
150
141
  strokeWidth: 0,
151
- fill: `rgb(${e},${s},${c})`,
142
+ fill: `rgb(${e},${s},${h})`,
152
143
  rx: 2,
153
144
  ry: 2,
154
- width: (l.width || 0) + 16,
155
- height: (l.height || 0) + 8,
145
+ width: (a.width || 0) + 16,
146
+ height: (a.height || 0) + 8,
156
147
  left: 0,
157
148
  top: 0
158
149
  });
159
- return new v.Group([o, l], {
150
+ return new d.Group([o, a], {
160
151
  selectable: !1,
161
- evented: !1,
162
152
  // lockScalingX: false,
163
153
  // lockScalingY: false,
164
154
  scaleX: 1 / this.canvas.getZoom(),
@@ -169,24 +159,24 @@ class M {
169
159
  var e, s;
170
160
  if (this._fabricRect) {
171
161
  if (this._label || (this._label = this.createLabelName(), this.setLabelPosition()), this._label.canvas === this.canvas) {
172
- const c = this._label.getObjects().find((o) => o.type === "rect"), l = this._label.getObjects().find((o) => o.type === "text");
173
- if (l) {
174
- l.set({
162
+ const h = this._label.getObjects().find((o) => o.type === "rect"), a = this._label.getObjects().find((o) => o.type === "text");
163
+ if (a) {
164
+ a.set({
175
165
  text: this.handlers.renderLabelItem ? this.handlers.renderLabelItem(this.config) : this.config.name,
176
166
  left: 8
177
167
  // fontSize: this.scaledNumber(12),
178
168
  });
179
- const o = (l.getBoundingRect().width || 0) + 16;
180
- c == null || c.set({
169
+ const o = (a.getBoundingRect().width || 0) + 16;
170
+ h == null || h.set({
181
171
  fill: `rgba(${this.color[0]},${this.color[1]}, ${this.color[2]}, 1)`,
182
172
  width: o,
183
173
  left: -o / 2
184
- }), l.set({
174
+ }), a.set({
185
175
  left: -o / 2 + 8
186
176
  });
187
- const g = ((e = this._fabricRect.aCoords) == null ? void 0 : e.tl.x) !== void 0 ? (s = this._fabricRect.aCoords) == null ? void 0 : s.tl.x : void 0;
177
+ const r = ((e = this._fabricRect.aCoords) == null ? void 0 : e.tl.x) !== void 0 ? (s = this._fabricRect.aCoords) == null ? void 0 : s.tl.x : void 0;
188
178
  this._label.set({
189
- left: g,
179
+ left: r,
190
180
  width: o
191
181
  });
192
182
  }
@@ -196,109 +186,82 @@ class M {
196
186
  }
197
187
  }
198
188
  setLabelPosition() {
199
- var g, h, n, t;
189
+ var r, t, i, c;
200
190
  if (!this._fabricRect || !this._label)
201
191
  return;
202
- const e = this._label.getObjects().find((i) => i.type === "rect");
192
+ const e = this._label.getObjects().find((R) => R.type === "rect");
203
193
  if (!e)
204
194
  return;
205
- const s = e.height ? e.height : void 0, c = e.width ? e.width : void 0, l = ((g = this._fabricRect.aCoords) == null ? void 0 : g.tl.y) !== void 0 && s !== void 0 && e.scaleY ? ((h = this._fabricRect.aCoords) == null ? void 0 : h.tl.y) - s / this.canvas.getZoom() : void 0, o = ((n = this._fabricRect.aCoords) == null ? void 0 : n.tl.x) !== void 0 ? (t = this._fabricRect.aCoords) == null ? void 0 : t.tl.x : void 0;
195
+ const s = e.height ? e.height : void 0, h = e.width ? e.width : void 0, a = ((r = this._fabricRect.aCoords) == null ? void 0 : r.tl.y) !== void 0 && s !== void 0 && e.scaleY ? ((t = this._fabricRect.aCoords) == null ? void 0 : t.tl.y) - s / this.canvas.getZoom() : void 0, o = ((i = this._fabricRect.aCoords) == null ? void 0 : i.tl.x) !== void 0 ? (c = this._fabricRect.aCoords) == null ? void 0 : c.tl.x : void 0;
206
196
  this._label.set({
207
- top: l,
197
+ top: a,
208
198
  left: o,
209
199
  height: s,
210
- width: c,
200
+ width: h,
211
201
  scaleX: 1 / this.canvas.getZoom(),
212
202
  scaleY: 1 / this.canvas.getZoom()
213
- }), this.config = d({}, this.config);
203
+ }), this.config = n({}, this.config);
214
204
  }
215
205
  addToCanvas(e) {
216
206
  if (!this._fabricRect)
217
207
  return;
218
- this.canvas = e, this.canvas.add(this._fabricRect), this._fabricRect.on("mouseover", (h) => {
208
+ this.canvas = e, this.canvas.add(this._fabricRect), this._fabricRect.on("mouseover", (o) => {
219
209
  this.hover = !0;
220
- }), this._fabricRect.on("mouseout", (h) => {
210
+ }), this._fabricRect.on("mouseout", (o) => {
221
211
  this.hover = !1;
222
212
  }), this._fabricRect.on("mousedown", () => {
223
213
  this._fabricRect && this.canvas.setActiveObject(this._fabricRect);
224
- }), this._handleSelectionUpdate && (this.canvas.off("selection:created", this._handleSelectionUpdate), this.canvas.off("selection:updated", this._handleSelectionUpdate)), this._handleSelectionCleared && this.canvas.off("selection:cleared", this._handleSelectionCleared);
225
- const s = (h) => {
226
- var n;
227
- (n = h.selected) != null && n.some((t) => t === this._fabricRect) ? (this.active = !0, this._fabricRect && (this._fabricRect.set({
228
- lockUniScaling: !1
229
- }), this._fabricRect.uniformScaling = !1)) : this.active && (this.active = !1);
230
- }, c = (h) => {
231
- this.active && (this.active = !1);
214
+ });
215
+ const s = (o) => {
216
+ var r;
217
+ (r = o.selected) != null && r.some((t) => t === this._fabricRect) ? this.active = !0 : this.active && (this.active = !1);
232
218
  };
233
- this.canvas.on("selection:created", s), this.canvas.on("selection:updated", s), this.canvas.on("selection:cleared", c), this._handleSelectionUpdate = s, this._handleSelectionCleared = c;
234
- const l = (h) => {
235
- var y, x, $, j, k, L;
236
- const n = h.transform.action;
237
- h.transform.corner;
238
- const t = h.transform.target, i = h.transform.target.canvas.backgroundImage, a = 0;
239
- if (i && (n === "drag" && (t.top < i.top && t.set({
219
+ this.canvas.on("selection:created", s), this.canvas.on("selection:updated", s), this.canvas.on("selection:cleared", (o) => {
220
+ this.active && (this.active = !1);
221
+ });
222
+ const h = (o) => {
223
+ const r = o.transform.action;
224
+ o.transform.corner;
225
+ const t = o.transform.target, i = o.transform.target.canvas.backgroundImage, c = 0;
226
+ i && (r === "drag" && (t.top < i.top && t.set({
240
227
  top: i.top
241
- }), t.top + (t.height + a) * t.scaleY > i.top + i.height && t.set({
242
- top: i.height + i.top - (t.height + a) * t.scaleY
228
+ }), t.top + (t.height + c) * t.scaleY > i.top + i.height && t.set({
229
+ top: i.height + i.top - (t.height + c) * t.scaleY
243
230
  }), t.left < i.left && t.set({
244
231
  left: i.left
245
- }), t.left + (t.width + a) * t.scaleX > i.left + i.width && t.set({
246
- left: i.width + i.left - (t.width + a) * t.scaleX
247
- })), n === "scale" && (t.top + (t.height + a) * t.scaleY > i.top + i.height && t.set({
248
- top: (t.height + a) * t.scaleY > i.height ? i.top : i.top + i.height - (t.height + a) * t.scaleY,
249
- height: (t.height + a) * t.scaleY > i.height ? i.height - a : t.height + a
250
- }), t.left + (t.width + a) * t.scaleX > i.left + i.width && t.set({
251
- left: i.width + i.left - (t.width + a) * t.scaleX
252
- })), n === "scaleX" && (t.left + (t.width + a) * t.scaleX > i.left + i.width && t.set({
253
- left: t.left - (t.left + (t.width + a) * t.scaleX - (i.left + i.width))
232
+ }), t.left + (t.width + c) * t.scaleX > i.left + i.width && t.set({
233
+ left: i.width + i.left - (t.width + c) * t.scaleX
234
+ })), r === "scale" && (t.top + (t.height + c) * t.scaleY > i.top + i.height && t.set({
235
+ top: (t.height + c) * t.scaleY > i.height ? i.top : i.top + i.height - (t.height + c) * t.scaleY,
236
+ height: (t.height + c) * t.scaleY > i.height ? i.height - c : t.height + c
237
+ }), t.left + (t.width + c) * t.scaleX > i.left + i.width && t.set({
238
+ left: i.width + i.left - (t.width + c) * t.scaleX
239
+ })), r === "scaleX" && (t.left + (t.width + c) * t.scaleX > i.left + i.width && t.set({
240
+ left: t.left - (t.left + (t.width + c) * t.scaleX - (i.left + i.width))
254
241
  }), t.left < i.left && t.set({
255
242
  left: i.left
256
- })), n === "scaleY" && (t.top + (t.height + a) * t.scaleY > i.top + i.height && t.set({
257
- top: t.top - (t.top + (t.height + a) * t.scaleY - (i.top + i.height))
243
+ })), r === "scaleY" && (t.top + (t.height + c) * t.scaleY > i.top + i.height && t.set({
244
+ top: t.top - (t.top + (t.height + c) * t.scaleY - (i.top + i.height))
258
245
  }), t.top < i.top && t.set({
259
246
  top: i.top
260
- })), (t.width + a) * t.scaleX > i.width && t.set({
247
+ })), (t.width + c) * t.scaleX > i.width && t.set({
261
248
  left: i.left,
262
- width: (i.width - a) / t.scaleX
263
- }), (t.height + a) * t.scaleY > i.height && t.set({
249
+ width: (i.width - c) / t.scaleX
250
+ }), (t.height + c) * t.scaleY > i.height && t.set({
264
251
  top: i.top,
265
- height: (i.height - a) / t.scaleY
266
- })), i) {
267
- const _ = t.getBoundingRect(!0), u = (y = i.left) != null ? y : 0, S = (x = i.top) != null ? x : 0, Y = u + (($ = i.width) != null ? $ : 0), F = S + ((j = i.height) != null ? j : 0);
268
- if (_.width > ((k = i.width) != null ? k : _.width)) {
269
- const w = (i.width - a) / Math.max(t.width, 1);
270
- t.set({
271
- scaleX: Math.min(t.scaleX, w)
272
- });
273
- }
274
- if (_.height > ((L = i.height) != null ? L : _.height)) {
275
- const w = (i.height - a) / Math.max(t.height, 1);
276
- t.set({
277
- scaleY: Math.min(t.scaleY, w)
278
- });
279
- }
280
- const f = t.getBoundingRect(!0);
281
- let p = 0, R = 0;
282
- f.left < u ? p = u - f.left : f.left + f.width > Y && (p = Y - (f.left + f.width)), f.top < S ? R = S - f.top : f.top + f.height > F && (R = F - (f.top + f.height)), (p !== 0 || R !== 0) && t.set({
283
- left: t.left + p,
284
- top: t.top + R
285
- });
286
- }
287
- this.canvas.renderAll();
288
- }, o = (h) => {
289
- l(h), this.setLabelPosition();
252
+ height: (i.height - c) / t.scaleY
253
+ })), this.canvas.renderAll();
254
+ }, a = (o) => {
255
+ h(o), this.setLabelPosition();
290
256
  };
291
- this._fabricRect.on("moving", o), this._fabricRect.on("scaling", o), this._fabricRect.on("rotating", o), this._fabricRect.on("skewing", o), this._fabricRect.on("resizing", o), this._objectRemovedHandler && this.canvas.off("object:removed", this._objectRemovedHandler);
292
- const g = (h) => {
293
- var n;
294
- ((n = h.target) == null ? void 0 : n.type) === "rect" && h.target === this._fabricRect && !this._isDestroying && this._fabricRect && this.destroy();
295
- };
296
- this.canvas.on("object:removed", g), this._objectRemovedHandler = g, this.canvas.on("object:modified", (h) => {
297
- h.target === this._fabricRect && (this.setLabelPosition(), this.handlers.onChange && this.handlers.onChange(this));
257
+ this._fabricRect.on("moving", a), this._fabricRect.on("scaling", a), this._fabricRect.on("rotating", a), this._fabricRect.on("skewing", a), this._fabricRect.on("resizing", a), this.canvas.on("object:removed", (o) => {
258
+ o.target === this._fabricRect && this.destroy();
259
+ }), this.canvas.on("object:modified", (o) => {
260
+ o.target === this._fabricRect && (this.setLabelPosition(), this.handlers.onChange && this.handlers.onChange(this));
298
261
  });
299
262
  }
300
263
  render(e) {
301
- I(v), this._fabricRect || (this._fabricRect = this.createRect()), this._fabricRect.canvas === this.canvas ? this._fabricRect.set({
264
+ y(d), this._fabricRect || (this._fabricRect = this.createRect()), this._fabricRect.canvas === this.canvas ? this._fabricRect.set({
302
265
  fill: `rgba(${this.color[0]},${this.color[1]}, ${this.color[2]}, 0)`,
303
266
  stroke: `rgba(${this.color[0]},${this.color[1]}, ${this.color[2]}, 1)`
304
267
  }) : this.addToCanvas(e), this.renderLabel();
@@ -309,19 +272,12 @@ class M {
309
272
  }
310
273
  }
311
274
  set labelConfig(e) {
312
- this.config = d(d({}, this.config), e), this.color = X(e.color), this.render(this.canvas), this.handlers.onChange && this.handlers.onChange(this);
275
+ this.config = n(n({}, this.config), e), this.color = _(e.color), this.render(this.canvas), this.handlers.onChange && this.handlers.onChange(this);
313
276
  }
314
277
  destroy() {
315
- if (!this._isDestroying) {
316
- if (this._isDestroying = !0, this._objectRemovedHandler) {
317
- this.canvas.off("object:removed", this._objectRemovedHandler);
318
- const e = this._objectRemovedHandler;
319
- this.canvas.off("object:removed", e), this._objectRemovedHandler = null;
320
- }
321
- this._handleSelectionUpdate && (this.canvas.off("selection:created", this._handleSelectionUpdate), this.canvas.off("selection:updated", this._handleSelectionUpdate), this._handleSelectionUpdate = null), this._handleSelectionCleared && (this.canvas.off("selection:cleared", this._handleSelectionCleared), this._handleSelectionCleared = null), this._fabricRect && this.canvas.remove(this._fabricRect), this._label && this.canvas.remove(this._label), this._label = null, this._fabricRect = null, this.canvas.requestRenderAll(), this.handlers.onDelete && this.handlers.onDelete(this);
322
- }
278
+ this._fabricRect && this.canvas.remove(this._fabricRect), this._label && this.canvas.remove(this._label), this._label = null, this._fabricRect = null, this.canvas.requestRenderAll(), this.handlers.onDelete && this.handlers.onDelete(this);
323
279
  }
324
280
  }
325
281
  export {
326
- M as default
282
+ F as default
327
283
  };