@rytass/bpm-core-react 0.9.0 → 0.10.0

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/chunks/{FormBuilderView-BPLwAJGv.cjs → FormBuilderView-D6baVqBY.cjs} +2 -2
  3. package/dist/chunks/{FormBuilderView-BPLwAJGv.cjs.map → FormBuilderView-D6baVqBY.cjs.map} +1 -1
  4. package/dist/chunks/{FormBuilderView-Do9-MIAe.js → FormBuilderView-QtREqV4j.js} +2 -2
  5. package/dist/chunks/{FormBuilderView-Do9-MIAe.js.map → FormBuilderView-QtREqV4j.js.map} +1 -1
  6. package/dist/chunks/FormRendererView-Cw9LiidV.cjs +2 -0
  7. package/dist/chunks/FormRendererView-Cw9LiidV.cjs.map +1 -0
  8. package/dist/chunks/{FormRendererView-C5POZbWz.js → FormRendererView-D8QHLvd0.js} +224 -139
  9. package/dist/chunks/FormRendererView-D8QHLvd0.js.map +1 -0
  10. package/dist/chunks/{compose-CULMDsLS.cjs → compose-CODnd9-2.cjs} +2 -2
  11. package/dist/chunks/{compose-CULMDsLS.cjs.map → compose-CODnd9-2.cjs.map} +1 -1
  12. package/dist/chunks/{compose-DJBlA5PD.js → compose-D-OS-Ngs.js} +4 -4
  13. package/dist/chunks/{compose-DJBlA5PD.js.map → compose-D-OS-Ngs.js.map} +1 -1
  14. package/dist/chunks/{designer-CmqAU92b.cjs → designer-Cdn10NNl.cjs} +2 -2
  15. package/dist/chunks/{designer-CmqAU92b.cjs.map → designer-Cdn10NNl.cjs.map} +1 -1
  16. package/dist/chunks/{designer-BszXJ5RO.js → designer-DDSxwtjV.js} +2 -2
  17. package/dist/chunks/{designer-BszXJ5RO.js.map → designer-DDSxwtjV.js.map} +1 -1
  18. package/dist/chunks/detail-CtVu5NTi.cjs +2 -0
  19. package/dist/chunks/detail-CtVu5NTi.cjs.map +1 -0
  20. package/dist/chunks/{detail-DAak2OXS.js → detail-DAPz2qyn.js} +31 -30
  21. package/dist/chunks/detail-DAPz2qyn.js.map +1 -0
  22. package/dist/pages/instances/detail/index.cjs +1 -1
  23. package/dist/pages/instances/detail/index.js +1 -1
  24. package/dist/pages/templates/compose/index.cjs +1 -1
  25. package/dist/pages/templates/compose/index.js +1 -1
  26. package/dist/pages/templates/designer/index.cjs +1 -1
  27. package/dist/pages/templates/designer/index.js +1 -1
  28. package/dist/views/forms/builder/index.cjs +1 -1
  29. package/dist/views/forms/builder/index.js +1 -1
  30. package/dist/views/forms/renderer/form-data-source-field.d.ts +15 -0
  31. package/dist/views/forms/renderer/index.cjs +1 -1
  32. package/dist/views/forms/renderer/index.js +2 -2
  33. package/dist/views/instances/detail/index.cjs +1 -1
  34. package/dist/views/instances/detail/index.js +1 -1
  35. package/dist/views/instances/new/index.cjs +1 -1
  36. package/dist/views/instances/new/index.cjs.map +1 -1
  37. package/dist/views/instances/new/index.js +8 -6
  38. package/dist/views/instances/new/index.js.map +1 -1
  39. package/dist/views/templates/compose/index.cjs +1 -1
  40. package/dist/views/templates/compose/index.js +1 -1
  41. package/dist/views/templates/designer/index.cjs +1 -1
  42. package/dist/views/templates/designer/index.js +1 -1
  43. package/package.json +29 -20
  44. package/dist/chunks/FormRendererView-C5POZbWz.js.map +0 -1
  45. package/dist/chunks/FormRendererView-DNtNodNl.cjs +0 -2
  46. package/dist/chunks/FormRendererView-DNtNodNl.cjs.map +0 -1
  47. package/dist/chunks/detail-CDexqBoU.cjs +0 -2
  48. package/dist/chunks/detail-CDexqBoU.cjs.map +0 -1
  49. package/dist/chunks/detail-DAak2OXS.js.map +0 -1
@@ -3,10 +3,11 @@ import { t as e } from "./bpm-form-field-Cao0rMol.js";
3
3
  import { useCallback as t, useEffect as n, useMemo as r, useRef as i, useState as a } from "react";
