nmrium 0.47.0 → 0.49.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 (88) hide show
  1. package/lib/component/1d/Chart1D.js +1 -1
  2. package/lib/component/1d/Line.js +1 -1
  3. package/lib/component/1d/LinesSeries.d.ts +1 -1
  4. package/lib/component/1d/LinesSeries.js +24 -3
  5. package/lib/component/1d/SpectraLegends.js +1 -1
  6. package/lib/component/1d/Viewer1D.js +144 -124
  7. package/lib/component/1d/jCouplingGraph/JsCoupling.js +1 -1
  8. package/lib/component/1d/peaks/Peaks.js +5 -4
  9. package/lib/component/1d/ranges/Atoms.d.ts +7 -0
  10. package/lib/component/1d/ranges/Atoms.js +43 -0
  11. package/lib/component/1d/ranges/Range.js +4 -2
  12. package/lib/component/1d/tool/BaseLine.d.ts +2 -0
  13. package/lib/component/1d/tool/BaseLine.js +26 -0
  14. package/lib/component/1d/tool/BaseLineZones.js +18 -3
  15. package/lib/component/1d/utilities/scale.d.ts +1 -0
  16. package/lib/component/1d/utilities/scale.js +2 -1
  17. package/lib/component/2d/Chart2D.js +6 -4
  18. package/lib/component/2d/Viewer2D.js +35 -26
  19. package/lib/component/context/KeyModifierContext.d.ts +14 -3
  20. package/lib/component/context/KeyModifierContext.js +35 -4
  21. package/lib/component/context/LoggerContext.d.ts +9 -0
  22. package/lib/component/context/LoggerContext.js +21 -7
  23. package/lib/component/context/PreferencesContext.d.ts +1 -108
  24. package/lib/component/context/TopicMoleculeContext.d.ts +8 -0
  25. package/lib/component/context/TopicMoleculeContext.js +30 -0
  26. package/lib/component/elements/Input.js +4 -1
  27. package/lib/component/elements/ResizerWithScale.js +19 -2
  28. package/lib/component/elements/SVGGroup.js +2 -2
  29. package/lib/component/elements/formik/FormikTextarea.js +8 -9
  30. package/lib/component/elements/linearAxis/LinearVerticalAxis.js +1 -1
  31. package/lib/component/elements/resizer/SVGResizer.js +1 -1
  32. package/lib/component/header/BaseLineCorrectionPanel.js +3 -2
  33. package/lib/component/header/Header.js +2 -2
  34. package/lib/component/hooks/useCheckToolsVisibility.js +1 -1
  35. package/lib/component/hooks/useExport.js +2 -2
  36. package/lib/component/hooks/useSetActiveSpectrumAction.d.ts +3 -0
  37. package/lib/component/hooks/useSetActiveSpectrumAction.js +16 -0
  38. package/lib/component/hooks/useToolsFunctions.js +4 -2
  39. package/lib/component/hooks/useVerticalAlign.d.ts +1 -1
  40. package/lib/component/main/InnerNMRium.js +3 -2
  41. package/lib/component/modal/ExportAsJcampModal.js +1 -1
  42. package/lib/component/modal/ImportPublicationStringModal.d.ts +2 -1
  43. package/lib/component/modal/ImportPublicationStringModal.js +76 -32
  44. package/lib/component/modal/editRange/forms/validation/EditRangeValidation.js +2 -4
  45. package/lib/component/modal/setting/settings-tabs/GeneralTabContent.js +9 -11
  46. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +2 -1
  47. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts +2 -1
  48. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +6 -5
  49. package/lib/component/panels/RangesPanel/RangesTable.js +1 -1
  50. package/lib/component/panels/SpectrumsPanel/SpectraPreferences.js +39 -5
  51. package/lib/component/panels/SpectrumsPanel/SpectraTable.js +28 -40
  52. package/lib/component/panels/SpectrumsPanel/SpectrumListPanel.js +4 -2
  53. package/lib/component/panels/SpectrumsPanel/SpectrumsTabs.js +3 -9
  54. package/lib/component/panels/SpectrumsPanel/base/RenderAsHTML.d.ts +7 -0
  55. package/lib/component/panels/SpectrumsPanel/base/RenderAsHTML.js +21 -0
  56. package/lib/component/panels/SpectrumsPanel/base/SpectraColumnsManager.js +19 -16
  57. package/lib/component/panels/SpectrumsPanel/base/SpectrumName.js +0 -1
  58. package/lib/component/panels/databasePanel/DatabasePanel.js +6 -1
  59. package/lib/component/panels/multipleAnalysisPanel/AnalysisChart.js +1 -1
  60. package/lib/component/panels/predictionPanel/PredictionPanel.js +3 -1
  61. package/lib/component/panels/spectrumSimulation/SpectrumSimulation.js +15 -4
  62. package/lib/component/reducer/Reducer.js +2 -0
  63. package/lib/component/reducer/actions/DomainActions.d.ts +2 -2
  64. package/lib/component/reducer/actions/DomainActions.js +2 -2
  65. package/lib/component/reducer/actions/FiltersActions.d.ts +3 -4
  66. package/lib/component/reducer/actions/FiltersActions.js +93 -57
  67. package/lib/component/reducer/actions/LoadActions.js +10 -8
  68. package/lib/component/reducer/actions/SpectrumsActions.d.ts +8 -1
  69. package/lib/component/reducer/actions/SpectrumsActions.js +8 -4
  70. package/lib/component/reducer/actions/ToolsActions.d.ts +8 -5
  71. package/lib/component/reducer/actions/ToolsActions.js +51 -44
  72. package/lib/component/reducer/helper/getVerticalAlign.d.ts +1 -1
  73. package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +0 -4
  74. package/lib/component/toolbar/BasicToolBar.js +11 -29
  75. package/lib/component/utility/export.d.ts +3 -2
  76. package/lib/component/utility/export.js +45 -26
  77. package/lib/component/workspaces/exercise.js +1 -0
  78. package/lib/component/workspaces/prediction.js +1 -16
  79. package/lib/component/workspaces/simulation.js +1 -2
  80. package/lib/component/workspaces/workspaceDefaultProperties.js +4 -3
  81. package/lib/data/data1d/Spectrum1D/index.d.ts +0 -1
  82. package/lib/data/data1d/Spectrum1D/index.js +0 -1
  83. package/lib/data/data1d/multipleSpectraAnalysis.js +27 -40
  84. package/lib/data/data2d/Spectrum2D/getMissingProjection.js +10 -1
  85. package/lib/versionInfo.js +1 -1
  86. package/package.json +31 -30
  87. package/lib/data/data1d/Spectrum1D/generateSpectrumFromPublicationString.d.ts +0 -2
  88. package/lib/data/data1d/Spectrum1D/generateSpectrumFromPublicationString.js +0 -6
