@glodon-aiot/dataset-annotation 3.2.2-beta.2 → 3.2.2-beta.4

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 (138) hide show
  1. package/dist/es/Common/Page/index.mjs +29 -0
  2. package/dist/es/Common/Page/style.less.mjs +4 -0
  3. package/dist/es/Common/PageContent/index.mjs +18 -0
  4. package/dist/es/Common/PageHeader/index.mjs +39 -0
  5. package/dist/es/Common/PageHeader/style.less.mjs +4 -0
  6. package/dist/es/DatasetContext/index.mjs +11 -0
  7. package/dist/es/_virtual/_commonjsHelpers.mjs +4 -0
  8. package/dist/es/_virtual/minio.mjs +4 -0
  9. package/dist/es/access/images/data_empty.svg.mjs +4 -0
  10. package/dist/es/components/CompositionInput/index.mjs +53 -0
  11. package/dist/es/components/DataEmpty/index.mjs +51 -0
  12. package/dist/es/components/DataEmpty/style.less.mjs +4 -0
  13. package/dist/es/components/DetectionAnnotation/PreSamplesPage/index.mjs +292 -0
  14. package/dist/es/components/DetectionAnnotation/PreSamplesPage/style.less.mjs +4 -0
  15. package/dist/es/components/DetectionAnnotation/components/DisabledTooltip/index.mjs +23 -0
  16. package/dist/es/components/DetectionAnnotation/components/ImageDetail/index.mjs +166 -0
  17. package/dist/es/components/DetectionAnnotation/components/ImageDetail/style.less.mjs +4 -0
  18. package/dist/es/components/DetectionAnnotation/components/LabelMaker/Drawable.mjs +51 -0
  19. package/dist/es/components/DetectionAnnotation/components/LabelMaker/FabricCustomize.mjs +42 -0
  20. package/dist/es/components/DetectionAnnotation/components/LabelMaker/RectLabel.mjs +283 -0
  21. package/dist/es/components/DetectionAnnotation/components/LabelMaker/icons/delete-icon.svg.mjs +4 -0
  22. package/dist/es/components/DetectionAnnotation/components/LabelMaker/index.mjs +315 -0
  23. package/dist/es/components/DetectionAnnotation/components/LabelMaker/style.less.mjs +4 -0
  24. package/dist/es/components/DetectionAnnotation/components/Labels/index.mjs +201 -0
  25. package/dist/es/components/DetectionAnnotation/components/Labels/style.less.mjs +4 -0
  26. package/dist/es/components/DetectionAnnotation/components/TagItem/index.mjs +144 -0
  27. package/dist/es/components/DetectionAnnotation/components/TagItem/style.less.mjs +4 -0
  28. package/dist/es/components/DetectionAnnotation/icon_item_empty.svg.mjs +4 -0
  29. package/dist/es/components/DetectionAnnotation/index.mjs +713 -0
  30. package/dist/es/components/DetectionAnnotation/style.less.mjs +4 -0
  31. package/dist/es/components/DetectionImageAnnotation/index.mjs +62 -0
  32. package/dist/es/components/DetectionImageAnnotation/style.less.mjs +4 -0
  33. package/dist/es/components/Iconfont/index.mjs +16 -0
  34. package/dist/es/components/MarkDescriptions/index.mjs +66 -0
  35. package/dist/es/components/MarkDescriptions/style.less.mjs +4 -0
  36. package/dist/es/components/OCRImageViewer/index.mjs +213 -0
  37. package/dist/es/components/OCRImageViewer/style.less.mjs +4 -0
  38. package/dist/es/components/OcrAnnotation/MarkKVOCRModal/CategoryDrawer.mjs +136 -0
  39. package/dist/es/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/LabelEditorInput.mjs +57 -0
  40. package/dist/es/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/LabelEditorItem.mjs +73 -0
  41. package/dist/es/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/LableEditor.mjs +55 -0
  42. package/dist/es/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/index.mjs +366 -0
  43. package/dist/es/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/style.less.mjs +4 -0
  44. package/dist/es/components/OcrAnnotation/MarkKVOCRModal/index.mjs +255 -0
  45. package/dist/es/components/OcrAnnotation/MarkKVOCRModal/style.less.mjs +4 -0
  46. package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/ImageDetail/index.mjs +101 -0
  47. package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/ImageDetail/style.less.mjs +4 -0
  48. package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/images/delete.png.mjs +4 -0
  49. package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/index.mjs +756 -0
  50. package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/style.less.mjs +4 -0
  51. package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/index.mjs +231 -0
  52. package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/style.less.mjs +4 -0
  53. package/dist/es/components/OcrAnnotation/OcrModal/index.mjs +180 -0
  54. package/dist/es/components/OcrAnnotation/OcrModal/style.less.mjs +4 -0
  55. package/dist/es/components/OcrAnnotation/PreLabelOCR/PreLabelModal.mjs +281 -0
  56. package/dist/es/components/OcrAnnotation/PreLabelOCR/index.mjs +44 -0
  57. package/dist/es/components/OcrAnnotation/PreLabelOCR/style.less.mjs +4 -0
  58. package/dist/es/components/OcrAnnotation/constant.mjs +5 -0
  59. package/dist/es/components/OcrAnnotation/index.mjs +382 -0
  60. package/dist/es/components/OcrAnnotation/style.less.mjs +4 -0
  61. package/dist/es/components/OcrImageAnnotation/index.mjs +40 -0
  62. package/dist/es/components/OcrImageAnnotation/style.less.mjs +4 -0
  63. package/dist/es/components/PageNav/index.mjs +30 -0
  64. package/dist/es/components/PageNav/style.less.mjs +4 -0
  65. package/dist/es/components/PicZipImportModal/index.mjs +584 -0
  66. package/dist/es/components/PicZipImportModal/pic_zip.svg.mjs +4 -0
  67. package/dist/es/components/PicZipImportModal/pic_zip_json.svg.mjs +4 -0
  68. package/dist/es/components/PicZipImportModal/style.less.mjs +4 -0
  69. package/dist/es/components/PreLabelOCR/PreLabelModal.mjs +276 -0
  70. package/dist/es/components/PreLabelOCR/index.mjs +44 -0
  71. package/dist/es/components/PreLabelOCR/style.less.mjs +4 -0
  72. package/dist/es/components/ScanTable/index.mjs +97 -0
  73. package/dist/es/components/ScanTable/style.less.mjs +4 -0
  74. package/dist/es/components/Thumbnail/default.png.mjs +4 -0
  75. package/dist/es/components/Thumbnail/index.mjs +31 -0
  76. package/dist/es/components/Thumbnail/style.less.mjs +4 -0
  77. package/dist/es/components/hooks/Prompt.mjs +33 -0
  78. package/dist/es/constant.mjs +13 -0
  79. package/dist/es/createDatasetAnnotation/index.mjs +133 -0
  80. package/dist/es/createDetectionDatasetAnnotation/index.mjs +129 -0
  81. package/dist/es/createDetectionImageAnnotation/index.mjs +31 -0
  82. package/dist/es/createOcrDatasetAnnotation/index.mjs +129 -0
  83. package/dist/es/createOcrImageAnnotation/index.mjs +33 -0
  84. package/dist/es/featuresConfig.mjs +79 -0
  85. package/dist/es/index.mjs +13 -0
  86. package/dist/es/node_modules/@glodon-aiot/minio/dist/minio.mjs +28463 -0
  87. package/dist/es/utils/color.mjs +30 -0
  88. package/dist/es/utils/index.mjs +22 -0
  89. package/dist/es/utils/sign.mjs +33 -0
  90. package/dist/lib/index.js +130 -0
  91. package/dist/src/Common/Page/index.d.ts +1 -2
  92. package/dist/src/Common/PageHeader/index.d.ts +0 -1
  93. package/dist/src/DatasetContext/index.d.ts +3 -4
  94. package/dist/src/components/CompositionInput/index.d.ts +2 -2
  95. package/dist/src/components/DataEmpty/index.d.ts +1 -2
  96. package/dist/src/components/DetectionAnnotation/PreSamplesPage/index.d.ts +1 -2
  97. package/dist/src/components/DetectionAnnotation/components/DisabledTooltip/index.d.ts +2 -2
  98. package/dist/src/components/DetectionAnnotation/components/ImageDetail/index.d.ts +1 -2
  99. package/dist/src/components/DetectionAnnotation/components/LabelMaker/Drawable.d.ts +2 -2
  100. package/dist/src/components/DetectionAnnotation/components/LabelMaker/RectLabel.d.ts +6 -5
  101. package/dist/src/components/DetectionAnnotation/components/LabelMaker/index.d.ts +0 -1
  102. package/dist/src/components/DetectionAnnotation/components/Labels/index.d.ts +0 -1
  103. package/dist/src/components/DetectionAnnotation/components/TagItem/index.d.ts +1 -2
  104. package/dist/src/components/DetectionAnnotation/index.d.ts +1 -2
  105. package/dist/src/components/DetectionImageAnnotation/index.d.ts +0 -2
  106. package/dist/src/components/Iconfont/font_3140028_iptomfpgyu.d.ts +0 -0
  107. package/dist/src/components/Iconfont/font_3454453_gu5ijeufyng.d.ts +0 -0
  108. package/dist/src/components/Iconfont/font_4108228_3slzqhoow93.d.ts +0 -0
  109. package/dist/src/components/Iconfont/font_4439177_k3mjwv7kzfd.d.ts +0 -0
  110. package/dist/src/components/Iconfont/index.d.ts +1 -2
  111. package/dist/src/components/MarkDescriptions/index.d.ts +0 -1
  112. package/dist/src/components/OCRImageViewer/index.d.ts +1 -2
  113. package/dist/src/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/LabelEditorInput.d.ts +2 -2
  114. package/dist/src/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/LabelEditorItem.d.ts +1 -2
  115. package/dist/src/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/LableEditor.d.ts +0 -1
  116. package/dist/src/components/OcrAnnotation/MarkKVOCRModal/index.d.ts +0 -1
  117. package/dist/src/components/OcrAnnotation/MarkOCRBoxModal/ImageDetail/index.d.ts +1 -2
  118. package/dist/src/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/LabelEditorInput.d.ts +2 -2
  119. package/dist/src/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/LabelEditorItem.d.ts +0 -1
  120. package/dist/src/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/LableEditor.d.ts +0 -1
  121. package/dist/src/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/index.d.ts +0 -1
  122. package/dist/src/components/OcrAnnotation/MarkOCRBoxModal/index.d.ts +0 -1
  123. package/dist/src/components/OcrAnnotation/OcrModal/index.d.ts +1 -2
  124. package/dist/src/components/OcrAnnotation/PreLabelOCR/PreLabelModal.d.ts +1 -2
  125. package/dist/src/components/OcrAnnotation/PreLabelOCR/index.d.ts +1 -2
  126. package/dist/src/components/OcrAnnotation/index.d.ts +1 -2
  127. package/dist/src/components/OcrImageAnnotation/index.d.ts +0 -2
  128. package/dist/src/components/PageNav/index.d.ts +1 -2
  129. package/dist/src/components/PicZipImportModal/index.d.ts +1 -2
  130. package/dist/src/components/PreLabelOCR/PreLabelModal.d.ts +1 -2
  131. package/dist/src/components/PreLabelOCR/index.d.ts +1 -2
  132. package/dist/src/components/ScanTable/index.d.ts +1 -2
  133. package/dist/src/components/Thumbnail/index.d.ts +1 -2
  134. package/dist/src/components/hooks/Prompt.d.ts +0 -1
  135. package/dist/src/components/hooks/useBlocker.d.ts +1 -1
  136. package/dist/src/featuresConfig.d.ts +1 -1
  137. package/dist/src/utils/sign.d.ts +1 -1
  138. package/package.json +15 -6
