@rytass/bpm-core-react 0.7.7 → 0.9.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 (155) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/README.md +18 -2
  3. package/dist/chunks/FormBuilderView-BPLwAJGv.cjs +3 -0
  4. package/dist/chunks/FormBuilderView-BPLwAJGv.cjs.map +1 -0
  5. package/dist/chunks/FormBuilderView-Do9-MIAe.js +1477 -0
  6. package/dist/chunks/FormBuilderView-Do9-MIAe.js.map +1 -0
  7. package/dist/chunks/FormRendererView-C5POZbWz.js +492 -0
  8. package/dist/chunks/FormRendererView-C5POZbWz.js.map +1 -0
  9. package/dist/chunks/FormRendererView-DNtNodNl.cjs +2 -0
  10. package/dist/chunks/FormRendererView-DNtNodNl.cjs.map +1 -0
  11. package/dist/chunks/{approval-instance-list-page-YZcGGDD8.js → approval-instance-list-page-BjX2kaoF.js} +56 -54
  12. package/dist/chunks/approval-instance-list-page-BjX2kaoF.js.map +1 -0
  13. package/dist/chunks/approval-instance-list-page-C408vxE2.cjs +2 -0
  14. package/dist/chunks/approval-instance-list-page-C408vxE2.cjs.map +1 -0
  15. package/dist/chunks/{categories-DBPoSrsi.js → categories-DGlxuC6X.js} +5 -5
  16. package/dist/chunks/{categories-DBPoSrsi.js.map → categories-DGlxuC6X.js.map} +1 -1
  17. package/dist/chunks/{categories-B6QZKZRt.cjs → categories-DUfldZ_9.cjs} +2 -2
  18. package/dist/chunks/{categories-B6QZKZRt.cjs.map → categories-DUfldZ_9.cjs.map} +1 -1
  19. package/dist/chunks/compose-CULMDsLS.cjs +2 -0
  20. package/dist/chunks/compose-CULMDsLS.cjs.map +1 -0
  21. package/dist/chunks/{compose-B1quUa7y.js → compose-DJBlA5PD.js} +60 -58
  22. package/dist/chunks/compose-DJBlA5PD.js.map +1 -0
  23. package/dist/chunks/{delegations-DDEk-WI6.cjs → delegations-CGj-tZNO.cjs} +2 -2
  24. package/dist/chunks/{delegations-DDEk-WI6.cjs.map → delegations-CGj-tZNO.cjs.map} +1 -1
  25. package/dist/chunks/{delegations-iVnRi3QE.js → delegations-DLEEFBlH.js} +231 -231
  26. package/dist/chunks/{delegations-iVnRi3QE.js.map → delegations-DLEEFBlH.js.map} +1 -1
  27. package/dist/chunks/{delegations-ZNtodFaD.js → delegations-DqMpI_Nk.js} +168 -167
  28. package/dist/chunks/delegations-DqMpI_Nk.js.map +1 -0
  29. package/dist/chunks/delegations-kbMOSEif.cjs +2 -0
  30. package/dist/chunks/delegations-kbMOSEif.cjs.map +1 -0
  31. package/dist/chunks/designer-BszXJ5RO.js +3038 -0
  32. package/dist/chunks/designer-BszXJ5RO.js.map +1 -0
  33. package/dist/chunks/designer-CmqAU92b.cjs +65 -0
  34. package/dist/chunks/designer-CmqAU92b.cjs.map +1 -0
  35. package/dist/chunks/detail-CDexqBoU.cjs +2 -0
  36. package/dist/chunks/detail-CDexqBoU.cjs.map +1 -0
  37. package/dist/chunks/{detail-fg8MTwuH.js → detail-DAak2OXS.js} +737 -653
  38. package/dist/chunks/detail-DAak2OXS.js.map +1 -0
  39. package/dist/chunks/notifications--hwl-DR0.cjs +2 -0
  40. package/dist/chunks/{notifications-BKs4--96.cjs.map → notifications--hwl-DR0.cjs.map} +1 -1
  41. package/dist/chunks/{notifications-CSulztkU.js → notifications-DJ5wzCye.js} +7 -7
  42. package/dist/chunks/{notifications-CSulztkU.js.map → notifications-DJ5wzCye.js.map} +1 -1
  43. package/dist/chunks/{orgs-CrNxqlwp.js → orgs-DytLvZ_X.js} +243 -241
  44. package/dist/chunks/{orgs-CrNxqlwp.js.map → orgs-DytLvZ_X.js.map} +1 -1
  45. package/dist/chunks/orgs-Ni22buHs.cjs +2 -0
  46. package/dist/chunks/orgs-Ni22buHs.cjs.map +1 -0
  47. package/dist/chunks/providers-DEqcuXw9.js +506 -0
  48. package/dist/chunks/providers-DEqcuXw9.js.map +1 -0
  49. package/dist/chunks/providers-D_zTbkQH.cjs +2 -0
  50. package/dist/chunks/providers-D_zTbkQH.cjs.map +1 -0
  51. package/dist/chunks/{users-qghSMtLn.cjs → users-0HqlM_VQ.cjs} +2 -2
  52. package/dist/chunks/{users-qghSMtLn.cjs.map → users-0HqlM_VQ.cjs.map} +1 -1
  53. package/dist/chunks/{users-CUY139DF.js → users-FWrb3ehW.js} +5 -5
  54. package/dist/chunks/{users-CUY139DF.js.map → users-FWrb3ehW.js.map} +1 -1
  55. package/dist/components/notification-drawer.d.ts +4 -3
  56. package/dist/index.cjs +1 -1
  57. package/dist/index.cjs.map +1 -1
  58. package/dist/index.js +21 -428
  59. package/dist/index.js.map +1 -1
  60. package/dist/next/index.cjs +1 -1
  61. package/dist/next/index.cjs.map +1 -1
  62. package/dist/next/index.js +16 -15
  63. package/dist/next/index.js.map +1 -1
  64. package/dist/pages/admin/delegations/index.cjs +1 -1
  65. package/dist/pages/admin/delegations/index.js +1 -1
  66. package/dist/pages/admin/orgs/index.cjs +1 -1
  67. package/dist/pages/admin/orgs/index.js +1 -1
  68. package/dist/pages/admin/users/index.cjs +1 -1
  69. package/dist/pages/admin/users/index.js +1 -1
  70. package/dist/pages/delegations/index.cjs +1 -1
  71. package/dist/pages/delegations/index.js +1 -1
  72. package/dist/pages/instances/detail/index.cjs +1 -1
  73. package/dist/pages/instances/detail/index.js +1 -1
  74. package/dist/pages/settings/notifications/index.cjs +1 -1
  75. package/dist/pages/settings/notifications/index.js +1 -1
  76. package/dist/pages/templates/categories/index.cjs +1 -1
  77. package/dist/pages/templates/categories/index.js +1 -1
  78. package/dist/pages/templates/compose/index.cjs +1 -1
  79. package/dist/pages/templates/compose/index.js +1 -1
  80. package/dist/pages/templates/designer/index.cjs +1 -1
  81. package/dist/pages/templates/designer/index.js +1 -1
  82. package/dist/views/admin/delegations/index.cjs +1 -1
  83. package/dist/views/admin/delegations/index.js +1 -1
  84. package/dist/views/admin/index.cjs +1 -1
  85. package/dist/views/admin/index.js +3 -3
  86. package/dist/views/admin/orgs/index.cjs +1 -1
  87. package/dist/views/admin/orgs/index.js +1 -1
  88. package/dist/views/admin/users/index.cjs +1 -1
  89. package/dist/views/admin/users/index.js +1 -1
  90. package/dist/views/cc/index.cjs +1 -1
  91. package/dist/views/cc/index.js +1 -1
  92. package/dist/views/delegations/index.cjs +1 -1
  93. package/dist/views/delegations/index.js +1 -1
  94. package/dist/views/forms/builder/index.cjs +1 -1
  95. package/dist/views/forms/builder/index.js +1 -1
  96. package/dist/views/forms/renderer/FormRendererView.d.ts +7 -2
  97. package/dist/views/forms/renderer/form-data-source-field.d.ts +34 -0
  98. package/dist/views/forms/renderer/index.cjs +1 -1
  99. package/dist/views/forms/renderer/index.d.ts +1 -0
  100. package/dist/views/forms/renderer/index.js +2 -2
  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.ts +4 -1
  104. package/dist/views/instances/detail/sections/InstanceTasksSection.d.ts +5 -1
  105. package/dist/views/instances/new/index.cjs +1 -1
  106. package/dist/views/instances/new/index.cjs.map +1 -1
  107. package/dist/views/instances/new/index.js +105 -86
  108. package/dist/views/instances/new/index.js.map +1 -1
  109. package/dist/views/search/index.cjs +1 -1
  110. package/dist/views/search/index.js +1 -1
  111. package/dist/views/sent/index.cjs +1 -1
  112. package/dist/views/sent/index.js +1 -1
  113. package/dist/views/settings/index.cjs +1 -1
  114. package/dist/views/settings/index.js +1 -1
  115. package/dist/views/settings/notifications/index.cjs +1 -1
  116. package/dist/views/settings/notifications/index.js +1 -1
  117. package/dist/views/templates/categories/index.cjs +1 -1
  118. package/dist/views/templates/categories/index.js +1 -1
  119. package/dist/views/templates/compose/TemplateComposeWizardView.d.ts +3 -2
  120. package/dist/views/templates/compose/index.cjs +1 -1
  121. package/dist/views/templates/compose/index.js +1 -1
  122. package/dist/views/templates/designer/index.cjs +1 -1
  123. package/dist/views/templates/designer/index.js +1 -1
  124. package/dist/views/templates/index.cjs +1 -1
  125. package/dist/views/templates/index.cjs.map +1 -1
  126. package/dist/views/templates/index.js +153 -112
  127. package/dist/views/templates/index.js.map +1 -1
  128. package/package.json +41 -5
  129. package/dist/chunks/FormBuilderView-B_KGPjlp.cjs +0 -3
  130. package/dist/chunks/FormBuilderView-B_KGPjlp.cjs.map +0 -1
  131. package/dist/chunks/FormBuilderView-D8DrQOXD.js +0 -1090
  132. package/dist/chunks/FormBuilderView-D8DrQOXD.js.map +0 -1
  133. package/dist/chunks/FormRendererView-BwVsH2eX.cjs +0 -2
  134. package/dist/chunks/FormRendererView-BwVsH2eX.cjs.map +0 -1
  135. package/dist/chunks/FormRendererView-DrHsuSVo.js +0 -220
  136. package/dist/chunks/FormRendererView-DrHsuSVo.js.map +0 -1
  137. package/dist/chunks/approval-instance-list-page-BMUKxzcz.cjs +0 -2
  138. package/dist/chunks/approval-instance-list-page-BMUKxzcz.cjs.map +0 -1
  139. package/dist/chunks/approval-instance-list-page-YZcGGDD8.js.map +0 -1
  140. package/dist/chunks/compose-B1quUa7y.js.map +0 -1
  141. package/dist/chunks/compose-B6nevcwq.cjs +0 -2
  142. package/dist/chunks/compose-B6nevcwq.cjs.map +0 -1
  143. package/dist/chunks/delegations-C2wLWsDQ.cjs +0 -2
  144. package/dist/chunks/delegations-C2wLWsDQ.cjs.map +0 -1
  145. package/dist/chunks/delegations-ZNtodFaD.js.map +0 -1
  146. package/dist/chunks/designer-BLfz5Dk9.js +0 -2594
  147. package/dist/chunks/designer-BLfz5Dk9.js.map +0 -1
  148. package/dist/chunks/designer-DP002lt7.cjs +0 -65
  149. package/dist/chunks/designer-DP002lt7.cjs.map +0 -1
  150. package/dist/chunks/detail-KEmfpCtt.cjs +0 -2
  151. package/dist/chunks/detail-KEmfpCtt.cjs.map +0 -1
  152. package/dist/chunks/detail-fg8MTwuH.js.map +0 -1
  153. package/dist/chunks/notifications-BKs4--96.cjs +0 -2
  154. package/dist/chunks/orgs-iNJ0QEcK.cjs +0 -2
  155. package/dist/chunks/orgs-iNJ0QEcK.cjs.map +0 -1
