nmrium 0.54.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 (142) 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/XAxis.js +1 -1
  4. package/lib/component/1d/integral/IntegralsSeries.js +2 -2
  5. package/lib/component/1d/integral/Integration.d.ts +3 -1
  6. package/lib/component/1d/integral/Integration.js +3 -2
  7. package/lib/component/1d/matrix/Boxplot.d.ts +6 -0
  8. package/lib/component/1d/matrix/Boxplot.js +97 -0
  9. package/lib/component/1d/matrix/Stocsy.d.ts +5 -0
  10. package/lib/component/1d/matrix/Stocsy.js +101 -0
  11. package/lib/component/1d/matrix/useMatrix.d.ts +29 -0
  12. package/lib/component/1d/matrix/useMatrix.js +93 -0
  13. package/lib/component/1d/peaks/PeakEditionManager.js +5 -3
  14. package/lib/component/1d/ranges/AssignmentActionsButtons.d.ts +1 -0
  15. package/lib/component/1d/ranges/AssignmentActionsButtons.js +3 -3
  16. package/lib/component/1d/ranges/AssignmentLabel.d.ts +1 -1
  17. package/lib/component/1d/ranges/AssignmentLabel.js +31 -4
  18. package/lib/component/1d/ranges/Atoms.js +4 -5
  19. package/lib/component/1d/ranges/Range.js +48 -6
  20. package/lib/component/1d/ranges/Ranges.js +2 -1
  21. package/lib/component/1d/ranges/RangesIntegrals.js +11 -4
  22. package/lib/component/1d/utilities/scale.d.ts +2 -1
  23. package/lib/component/1d/utilities/scale.js +6 -1
  24. package/lib/component/1d-2d/FieldEdition.d.ts +13 -0
  25. package/lib/component/1d-2d/FieldEdition.js +42 -0
  26. package/lib/component/2d/Chart2D.js +5 -3
  27. package/lib/component/2d/zones/Zone.js +18 -2
  28. package/lib/component/2d/zones/ZonesAssignmentsLabels.d.ts +7 -0
  29. package/lib/component/2d/zones/ZonesAssignmentsLabels.js +286 -0
  30. package/lib/component/EventsTrackers/KeysListenerTracker.js +14 -1
  31. package/lib/component/context/PrepareExportContext.d.ts +21 -0
  32. package/lib/component/context/PrepareExportContext.js +124 -0
  33. package/lib/component/context/ShareDataContext.d.ts +10 -0
  34. package/lib/component/context/ShareDataContext.js +22 -0
  35. package/lib/component/elements/ActionsButtonsPopover.d.ts +10 -0
  36. package/lib/component/elements/ActionsButtonsPopover.js +22 -0
  37. package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +7 -5
  38. package/lib/component/elements/ReactTable/ReactTable.d.ts +2 -2
  39. package/lib/component/elements/SVGButton.d.ts +14 -0
  40. package/lib/component/elements/SVGButton.js +6 -0
  41. package/lib/component/elements/SVGGroup.js +15 -13
  42. package/lib/component/elements/SVGText.d.ts +8 -0
  43. package/lib/component/elements/SVGText.js +24 -0
  44. package/lib/component/elements/draggable/SVGDraggable.d.ts +2 -2
  45. package/lib/component/elements/formik/FormikInput.d.ts +2 -1
  46. package/lib/component/elements/formik/FormikInput.js +4 -3
  47. package/lib/component/header/Header.js +7 -10
  48. package/lib/component/hooks/useActiveSpectrumZonesViewState.js +1 -0
  49. package/lib/component/hooks/useCheckPointsNumberInWindowArea.d.ts +1 -1
  50. package/lib/component/hooks/useExport.d.ts +1 -1
  51. package/lib/component/hooks/useExport.js +4 -4
  52. package/lib/component/hooks/useFormatNumberByNucleus.d.ts +1 -1
  53. package/lib/component/hooks/useFormatNumberByNucleus.js +8 -7
  54. package/lib/component/hooks/useIntegralPath.d.ts +2 -0
  55. package/lib/component/hooks/useIntegralPath.js +3 -1
  56. package/lib/component/hooks/usePanelPreferences.d.ts +2 -3
  57. package/lib/component/hooks/usePanelPreferences.js +4 -3
  58. package/lib/component/hooks/useSaveSettings.js +7 -14
  59. package/lib/component/hooks/useToggleSpectraVisibility.d.ts +10 -0
  60. package/lib/component/hooks/useToggleSpectraVisibility.js +41 -0
  61. package/lib/component/hooks/useTriggerNewAssignmentLabel.d.ts +4 -0
  62. package/lib/component/hooks/useTriggerNewAssignmentLabel.js +8 -0
  63. package/lib/component/hooks/useWorkspaceAction.d.ts +7 -0
  64. package/lib/component/hooks/useWorkspaceAction.js +89 -0
  65. package/lib/component/loader/DropZone.js +0 -3
  66. package/lib/component/main/InnerNMRium.js +3 -1
  67. package/lib/component/main/InnerNMRiumContents.js +14 -2
  68. package/lib/component/main/NMRiumStateProvider.js +4 -2
  69. package/lib/component/modal/editRange/forms/components/DeltaInput.js +3 -3
  70. package/lib/component/modal/editRange/forms/components/NewSignalTab.js +17 -12
  71. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.js +30 -13
  72. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.js +26 -16
  73. package/lib/component/modal/setting/GeneralSettings.js +7 -21
  74. package/lib/component/modal/setting/WorkspaceItem.js +1 -1
  75. package/lib/component/modal/setting/settings-tabs/NucleiTabContent.d.ts +2 -0
  76. package/lib/component/modal/setting/settings-tabs/NucleiTabContent.js +99 -0
  77. package/lib/component/modal/setting/settingsValidation.js +36 -40
  78. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.d.ts +2 -2
  79. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +121 -36
  80. package/lib/component/panels/Panels.js +1 -1
  81. package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +4 -27
  82. package/lib/component/panels/SpectraPanel/SpectraPreferences.js +13 -1
  83. package/lib/component/panels/SpectraPanel/base/setting/PlotChart.js +1 -1
  84. package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DHistogram.js +1 -1
  85. package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentLabelColumn.d.ts +6 -0
  86. package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentLabelColumn.js +16 -0
  87. package/lib/component/panels/ZonesPanel/ZonesPanel.js +18 -2
  88. package/lib/component/panels/ZonesPanel/ZonesPreferences.js +15 -9
  89. package/lib/component/panels/ZonesPanel/ZonesTable.js +2 -2
  90. package/lib/component/panels/ZonesPanel/ZonesTableRow.js +3 -2
  91. package/lib/component/panels/databasePanel/DatabaseTable.js +2 -2
  92. package/lib/component/panels/multipleAnalysisPanel/preferences/index.js +1 -1
  93. package/lib/component/reducer/IgnoreActions.js +1 -0
  94. package/lib/component/reducer/Reducer.d.ts +6 -0
  95. package/lib/component/reducer/Reducer.js +6 -0
  96. package/lib/component/reducer/actions/DomainActions.d.ts +12 -4
  97. package/lib/component/reducer/actions/DomainActions.js +35 -5
  98. package/lib/component/reducer/actions/FiltersActions.js +2 -2
  99. package/lib/component/reducer/actions/LoadActions.js +5 -2
  100. package/lib/component/reducer/actions/RangesActions.js +12 -6
  101. package/lib/component/reducer/actions/SpectraActions.d.ts +1 -0
  102. package/lib/component/reducer/actions/SpectraActions.js +7 -2
  103. package/lib/component/reducer/actions/ZonesActions.d.ts +15 -2
  104. package/lib/component/reducer/actions/ZonesActions.js +47 -13
  105. package/lib/component/reducer/helper/setRangesViewProperty.d.ts +1 -0
  106. package/lib/component/reducer/helper/setRangesViewProperty.js +11 -11
  107. package/lib/component/reducer/preferences/actions/addWorkspace.js +4 -23
  108. package/lib/component/reducer/preferences/actions/analyzeSpectra.js +4 -4
  109. package/lib/component/reducer/preferences/actions/initPreferences.js +2 -4
  110. package/lib/component/reducer/preferences/actions/matrixGeneration.d.ts +47 -2
  111. package/lib/component/reducer/preferences/actions/matrixGeneration.js +63 -26
  112. package/lib/component/reducer/preferences/actions/removeWorkspace.js +0 -5
  113. package/lib/component/reducer/preferences/actions/setActiveWorkspace.js +0 -4
  114. package/lib/component/reducer/preferences/actions/setPanelsPreferences.js +1 -1
  115. package/lib/component/reducer/preferences/actions/setPreferences.js +2 -16
  116. package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.d.ts +5 -2
  117. package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +17 -1
  118. package/lib/component/reducer/preferences/preferencesReducer.d.ts +9 -25
  119. package/lib/component/reducer/preferences/preferencesReducer.js +28 -19
  120. package/lib/component/toolbar/ToolBar.js +23 -20
  121. package/lib/component/utility/PathBuilder.d.ts +1 -0
  122. package/lib/component/utility/PathBuilder.js +8 -1
  123. package/lib/component/utility/PreferencesHelper.js +5 -4
  124. package/lib/component/utility/export.js +4 -0
  125. package/lib/component/workspaces/assignment.js +0 -1
  126. package/lib/component/workspaces/basic.js +0 -1
  127. package/lib/component/workspaces/embedded.js +0 -1
  128. package/lib/component/workspaces/exercise.js +26 -29
  129. package/lib/component/workspaces/prediction.js +171 -174
  130. package/lib/component/workspaces/process1D.js +0 -1
  131. package/lib/component/workspaces/simulation.js +35 -38
  132. package/lib/component/workspaces/workspaceDefaultProperties.js +9 -11
  133. package/lib/data/types/common/DeepPartial.d.ts +3 -0
  134. package/lib/data/types/common/DeepPartial.js +1 -0
  135. package/lib/versionInfo.js +1 -1
  136. package/package.json +39 -39
  137. package/lib/component/elements/CustomToolTip.d.ts +0 -8
  138. package/lib/component/elements/CustomToolTip.js +0 -107
  139. package/lib/component/modal/setting/settings-tabs/FormattingTabContent.d.ts +0 -2
  140. package/lib/component/modal/setting/settings-tabs/FormattingTabContent.js +0 -80
  141. package/lib/component/reducer/preferences/utilities/mapNucleiFormatting.d.ts +0 -2
  142. package/lib/component/reducer/preferences/utilities/mapNucleiFormatting.js +0 -10
