@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/dist/index.js ADDED
@@ -0,0 +1,453 @@
1
+ // src/components/ApprovalWorkflowEditor.tsx
2
+ import { Button, Checkbox, TextInput } from "@echothink-ui/core";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ function ApprovalWorkflowEditor({ steps = [], onChange, className, ...props }) {
5
+ const update = (index, next) => {
6
+ const nextSteps = [...steps];
7
+ nextSteps[index] = next;
8
+ onChange?.(nextSteps);
9
+ };
10
+ return /* @__PURE__ */ jsxs(
11
+ "section",
12
+ {
13
+ ...props,
14
+ className: `eth-workflow-approval-editor ${className ?? ""}`,
15
+ "data-eth-component": "ApprovalWorkflowEditor",
16
+ children: [
17
+ steps.map((step, index) => /* @__PURE__ */ jsxs("div", { className: "eth-workflow-approval-editor__step", children: [
18
+ /* @__PURE__ */ jsx(TextInput, { value: step.label, onChange: (event) => update(index, { ...step, label: event.currentTarget.value }), "aria-label": "Step label" }),
19
+ /* @__PURE__ */ jsx(TextInput, { value: step.approver ?? "", onChange: (event) => update(index, { ...step, approver: event.currentTarget.value }), "aria-label": "Approver" }),
20
+ /* @__PURE__ */ jsx(Checkbox, { checked: Boolean(step.required), label: "Required", onChange: (event) => update(index, { ...step, required: event.currentTarget.checked }) })
21
+ ] }, step.id)),
22
+ /* @__PURE__ */ jsx(
23
+ Button,
24
+ {
25
+ intent: "secondary",
26
+ density: "compact",
27
+ onClick: () => onChange?.([...steps, { id: `step-${steps.length + 1}`, label: "Approval step", required: true }]),
28
+ children: "Add approval"
29
+ }
30
+ )
31
+ ]
32
+ }
33
+ );
34
+ }
35
+
36
+ // src/components/ConditionBuilder.tsx
37
+ import { FormField, Select, TextInput as TextInput2 } from "@echothink-ui/core";
38
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
39
+ var operators = [
40
+ { value: "equals", label: "Equals" },
41
+ { value: "not-equals", label: "Does not equal" },
42
+ { value: "contains", label: "Contains" },
43
+ { value: "gt", label: "Greater than" },
44
+ { value: "gte", label: "Greater than or equal" },
45
+ { value: "lt", label: "Less than" },
46
+ { value: "lte", label: "Less than or equal" },
47
+ { value: "exists", label: "Exists" }
48
+ ];
49
+ function ConditionBuilder({ value, onChange, variables = [], className, ...props }) {
50
+ const fieldOptions = variables.length ? variables.map((field) => ({ value: field, label: field })) : [{ value: value.field, label: value.field || "field" }];
51
+ const update = (key, nextValue) => {
52
+ onChange({ ...value, [key]: nextValue });
53
+ };
54
+ return /* @__PURE__ */ jsxs2(
55
+ "section",
56
+ {
57
+ ...props,
58
+ className: `eth-workflow-condition-builder ${className ?? ""}`,
59
+ "data-eth-component": "ConditionBuilder",
60
+ children: [
61
+ /* @__PURE__ */ jsx2(FormField, { label: "Field", children: /* @__PURE__ */ jsx2(Select, { value: value.field, options: fieldOptions, onChange: (event) => update("field", event.currentTarget.value) }) }),
62
+ /* @__PURE__ */ jsx2(FormField, { label: "Operator", children: /* @__PURE__ */ jsx2(Select, { value: value.operator, options: operators, onChange: (event) => update("operator", event.currentTarget.value) }) }),
63
+ /* @__PURE__ */ jsx2(FormField, { label: "Value", children: /* @__PURE__ */ jsx2(TextInput2, { value: value.value ?? "", onChange: (event) => update("value", event.currentTarget.value), disabled: value.operator === "exists" }) })
64
+ ]
65
+ }
66
+ );
67
+ }
68
+
69
+ // src/components/PipelineStage.tsx
70
+ import { StatusDot } from "@echothink-ui/core";
71
+ import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
72
+ function PipelineStage({ stage, active, onSelect, className, ...props }) {
73
+ const content = /* @__PURE__ */ jsxs3(Fragment, { children: [
74
+ /* @__PURE__ */ jsx3(StatusDot, { status: stage.status, label: stage.status }),
75
+ /* @__PURE__ */ jsx3("strong", { children: stage.label }),
76
+ stage.durationMs !== void 0 ? /* @__PURE__ */ jsxs3("small", { children: [
77
+ stage.durationMs,
78
+ "ms"
79
+ ] }) : null
80
+ ] });
81
+ return onSelect ? /* @__PURE__ */ jsx3(
82
+ "button",
83
+ {
84
+ ...props,
85
+ type: "button",
86
+ className: `eth-workflow-pipeline-stage ${active ? "eth-workflow-pipeline-stage--active" : ""} ${className ?? ""}`,
87
+ "data-eth-component": "PipelineStage",
88
+ onClick: () => onSelect(stage.id),
89
+ children: content
90
+ }
91
+ ) : /* @__PURE__ */ jsx3(
92
+ "article",
93
+ {
94
+ ...props,
95
+ className: `eth-workflow-pipeline-stage ${active ? "eth-workflow-pipeline-stage--active" : ""} ${className ?? ""}`,
96
+ "data-eth-component": "PipelineStage",
97
+ children: content
98
+ }
99
+ );
100
+ }
101
+
102
+ // src/components/ProcessDesigner.tsx
103
+ import * as React from "react";
104
+ import { Button as Button2 } from "@echothink-ui/core";
105
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
106
+ function ProcessDesigner({
107
+ nodes,
108
+ edges,
109
+ onNodeMove,
110
+ onAddNode,
111
+ onConnect,
112
+ className,
113
+ ...props
114
+ }) {
115
+ const svgRef = React.useRef(null);
116
+ const [positions, setPositions] = React.useState(() => initialPositions(nodes));
117
+ const [draggingId, setDraggingId] = React.useState(null);
118
+ const [selectedNodeId, setSelectedNodeId] = React.useState(null);
119
+ React.useEffect(() => {
120
+ setPositions(initialPositions(nodes));
121
+ }, [nodes]);
122
+ const pointFromEvent = (event) => {
123
+ const rect = svgRef.current?.getBoundingClientRect();
124
+ if (!rect) return { x: 0, y: 0 };
125
+ return {
126
+ x: (event.clientX - rect.left) / rect.width * 900,
127
+ y: (event.clientY - rect.top) / rect.height * 420
128
+ };
129
+ };
130
+ const move = (event) => {
131
+ if (!draggingId) return;
132
+ const point = pointFromEvent(event);
133
+ setPositions((current) => ({ ...current, [draggingId]: point }));
134
+ };
135
+ const stop = () => {
136
+ if (!draggingId) return;
137
+ const point = positions[draggingId];
138
+ if (point) onNodeMove?.(draggingId, point.x, point.y);
139
+ setDraggingId(null);
140
+ };
141
+ const clickNode = (id) => {
142
+ if (selectedNodeId && selectedNodeId !== id) {
143
+ onConnect?.(selectedNodeId, id);
144
+ setSelectedNodeId(null);
145
+ } else {
146
+ setSelectedNodeId(id);
147
+ }
148
+ };
149
+ return /* @__PURE__ */ jsxs4(
150
+ "section",
151
+ {
152
+ ...props,
153
+ className: `eth-workflow-process-designer ${className ?? ""}`,
154
+ "data-eth-component": "ProcessDesigner",
155
+ children: [
156
+ /* @__PURE__ */ jsxs4("header", { children: [
157
+ /* @__PURE__ */ jsx4("h3", { children: "Process designer" }),
158
+ onAddNode ? /* @__PURE__ */ jsx4(Button2, { intent: "secondary", density: "compact", onClick: onAddNode, children: "Add node" }) : null
159
+ ] }),
160
+ /* @__PURE__ */ jsxs4(
161
+ "svg",
162
+ {
163
+ ref: svgRef,
164
+ viewBox: "0 0 900 420",
165
+ role: "img",
166
+ "aria-label": "Process graph",
167
+ onMouseMove: move,
168
+ onMouseUp: stop,
169
+ onMouseLeave: stop,
170
+ children: [
171
+ edges.map((edge, index) => {
172
+ const from = positions[edge.from];
173
+ const to = positions[edge.to];
174
+ if (!from || !to) return null;
175
+ const midX = (from.x + to.x) / 2;
176
+ const midY = (from.y + to.y) / 2;
177
+ return /* @__PURE__ */ jsxs4("g", { children: [
178
+ /* @__PURE__ */ jsx4("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)" }),
179
+ edge.label ? /* @__PURE__ */ jsx4("text", { x: midX, y: midY - 6, textAnchor: "middle", fontSize: 12, children: edge.label }) : null
180
+ ] }, `${edge.from}-${edge.to}-${index}`);
181
+ }),
182
+ /* @__PURE__ */ jsx4("defs", { children: /* @__PURE__ */ jsx4("marker", { id: "eth-workflow-arrow", viewBox: "0 0 10 10", refX: "8", refY: "5", markerWidth: "6", markerHeight: "6", orient: "auto-start-reverse", children: /* @__PURE__ */ jsx4("path", { d: "M 0 0 L 10 5 L 0 10 z", fill: "var(--eth-color-border-strong)" }) }) }),
183
+ nodes.map((node) => {
184
+ const point = positions[node.id];
185
+ if (!point) return null;
186
+ return /* @__PURE__ */ jsxs4(
187
+ "g",
188
+ {
189
+ transform: `translate(${point.x}, ${point.y})`,
190
+ className: `eth-workflow-process-designer__node eth-workflow-process-designer__node--${node.type} ${selectedNodeId === node.id ? "eth-workflow-process-designer__node--selected" : ""}`,
191
+ onMouseDown: (event) => {
192
+ event.preventDefault();
193
+ setDraggingId(node.id);
194
+ },
195
+ onClick: () => clickNode(node.id),
196
+ children: [
197
+ node.type === "decision" ? /* @__PURE__ */ jsx4("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__ */ jsx4("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 }),
198
+ /* @__PURE__ */ jsx4("text", { textAnchor: "middle", dominantBaseline: "middle", fontSize: 13, children: node.label })
199
+ ]
200
+ },
201
+ node.id
202
+ );
203
+ })
204
+ ]
205
+ }
206
+ )
207
+ ]
208
+ }
209
+ );
210
+ }
211
+ function initialPositions(nodes) {
212
+ const positions = {};
213
+ nodes.forEach((node, index) => {
214
+ positions[node.id] = {
215
+ x: node.x ?? 100 + index % 5 * 170,
216
+ y: node.y ?? 90 + Math.floor(index / 5) * 120
217
+ };
218
+ });
219
+ return positions;
220
+ }
221
+
222
+ // src/components/ProcessTimeline.tsx
223
+ import { StatusDot as StatusDot2 } from "@echothink-ui/core";
224
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
225
+ function ProcessTimeline({ events = [], className, ...props }) {
226
+ return /* @__PURE__ */ jsx5(
227
+ "section",
228
+ {
229
+ ...props,
230
+ className: `eth-workflow-process-timeline ${className ?? ""}`,
231
+ "data-eth-component": "ProcessTimeline",
232
+ children: /* @__PURE__ */ jsx5("ol", { children: events.map((event) => /* @__PURE__ */ jsxs5("li", { children: [
233
+ event.status ? /* @__PURE__ */ jsx5(StatusDot2, { status: event.status }) : null,
234
+ /* @__PURE__ */ jsx5("span", { children: event.label }),
235
+ event.timestamp ? /* @__PURE__ */ jsx5("time", { dateTime: event.timestamp, children: event.timestamp }) : null
236
+ ] }, event.id)) })
237
+ }
238
+ );
239
+ }
240
+
241
+ // src/components/RuleBuilder.tsx
242
+ import * as React2 from "react";
243
+ import { Button as Button3, FormField as FormField2, Select as Select2 } from "@echothink-ui/core";
244
+ import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
245
+ var defaultRule = {
246
+ combinator: "all",
247
+ conditions: [{ field: "", operator: "equals", value: "" }]
248
+ };
249
+ function RuleBuilder({ value, onChange, variables = [], className, ...props }) {
250
+ const [internalRule, setInternalRule] = React2.useState(value ?? defaultRule);
251
+ const rule = value ?? internalRule;
252
+ const commit = (nextRule) => {
253
+ setInternalRule(nextRule);
254
+ onChange?.(nextRule);
255
+ };
256
+ return /* @__PURE__ */ jsxs6(
257
+ "section",
258
+ {
259
+ ...props,
260
+ className: `eth-workflow-rule-builder ${className ?? ""}`,
261
+ "data-eth-component": "RuleBuilder",
262
+ children: [
263
+ /* @__PURE__ */ jsx6(FormField2, { label: "Match", children: /* @__PURE__ */ jsx6(
264
+ Select2,
265
+ {
266
+ value: rule.combinator,
267
+ options: [
268
+ { value: "all", label: "All conditions" },
269
+ { value: "any", label: "Any condition" }
270
+ ],
271
+ onChange: (event) => commit({ ...rule, combinator: event.currentTarget.value })
272
+ }
273
+ ) }),
274
+ /* @__PURE__ */ jsx6("div", { className: "eth-workflow-rule-builder__conditions", children: rule.conditions.map((condition, index) => /* @__PURE__ */ jsxs6("div", { className: "eth-workflow-rule-builder__condition", children: [
275
+ /* @__PURE__ */ jsx6(
276
+ ConditionBuilder,
277
+ {
278
+ value: condition,
279
+ variables,
280
+ onChange: (nextCondition) => {
281
+ const conditions = [...rule.conditions];
282
+ conditions[index] = nextCondition;
283
+ commit({ ...rule, conditions });
284
+ }
285
+ }
286
+ ),
287
+ /* @__PURE__ */ jsx6(
288
+ Button3,
289
+ {
290
+ intent: "ghost",
291
+ density: "compact",
292
+ onClick: () => commit({ ...rule, conditions: rule.conditions.filter((_, itemIndex) => itemIndex !== index) }),
293
+ children: "Remove"
294
+ }
295
+ )
296
+ ] }, index)) }),
297
+ /* @__PURE__ */ jsx6(
298
+ Button3,
299
+ {
300
+ intent: "secondary",
301
+ density: "compact",
302
+ onClick: () => commit({ ...rule, conditions: [...rule.conditions, { field: variables[0] ?? "", operator: "equals", value: "" }] }),
303
+ children: "Add condition"
304
+ }
305
+ )
306
+ ]
307
+ }
308
+ );
309
+ }
310
+
311
+ // src/components/RuleSimulationPanel.tsx
312
+ import { Button as Button4 } from "@echothink-ui/core";
313
+ import { DataTable } from "@echothink-ui/data";
314
+ import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
315
+ function RuleSimulationPanel({
316
+ rule,
317
+ sampleInputs,
318
+ results = [],
319
+ onRun,
320
+ className,
321
+ ...props
322
+ }) {
323
+ const resultMap = new Map(results.map((result) => [result.sampleId, result]));
324
+ const rows = sampleInputs.map((sample) => ({
325
+ ...sample,
326
+ actualOutcome: resultMap.get(sample.id)?.actualOutcome,
327
+ matched: resultMap.get(sample.id)?.matched
328
+ }));
329
+ const columns = [
330
+ { key: "label", header: "Sample" },
331
+ { key: "data", header: "Input", render: (row) => /* @__PURE__ */ jsx7("code", { children: JSON.stringify(row.data) }) },
332
+ { key: "expectedOutcome", header: "Expected", render: (row) => /* @__PURE__ */ jsx7("code", { children: JSON.stringify(row.expectedOutcome) }) },
333
+ { key: "actualOutcome", header: "Actual", render: (row) => /* @__PURE__ */ jsx7("code", { children: JSON.stringify(row.actualOutcome) }) },
334
+ { key: "matched", header: "Matched", render: (row) => row.matched ? "Yes" : row.matched === false ? "No" : "Not run" }
335
+ ];
336
+ return /* @__PURE__ */ jsxs7(
337
+ "section",
338
+ {
339
+ ...props,
340
+ className: `eth-workflow-rule-simulation ${className ?? ""}`,
341
+ "data-eth-component": "RuleSimulationPanel",
342
+ children: [
343
+ /* @__PURE__ */ jsxs7("header", { children: [
344
+ /* @__PURE__ */ jsx7("h3", { children: "Rule simulation" }),
345
+ onRun ? /* @__PURE__ */ jsx7(Button4, { onClick: onRun, children: "Run" }) : null
346
+ ] }),
347
+ /* @__PURE__ */ jsx7("pre", { className: "eth-workflow-rule-simulation__rule", children: /* @__PURE__ */ jsx7("code", { children: JSON.stringify(rule, null, 2) }) }),
348
+ /* @__PURE__ */ jsx7(DataTable, { rows, columns, rowKey: "id" })
349
+ ]
350
+ }
351
+ );
352
+ }
353
+
354
+ // src/components/WorkflowHandoffPanel.tsx
355
+ import * as React3 from "react";
356
+ import { Button as Button5, FormField as FormField3, Select as Select3, StatusDot as StatusDot3, Textarea } from "@echothink-ui/core";
357
+ import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
358
+ function WorkflowHandoffPanel({
359
+ item,
360
+ assigneeOptions = [],
361
+ onSubmit,
362
+ className,
363
+ ...props
364
+ }) {
365
+ const [assigneeId, setAssigneeId] = React3.useState(assigneeOptions[0]?.id ?? "");
366
+ const [reason, setReason] = React3.useState("");
367
+ return /* @__PURE__ */ jsxs8(
368
+ "section",
369
+ {
370
+ ...props,
371
+ className: `eth-workflow-handoff-panel ${className ?? ""}`,
372
+ "data-eth-component": "WorkflowHandoffPanel",
373
+ children: [
374
+ /* @__PURE__ */ jsxs8("header", { children: [
375
+ /* @__PURE__ */ jsx8("h3", { children: "Workflow handoff" }),
376
+ item?.status ? /* @__PURE__ */ jsx8(StatusDot3, { status: item.status, label: item.status }) : null
377
+ ] }),
378
+ item ? /* @__PURE__ */ jsx8("p", { children: item.label }) : null,
379
+ /* @__PURE__ */ jsxs8("form", { onSubmit: (event) => {
380
+ event.preventDefault();
381
+ onSubmit?.({ assigneeId, reason });
382
+ }, children: [
383
+ /* @__PURE__ */ jsx8(FormField3, { label: "Assignee", children: /* @__PURE__ */ jsx8(
384
+ Select3,
385
+ {
386
+ value: assigneeId,
387
+ options: assigneeOptions.map((option) => ({ value: option.id, label: option.kind ? `${option.label} (${option.kind})` : option.label })),
388
+ onChange: (event) => setAssigneeId(event.currentTarget.value)
389
+ }
390
+ ) }),
391
+ /* @__PURE__ */ jsx8(FormField3, { label: "Reason", children: /* @__PURE__ */ jsx8(Textarea, { value: reason, rows: 4, onChange: (event) => setReason(event.currentTarget.value) }) }),
392
+ /* @__PURE__ */ jsx8(Button5, { type: "submit", disabled: !assigneeId, children: "Handoff" })
393
+ ] })
394
+ ]
395
+ }
396
+ );
397
+ }
398
+
399
+ // src/components/WorkflowPipelineView.tsx
400
+ import { jsx as jsx9 } from "react/jsx-runtime";
401
+ function WorkflowPipelineView({
402
+ stages,
403
+ activeStageId,
404
+ onSelect,
405
+ className,
406
+ ...props
407
+ }) {
408
+ return /* @__PURE__ */ jsx9(
409
+ "section",
410
+ {
411
+ ...props,
412
+ className: `eth-workflow-pipeline-view ${className ?? ""}`,
413
+ "data-eth-component": "WorkflowPipelineView",
414
+ "aria-label": "Workflow pipeline",
415
+ children: /* @__PURE__ */ jsx9("ol", { className: "eth-workflow-pipeline-view__stages", children: stages.map((stage, index) => /* @__PURE__ */ jsx9("li", { children: /* @__PURE__ */ jsx9(
416
+ PipelineStage,
417
+ {
418
+ stage,
419
+ active: stage.id === activeStageId,
420
+ onSelect,
421
+ "aria-posinset": index + 1,
422
+ "aria-setsize": stages.length
423
+ }
424
+ ) }, stage.id)) })
425
+ }
426
+ );
427
+ }
428
+
429
+ // src/index.tsx
430
+ var WorkflowComponentNames = [
431
+ "WorkflowPipelineView",
432
+ "PipelineStage",
433
+ "ProcessDesigner",
434
+ "RuleBuilder",
435
+ "ConditionBuilder",
436
+ "RuleSimulationPanel",
437
+ "WorkflowHandoffPanel",
438
+ "ApprovalWorkflowEditor",
439
+ "ProcessTimeline"
440
+ ];
441
+ export {
442
+ ApprovalWorkflowEditor,
443
+ ConditionBuilder,
444
+ PipelineStage,
445
+ ProcessDesigner,
446
+ ProcessTimeline,
447
+ RuleBuilder,
448
+ RuleSimulationPanel,
449
+ WorkflowComponentNames,
450
+ WorkflowHandoffPanel,
451
+ WorkflowPipelineView
452
+ };
453
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/ApprovalWorkflowEditor.tsx","../src/components/ConditionBuilder.tsx","../src/components/PipelineStage.tsx","../src/components/ProcessDesigner.tsx","../src/components/ProcessTimeline.tsx","../src/components/RuleBuilder.tsx","../src/components/RuleSimulationPanel.tsx","../src/components/WorkflowHandoffPanel.tsx","../src/components/WorkflowPipelineView.tsx","../src/index.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { Button, Checkbox, TextInput } from \"@echothink-ui/core\";\nimport type { ApprovalWorkflowEditorProps } from \"./types\";\n\nexport function ApprovalWorkflowEditor({ steps = [], onChange, className, ...props }: ApprovalWorkflowEditorProps) {\n const update = (index: number, next: NonNullable<ApprovalWorkflowEditorProps[\"steps\"]>[number]) => {\n const nextSteps = [...steps];\n nextSteps[index] = next;\n onChange?.(nextSteps);\n };\n\n return (\n <section\n {...props}\n className={`eth-workflow-approval-editor ${className ?? \"\"}`}\n data-eth-component=\"ApprovalWorkflowEditor\"\n >\n {steps.map((step, index) => (\n <div key={step.id} className=\"eth-workflow-approval-editor__step\">\n <TextInput value={step.label} onChange={(event) => update(index, { ...step, label: event.currentTarget.value })} aria-label=\"Step label\" />\n <TextInput value={step.approver ?? \"\"} onChange={(event) => update(index, { ...step, approver: event.currentTarget.value })} aria-label=\"Approver\" />\n <Checkbox checked={Boolean(step.required)} label=\"Required\" onChange={(event) => update(index, { ...step, required: event.currentTarget.checked })} />\n </div>\n ))}\n <Button\n intent=\"secondary\"\n density=\"compact\"\n onClick={() => onChange?.([...steps, { id: `step-${steps.length + 1}`, label: \"Approval step\", required: true }])}\n >\n Add approval\n </Button>\n </section>\n );\n}\n","import * as React from \"react\";\nimport { FormField, Select, TextInput } from \"@echothink-ui/core\";\nimport type { ConditionBuilderProps, WorkflowRuleCondition } from \"./types\";\n\nconst operators: Array<{ value: WorkflowRuleCondition[\"operator\"]; label: string }> = [\n { value: \"equals\", label: \"Equals\" },\n { value: \"not-equals\", label: \"Does not equal\" },\n { value: \"contains\", label: \"Contains\" },\n { value: \"gt\", label: \"Greater than\" },\n { value: \"gte\", label: \"Greater than or equal\" },\n { value: \"lt\", label: \"Less than\" },\n { value: \"lte\", label: \"Less than or equal\" },\n { value: \"exists\", label: \"Exists\" }\n];\n\nexport function ConditionBuilder({ value, onChange, variables = [], className, ...props }: ConditionBuilderProps) {\n const fieldOptions = variables.length\n ? variables.map((field) => ({ value: field, label: field }))\n : [{ value: value.field, label: value.field || \"field\" }];\n const update = <K extends keyof WorkflowRuleCondition>(key: K, nextValue: WorkflowRuleCondition[K]) => {\n onChange({ ...value, [key]: nextValue });\n };\n\n return (\n <section\n {...props}\n className={`eth-workflow-condition-builder ${className ?? \"\"}`}\n data-eth-component=\"ConditionBuilder\"\n >\n <FormField label=\"Field\">\n <Select value={value.field} options={fieldOptions} onChange={(event) => update(\"field\", event.currentTarget.value)} />\n </FormField>\n <FormField label=\"Operator\">\n <Select value={value.operator} options={operators} onChange={(event) => update(\"operator\", event.currentTarget.value as WorkflowRuleCondition[\"operator\"])} />\n </FormField>\n <FormField label=\"Value\">\n <TextInput value={value.value ?? \"\"} onChange={(event) => update(\"value\", event.currentTarget.value)} disabled={value.operator === \"exists\"} />\n </FormField>\n </section>\n );\n}\n","import * as React from \"react\";\nimport { StatusDot } from \"@echothink-ui/core\";\nimport type { PipelineStageProps } from \"./types\";\n\nexport function PipelineStage({ stage, active, onSelect, className, ...props }: PipelineStageProps) {\n const content = (\n <>\n <StatusDot status={stage.status} label={stage.status} />\n <strong>{stage.label}</strong>\n {stage.durationMs !== undefined ? <small>{stage.durationMs}ms</small> : null}\n </>\n );\n\n return onSelect ? (\n <button\n {...props}\n type=\"button\"\n className={`eth-workflow-pipeline-stage ${active ? \"eth-workflow-pipeline-stage--active\" : \"\"} ${className ?? \"\"}`}\n data-eth-component=\"PipelineStage\"\n onClick={() => onSelect(stage.id)}\n >\n {content}\n </button>\n ) : (\n <article\n {...props}\n className={`eth-workflow-pipeline-stage ${active ? \"eth-workflow-pipeline-stage--active\" : \"\"} ${className ?? \"\"}`}\n data-eth-component=\"PipelineStage\"\n >\n {content}\n </article>\n );\n}\n","import * as React from \"react\";\nimport { Button } from \"@echothink-ui/core\";\nimport type { ProcessDesignerProps, ProcessNode } from \"./types\";\n\nexport function ProcessDesigner({\n nodes,\n edges,\n onNodeMove,\n onAddNode,\n onConnect,\n className,\n ...props\n}: ProcessDesignerProps) {\n const svgRef = React.useRef<SVGSVGElement>(null);\n const [positions, setPositions] = React.useState(() => initialPositions(nodes));\n const [draggingId, setDraggingId] = React.useState<string | null>(null);\n const [selectedNodeId, setSelectedNodeId] = React.useState<string | null>(null);\n\n React.useEffect(() => {\n setPositions(initialPositions(nodes));\n }, [nodes]);\n\n const pointFromEvent = (event: React.MouseEvent<SVGSVGElement>) => {\n const rect = svgRef.current?.getBoundingClientRect();\n if (!rect) return { x: 0, y: 0 };\n return {\n x: ((event.clientX - rect.left) / rect.width) * 900,\n y: ((event.clientY - rect.top) / rect.height) * 420\n };\n };\n\n const move = (event: React.MouseEvent<SVGSVGElement>) => {\n if (!draggingId) return;\n const point = pointFromEvent(event);\n setPositions((current) => ({ ...current, [draggingId]: point }));\n };\n\n const stop = () => {\n if (!draggingId) return;\n const point = positions[draggingId];\n if (point) onNodeMove?.(draggingId, point.x, point.y);\n setDraggingId(null);\n };\n\n const clickNode = (id: string) => {\n if (selectedNodeId && selectedNodeId !== id) {\n onConnect?.(selectedNodeId, id);\n setSelectedNodeId(null);\n } else {\n setSelectedNodeId(id);\n }\n };\n\n return (\n <section\n {...props}\n className={`eth-workflow-process-designer ${className ?? \"\"}`}\n data-eth-component=\"ProcessDesigner\"\n >\n <header>\n <h3>Process designer</h3>\n {onAddNode ? <Button intent=\"secondary\" density=\"compact\" onClick={onAddNode}>Add node</Button> : null}\n </header>\n <svg\n ref={svgRef}\n viewBox=\"0 0 900 420\"\n role=\"img\"\n aria-label=\"Process graph\"\n onMouseMove={move}\n onMouseUp={stop}\n onMouseLeave={stop}\n >\n {edges.map((edge, index) => {\n const from = positions[edge.from];\n const to = positions[edge.to];\n if (!from || !to) return null;\n const midX = (from.x + to.x) / 2;\n const midY = (from.y + to.y) / 2;\n return (\n <g key={`${edge.from}-${edge.to}-${index}`}>\n <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)\" />\n {edge.label ? <text x={midX} y={midY - 6} textAnchor=\"middle\" fontSize={12}>{edge.label}</text> : null}\n </g>\n );\n })}\n <defs>\n <marker id=\"eth-workflow-arrow\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"6\" markerHeight=\"6\" orient=\"auto-start-reverse\">\n <path d=\"M 0 0 L 10 5 L 0 10 z\" fill=\"var(--eth-color-border-strong)\" />\n </marker>\n </defs>\n {nodes.map((node) => {\n const point = positions[node.id];\n if (!point) return null;\n return (\n <g\n key={node.id}\n transform={`translate(${point.x}, ${point.y})`}\n className={`eth-workflow-process-designer__node eth-workflow-process-designer__node--${node.type} ${selectedNodeId === node.id ? \"eth-workflow-process-designer__node--selected\" : \"\"}`}\n onMouseDown={(event) => { event.preventDefault(); setDraggingId(node.id); }}\n onClick={() => clickNode(node.id)}\n >\n {node.type === \"decision\" ? (\n <polygon points=\"0,-32 54,0 0,32 -54,0\" fill=\"var(--eth-color-layer-01)\" stroke=\"var(--eth-color-border-strong)\" strokeWidth={2} />\n ) : (\n <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} />\n )}\n <text textAnchor=\"middle\" dominantBaseline=\"middle\" fontSize={13}>{node.label}</text>\n </g>\n );\n })}\n </svg>\n </section>\n );\n}\n\nfunction initialPositions(nodes: ProcessNode[]) {\n const positions: Record<string, { x: number; y: number }> = {};\n nodes.forEach((node, index) => {\n positions[node.id] = {\n x: node.x ?? 100 + (index % 5) * 170,\n y: node.y ?? 90 + Math.floor(index / 5) * 120\n };\n });\n return positions;\n}\n","import * as React from \"react\";\nimport { StatusDot } from \"@echothink-ui/core\";\nimport type { ProcessTimelineProps } from \"./types\";\n\nexport function ProcessTimeline({ events = [], className, ...props }: ProcessTimelineProps) {\n return (\n <section\n {...props}\n className={`eth-workflow-process-timeline ${className ?? \"\"}`}\n data-eth-component=\"ProcessTimeline\"\n >\n <ol>\n {events.map((event) => (\n <li key={event.id}>\n {event.status ? <StatusDot status={event.status} /> : null}\n <span>{event.label}</span>\n {event.timestamp ? <time dateTime={event.timestamp}>{event.timestamp}</time> : null}\n </li>\n ))}\n </ol>\n </section>\n );\n}\n","import * as React from \"react\";\nimport { Button, FormField, Select } from \"@echothink-ui/core\";\nimport { ConditionBuilder } from \"./ConditionBuilder\";\nimport type { RuleBuilderProps, WorkflowRule } from \"./types\";\n\nconst defaultRule: WorkflowRule = {\n combinator: \"all\",\n conditions: [{ field: \"\", operator: \"equals\", value: \"\" }]\n};\n\nexport function RuleBuilder({ value, onChange, variables = [], className, ...props }: RuleBuilderProps) {\n const [internalRule, setInternalRule] = React.useState<WorkflowRule>(value ?? defaultRule);\n const rule = value ?? internalRule;\n const commit = (nextRule: WorkflowRule) => {\n setInternalRule(nextRule);\n onChange?.(nextRule);\n };\n\n return (\n <section\n {...props}\n className={`eth-workflow-rule-builder ${className ?? \"\"}`}\n data-eth-component=\"RuleBuilder\"\n >\n <FormField label=\"Match\">\n <Select\n value={rule.combinator}\n options={[\n { value: \"all\", label: \"All conditions\" },\n { value: \"any\", label: \"Any condition\" }\n ]}\n onChange={(event) => commit({ ...rule, combinator: event.currentTarget.value as WorkflowRule[\"combinator\"] })}\n />\n </FormField>\n <div className=\"eth-workflow-rule-builder__conditions\">\n {rule.conditions.map((condition, index) => (\n <div key={index} className=\"eth-workflow-rule-builder__condition\">\n <ConditionBuilder\n value={condition}\n variables={variables}\n onChange={(nextCondition) => {\n const conditions = [...rule.conditions];\n conditions[index] = nextCondition;\n commit({ ...rule, conditions });\n }}\n />\n <Button\n intent=\"ghost\"\n density=\"compact\"\n onClick={() => commit({ ...rule, conditions: rule.conditions.filter((_, itemIndex) => itemIndex !== index) })}\n >\n Remove\n </Button>\n </div>\n ))}\n </div>\n <Button\n intent=\"secondary\"\n density=\"compact\"\n onClick={() => commit({ ...rule, conditions: [...rule.conditions, { field: variables[0] ?? \"\", operator: \"equals\", value: \"\" }] })}\n >\n Add condition\n </Button>\n </section>\n );\n}\n","import * as React from \"react\";\nimport { Button } from \"@echothink-ui/core\";\nimport { DataTable, type DataColumn } from \"@echothink-ui/data\";\nimport type { RuleSimulationPanelProps, RuleSimulationSample } from \"./types\";\n\ntype SimulationRow = RuleSimulationSample & {\n actualOutcome?: unknown;\n matched?: boolean;\n};\n\nexport function RuleSimulationPanel({\n rule,\n sampleInputs,\n results = [],\n onRun,\n className,\n ...props\n}: RuleSimulationPanelProps) {\n const resultMap = new Map(results.map((result) => [result.sampleId, result]));\n const rows: SimulationRow[] = sampleInputs.map((sample) => ({\n ...sample,\n actualOutcome: resultMap.get(sample.id)?.actualOutcome,\n matched: resultMap.get(sample.id)?.matched\n }));\n const columns: DataColumn<SimulationRow>[] = [\n { key: \"label\", header: \"Sample\" },\n { key: \"data\", header: \"Input\", render: (row) => <code>{JSON.stringify(row.data)}</code> },\n { key: \"expectedOutcome\", header: \"Expected\", render: (row) => <code>{JSON.stringify(row.expectedOutcome)}</code> },\n { key: \"actualOutcome\", header: \"Actual\", render: (row) => <code>{JSON.stringify(row.actualOutcome)}</code> },\n { key: \"matched\", header: \"Matched\", render: (row) => (row.matched ? \"Yes\" : row.matched === false ? \"No\" : \"Not run\") }\n ];\n\n return (\n <section\n {...props}\n className={`eth-workflow-rule-simulation ${className ?? \"\"}`}\n data-eth-component=\"RuleSimulationPanel\"\n >\n <header>\n <h3>Rule simulation</h3>\n {onRun ? <Button onClick={onRun}>Run</Button> : null}\n </header>\n <pre className=\"eth-workflow-rule-simulation__rule\"><code>{JSON.stringify(rule, null, 2)}</code></pre>\n <DataTable rows={rows} columns={columns} rowKey=\"id\" />\n </section>\n );\n}\n","import * as React from \"react\";\nimport { Button, FormField, Select, StatusDot, Textarea } from \"@echothink-ui/core\";\nimport type { WorkflowHandoffPanelProps } from \"./types\";\n\nexport function WorkflowHandoffPanel({\n item,\n assigneeOptions = [],\n onSubmit,\n className,\n ...props\n}: WorkflowHandoffPanelProps) {\n const [assigneeId, setAssigneeId] = React.useState(assigneeOptions[0]?.id ?? \"\");\n const [reason, setReason] = React.useState(\"\");\n\n return (\n <section\n {...props}\n className={`eth-workflow-handoff-panel ${className ?? \"\"}`}\n data-eth-component=\"WorkflowHandoffPanel\"\n >\n <header>\n <h3>Workflow handoff</h3>\n {item?.status ? <StatusDot status={item.status} label={item.status} /> : null}\n </header>\n {item ? <p>{item.label}</p> : null}\n <form onSubmit={(event) => { event.preventDefault(); onSubmit?.({ assigneeId, reason }); }}>\n <FormField label=\"Assignee\">\n <Select\n value={assigneeId}\n options={assigneeOptions.map((option) => ({ value: option.id, label: option.kind ? `${option.label} (${option.kind})` : option.label }))}\n onChange={(event) => setAssigneeId(event.currentTarget.value)}\n />\n </FormField>\n <FormField label=\"Reason\">\n <Textarea value={reason} rows={4} onChange={(event) => setReason(event.currentTarget.value)} />\n </FormField>\n <Button type=\"submit\" disabled={!assigneeId}>Handoff</Button>\n </form>\n </section>\n );\n}\n","import * as React from \"react\";\nimport { PipelineStage } from \"./PipelineStage\";\nimport type { WorkflowPipelineViewProps } from \"./types\";\n\nexport function WorkflowPipelineView({\n stages,\n activeStageId,\n onSelect,\n className,\n ...props\n}: WorkflowPipelineViewProps) {\n return (\n <section\n {...props}\n className={`eth-workflow-pipeline-view ${className ?? \"\"}`}\n data-eth-component=\"WorkflowPipelineView\"\n aria-label=\"Workflow pipeline\"\n >\n <ol className=\"eth-workflow-pipeline-view__stages\">\n {stages.map((stage, index) => (\n <li key={stage.id}>\n <PipelineStage\n stage={stage}\n active={stage.id === activeStageId}\n onSelect={onSelect}\n aria-posinset={index + 1}\n aria-setsize={stages.length}\n />\n </li>\n ))}\n </ol>\n </section>\n );\n}\n","import \"./styles.css\";\n\nexport type {\n ApprovalWorkflowEditorProps,\n ConditionBuilderProps,\n PipelineStageProps,\n ProcessDesignerProps,\n ProcessEdge,\n ProcessNode,\n ProcessTimelineProps,\n RuleBuilderProps,\n RuleSimulationPanelProps,\n RuleSimulationResult,\n RuleSimulationSample,\n WorkflowHandoffPanelProps,\n WorkflowPipelineViewProps,\n WorkflowRule,\n WorkflowRuleCondition,\n WorkflowStage\n} from \"./components/types\";\nexport { ApprovalWorkflowEditor } from \"./components/ApprovalWorkflowEditor\";\nexport { ConditionBuilder } from \"./components/ConditionBuilder\";\nexport { PipelineStage } from \"./components/PipelineStage\";\nexport { ProcessDesigner } from \"./components/ProcessDesigner\";\nexport { ProcessTimeline } from \"./components/ProcessTimeline\";\nexport { RuleBuilder } from \"./components/RuleBuilder\";\nexport { RuleSimulationPanel } from \"./components/RuleSimulationPanel\";\nexport { WorkflowHandoffPanel } from \"./components/WorkflowHandoffPanel\";\nexport { WorkflowPipelineView } from \"./components/WorkflowPipelineView\";\n\nexport const WorkflowComponentNames = [\n \"WorkflowPipelineView\",\n \"PipelineStage\",\n \"ProcessDesigner\",\n \"RuleBuilder\",\n \"ConditionBuilder\",\n \"RuleSimulationPanel\",\n \"WorkflowHandoffPanel\",\n \"ApprovalWorkflowEditor\",\n \"ProcessTimeline\"\n] as const;\nexport type WorkflowComponentName = (typeof WorkflowComponentNames)[number];\n"],"mappings":";AACA,SAAS,QAAQ,UAAU,iBAAiB;AAiBpC,SACE,KADF;AAdD,SAAS,uBAAuB,EAAE,QAAQ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,SAAA,EAAO,MAAK,UAAS,UAAU,CAAC,YAAY,qBAAO;AAAA,WACtD;AAAA;AAAA;AAAA,EACF;AAEJ;;;ACnBY,gBAAAM,YAAA;AAjBL,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAA8B;AAC5B,SACE,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,WAAW,8BAA8B,aAAa,EAAE;AAAA,MACxD,sBAAmB;AAAA,MACnB,cAAW;AAAA,MAEX,0BAAAA,KAAC,QAAG,WAAU,sCACX,iBAAO,IAAI,CAAC,OAAO,UAClB,gBAAAA,KAAC,QACC,0BAAAA;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA,QAAQ,MAAM,OAAO;AAAA,UACrB;AAAA,UACA,iBAAe,QAAQ;AAAA,UACvB,gBAAc,OAAO;AAAA;AAAA,MACvB,KAPO,MAAM,EAQf,CACD,GACH;AAAA;AAAA,EACF;AAEJ;;;ACHO,IAAM,yBAAyB;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":["TextInput","jsx","jsxs","jsx","jsxs","Button","jsx","jsxs","StatusDot","jsx","jsxs","React","Button","FormField","Select","jsx","jsxs","FormField","Select","Button","Button","jsx","jsxs","React","Button","FormField","Select","StatusDot","jsx","jsxs","jsx"]}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@echothink-ui/workflow",
3
+ "version": "0.1.0",
4
+ "private": false,
5
+ "type": "module",
6
+ "sideEffects": [
7
+ "**/*.css"
8
+ ],
9
+ "main": "./dist/index.cjs",
10
+ "module": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js",
16
+ "require": "./dist/index.cjs"
17
+ },
18
+ "./styles.css": "./src/styles.css"
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "src",
23
+ "README.md"
24
+ ],
25
+ "peerDependencies": {
26
+ "react": ">=18.3.0",
27
+ "react-dom": ">=18.3.0"
28
+ },
29
+ "dependencies": {
30
+ "@echothink-ui/core": "0.2.0",
31
+ "@echothink-ui/task": "0.1.0",
32
+ "@echothink-ui/data": "0.2.0"
33
+ },
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "scripts": {
38
+ "build": "tsup src/index.tsx --format esm,cjs --sourcemap --clean --external react --external react-dom && tsc -p tsconfig.json --declaration --emitDeclarationOnly --noEmit false --outDir dist",
39
+ "typecheck": "tsc -p tsconfig.json --noEmit",
40
+ "test": "vitest run --config ../../vitest.config.ts --passWithNoTests",
41
+ "lint": "eslint src"
42
+ }
43
+ }
@@ -0,0 +1,34 @@
1
+ import * as React from "react";
2
+ import { Button, Checkbox, TextInput } from "@echothink-ui/core";
3
+ import type { ApprovalWorkflowEditorProps } from "./types";
4
+
5
+ export function ApprovalWorkflowEditor({ steps = [], onChange, className, ...props }: ApprovalWorkflowEditorProps) {
6
+ const update = (index: number, next: NonNullable<ApprovalWorkflowEditorProps["steps"]>[number]) => {
7
+ const nextSteps = [...steps];
8
+ nextSteps[index] = next;
9
+ onChange?.(nextSteps);
10
+ };
11
+
12
+ return (
13
+ <section
14
+ {...props}
15
+ className={`eth-workflow-approval-editor ${className ?? ""}`}
16
+ data-eth-component="ApprovalWorkflowEditor"
17
+ >
18
+ {steps.map((step, index) => (
19
+ <div key={step.id} className="eth-workflow-approval-editor__step">
20
+ <TextInput value={step.label} onChange={(event) => update(index, { ...step, label: event.currentTarget.value })} aria-label="Step label" />
21
+ <TextInput value={step.approver ?? ""} onChange={(event) => update(index, { ...step, approver: event.currentTarget.value })} aria-label="Approver" />
22
+ <Checkbox checked={Boolean(step.required)} label="Required" onChange={(event) => update(index, { ...step, required: event.currentTarget.checked })} />
23
+ </div>
24
+ ))}
25
+ <Button
26
+ intent="secondary"
27
+ density="compact"
28
+ onClick={() => onChange?.([...steps, { id: `step-${steps.length + 1}`, label: "Approval step", required: true }])}
29
+ >
30
+ Add approval
31
+ </Button>
32
+ </section>
33
+ );
34
+ }
@@ -0,0 +1,41 @@
1
+ import * as React from "react";
2
+ import { FormField, Select, TextInput } from "@echothink-ui/core";
3
+ import type { ConditionBuilderProps, WorkflowRuleCondition } from "./types";
4
+
5
+ const operators: Array<{ value: WorkflowRuleCondition["operator"]; label: string }> = [
6
+ { value: "equals", label: "Equals" },
7
+ { value: "not-equals", label: "Does not equal" },
8
+ { value: "contains", label: "Contains" },
9
+ { value: "gt", label: "Greater than" },
10
+ { value: "gte", label: "Greater than or equal" },
11
+ { value: "lt", label: "Less than" },
12
+ { value: "lte", label: "Less than or equal" },
13
+ { value: "exists", label: "Exists" }
14
+ ];
15
+
16
+ export function ConditionBuilder({ value, onChange, variables = [], className, ...props }: ConditionBuilderProps) {
17
+ const fieldOptions = variables.length
18
+ ? variables.map((field) => ({ value: field, label: field }))
19
+ : [{ value: value.field, label: value.field || "field" }];
20
+ const update = <K extends keyof WorkflowRuleCondition>(key: K, nextValue: WorkflowRuleCondition[K]) => {
21
+ onChange({ ...value, [key]: nextValue });
22
+ };
23
+
24
+ return (
25
+ <section
26
+ {...props}
27
+ className={`eth-workflow-condition-builder ${className ?? ""}`}
28
+ data-eth-component="ConditionBuilder"
29
+ >
30
+ <FormField label="Field">
31
+ <Select value={value.field} options={fieldOptions} onChange={(event) => update("field", event.currentTarget.value)} />
32
+ </FormField>
33
+ <FormField label="Operator">
34
+ <Select value={value.operator} options={operators} onChange={(event) => update("operator", event.currentTarget.value as WorkflowRuleCondition["operator"])} />
35
+ </FormField>
36
+ <FormField label="Value">
37
+ <TextInput value={value.value ?? ""} onChange={(event) => update("value", event.currentTarget.value)} disabled={value.operator === "exists"} />
38
+ </FormField>
39
+ </section>
40
+ );
41
+ }