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.
Files changed (202) hide show
  1. package/lib/component/1d/Chart1D.js +3 -1
  2. package/lib/component/1d/ExclusionZoneAnnotation.d.ts +0 -1
  3. package/lib/component/1d/Viewer1D.js +36 -11
  4. package/lib/component/1d/database/DatabaseSpectrum.js +14 -19
  5. package/lib/component/1d/jCouplingGraph/JGraphContext.d.ts +0 -1
  6. package/lib/component/1d/matrix/Boxplot.d.ts +6 -0
  7. package/lib/component/1d/matrix/Boxplot.js +97 -0
  8. package/lib/component/1d/matrix/Stocsy.d.ts +5 -0
  9. package/lib/component/1d/matrix/Stocsy.js +101 -0
  10. package/lib/component/1d/matrix/useMatrix.d.ts +29 -0
  11. package/lib/component/1d/matrix/useMatrix.js +93 -0
  12. package/lib/component/1d/peaks/PeakAnnotationsSpreadMode.d.ts +0 -1
  13. package/lib/component/1d/peaks/PeakEditionManager.js +16 -10
  14. package/lib/component/1d/utilities/getDecimalsCount.js +1 -1
  15. package/lib/component/1d/utilities/intersectionResolver.js +1 -1
  16. package/lib/component/1d/utilities/scale.d.ts +2 -1
  17. package/lib/component/1d/utilities/scale.js +6 -1
  18. package/lib/component/1d-2d/FieldEdition.d.ts +3 -1
  19. package/lib/component/1d-2d/FieldEdition.js +26 -10
  20. package/lib/component/2d/1d-tracer/Left1DChart.d.ts +0 -1
  21. package/lib/component/2d/1d-tracer/Top1DChart.d.ts +0 -1
  22. package/lib/component/2d/XAxis.d.ts +0 -1
  23. package/lib/component/2d/YAxis.d.ts +0 -1
  24. package/lib/component/2d/ft/Contours.js +7 -7
  25. package/lib/component/assignment/AssignmentsContext.d.ts +0 -1
  26. package/lib/component/context/ChartContext.d.ts +0 -1
  27. package/lib/component/context/DispatchContext.d.ts +0 -1
  28. package/lib/component/context/GlobalContext.d.ts +0 -1
  29. package/lib/component/context/KeyModifierContext.js +1 -1
  30. package/lib/component/context/LoaderContext.d.ts +0 -1
  31. package/lib/component/context/PreferencesContext.d.ts +0 -1
  32. package/lib/component/context/PrepareExportContext.d.ts +21 -0
  33. package/lib/component/context/PrepareExportContext.js +124 -0
  34. package/lib/component/context/ScaleContext.d.ts +0 -1
  35. package/lib/component/elements/ActionButtons.d.ts +1 -0
  36. package/lib/component/elements/ActionButtons.js +4 -4
  37. package/lib/component/elements/ColorInput.d.ts +0 -1
  38. package/lib/component/elements/ColorPickerDropdownController.d.ts +2 -0
  39. package/lib/component/elements/ColorPickerDropdownController.js +8 -0
  40. package/lib/component/elements/ColumnWrapper.d.ts +0 -1
  41. package/lib/component/elements/ContextMenu.d.ts +0 -1
  42. package/lib/component/elements/Input.d.ts +1 -0
  43. package/lib/component/elements/Input.js +2 -1
  44. package/lib/component/elements/Input2.d.ts +13 -0
  45. package/lib/component/elements/Input2.js +118 -0
  46. package/lib/component/elements/Input2Controller.d.ts +12 -0
  47. package/lib/component/elements/Input2Controller.js +22 -0
  48. package/lib/component/elements/MoleculeSelection.js +1 -1
  49. package/lib/component/elements/NumberInput.js +1 -1
  50. package/lib/component/elements/NumberInput2.d.ts +12 -0
  51. package/lib/component/elements/NumberInput2.js +65 -0
  52. package/lib/component/elements/NumberInput2Controller.d.ts +8 -0
  53. package/lib/component/elements/NumberInput2Controller.js +15 -0
  54. package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +3 -3
  55. package/lib/component/elements/ReactTable/Style.d.ts +3 -1
  56. package/lib/component/elements/ReactTable/Style.js +11 -1
  57. package/lib/component/elements/ReactTable/utility/ReactTableContext.d.ts +0 -1
  58. package/lib/component/elements/Select2.d.ts +26 -0
  59. package/lib/component/elements/Select2.js +25 -0
  60. package/lib/component/elements/Select2Controller.d.ts +7 -0
  61. package/lib/component/elements/Select2Controller.js +12 -0
  62. package/lib/component/elements/draggable/useDraggable.d.ts +0 -1
  63. package/lib/component/elements/dropDownButton/DropDownButton.d.ts +2 -4
  64. package/lib/component/elements/dropDownButton/DropDownButton.js +11 -37
  65. package/lib/component/elements/dropDownButton/DropDownList.js +3 -32
  66. package/lib/component/elements/formik/FormikColorPicker.d.ts +0 -1
  67. package/lib/component/elements/formik/FormikColumnFormatField.d.ts +0 -1
  68. package/lib/component/elements/formik/FormikInput.d.ts +0 -1
  69. package/lib/component/elements/formik/FormikInput2.d.ts +11 -0
  70. package/lib/component/elements/formik/FormikInput2.js +26 -0
  71. package/lib/component/elements/formik/FormikOnChange.d.ts +0 -1
  72. package/lib/component/elements/popup/Modal/Context.d.ts +0 -1
  73. package/lib/component/elements/popup/Modal/ModalContent.d.ts +0 -1
  74. package/lib/component/elements/resizer/SVGResizer.d.ts +0 -1
  75. package/lib/component/elements/useFormValidateField.d.ts +1 -0
  76. package/lib/component/elements/useFormValidateField.js +9 -0
  77. package/lib/component/header/ApodizationOptionsPanel.js +26 -11
  78. package/lib/component/header/AutoPeakPickingOptionPanel.d.ts +1 -4
  79. package/lib/component/header/AutoPeakPickingOptionPanel.js +16 -16
  80. package/lib/component/header/BaseLineCorrectionPanel.js +49 -27
  81. package/lib/component/header/Header.js +1 -1
  82. package/lib/component/header/PhaseCorrectionPanel.js +12 -24
  83. package/lib/component/header/RangesPickingOptionPanel.js +12 -12
  84. package/lib/component/header/ZeroFillingOptionsPanel.js +18 -7
  85. package/lib/component/header/Zones2DOptionPanel.js +19 -18
  86. package/lib/component/hooks/useExport.d.ts +1 -1
  87. package/lib/component/hooks/useExport.js +4 -4
  88. package/lib/component/hooks/usePanelPreferences.d.ts +2 -3
  89. package/lib/component/hooks/usePanelPreferences.js +3 -1
  90. package/lib/component/hooks/useToggleSpectraVisibility.d.ts +10 -0
  91. package/lib/component/hooks/useToggleSpectraVisibility.js +41 -0
  92. package/lib/component/hooks/useWorkspaceAction.d.ts +1 -1
  93. package/lib/component/modal/editRange/forms/components/SignalTab.d.ts +0 -1
  94. package/lib/component/modal/editRange/forms/components/SignalsContent.d.ts +0 -1
  95. package/lib/component/modal/setting/GeneralSettings.d.ts +5 -1
  96. package/lib/component/modal/setting/GeneralSettings.js +107 -111
  97. package/lib/component/modal/setting/WorkspaceItem.js +4 -9
  98. package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.d.ts +1 -1
  99. package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.js +95 -59
  100. package/lib/component/modal/setting/settings-tabs/DisplayTabContent.js +33 -25
  101. package/lib/component/modal/setting/settings-tabs/GeneralTabContent.js +15 -4
  102. package/lib/component/modal/setting/settings-tabs/ImportationFiltersTabContent.js +56 -39
  103. package/lib/component/modal/setting/settings-tabs/InfoBlockTabContent.js +36 -36
  104. package/lib/component/modal/setting/settings-tabs/NucleiTabContent.js +44 -36
  105. package/lib/component/modal/setting/settings-tabs/OnLoadProcessingTabContent.js +16 -11
  106. package/lib/component/modal/setting/settings-tabs/SpectraColorsTabContent.js +47 -40
  107. package/lib/component/modal/setting/settings-tabs/ToolsTabContent.js +50 -40
  108. package/lib/component/modal/setting/settingsValidation.js +8 -34
  109. package/lib/component/panels/AutomaticAssignment/AutomaticAssignmentTable.d.ts +0 -1
  110. package/lib/component/panels/IntegralsPanel/IntegralTable.d.ts +0 -1
  111. package/lib/component/panels/IntegralsPanel/IntegralsPreferences.d.ts +0 -1
  112. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.d.ts +2 -2
  113. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +121 -36
  114. package/lib/component/panels/Panels.js +32 -9
  115. package/lib/component/panels/PeaksPanel/PeaksPreferences.d.ts +0 -1
  116. package/lib/component/panels/PeaksPanel/PeaksTable.d.ts +0 -1
  117. package/lib/component/panels/RangesPanel/RangesPreferences.d.ts +0 -1
  118. package/lib/component/panels/RangesPanel/TableColumns/RangeAssignmentsColumn.d.ts +0 -1
  119. package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +4 -27
  120. package/lib/component/panels/SpectraPanel/SpectraPreferences.d.ts +0 -1
  121. package/lib/component/panels/SpectraPanel/SpectraPreferences.js +32 -24
  122. package/lib/component/panels/SpectraPanel/SpectraTable.js +17 -2
  123. package/lib/component/panels/SpectraPanel/SpectrumListPanel.d.ts +0 -1
  124. package/lib/component/panels/SpectraPanel/base/ColorIndicator.d.ts +0 -1
  125. package/lib/component/panels/SpectraPanel/base/SpectraColumnsManager.d.ts +3 -3
  126. package/lib/component/panels/SpectraPanel/base/SpectraColumnsManager.js +25 -16
  127. package/lib/component/panels/SpectraPanel/base/setting/Spectrum1DHistogram.d.ts +0 -1
  128. package/lib/component/panels/SpectraPanel/base/setting/Spectrum1DSetting.js +15 -5
  129. package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DHistogram.d.ts +0 -1
  130. package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DSetting.js +44 -6
  131. package/lib/component/panels/SpectraPanel/base/setting/SpectrumSetting.d.ts +0 -1
  132. package/lib/component/panels/SummaryPanel/Overview.d.ts +0 -1
  133. package/lib/component/panels/SummaryPanel/SummaryPanel.d.ts +0 -1
  134. package/lib/component/panels/SummaryPanel/utilities/Utilities.d.ts +1 -1
  135. package/lib/component/panels/ZonesPanel/ZonesPreferences.d.ts +0 -1
  136. package/lib/component/panels/databasePanel/DatabasePanel.js +17 -3
  137. package/lib/component/panels/databasePanel/DatabasePreferences.d.ts +0 -1
  138. package/lib/component/panels/databasePanel/DatabaseTable.d.ts +11 -4
  139. package/lib/component/panels/databasePanel/DatabaseTable.js +22 -7
  140. package/lib/component/panels/informationPanel/InformationEditionModal.d.ts +6 -0
  141. package/lib/component/panels/informationPanel/InformationEditionModal.js +105 -0
  142. package/lib/component/panels/informationPanel/InformationPanel.d.ts +1 -0
  143. package/lib/component/panels/{InformationPanel.js → informationPanel/InformationPanel.js} +2 -2
  144. package/lib/component/panels/multipleAnalysisPanel/preferences/MultipleAnalysisCodeEditor.d.ts +0 -1
  145. package/lib/component/panels/multipleAnalysisPanel/preferences/index.d.ts +0 -1
  146. package/lib/component/panels/predictionPanel/PredictionOptionsPanel.d.ts +0 -1
  147. package/lib/component/panels/predictionPanel/PredictionOptionsPanel.js +1 -1
  148. package/lib/component/panels/predictionPanel/PredictionPreferences.d.ts +0 -1
  149. package/lib/component/panels/spectrumSimulation/SpectrumSimulationPreferences.d.ts +0 -1
  150. package/lib/component/reducer/Reducer.d.ts +7 -1
  151. package/lib/component/reducer/Reducer.js +2 -0
  152. package/lib/component/reducer/actions/DatabaseActions.js +22 -5
  153. package/lib/component/reducer/actions/DomainActions.d.ts +5 -2
  154. package/lib/component/reducer/actions/DomainActions.js +6 -4
  155. package/lib/component/reducer/actions/FiltersActions.js +2 -2
  156. package/lib/component/reducer/actions/LoadActions.js +5 -2
  157. package/lib/component/reducer/actions/SpectraActions.d.ts +9 -2
  158. package/lib/component/reducer/actions/SpectraActions.js +65 -23
  159. package/lib/component/reducer/actions/ToolsActions.js +3 -4
  160. package/lib/component/reducer/preferences/actions/matrixGeneration.d.ts +47 -2
  161. package/lib/component/reducer/preferences/actions/matrixGeneration.js +62 -25
  162. package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.d.ts +11 -8
  163. package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +19 -1
  164. package/lib/component/reducer/preferences/preferencesReducer.d.ts +3 -26
  165. package/lib/component/reducer/preferences/preferencesReducer.js +7 -1
  166. package/lib/component/toolbar/ToolBar.js +6 -7
  167. package/lib/component/utility/PathBuilder.d.ts +1 -0
  168. package/lib/component/utility/PathBuilder.js +8 -1
  169. package/lib/component/utility/checkUniqueByKey.d.ts +2 -0
  170. package/lib/component/utility/checkUniqueByKey.js +40 -0
  171. package/lib/component/utility/colorToHexWithAlpha.d.ts +9 -0
  172. package/lib/component/utility/colorToHexWithAlpha.js +4 -0
  173. package/lib/component/workspaces/exercise.js +2 -0
  174. package/lib/component/workspaces/process1D.js +0 -1
  175. package/lib/component/workspaces/workspaceDefaultProperties.js +1 -0
  176. package/lib/data/PredictionManager.js +3 -5
  177. package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +13 -13
  178. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +9 -9
  179. package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +13 -13
  180. package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +13 -13
  181. package/lib/data/data1d/database.d.ts +1 -0
  182. package/lib/data/data1d/database.js +4 -2
  183. package/lib/data/data2d/Spectrum2D/contours.d.ts +8 -22
  184. package/lib/data/data2d/Spectrum2D/contours.js +88 -67
  185. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +4 -2
  186. package/lib/data/data2d/Spectrum2D/zones/detectZonesManual.d.ts +20 -20
  187. package/lib/data/data2d/Spectrum2D/zones/initiateZones.d.ts +20 -20
  188. package/lib/data/getDefaultMatrixFilters.d.ts +1 -1
  189. package/lib/data/initiateFilters.d.ts +1 -1
  190. package/lib/data/matrixGeneration.js +1 -2
  191. package/lib/data/types/common/DeepPartial.d.ts +3 -0
  192. package/lib/data/types/common/DeepPartial.js +1 -0
  193. package/lib/data/types/common/Keys.d.ts +3 -0
  194. package/lib/data/types/common/Keys.js +1 -0
  195. package/lib/data/utilities/generateNumbersPowerOfX.d.ts +2 -2
  196. package/lib/versionInfo.js +1 -1
  197. package/package.json +39 -38
  198. package/lib/component/elements/CustomToolTip.d.ts +0 -8
  199. package/lib/component/elements/CustomToolTip.js +0 -107
  200. package/lib/component/elements/formik/FormikSlider.d.ts +0 -6
  201. package/lib/component/elements/formik/FormikSlider.js +0 -15
  202. package/lib/component/panels/InformationPanel.d.ts +0 -1
