@rytass/bpm-core-react 0.18.1 → 0.19.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 (68) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/chunks/{FormBuilderView-vQfVc08Z.js → FormBuilderView-Djlm3y4S.js} +2 -2
  3. package/dist/chunks/{FormBuilderView-vQfVc08Z.js.map → FormBuilderView-Djlm3y4S.js.map} +1 -1
  4. package/dist/chunks/{FormBuilderView-CHaAQL5v.cjs → FormBuilderView-G6uRSywl.cjs} +2 -2
  5. package/dist/chunks/{FormBuilderView-CHaAQL5v.cjs.map → FormBuilderView-G6uRSywl.cjs.map} +1 -1
  6. package/dist/chunks/{FormRendererView-CTLlG13b.js → FormRendererView-DHfVgbo6.js} +391 -265
  7. package/dist/chunks/FormRendererView-DHfVgbo6.js.map +1 -0
  8. package/dist/chunks/FormRendererView-DwfFbaip.cjs +6 -0
  9. package/dist/chunks/FormRendererView-DwfFbaip.cjs.map +1 -0
  10. package/dist/chunks/{compose-D9ipJpF_.js → compose-D6zBIc2Z.js} +4 -4
  11. package/dist/chunks/{compose-D9ipJpF_.js.map → compose-D6zBIc2Z.js.map} +1 -1
  12. package/dist/chunks/{compose-DtfX8DQ9.cjs → compose-NH6dsFXD.cjs} +2 -2
  13. package/dist/chunks/{compose-DtfX8DQ9.cjs.map → compose-NH6dsFXD.cjs.map} +1 -1
  14. package/dist/chunks/{designer-Df79YzUn.cjs → designer-Be9UI9Tg.cjs} +2 -2
  15. package/dist/chunks/{designer-Df79YzUn.cjs.map → designer-Be9UI9Tg.cjs.map} +1 -1
  16. package/dist/chunks/{designer-ubnZbP-A.js → designer-uhC_7m2i.js} +3 -3
  17. package/dist/chunks/{designer-ubnZbP-A.js.map → designer-uhC_7m2i.js.map} +1 -1
  18. package/dist/chunks/detail-6uw5dmTi.cjs +5 -0
  19. package/dist/chunks/detail-6uw5dmTi.cjs.map +1 -0
  20. package/dist/chunks/{detail-C6XKZjlF.js → detail-_GeKqNC-.js} +851 -839
  21. package/dist/chunks/detail-_GeKqNC-.js.map +1 -0
  22. package/dist/chunks/{approver-filled-form-B4zPg9kz.cjs → instance-error-message-DTARGbGo.cjs} +2 -2
  23. package/dist/chunks/instance-error-message-DTARGbGo.cjs.map +1 -0
  24. package/dist/chunks/{approver-filled-form-Bgazhbvd.js → instance-error-message-q6gy5evy.js} +44 -36
  25. package/dist/chunks/instance-error-message-q6gy5evy.js.map +1 -0
  26. package/dist/pages/instances/detail/index.cjs +1 -1
  27. package/dist/pages/instances/detail/index.js +1 -1
  28. package/dist/pages/templates/compose/index.cjs +1 -1
  29. package/dist/pages/templates/compose/index.js +1 -1
  30. package/dist/pages/templates/designer/index.cjs +1 -1
  31. package/dist/pages/templates/designer/index.js +1 -1
  32. package/dist/views/forms/builder/index.cjs +1 -1
  33. package/dist/views/forms/builder/index.js +1 -1
  34. package/dist/views/forms/renderer/FormRendererView.d.cts +24 -1
  35. package/dist/views/forms/renderer/FormRendererView.d.ts +24 -1
  36. package/dist/views/forms/renderer/file-upload-field.d.cts +84 -0
  37. package/dist/views/forms/renderer/file-upload-field.d.ts +84 -0
  38. package/dist/views/forms/renderer/form-value-readers.d.cts +7 -0
  39. package/dist/views/forms/renderer/form-value-readers.d.ts +7 -0
  40. package/dist/views/forms/renderer/index.cjs +1 -1
  41. package/dist/views/forms/renderer/index.d.cts +1 -0
  42. package/dist/views/forms/renderer/index.d.ts +1 -0
  43. package/dist/views/forms/renderer/index.js +1 -1
  44. package/dist/views/instances/detail/index.cjs +1 -1
  45. package/dist/views/instances/detail/index.js +1 -1
  46. package/dist/views/instances/detail/sections/InstanceFormSection.d.cts +19 -2
  47. package/dist/views/instances/detail/sections/InstanceFormSection.d.ts +19 -2
  48. package/dist/views/instances/detail/sections/shared.d.cts +1 -2
  49. package/dist/views/instances/detail/sections/shared.d.ts +1 -2
  50. package/dist/views/instances/instance-error-message.d.cts +5 -0
  51. package/dist/views/instances/instance-error-message.d.ts +5 -0
  52. package/dist/views/instances/new/index.cjs +1 -1
  53. package/dist/views/instances/new/index.cjs.map +1 -1
  54. package/dist/views/instances/new/index.js +77 -75
  55. package/dist/views/instances/new/index.js.map +1 -1
  56. package/dist/views/templates/compose/index.cjs +1 -1
  57. package/dist/views/templates/compose/index.js +1 -1
  58. package/dist/views/templates/designer/index.cjs +1 -1
  59. package/dist/views/templates/designer/index.js +1 -1
  60. package/package.json +3 -3
  61. package/dist/chunks/FormRendererView-CTLlG13b.js.map +0 -1
  62. package/dist/chunks/FormRendererView-ChmM_4Yc.cjs +0 -4
  63. package/dist/chunks/FormRendererView-ChmM_4Yc.cjs.map +0 -1
  64. package/dist/chunks/approver-filled-form-B4zPg9kz.cjs.map +0 -1
  65. package/dist/chunks/approver-filled-form-Bgazhbvd.js.map +0 -1
  66. package/dist/chunks/detail-BBC9kqXd.cjs +0 -5
  67. package/dist/chunks/detail-BBC9kqXd.cjs.map +0 -1
  68. package/dist/chunks/detail-C6XKZjlF.js.map +0 -1
