nmrium 0.55.0 → 0.56.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 (45) hide show
  1. package/lib/component/1d/Chart1D.js +3 -1
  2. package/lib/component/1d/Viewer1D.js +36 -11
  3. package/lib/component/1d/matrix/Boxplot.d.ts +6 -0
  4. package/lib/component/1d/matrix/Boxplot.js +97 -0
  5. package/lib/component/1d/matrix/Stocsy.d.ts +5 -0
  6. package/lib/component/1d/matrix/Stocsy.js +101 -0
  7. package/lib/component/1d/matrix/useMatrix.d.ts +29 -0
  8. package/lib/component/1d/matrix/useMatrix.js +93 -0
  9. package/lib/component/1d/utilities/scale.d.ts +2 -1
  10. package/lib/component/1d/utilities/scale.js +6 -1
  11. package/lib/component/context/PrepareExportContext.d.ts +21 -0
  12. package/lib/component/context/PrepareExportContext.js +124 -0
  13. package/lib/component/hooks/useExport.d.ts +1 -1
  14. package/lib/component/hooks/useExport.js +4 -4
  15. package/lib/component/hooks/usePanelPreferences.d.ts +2 -3
  16. package/lib/component/hooks/usePanelPreferences.js +3 -1
  17. package/lib/component/hooks/useToggleSpectraVisibility.d.ts +10 -0
  18. package/lib/component/hooks/useToggleSpectraVisibility.js +41 -0
  19. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.d.ts +2 -2
  20. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +121 -36
  21. package/lib/component/panels/Panels.js +1 -1
  22. package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +4 -27
  23. package/lib/component/panels/databasePanel/DatabaseTable.js +2 -2
  24. package/lib/component/reducer/Reducer.d.ts +6 -0
  25. package/lib/component/reducer/actions/DomainActions.d.ts +5 -2
  26. package/lib/component/reducer/actions/DomainActions.js +6 -4
  27. package/lib/component/reducer/actions/FiltersActions.js +2 -2
  28. package/lib/component/reducer/actions/LoadActions.js +5 -2
  29. package/lib/component/reducer/actions/SpectraActions.d.ts +1 -0
  30. package/lib/component/reducer/actions/SpectraActions.js +7 -2
  31. package/lib/component/reducer/preferences/actions/matrixGeneration.d.ts +47 -2
  32. package/lib/component/reducer/preferences/actions/matrixGeneration.js +62 -25
  33. package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.d.ts +5 -2
  34. package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +17 -1
  35. package/lib/component/reducer/preferences/preferencesReducer.d.ts +2 -25
  36. package/lib/component/reducer/preferences/preferencesReducer.js +7 -1
  37. package/lib/component/toolbar/ToolBar.js +6 -7
  38. package/lib/component/utility/PathBuilder.d.ts +1 -0
  39. package/lib/component/utility/PathBuilder.js +8 -1
  40. package/lib/data/types/common/DeepPartial.d.ts +3 -0
  41. package/lib/data/types/common/DeepPartial.js +1 -0
  42. package/lib/versionInfo.js +1 -1
  43. package/package.json +23 -23
  44. package/lib/component/elements/CustomToolTip.d.ts +0 -8
  45. package/lib/component/elements/CustomToolTip.js +0 -107
@@ -17,11 +17,11 @@ export default function useExport() {
17
17
  });
18
18
  setTimeout(async () => {
19
19
  await copyPNGToClipboard(rootRef, 'nmrSVG');
20
- hideLoading();
21
20
  toaster.show({
22
21
  message: 'Image copied to clipboard',
23
22
  intent: 'success',
24
23
  });
24
+ hideLoading();
25
25
  }, 0);
26
26
  }
27
27
  }, [state.data.length, rootRef, toaster]);
@@ -44,12 +44,12 @@ export default function useExport() {
44
44
  reportError(error);
45
45
  }
46
46
  }, [preferencesState, state, toaster]);
