@trungkhai/dynamic-form 0.1.5 → 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.es.js +285 -277
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx as l, jsxs as
|
|
2
|
-
import { Select as Ie, Form as
|
|
3
|
-
import { createContext as ht, useContext as Be, memo as
|
|
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
4
|
import ge from "dayjs";
|
|
5
5
|
import { FileImageOutlined as gt, UploadOutlined as wt, DeleteOutlined as vt, PlusOutlined as At } from "@ant-design/icons";
|
|
6
6
|
const ke = ht(
|
|
@@ -93,12 +93,12 @@ const Rt = ({
|
|
|
93
93
|
...n
|
|
94
94
|
}
|
|
95
95
|
);
|
|
96
|
-
}, xt =
|
|
96
|
+
}, xt = Z(Rt), Tt = ({
|
|
97
97
|
fieldName: e,
|
|
98
98
|
formInstance: t,
|
|
99
99
|
...n
|
|
100
100
|
}) => {
|
|
101
|
-
const r =
|
|
101
|
+
const r = Q.useWatch(e, t);
|
|
102
102
|
return j(() => {
|
|
103
103
|
if (r?.fileList?.length && r.fileList.some(
|
|
104
104
|
(o) => !o.type?.startsWith("image/")
|
|
@@ -122,16 +122,16 @@ const Rt = ({
|
|
|
122
122
|
children: /* @__PURE__ */ l(gt, {})
|
|
123
123
|
}
|
|
124
124
|
) });
|
|
125
|
-
}, Mt =
|
|
125
|
+
}, Mt = Z(Tt), Dt = ({
|
|
126
126
|
fieldName: e,
|
|
127
127
|
formInstance: t,
|
|
128
128
|
...n
|
|
129
129
|
}) => {
|
|
130
|
-
const r =
|
|
130
|
+
const r = Q.useWatch(e, t);
|
|
131
131
|
return /* @__PURE__ */ l(qe, { fileList: r?.fileList, ...n, children: /* @__PURE__ */ l(Ae, { icon: /* @__PURE__ */ l(wt, {}) }) });
|
|
132
|
-
}, Lt =
|
|
132
|
+
}, Lt = Z(Dt);
|
|
133
133
|
function we(e, t, n = {}) {
|
|
134
|
-
const { enabled: r = !0 } = n, [i, s] = L(), [o, a] = L(!1), [m, f] = L(), y =
|
|
134
|
+
const { enabled: r = !0 } = n, [i, s] = L(), [o, a] = L(!1), [m, f] = L(), y = q(t);
|
|
135
135
|
y.current = t;
|
|
136
136
|
const u = D(async () => {
|
|
137
137
|
if (r) {
|
|
@@ -193,7 +193,7 @@ function Pt(e, t) {
|
|
|
193
193
|
const n = t.method || "GET", r = n.toUpperCase() === "GET";
|
|
194
194
|
if (t.url_template)
|
|
195
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 ?
|
|
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
197
|
return {
|
|
198
198
|
method: n,
|
|
199
199
|
url: y,
|
|
@@ -201,7 +201,7 @@ function Pt(e, t) {
|
|
|
201
201
|
data: r ? void 0 : c
|
|
202
202
|
};
|
|
203
203
|
});
|
|
204
|
-
const i = Pe(e), s = t.params ?
|
|
204
|
+
const i = Pe(e), s = t.params ? oe(t.params, i) : void 0, o = t.data ? oe(t.data, i) : void 0;
|
|
205
205
|
return [
|
|
206
206
|
{
|
|
207
207
|
method: n,
|
|
@@ -212,7 +212,7 @@ function Pt(e, t) {
|
|
|
212
212
|
];
|
|
213
213
|
}
|
|
214
214
|
function Ne(e, t) {
|
|
215
|
-
const n = t.data_path ?
|
|
215
|
+
const n = t.data_path ? ae(e, t.data_path) : e;
|
|
216
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
217
|
}
|
|
218
218
|
function We(e, t) {
|
|
@@ -265,7 +265,7 @@ function Ee(e, t) {
|
|
|
265
265
|
const r = (Array.isArray(e) ? e : [e]).map((i) => t.find((s) => String(s.value) === String(i))?.label).filter((i) => !!i);
|
|
266
266
|
return r.length ? r.join(", ") : null;
|
|
267
267
|
}
|
|
268
|
-
function
|
|
268
|
+
function se(e, t, n) {
|
|
269
269
|
if (W(e)) return null;
|
|
270
270
|
const r = t.option_config?.value_attr || "value", i = Array.isArray(e) ? e : [e];
|
|
271
271
|
if (t.is_option_api && n?.length) {
|
|
@@ -297,13 +297,13 @@ function Ot(e) {
|
|
|
297
297
|
}
|
|
298
298
|
function It(e, t) {
|
|
299
299
|
return t?.length ? t.map((n) => {
|
|
300
|
-
const r =
|
|
300
|
+
const r = ae(e, n) ?? e[n];
|
|
301
301
|
return r != null ? String(r) : "";
|
|
302
302
|
}).filter(Boolean).join(" - ") : JSON.stringify(e);
|
|
303
303
|
}
|
|
304
304
|
function qt(e, t) {
|
|
305
305
|
return e ? e.replace(/\{\{(.+?)\}\}/g, (n, r) => {
|
|
306
|
-
const i = r.trim(), s =
|
|
306
|
+
const i = r.trim(), s = ae(t, i) ?? t[i];
|
|
307
307
|
return s != null ? String(s) : "";
|
|
308
308
|
}) : null;
|
|
309
309
|
}
|
|
@@ -346,7 +346,7 @@ function Bt(e, t, n) {
|
|
|
346
346
|
case "select":
|
|
347
347
|
case "radio":
|
|
348
348
|
case "checkbox":
|
|
349
|
-
return
|
|
349
|
+
return se(t, e, n.optionList);
|
|
350
350
|
case "image":
|
|
351
351
|
case "file":
|
|
352
352
|
return Ot(t);
|
|
@@ -358,14 +358,14 @@ function Bt(e, t, n) {
|
|
|
358
358
|
) : W(t) ? null : String(t);
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
|
-
function
|
|
361
|
+
function le(e) {
|
|
362
362
|
const t = e.additional_config?.default;
|
|
363
363
|
return typeof t == "string" && t.trim() ? t : void 0;
|
|
364
364
|
}
|
|
365
365
|
function He(e, t, n) {
|
|
366
366
|
if (!t || typeof t != "object" || Array.isArray(t))
|
|
367
367
|
return {};
|
|
368
|
-
const r = n ??
|
|
368
|
+
const r = n ?? le(e), i = t;
|
|
369
369
|
if (r && r in i) {
|
|
370
370
|
const s = i[r];
|
|
371
371
|
if (s && typeof s == "object" && !Array.isArray(s))
|
|
@@ -376,7 +376,7 @@ function He(e, t, n) {
|
|
|
376
376
|
function Ye(e, t, n) {
|
|
377
377
|
if (Array.isArray(t))
|
|
378
378
|
return t;
|
|
379
|
-
const r = n ??
|
|
379
|
+
const r = n ?? le(e);
|
|
380
380
|
if (!r || W(t))
|
|
381
381
|
return [];
|
|
382
382
|
if (t && typeof t == "object" && !Array.isArray(t)) {
|
|
@@ -432,7 +432,7 @@ function Je(e, t, n) {
|
|
|
432
432
|
}
|
|
433
433
|
return Array.isArray(i) ? i : [];
|
|
434
434
|
}
|
|
435
|
-
function
|
|
435
|
+
function ae(e, t) {
|
|
436
436
|
return t.split(".").reduce((n, r) => {
|
|
437
437
|
if (n && typeof n == "object")
|
|
438
438
|
return n[r];
|
|
@@ -442,7 +442,7 @@ function Ut(e, t) {
|
|
|
442
442
|
if (typeof e != "string") return e;
|
|
443
443
|
const n = e.match(/^\{\{(.+?)\}\}$/);
|
|
444
444
|
if (!n) return e;
|
|
445
|
-
const r = n[1].trim(), i =
|
|
445
|
+
const r = n[1].trim(), i = ae(t, r);
|
|
446
446
|
return i !== void 0 ? i : e;
|
|
447
447
|
}
|
|
448
448
|
function Nt(e, t) {
|
|
@@ -489,12 +489,12 @@ function Xe(e, t) {
|
|
|
489
489
|
break;
|
|
490
490
|
}
|
|
491
491
|
case "form": {
|
|
492
|
-
const o =
|
|
492
|
+
const o = le(r);
|
|
493
493
|
n[r.code] = He(r, i, o);
|
|
494
494
|
break;
|
|
495
495
|
}
|
|
496
496
|
case "multiple-form": {
|
|
497
|
-
const o =
|
|
497
|
+
const o = le(r);
|
|
498
498
|
n[r.code] = Ye(r, i, o);
|
|
499
499
|
break;
|
|
500
500
|
}
|
|
@@ -507,7 +507,7 @@ function Wt(e) {
|
|
|
507
507
|
).map((s) => s.slice(2, -2).trim());
|
|
508
508
|
return Array.from(/* @__PURE__ */ new Set([...r(t), ...r(n)]));
|
|
509
509
|
}
|
|
510
|
-
function
|
|
510
|
+
function oe(e, t) {
|
|
511
511
|
const n = {};
|
|
512
512
|
for (const r in e) {
|
|
513
513
|
const i = e[r];
|
|
@@ -553,7 +553,7 @@ const zt = (e) => ({
|
|
|
553
553
|
readOnly: i = !1,
|
|
554
554
|
registerNestedForm: s
|
|
555
555
|
}) => {
|
|
556
|
-
const o = U(), [a] =
|
|
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
557
|
data: u,
|
|
558
558
|
isLoading: c,
|
|
559
559
|
error: d
|
|
@@ -613,7 +613,7 @@ const zt = (e) => ({
|
|
|
613
613
|
}
|
|
614
614
|
) : /* @__PURE__ */ l(N, { type: "warning", message: "Missing nested form config_url", showIcon: !0 });
|
|
615
615
|
};
|
|
616
|
-
function
|
|
616
|
+
function de(e) {
|
|
617
617
|
return JSON.stringify(e);
|
|
618
618
|
}
|
|
619
619
|
function Yt(e, t) {
|
|
@@ -629,7 +629,7 @@ function Yt(e, t) {
|
|
|
629
629
|
function Jt(e, t, n, r) {
|
|
630
630
|
e.set(t, { data: n, expiresAt: Date.now() + r });
|
|
631
631
|
}
|
|
632
|
-
async function
|
|
632
|
+
async function ue(e, t, n, r, i) {
|
|
633
633
|
const s = e[t];
|
|
634
634
|
if (e.cache.enabled) {
|
|
635
635
|
const f = Yt(s, n);
|
|
@@ -651,7 +651,7 @@ async function Qt(e, t, n, r, i) {
|
|
|
651
651
|
if (s)
|
|
652
652
|
return s;
|
|
653
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 =
|
|
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
655
|
"collapseTitle",
|
|
656
656
|
t.code,
|
|
657
657
|
t.option_config.url,
|
|
@@ -660,7 +660,7 @@ async function Qt(e, t, n, r, i) {
|
|
|
660
660
|
n
|
|
661
661
|
]);
|
|
662
662
|
try {
|
|
663
|
-
const u = await
|
|
663
|
+
const u = await ue(
|
|
664
664
|
e,
|
|
665
665
|
"optionCache",
|
|
666
666
|
y,
|
|
@@ -686,7 +686,7 @@ async function Qt(e, t, n, r, i) {
|
|
|
686
686
|
});
|
|
687
687
|
return e.parsers.optionResponse(p.data, t);
|
|
688
688
|
}
|
|
689
|
-
), c =
|
|
689
|
+
), c = se(
|
|
690
690
|
n,
|
|
691
691
|
t,
|
|
692
692
|
u
|
|
@@ -695,7 +695,7 @@ async function Qt(e, t, n, r, i) {
|
|
|
695
695
|
} catch {
|
|
696
696
|
}
|
|
697
697
|
}
|
|
698
|
-
return
|
|
698
|
+
return se(n, t) ?? i;
|
|
699
699
|
}
|
|
700
700
|
function Zt(e, t, n, r, i) {
|
|
701
701
|
const s = U(), [o, a] = L({});
|
|
@@ -748,7 +748,7 @@ function en({
|
|
|
748
748
|
registerItemRef: s,
|
|
749
749
|
onValuesChange: o
|
|
750
750
|
}) {
|
|
751
|
-
const [a] =
|
|
751
|
+
const [a] = Q.useForm(), m = q(null);
|
|
752
752
|
return j(() => (s(e, m), () => {
|
|
753
753
|
s(e, null);
|
|
754
754
|
}), [e, s]), j(() => {
|
|
@@ -778,12 +778,12 @@ const tn = ({
|
|
|
778
778
|
readOnly: i = !1,
|
|
779
779
|
registerNestedForm: s
|
|
780
780
|
}) => {
|
|
781
|
-
const o = U(), a = e.additional_config?.multiple_form, m = a?.config_url, f = a?.method ?? "GET", y = a?.primary_field, u =
|
|
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
782
|
{}
|
|
783
|
-
), _ =
|
|
783
|
+
), _ = q(p), A = q(c), [g, S] = L(
|
|
784
784
|
String(c[0]?.key ?? "")
|
|
785
|
-
), b =
|
|
786
|
-
data:
|
|
785
|
+
), b = q(/* @__PURE__ */ new Map()), {
|
|
786
|
+
data: w,
|
|
787
787
|
isLoading: T,
|
|
788
788
|
error: F
|
|
789
789
|
} = we(
|
|
@@ -791,11 +791,11 @@ const tn = ({
|
|
|
791
791
|
async () => {
|
|
792
792
|
if (!m)
|
|
793
793
|
throw new Error("Missing additional_config.multiple_form.config_url");
|
|
794
|
-
const
|
|
794
|
+
const v = await o.client.request({
|
|
795
795
|
method: f,
|
|
796
796
|
url: m
|
|
797
797
|
});
|
|
798
|
-
return o.parsers.formConfigResponse(
|
|
798
|
+
return o.parsers.formConfigResponse(v.data);
|
|
799
799
|
},
|
|
800
800
|
{ enabled: !!m }
|
|
801
801
|
);
|
|
@@ -804,58 +804,59 @@ const tn = ({
|
|
|
804
804
|
}, [p]), j(() => {
|
|
805
805
|
A.current = c;
|
|
806
806
|
}, [c]), j(() => {
|
|
807
|
-
|
|
807
|
+
if (t === void 0) return;
|
|
808
|
+
const v = w?.code ?? le(e), k = Ye(e, t, v);
|
|
808
809
|
d((E) => {
|
|
809
810
|
if (E.length === k.length && E.length > 0) {
|
|
810
|
-
const
|
|
811
|
-
(te,
|
|
811
|
+
const X = E.reduce(
|
|
812
|
+
(te, ie, me) => (te[ie.key] = k[me] ?? {}, te),
|
|
812
813
|
{}
|
|
813
814
|
);
|
|
814
|
-
return h(
|
|
815
|
+
return h(X), E;
|
|
815
816
|
}
|
|
816
|
-
const M = k.length > 0 ? k : [{}],
|
|
817
|
-
(
|
|
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),
|
|
818
819
|
{}
|
|
819
820
|
);
|
|
820
|
-
return h(
|
|
821
|
+
return h(re), S(String(I[0]?.key ?? "")), I;
|
|
821
822
|
});
|
|
822
|
-
}, [e,
|
|
823
|
-
const
|
|
824
|
-
() =>
|
|
825
|
-
[
|
|
826
|
-
),
|
|
827
|
-
() =>
|
|
828
|
-
[
|
|
829
|
-
),
|
|
830
|
-
|
|
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,
|
|
831
832
|
y,
|
|
832
833
|
c,
|
|
833
834
|
p,
|
|
834
835
|
e.label
|
|
835
|
-
),
|
|
836
|
-
(
|
|
837
|
-
const E =
|
|
836
|
+
), B = D(
|
|
837
|
+
(v, k) => {
|
|
838
|
+
const E = v.map((M) => k[M.key] ?? {});
|
|
838
839
|
n?.(E);
|
|
839
840
|
},
|
|
840
841
|
[n]
|
|
841
|
-
),
|
|
842
|
-
(
|
|
842
|
+
), Y = D(
|
|
843
|
+
(v, k) => {
|
|
843
844
|
if (k) {
|
|
844
|
-
b.current.set(
|
|
845
|
+
b.current.set(v, k);
|
|
845
846
|
return;
|
|
846
847
|
}
|
|
847
|
-
b.current.delete(
|
|
848
|
+
b.current.delete(v);
|
|
848
849
|
},
|
|
849
850
|
[]
|
|
850
851
|
), ee = D(
|
|
851
|
-
(
|
|
852
|
+
(v, k) => {
|
|
852
853
|
h((E) => {
|
|
853
|
-
const M = { ...E, [
|
|
854
|
-
return
|
|
854
|
+
const M = { ...E, [v]: k };
|
|
855
|
+
return B(A.current, M), M;
|
|
855
856
|
});
|
|
856
857
|
},
|
|
857
|
-
[
|
|
858
|
-
), P =
|
|
858
|
+
[B]
|
|
859
|
+
), P = q({
|
|
859
860
|
submit: async () => {
|
|
860
861
|
},
|
|
861
862
|
isSubmitting: () => !1,
|
|
@@ -869,58 +870,58 @@ const tn = ({
|
|
|
869
870
|
})
|
|
870
871
|
));
|
|
871
872
|
}, []), j(() => {
|
|
872
|
-
if (
|
|
873
|
+
if (w)
|
|
873
874
|
return s?.(e.code, P, {
|
|
874
|
-
formCode:
|
|
875
|
+
formCode: w.code,
|
|
875
876
|
fieldType: "multiple-form"
|
|
876
877
|
}), () => {
|
|
877
878
|
s?.(e.code, null);
|
|
878
879
|
};
|
|
879
|
-
}, [e.code,
|
|
880
|
-
const
|
|
881
|
-
const
|
|
880
|
+
}, [e.code, w, s]);
|
|
881
|
+
const G = D(() => {
|
|
882
|
+
const v = { key: u.current++ };
|
|
882
883
|
d((k) => {
|
|
883
|
-
const E = [...k,
|
|
884
|
+
const E = [...k, v];
|
|
884
885
|
return h((M) => {
|
|
885
|
-
const
|
|
886
|
-
return
|
|
886
|
+
const I = { ...M, [v.key]: {} };
|
|
887
|
+
return B(E, I), I;
|
|
887
888
|
}), E;
|
|
888
|
-
}), S(String(
|
|
889
|
-
}, [
|
|
890
|
-
(
|
|
889
|
+
}), S(String(v.key));
|
|
890
|
+
}, [B]), K = D(
|
|
891
|
+
(v) => {
|
|
891
892
|
d((k) => {
|
|
892
|
-
const E = k.filter((M) => M.key !==
|
|
893
|
+
const E = k.filter((M) => M.key !== v);
|
|
893
894
|
return h((M) => {
|
|
894
|
-
const
|
|
895
|
-
return delete
|
|
895
|
+
const I = { ...M };
|
|
896
|
+
return delete I[v], B(E, I), I;
|
|
896
897
|
}), S(String(E[0]?.key ?? "")), E;
|
|
897
898
|
});
|
|
898
899
|
},
|
|
899
|
-
[
|
|
900
|
-
),
|
|
901
|
-
const E = p[
|
|
900
|
+
[B]
|
|
901
|
+
), ne = C(() => c.map((v, k) => {
|
|
902
|
+
const E = p[v.key] ?? {}, M = H[v.key] ?? `${e.label} ${k + 1}`;
|
|
902
903
|
return {
|
|
903
|
-
key: String(
|
|
904
|
-
label: /* @__PURE__ */
|
|
904
|
+
key: String(v.key),
|
|
905
|
+
label: /* @__PURE__ */ ce("div", { style: { display: "flex", justifyContent: "space-between", width: "100%" }, children: [
|
|
905
906
|
/* @__PURE__ */ l("span", { children: M }),
|
|
906
907
|
!r && !i ? /* @__PURE__ */ l(
|
|
907
908
|
vt,
|
|
908
909
|
{
|
|
909
|
-
onClick: (
|
|
910
|
-
|
|
910
|
+
onClick: (I) => {
|
|
911
|
+
I.preventDefault(), I.stopPropagation(), K(v.key);
|
|
911
912
|
}
|
|
912
913
|
}
|
|
913
914
|
) : null
|
|
914
915
|
] }),
|
|
915
|
-
children:
|
|
916
|
+
children: x ? /* @__PURE__ */ l(
|
|
916
917
|
en,
|
|
917
918
|
{
|
|
918
|
-
itemKey:
|
|
919
|
-
nestedFormConfig:
|
|
919
|
+
itemKey: v.key,
|
|
920
|
+
nestedFormConfig: x,
|
|
920
921
|
value: E,
|
|
921
922
|
disabled: r,
|
|
922
923
|
readOnly: i,
|
|
923
|
-
registerItemRef:
|
|
924
|
+
registerItemRef: Y,
|
|
924
925
|
onValuesChange: ee
|
|
925
926
|
}
|
|
926
927
|
) : null
|
|
@@ -928,23 +929,23 @@ const tn = ({
|
|
|
928
929
|
}), [
|
|
929
930
|
r,
|
|
930
931
|
e.label,
|
|
931
|
-
|
|
932
|
+
K,
|
|
932
933
|
c,
|
|
933
|
-
|
|
934
|
+
x,
|
|
934
935
|
ee,
|
|
935
936
|
i,
|
|
937
|
+
Y,
|
|
936
938
|
H,
|
|
937
|
-
z,
|
|
938
939
|
p
|
|
939
940
|
]);
|
|
940
|
-
return m ? y ? T ? /* @__PURE__ */ l(N, { type: "info", message: "Loading...", showIcon: !0 }) : F || !
|
|
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: [
|
|
941
942
|
/* @__PURE__ */ l(
|
|
942
943
|
at,
|
|
943
944
|
{
|
|
944
945
|
accordion: !0,
|
|
945
|
-
activeKey:
|
|
946
|
-
onChange: (
|
|
947
|
-
items:
|
|
946
|
+
activeKey: g,
|
|
947
|
+
onChange: (v) => S(Array.isArray(v) ? String(v[0] ?? "") : String(v)),
|
|
948
|
+
items: ne
|
|
948
949
|
}
|
|
949
950
|
),
|
|
950
951
|
!r && !i ? /* @__PURE__ */ l(
|
|
@@ -953,7 +954,7 @@ const tn = ({
|
|
|
953
954
|
style: { marginTop: 12 },
|
|
954
955
|
block: !0,
|
|
955
956
|
type: "dashed",
|
|
956
|
-
onClick:
|
|
957
|
+
onClick: G,
|
|
957
958
|
icon: /* @__PURE__ */ l(At, {}),
|
|
958
959
|
children: "Add item"
|
|
959
960
|
}
|
|
@@ -982,7 +983,7 @@ const tn = ({
|
|
|
982
983
|
if (i.upload) return i.upload;
|
|
983
984
|
const c = t ?? i.uploadUrl;
|
|
984
985
|
if (c)
|
|
985
|
-
return async ({ file: d, signal: p, onProgress: h, fieldCode: _, fieldGroup: A, metadata:
|
|
986
|
+
return async ({ file: d, signal: p, onProgress: h, fieldCode: _, fieldGroup: A, metadata: g }) => {
|
|
986
987
|
const S = i.getPayload ? i.getPayload({
|
|
987
988
|
file: d,
|
|
988
989
|
fieldCode: _,
|
|
@@ -990,13 +991,13 @@ const tn = ({
|
|
|
990
991
|
uploadUrl: c,
|
|
991
992
|
signal: p,
|
|
992
993
|
onProgress: h,
|
|
993
|
-
metadata:
|
|
994
|
+
metadata: g
|
|
994
995
|
}) : (() => {
|
|
995
996
|
const T = new FormData();
|
|
996
|
-
return T.append("file", d),
|
|
997
|
-
T.append(F, String(
|
|
997
|
+
return T.append("file", d), g && Object.entries(g).forEach(([F, x]) => {
|
|
998
|
+
T.append(F, String(x));
|
|
998
999
|
}), T;
|
|
999
|
-
})(),
|
|
1000
|
+
})(), w = (await r.request({
|
|
1000
1001
|
method: "POST",
|
|
1001
1002
|
url: c,
|
|
1002
1003
|
data: S,
|
|
@@ -1010,28 +1011,28 @@ const tn = ({
|
|
|
1010
1011
|
})).data;
|
|
1011
1012
|
return {
|
|
1012
1013
|
uid: d.uid,
|
|
1013
|
-
...
|
|
1014
|
-
path: String(
|
|
1014
|
+
...w,
|
|
1015
|
+
path: String(w.path ?? "")
|
|
1015
1016
|
};
|
|
1016
1017
|
};
|
|
1017
1018
|
}, [r, i, t]), f = D(
|
|
1018
1019
|
(c, d) => (p) => {
|
|
1019
|
-
const { file: h, onProgress: _, onError: A, onSuccess:
|
|
1020
|
+
const { file: h, onProgress: _, onError: A, onSuccess: g } = p, S = new AbortController(), b = m();
|
|
1020
1021
|
return b ? (b({
|
|
1021
1022
|
file: h,
|
|
1022
1023
|
fieldCode: c,
|
|
1023
1024
|
fieldGroup: d,
|
|
1024
1025
|
uploadUrl: t ?? i.uploadUrl,
|
|
1025
1026
|
signal: S.signal,
|
|
1026
|
-
onProgress: (
|
|
1027
|
+
onProgress: (w) => _?.({ percent: w })
|
|
1027
1028
|
}).then(
|
|
1028
|
-
(
|
|
1029
|
-
...
|
|
1030
|
-
uid:
|
|
1031
|
-
path:
|
|
1029
|
+
(w) => g?.({
|
|
1030
|
+
...w,
|
|
1031
|
+
uid: w.uid ?? h.uid,
|
|
1032
|
+
path: w.path,
|
|
1032
1033
|
upload_date: ge().format("YYYY-MM-DD HH:mm:ss")
|
|
1033
1034
|
})
|
|
1034
|
-
).catch((
|
|
1035
|
+
).catch((w) => A?.(w)), { abort: () => S.abort() }) : (A?.(new Error(a.uploadError ?? "Upload not configured")), { abort() {
|
|
1035
1036
|
} });
|
|
1036
1037
|
},
|
|
1037
1038
|
[a.uploadError, m, i.uploadUrl, t]
|
|
@@ -1048,26 +1049,26 @@ const tn = ({
|
|
|
1048
1049
|
optionsLoading: h,
|
|
1049
1050
|
optionsError: _,
|
|
1050
1051
|
onSearchKeyword: A,
|
|
1051
|
-
readOnly:
|
|
1052
|
+
readOnly: g = !1,
|
|
1052
1053
|
registerNestedForm: S
|
|
1053
1054
|
}) => {
|
|
1054
|
-
const { additional_config: b, field:
|
|
1055
|
+
const { additional_config: b, field: w } = c, T = w?.type?.code, F = g || c.is_readonly || d?.disabled, x = kt(
|
|
1055
1056
|
c,
|
|
1056
1057
|
o.fields
|
|
1057
1058
|
);
|
|
1058
|
-
if (
|
|
1059
|
-
return
|
|
1059
|
+
if (x)
|
|
1060
|
+
return x(c, {
|
|
1060
1061
|
state: d,
|
|
1061
1062
|
options: p,
|
|
1062
1063
|
optionsLoading: h,
|
|
1063
1064
|
optionsError: _,
|
|
1064
1065
|
onSearchKeyword: A,
|
|
1065
|
-
readOnly:
|
|
1066
|
+
readOnly: g,
|
|
1066
1067
|
formInstance: e,
|
|
1067
1068
|
disabled: !!F,
|
|
1068
1069
|
setFieldState: n
|
|
1069
1070
|
});
|
|
1070
|
-
const
|
|
1071
|
+
const z = Ct(p, c);
|
|
1071
1072
|
switch (T) {
|
|
1072
1073
|
case "text":
|
|
1073
1074
|
return b?.text?.textarea ? /* @__PURE__ */ l(
|
|
@@ -1096,9 +1097,9 @@ const tn = ({
|
|
|
1096
1097
|
}
|
|
1097
1098
|
);
|
|
1098
1099
|
case "select": {
|
|
1099
|
-
const
|
|
1100
|
+
const H = {
|
|
1100
1101
|
disabled: F,
|
|
1101
|
-
options:
|
|
1102
|
+
options: z,
|
|
1102
1103
|
placeholder: a.selectPlaceholder(c.label),
|
|
1103
1104
|
allowClear: !0,
|
|
1104
1105
|
loading: h,
|
|
@@ -1108,16 +1109,16 @@ const tn = ({
|
|
|
1108
1109
|
return A ? /* @__PURE__ */ l(
|
|
1109
1110
|
xt,
|
|
1110
1111
|
{
|
|
1111
|
-
...
|
|
1112
|
+
...H,
|
|
1112
1113
|
onSearchKeyword: A,
|
|
1113
1114
|
searchDebounceMs: b?.select?.searchDebounceMs ?? 500
|
|
1114
1115
|
}
|
|
1115
|
-
) : /* @__PURE__ */ l(Ie, { ...
|
|
1116
|
+
) : /* @__PURE__ */ l(Ie, { ...H, showSearch: !0, optionFilterProp: "label" });
|
|
1116
1117
|
}
|
|
1117
1118
|
case "radio":
|
|
1118
|
-
return /* @__PURE__ */ l(dt.Group, { disabled: F, options:
|
|
1119
|
+
return /* @__PURE__ */ l(dt.Group, { disabled: F, options: z });
|
|
1119
1120
|
case "checkbox":
|
|
1120
|
-
return /* @__PURE__ */ l(lt.Group, { disabled: F, options:
|
|
1121
|
+
return /* @__PURE__ */ l(lt.Group, { disabled: F, options: z });
|
|
1121
1122
|
case "datetime":
|
|
1122
1123
|
return /* @__PURE__ */ l(
|
|
1123
1124
|
ct,
|
|
@@ -1162,7 +1163,7 @@ const tn = ({
|
|
|
1162
1163
|
{
|
|
1163
1164
|
group: c,
|
|
1164
1165
|
disabled: !!F,
|
|
1165
|
-
readOnly:
|
|
1166
|
+
readOnly: g,
|
|
1166
1167
|
registerNestedForm: S
|
|
1167
1168
|
}
|
|
1168
1169
|
);
|
|
@@ -1172,7 +1173,7 @@ const tn = ({
|
|
|
1172
1173
|
{
|
|
1173
1174
|
group: c,
|
|
1174
1175
|
disabled: !!F,
|
|
1175
|
-
readOnly:
|
|
1176
|
+
readOnly: g,
|
|
1176
1177
|
registerNestedForm: S
|
|
1177
1178
|
}
|
|
1178
1179
|
);
|
|
@@ -1195,7 +1196,7 @@ function rn(e, t) {
|
|
|
1195
1196
|
const n = C(
|
|
1196
1197
|
() => Wt(e),
|
|
1197
1198
|
[e]
|
|
1198
|
-
), r =
|
|
1199
|
+
), r = Q.useWatch(
|
|
1199
1200
|
n.length > 0 ? n : void 0,
|
|
1200
1201
|
t
|
|
1201
1202
|
);
|
|
@@ -1213,19 +1214,19 @@ function on({
|
|
|
1213
1214
|
searchKeyword: n = "",
|
|
1214
1215
|
searchDebounceMs: r = 500
|
|
1215
1216
|
}) {
|
|
1216
|
-
const i = U(), s = rn(e, t), o =
|
|
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(
|
|
1217
1218
|
() => Fe((b) => h(b), r),
|
|
1218
1219
|
[r]
|
|
1219
1220
|
);
|
|
1220
1221
|
j(() => {
|
|
1221
1222
|
_ ? A(n) : h("");
|
|
1222
1223
|
}, [n, _, A]);
|
|
1223
|
-
const
|
|
1224
|
-
const b = e.option_config?.api_options?.params,
|
|
1225
|
-
if (!(!b && !
|
|
1224
|
+
const g = C(() => {
|
|
1225
|
+
const b = e.option_config?.api_options?.params, w = e.option_config?.api_options?.data;
|
|
1226
|
+
if (!(!b && !w))
|
|
1226
1227
|
return {
|
|
1227
|
-
params: b ?
|
|
1228
|
-
data:
|
|
1228
|
+
params: b ? oe(b, s) : void 0,
|
|
1229
|
+
data: w ? oe(w, s) : void 0
|
|
1229
1230
|
};
|
|
1230
1231
|
}, [s, e]), S = D(async () => {
|
|
1231
1232
|
if (!e.option_config || !e.is_option_api || !e.option_config.url)
|
|
@@ -1233,67 +1234,67 @@ function on({
|
|
|
1233
1234
|
d.current?.abort();
|
|
1234
1235
|
const b = new AbortController();
|
|
1235
1236
|
d.current = b;
|
|
1236
|
-
const
|
|
1237
|
+
const w = e.option_config.method?.toUpperCase() === "GET" || !e.option_config.method, T = _ ? p : "", F = de([
|
|
1237
1238
|
e.code,
|
|
1238
1239
|
e.option_config.url,
|
|
1239
1240
|
e.option_config.method,
|
|
1240
|
-
|
|
1241
|
+
g,
|
|
1241
1242
|
T
|
|
1242
1243
|
]);
|
|
1243
1244
|
y(!0), c(void 0);
|
|
1244
1245
|
try {
|
|
1245
|
-
const
|
|
1246
|
+
const x = await ue(
|
|
1246
1247
|
i,
|
|
1247
1248
|
"optionCache",
|
|
1248
1249
|
F,
|
|
1249
1250
|
async (P) => {
|
|
1250
|
-
const
|
|
1251
|
+
const G = await i.client.request({
|
|
1251
1252
|
method: e.option_config?.method || "GET",
|
|
1252
1253
|
url: e.option_config?.url,
|
|
1253
|
-
params:
|
|
1254
|
-
data: !
|
|
1254
|
+
params: w && _ ? { ...g?.params, keywords: T } : g?.params,
|
|
1255
|
+
data: !w && _ ? { ...g?.data, keywords: T } : g?.data,
|
|
1255
1256
|
signal: P
|
|
1256
1257
|
});
|
|
1257
|
-
return i.parsers.optionResponse(
|
|
1258
|
+
return i.parsers.optionResponse(G.data, e);
|
|
1258
1259
|
},
|
|
1259
1260
|
b.signal
|
|
1260
|
-
),
|
|
1261
|
-
|
|
1262
|
-
),
|
|
1263
|
-
let
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
const
|
|
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([
|
|
1267
1268
|
e.code,
|
|
1268
1269
|
e.option_config?.url,
|
|
1269
1270
|
e.option_config?.method,
|
|
1270
|
-
|
|
1271
|
+
g,
|
|
1271
1272
|
"selected",
|
|
1272
1273
|
P
|
|
1273
1274
|
]);
|
|
1274
|
-
return
|
|
1275
|
+
return ue(
|
|
1275
1276
|
i,
|
|
1276
1277
|
"optionCache",
|
|
1277
|
-
|
|
1278
|
-
async (
|
|
1279
|
-
const
|
|
1278
|
+
G,
|
|
1279
|
+
async (K) => {
|
|
1280
|
+
const v = { [e.option_config?.value_attr || "value"]: P }, k = await i.client.request({
|
|
1280
1281
|
method: e.option_config?.method || "GET",
|
|
1281
1282
|
url: e.option_config?.url,
|
|
1282
|
-
params:
|
|
1283
|
-
...
|
|
1283
|
+
params: w ? {
|
|
1284
|
+
...g?.params,
|
|
1284
1285
|
filter: {
|
|
1285
|
-
...
|
|
1286
|
-
...
|
|
1286
|
+
...g?.params?.filter,
|
|
1287
|
+
...v
|
|
1287
1288
|
}
|
|
1288
|
-
} :
|
|
1289
|
-
data:
|
|
1290
|
-
...
|
|
1289
|
+
} : g?.params,
|
|
1290
|
+
data: w ? g?.data : {
|
|
1291
|
+
...g?.data,
|
|
1291
1292
|
filter: {
|
|
1292
|
-
...
|
|
1293
|
-
...
|
|
1293
|
+
...g?.data?.filter,
|
|
1294
|
+
...v
|
|
1294
1295
|
}
|
|
1295
1296
|
},
|
|
1296
|
-
signal:
|
|
1297
|
+
signal: K
|
|
1297
1298
|
});
|
|
1298
1299
|
return i.parsers.optionResponse(k.data, e);
|
|
1299
1300
|
},
|
|
@@ -1302,17 +1303,17 @@ function on({
|
|
|
1302
1303
|
})
|
|
1303
1304
|
)).flat());
|
|
1304
1305
|
const ee = Et(
|
|
1305
|
-
[...
|
|
1306
|
+
[...x, ...Y],
|
|
1306
1307
|
e
|
|
1307
1308
|
);
|
|
1308
1309
|
b.signal.aborted || m(ee);
|
|
1309
|
-
} catch (
|
|
1310
|
-
b.signal.aborted || c(
|
|
1310
|
+
} catch (x) {
|
|
1311
|
+
b.signal.aborted || c(x);
|
|
1311
1312
|
} finally {
|
|
1312
1313
|
b.signal.aborted || y(!1);
|
|
1313
1314
|
}
|
|
1314
1315
|
}, [
|
|
1315
|
-
|
|
1316
|
+
g,
|
|
1316
1317
|
i,
|
|
1317
1318
|
p,
|
|
1318
1319
|
e,
|
|
@@ -1336,7 +1337,7 @@ const sn = ({
|
|
|
1336
1337
|
formInstance: t,
|
|
1337
1338
|
uploadUrl: i,
|
|
1338
1339
|
setFieldState: r
|
|
1339
|
-
}), y =
|
|
1340
|
+
}), y = Q.useWatch(e.code, t), [u, c] = L(""), d = e.additional_config?.select?.search_keyword ?? !1, { options: p, isLoading: h, error: _ } = on({
|
|
1340
1341
|
group: e,
|
|
1341
1342
|
formInstance: t,
|
|
1342
1343
|
searchKeyword: u,
|
|
@@ -1349,15 +1350,15 @@ const sn = ({
|
|
|
1349
1350
|
r(S, { disabled: !y });
|
|
1350
1351
|
});
|
|
1351
1352
|
}, [y, t, e, r]);
|
|
1352
|
-
const
|
|
1353
|
+
const g = o === "small" ? 4 : 12;
|
|
1353
1354
|
return /* @__PURE__ */ l(
|
|
1354
|
-
|
|
1355
|
+
Q.Item,
|
|
1355
1356
|
{
|
|
1356
1357
|
label: e.label,
|
|
1357
1358
|
name: e.code,
|
|
1358
1359
|
hidden: n?.hidden,
|
|
1359
1360
|
rules: [{ required: n?.required || !1 }],
|
|
1360
|
-
style: { marginBottom:
|
|
1361
|
+
style: { marginBottom: g, ...m.style },
|
|
1361
1362
|
...m,
|
|
1362
1363
|
children: f(e, {
|
|
1363
1364
|
state: n,
|
|
@@ -1374,7 +1375,7 @@ const sn = ({
|
|
|
1374
1375
|
function an(e, t) {
|
|
1375
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;
|
|
1376
1377
|
}
|
|
1377
|
-
const cn =
|
|
1378
|
+
const cn = Z(sn, an);
|
|
1378
1379
|
function ln({
|
|
1379
1380
|
fieldGroups: e,
|
|
1380
1381
|
fieldStates: t,
|
|
@@ -1391,7 +1392,9 @@ function dn(e) {
|
|
|
1391
1392
|
return C(() => {
|
|
1392
1393
|
const t = e?.form?.field_groups ?? [], n = /* @__PURE__ */ new Map(), r = {};
|
|
1393
1394
|
t.forEach((s) => {
|
|
1394
|
-
n.set(s.code, 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);
|
|
1395
1398
|
});
|
|
1396
1399
|
const i = t.filter((s) => !s.is_hidden);
|
|
1397
1400
|
return { fieldGroups: t, fieldByCode: n, visibleFieldGroups: i, initialValues: r };
|
|
@@ -1505,100 +1508,105 @@ const xe = _t(
|
|
|
1505
1508
|
submitDebounceMs: h,
|
|
1506
1509
|
gutter: _ = [8, 0],
|
|
1507
1510
|
defaultColSpan: A = 12,
|
|
1508
|
-
submitButtonLabel:
|
|
1511
|
+
submitButtonLabel: g,
|
|
1509
1512
|
disableHtmlFormWrapper: S = !1
|
|
1510
1513
|
}, b) => {
|
|
1511
|
-
const { message:
|
|
1512
|
-
(
|
|
1513
|
-
if (
|
|
1514
|
-
M.current.set(
|
|
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 });
|
|
1515
1518
|
return;
|
|
1516
1519
|
}
|
|
1517
|
-
M.current.delete(
|
|
1520
|
+
M.current.delete(R);
|
|
1518
1521
|
},
|
|
1519
1522
|
[]
|
|
1520
|
-
), { buildProcessedValues:
|
|
1523
|
+
), { buildProcessedValues: re } = mn({
|
|
1521
1524
|
formInstance: t,
|
|
1522
|
-
fieldByCode:
|
|
1525
|
+
fieldByCode: ne,
|
|
1523
1526
|
relatedData: n,
|
|
1524
|
-
transformers:
|
|
1527
|
+
transformers: Y,
|
|
1525
1528
|
nestedFormRefs: M
|
|
1526
|
-
}),
|
|
1529
|
+
}), X = q(!1), [te, ie] = L(!1), [me, Te] = L(!1);
|
|
1527
1530
|
j(() => {
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
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]);
|
|
1533
1541
|
const pe = D(async () => {
|
|
1534
|
-
if (!
|
|
1535
|
-
|
|
1542
|
+
if (!X.current) {
|
|
1543
|
+
X.current = !0, ie(!0);
|
|
1536
1544
|
try {
|
|
1537
|
-
let
|
|
1545
|
+
let R = await re();
|
|
1538
1546
|
try {
|
|
1539
|
-
s && (Te(!0), await
|
|
1547
|
+
s && (Te(!0), await x.request({
|
|
1540
1548
|
method: "POST",
|
|
1541
1549
|
url: s,
|
|
1542
|
-
data:
|
|
1550
|
+
data: R
|
|
1543
1551
|
}));
|
|
1544
|
-
const
|
|
1545
|
-
if (
|
|
1546
|
-
|
|
1547
|
-
} catch (
|
|
1548
|
-
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);
|
|
1549
1557
|
return;
|
|
1550
1558
|
} finally {
|
|
1551
1559
|
Te(!1);
|
|
1552
1560
|
}
|
|
1553
|
-
const
|
|
1561
|
+
const $ = await x.request({
|
|
1554
1562
|
method: e.method,
|
|
1555
1563
|
url: e.action,
|
|
1556
|
-
data:
|
|
1564
|
+
data: R
|
|
1557
1565
|
});
|
|
1558
1566
|
t.resetFields(
|
|
1559
|
-
|
|
1567
|
+
K.filter((O) => !O.is_hidden).map((O) => O.code)
|
|
1560
1568
|
);
|
|
1561
|
-
const
|
|
1562
|
-
f &&
|
|
1563
|
-
values:
|
|
1564
|
-
response:
|
|
1565
|
-
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
|
|
1566
1574
|
});
|
|
1567
|
-
} catch (
|
|
1568
|
-
const
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
), m?.(
|
|
1575
|
+
} catch (R) {
|
|
1576
|
+
const $ = R;
|
|
1577
|
+
w.error(
|
|
1578
|
+
$?.response?.data?.message ?? F.messages.submitError
|
|
1579
|
+
), m?.(R);
|
|
1572
1580
|
} finally {
|
|
1573
|
-
|
|
1581
|
+
X.current = !1, ie(!1);
|
|
1574
1582
|
}
|
|
1575
1583
|
}
|
|
1576
1584
|
}, [
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1585
|
+
re,
|
|
1586
|
+
x,
|
|
1587
|
+
K,
|
|
1580
1588
|
e.action,
|
|
1581
1589
|
e.method,
|
|
1582
1590
|
t,
|
|
1583
1591
|
F.messages.submitError,
|
|
1584
1592
|
f,
|
|
1585
|
-
|
|
1593
|
+
w,
|
|
1586
1594
|
o,
|
|
1587
1595
|
y,
|
|
1588
1596
|
m,
|
|
1589
1597
|
a,
|
|
1590
|
-
$,
|
|
1591
1598
|
z,
|
|
1599
|
+
H,
|
|
1592
1600
|
s
|
|
1593
1601
|
]);
|
|
1594
1602
|
bt(
|
|
1595
1603
|
b,
|
|
1596
1604
|
() => ({
|
|
1597
1605
|
submit: pe,
|
|
1598
|
-
getProcessedValues:
|
|
1599
|
-
isSubmitting: () =>
|
|
1606
|
+
getProcessedValues: re,
|
|
1607
|
+
isSubmitting: () => X.current
|
|
1600
1608
|
}),
|
|
1601
|
-
[
|
|
1609
|
+
[re, pe]
|
|
1602
1610
|
);
|
|
1603
1611
|
const Me = C(
|
|
1604
1612
|
() => Fe(() => {
|
|
@@ -1606,43 +1614,43 @@ const xe = _t(
|
|
|
1606
1614
|
}, P),
|
|
1607
1615
|
[pe, P]
|
|
1608
1616
|
), it = D(
|
|
1609
|
-
(
|
|
1610
|
-
Object.keys(
|
|
1611
|
-
const
|
|
1612
|
-
|
|
1613
|
-
|
|
1617
|
+
(R, $) => {
|
|
1618
|
+
Object.keys(R).forEach((J) => {
|
|
1619
|
+
const O = $t(
|
|
1620
|
+
J,
|
|
1621
|
+
K,
|
|
1614
1622
|
t.getFieldsValue()
|
|
1615
1623
|
);
|
|
1616
|
-
|
|
1617
|
-
}), d?.(
|
|
1624
|
+
O.length > 0 && t.resetFields(O);
|
|
1625
|
+
}), d?.(R, $);
|
|
1618
1626
|
},
|
|
1619
|
-
[
|
|
1627
|
+
[K, t, d]
|
|
1620
1628
|
), De = D(
|
|
1621
|
-
(
|
|
1629
|
+
(R) => /* @__PURE__ */ l(
|
|
1622
1630
|
cn,
|
|
1623
1631
|
{
|
|
1624
|
-
group:
|
|
1632
|
+
group: R,
|
|
1625
1633
|
formInstance: t,
|
|
1626
|
-
fieldState: k[
|
|
1634
|
+
fieldState: k[R.code],
|
|
1627
1635
|
setFieldState: E,
|
|
1628
1636
|
uploadUrl: ee,
|
|
1629
1637
|
readOnly: p,
|
|
1630
1638
|
size: u,
|
|
1631
|
-
registerNestedForm:
|
|
1639
|
+
registerNestedForm: I
|
|
1632
1640
|
},
|
|
1633
|
-
|
|
1641
|
+
R.id
|
|
1634
1642
|
),
|
|
1635
1643
|
[
|
|
1636
1644
|
k,
|
|
1637
1645
|
t,
|
|
1638
|
-
|
|
1646
|
+
I,
|
|
1639
1647
|
p,
|
|
1640
1648
|
ee,
|
|
1641
1649
|
E,
|
|
1642
1650
|
u
|
|
1643
1651
|
]
|
|
1644
|
-
), ot =
|
|
1645
|
-
fieldGroups:
|
|
1652
|
+
), ot = B.layout ? B.layout({
|
|
1653
|
+
fieldGroups: K,
|
|
1646
1654
|
fieldStates: k,
|
|
1647
1655
|
renderField: De,
|
|
1648
1656
|
gutter: _,
|
|
@@ -1651,28 +1659,28 @@ const xe = _t(
|
|
|
1651
1659
|
}) : /* @__PURE__ */ l(
|
|
1652
1660
|
ln,
|
|
1653
1661
|
{
|
|
1654
|
-
fieldGroups:
|
|
1662
|
+
fieldGroups: K,
|
|
1655
1663
|
fieldStates: k,
|
|
1656
1664
|
renderField: De,
|
|
1657
1665
|
gutter: _,
|
|
1658
1666
|
defaultColSpan: A,
|
|
1659
1667
|
size: u
|
|
1660
1668
|
}
|
|
1661
|
-
), st = !c && !p && (
|
|
1669
|
+
), st = !c && !p && (B.submitActions ? B.submitActions({
|
|
1662
1670
|
onSubmit: Me,
|
|
1663
1671
|
loading: te || me,
|
|
1664
|
-
label:
|
|
1672
|
+
label: G
|
|
1665
1673
|
}) : /* @__PURE__ */ l(Se, { justify: "flex-end", children: /* @__PURE__ */ l(
|
|
1666
1674
|
Ae,
|
|
1667
1675
|
{
|
|
1668
1676
|
type: "primary",
|
|
1669
1677
|
onClick: Me,
|
|
1670
1678
|
loading: te || me,
|
|
1671
|
-
children:
|
|
1679
|
+
children: G
|
|
1672
1680
|
}
|
|
1673
1681
|
) }));
|
|
1674
|
-
return /* @__PURE__ */
|
|
1675
|
-
|
|
1682
|
+
return /* @__PURE__ */ ce(
|
|
1683
|
+
Q,
|
|
1676
1684
|
{
|
|
1677
1685
|
layout: "vertical",
|
|
1678
1686
|
form: t,
|
|
@@ -1705,10 +1713,10 @@ function Oe(e, t) {
|
|
|
1705
1713
|
expiresAt: Date.now() + pn
|
|
1706
1714
|
});
|
|
1707
1715
|
}
|
|
1708
|
-
function
|
|
1709
|
-
const r = U(), [i, s] = L(), [o, a] = L(!1), [m, f] = L(), y =
|
|
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);
|
|
1710
1718
|
y.current = t, u.current = r;
|
|
1711
|
-
const c =
|
|
1719
|
+
const c = de(e);
|
|
1712
1720
|
return j(() => {
|
|
1713
1721
|
if (!n) {
|
|
1714
1722
|
s(void 0), f(void 0), a(!1);
|
|
@@ -1722,11 +1730,11 @@ function ue(e, t, n = !0) {
|
|
|
1722
1730
|
const h = new AbortController();
|
|
1723
1731
|
return a(!0), f(void 0), (async () => {
|
|
1724
1732
|
try {
|
|
1725
|
-
const A = await
|
|
1733
|
+
const A = await ue(
|
|
1726
1734
|
u.current,
|
|
1727
1735
|
"viewCache",
|
|
1728
1736
|
c,
|
|
1729
|
-
(
|
|
1737
|
+
(g) => y.current(g),
|
|
1730
1738
|
h.signal
|
|
1731
1739
|
);
|
|
1732
1740
|
h.signal.aborted || (s(A), f(void 0));
|
|
@@ -1741,7 +1749,7 @@ function ue(e, t, n = !0) {
|
|
|
1741
1749
|
const p = new AbortController();
|
|
1742
1750
|
a(!0), f(void 0);
|
|
1743
1751
|
try {
|
|
1744
|
-
const h = await
|
|
1752
|
+
const h = await ue(
|
|
1745
1753
|
u.current,
|
|
1746
1754
|
"viewCache",
|
|
1747
1755
|
c,
|
|
@@ -1764,7 +1772,7 @@ const hn = ({ value: e, code: t, modeConfig: n }) => {
|
|
|
1764
1772
|
data: a,
|
|
1765
1773
|
isLoading: m,
|
|
1766
1774
|
error: f
|
|
1767
|
-
} =
|
|
1775
|
+
} = fe(
|
|
1768
1776
|
["api_detail", t, o, n?.url, n?.method],
|
|
1769
1777
|
async (c) => (await Promise.all(
|
|
1770
1778
|
o.map(async (p) => {
|
|
@@ -1786,12 +1794,12 @@ const hn = ({ value: e, code: t, modeConfig: n }) => {
|
|
|
1786
1794
|
return d;
|
|
1787
1795
|
};
|
|
1788
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 });
|
|
1789
|
-
}, Qe =
|
|
1797
|
+
}, Qe = Z(hn), _n = ({ value: e, code: t, modeConfig: n }) => {
|
|
1790
1798
|
const { client: r, renderers: i, i18n: s } = U(), {
|
|
1791
1799
|
data: o,
|
|
1792
1800
|
isLoading: a,
|
|
1793
1801
|
error: m
|
|
1794
|
-
} =
|
|
1802
|
+
} = fe(
|
|
1795
1803
|
["api_ids", t, e, n?.url, n?.method],
|
|
1796
1804
|
async (u) => {
|
|
1797
1805
|
const c = n?.method || "GET", d = c.toUpperCase() === "POST", p = Array.isArray(e) ? e : [e], _ = (await r.request({
|
|
@@ -1800,7 +1808,7 @@ const hn = ({ value: e, code: t, modeConfig: n }) => {
|
|
|
1800
1808
|
data: d ? { ids: p } : void 0,
|
|
1801
1809
|
params: d ? void 0 : { ids: p },
|
|
1802
1810
|
signal: u
|
|
1803
|
-
})).data, A = n?.data_path ?
|
|
1811
|
+
})).data, A = n?.data_path ? ae(_, n.data_path) : _;
|
|
1804
1812
|
return Array.isArray(A) ? A : _;
|
|
1805
1813
|
},
|
|
1806
1814
|
!!(e && n?.url)
|
|
@@ -1815,7 +1823,7 @@ const hn = ({ value: e, code: t, modeConfig: n }) => {
|
|
|
1815
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(
|
|
1816
1824
|
Array.isArray(o) ? o[0] : o
|
|
1817
1825
|
) : /* @__PURE__ */ l(V, { children: i.viewEmpty?.() ?? s.messages.viewEmpty });
|
|
1818
|
-
}, Ze =
|
|
1826
|
+
}, Ze = Z(_n), bn = ({
|
|
1819
1827
|
value: e,
|
|
1820
1828
|
code: t,
|
|
1821
1829
|
modeConfig: n,
|
|
@@ -1834,13 +1842,13 @@ const hn = ({ value: e, code: t, modeConfig: n }) => {
|
|
|
1834
1842
|
(_) => i.request({ ..._, signal: h })
|
|
1835
1843
|
) : [],
|
|
1836
1844
|
[i, a, e]
|
|
1837
|
-
), { data: y, isLoading: u, error: c } =
|
|
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, _) => {
|
|
1838
1846
|
if (!a) return null;
|
|
1839
|
-
const A = We(h, a),
|
|
1847
|
+
const A = We(h, a), g = $e(h, a), S = g ? d(g, A, h) : A;
|
|
1840
1848
|
return /* @__PURE__ */ l("div", { children: S }, h.id ?? _);
|
|
1841
1849
|
};
|
|
1842
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 });
|
|
1843
|
-
}, Ge =
|
|
1851
|
+
}, Ge = Z(bn), gn = {
|
|
1844
1852
|
whiteSpace: "normal",
|
|
1845
1853
|
wordBreak: "break-word",
|
|
1846
1854
|
verticalAlign: "top"
|
|
@@ -1947,7 +1955,7 @@ const hn = ({ value: e, code: t, modeConfig: n }) => {
|
|
|
1947
1955
|
data: m,
|
|
1948
1956
|
isLoading: f,
|
|
1949
1957
|
error: y
|
|
1950
|
-
} =
|
|
1958
|
+
} = fe(
|
|
1951
1959
|
[
|
|
1952
1960
|
"selectLikeView",
|
|
1953
1961
|
t.code,
|
|
@@ -1980,8 +1988,8 @@ const hn = ({ value: e, code: t, modeConfig: n }) => {
|
|
|
1980
1988
|
},
|
|
1981
1989
|
a
|
|
1982
1990
|
);
|
|
1983
|
-
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) ??
|
|
1984
|
-
}, vn =
|
|
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 = ({
|
|
1985
1993
|
code: e,
|
|
1986
1994
|
value: t,
|
|
1987
1995
|
fieldGroup: n,
|
|
@@ -2034,7 +2042,7 @@ const hn = ({ value: e, code: t, modeConfig: n }) => {
|
|
|
2034
2042
|
default:
|
|
2035
2043
|
return a;
|
|
2036
2044
|
}
|
|
2037
|
-
}, tt =
|
|
2045
|
+
}, tt = Z(An), Sn = {
|
|
2038
2046
|
flexShrink: 0,
|
|
2039
2047
|
whiteSpace: "nowrap",
|
|
2040
2048
|
color: "rgba(0, 0, 0, 0.45)"
|
|
@@ -2067,8 +2075,8 @@ const hn = ({ value: e, code: t, modeConfig: n }) => {
|
|
|
2067
2075
|
}
|
|
2068
2076
|
)
|
|
2069
2077
|
})), [e, t]);
|
|
2070
|
-
return n.length === 0 ? /* @__PURE__ */ l(V, { children: "-" }) : /* @__PURE__ */ l("div", { style: { width: "100%" }, children: n.map((r) => /* @__PURE__ */
|
|
2071
|
-
/* @__PURE__ */
|
|
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: [
|
|
2072
2080
|
r.label,
|
|
2073
2081
|
":"
|
|
2074
2082
|
] }),
|
|
@@ -2124,11 +2132,11 @@ function En(e) {
|
|
|
2124
2132
|
return !!(e.option_config && e.is_option_api);
|
|
2125
2133
|
}
|
|
2126
2134
|
function Rn(e, t) {
|
|
2127
|
-
const n = U(), r =
|
|
2135
|
+
const n = U(), r = de([
|
|
2128
2136
|
"viewModeOptions",
|
|
2129
2137
|
e.map((s) => s.code),
|
|
2130
2138
|
t
|
|
2131
|
-
]), { data: i } =
|
|
2139
|
+
]), { data: i } = fe(
|
|
2132
2140
|
[r],
|
|
2133
2141
|
async (s) => {
|
|
2134
2142
|
const o = {};
|
|
@@ -2271,7 +2279,7 @@ const Kn = ({
|
|
|
2271
2279
|
}, Tn = (e) => ({
|
|
2272
2280
|
redirectUrl: e?.redirect_after_create,
|
|
2273
2281
|
data: e
|
|
2274
|
-
}), Mn = (e, t) => t?.dataPath ?
|
|
2282
|
+
}), Mn = (e, t) => t?.dataPath ? ae(e, t.dataPath) : e, Dn = (e) => e, ye = {
|
|
2275
2283
|
optionResponse: xn,
|
|
2276
2284
|
submitResponse: Tn,
|
|
2277
2285
|
viewResponse: Mn,
|
|
@@ -2303,15 +2311,15 @@ function Nn({
|
|
|
2303
2311
|
optionResponseParser: p,
|
|
2304
2312
|
customFieldRenderers: h
|
|
2305
2313
|
}) {
|
|
2306
|
-
const _ =
|
|
2314
|
+
const _ = q(/* @__PURE__ */ new Map()), A = q(/* @__PURE__ */ new Map()), g = C(() => {
|
|
2307
2315
|
const S = t ?? {
|
|
2308
2316
|
request: y ?? (() => {
|
|
2309
2317
|
throw new Error("DynamicFormProvider requires client or requestClient");
|
|
2310
2318
|
})
|
|
2311
|
-
}, b = h ? Object.entries(h).map(([F,
|
|
2319
|
+
}, b = h ? Object.entries(h).map(([F, x]) => ({
|
|
2312
2320
|
match: F,
|
|
2313
|
-
render:
|
|
2314
|
-
})) : [],
|
|
2321
|
+
render: x
|
|
2322
|
+
})) : [], w = {
|
|
2315
2323
|
...rt,
|
|
2316
2324
|
...r?.messages,
|
|
2317
2325
|
...d
|
|
@@ -2324,7 +2332,7 @@ function Nn({
|
|
|
2324
2332
|
return {
|
|
2325
2333
|
client: S,
|
|
2326
2334
|
upload: T,
|
|
2327
|
-
i18n: { messages:
|
|
2335
|
+
i18n: { messages: w },
|
|
2328
2336
|
parsers: {
|
|
2329
2337
|
optionResponse: i?.optionResponse ?? p ?? ye.optionResponse,
|
|
2330
2338
|
submitResponse: i?.submitResponse ?? ye.submitResponse,
|
|
@@ -2366,7 +2374,7 @@ function Nn({
|
|
|
2366
2374
|
m,
|
|
2367
2375
|
f
|
|
2368
2376
|
]);
|
|
2369
|
-
return /* @__PURE__ */ l(ke.Provider, { value:
|
|
2377
|
+
return /* @__PURE__ */ l(ke.Provider, { value: g, children: e });
|
|
2370
2378
|
}
|
|
2371
2379
|
function Wn(e) {
|
|
2372
2380
|
return {
|
|
@@ -2395,8 +2403,8 @@ export {
|
|
|
2395
2403
|
Ht as NestedForm,
|
|
2396
2404
|
nt as NestedFormView,
|
|
2397
2405
|
Pt as buildApiViewRequests,
|
|
2398
|
-
|
|
2399
|
-
|
|
2406
|
+
de as buildCacheKey,
|
|
2407
|
+
ue as cachedRequest,
|
|
2400
2408
|
Wn as createAxiosDynamicFormClient,
|
|
2401
2409
|
Bn as createNestedDynamicFormData,
|
|
2402
2410
|
Fe as debounce,
|
|
@@ -2414,11 +2422,11 @@ export {
|
|
|
2414
2422
|
Ne as extractViewData,
|
|
2415
2423
|
Vt as fetchApiViewItems,
|
|
2416
2424
|
he as fillTemplate,
|
|
2417
|
-
|
|
2425
|
+
ae as getByPath,
|
|
2418
2426
|
Yt as getCached,
|
|
2419
2427
|
We as getMappedLabel,
|
|
2420
2428
|
$e as getMappedLink,
|
|
2421
|
-
|
|
2429
|
+
le as getNestedFormCodeHint,
|
|
2422
2430
|
Re as getNestedSubmitContainerKey,
|
|
2423
2431
|
W as isEmptyValue,
|
|
2424
2432
|
Ft as mapOptionToSelectItem,
|
|
@@ -2426,7 +2434,7 @@ export {
|
|
|
2426
2434
|
Ue as normalizeApiViewConfig,
|
|
2427
2435
|
Xe as normalizeMetaForForm,
|
|
2428
2436
|
Nt as parseFormValues,
|
|
2429
|
-
|
|
2437
|
+
oe as replaceTemplateInObject,
|
|
2430
2438
|
Ce as resolveApiOptionMeta,
|
|
2431
2439
|
St as resolveFieldRenderer,
|
|
2432
2440
|
kt as resolveFieldRendererFromMap,
|
|
@@ -2435,7 +2443,7 @@ export {
|
|
|
2435
2443
|
Jt as setCache,
|
|
2436
2444
|
Ye as unwrapMultipleFormValueForEdit,
|
|
2437
2445
|
He as unwrapSingleFormValueForEdit,
|
|
2438
|
-
|
|
2446
|
+
fe as useCachedViewRequest,
|
|
2439
2447
|
rn as useDependencyValues,
|
|
2440
2448
|
nn as useDynamicField,
|
|
2441
2449
|
U as useDynamicFormContext,
|