@glodon-aiot/dataset-annotation 3.1.0-beta.15 → 3.2.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 (121) hide show
  1. package/dist/dataset-annotation.js +123591 -0
  2. package/dist/dataset-annotation.umd.cjs +1017 -0
  3. package/dist/example/DatasetAnnotationDemo.d.ts +3 -0
  4. package/dist/example/DemoTabs.d.ts +3 -0
  5. package/dist/example/DetectionDatasetDemo.d.ts +5 -0
  6. package/dist/example/DetectionImageDemo.d.ts +5 -0
  7. package/dist/example/OcrDatasetDemo.d.ts +5 -0
  8. package/dist/example/OcrImageDemo.d.ts +5 -0
  9. package/dist/example/OcrkvcDatasetDemo.d.ts +5 -0
  10. package/dist/example/constant.local.d.ts +6 -0
  11. package/dist/example/index.d.ts +1 -0
  12. package/dist/src/Common/Page/index.d.ts +2 -1
  13. package/dist/src/Common/PageHeader/index.d.ts +1 -0
  14. package/dist/src/DatasetContext/index.d.ts +4 -3
  15. package/dist/src/components/CompositionInput/index.d.ts +2 -2
  16. package/dist/src/components/DataEmpty/index.d.ts +2 -1
  17. package/dist/src/components/DetectionAnnotation/PreSamplesPage/index.d.ts +2 -1
  18. package/dist/src/components/DetectionAnnotation/components/DisabledTooltip/index.d.ts +2 -2
  19. package/dist/src/components/DetectionAnnotation/components/ImageDetail/index.d.ts +2 -1
  20. package/dist/src/components/DetectionAnnotation/components/LabelMaker/Drawable.d.ts +2 -2
  21. package/dist/src/components/DetectionAnnotation/components/LabelMaker/RectLabel.d.ts +2 -2
  22. package/dist/src/components/DetectionAnnotation/components/LabelMaker/index.d.ts +1 -0
  23. package/dist/src/components/DetectionAnnotation/components/Labels/index.d.ts +1 -0
  24. package/dist/src/components/DetectionAnnotation/components/TagItem/index.d.ts +2 -1
  25. package/dist/src/components/DetectionAnnotation/index.d.ts +2 -1
  26. package/dist/src/components/DetectionImageAnnotation/index.d.ts +2 -0
  27. package/dist/src/components/Iconfont/index.d.ts +1 -1
  28. package/dist/src/components/MarkDescriptions/index.d.ts +1 -0
  29. package/dist/src/components/OCRImageViewer/index.d.ts +2 -1
  30. package/dist/src/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/LabelEditorInput.d.ts +2 -2
  31. package/dist/src/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/LabelEditorItem.d.ts +2 -1
  32. package/dist/src/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/LableEditor.d.ts +1 -0
  33. package/dist/src/components/OcrAnnotation/MarkKVOCRModal/index.d.ts +1 -0
  34. package/dist/src/components/OcrAnnotation/MarkOCRBoxModal/ImageDetail/index.d.ts +2 -1
  35. package/dist/src/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/LabelEditorInput.d.ts +2 -2
  36. package/dist/src/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/LabelEditorItem.d.ts +1 -0
  37. package/dist/src/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/LableEditor.d.ts +1 -0
  38. package/dist/src/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/index.d.ts +1 -0
  39. package/dist/src/components/OcrAnnotation/MarkOCRBoxModal/index.d.ts +1 -0
  40. package/dist/src/components/OcrAnnotation/OcrModal/index.d.ts +2 -1
  41. package/dist/src/components/OcrAnnotation/PreLabelOCR/PreLabelModal.d.ts +2 -1
  42. package/dist/src/components/OcrAnnotation/PreLabelOCR/index.d.ts +2 -1
  43. package/dist/src/components/OcrAnnotation/index.d.ts +2 -1
  44. package/dist/src/components/OcrImageAnnotation/index.d.ts +2 -0
  45. package/dist/src/components/PageNav/index.d.ts +2 -1
  46. package/dist/src/components/PicZipImportModal/index.d.ts +2 -1
  47. package/dist/src/components/PreLabelOCR/PreLabelModal.d.ts +2 -1
  48. package/dist/src/components/PreLabelOCR/index.d.ts +2 -1
  49. package/dist/src/components/ScanTable/index.d.ts +2 -1
  50. package/dist/src/components/Thumbnail/index.d.ts +2 -1
  51. package/dist/src/components/hooks/useBlocker.d.ts +1 -1
  52. package/dist/src/featuresConfig.d.ts +1 -1
  53. package/package.json +15 -22
  54. package/dist/es/Common/Page/index.mjs +0 -28
  55. package/dist/es/Common/PageContent/index.mjs +0 -18
  56. package/dist/es/Common/PageHeader/index.mjs +0 -38
  57. package/dist/es/DatasetContext/index.mjs +0 -11
  58. package/dist/es/_virtual/_commonjsHelpers.mjs +0 -6
  59. package/dist/es/_virtual/index.mjs +0 -4
  60. package/dist/es/access/images/data_empty.svg.mjs +0 -4
  61. package/dist/es/components/CompositionInput/index.mjs +0 -53
  62. package/dist/es/components/DataEmpty/index.mjs +0 -50
  63. package/dist/es/components/DetectionAnnotation/PreSamplesPage/index.mjs +0 -291
  64. package/dist/es/components/DetectionAnnotation/components/DisabledTooltip/index.mjs +0 -23
  65. package/dist/es/components/DetectionAnnotation/components/ImageDetail/index.mjs +0 -165
  66. package/dist/es/components/DetectionAnnotation/components/LabelMaker/Drawable.mjs +0 -51
  67. package/dist/es/components/DetectionAnnotation/components/LabelMaker/FabricCustomize.mjs +0 -42
  68. package/dist/es/components/DetectionAnnotation/components/LabelMaker/RectLabel.mjs +0 -283
  69. package/dist/es/components/DetectionAnnotation/components/LabelMaker/icons/delete-icon.svg.mjs +0 -4
  70. package/dist/es/components/DetectionAnnotation/components/LabelMaker/index.mjs +0 -314
  71. package/dist/es/components/DetectionAnnotation/components/Labels/index.mjs +0 -200
  72. package/dist/es/components/DetectionAnnotation/components/TagItem/index.mjs +0 -143
  73. package/dist/es/components/DetectionAnnotation/icon_item_empty.svg.mjs +0 -4
  74. package/dist/es/components/DetectionAnnotation/index.mjs +0 -712
  75. package/dist/es/components/DetectionImageAnnotation/index.mjs +0 -61
  76. package/dist/es/components/Iconfont/index.mjs +0 -16
  77. package/dist/es/components/MarkDescriptions/index.mjs +0 -65
  78. package/dist/es/components/OCRImageViewer/index.mjs +0 -212
  79. package/dist/es/components/OcrAnnotation/MarkKVOCRModal/CategoryDrawer.mjs +0 -136
  80. package/dist/es/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/LabelEditorInput.mjs +0 -57
  81. package/dist/es/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/LabelEditorItem.mjs +0 -72
  82. package/dist/es/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/LableEditor.mjs +0 -54
  83. package/dist/es/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/index.mjs +0 -366
  84. package/dist/es/components/OcrAnnotation/MarkKVOCRModal/index.mjs +0 -254
  85. package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/ImageDetail/index.mjs +0 -100
  86. package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/images/delete.png.mjs +0 -4
  87. package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/index.mjs +0 -755
  88. package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/index.mjs +0 -230
  89. package/dist/es/components/OcrAnnotation/OcrModal/index.mjs +0 -179
  90. package/dist/es/components/OcrAnnotation/PreLabelOCR/PreLabelModal.mjs +0 -280
  91. package/dist/es/components/OcrAnnotation/PreLabelOCR/index.mjs +0 -43
  92. package/dist/es/components/OcrAnnotation/constant.mjs +0 -5
  93. package/dist/es/components/OcrAnnotation/index.mjs +0 -381
  94. package/dist/es/components/OcrImageAnnotation/index.mjs +0 -39
  95. package/dist/es/components/PageNav/index.mjs +0 -29
  96. package/dist/es/components/PicZipImportModal/index.mjs +0 -583
  97. package/dist/es/components/PicZipImportModal/pic_zip.svg.mjs +0 -4
  98. package/dist/es/components/PicZipImportModal/pic_zip_json.svg.mjs +0 -4
  99. package/dist/es/components/PreLabelOCR/PreLabelModal.mjs +0 -275
  100. package/dist/es/components/PreLabelOCR/index.mjs +0 -43
  101. package/dist/es/components/ScanTable/index.mjs +0 -96
  102. package/dist/es/components/Thumbnail/default.png.mjs +0 -4
  103. package/dist/es/components/Thumbnail/index.mjs +0 -30
  104. package/dist/es/components/hooks/Prompt.mjs +0 -33
  105. package/dist/es/constant.mjs +0 -13
  106. package/dist/es/createDatasetAnnotation/index.mjs +0 -133
  107. package/dist/es/createDetectionDatasetAnnotation/index.mjs +0 -129
  108. package/dist/es/createDetectionImageAnnotation/index.mjs +0 -31
  109. package/dist/es/createOcrDatasetAnnotation/index.mjs +0 -129
  110. package/dist/es/createOcrImageAnnotation/index.mjs +0 -33
  111. package/dist/es/featuresConfig.mjs +0 -79
  112. package/dist/es/index.mjs +0 -35
  113. package/dist/es/node_modules/classnames/index.mjs +0 -42
  114. package/dist/es/utils/color.mjs +0 -30
  115. package/dist/es/utils/index.mjs +0 -22
  116. package/dist/es/utils/sign.mjs +0 -33
  117. package/dist/lib/index.js +0 -7
  118. package/dist/src/components/Iconfont/font_3140028_iptomfpgyu.d.ts +0 -0
  119. package/dist/src/components/Iconfont/font_3454453_gu5ijeufyng.d.ts +0 -0
  120. package/dist/src/components/Iconfont/font_4108228_3slzqhoow93.d.ts +0 -0
  121. package/dist/src/components/Iconfont/font_4439177_k3mjwv7kzfd.d.ts +0 -0