@@ -15,15 +15,16 @@ import Button from '../../elements/Button';
15
15
  import Label from '../../elements/Label';
16
16
  import DropDownButton from '../../elements/dropDownButton/DropDownButton';
17
17
  import { useSaveSettings } from '../../hooks/useSaveSettings';
18
+ import { useWorkspaceAction } from '../../hooks/useWorkspaceAction';
18
19
  import { getPreferencesByWorkspace } from '../../reducer/preferences/utilities/getPreferencesByWorkspace';
19
20
  import PredefinedWorkspaces from '../../workspaces';
20
21
  import WorkspaceItem from './WorkspaceItem';
21
22
  import DatabasesTabContent from './settings-tabs/DatabasesTabContent';
22
23
  import DisplayTabContent from './settings-tabs/DisplayTabContent';
23
- import FormattingTabContent from './settings-tabs/FormattingTabContent';
24
24
  import GeneralTabContent from './settings-tabs/GeneralTabContent';
25
25
  import ImportationFiltersTabContent from './settings-tabs/ImportationFiltersTabContent';
26
26
  import InfoBlockTabContent from './settings-tabs/InfoBlockTabContent';
27
+ import NucleiTabContent from './settings-tabs/NucleiTabContent';
27
28
  import OnLoadProcessingTabContent from './settings-tabs/OnLoadProcessingTabContent';
