@glodon-aiot/dataset-annotation 3.24.0-alpha.5 → 3.24.0-alpha.6

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.
@@ -1,69 +1,74 @@
1
- var X = Object.defineProperty, Y = Object.defineProperties;
2
- var Z = Object.getOwnPropertyDescriptors;
3
- var V = Object.getOwnPropertySymbols;
4
- var ee = Object.prototype.hasOwnProperty, te = Object.prototype.propertyIsEnumerable;
5
- var $ = (l, s, r) => s in l ? X(l, s, { enumerable: !0, configurable: !0, writable: !0, value: r }) : l[s] = r, y = (l, s) => {
6
- for (var r in s || (s = {}))
7
- ee.call(s, r) && $(l, r, s[r]);
8
- if (V)
9
- for (var r of V(s))
10
- te.call(s, r) && $(l, r, s[r]);
1
+ var re = Object.defineProperty, se = Object.defineProperties;
2
+ var le = Object.getOwnPropertyDescriptors;
3
+ var _ = Object.getOwnPropertySymbols;
4
+ var oe = Object.prototype.hasOwnProperty, ce = Object.prototype.propertyIsEnumerable;
5
+ var H = (l, s, i) => s in l ? re(l, s, { enumerable: !0, configurable: !0, writable: !0, value: i }) : l[s] = i, C = (l, s) => {
6
+ for (var i in s || (s = {}))
7
+ oe.call(s, i) && H(l, i, s[i]);
8
+ if (_)
9
+ for (var i of _(s))
10
+ ce.call(s, i) && H(l, i, s[i]);
11
11
  return l;
12
- }, v = (l, s) => Y(l, Z(s));
13
- var q = (l, s, r) => new Promise((x, o) => {
14
- var f = (a) => {
12
+ }, S = (l, s) => se(l, le(s));
13
+ var x = (l, s, i) => new Promise((b, o) => {
14
+ var p = (a) => {
15
15
  try {
16
- g(r.next(a));
16
+ g(i.next(a));
17
17
  } catch (m) {
18
18
  o(m);
19
19
  }
20
- }, c = (a) => {
20
+ }, d = (a) => {
21
21
  try {
22
- g(r.throw(a));
22
+ g(i.throw(a));
23
23
  } catch (m) {
24
24
  o(m);
25
25
  }
26
- }, g = (a) => a.done ? x(a.value) : Promise.resolve(a.value).then(f, c);
27
- g((r = r.apply(l, s)).next());
26
+ }, g = (a) => a.done ? b(a.value) : Promise.resolve(a.value).then(p, d);
27
+ g((i = i.apply(l, s)).next());
28
28
  });
29
- import { jsxs as h, jsx as i } from "react/jsx-runtime";
30
- import { Space as L, Button as I, Tabs as ne, Tooltip as ae, Input as j, Modal as re, message as D } from "antd";
31
- import { forwardRef as ie, useState as Q, useContext as se, useRef as z, useImperativeHandle as le, useEffect as B } from "react";
29
+ import { jsxs as T, jsx as r } from "react/jsx-runtime";
30
+ import { Space as V, Button as I, Tabs as de, Tooltip as me, Input as J, Modal as fe, message as k } from "antd";
31
+ import { forwardRef as ue, useState as A, useContext as pe, useRef as P, useImperativeHandle as he, useEffect as $ } from "react";
32
32
  import R from "../../../Iconfont/index.mjs";
33
- import oe from "../../../../DatasetContext/index.mjs";
34
- import { UndoOutlined as ce } from "@ant-design/icons";
35
- const de = ie((l, s) => {
33
+ import ge from "../../../../DatasetContext/index.mjs";
34
+ import { UndoOutlined as Te } from "@ant-design/icons";
35
+ const we = ue((l, s) => {
36
36
  const {
37
- visionId: r,
38
- afterChangeTemplates: x,
37
+ visionId: i,
38
+ afterChangeTemplates: b,
39
39
  datasetId: o,
40
- onActiveIndexChange: f
41
- } = l, [c, g] = Q(!1), [a, m] = Q([]), [S, b] = Q(""), {
40
+ onActiveIndexChange: p
41
+ } = l, [d, g] = A(!1), [a, m] = A([]), [N, Q] = A(""), {
42
42
  services: {
43
43
  cvforceDatahub: u
44
+ },
45
+ featuresConfig: {
46
+ labelManager: w
47
+ } = {
48
+ labelManager: !1
44
49
  }
45
- } = se(oe), k = z(""), T = z(null), E = () => q(void 0, null, function* () {
46
- if (!o || !r)
50
+ } = pe(ge), E = !!(w && w.add), h = !!(w && w.edit), M = !!(w && w.delete), F = E || h || M, [j, z] = A(!1), L = P(""), v = P(null), B = () => x(void 0, null, function* () {
51
+ if (!o || !i)
47
52
  return;
48
- const e = yield u == null ? void 0 : u.getDatasetsIdVersionsVid(o, r), n = ((e == null ? void 0 : e.qaTemplate) || []).map((d, w) => {
49
- var p;
50
- return v(y({}, d), {
51
- id: (p = d.id) != null ? p : `template_${w}_${Date.now()}`
53
+ const e = yield u == null ? void 0 : u.getDatasetsIdVersionsVid(o, i), n = ((e == null ? void 0 : e.qaTemplate) || []).map((c, y) => {
54
+ var f;
55
+ return S(C({}, c), {
56
+ id: (f = c.id) != null ? f : `template_${y}_${Date.now()}`
52
57
  });
53
58
  });
54
- return m(n), k.current = A(n), n.length > 0 && (b(String(n[0].id)), f == null || f(0)), n;
55
- }), A = (e) => {
56
- const t = [...e].sort((n, d) => {
57
- const w = String(n.id), p = String(d.id);
58
- return w.localeCompare(p);
59
+ return m(n), L.current = U(n), n.length > 0 && (Q(String(n[0].id)), p == null || p(0)), n;
60
+ }), U = (e) => {
61
+ const t = [...e].sort((n, c) => {
62
+ const y = String(n.id), f = String(c.id);
63
+ return y.localeCompare(f);
59
64
  });
60
65
  return JSON.stringify(t);
61
- }, M = () => A(a) !== k.current, K = () => new Promise((e) => {
62
- if (!M()) {
66
+ }, K = () => U(a) !== L.current, W = () => new Promise((e) => {
67
+ if (!K()) {
63
68
  e(!0);
64
69
  return;
65
70
  }
66
- re.confirm({
71
+ fe.confirm({
67
72
  title: "提示",
68
73
  content: "QA生成配置有未保存的更改,确定要离开吗?",
69
74
  okText: "确定",
@@ -72,208 +77,212 @@ const de = ie((l, s) => {
72
77
  onCancel: () => e(!1)
73
78
  });
74
79
  });
75
- le(s, () => ({
76
- hasUnsavedChanges: M,
77
- checkDirtyAndConfirm: K
78
- })), B(() => {
79
- !o || !r || (E(), T.current = null);
80
- }, [o, r]), B(() => {
80
+ he(s, () => ({
81
+ hasUnsavedChanges: K,
82
+ checkDirtyAndConfirm: W
83
+ })), $(() => {
84
+ !o || !i || (B(), v.current = null);
85
+ }, [o, i]), $(() => {
86
+ h || g(!1);
87
+ }, [h]), $(() => {
81
88
  const e = (t) => {
82
- if (A(a) !== k.current)
89
+ if (U(a) !== L.current)
83
90
  return t.preventDefault(), t.returnValue = "", "";
84
91
  };
85
92
  return window.addEventListener("beforeunload", e), () => window.removeEventListener("beforeunload", e);
86
93
  }, [a]);
87
- const C = (e) => `模版${e + 1}`, U = () => q(void 0, null, function* () {
88
- if (T.current)
89
- return T.current;
90
- if (!o || !r)
94
+ const D = (e) => `模版${e + 1}`, O = () => x(void 0, null, function* () {
95
+ if (v.current)
96
+ return v.current;
97
+ if (!o || !i)
91
98
  return {
92
99
  q: "",
93
100
  a: ""
94
101
  };
95
102
  try {
96
- const e = yield u == null ? void 0 : u.getDefaultQaTemplates(o, r), t = (e == null ? void 0 : e[0]) || {
103
+ const e = yield u == null ? void 0 : u.getDefaultQaTemplates(o, i), t = (e == null ? void 0 : e[0]) || {
97
104
  q: "",
98
105
  a: ""
99
106
  };
100
- return T.current = t, t;
107
+ return v.current = t, t;
101
108
  } catch (e) {
102
- D.error("获取默认模板失败");
109
+ k.error("获取默认模板失败");
103
110
  const t = {
104
111
  q: "",
105
112
  a: ""
106
113
  };
107
- return T.current = t, t;
114
+ return v.current = t, t;
108
115
  }
109
- }), O = () => q(void 0, null, function* () {
110
- const e = yield U(), t = Date.now(), n = [...a, {
116
+ }), X = () => x(void 0, null, function* () {
117
+ const e = yield O(), t = Date.now(), n = [...a, {
111
118
  id: t,
112
- name: C(a.length),
119
+ name: D(a.length),
113
120
  q: e.q,
114
121
  a: e.a
115
122
  }];
116
- m(n), b(String(t)), g(!0);
117
- }), G = () => {
118
- var w;
123
+ m(n), Q(String(t)), h && g(!0);
124
+ }), Y = () => {
125
+ var y;
119
126
  if (a.length <= 1) {
120
- D.warning("至少保留一个模版");
127
+ k.warning("至少保留一个模版");
121
128
  return;
122
129
  }
123
- const e = a.findIndex((p) => String(p.id) === S), n = a.filter((p) => String(p.id) !== S).map((p, W) => v(y({}, p), {
124
- name: C(W)
130
+ const e = a.findIndex((f) => String(f.id) === N), n = a.filter((f) => String(f.id) !== N).map((f, ie) => S(C({}, f), {
131
+ name: D(ie)
125
132
  }));
126
133
  m(n);
127
- const d = Math.min(e, n.length - 1);
128
- b(String((w = n[d]) == null ? void 0 : w.id));
129
- }, _ = () => {
130
- const e = T.current || {
134
+ const c = Math.min(e, n.length - 1);
135
+ Q(String((y = n[c]) == null ? void 0 : y.id));
136
+ }, Z = () => {
137
+ const e = v.current || {
131
138
  q: "",
132
139
  a: ""
133
140
  };
134
- m(a.map((t) => String(t.id) === S ? v(y({}, t), {
141
+ m(a.map((t) => String(t.id) === N ? S(C({}, t), {
135
142
  q: e.q,
136
143
  a: e.a
137
144
  }) : t));
138
- }, H = (e, t) => {
139
- m(a.map((n) => n.id === e ? v(y({}, n), {
145
+ }, ee = (e, t) => {
146
+ m(a.map((n) => n.id === e ? S(C({}, n), {
140
147
  q: t
141
148
  }) : n));
142
- }, J = (e, t) => {
143
- m(a.map((n) => n.id === e ? v(y({}, n), {
149
+ }, te = (e, t) => {
150
+ m(a.map((n) => n.id === e ? S(C({}, n), {
144
151
  a: t
145
152
  }) : n));
146
- }, P = () => q(void 0, null, function* () {
147
- if (c) {
148
- if (a.filter((t) => {
149
- var n, d;
150
- return !((n = t.q) != null && n.trim()) || !((d = t.a) != null && d.trim());
151
- }).length > 0) {
152
- D.error("问题模版、回答模版均不能为空");
153
- return;
154
- }
155
- if (!o || !r)
156
- return;
157
- try {
158
- const t = a.map((n, d) => ({
159
- id: n.id,
160
- name: C(d),
161
- q: n.q,
162
- a: n.a
163
- }));
164
- yield u == null ? void 0 : u.patchDatasetsIdVersionsVid(o, r, {
165
- qaTemplate: t
166
- }), yield E();
167
- } catch (t) {
168
- D.error("保存失败");
153
+ }, G = () => x(void 0, null, function* () {
154
+ if (a.filter((t) => {
155
+ var n, c;
156
+ return !((n = t.q) != null && n.trim()) || !((c = t.a) != null && c.trim());
157
+ }).length > 0)
158
+ return k.error("问题模版、回答模版均不能为空"), !1;
159
+ if (!o || !i)
160
+ return !1;
161
+ z(!0);
162
+ try {
163
+ const t = a.map((n, c) => ({
164
+ id: n.id,
165
+ name: D(c),
166
+ q: n.q,
167
+ a: n.a
168
+ }));
169
+ return yield u == null ? void 0 : u.patchDatasetsIdVersionsVid(o, i, {
170
+ qaTemplate: t
171
+ }), yield B(), b == null || b(), !0;
172
+ } catch (t) {
173
+ return k.error("保存失败"), !1;
174
+ } finally {
175
+ z(!1);
176
+ }
177
+ }), ne = () => x(void 0, null, function* () {
178
+ if (d) {
179
+ if (!(yield G()))
169
180
  return;
170
- }
171
- x == null || x();
172
181
  } else
173
- yield U();
174
- g(!c);
175
- }), N = a.find((e) => String(e.id) === S), F = a.map((e, t) => ({
182
+ yield O();
183
+ g(!d);
184
+ }), q = a.find((e) => String(e.id) === N), ae = a.map((e, t) => ({
176
185
  key: String(e.id),
177
- label: C(t)
186
+ label: D(t)
178
187
  }));
179
- return /* @__PURE__ */ h("div", {
188
+ return /* @__PURE__ */ T("div", {
180
189
  className: "info-item",
181
- children: [/* @__PURE__ */ h("div", {
190
+ children: [/* @__PURE__ */ T("div", {
182
191
  className: "info-item-header",
183
- children: [/* @__PURE__ */ i("div", {
192
+ children: [/* @__PURE__ */ r("div", {
184
193
  className: "info-item-title",
185
194
  children: "QA生成配置"
186
- }), /* @__PURE__ */ h(L, {
195
+ }), (h || E) && /* @__PURE__ */ T(V, {
187
196
  style: {
188
197
  height: 32
189
198
  },
190
- children: [/* @__PURE__ */ i(I, {
199
+ children: [h && /* @__PURE__ */ r(I, {
191
200
  type: "text",
192
- icon: c ? /* @__PURE__ */ i(R, {
201
+ icon: d ? /* @__PURE__ */ r(R, {
193
202
  type: "icon-queding",
194
203
  className: "self-icon"
195
- }) : /* @__PURE__ */ i(R, {
204
+ }) : /* @__PURE__ */ r(R, {
196
205
  type: "icon-editing",
197
206
  className: "self-icon"
198
207
  }),
199
- onClick: P
200
- }), /* @__PURE__ */ i(I, {
208
+ onClick: ne
209
+ }), E && /* @__PURE__ */ r(I, {
201
210
  type: "text",
202
211
  disabled: a.length >= 2,
203
- icon: /* @__PURE__ */ i(R, {
212
+ icon: /* @__PURE__ */ r(R, {
204
213
  type: "icon-tianjia",
205
214
  className: `self-icon ${a.length >= 2 ? "disabled" : ""}`
206
215
  }),
207
- onClick: O
216
+ onClick: X
208
217
  })]
209
218
  })]
210
- }), /* @__PURE__ */ i("div", {
219
+ }), /* @__PURE__ */ r("div", {
211
220
  className: "template-tabs-wrapper",
212
- children: /* @__PURE__ */ i(ne, {
213
- activeKey: S,
221
+ children: /* @__PURE__ */ r(de, {
222
+ activeKey: N,
214
223
  onChange: (e) => {
215
- b(e);
224
+ Q(e);
216
225
  const t = a.findIndex((n) => String(n.id) === e);
217
- f == null || f(t);
226
+ p == null || p(t);
218
227
  },
219
- items: F,
220
- tabBarExtraContent: c && /* @__PURE__ */ i("div", {
228
+ items: ae,
229
+ tabBarExtraContent: (h && d || M) && /* @__PURE__ */ r("div", {
221
230
  className: "template-actions",
222
- children: /* @__PURE__ */ h(L, {
231
+ children: /* @__PURE__ */ T(V, {
223
232
  size: 0,
224
- children: [/* @__PURE__ */ i(ae, {
233
+ children: [h && d && /* @__PURE__ */ r(me, {
225
234
  title: "点击重置,您的设置会清空",
226
235
  placement: "bottom",
227
- children: /* @__PURE__ */ i(I, {
236
+ children: /* @__PURE__ */ r(I, {
228
237
  type: "text",
229
- icon: /* @__PURE__ */ i(ce, {}),
230
- onClick: _
238
+ icon: /* @__PURE__ */ r(Te, {}),
239
+ onClick: Z
231
240
  })
232
- }), /* @__PURE__ */ i(I, {
241
+ }), M && /* @__PURE__ */ r(I, {
233
242
  type: "text",
234
- icon: /* @__PURE__ */ i(R, {
243
+ icon: /* @__PURE__ */ r(R, {
235
244
  type: "icon-shanchu",
236
- className: `delete-btn ${!c || a.length <= 1 ? "disabled" : ""}`
245
+ className: `delete-btn ${a.length <= 1 ? "disabled" : ""}`
237
246
  }),
238
- disabled: !c || a.length <= 1,
239
- onClick: G
247
+ disabled: a.length <= 1,
248
+ onClick: Y
240
249
  })]
241
250
  })
242
251
  })
243
252
  })
244
- }), N && /* @__PURE__ */ i("div", {
253
+ }), q && /* @__PURE__ */ r("div", {
245
254
  className: "template-content",
246
- children: /* @__PURE__ */ h("div", {
247
- className: "form-item-container " + (c ? "active" : ""),
248
- children: [/* @__PURE__ */ h("div", {
255
+ children: /* @__PURE__ */ T("div", {
256
+ className: "form-item-container " + (d ? "active" : ""),
257
+ children: [/* @__PURE__ */ T("div", {
249
258
  className: "form-item",
250
- children: [/* @__PURE__ */ i("div", {
259
+ children: [/* @__PURE__ */ r("div", {
251
260
  className: "form-label",
252
261
  children: "问题模版"
253
- }), /* @__PURE__ */ i(j.TextArea, {
262
+ }), /* @__PURE__ */ r(J.TextArea, {
254
263
  showCount: !0,
255
264
  maxLength: 2e3,
256
- value: N.q,
257
- onChange: (e) => H(N.id, e.target.value),
265
+ value: q.q,
266
+ onChange: (e) => ee(q.id, e.target.value),
258
267
  placeholder: "请输入问题模版",
259
- disabled: !c,
268
+ disabled: !d,
260
269
  autoSize: {
261
270
  minRows: 2,
262
271
  maxRows: 20
263
272
  }
264
273
  })]
265
- }), /* @__PURE__ */ h("div", {
274
+ }), /* @__PURE__ */ T("div", {
266
275
  className: "form-item",
267
- children: [/* @__PURE__ */ i("div", {
276
+ children: [/* @__PURE__ */ r("div", {
268
277
  className: "form-label",
269
278
  children: "回答模版"
270
- }), /* @__PURE__ */ i(j.TextArea, {
279
+ }), /* @__PURE__ */ r(J.TextArea, {
271
280
  showCount: !0,
272
281
  maxLength: 2e3,
273
- value: N.a,
274
- onChange: (e) => J(N.id, e.target.value),
282
+ value: q.a,
283
+ onChange: (e) => te(q.id, e.target.value),
275
284
  placeholder: "请输入回答模版",
276
- disabled: !c,
285
+ disabled: !d,
277
286
  autoSize: {
278
287
  minRows: 2,
279
288
  maxRows: 20
@@ -281,10 +290,21 @@ const de = ie((l, s) => {
281
290
  })]
282
291
  })]
283
292
  })
293
+ }), F && /* @__PURE__ */ r("div", {
294
+ className: "qa-config-footer",
295
+ children: /* @__PURE__ */ r(V, {
296
+ children: /* @__PURE__ */ r(I, {
297
+ type: "primary",
298
+ loading: j,
299
+ disabled: j,
300
+ onClick: G,
301
+ children: "保存"
302
+ })
303
+ })
284
304
  })]
285
305
  });
286
306
  });
287
- de.displayName = "QAGenerationConfig";
307
+ we.displayName = "QAGenerationConfig";
288
308
  export {
289
- de as default
309
+ we as default
290
310
  };