@trungkhai/dynamic-form 0.1.0 → 0.1.1
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 +1 -2
- package/dist/index.es.js +700 -630
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
import { jsx as f, jsxs as
|
|
2
|
-
import { Select as
|
|
3
|
-
import { createContext as
|
|
4
|
-
import
|
|
5
|
-
import { FileImageOutlined as
|
|
6
|
-
const
|
|
1
|
+
import { jsx as f, jsxs as Oe, Fragment as L } from "react/jsx-runtime";
|
|
2
|
+
import { Select as Ae, Form as q, Upload as Fe, Button as Ee, DatePicker as qe, Checkbox as Ue, Radio as Ie, InputNumber as Be, Input as _e, Row as We, Col as Ge, App as Ke, Flex as Re, Spin as ke } from "antd";
|
|
3
|
+
import { createContext as $e, useContext as De, memo as M, useState as D, useMemo as R, useEffect as j, useCallback as P, useRef as U, forwardRef as He, useImperativeHandle as ze } from "react";
|
|
4
|
+
import Q from "dayjs";
|
|
5
|
+
import { FileImageOutlined as Ne, UploadOutlined as Ye } from "@ant-design/icons";
|
|
6
|
+
const ie = $e(
|
|
7
7
|
null
|
|
8
8
|
);
|
|
9
|
-
function
|
|
10
|
-
const e =
|
|
9
|
+
function V() {
|
|
10
|
+
const e = De(ie);
|
|
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 Qt() {
|
|
18
|
+
return De(ie);
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function Je(e, t = []) {
|
|
21
21
|
for (const i of t) {
|
|
22
22
|
if (typeof i == "function")
|
|
23
23
|
continue;
|
|
24
|
-
const { match:
|
|
25
|
-
if (typeof
|
|
26
|
-
if (
|
|
27
|
-
return
|
|
28
|
-
} else if (
|
|
29
|
-
return
|
|
24
|
+
const { match: r, render: a } = i;
|
|
25
|
+
if (typeof r == "string") {
|
|
26
|
+
if (r === e.field?.type?.code || r === e.code)
|
|
27
|
+
return a;
|
|
28
|
+
} else if (r(e))
|
|
29
|
+
return a;
|
|
30
30
|
}
|
|
31
31
|
const n = e.field?.type?.code;
|
|
32
32
|
for (const i of t)
|
|
33
33
|
;
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
return
|
|
35
|
+
function Qe(e, t = [], n = {}) {
|
|
36
|
+
return Je(e, t) ?? n[e.code] ?? n[e.field?.type?.code ?? ""];
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function Xe(e, t) {
|
|
39
39
|
const n = t.option_config?.label_attr, i = t.option_config?.value_attr || "value";
|
|
40
|
-
let
|
|
40
|
+
let r;
|
|
41
41
|
if (n?.length) {
|
|
42
|
-
const
|
|
43
|
-
e[
|
|
42
|
+
const a = n.join(" - ");
|
|
43
|
+
e[a] !== void 0 ? r = String(e[a]) : r = n.map((s) => e[s]).filter((s) => s != null && s !== "").join(" - ");
|
|
44
44
|
} else
|
|
45
|
-
|
|
45
|
+
r = String(e[i] ?? "");
|
|
46
46
|
return {
|
|
47
|
-
label:
|
|
47
|
+
label: r,
|
|
48
48
|
value: e[i]
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
return t.option_config && t.is_option_api ? e?.map((n) =>
|
|
51
|
+
function Ze(e, t) {
|
|
52
|
+
return t.option_config && t.is_option_api ? e?.map((n) => Xe(n, t)) : t.metas?.map((n) => ({
|
|
53
53
|
label: n.label,
|
|
54
54
|
value: n.value
|
|
55
55
|
}));
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function re(e, t) {
|
|
58
58
|
let n;
|
|
59
59
|
return (...i) => {
|
|
60
60
|
n && clearTimeout(n), n = setTimeout(() => e(...i), t);
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
-
const
|
|
63
|
+
const et = ({
|
|
64
64
|
onSearchKeyword: e,
|
|
65
65
|
searchDebounceMs: t = 500,
|
|
66
66
|
...n
|
|
67
67
|
}) => {
|
|
68
|
-
const [i,
|
|
69
|
-
() =>
|
|
68
|
+
const [i, r] = D(""), a = R(
|
|
69
|
+
() => re((o) => e?.(o), t),
|
|
70
70
|
[e, t]
|
|
71
71
|
);
|
|
72
72
|
return /* @__PURE__ */ f(
|
|
73
|
-
|
|
73
|
+
Ae,
|
|
74
74
|
{
|
|
75
75
|
allowClear: !0,
|
|
76
76
|
showSearch: !0,
|
|
77
77
|
searchValue: i,
|
|
78
78
|
onSearch: (o) => {
|
|
79
|
-
|
|
79
|
+
r(o), a(o);
|
|
80
80
|
},
|
|
81
81
|
filterOption: !1,
|
|
82
82
|
...n
|
|
83
83
|
}
|
|
84
84
|
);
|
|
85
|
-
},
|
|
85
|
+
}, tt = M(et), nt = ({
|
|
86
86
|
fieldName: e,
|
|
87
87
|
formInstance: t,
|
|
88
88
|
...n
|
|
89
89
|
}) => {
|
|
90
|
-
const i =
|
|
91
|
-
return
|
|
90
|
+
const i = q.useWatch(e, t);
|
|
91
|
+
return j(() => {
|
|
92
92
|
if (i?.fileList?.length && i.fileList.some(
|
|
93
93
|
(s) => !s.type?.startsWith("image/")
|
|
94
94
|
)) {
|
|
@@ -103,201 +103,201 @@ const Qe = ({
|
|
|
103
103
|
} : null
|
|
104
104
|
);
|
|
105
105
|
}
|
|
106
|
-
}, [e, t, i]), /* @__PURE__ */ f(
|
|
106
|
+
}, [e, t, i]), /* @__PURE__ */ f(Fe, { listType: "picture-card", accept: "image/*", ...n, children: /* @__PURE__ */ f(
|
|
107
107
|
"button",
|
|
108
108
|
{
|
|
109
109
|
style: { border: 0, background: "none", cursor: "pointer" },
|
|
110
110
|
type: "button",
|
|
111
|
-
children: /* @__PURE__ */ f(
|
|
111
|
+
children: /* @__PURE__ */ f(Ne, {})
|
|
112
112
|
}
|
|
113
113
|
) });
|
|
114
|
-
},
|
|
114
|
+
}, it = M(nt), rt = ({
|
|
115
115
|
fieldName: e,
|
|
116
116
|
formInstance: t,
|
|
117
117
|
...n
|
|
118
118
|
}) => {
|
|
119
|
-
const i =
|
|
120
|
-
return /* @__PURE__ */ f(
|
|
121
|
-
},
|
|
119
|
+
const i = q.useWatch(e, t);
|
|
120
|
+
return /* @__PURE__ */ f(Fe, { fileList: i?.fileList, ...n, children: /* @__PURE__ */ f(Ee, { icon: /* @__PURE__ */ f(Ye, {}) }) });
|
|
121
|
+
}, at = M(rt), ot = ({
|
|
122
122
|
formInstance: e,
|
|
123
123
|
uploadUrl: t,
|
|
124
124
|
setFieldState: n
|
|
125
125
|
}) => {
|
|
126
|
-
const { client: i, upload:
|
|
127
|
-
if (
|
|
128
|
-
const l = t ??
|
|
126
|
+
const { client: i, upload: r, i18n: a, renderers: s } = V(), { messages: o } = a, u = P(() => {
|
|
127
|
+
if (r.upload) return r.upload;
|
|
128
|
+
const l = t ?? r.uploadUrl;
|
|
129
129
|
if (l)
|
|
130
|
-
return async ({ file:
|
|
131
|
-
const
|
|
132
|
-
file:
|
|
133
|
-
fieldCode:
|
|
134
|
-
fieldGroup:
|
|
130
|
+
return async ({ file: b, signal: p, onProgress: d, fieldCode: v, fieldGroup: _, metadata: w }) => {
|
|
131
|
+
const m = r.getPayload ? r.getPayload({
|
|
132
|
+
file: b,
|
|
133
|
+
fieldCode: v,
|
|
134
|
+
fieldGroup: _,
|
|
135
135
|
uploadUrl: l,
|
|
136
|
-
signal:
|
|
137
|
-
onProgress:
|
|
138
|
-
metadata:
|
|
136
|
+
signal: p,
|
|
137
|
+
onProgress: d,
|
|
138
|
+
metadata: w
|
|
139
139
|
}) : (() => {
|
|
140
|
-
const
|
|
141
|
-
return
|
|
142
|
-
|
|
143
|
-
}),
|
|
144
|
-
})(),
|
|
140
|
+
const g = new FormData();
|
|
141
|
+
return g.append("file", b), w && Object.entries(w).forEach(([F, k]) => {
|
|
142
|
+
g.append(F, String(k));
|
|
143
|
+
}), g;
|
|
144
|
+
})(), S = (await i.request({
|
|
145
145
|
method: "POST",
|
|
146
146
|
url: l,
|
|
147
|
-
data:
|
|
148
|
-
headers:
|
|
149
|
-
signal:
|
|
150
|
-
onUploadProgress: (
|
|
151
|
-
|
|
152
|
-
Math.round(
|
|
147
|
+
data: m,
|
|
148
|
+
headers: m instanceof FormData ? { "Content-Type": "multipart/form-data" } : void 0,
|
|
149
|
+
signal: p,
|
|
150
|
+
onUploadProgress: (g) => {
|
|
151
|
+
d?.(
|
|
152
|
+
Math.round(g.loaded * 100 / (g.total || 1))
|
|
153
153
|
);
|
|
154
154
|
}
|
|
155
155
|
})).data;
|
|
156
156
|
return {
|
|
157
|
-
uid:
|
|
158
|
-
...
|
|
159
|
-
path: String(
|
|
157
|
+
uid: b.uid,
|
|
158
|
+
...S,
|
|
159
|
+
path: String(S.path ?? "")
|
|
160
160
|
};
|
|
161
161
|
};
|
|
162
|
-
}, [i,
|
|
163
|
-
(l,
|
|
164
|
-
const { file:
|
|
162
|
+
}, [i, r, t]), c = P(
|
|
163
|
+
(l, b) => (p) => {
|
|
164
|
+
const { file: d, onProgress: v, onError: _, onSuccess: w } = p, m = new AbortController(), A = u();
|
|
165
165
|
return A ? (A({
|
|
166
|
-
file:
|
|
166
|
+
file: d,
|
|
167
167
|
fieldCode: l,
|
|
168
|
-
fieldGroup:
|
|
169
|
-
uploadUrl: t ??
|
|
170
|
-
signal:
|
|
171
|
-
onProgress: (
|
|
168
|
+
fieldGroup: b,
|
|
169
|
+
uploadUrl: t ?? r.uploadUrl,
|
|
170
|
+
signal: m.signal,
|
|
171
|
+
onProgress: (S) => v?.({ percent: S })
|
|
172
172
|
}).then(
|
|
173
|
-
(
|
|
174
|
-
...
|
|
175
|
-
uid:
|
|
176
|
-
path:
|
|
177
|
-
upload_date:
|
|
173
|
+
(S) => w?.({
|
|
174
|
+
...S,
|
|
175
|
+
uid: S.uid ?? d.uid,
|
|
176
|
+
path: S.path,
|
|
177
|
+
upload_date: Q().format("YYYY-MM-DD HH:mm:ss")
|
|
178
178
|
})
|
|
179
|
-
).catch((
|
|
179
|
+
).catch((S) => _?.(S)), { abort: () => m.abort() }) : (_?.(new Error(o.uploadError ?? "Upload not configured")), { abort() {
|
|
180
180
|
} });
|
|
181
181
|
},
|
|
182
|
-
[o.uploadError,
|
|
183
|
-
),
|
|
184
|
-
(l,
|
|
185
|
-
const
|
|
186
|
-
return
|
|
182
|
+
[o.uploadError, u, r.uploadUrl, t]
|
|
183
|
+
), h = P(
|
|
184
|
+
(l, b) => async (p) => {
|
|
185
|
+
const d = p.response?.path;
|
|
186
|
+
return d ? r.remove({ path: d, fieldCode: l, fieldGroup: b }) : !0;
|
|
187
187
|
},
|
|
188
|
-
[
|
|
189
|
-
),
|
|
188
|
+
[r]
|
|
189
|
+
), y = P(
|
|
190
190
|
(l, {
|
|
191
|
-
state:
|
|
192
|
-
options:
|
|
193
|
-
optionsLoading:
|
|
194
|
-
optionsError:
|
|
195
|
-
onSearchKeyword:
|
|
196
|
-
readOnly:
|
|
191
|
+
state: b,
|
|
192
|
+
options: p,
|
|
193
|
+
optionsLoading: d,
|
|
194
|
+
optionsError: v,
|
|
195
|
+
onSearchKeyword: _,
|
|
196
|
+
readOnly: w = !1
|
|
197
197
|
}) => {
|
|
198
|
-
const { additional_config:
|
|
198
|
+
const { additional_config: m, field: A } = l, S = A?.type?.code, g = w || l.is_readonly || b?.disabled, F = Qe(
|
|
199
199
|
l,
|
|
200
200
|
s.fields
|
|
201
201
|
);
|
|
202
202
|
if (F)
|
|
203
203
|
return F(l, {
|
|
204
|
-
state:
|
|
205
|
-
options:
|
|
206
|
-
optionsLoading:
|
|
207
|
-
optionsError:
|
|
208
|
-
onSearchKeyword:
|
|
209
|
-
readOnly:
|
|
204
|
+
state: b,
|
|
205
|
+
options: p,
|
|
206
|
+
optionsLoading: d,
|
|
207
|
+
optionsError: v,
|
|
208
|
+
onSearchKeyword: _,
|
|
209
|
+
readOnly: w,
|
|
210
210
|
formInstance: e,
|
|
211
|
-
disabled: !!
|
|
211
|
+
disabled: !!g,
|
|
212
212
|
setFieldState: n
|
|
213
213
|
});
|
|
214
|
-
const
|
|
215
|
-
switch (
|
|
214
|
+
const k = Ze(p, l);
|
|
215
|
+
switch (S) {
|
|
216
216
|
case "text":
|
|
217
|
-
return
|
|
218
|
-
|
|
217
|
+
return m?.text?.textarea ? /* @__PURE__ */ f(
|
|
218
|
+
_e.TextArea,
|
|
219
219
|
{
|
|
220
|
-
disabled:
|
|
220
|
+
disabled: g,
|
|
221
221
|
placeholder: o.inputPlaceholder(l.label),
|
|
222
|
-
rows:
|
|
222
|
+
rows: m?.text?.rows
|
|
223
223
|
}
|
|
224
224
|
) : /* @__PURE__ */ f(
|
|
225
|
-
|
|
225
|
+
_e,
|
|
226
226
|
{
|
|
227
|
-
disabled:
|
|
227
|
+
disabled: g,
|
|
228
228
|
placeholder: o.inputPlaceholder(l.label)
|
|
229
229
|
}
|
|
230
230
|
);
|
|
231
231
|
case "number":
|
|
232
232
|
return /* @__PURE__ */ f(
|
|
233
|
-
|
|
233
|
+
Be,
|
|
234
234
|
{
|
|
235
235
|
style: { width: "100%" },
|
|
236
|
-
disabled:
|
|
236
|
+
disabled: g,
|
|
237
237
|
placeholder: o.inputPlaceholder(l.label),
|
|
238
|
-
min:
|
|
239
|
-
max:
|
|
238
|
+
min: m?.number?.min,
|
|
239
|
+
max: m?.number?.max
|
|
240
240
|
}
|
|
241
241
|
);
|
|
242
242
|
case "select": {
|
|
243
|
-
const
|
|
244
|
-
disabled:
|
|
245
|
-
options:
|
|
243
|
+
const T = {
|
|
244
|
+
disabled: g,
|
|
245
|
+
options: k,
|
|
246
246
|
placeholder: o.selectPlaceholder(l.label),
|
|
247
247
|
allowClear: !0,
|
|
248
|
-
loading:
|
|
249
|
-
mode:
|
|
250
|
-
notFoundContent:
|
|
248
|
+
loading: d,
|
|
249
|
+
mode: m?.select?.multiple ? "multiple" : void 0,
|
|
250
|
+
notFoundContent: v ? o.optionError : d ? o.optionLoading : void 0
|
|
251
251
|
};
|
|
252
|
-
return
|
|
253
|
-
|
|
252
|
+
return _ ? /* @__PURE__ */ f(
|
|
253
|
+
tt,
|
|
254
254
|
{
|
|
255
|
-
...
|
|
256
|
-
onSearchKeyword:
|
|
257
|
-
searchDebounceMs:
|
|
255
|
+
...T,
|
|
256
|
+
onSearchKeyword: _,
|
|
257
|
+
searchDebounceMs: m?.select?.searchDebounceMs ?? 500
|
|
258
258
|
}
|
|
259
|
-
) : /* @__PURE__ */ f(
|
|
259
|
+
) : /* @__PURE__ */ f(Ae, { ...T, showSearch: !0, optionFilterProp: "label" });
|
|
260
260
|
}
|
|
261
261
|
case "radio":
|
|
262
|
-
return /* @__PURE__ */ f(
|
|
262
|
+
return /* @__PURE__ */ f(Ie.Group, { disabled: g, options: k });
|
|
263
263
|
case "checkbox":
|
|
264
|
-
return /* @__PURE__ */ f(
|
|
264
|
+
return /* @__PURE__ */ f(Ue.Group, { disabled: g, options: k });
|
|
265
265
|
case "datetime":
|
|
266
266
|
return /* @__PURE__ */ f(
|
|
267
|
-
|
|
267
|
+
qe,
|
|
268
268
|
{
|
|
269
269
|
style: { width: "100%" },
|
|
270
|
-
disabled:
|
|
271
|
-
showTime:
|
|
272
|
-
format:
|
|
270
|
+
disabled: g,
|
|
271
|
+
showTime: m?.datetime?.showTime,
|
|
272
|
+
format: m?.datetime?.format
|
|
273
273
|
}
|
|
274
274
|
);
|
|
275
275
|
case "file":
|
|
276
276
|
return /* @__PURE__ */ f(
|
|
277
|
-
|
|
277
|
+
at,
|
|
278
278
|
{
|
|
279
|
-
disabled:
|
|
279
|
+
disabled: g,
|
|
280
280
|
fieldName: l.code,
|
|
281
281
|
formInstance: e,
|
|
282
|
-
multiple:
|
|
283
|
-
maxCount:
|
|
284
|
-
accept:
|
|
282
|
+
multiple: m?.file?.multiple || !1,
|
|
283
|
+
maxCount: m?.file?.max,
|
|
284
|
+
accept: m?.file?.accept,
|
|
285
285
|
customRequest: c(l.code, l),
|
|
286
|
-
onRemove:
|
|
286
|
+
onRemove: h(l.code, l)
|
|
287
287
|
}
|
|
288
288
|
);
|
|
289
289
|
case "image":
|
|
290
290
|
return /* @__PURE__ */ f(
|
|
291
|
-
|
|
291
|
+
it,
|
|
292
292
|
{
|
|
293
|
-
disabled:
|
|
293
|
+
disabled: g,
|
|
294
294
|
fieldName: l.code,
|
|
295
295
|
formInstance: e,
|
|
296
|
-
multiple:
|
|
297
|
-
maxCount:
|
|
298
|
-
accept:
|
|
296
|
+
multiple: m?.image?.multiple || !1,
|
|
297
|
+
maxCount: m?.image?.max,
|
|
298
|
+
accept: m?.image?.accept ?? "image/*",
|
|
299
299
|
customRequest: c(l.code, l),
|
|
300
|
-
onRemove:
|
|
300
|
+
onRemove: h(l.code, l)
|
|
301
301
|
}
|
|
302
302
|
);
|
|
303
303
|
default:
|
|
@@ -306,19 +306,19 @@ const Qe = ({
|
|
|
306
306
|
},
|
|
307
307
|
[
|
|
308
308
|
c,
|
|
309
|
-
|
|
309
|
+
h,
|
|
310
310
|
e,
|
|
311
311
|
o,
|
|
312
312
|
s.fields,
|
|
313
313
|
n
|
|
314
314
|
]
|
|
315
315
|
);
|
|
316
|
-
return
|
|
316
|
+
return R(() => ({ getDynamicField: y }), [y]);
|
|
317
317
|
};
|
|
318
|
-
function
|
|
318
|
+
function ae(e) {
|
|
319
319
|
return JSON.stringify(e);
|
|
320
320
|
}
|
|
321
|
-
function
|
|
321
|
+
function st(e, t) {
|
|
322
322
|
const n = e.get(t);
|
|
323
323
|
if (n) {
|
|
324
324
|
if (Date.now() > n.expiresAt) {
|
|
@@ -328,17 +328,17 @@ function at(e, t) {
|
|
|
328
328
|
return n.data;
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
|
-
function
|
|
331
|
+
function lt(e, t, n, i) {
|
|
332
332
|
e.set(t, { data: n, expiresAt: Date.now() + i });
|
|
333
333
|
}
|
|
334
|
-
async function
|
|
335
|
-
const
|
|
334
|
+
async function te(e, t, n, i, r) {
|
|
335
|
+
const a = e[t];
|
|
336
336
|
if (e.cache.enabled) {
|
|
337
|
-
const c =
|
|
337
|
+
const c = st(a, n);
|
|
338
338
|
if (c !== void 0) return c;
|
|
339
339
|
}
|
|
340
|
-
const s = new AbortController(), o =
|
|
341
|
-
return e.cache.enabled &&
|
|
340
|
+
const s = new AbortController(), o = r ? AbortSignal.any([r, s.signal]) : s.signal, u = await i(o);
|
|
341
|
+
return e.cache.enabled && lt(a, n, u, e.cache.ttlMs), u;
|
|
342
342
|
}
|
|
343
343
|
function W(e, t) {
|
|
344
344
|
return t.split(".").reduce((n, i) => {
|
|
@@ -346,41 +346,41 @@ function W(e, t) {
|
|
|
346
346
|
return n[i];
|
|
347
347
|
}, e);
|
|
348
348
|
}
|
|
349
|
-
function
|
|
349
|
+
function ct(e, t) {
|
|
350
350
|
if (typeof e != "string") return e;
|
|
351
351
|
const n = e.match(/^\{\{(.+?)\}\}$/);
|
|
352
352
|
if (!n) return e;
|
|
353
|
-
const i = n[1].trim(),
|
|
354
|
-
return
|
|
353
|
+
const i = n[1].trim(), r = W(t, i);
|
|
354
|
+
return r !== void 0 ? r : e;
|
|
355
355
|
}
|
|
356
|
-
function
|
|
356
|
+
function dt(e, t) {
|
|
357
357
|
const n = {};
|
|
358
358
|
for (const i in e)
|
|
359
|
-
n[i] =
|
|
359
|
+
n[i] = ct(
|
|
360
360
|
e[i],
|
|
361
361
|
t
|
|
362
362
|
);
|
|
363
363
|
return n;
|
|
364
364
|
}
|
|
365
|
-
function
|
|
365
|
+
function Xt(e, t) {
|
|
366
366
|
const n = { ...e };
|
|
367
367
|
return t.forEach((i) => {
|
|
368
|
-
const
|
|
369
|
-
if (
|
|
368
|
+
const r = e[i.code];
|
|
369
|
+
if (r == null) return;
|
|
370
370
|
switch (i.field?.type?.code) {
|
|
371
371
|
case "datetime": {
|
|
372
|
-
const s =
|
|
372
|
+
const s = Q(r);
|
|
373
373
|
s.isValid() && (n[i.code] = s);
|
|
374
374
|
break;
|
|
375
375
|
}
|
|
376
376
|
case "file":
|
|
377
377
|
case "image": {
|
|
378
|
-
if (Array.isArray(
|
|
379
|
-
const s =
|
|
378
|
+
if (Array.isArray(r) && r.length > 0) {
|
|
379
|
+
const s = r.map((o, u) => {
|
|
380
380
|
const c = o;
|
|
381
381
|
return {
|
|
382
|
-
uid: String(c.uid ?? c.path ??
|
|
383
|
-
name: c.name ?? `file-${
|
|
382
|
+
uid: String(c.uid ?? c.path ?? u),
|
|
383
|
+
name: c.name ?? `file-${u}`,
|
|
384
384
|
status: "done",
|
|
385
385
|
percent: 100,
|
|
386
386
|
type: c.type,
|
|
@@ -395,189 +395,189 @@ function Nt(e, t) {
|
|
|
395
395
|
}
|
|
396
396
|
}), n;
|
|
397
397
|
}
|
|
398
|
-
function
|
|
399
|
-
const t = e.option_config?.api_options?.params || {}, n = e.option_config?.api_options?.data || {}, i = (
|
|
400
|
-
(
|
|
401
|
-
).map((
|
|
398
|
+
function ut(e) {
|
|
399
|
+
const t = e.option_config?.api_options?.params || {}, n = e.option_config?.api_options?.data || {}, i = (r) => Object.values(r).filter(
|
|
400
|
+
(a) => typeof a == "string" && a.startsWith("{{") && a.endsWith("}}")
|
|
401
|
+
).map((a) => a.slice(2, -2).trim());
|
|
402
402
|
return Array.from(/* @__PURE__ */ new Set([...i(t), ...i(n)]));
|
|
403
403
|
}
|
|
404
|
-
function
|
|
404
|
+
function O(e, t) {
|
|
405
405
|
const n = {};
|
|
406
406
|
for (const i in e) {
|
|
407
|
-
const
|
|
408
|
-
if (typeof
|
|
409
|
-
const
|
|
410
|
-
n[i] = t?.[
|
|
407
|
+
const r = e[i];
|
|
408
|
+
if (typeof r == "string" && r.startsWith("{{") && r.endsWith("}}")) {
|
|
409
|
+
const a = r.slice(2, -2).trim();
|
|
410
|
+
n[i] = t?.[a];
|
|
411
411
|
} else
|
|
412
|
-
n[i] =
|
|
412
|
+
n[i] = r;
|
|
413
413
|
}
|
|
414
414
|
return n;
|
|
415
415
|
}
|
|
416
|
-
function
|
|
416
|
+
function ne(e, t) {
|
|
417
417
|
return e.replace(/\{\{\s*(\w+)\s*\}\}/g, (n, i) => {
|
|
418
|
-
const
|
|
419
|
-
return
|
|
418
|
+
const r = t?.[i];
|
|
419
|
+
return r != null ? String(r) : "";
|
|
420
420
|
});
|
|
421
421
|
}
|
|
422
|
-
function
|
|
423
|
-
const n =
|
|
424
|
-
() =>
|
|
422
|
+
function ft(e, t) {
|
|
423
|
+
const n = R(
|
|
424
|
+
() => ut(e),
|
|
425
425
|
[e]
|
|
426
|
-
), i =
|
|
426
|
+
), i = q.useWatch(
|
|
427
427
|
n.length > 0 ? n : void 0,
|
|
428
428
|
t
|
|
429
429
|
);
|
|
430
|
-
return
|
|
430
|
+
return R(() => {
|
|
431
431
|
if (!n.length) return {};
|
|
432
|
-
const
|
|
433
|
-
return n.forEach((
|
|
434
|
-
Array.isArray(i) ? a
|
|
435
|
-
}),
|
|
432
|
+
const r = {};
|
|
433
|
+
return n.forEach((a, s) => {
|
|
434
|
+
Array.isArray(i) ? r[a] = i[s] : r[a] = i;
|
|
435
|
+
}), r;
|
|
436
436
|
}, [n, i]);
|
|
437
437
|
}
|
|
438
|
-
function
|
|
438
|
+
function mt({
|
|
439
439
|
group: e,
|
|
440
440
|
formInstance: t,
|
|
441
441
|
searchKeyword: n = "",
|
|
442
442
|
searchDebounceMs: i = 500
|
|
443
443
|
}) {
|
|
444
|
-
const
|
|
445
|
-
() =>
|
|
444
|
+
const r = V(), a = ft(e, t), [s, o] = D(), [u, c] = D(!1), [h, y] = D(), l = U(null), [b, p] = D(n), d = e.additional_config?.select?.search_keyword ?? !1, v = R(
|
|
445
|
+
() => re((m) => p(m), i),
|
|
446
446
|
[i]
|
|
447
447
|
);
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
}, [n,
|
|
451
|
-
const
|
|
452
|
-
const
|
|
453
|
-
if (!(!
|
|
448
|
+
j(() => {
|
|
449
|
+
d ? v(n) : p("");
|
|
450
|
+
}, [n, d, v]);
|
|
451
|
+
const _ = R(() => {
|
|
452
|
+
const m = e.option_config?.api_options?.params, A = e.option_config?.api_options?.data;
|
|
453
|
+
if (!(!m && !A))
|
|
454
454
|
return {
|
|
455
|
-
params:
|
|
456
|
-
data: A ?
|
|
455
|
+
params: m ? O(m, a) : void 0,
|
|
456
|
+
data: A ? O(A, a) : void 0
|
|
457
457
|
};
|
|
458
|
-
}, [
|
|
458
|
+
}, [a, e]), w = P(async () => {
|
|
459
459
|
if (!e.option_config || !e.is_option_api || !e.option_config.url)
|
|
460
460
|
return;
|
|
461
461
|
l.current?.abort();
|
|
462
|
-
const
|
|
463
|
-
l.current =
|
|
464
|
-
const A = e.option_config.method?.toUpperCase() === "GET" || !e.option_config.method,
|
|
462
|
+
const m = new AbortController();
|
|
463
|
+
l.current = m;
|
|
464
|
+
const A = e.option_config.method?.toUpperCase() === "GET" || !e.option_config.method, S = d ? b : "", g = ae([
|
|
465
465
|
e.code,
|
|
466
466
|
e.option_config.url,
|
|
467
467
|
e.option_config.method,
|
|
468
|
-
|
|
469
|
-
|
|
468
|
+
_,
|
|
469
|
+
S
|
|
470
470
|
]);
|
|
471
|
-
c(!0),
|
|
471
|
+
c(!0), y(void 0);
|
|
472
472
|
try {
|
|
473
|
-
const F = await
|
|
474
|
-
|
|
473
|
+
const F = await te(
|
|
474
|
+
r,
|
|
475
475
|
"optionCache",
|
|
476
|
-
|
|
477
|
-
async (
|
|
478
|
-
const
|
|
476
|
+
g,
|
|
477
|
+
async (k) => {
|
|
478
|
+
const T = await r.client.request({
|
|
479
479
|
method: e.option_config?.method || "GET",
|
|
480
480
|
url: e.option_config?.url,
|
|
481
|
-
params: A &&
|
|
482
|
-
data: !A &&
|
|
483
|
-
signal:
|
|
481
|
+
params: A && d ? { ..._?.params, keywords: S } : _?.params,
|
|
482
|
+
data: !A && d ? { ..._?.data, keywords: S } : _?.data,
|
|
483
|
+
signal: k
|
|
484
484
|
});
|
|
485
|
-
return
|
|
485
|
+
return r.parsers.optionResponse(T.data, e);
|
|
486
486
|
},
|
|
487
|
-
|
|
487
|
+
m.signal
|
|
488
488
|
);
|
|
489
|
-
|
|
489
|
+
m.signal.aborted || o(F);
|
|
490
490
|
} catch (F) {
|
|
491
|
-
|
|
491
|
+
m.signal.aborted || y(F);
|
|
492
492
|
} finally {
|
|
493
|
-
|
|
493
|
+
m.signal.aborted || c(!1);
|
|
494
494
|
}
|
|
495
|
-
}, [
|
|
496
|
-
return
|
|
495
|
+
}, [_, r, b, e, d]);
|
|
496
|
+
return j(() => (e.option_config && e.is_option_api && w(), () => l.current?.abort()), [w, e]), { options: s, isLoading: u, error: h, refetch: w };
|
|
497
497
|
}
|
|
498
|
-
const
|
|
498
|
+
const pt = ({
|
|
499
499
|
group: e,
|
|
500
500
|
formInstance: t,
|
|
501
501
|
fieldState: n,
|
|
502
502
|
setFieldState: i,
|
|
503
|
-
uploadUrl:
|
|
504
|
-
readOnly:
|
|
503
|
+
uploadUrl: r,
|
|
504
|
+
readOnly: a = !1,
|
|
505
505
|
size: s = "middle",
|
|
506
506
|
...o
|
|
507
507
|
}) => {
|
|
508
|
-
const { getDynamicField:
|
|
508
|
+
const { getDynamicField: u } = ot({
|
|
509
509
|
formInstance: t,
|
|
510
|
-
uploadUrl:
|
|
510
|
+
uploadUrl: r,
|
|
511
511
|
setFieldState: i
|
|
512
|
-
}), c =
|
|
512
|
+
}), c = q.useWatch(e.code, t), [h, y] = D(""), l = e.additional_config?.select?.search_keyword ?? !1, { options: b, isLoading: p, error: d } = mt({
|
|
513
513
|
group: e,
|
|
514
514
|
formInstance: t,
|
|
515
|
-
searchKeyword:
|
|
515
|
+
searchKeyword: h,
|
|
516
516
|
searchDebounceMs: e.additional_config?.select?.searchDebounceMs ?? 500
|
|
517
|
-
}),
|
|
518
|
-
|
|
517
|
+
}), v = P((w) => {
|
|
518
|
+
y(w);
|
|
519
519
|
}, []);
|
|
520
|
-
|
|
520
|
+
j(() => {
|
|
521
521
|
if (e.additional_config?.on_field_change?.clear?.length) {
|
|
522
|
-
const
|
|
522
|
+
const w = t.getFieldsValue(
|
|
523
523
|
e.additional_config.on_field_change.clear
|
|
524
|
-
),
|
|
525
|
-
(A) =>
|
|
524
|
+
), m = e.additional_config.on_field_change.clear.filter(
|
|
525
|
+
(A) => w?.[A]
|
|
526
526
|
);
|
|
527
|
-
|
|
527
|
+
m.length && t.resetFields(m);
|
|
528
528
|
}
|
|
529
|
-
e.additional_config?.on_field_empty?.disable?.length && e.additional_config.on_field_empty.disable.forEach((
|
|
530
|
-
i(
|
|
529
|
+
e.additional_config?.on_field_empty?.disable?.length && e.additional_config.on_field_empty.disable.forEach((w) => {
|
|
530
|
+
i(w, { disabled: !c });
|
|
531
531
|
});
|
|
532
532
|
}, [c, t, e, i]);
|
|
533
|
-
const
|
|
533
|
+
const _ = s === "small" ? 4 : 12;
|
|
534
534
|
return /* @__PURE__ */ f(
|
|
535
|
-
|
|
535
|
+
q.Item,
|
|
536
536
|
{
|
|
537
537
|
label: e.label,
|
|
538
538
|
name: e.code,
|
|
539
539
|
hidden: n?.hidden,
|
|
540
540
|
rules: [{ required: n?.required || !1 }],
|
|
541
|
-
style: { marginBottom:
|
|
541
|
+
style: { marginBottom: _, ...o.style },
|
|
542
542
|
...o,
|
|
543
|
-
children:
|
|
543
|
+
children: u(e, {
|
|
544
544
|
state: n,
|
|
545
|
-
options:
|
|
546
|
-
optionsLoading:
|
|
547
|
-
optionsError:
|
|
548
|
-
onSearchKeyword: l ?
|
|
549
|
-
readOnly:
|
|
545
|
+
options: b,
|
|
546
|
+
optionsLoading: p,
|
|
547
|
+
optionsError: d,
|
|
548
|
+
onSearchKeyword: l ? v : void 0,
|
|
549
|
+
readOnly: a
|
|
550
550
|
})
|
|
551
551
|
}
|
|
552
552
|
);
|
|
553
553
|
};
|
|
554
|
-
function
|
|
554
|
+
function ht(e, t) {
|
|
555
555
|
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;
|
|
556
556
|
}
|
|
557
|
-
const
|
|
558
|
-
function
|
|
557
|
+
const yt = M(pt, ht);
|
|
558
|
+
function bt({
|
|
559
559
|
fieldGroups: e,
|
|
560
560
|
fieldStates: t,
|
|
561
561
|
renderField: n,
|
|
562
562
|
gutter: i,
|
|
563
|
-
defaultColSpan:
|
|
563
|
+
defaultColSpan: r
|
|
564
564
|
}) {
|
|
565
|
-
return /* @__PURE__ */ f(
|
|
566
|
-
const s = t[
|
|
567
|
-
return /* @__PURE__ */ f(
|
|
565
|
+
return /* @__PURE__ */ f(We, { gutter: i, children: e.map((a) => {
|
|
566
|
+
const s = t[a.code]?.hidden ? 0 : Number(a.additional_config?.field_col_span) || r;
|
|
567
|
+
return /* @__PURE__ */ f(Ge, { xs: s, children: n(a) }, a.id);
|
|
568
568
|
}) });
|
|
569
569
|
}
|
|
570
|
-
function
|
|
571
|
-
return
|
|
570
|
+
function _t(e) {
|
|
571
|
+
return R(() => {
|
|
572
572
|
const t = e?.form?.field_groups ?? [], n = /* @__PURE__ */ new Map(), i = {};
|
|
573
|
-
t.forEach((
|
|
574
|
-
n.set(
|
|
573
|
+
t.forEach((a) => {
|
|
574
|
+
n.set(a.code, a), a.additional_config?.default !== void 0 && (i[a.code] = a.additional_config.default);
|
|
575
575
|
});
|
|
576
|
-
const
|
|
577
|
-
return { fieldGroups: t, fieldByCode: n, visibleFieldGroups:
|
|
576
|
+
const r = t.filter((a) => !a.is_hidden);
|
|
577
|
+
return { fieldGroups: t, fieldByCode: n, visibleFieldGroups: r, initialValues: i };
|
|
578
578
|
}, [e]);
|
|
579
579
|
}
|
|
580
|
-
function
|
|
580
|
+
function ve(e) {
|
|
581
581
|
const t = {};
|
|
582
582
|
return e.forEach((n) => {
|
|
583
583
|
t[n.code] = {
|
|
@@ -587,43 +587,43 @@ function he(e) {
|
|
|
587
587
|
};
|
|
588
588
|
}), t;
|
|
589
589
|
}
|
|
590
|
-
function
|
|
591
|
-
const [t, n] =
|
|
592
|
-
() =>
|
|
590
|
+
function vt(e) {
|
|
591
|
+
const [t, n] = D(
|
|
592
|
+
() => ve(e)
|
|
593
593
|
);
|
|
594
|
-
|
|
595
|
-
n(
|
|
594
|
+
j(() => {
|
|
595
|
+
n(ve(e));
|
|
596
596
|
}, [e]);
|
|
597
|
-
const i =
|
|
597
|
+
const i = P((r, a) => {
|
|
598
598
|
n((s) => ({
|
|
599
599
|
...s,
|
|
600
|
-
[
|
|
600
|
+
[r]: { ...s[r], ...a }
|
|
601
601
|
}));
|
|
602
602
|
}, []);
|
|
603
603
|
return { fieldStates: t, setFieldStates: n, setFieldState: i };
|
|
604
604
|
}
|
|
605
|
-
function
|
|
605
|
+
function wt({
|
|
606
606
|
formInstance: e,
|
|
607
607
|
fieldByCode: t,
|
|
608
608
|
relatedData: n,
|
|
609
609
|
transformers: i
|
|
610
610
|
}) {
|
|
611
|
-
return { buildProcessedValues:
|
|
611
|
+
return { buildProcessedValues: P(async () => {
|
|
612
612
|
await e.validateFields();
|
|
613
|
-
const
|
|
614
|
-
for (const c of Object.keys(
|
|
615
|
-
const
|
|
616
|
-
if (!
|
|
617
|
-
let
|
|
618
|
-
switch (
|
|
613
|
+
const a = e.getFieldsValue(), s = {};
|
|
614
|
+
for (const c of Object.keys(a)) {
|
|
615
|
+
const h = t.get(c);
|
|
616
|
+
if (!h) continue;
|
|
617
|
+
let y;
|
|
618
|
+
switch (h.field?.type?.code) {
|
|
619
619
|
case "datetime":
|
|
620
|
-
|
|
621
|
-
|
|
620
|
+
y = a[c] ? Q(a[c]).format(
|
|
621
|
+
h.additional_config?.datetime?.format
|
|
622
622
|
) : null;
|
|
623
623
|
break;
|
|
624
624
|
case "image":
|
|
625
625
|
case "file":
|
|
626
|
-
|
|
626
|
+
a[c]?.fileList?.length && (y = a[c].fileList.filter((l) => l.percent === 100).map((l) => ({
|
|
627
627
|
...l.response,
|
|
628
628
|
name: l.name,
|
|
629
629
|
type: l.type,
|
|
@@ -631,196 +631,196 @@ function _t({
|
|
|
631
631
|
})));
|
|
632
632
|
break;
|
|
633
633
|
default:
|
|
634
|
-
|
|
634
|
+
y = a[c];
|
|
635
635
|
}
|
|
636
|
-
i.transformFieldValue && (
|
|
636
|
+
i.transformFieldValue && (y = i.transformFieldValue(c, y, h)), s[c] = y;
|
|
637
637
|
}
|
|
638
638
|
let o = s;
|
|
639
639
|
return i.transformSubmitValues && (o = i.transformSubmitValues(
|
|
640
640
|
o,
|
|
641
641
|
Array.from(t.values()),
|
|
642
642
|
n
|
|
643
|
-
)), (i.parseRelatedDataTemplates ??
|
|
643
|
+
)), (i.parseRelatedDataTemplates ?? dt)(o, n ?? {});
|
|
644
644
|
}, [t, e, n, i]) };
|
|
645
645
|
}
|
|
646
|
-
const
|
|
646
|
+
const gt = He(
|
|
647
647
|
({
|
|
648
648
|
formConfig: e,
|
|
649
649
|
formInstance: t,
|
|
650
650
|
relatedData: n,
|
|
651
651
|
uploadUrl: i,
|
|
652
|
-
uploadResourceUrl:
|
|
653
|
-
submitTrackingUrl:
|
|
652
|
+
uploadResourceUrl: r,
|
|
653
|
+
submitTrackingUrl: a,
|
|
654
654
|
onBeforeSubmit: s,
|
|
655
655
|
onSubmitSuccess: o,
|
|
656
|
-
onSubmitError:
|
|
656
|
+
onSubmitError: u,
|
|
657
657
|
isRedirectAfterCreate: c,
|
|
658
|
-
onRedirect:
|
|
659
|
-
size:
|
|
658
|
+
onRedirect: h,
|
|
659
|
+
size: y = "middle",
|
|
660
660
|
manualSubmit: l = !1,
|
|
661
|
-
onValuesChange:
|
|
662
|
-
readOnly:
|
|
663
|
-
submitDebounceMs:
|
|
664
|
-
gutter:
|
|
665
|
-
defaultColSpan:
|
|
666
|
-
submitButtonLabel:
|
|
667
|
-
},
|
|
668
|
-
const { message: A } =
|
|
661
|
+
onValuesChange: b,
|
|
662
|
+
readOnly: p = !1,
|
|
663
|
+
submitDebounceMs: d,
|
|
664
|
+
gutter: v = [8, 0],
|
|
665
|
+
defaultColSpan: _ = 12,
|
|
666
|
+
submitButtonLabel: w
|
|
667
|
+
}, m) => {
|
|
668
|
+
const { message: A } = Ke.useApp(), S = V(), { i18n: g, client: F, parsers: k, redirectHandler: T, renderers: G, transformers: K } = S, le = i ?? r, ce = d ?? S.submitDebounceMs, de = w ?? g.messages.submit, { fieldGroups: C, fieldByCode: Le, initialValues: $ } = _t(e), { fieldStates: H, setFieldState: ue } = vt(C), { buildProcessedValues: z } = wt({
|
|
669
669
|
formInstance: t,
|
|
670
|
-
fieldByCode:
|
|
670
|
+
fieldByCode: Le,
|
|
671
671
|
relatedData: n,
|
|
672
|
-
transformers:
|
|
673
|
-
}),
|
|
674
|
-
|
|
675
|
-
if (Object.keys(
|
|
676
|
-
const
|
|
677
|
-
t.setFieldsValue(
|
|
672
|
+
transformers: K
|
|
673
|
+
}), N = U(!1), [fe, me] = D(!1), [pe, he] = D(!1);
|
|
674
|
+
j(() => {
|
|
675
|
+
if (Object.keys($).length > 0) {
|
|
676
|
+
const E = K.normalizeInitialValues ? K.normalizeInitialValues($, C) : $;
|
|
677
|
+
t.setFieldsValue(E);
|
|
678
678
|
}
|
|
679
|
-
}, [
|
|
680
|
-
const
|
|
681
|
-
if (!
|
|
682
|
-
|
|
679
|
+
}, [C, t, $, K]);
|
|
680
|
+
const Y = P(async () => {
|
|
681
|
+
if (!N.current) {
|
|
682
|
+
N.current = !0, me(!0);
|
|
683
683
|
try {
|
|
684
|
-
let
|
|
684
|
+
let E = await z();
|
|
685
685
|
try {
|
|
686
|
-
|
|
686
|
+
a && (he(!0), await F.request({
|
|
687
687
|
method: "POST",
|
|
688
|
-
url:
|
|
689
|
-
data:
|
|
688
|
+
url: a,
|
|
689
|
+
data: E
|
|
690
690
|
}));
|
|
691
|
-
const
|
|
692
|
-
if (
|
|
693
|
-
|
|
694
|
-
} catch (
|
|
695
|
-
console.error(
|
|
691
|
+
const x = await s?.(E);
|
|
692
|
+
if (x === !1) return;
|
|
693
|
+
x && typeof x == "object" && (E = x);
|
|
694
|
+
} catch (x) {
|
|
695
|
+
console.error(x);
|
|
696
696
|
return;
|
|
697
697
|
} finally {
|
|
698
|
-
|
|
698
|
+
he(!1);
|
|
699
699
|
}
|
|
700
|
-
const
|
|
700
|
+
const B = await F.request({
|
|
701
701
|
method: e.method,
|
|
702
702
|
url: e.action,
|
|
703
|
-
data:
|
|
703
|
+
data: E
|
|
704
704
|
});
|
|
705
705
|
t.resetFields(
|
|
706
|
-
|
|
706
|
+
C.filter((x) => !x.is_hidden).map((x) => x.code)
|
|
707
707
|
);
|
|
708
|
-
const
|
|
709
|
-
c &&
|
|
710
|
-
values:
|
|
711
|
-
response:
|
|
712
|
-
data:
|
|
708
|
+
const X = k.submitResponse(B.data);
|
|
709
|
+
c && X.redirectUrl && (h ?? T)(X.redirectUrl, "_blank"), o?.({
|
|
710
|
+
values: E,
|
|
711
|
+
response: B.data,
|
|
712
|
+
data: X.data ?? B.data
|
|
713
713
|
});
|
|
714
|
-
} catch (
|
|
715
|
-
const
|
|
714
|
+
} catch (E) {
|
|
715
|
+
const B = E;
|
|
716
716
|
A.error(
|
|
717
|
-
|
|
718
|
-
),
|
|
717
|
+
B?.response?.data?.message ?? g.messages.submitError
|
|
718
|
+
), u?.(E);
|
|
719
719
|
} finally {
|
|
720
|
-
|
|
720
|
+
N.current = !1, me(!1);
|
|
721
721
|
}
|
|
722
722
|
}
|
|
723
723
|
}, [
|
|
724
|
-
|
|
724
|
+
z,
|
|
725
725
|
F,
|
|
726
|
-
|
|
726
|
+
C,
|
|
727
727
|
e.action,
|
|
728
728
|
e.method,
|
|
729
729
|
t,
|
|
730
|
-
|
|
730
|
+
g.messages.submitError,
|
|
731
731
|
c,
|
|
732
732
|
A,
|
|
733
733
|
s,
|
|
734
|
-
|
|
735
|
-
|
|
734
|
+
h,
|
|
735
|
+
u,
|
|
736
736
|
o,
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
737
|
+
k,
|
|
738
|
+
T,
|
|
739
|
+
a
|
|
740
740
|
]);
|
|
741
|
-
|
|
742
|
-
|
|
741
|
+
ze(
|
|
742
|
+
m,
|
|
743
743
|
() => ({
|
|
744
|
-
submit:
|
|
745
|
-
getProcessedValues:
|
|
746
|
-
isSubmitting: () =>
|
|
744
|
+
submit: Y,
|
|
745
|
+
getProcessedValues: z,
|
|
746
|
+
isSubmitting: () => N.current
|
|
747
747
|
}),
|
|
748
|
-
[
|
|
748
|
+
[z, Y]
|
|
749
749
|
);
|
|
750
|
-
const
|
|
751
|
-
() =>
|
|
752
|
-
|
|
753
|
-
},
|
|
754
|
-
[
|
|
755
|
-
),
|
|
756
|
-
(
|
|
757
|
-
|
|
750
|
+
const ye = R(
|
|
751
|
+
() => re(() => {
|
|
752
|
+
Y();
|
|
753
|
+
}, ce),
|
|
754
|
+
[Y, ce]
|
|
755
|
+
), be = P(
|
|
756
|
+
(E) => /* @__PURE__ */ f(
|
|
757
|
+
yt,
|
|
758
758
|
{
|
|
759
|
-
group:
|
|
759
|
+
group: E,
|
|
760
760
|
formInstance: t,
|
|
761
|
-
fieldState:
|
|
762
|
-
setFieldState:
|
|
763
|
-
uploadUrl:
|
|
764
|
-
readOnly:
|
|
765
|
-
size:
|
|
761
|
+
fieldState: H[E.code],
|
|
762
|
+
setFieldState: ue,
|
|
763
|
+
uploadUrl: le,
|
|
764
|
+
readOnly: p,
|
|
765
|
+
size: y
|
|
766
766
|
},
|
|
767
|
-
|
|
767
|
+
E.id
|
|
768
768
|
),
|
|
769
769
|
[
|
|
770
|
-
|
|
770
|
+
H,
|
|
771
771
|
t,
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
772
|
+
p,
|
|
773
|
+
le,
|
|
774
|
+
ue,
|
|
775
|
+
y
|
|
776
776
|
]
|
|
777
|
-
),
|
|
778
|
-
fieldGroups:
|
|
779
|
-
fieldStates:
|
|
780
|
-
renderField:
|
|
781
|
-
gutter:
|
|
782
|
-
defaultColSpan:
|
|
783
|
-
size:
|
|
777
|
+
), je = G.layout ? G.layout({
|
|
778
|
+
fieldGroups: C,
|
|
779
|
+
fieldStates: H,
|
|
780
|
+
renderField: be,
|
|
781
|
+
gutter: v,
|
|
782
|
+
defaultColSpan: _,
|
|
783
|
+
size: y
|
|
784
784
|
}) : /* @__PURE__ */ f(
|
|
785
|
-
|
|
785
|
+
bt,
|
|
786
786
|
{
|
|
787
|
-
fieldGroups:
|
|
788
|
-
fieldStates:
|
|
789
|
-
renderField:
|
|
790
|
-
gutter:
|
|
791
|
-
defaultColSpan:
|
|
792
|
-
size:
|
|
787
|
+
fieldGroups: C,
|
|
788
|
+
fieldStates: H,
|
|
789
|
+
renderField: be,
|
|
790
|
+
gutter: v,
|
|
791
|
+
defaultColSpan: _,
|
|
792
|
+
size: y
|
|
793
793
|
}
|
|
794
|
-
),
|
|
795
|
-
onSubmit:
|
|
796
|
-
loading:
|
|
797
|
-
label:
|
|
798
|
-
}) : /* @__PURE__ */ f(
|
|
799
|
-
|
|
794
|
+
), Ve = !l && !p && (G.submitActions ? G.submitActions({
|
|
795
|
+
onSubmit: ye,
|
|
796
|
+
loading: fe || pe,
|
|
797
|
+
label: de
|
|
798
|
+
}) : /* @__PURE__ */ f(Re, { justify: "flex-end", children: /* @__PURE__ */ f(
|
|
799
|
+
Ee,
|
|
800
800
|
{
|
|
801
801
|
type: "primary",
|
|
802
|
-
onClick:
|
|
803
|
-
loading:
|
|
804
|
-
children:
|
|
802
|
+
onClick: ye,
|
|
803
|
+
loading: fe || pe,
|
|
804
|
+
children: de
|
|
805
805
|
}
|
|
806
806
|
) }));
|
|
807
|
-
return /* @__PURE__ */
|
|
808
|
-
|
|
807
|
+
return /* @__PURE__ */ Oe(
|
|
808
|
+
q,
|
|
809
809
|
{
|
|
810
810
|
layout: "vertical",
|
|
811
811
|
form: t,
|
|
812
|
-
size:
|
|
813
|
-
onValuesChange:
|
|
812
|
+
size: y,
|
|
813
|
+
onValuesChange: b,
|
|
814
814
|
children: [
|
|
815
|
-
|
|
816
|
-
|
|
815
|
+
je,
|
|
816
|
+
Ve
|
|
817
817
|
]
|
|
818
818
|
}
|
|
819
819
|
);
|
|
820
820
|
}
|
|
821
821
|
);
|
|
822
|
-
|
|
823
|
-
function
|
|
822
|
+
gt.displayName = "DynamicForm";
|
|
823
|
+
function xe(e) {
|
|
824
824
|
if (!e) return;
|
|
825
825
|
const { mode: t } = e;
|
|
826
826
|
if (t === "api" && e.api?.url)
|
|
@@ -853,110 +853,110 @@ function Fe(e) {
|
|
|
853
853
|
};
|
|
854
854
|
}
|
|
855
855
|
}
|
|
856
|
-
function
|
|
856
|
+
function we(e) {
|
|
857
857
|
return {
|
|
858
858
|
value: e,
|
|
859
859
|
id: e
|
|
860
860
|
};
|
|
861
861
|
}
|
|
862
|
-
function
|
|
862
|
+
function St(e, t) {
|
|
863
863
|
const n = t.method || "GET", i = n.toUpperCase() === "GET";
|
|
864
864
|
if (t.url_template)
|
|
865
|
-
return (Array.isArray(e) ? e.filter((
|
|
866
|
-
const c =
|
|
865
|
+
return (Array.isArray(e) ? e.filter((u) => u != null && u !== "") : e != null && e !== "" ? [e] : []).map((u) => {
|
|
866
|
+
const c = we(u), h = ne(t.url, c), y = t.params ? O(t.params, c) : void 0, l = t.data ? O(t.data, c) : void 0;
|
|
867
867
|
return {
|
|
868
868
|
method: n,
|
|
869
|
-
url:
|
|
870
|
-
params: i ?
|
|
869
|
+
url: h,
|
|
870
|
+
params: i ? y : void 0,
|
|
871
871
|
data: i ? void 0 : l
|
|
872
872
|
};
|
|
873
873
|
});
|
|
874
|
-
const
|
|
874
|
+
const r = we(e), a = t.params ? O(t.params, r) : void 0, s = t.data ? O(t.data, r) : void 0;
|
|
875
875
|
return [
|
|
876
876
|
{
|
|
877
877
|
method: n,
|
|
878
878
|
url: t.url,
|
|
879
|
-
params: i ?
|
|
879
|
+
params: i ? a : void 0,
|
|
880
880
|
data: i ? void 0 : s
|
|
881
881
|
}
|
|
882
882
|
];
|
|
883
883
|
}
|
|
884
|
-
function
|
|
884
|
+
function Pe(e, t) {
|
|
885
885
|
const n = t.data_path ? W(e, t.data_path) : e;
|
|
886
886
|
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] : [];
|
|
887
887
|
}
|
|
888
|
-
function
|
|
889
|
-
return
|
|
888
|
+
function Me(e, t) {
|
|
889
|
+
return Pt(e, t.mapping_attr);
|
|
890
890
|
}
|
|
891
|
-
function
|
|
892
|
-
return
|
|
891
|
+
function Te(e, t) {
|
|
892
|
+
return Mt(t.link, e);
|
|
893
893
|
}
|
|
894
|
-
async function
|
|
895
|
-
const
|
|
896
|
-
if (!
|
|
897
|
-
const
|
|
898
|
-
|
|
894
|
+
async function At(e, t, n, i) {
|
|
895
|
+
const r = St(e, t);
|
|
896
|
+
if (!r.length) return [];
|
|
897
|
+
const a = await Promise.all(
|
|
898
|
+
r.map((o) => n({ ...o, signal: i }))
|
|
899
899
|
), s = [];
|
|
900
|
-
for (const o of
|
|
901
|
-
s.push(...
|
|
900
|
+
for (const o of a)
|
|
901
|
+
s.push(...Pe(o.data, t));
|
|
902
902
|
return s;
|
|
903
903
|
}
|
|
904
|
-
function
|
|
904
|
+
function I(e) {
|
|
905
905
|
return !!(e == null || e === "" || Array.isArray(e) && e.length === 0);
|
|
906
906
|
}
|
|
907
|
-
function
|
|
907
|
+
function Ft(e, t) {
|
|
908
908
|
const n = e.option_config?.api_options?.params, i = e.option_config?.api_options?.data;
|
|
909
909
|
if (!n && !i) return;
|
|
910
|
-
const
|
|
910
|
+
const r = (a) => {
|
|
911
911
|
const s = {};
|
|
912
|
-
for (const o in
|
|
913
|
-
if (typeof
|
|
914
|
-
const
|
|
915
|
-
s[o] = t?.[
|
|
912
|
+
for (const o in a)
|
|
913
|
+
if (typeof a[o] == "string" && a[o].startsWith("{{") && a[o].endsWith("}}")) {
|
|
914
|
+
const u = a[o].slice(2, -2).trim();
|
|
915
|
+
s[o] = t?.[u];
|
|
916
916
|
} else
|
|
917
|
-
s[o] =
|
|
917
|
+
s[o] = a[o];
|
|
918
918
|
return s;
|
|
919
919
|
};
|
|
920
920
|
return {
|
|
921
|
-
params: n ?
|
|
922
|
-
data: i ?
|
|
921
|
+
params: n ? r(n) : void 0,
|
|
922
|
+
data: i ? r(i) : void 0
|
|
923
923
|
};
|
|
924
924
|
}
|
|
925
|
-
function
|
|
925
|
+
function Et(e, t) {
|
|
926
926
|
const n = t.option_config?.label_attr, i = t.option_config?.value_attr || "";
|
|
927
927
|
if (n?.length) {
|
|
928
|
-
const
|
|
929
|
-
return e[
|
|
928
|
+
const r = n.join(" - ");
|
|
929
|
+
return e[r] !== void 0 ? String(e[r]) : n.map((a) => e[a]).filter((a) => a != null && a !== "").join(" - ");
|
|
930
930
|
}
|
|
931
931
|
return String(e[i] ?? "");
|
|
932
932
|
}
|
|
933
|
-
function
|
|
933
|
+
function Rt(e, t) {
|
|
934
934
|
if (!t?.length) return null;
|
|
935
|
-
const i = (Array.isArray(e) ? e : [e]).map((
|
|
935
|
+
const i = (Array.isArray(e) ? e : [e]).map((r) => t.find((a) => String(a.value) === String(r))?.label).filter((r) => !!r);
|
|
936
936
|
return i.length ? i.join(", ") : null;
|
|
937
937
|
}
|
|
938
|
-
function
|
|
939
|
-
if (
|
|
940
|
-
const i = t.option_config?.value_attr || "value",
|
|
938
|
+
function kt(e, t, n) {
|
|
939
|
+
if (I(e)) return null;
|
|
940
|
+
const i = t.option_config?.value_attr || "value", r = Array.isArray(e) ? e : [e];
|
|
941
941
|
if (t.is_option_api && n?.length) {
|
|
942
|
-
const s =
|
|
943
|
-
const
|
|
942
|
+
const s = r.map((o) => {
|
|
943
|
+
const u = n.find(
|
|
944
944
|
(c) => String(c[i]) === String(o)
|
|
945
945
|
);
|
|
946
|
-
return
|
|
946
|
+
return u ? Et(u, t) : String(o);
|
|
947
947
|
}).filter(Boolean);
|
|
948
948
|
return s.length ? s.join(", ") : null;
|
|
949
949
|
}
|
|
950
|
-
const
|
|
951
|
-
return
|
|
950
|
+
const a = Rt(e, t.metas);
|
|
951
|
+
return a || r.map(String).join(", ");
|
|
952
952
|
}
|
|
953
|
-
function
|
|
954
|
-
if (
|
|
955
|
-
const n = t.additional_config?.datetime?.format, i =
|
|
953
|
+
function Dt(e, t) {
|
|
954
|
+
if (I(e)) return null;
|
|
955
|
+
const n = t.additional_config?.datetime?.format, i = Q(e);
|
|
956
956
|
return i.isValid() ? n ? i.format(n) : i.format("YYYY-MM-DD HH:mm:ss") : String(e);
|
|
957
957
|
}
|
|
958
|
-
function
|
|
959
|
-
if (
|
|
958
|
+
function xt(e) {
|
|
959
|
+
if (I(e)) return null;
|
|
960
960
|
if (Array.isArray(e)) {
|
|
961
961
|
const t = e.map(
|
|
962
962
|
(n) => typeof n == "object" && n && "name" in n ? String(n.name) : String(n)
|
|
@@ -965,20 +965,20 @@ function kt(e) {
|
|
|
965
965
|
}
|
|
966
966
|
return String(e);
|
|
967
967
|
}
|
|
968
|
-
function
|
|
968
|
+
function Pt(e, t) {
|
|
969
969
|
return t?.length ? t.map((n) => {
|
|
970
970
|
const i = W(e, n) ?? e[n];
|
|
971
971
|
return i != null ? String(i) : "";
|
|
972
972
|
}).filter(Boolean).join(" - ") : JSON.stringify(e);
|
|
973
973
|
}
|
|
974
|
-
function
|
|
974
|
+
function Mt(e, t) {
|
|
975
975
|
return e ? e.replace(/\{\{(.+?)\}\}/g, (n, i) => {
|
|
976
|
-
const
|
|
977
|
-
return
|
|
976
|
+
const r = i.trim(), a = W(t, r) ?? t[r];
|
|
977
|
+
return a != null ? String(a) : "";
|
|
978
978
|
}) : null;
|
|
979
979
|
}
|
|
980
|
-
function
|
|
981
|
-
if (
|
|
980
|
+
function ge(e, t, n) {
|
|
981
|
+
if (I(e)) return null;
|
|
982
982
|
switch (t?.mode ?? "formatted") {
|
|
983
983
|
case "raw":
|
|
984
984
|
case "formatted":
|
|
@@ -986,23 +986,23 @@ function be(e, t, n) {
|
|
|
986
986
|
case "api":
|
|
987
987
|
case "api_ids":
|
|
988
988
|
case "api_detail": {
|
|
989
|
-
const
|
|
990
|
-
if (!n || !
|
|
989
|
+
const r = xe(t);
|
|
990
|
+
if (!n || !r)
|
|
991
991
|
return Array.isArray(e) ? e.map(String).join(", ") : String(e);
|
|
992
|
-
const
|
|
993
|
-
return
|
|
994
|
-
const
|
|
995
|
-
return c ? `${
|
|
992
|
+
const a = Pe(n, r);
|
|
993
|
+
return a.length ? a.map((o) => {
|
|
994
|
+
const u = Me(o, r), c = Te(o, r);
|
|
995
|
+
return c ? `${u} (${c})` : u;
|
|
996
996
|
}).filter(Boolean).join(", ") || null : String(e);
|
|
997
997
|
}
|
|
998
998
|
default:
|
|
999
999
|
return String(e);
|
|
1000
1000
|
}
|
|
1001
1001
|
}
|
|
1002
|
-
function
|
|
1002
|
+
function Tt(e, t, n) {
|
|
1003
1003
|
const i = e.additional_config?.view_value;
|
|
1004
1004
|
if (i?.mode === "api" || i?.mode === "api_ids" || i?.mode === "api_detail")
|
|
1005
|
-
return
|
|
1005
|
+
return ge(
|
|
1006
1006
|
t,
|
|
1007
1007
|
i,
|
|
1008
1008
|
n.viewValueFetched
|
|
@@ -1010,141 +1010,188 @@ function xt(e, t, n) {
|
|
|
1010
1010
|
switch (e.field?.type?.code) {
|
|
1011
1011
|
case "text":
|
|
1012
1012
|
case "number":
|
|
1013
|
-
return
|
|
1013
|
+
return I(t) ? null : String(t);
|
|
1014
1014
|
case "datetime":
|
|
1015
|
-
return
|
|
1015
|
+
return Dt(t, e);
|
|
1016
1016
|
case "select":
|
|
1017
1017
|
case "radio":
|
|
1018
1018
|
case "checkbox":
|
|
1019
|
-
return
|
|
1019
|
+
return kt(t, e, n.optionList);
|
|
1020
1020
|
case "image":
|
|
1021
1021
|
case "file":
|
|
1022
|
-
return
|
|
1022
|
+
return xt(t);
|
|
1023
1023
|
default:
|
|
1024
|
-
return i ?
|
|
1024
|
+
return i ? ge(
|
|
1025
1025
|
t,
|
|
1026
1026
|
i,
|
|
1027
1027
|
n.viewValueFetched
|
|
1028
|
-
) :
|
|
1028
|
+
) : I(t) ? null : String(t);
|
|
1029
1029
|
}
|
|
1030
1030
|
}
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1031
|
+
const J = /* @__PURE__ */ new Map(), Ct = 3e4;
|
|
1032
|
+
function Lt(e) {
|
|
1033
|
+
const t = J.get(e);
|
|
1034
|
+
if (t) {
|
|
1035
|
+
if (Date.now() > t.expiresAt) {
|
|
1036
|
+
J.delete(e);
|
|
1037
|
+
return;
|
|
1038
|
+
}
|
|
1039
|
+
return t.error;
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
function Se(e, t) {
|
|
1043
|
+
J.set(e, {
|
|
1044
|
+
error: t,
|
|
1045
|
+
expiresAt: Date.now() + Ct
|
|
1046
|
+
});
|
|
1047
|
+
}
|
|
1048
|
+
function oe(e, t, n = !0) {
|
|
1049
|
+
const i = V(), [r, a] = D(), [s, o] = D(!1), [u, c] = D(), h = U(t), y = U(i);
|
|
1050
|
+
h.current = t, y.current = i;
|
|
1051
|
+
const l = ae(e);
|
|
1052
|
+
return j(() => {
|
|
1053
|
+
if (!n) {
|
|
1054
|
+
a(void 0), c(void 0), o(!1);
|
|
1055
|
+
return;
|
|
1056
|
+
}
|
|
1057
|
+
const p = Lt(l);
|
|
1058
|
+
if (p !== void 0) {
|
|
1059
|
+
c(p), o(!1);
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
const d = new AbortController();
|
|
1063
|
+
return o(!0), c(void 0), (async () => {
|
|
1064
|
+
try {
|
|
1065
|
+
const _ = await te(
|
|
1066
|
+
y.current,
|
|
1067
|
+
"viewCache",
|
|
1068
|
+
l,
|
|
1069
|
+
(w) => h.current(w),
|
|
1070
|
+
d.signal
|
|
1071
|
+
);
|
|
1072
|
+
d.signal.aborted || (a(_), c(void 0));
|
|
1073
|
+
} catch (_) {
|
|
1074
|
+
d.signal.aborted || (Se(l, _), c(_));
|
|
1075
|
+
} finally {
|
|
1076
|
+
d.signal.aborted || o(!1);
|
|
1077
|
+
}
|
|
1078
|
+
})(), () => d.abort();
|
|
1079
|
+
}, [n, l]), { data: r, isLoading: s, error: u, refetch: async () => {
|
|
1080
|
+
if (J.delete(l), !n) return;
|
|
1081
|
+
const p = new AbortController();
|
|
1038
1082
|
o(!0), c(void 0);
|
|
1039
1083
|
try {
|
|
1040
|
-
const
|
|
1041
|
-
|
|
1084
|
+
const d = await te(
|
|
1085
|
+
y.current,
|
|
1042
1086
|
"viewCache",
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1087
|
+
l,
|
|
1088
|
+
(v) => h.current(v),
|
|
1089
|
+
p.signal
|
|
1046
1090
|
);
|
|
1047
|
-
return
|
|
1048
|
-
} catch (
|
|
1049
|
-
throw l
|
|
1091
|
+
return a(d), d;
|
|
1092
|
+
} catch (d) {
|
|
1093
|
+
throw Se(l, d), c(d), d;
|
|
1050
1094
|
} finally {
|
|
1051
|
-
|
|
1095
|
+
o(!1);
|
|
1052
1096
|
}
|
|
1053
|
-
}
|
|
1054
|
-
return L(() => (n && b(), () => y.current?.abort()), [n, b]), { data: a, isLoading: s, error: d, refetch: b };
|
|
1097
|
+
} };
|
|
1055
1098
|
}
|
|
1056
|
-
const
|
|
1099
|
+
const jt = ({
|
|
1057
1100
|
value: e,
|
|
1058
1101
|
code: t,
|
|
1059
1102
|
modeConfig: n,
|
|
1060
1103
|
viewConfig: i
|
|
1061
1104
|
}) => {
|
|
1062
|
-
const { client:
|
|
1063
|
-
|
|
1064
|
-
|
|
1105
|
+
const { client: r, renderers: a, i18n: s } = V(), o = R(
|
|
1106
|
+
() => n ?? (i ? xe(i) : void 0),
|
|
1107
|
+
[n, i]
|
|
1108
|
+
), u = R(
|
|
1109
|
+
() => ["api_view", t, e, o?.url, o?.method, o?.data_path],
|
|
1110
|
+
[t, e, o?.url, o?.method, o?.data_path]
|
|
1111
|
+
), c = P(
|
|
1112
|
+
async (d) => o ? At(
|
|
1065
1113
|
e,
|
|
1066
1114
|
o,
|
|
1067
|
-
(
|
|
1068
|
-
p
|
|
1115
|
+
(v) => r.request({ ...v, signal: d })
|
|
1069
1116
|
) : [],
|
|
1070
|
-
|
|
1071
|
-
), b = (
|
|
1117
|
+
[r, o, e]
|
|
1118
|
+
), { data: h, isLoading: y, error: l } = oe(u, c, !!(e && o?.url)), b = (d, v, _) => a.link ? a.link({ url: d, label: v, data: _ }) : /* @__PURE__ */ f("a", { href: d, target: "_blank", rel: "noreferrer", children: v }), p = (d, v) => {
|
|
1072
1119
|
if (!o) return null;
|
|
1073
|
-
const
|
|
1074
|
-
return /* @__PURE__ */ f("div", { children:
|
|
1120
|
+
const _ = Me(d, o), w = Te(d, o), m = w ? b(w, _, d) : _;
|
|
1121
|
+
return /* @__PURE__ */ f("div", { children: m }, d.id ?? v);
|
|
1075
1122
|
};
|
|
1076
|
-
return
|
|
1077
|
-
},
|
|
1078
|
-
function
|
|
1123
|
+
return y ? /* @__PURE__ */ f(L, { children: a.viewLoading?.() ?? /* @__PURE__ */ f(ke, { size: "small" }) }) : l ? /* @__PURE__ */ f(L, { children: a.viewError?.(l) ?? s.messages.viewError }) : h?.length ? o?.result_type === "object" && h.length === 1 ? p(h[0], 0) : /* @__PURE__ */ f(Re, { vertical: !0, children: h.map(p) }) : /* @__PURE__ */ f(L, { children: a.viewEmpty?.() ?? s.messages.viewEmpty });
|
|
1124
|
+
}, se = M(jt);
|
|
1125
|
+
function Vt(e) {
|
|
1079
1126
|
return !!(e.option_config && e.is_option_api);
|
|
1080
1127
|
}
|
|
1081
|
-
function
|
|
1128
|
+
function Ot(e) {
|
|
1082
1129
|
return e === "api" || e === "api_ids" || e === "api_detail";
|
|
1083
1130
|
}
|
|
1084
|
-
function
|
|
1085
|
-
const n =
|
|
1131
|
+
function qt(e, t) {
|
|
1132
|
+
const n = V(), i = ae([
|
|
1086
1133
|
"viewModeOptions",
|
|
1087
|
-
e.map((
|
|
1134
|
+
e.map((a) => a.code),
|
|
1088
1135
|
t
|
|
1089
|
-
]), { data:
|
|
1136
|
+
]), { data: r } = oe(
|
|
1090
1137
|
[i],
|
|
1091
|
-
async (
|
|
1138
|
+
async (a) => {
|
|
1092
1139
|
const s = {};
|
|
1093
1140
|
return await Promise.all(
|
|
1094
1141
|
e.map(async (o) => {
|
|
1095
1142
|
if (!o.option_config?.url) return;
|
|
1096
|
-
const
|
|
1143
|
+
const u = Ft(o, t), c = o.option_config.method?.toUpperCase() === "GET" || !o.option_config.method, h = await n.client.request({
|
|
1097
1144
|
method: o.option_config.method || "GET",
|
|
1098
1145
|
url: o.option_config.url,
|
|
1099
|
-
params: c ?
|
|
1100
|
-
data: c ? void 0 :
|
|
1101
|
-
signal:
|
|
1146
|
+
params: c ? u?.params : void 0,
|
|
1147
|
+
data: c ? void 0 : u?.data,
|
|
1148
|
+
signal: a
|
|
1102
1149
|
});
|
|
1103
1150
|
s[o.code] = {
|
|
1104
|
-
optionList: n.parsers.optionResponse(
|
|
1151
|
+
optionList: n.parsers.optionResponse(h.data, o)
|
|
1105
1152
|
};
|
|
1106
1153
|
})
|
|
1107
1154
|
), s;
|
|
1108
1155
|
},
|
|
1109
1156
|
e.length > 0
|
|
1110
1157
|
);
|
|
1111
|
-
return
|
|
1158
|
+
return r ?? {};
|
|
1112
1159
|
}
|
|
1113
|
-
const
|
|
1160
|
+
const Zt = ({
|
|
1114
1161
|
formConfig: e,
|
|
1115
1162
|
formValues: t
|
|
1116
1163
|
}) => {
|
|
1117
|
-
const n = e?.form?.field_groups ?? [], i =
|
|
1118
|
-
() => n.filter(
|
|
1164
|
+
const n = e?.form?.field_groups ?? [], i = R(
|
|
1165
|
+
() => n.filter(Vt),
|
|
1119
1166
|
[n]
|
|
1120
|
-
),
|
|
1121
|
-
return
|
|
1122
|
-
const o = t?.[s.code],
|
|
1123
|
-
if (
|
|
1167
|
+
), r = qt(i, t);
|
|
1168
|
+
return R(() => n.filter((s) => !s.is_hidden).map((s) => {
|
|
1169
|
+
const o = t?.[s.code], u = s.additional_config?.view_value, c = u?.mode;
|
|
1170
|
+
if (Ot(c) && u)
|
|
1124
1171
|
return {
|
|
1125
1172
|
key: s.code,
|
|
1126
1173
|
label: s.label,
|
|
1127
1174
|
rawValue: o,
|
|
1128
1175
|
viewValue: /* @__PURE__ */ f(
|
|
1129
|
-
|
|
1176
|
+
se,
|
|
1130
1177
|
{
|
|
1131
1178
|
code: s.code,
|
|
1132
1179
|
value: o,
|
|
1133
|
-
viewConfig:
|
|
1180
|
+
viewConfig: u
|
|
1134
1181
|
}
|
|
1135
1182
|
),
|
|
1136
1183
|
field_group: s
|
|
1137
1184
|
};
|
|
1138
|
-
const
|
|
1185
|
+
const h = r[s.code] ?? {};
|
|
1139
1186
|
return {
|
|
1140
1187
|
key: s.code,
|
|
1141
1188
|
label: s.label,
|
|
1142
1189
|
rawValue: o,
|
|
1143
|
-
viewValue:
|
|
1190
|
+
viewValue: Tt(s, o, h),
|
|
1144
1191
|
field_group: s
|
|
1145
1192
|
};
|
|
1146
|
-
}), [
|
|
1147
|
-
},
|
|
1193
|
+
}), [r, n, t]);
|
|
1194
|
+
}, Ut = ({
|
|
1148
1195
|
code: e,
|
|
1149
1196
|
value: t,
|
|
1150
1197
|
fieldGroup: n
|
|
@@ -1156,25 +1203,48 @@ const Yt = ({
|
|
|
1156
1203
|
case "api":
|
|
1157
1204
|
case "api_ids":
|
|
1158
1205
|
case "api_detail":
|
|
1159
|
-
return /* @__PURE__ */ f(
|
|
1206
|
+
return /* @__PURE__ */ f(se, { code: e, value: t, viewConfig: i });
|
|
1160
1207
|
default:
|
|
1161
1208
|
return t;
|
|
1162
1209
|
}
|
|
1163
|
-
},
|
|
1164
|
-
|
|
1210
|
+
}, en = M(Ut), It = ({ value: e, code: t, modeConfig: n }) => /* @__PURE__ */ f(
|
|
1211
|
+
se,
|
|
1165
1212
|
{
|
|
1166
1213
|
code: t,
|
|
1167
1214
|
value: e,
|
|
1168
1215
|
viewConfig: n ? { mode: "api_ids", api_ids: n } : void 0
|
|
1169
1216
|
}
|
|
1170
|
-
),
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1217
|
+
), tn = M(It), Bt = ({ value: e, code: t, modeConfig: n }) => {
|
|
1218
|
+
const { client: i, renderers: r, i18n: a } = V(), s = R(
|
|
1219
|
+
() => (Array.isArray(e) ? e : [e]).filter(Boolean),
|
|
1220
|
+
[e]
|
|
1221
|
+
), {
|
|
1222
|
+
data: o,
|
|
1223
|
+
isLoading: u,
|
|
1224
|
+
error: c
|
|
1225
|
+
} = oe(
|
|
1226
|
+
["api_detail", t, s, n?.url, n?.method],
|
|
1227
|
+
async (l) => (await Promise.all(
|
|
1228
|
+
s.map(async (p) => {
|
|
1229
|
+
const d = ne(n?.url || "", { id: p });
|
|
1230
|
+
return (await i.request({
|
|
1231
|
+
method: n?.method,
|
|
1232
|
+
url: d,
|
|
1233
|
+
signal: l
|
|
1234
|
+
})).data;
|
|
1235
|
+
})
|
|
1236
|
+
)).filter(Boolean),
|
|
1237
|
+
!!(s.length && n?.url)
|
|
1238
|
+
), h = (l, b, p) => r.link ? r.link({ url: l, label: b, data: p }) : /* @__PURE__ */ f("a", { href: l, target: "_blank", rel: "noreferrer", children: b }), y = (l) => {
|
|
1239
|
+
const b = n?.mapping_attr?.map((p) => l?.[p]).join(" - ");
|
|
1240
|
+
if (n?.link) {
|
|
1241
|
+
const p = ne(n.link, l);
|
|
1242
|
+
return h(p, b, l);
|
|
1243
|
+
}
|
|
1244
|
+
return b;
|
|
1245
|
+
};
|
|
1246
|
+
return u ? /* @__PURE__ */ f(L, { children: r.viewLoading?.() ?? /* @__PURE__ */ f(ke, { size: "small" }) }) : c ? /* @__PURE__ */ f(L, { children: r.viewError?.(c) ?? a.messages.viewError }) : o?.length ? /* @__PURE__ */ f(L, { children: o.map((l, b) => /* @__PURE__ */ f("div", { children: y(l) }, b)) }) : /* @__PURE__ */ f(L, { children: r.viewEmpty?.() ?? a.messages.viewEmpty });
|
|
1247
|
+
}, nn = M(Bt), Ce = {
|
|
1178
1248
|
submit: "Save",
|
|
1179
1249
|
submitError: "Failed to submit form",
|
|
1180
1250
|
inputPlaceholder: (e) => `Enter ${e}`,
|
|
@@ -1185,9 +1255,9 @@ const Yt = ({
|
|
|
1185
1255
|
viewLoading: "Loading...",
|
|
1186
1256
|
viewEmpty: "-",
|
|
1187
1257
|
viewError: "Failed to load"
|
|
1188
|
-
},
|
|
1189
|
-
messages:
|
|
1190
|
-
},
|
|
1258
|
+
}, rn = {
|
|
1259
|
+
messages: Ce
|
|
1260
|
+
}, Wt = (e) => {
|
|
1191
1261
|
if (Array.isArray(e)) return e;
|
|
1192
1262
|
if (e && typeof e == "object" && "items" in e && Array.isArray(e.items))
|
|
1193
1263
|
return e.items;
|
|
@@ -1196,14 +1266,14 @@ const Yt = ({
|
|
|
1196
1266
|
return Array.isArray(t.items) ? t.items : [];
|
|
1197
1267
|
}
|
|
1198
1268
|
return [];
|
|
1199
|
-
},
|
|
1269
|
+
}, Gt = (e) => ({
|
|
1200
1270
|
redirectUrl: e?.redirect_after_create,
|
|
1201
1271
|
data: e
|
|
1202
|
-
}),
|
|
1203
|
-
optionResponse:
|
|
1204
|
-
submitResponse:
|
|
1205
|
-
viewResponse:
|
|
1206
|
-
},
|
|
1272
|
+
}), Kt = (e, t) => t?.dataPath ? W(e, t.dataPath) : e, Z = {
|
|
1273
|
+
optionResponse: Wt,
|
|
1274
|
+
submitResponse: Gt,
|
|
1275
|
+
viewResponse: Kt
|
|
1276
|
+
}, $t = (e, t = "_blank") => {
|
|
1207
1277
|
window.open(e, t);
|
|
1208
1278
|
}, ee = {
|
|
1209
1279
|
upload: async () => {
|
|
@@ -1211,89 +1281,89 @@ const Yt = ({
|
|
|
1211
1281
|
},
|
|
1212
1282
|
remove: async () => !1
|
|
1213
1283
|
};
|
|
1214
|
-
function
|
|
1284
|
+
function an({
|
|
1215
1285
|
children: e,
|
|
1216
1286
|
client: t,
|
|
1217
1287
|
upload: n,
|
|
1218
1288
|
i18n: i,
|
|
1219
|
-
parsers:
|
|
1220
|
-
renderers:
|
|
1289
|
+
parsers: r,
|
|
1290
|
+
renderers: a = {},
|
|
1221
1291
|
transformers: s = {},
|
|
1222
1292
|
cache: o,
|
|
1223
|
-
submitDebounceMs:
|
|
1293
|
+
submitDebounceMs: u = 200,
|
|
1224
1294
|
redirectHandler: c,
|
|
1225
1295
|
// legacy props
|
|
1226
|
-
requestClient:
|
|
1227
|
-
uploadAdapter:
|
|
1296
|
+
requestClient: h,
|
|
1297
|
+
uploadAdapter: y,
|
|
1228
1298
|
deleteUploadAdapter: l,
|
|
1229
|
-
messages:
|
|
1230
|
-
optionResponseParser:
|
|
1231
|
-
customFieldRenderers:
|
|
1299
|
+
messages: b,
|
|
1300
|
+
optionResponseParser: p,
|
|
1301
|
+
customFieldRenderers: d
|
|
1232
1302
|
}) {
|
|
1233
|
-
const
|
|
1234
|
-
const
|
|
1235
|
-
request:
|
|
1303
|
+
const v = U(/* @__PURE__ */ new Map()), _ = U(/* @__PURE__ */ new Map()), w = R(() => {
|
|
1304
|
+
const m = t ?? {
|
|
1305
|
+
request: h ?? (() => {
|
|
1236
1306
|
throw new Error("DynamicFormProvider requires client or requestClient");
|
|
1237
1307
|
})
|
|
1238
|
-
}, A =
|
|
1308
|
+
}, A = d ? Object.entries(d).map(([F, k]) => ({
|
|
1239
1309
|
match: F,
|
|
1240
|
-
render:
|
|
1241
|
-
})) : [],
|
|
1242
|
-
...
|
|
1310
|
+
render: k
|
|
1311
|
+
})) : [], S = {
|
|
1312
|
+
...Ce,
|
|
1243
1313
|
...i?.messages,
|
|
1244
|
-
...
|
|
1245
|
-
},
|
|
1314
|
+
...b
|
|
1315
|
+
}, g = {
|
|
1246
1316
|
...ee,
|
|
1247
1317
|
...n,
|
|
1248
|
-
upload: n?.upload ??
|
|
1318
|
+
upload: n?.upload ?? y ?? ee.upload,
|
|
1249
1319
|
remove: n?.remove ?? (l ? (F) => l(F.path) : ee.remove)
|
|
1250
1320
|
};
|
|
1251
1321
|
return {
|
|
1252
|
-
client:
|
|
1253
|
-
upload:
|
|
1254
|
-
i18n: { messages:
|
|
1322
|
+
client: m,
|
|
1323
|
+
upload: g,
|
|
1324
|
+
i18n: { messages: S },
|
|
1255
1325
|
parsers: {
|
|
1256
|
-
optionResponse:
|
|
1257
|
-
submitResponse:
|
|
1258
|
-
viewResponse:
|
|
1326
|
+
optionResponse: r?.optionResponse ?? p ?? Z.optionResponse,
|
|
1327
|
+
submitResponse: r?.submitResponse ?? Z.submitResponse,
|
|
1328
|
+
viewResponse: r?.viewResponse ?? Z.viewResponse
|
|
1259
1329
|
},
|
|
1260
1330
|
renderers: {
|
|
1261
|
-
...
|
|
1262
|
-
fields: [...
|
|
1331
|
+
...a,
|
|
1332
|
+
fields: [...a.fields ?? [], ...A]
|
|
1263
1333
|
},
|
|
1264
1334
|
transformers: s,
|
|
1265
1335
|
cache: {
|
|
1266
1336
|
enabled: o?.enabled ?? !0,
|
|
1267
1337
|
ttlMs: o?.ttlMs ?? 6e4
|
|
1268
1338
|
},
|
|
1269
|
-
submitDebounceMs:
|
|
1270
|
-
redirectHandler: c ??
|
|
1271
|
-
optionCache:
|
|
1272
|
-
viewCache:
|
|
1339
|
+
submitDebounceMs: u,
|
|
1340
|
+
redirectHandler: c ?? $t,
|
|
1341
|
+
optionCache: v.current,
|
|
1342
|
+
viewCache: _.current
|
|
1273
1343
|
};
|
|
1274
1344
|
}, [
|
|
1275
1345
|
t,
|
|
1276
|
-
|
|
1346
|
+
h,
|
|
1277
1347
|
n,
|
|
1278
|
-
|
|
1348
|
+
y,
|
|
1279
1349
|
l,
|
|
1280
1350
|
i?.messages,
|
|
1351
|
+
b,
|
|
1352
|
+
r?.optionResponse,
|
|
1353
|
+
r?.submitResponse,
|
|
1354
|
+
r?.viewResponse,
|
|
1281
1355
|
p,
|
|
1282
|
-
a
|
|
1283
|
-
|
|
1284
|
-
a?.viewResponse,
|
|
1285
|
-
m,
|
|
1286
|
-
r,
|
|
1287
|
-
h,
|
|
1356
|
+
a,
|
|
1357
|
+
d,
|
|
1288
1358
|
s,
|
|
1289
1359
|
o?.enabled,
|
|
1290
1360
|
o?.ttlMs,
|
|
1291
|
-
|
|
1361
|
+
u,
|
|
1292
1362
|
c
|
|
1293
1363
|
]);
|
|
1294
|
-
return /* @__PURE__ */ f(
|
|
1364
|
+
return /* @__PURE__ */ f(ie.Provider, { value: w, children: e });
|
|
1295
1365
|
}
|
|
1296
|
-
function
|
|
1366
|
+
function on(e) {
|
|
1297
1367
|
return {
|
|
1298
1368
|
request: async (t) => ({ data: (await e({
|
|
1299
1369
|
method: t.method,
|
|
@@ -1307,55 +1377,55 @@ function tn(e) {
|
|
|
1307
1377
|
};
|
|
1308
1378
|
}
|
|
1309
1379
|
export {
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1380
|
+
nn as ApiDetailItem,
|
|
1381
|
+
tn as ApiItem,
|
|
1382
|
+
se as ApiViewItem,
|
|
1383
|
+
bt as DefaultLayout,
|
|
1384
|
+
gt as DynamicForm,
|
|
1385
|
+
an as DynamicFormProvider,
|
|
1386
|
+
yt as FormItem,
|
|
1387
|
+
en as MetaItemValue,
|
|
1388
|
+
St as buildApiViewRequests,
|
|
1389
|
+
ae as buildCacheKey,
|
|
1390
|
+
te as cachedRequest,
|
|
1391
|
+
on as createAxiosDynamicFormClient,
|
|
1392
|
+
re as debounce,
|
|
1393
|
+
rn as defaultI18n,
|
|
1394
|
+
Ce as defaultMessages,
|
|
1395
|
+
Wt as defaultOptionResponseParser,
|
|
1326
1396
|
Z as defaultParsers,
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1397
|
+
$t as defaultRedirectHandler,
|
|
1398
|
+
Gt as defaultSubmitResponseParser,
|
|
1399
|
+
Kt as defaultViewResponseParser,
|
|
1400
|
+
ut as extractDependencyFields,
|
|
1401
|
+
Pe as extractViewData,
|
|
1402
|
+
At as fetchApiViewItems,
|
|
1403
|
+
ne as fillTemplate,
|
|
1334
1404
|
W as getByPath,
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1405
|
+
st as getCached,
|
|
1406
|
+
Me as getMappedLabel,
|
|
1407
|
+
Te as getMappedLink,
|
|
1408
|
+
I as isEmptyValue,
|
|
1409
|
+
Xe as mapOptionToSelectItem,
|
|
1410
|
+
Ze as mapOptions,
|
|
1411
|
+
xe as normalizeApiViewConfig,
|
|
1412
|
+
Xt as normalizeMetaForForm,
|
|
1413
|
+
dt as parseFormValues,
|
|
1414
|
+
O as replaceTemplateInObject,
|
|
1415
|
+
Ft as resolveApiOptionMeta,
|
|
1416
|
+
Je as resolveFieldRenderer,
|
|
1417
|
+
Qe as resolveFieldRendererFromMap,
|
|
1418
|
+
Tt as resolveFieldViewValue,
|
|
1419
|
+
ge as resolveViewValueConfig,
|
|
1420
|
+
lt as setCache,
|
|
1421
|
+
oe as useCachedViewRequest,
|
|
1422
|
+
ft as useDependencyValues,
|
|
1423
|
+
ot as useDynamicField,
|
|
1424
|
+
V as useDynamicFormContext,
|
|
1425
|
+
Qt as useDynamicFormContextOptional,
|
|
1426
|
+
mt as useDynamicOptions,
|
|
1427
|
+
_t as useFieldGroups,
|
|
1428
|
+
vt as useFieldStates,
|
|
1429
|
+
wt as useProcessedValues,
|
|
1430
|
+
Zt as useViewMode
|
|
1361
1431
|
};
|