@@ -1,107 +1,117 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { CheckBoxCell } from '../../../elements/CheckBoxCell';
2
+ import { Checkbox } from '@blueprintjs/core';
3
+ import { useMemo } from 'react';
4
+ import { useFormContext } from 'react-hook-form';
3
5
  import ReactTable from '../../../elements/ReactTable/ReactTable';
4
6
  const LIST = [
5
7
  {
6
8
  label: 'Zoom in',
7
- name: 'toolBarButtons.zoom',
9
+ name: 'zoom',
8
10
  },
9
11
  {
10
12
  label: 'Zoom out',
11
- name: 'toolBarButtons.zoomOut',
13
+ name: 'zoomOut',
12
14
  },
13
15
  {
14
16
  label: 'Import',
15
- name: 'toolBarButtons.import',
17
+ name: 'import',
16
18
  },
17
19
  {
18
20
  label: 'Export As',
19
- name: 'toolBarButtons.exportAs',
21
+ name: 'exportAs',
20
22
  },
21
23
  {
22
24
  label: 'Stack Alignments',
23
- name: 'toolBarButtons.spectraStackAlignments',
25
+ name: 'spectraStackAlignments',
24
26
  },
25
27
  {
26
28
  label: 'Center Alignments',
27
- name: 'toolBarButtons.spectraCenterAlignments',
29
+ name: 'spectraCenterAlignments',
28
30
  },
29
31
  {
30
32
  label: 'Real/Imaginary ',
31
- name: 'toolBarButtons.realImaginary',
33
+ name: 'realImaginary',
32
34
  },
33
35
  {
34
36
  label: 'Peak picking',
35
- name: 'toolBarButtons.peakPicking',
37
+ name: 'peakPicking',
36
38
  },
37
39
  {
38
40
  label: 'Integral',
39
- name: 'toolBarButtons.integral',
41
+ name: 'integral',
40
42
  },
41
43
  {
42
44
  label: 'Zone Picking',
43
- name: 'toolBarButtons.zonePicking',
45
+ name: 'zonePicking',
44
46
  },
45
47
  {
46
48
  label: 'Range picking',
47
- name: 'toolBarButtons.rangePicking',
49
+ name: 'rangePicking',
48
50
  },
49
51
  {
50
52
  label: 'Slicing',
51
- name: 'toolBarButtons.slicing',
53
+ name: 'slicing',
52
54
  },
53
55
  {
54
56
  label: 'Apodization',
55
- name: 'toolBarButtons.apodization',
57
+ name: 'apodization',
56
58
  },
57
59
  {
58
60
  label: 'Zero filling',
59
- name: 'toolBarButtons.zeroFilling',
61
+ name: 'zeroFilling',
60
62
  },
61
63
  {
62
64
  label: 'Fourier transform',
63
- name: 'toolBarButtons.fft',
65
+ name: 'fft',
64
66
  },
65
67
  {
66
68
  label: 'Phase correction',
67
- name: 'toolBarButtons.phaseCorrection',
69
+ name: 'phaseCorrection',
68
70
  },
69
71
  {
70
72
  label: 'Baseline correction',
71
- name: 'toolBarButtons.baselineCorrection',
73
+ name: 'baselineCorrection',
72
74
  },
73
75
  {
74
76
  label: 'Exclusion zones',
75
- name: 'toolBarButtons.exclusionZones',
77
+ name: 'exclusionZones',
76
78
  },
77
79
  {
78
80
  label: 'Multiple spectra analysis',
79
- name: 'toolBarButtons.multipleSpectraAnalysis',
81
+ name: 'multipleSpectraAnalysis',
80
82
  },
81
83
  {
82
84
  label: 'Auto range and zone picking',
83
- name: 'toolBarButtons.autoRangeAndZonePicking',
84
- },
85
- ];
86
- const COLUMNS = [
87
- {
88
- index: 1,
89
- Header: '#',
90
- accessor: (_, index) => index + 1,
91
- },
92
- {
93
- index: 1,
94
- Header: 'Tool',
95
- accessor: 'label',
96
- style: { width: '60%' },
97
- },
98
- {
99
- index: 2,
100
- Header: 'Active',
101
- Cell: ({ row }) => (_jsx(CheckBoxCell, { name: `display.${row.original.name}`, defaultValue: false })),
85
+ name: 'autoRangeAndZonePicking',
102
86
  },
103
87
  ];
