@trungkhai/dynamic-form 0.1.3 → 0.1.4

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