@rytass/bpm-core-react 0.4.0 → 0.5.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 (195) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/dist/chunks/FormBuilderView-B_KGPjlp.cjs +3 -0
  3. package/dist/chunks/FormBuilderView-B_KGPjlp.cjs.map +1 -0
  4. package/dist/chunks/FormBuilderView-D8DrQOXD.js +1090 -0
  5. package/dist/chunks/FormBuilderView-D8DrQOXD.js.map +1 -0
  6. package/dist/chunks/{approval-instance-list-page-UNIIgUZy.cjs → approval-instance-list-page-BMUKxzcz.cjs} +2 -2
  7. package/dist/chunks/{approval-instance-list-page-UNIIgUZy.cjs.map → approval-instance-list-page-BMUKxzcz.cjs.map} +1 -1
  8. package/dist/chunks/{approval-instance-list-page-BtEc8Cs3.js → approval-instance-list-page-YZcGGDD8.js} +3 -3
  9. package/dist/chunks/{approval-instance-list-page-BtEc8Cs3.js.map → approval-instance-list-page-YZcGGDD8.js.map} +1 -1
  10. package/dist/chunks/{auth-provider-D2P-qWmY.cjs → auth-provider-4BeCw7cI.cjs} +2 -2
  11. package/dist/chunks/{auth-provider-D2P-qWmY.cjs.map → auth-provider-4BeCw7cI.cjs.map} +1 -1
  12. package/dist/chunks/{auth-provider-TTO9eNZV.js → auth-provider-B5oPmvk2.js} +2 -2
  13. package/dist/chunks/{auth-provider-TTO9eNZV.js.map → auth-provider-B5oPmvk2.js.map} +1 -1
  14. package/dist/chunks/compose-PMrmi-LE.js +451 -0
  15. package/dist/chunks/compose-PMrmi-LE.js.map +1 -0
  16. package/dist/chunks/compose-ziVbRYdo.cjs +2 -0
  17. package/dist/chunks/compose-ziVbRYdo.cjs.map +1 -0
  18. package/dist/chunks/{dashboard-page-CQRBJxze.js → dashboard-page-DJ9vOPga.js} +4 -4
  19. package/dist/chunks/{dashboard-page-CQRBJxze.js.map → dashboard-page-DJ9vOPga.js.map} +1 -1
  20. package/dist/chunks/{dashboard-page-DrDChhg1.cjs → dashboard-page-DwHQY6Ki.cjs} +2 -2
  21. package/dist/chunks/{dashboard-page-DrDChhg1.cjs.map → dashboard-page-DwHQY6Ki.cjs.map} +1 -1
  22. package/dist/chunks/{delegations-CFXaJrdX.cjs → delegations-C2wLWsDQ.cjs} +2 -2
  23. package/dist/chunks/{delegations-CFXaJrdX.cjs.map → delegations-C2wLWsDQ.cjs.map} +1 -1
  24. package/dist/chunks/{delegations-DwbYkNUg.cjs → delegations-DDEk-WI6.cjs} +2 -2
  25. package/dist/chunks/{delegations-DwbYkNUg.cjs.map → delegations-DDEk-WI6.cjs.map} +1 -1
  26. package/dist/chunks/{delegations-FTLaWo1Y.js → delegations-ZNtodFaD.js} +2 -2
  27. package/dist/chunks/{delegations-FTLaWo1Y.js.map → delegations-ZNtodFaD.js.map} +1 -1
  28. package/dist/chunks/{delegations-D5pPEWsP.js → delegations-iVnRi3QE.js} +2 -2
  29. package/dist/chunks/{delegations-D5pPEWsP.js.map → delegations-iVnRi3QE.js.map} +1 -1
  30. package/dist/chunks/designer-DCn6_v4b.cjs +65 -0
  31. package/dist/chunks/designer-DCn6_v4b.cjs.map +1 -0
  32. package/dist/chunks/designer-mOMxJ0Py.js +2576 -0
  33. package/dist/chunks/designer-mOMxJ0Py.js.map +1 -0
  34. package/dist/chunks/detail-Bml-vXHX.js +1622 -0
  35. package/dist/chunks/detail-Bml-vXHX.js.map +1 -0
  36. package/dist/chunks/detail-CWeCrmtC.cjs +2 -0
  37. package/dist/chunks/detail-CWeCrmtC.cjs.map +1 -0
  38. package/dist/chunks/{login-BfmfCclF.cjs → login-9bCXyjbX.cjs} +2 -2
  39. package/dist/chunks/{login-BfmfCclF.cjs.map → login-9bCXyjbX.cjs.map} +1 -1
  40. package/dist/chunks/{login-xgI4wLHe.js → login-BKxpLibd.js} +3 -3
  41. package/dist/chunks/{login-xgI4wLHe.js.map → login-BKxpLibd.js.map} +1 -1
  42. package/dist/chunks/{notifications-a-FCxV02.cjs → notifications-BKs4--96.cjs} +2 -2
  43. package/dist/chunks/{notifications-a-FCxV02.cjs.map → notifications-BKs4--96.cjs.map} +1 -1
  44. package/dist/chunks/{notifications-BoNa1BXD.js → notifications-CSulztkU.js} +2 -2
  45. package/dist/chunks/{notifications-BoNa1BXD.js.map → notifications-CSulztkU.js.map} +1 -1
  46. package/dist/chunks/router-adapter--gYs13E8.cjs +2 -0
  47. package/dist/chunks/{router-adapter-BybHrCNP.cjs.map → router-adapter--gYs13E8.cjs.map} +1 -1
  48. package/dist/chunks/{router-adapter-BdHZXLS3.js → router-adapter-DftlFTOd.js} +2 -2
  49. package/dist/chunks/{router-adapter-BdHZXLS3.js.map → router-adapter-DftlFTOd.js.map} +1 -1
  50. package/dist/chunks/{routes-config-dxahImVe.js → routes-config-RBYQtUd0.js} +2 -3
  51. package/dist/chunks/routes-config-RBYQtUd0.js.map +1 -0
  52. package/dist/chunks/routes-config-fDVHmvXi.cjs +2 -0
  53. package/dist/chunks/routes-config-fDVHmvXi.cjs.map +1 -0
  54. package/dist/index.cjs +1 -1
  55. package/dist/index.cjs.map +1 -1
  56. package/dist/index.js +270 -130
  57. package/dist/index.js.map +1 -1
  58. package/dist/lib/routes-config.d.ts +6 -4
  59. package/dist/next/BPMNextProviders.d.ts +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 +14 -24
  63. package/dist/next/index.js.map +1 -1
  64. package/dist/next/workflow-chat-route.cjs +19 -0
  65. package/dist/next/workflow-chat-route.cjs.map +1 -0
  66. package/dist/next/workflow-chat-route.d.ts +17 -0
  67. package/dist/next/workflow-chat-route.js +31 -0
  68. package/dist/next/workflow-chat-route.js.map +1 -0
  69. package/dist/pages/admin/delegations/index.cjs +1 -1
  70. package/dist/pages/admin/delegations/index.js +1 -1
  71. package/dist/pages/delegations/index.cjs +1 -1
  72. package/dist/pages/delegations/index.js +1 -1
  73. package/dist/pages/instances/detail/index.cjs +1 -1
  74. package/dist/pages/instances/detail/index.js +1 -1
  75. package/dist/pages/login/index.cjs +1 -1
  76. package/dist/pages/login/index.js +1 -1
  77. package/dist/pages/settings/notifications/index.cjs +1 -1
  78. package/dist/pages/settings/notifications/index.js +1 -1
  79. package/dist/pages/templates/compose/index.cjs +2 -0
  80. package/dist/pages/templates/compose/index.cjs.map +1 -0
  81. package/dist/pages/templates/compose/index.d.ts +13 -0
  82. package/dist/pages/templates/compose/index.js +14 -0
  83. package/dist/pages/templates/compose/index.js.map +1 -0
  84. package/dist/pages/templates/designer/index.cjs +1 -1
  85. package/dist/pages/templates/designer/index.cjs.map +1 -1
  86. package/dist/pages/templates/designer/index.js +7 -2
  87. package/dist/pages/templates/designer/index.js.map +1 -1
  88. package/dist/pages/templates/index.cjs +1 -1
  89. package/dist/pages/templates/index.cjs.map +1 -1
  90. package/dist/pages/templates/index.js +3 -3
  91. package/dist/pages/templates/index.js.map +1 -1
  92. package/dist/views/admin/delegations/index.cjs +1 -1
  93. package/dist/views/admin/delegations/index.js +1 -1
  94. package/dist/views/admin/index.cjs +1 -1
  95. package/dist/views/admin/index.js +1 -1
  96. package/dist/views/cc/index.cjs +1 -1
  97. package/dist/views/cc/index.js +1 -1
  98. package/dist/views/dashboard/index.cjs +1 -1
  99. package/dist/views/dashboard/index.js +1 -1
  100. package/dist/views/delegations/index.cjs +1 -1
  101. package/dist/views/delegations/index.js +1 -1
  102. package/dist/views/forms/builder/FormBuilderView.d.ts +13 -4
  103. package/dist/views/forms/builder/index.cjs +1 -1
  104. package/dist/views/forms/builder/index.js +1 -1
  105. package/dist/views/forms/builder/json-code-editor.d.ts +1 -1
  106. package/dist/views/inbox/index.cjs +1 -1
  107. package/dist/views/inbox/index.js +3 -3
  108. package/dist/views/instances/detail/InstanceDetailView.d.ts +11 -1
  109. package/dist/views/instances/detail/index.cjs +1 -1
  110. package/dist/views/instances/detail/index.d.ts +5 -0
  111. package/dist/views/instances/detail/index.js +2 -2
  112. package/dist/views/instances/detail/sections/InstanceAttachmentsSection.d.ts +15 -0
  113. package/dist/views/instances/detail/sections/InstanceFormSection.d.ts +33 -0
  114. package/dist/views/instances/detail/sections/InstanceHistorySection.d.ts +29 -0
  115. package/dist/views/instances/detail/sections/InstanceSignaturesSection.d.ts +14 -0
  116. package/dist/views/instances/detail/sections/InstanceTasksSection.d.ts +44 -0
  117. package/dist/views/instances/detail/sections/container-helpers.d.ts +8 -0
  118. package/dist/views/instances/detail/sections/shared.d.ts +103 -0
  119. package/dist/views/instances/new/index.cjs +1 -1
  120. package/dist/views/instances/new/index.js +3 -3
  121. package/dist/views/login/index.cjs +1 -1
  122. package/dist/views/login/index.js +1 -1
  123. package/dist/views/search/index.cjs +1 -1
  124. package/dist/views/search/index.js +1 -1
  125. package/dist/views/sent/index.cjs +1 -1
  126. package/dist/views/sent/index.js +1 -1
  127. package/dist/views/settings/index.cjs +1 -1
  128. package/dist/views/settings/index.js +1 -1
  129. package/dist/views/settings/notifications/index.cjs +1 -1
  130. package/dist/views/settings/notifications/index.js +1 -1
  131. package/dist/views/templates/TemplatesView.d.ts +5 -0
  132. package/dist/views/templates/compose/TemplateComposeWizardView.d.ts +8 -0
  133. package/dist/views/templates/compose/index.cjs +1 -0
  134. package/dist/views/templates/compose/index.d.ts +2 -0
  135. package/dist/views/templates/compose/index.js +2 -0
  136. package/dist/views/templates/compose/steps/ComposeFormStep.d.ts +15 -0
  137. package/dist/views/templates/compose/steps/ComposeReviewStep.d.ts +12 -0
  138. package/dist/views/templates/compose/steps/ComposeWorkflowStep.d.ts +11 -0
  139. package/dist/views/templates/compose/use-template-compose-wizard.d.ts +46 -0
  140. package/dist/views/templates/designer/TemplateDesignerView.d.ts +60 -2
  141. package/dist/views/templates/designer/chrome-workflow-chat.d.ts +12 -0
  142. package/dist/views/templates/designer/index.cjs +1 -51
  143. package/dist/views/templates/designer/index.js +2 -2272
  144. package/dist/views/templates/designer/use-workflow-chat.d.ts +21 -0
  145. package/dist/views/templates/designer/use-workflow-designer-controller.d.ts +41 -0
  146. package/dist/views/templates/designer/workflow-chat-drawer.d.ts +16 -0
  147. package/dist/views/templates/index.cjs +2 -1
  148. package/dist/views/templates/index.cjs.map +1 -0
  149. package/dist/views/templates/index.js +265 -4
  150. package/dist/views/templates/index.js.map +1 -0
  151. package/dist/views/templates/versions/index.cjs +1 -1
  152. package/dist/views/templates/versions/index.cjs.map +1 -1
  153. package/dist/views/templates/versions/index.js +39 -43
  154. package/dist/views/templates/versions/index.js.map +1 -1
  155. package/package.json +22 -19
  156. package/dist/chunks/builder-C3E-8OJu.js +0 -1300
  157. package/dist/chunks/builder-C3E-8OJu.js.map +0 -1
  158. package/dist/chunks/builder-f-Q_0NUs.cjs +0 -3
  159. package/dist/chunks/builder-f-Q_0NUs.cjs.map +0 -1
  160. package/dist/chunks/detail-B9JkYNHc.cjs +0 -2
  161. package/dist/chunks/detail-B9JkYNHc.cjs.map +0 -1
  162. package/dist/chunks/detail-CSxI04gB.js +0 -1518
  163. package/dist/chunks/detail-CSxI04gB.js.map +0 -1
  164. package/dist/chunks/form-name-modal-C3OEvkCV.js +0 -64
  165. package/dist/chunks/form-name-modal-C3OEvkCV.js.map +0 -1
  166. package/dist/chunks/form-name-modal-uZCHbtRH.cjs +0 -2
  167. package/dist/chunks/form-name-modal-uZCHbtRH.cjs.map +0 -1
  168. package/dist/chunks/router-adapter-BybHrCNP.cjs +0 -2
  169. package/dist/chunks/routes-config-2aKbWq2H.cjs +0 -2
  170. package/dist/chunks/routes-config-2aKbWq2H.cjs.map +0 -1
  171. package/dist/chunks/routes-config-dxahImVe.js.map +0 -1
  172. package/dist/chunks/templates-CL8bPvgn.cjs +0 -2
  173. package/dist/chunks/templates-CL8bPvgn.cjs.map +0 -1
  174. package/dist/chunks/templates-DNfDOPGm.js +0 -380
  175. package/dist/chunks/templates-DNfDOPGm.js.map +0 -1
  176. package/dist/pages/forms/builder/index.cjs +0 -2
  177. package/dist/pages/forms/builder/index.cjs.map +0 -1
  178. package/dist/pages/forms/builder/index.d.ts +0 -21
  179. package/dist/pages/forms/builder/index.js +0 -15
  180. package/dist/pages/forms/builder/index.js.map +0 -1
  181. package/dist/pages/forms/index.cjs +0 -2
  182. package/dist/pages/forms/index.cjs.map +0 -1
  183. package/dist/pages/forms/index.d.ts +0 -17
  184. package/dist/pages/forms/index.js +0 -14
  185. package/dist/pages/forms/index.js.map +0 -1
  186. package/dist/views/forms/FormsView.d.ts +0 -2
  187. package/dist/views/forms/form-name-modal.d.ts +0 -12
  188. package/dist/views/forms/index.cjs +0 -2
  189. package/dist/views/forms/index.cjs.map +0 -1
  190. package/dist/views/forms/index.d.ts +0 -2
  191. package/dist/views/forms/index.js +0 -186
  192. package/dist/views/forms/index.js.map +0 -1
  193. package/dist/views/templates/designer/index.cjs.map +0 -1
  194. package/dist/views/templates/designer/index.js.map +0 -1
  195. package/dist/views/templates/template-name-modal.d.ts +0 -22
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../chunks/notifications-a-FCxV02.cjs");exports.SettingsNotificationsView=e.t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../chunks/notifications-BKs4--96.cjs");exports.SettingsNotificationsView=e.t;
@@ -1,2 +1,2 @@
1
- import { t as e } from "../../../chunks/notifications-BoNa1BXD.js";
1
+ import { t as e } from "../../../chunks/notifications-CSulztkU.js";
2
2
  export { e as SettingsNotificationsView };