104
88
  function ToolsTabContent() {
105
- return (_jsx("div", { style: { width: '100%', overflow: 'hidden' }, children: _jsx(ReactTable, { columns: COLUMNS, data: LIST }) }));
89
+ const { register } = useFormContext();
90
+ const COLUMNS = useMemo(() => [
91
+ {
92
+ index: 1,
93
+ Header: '#',
94
+ accessor: (_, index) => index + 1,
95
+ },
96
+ {
97
+ index: 1,
98
+ Header: 'Tool',
99
+ accessor: 'label',
100
+ style: { width: '60%' },
101
+ },
102
+ {
103
+ index: 2,
104
+ Header: 'Active',
105
+ style: { textAlign: 'center' },
106
+ Cell: ({ row }) => {
107
+ const name = `display.toolBarButtons.${row.original.name}`;
108
+ return (_jsx(Checkbox, { style: { margin: 0 }, ...register(name), defaultChecked: false }));
109
+ },
110
+ },
111
+ ], [register]);
112
+ return (_jsx("div", { style: { width: '100%', overflow: 'hidden' }, children: _jsx(ReactTable, { columns: COLUMNS, data: LIST, rowStyle: {
113
+ hover: { backgroundColor: '#f7f7f7' },
114
+ active: { backgroundColor: '#f5f5f5' },
115
+ } }) }));
106
116
  }
