nmrium 0.55.0 → 0.57.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.
- package/lib/component/1d/Chart1D.js +3 -1
- package/lib/component/1d/ExclusionZoneAnnotation.d.ts +0 -1
- package/lib/component/1d/Viewer1D.js +36 -11
- package/lib/component/1d/database/DatabaseSpectrum.js +14 -19
- package/lib/component/1d/jCouplingGraph/JGraphContext.d.ts +0 -1
- package/lib/component/1d/matrix/Boxplot.d.ts +6 -0
- package/lib/component/1d/matrix/Boxplot.js +97 -0
- package/lib/component/1d/matrix/Stocsy.d.ts +5 -0
- package/lib/component/1d/matrix/Stocsy.js +101 -0
- package/lib/component/1d/matrix/useMatrix.d.ts +29 -0
- package/lib/component/1d/matrix/useMatrix.js +93 -0
- package/lib/component/1d/peaks/PeakAnnotationsSpreadMode.d.ts +0 -1
- package/lib/component/1d/peaks/PeakEditionManager.js +16 -10
- package/lib/component/1d/utilities/getDecimalsCount.js +1 -1
- package/lib/component/1d/utilities/intersectionResolver.js +1 -1
- package/lib/component/1d/utilities/scale.d.ts +2 -1
- package/lib/component/1d/utilities/scale.js +6 -1
- package/lib/component/1d-2d/FieldEdition.d.ts +3 -1
- package/lib/component/1d-2d/FieldEdition.js +26 -10
- package/lib/component/2d/1d-tracer/Left1DChart.d.ts +0 -1
- package/lib/component/2d/1d-tracer/Top1DChart.d.ts +0 -1
- package/lib/component/2d/XAxis.d.ts +0 -1
- package/lib/component/2d/YAxis.d.ts +0 -1
- package/lib/component/2d/ft/Contours.js +7 -7
- package/lib/component/assignment/AssignmentsContext.d.ts +0 -1
- package/lib/component/context/ChartContext.d.ts +0 -1
- package/lib/component/context/DispatchContext.d.ts +0 -1
- package/lib/component/context/GlobalContext.d.ts +0 -1
- package/lib/component/context/KeyModifierContext.js +1 -1
- package/lib/component/context/LoaderContext.d.ts +0 -1
- package/lib/component/context/PreferencesContext.d.ts +0 -1
- package/lib/component/context/PrepareExportContext.d.ts +21 -0
- package/lib/component/context/PrepareExportContext.js +124 -0
- package/lib/component/context/ScaleContext.d.ts +0 -1
- package/lib/component/elements/ActionButtons.d.ts +1 -0
- package/lib/component/elements/ActionButtons.js +4 -4
- package/lib/component/elements/ColorInput.d.ts +0 -1
- package/lib/component/elements/ColorPickerDropdownController.d.ts +2 -0
- package/lib/component/elements/ColorPickerDropdownController.js +8 -0
- package/lib/component/elements/ColumnWrapper.d.ts +0 -1
- package/lib/component/elements/ContextMenu.d.ts +0 -1
- package/lib/component/elements/Input.d.ts +1 -0
- package/lib/component/elements/Input.js +2 -1
- package/lib/component/elements/Input2.d.ts +13 -0
- package/lib/component/elements/Input2.js +118 -0
- package/lib/component/elements/Input2Controller.d.ts +12 -0
- package/lib/component/elements/Input2Controller.js +22 -0
- package/lib/component/elements/MoleculeSelection.js +1 -1
- package/lib/component/elements/NumberInput.js +1 -1
- package/lib/component/elements/NumberInput2.d.ts +12 -0
- package/lib/component/elements/NumberInput2.js +65 -0
- package/lib/component/elements/NumberInput2Controller.d.ts +8 -0
- package/lib/component/elements/NumberInput2Controller.js +15 -0
- package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +3 -3
- package/lib/component/elements/ReactTable/Style.d.ts +3 -1
- package/lib/component/elements/ReactTable/Style.js +11 -1
- package/lib/component/elements/ReactTable/utility/ReactTableContext.d.ts +0 -1
- package/lib/component/elements/Select2.d.ts +26 -0
- package/lib/component/elements/Select2.js +25 -0
- package/lib/component/elements/Select2Controller.d.ts +7 -0
- package/lib/component/elements/Select2Controller.js +12 -0
- package/lib/component/elements/draggable/useDraggable.d.ts +0 -1
- package/lib/component/elements/dropDownButton/DropDownButton.d.ts +2 -4
- package/lib/component/elements/dropDownButton/DropDownButton.js +11 -37
- package/lib/component/elements/dropDownButton/DropDownList.js +3 -32
- package/lib/component/elements/formik/FormikColorPicker.d.ts +0 -1
- package/lib/component/elements/formik/FormikColumnFormatField.d.ts +0 -1
- package/lib/component/elements/formik/FormikInput.d.ts +0 -1
- package/lib/component/elements/formik/FormikInput2.d.ts +11 -0
- package/lib/component/elements/formik/FormikInput2.js +26 -0
- package/lib/component/elements/formik/FormikOnChange.d.ts +0 -1
- package/lib/component/elements/popup/Modal/Context.d.ts +0 -1
- package/lib/component/elements/popup/Modal/ModalContent.d.ts +0 -1
- package/lib/component/elements/resizer/SVGResizer.d.ts +0 -1
- package/lib/component/elements/useFormValidateField.d.ts +1 -0
- package/lib/component/elements/useFormValidateField.js +9 -0
- package/lib/component/header/ApodizationOptionsPanel.js +26 -11
- package/lib/component/header/AutoPeakPickingOptionPanel.d.ts +1 -4
- package/lib/component/header/AutoPeakPickingOptionPanel.js +16 -16
- package/lib/component/header/BaseLineCorrectionPanel.js +49 -27
- package/lib/component/header/Header.js +1 -1
- package/lib/component/header/PhaseCorrectionPanel.js +12 -24
- package/lib/component/header/RangesPickingOptionPanel.js +12 -12
- package/lib/component/header/ZeroFillingOptionsPanel.js +18 -7
- package/lib/component/header/Zones2DOptionPanel.js +19 -18
- package/lib/component/hooks/useExport.d.ts +1 -1
- package/lib/component/hooks/useExport.js +4 -4
- package/lib/component/hooks/usePanelPreferences.d.ts +2 -3
- package/lib/component/hooks/usePanelPreferences.js +3 -1
- package/lib/component/hooks/useToggleSpectraVisibility.d.ts +10 -0
- package/lib/component/hooks/useToggleSpectraVisibility.js +41 -0
- package/lib/component/hooks/useWorkspaceAction.d.ts +1 -1
- package/lib/component/modal/editRange/forms/components/SignalTab.d.ts +0 -1
- package/lib/component/modal/editRange/forms/components/SignalsContent.d.ts +0 -1
- package/lib/component/modal/setting/GeneralSettings.d.ts +5 -1
- package/lib/component/modal/setting/GeneralSettings.js +107 -111
- package/lib/component/modal/setting/WorkspaceItem.js +4 -9
- package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.d.ts +1 -1
- package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.js +95 -59
- package/lib/component/modal/setting/settings-tabs/DisplayTabContent.js +33 -25
- package/lib/component/modal/setting/settings-tabs/GeneralTabContent.js +15 -4
- package/lib/component/modal/setting/settings-tabs/ImportationFiltersTabContent.js +56 -39
- package/lib/component/modal/setting/settings-tabs/InfoBlockTabContent.js +36 -36
- package/lib/component/modal/setting/settings-tabs/NucleiTabContent.js +44 -36
- package/lib/component/modal/setting/settings-tabs/OnLoadProcessingTabContent.js +16 -11
- package/lib/component/modal/setting/settings-tabs/SpectraColorsTabContent.js +47 -40
- package/lib/component/modal/setting/settings-tabs/ToolsTabContent.js +50 -40
- package/lib/component/modal/setting/settingsValidation.js +8 -34
- package/lib/component/panels/AutomaticAssignment/AutomaticAssignmentTable.d.ts +0 -1
- package/lib/component/panels/IntegralsPanel/IntegralTable.d.ts +0 -1
- package/lib/component/panels/IntegralsPanel/IntegralsPreferences.d.ts +0 -1
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.d.ts +2 -2
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +121 -36
- package/lib/component/panels/Panels.js +32 -9
- package/lib/component/panels/PeaksPanel/PeaksPreferences.d.ts +0 -1
- package/lib/component/panels/PeaksPanel/PeaksTable.d.ts +0 -1
- package/lib/component/panels/RangesPanel/RangesPreferences.d.ts +0 -1
- package/lib/component/panels/RangesPanel/TableColumns/RangeAssignmentsColumn.d.ts +0 -1
- package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +4 -27
- package/lib/component/panels/SpectraPanel/SpectraPreferences.d.ts +0 -1
- package/lib/component/panels/SpectraPanel/SpectraPreferences.js +32 -24
- package/lib/component/panels/SpectraPanel/SpectraTable.js +17 -2
- package/lib/component/panels/SpectraPanel/SpectrumListPanel.d.ts +0 -1
- package/lib/component/panels/SpectraPanel/base/ColorIndicator.d.ts +0 -1
- package/lib/component/panels/SpectraPanel/base/SpectraColumnsManager.d.ts +3 -3
- package/lib/component/panels/SpectraPanel/base/SpectraColumnsManager.js +25 -16
- package/lib/component/panels/SpectraPanel/base/setting/Spectrum1DHistogram.d.ts +0 -1
- package/lib/component/panels/SpectraPanel/base/setting/Spectrum1DSetting.js +15 -5
- package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DHistogram.d.ts +0 -1
- package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DSetting.js +44 -6
- package/lib/component/panels/SpectraPanel/base/setting/SpectrumSetting.d.ts +0 -1
- package/lib/component/panels/SummaryPanel/Overview.d.ts +0 -1
- package/lib/component/panels/SummaryPanel/SummaryPanel.d.ts +0 -1
- package/lib/component/panels/SummaryPanel/utilities/Utilities.d.ts +1 -1
- package/lib/component/panels/ZonesPanel/ZonesPreferences.d.ts +0 -1
- package/lib/component/panels/databasePanel/DatabasePanel.js +17 -3
- package/lib/component/panels/databasePanel/DatabasePreferences.d.ts +0 -1
- package/lib/component/panels/databasePanel/DatabaseTable.d.ts +11 -4
- package/lib/component/panels/databasePanel/DatabaseTable.js +22 -7
- package/lib/component/panels/informationPanel/InformationEditionModal.d.ts +6 -0
- package/lib/component/panels/informationPanel/InformationEditionModal.js +105 -0
- package/lib/component/panels/informationPanel/InformationPanel.d.ts +1 -0
- package/lib/component/panels/{InformationPanel.js → informationPanel/InformationPanel.js} +2 -2
- package/lib/component/panels/multipleAnalysisPanel/preferences/MultipleAnalysisCodeEditor.d.ts +0 -1
- package/lib/component/panels/multipleAnalysisPanel/preferences/index.d.ts +0 -1
- package/lib/component/panels/predictionPanel/PredictionOptionsPanel.d.ts +0 -1
- package/lib/component/panels/predictionPanel/PredictionOptionsPanel.js +1 -1
- package/lib/component/panels/predictionPanel/PredictionPreferences.d.ts +0 -1
- package/lib/component/panels/spectrumSimulation/SpectrumSimulationPreferences.d.ts +0 -1
- package/lib/component/reducer/Reducer.d.ts +7 -1
- package/lib/component/reducer/Reducer.js +2 -0
- package/lib/component/reducer/actions/DatabaseActions.js +22 -5
- package/lib/component/reducer/actions/DomainActions.d.ts +5 -2
- package/lib/component/reducer/actions/DomainActions.js +6 -4
- package/lib/component/reducer/actions/FiltersActions.js +2 -2
- package/lib/component/reducer/actions/LoadActions.js +5 -2
- package/lib/component/reducer/actions/SpectraActions.d.ts +9 -2
- package/lib/component/reducer/actions/SpectraActions.js +65 -23
- package/lib/component/reducer/actions/ToolsActions.js +3 -4
- package/lib/component/reducer/preferences/actions/matrixGeneration.d.ts +47 -2
- package/lib/component/reducer/preferences/actions/matrixGeneration.js +62 -25
- package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.d.ts +11 -8
- package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +19 -1
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +3 -26
- package/lib/component/reducer/preferences/preferencesReducer.js +7 -1
- package/lib/component/toolbar/ToolBar.js +6 -7
- package/lib/component/utility/PathBuilder.d.ts +1 -0
- package/lib/component/utility/PathBuilder.js +8 -1
- package/lib/component/utility/checkUniqueByKey.d.ts +2 -0
- package/lib/component/utility/checkUniqueByKey.js +40 -0
- package/lib/component/utility/colorToHexWithAlpha.d.ts +9 -0
- package/lib/component/utility/colorToHexWithAlpha.js +4 -0
- package/lib/component/workspaces/exercise.js +2 -0
- package/lib/component/workspaces/process1D.js +0 -1
- package/lib/component/workspaces/workspaceDefaultProperties.js +1 -0
- package/lib/data/PredictionManager.js +3 -5
- package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +13 -13
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +9 -9
- package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +13 -13
- package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +13 -13
- package/lib/data/data1d/database.d.ts +1 -0
- package/lib/data/data1d/database.js +4 -2
- package/lib/data/data2d/Spectrum2D/contours.d.ts +8 -22
- package/lib/data/data2d/Spectrum2D/contours.js +88 -67
- package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +4 -2
- package/lib/data/data2d/Spectrum2D/zones/detectZonesManual.d.ts +20 -20
- package/lib/data/data2d/Spectrum2D/zones/initiateZones.d.ts +20 -20
- package/lib/data/getDefaultMatrixFilters.d.ts +1 -1
- package/lib/data/initiateFilters.d.ts +1 -1
- package/lib/data/matrixGeneration.js +1 -2
- package/lib/data/types/common/DeepPartial.d.ts +3 -0
- package/lib/data/types/common/DeepPartial.js +1 -0
- package/lib/data/types/common/Keys.d.ts +3 -0
- package/lib/data/types/common/Keys.js +1 -0
- package/lib/data/utilities/generateNumbersPowerOfX.d.ts +2 -2
- package/lib/versionInfo.js +1 -1
- package/package.json +39 -38
- package/lib/component/elements/CustomToolTip.d.ts +0 -8
- package/lib/component/elements/CustomToolTip.js +0 -107
- package/lib/component/elements/formik/FormikSlider.d.ts +0 -6
- package/lib/component/elements/formik/FormikSlider.js +0 -15
- package/lib/component/panels/InformationPanel.d.ts +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { useImperativeHandle,
|
|
2
|
+
import { yupResolver } from '@hookform/resolvers/yup';
|
|
3
|
+
import { useImperativeHandle, memo, forwardRef, useCallback, useMemo, } from 'react';
|
|
4
|
+
import { FormProvider, useForm } from 'react-hook-form';
|
|
4
5
|
import * as Yup from 'yup';
|
|
5
6
|
import { useChartData } from '../../context/ChartContext';
|
|
6
7
|
import { usePreferences } from '../../context/PreferencesContext';
|
|
@@ -8,11 +9,17 @@ import { GroupPane } from '../../elements/GroupPane';
|
|
|
8
9
|
import { Scroller } from '../../elements/Scroller';
|
|
9
10
|
import useNucleus from '../../hooks/useNucleus';
|
|
10
11
|
import { usePanelPreferencesByNuclei } from '../../hooks/usePanelPreferences';
|
|
11
|
-
import { convertPathArrayToString } from '../../utility/convertPathArrayToString';
|
|
12
12
|
import { getSpectraObjectPaths } from '../../utility/getSpectraObjectPaths';
|
|
13
13
|
import { NucleusGroup } from '../extra/preferences/NucleusGroup';
|
|
14
14
|
import { PreferencesContainer } from '../extra/preferences/PreferencesContainer';
|
|
15
15
|
import { SpectraColumnsManager } from './base/SpectraColumnsManager';
|
|
16
|
+
function replaceNucleusKeys(data, searchValue, replaceValue) {
|
|
17
|
+
const nuclei = {};
|
|
18
|
+
for (const key in data.nuclei) {
|
|
19
|
+
nuclei[key.replace(searchValue, replaceValue)] = data.nuclei[key];
|
|
20
|
+
}
|
|
21
|
+
return { ...data, nuclei };
|
|
22
|
+
}
|
|
16
23
|
const groupPaneStyle = {
|
|
17
24
|
header: {
|
|
18
25
|
color: 'black',
|
|
@@ -45,30 +52,34 @@ const spectraPreferencesValidation = Yup.lazy((obj) => Yup.object().shape({
|
|
|
45
52
|
nuclei: Yup.object().shape(validationColumns(obj)),
|
|
46
53
|
}));
|
|
47
54
|
function SpectraPreferences(props, ref) {
|
|
48
|
-
const formRef = useRef(null);
|
|
49
55
|
const { data, view: { spectra: { activeTab }, }, } = useChartData();
|
|
50
56
|
const preferences = usePreferences();
|
|
51
57
|
const nuclei = useNucleus();
|
|
52
58
|
const preferencesByNuclei = usePanelPreferencesByNuclei('spectra', nuclei);
|
|
59
|
+
const methods = useForm({
|
|
60
|
+
defaultValues: replaceNucleusKeys(preferencesByNuclei, ',', '_'),
|
|
61
|
+
resolver: yupResolver(spectraPreferencesValidation),
|
|
62
|
+
});
|
|
63
|
+
const { handleSubmit, getValues, reset, formState: { isValid }, } = methods;
|
|
53
64
|
const { datalist, paths } = useMemo(() => getSpectraObjectPaths(data), [data]);
|
|
54
|
-
|
|
65
|
+
const saveHandler = useCallback((values) => {
|
|
55
66
|
preferences.dispatch({
|
|
56
67
|
type: 'SET_PANELS_PREFERENCES',
|
|
57
|
-
payload: {
|
|
68
|
+
payload: {
|
|
69
|
+
key: 'spectra',
|
|
70
|
+
value: replaceNucleusKeys(values, '_', ','),
|
|
71
|
+
},
|
|
58
72
|
});
|
|
59
|
-
|
|
73
|
+
return true;
|
|
74
|
+
}, [preferences]);
|
|
60
75
|
useImperativeHandle(ref, () => ({
|
|
61
76
|
saveSetting: () => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
void formRef.current.submitForm();
|
|
65
|
-
return formRef.current?.isValid;
|
|
77
|
+
void handleSubmit(saveHandler)();
|
|
78
|
+
return isValid;
|
|
66
79
|
},
|
|
67
|
-
}), []);
|
|
80
|
+
}), [handleSubmit, isValid, saveHandler]);
|
|
68
81
|
const handleAdd = useCallback((nucleus, index) => {
|
|
69
|
-
|
|
70
|
-
return;
|
|
71
|
-
const data = formRef.current.values;
|
|
82
|
+
const data = getValues();
|
|
72
83
|
let columns = data.nuclei[nucleus]?.columns || [];
|
|
73
84
|
columns = [
|
|
74
85
|
...columns.slice(0, index),
|
|
@@ -79,7 +90,7 @@ function SpectraPreferences(props, ref) {
|
|
|
79
90
|
},
|
|
80
91
|
...columns.slice(index),
|
|
81
92
|
];
|
|
82
|
-
|
|
93
|
+
reset({
|
|
83
94
|
...data,
|
|
84
95
|
nuclei: {
|
|
85
96
|
...data.nuclei,
|
|
@@ -89,13 +100,11 @@ function SpectraPreferences(props, ref) {
|
|
|
89
100
|
},
|
|
90
101
|
},
|
|
91
102
|
});
|
|
92
|
-
}, []);
|
|
103
|
+
}, [getValues, reset]);
|
|
93
104
|
const handleDelete = useCallback((nucleus, index) => {
|
|
94
|
-
|
|
95
|
-
return;
|
|
96
|
-
const data = formRef.current.values;
|
|
105
|
+
const data = getValues();
|
|
97
106
|
const columns = data.nuclei[nucleus]?.columns.filter((_, columnIndex) => columnIndex !== index);
|
|
98
|
-
|
|
107
|
+
reset({
|
|
99
108
|
...data,
|
|
100
109
|
nuclei: {
|
|
101
110
|
...data.nuclei,
|
|
@@ -105,7 +114,7 @@ function SpectraPreferences(props, ref) {
|
|
|
105
114
|
},
|
|
106
115
|
},
|
|
107
116
|
});
|
|
108
|
-
}, []);
|
|
117
|
+
}, [getValues, reset]);
|
|
109
118
|
const mapOnChangeValueHandler = useCallback((key) => {
|
|
110
119
|
const path = paths?.[key];
|
|
111
120
|
if (path) {
|
|
@@ -113,7 +122,6 @@ function SpectraPreferences(props, ref) {
|
|
|
113
122
|
}
|
|
114
123
|
return key || ' ';
|
|
115
124
|
}, [paths]);
|
|
116
|
-
|
|
117
|
-
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(GroupPane, { text: "General", style: groupPaneStyle, children: _jsx(SpectraColumnsManager, { nucleus: n, onAdd: handleAdd, onDelete: handleDelete, mapOnChangeValue: mapOnChangeValueHandler, mapValue: mapValue, datalist: datalist }) }) }) }, n))) }) }) }));
|
|
125
|
+
return (_jsx(PreferencesContainer, { children: _jsx(FormProvider, { ...methods, children: _jsx(Scroller, { scrollTo: activeTab, children: nuclei?.map((n) => (_jsx(Scroller.Item, { elementKey: n, children: _jsx(NucleusGroup, { nucleus: n, children: _jsx(GroupPane, { text: "General", style: groupPaneStyle, children: _jsx(SpectraColumnsManager, { nucleus: n.replace(',', '_'), onAdd: handleAdd, onDelete: handleDelete, mapOnChangeValue: mapOnChangeValueHandler, datalist: datalist }) }) }) }, n))) }) }) }));
|
|
118
126
|
}
|
|
119
127
|
export default memo(forwardRef(SpectraPreferences));
|
|
@@ -175,7 +175,7 @@ export function SpectraTable(props) {
|
|
|
175
175
|
});
|
|
176
176
|
}
|
|
177
177
|
else {
|
|
178
|
-
const pathString =
|
|
178
|
+
const pathString = pathToString(path);
|
|
179
179
|
let style = columnStyle;
|
|
180
180
|
let cellRender = null;
|
|
181
181
|
if (pathString === 'info.name') {
|
|
@@ -193,7 +193,7 @@ export function SpectraTable(props) {
|
|
|
193
193
|
}
|
|
194
194
|
const cell = {
|
|
195
195
|
Header: () => _jsx(ColumnHeader, { label: col.label, col: col }),
|
|
196
|
-
accessor: (row) =>
|
|
196
|
+
accessor: (row) => getValue(row, path),
|
|
197
197
|
...(cellRender && { Cell: cellRender }),
|
|
198
198
|
id: `${index}`,
|
|
199
199
|
style,
|
|
@@ -251,3 +251,18 @@ function convertSpectrumToText(spectrum) {
|
|
|
251
251
|
}
|
|
252
252
|
return lines.join('\n');
|
|
253
253
|
}
|
|
254
|
+
function pathToString(path) {
|
|
255
|
+
return Array.isArray(path) ? path.join('.') : '';
|
|
256
|
+
}
|
|
257
|
+
function getValue(row, path) {
|
|
258
|
+
const value = lodashGet(row, path, '');
|
|
259
|
+
const pathString = pathToString(path);
|
|
260
|
+
if (Array.isArray(value) &&
|
|
261
|
+
['info.baseFrequency', 'info.originFrequency'].includes(pathString)) {
|
|
262
|
+
return value[0];
|
|
263
|
+
}
|
|
264
|
+
if (Array.isArray(value)) {
|
|
265
|
+
return value.join(',');
|
|
266
|
+
}
|
|
267
|
+
return value;
|
|
268
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
interface SpectraColumnsManagerProps extends InputMapValueFunctions {
|
|
1
|
+
interface SpectraColumnsManagerProps {
|
|
3
2
|
nucleus: string;
|
|
4
3
|
onAdd: (nucleus: string, index: number) => void;
|
|
5
4
|
onDelete: (nucleus: string, index: number) => void;
|
|
6
5
|
datalist?: string[];
|
|
6
|
+
mapOnChangeValue: (value: string) => string;
|
|
7
7
|
}
|
|
8
|
-
export declare function SpectraColumnsManager({ nucleus, onAdd, onDelete, datalist, mapOnChangeValue,
|
|
8
|
+
export declare function SpectraColumnsManager({ nucleus, onAdd, onDelete, datalist, mapOnChangeValue, }: SpectraColumnsManagerProps): import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
export {};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { Checkbox, Classes } from '@blueprintjs/core';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
4
|
+
import { useFormContext } from 'react-hook-form';
|
|
5
|
+
import { FaPlus, FaRegTrashAlt } from 'react-icons/fa';
|
|
6
|
+
import { Button } from 'react-science/ui';
|
|
7
|
+
import { Input2Controller } from '../../../elements/Input2Controller';
|
|
7
8
|
import ReactTable from '../../../elements/ReactTable/ReactTable';
|
|
8
|
-
import
|
|
9
|
+
import { convertPathArrayToString } from '../../../utility/convertPathArrayToString';
|
|
9
10
|
const inputStyle = {
|
|
10
11
|
input: {
|
|
11
12
|
width: '100%',
|
|
@@ -19,8 +20,11 @@ const inputStyle = {
|
|
|
19
20
|
borderColor: 'white',
|
|
20
21
|
},
|
|
21
22
|
};
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
function getObjectKey(nucleus, index, key) {
|
|
24
|
+
return `nuclei.${nucleus}.columns.${index}.${key}`;
|
|
25
|
+
}
|
|
26
|
+
export function SpectraColumnsManager({ nucleus, onAdd, onDelete, datalist, mapOnChangeValue, }) {
|
|
27
|
+
const { control, getValues, register } = useFormContext();
|
|
24
28
|
const COLUMNS = useMemo(() => [
|
|
25
29
|
{
|
|
26
30
|
Header: '#',
|
|
@@ -31,7 +35,8 @@ export function SpectraColumnsManager({ nucleus, onAdd, onDelete, datalist, mapO
|
|
|
31
35
|
Header: 'Label',
|
|
32
36
|
style: { padding: 0 },
|
|
33
37
|
Cell: ({ row }) => {
|
|
34
|
-
|
|
38
|
+
const name = getObjectKey(nucleus, row.index, 'label');
|
|
39
|
+
return (_jsx(Input2Controller, { control: control, name: name, style: { backgroundColor: 'transparent' }, noShadowBox: true }));
|
|
35
40
|
},
|
|
36
41
|
},
|
|
37
42
|
{
|
|
@@ -45,23 +50,27 @@ export function SpectraColumnsManager({ nucleus, onAdd, onDelete, datalist, mapO
|
|
|
45
50
|
padding: '0.25rem 0.5rem',
|
|
46
51
|
}, children: column?.jpath?.join('.') || column.description }));
|
|
47
52
|
}
|
|
48
|
-
|
|
53
|
+
const name = getObjectKey(nucleus, row.index, 'jpath');
|
|
54
|
+
return (_jsx(Input2Controller, { control: control, name: name, filterItems: datalist, mapOnChangeValue: mapOnChangeValue, mapValue: convertPathArrayToString, style: { backgroundColor: 'transparent' }, noShadowBox: true }));
|
|
49
55
|
},
|
|
50
56
|
},
|
|
51
57
|
{
|
|
52
58
|
Header: 'Visible',
|
|
53
|
-
style: { width: '30px' },
|
|
54
|
-
Cell: ({ row }) => (_jsx(
|
|
59
|
+
style: { width: '30px', textAlign: 'center' },
|
|
60
|
+
Cell: ({ row }) => (_jsx(Checkbox, { style: { margin: 0 }, ...register(getObjectKey(nucleus, row.index, 'visible')) })),
|
|
55
61
|
},
|
|
56
62
|
{
|
|
57
63
|
Header: '',
|
|
58
|
-
style: { width: '
|
|
59
|
-
id: '
|
|
64
|
+
style: { width: '65px' },
|
|
65
|
+
id: 'op-buttons',
|
|
60
66
|
Cell: ({ row }) => {
|
|
61
67
|
const record = row.original;
|
|
62
|
-
return (_jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx(Button
|
|
68
|
+
return (_jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx(Button, { small: true, intent: "success", outlined: true, tooltipProps: { content: '', disabled: true }, onClick: () => onAdd(nucleus, row.index + 1), children: _jsx(FaPlus, { className: Classes.ICON }) }), !record?.name && (_jsx(Button, { small: true, outlined: true, intent: "danger", tooltipProps: { content: '', disabled: true }, onClick: () => onDelete(nucleus, row.index), children: _jsx(FaRegTrashAlt, { className: Classes.ICON }) }))] }));
|
|
63
69
|
},
|
|
64
70
|
},
|
|
65
|
-
], [datalist, mapOnChangeValue,
|
|
66
|
-
return (_jsx(ReactTable, { data:
|
|
71
|
+
], [control, datalist, mapOnChangeValue, nucleus, onAdd, onDelete, register]);
|
|
72
|
+
return (_jsx(ReactTable, { data: getValues().nuclei[nucleus]?.columns || [], columns: COLUMNS, rowStyle: {
|
|
73
|
+
hover: { backgroundColor: '#f7f7f7' },
|
|
74
|
+
active: { backgroundColor: '#f5f5f5' },
|
|
75
|
+
} }));
|
|
67
76
|
}
|
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Controller, useForm } from 'react-hook-form';
|
|
3
|
+
import { ColorPicker } from 'react-science/ui';
|
|
4
|
+
import { COLORS } from '../../../../../data/utilities/generateColor';
|
|
5
|
+
import { colorToHexWithAlpha } from '../../../../utility/colorToHexWithAlpha';
|
|
5
6
|
import Spectrum1DHistogram from './Spectrum1DHistogram';
|
|
6
7
|
function Spectrum1DSetting({ data: SpectrumData, onSubmit, }) {
|
|
7
|
-
|
|
8
|
+
const { control, handleSubmit } = useForm({
|
|
9
|
+
defaultValues: SpectrumData.display,
|
|
10
|
+
});
|
|
11
|
+
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: '1.25rem' }, children: [_jsx("div", { style: { display: 'block', position: 'relative' }, children: _jsx(Controller, { name: "color", control: control, render: ({ field }) => {
|
|
12
|
+
const { value, onChange } = field;
|
|
13
|
+
return (_jsx(ColorPicker, { onChangeComplete: (color) => {
|
|
14
|
+
onChange(colorToHexWithAlpha(color));
|
|
15
|
+
void handleSubmit(onSubmit)();
|
|
16
|
+
}, color: { hex: value || '#000' }, presetColors: COLORS, style: { boxShadow: 'none' } }));
|
|
17
|
+
} }) }), _jsx(Spectrum1DHistogram, { color: "red", data: SpectrumData.data })] }));
|
|
8
18
|
}
|
|
9
19
|
export default Spectrum1DSetting;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
|
+
import { RangeSlider } from '@blueprintjs/core';
|
|
3
4
|
import { css } from '@emotion/react';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
5
|
+
import debounce from 'lodash/debounce';
|
|
6
|
+
import { useMemo } from 'react';
|
|
7
|
+
import { Controller, FormProvider, useForm, useFormContext, useWatch, } from 'react-hook-form';
|
|
8
|
+
import { ColorPicker } from 'react-science/ui';
|
|
9
|
+
import { COLORS } from '../../../../../data/utilities/generateColor';
|
|
10
|
+
import { NumberInput2 } from '../../../../elements/NumberInput2';
|
|
11
|
+
import { useFormValidateField } from '../../../../elements/useFormValidateField';
|
|
12
|
+
import { colorToHexWithAlpha } from '../../../../utility/colorToHexWithAlpha';
|
|
9
13
|
import Spectrum2DHistogram from './Spectrum2DHistogram';
|
|
10
14
|
const style = (color) => css `
|
|
11
15
|
display: inline-block;
|
|
@@ -16,6 +20,40 @@ const style = (color) => css `
|
|
|
16
20
|
`;
|
|
17
21
|
function Spectrum2DSetting({ data: SpectrumData, onSubmit, }) {
|
|
18
22
|
const { positiveColor, negativeColor } = SpectrumData.display;
|
|
19
|
-
|
|
23
|
+
const methods = useForm({ defaultValues: SpectrumData.display });
|
|
24
|
+
return (_jsx(FormProvider, { ...methods, children: _jsxs("div", { children: [_jsxs("div", { css: style(positiveColor), children: [_jsx("span", { style: { padding: '0 10px' }, children: "Positive" }), _jsx(Settings, { sign: "positive", onSubmit: onSubmit })] }), _jsxs("div", { css: style(negativeColor), children: [_jsx("span", { style: { padding: '0 10px' }, children: "Negative" }), _jsx(Settings, { sign: "negative", onSubmit: onSubmit })] }), _jsx(Spectrum2DHistogram, { data: SpectrumData.data })] }) }));
|
|
25
|
+
}
|
|
26
|
+
function Settings(props) {
|
|
27
|
+
const { sign, onSubmit } = props;
|
|
28
|
+
const { control, handleSubmit } = useFormContext();
|
|
29
|
+
const isValid = useFormValidateField();
|
|
30
|
+
const progressColor = useWatch({ name: `${sign}Color` });
|
|
31
|
+
const debounceOnSubmit = useMemo(() => debounce((onSubmit) => {
|
|
32
|
+
void handleSubmit(onSubmit)();
|
|
33
|
+
}, 250), [handleSubmit]);
|
|
34
|
+
return (_jsxs(_Fragment, { children: [_jsx(Controller, { name: `${sign}Color`, control: control, render: ({ field }) => {
|
|
35
|
+
const { value, onChange } = field;
|
|
36
|
+
return (_jsx(ColorPicker, { onChangeComplete: (color) => {
|
|
37
|
+
onChange(colorToHexWithAlpha(color));
|
|
38
|
+
void handleSubmit(onSubmit)();
|
|
39
|
+
}, color: { hex: value || '#000' }, presetColors: COLORS, style: { boxShadow: 'none' } }));
|
|
40
|
+
} }), _jsxs("div", { style: { padding: '5px' }, children: [_jsx("span", { className: "label", children: "contour Levels [ min - max ]" }), _jsx(Controller, { name: `contourOptions.${sign}.contourLevels`, control: control, render: ({ field }) => {
|
|
41
|
+
const { value, onChange } = field;
|
|
42
|
+
return (_jsx(RangeSlider, { min: 0, max: 100, stepSize: 1, labelStepSize: 10, onChange: (e) => {
|
|
43
|
+
onChange(e);
|
|
44
|
+
debounceOnSubmit(onSubmit);
|
|
45
|
+
}, value: value, showTrackFill: true, css: css `
|
|
46
|
+
width: 90%;
|
|
47
|
+
|
|
48
|
+
[class*='slider-progress']:nth-child(2) {
|
|
49
|
+
background-color: ${progressColor};
|
|
50
|
+
}
|
|
51
|
+
` }));
|
|
52
|
+
} }), _jsx("span", { className: "label", children: "number of Layers " }), _jsx(Controller, { control: control, name: `contourOptions.${sign}.numberOfLayers`, rules: { required: true }, render: ({ field }) => {
|
|
53
|
+
return (_jsx(NumberInput2, { ...field, onValueChange: (valueAsNumber) => {
|
|
54
|
+
field.onChange(valueAsNumber);
|
|
55
|
+
void handleSubmit(onSubmit)();
|
|
56
|
+
}, intent: !isValid(field.name) ? 'danger' : 'none', style: { width: 60 }, min: 0, debounceTime: 250 }));
|
|
57
|
+
} })] })] }));
|
|
20
58
|
}
|
|
21
59
|
export default Spectrum2DSetting;
|
|
@@ -20,7 +20,7 @@ declare function getEditedCorrelations({ correlationDim1, correlationDim2, selec
|
|
|
20
20
|
}): {
|
|
21
21
|
editedCorrelations: Correlation[];
|
|
22
22
|
buildCorrelationDataOptions: {
|
|
23
|
-
skipDataUpdate?: boolean
|
|
23
|
+
skipDataUpdate?: boolean;
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
26
|
declare function convertValuesString(valuesString: string, key: 'protonsCount' | 'hybridization'): number[];
|
|
@@ -177,7 +177,7 @@ function DatabasePanelInner({ nucleus, selectedTool, databases, defaultDatabase,
|
|
|
177
177
|
}, [result.data]);
|
|
178
178
|
const resurrectHandler = useCallback((rowData) => {
|
|
179
179
|
const { index, baseURL, jcampURL: jcampRelativeURL } = rowData;
|
|
180
|
-
const { ranges, solvent, names = [] } = result.data[index];
|
|
180
|
+
const { ranges, solvent, names = [], id: spectrumID, } = result.data[index];
|
|
181
181
|
if (jcampRelativeURL) {
|
|
182
182
|
const url = new URL(jcampRelativeURL, baseURL);
|
|
183
183
|
setTimeout(async () => {
|
|
@@ -189,7 +189,8 @@ function DatabasePanelInner({ nucleus, selectedTool, databases, defaultDatabase,
|
|
|
189
189
|
entries: [{ baseURL: url.origin, relativePath: url.pathname }],
|
|
190
190
|
});
|
|
191
191
|
const spectrum = data?.spectra?.[0] || null;
|
|
192
|
-
if (spectrum && isSpectrum1D(spectrum)) {
|
|
192
|
+
if (spectrum && isSpectrum1D(spectrum) && spectrumID) {
|
|
193
|
+
spectrum.id = spectrumID;
|
|
193
194
|
dispatch({
|
|
194
195
|
type: 'RESURRECTING_SPECTRUM_FROM_JCAMP',
|
|
195
196
|
payload: { ranges, spectrum },
|
|
@@ -236,6 +237,19 @@ function DatabasePanelInner({ nucleus, selectedTool, databases, defaultDatabase,
|
|
|
236
237
|
toaster.show({ message: 'No jcamp file to save', intent: 'danger' });
|
|
237
238
|
}
|
|
238
239
|
}, [result, toaster]);
|
|
240
|
+
const removeHandler = useCallback((row) => {
|
|
241
|
+
const { spectrumID: id } = row;
|
|
242
|
+
if (!id) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
dispatch({
|
|
246
|
+
type: 'DELETE_SPECTRA',
|
|
247
|
+
payload: {
|
|
248
|
+
id,
|
|
249
|
+
domainOptions: { isYDomainShared: false, updateYDomain: false },
|
|
250
|
+
},
|
|
251
|
+
});
|
|
252
|
+
}, [dispatch]);
|
|
239
253
|
const searchByStructureHandler = (idCodeValue) => {
|
|
240
254
|
setIdCode(idCodeValue);
|
|
241
255
|
};
|
|
@@ -250,7 +264,7 @@ function DatabasePanelInner({ nucleus, selectedTool, databases, defaultDatabase,
|
|
|
250
264
|
}
|
|
251
265
|
}
|
|
252
266
|
`,
|
|
253
|
-
], children: [!isFlipped && (_jsxs(_Fragment, { children: [_jsx(DatabaseSearchOptions, { databases: databases, defaultDatabase: defaultDatabase, idCode: idCode, keywords: keywords, result: result, total: databaseInstance.current?.data.length || 0, onKeywordsChange: (options) => setKeywords((prevKeywords) => ({ ...prevKeywords, ...options })), onSettingClick: settingsPanelHandler, onStructureClick: openSearchByStructure, onDatabaseChange: handleChangeDatabase }), _jsx(DatabaseStructureSearchModal, { isOpen: isOpenSearchByStructure, onClose: closeSearchByStructure, onChange: searchByStructureHandler, idCode: idCode })] })), isFlipped && (_jsx(PreferencesHeader, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), _jsx("div", { className: "inner-container", children: !isFlipped ? (tableData && tableData.length > 0 ? (_jsx(DatabaseTable, { data: tableData, totalCount: result.data.length, onAdd: resurrectHandler, onSave: saveHandler })) : (_jsx(NoTableData, { text: databases && databases?.length > 0
|
|
267
|
+
], children: [!isFlipped && (_jsxs(_Fragment, { children: [_jsx(DatabaseSearchOptions, { databases: databases, defaultDatabase: defaultDatabase, idCode: idCode, keywords: keywords, result: result, total: databaseInstance.current?.data.length || 0, onKeywordsChange: (options) => setKeywords((prevKeywords) => ({ ...prevKeywords, ...options })), onSettingClick: settingsPanelHandler, onStructureClick: openSearchByStructure, onDatabaseChange: handleChangeDatabase }), _jsx(DatabaseStructureSearchModal, { isOpen: isOpenSearchByStructure, onClose: closeSearchByStructure, onChange: searchByStructureHandler, idCode: idCode })] })), isFlipped && (_jsx(PreferencesHeader, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), _jsx("div", { className: "inner-container", children: !isFlipped ? (tableData && tableData.length > 0 ? (_jsx(DatabaseTable, { data: tableData, totalCount: result.data.length, onAdd: resurrectHandler, onRemove: removeHandler, onSave: saveHandler })) : (_jsx(NoTableData, { text: databases && databases?.length > 0
|
|
254
268
|
? 'Please select a database'
|
|
255
269
|
: 'Please add databases URL in the general preferences' }))) : (_jsx(DatabasePreferences, { ref: settingRef })) })] }));
|
|
256
270
|
}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
interface
|
|
3
|
-
data: any;
|
|
1
|
+
import { PrepareDataResult } from '../../../data/data1d/database';
|
|
2
|
+
interface ToggleEvent {
|
|
4
3
|
onAdd: (row: any) => void;
|
|
4
|
+
onRemove: (row: any) => void;
|
|
5
|
+
}
|
|
6
|
+
interface DatabaseTableProps extends ToggleEvent {
|
|
7
|
+
data: any;
|
|
5
8
|
onSave: (row: any) => void;
|
|
6
9
|
totalCount: number;
|
|
7
10
|
}
|
|
8
|
-
declare function DatabaseTable({ data, onAdd, onSave, totalCount, }: DatabaseTableProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
11
|
+
declare function DatabaseTable({ data, onAdd, onRemove, onSave, totalCount, }: DatabaseTableProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
12
|
+
interface ToggleBtnProps extends ToggleEvent {
|
|
13
|
+
data: PrepareDataResult;
|
|
14
|
+
}
|
|
15
|
+
export declare function ToggleBtn(props: ToggleBtnProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
9
16
|
declare const _default: import("react").MemoExoticComponent<typeof DatabaseTable>;
|
|
10
17
|
export default _default;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
|
+
import { Classes } from '@blueprintjs/core';
|
|
3
4
|
import lodashGet from 'lodash/get';
|
|
4
5
|
import { useMemo, memo } from 'react';
|
|
5
6
|
import { ResponsiveChart } from 'react-d3-utils';
|
|
6
|
-
import { FaDownload, FaPlus } from 'react-icons/fa';
|
|
7
|
+
import { FaDownload, FaMinus, FaPlus } from 'react-icons/fa';
|
|
7
8
|
import { IdcodeSvgRenderer, SmilesSvgRenderer } from 'react-ocl/full';
|
|
8
|
-
import Button from '
|
|
9
|
+
import { Button } from 'react-science/ui';
|
|
9
10
|
import { ColumnWrapper } from '../../elements/ColumnWrapper';
|
|
10
11
|
import ReactTable from '../../elements/ReactTable/ReactTable';
|
|
11
12
|
import addCustomColumn from '../../elements/ReactTable/utility/addCustomColumn';
|
|
12
13
|
import { HighlightEventSource } from '../../highlight';
|
|
13
14
|
import { usePanelPreferences } from '../../hooks/usePanelPreferences';
|
|
15
|
+
import useSpectraByActiveNucleus from '../../hooks/useSpectraPerNucleus';
|
|
14
16
|
import { formatNumber } from '../../utility/formatNumber';
|
|
15
17
|
const overFlowStyle = {
|
|
16
18
|
overflow: 'hidden',
|
|
@@ -106,7 +108,7 @@ const databaseTableColumns = (databasePreferences) => [
|
|
|
106
108
|
Cell({ row }) {
|
|
107
109
|
const { idCode, coordinates } = row.original?.ocl || {};
|
|
108
110
|
const smiles = row.original?.smiles;
|
|
109
|
-
return (_jsx(ResponsiveChart, { children: ({ width, height }) => {
|
|
111
|
+
return (_jsx(ResponsiveChart, { minWidth: 50, minHeight: 23, children: ({ width, height }) => {
|
|
110
112
|
if (idCode && coordinates) {
|
|
111
113
|
return (_jsx(IdcodeSvgRenderer, { height: height, width: width, idcode: idCode, coordinates: coordinates }));
|
|
112
114
|
}
|
|
@@ -120,7 +122,7 @@ const databaseTableColumns = (databasePreferences) => [
|
|
|
120
122
|
},
|
|
121
123
|
},
|
|
122
124
|
];
|
|
123
|
-
function DatabaseTable({ data, onAdd, onSave, totalCount, }) {
|
|
125
|
+
function DatabaseTable({ data, onAdd, onRemove, onSave, totalCount, }) {
|
|
124
126
|
const databasePreferences = usePanelPreferences('database');
|
|
125
127
|
const initialColumns = useMemo(() => [
|
|
126
128
|
{
|
|
@@ -137,10 +139,10 @@ function DatabaseTable({ data, onAdd, onSave, totalCount, }) {
|
|
|
137
139
|
enableRowSpan: true,
|
|
138
140
|
Cell: ({ row }) => {
|
|
139
141
|
const { jcampURL } = row.original;
|
|
140
|
-
return (_jsxs(ColumnWrapper, { style: { display: 'flex', justifyContent: 'space-evenly' }, children: [_jsx(
|
|
142
|
+
return (_jsxs(ColumnWrapper, { style: { display: 'flex', justifyContent: 'space-evenly' }, children: [_jsx(ToggleBtn, { onAdd: onAdd, onRemove: onRemove, data: row.original }), databasePreferences?.allowSaveAsNMRium && (_jsx(Button, { small: true, outlined: true, tooltipProps: { content: '', disabled: true }, onClick: () => onSave(row.original), disabled: !jcampURL, children: _jsx(FaDownload, { className: Classes.ICON }) }))] }));
|
|
141
143
|
},
|
|
142
144
|
},
|
|
143
|
-
], [databasePreferences?.allowSaveAsNMRium, onAdd, onSave]);
|
|
145
|
+
], [databasePreferences?.allowSaveAsNMRium, onAdd, onRemove, onSave]);
|
|
144
146
|
const tableColumns = useMemo(() => {
|
|
145
147
|
const columns = [...initialColumns];
|
|
146
148
|
for (const col of databaseTableColumns(databasePreferences)) {
|
|
@@ -151,6 +153,19 @@ function DatabaseTable({ data, onAdd, onSave, totalCount, }) {
|
|
|
151
153
|
}
|
|
152
154
|
return columns.sort((object1, object2) => object1.index - object2.index);
|
|
153
155
|
}, [databasePreferences, initialColumns]);
|
|
154
|
-
return (_jsx(ReactTable, { data: data, columns: tableColumns, highlightedSource: HighlightEventSource.DATABASE, groupKey: "index", approxItemHeight: 23
|
|
156
|
+
return (_jsx(ReactTable, { data: data, columns: tableColumns, highlightedSource: HighlightEventSource.DATABASE, groupKey: "index", approxItemHeight: 23, enableVirtualScroll: true, totalCount: totalCount, disableDefaultRowStyle: true }));
|
|
157
|
+
}
|
|
158
|
+
export function ToggleBtn(props) {
|
|
159
|
+
const { onAdd, onRemove, data } = props;
|
|
160
|
+
const spectra = useSpectraByActiveNucleus();
|
|
161
|
+
const isAdded = spectra.some((spectrum) => spectrum.id === data.spectrumID);
|
|
162
|
+
return (_jsx(Button, { small: true, intent: isAdded ? 'danger' : 'success', outlined: true, tooltipProps: { content: '', disabled: true }, onClick: () => {
|
|
163
|
+
if (isAdded) {
|
|
164
|
+
onRemove(data);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
onAdd(data);
|
|
168
|
+
}
|
|
169
|
+
}, children: isAdded ? (_jsx(FaMinus, { className: Classes.ICON })) : (_jsx(FaPlus, { className: Classes.ICON })) }));
|
|
155
170
|
}
|
|
156
171
|
export default memo(DatabaseTable);
|