28
29
  import SpectraColorsTabContent from './settings-tabs/SpectraColorsTabContent';
29
30
  import ToolsTabContent from './settings-tabs/ToolsTabContent';
@@ -72,6 +73,7 @@ function isRestButtonDisable(currentWorkspaceSetting, workspaceName, customWorks
72
73
  function GeneralSettingsModal({ height }) {
73
74
  const [isOpenDialog, openDialog, closeDialog] = useOnOff(false);
74
75
  const { dispatch, current: currentWorkspace, originalWorkspaces, ...preferences } = usePreferences();
76
+ const { addNewWorkspace, removeWorkspace, setActiveWorkspace } = useWorkspaceAction();
75
77
  const { saveSettings, SaveSettingsModal } = useSaveSettings();
76
78
  const toaster = useToaster();
77
79
  const refForm = useRef(null);
@@ -96,13 +98,7 @@ function GeneralSettingsModal({ height }) {
96
98
  closeDialog?.();
97
99
  }
98
100
  function addWorkSpaceHandler(name) {
99
- dispatch({
100
- type: 'ADD_WORKSPACE',
101
- payload: {
102
- workspaceKey: name,
103
- data: refForm.current?.values,
104
- },
105
- });
101
+ addNewWorkspace(name, refForm.current?.values);
106
102
  }
107
103
  async function applyPreferencesHandler() {
108
104
  const errors = await refForm.current?.validateForm();
@@ -120,20 +116,10 @@ function GeneralSettingsModal({ height }) {
120
116
  }
121
117
  }
122
118
  function deleteWorkSpaceHandler(key) {
123
- dispatch({
124
- type: 'REMOVE_WORKSPACE',
125
- payload: {
126
- workspace: key,
127
- },
128
- });
119
+ removeWorkspace(key);
129
120
  }
130
121
  function ChangeWorkspaceHandler(option) {
131
- dispatch({
132
- type: 'SET_ACTIVE_WORKSPACE',
133
- payload: {
134
- workspace: option.key,
135
- },
136
- });
122
+ setActiveWorkspace(option.key);
137
123
  }
138
124
  function renderItem(item) {
139
125
  return (_jsx(WorkspaceItem, { item: item, onSave: addWorkSpaceHandler, onDelete: deleteWorkSpaceHandler }));
@@ -211,7 +197,7 @@ function GeneralSettingsModal({ height }) {
211
197
  overflow: auto;
212
198
  max-height: 100%;
213
199
  }
214
- `, fill: true, children: [_jsx(Tab, { title: "General", id: "general", panel: _jsx(GeneralTabContent, {}) }), _jsx(Tab, { title: "Formatting", id: "formatting", panel: _jsx(FormattingTabContent, {}) }), _jsx(Tab, { title: "Panels", id: "display", panel: _jsx(DisplayTabContent, {}) }), _jsx(Tab, { title: "Tools", id: "tools", panel: _jsx(ToolsTabContent, {}) }), _jsx(Tab, { title: "Databases", id: "databases", panel: _jsx(DatabasesTabContent, { currentWorkspace: workspaceName, originalWorkspaces: originalWorkspaces }) }), _jsx(Tab, { title: "Import filters", id: "importation-filters", panel: _jsx(ImportationFiltersTabContent, {}) }), _jsx(Tab, { title: "Title block", id: "title-block", panel: _jsx(InfoBlockTabContent, {}) }), _jsx(Tab, { title: "Auto processing", id: "on-load-processing", panel: _jsx(OnLoadProcessingTabContent, {}) }), _jsx(Tab, { title: "Spectra colors", id: "spectra-colors", panel: _jsx(SpectraColorsTabContent, {}) })] }) }) }) }), _jsx(DialogFooter, { children: _jsxs("div", { style: { display: 'flex', justifyContent: 'flex-end' }, children: [_jsx(ActionButtons, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: () => refForm.current?.submitForm(), doneLabel: "Apply and Save", onCancel: () => {
200
+ `, fill: true, children: [_jsx(Tab, { title: "General", id: "general", panel: _jsx(GeneralTabContent, {}) }), _jsx(Tab, { title: "Nuclei", id: "nuclei", panel: _jsx(NucleiTabContent, {}) }), _jsx(Tab, { title: "Panels", id: "display", panel: _jsx(DisplayTabContent, {}) }), _jsx(Tab, { title: "Tools", id: "tools", panel: _jsx(ToolsTabContent, {}) }), _jsx(Tab, { title: "Databases", id: "databases", panel: _jsx(DatabasesTabContent, { currentWorkspace: workspaceName, originalWorkspaces: originalWorkspaces }) }), _jsx(Tab, { title: "Import filters", id: "importation-filters", panel: _jsx(ImportationFiltersTabContent, {}) }), _jsx(Tab, { title: "Title block", id: "title-block", panel: _jsx(InfoBlockTabContent, {}) }), _jsx(Tab, { title: "Auto processing", id: "on-load-processing", panel: _jsx(OnLoadProcessingTabContent, {}) }), _jsx(Tab, { title: "Spectra colors", id: "spectra-colors", panel: _jsx(SpectraColorsTabContent, {}) })] }) }) }) }), _jsx(DialogFooter, { children: _jsxs("div", { style: { display: 'flex', justifyContent: 'flex-end' }, children: [_jsx(ActionButtons, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: () => refForm.current?.submitForm(), doneLabel: "Apply and Save", onCancel: () => {
215
201
  closeDialog?.();
216
202
  } }), _jsx(Button.Secondary, { style: { margin: '0 10px' }, onClick: applyPreferencesHandler, children: "Apply" })] }) })] }), _jsx(SaveSettingsModal, {}), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, onReadText: handlePastWorkspace, text: text, label: "Workspace" })] }));
