nmrium 0.41.0 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/lib/component/1d-2d/components/SpectrumInfoBlock.js +4 -1
  2. package/lib/component/NMRium.js +5 -5
  3. package/lib/component/elements/Input.js +1 -0
  4. package/lib/component/elements/Scroller.d.ts +15 -0
  5. package/lib/component/elements/Scroller.js +31 -0
  6. package/lib/component/hooks/useSaveSettings.js +9 -11
  7. package/lib/component/modal/AboutPredictionModal.js +1 -1
  8. package/lib/component/modal/AboutSpectrumSimulationModal.js +1 -1
  9. package/lib/component/modal/setting/settings-tabs/InfoBlockTabContent.js +9 -2
  10. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +4 -2
  11. package/lib/component/panels/SpectrumsPanel/SpectraPreferences.js +4 -3
  12. package/lib/component/panels/databasePanel/DatabasePanel.js +33 -26
  13. package/lib/component/reducer/Reducer.js +2 -0
  14. package/lib/component/reducer/actions/MoleculeActions.d.ts +6 -2
  15. package/lib/component/reducer/actions/MoleculeActions.js +7 -1
  16. package/lib/component/reducer/preferences/actions/addWorkspace.js +19 -15
  17. package/lib/component/utility/PathBuilder.js +11 -0
  18. package/lib/component/workspaces/workspaceDefaultProperties.js +8 -5
  19. package/lib/data/data1d/database.d.ts +4 -2
  20. package/lib/data/data1d/database.js +10 -3
  21. package/lib/data/molecules/MoleculeManager.d.ts +1 -0
  22. package/lib/data/molecules/MoleculeManager.js +14 -0
  23. package/lib/versionInfo.js +1 -1
  24. package/lib-cjs/component/1d-2d/components/SpectrumInfoBlock.js +4 -1
  25. package/lib-cjs/component/NMRium.js +3 -3
  26. package/lib-cjs/component/elements/Input.js +1 -0
  27. package/lib-cjs/component/elements/Scroller.js +35 -0
  28. package/lib-cjs/component/hooks/useSaveSettings.js +9 -11
  29. package/lib-cjs/component/modal/AboutPredictionModal.js +1 -1
  30. package/lib-cjs/component/modal/AboutSpectrumSimulationModal.js +1 -1
  31. package/lib-cjs/component/modal/setting/settings-tabs/InfoBlockTabContent.js +9 -2
  32. package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +4 -2
  33. package/lib-cjs/component/panels/SpectrumsPanel/SpectraPreferences.js +3 -2
  34. package/lib-cjs/component/panels/databasePanel/DatabasePanel.js +33 -26
  35. package/lib-cjs/component/reducer/Reducer.js +2 -0
  36. package/lib-cjs/component/reducer/actions/MoleculeActions.js +8 -1
  37. package/lib-cjs/component/reducer/preferences/actions/addWorkspace.js +19 -15
  38. package/lib-cjs/component/utility/PathBuilder.js +11 -0
  39. package/lib-cjs/component/workspaces/workspaceDefaultProperties.js +8 -5
  40. package/lib-cjs/data/data1d/database.js +10 -3
  41. package/lib-cjs/data/molecules/MoleculeManager.js +16 -1
  42. package/lib-cjs/versionInfo.js +1 -1
  43. package/package.json +2 -2
@@ -4,6 +4,7 @@ import { useChartData } from '../../context/ChartContext';
4
4
  import { usePreferences } from '../../context/PreferencesContext';
5
5
  import { SVGGroup } from '../../elements/SVGGroup';
6
6
  import useSpectrum from '../../hooks/useSpectrum';
7
+ import { formatNumber } from '../../utility/formatNumber';
7
8
  const styles = {
8
9
  label: {
9
10
  fontSize: '11px',
@@ -29,7 +30,9 @@ function SpectrumInfoBlock() {
29
30
  .filter((field) => field.visible)
30
31
  .map((field, index) => {
31
32
  const value = lodashGet(spectrum, field.jpath, '');
32
- return (_jsxs(SVGGroup, { transform: `translate(0,${20 * (index + 1)})`, space: 5, children: [_jsxs("text", { alignmentBaseline: "middle", style: styles.label, children: [field.label, " :"] }), _jsx("text", { alignmentBaseline: "middle", style: styles.value, children: value })] }, field.jpath + field.label));
33
+ return (_jsxs(SVGGroup, { transform: `translate(0,${20 * (index + 1)})`, space: 5, children: [_jsxs("text", { alignmentBaseline: "middle", style: styles.label, children: [field.label, " :"] }), _jsx("text", { alignmentBaseline: "middle", style: styles.value, children: field?.format && typeof value === 'number'
34
+ ? formatNumber(value, field.format)
35
+ : value })] }, field.jpath + field.label));
33
36
  }) }));
34
37
  }
35
38
  export default SpectrumInfoBlock;
@@ -18,9 +18,9 @@ import { AssignmentProvider } from './assignment';
18
18
  import { ChartDataProvider, useChartData } from './context/ChartContext';
19
19
  import { DispatchProvider } from './context/DispatchContext';
20
20
  import { GlobalProvider } from './context/GlobalContext';
21
- import { LoggerProvider } from './context/LoggerContext';
21
+ import { LoggerProvider, useLogger } from './context/LoggerContext';
22
22
  import { PreferencesProvider } from './context/PreferencesContext';
23
- import { AlertProvider, useAlert } from './elements/popup/Alert';
23
+ import { AlertProvider } from './elements/popup/Alert';
24
24
  import { ModalProvider } from './elements/popup/Modal';
25
25
  import Header from './header/Header';
26
26
  import { HighlightProvider } from './highlight';
@@ -227,11 +227,11 @@ export default memo(NMRium);
227
227
  */
228
228
  function StateError() {
229
229
  const { errorAction } = useChartData();
230
- const { error: alertError } = useAlert();
230
+ const { logger } = useLogger();
231
231
  useEffect(() => {
232
232
  if (!errorAction)
233
233
  return;
234
- alertError(errorAction?.message ?? String(errorAction));
235
- }, [errorAction, alertError]);
234
+ logger.error(errorAction);
235
+ }, [errorAction, logger]);
236
236
  return null;
237
237
  }
