@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
package/CHANGELOG.md CHANGED
@@ -1,3 +1,87 @@
1
+ ## 0.24.0 (2026-11-14)
2
+
3
+ ### 🚀 Features
4
+
5
+ - **bpm-core-react:** page the stuck instances table ([d79a7d10](https://github.com/Rytass/BPMCore/commit/d79a7d10))
6
+ - **bpm-core:** page the stuck approval instance list ([6cd50975](https://github.com/Rytass/BPMCore/commit/6cd50975))
7
+ - **bpm-core-react:** mount the stuck approval instances page like the other admin pages ([fc19c298](https://github.com/Rytass/BPMCore/commit/fc19c298))
8
+ - **bpm-core-react:** show administrators the stuck approval instances and let them cancel one ([0e76e1b6](https://github.com/Rytass/BPMCore/commit/0e76e1b6))
9
+ - **bpm-core-react:** let an administrator pick which tasks of a member to reassign ([a25132fa](https://github.com/Rytass/BPMCore/commit/a25132fa))
10
+ - let reassignMemberTasks take an optional list of task ids ([4b3c22a1](https://github.com/Rytass/BPMCore/commit/4b3c22a1))
11
+ - **bpm-core-react:** let the designer continue a manager chain or skip it when its start already qualifies ([3ca960f1](https://github.com/Rytass/BPMCore/commit/3ca960f1))
12
+
13
+ ### 🩹 Fixes
14
+
15
+ - **admin-stuck-instances:** clear the rows when a page fails to load ([552754a6](https://github.com/Rytass/BPMCore/commit/552754a6))
16
+ - **admin-stuck-instances:** send one cancellation for a double press ([8c0fddce](https://github.com/Rytass/BPMCore/commit/8c0fddce))
17
+ - **admin-users:** drop a reassignment answer once another member is shown ([acbc8a66](https://github.com/Rytass/BPMCore/commit/acbc8a66))
18
+ - **bpm-core:** tell the initiator of an administrator cancel only after it commits ([2fca97e7](https://github.com/Rytass/BPMCore/commit/2fca97e7))
19
+ - **bpm-core-react:** keep the administrator's selection when the reassign list reloads ([0bb6f9cd](https://github.com/Rytass/BPMCore/commit/0bb6f9cd))
20
+ - **bpm-core-react:** type the stuck instances page against the member profile resolveMembers returns ([e613adad](https://github.com/Rytass/BPMCore/commit/e613adad))
21
+ - **bpm-core:** export the administrator cancel input like the other workflow inputs ([988981ae](https://github.com/Rytass/BPMCore/commit/988981ae))
22
+ - **bpm-core-react:** name the not-a-continuation condition in the no continuable chain hint ([971579ff](https://github.com/Rytass/BPMCore/commit/971579ff))
23
+ - **bpm-core-react:** keep the skip toggle usable when a continuation stores a non-boolean flag ([c6882875](https://github.com/Rytass/BPMCore/commit/c6882875))
24
+
25
+ ### 🔥 Performance
26
+
27
+ - **workflow-engine:** index the ADVANCE_FAILED rows the stuck list reads ([2cf16d8d](https://github.com/Rytass/BPMCore/commit/2cf16d8d))
28
+
29
+ ### ❤️ Thank You
30
+
31
+ - Chia Yu Pai @fantasywind
32
+ - Kai-Chieh Yang
33
+
34
+ ## 0.23.0 (2026-11-14)
35
+
36
+ ### 🚀 Features
37
+
38
+ - **form-data-source:** locate approver-fill VALUE_NOT_RESOLVED on its field or cell ([1a17907a](https://github.com/Rytass/BPMCore/commit/1a17907a))
39
+ - **bpm-core-react:** edit per-column fill under table rows in field access drawer ([948dca5f](https://github.com/Rytass/BPMCore/commit/948dca5f))
40
+ - **bpm-core-react:** add per-column fill labels for field access matrix ([9c9b23e6](https://github.com/Rytass/BPMCore/commit/9c9b23e6))
41
+ - **bpm-core-react:** show column-mode labels and per-column fill counts ([8564d50a](https://github.com/Rytass/BPMCore/commit/8564d50a))
42
+ - **bpm-core-react:** lock table rows and surface fill error codes ([bf0cbc0a](https://github.com/Rytass/BPMCore/commit/bf0cbc0a))
43
+ - **bpm-core-client:** expose host error code on BPMGraphQLRequestError ([3a388721](https://github.com/Rytass/BPMCore/commit/3a388721))
44
+ - **bpm-core-react:** pass column-mode table access to approver fill ([c4fcb87d](https://github.com/Rytass/BPMCore/commit/c4fcb87d))
45
+ - **bpm-core-react:** add per-table access to form renderer ([98cd5208](https://github.com/Rytass/BPMCore/commit/98cd5208))
46
+ - **bpm-core-react:** support column-mode approver fill helpers ([b1229c6a](https://github.com/Rytass/BPMCore/commit/b1229c6a))
47
+ - **field-access:** reject publish when a table dependent column is not opened ([a4f64372](https://github.com/Rytass/BPMCore/commit/a4f64372))
48
+ - **field-access:** export dependency break helper for column fills ([d25212c6](https://github.com/Rytass/BPMCore/commit/d25212c6))
49
+ - **field-access:** lint per-column fill conflicts and approver data sources ([2d081bb2](https://github.com/Rytass/BPMCore/commit/2d081bb2))
50
+ - **field-access:** read per-column fill units for table fields ([996bffcc](https://github.com/Rytass/BPMCore/commit/996bffcc))
51
+ - **workflow-engine:** expose recordTaskAutoDecisionFailed on the engine token ([40d69180](https://github.com/Rytass/BPMCore/commit/40d69180))
52
+ - **instance-event:** expose admin list and retry resolvers ([4cbb84ac](https://github.com/Rytass/BPMCore/commit/4cbb84ac))
53
+ - **instance-event:** purge delivered rows past retention ([69d19f9a](https://github.com/Rytass/BPMCore/commit/69d19f9a))
54
+ - **instance-event:** schedule periodic delivery scans ([ac9b7dc3](https://github.com/Rytass/BPMCore/commit/ac9b7dc3))
55
+ - **instance-event:** deliver on commit via subscriber ([53641feb](https://github.com/Rytass/BPMCore/commit/53641feb))
56
+ - **instance-event:** add outbox delivery service ([b7ddcd3f](https://github.com/Rytass/BPMCore/commit/b7ddcd3f))
57
+ - **instance-event:** add outbox event writer ([fd891be4](https://github.com/Rytass/BPMCore/commit/fd891be4))
58
+ - **instance-event:** add lifecycle event outbox and observer wiring ([74dcdffd](https://github.com/Rytass/BPMCore/commit/74dcdffd))
59
+ - **workflow-engine:** add pre-decision host guard for submit, resubmit and decide ([8d450dd3](https://github.com/Rytass/BPMCore/commit/8d450dd3))
60
+ - **form:** add HOST_RULE issue reason with optional host code ([3d58779d](https://github.com/Rytass/BPMCore/commit/3d58779d))
61
+ - **designer:** carry launch mode through the compose wizard ([e9a246e1](https://github.com/Rytass/BPMCore/commit/e9a246e1))
62
+ - **designer:** add 發起方式 control and send launch mode ([6dfd6982](https://github.com/Rytass/BPMCore/commit/6dfd6982))
63
+ - **designer:** add launch mode options and helpers ([e8e91ec5](https://github.com/Rytass/BPMCore/commit/e8e91ec5))
64
+ - **form:** warn when a publish leaves a dynamic default unresolved ([27c42583](https://github.com/Rytass/BPMCore/commit/27c42583))
65
+ - **form:** let dynamic source fields keep a fixed default ([d931ec64](https://github.com/Rytass/BPMCore/commit/d931ec64))
66
+ - **form:** resolve untouched dynamic defaults on render ([61f1aa07](https://github.com/Rytass/BPMCore/commit/61f1aa07))
67
+ - **bpm-core-react:** drop the boolean REQUIRED note from the matrix drawer ([39e0c4d6](https://github.com/Rytass/BPMCore/commit/39e0c4d6))
68
+ - **instances:** filter approval instances by template key ([18d496c7](https://github.com/Rytass/BPMCore/commit/18d496c7))
69
+ - **conditions:** optionally read unfilled form fields as null ([958d3be6](https://github.com/Rytass/BPMCore/commit/958d3be6))
70
+ - **template:** add a HOST_ONLY launch mode to template versions ([d83db05e](https://github.com/Rytass/BPMCore/commit/d83db05e))
71
+ - **initiator:** let a host add customFields to the built snapshot ([609bc5ab](https://github.com/Rytass/BPMCore/commit/609bc5ab))
72
+ - **inbox:** filter inbox and approval history by template ([6870883a](https://github.com/Rytass/BPMCore/commit/6870883a))
73
+ - **migrations:** add the host integration round schema ([34eef9b2](https://github.com/Rytass/BPMCore/commit/34eef9b2))
74
+
75
+ ### 🩹 Fixes
76
+
77
+ - **workflow-engine:** report only changed keys to the resubmit guard ([53d7bdb2](https://github.com/Rytass/BPMCore/commit/53d7bdb2))
78
+ - **bpm-core-react:** use grant units for fill labels and visibility ([0ff2e6ab](https://github.com/Rytass/BPMCore/commit/0ff2e6ab))
79
+ - **bpm-core-react:** send untouched required boolean fill values ([4713526e](https://github.com/Rytass/BPMCore/commit/4713526e))
80
+
81
+ ### ❤️ Thank You
82
+
83
+ - Chia Yu Pai @fantasywind
84
+
1
85
  ## 0.22.0 (2026-11-13)
2
86
 
3
87
  ### 🚀 Features
package/README.md CHANGED
@@ -272,6 +272,7 @@ function createPrefixedRoutes(prefix: string): BPMRoutes {
272
272
  adminUsers: () => `${trim}/admin/users`,
273
273
  adminDelegations: () => `${trim}/admin/delegations`,
274
274
  adminWebhookEndpoints: () => `${trim}/admin/webhook-endpoints`,
275
+ adminStuckInstances: () => `${trim}/admin/stuck-instances`,
275
276
  };
276
277
  }
277
278
 
@@ -0,0 +1,4 @@
1
+ "use client";const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./bpm-form-field-Bc6k4ZEO.cjs"),n=require("./FormRendererView-D-p6GDQB.cjs");let r=require("react"),i=require("@mezzanine-ui/react"),a=require("react/jsx-runtime"),o=require("@rytass/bpm-core-client/workflow"),s=require("@rytass/bpm-core-shared"),c=require("@mezzanine-ui/core/form"),l=require("@rytass/bpm-core-client/template"),u=require("@rytass/bpm-core-client/form"),d=require("@mezzanine-ui/icons"),f=require("@rytass/bpm-core-shared/form"),p=require("@hello-pangea/dnd"),m=require("next/dynamic");m=e.t(m,1);let h=require("@codemirror/lang-json"),g=require("@codemirror/view");var ee={alignItems:`center`,border:`1px solid var(--mzn-color-border-neutral)`,borderRadius:4,color:`var(--mzn-color-text-neutral)`,display:`flex`,minHeight:160,padding:12,width:`100%`},_=[(0,h.json)(),g.EditorView.lineWrapping,g.EditorView.theme({"&":{border:`1px solid var(--mzn-color-border-neutral)`,borderRadius:`4px`,fontSize:`13px`,width:`100%`},"&.cm-focused":{outline:`1px solid var(--mzn-color-border-primary)`},".cm-content":{fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace`,minHeight:`100%`},".cm-editor":{width:`100%`},".cm-gutters":{borderRight:`1px solid var(--mzn-color-border-neutral)`},".cm-scroller":{fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace`}})],v=(0,m.default)(()=>import(`@uiw/react-codemirror`),{loading:()=>(0,a.jsx)(`div`,{style:ee,children:`載入 JSON 編輯器`}),ssr:!1});function te({disabled:e=!1,height:t,name:n,onChange:r,placeholder:i,value:o}){return(0,a.jsx)(v,{"aria-label":n,basicSetup:{autocompletion:!0,bracketMatching:!0,closeBrackets:!0,defaultKeymap:!0,foldGutter:!0,highlightActiveLine:!0,highlightSelectionMatches:!0,lineNumbers:!0,syntaxHighlighting:!0},editable:!e,extensions:[..._],height:t,indentWithTab:!1,onChange:r,placeholder:i,readOnly:e,theme:`light`,value:o,width:`100%`})}var y=`選項來源改為依賴其他欄位的值後,目前的預設值會被清除,之後由使用者在表單中自行選擇。`,ne=[{description:`單行文字、姓名、編號`,icon:d.AlignLeftIcon,label:`文字`,type:`text`},{description:`多行補充內容`,icon:d.FileIcon,label:`長文字`,type:`textarea`},{description:`金額、數量、分數`,icon:d.CurrencyDollarIcon,label:`數字`,type:`number`},{description:`金額與費用`,icon:d.CurrencyDollarIcon,label:`金額`,type:`money`},{description:`日期或到期日`,icon:d.CalendarIcon,label:`日期`,type:`date`},{description:`日期與時間`,icon:d.CalendarIcon,label:`日期時間`,type:`datetime`},{description:`是 / 否狀態`,icon:d.CheckedIcon,label:`開關`,type:`boolean`},{description:`固定選項擇一`,icon:d.ListIcon,label:`下拉選單`,type:`select`},{description:`可搜尋的固定選項`,icon:d.ListIcon,label:`自動完成`,type:`autocomplete`},{description:`固定選項單選`,icon:d.DotGridIcon,label:`單選`,type:`radio`},{description:`固定選項複選`,icon:d.CheckedOutlineIcon,label:`複選`,type:`checkbox`},{description:`附件或佐證資料`,icon:d.FileAttachmentIcon,label:`附件`,type:`file_upload`},{description:`從成員名單挑選一或多位人員`,icon:d.UserIcon,label:`人員選擇`,type:`member`},{description:`從組織圖挑選一個組織`,icon:d.FolderIcon,label:`組織選擇`,type:`org_unit`},{description:`多列多欄明細`,icon:d.DotGridIcon,label:`表格`,type:`table`}],b=ne.filter(e=>(0,f.isTableColumnFieldType)(e.type)).map(e=>({id:e.type,name:e.label})),re={alignItems:`start`,display:`flex`,flexWrap:`wrap`,gap:16},ie={flex:`0.55 1 300px`,minWidth:0},ae={flex:`1.45 1 720px`,minWidth:620,paddingBottom:260},oe=240,se={BOOLEAN:`開關`,NUMBER:`數字`,STRING:`文字或選單`,STRING_ARRAY:`多選`},ce=/^schema\.fields\[(\d+)\](?:\.columns\[(\d+)\])?\.dataSource\.bindings missing required parameter: (.+)$/u,le=/^schema\.fields\[(\d+)\](?:\.columns\[(\d+)\])?\.dataSource\.bindings unknown parameter: (.+)$/u,x={display:`grid`,gap:12},ue={display:`flex`,flexWrap:`wrap`,gap:6},de={flex:`0 0 auto`,whiteSpace:`nowrap`},fe={display:`grid`,gap:8},pe={alignItems:`center`,cursor:`grab`,display:`flex`,gap:12,touchAction:`none`},me={display:`grid`,flex:`1 1 auto`,gap:2,minWidth:0},he={alignItems:`center`,display:`flex`,flex:`0 0 auto`,gap:4},ge={alignItems:`center`,display:`flex`,gap:6},_e={cursor:`pointer`,userSelect:`none`},ve={filter:`drop-shadow(0 8px 18px rgba(0, 0, 0, 0.12))`},ye={backgroundColor:`color-mix(in srgb, var(--mzn-color-primary) 8%, var(--mzn-color-bg-surface))`,boxShadow:`inset 0 0 0 1px var(--mzn-color-border-primary)`},be={alignItems:`center`,border:`1px dashed var(--mzn-color-border-neutral)`,borderRadius:6,display:`grid`,gap:12,minHeight:240,padding:32,textAlign:`center`},xe={display:`flex`,gap:8,justifyContent:`center`},Se={display:`grid`,gap:14},Ce={display:`grid`,columnGap:16,gridTemplateColumns:`repeat(auto-fit, minmax(280px, 360px))`,justifyContent:`start`,maxWidth:736,rowGap:8},we={gridColumn:`1 / -1`},Te={alignItems:`center`,display:`flex`,gap:8,gridColumn:`1 / -1`,justifyContent:`flex-end`},S={gridColumn:`1 / -1`},Ee={alignItems:`start`,display:`block`,width:`100%`},De={...Ee,gridColumn:`1 / -1`},Oe={minWidth:0,width:`100%`},ke={minWidth:`100%`,width:`100%`},Ae={display:`grid`,gap:14},je={alignItems:`start`,display:`block`,width:`100%`},Me={minWidth:0,width:`100%`},Ne={gridColumn:`2 / -1`},Pe={display:`grid`,gap:10,width:`100%`},Fe={display:`grid`,gap:8,gridTemplateColumns:`repeat(auto-fit, minmax(160px, 1fr))`},Ie={display:`inline-flex`},Le={display:`grid`,gap:16},Re={display:`grid`,gap:8},ze={display:`flex`,justifyContent:`flex-end`},Be={color:`var(--mzn-color-text-error)`,fontSize:`0.72em`,lineHeight:0,marginLeft:2,verticalAlign:`super`},Ve={display:`grid`,gap:10,gridColumn:`1 / -1`},He={display:`grid`,gap:2},C={display:`grid`,gap:8},Ue={display:`flex`,justifyContent:`flex-start`},We={display:`flex`,flexWrap:`wrap`,gap:4},Ge={backgroundColor:`var(--mzn-color-bg-surface-secondary)`,borderRadius:6,display:`grid`,gap:4,padding:10},Ke={...Ce,gridTemplateColumns:`minmax(280px, 520px)`,padding:`4px 0 8px`},qe={display:`grid`,gap:8,gridColumn:`1 / -1`},Je={alignItems:`center`,display:`flex`,gap:12,justifyContent:`space-between`},Ye={alignItems:`baseline`,display:`flex`,gap:2},Xe={display:`grid`,gap:4};function Ze(e){e&&(e.style.width=`100%`)}var Qe={fields:[],schemaVersion:1},$e={layout:[],schemaVersion:1},w=`__STATIC_OPTIONS__`,T=`__CONSTANT__`,et=`__EXPRESSION__`,E=`__UNSUPPORTED__`,tt=`__ROW_FIELD__:`,nt=`__UNBOUND__`,rt=[{id:w,name:`靜態選項`}],it=[{id:`single`,name:`單選`},{id:`multiple`,name:`複選`}],at=[{id:`unset`,name:`不預設`},{id:`true`,name:`是`},{id:`false`,name:`否`}],ot=[{id:`true`,name:`是`},{id:`false`,name:`否`}],st=[{label:`顯示`,name:`fieldVisibleWhen`,supportingText:`符合條件時才顯示這個欄位。`,target:`visibleWhen`},{label:`必填`,name:`fieldRequiredWhen`,supportingText:`符合條件時才要求填寫這個欄位。`,target:`requiredWhen`},{label:`唯讀`,name:`fieldReadonlyWhen`,supportingText:`符合條件時不允許修改這個欄位。`,target:`readonlyWhen`}],ct={whiteSpace:`pre-line`},lt=`勾選後,此欄位的 key 與型別在之後的版本不能再改。HIDE/hidden 不是保密手段。`;function D({formDefinitionId:e,onChange:m,templateId:h,value:g}){let ee=g?.schema??Qe,_=g?.uiSchema??$e,[v,y]=(0,r.useState)(ee),[D,O]=(0,r.useState)(_),[ht,k]=(0,r.useState)(j(ee)),[bt,M]=(0,r.useState)(j(_)),[Lt,Rt]=(0,r.useState)({}),[zt,P]=(0,r.useState)(null),[F,Bt]=(0,r.useState)([]),[Vt,Ht]=(0,r.useState)(null);(0,r.useEffect)(()=>{if(!h&&!e||(0,s.readFilterableFieldPaths)(v).length===0)return Bt([]),Ht(null),()=>void 0;let t=!1,n=setTimeout(()=>{(0,o.listFilterableFieldIssues)({formDefinitionId:e,schemaJson:j(v),templateId:h}).then(e=>{t||(Bt(e),Ht(null))}).catch(e=>{t||(Bt([]),Ht(e instanceof Error?e.message:`無法檢查可篩選欄位。`))})},400);return()=>{t=!0,clearTimeout(n)}},[e,v,h]);let Ut=(0,r.useMemo)(()=>new Map(F.map(e=>[e.path,e.message])),[F]),[I,Wt]=(0,r.useState)(`design`),[L,R]=(0,r.useState)(null),[z,Gt]=(0,r.useState)([]),[Kt,qt]=(0,r.useState)(null),[Jt,Yt]=(0,r.useState)(`loading`),[Xt,B]=(0,r.useState)(null),[Zt,Qt]=(0,r.useState)(!1),[V,H]=(0,r.useState)(null),[$t,U]=(0,r.useState)(null);(0,r.useEffect)(()=>{let e=!0;return(0,u.listFormDataSources)().then(t=>{e&&(Gt(t),qt(null),Yt(`ready`))}).catch(t=>{e&&(Gt([]),qt(`目前無法載入 DataSource Catalog,請稍後重試。`),Yt(`unavailable`))}),()=>{e=!1}},[]),(0,r.useEffect)(()=>{v.fields.some(e=>e.fieldKey===L)||R(v.fields[0]?.fieldKey??null)},[v.fields,L]),(0,r.useEffect)(()=>{Rt(e=>(0,u.buildFormRendererValues)(v.fields,e))},[v.fields]),(0,r.useEffect)(()=>{I!==`advanced`&&(k(j(v)),M(j(D)))},[I,v,D]);let W=(0,r.useMemo)(()=>v.fields.find(e=>e.fieldKey===L)??v.fields[0]??null,[v.fields,L]);(0,r.useEffect)(()=>{m?.({schema:v,uiSchema:D})},[v,D]);function en(e){let t=v.fields.length+1,n=(0,u.createFieldDefinition)(e,t);y({...v,fields:[...v.fields,n]}),O({...D,layout:[...D.layout,{fieldKey:n.fieldKey,width:e===`textarea`||e===`file_upload`||e===`table`?`FULL`:`HALF`}]}),R(n.fieldKey),Wt(`design`),P(null)}function tn(e){let t=e;t===`advanced`&&I!==`advanced`&&(k(j(v)),M(j(D))),Wt(t)}function nn(e){let t=v.fields.flatMap(t=>(0,f.isTableFieldDefinition)(t)?t.columns.flatMap(n=>(0,f.isFormDataSourceFieldDefinition)(n)&&(0,u.readFormDataSourceFieldDependencyKeys)(n).includes(e)?[`${t.fieldKey}.${n.fieldKey}`]:[]):(0,f.isFormDataSourceFieldDefinition)(t)&&(0,u.readFormDataSourceFieldDependencyKeys)(t).includes(e)?[t.fieldKey]:[]);t.length>0?H({affectedFieldKeys:t,fieldKey:e,kind:`remove-field`}):rn(e)}function rn(e){let t=v.fields.filter(t=>t.fieldKey!==e);y({...v,fields:t}),O({...D,layout:D.layout.filter(t=>t.fieldKey!==e)}),R(L===e?t[0]?.fieldKey??null:L),P(null),B(null)}function an(e){let t=e.destination;t&&e.source.index!==t.index&&(y(n=>({...n,fields:N(n.fields,e.source.index,t.index)})),O(n=>({...n,layout:N(n.layout,e.source.index,t.index)})),P(null))}function G(e){K(t=>({...t,...e}))}function K(e){if(!W)return;let t=W.fieldKey,n=e(W),r=n.fieldKey,i={...v,fields:v.fields.map(e=>e.fieldKey===t?n:e)},a=t===r?i:(0,u.renameFormDataSourceFieldBindings)(i,t,r);y(a),O({...D,layout:D.layout.map(e=>e.fieldKey===t?{...e,fieldKey:r}:e)}),R(r),P(null),B(null)}function on(e){K(()=>e)}function q(e,t){y(n=>({...n,fields:n.fields.map(n=>n.fieldKey===e&&(0,f.isTableFieldDefinition)(n)?t(n):n)})),P(null),B(null)}function J(e,t,n){let r=e.columns[t]?.fieldKey;q(e.fieldKey,e=>{let i={...e,columns:e.columns.map((e,r)=>r===t?n:e)};return typeof r==`string`&&r!==n.fieldKey?(0,u.renameFormTableColumnBindings)(i,r,n.fieldKey):i})}function sn(e){let t=(0,u.createTableColumnDefinition)(e.columns,`text`);q(e.fieldKey,e=>({...e,columns:[...e.columns,t]})),U(e.columns.length)}function cn(e,t){q(e,e=>({...e,columns:e.columns.filter((e,n)=>n!==t)})),U(e=>e===null||e<t?e:e===t?null:e-1)}function ln(e,t,n){q(e.fieldKey,e=>({...e,columns:N(e.columns,t,n)})),U(e=>e===null?e:e===t?n:e>t&&e<=n?e-1:e<t&&e>=n?e+1:e)}function un(e,t,n){if(e.type!==`select`&&e.type!==`autocomplete`||(0,f.readFormFieldSelectionMode)(e)===t)return;let r=e.defaultValue,i=t===`multiple`?typeof r==`string`?[r]:r:Array.isArray(r)?r[0]:r;n(e,{...e,defaultValue:i,mode:t},`選擇模式變更可能轉換或捨棄既有預設值。`)}function dn(e,t,n=`此變更會替換目前選項來源;既有 options、dynamic reference 或 bindings 可能失效。`){JSON.stringify(e)!==JSON.stringify(t)&&H({fieldKey:e.fieldKey,impact:n,kind:`replace-field`,nextField:t})}function fn(e,t,n){if(!t)return;if(t===w){if(!(0,f.isFormDataSourceFieldDefinition)(e))return;let{dataSource:t,defaultValue:r,...i}=e;n({...i,options:[]});return}let r=z.find(e=>dt(e)===t);if(!r)return;if((0,f.isFormDataSourceFieldDefinition)(e)){let t=new Set(r.parameters.map(e=>e.key)),i=e.dataSource.bindings.filter(e=>t.has(e.parameter));n({...e,dataSource:{bindings:i,key:r.key,version:r.version}});return}let{options:i,...a}=e;n({...a,dataSource:{bindings:[],key:r.key,version:r.version}})}function pn(){V&&(mn(V),H(null))}function mn(e){e.kind===`remove-field`?rn(e.fieldKey):e.kind===`remove-column`?cn(e.fieldKey,e.columnIndex):e.kind===`replace-column`?(q(e.fieldKey,t=>({...t,columns:t.columns.map(t=>t.fieldKey===e.columnKey?e.nextColumn:t)})),U(e.columnIndex)):(y({...v,fields:v.fields.map(t=>t.fieldKey===e.fieldKey?e.nextField:t)}),P(null),B(null))}async function hn(){Qt(!0);try{let e=await(0,u.lintFormSchema)(v,D);B(e.errors.map(gn))}catch{B([`目前無法完成 DataSource schema 驗證。`])}finally{Qt(!1)}}function gn(e){let t=ce.exec(e);if(t?.[1]&&t[3])return`${_n(t[1],t[2])}尚未指定必要參數「${vn(t[1],t[2],t[3])}」的來源`;let n=(0,l.parseFormBindingExpressionLintLine)(e);if(n){let e=String(n.fieldIndex),t=n.columnIndex===null?void 0:String(n.columnIndex),r=v.fields[n.fieldIndex],i=r?Y(r,t):void 0,a=yn(e,t,String(n.bindingIndex))??``;return(0,l.readFormBindingExpressionLintMessage)({code:n.code,columnLabel:i?i.label||i.fieldKey:null,fieldLabel:r?r.label||r.fieldKey:``,parameterLabel:vn(e,t,a),subject:n.subject})}let r=le.exec(e);return r?.[1]&&r[3]?`${_n(r[1],r[2])}綁定了來源沒有的參數「${r[3]}」`:(0,u.readFormSchemaLintMessage)(e)}function _n(e,t){let n=v.fields[Number(e)];if(!n)return``;let r=n.label||n.fieldKey,i=Y(n,t);return i?`「${r}」表格的「${i.label||i.fieldKey}」欄`:`「${r}」欄位`}function vn(e,t,n){let r=v.fields[Number(e)];if(!r)return n;let i=Y(r,t)??r,a=(0,f.isFormDataSourceFieldDefinition)(i)?i.dataSource:null;return(a?z.find(e=>e.key===a.key&&e.version===a.version):void 0)?.parameters.find(e=>e.key===n)?.label||n}function yn(e,t,n){let r=v.fields[Number(e)],i=r?Y(r,t)??r:null;return i&&(0,f.isFormDataSourceFieldDefinition)(i)?i.dataSource.bindings[Number(n)]?.parameter??null:null}function Y(e,t){return typeof t==`string`&&(0,f.isTableFieldDefinition)(e)?e.columns[Number(t)]:void 0}function bn(e){Rt(e)}function xn(e,t){y(n=>({...n,fields:n.fields.map(n=>n.fieldKey===e?{...n,required:t}:n)})),P(null)}function Sn(e){k(e);try{y(JSON.parse(e)),P(null)}catch{P(`Form Schema JSON 格式不正確`)}}function Cn(e){M(e);try{O(JSON.parse(e)),P(null)}catch{P(`UI Schema JSON 格式不正確`)}}return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(a.Fragment,{children:[Vt?(0,a.jsx)(i.InlineMessage,{content:Vt,severity:`warning`}):null,F.length>0?(0,a.jsx)(i.Typography,{color:`text-error`,style:ct,variant:`body`,children:F.map(e=>e.message).join(`
2
+ `)}):null,(0,a.jsx)(i.SectionGroup,{children:(0,a.jsx)(i.Section,{children:(0,a.jsxs)(`div`,{style:Le,children:[(0,a.jsxs)(i.Tab,{activeKey:I,onChange:tn,size:`sub`,children:[(0,a.jsx)(i.TabItem,{children:`設計`},`design`),(0,a.jsx)(i.TabItem,{children:`預覽`},`preview`),(0,a.jsx)(i.TabItem,{children:`進階`},`advanced`)]}),I===`design`?wn():null,I===`preview`?fr():null,I===`advanced`?pr():null]})})})]}),V?(0,a.jsx)(i.Modal,{cancelText:`返回`,confirmText:`確認變更`,modalType:`standard`,onCancel:()=>H(null),onClose:()=>H(null),onConfirm:pn,open:!0,showModalFooter:!0,showModalHeader:!0,title:vt(V),children:V.kind===`remove-field`?(0,a.jsxs)(`div`,{style:Re,children:[(0,a.jsx)(i.Typography,{variant:`body`,children:`此欄位仍被下列 DataSource binding 使用;移除後請重新設定這些欄位。`}),(0,a.jsx)(i.Typography,{color:`text-warning`,variant:`body`,children:V.affectedFieldKeys.join(`、`)})]}):V.kind===`remove-column`?(0,a.jsxs)(i.Typography,{variant:`body`,children:[`移除欄「`,V.columnKey,`」後,既有案件仍保留原本的表單版本,但新版本的這一欄資料將不再被填寫。`]}):(0,a.jsx)(i.Typography,{variant:`body`,children:V.impact})}):null]});function wn(){return(0,a.jsxs)(`div`,{style:x,children:[(0,a.jsxs)(`div`,{style:fe,children:[(0,a.jsx)(i.Typography,{component:`h2`,variant:`label-primary`,children:`新增欄位`}),(0,a.jsx)(`div`,{style:ue,children:ne.map(e=>(0,a.jsx)(i.Button,{icon:e.icon,iconType:`leading`,onClick:()=>en(e.type),size:`sub`,style:de,type:`button`,variant:`base-secondary`,children:e.label},e.type))})]}),(0,a.jsxs)(`div`,{style:re,children:[(0,a.jsxs)(`div`,{style:{...x,...ie},children:[(0,a.jsx)(i.Typography,{component:`h2`,variant:`label-primary`,children:`表單畫布`}),v.fields.length>0?(0,a.jsx)(p.DragDropContext,{onDragEnd:an,children:(0,a.jsx)(p.Droppable,{droppableId:`form-builder-fields`,children:e=>(0,a.jsxs)(`div`,{...e.droppableProps,ref:e.innerRef,style:x,children:[v.fields.map((e,t)=>(0,a.jsx)(p.Draggable,{draggableId:e.fieldKey,index:t,children:(t,n)=>ur(e,t,n.isDragging)},e.fieldKey)),e.placeholder]})})}):(0,a.jsxs)(`div`,{style:be,children:[(0,a.jsxs)(`div`,{style:x,children:[(0,a.jsx)(i.Typography,{component:`h3`,variant:`h3`,children:`尚未建立欄位`}),(0,a.jsx)(i.Typography,{color:`text-neutral`,variant:`body`,children:`從上方新增第一個欄位,或直接建立常用文字欄位開始設計。`})]}),(0,a.jsxs)(`div`,{style:xe,children:[(0,a.jsx)(i.Button,{onClick:()=>en(`text`),variant:`base-primary`,children:`新增文字欄位`}),(0,a.jsx)(i.Button,{onClick:()=>en(`textarea`),variant:`base-secondary`,children:`新增長文字`})]})]})]}),(0,a.jsxs)(`div`,{style:{...x,...ae},children:[(0,a.jsx)(i.Typography,{component:`h2`,variant:`label-primary`,children:`欄位設定`}),W?Tn(W):(0,a.jsx)(i.Typography,{color:`text-neutral`,variant:`body`,children:`請先新增或選取欄位。`})]})]})]})}function Tn(e){return(0,a.jsxs)(`div`,{style:Se,children:[En(e),(0,f.isTableFieldDefinition)(e)?An(e):null,Dn(e)]})}function En(e){return(0,a.jsxs)(`div`,{style:Ce,children:[(0,a.jsx)(`div`,{style:Te,children:(0,a.jsx)(i.Badge,{size:`main`,text:ut(e.type),variant:`text-info`})}),$(`標題`,`fieldLabel`,(0,a.jsx)(i.Input,{onChange:e=>G({label:e.target.value}),placeholder:`例如:申請金額`,value:e.label,variant:`base`})),$(`欄位 Key`,`fieldKey`,(0,a.jsx)(i.Input,{onChange:e=>G({fieldKey:e.target.value}),placeholder:`例如:amount`,value:e.fieldKey,variant:`base`})),(0,f.isTableFieldDefinition)(e)?null:$(`提示文字`,`fieldPlaceholder`,(0,a.jsx)(i.Input,{onChange:e=>G({placeholder:e.target.value||void 0}),placeholder:`例如:請輸入申請金額`,value:e.placeholder??``,variant:`base`})),On(e,on,dn,dn),kt(e)?$(`以連結顯示`,`fieldDisplayAsLink`,(0,a.jsx)(i.Toggle,{checked:e.displayAs===`link`,onChange:e=>K(t=>e.target.checked?kt(t)?{...t,displayAs:`link`}:t:Et(t,`displayAs`))})):null,$(`可篩選`,`fieldFilterable`,(0,a.jsx)(i.Toggle,{checked:e.filterable===!0,onChange:e=>K(t=>e.target.checked?{...t,filterable:!0}:Et(t,`filterable`))})),e.filterable===!0?(0,a.jsx)(i.Typography,{color:`text-neutral`,style:S,variant:`body`,children:lt}):null,Ut.has(e.fieldKey)?(0,a.jsx)(i.Typography,{color:`text-error`,style:S,variant:`body`,children:Ut.get(e.fieldKey)}):null,$(`只存不顯示(系統整合用)`,`fieldHidden`,(0,a.jsx)(i.Toggle,{checked:e.hidden===!0,onChange:e=>K(t=>e.target.checked?{...t,hidden:!0,required:!1}:Et(t,`hidden`))})),e.hidden===!0?(0,a.jsx)(i.Typography,{color:`text-neutral`,style:S,variant:`body`,children:`填寫、唯讀與重送畫面都不會顯示這個欄位,值仍會存下來; 透過 API 仍然讀得到這個值,不是權限控管。`}):null]})}function Dn(e){return(0,a.jsx)(i.Accordion,{defaultExpanded:Dt(e),size:`sub`,title:`進階設定`,children:(0,a.jsxs)(`div`,{style:Ce,children:[(0,a.jsx)(i.Typography,{component:`h3`,style:we,variant:`label-primary`,children:`條件規則`}),(0,a.jsx)(i.Typography,{color:`text-neutral`,style:S,variant:`body`,children:`只有需要根據其他欄位改變顯示、必填或唯讀狀態時才需要設定。`}),ir(e)]})})}function On(e,t,n,r,i){return kt(e)?Fn(e,t):(0,u.isNumberFieldDefinition)(e)?In(e,t):(0,u.isDateFieldDefinition)(e)?Ln(e,t):(0,f.isFormOptionFieldDefinition)(e)?Rn(e,t,n,r,i):e.type===`boolean`?tr(e,t):e.type===`file_upload`?rr(e,t):(0,f.isMemberFieldDefinition)(e)?nr(e,t):(0,f.isTableFieldDefinition)(e)?kn(e):null}function kn(e){let t=(0,u.readFormTableRowBounds)(e);return(0,a.jsxs)(a.Fragment,{children:[$(`最少列數`,`fieldMinRows`,Q(e.minRows,t=>q(e.fieldKey,e=>({...e,minRows:t})),`例如:1`,{max:t.maxRows,min:0})),$(`最多列數`,`fieldMaxRows`,Q(e.maxRows,t=>q(e.fieldKey,e=>({...e,maxRows:t})),`未設定即為 ${f.FORM_TABLE_MAX_ROWS}`,{max:f.FORM_TABLE_MAX_ROWS,min:Math.max(t.minRows,1)})),$(`新增列按鈕文字`,`fieldAddRowLabel`,(0,a.jsx)(i.Input,{onChange:t=>q(e.fieldKey,e=>({...e,addRowLabel:t.target.value||void 0})),placeholder:`預設為「新增一列」`,value:e.addRowLabel??``,variant:`base`}))]})}function An(e){return(0,a.jsxs)(`div`,{style:qe,children:[(0,a.jsxs)(`div`,{style:Je,children:[(0,a.jsxs)(i.Typography,{component:`h3`,variant:`label-primary`,children:[`欄(`,e.columns.length,`)`]}),(0,a.jsx)(i.Button,{icon:d.PlusIcon,iconType:`leading`,onClick:()=>sn(e),size:`sub`,type:`button`,variant:`base-secondary`,children:`新增欄`})]}),jn(e)]})}function jn(e){let t=e.columns.map((t,n)=>({fieldKey:t.fieldKey,index:n,key:`${e.fieldKey}-column-${n}`,label:t.label,type:t.type})),n=[{key:`label`,render:t=>(0,a.jsx)(i.Input,{fullWidth:!0,onChange:n=>J(e,t.index,{...X(e,t.index),label:n.target.value}),placeholder:`例如:數量`,size:`sub`,value:t.label,variant:`base`}),title:`標題`},{key:`type`,render:t=>(0,a.jsx)(i.Select,{fullWidth:!0,clearable:!1,menuMaxHeight:oe,onChange:n=>Nn(e,t.index,n?.id),options:[...b],size:`sub`,value:(0,u.readSelectOption)(b,t.type)}),title:`型別`},{key:`required`,render:t=>(0,a.jsx)(i.Toggle,{checked:X(e,t.index).required===!0,inputProps:{"aria-label":`${t.label||t.fieldKey} 必填`},onChange:n=>J(e,t.index,{...X(e,t.index),required:n.target.checked}),size:`sub`}),title:`必填`},{key:`filterable`,render:t=>{let n=X(e,t.index),r=Ut.get(`${e.fieldKey}.${n.fieldKey}`);return(0,a.jsxs)(`div`,{children:[(0,a.jsx)(i.Toggle,{checked:n.filterable===!0,inputProps:{"aria-label":`${t.label||t.fieldKey} 可篩選`},onChange:r=>J(e,t.index,{...n,filterable:r.target.checked}),size:`sub`}),n.filterable===!0?(0,a.jsx)(i.Typography,{color:`text-neutral`,variant:`caption`,children:lt}):null,r?(0,a.jsx)(i.Typography,{color:`text-error`,variant:`caption`,children:r}):null]})},title:`可篩選`}],r={render:t=>[{disabled:()=>e.columns.length<=1,icon:d.TrashIcon,iconType:`leading`,name:`移除此欄`,onClick:()=>H({columnIndex:t.index,columnKey:t.fieldKey,fieldKey:e.fieldKey,kind:`remove-column`}),variant:`destructive-ghost`}],width:104},o=$t===null?void 0:t[$t]?.key;return(0,a.jsx)(i.Table,{actions:r,columns:n,dataSource:t,draggable:{enabled:!0,onDragEnd:(t,n)=>ln(e,n.fromIndex,n.toIndex)},expandable:{expandedRowKeys:o?[o]:[],expandedRowRender:t=>Mn(e,t.index),onExpand:(e,t)=>U(e?t.index:null)},fullWidth:!0,rowHeightPreset:`roomy`,showHeader:!0,size:`sub`})}function Mn(e,t){let n=e.columns[t];return n?(0,a.jsxs)(`div`,{style:Ke,children:[$(`欄位 Key`,`columnFieldKey`,(0,a.jsx)(i.Input,{onChange:r=>J(e,t,{...n,fieldKey:r.target.value}),placeholder:`例如:qty`,value:n.fieldKey,variant:`base`})),$(`提示文字`,`columnPlaceholder`,(0,a.jsx)(i.Input,{onChange:r=>J(e,t,{...n,placeholder:r.target.value||void 0}),placeholder:`例如:請輸入數量`,value:n.placeholder??``,variant:`base`})),On(n,n=>{(0,f.isTableColumnFieldType)(n.type)&&J(e,t,n)},(n,r)=>{(0,f.isTableColumnFieldType)(r.type)&&J(e,t,r)},(n,r,i)=>H({columnIndex:t,columnKey:n.fieldKey,fieldKey:e.fieldKey,impact:i,kind:`replace-column`,nextColumn:r}),e.columns)]}):null}function Nn(e,t,n){let r=e.columns[t],i=b.find(e=>e.id===n)?.id;if(!r||!i||r.type===i)return;let a=Tt(r,i),o=yt(r);o.length===0?(J(e,t,a),U(t)):H({columnIndex:t,columnKey:r.fieldKey,fieldKey:e.fieldKey,impact:`「${r.label||r.fieldKey}」改為${Pn(i)}後,這一欄的${o.join(`、`)}會被捨棄。`,kind:`replace-column`,nextColumn:a})}function Pn(e){return b.find(t=>t.id===e)?.name??e}function X(e,t){let n=e.columns[t];if(!n)throw Error(`Table ${e.fieldKey} has no column at index ${t}.`);return n}function Fn(e,t){return(0,a.jsxs)(a.Fragment,{children:[$(`預設值`,`fieldDefaultValue`,e.type===`textarea`?sr({name:`fieldDefaultValue`,onChange:n=>t({...e,defaultValue:n||void 0}),placeholder:`輸入此欄位的預設文字`,rows:3,value:A(e.defaultValue)}):(0,a.jsx)(i.Input,{onChange:n=>t({...e,defaultValue:n.target.value||void 0}),placeholder:`輸入此欄位的預設文字`,value:A(e.defaultValue),variant:`base`})),$(`最小長度`,`fieldMinLength`,Q(e.minLength,n=>t({...e,minLength:n}),`例如:2`,{min:0})),$(`最大長度`,`fieldMaxLength`,Q(e.maxLength,n=>t({...e,maxLength:n}),`例如:100`,{min:1})),$(`格式(正規表示式)`,`fieldPattern`,(0,a.jsx)(i.Input,{onChange:n=>t(xt(e,n.target.value)),placeholder:`例如:[0-9]{8}`,value:e.pattern??``,variant:`base`}),!1,Ct(e.pattern)),e.pattern?$(`格式錯誤訊息`,`fieldPatternErrorMessage`,(0,a.jsx)(i.Input,{onChange:n=>t(St(e,n.target.value)),placeholder:`例如:統一編號為 8 位數字。`,value:e.patternErrorMessage??``,variant:`base`}),!1,wt(e.patternErrorMessage)):null]})}function In(e,t){return(0,a.jsxs)(a.Fragment,{children:[$(`預設值`,`fieldDefaultValue`,Q(typeof e.defaultValue==`number`?e.defaultValue:void 0,n=>t({...e,defaultValue:n}),e.type===`money`?`例如:1000`:`輸入預設數值`,{max:e.maximum,min:e.minimum})),$(`最小值`,`fieldMinimum`,Q(e.minimum,n=>t({...e,minimum:n}),`例如:0`)),$(`最大值`,`fieldMaximum`,Q(e.maximum,n=>t({...e,maximum:n}),`例如:999999`))]})}function Ln(e,t){return $(`預設值`,`fieldDefaultValue`,cr(e,A(e.defaultValue),n=>t({...e,defaultValue:n})))}function Rn(e,t,n,r,o){let s=(0,u.readCompatibleFormDataSourceDescriptors)(e.type,z),c={commit:e=>t(e),requestDependencyChange:r,rowColumns:o},l=(0,f.isFormDataSourceFieldDefinition)(e)?dt(e.dataSource):w,d=(0,f.isFormDataSourceFieldDefinition)(e)?z.find(t=>t.key===e.dataSource.key&&t.version===e.dataSource.version):null,p=d?s.some(e=>e.key===d.key&&e.version===d.version):!1,m=[...rt,...s.map(pt),...(0,f.isFormDataSourceFieldDefinition)(e)&&!p?[{id:l,name:`${e.dataSource.key} v${e.dataSource.version}(目前不可用或不支援)`}]:[]],h=(0,f.readFormFieldSelectionMode)(e);return(0,a.jsxs)(a.Fragment,{children:[e.type===`select`||e.type===`autocomplete`?$(`選擇模式`,`fieldSelectionMode`,(0,a.jsx)(i.Select,{clearable:!1,onChange:t=>{(t?.id===`single`||t?.id===`multiple`)&&un(e,t.id,n)},options:[...it],value:(0,u.readSelectOption)(it,h)})):$(`選擇模式`,`fieldSelectionMode`,(0,a.jsx)(i.Typography,{color:`text-neutral`,variant:`body`,children:h===`multiple`?`固定複選`:`固定單選`})),$(`選項來源`,`fieldOptionSource`,(0,a.jsx)(i.Select,{clearable:!1,disabled:Jt===`loading`&&!(0,f.isFormDataSourceFieldDefinition)(e),onChange:n=>fn(e,n?.id,t),options:m,placeholder:`選擇選項來源`,value:(0,u.readSelectOption)(m,l)})),(0,f.isFormDataSourceFieldDefinition)(e)?Bn(e,s,c):er(e,t)]})}function zn(e,t){let n=Mt(e),r=n?{severity:`info`,text:`選項依賴其他欄位的值,不能設定固定預設值;由使用者自行選擇。`}:void 0;if((0,f.readFormFieldSelectionMode)(e)===`multiple`){let i=Array.isArray(e.defaultValue)?e.defaultValue.filter(e=>typeof e==`string`):void 0;return $(`預設值`,`fieldDefaultValue`,(0,a.jsx)(Nt,{disabled:n,onCommit:n=>t.commit({...e,defaultValue:n?[...n]:void 0}),value:i},`${e.fieldKey}:${String(n)}`),!0,r)}return $(`預設值`,`fieldDefaultValue`,(0,a.jsx)(i.Input,{disabled:n?!0:void 0,onChange:n=>t.commit({...e,defaultValue:n.target.value||void 0}),placeholder:`輸入預設選項的值`,value:A(e.defaultValue)}),!1,r)}function Bn(e,t,n){let r=z.find(t=>t.key===e.dataSource.key&&t.version===e.dataSource.version),o=r&&!(0,u.isFormDataSourceDescriptorCompatible)(r,e.type);return(0,a.jsxs)(`div`,{style:Ve,children:[Jt===`loading`?(0,a.jsx)(i.Typography,{color:`text-neutral`,variant:`body`,children:`正在載入可用的選項來源…`}):null,Kt?(0,a.jsx)(i.Typography,{color:`text-error`,variant:`body`,children:Kt}):null,r?null:(0,a.jsx)(i.Typography,{color:`text-warning`,variant:`body`,children:`找不到目前設定的來源版本。設定會保留,但這張表單在來源恢復前無法發布。`}),o?(0,a.jsx)(i.Typography,{color:`text-error`,variant:`body`,children:`這個來源不支援目前的控制項,請改選其他來源。`}):null,r?Vn(r):null,r&&r.parameters.length>0?Hn(e,r,n):null,r?zn(e,n):null,t.length===0&&!Kt?(0,a.jsx)(i.Typography,{color:`text-warning`,variant:`body`,children:`沒有支援目前控制項的已註冊來源。`}):null,(0,a.jsx)(`div`,{style:Ue,children:(0,a.jsx)(i.Button,{disabled:Zt,loading:Zt,onClick:()=>void hn(),size:`sub`,type:`button`,variant:`base-secondary`,children:`檢查全部動態選項設定`})}),Xt?(0,a.jsx)(`div`,{style:He,children:Xt.length>0?Xt.map(e=>(0,a.jsx)(i.Typography,{color:`text-error`,variant:`caption`,children:e},e)):(0,a.jsx)(i.Typography,{color:`text-success`,variant:`caption`,children:`這張表單的動態選項設定都可以使用。`})}):null]})}function Vn(e){return(0,a.jsxs)(`div`,{style:Ge,children:[e.description?(0,a.jsx)(i.Typography,{variant:`body`,children:e.description}):null,(0,a.jsx)(`div`,{style:We,children:ft(e).map(e=>(0,a.jsx)(i.Tag,{label:e,readOnly:!0,size:`minor`},e))}),(0,a.jsxs)(i.Typography,{color:`text-neutral`,variant:`caption`,children:[`來源代號:`,e.key,` · v`,e.version]})]})}function Hn(e,t,n){let r=t.parameters.map((e,t)=>({key:e.key,index:t,parameter:e}));return(0,a.jsxs)(`div`,{style:C,children:[(0,a.jsx)(i.Typography,{color:`text-neutral`,variant:`label-secondary`,children:`這個來源需要的條件`}),(0,a.jsx)(i.Table,{columns:[{key:`parameter`,render:e=>(0,a.jsxs)(`div`,{style:Ye,children:[(0,a.jsx)(i.Typography,{variant:`input`,children:e.parameter.label??e.parameter.key}),e.parameter.required?(0,a.jsx)(i.Typography,{color:`text-error`,variant:`input`,children:`*`}):null]}),title:`條件`,width:100},{key:`binding`,width:268,render:t=>Gn(e,t.parameter,n),title:`值從哪裡來`},{key:`constant`,width:140,render:t=>{let r=(0,u.readFormDataSourceBindingValueKind)((0,u.readFormDataSourceBinding)(e,t.parameter.key));return r===`CONSTANT`?Yn(e,t.parameter.key,t.parameter.type,(0,u.readFormDataSourceBinding)(e,t.parameter.key),n):(0,a.jsx)(i.Typography,{color:`text-neutral`,variant:`caption`,children:r===`EXPRESSION`?`見下方運算式`:`—`})},title:`固定值`},{key:`meaning`,render:t=>(0,a.jsx)(i.Typography,{color:`text-neutral`,variant:`caption`,children:qn((0,u.readFormDataSourceBinding)(e,t.parameter.key),t.parameter,n,Wn(e,t.parameter,n))}),title:`填寫時的行為`}],dataSource:r,fullWidth:!0,showHeader:!0,size:`sub`}),Un(e,t,n)]})}function Un(e,t,n){let r=t.parameters.filter(t=>(0,u.readFormDataSourceBindingValueKind)((0,u.readFormDataSourceBinding)(e,t.key))===`EXPRESSION`);return r.length===0?null:(0,a.jsx)(`div`,{style:C,children:r.map(t=>{let r=`${t.label??t.key} 的運算式`;return(0,a.jsxs)(`div`,{"data-data-source-expression":t.key,style:C,children:[(0,a.jsx)(i.Typography,{color:`text-neutral`,variant:`label-secondary`,children:r}),sr({name:r,onChange:r=>Qn(e,t.key,r,n),placeholder:n.rowColumns?`例如:row.plant == "" ? form.plant : row.plant`:`例如:form.chargeTo == "OTHER" ? "TW02" : form.plant`,rows:2,value:(0,u.readFormDataSourceBindingExpression)(e,t.key)??``}),(0,a.jsx)(i.Typography,{color:`text-neutral`,variant:`caption`,children:n.rowColumns?`以 form.欄位代號 讀表單欄位、row.欄位代號 讀同列欄位;只能使用內建函式,結果須符合條件的型別。`:`以 form.欄位代號 讀表單欄位;只能使用內建函式,結果須符合條件的型別。`})]},t.key)})})}function Wn(e,t,n){return(0,u.readCompatibleFormDataSourceBindingFields)(t.type,v.fields,e.fieldKey).length+(n.rowColumns?(0,u.readCompatibleFormTableColumnBindingFields)(t.type,n.rowColumns,e.fieldKey).length:0)}function Gn(e,t,n){let r=mt((0,u.readFormDataSourceBinding)(e,t.key)),o=n.rowColumns?(0,u.readCompatibleFormTableColumnBindingFields)(t.type,n.rowColumns,e.fieldKey).map(e=>({id:`${tt}${e.id}`,name:`同列:${e.name}`})):[],s=[...t.required?[]:[{id:nt,name:`未綁定`}],...o,...(0,u.readCompatibleFormDataSourceBindingFields)(t.type,v.fields,e.fieldKey),...t.type===`STRING_ARRAY`?[]:[{id:T,name:`固定常數`},{id:et,name:`運算式`}],...r===E?[{id:E,name:`不支援的來源(請重新設定)`}]:[]];return(0,a.jsx)(`div`,{"data-data-source-parameter":t.key,style:Xe,children:(0,a.jsx)(i.Select,{clearable:!1,fullWidth:!0,inputProps:{"aria-label":`${t.label??t.key} 的值來源`,title:(0,u.readSelectOption)(s,r)?.name??``},onChange:r=>Zn(e,t.key,t.type,r?.id,n),options:s,placeholder:`選擇欄位或常數`,size:`sub`,value:(0,u.readSelectOption)(s,r)})})}function Kn(e){return se[e]}function qn(e,t,n,r){let i=(0,u.readFormDataSourceBindingValueKind)(e);return i===`CONSTANT`?`固定值,不隨填寫變動`:i===`FIELD`?`隨欄位「${Jn(e,n)}」變動`:i===`ROW_FIELD`?`隨同列「${Jn(e,n)}」變動`:i===`EXPRESSION`?`由運算式計算,隨引用的欄位變動`:e?`這個來源目前的版本不支援,選項無法載入`:t.required?r>0?`尚未設定,選項無法載入`:`沒有相容的${Kn(t.type)}欄位,請改用固定值`:`未設定,不做這層篩選`}function Jn(e,t){let n=e?.from;if(n?.kind===`FIELD`){let e=v.fields.find(e=>e.fieldKey===n.fieldKey);return e?e.label||e.fieldKey:``}if(n?.kind===`ROW_FIELD`){let e=t.rowColumns?.find(e=>e.fieldKey===n.columnKey);return e?e.label||e.fieldKey:``}return``}function Yn(e,t,n,r,i){return(0,a.jsx)(`div`,{"data-data-source-constant":t,children:Xn(e,t,n,r,i)})}function Xn(e,t,n,r,o){let s=(0,u.readFormDataSourceBindingValue)(e,t);if(n===`BOOLEAN`){let n=[{id:`true`,name:`是`},{id:`false`,name:`否`}];return(0,a.jsx)(i.Select,{clearable:!1,fullWidth:!0,onChange:n=>$n(e,t,n?.id===`true`,o),options:n,size:`sub`,value:(0,u.readSelectOption)(n,s===!0?`true`:`false`)})}return n===`STRING_ARRAY`?(0,a.jsx)(i.Typography,{color:`text-warning`,variant:`caption`,children:`這個條件要收多個值,請綁定一個複選欄位;不接受固定值。`}):(0,a.jsx)(i.Input,{onChange:r=>$n(e,t,n===`NUMBER`?(0,u.parseOptionalNumberInput)(r.target.value)??0:r.target.value,o),placeholder:n===`NUMBER`?`輸入數字`:`輸入固定值`,value:gt(r,n),variant:`base`})}function Zn(e,t,n,r,i){r!==E&&Pt(e,(0,u.upsertFormDataSourceFieldBinding)(e,t,_t(t,n,r)),i)}function Qn(e,t,n,r){Pt(e,(0,u.upsertFormDataSourceFieldBinding)(e,t,{from:{expression:n,kind:`EXPRESSION`},parameter:t}),r)}function $n(e,t,n,r){Pt(e,(0,u.upsertFormDataSourceFieldBinding)(e,t,{from:{kind:`CONSTANT`,value:n},parameter:t}),r)}function er(e,t){let n=(0,f.readFormFieldSelectionMode)(e),r=Array.isArray(e.defaultValue)?e.defaultValue:[],o=e.options.map(u.readFieldOptionAsSelectOption),s=o.filter(e=>r.includes(e.id));return(0,a.jsxs)(a.Fragment,{children:[$(`預設值`,`fieldDefaultValue`,n===`multiple`?(0,a.jsx)(i.Select,{clearable:!0,mode:`multiple`,onChange:n=>t({...e,defaultValue:n.length?n.map(e=>e.id):void 0}),options:o,placeholder:`選擇一或多個預設選項`,value:s}):(0,a.jsx)(i.Select,{clearable:!0,onChange:n=>t({...e,defaultValue:n?.id||void 0}),options:o,placeholder:`選擇預設選項`,value:typeof e.defaultValue==`string`?(0,u.readSelectOption)(o,e.defaultValue):null})),$(`選項`,`fieldOptions`,lr(e,t),!0)]})}function tr(e,t){let n=typeof e.defaultValue==`boolean`?String(e.defaultValue):`unset`;return $(`預設值`,`fieldDefaultValue`,(0,a.jsx)(i.Select,{clearable:!1,onChange:n=>t({...e,defaultValue:n?.id===`true`||n?.id!==`false`&&void 0}),options:[...at],placeholder:`選擇預設狀態`,value:(0,u.readSelectOption)(at,n)}))}function nr(e,t){return $(`可複選`,`fieldMemberMultiple`,(0,a.jsx)(i.Toggle,{checked:e.multiple===!0,label:e.multiple===!0?`可選多位`:`只能選一位`,onChange:n=>t({...e,defaultValue:void 0,multiple:n.target.checked||void 0}),size:`sub`}))}function rr(e,t){return(0,a.jsxs)(a.Fragment,{children:[$(`檔案數`,`fieldMaxFiles`,Q(e.maxFiles,n=>t({...e,maxFiles:n}),`例如:1`,{min:1})),$(`MIME`,`fieldAcceptedMimeTypes`,sr({name:`fieldAcceptedMimeTypes`,onChange:n=>t({...e,acceptedMimeTypes:At(n)}),placeholder:`每行一個 MIME type,例如:application/pdf`,rows:3,value:jt(e.acceptedMimeTypes)}),!1)]})}function ir(e){let t=v.fields.filter(t=>t.fieldKey!==e.fieldKey&&!(0,f.isMemberFieldDefinition)(t)&&!(0,f.isOrgUnitFieldDefinition)(t));return t.length?(0,a.jsx)(a.Fragment,{children:st.map(n=>ar(e,n,t))}):(0,a.jsx)(i.Typography,{color:`text-neutral`,style:S,variant:`body`,children:`目前沒有其他欄位可作為條件來源。新增更多欄位後即可設定條件規則。`})}function ar(e,t,n){let r=e[t.target],o=r?(0,u.parseConditionRule)(r):null,s=n.find(e=>e.fieldKey===o?.fieldKey),c=s??n[0],l=n.map(Ot),d=(0,u.readConditionOperatorOptions)(c),f=o&&d.some(e=>e.id===o.operator)?o.operator:(0,u.readDefaultConditionOperator)(c),p=o?.value??(0,u.readDefaultConditionValue)(c),m=!!r,h=m&&(!o||!s);return $(t.label,t.name,(0,a.jsxs)(`div`,{style:Pe,children:[(0,a.jsx)(i.Toggle,{checked:m,label:m?`已啟用`:`不啟用`,onChange:e=>Z(t.target,e.target.checked?(0,u.buildConditionExpression)(c,(0,u.readDefaultConditionOperator)(c),(0,u.readDefaultConditionValue)(c)):void 0),size:`sub`,supportingText:t.supportingText}),m?h?(0,a.jsx)(i.Typography,{color:`text-warning`,variant:`body`,children:`這個規則不是目前 UI 支援的格式。重新選擇條件後會取代既有規則。`}):(0,a.jsxs)(`div`,{style:Fe,children:[(0,a.jsx)(i.Select,{clearable:!1,onChange:e=>{let r=n.find(t=>t.fieldKey===e?.id)??c;Z(t.target,(0,u.buildConditionExpression)(r,(0,u.readDefaultConditionOperator)(r),(0,u.readDefaultConditionValue)(r)))},options:l,placeholder:`選擇欄位`,value:(0,u.readSelectOption)(l,c.fieldKey)}),(0,a.jsx)(i.Select,{clearable:!1,onChange:e=>Z(t.target,(0,u.buildConditionExpression)(c,(0,u.readConditionOperatorOption)(e?.id)??f,p)),options:[...d],placeholder:`判斷方式`,value:(0,u.readSelectOption)(d,f)}),or(c,p,e=>Z(t.target,(0,u.buildConditionExpression)(c,f,e)))]}):null]}),!0)}function Z(e,t){G({[e]:t})}function or(e,t,n){if(e.type===`boolean`)return(0,a.jsx)(i.Select,{clearable:!1,onChange:e=>n(e?.id??`true`),options:[...ot],placeholder:`比較值`,value:(0,u.readSelectOption)(ot,t===`false`?`false`:`true`)});if((0,u.isSelectFieldDefinition)(e)){let r=e.options.map(u.readFieldOptionAsSelectOption);return(0,a.jsx)(i.Select,{clearable:!1,onChange:e=>n(e?.id??r[0]?.id??``),options:r,placeholder:`比較值`,value:(0,u.readSelectOption)(r,t)})}return(0,u.isNumberFieldDefinition)(e)?Q((0,u.parseOptionalNumberInput)(t),e=>n(String(e??0)),`比較值`):(0,u.isDateFieldDefinition)(e)?cr(e,t,e=>n(e??``)):(0,a.jsx)(i.Input,{onChange:e=>n(e.target.value),placeholder:`比較值`,value:t,variant:`base`})}function sr({name:e,onChange:t,placeholder:n,rows:r,value:o}){return(0,a.jsx)(i.Textarea,{"aria-label":e,onChange:e=>t(e.target.value),placeholder:n,ref:Ze,resize:`vertical`,rows:r,style:ke,value:o})}function Q(e,t,n,r={}){return(0,a.jsx)(i.Input,{max:r.max,min:r.min,onChange:e=>t((0,u.clampOptionalNumber)((0,u.parseOptionalNumberInput)(e.target.value),r)),placeholder:n,showSpinner:!0,step:r.step??1,value:typeof e==`number`?String(e):``,variant:`measure`})}function cr(e,t,n){return e.type===`datetime`?(0,a.jsx)(i.DateTimePicker,{formatDate:`YYYY-MM-DD`,formatTime:`HH:mm`,hideSecond:!0,onChange:e=>n((0,u.formatDateTimePickerValue)(e)),placeholderLeft:`選擇日期`,placeholderRight:`選擇時間`,value:(0,u.readDatePickerValue)(t)}):(0,a.jsx)(i.DatePicker,{format:`YYYY-MM-DD`,onChange:e=>n((0,u.formatDatePickerValue)(e)),placeholder:`選擇日期`,value:(0,u.readDatePickerValue)(t)})}function lr(e,t){let n=e.options.map((t,n)=>({index:n,key:`${e.fieldKey}-${n}`,label:t.label,value:t.value}));return(0,a.jsxs)(`div`,{style:Re,children:[(0,a.jsx)(i.Table,{actions:{render:n=>[{disabled:()=>e.options.length<=1,icon:d.TrashIcon,iconType:`icon-only`,name:`移除選項`,onClick:()=>t({...e,options:e.options.filter((e,t)=>t!==n.index)}),variant:`destructive-ghost`}],width:56},columns:[{key:`label`,render:n=>(0,a.jsx)(i.Input,{onChange:r=>t({...e,options:Ft(e.options,n.index,{label:r.target.value})}),placeholder:`例如:主管`,size:`sub`,value:n.label,variant:`base`}),title:`Label`},{key:`value`,render:n=>(0,a.jsx)(i.Input,{onChange:r=>t({...e,options:Ft(e.options,n.index,{value:r.target.value})}),placeholder:`例如:manager`,size:`sub`,value:n.value,variant:`base`}),title:`Value`}],dataSource:n,showHeader:!0,size:`sub`}),(0,a.jsx)(`div`,{style:ze,children:(0,a.jsx)(i.Button,{icon:d.PlusIcon,iconType:`leading`,onClick:()=>t({...e,options:[...e.options,It(e.options)]}),variant:`base-secondary`,children:`新增選項`})})]})}function ur(e,t,n){return(0,a.jsx)(`div`,{...t.draggableProps,"data-form-builder-field-key":e.fieldKey,ref:t.innerRef,style:{..._e,...n?ve:null,...t.draggableProps.style},children:(0,a.jsx)(i.BaseCard,{style:e.fieldKey===W?.fieldKey?ye:void 0,children:dr(e,t,n)})})}function $(e,n,r,i=!1,o){return(0,a.jsx)(`div`,{style:i?De:Ee,children:(0,a.jsx)(`div`,{style:Oe,children:(0,a.jsx)(t.t,{label:e,layout:i?c.FormFieldLayout.VERTICAL:c.FormFieldLayout.STRETCH,name:n,...o?{hintText:o.text,severity:o.severity}:{},children:r})})})}function dr(e,t,n){return(0,a.jsxs)(`div`,{...t.dragHandleProps??{},"aria-label":`選取或拖曳排序欄位`,onClick:()=>R(e.fieldKey),style:pe,title:`點擊選取,拖曳排序`,children:[(0,a.jsx)(`span`,{"aria-label":`拖曳排序`,role:`img`,style:Ie,title:`拖曳排序`,children:(0,a.jsx)(i.Icon,{icon:d.DotDragVerticalIcon,size:20})}),(0,a.jsxs)(`div`,{style:me,children:[(0,a.jsxs)(i.Typography,{component:`span`,ellipsis:!0,variant:`label-primary`,children:[e.label,e.required?(0,a.jsx)(`sup`,{"aria-label":`必填`,style:Be,children:`*`}):null]}),(0,a.jsxs)(i.Typography,{color:`text-neutral`,component:`span`,ellipsis:!0,variant:`caption`,children:[ut(e.type),` ·`,e.required?` 必填`:` 選填`,` ·`,e.fieldKey,e.hidden?` · 只存不顯示`:null]})]}),(0,a.jsxs)(`div`,{onClick:e=>e.stopPropagation(),style:he,children:[(0,a.jsx)(`div`,{style:ge,children:(0,a.jsx)(i.Toggle,{checked:!!e.required,disabled:n||e.hidden===!0,label:`必填`,onChange:t=>xn(e.fieldKey,t.target.checked)})}),(0,a.jsx)(i.Button,{disabled:n,icon:d.TrashIcon,iconType:`icon-only`,onClick:()=>nn(e.fieldKey),variant:`destructive-ghost`,children:`移除欄位`})]})]})}function fr(){return(0,a.jsxs)(`div`,{style:x,children:[(0,a.jsx)(i.Typography,{component:`h2`,variant:`h3`,children:`填寫預覽`}),(0,a.jsx)(n.t,{dataSourceContext:{kind:`preview`},onChange:bn,schema:v,uiSchema:D,value:Lt})]})}function pr(){return(0,a.jsxs)(`div`,{style:x,children:[(0,a.jsx)(i.Typography,{component:`h2`,variant:`h3`,children:`Schema`}),(0,a.jsxs)(`div`,{style:Ae,children:[mr(`Form Schema`,`schemaJson`,(0,a.jsx)(te,{height:`360px`,name:`schemaJson`,onChange:Sn,placeholder:`輸入 Form Schema JSON`,value:ht})),mr(`UI Schema`,`uiSchemaJson`,(0,a.jsx)(te,{height:`240px`,name:`uiSchemaJson`,onChange:Cn,placeholder:`輸入 UI Schema JSON`,value:bt})),zt?(0,a.jsx)(i.Typography,{color:`text-error`,style:Ne,variant:`body`,children:zt}):null]})]})}function mr(e,n,r){return(0,a.jsx)(`div`,{style:je,children:(0,a.jsx)(`div`,{style:Me,children:(0,a.jsx)(t.t,{label:e,name:n,children:r})})})}}function ut(e){return ne.find(t=>t.type===e)?.label??e}function dt(e){return`${e.key}@${e.version}`}function ft(e){return[e.supportsSearch?`可輸入關鍵字搜尋${e.minimumSearchLength>1?`(至少 ${e.minimumSearchLength} 字)`:``}`:`不支援搜尋`,e.paginationMode===`CURSOR`?`捲動載入更多(每次 ${e.pageSize} 筆)`:`一次載入完整清單(最多 ${e.maximumResultCount} 筆)`,e.revalidationPolicy===`ALWAYS`?`退回重送時一律重新確認`:`值與條件未變時沿用上次結果`]}function pt(e){return{id:dt(e),name:e.label}}function mt(e){if(!e)return nt;let t=e.from;switch(t.kind){case`FIELD`:return t.fieldKey;case`ROW_FIELD`:return`${tt}${t.columnKey}`;case`CONSTANT`:return T;case`EXPRESSION`:return et;default:return O(t)}}function O(e){return E}function ht(e){switch(e){case`BOOLEAN`:return!1;case`NUMBER`:return 0;case`STRING_ARRAY`:return``;case`STRING`:return``;default:return``}}function gt(e,t){let n=e?.from.kind===`CONSTANT`?e.from.value:``;return t===`NUMBER`?typeof n==`number`?String(n):``:typeof n==`string`?n:``}function _t(e,t,n){return!n||n===nt?null:n===et?{from:{expression:``,kind:`EXPRESSION`},parameter:e}:n===T?{from:{kind:`CONSTANT`,value:ht(t)},parameter:e}:n.startsWith(tt)?{from:{columnKey:n.slice(14),kind:`ROW_FIELD`},parameter:e}:{from:{fieldKey:n,kind:`FIELD`},parameter:e}}function vt(e){return e.kind===`remove-field`?`確認移除 dependency 欄位`:e.kind===`remove-column`?`確認移除表格欄`:e.kind===`replace-column`?`確認變更欄型別`:`確認變更選擇模式`}var k=[{label:`選項 A`,value:`option_a`},{label:`選項 B`,value:`option_b`}];function yt(e){let t=[];return e.defaultValue!==void 0&&t.push(`預設值`),e.type===`text`&&(typeof e.minLength==`number`||typeof e.maxLength==`number`)&&t.push(`長度限制`),e.type===`text`&&e.pattern&&t.push(`格式`),e.type!==`number`&&e.type!==`money`||typeof e.minimum!=`number`&&typeof e.maximum!=`number`||t.push(`數值範圍`),(0,f.isFormDataSourceFieldDefinition)(e)?t.push(`選項來源設定`):(0,f.isFormStaticOptionFieldDefinition)(e)&&!bt(e.options)&&t.push(`${e.options.length} 個選項`),(e.type===`select`||e.type===`autocomplete`)&&e.mode===`multiple`&&t.push(`選擇模式`),t}function bt(e){return e.length===k.length&&e.every((e,t)=>e.label===k[t]?.label&&e.value===k[t]?.value)}function xt(e,t){return t?{...e,pattern:t}:Object.fromEntries(Object.entries(e).filter(([e])=>e!==`pattern`&&e!==`patternErrorMessage`))}function St(e,t){return t?{...e,patternErrorMessage:t}:Object.fromEntries(Object.entries(e).filter(([e])=>e!==`patternErrorMessage`))}function Ct(e){return e&&!e.trim()?{severity:`error`,text:`格式不能只有空白,儲存時會被拒絕。`}:e&&e.length>f.TEXT_FIELD_PATTERN_MAX_LENGTH?{severity:`error`,text:`格式最多 ${f.TEXT_FIELD_PATTERN_MAX_LENGTH} 個字元,儲存時會被拒絕。`}:e&&!(0,f.compileTextFieldPattern)(e)?{severity:`error`,text:`這不是有效的正規表示式,儲存時會被拒絕。格式以 u 模式檢查,多餘的跳脫(例如在方括號 [ ] 外寫 \\-)也算錯誤。`}:e&&(0,f.hasRepeatedTextFieldPatternGroup)(e)?{severity:`error`,text:`格式裡的括號群組後面不能接重複次數(例如 (ab)+、(\\w|\\d)*、(ab){2}),填寫的內容可能讓系統卡住,儲存時會被拒絕。請把重複的部分直接寫出來,或改用 [ ] 字元集合加次數。`}:{severity:`info`,text:`填寫的內容要整段符合格式才能送出;留空表示不檢查格式。`}}function wt(e){return e&&e.length>f.TEXT_FIELD_PATTERN_ERROR_MESSAGE_MAX_LENGTH?{severity:`error`,text:`錯誤訊息最多 ${f.TEXT_FIELD_PATTERN_ERROR_MESSAGE_MAX_LENGTH} 個字元,儲存時會被拒絕。`}:void 0}function Tt(e,t){let n={fieldKey:e.fieldKey,label:e.label,required:e.required,...e.description?{description:e.description}:{},...e.placeholder?{placeholder:e.placeholder}:{}};return t===`select`||t===`autocomplete`?{...n,mode:`single`,options:[...k],type:t}:{...n,type:t}}function Et(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==t))}function Dt(e){return!!(e.visibleWhen||e.requiredWhen||e.readonlyWhen)}function Ot(e){return{id:e.fieldKey,name:e.label}}function kt(e){return e.type===`text`||e.type===`textarea`}function A(e){return typeof e==`string`?e:``}function At(e){let t=e.split(/[\n,]/u).map(e=>e.trim()).filter(Boolean);return t.length?t:void 0}function jt(e){return e?.join(`
3
+ `)??``}function Mt(e){return e.dataSource.bindings.some(e=>e.from.kind!==`CONSTANT`)}function Nt({disabled:e,onCommit:t,value:n}){let[o,s]=(0,r.useState)(jt(n));return(0,a.jsx)(i.Textarea,{"aria-label":`fieldDefaultValue`,disabled:e,onBlur:()=>t(At(o)),onChange:e=>s(e.target.value),placeholder:`每行或以逗號分隔一個預設值`,ref:Ze,resize:`vertical`,rows:3,style:ke,value:o})}function Pt(e,t,n){if(e.defaultValue===void 0||Mt(e)||!Mt(t)){n.commit(t);return}let{defaultValue:r,...i}=t;n.requestDependencyChange(e,i,y)}function j(e){return JSON.stringify(e,null,2)}function Ft(e,t,n){return e.map((e,r)=>r===t?{...e,...n}:e)}function It(e){let t=e.length+1;return{label:`選項 ${t}`,value:M(e,t)}}function M(e,t){let n=`option_${t}`;return e.some(e=>e.value===n)?M(e,t+1):n}function N(e,t,n){let r=e[t];if(!r||t===n)return[...e];let i=e.filter((e,n)=>n!==t);return[...i.slice(0,n),r,...i.slice(n)]}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return D}});
4
+ //# sourceMappingURL=FormBuilderView-Bg9ftYz-.cjs.map