4
4
  import { AutoComplete as o, Button as s, CheckboxGroup as c, DatePicker as l, DateTimePicker as u, Input as d, RadioGroup as f, Select as p, Textarea as m, Toggle as h, Typography as g, Upload as _ } from "@mezzanine-ui/react";
5
5
  import { jsx as v, jsxs as y } from "react/jsx-runtime";
6
- import { buildFormRendererValues as b, clampOptionalNumber as x, formatDatePickerValue as S, formatDateTimePickerValue as C, isFormRendererFieldReadonly as w, isFormRendererFieldRequired as T, mergeFormDataSourceOptions as E, parseOptionalNumberInput as D, previewFormFieldOptions as ee, readDatePickerValue as O, readFieldOptionAsSelectOption as k, readFormDataSourceErrorMessage as te, readFormDataSourceValueSignature as A, readFormFieldOptions as j, readMissingFormDataSourceDependencies as ne, readMissingFormDataSourceOptionValues as re, readSelectOption as M, readSelectedFormDataSourceOptions as N, readVisibleFormRendererFields as P } from "@rytass/bpm-core-client/form";
7
- import { isFormDataSourceFieldDefinition as F, isFormStaticOptionFieldDefinition as I, readFormFieldSelectionMode as L } from "@rytass/bpm-core-shared/form";
6
+ import { buildFormRendererValues as b, clampOptionalNumber as x, formatDatePickerValue as S, formatDateTimePickerValue as C, isFormRendererFieldReadonly as w, isFormRendererFieldRequired as T, mergeFormDataSourceOptions as E, parseOptionalNumberInput as D, previewFormFieldOptions as ee, previewResolveFormFieldOptions as te, readDatePickerValue as O, readFieldOptionAsSelectOption as k, readFormDataSourceErrorCode as ne, readFormDataSourceErrorMessage as re, readFormDataSourceSelectedValues as ie, readFormDataSourceValueSignature as A, readFormFieldOptions as ae, readMissingFormDataSourceDependencies as oe, readMissingFormDataSourceOptionValues as j, readSelectOption as M, readSelectedFormDataSourceOptions as N, readVisibleFormRendererFields as se, resolveFormFieldOptions as ce } from "@rytass/bpm-core-client/form";
7
+ import { isFormDataSourceFieldDefinition as le, isFormStaticOptionFieldDefinition as P, readFormFieldSelectionMode as F } from "@rytass/bpm-core-shared/form";
8
8
  //#region src/views/forms/renderer/form-data-source-field.ts