217
203
  }
@@ -54,7 +54,7 @@ function WorkspaceItem({ item, onSave, onDelete }) {
54
54
  function onTextChange(e) {
55
55
  setName(e.target.value);
56
56
  }
57
- return (_jsx("div", { children: item.key === 'new' ? (_jsxs("div", { style: styles.newContainer, children: [_jsx("input", { style: styles.input, value: name, placeholder: "Custom workspace", onClick: (e) => e.stopPropagation(), onChange: onTextChange }), _jsx(Button.Done, { onClick: addHandler, disabled: !name, style: { fontSize: '11px' }, children: "Save" })] })) : (_jsxs("div", { style: styles.container, children: [_jsx(WorkSpaceIndicator, { source: item.source }), _jsx("span", { style: styles.workspaceName, children: item.label }), item.source !== 'user' && (_jsx("span", { style: styles.readOnly, children: "Read Only" })), item.source === 'user' && onDelete && (_jsx(Button.Danger, { onClick: deleteHandler, size: "xSmall", fill: "clear", children: _jsx(FaTimes, {}) })), item.version && !item.isReadOnly && (_jsxs("span", { style: styles.workspaceVersion, children: ["V", item.version] }))] })) }));
57
+ return (_jsx("div", { children: item.key === 'new' ? (_jsxs("div", { style: styles.newContainer, children: [_jsx("input", { style: styles.input, value: name, placeholder: "Custom workspace", onClick: (e) => e.stopPropagation(), onChange: onTextChange }), _jsx(Button.Done, { onClick: addHandler, disabled: !name, style: { fontSize: '11px' }, children: "Save" })] })) : (_jsxs("div", { style: styles.container, children: [_jsx(WorkSpaceIndicator, { source: item.source }), _jsx("span", { style: styles.workspaceName, children: item.label }), item.source !== 'user' && (_jsx("span", { style: styles.readOnly, children: "Read Only" })), item.source === 'user' && onDelete && (_jsx(Button.Danger, { onClick: deleteHandler, size: "xSmall", fill: "clear", children: _jsx(FaTimes, {}) }))] })) }));
58
58
  }