47
- const saveAsSVGHandler = useCallback(async () => {
47
+ const saveAsSVGHandler = useCallback(() => {
48
48
  if (state.data.length > 0 && rootRef) {
49
49
  const hideLoading = toaster.showLoading({
50
50
  message: 'Exporting as SVG process in progress',
51
51
  });
52
- setTimeout(() => {
52
+ void setTimeout(async () => {
53
53
  const fileName = state.data[0]?.info?.name;
54
54
  exportAsSVG(rootRef, 'nmrSVG', fileName);
55
55
  hideLoading();
@@ -61,7 +61,7 @@ export default function useExport() {
61
61
  const hideLoading = toaster.showLoading({
62
62
  message: 'Exporting as PNG process in progress',
63
63
  });
64
- setTimeout(() => {
64
+ void setTimeout(async () => {
65
65
  const fileName = state.data[0]?.info?.name;
66
66
  exportAsPng(rootRef, 'nmrSVG', fileName);
67
67
  hideLoading();
@@ -1,7 +1,6 @@
1
- import { MultipleSpectraAnalysisPreferences, PanelsPreferences, WorkSpacePanelPreferences } from 'nmr-load-save';
2
- import { MatrixOptions } from '../../data/types/data1d/MatrixOptions';
1
+ import { MatrixGenerationOptions, MultipleSpectraAnalysisPreferences, PanelsPreferences, WorkSpacePanelPreferences } from 'nmr-load-save';
3
2
  type Panel = 'spectra' | 'peaks' | 'integrals' | 'zones' | 'ranges' | 'database' | 'multipleSpectraAnalysis' | 'matrixGeneration' | 'prediction';
4
- export declare function usePanelPreferences<T extends Panel>(panelKey: T, nucleus: string): T extends 'matrixGeneration' ? MatrixOptions : T extends 'multipleSpectraAnalysis' ? MultipleSpectraAnalysisPreferences : WorkSpacePanelPreferences[T];
3
+ export declare function usePanelPreferences<T extends Panel>(panelKey: T, nucleus: string): T extends 'matrixGeneration' ? MatrixGenerationOptions : T extends 'multipleSpectraAnalysis' ? MultipleSpectraAnalysisPreferences : WorkSpacePanelPreferences[T];
5
4
  export declare function usePanelPreferences<T extends 'database' | 'prediction'>(panelKey: T): WorkSpacePanelPreferences[T];
6
5
  export type UsePanelPreferencesByNucleiResult<T extends Panel> = T extends 'spectra' ? PanelsPreferences['spectra'] : T extends 'peaks' ? PanelsPreferences['peaks'] : T extends 'integrals' ? PanelsPreferences['integrals'] : T extends 'zones' ? PanelsPreferences['zones'] : T extends 'ranges' ? PanelsPreferences['ranges'] : T extends 'multipleSpectraAnalysis' ? PanelsPreferences['multipleSpectraAnalysis'] : T extends 'matrixGeneration' ? PanelsPreferences['matrixGeneration'] : void;
7
6
  export declare function usePanelPreferencesByNuclei<T extends Panel>(panelKey: T, nuclei: string[]): UsePanelPreferencesByNucleiResult<T>;
@@ -2,7 +2,7 @@ import has from 'lodash/has';
2
2
  import { useMemo } from 'react';
3
3
  import { getDefaultPredictionOptions } from '../../data/PredictionManager';
4
4
  import { usePreferences } from '../context/PreferencesContext';
5
- import { getIntegralDefaultValues, getPeaksDefaultValues, getZoneDefaultValues, getRangeDefaultValues, databaseDefaultValues, getMultipleSpectraAnalysisDefaultValues, getSpectraDefaultValues, } from '../reducer/preferences/panelsPreferencesDefaultValues';
5
+ import { getIntegralDefaultValues, getPeaksDefaultValues, getZoneDefaultValues, getRangeDefaultValues, databaseDefaultValues, getMultipleSpectraAnalysisDefaultValues, getSpectraDefaultValues, getMatrixGenerationDefaultValues, } from '../reducer/preferences/panelsPreferencesDefaultValues';
6
6
  import { getValue } from '../utility/LocalStorage';
7
7
  function getDefaultPreferences(panelKey, nucleus) {
8
8
  switch (panelKey) {
@@ -22,6 +22,8 @@ function getDefaultPreferences(panelKey, nucleus) {
22
22
  return getMultipleSpectraAnalysisDefaultValues(nucleus);
23
23
  case 'prediction':
24
24
  return getDefaultPredictionOptions();
25
+ case 'matrixGeneration':
26
+ return getMatrixGenerationDefaultValues(nucleus);
25
27
  default:
26
28
  return {};
27
29
  }
@@ -0,0 +1,10 @@
1
+ export declare function useToggleSpectraVisibility(mode?: 'selected' | 'all'): {
2
+ showSpectraHandler: () => void;
3
+ hideSpectraHandler: () => void;
4
+ getToggleVisibilityButtons: (disabled?: boolean) => {
5
+ disabled: boolean;
6
+ icon: import("react/jsx-runtime").JSX.Element;
7
+ tooltip: string;
8
+ onClick: () => void;
9
+ }[];
10
+ };
@@ -0,0 +1,41 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { FaEye, FaEyeSlash } from 'react-icons/fa';
3
+ import { useChartData } from '../context/ChartContext';
4
+ import { useDispatch } from '../context/DispatchContext';
5
+ export function useToggleSpectraVisibility(mode = 'all') {
6
+ const dispatch = useDispatch();
7
+ const { view: { spectra: { activeTab }, }, } = useChartData();
8
+ function showSpectraHandler() {
9
+ dispatch({
10
+ type: 'CHANGE_SPECTRA_VISIBILITY_BY_NUCLEUS',
11
+ payload: { nucleus: activeTab, flag: true, mode },
12
+ });
13
+ }
14
+ function hideSpectraHandler() {
15
+ dispatch({
16
+ type: 'CHANGE_SPECTRA_VISIBILITY_BY_NUCLEUS',
17
+ payload: { nucleus: activeTab, flag: false, mode },
18
+ });
19
+ }
20
+ function getToggleVisibilityButtons(disabled = false) {
21
+ return [
22
+ {
23
+ disabled,
24
+ icon: _jsx(FaEyeSlash, {}),
25
+ tooltip: `Hide ${mode} spectra`,
26
+ onClick: hideSpectraHandler,
27
+ },
28
+ {
29
+ disabled,
30
+ icon: _jsx(FaEye, {}),
31
+ tooltip: `Show ${mode} spectra`,
32
+ onClick: showSpectraHandler,
33
+ },
34
+ ];
35
+ }
36
+ return {
37
+ showSpectraHandler,
38
+ hideSpectraHandler,
39
+ getToggleVisibilityButtons,
40
+ };
41
+ }
@@ -2,5 +2,5 @@ import { MatrixFilter } from '../../../data/matrixGeneration';
2
2
  import { GroupPaneStyle } from '../../elements/GroupPane';
3
3
  export declare const DEFAULT_MATRIX_FILTERS: MatrixFilter[];
4
4
  export declare const GroupPanelStyle: GroupPaneStyle;
5
- declare function MatrixGenerationPanel(): import("@emotion/react/jsx-runtime").JSX.Element | null;
6
- export default MatrixGenerationPanel;
5
+ export declare function useHasSignalProcessingFilter(): any;
6
+ export declare function MatrixGenerationPanel(): import("@emotion/react/jsx-runtime").JSX.Element | null;
@@ -1,9 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
2
2
  /** @jsxImportSource @emotion/react */
3
+ import styled from '@emotion/styled';
3
4
  import { SvgNmrExportAsMatrix, SvgNmrMultipleAnalysis } from 'cheminfo-font';
4
5
  import { Formik } from 'formik';
6
+ import { Filters } from 'nmr-processing';
5
7
  import { useRef } from 'react';
6
- import { FaCheck } from 'react-icons/fa';
8
+ import { IoAnalytics } from 'react-icons/io5';
9
+ import { TbBrandGoogleAnalytics } from 'react-icons/tb';
10
+ import { Button, Toolbar, TooltipHelpContent } from 'react-science/ui';
7
11
  import * as yup from 'yup';
8
12
  import { getMatrixFilters } from '../../../data/matrixGeneration';
9
13
  import { useChartData } from '../../context/ChartContext';
@@ -12,18 +16,31 @@ import { usePreferences } from '../../context/PreferencesContext';
12
16
  import StyledButton from '../../elements/Button';
13
17
  import { GroupPane } from '../../elements/GroupPane';
14
18
  import Label from '../../elements/Label';
15
- import ToggleButton from '../../elements/ToggleButton';
16
19
  import FormikInput from '../../elements/formik/FormikInput';
17
20
  import FormikOnChange from '../../elements/formik/FormikOnChange';
18
21
  import { usePanelPreferences } from '../../hooks/usePanelPreferences';
22
+ import useSpectraByActiveNucleus from '../../hooks/useSpectraPerNucleus';
23
+ import { useToggleSpectraVisibility } from '../../hooks/useToggleSpectraVisibility';
19
24
  import useToolsFunctions from '../../hooks/useToolsFunctions';
25
+ import { getMatrixGenerationDefaultOptions } from '../../reducer/preferences/panelsPreferencesDefaultValues';
20
26
  import { options } from '../../toolbar/ToolTypes';
27
+ import { booleanToString } from '../../utility/booleanToString';
21
28
  import { exportAsMatrix } from '../../utility/export';
22
29
  import { tablePanelStyle } from '../extra/BasicPanelStyle';
23
30
  import { PreferencesContainer } from '../extra/preferences/PreferencesContainer';
24
31
  import DefaultPanelHeader from '../header/DefaultPanelHeader';
25
32
  import { ExclusionsZonesTable } from './ExclusionsZonesTable';
26
33
  import { FiltersOptions } from './FiltersOptions';
34
+ const { signalProcessing } = Filters;
35
+ const StickyFooter = styled.div({
36
+ position: 'sticky',
37
+ padding: '5px',
38
+ bottom: 0,
39
+ width: '100%',
40
+ backgroundColor: 'white',
41
+ display: 'flex',
42
+ flexDirection: 'row',
43
+ });
27
44
  const schema = yup.object().shape({
28
45
  range: yup.object({
29
46
  from: yup.number().required(),
@@ -36,40 +53,73 @@ const labelStyle = {
36
53
  wrapper: { flex: 1, display: 'flex', flexDirection: 'row' },
37
54
  };
38
55
  const inputStyle = {
39
- input: { padding: '0.2em 0.1em', width: '100%' },
56
+ input: { padding: '0.4em 0.1em', width: '100%' },
40
57
  };
41
58
  export const DEFAULT_MATRIX_FILTERS = getMatrixFilters();
42
- const DEFAULT_MATRIX_OPTIONS = {
43
- filters: [],
44
- exclusionsZones: [],
45
- numberOfPoints: 1024,
46
- };
59
+ const DEFAULT_MATRIX_OPTIONS = getMatrixGenerationDefaultOptions();
47
60
  function getMatrixOptions(options, range) {
48
- return { ...DEFAULT_MATRIX_OPTIONS, range, ...options };
61
+ return {
62
+ ...DEFAULT_MATRIX_OPTIONS.matrixOptions,
63
+ range,
64
+ ...options,
65
+ };
49
66
  }
50
67
  export const GroupPanelStyle = {
51
68
  container: { padding: '10px' },
52
69
  header: { color: 'black', fontWeight: 'bolder' },
53
70
  };
54
- function MatrixGenerationPanel() {
71
+ export function useHasSignalProcessingFilter() {
72
+ const spectra = useSpectraByActiveNucleus();
73
+ if (!spectra)
74
+ return null;
75
+ for (const spectrum of spectra) {
76
+ for (const filter of spectrum.filters || []) {
77
+ if (filter.name === signalProcessing.id) {
78
+ return filter.value;
79
+ }
80
+ }
81
+ }
82
+ return null;
83
+ }
84
+ export function MatrixGenerationPanel() {
85
+ const { originDomain: { xDomain }, } = useChartData();
86
+ if (xDomain[0] === undefined || xDomain[1] === undefined) {
87
+ return null;
88
+ }
89
+ return _jsx(InnerMatrixGenerationPanel, {});
90
+ }
91
+ function InnerMatrixGenerationPanel() {
55
92
  const dispatch = useDispatch();
56
- const preferences = usePreferences();
57
- const { view: { spectra: { activeTab }, }, xDomain, data, } = useChartData();
93
+ const { dispatch: dispatchPreferences } = usePreferences();
94
+ const { view: { spectra: { activeTab }, }, xDomain, originDomain, data, } = useChartData();
95
+ const { getToggleVisibilityButtons } = useToggleSpectraVisibility();
58
96
  const formRef = useRef(null);
59
97
  const nucleusMatrixOptions = usePanelPreferences('matrixGeneration', activeTab);
60
98
  const spectraPreferences = usePanelPreferences('spectra', activeTab);
61
- const matrixOptions = getMatrixOptions(nucleusMatrixOptions, {
62
- from: xDomain[0],
63
- to: xDomain[1],
99
+ const matrixOptions = getMatrixOptions(nucleusMatrixOptions.matrixOptions, {
100
+ from: originDomain.xDomain[0],
101
+ to: originDomain.xDomain[1],
64
102
  });
65
103
  function handleExportAsMatrix() {
66
104
  exportAsMatrix(data, spectraPreferences?.columns || [], 'Spectra Matrix');
67
105
  }
106
+ function handleToggleStocsy() {
107
+ dispatchPreferences({
108
+ type: 'TOGGLE_MATRIX_GENERATION_VIEW_PROPERTY',
109
+ payload: { key: 'showStocsy', nucleus: activeTab },
110
+ });
111
+ }
112
+ function handleToggleBoxplot() {
113
+ dispatchPreferences({
114
+ type: 'TOGGLE_MATRIX_GENERATION_VIEW_PROPERTY',
115
+ payload: { key: 'showBoxPlot', nucleus: activeTab },
116
+ });
117
+ }
68
118
  function handleSave(options) {
69
119
  dispatch({ type: 'APPLY_SIGNAL_PROCESSING_FILTER', payload: { options } });
70
120
  }
71
121
  function handleOnChange(options) {
72
- preferences.dispatch({
122
+ dispatchPreferences({
73
123
  type: 'SET_MATRIX_GENERATION_OPTIONS',
74
124
  payload: { options, nucleus: activeTab },
75
125
  });
@@ -79,38 +129,73 @@ function MatrixGenerationPanel() {
79
129
  filters.push(DEFAULT_MATRIX_FILTERS[0]);
80
130
  handleOnChange({ ...matrixOptions, filters });
81
131
  }
82
- if (xDomain[0] === undefined || xDomain[1] === undefined) {
83
- return null;
132
+ function handleRemoveProcessing() {
133
+ dispatch({
134
+ type: 'DELETE_SPECTRA_FILTER',
135
+ payload: { filterName: signalProcessing.id },
136
+ });
84
137
  }
138
+ function handleUseCurrentRange() {
139
+ handleOnChange({
140
+ ...matrixOptions,
141
+ range: { from: xDomain[0], to: xDomain[1] },
142
+ });
143
+ }
144
+ const signalProcessingFilterData = useHasSignalProcessingFilter();
145
+ const { showStocsy, showBoxPlot } = nucleusMatrixOptions || DEFAULT_MATRIX_OPTIONS;
85
146
  return (_jsxs("div", { css: tablePanelStyle, children: [_jsx(DefaultPanelHeader, { leftButtons: [
86
147
  {
148
+ disabled: !signalProcessingFilterData,
87
149
  icon: _jsx(SvgNmrExportAsMatrix, {}),
88
- tooltip: 'Export spectra as a matrix',
150
+ tooltip: (_jsx(TooltipHelpContent, { title: "Export spectra as a matrix", description: "Export the matrix as a tab-delimited file. The first row contains meta information labels followed by the chemical shifts. Next rows contains the meta information and the intensities of the spectra." })),
89
151
  onClick: handleExportAsMatrix,
90
152
  },
91
- ], rightButtons: [
153
+ ...getToggleVisibilityButtons(),
154
+ {
155
+ disabled: !signalProcessingFilterData,
156
+ icon: _jsx(IoAnalytics, {}),
157
+ tooltip: (_jsx(TooltipHelpContent, { title: `${booleanToString(!showStocsy)} STOCSY`, subTitles: [
158
+ { title: 'Vertical zoom', shortcuts: ['⌥', 'Scroll wheel'] },
159
+ { title: 'STOCSY pivot', shortcuts: ['⇧', 'click'] },
160
+ ], description: "Statistical Total Correlation Spectroscopy (STOCSY) is a method to identify correlations between signals.", link: "https://doi.org/10.1021/ac048630x" })),
161
+ onClick: handleToggleStocsy,
162
+ active: showStocsy,
163
+ },
92
164
  {
93
- onClick: () => formRef.current?.submitForm(),
94
- tooltip: 'Signal processing',
95
- id: 'save-button',
96
- intent: 'success',
97
- icon: _jsx(FaCheck, {}),
165
+ disabled: !signalProcessingFilterData,
166
+ icon: _jsx(TbBrandGoogleAnalytics, {}),
167
+ tooltip: (_jsx(TooltipHelpContent, { title: `${booleanToString(!showBoxPlot)} box plot`, subTitles: [
168
+ { title: 'Vertical zoom', shortcuts: ['⌥', 'Scroll wheel'] },
169
+ ], description: "Display box plot like information. Light grey for min/max, dark grey for 1st/3rd quartile, and black for median." })),
170
+ onClick: handleToggleBoxplot,
171
+ active: showBoxPlot,
98
172
  },
99
- ] }), _jsx("div", { className: "inner-container", children: _jsx(PreferencesContainer, { style: { backgroundColor: 'white' }, children: _jsx(Formik, { innerRef: formRef, onSubmit: handleSave, initialValues: matrixOptions, enableReinitialize: true, validationSchema: schema, children: _jsxs(_Fragment, { children: [_jsx(GroupPane, { text: "Filters", style: GroupPanelStyle, renderHeader: (text) => (_jsx(FiltersPanelGroupHeader, { text: text, onAdd: handleAddFilter })), children: _jsx(FiltersOptions, {}) }), _jsx(GroupPane, { style: GroupPanelStyle, text: "Exclusions zones", renderHeader: (text) => (_jsx(ExclusionZonesGroupHeader, { text: text })), children: _jsx(ExclusionsZonesTable, {}) }), _jsxs(GroupPane, { text: "More options", style: GroupPanelStyle, children: [_jsxs(Label, { title: "Range", style: labelStyle, children: [_jsx(Label, { title: "From", children: _jsx(FormikInput, { name: "range.from", type: "number", style: inputStyle }) }), _jsx(Label, { title: "To", style: { container: { paddingLeft: '10px' } }, children: _jsx(FormikInput, { name: "range.to", type: "number", style: inputStyle }) })] }), _jsx(Label, { title: "Number of points", style: {
100
- ...labelStyle,
101
- wrapper: {},
102
- container: { paddingTop: '10px' },
103
- }, children: _jsx(FormikInput, { name: "numberOfPoints", type: "number", style: inputStyle }) })] }), _jsx(FormikOnChange, { onChange: handleOnChange })] }) }) }) })] }));
173
+ ] }), _jsx("div", { className: "inner-container", style: { position: 'relative' }, children: _jsxs(PreferencesContainer, { style: { backgroundColor: 'white', padding: 0 }, children: [_jsx(Formik, { innerRef: formRef, onSubmit: handleSave, initialValues: matrixOptions, enableReinitialize: true, validationSchema: schema, children: _jsxs(_Fragment, { children: [_jsx(GroupPane, { text: "Filters", style: GroupPanelStyle, renderHeader: (text) => (_jsx(FiltersPanelGroupHeader, { text: text, onAdd: handleAddFilter })), children: _jsx(FiltersOptions, {}) }), _jsx(GroupPane, { style: GroupPanelStyle, text: "Exclusions zones", renderHeader: (text) => (_jsx(CustomGroupHeader, { text: text, children: _jsx(ExclusionZonesGroupHeaderContent, {}) })), children: _jsx(ExclusionsZonesTable, {}) }), _jsxs(GroupPane, { text: "More options", style: GroupPanelStyle, renderHeader: (text) => (_jsx(CustomGroupHeader, { text: text, children: _jsx(Toolbar, { children: _jsx(Toolbar.Item, { tooltip: 'Use current range', onClick: handleUseCurrentRange, icon: _jsx(SvgNmrMultipleAnalysis, {}) }) }) })), children: [_jsxs(Label, { title: "Range", style: labelStyle, children: [_jsx(Label, { title: "From", children: _jsx(FormikInput, { name: "range.from", type: "number", style: inputStyle }) }), _jsx(Label, { title: "To", style: { container: { paddingLeft: '10px' } }, children: _jsx(FormikInput, { name: "range.to", type: "number", style: inputStyle }) })] }), _jsx(Label, { title: "Number of points", style: {
174
+ ...labelStyle,
175
+ wrapper: {},
176
+ container: { paddingTop: '10px' },
177
+ }, children: _jsx(FormikInput, { name: "numberOfPoints", type: "number", style: inputStyle }) })] }), _jsx(FormikOnChange, { onChange: handleOnChange })] }) }), _jsxs(StickyFooter, { children: [_jsx(Button, { intent: "success", onClick: () => formRef.current?.submitForm(), tooltipProps: { disabled: true, content: '' }, disabled: signalProcessingFilterData &&
178
+ JSON.stringify(signalProcessingFilterData) ===
179
+ JSON.stringify(matrixOptions), children: signalProcessingFilterData
180
+ ? 'Update processing'
181
+ : 'Apply processing' }), signalProcessingFilterData && (_jsx("div", { style: { paddingLeft: '5px' }, children: _jsx(Button, { intent: "danger", onClick: handleRemoveProcessing, tooltipProps: { disabled: true, content: '' }, children: "Remove processing" }) }))] })] }) })] }));
104
182
  }
105
183
  function FiltersPanelGroupHeader({ text, onAdd }) {
106
184
  return (_jsxs("div", { className: "section-header", style: { display: 'flex', padding: '5px 0px' }, children: [_jsx("p", { style: { flex: 1, ...GroupPanelStyle.header }, children: text }), _jsx(StyledButton.Done, { fill: "outline", size: "xSmall", onClick: onAdd, children: "Add Filter" })] }));
107
185
  }
108
- function ExclusionZonesGroupHeader({ text }) {
186
+ function CustomGroupHeader({ text, children }) {
187
+ return (_jsxs("div", { className: "section-header", style: { display: 'flex', padding: '5px 0px' }, children: [_jsx("p", { style: { flex: 1, ...GroupPanelStyle.header }, children: text }), children] }));
188
+ }
189
+ function ExclusionZonesGroupHeaderContent() {
109
190
  const { toolOptions: { selectedTool }, } = useChartData();
110
191
  const { handleChangeOption } = useToolsFunctions();
111
- return (_jsxs("div", { className: "section-header", style: { display: 'flex', padding: '5px 0px' }, children: [_jsx("p", { style: { flex: 1, ...GroupPanelStyle.header }, children: text }), _jsx(ToggleButton, { defaultValue: selectedTool === options.matrixGenerationExclusionZones.id, popupTitle: "Select exclusions zones", popupPlacement: "left", onClick: () => handleChangeOption(options.matrixGenerationExclusionZones.id), children: _jsx(SvgNmrMultipleAnalysis, { style: {
112
- pointerEvents: 'none',
113
- fontSize: '12px',
114
- } }) }, selectedTool)] }));
192
+ function handleToggleExclusionZoneTool() {
193
+ if (selectedTool !== options.matrixGenerationExclusionZones.id) {
194
+ handleChangeOption(options.matrixGenerationExclusionZones.id);
195
+ }
196
+ else {
197
+ handleChangeOption(options.zoom.id);
198
+ }
199
+ }
200
+ return (_jsx(Toolbar, { children: _jsx(Toolbar.Item, { tooltip: "Select exclusions zones", onClick: handleToggleExclusionZoneTool, icon: _jsx(SvgNmrMultipleAnalysis, {}), active: selectedTool === options.matrixGenerationExclusionZones.id }) }));
115
201
  }
116
- export default MatrixGenerationPanel;
@@ -8,7 +8,7 @@ import useCheckExperimentalFeature from '../hooks/useCheckExperimentalFeature';
8
8
  import AutomaticAssignment from './AutomaticAssignment/AutomaticAssignment';
9
9
  import InformationPanel from './InformationPanel';
10
10
  import IntegralPanel from './IntegralsPanel/IntegralPanel';
11
- import MatrixGenerationPanel from './MatrixGenerationPanel/MatrixGenerationPanel';
11
+ import { MatrixGenerationPanel } from './MatrixGenerationPanel/MatrixGenerationPanel';
12
12
  import MoleculePanel from './MoleculesPanel/MoleculePanel';
13
13
  import PeaksPanel from './PeaksPanel/PeaksPanel';
14
14
  import RangesPanel from './RangesPanel/RangesPanel';
@@ -1,7 +1,7 @@
1
1
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { SvgNmrSameTop, SvgNmrResetScale } from 'cheminfo-font';
3
3
  import { memo, useCallback } from 'react';
4
- import { FaCreativeCommonsSamplingPlus, FaEye, FaEyeSlash, } from 'react-icons/fa';
4
+ import { FaCreativeCommonsSamplingPlus } from 'react-icons/fa';
5
5
  import { IoColorPaletteOutline } from 'react-icons/io5';
6
6
  import { MdFormatColorFill } from 'react-icons/md';
7
7
  import { useChartData } from '../../context/ChartContext';
@@ -11,6 +11,7 @@ import { useToaster } from '../../context/ToasterContext';
11
11
  import { useModal } from '../../elements/popup/Modal';
12
12
  import { useActiveSpectra } from '../../hooks/useActiveSpectra';
13
13
  import useSpectrum from '../../hooks/useSpectrum';
14
+ import { useToggleSpectraVisibility } from '../../hooks/useToggleSpectraVisibility';
14
15
  import { getSpectraByNucleus } from '../../utility/getSpectraByNucleus';
15
16
  import DefaultPanelHeader from '../header/DefaultPanelHeader';
16
17
  import { SpectraAutomaticPickingButton } from '../header/SpectraAutomaticPickingButton';
@@ -30,6 +31,7 @@ function SpectraPanelHeaderInner({ data, activeSpectrum, activeSpectra, activeTa
30
31
  const modal = useModal();
31
32
  const toaster = useToaster();
32
33
  const dispatch = useDispatch();
34
+ const { getToggleVisibilityButtons } = useToggleSpectraVisibility('selected');
33
35
  const { current: { spectraColors }, } = usePreferences();
34
36
  const handleDelete = useCallback(() => {
35
37
  modal.showConfirmDialog({
@@ -45,18 +47,6 @@ function SpectraPanelHeaderInner({ data, activeSpectrum, activeSpectra, activeTa
45
47
  ],
46
48
  });
47
49
  }, [activeSpectra?.length, dispatch, modal]);
48
- function showAllSpectraHandler() {
49
- dispatch({
50
- type: 'CHANGE_SPECTRA_VISIBILITY_BY_NUCLEUS',
51
- payload: { nucleus: activeTab, flag: true },
52
- });
53
- }
54
- function hideAllSpectraHandler() {
55
- dispatch({
56
- type: 'CHANGE_SPECTRA_VISIBILITY_BY_NUCLEUS',
57
- payload: { nucleus: activeTab, flag: false },
58
- });
59
- }
60
50
  function addMissingProjectionHandler() {
61
51
  const missingNucleus = getMissingProjection(data, activeTab);
62
52
  if (missingNucleus.length > 0) {
@@ -89,20 +79,7 @@ function SpectraPanelHeaderInner({ data, activeSpectrum, activeSpectra, activeTa
89
79
  }
90
80
  const hasActiveSpectra = activeSpectra && activeSpectra?.length > 0;
91
81
  const spectraLengthPerTab = getSpectraByNucleus(activeTab, data)?.length;
92
- let leftButtons = [
93
- {
94
- disabled: !hasActiveSpectra,
95
- icon: _jsx(FaEyeSlash, {}),
96
- tooltip: 'Hide selected spectra',
97
- onClick: hideAllSpectraHandler,
98
- },
99
- {
100
- disabled: !hasActiveSpectra,
101
- icon: _jsx(FaEye, {}),
102
- tooltip: 'Show selected spectra',
103
- onClick: showAllSpectraHandler,
104
- },
105
- ];
82
+ let leftButtons = getToggleVisibilityButtons(!hasActiveSpectra);
106
83
  if (displayerMode === '2D' && activeSpectrum?.info.isFt) {
107
84
  leftButtons.push({
108
85
  icon: _jsx(FaCreativeCommonsSamplingPlus, {}),
@@ -106,7 +106,7 @@ const databaseTableColumns = (databasePreferences) => [
106
106
  Cell({ row }) {
107
107
  const { idCode, coordinates } = row.original?.ocl || {};
108
108
  const smiles = row.original?.smiles;
109
- return (_jsx(ResponsiveChart, { children: ({ width, height }) => {
109
+ return (_jsx(ResponsiveChart, { minWidth: 50, minHeight: 23, children: ({ width, height }) => {
110
110
  if (idCode && coordinates) {
111
111
  return (_jsx(IdcodeSvgRenderer, { height: height, width: width, idcode: idCode, coordinates: coordinates }));
112
112
  }
@@ -151,6 +151,6 @@ function DatabaseTable({ data, onAdd, onSave, totalCount, }) {
151
151
  }
152
152
  return columns.sort((object1, object2) => object1.index - object2.index);
153
153
  }, [databasePreferences, initialColumns]);
154
- return (_jsx(ReactTable, { data: data, columns: tableColumns, highlightedSource: HighlightEventSource.DATABASE, groupKey: "index", approxItemHeight: 23.5, enableVirtualScroll: true, totalCount: totalCount, disableDefaultRowStyle: true }));
154
+ return (_jsx(ReactTable, { data: data, columns: tableColumns, highlightedSource: HighlightEventSource.DATABASE, groupKey: "index", approxItemHeight: 23, enableVirtualScroll: true, totalCount: totalCount, disableDefaultRowStyle: true }));
155
155
  }
156
156
  export default memo(DatabaseTable);
@@ -39,6 +39,12 @@ export interface TwoDimensionPhaseCorrection {
39
39
  activeTraceDirection: TraceDirection;
40
40
  addTracesToBothDirections: boolean;
41
41
  }
42
+ export interface MatrixGenerationOptions {
43
+ showBoxPlot: boolean;
44
+ showStocsy: boolean;
45
+ scaleRatio: number;
46
+ chemicalShift: number | null;
47
+ }
42
48
  export declare const getDefaultTwoDimensionsPhaseCorrectionTraceOptions: () => TwoDimensionPhaseCorrection['traces'];
43
49
  export declare function getDefaultViewState(): ViewState;
44
50
  export declare const getInitialState: () => State;
@@ -16,13 +16,16 @@ type MoveXAxisAction = ActionType<'MOVE', {
16
16
  shiftY: number;
17
17
  }>;
18
18
  export type DomainActions = SetXDomainAction | SetYDomainAction | SetAxisDomainAction | MoveXAxisAction;
19
- declare function getDomain(draft: Draft<State>): {
19
+ interface GetDomainOptions {
20
+ domainSpectraScope?: 'visible' | 'all';
21
+ }
22
+ declare function getDomain(draft: Draft<State>, options?: GetDomainOptions): {
20
23
  xDomain: [number, number] | never[] | [undefined, undefined];
21
24
  yDomain: [number, number] | never[] | [undefined, undefined];
22
25
  yDomains: Record<string, number[]>;
23
26
  xDomains: Record<string, number[]>;
24
27
  };
25
- export interface SetDomainOptions {
28
+ export interface SetDomainOptions extends GetDomainOptions {
26
29
  updateYDomain?: boolean;
27
30
  isYDomainShared?: boolean;
28
31
  updateXDomain?: boolean;
@@ -22,7 +22,8 @@ function getActiveData(draft) {
22
22
  }
23
23
  return data;
24
24
  }
25
- function getDomain(draft) {
25
+ function getDomain(draft, options = {}) {
26
+ const { domainSpectraScope = 'visible' } = options;
26
27
  let xArray = [];
27
28
  let yArray = [];
28
29
  const yDomains = {};
@@ -36,7 +37,8 @@ function getDomain(draft) {
36
37
  const domain = [data.x[0], data.x.at(-1)];
37
38
  yDomains[id] = _extent;
38
39
  xDomains[id] = domain;
39
- if (display.isVisible) {
40
+ if (domainSpectraScope === 'all' ||
41
+ (domainSpectraScope === 'visible' && display.isVisible)) {
40
42
  xArray = xArray.concat(domain);
41
43
  yArray = yArray.concat(_extent);
42
44
  }
@@ -120,11 +122,11 @@ function get2DDomain(state) {
120
122
  };
121
123
  }
122
124
  function setDomain(draft, options) {
123
- const { updateYDomain = true, isYDomainShared = true, updateXDomain = true, } = options || {};
125
+ const { updateYDomain = true, isYDomainShared = true, updateXDomain = true, domainSpectraScope, } = options || {};
124
126
  let domain;
125
127
  if (draft.view.spectra.activeTab) {
126
128
  if (draft.displayerMode === '1D') {
127
- domain = getDomain(draft);
129
+ domain = getDomain(draft, { domainSpectraScope });
128
130
  }
129
131
  else {
130
132
  domain = get2DDomain(draft);
@@ -761,7 +761,7 @@ function handleDeleteSpectraFilter(draft, action) {
761
761
  }
762
762
  }
763
763
  resetSelectedTool(draft);
764
- setDomain(draft);
764
+ setDomain(draft, { domainSpectraScope: 'all' });
765
765
  setMode(draft);
766
766
  }
767
767
  }
@@ -791,7 +791,7 @@ function handleSignalProcessingFilter(draft, action) {
791
791
  ], { forceReapply: true });
792
792
  }
793
793
  const { updateXDomain, updateYDomain } = signalProcessing.DOMAIN_UPDATE_RULES;
794
- setDomain(draft, { updateXDomain, updateYDomain });
794
+ setDomain(draft, { updateXDomain, updateYDomain, domainSpectraScope: 'all' });
795
795
  }
796
796
  //action
797
797
  function handleAddExclusionZone(draft, action) {
@@ -116,7 +116,10 @@ function initData(draft, action, options = {}) {
116
116
  const state = getInitialState();
117
117
  return produce(state, (initialDraft) => {
118
118
  setData(initialDraft, action.payload);
119
- setActiveTab(initialDraft, { tab: viewState?.spectra?.activeTab || '' });
119
+ setActiveTab(initialDraft, {
120
+ tab: viewState?.spectra?.activeTab || '',
121
+ domainOptions: { domainSpectraScope: 'all' },
122
+ });
120
123
  initialDraft.width = draft.width;
121
124
  initialDraft.height = draft.height;
122
125
  setPreferences(initialDraft, viewState);
@@ -152,7 +155,7 @@ function handleLoadDropFiles(draft, action) {
152
155
  }
153
156
  else {
154
157
  setData(draft, payload);
155
- setActiveTab(draft);
158
+ setActiveTab(draft, { domainOptions: { domainSpectraScope: 'all' } });
156
159
  changeSpectrumVerticalAlignment(draft, { verticalAlign: 'auto-check' });
157
160
  // set source undefined when dragging and dropping a spectra file to prevent export spectra with the data source.
158
161
  if (resetSourceObject && spectra?.length > 0) {
@@ -12,6 +12,7 @@ type ChangeSpectrumVisibilityByIdAction = ActionType<'CHANGE_SPECTRUM_VISIBILITY
12
12
  type ChangeSpectraVisibilityByNucleusAction = ActionType<'CHANGE_SPECTRA_VISIBILITY_BY_NUCLEUS', {
13
13
  nucleus: Nucleus;
14
14
  flag: boolean;
15
+ mode?: 'selected' | 'all';
15
16
  }>;
16
17
  type ChangeActiveSpectrumAction = ActionType<'CHANGE_ACTIVE_SPECTRUM', {
17
18
  modifier?: 'shift[false]_ctrl[true]' | 'shift[true]_ctrl[false]' | 'shift[true]_ctrl[true]' | (string & {});
@@ -93,10 +93,15 @@ function handleChangeSpectrumVisibilityById(draft, action) {
93
93
  }
94
94
  //action
95
95
  function handleChangeSpectraVisibilityByNucleus(draft, action) {
96
- const { nucleus, flag } = action.payload;
96
+ const { nucleus, flag, mode = 'all' } = action.payload;
97
97
  const activeSpectra = getActiveSpectraAsObject(draft);
98
98
  for (const datum of getSpectraByNucleus(nucleus, draft.data)) {
99
- if (activeSpectra && datum.id in activeSpectra) {
99
+ if (mode === 'selected') {
100
+ if (activeSpectra && datum.id in activeSpectra) {
101
+ setVisible(datum, flag);
102
+ }
103
+ }
104
+ else {
100
105
  setVisible(datum, flag);
101
106
  }
102
107
  }