From 78057939dae123f2936f0c7d9769407bf3cfa99c Mon Sep 17 00:00:00 2001 From: Ari Date: Mon, 5 Sep 2022 15:11:59 -0400 Subject: [PATCH] clean up --- .../src/components/Inputs/Base/InputText.tsx | 15 ------- webapp/src/tooltip/context.ts | 41 ------------------- webapp/src/tooltip/index.tsx | 40 ------------------ 3 files changed, 96 deletions(-) delete mode 100644 webapp/src/tooltip/context.ts delete mode 100644 webapp/src/tooltip/index.tsx diff --git a/webapp/src/components/Inputs/Base/InputText.tsx b/webapp/src/components/Inputs/Base/InputText.tsx index 87d9318..178b9d5 100644 --- a/webapp/src/components/Inputs/Base/InputText.tsx +++ b/webapp/src/components/Inputs/Base/InputText.tsx @@ -1,5 +1,4 @@ import React, { ReactNode, useState } from "react"; -import { useToolTip } from "tooltip/context"; import TextField from "@mui/material/TextField"; export interface Props { @@ -22,19 +21,16 @@ export default function InputText({ label, title, helperText, - textBoxFor, value = "", onChange, endAdornment, onEnter = () => {}, - additionalTooltipFilters = {}, multiline = false, maxRows = 4, className, placeholder, required, }: Props) { - const tooltip = useToolTip(); const [isFocused, setIsFocused] = useState(false); return ( { setIsFocused(true); - if (textBoxFor) { - tooltip.setFocus( - e.target.getBoundingClientRect(), - { - searchObject: textBoxFor, - searchText: value, - filterObjects: additionalTooltipFilters, - }, - onChange - ); - } }} /> ); diff --git a/webapp/src/tooltip/context.ts b/webapp/src/tooltip/context.ts deleted file mode 100644 index e1c41d2..0000000 --- a/webapp/src/tooltip/context.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { createContext, useContext } from "react" - -export interface TooltipSearchOption { - searchObject: string; - searchText: string; - filterObjects: Record; -} -export interface TooltipState { - domrect?: DOMRect; - searchOptions?: TooltipSearchOption; - onSelected?: (s: string) => void; - searchResults: string[]; - updateState: (s: TooltipState) => void; -} -export const TooltipContext = createContext({ - 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 - }) - }, - } -}; \ No newline at end of file diff --git a/webapp/src/tooltip/index.tsx b/webapp/src/tooltip/index.tsx deleted file mode 100644 index 4ad983e..0000000 --- a/webapp/src/tooltip/index.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import { TooltipState } from "./context"; - -export default function Tooltip({ - domrect, - searchOptions, - searchResults=[], - onSelected=()=>{}, - updateState, -}: TooltipState) { - - // state alias - const rootClassName = !!domrect && !!searchOptions ? "tooltip show" : "tooltip hide"; - let tooltipStyle = {}; - if (domrect) { - const {left=0, top=0, height=0, width=0} = domrect; - tooltipStyle = { - top: `${top + height}px`, - left: `${left}px`, - width: `${width}px`, - } - } - const unFocus = () => updateState({ - updateState, - onSelected, - searchResults: [], - }); - - return
-
unFocus()}>
-
    - {searchResults.map((r, i) =>
  • { - onSelected(r); - unFocus(); - }}> - {r} -
  • )} - {searchResults.length === 0 ?
  • unFocus()}>No Options...
  • : ""} -
-
-} \ No newline at end of file