nmrium 1.4.0 → 1.6.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 (143) hide show
  1. package/lib/component/1d/FloatPublicationString.d.ts.map +1 -1
  2. package/lib/component/1d/FloatPublicationString.js +4 -9
  3. package/lib/component/1d/FloatPublicationString.js.map +1 -1
  4. package/lib/component/1d/peaks/PeakAnnotations.d.ts.map +1 -1
  5. package/lib/component/1d/peaks/PeakAnnotations.js +99 -3
  6. package/lib/component/1d/peaks/PeakAnnotations.js.map +1 -1
  7. package/lib/component/1d/peaks/PeakAnnotationsSpreadMode.js +3 -3
  8. package/lib/component/1d/peaks/PeakAnnotationsSpreadMode.js.map +1 -1
  9. package/lib/component/1d/peaks/Peaks.d.ts +4 -2
  10. package/lib/component/1d/peaks/Peaks.d.ts.map +1 -1
  11. package/lib/component/1d/peaks/Peaks.js +23 -19
  12. package/lib/component/1d/peaks/Peaks.js.map +1 -1
  13. package/lib/component/1d/ranges/Ranges.js +4 -4
  14. package/lib/component/1d/ranges/Ranges.js.map +1 -1
  15. package/lib/component/2d/zones/SignalsGuideLines.d.ts.map +1 -1
  16. package/lib/component/2d/zones/SignalsGuideLines.js +10 -6
  17. package/lib/component/2d/zones/SignalsGuideLines.js.map +1 -1
  18. package/lib/component/elements/DraggableDialog.js +0 -2
  19. package/lib/component/elements/DraggableDialog.js.map +1 -1
  20. package/lib/component/elements/EditableColumn.d.ts.map +1 -1
  21. package/lib/component/elements/EditableColumn.js +2 -0
  22. package/lib/component/elements/EditableColumn.js.map +1 -1
  23. package/lib/component/elements/ReactTable/Elements/ReactTableRow.d.ts.map +1 -1
  24. package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +0 -1
  25. package/lib/component/elements/ReactTable/Elements/ReactTableRow.js.map +1 -1
  26. package/lib/component/elements/ReactTable/ReactTable.d.ts.map +1 -1
  27. package/lib/component/elements/ReactTable/ReactTable.js +1 -4
  28. package/lib/component/elements/ReactTable/ReactTable.js.map +1 -1
  29. package/lib/component/elements/Sections.d.ts.map +1 -1
  30. package/lib/component/elements/Sections.js +1 -1
  31. package/lib/component/elements/Sections.js.map +1 -1
  32. package/lib/component/elements/Tab/Tabs.js +1 -1
  33. package/lib/component/elements/Tab/Tabs.js.map +1 -1
  34. package/lib/component/hooks/useActiveSpectrumRangesViewState.d.ts +1 -1
  35. package/lib/component/hooks/useActiveSpectrumRangesViewState.d.ts.map +1 -1
  36. package/lib/component/hooks/useActiveSpectrumRangesViewState.js +20 -16
  37. package/lib/component/hooks/useActiveSpectrumRangesViewState.js.map +1 -1
  38. package/lib/component/hooks/useCombinedRefs.js +1 -1
  39. package/lib/component/hooks/useCombinedRefs.js.map +1 -1
  40. package/lib/component/hooks/useTextMetrics.d.ts +4 -0
  41. package/lib/component/hooks/useTextMetrics.d.ts.map +1 -0
  42. package/lib/component/hooks/useTextMetrics.js +21 -0
  43. package/lib/component/hooks/useTextMetrics.js.map +1 -0
  44. package/lib/component/modal/MultipletAnalysisModal.js +2 -0
  45. package/lib/component/modal/MultipletAnalysisModal.js.map +1 -1
  46. package/lib/component/modal/changeSum/ChangeSumModalContents.d.ts.map +1 -1
  47. package/lib/component/modal/changeSum/ChangeSumModalContents.js +2 -0
  48. package/lib/component/modal/changeSum/ChangeSumModalContents.js.map +1 -1
  49. package/lib/component/modal/changeSum/SelectMolecule.d.ts.map +1 -1
  50. package/lib/component/modal/changeSum/SelectMolecule.js +2 -0
  51. package/lib/component/modal/changeSum/SelectMolecule.js.map +1 -1
  52. package/lib/component/panels/MoleculesPanel/MoleculePanel.d.ts.map +1 -1
  53. package/lib/component/panels/MoleculesPanel/MoleculePanel.js +2 -0
  54. package/lib/component/panels/MoleculesPanel/MoleculePanel.js.map +1 -1
  55. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts.map +1 -1
  56. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +1 -1
  57. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js.map +1 -1
  58. package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +1 -1
  59. package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditPathLength.d.ts.map +1 -1
  60. package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditPathLength.js +2 -5
  61. package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditPathLength.js.map +1 -1
  62. package/lib/component/panels/SummaryPanel/SummaryPanel.d.ts.map +1 -1
  63. package/lib/component/panels/SummaryPanel/SummaryPanel.js +8 -9
  64. package/lib/component/panels/SummaryPanel/SummaryPanel.js.map +1 -1
  65. package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrection.js +10 -10
  66. package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrection.js.map +1 -1
  67. package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.d.ts.map +1 -1
  68. package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.js +7 -5
  69. package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.js.map +1 -1
  70. package/lib/component/panels/multipleAnalysisPanel/preferences/MultipleAnalysisCodeEditor.d.ts.map +1 -1
  71. package/lib/component/panels/multipleAnalysisPanel/preferences/MultipleAnalysisCodeEditor.js +2 -0
  72. package/lib/component/panels/multipleAnalysisPanel/preferences/MultipleAnalysisCodeEditor.js.map +1 -1
  73. package/lib/component/reducer/actions/InsetActions.js +6 -6
  74. package/lib/component/reducer/actions/InsetActions.js.map +1 -1
  75. package/lib/component/reducer/actions/PeaksActions.d.ts.map +1 -1
  76. package/lib/component/reducer/actions/PeaksActions.js +3 -2
  77. package/lib/component/reducer/actions/PeaksActions.js.map +1 -1
  78. package/lib/component/reducer/actions/RangesActions.d.ts.map +1 -1
  79. package/lib/component/reducer/actions/RangesActions.js +16 -10
  80. package/lib/component/reducer/actions/RangesActions.js.map +1 -1
  81. package/lib/component/reducer/helper/setRangesViewProperty.d.ts.map +1 -1
  82. package/lib/component/reducer/helper/setRangesViewProperty.js +5 -5
  83. package/lib/component/reducer/helper/setRangesViewProperty.js.map +1 -1
  84. package/lib/component/utility/isHomoNuclear.d.ts +2 -0
  85. package/lib/component/utility/isHomoNuclear.d.ts.map +1 -0
  86. package/lib/component/utility/isHomoNuclear.js +11 -0
  87. package/lib/component/utility/isHomoNuclear.js.map +1 -0
  88. package/lib/data/data1d/Spectrum1D/peaks/autoPeakPicking.d.ts.map +1 -1
  89. package/lib/data/data1d/Spectrum1D/peaks/autoPeakPicking.js +2 -1
  90. package/lib/data/data1d/Spectrum1D/peaks/autoPeakPicking.js.map +1 -1
  91. package/lib/data/data1d/Spectrum1D/ranges/autoRangesDetection.d.ts.map +1 -1
  92. package/lib/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +8 -5
  93. package/lib/data/data1d/Spectrum1D/ranges/autoRangesDetection.js.map +1 -1
  94. package/lib/utils/clipboard/clipboardComponents.d.ts.map +1 -1
  95. package/lib/utils/clipboard/clipboardComponents.js +12 -4
  96. package/lib/utils/clipboard/clipboardComponents.js.map +1 -1
  97. package/lib/versionInfo.js +1 -1
  98. package/package.json +22 -20
  99. package/src/component/1d/FloatPublicationString.tsx +4 -9
  100. package/src/component/1d/peaks/PeakAnnotations.tsx +147 -22
  101. package/src/component/1d/peaks/PeakAnnotationsSpreadMode.tsx +3 -3
  102. package/src/component/1d/peaks/Peaks.tsx +37 -31
  103. package/src/component/1d/ranges/Ranges.tsx +4 -4
  104. package/src/component/2d/zones/SignalsGuideLines.tsx +11 -6
  105. package/src/component/elements/DraggableDialog.tsx +0 -2
  106. package/src/component/elements/EditableColumn.tsx +2 -0
  107. package/src/component/elements/ReactTable/Elements/ReactTableRow.tsx +0 -1
  108. package/src/component/elements/ReactTable/ReactTable.tsx +0 -3
  109. package/src/component/elements/Sections.tsx +10 -11
  110. package/src/component/elements/Tab/Tabs.tsx +1 -1
  111. package/src/component/hooks/useActiveSpectrumRangesViewState.ts +24 -16
  112. package/src/component/hooks/useCombinedRefs.ts +1 -1
  113. package/src/component/hooks/useTextMetrics.ts +27 -0
  114. package/src/component/modal/MultipletAnalysisModal.tsx +2 -0
  115. package/src/component/modal/changeSum/ChangeSumModalContents.tsx +2 -0
  116. package/src/component/modal/changeSum/SelectMolecule.tsx +2 -0
  117. package/src/component/panels/MoleculesPanel/MoleculePanel.tsx +2 -0
  118. package/src/component/panels/MoleculesPanel/MoleculePanelHeader.tsx +4 -3
  119. package/src/component/panels/SpectraPanel/SpectraPanelHeader.tsx +1 -1
  120. package/src/component/panels/SummaryPanel/CorrelationTable/editLink/EditPathLength.tsx +3 -6
  121. package/src/component/panels/SummaryPanel/SummaryPanel.tsx +10 -16
  122. package/src/component/panels/filtersPanel/Filters/hooks/usePhaseCorrection.tsx +14 -14
  123. package/src/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.tsx +10 -8
  124. package/src/component/panels/multipleAnalysisPanel/preferences/MultipleAnalysisCodeEditor.tsx +2 -0
  125. package/src/component/reducer/actions/InsetActions.ts +6 -6
  126. package/src/component/reducer/actions/PeaksActions.ts +7 -2
  127. package/src/component/reducer/actions/RangesActions.ts +17 -16
  128. package/src/component/reducer/helper/setRangesViewProperty.ts +8 -5
  129. package/src/component/utility/isHomoNuclear.ts +11 -0
  130. package/src/data/data1d/Spectrum1D/peaks/autoPeakPicking.ts +2 -0
  131. package/src/data/data1d/Spectrum1D/ranges/autoRangesDetection.ts +8 -5
  132. package/src/utils/clipboard/clipboardComponents.tsx +15 -5
  133. package/src/versionInfo.ts +1 -1
  134. package/lib/component/elements/pdnd.cjs +0 -25
  135. package/lib/component/elements/pdnd.cjs.map +0 -1
  136. package/lib/component/elements/pdnd.d.cts +0 -7
  137. package/lib/component/elements/pdnd.d.cts.map +0 -1
  138. package/lib/component/hooks/useCanvasContext.d.ts +0 -2
  139. package/lib/component/hooks/useCanvasContext.d.ts.map +0 -1
  140. package/lib/component/hooks/useCanvasContext.js +0 -13
  141. package/lib/component/hooks/useCanvasContext.js.map +0 -1
  142. package/src/component/elements/pdnd.cts +0 -19
  143. package/src/component/hooks/useCanvasContext.ts +0 -15