@@ -3,6 +3,7 @@ import lodashMap from 'lodash/map';
3
3
  import { useCallback, useRef, useState } from 'react';
4
4
  import { useToggleAccordion } from 'react-science/ui';
5
5
  import { useDispatch } from '../context/DispatchContext';
6
+ import { usePreferences } from '../context/PreferencesContext';
6
7
  import { useAlert } from '../elements/popup/Alert';
7
8
  import { TOOLS_PANELS_ACCORDION } from '../panels/Panels';
8
9
  import { options } from '../toolbar/ToolTypes';
@@ -12,6 +13,7 @@ export default function useToolsFunctions() {
12
13
  const { open: openPanel } = useToggleAccordion();
13
14
  const [isRealSpectrumShown, setIsRealSpectrumShown] = useState(false);
14
15
  const debounceClickEventsRef = useRef({ clicks: [] });
16
+ const { current: { general: { invert }, }, } = usePreferences();
15
17
  const handleChangeOption = useCallback((selectedTool) => {
16
18
  if ([
17
19
  options.peakPicking.id,
@@ -20,7 +22,7 @@ export default function useToolsFunctions() {
20
22
  options.exclusionZones.id,
21
23
  options.rangePicking.id,
22
24
  ].includes(selectedTool)) {
23
- alert.show('Press Shift + Left Mouse button to select zone');
25
+ alert.show(`Press ${!invert ? 'Shift +' : ''} Left Mouse button to select zone`);
24
26
  }
25
27
  if (Object.keys(TOOLS_PANELS_ACCORDION).includes(selectedTool)) {
26
28
  openPanel(TOOLS_PANELS_ACCORDION[selectedTool]);
@@ -29,7 +31,7 @@ export default function useToolsFunctions() {
29
31
  type: 'SET_SELECTED_TOOL',
30
32
  payload: { selectedTool: selectedTool || options.zoom.id },
31
33
  });
32
- }, [alert, dispatch, openPanel]);
34
+ }, [alert, dispatch, invert, openPanel]);
33
35
  const handleFullZoomOut = useCallback(() => {
34
36
  if (debounceClickEventsRef.current.clicks.length === 0) {
35
37
  dispatch({
@@ -1 +1 @@
1
- export declare function useVerticalAlign(): any;
1
+ export declare function useVerticalAlign(): import("../reducer/Reducer").VerticalAlignment;
@@ -7,6 +7,7 @@ import { GlobalProvider } from '../context/GlobalContext';
7
7
  import { KeyModifiersProvider } from '../context/KeyModifierContext';
8
8
  import { LoggerProvider } from '../context/LoggerContext';
9
9
  import { PreferencesProvider } from '../context/PreferencesContext';
10
+ import { TopicMoleculeProvider } from '../context/TopicMoleculeContext';
10
11
  import { AlertProvider } from '../elements/popup/Alert';
11
12
  import { ModalProvider } from '../elements/popup/Modal';
12
13
  import { HighlightProvider } from '../highlight';
@@ -44,9 +45,9 @@ export function InnerNMRium({ data: nmriumData, workspace, customWorkspaces, pre
44
45
  return rootRef?.current ? getBlob(rootRef.current, 'nmrSVG') : null;
45
46
  },
46
47
  }), []);
47
- return (_jsx("div", { ref: mainDivRef, style: { height: '100%', position: 'relative' }, children: _jsx(GlobalProvider, { value: {
48
+ return (_jsx("div", { ref: mainDivRef, style: { height: '100%', position: 'relative' }, translate: "no", children: _jsx(GlobalProvider, { value: {
48
49
  rootRef: rootRef.current,
49
50
  elementsWrapperRef: elementsWrapperRef.current,
50
51
  viewerRef: viewerRef.current,
51
- }, children: _jsx(PreferencesProvider, { value: preferencesState, children: _jsx(LoggerProvider, { children: _jsx(KeyModifiersProvider, { children: _jsx(AlertProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(NMRiumStateProvider, { onChange: onChange, nmriumData: nmriumData, children: _jsx(ModalProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(HighlightProvider, { children: _jsx(AssignmentProvider, { children: _jsx(SpinnerProvider, { value: getSpinner, children: _jsx(InnerNMRiumContents, { isFullscreenEnabled: isFullscreenEnabled, toggleFullscreen: toggleFullscreen, emptyText: emptyText, mainDivRef: mainDivRef, elementsWrapperRef: elementsWrapperRef, rootRef: rootRef, viewerRef: viewerRef }) }) }) }) }) }) }) }) }) }) }) }));
52
+ }, children: _jsx(PreferencesProvider, { value: preferencesState, children: _jsx(LoggerProvider, { children: _jsx(KeyModifiersProvider, { children: _jsx(AlertProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(NMRiumStateProvider, { onChange: onChange, nmriumData: nmriumData, children: _jsx(TopicMoleculeProvider, { children: _jsx(ModalProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(HighlightProvider, { children: _jsx(AssignmentProvider, { children: _jsx(SpinnerProvider, { value: getSpinner, children: _jsx(InnerNMRiumContents, { isFullscreenEnabled: isFullscreenEnabled, toggleFullscreen: toggleFullscreen, emptyText: emptyText, mainDivRef: mainDivRef, elementsWrapperRef: elementsWrapperRef, rootRef: rootRef, viewerRef: viewerRef }) }) }) }) }) }) }) }) }) }) }) }) }));
52
53
  }
