moved back the components
This commit is contained in:
1 parent
24afb602cb
commit
0764feb432
18 files changed
+786
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import { createContext, useContext } from "react"
|
||||
|
||||
export interface TooltipSearchOption {
|
||||
searchObject: string;
|
||||
searchText: string;
|
||||
filterObjects: Record<string, string>;
|
||||
}
|
||||
export interface TooltipState {
|
||||
domrect?: DOMRect;
|
||||
searchOptions?: TooltipSearchOption;
|
||||
onSelected?: (s: string) => void;
|
||||
searchResults: string[];
|
||||
updateState: (s: TooltipState) => void;
|
||||
}
|
||||
export const TooltipContext = createContext<TooltipState>({
|
||||
updateState(s) {},
|
||||
searchResults: [],
|
||||
})
|
||||
|
||||
export const useToolTip = () => {
|
||||
const state = useContext(TooltipContext);
|
||||
|
||||
return {
|
||||
setFocus(
|
||||
domrect: DOMRect,
|
||||
searchOptions: TooltipSearchOption,
|
||||
onSelected: (s: string) => void
|
||||
){
|
||||
state.updateState({
|
||||
...state,
|
||||
domrect, searchOptions, onSelected
|
||||
})
|
||||
},
|
||||
setSearchResults(searchResults: string[]){
|
||||
state.updateState({
|
||||
...state,
|
||||
searchResults
|
||||
})
|
||||
},
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user