@tari-project/tari-extension-query-builder 0.0.4
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/LICENSE +29 -0
- package/README.md +1 -0
- package/components.json +21 -0
- package/dist/App.d.ts +3 -0
- package/dist/App.d.ts.map +1 -0
- package/dist/codegen/BuilderCodegen.d.ts +20 -0
- package/dist/codegen/BuilderCodegen.d.ts.map +1 -0
- package/dist/codegen/sample.d.ts +3 -0
- package/dist/codegen/sample.d.ts.map +1 -0
- package/dist/components/query-builder/edges/button-edge.d.ts +3 -0
- package/dist/components/query-builder/edges/button-edge.d.ts.map +1 -0
- package/dist/components/query-builder/input/call-input-checkbox.d.ts +11 -0
- package/dist/components/query-builder/input/call-input-checkbox.d.ts.map +1 -0
- package/dist/components/query-builder/input/call-input-select.d.ts +14 -0
- package/dist/components/query-builder/input/call-input-select.d.ts.map +1 -0
- package/dist/components/query-builder/input/call-input-text.d.ts +18 -0
- package/dist/components/query-builder/input/call-input-text.d.ts.map +1 -0
- package/dist/components/query-builder/input/call-input.d.ts +13 -0
- package/dist/components/query-builder/input/call-input.d.ts.map +1 -0
- package/dist/components/query-builder/nodes/call-node.types.d.ts +4 -0
- package/dist/components/query-builder/nodes/call-node.types.d.ts.map +1 -0
- package/dist/components/query-builder/nodes/constants.d.ts +5 -0
- package/dist/components/query-builder/nodes/constants.d.ts.map +1 -0
- package/dist/components/query-builder/nodes/enter-connection.d.ts +3 -0
- package/dist/components/query-builder/nodes/enter-connection.d.ts.map +1 -0
- package/dist/components/query-builder/nodes/exit-connection.d.ts +3 -0
- package/dist/components/query-builder/nodes/exit-connection.d.ts.map +1 -0
- package/dist/components/query-builder/nodes/generic/generic-node.d.ts +5 -0
- package/dist/components/query-builder/nodes/generic/generic-node.d.ts.map +1 -0
- package/dist/components/query-builder/nodes/generic/node-icon.d.ts +8 -0
- package/dist/components/query-builder/nodes/generic/node-icon.d.ts.map +1 -0
- package/dist/components/query-builder/nodes/generic-node.types.d.ts +6 -0
- package/dist/components/query-builder/nodes/generic-node.types.d.ts.map +1 -0
- package/dist/components/query-builder/nodes/input/constants.d.ts +2 -0
- package/dist/components/query-builder/nodes/input/constants.d.ts.map +1 -0
- package/dist/components/query-builder/nodes/input/editable-label.d.ts +9 -0
- package/dist/components/query-builder/nodes/input/editable-label.d.ts.map +1 -0
- package/dist/components/query-builder/nodes/input/input-params-node.d.ts +5 -0
- package/dist/components/query-builder/nodes/input/input-params-node.d.ts.map +1 -0
- package/dist/components/query-builder/query-builder.d.ts +13 -0
- package/dist/components/query-builder/query-builder.d.ts.map +1 -0
- package/dist/components/ui/alert-dialog.d.ts +15 -0
- package/dist/components/ui/alert-dialog.d.ts.map +1 -0
- package/dist/components/ui/badge.d.ts +10 -0
- package/dist/components/ui/badge.d.ts.map +1 -0
- package/dist/components/ui/button.d.ts +11 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/checkbox.d.ts +5 -0
- package/dist/components/ui/checkbox.d.ts.map +1 -0
- package/dist/components/ui/dropdown-menu.d.ts +26 -0
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/components/ui/input.d.ts +4 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/label.d.ts +5 -0
- package/dist/components/ui/label.d.ts.map +1 -0
- package/dist/components/ui/loading-spinner.d.ts +7 -0
- package/dist/components/ui/loading-spinner.d.ts.map +1 -0
- package/dist/components/ui/popover.d.ts +8 -0
- package/dist/components/ui/popover.d.ts.map +1 -0
- package/dist/components/ui/select.d.ts +16 -0
- package/dist/components/ui/select.d.ts.map +1 -0
- package/dist/components/ui/separator.d.ts +5 -0
- package/dist/components/ui/separator.d.ts.map +1 -0
- package/dist/components/ui/sonner.d.ts +4 -0
- package/dist/components/ui/sonner.d.ts.map +1 -0
- package/dist/components/ui/textarea.d.ts +4 -0
- package/dist/components/ui/textarea.d.ts.map +1 -0
- package/dist/components/ui/tooltip.d.ts +8 -0
- package/dist/components/ui/tooltip.d.ts.map +1 -0
- package/dist/execute/AmbiguousOrderError.d.ts +6 -0
- package/dist/execute/AmbiguousOrderError.d.ts.map +1 -0
- package/dist/execute/CycleDetectedError.d.ts +4 -0
- package/dist/execute/CycleDetectedError.d.ts.map +1 -0
- package/dist/execute/ExecutionPlanner.d.ts +30 -0
- package/dist/execute/ExecutionPlanner.d.ts.map +1 -0
- package/dist/execute/ExecutionPlanner.spec.d.ts +2 -0
- package/dist/execute/ExecutionPlanner.spec.d.ts.map +1 -0
- package/dist/execute/MissingDataError.d.ts +5 -0
- package/dist/execute/MissingDataError.d.ts.map +1 -0
- package/dist/execute/types.d.ts +65 -0
- package/dist/execute/types.d.ts.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/lib/get-next-available.d.ts +2 -0
- package/dist/lib/get-next-available.d.ts.map +1 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/query-builder/tari-type.d.ts +29 -0
- package/dist/query-builder/tari-type.d.ts.map +1 -0
- package/dist/query-builder/template-reader.d.ts +13 -0
- package/dist/query-builder/template-reader.d.ts.map +1 -0
- package/dist/store/persistence/handlers.d.ts +12 -0
- package/dist/store/persistence/handlers.d.ts.map +1 -0
- package/dist/store/persistence/types.d.ts +18 -0
- package/dist/store/persistence/types.d.ts.map +1 -0
- package/dist/store/persistence/v1_0.d.ts +5 -0
- package/dist/store/persistence/v1_0.d.ts.map +1 -0
- package/dist/store/store.d.ts +4 -0
- package/dist/store/store.d.ts.map +1 -0
- package/dist/store/types.d.ts +97 -0
- package/dist/store/types.d.ts.map +1 -0
- package/dist/tari-extension-query-builder.css +1 -0
- package/dist/tari-extension-query-builder.es.js +183368 -0
- package/dist/tari-extension-query-builder.umd.js +620 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -0
- package/eslint.config.js +34 -0
- package/index.html +12 -0
- package/moon.yml +43 -0
- package/package.json +84 -0
- package/src/App.tsx +114 -0
- package/src/assets/react.svg +1 -0
- package/src/codegen/BuilderCodegen.ts +516 -0
- package/src/codegen/sample.ts +58 -0
- package/src/components/query-builder/edges/button-edge.tsx +50 -0
- package/src/components/query-builder/input/call-input-checkbox.tsx +54 -0
- package/src/components/query-builder/input/call-input-select.tsx +87 -0
- package/src/components/query-builder/input/call-input-text.tsx +98 -0
- package/src/components/query-builder/input/call-input.tsx +51 -0
- package/src/components/query-builder/nodes/call-node.types.ts +3 -0
- package/src/components/query-builder/nodes/constants.ts +4 -0
- package/src/components/query-builder/nodes/enter-connection.tsx +16 -0
- package/src/components/query-builder/nodes/exit-connection.tsx +16 -0
- package/src/components/query-builder/nodes/generic/generic-node.tsx +252 -0
- package/src/components/query-builder/nodes/generic/node-icon.tsx +37 -0
- package/src/components/query-builder/nodes/generic-node.types.ts +5 -0
- package/src/components/query-builder/nodes/input/constants.ts +1 -0
- package/src/components/query-builder/nodes/input/editable-label.tsx +142 -0
- package/src/components/query-builder/nodes/input/input-params-node.tsx +190 -0
- package/src/components/query-builder/query-builder.tsx +577 -0
- package/src/components/ui/alert-dialog.tsx +111 -0
- package/src/components/ui/badge.tsx +37 -0
- package/src/components/ui/button.tsx +50 -0
- package/src/components/ui/checkbox.tsx +27 -0
- package/src/components/ui/dropdown-menu.tsx +217 -0
- package/src/components/ui/input.tsx +21 -0
- package/src/components/ui/label.tsx +19 -0
- package/src/components/ui/loading-spinner.tsx +46 -0
- package/src/components/ui/popover.tsx +40 -0
- package/src/components/ui/select.tsx +158 -0
- package/src/components/ui/separator.tsx +26 -0
- package/src/components/ui/sonner.tsx +23 -0
- package/src/components/ui/textarea.tsx +18 -0
- package/src/components/ui/tooltip.tsx +46 -0
- package/src/execute/AmbiguousOrderError.ts +13 -0
- package/src/execute/CycleDetectedError.ts +7 -0
- package/src/execute/ExecutionPlanner.spec.ts +174 -0
- package/src/execute/ExecutionPlanner.ts +445 -0
- package/src/execute/MissingDataError.ts +10 -0
- package/src/execute/types.ts +87 -0
- package/src/index.css +124 -0
- package/src/index.ts +5 -0
- package/src/lib/get-next-available.ts +12 -0
- package/src/lib/utils.ts +6 -0
- package/src/main.tsx +13 -0
- package/src/query-builder/tari-type.ts +185 -0
- package/src/query-builder/template-reader.ts +69 -0
- package/src/root.css +4 -0
- package/src/store/persistence/handlers.ts +16 -0
- package/src/store/persistence/types.ts +14 -0
- package/src/store/persistence/v1_0.ts +35 -0
- package/src/store/store.ts +396 -0
- package/src/store/types.ts +115 -0
- package/src/stories/data/tari-swap-pool.json +317 -0
- package/src/stories/data/wallet-functions.json +580 -0
- package/src/types.ts +7 -0
- package/src/vite-env.d.ts +1 -0
- package/src/xy-theme.css +144 -0
- package/tsconfig.app.json +31 -0
- package/tsconfig.json +15 -0
- package/tsconfig.lib.json +13 -0
- package/tsconfig.node.json +24 -0
- package/vite.config.ts +35 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { Button } from "@/components/ui/button";
|
|
2
|
+
import { Input } from "@/components/ui/input";
|
|
3
|
+
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
|
4
|
+
import { Pencil1Icon, TrashIcon } from "@radix-ui/react-icons";
|
|
5
|
+
import { ChangeEvent, useState, useRef, useEffect } from "react";
|
|
6
|
+
import { cn } from "@/lib/utils";
|
|
7
|
+
|
|
8
|
+
const ICON_WIDTH = 30;
|
|
9
|
+
const SPACE_WIDTH = 8;
|
|
10
|
+
|
|
11
|
+
export interface EditableLabelProps {
|
|
12
|
+
initialLabel: string;
|
|
13
|
+
isValidLabel?: (label: string) => boolean;
|
|
14
|
+
onLabelChange?: (newLabel: string) => void;
|
|
15
|
+
onRemove?: () => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function EditableLabel({ initialLabel, onLabelChange, isValidLabel, onRemove }: EditableLabelProps) {
|
|
19
|
+
const [label, setLabel] = useState(initialLabel);
|
|
20
|
+
const [isHovering, setIsHovering] = useState(false);
|
|
21
|
+
const [open, setOpen] = useState(false);
|
|
22
|
+
const [editInputValue, setEditInputValue] = useState(initialLabel);
|
|
23
|
+
const labelRef = useRef<HTMLSpanElement>(null);
|
|
24
|
+
const [controlsPosition, setControlsPosition] = useState({ top: -35, left: 0 });
|
|
25
|
+
const [isInputValid, setIsInputValid] = useState(isValidLabel ? isValidLabel(initialLabel) : true);
|
|
26
|
+
|
|
27
|
+
const editEnabled = isValidLabel && onLabelChange;
|
|
28
|
+
|
|
29
|
+
const handleInputChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
30
|
+
if (!isValidLabel) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const newValue = event.target.value;
|
|
34
|
+
setEditInputValue(newValue);
|
|
35
|
+
setIsInputValid(isValidLabel(newValue));
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const closeAll = () => {
|
|
39
|
+
setOpen(false);
|
|
40
|
+
setIsHovering(false);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const handleSave = () => {
|
|
44
|
+
if (!isInputValid || !onLabelChange) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
onLabelChange(editInputValue);
|
|
48
|
+
setLabel(editInputValue);
|
|
49
|
+
closeAll();
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const handleRemove = () => {
|
|
53
|
+
if (onRemove) {
|
|
54
|
+
onRemove();
|
|
55
|
+
}
|
|
56
|
+
closeAll();
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const handleOpenChange = (newOpen: boolean) => {
|
|
60
|
+
setOpen(newOpen);
|
|
61
|
+
if (!isValidLabel) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (!newOpen) {
|
|
65
|
+
setEditInputValue(label);
|
|
66
|
+
setIsInputValid(isValidLabel(label));
|
|
67
|
+
closeAll();
|
|
68
|
+
} else {
|
|
69
|
+
setIsInputValid(isValidLabel(editInputValue));
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
|
|
74
|
+
if (event.key === "Enter" && isInputValid) {
|
|
75
|
+
handleSave();
|
|
76
|
+
event.preventDefault();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (labelRef.current && (isHovering || open)) {
|
|
82
|
+
const labelWidth = labelRef.current.offsetWidth;
|
|
83
|
+
const controlsWidth = ICON_WIDTH + (onRemove ? ICON_WIDTH + SPACE_WIDTH : 0);
|
|
84
|
+
const leftPosition = (labelWidth - controlsWidth) / 2;
|
|
85
|
+
setControlsPosition((prev) => ({ ...prev, left: leftPosition }));
|
|
86
|
+
} else {
|
|
87
|
+
setControlsPosition((prev) => ({ ...prev, left: 0 }));
|
|
88
|
+
}
|
|
89
|
+
}, [isHovering, open, label, onRemove]);
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<div
|
|
93
|
+
className="relative inline-block group"
|
|
94
|
+
onMouseEnter={() => {
|
|
95
|
+
setIsHovering(true);
|
|
96
|
+
}}
|
|
97
|
+
onMouseLeave={() => {
|
|
98
|
+
setIsHovering(false);
|
|
99
|
+
}}
|
|
100
|
+
>
|
|
101
|
+
<span ref={labelRef} className="cursor-pointer block">
|
|
102
|
+
{label}
|
|
103
|
+
</span>
|
|
104
|
+
{editEnabled && (isHovering || open) && (
|
|
105
|
+
<div className="absolute flex space-x-2" style={{ top: controlsPosition.top, left: controlsPosition.left }}>
|
|
106
|
+
<Popover open={open} onOpenChange={handleOpenChange}>
|
|
107
|
+
<PopoverTrigger asChild>
|
|
108
|
+
<Button className="nodrag" size="icon" variant="default">
|
|
109
|
+
<Pencil1Icon className="h-4 w-4" />
|
|
110
|
+
</Button>
|
|
111
|
+
</PopoverTrigger>
|
|
112
|
+
<PopoverContent className="w-80 p-4">
|
|
113
|
+
<div className="flex items-center space-x-2">
|
|
114
|
+
<Input
|
|
115
|
+
className={cn(
|
|
116
|
+
"flex-grow nodrag border",
|
|
117
|
+
!isInputValid
|
|
118
|
+
? "border-red-500 focus:border-red-500 focus:ring-red-500 !ring-red-500"
|
|
119
|
+
: "border-gray-400 dark:border-gray-700 focus:border-primary focus:ring-primary",
|
|
120
|
+
)}
|
|
121
|
+
value={editInputValue}
|
|
122
|
+
onChange={handleInputChange}
|
|
123
|
+
onKeyDown={handleKeyDown}
|
|
124
|
+
/>
|
|
125
|
+
<Button className="nodrag" size="sm" onClick={handleSave} disabled={!isInputValid}>
|
|
126
|
+
Update
|
|
127
|
+
</Button>
|
|
128
|
+
</div>
|
|
129
|
+
</PopoverContent>
|
|
130
|
+
</Popover>
|
|
131
|
+
{onRemove && (
|
|
132
|
+
<Button className="nodrag" size="icon" variant="destructive" onClick={handleRemove}>
|
|
133
|
+
<TrashIcon className="h-4 w-4 text-red-500" />
|
|
134
|
+
</Button>
|
|
135
|
+
)}
|
|
136
|
+
</div>
|
|
137
|
+
)}
|
|
138
|
+
</div>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export default EditableLabel;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { Button } from "@/components/ui/button";
|
|
2
|
+
import useStore from "@/store/store";
|
|
3
|
+
import { InputParameterType, NodeType, type InputParamsNode } from "@/store/types";
|
|
4
|
+
import { InputIcon, TrashIcon } from "@radix-ui/react-icons";
|
|
5
|
+
import { Handle, NodeProps, Position, useUpdateNodeInternals } from "@xyflow/react";
|
|
6
|
+
import { NEW_INPUT_PARAM } from "./constants";
|
|
7
|
+
import { ROW_HEIGHT, ROW_HEIGHT_PX, ROW_PADDING } from "../constants";
|
|
8
|
+
import { Separator } from "@/components/ui/separator";
|
|
9
|
+
import { InputControlType, TariType } from "@/query-builder/tari-type";
|
|
10
|
+
import CallInputCheckbox from "../../input/call-input-checkbox";
|
|
11
|
+
import CallInputText from "../../input/call-input-text";
|
|
12
|
+
import EditableLabel from "./editable-label";
|
|
13
|
+
import { useCallback, useEffect } from "react";
|
|
14
|
+
import { SafeParseReturnType } from "zod";
|
|
15
|
+
|
|
16
|
+
const HANDLE_STARTING_OFFSET = 68;
|
|
17
|
+
const FULL_ROW_HEIGHT = ROW_HEIGHT + ROW_PADDING;
|
|
18
|
+
|
|
19
|
+
function InputParamsNode(props: NodeProps<InputParamsNode>) {
|
|
20
|
+
const { id, data } = props;
|
|
21
|
+
const { title, inputs } = data;
|
|
22
|
+
|
|
23
|
+
const updateNodeInternals = useUpdateNodeInternals();
|
|
24
|
+
const removeNode = useStore((store) => store.removeNode);
|
|
25
|
+
const readOnly = useStore((store) => store.readOnly);
|
|
26
|
+
const getNodeById = useStore((store) => store.getNodeById);
|
|
27
|
+
const isValidInputParamsTitle = useStore((store) => store.isValidInputParamsTitle);
|
|
28
|
+
const updateInputParamsTitle = useStore((store) => store.updateInputParamsTitle);
|
|
29
|
+
const updateInputParamsNode = useStore((store) => store.updateInputParamsNode);
|
|
30
|
+
const removeInputParam = useStore((store) => store.removeInputParam);
|
|
31
|
+
const isValidInputParamsName = useStore((store) => store.isValidInputParamsName);
|
|
32
|
+
const updateInputParamsName = useStore((store) => store.updateInputParamsName);
|
|
33
|
+
|
|
34
|
+
const getNewParamOffset = () => {
|
|
35
|
+
const offset = HANDLE_STARTING_OFFSET + FULL_ROW_HEIGHT * inputs.length + 18;
|
|
36
|
+
return `${offset.toString()}px`;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const getInputNodeValue = useCallback(
|
|
40
|
+
(paramId: string) => {
|
|
41
|
+
const node = getNodeById(id);
|
|
42
|
+
if (!node || node.type !== NodeType.InputParamsNode) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
return node.data.values[paramId];
|
|
46
|
+
},
|
|
47
|
+
[id, getNodeById],
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const handleOnChange = (paramId: string, value: SafeParseReturnType<unknown, unknown>) => {
|
|
51
|
+
updateInputParamsNode(id, paramId, value);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const isValidTitle = (label: string) => {
|
|
55
|
+
return isValidInputParamsTitle(id, label);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const handleTitleChange = (newLabel: string) => {
|
|
59
|
+
updateInputParamsTitle(id, newLabel);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const isValidLabel = (input: InputParameterType, label: string) => {
|
|
63
|
+
return isValidInputParamsName(id, input.id, label);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const handleLabelChange = (input: InputParameterType, newLabel: string) => {
|
|
67
|
+
updateInputParamsName(id, input.id, newLabel);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const handleRemove = (input: InputParameterType) => {
|
|
71
|
+
removeInputParam(id, input.id);
|
|
72
|
+
updateNodeInternals(id);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
// TODO: does not seem to help with [React Flow]: Couldn't create edge for source handle id:
|
|
77
|
+
updateNodeInternals(id);
|
|
78
|
+
}, [inputs, id, updateNodeInternals]);
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<div className="min-w-160">
|
|
82
|
+
<div className="absolute top-3 left-3 flex items-center">
|
|
83
|
+
<InputIcon className="h-5 w-5 mr-1" />
|
|
84
|
+
</div>
|
|
85
|
+
<div className="absolute top-1 right-2 nodrag nopan">
|
|
86
|
+
<Button
|
|
87
|
+
variant="ghost"
|
|
88
|
+
size="icon"
|
|
89
|
+
onClick={() => {
|
|
90
|
+
removeNode(id);
|
|
91
|
+
}}
|
|
92
|
+
>
|
|
93
|
+
<TrashIcon className="h-4 w-4" />
|
|
94
|
+
</Button>
|
|
95
|
+
</div>
|
|
96
|
+
|
|
97
|
+
<h3 className="text-center font-bold pt-1 pb-3 border-b">
|
|
98
|
+
<EditableLabel initialLabel={title} onLabelChange={handleTitleChange} isValidLabel={isValidTitle} />
|
|
99
|
+
</h3>
|
|
100
|
+
|
|
101
|
+
{inputs.map((input, idx) => {
|
|
102
|
+
return (
|
|
103
|
+
<Handle
|
|
104
|
+
key={input.id}
|
|
105
|
+
id={input.id}
|
|
106
|
+
type="source"
|
|
107
|
+
position={Position.Right}
|
|
108
|
+
style={{
|
|
109
|
+
border: "2px solid #608bb9",
|
|
110
|
+
top: `${(HANDLE_STARTING_OFFSET + idx * FULL_ROW_HEIGHT).toString()}px`,
|
|
111
|
+
}}
|
|
112
|
+
/>
|
|
113
|
+
);
|
|
114
|
+
})}
|
|
115
|
+
|
|
116
|
+
<form noValidate>
|
|
117
|
+
{inputs.map((input) => {
|
|
118
|
+
const type = new TariType(input.type);
|
|
119
|
+
switch (type.getInputControlType()) {
|
|
120
|
+
case InputControlType.TextBoxInput:
|
|
121
|
+
return (
|
|
122
|
+
<CallInputText
|
|
123
|
+
readOnly={readOnly}
|
|
124
|
+
key={input.id}
|
|
125
|
+
name={input.name}
|
|
126
|
+
placeHolder={type.prompt}
|
|
127
|
+
type={type.inputType}
|
|
128
|
+
min={type.min?.toString()}
|
|
129
|
+
max={type.max?.toString()}
|
|
130
|
+
validate={(data) => type.validate(data)}
|
|
131
|
+
value={getInputNodeValue(input.id)}
|
|
132
|
+
onChange={(value) => {
|
|
133
|
+
handleOnChange(input.id, value);
|
|
134
|
+
}}
|
|
135
|
+
rowHeight={ROW_HEIGHT_PX}
|
|
136
|
+
isValidLabel={(label) => isValidLabel(input, label)}
|
|
137
|
+
onLabelChange={(label) => {
|
|
138
|
+
handleLabelChange(input, label);
|
|
139
|
+
}}
|
|
140
|
+
onRemove={() => {
|
|
141
|
+
handleRemove(input);
|
|
142
|
+
}}
|
|
143
|
+
/>
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
case InputControlType.CheckBoxInput:
|
|
147
|
+
return (
|
|
148
|
+
<CallInputCheckbox
|
|
149
|
+
readOnly={readOnly}
|
|
150
|
+
key={input.id}
|
|
151
|
+
name={input.name}
|
|
152
|
+
value={getInputNodeValue(input.id)}
|
|
153
|
+
onChange={(value) => {
|
|
154
|
+
handleOnChange(input.id, value);
|
|
155
|
+
}}
|
|
156
|
+
rowHeight={ROW_HEIGHT_PX}
|
|
157
|
+
isValidLabel={(label) => isValidLabel(input, label)}
|
|
158
|
+
onLabelChange={(label) => {
|
|
159
|
+
handleLabelChange(input, label);
|
|
160
|
+
}}
|
|
161
|
+
onRemove={() => {
|
|
162
|
+
handleRemove(input);
|
|
163
|
+
}}
|
|
164
|
+
/>
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
})}
|
|
168
|
+
</form>
|
|
169
|
+
|
|
170
|
+
<>
|
|
171
|
+
<Separator className="my-4 h-px w-full bg-gray-300 dark:bg-gray-600" />
|
|
172
|
+
<div className="flex justify-end w-full">
|
|
173
|
+
<span className="italic text-xs pr-2">Drag, to add new parameter</span>
|
|
174
|
+
</div>
|
|
175
|
+
|
|
176
|
+
<Handle
|
|
177
|
+
id={NEW_INPUT_PARAM}
|
|
178
|
+
type="source"
|
|
179
|
+
position={Position.Right}
|
|
180
|
+
style={{
|
|
181
|
+
border: "2px solid #608bb9",
|
|
182
|
+
top: getNewParamOffset(),
|
|
183
|
+
}}
|
|
184
|
+
/>
|
|
185
|
+
</>
|
|
186
|
+
</div>
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export default InputParamsNode;
|