@rytass/bpm-core-react 0.22.0 → 0.24.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 (166) hide show
  1. package/CHANGELOG.md +84 -0
  2. package/README.md +1 -0
  3. package/dist/chunks/FormBuilderView-Bg9ftYz-.cjs +4 -0
  4. package/dist/chunks/FormBuilderView-Bg9ftYz-.cjs.map +1 -0
  5. package/dist/chunks/{FormBuilderView-DbfbLZCI.js → FormBuilderView-CBvdcg_t.js} +675 -614
  6. package/dist/chunks/FormBuilderView-CBvdcg_t.js.map +1 -0
  7. package/dist/chunks/FormRendererView-D-p6GDQB.cjs +6 -0
  8. package/dist/chunks/FormRendererView-D-p6GDQB.cjs.map +1 -0
  9. package/dist/chunks/FormRendererView-DHXmekC3.js +1319 -0
  10. package/dist/chunks/FormRendererView-DHXmekC3.js.map +1 -0
  11. package/dist/chunks/{approval-instance-list-page-Cv5I1YPX.cjs → approval-instance-list-page-BqkG9jiR.cjs} +2 -2
  12. package/dist/chunks/{approval-instance-list-page-Cv5I1YPX.cjs.map → approval-instance-list-page-BqkG9jiR.cjs.map} +1 -1
  13. package/dist/chunks/{approval-instance-list-page-BI5fIXc-.js → approval-instance-list-page-CsSpIN4C.js} +2 -2
  14. package/dist/chunks/{approval-instance-list-page-BI5fIXc-.js.map → approval-instance-list-page-CsSpIN4C.js.map} +1 -1
  15. package/dist/chunks/compose-B43jtdyL.cjs +2 -0
  16. package/dist/chunks/compose-B43jtdyL.cjs.map +1 -0
  17. package/dist/chunks/{compose-U1zs3Yof.js → compose-C7yS6bJm.js} +162 -148
  18. package/dist/chunks/compose-C7yS6bJm.js.map +1 -0
  19. package/dist/chunks/{dashboard-page-BoqNhjT_.js → dashboard-page-DBJCsPya.js} +2 -2
  20. package/dist/chunks/{dashboard-page-BoqNhjT_.js.map → dashboard-page-DBJCsPya.js.map} +1 -1
  21. package/dist/chunks/{dashboard-page-D7YJ3udk.cjs → dashboard-page-lqlLELKs.cjs} +2 -2
  22. package/dist/chunks/{dashboard-page-D7YJ3udk.cjs.map → dashboard-page-lqlLELKs.cjs.map} +1 -1
  23. package/dist/chunks/{designer-DPG7R_WP.js → designer-B9Ut4xze.js} +1786 -1463
  24. package/dist/chunks/designer-B9Ut4xze.js.map +1 -0
  25. package/dist/chunks/designer-eXw7R9ug.cjs +69 -0
  26. package/dist/chunks/designer-eXw7R9ug.cjs.map +1 -0
  27. package/dist/chunks/{detail-CHZDNNM6.js → detail-BB_uYaoM.js} +904 -896
  28. package/dist/chunks/detail-BB_uYaoM.js.map +1 -0
  29. package/dist/chunks/detail-DN8pEzUJ.cjs +5 -0
  30. package/dist/chunks/detail-DN8pEzUJ.cjs.map +1 -0
  31. package/dist/chunks/instance-error-message-BKt07-Bo.js +270 -0
  32. package/dist/chunks/instance-error-message-BKt07-Bo.js.map +1 -0
  33. package/dist/chunks/instance-error-message-BL_X7Af8.cjs +2 -0
  34. package/dist/chunks/instance-error-message-BL_X7Af8.cjs.map +1 -0
  35. package/dist/chunks/member-profile-resolution-CJlgVdTR.js +44 -0
  36. package/dist/chunks/member-profile-resolution-CJlgVdTR.js.map +1 -0
  37. package/dist/chunks/member-profile-resolution-DiH-P-Vh.cjs +2 -0
  38. package/dist/chunks/member-profile-resolution-DiH-P-Vh.cjs.map +1 -0
  39. package/dist/chunks/{providers-CQWekD7_.js → providers-D35lBOTd.js} +2 -2
  40. package/dist/chunks/{providers-CQWekD7_.js.map → providers-D35lBOTd.js.map} +1 -1
  41. package/dist/chunks/{providers-VUOh6i0i.cjs → providers-Dz4Wqxr6.cjs} +2 -2
  42. package/dist/chunks/{providers-VUOh6i0i.cjs.map → providers-Dz4Wqxr6.cjs.map} +1 -1
  43. package/dist/chunks/{routes-config-C1j_vFKo.cjs → routes-config-BWjZDAU3.cjs} +2 -2
  44. package/dist/chunks/{routes-config-C1j_vFKo.cjs.map → routes-config-BWjZDAU3.cjs.map} +1 -1
  45. package/dist/chunks/{routes-config-BcNaWJWJ.js → routes-config-DjEOE9eP.js} +3 -2
  46. package/dist/chunks/{routes-config-BcNaWJWJ.js.map → routes-config-DjEOE9eP.js.map} +1 -1
  47. package/dist/chunks/users-C_Dtw_sR.cjs +2 -0
  48. package/dist/chunks/users-C_Dtw_sR.cjs.map +1 -0
  49. package/dist/chunks/users-wgM3TqU3.js +513 -0
  50. package/dist/chunks/users-wgM3TqU3.js.map +1 -0
  51. package/dist/index.cjs +1 -1
  52. package/dist/index.js +4 -4
  53. package/dist/lib/routes-config.d.cts +2 -0
  54. package/dist/lib/routes-config.d.ts +2 -0
  55. package/dist/next/index.cjs +1 -1
  56. package/dist/next/index.js +2 -2
  57. package/dist/pages/admin/stuck-instances/index.cjs +2 -0
  58. package/dist/pages/admin/stuck-instances/index.cjs.map +1 -0
  59. package/dist/pages/admin/stuck-instances/index.d.cts +4 -0
  60. package/dist/pages/admin/stuck-instances/index.d.ts +4 -0
  61. package/dist/pages/admin/stuck-instances/index.js +13 -0
  62. package/dist/pages/admin/stuck-instances/index.js.map +1 -0
  63. package/dist/pages/admin/users/index.cjs +1 -1
  64. package/dist/pages/admin/users/index.js +1 -1
  65. package/dist/pages/instances/detail/index.cjs +1 -1
  66. package/dist/pages/instances/detail/index.js +1 -1
  67. package/dist/pages/templates/compose/index.cjs +1 -1
  68. package/dist/pages/templates/compose/index.js +1 -1
  69. package/dist/pages/templates/designer/index.cjs +1 -1
  70. package/dist/pages/templates/designer/index.js +1 -1
  71. package/dist/views/admin/index.cjs +1 -1
  72. package/dist/views/admin/index.d.cts +1 -0
  73. package/dist/views/admin/index.d.ts +1 -0
  74. package/dist/views/admin/index.js +3 -2
  75. package/dist/views/admin/stuck-instances/AdminStuckInstancesView.d.cts +10 -0
  76. package/dist/views/admin/stuck-instances/AdminStuckInstancesView.d.ts +10 -0
  77. package/dist/views/admin/stuck-instances/StuckInstanceCancelModal.d.cts +14 -0
  78. package/dist/views/admin/stuck-instances/StuckInstanceCancelModal.d.ts +14 -0
  79. package/dist/views/admin/stuck-instances/index.cjs +2 -0
  80. package/dist/views/admin/stuck-instances/index.cjs.map +1 -0
  81. package/dist/views/admin/stuck-instances/index.d.cts +2 -0
  82. package/dist/views/admin/stuck-instances/index.d.ts +2 -0
  83. package/dist/views/admin/stuck-instances/index.js +237 -0
  84. package/dist/views/admin/stuck-instances/index.js.map +1 -0
  85. package/dist/views/admin/users/index.cjs +1 -1
  86. package/dist/views/admin/users/index.js +1 -1
  87. package/dist/views/cc/index.cjs +1 -1
  88. package/dist/views/cc/index.js +1 -1
  89. package/dist/views/dashboard/index.cjs +1 -1
  90. package/dist/views/dashboard/index.js +1 -1
  91. package/dist/views/forms/builder/index.cjs +1 -1
  92. package/dist/views/forms/builder/index.js +1 -1
  93. package/dist/views/forms/renderer/FormRendererView.d.cts +26 -1
  94. package/dist/views/forms/renderer/FormRendererView.d.ts +26 -1
  95. package/dist/views/forms/renderer/index.cjs +1 -1
  96. package/dist/views/forms/renderer/index.js +1 -1
  97. package/dist/views/inbox/index.cjs +1 -1
  98. package/dist/views/inbox/index.js +1 -1
  99. package/dist/views/instances/approver-filled-form.d.cts +56 -20
  100. package/dist/views/instances/approver-filled-form.d.ts +56 -20
  101. package/dist/views/instances/detail/index.cjs +1 -1
  102. package/dist/views/instances/detail/index.js +1 -1
  103. package/dist/views/instances/detail/sections/InstanceFormSection.d.cts +7 -0
  104. package/dist/views/instances/detail/sections/InstanceFormSection.d.ts +7 -0
  105. package/dist/views/instances/detail/sections/InstanceTasksSection.d.cts +1 -1
  106. package/dist/views/instances/detail/sections/InstanceTasksSection.d.ts +1 -1
  107. package/dist/views/instances/new/index.cjs +1 -1
  108. package/dist/views/instances/new/index.js +5 -5
  109. package/dist/views/instances/new/index.js.map +1 -1
  110. package/dist/views/search/index.cjs +1 -1
  111. package/dist/views/search/index.js +1 -1
  112. package/dist/views/sent/index.cjs +1 -1
  113. package/dist/views/sent/index.js +1 -1
  114. package/dist/views/templates/compose/index.cjs +1 -1
  115. package/dist/views/templates/compose/index.js +1 -1
  116. package/dist/views/templates/compose/steps/ComposeReviewStep.d.cts +3 -1
  117. package/dist/views/templates/compose/steps/ComposeReviewStep.d.ts +3 -1
  118. package/dist/views/templates/compose/steps/ComposeWorkflowStep.d.cts +4 -1
  119. package/dist/views/templates/compose/steps/ComposeWorkflowStep.d.ts +4 -1
  120. package/dist/views/templates/compose/use-template-compose-wizard.d.cts +3 -1
  121. package/dist/views/templates/compose/use-template-compose-wizard.d.ts +3 -1
  122. package/dist/views/templates/designer/TemplateDesignerView.d.cts +10 -1
  123. package/dist/views/templates/designer/TemplateDesignerView.d.ts +10 -1
  124. package/dist/views/templates/designer/approver-resolver-model.d.cts +31 -0
  125. package/dist/views/templates/designer/approver-resolver-model.d.ts +31 -0
  126. package/dist/views/templates/designer/field-access-matrix/FieldAccessMatrixDrawer.d.cts +3 -1
  127. package/dist/views/templates/designer/field-access-matrix/FieldAccessMatrixDrawer.d.ts +3 -1
  128. package/dist/views/templates/designer/field-access-matrix/field-access-copy.d.cts +3 -2
  129. package/dist/views/templates/designer/field-access-matrix/field-access-copy.d.ts +3 -2
  130. package/dist/views/templates/designer/index.cjs +1 -1
  131. package/dist/views/templates/designer/index.js +1 -1
  132. package/dist/views/templates/designer/launch-mode.d.cts +19 -0
  133. package/dist/views/templates/designer/launch-mode.d.ts +19 -0
  134. package/dist/views/templates/designer/node-actor-resolver-options.d.cts +30 -3
  135. package/dist/views/templates/designer/node-actor-resolver-options.d.ts +30 -3
  136. package/dist/views/templates/designer/publish-default-value-check.d.cts +36 -0
  137. package/dist/views/templates/designer/publish-default-value-check.d.ts +36 -0
  138. package/dist/views/templates/index.cjs +1 -1
  139. package/dist/views/templates/index.js +1 -1
  140. package/dist/views/templates/versions/index.cjs +1 -1
  141. package/dist/views/templates/versions/index.js +1 -1
  142. package/package.json +23 -3
  143. package/dist/chunks/FormBuilderView-Bok4Y59D.cjs +0 -4
  144. package/dist/chunks/FormBuilderView-Bok4Y59D.cjs.map +0 -1
  145. package/dist/chunks/FormBuilderView-DbfbLZCI.js.map +0 -1
  146. package/dist/chunks/FormRendererView-CAyPXhPq.js +0 -1351
  147. package/dist/chunks/FormRendererView-CAyPXhPq.js.map +0 -1
  148. package/dist/chunks/FormRendererView-iLlHFIUR.cjs +0 -6
  149. package/dist/chunks/FormRendererView-iLlHFIUR.cjs.map +0 -1
  150. package/dist/chunks/compose-DP1N4twA.cjs +0 -2
  151. package/dist/chunks/compose-DP1N4twA.cjs.map +0 -1
  152. package/dist/chunks/compose-U1zs3Yof.js.map +0 -1
  153. package/dist/chunks/designer-CWL-dCQ_.cjs +0 -69
  154. package/dist/chunks/designer-CWL-dCQ_.cjs.map +0 -1
  155. package/dist/chunks/designer-DPG7R_WP.js.map +0 -1
  156. package/dist/chunks/detail-BUfsSal0.cjs +0 -5
  157. package/dist/chunks/detail-BUfsSal0.cjs.map +0 -1
  158. package/dist/chunks/detail-CHZDNNM6.js.map +0 -1
  159. package/dist/chunks/instance-error-message-BEM4O_Kj.js +0 -208
  160. package/dist/chunks/instance-error-message-BEM4O_Kj.js.map +0 -1
  161. package/dist/chunks/instance-error-message-BpCLCOjp.cjs +0 -2
  162. package/dist/chunks/instance-error-message-BpCLCOjp.cjs.map +0 -1
  163. package/dist/chunks/users-BBtiZ9QQ.js +0 -486
  164. package/dist/chunks/users-BBtiZ9QQ.js.map +0 -1
  165. package/dist/chunks/users-EqSzDhuj.cjs +0 -2
  166. package/dist/chunks/users-EqSzDhuj.cjs.map +0 -1
