nmrium 0.52.0 → 0.54.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 (100) hide show
  1. package/lib/component/1d/Viewer1D.js +48 -17
  2. package/lib/component/1d/ranges/AssignmentLabel.d.ts +7 -0
  3. package/lib/component/1d/ranges/AssignmentLabel.js +10 -0
  4. package/lib/component/1d/ranges/Range.js +15 -6
  5. package/lib/component/1d/tool/XLabelPointer.js +4 -12
  6. package/lib/component/2d/tools/XYLabelPointer.js +3 -9
  7. package/lib/component/context/LoggerContext.js +11 -4
  8. package/lib/component/elements/CloseButton.d.ts +1 -1
  9. package/lib/component/elements/CustomToolTip.d.ts +8 -0
  10. package/lib/component/elements/CustomToolTip.js +107 -0
  11. package/lib/component/elements/EditableColumn.js +6 -5
  12. package/lib/component/elements/SaveButton.d.ts +1 -1
  13. package/lib/component/elements/formik/FormikError.js +2 -4
  14. package/lib/component/elements/formik/FormikInput.js +2 -2
  15. package/lib/component/header/Header.js +1 -1
  16. package/lib/component/header/PhaseCorrectionTwoDimensionsPanel.js +41 -10
  17. package/lib/component/hooks/useActiveSpectrumRangesViewState.js +1 -0
  18. package/lib/component/hooks/useActiveSpectrumZonesViewState.js +1 -0
  19. package/lib/component/hooks/useToolsFunctions.js +7 -1
  20. package/lib/component/main/NMRiumStateProvider.js +12 -2
  21. package/lib/component/modal/AboutPredictionModal.js +1 -1
  22. package/lib/component/modal/AboutSpectrumSimulationModal.js +1 -1
  23. package/lib/component/modal/CopyClipboardModal.js +1 -1
  24. package/lib/component/modal/EditPeakShapeModal.js +1 -1
  25. package/lib/component/modal/ImportPublicationStringModal.d.ts +5 -3
  26. package/lib/component/modal/ImportPublicationStringModal.js +18 -9
  27. package/lib/component/modal/PredictSpectraModal.js +1 -1
  28. package/lib/component/modal/aboutUs/AboutUsModal.js +1 -1
  29. package/lib/component/modal/changeSum/ChangeSumModal.js +1 -1
  30. package/lib/component/modal/editRange/EditRangeModal.js +1 -1
  31. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.js +1 -1
  32. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.js +1 -1
  33. package/lib/component/modal/editZone/EditZoneModal.js +1 -1
  34. package/lib/component/modal/setting/GeneralSettings.js +12 -19
  35. package/lib/component/panels/AutomaticAssignment/AutomaticAssignment.js +2 -2
  36. package/lib/component/panels/IntegralsPanel/IntegralPanel.js +2 -2
  37. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +2 -2
  38. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +1 -1
  39. package/lib/component/panels/PeaksPanel/PeaksPanel.js +5 -5
  40. package/lib/component/panels/RangesPanel/RangesHeader.js +29 -15
  41. package/lib/component/panels/RangesPanel/RangesPreferences.js +19 -13
  42. package/lib/component/panels/RangesPanel/RangesTable.js +1 -1
  43. package/lib/component/panels/RangesPanel/RangesTableRow.js +2 -1
  44. package/lib/component/panels/RangesPanel/TableColumns/RangeAssignmentColumn.d.ts +7 -0
  45. package/lib/component/panels/RangesPanel/TableColumns/RangeAssignmentColumn.js +16 -0
  46. package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +22 -8
  47. package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.js +1 -1
  48. package/lib/component/panels/SummaryPanel/SetMolecularFormulaModal.d.ts +5 -5
  49. package/lib/component/panels/SummaryPanel/SetMolecularFormulaModal.js +79 -89
  50. package/lib/component/panels/SummaryPanel/SetShiftTolerancesModal.d.ts +5 -4
  51. package/lib/component/panels/SummaryPanel/SetShiftTolerancesModal.js +66 -98
  52. package/lib/component/panels/SummaryPanel/SummaryPanel.js +13 -32
  53. package/lib/component/panels/ZonesPanel/ZonesPanel.js +4 -4
  54. package/lib/component/panels/databasePanel/DatabaseSearchOptions.js +2 -2
  55. package/lib/component/panels/header/DefaultPanelHeader.js +2 -2
  56. package/lib/component/panels/header/PreferencesHeader.js +1 -1
  57. package/lib/component/panels/header/SpectraAutomaticPickingButton.js +1 -1
  58. package/lib/component/panels/multipleAnalysisPanel/MultipleSpectraAnalysisPanel.js +4 -4
  59. package/lib/component/panels/spectrumSimulation/SpectrumSimulation.js +8 -1
  60. package/lib/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +1 -1
  61. package/lib/component/panels/spectrumSimulation/SpinSystemTable.js +1 -1
  62. package/lib/component/reducer/Reducer.js +4 -0
  63. package/lib/component/reducer/actions/FiltersActions.d.ts +3 -2
  64. package/lib/component/reducer/actions/FiltersActions.js +364 -318
  65. package/lib/component/reducer/actions/MoleculeActions.js +1 -1
  66. package/lib/component/reducer/actions/RangesActions.d.ts +9 -5
  67. package/lib/component/reducer/actions/RangesActions.js +31 -21
  68. package/lib/component/reducer/actions/SpectraActions.d.ts +5 -4
  69. package/lib/component/reducer/actions/SpectraActions.js +5 -1
  70. package/lib/component/reducer/actions/ToolsActions.js +13 -20
  71. package/lib/component/reducer/preferences/actions/setWorkspace.js +4 -3
  72. package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +6 -4
  73. package/lib/component/toolbar/ToolBar.js +112 -26
  74. package/lib/component/utility/export.js +1 -1
  75. package/lib/component/workspaces/workspaceDefaultProperties.js +7 -12
  76. package/lib/data/data1d/Spectrum1D/get1DColor.d.ts +10 -3
  77. package/lib/data/data1d/Spectrum1D/get1DColor.js +28 -2
  78. package/lib/data/data1d/Spectrum1D/index.d.ts +2 -2
  79. package/lib/data/data1d/Spectrum1D/index.js +2 -2
  80. package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +50 -0
  81. package/lib/data/data1d/Spectrum1D/ranges/createRange.js +51 -0
  82. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +2 -1
  83. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +4 -2
  84. package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +52 -0
  85. package/lib/data/data1d/Spectrum1D/ranges/resizeRange.js +28 -0
  86. package/lib/data/data2d/Spectrum2D/get2DColor.d.ts +11 -3
  87. package/lib/data/data2d/Spectrum2D/get2DColor.js +20 -4
  88. package/lib/data/data2d/Spectrum2D/getSlice.js +1 -1
  89. package/lib/data/data2d/Spectrum2D/zones/detectZonesManual.d.ts +1 -0
  90. package/lib/data/data2d/Spectrum2D/zones/initiateZones.d.ts +1 -0
  91. package/lib/data/utilities/generateColor.d.ts +7 -3
  92. package/lib/data/utilities/generateColor.js +5 -17
  93. package/lib/versionInfo.js +1 -1
  94. package/package.json +29 -29
  95. package/lib/component/elements/MolecularFormulaInput.d.ts +0 -6
  96. package/lib/component/elements/MolecularFormulaInput.js +0 -63
  97. package/lib/data/data1d/Spectrum1D/ranges/addRange.d.ts +0 -7
  98. package/lib/data/data1d/Spectrum1D/ranges/addRange.js +0 -31
  99. package/lib/data/data1d/Spectrum1D/ranges/changeRange.d.ts +0 -3
  100. package/lib/data/data1d/Spectrum1D/ranges/changeRange.js +0 -32
