({
inputAnchor,
inputParam,
data,
disabled = false,
isAdditionalParams = false,
disablePadding = false,
onDataChange,
itemParameters,
AsyncInputComponent,
ConfigInputComponent,
onConfigChange,
arrayIndex = null,
parentArrayParam = null,
variableItems
}: NodeInputHandlerProps)
| 101 | * Handles basic input types: string, number, password, boolean, options, array, single-select, multi-select. |
| 102 | */ |
| 103 | export function NodeInputHandler({ |
| 104 | inputAnchor, |
| 105 | inputParam, |
| 106 | data, |
| 107 | disabled = false, |
| 108 | isAdditionalParams = false, |
| 109 | disablePadding = false, |
| 110 | onDataChange, |
| 111 | itemParameters, |
| 112 | AsyncInputComponent, |
| 113 | ConfigInputComponent, |
| 114 | onConfigChange, |
| 115 | arrayIndex = null, |
| 116 | parentArrayParam = null, |
| 117 | variableItems |
| 118 | }: NodeInputHandlerProps) { |
| 119 | const theme = useTheme() |
| 120 | const ref = useRef<HTMLDivElement>(null) |
| 121 | const updateNodeInternals = useUpdateNodeInternals() |
| 122 | |
| 123 | const [position, setPosition] = useState(0) |
| 124 | const [expandOpen, setExpandOpen] = useState(false) |
| 125 | const [variableAnchorEl, setVariableAnchorEl] = useState<HTMLElement | null>(null) |
| 126 | const [jsonDialogOpen, setJsonDialogOpen] = useState(false) |
| 127 | |
| 128 | const handleDataChange = useCallback( |
| 129 | (newValue: unknown) => { |
| 130 | if (inputParam) { |
| 131 | onDataChange?.({ inputParam, newValue }) |
| 132 | } |
| 133 | }, |
| 134 | [inputParam, onDataChange] |
| 135 | ) |
| 136 | |
| 137 | useEffect(() => { |
| 138 | if (ref.current && ref.current.offsetTop && ref.current.clientHeight) { |
| 139 | setPosition(ref.current.offsetTop + ref.current.clientHeight / 2) |
| 140 | updateNodeInternals(data.id) |
| 141 | } |
| 142 | }, [data.id, ref, updateNodeInternals]) |
| 143 | |
| 144 | useEffect(() => { |
| 145 | updateNodeInternals(data.id) |
| 146 | }, [data.id, position, updateNodeInternals]) |
| 147 | |
| 148 | const isExpandable = useMemo( |
| 149 | () => (inputParam?.type === 'string' && !!inputParam?.rows) || inputParam?.type === 'code', |
| 150 | [inputParam?.type, inputParam?.rows] |
| 151 | ) |
| 152 | |
| 153 | const expandValue = useMemo(() => { |
| 154 | if (!inputParam) return '' |
| 155 | const v = data.inputs?.[inputParam.name] ?? inputParam.default ?? '' |
| 156 | return typeof v === 'string' ? v : JSON.stringify(v) |
| 157 | }, [data.inputs, inputParam]) |
| 158 | |
| 159 | const handleExpandConfirm = useCallback( |
| 160 | (value: string) => { |
nothing calls this directly
no test coverage detected