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