diff --git a/src/component/panels/databasePanel/DatabasePanel.tsx b/src/component/panels/databasePanel/DatabasePanel.tsx index e1430dcf8..153d0c4df 100644 --- a/src/component/panels/databasePanel/DatabasePanel.tsx +++ b/src/component/panels/databasePanel/DatabasePanel.tsx @@ -10,7 +10,7 @@ import { import { DatabaseNMREntry, mapRanges } from 'nmr-processing'; import OCL from 'openchemlib/full'; import { useCallback, useState, useRef, memo, useEffect, useMemo } from 'react'; -import { useAccordionContext } from 'react-science/ui'; +import { useAccordionContext, useOnOff } from 'react-science/ui'; import { isSpectrum1D } from '../../../data/data1d/Spectrum1D'; import { getSum } from '../../../data/data1d/Spectrum1D/SumManager'; @@ -25,7 +25,6 @@ import { useChartData } from '../../context/ChartContext'; import { useDispatch } from '../../context/DispatchContext'; import { usePreferences } from '../../context/PreferencesContext'; import { useAlert } from '../../elements/popup/Alert'; -import { positions, transitions, useModal } from '../../elements/popup/Modal'; import { useFormatNumberByNucleus } from '../../hooks/useFormatNumberByNucleus'; import { options } from '../../toolbar/ToolTypes'; import Events from '../../utility/Events'; @@ -37,9 +36,9 @@ import NoTableData from '../extra/placeholder/NoTableData'; import PreferencesHeader from '../header/PreferencesHeader'; import DatabasePreferences from './DatabasePreferences'; +import { DatabaseSearchOptions } from './DatabaseSearchOptions'; import { DatabaseStructureSearchModal } from './DatabaseStructureSearchModal'; import DatabaseTable from './DatabaseTable'; -import { DatabaseSearchOptions } from './DatabaseSearchOptions'; export type Databases = Array; @@ -82,11 +81,15 @@ function DatabasePanelInner({ }: DatabaseInnerProps) { const dispatch = useDispatch(); const alert = useAlert(); - const modal = useModal(); const { item } = useAccordionContext('Databases'); const format = useFormatNumberByNucleus(nucleus); const [isFlipped, setFlipStatus] = useState(false); + const [ + isOpenSearchByStructure, + openSearchByStructure, + closeSearchByStructure, + ] = useOnOff(false); const settingRef = useRef(); const [keywords, setKeywords] = useState(emptyKeywords); @@ -296,24 +299,9 @@ function DatabasePanelInner({ }, [alert, result], ); - const searchByStructureHandler = (idCodeValue: string) => { setIdCode(idCodeValue); }; - const openSearchByStructure = () => { - modal.show( - , - { - position: positions.MIDDLE, - transition: transitions.SCALE, - isBackgroundBlur: false, - }, - ); - }; - return (
{!isFlipped && ( - - setKeywords((prevKeywords) => ({ ...prevKeywords, ...options })) - } - onSettingClick={settingsPanelHandler} - onStructureClick={openSearchByStructure} - onDatabaseChange={handleChangeDatabase} - /> + <> + + setKeywords((prevKeywords) => ({ ...prevKeywords, ...options })) + } + onSettingClick={settingsPanelHandler} + onStructureClick={openSearchByStructure} + onDatabaseChange={handleChangeDatabase} + /> + + )} {isFlipped && ( ['onClick']; @@ -123,10 +125,11 @@ export function DatabaseSearchOptions({ }} /> + } - style={{ inputWrapper: { margin: '0 5px', flex: 1 } }} + style={{ inputWrapper: { flex: 3 } }} className="search-input" type="text" debounceTime={250} @@ -135,6 +138,7 @@ export function DatabaseSearchOptions({ onClear={clearHandler} canClear /> + void; + isOpen: boolean; idCode: string | undefined; onClose?: () => void; } export function DatabaseStructureSearchModal({ onChange, + isOpen, idCode, onClose, }: DatabaseStructureSearchModalProps) { return ( -
-
- Search by structure - -
- -
+ { + onClose?.(); + }} + maxWidth={1000} + > + +
+ Search by structure +
+
+ onChange(idCode)} /> -
-
+ + ); }