@@ -1,2 +1,7 @@
1
1
  import { ReactElement } from 'react';
2
+ export interface TemplateCategoryOption {
3
+ readonly categoryId: string | null;
4
+ readonly id: string;
5
+ readonly name: string;
6
+ }
2
7
  export declare function TemplatesView(): ReactElement;
@@ -0,0 +1,8 @@
1
+ import { ReactElement } from 'react';
2
+ /**
3
+ * Unified "form + flow" template creation wizard. Walks the user through
4
+ * Step 0 表單設計 → Step 1 流程設計 → Step 2 檢視並發佈, then commits both
5
+ * sides atomically through `composeApprovalTemplateWithForm`. Coexists with
6
+ * the separate `/forms` and `/templates` entry points.
7
+ */
8
+ export declare function TemplateComposeWizardView(): ReactElement;
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../chunks/compose-ziVbRYdo.cjs");exports.EMPTY_COMPOSE_FORM_SCHEMA=e.n,exports.EMPTY_COMPOSE_FORM_UI_SCHEMA=e.r,exports.TemplateComposeWizardView=e.t,exports.useTemplateComposeWizard=e.i;
@@ -0,0 +1,2 @@
1
+ export * from './TemplateComposeWizardView';
2
+ export * from './use-template-compose-wizard';
@@ -0,0 +1,2 @@
1
+ import { i as e, n as t, r as n, t as r } from "../../../chunks/compose-PMrmi-LE.js";
2
+ export { t as EMPTY_COMPOSE_FORM_SCHEMA, n as EMPTY_COMPOSE_FORM_UI_SCHEMA, r as TemplateComposeWizardView, e as useTemplateComposeWizard };
@@ -0,0 +1,15 @@
1
+ import { ReactElement } from 'react';
2
+ import { FormDefinitionSchema, FormUiSchema } from '@rytass/bpm-core-shared/form';
3
+ export interface ComposeFormStepProps {
4
+ readonly name: string;
5
+ readonly categoryId: string | null;
6
+ readonly formSchema: FormDefinitionSchema;
7
+ readonly formUiSchema: FormUiSchema;
8
+ readonly onNameChange: (value: string) => void;
9
+ readonly onCategoryIdChange: (value: string | null) => void;
10
+ readonly onFormChange: (next: {
11
+ readonly schema: FormDefinitionSchema;
12
+ readonly uiSchema: FormUiSchema;
13
+ }) => void;
14
+ }
15
+ export declare function ComposeFormStep({ categoryId, formSchema, formUiSchema, name, onCategoryIdChange, onFormChange, onNameChange, }: ComposeFormStepProps): ReactElement;
@@ -0,0 +1,12 @@
1
+ import { ReactElement } from 'react';
2
+ import { FormDefinitionSchema, FormUiSchema } from '@rytass/bpm-core-shared/form';
3
+ import { WorkflowDefinition } from '@rytass/bpm-core-shared/workflow';
4
+ export interface ComposeReviewStepProps {
5
+ readonly name: string;
6
+ readonly formSchema: FormDefinitionSchema;
7
+ readonly formUiSchema: FormUiSchema;
8
+ readonly workflowDefinition: WorkflowDefinition | null;
9
+ readonly initiatorPolicyCel: string | null;
10
+ readonly publishError: string | null;
11
+ }
12
+ export declare function ComposeReviewStep({ formSchema, formUiSchema, initiatorPolicyCel, name, publishError, workflowDefinition, }: ComposeReviewStepProps): ReactElement;
@@ -0,0 +1,11 @@
1
+ import { ReactElement } from 'react';
2
+ import { FormDefinitionSchema } from '@rytass/bpm-core-shared/form';
3
+ import { WorkflowDefinition } from '@rytass/bpm-core-shared/workflow';
4
+ export interface ComposeWorkflowStepProps {
5
+ readonly formSchema: FormDefinitionSchema;
6
+ readonly workflowDefinition: WorkflowDefinition | null;
7
+ readonly initiatorPolicyCel: string | null;
8
+ readonly onWorkflowChange: (definition: WorkflowDefinition) => void;
9
+ readonly onInitiatorPolicyChange: (cel: string | null) => void;
10
+ }
11
+ export declare function ComposeWorkflowStep({ formSchema, initiatorPolicyCel, onInitiatorPolicyChange, onWorkflowChange, workflowDefinition, }: ComposeWorkflowStepProps): ReactElement;
@@ -0,0 +1,46 @@
1
+ import { FormDefinitionSchema, FormUiSchema } from '@rytass/bpm-core-shared/form';
2
+ import { WorkflowDefinition } from '@rytass/bpm-core-shared/workflow';
3
+ import { ComposeApprovalTemplateWithFormResult } from '@rytass/bpm-core-client/template';
4
+ export type ComposeWizardStep = 0 | 1 | 2;
5
+ export type ComposePublishPhase = 'error' | 'idle' | 'submitting' | 'success';
6
+ export declare const EMPTY_COMPOSE_FORM_SCHEMA: FormDefinitionSchema;
7
+ export declare const EMPTY_COMPOSE_FORM_UI_SCHEMA: FormUiSchema;
8
+ export interface TemplateComposeWizard {
9
+ readonly currentStep: ComposeWizardStep;
10
+ /**
11
+ * Single user-facing name. Persisted to both the template and the form
12
+ * (`templateName` / `formName`) at the `composeApprovalTemplateWithForm`
13
+ * boundary — the DB keeps two columns, the UI keeps one field.
14
+ */
15
+ readonly name: string;
16
+ readonly categoryId: string | null;
17
+ readonly formSchema: FormDefinitionSchema;
18
+ readonly formUiSchema: FormUiSchema;
19
+ readonly workflowDefinition: WorkflowDefinition | null;
20
+ readonly initiatorPolicyCel: string | null;
21
+ readonly publishPhase: ComposePublishPhase;
22
+ readonly publishError: string | null;
23
+ readonly canLeaveBasics: boolean;
24
+ readonly goToStep: (step: ComposeWizardStep) => void;
25
+ readonly goNext: () => void;
26
+ readonly goBack: () => void;
27
+ readonly setName: (value: string) => void;
28
+ readonly setCategoryId: (value: string | null) => void;
29
+ readonly setFormValue: (next: {
30
+ readonly schema: FormDefinitionSchema;
31
+ readonly uiSchema: FormUiSchema;
32
+ }) => void;
33
+ readonly setWorkflowDefinition: (definition: WorkflowDefinition) => void;
34
+ readonly setInitiatorPolicyCel: (cel: string | null) => void;
35
+ readonly publish: () => Promise<ComposeApprovalTemplateWithFormResult | null>;
36
+ }
37
+ /**
38
+ * Owns the cross-step state for the unified "form + flow" template wizard.
39
+ *
40
+ * Step 0 (表單) edits `formSchema`/`formUiSchema`; that same in-memory schema
41
+ * feeds Step 1 (流程) as the field source for condition branches, so the
42
+ * embedded designer never needs a published form version. Step 2 (檢視發佈)
43
+ * submits everything through the atomic `composeApprovalTemplateWithForm`
44
+ * mutation.
45
+ */
46
+ export declare function useTemplateComposeWizard(): TemplateComposeWizard;
@@ -1,5 +1,63 @@
1
1
  import { ReactElement } from 'react';