@@ -42,7 +42,7 @@ function ExportAsJcampModal(props) {
42
42
  const alert = useAlert();
43
43
  function submitHandler(options) {
44
44
  void (async () => {
45
- const hideLoading = await alert.showLoading('export as JCAMP in progress');
45
+ const hideLoading = await alert.showLoading('export as JCAMP-DX in progress');
46
46
  try {
47
47
  exportAsJcamp(spectrum, options);
48
48
  }
@@ -1,5 +1,6 @@
1
1
  interface ImportPublicationStringModalProps {
2
2
  onClose: () => void;
3
+ isOpen: boolean;
3
4
  }
4
- declare function ImportPublicationStringModal({ onClose, }: ImportPublicationStringModalProps): import("@emotion/react/jsx-runtime").JSX.Element;
5
+ declare function ImportPublicationStringModal(props: ImportPublicationStringModalProps): import("react/jsx-runtime").JSX.Element | undefined;
5
6
  export default ImportPublicationStringModal;
@@ -1,56 +1,100 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
- /** @jsxImportSource @emotion/react */
3
- import { css } from '@emotion/react';
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { FifoLogger } from 'fifo-logger';
4
3
  import { Formik } from 'formik';
5
- import { useCallback, useRef } from 'react';
4
+ import debounce from 'lodash/debounce';
5
+ import { resurrect } from 'nmr-processing';
6
+ import { useMemo, useRef, useState } from 'react';
7
+ import { Modal } from 'react-science/ui';
6
8
  import * as yup from 'yup';
7
9
  import { useDispatch } from '../context/DispatchContext';
8
10
  import Button from '../elements/Button';
9
- import CloseButton from '../elements/CloseButton';
11
+ import { GroupPane } from '../elements/GroupPane';
12
+ import ReactTable from '../elements/ReactTable/ReactTable';
10
13
  import FormikTextarea from '../elements/formik/FormikTextarea';
11
14
  import { useAlert } from '../elements/popup/Alert';
12
- import { ModalStyles } from './ModalStyle';
13
- const styles = css `
14
- width: 600px;
15
- height: 300px;
16
-
17
- .inner-content {
18
- flex: 1;
19
- border: none;
20
- overflow: hidden;
21
- padding: 0;
22
- }
23
-
24
- .text-area {
25
- width: 100%;
26
- height: 100%;
27
- outline: none;
28
- resize: none;
29
- padding: 0 0 0 15px;
30
- }
31
- `;
32
15
  const validationSchema = yup.object({
33
16
  publicationText: yup.string().required(),
34
17
  });
35
- function ImportPublicationStringModal({ onClose, }) {
18
+ function handleRowStyle(data) {
19
+ const level = (data?.original).level;
20
+ let backgroundColor = 'lightgreen';
21
+ if (level > 40) {
22
+ backgroundColor = 'pink';
23
+ }
24
+ else if (level === 40) {
25
+ backgroundColor = 'lightyellow';
26
+ }
27
+ return { base: { backgroundColor } };
28
+ }
29
+ const INITIAL_VALUES = {
30
+ publicationText: '1H NMR (CDCl3, 400MHz) δ 10.58 (b, 1H), 7.40 (d, 1H, J = 8.0 Hz), 6.19 (d, 1H, J = 7.6 Hz), 4.88 (s, 1H), 2.17 (s, 3H), 1.02 (s, 9H), 1.01 (s, 9H), 0.89 (s, 9H)',
31
+ };
32
+ function ImportPublicationStringModal(props) {
33
+ const { onClose, isOpen } = props;
36
34
  const formRef = useRef();
37
35
  const dispatch = useDispatch();
38
36
  const alert = useAlert();
39
- const publicationStringHandler = useCallback((values) => {
37
+ const [logs, setLogs] = useState([]);
38
+ const loggerRef = useRef(new FifoLogger({
39
+ onChange: (log, logs) => {
40
+ setLogs(logs.slice());
41
+ },
42
+ }));
43
+ const COLUMNS = useMemo(() => [
44
+ {
45
+ Header: '#',
46
+ accessor: (_, index) => index + 1,
47
+ style: { width: '40px' },
48
+ },
49
+ {
50
+ Header: 'Label',
51
+ accessor: 'levelLabel',
52
+ style: { width: '60px' },
53
+ },
54
+ {
55
+ Header: 'Message',
56
+ accessor: 'message',
57
+ },
58
+ ], []);
59
+ const debounceChanges = useMemo(() => debounce((value) => {
60
+ resurrect(value, { logger: loggerRef.current });
61
+ }, 250), []);
62
+ if (!isOpen)
63
+ return;
64
+ function publicationStringHandler({ publicationText }) {
40
65
  void (async () => {
41
66
  const hideLoading = await alert.showLoading('Generate spectrum from publication string in progress');
67
+ const { ranges, info: { nucleus, solvent = '', frequency }, parts, } = resurrect(publicationText, { logger: loggerRef.current });
42
68
  setTimeout(() => {
43
69
  dispatch({
44
70
  type: 'GENERATE_SPECTRUM_FROM_PUBLICATION_STRING',
45
- payload: values,
71
+ payload: {
72
+ ranges,
73
+ info: { nucleus, solvent, frequency, name: parts[0] },
74
+ },
46
75
  });
47
76
  hideLoading();
48
77
  });
49
78
  onClose();
50
79
  })();
51
- }, [alert, dispatch, onClose]);
52
- return (_jsxs("div", { css: [ModalStyles, styles], children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: "Import from publication string" }), _jsx(CloseButton, { onClick: onClose, className: "close-bt" })] }), _jsx("div", { className: "inner-content", children: _jsx(Formik, { innerRef: formRef, initialValues: {
53
- publicationText: '1H NMR (CDCl3, 400MHz) δ 10.58 (b, 1H), 7.40 (d, 1H, J = 8.0 Hz), 6.19 (d, 1H, J = 7.6 Hz), 4.88 (s, 1H), 2.17 (s, 3H), 1.02 (s, 9H), 1.01 (s, 9H), 0.89 (s, 9H)',
54
- }, validationSchema: validationSchema, onSubmit: publicationStringHandler, children: _jsx(FormikTextarea, { name: "publicationText", className: "text-area", placeholder: "Enter publication string" }) }) }), _jsx("div", { className: "footer-container", children: _jsx(Button.Done, { onClick: () => formRef.current.submitForm(), children: "Import" }) })] }));
80
+ }
81
+ function handleOnChange(event) {
82
+ loggerRef.current.clear();
83
+ const value = event.target.value;
84
+ if (value) {
85
+ debounceChanges(value);
86
+ }
87
+ }
88
+ const isNotValid = logs.some((log) => ['error', 'fatal'].includes(log.levelLabel));
89
+ return (_jsx(Modal, { hasCloseButton: true, isOpen: true, onRequestClose: onClose, children: _jsx(Formik, { innerRef: formRef, initialValues: INITIAL_VALUES, validationSchema: validationSchema, onSubmit: publicationStringHandler, children: ({ isValid }) => (_jsxs(_Fragment, { children: [_jsx(Modal.Header, { children: "Generate spectrum from publication string" }), _jsx(Modal.Body, { children: _jsxs("div", { style: { width: 800, minHeight: 400, padding: '10px' }, children: [_jsxs("p", { children: ["Paste a publication string in the text area below and click on the button ", _jsx("i", { children: "Generate spectrum" })] }), _jsx(FormikTextarea, { style: {
90
+ width: '100%',
91
+ height: '180px',
92
+ outline: 'none',
93
+ borderWidth: '1px',
94
+ borderColor: '#dedede',
95
+ borderRadius: '5px',
96
+ resize: 'none',
97
+ padding: '15px',
98
+ }, name: "publicationText", className: "text-area", placeholder: "Enter publication string", onChange: handleOnChange }), _jsx(GroupPane, { text: "Logs", children: _jsx(ReactTable, { columns: COLUMNS, data: logs, emptyDataRowText: "No Logs", rowStyle: handleRowStyle }) })] }) }), _jsx(Modal.Footer, { children: _jsx("div", { style: { display: 'flex', flexDirection: 'row-reverse' }, children: _jsx(Button.Done, { onClick: () => formRef.current.submitForm(), disabled: isNotValid || !isValid, children: "Generate spectrum" }) }) })] })) }) }));
55
99
  }