@@ -4,6 +4,7 @@ import lodashGet from 'lodash/get';
4
4
  import { rangesToACS } from 'nmr-processing';
5
5
  import { FaFileExport, FaUnlink, FaSitemap, FaChartBar } from 'react-icons/fa';
6
6
  import { ImLink } from 'react-icons/im';
7
+ import { LuSubtitles } from 'react-icons/lu';
7
8
  import { ClipboardFallbackModal } from '../../../utils/clipboard/clipboardComponents';
8
9
  import { useClipboard } from '../../../utils/clipboard/clipboardHooks';
9
10
  import { useAssignmentData } from '../../assignment/AssignmentsContext';
@@ -23,7 +24,7 @@ function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClic
23
24
  const assignmentData = useAssignmentData();
24
25
  const currentSum = lodashGet(ranges, 'options.sum', null);
25
26
  const rangesPreferences = usePanelPreferences('ranges', activeTab);
26
- const { showMultiplicityTrees, showJGraph, showIntegrals, showIntegralsValues, showPeaks, displayingMode, } = useActiveSpectrumRangesViewState();
27
+ const { showMultiplicityTrees, showJGraph, showIntegrals, showIntegralsValues, showPeaks, displayingMode, showAssignmentsLabels, } = useActiveSpectrumRangesViewState();
27
28
  function changeRangesSumHandler(options) {
28
29
  dispatch({ type: 'CHANGE_RANGE_SUM', payload: { options } });
29
30
  modal.close();
@@ -78,6 +79,12 @@ function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClic
78
79
  payload: { key: 'showJGraph' },
79
80
  });
80
81
  }
82
+ function handleShowAssignmentsLabel() {
83
+ dispatch({
84
+ type: 'TOGGLE_RANGES_VIEW_PROPERTY',
85
+ payload: { key: 'showAssignmentsLabels' },
86
+ });
87
+ }
81
88
  const { rawWriteWithType, shouldFallback, cleanShouldFallback, text } = useClipboard();