@@ -1,2594 +0,0 @@
1
- "use client";
2
- import { r as e } from "./router-adapter-DftlFTOd.js";
3
- import { r as t } from "./routes-config-RBYQtUd0.js";
4
- import { a as n, n as r, o as i, r as a } from "./admin-pickers-DLlG_1du.js";
5
- import { t as o } from "./bpm-form-field-Cao0rMol.js";
6
- import '../style.css';/* empty css */
7
- import { t as s } from "./FormBuilderView-D8DrQOXD.js";
8
- import { Fragment as c, useCallback as l, useEffect as u, useMemo as d, useRef as f, useState as p } from "react";
9
- import { AutoComplete as m, Button as h, Icon as ee, Input as g, Modal as _, PageHeader as te, Section as ne, SectionGroup as re, Select as v, Textarea as ie, Toggle as ae, Typography as y } from "@mezzanine-ui/react";
10
- import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
11
- import oe from "@mezzanine-ui/react/Drawer";
12
- import se from "@mezzanine-ui/react/ContentHeader";
13
- import { CheckedIcon as ce, DotGridIcon as le, EyeIcon as ue, FilterIcon as de, MailIcon as fe, SaveIcon as pe, TrashIcon as me, UserIcon as he } from "@mezzanine-ui/icons";
14
- import { DefaultChatTransport as ge, getToolName as _e, isToolUIPart as ve, lastAssistantMessageIsCompleteWithToolCalls as ye } from "ai";
15
- import { WORKFLOW_TOOLSET as be, applyWorkflowCommand as C, applyWorkflowMacroCommand as xe, executeWorkflowTool as Se, readWorkflowSnapshot as Ce } from "@rytass/bpm-core-shared";
16
- import { readFormBuilder as we } from "@rytass/bpm-core-client/form";
17
- import { readOrganizationDashboard as Te } from "@rytass/bpm-core-client/organization";
18
- import { Background as Ee, ConnectionMode as De, ControlButton as Oe, Controls as ke, Handle as Ae, MiniMap as je, Panel as Me, Position as w, ReactFlow as Ne, applyNodeChanges as Pe, getViewportForBounds as Fe } from "@xyflow/react";
19
- import * as Ie from "dagre";
20
- import { composeApprovalTemplateWithForm as Le, dryRunApprovalWorkflow as Re, forkApprovalTemplate as ze, publishApprovalTemplateVersion as Be, readTemplateDesigner as Ve, resolveMemberOptions as He, searchMemberOptions as Ue, searchPublishedFormVersionOptions as We, updateApprovalTemplateDraft as Ge } from "@rytass/bpm-core-client/template";
21
- import { useChat as Ke } from "@ai-sdk/react";
22
- //#region src/views/templates/designer/use-workflow-designer-controller.ts
23
- function qe({ directory: e, initialState: t, layout: n, onLayout: r }) {
24
- let [i, a] = p(t), o = f(t), s = f(e);
25
- s.current = e;
26
- let c = l((e) => {
27
- if (!e.changed && !e.error) return e;
28
- let t = e.effects.layout ? n(e.state.definition) : e.state.definition, i = {
29
- ...e.state,
30
- definition: t
31
- };
32
- return o.current = i, a(i), e.effects.layout && r?.(t), {
33
- ...e,
34
- state: i
35
- };
36
- }, [n, r]), u = l((e) => c(C(o.current, e)), [c]), m = l((e) => c(xe(o.current, e)), [c]), h = l(async (e, t) => {
37
- let n = await Se(o.current, e, t, { directory: s.current });
38
- if (n.ok && (n.kind === "mutation" || n.kind === "macro")) {
39
- let e = c(n.result);
40
- return {
41
- ...n,
42
- result: e,
43
- snapshot: Ce(e.state)
44
- };
45
- }
46
- return n;
47
- }, [c]), ee = l((e) => {
48
- let t = typeof e == "function" ? e(o.current) : e;
49
- o.current = t, a(t);
50
- }, []), g = l(() => o.current, []), _ = d(() => Ce(i), [i]);
51
- return d(() => ({
52
- dispatch: u,
53
- dispatchMacro: m,
54
- executeTool: h,
55
- getState: g,
56
- replaceState: ee,
57
- snapshot: _,
58
- state: i,
59
- tools: be
60
- }), [
61
- u,
62
- m,
63
- h,
64
- g,
65
- ee,
66
- _,
67
- i
68
- ]);
69
- }
70
- //#endregion
71
- //#region src/views/templates/designer/use-workflow-chat.ts
72
- function Je({ controller: e, api: t = "/api/chat" }) {
73
- let n = Ke({
74
- transport: d(() => new ge({ api: t }), [t]),
75
- sendAutomaticallyWhen: ye,
76
- async onToolCall({ toolCall: t }) {
77
- let r = await e.executeTool(t.toolName, t.input);
78
- if (r.ok) {
79
- n.addToolOutput({
80
- output: r.kind === "query" ? r.data : r.snapshot,
81
- tool: t.toolName,
82
- toolCallId: t.toolCallId
83
- });
84
- return;
85
- }
86
- n.addToolOutput({
87
- errorText: r.error,
88
- state: "output-error",
89
- tool: t.toolName,
90
- toolCallId: t.toolCallId
91
- });
92
- }
93
- });
94
- return n;
95
- }
96
- //#endregion
97
- //#region src/views/templates/designer/chrome-workflow-chat.ts
98
- var Ye = 12;
99
- function Xe() {
100
- let e = globalThis.LanguageModel;
101
- return e && typeof e == "object" ? e : null;
102
- }
103
- var Ze = {
104
- additionalProperties: !1,
105
- properties: {
106
- action: {
107
- enum: ["tool", "message"],
108
- type: "string"
109
- },
110
- input: { type: "object" },
111
- text: { type: "string" },
112
- tool: { type: "string" }
113
- },
114
- required: ["action"],
115
- type: "object"
116
- };
117
- function Qe() {
118
- return `你是「簽核流程設計器」頁面的離線 AI 助理。只能透過下列工具操作這個流程畫布,其他請求一律婉拒並引導回流程設計。
119
-
120
- 每一步只輸出一個 JSON 決策物件:
121
- - 呼叫工具:{"action":"tool","tool":"<工具名>","input":{...}}
122
- - 回覆使用者(完成或詢問):{"action":"message","text":"<繁體中文訊息>"}
123
-
124
- 規則:先用 get_workflow_snapshot 了解現況再規劃;完成後用 validate_workflow 檢查並以 message 說明做了什麼。
125
-
126
- 可用工具:
127
- ${be.map((e) => `- ${e.name}(${JSON.stringify(e.inputSchema.properties ?? {})}): ${e.description}`).join("\n")}`;
128
- }
129
- function T({ controller: e }) {
130
- let [t, n] = p(!1), [r, i] = p([]), [a, o] = p("ready"), s = f(0);
131
- u(() => {
132
- let e = Xe();
133
- e && e.availability().then((e) => {
134
- n(e !== "unavailable");
135
- }).catch(() => n(!1));
136
- }, []);
137
- let c = l((e, t) => {
138
- s.current += 1, i((n) => [...n, {
139
- id: `chrome-${s.current}`,
140
- parts: [{
141
- text: t,
142
- type: "text"
143
- }],
144
- role: e
145
- }]);
146
- }, []);
147
- return {
148
- available: t,
149
- messages: r,
150
- send: l((t) => {
151
- let n = Xe();
152
- !n || a !== "ready" || (c("user", t), o("submitted"), E({
153
- appendMessage: c,
154
- controller: e,
155
- model: n,
156
- userText: t
157
- }).then(() => o("ready")).catch((e) => {
158
- c("assistant", O(e)), o("error");
159
- }));
160
- }, [
161
- c,
162
- e,
163
- a
164
- ]),
165
- status: a
166
- };
167
- }
168
- async function E({ appendMessage: e, controller: t, model: n, userText: r }) {
169
- let i = await n.create({ initialPrompts: [{
170
- content: Qe(),
171
- role: "system"
172
- }] });
173
- try {
174
- let n = `使用者需求:${r}\n目前流程:${JSON.stringify(t.snapshot)}`;
175
- for (let r = 0; r < Ye; r += 1) {
176
- let r = D(await i.prompt(n, { responseConstraint: Ze }));
177
- if (!r || r.action === "message") {
178
- e("assistant", r?.text ?? "我已完成可處理的部分。");
179
- return;
180
- }
181
- if (!r.tool) {
182
- e("assistant", "我已完成可處理的部分。");
183
- return;
184
- }
185
- let a = await t.executeTool(r.tool, r.input ?? {});
186
- if (a.ok) {
187
- let t = a.kind === "query" ? a.data : a.snapshot;
188
- e("assistant", `⚙ ${r.tool}`), n = `工具 ${r.tool} 已執行。最新流程:${JSON.stringify(t)}\n請決定下一步。`;
189
- } else n = `工具 ${r.tool} 失敗:${a.error}\n請改用其他方式或回覆使用者。`;
190
- }
191
- e("assistant", "已達到單次操作步數上限,請告訴我下一步。");
192
- } finally {
193
- i.destroy();
194
- }
195
- }
196
- function D(e) {
197
- try {
198
- let t = JSON.parse(e);
199
- return typeof t == "object" && t && t.action !== void 0 ? t : null;
200
- } catch {
201
- return null;
202
- }
203
- }
204
- function O(e) {
205
- return e instanceof Error ? `離線模式發生錯誤:${e.message}` : "離線模式發生未知錯誤。";
206
- }
207
- //#endregion
208
- //#region src/views/templates/designer/workflow-chat-drawer.tsx
209
- var $e = {
210
- display: "flex",
211
- flexDirection: "column",
212
- gap: 12,
213
- height: "100%"
214
- }, k = {
215
- display: "flex",
216
- flex: 1,
217
- flexDirection: "column",
218
- gap: 12,
219
- minHeight: 0,
220
- overflowY: "auto"
221
- }, et = {
222
- display: "flex",
223
- gap: 8,
224
- paddingBottom: 4
225
- }, tt = {
226
- borderTop: "1px solid var(--mzn-color-border-neutral, #e5e7eb)",
227
- display: "flex",
228
- flexDirection: "column",
229
- gap: 8,
230
- paddingTop: 12
231
- }, nt = {
232
- display: "flex",
233
- justifyContent: "flex-end"
234
- }, rt = { width: "100%" }, A = "workflow-chat-input-field", it = `
235
- .${A}.mzn-text-field {
236
- width: 100%;
237
- }
238
- `, at = {
239
- color: "var(--mzn-color-text-secondary, #6b7280)",
240
- fontSize: 12,
241
- padding: "2px 0"
242
- }, ot = {
243
- "input-available": "執行中…",
244
- "input-streaming": "準備中…",
245
- "output-available": "完成",
246
- "output-error": "失敗"
247
- };
248
- function j(e) {
249
- let t = e === "user";
250
- return {
251
- alignSelf: t ? "flex-end" : "flex-start",
252
- background: t ? "var(--mzn-color-primary, #2563eb)" : "var(--mzn-color-surface, #f3f4f6)",
253
- borderRadius: 10,
254
- color: t ? "#fff" : "var(--mzn-color-text-primary, #111827)",
255
- maxWidth: "85%",
256
- padding: "8px 12px",
257
- whiteSpace: "pre-wrap",
258
- wordBreak: "break-word"
259
- };
260
- }
261
- function st({ api: e, controller: t, onClose: n, open: r }) {
262
- let i = Je({
263
- api: e,
264
- controller: t
265
- }), a = T({ controller: t }), [o, s] = p("online"), [u, d] = p(""), f = o === "offline" ? {
266
- messages: a.messages,
267
- send: a.send,
268
- status: a.status
269
- } : {
270
- messages: i.messages,
271
- send: (e) => {
272
- i.sendMessage({ text: e });
273
- },
274
- status: i.status
275
- }, { messages: m, send: ee } = f, g = f.status === "submitted" || f.status === "streaming", _ = l(() => {
276
- let e = u.trim();
277
- !e || g || (d(""), ee(e));
278
- }, [
279
- g,
280
- u,
281
- ee
282
- ]), te = l((e) => {
283
- e.nativeEvent.isComposing || e.key === "Enter" && !e.shiftKey && (e.preventDefault(), _());
284
- }, [_]);
285
- return /* @__PURE__ */ S(oe, {
286
- headerTitle: "AI 流程助理",
287
- isHeaderDisplay: !0,
288
- onClose: n,
289
- open: r,
290
- size: "medium",
291
- children: [/* @__PURE__ */ x("style", { children: it }), /* @__PURE__ */ S("div", {
292
- style: $e,
293
- children: [
294
- a.available ? /* @__PURE__ */ S("div", {
295
- style: et,
296
- children: [/* @__PURE__ */ x(h, {
297
- onClick: () => s("online"),
298
- variant: o === "online" ? "base-primary" : "base-tertiary",
299
- children: "線上"
300
- }), /* @__PURE__ */ x(h, {
301
- onClick: () => s("offline"),
302
- variant: o === "offline" ? "base-primary" : "base-tertiary",
303
- children: "離線(裝置內,實驗)"
304
- })]
305
- }) : null,
306
- /* @__PURE__ */ S("div", {
307
- role: "log",
308
- style: k,
309
- children: [
310
- m.length === 0 ? /* @__PURE__ */ x(y, {
311
- color: "text-neutral",
312
- variant: "body",
313
- children: "用一句話描述你想要的流程,例如:「建立三關簽核:部門主管 → 經理 → 財務,金額大於十萬走財務複核」。我會直接在畫布上幫你繪製。"
314
- }) : null,
315
- m.map((e) => /* @__PURE__ */ x(c, { children: ct(e) }, e.id)),
316
- g ? /* @__PURE__ */ x(y, {
317
- color: "text-neutral",
318
- variant: "body",
319
- children: "思考中…"
320
- }) : null
321
- ]
322
- }),
323
- /* @__PURE__ */ S("div", {
324
- style: tt,
325
- children: [/* @__PURE__ */ x(ie, {
326
- className: A,
327
- disabled: g,
328
- maxLength: 2e3,
329
- onChange: (e) => d(e.target.value),
330
- onKeyDown: te,
331
- placeholder: "描述你想要的流程…(Enter 送出,Shift + Enter 換行)",
332
- rows: 3,
333
- style: rt,
334
- value: u
335
- }), /* @__PURE__ */ x("div", {
336
- style: nt,
337
- children: /* @__PURE__ */ x(h, {
338
- disabled: g || u.trim().length === 0,
339
- loading: g,
340
- onClick: _,
341
- type: "button",
342
- variant: "base-primary",
343
- children: "送出"
344
- })
345
- })]
346
- })
347
- ]
348
- })]
349
- });
350
- }
351
- function ct(e) {
352
- return e.parts.map((t, n) => t.type === "text" ? /* @__PURE__ */ x("div", {
353
- style: j(e.role),
354
- children: t.text
355
- }, `${e.id}-${n}`) : t.type === "dynamic-tool" || ve(t) ? /* @__PURE__ */ x("div", {
356
- style: at,
357
- children: `⚙ ${_e(t)} · ${ot[t.state] ?? t.state}`
358
- }, `${e.id}-${n}`) : null);
359
- }
360
- //#endregion
361
- //#region src/views/templates/designer/TemplateDesignerView.tsx
362
- var lt = {
363
- display: "grid",
364
- gap: 16
365
- }, ut = {
366
- alignItems: "start",
367
- display: "grid",
368
- gap: 16,
369
- gridTemplateColumns: "minmax(0, 1fr) 420px"
370
- }, dt = {
371
- border: "1px solid var(--mzn-color-border-neutral)",
372
- borderRadius: 6,
373
- height: 620,
374
- minWidth: 0,
375
- overflow: "hidden"
376
- }, ft = {
377
- alignItems: "center",
378
- boxSizing: "border-box",
379
- color: "var(--mzn-color-text-error)",
380
- display: "flex",
381
- height: 26,
382
- justifyContent: "center",
383
- lineHeight: 0,
384
- padding: 0,
385
- width: 26
386
- }, pt = {
387
- alignItems: "center",
388
- display: "flex",
389
- height: "100%",
390
- justifyContent: "center",
391
- width: "100%"
392
- }, mt = "workflow-designer-side-panel", M = 96, ht = `
393
- .${mt} .mzn-form-field--stretch .mzn-form-field__label-area,
394
- .${mt} .mzn-form-field--horizontal .mzn-form-field__label-area {
395
- flex: 0 0 ${M}px;
396
- width: ${M}px;
397
- }
398
-
399
- .${mt} .mzn-form-field--stretch .mzn-form-field__data-entry,
400
- .${mt} .mzn-form-field--horizontal .mzn-form-field__data-entry {
401
- min-width: 0;
402
- }
403
- `, gt = "#2563eb", N = "#64748b", _t = "var(--mzn-color-text-error, #dc2626)", vt = "drop-shadow(0 0 3px rgba(0, 87, 255, 0.85)) drop-shadow(0 0 9px rgba(0, 87, 255, 0.36))", yt = `
404
- .workflow-selection-delete-control.react-flow__controls-button {
405
- align-items: center !important;
406
- display: flex !important;
407
- height: 26px !important;
408
- justify-content: center !important;
409
- padding: 0 !important;
410
- width: 26px !important;
411
- }
412
-
413
- .workflow-selection-delete-control .mzn-icon {
414
- align-items: center;
415
- display: flex;
416
- justify-content: center;
417
- }
418
-
419
- .workflow-selection-delete-control .mzn-icon svg {
420
- height: 16px !important;
421
- max-height: none !important;
422
- max-width: none !important;
423
- width: 16px !important;
424
- }
425
-
426
- .workflow-edge--selected .react-flow__edge-path,
427
- .react-flow__edge-path.workflow-edge--selected {
428
- filter: ${vt};
429
- opacity: 1 !important;
430
- stroke: ${N} !important;
431
- stroke-opacity: 1 !important;
432
- stroke-width: 1.5px !important;
433
- }
434
-
435
- .workflow-edge--selected {
436
- --xy-edge-stroke: ${N};
437
- --xy-edge-stroke-selected: ${N};
438
- --xy-edge-stroke-width: 1.5px;
439
- }
440
-
441
- `, bt = {
442
- display: "grid",
443
- gap: 12
444
- }, P = {
445
- display: "grid",
446
- gap: 12
447
- }, xt = {
448
- border: "1px solid var(--mzn-color-border-neutral)",
449
- borderRadius: 6,
450
- display: "grid",
451
- gap: 8,
452
- maxHeight: 360,
453
- overflow: "auto",
454
- padding: 12
455
- }, St = {
456
- borderBottom: "1px solid var(--mzn-color-border-neutral)",
457
- display: "grid",
458
- gap: 4,
459
- padding: "0 0 8px"
460
- }, Ct = {
461
- display: "flex",
462
- flexWrap: "wrap",
463
- gap: 8
464
- }, wt = {
465
- alignItems: "center",
466
- display: "flex",
467
- gap: 8
468
- }, Tt = {
469
- flex: "1 1 auto",
470
- minWidth: 0
471
- }, Et = { flex: "0 0 auto" }, Dt = {
472
- display: "grid",
473
- gap: 8
474
- }, F = {
475
- alignContent: "center",
476
- background: "var(--mzn-color-bg-surface)",
477
- border: "1px solid var(--mzn-color-border-neutral)",
478
- borderRadius: 6,
479
- boxShadow: "0 8px 20px rgba(15, 23, 42, 0.08)",
480
- boxSizing: "border-box",
481
- display: "grid",
482
- gap: 4,
483
- height: "100%",
484
- minWidth: 132,
485
- overflow: "visible",
486
- padding: "10px 12px",
487
- textAlign: "center",
488
- width: "100%"
489
- }, Ot = "0 8px 20px rgba(15, 23, 42, 0.08), 0 0 0 1px var(--mzn-color-primary, #0057ff), 0 0 10px rgba(0, 87, 255, 0.3)", kt = 64, At = 160, I = 20, jt = 64, Mt = 180, L = {
490
- ...F,
491
- display: "grid",
492
- gap: 8,
493
- padding: "10px 12px"
494
- }, Nt = {
495
- ...L,
496
- background: "#eff6ff",
497
- border: "1px solid #2563eb"
498
- }, R = {
499
- ...L,
500
- background: "#f0fdfa",
501
- border: "1px solid #0f766e"
502
- }, Pt = {
503
- ...F,
504
- background: "#ffffff"
505
- }, z = {
506
- ...F,
507
- background: "#ecfdf3",
508
- border: "1px solid #2f855a"
509
- }, Ft = {
510
- ...F,
511
- background: "#fff4ed",
512
- border: "1px solid #c2410c"
513
- }, It = {
514
- display: "block",
515
- maxWidth: "100%",
516
- minWidth: 0
517
- }, Lt = {
518
- display: "grid",
519
- gap: 2,
520
- minWidth: 0
521
- }, Rt = "input", B = "output", zt = {
522
- endEvent: "結束",
523
- exclusiveGateway: "條件分流",
524
- parallelGateway: "並行處理",
525
- serviceTask: "系統",
526
- startEvent: "開始",
527
- userTask: "簽核"
528
- }, Bt = [{
529
- icon: he,
530
- label: "簽核節點",
531
- type: "userTask"
532
- }, {
533
- icon: fe,
534
- label: "知會節點",
535
- type: "serviceTask"
536
- }], Vt = [{
537
- icon: de,
538
- label: "條件分流",
539
- type: "exclusiveGateway"
540
- }], Ht = [{
541
- id: "AND",
542
- name: "全部前置完成"
543
- }, {
544
- id: "OR",
545
- name: "任一前置完成"
546
- }], Ut = [{
547
- id: "RESTART",
548
- name: "重新送出後從開始重跑"
549
- }, {
550
- id: "FROM_RETURN_POINT",
551
- name: "重新送出後回到退回節點"
552
- }], Wt = [
553
- {
554
- id: "DIRECT",
555
- name: "指定會員"
556
- },
557
- {
558
- id: "ORG_MANAGER",
559
- name: "發起人主管"
560
- },
561
- {
562
- id: "ORG_UNIT_MANAGER",
563
- name: "指定組織主管"
564
- },
565
- {
566
- id: "ORG_UNIT_MEMBER",
567
- name: "組織任一人"
568
- },
569
- {
570
- id: "ORG_UNIT_POSITION",
571
- name: "組織特定職位"
572
- },
573
- {
574
- id: "POSITION",
575
- name: "指定職位"
576
- }
577
- ], Gt = [
578
- {
579
- id: "1",
580
- name: "直屬主管",
581
- value: 1
582
- },
583
- {
584
- id: "2",
585
- name: "第二層主管",
586
- value: 2
587
- },
588
- {
589
- id: "3",
590
- name: "第三層主管",
591
- value: 3
592
- }
593
- ], Kt = [{
594
- id: "NONE",
595
- name: "停止流程並提示"
596
- }, {
597
- id: "DIRECT",
598
- name: "固定改派"
599
- }], qt = [
600
- {
601
- id: "EQUALS",
602
- name: "等於"
603
- },
604
- {
605
- id: "NOT_EQUALS",
606
- name: "不等於"
607
- },
608
- {
609
- id: "GREATER_THAN",
610
- name: "大於"
611
- },
612
- {
613
- id: "GREATER_THAN_OR_EQUALS",
614
- name: "大於等於"
615
- },
616
- {
617
- id: "LESS_THAN",
618
- name: "小於"
619
- },
620
- {
621
- id: "LESS_THAN_OR_EQUALS",
622
- name: "小於等於"
623
- },
624
- {
625
- id: "IS_FILLED",
626
- name: "已填寫"
627
- },
628
- {
629
- id: "IS_EMPTY",
630
- name: "未填寫"
631
- }
632
- ], Jt = [
633
- "EQUALS",
634
- "GREATER_THAN",
635
- "GREATER_THAN_OR_EQUALS",
636
- "LESS_THAN",
637
- "LESS_THAN_OR_EQUALS",
638
- "NOT_EQUALS"
639
- ], Yt = [
640
- {
641
- id: "NONE",
642
- name: "未設定"
643
- },
644
- {
645
- id: "ALL",
646
- name: "所有人"
647
- },
648
- {
649
- id: "ORG_UNIT",
650
- name: "指定組織"
651
- },
652
- {
653
- id: "ORG_UNIT_POSITION",
654
- name: "指定組織職位"
655
- }
656
- ], Xt = {
657
- id: "CUSTOM",
658
- name: "既有自訂規則"
659
- }, Zt = "member-001", Qt = {
660
- display: "flex",
661
- flexDirection: "column",
662
- height: "100%"
663
- }, $t = {
664
- flex: 1,
665
- minHeight: 0,
666
- overflowY: "auto"
667
- }, en = {
668
- borderTop: "1px solid var(--mzn-color-border-neutral)",
669
- display: "flex",
670
- gap: 8,
671
- paddingTop: 12
672
- }, tn = {
673
- fields: [],
674
- schemaVersion: 1
675
- }, nn = {
676
- layout: [],
677
- schemaVersion: 1
678
- }, rn = {
679
- endEvent: V,
680
- exclusiveGateway: V,
681
- parallelGateway: V,
682
- serviceTask: V,
683
- startEvent: V,
684
- userTask: V
685
- };
686
- function an(e, t) {
687
- return typeof e == "function" ? e(t) : e;
688
- }
689
- function on({ aiAssistantAvailable: n = !0, embedded: i = !1, formSchemaOverride: c, initialInitiatorPolicyCel: le, initialWorkflowDefinition: de, onInitiatorPolicyChange: fe, onWorkflowChange: he, showAiAssistant: ge = !1, showDryRun: _e = !0, templateId: ve }) {
690
- let ye = e(), be = t(), [C, xe] = p(null), [Se, Ce] = p(null), [Ae, Me] = p(""), [w, Fe] = p(null), [Ie, Ke] = p(null), Je = f(null), [Ye, Xe] = p(void 0), Ze = f([]), Qe = f([]), T = qe({
691
- directory: d(() => ({
692
- listOrgUnits: async () => Ze.current.map((e) => ({
693
- id: e.id,
694
- name: e.name
695
- })),
696
- listPositions: async () => Qe.current.map((e) => ({
697
- id: e.id,
698
- name: e.name
699
- })),
700
- searchMembers: async (e) => $n(await Ue(e)).map((e) => ({
701
- email: e.email,
702
- id: e.memberId,
703
- name: e.name
704
- }))
705
- }), []),
706
- initialState: {
707
- definition: i && de != null ? de : bn(),
708
- editingEdgeId: null,
709
- formDefinitionVersionId: null,
710
- formSchema: null,
711
- initiatorPolicyCel: i && le !== void 0 ? le : null,
712
- selectedEdgeIds: [],
713
- selectedNodeId: i && de != null ? de.nodes[0]?.id ?? "start" : "start"
714
- },
715
- layout: Sn,
716
- onLayout: (e) => {
717
- let t = vr(e, Je.current);
718
- t && Xe(t);
719
- }
720
- }), E = T.state.definition, D = T.state.formDefinitionVersionId, O = T.state.initiatorPolicyCel, $e = T.state.selectedNodeId, k = T.state.selectedEdgeIds, et = T.state.editingEdgeId, tt = (e) => T.replaceState((t) => ({
721
- ...t,
722
- definition: an(e, t.definition)
723
- })), nt = (e) => T.replaceState((t) => ({
724
- ...t,
725
- formDefinitionVersionId: an(e, t.formDefinitionVersionId)
726
- })), rt = (e) => T.replaceState((t) => ({
727
- ...t,
728
- initiatorPolicyCel: an(e, t.initiatorPolicyCel)
729
- })), A = (e) => T.replaceState((t) => ({
730
- ...t,
731
- selectedNodeId: an(e, t.selectedNodeId)
732
- })), it = (e) => T.replaceState((t) => ({
733
- ...t,
734
- selectedEdgeIds: an(e, t.selectedEdgeIds)
735
- })), at = (e) => T.replaceState((t) => ({
736
- ...t,
737
- editingEdgeId: an(e, t.editingEdgeId)
738
- })), [ot, j] = p(null), [ct, M] = p(!0), [gt, N] = p(!1), [vt, F] = p(!1), [Ot, kt] = p([]), At = d(() => JSON.stringify({
739
- formDefinitionVersionId: D,
740
- initiatorPolicyCel: O,
741
- workflowDefinition: E
742
- }), [
743
- D,
744
- O,
745
- E
746
- ]), I = !!Ae && At !== Ae, [jt, Mt] = p(!1), [L, Nt] = p([]), [R, Pt] = p([]), [z, Ft] = p([]), [It, Lt] = p([]);
747
- Ze.current = R, Qe.current = z;
748
- let [Rt, B] = p(!1), [qt, Jt] = p(!1), [on, V] = p("{}"), [cn, ln] = p(null), [un, dn] = p(null), [H, pn] = p(!1), [mn, hn] = p(!1), [U, vn] = p(null), [yn, Mn] = p(!1), [Fn, Ln] = p(!1), Hn = I || yn ? "保存並發布" : Se ? "發布草稿" : "已發布";
749
- u(() => {
750
- i ? Or() : Ar();
751
- }, [i, ve]), u(() => {
752
- function e(e) {
753
- I && (e.preventDefault(), e.returnValue = "");
754
- }
755
- return window.addEventListener("beforeunload", e), () => {
756
- window.removeEventListener("beforeunload", e);
757
- };
758
- }, [I]), u(() => {
759
- Nr(E);
760
- }, [E, L]), u(() => {
761
- tt((e) => _n(e));
762
- }, [E.edges, E.nodes]);
763
- function Un() {
764
- I && !window.confirm("目前有尚未儲存的流程草稿,確定要離開嗎?") || ye.push(be.templates());
765
- }
766
- let G = d(() => E.nodes.find((e) => e.id === $e) ?? null, [$e, E.nodes]), qn = G ? Vn(G) : !1, Yn = k.length > 0 || qn, K = l(() => {
767
- T.getState().selectedEdgeIds.forEach((e) => T.dispatch({
768
- edgeId: e,
769
- type: "deleteEdge"
770
- })), G && Vn(G) && T.dispatch({
771
- nodeId: G.id,
772
- type: "deleteNode"
773
- });
774
- }, [T, G]);
775
- u(() => {
776
- if (!Yn) return;
777
- function e(e) {
778
- e.key !== "Delete" && e.key !== "Backspace" || Wn(e.target) || (e.preventDefault(), K());
779
- }
780
- return window.addEventListener("keydown", e), () => {
781
- window.removeEventListener("keydown", e);
782
- };
783
- }, [Yn, K]);
784
- let ar = d(() => E.edges.find((e) => e.id === et) ?? null, [et, E.edges]), sr = d(() => k.length === 1 ? E.edges.find((e) => e.id === k[0]) ?? null : null, [k, E.edges]), cr = d(() => k.map((e) => E.edges.find((t) => t.id === e) ?? null).filter((e) => !!e), [k, E.edges]), q = d(() => Ie ?? Nn(O, w), [
785
- O,
786
- Ie,
787
- w
788
- ]), lr = d(() => E.nodes.map((e) => fn(e, L, R, z, e.id === $e, q)), [
789
- q,
790
- L,
791
- R,
792
- z,
793
- $e,
794
- E.nodes
795
- ]), dr = d(() => E.edges.map((e) => gn(e, E.nodes, k.includes(e.id))), [
796
- k,
797
- E.edges,
798
- E.nodes
799
- ]), J = d(() => W(Ot, D) ?? W(Gn(C?.formVersions ?? []), D), [
800
- D,
801
- Ot,
802
- C?.formVersions
803
- ]), mr = d(() => Qn(Ot, J), [Ot, J]), hr = J?.schema ?? null, gr = i ? c ?? null : hr;
804
- u(() => {
805
- T.getState().formSchema !== gr && T.replaceState((e) => ({
806
- ...e,
807
- formSchema: gr
808
- }));
809
- }, [T, gr]);
810
- let _r = d(() => yr(E), [E]), Y = d(() => br(E), [E]), X = d(() => Pn(q), [q]);
811
- u(() => {
812
- i && he?.(E);
813
- }, [i, E]), u(() => {
814
- i && fe?.(O);
815
- }, [i, O]);
816
- async function Or() {
817
- M(!0), j(null);
818
- try {
819
- let e = await Te();
820
- Pt(e.orgUnits), Ft(e.positions), Lt(e.memberships);
821
- } catch (e) {
822
- j(Z(e));
823
- } finally {
824
- M(!1);
825
- }
826
- }
827
- async function Ar() {
828
- M(!0), j(null);
829
- try {
830
- let [e, t] = await Promise.all([Ve(ve), Te()]), n = e.versions.find((e) => e.status === "DRAFT") ?? null, r = n ?? e.versions[0] ?? null;
831
- xe(e), Ce(n), Pt(t.orgUnits), Ft(t.positions), Lt(t.memberships), kt(Gn(e.formVersions));
832
- let i = r?.workflowDefinition ?? bn(), a = r?.formDefinitionVersionId ?? e.formVersions[0]?.id ?? null, o = r?.initiatorPolicyCel ?? null;
833
- tt(i), nt(a), rt(o), Me(JSON.stringify({
834
- formDefinitionVersionId: a,
835
- initiatorPolicyCel: o,
836
- workflowDefinition: i
837
- })), Fe(r && !e.template.currentVersionId && !r.initiatorPolicyCel && xn(r.workflowDefinition) ? "NONE" : null), Ke(null), A(r?.workflowDefinition.nodes[0]?.id ?? "start"), it([]), at(null), vn(null), Mn(!1);
838
- } catch (e) {
839
- j(Z(e));
840
- } finally {
841
- M(!1);
842
- }
843
- }
844
- async function Mr(e) {
845
- F(!0), j(null);
846
- try {
847
- kt(Qn(Gn(await We(e)), J));
848
- } catch (e) {
849
- j(Z(e));
850
- } finally {
851
- F(!1);
852
- }
853
- }
854
- async function Q(e) {
855
- Mt(!0), j(null);
856
- try {
857
- let t = await Ue(e);
858
- Nt((e) => fr(e, $n(t)));
859
- } catch (e) {
860
- j(Z(e));
861
- } finally {
862
- Mt(!1);
863
- }
864
- }
865
- async function Nr(e) {
866
- let t = pr(e).filter((e) => !L.some((t) => t.memberId === e));
867
- if (t.length !== 0) try {
868
- let e = await He(t);
869
- Nt((t) => fr(t, $n(e)));
870
- } catch {
871
- Nt((e) => fr(e, t.map(er)));
872
- }
873
- }
874
- async function Pr(e) {
875
- N(!0), j(null);
876
- try {
877
- let t = yr(E), n = Pn(q);
878
- if (t || n) {
879
- let e = t ?? n ?? "流程設定未完成";
880
- throw j(e), Error(e);
881
- }
882
- if (yn && U !== null) await Le({
883
- category: C?.template.category ?? null,
884
- categoryId: C?.template.categoryId ?? null,
885
- formDefinitionId: J?.formDefinitionId ?? null,
886
- formDescription: null,
887
- formName: J?.formName ?? C?.template.name ?? "表單",
888
- initiatorPolicyCel: O,
889
- notificationConfig: null,
890
- publish: e,
891
- schema: U.schema,
892
- slaDefaults: null,
893
- templateDescription: null,
894
- templateId: ve ?? null,
895
- templateName: C?.template.name ?? "模板",
896
- uiSchema: U.uiSchema,
897
- workflowDefinition: E
898
- }), Mn(!1), vn(null), await Ar();
899
- else {
900
- let t = await Ge({
901
- formDefinitionVersionId: D,
902
- initiatorPolicyCel: O,
903
- versionId: (Se ?? await ze(ve)).id,
904
- workflowDefinition: E
905
- });
906
- Ce(t), e && await Be(t.id), await Ar();
907
- }
908
- } catch (e) {
909
- throw j(Z(e)), e;
910
- } finally {
911
- N(!1);
912
- }
913
- }
914
- async function Fr() {
915
- await Pr(!1);
916
- }
917
- async function Ir() {
918
- await Pr(!0);
919
- }
920
- function Lr() {
921
- V(JSON.stringify(Kn(J), null, 2)), ln(null), dn(null), B(!0);
922
- }
923
- function Rr() {
924
- qt || B(!1);
925
- }
926
- async function zr() {
927
- Jt(!0), dn(null), ln(null);
928
- try {
929
- ln(await Re({
930
- formData: Jn(on),
931
- initiatorMemberId: Zt,
932
- initiatorMetadataSnapshot: or(Zt, It),
933
- workflowDefinition: E
934
- }));
935
- } catch (e) {
936
- dn(Z(e));
937
- } finally {
938
- Jt(!1);
939
- }
940
- }
941
- async function Br() {
942
- if (hn(!0), U !== null) return;
943
- let e = J?.formDefinitionId ?? null;
944
- if (!e) {
945
- vn({
946
- schema: tn,
947
- uiSchema: nn
948
- });
949
- return;
950
- }
951
- Ln(!0);
952
- try {
953
- let t = await we(e), n = t.versions.find((e) => e.status === "DRAFT") ?? t.versions.find((e) => e.id === t.definition.currentVersionId) ?? t.versions[0] ?? null;
954
- vn({
955
- schema: n?.schema ?? tn,
956
- uiSchema: n?.uiSchema ?? nn
957
- });
958
- } catch (e) {
959
- j(Z(e));
960
- } finally {
961
- Ln(!1);
962
- }
963
- }
964
- function Vr(e) {
965
- let t = Pe(e, lr);
966
- tt((e) => ({
967
- ...e,
968
- nodes: e.nodes.map((e) => {
969
- let n = t.find((t) => t.id === e.id);
970
- return n ? {
971
- ...e,
972
- position: n.position
973
- } : e;
974
- })
975
- }));
976
- }
977
- function Hr(e) {
978
- !zn(e, E.nodes) || !e.source || !e.target || T.dispatch({
979
- source: e.source,
980
- target: e.target,
981
- type: "connectEdge"
982
- });
983
- }
984
- function Ur(e, t) {
985
- e.stopPropagation(), it((n) => e.shiftKey || e.metaKey || e.ctrlKey ? Bn(n, t.id) : [t.id]), A(null);
986
- }
987
- function Wr() {
988
- at(null);
989
- }
990
- function Gr(e) {
991
- T.dispatch({
992
- nodeType: e,
993
- type: "addNode"
994
- });
995
- }
996
- function Kr(e) {
997
- G && T.dispatch({
998
- label: e,
999
- nodeId: G.id,
1000
- type: "renameNode"
1001
- });
1002
- }
1003
- function $(e) {
1004
- !G || G.type !== "userTask" || T.dispatch({
1005
- approverResolver: e,
1006
- nodeId: G.id,
1007
- type: "setUserTaskApprover"
1008
- });
1009
- }
1010
- function qr(e) {
1011
- !G || G.type !== "userTask" || T.dispatch({
1012
- nodeId: G.id,
1013
- resubmitStrategy: e,
1014
- type: "setUserTaskReturnResubmitStrategy"
1015
- });
1016
- }
1017
- function Jr(e) {
1018
- !G || G.type !== "serviceTask" || T.dispatch({
1019
- action: e,
1020
- nodeId: G.id,
1021
- type: "setServiceAction"
1022
- });
1023
- }
1024
- function Yr(e) {
1025
- Ke(e.mode === "ALL" || e.mode === "CUSTOM" ? null : e), Fe(e.mode === "ALL" || e.mode === "CUSTOM" ? null : e.mode), rt(In(e, R));
1026
- }
1027
- function Xr(e) {
1028
- !G || G.type === "startEvent" || T.dispatch({
1029
- nodeId: G.id,
1030
- triggerMode: e,
1031
- type: "setNodeTriggerMode"
1032
- });
1033
- }
1034
- function Zr(e, t) {
1035
- T.dispatch({
1036
- edgeId: e,
1037
- isDefault: t,
1038
- type: "setEdgeDefault"
1039
- });
1040
- }
1041
- function Qr({ edgeId: e, fieldKey: t, operator: n, value: r }) {
1042
- T.dispatch({
1043
- edgeId: e,
1044
- fieldKey: t,
1045
- operator: n,
1046
- type: "setEdgeCondition",
1047
- value: r
1048
- });
1049
- }
1050
- function $r() {
1051
- T.dispatch({ type: "autoLayout" });
1052
- }
1053
- return /* @__PURE__ */ S(b, { children: [
1054
- /* @__PURE__ */ x("style", { children: ht }),
1055
- i ? null : /* @__PURE__ */ x(te, { children: /* @__PURE__ */ S(se, {
1056
- description: `${Se ? `草稿 v${Se.version}` : "尚未建立草稿"} ·${C?.template.currentVersionId ? " 已發布版本" : " 尚未發布"}`,
1057
- onBackClick: Un,
1058
- title: C?.template.name ?? "流程設計器",
1059
- children: [
1060
- ge ? /* @__PURE__ */ x(h, {
1061
- disabled: !n,
1062
- onClick: () => pn((e) => !e),
1063
- variant: H ? "base-primary" : "base-secondary",
1064
- children: n ? "AI 助理" : "AI 助理(未設定)"
1065
- }) : null,
1066
- /* @__PURE__ */ x(h, {
1067
- "aria-label": "儲存草稿",
1068
- disabled: gt || !!_r || !!X,
1069
- icon: pe,
1070
- iconType: "icon-only",
1071
- onClick: () => void Fr(),
1072
- variant: "base-secondary",
1073
- children: "儲存草稿"
1074
- }),
1075
- _e ? /* @__PURE__ */ x(h, {
1076
- disabled: ct || !!_r || !!X,
1077
- icon: ue,
1078
- iconType: "leading",
1079
- onClick: Lr,
1080
- variant: "base-secondary",
1081
- children: "試跑流程"
1082
- }) : null,
1083
- /* @__PURE__ */ x(h, {
1084
- disabled: gt || !Se && !I && !yn || !!_r || !!X,
1085
- icon: ce,
1086
- iconType: "leading",
1087
- onClick: () => void Ir(),
1088
- variant: "base-primary",
1089
- children: Hn
1090
- })
1091
- ]
1092
- }) }),
1093
- /* @__PURE__ */ x(re, { children: /* @__PURE__ */ x(ne, { children: /* @__PURE__ */ S("div", {
1094
- style: lt,
1095
- children: [
1096
- ot ? /* @__PURE__ */ x(y, {
1097
- color: "text-error",
1098
- variant: "body",
1099
- children: ot
1100
- }) : null,
1101
- _r ? /* @__PURE__ */ x(y, {
1102
- color: "text-error",
1103
- variant: "body",
1104
- children: _r
1105
- }) : null,
1106
- X ? /* @__PURE__ */ x(y, {
1107
- color: "text-error",
1108
- variant: "body",
1109
- children: X
1110
- }) : null,
1111
- i ? null : /* @__PURE__ */ x("div", {
1112
- style: P,
1113
- children: /* @__PURE__ */ x(o, {
1114
- hintText: Y ? "已設定條件分流條件。請先移除所有條件,才能更換綁定表單版本。" : void 0,
1115
- label: "綁定表單版本",
1116
- name: "formDefinitionVersionId",
1117
- required: !0,
1118
- children: /* @__PURE__ */ S("div", {
1119
- style: wt,
1120
- children: [/* @__PURE__ */ x("div", {
1121
- style: Tt,
1122
- children: /* @__PURE__ */ x(m, {
1123
- asyncData: !0,
1124
- disabled: ct || Y,
1125
- disabledOptionsFilter: !0,
1126
- emptyText: "沒有符合的已發布表單版本",
1127
- isForceClearable: !!D && !Y,
1128
- loading: vt,
1129
- loadingText: "搜尋表單版本中...",
1130
- mode: "single",
1131
- onChange: (e) => {
1132
- Y || nt(e?.id ?? null);
1133
- },
1134
- onClear: () => {
1135
- Y || nt(null);
1136
- },
1137
- onSearch: Mr,
1138
- onVisibilityChange: (e) => {
1139
- e && !Y && Mr("");
1140
- },
1141
- options: [...mr],
1142
- placeholder: "選擇已發布表單版本",
1143
- searchDebounceTime: 300,
1144
- value: J
1145
- })
1146
- }), /* @__PURE__ */ x(h, {
1147
- disabled: ct,
1148
- onClick: () => {
1149
- Br();
1150
- },
1151
- style: Et,
1152
- variant: "base-secondary",
1153
- children: "編輯表單"
1154
- })]
1155
- })
1156
- })
1157
- }),
1158
- /* @__PURE__ */ S("div", {
1159
- style: ut,
1160
- children: [/* @__PURE__ */ x("div", {
1161
- ref: Je,
1162
- style: dt,
1163
- children: /* @__PURE__ */ S(Ne, {
1164
- connectionMode: De.Strict,
1165
- edges: dr,
1166
- fitView: !0,
1167
- isValidConnection: (e) => zn(e, E.nodes),
1168
- nodeTypes: rn,
1169
- nodes: lr,
1170
- deleteKeyCode: null,
1171
- multiSelectionKeyCode: [
1172
- "Shift",
1173
- "Meta",
1174
- "Control"
1175
- ],
1176
- onConnect: Hr,
1177
- onEdgeClick: Ur,
1178
- onNodeClick: (e, t) => {
1179
- A(t.id), it([]);
1180
- },
1181
- onNodesChange: Vr,
1182
- onPaneClick: () => {
1183
- A(null), it([]);
1184
- },
1185
- onViewportChange: Xe,
1186
- viewport: Ye,
1187
- children: [
1188
- /* @__PURE__ */ x(Ee, {}),
1189
- /* @__PURE__ */ x("style", { children: yt }),
1190
- /* @__PURE__ */ x(ke, { children: Yn ? /* @__PURE__ */ x(Oe, {
1191
- "aria-label": "刪除選取項目",
1192
- className: "workflow-selection-delete-control",
1193
- onClick: K,
1194
- style: ft,
1195
- title: "刪除選取項目",
1196
- children: /* @__PURE__ */ x("span", {
1197
- style: pt,
1198
- children: /* @__PURE__ */ x(ee, {
1199
- color: "error",
1200
- icon: me,
1201
- size: 16
1202
- })
1203
- })
1204
- }) : null }),
1205
- /* @__PURE__ */ x(sn, { onApplyAutoLayout: $r }),
1206
- /* @__PURE__ */ x(je, {})
1207
- ]
1208
- })
1209
- }), /* @__PURE__ */ S("div", {
1210
- className: mt,
1211
- style: bt,
1212
- children: [
1213
- /* @__PURE__ */ x(y, {
1214
- component: "h2",
1215
- variant: "h3",
1216
- children: "流程工具"
1217
- }),
1218
- i && ge ? /* @__PURE__ */ S("div", {
1219
- style: Dt,
1220
- children: [/* @__PURE__ */ x(y, {
1221
- color: "text-neutral",
1222
- variant: "caption",
1223
- children: "AI 協助"
1224
- }), /* @__PURE__ */ x("div", {
1225
- style: Ct,
1226
- children: /* @__PURE__ */ x(h, {
1227
- disabled: !n,
1228
- onClick: () => pn((e) => !e),
1229
- size: "sub",
1230
- variant: H ? "base-primary" : "base-secondary",
1231
- children: n ? "AI 助理" : "AI 助理(未設定)"
1232
- })
1233
- })]
1234
- }) : null,
1235
- /* @__PURE__ */ S("div", {
1236
- style: Dt,
1237
- children: [/* @__PURE__ */ x(y, {
1238
- color: "text-neutral",
1239
- variant: "caption",
1240
- children: "動作節點"
1241
- }), /* @__PURE__ */ x("div", {
1242
- style: Ct,
1243
- children: Bt.map((e) => /* @__PURE__ */ x(h, {
1244
- icon: e.icon,
1245
- iconType: "leading",
1246
- onClick: () => Gr(e.type),
1247
- size: "sub",
1248
- variant: "base-secondary",
1249
- children: e.label
1250
- }, e.type))
1251
- })]
1252
- }),
1253
- /* @__PURE__ */ S("div", {
1254
- style: Dt,
1255
- children: [/* @__PURE__ */ x(y, {
1256
- color: "text-neutral",
1257
- variant: "caption",
1258
- children: "流程控制"
1259
- }), /* @__PURE__ */ x("div", {
1260
- style: Ct,
1261
- children: Vt.map((e) => /* @__PURE__ */ x(h, {
1262
- icon: e.icon,
1263
- iconType: "leading",
1264
- onClick: () => Gr(e.type),
1265
- size: "sub",
1266
- variant: "base-secondary",
1267
- children: e.label
1268
- }, e.type))
1269
- })]
1270
- }),
1271
- cr.length > 1 ? oi(cr) : null,
1272
- cr.length === 1 && sr ? si(sr) : null,
1273
- cr.length === 0 && G ? ti(G) : null
1274
- ]
1275
- })]
1276
- })
1277
- ]
1278
- }) }) }),
1279
- ci(ar),
1280
- !i && _e ? ei() : null,
1281
- ge && n ? /* @__PURE__ */ x(st, {
1282
- controller: T,
1283
- onClose: () => pn(!1),
1284
- open: H
1285
- }) : null,
1286
- i ? null : /* @__PURE__ */ x(oe, {
1287
- headerTitle: "編輯表單",
1288
- isHeaderDisplay: !0,
1289
- onClose: () => hn(!1),
1290
- open: mn,
1291
- size: "wide",
1292
- children: /* @__PURE__ */ S("div", {
1293
- style: Qt,
1294
- children: [/* @__PURE__ */ x("div", {
1295
- style: $t,
1296
- children: Fn ? /* @__PURE__ */ x(y, {
1297
- color: "text-neutral",
1298
- variant: "body",
1299
- children: "載入中…"
1300
- }) : /* @__PURE__ */ x(s, {
1301
- onChange: (e) => {
1302
- vn(e);
1303
- },
1304
- value: U ?? {
1305
- schema: tn,
1306
- uiSchema: nn
1307
- }
1308
- })
1309
- }), /* @__PURE__ */ S("div", {
1310
- style: en,
1311
- children: [/* @__PURE__ */ x(h, {
1312
- disabled: Fn,
1313
- onClick: () => {
1314
- U !== null && (Mn(!0), T.replaceState((e) => ({
1315
- ...e,
1316
- formSchema: U.schema
1317
- }))), hn(!1);
1318
- },
1319
- variant: "base-primary",
1320
- children: "套用"
1321
- }), /* @__PURE__ */ x(h, {
1322
- onClick: () => hn(!1),
1323
- variant: "base-secondary",
1324
- children: "取消"
1325
- })]
1326
- })]
1327
- })
1328
- })
1329
- ] });
1330
- function ei() {
1331
- return /* @__PURE__ */ x(_, {
1332
- cancelText: "關閉",
1333
- confirmText: "執行試跑",
1334
- loading: qt,
1335
- modalType: "standard",
1336
- onCancel: Rr,
1337
- onClose: Rr,
1338
- onConfirm: () => void zr(),
1339
- open: Rt,
1340
- showModalFooter: !0,
1341
- showModalHeader: !0,
1342
- size: "wide",
1343
- supportingText: `使用 ${Zt} 與範例表單資料模擬目前畫布流程,不會建立案件。`,
1344
- title: "試跑流程",
1345
- children: /* @__PURE__ */ S("div", {
1346
- style: P,
1347
- children: [
1348
- /* @__PURE__ */ x(o, {
1349
- label: "表單資料 JSON",
1350
- name: "dryRunFormDataJson",
1351
- required: !0,
1352
- children: /* @__PURE__ */ x(ie, {
1353
- onChange: (e) => V(e.target.value),
1354
- resize: "vertical",
1355
- rows: 8,
1356
- value: on
1357
- })
1358
- }),
1359
- un ? /* @__PURE__ */ x(y, {
1360
- color: "text-error",
1361
- variant: "body",
1362
- children: un
1363
- }) : null,
1364
- cn ? /* @__PURE__ */ S("div", {
1365
- style: xt,
1366
- children: [
1367
- /* @__PURE__ */ x(y, {
1368
- color: cn.valid ? "text-success" : "text-error",
1369
- variant: "label-primary-highlight",
1370
- children: cn.valid ? "試跑通過" : "試跑失敗"
1371
- }),
1372
- cn.errors.map((e) => /* @__PURE__ */ x(y, {
1373
- color: "text-error",
1374
- variant: "body",
1375
- children: e
1376
- }, e)),
1377
- cn.steps.map((e) => /* @__PURE__ */ S("div", {
1378
- style: St,
1379
- children: [
1380
- /* @__PURE__ */ S(y, {
1381
- variant: "label-primary-highlight",
1382
- children: [
1383
- e.nodeLabel,
1384
- " · ",
1385
- Xn(e.status)
1386
- ]
1387
- }),
1388
- /* @__PURE__ */ S(y, {
1389
- color: "text-neutral",
1390
- variant: "caption",
1391
- children: [
1392
- Zn(e.nodeType),
1393
- e.assigneeMemberId ? ` · 處理者:${e.assigneeMemberId}` : "",
1394
- e.edgeLabel ? ` · 來源線段:${e.edgeLabel}` : ""
1395
- ]
1396
- }),
1397
- e.edgeReason ? /* @__PURE__ */ x(y, {
1398
- color: "text-neutral",
1399
- variant: "caption",
1400
- children: e.edgeReason
1401
- }) : null,
1402
- e.entryCondition ? /* @__PURE__ */ S(y, {
1403
- color: "text-neutral",
1404
- variant: "caption",
1405
- children: [
1406
- "進入條件:",
1407
- e.entryConditionMatched ? "符合" : "不符合",
1408
- " ·",
1409
- " ",
1410
- e.entryCondition
1411
- ]
1412
- }) : null,
1413
- /* @__PURE__ */ x(y, {
1414
- color: "text-neutral",
1415
- variant: "body",
1416
- children: e.message
1417
- })
1418
- ]
1419
- }, e.id))
1420
- ]
1421
- }) : null
1422
- ]
1423
- })
1424
- });
1425
- }
1426
- function ti(e) {
1427
- return /* @__PURE__ */ S("div", {
1428
- style: P,
1429
- children: [
1430
- /* @__PURE__ */ x(y, {
1431
- component: "h2",
1432
- variant: "h3",
1433
- children: "節點屬性"
1434
- }),
1435
- /* @__PURE__ */ S(y, {
1436
- color: "text-neutral",
1437
- variant: "body",
1438
- children: [
1439
- zt[e.type],
1440
- " · ",
1441
- e.id
1442
- ]
1443
- }),
1444
- /* @__PURE__ */ x(o, {
1445
- label: "顯示名稱",
1446
- name: "nodeLabel",
1447
- required: !0,
1448
- children: /* @__PURE__ */ x(g, {
1449
- onChange: (e) => Kr(e.target.value),
1450
- value: e.data.label,
1451
- variant: "base"
1452
- })
1453
- }),
1454
- e.type === "startEvent" ? ni() : null,
1455
- e.type === "startEvent" ? null : ri(e),
1456
- e.type === "userTask" ? ii(e) : null,
1457
- e.type === "serviceTask" ? ai(e) : null
1458
- ]
1459
- });
1460
- }
1461
- function ni() {
1462
- let e = q.mode === "CUSTOM" ? [...Yt, Xt] : [...Yt], t = q.mode === "ORG_UNIT" || q.mode === "ORG_UNIT_POSITION" ? rr(R, q.orgUnitId ?? "") : null, n = q.mode === "ORG_UNIT_POSITION" ? ir(z, q.positionId ?? "") : null, i = q.mode === "ORG_UNIT_POSITION" ? ur({
1463
- includeDescendants: !!q.includeDescendants,
1464
- memberships: It,
1465
- orgUnitId: q.orgUnitId ?? "",
1466
- orgUnits: R,
1467
- positions: z
1468
- }) : [];
1469
- return /* @__PURE__ */ S(b, { children: [
1470
- /* @__PURE__ */ x(o, {
1471
- hintText: q.mode === "CUSTOM" ? "這是舊版表達式規則;切換成標準選項後會改由 UI 管理。" : void 0,
1472
- label: "發起權限",
1473
- name: "initiatorPolicyMode",
1474
- required: !0,
1475
- children: /* @__PURE__ */ x(v, {
1476
- clearable: !1,
1477
- onChange: (e) => {
1478
- if (e?.id === "CUSTOM") {
1479
- Fe(null), Ke(null);
1480
- return;
1481
- }
1482
- let t = jn(e?.id ?? null), n = Rn(t);
1483
- Fe(t === "ALL" ? null : t), Ke(t === "ALL" ? null : n), rt(In(n, R));
1484
- },
1485
- options: e,
1486
- placeholder: "選擇誰可以發起",
1487
- value: W(e, q.mode)
1488
- })
1489
- }),
1490
- q.mode === "ORG_UNIT" || q.mode === "ORG_UNIT_POSITION" ? /* @__PURE__ */ x(o, {
1491
- label: "組織",
1492
- name: "initiatorOrgUnitId",
1493
- required: !0,
1494
- children: /* @__PURE__ */ x(r, {
1495
- name: "initiatorOrgUnitId",
1496
- onChange: (e) => Yr({
1497
- ...q,
1498
- orgUnitId: e?.id ?? "",
1499
- positionId: "",
1500
- value: e?.id ?? ""
1501
- }),
1502
- orgUnits: R,
1503
- placeholder: "選擇組織",
1504
- value: t
1505
- })
1506
- }) : null,
1507
- q.mode === "ORG_UNIT" || q.mode === "ORG_UNIT_POSITION" ? /* @__PURE__ */ x(o, {
1508
- label: "包含下層",
1509
- name: "initiatorIncludeDescendants",
1510
- children: /* @__PURE__ */ x(ae, {
1511
- checked: !!q.includeDescendants,
1512
- onChange: (e) => Yr({
1513
- ...q,
1514
- includeDescendants: e.target.checked,
1515
- ...q.mode === "ORG_UNIT_POSITION" ? { positionId: "" } : {}
1516
- })
1517
- })
1518
- }) : null,
1519
- q.mode === "ORG_UNIT_POSITION" ? /* @__PURE__ */ x(o, {
1520
- label: "職位",
1521
- name: "initiatorPositionId",
1522
- required: !0,
1523
- children: /* @__PURE__ */ x(a, {
1524
- disabled: !q.orgUnitId?.trim(),
1525
- name: "initiatorPositionId",
1526
- onChange: (e) => Yr({
1527
- ...q,
1528
- positionId: e?.id ?? ""
1529
- }),
1530
- placeholder: q.orgUnitId?.trim() ? "選擇職位" : "請先選擇組織",
1531
- positions: i,
1532
- value: n
1533
- })
1534
- }) : null
1535
- ] });
1536
- }
1537
- function ri(e) {
1538
- let t = E.edges.filter((t) => t.target === e.id).length, n = t < 2, r = n ? "AND" : e.data.triggerMode ?? "AND";
1539
- return /* @__PURE__ */ x(o, {
1540
- hintText: n ? "需要至少兩條前置連線,才可切換為任一前置完成。" : t > 1 ? `${t} 條前置連線會依此規則觸發。` : "只有一條前置連線時,兩種設定效果相同。",
1541
- label: "前置條件",
1542
- name: "triggerMode",
1543
- required: !0,
1544
- children: /* @__PURE__ */ x(v, {
1545
- clearable: !1,
1546
- onChange: (e) => n ? void 0 : Xr(Cn(e?.id ?? null)),
1547
- options: [...Ht],
1548
- readOnly: n,
1549
- value: W(Ht, r)
1550
- })
1551
- });
1552
- }
1553
- function ii(e) {
1554
- let t = e.data.approverResolver, n = Tn(t.type), i = t.type === "DIRECT" ? nr(t.memberIds, L) : null, s = t.type === "ORG_UNIT_MANAGER" || t.type === "ORG_UNIT_MEMBER" || t.type === "ORG_UNIT_POSITION" ? rr(R, t.orgUnitId) : null, c = t.type === "POSITION" || t.type === "ORG_UNIT_POSITION" ? ir(z, t.positionId) : null, l = t.type === "ORG_UNIT_POSITION" ? ur({
1555
- includeDescendants: !!t.includeDescendants,
1556
- memberships: It,
1557
- orgUnitId: t.orgUnitId,
1558
- orgUnits: R,
1559
- positions: z
1560
- }) : [], u = t.type === "ORG_MANAGER" ? kn(t.levelsUp) : Gt[0], d = t.type === "ORG_MANAGER" || t.type === "ORG_UNIT_MANAGER" ? t.fallback ?? { type: "NONE" } : { type: "NONE" }, f = d.type === "DIRECT" ? tr(L, d.memberId) : null, p = e.data.returnBehavior.resubmitStrategy ?? "RESTART";
1561
- return /* @__PURE__ */ S(b, { children: [
1562
- /* @__PURE__ */ x(o, {
1563
- label: "簽核來源",
1564
- name: "approverResolverType",
1565
- required: !0,
1566
- children: /* @__PURE__ */ x(v, {
1567
- clearable: !1,
1568
- onChange: (e) => $(En(e?.id ?? null)),
1569
- options: [...Wt],
1570
- value: W(Wt, n)
1571
- })
1572
- }),
1573
- t.type === "DIRECT" ? /* @__PURE__ */ x(o, {
1574
- label: "簽核者",
1575
- name: "memberId",
1576
- required: !0,
1577
- children: /* @__PURE__ */ x(m, {
1578
- asyncData: !0,
1579
- disabledOptionsFilter: !0,
1580
- emptyText: "沒有符合的成員",
1581
- inputProps: {
1582
- autoCapitalize: "none",
1583
- autoCorrect: "off",
1584
- name: "workflow-approver-search",
1585
- spellCheck: !1
1586
- },
1587
- loading: jt,
1588
- loadingText: "搜尋成員中...",
1589
- mode: "single",
1590
- onChange: (e) => $({
1591
- memberIds: e?.id ? [e.id] : [],
1592
- type: "DIRECT"
1593
- }),
1594
- onSearch: Q,
1595
- onVisibilityChange: (e) => {
1596
- e && Q("");
1597
- },
1598
- options: [...L],
1599
- placeholder: "搜尋姓名或信箱",
1600
- searchDebounceTime: 300,
1601
- value: i
1602
- })
1603
- }) : null,
1604
- t.type === "ORG_MANAGER" ? /* @__PURE__ */ x(o, {
1605
- hintText: "依發起人的有效會員歸屬與主管解析規則決定簽核人。",
1606
- label: "主管層級",
1607
- name: "managerLevelsUp",
1608
- required: !0,
1609
- children: /* @__PURE__ */ x(v, {
1610
- clearable: !1,
1611
- onChange: (e) => $({
1612
- baseFromInitiator: !0,
1613
- levelsUp: An(e?.id ?? null).value,
1614
- type: "ORG_MANAGER"
1615
- }),
1616
- options: [...Gt],
1617
- value: u
1618
- })
1619
- }) : null,
1620
- t.type === "ORG_UNIT_MANAGER" || t.type === "ORG_UNIT_MEMBER" || t.type === "ORG_UNIT_POSITION" ? /* @__PURE__ */ x(o, {
1621
- hintText: t.type === "ORG_UNIT_MANAGER" ? "依指定組織或其上層的主管解析規則決定簽核人。" : "依指定組織目前有效會員歸屬建立候選簽核人。",
1622
- label: "組織",
1623
- name: "orgUnitId",
1624
- required: !0,
1625
- children: /* @__PURE__ */ x(r, {
1626
- name: "orgUnitId",
1627
- onChange: (e) => $(t.type === "ORG_UNIT_MEMBER" ? {
1628
- includeDescendants: t.includeDescendants,
1629
- orgUnitId: e?.id ?? "",
1630
- type: "ORG_UNIT_MEMBER"
1631
- } : t.type === "ORG_UNIT_POSITION" ? {
1632
- includeDescendants: t.includeDescendants,
1633
- orgUnitId: e?.id ?? "",
1634
- positionId: "",
1635
- type: "ORG_UNIT_POSITION"
1636
- } : {
1637
- fallback: t.fallback,
1638
- orgUnitId: e?.id ?? "",
1639
- type: "ORG_UNIT_MANAGER"
1640
- }),
1641
- orgUnits: R,
1642
- placeholder: "選擇組織",
1643
- value: s
1644
- })
1645
- }) : null,
1646
- t.type === "ORG_MANAGER" || t.type === "ORG_UNIT_MANAGER" ? /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x(o, {
1647
- hintText: "預設會停止流程並提示;若設定固定人,找不到主管時會改派給該會員。",
1648
- label: "無主管時",
1649
- name: "approverFallbackMode",
1650
- required: !0,
1651
- children: /* @__PURE__ */ x(v, {
1652
- clearable: !1,
1653
- onChange: (e) => $(On(t, Dn(e?.id ?? null) === "DIRECT" ? {
1654
- memberId: "",
1655
- type: "DIRECT"
1656
- } : { type: "NONE" })),
1657
- options: [...Kt],
1658
- value: W(Kt, d.type)
1659
- })
1660
- }), d.type === "DIRECT" ? /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x(o, {
1661
- label: "改派人員",
1662
- name: "approverFallbackMemberId",
1663
- required: !0,
1664
- children: /* @__PURE__ */ x(m, {
1665
- asyncData: !0,
1666
- disabledOptionsFilter: !0,
1667
- emptyText: "沒有符合的成員",
1668
- inputProps: {
1669
- autoCapitalize: "none",
1670
- autoCorrect: "off",
1671
- name: "workflow-approver-fallback-search",
1672
- spellCheck: !1
1673
- },
1674
- loading: jt,
1675
- loadingText: "搜尋成員中...",
1676
- mode: "single",
1677
- onChange: (e) => $(On(t, {
1678
- allowInitiatorSelfApproval: d.allowInitiatorSelfApproval,
1679
- memberId: e?.id ?? "",
1680
- type: "DIRECT"
1681
- })),
1682
- onSearch: Q,
1683
- onVisibilityChange: (e) => {
1684
- e && Q("");
1685
- },
1686
- options: [...L],
1687
- placeholder: "搜尋姓名或信箱",
1688
- searchDebounceTime: 300,
1689
- value: f
1690
- })
1691
- }), /* @__PURE__ */ x(o, {
1692
- hintText: "預設禁止申請人簽自己的案件;只有此流程允許自簽時才開啟。",
1693
- label: "允許自簽",
1694
- name: "allowInitiatorSelfApproval",
1695
- children: /* @__PURE__ */ x(ae, {
1696
- checked: !!d.allowInitiatorSelfApproval,
1697
- onChange: (e) => $(On(t, {
1698
- allowInitiatorSelfApproval: e.target.checked,
1699
- memberId: d.memberId,
1700
- type: "DIRECT"
1701
- }))
1702
- })
1703
- })] }) : null] }) : null,
1704
- t.type === "ORG_UNIT_MEMBER" || t.type === "ORG_UNIT_POSITION" ? /* @__PURE__ */ x(o, {
1705
- label: "包含下層",
1706
- name: "includeDescendants",
1707
- children: /* @__PURE__ */ x(ae, {
1708
- checked: !!t.includeDescendants,
1709
- onChange: (e) => $({
1710
- ...t,
1711
- includeDescendants: e.target.checked,
1712
- ...t.type === "ORG_UNIT_POSITION" ? { positionId: "" } : {}
1713
- })
1714
- })
1715
- }) : null,
1716
- t.type === "POSITION" ? /* @__PURE__ */ x(o, {
1717
- hintText: "指派給目前有效歸屬中擁有此職位的會員;主要歸屬優先。",
1718
- label: "職位",
1719
- name: "positionId",
1720
- required: !0,
1721
- children: /* @__PURE__ */ x(a, {
1722
- name: "positionId",
1723
- onChange: (e) => $({
1724
- positionId: e?.id ?? "",
1725
- type: "POSITION"
1726
- }),
1727
- placeholder: "選擇職位",
1728
- positions: z,
1729
- value: c
1730
- })
1731
- }) : null,
1732
- t.type === "ORG_UNIT_POSITION" ? /* @__PURE__ */ x(o, {
1733
- hintText: "只納入指定組織範圍內擁有此職位的有效會員。",
1734
- label: "職位",
1735
- name: "orgUnitPositionId",
1736
- required: !0,
1737
- children: /* @__PURE__ */ x(a, {
1738
- disabled: !t.orgUnitId.trim(),
1739
- name: "orgUnitPositionId",
1740
- onChange: (e) => $({
1741
- includeDescendants: t.includeDescendants,
1742
- orgUnitId: t.orgUnitId,
1743
- positionId: e?.id ?? "",
1744
- type: "ORG_UNIT_POSITION"
1745
- }),
1746
- placeholder: t.orgUnitId.trim() ? "選擇職位" : "請先選擇組織",
1747
- positions: l,
1748
- value: c
1749
- })
1750
- }) : null,
1751
- e.data.returnBehavior.allowReturn ? /* @__PURE__ */ x(o, {
1752
- hintText: "退回發起人後,重新送出時要從流程開始重跑,或直接回到退回的簽核節點。",
1753
- label: "重送策略",
1754
- name: "returnResubmitStrategy",
1755
- required: !0,
1756
- children: /* @__PURE__ */ x(v, {
1757
- clearable: !1,
1758
- onChange: (e) => qr(wn(e?.id ?? null)),
1759
- options: [...Ut],
1760
- value: W(Ut, p)
1761
- })
1762
- }) : null
1763
- ] });
1764
- }
1765
- function ai(e) {
1766
- let t = jr(e.data.action).map((e) => tr(L, e));
1767
- return /* @__PURE__ */ x(o, {
1768
- label: "知會對象",
1769
- name: "notifyMemberIds",
1770
- required: !0,
1771
- children: /* @__PURE__ */ x(m, {
1772
- asyncData: !0,
1773
- disabledOptionsFilter: !0,
1774
- emptyText: "沒有符合的成員",
1775
- loading: jt,
1776
- loadingText: "搜尋成員中...",
1777
- mode: "multiple",
1778
- onChange: (e) => Jr({
1779
- channels: ["IN_APP"],
1780
- recipients: {
1781
- memberIds: e.map((e) => e.id),
1782
- type: "DIRECT"
1783
- },
1784
- type: "NOTIFY"
1785
- }),
1786
- onSearch: Q,
1787
- onVisibilityChange: (e) => {
1788
- e && Q("");
1789
- },
1790
- options: [...L],
1791
- overflowStrategy: "wrap",
1792
- placeholder: "搜尋姓名或信箱",
1793
- searchDebounceTime: 300,
1794
- value: [...t]
1795
- })
1796
- });
1797
- }
1798
- function oi(e) {
1799
- return /* @__PURE__ */ S("div", {
1800
- style: P,
1801
- children: [/* @__PURE__ */ x(y, {
1802
- component: "h2",
1803
- variant: "h3",
1804
- children: "已選取線段"
1805
- }), /* @__PURE__ */ S(y, {
1806
- color: "text-neutral",
1807
- variant: "body",
1808
- children: [
1809
- "已選取 ",
1810
- e.length,
1811
- " 條線段,可使用 Delete 或控制面板刪除。"
1812
- ]
1813
- })]
1814
- });
1815
- }
1816
- function si(e) {
1817
- let t = kr(e, E.nodes);
1818
- return /* @__PURE__ */ S("div", {
1819
- style: P,
1820
- children: [
1821
- /* @__PURE__ */ x(y, {
1822
- component: "h2",
1823
- variant: "h3",
1824
- children: t ? "條件設定" : "線段屬性"
1825
- }),
1826
- /* @__PURE__ */ S(y, {
1827
- color: "text-neutral",
1828
- variant: "body",
1829
- children: [
1830
- e.source,
1831
- " → ",
1832
- e.target
1833
- ]
1834
- }),
1835
- t ? li(e) : /* @__PURE__ */ x(y, {
1836
- color: "text-neutral",
1837
- variant: "body",
1838
- children: "這條線會直接把流程送到下一個節點。"
1839
- })
1840
- ]
1841
- });
1842
- }
1843
- function ci(e) {
1844
- return !e || !kr(e, E.nodes) ? null : /* @__PURE__ */ x(_, {
1845
- cancelText: "取消",
1846
- confirmButtonProps: { disabled: !e.data.isDefault && !e.data.condition },
1847
- confirmText: "完成",
1848
- modalType: "standard",
1849
- onCancel: Wr,
1850
- onClose: Wr,
1851
- onConfirm: Wr,
1852
- open: !!et,
1853
- showModalFooter: !0,
1854
- showModalHeader: !0,
1855
- size: "regular",
1856
- supportingText: "條件分流的輸出連線需要指定條件,條件會直接顯示在線上。",
1857
- title: "條件設定",
1858
- children: li(e)
1859
- });
1860
- }
1861
- function li(e) {
1862
- let t = Dr(e, E.nodes), n = xr(J?.schema ?? null), r = Sr(J?.schema ?? null, e.data.conditionFieldKey ?? null), i = Cr(r), a = Tr(r), s = W(i, e.data.conditionOperator ?? null);
1863
- return /* @__PURE__ */ S("div", {
1864
- style: P,
1865
- children: [
1866
- /* @__PURE__ */ S(y, {
1867
- color: "text-neutral",
1868
- variant: "body",
1869
- children: [
1870
- "畫布上的這條線目前會顯示「",
1871
- /* @__PURE__ */ x("span", {
1872
- style: { color: !e.data.isDefault && !e.data.condition ? _t : void 0 },
1873
- children: t ?? "請設定條件"
1874
- }),
1875
- "」。"
1876
- ]
1877
- }),
1878
- /* @__PURE__ */ x(ae, {
1879
- checked: !!e.data.isDefault,
1880
- label: "其他情況走這條",
1881
- onChange: (t) => Zr(e.id, t.target.checked)
1882
- }),
1883
- e.data.isDefault ? /* @__PURE__ */ x(y, {
1884
- color: "text-neutral",
1885
- variant: "body",
1886
- children: "其他條件都不符合時,流程會走這條線。"
1887
- }) : /* @__PURE__ */ S(b, { children: [
1888
- J ? null : /* @__PURE__ */ x(y, {
1889
- color: "text-neutral",
1890
- variant: "body",
1891
- children: "請先綁定表單版本,才能選擇條件欄位。"
1892
- }),
1893
- /* @__PURE__ */ x(o, {
1894
- label: "條件欄位",
1895
- name: "edgeConditionField",
1896
- required: !0,
1897
- children: /* @__PURE__ */ x(v, {
1898
- clearable: !1,
1899
- onChange: (t) => Qr({
1900
- edgeId: e.id,
1901
- fieldKey: t?.id ?? null,
1902
- operator: null,
1903
- value: null
1904
- }),
1905
- options: [...n],
1906
- placeholder: "選擇條件欄位",
1907
- value: W(n, e.data.conditionFieldKey ?? null)
1908
- })
1909
- }),
1910
- /* @__PURE__ */ x(o, {
1911
- label: "條件判斷",
1912
- name: "edgeConditionOperator",
1913
- required: !0,
1914
- children: /* @__PURE__ */ x(v, {
1915
- clearable: !1,
1916
- onChange: (t) => Qr({
1917
- edgeId: e.id,
1918
- operator: wr(t?.id ?? null),
1919
- value: null
1920
- }),
1921
- options: [...i],
1922
- placeholder: "選擇判斷方式",
1923
- value: s
1924
- })
1925
- }),
1926
- s && Er(s.id) ? /* @__PURE__ */ x(o, {
1927
- label: "條件值",
1928
- name: "edgeConditionValue",
1929
- required: !0,
1930
- children: a.length > 0 ? /* @__PURE__ */ x(v, {
1931
- clearable: !1,
1932
- onChange: (t) => Qr({
1933
- edgeId: e.id,
1934
- value: t?.id ?? null
1935
- }),
1936
- options: [...a],
1937
- placeholder: "選擇條件值",
1938
- value: W(a, e.data.conditionValue ?? null)
1939
- }) : /* @__PURE__ */ x(g, {
1940
- onChange: (t) => Qr({
1941
- edgeId: e.id,
1942
- value: t.target.value
1943
- }),
1944
- placeholder: "輸入要比對的值",
1945
- value: e.data.conditionValue ?? "",
1946
- variant: "base"
1947
- })
1948
- }) : null
1949
- ] })
1950
- ]
1951
- });
1952
- }
1953
- }
1954
- function sn({ onApplyAutoLayout: e }) {
1955
- function t() {
1956
- e();
1957
- }
1958
- return /* @__PURE__ */ x(Me, {
1959
- position: "top-right",
1960
- children: /* @__PURE__ */ x(h, {
1961
- icon: le,
1962
- iconType: "leading",
1963
- onClick: t,
1964
- size: "sub",
1965
- variant: "base-secondary",
1966
- children: "自動排版"
1967
- })
1968
- });
1969
- }
1970
- function V({ data: e, selected: t, type: n }) {
1971
- let r = e.approverLines ?? [e.approverSummary ?? e.label], i = cn(e);
1972
- return /* @__PURE__ */ S("div", {
1973
- style: ln(n, t),
1974
- children: [
1975
- dn(e),
1976
- /* @__PURE__ */ x("div", {
1977
- style: Lt,
1978
- children: r.map((e, t) => /* @__PURE__ */ x(y, {
1979
- component: "span",
1980
- ellipsis: !0,
1981
- style: It,
1982
- title: e,
1983
- variant: "label-primary",
1984
- children: e
1985
- }, `${e}_${t}`))
1986
- }),
1987
- /* @__PURE__ */ x(y, {
1988
- color: "text-neutral",
1989
- component: "span",
1990
- ellipsis: !0,
1991
- style: It,
1992
- title: i,
1993
- variant: "caption",
1994
- children: i
1995
- })
1996
- ]
1997
- });
1998
- }
1999
- function cn(e) {
2000
- return e.nodeKind === "startEvent" ? e.initiatorPolicySummary ?? "所有人" : e.approverSummary || e.approverLines ? e.label : e.nodeKind === "exclusiveGateway" ? "條件在線上" : e.nodeKind === "parallelGateway" ? "多條路徑同時進行" : zt[e.nodeKind];
2001
- }
2002
- function ln(e, t) {
2003
- let n = un(e);
2004
- return t ? {
2005
- ...n,
2006
- border: "1px solid var(--mzn-color-primary, #0057ff)",
2007
- boxShadow: Ot
2008
- } : n;
2009
- }
2010
- function un(e) {
2011
- return e === "exclusiveGateway" ? Nt : e === "parallelGateway" ? R : e === "startEvent" ? z : e === "endEvent" ? Ft : e === "userTask" ? Pt : F;
2012
- }
2013
- function dn(e) {
2014
- return !e.hasInput && e.hasOutput ? /* @__PURE__ */ x(Ae, {
2015
- id: B,
2016
- position: w.Right,
2017
- type: "source"
2018
- }) : e.hasInput && !e.hasOutput ? /* @__PURE__ */ x(Ae, {
2019
- id: Rt,
2020
- position: w.Left,
2021
- type: "target"
2022
- }) : !e.hasInput && !e.hasOutput ? null : [/* @__PURE__ */ x(Ae, {
2023
- id: Rt,
2024
- position: w.Left,
2025
- type: "target"
2026
- }, "target"), /* @__PURE__ */ x(Ae, {
2027
- id: B,
2028
- position: w.Right,
2029
- type: "source"
2030
- }, "source")];
2031
- }
2032
- function fn(e, t, n, r, i, a) {
2033
- let o = H(e);
2034
- return {
2035
- data: {
2036
- approverLines: hr(e, t),
2037
- approverSummary: J(e, t, n, r),
2038
- hasInput: Hn(e),
2039
- hasOutput: Un(e),
2040
- initiatorPolicySummary: e.type === "startEvent" ? Ln(a, n, r) : null,
2041
- label: e.data.label,
2042
- nodeKind: e.type
2043
- },
2044
- height: o.height,
2045
- handles: pn(e),
2046
- id: e.id,
2047
- initialHeight: o.height,
2048
- initialWidth: o.width,
2049
- position: e.position,
2050
- selected: i,
2051
- sourcePosition: w.Right,
2052
- targetPosition: w.Left,
2053
- type: e.type,
2054
- width: o.width
2055
- };
2056
- }
2057
- function H(e) {
2058
- return e.type === "exclusiveGateway" || e.type === "parallelGateway" ? {
2059
- height: jt,
2060
- width: Mt
2061
- } : e.type === "serviceTask" ? {
2062
- height: kt + (Math.max(1, jr(e.data.action).length) - 1) * I,
2063
- width: At
2064
- } : {
2065
- height: kt,
2066
- width: At
2067
- };
2068
- }
2069
- function pn(e) {
2070
- let t = H(e);
2071
- return [...Hn(e) ? [mn(t)] : [], ...Un(e) ? [hn(t)] : []];
2072
- }
2073
- function mn({ height: e }) {
2074
- let t = e / 2 - 9 / 2;
2075
- return {
2076
- height: 9,
2077
- id: Rt,
2078
- position: w.Left,
2079
- type: "target",
2080
- width: 9,
2081
- x: -9 / 2,
2082
- y: t
2083
- };
2084
- }
2085
- function hn({ height: e, width: t }) {
2086
- let n = e / 2 - 9 / 2;
2087
- return {
2088
- height: 9,
2089
- id: B,
2090
- position: w.Right,
2091
- type: "source",
2092
- width: 9,
2093
- x: t - 9 / 2,
2094
- y: n
2095
- };
2096
- }
2097
- function gn(e, t, n) {
2098
- let r = Dr(e, t), i = kr(e, t), a = i && !e.data.isDefault && !e.data.condition, o = a ? _t : i ? gt : "#475569", s = a ? "#fef2f2" : i ? "#eff6ff" : "#ffffff", c = a ? _t : i ? gt : N;
2099
- return {
2100
- className: n ? "workflow-edge--selected" : void 0,
2101
- data: e.data,
2102
- id: e.id,
2103
- label: r,
2104
- labelBgBorderRadius: 6,
2105
- labelBgPadding: [8, 4],
2106
- labelBgStyle: {
2107
- fill: s,
2108
- stroke: c,
2109
- strokeWidth: 1
2110
- },
2111
- labelShowBg: !!r,
2112
- labelStyle: {
2113
- fill: o,
2114
- fontSize: 12,
2115
- fontWeight: 600
2116
- },
2117
- selected: n,
2118
- source: e.source,
2119
- sourceHandle: e.sourceHandle,
2120
- style: {
2121
- filter: n ? vt : void 0,
2122
- opacity: 1,
2123
- stroke: N,
2124
- strokeOpacity: 1,
2125
- strokeWidth: 1.5
2126
- },
2127
- target: e.target,
2128
- targetHandle: e.targetHandle,
2129
- type: e.type ?? "smoothstep"
2130
- };
2131
- }
2132
- function U(e, t) {
2133
- return e.type === "startEvent" ? e : (e.type === "endEvent" || e.type === "userTask" || e.type === "serviceTask" || e.type, {
2134
- ...e,
2135
- data: {
2136
- ...e.data,
2137
- triggerMode: t
2138
- }
2139
- });
2140
- }
2141
- function _n(e) {
2142
- return yn(vn(e));
2143
- }
2144
- function vn(e) {
2145
- let t = new Set(e.nodes.filter((e) => G(e)).map((e) => e.id)), n = e.edges.filter((e) => !t.has(e.source));
2146
- return n.length === e.edges.length ? e : {
2147
- ...e,
2148
- edges: n
2149
- };
2150
- }
2151
- function yn(e) {
2152
- let t = e.edges.reduce((e, t) => ({
2153
- ...e,
2154
- [t.target]: (e[t.target] ?? 0) + 1
2155
- }), {}), n = e.nodes.map((e) => e.type === "startEvent" ? e : (t[e.id] ?? 0) < 2 && e.data.triggerMode !== "AND" ? U(e, "AND") : e);
2156
- return n.some((t, n) => t !== e.nodes[n]) ? {
2157
- ...e,
2158
- nodes: n
2159
- } : e;
2160
- }
2161
- function bn() {
2162
- return {
2163
- edges: [],
2164
- meta: { schemaVersion: 1 },
2165
- nodes: [{
2166
- data: { label: "開始" },
2167
- id: "start",
2168
- position: {
2169
- x: 80,
2170
- y: 160
2171
- },
2172
- type: "startEvent"
2173
- }, {
2174
- data: {
2175
- endState: "APPROVED",
2176
- label: "完成",
2177
- triggerMode: "AND"
2178
- },
2179
- id: "end",
2180
- position: {
2181
- x: 560,
2182
- y: 160
2183
- },
2184
- type: "endEvent"
2185
- }]
2186
- };
2187
- }
2188
- function xn(e) {
2189
- return e.edges.length === 0 && e.nodes.length === 2 && e.nodes.some((e) => e.type === "startEvent") && e.nodes.some((e) => e.type === "endEvent");
2190
- }
2191
- function Sn(e) {
2192
- let t = new Ie.graphlib.Graph();
2193
- return t.setDefaultEdgeLabel(() => ({})), t.setGraph({
2194
- rankdir: "LR",
2195
- ranksep: 120
2196
- }), e.nodes.forEach((e) => {
2197
- t.setNode(e.id, H(e));
2198
- }), e.edges.forEach((e) => {
2199
- t.setEdge(e.source, e.target);
2200
- }), Ie.layout(t), {
2201
- ...e,
2202
- nodes: e.nodes.map((e) => {
2203
- let n = t.node(e.id);
2204
- return n ? {
2205
- ...e,
2206
- position: {
2207
- x: n.x - H(e).width / 2,
2208
- y: n.y - H(e).height / 2
2209
- }
2210
- } : e;
2211
- })
2212
- };
2213
- }
2214
- function W(e, t) {
2215
- return t ? e.find((e) => e.id === t) ?? null : null;
2216
- }
2217
- function Cn(e) {
2218
- return e === "OR" ? "OR" : "AND";
2219
- }
2220
- function wn(e) {
2221
- return e === "FROM_RETURN_POINT" ? "FROM_RETURN_POINT" : "RESTART";
2222
- }
2223
- function Tn(e) {
2224
- return e === "ORG_MANAGER" || e === "ORG_UNIT_MANAGER" || e === "ORG_UNIT_MEMBER" || e === "ORG_UNIT_POSITION" || e === "POSITION" ? e : "DIRECT";
2225
- }
2226
- function En(e) {
2227
- let t = Tn(e ?? "DIRECT");
2228
- return t === "ORG_MANAGER" ? {
2229
- baseFromInitiator: !0,
2230
- levelsUp: 1,
2231
- type: "ORG_MANAGER"
2232
- } : t === "ORG_UNIT_MANAGER" ? {
2233
- orgUnitId: "",
2234
- type: "ORG_UNIT_MANAGER"
2235
- } : t === "ORG_UNIT_MEMBER" ? {
2236
- includeDescendants: !1,
2237
- orgUnitId: "",
2238
- type: "ORG_UNIT_MEMBER"
2239
- } : t === "ORG_UNIT_POSITION" ? {
2240
- includeDescendants: !1,
2241
- orgUnitId: "",
2242
- positionId: "",
2243
- type: "ORG_UNIT_POSITION"
2244
- } : t === "POSITION" ? {
2245
- positionId: "",
2246
- type: "POSITION"
2247
- } : {
2248
- memberIds: [],
2249
- type: "DIRECT"
2250
- };
2251
- }
2252
- function Dn(e) {
2253
- return e === "DIRECT" ? "DIRECT" : "NONE";
2254
- }
2255
- function On(e, t) {
2256
- return e.type === "ORG_MANAGER" || e.type === "ORG_UNIT_MANAGER" ? {
2257
- ...e,
2258
- fallback: t
2259
- } : e;
2260
- }
2261
- function kn(e) {
2262
- return Gt.find((t) => t.value === e) ?? Gt[0];
2263
- }
2264
- function An(e) {
2265
- return Gt.find((t) => t.id === e) ?? Gt[0];
2266
- }
2267
- function jn(e) {
2268
- return e === "ORG_UNIT" || e === "ORG_UNIT_POSITION" || e === "NONE" ? e : "ALL";
2269
- }
2270
- function Mn(e) {
2271
- let t = e?.trim();
2272
- if (!t) return {
2273
- mode: "ALL",
2274
- value: ""
2275
- };
2276
- let n = Fn(t, /"([^"]+)" in subject\.orgUnitIds/gu), r = Fn(t, /"([^"]+)" in subject\.positionIds/gu);
2277
- return n.length > 0 && r.length > 0 ? {
2278
- includeDescendants: n.length > 1,
2279
- mode: "ORG_UNIT_POSITION",
2280
- orgUnitId: n[0],
2281
- positionId: r[0],
2282
- value: n[0] ?? ""
2283
- } : n.length > 0 ? {
2284
- includeDescendants: n.length > 1,
2285
- mode: "ORG_UNIT",
2286
- orgUnitId: n[0],
2287
- value: n[0] ?? ""
2288
- } : {
2289
- mode: "CUSTOM",
2290
- value: t
2291
- };
2292
- }
2293
- function Nn(e, t) {
2294
- let n = Mn(e);
2295
- return !t || t === "ALL" || t === "NONE" ? t === "ALL" || t === "NONE" ? {
2296
- mode: t,
2297
- value: ""
2298
- } : n : n.mode === t ? n : Rn(t);
2299
- }
2300
- function Pn(e) {
2301
- return e.mode === "NONE" ? "發起權限需要選擇誰可以發起。" : (e.mode === "ORG_UNIT" || e.mode === "ORG_UNIT_POSITION") && !e.orgUnitId?.trim() ? "指定組織發起時,需要選擇組織。" : e.mode === "ORG_UNIT_POSITION" && !e.positionId?.trim() ? "指定組織職位發起時,需要選擇職位。" : null;
2302
- }
2303
- function Fn(e, t) {
2304
- return [...e.matchAll(t)].map((e) => e[1]).filter((e) => !!e);
2305
- }
2306
- function In(e, t) {
2307
- if (e.mode === "ALL" || e.mode === "NONE") return null;
2308
- let n = e.orgUnitId?.trim() ?? "";
2309
- if (!n) return null;
2310
- let r = dr(t, n, !!e.includeDescendants).map((e) => `${JSON.stringify(e)} in subject.orgUnitIds`).join(" || ");
2311
- if (e.mode === "ORG_UNIT") return r ? `(${r})` : null;
2312
- let i = e.positionId?.trim() ?? "";
2313
- return i && r ? `(${r}) && ${JSON.stringify(i)} in subject.positionIds` : null;
2314
- }
2315
- function Ln(e, t, n) {
2316
- return e.mode === "NONE" ? "未設定" : e.mode === "ORG_UNIT" ? e.orgUnitId ? `組織:${K(t, e.orgUnitId)}` : "指定組織" : e.mode === "ORG_UNIT_POSITION" ? e.orgUnitId && e.positionId ? `組織職位:${K(t, e.orgUnitId)} / ${ar(n, e.positionId)}` : "指定組織職位" : e.mode === "CUSTOM" ? "既有自訂規則" : "所有人";
2317
- }
2318
- function Rn(e) {
2319
- return {
2320
- includeDescendants: !0,
2321
- mode: e,
2322
- orgUnitId: "",
2323
- positionId: "",
2324
- value: ""
2325
- };
2326
- }
2327
- function zn(e, t) {
2328
- let n = e.source ? t.find((t) => t.id === e.source) ?? null : null, r = e.target ? t.find((t) => t.id === e.target) ?? null : null;
2329
- return !!n && !!r && e.source !== e.target && e.sourceHandle === B && e.targetHandle === Rt && !!(n && Un(n)) && !!(r && Hn(r));
2330
- }
2331
- function Bn(e, t) {
2332
- return e.includes(t) ? e.filter((e) => e !== t) : [...e, t];
2333
- }
2334
- function Vn(e) {
2335
- return e.type !== "startEvent" && e.type !== "endEvent";
2336
- }
2337
- function Hn(e) {
2338
- return e.type !== "startEvent";
2339
- }
2340
- function Un(e) {
2341
- return e.type !== "endEvent" && !G(e);
2342
- }
2343
- function G(e) {
2344
- return e.type === "serviceTask" && e.data.action.type === "NOTIFY";
2345
- }
2346
- function Wn(e) {
2347
- return e instanceof HTMLElement ? e.isContentEditable || e.tagName === "INPUT" || e.tagName === "TEXTAREA" || e.tagName === "SELECT" || !!e.closest("[contenteditable=\"true\"]") : !1;
2348
- }
2349
- function Gn(e) {
2350
- return e.map((e) => ({
2351
- formDefinitionId: e.formDefinitionId,
2352
- formName: e.formName,
2353
- id: e.id,
2354
- name: `${e.formName} | v${e.version}`,
2355
- schema: e.schema
2356
- }));
2357
- }
2358
- function Kn(e) {
2359
- return (e?.schema.fields ?? []).reduce((e, t) => ({
2360
- ...e,
2361
- [t.fieldKey]: qn(t)
2362
- }), {});
2363
- }
2364
- function qn(e) {
2365
- return e.type === "number" ? 1e3 : e.type === "boolean" ? !0 : e.type === "select" ? e.options[0]?.value ?? "" : e.type === "checkbox" ? e.options[0] ? [e.options[0].value] : [] : e.type === "date" ? "2026-05-08" : e.type === "datetime" ? "2026-05-08T09:00:00+08:00" : e.placeholder ?? e.label;
2366
- }
2367
- function Jn(e) {
2368
- let t = JSON.parse(e);
2369
- if (!Yn(t)) throw Error("表單資料 JSON 必須是物件。");
2370
- return t;
2371
- }
2372
- function Yn(e) {
2373
- return typeof e == "object" && !!e && !Array.isArray(e);
2374
- }
2375
- function Xn(e) {
2376
- return e === "COMPLETED" ? "完成" : e === "PASSED" ? "通過" : e === "SKIPPED" ? "略過" : e === "STOPPED" ? "已停止" : e === "WAITING" ? "將等待簽核" : e;
2377
- }
2378
- function Zn(e) {
2379
- return e in zt ? zt[e] : e;
2380
- }
2381
- function Qn(e, t) {
2382
- return t && !e.some((e) => e.id === t.id) ? [t, ...e] : e;
2383
- }
2384
- function $n(e) {
2385
- return e.map((e) => ({
2386
- displayName: e.name,
2387
- email: e.email,
2388
- id: e.memberId,
2389
- memberId: e.memberId,
2390
- name: _r(e.name, e.email)
2391
- }));
2392
- }
2393
- function er(e) {
2394
- return {
2395
- displayName: "未知會員",
2396
- email: "",
2397
- id: e,
2398
- memberId: e,
2399
- name: "未知會員"
2400
- };
2401
- }
2402
- function tr(e, t) {
2403
- return e.find((e) => e.memberId === t) ?? er(t);
2404
- }
2405
- function nr(e, t) {
2406
- let n = e[0];
2407
- return n ? tr(t, n) : null;
2408
- }
2409
- function rr(e, t) {
2410
- let r = e.find((e) => e.id === t);
2411
- return r ? n(r) : null;
2412
- }
2413
- function ir(e, t) {
2414
- let n = e.find((e) => e.id === t);
2415
- return n ? i(n) : null;
2416
- }
2417
- function K(e, t) {
2418
- return rr(e, t)?.name ?? "未指定組織";
2419
- }
2420
- function ar(e, t) {
2421
- return ir(e, t)?.name ?? "未指定職位";
2422
- }
2423
- function or(e, t) {
2424
- let n = sr(), r = t.filter((t) => t.memberId === e && cr(t, n)), i = r.reduce((e, t) => e && q(e, t) <= 0 ? e : t, null);
2425
- return {
2426
- customFields: {},
2427
- managerMemberId: "member-002",
2428
- memberId: e,
2429
- orgCode: "HQ",
2430
- orgUnitIds: lr(r.map((e) => e.orgUnitId)),
2431
- positionId: i?.positionId ?? null,
2432
- positionIds: lr(r.map((e) => e.positionId)),
2433
- primaryOrgUnitId: i?.orgUnitId ?? null,
2434
- roles: ["manager"]
2435
- };
2436
- }
2437
- function sr() {
2438
- return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
2439
- }
2440
- function cr(e, t) {
2441
- return e.effectiveFrom <= t && (!e.effectiveTo || e.effectiveTo >= t);
2442
- }
2443
- function q(e, t) {
2444
- return e.isPrimary === t.isPrimary ? t.effectiveFrom.localeCompare(e.effectiveFrom) : e.isPrimary ? -1 : 1;
2445
- }
2446
- function lr(e) {
2447
- return e.reduce((e, t) => t && !e.includes(t) ? [...e, t] : e, []);
2448
- }
2449
- function ur({ includeDescendants: e, memberships: t, orgUnitId: n, orgUnits: r, positions: i }) {
2450
- let a = new Set(dr(r, n, e)), o = new Set(t.filter((e) => a.has(e.orgUnitId)).map((e) => e.positionId).filter((e) => !!e));
2451
- return i.filter((e) => o.has(e.id));
2452
- }
2453
- function dr(e, t, n) {
2454
- let r = e.find((e) => e.id === t);
2455
- return r ? n ? e.filter((e) => e.id === r.id || e.path.startsWith(`${r.path}.`)).map((e) => e.id) : [r.id] : t.trim() ? [t] : [];
2456
- }
2457
- function fr(e, t) {
2458
- let n = new Set(e.map((e) => e.memberId)), r = t.filter((e) => !n.has(e.memberId));
2459
- return [...e, ...r];
2460
- }
2461
- function pr(e) {
2462
- return [...new Set(e.nodes.flatMap((e) => e.type === "userTask" ? e.data.approverResolver.type === "DIRECT" ? e.data.approverResolver.memberIds : [] : e.type === "serviceTask" ? jr(e.data.action) : []))];
2463
- }
2464
- function J(e, t, n, r) {
2465
- return e.type === "userTask" ? mr(e.data.approverResolver, t, n, r) : null;
2466
- }
2467
- function mr(e, t, n, r) {
2468
- return e.type === "DIRECT" ? gr(e.memberIds, t, "未指定簽核者") : e.type === "ORG_MANAGER" ? kn(e.levelsUp).name : e.type === "ORG_UNIT_MANAGER" ? `組織主管:${K(n, e.orgUnitId)}` : e.type === "ORG_UNIT_MEMBER" ? `組織任一人:${K(n, e.orgUnitId)}` : e.type === "ORG_UNIT_POSITION" ? `組織職位:${K(n, e.orgUnitId)} / ${ar(r, e.positionId)}` : e.type === "POSITION" ? `職位:${ar(r, e.positionId)}` : e.type === "DYNAMIC_FORM" ? `表單欄位:${e.formPath || "未設定"}` : "自訂表達式";
2469
- }
2470
- function hr(e, t) {
2471
- if (e.type !== "serviceTask") return null;
2472
- let n = jr(e.data.action);
2473
- return n.length === 0 ? ["未指定知會對象"] : n.map((e) => tr(t, e).name);
2474
- }
2475
- function gr(e, t, n) {
2476
- let r = e.map((e) => tr(t, e).name);
2477
- return r.length === 0 ? n : r.length <= 2 ? r.join("、") : `${r.slice(0, 2).join("、")} 等 ${r.length} 人`;
2478
- }
2479
- function _r(e, t) {
2480
- return `${e} (${t})`;
2481
- }
2482
- function vr(e, t) {
2483
- let n = t?.getBoundingClientRect();
2484
- if (!n || e.nodes.length === 0) return null;
2485
- let r = e.nodes.reduce((e, t) => {
2486
- let n = H(t);
2487
- return {
2488
- maxX: Math.max(e.maxX, t.position.x + n.width),
2489
- maxY: Math.max(e.maxY, t.position.y + n.height),
2490
- minX: Math.min(e.minX, t.position.x),
2491
- minY: Math.min(e.minY, t.position.y)
2492
- };
2493
- }, {
2494
- maxX: -Infinity,
2495
- maxY: -Infinity,
2496
- minX: Infinity,
2497
- minY: Infinity
2498
- });
2499
- return Fe({
2500
- height: r.maxY - r.minY,
2501
- width: r.maxX - r.minX,
2502
- x: r.minX,
2503
- y: r.minY
2504
- }, n.width, n.height, .1, 1, .2);
2505
- }
2506
- function yr(e) {
2507
- let t = e.nodes.find((e) => e.type === "userTask" && !!Y(e.data.approverResolver)), n = e.nodes.find((e) => e.type === "serviceTask" && e.data.action.type === "NOTIFY" && jr(e.data.action).length === 0), r = e.edges.find((t) => kr(t, e.nodes) && !t.data.isDefault && !t.data.condition);
2508
- return t && t.type === "userTask" ? Y(t.data.approverResolver) : n ? "知會節點需要至少一位知會對象。" : r ? "條件分流的每條輸出連線都需要先設定條件。" : null;
2509
- }
2510
- function Y(e) {
2511
- return e.type === "DIRECT" && e.memberIds.length === 0 ? "簽核節點需要指定簽核會員。" : e.type === "ORG_MANAGER" && e.levelsUp < 1 ? "簽核節點需要指定有效的主管層級。" : e.type === "ORG_UNIT_MANAGER" && !e.orgUnitId.trim() || e.type === "ORG_UNIT_MEMBER" && !e.orgUnitId.trim() ? "簽核節點需要指定組織。" : e.type === "ORG_UNIT_POSITION" && (!e.orgUnitId.trim() || !e.positionId.trim()) ? "簽核節點需要指定組織與職位。" : (e.type === "ORG_MANAGER" || e.type === "ORG_UNIT_MANAGER") && e.fallback?.type === "DIRECT" && !e.fallback.memberId.trim() ? "簽核節點需要指定改派固定人。" : e.type === "POSITION" && !e.positionId.trim() ? "簽核節點需要指定職位。" : null;
2512
- }
2513
- function br(e) {
2514
- return e.edges.some((t) => kr(t, e.nodes) && !!(t.data.condition || t.data.conditionFieldKey || t.data.conditionOperator || t.data.conditionValue));
2515
- }
2516
- function xr(e) {
2517
- return e?.fields.map((e) => ({
2518
- fieldType: e.type,
2519
- id: e.fieldKey,
2520
- name: `${e.label} (${e.fieldKey})`
2521
- })) ?? [];
2522
- }
2523
- function Sr(e, t) {
2524
- return t ? e?.fields.find((e) => e.fieldKey === t) ?? null : null;
2525
- }
2526
- function Cr(e) {
2527
- if (!e) return [];
2528
- let t = X(e);
2529
- return qt.filter((e) => t.includes(e.id));
2530
- }
2531
- function wr(e) {
2532
- return qt.some((t) => t.id === e) ? e : null;
2533
- }
2534
- function X(e) {
2535
- return e.type === "file_upload" ? ["IS_FILLED", "IS_EMPTY"] : e.type === "boolean" ? [
2536
- "EQUALS",
2537
- "NOT_EQUALS",
2538
- "IS_FILLED",
2539
- "IS_EMPTY"
2540
- ] : e.type === "date" || e.type === "datetime" || e.type === "money" || e.type === "number" ? [
2541
- "EQUALS",
2542
- "NOT_EQUALS",
2543
- "GREATER_THAN",
2544
- "GREATER_THAN_OR_EQUALS",
2545
- "LESS_THAN",
2546
- "LESS_THAN_OR_EQUALS",
2547
- "IS_FILLED",
2548
- "IS_EMPTY"
2549
- ] : [
2550
- "EQUALS",
2551
- "NOT_EQUALS",
2552
- "IS_FILLED",
2553
- "IS_EMPTY"
2554
- ];
2555
- }
2556
- function Tr(e) {
2557
- return e ? e.type === "boolean" ? [{
2558
- id: "true",
2559
- name: "是"
2560
- }, {
2561
- id: "false",
2562
- name: "否"
2563
- }] : e.type === "checkbox" || e.type === "radio" || e.type === "select" ? e.options.map((e) => ({
2564
- id: e.value,
2565
- name: e.label
2566
- })) : [] : [];
2567
- }
2568
- function Er(e) {
2569
- return Jt.includes(e);
2570
- }
2571
- function Dr(e, t) {
2572
- if (e.data.label) return e.data.label;
2573
- if (kr(e, t)) return Or(e);
2574
- if (Ar(e, t)) return "同時進行";
2575
- }
2576
- function Or(e) {
2577
- return e.data.isDefault ? "其他情況" : "請設定條件";
2578
- }
2579
- function kr(e, t) {
2580
- return t.some((t) => t.id === e.source && t.type === "exclusiveGateway");
2581
- }
2582
- function Ar(e, t) {
2583
- return t.some((t) => t.id === e.source && t.type === "parallelGateway");
2584
- }
2585
- function jr(e) {
2586
- return e.type === "NOTIFY" && e.recipients.type === "DIRECT" ? e.recipients.memberIds : [];
2587
- }
2588
- function Z(e) {
2589
- return e instanceof Error ? e.message : "發生未知錯誤";
2590
- }
2591
- //#endregion
2592
- export { on as t };
2593
-
2594
- //# sourceMappingURL=designer-BLfz5Dk9.js.map