@@ -125,6 +125,7 @@ const Input = forwardRef((props, ref) => {
125
125
  onClear?.();
126
126
  }
127
127
  return (_jsxs("div", { style: {
128
+ ...(renderIcon || (canClear && { padding: '0 5px' })),
128
129
  ...styles.inputWrapper,
129
130
  ...style?.inputWrapper,
130
131
  }, className: `input ${className || ''}`, children: [renderIcon?.(), _jsx("input", { ...otherProps, ref: combinedRef, name: name, style: {
@@ -0,0 +1,15 @@
1
+ import { ReactNode } from 'react';
2
+ interface ScrollerProps {
3
+ scrollTo: string;
4
+ children: ReactNode;
5
+ }
6
+ export declare function Scroller(props: ScrollerProps): import("react/jsx-runtime").JSX.Element;
7
+ export declare namespace Scroller {
8
+ var Item: typeof ScrollerElement;
9
+ }
10
+ interface ScrollerElementProps {
11
+ elementKey: string;
12
+ children: ReactNode;
13
+ }
14
+ declare function ScrollerElement(props: ScrollerElementProps): import("react/jsx-runtime").JSX.Element;
15
+ export {};
@@ -0,0 +1,31 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ import { Children, createContext, isValidElement, useContext, useEffect, useRef, } from 'react';
3
+ const ScrollContext = createContext('');
4
+ const ScrollProvider = ScrollContext.Provider;
5
+ function useScrollKey() {
6
+ const context = useContext(ScrollContext);
7
+ if (!context) {
8
+ throw new Error('Scroller context was not found');
9
+ }
10
+ return context;
11
+ }
12
+ export function Scroller(props) {
13
+ const { scrollTo, children } = props;
14
+ const isAllScrollItem = Children.toArray(children).some((child) => isValidElement(child) && child.type === ScrollerElement);
15
+ if (!isAllScrollItem && Children.count(children) > 0) {
16
+ throw new Error("one of the children should be of type <Scroller.Item elementKey='...' > children </Scroller.Item>");
17
+ }
18
+ return _jsxs(ScrollProvider, { value: scrollTo, children: [" ", children, " "] });
19
+ }
20
+ function ScrollerElement(props) {
21
+ const { children, elementKey } = props;
22
+ const scrollToKey = useScrollKey();
23
+ const ref = useRef(null);
24
+ useEffect(() => {
25
+ if (ref.current && elementKey === scrollToKey) {
26
+ ref.current.scrollIntoView({ behavior: 'smooth' });
27
+ }
28
+ }, [elementKey, scrollToKey]);
29
+ return _jsx("div", { ref: ref, children: children });
30
+ }
31
+ Scroller.Item = ScrollerElement;
@@ -27,17 +27,15 @@ export function useSaveSettings() {
27
27
  const { dispatch, current } = usePreferences();
28
28
  const formRef = useRef(null);
29
29
  function addNewWorkspace({ workspaceName }) {
30
- if (settingsRef.current) {
31
- dispatch({
32
- type: 'ADD_WORKSPACE',
33
- payload: {
34
- workspaceKey: workspaceName,
35
- data: settingsRef.current,
36
- },
37
- });
38
- closeDialog();
39
- alert.success('Preferences saved successfully');
40
- }
30
+ dispatch({
31
+ type: 'ADD_WORKSPACE',
32
+ payload: {
33
+ workspaceKey: workspaceName,
34
+ data: settingsRef.current,
35
+ },
36
+ });
37
+ closeDialog();
38
+ alert.success('Preferences saved successfully');
41
39
  }
42
40
  return {
43
41
  saveSettings: (values) => {
@@ -44,6 +44,6 @@ const styles = css `
44
44
  `;
45
45
  function AboutPredictionModal() {
46
46
  const [isOpenDialog, openDialog, closeDialog] = useOnOff(false);
47
- return (_jsxs(_Fragment, { children: [_jsx(Button.BarButton, { onClick: openDialog, tooltipOrientation: "horizontal", toolTip: "About Prediction", children: _jsx(FaInfo, {}) }), _jsx(Modal, { hasCloseButton: true, isOpen: isOpenDialog, onRequestClose: closeDialog, children: _jsxs("div", { css: styles, children: [_jsx(Modal.Header, { children: _jsx("div", { className: "header", children: _jsx("span", { children: "About Prediction" }) }) }), _jsx(Modal.Body, { children: _jsxs("div", { className: "content", children: [_jsx("p", { children: "If you are using our tools please cite us:" }), _jsxs("ul", { children: [_jsxs("li", { children: ["Banfi, D.; Patiny, L.", ' ', _jsx("a", { href: "http://dx.doi.org/10.2533/chimia.2008.280", target: "_blank", rel: "noreferrer", children: "www.nmrdb.org: Resurrecting and processing NMR spectra on-line" }), ' ', "Chimia, 2008, 62(4), 280-281."] }), _jsxs("li", { children: ["Andr\u00E9s M. Castillo, Luc Patiny and Julien Wist.", ' ', _jsx("a", { href: "http://dx.doi.org/10.1016/j.jmr.2010.12.008", target: "_blank", rel: "noreferrer", children: "Fast and Accurate Algorithm for the Simulation of NMR spectra of Large Spin Systems" }), ". Journal of Magnetic Resonance 2011."] })] }), _jsx("p", { children: "1H NMR prediction was possible thanks to the tool of the FCT-Universidade NOVA de Lisboa developed by Yuri Binev and Joao Aires-de-Sousa:" }), _jsxs("ul", { children: [_jsxs("li", { children: ["Y. Binev, M.M. Marques, J. Aires-de-Sousa,", ' ', _jsx("a", { href: "http://dx.doi.org/10.1021/ci700172n", target: "_blank", rel: "noreferrer", children: "Prediction of 1H NMR coupling constants with associative neural networks trained for chemical shifts" }), ' ', "J. Chem. Inf. Model. 2007, 47/(6), 2089-2097."] }), _jsxs("li", { children: ["Aires-de-Sousa, M. Hemmer, J. Gasteiger,", ' ', _jsx("a", { href: "http://dx.doi.org/10.1021/ac010737m", target: "_blank", rel: "noreferrer", children: "\u201C Prediction of 1H NMR Chemical Shifts Using Neural Networks\u201D" }), ", Analytical Chemistry, 2002, 74(1), 80-90."] })] }), _jsx("p", { children: "13 NMR prediction was possible thanks to NMRshiftDB:" }), _jsx("ul", { children: _jsxs("li", { children: ["Steinbeck, Christoph, Stefan Krause, and Stefan Kuhn.", ' ', _jsx("a", { href: "http://dx.doi.org/10.1021/ci0341363", target: "_blank", rel: "noreferrer", children: "NMRShiftDB Constructing a Free Chemical Information System with Open-Source Components." }), ' ', "Journal of chemical information and computer sciences, 2003, 43(6): 1733-1739."] }) })] }) })] }) })] }));
47
+ return (_jsxs(_Fragment, { children: [_jsx(Button.BarButton, { onClick: openDialog, tooltipOrientation: "horizontal", toolTip: "About Prediction", children: _jsx(FaInfo, {}) }), _jsx(Modal, { hasCloseButton: true, isOpen: isOpenDialog, onRequestClose: closeDialog, children: _jsxs("div", { css: styles, children: [_jsx(Modal.Header, { children: _jsx("div", { className: "header", children: _jsx("span", { children: "About Prediction" }) }) }), _jsx(Modal.Body, { children: _jsxs("div", { className: "content", children: [_jsx("p", { children: "If you are using our tools please cite us:" }), _jsxs("ul", { children: [_jsxs("li", { children: ["Damiano Banfi and Luc Patiny", ' ', _jsx("a", { href: "http://dx.doi.org/10.2533/chimia.2008.280", target: "_blank", rel: "noreferrer", children: "www.nmrdb.org: Resurrecting and processing NMR spectra on-line" }), ' ', _jsx("i", { children: "Chimia" }), ", ", _jsx("b", { children: "2008" }), ", 62(4), 280-281."] }), _jsxs("li", { children: ["Andr\u00E9s M. Castillo, Luc Patiny and Julien Wist", ' ', _jsx("a", { href: "http://dx.doi.org/10.1016/j.jmr.2010.12.008", target: "_blank", rel: "noreferrer", children: "Fast and Accurate Algorithm for the Simulation of NMR spectra of Large Spin Systems" }), ' ', _jsx("i", { children: "Journal of Magnetic Resonance" }), " ", _jsx("b", { children: "2011" }), ", 209(2), 123-130."] })] }), _jsxs("p", { children: [_jsx("sup", { children: "1" }), "H NMR prediction is possible thanks to the tool of the FCT-Universidade NOVA de Lisboa developed by Yuri Binev and Joao Aires-de-Sousa:"] }), _jsxs("ul", { children: [_jsxs("li", { children: ["Yuri Binev, Maria M. B. Marques and Jo\u00E3o Aires-de-Sousa", ' ', _jsxs("a", { href: "http://dx.doi.org/10.1021/ci700172n", target: "_blank", rel: "noreferrer", children: ["Prediction of ", _jsx("sup", { children: "1" }), "H NMR coupling constants with associative neural networks trained for chemical shifts"] }), ' ', _jsx("i", { children: "J. Chem. Inf. Model." }), " ", _jsx("b", { children: "2007" }), ", 47(6), 2089-2097."] }), _jsxs("li", { children: ["Jo\u00E3o Aires-de-Sousa, Markus C. Hemmer and Johann Gasteiger", ' ', _jsxs("a", { href: "http://dx.doi.org/10.1021/ac010737m", target: "_blank", rel: "noreferrer", children: ["Prediction of ", _jsx("sup", { children: "1" }), "H NMR Chemical Shifts Using Neural Networks"] }), ", ", _jsx("i", { children: "Analytical Chemistry" }), ", ", _jsx("b", { children: "2002" }), ", 74(1), 80-90."] })] }), _jsxs("p", { children: [_jsx("sup", { children: "13" }), "C NMR prediction was possible thanks to NMRshiftDB:"] }), _jsx("ul", { children: _jsxs("li", { children: ["Steinbeck, Christoph, Stefan Krause, and Stefan Kuhn", ' ', _jsx("a", { href: "http://dx.doi.org/10.1021/ci0341363", target: "_blank", rel: "noreferrer", children: "NMRShiftDB Constructing a Free Chemical Information System with Open-Source Components" }), ' ', _jsx("i", { children: "Journal of chemical information and computer sciences" }), ",", ' ', _jsx("b", { children: "2003" }), ", 43(6): 1733-1739."] }) })] }) })] }) })] }));
48
48
  }
49
49
  export default AboutPredictionModal;
@@ -44,6 +44,6 @@ const styles = css `
44
44
  `;
45
45
  function AboutSpectrumSimulationModal() {
46
46
  const [isOpenDialog, openDialog, closeDialog] = useOnOff(false);
47
- return (_jsxs(_Fragment, { children: [_jsx(Button.BarButton, { onClick: openDialog, tooltipOrientation: "horizontal", toolTip: "About Prediction", children: _jsx(FaInfo, {}) }), _jsx(Modal, { hasCloseButton: true, isOpen: isOpenDialog, onRequestClose: closeDialog, children: _jsxs("div", { css: styles, children: [_jsx(Modal.Header, { children: _jsx("div", { className: "header", children: _jsx("span", { children: "About spectrum simulation" }) }) }), _jsx(Modal.Body, { children: _jsxs("div", { className: "content", children: [_jsx("p", { children: "If you are using our tools please cite us:" }), _jsx("ul", { children: _jsxs("li", { children: ["Fast and Accurate Algorithm for the Simulation of NMR spectra of Large Spin Systems. Andr\u00E9s M. Castillo, Luc Patiny and Julien Wist Journal of Magnetic Resonance 2011.", _jsx("a", { href: "http://dx.doi.org/10.1016/j.jmr.2010.12.008", target: "_blank", rel: "noreferrer", children: "10.1016/j.jmr.2010.12.008" })] }) })] }) })] }) })] }));
47
+ return (_jsxs(_Fragment, { children: [_jsx(Button.BarButton, { onClick: openDialog, tooltipOrientation: "horizontal", toolTip: "About Prediction", children: _jsx(FaInfo, {}) }), _jsx(Modal, { hasCloseButton: true, isOpen: isOpenDialog, onRequestClose: closeDialog, children: _jsxs("div", { css: styles, children: [_jsx(Modal.Header, { children: _jsx("div", { className: "header", children: _jsx("span", { children: "About spectrum simulation" }) }) }), _jsx(Modal.Body, { children: _jsxs("div", { className: "content", children: [_jsx("p", { children: "If you are using our tools please cite us:" }), _jsx("ul", { children: _jsxs("li", { children: ["Andr\u00E9s M. Castillo, Luc Patiny and Julien Wist", ' ', _jsx("a", { href: "http://dx.doi.org/10.1016/j.jmr.2010.12.008", target: "_blank", rel: "noreferrer", children: "Fast and Accurate Algorithm for the Simulation of NMR spectra of Large Spin Systems" }), ' ', _jsx("i", { children: "Journal of Magnetic Resonance" }), " ", _jsx("b", { children: "2011" }), ", 209(2), 123-130."] }) })] }) })] }) })] }));
48
48
  }
49
49
  export default AboutSpectrumSimulationModal;
@@ -64,6 +64,13 @@ function InfoBlockTabContent() {
64
64
  return (_jsx(FormikInput, { name: `infoBlock.fields.${row.index}.jpath`, style: { input: styles.input }, mapOnChangeValue: (key) => paths?.[key] || null, mapValue: (paths) => convertPathArrayToString(paths), datalist: datalist }));
65
65
  },
66
66
  },
67
+ {
68
+ Header: 'Format',
69
+ style: { padding: 0, ...styles.column },
70
+ Cell: ({ row }) => {
71
+ return (_jsx(FormikInput, { name: `infoBlock.fields.${row.index}.format`, style: { input: styles.input } }));
72
+ },
73
+ },
67
74
  {
68
75
  Header: 'Visible',
69
76
  style: { width: '30px', ...styles.column },
@@ -71,11 +78,11 @@ function InfoBlockTabContent() {
71
78
  },
72
79
  {
73
80
  Header: '',
74
- style: { width: '30px', ...styles.column },
81
+ style: { width: '70px', ...styles.column },
75
82
  id: 'add-button',
76
83
  Cell: ({ data, row }) => {
77
84
  const record = row.original;
78
- return (_jsxs("div", { style: { display: 'flex' }, children: [_jsx(Button.Done, { fill: "outline", onClick: () => addHandler(data, row.index + 1), children: _jsx(FaPlus, {}) }), !record?.name && (_jsx(Button.Danger, { fill: "outline", onClick: () => deleteHandler(data, row.index), children: _jsx(FaTimes, {}) }))] }));
85
+ return (_jsxs("div", { style: { display: 'flex', justifyContent: 'space-around' }, children: [_jsx(Button.Done, { fill: "outline", onClick: () => addHandler(data, row.index + 1), children: _jsx(FaPlus, {}) }), !record?.name && (_jsx(Button.Danger, { fill: "outline", onClick: () => deleteHandler(data, row.index), children: _jsx(FaTimes, {}) }))] }));
79
86
  },
80
87
  },
81
88
  ], [addHandler, datalist, deleteHandler, paths]);
@@ -4,6 +4,7 @@ import { useCallback } from 'react';
4
4
  import { FaCog, FaCopy, FaDownload, FaFileExport, FaFileImage, FaPaste, FaPlus, FaRegTrashAlt, } from 'react-icons/fa';
5
5
  import { IoOpenOutline } from 'react-icons/io5';
6
6
  import { DropdownMenu } from 'react-science/ui';
7
+ import { getMolecules } from '../../../data/molecules/MoleculeManager';
7
8
  import { ClipboardFallbackModal } from '../../../utils/clipboard/clipboardComponents';
8
9
  import { useClipboard } from '../../../utils/clipboard/clipboardHooks';
9
10
  import { useAssignmentData } from '../../assignment/AssignmentsContext';
@@ -124,10 +125,11 @@ export default function MoleculePanelHeader({ currentIndex, molecules, molecules
124
125
  function handlePasteMolfileAction() {
125
126
  void readText().then(handlePasteMolfile);
126
127
  }
127
- function handlePasteMolfile(molfile) {
128
+ async function handlePasteMolfile(molfile) {
128
129
  if (!molfile)
129
130
  return;
130
- dispatch({ type: 'ADD_MOLECULE', payload: { molfile } });
131
+ const molecules = await getMolecules(molfile);
132
+ dispatch({ type: 'ADD_MOLECULES', payload: { molecules } });
131
133
  cleanShouldFallback();
132
134
  }
133
135
  const handleDelete = useCallback(() => {
@@ -1,8 +1,9 @@
1
- import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Formik } from 'formik';
3
3
  import { useImperativeHandle, useRef, memo, forwardRef, useCallback, useMemo, } from 'react';
4
4
  import { useChartData } from '../../context/ChartContext';
5
5
  import { usePreferences } from '../../context/PreferencesContext';
6
+ import { Scroller } from '../../elements/Scroller';
6
7
  import useNucleus from '../../hooks/useNucleus';
7
8
  import { usePanelPreferencesByNuclei } from '../../hooks/usePanelPreferences';
8
9
  import { convertPathArrayToString } from '../../utility/convertPathArrayToString';
@@ -12,7 +13,7 @@ import { PreferencesContainer } from '../extra/preferences/PreferencesContainer'
12
13
  import { SpectraColumnsManager } from './base/SpectraColumnsManager';
13
14
  function SpectraPreferences(props, ref) {
14
15
  const formRef = useRef(null);
15
- const { data } = useChartData();
16
+ const { data, view: { spectra: { activeTab }, }, } = useChartData();
16
17
  const preferences = usePreferences();
17
18
  const nuclei = useNucleus();
18
19
  const preferencesByNuclei = usePanelPreferencesByNuclei('spectra', nuclei);
@@ -67,6 +68,6 @@ function SpectraPreferences(props, ref) {
67
68
  }, []);
68
69
  const mapOnChangeValueHandler = useCallback((key) => paths[key], [paths]);
69
70
  const mapValue = useCallback((value) => convertPathArrayToString(value), []);
70
- return (_jsx(PreferencesContainer, { children: _jsx(Formik, { innerRef: formRef, onSubmit: saveHandler, initialValues: preferencesByNuclei, children: _jsx(_Fragment, { children: nuclei?.map((n) => (_jsx(NucleusGroup, { nucleus: n, children: _jsx(SpectraColumnsManager, { nucleus: n, onAdd: handleAdd, onDelete: handleDelete, mapOnChangeValue: mapOnChangeValueHandler, mapValue: mapValue, datalist: datalist }) }, n))) }) }) }));
71
+ return (_jsx(PreferencesContainer, { children: _jsx(Formik, { innerRef: formRef, onSubmit: saveHandler, initialValues: preferencesByNuclei, children: _jsx(Scroller, { scrollTo: activeTab, children: nuclei?.map((n) => (_jsx(Scroller.Item, { elementKey: n, children: _jsx(NucleusGroup, { nucleus: n, children: _jsx(SpectraColumnsManager, { nucleus: n, onAdd: handleAdd, onDelete: handleDelete, mapOnChangeValue: mapOnChangeValueHandler, mapValue: mapValue, datalist: datalist }) }) }, n))) }) }) }));
71
72
  }
72
73
  export default memo(forwardRef(SpectraPreferences));
@@ -40,6 +40,13 @@ const emptyKeywords = {
40
40
  solvent: '-1',
41
41
  searchKeywords: '',
42
42
  };
43
+ function mapKeywordsToArray(searchKeywords, solvent) {
44
+ const values = searchKeywords ? searchKeywords.split(' ') : [];
45
+ if (solvent !== '-1') {
46
+ values.unshift(`solvent:${solvent}`);
47
+ }
48
+ return values;
49
+ }
43
50
  function DatabasePanelInner({ nucleus, selectedTool, databases, defaultDatabase, }) {
44
51
  const dispatch = useDispatch();
45
52
  const alert = useAlert();
@@ -77,28 +84,34 @@ function DatabasePanelInner({ nucleus, selectedTool, databases, defaultDatabase,
77
84
  }));
78
85
  }
79
86
  }, []);
87
+ const search = useCallback((solvents) => {
88
+ const { solvent, searchKeywords } = keywords;
89
+ if (databaseInstance.current) {
90
+ const keywords = mapKeywordsToArray(searchKeywords, solvent);
91
+ const data = databaseInstance.current.search({ keywords, idCode });
92
+ setResult((prevResult) => ({
93
+ ...prevResult,
94
+ data,
95
+ ...(solvents && { solvents }),
96
+ }));
97
+ }
98
+ }, [idCode, keywords]);
80
99
  useEffect(() => {
81
100
  const { solvent, searchKeywords } = keywords;
82
101
  setTimeout(async () => {
83
102
  if (databaseInstance.current) {
84
103
  const hideLoading = await alert.showLoading(`Preparing of the Result`);
85
104
  if (solvent === '-1' && !searchKeywords) {
86
- const data = databaseInstance.current.data;
87
105
  const solvents = mapSolventsToSelect(databaseInstance.current.getSolvents());
88
- setResult((prevResult) => ({ ...prevResult, data, solvents }));
106
+ search(solvents);
89
107
  }
90
108
  else {
91
- const values = searchKeywords.split(' ');
92
- if (solvent !== '-1') {
93
- values.unshift(`solvent:${solvent}`);
94
- }
95
- const data = databaseInstance.current.search(values.join(' '));
96
- setResult((prevResult) => ({ ...prevResult, data }));
109
+ search();
97
110
  }
98
111
  hideLoading();
99
112
  }
100
113
  }, 0);
101
- }, [alert, keywords]);
114
+ }, [alert, idCode, keywords, search]);
102
115
  useEffect(() => {
103
116
  function handle(event) {
104
117
  if (selectedTool === options.databaseRangesSelection.id) {
@@ -120,6 +133,16 @@ function DatabasePanelInner({ nucleus, selectedTool, databases, defaultDatabase,
120
133
  Events.off('brushEnd', handle);
121
134
  };
122
135
  }, [format, selectedTool]);
136
+ useEffect(() => {
137
+ setTimeout(async () => {
138
+ if (databaseInstance.current) {
139
+ const hideLoading = await alert.showLoading(`Loading the database`);
140
+ databaseInstance.current = initiateDatabase(databaseDataRef.current, nucleus);
141
+ hideLoading();
142
+ setKeywords({ ...emptyKeywords });
143
+ }
144
+ }, 0);
145
+ }, [alert, nucleus]);
123
146
  const handleChangeDatabase = useCallback((databaseKey) => {
124
147
  const database = databases.find((item) => item.key === databaseKey);
125
148
  setTimeout(async () => {
@@ -151,16 +174,6 @@ function DatabasePanelInner({ nucleus, selectedTool, databases, defaultDatabase,
151
174
  hideLoading();
152
175
  }, 0);
153
176
  }, [alert, databases, nucleus]);
154
- useEffect(() => {
155
- setTimeout(async () => {
156
- if (databaseInstance.current) {
157
- const hideLoading = await alert.showLoading(`Loading the database`);
158
- databaseInstance.current = initiateDatabase(databaseDataRef.current, nucleus);
159
- hideLoading();
160
- setKeywords({ ...emptyKeywords });
161
- }
162
- }, 0);
163
- }, [alert, nucleus]);
164
177
  useEffect(() => {
165
178
  if (item?.isOpen && defaultDatabase && !databaseInstance.current) {
166
179
  handleChangeDatabase(defaultDatabase);
@@ -231,13 +244,7 @@ function DatabasePanelInner({ nucleus, selectedTool, databases, defaultDatabase,
231
244
  handleChangeOption(tool);
232
245
  }, [handleChangeOption]);
233
246
  const searchByStructureHandler = (idCodeValue) => {
234
- setTimeout(async () => {
235
- const hideLoading = await alert.showLoading(`Searching in progress...`);
236
- const data = databaseInstance.current?.searchByStructure(idCodeValue) || [];
237
- setResult((prevResult) => ({ ...prevResult, data }));
238
- setIdCode(idCodeValue);
239
- hideLoading();
240
- }, 0);
247
+ setIdCode(idCodeValue);
241
248
  };
242
249
  const openSearchByStructure = () => {
243
250
  modal.show(_jsx(DatabaseStructureSearchModal, { onChange: searchByStructureHandler, idCode: idCode }), {
@@ -266,6 +266,8 @@ function innerSpectrumReducer(draft, action) {
266
266
  return ToolsActions.levelChangeHandler(draft, action);
267
267
  case 'ADD_MOLECULE':
268
268
  return MoleculeActions.handleAddMolecule(draft, action);
269
+ case 'ADD_MOLECULES':
270
+ return MoleculeActions.handleAddMolecules(draft, action);
269
271
  case 'SET_MOLECULE':
270
272
  return MoleculeActions.handleSetMolecule(draft, action);
271
273
  case 'CHANGE_MOLECULE_LABEL':
@@ -10,6 +10,9 @@ interface AddMoleculeProps {
10
10
  floatMoleculeOnSave?: boolean;
11
11
  }
12
12
  type AddMoleculeAction = ActionType<'ADD_MOLECULE', AddMoleculeProps>;
13
+ type AddMoleculesAction = ActionType<'ADD_MOLECULES', {
14
+ molecules: StateMolecule[];
15
+ }>;
13
16
  type SetMoleculeAction = ActionType<'SET_MOLECULE', Required<StateMolecule>>;
14
17
  type DeleteMoleculeAction = ActionType<'DELETE_MOLECULE', {
15
18
  id: string;
@@ -33,8 +36,9 @@ type ChangeMoleculeLabelAction = ActionType<'CHANGE_MOLECULE_LABEL', {
33
36
  id: string;
34
37
  label: string;
35
38
  }>;
36
- export type MoleculeActions = AddMoleculeAction | SetMoleculeAction | DeleteMoleculeAction | PredictSpectraFromMoleculeAction | ToggleMoleculeViewObjectAction | ChangeFloatMoleculePositionAction | ChangeMoleculeLabelAction;
39
+ export type MoleculeActions = AddMoleculeAction | AddMoleculesAction | SetMoleculeAction | DeleteMoleculeAction | PredictSpectraFromMoleculeAction | ToggleMoleculeViewObjectAction | ChangeFloatMoleculePositionAction | ChangeMoleculeLabelAction;
37
40
  declare function handleAddMolecule(draft: Draft<State>, action: AddMoleculeAction): void;
41
+ declare function handleAddMolecules(draft: Draft<State>, action: AddMoleculesAction): void;
38
42
  declare function handleSetMolecule(draft: Draft<State>, action: SetMoleculeAction): void;
39
43
  declare function handleDeleteMolecule(draft: Draft<State>, action: DeleteMoleculeAction): void;
40
44
  declare function handlePredictSpectraFromMolecule(draft: Draft<State>, action: PredictSpectraFromMoleculeAction): void;
@@ -42,4 +46,4 @@ declare function handleFloatMoleculeOverSpectrum(draft: Draft<State>, action: To
42
46
  declare function handleToggleMoleculeAtomsNumbers(draft: Draft<State>, action: ToggleMoleculeViewObjectAction): void;
43
47
  declare function handleChangeFloatMoleculePosition(draft: Draft<State>, action: ChangeFloatMoleculePositionAction): void;
44
48
  declare function handleChangeMoleculeLabel(draft: Draft<State>, action: ChangeMoleculeLabelAction): void;
45
- export { handleAddMolecule, handleSetMolecule, handleDeleteMolecule, handlePredictSpectraFromMolecule, handleFloatMoleculeOverSpectrum, handleToggleMoleculeAtomsNumbers, handleChangeFloatMoleculePosition, handleChangeMoleculeLabel, };
49
+ export { handleAddMolecule, handleAddMolecules, handleSetMolecule, handleDeleteMolecule, handlePredictSpectraFromMolecule, handleFloatMoleculeOverSpectrum, handleToggleMoleculeAtomsNumbers, handleChangeFloatMoleculePosition, handleChangeMoleculeLabel, };
@@ -31,6 +31,12 @@ function addMolecule(draft, props) {
31
31
  function handleAddMolecule(draft, action) {
32
32
  addMolecule(draft, action.payload);
33
33
  }
34
+ function handleAddMolecules(draft, action) {
35
+ const molecules = action.payload.molecules;
36
+ for (const { molfile } of molecules) {
37
+ addMolecule(draft, { molfile });
38
+ }
39
+ }
34
40
  function setMolecule(draft, props) {
35
41
  const { id, label, molfile } = props;
36
42
  MoleculeManager.setMolfile(draft.molecules, {
@@ -236,4 +242,4 @@ function handleChangeMoleculeLabel(draft, action) {
236
242
  const moleculeIndex = draft.molecules.findIndex((molecule) => molecule.id === id);
237
243
  draft.molecules[moleculeIndex].label = label;
238
244
  }
239
- export { handleAddMolecule, handleSetMolecule, handleDeleteMolecule, handlePredictSpectraFromMolecule, handleFloatMoleculeOverSpectrum, handleToggleMoleculeAtomsNumbers, handleChangeFloatMoleculePosition, handleChangeMoleculeLabel, };
245
+ export { handleAddMolecule, handleAddMolecules, handleSetMolecule, handleDeleteMolecule, handlePredictSpectraFromMolecule, handleFloatMoleculeOverSpectrum, handleToggleMoleculeAtomsNumbers, handleChangeFloatMoleculePosition, handleChangeMoleculeLabel, };
@@ -4,20 +4,24 @@ import { getLocalStorage, storeData } from '../../../utility/LocalStorage';
4
4
  import { workspaceDefaultProperties } from '../../../workspaces/workspaceDefaultProperties';
5
5
  export function addWorkspace(draft, action) {
6
6
  const { workspaceKey, data } = action.payload;
7
- const newWorkSpace = lodashMerge({}, workspaceDefaultProperties,
8
7
  // eslint-disable-next-line unicorn/prefer-logical-operator-over-ternary
9
- data ? data : draft.workspaces[draft.workspace.current], {
10
- version: 1,
11
- label: workspaceKey,
12
- source: 'user',
13
- });
14
- const newWorkspaceKey = v4();
15
- const localData = getLocalStorage('nmr-general-settings');
16
- localData.currentWorkspace = newWorkspaceKey;
17
- localData.workspaces[newWorkspaceKey] = newWorkSpace;
18
- storeData('nmr-general-settings', JSON.stringify(localData));
19
- draft.workspaces[newWorkspaceKey] = newWorkSpace;
20
- draft.originalWorkspaces[newWorkspaceKey] =
21
- newWorkSpace;
22
- draft.workspace.current = newWorkspaceKey;
8
+ const workSpaceData = data
9
+ ? data
10
+ : draft.workspaces?.[draft.workspace.current];
11
+ if (workSpaceData) {
12
+ const newWorkSpace = lodashMerge({}, workspaceDefaultProperties, workSpaceData, {
13
+ version: 1,
14
+ label: workspaceKey,
15
+ source: 'user',
16
+ });
17
+ const newWorkspaceKey = v4();
18
+ const localData = getLocalStorage('nmr-general-settings');
19
+ localData.currentWorkspace = newWorkspaceKey;
20
+ localData.workspaces[newWorkspaceKey] = newWorkSpace;
21
+ storeData('nmr-general-settings', JSON.stringify(localData));
22
+ draft.workspaces[newWorkspaceKey] = newWorkSpace;
23
+ draft.originalWorkspaces[newWorkspaceKey] =
24
+ newWorkSpace;
25
+ draft.workspace.current = newWorkspaceKey;
26
+ }
23
27
  }
@@ -3,9 +3,13 @@ export class PathBuilder {
3
3
  this.array = [];
4
4
  }
5
5
  moveTo(x, y) {
6
+ x = clamp(x);
7
+ y = clamp(y);
6
8
  this.array.push(`M ${x} ${y}`);
7
9
  }
8
10
  lineTo(x, y) {
11
+ x = clamp(x);
12
+ y = clamp(y);
9
13
  this.array.push(`L ${x} ${y}`);
10
14
  }
11
15
  closePath() {
@@ -16,3 +20,10 @@ export class PathBuilder {
16
20
  return this.array.join(' ');
17
21
  }
18
22
  }
23
+ /**
24
+ * Clamp values to avoid rendering issues of the SVG.
25
+ * This assumes that the viewport has pixel coordinates (so the max values are outside of the visible area)
26
+ */
27
+ function clamp(value) {
28
+ return Math.max(-1e5, Math.min(1e5, value));
29
+ }
@@ -89,21 +89,24 @@ export const workspaceDefaultProperties = {
89
89
  infoBlock: {
90
90
  visible: false,
91
91
  fields: [
92
- { label: 'name', jpath: ['display', 'name'], visible: true },
92
+ { label: 'name', jpath: ['info', 'name'], visible: true, format: '' },
93
93
  {
94
94
  label: 'Number Of Scan',
95
95
  jpath: ['info', 'numberOfScans'],
96
96
  visible: true,
97
+ format: '0',
97
98
  },
98
99
  {
99
- label: 'Acquisition Time',
100
- jpath: ['info', 'acquisitionTime'],
100
+ label: 'Pulse Sequence',
101
+ jpath: ['info', 'pulseSequence'],
101
102
  visible: true,
103
+ format: '',
102
104
  },
103
105
  {
104
- label: 'Pulse Sequence',
105
- jpath: ['info', 'pulseSequence'],
106
+ label: 'Frequency',
107
+ jpath: ['info', 'originFrequency'],
106
108
  visible: true,
109
+ format: '0',
107
110
  },
108
111
  ],
109
112
  },
@@ -33,8 +33,10 @@ export type PrepareDataResult = Partial<DataBaseBasic & DataBaseRange & DataBase
33
33
  export interface InitiateDatabaseResult {
34
34
  data: DatabaseNMREntry[];
35
35
  getSolvents: () => string[];
36
- search: (keywords?: string | string[]) => DatabaseNMREntry[];
37
- searchByStructure: (idCode: string) => DatabaseNMREntry[];
36
+ search: (options: {
37
+ keywords?: string | string[];
38
+ idCode?: string;
39
+ }) => DatabaseNMREntry[];
38
40
  }
39
41
  export declare function initiateDatabase(databases: DatabaseNMREntry[], nucleus: string): InitiateDatabaseResult;
40
42
  export declare function prepareData(data: DatabaseNMREntry[]): PrepareDataResult[];
@@ -14,9 +14,16 @@ export function initiateDatabase(databases, nucleus) {
14
14
  const data = databases.filter((datum) => datum.nucleus === nucleus);
15
15
  const moleculesDB = prepareMoleculesDB(data);
16
16
  const getSolvents = () => prepareGetSolvents(data);
17
- const search = (keywords = []) => filter(data, { keywords });
18
- const searchByStructure = (idCode) => processSearchByStructure(moleculesDB, idCode);
19
- return { searchByStructure, data, getSolvents, search };
17
+ const search = ({ idCode = '', keywords = '', }) => prepareSearch({ idCode, keywords, data, moleculesDB });
18
+ return { data, getSolvents, search };
19
+ }
20
+ function prepareSearch(options) {
21
+ const { data, keywords = [], moleculesDB, idCode } = options;
22
+ let searchData = data;
23
+ if (idCode) {
24
+ searchData = processSearchByStructure(moleculesDB, idCode);
25
+ }
26
+ return filter(searchData, { keywords });
20
27
  }
21
28
  function processSearchByStructure(moleculesDB, idCode) {
22
29
  // default format { format: 'idCode' }
@@ -5,3 +5,4 @@ export declare function setMolfile(molecules: StateMoleculeExtended[], currentMo
5
5
  export declare function extractNumber(value: string): string | null;
6
6
  export declare function extractLabelsNumbers(molecules: Array<Pick<StateMolecule, 'label'>>): number[];
7
7
  export declare function getLabelNumber(reserveNumbers: number[]): number;
8
+ export declare function getMolecules(text: string): Promise<import("nmr-load-save").StateMolecule[]>;
@@ -1,3 +1,5 @@
1
+ import { fileCollectionFromFiles } from 'filelist-utils';
2
+ import { read } from 'nmr-load-save';
1
3
  import { Molecule as OCLMolecule } from 'openchemlib/full';
2
4
  import { initMolecule } from './Molecule';
3
5
  export function fromJSON(mols, reservedMolecules = []) {
@@ -80,3 +82,15 @@ export function getLabelNumber(reserveNumbers) {
80
82
  }
81
83
  return 1;
82
84
  }
85
+ export async function getMolecules(text) {
86
+ let extension = 'smi';
87
+ if (/v[23]000/i.test(text)) {
88
+ extension = 'sdf';
89
+ }
90
+ const file = new File([text], `file.${extension}`, {
91
+ type: 'text/plain',
92
+ });
93
+ const collection = await fileCollectionFromFiles([file]);
94
+ const { nmriumState: { data }, } = await read(collection);
95
+ return data?.molecules || [];
96
+ }
@@ -1 +1 @@
1
- export default { version: 'v0.41.0' };
1
+ export default { version: 'v0.42.0' };
@@ -9,6 +9,7 @@ const ChartContext_1 = require("../../context/ChartContext");
9
9
  const PreferencesContext_1 = require("../../context/PreferencesContext");
10
10
  const SVGGroup_1 = require("../../elements/SVGGroup");
11
11
  const useSpectrum_1 = __importDefault(require("../../hooks/useSpectrum"));
12
+ const formatNumber_1 = require("../../utility/formatNumber");
12
13
  const styles = {
13
14
  label: {
14
15
  fontSize: '11px',
@@ -34,7 +35,9 @@ function SpectrumInfoBlock() {
34
35
  .filter((field) => field.visible)
35
36
  .map((field, index) => {
36
37
  const value = (0, get_1.default)(spectrum, field.jpath, '');
37
- return ((0, jsx_runtime_1.jsxs)(SVGGroup_1.SVGGroup, { transform: `translate(0,${20 * (index + 1)})`, space: 5, children: [(0, jsx_runtime_1.jsxs)("text", { alignmentBaseline: "middle", style: styles.label, children: [field.label, " :"] }), (0, jsx_runtime_1.jsx)("text", { alignmentBaseline: "middle", style: styles.value, children: value })] }, field.jpath + field.label));
38
+ return ((0, jsx_runtime_1.jsxs)(SVGGroup_1.SVGGroup, { transform: `translate(0,${20 * (index + 1)})`, space: 5, children: [(0, jsx_runtime_1.jsxs)("text", { alignmentBaseline: "middle", style: styles.label, children: [field.label, " :"] }), (0, jsx_runtime_1.jsx)("text", { alignmentBaseline: "middle", style: styles.value, children: field?.format && typeof value === 'number'
39
+ ? (0, formatNumber_1.formatNumber)(value, field.format)
40
+ : value })] }, field.jpath + field.label));
38
41
  }) }));
39
42
  }
40
43
  exports.default = SpectrumInfoBlock;
@@ -257,11 +257,11 @@ exports.default = (0, react_2.memo)(NMRium);
257
257
  */
258
258
  function StateError() {
259
259
  const { errorAction } = (0, ChartContext_1.useChartData)();
260
- const { error: alertError } = (0, Alert_1.useAlert)();
260
+ const { logger } = (0, LoggerContext_1.useLogger)();
261
261
  (0, react_2.useEffect)(() => {
262
262
  if (!errorAction)
263
263
  return;
264
- alertError(errorAction?.message ?? String(errorAction));
265
- }, [errorAction, alertError]);
264
+ logger.error(errorAction);
265
+ }, [errorAction, logger]);
266
266
  return null;
267
267
  }
@@ -130,6 +130,7 @@ const Input = (0, react_1.forwardRef)((props, ref) => {
130
130
  onClear?.();
131
131
  }
132
132
  return ((0, jsx_runtime_1.jsxs)("div", { style: {
133
+ ...(renderIcon || (canClear && { padding: '0 5px' })),
133
134
  ...styles.inputWrapper,
134
135
  ...style?.inputWrapper,
135
136
  }, className: `input ${className || ''}`, children: [renderIcon?.(), (0, jsx_runtime_1.jsx)("input", { ...otherProps, ref: combinedRef, name: name, style: {
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Scroller = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const ScrollContext = (0, react_1.createContext)('');
7
+ const ScrollProvider = ScrollContext.Provider;
8
+ function useScrollKey() {
9
+ const context = (0, react_1.useContext)(ScrollContext);
10
+ if (!context) {
11
+ throw new Error('Scroller context was not found');
12
+ }
13
+ return context;
14
+ }
15
+ function Scroller(props) {
16
+ const { scrollTo, children } = props;
17
+ const isAllScrollItem = react_1.Children.toArray(children).some((child) => (0, react_1.isValidElement)(child) && child.type === ScrollerElement);
18
+ if (!isAllScrollItem && react_1.Children.count(children) > 0) {
19
+ throw new Error("one of the children should be of type <Scroller.Item elementKey='...' > children </Scroller.Item>");
20
+ }
21
+ return (0, jsx_runtime_1.jsxs)(ScrollProvider, { value: scrollTo, children: [" ", children, " "] });
22
+ }
23
+ exports.Scroller = Scroller;
24
+ function ScrollerElement(props) {
25
+ const { children, elementKey } = props;
26
+ const scrollToKey = useScrollKey();
27
+ const ref = (0, react_1.useRef)(null);
28
+ (0, react_1.useEffect)(() => {
29
+ if (ref.current && elementKey === scrollToKey) {
30
+ ref.current.scrollIntoView({ behavior: 'smooth' });
31
+ }
32
+ }, [elementKey, scrollToKey]);
33
+ return (0, jsx_runtime_1.jsx)("div", { ref: ref, children: children });
34
+ }
35
+ Scroller.Item = ScrollerElement;
@@ -56,17 +56,15 @@ function useSaveSettings() {
56
56
  const { dispatch, current } = (0, PreferencesContext_1.usePreferences)();
57
57
  const formRef = (0, react_1.useRef)(null);
58
58
  function addNewWorkspace({ workspaceName }) {
59
- if (settingsRef.current) {
60
- dispatch({
61
- type: 'ADD_WORKSPACE',
62
- payload: {
63
- workspaceKey: workspaceName,
64
- data: settingsRef.current,
65
- },
66
- });
67
- closeDialog();
68
- alert.success('Preferences saved successfully');
69
- }
59
+ dispatch({
60
+ type: 'ADD_WORKSPACE',
61
+ payload: {
62
+ workspaceKey: workspaceName,
63
+ data: settingsRef.current,
64
+ },
65
+ });
66
+ closeDialog();
67
+ alert.success('Preferences saved successfully');
70
68
  }
71
69
  return {
72
70
  saveSettings: (values) => {
@@ -49,6 +49,6 @@ const styles = (0, react_1.css) `
49
49
  `;
50
50
  function AboutPredictionModal() {
51
51
  const [isOpenDialog, openDialog, closeDialog] = (0, ui_1.useOnOff)(false);
52
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { onClick: openDialog, tooltipOrientation: "horizontal", toolTip: "About Prediction", children: (0, jsx_runtime_1.jsx)(fa_1.FaInfo, {}) }), (0, jsx_runtime_1.jsx)(ui_1.Modal, { hasCloseButton: true, isOpen: isOpenDialog, onRequestClose: closeDialog, children: (0, jsx_runtime_1.jsxs)("div", { css: styles, children: [(0, jsx_runtime_1.jsx)(ui_1.Modal.Header, { children: (0, jsx_runtime_1.jsx)("div", { className: "header", children: (0, jsx_runtime_1.jsx)("span", { children: "About Prediction" }) }) }), (0, jsx_runtime_1.jsx)(ui_1.Modal.Body, { children: (0, jsx_runtime_1.jsxs)("div", { className: "content", children: [(0, jsx_runtime_1.jsx)("p", { children: "If you are using our tools please cite us:" }), (0, jsx_runtime_1.jsxs)("ul", { children: [(0, jsx_runtime_1.jsxs)("li", { children: ["Banfi, D.; Patiny, L.", ' ', (0, jsx_runtime_1.jsx)("a", { href: "http://dx.doi.org/10.2533/chimia.2008.280", target: "_blank", rel: "noreferrer", children: "www.nmrdb.org: Resurrecting and processing NMR spectra on-line" }), ' ', "Chimia, 2008, 62(4), 280-281."] }), (0, jsx_runtime_1.jsxs)("li", { children: ["Andr\u00E9s M. Castillo, Luc Patiny and Julien Wist.", ' ', (0, jsx_runtime_1.jsx)("a", { href: "http://dx.doi.org/10.1016/j.jmr.2010.12.008", target: "_blank", rel: "noreferrer", children: "Fast and Accurate Algorithm for the Simulation of NMR spectra of Large Spin Systems" }), ". Journal of Magnetic Resonance 2011."] })] }), (0, jsx_runtime_1.jsx)("p", { children: "1H NMR prediction was possible thanks to the tool of the FCT-Universidade NOVA de Lisboa developed by Yuri Binev and Joao Aires-de-Sousa:" }), (0, jsx_runtime_1.jsxs)("ul", { children: [(0, jsx_runtime_1.jsxs)("li", { children: ["Y. Binev, M.M. Marques, J. Aires-de-Sousa,", ' ', (0, jsx_runtime_1.jsx)("a", { href: "http://dx.doi.org/10.1021/ci700172n", target: "_blank", rel: "noreferrer", children: "Prediction of 1H NMR coupling constants with associative neural networks trained for chemical shifts" }), ' ', "J. Chem. Inf. Model. 2007, 47/(6), 2089-2097."] }), (0, jsx_runtime_1.jsxs)("li", { children: ["Aires-de-Sousa, M. Hemmer, J. Gasteiger,", ' ', (0, jsx_runtime_1.jsx)("a", { href: "http://dx.doi.org/10.1021/ac010737m", target: "_blank", rel: "noreferrer", children: "\u201C Prediction of 1H NMR Chemical Shifts Using Neural Networks\u201D" }), ", Analytical Chemistry, 2002, 74(1), 80-90."] })] }), (0, jsx_runtime_1.jsx)("p", { children: "13 NMR prediction was possible thanks to NMRshiftDB:" }), (0, jsx_runtime_1.jsx)("ul", { children: (0, jsx_runtime_1.jsxs)("li", { children: ["Steinbeck, Christoph, Stefan Krause, and Stefan Kuhn.", ' ', (0, jsx_runtime_1.jsx)("a", { href: "http://dx.doi.org/10.1021/ci0341363", target: "_blank", rel: "noreferrer", children: "NMRShiftDB Constructing a Free Chemical Information System with Open-Source Components." }), ' ', "Journal of chemical information and computer sciences, 2003, 43(6): 1733-1739."] }) })] }) })] }) })] }));
52
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { onClick: openDialog, tooltipOrientation: "horizontal", toolTip: "About Prediction", children: (0, jsx_runtime_1.jsx)(fa_1.FaInfo, {}) }), (0, jsx_runtime_1.jsx)(ui_1.Modal, { hasCloseButton: true, isOpen: isOpenDialog, onRequestClose: closeDialog, children: (0, jsx_runtime_1.jsxs)("div", { css: styles, children: [(0, jsx_runtime_1.jsx)(ui_1.Modal.Header, { children: (0, jsx_runtime_1.jsx)("div", { className: "header", children: (0, jsx_runtime_1.jsx)("span", { children: "About Prediction" }) }) }), (0, jsx_runtime_1.jsx)(ui_1.Modal.Body, { children: (0, jsx_runtime_1.jsxs)("div", { className: "content", children: [(0, jsx_runtime_1.jsx)("p", { children: "If you are using our tools please cite us:" }), (0, jsx_runtime_1.jsxs)("ul", { children: [(0, jsx_runtime_1.jsxs)("li", { children: ["Damiano Banfi and Luc Patiny", ' ', (0, jsx_runtime_1.jsx)("a", { href: "http://dx.doi.org/10.2533/chimia.2008.280", target: "_blank", rel: "noreferrer", children: "www.nmrdb.org: Resurrecting and processing NMR spectra on-line" }), ' ', (0, jsx_runtime_1.jsx)("i", { children: "Chimia" }), ", ", (0, jsx_runtime_1.jsx)("b", { children: "2008" }), ", 62(4), 280-281."] }), (0, jsx_runtime_1.jsxs)("li", { children: ["Andr\u00E9s M. Castillo, Luc Patiny and Julien Wist", ' ', (0, jsx_runtime_1.jsx)("a", { href: "http://dx.doi.org/10.1016/j.jmr.2010.12.008", target: "_blank", rel: "noreferrer", children: "Fast and Accurate Algorithm for the Simulation of NMR spectra of Large Spin Systems" }), ' ', (0, jsx_runtime_1.jsx)("i", { children: "Journal of Magnetic Resonance" }), " ", (0, jsx_runtime_1.jsx)("b", { children: "2011" }), ", 209(2), 123-130."] })] }), (0, jsx_runtime_1.jsxs)("p", { children: [(0, jsx_runtime_1.jsx)("sup", { children: "1" }), "H NMR prediction is possible thanks to the tool of the FCT-Universidade NOVA de Lisboa developed by Yuri Binev and Joao Aires-de-Sousa:"] }), (0, jsx_runtime_1.jsxs)("ul", { children: [(0, jsx_runtime_1.jsxs)("li", { children: ["Yuri Binev, Maria M. B. Marques and Jo\u00E3o Aires-de-Sousa", ' ', (0, jsx_runtime_1.jsxs)("a", { href: "http://dx.doi.org/10.1021/ci700172n", target: "_blank", rel: "noreferrer", children: ["Prediction of ", (0, jsx_runtime_1.jsx)("sup", { children: "1" }), "H NMR coupling constants with associative neural networks trained for chemical shifts"] }), ' ', (0, jsx_runtime_1.jsx)("i", { children: "J. Chem. Inf. Model." }), " ", (0, jsx_runtime_1.jsx)("b", { children: "2007" }), ", 47(6), 2089-2097."] }), (0, jsx_runtime_1.jsxs)("li", { children: ["Jo\u00E3o Aires-de-Sousa, Markus C. Hemmer and Johann Gasteiger", ' ', (0, jsx_runtime_1.jsxs)("a", { href: "http://dx.doi.org/10.1021/ac010737m", target: "_blank", rel: "noreferrer", children: ["Prediction of ", (0, jsx_runtime_1.jsx)("sup", { children: "1" }), "H NMR Chemical Shifts Using Neural Networks"] }), ", ", (0, jsx_runtime_1.jsx)("i", { children: "Analytical Chemistry" }), ", ", (0, jsx_runtime_1.jsx)("b", { children: "2002" }), ", 74(1), 80-90."] })] }), (0, jsx_runtime_1.jsxs)("p", { children: [(0, jsx_runtime_1.jsx)("sup", { children: "13" }), "C NMR prediction was possible thanks to NMRshiftDB:"] }), (0, jsx_runtime_1.jsx)("ul", { children: (0, jsx_runtime_1.jsxs)("li", { children: ["Steinbeck, Christoph, Stefan Krause, and Stefan Kuhn", ' ', (0, jsx_runtime_1.jsx)("a", { href: "http://dx.doi.org/10.1021/ci0341363", target: "_blank", rel: "noreferrer", children: "NMRShiftDB Constructing a Free Chemical Information System with Open-Source Components" }), ' ', (0, jsx_runtime_1.jsx)("i", { children: "Journal of chemical information and computer sciences" }), ",", ' ', (0, jsx_runtime_1.jsx)("b", { children: "2003" }), ", 43(6): 1733-1739."] }) })] }) })] }) })] }));
53
53
  }
54
54
  exports.default = AboutPredictionModal;
@@ -49,6 +49,6 @@ const styles = (0, react_1.css) `
49
49
  `;
50
50
  function AboutSpectrumSimulationModal() {
51
51
  const [isOpenDialog, openDialog, closeDialog] = (0, ui_1.useOnOff)(false);
52
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { onClick: openDialog, tooltipOrientation: "horizontal", toolTip: "About Prediction", children: (0, jsx_runtime_1.jsx)(fa_1.FaInfo, {}) }), (0, jsx_runtime_1.jsx)(ui_1.Modal, { hasCloseButton: true, isOpen: isOpenDialog, onRequestClose: closeDialog, children: (0, jsx_runtime_1.jsxs)("div", { css: styles, children: [(0, jsx_runtime_1.jsx)(ui_1.Modal.Header, { children: (0, jsx_runtime_1.jsx)("div", { className: "header", children: (0, jsx_runtime_1.jsx)("span", { children: "About spectrum simulation" }) }) }), (0, jsx_runtime_1.jsx)(ui_1.Modal.Body, { children: (0, jsx_runtime_1.jsxs)("div", { className: "content", children: [(0, jsx_runtime_1.jsx)("p", { children: "If you are using our tools please cite us:" }), (0, jsx_runtime_1.jsx)("ul", { children: (0, jsx_runtime_1.jsxs)("li", { children: ["Fast and Accurate Algorithm for the Simulation of NMR spectra of Large Spin Systems. Andr\u00E9s M. Castillo, Luc Patiny and Julien Wist Journal of Magnetic Resonance 2011.", (0, jsx_runtime_1.jsx)("a", { href: "http://dx.doi.org/10.1016/j.jmr.2010.12.008", target: "_blank", rel: "noreferrer", children: "10.1016/j.jmr.2010.12.008" })] }) })] }) })] }) })] }));
52
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { onClick: openDialog, tooltipOrientation: "horizontal", toolTip: "About Prediction", children: (0, jsx_runtime_1.jsx)(fa_1.FaInfo, {}) }), (0, jsx_runtime_1.jsx)(ui_1.Modal, { hasCloseButton: true, isOpen: isOpenDialog, onRequestClose: closeDialog, children: (0, jsx_runtime_1.jsxs)("div", { css: styles, children: [(0, jsx_runtime_1.jsx)(ui_1.Modal.Header, { children: (0, jsx_runtime_1.jsx)("div", { className: "header", children: (0, jsx_runtime_1.jsx)("span", { children: "About spectrum simulation" }) }) }), (0, jsx_runtime_1.jsx)(ui_1.Modal.Body, { children: (0, jsx_runtime_1.jsxs)("div", { className: "content", children: [(0, jsx_runtime_1.jsx)("p", { children: "If you are using our tools please cite us:" }), (0, jsx_runtime_1.jsx)("ul", { children: (0, jsx_runtime_1.jsxs)("li", { children: ["Andr\u00E9s M. Castillo, Luc Patiny and Julien Wist", ' ', (0, jsx_runtime_1.jsx)("a", { href: "http://dx.doi.org/10.1016/j.jmr.2010.12.008", target: "_blank", rel: "noreferrer", children: "Fast and Accurate Algorithm for the Simulation of NMR spectra of Large Spin Systems" }), ' ', (0, jsx_runtime_1.jsx)("i", { children: "Journal of Magnetic Resonance" }), " ", (0, jsx_runtime_1.jsx)("b", { children: "2011" }), ", 209(2), 123-130."] }) })] }) })] }) })] }));
53
53
  }
54
54
  exports.default = AboutSpectrumSimulationModal;
@@ -69,6 +69,13 @@ function InfoBlockTabContent() {
69
69
  return ((0, jsx_runtime_1.jsx)(FormikInput_1.default, { name: `infoBlock.fields.${row.index}.jpath`, style: { input: styles.input }, mapOnChangeValue: (key) => paths?.[key] || null, mapValue: (paths) => (0, convertPathArrayToString_1.convertPathArrayToString)(paths), datalist: datalist }));
70
70
  },
71
71
  },
72
+ {
73
+ Header: 'Format',
74
+ style: { padding: 0, ...styles.column },
75
+ Cell: ({ row }) => {
76
+ return ((0, jsx_runtime_1.jsx)(FormikInput_1.default, { name: `infoBlock.fields.${row.index}.format`, style: { input: styles.input } }));
77
+ },
78
+ },
72
79
  {
73
80
  Header: 'Visible',
74
81
  style: { width: '30px', ...styles.column },
@@ -76,11 +83,11 @@ function InfoBlockTabContent() {
76
83
  },
77
84
  {
78
85
  Header: '',
79
- style: { width: '30px', ...styles.column },
86
+ style: { width: '70px', ...styles.column },
80
87
  id: 'add-button',
81
88
  Cell: ({ data, row }) => {
82
89
  const record = row.original;
83
- return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex' }, children: [(0, jsx_runtime_1.jsx)(Button_1.default.Done, { fill: "outline", onClick: () => addHandler(data, row.index + 1), children: (0, jsx_runtime_1.jsx)(fa_1.FaPlus, {}) }), !record?.name && ((0, jsx_runtime_1.jsx)(Button_1.default.Danger, { fill: "outline", onClick: () => deleteHandler(data, row.index), children: (0, jsx_runtime_1.jsx)(fa_1.FaTimes, {}) }))] }));
90
+ return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', justifyContent: 'space-around' }, children: [(0, jsx_runtime_1.jsx)(Button_1.default.Done, { fill: "outline", onClick: () => addHandler(data, row.index + 1), children: (0, jsx_runtime_1.jsx)(fa_1.FaPlus, {}) }), !record?.name && ((0, jsx_runtime_1.jsx)(Button_1.default.Danger, { fill: "outline", onClick: () => deleteHandler(data, row.index), children: (0, jsx_runtime_1.jsx)(fa_1.FaTimes, {}) }))] }));
84
91
  },
85
92
  },
86
93
  ], [addHandler, datalist, deleteHandler, paths]);
@@ -9,6 +9,7 @@ const react_1 = require("react");
9
9
  const fa_1 = require("react-icons/fa");
10
10
  const io5_1 = require("react-icons/io5");
11
11
  const ui_1 = require("react-science/ui");
12
+ const MoleculeManager_1 = require("../../../data/molecules/MoleculeManager");
12
13
  const clipboardComponents_1 = require("../../../utils/clipboard/clipboardComponents");
13
14
  const clipboardHooks_1 = require("../../../utils/clipboard/clipboardHooks");
14
15
  const AssignmentsContext_1 = require("../../assignment/AssignmentsContext");
@@ -129,10 +130,11 @@ function MoleculePanelHeader({ currentIndex, molecules, moleculesView, onMolecul
129
130
  function handlePasteMolfileAction() {
130
131
  void readText().then(handlePasteMolfile);
131
132
  }
132
- function handlePasteMolfile(molfile) {
133
+ async function handlePasteMolfile(molfile) {
133
134
  if (!molfile)
134
135
  return;
135
- dispatch({ type: 'ADD_MOLECULE', payload: { molfile } });
136
+ const molecules = await (0, MoleculeManager_1.getMolecules)(molfile);
137
+ dispatch({ type: 'ADD_MOLECULES', payload: { molecules } });
136
138
  cleanShouldFallback();
137
139
  }
138
140
  const handleDelete = (0, react_1.useCallback)(() => {
@@ -8,6 +8,7 @@ const formik_1 = require("formik");
8
8
  const react_1 = require("react");
9
9
  const ChartContext_1 = require("../../context/ChartContext");
10
10
  const PreferencesContext_1 = require("../../context/PreferencesContext");
11
+ const Scroller_1 = require("../../elements/Scroller");
11
12
  const useNucleus_1 = __importDefault(require("../../hooks/useNucleus"));
12
13
  const usePanelPreferences_1 = require("../../hooks/usePanelPreferences");
13
14
  const convertPathArrayToString_1 = require("../../utility/convertPathArrayToString");
@@ -17,7 +18,7 @@ const PreferencesContainer_1 = require("../extra/preferences/PreferencesContaine
17
18
  const SpectraColumnsManager_1 = require("./base/SpectraColumnsManager");
18
19
  function SpectraPreferences(props, ref) {
19
20
  const formRef = (0, react_1.useRef)(null);
20
- const { data } = (0, ChartContext_1.useChartData)();
21
+ const { data, view: { spectra: { activeTab }, }, } = (0, ChartContext_1.useChartData)();
21
22
  const preferences = (0, PreferencesContext_1.usePreferences)();
22
23
  const nuclei = (0, useNucleus_1.default)();
23
24
  const preferencesByNuclei = (0, usePanelPreferences_1.usePanelPreferencesByNuclei)('spectra', nuclei);
@@ -72,6 +73,6 @@ function SpectraPreferences(props, ref) {
72
73
  }, []);
73
74
  const mapOnChangeValueHandler = (0, react_1.useCallback)((key) => paths[key], [paths]);
74
75
  const mapValue = (0, react_1.useCallback)((value) => (0, convertPathArrayToString_1.convertPathArrayToString)(value), []);
75
- return ((0, jsx_runtime_1.jsx)(PreferencesContainer_1.PreferencesContainer, { children: (0, jsx_runtime_1.jsx)(formik_1.Formik, { innerRef: formRef, onSubmit: saveHandler, initialValues: preferencesByNuclei, children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: nuclei?.map((n) => ((0, jsx_runtime_1.jsx)(NucleusGroup_1.NucleusGroup, { nucleus: n, children: (0, jsx_runtime_1.jsx)(SpectraColumnsManager_1.SpectraColumnsManager, { nucleus: n, onAdd: handleAdd, onDelete: handleDelete, mapOnChangeValue: mapOnChangeValueHandler, mapValue: mapValue, datalist: datalist }) }, n))) }) }) }));
76
+ return ((0, jsx_runtime_1.jsx)(PreferencesContainer_1.PreferencesContainer, { children: (0, jsx_runtime_1.jsx)(formik_1.Formik, { innerRef: formRef, onSubmit: saveHandler, initialValues: preferencesByNuclei, children: (0, jsx_runtime_1.jsx)(Scroller_1.Scroller, { scrollTo: activeTab, children: nuclei?.map((n) => ((0, jsx_runtime_1.jsx)(Scroller_1.Scroller.Item, { elementKey: n, children: (0, jsx_runtime_1.jsx)(NucleusGroup_1.NucleusGroup, { nucleus: n, children: (0, jsx_runtime_1.jsx)(SpectraColumnsManager_1.SpectraColumnsManager, { nucleus: n, onAdd: handleAdd, onDelete: handleDelete, mapOnChangeValue: mapOnChangeValueHandler, mapValue: mapValue, datalist: datalist }) }) }, n))) }) }) }));
76
77
  }
77
78
  exports.default = (0, react_1.memo)((0, react_1.forwardRef)(SpectraPreferences));
@@ -45,6 +45,13 @@ const emptyKeywords = {
45
45
  solvent: '-1',
46
46
  searchKeywords: '',
47
47
  };
48
+ function mapKeywordsToArray(searchKeywords, solvent) {
49
+ const values = searchKeywords ? searchKeywords.split(' ') : [];
50
+ if (solvent !== '-1') {
51
+ values.unshift(`solvent:${solvent}`);
52
+ }
53
+ return values;
54
+ }
48
55
  function DatabasePanelInner({ nucleus, selectedTool, databases, defaultDatabase, }) {
49
56
  const dispatch = (0, DispatchContext_1.useDispatch)();
50
57
  const alert = (0, Alert_1.useAlert)();
@@ -82,28 +89,34 @@ function DatabasePanelInner({ nucleus, selectedTool, databases, defaultDatabase,
82
89
  }));
83
90
  }
84
91
  }, []);
92
+ const search = (0, react_2.useCallback)((solvents) => {
93
+ const { solvent, searchKeywords } = keywords;
94
+ if (databaseInstance.current) {
95
+ const keywords = mapKeywordsToArray(searchKeywords, solvent);
96
+ const data = databaseInstance.current.search({ keywords, idCode });
97
+ setResult((prevResult) => ({
98
+ ...prevResult,
99
+ data,
100
+ ...(solvents && { solvents }),
101
+ }));
102
+ }
103
+ }, [idCode, keywords]);
85
104
  (0, react_2.useEffect)(() => {
86
105
  const { solvent, searchKeywords } = keywords;
87
106
  setTimeout(async () => {
88
107
  if (databaseInstance.current) {
89
108
  const hideLoading = await alert.showLoading(`Preparing of the Result`);
90
109
  if (solvent === '-1' && !searchKeywords) {
91
- const data = databaseInstance.current.data;
92
110
  const solvents = mapSolventsToSelect(databaseInstance.current.getSolvents());
93
- setResult((prevResult) => ({ ...prevResult, data, solvents }));
111
+ search(solvents);
94
112
  }
95
113
  else {
96
- const values = searchKeywords.split(' ');
97
- if (solvent !== '-1') {
98
- values.unshift(`solvent:${solvent}`);
99
- }
100
- const data = databaseInstance.current.search(values.join(' '));
101
- setResult((prevResult) => ({ ...prevResult, data }));
114
+ search();
102
115
  }
103
116
  hideLoading();
104
117
  }
105
118
  }, 0);
106
- }, [alert, keywords]);
119
+ }, [alert, idCode, keywords, search]);
107
120
  (0, react_2.useEffect)(() => {
108
121
  function handle(event) {
109
122
  if (selectedTool === ToolTypes_1.options.databaseRangesSelection.id) {
@@ -125,6 +138,16 @@ function DatabasePanelInner({ nucleus, selectedTool, databases, defaultDatabase,
125
138
  Events_1.default.off('brushEnd', handle);
126
139
  };
127
140
  }, [format, selectedTool]);
141
+ (0, react_2.useEffect)(() => {
142
+ setTimeout(async () => {
143
+ if (databaseInstance.current) {
144
+ const hideLoading = await alert.showLoading(`Loading the database`);
145
+ databaseInstance.current = (0, database_1.initiateDatabase)(databaseDataRef.current, nucleus);
146
+ hideLoading();
147
+ setKeywords({ ...emptyKeywords });
148
+ }
149
+ }, 0);
150
+ }, [alert, nucleus]);
128
151
  const handleChangeDatabase = (0, react_2.useCallback)((databaseKey) => {
129
152
  const database = databases.find((item) => item.key === databaseKey);
130
153
  setTimeout(async () => {
@@ -156,16 +179,6 @@ function DatabasePanelInner({ nucleus, selectedTool, databases, defaultDatabase,
156
179
  hideLoading();
157
180
  }, 0);
158
181
  }, [alert, databases, nucleus]);
159
- (0, react_2.useEffect)(() => {
160
- setTimeout(async () => {
161
- if (databaseInstance.current) {
162
- const hideLoading = await alert.showLoading(`Loading the database`);
163
- databaseInstance.current = (0, database_1.initiateDatabase)(databaseDataRef.current, nucleus);
164
- hideLoading();
165
- setKeywords({ ...emptyKeywords });
166
- }
167
- }, 0);
168
- }, [alert, nucleus]);
169
182
  (0, react_2.useEffect)(() => {
170
183
  if (item?.isOpen && defaultDatabase && !databaseInstance.current) {
171
184
  handleChangeDatabase(defaultDatabase);
@@ -236,13 +249,7 @@ function DatabasePanelInner({ nucleus, selectedTool, databases, defaultDatabase,
236
249
  handleChangeOption(tool);
237
250
  }, [handleChangeOption]);
238
251
  const searchByStructureHandler = (idCodeValue) => {
239
- setTimeout(async () => {
240
- const hideLoading = await alert.showLoading(`Searching in progress...`);
241
- const data = databaseInstance.current?.searchByStructure(idCodeValue) || [];
242
- setResult((prevResult) => ({ ...prevResult, data }));
243
- setIdCode(idCodeValue);
244
- hideLoading();
245
- }, 0);
252
+ setIdCode(idCodeValue);
246
253
  };
247
254
  const openSearchByStructure = () => {
248
255
  modal.show((0, jsx_runtime_1.jsx)(DatabaseStructureSearchModal_1.DatabaseStructureSearchModal, { onChange: searchByStructureHandler, idCode: idCode }), {
@@ -295,6 +295,8 @@ function innerSpectrumReducer(draft, action) {
295
295
  return ToolsActions.levelChangeHandler(draft, action);
296
296
  case 'ADD_MOLECULE':
297
297
  return MoleculeActions.handleAddMolecule(draft, action);
298
+ case 'ADD_MOLECULES':
299
+ return MoleculeActions.handleAddMolecules(draft, action);
298
300
  case 'SET_MOLECULE':
299
301
  return MoleculeActions.handleSetMolecule(draft, action);
300
302
  case 'CHANGE_MOLECULE_LABEL':
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.handleChangeMoleculeLabel = exports.handleChangeFloatMoleculePosition = exports.handleToggleMoleculeAtomsNumbers = exports.handleFloatMoleculeOverSpectrum = exports.handlePredictSpectraFromMolecule = exports.handleDeleteMolecule = exports.handleSetMolecule = exports.handleAddMolecule = void 0;
29
+ exports.handleChangeMoleculeLabel = exports.handleChangeFloatMoleculePosition = exports.handleToggleMoleculeAtomsNumbers = exports.handleFloatMoleculeOverSpectrum = exports.handlePredictSpectraFromMolecule = exports.handleDeleteMolecule = exports.handleSetMolecule = exports.handleAddMolecules = exports.handleAddMolecule = void 0;
30
30
  const full_1 = __importDefault(require("openchemlib/full"));
31
31
  const openchemlib_utils_1 = require("openchemlib-utils");
32
32
  const PredictionManager_1 = require("../../../data/PredictionManager");
@@ -61,6 +61,13 @@ function handleAddMolecule(draft, action) {
61
61
  addMolecule(draft, action.payload);
62
62
  }
63
63
  exports.handleAddMolecule = handleAddMolecule;
64
+ function handleAddMolecules(draft, action) {
65
+ const molecules = action.payload.molecules;
66
+ for (const { molfile } of molecules) {
67
+ addMolecule(draft, { molfile });
68
+ }
69
+ }
70
+ exports.handleAddMolecules = handleAddMolecules;
64
71
  function setMolecule(draft, props) {
65
72
  const { id, label, molfile } = props;
66
73
  MoleculeManager.setMolfile(draft.molecules, {
@@ -10,21 +10,25 @@ const LocalStorage_1 = require("../../../utility/LocalStorage");
10
10
  const workspaceDefaultProperties_1 = require("../../../workspaces/workspaceDefaultProperties");
11
11
  function addWorkspace(draft, action) {
12
12
  const { workspaceKey, data } = action.payload;
13
- const newWorkSpace = (0, merge_1.default)({}, workspaceDefaultProperties_1.workspaceDefaultProperties,
14
13
  // eslint-disable-next-line unicorn/prefer-logical-operator-over-ternary
15
- data ? data : draft.workspaces[draft.workspace.current], {
16
- version: 1,
17
- label: workspaceKey,
18
- source: 'user',
19
- });
20
- const newWorkspaceKey = (0, uuid_1.v4)();
21
- const localData = (0, LocalStorage_1.getLocalStorage)('nmr-general-settings');
22
- localData.currentWorkspace = newWorkspaceKey;
23
- localData.workspaces[newWorkspaceKey] = newWorkSpace;
24
- (0, LocalStorage_1.storeData)('nmr-general-settings', JSON.stringify(localData));
25
- draft.workspaces[newWorkspaceKey] = newWorkSpace;
26
- draft.originalWorkspaces[newWorkspaceKey] =
27
- newWorkSpace;
28
- draft.workspace.current = newWorkspaceKey;
14
+ const workSpaceData = data
15
+ ? data
16
+ : draft.workspaces?.[draft.workspace.current];
17
+ if (workSpaceData) {
18
+ const newWorkSpace = (0, merge_1.default)({}, workspaceDefaultProperties_1.workspaceDefaultProperties, workSpaceData, {
19
+ version: 1,
20
+ label: workspaceKey,
21
+ source: 'user',
22
+ });
23
+ const newWorkspaceKey = (0, uuid_1.v4)();
24
+ const localData = (0, LocalStorage_1.getLocalStorage)('nmr-general-settings');
25
+ localData.currentWorkspace = newWorkspaceKey;
26
+ localData.workspaces[newWorkspaceKey] = newWorkSpace;
27
+ (0, LocalStorage_1.storeData)('nmr-general-settings', JSON.stringify(localData));
28
+ draft.workspaces[newWorkspaceKey] = newWorkSpace;
29
+ draft.originalWorkspaces[newWorkspaceKey] =
30
+ newWorkSpace;
31
+ draft.workspace.current = newWorkspaceKey;
32
+ }
29
33
  }
30
34
  exports.addWorkspace = addWorkspace;
@@ -6,9 +6,13 @@ class PathBuilder {
6
6
  this.array = [];
7
7
  }
8
8
  moveTo(x, y) {
9
+ x = clamp(x);
10
+ y = clamp(y);
9
11
  this.array.push(`M ${x} ${y}`);
10
12
  }
11
13
  lineTo(x, y) {
14
+ x = clamp(x);
15
+ y = clamp(y);
12
16
  this.array.push(`L ${x} ${y}`);
13
17
  }
14
18
  closePath() {
@@ -20,3 +24,10 @@ class PathBuilder {
20
24
  }
21
25
  }
22
26
  exports.PathBuilder = PathBuilder;
27
+ /**
28
+ * Clamp values to avoid rendering issues of the SVG.
29
+ * This assumes that the viewport has pixel coordinates (so the max values are outside of the visible area)
30
+ */
31
+ function clamp(value) {
32
+ return Math.max(-1e5, Math.min(1e5, value));
33
+ }
@@ -92,21 +92,24 @@ exports.workspaceDefaultProperties = {
92
92
  infoBlock: {
93
93
  visible: false,
94
94
  fields: [
95
- { label: 'name', jpath: ['display', 'name'], visible: true },
95
+ { label: 'name', jpath: ['info', 'name'], visible: true, format: '' },
96
96
  {
97
97
  label: 'Number Of Scan',
98
98
  jpath: ['info', 'numberOfScans'],
99
99
  visible: true,
100
+ format: '0',
100
101
  },
101
102
  {
102
- label: 'Acquisition Time',
103
- jpath: ['info', 'acquisitionTime'],
103
+ label: 'Pulse Sequence',
104
+ jpath: ['info', 'pulseSequence'],
104
105
  visible: true,
106
+ format: '',
105
107
  },
106
108
  {
107
- label: 'Pulse Sequence',
108
- jpath: ['info', 'pulseSequence'],
109
+ label: 'Frequency',
110
+ jpath: ['info', 'originFrequency'],
109
111
  visible: true,
112
+ format: '0',
110
113
  },
111
114
  ],
112
115
  },
@@ -20,11 +20,18 @@ function initiateDatabase(databases, nucleus) {
20
20
  const data = databases.filter((datum) => datum.nucleus === nucleus);
21
21
  const moleculesDB = prepareMoleculesDB(data);
22
22
  const getSolvents = () => prepareGetSolvents(data);
23
- const search = (keywords = []) => (0, smart_array_filter_1.filter)(data, { keywords });
24
- const searchByStructure = (idCode) => processSearchByStructure(moleculesDB, idCode);
25
- return { searchByStructure, data, getSolvents, search };
23
+ const search = ({ idCode = '', keywords = '', }) => prepareSearch({ idCode, keywords, data, moleculesDB });
24
+ return { data, getSolvents, search };
26
25
  }
27
26
  exports.initiateDatabase = initiateDatabase;
27
+ function prepareSearch(options) {
28
+ const { data, keywords = [], moleculesDB, idCode } = options;
29
+ let searchData = data;
30
+ if (idCode) {
31
+ searchData = processSearchByStructure(moleculesDB, idCode);
32
+ }
33
+ return (0, smart_array_filter_1.filter)(searchData, { keywords });
34
+ }
28
35
  function processSearchByStructure(moleculesDB, idCode) {
29
36
  // default format { format: 'idCode' }
30
37
  // https://github.com/cheminfo/openchemlib-utils/blob/ef3a9c30be7efe225a24de04ea9cefc9299674aa/src/db/MoleculesDB.js#L102-L115
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLabelNumber = exports.extractLabelsNumbers = exports.extractNumber = exports.setMolfile = exports.addMolfile = exports.fromJSON = void 0;
3
+ exports.getMolecules = exports.getLabelNumber = exports.extractLabelsNumbers = exports.extractNumber = exports.setMolfile = exports.addMolfile = exports.fromJSON = void 0;
4
+ const filelist_utils_1 = require("filelist-utils");
5
+ const nmr_load_save_1 = require("nmr-load-save");
4
6
  const full_1 = require("openchemlib/full");
5
7
  const Molecule_1 = require("./Molecule");
6
8
  function fromJSON(mols, reservedMolecules = []) {
@@ -89,3 +91,16 @@ function getLabelNumber(reserveNumbers) {
89
91
  return 1;
90
92
  }
91
93
  exports.getLabelNumber = getLabelNumber;
94
+ async function getMolecules(text) {
95
+ let extension = 'smi';
96
+ if (/v[23]000/i.test(text)) {
97
+ extension = 'sdf';
98
+ }
99
+ const file = new File([text], `file.${extension}`, {
100
+ type: 'text/plain',
101
+ });
102
+ const collection = await (0, filelist_utils_1.fileCollectionFromFiles)([file]);
103
+ const { nmriumState: { data }, } = await (0, nmr_load_save_1.read)(collection);
104
+ return data?.molecules || [];
105
+ }
106
+ exports.getMolecules = getMolecules;
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = { version: 'v0.41.0' };
3
+ exports.default = { version: 'v0.42.0' };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nmrium",
3
3
  "description": "React component to display and process nuclear magnetic resonance (NMR) spectra.",
4
- "version": "0.41.0",
4
+ "version": "0.42.0",
5
5
  "license": "MIT",
6
6
  "main": "lib-cjs/component/NMRium.js",
7
7
  "module": "lib/component/NMRium.js",
@@ -86,7 +86,7 @@
86
86
  "ml-stat": "^1.3.3",
87
87
  "multiplet-analysis": "^2.1.2",
88
88
  "nmr-correlation": "^2.3.3",
89
- "nmr-load-save": "^0.14.1",
89
+ "nmr-load-save": "^0.15.1",
90
90
  "nmr-processing": "^9.7.8",
91
91
  "nmredata": "^0.9.2",
92
92
  "numeral": "^2.0.6",