@@ -164,7 +164,6 @@ export default function MoleculePanelHeader(props: MoleculePanelHeaderProps) {
164
164
  (selected: any) => {
165
165
  const m = molecules?.[currentIndex];
166
166
  const molecule = Molecule.fromMolfile(m.molfile);
167
-
168
167
  if (molecule) {
169
168
  switch (selected?.id) {
170
169
  case 'smiles':
@@ -175,8 +174,10 @@ export default function MoleculePanelHeader(props: MoleculePanelHeaderProps) {
175
174
  copyHandler(m.molfile, 'MOLFile');
176
175
  break;
177
176
  case 'molfileV2': {
178
- copyHandler(molecule.toMolfile(), 'MOLFile');
179
-
177
+ copyHandler(
178
+ molecule.toMolfile({ customLabelPosition: 'normal' }),
179
+ 'MOLFile',
180
+ );
180
181
  break;
181
182
  }
182
183
  case 'png':
@@ -119,7 +119,7 @@ function SpectraPanelHeaderInner({
119
119
  const hasActiveSpectra = activeSpectra && activeSpectra?.length > 0;
120
120
  const spectraLengthPerTab = getSpectraByNucleus(activeTab, data)?.length;
121
121
  const { getToggleVisibilityButtons } = useToggleSpectraVisibility(
122
- spectraLengthPerTab < 5
122
+ spectraLengthPerTab < 3
123
123
  ? {
124
124
  enableHideSelected: false,
125
125
  enableShowSelected: false,
@@ -1,7 +1,7 @@
1
1
  import styled from '@emotion/styled';
2
2
  import type { Signal2D } from '@zakodium/nmr-types';
3
3
  import type { FromTo } from 'cheminfo-types';
4
- import { useCallback, useEffect, useState } from 'react';
4
+ import { useCallback, useState } from 'react';
5
5
 
6
6
  import DefaultPathLengths from '../../../../../data/constants/DefaultPathLengths.js';
7
7
  import Button from '../../../../elements/Button.js';
@@ -60,7 +60,8 @@ function EditPathLength({ signal, experimentType, onEdit }: InputProps) {
60
60
  ? (signal.j.pathLength as FromTo).to
61
61
  : DefaultPathLengths[experimentType]?.to || 0,
62
62
  );
63
- const [isError, setIsError] = useState<boolean>(false);
63
+
64
+ const isError = from <= 0 || from > to;
64
65
 
65
66
  const handleOnEdit = useCallback(() => {
66
67
  const pathLength: FromTo = {
@@ -78,10 +79,6 @@ function EditPathLength({ signal, experimentType, onEdit }: InputProps) {
78
79
  onEdit(editedSignal);
79
80
  }, [to, from, onEdit, signal]);
80
81
 
81
- useEffect(() => {
82
- setIsError(from <= 0 || from > to);
83
- }, [to, from]);
84
-
85
82
  return (
86
83
  <Container>
87
84
  <p>Setting of the minimum and maximum path length (J coupling).</p>
@@ -7,7 +7,7 @@ import type {
7
7
  Values as CorrelationValues,
8
8
  } from 'nmr-correlation';
9
9
  import { getLinkDelta, getLinkDim } from 'nmr-correlation';
10
- import { memo, useCallback, useEffect, useMemo, useState } from 'react';
10
+ import { memo, useCallback, useMemo, useState } from 'react';
11
11
  import { FaFlask, FaSlidersH } from 'react-icons/fa';
12
12
 
13
13
  import {
@@ -102,9 +102,6 @@ function SummaryPanel() {
102
102
  molecularFormula: false,
103
103
  });
104
104
 
105
- const [additionalColumnData, setAdditionalColumnData] = useState<
106
- Correlation[]
107
- >([]);
108
105
  const [
109
106
  selectedAdditionalColumnsAtomType,
110
107
  setSelectedAdditionalColumnsAtomType,
@@ -265,21 +262,18 @@ function SummaryPanel() {
265
262
  });
266
263
  }, [correlationsData]);
267
264
 
268
- useEffect(() => {
265
+ const additionalColumnData = useMemo<Correlation[]>(() => {
269
266
  const _selectedAdditionalColumnsAtomType =
270
267
  selectedAdditionalColumnsAtomType.split('-')[0];
271
-
272
- setAdditionalColumnData(
273
- filteredCorrelationsData
274
- ? filteredCorrelationsData.values
275
- .filter(
276
- (correlation: any) =>
277
- correlation.atomType === _selectedAdditionalColumnsAtomType,
278
- )
279
- // eslint-disable-next-line unicorn/no-array-reverse
280
- .reverse()
281
- : [],
268
+ if (!filteredCorrelationsData) {
269
+ return [];
270
+ }
271
+ const result = filteredCorrelationsData.values.filter(
272
+ (correlation: any) =>
273
+ correlation.atomType === _selectedAdditionalColumnsAtomType,
282
274
  );
275
+ result.reverse();
276
+ return result;
283
277
  }, [filteredCorrelationsData, selectedAdditionalColumnsAtomType]);
284
278
 
285
279
  const editEquivalencesSaveHandler = useCallback(
@@ -55,14 +55,6 @@ export function usePhaseCorrection(
55
55
  itemTextKey: 'label',
56
56
  });
57
57
 
58
- function syncWatch(sharedFilterOptions: any) {
59
- updateInputRangeInitialValue(sharedFilterOptions);
60
- setValue(sharedFilterOptions);
61
- }
62
-
63
- const { syncFilterOptions, clearSyncFilterOptions } =
64
- useSyncedFilterOptions(syncWatch);
65
-
66
58
  useEffect(() => {
67
59
  if (filter && phaseCorrectionTypeItem?.value === 'manual') {
68
60
  const { ph0 = 0, ph1 = 0 } = filter?.value || {};
@@ -79,6 +71,20 @@ export function usePhaseCorrection(
79
71
  }
80
72
  }, [filter, phaseCorrectionTypeItem]);
81
73
 
74
+ const updateInputRangeInitialValue = useCallback((value: any) => {
75
+ // update InputRange initial value
76
+ ph0Ref.current?.setValue(value.ph0);
77
+ ph1Ref.current?.setValue(value.ph1);
78
+ }, []);
79
+
80
+ function syncWatch(sharedFilterOptions: any) {
81
+ updateInputRangeInitialValue(sharedFilterOptions);
82
+ setValue(sharedFilterOptions);
83
+ }
84
+
85
+ const { syncFilterOptions, clearSyncFilterOptions } =
86
+ useSyncedFilterOptions(syncWatch);
87
+
82
88
  function handleApplyFilter() {
83
89
  switch (phaseCorrectionTypeItem?.value) {
84
90
  case 'automatic': {
@@ -123,12 +129,6 @@ export function usePhaseCorrection(
123
129
  [data.re, dispatch, pivot?.index],
124
130
  );
125
131
 
126
- const updateInputRangeInitialValue = useCallback((value: any) => {
127
- // update InputRange initial value
128
- ph0Ref.current?.setValue(value.ph0);
129
- ph1Ref.current?.setValue(value.ph1);
130
- }, []);
131
-
132
132
  const handleInput = useCallback(
133
133
  (valueAsNumber: any, valueAsString: any, element: any) => {
134
134
  const { name } = element;
@@ -59,14 +59,6 @@ export function usePhaseCorrectionTwoDimensions(filter: Filter2DEntry | null) {
59
59
  }, 250),
60
60
  );
61
61
 
62
- function syncWatch(sharedFilterOptions: any) {
63
- updateInputRangeInitialValue(sharedFilterOptions);
64
- setValue(sharedFilterOptions);
65
- }
66
-
67
- const { syncFilterOptions, clearSyncFilterOptions } =
68
- useSyncedFilterOptions(syncWatch);
69
-
70
62
  const {
71
63
  value: phaseCorrectionSelectItem,
72
64
  ...defaultPhaseCorrectionSelectProps
@@ -85,6 +77,8 @@ export function usePhaseCorrectionTwoDimensions(filter: Filter2DEntry | null) {
85
77
  (phaseOptions as any)[direction] = { ph0, ph1 };
86
78
  }
87
79
 
80
+ // TODO: change this to not use an effect
81
+ // eslint-disable-next-line react-hooks/set-state-in-effect
88
82
  setValue(phaseOptions);
89
83
  valueRef.current = phaseOptions;
90
84
  }
@@ -135,6 +129,14 @@ export function usePhaseCorrectionTwoDimensions(filter: Filter2DEntry | null) {
135
129
  [activeTraceDirection],
136
130
  );
137
131
 
132
+ function syncWatch(sharedFilterOptions: any) {
133
+ updateInputRangeInitialValue(sharedFilterOptions);
134
+ setValue(sharedFilterOptions);
135
+ }
136
+
137
+ const { syncFilterOptions, clearSyncFilterOptions } =
138
+ useSyncedFilterOptions(syncWatch);
139
+
138
140
  const handleInputValueChange = useCallback(
139
141
  (valueAsNumber: any, valueAsString: any, inputElement: any) => {
140
142
  const { name } = inputElement;
@@ -23,6 +23,8 @@ function MultipleAnalysisCodeEditor({ data }: MultipleAnalysisCodeEditorProps) {
23
23
  useEffect(() => {
24
24
  const evalResult = evaluate(code, data);
25
25
  if (evalResult instanceof Error) {
26
+ // TODO: change this to not use an effect.
27
+ // eslint-disable-next-line react-hooks/set-state-in-effect
26
28
  setResult(evalResult.message);
27
29
  } else {
28
30
  setValue('code', code);
@@ -18,7 +18,7 @@ import { getInsetXScale } from '../../1d/utilities/scale.js';
18
18
  import type { ZoomOptions } from '../../EventsTrackers/BrushTracker.js';
19
19
  import { defaultIntegralsViewState } from '../../hooks/useActiveSpectrumIntegralsViewState.js';
20
20
  import { defaultPeaksViewState } from '../../hooks/useActiveSpectrumPeaksViewState.js';
21
- import { defaultRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState.js';
21
+ import { getDefaultRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState.js';
22
22
  import {
23
23
  convertPercentToPixel,
24
24
  convertPixelToPercent,
@@ -116,7 +116,7 @@ function handleAddInset(draft: Draft<State>, action: AddInsetAction) {
116
116
  const {
117
117
  yDomain,
118
118
  view: {
119
- spectra: { activeTab },
119
+ spectra: { activeTab: nucleus },
120
120
  },
121
121
  width: baseWidth,
122
122
  height: baseHeight,
@@ -142,16 +142,16 @@ function handleAddInset(draft: Draft<State>, action: AddInsetAction) {
142
142
  yDomain,
143
143
  zoomHistory: [{ xDomain, yDomain }],
144
144
  view: {
145
- ranges: { ...defaultRangesViewState },
145
+ ranges: getDefaultRangesViewState(nucleus),
146
146
  peaks: { ...defaultPeaksViewState },
147
147
  integrals: { ...defaultIntegralsViewState },
148
148
  },
149
149
  };
150
150
 
151
- if (draft.insets?.[activeTab]) {
152
- draft.insets[activeTab].push(inset);
151
+ if (draft.insets?.[nucleus]) {
152
+ draft.insets[nucleus].push(inset);
153
153
  } else {
154
- draft.insets[activeTab] = [inset];
154
+ draft.insets[nucleus] = [inset];
155
155
  }
156
156
  }
157
157
  function handleDeleteInset(draft: Draft<State>, action: DeleteInsetAction) {
@@ -18,7 +18,7 @@ import {
18
18
  optimizePeaks,
19
19
  } from '../../../data/data1d/Spectrum1D/index.js';
20
20
  import { defaultPeaksViewState } from '../../hooks/useActiveSpectrumPeaksViewState.js';
21
- import { defaultRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState.js';
21
+ import { getDefaultRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState.js';
22
22
  import type { FilterType } from '../../utility/filterType.js';
23
23
  import { getClosePeak } from '../../utility/getClosePeak.js';
24
24
  import type { State } from '../Reducer.js';
@@ -264,6 +264,11 @@ function toggleDisplayingPeaks(
264
264
  draft: Draft<State>,
265
265
  key: keyof Pick<ViewState, 'peaks' | 'ranges'>,
266
266
  ) {
267
+ const {
268
+ view: {
269
+ spectra: { activeTab: nucleus },
270
+ },
271
+ } = draft;
267
272
  const activeSpectrum = getActiveSpectrum(draft);
268
273
 
269
274
  if (activeSpectrum?.id) {
@@ -281,7 +286,7 @@ function toggleDisplayingPeaks(
281
286
 
282
287
  break;
283
288
  case 'ranges':
284
- defaultsViewOptions = { ...defaultRangesViewState };
289
+ defaultsViewOptions = getDefaultRangesViewState(nucleus);
285
290
  break;
286
291
  default:
287
292
  break;
@@ -231,12 +231,15 @@ function handleAutoRangesDetection(
231
231
  const detectionOptions: any = {
232
232
  rangePicking: {
233
233
  integrationSum: 100,
234
- compile: true,
235
- frequencyCluster: 16,
234
+ compile: nucleus === '1H',
235
+ frequencyCluster: nucleus === '1H' ? 16 : 0,
236
236
  clean: 0.3,
237
237
  keepPeaks: true,
238
+ joinOverlapRanges: nucleus === '1H',
238
239
  },
239
240
  peakPicking: {
241
+ smoothY: false,
242
+ sensitivity: 100,
240
243
  broadWidth: 0.05,
241
244
  thresholdFactor: 8,
242
245
  minMaxRatio,
@@ -257,25 +260,23 @@ function handleAutoRangesDetection(
257
260
  //action
258
261
  function handleAutoSpectraRangesDetection(draft: Draft<State>) {
259
262
  const peakPicking = {
263
+ sensitivity: 100,
260
264
  thresholdFactor: 8,
261
265
  minMaxRatio: 0.05,
262
266
  };
263
- const rangePicking = {
264
- integrationSum: 100,
265
- compile: true,
266
- frequencyCluster: 16,
267
- clean: 0.3,
268
- keepPeaks: true,
269
- };
270
- const {
271
- data,
272
- view: {
273
- spectra: { activeTab: nucleus },
274
- },
275
- molecules,
276
- } = draft;
267
+ const { data, molecules } = draft;
268
+
277
269
  for (const datum of data) {
278
270
  if (datum.info.dimension === 1) {
271
+ const nucleus = datum.info.nucleus as string;
272
+ const rangePicking = {
273
+ integrationSum: 100,
274
+ compile: nucleus === '1H',
275
+ frequencyCluster: nucleus === '1H' ? 16 : 0,
276
+ clean: 0.3,
277
+ keepPeaks: true,
278
+ joinOverlapRanges: nucleus === '1H',
279
+ };
279
280
  detectRanges(datum as Spectrum1D, {
280
281
  peakPicking,
281
282
  rangePicking,
@@ -1,7 +1,7 @@
1
1
  import type { RangesViewState } from '@zakodium/nmrium-core';
2
2
  import type { Draft } from 'immer';
3
3
 
4
- import { defaultRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState.js';
4
+ import { getDefaultRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState.js';
5
5
  import type { State } from '../Reducer.js';
6
6
 
7
7
  import { getActiveSpectrum } from './getActiveSpectrum.js';
@@ -56,10 +56,13 @@ export function initializeRangeViewObject(
56
56
  draft: Draft<State>,
57
57
  spectrumID: string,
58
58
  ) {
59
- const rangesView = draft.view.ranges;
59
+ const {
60
+ ranges,
61
+ spectra: { activeTab: nucleus },
62
+ } = draft.view;
60
63
 
61
- if (spectrumID in rangesView) return;
64
+ if (spectrumID in ranges) return;
62
65
 
63
- const defaultRangesView = { ...defaultRangesViewState };
64
- rangesView[spectrumID] = defaultRangesView;
66
+ const defaultRangesView = getDefaultRangesViewState(nucleus);
67
+ ranges[spectrumID] = defaultRangesView;
65
68
  }
@@ -0,0 +1,11 @@
1
+ export function isHomoNuclear(nuclei: string | string[], splitSeparator = ',') {
2
+ let parts: string[] = [];
3
+
4
+ if (typeof nuclei === 'string') {
5
+ parts = nuclei.split(splitSeparator).map((s) => s.trim());
6
+ } else {
7
+ parts = nuclei;
8
+ }
9
+
10
+ return parts.length === 1 || parts.every((p) => p === parts[0]);
11
+ }
@@ -9,6 +9,7 @@ export function autoPeakPicking(spectrum: Spectrum1D, options: any) {
9
9
  maxNumberOfPeaks,
10
10
  noiseFactor,
11
11
  direction,
12
+ sensitivity = 100,
12
13
  windowFromIndex,
13
14
  windowToIndex,
14
15
  } = options;
@@ -28,6 +29,7 @@ export function autoPeakPicking(spectrum: Spectrum1D, options: any) {
28
29
  {
29
30
  frequency,
30
31
  direction,
32
+ sensitivity,
31
33
  shape: { kind: 'lorentzian' },
32
34
  noiseLevel: noise * noiseFactor,
33
35
  minMaxRatio, // Threshold to determine if a given peak should be considered as a noise
@@ -8,6 +8,7 @@ const defaultPeakPickingOptions = {
8
8
  realTopDetection: true,
9
9
  maxCriteria: true,
10
10
  smoothY: true,
11
+ sensitivity: 100,
11
12
  broadWidth: 0.25,
12
13
  broadRatio: 0.0025,
13
14
  integrationSum: 100,
@@ -23,7 +24,7 @@ export default function autoRangesDetection(
23
24
 
24
25
  let { re, x } = spectrum.data;
25
26
 
26
- const { originFrequency, nucleus } = spectrum.info;
27
+ const { originFrequency, nucleus, solvent } = spectrum.info;
27
28
 
28
29
  const { windowFromIndex, windowToIndex, peakPicking, rangePicking } = options;
29
30
 
@@ -34,12 +35,13 @@ export default function autoRangesDetection(
34
35
  };
35
36
 
36
37
  const rangesOptions = {
37
- frequency: originFrequency,
38
38
  nucleus,
39
- compile: true,
40
- frequencyCluster: 13,
41
- keepPeaks: true,
42
39
  clean: 0.3,
40
+ keepPeaks: true,
41
+ compile: nucleus === '1H',
42
+ frequency: originFrequency,
43
+ joinOverlapRanges: nucleus === '1H',
44
+ frequencyCluster: nucleus === '1H' ? 13 : 0,
43
45
  ...rangePicking,
44
46
  };
45
47
 
@@ -54,6 +56,7 @@ export default function autoRangesDetection(
54
56
  const ranges = xyAutoRangesPicking(
55
57
  { x, y: re },
56
58
  {
59
+ impurities: { solvent },
57
60
  peakPicking: peakPickingOptions,
58
61
  ranges: rangesOptions,
59
62
  },
@@ -139,7 +139,9 @@ interface ClipboardFallbackReadProps extends CFBP {
139
139
  }
140
140
  function ClipboardFallbackRead(props: ClipboardFallbackReadProps) {
141
141
  const onFileRef = useRef(props.onRead);
142
- onFileRef.current = props.onRead;
142
+ useEffect(() => {
143
+ onFileRef.current = props.onRead;
144
+ });
143
145
 
144
146
  const onSubmit = useCallback((event: FormEvent<HTMLFormElement>) => {
145
147
  event.preventDefault();
@@ -178,9 +180,12 @@ interface ClipboardFallbackReadTextProps extends CFBP {
178
180
  onReadText: (text: string) => void;
179
181
  mode: 'readText';
180
182
  }
183
+
181
184
  function ClipboardFallbackReadText(props: ClipboardFallbackReadTextProps) {
182
185
  const onTextRef = useRef(props.onReadText);
183
- onTextRef.current = props.onReadText;
186
+ useEffect(() => {
187
+ onTextRef.current = props.onReadText;
188
+ });
184
189
 
185
190
  const onSubmit = useCallback((event: FormEvent<HTMLFormElement>) => {
186
191
  event.preventDefault();
@@ -219,9 +224,12 @@ interface ClipboardFallbackWriteProps extends CFBP {
219
224
  file: File;
220
225
  mode: 'write';
221
226
  }
227
+
222
228
  function ClipboardFallbackWrite(props: ClipboardFallbackWriteProps) {
223
229
  const onDismissRef = useRef(props.onDismiss);
224
- onDismissRef.current = props.onDismiss;
230
+ useEffect(() => {
231
+ onDismissRef.current = props.onDismiss;
232
+ });
225
233
 
226
234
  const onSubmit = useCallback((event: FormEvent<HTMLFormElement>) => {
227
235
  event.preventDefault();
@@ -259,13 +267,15 @@ interface ClipboardFallbackWriteTextProps extends CFBP {
259
267
  text: string;
260
268
  mode: 'writeText';
261
269
  }
270
+
262
271
  function ClipboardFallbackWriteText(props: ClipboardFallbackWriteTextProps) {
263
272
  const onDismissRef = useRef(props.onDismiss);
264
- onDismissRef.current = props.onDismiss;
273
+ useEffect(() => {
274
+ onDismissRef.current = props.onDismiss;
275
+ });
265
276
 
266
277
  const onSubmit = useCallback((event: FormEvent<HTMLFormElement>) => {
267
278
  event.preventDefault();
268
-
269
279
  onDismissRef.current();
270
280
  }, []);
271
281
 
@@ -1 +1 @@
1
- export default { version: 'v1.4.0' };
1
+ export default { version: 'v1.6.0' };
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getReorderDestinationIndex = exports.pointerOutsideOfPreview = exports.setCustomNativeDragPreview = exports.combine = exports.extractClosestEdge = exports.attachClosestEdge = exports.dropTargetForElements = exports.draggable = void 0;
4
- // https://github.com/atlassian/pragmatic-drag-and-drop/issues/27
5
- // Given how `@atlaskit/pragmatic-drag-and-drop` publishes ESM in a non-native way,
6
- // we have to trick TS into using the CJS build so that our build is compatible
7
- // with native ESM.
8
- // This file is not compatible with the `verbatimModuleSyntax` TS option.
9
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
10
- // @ts-nocheck
11
- var adapter_1 = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
12
- Object.defineProperty(exports, "draggable", { enumerable: true, get: function () { return adapter_1.draggable; } });
13
- Object.defineProperty(exports, "dropTargetForElements", { enumerable: true, get: function () { return adapter_1.dropTargetForElements; } });
14
- var closest_edge_1 = require("@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge");
15
- Object.defineProperty(exports, "attachClosestEdge", { enumerable: true, get: function () { return closest_edge_1.attachClosestEdge; } });
16
- Object.defineProperty(exports, "extractClosestEdge", { enumerable: true, get: function () { return closest_edge_1.extractClosestEdge; } });
17
- var combine_1 = require("@atlaskit/pragmatic-drag-and-drop/combine");
18
- Object.defineProperty(exports, "combine", { enumerable: true, get: function () { return combine_1.combine; } });
19
- var set_custom_native_drag_preview_1 = require("@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview");
20
- Object.defineProperty(exports, "setCustomNativeDragPreview", { enumerable: true, get: function () { return set_custom_native_drag_preview_1.setCustomNativeDragPreview; } });
21
- var pointer_outside_of_preview_1 = require("@atlaskit/pragmatic-drag-and-drop/element/pointer-outside-of-preview");
22
- Object.defineProperty(exports, "pointerOutsideOfPreview", { enumerable: true, get: function () { return pointer_outside_of_preview_1.pointerOutsideOfPreview; } });
23
- var get_reorder_destination_index_1 = require("@atlaskit/pragmatic-drag-and-drop-hitbox/util/get-reorder-destination-index");
24
- Object.defineProperty(exports, "getReorderDestinationIndex", { enumerable: true, get: function () { return get_reorder_destination_index_1.getReorderDestinationIndex; } });
25
- //# sourceMappingURL=pdnd.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pdnd.cjs","sourceRoot":"","sources":["../../../src/component/elements/pdnd.cts"],"names":[],"mappings":";;;AAAA,iEAAiE;AACjE,mFAAmF;AACnF,+EAA+E;AAC/E,mBAAmB;AACnB,yEAAyE;AACzE,6DAA6D;AAC7D,cAAc;AACd,6EAG2D;AAFzD,oGAAA,SAAS,OAAA;AACT,gHAAA,qBAAqB,OAAA;AAEvB,sFAG+D;AAF7D,iHAAA,iBAAiB,OAAA;AACjB,kHAAA,kBAAkB,OAAA;AAEpB,qEAAoE;AAA3D,kGAAA,OAAO,OAAA;AAChB,2HAAsH;AAA7G,4IAAA,0BAA0B,OAAA;AACnC,mHAA+G;AAAtG,qIAAA,uBAAuB,OAAA;AAChC,6HAAyH;AAAhH,2IAAA,0BAA0B,OAAA"}
@@ -1,7 +0,0 @@
1
- export { draggable, dropTargetForElements, } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
2
- export { attachClosestEdge, extractClosestEdge, } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
3
- export { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
4
- export { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
5
- export { pointerOutsideOfPreview } from '@atlaskit/pragmatic-drag-and-drop/element/pointer-outside-of-preview';
6
- export { getReorderDestinationIndex } from '@atlaskit/pragmatic-drag-and-drop-hitbox/util/get-reorder-destination-index';
7
- //# sourceMappingURL=pdnd.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pdnd.d.cts","sourceRoot":"","sources":["../../../src/component/elements/pdnd.cts"],"names":[],"mappings":"AAOA,OAAO,EACL,SAAS,EACT,qBAAqB,GACtB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EACL,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,2CAA2C,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,0EAA0E,CAAC;AACtH,OAAO,EAAE,uBAAuB,EAAE,MAAM,sEAAsE,CAAC;AAC/G,OAAO,EAAE,0BAA0B,EAAE,MAAM,6EAA6E,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare function useCanvasContext(labelSize?: number): CanvasRenderingContext2D | null;
2
- //# sourceMappingURL=useCanvasContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCanvasContext.d.ts","sourceRoot":"","sources":["../../../src/component/hooks/useCanvasContext.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,CAAC,SAAS,SAAK,mCAY9C"}
@@ -1,13 +0,0 @@
1
- import { useRef } from 'react';
2
- export function useCanvasContext(labelSize = 12) {
3
- const contextRef = useRef(null);
4
- if (!contextRef.current) {
5
- const canvas = document.createElement('canvas');
6
- contextRef.current = canvas.getContext('2d');
7
- if (contextRef.current) {
8
- contextRef.current.font = `${labelSize}px Arial`;
9
- }
10
- }
11
- return contextRef.current;
12
- }
13
- //# sourceMappingURL=useCanvasContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCanvasContext.js","sourceRoot":"","sources":["../../../src/component/hooks/useCanvasContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B,MAAM,UAAU,gBAAgB,CAAC,SAAS,GAAG,EAAE;IAC7C,MAAM,UAAU,GAAG,MAAM,CAAkC,IAAI,CAAC,CAAC;IAEjE,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QACxB,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChD,UAAU,CAAC,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;YACvB,UAAU,CAAC,OAAO,CAAC,IAAI,GAAG,GAAG,SAAS,UAAU,CAAC;QACnD,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC,OAAO,CAAC;AAC5B,CAAC"}
@@ -1,19 +0,0 @@
1
- // https://github.com/atlassian/pragmatic-drag-and-drop/issues/27
2
- // Given how `@atlaskit/pragmatic-drag-and-drop` publishes ESM in a non-native way,
3
- // we have to trick TS into using the CJS build so that our build is compatible
4
- // with native ESM.
5
- // This file is not compatible with the `verbatimModuleSyntax` TS option.
6
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
7
- // @ts-nocheck
8
- export {
9
- draggable,
10
- dropTargetForElements,
11
- } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
12
- export {
13
- attachClosestEdge,
14
- extractClosestEdge,
15
- } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
16
- export { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
17
- export { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
18
- export { pointerOutsideOfPreview } from '@atlaskit/pragmatic-drag-and-drop/element/pointer-outside-of-preview';
19
- export { getReorderDestinationIndex } from '@atlaskit/pragmatic-drag-and-drop-hitbox/util/get-reorder-destination-index';
@@ -1,15 +0,0 @@
1
- import { useRef } from 'react';
2
-
3
- export function useCanvasContext(labelSize = 12) {
4
- const contextRef = useRef<CanvasRenderingContext2D | null>(null);
5
-
6
- if (!contextRef.current) {
7
- const canvas = document.createElement('canvas');
8
- contextRef.current = canvas.getContext('2d');
9
- if (contextRef.current) {
10
- contextRef.current.font = `${labelSize}px Arial`;
11
- }
12
- }
13
-
14
- return contextRef.current;
15
- }