2
+ import { FormDefinitionSchema } from '@rytass/bpm-core-shared/form';
3
+ import { WorkflowDefinition } from '@rytass/bpm-core-shared/workflow';
2
4
  export interface TemplateDesignerViewProps {
3
- readonly templateId: string;
5
+ /**
6
+ * Template id to load. Required in non-embedded mode; unused in embedded mode.
7
+ */
8
+ readonly templateId?: string;
9
+ /**
10
+ * When `true`, the component operates in embedded / wizard mode:
11
+ * - No `readTemplateDesigner` call (no templateId needed).
12
+ * - Only org data is loaded for approver pickers.
13
+ * - PageHeader / ContentHeader, form-version binding, dry-run, and the AI
14
+ * drawer are hidden.
15
+ * - Mutations flow out via `onWorkflowChange` / `onInitiatorPolicyChange`
16
+ * rather than save-draft / publish actions.
17
+ * Default `false`.
18
+ */
19
+ readonly embedded?: boolean;
20
+ /**
21
+ * In embedded mode: the formSchema used for condition-edge compilation,
22
+ * injected from outside (e.g. the wizard already knows the form). Replaces
23
+ * the "bind form version" picker. Pass `null` to clear.
24
+ */
25
+ readonly formSchemaOverride?: FormDefinitionSchema | null;
26
+ /**
27
+ * In embedded mode: the initial workflow definition to seed the canvas.
28
+ * Falls back to an empty start→end workflow when omitted.
29
+ */
30
+ readonly initialWorkflowDefinition?: WorkflowDefinition;
31
+ /**
32
+ * In embedded mode: the initial initiator-policy CEL expression.
33
+ * Falls back to `null` (no policy) when omitted.
34
+ */
35
+ readonly initialInitiatorPolicyCel?: string | null;
36
+ /**
37
+ * In embedded mode: called whenever the workflow definition changes so the
38
+ * host can persist the current canvas state.
39
+ */
40
+ readonly onWorkflowChange?: (definition: WorkflowDefinition) => void;
41
+ /**
42
+ * In embedded mode: called whenever the initiator-policy CEL changes.
43
+ */
44
+ readonly onInitiatorPolicyChange?: (cel: string | null) => void;
45
+ /**
46
+ * Render the "試跑流程" (dry-run) button at all. Default `true`. Hosts can
47
+ * pass `false` to hide it (e.g. deployments that don't expose dry-run).
48
+ * Has no effect in embedded mode, where the PageHeader is hidden entirely.
49
+ */
50
+ readonly showDryRun?: boolean;
51
+ /**
52
+ * Render the AI assistant toggle at all. Default `false` — the feature is
53
+ * hidden unless the host opts in (e.g. a deployment that has it configured).
54
+ */
55
+ readonly showAiAssistant?: boolean;
56
+ /**
57
+ * Whether the LLM backend is configured (e.g. the host has an API key set).
58
+ * Default `true`. When `false`, the toggle is shown but disabled and labelled
59
+ * as not configured — a placeholder rather than a broken feature.
60
+ */
61
+ readonly aiAssistantAvailable?: boolean;
4
62
  }
