diff --git a/src/CallBlock.tsx b/src/CallBlock.tsx index 5ddd789..f032d22 100644 --- a/src/CallBlock.tsx +++ b/src/CallBlock.tsx @@ -22,9 +22,10 @@ interface CallBlockProps< FnState=EditorState, InputState=EditorState, > extends State2Props,EditorState> { + filter: (suggestion: SuggestionType) => boolean; } -function headlessCallBlock({setState}: CallBlockProps) { +function headlessCallBlock(setState: (callback: SetStateFn) => void) { const setFn = (callback: SetStateFn) => { setState(state => ({...state, fn: callback(state.fn)})); } @@ -40,9 +41,9 @@ function headlessCallBlock({setState}: CallBlockProps) { return {setFn, setInput, onFnCancel, onInputCancel}; } -export function CallBlock({ state, setState }: CallBlockProps) { +export function CallBlock({ state, setState, filter }: CallBlockProps) { const {setFn, setInput, onFnCancel, onInputCancel} - = headlessCallBlock({ state, setState }); + = headlessCallBlock(setState); const env = useContext(EnvContext); const resolved = evalEditorBlock(state, env); return @@ -84,7 +85,7 @@ function FunctionHeader({ fn, setFn, input, onFnCancel }) { const { setFn : setFnFn, onFnCancel : onFnFnCancel, - } = headlessCallBlock({state: fn, setState: setFn}); + } = headlessCallBlock(setFn); return EditorState)=>void} + filter={filter} />; case "let": return