82
89
  function saveToClipboardHandler(value) {
83
90
  void rawWriteWithType(value, 'text/html').then(() => toaster.show({ message: 'Data copied to clipboard', intent: 'success' }));
@@ -111,67 +118,74 @@ function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClic
111
118
  {
112
119
  disabled: !hasRanges,
113
120
  icon: _jsx(FaFileExport, {}),
114
- title: 'Preview publication string',
121
+ tooltip: 'Preview publication string',
115
122
  onClick: saveAsHTMLHandler,
116
123
  },
117
124
  {
118
125
  component: (_jsx(ChangeSumModal, { onSave: changeRangesSumHandler, sumType: "ranges", currentSum: currentSum, sumOptions: ranges?.options })),
119
126
  },
127
+ {
128
+ icon: _jsx(ImLink, {}),
129
+ tooltip: 'Fixed integration sum',
130
+ onClick: changeSumConstantFlagHandler,
131
+ active: ranges?.options?.isSumConstant,
132
+ },
120
133
  {
121
134
  disabled: !hasRanges,
122
135
  icon: _jsx(FaUnlink, {}),
123
- title: 'Remove all assignments',
136
+ tooltip: 'Remove all assignments',
124
137
  onClick: handleOnRemoveAssignments,
125
138
  },
126
139
  {
127
140
  disabled: !hasRanges,
128
141
  icon: _jsx(FaSitemap, {}),
129
- title: `${booleanToString(!showMultiplicityTrees)} multiplicity trees in spectrum`,
142
+ tooltip: `${booleanToString(!showMultiplicityTrees)} multiplicity trees in spectrum`,
130
143
  onClick: handleSetShowMultiplicityTrees,
131
144
  active: showMultiplicityTrees,
132
145
  },
133
146
  {
134
147
  disabled: !hasRanges,
135
148
  icon: _jsx(FaChartBar, {}),
136
- title: `${booleanToString(!showJGraph)} J Graph`,
149
+ tooltip: `${booleanToString(!showJGraph)} J Graph`,
137
150
  onClick: handleShowJGraph,
138
151
  active: showJGraph,
139
152
  },
140
153
  {
141
154
  disabled: !hasRanges,
142
155
  icon: _jsx(SvgNmrIntegrate, {}),
143
- title: `${booleanToString(!showIntegrals)} integrals`,
156
+ tooltip: `${booleanToString(!showIntegrals)} integrals`,
144
157
  onClick: handleShowIntegrals,
145
158
  active: showIntegrals,
146
159
  },
147
160
  {
148
161
  disabled: !hasRanges,
149
162
  icon: _jsx(SvgNmrIntegrate, {}),
150
- title: `${booleanToString(!showIntegralsValues)} integrals values`,
163
+ tooltip: `${booleanToString(!showIntegralsValues)} integrals values`,
151
164
  onClick: handleShowIntegralsValues,
152
165
  active: showIntegralsValues,
153
166
  },
154
- {
155
- icon: _jsx(ImLink, {}),
156
- title: 'Fixed integration sum',
157
- onClick: changeSumConstantFlagHandler,
158
- active: ranges?.options?.isSumConstant,
159
- },
160
167
  {
161
168
  id: 'ranges-toggle-peaks',
162
169
  disabled: !hasRanges,
163
170
  icon: _jsx(SvgNmrPeaks, {}),
164
- title: `${booleanToString(!showPeaks)} peaks`,
171
+ tooltip: `${booleanToString(!showPeaks)} peaks`,
165
172
  onClick: () => toggleViewProperty('showPeaks'),
166
173
  active: showPeaks,
167
174
  },
168
175
  {
169
176
  disabled: !hasRanges,
170
177
  icon: _jsx(SvgNmrPeaksTopLabels, {}),
171
- title: `${displayingMode === 'spread' ? 'Single' : 'Spread'} mode`,
178
+ tooltip: `${displayingMode === 'spread' ? 'Single' : 'Spread'} mode`,
172
179
  onClick: toggleDisplayingMode,
173
180
  active: displayingMode === 'spread',
174
181
  },
182
+ {
183
+ disabled: !hasRanges,
184
+ icon: _jsx(LuSubtitles, {}),
185
+ tooltip: `${booleanToString(!showAssignmentsLabels)} assignments labels`,
186
+ onClick: handleShowAssignmentsLabel,
187
+ active: showAssignmentsLabels,
188
+ },
175
189
  ] }), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, text: text, label: "Preview publication string" })] }));
176
190
  }
177
191
  export default RangesHeader;
@@ -19,78 +19,84 @@ const formatFields = [
19
19
  },
20
20
  {
21
21
  id: 2,
22
+ label: 'Assignment label :',
23
+ checkControllerName: 'showAssignmentLabel',
24
+ hideFormatField: true,
25
+ },
26
+ {
27
+ id: 3,
22
28
  label: 'From (ppm) :',
23
29
  checkControllerName: 'from.show',
24
30
  formatControllerName: 'from.format',
25
31
  },
26
32
  {
27
- id: 3,
33
+ id: 4,
28
34
  label: 'To (ppm) :',
29
35
  checkControllerName: 'to.show',
30
36
  formatControllerName: 'to.format',
31
37
  },
32
38
  {
33
- id: 4,
39
+ id: 5,
34
40
  label: 'Absolute integration :',
35
41
  checkControllerName: 'absolute.show',
36
42
  formatControllerName: 'absolute.format',
37
43
  },
38
44
  {
39
- id: 5,
45
+ id: 6,
40
46
  label: 'Relative integration :',
41
47
  checkControllerName: 'relative.show',
42
48
  formatControllerName: 'relative.format',
43
49
  },
44
50
  {
45
- id: 6,
51
+ id: 7,
46
52
  label: 'δ (ppm) :',
47
53
  checkControllerName: 'deltaPPM.show',
48
54
  formatControllerName: 'deltaPPM.format',
49
55
  },
50
56
  {
51
- id: 7,
57
+ id: 8,
52
58
  label: 'δ (Hz) :',
53
59
  checkControllerName: 'deltaHz.show',
54
60
  formatControllerName: 'deltaHz.format',
55
61
  },
56
62
  {
57
- id: 8,
63
+ id: 9,
58
64
  label: 'Coupling (Hz) :',
59
65
  checkControllerName: 'coupling.show',
60
66
  formatControllerName: 'coupling.format',
61
67
  },
62
68
  {
63
- id: 9,
69
+ id: 10,
64
70
  label: 'Kind :',
65
71
  checkControllerName: 'showKind',
66
72
  hideFormatField: true,
67
73
  },
