@echothink-ui/workflow 0.1.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.
- package/README.md +5 -0
- package/dist/components/ApprovalWorkflowEditor.d.ts +2 -0
- package/dist/components/ConditionBuilder.d.ts +2 -0
- package/dist/components/PipelineStage.d.ts +2 -0
- package/dist/components/ProcessDesigner.d.ts +2 -0
- package/dist/components/ProcessTimeline.d.ts +2 -0
- package/dist/components/RuleBuilder.d.ts +2 -0
- package/dist/components/RuleSimulationPanel.d.ts +2 -0
- package/dist/components/WorkflowHandoffPanel.d.ts +2 -0
- package/dist/components/WorkflowPipelineView.d.ts +2 -0
- package/dist/components/types.d.ts +112 -0
- package/dist/index.cjs +499 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +268 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +453 -0
- package/dist/index.js.map +1 -0
- package/package.json +43 -0
- package/src/components/ApprovalWorkflowEditor.tsx +34 -0
- package/src/components/ConditionBuilder.tsx +41 -0
- package/src/components/PipelineStage.tsx +33 -0
- package/src/components/ProcessDesigner.tsx +125 -0
- package/src/components/ProcessTimeline.tsx +23 -0
- package/src/components/RuleBuilder.tsx +66 -0
- package/src/components/RuleSimulationPanel.tsx +47 -0
- package/src/components/WorkflowHandoffPanel.tsx +41 -0
- package/src/components/WorkflowPipelineView.tsx +34 -0
- package/src/components/types.ts +107 -0
- package/src/css.d.ts +1 -0
- package/src/index.tsx +42 -0
- package/src/styles.css +312 -0
package/README.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# @echothink-ui/workflow
|
|
2
|
+
|
|
3
|
+
Workflow package for EchoThink app-domain websites.
|
|
4
|
+
|
|
5
|
+
This package is part of the EchoThink-UI app-domain library. It is designed for normal website app domains rendered inside EchoThink Studio's Chromium shell, not for implementing the studio browser chrome itself.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import type { EthOperationalStatus } from "@echothink-ui/core";
|
|
3
|
+
export interface WorkflowStage extends Record<string, unknown> {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
status: EthOperationalStatus;
|
|
7
|
+
startedAt?: string;
|
|
8
|
+
durationMs?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface WorkflowPipelineViewProps extends Omit<React.HTMLAttributes<HTMLElement>, "onSelect"> {
|
|
11
|
+
stages: WorkflowStage[];
|
|
12
|
+
activeStageId?: string;
|
|
13
|
+
onSelect?: (id: string) => void;
|
|
14
|
+
}
|
|
15
|
+
export interface PipelineStageProps extends Omit<React.HTMLAttributes<HTMLElement>, "onSelect"> {
|
|
16
|
+
stage: WorkflowStage;
|
|
17
|
+
active?: boolean;
|
|
18
|
+
onSelect?: (id: string) => void;
|
|
19
|
+
}
|
|
20
|
+
export interface ProcessNode extends Record<string, unknown> {
|
|
21
|
+
id: string;
|
|
22
|
+
label: string;
|
|
23
|
+
type: "task" | "decision" | "start" | "end";
|
|
24
|
+
x?: number;
|
|
25
|
+
y?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface ProcessEdge extends Record<string, unknown> {
|
|
28
|
+
from: string;
|
|
29
|
+
to: string;
|
|
30
|
+
label?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ProcessDesignerProps extends Omit<React.HTMLAttributes<HTMLElement>, "onSelect"> {
|
|
33
|
+
nodes: ProcessNode[];
|
|
34
|
+
edges: ProcessEdge[];
|
|
35
|
+
onNodeMove?: (id: string, x: number, y: number) => void;
|
|
36
|
+
onAddNode?: () => void;
|
|
37
|
+
onConnect?: (from: string, to: string) => void;
|
|
38
|
+
}
|
|
39
|
+
export interface WorkflowRuleCondition extends Record<string, unknown> {
|
|
40
|
+
field: string;
|
|
41
|
+
operator: "equals" | "not-equals" | "contains" | "gt" | "gte" | "lt" | "lte" | "exists";
|
|
42
|
+
value?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface WorkflowRule extends Record<string, unknown> {
|
|
45
|
+
combinator: "all" | "any";
|
|
46
|
+
conditions: WorkflowRuleCondition[];
|
|
47
|
+
}
|
|
48
|
+
export interface RuleBuilderProps extends Omit<React.HTMLAttributes<HTMLElement>, "onChange"> {
|
|
49
|
+
value?: WorkflowRule;
|
|
50
|
+
onChange?: (rule: WorkflowRule) => void;
|
|
51
|
+
variables?: string[];
|
|
52
|
+
}
|
|
53
|
+
export interface ConditionBuilderProps extends Omit<React.HTMLAttributes<HTMLElement>, "onChange"> {
|
|
54
|
+
value: WorkflowRuleCondition;
|
|
55
|
+
onChange: (condition: WorkflowRuleCondition) => void;
|
|
56
|
+
variables?: string[];
|
|
57
|
+
}
|
|
58
|
+
export interface RuleSimulationSample extends Record<string, unknown> {
|
|
59
|
+
id: string;
|
|
60
|
+
label: string;
|
|
61
|
+
data: unknown;
|
|
62
|
+
expectedOutcome?: unknown;
|
|
63
|
+
}
|
|
64
|
+
export interface RuleSimulationResult extends Record<string, unknown> {
|
|
65
|
+
sampleId: string;
|
|
66
|
+
actualOutcome: unknown;
|
|
67
|
+
matched: boolean;
|
|
68
|
+
}
|
|
69
|
+
export interface RuleSimulationPanelProps extends Omit<React.HTMLAttributes<HTMLElement>, "results"> {
|
|
70
|
+
rule: unknown;
|
|
71
|
+
sampleInputs: RuleSimulationSample[];
|
|
72
|
+
results?: RuleSimulationResult[];
|
|
73
|
+
onRun?: () => void;
|
|
74
|
+
}
|
|
75
|
+
export interface WorkflowHandoffPanelProps extends Omit<React.HTMLAttributes<HTMLElement>, "onSubmit"> {
|
|
76
|
+
item?: {
|
|
77
|
+
id: string;
|
|
78
|
+
label: React.ReactNode;
|
|
79
|
+
status?: EthOperationalStatus;
|
|
80
|
+
};
|
|
81
|
+
assigneeOptions?: Array<{
|
|
82
|
+
id: string;
|
|
83
|
+
label: string;
|
|
84
|
+
kind?: "user" | "team" | "agent";
|
|
85
|
+
}>;
|
|
86
|
+
onSubmit?: (handoff: {
|
|
87
|
+
assigneeId: string;
|
|
88
|
+
reason: string;
|
|
89
|
+
}) => void;
|
|
90
|
+
}
|
|
91
|
+
export interface ApprovalWorkflowEditorProps extends Omit<React.HTMLAttributes<HTMLElement>, "onChange"> {
|
|
92
|
+
steps?: Array<{
|
|
93
|
+
id: string;
|
|
94
|
+
label: string;
|
|
95
|
+
approver?: string;
|
|
96
|
+
required?: boolean;
|
|
97
|
+
}>;
|
|
98
|
+
onChange?: (steps: Array<{
|
|
99
|
+
id: string;
|
|
100
|
+
label: string;
|
|
101
|
+
approver?: string;
|
|
102
|
+
required?: boolean;
|
|
103
|
+
}>) => void;
|
|
104
|
+
}
|
|
105
|
+
export interface ProcessTimelineProps extends React.HTMLAttributes<HTMLElement> {
|
|
106
|
+
events?: Array<{
|
|
107
|
+
id: string;
|
|
108
|
+
label: React.ReactNode;
|
|
109
|
+
timestamp?: string;
|
|
110
|
+
status?: EthOperationalStatus;
|
|
111
|
+
}>;
|
|
112
|
+
}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.tsx
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
ApprovalWorkflowEditor: () => ApprovalWorkflowEditor,
|
|
34
|
+
ConditionBuilder: () => ConditionBuilder,
|
|
35
|
+
PipelineStage: () => PipelineStage,
|
|
36
|
+
ProcessDesigner: () => ProcessDesigner,
|
|
37
|
+
ProcessTimeline: () => ProcessTimeline,
|
|
38
|
+
RuleBuilder: () => RuleBuilder,
|
|
39
|
+
RuleSimulationPanel: () => RuleSimulationPanel,
|
|
40
|
+
WorkflowComponentNames: () => WorkflowComponentNames,
|
|
41
|
+
WorkflowHandoffPanel: () => WorkflowHandoffPanel,
|
|
42
|
+
WorkflowPipelineView: () => WorkflowPipelineView
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(index_exports);
|
|
45
|
+
|
|
46
|
+
// src/components/ApprovalWorkflowEditor.tsx
|
|
47
|
+
var import_core = require("@echothink-ui/core");
|
|
48
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
49
|
+
function ApprovalWorkflowEditor({ steps = [], onChange, className, ...props }) {
|
|
50
|
+
const update = (index, next) => {
|
|
51
|
+
const nextSteps = [...steps];
|
|
52
|
+
nextSteps[index] = next;
|
|
53
|
+
onChange?.(nextSteps);
|
|
54
|
+
};
|
|
55
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
56
|
+
"section",
|
|
57
|
+
{
|
|
58
|
+
...props,
|
|
59
|
+
className: `eth-workflow-approval-editor ${className ?? ""}`,
|
|
60
|
+
"data-eth-component": "ApprovalWorkflowEditor",
|
|
61
|
+
children: [
|
|
62
|
+
steps.map((step, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "eth-workflow-approval-editor__step", children: [
|
|
63
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.TextInput, { value: step.label, onChange: (event) => update(index, { ...step, label: event.currentTarget.value }), "aria-label": "Step label" }),
|
|
64
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.TextInput, { value: step.approver ?? "", onChange: (event) => update(index, { ...step, approver: event.currentTarget.value }), "aria-label": "Approver" }),
|
|
65
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Checkbox, { checked: Boolean(step.required), label: "Required", onChange: (event) => update(index, { ...step, required: event.currentTarget.checked }) })
|
|
66
|
+
] }, step.id)),
|
|
67
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
68
|
+
import_core.Button,
|
|
69
|
+
{
|
|
70
|
+
intent: "secondary",
|
|
71
|
+
density: "compact",
|
|
72
|
+
onClick: () => onChange?.([...steps, { id: `step-${steps.length + 1}`, label: "Approval step", required: true }]),
|
|
73
|
+
children: "Add approval"
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// src/components/ConditionBuilder.tsx
|
|
82
|
+
var import_core2 = require("@echothink-ui/core");
|
|
83
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
84
|
+
var operators = [
|
|
85
|
+
{ value: "equals", label: "Equals" },
|
|
86
|
+
{ value: "not-equals", label: "Does not equal" },
|
|
87
|
+
{ value: "contains", label: "Contains" },
|
|
88
|
+
{ value: "gt", label: "Greater than" },
|
|
89
|
+
{ value: "gte", label: "Greater than or equal" },
|
|
90
|
+
{ value: "lt", label: "Less than" },
|
|
91
|
+
{ value: "lte", label: "Less than or equal" },
|
|
92
|
+
{ value: "exists", label: "Exists" }
|
|
93
|
+
];
|
|
94
|
+
function ConditionBuilder({ value, onChange, variables = [], className, ...props }) {
|
|
95
|
+
const fieldOptions = variables.length ? variables.map((field) => ({ value: field, label: field })) : [{ value: value.field, label: value.field || "field" }];
|
|
96
|
+
const update = (key, nextValue) => {
|
|
97
|
+
onChange({ ...value, [key]: nextValue });
|
|
98
|
+
};
|
|
99
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
100
|
+
"section",
|
|
101
|
+
{
|
|
102
|
+
...props,
|
|
103
|
+
className: `eth-workflow-condition-builder ${className ?? ""}`,
|
|
104
|
+
"data-eth-component": "ConditionBuilder",
|
|
105
|
+
children: [
|
|
106
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.FormField, { label: "Field", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.Select, { value: value.field, options: fieldOptions, onChange: (event) => update("field", event.currentTarget.value) }) }),
|
|
107
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.FormField, { label: "Operator", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.Select, { value: value.operator, options: operators, onChange: (event) => update("operator", event.currentTarget.value) }) }),
|
|
108
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.FormField, { label: "Value", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.TextInput, { value: value.value ?? "", onChange: (event) => update("value", event.currentTarget.value), disabled: value.operator === "exists" }) })
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// src/components/PipelineStage.tsx
|
|
115
|
+
var import_core3 = require("@echothink-ui/core");
|
|
116
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
117
|
+
function PipelineStage({ stage, active, onSelect, className, ...props }) {
|
|
118
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
119
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.StatusDot, { status: stage.status, label: stage.status }),
|
|
120
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: stage.label }),
|
|
121
|
+
stage.durationMs !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("small", { children: [
|
|
122
|
+
stage.durationMs,
|
|
123
|
+
"ms"
|
|
124
|
+
] }) : null
|
|
125
|
+
] });
|
|
126
|
+
return onSelect ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
127
|
+
"button",
|
|
128
|
+
{
|
|
129
|
+
...props,
|
|
130
|
+
type: "button",
|
|
131
|
+
className: `eth-workflow-pipeline-stage ${active ? "eth-workflow-pipeline-stage--active" : ""} ${className ?? ""}`,
|
|
132
|
+
"data-eth-component": "PipelineStage",
|
|
133
|
+
onClick: () => onSelect(stage.id),
|
|
134
|
+
children: content
|
|
135
|
+
}
|
|
136
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
137
|
+
"article",
|
|
138
|
+
{
|
|
139
|
+
...props,
|
|
140
|
+
className: `eth-workflow-pipeline-stage ${active ? "eth-workflow-pipeline-stage--active" : ""} ${className ?? ""}`,
|
|
141
|
+
"data-eth-component": "PipelineStage",
|
|
142
|
+
children: content
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// src/components/ProcessDesigner.tsx
|
|
148
|
+
var React = __toESM(require("react"), 1);
|
|
149
|
+
var import_core4 = require("@echothink-ui/core");
|
|
150
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
151
|
+
function ProcessDesigner({
|
|
152
|
+
nodes,
|
|
153
|
+
edges,
|
|
154
|
+
onNodeMove,
|
|
155
|
+
onAddNode,
|
|
156
|
+
onConnect,
|
|
157
|
+
className,
|
|
158
|
+
...props
|
|
159
|
+
}) {
|
|
160
|
+
const svgRef = React.useRef(null);
|
|
161
|
+
const [positions, setPositions] = React.useState(() => initialPositions(nodes));
|
|
162
|
+
const [draggingId, setDraggingId] = React.useState(null);
|
|
163
|
+
const [selectedNodeId, setSelectedNodeId] = React.useState(null);
|
|
164
|
+
React.useEffect(() => {
|
|
165
|
+
setPositions(initialPositions(nodes));
|
|
166
|
+
}, [nodes]);
|
|
167
|
+
const pointFromEvent = (event) => {
|
|
168
|
+
const rect = svgRef.current?.getBoundingClientRect();
|
|
169
|
+
if (!rect) return { x: 0, y: 0 };
|
|
170
|
+
return {
|
|
171
|
+
x: (event.clientX - rect.left) / rect.width * 900,
|
|
172
|
+
y: (event.clientY - rect.top) / rect.height * 420
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
const move = (event) => {
|
|
176
|
+
if (!draggingId) return;
|
|
177
|
+
const point = pointFromEvent(event);
|
|
178
|
+
setPositions((current) => ({ ...current, [draggingId]: point }));
|
|
179
|
+
};
|
|
180
|
+
const stop = () => {
|
|
181
|
+
if (!draggingId) return;
|
|
182
|
+
const point = positions[draggingId];
|
|
183
|
+
if (point) onNodeMove?.(draggingId, point.x, point.y);
|
|
184
|
+
setDraggingId(null);
|
|
185
|
+
};
|
|
186
|
+
const clickNode = (id) => {
|
|
187
|
+
if (selectedNodeId && selectedNodeId !== id) {
|
|
188
|
+
onConnect?.(selectedNodeId, id);
|
|
189
|
+
setSelectedNodeId(null);
|
|
190
|
+
} else {
|
|
191
|
+
setSelectedNodeId(id);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
195
|
+
"section",
|
|
196
|
+
{
|
|
197
|
+
...props,
|
|
198
|
+
className: `eth-workflow-process-designer ${className ?? ""}`,
|
|
199
|
+
"data-eth-component": "ProcessDesigner",
|
|
200
|
+
children: [
|
|
201
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("header", { children: [
|
|
202
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h3", { children: "Process designer" }),
|
|
203
|
+
onAddNode ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core4.Button, { intent: "secondary", density: "compact", onClick: onAddNode, children: "Add node" }) : null
|
|
204
|
+
] }),
|
|
205
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
206
|
+
"svg",
|
|
207
|
+
{
|
|
208
|
+
ref: svgRef,
|
|
209
|
+
viewBox: "0 0 900 420",
|
|
210
|
+
role: "img",
|
|
211
|
+
"aria-label": "Process graph",
|
|
212
|
+
onMouseMove: move,
|
|
213
|
+
onMouseUp: stop,
|
|
214
|
+
onMouseLeave: stop,
|
|
215
|
+
children: [
|
|
216
|
+
edges.map((edge, index) => {
|
|
217
|
+
const from = positions[edge.from];
|
|
218
|
+
const to = positions[edge.to];
|
|
219
|
+
if (!from || !to) return null;
|
|
220
|
+
const midX = (from.x + to.x) / 2;
|
|
221
|
+
const midY = (from.y + to.y) / 2;
|
|
222
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("g", { children: [
|
|
223
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("line", { x1: from.x, y1: from.y, x2: to.x, y2: to.y, stroke: "var(--eth-color-border-strong)", strokeWidth: 2, markerEnd: "url(#eth-workflow-arrow)" }),
|
|
224
|
+
edge.label ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("text", { x: midX, y: midY - 6, textAnchor: "middle", fontSize: 12, children: edge.label }) : null
|
|
225
|
+
] }, `${edge.from}-${edge.to}-${index}`);
|
|
226
|
+
}),
|
|
227
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("marker", { id: "eth-workflow-arrow", viewBox: "0 0 10 10", refX: "8", refY: "5", markerWidth: "6", markerHeight: "6", orient: "auto-start-reverse", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M 0 0 L 10 5 L 0 10 z", fill: "var(--eth-color-border-strong)" }) }) }),
|
|
228
|
+
nodes.map((node) => {
|
|
229
|
+
const point = positions[node.id];
|
|
230
|
+
if (!point) return null;
|
|
231
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
232
|
+
"g",
|
|
233
|
+
{
|
|
234
|
+
transform: `translate(${point.x}, ${point.y})`,
|
|
235
|
+
className: `eth-workflow-process-designer__node eth-workflow-process-designer__node--${node.type} ${selectedNodeId === node.id ? "eth-workflow-process-designer__node--selected" : ""}`,
|
|
236
|
+
onMouseDown: (event) => {
|
|
237
|
+
event.preventDefault();
|
|
238
|
+
setDraggingId(node.id);
|
|
239
|
+
},
|
|
240
|
+
onClick: () => clickNode(node.id),
|
|
241
|
+
children: [
|
|
242
|
+
node.type === "decision" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("polygon", { points: "0,-32 54,0 0,32 -54,0", fill: "var(--eth-color-layer-01)", stroke: "var(--eth-color-border-strong)", strokeWidth: 2 }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("rect", { x: -62, y: -28, width: 124, height: 56, rx: 0, fill: "var(--eth-color-layer-01)", stroke: "var(--eth-color-border-strong)", strokeWidth: 2 }),
|
|
243
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("text", { textAnchor: "middle", dominantBaseline: "middle", fontSize: 13, children: node.label })
|
|
244
|
+
]
|
|
245
|
+
},
|
|
246
|
+
node.id
|
|
247
|
+
);
|
|
248
|
+
})
|
|
249
|
+
]
|
|
250
|
+
}
|
|
251
|
+
)
|
|
252
|
+
]
|
|
253
|
+
}
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
function initialPositions(nodes) {
|
|
257
|
+
const positions = {};
|
|
258
|
+
nodes.forEach((node, index) => {
|
|
259
|
+
positions[node.id] = {
|
|
260
|
+
x: node.x ?? 100 + index % 5 * 170,
|
|
261
|
+
y: node.y ?? 90 + Math.floor(index / 5) * 120
|
|
262
|
+
};
|
|
263
|
+
});
|
|
264
|
+
return positions;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// src/components/ProcessTimeline.tsx
|
|
268
|
+
var import_core5 = require("@echothink-ui/core");
|
|
269
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
270
|
+
function ProcessTimeline({ events = [], className, ...props }) {
|
|
271
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
272
|
+
"section",
|
|
273
|
+
{
|
|
274
|
+
...props,
|
|
275
|
+
className: `eth-workflow-process-timeline ${className ?? ""}`,
|
|
276
|
+
"data-eth-component": "ProcessTimeline",
|
|
277
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("ol", { children: events.map((event) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("li", { children: [
|
|
278
|
+
event.status ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_core5.StatusDot, { status: event.status }) : null,
|
|
279
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: event.label }),
|
|
280
|
+
event.timestamp ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("time", { dateTime: event.timestamp, children: event.timestamp }) : null
|
|
281
|
+
] }, event.id)) })
|
|
282
|
+
}
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// src/components/RuleBuilder.tsx
|
|
287
|
+
var React2 = __toESM(require("react"), 1);
|
|
288
|
+
var import_core6 = require("@echothink-ui/core");
|
|
289
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
290
|
+
var defaultRule = {
|
|
291
|
+
combinator: "all",
|
|
292
|
+
conditions: [{ field: "", operator: "equals", value: "" }]
|
|
293
|
+
};
|
|
294
|
+
function RuleBuilder({ value, onChange, variables = [], className, ...props }) {
|
|
295
|
+
const [internalRule, setInternalRule] = React2.useState(value ?? defaultRule);
|
|
296
|
+
const rule = value ?? internalRule;
|
|
297
|
+
const commit = (nextRule) => {
|
|
298
|
+
setInternalRule(nextRule);
|
|
299
|
+
onChange?.(nextRule);
|
|
300
|
+
};
|
|
301
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
302
|
+
"section",
|
|
303
|
+
{
|
|
304
|
+
...props,
|
|
305
|
+
className: `eth-workflow-rule-builder ${className ?? ""}`,
|
|
306
|
+
"data-eth-component": "RuleBuilder",
|
|
307
|
+
children: [
|
|
308
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_core6.FormField, { label: "Match", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
309
|
+
import_core6.Select,
|
|
310
|
+
{
|
|
311
|
+
value: rule.combinator,
|
|
312
|
+
options: [
|
|
313
|
+
{ value: "all", label: "All conditions" },
|
|
314
|
+
{ value: "any", label: "Any condition" }
|
|
315
|
+
],
|
|
316
|
+
onChange: (event) => commit({ ...rule, combinator: event.currentTarget.value })
|
|
317
|
+
}
|
|
318
|
+
) }),
|
|
319
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "eth-workflow-rule-builder__conditions", children: rule.conditions.map((condition, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "eth-workflow-rule-builder__condition", children: [
|
|
320
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
321
|
+
ConditionBuilder,
|
|
322
|
+
{
|
|
323
|
+
value: condition,
|
|
324
|
+
variables,
|
|
325
|
+
onChange: (nextCondition) => {
|
|
326
|
+
const conditions = [...rule.conditions];
|
|
327
|
+
conditions[index] = nextCondition;
|
|
328
|
+
commit({ ...rule, conditions });
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
),
|
|
332
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
333
|
+
import_core6.Button,
|
|
334
|
+
{
|
|
335
|
+
intent: "ghost",
|
|
336
|
+
density: "compact",
|
|
337
|
+
onClick: () => commit({ ...rule, conditions: rule.conditions.filter((_, itemIndex) => itemIndex !== index) }),
|
|
338
|
+
children: "Remove"
|
|
339
|
+
}
|
|
340
|
+
)
|
|
341
|
+
] }, index)) }),
|
|
342
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
343
|
+
import_core6.Button,
|
|
344
|
+
{
|
|
345
|
+
intent: "secondary",
|
|
346
|
+
density: "compact",
|
|
347
|
+
onClick: () => commit({ ...rule, conditions: [...rule.conditions, { field: variables[0] ?? "", operator: "equals", value: "" }] }),
|
|
348
|
+
children: "Add condition"
|
|
349
|
+
}
|
|
350
|
+
)
|
|
351
|
+
]
|
|
352
|
+
}
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// src/components/RuleSimulationPanel.tsx
|
|
357
|
+
var import_core7 = require("@echothink-ui/core");
|
|
358
|
+
var import_data = require("@echothink-ui/data");
|
|
359
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
360
|
+
function RuleSimulationPanel({
|
|
361
|
+
rule,
|
|
362
|
+
sampleInputs,
|
|
363
|
+
results = [],
|
|
364
|
+
onRun,
|
|
365
|
+
className,
|
|
366
|
+
...props
|
|
367
|
+
}) {
|
|
368
|
+
const resultMap = new Map(results.map((result) => [result.sampleId, result]));
|
|
369
|
+
const rows = sampleInputs.map((sample) => ({
|
|
370
|
+
...sample,
|
|
371
|
+
actualOutcome: resultMap.get(sample.id)?.actualOutcome,
|
|
372
|
+
matched: resultMap.get(sample.id)?.matched
|
|
373
|
+
}));
|
|
374
|
+
const columns = [
|
|
375
|
+
{ key: "label", header: "Sample" },
|
|
376
|
+
{ key: "data", header: "Input", render: (row) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { children: JSON.stringify(row.data) }) },
|
|
377
|
+
{ key: "expectedOutcome", header: "Expected", render: (row) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { children: JSON.stringify(row.expectedOutcome) }) },
|
|
378
|
+
{ key: "actualOutcome", header: "Actual", render: (row) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { children: JSON.stringify(row.actualOutcome) }) },
|
|
379
|
+
{ key: "matched", header: "Matched", render: (row) => row.matched ? "Yes" : row.matched === false ? "No" : "Not run" }
|
|
380
|
+
];
|
|
381
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
382
|
+
"section",
|
|
383
|
+
{
|
|
384
|
+
...props,
|
|
385
|
+
className: `eth-workflow-rule-simulation ${className ?? ""}`,
|
|
386
|
+
"data-eth-component": "RuleSimulationPanel",
|
|
387
|
+
children: [
|
|
388
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("header", { children: [
|
|
389
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h3", { children: "Rule simulation" }),
|
|
390
|
+
onRun ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_core7.Button, { onClick: onRun, children: "Run" }) : null
|
|
391
|
+
] }),
|
|
392
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("pre", { className: "eth-workflow-rule-simulation__rule", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { children: JSON.stringify(rule, null, 2) }) }),
|
|
393
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_data.DataTable, { rows, columns, rowKey: "id" })
|
|
394
|
+
]
|
|
395
|
+
}
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// src/components/WorkflowHandoffPanel.tsx
|
|
400
|
+
var React3 = __toESM(require("react"), 1);
|
|
401
|
+
var import_core8 = require("@echothink-ui/core");
|
|
402
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
403
|
+
function WorkflowHandoffPanel({
|
|
404
|
+
item,
|
|
405
|
+
assigneeOptions = [],
|
|
406
|
+
onSubmit,
|
|
407
|
+
className,
|
|
408
|
+
...props
|
|
409
|
+
}) {
|
|
410
|
+
const [assigneeId, setAssigneeId] = React3.useState(assigneeOptions[0]?.id ?? "");
|
|
411
|
+
const [reason, setReason] = React3.useState("");
|
|
412
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
413
|
+
"section",
|
|
414
|
+
{
|
|
415
|
+
...props,
|
|
416
|
+
className: `eth-workflow-handoff-panel ${className ?? ""}`,
|
|
417
|
+
"data-eth-component": "WorkflowHandoffPanel",
|
|
418
|
+
children: [
|
|
419
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("header", { children: [
|
|
420
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h3", { children: "Workflow handoff" }),
|
|
421
|
+
item?.status ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core8.StatusDot, { status: item.status, label: item.status }) : null
|
|
422
|
+
] }),
|
|
423
|
+
item ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { children: item.label }) : null,
|
|
424
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("form", { onSubmit: (event) => {
|
|
425
|
+
event.preventDefault();
|
|
426
|
+
onSubmit?.({ assigneeId, reason });
|
|
427
|
+
}, children: [
|
|
428
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core8.FormField, { label: "Assignee", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
429
|
+
import_core8.Select,
|
|
430
|
+
{
|
|
431
|
+
value: assigneeId,
|
|
432
|
+
options: assigneeOptions.map((option) => ({ value: option.id, label: option.kind ? `${option.label} (${option.kind})` : option.label })),
|
|
433
|
+
onChange: (event) => setAssigneeId(event.currentTarget.value)
|
|
434
|
+
}
|
|
435
|
+
) }),
|
|
436
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core8.FormField, { label: "Reason", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core8.Textarea, { value: reason, rows: 4, onChange: (event) => setReason(event.currentTarget.value) }) }),
|
|
437
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core8.Button, { type: "submit", disabled: !assigneeId, children: "Handoff" })
|
|
438
|
+
] })
|
|
439
|
+
]
|
|
440
|
+
}
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// src/components/WorkflowPipelineView.tsx
|
|
445
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
446
|
+
function WorkflowPipelineView({
|
|
447
|
+
stages,
|
|
448
|
+
activeStageId,
|
|
449
|
+
onSelect,
|
|
450
|
+
className,
|
|
451
|
+
...props
|
|
452
|
+
}) {
|
|
453
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
454
|
+
"section",
|
|
455
|
+
{
|
|
456
|
+
...props,
|
|
457
|
+
className: `eth-workflow-pipeline-view ${className ?? ""}`,
|
|
458
|
+
"data-eth-component": "WorkflowPipelineView",
|
|
459
|
+
"aria-label": "Workflow pipeline",
|
|
460
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ol", { className: "eth-workflow-pipeline-view__stages", children: stages.map((stage, index) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
461
|
+
PipelineStage,
|
|
462
|
+
{
|
|
463
|
+
stage,
|
|
464
|
+
active: stage.id === activeStageId,
|
|
465
|
+
onSelect,
|
|
466
|
+
"aria-posinset": index + 1,
|
|
467
|
+
"aria-setsize": stages.length
|
|
468
|
+
}
|
|
469
|
+
) }, stage.id)) })
|
|
470
|
+
}
|
|
471
|
+
);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// src/index.tsx
|
|
475
|
+
var WorkflowComponentNames = [
|
|
476
|
+
"WorkflowPipelineView",
|
|
477
|
+
"PipelineStage",
|
|
478
|
+
"ProcessDesigner",
|
|
479
|
+
"RuleBuilder",
|
|
480
|
+
"ConditionBuilder",
|
|
481
|
+
"RuleSimulationPanel",
|
|
482
|
+
"WorkflowHandoffPanel",
|
|
483
|
+
"ApprovalWorkflowEditor",
|
|
484
|
+
"ProcessTimeline"
|
|
485
|
+
];
|
|
486
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
487
|
+
0 && (module.exports = {
|
|
488
|
+
ApprovalWorkflowEditor,
|
|
489
|
+
ConditionBuilder,
|
|
490
|
+
PipelineStage,
|
|
491
|
+
ProcessDesigner,
|
|
492
|
+
ProcessTimeline,
|
|
493
|
+
RuleBuilder,
|
|
494
|
+
RuleSimulationPanel,
|
|
495
|
+
WorkflowComponentNames,
|
|
496
|
+
WorkflowHandoffPanel,
|
|
497
|
+
WorkflowPipelineView
|
|
498
|
+
});
|
|
499
|
+
//# sourceMappingURL=index.cjs.map
|