56
100
  export default ImportPublicationStringModal;
@@ -1,8 +1,7 @@
1
1
  import * as Yup from 'yup';
2
2
  import { hasCouplingConstant } from '../../../../panels/extra/utilities/MultiplicityUtilities';
3
3
  const editRangeFormValidation = Yup.object().shape({
4
- signals: Yup.array()
5
- .of(Yup.object().shape({
4
+ signals: Yup.array().of(Yup.object().shape({
6
5
  js: Yup.array()
7
6
  .of(Yup.object().shape({
8
7
  multiplicity: Yup.string().required(),
@@ -22,7 +21,6 @@ const editRangeFormValidation = Yup.object().shape({
22
21
  }),
23
22
  }))
24
23
  .min(1, 'There must be at least one coupling in a signal'),
25
- }))
26
- .min(1, 'There must be at least one signal in a range!'),
24
+ })),
27
25
  });
28
26
  export default editRangeFormValidation;
@@ -1,9 +1,15 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { LOGGER_LEVELS } from '../../../context/LoggerContext';
2
3
  import { GroupPane } from '../../../elements/GroupPane';
3
4
  import Label from '../../../elements/Label';
4
5
  import FormikCheckBox from '../../../elements/formik/FormikCheckBox';
5
6
  import FormikInput from '../../../elements/formik/FormikInput';
6
7
  import FormikSelect from '../../../elements/formik/FormikSelect';
