nmrium 0.56.0 → 0.57.1
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/ExclusionZoneAnnotation.d.ts +0 -1
- package/lib/component/1d/database/DatabaseSpectrum.js +14 -19
- package/lib/component/1d/jCouplingGraph/JGraphContext.d.ts +0 -1
- 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-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/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/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/Panels.js +31 -8
- 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/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 +20 -5
- 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 +1 -1
- package/lib/component/reducer/Reducer.js +2 -0
- package/lib/component/reducer/actions/DatabaseActions.js +22 -5
- package/lib/component/reducer/actions/SpectraActions.d.ts +8 -2
- package/lib/component/reducer/actions/SpectraActions.js +58 -21
- package/lib/component/reducer/actions/ToolsActions.js +3 -4
- package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.d.ts +7 -7
- package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +2 -0
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +1 -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/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 +32 -31
- 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,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',
|
|
@@ -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)) {
|
|
@@ -153,4 +155,17 @@ function DatabaseTable({ data, onAdd, onSave, totalCount, }) {
|
|
|
153
155
|
}, [databasePreferences, initialColumns]);
|
|
154
156
|
return (_jsx(ReactTable, { data: data, columns: tableColumns, highlightedSource: HighlightEventSource.DATABASE, groupKey: "index", approxItemHeight: 23, enableVirtualScroll: true, totalCount: totalCount, disableDefaultRowStyle: true }));
|
|
155
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 })) }));
|
|
170
|
+
}
|
|
156
171
|
export default memo(DatabaseTable);
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource @emotion/react */
|
|
3
|
+
import { Classes, Dialog, DialogBody, DialogFooter } from '@blueprintjs/core';
|
|
4
|
+
import { css } from '@emotion/react';
|
|
5
|
+
import { Formik } from 'formik';
|
|
6
|
+
import { useCallback, useMemo, useRef } from 'react';
|
|
7
|
+
import { FaPlus, FaRegTrashAlt } from 'react-icons/fa';
|
|
8
|
+
import { Button } from 'react-science/ui';
|
|
9
|
+
import { array, object, string } from 'yup';
|
|
10
|
+
import { useDispatch } from '../../context/DispatchContext';
|
|
11
|
+
import ReactTable from '../../elements/ReactTable/ReactTable';
|
|
12
|
+
import { tableInputStyle } from '../../elements/ReactTable/Style';
|
|
13
|
+
import FormikInput from '../../elements/formik/FormikInput';
|
|
14
|
+
import useSpectrum from '../../hooks/useSpectrum';
|
|
15
|
+
import { checkUniqueByKey } from '../../utility/checkUniqueByKey';
|
|
16
|
+
import { tablePanelStyle } from '../extra/BasicPanelStyle';
|
|
17
|
+
const metaInfoValidationSchema = array()
|
|
18
|
+
.of(object().shape({
|
|
19
|
+
key: string().required().trim(),
|
|
20
|
+
value: string().required().trim(),
|
|
21
|
+
}))
|
|
22
|
+
.test('Unique', 'Key need te be unique', function check(metaInfo) {
|
|
23
|
+
// eslint-disable-next-line no-invalid-this
|
|
24
|
+
return checkUniqueByKey(metaInfo, 'key', this);
|
|
25
|
+
});
|
|
26
|
+
export function InformationEditionModal(props) {
|
|
27
|
+
const { isOpen, onCloseDialog } = props;
|
|
28
|
+
const spectrum = useSpectrum();
|
|
29
|
+
if (!isOpen || !spectrum)
|
|
30
|
+
return null;
|
|
31
|
+
const metaInfo = Object.keys(spectrum.customInfo).map((key) => ({
|
|
32
|
+
key,
|
|
33
|
+
value: spectrum.customInfo[key],
|
|
34
|
+
}));
|
|
35
|
+
return (_jsx(Dialog, { isOpen: true, title: "Edit spectrum meta information", onClose: onCloseDialog, style: { width: 700, height: 500 }, children: _jsx(InnerInformationPanel, { metaInfo: metaInfo, onCloseDialog: onCloseDialog }) }));
|
|
36
|
+
}
|
|
37
|
+
function InnerInformationPanel(props) {
|
|
38
|
+
const { metaInfo = [], onCloseDialog } = props;
|
|
39
|
+
const dispatch = useDispatch();
|
|
40
|
+
const formRef = useRef(null);
|
|
41
|
+
const addHandler = useCallback((data, index = 0) => {
|
|
42
|
+
const meta = { key: '', value: '' };
|
|
43
|
+
void formRef.current?.setValues([
|
|
44
|
+
...data.slice(0, index),
|
|
45
|
+
meta,
|
|
46
|
+
...data.slice(index),
|
|
47
|
+
]);
|
|
48
|
+
}, []);
|
|
49
|
+
const deleteHandler = useCallback((data, index) => {
|
|
50
|
+
const meta = data.filter((_, columnIndex) => columnIndex !== index);
|
|
51
|
+
void formRef.current?.setValues(meta);
|
|
52
|
+
}, []);
|
|
53
|
+
function saveHandler(metaArray) {
|
|
54
|
+
const meta = {};
|
|
55
|
+
for (const { key, value } of metaArray) {
|
|
56
|
+
meta[key] = value;
|
|
57
|
+
}
|
|
58
|
+
dispatch({ type: 'UPDATE_SPECTRUM_META', payload: { meta } });
|
|
59
|
+
onCloseDialog();
|
|
60
|
+
}
|
|
61
|
+
const COLUMNS = useMemo(() => [
|
|
62
|
+
{
|
|
63
|
+
Header: '#',
|
|
64
|
+
style: { width: '25px', textAlign: 'center' },
|
|
65
|
+
accessor: (_, index) => index + 1,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
Header: 'Key',
|
|
69
|
+
style: { padding: 0 },
|
|
70
|
+
Cell: ({ row }) => {
|
|
71
|
+
return (_jsx(FormikInput, { name: `${row.index}.key`, style: tableInputStyle }));
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
Header: 'Value',
|
|
76
|
+
style: { padding: 0 },
|
|
77
|
+
Cell: ({ row }) => {
|
|
78
|
+
return (_jsx(FormikInput, { name: `${row.index}.value`, style: tableInputStyle }));
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
Header: '',
|
|
83
|
+
style: { width: '60px' },
|
|
84
|
+
id: 'action-button',
|
|
85
|
+
Cell: ({ data, row }) => {
|
|
86
|
+
return (_jsxs("div", { style: { display: 'flex', justifyContent: 'space-evenly' }, children: [_jsx(Button, { small: true, outlined: true, intent: "success", tooltipProps: { content: '', disabled: true }, onClick: (e) => {
|
|
87
|
+
e.stopPropagation();
|
|
88
|
+
addHandler(data, row.index + 1);
|
|
89
|
+
}, children: _jsx(FaPlus, { className: Classes.ICON }) }), _jsx(Button, { small: true, outlined: true, intent: "danger", tooltipProps: { content: '', disabled: true }, onClick: (e) => {
|
|
90
|
+
e.stopPropagation();
|
|
91
|
+
deleteHandler(data, row.index);
|
|
92
|
+
}, children: _jsx(FaRegTrashAlt, { className: Classes.ICON }) })] }));
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
], [addHandler, deleteHandler]);
|
|
96
|
+
return (_jsx(Formik, { innerRef: formRef, initialValues: metaInfo, validationSchema: metaInfoValidationSchema, onSubmit: saveHandler, children: ({ values, submitForm, isValid }) => (_jsxs(_Fragment, { children: [_jsx(DialogBody, { css: css `
|
|
97
|
+
background-color: white;
|
|
98
|
+
`, children: _jsxs("div", { css: tablePanelStyle, style: { height: 'calc(100% - 30px)' }, children: [_jsx("div", { style: { padding: '5px 0', display: 'flex' }, children: _jsx(Button, { intent: "success", small: true, outlined: true, onClick: () => addHandler(values), tooltipProps: { content: '', disabled: true }, children: "Add a new meta" }) }), _jsx(ReactTable, { data: values, columns: COLUMNS, emptyDataRowText: "No meta", style: {
|
|
99
|
+
'thead tr th': { zIndex: 1 },
|
|
100
|
+
td: { padding: 0 },
|
|
101
|
+
}, rowStyle: {
|
|
102
|
+
hover: { backgroundColor: '#f7f7f7' },
|
|
103
|
+
active: { backgroundColor: '#f5f5f5' },
|
|
104
|
+
} })] }) }), _jsx(DialogFooter, { children: _jsx(Button, { intent: "success", onClick: submitForm, tooltipProps: { content: '', disabled: true }, disabled: !isValid, children: "Save meta" }) })] })) }));
|
|
105
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function InformationPanel(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { InfoPanel } from 'react-science/ui';
|
|
4
|
-
import useSpectrum from '
|
|
4
|
+
import useSpectrum from '../../hooks/useSpectrum';
|
|
5
5
|
const emptyData = { info: {}, meta: {} };
|
|
6
|
-
export
|
|
6
|
+
export function InformationPanel() {
|
|
7
7
|
const { info, meta, customInfo } = useSpectrum(emptyData);
|
|
8
8
|
const data = useMemo(() => [
|
|
9
9
|
{ description: 'Custom information', data: customInfo || {} },
|
|
@@ -13,7 +13,7 @@ import FormikInput from '../../elements/formik/FormikInput';
|
|
|
13
13
|
import FormikSelect from '../../elements/formik/FormikSelect';
|
|
14
14
|
const NUMBER_OF_POINTS_1D = generateNumbersPowerOfX(12, 19);
|
|
15
15
|
const NUMBER_OF_POINTS_2D = generateNumbersPowerOfX(10, 10, {
|
|
16
|
-
format:
|
|
16
|
+
format: String,
|
|
17
17
|
});
|
|
18
18
|
const predictionFormValidation = Yup.object().shape({
|
|
19
19
|
name: Yup.string().label('Name'),
|
|
@@ -45,7 +45,7 @@ export interface MatrixGenerationOptions {
|
|
|
45
45
|
scaleRatio: number;
|
|
46
46
|
chemicalShift: number | null;
|
|
47
47
|
}
|
|
48
|
-
export declare const getDefaultTwoDimensionsPhaseCorrectionTraceOptions: () => TwoDimensionPhaseCorrection[
|
|
48
|
+
export declare const getDefaultTwoDimensionsPhaseCorrectionTraceOptions: () => TwoDimensionPhaseCorrection["traces"];
|
|
49
49
|
export declare function getDefaultViewState(): ViewState;
|
|
50
50
|
export declare const getInitialState: () => State;
|
|
51
51
|
export declare const initialState: State;
|
|
@@ -276,6 +276,8 @@ function innerSpectrumReducer(draft, action) {
|
|
|
276
276
|
return SpectraActions.handleOrderSpectra(draft, action);
|
|
277
277
|
case 'SIMULATE_SPECTRUM':
|
|
278
278
|
return SpectraActions.handleSimulateSpectrum(draft, action);
|
|
279
|
+
case 'UPDATE_SPECTRUM_META':
|
|
280
|
+
return SpectraActions.handleUpdateSpectrumMeta(draft, action);
|
|
279
281
|
case 'SET_SELECTED_TOOL':
|
|
280
282
|
return ToolsActions.setSelectedTool(draft, action);
|
|
281
283
|
case 'RESET_SELECTED_TOOL':
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { get1DColor, mapRanges } from '../../../data/data1d/Spectrum1D';
|
|
2
2
|
import { generateSpectrumFromRanges, } from '../../../data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges';
|
|
3
3
|
import { setZoom } from '../helper/Zoom1DManager';
|
|
4
|
+
import zoomHistoryManager from '../helper/ZoomHistoryManager';
|
|
4
5
|
import { setDomain } from './DomainActions';
|
|
5
6
|
function handleResurrectSpectrumFromJcamp(draft, action) {
|
|
6
7
|
const { ranges } = action.payload;
|
|
@@ -17,16 +18,32 @@ function handleResurrectSpectrumFromJcamp(draft, action) {
|
|
|
17
18
|
},
|
|
18
19
|
};
|
|
19
20
|
draft.data.push(spectrum);
|
|
20
|
-
setDomain(draft);
|
|
21
|
+
setDomain(draft, { isYDomainShared: false });
|
|
22
|
+
//rescale the vertical zoom
|
|
21
23
|
setZoom(draft, { scale: 0.8, spectrumID: spectrum.id });
|
|
24
|
+
//keep the last horizontal zoom
|
|
25
|
+
const zoomHistory = zoomHistoryManager(draft.zoom.history, draft.view.spectra.activeTab);
|
|
26
|
+
const zoomValue = zoomHistory.getLast();
|
|
27
|
+
if (zoomValue) {
|
|
28
|
+
draft.xDomain = zoomValue.xDomain;
|
|
29
|
+
draft.yDomain = zoomValue.yDomain;
|
|
30
|
+
}
|
|
22
31
|
}
|
|
23
32
|
function handleResurrectSpectrumFromRanges(draft, action) {
|
|
24
33
|
const { ranges, info } = action.payload;
|
|
25
34
|
const datum = generateSpectrumFromRanges(ranges, info, draft.usedColors);
|
|
26
|
-
if (datum)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
35
|
+
if (!datum)
|
|
36
|
+
return;
|
|
37
|
+
draft.data.push(datum);
|
|
38
|
+
setDomain(draft, { isYDomainShared: false });
|
|
39
|
+
//rescale the vertical zoom
|
|
40
|
+
setZoom(draft, { scale: 0.8, spectrumID: datum.id });
|
|
41
|
+
//keep the last horizontal zoom
|
|
42
|
+
const zoomHistory = zoomHistoryManager(draft.zoom.history, draft.view.spectra.activeTab);
|
|
43
|
+
const zoomValue = zoomHistory.getLast();
|
|
44
|
+
if (zoomValue) {
|
|
45
|
+
draft.xDomain = zoomValue.xDomain;
|
|
46
|
+
draft.yDomain = zoomValue.yDomain;
|
|
30
47
|
}
|
|
31
48
|
}
|
|
32
49
|
function handleToggleSimilarityTree(draft) {
|
|
@@ -5,6 +5,7 @@ import { SpectrumSimulationOptions } from '../../../data/data1d/spectrumSimulati
|
|
|
5
5
|
import { Nuclei, Nucleus } from '../../../data/types/common/Nucleus';
|
|
6
6
|
import { State } from '../Reducer';
|
|
7
7
|
import { ActionType } from '../types/ActionType';
|
|
8
|
+
import { SetDomainOptions } from './DomainActions';
|
|
8
9
|
type ChangeSpectrumVisibilityByIdAction = ActionType<'CHANGE_SPECTRUM_VISIBILITY', {
|
|
9
10
|
id: string;
|
|
10
11
|
key: 'isVisible' | 'isPositiveVisible' | 'isNegativeVisible';
|
|
@@ -24,6 +25,7 @@ type ChangeSpectrumSettingAction = ActionType<'CHANGE_SPECTRUM_SETTING', {
|
|
|
24
25
|
}>;
|
|
25
26
|
type DeleteSpectraAction = ActionType<'DELETE_SPECTRA', {
|
|
26
27
|
id?: string;
|
|
28
|
+
domainOptions?: SetDomainOptions;
|
|
27
29
|
}>;
|
|
28
30
|
type AddMissingProjectionAction = ActionType<'ADD_MISSING_PROJECTION', {
|
|
29
31
|
nucleus: Nuclei[];
|
|
@@ -57,7 +59,10 @@ type SimulateSpectrumAction = ActionType<'SIMULATE_SPECTRUM', {
|
|
|
57
59
|
keepSpectrum?: boolean;
|
|
58
60
|
spinSystem: string;
|
|
59
61
|
} & SpectrumSimulationOptions>;
|
|
60
|
-
|
|
62
|
+
type UpdateSpectrumMetaAction = ActionType<'UPDATE_SPECTRUM_META', {
|
|
63
|
+
meta: Record<string, string>;
|
|
64
|
+
}>;
|
|
65
|
+
export type SpectrumActions = ActionType<'TOGGLE_SPECTRA_LEGEND'> | ChangeSpectrumVisibilityByIdAction | ChangeSpectraVisibilityByNucleusAction | ChangeActiveSpectrumAction | ChangeSpectrumSettingAction | DeleteSpectraAction | AddMissingProjectionAction | AlignSpectraAction | GenerateSpectrumFromPublicationStringAction | ImportSpectraMetaInfoAction | ReColorSpectraBasedOnDistinctValueAction | OrderSpectraAction | SimulateSpectrumAction | UpdateSpectrumMetaAction;
|
|
61
66
|
declare function setSpectraMetaInfo(draft: Draft<State>, spectraMetaInfo: Record<string, Record<string, any>>): void;
|
|
62
67
|
declare function handleChangeSpectrumVisibilityById(draft: Draft<State>, action: ChangeSpectrumVisibilityByIdAction): void;
|
|
63
68
|
declare function handleChangeSpectraVisibilityByNucleus(draft: Draft<State>, action: ChangeSpectraVisibilityByNucleusAction): void;
|
|
@@ -72,4 +77,5 @@ declare function handleToggleSpectraLegend(draft: Draft<State>): void;
|
|
|
72
77
|
declare function handleRecolorSpectraBasedOnDistinctValue(draft: Draft<State>, action: ReColorSpectraBasedOnDistinctValueAction): void;
|
|
73
78
|
declare function handleOrderSpectra(draft: Draft<State>, action: OrderSpectraAction): void;
|
|
74
79
|
declare function handleSimulateSpectrum(draft: Draft<State>, simulateSpectrumOptions: SimulateSpectrumAction): void;
|
|
75
|
-
|
|
80
|
+
declare function handleUpdateSpectrumMeta(draft: Draft<State>, action: UpdateSpectrumMetaAction): null | undefined;
|
|
81
|
+
export { handleChangeSpectrumVisibilityById, handleChangeSpectraVisibilityByNucleus, handleChangeActiveSpectrum, handleChangeSpectrumSetting, handleDeleteSpectra, handleAddMissingProjectionHandler, handleAlignSpectraHandler, handleGenerateSpectrumFromPublicationStringHandler, handleImportSpectraMetaInfo, handleToggleSpectraLegend, handleRecolorSpectraBasedOnDistinctValue, handleOrderSpectra, handleSimulateSpectrum, setSpectraMetaInfo, handleUpdateSpectrumMeta, };
|