9
- var R = {
9
+ var ue = {
10
+ canRetry: !1,
10
11
  error: null,
11
12
  hasValue: !1,
12
13
  hasNextPage: !1,
@@ -16,166 +17,250 @@ var R = {
16
17
  options: [],
17
18
  retry: () => void 0,
18
19
  status: "IDLE"
19
- };
20
- function z(e) {
21
- let o = F(e.field) ? e.field : null, s = o ? e.optionSnapshots?.[o.fieldKey] : void 0, c = JSON.stringify(s ?? null), l = r(() => s?.options ?? [], [c]), u = JSON.stringify(e.formData), d = JSON.stringify(e.initialFormData ?? {}), f = JSON.stringify(e.schema), p = JSON.stringify(e.uiSchema), m = e.context?.kind, h = e.context?.kind === "runtime" ? e.context.instanceId : void 0, g = e.context?.kind === "runtime" ? e.context.templateId : void 0, _ = o ? ne(o, e.formData) : [], v = JSON.stringify(_), y = o ? JSON.stringify({
20
+ }, I = [], de = 10, fe = ["FORM_DATA_SOURCE_SEARCH_NOT_SUPPORTED", "FORM_DATA_SOURCE_SEARCH_TOO_SHORT"];
21
+ function L(e) {
22
+ let o = le(e.field) ? e.field : null, s = o ? e.optionSnapshots?.[o.fieldKey] : void 0, c = o ? JSON.stringify({
23
+ dataSource: o.dataSource,
24
+ fieldKey: o.fieldKey,
25
+ type: o.type
26
+ }) : "", l = JSON.stringify(s ?? null), u = r(() => s?.options ?? [], [l]), d = JSON.stringify(e.formData), f = JSON.stringify(e.initialFormData ?? {}), p = JSON.stringify(e.schema), m = JSON.stringify(e.uiSchema), h = e.context?.kind, g = e.context?.kind === "runtime" ? e.context.instanceId : void 0, _ = e.context?.kind === "runtime" ? e.context.templateId : void 0, v = o ? e.formData[o.fieldKey] : void 0, y = A(v), b = r(() => ie(v), [y]), x = b.length > 0, S = o ? JSON.stringify({
22
27
  bindings: o.dataSource.bindings.map((t) => t.from.kind === "FIELD" ? {
23
28
  fieldKey: t.from.fieldKey,
24
29
  value: e.formData[t.from.fieldKey]
25
30
  } : { value: t.from.value }),
26
31
  value: e.initialFormData !== void 0 || e.initialValue !== void 0 ? e.formData[o.fieldKey] : void 0
27
- }) : "", b = r(() => {
28
- if (m === "preview") return { kind: "preview" };
29
- if (m === "runtime" && !e.readonly) return {
30
- instanceId: h,
32
+ }) : "", C = r(() => {
33
+ if (h === "preview") return { kind: "preview" };
34
+ if (h === "runtime" && !e.readonly) return {
35
+ instanceId: g,
31
36
  kind: "runtime",
32
- templateId: g
37
+ templateId: _
33
38
  };
34
39
  }, [
35
- h,
36
- m,
37
40
  g,
41
+ h,
42
+ _,
38
43
  e.readonly
39
- ]), x = o ? (e.initialFormData !== void 0 || e.initialValue !== void 0) && A(e.initialValue) !== A(e.formData[o.fieldKey]) : !1, S = o ? e.initialFormData !== void 0 && o.dataSource.bindings.some((t) => t.from.kind === "FIELD" ? A(e.initialFormData?.[t.from.fieldKey]) !== A(e.formData[t.from.fieldKey]) : !1) : !1, C = !!(s && (x || S)), [w, T] = a([]), [D, O] = a(""), [k, M] = a(null), [P, I] = a(o && s ? C ? "STALE" : "VALID" : "IDLE"), [L, z] = a(null), B = i(0), V = i({
44
+ ]), w = o ? (e.initialFormData !== void 0 || e.initialValue !== void 0) && A(e.initialValue) !== y : !1, T = o ? e.initialFormData !== void 0 && o.dataSource.bindings.some((t) => t.from.kind === "FIELD" ? A(e.initialFormData?.[t.from.fieldKey]) !== A(e.formData[t.from.fieldKey]) : !1) : !1, D = !!((s || x) && (w || T)), O = !!(o && C && D && x), k = he({
45
+ hasSnapshot: !!s,
46
+ hasValue: x,
47
+ isStale: D,
48
+ readonly: e.readonly
49
+ }), j = !!(o && C && o.type !== "autocomplete"), M = ge(D, j && o !== null && oe(o, e.formData).length > 0), [se, P] = a([]), [F, I] = a(""), [L, R] = a(null), [z, pe] = a(null), [ye, V] = a(() => o ? j ? M : k : "IDLE"), [be, H] = a(null), U = i(0), W = i(0), G = i(0), K = i(null), q = i(null), J = i({
40
50
  cursor: null,
41
51
  searchText: ""
42
- }), H = r(() => Object.entries(e.formData).reduce((e, [t, n]) => n === void 0 ? e : {
52
+ }), Y = r(() => Object.entries(e.formData).reduce((e, [t, n]) => n === void 0 ? e : {
43
53
  ...e,
44
54
  [t]: n
45
- }, {}), [u]), U = r(() => E(l, w), [w, l]), W = r(() => re(o ? e.formData[o.fieldKey] : void 0, U), [
46
- o,
47
- e.formData,
48
- U
49
- ]), G = ie(o ? e.formData[o.fieldKey] : void 0), K = t((t, n) => {
50
- if (!o || !b) return;
51
- if (_.length > 0) {
52
- I("WAITING_FOR_DEPENDENCIES"), z(null);
53
- return;
54
- }
55
- let r = B.current + 1;
56
- B.current = r, V.current = {
55
+ }, {}), [d]), X = r(() => E(u, se), [se, u]), Z = z && z.signature === S ? z : null, xe = O && !Z, Q = me({
56
+ options: X,
57
+ resolution: Z,
58
+ resolvePending: xe,
59
+ value: v
60
+ }), $ = t((t, n) => {
61
+ if (!o || !C) return;
62
+ let r = W.current + 1;
63
+ W.current = r, J.current = {
57
64
  cursor: n,
58
65
  searchText: t
59
- }, I(C ? "STALE" : "LOADING"), z(null), (b.kind === "preview" ? ee({
66
+ }, K.current?.abort();
67
+ let i = new AbortController();
68
+ K.current = i, V(M), H(null), (C.kind === "preview" ? ee({
60
69
  cursor: n,
61
70
  fieldKey: o.fieldKey,
62
- formData: H,
71
+ formData: Y,
63
72
  schema: e.schema,
64
73
  searchText: t,
74
+ signal: i.signal,
65
75
  uiSchema: e.uiSchema
66
- }) : j({
76
+ }) : ae({
67
77
  cursor: n,
68
78
  fieldKey: o.fieldKey,
69
- formData: H,
70
- instanceId: b.instanceId ?? null,
79
+ formData: Y,
80
+ instanceId: C.instanceId ?? null,
71
81
  searchText: t,
72
- templateId: b.templateId ?? null
73
- })).then((t) => {
74
- B.current === r && (T((r) => E(N(o ? e.formData[o.fieldKey] : void 0, r), n ? r : [], t.options)), M(t.nextCursor), I("VALID"), z(null));
82
+ signal: i.signal,
83
+ templateId: C.templateId ?? null
84
+ })).then((a) => {
85
+ B(i, W, r) || (P((t) => E(N(o ? e.formData[o.fieldKey] : void 0, t), n ? t : [], a.options)), R(a.nextCursor), H(null), U.current = n ? U.current + a.options.length : a.options.length, a.nextCursor && a.options.length > 0 && U.current < de && Se.current(t, a.nextCursor), V(a.waitingForFieldKeys.length ? "WAITING_FOR_DEPENDENCIES" : "VALID"));
75
86
  }).catch((e) => {
76
- B.current === r && (I("UNAVAILABLE"), z(te(e) ?? (e instanceof Error ? e.message : "選項來源暫時無法使用。")));
87
+ if (B(i, W, r)) return;
88
+ let t = re(e) ?? "選項來源暫時無法使用。", n = ne(e);
89
+ H(t), V(_e(!!(n && fe.includes(n)), x));
77
90
  });
78
91
  }, [
79
- o,
80
- b,
92
+ c,
81
93
  C,
82
- _.length,
83
- H,
84
- f,
85
- p
86
- ]), q = i(K);
87
- q.current = K, n(() => {
88
- if (B.current += 1, T((t) => N(o ? e.formData[o.fieldKey] : void 0, t)), M((e) => e === null ? e : null), O((e) => e && ""), z((e) => e && null), !o) {
89
- I("IDLE");
90
- return;
91
- }
92
- if (_.length > 0) {
93
- I("WAITING_FOR_DEPENDENCIES");
94
- return;
95
- }
96
- if (!b) {
97
- I(s ? C ? "STALE" : "VALID" : e.readonly ? "UNAVAILABLE" : "IDLE");
94
+ x,
95
+ M,
96
+ Y,
97
+ p,
98
+ m
99
+ ]), Se = i($);
100
+ Se.current = $;
101
+ let Ce = t(() => {
102
+ if (!o || !C || b.length === 0) return;
103
+ let t = S, n = G.current + 1;
104
+ G.current = n, q.current?.abort();
105
+ let r = new AbortController();
106
+ q.current = r, H(null), (C.kind === "preview" ? te({
107
+ fieldKey: o.fieldKey,
108
+ formData: Y,
109
+ schema: e.schema,
110
+ signal: r.signal,
111
+ uiSchema: e.uiSchema,
112
+ values: b
113
+ }) : ce({
114
+ fieldKey: o.fieldKey,
115
+ formData: Y,
116
+ instanceId: C.instanceId ?? null,
117
+ signal: r.signal,
118
+ templateId: C.templateId ?? null,
119
+ values: b
120
+ })).then((e) => {
121
+ if (!B(r, G, n)) {
122
+ if (e.waitingForFieldKeys.length) {
123
+ V("WAITING_FOR_DEPENDENCIES");
124
+ return;
125
+ }
126
+ P((t) => E(t, e.options)), pe({
127
+ signature: t,
128
+ unresolvedValues: e.unresolvedValues
129
+ }), V("VALID");
130
+ }
131
+ }).catch((e) => {
132
+ B(r, G, n) || (V("UNAVAILABLE"), H(re(e) ?? "選項來源暫時無法使用。"));
133
+ });
134
+ }, [
135
+ S,
136
+ c,
137
+ C,
138
+ Y,
139
+ p,
140
+ b,
141
+ m
142
+ ]), we = i(Ce);
143
+ we.current = Ce, n(() => {
144
+ if (W.current += 1, K.current?.abort(), P((e) => N(v, e)), R((e) => e === null ? e : null), I((e) => e && ""), H((e) => e && null), !o) {
145
+ V("IDLE");
98
146
  return;
99
147
  }
100
- if (o.type === "autocomplete") {
101
- I(s ? C ? "STALE" : "VALID" : "IDLE");
148
+ if (!j) {
149
+ V(k);
102
150
  return;
103
151
  }
104
- q.current("", null);
152
+ Se.current("", null);
105
153
  }, [
106
- o,
107
- b,
108
- y,
109
- d,
154
+ j,
155
+ c,
156
+ C,
157
+ S,
158
+ f,
110
159
  e.readonly,
160
+ M,
161
+ k,
162
+ l
163
+ ]), n(() => {
164
+ O && we.current();
165
+ }, [
166
+ S,
111
167
  C,
112
- v,
113
- c
114
- ]);
115
- let J = t((t) => {
116
- O(t), T((t) => N(o ? e.formData[o.fieldKey] : void 0, t)), M(null), K(t, null);
117
- }, [K]), Y = t(() => {
118
- k && K(D, k);
168
+ O
169
+ ]), n(() => () => {
170
+ K.current?.abort(), q.current?.abort();
171
+ }, []);
172
+ let Te = t((e) => {
173
+ I(e), P((e) => N(v, e)), R(null), $(e, null);
174
+ }, [$]), Ee = t(() => {
175
+ L && $(F, L);
119
176
  }, [
120
- K,
121
- k,
122
- D
123
- ]), X = t(() => {
124
- K(V.current.searchText, V.current.cursor);
125
- }, [K]);
177
+ $,
178
+ L,
179
+ F
180
+ ]), De = t(() => {
181
+ C && ($(J.current.searchText, J.current.cursor), O && we.current());
182
+ }, [
183
+ C,
184
+ $,
185
+ O
186
+ ]);
126
187
  return o ? {
127
- error: L,
128
- hasValue: G,
129
- hasNextPage: !!k,
130
- invalidValues: W,
131
- onReachBottom: Y,
132
- onSearch: J,
133
- options: U,
134
- retry: X,
135
- status: P === "VALID" && W.length ? "INVALID" : P
136
- } : R;
188
+ canRetry: !!C,
189
+ error: be,
190
+ hasValue: x,
191
+ hasNextPage: !!L,
192
+ invalidValues: Q,
193
+ onReachBottom: Ee,
194
+ onSearch: Te,
195
+ options: X,
196
+ retry: De,
197
+ status: ve({
198
+ invalidValues: Q,
199
+ resolvePending: xe,
200
+ status: ye
201
+ })
202
+ } : ue;
137
203
  }
138
- function B(e) {
204
+ function R(e) {
139
205
  switch (e.status) {
140
206
  case "WAITING_FOR_DEPENDENCIES": return "請先填寫相依欄位。";
141
207
  case "STALE": return "選項需要重新載入或驗證。";
142
208
  case "INVALID": return e.invalidValues.length ? `無法辨識選項:${e.invalidValues.join("、")}` : "目前選項已失效,請重新選擇。";
143
209
  case "UNAVAILABLE": return e.error ?? "選項來源暫時無法使用。";
144
- case "VALID": return e.options.length ? null : "目前沒有可用選項。";
145
- default: return null;
210
+ case "VALID": return e.error ?? (e.options.length ? null : "目前沒有可用選項。");
211
+ default: return e.error;
146
212
  }
147
213
  }
148
- function V(e) {
214
+ function z(e) {
149
215
  return e.hasValue && e.status !== "VALID";
150
216
  }
151
- function ie(e) {
152
- return e == null ? !1 : typeof e == "string" ? e.trim().length > 0 : Array.isArray(e) ? e.length > 0 : !0;
217
+ function pe(e) {
218
+ let t = e.filter(z);
219
+ return t.length === 0 ? null : t.every((e) => e.status === "LOADING" || e.status === "STALE") ? "選項驗證中,請稍候再送出。" : "請先完成動態選項驗證。";
220
+ }
221
+ function me(e) {
222
+ return e.resolution ? e.resolution.unresolvedValues : e.resolvePending ? I : j(e.value, e.options);
223
+ }
224
+ function he(e) {
225
+ return e.isStale ? "STALE" : e.hasSnapshot ? "VALID" : e.readonly && e.hasValue ? "UNAVAILABLE" : "IDLE";
226
+ }
227
+ function ge(e, t) {
228
+ return t ? "WAITING_FOR_DEPENDENCIES" : e ? "STALE" : "LOADING";
229
+ }
230
+ function _e(e, t) {
231
+ return e ? t ? "VALID" : "IDLE" : "UNAVAILABLE";
232
+ }
233
+ function ve(e) {
234
+ return e.status === "LOADING" || e.status === "UNAVAILABLE" || e.status === "WAITING_FOR_DEPENDENCIES" ? e.status : e.invalidValues.length ? "INVALID" : e.resolvePending ? "STALE" : e.status;
235
+ }
236
+ function B(e, t, n) {
237
+ return e.signal.aborted || t.current !== n;
153
238
  }
154
239
  //#endregion
155
240
  //#region src/views/forms/renderer/FormRendererView.tsx
156
- var H = {
241
+ var ye = {
157
242
  alignItems: "start",
158
243
  display: "grid",
159
244
  gap: 12,
160
245
  gridTemplateColumns: "repeat(12, minmax(0, 1fr))"
161
- }, U = { gridColumn: "1 / -1" }, W = {
246
+ }, V = { gridColumn: "1 / -1" }, be = {
162
247
  alignItems: "start",
163
248
  display: "grid",
164
249
  gap: 8,
165
250
  minWidth: 0
166
- }, G = {
251
+ }, H = {
167
252
  minWidth: "100%",
168
253
  width: "100%"
169
254
  };
170
- function K(e) {
255
+ function U(e) {
171
256
  e && (e.style.width = "100%");
172
257
  }
173
- function q({ dataSourceContext: e, dataSourceInitialValues: t, emptyText: o = "尚未建立欄位。", errors: s = {}, maxWidth: c, onChange: l, onDataSourceStateChange: u, onUploadAttachment: d, optionSnapshots: f, readonly: p = !1, schema: m, singleColumn: h = !1, uiSchema: _, value: y }) {
258
+ function W({ dataSourceContext: e, dataSourceInitialValues: t, emptyText: o = "尚未建立欄位。", errors: s = {}, maxWidth: c, onChange: l, onDataSourceStateChange: u, onUploadAttachment: d, optionSnapshots: f, readonly: p = !1, schema: m, singleColumn: h = !1, uiSchema: _, value: y }) {
174
259
  let [x, S] = a(() => b(m.fields, y ?? {})), C = r(() => b(m.fields, y ?? x), [
175
260
  x,
176
261
  m.fields,
177
262
  y
178
- ]), w = i(C), T = r(() => P(m, _, C), [
263
+ ]), w = i(C), T = r(() => se(m, _, C), [
179
264
  m,
180
265
  _,
181
266
  C
@@ -194,13 +279,13 @@ function q({ dataSourceContext: e, dataSourceInitialValues: t, emptyText: o = "
194
279
  }
195
280
  return T.length ? /* @__PURE__ */ v("div", {
196
281
  style: {
197
- ...H,
282
+ ...ye,
198
283
  ...h ? {
199
284
  maxWidth: c,
200
285
  width: "100%"
201
286
  } : {}
202
287
  },
203
- children: T.map((n) => /* @__PURE__ */ v(J, {
288
+ children: T.map((n) => /* @__PURE__ */ v(G, {
204
289
  dataSourceContext: e,
205
290
  dataSourceInitialValues: t,
206
291
  field: n,
@@ -213,25 +298,25 @@ function q({ dataSourceContext: e, dataSourceInitialValues: t, emptyText: o = "
213
298
  readonly: p,
214
299
  schema: m,
215
300
  style: {
216
- ...W,
217
- gridColumn: `span ${h ? 12 : oe(n, _)}`
301
+ ...be,
302
+ gridColumn: `span ${h ? 12 : Y(n, _)}`
218
303
  },
219
304
  value: C[n.fieldKey],
220
305
  values: C,
221
306
  uiSchema: _
222
307
  }, n.fieldKey))
223
308
  }) : /* @__PURE__ */ v("div", {
224
- style: H,
309
+ style: ye,
225
310
  children: /* @__PURE__ */ v(g, {
226
311
  color: "text-neutral",
227
- style: U,
312
+ style: V,
228
313
  variant: "body",
229
314
  children: m.fields.length > 0 ? "目前條件下沒有可填寫欄位。" : o
230
315
  })
231
316
  });
232
317
  }
233
- function J({ dataSourceContext: t, dataSourceInitialValues: r, error: i, field: a, fields: o, onChange: c, onDataSourceStateChange: l, onUploadAttachment: u, optionSnapshots: d, readonly: f, schema: p, style: m, value: h, values: _, uiSchema: b }) {
234
- let x = T(a, o, _), S = f || w(a, o, _), C = z({
318
+ function G({ dataSourceContext: t, dataSourceInitialValues: r, error: i, field: a, fields: o, onChange: c, onDataSourceStateChange: l, onUploadAttachment: u, optionSnapshots: d, readonly: f, schema: p, style: m, value: h, values: _, uiSchema: b }) {
319
+ let x = T(a, o, _), S = f || w(a, o, _), C = L({
235
320
  context: t,
236
321
  field: a,
237
322
  formData: _,
@@ -241,9 +326,9 @@ function J({ dataSourceContext: t, dataSourceInitialValues: r, error: i, field:
241
326
  readonly: S,
242
327
  schema: p,
243
328
  uiSchema: b
244
- }), E = B(C);
329
+ }), E = R(C);
245
330
  return n(() => {
246
- F(a) && l?.(a.fieldKey, {
331
+ le(a) && l?.(a.fieldKey, {
247
332
  hasValue: C.hasValue,
248
333
  invalidValues: C.invalidValues,
249
334
  status: C.status
@@ -264,7 +349,7 @@ function J({ dataSourceContext: t, dataSourceInitialValues: r, error: i, field:
264
349
  label: a.label,
265
350
  name: a.fieldKey,
266
351
  required: x,
267
- children: X(a, h, S, c, u, t, C)
352
+ children: q(a, h, S, c, u, t, C)
268
353
  }),
269
354
  i ? /* @__PURE__ */ v(g, {
270
355
  color: "text-error",
@@ -272,12 +357,12 @@ function J({ dataSourceContext: t, dataSourceInitialValues: r, error: i, field:
272
357
  children: i
273
358
  }) : null,
274
359
  E ? /* @__PURE__ */ y("div", {
275
- style: Y,
360
+ style: K,
276
361
  children: [/* @__PURE__ */ v(g, {
277
362
  color: C.status === "INVALID" || C.status === "UNAVAILABLE" ? "text-error" : "text-neutral",
278
363
  variant: "caption",
279
364
  children: E
280
- }), C.status === "UNAVAILABLE" ? /* @__PURE__ */ v(s, {
365
+ }), C.status === "UNAVAILABLE" && C.canRetry ? /* @__PURE__ */ v(s, {
281
366
  onClick: C.retry,
282
367
  size: "sub",
283
368
  type: "button",
@@ -288,20 +373,20 @@ function J({ dataSourceContext: t, dataSourceInitialValues: r, error: i, field:
288
373
  ]
289
374
  });
290
375
  }
291
- var Y = {
376
+ var K = {
292
377
  alignItems: "center",
293
378
  display: "flex",
294
379
  gap: 8
295
380
  };
296
- function X(e, t, n, r, i, a, o) {
381
+ function q(e, t, n, r, i, a, o) {
297
382
  if (e.type === "textarea") return /* @__PURE__ */ v(m, {
298
383
  onChange: (t) => r(e.fieldKey, t.target.value),
299
384
  placeholder: e.placeholder ?? "請輸入多行文字",
300
385
  readOnly: n,
301
- ref: K,
386
+ ref: U,
302
387
  rows: 3,
303
- style: G,
304
- value: Z(t)
388
+ style: H,
389
+ value: X(t)
305
390
  });
306
391
  if (e.type === "boolean") return /* @__PURE__ */ v(h, {
307
392
  checked: t === !0,
@@ -309,8 +394,8 @@ function X(e, t, n, r, i, a, o) {
309
394
  label: "啟用",
310
395
  onChange: (t) => r(e.fieldKey, t.target.checked)
311
396
  });
312
- if (F(e)) return ae(e, t, n, r, a, o);
313
- if (I(e) && e.type === "checkbox") {
397
+ if (le(e)) return J(e, t, n, r, a, o);
398
+ if (P(e) && e.type === "checkbox") {
314
399
  let i = e.options.map(k);
315
400
  return /* @__PURE__ */ v(p, {
316
401
  mode: "multiple",
@@ -318,17 +403,17 @@ function X(e, t, n, r, i, a, o) {
318
403
  options: i,
319
404
  placeholder: e.placeholder ?? "請選擇一或多個選項",
320
405
  readOnly: n,
321
- value: i.filter((e) => Q(t).includes(e.id))
406
+ value: i.filter((e) => Z(t).includes(e.id))
322
407
  });
323
408
  }
324
- if (I(e)) {
409
+ if (P(e)) {
325
410
  let i = e.options.map(k);
326
411
  return /* @__PURE__ */ v(p, {
327
412
  onChange: (t) => r(e.fieldKey, t?.id ?? void 0),
328
413
  options: i,
329
414
  placeholder: e.placeholder ?? "請選擇",
330
415
  readOnly: n,
331
- value: M(i, Z(t))
416
+ value: M(i, X(t))
332
417
  });
333
418
  }
334
419
  return e.type === "file_upload" ? /* @__PURE__ */ v(_, {
@@ -349,7 +434,7 @@ function X(e, t, n, r, i, a, o) {
349
434
  format: "YYYY-MM-DD",
350
435
  fullWidth: !0,
351
436
  onChange: (t) => r(e.fieldKey, S(t)),
352
- placeholder: e.placeholder ?? $(e.type),
437
+ placeholder: e.placeholder ?? Q(e.type),
353
438
  readOnly: n,
354
439
  value: O(t)
355
440
  }) : e.type === "datetime" ? /* @__PURE__ */ v(u, {
@@ -370,26 +455,26 @@ function X(e, t, n, r, i, a, o) {
370
455
  max: e.maximum,
371
456
  min: e.minimum
372
457
  })),
373
- placeholder: e.placeholder ?? $(e.type),
458
+ placeholder: e.placeholder ?? Q(e.type),
374
459
  ...n ? { readonly: !0 } : {},
375
460
  showSpinner: !0,
376
- value: se(t),
461
+ value: xe(t),
377
462
  variant: "measure"
378
463
  }) : /* @__PURE__ */ v(d, {
379
464
  fullWidth: !0,
380
465
  onChange: (t) => r(e.fieldKey, t.target.value),
381
- placeholder: e.placeholder ?? $(e.type),
466
+ placeholder: e.placeholder ?? Q(e.type),
382
467
  ...n ? { readonly: !0 } : {},
383
- value: Z(t),
468
+ value: X(t),
384
469
  variant: "base"
385
470
  });
386
471
  }
387
- function ae(e, t, n, r, i, a) {
388
- let s = a.options.map(k), l = N(t, a.options).map(k), u = a.status === "LOADING", d = a.status === "WAITING_FOR_DEPENDENCIES", m = !!i && !n, h = n || d;
389
- return e.type === "autocomplete" ? L(e) === "multiple" ? /* @__PURE__ */ v(o, {
472
+ function J(e, t, n, r, i, a) {
473
+ let s = a.options.map(k), l = N(t, a.options).map(k), u = a.status === "LOADING", d = a.status === "WAITING_FOR_DEPENDENCIES", m = !!i && !n, h = n || d, g = n;
474
+ return e.type === "autocomplete" ? F(e) === "multiple" ? /* @__PURE__ */ v(o, {
390
475
  asyncData: m,
391
476
  clearSearchText: !0,
392
- disabled: h,
477
+ disabled: g,
393
478
  disabledOptionsFilter: m,
394
479
  globalPortal: !0,
395
480
  loading: u,
@@ -405,7 +490,7 @@ function ae(e, t, n, r, i, a) {
405
490
  }) : /* @__PURE__ */ v(o, {
406
491
  asyncData: m,
407
492
  clearSearchText: !0,
408
- disabled: h,
493
+ disabled: g,
409
494
  disabledOptionsFilter: m,
410
495
  globalPortal: !0,
411
496
  loading: u,
@@ -423,7 +508,7 @@ function ae(e, t, n, r, i, a) {
423
508
  name: e.fieldKey,
424
509
  onChange: (t) => r(e.fieldKey, t.target.value || void 0),
425
510
  options: s,
426
- value: Z(t)
511
+ value: X(t)
427
512
  }) : e.type === "checkbox" ? /* @__PURE__ */ v(c, {
428
513
  disabled: h,
429
514
  name: e.fieldKey,
@@ -432,8 +517,8 @@ function ae(e, t, n, r, i, a) {
432
517
  label: e.name,
433
518
  value: e.id
434
519
  })),
435
- value: [...Q(t)]
436
- }) : L(e) === "multiple" ? /* @__PURE__ */ v(p, {
520
+ value: [...Z(t)]
521
+ }) : F(e) === "multiple" ? /* @__PURE__ */ v(p, {
437
522
  disabled: h,
438
523
  loading: u,
439
524
  mode: "multiple",
@@ -454,23 +539,23 @@ function ae(e, t, n, r, i, a) {
454
539
  value: l[0] ?? null
455
540
  });
456
541
  }
457
- function oe(e, t) {
542
+ function Y(e, t) {
458
543
  return {
459
544
  FULL: 12,
460
545
  HALF: 6,
461
546
  THIRD: 4
462
547
  }[t.layout.find((t) => t.fieldKey === e.fieldKey)?.width ?? "FULL"];
463
548
  }
464
- function Z(e) {
549
+ function X(e) {
465
550
  return typeof e == "string" ? e : "";
466
551
  }
467
- function Q(e) {
552
+ function Z(e) {
468
553
  return Array.isArray(e) ? e : [];
469
554
  }
470
- function se(e) {
555
+ function xe(e) {
471
556
  return typeof e == "number" ? String(e) : "";
472
557
  }
473
- function $(e) {
558
+ function Q(e) {
474
559
  return {
475
560
  boolean: "",
476
561
  autocomplete: "請輸入或選擇",
@@ -487,6 +572,6 @@ function $(e) {
487
572
  }[e];
488
573
  }
489
574
  //#endregion
490
- export { z as i, V as n, B as r, q as t };
575
+ export { L as a, pe as i, z as n, R as r, W as t };
491
576
 
492
- //# sourceMappingURL=FormRendererView-C5POZbWz.js.map
577
+ //# sourceMappingURL=FormRendererView-D8QHLvd0.js.map