@synergenius/flow-weaver-pack-weaver 0.9.53 → 0.9.54

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.
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+
3
+ // src/ui/approval-card.tsx
4
+ var React = require("react");
5
+ var { useState, useCallback } = React;
6
+ var {
7
+ CollapsibleBlock,
8
+ Flex,
9
+ Typography,
10
+ Badge,
11
+ Tag,
12
+ Button,
13
+ toast
14
+ } = require("@fw/plugin-ui-kit");
15
+ function ApprovalCard({ plan, callTool, onDecision }) {
16
+ const [deciding, setDeciding] = useState(false);
17
+ const [decided, setDecided] = useState(null);
18
+ const handleDecision = useCallback(
19
+ async (approved) => {
20
+ setDeciding(true);
21
+ try {
22
+ await callTool("fw_weaver_approve", { approved });
23
+ setDecided(approved);
24
+ onDecision?.(approved);
25
+ toast(approved ? "Plan approved" : "Plan rejected", {
26
+ type: approved ? "success" : "info"
27
+ });
28
+ } catch (err) {
29
+ toast(err instanceof Error ? err.message : "Failed to send decision", { type: "error" });
30
+ } finally {
31
+ setDeciding(false);
32
+ }
33
+ },
34
+ [callTool, onDecision]
35
+ );
36
+ if (decided !== null) {
37
+ return React.createElement(CollapsibleBlock, {
38
+ status: decided ? "completed" : "error",
39
+ label: React.createElement(Typography, {
40
+ variant: "caption-bold",
41
+ color: decided ? "color-status-positive" : "color-status-negative"
42
+ }, decided ? "Plan Approved" : "Plan Rejected"),
43
+ expanded: false,
44
+ canExpand: false
45
+ });
46
+ }
47
+ return React.createElement(
48
+ CollapsibleBlock,
49
+ {
50
+ status: "pending",
51
+ label: React.createElement(
52
+ Flex,
53
+ { variant: "row-center-start-nowrap-8" },
54
+ React.createElement(Badge, { variant: "warning" }, "Approval Needed"),
55
+ React.createElement(
56
+ Typography,
57
+ { variant: "caption-bold", color: "color-text-high" },
58
+ plan.summary || `${plan.steps.length} step plan`
59
+ )
60
+ ),
61
+ expanded: true,
62
+ canExpand: false
63
+ },
64
+ React.createElement(
65
+ Flex,
66
+ {
67
+ variant: "column-start-start-nowrap-6",
68
+ style: { padding: "10px 12px" }
69
+ },
70
+ ...plan.steps.map(
71
+ (step, i) => React.createElement(
72
+ Flex,
73
+ {
74
+ key: step.id || i,
75
+ variant: "row-center-start-nowrap-6",
76
+ style: { fontSize: "11px" }
77
+ },
78
+ React.createElement(Tag, { size: "small", color: "info" }, step.operation),
79
+ React.createElement(Typography, {
80
+ variant: "smallCaption-regular",
81
+ color: "color-text-medium"
82
+ }, step.description)
83
+ )
84
+ )
85
+ ),
86
+ React.createElement(
87
+ Flex,
88
+ {
89
+ variant: "row-center-start-nowrap-8",
90
+ style: { padding: "10px 12px", borderTop: "1px solid var(--color-border-default)" }
91
+ },
92
+ React.createElement(Button, {
93
+ variant: "fill",
94
+ color: "primary",
95
+ size: "xs",
96
+ onClick: () => handleDecision(true),
97
+ loading: deciding,
98
+ disabled: deciding
99
+ }, "Approve"),
100
+ React.createElement(Button, {
101
+ variant: "outlined",
102
+ color: "danger",
103
+ size: "xs",
104
+ onClick: () => handleDecision(false),
105
+ loading: deciding,
106
+ disabled: deciding
107
+ }, "Reject")
108
+ )
109
+ );
110
+ }
111
+ module.exports = ApprovalCard;