5
- export declare function TemplateDesignerView({ templateId, }: TemplateDesignerViewProps): ReactElement;
63
+ export declare function TemplateDesignerView({ aiAssistantAvailable, embedded, formSchemaOverride, initialInitiatorPolicyCel, initialWorkflowDefinition, onInitiatorPolicyChange, onWorkflowChange, showAiAssistant, showDryRun, templateId, }: TemplateDesignerViewProps): ReactElement;
@@ -0,0 +1,12 @@
1
+ import { UIMessage } from 'ai';
2
+ import { WorkflowDesignerController } from './use-workflow-designer-controller';
3
+ export interface UseChromeWorkflowChatResult {
4
+ /** True only when the on-device model is usable in this browser. */
5
+ readonly available: boolean;
6
+ readonly messages: readonly UIMessage[];
7
+ readonly status: 'ready' | 'submitted' | 'streaming' | 'error';
8
+ readonly send: (text: string) => void;
9
+ }
10
+ export declare function useChromeWorkflowChat({ controller, }: {
11
+ readonly controller: WorkflowDesignerController;
12
+ }): UseChromeWorkflowChatResult;
@@ -1,51 +1 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../chunks/chunk-CMqjfN_6.cjs"),t=require("../../../chunks/router-adapter-BybHrCNP.cjs"),n=require("../../../chunks/routes-config-2aKbWq2H.cjs"),r=require("../../../chunks/admin-pickers-Btvij1at.cjs"),i=require("../../../chunks/bpm-form-field-Bc6k4ZEO.cjs");let a=require("react"),o=require("@mezzanine-ui/react"),s=require("react/jsx-runtime"),c=require("@mezzanine-ui/react/ContentHeader");c=e.t(c,1);let l=require("@mezzanine-ui/icons"),ee=require("@rytass/bpm-core-client/organization"),u=require("@xyflow/react"),d=require("dagre");d=e.t(d,1);let f=require("@rytass/bpm-core-client/template");var te={display:`grid`,gap:16},ne={alignItems:`start`,display:`grid`,gap:16,gridTemplateColumns:`minmax(0, 1fr) 420px`},re={border:`1px solid var(--mzn-color-border-neutral)`,borderRadius:6,height:620,minWidth:0,overflow:`hidden`},ie={alignItems:`center`,boxSizing:`border-box`,color:`var(--mzn-color-text-error)`,display:`flex`,height:26,justifyContent:`center`,lineHeight:0,padding:0,width:26},ae={alignItems:`center`,display:`flex`,height:`100%`,justifyContent:`center`,width:`100%`},p=`workflow-designer-side-panel`,oe=96,se=`
2
- .${p} .mzn-form-field--stretch .mzn-form-field__label-area,
3
- .${p} .mzn-form-field--horizontal .mzn-form-field__label-area {
4
- flex: 0 0 ${oe}px;
5
- width: ${oe}px;
6
- }
7
-
8
- .${p} .mzn-form-field--stretch .mzn-form-field__data-entry,
9
- .${p} .mzn-form-field--horizontal .mzn-form-field__data-entry {
10
- min-width: 0;
11
- }
12
- `,m=`#2563eb`,h=`#64748b`,ce=`var(--mzn-color-text-error, #dc2626)`,g=`drop-shadow(0 0 3px rgba(0, 87, 255, 0.85)) drop-shadow(0 0 9px rgba(0, 87, 255, 0.36))`,le=`
13
- .workflow-selection-delete-control.react-flow__controls-button {
14
- align-items: center !important;
15
- display: flex !important;
16
- height: 26px !important;
17
- justify-content: center !important;
18
- padding: 0 !important;
19
- width: 26px !important;
20
- }
21
-
22
- .workflow-selection-delete-control .mzn-icon {
23
- align-items: center;
24
- display: flex;
25
- justify-content: center;
26
- }
27
-
28
- .workflow-selection-delete-control .mzn-icon svg {
29
- height: 16px !important;
30
- max-height: none !important;
31
- max-width: none !important;
32
- width: 16px !important;
33
- }
34
-
35
- .workflow-edge--selected .react-flow__edge-path,
36
- .react-flow__edge-path.workflow-edge--selected {
37
- filter: ${g};
38
- opacity: 1 !important;
39
- stroke: ${h} !important;
40
- stroke-opacity: 1 !important;
41
- stroke-width: 1.5px !important;
42
- }
43
-
44
- .workflow-edge--selected {
45
- --xy-edge-stroke: ${h};
46
- --xy-edge-stroke-selected: ${h};
47
- --xy-edge-stroke-width: 1.5px;
48
- }
49
-
50
- `,ue={display:`grid`,gap:12},_={display:`grid`,gap:12},de={border:`1px solid var(--mzn-color-border-neutral)`,borderRadius:6,display:`grid`,gap:8,maxHeight:360,overflow:`auto`,padding:12},fe={borderBottom:`1px solid var(--mzn-color-border-neutral)`,display:`grid`,gap:4,padding:`0 0 8px`},pe={display:`flex`,flexWrap:`wrap`,gap:8},me={display:`grid`,gap:8},v={alignContent:`center`,background:`var(--mzn-color-bg-surface)`,border:`1px solid var(--mzn-color-border-neutral)`,borderRadius:6,boxShadow:`0 8px 20px rgba(15, 23, 42, 0.08)`,boxSizing:`border-box`,display:`grid`,gap:4,height:`100%`,minWidth:132,overflow:`visible`,padding:`10px 12px`,textAlign:`center`,width:`100%`},y=`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)`,b=64,he=160,ge=20,x=64,_e=180,S={...v,display:`grid`,gap:8,padding:`10px 12px`},ve={...S,background:`#eff6ff`,border:`1px solid #2563eb`},ye={...S,background:`#f0fdfa`,border:`1px solid #0f766e`},be={...v,background:`#ffffff`},xe={...v,background:`#ecfdf3`,border:`1px solid #2f855a`},Se={...v,background:`#fff4ed`,border:`1px solid #c2410c`},C={display:`block`,maxWidth:`100%`,minWidth:0},w={display:`grid`,gap:2,minWidth:0},T=`input`,E=`output`,Ce={endEvent:`結束`,exclusiveGateway:`條件分流`,parallelGateway:`並行處理`,serviceTask:`系統`,startEvent:`開始`,userTask:`簽核`},we=[{icon:l.UserIcon,label:`簽核節點`,type:`userTask`},{icon:l.MailIcon,label:`知會節點`,type:`serviceTask`}],Te=[{icon:l.FilterIcon,label:`條件分流`,type:`exclusiveGateway`}],Ee=[{id:`AND`,name:`全部前置完成`},{id:`OR`,name:`任一前置完成`}],De=[{id:`RESTART`,name:`重新送出後從開始重跑`},{id:`FROM_RETURN_POINT`,name:`重新送出後回到退回節點`}],Oe=[{id:`DIRECT`,name:`指定會員`},{id:`ORG_MANAGER`,name:`發起人主管`},{id:`ORG_UNIT_MANAGER`,name:`指定組織主管`},{id:`ORG_UNIT_MEMBER`,name:`組織任一人`},{id:`ORG_UNIT_POSITION`,name:`組織特定職位`},{id:`POSITION`,name:`指定職位`}],D=[{id:`1`,name:`直屬主管`,value:1},{id:`2`,name:`第二層主管`,value:2},{id:`3`,name:`第三層主管`,value:3}],ke=[{id:`NONE`,name:`停止流程並提示`},{id:`DIRECT`,name:`固定改派`}],O=[{id:`EQUALS`,name:`等於`},{id:`NOT_EQUALS`,name:`不等於`},{id:`GREATER_THAN`,name:`大於`},{id:`GREATER_THAN_OR_EQUALS`,name:`大於等於`},{id:`LESS_THAN`,name:`小於`},{id:`LESS_THAN_OR_EQUALS`,name:`小於等於`},{id:`IS_FILLED`,name:`已填寫`},{id:`IS_EMPTY`,name:`未填寫`}],k=[`EQUALS`,`GREATER_THAN`,`GREATER_THAN_OR_EQUALS`,`LESS_THAN`,`LESS_THAN_OR_EQUALS`,`NOT_EQUALS`],Ae=[{id:`NONE`,name:`未設定`},{id:`ALL`,name:`所有人`},{id:`ORG_UNIT`,name:`指定組織`},{id:`ORG_UNIT_POSITION`,name:`指定組織職位`}],je={id:`CUSTOM`,name:`既有自訂規則`},Me=`member-001`,Ne={endEvent:A,exclusiveGateway:A,parallelGateway:A,serviceTask:A,startEvent:A,userTask:A};function Pe({templateId:e}){let d=t.r(),oe=n.r(),[m,h]=(0,a.useState)(null),[g,v]=(0,a.useState)(null),[y,b]=(0,a.useState)($e()),[he,ge]=(0,a.useState)(``),[x,_e]=(0,a.useState)(null),[S,ve]=(0,a.useState)(null),[ye,be]=(0,a.useState)(null),[xe,Se]=(0,a.useState)(null),[C,w]=(0,a.useState)(`start`),[T,E]=(0,a.useState)([]),[O,k]=(0,a.useState)(null),[Pe,A]=(0,a.useState)(null),[Ie,Le]=(0,a.useState)(!0),[Re,ze]=(0,a.useState)(!1),[j,Ve]=(0,a.useState)(!1),[M,He]=(0,a.useState)([]),qe=(0,a.useMemo)(()=>JSON.stringify({formDefinitionVersionId:x,initiatorPolicyCel:S,workflowDefinition:y}),[x,S,y]),Je=!!he&&qe!==he,[N,Qe]=(0,a.useState)(!1),[F,dt]=(0,a.useState)([]),[L,ht]=(0,a.useState)([]),[R,z]=(0,a.useState)([]),[B,Ct]=(0,a.useState)([]),[Tt,H]=(0,a.useState)(!1),[U,Ft]=(0,a.useState)(!1),[It,Lt]=(0,a.useState)(`{}`),[W,G]=(0,a.useState)(null),[Vt,Ht]=(0,a.useState)(null),[Ut,Wt]=(0,a.useState)(void 0),Gt=(0,a.useRef)(null);(0,a.useEffect)(()=>{bn()},[e]),(0,a.useEffect)(()=>{function e(e){Je&&(e.preventDefault(),e.returnValue=``)}return window.addEventListener(`beforeunload`,e),()=>{window.removeEventListener(`beforeunload`,e)}},[Je]),(0,a.useEffect)(()=>{Sn(y)},[y,F]),(0,a.useEffect)(()=>{b(e=>Ke(e))},[y.edges,y.nodes]);function Jt(){Je&&!window.confirm(`目前有尚未儲存的流程草稿,確定要離開嗎?`)||d.push(oe.templates())}let K=(0,a.useMemo)(()=>y.nodes.find(e=>e.id===C)??null,[C,y.nodes]),on=K?yt(K):!1,sn=T.length>0||on,cn=(0,a.useCallback)(()=>{let e=K&&yt(K)?K.id:null;b(t=>({...t,edges:t.edges.filter(t=>!T.includes(t.id)&&t.source!==e&&t.target!==e),nodes:e?t.nodes.filter(t=>t.id!==e):t.nodes})),E([]),k(null),e&&w(`start`)},[T,K]);(0,a.useEffect)(()=>{if(!sn)return;function e(e){e.key!==`Delete`&&e.key!==`Backspace`||bt(e.target)||(e.preventDefault(),cn())}return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[sn,cn]);let un=(0,a.useMemo)(()=>y.edges.find(e=>e.id===O)??null,[O,y.edges]),dn=(0,a.useMemo)(()=>T.length===1?y.edges.find(e=>e.id===T[0])??null:null,[T,y.edges]),fn=(0,a.useMemo)(()=>T.map(e=>y.edges.find(t=>t.id===e)??null).filter(e=>!!e),[T,y.edges]),q=(0,a.useMemo)(()=>xe??ft(S,ye),[S,xe,ye]),mn=(0,a.useMemo)(()=>y.nodes.map(e=>Be(e,F,L,R,e.id===C,q)),[q,F,L,R,C,y.nodes]),gn=(0,a.useMemo)(()=>y.edges.map(e=>Ue(e,y.nodes,T.includes(e.id))),[T,y.edges,y.nodes]),X=(0,a.useMemo)(()=>I(M,x)??I(xt(m?.formVersions??[]),x),[x,M,m?.formVersions]),_n=(0,a.useMemo)(()=>Ot(M,X),[M,X]),vn=(0,a.useMemo)(()=>qt(y),[y]),Z=(0,a.useMemo)(()=>Yt(y),[y]),yn=(0,a.useMemo)(()=>pt(q),[q]);async function bn(){Le(!0),A(null);try{let[t,n]=await Promise.all([(0,f.readTemplateDesigner)(e),(0,ee.readOrganizationDashboard)()]),r=t.versions.find(e=>e.status===`DRAFT`)??null,i=r??t.versions[0]??null;h(t),v(r),ht(n.orgUnits),z(n.positions),Ct(n.memberships),He(xt(t.formVersions));let a=i?.workflowDefinition??$e(),o=i?.formDefinitionVersionId??t.formVersions[0]?.id??null,s=i?.initiatorPolicyCel??null;b(a),_e(o),ve(s),ge(JSON.stringify({formDefinitionVersionId:o,initiatorPolicyCel:s,workflowDefinition:a})),be(i&&!t.template.currentVersionId&&!i.initiatorPolicyCel&&et(i.workflowDefinition)?`NONE`:null),Se(null),w(i?.workflowDefinition.nodes[0]?.id??`start`),E([]),k(null)}catch(e){A(Y(e))}finally{Le(!1)}}async function xn(e){Ve(!0),A(null);try{He(Ot(xt(await(0,f.searchPublishedFormVersionOptions)(e)),X))}catch(e){A(Y(e))}finally{Ve(!1)}}async function Q(e){Qe(!0),A(null);try{let t=await(0,f.searchMemberOptions)(e);dt(e=>zt(e,kt(t)))}catch(e){A(Y(e))}finally{Qe(!1)}}async function Sn(e){let t=Bt(e).filter(e=>!F.some(t=>t.memberId===e));if(t.length!==0)try{let e=await(0,f.resolveMemberOptions)(t);dt(t=>zt(t,kt(e)))}catch{dt(e=>zt(e,t.map(At)))}}async function Cn(){ze(!0),A(null);try{let t=qt(y),n=pt(q);if(t||n){let e=t??n??`流程設定未完成`;throw A(e),Error(e)}let r=await(0,f.updateApprovalTemplateDraft)({formDefinitionVersionId:x,initiatorPolicyCel:S,versionId:(g??await(0,f.forkApprovalTemplate)(e)).id,workflowDefinition:y});return v(r),await bn(),r}catch(e){throw A(Y(e)),e}finally{ze(!1)}}async function wn(){ze(!0),A(null);try{await(0,f.publishApprovalTemplateVersion)((await Cn()).id),await bn()}catch(e){A(Y(e))}finally{ze(!1)}}function Tn(){Lt(JSON.stringify(St(X),null,2)),G(null),Ht(null),H(!0)}function En(){U||H(!1)}async function Dn(){Ft(!0),Ht(null),G(null);try{G(await(0,f.dryRunApprovalWorkflow)({formData:wt(It),initiatorMemberId:Me,initiatorMetadataSnapshot:Pt(Me,B),workflowDefinition:y}))}catch(e){Ht(Y(e))}finally{Ft(!1)}}function On(e){let t=(0,u.applyNodeChanges)(e,mn);b(e=>({...e,nodes:e.nodes.map(e=>{let n=t.find(t=>t.id===e.id);return n?{...e,position:n.position}:e})}))}function kn(e){if(!_t(e,y.nodes))return;let t=y.nodes.some(t=>t.id===e.source&&t.type===`exclusiveGateway`),n=P(e.source,e.target,{});b(e=>({...e,edges:[...e.edges,n]})),w(null),E([n.id]),k(t?n.id:null)}function An(e,t){e.stopPropagation(),E(n=>e.shiftKey||e.metaKey||e.ctrlKey?vt(n,t.id):[t.id]),w(null)}function jn(){k(null)}function Mn(e){let t=Ze({definition:y,node:Ye(e,Xe(y.nodes,e)),selectedEdgeId:T.length===1?T[0]:null,selectedNodeId:C}),n=tt(t.definition),r=Kt(n,Gt.current);b(n),w(t.selectedNodeId),E(t.selectedEdgeIds),k(t.editingEdgeId),r&&Wt(r)}function Nn(e){K&&Rn(K.id,t=>We(t,e))}function $(e){!K||K.type!==`userTask`||Rn(K.id,t=>t.type===`userTask`?{...t,data:{...t.data,approverResolver:e,decisionPolicy:{type:`SINGLE`}}}:t)}function Pn(e){!K||K.type!==`userTask`||Rn(K.id,t=>t.type===`userTask`?{...t,data:{...t.data,returnBehavior:{...t.data.returnBehavior,resubmitStrategy:e}}}:t)}function Fn(e){!K||K.type!==`serviceTask`||Rn(K.id,t=>t.type===`serviceTask`?{...t,data:{...t.data,action:e}}:t)}function In(e){Se(e.mode===`ALL`||e.mode===`CUSTOM`?null:e),be(e.mode===`ALL`||e.mode===`CUSTOM`?null:e.mode),ve(mt(e,L))}function Ln(e){!K||K.type===`startEvent`||Rn(K.id,t=>Ge(t,e))}function Rn(e,t){b(n=>({...n,nodes:n.nodes.map(n=>n.id===e?t(n):n)}))}function zn(e,t){b(n=>({...n,edges:n.edges.map(n=>n.id===e?t(n):n)}))}function Bn(e,t){b(n=>{let r=n.edges.find(t=>t.id===e);return r?{...n,edges:n.edges.map(e=>t&&e.source===r.source&&e.id!==r.id&&J(e,n.nodes)?{...e,data:{...e.data,isDefault:!1}}:e.id===r.id?{...e,data:{...e.data,isDefault:t}}:e)}:n})}function Vn({edgeId:e,fieldKey:t,operator:n,value:r}){let i=X?.schema??null;zn(e,e=>{let a=Zt(i,t??e.data.conditionFieldKey??null),o=tn(a,n??e.data.conditionOperator??null),s=nn(a,o,r??e.data.conditionValue??null),c=an(a,o,s);return{...e,data:{...e.data,condition:ln(a,o,s),conditionFieldKey:a?.fieldKey,conditionOperator:o,conditionValue:s,isDefault:!1,label:c}}})}function Hn(){let e=tt(y),t=Kt(e,Gt.current);b(e),t&&Wt(t)}return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`style`,{children:se}),(0,s.jsx)(o.PageHeader,{children:(0,s.jsxs)(c.default,{description:`${g?`草稿 v${g.version}`:`尚未建立草稿`} ·${m?.template.currentVersionId?` 已發布版本`:` 尚未發布`}`,onBackClick:Jt,title:m?.template.name??`流程設計器`,children:[(0,s.jsx)(o.Button,{"aria-label":`儲存草稿`,disabled:Re||!!vn||!!yn,icon:l.SaveIcon,iconType:`icon-only`,onClick:()=>void Cn(),variant:`base-secondary`,children:`儲存草稿`}),(0,s.jsx)(o.Button,{disabled:Ie||!!vn||!!yn,icon:l.EyeIcon,iconType:`leading`,onClick:Tn,variant:`base-secondary`,children:`試跑流程`}),(0,s.jsx)(o.Button,{disabled:Re||!g||!!vn||!!yn,icon:l.CheckedIcon,iconType:`leading`,onClick:()=>void wn(),variant:`base-primary`,children:`發布版本`})]})}),(0,s.jsx)(o.SectionGroup,{children:(0,s.jsx)(o.Section,{children:(0,s.jsxs)(`div`,{style:te,children:[Pe?(0,s.jsx)(o.Typography,{color:`text-error`,variant:`body`,children:Pe}):null,vn?(0,s.jsx)(o.Typography,{color:`text-error`,variant:`body`,children:vn}):null,yn?(0,s.jsx)(o.Typography,{color:`text-error`,variant:`body`,children:yn}):null,(0,s.jsx)(`div`,{style:_,children:(0,s.jsx)(i.t,{hintText:Z?`已設定條件分流條件。請先移除所有條件,才能更換綁定表單版本。`:void 0,label:`綁定表單版本`,name:`formDefinitionVersionId`,required:!0,children:(0,s.jsx)(o.AutoComplete,{asyncData:!0,disabled:Ie||Z,disabledOptionsFilter:!0,emptyText:`沒有符合的已發布表單版本`,isForceClearable:!!x&&!Z,loading:j,loadingText:`搜尋表單版本中...`,mode:`single`,onChange:e=>{Z||_e(e?.id??null)},onClear:()=>{Z||_e(null)},onSearch:xn,onVisibilityChange:e=>{e&&!Z&&xn(``)},options:[..._n],placeholder:`選擇已發布表單版本`,searchDebounceTime:300,value:X})})}),(0,s.jsxs)(`div`,{style:ne,children:[(0,s.jsx)(`div`,{ref:Gt,style:re,children:(0,s.jsxs)(u.ReactFlow,{connectionMode:u.ConnectionMode.Strict,edges:gn,fitView:!0,isValidConnection:e=>_t(e,y.nodes),nodeTypes:Ne,nodes:mn,deleteKeyCode:null,multiSelectionKeyCode:[`Shift`,`Meta`,`Control`],onConnect:kn,onEdgeClick:An,onNodeClick:(e,t)=>{w(t.id),E([])},onNodesChange:On,onPaneClick:()=>{w(null),E([])},onViewportChange:Wt,viewport:Ut,children:[(0,s.jsx)(u.Background,{}),(0,s.jsx)(`style`,{children:le}),(0,s.jsx)(u.Controls,{children:sn?(0,s.jsx)(u.ControlButton,{"aria-label":`刪除選取項目`,className:`workflow-selection-delete-control`,onClick:cn,style:ie,title:`刪除選取項目`,children:(0,s.jsx)(`span`,{style:ae,children:(0,s.jsx)(o.Icon,{color:`error`,icon:l.TrashIcon,size:16})})}):null}),(0,s.jsx)(Fe,{onApplyAutoLayout:Hn}),(0,s.jsx)(u.MiniMap,{})]})}),(0,s.jsxs)(`div`,{className:p,style:ue,children:[(0,s.jsx)(o.Typography,{component:`h2`,variant:`h3`,children:`流程工具`}),(0,s.jsxs)(`div`,{style:me,children:[(0,s.jsx)(o.Typography,{color:`text-neutral`,variant:`caption`,children:`動作節點`}),(0,s.jsx)(`div`,{style:pe,children:we.map(e=>(0,s.jsx)(o.Button,{icon:e.icon,iconType:`leading`,onClick:()=>Mn(e.type),size:`sub`,variant:`base-secondary`,children:e.label},e.type))})]}),(0,s.jsxs)(`div`,{style:me,children:[(0,s.jsx)(o.Typography,{color:`text-neutral`,variant:`caption`,children:`流程控制`}),(0,s.jsx)(`div`,{style:pe,children:Te.map(e=>(0,s.jsx)(o.Button,{icon:e.icon,iconType:`leading`,onClick:()=>Mn(e.type),size:`sub`,variant:`base-secondary`,children:e.label},e.type))})]}),fn.length>1?Yn(fn):null,fn.length===1&&dn?Xn(dn):null,fn.length===0&&K?Wn(K):null]})]})]})})}),Zn(un),Un()]});function Un(){return(0,s.jsx)(o.Modal,{cancelText:`關閉`,confirmText:`執行試跑`,loading:U,modalType:`standard`,onCancel:En,onClose:En,onConfirm:()=>void Dn(),open:Tt,showModalFooter:!0,showModalHeader:!0,size:`wide`,supportingText:`使用 ${Me} 與範例表單資料模擬目前畫布流程,不會建立案件。`,title:`試跑流程`,children:(0,s.jsxs)(`div`,{style:_,children:[(0,s.jsx)(i.t,{label:`表單資料 JSON`,name:`dryRunFormDataJson`,required:!0,children:(0,s.jsx)(o.Textarea,{onChange:e=>Lt(e.target.value),resize:`vertical`,rows:8,value:It})}),Vt?(0,s.jsx)(o.Typography,{color:`text-error`,variant:`body`,children:Vt}):null,W?(0,s.jsxs)(`div`,{style:de,children:[(0,s.jsx)(o.Typography,{color:W.valid?`text-success`:`text-error`,variant:`label-primary-highlight`,children:W.valid?`試跑通過`:`試跑失敗`}),W.errors.map(e=>(0,s.jsx)(o.Typography,{color:`text-error`,variant:`body`,children:e},e)),W.steps.map(e=>(0,s.jsxs)(`div`,{style:fe,children:[(0,s.jsxs)(o.Typography,{variant:`label-primary-highlight`,children:[e.nodeLabel,` · `,Et(e.status)]}),(0,s.jsxs)(o.Typography,{color:`text-neutral`,variant:`caption`,children:[Dt(e.nodeType),e.assigneeMemberId?` · 處理者:${e.assigneeMemberId}`:``,e.edgeLabel?` · 來源線段:${e.edgeLabel}`:``]}),e.edgeReason?(0,s.jsx)(o.Typography,{color:`text-neutral`,variant:`caption`,children:e.edgeReason}):null,e.entryCondition?(0,s.jsxs)(o.Typography,{color:`text-neutral`,variant:`caption`,children:[`進入條件:`,e.entryConditionMatched?`符合`:`不符合`,` ·`,` `,e.entryCondition]}):null,(0,s.jsx)(o.Typography,{color:`text-neutral`,variant:`body`,children:e.message})]},e.id))]}):null]})})}function Wn(e){return(0,s.jsxs)(`div`,{style:_,children:[(0,s.jsx)(o.Typography,{component:`h2`,variant:`h3`,children:`節點屬性`}),(0,s.jsxs)(o.Typography,{color:`text-neutral`,variant:`body`,children:[Ce[e.type],` · `,e.id]}),(0,s.jsx)(i.t,{label:`顯示名稱`,name:`nodeLabel`,required:!0,children:(0,s.jsx)(o.Input,{onChange:e=>Nn(e.target.value),value:e.data.label,variant:`base`})}),e.type===`startEvent`?Gn():null,e.type===`startEvent`?null:Kn(e),e.type===`userTask`?qn(e):null,e.type===`serviceTask`?Jn(e):null]})}function Gn(){let e=q.mode===`CUSTOM`?[...Ae,je]:[...Ae],t=q.mode===`ORG_UNIT`||q.mode===`ORG_UNIT_POSITION`?Mt(L,q.orgUnitId??``):null,n=q.mode===`ORG_UNIT_POSITION`?Nt(R,q.positionId??``):null,a=q.mode===`ORG_UNIT_POSITION`?Rt({includeDescendants:!!q.includeDescendants,memberships:B,orgUnitId:q.orgUnitId??``,orgUnits:L,positions:R}):[];return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.t,{hintText:q.mode===`CUSTOM`?`這是舊版表達式規則;切換成標準選項後會改由 UI 管理。`:void 0,label:`發起權限`,name:`initiatorPolicyMode`,required:!0,children:(0,s.jsx)(o.Select,{clearable:!1,onChange:e=>{if(e?.id===`CUSTOM`){be(null),Se(null);return}let t=ut(e?.id??null),n=gt(t);be(t===`ALL`?null:t),Se(t===`ALL`?null:n),ve(mt(n,L))},options:e,placeholder:`選擇誰可以發起`,value:I(e,q.mode)})}),q.mode===`ORG_UNIT`||q.mode===`ORG_UNIT_POSITION`?(0,s.jsx)(i.t,{label:`組織`,name:`initiatorOrgUnitId`,required:!0,children:(0,s.jsx)(r.n,{name:`initiatorOrgUnitId`,onChange:e=>In({...q,orgUnitId:e?.id??``,positionId:``,value:e?.id??``}),orgUnits:L,placeholder:`選擇組織`,value:t})}):null,q.mode===`ORG_UNIT`||q.mode===`ORG_UNIT_POSITION`?(0,s.jsx)(i.t,{label:`包含下層`,name:`initiatorIncludeDescendants`,children:(0,s.jsx)(o.Toggle,{checked:!!q.includeDescendants,onChange:e=>In({...q,includeDescendants:e.target.checked,...q.mode===`ORG_UNIT_POSITION`?{positionId:``}:{}})})}):null,q.mode===`ORG_UNIT_POSITION`?(0,s.jsx)(i.t,{label:`職位`,name:`initiatorPositionId`,required:!0,children:(0,s.jsx)(r.r,{disabled:!q.orgUnitId?.trim(),name:`initiatorPositionId`,onChange:e=>In({...q,positionId:e?.id??``}),placeholder:q.orgUnitId?.trim()?`選擇職位`:`請先選擇組織`,positions:a,value:n})}):null]})}function Kn(e){let t=y.edges.filter(t=>t.target===e.id).length,n=t<2,r=n?`AND`:e.data.triggerMode??`AND`;return(0,s.jsx)(i.t,{hintText:n?`需要至少兩條前置連線,才可切換為任一前置完成。`:t>1?`${t} 條前置連線會依此規則觸發。`:`只有一條前置連線時,兩種設定效果相同。`,label:`前置條件`,name:`triggerMode`,required:!0,children:(0,s.jsx)(o.Select,{clearable:!1,onChange:e=>n?void 0:Ln(nt(e?.id??null)),options:[...Ee],readOnly:n,value:I(Ee,r)})})}function qn(e){let t=e.data.approverResolver,n=it(t.type),a=t.type===`DIRECT`?jt(t.memberIds,F):null,c=t.type===`ORG_UNIT_MANAGER`||t.type===`ORG_UNIT_MEMBER`||t.type===`ORG_UNIT_POSITION`?Mt(L,t.orgUnitId):null,l=t.type===`POSITION`||t.type===`ORG_UNIT_POSITION`?Nt(R,t.positionId):null,ee=t.type===`ORG_UNIT_POSITION`?Rt({includeDescendants:!!t.includeDescendants,memberships:B,orgUnitId:t.orgUnitId,orgUnits:L,positions:R}):[],u=t.type===`ORG_MANAGER`?ct(t.levelsUp):D[0],d=t.type===`ORG_MANAGER`||t.type===`ORG_UNIT_MANAGER`?t.fallback??{type:`NONE`}:{type:`NONE`},f=d.type===`DIRECT`?V(F,d.memberId):null,te=e.data.returnBehavior.resubmitStrategy??`RESTART`;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.t,{label:`簽核來源`,name:`approverResolverType`,required:!0,children:(0,s.jsx)(o.Select,{clearable:!1,onChange:e=>$(at(e?.id??null)),options:[...Oe],value:I(Oe,n)})}),t.type===`DIRECT`?(0,s.jsx)(i.t,{label:`簽核者`,name:`memberId`,required:!0,children:(0,s.jsx)(o.AutoComplete,{asyncData:!0,disabledOptionsFilter:!0,emptyText:`沒有符合的成員`,inputProps:{autoCapitalize:`none`,autoCorrect:`off`,name:`workflow-approver-search`,spellCheck:!1},loading:N,loadingText:`搜尋成員中...`,mode:`single`,onChange:e=>$({memberIds:e?.id?[e.id]:[],type:`DIRECT`}),onSearch:Q,onVisibilityChange:e=>{e&&Q(``)},options:[...F],placeholder:`搜尋姓名或信箱`,searchDebounceTime:300,value:a})}):null,t.type===`ORG_MANAGER`?(0,s.jsx)(i.t,{hintText:`依發起人的有效會員歸屬與主管解析規則決定簽核人。`,label:`主管層級`,name:`managerLevelsUp`,required:!0,children:(0,s.jsx)(o.Select,{clearable:!1,onChange:e=>$({baseFromInitiator:!0,levelsUp:lt(e?.id??null).value,type:`ORG_MANAGER`}),options:[...D],value:u})}):null,t.type===`ORG_UNIT_MANAGER`||t.type===`ORG_UNIT_MEMBER`||t.type===`ORG_UNIT_POSITION`?(0,s.jsx)(i.t,{hintText:t.type===`ORG_UNIT_MANAGER`?`依指定組織或其上層的主管解析規則決定簽核人。`:`依指定組織目前有效會員歸屬建立候選簽核人。`,label:`組織`,name:`orgUnitId`,required:!0,children:(0,s.jsx)(r.n,{name:`orgUnitId`,onChange:e=>$(t.type===`ORG_UNIT_MEMBER`?{includeDescendants:t.includeDescendants,orgUnitId:e?.id??``,type:`ORG_UNIT_MEMBER`}:t.type===`ORG_UNIT_POSITION`?{includeDescendants:t.includeDescendants,orgUnitId:e?.id??``,positionId:``,type:`ORG_UNIT_POSITION`}:{fallback:t.fallback,orgUnitId:e?.id??``,type:`ORG_UNIT_MANAGER`}),orgUnits:L,placeholder:`選擇組織`,value:c})}):null,t.type===`ORG_MANAGER`||t.type===`ORG_UNIT_MANAGER`?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.t,{hintText:`預設會停止流程並提示;若設定固定人,找不到主管時會改派給該會員。`,label:`無主管時`,name:`approverFallbackMode`,required:!0,children:(0,s.jsx)(o.Select,{clearable:!1,onChange:e=>$(st(t,ot(e?.id??null)===`DIRECT`?{memberId:``,type:`DIRECT`}:{type:`NONE`})),options:[...ke],value:I(ke,d.type)})}),d.type===`DIRECT`?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.t,{label:`改派人員`,name:`approverFallbackMemberId`,required:!0,children:(0,s.jsx)(o.AutoComplete,{asyncData:!0,disabledOptionsFilter:!0,emptyText:`沒有符合的成員`,inputProps:{autoCapitalize:`none`,autoCorrect:`off`,name:`workflow-approver-fallback-search`,spellCheck:!1},loading:N,loadingText:`搜尋成員中...`,mode:`single`,onChange:e=>$(st(t,{allowInitiatorSelfApproval:d.allowInitiatorSelfApproval,memberId:e?.id??``,type:`DIRECT`})),onSearch:Q,onVisibilityChange:e=>{e&&Q(``)},options:[...F],placeholder:`搜尋姓名或信箱`,searchDebounceTime:300,value:f})}),(0,s.jsx)(i.t,{hintText:`預設禁止申請人簽自己的案件;只有此流程允許自簽時才開啟。`,label:`允許自簽`,name:`allowInitiatorSelfApproval`,children:(0,s.jsx)(o.Toggle,{checked:!!d.allowInitiatorSelfApproval,onChange:e=>$(st(t,{allowInitiatorSelfApproval:e.target.checked,memberId:d.memberId,type:`DIRECT`}))})})]}):null]}):null,t.type===`ORG_UNIT_MEMBER`||t.type===`ORG_UNIT_POSITION`?(0,s.jsx)(i.t,{label:`包含下層`,name:`includeDescendants`,children:(0,s.jsx)(o.Toggle,{checked:!!t.includeDescendants,onChange:e=>$({...t,includeDescendants:e.target.checked,...t.type===`ORG_UNIT_POSITION`?{positionId:``}:{}})})}):null,t.type===`POSITION`?(0,s.jsx)(i.t,{hintText:`指派給目前有效歸屬中擁有此職位的會員;主要歸屬優先。`,label:`職位`,name:`positionId`,required:!0,children:(0,s.jsx)(r.r,{name:`positionId`,onChange:e=>$({positionId:e?.id??``,type:`POSITION`}),placeholder:`選擇職位`,positions:R,value:l})}):null,t.type===`ORG_UNIT_POSITION`?(0,s.jsx)(i.t,{hintText:`只納入指定組織範圍內擁有此職位的有效會員。`,label:`職位`,name:`orgUnitPositionId`,required:!0,children:(0,s.jsx)(r.r,{disabled:!t.orgUnitId.trim(),name:`orgUnitPositionId`,onChange:e=>$({includeDescendants:t.includeDescendants,orgUnitId:t.orgUnitId,positionId:e?.id??``,type:`ORG_UNIT_POSITION`}),placeholder:t.orgUnitId.trim()?`選擇職位`:`請先選擇組織`,positions:ee,value:l})}):null,e.data.returnBehavior.allowReturn?(0,s.jsx)(i.t,{hintText:`退回發起人後,重新送出時要從流程開始重跑,或直接回到退回的簽核節點。`,label:`重送策略`,name:`returnResubmitStrategy`,required:!0,children:(0,s.jsx)(o.Select,{clearable:!1,onChange:e=>Pn(rt(e?.id??null)),options:[...De],value:I(De,te)})}):null]})}function Jn(e){let t=hn(e.data.action).map(e=>V(F,e));return(0,s.jsx)(i.t,{label:`知會對象`,name:`notifyMemberIds`,required:!0,children:(0,s.jsx)(o.AutoComplete,{asyncData:!0,disabledOptionsFilter:!0,emptyText:`沒有符合的成員`,loading:N,loadingText:`搜尋成員中...`,mode:`multiple`,onChange:e=>Fn({channels:[`IN_APP`],recipients:{memberIds:e.map(e=>e.id),type:`DIRECT`},type:`NOTIFY`}),onSearch:Q,onVisibilityChange:e=>{e&&Q(``)},options:[...F],overflowStrategy:`wrap`,placeholder:`搜尋姓名或信箱`,searchDebounceTime:300,value:[...t]})})}function Yn(e){return(0,s.jsxs)(`div`,{style:_,children:[(0,s.jsx)(o.Typography,{component:`h2`,variant:`h3`,children:`已選取線段`}),(0,s.jsxs)(o.Typography,{color:`text-neutral`,variant:`body`,children:[`已選取 `,e.length,` 條線段,可使用 Delete 或控制面板刪除。`]})]})}function Xn(e){let t=J(e,y.nodes);return(0,s.jsxs)(`div`,{style:_,children:[(0,s.jsx)(o.Typography,{component:`h2`,variant:`h3`,children:t?`條件設定`:`線段屬性`}),(0,s.jsxs)(o.Typography,{color:`text-neutral`,variant:`body`,children:[e.source,` → `,e.target]}),t?Qn(e):(0,s.jsx)(o.Typography,{color:`text-neutral`,variant:`body`,children:`這條線會直接把流程送到下一個節點。`})]})}function Zn(e){return!e||!J(e,y.nodes)?null:(0,s.jsx)(o.Modal,{cancelText:`取消`,confirmButtonProps:{disabled:!e.data.isDefault&&!e.data.condition},confirmText:`完成`,modalType:`standard`,onCancel:jn,onClose:jn,onConfirm:jn,open:!!O,showModalFooter:!0,showModalHeader:!0,size:`regular`,supportingText:`條件分流的輸出連線需要指定條件,條件會直接顯示在線上。`,title:`條件設定`,children:Qn(e)})}function Qn(e){let t=pn(e,y.nodes),n=Xt(X?.schema??null),r=Zt(X?.schema??null,e.data.conditionFieldKey??null),a=Qt(r),c=en(r),l=I(a,e.data.conditionOperator??null);return(0,s.jsxs)(`div`,{style:_,children:[(0,s.jsxs)(o.Typography,{color:`text-neutral`,variant:`body`,children:[`畫布上的這條線目前會顯示「`,(0,s.jsx)(`span`,{style:{color:!e.data.isDefault&&!e.data.condition?ce:void 0},children:t??`請設定條件`}),`」。`]}),(0,s.jsx)(o.Toggle,{checked:!!e.data.isDefault,label:`其他情況走這條`,onChange:t=>Bn(e.id,t.target.checked)}),e.data.isDefault?(0,s.jsx)(o.Typography,{color:`text-neutral`,variant:`body`,children:`其他條件都不符合時,流程會走這條線。`}):(0,s.jsxs)(s.Fragment,{children:[X?null:(0,s.jsx)(o.Typography,{color:`text-neutral`,variant:`body`,children:`請先綁定表單版本,才能選擇條件欄位。`}),(0,s.jsx)(i.t,{label:`條件欄位`,name:`edgeConditionField`,required:!0,children:(0,s.jsx)(o.Select,{clearable:!1,onChange:t=>Vn({edgeId:e.id,fieldKey:t?.id??null,operator:null,value:null}),options:[...n],placeholder:`選擇條件欄位`,value:I(n,e.data.conditionFieldKey??null)})}),(0,s.jsx)(i.t,{label:`條件判斷`,name:`edgeConditionOperator`,required:!0,children:(0,s.jsx)(o.Select,{clearable:!1,onChange:t=>Vn({edgeId:e.id,operator:$t(t?.id??null),value:null}),options:[...a],placeholder:`選擇判斷方式`,value:l})}),l&&rn(l.id)?(0,s.jsx)(i.t,{label:`條件值`,name:`edgeConditionValue`,required:!0,children:c.length>0?(0,s.jsx)(o.Select,{clearable:!1,onChange:t=>Vn({edgeId:e.id,value:t?.id??null}),options:[...c],placeholder:`選擇條件值`,value:I(c,e.data.conditionValue??null)}):(0,s.jsx)(o.Input,{onChange:t=>Vn({edgeId:e.id,value:t.target.value}),placeholder:`輸入要比對的值`,value:e.data.conditionValue??``,variant:`base`})}):null]})]})}}function Fe({onApplyAutoLayout:e}){function t(){e()}return(0,s.jsx)(u.Panel,{position:`top-right`,children:(0,s.jsx)(o.Button,{icon:l.DotGridIcon,iconType:`leading`,onClick:t,size:`sub`,variant:`base-secondary`,children:`自動排版`})})}function A({data:e,selected:t,type:n}){let r=e.approverLines??[e.approverSummary??e.label],i=Ie(e);return(0,s.jsxs)(`div`,{style:Le(n,t),children:[ze(e),(0,s.jsx)(`div`,{style:w,children:r.map((e,t)=>(0,s.jsx)(o.Typography,{component:`span`,ellipsis:!0,style:C,title:e,variant:`label-primary`,children:e},`${e}_${t}`))}),(0,s.jsx)(o.Typography,{color:`text-neutral`,component:`span`,ellipsis:!0,style:C,title:i,variant:`caption`,children:i})]})}function Ie(e){return e.nodeKind===`startEvent`?e.initiatorPolicySummary??`所有人`:e.approverSummary||e.approverLines?e.label:e.nodeKind===`exclusiveGateway`?`條件在線上`:e.nodeKind===`parallelGateway`?`多條路徑同時進行`:Ce[e.nodeKind]}function Le(e,t){let n=Re(e);return t?{...n,border:`1px solid var(--mzn-color-primary, #0057ff)`,boxShadow:y}:n}function Re(e){return e===`exclusiveGateway`?ve:e===`parallelGateway`?ye:e===`startEvent`?xe:e===`endEvent`?Se:e===`userTask`?be:v}function ze(e){return!e.hasInput&&e.hasOutput?(0,s.jsx)(u.Handle,{id:E,position:u.Position.Right,type:`source`}):e.hasInput&&!e.hasOutput?(0,s.jsx)(u.Handle,{id:T,position:u.Position.Left,type:`target`}):!e.hasInput&&!e.hasOutput?null:[(0,s.jsx)(u.Handle,{id:T,position:u.Position.Left,type:`target`},`target`),(0,s.jsx)(u.Handle,{id:E,position:u.Position.Right,type:`source`},`source`)]}function Be(e,t,n,r,i,a){let o=j(e);return{data:{approverLines:Ut(e,t),approverSummary:Vt(e,t,n,r),hasInput:R(e),hasOutput:z(e),initiatorPolicySummary:e.type===`startEvent`?ht(a,n,r):null,label:e.data.label,nodeKind:e.type},height:o.height,handles:Ve(e),id:e.id,initialHeight:o.height,initialWidth:o.width,position:e.position,selected:i,sourcePosition:u.Position.Right,targetPosition:u.Position.Left,type:e.type,width:o.width}}function j(e){return e.type===`exclusiveGateway`||e.type===`parallelGateway`?{height:x,width:_e}:e.type===`serviceTask`?{height:b+(Math.max(1,hn(e.data.action).length)-1)*ge,width:he}:{height:b,width:he}}function Ve(e){let t=j(e);return[...R(e)?[M(t)]:[],...z(e)?[He(t)]:[]]}function M({height:e}){let t=e/2-9/2;return{height:9,id:T,position:u.Position.Left,type:`target`,width:9,x:-9/2,y:t}}function He({height:e,width:t}){let n=e/2-9/2;return{height:9,id:E,position:u.Position.Right,type:`source`,width:9,x:t-9/2,y:n}}function Ue(e,t,n){let r=pn(e,t),i=J(e,t),a=i&&!e.data.isDefault&&!e.data.condition,o=a?ce:i?m:`#475569`,s=a?`#fef2f2`:i?`#eff6ff`:`#ffffff`,c=a?ce:i?m:h;return{className:n?`workflow-edge--selected`:void 0,data:e.data,id:e.id,label:r,labelBgBorderRadius:6,labelBgPadding:[8,4],labelBgStyle:{fill:s,stroke:c,strokeWidth:1},labelShowBg:!!r,labelStyle:{fill:o,fontSize:12,fontWeight:600},selected:n,source:e.source,sourceHandle:e.sourceHandle,style:{filter:n?g:void 0,opacity:1,stroke:h,strokeOpacity:1,strokeWidth:1.5},target:e.target,targetHandle:e.targetHandle,type:e.type??`smoothstep`}}function We(e,t){return e.type===`startEvent`||e.type===`endEvent`||e.type===`userTask`||e.type===`serviceTask`||e.type,{...e,data:{...e.data,label:t}}}function Ge(e,t){return e.type===`startEvent`?e:(e.type===`endEvent`||e.type===`userTask`||e.type===`serviceTask`||e.type,{...e,data:{...e.data,triggerMode:t}})}function Ke(e){return Je(qe(e))}function qe(e){let t=new Set(e.nodes.filter(e=>B(e)).map(e=>e.id)),n=e.edges.filter(e=>!t.has(e.source));return n.length===e.edges.length?e:{...e,edges:n}}function Je(e){let t=e.edges.reduce((e,t)=>({...e,[t.target]:(e[t.target]??0)+1}),{}),n=e.nodes.map(e=>e.type===`startEvent`?e:(t[e.id]??0)<2&&e.data.triggerMode!==`AND`?Ge(e,`AND`):e);return n.some((t,n)=>t!==e.nodes[n])?{...e,nodes:n}:e}function Ye(e,t){let n={id:`${e}_${t}`,position:{x:260+t*48,y:120+t*42}};return e===`userTask`?{...n,data:{allowAddSigner:!1,allowReject:!0,allowTransfer:!0,approverResolver:{memberIds:[`member-001`],type:`DIRECT`},decisionPolicy:{type:`SINGLE`},label:`簽核節點 ${t}`,returnBehavior:{allowReturn:!0,allowedTargets:`INITIATOR`,resubmitStrategy:`RESTART`},triggerMode:`AND`},type:e}:e===`serviceTask`?{...n,data:{action:{channels:[`IN_APP`],recipients:{memberIds:[`member-001`],type:`DIRECT`},type:`NOTIFY`},label:`知會節點 ${t}`,triggerMode:`AND`},type:e}:{...n,data:{direction:`split`,label:`條件分流 ${t}`,triggerMode:`AND`},type:e}}function Xe(e,t){let n=new Set(e.filter(e=>e.type===t).map(e=>Number(e.id.replace(`${t}_`,``))).filter(e=>Number.isInteger(e)&&e>0));return Array.from({length:e.length+1},(e,t)=>t+1).find(e=>!n.has(e))??e.length+1}function Ze({definition:e,node:t,selectedEdgeId:n,selectedNodeId:r}){let i=n?e.edges.find(e=>e.id===n)??null:null,a=r?e.nodes.find(e=>e.id===r)??null:null;return i?N(e,t,i):a?Qe(e,t,a):{definition:{...e,nodes:[...e.nodes,t]},editingEdgeId:null,selectedEdgeIds:[],selectedNodeId:t.id}}function N(e,t,n){if(!R(t))return{definition:e,editingEdgeId:null,selectedEdgeIds:[n.id],selectedNodeId:null};if(!z(t)){let r=P(n.source,t.id,{});return{definition:{...e,edges:[...e.edges,r],nodes:[...e.nodes,t]},editingEdgeId:null,selectedEdgeIds:[],selectedNodeId:t.id}}let r=P(n.source,t.id,n.data),i=P(t.id,n.target,F(t,n)),a=J(i,[...e.nodes,t]);return{definition:{...e,edges:e.edges.flatMap(e=>e.id===n.id?[r,i]:[e]),nodes:[...e.nodes,t]},editingEdgeId:a?i.id:null,selectedEdgeIds:a?[i.id]:[],selectedNodeId:a?null:t.id}}function Qe(e,t,n){if(!z(n))return{definition:{...e,nodes:[...e.nodes,t]},editingEdgeId:null,selectedEdgeIds:[],selectedNodeId:t.id};let r=e.edges.find(e=>e.source===n.id)??null;if(r&&z(t))return N(e,t,r);let i=e.nodes.find(e=>e.type===`endEvent`);if(i&&n.id!==i.id&&z(t)){let r=P(n.id,t.id,{}),a=P(t.id,i.id,F(t,r)),o=J(a,[...e.nodes,t]);return{definition:{...e,edges:[...e.edges,r,a],nodes:[...e.nodes,t]},editingEdgeId:o?a.id:null,selectedEdgeIds:o?[a.id]:[],selectedNodeId:o?null:t.id}}let a=P(n.id,t.id,{});return{definition:{...e,edges:[...e.edges,a],nodes:[...e.nodes,t]},editingEdgeId:null,selectedEdgeIds:[],selectedNodeId:t.id}}function P(e,t,n){return{data:n,id:`edge_${e}_${t}_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,source:e,sourceHandle:E,target:t,targetHandle:T,type:`smoothstep`}}function F(e,t){return e.type===`exclusiveGateway`?{isDefault:!0,label:`其他情況`}:{}}function $e(){return{edges:[],meta:{schemaVersion:1},nodes:[{data:{label:`開始`},id:`start`,position:{x:80,y:160},type:`startEvent`},{data:{endState:`APPROVED`,label:`完成`,triggerMode:`AND`},id:`end`,position:{x:560,y:160},type:`endEvent`}]}}function et(e){return e.edges.length===0&&e.nodes.length===2&&e.nodes.some(e=>e.type===`startEvent`)&&e.nodes.some(e=>e.type===`endEvent`)}function tt(e){let t=new d.graphlib.Graph;return t.setDefaultEdgeLabel(()=>({})),t.setGraph({rankdir:`LR`,ranksep:120}),e.nodes.forEach(e=>{t.setNode(e.id,j(e))}),e.edges.forEach(e=>{t.setEdge(e.source,e.target)}),d.layout(t),{...e,nodes:e.nodes.map(e=>{let n=t.node(e.id);return n?{...e,position:{x:n.x-j(e).width/2,y:n.y-j(e).height/2}}:e})}}function I(e,t){return t?e.find(e=>e.id===t)??null:null}function nt(e){return e===`OR`?`OR`:`AND`}function rt(e){return e===`FROM_RETURN_POINT`?`FROM_RETURN_POINT`:`RESTART`}function it(e){return e===`ORG_MANAGER`||e===`ORG_UNIT_MANAGER`||e===`ORG_UNIT_MEMBER`||e===`ORG_UNIT_POSITION`||e===`POSITION`?e:`DIRECT`}function at(e){let t=it(e??`DIRECT`);return t===`ORG_MANAGER`?{baseFromInitiator:!0,levelsUp:1,type:`ORG_MANAGER`}:t===`ORG_UNIT_MANAGER`?{orgUnitId:``,type:`ORG_UNIT_MANAGER`}:t===`ORG_UNIT_MEMBER`?{includeDescendants:!1,orgUnitId:``,type:`ORG_UNIT_MEMBER`}:t===`ORG_UNIT_POSITION`?{includeDescendants:!1,orgUnitId:``,positionId:``,type:`ORG_UNIT_POSITION`}:t===`POSITION`?{positionId:``,type:`POSITION`}:{memberIds:[],type:`DIRECT`}}function ot(e){return e===`DIRECT`?`DIRECT`:`NONE`}function st(e,t){return e.type===`ORG_MANAGER`||e.type===`ORG_UNIT_MANAGER`?{...e,fallback:t}:e}function ct(e){return D.find(t=>t.value===e)??D[0]}function lt(e){return D.find(t=>t.id===e)??D[0]}function ut(e){return e===`ORG_UNIT`||e===`ORG_UNIT_POSITION`||e===`NONE`?e:`ALL`}function dt(e){let t=e?.trim();if(!t)return{mode:`ALL`,value:``};let n=L(t,/"([^"]+)" in subject\.orgUnitIds/gu),r=L(t,/"([^"]+)" in subject\.positionIds/gu);return n.length>0&&r.length>0?{includeDescendants:n.length>1,mode:`ORG_UNIT_POSITION`,orgUnitId:n[0],positionId:r[0],value:n[0]??``}:n.length>0?{includeDescendants:n.length>1,mode:`ORG_UNIT`,orgUnitId:n[0],value:n[0]??``}:{mode:`CUSTOM`,value:t}}function ft(e,t){let n=dt(e);return!t||t===`ALL`||t===`NONE`?t===`ALL`||t===`NONE`?{mode:t,value:``}:n:n.mode===t?n:gt(t)}function pt(e){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}function L(e,t){return[...e.matchAll(t)].map(e=>e[1]).filter(e=>!!e)}function mt(e,t){if(e.mode===`ALL`||e.mode===`NONE`)return null;let n=e.orgUnitId?.trim()??``;if(!n)return null;let r=G(t,n,!!e.includeDescendants).map(e=>`${JSON.stringify(e)} in subject.orgUnitIds`).join(` || `);if(e.mode===`ORG_UNIT`)return r?`(${r})`:null;let i=e.positionId?.trim()??``;return i&&r?`(${r}) && ${JSON.stringify(i)} in subject.positionIds`:null}function ht(e,t,n){return e.mode===`NONE`?`未設定`:e.mode===`ORG_UNIT`?e.orgUnitId?`組織:${H(t,e.orgUnitId)}`:`指定組織`:e.mode===`ORG_UNIT_POSITION`?e.orgUnitId&&e.positionId?`組織職位:${H(t,e.orgUnitId)} / ${U(n,e.positionId)}`:`指定組織職位`:e.mode===`CUSTOM`?`既有自訂規則`:`所有人`}function gt(e){return{includeDescendants:!0,mode:e,orgUnitId:``,positionId:``,value:``}}function _t(e,t){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;return!!n&&!!r&&e.source!==e.target&&e.sourceHandle===E&&e.targetHandle===T&&!!(n&&z(n))&&!!(r&&R(r))}function vt(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function yt(e){return e.type!==`startEvent`&&e.type!==`endEvent`}function R(e){return e.type!==`startEvent`}function z(e){return e.type!==`endEvent`&&!B(e)}function B(e){return e.type===`serviceTask`&&e.data.action.type===`NOTIFY`}function bt(e){return e instanceof HTMLElement?e.isContentEditable||e.tagName===`INPUT`||e.tagName===`TEXTAREA`||e.tagName===`SELECT`||!!e.closest(`[contenteditable="true"]`):!1}function xt(e){return e.map(e=>({id:e.id,name:`${e.formName} | v${e.version}`,schema:e.schema}))}function St(e){return(e?.schema.fields??[]).reduce((e,t)=>({...e,[t.fieldKey]:Ct(t)}),{})}function Ct(e){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}function wt(e){let t=JSON.parse(e);if(!Tt(t))throw Error(`表單資料 JSON 必須是物件。`);return t}function Tt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Et(e){return e===`COMPLETED`?`完成`:e===`PASSED`?`通過`:e===`SKIPPED`?`略過`:e===`STOPPED`?`已停止`:e===`WAITING`?`將等待簽核`:e}function Dt(e){return e in Ce?Ce[e]:e}function Ot(e,t){return t&&!e.some(e=>e.id===t.id)?[t,...e]:e}function kt(e){return e.map(e=>({displayName:e.name,email:e.email,id:e.memberId,memberId:e.memberId,name:Gt(e.name,e.email)}))}function At(e){return{displayName:`未知會員`,email:``,id:e,memberId:e,name:`未知會員`}}function V(e,t){return e.find(e=>e.memberId===t)??At(t)}function jt(e,t){let n=e[0];return n?V(t,n):null}function Mt(e,t){let n=e.find(e=>e.id===t);return n?r.a(n):null}function Nt(e,t){let n=e.find(e=>e.id===t);return n?r.o(n):null}function H(e,t){return Mt(e,t)?.name??`未指定組織`}function U(e,t){return Nt(e,t)?.name??`未指定職位`}function Pt(e,t){let n=Ft(),r=t.filter(t=>t.memberId===e&&It(t,n)),i=r.reduce((e,t)=>e&&Lt(e,t)<=0?e:t,null);return{customFields:{},managerMemberId:`member-002`,memberId:e,orgCode:`HQ`,orgUnitIds:W(r.map(e=>e.orgUnitId)),positionId:i?.positionId??null,positionIds:W(r.map(e=>e.positionId)),primaryOrgUnitId:i?.orgUnitId??null,roles:[`manager`]}}function Ft(){return new Date().toISOString().slice(0,10)}function It(e,t){return e.effectiveFrom<=t&&(!e.effectiveTo||e.effectiveTo>=t)}function Lt(e,t){return e.isPrimary===t.isPrimary?t.effectiveFrom.localeCompare(e.effectiveFrom):e.isPrimary?-1:1}function W(e){return e.reduce((e,t)=>t&&!e.includes(t)?[...e,t]:e,[])}function Rt({includeDescendants:e,memberships:t,orgUnitId:n,orgUnits:r,positions:i}){let a=new Set(G(r,n,e)),o=new Set(t.filter(e=>a.has(e.orgUnitId)).map(e=>e.positionId).filter(e=>!!e));return i.filter(e=>o.has(e.id))}function G(e,t,n){let r=e.find(e=>e.id===t);return r?n?e.filter(e=>e.id===r.id||e.path.startsWith(`${r.path}.`)).map(e=>e.id):[r.id]:t.trim()?[t]:[]}function zt(e,t){let n=new Set(e.map(e=>e.memberId)),r=t.filter(e=>!n.has(e.memberId));return[...e,...r]}function Bt(e){return[...new Set(e.nodes.flatMap(e=>e.type===`userTask`?e.data.approverResolver.type===`DIRECT`?e.data.approverResolver.memberIds:[]:e.type===`serviceTask`?hn(e.data.action):[]))]}function Vt(e,t,n,r){return e.type===`userTask`?Ht(e.data.approverResolver,t,n,r):null}function Ht(e,t,n,r){return e.type===`DIRECT`?Wt(e.memberIds,t,`未指定簽核者`):e.type===`ORG_MANAGER`?ct(e.levelsUp).name:e.type===`ORG_UNIT_MANAGER`?`組織主管:${H(n,e.orgUnitId)}`:e.type===`ORG_UNIT_MEMBER`?`組織任一人:${H(n,e.orgUnitId)}`:e.type===`ORG_UNIT_POSITION`?`組織職位:${H(n,e.orgUnitId)} / ${U(r,e.positionId)}`:e.type===`POSITION`?`職位:${U(r,e.positionId)}`:e.type===`DYNAMIC_FORM`?`表單欄位:${e.formPath||`未設定`}`:`自訂表達式`}function Ut(e,t){if(e.type!==`serviceTask`)return null;let n=hn(e.data.action);return n.length===0?[`未指定知會對象`]:n.map(e=>V(t,e).name)}function Wt(e,t,n){let r=e.map(e=>V(t,e).name);return r.length===0?n:r.length<=2?r.join(`、`):`${r.slice(0,2).join(`、`)} 等 ${r.length} 人`}function Gt(e,t){return`${e} (${t})`}function Kt(e,t){let n=t?.getBoundingClientRect();if(!n||e.nodes.length===0)return null;let r=e.nodes.reduce((e,t)=>{let n=j(t);return{maxX:Math.max(e.maxX,t.position.x+n.width),maxY:Math.max(e.maxY,t.position.y+n.height),minX:Math.min(e.minX,t.position.x),minY:Math.min(e.minY,t.position.y)}},{maxX:-1/0,maxY:-1/0,minX:1/0,minY:1/0});return(0,u.getViewportForBounds)({height:r.maxY-r.minY,width:r.maxX-r.minX,x:r.minX,y:r.minY},n.width,n.height,.1,1,.2)}function qt(e){let t=e.nodes.find(e=>e.type===`userTask`&&!!Jt(e.data.approverResolver)),n=e.nodes.find(e=>e.type===`serviceTask`&&e.data.action.type===`NOTIFY`&&hn(e.data.action).length===0),r=e.edges.find(t=>J(t,e.nodes)&&!t.data.isDefault&&!t.data.condition);return t&&t.type===`userTask`?Jt(t.data.approverResolver):n?`知會節點需要至少一位知會對象。`:r?`條件分流的每條輸出連線都需要先設定條件。`:null}function Jt(e){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}function Yt(e){return e.edges.some(t=>J(t,e.nodes)&&!!(t.data.condition||t.data.conditionFieldKey||t.data.conditionOperator||t.data.conditionValue))}function Xt(e){return e?.fields.map(e=>({fieldType:e.type,id:e.fieldKey,name:`${e.label} (${e.fieldKey})`}))??[]}function Zt(e,t){return t?e?.fields.find(e=>e.fieldKey===t)??null:null}function Qt(e){if(!e)return[];let t=K(e);return O.filter(e=>t.includes(e.id))}function $t(e){return O.some(t=>t.id===e)?e:null}function K(e){return e.type===`file_upload`?[`IS_FILLED`,`IS_EMPTY`]:e.type===`boolean`?[`EQUALS`,`NOT_EQUALS`,`IS_FILLED`,`IS_EMPTY`]:e.type===`date`||e.type===`datetime`||e.type===`money`||e.type===`number`?[`EQUALS`,`NOT_EQUALS`,`GREATER_THAN`,`GREATER_THAN_OR_EQUALS`,`LESS_THAN`,`LESS_THAN_OR_EQUALS`,`IS_FILLED`,`IS_EMPTY`]:[`EQUALS`,`NOT_EQUALS`,`IS_FILLED`,`IS_EMPTY`]}function en(e){return e?e.type===`boolean`?[{id:`true`,name:`是`},{id:`false`,name:`否`}]:e.type===`checkbox`||e.type===`radio`||e.type===`select`?e.options.map(e=>({id:e.value,name:e.label})):[]:[]}function tn(e,t){if(!e)return;let n=K(e);return t&&n.includes(t)?t:n[0]}function nn(e,t,n){if(!e||!t||!rn(t))return;let r=en(e);return r.length===0||r.some(e=>e.id===n)?n??void 0:r[0]?.id}function rn(e){return k.includes(e)}function an(e,t,n){if(!e||!t)return;let r=on(t);if(!rn(t))return`${e.label} ${r}`;if(n)return`${e.label} ${r} ${sn(e,n)}`}function on(e){return O.find(t=>t.id===e)?.name??e}function sn(e,t){return e.type===`boolean`?t===`true`?`是`:`否`:e.type===`checkbox`||e.type===`radio`||e.type===`select`?cn(e.options,t)?.label??t:t}function cn(e,t){return e.find(e=>e.value===t)??null}function ln(e,t,n){if(!e||!t)return;let r=un(e.fieldKey);if(t===`IS_FILLED`)return`${r} != null && ${r} != ""`;if(t===`IS_EMPTY`)return`${r} == null || ${r} == ""`;if(n)return`${r} ${dn(t)} ${fn(e,n)}`}function un(e){return/^[A-Za-z_][A-Za-z0-9_]*$/u.test(e)?`form.${e}`:`form[${JSON.stringify(e)}]`}function dn(e){return e===`EQUALS`?`==`:e===`NOT_EQUALS`?`!=`:e===`GREATER_THAN`?`>`:e===`GREATER_THAN_OR_EQUALS`?`>=`:e===`LESS_THAN`?`<`:`<=`}function fn(e,t){return e.type===`boolean`?t===`true`?`true`:`false`:(e.type===`money`||e.type===`number`)&&Number.isFinite(Number(t))?t:JSON.stringify(t)}function pn(e,t){if(e.data.label)return e.data.label;if(J(e,t))return q(e);if(mn(e,t))return`同時進行`}function q(e){return e.data.isDefault?`其他情況`:`請設定條件`}function J(e,t){return t.some(t=>t.id===e.source&&t.type===`exclusiveGateway`)}function mn(e,t){return t.some(t=>t.id===e.source&&t.type===`parallelGateway`)}function hn(e){return e.type===`NOTIFY`&&e.recipients.type===`DIRECT`?e.recipients.memberIds:[]}function Y(e){return e instanceof Error?e.message:`發生未知錯誤`}exports.TemplateDesignerView=Pe;
51
- //# sourceMappingURL=index.cjs.map
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../chunks/designer-DCn6_v4b.cjs");exports.TemplateDesignerView=e.t;