59
59
  const style = {
60
60
  width: '20px',
@@ -0,0 +1,2 @@
1
+ declare function NucleiTabContent(): import("react/jsx-runtime").JSX.Element;
2
+ export default NucleiTabContent;
@@ -0,0 +1,99 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useFormikContext } from 'formik';
3
+ import { useCallback, useMemo } from 'react';
4
+ import { FaPlus, FaTimes } from 'react-icons/fa';
5
+ import Button from '../../../elements/Button';
6
+ import { GroupPane } from '../../../elements/GroupPane';
7
+ import ReactTable from '../../../elements/ReactTable/ReactTable';
8
+ import FormikInput from '../../../elements/formik/FormikInput';
9
+ const styles = {
10
+ input: {
11
+ width: '100%',
12
+ },
13
+ column: {
14
+ padding: '2px',
15
+ },
16
+ };
17
+ function NucleiTabContent() {
18
+ const { values, setFieldValue } = useFormikContext();
19
+ const fields = values?.nuclei || [];
20
+ const addHandler = useCallback((data, index) => {
21
+ let columns = [];
22
+ const emptyField = {
23
+ nucleus: '',
24
+ ppmFormat: '0.00',
25
+ hzFormat: '0.00',
26
+ };
27
+ if (data && Array.isArray(data)) {
28
+ columns = [...data.slice(0, index), emptyField, ...data.slice(index)];
29
+ }
30
+ else {
31
+ columns.push(emptyField);
32
+ }
33
+ void setFieldValue('nuclei', columns);
34
+ }, [setFieldValue]);
35
+ const deleteHandler = useCallback((data, index) => {
36
+ const _fields = data.filter((_, columnIndex) => columnIndex !== index);
37
+ void setFieldValue('nuclei', _fields);
38
+ }, [setFieldValue]);
39
+ const COLUMNS = useMemo(() => [
40
+ {
41
+ Header: '#',
42
+ style: { width: '25px', ...styles.column },
43
+ accessor: (_, index) => index + 1,
44
+ },
45
+ {
46
+ Header: 'Nucleus',
47
+ style: { padding: 0, ...styles.column },
48
+ Cell: ({ row }) => {
49
+ return (_jsx(FormikInput, { name: `nuclei.${row.index}.nucleus`, style: { input: styles.input } }));
50
+ },
51
+ },
52
+ {
53
+ Header: 'δ (ppm)',
54
+ style: { padding: 0, ...styles.column },
55
+ Cell: ({ row }) => {
56
+ return (_jsx(FormikInput, { name: `nuclei.${row.index}.ppmFormat`, style: { input: styles.input } }));
57
+ },
58
+ },
59
+ {
60
+ Header: 'Coupling (Hz)',
61
+ style: { padding: 0, ...styles.column },
62
+ Cell: ({ row }) => {
63
+ return (_jsx(FormikInput, { name: `nuclei.${row.index}.hzFormat`, style: { input: styles.input } }));
64
+ },
65
+ },
66
+ {
67
+ Header: 'Axis from',
68
+ style: { padding: 0, ...styles.column },
69
+ Cell: ({ row }) => {
70
+ return (_jsx(FormikInput, { name: `nuclei.${row.index}.axisFrom`, style: { input: styles.input }, type: "number" }));
71
+ },
72
+ },
73
+ {
74
+ Header: 'Axis to',
75
+ style: { padding: 0, ...styles.column },
76
+ Cell: ({ row }) => {
77
+ return (_jsx(FormikInput, { name: `nuclei.${row.index}.axisTo`, style: { input: styles.input }, type: "number" }));
78
+ },
79
+ },
80
+ {
81
+ Header: '',
82
+ style: { width: '70px', ...styles.column },
83
+ id: 'add-button',
84
+ Cell: ({ data, row }) => {
85
+ return (_jsxs("div", { style: { display: 'flex', justifyContent: 'space-around' }, children: [_jsx(Button.Done, { fill: "outline", onClick: () => addHandler(data, row.index + 1), children: _jsx(FaPlus, {}) }), _jsx(Button.Danger, { fill: "outline", onClick: () => deleteHandler(data, row.index), children: _jsx(FaTimes, {}) })] }));
86
+ },
87
+ },
88
+ ], [addHandler, deleteHandler]);
89
+ return (_jsx("div", { children: _jsx(GroupPane, { text: "Number formatting for crosshair and info line and axis domain", renderHeader: (text) => {
90
+ return (_jsx(FieldsBlockHeader, { text: text, onAdd: () => addHandler(fields, 0) }));
91
+ }, children: _jsx(ReactTable, { style: {
92
+ 'table, table td, table th': { border: 'none' },
93
+ 'table thead': { borderBottom: '1px solid #f9f9f9' },
94
+ }, data: fields, columns: COLUMNS, emptyDataRowText: "No Nucleus" }) }) }));
95
+ }
96
+ function FieldsBlockHeader({ onAdd, text }) {
97
+ return (_jsxs("div", { className: "section-header", style: { display: 'flex' }, children: [_jsx("p", { style: { flex: 1 }, children: text }), _jsx(Button.Done, { fill: "outline", size: "xSmall", onClick: onAdd, children: "Add nuclei preferences" })] }));
98
+ }
99
+ export default NucleiTabContent;
@@ -1,44 +1,40 @@
1
- import { array, lazy, object, string, ValidationError, number, } from 'yup';
2
- const formattingElementValidation = (obj) => {
3
- return Object.fromEntries(Object.keys(obj.formatting.nuclei).map((key) => [
4
- key,
5
- object().shape({
6
- name: string().trim().required('Nucleus is a required field'),
7
- ppm: string().trim().required('PPM format is a required field'),
8
- hz: string().trim().required('Hz format is a required field'),
9
- }),
10
- ]));
11
- };
12
- const formattingValidation = (obj) => object().shape({
13
- nuclei: object()
14
- .shape(formattingElementValidation(obj))
15
- .test('Unique', 'Nuclei need te be unique', function check(nuclei) {
16
- const nucleusFrequencies = {};
17
- for (const key of Object.keys(nuclei)) {
18
- const _key = nuclei[key].name?.toLowerCase() || '';
19
- if (_key) {
20
- if (nucleusFrequencies[_key]) {
21
- ++nucleusFrequencies[_key].value;
22
- nucleusFrequencies[_key].fields.push(key);
23
- }
24
- else {
25
- nucleusFrequencies[_key] = { value: 1, fields: [key] };
26
- }
1
+ import { array, object, string, ValidationError, number } from 'yup';
2
+ const nucleiValidation = array()
3
+ .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'),
7
+ }))
8
+ .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] };
27
22
  }