8
+ const labelStyle = {
9
+ label: { flex: 6 },
10
+ wrapper: { flex: 6 },
11
+ container: { paddingBottom: '5px' },
12
+ };
7
13
  const SHAPE_RENDERING = [
8
14
  {
9
15
  label: 'Auto',
@@ -22,19 +28,11 @@ const SHAPE_RENDERING = [
22
28
  value: 'geometricPrecision',
23
29
  },
24
30
  ];
25
- const LOGS_LEVELS = [
26
- 'fatal',
27
- 'error',
28
- 'warn',
29
- 'info',
30
- 'debug',
31
- 'trace',
32
- 'silent',
33
- ].map((level) => ({
31
+ const LOGS_LEVELS = Object.keys(LOGGER_LEVELS).map((level) => ({
34
32
  label: level.replace(/^\w/, (c) => c.toUpperCase()),
35
33
  value: level,
36
34
  }));
37
35
  function GeneralTabContent() {
38
- return (_jsxs(_Fragment, { children: [_jsx(GroupPane, { text: "Spectra", children: _jsx(Label, { title: "Opacity of dimmed spectra [ 0 - 1 ]", children: _jsx(FormikInput, { name: "general.dimmedSpectraOpacity", checkValue: (value) => Number(value) >= 0 && Number(value) <= 1, type: "number", step: 0.1, min: 0, max: 1 }) }) }), _jsx(GroupPane, { text: "Experimental features", children: _jsx(Label, { title: "Enable experimental features", htmlFor: "display.general.experimentalFeatures.display", children: _jsx(FormikCheckBox, { name: "display.general.experimentalFeatures.display" }) }) }), _jsx(GroupPane, { text: "Rendering", children: _jsx(Label, { title: "Spectra rendering ", children: _jsx(FormikSelect, { items: SHAPE_RENDERING, name: "general.spectraRendering", style: { width: '150px' } }) }) }), _jsx(GroupPane, { text: "Logging settings", children: _jsx(Label, { title: "Level ", children: _jsx(FormikSelect, { items: LOGS_LEVELS, name: "general.loggingLevel", style: { width: '100px' } }) }) })] }));
36
+ return (_jsxs(_Fragment, { children: [_jsxs(GroupPane, { text: "General", children: [_jsx(Label, { title: "Opacity of dimmed spectra [ 0 - 1 ]", style: labelStyle, children: _jsx(FormikInput, { name: "general.dimmedSpectraOpacity", checkValue: (value) => Number(value) >= 0 && Number(value) <= 1, type: "number", step: 0.1, min: 0, max: 1, style: { inputWrapper: { width: 60 } } }) }), _jsx(Label, { title: "Invert actions", htmlFor: "general.invert", style: labelStyle, children: _jsx(FormikCheckBox, { name: "general.invert", style: { container: { justifyContent: 'flex-start' } } }) })] }), _jsx(GroupPane, { text: "Experimental features", children: _jsx(Label, { title: "Enable experimental features", htmlFor: "display.general.experimentalFeatures.display", style: labelStyle, children: _jsx(FormikCheckBox, { name: "display.general.experimentalFeatures.display", style: { container: { justifyContent: 'flex-start' } } }) }) }), _jsx(GroupPane, { text: "Rendering", children: _jsx(Label, { title: "Spectra rendering ", style: labelStyle, children: _jsx(FormikSelect, { items: SHAPE_RENDERING, name: "general.spectraRendering", style: { width: '150px' } }) }) }), _jsxs(GroupPane, { text: "Logging settings", children: [_jsx(Label, { title: "Level ", style: labelStyle, children: _jsx(FormikSelect, { items: LOGS_LEVELS, name: "general.loggingLevel", style: { width: '100px' } }) }), _jsx(Label, { title: "Popup logging level ", style: labelStyle, children: _jsx(FormikSelect, { items: LOGS_LEVELS, name: "general.popupLoggingLevel", style: { width: '100px' } }) })] })] }));
39
37
  }
40
38
  export default GeneralTabContent;
@@ -58,12 +58,13 @@ function MatrixGenerationPanel() {
58
58
  const { view: { spectra: { activeTab }, }, xDomain, data, } = useChartData();
59
59
  const formRef = useRef(null);
60
60
  const nucleusMatrixOptions = usePanelPreferences('matrixGeneration', activeTab);
61
+ const spectraPreferences = usePanelPreferences('spectra', activeTab);
61
62
  const matrixOptions = getMatrixOptions(nucleusMatrixOptions, {
62
63
  from: xDomain[0],
63
64
  to: xDomain[1],
64
65
  });
65
66
  function handleExportAsMatrix() {
66
- exportAsMatrix(data, 'Spectra Matrix');
67
+ exportAsMatrix(data, spectraPreferences?.columns || [], 'Spectra Matrix');
67
68
  }
68
69
  function handleSave(options) {
69
70
  dispatch({ type: 'APPLY_SIGNAL_PROCESSING_FILTER', payload: { options } });
@@ -8,7 +8,8 @@ interface MoleculePanelHeaderProps {
8
8
  onOpenMoleculeEditor: () => void;
9
9
  renderSource?: 'moleculePanel' | 'predictionPanel';
10
10
  onClickPreferences?: () => void;
11
+ onClickPastMolecule?: () => void;
11
12
  children?: ReactNode;
12
13
  }
13
- export default function MoleculePanelHeader({ currentIndex, molecules, moleculesView, onMoleculeIndexChange, onOpenMoleculeEditor, renderSource, onClickPreferences, children, }: MoleculePanelHeaderProps): import("react/jsx-runtime").JSX.Element;
14
+ export default function MoleculePanelHeader({ currentIndex, molecules, moleculesView, onMoleculeIndexChange, onOpenMoleculeEditor, renderSource, onClickPreferences, onClickPastMolecule, children, }: MoleculePanelHeaderProps): import("react/jsx-runtime").JSX.Element;
14
15
  export {};
@@ -64,7 +64,7 @@ const MOL_EXPORT_MENU = [
64
64
  },
65
65
  },
66
66
  ];
67
- export default function MoleculePanelHeader({ currentIndex, molecules, moleculesView, onMoleculeIndexChange, onOpenMoleculeEditor, renderSource = 'moleculePanel', onClickPreferences, children, }) {
67
+ export default function MoleculePanelHeader({ currentIndex, molecules, moleculesView, onMoleculeIndexChange, onOpenMoleculeEditor, renderSource = 'moleculePanel', onClickPreferences, onClickPastMolecule, children, }) {
68
68
  const { rootRef } = useGlobal();
69
69
  const alert = useAlert();
70
70
  const dispatch = useDispatch();
@@ -75,10 +75,10 @@ export default function MoleculePanelHeader({ currentIndex, molecules, molecules
75
75
  return;
76
76
  exportAsSVG(rootRef, `molSVG${currentIndex} `, 'molFile');
77
77
  }, [rootRef, currentIndex]);
78
- const saveAsPNGHandler = useCallback(() => {
78
+ const saveAsPNGHandler = useCallback(async () => {
79
79
  if (!rootRef)
80
80
  return;
81
- copyPNGToClipboard(rootRef, `molSVG${currentIndex} `);
81
+ await copyPNGToClipboard(rootRef, `molSVG${currentIndex} `);
82
82
  alert.success('MOL copied as PNG to clipboard');
83
83
  }, [rootRef, alert, currentIndex]);
84
84
  const { rawWriteWithType, readText, shouldFallback, cleanShouldFallback, text, } = useClipboard();
@@ -99,7 +99,7 @@ export default function MoleculePanelHeader({ currentIndex, molecules, molecules
99
99
  break;
100
100
  }
101
101
  case 'png':
102
- saveAsPNGHandler();
102
+ void saveAsPNGHandler();
103
103
  break;
104
104
  case 'svg':
105
105
  saveAsSVGHandler();
@@ -116,6 +116,7 @@ export default function MoleculePanelHeader({ currentIndex, molecules, molecules
116
116
  saveAsSVGHandler,
117
117
  ]);
118
118
  function handlePasteMolfileAction() {
119
+ onClickPastMolecule?.();
119
120
  void readText().then(handlePasteMolfile);
120
121
  }
121
122
  async function handlePasteMolfile(molfile) {
@@ -153,5 +154,5 @@ export default function MoleculePanelHeader({ currentIndex, molecules, molecules
153
154
  });
154
155
  }
155
156
  const hasMolecules = molecules && molecules.length > 0;
156
- return (_jsxs(PanelHeader, { children: [renderSource === 'predictionPanel' && _jsx(AboutPredictionModal, {}), renderSource === 'moleculePanel' && (_jsx(DropdownMenu, { options: MOL_EXPORT_MENU, onSelect: exportHandler, children: _jsx(Button.BarButton, { as: "div", disabled: !hasMolecules, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Export As", tooltipOrientation: "horizontal", children: _jsx(FaFileExport, {}) }) })), _jsx(Button.BarButton, { onClick: handlePasteMolfileAction, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Paste molfile", tooltipOrientation: "horizontal", children: _jsx(FaPaste, {}) }), _jsx(Button.BarButton, { onClick: onOpenMoleculeEditor, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Add molecule", tooltipOrientation: "horizontal", children: _jsx(FaPlus, {}) }), renderSource === 'moleculePanel' && (_jsxs(_Fragment, { children: [_jsx(Button.BarButton, { onClick: handleDelete, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Delete molecule", tooltipOrientation: "horizontal", disabled: !hasMolecules, children: _jsx(FaRegTrashAlt, {}) }), hasMolecules && (_jsx(PredictSpectraModal, { molecule: molecules[currentIndex] }))] })), _jsx(ActiveButton, { value: moleculesView?.[moleculeKey]?.floating.visible || false, popupTitle: "Float molecule", popupPlacement: "left", onClick: floatMoleculeHandler, disabled: !hasMolecules, children: _jsx(IoOpenOutline, {}) }), _jsx(ActiveButton, { style: { marginLeft: '2px' }, value: moleculesView?.[moleculeKey]?.showAtomNumber || false, popupTitle: "Show atom number", popupPlacement: "left", onClick: showAtomNumbersHandler, disabled: !hasMolecules, children: _jsx("p", { style: styles.atomLabel, children: "#" }) }), _jsx("div", { style: { flex: 1 }, children: children }), molecules && molecules.length > 0 && (_jsx("p", { style: styles.counter, children: `${+(currentIndex + 1)} / ${molecules.length}` })), onClickPreferences && (_jsx(Button.BarButton, { color: { base: 'black', hover: 'black' }, onClick: onClickPreferences, toolTip: "Preferences", tooltipOrientation: "vertical", children: _jsx(FaCog, {}) })), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, onReadText: handlePasteMolfile, text: text, label: "Molfile" })] }));
157
+ return (_jsxs(PanelHeader, { children: [renderSource === 'predictionPanel' && _jsx(AboutPredictionModal, {}), renderSource === 'moleculePanel' && (_jsx(DropdownMenu, { options: MOL_EXPORT_MENU, onSelect: exportHandler, children: _jsx(Button.BarButton, { as: "div", disabled: !hasMolecules, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Export As", tooltipOrientation: "horizontal", children: _jsx(FaFileExport, {}) }) })), _jsx(Button.BarButton, { onClick: handlePasteMolfileAction, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Paste molfile or SMILES", tooltipOrientation: "horizontal", children: _jsx(FaPaste, {}) }), _jsx(Button.BarButton, { onClick: onOpenMoleculeEditor, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Add molecule", tooltipOrientation: "horizontal", children: _jsx(FaPlus, {}) }), renderSource === 'moleculePanel' && (_jsxs(_Fragment, { children: [_jsx(Button.BarButton, { onClick: handleDelete, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Delete molecule", tooltipOrientation: "horizontal", disabled: !hasMolecules, children: _jsx(FaRegTrashAlt, {}) }), hasMolecules && (_jsx(PredictSpectraModal, { molecule: molecules[currentIndex] }))] })), _jsx(ActiveButton, { value: moleculesView?.[moleculeKey]?.floating.visible || false, popupTitle: "Float molecule", popupPlacement: "left", onClick: floatMoleculeHandler, disabled: !hasMolecules, children: _jsx(IoOpenOutline, {}) }), _jsx(ActiveButton, { style: { marginLeft: '2px' }, value: moleculesView?.[moleculeKey]?.showAtomNumber || false, popupTitle: "Show atom number", popupPlacement: "left", onClick: showAtomNumbersHandler, disabled: !hasMolecules, children: _jsx("p", { style: styles.atomLabel, children: "#" }) }), _jsx("div", { style: { flex: 1 }, children: children }), molecules && molecules.length > 0 && (_jsx("p", { style: styles.counter, children: `${+(currentIndex + 1)} / ${molecules.length}` })), onClickPreferences && (_jsx(Button.BarButton, { color: { base: 'black', hover: 'black' }, onClick: onClickPreferences, toolTip: "Preferences", tooltipOrientation: "vertical", children: _jsx(FaCog, {}) })), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, onReadText: handlePasteMolfile, text: text, label: "Molfile" })] }));
157
158
  }
@@ -64,7 +64,7 @@ function RangesTable({ tableData, onUnlink, contextMenu = [], onContextMenuSelec
64
64
  const showActions = preferences.showDeleteAction ||
65
65
  preferences.showEditAction ||
66
66
  preferences.showZoomAction;
67
- return (_jsxs("table", { css: tableStyle, children: [_jsx("thead", { children: _jsxs("tr", { children: [preferences.showSerialNumber && _jsx("th", { children: "#" }), preferences.from.show && (_jsxs("th", { id: "from", ...onSort, children: ["From", isSortedDesc('from').content] })), preferences.to.show && (_jsxs("th", { id: "to", ...onSort, children: ["To ", isSortedDesc('to').content] })), preferences.deltaPPM.show && _jsx("th", { children: "\u03B4 (ppm) " }), preferences.deltaHz.show && _jsx("th", { children: "\u03B4 (Hz) " }), preferences.relative.show && (_jsxs("th", { id: "integration", ...onSort, children: ["Rel. ", element, " ", isSortedDesc('integration').content] })), preferences.absolute.show && _jsx("th", { children: "Absolute" }), preferences.showMultiplicity && _jsx("th", { children: "Mult." }), preferences.coupling.show && _jsx("th", { children: "J (Hz)" }), preferences.showAssignment && (_jsxs(_Fragment, { children: [_jsx("th", { title: "Assign multiplets", children: _jsx(FaLink, { style: { fontSize: 10, margin: 'auto' } }) }), _jsx("th", { title: "Assign ranges", style: { minWidth: '50px' }, children: "\u03A3" })] })), preferences.showKind && _jsx("th", { children: "Kind" }), showActions && _jsx("th", { children: '' })] }) }), _jsx("tbody", { children: data?.map((range) => {
67
+ return (_jsxs("table", { css: tableStyle, children: [_jsx("thead", { children: _jsxs("tr", { children: [preferences.showSerialNumber && _jsx("th", { children: "#" }), preferences.from.show && (_jsxs("th", { id: "from", ...onSort, children: ["From", isSortedDesc('from').content] })), preferences.to.show && (_jsxs("th", { id: "to", ...onSort, children: ["To ", isSortedDesc('to').content] })), preferences.deltaPPM.show && (_jsxs("th", { id: "from", ...onSort, children: ["\u03B4 (ppm) ", isSortedDesc('from').content] })), preferences.deltaHz.show && _jsx("th", { children: "\u03B4 (Hz) " }), preferences.relative.show && (_jsxs("th", { id: "integration", ...onSort, children: ["Rel. ", element, " ", isSortedDesc('integration').content] })), preferences.absolute.show && _jsx("th", { children: "Absolute" }), preferences.showMultiplicity && _jsx("th", { children: "Mult." }), preferences.coupling.show && _jsx("th", { children: "J (Hz)" }), preferences.showAssignment && (_jsxs(_Fragment, { children: [_jsx("th", { title: "Assign multiplets", children: _jsx(FaLink, { style: { fontSize: 10, margin: 'auto' } }) }), _jsx("th", { title: "Assign ranges", style: { minWidth: '50px' }, children: "\u03A3" })] })), preferences.showKind && _jsx("th", { children: "Kind" }), showActions && _jsx("th", { children: '' })] }) }), _jsx("tbody", { children: data?.map((range) => {
68
68
  return (_jsx(RangesTableRow, { rowData: range, onUnlink: onUnlink, preferences: preferences, info: info, contextMenu: contextMenu, onContextMenuSelect: onContextMenuSelect }, range.rowKey));
69
69
  }) })] }));
70
70
  }
@@ -1,6 +1,7 @@
1
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
+ import * as Yup from 'yup';
4
5
  import { useChartData } from '../../context/ChartContext';
5
6
  import { usePreferences } from '../../context/PreferencesContext';
6
7
  import { Scroller } from '../../elements/Scroller';
@@ -11,6 +12,26 @@ import { getSpectraObjectPaths } from '../../utility/getSpectraObjectPaths';
11
12
  import { NucleusGroup } from '../extra/preferences/NucleusGroup';
12
13
  import { PreferencesContainer } from '../extra/preferences/PreferencesContainer';
13
14
  import { SpectraColumnsManager } from './base/SpectraColumnsManager';
15
+ function validationColumns(obj) {
16
+ const validationObject = {};
17
+ for (const key of Object.keys(obj.nuclei)) {
18
+ validationObject[key] = Yup.object({
19
+ columns: Yup.array().of(Yup.object().shape({
20
+ jpath: Yup.array().when('jpath', {
21
+ is: (jpath) => {
22
+ return jpath !== undefined;
23
+ },
24
+ // eslint-disable-next-line unicorn/no-thenable
25
+ then: () => Yup.array().of(Yup.string()).required().min(1),
26
+ }),
27
+ }, [['jpath', 'jpath']])),
28
+ });
29
+ }
30
+ return validationObject;
31
+ }
32
+ const spectraPreferencesValidation = Yup.lazy((obj) => Yup.object().shape({
33
+ nuclei: Yup.object().shape(validationColumns(obj)),
34
+ }));
14
35
  function SpectraPreferences(props, ref) {
15
36
  const formRef = useRef(null);
16
37
  const { data, view: { spectra: { activeTab }, }, } = useChartData();
@@ -26,10 +47,15 @@ function SpectraPreferences(props, ref) {
26
47
  }
27
48
  useImperativeHandle(ref, () => ({
28
49
  saveSetting: () => {
29
- formRef.current.submitForm();
50
+ if (!formRef.current)
51
+ return;
52
+ void formRef.current.submitForm();
53
+ return formRef.current?.isValid;
30
54
  },
31
55
  }), []);
32
56
  const handleAdd = useCallback((nucleus, index) => {
57
+ if (!formRef.current)
58
+ return;
33
59
  const data = formRef.current.values;
34
60
  let columns = data.nuclei[nucleus]?.columns || [];
35
61
  columns = [
@@ -41,7 +67,7 @@ function SpectraPreferences(props, ref) {
41
67
  },
42
68
  ...columns.slice(index),
43
69
  ];
44
- formRef.current.setValues({
70
+ void formRef.current.setValues({
45
71
  ...data,
46
72
  nuclei: {
47
73
  ...data.nuclei,
@@ -53,9 +79,11 @@ function SpectraPreferences(props, ref) {
53
79
  });
54
80
  }, []);
55
81
  const handleDelete = useCallback((nucleus, index) => {
82
+ if (!formRef.current)
83
+ return;
56
84
  const data = formRef.current.values;
57
85
  const columns = data.nuclei[nucleus]?.columns.filter((_, columnIndex) => columnIndex !== index);
58
- formRef.current.setValues({
86
+ void formRef.current.setValues({
59
87
  ...data,
60
88
  nuclei: {
61
89
  ...data.nuclei,
@@ -66,8 +94,14 @@ function SpectraPreferences(props, ref) {
66
94
  },
67
95
  });
68
96
  }, []);
69
- const mapOnChangeValueHandler = useCallback((key) => paths?.[key] || key, [paths]);
97
+ const mapOnChangeValueHandler = useCallback((key) => {
98
+ const path = paths?.[key];
99
+ if (path) {
100
+ return path;
101
+ }
102
+ return key || ' ';
103
+ }, [paths]);
70
104
  const mapValue = useCallback((value) => convertPathArrayToString(value), []);
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))) }) }) }));
105
+ return (_jsx(PreferencesContainer, { children: _jsx(Formik, { innerRef: formRef, onSubmit: saveHandler, initialValues: preferencesByNuclei, validationSchema: spectraPreferencesValidation, 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))) }) }) }));
72
106
  }
73
107
  export default memo(forwardRef(SpectraPreferences));
@@ -12,14 +12,9 @@ import { useAlert } from '../../elements/popup/Alert';
12
12
  import { usePanelPreferences } from '../../hooks/usePanelPreferences';
13
13
  import ExportAsJcampModal from '../../modal/ExportAsJcampModal';
14
14
  import ColorIndicator from './base/ColorIndicator';
15
+ import { RenderAsHTML } from './base/RenderAsHTML';
15
16
  import ShowHideSpectrumButton from './base/ShowHideSpectrumButton';
16
17
  import { SpectrumName } from './base/SpectrumName';
17
- function formatValueAsHTML(value) {
18
- if (value) {
19
- value = value.replaceAll(/(?<value>\d+)/g, '<sub>$<value></sub>');
20
- }
21
- return value;
22
- }
23
18
  function getActiveSpectraAsObject(activeSpectra) {
24
19
  const result = {};
25
20
  if (activeSpectra) {
@@ -34,6 +29,7 @@ function getActiveSpectraAsObject(activeSpectra) {
34
29
  const columnStyle = {
35
30
  maxWidth: 0,
36
31
  overflow: 'hidden',
32
+ height: '24px',
37
33
  };
38
34
  const options = [
39
35
  {
@@ -59,7 +55,7 @@ const Spectra2DContextMenuOptions = [
59
55
  data: { id: SpectraContextMenuOptionsKeys.Delete },
60
56
  },
61
57
  {
62
- text: 'Export as jcamp',
58
+ text: 'Export as JCAMP-DX',
63
59
  icon: _jsx(FaFileExport, {}),
64
60
  data: { id: SpectraContextMenuOptionsKeys.ExportAsJcamp },
65
61
  },
@@ -67,7 +63,7 @@ const Spectra2DContextMenuOptions = [
67
63
  const Spectra1DContextMenuOptions = [
68
64
  ...Spectra2DContextMenuOptions,
69
65
  {
70
- text: 'Export as jcamp',
66
+ text: 'Export as JCAMP-DX',
71
67
  icon: _jsx(FaFileExport, {}),
72
68
  data: { id: SpectraContextMenuOptionsKeys.ExportAsJcamp },
73
69
  },
@@ -86,38 +82,18 @@ export function SpectraTable(props) {
86
82
  style: {
87
83
  width: '35px',
88
84
  maxWidth: '55px',
85
+ height: '24px',
89
86
  },
90
87
  Cell: ({ row }) => {
91
88
  return (_jsx(ShowHideSpectrumButton, { data: row.original, onChangeVisibility: onChangeVisibility }));
92
89
  },
93
90
  },
94
- name: {
95
- Header: '',
96
- style: columnStyle,
97
- accessor: (row) => row.info.name,
98
- Cell: ({ row }) => {
99
- return _jsx(SpectrumName, { data: row.original });
100
- },
101
- },
102
- solvent: {
103
- Header: '',
104
- style: columnStyle,
105
- accessor: (row) => row.info.solvent,
106
- Cell: ({ row }) => {
107
- const info = row.original.info;
108
- return (info?.solvent && (_jsx("div", {
109
- // style={styles.info}
110
- // eslint-disable-next-line react/no-danger
111
- dangerouslySetInnerHTML: {
112
- __html: formatValueAsHTML(info.solvent),
113
- } })));
114
- },
115
- },
116
91
  color: {
117
92
  id: 'spectrum-actions',
118
93
  style: {
119
94
  width: '30px',
120
95
  maxWidth: '30px',
96
+ height: '24px',
121
97
  },
122
98
  Cell: ({ row }) => {
123
99
  const { display, info: { dimension, isFid }, } = row.original;
@@ -170,21 +146,33 @@ export function SpectraTable(props) {
170
146
  ...COLUMNS[name],
171
147
  Header: () => _jsx(ColumnHeader, { label: col.label, col: col }),
172
148
  id: name,
173
- style: name === 'name' && visibleColumns.length > 3
174
- ? {
175
- ...COLUMNS[name].style,
176
- width: '50%',
177
- }
178
- : COLUMNS[name].style,
179
149
  });
180
150
  }
181
151
  else {
182
- columns.push({
152
+ const pathString = Array.isArray(path) ? path.join('.') : '';
153
+ let style = columnStyle;
154
+ let cellRender = null;
155
+ if (pathString === 'info.name') {
156
+ if (visibleColumns.length > 3) {
157
+ style = { ...columnStyle, width: '50%' };
158
+ }
159
+ cellRender = ({ row }) => {
160
+ return _jsx(SpectrumName, { data: row.original });
161
+ };
162
+ }
163
+ if (pathString === 'info.solvent') {
164
+ cellRender = ({ row }) => {
165
+ return _jsx(RenderAsHTML, { data: row.original, jpath: pathString });
166
+ };
167
+ }
168
+ const cell = {
183
169
  Header: () => _jsx(ColumnHeader, { label: col.label, col: col }),
184
170
  accessor: (row) => lodashGet(row, path, ''),
171
+ ...(cellRender && { Cell: cellRender }),
185
172
  id: `${index}`,
186
- style: columnStyle,
187
- });
173
+ style,
174
+ };
175
+ columns.push(cell);
188
176
  }
189
177
  index++;
190
178
  }
@@ -204,7 +192,7 @@ export function SpectraTable(props) {
204
192
  activated: { opacity: 1 },
205
193
  };
206
194
  }
207
- return (_jsxs(_Fragment, { children: [_jsx(ReactTable, { rowStyle: handleRowStyle, activeRow: handleActiveRow, data: data, columns: tableColumns, onClick: (e, data) => onChangeActiveSpectrum(e, data.original), enableVirtualScroll: true, approxItemHeight: 26, contextMenu: data.info && data.info.dimension === 1
195
+ return (_jsxs(_Fragment, { children: [_jsx(ReactTable, { rowStyle: handleRowStyle, activeRow: handleActiveRow, data: data, columns: tableColumns, onClick: (e, data) => onChangeActiveSpectrum(e, data.original), enableVirtualScroll: true, approxItemHeight: 24, contextMenu: data.info && data.info.dimension === 1
208
196
  ? Spectra1DContextMenuOptions
209
197
  : Spectra2DContextMenuOptions, onContextMenuSelect: selectContextMenuHandler, onSortEnd: handleSortEnd, style: { 'table td': { paddingTop: 0, paddingBottom: 0 } } }), exportedSpectrum && (_jsx(ExportAsJcampModal, { spectrum: exportedSpectrum, closeDialog: () => {
210
198
  setExportedSpectrum(null);
@@ -18,8 +18,10 @@ function SpectrumListPanel() {
18
18
  setFlipStatus(!isFlipped);
19
19
  }
20
20
  function saveSettingHandler() {
21
- settingsRef.current.saveSetting();
22
- setFlipStatus(!isFlipped);
21
+ const isValid = settingsRef.current.saveSetting();
22
+ if (isValid) {
23
+ setFlipStatus(!isFlipped);
24
+ }
23
25
  }
24
26
  return (_jsx("div", { style: styles, children: isFlipped ? (_jsxs(_Fragment, { children: [_jsx(PreferencesHeader, { onSave: saveSettingHandler, onClose: settingsPanelHandler }), _jsx(SpectraPreferences, { ref: settingsRef })] })) : (_jsxs(_Fragment, { children: [_jsx(SpectraPanelHeader, { onSettingClick: settingsPanelHandler }), _jsx(SpectrumsTabs, {})] })) }));
25
27
  }