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