107
117
  export default ToolsTabContent;
@@ -1,40 +1,14 @@
1
- import { array, object, string, ValidationError, number } from 'yup';
1
+ import { array, object, string, number } from 'yup';
2
+ import { checkUniqueByKey } from '../../utility/checkUniqueByKey';
2
3
  const nucleiValidation = array()
3
4
  .of(object().shape({
4
- nucleus: string().trim().required('Nucleus is a required field'),
5
- ppmFormat: string().trim().required('PPM format is a required field'),
6
- hzFormat: string().trim().required('Hz format is a required field'),
5
+ nucleus: string().required('Nucleus is a required field'),
6
+ ppmFormat: string().required('PPM format is a required field'),
7
+ hzFormat: string().required('Hz format is a required field'),
7
8
  }))
8
9
  .test('Unique', 'Nuclei need te be unique', function check(nuclei) {
9
- if (!nuclei)
10
- return true;
11
- const nucleusFrequencies = {};
12
- let index = 0;
13
- for (const nucleiPreferences of nuclei) {
14
- const key = nucleiPreferences.nucleus?.toLowerCase() || '';
15
- if (key) {
16
- if (nucleusFrequencies[key]) {
17
- ++nucleusFrequencies[key].value;
18
- nucleusFrequencies[key].fieldsIndexes.push(index);
19
- }
20
- else {
21
- nucleusFrequencies[key] = { value: 1, fieldsIndexes: [index] };
22
- }
23
- }
24
- index++;
25
- }
26
- const errors = [];
27
- for (const key in nucleusFrequencies) {
28
- const { value, fieldsIndexes } = nucleusFrequencies[key];
29
- if (value > 1) {
30
- for (const index of fieldsIndexes) {
31
- errors.push(new ValidationError(`${key} nucleus must te be unique`, nuclei[index].nucleus,
32
- // eslint-disable-next-line no-invalid-this
33
- `${this.path}.${index}.name`));
34
- }
35
- }
36
- }
37
- return new ValidationError(errors);
10
+ // eslint-disable-next-line no-invalid-this
11
+ return checkUniqueByKey(nuclei, 'nucleus', this);
38
12
  });
