@glodon-aiot/dataset-annotation 3.23.0-alpha.2 → 3.23.0-alpha.3
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.
- package/dist/es/components/DetectionAnnotation/components/Labels/index.mjs +148 -119
- package/dist/es/components/DetectionAnnotation/index.mjs +254 -245
- package/dist/es/index.mjs +1 -1
- package/dist/es/utils/formatCount.mjs +12 -0
- package/dist/lib/index.js +4 -4
- package/dist/src/components/DetectionAnnotation/components/Labels/index.d.ts +2 -0
- package/dist/src/utils/formatCount.d.ts +9 -0
- package/package.json +2 -2
|
@@ -1,198 +1,227 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
for (var
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var
|
|
10
|
-
|
|
1
|
+
var L = Object.defineProperty, ee = Object.defineProperties;
|
|
2
|
+
var le = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var F = Object.getOwnPropertySymbols;
|
|
4
|
+
var te = Object.prototype.hasOwnProperty, ie = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var U = (i, n, a) => n in i ? L(i, n, { enumerable: !0, configurable: !0, writable: !0, value: a }) : i[n] = a, g = (i, n) => {
|
|
6
|
+
for (var a in n || (n = {}))
|
|
7
|
+
te.call(n, a) && U(i, a, n[a]);
|
|
8
|
+
if (F)
|
|
9
|
+
for (var a of F(n))
|
|
10
|
+
ie.call(n, a) && U(i, a, n[a]);
|
|
11
11
|
return i;
|
|
12
|
-
},
|
|
13
|
-
import { jsxs as
|
|
14
|
-
import { Row as
|
|
15
|
-
import { forwardRef as
|
|
12
|
+
}, A = (i, n) => ee(i, le(n));
|
|
13
|
+
import { jsxs as p, jsx as r, Fragment as re } from "react/jsx-runtime";
|
|
14
|
+
import { Row as Z, Button as $, Input as ne, Space as oe, Empty as se, Modal as ae, Tooltip as ce } from "antd";
|
|
15
|
+
import { forwardRef as de, useState as h, useContext as fe, useEffect as M, useImperativeHandle as me } from "react";
|
|
16
16
|
import q from "../TagItem/index.mjs";
|
|
17
17
|
import "./style.less.mjs";
|
|
18
|
-
import { PlusOutlined as
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import { tagColors as
|
|
22
|
-
import
|
|
23
|
-
|
|
18
|
+
import { PlusOutlined as pe } from "@ant-design/icons";
|
|
19
|
+
import G from "../DisabledTooltip/index.mjs";
|
|
20
|
+
import ue from "../../../../DatasetContext/index.mjs";
|
|
21
|
+
import { tagColors as T } from "../../../../utils/index.mjs";
|
|
22
|
+
import { formatCount as he } from "../../../../utils/formatCount.mjs";
|
|
23
|
+
import be from "../../../Iconfont/index.mjs";
|
|
24
|
+
const xe = de(({
|
|
24
25
|
datasetId: i,
|
|
25
|
-
data:
|
|
26
|
-
selected:
|
|
27
|
-
showZero:
|
|
28
|
-
shortcut:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
data: n,
|
|
27
|
+
selected: a = [],
|
|
28
|
+
showZero: ve = !0,
|
|
29
|
+
shortcut: C = !1,
|
|
30
|
+
showStatColumns: D = !1,
|
|
31
|
+
selectMode: H = "multiple",
|
|
32
|
+
onItemClick: E,
|
|
33
|
+
onSelectedChange: j,
|
|
34
|
+
onListChange: u,
|
|
35
|
+
isPreLabel: x = !1,
|
|
36
|
+
settingHide: z = !1
|
|
37
|
+
}, J) => {
|
|
38
|
+
const [s, S] = h([]), [Ne, R] = h(!1), [o, b] = h([]), [O, P] = h(""), [v, w] = h(null), [y, K] = h(!1), {
|
|
37
39
|
services: {
|
|
38
|
-
cvforceDatahub:
|
|
40
|
+
cvforceDatahub: f
|
|
39
41
|
},
|
|
40
42
|
featuresConfig: {
|
|
41
|
-
labelManager:
|
|
43
|
+
labelManager: m
|
|
42
44
|
} = {
|
|
43
45
|
labelManager: !1
|
|
44
46
|
}
|
|
45
|
-
} =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}, [
|
|
49
|
-
i &&
|
|
50
|
-
}, [i]),
|
|
51
|
-
!i &&
|
|
47
|
+
} = fe(ue);
|
|
48
|
+
M(() => {
|
|
49
|
+
o.length && S(a.map((e) => o.find((l) => l.id === e.id)));
|
|
50
|
+
}, [a, o]), M(() => {
|
|
51
|
+
i && k();
|
|
52
|
+
}, [i]), M(() => {
|
|
53
|
+
!i && n && b(n.map((e) => A(g({}, e), {
|
|
52
54
|
createdAt: 0,
|
|
53
55
|
updatedAt: 0
|
|
54
56
|
})));
|
|
55
|
-
}, [i,
|
|
56
|
-
const
|
|
57
|
-
!i || !
|
|
57
|
+
}, [i, n]);
|
|
58
|
+
const k = () => {
|
|
59
|
+
!i || !f || (R(!0), f.listLabels(i, {
|
|
58
60
|
pageNo: 1,
|
|
59
61
|
pageSize: 1e4
|
|
60
62
|
}).then((e) => {
|
|
61
|
-
|
|
62
|
-
color:
|
|
63
|
+
b(e.recordList.sort((l, t) => l.createdAt - t.createdAt > 0 ? -1 : l.createdAt - t.createdAt < 0 ? 1 : 0).map((l, t) => A(g({}, l), {
|
|
64
|
+
color: T[t % 40]
|
|
63
65
|
})));
|
|
64
|
-
}).finally(() =>
|
|
66
|
+
}).finally(() => R(!1)));
|
|
65
67
|
};
|
|
66
|
-
|
|
67
|
-
fetchLabels:
|
|
68
|
+
me(J, () => ({
|
|
69
|
+
fetchLabels: k
|
|
68
70
|
}));
|
|
69
|
-
const
|
|
71
|
+
const Q = (e) => !i || !f ? Promise.resolve(!1) : f.postLabels(i, {
|
|
70
72
|
labels: [{
|
|
71
73
|
label: e
|
|
72
74
|
}]
|
|
73
|
-
}).then((
|
|
74
|
-
|
|
75
|
+
}).then((l) => {
|
|
76
|
+
b([...o, {
|
|
75
77
|
label: e,
|
|
76
|
-
id:
|
|
77
|
-
color:
|
|
78
|
+
id: l[0],
|
|
79
|
+
color: T[o.length % 40],
|
|
78
80
|
createdAt: Date.now(),
|
|
79
81
|
updatedAt: Date.now()
|
|
80
|
-
}]),
|
|
81
|
-
}).then(() => !0).catch(() => !1),
|
|
82
|
-
let
|
|
83
|
-
|
|
84
|
-
}, V = (e) => {
|
|
85
|
-
R(e);
|
|
82
|
+
}]), w(null), u && u([...o]);
|
|
83
|
+
}).then(() => !0).catch(() => !1), V = (e) => {
|
|
84
|
+
let l = [];
|
|
85
|
+
H === "multiple" ? s != null && s.some((t) => t.id === e.id) ? l = s == null ? void 0 : s.filter((t) => t.id !== e.id) : l = [...s, e] : s != null && s.some((t) => t.id === e.id) ? l = [] : l = [e], S(l), j && j(l);
|
|
86
86
|
}, W = (e) => {
|
|
87
|
-
|
|
88
|
-
return Promise.resolve(!1);
|
|
89
|
-
const t = r.findIndex((l) => l.id === e.id);
|
|
90
|
-
return d.patchLabel(i, e.id, e).then(() => (t < 0 || (r[t] = e, p([...r]), m && m([...r])), !0)).catch(() => !1);
|
|
87
|
+
P(e);
|
|
91
88
|
}, X = (e) => {
|
|
92
|
-
|
|
89
|
+
if (!i || !f)
|
|
90
|
+
return Promise.resolve(!1);
|
|
91
|
+
const l = o.findIndex((t) => t.id === e.id);
|
|
92
|
+
return f.patchLabel(i, e.id, e).then(() => (l < 0 || (o[l] = e, b([...o]), u && u([...o])), !0)).catch(() => !1);
|
|
93
|
+
}, Y = (e) => {
|
|
94
|
+
ae.confirm({
|
|
93
95
|
title: "确认要删除当前标签吗?",
|
|
94
96
|
content: "删除后,将会删除当前数据集中所有与当前标签关联的数据,删除后无法恢复,请确认是否删除!",
|
|
95
97
|
onOk: () => {
|
|
96
|
-
if (!i || !
|
|
98
|
+
if (!i || !f)
|
|
97
99
|
return;
|
|
98
|
-
const
|
|
99
|
-
return
|
|
100
|
-
|
|
100
|
+
const l = o.findIndex((d) => d.id === e), t = s.findIndex((d) => d.id === e);
|
|
101
|
+
return f.deleteLabel(i, e).then(() => {
|
|
102
|
+
t > -1 && (s.splice(t, 1), S([...s])), o.splice(l, 1), b([...o]), u && u([...o]), k();
|
|
101
103
|
});
|
|
102
104
|
}
|
|
103
105
|
});
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
}, N = (o == null ? void 0 : o.filter((e) => !O || e.label.includes(O))) || [], _ = (e) => {
|
|
107
|
+
var t, d;
|
|
108
|
+
const l = he((t = e == null ? void 0 : e.boxCount) != null ? t : 0);
|
|
109
|
+
return /* @__PURE__ */ p(re, {
|
|
110
|
+
children: [/* @__PURE__ */ r("span", {
|
|
111
|
+
className: "label-stat-col",
|
|
112
|
+
children: l.exact ? /* @__PURE__ */ r(ce, {
|
|
113
|
+
title: l.exact,
|
|
114
|
+
children: l.text
|
|
115
|
+
}) : l.text
|
|
116
|
+
}), /* @__PURE__ */ r("span", {
|
|
117
|
+
className: "label-stat-col",
|
|
118
|
+
children: (d = e == null ? void 0 : e.count) != null ? d : 0
|
|
119
|
+
})]
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
return /* @__PURE__ */ p("div", {
|
|
123
|
+
className: `label-list-wrap${D ? " label-list-wrap--stats" : ""}`,
|
|
124
|
+
children: [/* @__PURE__ */ p(Z, {
|
|
108
125
|
justify: "space-between",
|
|
109
126
|
className: "label-list-title",
|
|
110
|
-
children: [/* @__PURE__ */
|
|
127
|
+
children: [/* @__PURE__ */ r("span", {
|
|
111
128
|
className: "label-list-title",
|
|
112
129
|
children: "标签列表"
|
|
113
|
-
}), /* @__PURE__ */
|
|
130
|
+
}), /* @__PURE__ */ r("span", {
|
|
114
131
|
className: "label-list-icon",
|
|
115
|
-
children: !
|
|
116
|
-
isPreLabel:
|
|
132
|
+
children: !z && m && m.visible && /* @__PURE__ */ r(G, {
|
|
133
|
+
isPreLabel: x,
|
|
117
134
|
placement: "topRight",
|
|
118
|
-
children: /* @__PURE__ */
|
|
119
|
-
type:
|
|
135
|
+
children: /* @__PURE__ */ r($, {
|
|
136
|
+
type: y ? "link" : "text",
|
|
120
137
|
size: "small",
|
|
121
|
-
onClick: () =>
|
|
122
|
-
icon: /* @__PURE__ */
|
|
138
|
+
onClick: () => K(!y),
|
|
139
|
+
icon: /* @__PURE__ */ r(be, {
|
|
123
140
|
type: "icon-shezhi"
|
|
124
141
|
}),
|
|
125
|
-
disabled:
|
|
142
|
+
disabled: x
|
|
126
143
|
})
|
|
127
144
|
})
|
|
128
145
|
})]
|
|
129
|
-
}), /* @__PURE__ */
|
|
146
|
+
}), /* @__PURE__ */ p(Z, {
|
|
130
147
|
className: "label-list-opration",
|
|
131
|
-
children: [!
|
|
132
|
-
isPreLabel:
|
|
133
|
-
children: /* @__PURE__ */
|
|
148
|
+
children: [!z && m && m.add && /* @__PURE__ */ r(G, {
|
|
149
|
+
isPreLabel: x,
|
|
150
|
+
children: /* @__PURE__ */ r($, {
|
|
134
151
|
className: "label-list-create",
|
|
135
152
|
type: "default",
|
|
136
|
-
icon: /* @__PURE__ */
|
|
137
|
-
disabled:
|
|
153
|
+
icon: /* @__PURE__ */ r(pe, {}),
|
|
154
|
+
disabled: v !== null || x,
|
|
138
155
|
onClick: () => {
|
|
139
|
-
|
|
140
|
-
color:
|
|
156
|
+
w({
|
|
157
|
+
color: T[o.length % 40],
|
|
141
158
|
label: ""
|
|
142
159
|
});
|
|
143
160
|
}
|
|
144
161
|
})
|
|
145
|
-
}), /* @__PURE__ */
|
|
162
|
+
}), /* @__PURE__ */ r("span", {
|
|
146
163
|
className: "label-list-search",
|
|
147
|
-
children: /* @__PURE__ */
|
|
164
|
+
children: /* @__PURE__ */ r(ne.Search, {
|
|
148
165
|
placeholder: "请输入标签名称搜索",
|
|
149
|
-
onSearch:
|
|
166
|
+
onSearch: W,
|
|
150
167
|
onChange: (e) => {
|
|
151
|
-
|
|
168
|
+
P(e.target.value);
|
|
152
169
|
}
|
|
153
170
|
})
|
|
154
171
|
})]
|
|
155
|
-
}), /* @__PURE__ */
|
|
172
|
+
}), D && /* @__PURE__ */ p("div", {
|
|
173
|
+
className: "label-list-header",
|
|
174
|
+
children: [/* @__PURE__ */ r("span", {
|
|
175
|
+
className: "label-list-header-name",
|
|
176
|
+
children: "标签名称"
|
|
177
|
+
}), /* @__PURE__ */ r("span", {
|
|
178
|
+
className: "label-stat-col",
|
|
179
|
+
children: "标注框数"
|
|
180
|
+
}), /* @__PURE__ */ r("span", {
|
|
181
|
+
className: "label-stat-col",
|
|
182
|
+
children: "图片数"
|
|
183
|
+
})]
|
|
184
|
+
}), /* @__PURE__ */ p(oe, {
|
|
156
185
|
direction: "vertical",
|
|
157
186
|
className: "label-list",
|
|
158
|
-
children: [
|
|
159
|
-
onSave:
|
|
187
|
+
children: [v && /* @__PURE__ */ r(q, {
|
|
188
|
+
onSave: Q,
|
|
160
189
|
onCancel: () => {
|
|
161
|
-
|
|
190
|
+
w(null);
|
|
162
191
|
},
|
|
163
|
-
label:
|
|
164
|
-
color:
|
|
192
|
+
label: v.label || "",
|
|
193
|
+
color: v.color || "",
|
|
165
194
|
editMode: !0,
|
|
166
195
|
isActive: !1,
|
|
167
196
|
onCheckDuplication: (e) => {
|
|
168
|
-
const
|
|
169
|
-
return Promise.resolve(
|
|
197
|
+
const l = N.findIndex((t) => t.label === e);
|
|
198
|
+
return Promise.resolve(l > -1);
|
|
170
199
|
}
|
|
171
|
-
}),
|
|
172
|
-
var
|
|
173
|
-
return /* @__PURE__ */
|
|
174
|
-
isActive:
|
|
175
|
-
editable:
|
|
176
|
-
shortcut:
|
|
177
|
-
extra:
|
|
200
|
+
}), N.length ? N.reverse().map((e, l) => {
|
|
201
|
+
var t, d;
|
|
202
|
+
return /* @__PURE__ */ r(q, {
|
|
203
|
+
isActive: s.some((c) => (c == null ? void 0 : c.id) === e.id),
|
|
204
|
+
editable: y,
|
|
205
|
+
shortcut: C && l < 10 ? l.toString() : void 0,
|
|
206
|
+
extra: C ? l < 10 ? /* @__PURE__ */ p("span", {
|
|
178
207
|
className: "shortcut",
|
|
179
|
-
children: ["快捷键",
|
|
180
|
-
}) : null : ((
|
|
208
|
+
children: ["快捷键", l]
|
|
209
|
+
}) : null : D ? _(n.find((c) => c.label === e.label)) : (d = (t = n.find((c) => c.label === e.label)) == null ? void 0 : t.count) != null ? d : 0,
|
|
181
210
|
label: e.label,
|
|
182
211
|
color: e.color,
|
|
183
212
|
onClick: () => {
|
|
184
|
-
|
|
213
|
+
V(e), E && E(e);
|
|
185
214
|
},
|
|
186
|
-
onSave:
|
|
215
|
+
onSave: m && m.edit ? (c) => X(A(g({}, e), {
|
|
187
216
|
label: c
|
|
188
217
|
})) : void 0,
|
|
189
|
-
onDelete:
|
|
218
|
+
onDelete: m && m.delete ? () => Y(e.id) : void 0,
|
|
190
219
|
onCheckDuplication: (c) => {
|
|
191
|
-
const
|
|
192
|
-
return Promise.resolve(
|
|
220
|
+
const I = N.findIndex((B) => B.label === c && e.id !== B.id);
|
|
221
|
+
return Promise.resolve(I > -1);
|
|
193
222
|
}
|
|
194
223
|
}, e.id);
|
|
195
|
-
}) : /* @__PURE__ */
|
|
224
|
+
}) : /* @__PURE__ */ r(se, {
|
|
196
225
|
className: "label-list-empty",
|
|
197
226
|
image: !1,
|
|
198
227
|
description: "请先添加标签,然后在图中框选标注"
|
|
@@ -200,7 +229,7 @@ const fe = oe(({
|
|
|
200
229
|
})]
|
|
201
230
|
});
|
|
202
231
|
});
|
|
203
|
-
|
|
232
|
+
xe.displayName = "Labels";
|
|
204
233
|
export {
|
|
205
|
-
|
|
234
|
+
xe as default
|
|
206
235
|
};
|