@@ -1,283 +0,0 @@
1
- var p = Object.defineProperty, u = Object.defineProperties;
2
- var m = 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
- for (var s in e || (e = {}))
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) => u(l, m(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
- borderWidth: 2,
19
- controls: ["TL", "BL", "TR", "BR"],
20
- cornerStrokeColor: "#84868C",
21
- cornerSize: 6,
22
- visible: !0,
23
- active: !1
24
- };
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
- }
36
- get object() {
37
- return this._fabricRect;
38
- }
39
- get active() {
40
- return this._active;
41
- }
42
- set active(e) {
43
- var s;
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());
45
- }
46
- get hover() {
47
- return this._hover;
48
- }
49
- set hover(e) {
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();
52
- }
53
- get canvas() {
54
- return this._canvas;
55
- }
56
- set canvas(e) {
57
- this._canvas !== e && (this._canvas = e, this.render(e));
58
- }
59
- get normalStyle() {
60
- return {
61
- fill: `rgba(${this.color[0]},${this.color[1]}, ${this.color[2]}, 0)`,
62
- stroke: this.config.color,
63
- // strokeWidth: this.config.borderWidth
64
- // ? this.config.borderWidth / this.canvas.getZoom()
65
- // : 2,
66
- strokeWidth: 0,
67
- strokeUniform: !0
68
- };
69
- }
70
- get activeStyle() {
71
- return v(n({}, this.normalStyle), {
72
- content: `<svg height="500" width="500"><text fill="#ffffff" font-size="45" x="50" y="86">${this.config.name}</text></svg>`,
73
- fill: `rgba(${this.color[0]},${this.color[1]}, ${this.color[2]}, 0.1)`
74
- });
75
- }
76
- get hoverStyle() {
77
- return this.activeStyle;
78
- }
79
- createRect() {
80
- const e = {
81
- hasBorders: !1,
82
- cornerSize: 6,
83
- cornerStrokeColor: "#84868C",
84
- cornerColor: "#FFFFFF",
85
- transparentCorners: !1
86
- }, s = 0, h = new d.Rect(
87
- // this.config.points?.map((p) => ({ x: p[0], y: p[1] })),
88
- n(n({
89
- left: this.config.points[0][0],
90
- top: this.config.points[0][1],
91
- width: this.config.points[2][0] - this.config.points[0][0] - s,
92
- height: this.config.points[2][1] - this.config.points[0][1] - s
93
- }, e), this.normalStyle)
94
- );
95
- h.setControlsVisibility({
96
- mtr: !1
97
- });
98
- const a = () => {
99
- if (h.canvas !== this.canvas) {
100
- this.canvas.off("after:render", a);
101
- return;
102
- }
103
- this.canvas.contextContainer.strokeStyle = `rgb(${this.color[0]},${this.color[1]}, ${this.color[2]})`;
104
- const o = h.getBoundingRect();
105
- this._strokeRect = this.canvas.contextContainer.strokeRect(o.left + 0.5, o.top + 0.5, o.width, o.height);
106
- };
107
- return this.canvas.on("after:render", a), h;
108
- }
109
- scaledNumber(e) {
110
- return e / this.canvas.getZoom();
111
- }
112
- // getPolyVertices(poly: fabric.Rect) {
113
- // const points = poly.points,
114
- // vertices: fabric.Point[] = [];
115
- // points.forEach((point) => {
116
- // const x: number = point.x - poly.pathOffset.x,
117
- // y: number = point.y - poly.pathOffset.y;
118
- // vertices.push(
119
- // fabric.util.transformPoint(
120
- // { x, y } as fabric.Point,
121
- // fabric.util.multiplyTransformMatrices(
122
- // poly.canvas.viewportTransform,
123
- // poly.calcTransformMatrix()
124
- // )
125
- // )
126
- // );
127
- // });
128
- // return vertices.map((v) => {
129
- // return { x: this.scaledNumber(v.x), y: this.scaledNumber(v.y) };
130
- // });
131
- // }
132
- createLabelName() {
133
- const [e, s, h] = this.color, a = new d.Text(this.handlers.renderLabelItem ? this.handlers.renderLabelItem(this.config) : this.config.name, {
134
- fill: "#FFFFFF",
135
- fontSize: 12,
136
- selectable: !1,
137
- top: 4,
138
- left: 8
139
- }), o = new d.Rect({
140
- selectable: !1,
141
- strokeWidth: 0,
142
- fill: `rgb(${e},${s},${h})`,
143
- rx: 2,
144
- ry: 2,
145
- width: (a.width || 0) + 16,
146
- height: (a.height || 0) + 8,
147
- left: 0,
148
- top: 0
149
- });
150
- return new d.Group([o, a], {
151
- selectable: !1,
152
- // lockScalingX: false,
153
- // lockScalingY: false,
154
- scaleX: 1 / this.canvas.getZoom(),
155
- scaleY: 1 / this.canvas.getZoom()
156
- });
157
- }
158
- renderLabel() {
159
- var e, s;
160
- if (this._fabricRect) {
161
- if (this._label || (this._label = this.createLabelName(), this.setLabelPosition()), this._label.canvas === this.canvas) {
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({
165
- text: this.handlers.renderLabelItem ? this.handlers.renderLabelItem(this.config) : this.config.name,
166
- left: 8
167
- // fontSize: this.scaledNumber(12),
168
- });
169
- const o = (a.getBoundingRect().width || 0) + 16;
170
- h == null || h.set({
171
- fill: `rgba(${this.color[0]},${this.color[1]}, ${this.color[2]}, 1)`,
172
- width: o,
173
- left: -o / 2
174
- }), a.set({
175
- left: -o / 2 + 8
176
- });
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;
178
- this._label.set({
179
- left: r,
180
- width: o
181
- });
182
- }
183
- } else
184
- this.canvas.add(this._label);
185
- this.setLabelPosition();
186
- }
187
- }
188
- setLabelPosition() {
189
- var r, t, i, c;
190
- if (!this._fabricRect || !this._label)
191
- return;
192
- const e = this._label.getObjects().find((R) => R.type === "rect");
193
- if (!e)
194
- return;
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;
196
- this._label.set({
197
- top: a,
198
- left: o,
199
- height: s,
200
- width: h,
201
- scaleX: 1 / this.canvas.getZoom(),
202
- scaleY: 1 / this.canvas.getZoom()
203
- }), this.config = n({}, this.config);
204
- }
205
- addToCanvas(e) {
206
- if (!this._fabricRect)
207
- return;
208
- this.canvas = e, this.canvas.add(this._fabricRect), this._fabricRect.on("mouseover", (o) => {
209
- this.hover = !0;
210
- }), this._fabricRect.on("mouseout", (o) => {
211
- this.hover = !1;
212
- }), this._fabricRect.on("mouseup", () => {
213
- this._fabricRect && this.canvas.setActiveObject(this._fabricRect);
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);
218
- };
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({
227
- top: i.top
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
230
- }), t.left < i.left && t.set({
231
- left: i.left
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))
241
- }), t.left < i.left && t.set({
242
- left: i.left
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))
245
- }), t.top < i.top && t.set({
246
- top: i.top
247
- })), (t.width + c) * t.scaleX > i.width && t.set({
248
- left: i.left,
249
- width: (i.width - c) / t.scaleX
250
- }), (t.height + c) * t.scaleY > i.height && t.set({
251
- top: i.top,
252
- height: (i.height - c) / t.scaleY
253
- })), this.canvas.renderAll();
254
- }, a = (o) => {
255
- h(o), this.setLabelPosition();
256
- };
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));
261
- });
262
- }
263
- render(e) {
264
- y(d), this._fabricRect || (this._fabricRect = this.createRect()), this._fabricRect.canvas === this.canvas ? this._fabricRect.set({
265
- fill: `rgba(${this.color[0]},${this.color[1]}, ${this.color[2]}, 0)`,
266
- stroke: `rgba(${this.color[0]},${this.color[1]}, ${this.color[2]}, 1)`
267
- }) : this.addToCanvas(e), this.renderLabel();
268
- try {
269
- this.canvas.renderAll();
270
- } catch (s) {
271
- console.log("render failed");
272
- }
273
- }
274
- set labelConfig(e) {
275
- this.config = n(n({}, this.config), e), this.color = _(e.color), this.render(this.canvas), this.handlers.onChange && this.handlers.onChange(this);
276
- }
277
- destroy() {
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.onD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xMC43MjcgOS4zMjM0IDEwLjgwMDJDOS4yNDI1OCAxMC44NzM1IDkuMTMyOTcgMTAuOTE0NiA5LjAxODY3IDEwLjkxNDZINi45NTg3N0M2LjkwMjE4IDEwLjkxNDYgNi44NDYxNCAxMC45MDQ1IDYuNzkzODYgMTAuODg0OUM2Ljc0MTU4IDEwLjg2NTMgNi42OTQwNyAxMC44MzY1IDYuNjU0MDUgMTAuODAwMkM2LjYxNDA0IDEwLjc2MzkgNi41ODIyOSAxMC43MjA5IDYuNTYwNjQgMTAuNjczNUM2LjUzODk4IDEwLjYyNjEgNi41Mjc4MyAxMC41NzUzIDYuNTI3ODMgMTAuNTI0Wk02LjQ0NTA5IDcuODg5NDVDNi4zMzA4IDcuODg5NDUgNi4yMjExOSA3LjkzMDYgNi4xNDAzNyA4LjAwMzg2QzYuMDU5NTUgOC4wNzcxMyA2LjAxNDE1IDguMTc2NDkgNi4wMTQxNSA4LjI4MDFDNi4wMTQxNSA4LjM4MzcgNi4wNTk1NSA4LjQ4MzA3IDYuMTQwMzcgOC41NTYzM0M2LjIyMTE5IDguNjI5NTkgNi4zMzA4IDguNjcwNzUgNi40NDUwOSA4LjY3MDc1SDkuNTM5MjVDOS42NTM1NSA4LjY3MDc1IDkuNzYzMTYgOC42Mjk1OSA5Ljg0Mzk3IDguNTU2MzNDOS45MjQ3OSA4LjQ4MzA3IDkuOTcwMTkgOC4zODM3IDkuOTcwMTkgOC4yODAxQzkuOTcwMTkgOC4xNzY0OSA5LjkyNDc5IDguMDc3MTMgOS44NDM5NyA4LjAwMzg2QzkuNzYzMTYgNy45MzA2IDkuNjUzNTUgNy44ODk0NSA5LjUzOTI1IDcuODg5NDVINi40NDUwOVoiIGZpbGw9IiM1QzVGNjYiLz4KPC9zdmc+";
2
- export {
3
- M as default
4
- };
@@ -1,314 +0,0 @@
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
- /* empty css */import le from "react-dom";
7
- import { Spin as ce, Space as fe, Tooltip as X, Button as Z } from "antd";
8
- import _ from "./RectLabel.mjs";
9
- import { drawable as de } from "./Drawable.mjs";
10
- import { ZoomInOutlined as ue, ZoomOutOutlined as me, DragOutlined as ge } from "@ant-design/icons";
11
- import he from "../../../../node_modules/classnames/index.mjs";
12
- import { approxeq as L } from "../../../../utils/index.mjs";
13
- const $ = (r) => {
14
- r.off("mouse:down"), r.off("mouse:up");
15
- }, k = (r) => {
16
- var a, w, f;
17
- let s = [];
18
- (a = r.object) != null && a.aCoords && (s = [r.object.aCoords.tl, r.object.aCoords.tr, r.object.aCoords.br, r.object.aCoords.bl]);
19
- const c = {
20
- x: 0,
21
- y: 0
22
- }, d = {
23
- width: 0,
24
- height: 0
25
- };
26
- 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), {
27
- id: r.config.id,
28
- label: r.config.name,
29
- color: r.config.color,
30
- 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])) || []
31
- };
32
- }, Ne = (r) => {
33
- const s = se(null), {
34
- labels: c,
35
- imageUrl: d,
36
- pen: a,
37
- onImageLoad: w,
38
- onChange: f,
39
- isPreLabel: u,
40
- disabled: x,
41
- renderLabelItem: O
42
- } = r, [N, B] = b(!0), [e, T] = b(), [pe, V] = b({}), [y, U] = b(), [H, ee] = b({
43
- left: 0,
44
- top: 0
45
- }), [te, S] = b([1, 1]), [j, K] = b(), [h, v] = b([]), [p, E] = b(x || !1), A = (t, o) => {
46
- if (!e)
47
- return;
48
- o || (o = {
49
- x: e.getCenter().left,
50
- y: e.getCenter().top
51
- });
52
- let n = e.getZoom();
53
- n *= J(0.999, t), n > 20 && (n = 20), n < 0.01 && (n = 0.01), e.zoomToPoint(
54
- o,
55
- n
56
- // 传入修改后的缩放级别
57
- ), S([n, n]);
58
- };
59
- g(() => {
60
- h.forEach((t) => {
61
- t.renderLabel();
62
- });
63
- }, [te, h, e]);
64
- const W = (t) => {
65
- var n;
66
- if (((n = t.target) == null ? void 0 : n.tagName) === "INPUT" || !e)
67
- return;
68
- const o = e == null ? void 0 : e.getActiveObject();
69
- o && v((i) => {
70
- const I = i.findIndex((z) => z.object === o);
71
- return i[I] && (i[I].destroy(), i.splice(I, 1)), f && f(i.map(k)), [...i];
72
- });
73
- };
74
- P("Delete", W), P("Backspace", W), P("ctrl", () => {
75
- E(!0);
76
- }, {
77
- events: ["keydown"]
78
- }), P("ctrl", () => {
79
- x || E(!1);
80
- }, {
81
- events: ["keyup"]
82
- }), g(() => {
83
- E(x || !1);
84
- }, [x]);
85
- const q = (t) => {
86
- e && $(e), v((o) => {
87
- const n = o.findIndex((i) => i === t);
88
- return n > -1 && (o.splice(n, 1), f && f(o.map(k)), Y()), [...o];
89
- });
90
- }, F = (t) => {
91
- v((o) => {
92
- const n = o.findIndex((i) => i === t);
93
- return n > -1 && (o[n] = t, f && f(o.map(k))), [...o];
94
- });
95
- };
96
- g(() => {
97
- if (!e)
98
- return;
99
- const t = [];
100
- return c.filter((o) => o.color).forEach((o) => {
101
- t.push(new _({
102
- id: o.id,
103
- name: o.label,
104
- color: o.color,
105
- points: o.box.map((n) => [n[0] + H.left, n[1] + H.top]),
106
- hideDelete: u
107
- }, e, {
108
- onChange: F,
109
- onDelete: q,
110
- renderLabelItem: O ? (n) => O ? O(o) : n.name : void 0
111
- }));
112
- }), v(t), t.forEach((o) => {
113
- o.render(e);
114
- }), () => {
115
- t.forEach((o) => {
116
- o.canvas !== e && o.destroy();
117
- });
118
- };
119
- }, [e, d]);
120
- const Y = () => {
121
- e && de(e, (t) => {
122
- const o = new _({
123
- id: (a == null ? void 0 : a.id) || t.id,
124
- name: (a == null ? void 0 : a.label) || t.label,
125
- color: (a == null ? void 0 : a.color) || t.color,
126
- points: t.box.map((n) => [n[0], n[1]]),
127
- hideDelete: u
128
- }, e, {
129
- onChange: F,
130
- onDelete: q
131
- });
132
- o.active = !0, h.push(o), f && f(h.map(k)), v([...h]);
133
- }, u);
134
- }, oe = () => {
135
- let t = !1;
136
- e && (e.on("mouse:down", (o) => {
137
- t = !0, e.selection = !1;
138
- }), e.on("mouse:move", (o) => {
139
- if (t && o && o.e) {
140
- const n = new R.Point(o.e.movementX, o.e.movementY);
141
- e.relativePan(n);
142
- }
143
- }), e.on("mouse:up", (o) => {
144
- t = !1, e.selection = !0;
145
- }));
146
- }, ne = () => {
147
- e && (e.off("mouse:down"), e.off("mouse:move"), e.off("mouse:up"));
148
- };
149
- g(() => {
150
- if (e)
151
- return p ? (oe(), e.defaultCursor = "grab", e.on("mouse:down:before", () => {
152
- e.setCursor("grabbing");
153
- }), e.on("mouse:up", () => {
154
- e.defaultCursor = "grab";
155
- }), e.getObjects(), v((t) => (t.forEach((o) => {
156
- var n;
157
- return (n = o.object) == null ? void 0 : n.set("evented", !1);
158
- }), t))) : (e.defaultCursor = "default", e.off("mouse:down:before"), e.off("mouse:up"), e.setCursor("default"), v((t) => (t.forEach((o) => {
159
- var n;
160
- return (n = o.object) == null ? void 0 : n.set("evented", !0);
161
- }), t)), Y()), () => {
162
- ne();
163
- };
164
- }, [e, p]), g(() => {
165
- if (e == null || e.on("mouse:wheel", (t) => {
166
- const o = t.e.deltaY;
167
- A(o, {
168
- x: t.e.offsetX,
169
- y: t.e.offsetY
170
- }), h.forEach((n) => {
171
- n.renderLabel();
172
- });
173
- }), !p)
174
- return Y(), () => {
175
- e && ($(e), e.off("mouse:wheel"));
176
- };
177
- }, [e, a, h, p]);
178
- const re = () => {
179
- V({}), U(void 0), S([1, 1]), e == null || e.dispose(), T(void 0);
180
- };
181
- return g(() => {
182
- B(!0), re(), !(!s.current || !d) && R.Image.fromURL(d, (t) => {
183
- t.set({
184
- originX: "center",
185
- originY: "center"
186
- }), U(t), B(!1);
187
- }, {
188
- crossOrigin: "anonymous"
189
- });
190
- }, [d]), g(() => {
191
- if (!y && e) {
192
- try {
193
- e.clear();
194
- } catch (M) {
195
- }
196
- return;
197
- }
198
- if (!s.current || !s.current.parentElement)
199
- return;
200
- const t = y == null ? void 0 : y.getElement();
201
- if (!(t != null && t.width) || !(t != null && t.height))
202
- return;
203
- const o = t.width / t.height, n = s.current.parentElement.offsetWidth, i = s.current.parentElement.offsetHeight, I = n / t.width, z = i / t.height;
204
- let C = [n, i];
205
- I > z ? C = [i * o, i] : C = [n, n / o];
206
- const ae = C[0] / t.width, ie = C[1] / t.height, D = Math.min(ae, ie);
207
- S([D, D]);
208
- const m = new R.Canvas(s.current, {
209
- containerClass: "marking-canvas",
210
- width: n,
211
- height: i
212
- });
213
- if (m == null || m.setZoom(D), m == null || m.renderAll(), m && y) {
214
- const M = (n - C[0]) / D / 2, G = (i - C[1]) / D / 2;
215
- m.setBackgroundImage(
216
- y,
217
- () => {
218
- m.renderAll(), ee({
219
- left: M,
220
- top: G
221
- }), T(m), w && w();
222
- },
223
- // 刷新画布
224
- {
225
- originX: "left",
226
- originY: "top",
227
- left: M,
228
- top: G
229
- }
230
- );
231
- }
232
- }, [y]), g(() => {
233
- h.length > c.length && h.forEach((t) => {
234
- c.find((o) => o.id === t.config.id) || t.destroy();
235
- });
236
- }, [c.length]), g(() => {
237
- e && (p || v((t) => {
238
- const o = e == null ? void 0 : e.getActiveObject(), n = t.find((i) => i.object === o);
239
- return n && a && (n.labelConfig = {
240
- id: a.id,
241
- name: a.label,
242
- color: a.color
243
- }, f && f(t.map(k))), e && (a ? e.defaultCursor = "copy" : e.defaultCursor = "default"), [...t];
244
- }));
245
- }, [a, e, p]), g(() => {
246
- var t;
247
- if (N && s.current && !j) {
248
- const o = document.createElement("div");
249
- 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);
250
- } else
251
- !N && j && (j.remove(), K(null));
252
- }, [N, s.current, j]), /* @__PURE__ */ Q("div", {
253
- style: {
254
- width: "100%",
255
- height: "100%",
256
- display: "flex"
257
- },
258
- children: [/* @__PURE__ */ l("div", {
259
- className: "marker-toolbar",
260
- children: /* @__PURE__ */ l("div", {
261
- className: "create-mode-select",
262
- children: /* @__PURE__ */ Q(fe, {
263
- direction: "vertical",
264
- size: 16,
265
- children: [/* @__PURE__ */ l(X, {
266
- title: "放大-鼠标滚轮前滑",
267
- placement: "right",
268
- children: /* @__PURE__ */ l(Z, {
269
- icon: /* @__PURE__ */ l(ue, {}),
270
- onClick: () => {
271
- A(-100);
272
- }
273
- })
274
- }), /* @__PURE__ */ l(X, {
275
- title: "缩小-鼠标滚轮后滑",
276
- placement: "right",
277
- children: /* @__PURE__ */ l(Z, {
278
- icon: /* @__PURE__ */ l(me, {}),
279
- onClick: () => {
280
- A(100);
281
- }
282
- })
283
- }), !x && /* @__PURE__ */ l(X, {
284
- title: "拖动-按住ctrl",
285
- placement: "right",
286
- children: /* @__PURE__ */ l(Z, {
287
- disabled: x,
288
- icon: /* @__PURE__ */ l(ge, {}),
289
- className: p ? "active" : "",
290
- onClick: () => {
291
- E(!p);
292
- }
293
- })
294
- })]
295
- })
296
- })
297
- }), /* @__PURE__ */ l("div", {
298
- className: he({
299
- "label-maker-wrap": !0,
300
- draggable: p
301
- }),
302
- onContextMenu: (t) => {
303
- t.preventDefault();
304
- },
305
- children: /* @__PURE__ */ l("canvas", {
306
- className: "label-maker-canvas",
307
- ref: s
308
- })
309
- })]
310
- });
311
- };
312
- export {
313
- Ne as default
314
- };