nmrium 0.63.2 → 0.64.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 (160) hide show
  1. package/lib/component/1d/BrushTracker1D.d.ts.map +1 -1
  2. package/lib/component/1d/BrushTracker1D.js +8 -1
  3. package/lib/component/1d/BrushTracker1D.js.map +1 -1
  4. package/lib/component/1d/PredictionErrorsNotations.d.ts +2 -0
  5. package/lib/component/1d/PredictionErrorsNotations.d.ts.map +1 -0
  6. package/lib/component/1d/PredictionErrorsNotations.js +112 -0
  7. package/lib/component/1d/PredictionErrorsNotations.js.map +1 -0
  8. package/lib/component/1d/SVGContent1D.d.ts.map +1 -1
  9. package/lib/component/1d/SVGContent1D.js +2 -1
  10. package/lib/component/1d/SVGContent1D.js.map +1 -1
  11. package/lib/component/2d/ft/Contours.d.ts.map +1 -1
  12. package/lib/component/2d/ft/Contours.js +3 -4
  13. package/lib/component/2d/ft/Contours.js.map +1 -1
  14. package/lib/component/2d/utilities/extractSpectrumSignals.d.ts +5 -3
  15. package/lib/component/2d/utilities/extractSpectrumSignals.d.ts.map +1 -1
  16. package/lib/component/2d/utilities/extractSpectrumSignals.js +3 -3
  17. package/lib/component/2d/utilities/extractSpectrumSignals.js.map +1 -1
  18. package/lib/component/2d/zones/SignalsGuideLines.d.ts.map +1 -1
  19. package/lib/component/2d/zones/SignalsGuideLines.js +74 -6
  20. package/lib/component/2d/zones/SignalsGuideLines.js.map +1 -1
  21. package/lib/component/EventsTrackers/BrushTracker.d.ts.map +1 -1
  22. package/lib/component/EventsTrackers/BrushTracker.js +2 -2
  23. package/lib/component/EventsTrackers/BrushTracker.js.map +1 -1
  24. package/lib/component/assignment/AssignmentProvider.d.ts.map +1 -1
  25. package/lib/component/assignment/AssignmentProvider.js +2 -1
  26. package/lib/component/assignment/AssignmentProvider.js.map +1 -1
  27. package/lib/component/assignment/AssignmentsContext.d.ts +5 -2
  28. package/lib/component/assignment/AssignmentsContext.d.ts.map +1 -1
  29. package/lib/component/assignment/AssignmentsContext.js +2 -1
  30. package/lib/component/assignment/AssignmentsContext.js.map +1 -1
  31. package/lib/component/elements/SVGGroup.js +1 -1
  32. package/lib/component/elements/SVGGroup.js.map +1 -1
  33. package/lib/component/elements/Sections.d.ts +1 -0
  34. package/lib/component/elements/Sections.d.ts.map +1 -1
  35. package/lib/component/elements/Sections.js +42 -7
  36. package/lib/component/elements/Sections.js.map +1 -1
  37. package/lib/component/elements/pdnd.cjs +12 -0
  38. package/lib/component/elements/pdnd.cjs.map +1 -0
  39. package/lib/component/elements/pdnd.d.cts +2 -0
  40. package/lib/component/elements/pdnd.d.cts.map +1 -0
  41. package/lib/component/hooks/useToolsFunctions.js +1 -1
  42. package/lib/component/hooks/useToolsFunctions.js.map +1 -1
  43. package/lib/component/main/InnerNMRiumContents.d.ts.map +1 -1
  44. package/lib/component/main/InnerNMRiumContents.js +3 -1
  45. package/lib/component/main/InnerNMRiumContents.js.map +1 -1
  46. package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.d.ts.map +1 -1
  47. package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.js +7 -4
  48. package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.js.map +1 -1
  49. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +6 -5
  50. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js.map +1 -1
  51. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts +1 -1
  52. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts.map +1 -1
  53. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +3 -2
  54. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js.map +1 -1
  55. package/lib/component/panels/MoleculesPanel/useAtomAssignment.d.ts.map +1 -1
  56. package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +17 -9
  57. package/lib/component/panels/MoleculesPanel/useAtomAssignment.js.map +1 -1
  58. package/lib/component/panels/Panels.d.ts +0 -4
  59. package/lib/component/panels/Panels.d.ts.map +1 -1
  60. package/lib/component/panels/Panels.js +8 -14
  61. package/lib/component/panels/Panels.js.map +1 -1
  62. package/lib/component/panels/RangesPanel/RangesHeader.d.ts.map +1 -1
  63. package/lib/component/panels/RangesPanel/RangesHeader.js +5 -8
  64. package/lib/component/panels/RangesPanel/RangesHeader.js.map +1 -1
  65. package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DSetting.d.ts.map +1 -1
  66. package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DSetting.js +4 -1
  67. package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DSetting.js.map +1 -1
  68. package/lib/component/panels/extra/utilities/MultiplicityUtilities.d.ts +1 -1
  69. package/lib/component/panels/extra/utilities/MultiplicityUtilities.d.ts.map +1 -1
  70. package/lib/component/panels/filtersPanel/Filters/FiltersSectionsPanel.d.ts.map +1 -1
  71. package/lib/component/panels/filtersPanel/Filters/FiltersSectionsPanel.js +7 -1
  72. package/lib/component/panels/filtersPanel/Filters/FiltersSectionsPanel.js.map +1 -1
  73. package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.d.ts +1 -1
  74. package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.d.ts.map +1 -1
  75. package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.js +15 -17
  76. package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.js.map +1 -1
  77. package/lib/component/panels/hooks/useTogglePanel.d.ts.map +1 -1
  78. package/lib/component/panels/hooks/useTogglePanel.js +4 -3
  79. package/lib/component/panels/hooks/useTogglePanel.js.map +1 -1
  80. package/lib/component/reducer/Reducer.d.ts.map +1 -1
  81. package/lib/component/reducer/Reducer.js +2 -0
  82. package/lib/component/reducer/Reducer.js.map +1 -1
  83. package/lib/component/reducer/actions/FiltersActions.d.ts +7 -2
  84. package/lib/component/reducer/actions/FiltersActions.d.ts.map +1 -1
  85. package/lib/component/reducer/actions/FiltersActions.js +56 -26
  86. package/lib/component/reducer/actions/FiltersActions.js.map +1 -1
  87. package/lib/component/reducer/actions/InsetActions.d.ts.map +1 -1
  88. package/lib/component/reducer/actions/InsetActions.js +1 -5
  89. package/lib/component/reducer/actions/InsetActions.js.map +1 -1
  90. package/lib/component/reducer/actions/RangesActions.d.ts +3 -1
  91. package/lib/component/reducer/actions/RangesActions.d.ts.map +1 -1
  92. package/lib/component/reducer/actions/RangesActions.js +7 -14
  93. package/lib/component/reducer/actions/RangesActions.js.map +1 -1
  94. package/lib/component/reducer/actions/ToolsActions.d.ts.map +1 -1
  95. package/lib/component/reducer/actions/ToolsActions.js +2 -2
  96. package/lib/component/reducer/actions/ToolsActions.js.map +1 -1
  97. package/lib/component/reducer/helper/ZoomHistoryManager.d.ts +3 -2
  98. package/lib/component/reducer/helper/ZoomHistoryManager.d.ts.map +1 -1
  99. package/lib/component/reducer/helper/ZoomHistoryManager.js +17 -8
  100. package/lib/component/reducer/helper/ZoomHistoryManager.js.map +1 -1
  101. package/lib/component/reducer/preferences/actions/togglePanel.d.ts.map +1 -1
  102. package/lib/component/reducer/preferences/actions/togglePanel.js +11 -6
  103. package/lib/component/reducer/preferences/actions/togglePanel.js.map +1 -1
  104. package/lib/component/reducer/preferences/preferencesReducer.d.ts +3 -1
  105. package/lib/component/reducer/preferences/preferencesReducer.d.ts.map +1 -1
  106. package/lib/component/reducer/preferences/preferencesReducer.js.map +1 -1
  107. package/lib/component/workspaces/prediction.js +1 -1
  108. package/lib/component/workspaces/prediction.js.map +1 -1
  109. package/lib/data/PredictionManager.d.ts.map +1 -1
  110. package/lib/data/PredictionManager.js +1 -0
  111. package/lib/data/PredictionManager.js.map +1 -1
  112. package/lib/data/data2d/Spectrum2D/contours.d.ts.map +1 -1
  113. package/lib/data/data2d/Spectrum2D/contours.js +6 -4
  114. package/lib/data/data2d/Spectrum2D/contours.js.map +1 -1
  115. package/lib/data/data2d/Spectrum2D/initiateDatum2D.d.ts.map +1 -1
  116. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +22 -10
  117. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js.map +1 -1
  118. package/lib/data/data2d/Spectrum2D/zones/detectZonesManual.d.ts.map +1 -1
  119. package/lib/data/data2d/Spectrum2D/zones/initiateZones.d.ts.map +1 -1
  120. package/lib/data/types/data1d/index.js +1 -1
  121. package/lib/data/types/data1d/index.js.map +1 -1
  122. package/lib/versionInfo.js +1 -1
  123. package/package.json +20 -19
  124. package/src/component/1d/BrushTracker1D.tsx +8 -1
  125. package/src/component/1d/PredictionErrorsNotations.tsx +209 -0
  126. package/src/component/1d/SVGContent1D.tsx +2 -0
  127. package/src/component/2d/ft/Contours.tsx +3 -11
  128. package/src/component/2d/utilities/extractSpectrumSignals.ts +12 -9
  129. package/src/component/2d/zones/SignalsGuideLines.tsx +107 -11
  130. package/src/component/EventsTrackers/BrushTracker.tsx +2 -3
  131. package/src/component/assignment/AssignmentProvider.tsx +2 -1
  132. package/src/component/assignment/AssignmentsContext.ts +7 -2
  133. package/src/component/elements/SVGGroup.tsx +2 -2
  134. package/src/component/elements/Sections.tsx +103 -19
  135. package/src/component/elements/pdnd.cts +9 -0
  136. package/src/component/hooks/useToolsFunctions.ts +1 -1
  137. package/src/component/main/InnerNMRiumContents.tsx +3 -1
  138. package/src/component/modal/setting/settings-tabs/DatabasesTabContent.tsx +12 -7
  139. package/src/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.tsx +11 -5
  140. package/src/component/panels/MoleculesPanel/MoleculePanelHeader.tsx +32 -32
  141. package/src/component/panels/MoleculesPanel/useAtomAssignment.tsx +29 -8
  142. package/src/component/panels/Panels.tsx +9 -24
  143. package/src/component/panels/RangesPanel/RangesHeader.tsx +14 -21
  144. package/src/component/panels/SpectraPanel/base/setting/Spectrum2DSetting.tsx +11 -1
  145. package/src/component/panels/filtersPanel/Filters/FiltersSectionsPanel.tsx +9 -0
  146. package/src/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.tsx +16 -18
  147. package/src/component/panels/hooks/useTogglePanel.ts +4 -3
  148. package/src/component/reducer/Reducer.ts +2 -0
  149. package/src/component/reducer/actions/FiltersActions.ts +86 -40
  150. package/src/component/reducer/actions/InsetActions.ts +1 -5
  151. package/src/component/reducer/actions/RangesActions.ts +10 -13
  152. package/src/component/reducer/actions/ToolsActions.ts +1 -2
  153. package/src/component/reducer/helper/ZoomHistoryManager.ts +20 -9
  154. package/src/component/reducer/preferences/actions/togglePanel.ts +10 -6
  155. package/src/component/reducer/preferences/preferencesReducer.ts +11 -1
  156. package/src/component/workspaces/prediction.ts +1 -1
  157. package/src/data/PredictionManager.ts +1 -0
  158. package/src/data/data2d/Spectrum2D/contours.ts +8 -4
  159. package/src/data/data2d/Spectrum2D/initiateDatum2D.ts +34 -16
  160. package/src/versionInfo.ts +1 -1