@@ -1,1351 +0,0 @@
1
- "use client";
2
- import { t as e } from "./bpm-form-field-9B-Det0u.js";
3
- import { t } from "./format-member-label-C73FuP-d.js";
4
- import { useCallback as n, useEffect as r, useMemo as i, useRef as a, useState as o } from "react";
5
- import { AutoComplete as s, Button as c, CheckboxGroup as l, DatePicker as u, DateTimePicker as d, Input as f, RadioGroup as p, Select as m, Table as h, Textarea as g, Toggle as _, Typography as v, Upload as y } from "@mezzanine-ui/react";
6
- import { resolveMembers as b, searchMembers as x } from "@rytass/bpm-core-client";
7
- import { jsx as S, jsxs as C } from "react/jsx-runtime";
8
- import { FormFieldDensity as w, FormFieldLayout as T } from "@mezzanine-ui/core/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 ee, 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 se, readFormTableRowBounds as ce, readFormTableRows as L, readMissingFormDataSourceDependencies as le, readMissingFormDataSourceOptionValues as R, readSelectOption as z, readSelectedFormDataSourceOptions as ue, readVisibleFormRendererFields as B, resolveFormFieldOptions as de } from "@rytass/bpm-core-client/form";
10
- import { PlusIcon as V, TrashIcon as fe } from "@mezzanine-ui/icons";
11
- import { isFormDataSourceFieldDefinition as pe, isFormStaticOptionFieldDefinition as me, isFormTableCellValue as he, isTableFieldDefinition as H, readFormFieldSelectionMode as ge, readFormMemberIds as _e } from "@rytass/bpm-core-shared/form";
12
- import { resolveOrgUnitOptions as ve, searchOrgUnitOptions as ye } from "@rytass/bpm-core-client/organization";
13
- // src/views/forms/renderer/form-data-source-field.ts
14
- var be = {
15
- canRetry: !1,
16
- error: null,
17
- hasValue: !1,
18
- hasNextPage: !1,
19
- loadingNextPage: !1,
20
- invalidValues: [],
21
- onOpen: () => void 0,
22
- onReachBottom: () => void 0,
23
- onSearch: () => void 0,
24
- options: [],
25
- retry: () => void 0,
26
- status: "IDLE"
27
- }, xe = [], Se = 10, Ce = 300, we = ["FORM_DATA_SOURCE_SEARCH_NOT_SUPPORTED", "FORM_DATA_SOURCE_SEARCH_TOO_SHORT"];
28
- function Te(e, t) {
29
- if (!t.row) return e;
30
- let n = t.fieldPath?.indexOf(".") ?? -1;
31
- return t.fieldPath && n > 0 ? t.fieldPath.slice(0, n) : null;
32
- }
33
- function Ee(e, t) {
34
- return t === null ? e : Object.fromEntries(Object.entries(e).filter(([e]) => e !== t));
35
- }
36
- function De(e, t) {
37
- let n = e.from;
38
- switch (n.kind) {
39
- case "FIELD": return {
40
- fieldKey: n.fieldKey,
41
- value: t.formData[n.fieldKey]
42
- };
43
- case "CONSTANT": return { value: n.value };
44
- case "ROW_FIELD": return {
45
- columnKey: n.columnKey,
46
- value: t.rowValues?.[n.columnKey]
47
- };
48
- case "EXPRESSION": return {
49
- expression: n.expression,
50
- form: Ee(t.formData, t.ownFormKey),
51
- row: t.rowValues ? Ee(t.rowValues, t.ownRowKey) : null
52
- };
53
- default: return U(n);
54
- }
55
- }
56
- function U(e) {
57
- return { unsupported: !0 };
58
- }
59
- function Oe(e) {
60
- return JSON.stringify(ke(e)) ?? "null";
61
- }
62
- function ke(e) {
63
- return Array.isArray(e) ? e.map(ke) : typeof e == "object" && e ? Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0).sort(([e], [t]) => e < t ? -1 : +(e > t)).map(([e, t]) => [e, ke(t)])) : e;
64
- }
65
- function W(e) {
66
- let t = pe(e.field) ? e.field : null, s = e.fieldPath ?? t?.fieldKey ?? "", c = t ? e.optionSnapshots?.[e.snapshotKey ?? t.fieldKey] : void 0, l = t ? JSON.stringify({
67
- dataSource: t.dataSource,
68
- fieldKey: t.fieldKey,
69
- type: t.type
70
- }) : "", 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(t.dataSource.bindings.map((n) => De(n, {
71
- formData: e.formData,
72
- ownFormKey: Te(t.fieldKey, e),
73
- ownRowKey: e.row ? t.fieldKey : null,
74
- rowValues: e.row?.values
75
- }))) : "", D = t ? JSON.stringify(e.initialFormData !== void 0 || e.initialValue !== void 0 ? x ?? null : null) : "", O = t ? `${T}\u0000${D}` : "", k = Ae(T, t?.dataSource.bindings.some((e) => e.from.kind === "EXPRESSION") ? Ce : 0), A = k !== T, j = i(() => {
76
- if (g === "preview") return { kind: "preview" };
77
- if (g === "runtime" && !e.readonly) return {
78
- instanceId: _,
79
- kind: "runtime",
80
- templateId: v
81
- };
82
- }, [
83
- _,
84
- g,
85
- v,
86
- e.readonly
87
- ]), M = t ? (e.initialFormData !== void 0 || e.initialValue !== void 0) && I(e.initialValue) !== S : !1, ee = t ? e.initialFormData !== void 0 && t.dataSource.bindings.some((n) => {
88
- if (n.from.kind === "FIELD") return I(e.initialFormData?.[n.from.fieldKey]) !== I(e.formData[n.from.fieldKey]);
89
- if (n.from.kind === "ROW_FIELD" && e.row?.initialValues) return I(e.row.initialValues[n.from.columnKey]) !== I(e.row.values[n.from.columnKey]);
90
- if (n.from.kind === "EXPRESSION") {
91
- if (!j) return !1;
92
- let r = {
93
- ownFormKey: Te(t.fieldKey, e),
94
- ownRowKey: e.row ? t.fieldKey : null
95
- };
96
- return Oe(De(n, {
97
- ...r,
98
- formData: E(e.schema.fields, e.initialFormData ?? {}),
99
- rowValues: e.row?.initialValues ?? e.row?.values
100
- })) !== Oe(De(n, {
101
- ...r,
102
- formData: E(e.schema.fields, e.formData),
103
- rowValues: e.row?.values
104
- }));
105
- }
106
- return !1;
107
- }) : !1, P = !!t?.dataSource.bindings.some((e) => e.from.kind === "EXPRESSION"), [F, se] = o(() => ({
108
- bindings: k,
109
- value: S
110
- }));
111
- F.value !== S && se({
112
- bindings: k,
113
- value: S
114
- });
115
- let ce = !!(P && j && w && F.value === S && F.bindings !== k), L = !!((c || w) && (M || ee || ce)), R = !!(t && j && L && w), z = Pe({
116
- hasSnapshot: !!c,
117
- hasValue: w,
118
- isStale: L,
119
- readonly: e.readonly
120
- }), B = !!(t && j && t.type !== "autocomplete"), V = Fe(L, B && t !== null && le(t, e.formData, e.row?.values).length > 0), fe = a(z);
121
- fe.current = z;
122
- let [me, he] = o([]), [H, ge] = o(""), [_e, ve] = o(null), [ye, xe] = o(null), [Ee, U] = o(() => t ? B ? V : z : "IDLE"), [ke, W] = o(null), [je, G] = o(!1), Me = a(0), K = a(0), q = a(0), Be = a(null), Ve = a(null), J = a(!1), He = a({
123
- cursor: null,
124
- searchText: ""
125
- }), Y = i(() => ze(e.formData), [f]), X = i(() => e.row ? ze(e.row.values) : void 0, [y]), Ue = i(() => N(d, me), [me, d]), We = ye && ye.signature === O && ye.valueSignature === S ? ye : null, Ge = R && !We, Ke = !!(ce && We && We.unresolvedValues.length > 0), qe = Ne({
126
- options: Ue,
127
- resolution: We,
128
- resolvePending: Ge,
129
- value: x
130
- }), Z = n((n, r) => {
131
- if (!t || !j) return;
132
- let i = K.current + 1;
133
- K.current = i, J.current = !0, He.current = {
134
- cursor: r,
135
- searchText: n
136
- }, Be.current?.abort();
137
- let a = new AbortController();
138
- Be.current = a, U(V), G(r !== null), W(null), (j.kind === "preview" ? te({
139
- cursor: r,
140
- fieldKey: s,
141
- formData: Y,
142
- rowValues: X,
143
- schema: e.schema,
144
- searchText: n,
145
- signal: a.signal,
146
- uiSchema: e.uiSchema
147
- }) : oe({
148
- cursor: r,
149
- fieldKey: s,
150
- formData: Y,
151
- instanceId: j.instanceId ?? null,
152
- rowValues: X,
153
- searchText: n,
154
- signal: a.signal,
155
- templateId: j.templateId ?? null
156
- })).then((e) => {
157
- Re(a, K, i) || (G(!1), he((t) => {
158
- let n = ue(x, t);
159
- return N(n, r ? t : [], e.options);
160
- }), ve(e.nextCursor), W(null), Me.current = r ? Me.current + e.options.length : e.options.length, e.nextCursor && e.options.length > 0 && Me.current < Se && Q.current(n, e.nextCursor), U(e.waitingForFieldKeys.length ? "WAITING_FOR_DEPENDENCIES" : "VALID"));
161
- }).catch((e) => {
162
- if (Re(a, K, i)) return;
163
- r === null && (J.current = !1), G(!1);
164
- let t = ie(e) ?? "選項來源暫時無法使用。", n = re(e);
165
- W(t), U(Ie(!!(n && we.includes(n)), w));
166
- });
167
- }, [
168
- S,
169
- l,
170
- j,
171
- w,
172
- V,
173
- s,
174
- Y,
175
- X,
176
- m,
177
- h
178
- ]), Q = a(Z);
179
- Q.current = Z;
180
- let Je = n(() => {
181
- if (!t || !j || C.length === 0) return;
182
- let n = O, r = S, i = q.current + 1;
183
- q.current = i, Ve.current?.abort();
184
- let a = new AbortController();
185
- Ve.current = a, W(null), (j.kind === "preview" ? ne({
186
- fieldKey: s,
187
- formData: Y,
188
- rowValues: X,
189
- schema: e.schema,
190
- signal: a.signal,
191
- uiSchema: e.uiSchema,
192
- values: C
193
- }) : de({
194
- fieldKey: s,
195
- formData: Y,
196
- instanceId: j.instanceId ?? null,
197
- rowValues: X,
198
- signal: a.signal,
199
- templateId: j.templateId ?? null,
200
- values: C
201
- })).then((e) => {
202
- Re(a, q, i) || (e.waitingForFieldKeys.length ? U("WAITING_FOR_DEPENDENCIES") : (he((t) => N(t, e.options)), xe({
203
- signature: n,
204
- unresolvedValues: e.unresolvedValues,
205
- valueSignature: r
206
- }), U("VALID")));
207
- }).catch((e) => {
208
- Re(a, q, i) || (U("UNAVAILABLE"), W(ie(e) ?? "選項來源暫時無法使用。"));
209
- });
210
- }, [
211
- S,
212
- O,
213
- l,
214
- j,
215
- s,
216
- Y,
217
- X,
218
- m,
219
- C,
220
- h
221
- ]), Ye = a(Je);
222
- Ye.current = Je, r(() => {
223
- K.current += 1, J.current = !1, Be.current?.abort(), G(!1), he((e) => ue(x, e)), ve((e) => e === null ? e : null), ge((e) => e && ""), W((e) => e && null), t ? B ? Q.current("", null) : U(fe.current) : U("IDLE");
224
- }, [
225
- B,
226
- l,
227
- j,
228
- k,
229
- D,
230
- p,
231
- b,
232
- e.readonly,
233
- u
234
- ]), r(() => {
235
- t && !B && U(z);
236
- }, [
237
- B,
238
- l,
239
- z
240
- ]), r(() => {
241
- R && !A && Ye.current();
242
- }, [
243
- j,
244
- R,
245
- A,
246
- k,
247
- D
248
- ]), r(() => () => {
249
- Be.current?.abort(), Ve.current?.abort();
250
- }, []);
251
- let Xe = n((e) => {
252
- ge(e), he((e) => ue(x, e)), ve(null), Z(e, null);
253
- }, [Z]), Ze = n(() => {
254
- B || !j || e.readonly || J.current && H === "" || Xe("");
255
- }, [
256
- B,
257
- j,
258
- e.readonly,
259
- Xe,
260
- H
261
- ]), Qe = a({
262
- cursor: _e,
263
- searchText: H
264
- });
265
- Qe.current = {
266
- cursor: _e,
267
- searchText: H
268
- };
269
- let $e = n(() => {
270
- let { cursor: e, searchText: t } = Qe.current;
271
- e && Q.current(t, e);
272
- }, []), et = n(() => {
273
- j && (Z(He.current.searchText, He.current.cursor), R && Ye.current());
274
- }, [
275
- j,
276
- Z,
277
- R
278
- ]);
279
- return t ? {
280
- canRetry: !!j,
281
- error: ke,
282
- hasValue: w,
283
- hasNextPage: !!_e,
284
- loadingNextPage: je,
285
- invalidValues: qe,
286
- onOpen: Ze,
287
- onReachBottom: $e,
288
- onSearch: Xe,
289
- options: Ue,
290
- retry: et,
291
- selectionExpired: Ke,
292
- status: A && j && (B || w) ? B ? V : "STALE" : Le({
293
- invalidValues: qe,
294
- resolvePending: Ge,
295
- status: Ee
296
- })
297
- } : be;
298
- }
299
- function Ae(e, t) {
300
- let [n, i] = o(e);
301
- return r(() => {
302
- if (t <= 0) return;
303
- let n = setTimeout(() => {
304
- i(e);
305
- }, t);
306
- return () => {
307
- clearTimeout(n);
308
- };
309
- }, [t, e]), t > 0 ? n : e;
310
- }
311
- function je(e) {
312
- switch (e.status) {
313
- case "WAITING_FOR_DEPENDENCIES": return "請先填寫相依欄位。";
314
- case "STALE": return "選項需要重新載入或驗證。";
315
- case "INVALID": return e.selectionExpired ? ie("FORM_DATA_SOURCE_VALUE_NOT_RESOLVED") : e.invalidValues.length ? `無法辨識選項:${e.invalidValues.join("、")}` : "目前選項已失效,請重新選擇。";
316
- case "UNAVAILABLE": return e.error ?? "選項來源暫時無法使用。";
317
- case "VALID": return e.error ?? (e.options.length ? null : "目前沒有可用選項。");
318
- default: return e.error;
319
- }
320
- }
321
- function G(e) {
322
- return e.hasValue && e.status !== "VALID";
323
- }
324
- function Me(e) {
325
- let t = e.filter(G);
326
- return t.length === 0 ? null : t.some((e) => e.status === "INVALID" && e.selectionExpired === !0) ? ie("FORM_DATA_SOURCE_VALUE_NOT_RESOLVED") : t.every((e) => e.status === "LOADING" || e.status === "STALE") ? "選項驗證中,請稍候再送出。" : "請先完成動態選項驗證。";
327
- }
328
- function Ne(e) {
329
- return e.resolution ? e.resolution.unresolvedValues : e.resolvePending ? xe : R(e.value, e.options);
330
- }
331
- function Pe(e) {
332
- return e.isStale ? "STALE" : e.hasSnapshot ? "VALID" : e.readonly && e.hasValue ? "UNAVAILABLE" : "IDLE";
333
- }
334
- function Fe(e, t) {
335
- return t ? "WAITING_FOR_DEPENDENCIES" : e ? "STALE" : "LOADING";
336
- }
337
- function Ie(e, t) {
338
- return e ? t ? "VALID" : "IDLE" : "UNAVAILABLE";
339
- }
340
- function Le(e) {
341
- return e.status === "LOADING" || e.status === "UNAVAILABLE" || e.status === "WAITING_FOR_DEPENDENCIES" ? e.status : e.invalidValues.length ? "INVALID" : e.resolvePending ? "STALE" : e.status;
342
- }
343
- function Re(e, t, n) {
344
- return e.signal.aborted || t.current !== n;
345
- }
346
- function ze(e) {
347
- return Object.entries(e).reduce((e, [t, n]) => n === void 0 ? e : {
348
- ...e,
349
- [t]: n
350
- }, {});
351
- }
352
- // src/views/forms/renderer/form-value-readers.ts
353
- function K(e) {
354
- return Array.isArray(e) && e.every((e) => typeof e == "string") ? e : [];
355
- }
356
- // src/views/forms/renderer/file-upload-field.tsx
357
- function q(e) {
358
- return e.some((e) => e.pendingCount > 0) ? "附件仍在上傳中,請稍候再送出。" : e.some((e) => e.failedCount > 0) ? "有附件上傳失敗,請重試或移除後再送出。" : null;
359
- }
360
- function Be() {
361
- let [e, t] = o({}), r = n((e, n) => t((t) => ({
362
- ...t,
363
- [e]: n
364
- })), []);
365
- return {
366
- blockMessage: q(Object.values(e)),
367
- onFileUploadStateChange: r
368
- };
369
- }
370
- var Ve = "無法讀取檔名的附件", J = "此處無法上傳附件";
371
- function He({ attachments: e, field: t, onChange: s, onDownloadAttachment: c, onStateChange: l, onUploadAttachment: u, readonly: d, value: f }) {
372
- let [p, m] = o([]), [h, g] = o(() => /* @__PURE__ */ new Map()), [_, v] = o([]), b = K(f), x = b.join("\n"), C = i(() => new Map((e ?? []).map((e) => [e.id, e])), [e]), w = i(() => {
373
- let e = new Map(_.map((e, t) => [e, t]));
374
- return [...b.map((e) => h.get(e) ?? Y(e, C.get(e))), ...p].sort((t, n) => (e.get(t.id) ?? -1) - (e.get(n.id) ?? -1));
375
- }, [
376
- C,
377
- _,
378
- h,
379
- p,
380
- x
381
- ]), T = a(w), E = a(!0), D = a(M);
382
- D.current = M, r(() => {
383
- T.current = w;
384
- }, [w]);
385
- 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);
386
- j.current = l, r(() => {
387
- j.current?.({
388
- failedCount: A,
389
- pendingCount: k
390
- });
391
- }, [A, k]), r(() => (E.current = !0, () => {
392
- E.current = !1, j.current?.({
393
- failedCount: 0,
394
- pendingCount: 0
395
- });
396
- }), []);
397
- function M(e) {
398
- if (!E.current) return;
399
- 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));
400
- 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);
401
- }
402
- async function N(e) {
403
- if (!u) throw Error(J);
404
- return {
405
- file: e,
406
- id: (await u(t, e)).id,
407
- progress: 100,
408
- status: "done"
409
- };
410
- }
411
- async function ee(e, t) {
412
- let n = await N(t).catch((n) => ({
413
- errorMessage: Ue(n),
414
- file: t,
415
- id: e,
416
- status: "error"
417
- }));
418
- D.current(T.current.map((t) => t.id === e ? n : t));
419
- }
420
- function te(e, t) {
421
- h.has(e) ? We(t) : c?.(e);
422
- }
423
- let ne = !!u && !d, P = [...!d && !u ? [{
424
- label: J,
425
- type: "info"
426
- }] : [], ...p.filter((e) => e.status === "error").map((e) => ({
427
- label: `${e.file?.name ?? "檔案"}:${e.errorMessage ?? "上傳失敗"},未附加。請重試或刪除。`,
428
- type: "error"
429
- }))];
430
- return /* @__PURE__ */ S(y, {
431
- accept: t.acceptedMimeTypes?.join(","),
432
- disabled: !ne,
433
- files: w,
434
- ...P.length > 0 ? { hints: P } : {},
435
- maxFiles: t.maxFiles,
436
- mode: "button-list",
437
- ...(t.maxFiles ?? 1) > 1 ? { multiple: !0 } : {},
438
- onChange: O,
439
- onDownload: te,
440
- onReload: (e, t) => {
441
- ee(e, t);
442
- },
443
- onUpload: async (e) => Promise.all(e.map(async (e) => N(e).catch((t) => ({
444
- errorMessage: Ue(t),
445
- file: e,
446
- id: `failed-${e.name}-${e.lastModified}-${Math.random()}`,
447
- status: "error"
448
- })))),
449
- size: "sub"
450
- });
451
- }
452
- function Y(e, t) {
453
- return t ? {
454
- file: X(t),
455
- id: e,
456
- progress: 100,
457
- status: "done"
458
- } : {
459
- id: e,
460
- progress: 100,
461
- status: "done",
462
- url: Ve
463
- };
464
- }
465
- function X(e) {
466
- let t = new File([], e.filename), n = Number(e.sizeBytes);
467
- return Number.isFinite(n) && n >= 0 && Object.defineProperty(t, "size", { value: n }), t;
468
- }
469
- function Ue(e) {
470
- return e instanceof Error && e.message ? `上傳失敗:${e.message}` : "上傳失敗,請重試。";
471
- }
472
- function We(e) {
473
- let t = URL.createObjectURL(e), n = document.createElement("a");
474
- n.href = t, n.download = e.name, n.style.display = "none", document.body.appendChild(n), n.click(), n.remove(), setTimeout(() => URL.revokeObjectURL(t), 3e4);
475
- }
476
- // src/views/forms/renderer/form-field-link.ts
477
- var Ge = /\s/u;
478
- function Ke(e) {
479
- return [...e].some((e) => {
480
- let t = e.codePointAt(0) ?? 0;
481
- return t <= 32 || t >= 127 && t <= 160 || Ge.test(e);
482
- });
483
- }
484
- var qe = /^https?:\/\//iu;
485
- function Z(e) {
486
- return typeof e != "string" || !e || e.includes("\\") || Ke(e) ? null : e.startsWith("/") ? !e.startsWith("//") && Je(e) ? {
487
- external: !1,
488
- href: e
489
- } : null : qe.test(e) && Ye(e) ? {
490
- external: !0,
491
- href: e
492
- } : null;
493
- }
494
- var Q = "http://placeholder.invalid";
495
- function Je(e) {
496
- try {
497
- let t = new URL(e, Q);
498
- return t.origin === Q && !t.pathname.startsWith("//");
499
- } catch {
500
- return !1;
501
- }
502
- }
503
- function Ye(e) {
504
- try {
505
- let t = new URL(e);
506
- return (t.protocol === "http:" || t.protocol === "https:") && !!t.hostname && !t.username && !t.password;
507
- } catch {
508
- return !1;
509
- }
510
- }
511
- async function Xe(e, t, n = {}) {
512
- let r = n.maxPerIdRequests ?? 20, i = Math.max(1, n.concurrency ?? 4);
513
- try {
514
- return {
515
- failedIds: [],
516
- profiles: await t(e),
517
- skippedIds: []
518
- };
519
- } catch {
520
- if (e.length <= 1) return {
521
- failedIds: e,
522
- profiles: [],
523
- skippedIds: []
524
- };
525
- }
526
- let a = e.slice(0, r), o = await Qe(a, i, (e) => t([e]));
527
- return {
528
- failedIds: a.filter((e, t) => o[t].status === "rejected"),
529
- profiles: o.flatMap((e) => e.status === "fulfilled" ? e.value : []),
530
- skippedIds: e.slice(r)
531
- };
532
- }
533
- function Ze(e, t) {
534
- return e.filter((e) => !t.has(e));
535
- }
536
- async function Qe(e, t, n) {
537
- let r = [], i = 0;
538
- async function a() {
539
- for (; i < e.length;) {
540
- let t = i;
541
- i += 1, r[t] = await n(e[t]).then((e) => ({
542
- status: "fulfilled",
543
- value: e
544
- }), (e) => ({
545
- reason: e,
546
- status: "rejected"
547
- }));
548
- }
549
- }
550
- return await Promise.all(Array.from({ length: Math.min(t, e.length) }, a)), r;
551
- }
552
- // src/views/forms/renderer/member-field-options.ts
553
- var $e = "未知會員";
554
- function et(e) {
555
- return {
556
- id: e.memberId,
557
- name: t(e.name, e.email)
558
- };
559
- }
560
- function tt(e) {
561
- return {
562
- id: e,
563
- name: $e,
564
- unresolved: !0
565
- };
566
- }
567
- function nt(e, t) {
568
- 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);
569
- return i.length > 0 || a.some((t, n) => t !== e[n]) ? [...a, ...i] : e;
570
- }
571
- function rt(e, t) {
572
- let n = new Set(t.filter((e) => !e.unresolved).map((e) => e.id));
573
- return _e(e).filter((e) => !n.has(e));
574
- }
575
- function it(e, t) {
576
- return _e(e).map((e) => t.find((t) => t.id === e) ?? tt(e));
577
- }
578
- function at(e, t) {
579
- if (e.length !== 0) return t ? e.map((e) => e.id) : e[0]?.id;
580
- }
581
- // src/views/forms/renderer/member-field.tsx
582
- function ot({ multiple: e, name: t, onChange: n, placeholder: i, readonly: c, size: l, value: u }) {
583
- let [d, f] = o([]), [p, m] = o([]), [h, g] = o(!1), _ = a(0), v = a(/* @__PURE__ */ new Set()), y = rt(u, d).join("\n");
584
- r(() => {
585
- let e = Ze(y ? y.split("\n") : [], v.current), t = !1;
586
- return e.length === 0 ? () => void 0 : (Xe(e, b).then(({ profiles: n, skippedIds: r }) => {
587
- if (t) return;
588
- let i = n.map(et), a = e.filter((e) => !i.some((t) => t.id === e)).map(tt);
589
- a.filter((e) => !r.includes(e.id)).forEach((e) => v.current.add(e.id)), f((e) => nt(e, [...i, ...a]));
590
- }), () => {
591
- t = !0;
592
- });
593
- }, [y]);
594
- async function C(e) {
595
- let t = _.current + 1;
596
- _.current = t, g(!0);
597
- try {
598
- let n = (await x(e)).map(et);
599
- _.current === t && (m(n), f((e) => nt(e, n)));
600
- } catch {
601
- _.current === t && m([]);
602
- } finally {
603
- _.current === t && g(!1);
604
- }
605
- }
606
- let w = it(u, d), T = [...nt(w, p)], E = {
607
- asyncData: !0,
608
- clearSearchText: !0,
609
- disabled: c,
610
- disabledOptionsFilter: !0,
611
- emptyText: "沒有符合的成員",
612
- globalPortal: !0,
613
- inputProps: {
614
- autoCapitalize: "none",
615
- autoCorrect: "off",
616
- name: t,
617
- spellCheck: !1
618
- },
619
- loading: h,
620
- loadingText: "搜尋成員中...",
621
- menuMaxHeight: 320,
622
- onSearch: C,
623
- onVisibilityChange: (e) => {
624
- e && (m([]), C(""));
625
- },
626
- options: T,
627
- placeholder: i ?? "搜尋姓名或信箱",
628
- readOnly: c,
629
- searchDebounceTime: 300,
630
- size: l
631
- };
632
- return e ? /* @__PURE__ */ S(s, {
633
- ...E,
634
- mode: "multiple",
635
- onChange: (e) => n(at(e, !0)),
636
- value: [...w]
637
- }) : /* @__PURE__ */ S(s, {
638
- ...E,
639
- mode: "single",
640
- onChange: (e) => n(at(e ? [e] : [], !1)),
641
- value: w[0] ?? null
642
- });
643
- }
644
- // src/views/forms/renderer/org-unit-field-options.ts
645
- var st = "未知組織", ct = "(已刪除)";
646
- function lt(e) {
647
- return {
648
- id: e.id,
649
- name: e.deleted ? `${e.name}${ct}` : e.name
650
- };
651
- }
652
- function ut(e) {
653
- return {
654
- id: e,
655
- name: e,
656
- unresolved: !0
657
- };
658
- }
659
- function dt(e) {
660
- return {
661
- id: e,
662
- name: st,
663
- unresolved: !0
664
- };
665
- }
666
- function ft(e) {
667
- return typeof e == "string" && e.trim() ? e : null;
668
- }
669
- function $(e) {
670
- return e.toLowerCase();
671
- }
672
- function pt(e, t) {
673
- return $(e) === $(t);
674
- }
675
- function mt(e, t) {
676
- let n = ft(e);
677
- return n === null ? null : t.find((e) => pt(e.id, n)) ?? ut(n);
678
- }
679
- function ht(e, t) {
680
- let n = ft(e);
681
- return n !== null && !t.some((e) => pt(e.id, n)) ? n : null;
682
- }
683
- function gt(e, t) {
684
- 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) => pt(t.id, e.id)) === n), a = e.map((e) => (e.unresolved ? n.get($(e.id)) : void 0) ?? e);
685
- return i.length > 0 || a.some((t, n) => t !== e[n]) ? [...a, ...i] : e;
686
- }
687
- function _t(e) {
688
- return e ? e.id : void 0;
689
- }
690
- // src/views/forms/renderer/org-unit-field.tsx
691
- var vt = "搜尋組織失敗,請稍後再試。";
692
- function yt({ name: e, onChange: t, placeholder: n, readonly: i, size: c, value: l }) {
693
- let [u, d] = o([]), [f, p] = o([]), [m, h] = o(!1), [g, _] = o(!1), y = a(0), b = ht(l, u);
694
- r(() => {
695
- let e = !1;
696
- return b === null ? () => void 0 : (ve([b]).then((e) => {
697
- let t = e.map(lt);
698
- return t.some((e) => e.id.toLowerCase() === b.toLowerCase()) ? t : [...t, dt(b)];
699
- }).catch(() => [dt(b)]).then((t) => {
700
- e || d((e) => gt(e, t));
701
- }), () => {
702
- e = !0;
703
- });
704
- }, [b]);
705
- async function x(e) {
706
- let t = y.current + 1;
707
- y.current = t, h(!0);
708
- try {
709
- let n = (await ye(e)).map(lt);
710
- y.current === t && (p(n), _(!1), d((e) => gt(e, n)));
711
- } catch {
712
- y.current === t && (p([]), _(!0));
713
- } finally {
714
- y.current === t && h(!1);
715
- }
716
- }
717
- let w = mt(l, u), T = [...gt(w ? [w] : [], f)];
718
- return /* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S(s, {
719
- asyncData: !0,
720
- clearSearchText: !0,
721
- disabled: i,
722
- disabledOptionsFilter: !0,
723
- emptyText: "沒有符合的組織",
724
- globalPortal: !0,
725
- inputProps: {
726
- autoCapitalize: "none",
727
- autoCorrect: "off",
728
- name: e,
729
- spellCheck: !1
730
- },
731
- loading: m,
732
- loadingText: "搜尋組織中...",
733
- menuMaxHeight: 320,
734
- mode: "single",
735
- onChange: (e) => t(_t(e ?? null)),
736
- onSearch: x,
737
- onVisibilityChange: (e) => {
738
- e && (p([]), x(""));
739
- },
740
- options: T,
741
- placeholder: n ?? "搜尋組織名稱",
742
- readOnly: i,
743
- searchDebounceTime: 300,
744
- size: c,
745
- value: w
746
- }), g ? /* @__PURE__ */ S(v, {
747
- color: "text-error",
748
- variant: "caption",
749
- children: vt
750
- }) : null] });
751
- }
752
- // src/views/forms/renderer/FormRendererView.tsx
753
- var bt = {
754
- alignItems: "start",
755
- display: "grid",
756
- gap: 12,
757
- gridTemplateColumns: "repeat(12, minmax(0, 1fr))"
758
- }, xt = { gridColumn: "1 / -1" }, St = {
759
- alignItems: "start",
760
- display: "grid",
761
- gap: 8,
762
- minWidth: 0
763
- }, Ct = {
764
- minWidth: "100%",
765
- width: "100%"
766
- };
767
- function wt(e) {
768
- e && (e.style.width = "100%");
769
- }
770
- function Tt({ 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 }) {
771
- let T = i(() => ({
772
- attachments: e,
773
- onDownloadAttachment: m,
774
- onStateChange: h,
775
- onUploadAttachment: g
776
- }), [
777
- e,
778
- m,
779
- h,
780
- g
781
- ]), [D, O] = o(() => E(b.fields, w ?? {})), k = i(() => E(b.fields, w ?? D), [
782
- D,
783
- b.fields,
784
- w
785
- ]), A = a(k), j = i(() => B(b, C, k).filter((e) => Et(l, e.fieldKey)?.visible !== !1), [
786
- l,
787
- b,
788
- C,
789
- k
790
- ]);
791
- r(() => {
792
- A.current = k;
793
- }, [k]), r(() => {
794
- O((e) => E(b.fields, w ?? e));
795
- }, [b.fields, w]);
796
- function M(e, t) {
797
- let n = {
798
- ...A.current,
799
- [e]: t
800
- };
801
- A.current = n, w || O(n), f?.(n);
802
- }
803
- return j.length ? /* @__PURE__ */ S("div", {
804
- style: {
805
- ...bt,
806
- ...x ? { width: "100%" } : {}
807
- },
808
- children: j.map((e) => /* @__PURE__ */ S(Ot, {
809
- dataSourceContext: t,
810
- dataSourceInitialValues: n,
811
- field: e,
812
- error: c[e.fieldKey] ?? null,
813
- errors: c,
814
- fields: b.fields,
815
- labelMarker: u !== void 0 && Object.prototype.hasOwnProperty.call(u, e.fieldKey) ? u[e.fieldKey] : void 0,
816
- onChange: M,
817
- fileUpload: T,
818
- onDataSourceStateChange: p,
819
- optionSnapshots: _,
820
- readonly: Dt(Et(l, e.fieldKey), y),
821
- schema: b,
822
- style: {
823
- ...St,
824
- gridColumn: `span ${x ? 12 : qt(e, C)}`,
825
- ...x && !H(e) ? { maxWidth: d } : {}
826
- },
827
- value: k[e.fieldKey],
828
- values: k,
829
- uiSchema: C
830
- }, e.fieldKey))
831
- }) : /* @__PURE__ */ S("div", {
832
- style: bt,
833
- children: /* @__PURE__ */ S(v, {
834
- color: "text-neutral",
835
- style: xt,
836
- variant: "body",
837
- children: b.fields.length > 0 ? "目前條件下沒有可填寫欄位。" : s
838
- })
839
- });
840
- }
841
- function Et(e, t) {
842
- return e !== void 0 && Object.prototype.hasOwnProperty.call(e, t) ? e[t] : void 0;
843
- }
844
- function Dt(e, t) {
845
- return e === void 0 ? t : !e.editable;
846
- }
847
- function Ot({ 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 }) {
848
- let x = M(o, s, y), w = m || j(o, s, y), T = W({
849
- context: t,
850
- field: o,
851
- formData: y,
852
- initialFormData: n,
853
- initialValue: n?.[o.fieldKey],
854
- optionSnapshots: p,
855
- readonly: w,
856
- schema: h,
857
- uiSchema: b
858
- }), E = je(T), D = JSON.stringify({
859
- hasValue: T.hasValue,
860
- invalidValues: T.invalidValues,
861
- selectionExpired: T.selectionExpired === !0,
862
- status: T.status
863
- });
864
- return r(() => {
865
- pe(o) && f?.(o.fieldKey, {
866
- hasValue: T.hasValue,
867
- invalidValues: T.invalidValues,
868
- selectionExpired: T.selectionExpired === !0,
869
- status: T.status
870
- });
871
- }, [
872
- D,
873
- o.fieldKey,
874
- f
875
- ]), /* @__PURE__ */ C("div", {
876
- "data-form-field-key": o.fieldKey,
877
- style: g,
878
- children: [
879
- /* @__PURE__ */ S(e, {
880
- label: o.label,
881
- ...u ? { labelOptionalMarker: u } : {},
882
- ...H(o) ? It : {},
883
- name: o.fieldKey,
884
- required: x,
885
- children: H(o) ? /* @__PURE__ */ S(Rt, {
886
- dataSourceContext: t,
887
- dataSourceInitialValues: n,
888
- errors: a,
889
- field: o,
890
- onChange: d,
891
- onDataSourceStateChange: f,
892
- optionSnapshots: p,
893
- readonly: w,
894
- schema: h,
895
- uiSchema: b,
896
- value: _,
897
- values: y
898
- }) : Wt(o, _, w, d, l, t, T)
899
- }),
900
- i ? /* @__PURE__ */ S(v, {
901
- color: "text-error",
902
- variant: "caption",
903
- children: i
904
- }) : null,
905
- E ? /* @__PURE__ */ C("div", {
906
- style: Mt,
907
- children: [/* @__PURE__ */ S(v, {
908
- color: T.status === "INVALID" || T.status === "UNAVAILABLE" ? "text-error" : "text-neutral",
909
- variant: "caption",
910
- children: E
911
- }), T.status === "UNAVAILABLE" && T.canRetry ? /* @__PURE__ */ S(c, {
912
- onClick: T.retry,
913
- size: "sub",
914
- type: "button",
915
- variant: "base-ghost",
916
- children: "重試"
917
- }) : null]
918
- }) : null
919
- ]
920
- });
921
- }
922
- var kt = "(另開新分頁)", At = "另開新分頁", jt = {
923
- color: "inherit",
924
- textDecoration: "underline",
925
- wordBreak: "break-all"
926
- }, Mt = {
927
- alignItems: "center",
928
- display: "flex",
929
- gap: 8
930
- }, Nt = {
931
- display: "grid",
932
- gap: 8,
933
- minWidth: 0,
934
- width: "100%"
935
- }, Pt = {
936
- display: "flex",
937
- justifyContent: "flex-start"
938
- }, Ft = 160, It = {
939
- density: w.BASE,
940
- layout: T.STRETCH
941
- }, Lt = {
942
- display: "grid",
943
- gap: 4,
944
- minWidth: 0
945
- };
946
- function Rt({ dataSourceContext: e, dataSourceInitialValues: t, errors: n, field: i, onChange: s, onDataSourceStateChange: l, optionSnapshots: u, readonly: d, schema: f, uiSchema: p, value: m, values: g }) {
947
- let _ = L(m), v = ce(i), y = a(0), [b, x] = o(() => _.map(() => Vt(y)));
948
- r(() => {
949
- b.length !== _.length && x(_.map(() => Vt(y)));
950
- }, [b.length, _.length]);
951
- function w(e) {
952
- s(i.fieldKey, e);
953
- }
954
- function T() {
955
- x([...b, Vt(y)]), w([..._, O(i.columns)]);
956
- }
957
- function E(e) {
958
- x(b.filter((t, n) => n !== e)), w(_.filter((t, n) => n !== e));
959
- }
960
- function D(e, t, n) {
961
- w(_.map((r, i) => i === e ? Ht(r, t, n) : r));
962
- }
963
- let k = _.map((e, t) => ({
964
- ...e,
965
- index: t,
966
- key: b[t] ?? `row-${t}`
967
- })), A = i.columns.map((r) => ({
968
- key: r.fieldKey,
969
- minWidth: Ft,
970
- render: (a) => /* @__PURE__ */ S(zt, {
971
- column: r,
972
- dataSourceContext: e,
973
- error: n[se(i.fieldKey, a.index, r.fieldKey)] ?? null,
974
- fieldPath: `${i.fieldKey}.${r.fieldKey}`,
975
- formData: g,
976
- initialFormData: t,
977
- initialRowValues: Bt(t?.[i.fieldKey], a.index),
978
- onChange: (e) => D(a.index, r.fieldKey, e),
979
- onDataSourceStateChange: l,
980
- optionSnapshots: u,
981
- path: se(i.fieldKey, a.index, r.fieldKey),
982
- readonly: d,
983
- rowValues: _[a.index] ?? {},
984
- schema: f,
985
- uiSchema: p
986
- }, `${b[a.index] ?? a.index}-${r.fieldKey}`),
987
- title: r.label || r.fieldKey
988
- })), j = d ? void 0 : {
989
- render: (e) => [{
990
- disabled: () => _.length <= v.minRows,
991
- icon: fe,
992
- iconType: "icon-only",
993
- name: "刪除此列",
994
- onClick: () => E(e.index),
995
- variant: "destructive-ghost"
996
- }],
997
- fixed: "end",
998
- width: 56
999
- };
1000
- return /* @__PURE__ */ C("div", {
1001
- style: Nt,
1002
- children: [/* @__PURE__ */ S(h, {
1003
- ...j ? { actions: j } : {},
1004
- columns: A,
1005
- dataSource: [...k],
1006
- rowHeightPreset: "roomy",
1007
- showHeader: !0,
1008
- size: "sub"
1009
- }), d ? null : /* @__PURE__ */ S("div", {
1010
- style: Pt,
1011
- children: /* @__PURE__ */ S(c, {
1012
- disabled: _.length >= v.maxRows,
1013
- icon: V,
1014
- iconType: "leading",
1015
- onClick: T,
1016
- size: "sub",
1017
- type: "button",
1018
- variant: "base-secondary",
1019
- children: i.addRowLabel || "新增一列"
1020
- })
1021
- })]
1022
- });
1023
- }
1024
- function zt({ 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 }) {
1025
- let _ = Ut(m, e.fieldKey), y = W({
1026
- context: t,
1027
- field: e,
1028
- fieldPath: i,
1029
- formData: a,
1030
- initialFormData: o,
1031
- initialValue: s ? Ut(s, e.fieldKey) : void 0,
1032
- optionSnapshots: d,
1033
- readonly: p,
1034
- row: {
1035
- initialValues: s,
1036
- values: m
1037
- },
1038
- schema: h,
1039
- snapshotKey: f,
1040
- uiSchema: g
1041
- }), b = je(y), x = JSON.stringify({
1042
- hasValue: y.hasValue,
1043
- invalidValues: y.invalidValues,
1044
- selectionExpired: y.selectionExpired === !0,
1045
- status: y.status
1046
- });
1047
- return r(() => {
1048
- if (pe(e)) return u?.(f, {
1049
- hasValue: y.hasValue,
1050
- invalidValues: y.invalidValues,
1051
- selectionExpired: y.selectionExpired === !0,
1052
- status: y.status
1053
- }), () => {
1054
- u?.(f, {
1055
- hasValue: !1,
1056
- invalidValues: [],
1057
- status: "IDLE"
1058
- });
1059
- };
1060
- }, [
1061
- u,
1062
- f,
1063
- x
1064
- ]), /* @__PURE__ */ C("div", {
1065
- "data-form-field-key": f,
1066
- style: Lt,
1067
- children: [
1068
- Wt(e, _, p, (e, t) => l(t), void 0, t, y, "sub"),
1069
- n ? /* @__PURE__ */ S(v, {
1070
- color: "text-error",
1071
- variant: "caption",
1072
- children: n
1073
- }) : null,
1074
- b ? /* @__PURE__ */ C("div", {
1075
- style: Mt,
1076
- children: [/* @__PURE__ */ S(v, {
1077
- color: y.status === "INVALID" || y.status === "UNAVAILABLE" ? "text-error" : "text-neutral",
1078
- variant: "caption",
1079
- children: b
1080
- }), y.status === "UNAVAILABLE" && y.canRetry ? /* @__PURE__ */ S(c, {
1081
- onClick: y.retry,
1082
- size: "sub",
1083
- type: "button",
1084
- variant: "base-ghost",
1085
- children: "重試"
1086
- }) : null]
1087
- }) : null
1088
- ]
1089
- });
1090
- }
1091
- function Bt(e, t) {
1092
- return L(e)[t];
1093
- }
1094
- function Vt(e) {
1095
- return e.current += 1, `table-row-${e.current}`;
1096
- }
1097
- function Ht(e, t, n) {
1098
- return n === void 0 || !he(n) ? Object.fromEntries(Object.entries(e).filter(([e]) => e !== t)) : {
1099
- ...e,
1100
- [t]: n
1101
- };
1102
- }
1103
- function Ut(e, t) {
1104
- if (e && Object.prototype.hasOwnProperty.call(e, t)) return e[t];
1105
- }
1106
- function Wt(e, t, n, r, i, a, o, s = "main") {
1107
- return pe(e) ? Kt(e, t, n, r, a, o, s) : Gt(e, t, n, r, i, s);
1108
- }
1109
- function Gt(e, t, n, r, i, a = "main") {
1110
- let o = n && (e.type === "text" || e.type === "textarea") && e.displayAs === "link" ? Z(t) : null;
1111
- if (o) return /* @__PURE__ */ S(v, {
1112
- color: "text-brand",
1113
- component: "span",
1114
- variant: "body",
1115
- children: /* @__PURE__ */ S("a", {
1116
- href: o.href,
1117
- style: jt,
1118
- ...o.external ? {
1119
- "aria-label": `${o.href}${kt}`,
1120
- rel: "noopener noreferrer",
1121
- target: "_blank",
1122
- title: At
1123
- } : {},
1124
- children: o.href
1125
- })
1126
- });
1127
- if (e.type === "textarea") return /* @__PURE__ */ S(g, {
1128
- onChange: (t) => r(e.fieldKey, t.target.value),
1129
- placeholder: e.placeholder ?? "請輸入多行文字",
1130
- readOnly: n,
1131
- ref: wt,
1132
- rows: 3,
1133
- style: Ct,
1134
- value: Jt(t)
1135
- });
1136
- if (e.type === "boolean") return /* @__PURE__ */ S(_, {
1137
- checked: t === !0,
1138
- disabled: n,
1139
- label: "啟用",
1140
- onChange: (t) => r(e.fieldKey, t.target.checked),
1141
- size: a
1142
- });
1143
- if (me(e) && e.type === "checkbox") {
1144
- let i = e.options.map(F);
1145
- return /* @__PURE__ */ S(m, {
1146
- menuMaxHeight: 320,
1147
- mode: "multiple",
1148
- onChange: (t) => r(e.fieldKey, t?.length ? t.map((e) => e.id) : void 0),
1149
- options: i,
1150
- placeholder: e.placeholder ?? "請選擇一或多個選項",
1151
- readOnly: n,
1152
- size: a,
1153
- value: i.filter((e) => K(t).includes(e.id))
1154
- });
1155
- }
1156
- if (me(e)) {
1157
- let i = e.options.map(F);
1158
- return /* @__PURE__ */ S(m, {
1159
- menuMaxHeight: 320,
1160
- onChange: (t) => r(e.fieldKey, t?.id ?? void 0),
1161
- options: i,
1162
- placeholder: e.placeholder ?? "請選擇",
1163
- readOnly: n,
1164
- size: a,
1165
- value: z(i, Jt(t))
1166
- });
1167
- }
1168
- return e.type === "member" ? /* @__PURE__ */ S(ot, {
1169
- multiple: e.multiple === !0,
1170
- name: e.fieldKey,
1171
- onChange: (t) => r(e.fieldKey, t),
1172
- placeholder: e.placeholder,
1173
- readonly: n,
1174
- size: a,
1175
- value: t
1176
- }) : e.type === "org_unit" ? /* @__PURE__ */ S(yt, {
1177
- name: e.fieldKey,
1178
- onChange: (t) => r(e.fieldKey, t),
1179
- placeholder: e.placeholder ?? Xt(e.type),
1180
- readonly: n,
1181
- size: a,
1182
- value: t
1183
- }) : e.type === "file_upload" ? /* @__PURE__ */ S(He, {
1184
- attachments: i?.attachments,
1185
- field: e,
1186
- onChange: (t) => r(e.fieldKey, t),
1187
- onDownloadAttachment: i?.onDownloadAttachment,
1188
- onStateChange: (t) => i?.onStateChange?.(e.fieldKey, t),
1189
- onUploadAttachment: i?.onUploadAttachment,
1190
- readonly: n,
1191
- value: t
1192
- }) : e.type === "date" ? /* @__PURE__ */ S(u, {
1193
- format: "YYYY-MM-DD",
1194
- fullWidth: !0,
1195
- onChange: (t) => r(e.fieldKey, k(t)),
1196
- placeholder: e.placeholder ?? Xt(e.type),
1197
- readOnly: n,
1198
- value: P(t)
1199
- }) : e.type === "datetime" ? /* @__PURE__ */ S(d, {
1200
- formatDate: "YYYY-MM-DD",
1201
- formatTime: "HH:mm",
1202
- fullWidth: !0,
1203
- hideSecond: !0,
1204
- onChange: (t) => r(e.fieldKey, A(t)),
1205
- placeholderLeft: "選擇日期",
1206
- placeholderRight: "選擇時間",
1207
- readOnly: n,
1208
- value: P(t)
1209
- }) : e.type === "number" || e.type === "money" ? /* @__PURE__ */ S(f, {
1210
- fullWidth: !0,
1211
- max: e.maximum,
1212
- min: e.minimum,
1213
- size: a,
1214
- onChange: (t) => r(e.fieldKey, D(ee(t.target.value), {
1215
- max: e.maximum,
1216
- min: e.minimum
1217
- })),
1218
- placeholder: e.placeholder ?? Xt(e.type),
1219
- ...n ? { readonly: !0 } : {},
1220
- showSpinner: !0,
1221
- value: Yt(t),
1222
- variant: "measure"
1223
- }) : /* @__PURE__ */ S(f, {
1224
- fullWidth: !0,
1225
- onChange: (t) => r(e.fieldKey, t.target.value),
1226
- placeholder: e.placeholder ?? Xt(e.type),
1227
- ...n ? { readonly: !0 } : {},
1228
- size: a,
1229
- value: Jt(t),
1230
- variant: "base"
1231
- });
1232
- }
1233
- function Kt(e, t, n, r, i, a, o = "main") {
1234
- let c = a.options.map(F), u = ue(t, a.options).map(F), d = a.status === "LOADING", f = d && !a.loadingNextPage, h = a.status === "WAITING_FOR_DEPENDENCIES", g = !!i && !n, _ = n || h, v = n;
1235
- return e.type === "autocomplete" ? ge(e) === "multiple" ? /* @__PURE__ */ S(s, {
1236
- asyncData: g,
1237
- clearSearchText: !0,
1238
- disabled: v,
1239
- disabledOptionsFilter: g,
1240
- globalPortal: !0,
1241
- loading: f,
1242
- menuMaxHeight: 320,
1243
- mode: "multiple",
1244
- onChange: (t) => r(e.fieldKey, t.length ? t.map((e) => e.id) : void 0),
1245
- onReachBottom: a.onReachBottom,
1246
- onSearch: g ? a.onSearch : void 0,
1247
- onVisibilityChange: (e) => {
1248
- e && g && a.onOpen();
1249
- },
1250
- options: c,
1251
- placeholder: e.placeholder ?? "請輸入或選擇",
1252
- readOnly: n,
1253
- searchDebounceTime: 300,
1254
- size: o,
1255
- value: u
1256
- }) : /* @__PURE__ */ S(s, {
1257
- asyncData: g,
1258
- clearSearchText: !0,
1259
- disabled: v,
1260
- disabledOptionsFilter: g,
1261
- globalPortal: !0,
1262
- loading: f,
1263
- menuMaxHeight: 320,
1264
- mode: "single",
1265
- onChange: (t) => r(e.fieldKey, t?.id ?? void 0),
1266
- onReachBottom: a.onReachBottom,
1267
- onSearch: g ? a.onSearch : void 0,
1268
- onVisibilityChange: (e) => {
1269
- e && g && a.onOpen();
1270
- },
1271
- options: c,
1272
- placeholder: e.placeholder ?? "請輸入或選擇",
1273
- readOnly: n,
1274
- searchDebounceTime: 300,
1275
- size: o,
1276
- value: u[0] ?? null
1277
- }) : e.type === "radio" ? /* @__PURE__ */ S(p, {
1278
- disabled: _,
1279
- name: e.fieldKey,
1280
- onChange: (t) => r(e.fieldKey, t.target.value || void 0),
1281
- options: c,
1282
- value: Jt(t)
1283
- }) : e.type === "checkbox" ? /* @__PURE__ */ S(l, {
1284
- disabled: _,
1285
- name: e.fieldKey,
1286
- onChange: (t) => r(e.fieldKey, t.target.values.length ? t.target.values : void 0),
1287
- options: c.map((e) => ({
1288
- label: e.name,
1289
- value: e.id
1290
- })),
1291
- value: [...K(t)]
1292
- }) : ge(e) === "multiple" ? /* @__PURE__ */ S(m, {
1293
- disabled: _,
1294
- loading: d,
1295
- menuMaxHeight: 320,
1296
- mode: "multiple",
1297
- onChange: (t) => r(e.fieldKey, t.length ? t.map((e) => e.id) : void 0),
1298
- onReachBottom: a.onReachBottom,
1299
- options: c,
1300
- placeholder: e.placeholder ?? "請選擇一或多個選項",
1301
- readOnly: n,
1302
- size: o,
1303
- value: u
1304
- }) : /* @__PURE__ */ S(m, {
1305
- disabled: _,
1306
- loading: d,
1307
- menuMaxHeight: 320,
1308
- onChange: (t) => r(e.fieldKey, t?.id ?? void 0),
1309
- onReachBottom: a.onReachBottom,
1310
- options: c,
1311
- placeholder: e.placeholder ?? "請選擇",
1312
- readOnly: n,
1313
- size: o,
1314
- value: u[0] ?? null
1315
- });
1316
- }
1317
- function qt(e, t) {
1318
- return {
1319
- FULL: 12,
1320
- HALF: 6,
1321
- THIRD: 4
1322
- }[t.layout.find((t) => t.fieldKey === e.fieldKey)?.width ?? "FULL"];
1323
- }
1324
- function Jt(e) {
1325
- return typeof e == "string" ? e : "";
1326
- }
1327
- function Yt(e) {
1328
- return typeof e == "number" ? String(e) : "";
1329
- }
1330
- function Xt(e) {
1331
- return {
1332
- boolean: "",
1333
- autocomplete: "請輸入或選擇",
1334
- checkbox: "請選擇一或多個選項",
1335
- date: "請選擇日期",
1336
- datetime: "請選擇日期與時間",
1337
- file_upload: "請上傳附件",
1338
- member: "搜尋姓名或信箱",
1339
- money: "請輸入金額",
1340
- number: "請輸入數字",
1341
- org_unit: "搜尋組織名稱",
1342
- radio: "請選擇一個選項",
1343
- select: "請選擇一個選項",
1344
- table: "",
1345
- text: "請輸入文字",
1346
- textarea: "請輸入多行文字"
1347
- }[e];
1348
- }
1349
- export { q as a, je as c, Xe as i, Me as l, lt as n, Be as o, Ze as r, G as s, Tt as t, W as u };
1350
-
1351
- //# sourceMappingURL=FormRendererView-CAyPXhPq.js.map