28
23
  }
29
- const errors = [];
30
- for (const key in nucleusFrequencies) {
31
- const { value, fields } = nucleusFrequencies[key];
32
- if (value > 1) {
33
- for (const field of fields) {
34
- errors.push(new ValidationError(`${key} nucleus must te be unique`, nuclei[key].name,
35
- // eslint-disable-next-line no-invalid-this
36
- `${this.path}.${field}.name`));
37
- }
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`));
38
34
  }
39
35
  }
40
- return new ValidationError(errors);
41
- }),
36
+ }
37
+ return new ValidationError(errors);
42
38
  });
43
39
  const databasesValidation = object().shape({
44
40
  data: array().of(object().shape({
@@ -65,10 +61,10 @@ const spectraColorsSchemaValidation = object({
65
61
  const generalValidation = object({
66
62
  dimmedSpectraOpacity: number().required(),
67
63
  });
68
- export const validation = lazy((obj) => object().shape({
69
- formatting: formattingValidation(obj),
64
+ export const validation = object().shape({
65
+ nuclei: nucleiValidation,
70
66
  databases: databasesValidation,
71
67
  infoBlock: infoBlockValidation,
72
68
  general: generalValidation,
73
69
  spectraColors: spectraColorsSchemaValidation,
74
- }));
70
+ });
@@ -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, {}),
@@ -4,6 +4,7 @@ import { useImperativeHandle, useRef, memo, forwardRef, useCallback, useMemo, }
4
4
  import * as Yup from 'yup';
5
5
  import { useChartData } from '../../context/ChartContext';
6
6
  import { usePreferences } from '../../context/PreferencesContext';
7
+ import { GroupPane } from '../../elements/GroupPane';
7
8
  import { Scroller } from '../../elements/Scroller';
8
9
  import useNucleus from '../../hooks/useNucleus';
9
10
  import { usePanelPreferencesByNuclei } from '../../hooks/usePanelPreferences';
@@ -12,6 +13,17 @@ import { getSpectraObjectPaths } from '../../utility/getSpectraObjectPaths';
12
13
  import { NucleusGroup } from '../extra/preferences/NucleusGroup';
13
14
  import { PreferencesContainer } from '../extra/preferences/PreferencesContainer';
14
15
  import { SpectraColumnsManager } from './base/SpectraColumnsManager';
16
+ const groupPaneStyle = {
17
+ header: {
18
+ color: 'black',
19
+ fontSize: '12px',
20
+ padding: '5px',
21
+ backgroundColor: '#f8f8f8',
22
+ },
23
+ container: {
24
+ paddingBottom: '10px',
25
+ },
26
+ };
15
27
  function validationColumns(obj) {
16
28
  const validationObject = {};
17
29
  for (const key of Object.keys(obj.nuclei)) {
@@ -102,6 +114,6 @@ function SpectraPreferences(props, ref) {
102
114
  return key || ' ';
103
115
  }, [paths]);
104
116
  const mapValue = useCallback((value) => convertPathArrayToString(value), []);
105
- return (_jsx(PreferencesContainer, { children: _jsx(Formik, { innerRef: formRef, onSubmit: saveHandler, initialValues: preferencesByNuclei, validationSchema: spectraPreferencesValidation, children: _jsx(Scroller, { scrollTo: activeTab, children: nuclei?.map((n) => (_jsx(Scroller.Item, { elementKey: n, children: _jsx(NucleusGroup, { nucleus: n, children: _jsx(SpectraColumnsManager, { nucleus: n, onAdd: handleAdd, onDelete: handleDelete, mapOnChangeValue: mapOnChangeValueHandler, mapValue: mapValue, datalist: datalist }) }) }, n))) }) }) }));
117
+ return (_jsx(PreferencesContainer, { children: _jsx(Formik, { innerRef: formRef, onSubmit: saveHandler, initialValues: preferencesByNuclei, validationSchema: spectraPreferencesValidation, children: _jsx(Scroller, { scrollTo: activeTab, children: nuclei?.map((n) => (_jsx(Scroller.Item, { elementKey: n, children: _jsx(NucleusGroup, { nucleus: n, children: _jsx(GroupPane, { text: "General", style: groupPaneStyle, children: _jsx(SpectraColumnsManager, { nucleus: n, onAdd: handleAdd, onDelete: handleDelete, mapOnChangeValue: mapOnChangeValueHandler, mapValue: mapValue, datalist: datalist }) }) }) }, n))) }) }) }));
106
118
  }
107
119
  export default memo(forwardRef(SpectraPreferences));