@trungkhai/dynamic-form 0.1.4 → 0.1.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.
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +93 -5
- package/dist/index.es.js +1900 -1005
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Select as
|
|
3
|
-
import { createContext as
|
|
4
|
-
import
|
|
5
|
-
import { FileImageOutlined as
|
|
6
|
-
const
|
|
1
|
+
import { jsx as l, jsxs as ce, Fragment as V } from "react/jsx-runtime";
|
|
2
|
+
import { Select as Ie, Form as Q, Upload as qe, Button as Ae, Alert as N, Collapse as at, DatePicker as ct, Checkbox as lt, Radio as dt, InputNumber as ut, Input as Le, Row as ft, Col as mt, App as pt, Flex as Se, Spin as be, Table as yt } from "antd";
|
|
3
|
+
import { createContext as ht, useContext as Be, memo as Z, useState as L, useMemo as C, useEffect as j, useRef as q, useCallback as D, forwardRef as _t, useImperativeHandle as bt } from "react";
|
|
4
|
+
import ge from "dayjs";
|
|
5
|
+
import { FileImageOutlined as gt, UploadOutlined as wt, DeleteOutlined as vt, PlusOutlined as At } from "@ant-design/icons";
|
|
6
|
+
const ke = ht(
|
|
7
7
|
null
|
|
8
8
|
);
|
|
9
|
-
function
|
|
10
|
-
const e =
|
|
9
|
+
function U() {
|
|
10
|
+
const e = Be(ke);
|
|
11
11
|
if (!e)
|
|
12
12
|
throw new Error(
|
|
13
13
|
"useDynamicFormContext must be used within DynamicFormProvider"
|
|
14
14
|
);
|
|
15
15
|
return e;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
return
|
|
17
|
+
function qn() {
|
|
18
|
+
return Be(ke);
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function St(e, t = []) {
|
|
21
21
|
for (const r of t) {
|
|
22
22
|
if (typeof r == "function")
|
|
23
23
|
continue;
|
|
24
|
-
const { match: i, render:
|
|
24
|
+
const { match: i, render: s } = r;
|
|
25
25
|
if (typeof i == "string") {
|
|
26
26
|
if (i === e.field?.type?.code || i === e.code)
|
|
27
|
-
return
|
|
27
|
+
return s;
|
|
28
28
|
} else if (i(e))
|
|
29
|
-
return
|
|
29
|
+
return s;
|
|
30
30
|
}
|
|
31
31
|
const n = e.field?.type?.code;
|
|
32
32
|
for (const r of t)
|
|
33
33
|
;
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
return
|
|
35
|
+
function kt(e, t = [], n = {}) {
|
|
36
|
+
return St(e, t) ?? n[e.code] ?? n[e.field?.type?.code ?? ""];
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function Ft(e, t) {
|
|
39
39
|
const n = t.option_config?.label_attr, r = t.option_config?.value_attr || "value";
|
|
40
40
|
let i;
|
|
41
41
|
if (n?.length) {
|
|
42
|
-
const
|
|
43
|
-
e[
|
|
42
|
+
const s = n.join(" - ");
|
|
43
|
+
e[s] !== void 0 ? i = String(e[s]) : i = n.map((o) => e[o]).filter((o) => o != null && o !== "").join(" - ");
|
|
44
44
|
} else
|
|
45
45
|
i = String(e[r] ?? "");
|
|
46
46
|
return {
|
|
@@ -48,63 +48,63 @@ function nt(e, t) {
|
|
|
48
48
|
value: e[r]
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
return t.option_config && t.is_option_api ? e?.map((n) =>
|
|
51
|
+
function Ct(e, t) {
|
|
52
|
+
return t.option_config && t.is_option_api ? e?.map((n) => Ft(n, t)) : t.metas?.map((n) => ({
|
|
53
53
|
label: n.label,
|
|
54
54
|
value: n.value
|
|
55
55
|
}));
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function Ke(e, t) {
|
|
58
58
|
const n = t.option_config?.value_attr || "value";
|
|
59
59
|
return e[n];
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function Et(e, t) {
|
|
62
62
|
const n = /* @__PURE__ */ new Set(), r = [];
|
|
63
63
|
return e.forEach((i) => {
|
|
64
|
-
const
|
|
64
|
+
const s = Ke(i, t), o = String(s);
|
|
65
65
|
n.has(o) || (n.add(o), r.push(i));
|
|
66
66
|
}), r;
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function Fe(e, t) {
|
|
69
69
|
let n;
|
|
70
70
|
return (...r) => {
|
|
71
71
|
n && clearTimeout(n), n = setTimeout(() => e(...r), t);
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
-
const
|
|
74
|
+
const Rt = ({
|
|
75
75
|
onSearchKeyword: e,
|
|
76
76
|
searchDebounceMs: t = 500,
|
|
77
77
|
...n
|
|
78
78
|
}) => {
|
|
79
|
-
const [r, i] =
|
|
80
|
-
() =>
|
|
79
|
+
const [r, i] = L(""), s = C(
|
|
80
|
+
() => Fe((a) => e?.(a), t),
|
|
81
81
|
[e, t]
|
|
82
82
|
);
|
|
83
|
-
return /* @__PURE__ */
|
|
84
|
-
|
|
83
|
+
return /* @__PURE__ */ l(
|
|
84
|
+
Ie,
|
|
85
85
|
{
|
|
86
86
|
allowClear: !0,
|
|
87
87
|
showSearch: !0,
|
|
88
88
|
searchValue: r,
|
|
89
|
-
onSearch: (
|
|
90
|
-
i(
|
|
89
|
+
onSearch: (a) => {
|
|
90
|
+
i(a), s(a);
|
|
91
91
|
},
|
|
92
92
|
filterOption: !1,
|
|
93
93
|
...n
|
|
94
94
|
}
|
|
95
95
|
);
|
|
96
|
-
},
|
|
96
|
+
}, xt = Z(Rt), Tt = ({
|
|
97
97
|
fieldName: e,
|
|
98
98
|
formInstance: t,
|
|
99
99
|
...n
|
|
100
100
|
}) => {
|
|
101
|
-
const r =
|
|
102
|
-
return
|
|
101
|
+
const r = Q.useWatch(e, t);
|
|
102
|
+
return j(() => {
|
|
103
103
|
if (r?.fileList?.length && r.fileList.some(
|
|
104
104
|
(o) => !o.type?.startsWith("image/")
|
|
105
105
|
)) {
|
|
106
106
|
const o = r.fileList.filter(
|
|
107
|
-
(
|
|
107
|
+
(a) => a.type?.startsWith("image/")
|
|
108
108
|
);
|
|
109
109
|
t.setFieldValue(
|
|
110
110
|
e,
|
|
@@ -114,201 +114,1067 @@ const at = ({
|
|
|
114
114
|
} : null
|
|
115
115
|
);
|
|
116
116
|
}
|
|
117
|
-
}, [e, t, r]), /* @__PURE__ */
|
|
117
|
+
}, [e, t, r]), /* @__PURE__ */ l(qe, { listType: "picture-card", accept: "image/*", ...n, children: /* @__PURE__ */ l(
|
|
118
118
|
"button",
|
|
119
119
|
{
|
|
120
120
|
style: { border: 0, background: "none", cursor: "pointer" },
|
|
121
121
|
type: "button",
|
|
122
|
-
children: /* @__PURE__ */
|
|
122
|
+
children: /* @__PURE__ */ l(gt, {})
|
|
123
123
|
}
|
|
124
124
|
) });
|
|
125
|
-
},
|
|
125
|
+
}, Mt = Z(Tt), Dt = ({
|
|
126
126
|
fieldName: e,
|
|
127
127
|
formInstance: t,
|
|
128
128
|
...n
|
|
129
129
|
}) => {
|
|
130
|
-
const r =
|
|
131
|
-
return /* @__PURE__ */
|
|
132
|
-
},
|
|
130
|
+
const r = Q.useWatch(e, t);
|
|
131
|
+
return /* @__PURE__ */ l(qe, { fileList: r?.fileList, ...n, children: /* @__PURE__ */ l(Ae, { icon: /* @__PURE__ */ l(wt, {}) }) });
|
|
132
|
+
}, Lt = Z(Dt);
|
|
133
|
+
function we(e, t, n = {}) {
|
|
134
|
+
const { enabled: r = !0 } = n, [i, s] = L(), [o, a] = L(!1), [m, f] = L(), y = q(t);
|
|
135
|
+
y.current = t;
|
|
136
|
+
const u = D(async () => {
|
|
137
|
+
if (r) {
|
|
138
|
+
a(!0);
|
|
139
|
+
try {
|
|
140
|
+
const c = await y.current();
|
|
141
|
+
return s(c), f(void 0), c;
|
|
142
|
+
} catch (c) {
|
|
143
|
+
throw f(c), c;
|
|
144
|
+
} finally {
|
|
145
|
+
a(!1);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}, [r]);
|
|
149
|
+
return j(() => {
|
|
150
|
+
r && u();
|
|
151
|
+
}, [r, u, ...e]), { data: i, isLoading: o, error: m, refetch: u };
|
|
152
|
+
}
|
|
153
|
+
function Ue(e) {
|
|
154
|
+
if (!e) return;
|
|
155
|
+
const { mode: t } = e;
|
|
156
|
+
if (t === "api" && e.api?.url)
|
|
157
|
+
return e.api;
|
|
158
|
+
if (t === "api_ids" && e.api_ids?.url) {
|
|
159
|
+
const n = e.api_ids, r = n.method?.toUpperCase() === "POST";
|
|
160
|
+
return {
|
|
161
|
+
url: n.url,
|
|
162
|
+
method: n.method,
|
|
163
|
+
data_path: n.data_path,
|
|
164
|
+
mapping_attr: n.mapping_attr,
|
|
165
|
+
link: n.link,
|
|
166
|
+
result_type: n.result_type ?? "array",
|
|
167
|
+
params: n.params ?? (!r && !n.data ? { ids: "{{value}}" } : void 0),
|
|
168
|
+
data: n.data ?? (r && !n.params ? { ids: "{{value}}" } : void 0)
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
if (t === "api_detail" && e.api_detail?.url) {
|
|
172
|
+
const n = e.api_detail;
|
|
173
|
+
return {
|
|
174
|
+
url: n.url,
|
|
175
|
+
method: n.method,
|
|
176
|
+
data_path: n.data_path,
|
|
177
|
+
mapping_attr: n.mapping_attr,
|
|
178
|
+
link: n.link,
|
|
179
|
+
result_type: n.result_type ?? "object",
|
|
180
|
+
url_template: n.url_template ?? !0,
|
|
181
|
+
params: n.params,
|
|
182
|
+
data: n.data
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function Pe(e) {
|
|
187
|
+
return {
|
|
188
|
+
value: e,
|
|
189
|
+
id: e
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function Pt(e, t) {
|
|
193
|
+
const n = t.method || "GET", r = n.toUpperCase() === "GET";
|
|
194
|
+
if (t.url_template)
|
|
195
|
+
return (Array.isArray(e) ? e.filter((m) => m != null && m !== "") : e != null && e !== "" ? [e] : []).map((m) => {
|
|
196
|
+
const f = Pe(m), y = he(t.url, f), u = t.params ? oe(t.params, f) : void 0, c = t.data ? oe(t.data, f) : void 0;
|
|
197
|
+
return {
|
|
198
|
+
method: n,
|
|
199
|
+
url: y,
|
|
200
|
+
params: r ? u : void 0,
|
|
201
|
+
data: r ? void 0 : c
|
|
202
|
+
};
|
|
203
|
+
});
|
|
204
|
+
const i = Pe(e), s = t.params ? oe(t.params, i) : void 0, o = t.data ? oe(t.data, i) : void 0;
|
|
205
|
+
return [
|
|
206
|
+
{
|
|
207
|
+
method: n,
|
|
208
|
+
url: t.url,
|
|
209
|
+
params: r ? s : void 0,
|
|
210
|
+
data: r ? void 0 : o
|
|
211
|
+
}
|
|
212
|
+
];
|
|
213
|
+
}
|
|
214
|
+
function Ne(e, t) {
|
|
215
|
+
const n = t.data_path ? ae(e, t.data_path) : e;
|
|
216
|
+
return (t.result_type ?? (Array.isArray(n) ? "array" : "object")) === "array" ? Array.isArray(n) ? n : n != null ? [n] : [] : Array.isArray(n) ? n.length ? [n[0]] : [] : n && typeof n == "object" ? [n] : [];
|
|
217
|
+
}
|
|
218
|
+
function We(e, t) {
|
|
219
|
+
return It(e, t.mapping_attr);
|
|
220
|
+
}
|
|
221
|
+
function $e(e, t) {
|
|
222
|
+
return qt(t.link, e);
|
|
223
|
+
}
|
|
224
|
+
async function Vt(e, t, n, r) {
|
|
225
|
+
const i = Pt(e, t);
|
|
226
|
+
if (!i.length) return [];
|
|
227
|
+
const s = await Promise.all(
|
|
228
|
+
i.map((a) => n({ ...a, signal: r }))
|
|
229
|
+
), o = [];
|
|
230
|
+
for (const a of s)
|
|
231
|
+
o.push(...Ne(a.data, t));
|
|
232
|
+
return o;
|
|
233
|
+
}
|
|
234
|
+
function W(e) {
|
|
235
|
+
return !!(e == null || e === "" || Array.isArray(e) && e.length === 0);
|
|
236
|
+
}
|
|
237
|
+
function Ce(e, t) {
|
|
238
|
+
const n = e.option_config?.api_options?.params, r = e.option_config?.api_options?.data;
|
|
239
|
+
if (!n && !r) return;
|
|
240
|
+
const i = (s) => {
|
|
241
|
+
const o = {};
|
|
242
|
+
for (const a in s)
|
|
243
|
+
if (typeof s[a] == "string" && s[a].startsWith("{{") && s[a].endsWith("}}")) {
|
|
244
|
+
const m = s[a].slice(2, -2).trim();
|
|
245
|
+
o[a] = t?.[m];
|
|
246
|
+
} else
|
|
247
|
+
o[a] = s[a];
|
|
248
|
+
return o;
|
|
249
|
+
};
|
|
250
|
+
return {
|
|
251
|
+
params: n ? i(n) : void 0,
|
|
252
|
+
data: r ? i(r) : void 0
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
function jt(e, t) {
|
|
256
|
+
const n = t.option_config?.label_attr, r = t.option_config?.value_attr || "";
|
|
257
|
+
if (n?.length) {
|
|
258
|
+
const i = n.join(" - ");
|
|
259
|
+
return e[i] !== void 0 ? String(e[i]) : n.map((s) => e[s]).filter((s) => s != null && s !== "").join(" - ");
|
|
260
|
+
}
|
|
261
|
+
return String(e[r] ?? "");
|
|
262
|
+
}
|
|
263
|
+
function Ee(e, t) {
|
|
264
|
+
if (!t?.length) return null;
|
|
265
|
+
const r = (Array.isArray(e) ? e : [e]).map((i) => t.find((s) => String(s.value) === String(i))?.label).filter((i) => !!i);
|
|
266
|
+
return r.length ? r.join(", ") : null;
|
|
267
|
+
}
|
|
268
|
+
function se(e, t, n) {
|
|
269
|
+
if (W(e)) return null;
|
|
270
|
+
const r = t.option_config?.value_attr || "value", i = Array.isArray(e) ? e : [e];
|
|
271
|
+
if (t.is_option_api && n?.length) {
|
|
272
|
+
const o = i.map((a) => {
|
|
273
|
+
const m = n.find(
|
|
274
|
+
(f) => String(f[r]) === String(a)
|
|
275
|
+
);
|
|
276
|
+
return m ? jt(m, t) : String(a);
|
|
277
|
+
}).filter(Boolean);
|
|
278
|
+
return o.length ? o.join(", ") : null;
|
|
279
|
+
}
|
|
280
|
+
const s = Ee(e, t.metas);
|
|
281
|
+
return s || i.map(String).join(", ");
|
|
282
|
+
}
|
|
283
|
+
function ze(e, t) {
|
|
284
|
+
if (W(e)) return null;
|
|
285
|
+
const n = t.additional_config?.datetime?.format, r = ge(e);
|
|
286
|
+
return r.isValid() ? n ? r.format(n) : r.format("YYYY-MM-DD HH:mm:ss") : String(e);
|
|
287
|
+
}
|
|
288
|
+
function Ot(e) {
|
|
289
|
+
if (W(e)) return null;
|
|
290
|
+
if (Array.isArray(e)) {
|
|
291
|
+
const t = e.map(
|
|
292
|
+
(n) => typeof n == "object" && n && "name" in n ? String(n.name) : String(n)
|
|
293
|
+
).filter(Boolean);
|
|
294
|
+
return t.length ? t.join(", ") : null;
|
|
295
|
+
}
|
|
296
|
+
return String(e);
|
|
297
|
+
}
|
|
298
|
+
function It(e, t) {
|
|
299
|
+
return t?.length ? t.map((n) => {
|
|
300
|
+
const r = ae(e, n) ?? e[n];
|
|
301
|
+
return r != null ? String(r) : "";
|
|
302
|
+
}).filter(Boolean).join(" - ") : JSON.stringify(e);
|
|
303
|
+
}
|
|
304
|
+
function qt(e, t) {
|
|
305
|
+
return e ? e.replace(/\{\{(.+?)\}\}/g, (n, r) => {
|
|
306
|
+
const i = r.trim(), s = ae(t, i) ?? t[i];
|
|
307
|
+
return s != null ? String(s) : "";
|
|
308
|
+
}) : null;
|
|
309
|
+
}
|
|
310
|
+
function Ve(e, t, n) {
|
|
311
|
+
if (W(e)) return null;
|
|
312
|
+
switch (t?.mode ?? "formatted") {
|
|
313
|
+
case "raw":
|
|
314
|
+
case "formatted":
|
|
315
|
+
return Array.isArray(e) ? e.map(String).join(", ") : String(e);
|
|
316
|
+
case "api":
|
|
317
|
+
case "api_ids":
|
|
318
|
+
case "api_detail": {
|
|
319
|
+
const i = Ue(t);
|
|
320
|
+
if (!n || !i)
|
|
321
|
+
return Array.isArray(e) ? e.map(String).join(", ") : String(e);
|
|
322
|
+
const s = Ne(n, i);
|
|
323
|
+
return s.length ? s.map((a) => {
|
|
324
|
+
const m = We(a, i), f = $e(a, i);
|
|
325
|
+
return f ? `${m} (${f})` : m;
|
|
326
|
+
}).filter(Boolean).join(", ") || null : String(e);
|
|
327
|
+
}
|
|
328
|
+
default:
|
|
329
|
+
return String(e);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
function Bt(e, t, n) {
|
|
333
|
+
const r = e.additional_config?.view_value;
|
|
334
|
+
if (r?.mode === "api" || r?.mode === "api_ids" || r?.mode === "api_detail")
|
|
335
|
+
return Ve(
|
|
336
|
+
t,
|
|
337
|
+
r,
|
|
338
|
+
n.viewValueFetched
|
|
339
|
+
);
|
|
340
|
+
switch (e.field?.type?.code) {
|
|
341
|
+
case "text":
|
|
342
|
+
case "number":
|
|
343
|
+
return W(t) ? null : String(t);
|
|
344
|
+
case "datetime":
|
|
345
|
+
return ze(t, e);
|
|
346
|
+
case "select":
|
|
347
|
+
case "radio":
|
|
348
|
+
case "checkbox":
|
|
349
|
+
return se(t, e, n.optionList);
|
|
350
|
+
case "image":
|
|
351
|
+
case "file":
|
|
352
|
+
return Ot(t);
|
|
353
|
+
default:
|
|
354
|
+
return r ? Ve(
|
|
355
|
+
t,
|
|
356
|
+
r,
|
|
357
|
+
n.viewValueFetched
|
|
358
|
+
) : W(t) ? null : String(t);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
function le(e) {
|
|
362
|
+
const t = e.additional_config?.default;
|
|
363
|
+
return typeof t == "string" && t.trim() ? t : void 0;
|
|
364
|
+
}
|
|
365
|
+
function He(e, t, n) {
|
|
366
|
+
if (!t || typeof t != "object" || Array.isArray(t))
|
|
367
|
+
return {};
|
|
368
|
+
const r = n ?? le(e), i = t;
|
|
369
|
+
if (r && r in i) {
|
|
370
|
+
const s = i[r];
|
|
371
|
+
if (s && typeof s == "object" && !Array.isArray(s))
|
|
372
|
+
return s;
|
|
373
|
+
}
|
|
374
|
+
return i;
|
|
375
|
+
}
|
|
376
|
+
function Ye(e, t, n) {
|
|
377
|
+
if (Array.isArray(t))
|
|
378
|
+
return t;
|
|
379
|
+
const r = n ?? le(e);
|
|
380
|
+
if (!r || W(t))
|
|
381
|
+
return [];
|
|
382
|
+
if (t && typeof t == "object" && !Array.isArray(t)) {
|
|
383
|
+
const i = t;
|
|
384
|
+
if (r in i && Array.isArray(i[r]))
|
|
385
|
+
return i[r];
|
|
386
|
+
}
|
|
387
|
+
return Je(
|
|
388
|
+
e,
|
|
389
|
+
{ [e.code]: t },
|
|
390
|
+
r
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
function Bn(e) {
|
|
394
|
+
return {
|
|
395
|
+
id: e.id,
|
|
396
|
+
code: e.code,
|
|
397
|
+
form_id: e.id,
|
|
398
|
+
method: "POST",
|
|
399
|
+
action: "",
|
|
400
|
+
config: {
|
|
401
|
+
body: ""
|
|
402
|
+
},
|
|
403
|
+
created_at: e.created_at ?? "",
|
|
404
|
+
updated_at: e.updated_at ?? "",
|
|
405
|
+
created_by: e.created_by,
|
|
406
|
+
deleted_at: e.deleted_at,
|
|
407
|
+
form: e
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
function Re(e) {
|
|
411
|
+
return e.additional_config?.form?.submit_container_key ?? e.additional_config?.multiple_form?.submit_container_key ?? e.code;
|
|
412
|
+
}
|
|
413
|
+
function Kt(e, t, n, r) {
|
|
414
|
+
const i = Re(e), s = t[e.code] ?? t[i];
|
|
415
|
+
if (!W(s) && s && typeof s == "object" && !Array.isArray(s)) {
|
|
416
|
+
const o = s;
|
|
417
|
+
if (n in o) {
|
|
418
|
+
const a = o[n];
|
|
419
|
+
return a && typeof a == "object" && !Array.isArray(a) ? a : void 0;
|
|
420
|
+
}
|
|
421
|
+
return o;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
function Je(e, t, n) {
|
|
425
|
+
const r = Re(e), i = t[e.code] ?? t[r];
|
|
426
|
+
if (W(i))
|
|
427
|
+
return [];
|
|
428
|
+
if (i && typeof i == "object" && !Array.isArray(i)) {
|
|
429
|
+
const s = i;
|
|
430
|
+
if (n in s && Array.isArray(s[n]))
|
|
431
|
+
return s[n];
|
|
432
|
+
}
|
|
433
|
+
return Array.isArray(i) ? i : [];
|
|
434
|
+
}
|
|
435
|
+
function ae(e, t) {
|
|
436
|
+
return t.split(".").reduce((n, r) => {
|
|
437
|
+
if (n && typeof n == "object")
|
|
438
|
+
return n[r];
|
|
439
|
+
}, e);
|
|
440
|
+
}
|
|
441
|
+
function Ut(e, t) {
|
|
442
|
+
if (typeof e != "string") return e;
|
|
443
|
+
const n = e.match(/^\{\{(.+?)\}\}$/);
|
|
444
|
+
if (!n) return e;
|
|
445
|
+
const r = n[1].trim(), i = ae(t, r);
|
|
446
|
+
return i !== void 0 ? i : e;
|
|
447
|
+
}
|
|
448
|
+
function Nt(e, t) {
|
|
449
|
+
const n = {};
|
|
450
|
+
for (const r in e)
|
|
451
|
+
n[r] = Ut(
|
|
452
|
+
e[r],
|
|
453
|
+
t
|
|
454
|
+
);
|
|
455
|
+
return n;
|
|
456
|
+
}
|
|
457
|
+
function Xe(e, t) {
|
|
458
|
+
const n = { ...e };
|
|
459
|
+
return t.forEach((r) => {
|
|
460
|
+
const i = e[r.code];
|
|
461
|
+
if (i == null) return;
|
|
462
|
+
switch (r.field?.type?.code) {
|
|
463
|
+
case "datetime": {
|
|
464
|
+
if (i && typeof i == "object" && typeof i.isValid == "function") {
|
|
465
|
+
n[r.code] = i;
|
|
466
|
+
break;
|
|
467
|
+
}
|
|
468
|
+
const o = ge(i);
|
|
469
|
+
o.isValid() && (n[r.code] = o);
|
|
470
|
+
break;
|
|
471
|
+
}
|
|
472
|
+
case "file":
|
|
473
|
+
case "image": {
|
|
474
|
+
if (Array.isArray(i) && i.length > 0) {
|
|
475
|
+
const o = i.map((a, m) => {
|
|
476
|
+
const f = a;
|
|
477
|
+
return {
|
|
478
|
+
uid: String(f.uid ?? f.path ?? m),
|
|
479
|
+
name: f.name ?? `file-${m}`,
|
|
480
|
+
status: "done",
|
|
481
|
+
percent: 100,
|
|
482
|
+
type: f.type,
|
|
483
|
+
size: f.size,
|
|
484
|
+
response: a
|
|
485
|
+
};
|
|
486
|
+
});
|
|
487
|
+
n[r.code] = { fileList: o };
|
|
488
|
+
}
|
|
489
|
+
break;
|
|
490
|
+
}
|
|
491
|
+
case "form": {
|
|
492
|
+
const o = le(r);
|
|
493
|
+
n[r.code] = He(r, i, o);
|
|
494
|
+
break;
|
|
495
|
+
}
|
|
496
|
+
case "multiple-form": {
|
|
497
|
+
const o = le(r);
|
|
498
|
+
n[r.code] = Ye(r, i, o);
|
|
499
|
+
break;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}), n;
|
|
503
|
+
}
|
|
504
|
+
function Wt(e) {
|
|
505
|
+
const t = e.option_config?.api_options?.params || {}, n = e.option_config?.api_options?.data || {}, r = (i) => Object.values(i).filter(
|
|
506
|
+
(s) => typeof s == "string" && s.startsWith("{{") && s.endsWith("}}")
|
|
507
|
+
).map((s) => s.slice(2, -2).trim());
|
|
508
|
+
return Array.from(/* @__PURE__ */ new Set([...r(t), ...r(n)]));
|
|
509
|
+
}
|
|
510
|
+
function oe(e, t) {
|
|
511
|
+
const n = {};
|
|
512
|
+
for (const r in e) {
|
|
513
|
+
const i = e[r];
|
|
514
|
+
if (typeof i == "string" && i.startsWith("{{") && i.endsWith("}}")) {
|
|
515
|
+
const s = i.slice(2, -2).trim();
|
|
516
|
+
n[r] = t?.[s];
|
|
517
|
+
} else
|
|
518
|
+
n[r] = i;
|
|
519
|
+
}
|
|
520
|
+
return n;
|
|
521
|
+
}
|
|
522
|
+
function he(e, t) {
|
|
523
|
+
return e.replace(/\{\{\s*(\w+)\s*\}\}/g, (n, r) => {
|
|
524
|
+
const i = t?.[r];
|
|
525
|
+
return i != null ? String(i) : "";
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
function $t(e, t, n) {
|
|
529
|
+
const i = t.find((s) => s.code === e)?.additional_config?.on_field_change?.clear ?? [];
|
|
530
|
+
return i.length === 0 ? [] : i.filter(
|
|
531
|
+
(s) => n?.[s] !== void 0 && n?.[s] !== null
|
|
532
|
+
);
|
|
533
|
+
}
|
|
534
|
+
const zt = (e) => ({
|
|
535
|
+
id: e.id,
|
|
536
|
+
code: e.code,
|
|
537
|
+
form_id: e.id,
|
|
538
|
+
method: "POST",
|
|
539
|
+
action: "",
|
|
540
|
+
config: {
|
|
541
|
+
body: ""
|
|
542
|
+
},
|
|
543
|
+
created_at: e.created_at ?? "",
|
|
544
|
+
updated_at: e.updated_at ?? "",
|
|
545
|
+
created_by: e.created_by,
|
|
546
|
+
deleted_at: e.deleted_at,
|
|
547
|
+
form: e
|
|
548
|
+
}), Ht = ({
|
|
549
|
+
group: e,
|
|
550
|
+
value: t,
|
|
551
|
+
onChange: n,
|
|
552
|
+
disabled: r = !1,
|
|
553
|
+
readOnly: i = !1,
|
|
554
|
+
registerNestedForm: s
|
|
555
|
+
}) => {
|
|
556
|
+
const o = U(), [a] = Q.useForm(), m = q(null), f = e.additional_config?.form?.config_url, y = e.additional_config?.form?.method ?? "GET", {
|
|
557
|
+
data: u,
|
|
558
|
+
isLoading: c,
|
|
559
|
+
error: d
|
|
560
|
+
} = we(
|
|
561
|
+
[f, y],
|
|
562
|
+
async () => {
|
|
563
|
+
if (!f)
|
|
564
|
+
throw new Error("Missing additional_config.form.config_url");
|
|
565
|
+
const h = await o.client.request({
|
|
566
|
+
method: y,
|
|
567
|
+
url: f
|
|
568
|
+
});
|
|
569
|
+
return o.parsers.formConfigResponse(h.data);
|
|
570
|
+
},
|
|
571
|
+
{ enabled: !!f }
|
|
572
|
+
), p = C(
|
|
573
|
+
() => u ? zt(u) : void 0,
|
|
574
|
+
[u]
|
|
575
|
+
);
|
|
576
|
+
return j(() => {
|
|
577
|
+
if (u)
|
|
578
|
+
return s?.(e.code, m, {
|
|
579
|
+
formCode: u.code,
|
|
580
|
+
fieldType: "form"
|
|
581
|
+
}), () => {
|
|
582
|
+
s?.(e.code, null);
|
|
583
|
+
};
|
|
584
|
+
}, [e.code, u, s]), j(() => {
|
|
585
|
+
if (!u) return;
|
|
586
|
+
const h = He(e, t, u.code);
|
|
587
|
+
a.setFieldsValue(
|
|
588
|
+
Xe(h, u.field_groups)
|
|
589
|
+
);
|
|
590
|
+
}, [e, a, u, t]), f ? c ? /* @__PURE__ */ l(N, { type: "info", message: "Loading...", showIcon: !0 }) : d || !p ? /* @__PURE__ */ l(N, { type: "error", message: "Failed to load nested form", showIcon: !0 }) : /* @__PURE__ */ l(
|
|
591
|
+
"div",
|
|
592
|
+
{
|
|
593
|
+
style: {
|
|
594
|
+
border: "1px solid rgba(5, 5, 5, 0.12)",
|
|
595
|
+
borderRadius: 8,
|
|
596
|
+
padding: 12,
|
|
597
|
+
background: "#fff"
|
|
598
|
+
},
|
|
599
|
+
children: /* @__PURE__ */ l(
|
|
600
|
+
xe,
|
|
601
|
+
{
|
|
602
|
+
ref: m,
|
|
603
|
+
formConfig: p,
|
|
604
|
+
formInstance: a,
|
|
605
|
+
manualSubmit: !0,
|
|
606
|
+
disableHtmlFormWrapper: !0,
|
|
607
|
+
readOnly: r || i,
|
|
608
|
+
onValuesChange: (h, _) => {
|
|
609
|
+
n?.(_ ?? {});
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
)
|
|
613
|
+
}
|
|
614
|
+
) : /* @__PURE__ */ l(N, { type: "warning", message: "Missing nested form config_url", showIcon: !0 });
|
|
615
|
+
};
|
|
616
|
+
function de(e) {
|
|
617
|
+
return JSON.stringify(e);
|
|
618
|
+
}
|
|
619
|
+
function Yt(e, t) {
|
|
620
|
+
const n = e.get(t);
|
|
621
|
+
if (n) {
|
|
622
|
+
if (Date.now() > n.expiresAt) {
|
|
623
|
+
e.delete(t);
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
return n.data;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
function Jt(e, t, n, r) {
|
|
630
|
+
e.set(t, { data: n, expiresAt: Date.now() + r });
|
|
631
|
+
}
|
|
632
|
+
async function ue(e, t, n, r, i) {
|
|
633
|
+
const s = e[t];
|
|
634
|
+
if (e.cache.enabled) {
|
|
635
|
+
const f = Yt(s, n);
|
|
636
|
+
if (f !== void 0) return f;
|
|
637
|
+
}
|
|
638
|
+
const o = new AbortController(), a = i ? AbortSignal.any([i, o.signal]) : o.signal, m = await r(a);
|
|
639
|
+
return e.cache.enabled && Jt(s, n, m, e.cache.ttlMs), m;
|
|
640
|
+
}
|
|
641
|
+
function Xt(e) {
|
|
642
|
+
const t = e?.field?.type?.code;
|
|
643
|
+
return t === "select" || t === "radio" || t === "checkbox";
|
|
644
|
+
}
|
|
645
|
+
async function Qt(e, t, n, r, i) {
|
|
646
|
+
if (W(n))
|
|
647
|
+
return i;
|
|
648
|
+
if (!Xt(t))
|
|
649
|
+
return String(n);
|
|
650
|
+
const s = Ee(n, t.metas);
|
|
651
|
+
if (s)
|
|
652
|
+
return s;
|
|
653
|
+
if (t.is_option_api && t.option_config?.url) {
|
|
654
|
+
const o = Ce(t, r), a = t.option_config.method?.toUpperCase() === "GET" || !t.option_config.method, f = { [t.option_config.value_attr || "value"]: n }, y = de([
|
|
655
|
+
"collapseTitle",
|
|
656
|
+
t.code,
|
|
657
|
+
t.option_config.url,
|
|
658
|
+
t.option_config.method,
|
|
659
|
+
o,
|
|
660
|
+
n
|
|
661
|
+
]);
|
|
662
|
+
try {
|
|
663
|
+
const u = await ue(
|
|
664
|
+
e,
|
|
665
|
+
"optionCache",
|
|
666
|
+
y,
|
|
667
|
+
async (d) => {
|
|
668
|
+
const p = await e.client.request({
|
|
669
|
+
method: t.option_config?.method || "GET",
|
|
670
|
+
url: t.option_config?.url,
|
|
671
|
+
params: a ? {
|
|
672
|
+
...o?.params,
|
|
673
|
+
filter: {
|
|
674
|
+
...o?.params?.filter,
|
|
675
|
+
...f
|
|
676
|
+
}
|
|
677
|
+
} : o?.params,
|
|
678
|
+
data: a ? o?.data : {
|
|
679
|
+
...o?.data,
|
|
680
|
+
filter: {
|
|
681
|
+
...o?.data?.filter,
|
|
682
|
+
...f
|
|
683
|
+
}
|
|
684
|
+
},
|
|
685
|
+
signal: d
|
|
686
|
+
});
|
|
687
|
+
return e.parsers.optionResponse(p.data, t);
|
|
688
|
+
}
|
|
689
|
+
), c = se(
|
|
690
|
+
n,
|
|
691
|
+
t,
|
|
692
|
+
u
|
|
693
|
+
);
|
|
694
|
+
if (c) return c;
|
|
695
|
+
} catch {
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
return se(n, t) ?? i;
|
|
699
|
+
}
|
|
700
|
+
function Zt(e, t, n, r, i) {
|
|
701
|
+
const s = U(), [o, a] = L({});
|
|
702
|
+
return j(() => {
|
|
703
|
+
if (!t || !e) {
|
|
704
|
+
a({});
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
let m = !1;
|
|
708
|
+
return (async () => {
|
|
709
|
+
const y = await Promise.all(
|
|
710
|
+
n.map(async (u, c) => {
|
|
711
|
+
const d = r[u.key] ?? {}, p = await Qt(
|
|
712
|
+
s,
|
|
713
|
+
e,
|
|
714
|
+
d[t],
|
|
715
|
+
d,
|
|
716
|
+
`${i} ${c + 1}`
|
|
717
|
+
);
|
|
718
|
+
return [u.key, p];
|
|
719
|
+
})
|
|
720
|
+
);
|
|
721
|
+
m || a(Object.fromEntries(y));
|
|
722
|
+
})(), () => {
|
|
723
|
+
m = !0;
|
|
724
|
+
};
|
|
725
|
+
}, [s, i, n, t, e, r]), o;
|
|
726
|
+
}
|
|
727
|
+
const Gt = (e) => ({
|
|
728
|
+
id: e.id,
|
|
729
|
+
code: e.code,
|
|
730
|
+
form_id: e.id,
|
|
731
|
+
method: "POST",
|
|
732
|
+
action: "",
|
|
733
|
+
config: {
|
|
734
|
+
body: ""
|
|
735
|
+
},
|
|
736
|
+
created_at: e.created_at ?? "",
|
|
737
|
+
updated_at: e.updated_at ?? "",
|
|
738
|
+
created_by: e.created_by,
|
|
739
|
+
deleted_at: e.deleted_at,
|
|
740
|
+
form: e
|
|
741
|
+
});
|
|
742
|
+
function en({
|
|
743
|
+
itemKey: e,
|
|
744
|
+
nestedFormConfig: t,
|
|
745
|
+
value: n,
|
|
746
|
+
disabled: r = !1,
|
|
747
|
+
readOnly: i = !1,
|
|
748
|
+
registerItemRef: s,
|
|
749
|
+
onValuesChange: o
|
|
750
|
+
}) {
|
|
751
|
+
const [a] = Q.useForm(), m = q(null);
|
|
752
|
+
return j(() => (s(e, m), () => {
|
|
753
|
+
s(e, null);
|
|
754
|
+
}), [e, s]), j(() => {
|
|
755
|
+
a.setFieldsValue(
|
|
756
|
+
Xe(n ?? {}, t.form.field_groups)
|
|
757
|
+
);
|
|
758
|
+
}, [a, t.form.field_groups, n]), /* @__PURE__ */ l(
|
|
759
|
+
xe,
|
|
760
|
+
{
|
|
761
|
+
ref: m,
|
|
762
|
+
formConfig: t,
|
|
763
|
+
formInstance: a,
|
|
764
|
+
manualSubmit: !0,
|
|
765
|
+
disableHtmlFormWrapper: !0,
|
|
766
|
+
readOnly: r || i,
|
|
767
|
+
onValuesChange: (f, y) => {
|
|
768
|
+
o(e, y ?? {});
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
);
|
|
772
|
+
}
|
|
773
|
+
const tn = ({
|
|
774
|
+
group: e,
|
|
775
|
+
value: t,
|
|
776
|
+
onChange: n,
|
|
777
|
+
disabled: r = !1,
|
|
778
|
+
readOnly: i = !1,
|
|
779
|
+
registerNestedForm: s
|
|
780
|
+
}) => {
|
|
781
|
+
const o = U(), a = e.additional_config?.multiple_form, m = a?.config_url, f = a?.method ?? "GET", y = a?.primary_field, u = q(0), [c, d] = L([{ key: u.current++ }]), [p, h] = L(
|
|
782
|
+
{}
|
|
783
|
+
), _ = q(p), A = q(c), [g, S] = L(
|
|
784
|
+
String(c[0]?.key ?? "")
|
|
785
|
+
), b = q(/* @__PURE__ */ new Map()), {
|
|
786
|
+
data: w,
|
|
787
|
+
isLoading: T,
|
|
788
|
+
error: F
|
|
789
|
+
} = we(
|
|
790
|
+
[m, f],
|
|
791
|
+
async () => {
|
|
792
|
+
if (!m)
|
|
793
|
+
throw new Error("Missing additional_config.multiple_form.config_url");
|
|
794
|
+
const v = await o.client.request({
|
|
795
|
+
method: f,
|
|
796
|
+
url: m
|
|
797
|
+
});
|
|
798
|
+
return o.parsers.formConfigResponse(v.data);
|
|
799
|
+
},
|
|
800
|
+
{ enabled: !!m }
|
|
801
|
+
);
|
|
802
|
+
j(() => {
|
|
803
|
+
_.current = p;
|
|
804
|
+
}, [p]), j(() => {
|
|
805
|
+
A.current = c;
|
|
806
|
+
}, [c]), j(() => {
|
|
807
|
+
if (t === void 0) return;
|
|
808
|
+
const v = w?.code ?? le(e), k = Ye(e, t, v);
|
|
809
|
+
d((E) => {
|
|
810
|
+
if (E.length === k.length && E.length > 0) {
|
|
811
|
+
const X = E.reduce(
|
|
812
|
+
(te, ie, me) => (te[ie.key] = k[me] ?? {}, te),
|
|
813
|
+
{}
|
|
814
|
+
);
|
|
815
|
+
return h(X), E;
|
|
816
|
+
}
|
|
817
|
+
const M = k.length > 0 ? k : [{}], I = M.map(() => ({ key: u.current++ })), re = I.reduce(
|
|
818
|
+
(X, te, ie) => (X[te.key] = M[ie] ?? {}, X),
|
|
819
|
+
{}
|
|
820
|
+
);
|
|
821
|
+
return h(re), S(String(I[0]?.key ?? "")), I;
|
|
822
|
+
});
|
|
823
|
+
}, [e, w?.code, t]);
|
|
824
|
+
const x = C(
|
|
825
|
+
() => w ? Gt(w) : void 0,
|
|
826
|
+
[w]
|
|
827
|
+
), z = C(
|
|
828
|
+
() => w?.field_groups.find((v) => v.code === y),
|
|
829
|
+
[w, y]
|
|
830
|
+
), H = Zt(
|
|
831
|
+
z,
|
|
832
|
+
y,
|
|
833
|
+
c,
|
|
834
|
+
p,
|
|
835
|
+
e.label
|
|
836
|
+
), B = D(
|
|
837
|
+
(v, k) => {
|
|
838
|
+
const E = v.map((M) => k[M.key] ?? {});
|
|
839
|
+
n?.(E);
|
|
840
|
+
},
|
|
841
|
+
[n]
|
|
842
|
+
), Y = D(
|
|
843
|
+
(v, k) => {
|
|
844
|
+
if (k) {
|
|
845
|
+
b.current.set(v, k);
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
b.current.delete(v);
|
|
849
|
+
},
|
|
850
|
+
[]
|
|
851
|
+
), ee = D(
|
|
852
|
+
(v, k) => {
|
|
853
|
+
h((E) => {
|
|
854
|
+
const M = { ...E, [v]: k };
|
|
855
|
+
return B(A.current, M), M;
|
|
856
|
+
});
|
|
857
|
+
},
|
|
858
|
+
[B]
|
|
859
|
+
), P = q({
|
|
860
|
+
submit: async () => {
|
|
861
|
+
},
|
|
862
|
+
isSubmitting: () => !1,
|
|
863
|
+
getProcessedValues: async () => ({})
|
|
864
|
+
});
|
|
865
|
+
j(() => {
|
|
866
|
+
P.current && (P.current.getProcessedValues = async () => await Promise.all(
|
|
867
|
+
A.current.map(async (k) => {
|
|
868
|
+
const E = b.current.get(k.key);
|
|
869
|
+
return E?.current ? E.current.getProcessedValues() : _.current[k.key] ?? {};
|
|
870
|
+
})
|
|
871
|
+
));
|
|
872
|
+
}, []), j(() => {
|
|
873
|
+
if (w)
|
|
874
|
+
return s?.(e.code, P, {
|
|
875
|
+
formCode: w.code,
|
|
876
|
+
fieldType: "multiple-form"
|
|
877
|
+
}), () => {
|
|
878
|
+
s?.(e.code, null);
|
|
879
|
+
};
|
|
880
|
+
}, [e.code, w, s]);
|
|
881
|
+
const G = D(() => {
|
|
882
|
+
const v = { key: u.current++ };
|
|
883
|
+
d((k) => {
|
|
884
|
+
const E = [...k, v];
|
|
885
|
+
return h((M) => {
|
|
886
|
+
const I = { ...M, [v.key]: {} };
|
|
887
|
+
return B(E, I), I;
|
|
888
|
+
}), E;
|
|
889
|
+
}), S(String(v.key));
|
|
890
|
+
}, [B]), K = D(
|
|
891
|
+
(v) => {
|
|
892
|
+
d((k) => {
|
|
893
|
+
const E = k.filter((M) => M.key !== v);
|
|
894
|
+
return h((M) => {
|
|
895
|
+
const I = { ...M };
|
|
896
|
+
return delete I[v], B(E, I), I;
|
|
897
|
+
}), S(String(E[0]?.key ?? "")), E;
|
|
898
|
+
});
|
|
899
|
+
},
|
|
900
|
+
[B]
|
|
901
|
+
), ne = C(() => c.map((v, k) => {
|
|
902
|
+
const E = p[v.key] ?? {}, M = H[v.key] ?? `${e.label} ${k + 1}`;
|
|
903
|
+
return {
|
|
904
|
+
key: String(v.key),
|
|
905
|
+
label: /* @__PURE__ */ ce("div", { style: { display: "flex", justifyContent: "space-between", width: "100%" }, children: [
|
|
906
|
+
/* @__PURE__ */ l("span", { children: M }),
|
|
907
|
+
!r && !i ? /* @__PURE__ */ l(
|
|
908
|
+
vt,
|
|
909
|
+
{
|
|
910
|
+
onClick: (I) => {
|
|
911
|
+
I.preventDefault(), I.stopPropagation(), K(v.key);
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
) : null
|
|
915
|
+
] }),
|
|
916
|
+
children: x ? /* @__PURE__ */ l(
|
|
917
|
+
en,
|
|
918
|
+
{
|
|
919
|
+
itemKey: v.key,
|
|
920
|
+
nestedFormConfig: x,
|
|
921
|
+
value: E,
|
|
922
|
+
disabled: r,
|
|
923
|
+
readOnly: i,
|
|
924
|
+
registerItemRef: Y,
|
|
925
|
+
onValuesChange: ee
|
|
926
|
+
}
|
|
927
|
+
) : null
|
|
928
|
+
};
|
|
929
|
+
}), [
|
|
930
|
+
r,
|
|
931
|
+
e.label,
|
|
932
|
+
K,
|
|
933
|
+
c,
|
|
934
|
+
x,
|
|
935
|
+
ee,
|
|
936
|
+
i,
|
|
937
|
+
Y,
|
|
938
|
+
H,
|
|
939
|
+
p
|
|
940
|
+
]);
|
|
941
|
+
return m ? y ? T ? /* @__PURE__ */ l(N, { type: "info", message: "Loading...", showIcon: !0 }) : F || !x ? /* @__PURE__ */ l(N, { type: "error", message: "Failed to load nested form", showIcon: !0 }) : /* @__PURE__ */ ce("div", { children: [
|
|
942
|
+
/* @__PURE__ */ l(
|
|
943
|
+
at,
|
|
944
|
+
{
|
|
945
|
+
accordion: !0,
|
|
946
|
+
activeKey: g,
|
|
947
|
+
onChange: (v) => S(Array.isArray(v) ? String(v[0] ?? "") : String(v)),
|
|
948
|
+
items: ne
|
|
949
|
+
}
|
|
950
|
+
),
|
|
951
|
+
!r && !i ? /* @__PURE__ */ l(
|
|
952
|
+
Ae,
|
|
953
|
+
{
|
|
954
|
+
style: { marginTop: 12 },
|
|
955
|
+
block: !0,
|
|
956
|
+
type: "dashed",
|
|
957
|
+
onClick: G,
|
|
958
|
+
icon: /* @__PURE__ */ l(At, {}),
|
|
959
|
+
children: "Add item"
|
|
960
|
+
}
|
|
961
|
+
) : null
|
|
962
|
+
] }) : /* @__PURE__ */ l(
|
|
963
|
+
N,
|
|
964
|
+
{
|
|
965
|
+
type: "warning",
|
|
966
|
+
message: "Missing multiple_form primary_field",
|
|
967
|
+
showIcon: !0
|
|
968
|
+
}
|
|
969
|
+
) : /* @__PURE__ */ l(
|
|
970
|
+
N,
|
|
971
|
+
{
|
|
972
|
+
type: "warning",
|
|
973
|
+
message: "Missing multiple_form config_url",
|
|
974
|
+
showIcon: !0
|
|
975
|
+
}
|
|
976
|
+
);
|
|
977
|
+
}, nn = ({
|
|
133
978
|
formInstance: e,
|
|
134
979
|
uploadUrl: t,
|
|
135
980
|
setFieldState: n
|
|
136
981
|
}) => {
|
|
137
|
-
const { client: r, upload: i, i18n:
|
|
982
|
+
const { client: r, upload: i, i18n: s, renderers: o } = U(), { messages: a } = s, m = D(() => {
|
|
138
983
|
if (i.upload) return i.upload;
|
|
139
|
-
const
|
|
140
|
-
if (
|
|
141
|
-
return async ({ file:
|
|
142
|
-
const
|
|
143
|
-
file:
|
|
984
|
+
const c = t ?? i.uploadUrl;
|
|
985
|
+
if (c)
|
|
986
|
+
return async ({ file: d, signal: p, onProgress: h, fieldCode: _, fieldGroup: A, metadata: g }) => {
|
|
987
|
+
const S = i.getPayload ? i.getPayload({
|
|
988
|
+
file: d,
|
|
144
989
|
fieldCode: _,
|
|
145
|
-
fieldGroup:
|
|
146
|
-
uploadUrl:
|
|
147
|
-
signal:
|
|
148
|
-
onProgress:
|
|
149
|
-
metadata:
|
|
990
|
+
fieldGroup: A,
|
|
991
|
+
uploadUrl: c,
|
|
992
|
+
signal: p,
|
|
993
|
+
onProgress: h,
|
|
994
|
+
metadata: g
|
|
150
995
|
}) : (() => {
|
|
151
|
-
const
|
|
152
|
-
return
|
|
153
|
-
|
|
154
|
-
}),
|
|
155
|
-
})(),
|
|
996
|
+
const T = new FormData();
|
|
997
|
+
return T.append("file", d), g && Object.entries(g).forEach(([F, x]) => {
|
|
998
|
+
T.append(F, String(x));
|
|
999
|
+
}), T;
|
|
1000
|
+
})(), w = (await r.request({
|
|
156
1001
|
method: "POST",
|
|
157
|
-
url:
|
|
158
|
-
data:
|
|
159
|
-
headers:
|
|
160
|
-
signal:
|
|
161
|
-
onUploadProgress: (
|
|
162
|
-
|
|
163
|
-
Math.round(
|
|
1002
|
+
url: c,
|
|
1003
|
+
data: S,
|
|
1004
|
+
headers: S instanceof FormData ? { "Content-Type": "multipart/form-data" } : void 0,
|
|
1005
|
+
signal: p,
|
|
1006
|
+
onUploadProgress: (T) => {
|
|
1007
|
+
h?.(
|
|
1008
|
+
Math.round(T.loaded * 100 / (T.total || 1))
|
|
164
1009
|
);
|
|
165
1010
|
}
|
|
166
1011
|
})).data;
|
|
167
1012
|
return {
|
|
168
|
-
uid:
|
|
169
|
-
...
|
|
170
|
-
path: String(
|
|
1013
|
+
uid: d.uid,
|
|
1014
|
+
...w,
|
|
1015
|
+
path: String(w.path ?? "")
|
|
171
1016
|
};
|
|
172
1017
|
};
|
|
173
|
-
}, [r, i, t]),
|
|
174
|
-
(
|
|
175
|
-
const { file:
|
|
176
|
-
return
|
|
177
|
-
file:
|
|
178
|
-
fieldCode:
|
|
179
|
-
fieldGroup:
|
|
1018
|
+
}, [r, i, t]), f = D(
|
|
1019
|
+
(c, d) => (p) => {
|
|
1020
|
+
const { file: h, onProgress: _, onError: A, onSuccess: g } = p, S = new AbortController(), b = m();
|
|
1021
|
+
return b ? (b({
|
|
1022
|
+
file: h,
|
|
1023
|
+
fieldCode: c,
|
|
1024
|
+
fieldGroup: d,
|
|
180
1025
|
uploadUrl: t ?? i.uploadUrl,
|
|
181
|
-
signal:
|
|
182
|
-
onProgress: (
|
|
1026
|
+
signal: S.signal,
|
|
1027
|
+
onProgress: (w) => _?.({ percent: w })
|
|
183
1028
|
}).then(
|
|
184
|
-
(
|
|
185
|
-
...
|
|
186
|
-
uid:
|
|
187
|
-
path:
|
|
188
|
-
upload_date:
|
|
1029
|
+
(w) => g?.({
|
|
1030
|
+
...w,
|
|
1031
|
+
uid: w.uid ?? h.uid,
|
|
1032
|
+
path: w.path,
|
|
1033
|
+
upload_date: ge().format("YYYY-MM-DD HH:mm:ss")
|
|
189
1034
|
})
|
|
190
|
-
).catch((
|
|
1035
|
+
).catch((w) => A?.(w)), { abort: () => S.abort() }) : (A?.(new Error(a.uploadError ?? "Upload not configured")), { abort() {
|
|
191
1036
|
} });
|
|
192
1037
|
},
|
|
193
|
-
[
|
|
194
|
-
), y =
|
|
195
|
-
(
|
|
196
|
-
const
|
|
197
|
-
return
|
|
1038
|
+
[a.uploadError, m, i.uploadUrl, t]
|
|
1039
|
+
), y = D(
|
|
1040
|
+
(c, d) => async (p) => {
|
|
1041
|
+
const h = p.response?.path;
|
|
1042
|
+
return h ? i.remove({ path: h, fieldCode: c, fieldGroup: d }) : !0;
|
|
198
1043
|
},
|
|
199
1044
|
[i]
|
|
200
|
-
),
|
|
201
|
-
(
|
|
202
|
-
state:
|
|
203
|
-
options:
|
|
204
|
-
optionsLoading:
|
|
1045
|
+
), u = D(
|
|
1046
|
+
(c, {
|
|
1047
|
+
state: d,
|
|
1048
|
+
options: p,
|
|
1049
|
+
optionsLoading: h,
|
|
205
1050
|
optionsError: _,
|
|
206
|
-
onSearchKeyword:
|
|
207
|
-
readOnly:
|
|
1051
|
+
onSearchKeyword: A,
|
|
1052
|
+
readOnly: g = !1,
|
|
1053
|
+
registerNestedForm: S
|
|
208
1054
|
}) => {
|
|
209
|
-
const { additional_config:
|
|
210
|
-
|
|
1055
|
+
const { additional_config: b, field: w } = c, T = w?.type?.code, F = g || c.is_readonly || d?.disabled, x = kt(
|
|
1056
|
+
c,
|
|
211
1057
|
o.fields
|
|
212
1058
|
);
|
|
213
|
-
if (
|
|
214
|
-
return
|
|
215
|
-
state:
|
|
216
|
-
options:
|
|
217
|
-
optionsLoading:
|
|
1059
|
+
if (x)
|
|
1060
|
+
return x(c, {
|
|
1061
|
+
state: d,
|
|
1062
|
+
options: p,
|
|
1063
|
+
optionsLoading: h,
|
|
218
1064
|
optionsError: _,
|
|
219
|
-
onSearchKeyword:
|
|
220
|
-
readOnly:
|
|
1065
|
+
onSearchKeyword: A,
|
|
1066
|
+
readOnly: g,
|
|
221
1067
|
formInstance: e,
|
|
222
|
-
disabled: !!
|
|
1068
|
+
disabled: !!F,
|
|
223
1069
|
setFieldState: n
|
|
224
1070
|
});
|
|
225
|
-
const
|
|
226
|
-
switch (
|
|
1071
|
+
const z = Ct(p, c);
|
|
1072
|
+
switch (T) {
|
|
227
1073
|
case "text":
|
|
228
|
-
return
|
|
229
|
-
|
|
1074
|
+
return b?.text?.textarea ? /* @__PURE__ */ l(
|
|
1075
|
+
Le.TextArea,
|
|
230
1076
|
{
|
|
231
|
-
disabled:
|
|
232
|
-
placeholder:
|
|
233
|
-
rows:
|
|
1077
|
+
disabled: F,
|
|
1078
|
+
placeholder: a.inputPlaceholder(c.label),
|
|
1079
|
+
rows: b?.text?.rows
|
|
234
1080
|
}
|
|
235
|
-
) : /* @__PURE__ */
|
|
236
|
-
|
|
1081
|
+
) : /* @__PURE__ */ l(
|
|
1082
|
+
Le,
|
|
237
1083
|
{
|
|
238
|
-
disabled:
|
|
239
|
-
placeholder:
|
|
1084
|
+
disabled: F,
|
|
1085
|
+
placeholder: a.inputPlaceholder(c.label)
|
|
240
1086
|
}
|
|
241
1087
|
);
|
|
242
1088
|
case "number":
|
|
243
|
-
return /* @__PURE__ */
|
|
244
|
-
|
|
1089
|
+
return /* @__PURE__ */ l(
|
|
1090
|
+
ut,
|
|
245
1091
|
{
|
|
246
1092
|
style: { width: "100%" },
|
|
247
|
-
disabled:
|
|
248
|
-
placeholder:
|
|
249
|
-
min:
|
|
250
|
-
max:
|
|
1093
|
+
disabled: F,
|
|
1094
|
+
placeholder: a.inputPlaceholder(c.label),
|
|
1095
|
+
min: b?.number?.min,
|
|
1096
|
+
max: b?.number?.max
|
|
251
1097
|
}
|
|
252
1098
|
);
|
|
253
1099
|
case "select": {
|
|
254
|
-
const
|
|
255
|
-
disabled:
|
|
256
|
-
options:
|
|
257
|
-
placeholder:
|
|
1100
|
+
const H = {
|
|
1101
|
+
disabled: F,
|
|
1102
|
+
options: z,
|
|
1103
|
+
placeholder: a.selectPlaceholder(c.label),
|
|
258
1104
|
allowClear: !0,
|
|
259
|
-
loading:
|
|
260
|
-
mode:
|
|
261
|
-
notFoundContent: _ ?
|
|
1105
|
+
loading: h,
|
|
1106
|
+
mode: b?.select?.multiple ? "multiple" : void 0,
|
|
1107
|
+
notFoundContent: _ ? a.optionError : h ? a.optionLoading : void 0
|
|
262
1108
|
};
|
|
263
|
-
return
|
|
264
|
-
|
|
1109
|
+
return A ? /* @__PURE__ */ l(
|
|
1110
|
+
xt,
|
|
265
1111
|
{
|
|
266
|
-
...
|
|
267
|
-
onSearchKeyword:
|
|
268
|
-
searchDebounceMs:
|
|
1112
|
+
...H,
|
|
1113
|
+
onSearchKeyword: A,
|
|
1114
|
+
searchDebounceMs: b?.select?.searchDebounceMs ?? 500
|
|
269
1115
|
}
|
|
270
|
-
) : /* @__PURE__ */
|
|
1116
|
+
) : /* @__PURE__ */ l(Ie, { ...H, showSearch: !0, optionFilterProp: "label" });
|
|
271
1117
|
}
|
|
272
1118
|
case "radio":
|
|
273
|
-
return /* @__PURE__ */
|
|
1119
|
+
return /* @__PURE__ */ l(dt.Group, { disabled: F, options: z });
|
|
274
1120
|
case "checkbox":
|
|
275
|
-
return /* @__PURE__ */
|
|
1121
|
+
return /* @__PURE__ */ l(lt.Group, { disabled: F, options: z });
|
|
276
1122
|
case "datetime":
|
|
277
|
-
return /* @__PURE__ */
|
|
278
|
-
|
|
1123
|
+
return /* @__PURE__ */ l(
|
|
1124
|
+
ct,
|
|
279
1125
|
{
|
|
280
1126
|
style: { width: "100%" },
|
|
281
|
-
disabled:
|
|
282
|
-
showTime:
|
|
283
|
-
format:
|
|
1127
|
+
disabled: F,
|
|
1128
|
+
showTime: b?.datetime?.showTime,
|
|
1129
|
+
format: b?.datetime?.format
|
|
284
1130
|
}
|
|
285
1131
|
);
|
|
286
1132
|
case "file":
|
|
287
|
-
return /* @__PURE__ */
|
|
288
|
-
|
|
1133
|
+
return /* @__PURE__ */ l(
|
|
1134
|
+
Lt,
|
|
289
1135
|
{
|
|
290
|
-
disabled:
|
|
291
|
-
fieldName:
|
|
1136
|
+
disabled: F,
|
|
1137
|
+
fieldName: c.code,
|
|
292
1138
|
formInstance: e,
|
|
293
|
-
multiple:
|
|
294
|
-
maxCount:
|
|
295
|
-
accept:
|
|
296
|
-
customRequest: c
|
|
297
|
-
onRemove: y(
|
|
1139
|
+
multiple: b?.file?.multiple || !1,
|
|
1140
|
+
maxCount: b?.file?.max,
|
|
1141
|
+
accept: b?.file?.accept,
|
|
1142
|
+
customRequest: f(c.code, c),
|
|
1143
|
+
onRemove: y(c.code, c)
|
|
298
1144
|
}
|
|
299
1145
|
);
|
|
300
1146
|
case "image":
|
|
301
|
-
return /* @__PURE__ */
|
|
302
|
-
|
|
1147
|
+
return /* @__PURE__ */ l(
|
|
1148
|
+
Mt,
|
|
303
1149
|
{
|
|
304
|
-
disabled:
|
|
305
|
-
fieldName:
|
|
1150
|
+
disabled: F,
|
|
1151
|
+
fieldName: c.code,
|
|
306
1152
|
formInstance: e,
|
|
307
|
-
multiple:
|
|
308
|
-
maxCount:
|
|
309
|
-
accept:
|
|
310
|
-
customRequest: c
|
|
311
|
-
onRemove: y(
|
|
1153
|
+
multiple: b?.image?.multiple || !1,
|
|
1154
|
+
maxCount: b?.image?.max,
|
|
1155
|
+
accept: b?.image?.accept ?? "image/*",
|
|
1156
|
+
customRequest: f(c.code, c),
|
|
1157
|
+
onRemove: y(c.code, c)
|
|
1158
|
+
}
|
|
1159
|
+
);
|
|
1160
|
+
case "form":
|
|
1161
|
+
return /* @__PURE__ */ l(
|
|
1162
|
+
Ht,
|
|
1163
|
+
{
|
|
1164
|
+
group: c,
|
|
1165
|
+
disabled: !!F,
|
|
1166
|
+
readOnly: g,
|
|
1167
|
+
registerNestedForm: S
|
|
1168
|
+
}
|
|
1169
|
+
);
|
|
1170
|
+
case "multiple-form":
|
|
1171
|
+
return /* @__PURE__ */ l(
|
|
1172
|
+
tn,
|
|
1173
|
+
{
|
|
1174
|
+
group: c,
|
|
1175
|
+
disabled: !!F,
|
|
1176
|
+
readOnly: g,
|
|
1177
|
+
registerNestedForm: S
|
|
312
1178
|
}
|
|
313
1179
|
);
|
|
314
1180
|
default:
|
|
@@ -316,331 +1182,225 @@ const at = ({
|
|
|
316
1182
|
}
|
|
317
1183
|
},
|
|
318
1184
|
[
|
|
319
|
-
|
|
1185
|
+
f,
|
|
320
1186
|
y,
|
|
321
1187
|
e,
|
|
322
|
-
|
|
1188
|
+
a,
|
|
323
1189
|
o.fields,
|
|
324
1190
|
n
|
|
325
1191
|
]
|
|
326
1192
|
);
|
|
327
|
-
return
|
|
1193
|
+
return C(() => ({ getDynamicField: u }), [u]);
|
|
328
1194
|
};
|
|
329
|
-
function te(e) {
|
|
330
|
-
return JSON.stringify(e);
|
|
331
|
-
}
|
|
332
|
-
function ft(e, t) {
|
|
333
|
-
const n = e.get(t);
|
|
334
|
-
if (n) {
|
|
335
|
-
if (Date.now() > n.expiresAt) {
|
|
336
|
-
e.delete(t);
|
|
337
|
-
return;
|
|
338
|
-
}
|
|
339
|
-
return n.data;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
function mt(e, t, n, r) {
|
|
343
|
-
e.set(t, { data: n, expiresAt: Date.now() + r });
|
|
344
|
-
}
|
|
345
|
-
async function ne(e, t, n, r, i) {
|
|
346
|
-
const a = e[t];
|
|
347
|
-
if (e.cache.enabled) {
|
|
348
|
-
const c = ft(a, n);
|
|
349
|
-
if (c !== void 0) return c;
|
|
350
|
-
}
|
|
351
|
-
const o = new AbortController(), s = i ? AbortSignal.any([i, o.signal]) : o.signal, d = await r(s);
|
|
352
|
-
return e.cache.enabled && mt(a, n, d, e.cache.ttlMs), d;
|
|
353
|
-
}
|
|
354
|
-
function z(e, t) {
|
|
355
|
-
return t.split(".").reduce((n, r) => {
|
|
356
|
-
if (n && typeof n == "object")
|
|
357
|
-
return n[r];
|
|
358
|
-
}, e);
|
|
359
|
-
}
|
|
360
|
-
function pt(e, t) {
|
|
361
|
-
if (typeof e != "string") return e;
|
|
362
|
-
const n = e.match(/^\{\{(.+?)\}\}$/);
|
|
363
|
-
if (!n) return e;
|
|
364
|
-
const r = n[1].trim(), i = z(t, r);
|
|
365
|
-
return i !== void 0 ? i : e;
|
|
366
|
-
}
|
|
367
|
-
function ht(e, t) {
|
|
368
|
-
const n = {};
|
|
369
|
-
for (const r in e)
|
|
370
|
-
n[r] = pt(
|
|
371
|
-
e[r],
|
|
372
|
-
t
|
|
373
|
-
);
|
|
374
|
-
return n;
|
|
375
|
-
}
|
|
376
1195
|
function rn(e, t) {
|
|
377
|
-
const n =
|
|
378
|
-
|
|
379
|
-
const i = e[r.code];
|
|
380
|
-
if (i == null) return;
|
|
381
|
-
switch (r.field?.type?.code) {
|
|
382
|
-
case "datetime": {
|
|
383
|
-
const o = ae(i);
|
|
384
|
-
o.isValid() && (n[r.code] = o);
|
|
385
|
-
break;
|
|
386
|
-
}
|
|
387
|
-
case "file":
|
|
388
|
-
case "image": {
|
|
389
|
-
if (Array.isArray(i) && i.length > 0) {
|
|
390
|
-
const o = i.map((s, d) => {
|
|
391
|
-
const c = s;
|
|
392
|
-
return {
|
|
393
|
-
uid: String(c.uid ?? c.path ?? d),
|
|
394
|
-
name: c.name ?? `file-${d}`,
|
|
395
|
-
status: "done",
|
|
396
|
-
percent: 100,
|
|
397
|
-
type: c.type,
|
|
398
|
-
size: c.size,
|
|
399
|
-
response: s
|
|
400
|
-
};
|
|
401
|
-
});
|
|
402
|
-
n[r.code] = { fileList: o };
|
|
403
|
-
}
|
|
404
|
-
break;
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
}), n;
|
|
408
|
-
}
|
|
409
|
-
function yt(e) {
|
|
410
|
-
const t = e.option_config?.api_options?.params || {}, n = e.option_config?.api_options?.data || {}, r = (i) => Object.values(i).filter(
|
|
411
|
-
(a) => typeof a == "string" && a.startsWith("{{") && a.endsWith("}}")
|
|
412
|
-
).map((a) => a.slice(2, -2).trim());
|
|
413
|
-
return Array.from(/* @__PURE__ */ new Set([...r(t), ...r(n)]));
|
|
414
|
-
}
|
|
415
|
-
function I(e, t) {
|
|
416
|
-
const n = {};
|
|
417
|
-
for (const r in e) {
|
|
418
|
-
const i = e[r];
|
|
419
|
-
if (typeof i == "string" && i.startsWith("{{") && i.endsWith("}}")) {
|
|
420
|
-
const a = i.slice(2, -2).trim();
|
|
421
|
-
n[r] = t?.[a];
|
|
422
|
-
} else
|
|
423
|
-
n[r] = i;
|
|
424
|
-
}
|
|
425
|
-
return n;
|
|
426
|
-
}
|
|
427
|
-
function re(e, t) {
|
|
428
|
-
return e.replace(/\{\{\s*(\w+)\s*\}\}/g, (n, r) => {
|
|
429
|
-
const i = t?.[r];
|
|
430
|
-
return i != null ? String(i) : "";
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
function _t(e, t, n) {
|
|
434
|
-
const i = t.find((a) => a.code === e)?.additional_config?.on_field_change?.clear ?? [];
|
|
435
|
-
return i.length === 0 ? [] : i.filter(
|
|
436
|
-
(a) => n?.[a] !== void 0 && n?.[a] !== null
|
|
437
|
-
);
|
|
438
|
-
}
|
|
439
|
-
function bt(e, t) {
|
|
440
|
-
const n = P(
|
|
441
|
-
() => yt(e),
|
|
1196
|
+
const n = C(
|
|
1197
|
+
() => Wt(e),
|
|
442
1198
|
[e]
|
|
443
|
-
), r =
|
|
1199
|
+
), r = Q.useWatch(
|
|
444
1200
|
n.length > 0 ? n : void 0,
|
|
445
1201
|
t
|
|
446
1202
|
);
|
|
447
|
-
return
|
|
1203
|
+
return C(() => {
|
|
448
1204
|
if (!n.length) return {};
|
|
449
1205
|
const i = {};
|
|
450
|
-
return n.forEach((
|
|
451
|
-
Array.isArray(r) ? i[
|
|
1206
|
+
return n.forEach((s, o) => {
|
|
1207
|
+
Array.isArray(r) ? i[s] = r[o] : i[s] = r;
|
|
452
1208
|
}), i;
|
|
453
1209
|
}, [n, r]);
|
|
454
1210
|
}
|
|
455
|
-
function
|
|
1211
|
+
function on({
|
|
456
1212
|
group: e,
|
|
457
1213
|
formInstance: t,
|
|
458
1214
|
searchKeyword: n = "",
|
|
459
1215
|
searchDebounceMs: r = 500
|
|
460
1216
|
}) {
|
|
461
|
-
const i =
|
|
462
|
-
() =>
|
|
1217
|
+
const i = U(), s = rn(e, t), o = Q.useWatch(e.code, t), [a, m] = L(), [f, y] = L(!1), [u, c] = L(), d = q(null), [p, h] = L(n), _ = e.additional_config?.select?.search_keyword ?? !1, A = C(
|
|
1218
|
+
() => Fe((b) => h(b), r),
|
|
463
1219
|
[r]
|
|
464
1220
|
);
|
|
465
|
-
|
|
466
|
-
_ ?
|
|
467
|
-
}, [n, _,
|
|
468
|
-
const
|
|
469
|
-
const
|
|
470
|
-
if (!(!
|
|
1221
|
+
j(() => {
|
|
1222
|
+
_ ? A(n) : h("");
|
|
1223
|
+
}, [n, _, A]);
|
|
1224
|
+
const g = C(() => {
|
|
1225
|
+
const b = e.option_config?.api_options?.params, w = e.option_config?.api_options?.data;
|
|
1226
|
+
if (!(!b && !w))
|
|
471
1227
|
return {
|
|
472
|
-
params:
|
|
473
|
-
data:
|
|
1228
|
+
params: b ? oe(b, s) : void 0,
|
|
1229
|
+
data: w ? oe(w, s) : void 0
|
|
474
1230
|
};
|
|
475
|
-
}, [
|
|
1231
|
+
}, [s, e]), S = D(async () => {
|
|
476
1232
|
if (!e.option_config || !e.is_option_api || !e.option_config.url)
|
|
477
1233
|
return;
|
|
478
|
-
|
|
479
|
-
const
|
|
480
|
-
|
|
481
|
-
const
|
|
1234
|
+
d.current?.abort();
|
|
1235
|
+
const b = new AbortController();
|
|
1236
|
+
d.current = b;
|
|
1237
|
+
const w = e.option_config.method?.toUpperCase() === "GET" || !e.option_config.method, T = _ ? p : "", F = de([
|
|
482
1238
|
e.code,
|
|
483
1239
|
e.option_config.url,
|
|
484
1240
|
e.option_config.method,
|
|
485
|
-
|
|
486
|
-
|
|
1241
|
+
g,
|
|
1242
|
+
T
|
|
487
1243
|
]);
|
|
488
|
-
y(!0),
|
|
1244
|
+
y(!0), c(void 0);
|
|
489
1245
|
try {
|
|
490
|
-
const
|
|
1246
|
+
const x = await ue(
|
|
491
1247
|
i,
|
|
492
1248
|
"optionCache",
|
|
493
|
-
|
|
494
|
-
async (
|
|
495
|
-
const
|
|
1249
|
+
F,
|
|
1250
|
+
async (P) => {
|
|
1251
|
+
const G = await i.client.request({
|
|
496
1252
|
method: e.option_config?.method || "GET",
|
|
497
1253
|
url: e.option_config?.url,
|
|
498
|
-
params:
|
|
499
|
-
data: !
|
|
500
|
-
signal:
|
|
1254
|
+
params: w && _ ? { ...g?.params, keywords: T } : g?.params,
|
|
1255
|
+
data: !w && _ ? { ...g?.data, keywords: T } : g?.data,
|
|
1256
|
+
signal: P
|
|
501
1257
|
});
|
|
502
|
-
return i.parsers.optionResponse(
|
|
1258
|
+
return i.parsers.optionResponse(G.data, e);
|
|
503
1259
|
},
|
|
504
|
-
|
|
505
|
-
),
|
|
506
|
-
|
|
507
|
-
),
|
|
508
|
-
let
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
const
|
|
1260
|
+
b.signal
|
|
1261
|
+
), z = Array.isArray(o) ? o : o == null ? [] : [o], H = new Set(
|
|
1262
|
+
x.map((P) => String(Ke(P, e)))
|
|
1263
|
+
), B = z.filter((P) => P == null || P === "" ? !1 : !H.has(String(P)));
|
|
1264
|
+
let Y = [];
|
|
1265
|
+
B.length > 0 && (Y = (await Promise.all(
|
|
1266
|
+
B.map(async (P) => {
|
|
1267
|
+
const G = de([
|
|
512
1268
|
e.code,
|
|
513
1269
|
e.option_config?.url,
|
|
514
1270
|
e.option_config?.method,
|
|
515
|
-
|
|
1271
|
+
g,
|
|
516
1272
|
"selected",
|
|
517
|
-
|
|
1273
|
+
P
|
|
518
1274
|
]);
|
|
519
|
-
return
|
|
1275
|
+
return ue(
|
|
520
1276
|
i,
|
|
521
1277
|
"optionCache",
|
|
522
|
-
|
|
523
|
-
async (
|
|
524
|
-
const
|
|
1278
|
+
G,
|
|
1279
|
+
async (K) => {
|
|
1280
|
+
const v = { [e.option_config?.value_attr || "value"]: P }, k = await i.client.request({
|
|
525
1281
|
method: e.option_config?.method || "GET",
|
|
526
1282
|
url: e.option_config?.url,
|
|
527
|
-
params:
|
|
528
|
-
...
|
|
1283
|
+
params: w ? {
|
|
1284
|
+
...g?.params,
|
|
529
1285
|
filter: {
|
|
530
|
-
...
|
|
531
|
-
...
|
|
1286
|
+
...g?.params?.filter,
|
|
1287
|
+
...v
|
|
532
1288
|
}
|
|
533
|
-
} :
|
|
534
|
-
data:
|
|
535
|
-
...
|
|
1289
|
+
} : g?.params,
|
|
1290
|
+
data: w ? g?.data : {
|
|
1291
|
+
...g?.data,
|
|
536
1292
|
filter: {
|
|
537
|
-
...
|
|
538
|
-
...
|
|
1293
|
+
...g?.data?.filter,
|
|
1294
|
+
...v
|
|
539
1295
|
}
|
|
540
1296
|
},
|
|
541
|
-
signal:
|
|
1297
|
+
signal: K
|
|
542
1298
|
});
|
|
543
|
-
return i.parsers.optionResponse(
|
|
1299
|
+
return i.parsers.optionResponse(k.data, e);
|
|
544
1300
|
},
|
|
545
|
-
|
|
1301
|
+
b.signal
|
|
546
1302
|
);
|
|
547
1303
|
})
|
|
548
1304
|
)).flat());
|
|
549
|
-
const
|
|
550
|
-
[...
|
|
1305
|
+
const ee = Et(
|
|
1306
|
+
[...x, ...Y],
|
|
551
1307
|
e
|
|
552
1308
|
);
|
|
553
|
-
|
|
554
|
-
} catch (
|
|
555
|
-
|
|
1309
|
+
b.signal.aborted || m(ee);
|
|
1310
|
+
} catch (x) {
|
|
1311
|
+
b.signal.aborted || c(x);
|
|
556
1312
|
} finally {
|
|
557
|
-
|
|
1313
|
+
b.signal.aborted || y(!1);
|
|
558
1314
|
}
|
|
559
1315
|
}, [
|
|
560
|
-
|
|
1316
|
+
g,
|
|
561
1317
|
i,
|
|
562
|
-
|
|
1318
|
+
p,
|
|
563
1319
|
e,
|
|
564
1320
|
_,
|
|
565
1321
|
o
|
|
566
1322
|
]);
|
|
567
|
-
return
|
|
1323
|
+
return j(() => (e.option_config && e.is_option_api && S(), () => d.current?.abort()), [S, e]), { options: a, isLoading: f, error: u, refetch: S };
|
|
568
1324
|
}
|
|
569
|
-
const
|
|
1325
|
+
const sn = ({
|
|
570
1326
|
group: e,
|
|
571
1327
|
formInstance: t,
|
|
572
1328
|
fieldState: n,
|
|
573
1329
|
setFieldState: r,
|
|
574
1330
|
uploadUrl: i,
|
|
575
|
-
readOnly:
|
|
1331
|
+
readOnly: s = !1,
|
|
576
1332
|
size: o = "middle",
|
|
577
|
-
|
|
1333
|
+
registerNestedForm: a,
|
|
1334
|
+
...m
|
|
578
1335
|
}) => {
|
|
579
|
-
const { getDynamicField:
|
|
1336
|
+
const { getDynamicField: f } = nn({
|
|
580
1337
|
formInstance: t,
|
|
581
1338
|
uploadUrl: i,
|
|
582
1339
|
setFieldState: r
|
|
583
|
-
}),
|
|
1340
|
+
}), y = Q.useWatch(e.code, t), [u, c] = L(""), d = e.additional_config?.select?.search_keyword ?? !1, { options: p, isLoading: h, error: _ } = on({
|
|
584
1341
|
group: e,
|
|
585
1342
|
formInstance: t,
|
|
586
|
-
searchKeyword:
|
|
1343
|
+
searchKeyword: u,
|
|
587
1344
|
searchDebounceMs: e.additional_config?.select?.searchDebounceMs ?? 500
|
|
588
|
-
}),
|
|
589
|
-
|
|
1345
|
+
}), A = D((S) => {
|
|
1346
|
+
c(S);
|
|
590
1347
|
}, []);
|
|
591
|
-
|
|
592
|
-
e.additional_config?.on_field_empty?.disable?.length && e.additional_config.on_field_empty.disable.forEach((
|
|
593
|
-
r(
|
|
1348
|
+
j(() => {
|
|
1349
|
+
e.additional_config?.on_field_empty?.disable?.length && e.additional_config.on_field_empty.disable.forEach((S) => {
|
|
1350
|
+
r(S, { disabled: !y });
|
|
594
1351
|
});
|
|
595
|
-
}, [
|
|
596
|
-
const
|
|
597
|
-
return /* @__PURE__ */
|
|
598
|
-
|
|
1352
|
+
}, [y, t, e, r]);
|
|
1353
|
+
const g = o === "small" ? 4 : 12;
|
|
1354
|
+
return /* @__PURE__ */ l(
|
|
1355
|
+
Q.Item,
|
|
599
1356
|
{
|
|
600
1357
|
label: e.label,
|
|
601
1358
|
name: e.code,
|
|
602
1359
|
hidden: n?.hidden,
|
|
603
1360
|
rules: [{ required: n?.required || !1 }],
|
|
604
|
-
style: { marginBottom:
|
|
605
|
-
...
|
|
606
|
-
children:
|
|
1361
|
+
style: { marginBottom: g, ...m.style },
|
|
1362
|
+
...m,
|
|
1363
|
+
children: f(e, {
|
|
607
1364
|
state: n,
|
|
608
1365
|
options: p,
|
|
609
1366
|
optionsLoading: h,
|
|
610
|
-
optionsError:
|
|
611
|
-
onSearchKeyword:
|
|
612
|
-
readOnly:
|
|
1367
|
+
optionsError: _,
|
|
1368
|
+
onSearchKeyword: d ? A : void 0,
|
|
1369
|
+
readOnly: s,
|
|
1370
|
+
registerNestedForm: a
|
|
613
1371
|
})
|
|
614
1372
|
}
|
|
615
1373
|
);
|
|
616
1374
|
};
|
|
617
|
-
function
|
|
618
|
-
return e.group.id === t.group.id && e.readOnly === t.readOnly && e.uploadUrl === t.uploadUrl && e.size === t.size && e.fieldState?.disabled === t.fieldState?.disabled && e.fieldState?.hidden === t.fieldState?.hidden && e.fieldState?.required === t.fieldState?.required;
|
|
1375
|
+
function an(e, t) {
|
|
1376
|
+
return e.group.id === t.group.id && e.readOnly === t.readOnly && e.uploadUrl === t.uploadUrl && e.size === t.size && e.registerNestedForm === t.registerNestedForm && e.fieldState?.disabled === t.fieldState?.disabled && e.fieldState?.hidden === t.fieldState?.hidden && e.fieldState?.required === t.fieldState?.required;
|
|
619
1377
|
}
|
|
620
|
-
const
|
|
621
|
-
function
|
|
1378
|
+
const cn = Z(sn, an);
|
|
1379
|
+
function ln({
|
|
622
1380
|
fieldGroups: e,
|
|
623
1381
|
fieldStates: t,
|
|
624
1382
|
renderField: n,
|
|
625
1383
|
gutter: r,
|
|
626
1384
|
defaultColSpan: i
|
|
627
1385
|
}) {
|
|
628
|
-
return /* @__PURE__ */
|
|
629
|
-
const o = t[
|
|
630
|
-
return /* @__PURE__ */
|
|
1386
|
+
return /* @__PURE__ */ l(ft, { gutter: r, children: e.map((s) => {
|
|
1387
|
+
const o = t[s.code]?.hidden ? 0 : Number(s.additional_config?.field_col_span) || i;
|
|
1388
|
+
return /* @__PURE__ */ l(mt, { xs: o, children: n(s) }, s.id);
|
|
631
1389
|
}) });
|
|
632
1390
|
}
|
|
633
|
-
function
|
|
634
|
-
return
|
|
1391
|
+
function dn(e) {
|
|
1392
|
+
return C(() => {
|
|
635
1393
|
const t = e?.form?.field_groups ?? [], n = /* @__PURE__ */ new Map(), r = {};
|
|
636
|
-
t.forEach((
|
|
637
|
-
n.set(
|
|
1394
|
+
t.forEach((s) => {
|
|
1395
|
+
n.set(s.code, s);
|
|
1396
|
+
const o = s.field?.type?.code;
|
|
1397
|
+
s.additional_config?.default !== void 0 && o !== "form" && o !== "multiple-form" && (r[s.code] = s.additional_config.default);
|
|
638
1398
|
});
|
|
639
|
-
const i = t.filter((
|
|
1399
|
+
const i = t.filter((s) => !s.is_hidden);
|
|
640
1400
|
return { fieldGroups: t, fieldByCode: n, visibleFieldGroups: i, initialValues: r };
|
|
641
1401
|
}, [e]);
|
|
642
1402
|
}
|
|
643
|
-
function
|
|
1403
|
+
function je(e) {
|
|
644
1404
|
const t = {};
|
|
645
1405
|
return e.forEach((n) => {
|
|
646
1406
|
t[n.code] = {
|
|
@@ -650,636 +1410,748 @@ function ge(e) {
|
|
|
650
1410
|
};
|
|
651
1411
|
}), t;
|
|
652
1412
|
}
|
|
653
|
-
function
|
|
654
|
-
const [t, n] =
|
|
655
|
-
() =>
|
|
1413
|
+
function un(e) {
|
|
1414
|
+
const [t, n] = L(
|
|
1415
|
+
() => je(e)
|
|
656
1416
|
);
|
|
657
|
-
|
|
658
|
-
n(
|
|
1417
|
+
j(() => {
|
|
1418
|
+
n(je(e));
|
|
659
1419
|
}, [e]);
|
|
660
|
-
const r =
|
|
1420
|
+
const r = D((i, s) => {
|
|
661
1421
|
n((o) => ({
|
|
662
1422
|
...o,
|
|
663
|
-
[i]: { ...o[i], ...
|
|
1423
|
+
[i]: { ...o[i], ...s }
|
|
664
1424
|
}));
|
|
665
1425
|
}, []);
|
|
666
1426
|
return { fieldStates: t, setFieldStates: n, setFieldState: r };
|
|
667
1427
|
}
|
|
668
|
-
function
|
|
1428
|
+
function fn(e) {
|
|
1429
|
+
const t = {}, n = {};
|
|
1430
|
+
return e.forEach((r) => {
|
|
1431
|
+
t[r.containerKey] || (t[r.containerKey] = {}), t[r.containerKey][r.formCode] = r.value, n[r.fieldGroupCode] = [{ form_code: r.formCode }];
|
|
1432
|
+
}), { containers: t, formReferences: n };
|
|
1433
|
+
}
|
|
1434
|
+
function mn({
|
|
669
1435
|
formInstance: e,
|
|
670
1436
|
fieldByCode: t,
|
|
671
1437
|
relatedData: n,
|
|
672
|
-
transformers: r
|
|
1438
|
+
transformers: r,
|
|
1439
|
+
nestedFormRefs: i
|
|
673
1440
|
}) {
|
|
674
|
-
return { buildProcessedValues:
|
|
1441
|
+
return { buildProcessedValues: D(async () => {
|
|
675
1442
|
await e.validateFields();
|
|
676
|
-
const
|
|
677
|
-
for (const
|
|
678
|
-
const
|
|
679
|
-
if (!
|
|
680
|
-
let
|
|
681
|
-
switch (
|
|
1443
|
+
const o = e.getFieldsValue(), a = {}, m = [];
|
|
1444
|
+
for (const u of Object.keys(o)) {
|
|
1445
|
+
const c = t.get(u);
|
|
1446
|
+
if (!c) continue;
|
|
1447
|
+
let d;
|
|
1448
|
+
switch (c.field?.type?.code) {
|
|
682
1449
|
case "datetime":
|
|
683
|
-
|
|
684
|
-
|
|
1450
|
+
d = o[u] ? ge(o[u]).format(
|
|
1451
|
+
c.additional_config?.datetime?.format
|
|
685
1452
|
) : null;
|
|
686
1453
|
break;
|
|
687
1454
|
case "image":
|
|
688
1455
|
case "file":
|
|
689
|
-
|
|
690
|
-
...
|
|
691
|
-
name:
|
|
692
|
-
type:
|
|
693
|
-
size:
|
|
1456
|
+
o[u]?.fileList?.length && (d = o[u].fileList.filter((p) => p.percent === 100).map((p) => ({
|
|
1457
|
+
...p.response,
|
|
1458
|
+
name: p.name,
|
|
1459
|
+
type: p.type,
|
|
1460
|
+
size: p.size
|
|
694
1461
|
})));
|
|
695
1462
|
break;
|
|
1463
|
+
case "form":
|
|
1464
|
+
case "multiple-form": {
|
|
1465
|
+
const p = i.current.get(u);
|
|
1466
|
+
p?.ref.current ? d = await p.ref.current.getProcessedValues() : d = o[u], r.transformFieldValue && (d = r.transformFieldValue(u, d, c)), p ? m.push({
|
|
1467
|
+
fieldGroupCode: u,
|
|
1468
|
+
formCode: p.formCode,
|
|
1469
|
+
value: d,
|
|
1470
|
+
containerKey: Re(c)
|
|
1471
|
+
}) : a[u] = d;
|
|
1472
|
+
break;
|
|
1473
|
+
}
|
|
696
1474
|
default:
|
|
697
|
-
|
|
1475
|
+
d = o[u];
|
|
698
1476
|
}
|
|
699
|
-
r.transformFieldValue && (
|
|
1477
|
+
c.field?.type?.code !== "form" && c.field?.type?.code !== "multiple-form" && (r.transformFieldValue && (d = r.transformFieldValue(u, d, c)), a[u] = d);
|
|
1478
|
+
}
|
|
1479
|
+
if (m.length > 0) {
|
|
1480
|
+
const { containers: u, formReferences: c } = fn(m);
|
|
1481
|
+
Object.assign(a, u), Object.keys(c).length > 0 && (a.form_references = c);
|
|
700
1482
|
}
|
|
701
|
-
let
|
|
702
|
-
return r.transformSubmitValues && (
|
|
703
|
-
|
|
1483
|
+
let f = a;
|
|
1484
|
+
return r.transformSubmitValues && (f = r.transformSubmitValues(
|
|
1485
|
+
f,
|
|
704
1486
|
Array.from(t.values()),
|
|
705
1487
|
n
|
|
706
|
-
)), (r.parseRelatedDataTemplates ??
|
|
707
|
-
}, [t, e, n, r]) };
|
|
1488
|
+
)), (r.parseRelatedDataTemplates ?? Nt)(f, n ?? {});
|
|
1489
|
+
}, [t, e, i, n, r]) };
|
|
708
1490
|
}
|
|
709
|
-
const
|
|
1491
|
+
const xe = _t(
|
|
710
1492
|
({
|
|
711
1493
|
formConfig: e,
|
|
712
1494
|
formInstance: t,
|
|
713
1495
|
relatedData: n,
|
|
714
1496
|
uploadUrl: r,
|
|
715
1497
|
uploadResourceUrl: i,
|
|
716
|
-
submitTrackingUrl:
|
|
1498
|
+
submitTrackingUrl: s,
|
|
717
1499
|
onBeforeSubmit: o,
|
|
718
|
-
onSubmitSuccess:
|
|
719
|
-
onSubmitError:
|
|
720
|
-
isRedirectAfterCreate:
|
|
1500
|
+
onSubmitSuccess: a,
|
|
1501
|
+
onSubmitError: m,
|
|
1502
|
+
isRedirectAfterCreate: f,
|
|
721
1503
|
onRedirect: y,
|
|
722
|
-
size:
|
|
723
|
-
manualSubmit:
|
|
724
|
-
onValuesChange:
|
|
725
|
-
readOnly:
|
|
726
|
-
submitDebounceMs:
|
|
1504
|
+
size: u = "middle",
|
|
1505
|
+
manualSubmit: c = !1,
|
|
1506
|
+
onValuesChange: d,
|
|
1507
|
+
readOnly: p = !1,
|
|
1508
|
+
submitDebounceMs: h,
|
|
727
1509
|
gutter: _ = [8, 0],
|
|
728
|
-
defaultColSpan:
|
|
729
|
-
submitButtonLabel:
|
|
730
|
-
|
|
731
|
-
|
|
1510
|
+
defaultColSpan: A = 12,
|
|
1511
|
+
submitButtonLabel: g,
|
|
1512
|
+
disableHtmlFormWrapper: S = !1
|
|
1513
|
+
}, b) => {
|
|
1514
|
+
const { message: w } = pt.useApp(), T = U(), { i18n: F, client: x, parsers: z, redirectHandler: H, renderers: B, transformers: Y } = T, ee = r ?? i, P = h ?? T.submitDebounceMs, G = g ?? F.messages.submit, { fieldGroups: K, fieldByCode: ne, initialValues: v } = dn(e), { fieldStates: k, setFieldState: E } = un(K), M = q(/* @__PURE__ */ new Map()), I = D(
|
|
1515
|
+
(R, $, J) => {
|
|
1516
|
+
if ($ && J) {
|
|
1517
|
+
M.current.set(R, { ref: $, ...J });
|
|
1518
|
+
return;
|
|
1519
|
+
}
|
|
1520
|
+
M.current.delete(R);
|
|
1521
|
+
},
|
|
1522
|
+
[]
|
|
1523
|
+
), { buildProcessedValues: re } = mn({
|
|
732
1524
|
formInstance: t,
|
|
733
|
-
fieldByCode:
|
|
1525
|
+
fieldByCode: ne,
|
|
734
1526
|
relatedData: n,
|
|
735
|
-
transformers:
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
1527
|
+
transformers: Y,
|
|
1528
|
+
nestedFormRefs: M
|
|
1529
|
+
}), X = q(!1), [te, ie] = L(!1), [me, Te] = L(!1);
|
|
1530
|
+
j(() => {
|
|
1531
|
+
const R = Object.fromEntries(
|
|
1532
|
+
Object.entries(v).filter(([J]) => {
|
|
1533
|
+
const O = ne.get(J)?.field?.type?.code;
|
|
1534
|
+
return O !== "form" && O !== "multiple-form";
|
|
1535
|
+
})
|
|
1536
|
+
);
|
|
1537
|
+
if (Object.keys(R).length === 0) return;
|
|
1538
|
+
const $ = Y.normalizeInitialValues ? Y.normalizeInitialValues(R, K) : R;
|
|
1539
|
+
t.setFieldsValue($);
|
|
1540
|
+
}, [ne, K, t, v, Y]);
|
|
1541
|
+
const pe = D(async () => {
|
|
1542
|
+
if (!X.current) {
|
|
1543
|
+
X.current = !0, ie(!0);
|
|
746
1544
|
try {
|
|
747
|
-
let
|
|
1545
|
+
let R = await re();
|
|
748
1546
|
try {
|
|
749
|
-
|
|
1547
|
+
s && (Te(!0), await x.request({
|
|
750
1548
|
method: "POST",
|
|
751
|
-
url:
|
|
752
|
-
data:
|
|
1549
|
+
url: s,
|
|
1550
|
+
data: R
|
|
753
1551
|
}));
|
|
754
|
-
const
|
|
755
|
-
if (
|
|
756
|
-
|
|
757
|
-
} catch (
|
|
758
|
-
console.error(
|
|
1552
|
+
const O = await o?.(R);
|
|
1553
|
+
if (O === !1) return;
|
|
1554
|
+
O && typeof O == "object" && (R = O);
|
|
1555
|
+
} catch (O) {
|
|
1556
|
+
console.error(O);
|
|
759
1557
|
return;
|
|
760
1558
|
} finally {
|
|
761
|
-
|
|
1559
|
+
Te(!1);
|
|
762
1560
|
}
|
|
763
|
-
const
|
|
1561
|
+
const $ = await x.request({
|
|
764
1562
|
method: e.method,
|
|
765
1563
|
url: e.action,
|
|
766
|
-
data:
|
|
1564
|
+
data: R
|
|
767
1565
|
});
|
|
768
1566
|
t.resetFields(
|
|
769
|
-
|
|
1567
|
+
K.filter((O) => !O.is_hidden).map((O) => O.code)
|
|
770
1568
|
);
|
|
771
|
-
const
|
|
772
|
-
|
|
773
|
-
values:
|
|
774
|
-
response:
|
|
775
|
-
data:
|
|
1569
|
+
const J = z.submitResponse($.data);
|
|
1570
|
+
f && J.redirectUrl && (y ?? H)(J.redirectUrl, "_blank"), a?.({
|
|
1571
|
+
values: R,
|
|
1572
|
+
response: $.data,
|
|
1573
|
+
data: J.data ?? $.data
|
|
776
1574
|
});
|
|
777
|
-
} catch (
|
|
778
|
-
const
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
),
|
|
1575
|
+
} catch (R) {
|
|
1576
|
+
const $ = R;
|
|
1577
|
+
w.error(
|
|
1578
|
+
$?.response?.data?.message ?? F.messages.submitError
|
|
1579
|
+
), m?.(R);
|
|
782
1580
|
} finally {
|
|
783
|
-
|
|
1581
|
+
X.current = !1, ie(!1);
|
|
784
1582
|
}
|
|
785
1583
|
}
|
|
786
1584
|
}, [
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
1585
|
+
re,
|
|
1586
|
+
x,
|
|
1587
|
+
K,
|
|
790
1588
|
e.action,
|
|
791
1589
|
e.method,
|
|
792
1590
|
t,
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
1591
|
+
F.messages.submitError,
|
|
1592
|
+
f,
|
|
1593
|
+
w,
|
|
796
1594
|
o,
|
|
797
1595
|
y,
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
1596
|
+
m,
|
|
1597
|
+
a,
|
|
1598
|
+
z,
|
|
1599
|
+
H,
|
|
1600
|
+
s
|
|
803
1601
|
]);
|
|
804
|
-
|
|
805
|
-
|
|
1602
|
+
bt(
|
|
1603
|
+
b,
|
|
806
1604
|
() => ({
|
|
807
|
-
submit:
|
|
808
|
-
getProcessedValues:
|
|
809
|
-
isSubmitting: () =>
|
|
1605
|
+
submit: pe,
|
|
1606
|
+
getProcessedValues: re,
|
|
1607
|
+
isSubmitting: () => X.current
|
|
810
1608
|
}),
|
|
811
|
-
[
|
|
1609
|
+
[re, pe]
|
|
812
1610
|
);
|
|
813
|
-
const
|
|
814
|
-
() =>
|
|
815
|
-
|
|
816
|
-
},
|
|
817
|
-
[
|
|
818
|
-
),
|
|
819
|
-
(
|
|
820
|
-
Object.keys(
|
|
821
|
-
const
|
|
822
|
-
|
|
823
|
-
|
|
1611
|
+
const Me = C(
|
|
1612
|
+
() => Fe(() => {
|
|
1613
|
+
pe();
|
|
1614
|
+
}, P),
|
|
1615
|
+
[pe, P]
|
|
1616
|
+
), it = D(
|
|
1617
|
+
(R, $) => {
|
|
1618
|
+
Object.keys(R).forEach((J) => {
|
|
1619
|
+
const O = $t(
|
|
1620
|
+
J,
|
|
1621
|
+
K,
|
|
824
1622
|
t.getFieldsValue()
|
|
825
1623
|
);
|
|
826
|
-
|
|
827
|
-
}),
|
|
1624
|
+
O.length > 0 && t.resetFields(O);
|
|
1625
|
+
}), d?.(R, $);
|
|
828
1626
|
},
|
|
829
|
-
[
|
|
830
|
-
),
|
|
831
|
-
(
|
|
832
|
-
|
|
1627
|
+
[K, t, d]
|
|
1628
|
+
), De = D(
|
|
1629
|
+
(R) => /* @__PURE__ */ l(
|
|
1630
|
+
cn,
|
|
833
1631
|
{
|
|
834
|
-
group:
|
|
1632
|
+
group: R,
|
|
835
1633
|
formInstance: t,
|
|
836
|
-
fieldState:
|
|
837
|
-
setFieldState:
|
|
838
|
-
uploadUrl:
|
|
839
|
-
readOnly:
|
|
840
|
-
size:
|
|
1634
|
+
fieldState: k[R.code],
|
|
1635
|
+
setFieldState: E,
|
|
1636
|
+
uploadUrl: ee,
|
|
1637
|
+
readOnly: p,
|
|
1638
|
+
size: u,
|
|
1639
|
+
registerNestedForm: I
|
|
841
1640
|
},
|
|
842
|
-
|
|
1641
|
+
R.id
|
|
843
1642
|
),
|
|
844
1643
|
[
|
|
845
|
-
|
|
1644
|
+
k,
|
|
846
1645
|
t,
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
1646
|
+
I,
|
|
1647
|
+
p,
|
|
1648
|
+
ee,
|
|
1649
|
+
E,
|
|
1650
|
+
u
|
|
851
1651
|
]
|
|
852
|
-
),
|
|
853
|
-
fieldGroups:
|
|
854
|
-
fieldStates:
|
|
855
|
-
renderField:
|
|
1652
|
+
), ot = B.layout ? B.layout({
|
|
1653
|
+
fieldGroups: K,
|
|
1654
|
+
fieldStates: k,
|
|
1655
|
+
renderField: De,
|
|
856
1656
|
gutter: _,
|
|
857
|
-
defaultColSpan:
|
|
858
|
-
size:
|
|
859
|
-
}) : /* @__PURE__ */
|
|
860
|
-
|
|
1657
|
+
defaultColSpan: A,
|
|
1658
|
+
size: u
|
|
1659
|
+
}) : /* @__PURE__ */ l(
|
|
1660
|
+
ln,
|
|
861
1661
|
{
|
|
862
|
-
fieldGroups:
|
|
863
|
-
fieldStates:
|
|
864
|
-
renderField:
|
|
1662
|
+
fieldGroups: K,
|
|
1663
|
+
fieldStates: k,
|
|
1664
|
+
renderField: De,
|
|
865
1665
|
gutter: _,
|
|
866
|
-
defaultColSpan:
|
|
867
|
-
size:
|
|
1666
|
+
defaultColSpan: A,
|
|
1667
|
+
size: u
|
|
868
1668
|
}
|
|
869
|
-
),
|
|
870
|
-
onSubmit:
|
|
871
|
-
loading:
|
|
872
|
-
label:
|
|
873
|
-
}) : /* @__PURE__ */
|
|
874
|
-
|
|
1669
|
+
), st = !c && !p && (B.submitActions ? B.submitActions({
|
|
1670
|
+
onSubmit: Me,
|
|
1671
|
+
loading: te || me,
|
|
1672
|
+
label: G
|
|
1673
|
+
}) : /* @__PURE__ */ l(Se, { justify: "flex-end", children: /* @__PURE__ */ l(
|
|
1674
|
+
Ae,
|
|
875
1675
|
{
|
|
876
1676
|
type: "primary",
|
|
877
|
-
onClick:
|
|
878
|
-
loading:
|
|
879
|
-
children:
|
|
1677
|
+
onClick: Me,
|
|
1678
|
+
loading: te || me,
|
|
1679
|
+
children: G
|
|
880
1680
|
}
|
|
881
1681
|
) }));
|
|
882
|
-
return /* @__PURE__ */
|
|
883
|
-
|
|
1682
|
+
return /* @__PURE__ */ ce(
|
|
1683
|
+
Q,
|
|
884
1684
|
{
|
|
885
1685
|
layout: "vertical",
|
|
886
1686
|
form: t,
|
|
887
|
-
size:
|
|
888
|
-
|
|
1687
|
+
size: u,
|
|
1688
|
+
component: S ? !1 : void 0,
|
|
1689
|
+
onValuesChange: it,
|
|
889
1690
|
children: [
|
|
890
|
-
|
|
891
|
-
|
|
1691
|
+
ot,
|
|
1692
|
+
st
|
|
892
1693
|
]
|
|
893
1694
|
}
|
|
894
1695
|
);
|
|
895
1696
|
}
|
|
896
1697
|
);
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
const
|
|
901
|
-
if (t === "api" && e.api?.url)
|
|
902
|
-
return e.api;
|
|
903
|
-
if (t === "api_ids" && e.api_ids?.url) {
|
|
904
|
-
const n = e.api_ids, r = n.method?.toUpperCase() === "POST";
|
|
905
|
-
return {
|
|
906
|
-
url: n.url,
|
|
907
|
-
method: n.method,
|
|
908
|
-
data_path: n.data_path,
|
|
909
|
-
mapping_attr: n.mapping_attr,
|
|
910
|
-
link: n.link,
|
|
911
|
-
result_type: n.result_type ?? "array",
|
|
912
|
-
params: n.params ?? (!r && !n.data ? { ids: "{{value}}" } : void 0),
|
|
913
|
-
data: n.data ?? (r && !n.params ? { ids: "{{value}}" } : void 0)
|
|
914
|
-
};
|
|
915
|
-
}
|
|
916
|
-
if (t === "api_detail" && e.api_detail?.url) {
|
|
917
|
-
const n = e.api_detail;
|
|
918
|
-
return {
|
|
919
|
-
url: n.url,
|
|
920
|
-
method: n.method,
|
|
921
|
-
data_path: n.data_path,
|
|
922
|
-
mapping_attr: n.mapping_attr,
|
|
923
|
-
link: n.link,
|
|
924
|
-
result_type: n.result_type ?? "object",
|
|
925
|
-
url_template: n.url_template ?? !0,
|
|
926
|
-
params: n.params,
|
|
927
|
-
data: n.data
|
|
928
|
-
};
|
|
929
|
-
}
|
|
930
|
-
}
|
|
931
|
-
function Ae(e) {
|
|
932
|
-
return {
|
|
933
|
-
value: e,
|
|
934
|
-
id: e
|
|
935
|
-
};
|
|
936
|
-
}
|
|
937
|
-
function Dt(e, t) {
|
|
938
|
-
const n = t.method || "GET", r = n.toUpperCase() === "GET";
|
|
939
|
-
if (t.url_template)
|
|
940
|
-
return (Array.isArray(e) ? e.filter((d) => d != null && d !== "") : e != null && e !== "" ? [e] : []).map((d) => {
|
|
941
|
-
const c = Ae(d), y = re(t.url, c), m = t.params ? I(t.params, c) : void 0, l = t.data ? I(t.data, c) : void 0;
|
|
942
|
-
return {
|
|
943
|
-
method: n,
|
|
944
|
-
url: y,
|
|
945
|
-
params: r ? m : void 0,
|
|
946
|
-
data: r ? void 0 : l
|
|
947
|
-
};
|
|
948
|
-
});
|
|
949
|
-
const i = Ae(e), a = t.params ? I(t.params, i) : void 0, o = t.data ? I(t.data, i) : void 0;
|
|
950
|
-
return [
|
|
951
|
-
{
|
|
952
|
-
method: n,
|
|
953
|
-
url: t.url,
|
|
954
|
-
params: r ? a : void 0,
|
|
955
|
-
data: r ? void 0 : o
|
|
956
|
-
}
|
|
957
|
-
];
|
|
958
|
-
}
|
|
959
|
-
function xe(e, t) {
|
|
960
|
-
const n = t.data_path ? z(e, t.data_path) : e;
|
|
961
|
-
return (t.result_type ?? (Array.isArray(n) ? "array" : "object")) === "array" ? Array.isArray(n) ? n : n != null ? [n] : [] : Array.isArray(n) ? n.length ? [n[0]] : [] : n && typeof n == "object" ? [n] : [];
|
|
962
|
-
}
|
|
963
|
-
function Le(e, t) {
|
|
964
|
-
return Mt(e, t.mapping_attr);
|
|
965
|
-
}
|
|
966
|
-
function Ce(e, t) {
|
|
967
|
-
return jt(t.link, e);
|
|
968
|
-
}
|
|
969
|
-
async function Pt(e, t, n, r) {
|
|
970
|
-
const i = Dt(e, t);
|
|
971
|
-
if (!i.length) return [];
|
|
972
|
-
const a = await Promise.all(
|
|
973
|
-
i.map((s) => n({ ...s, signal: r }))
|
|
974
|
-
), o = [];
|
|
975
|
-
for (const s of a)
|
|
976
|
-
o.push(...xe(s.data, t));
|
|
977
|
-
return o;
|
|
978
|
-
}
|
|
979
|
-
function $(e) {
|
|
980
|
-
return !!(e == null || e === "" || Array.isArray(e) && e.length === 0);
|
|
981
|
-
}
|
|
982
|
-
function Tt(e, t) {
|
|
983
|
-
const n = e.option_config?.api_options?.params, r = e.option_config?.api_options?.data;
|
|
984
|
-
if (!n && !r) return;
|
|
985
|
-
const i = (a) => {
|
|
986
|
-
const o = {};
|
|
987
|
-
for (const s in a)
|
|
988
|
-
if (typeof a[s] == "string" && a[s].startsWith("{{") && a[s].endsWith("}}")) {
|
|
989
|
-
const d = a[s].slice(2, -2).trim();
|
|
990
|
-
o[s] = t?.[d];
|
|
991
|
-
} else
|
|
992
|
-
o[s] = a[s];
|
|
993
|
-
return o;
|
|
994
|
-
};
|
|
995
|
-
return {
|
|
996
|
-
params: n ? i(n) : void 0,
|
|
997
|
-
data: r ? i(r) : void 0
|
|
998
|
-
};
|
|
999
|
-
}
|
|
1000
|
-
function xt(e, t) {
|
|
1001
|
-
const n = t.option_config?.label_attr, r = t.option_config?.value_attr || "";
|
|
1002
|
-
if (n?.length) {
|
|
1003
|
-
const i = n.join(" - ");
|
|
1004
|
-
return e[i] !== void 0 ? String(e[i]) : n.map((a) => e[a]).filter((a) => a != null && a !== "").join(" - ");
|
|
1005
|
-
}
|
|
1006
|
-
return String(e[r] ?? "");
|
|
1007
|
-
}
|
|
1008
|
-
function Lt(e, t) {
|
|
1009
|
-
if (!t?.length) return null;
|
|
1010
|
-
const r = (Array.isArray(e) ? e : [e]).map((i) => t.find((a) => String(a.value) === String(i))?.label).filter((i) => !!i);
|
|
1011
|
-
return r.length ? r.join(", ") : null;
|
|
1012
|
-
}
|
|
1013
|
-
function Ct(e, t, n) {
|
|
1014
|
-
if ($(e)) return null;
|
|
1015
|
-
const r = t.option_config?.value_attr || "value", i = Array.isArray(e) ? e : [e];
|
|
1016
|
-
if (t.is_option_api && n?.length) {
|
|
1017
|
-
const o = i.map((s) => {
|
|
1018
|
-
const d = n.find(
|
|
1019
|
-
(c) => String(c[r]) === String(s)
|
|
1020
|
-
);
|
|
1021
|
-
return d ? xt(d, t) : String(s);
|
|
1022
|
-
}).filter(Boolean);
|
|
1023
|
-
return o.length ? o.join(", ") : null;
|
|
1024
|
-
}
|
|
1025
|
-
const a = Lt(e, t.metas);
|
|
1026
|
-
return a || i.map(String).join(", ");
|
|
1027
|
-
}
|
|
1028
|
-
function Vt(e, t) {
|
|
1029
|
-
if ($(e)) return null;
|
|
1030
|
-
const n = t.additional_config?.datetime?.format, r = ae(e);
|
|
1031
|
-
return r.isValid() ? n ? r.format(n) : r.format("YYYY-MM-DD HH:mm:ss") : String(e);
|
|
1032
|
-
}
|
|
1033
|
-
function Ot(e) {
|
|
1034
|
-
if ($(e)) return null;
|
|
1035
|
-
if (Array.isArray(e)) {
|
|
1036
|
-
const t = e.map(
|
|
1037
|
-
(n) => typeof n == "object" && n && "name" in n ? String(n.name) : String(n)
|
|
1038
|
-
).filter(Boolean);
|
|
1039
|
-
return t.length ? t.join(", ") : null;
|
|
1040
|
-
}
|
|
1041
|
-
return String(e);
|
|
1042
|
-
}
|
|
1043
|
-
function Mt(e, t) {
|
|
1044
|
-
return t?.length ? t.map((n) => {
|
|
1045
|
-
const r = z(e, n) ?? e[n];
|
|
1046
|
-
return r != null ? String(r) : "";
|
|
1047
|
-
}).filter(Boolean).join(" - ") : JSON.stringify(e);
|
|
1048
|
-
}
|
|
1049
|
-
function jt(e, t) {
|
|
1050
|
-
return e ? e.replace(/\{\{(.+?)\}\}/g, (n, r) => {
|
|
1051
|
-
const i = r.trim(), a = z(t, i) ?? t[i];
|
|
1052
|
-
return a != null ? String(a) : "";
|
|
1053
|
-
}) : null;
|
|
1054
|
-
}
|
|
1055
|
-
function Se(e, t, n) {
|
|
1056
|
-
if ($(e)) return null;
|
|
1057
|
-
switch (t?.mode ?? "formatted") {
|
|
1058
|
-
case "raw":
|
|
1059
|
-
case "formatted":
|
|
1060
|
-
return Array.isArray(e) ? e.map(String).join(", ") : String(e);
|
|
1061
|
-
case "api":
|
|
1062
|
-
case "api_ids":
|
|
1063
|
-
case "api_detail": {
|
|
1064
|
-
const i = Te(t);
|
|
1065
|
-
if (!n || !i)
|
|
1066
|
-
return Array.isArray(e) ? e.map(String).join(", ") : String(e);
|
|
1067
|
-
const a = xe(n, i);
|
|
1068
|
-
return a.length ? a.map((s) => {
|
|
1069
|
-
const d = Le(s, i), c = Ce(s, i);
|
|
1070
|
-
return c ? `${d} (${c})` : d;
|
|
1071
|
-
}).filter(Boolean).join(", ") || null : String(e);
|
|
1072
|
-
}
|
|
1073
|
-
default:
|
|
1074
|
-
return String(e);
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
function qt(e, t, n) {
|
|
1078
|
-
const r = e.additional_config?.view_value;
|
|
1079
|
-
if (r?.mode === "api" || r?.mode === "api_ids" || r?.mode === "api_detail")
|
|
1080
|
-
return Se(
|
|
1081
|
-
t,
|
|
1082
|
-
r,
|
|
1083
|
-
n.viewValueFetched
|
|
1084
|
-
);
|
|
1085
|
-
switch (e.field?.type?.code) {
|
|
1086
|
-
case "text":
|
|
1087
|
-
case "number":
|
|
1088
|
-
return $(t) ? null : String(t);
|
|
1089
|
-
case "datetime":
|
|
1090
|
-
return Vt(t, e);
|
|
1091
|
-
case "select":
|
|
1092
|
-
case "radio":
|
|
1093
|
-
case "checkbox":
|
|
1094
|
-
return Ct(t, e, n.optionList);
|
|
1095
|
-
case "image":
|
|
1096
|
-
case "file":
|
|
1097
|
-
return Ot(t);
|
|
1098
|
-
default:
|
|
1099
|
-
return r ? Se(
|
|
1100
|
-
t,
|
|
1101
|
-
r,
|
|
1102
|
-
n.viewValueFetched
|
|
1103
|
-
) : $(t) ? null : String(t);
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1106
|
-
const ie = /* @__PURE__ */ new Map(), Ut = 3e4;
|
|
1107
|
-
function Gt(e) {
|
|
1108
|
-
const t = ie.get(e);
|
|
1698
|
+
xe.displayName = "DynamicForm";
|
|
1699
|
+
const _e = /* @__PURE__ */ new Map(), pn = 3e4;
|
|
1700
|
+
function yn(e) {
|
|
1701
|
+
const t = _e.get(e);
|
|
1109
1702
|
if (t) {
|
|
1110
1703
|
if (Date.now() > t.expiresAt) {
|
|
1111
|
-
|
|
1704
|
+
_e.delete(e);
|
|
1112
1705
|
return;
|
|
1113
1706
|
}
|
|
1114
1707
|
return t.error;
|
|
1115
1708
|
}
|
|
1116
1709
|
}
|
|
1117
|
-
function
|
|
1118
|
-
|
|
1710
|
+
function Oe(e, t) {
|
|
1711
|
+
_e.set(e, {
|
|
1119
1712
|
error: t,
|
|
1120
|
-
expiresAt: Date.now() +
|
|
1713
|
+
expiresAt: Date.now() + pn
|
|
1121
1714
|
});
|
|
1122
1715
|
}
|
|
1123
|
-
function
|
|
1124
|
-
const r =
|
|
1125
|
-
y.current = t,
|
|
1126
|
-
const
|
|
1127
|
-
return
|
|
1716
|
+
function fe(e, t, n = !0) {
|
|
1717
|
+
const r = U(), [i, s] = L(), [o, a] = L(!1), [m, f] = L(), y = q(t), u = q(r);
|
|
1718
|
+
y.current = t, u.current = r;
|
|
1719
|
+
const c = de(e);
|
|
1720
|
+
return j(() => {
|
|
1128
1721
|
if (!n) {
|
|
1129
|
-
|
|
1722
|
+
s(void 0), f(void 0), a(!1);
|
|
1130
1723
|
return;
|
|
1131
1724
|
}
|
|
1132
|
-
const
|
|
1133
|
-
if (
|
|
1134
|
-
|
|
1725
|
+
const p = yn(c);
|
|
1726
|
+
if (p !== void 0) {
|
|
1727
|
+
f(p), a(!1);
|
|
1135
1728
|
return;
|
|
1136
1729
|
}
|
|
1137
|
-
const
|
|
1138
|
-
return
|
|
1730
|
+
const h = new AbortController();
|
|
1731
|
+
return a(!0), f(void 0), (async () => {
|
|
1139
1732
|
try {
|
|
1140
|
-
const
|
|
1141
|
-
|
|
1733
|
+
const A = await ue(
|
|
1734
|
+
u.current,
|
|
1142
1735
|
"viewCache",
|
|
1143
|
-
|
|
1144
|
-
(
|
|
1145
|
-
|
|
1736
|
+
c,
|
|
1737
|
+
(g) => y.current(g),
|
|
1738
|
+
h.signal
|
|
1146
1739
|
);
|
|
1147
|
-
|
|
1148
|
-
} catch (
|
|
1149
|
-
|
|
1740
|
+
h.signal.aborted || (s(A), f(void 0));
|
|
1741
|
+
} catch (A) {
|
|
1742
|
+
h.signal.aborted || (Oe(c, A), f(A));
|
|
1150
1743
|
} finally {
|
|
1151
|
-
|
|
1744
|
+
h.signal.aborted || a(!1);
|
|
1152
1745
|
}
|
|
1153
|
-
})(), () =>
|
|
1154
|
-
}, [n,
|
|
1155
|
-
if (
|
|
1156
|
-
const
|
|
1157
|
-
|
|
1746
|
+
})(), () => h.abort();
|
|
1747
|
+
}, [n, c]), { data: i, isLoading: o, error: m, refetch: async () => {
|
|
1748
|
+
if (_e.delete(c), !n) return;
|
|
1749
|
+
const p = new AbortController();
|
|
1750
|
+
a(!0), f(void 0);
|
|
1158
1751
|
try {
|
|
1159
|
-
const
|
|
1160
|
-
|
|
1752
|
+
const h = await ue(
|
|
1753
|
+
u.current,
|
|
1161
1754
|
"viewCache",
|
|
1162
|
-
|
|
1755
|
+
c,
|
|
1163
1756
|
(_) => y.current(_),
|
|
1164
|
-
|
|
1757
|
+
p.signal
|
|
1165
1758
|
);
|
|
1166
|
-
return
|
|
1167
|
-
} catch (
|
|
1168
|
-
throw
|
|
1759
|
+
return s(h), h;
|
|
1760
|
+
} catch (h) {
|
|
1761
|
+
throw Oe(c, h), f(h), h;
|
|
1169
1762
|
} finally {
|
|
1170
|
-
|
|
1763
|
+
a(!1);
|
|
1171
1764
|
}
|
|
1172
1765
|
} };
|
|
1173
1766
|
}
|
|
1174
|
-
const
|
|
1175
|
-
const { client: r, renderers: i, i18n:
|
|
1767
|
+
const hn = ({ value: e, code: t, modeConfig: n }) => {
|
|
1768
|
+
const { client: r, renderers: i, i18n: s } = U(), o = C(
|
|
1176
1769
|
() => (Array.isArray(e) ? e : [e]).filter(Boolean),
|
|
1177
1770
|
[e]
|
|
1178
1771
|
), {
|
|
1179
|
-
data:
|
|
1180
|
-
isLoading:
|
|
1181
|
-
error:
|
|
1182
|
-
} =
|
|
1772
|
+
data: a,
|
|
1773
|
+
isLoading: m,
|
|
1774
|
+
error: f
|
|
1775
|
+
} = fe(
|
|
1183
1776
|
["api_detail", t, o, n?.url, n?.method],
|
|
1184
|
-
async (
|
|
1185
|
-
o.map(async (
|
|
1186
|
-
const
|
|
1777
|
+
async (c) => (await Promise.all(
|
|
1778
|
+
o.map(async (p) => {
|
|
1779
|
+
const h = he(n?.url || "", { id: p });
|
|
1187
1780
|
return (await r.request({
|
|
1188
1781
|
method: n?.method,
|
|
1189
|
-
url:
|
|
1190
|
-
signal:
|
|
1782
|
+
url: h,
|
|
1783
|
+
signal: c
|
|
1191
1784
|
})).data;
|
|
1192
1785
|
})
|
|
1193
1786
|
)).filter(Boolean),
|
|
1194
1787
|
!!(o.length && n?.url)
|
|
1195
|
-
), y = (
|
|
1196
|
-
const
|
|
1788
|
+
), y = (c, d, p) => i.link ? i.link({ url: c, label: d, data: p }) : /* @__PURE__ */ l("a", { href: c, target: "_blank", rel: "noreferrer", children: d }), u = (c) => {
|
|
1789
|
+
const d = n?.mapping_attr?.map((p) => c?.[p]).join(" - ");
|
|
1197
1790
|
if (n?.link) {
|
|
1198
|
-
const
|
|
1199
|
-
return y(
|
|
1791
|
+
const p = he(n.link, c);
|
|
1792
|
+
return y(p, d, c);
|
|
1200
1793
|
}
|
|
1201
|
-
return
|
|
1794
|
+
return d;
|
|
1202
1795
|
};
|
|
1203
|
-
return
|
|
1204
|
-
},
|
|
1205
|
-
const { client: r, renderers: i, i18n:
|
|
1796
|
+
return m ? /* @__PURE__ */ l(V, { children: i.viewLoading?.() ?? /* @__PURE__ */ l(be, { size: "small" }) }) : f ? /* @__PURE__ */ l(V, { children: i.viewError?.(f) ?? s.messages.viewError }) : a?.length ? /* @__PURE__ */ l(V, { children: a.map((c, d) => /* @__PURE__ */ l("div", { children: u(c) }, d)) }) : /* @__PURE__ */ l(V, { children: i.viewEmpty?.() ?? s.messages.viewEmpty });
|
|
1797
|
+
}, Qe = Z(hn), _n = ({ value: e, code: t, modeConfig: n }) => {
|
|
1798
|
+
const { client: r, renderers: i, i18n: s } = U(), {
|
|
1206
1799
|
data: o,
|
|
1207
|
-
isLoading:
|
|
1208
|
-
error:
|
|
1209
|
-
} =
|
|
1800
|
+
isLoading: a,
|
|
1801
|
+
error: m
|
|
1802
|
+
} = fe(
|
|
1210
1803
|
["api_ids", t, e, n?.url, n?.method],
|
|
1211
|
-
async (
|
|
1212
|
-
const
|
|
1213
|
-
method:
|
|
1804
|
+
async (u) => {
|
|
1805
|
+
const c = n?.method || "GET", d = c.toUpperCase() === "POST", p = Array.isArray(e) ? e : [e], _ = (await r.request({
|
|
1806
|
+
method: c,
|
|
1214
1807
|
url: n?.url || "",
|
|
1215
|
-
data:
|
|
1216
|
-
params:
|
|
1217
|
-
signal:
|
|
1218
|
-
})).data,
|
|
1219
|
-
return Array.isArray(
|
|
1808
|
+
data: d ? { ids: p } : void 0,
|
|
1809
|
+
params: d ? void 0 : { ids: p },
|
|
1810
|
+
signal: u
|
|
1811
|
+
})).data, A = n?.data_path ? ae(_, n.data_path) : _;
|
|
1812
|
+
return Array.isArray(A) ? A : _;
|
|
1220
1813
|
},
|
|
1221
1814
|
!!(e && n?.url)
|
|
1222
|
-
),
|
|
1223
|
-
const
|
|
1815
|
+
), f = (u, c, d) => i.link ? i.link({ url: u, label: c, data: d }) : /* @__PURE__ */ l("a", { href: u, target: "_blank", rel: "noreferrer", children: c }), y = (u) => {
|
|
1816
|
+
const c = n?.mapping_attr?.map((d) => u?.[d]).join(" - ");
|
|
1224
1817
|
if (n?.link) {
|
|
1225
|
-
const
|
|
1226
|
-
return
|
|
1818
|
+
const d = he(n.link, u);
|
|
1819
|
+
return f(d, c, u);
|
|
1227
1820
|
}
|
|
1228
|
-
return
|
|
1821
|
+
return c;
|
|
1229
1822
|
};
|
|
1230
|
-
return
|
|
1823
|
+
return a ? /* @__PURE__ */ l(V, { children: i.viewLoading?.() ?? /* @__PURE__ */ l(be, { size: "small" }) }) : m ? /* @__PURE__ */ l(V, { children: i.viewError?.(m) ?? s.messages.viewError }) : o ? Array.isArray(e) ? /* @__PURE__ */ l(Se, { vertical: !0, children: (Array.isArray(o) ? o : [o]).map((u, c) => /* @__PURE__ */ l("div", { children: y(u) }, u.id ?? c)) }) : y(
|
|
1231
1824
|
Array.isArray(o) ? o[0] : o
|
|
1232
|
-
) : /* @__PURE__ */
|
|
1233
|
-
},
|
|
1825
|
+
) : /* @__PURE__ */ l(V, { children: i.viewEmpty?.() ?? s.messages.viewEmpty });
|
|
1826
|
+
}, Ze = Z(_n), bn = ({
|
|
1234
1827
|
value: e,
|
|
1235
1828
|
code: t,
|
|
1236
1829
|
modeConfig: n,
|
|
1237
1830
|
viewConfig: r
|
|
1238
1831
|
}) => {
|
|
1239
|
-
const { client: i, renderers:
|
|
1240
|
-
() => n ?? (r ?
|
|
1832
|
+
const { client: i, renderers: s, i18n: o } = U(), a = C(
|
|
1833
|
+
() => n ?? (r ? Ue(r) : void 0),
|
|
1241
1834
|
[n, r]
|
|
1242
|
-
),
|
|
1243
|
-
() => ["api_view", t, e,
|
|
1244
|
-
[t, e,
|
|
1245
|
-
),
|
|
1246
|
-
async (
|
|
1835
|
+
), m = C(
|
|
1836
|
+
() => ["api_view", t, e, a?.url, a?.method, a?.data_path],
|
|
1837
|
+
[t, e, a?.url, a?.method, a?.data_path]
|
|
1838
|
+
), f = D(
|
|
1839
|
+
async (h) => a ? Vt(
|
|
1247
1840
|
e,
|
|
1248
|
-
|
|
1249
|
-
(_) => i.request({ ..._, signal:
|
|
1841
|
+
a,
|
|
1842
|
+
(_) => i.request({ ..._, signal: h })
|
|
1250
1843
|
) : [],
|
|
1251
|
-
[i,
|
|
1252
|
-
), { data: y, isLoading:
|
|
1253
|
-
if (!
|
|
1254
|
-
const
|
|
1255
|
-
return /* @__PURE__ */
|
|
1844
|
+
[i, a, e]
|
|
1845
|
+
), { data: y, isLoading: u, error: c } = fe(m, f, !!(e && a?.url)), d = (h, _, A) => s.link ? s.link({ url: h, label: _, data: A }) : /* @__PURE__ */ l("a", { href: h, target: "_blank", rel: "noreferrer", children: _ }), p = (h, _) => {
|
|
1846
|
+
if (!a) return null;
|
|
1847
|
+
const A = We(h, a), g = $e(h, a), S = g ? d(g, A, h) : A;
|
|
1848
|
+
return /* @__PURE__ */ l("div", { children: S }, h.id ?? _);
|
|
1256
1849
|
};
|
|
1257
|
-
return
|
|
1258
|
-
},
|
|
1259
|
-
|
|
1850
|
+
return u ? /* @__PURE__ */ l(V, { children: s.viewLoading?.() ?? /* @__PURE__ */ l(be, { size: "small" }) }) : c ? /* @__PURE__ */ l(V, { children: s.viewError?.(c) ?? o.messages.viewError }) : y?.length ? a?.result_type === "object" && y.length === 1 ? p(y[0], 0) : /* @__PURE__ */ l(Se, { vertical: !0, children: y.map(p) }) : /* @__PURE__ */ l(V, { children: s.viewEmpty?.() ?? o.messages.viewEmpty });
|
|
1851
|
+
}, Ge = Z(bn), gn = {
|
|
1852
|
+
whiteSpace: "normal",
|
|
1853
|
+
wordBreak: "break-word",
|
|
1854
|
+
verticalAlign: "top"
|
|
1855
|
+
}, et = ({
|
|
1856
|
+
group: e,
|
|
1857
|
+
value: t,
|
|
1858
|
+
formValues: n = {}
|
|
1859
|
+
}) => {
|
|
1860
|
+
const r = U(), i = e.additional_config?.multiple_form, s = i?.config_url, o = i?.method ?? "GET", {
|
|
1861
|
+
data: a,
|
|
1862
|
+
isLoading: m,
|
|
1863
|
+
error: f
|
|
1864
|
+
} = we(
|
|
1865
|
+
[s, o],
|
|
1866
|
+
async () => {
|
|
1867
|
+
if (!s)
|
|
1868
|
+
throw new Error("Missing additional_config.multiple_form.config_url");
|
|
1869
|
+
const d = await r.client.request({
|
|
1870
|
+
method: o,
|
|
1871
|
+
url: s
|
|
1872
|
+
});
|
|
1873
|
+
return r.parsers.formConfigResponse(d.data);
|
|
1874
|
+
},
|
|
1875
|
+
{ enabled: !!s }
|
|
1876
|
+
), y = C(() => {
|
|
1877
|
+
if (!a) return [];
|
|
1878
|
+
if (t && typeof t == "object" && !Array.isArray(t)) {
|
|
1879
|
+
const d = t;
|
|
1880
|
+
if (a.code in d && Array.isArray(d[a.code]))
|
|
1881
|
+
return d[a.code];
|
|
1882
|
+
}
|
|
1883
|
+
return Array.isArray(t) ? t : Je(
|
|
1884
|
+
e,
|
|
1885
|
+
{ ...n, [e.code]: t },
|
|
1886
|
+
a.code
|
|
1887
|
+
);
|
|
1888
|
+
}, [n, e, a, t]), u = C(() => a ? [...a.field_groups].filter((d) => !d.is_hidden).sort(
|
|
1889
|
+
(d, p) => Number(d.position ?? 0) - Number(p.position ?? 0)
|
|
1890
|
+
).map((d) => ({
|
|
1891
|
+
key: d.code,
|
|
1892
|
+
title: d.label,
|
|
1893
|
+
dataIndex: d.code,
|
|
1894
|
+
width: 140,
|
|
1895
|
+
onCell: () => ({
|
|
1896
|
+
style: gn
|
|
1897
|
+
}),
|
|
1898
|
+
render: (p, h) => /* @__PURE__ */ l(
|
|
1899
|
+
tt,
|
|
1900
|
+
{
|
|
1901
|
+
code: d.code,
|
|
1902
|
+
value: h[d.code],
|
|
1903
|
+
fieldGroup: d,
|
|
1904
|
+
formValues: h
|
|
1905
|
+
}
|
|
1906
|
+
)
|
|
1907
|
+
})) : [], [a]), c = C(
|
|
1908
|
+
() => y.map((d, p) => ({
|
|
1909
|
+
key: p,
|
|
1910
|
+
...d
|
|
1911
|
+
})),
|
|
1912
|
+
[y]
|
|
1913
|
+
);
|
|
1914
|
+
return s ? m ? /* @__PURE__ */ l(N, { type: "info", message: "Loading...", showIcon: !0 }) : f || !a ? /* @__PURE__ */ l(N, { type: "error", message: "Failed to load nested form", showIcon: !0 }) : y.length === 0 ? "-" : /* @__PURE__ */ l(
|
|
1915
|
+
"div",
|
|
1916
|
+
{
|
|
1917
|
+
style: {
|
|
1918
|
+
width: "100%",
|
|
1919
|
+
maxWidth: "100%",
|
|
1920
|
+
overflowX: "auto",
|
|
1921
|
+
overflowY: "hidden"
|
|
1922
|
+
},
|
|
1923
|
+
children: /* @__PURE__ */ l(
|
|
1924
|
+
yt,
|
|
1925
|
+
{
|
|
1926
|
+
size: "small",
|
|
1927
|
+
bordered: !0,
|
|
1928
|
+
pagination: {
|
|
1929
|
+
pageSize: 5,
|
|
1930
|
+
hideOnSinglePage: !0,
|
|
1931
|
+
size: "small"
|
|
1932
|
+
},
|
|
1933
|
+
columns: u,
|
|
1934
|
+
dataSource: c
|
|
1935
|
+
}
|
|
1936
|
+
)
|
|
1937
|
+
}
|
|
1938
|
+
) : /* @__PURE__ */ l(
|
|
1939
|
+
N,
|
|
1940
|
+
{
|
|
1941
|
+
type: "warning",
|
|
1942
|
+
message: "Missing multiple_form config_url",
|
|
1943
|
+
showIcon: !0
|
|
1944
|
+
}
|
|
1945
|
+
);
|
|
1946
|
+
}, wn = ({
|
|
1947
|
+
value: e,
|
|
1948
|
+
fieldGroup: t,
|
|
1949
|
+
formValues: n = {}
|
|
1950
|
+
}) => {
|
|
1951
|
+
const r = U(), { renderers: i } = r, s = C(
|
|
1952
|
+
() => Ee(e, t.metas),
|
|
1953
|
+
[t.metas, e]
|
|
1954
|
+
), o = !!(t.is_option_api && t.option_config?.url), a = o && !s && !W(e), {
|
|
1955
|
+
data: m,
|
|
1956
|
+
isLoading: f,
|
|
1957
|
+
error: y
|
|
1958
|
+
} = fe(
|
|
1959
|
+
[
|
|
1960
|
+
"selectLikeView",
|
|
1961
|
+
t.code,
|
|
1962
|
+
t.option_config?.url,
|
|
1963
|
+
t.option_config?.method,
|
|
1964
|
+
e,
|
|
1965
|
+
n
|
|
1966
|
+
],
|
|
1967
|
+
async (u) => {
|
|
1968
|
+
const c = Ce(t, n), d = t.option_config?.method?.toUpperCase() === "GET" || !t.option_config?.method, h = { [t.option_config?.value_attr || "value"]: e }, _ = await r.client.request({
|
|
1969
|
+
method: t.option_config?.method || "GET",
|
|
1970
|
+
url: t.option_config?.url || "",
|
|
1971
|
+
params: d ? {
|
|
1972
|
+
...c?.params,
|
|
1973
|
+
filter: {
|
|
1974
|
+
...c?.params?.filter,
|
|
1975
|
+
...h
|
|
1976
|
+
}
|
|
1977
|
+
} : c?.params,
|
|
1978
|
+
data: d ? c?.data : {
|
|
1979
|
+
...c?.data,
|
|
1980
|
+
filter: {
|
|
1981
|
+
...c?.data?.filter,
|
|
1982
|
+
...h
|
|
1983
|
+
}
|
|
1984
|
+
},
|
|
1985
|
+
signal: u
|
|
1986
|
+
});
|
|
1987
|
+
return r.parsers.optionResponse(_.data, t);
|
|
1988
|
+
},
|
|
1989
|
+
a
|
|
1990
|
+
);
|
|
1991
|
+
return W(e) ? /* @__PURE__ */ l(V, { children: i.viewEmpty?.() ?? "-" }) : s ? /* @__PURE__ */ l(V, { children: s }) : o ? f ? /* @__PURE__ */ l(V, { children: i.viewLoading?.() ?? /* @__PURE__ */ l(be, { size: "small" }) }) : y ? /* @__PURE__ */ l(V, { children: i.viewError?.(y) ?? se(e, t) ?? String(e) }) : /* @__PURE__ */ l(V, { children: se(e, t, m) ?? String(e) }) : /* @__PURE__ */ l(V, { children: se(e, t) ?? String(e) });
|
|
1992
|
+
}, vn = Z(wn), An = ({
|
|
1993
|
+
code: e,
|
|
1994
|
+
value: t,
|
|
1995
|
+
fieldGroup: n,
|
|
1996
|
+
formValues: r
|
|
1997
|
+
}) => {
|
|
1998
|
+
const i = n?.field?.type?.code, s = r ?? { [e]: t };
|
|
1999
|
+
if (i === "form" && n)
|
|
2000
|
+
return /* @__PURE__ */ l(
|
|
2001
|
+
nt,
|
|
2002
|
+
{
|
|
2003
|
+
group: n,
|
|
2004
|
+
value: t,
|
|
2005
|
+
formValues: s
|
|
2006
|
+
}
|
|
2007
|
+
);
|
|
2008
|
+
if (i === "multiple-form" && n)
|
|
2009
|
+
return /* @__PURE__ */ l(
|
|
2010
|
+
et,
|
|
2011
|
+
{
|
|
2012
|
+
group: n,
|
|
2013
|
+
value: t,
|
|
2014
|
+
formValues: s
|
|
2015
|
+
}
|
|
2016
|
+
);
|
|
2017
|
+
const o = n?.additional_config?.view_value, a = t == null ? "" : String(t);
|
|
2018
|
+
if ((i === "select" || i === "radio" || i === "checkbox") && n && !o?.mode)
|
|
2019
|
+
return /* @__PURE__ */ l(
|
|
2020
|
+
vn,
|
|
2021
|
+
{
|
|
2022
|
+
value: t,
|
|
2023
|
+
fieldGroup: n,
|
|
2024
|
+
formValues: s
|
|
2025
|
+
}
|
|
2026
|
+
);
|
|
2027
|
+
if (i === "datetime" && n && !o?.mode)
|
|
2028
|
+
return /* @__PURE__ */ l(V, { children: ze(t, n) ?? (W(t) ? "-" : a) });
|
|
2029
|
+
switch (o?.mode) {
|
|
2030
|
+
case "raw":
|
|
2031
|
+
return a;
|
|
2032
|
+
case "api":
|
|
2033
|
+
return /* @__PURE__ */ l(Ge, { code: e, value: a, viewConfig: o });
|
|
2034
|
+
case "api_ids": {
|
|
2035
|
+
const m = o?.api_ids;
|
|
2036
|
+
return /* @__PURE__ */ l(Ze, { code: e, value: a, modeConfig: m });
|
|
2037
|
+
}
|
|
2038
|
+
case "api_detail": {
|
|
2039
|
+
const m = o?.api_detail;
|
|
2040
|
+
return /* @__PURE__ */ l(Qe, { code: e, value: a, modeConfig: m });
|
|
2041
|
+
}
|
|
2042
|
+
default:
|
|
2043
|
+
return a;
|
|
2044
|
+
}
|
|
2045
|
+
}, tt = Z(An), Sn = {
|
|
2046
|
+
flexShrink: 0,
|
|
2047
|
+
whiteSpace: "nowrap",
|
|
2048
|
+
color: "rgba(0, 0, 0, 0.45)"
|
|
2049
|
+
}, kn = {
|
|
2050
|
+
flex: 1,
|
|
2051
|
+
minWidth: 0,
|
|
2052
|
+
whiteSpace: "normal",
|
|
2053
|
+
wordBreak: "break-word"
|
|
2054
|
+
}, Fn = {
|
|
2055
|
+
display: "flex",
|
|
2056
|
+
alignItems: "flex-start",
|
|
2057
|
+
gap: 12,
|
|
2058
|
+
marginBottom: 8
|
|
2059
|
+
}, Cn = ({
|
|
2060
|
+
fieldGroups: e,
|
|
2061
|
+
values: t
|
|
2062
|
+
}) => {
|
|
2063
|
+
const n = C(() => [...e].sort(
|
|
2064
|
+
(r, i) => Number(r.position ?? 0) - Number(i.position ?? 0)
|
|
2065
|
+
).filter((r) => !r.is_hidden && r.code in t).map((r) => ({
|
|
2066
|
+
key: r.code,
|
|
2067
|
+
label: r.label,
|
|
2068
|
+
content: /* @__PURE__ */ l(
|
|
2069
|
+
tt,
|
|
2070
|
+
{
|
|
2071
|
+
code: r.code,
|
|
2072
|
+
value: t[r.code],
|
|
2073
|
+
fieldGroup: r,
|
|
2074
|
+
formValues: t
|
|
2075
|
+
}
|
|
2076
|
+
)
|
|
2077
|
+
})), [e, t]);
|
|
2078
|
+
return n.length === 0 ? /* @__PURE__ */ l(V, { children: "-" }) : /* @__PURE__ */ l("div", { style: { width: "100%" }, children: n.map((r) => /* @__PURE__ */ ce("div", { style: Fn, children: [
|
|
2079
|
+
/* @__PURE__ */ ce("div", { style: Sn, children: [
|
|
2080
|
+
r.label,
|
|
2081
|
+
":"
|
|
2082
|
+
] }),
|
|
2083
|
+
/* @__PURE__ */ l("div", { style: kn, children: r.content })
|
|
2084
|
+
] }, r.key)) });
|
|
2085
|
+
}, nt = ({
|
|
2086
|
+
group: e,
|
|
2087
|
+
value: t,
|
|
2088
|
+
formValues: n = {}
|
|
2089
|
+
}) => {
|
|
2090
|
+
const r = U(), i = e.additional_config?.form?.config_url, s = e.additional_config?.form?.method ?? "GET", {
|
|
2091
|
+
data: o,
|
|
2092
|
+
isLoading: a,
|
|
2093
|
+
error: m
|
|
2094
|
+
} = we(
|
|
2095
|
+
[i, s],
|
|
2096
|
+
async () => {
|
|
2097
|
+
if (!i)
|
|
2098
|
+
throw new Error("Missing additional_config.form.config_url");
|
|
2099
|
+
const y = await r.client.request({
|
|
2100
|
+
method: s,
|
|
2101
|
+
url: i
|
|
2102
|
+
});
|
|
2103
|
+
return r.parsers.formConfigResponse(y.data);
|
|
2104
|
+
},
|
|
2105
|
+
{ enabled: !!i }
|
|
2106
|
+
), f = C(() => {
|
|
2107
|
+
if (o) {
|
|
2108
|
+
if (t && typeof t == "object" && !Array.isArray(t)) {
|
|
2109
|
+
const y = t;
|
|
2110
|
+
if (o.code in y) {
|
|
2111
|
+
const u = y[o.code];
|
|
2112
|
+
return u && typeof u == "object" && !Array.isArray(u) ? u : void 0;
|
|
2113
|
+
}
|
|
2114
|
+
return y;
|
|
2115
|
+
}
|
|
2116
|
+
return Kt(
|
|
2117
|
+
e,
|
|
2118
|
+
{ ...n, [e.code]: t },
|
|
2119
|
+
o.code
|
|
2120
|
+
);
|
|
2121
|
+
}
|
|
2122
|
+
}, [n, e, o, t]);
|
|
2123
|
+
return i ? a ? /* @__PURE__ */ l(N, { type: "info", message: "Loading...", showIcon: !0 }) : m || !o ? /* @__PURE__ */ l(N, { type: "error", message: "Failed to load nested form", showIcon: !0 }) : !f || Object.keys(f).length === 0 ? "-" : /* @__PURE__ */ l(
|
|
2124
|
+
Cn,
|
|
2125
|
+
{
|
|
2126
|
+
fieldGroups: o.field_groups,
|
|
2127
|
+
values: f
|
|
2128
|
+
}
|
|
2129
|
+
) : /* @__PURE__ */ l(N, { type: "warning", message: "Missing nested form config_url", showIcon: !0 });
|
|
2130
|
+
};
|
|
2131
|
+
function En(e) {
|
|
1260
2132
|
return !!(e.option_config && e.is_option_api);
|
|
1261
2133
|
}
|
|
1262
|
-
function
|
|
1263
|
-
const n =
|
|
2134
|
+
function Rn(e, t) {
|
|
2135
|
+
const n = U(), r = de([
|
|
1264
2136
|
"viewModeOptions",
|
|
1265
|
-
e.map((
|
|
2137
|
+
e.map((s) => s.code),
|
|
1266
2138
|
t
|
|
1267
|
-
]), { data: i } =
|
|
2139
|
+
]), { data: i } = fe(
|
|
1268
2140
|
[r],
|
|
1269
|
-
async (
|
|
2141
|
+
async (s) => {
|
|
1270
2142
|
const o = {};
|
|
1271
2143
|
return await Promise.all(
|
|
1272
|
-
e.map(async (
|
|
1273
|
-
if (!
|
|
1274
|
-
const
|
|
1275
|
-
method:
|
|
1276
|
-
url:
|
|
1277
|
-
params:
|
|
1278
|
-
data:
|
|
1279
|
-
signal:
|
|
2144
|
+
e.map(async (a) => {
|
|
2145
|
+
if (!a.option_config?.url) return;
|
|
2146
|
+
const m = Ce(a, t), f = a.option_config.method?.toUpperCase() === "GET" || !a.option_config.method, y = await n.client.request({
|
|
2147
|
+
method: a.option_config.method || "GET",
|
|
2148
|
+
url: a.option_config.url,
|
|
2149
|
+
params: f ? m?.params : void 0,
|
|
2150
|
+
data: f ? void 0 : m?.data,
|
|
2151
|
+
signal: s
|
|
1280
2152
|
});
|
|
1281
|
-
o[
|
|
1282
|
-
optionList: n.parsers.optionResponse(y.data,
|
|
2153
|
+
o[a.code] = {
|
|
2154
|
+
optionList: n.parsers.optionResponse(y.data, a)
|
|
1283
2155
|
};
|
|
1284
2156
|
})
|
|
1285
2157
|
), o;
|
|
@@ -1288,93 +2160,101 @@ function $t(e, t) {
|
|
|
1288
2160
|
);
|
|
1289
2161
|
return i ?? {};
|
|
1290
2162
|
}
|
|
1291
|
-
const
|
|
2163
|
+
const Kn = ({
|
|
1292
2164
|
formConfig: e,
|
|
1293
2165
|
formValues: t
|
|
1294
2166
|
}) => {
|
|
1295
|
-
const n = e?.form?.field_groups ?? [], r =
|
|
1296
|
-
() => n.filter(
|
|
2167
|
+
const n = e?.form?.field_groups ?? [], r = C(
|
|
2168
|
+
() => n.filter(En),
|
|
1297
2169
|
[n]
|
|
1298
|
-
), i =
|
|
1299
|
-
return
|
|
1300
|
-
const
|
|
1301
|
-
if (
|
|
2170
|
+
), i = Rn(r, t);
|
|
2171
|
+
return C(() => n.filter((o) => !o.is_hidden).map((o) => {
|
|
2172
|
+
const a = t?.[o.code], m = o.field?.type?.code, f = o.additional_config?.view_value, y = f?.mode;
|
|
2173
|
+
if (m === "form")
|
|
2174
|
+
return {
|
|
2175
|
+
key: o.code,
|
|
2176
|
+
label: o.label,
|
|
2177
|
+
rawValue: a,
|
|
2178
|
+
viewValue: /* @__PURE__ */ l(
|
|
2179
|
+
nt,
|
|
2180
|
+
{
|
|
2181
|
+
group: o,
|
|
2182
|
+
value: a,
|
|
2183
|
+
formValues: t
|
|
2184
|
+
}
|
|
2185
|
+
),
|
|
2186
|
+
field_group: o
|
|
2187
|
+
};
|
|
2188
|
+
if (m === "multiple-form")
|
|
2189
|
+
return {
|
|
2190
|
+
key: o.code,
|
|
2191
|
+
label: o.label,
|
|
2192
|
+
rawValue: a,
|
|
2193
|
+
viewValue: /* @__PURE__ */ l(
|
|
2194
|
+
et,
|
|
2195
|
+
{
|
|
2196
|
+
group: o,
|
|
2197
|
+
value: a,
|
|
2198
|
+
formValues: t
|
|
2199
|
+
}
|
|
2200
|
+
),
|
|
2201
|
+
field_group: o
|
|
2202
|
+
};
|
|
2203
|
+
if (y === "api" && f)
|
|
1302
2204
|
return {
|
|
1303
2205
|
key: o.code,
|
|
1304
2206
|
label: o.label,
|
|
1305
|
-
rawValue:
|
|
1306
|
-
viewValue: /* @__PURE__ */
|
|
1307
|
-
|
|
2207
|
+
rawValue: a,
|
|
2208
|
+
viewValue: /* @__PURE__ */ l(
|
|
2209
|
+
Ge,
|
|
1308
2210
|
{
|
|
1309
2211
|
code: o.code,
|
|
1310
|
-
value:
|
|
1311
|
-
viewConfig:
|
|
2212
|
+
value: a,
|
|
2213
|
+
viewConfig: f
|
|
1312
2214
|
}
|
|
1313
2215
|
),
|
|
1314
2216
|
field_group: o
|
|
1315
2217
|
};
|
|
1316
|
-
if (
|
|
2218
|
+
if (y === "api_ids" && f?.api_ids)
|
|
1317
2219
|
return {
|
|
1318
2220
|
key: o.code,
|
|
1319
2221
|
label: o.label,
|
|
1320
|
-
rawValue:
|
|
1321
|
-
viewValue: /* @__PURE__ */
|
|
1322
|
-
|
|
2222
|
+
rawValue: a,
|
|
2223
|
+
viewValue: /* @__PURE__ */ l(
|
|
2224
|
+
Ze,
|
|
1323
2225
|
{
|
|
1324
2226
|
code: o.code,
|
|
1325
|
-
value:
|
|
1326
|
-
modeConfig:
|
|
2227
|
+
value: a,
|
|
2228
|
+
modeConfig: f.api_ids
|
|
1327
2229
|
}
|
|
1328
2230
|
),
|
|
1329
2231
|
field_group: o
|
|
1330
2232
|
};
|
|
1331
|
-
if (
|
|
2233
|
+
if (y === "api_detail" && f?.api_detail)
|
|
1332
2234
|
return {
|
|
1333
2235
|
key: o.code,
|
|
1334
2236
|
label: o.label,
|
|
1335
|
-
rawValue:
|
|
1336
|
-
viewValue: /* @__PURE__ */
|
|
1337
|
-
|
|
2237
|
+
rawValue: a,
|
|
2238
|
+
viewValue: /* @__PURE__ */ l(
|
|
2239
|
+
Qe,
|
|
1338
2240
|
{
|
|
1339
2241
|
code: o.code,
|
|
1340
|
-
value:
|
|
1341
|
-
modeConfig:
|
|
2242
|
+
value: a,
|
|
2243
|
+
modeConfig: f.api_detail
|
|
1342
2244
|
}
|
|
1343
2245
|
),
|
|
1344
2246
|
field_group: o
|
|
1345
2247
|
};
|
|
1346
|
-
const
|
|
2248
|
+
const u = i[o.code] ?? {};
|
|
1347
2249
|
return {
|
|
1348
2250
|
key: o.code,
|
|
1349
2251
|
label: o.label,
|
|
1350
|
-
rawValue:
|
|
1351
|
-
viewValue:
|
|
2252
|
+
rawValue: a,
|
|
2253
|
+
viewValue: Bt(o, a, u),
|
|
1352
2254
|
field_group: o
|
|
1353
2255
|
};
|
|
1354
2256
|
}), [i, n, t]);
|
|
1355
|
-
},
|
|
1356
|
-
code: e,
|
|
1357
|
-
value: t,
|
|
1358
|
-
fieldGroup: n
|
|
1359
|
-
}) => {
|
|
1360
|
-
const r = n?.additional_config?.view_value;
|
|
1361
|
-
switch (r?.mode) {
|
|
1362
|
-
case "raw":
|
|
1363
|
-
return t;
|
|
1364
|
-
case "api":
|
|
1365
|
-
return /* @__PURE__ */ u(Me, { code: e, value: t, viewConfig: r });
|
|
1366
|
-
case "api_ids": {
|
|
1367
|
-
const i = r?.api_ids;
|
|
1368
|
-
return /* @__PURE__ */ u(Oe, { code: e, value: t, modeConfig: i });
|
|
1369
|
-
}
|
|
1370
|
-
case "api_detail": {
|
|
1371
|
-
const i = r?.api_detail;
|
|
1372
|
-
return /* @__PURE__ */ u(Ve, { code: e, value: t, modeConfig: i });
|
|
1373
|
-
}
|
|
1374
|
-
default:
|
|
1375
|
-
return t;
|
|
1376
|
-
}
|
|
1377
|
-
}, on = V(zt), je = {
|
|
2257
|
+
}, rt = {
|
|
1378
2258
|
submit: "Save",
|
|
1379
2259
|
submitError: "Failed to submit form",
|
|
1380
2260
|
inputPlaceholder: (e) => `Enter ${e}`,
|
|
@@ -1385,9 +2265,9 @@ const an = ({
|
|
|
1385
2265
|
viewLoading: "Loading...",
|
|
1386
2266
|
viewEmpty: "-",
|
|
1387
2267
|
viewError: "Failed to load"
|
|
1388
|
-
},
|
|
1389
|
-
messages:
|
|
1390
|
-
},
|
|
2268
|
+
}, Un = {
|
|
2269
|
+
messages: rt
|
|
2270
|
+
}, xn = (e) => {
|
|
1391
2271
|
if (Array.isArray(e)) return e;
|
|
1392
2272
|
if (e && typeof e == "object" && "items" in e && Array.isArray(e.items))
|
|
1393
2273
|
return e.items;
|
|
@@ -1396,104 +2276,107 @@ const an = ({
|
|
|
1396
2276
|
return Array.isArray(t.items) ? t.items : [];
|
|
1397
2277
|
}
|
|
1398
2278
|
return [];
|
|
1399
|
-
},
|
|
2279
|
+
}, Tn = (e) => ({
|
|
1400
2280
|
redirectUrl: e?.redirect_after_create,
|
|
1401
2281
|
data: e
|
|
1402
|
-
}),
|
|
1403
|
-
optionResponse:
|
|
1404
|
-
submitResponse:
|
|
1405
|
-
viewResponse:
|
|
1406
|
-
|
|
2282
|
+
}), Mn = (e, t) => t?.dataPath ? ae(e, t.dataPath) : e, Dn = (e) => e, ye = {
|
|
2283
|
+
optionResponse: xn,
|
|
2284
|
+
submitResponse: Tn,
|
|
2285
|
+
viewResponse: Mn,
|
|
2286
|
+
formConfigResponse: Dn
|
|
2287
|
+
}, Ln = (e, t = "_blank") => {
|
|
1407
2288
|
window.open(e, t);
|
|
1408
|
-
},
|
|
2289
|
+
}, ve = {
|
|
1409
2290
|
upload: async () => {
|
|
1410
2291
|
throw new Error("Upload adapter is not configured");
|
|
1411
2292
|
},
|
|
1412
2293
|
remove: async () => !1
|
|
1413
2294
|
};
|
|
1414
|
-
function
|
|
2295
|
+
function Nn({
|
|
1415
2296
|
children: e,
|
|
1416
2297
|
client: t,
|
|
1417
2298
|
upload: n,
|
|
1418
2299
|
i18n: r,
|
|
1419
2300
|
parsers: i,
|
|
1420
|
-
renderers:
|
|
2301
|
+
renderers: s = {},
|
|
1421
2302
|
transformers: o = {},
|
|
1422
|
-
cache:
|
|
1423
|
-
submitDebounceMs:
|
|
1424
|
-
redirectHandler:
|
|
2303
|
+
cache: a,
|
|
2304
|
+
submitDebounceMs: m = 200,
|
|
2305
|
+
redirectHandler: f,
|
|
1425
2306
|
// legacy props
|
|
1426
2307
|
requestClient: y,
|
|
1427
|
-
uploadAdapter:
|
|
1428
|
-
deleteUploadAdapter:
|
|
1429
|
-
messages:
|
|
1430
|
-
optionResponseParser:
|
|
1431
|
-
customFieldRenderers:
|
|
2308
|
+
uploadAdapter: u,
|
|
2309
|
+
deleteUploadAdapter: c,
|
|
2310
|
+
messages: d,
|
|
2311
|
+
optionResponseParser: p,
|
|
2312
|
+
customFieldRenderers: h
|
|
1432
2313
|
}) {
|
|
1433
|
-
const _ =
|
|
1434
|
-
const
|
|
2314
|
+
const _ = q(/* @__PURE__ */ new Map()), A = q(/* @__PURE__ */ new Map()), g = C(() => {
|
|
2315
|
+
const S = t ?? {
|
|
1435
2316
|
request: y ?? (() => {
|
|
1436
2317
|
throw new Error("DynamicFormProvider requires client or requestClient");
|
|
1437
2318
|
})
|
|
1438
|
-
},
|
|
1439
|
-
match:
|
|
1440
|
-
render:
|
|
1441
|
-
})) : [],
|
|
1442
|
-
...
|
|
2319
|
+
}, b = h ? Object.entries(h).map(([F, x]) => ({
|
|
2320
|
+
match: F,
|
|
2321
|
+
render: x
|
|
2322
|
+
})) : [], w = {
|
|
2323
|
+
...rt,
|
|
1443
2324
|
...r?.messages,
|
|
1444
|
-
...
|
|
1445
|
-
},
|
|
1446
|
-
...
|
|
2325
|
+
...d
|
|
2326
|
+
}, T = {
|
|
2327
|
+
...ve,
|
|
1447
2328
|
...n,
|
|
1448
|
-
upload: n?.upload ??
|
|
1449
|
-
remove: n?.remove ?? (
|
|
2329
|
+
upload: n?.upload ?? u ?? ve.upload,
|
|
2330
|
+
remove: n?.remove ?? (c ? (F) => c(F.path) : ve.remove)
|
|
1450
2331
|
};
|
|
1451
2332
|
return {
|
|
1452
|
-
client:
|
|
1453
|
-
upload:
|
|
1454
|
-
i18n: { messages:
|
|
2333
|
+
client: S,
|
|
2334
|
+
upload: T,
|
|
2335
|
+
i18n: { messages: w },
|
|
1455
2336
|
parsers: {
|
|
1456
|
-
optionResponse: i?.optionResponse ??
|
|
1457
|
-
submitResponse: i?.submitResponse ??
|
|
1458
|
-
viewResponse: i?.viewResponse ??
|
|
2337
|
+
optionResponse: i?.optionResponse ?? p ?? ye.optionResponse,
|
|
2338
|
+
submitResponse: i?.submitResponse ?? ye.submitResponse,
|
|
2339
|
+
viewResponse: i?.viewResponse ?? ye.viewResponse,
|
|
2340
|
+
formConfigResponse: i?.formConfigResponse ?? ye.formConfigResponse
|
|
1459
2341
|
},
|
|
1460
2342
|
renderers: {
|
|
1461
|
-
...
|
|
1462
|
-
fields: [...
|
|
2343
|
+
...s,
|
|
2344
|
+
fields: [...s.fields ?? [], ...b]
|
|
1463
2345
|
},
|
|
1464
2346
|
transformers: o,
|
|
1465
2347
|
cache: {
|
|
1466
|
-
enabled:
|
|
1467
|
-
ttlMs:
|
|
2348
|
+
enabled: a?.enabled ?? !0,
|
|
2349
|
+
ttlMs: a?.ttlMs ?? 6e4
|
|
1468
2350
|
},
|
|
1469
|
-
submitDebounceMs:
|
|
1470
|
-
redirectHandler:
|
|
2351
|
+
submitDebounceMs: m,
|
|
2352
|
+
redirectHandler: f ?? Ln,
|
|
1471
2353
|
optionCache: _.current,
|
|
1472
|
-
viewCache:
|
|
2354
|
+
viewCache: A.current
|
|
1473
2355
|
};
|
|
1474
2356
|
}, [
|
|
1475
2357
|
t,
|
|
1476
2358
|
y,
|
|
1477
2359
|
n,
|
|
1478
|
-
|
|
1479
|
-
|
|
2360
|
+
u,
|
|
2361
|
+
c,
|
|
1480
2362
|
r?.messages,
|
|
1481
|
-
|
|
2363
|
+
d,
|
|
1482
2364
|
i?.optionResponse,
|
|
1483
2365
|
i?.submitResponse,
|
|
1484
2366
|
i?.viewResponse,
|
|
2367
|
+
i?.formConfigResponse,
|
|
2368
|
+
p,
|
|
2369
|
+
s,
|
|
1485
2370
|
h,
|
|
1486
|
-
a,
|
|
1487
|
-
f,
|
|
1488
2371
|
o,
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
2372
|
+
a?.enabled,
|
|
2373
|
+
a?.ttlMs,
|
|
2374
|
+
m,
|
|
2375
|
+
f
|
|
1493
2376
|
]);
|
|
1494
|
-
return /* @__PURE__ */
|
|
2377
|
+
return /* @__PURE__ */ l(ke.Provider, { value: g, children: e });
|
|
1495
2378
|
}
|
|
1496
|
-
function
|
|
2379
|
+
function Wn(e) {
|
|
1497
2380
|
return {
|
|
1498
2381
|
request: async (t) => ({ data: (await e({
|
|
1499
2382
|
method: t.method,
|
|
@@ -1507,55 +2390,67 @@ function cn(e) {
|
|
|
1507
2390
|
};
|
|
1508
2391
|
}
|
|
1509
2392
|
export {
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
2393
|
+
Qe as ApiDetailItem,
|
|
2394
|
+
Ze as ApiItem,
|
|
2395
|
+
Ge as ApiViewItem,
|
|
2396
|
+
ln as DefaultLayout,
|
|
2397
|
+
xe as DynamicForm,
|
|
2398
|
+
Nn as DynamicFormProvider,
|
|
2399
|
+
cn as FormItem,
|
|
2400
|
+
tt as MetaItemValue,
|
|
2401
|
+
tn as MultipleNestedForm,
|
|
2402
|
+
et as MultipleNestedFormView,
|
|
2403
|
+
Ht as NestedForm,
|
|
2404
|
+
nt as NestedFormView,
|
|
2405
|
+
Pt as buildApiViewRequests,
|
|
2406
|
+
de as buildCacheKey,
|
|
2407
|
+
ue as cachedRequest,
|
|
2408
|
+
Wn as createAxiosDynamicFormClient,
|
|
2409
|
+
Bn as createNestedDynamicFormData,
|
|
2410
|
+
Fe as debounce,
|
|
2411
|
+
Dn as defaultFormConfigResponseParser,
|
|
2412
|
+
Un as defaultI18n,
|
|
2413
|
+
rt as defaultMessages,
|
|
2414
|
+
xn as defaultOptionResponseParser,
|
|
2415
|
+
ye as defaultParsers,
|
|
2416
|
+
Ln as defaultRedirectHandler,
|
|
2417
|
+
Tn as defaultSubmitResponseParser,
|
|
2418
|
+
Mn as defaultViewResponseParser,
|
|
2419
|
+
Wt as extractDependencyFields,
|
|
2420
|
+
Je as extractMultipleNestedFormValues,
|
|
2421
|
+
Kt as extractNestedFormValue,
|
|
2422
|
+
Ne as extractViewData,
|
|
2423
|
+
Vt as fetchApiViewItems,
|
|
2424
|
+
he as fillTemplate,
|
|
2425
|
+
ae as getByPath,
|
|
2426
|
+
Yt as getCached,
|
|
2427
|
+
We as getMappedLabel,
|
|
2428
|
+
$e as getMappedLink,
|
|
2429
|
+
le as getNestedFormCodeHint,
|
|
2430
|
+
Re as getNestedSubmitContainerKey,
|
|
2431
|
+
W as isEmptyValue,
|
|
2432
|
+
Ft as mapOptionToSelectItem,
|
|
2433
|
+
Ct as mapOptions,
|
|
2434
|
+
Ue as normalizeApiViewConfig,
|
|
2435
|
+
Xe as normalizeMetaForForm,
|
|
2436
|
+
Nt as parseFormValues,
|
|
2437
|
+
oe as replaceTemplateInObject,
|
|
2438
|
+
Ce as resolveApiOptionMeta,
|
|
2439
|
+
St as resolveFieldRenderer,
|
|
2440
|
+
kt as resolveFieldRendererFromMap,
|
|
2441
|
+
Bt as resolveFieldViewValue,
|
|
2442
|
+
Ve as resolveViewValueConfig,
|
|
2443
|
+
Jt as setCache,
|
|
2444
|
+
Ye as unwrapMultipleFormValueForEdit,
|
|
2445
|
+
He as unwrapSingleFormValueForEdit,
|
|
2446
|
+
fe as useCachedViewRequest,
|
|
2447
|
+
rn as useDependencyValues,
|
|
2448
|
+
nn as useDynamicField,
|
|
2449
|
+
U as useDynamicFormContext,
|
|
2450
|
+
qn as useDynamicFormContextOptional,
|
|
2451
|
+
on as useDynamicOptions,
|
|
2452
|
+
dn as useFieldGroups,
|
|
2453
|
+
un as useFieldStates,
|
|
2454
|
+
mn as useProcessedValues,
|
|
2455
|
+
Kn as useViewMode
|
|
1561
2456
|
};
|