@glodon-aiot/dataset-annotation 3.14.0-alpha.33 → 3.14.0-alpha.34

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