68
74
  {
69
- id: 10,
75
+ id: 11,
70
76
  label: 'Multiplicity :',
71
77
  checkControllerName: 'showMultiplicity',
72
78
  hideFormatField: true,
73
79
  },
74
80
  {
75
- id: 11,
76
- label: 'Assignment :',
81
+ id: 12,
82
+ label: 'Assignment links :',
77
83
  checkControllerName: 'showAssignment',
78
84
  hideFormatField: true,
79
85
  },
80
86
  {
81
- id: 12,
87
+ id: 13,
82
88
  label: 'Delete action :',
83
89
  checkControllerName: 'showDeleteAction',
84
90
  hideFormatField: true,
85
91
  },
86
92
  {
87
- id: 13,
93
+ id: 14,
88
94
  label: 'Zoom action :',
89
95
  checkControllerName: 'showZoomAction',
90
96
  hideFormatField: true,
91
97
  },
92
98
  {
93
- id: 14,
99
+ id: 15,
94
100
  label: 'Edit action :',
95
101
  checkControllerName: 'showEditAction',
96
102
  hideFormatField: true,
@@ -64,7 +64,7 @@ function RangesTable({ tableData, onUnlink, contextMenu = [], onContextMenuSelec
64
64
  const showActions = preferences.showDeleteAction ||
65
65
  preferences.showEditAction ||
66
66
  preferences.showZoomAction;
67
- return (_jsxs("table", { css: tableStyle, children: [_jsx("thead", { children: _jsxs("tr", { children: [preferences.showSerialNumber && _jsx("th", { children: "#" }), preferences.from.show && (_jsxs("th", { id: "from", ...onSort, children: ["From", isSortedDesc('from').content] })), preferences.to.show && (_jsxs("th", { id: "to", ...onSort, children: ["To ", isSortedDesc('to').content] })), preferences.deltaPPM.show && (_jsxs("th", { id: "from", ...onSort, children: ["\u03B4 (ppm) ", isSortedDesc('from').content] })), preferences.deltaHz.show && _jsx("th", { children: "\u03B4 (Hz) " }), preferences.relative.show && (_jsxs("th", { id: "integration", ...onSort, children: ["Rel. ", element, " ", isSortedDesc('integration').content] })), preferences.absolute.show && _jsx("th", { children: "Absolute" }), preferences.showMultiplicity && _jsx("th", { children: "Mult." }), preferences.coupling.show && _jsx("th", { children: "J (Hz)" }), preferences.showAssignment && (_jsxs(_Fragment, { children: [_jsx("th", { title: "Assign multiplets", children: _jsx(FaLink, { style: { fontSize: 10, margin: 'auto' } }) }), _jsx("th", { title: "Assign ranges", style: { minWidth: '50px' }, children: "\u03A3" })] })), preferences.showKind && _jsx("th", { children: "Kind" }), showActions && _jsx("th", { children: '' })] }) }), _jsx("tbody", { children: data?.map((range) => {
67
+ return (_jsxs("table", { css: tableStyle, children: [_jsx("thead", { children: _jsxs("tr", { children: [preferences.showSerialNumber && _jsx("th", { children: "#" }), preferences.showAssignmentLabel && (_jsx("th", { title: "Assignment", children: "Assignment" })), preferences.from.show && (_jsxs("th", { id: "from", ...onSort, children: ["From", isSortedDesc('from').content] })), preferences.to.show && (_jsxs("th", { id: "to", ...onSort, children: ["To ", isSortedDesc('to').content] })), preferences.deltaPPM.show && (_jsxs("th", { id: "from", ...onSort, children: ["\u03B4 (ppm) ", isSortedDesc('from').content] })), preferences.deltaHz.show && _jsx("th", { children: "\u03B4 (Hz) " }), preferences.relative.show && (_jsxs("th", { id: "integration", ...onSort, children: ["Rel. ", element, " ", isSortedDesc('integration').content] })), preferences.absolute.show && _jsx("th", { children: "Absolute" }), preferences.showMultiplicity && _jsx("th", { children: "Mult." }), preferences.coupling.show && _jsx("th", { children: "J (Hz)" }), preferences.showAssignment && (_jsxs(_Fragment, { children: [_jsx("th", { title: "Assign multiplets", children: _jsx(FaLink, { style: { fontSize: 10, margin: 'auto' } }) }), _jsx("th", { title: "Assign ranges", style: { minWidth: '50px' }, children: "\u03A3" })] })), preferences.showKind && _jsx("th", { children: "Kind" }), showActions && _jsx("th", { children: '' })] }) }), _jsx("tbody", { children: data?.map((range) => {
68
68
  return (_jsx(RangesTableRow, { rowData: range, onUnlink: onUnlink, preferences: preferences, info: info, contextMenu: contextMenu, onContextMenuSelect: onContextMenuSelect }, range.rowKey));
69
69
  }) })] }));
70
70
  }
@@ -10,6 +10,7 @@ import { HighlightEventSource, useHighlight, useHighlightData, } from '../../hig
10
10
  import AbsoluteColumn from './TableColumns/AbsoluteColumn';
11
11
  import ActionsColumn from './TableColumns/ActionsColumn';
12
12
  import CouplingColumn from './TableColumns/CouplingColumn';
13
+ import { RangeAssignmentColumn } from './TableColumns/RangeAssignmentColumn';
13
14
  import RangeAssignmentsColumn from './TableColumns/RangeAssignmentsColumn';
14
15
  import RangeColumn from './TableColumns/RangeColumn';
15
16
  import RelativeColumn from './TableColumns/RelativeColumn';
@@ -103,7 +104,7 @@ function RangesTableRow({ rowData, onUnlink, onContextMenuSelect, contextMenu =
103
104
  ? ConstantlyHighlightedRowStyle
104
105
  : null;
105
106
  }, [assignmentRange.isActive, highlightRange.isActive, rowData]);
106
- return (_jsxs(ContextMenu, { options: contextMenu, onSelect: (selected) => onContextMenuSelect?.(selected, rowData), as: "tr", css: trCss, children: [preferences.showSerialNumber && (_jsx("td", { ...rowSpanTags, ...onHoverRange, children: rowData.tableMetaInfo.rowIndex + 1 })), preferences.from.show && (_jsx(RangeColumn, { value: rowData.from, rowSpanTags: rowSpanTags, onHover: onHoverRange, format: preferences.from.format })), preferences.to.show && (_jsx(RangeColumn, { value: rowData.to, rowSpanTags: rowSpanTags, onHover: onHoverRange, format: preferences.to.format })), preferences.deltaPPM.show && (_jsx(SignalDeltaColumn, { row: rowData, rowSpanTags: rowSpanTags, onHover: onHoverSignal, format: preferences.deltaPPM.format })), preferences.deltaHz.show && (_jsx(SignalDeltaHzColumn, { row: rowData, rowSpanTags: rowSpanTags, onHover: onHoverSignal, format: preferences.deltaHz.format, info: info })), preferences.relative.show && (_jsx(RelativeColumn, { row: rowData, rowSpanTags: rowSpanTags, onHover: onHoverRange, format: preferences.relative.format })), preferences.absolute.show && (_jsx(AbsoluteColumn, { row: rowData, rowSpanTags: rowSpanTags, onHover: onHoverRange, format: preferences.absolute.format })), preferences.showMultiplicity && (_jsx("td", { ...onHoverSignal, children: !rowData?.tableMetaInfo?.signal
107
+ return (_jsxs(ContextMenu, { options: contextMenu, onSelect: (selected) => onContextMenuSelect?.(selected, rowData), as: "tr", css: trCss, children: [preferences.showSerialNumber && (_jsx("td", { ...rowSpanTags, ...onHoverRange, children: rowData.tableMetaInfo.rowIndex + 1 })), preferences.showAssignmentLabel && (_jsx(RangeAssignmentColumn, { row: rowData, onHover: onHoverRange, rowSpanTags: rowSpanTags })), preferences.from.show && (_jsx(RangeColumn, { value: rowData.from, rowSpanTags: rowSpanTags, onHover: onHoverRange, format: preferences.from.format })), preferences.to.show && (_jsx(RangeColumn, { value: rowData.to, rowSpanTags: rowSpanTags, onHover: onHoverRange, format: preferences.to.format })), preferences.deltaPPM.show && (_jsx(SignalDeltaColumn, { row: rowData, rowSpanTags: rowSpanTags, onHover: onHoverSignal, format: preferences.deltaPPM.format })), preferences.deltaHz.show && (_jsx(SignalDeltaHzColumn, { row: rowData, rowSpanTags: rowSpanTags, onHover: onHoverSignal, format: preferences.deltaHz.format, info: info })), preferences.relative.show && (_jsx(RelativeColumn, { row: rowData, rowSpanTags: rowSpanTags, onHover: onHoverRange, format: preferences.relative.format })), preferences.absolute.show && (_jsx(AbsoluteColumn, { row: rowData, rowSpanTags: rowSpanTags, onHover: onHoverRange, format: preferences.absolute.format })), preferences.showMultiplicity && (_jsx("td", { ...onHoverSignal, children: !rowData?.tableMetaInfo?.signal
107
108
  ? 'm'
108
109
  : lodashGet(rowData, 'tableMetaInfo.signal.multiplicity', '') })), preferences.coupling.show && (_jsx(CouplingColumn, { row: rowData, onHover: onHoverSignal, format: preferences.coupling.format })), preferences.showAssignment && (_jsxs(_Fragment, { children: [_jsx(SignalAssignmentsColumn, { row: rowData, assignment: assignmentSignal, highlight: highlightSignal, onHover: onHoverSignal, onLink: linkHandler, onUnlink: unlinkHandler }), _jsx(RangeAssignmentsColumn, { row: rowData, assignment: assignmentRange, highlight: highlightRangeAssignmentsColumn, onHover: onHoverRangeAssignmentsColumn, onLink: linkHandler, onUnlink: unlinkHandler, rowSpanTags: rowSpanTags, highlightData: highlightData })] })), _jsx(ActionsColumn, { row: rowData, onHoverSignal: onHoverSignal, onHoverRange: onHoverRange, rowSpanTags: rowSpanTags, showKind: preferences.showKind, showDeleteAction: preferences.showDeleteAction, showEditAction: preferences.showEditAction, showZoomAction: preferences.showZoomAction })] }));
109
110
  }
@@ -0,0 +1,7 @@
1
+ import { OnHoverEvent, RowSpanTags } from '../RangesTableRow';
2
+ import { RangeData } from '../hooks/useMapRanges';
3
+ type RangeAssignmentColumnProps = OnHoverEvent & RowSpanTags & {
4
+ row: RangeData;
5
+ };
6
+ export declare function RangeAssignmentColumn({ row, onHover, rowSpanTags, }: RangeAssignmentColumnProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useDispatch } from '../../../context/DispatchContext';
3
+ import EditableColumn from '../../../elements/EditableColumn';
4
+ export function RangeAssignmentColumn({ row, onHover, rowSpanTags, }) {
5
+ const dispatch = useDispatch();
6
+ function saveHandler(event) {
7
+ dispatch({
8
+ type: 'CHANGE_RANGE_ASSIGNMENT_LABEL',
9
+ payload: {
10
+ value: event.target.value,
11
+ rangeID: row.id,
12
+ },
13
+ });
14
+ }
15
+ return (_jsx("td", { ...rowSpanTags, ...onHover, children: _jsx(EditableColumn, { value: row?.assignment || '', onSave: saveHandler, style: { padding: '0.1rem 0.4rem' } }) }));
16
+ }
@@ -3,8 +3,10 @@ import { SvgNmrSameTop, SvgNmrResetScale } from 'cheminfo-font';
3
3
  import { memo, useCallback } from 'react';
4
4
  import { FaCreativeCommonsSamplingPlus, FaEye, FaEyeSlash, } from 'react-icons/fa';
5
5
  import { IoColorPaletteOutline } from 'react-icons/io5';
6
+ import { MdFormatColorFill } from 'react-icons/md';
6
7
  import { useChartData } from '../../context/ChartContext';
7
8
  import { useDispatch } from '../../context/DispatchContext';
9
+ import { usePreferences } from '../../context/PreferencesContext';
8
10
  import { useToaster } from '../../context/ToasterContext';
9
11
  import { useModal } from '../../elements/popup/Modal';
10
12
  import { useActiveSpectra } from '../../hooks/useActiveSpectra';
@@ -28,6 +30,7 @@ function SpectraPanelHeaderInner({ data, activeSpectrum, activeSpectra, activeTa
28
30
  const modal = useModal();
29
31
  const toaster = useToaster();
30
32
  const dispatch = useDispatch();
33
+ const { current: { spectraColors }, } = usePreferences();
31
34
  const handleDelete = useCallback(() => {
32
35
  modal.showConfirmDialog({
33
36
  message: (_jsxs("span", { children: ["You are about to delete", _jsxs("span", { style: { color: 'black' }, children: [" ", activeSpectra?.length, " "] }), "spectra, Are you sure?"] })),
@@ -72,7 +75,13 @@ function SpectraPanelHeaderInner({ data, activeSpectrum, activeSpectra, activeTa
72
75
  function resetScaleHandler() {
73
76
  dispatch({ type: 'RESET_SPECTRA_SCALE' });
74
77
  }
75
- function reColorSpectraHandler() {
78
+ function defaultReColorSpectraHandler() {
79
+ dispatch({
80
+ type: 'RECOLOR_SPECTRA_COLOR',
81
+ payload: { customColors: spectraColors },
82
+ });
83
+ }
84
+ function distinctReColorSpectraHandler() {
76
85
  dispatch({
77
86
  type: 'RECOLOR_SPECTRA_COLOR',
78
87
  payload: {},
@@ -84,31 +93,31 @@ function SpectraPanelHeaderInner({ data, activeSpectrum, activeSpectra, activeTa
84
93
  {
85
94
  disabled: !hasActiveSpectra,
86
95
  icon: _jsx(FaEyeSlash, {}),
87
- title: 'Hide selected spectra',
96
+ tooltip: 'Hide selected spectra',
88
97
  onClick: hideAllSpectraHandler,
89
98
  },
90
99
  {
91
100
  disabled: !hasActiveSpectra,
92
101
  icon: _jsx(FaEye, {}),
93
- title: 'Show selected spectra',
102
+ tooltip: 'Show selected spectra',
94
103
  onClick: showAllSpectraHandler,
95
104
  },
96
105
  ];
97
106
  if (displayerMode === '2D' && activeSpectrum?.info.isFt) {
98
107
  leftButtons.push({
99
108
  icon: _jsx(FaCreativeCommonsSamplingPlus, {}),
100
- title: 'Add missing projection',
109
+ tooltip: 'Add missing projection',
101
110
  onClick: addMissingProjectionHandler,
102
111
  });
103
112
  }
104
113
  if (displayerMode === '1D' && spectraLengthPerTab > 1) {
105
114
  leftButtons.push({
106
115
  icon: _jsx(SvgNmrResetScale, {}),
107
- title: 'Reset scale',
116
+ tooltip: 'Reset scale',
108
117
  onClick: resetScaleHandler,
109
118
  }, {
110
119
  icon: _jsx(SvgNmrSameTop, {}),
111
- title: 'Same top',
120
+ tooltip: 'Same top',
112
121
  onClick: setSameTopHandler,
113
122
  });
114
123
  }
@@ -118,8 +127,13 @@ function SpectraPanelHeaderInner({ data, activeSpectrum, activeSpectra, activeTa
118
127
  },
119
128
  {
120
129
  icon: _jsx(IoColorPaletteOutline, {}),
121
- title: 'Recolor spectra',
122
- onClick: reColorSpectraHandler,
130
+ tooltip: 'Default spectra recoloring',
131
+ onClick: defaultReColorSpectraHandler,
132
+ },
133
+ {
134
+ icon: _jsx(MdFormatColorFill, {}),
135
+ tooltip: 'Distinct spectra recoloring',
136
+ onClick: distinctReColorSpectraHandler,
123
137
  },
124
138
  ]);
125
139
  return (_jsx(DefaultPanelHeader, { onDelete: handleDelete, total: data?.length, counter: spectraLengthPerTab, deleteToolTip: "Delete selected spectra", disableDelete: !hasActiveSpectra, onSettingClick: onSettingClick, leftButtons: leftButtons }));
@@ -103,5 +103,5 @@ export default function EditLinkModal({ correlationDim1, correlationDim2, link,
103
103
  handleOnEdit,
104
104
  link,
105
105
  ]);
106
- return (_jsxs("div", { css: modalContainer, children: [_jsxs("div", { className: "header handle", children: [_jsx(CloseButton, { title: "Close", onClick: onClose }), _jsx("p", { className: "header-info", children: `${link.experimentType.toUpperCase()} signal at ${getLinkLabel()}` })] }), tabsContainer] }));
106
+ return (_jsxs("div", { css: modalContainer, children: [_jsxs("div", { className: "header handle", children: [_jsx(CloseButton, { tooltip: "Close", onClick: onClose }), _jsx("p", { className: "header-info", children: `${link.experimentType.toUpperCase()} signal at ${getLinkLabel()}` })] }), tabsContainer] }));
107
107
  }
@@ -1,8 +1,8 @@
1
- interface SetMolecularFormulaModalProps {
1
+ interface InnerMolecularFormulaModalProps {
2
2
  onClose: () => void;
3
- onSave?: (element: any) => void;
4
- molecules: any;
5
- previousMF: any;
6
3
  }
7
- export default function SetMolecularFormulaModal({ onClose, onSave, molecules, previousMF, }: SetMolecularFormulaModalProps): import("@emotion/react/jsx-runtime").JSX.Element;
4
+ interface MolecularFormulaModalProps extends InnerMolecularFormulaModalProps {
5
+ isOpen: boolean;
6
+ }
7
+ export declare function SetMolecularFormulaModal(props: MolecularFormulaModalProps): import("react/jsx-runtime").JSX.Element | undefined;
8
8
  export {};
@@ -1,94 +1,84 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
- /** @jsxImportSource @emotion/react */
3
- import { css } from '@emotion/react';
4
- import { useCallback, useEffect, useState } from 'react';
5
- import { CloseButton } from '../../elements/CloseButton';
6
- import MolecularFormulaInput from '../../elements/MolecularFormulaInput';
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Dialog, DialogBody, Tab, Tabs } from '@blueprintjs/core';
3
+ import { Formik } from 'formik';
4
+ import { useState } from 'react';
5
+ import * as Yup from 'yup';
6
+ import getAtomsFromMF from '../../../data/utilities/getAtomsFromMF';
7
+ import { useChartData } from '../../context/ChartContext';
8
+ import { useDispatch } from '../../context/DispatchContext';
9
+ import Button from '../../elements/Button';
7
10
  import MoleculeSelection from '../../elements/MoleculeSelection';
8
- const modalContainer = css `
9
- overflow: auto;
10
- width: 400px;
11
- height: 550px;
12
- padding: 5px;
13
-
14
- button {
15
- flex: 2;
16
- padding: 5px;
17
- border: 1px solid gray;
18
- border-radius: 5px;
19
- height: 30px;
20
- margin: 0 auto;
21
- margin-top: 15px;
22
- display: block;
23
- width: 20%;
24
- color: white;
25
- background-color: gray;
26
- }
27
-
28
- button:focus {
29
- outline: none;
30
- }
31
-
32
- .header {
33
- height: 24px;
34
- border-bottom: 1px solid #f0f0f0;
35
- display: flex;
36
- align-items: center;
37
-
38
- button {
39
- height: 36px;
40
- margin: 2px;
41
- background-color: transparent;
42
- border: none;
43
-
44
- svg {
45
- height: 16px;
46
- }
11
+ import FormikError from '../../elements/formik/FormikError';
12
+ import FormikInput from '../../elements/formik/FormikInput';
13
+ function isValidMf(value) {
14
+ try {
15
+ getAtomsFromMF(value);
16
+ return true;
47
17
  }
48
- }
49
-
50
- .info {
51
- margin-top: 0;
52
- margin-bottom: 10px;
53
- padding: 0 10px;
54
- width: 100%;
55
- text-align: center;
56
- }
57
-
58
- .optional {
59
- margin-top: 20px;
60
- margin-bottom: 5px;
61
- padding: 0 10px;
62
- text-align: center;
63
- font-size: 18px;
64
- font-weight: bold;
65
- }
66
-
67
- .optional2 {
68
- margin-top: 5px;
69
- margin-bottom: 25px;
70
- padding: 0 10px;
71
- width: 100%;
72
- text-align: center;
73
- }
74
- `;
75
- export default function SetMolecularFormulaModal({ onClose, onSave, molecules, previousMF, }) {
76
- const [currentIndex, setCurrentIndex] = useState(0);
77
- useEffect(() => {
78
- if (molecules && molecules.length > 0) {
79
- setCurrentIndex(0);
80
- }
81
- }, [molecules]);
82
- const onSaveHandlerMolecularFormulaInput = useCallback((mf) => {
83
- onSave?.(mf);
84
- onClose?.();
85
- }, [onClose, onSave]);
86
- const onSaveHandlerMoleculeSelection = useCallback(() => {
87
- onSave?.(molecules[currentIndex].mf);
18
+ catch {
19
+ return false;
20
+ }
21
+ }
22
+ const validationSchema = Yup.object({
23
+ mf: Yup.string()
24
+ .required()
25
+ .test('valid-mf', 'Enter a valid molecular formula', (value) => isValidMf(value)),
26
+ });
27
+ const styles = {
28
+ input: {
29
+ padding: '0.5rem',
30
+ },
31
+ container: {
32
+ padding: '0.5rem',
33
+ },
34
+ error: {
35
+ textAlign: 'center',
36
+ color: 'red',
37
+ fontSize: '0.9em',
38
+ },
39
+ title: {
40
+ textAlign: 'center',
41
+ },
42
+ };
43
+ export function SetMolecularFormulaModal(props) {
44
+ const { isOpen, ...otherProps } = props;
45
+ if (!isOpen) {
46
+ return;
47
+ }
48
+ return _jsx(InnerSetMolecularFormulaModal, { ...otherProps });
49
+ }
50
+ function InnerSetMolecularFormulaModal({ onClose, }) {
51
+ const dispatch = useDispatch();
52
+ function saveHandler(mf) {
53
+ dispatch({
54
+ type: 'SET_CORRELATIONS_MF',
55
+ payload: {
56
+ mf,
57
+ },
58
+ });
88
59
  onClose?.();
89
- }, [currentIndex, molecules, onClose, onSave]);
90
- const onChangeHandlerMoleculeSelection = useCallback((index) => {
60
+ }
61
+ return (_jsx(Dialog, { isOpen: true, title: "Molecular formula", style: { width: 400 }, onClose: onClose, children: _jsx(DialogBody, { children: _jsxs(Tabs, { fill: true, children: [_jsx(Tab, { id: "manual", title: "Manual", panel: _jsx(ManualFormula, { onSave: saveHandler }) }), _jsx(Tab, { id: "auto", title: "Auto", panel: _jsx(AutoFormula, { onSave: saveHandler }) })] }) }) }));
62
+ }
63
+ function ManualFormula(props) {
64
+ const { correlations } = useChartData();
65
+ function saveHandler(data) {
66
+ props?.onSave(data.mf);
67
+ }
68
+ return (_jsxs("div", { style: styles.container, children: [_jsx("p", { children: "Please type in a molecular formula!" }), _jsx(Formik, { onSubmit: saveHandler, initialValues: { mf: correlations?.options?.mf }, validationSchema: validationSchema, children: ({ isValid, handleSubmit }) => (_jsxs(_Fragment, { children: [_jsx(FormikError, { name: "mf", children: _jsx(FormikInput, { name: "mf", placeholder: "Enter a molecular formula", style: { input: styles.input }, checkErrorAfterInputTouched: false }) }), _jsx(Button.Done, { onClick: () => handleSubmit(), disabled: !isValid, style: { marginTop: '10px' }, children: "Set molecular formula" })] })) })] }));
69
+ }
70
+ function AutoFormula(props) {
71
+ const { molecules } = useChartData();
72
+ const [currentIndex, setCurrentIndex] = useState(0);
73
+ function onChangeHandlerMoleculeSelection(index) {
91
74
  setCurrentIndex(index);
92
- }, []);
93
- return (_jsxs("div", { css: modalContainer, children: [_jsx("div", { className: "header handle", children: _jsx(CloseButton, { title: "Close", onClick: onClose }) }), _jsx("div", { children: _jsx("p", { className: "info", children: "Please type in a molecular formula!" }) }), _jsx(MolecularFormulaInput, { onSave: onSaveHandlerMolecularFormulaInput, previousMF: previousMF }), _jsxs("div", { children: [_jsx("p", { className: "optional", children: "OR" }), _jsx("p", { className: "optional2", children: "Select a molecule as reference!" })] }), _jsx(MoleculeSelection, { molecules: molecules, onChange: onChangeHandlerMoleculeSelection }), _jsx("button", { type: "button", onClick: onSaveHandlerMoleculeSelection, children: "Set" })] }));
75
+ }
76
+ function saveHandler() {
77
+ const mf = molecules?.[currentIndex]?.mf;
78
+ props?.onSave(mf);
79
+ }
80
+ if (!molecules || molecules?.length === 0) {
81
+ return (_jsx("p", { style: styles.error, children: "You have to Select a spectrum and Add a molecule from the Structure panel to select as a reference!" }));
82
+ }
83
+ return (_jsxs("div", { style: styles.container, children: [_jsx("p", { style: styles.title, children: "Select a molecule as reference!" }), _jsx(MoleculeSelection, { molecules: molecules, onChange: onChangeHandlerMoleculeSelection }), _jsx(Button.Done, { onClick: saveHandler, disabled: !molecules?.[currentIndex], style: { marginTop: '10px' }, children: "Set molecular formula" })] }));
94
84
  }
@@ -1,7 +1,8 @@
1
- interface SetShiftToleranceModalProps {
1
+ interface SetShiftToleranceModalProps extends InnerSetShiftToleranceModalProps {
2
+ isOpen: boolean;
3
+ }
4
+ interface InnerSetShiftToleranceModalProps {
2
5
  onClose: () => void;
3
- onSave?: (element: any) => void;
4
- previousTolerance: any;
5
6
  }
6
- export default function SetShiftToleranceModal({ onClose, onSave, previousTolerance, }: SetShiftToleranceModalProps): import("@emotion/react/jsx-runtime").JSX.Element;
7
+ export declare function SetShiftToleranceModal(props: SetShiftToleranceModalProps): import("@emotion/react/jsx-runtime").JSX.Element | undefined;
7
8
  export {};