@@ -88,17 +88,18 @@ interface MoleculePanelHeaderProps {
88
88
  children?: ReactNode;
89
89
  }
90
90
 
91
- export default function MoleculePanelHeader({
92
- currentIndex,
93
- molecules,
94
- moleculesView,
95
- onMoleculeIndexChange,
96
- onOpenMoleculeEditor,
97
- renderSource = 'moleculePanel',
98
- onClickPreferences,
99
- onClickPastMolecule,
100
- children,
101
- }: MoleculePanelHeaderProps) {
91
+ export default function MoleculePanelHeader(props: MoleculePanelHeaderProps) {
92
+ const {
93
+ currentIndex,
94
+ molecules,
95
+ moleculesView,
96
+ onMoleculeIndexChange,
97
+ onOpenMoleculeEditor,
98
+ renderSource = 'moleculePanel',
99
+ onClickPreferences,
100
+ onClickPastMolecule,
101
+ children,
102
+ } = props;
102
103
  const { rootRef } = useGlobal();
103
104
  const toaster = useToaster();
104
105
  const dispatch = useDispatch();
@@ -256,27 +257,26 @@ export default function MoleculePanelHeader({
256
257
  <Toolbar>
257
258
  {renderSource === 'predictionPanel' && <AboutPredictionModal />}
258
259
  {renderSource === 'moleculePanel' && (
259
- <>
260
- <ToolbarPopoverItem
261
- options={MOL_EXPORT_MENU}
262
- onClick={exportHandler}
263
- disabled={!hasMolecules}
264
- tooltip="Export As"
265
- icon={<FaFileExport />}
266
- id="molecule-export-as"
267
- />
268
-
269
- <Toolbar.Item
270
- tooltip="Paste molfile"
271
- icon={<FaPaste />}
272
- onClick={handlePasteMolfileAction}
273
- />
274
- <Toolbar.Item
275
- tooltip="Add molecule"
276
- icon={<FaPlus />}
277
- onClick={onOpenMoleculeEditor}
278
- />
279
- </>
260
+ <ToolbarPopoverItem
261
+ options={MOL_EXPORT_MENU}
262
+ onClick={exportHandler}
263
+ disabled={!hasMolecules}
264
+ tooltip="Export As"
265
+ icon={<FaFileExport />}
266
+ id="molecule-export-as"
267
+ />
268
+ )}
269
+ <Toolbar.Item
270
+ tooltip="Paste molfile"
271
+ icon={<FaPaste />}
272
+ onClick={handlePasteMolfileAction}
273
+ />
274
+ {renderSource === 'moleculePanel' && (
275
+ <Toolbar.Item
276
+ tooltip="Add molecule"
277
+ icon={<FaPlus />}
278
+ onClick={onOpenMoleculeEditor}
279
+ />
280
280
  )}
281
281
 
282
282
  {renderSource === 'moleculePanel' && (
@@ -75,6 +75,7 @@ function getSignalsDiaIDs(
75
75
 
76
76
  export default function useAtomAssignment() {
77
77
  const {
78
+ data: spectra,
78
79
  view: {
79
80
  spectra: { activeTab: nucleus },
80
81
  },
@@ -85,8 +86,10 @@ export default function useAtomAssignment() {
85
86
  const highlightData = useHighlightData();
86
87
  const highlightedIdDsRef = useRef<string[]>([]);
87
88
  const assignments = useAssignmentContext();
88
- const activatedKey = assignments.activated
89
- ? assignments.activated.id
89
+ const { activated: activatedAssignment } = assignments;
90
+
91
+ const activatedKey = activatedAssignment
92
+ ? activatedAssignment.id
90
93
  : ConcatenationString; // dummy value
91
94
 
92
95
  // used for atom highlighting for now, until we would like to highlight atoms per axis separately
@@ -117,7 +120,11 @@ export default function useAtomAssignment() {
117
120
 
118
121
  if (!assignKeys) return;
119
122
  const [{ index: rangeIndex }] = assignKeys;
120
- const range = spectrum.ranges.values[rangeIndex];
123
+ const {
124
+ id: spectrumId,
125
+ ranges: { values },
126
+ } = spectrum;
127
+ const range = values[rangeIndex];
121
128
 
122
129
  let diaIDs: string[] = [];
123
130
 
@@ -135,6 +142,7 @@ export default function useAtomAssignment() {
135
142
  nbAtoms: uniqueDiaIDs.nbAtoms,
136
143
  diaIDs: uniqueDiaIDs.diaIDs,
137
144
  keys: assignKeys,
145
+ spectrumId,
138
146
  },
139
147
  });
140
148
  }
@@ -175,9 +183,9 @@ export default function useAtomAssignment() {
175
183
  diaIDAndInfo: DiaIDAndInfo | undefined,
176
184
  event: MouseEvent,
177
185
  ) {
178
- if (checkModifierKeyActivated(event) || !assignments.activated) return;
186
+ if (checkModifierKeyActivated(event) || !activatedAssignment) return;
179
187
 
180
- const { axis, id } = assignments.activated;
188
+ const { axis, id } = activatedAssignment;
181
189
 
182
190
  if (!id || !axis) {
183
191
  return;
@@ -198,10 +206,23 @@ export default function useAtomAssignment() {
198
206
  // determine the level of setting the diaIDs array (range vs. signal level) and save there
199
207
  // let nbAtoms = 0;
200
208
  // on range/zone level
201
- if (isSpectrum1D(spectrum)) {
202
- assign1DAtom(spectrum, assignments.activated.id, atomInformation);
209
+ const currentSpectrum = activatedAssignment.spectrumId
210
+ ? spectra.find(
211
+ (spectrum) => spectrum.id === activatedAssignment.spectrumId,
212
+ )
213
+ : spectrum;
214
+
215
+ if (!currentSpectrum) return;
216
+
217
+ if (isSpectrum1D(currentSpectrum)) {
218
+ assign1DAtom(currentSpectrum, activatedAssignment.id, atomInformation);
203
219
  } else {
204
- assign2DAtom(spectrum, assignments.activated.id, atomInformation, axis);
220
+ assign2DAtom(
221
+ currentSpectrum,
222
+ activatedAssignment.id,
223
+ atomInformation,
224
+ axis,
225
+ );
205
226
  }
206
227
  assignments.activate({ id: activatedKey, axis });
207
228
  }
@@ -20,11 +20,7 @@ const Container = styled.div`
20
20
  height: 100%;
21
21
  flex: 1 1 0%;
22
22
  `;
23
-
24
- type PanelOpenState = Partial<Record<keyof NMRiumPanelPreferences, boolean>>;
25
23
  interface PanelStateContext {
26
- setPanelOpenState: (id: keyof NMRiumPanelPreferences, value: boolean) => void;
27
- panelOpenState: PanelOpenState;
28
24
  openSplitPane: () => void;
29
25
  closeSplitPane: () => void;
30
26
  isSplitPaneOpen: boolean;
@@ -48,26 +44,12 @@ export function PanelOpenProviderProvider({ children }) {
48
44
  const {
49
45
  display: { general = {} },
50
46
  } = current;
51
-
52
- const [panelOpenState, toggleAccordionItem] = useState<PanelOpenState>({});
53
47
  // TODO: make sure to move this state to the workspace once the refactoring of nmrium-core is finished.
54
48
  const [isSplitPaneOpen, setIsSplitPaneOpen] = useState(
55
49
  !general?.hidePanelOnLoad,
56
50
  );
57
51
 
58
52
  const state = useMemo(() => {
59
- function setPanelOpenState(
60
- id: keyof NMRiumPanelPreferences,
61
- value: boolean,
62
- ) {
63
- toggleAccordionItem((prev) => {
64
- return {
65
- ...prev,
66
- [id]: value,
67
- };
68
- });
69
- }
70
-
71
53
  function openSplitPane() {
72
54
  setIsSplitPaneOpen(true);
73
55
  }
@@ -75,13 +57,11 @@ export function PanelOpenProviderProvider({ children }) {
75
57
  setIsSplitPaneOpen(false);
76
58
  }
77
59
  return {
78
- setPanelOpenState,
79
- panelOpenState,
80
60
  openSplitPane,
81
61
  closeSplitPane,
82
62
  isSplitPaneOpen,
83
63
  };
84
- }, [isSplitPaneOpen, panelOpenState]);
64
+ }, [isSplitPaneOpen]);
85
65
 
86
66
  return (
87
67
  <AccordionContext.Provider value={state}>
@@ -92,11 +72,10 @@ export function PanelOpenProviderProvider({ children }) {
92
72
 
93
73
  function PanelsInner() {
94
74
  const getPanelPreferences = useGetPanelOptions();
95
- const { panelOpenState } = usePanelOpenState();
96
75
  const { dialog, openDialog, closeDialog } = useDialogToggle({
97
76
  informationModal: false,
98
77
  });
99
-
78
+ const { dispatch } = usePreferences();
100
79
  const items = useAccordionItems();
101
80
  function isOpened(item: AccordionItem) {
102
81
  const panelOptions = getPanelPreferences(item);
@@ -126,7 +105,13 @@ function PanelsInner() {
126
105
  id={id}
127
106
  key={title}
128
107
  title={title}
129
- defaultOpen={isOpened(item) || panelOpenState[id]}
108
+ open={isOpened(item)}
109
+ onOpenChange={(isOpened) => {
110
+ dispatch({
111
+ type: 'TOGGLE_PANEL',
112
+ payload: { id, options: { open: isOpened } },
113
+ });
114
+ }}
130
115
  renderToolbar={() => (
131
116
  <RightButtons
132
117
  id={id}
@@ -26,7 +26,6 @@ import { useAlert } from '../../elements/Alert.js';
26
26
  import type { ToolbarPopoverMenuItem } from '../../elements/ToolbarPopoverItem.js';
27
27
  import { ToolbarPopoverItem } from '../../elements/ToolbarPopoverItem.js';
28
28
  import { useActiveSpectrumRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState.js';
29
- import useCheckExperimentalFeature from '../../hooks/useCheckExperimentalFeature.js';
30
29
  import { useDialogToggle } from '../../hooks/useDialogToggle.js';
31
30
  import { PublicationStringModal } from '../../modal/PublicationStringModal.js';
32
31
  import ChangeSumModal from '../../modal/changeSum/ChangeSumModal.js';
@@ -80,7 +79,6 @@ function RangesHeader(props: RangesHeaderProps) {
80
79
  const dispatch = useDispatch();
81
80
  const alert = useAlert();
82
81
  const toaster = useToaster();
83
- const isExperimentalFeature = useCheckExperimentalFeature();
84
82
  const { openDialog, dialog, closeDialog } = useDialogToggle({
85
83
  publicationStringModal: false,
86
84
  });
@@ -312,27 +310,22 @@ function RangesHeader(props: RangesHeaderProps) {
312
310
  onClick: handleShowAssignmentsLabel,
313
311
  active: showAssignmentsLabels,
314
312
  },
313
+ {
314
+ disabled: !hasRanges,
315
+ icon: <FaCopy />,
316
+ tooltip: `${booleanToString(!showPublicationString)} publication string`,
317
+ onClick: handleShowPublicationString,
318
+ active: showPublicationString,
319
+ },
320
+ {
321
+ disabled: !hasRanges,
322
+ icon: <SvgNmrPeaksTopLabels />,
323
+ tooltip: `${booleanToString(!showRanges)} ranges`,
324
+ onClick: handleShowRanges,
325
+ active: showRanges,
326
+ },
315
327
  ];
316
328
 
317
- if (isExperimentalFeature) {
318
- lefButtons.push(
319
- {
320
- disabled: !hasRanges,
321
- icon: <FaCopy />,
322
- tooltip: `${booleanToString(!showPublicationString)} publication string`,
323
- onClick: handleShowPublicationString,
324
- active: showPublicationString,
325
- },
326
- {
327
- disabled: !hasRanges,
328
- icon: <SvgNmrPeaksTopLabels />,
329
- tooltip: `${booleanToString(!showRanges)} ranges`,
330
- onClick: handleShowRanges,
331
- active: showRanges,
332
- },
333
- );
334
- }
335
-
336
329
  return (
337
330
  <div>
338
331
  <PublicationStringModal
@@ -1,3 +1,4 @@
1
+ import type { RangeSliderProps } from '@blueprintjs/core';
1
2
  import { RangeSlider } from '@blueprintjs/core';
2
3
  import styled from '@emotion/styled';
3
4
  import debounce from 'lodash/debounce.js';
@@ -28,6 +29,14 @@ const StyledRangeSlider = styled(RangeSlider)<{
28
29
  background-color: ${(props) => props.progressColor};
29
30
  }
30
31
  `;
32
+ type ContoursRangeSliderProps = RangeSliderProps & {
33
+ progressColor: React.CSSProperties['backgroundColor'];
34
+ name?: string;
35
+ };
36
+ function ContoursRangeSlider(props: ContoursRangeSliderProps) {
37
+ return <StyledRangeSlider {...props} />;
38
+ }
39
+
31
40
  interface Spectrum2DSettingProps {
32
41
  data: any;
33
42
  onSubmit: (values: any) => void;
@@ -113,7 +122,8 @@ function Settings(props: SettingsProps) {
113
122
  const { value, onChange } = field;
114
123
 
115
124
  return (
116
- <StyledRangeSlider
125
+ <ContoursRangeSlider
126
+ name={sign}
117
127
  min={0}
118
128
  max={100}
119
129
  stepSize={1}
@@ -262,6 +262,14 @@ function FiltersInner(props: FiltersInnerProps) {
262
262
  openSection(null);
263
263
  }
264
264
 
265
+ function handleReorderFilters(sourceId, targetId) {
266
+ if (!sourceId || !targetId) {
267
+ return;
268
+ }
269
+
270
+ dispatch({ type: 'REORDER_FILTERS', payload: { sourceId, targetId } });
271
+ }
272
+
265
273
  return (
266
274
  <Sections isOverflow renderActiveSectionContentOnly>
267
275
  {filtersList.map((filter, index) => {
@@ -272,6 +280,7 @@ function FiltersInner(props: FiltersInnerProps) {
272
280
  <Sections.Item
273
281
  key={id}
274
282
  id={name}
283
+ onReorder={handleReorderFilters}
275
284
  title={error || getFilterLabel(name)}
276
285
  serial={index + 1}
277
286
  onClick={(id) => {
@@ -136,25 +136,23 @@ export function usePhaseCorrectionTwoDimensions(filter: Filter2DEntry | null) {
136
136
  );
137
137
 
138
138
  const handleInputValueChange = useCallback(
139
- (e) => {
140
- const { name, value } = e.target;
141
- if (e.target) {
142
- const newValue = {
143
- ...valueRef.current,
144
- [activeTraceDirection]: {
145
- ...valueRef.current[activeTraceDirection],
146
- [name]: Number(value),
147
- },
148
- };
149
-
150
- if (String(value).trim() !== '-') {
151
- calcPhaseCorrectionHandler(newValue, name, 'input');
152
- }
153
- updateInputRangeInitialValue(newValue);
154
- valueRef.current = newValue;
155
- setValue(valueRef.current);
156
- syncFilterOptions(valueRef.current);
139
+ (valueAsNumber, valueAsString, inputElement) => {
140
+ const { name } = inputElement;
141
+ const newValue = {
142
+ ...valueRef.current,
143
+ [activeTraceDirection]: {
144
+ ...valueRef.current[activeTraceDirection],
145
+ [name]: valueAsNumber,
146
+ },
147
+ };
148
+
149
+ if (valueAsString.trim() !== '-') {
150
+ calcPhaseCorrectionHandler(newValue, name, 'input');
157
151
  }
152
+ updateInputRangeInitialValue(newValue);
153
+ valueRef.current = newValue;
154
+ setValue(valueRef.current);
155
+ syncFilterOptions(valueRef.current);
158
156
  },
159
157
  [
160
158
  activeTraceDirection,
@@ -5,7 +5,6 @@ import { usePanelOpenState } from '../Panels.js';
5
5
 
6
6
  export function useTogglePanel() {
7
7
  const { dispatch, current } = usePreferences();
8
- const { setPanelOpenState } = usePanelOpenState();
9
8
  const { isSplitPaneOpen, openSplitPane } = usePanelOpenState();
10
9
 
11
10
  function togglePanel(id: keyof NMRiumPanelPreferences) {
@@ -15,8 +14,10 @@ export function useTogglePanel() {
15
14
  openSplitPane();
16
15
 
17
16
  if ((!isSplitPaneOpen && !flag) || isSplitPaneOpen) {
18
- setPanelOpenState(id, !flag);
19
- dispatch({ type: 'TOGGLE_PANEL', payload: { id } });
17
+ dispatch({
18
+ type: 'TOGGLE_PANEL',
19
+ payload: { id, options: { display: undefined, open: !flag } },
20
+ });
20
21
  }
21
22
  }
22
23
 
@@ -574,6 +574,8 @@ function innerSpectrumReducer(draft: Draft<State>, action: Action) {
574
574
  return FiltersActions.handleApplyAutoPhaseCorrectionTwoDimensionsFilter(
575
575
  draft,
576
576
  );
577
+ case 'REORDER_FILTERS':
578
+ return FiltersActions.handleReorderFilters(draft, action);
577
579
  case 'CHANGE_SPECTRUM_VISIBILITY':
578
580
  return SpectraActions.handleChangeSpectrumVisibilityById(draft, action);
579
581
  case 'CHANGE_SPECTRA_VISIBILITY_BY_NUCLEUS':
@@ -26,7 +26,10 @@ import { isSpectrum1D } from '../../../data/data1d/Spectrum1D/index.js';
26
26
  import { isFid1DSpectrum } from '../../../data/data1d/Spectrum1D/isSpectrum1D.js';
27
27
  import { getProjection } from '../../../data/data2d/Spectrum2D/getMissingProjection.js';
28
28
  import { isSpectrum2D } from '../../../data/data2d/Spectrum2D/index.js';
29
- import { isFid2DSpectrum } from '../../../data/data2d/Spectrum2D/isSpectrum2D.js';
29
+ import {
30
+ isFid2DSpectrum,
31
+ isFt2DSpectrum,
32
+ } from '../../../data/data2d/Spectrum2D/isSpectrum2D.js';
30
33
  import type { ExclusionZone } from '../../../data/types/data1d/ExclusionZone.js';
31
34
  import { getXScale } from '../../1d/utilities/scale.js';
32
35
  import { get2DXScale, get2DYScale } from '../../2d/utilities/scale.js';
@@ -56,6 +59,7 @@ import type { ActionType } from '../types/ActionType.js';
56
59
  import { get2DDomain, setDomain, setMode } from './DomainActions.js';
57
60
  import { changeSpectrumVerticalAlignment } from './PreferencesActions.js';
58
61
  import { activateTool, resetSelectedTool } from './ToolsActions.js';
62
+ import { getDefaultContoursLevel } from '../../../data/data2d/Spectrum2D/contours.js';
59
63
 
60
64
  const {
61
65
  fft,
@@ -213,6 +217,10 @@ type DeletePhaseCorrectionTrace = ActionType<
213
217
  'DELETE_PHASE_CORRECTION_TRACE',
214
218
  { id: string }
215
219
  >;
220
+ type ReorderFiltersAction = ActionType<
221
+ 'REORDER_FILTERS',
222
+ { sourceId: string; targetId: string }
223
+ >;
216
224
 
217
225
  type SetOneDimensionPhaseCorrectionPivotPoint = ActionType<
218
226
  'SET_ONE_DIMENSION_PIVOT_POINT',
@@ -254,6 +262,7 @@ export type FiltersActions =
254
262
  | SetOneDimensionPhaseCorrectionPivotPoint
255
263
  | SetTwoDimensionPhaseCorrectionPivotPoint
256
264
  | ManualTwoDimensionsPhaseCorrectionFilterAction
265
+ | ReorderFiltersAction
257
266
  | ActionType<
258
267
  | 'APPLY_FFT_FILTER'
259
268
  | 'APPLY_FFT_DIMENSION_1_FILTER'
@@ -466,15 +475,13 @@ function rollbackSpectrumByFilter(
466
475
  reapplyFilters(spectrum, filters);
467
476
 
468
477
  draft.tempData = current(draft).data.slice();
469
- draft.tempData[index] = spectrum;
478
+ draft.tempData[index] = structuredClone(spectrum);
470
479
 
471
480
  // apply the current Filters
472
481
  if (applyFilter) {
473
482
  executeFilter(spectrum, spectrum.filters[filterIndex]);
474
483
  }
475
484
 
476
- spectrum = structuredClone(spectrum);
477
-
478
485
  if (tempRollback) {
479
486
  reapplyFilters(spectrum);
480
487
  updateDomainOptions = getFilterDomain(spectrum, {
@@ -496,16 +503,24 @@ function rollbackSpectrumByFilter(
496
503
  // re-implement all filters and rest all view property that related to filters
497
504
  if (reset) {
498
505
  if (filterIndex !== -1 && spectrum.filters.length > 0) {
506
+ // A filter exists, reset the domain based on the filters from the current filter index to the last one
499
507
  updateDomainOptions = getFilterDomain(spectrum, {
500
508
  startIndex: filterIndex,
501
509
  lastIndex: spectrum.filters.length - 1,
502
510
  });
503
511
  } else if (toolData.activeFilterID) {
512
+ // No filter exists yet, but there is an active one in this case reset both x and y domain
513
+
504
514
  updateDomainOptions = { updateXDomain: true, updateYDomain: true };
515
+ } else if (searchBy === 'name' && key) {
516
+ // No filter exists yet and no active filter, reset the x and y domain based on the current filter domain rules
517
+ const { updateXDomain, updateYDomain } =
518
+ getFilterUpdateDomainRules(key);
519
+ updateDomainOptions = { updateXDomain, updateYDomain };
505
520
  } else {
521
+ //otherwise do not reset the domain
506
522
  updateDomainOptions = { updateXDomain: false, updateYDomain: false };
507
523
  }
508
-
509
524
  toolData.activeFilterID = null;
510
525
  draft.tempData = null;
511
526
 
@@ -1224,7 +1239,16 @@ function handleApplyFFTFilter(draft: Draft<State>) {
1224
1239
  draft.toolOptions.selectedTool = 'zoom';
1225
1240
  }
1226
1241
 
1227
- function handleApplyFFtDimension1Filter(draft: Draft<State>) {
1242
+ function applyFFTTwoDimensionFilter(
1243
+ draft: Draft<State>,
1244
+ {
1245
+ filterName,
1246
+ domainUpdateRules,
1247
+ }: {
1248
+ filterName: 'fftDimension1' | 'fftDimension2';
1249
+ domainUpdateRules: FilterDomainUpdateRules;
1250
+ },
1251
+ ) {
1228
1252
  const activeSpectrum = getActiveSpectrum(draft);
1229
1253
 
1230
1254
  if (!activeSpectrum) {
@@ -1234,46 +1258,24 @@ function handleApplyFFtDimension1Filter(draft: Draft<State>) {
1234
1258
  const { index } = activeSpectrum;
1235
1259
  const activeFilterIndex = getActiveFilterIndex(draft);
1236
1260
 
1237
- //apply filter into the spectrum
1238
- Filters2DManager.applyFilters(
1239
- activeFilterIndex !== -1 ? draft.tempData[index] : draft.data[index],
1240
- [{ name: 'fftDimension1', value: {} }],
1241
- );
1261
+ const targetSpectrum =
1262
+ activeFilterIndex !== -1 ? draft.tempData[index] : draft.data[index];
1263
+
1264
+ Filters2DManager.applyFilters(targetSpectrum, [
1265
+ { name: filterName, value: {} },
1266
+ ]);
1242
1267
 
1243
1268
  if (activeFilterIndex !== -1) {
1244
1269
  draft.data[index] = draft.tempData[index];
1245
1270
  }
1246
1271
 
1247
- updateView(draft, fftDimension1.domainUpdateRules);
1248
-
1249
- //clear zoom history
1250
- draft.zoom.history[draft.view.spectra.activeTab] = [];
1251
-
1252
- draft.toolOptions.selectedOptionPanel = null;
1253
- draft.toolOptions.selectedTool = 'zoom';
1254
- }
1255
-
1256
- function handleApplyFFtDimension2Filter(draft: Draft<State>) {
1257
- const activeSpectrum = getActiveSpectrum(draft);
1258
-
1259
- if (!activeSpectrum) {
1260
- return;
1261
- }
1262
-
1263
- const { index } = activeSpectrum;
1264
- const activeFilterIndex = getActiveFilterIndex(draft);
1265
-
1266
- //apply filter into the spectrum
1267
- Filters2DManager.applyFilters(
1268
- activeFilterIndex !== -1 ? draft.tempData[index] : draft.data[index],
1269
- [{ name: 'fftDimension2', value: {} }],
1270
- );
1272
+ const spectrum = draft.data[index];
1271
1273
 
1272
- if (activeFilterIndex !== -1) {
1273
- draft.data[index] = draft.tempData[index];
1274
+ if (isFt2DSpectrum(spectrum)) {
1275
+ spectrum.display.contourOptions = getDefaultContoursLevel(spectrum);
1274
1276
  }
1275
1277
 
1276
- updateView(draft, fftDimension2.domainUpdateRules);
1278
+ updateView(draft, domainUpdateRules);
1277
1279
 
1278
1280
  //clear zoom history
1279
1281
  draft.zoom.history[draft.view.spectra.activeTab] = [];
@@ -1282,6 +1284,20 @@ function handleApplyFFtDimension2Filter(draft: Draft<State>) {
1282
1284
  draft.toolOptions.selectedTool = 'zoom';
1283
1285
  }
1284
1286
 
1287
+ function handleApplyFFtDimension1Filter(draft: Draft<State>) {
1288
+ applyFFTTwoDimensionFilter(draft, {
1289
+ filterName: 'fftDimension1',
1290
+ domainUpdateRules: fftDimension1.domainUpdateRules,
1291
+ });
1292
+ }
1293
+
1294
+ function handleApplyFFtDimension2Filter(draft: Draft<State>) {
1295
+ applyFFTTwoDimensionFilter(draft, {
1296
+ filterName: 'fftDimension2',
1297
+ domainUpdateRules: fftDimension2.domainUpdateRules,
1298
+ });
1299
+ }
1300
+
1285
1301
  //action
1286
1302
  function handleApplyManualPhaseCorrectionFilter(
1287
1303
  draft: Draft<State>,
@@ -1914,7 +1930,7 @@ function handleCalculateManualTwoDimensionPhaseCorrection(
1914
1930
  }
1915
1931
 
1916
1932
  const { index } = activeSpectrum;
1917
- const spectrum = draft.tempData[index];
1933
+ const spectrum = structuredClone(current(draft).tempData[index]);
1918
1934
  const datum = draft.data[index];
1919
1935
 
1920
1936
  if (!isSpectrum2D(datum) || !spectrum) {
@@ -1923,7 +1939,8 @@ function handleCalculateManualTwoDimensionPhaseCorrection(
1923
1939
 
1924
1940
  const filterOptions = getTwoDimensionsPhaseCorrectionOptions(draft);
1925
1941
 
1926
- phaseCorrectionTwoDimensions.apply(datum, filterOptions);
1942
+ phaseCorrectionTwoDimensions.apply(spectrum, filterOptions);
1943
+ draft.data[index].data = spectrum.data;
1927
1944
  }
1928
1945
 
1929
1946
  function getTwoDimensionsPhaseCorrectionOptions(draft: Draft<State>) {
@@ -1997,6 +2014,34 @@ function handleApplyAutoPhaseCorrectionTwoDimensionsFilter(
1997
2014
  updateView(draft, phaseCorrectionTwoDimensions.domainUpdateRules);
1998
2015
  }
1999
2016
 
2017
+ function handleReorderFilters(
2018
+ draft: Draft<State>,
2019
+ action: ReorderFiltersAction,
2020
+ ) {
2021
+ const { sourceId, targetId } = action.payload;
2022
+ const spectrum = getSpectrum(draft);
2023
+
2024
+ if (!spectrum) {
2025
+ return;
2026
+ }
2027
+
2028
+ const filters = spectrum.filters;
2029
+
2030
+ const sourceIndex = filters.findIndex((filter) => filter.name === sourceId);
2031
+ const targetIndex = filters.findIndex((filter) => filter.name === targetId);
2032
+
2033
+ if (sourceIndex === -1 || targetIndex === -1) return;
2034
+
2035
+ const sourceFilter = filters[sourceIndex];
2036
+ filters.splice(sourceIndex, 1);
2037
+ filters.splice(targetIndex, 0, sourceFilter);
2038
+ if (isSpectrum1D(spectrum)) {
2039
+ Filters1DManager.reapplyFilters(spectrum);
2040
+ } else {
2041
+ Filters2DManager.reapplyFilters(spectrum);
2042
+ }
2043
+ }
2044
+
2000
2045
  export {
2001
2046
  handleShiftSpectrumAlongXAxis,
2002
2047
  handleApplyZeroFillingFilter,
@@ -2040,4 +2085,5 @@ export {
2040
2085
  handleToggleAddTracesToBothDirections,
2041
2086
  handleApplyAutoPhaseCorrectionTwoDimensionsFilter,
2042
2087
  handleApplyExclusionZone,
2088
+ handleReorderFilters,
2043
2089
  };
@@ -344,12 +344,8 @@ function handleInsetZoomOut(draft: Draft<State>, action: ZoomOutInsetAction) {
344
344
 
345
345
  if (!inset) return;
346
346
  const originXDomain = draft.originDomain.xDomains[inset.spectrumKey];
347
- const originYDomain = draft.originDomain.yDomains[inset.spectrumKey];
348
347
 
349
- const pop = preparePop(inset.zoomHistory, {
350
- xDomain: originXDomain,
351
- yDomain: originYDomain,
352
- });
348
+ const pop = preparePop(inset.zoomHistory);
353
349
 
354
350
  switch (zoomType) {
355
351
  case ZOOM_TYPES.HORIZONTAL: {