@@ -6,8 +6,8 @@ import { AutoComplete as s, Button as c, CheckboxGroup as l, DatePicker as u, Da
6
6
  import { resolveMembers as b, searchMembers as x } from "@rytass/bpm-core-client";
7
7
  import { jsx as S, jsxs as C } from "react/jsx-runtime";
8
8
  import { PlusIcon as w, TrashIcon as T } from "@mezzanine-ui/icons";
9
- import { buildFormRendererValues as E, clampOptionalNumber as D, createFormTableRow as ee, formatDatePickerValue as O, formatDateTimePickerValue as k, isFormRendererFieldReadonly as A, isFormRendererFieldRequired as j, mergeFormDataSourceOptions as M, parseOptionalNumberInput as N, previewFormFieldOptions as te, previewResolveFormFieldOptions as ne, readDatePickerValue as P, readFieldOptionAsSelectOption as F, readFormDataSourceErrorCode as re, readFormDataSourceErrorMessage as ie, readFormDataSourceSelectedValues as ae, readFormDataSourceValueSignature as I, readFormFieldOptions as oe, readFormTableCellPath as L, readFormTableRowBounds as se, readFormTableRows as R, readMissingFormDataSourceDependencies as ce, readMissingFormDataSourceOptionValues as z, readSelectOption as B, readSelectedFormDataSourceOptions as le, readVisibleFormRendererFields as ue, resolveFormFieldOptions as de } from "@rytass/bpm-core-client/form";
10
- import { isFormDataSourceFieldDefinition as fe, isFormStaticOptionFieldDefinition as pe, isFormTableCellValue as V, isTableFieldDefinition as me, readFormFieldSelectionMode as H, readFormMemberIds as U } from "@rytass/bpm-core-shared/form";
9
+ import { buildFormRendererValues as E, clampOptionalNumber as D, createFormTableRow as O, formatDatePickerValue as k, formatDateTimePickerValue as A, isFormRendererFieldReadonly as j, isFormRendererFieldRequired as M, mergeFormDataSourceOptions as N, parseOptionalNumberInput as P, previewFormFieldOptions as ee, previewResolveFormFieldOptions as te, readDatePickerValue as F, readFieldOptionAsSelectOption as I, readFormDataSourceErrorCode as ne, readFormDataSourceErrorMessage as re, readFormDataSourceSelectedValues as ie, readFormDataSourceValueSignature as L, readFormFieldOptions as ae, readFormTableCellPath as oe, readFormTableRowBounds as se, readFormTableRows as R, readMissingFormDataSourceDependencies as ce, readMissingFormDataSourceOptionValues as z, readSelectOption as le, readSelectedFormDataSourceOptions as ue, readVisibleFormRendererFields as de, resolveFormFieldOptions as fe } from "@rytass/bpm-core-client/form";
10
+ import { isFormDataSourceFieldDefinition as B, isFormStaticOptionFieldDefinition as pe, isFormTableCellValue as V, isTableFieldDefinition as me, readFormFieldSelectionMode as H, readFormMemberIds as U } from "@rytass/bpm-core-shared/form";
11
11
  import { resolveOrgUnitOptions as W, searchOrgUnitOptions as G } from "@rytass/bpm-core-client/organization";
12
12
  // src/views/forms/renderer/form-data-source-field.ts
13
13
  var he = {
@@ -23,11 +23,11 @@ var he = {
23
23
  status: "IDLE"
24
24
  }, K = [], ge = 10, _e = ["FORM_DATA_SOURCE_SEARCH_NOT_SUPPORTED", "FORM_DATA_SOURCE_SEARCH_TOO_SHORT"];
25
25
  function q(e) {
26
- let t = fe(e.field) ? e.field : null, s = e.fieldPath ?? t?.fieldKey ?? "", c = t ? e.optionSnapshots?.[e.snapshotKey ?? t.fieldKey] : void 0, l = t ? JSON.stringify({
26
+ let t = B(e.field) ? e.field : null, s = e.fieldPath ?? t?.fieldKey ?? "", c = t ? e.optionSnapshots?.[e.snapshotKey ?? t.fieldKey] : void 0, l = t ? JSON.stringify({
27
27
  dataSource: t.dataSource,
28
28
  fieldKey: t.fieldKey,
29
29
  type: t.type
30
- }) : "", u = JSON.stringify(c ?? null), d = i(() => c?.options ?? [], [u]), f = JSON.stringify(e.formData), p = JSON.stringify(e.initialFormData ?? {}), m = JSON.stringify(e.schema), h = JSON.stringify(e.uiSchema), g = e.context?.kind, _ = e.context?.kind === "runtime" ? e.context.instanceId : void 0, v = e.context?.kind === "runtime" ? e.context.templateId : void 0, y = JSON.stringify(e.row?.values ?? null), b = JSON.stringify(e.row?.initialValues ?? null), x = t ? e.row ? e.row.values[t.fieldKey] : e.formData[t.fieldKey] : void 0, S = I(x), C = i(() => ae(x), [S]), w = C.length > 0, T = t ? JSON.stringify({
30
+ }) : "", u = JSON.stringify(c ?? null), d = i(() => c?.options ?? [], [u]), f = JSON.stringify(e.formData), p = JSON.stringify(e.initialFormData ?? {}), m = JSON.stringify(e.schema), h = JSON.stringify(e.uiSchema), g = e.context?.kind, _ = e.context?.kind === "runtime" ? e.context.instanceId : void 0, v = e.context?.kind === "runtime" ? e.context.templateId : void 0, y = JSON.stringify(e.row?.values ?? null), b = JSON.stringify(e.row?.initialValues ?? null), x = t ? e.row ? e.row.values[t.fieldKey] : e.formData[t.fieldKey] : void 0, S = L(x), C = i(() => ie(x), [S]), w = C.length > 0, T = t ? JSON.stringify({
31
31
  bindings: t.dataSource.bindings.map((t) => t.from.kind === "FIELD" ? {
32
32
  fieldKey: t.from.fieldKey,
33
33
  value: e.formData[t.from.fieldKey]
@@ -48,20 +48,20 @@ function q(e) {
48
48
  g,
49
49
  v,
50
50
  e.readonly
51
- ]), D = t ? (e.initialFormData !== void 0 || e.initialValue !== void 0) && I(e.initialValue) !== S : !1, ee = t ? e.initialFormData !== void 0 && t.dataSource.bindings.some((t) => t.from.kind === "FIELD" ? I(e.initialFormData?.[t.from.fieldKey]) !== I(e.formData[t.from.fieldKey]) : t.from.kind === "ROW_FIELD" && e.row?.initialValues ? I(e.row.initialValues[t.from.columnKey]) !== I(e.row.values[t.from.columnKey]) : !1) : !1, O = !(!c && !w || !D && !ee), k = !!(t && E && O && w), A = ye({
51
+ ]), D = t ? (e.initialFormData !== void 0 || e.initialValue !== void 0) && L(e.initialValue) !== S : !1, O = t ? e.initialFormData !== void 0 && t.dataSource.bindings.some((t) => t.from.kind === "FIELD" ? L(e.initialFormData?.[t.from.fieldKey]) !== L(e.formData[t.from.fieldKey]) : t.from.kind === "ROW_FIELD" && e.row?.initialValues ? L(e.row.initialValues[t.from.columnKey]) !== L(e.row.values[t.from.columnKey]) : !1) : !1, k = !(!c && !w || !D && !O), A = !!(t && E && k && w), j = ye({
52
52
  hasSnapshot: !!c,
53
53
  hasValue: w,
54
- isStale: O,
54
+ isStale: k,
55
55
  readonly: e.readonly
56
- }), j = !!(t && E && t.type !== "autocomplete"), N = be(O, j && t !== null && ce(t, e.formData, e.row?.values).length > 0), [P, F] = o([]), [L, se] = o(""), [R, z] = o(null), [B, ue] = o(null), [pe, V] = o(() => t ? j ? N : A : "IDLE"), [me, H] = o(null), U = a(0), W = a(0), G = a(0), K = a(null), q = a(null), J = a({
56
+ }), M = !!(t && E && t.type !== "autocomplete"), P = be(k, M && t !== null && ce(t, e.formData, e.row?.values).length > 0), [F, I] = o([]), [oe, se] = o(""), [R, z] = o(null), [le, de] = o(null), [pe, V] = o(() => t ? M ? P : j : "IDLE"), [me, H] = o(null), U = a(0), W = a(0), G = a(0), K = a(null), q = a(null), J = a({
57
57
  cursor: null,
58
58
  searchText: ""
59
- }), Y = i(() => we(e.formData), [f]), X = i(() => e.row ? we(e.row.values) : void 0, [y]), Te = i(() => M(d, P), [P, d]), Ee = B && B.signature === T ? B : null, De = k && !Ee, Oe = ve({
60
- options: Te,
61
- resolution: Ee,
62
- resolvePending: De,
59
+ }), Y = i(() => we(e.formData), [f]), X = i(() => e.row ? we(e.row.values) : void 0, [y]), Z = i(() => N(d, F), [F, d]), Te = le && le.signature === T ? le : null, Ee = A && !Te, De = ve({
60
+ options: Z,
61
+ resolution: Te,
62
+ resolvePending: Ee,
63
63
  value: x
64
- }), Z = n((n, r) => {
64
+ }), Q = n((n, r) => {
65
65
  if (!t || !E) return;
66
66
  let i = W.current + 1;
67
67
  W.current = i, J.current = {
@@ -69,7 +69,7 @@ function q(e) {
69
69
  searchText: n
70
70
  }, K.current?.abort();
71
71
  let a = new AbortController();
72
- K.current = a, V(N), H(null), (E.kind === "preview" ? te({
72
+ K.current = a, V(P), H(null), (E.kind === "preview" ? ee({
73
73
  cursor: r,
74
74
  fieldKey: s,
75
75
  formData: Y,
@@ -78,7 +78,7 @@ function q(e) {
78
78
  searchText: n,
79
79
  signal: a.signal,
80
80
  uiSchema: e.uiSchema
81
- }) : oe({
81
+ }) : ae({
82
82
  cursor: r,
83
83
  fieldKey: s,
84
84
  formData: Y,
@@ -88,13 +88,13 @@ function q(e) {
88
88
  signal: a.signal,
89
89
  templateId: E.templateId ?? null
90
90
  })).then((e) => {
91
- Ce(a, W, i) || (F((t) => {
92
- let n = le(x, t);
93
- return M(n, r ? t : [], e.options);
94
- }), z(e.nextCursor), H(null), U.current = r ? U.current + e.options.length : e.options.length, e.nextCursor && e.options.length > 0 && U.current < ge && ke.current(n, e.nextCursor), V(e.waitingForFieldKeys.length ? "WAITING_FOR_DEPENDENCIES" : "VALID"));
91
+ Ce(a, W, i) || (I((t) => {
92
+ let n = ue(x, t);
93
+ return N(n, r ? t : [], e.options);
94
+ }), z(e.nextCursor), H(null), U.current = r ? U.current + e.options.length : e.options.length, e.nextCursor && e.options.length > 0 && U.current < ge && Oe.current(n, e.nextCursor), V(e.waitingForFieldKeys.length ? "WAITING_FOR_DEPENDENCIES" : "VALID"));
95
95
  }).catch((e) => {
96
96
  if (Ce(a, W, i)) return;
97
- let t = ie(e) ?? "選項來源暫時無法使用。", n = re(e);
97
+ let t = re(e) ?? "選項來源暫時無法使用。", n = ne(e);
98
98
  H(t), V(xe(!!(n && _e.includes(n)), w));
99
99
  });
100
100
  }, [
@@ -102,20 +102,20 @@ function q(e) {
102
102
  l,
103
103
  E,
104
104
  w,
105
- N,
105
+ P,
106
106
  s,
107
107
  Y,
108
108
  X,
109
109
  m,
110
110
  h
111
- ]), ke = a(Z);
112
- ke.current = Z;
113
- let Ae = n(() => {
111
+ ]), Oe = a(Q);
112
+ Oe.current = Q;
113
+ let ke = n(() => {
114
114
  if (!t || !E || C.length === 0) return;
115
115
  let n = T, r = G.current + 1;
116
116
  G.current = r, q.current?.abort();
117
117
  let i = new AbortController();
118
- q.current = i, H(null), (E.kind === "preview" ? ne({
118
+ q.current = i, H(null), (E.kind === "preview" ? te({
119
119
  fieldKey: s,
120
120
  formData: Y,
121
121
  rowValues: X,
@@ -123,7 +123,7 @@ function q(e) {
123
123
  signal: i.signal,
124
124
  uiSchema: e.uiSchema,
125
125
  values: C
126
- }) : de({
126
+ }) : fe({
127
127
  fieldKey: s,
128
128
  formData: Y,
129
129
  instanceId: E.instanceId ?? null,
@@ -132,12 +132,12 @@ function q(e) {
132
132
  templateId: E.templateId ?? null,
133
133
  values: C
134
134
  })).then((e) => {
135
- Ce(i, G, r) || (e.waitingForFieldKeys.length ? V("WAITING_FOR_DEPENDENCIES") : (F((t) => M(t, e.options)), ue({
135
+ Ce(i, G, r) || (e.waitingForFieldKeys.length ? V("WAITING_FOR_DEPENDENCIES") : (I((t) => N(t, e.options)), de({
136
136
  signature: n,
137
137
  unresolvedValues: e.unresolvedValues
138
138
  }), V("VALID")));
139
139
  }).catch((e) => {
140
- Ce(i, G, r) || (V("UNAVAILABLE"), H(ie(e) ?? "選項來源暫時無法使用。"));
140
+ Ce(i, G, r) || (V("UNAVAILABLE"), H(re(e) ?? "選項來源暫時無法使用。"));
141
141
  });
142
142
  }, [
143
143
  T,
@@ -149,57 +149,57 @@ function q(e) {
149
149
  m,
150
150
  C,
151
151
  h
152
- ]), Q = a(Ae);
153
- Q.current = Ae, r(() => {
154
- W.current += 1, K.current?.abort(), F((e) => le(x, e)), z((e) => e === null ? e : null), se((e) => e && ""), H((e) => e && null), t ? j ? ke.current("", null) : V(A) : V("IDLE");
152
+ ]), Ae = a(ke);
153
+ Ae.current = ke, r(() => {
154
+ W.current += 1, K.current?.abort(), I((e) => ue(x, e)), z((e) => e === null ? e : null), se((e) => e && ""), H((e) => e && null), t ? M ? Oe.current("", null) : V(j) : V("IDLE");
155
155
  }, [
156
- j,
156
+ M,
157
157
  l,
158
158
  E,
159
159
  T,
160
160
  p,
161
161
  b,
162
162
  e.readonly,
163
- N,
164
- A,
163
+ P,
164
+ j,
165
165
  u
166
166
  ]), r(() => {
167
- k && Q.current();
167
+ A && Ae.current();
168
168
  }, [
169
169
  T,
170
170
  E,
171
- k
171
+ A
172
172
  ]), r(() => () => {
173
173
  K.current?.abort(), q.current?.abort();
174
174
  }, []);
175
175
  let je = n((e) => {
176
- se(e), F((e) => le(x, e)), z(null), Z(e, null);
177
- }, [Z]), Me = n(() => {
178
- R && Z(L, R);
176
+ se(e), I((e) => ue(x, e)), z(null), Q(e, null);
177
+ }, [Q]), Me = n(() => {
178
+ R && Q(oe, R);
179
179
  }, [
180
- Z,
180
+ Q,
181
181
  R,
182
- L
182
+ oe
183
183
  ]), Ne = n(() => {
184
- E && (Z(J.current.searchText, J.current.cursor), k && Q.current());
184
+ E && (Q(J.current.searchText, J.current.cursor), A && Ae.current());
185
185
  }, [
186
186
  E,
187
- Z,
188
- k
187
+ Q,
188
+ A
189
189
  ]);
190
190
  return t ? {
191
191
  canRetry: !!E,
192
192
  error: me,
193
193
  hasValue: w,
194
194
  hasNextPage: !!R,
195
- invalidValues: Oe,
195
+ invalidValues: De,
196
196
  onReachBottom: Me,
197
197
  onSearch: je,
198
- options: Te,
198
+ options: Z,
199
199
  retry: Ne,
200
200
  status: Se({
201
- invalidValues: Oe,
202
- resolvePending: De,
201
+ invalidValues: De,
202
+ resolvePending: Ee,
203
203
  status: pe
204
204
  })
205
205
  } : he;
@@ -245,34 +245,158 @@ function we(e) {
245
245
  [t]: n
246
246
  }, {});
247
247
  }
248
+ // src/views/forms/renderer/form-value-readers.ts
249
+ function Z(e) {
250
+ return Array.isArray(e) && e.every((e) => typeof e == "string") ? e : [];
251
+ }
252
+ // src/views/forms/renderer/file-upload-field.tsx
253
+ function Te(e) {
254
+ return e.some((e) => e.pendingCount > 0) ? "附件仍在上傳中,請稍候再送出。" : e.some((e) => e.failedCount > 0) ? "有附件上傳失敗,請重試或移除後再送出。" : null;
255
+ }
256
+ function Ee() {
257
+ let [e, t] = o({}), r = n((e, n) => t((t) => ({
258
+ ...t,
259
+ [e]: n
260
+ })), []);
261
+ return {
262
+ blockMessage: Te(Object.values(e)),
263
+ onFileUploadStateChange: r
264
+ };
265
+ }
266
+ var De = "無法讀取檔名的附件", Q = "此處無法上傳附件";
267
+ function Oe({ attachments: e, field: t, onChange: s, onDownloadAttachment: c, onStateChange: l, onUploadAttachment: u, readonly: d, value: f }) {
268
+ let [p, m] = o([]), [h, g] = o(() => /* @__PURE__ */ new Map()), [_, v] = o([]), b = Z(f), x = b.join("\n"), C = i(() => new Map((e ?? []).map((e) => [e.id, e])), [e]), w = i(() => {
269
+ let e = new Map(_.map((e, t) => [e, t]));
270
+ return [...b.map((e) => h.get(e) ?? ke(e, C.get(e))), ...p].sort((t, n) => (e.get(t.id) ?? -1) - (e.get(n.id) ?? -1));
271
+ }, [
272
+ C,
273
+ _,
274
+ h,
275
+ p,
276
+ x
277
+ ]), T = a(w), E = a(!0), D = a(M);
278
+ D.current = M, r(() => {
279
+ T.current = w;
280
+ }, [w]);
281
+ let O = n((e) => D.current(e), []), k = p.filter((e) => e.status === "loading").length, A = p.filter((e) => e.status === "error").length, j = a(l);
282
+ j.current = l, r(() => {
283
+ j.current?.({
284
+ failedCount: A,
285
+ pendingCount: k
286
+ });
287
+ }, [A, k]), r(() => (E.current = !0, () => {
288
+ E.current = !1, j.current?.({
289
+ failedCount: 0,
290
+ pendingCount: 0
291
+ });
292
+ }), []);
293
+ function M(e) {
294
+ if (!E.current) return;
295
+ let t = e.filter((e) => e.status === "done"), n = t.map((e) => e.id), r = new Set(b), i = t.filter((e) => e.file !== void 0 && !r.has(e.id));
296
+ T.current = e, v(e.map((e) => e.id)), m(e.filter((e) => e.status !== "done")), i.length > 0 && g((e) => new Map([...e, ...i.map((e) => [e.id, e])])), n.join("\n") !== x && s(n.length ? n : void 0);
297
+ }
298
+ async function N(e) {
299
+ if (!u) throw Error(Q);
300
+ return {
301
+ file: e,
302
+ id: (await u(t, e)).id,
303
+ progress: 100,
304
+ status: "done"
305
+ };
306
+ }
307
+ async function P(e, t) {
308
+ let n = await N(t).catch((n) => ({
309
+ errorMessage: je(n),
310
+ file: t,
311
+ id: e,
312
+ status: "error"
313
+ }));
314
+ D.current(T.current.map((t) => t.id === e ? n : t));
315
+ }
316
+ function ee(e, t) {
317
+ h.has(e) ? Me(t) : c?.(e);
318
+ }
319
+ let te = !!u && !d, F = [...!d && !u ? [{
320
+ label: Q,
321
+ type: "info"
322
+ }] : [], ...p.filter((e) => e.status === "error").map((e) => ({
323
+ label: `${e.file?.name ?? "檔案"}:${e.errorMessage ?? "上傳失敗"},未附加。請重試或刪除。`,
324
+ type: "error"
325
+ }))];
326
+ return /* @__PURE__ */ S(y, {
327
+ accept: t.acceptedMimeTypes?.join(","),
328
+ disabled: !te,
329
+ files: w,
330
+ ...F.length > 0 ? { hints: F } : {},
331
+ maxFiles: t.maxFiles,
332
+ mode: "button-list",
333
+ ...(t.maxFiles ?? 1) > 1 ? { multiple: !0 } : {},
334
+ onChange: O,
335
+ onDownload: ee,
336
+ onReload: (e, t) => {
337
+ P(e, t);
338
+ },
339
+ onUpload: async (e) => Promise.all(e.map(async (e) => N(e).catch((t) => ({
340
+ errorMessage: je(t),
341
+ file: e,
342
+ id: `failed-${e.name}-${e.lastModified}-${Math.random()}`,
343
+ status: "error"
344
+ })))),
345
+ size: "sub"
346
+ });
347
+ }
348
+ function ke(e, t) {
349
+ return t ? {
350
+ file: Ae(t),
351
+ id: e,
352
+ progress: 100,
353
+ status: "done"
354
+ } : {
355
+ id: e,
356
+ progress: 100,
357
+ status: "done",
358
+ url: De
359
+ };
360
+ }
361
+ function Ae(e) {
362
+ let t = new File([], e.filename), n = Number(e.sizeBytes);
363
+ return Number.isFinite(n) && n >= 0 && Object.defineProperty(t, "size", { value: n }), t;
364
+ }
365
+ function je(e) {
366
+ return e instanceof Error && e.message ? `上傳失敗:${e.message}` : "上傳失敗,請重試。";
367
+ }
368
+ function Me(e) {
369
+ let t = URL.createObjectURL(e), n = document.createElement("a");
370
+ n.href = t, n.download = e.name, n.style.display = "none", document.body.appendChild(n), n.click(), n.remove(), setTimeout(() => URL.revokeObjectURL(t), 3e4);
371
+ }
248
372
  // src/views/forms/renderer/form-field-link.ts
249
- var Te = /\s/u;
250
- function Ee(e) {
373
+ var Ne = /\s/u;
374
+ function Pe(e) {
251
375
  return [...e].some((e) => {
252
376
  let t = e.codePointAt(0) ?? 0;
253
- return t <= 32 || t >= 127 && t <= 160 || Te.test(e);
377
+ return t <= 32 || t >= 127 && t <= 160 || Ne.test(e);
254
378
  });
255
379
  }
256
- var De = /^https?:\/\//iu;
257
- function Oe(e) {
258
- return typeof e != "string" || !e || e.includes("\\") || Ee(e) ? null : e.startsWith("/") ? !e.startsWith("//") && ke(e) ? {
380
+ var Fe = /^https?:\/\//iu;
381
+ function Ie(e) {
382
+ return typeof e != "string" || !e || e.includes("\\") || Pe(e) ? null : e.startsWith("/") ? !e.startsWith("//") && Re(e) ? {
259
383
  external: !1,
260
384
  href: e
261
- } : null : De.test(e) && Ae(e) ? {
385
+ } : null : Fe.test(e) && ze(e) ? {
262
386
  external: !0,
263
387
  href: e
264
388
  } : null;
265
389
  }
266
- var Z = "http://placeholder.invalid";
267
- function ke(e) {
390
+ var Le = "http://placeholder.invalid";
391
+ function Re(e) {
268
392
  try {
269
- let t = new URL(e, Z);
270
- return t.origin === Z && !t.pathname.startsWith("//");
393
+ let t = new URL(e, Le);
394
+ return t.origin === Le && !t.pathname.startsWith("//");
271
395
  } catch {
272
396
  return !1;
273
397
  }
274
398
  }
275
- function Ae(e) {
399
+ function ze(e) {
276
400
  try {
277
401
  let t = new URL(e);
278
402
  return (t.protocol === "http:" || t.protocol === "https:") && !!t.hostname && !t.username && !t.password;
@@ -280,7 +404,7 @@ function Ae(e) {
280
404
  return !1;
281
405
  }
282
406
  }
283
- async function Q(e, t, n = {}) {
407
+ async function Be(e, t, n = {}) {
284
408
  let r = n.maxPerIdRequests ?? 20, i = Math.max(1, n.concurrency ?? 4);
285
409
  try {
286
410
  return {
@@ -295,17 +419,17 @@ async function Q(e, t, n = {}) {
295
419
  skippedIds: []
296
420
  };
297
421
  }
298
- let a = e.slice(0, r), o = await Me(a, i, (e) => t([e]));
422
+ let a = e.slice(0, r), o = await He(a, i, (e) => t([e]));
299
423
  return {
300
424
  failedIds: a.filter((e, t) => o[t].status === "rejected"),
301
425
  profiles: o.flatMap((e) => e.status === "fulfilled" ? e.value : []),
302
426
  skippedIds: e.slice(r)
303
427
  };
304
428
  }
305
- function je(e, t) {
429
+ function Ve(e, t) {
306
430
  return e.filter((e) => !t.has(e));
307
431
  }
308
- async function Me(e, t, n) {
432
+ async function He(e, t, n) {
309
433
  let r = [], i = 0;
310
434
  async function a() {
311
435
  for (; i < e.length;) {
@@ -322,43 +446,43 @@ async function Me(e, t, n) {
322
446
  return await Promise.all(Array.from({ length: Math.min(t, e.length) }, a)), r;
323
447
  }
324
448
  // src/views/forms/renderer/member-field-options.ts
325
- var Ne = "未知會員";
326
- function Pe(e) {
449
+ var Ue = "未知會員";
450
+ function We(e) {
327
451
  return {
328
452
  id: e.memberId,
329
453
  name: t(e.name, e.email)
330
454
  };
331
455
  }
332
- function Fe(e) {
456
+ function Ge(e) {
333
457
  return {
334
458
  id: e,
335
- name: Ne,
459
+ name: Ue,
336
460
  unresolved: !0
337
461
  };
338
462
  }
339
- function Ie(e, t) {
463
+ function Ke(e, t) {
340
464
  let n = new Map(t.filter((e) => !e.unresolved).map((e) => [e.id, e])), r = new Set(e.map((e) => e.id)), i = t.filter((e, n) => !r.has(e.id) && t.findIndex((t) => t.id === e.id) === n), a = e.map((e) => (e.unresolved ? n.get(e.id) : void 0) ?? e);
341
465
  return i.length > 0 || a.some((t, n) => t !== e[n]) ? [...a, ...i] : e;
342
466
  }
343
- function Le(e, t) {
467
+ function qe(e, t) {
344
468
  let n = new Set(t.filter((e) => !e.unresolved).map((e) => e.id));
345
469
  return U(e).filter((e) => !n.has(e));
346
470
  }
347
- function Re(e, t) {
348
- return U(e).map((e) => t.find((t) => t.id === e) ?? Fe(e));
471
+ function Je(e, t) {
472
+ return U(e).map((e) => t.find((t) => t.id === e) ?? Ge(e));
349
473
  }
350
- function ze(e, t) {
474
+ function Ye(e, t) {
351
475
  if (e.length !== 0) return t ? e.map((e) => e.id) : e[0]?.id;
352
476
  }
353
477
  // src/views/forms/renderer/member-field.tsx
354
- function Be({ multiple: e, name: t, onChange: n, placeholder: i, readonly: c, size: l, value: u }) {
355
- let [d, f] = o([]), [p, m] = o([]), [h, g] = o(!1), _ = a(0), v = a(/* @__PURE__ */ new Set()), y = Le(u, d).join("\n");
478
+ function Xe({ multiple: e, name: t, onChange: n, placeholder: i, readonly: c, size: l, value: u }) {
479
+ let [d, f] = o([]), [p, m] = o([]), [h, g] = o(!1), _ = a(0), v = a(/* @__PURE__ */ new Set()), y = qe(u, d).join("\n");
356
480
  r(() => {
357
- let e = je(y ? y.split("\n") : [], v.current), t = !1;
358
- return e.length === 0 ? () => void 0 : (Q(e, b).then(({ profiles: n, skippedIds: r }) => {
481
+ let e = Ve(y ? y.split("\n") : [], v.current), t = !1;
482
+ return e.length === 0 ? () => void 0 : (Be(e, b).then(({ profiles: n, skippedIds: r }) => {
359
483
  if (t) return;
360
- let i = n.map(Pe), a = e.filter((e) => !i.some((t) => t.id === e)).map(Fe);
361
- a.filter((e) => !r.includes(e.id)).forEach((e) => v.current.add(e.id)), f((e) => Ie(e, [...i, ...a]));
484
+ let i = n.map(We), a = e.filter((e) => !i.some((t) => t.id === e)).map(Ge);
485
+ a.filter((e) => !r.includes(e.id)).forEach((e) => v.current.add(e.id)), f((e) => Ke(e, [...i, ...a]));
362
486
  }), () => {
363
487
  t = !0;
364
488
  });
@@ -367,15 +491,15 @@ function Be({ multiple: e, name: t, onChange: n, placeholder: i, readonly: c, si
367
491
  let t = _.current + 1;
368
492
  _.current = t, g(!0);
369
493
  try {
370
- let n = (await x(e)).map(Pe);
371
- _.current === t && (m(n), f((e) => Ie(e, n)));
494
+ let n = (await x(e)).map(We);
495
+ _.current === t && (m(n), f((e) => Ke(e, n)));
372
496
  } catch {
373
497
  _.current === t && m([]);
374
498
  } finally {
375
499
  _.current === t && g(!1);
376
500
  }
377
501
  }
378
- let w = Re(u, d), T = [...Ie(w, p)], E = {
502
+ let w = Je(u, d), T = [...Ke(w, p)], E = {
379
503
  asyncData: !0,
380
504
  clearSearchText: !0,
381
505
  disabled: c,
@@ -403,72 +527,72 @@ function Be({ multiple: e, name: t, onChange: n, placeholder: i, readonly: c, si
403
527
  return e ? /* @__PURE__ */ S(s, {
404
528
  ...E,
405
529
  mode: "multiple",
406
- onChange: (e) => n(ze(e, !0)),
530
+ onChange: (e) => n(Ye(e, !0)),
407
531
  value: [...w]
408
532
  }) : /* @__PURE__ */ S(s, {
409
533
  ...E,
410
534
  mode: "single",
411
- onChange: (e) => n(ze(e ? [e] : [], !1)),
535
+ onChange: (e) => n(Ye(e ? [e] : [], !1)),
412
536
  value: w[0] ?? null
413
537
  });
414
538
  }
415
539
  // src/views/forms/renderer/org-unit-field-options.ts
416
- var Ve = "未知組織", He = "(已刪除)";
417
- function Ue(e) {
540
+ var Ze = "未知組織", Qe = "(已刪除)";
541
+ function $e(e) {
418
542
  return {
419
543
  id: e.id,
420
- name: e.deleted ? `${e.name}${He}` : e.name
544
+ name: e.deleted ? `${e.name}${Qe}` : e.name
421
545
  };
422
546
  }
423
- function We(e) {
547
+ function et(e) {
424
548
  return {
425
549
  id: e,
426
550
  name: e,
427
551
  unresolved: !0
428
552
  };
429
553
  }
430
- function Ge(e) {
554
+ function tt(e) {
431
555
  return {
432
556
  id: e,
433
- name: Ve,
557
+ name: Ze,
434
558
  unresolved: !0
435
559
  };
436
560
  }
437
- function Ke(e) {
561
+ function nt(e) {
438
562
  return typeof e == "string" && e.trim() ? e : null;
439
563
  }
440
564
  function $(e) {
441
565
  return e.toLowerCase();
442
566
  }
443
- function qe(e, t) {
567
+ function rt(e, t) {
444
568
  return $(e) === $(t);
445
569
  }
446
- function Je(e, t) {
447
- let n = Ke(e);
448
- return n === null ? null : t.find((e) => qe(e.id, n)) ?? We(n);
570
+ function it(e, t) {
571
+ let n = nt(e);
572
+ return n === null ? null : t.find((e) => rt(e.id, n)) ?? et(n);
449
573
  }
450
- function Ye(e, t) {
451
- let n = Ke(e);
452
- return n !== null && !t.some((e) => qe(e.id, n)) ? n : null;
574
+ function at(e, t) {
575
+ let n = nt(e);
576
+ return n !== null && !t.some((e) => rt(e.id, n)) ? n : null;
453
577
  }
454
- function Xe(e, t) {
455
- let n = new Map(t.filter((e) => !e.unresolved).map((e) => [$(e.id), e])), r = new Set(e.map((e) => $(e.id))), i = t.filter((e, n) => !r.has($(e.id)) && t.findIndex((t) => qe(t.id, e.id)) === n), a = e.map((e) => (e.unresolved ? n.get($(e.id)) : void 0) ?? e);
578
+ function ot(e, t) {
579
+ let n = new Map(t.filter((e) => !e.unresolved).map((e) => [$(e.id), e])), r = new Set(e.map((e) => $(e.id))), i = t.filter((e, n) => !r.has($(e.id)) && t.findIndex((t) => rt(t.id, e.id)) === n), a = e.map((e) => (e.unresolved ? n.get($(e.id)) : void 0) ?? e);
456
580
  return i.length > 0 || a.some((t, n) => t !== e[n]) ? [...a, ...i] : e;
457
581
  }
458
- function Ze(e) {
582
+ function st(e) {
459
583
  return e ? e.id : void 0;
460
584
  }
461
585
  // src/views/forms/renderer/org-unit-field.tsx
462
- var Qe = "搜尋組織失敗,請稍後再試。";
463
- function $e({ name: e, onChange: t, placeholder: n, readonly: i, size: c, value: l }) {
464
- let [u, d] = o([]), [f, p] = o([]), [m, h] = o(!1), [g, _] = o(!1), y = a(0), b = Ye(l, u);
586
+ var ct = "搜尋組織失敗,請稍後再試。";
587
+ function lt({ name: e, onChange: t, placeholder: n, readonly: i, size: c, value: l }) {
588
+ let [u, d] = o([]), [f, p] = o([]), [m, h] = o(!1), [g, _] = o(!1), y = a(0), b = at(l, u);
465
589
  r(() => {
466
590
  let e = !1;
467
591
  return b === null ? () => void 0 : (W([b]).then((e) => {
468
- let t = e.map(Ue);
469
- return t.some((e) => e.id.toLowerCase() === b.toLowerCase()) ? t : [...t, Ge(b)];
470
- }).catch(() => [Ge(b)]).then((t) => {
471
- e || d((e) => Xe(e, t));
592
+ let t = e.map($e);
593
+ return t.some((e) => e.id.toLowerCase() === b.toLowerCase()) ? t : [...t, tt(b)];
594
+ }).catch(() => [tt(b)]).then((t) => {
595
+ e || d((e) => ot(e, t));
472
596
  }), () => {
473
597
  e = !0;
474
598
  });
@@ -477,15 +601,15 @@ function $e({ name: e, onChange: t, placeholder: n, readonly: i, size: c, value:
477
601
  let t = y.current + 1;
478
602
  y.current = t, h(!0);
479
603
  try {
480
- let n = (await G(e)).map(Ue);
481
- y.current === t && (p(n), _(!1), d((e) => Xe(e, n)));
604
+ let n = (await G(e)).map($e);
605
+ y.current === t && (p(n), _(!1), d((e) => ot(e, n)));
482
606
  } catch {
483
607
  y.current === t && (p([]), _(!0));
484
608
  } finally {
485
609
  y.current === t && h(!1);
486
610
  }
487
611
  }
488
- let w = Je(l, u), T = [...Xe(w ? [w] : [], f)];
612
+ let w = it(l, u), T = [...ot(w ? [w] : [], f)];
489
613
  return /* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S(s, {
490
614
  asyncData: !0,
491
615
  clearSearchText: !0,
@@ -502,7 +626,7 @@ function $e({ name: e, onChange: t, placeholder: n, readonly: i, size: c, value:
502
626
  loading: m,
503
627
  loadingText: "搜尋組織中...",
504
628
  mode: "single",
505
- onChange: (e) => t(Ze(e ?? null)),
629
+ onChange: (e) => t(st(e ?? null)),
506
630
  onSearch: x,
507
631
  onVisibilityChange: (e) => {
508
632
  e && (p([]), x(""));
@@ -516,96 +640,106 @@ function $e({ name: e, onChange: t, placeholder: n, readonly: i, size: c, value:
516
640
  }), g ? /* @__PURE__ */ S(v, {
517
641
  color: "text-error",
518
642
  variant: "caption",
519
- children: Qe
643
+ children: ct
520
644
  }) : null] });
521
645
  }
522
646
  // src/views/forms/renderer/FormRendererView.tsx
523
- var et = {
647
+ var ut = {
524
648
  alignItems: "start",
525
649
  display: "grid",
526
650
  gap: 12,
527
651
  gridTemplateColumns: "repeat(12, minmax(0, 1fr))"
528
- }, tt = { gridColumn: "1 / -1" }, nt = {
652
+ }, dt = { gridColumn: "1 / -1" }, ft = {
529
653
  alignItems: "start",
530
654
  display: "grid",
531
655
  gap: 8,
532
656
  minWidth: 0
533
- }, rt = {
657
+ }, pt = {
534
658
  minWidth: "100%",
535
659
  width: "100%"
536
660
  };
537
- function it(e) {
661
+ function mt(e) {
538
662
  e && (e.style.width = "100%");
539
663
  }
540
- function at({ dataSourceContext: e, dataSourceInitialValues: t, emptyText: n = "尚未建立欄位。", errors: s = {}, fieldAccess: c, fieldLabelMarkers: l, maxWidth: u, onChange: d, onDataSourceStateChange: f, onUploadAttachment: p, optionSnapshots: m, readonly: h = !1, schema: g, singleColumn: _ = !1, uiSchema: y, value: b }) {
541
- let [x, C] = o(() => E(g.fields, b ?? {})), w = i(() => E(g.fields, b ?? x), [
542
- x,
543
- g.fields,
544
- b
545
- ]), T = a(w), D = i(() => ue(g, y, w).filter((e) => ot(c, e.fieldKey)?.visible !== !1), [
546
- c,
547
- g,
548
- y,
664
+ function ht({ attachments: e, dataSourceContext: t, dataSourceInitialValues: n, emptyText: s = "尚未建立欄位。", errors: c = {}, fieldAccess: l, fieldLabelMarkers: u, maxWidth: d, onChange: f, onDataSourceStateChange: p, onDownloadAttachment: m, onFileUploadStateChange: h, onUploadAttachment: g, optionSnapshots: _, readonly: y = !1, schema: b, singleColumn: x = !1, uiSchema: C, value: w }) {
665
+ let T = i(() => ({
666
+ attachments: e,
667
+ onDownloadAttachment: m,
668
+ onStateChange: h,
669
+ onUploadAttachment: g
670
+ }), [
671
+ e,
672
+ m,
673
+ h,
674
+ g
675
+ ]), [D, O] = o(() => E(b.fields, w ?? {})), k = i(() => E(b.fields, w ?? D), [
676
+ D,
677
+ b.fields,
549
678
  w
679
+ ]), A = a(k), j = i(() => de(b, C, k).filter((e) => gt(l, e.fieldKey)?.visible !== !1), [
680
+ l,
681
+ b,
682
+ C,
683
+ k
550
684
  ]);
551
685
  r(() => {
552
- T.current = w;
553
- }, [w]), r(() => {
554
- C((e) => E(g.fields, b ?? e));
555
- }, [g.fields, b]);
556
- function ee(e, t) {
686
+ A.current = k;
687
+ }, [k]), r(() => {
688
+ O((e) => E(b.fields, w ?? e));
689
+ }, [b.fields, w]);
690
+ function M(e, t) {
557
691
  let n = {
558
- ...T.current,
692
+ ...A.current,
559
693
  [e]: t
560
694
  };
561
- T.current = n, b || C(n), d?.(n);
695
+ A.current = n, w || O(n), f?.(n);
562
696
  }
563
- return D.length ? /* @__PURE__ */ S("div", {
697
+ return j.length ? /* @__PURE__ */ S("div", {
564
698
  style: {
565
- ...et,
566
- ..._ ? { width: "100%" } : {}
699
+ ...ut,
700
+ ...x ? { width: "100%" } : {}
567
701
  },
568
- children: D.map((n) => /* @__PURE__ */ S(ct, {
569
- dataSourceContext: e,
570
- dataSourceInitialValues: t,
571
- field: n,
572
- error: s[n.fieldKey] ?? null,
573
- errors: s,
574
- fields: g.fields,
575
- labelMarker: l !== void 0 && Object.prototype.hasOwnProperty.call(l, n.fieldKey) ? l[n.fieldKey] : void 0,
576
- onChange: ee,
577
- onDataSourceStateChange: f,
578
- onUploadAttachment: p,
579
- optionSnapshots: m,
580
- readonly: st(ot(c, n.fieldKey), h),
581
- schema: g,
702
+ children: j.map((e) => /* @__PURE__ */ S(vt, {
703
+ dataSourceContext: t,
704
+ dataSourceInitialValues: n,
705
+ field: e,
706
+ error: c[e.fieldKey] ?? null,
707
+ errors: c,
708
+ fields: b.fields,
709
+ labelMarker: u !== void 0 && Object.prototype.hasOwnProperty.call(u, e.fieldKey) ? u[e.fieldKey] : void 0,
710
+ onChange: M,
711
+ fileUpload: T,
712
+ onDataSourceStateChange: p,
713
+ optionSnapshots: _,
714
+ readonly: _t(gt(l, e.fieldKey), y),
715
+ schema: b,
582
716
  style: {
583
- ...nt,
584
- gridColumn: `span ${_ ? 12 : Ot(n, y)}`,
585
- ..._ && !me(n) ? { maxWidth: u } : {}
717
+ ...ft,
718
+ gridColumn: `span ${x ? 12 : Rt(e, C)}`,
719
+ ...x && !me(e) ? { maxWidth: d } : {}
586
720
  },
587
- value: w[n.fieldKey],
588
- values: w,
589
- uiSchema: y
590
- }, n.fieldKey))
721
+ value: k[e.fieldKey],
722
+ values: k,
723
+ uiSchema: C
724
+ }, e.fieldKey))
591
725
  }) : /* @__PURE__ */ S("div", {
592
- style: et,
726
+ style: ut,
593
727
  children: /* @__PURE__ */ S(v, {
594
728
  color: "text-neutral",
595
- style: tt,
729
+ style: dt,
596
730
  variant: "body",
597
- children: g.fields.length > 0 ? "目前條件下沒有可填寫欄位。" : n
731
+ children: b.fields.length > 0 ? "目前條件下沒有可填寫欄位。" : s
598
732
  })
599
733
  });
600
734
  }
601
- function ot(e, t) {
735
+ function gt(e, t) {
602
736
  return e !== void 0 && Object.prototype.hasOwnProperty.call(e, t) ? e[t] : void 0;
603
737
  }
604
- function st(e, t) {
738
+ function _t(e, t) {
605
739
  return e === void 0 ? t : !e.editable;
606
740
  }
607
- function ct({ dataSourceContext: t, dataSourceInitialValues: n, error: i, errors: a, field: o, fields: s, labelMarker: l, onChange: u, onDataSourceStateChange: d, onUploadAttachment: f, optionSnapshots: p, readonly: m, schema: h, style: g, value: _, values: y, uiSchema: b }) {
608
- let x = j(o, s, y), w = m || A(o, s, y), T = q({
741
+ function vt({ dataSourceContext: t, dataSourceInitialValues: n, error: i, errors: a, field: o, fields: s, fileUpload: l, labelMarker: u, onChange: d, onDataSourceStateChange: f, optionSnapshots: p, readonly: m, schema: h, style: g, value: _, values: y, uiSchema: b }) {
742
+ let x = M(o, s, y), w = m || j(o, s, y), T = q({
609
743
  context: t,
610
744
  field: o,
611
745
  formData: y,
@@ -621,7 +755,7 @@ function ct({ dataSourceContext: t, dataSourceInitialValues: n, error: i, errors
621
755
  status: T.status
622
756
  });
623
757
  return r(() => {
624
- fe(o) && d?.(o.fieldKey, {
758
+ B(o) && f?.(o.fieldKey, {
625
759
  hasValue: T.hasValue,
626
760
  invalidValues: T.invalidValues,
627
761
  status: T.status
@@ -629,30 +763,30 @@ function ct({ dataSourceContext: t, dataSourceInitialValues: n, error: i, errors
629
763
  }, [
630
764
  D,
631
765
  o.fieldKey,
632
- d
766
+ f
633
767
  ]), /* @__PURE__ */ C("div", {
634
768
  "data-form-field-key": o.fieldKey,
635
769
  style: g,
636
770
  children: [
637
771
  /* @__PURE__ */ S(e, {
638
772
  label: o.label,
639
- ...l ? { labelOptionalMarker: l } : {},
773
+ ...u ? { labelOptionalMarker: u } : {},
640
774
  name: o.fieldKey,
641
775
  required: x,
642
- children: me(o) ? /* @__PURE__ */ S(yt, {
776
+ children: me(o) ? /* @__PURE__ */ S(kt, {
643
777
  dataSourceContext: t,
644
778
  dataSourceInitialValues: n,
645
779
  errors: a,
646
780
  field: o,
647
- onChange: u,
648
- onDataSourceStateChange: d,
781
+ onChange: d,
782
+ onDataSourceStateChange: f,
649
783
  optionSnapshots: p,
650
784
  readonly: w,
651
785
  schema: h,
652
786
  uiSchema: b,
653
787
  value: _,
654
788
  values: y
655
- }) : Tt(o, _, w, u, f, t, T)
789
+ }) : Ft(o, _, w, d, l, t, T)
656
790
  }),
657
791
  i ? /* @__PURE__ */ S(v, {
658
792
  color: "text-error",
@@ -660,7 +794,7 @@ function ct({ dataSourceContext: t, dataSourceInitialValues: n, error: i, errors
660
794
  children: i
661
795
  }) : null,
662
796
  E ? /* @__PURE__ */ C("div", {
663
- style: ft,
797
+ style: St,
664
798
  children: [/* @__PURE__ */ S(v, {
665
799
  color: T.status === "INVALID" || T.status === "UNAVAILABLE" ? "text-error" : "text-neutral",
666
800
  variant: "caption",
@@ -676,99 +810,99 @@ function ct({ dataSourceContext: t, dataSourceInitialValues: n, error: i, errors
676
810
  ]
677
811
  });
678
812
  }
679
- var lt = "(另開新分頁)", ut = "另開新分頁", dt = {
813
+ var yt = "(另開新分頁)", bt = "另開新分頁", xt = {
680
814
  color: "inherit",
681
815
  textDecoration: "underline",
682
816
  wordBreak: "break-all"
683
- }, ft = {
817
+ }, St = {
684
818
  alignItems: "center",
685
819
  display: "flex",
686
820
  gap: 8
687
- }, pt = {
821
+ }, Ct = {
688
822
  display: "grid",
689
823
  gap: 8,
690
824
  minWidth: 0,
691
825
  width: "100%"
692
- }, mt = {
826
+ }, wt = {
693
827
  display: "flex",
694
828
  justifyContent: "flex-start"
695
- }, ht = {
829
+ }, Tt = {
696
830
  maxWidth: "100%",
697
831
  overflowX: "auto"
698
- }, gt = 160, _t = 56, vt = {
832
+ }, Et = 160, Dt = 56, Ot = {
699
833
  display: "grid",
700
834
  gap: 4,
701
835
  minWidth: 0
702
836
  };
703
- function yt({ dataSourceContext: e, dataSourceInitialValues: t, errors: n, field: i, onChange: s, onDataSourceStateChange: l, optionSnapshots: u, readonly: d, schema: f, uiSchema: p, value: m, values: g }) {
704
- let _ = R(m), v = se(i), y = a(0), [b, x] = o(() => _.map(() => St(y)));
837
+ function kt({ dataSourceContext: e, dataSourceInitialValues: t, errors: n, field: i, onChange: s, onDataSourceStateChange: l, optionSnapshots: u, readonly: d, schema: f, uiSchema: p, value: m, values: g }) {
838
+ let _ = R(m), v = se(i), y = a(0), [b, x] = o(() => _.map(() => Mt(y)));
705
839
  r(() => {
706
- b.length !== _.length && x(_.map(() => St(y)));
840
+ b.length !== _.length && x(_.map(() => Mt(y)));
707
841
  }, [b.length, _.length]);
708
842
  function E(e) {
709
843
  s(i.fieldKey, e);
710
844
  }
711
845
  function D() {
712
- x([...b, St(y)]), E([..._, ee(i.columns)]);
846
+ x([...b, Mt(y)]), E([..._, O(i.columns)]);
713
847
  }
714
- function O(e) {
848
+ function k(e) {
715
849
  x(b.filter((t, n) => n !== e)), E(_.filter((t, n) => n !== e));
716
850
  }
717
- function k(e, t, n) {
718
- E(_.map((r, i) => i === e ? Ct(r, t, n) : r));
851
+ function A(e, t, n) {
852
+ E(_.map((r, i) => i === e ? Nt(r, t, n) : r));
719
853
  }
720
- let A = _.map((e, t) => ({
854
+ let j = _.map((e, t) => ({
721
855
  ...e,
722
856
  index: t,
723
857
  key: b[t] ?? `row-${t}`
724
- })), j = i.columns.map((r) => ({
858
+ })), M = i.columns.map((r) => ({
725
859
  key: r.fieldKey,
726
- render: (a) => /* @__PURE__ */ S(bt, {
860
+ render: (a) => /* @__PURE__ */ S(At, {
727
861
  column: r,
728
862
  dataSourceContext: e,
729
- error: n[L(i.fieldKey, a.index, r.fieldKey)] ?? null,
863
+ error: n[oe(i.fieldKey, a.index, r.fieldKey)] ?? null,
730
864
  fieldPath: `${i.fieldKey}.${r.fieldKey}`,
731
865
  formData: g,
732
866
  initialFormData: t,
733
- initialRowValues: xt(t?.[i.fieldKey], a.index),
734
- onChange: (e) => k(a.index, r.fieldKey, e),
867
+ initialRowValues: jt(t?.[i.fieldKey], a.index),
868
+ onChange: (e) => A(a.index, r.fieldKey, e),
735
869
  onDataSourceStateChange: l,
736
870
  optionSnapshots: u,
737
- path: L(i.fieldKey, a.index, r.fieldKey),
871
+ path: oe(i.fieldKey, a.index, r.fieldKey),
738
872
  readonly: d,
739
873
  rowValues: _[a.index] ?? {},
740
874
  schema: f,
741
875
  uiSchema: p
742
876
  }, `${b[a.index] ?? a.index}-${r.fieldKey}`),
743
877
  title: r.label || r.fieldKey
744
- })), M = d ? void 0 : {
878
+ })), N = d ? void 0 : {
745
879
  render: (e) => [{
746
880
  disabled: () => _.length <= v.minRows,
747
881
  icon: T,
748
882
  iconType: "icon-only",
749
883
  name: "刪除此列",
750
- onClick: () => O(e.index),
884
+ onClick: () => k(e.index),
751
885
  variant: "destructive-ghost"
752
886
  }],
753
887
  width: 56
754
888
  };
755
889
  return /* @__PURE__ */ C("div", {
756
- style: pt,
890
+ style: Ct,
757
891
  children: [/* @__PURE__ */ S("div", {
758
- style: ht,
892
+ style: Tt,
759
893
  children: /* @__PURE__ */ S("div", {
760
- style: { minWidth: i.columns.length * gt + (M ? _t : 0) },
894
+ style: { minWidth: i.columns.length * Et + (N ? Dt : 0) },
761
895
  children: /* @__PURE__ */ S(h, {
762
- ...M ? { actions: M } : {},
763
- columns: j,
764
- dataSource: [...A],
896
+ ...N ? { actions: N } : {},
897
+ columns: M,
898
+ dataSource: [...j],
765
899
  rowHeightPreset: "roomy",
766
900
  showHeader: !0,
767
901
  size: "sub"
768
902
  })
769
903
  })
770
904
  }), d ? null : /* @__PURE__ */ S("div", {
771
- style: mt,
905
+ style: wt,
772
906
  children: /* @__PURE__ */ S(c, {
773
907
  disabled: _.length >= v.maxRows,
774
908
  icon: w,
@@ -782,14 +916,14 @@ function yt({ dataSourceContext: e, dataSourceInitialValues: t, errors: n, field
782
916
  })]
783
917
  });
784
918
  }
785
- function bt({ column: e, dataSourceContext: t, error: n, fieldPath: i, formData: a, initialFormData: o, initialRowValues: s, onChange: l, onDataSourceStateChange: u, optionSnapshots: d, path: f, readonly: p, rowValues: m, schema: h, uiSchema: g }) {
786
- let _ = wt(m, e.fieldKey), y = q({
919
+ function At({ column: e, dataSourceContext: t, error: n, fieldPath: i, formData: a, initialFormData: o, initialRowValues: s, onChange: l, onDataSourceStateChange: u, optionSnapshots: d, path: f, readonly: p, rowValues: m, schema: h, uiSchema: g }) {
920
+ let _ = Pt(m, e.fieldKey), y = q({
787
921
  context: t,
788
922
  field: e,
789
923
  fieldPath: i,
790
924
  formData: a,
791
925
  initialFormData: o,
792
- initialValue: s ? wt(s, e.fieldKey) : void 0,
926
+ initialValue: s ? Pt(s, e.fieldKey) : void 0,
793
927
  optionSnapshots: d,
794
928
  readonly: p,
795
929
  row: {
@@ -805,7 +939,7 @@ function bt({ column: e, dataSourceContext: t, error: n, fieldPath: i, formData:
805
939
  status: y.status
806
940
  });
807
941
  return r(() => {
808
- if (fe(e)) return u?.(f, {
942
+ if (B(e)) return u?.(f, {
809
943
  hasValue: y.hasValue,
810
944
  invalidValues: y.invalidValues,
811
945
  status: y.status
@@ -822,16 +956,16 @@ function bt({ column: e, dataSourceContext: t, error: n, fieldPath: i, formData:
822
956
  x
823
957
  ]), /* @__PURE__ */ C("div", {
824
958
  "data-form-field-key": f,
825
- style: vt,
959
+ style: Ot,
826
960
  children: [
827
- Tt(e, _, p, (e, t) => l(t), void 0, t, y, "sub"),
961
+ Ft(e, _, p, (e, t) => l(t), void 0, t, y, "sub"),
828
962
  n ? /* @__PURE__ */ S(v, {
829
963
  color: "text-error",
830
964
  variant: "caption",
831
965
  children: n
832
966
  }) : null,
833
967
  b ? /* @__PURE__ */ C("div", {
834
- style: ft,
968
+ style: St,
835
969
  children: [/* @__PURE__ */ S(v, {
836
970
  color: y.status === "INVALID" || y.status === "UNAVAILABLE" ? "text-error" : "text-neutral",
837
971
  variant: "caption",
@@ -847,38 +981,38 @@ function bt({ column: e, dataSourceContext: t, error: n, fieldPath: i, formData:
847
981
  ]
848
982
  });
849
983
  }
850
- function xt(e, t) {
984
+ function jt(e, t) {
851
985
  return R(e)[t];
852
986
  }
853
- function St(e) {
987
+ function Mt(e) {
854
988
  return e.current += 1, `table-row-${e.current}`;
855
989
  }
856
- function Ct(e, t, n) {
990
+ function Nt(e, t, n) {
857
991
  return n === void 0 || !V(n) ? Object.fromEntries(Object.entries(e).filter(([e]) => e !== t)) : {
858
992
  ...e,
859
993
  [t]: n
860
994
  };
861
995
  }
862
- function wt(e, t) {
996
+ function Pt(e, t) {
863
997
  if (e && Object.prototype.hasOwnProperty.call(e, t)) return e[t];
864
998
  }
865
- function Tt(e, t, n, r, i, a, o, s = "main") {
866
- return fe(e) ? Dt(e, t, n, r, a, o, s) : Et(e, t, n, r, i, s);
999
+ function Ft(e, t, n, r, i, a, o, s = "main") {
1000
+ return B(e) ? Lt(e, t, n, r, a, o, s) : It(e, t, n, r, i, s);
867
1001
  }
868
- function Et(e, t, n, r, i, a = "main") {
869
- let o = n && (e.type === "text" || e.type === "textarea") && e.displayAs === "link" ? Oe(t) : null;
1002
+ function It(e, t, n, r, i, a = "main") {
1003
+ let o = n && (e.type === "text" || e.type === "textarea") && e.displayAs === "link" ? Ie(t) : null;
870
1004
  if (o) return /* @__PURE__ */ S(v, {
871
1005
  color: "text-brand",
872
1006
  component: "span",
873
1007
  variant: "body",
874
1008
  children: /* @__PURE__ */ S("a", {
875
1009
  href: o.href,
876
- style: dt,
1010
+ style: xt,
877
1011
  ...o.external ? {
878
- "aria-label": `${o.href}${lt}`,
1012
+ "aria-label": `${o.href}${yt}`,
879
1013
  rel: "noopener noreferrer",
880
1014
  target: "_blank",
881
- title: ut
1015
+ title: bt
882
1016
  } : {},
883
1017
  children: o.href
884
1018
  })
@@ -887,10 +1021,10 @@ function Et(e, t, n, r, i, a = "main") {
887
1021
  onChange: (t) => r(e.fieldKey, t.target.value),
888
1022
  placeholder: e.placeholder ?? "請輸入多行文字",
889
1023
  readOnly: n,
890
- ref: it,
1024
+ ref: mt,
891
1025
  rows: 3,
892
- style: rt,
893
- value: kt(t)
1026
+ style: pt,
1027
+ value: zt(t)
894
1028
  });
895
1029
  if (e.type === "boolean") return /* @__PURE__ */ S(_, {
896
1030
  checked: t === !0,
@@ -900,7 +1034,7 @@ function Et(e, t, n, r, i, a = "main") {
900
1034
  size: a
901
1035
  });
902
1036
  if (pe(e) && e.type === "checkbox") {
903
- let i = e.options.map(F);
1037
+ let i = e.options.map(I);
904
1038
  return /* @__PURE__ */ S(m, {
905
1039
  mode: "multiple",
906
1040
  onChange: (t) => r(e.fieldKey, t?.length ? t.map((e) => e.id) : void 0),
@@ -908,21 +1042,21 @@ function Et(e, t, n, r, i, a = "main") {
908
1042
  placeholder: e.placeholder ?? "請選擇一或多個選項",
909
1043
  readOnly: n,
910
1044
  size: a,
911
- value: i.filter((e) => At(t).includes(e.id))
1045
+ value: i.filter((e) => Z(t).includes(e.id))
912
1046
  });
913
1047
  }
914
1048
  if (pe(e)) {
915
- let i = e.options.map(F);
1049
+ let i = e.options.map(I);
916
1050
  return /* @__PURE__ */ S(m, {
917
1051
  onChange: (t) => r(e.fieldKey, t?.id ?? void 0),
918
1052
  options: i,
919
1053
  placeholder: e.placeholder ?? "請選擇",
920
1054
  readOnly: n,
921
1055
  size: a,
922
- value: B(i, kt(t))
1056
+ value: le(i, zt(t))
923
1057
  });
924
1058
  }
925
- return e.type === "member" ? /* @__PURE__ */ S(Be, {
1059
+ return e.type === "member" ? /* @__PURE__ */ S(Xe, {
926
1060
  multiple: e.multiple === !0,
927
1061
  name: e.fieldKey,
928
1062
  onChange: (t) => r(e.fieldKey, t),
@@ -930,70 +1064,65 @@ function Et(e, t, n, r, i, a = "main") {
930
1064
  readonly: n,
931
1065
  size: a,
932
1066
  value: t
933
- }) : e.type === "org_unit" ? /* @__PURE__ */ S($e, {
1067
+ }) : e.type === "org_unit" ? /* @__PURE__ */ S(lt, {
934
1068
  name: e.fieldKey,
935
1069
  onChange: (t) => r(e.fieldKey, t),
936
- placeholder: e.placeholder ?? Mt(e.type),
1070
+ placeholder: e.placeholder ?? Vt(e.type),
937
1071
  readonly: n,
938
1072
  size: a,
939
1073
  value: t
940
- }) : e.type === "file_upload" ? /* @__PURE__ */ S(y, {
941
- accept: e.acceptedMimeTypes?.join(","),
942
- disabled: n,
943
- maxFiles: e.maxFiles,
944
- mode: "button-list",
945
- ...(e.maxFiles ?? 1) > 1 ? { multiple: !0 } : {},
946
- onChange: (t) => r(e.fieldKey, t.length ? t.map((e) => e.id) : void 0),
947
- onUpload: async (t) => Promise.all(t.map(async (t) => ({
948
- file: t,
949
- id: (i ? await i(e, t) : { id: `${t.name}-${t.lastModified}` }).id,
950
- progress: 100,
951
- status: "done"
952
- }))),
953
- size: "sub"
1074
+ }) : e.type === "file_upload" ? /* @__PURE__ */ S(Oe, {
1075
+ attachments: i?.attachments,
1076
+ field: e,
1077
+ onChange: (t) => r(e.fieldKey, t),
1078
+ onDownloadAttachment: i?.onDownloadAttachment,
1079
+ onStateChange: (t) => i?.onStateChange?.(e.fieldKey, t),
1080
+ onUploadAttachment: i?.onUploadAttachment,
1081
+ readonly: n,
1082
+ value: t
954
1083
  }) : e.type === "date" ? /* @__PURE__ */ S(u, {
955
1084
  format: "YYYY-MM-DD",
956
1085
  fullWidth: !0,
957
- onChange: (t) => r(e.fieldKey, O(t)),
958
- placeholder: e.placeholder ?? Mt(e.type),
1086
+ onChange: (t) => r(e.fieldKey, k(t)),
1087
+ placeholder: e.placeholder ?? Vt(e.type),
959
1088
  readOnly: n,
960
- value: P(t)
1089
+ value: F(t)
961
1090
  }) : e.type === "datetime" ? /* @__PURE__ */ S(d, {
962
1091
  formatDate: "YYYY-MM-DD",
963
1092
  formatTime: "HH:mm",
964
1093
  fullWidth: !0,
965
1094
  hideSecond: !0,
966
- onChange: (t) => r(e.fieldKey, k(t)),
1095
+ onChange: (t) => r(e.fieldKey, A(t)),
967
1096
  placeholderLeft: "選擇日期",
968
1097
  placeholderRight: "選擇時間",
969
1098
  readOnly: n,
970
- value: P(t)
1099
+ value: F(t)
971
1100
  }) : e.type === "number" || e.type === "money" ? /* @__PURE__ */ S(f, {
972
1101
  fullWidth: !0,
973
1102
  max: e.maximum,
974
1103
  min: e.minimum,
975
1104
  size: a,
976
- onChange: (t) => r(e.fieldKey, D(N(t.target.value), {
1105
+ onChange: (t) => r(e.fieldKey, D(P(t.target.value), {
977
1106
  max: e.maximum,
978
1107
  min: e.minimum
979
1108
  })),
980
- placeholder: e.placeholder ?? Mt(e.type),
1109
+ placeholder: e.placeholder ?? Vt(e.type),
981
1110
  ...n ? { readonly: !0 } : {},
982
1111
  showSpinner: !0,
983
- value: jt(t),
1112
+ value: Bt(t),
984
1113
  variant: "measure"
985
1114
  }) : /* @__PURE__ */ S(f, {
986
1115
  fullWidth: !0,
987
1116
  onChange: (t) => r(e.fieldKey, t.target.value),
988
- placeholder: e.placeholder ?? Mt(e.type),
1117
+ placeholder: e.placeholder ?? Vt(e.type),
989
1118
  ...n ? { readonly: !0 } : {},
990
1119
  size: a,
991
- value: kt(t),
1120
+ value: zt(t),
992
1121
  variant: "base"
993
1122
  });
994
1123
  }
995
- function Dt(e, t, n, r, i, a, o = "main") {
996
- let c = a.options.map(F), u = le(t, a.options).map(F), d = a.status === "LOADING", f = a.status === "WAITING_FOR_DEPENDENCIES", h = !!i && !n, g = n || f, _ = n;
1124
+ function Lt(e, t, n, r, i, a, o = "main") {
1125
+ let c = a.options.map(I), u = ue(t, a.options).map(I), d = a.status === "LOADING", f = a.status === "WAITING_FOR_DEPENDENCIES", h = !!i && !n, g = n || f, _ = n;
997
1126
  return e.type === "autocomplete" ? H(e) === "multiple" ? /* @__PURE__ */ S(s, {
998
1127
  asyncData: h,
999
1128
  clearSearchText: !0,
@@ -1033,7 +1162,7 @@ function Dt(e, t, n, r, i, a, o = "main") {
1033
1162
  name: e.fieldKey,
1034
1163
  onChange: (t) => r(e.fieldKey, t.target.value || void 0),
1035
1164
  options: c,
1036
- value: kt(t)
1165
+ value: zt(t)
1037
1166
  }) : e.type === "checkbox" ? /* @__PURE__ */ S(l, {
1038
1167
  disabled: g,
1039
1168
  name: e.fieldKey,
@@ -1042,7 +1171,7 @@ function Dt(e, t, n, r, i, a, o = "main") {
1042
1171
  label: e.name,
1043
1172
  value: e.id
1044
1173
  })),
1045
- value: [...At(t)]
1174
+ value: [...Z(t)]
1046
1175
  }) : H(e) === "multiple" ? /* @__PURE__ */ S(m, {
1047
1176
  disabled: g,
1048
1177
  loading: d,
@@ -1066,23 +1195,20 @@ function Dt(e, t, n, r, i, a, o = "main") {
1066
1195
  value: u[0] ?? null
1067
1196
  });
1068
1197
  }
1069
- function Ot(e, t) {
1198
+ function Rt(e, t) {
1070
1199
  return {
1071
1200
  FULL: 12,
1072
1201
  HALF: 6,
1073
1202
  THIRD: 4
1074
1203
  }[t.layout.find((t) => t.fieldKey === e.fieldKey)?.width ?? "FULL"];
1075
1204
  }
1076
- function kt(e) {
1205
+ function zt(e) {
1077
1206
  return typeof e == "string" ? e : "";
1078
1207
  }
1079
- function At(e) {
1080
- return Array.isArray(e) && e.every((e) => typeof e == "string") ? e : [];
1081
- }
1082
- function jt(e) {
1208
+ function Bt(e) {
1083
1209
  return typeof e == "number" ? String(e) : "";
1084
1210
  }
1085
- function Mt(e) {
1211
+ function Vt(e) {
1086
1212
  return {
1087
1213
  boolean: "",
1088
1214
  autocomplete: "請輸入或選擇",
@@ -1101,6 +1227,6 @@ function Mt(e) {
1101
1227
  textarea: "請輸入多行文字"
1102
1228
  }[e];
1103
1229
  }
1104
- export { Y as a, q as c, Q as i, Ue as n, J as o, je as r, X as s, at as t };
1230
+ export { Te as a, J as c, Be as i, X as l, $e as n, Ee as o, Ve as r, Y as s, ht as t, q as u };
1105
1231
 
1106
- //# sourceMappingURL=FormRendererView-CTLlG13b.js.map
1232
+ //# sourceMappingURL=FormRendererView-DHfVgbo6.js.map