39
13
  const databasesValidation = object().shape({
40
14
  data: array().of(object().shape({
@@ -59,7 +33,7 @@ const spectraColorsSchemaValidation = object({
59
33
  })),
60
34
  });
61
35
  const generalValidation = object({
62
- dimmedSpectraOpacity: number().required(),
36
+ dimmedSpectraOpacity: number().min(0).max(1).required(),
63
37
  });
64
38
  export const validation = object().shape({
65
39
  nuclei: nucleiValidation,
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { AutoAssignmentsData } from './useAutoAssignments';
3
2
  interface AutomaticAssignmentTableProps {
4
3
  data: AutoAssignmentsData[];
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Info1D, Integral } from 'nmr-processing';
3
2
  import { IntegralPanelInnerProps } from './IntegralPanel';
4
3
  interface IntegralTableProps extends Pick<IntegralPanelInnerProps, 'activeTab'> {
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  declare const _default: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Omit<any, "ref"> & import("react").RefAttributes<unknown>>>;
3
2
  export default _default;
@@ -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;
@@ -1,14 +1,15 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import lodashGet from 'lodash/get';
3
3
  import { useCallback, memo } from 'react';
4
- import { Accordion } from 'react-science/ui';
4
+ import { FaRegEdit } from 'react-icons/fa';
5
+ import { Accordion, Toolbar, } from 'react-science/ui';
5
6
  import { useChartData } from '../context/ChartContext';
6
7
  import { usePreferences } from '../context/PreferencesContext';
7
8
  import useCheckExperimentalFeature from '../hooks/useCheckExperimentalFeature';
9
+ import { useDialogToggle } from '../hooks/useDialogToggle';
8
10
  import AutomaticAssignment from './AutomaticAssignment/AutomaticAssignment';
9
- import InformationPanel from './InformationPanel';
10
11
  import IntegralPanel from './IntegralsPanel/IntegralPanel';
11
- import MatrixGenerationPanel from './MatrixGenerationPanel/MatrixGenerationPanel';
12
+ import { MatrixGenerationPanel } from './MatrixGenerationPanel/MatrixGenerationPanel';
12
13
  import MoleculePanel from './MoleculesPanel/MoleculePanel';
13
14
  import PeaksPanel from './PeaksPanel/PeaksPanel';
14
15
  import RangesPanel from './RangesPanel/RangesPanel';
@@ -17,6 +18,8 @@ import SummaryPanel from './SummaryPanel/SummaryPanel';
17
18
  import ZonesPanel from './ZonesPanel/ZonesPanel';
18
19
  import DatabasePanel from './databasePanel/DatabasePanel';
19
20
  import FilterPanel from './filtersPanel/FilterPanel';
21
+ import { InformationEditionModal } from './informationPanel/InformationEditionModal';
22
+ import { InformationPanel } from './informationPanel/InformationPanel';
20
23
  import MultipleSpectraAnalysisPanel from './multipleAnalysisPanel/MultipleSpectraAnalysisPanel';
21
24
  import PredictionPane from './predictionPanel/PredictionPanel';
22
25
  import SpectrumSimulation from './spectrumSimulation/SpectrumSimulation';
@@ -28,6 +31,7 @@ const accordionItems = [
28
31
  mode: null,
29
32
  },
30
33
  {
34
+ id: 'informationPanel',
31
35
  title: 'Information',
32
36
  component: _jsx(InformationPanel, {}),
33
37
  style: { overflow: 'hidden' },
@@ -140,6 +144,9 @@ function usePanelPreferences() {
140
144
  function PanelsInner({ displayerMode: displayedMode }) {
141
145
  const getPanelPreferences = usePanelPreferences();
142
146
  const isExperimental = useCheckExperimentalFeature();
147
+ const { dialog, openDialog, closeDialog } = useDialogToggle({
148
+ informationModal: false,
149
+ });
143
150
  const check = useCallback((item) => {
144
151
  const panelOptions = getPanelPreferences(item);
145
152
  return ((panelOptions?.display &&
@@ -147,13 +154,29 @@ function PanelsInner({ displayerMode: displayedMode }) {
147
154
  (item.mode == null || item.mode === displayedMode)) ||
148
155
  (item.isExperimental && isExperimental));
149
156
  }, [displayedMode, getPanelPreferences, isExperimental]);
150
- const isOpened = useCallback((item) => {
157
+ function isOpened(item) {
151
158
  const panelOptions = getPanelPreferences(item);
152
159
  return panelOptions?.display && panelOptions?.open;
153
- }, [getPanelPreferences]);
154
- return (_jsx("div", { style: { width: '100%', height: '100%', flex: '1 1 0%' }, children: _jsx(Accordion, { children: accordionItems.map((item) => {
155
- return (check(item) && (_jsx(Accordion.Item, { title: item.title, defaultOpened: isOpened(item), children: item.component }, item.title)));
156
- }) }) }));
160
+ }
161
+ const toolbars = {
162
+ informationPanel: [
163
+ {
164
+ icon: _jsx(FaRegEdit, {}),
165
+ onClick: ({ event }) => {
166
+ event.stopPropagation();
167
+ openDialog('informationModal');
168
+ },
169
+ },
170
+ ],
171
+ };
172
+ return (_jsxs("div", { style: { width: '100%', height: '100%', flex: '1 1 0%' }, children: [_jsx(InformationEditionModal, { isOpen: dialog.informationModal, onCloseDialog: closeDialog }), _jsx(Accordion, { children: accordionItems.map((item) => {
173
+ const { title, component, id } = item;
174
+ let toolbar;
175
+ if (id && toolbars[id]) {
176
+ toolbar = (_jsx(Toolbar, { children: toolbars[id]?.map((options, index) => (_jsx(Toolbar.Item, { ...options }, index))) }));
177
+ }
178
+ return (check(item) && (_jsx(Accordion.Item, { title: title, defaultOpened: isOpened(item), toolbar: toolbar, children: component }, title)));
179
+ }) })] }));
157
180
  }
158
181
  const MemoizedPanels = memo(PanelsInner);
159
182
  export default function Panels() {
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  declare const _default: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Omit<any, "ref"> & import("react").RefAttributes<unknown>>>;
3
2
  export default _default;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Info1D } from 'nmr-processing';
3
2
  import { PeakRecord } from './PeaksPanel';
4
3
  interface PeaksTableProps {
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  declare const _default: import("react").ForwardRefExoticComponent<Omit<any, "ref"> & import("react").RefAttributes<unknown>>;
3
2
  export default _default;
@@ -1,5 +1,4 @@
1
1
  /** @jsxImportSource @emotion/react */
2
- /// <reference types="react" />
3
2
  import { AssignmentsData } from '../../../assignment/AssignmentsContext';
4
3
  import { RangeColumnProps } from '../RangesTableRow';
5
4
  interface RemoveAssignmentsButtonProps {
@@ -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, {}),
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  declare const _default: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Omit<any, "ref"> & import("react").RefAttributes<unknown>>>;
3
2
  export default _default;