@@ -0,0 +1,366 @@
1
+ var re = Object.defineProperty, de = Object.defineProperties;
2
+ var ue = Object.getOwnPropertyDescriptors;
3
+ var ee = Object.getOwnPropertySymbols;
4
+ var fe = Object.prototype.hasOwnProperty, se = Object.prototype.propertyIsEnumerable;
5
+ var te = (r, h, g) => h in r ? re(r, h, { enumerable: !0, configurable: !0, writable: !0, value: g }) : r[h] = g, L = (r, h) => {
6
+ for (var g in h || (h = {}))
7
+ fe.call(h, g) && te(r, g, h[g]);
8
+ if (ee)
9
+ for (var g of ee(h))
10
+ se.call(h, g) && te(r, g, h[g]);
11
+ return r;
12
+ }, U = (r, h) => de(r, ue(h));
13
+ import { jsx as E } from "react/jsx-runtime";
14
+ import { useState as I, useContext as ge, useEffect as B } from "react";
15
+ import ce from "./LableEditor.mjs";
16
+ import { fabric as X } from "fabric";
17
+ import oe from "ahooks/lib/useKeyPress";
18
+ import { Spin as le } from "antd";
19
+ import he from "react-dom";
20
+ import { getUuid as K } from "../../../../utils/index.mjs";
21
+ import me from "../../../../DatasetContext/index.mjs";
22
+ import { OCRServiceId as pe } from "@glodon-aiot/apis";
23
+ function T(r, h) {
24
+ let g = -1, u = -1, x = 0, w = 0, a, m;
25
+ function Y(e) {
26
+ const i = e.target;
27
+ i && (i.currentHeight > i.canvas.height || i.currentWidth > i.canvas.width || (i.setCoords(), (i.getBoundingRect().top < 0 || i.getBoundingRect().left < 0) && (i.top = Math.max(i.top, i.top - i.getBoundingRect().top), i.left = Math.max(i.left, i.left - i.getBoundingRect().left)), (i.getBoundingRect().top + i.getBoundingRect().height > i.canvas.height || i.getBoundingRect().left + i.getBoundingRect().width > i.canvas.width) && (i.top = Math.min(i.top, i.canvas.height - i.getBoundingRect().height + i.top - i.getBoundingRect().top), i.left = Math.min(i.left, i.canvas.width - i.getBoundingRect().width + i.left - i.getBoundingRect().left)), i && m && (m.left = i.left, m.top = i.top + i.getBoundingRect().height)));
28
+ }
29
+ r.on("mouse:down", (e) => {
30
+ const i = r.getZoom();
31
+ u = e.e.offsetX / i, g = e.e.offsetY / i;
32
+ }), r.on("mouse:up", (e) => {
33
+ if (u === -1 && g === -1)
34
+ return;
35
+ const i = r.getZoom(), c = e.e.offsetX > r.getWidth() ? r.getWidth() / i : e.e.offsetX / i, P = e.e.offsetY > r.getHeight() ? r.getHeight() / i : e.e.offsetY / i;
36
+ if (x = Math.abs(c - u), w = Math.abs(P - g), x === 0 || w === 0)
37
+ return;
38
+ const b = g > P ? P : g, k = u > c ? c : u, W = x, j = w, f = [{
39
+ x: k,
40
+ y: b
41
+ }, {
42
+ x: k + W,
43
+ y: b
44
+ }, {
45
+ x: k + W,
46
+ y: b + j
47
+ }, {
48
+ x: k,
49
+ y: b + j
50
+ }];
51
+ a = new X.Polygon(f, {
52
+ fill: "rgba(255, 69, 0, 0.45)",
53
+ stroke: "rgb(255, 69, 0)",
54
+ strokeWidth: 1
55
+ }), a.set("strokeUniform", !0), r.add(a), m = new X.Text("请在右侧选择对应字段", {
56
+ top: b + j,
57
+ left: k,
58
+ fontSize: 14 / i,
59
+ backgroundColor: "rgba(0, 0, 0, 0.75)",
60
+ fill: "#fff",
61
+ selectable: !1
62
+ }), r.add(m), r.setActiveObject(a), h && h(a, m), r.skipTargetFind = !1;
63
+ }), r.on("mouse:move", (e) => {
64
+ e.target && Y(e);
65
+ });
66
+ }
67
+ const Z = (r) => {
68
+ r.off("mouse:down"), r.off("mouse:up");
69
+ }, ae = (r, [h, g, u]) => new X.Polygon(r, {
70
+ fill: `rgba(${h},${g}, ${u}, 0.45)`,
71
+ stroke: `rgba(${h},${g}, ${u}, 1)`,
72
+ strokeWidth: 0
73
+ }), xe = (r, h, g) => {
74
+ if (!r) {
75
+ console.error("canvas is not exist");
76
+ return;
77
+ }
78
+ r.remove(h), r.add(g);
79
+ }, ie = (r, h) => new Promise((g, u) => {
80
+ if (!r.canvas) {
81
+ u("polygon.canvas is not exist");
82
+ return;
83
+ }
84
+ const x = r.canvas.getElement(), w = r.getBoundingRect(), a = document.createElement("canvas");
85
+ a.width = r.getScaledWidth() || 0, a.height = r.getScaledHeight() || 0;
86
+ const m = a.getContext("2d");
87
+ if (!m) {
88
+ u("tContext is null");
89
+ return;
90
+ }
91
+ m.drawImage(x, w.left * devicePixelRatio, w.top * devicePixelRatio, w.width * devicePixelRatio || 0, w.height * devicePixelRatio || 0, 0, 0, r.getScaledWidth() || 0, r.getScaledHeight() || 0), g(a.toDataURL());
92
+ }), je = (r) => {
93
+ const {
94
+ id: h,
95
+ imageUrl: g,
96
+ canvasElement: u,
97
+ labels: x = [],
98
+ categories: w,
99
+ onChange: a
100
+ } = r, [m, Y] = I(!0), [e, i] = I(), [c, P] = I({}), [b, k] = I(), [W, j] = I([1, 1]), [f, M] = I(), [p, H] = I(null), [D, O] = I(), [s, A] = I(x == null ? void 0 : x.filter((t) => !!t).map((t) => {
101
+ var o, n;
102
+ return {
103
+ uuid: t.uuid,
104
+ box: ((o = t.box) == null ? void 0 : o.map((d) => [d[0], d[1]])) || [],
105
+ words: t.words,
106
+ type: (n = t.type) == null ? void 0 : n.toLowerCase(),
107
+ catagoryId: t.catagoryId
108
+ };
109
+ })), [F, V] = I(!0), [$, q] = I(), {
110
+ services: {
111
+ aiShop: z
112
+ },
113
+ featuresConfig: {
114
+ labelManager: ye
115
+ } = {
116
+ labelManager: !1
117
+ }
118
+ } = ge(me);
119
+ B(() => {
120
+ if (e && F) {
121
+ const t = e.getActiveObject();
122
+ if (t) {
123
+ t === (f == null ? void 0 : f.polygon) && (e == null || e.remove(f == null ? void 0 : f.text), M(void 0)), e.remove(t), e.renderAll();
124
+ const o = s.findIndex((n) => c[n.uuid] === t);
125
+ o > -1 && (c[s[o].uuid] && (e == null || e.remove(c[s[o].uuid])), s.splice(o, 1), A([...s]), a([...s]));
126
+ } else
127
+ console.log("no active object");
128
+ V(!1);
129
+ }
130
+ }, [e, F, s]);
131
+ const G = (t) => {
132
+ var o;
133
+ ((o = t.target) == null ? void 0 : o.tagName) !== "INPUT" && V(!0);
134
+ };
135
+ oe("Delete", G), oe("Backspace", G), B(() => {
136
+ s.forEach((t) => {
137
+ x.find((o) => o.uuid === t.uuid) || e == null || e.remove(c[t.uuid]);
138
+ }), A(x == null ? void 0 : x.filter((t) => !!t).map((t) => {
139
+ var o, n;
140
+ return {
141
+ uuid: t.uuid,
142
+ box: ((o = t.box) == null ? void 0 : o.map((d) => [d[0], d[1]])) || [],
143
+ words: t.words,
144
+ type: (n = t.type) == null ? void 0 : n.toLowerCase(),
145
+ catagoryId: t.catagoryId
146
+ };
147
+ }));
148
+ }, [x]);
149
+ const ne = () => {
150
+ P({}), k(void 0), j([1, 1]), M(void 0), H(null), O(void 0), A([]), e == null || e.dispose(), i(void 0);
151
+ };
152
+ B(() => {
153
+ Y(!0), ne(), !(!u || !g || !h) && X.Image.fromURL(g, (t) => {
154
+ t.set({
155
+ originX: "center",
156
+ originY: "center"
157
+ }), k(t), Y(!1);
158
+ }, {
159
+ crossOrigin: "anonymous"
160
+ });
161
+ }, [g]), B(() => {
162
+ var Q, _;
163
+ if (!b && e) {
164
+ e.clear();
165
+ return;
166
+ }
167
+ if (!u)
168
+ return;
169
+ const t = b == null ? void 0 : b.getElement();
170
+ if (!(t != null && t.width) || !(t != null && t.height))
171
+ return;
172
+ const o = t.width / t.height, n = ((Q = u.parentElement) == null ? void 0 : Q.offsetWidth) || (u == null ? void 0 : u.offsetWidth), d = ((_ = u == null ? void 0 : u.parentElement) == null ? void 0 : _.offsetHeight) || (u == null ? void 0 : u.offsetHeight), y = n / t.width, R = d / t.height;
173
+ y > R ? (u.width = d * o, u.height = d) : (u.width = n, u.height = n / o);
174
+ const l = u.width / t.width, C = u.height / t.height, v = Math.min(l, C);
175
+ j([v, v]);
176
+ let S = e;
177
+ e ? (e.clear(), e.setWidth(u.width), e.setHeight(u.height)) : S = new X.Canvas(u, {
178
+ containerClass: "marking-canvas",
179
+ width: u.width,
180
+ height: u.height
181
+ }), S == null || S.setZoom(v), S && b && (S.setBackgroundImage(
182
+ b,
183
+ S.renderAll.bind(S),
184
+ // 刷新画布
185
+ {
186
+ originX: "left",
187
+ originY: "top",
188
+ left: 0,
189
+ top: 0
190
+ }
191
+ ), i(S));
192
+ }, [b]), B(() => {
193
+ m || !e || N(e, s, D);
194
+ }, [s, e, D, m]), B(() => {
195
+ D || a(s);
196
+ }, [D]);
197
+ const N = (t, o, n = "") => {
198
+ o == null || o.map((d) => {
199
+ var R, l;
200
+ const y = ae((R = d.box) == null ? void 0 : R.map((C) => ({
201
+ x: C[0],
202
+ y: C[1]
203
+ })), ((l = d.type) == null ? void 0 : l.toLowerCase()) === "key" ? [255, 193, 0] : [80, 139, 238]);
204
+ c[d.uuid] ? xe(t, c[d.uuid], y) : t.add(y), c[d.uuid] = y, P(() => c);
205
+ }), n && (!p || p !== t.getActiveObject()) && (t == null || t.setActiveObject(c[n]), H(c[n]));
206
+ };
207
+ B(() => {
208
+ var t;
209
+ if (m && u && !$) {
210
+ const o = document.createElement("div");
211
+ o.setAttribute("style", "width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: absolute;top: 0;"), (t = u.parentElement) == null || t.appendChild(o), he.render(/* @__PURE__ */ E(le, {}), o), q(o);
212
+ } else
213
+ !m && $ && ($.remove(), q(null));
214
+ }, [m, u, $]), B(() => {
215
+ m && e && N(e, []), !(m || !e) && (N(e, []), T(e, (t, o) => {
216
+ f && (e == null || e.remove(f.text), e == null || e.remove(f.polygon)), M({
217
+ polygon: t,
218
+ text: o,
219
+ uuid: K()
220
+ });
221
+ }), e.on("selection:created", (t) => {
222
+ var n;
223
+ Z(e), H(e.getActiveObject());
224
+ const o = e.getActiveObject();
225
+ o == null || o.set({
226
+ borderColor: "rgba(255, 69, 0, 1)",
227
+ cornerColor: "white",
228
+ cornerSize: 7,
229
+ transparentCorners: !1,
230
+ cornerStrokeColor: "rgba(109, 109, 109, 1)"
231
+ }), (n = Object.keys(c)) == null || n.map((d) => {
232
+ o === c[d] && O(d);
233
+ });
234
+ }), e.on("selection:updated", (t) => {
235
+ var n;
236
+ Z(e), H(e.getActiveObject());
237
+ const o = e.getActiveObject();
238
+ (n = Object.keys(c)) == null || n.map((d) => {
239
+ o === c[d] && O(d);
240
+ });
241
+ }), e.on("selection:cleared", () => {
242
+ H(null), O(void 0);
243
+ }));
244
+ }, [e, m]);
245
+ const J = (t) => z == null ? void 0 : z.ocr(pe.common, {
246
+ image: t
247
+ }).catch(() => [{
248
+ words: ""
249
+ }]).then((o) => o == null ? void 0 : o.map((n) => n.words).join(""));
250
+ return B(() => {
251
+ e && (f ? (Z(e), f.value === void 0 && (ie(f.polygon).then((t) => J(t)).then((t) => {
252
+ M(U(L({}, f), {
253
+ value: t
254
+ }));
255
+ }), e.on("event:moved", () => {
256
+ ie(f.polygon).then((t) => J(t)).then((t) => {
257
+ f && (e == null || e.remove(f.text), e == null || e.remove(f.polygon)), M(U(L({}, f), {
258
+ value: t
259
+ }));
260
+ });
261
+ }))) : p || T(e, (t, o) => {
262
+ M({
263
+ polygon: t,
264
+ text: o,
265
+ uuid: K()
266
+ });
267
+ }));
268
+ }, [f, e, s, c]), B(() => {
269
+ if (e) {
270
+ if (!p) {
271
+ T(e, (t, o) => {
272
+ f && (e == null || e.remove(f.text), e == null || e.remove(f.polygon)), M({
273
+ polygon: t,
274
+ text: o,
275
+ uuid: K()
276
+ });
277
+ });
278
+ return;
279
+ }
280
+ p == null || p.on("mousedown", () => {
281
+ e && Z(e);
282
+ }), p == null || p.on("mouseup:before", () => {
283
+ var n;
284
+ if (!e)
285
+ return;
286
+ const t = p, o = e.getZoom();
287
+ (n = Object.keys(c)) == null || n.map((d) => {
288
+ var y;
289
+ if (t === c[d]) {
290
+ const R = s.findIndex((l) => l.uuid === d);
291
+ R > -1 && (s[R].box = (y = t.getCoords()) == null ? void 0 : y.map((l) => [l.x / o, l.y / o]));
292
+ }
293
+ }), A([...s]), a([...s]);
294
+ }), p == null || p.on("moving", () => {
295
+ var n;
296
+ if (!e)
297
+ return;
298
+ const t = p, o = e.getZoom();
299
+ (n = Object.keys(c)) == null || n.map((d) => {
300
+ var y;
301
+ if (t === c[d]) {
302
+ const R = s.findIndex((l) => l.uuid === d);
303
+ s[R].box = (y = t.getCoords()) == null ? void 0 : y.map((l) => [l.x / o, l.y / o]);
304
+ }
305
+ });
306
+ });
307
+ }
308
+ }, [p]), /* @__PURE__ */ E("div", {
309
+ children: w.length ? w == null ? void 0 : w.map((t) => {
310
+ var o;
311
+ return /* @__PURE__ */ E(ce, {
312
+ selectedLabel: s.find((n) => c[n.uuid] === p),
313
+ holdingLabel: f != null && f.polygon ? {
314
+ uuid: f.uuid,
315
+ box: (o = f.polygon.getCoords()) == null ? void 0 : o.map((n) => [n.x / W[0], n.y / W[1]]),
316
+ words: f.value || ""
317
+ } : void 0,
318
+ type: s.filter((n) => {
319
+ var d;
320
+ return n.catagoryId === t.id && ((d = n.type) == null ? void 0 : d.toLowerCase()) === "key";
321
+ }),
322
+ value: s.filter((n) => {
323
+ var d;
324
+ return n.catagoryId === t.id && ((d = n.type) == null ? void 0 : d.toLowerCase()) === "value";
325
+ }),
326
+ category: t,
327
+ onChange: (n, d) => {
328
+ var R;
329
+ ((R = n.concat(d)) == null ? void 0 : R.map((l) => {
330
+ var C;
331
+ return U(L({}, l), {
332
+ box: (C = l.box) == null ? void 0 : C.map((v) => [v[0], v[1]])
333
+ });
334
+ })).forEach((l) => {
335
+ const C = s.findIndex((v) => v.uuid === l.uuid);
336
+ C < 0 ? s.push(l) : s[C] = l;
337
+ }), A([
338
+ // eslint-disable-next-line no-unsafe-optional-chaining
339
+ ...s == null ? void 0 : s.map((l) => {
340
+ var C;
341
+ return U(L({}, l), {
342
+ box: (C = l.box) == null ? void 0 : C.map((v) => [v[0], v[1]])
343
+ });
344
+ })
345
+ ]), a([...s]);
346
+ },
347
+ onRemove: (n) => {
348
+ const d = s.findIndex((y) => y.uuid === n.uuid);
349
+ d > -1 && (c[s[d].uuid] && (e == null || e.remove(c[s[d].uuid])), s.splice(d, 1), A([...s]), a([...s]));
350
+ },
351
+ clearHoldingLabel: () => {
352
+ f && (e == null || e.remove(f.text), e == null || e.remove(f.polygon), M(void 0), O(f.uuid));
353
+ },
354
+ onSelect: (n) => {
355
+ O(n == null ? void 0 : n.uuid);
356
+ }
357
+ }, t.id);
358
+ }) : /* @__PURE__ */ E("div", {
359
+ className: "empty",
360
+ children: "暂无字段,请先在“字段管理”中进行添加"
361
+ })
362
+ });
363
+ };
364
+ export {
365
+ je as default
366
+ };
@@ -0,0 +1,4 @@
1
+ const t = "";
2
+ export {
3
+ t as default
4
+ };
@@ -0,0 +1,255 @@
1
+ var se = Object.defineProperty, ie = Object.defineProperties;
2
+ var oe = Object.getOwnPropertyDescriptors;
3
+ var F = Object.getOwnPropertySymbols;
4
+ var le = Object.prototype.hasOwnProperty, ae = Object.prototype.propertyIsEnumerable;
5
+ var H = (p, i, n) => i in p ? se(p, i, { enumerable: !0, configurable: !0, writable: !0, value: n }) : p[i] = n, W = (p, i) => {
6
+ for (var n in i || (i = {}))
7
+ le.call(i, n) && H(p, n, i[n]);
8
+ if (F)
9
+ for (var n of F(i))
10
+ ae.call(i, n) && H(p, n, i[n]);
11
+ return p;
12
+ }, q = (p, i) => ie(p, oe(i));
13
+ import { jsxs as S, jsx as s } from "react/jsx-runtime";
14
+ import { Modal as ce, Space as de, Button as y, message as b, Tabs as G, Row as fe, Col as D } from "antd";
15
+ import { useRef as M, useState as m, useContext as pe, useEffect as z } from "react";
16
+ import "./style.less.mjs";
17
+ import me from "./CategoryDrawer.mjs";
18
+ import ue from "./KVOCRLabelMaker/index.mjs";
19
+ import ge from "../../../DatasetContext/index.mjs";
20
+ import he from "../../DataEmpty/index.mjs";
21
+ import Ce from "../../Iconfont/index.mjs";
22
+ const {
23
+ TabPane: L
24
+ } = G, Le = (p) => {
25
+ var A, B;
26
+ const {
27
+ visible: i,
28
+ selectSampleId: n,
29
+ datasetId: d,
30
+ versionId: x,
31
+ ocrMarkTmpl: J,
32
+ onClose: Q,
33
+ onSave: N
34
+ } = p, u = M(null);
35
+ M(null);
36
+ const X = M({}), [t, f] = m(), [Y, w] = m(0), [g, Z] = m(), [R, h] = m(-1), [r, V] = m({
37
+ current: 1,
38
+ pageSize: 50
39
+ }), [T, K] = m(0), [O, E] = m(0), [I, _] = m(() => n ? "" : "nocode"), [ee, P] = m(!1), [k, te] = m([]), {
40
+ services: {
41
+ cvforceDatahub: a
42
+ },
43
+ featuresConfig: {
44
+ labelManager: $
45
+ } = {
46
+ labelManager: !1
47
+ }
48
+ } = pe(ge);
49
+ z(() => {
50
+ const e = r.current || 1, l = r.pageSize || 50;
51
+ !d || !x || (a == null || a.getDatasetsIdVersionsVidSamples(d, x, {
52
+ labels: I ? [I] : void 0,
53
+ pageNo: e,
54
+ pageSize: l
55
+ }).then((C) => {
56
+ const o = C.recordList || [];
57
+ if (Z(o), o.find((c) => c.id === n)) {
58
+ if (f(n ? o.find((c) => c.id === n) : o[0]), h(0), w(o.length), r.type === "next" && o.length) {
59
+ h(0);
60
+ const c = C.recordList[0];
61
+ f(c);
62
+ }
63
+ if (r.type === "prev" && o.length) {
64
+ h(r.pageSize - 1);
65
+ const c = C.recordList[r.pageSize - 1];
66
+ f(c);
67
+ }
68
+ } else if (n)
69
+ a.getDatasetsIdVersionsVidSsamplesSid(d, x, n).then((c) => {
70
+ f(c);
71
+ });
72
+ else {
73
+ if (f(o[0]), h(0), w(o.length), r.type === "next" && o.length) {
74
+ h(0);
75
+ const c = C.recordList[0];
76
+ f(c);
77
+ }
78
+ if (r.type === "prev" && o.length) {
79
+ h(r.pageSize - 1);
80
+ const c = C.recordList[r.pageSize - 1];
81
+ f(c);
82
+ }
83
+ }
84
+ }), v());
85
+ }, [r.current, I]);
86
+ const v = () => {
87
+ !d || !x || a == null || a.getDatasetsIdVersionsVidLabelcount(d, x).then((e) => {
88
+ const l = e.find((o) => o.id === "allcodeid"), C = e.find((o) => o.id === "nocodeid");
89
+ K(l ? l.count : 0), E(C ? C.count : 0);
90
+ });
91
+ }, j = () => {
92
+ d && (a == null || a.listCategory(d).then((e) => te(e || [])));
93
+ };
94
+ z(() => {
95
+ j();
96
+ }, [d]);
97
+ const U = () => {
98
+ if (!g)
99
+ return;
100
+ const e = R + 1;
101
+ if (e >= g.length)
102
+ (r.current - 1) * r.pageSize + e >= Y ? (b.error("已经是最后一个了"), V({
103
+ current: 1,
104
+ pageSize: r.pageSize
105
+ })) : V({
106
+ current: r.current + 1,
107
+ pageSize: r.pageSize,
108
+ type: "next"
109
+ });
110
+ else {
111
+ h(e);
112
+ const l = g[e];
113
+ f(l);
114
+ }
115
+ }, ne = () => {
116
+ if (!g)
117
+ return;
118
+ const e = R - 1;
119
+ if (e < 0)
120
+ (r.current - 1) * r.pageSize + e < 0 ? b.error("已经是第一个了") : V({
121
+ current: r.current - 1,
122
+ pageSize: r.pageSize,
123
+ type: "prev"
124
+ });
125
+ else {
126
+ h(e);
127
+ const l = g[e];
128
+ f(l);
129
+ }
130
+ };
131
+ z(() => {
132
+ i && d && x && t && (a == null || a.getDatasetsIdVersionsVidSsamplesSid(d, x, t.id).then((e) => {
133
+ f(e);
134
+ }));
135
+ }, [i, t == null ? void 0 : t.id]);
136
+ const re = () => {
137
+ Q();
138
+ };
139
+ return z(() => {
140
+ u.current && (u.current.width = u.current.offsetWidth, u.current.height = u.current.offsetHeight);
141
+ }, [u.current]), /* @__PURE__ */ S(ce, {
142
+ title: "标注",
143
+ width: "100%",
144
+ wrapClassName: "ocr-modal-wrap",
145
+ className: "ocr-modal",
146
+ open: i,
147
+ destroyOnClose: !0,
148
+ onCancel: () => re(),
149
+ maskClosable: !1,
150
+ centered: !0,
151
+ footer: /* @__PURE__ */ S(de, {
152
+ children: [/* @__PURE__ */ S("span", {
153
+ className: "ocr-modal-label-count",
154
+ children: ["当前图片标注框数量:", ((A = t == null ? void 0 : t.labels) == null ? void 0 : A.filter((e) => k.find((l) => l.id === e.catagoryId)).length) || 0]
155
+ }), /* @__PURE__ */ s(y, {
156
+ disabled: !t,
157
+ type: "primary",
158
+ onClick: () => {
159
+ t && N(t).then((e) => {
160
+ e ? (b.success("保存成功"), n || U(), v()) : b.error("保存失败");
161
+ });
162
+ },
163
+ children: "保存标注"
164
+ }, "save"), !n && /* @__PURE__ */ s(y, {
165
+ onClick: () => {
166
+ t && N(t).then((e) => {
167
+ e ? (ne(), v()) : b.error("保存失败");
168
+ });
169
+ },
170
+ children: "上一张"
171
+ }, "prev"), !n && /* @__PURE__ */ s(y, {
172
+ onClick: () => {
173
+ t && N(t).then((e) => {
174
+ e ? (U(), v()) : b.error("保存失败");
175
+ });
176
+ },
177
+ children: "下一张"
178
+ }, "next")]
179
+ }),
180
+ children: [/* @__PURE__ */ S("div", {
181
+ className: "records-content",
182
+ children: [!n && /* @__PURE__ */ S(G, {
183
+ className: "records-content-tabs",
184
+ defaultActiveKey: I,
185
+ onChange: (e) => _(e),
186
+ children: [/* @__PURE__ */ s(L, {
187
+ tab: `全部(${T})`
188
+ }, ""), /* @__PURE__ */ s(L, {
189
+ tab: `未标注(${O})`
190
+ }, "nocode"), /* @__PURE__ */ s(L, {
191
+ tab: `已标注(${T - O})`
192
+ }, "hascode")]
193
+ }), g != null && g.length ? /* @__PURE__ */ s("div", {
194
+ className: "ocr-mark",
195
+ children: /* @__PURE__ */ S(fe, {
196
+ className: "ocr-detail",
197
+ children: [/* @__PURE__ */ s(D, {
198
+ className: "detail-content",
199
+ children: /* @__PURE__ */ s("div", {
200
+ className: "select-main",
201
+ ref: X,
202
+ children: /* @__PURE__ */ s("canvas", {
203
+ ref: u,
204
+ id: "marking-canvas",
205
+ style: {
206
+ width: "100%",
207
+ height: "100%"
208
+ }
209
+ })
210
+ })
211
+ }), J === "StructKVCOCR" && /* @__PURE__ */ S(D, {
212
+ span: 8,
213
+ className: "detail-slide",
214
+ children: [/* @__PURE__ */ S("div", {
215
+ className: "slide-header",
216
+ children: [/* @__PURE__ */ s("b", {
217
+ children: "字段信息"
218
+ }), $ && $.visible && /* @__PURE__ */ s(y, {
219
+ size: "small",
220
+ onClick: () => P(!0),
221
+ icon: /* @__PURE__ */ s(Ce, {
222
+ type: "icon-shezhi"
223
+ }),
224
+ children: "字段管理"
225
+ })]
226
+ }), /* @__PURE__ */ s("div", {
227
+ className: "slide-main",
228
+ children: t && /* @__PURE__ */ s(ue, {
229
+ id: t.id,
230
+ canvasElement: u.current,
231
+ imageUrl: t == null ? void 0 : t.fileUrl,
232
+ categories: k,
233
+ labels: ((B = t.labels) == null ? void 0 : B.filter((e) => k.find((l) => l.id === e.catagoryId))) || [],
234
+ onChange: (e) => {
235
+ f(q(W({}, t), {
236
+ labels: e
237
+ }));
238
+ }
239
+ })
240
+ })]
241
+ })]
242
+ })
243
+ }) : /* @__PURE__ */ s(he, {})]
244
+ }), d && /* @__PURE__ */ s(me, {
245
+ datasetId: d,
246
+ visible: ee,
247
+ onClose: (e) => {
248
+ e && j(), P(!1);
249
+ }
250
+ })]
251
+ });
252
+ };
253
+ export {
254
+ Le as default
255
+ };
@@ -0,0 +1,4 @@
1
+ const t = "";
2
+ export {
3
+ t as default
4
+ };