nmrium 2.3.0 → 2.4.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 (176) hide show
  1. package/lib/component/1d/peaks/PeakEditionManager.d.ts +1 -1
  2. package/lib/component/1d-2d/tools/BrushXY.js +6 -6
  3. package/lib/component/1d-2d/tools/BrushXY.js.map +1 -1
  4. package/lib/component/2d/1d-tracer/Left1DChart.d.ts.map +1 -1
  5. package/lib/component/2d/1d-tracer/Left1DChart.js +6 -2
  6. package/lib/component/2d/1d-tracer/Left1DChart.js.map +1 -1
  7. package/lib/component/2d/1d-tracer/Ranges1D.d.ts +9 -0
  8. package/lib/component/2d/1d-tracer/Ranges1D.d.ts.map +1 -0
  9. package/lib/component/2d/1d-tracer/Ranges1D.js +76 -0
  10. package/lib/component/2d/1d-tracer/Ranges1D.js.map +1 -0
  11. package/lib/component/2d/1d-tracer/Signals1D.d.ts +11 -0
  12. package/lib/component/2d/1d-tracer/Signals1D.d.ts.map +1 -0
  13. package/lib/component/2d/1d-tracer/Signals1D.js +90 -0
  14. package/lib/component/2d/1d-tracer/Signals1D.js.map +1 -0
  15. package/lib/component/2d/1d-tracer/Top1DChart.d.ts.map +1 -1
  16. package/lib/component/2d/1d-tracer/Top1DChart.js +6 -2
  17. package/lib/component/2d/1d-tracer/Top1DChart.js.map +1 -1
  18. package/lib/component/2d/ft/FTContainer.d.ts.map +1 -1
  19. package/lib/component/2d/ft/FTContainer.js.map +1 -1
  20. package/lib/component/AnchorSVG.d.ts +37 -0
  21. package/lib/component/AnchorSVG.d.ts.map +1 -0
  22. package/lib/component/AnchorSVG.js +137 -0
  23. package/lib/component/AnchorSVG.js.map +1 -0
  24. package/lib/component/EventsTrackers/BrushTracker.d.ts.map +1 -1
  25. package/lib/component/EventsTrackers/BrushTracker.js +4 -0
  26. package/lib/component/EventsTrackers/BrushTracker.js.map +1 -1
  27. package/lib/component/context/KeyModifierContext.d.ts +1 -0
  28. package/lib/component/context/KeyModifierContext.d.ts.map +1 -1
  29. package/lib/component/context/KeyModifierContext.js +4 -0
  30. package/lib/component/context/KeyModifierContext.js.map +1 -1
  31. package/lib/component/elements/DraggableDialog.d.ts.map +1 -1
  32. package/lib/component/elements/DraggableDialog.js +1 -2
  33. package/lib/component/elements/DraggableDialog.js.map +1 -1
  34. package/lib/component/elements/Sections.d.ts +3 -3
  35. package/lib/component/elements/Sections.d.ts.map +1 -1
  36. package/lib/component/elements/Sections.js +1 -1
  37. package/lib/component/elements/Sections.js.map +1 -1
  38. package/lib/component/elements/export/ExportOptionsModal.js +2 -5
  39. package/lib/component/elements/export/ExportOptionsModal.js.map +1 -1
  40. package/lib/component/header/Header.d.ts.map +1 -1
  41. package/lib/component/header/Header.js +2 -4
  42. package/lib/component/header/Header.js.map +1 -1
  43. package/lib/component/hooks/useSaveSettings.d.ts.map +1 -1
  44. package/lib/component/hooks/useSaveSettings.js +3 -6
  45. package/lib/component/hooks/useSaveSettings.js.map +1 -1
  46. package/lib/component/modal/PublicationStringModal.d.ts.map +1 -1
  47. package/lib/component/modal/PublicationStringModal.js +2 -6
  48. package/lib/component/modal/PublicationStringModal.js.map +1 -1
  49. package/lib/component/modal/SaveAsModal.js +3 -6
  50. package/lib/component/modal/SaveAsModal.js.map +1 -1
  51. package/lib/component/modal/aboutUs/AboutUsModal.d.ts.map +1 -1
  52. package/lib/component/modal/aboutUs/AboutUsModal.js +2 -4
  53. package/lib/component/modal/aboutUs/AboutUsModal.js.map +1 -1
  54. package/lib/component/modal/editRange/forms/components/NewSignalTab.d.ts.map +1 -1
  55. package/lib/component/modal/editRange/forms/components/NewSignalTab.js +38 -36
  56. package/lib/component/modal/editRange/forms/components/NewSignalTab.js.map +1 -1
  57. package/lib/component/modal/setting/tanstack_general_settings/errors/context.d.ts +24 -24
  58. package/lib/component/modal/setting/tanstack_general_settings/errors/renderer.d.ts +24 -24
  59. package/lib/component/modal/setting/tanstack_general_settings/general_settings.d.ts.map +1 -1
  60. package/lib/component/modal/setting/tanstack_general_settings/general_settings.js +9 -12
  61. package/lib/component/modal/setting/tanstack_general_settings/general_settings.js.map +1 -1
  62. package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_body.d.ts +24 -24
  63. package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_footer.d.ts +24 -24
  64. package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_header.d.ts +24 -24
  65. package/lib/component/modal/setting/tanstack_general_settings/hooks/use_safe_workspace.d.ts +4 -4
  66. package/lib/component/modal/setting/tanstack_general_settings/tabs/auto_processing_tab.d.ts +24 -24
  67. package/lib/component/modal/setting/tanstack_general_settings/tabs/axis_tab.d.ts +24 -24
  68. package/lib/component/modal/setting/tanstack_general_settings/tabs/database_tab.d.ts +24 -24
  69. package/lib/component/modal/setting/tanstack_general_settings/tabs/export_tab.d.ts +24 -24
  70. package/lib/component/modal/setting/tanstack_general_settings/tabs/external_api_tab.d.ts +24 -24
  71. package/lib/component/modal/setting/tanstack_general_settings/tabs/general_tab.d.ts +24 -24
  72. package/lib/component/modal/setting/tanstack_general_settings/tabs/import_filters_tab.d.ts +24 -24
  73. package/lib/component/modal/setting/tanstack_general_settings/tabs/nuclei_tab.d.ts +24 -24
  74. package/lib/component/modal/setting/tanstack_general_settings/tabs/panels_tab.d.ts +24 -24
  75. package/lib/component/modal/setting/tanstack_general_settings/tabs/spectra_colors_tab.d.ts +24 -24
  76. package/lib/component/modal/setting/tanstack_general_settings/tabs/spectra_label_tab.d.ts +24 -24
  77. package/lib/component/modal/setting/tanstack_general_settings/tabs/title_block_tab.d.ts +24 -24
  78. package/lib/component/modal/setting/tanstack_general_settings/tabs/tools_tab.d.ts +24 -24
  79. package/lib/component/panels/PeaksPanel/PeaksPanel.d.ts.map +1 -1
  80. package/lib/component/panels/PeaksPanel/PeaksPanel.js +1 -9
  81. package/lib/component/panels/PeaksPanel/PeaksPanel.js.map +1 -1
  82. package/lib/component/panels/PeaksPanel/PeaksPreferences.js +1 -1
  83. package/lib/component/panels/PeaksPanel/PeaksPreferences.js.map +1 -1
  84. package/lib/component/panels/PeaksPanel/PeaksTable.d.ts.map +1 -1
  85. package/lib/component/panels/PeaksPanel/PeaksTable.js +9 -9
  86. package/lib/component/panels/PeaksPanel/PeaksTable.js.map +1 -1
  87. package/lib/component/panels/SummaryPanel/SummaryPanel.d.ts.map +1 -1
  88. package/lib/component/panels/SummaryPanel/SummaryPanel.js +7 -0
  89. package/lib/component/panels/SummaryPanel/SummaryPanel.js.map +1 -1
  90. package/lib/component/panels/filtersPanel/FilterPanel.d.ts.map +1 -1
  91. package/lib/component/panels/filtersPanel/FilterPanel.js +5 -2
  92. package/lib/component/panels/filtersPanel/FilterPanel.js.map +1 -1
  93. package/lib/component/panels/filtersPanel/Filters/base/BaseApodizationOptions.js +1 -1
  94. package/lib/component/panels/filtersPanel/Filters/base/BaseApodizationOptions.js.map +1 -1
  95. package/lib/component/panels/filtersPanel/processings_sections_panel.d.ts +2 -0
  96. package/lib/component/panels/filtersPanel/processings_sections_panel.d.ts.map +1 -0
  97. package/lib/component/panels/filtersPanel/processings_sections_panel.js +144 -0
  98. package/lib/component/panels/filtersPanel/processings_sections_panel.js.map +1 -0
  99. package/lib/component/reducer/Reducer.d.ts.map +1 -1
  100. package/lib/component/reducer/Reducer.js +2 -0
  101. package/lib/component/reducer/Reducer.js.map +1 -1
  102. package/lib/component/reducer/actions/CorrelationsActions.js +1 -1
  103. package/lib/component/reducer/actions/CorrelationsActions.js.map +1 -1
  104. package/lib/component/reducer/actions/MoleculeActions.d.ts +9 -0
  105. package/lib/component/reducer/actions/MoleculeActions.d.ts.map +1 -1
  106. package/lib/component/reducer/actions/RangesActions.d.ts +11 -2
  107. package/lib/component/reducer/actions/RangesActions.d.ts.map +1 -1
  108. package/lib/component/reducer/actions/RangesActions.js +23 -5
  109. package/lib/component/reducer/actions/RangesActions.js.map +1 -1
  110. package/lib/component/reducer/actions/ToolsActions.d.ts.map +1 -1
  111. package/lib/component/reducer/actions/ToolsActions.js +5 -17
  112. package/lib/component/reducer/actions/ToolsActions.js.map +1 -1
  113. package/lib/component/reducer/helper/getTraceSpectrumID.d.ts +5 -0
  114. package/lib/component/reducer/helper/getTraceSpectrumID.d.ts.map +1 -0
  115. package/lib/component/reducer/helper/getTraceSpectrumID.js +14 -0
  116. package/lib/component/reducer/helper/getTraceSpectrumID.js.map +1 -0
  117. package/lib/component/toolbar/nmr_toolbar.d.ts.map +1 -1
  118. package/lib/component/toolbar/nmr_toolbar.js +3 -1
  119. package/lib/component/toolbar/nmr_toolbar.js.map +1 -1
  120. package/lib/component/utility/CoreSlot.d.ts +27 -0
  121. package/lib/component/utility/CoreSlot.d.ts.map +1 -0
  122. package/lib/component/utility/CoreSlot.js +56 -0
  123. package/lib/component/utility/CoreSlot.js.map +1 -0
  124. package/lib/data/data1d/Spectrum1D/peaks/autoPeakPicking.d.ts.map +1 -1
  125. package/lib/data/data1d/Spectrum1D/peaks/autoPeakPicking.js +1 -0
  126. package/lib/data/data1d/Spectrum1D/peaks/autoPeakPicking.js.map +1 -1
  127. package/lib/data/data1d/Spectrum1D/peaks/optimizePeaks.d.ts.map +1 -1
  128. package/lib/data/data1d/Spectrum1D/peaks/optimizePeaks.js +35 -30
  129. package/lib/data/data1d/Spectrum1D/peaks/optimizePeaks.js.map +1 -1
  130. package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.d.ts.map +1 -1
  131. package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.js +1 -0
  132. package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.js.map +1 -1
  133. package/lib/versionInfo.js +1 -1
  134. package/package.json +25 -24
  135. package/src/component/1d-2d/tools/BrushXY.tsx +8 -8
  136. package/src/component/2d/1d-tracer/Left1DChart.tsx +24 -1
  137. package/src/component/2d/1d-tracer/Ranges1D.tsx +134 -0
  138. package/src/component/2d/1d-tracer/Signals1D.tsx +145 -0
  139. package/src/component/2d/1d-tracer/Top1DChart.tsx +29 -2
  140. package/src/component/2d/ft/FTContainer.tsx +1 -0
  141. package/src/component/AnchorSVG.tsx +370 -0
  142. package/src/component/EventsTrackers/BrushTracker.tsx +6 -0
  143. package/src/component/context/KeyModifierContext.tsx +5 -0
  144. package/src/component/elements/DraggableDialog.tsx +1 -2
  145. package/src/component/elements/Sections.tsx +4 -4
  146. package/src/component/elements/export/ExportOptionsModal.tsx +22 -31
  147. package/src/component/header/Header.tsx +2 -4
  148. package/src/component/hooks/useSaveSettings.tsx +4 -15
  149. package/src/component/modal/PublicationStringModal.tsx +5 -11
  150. package/src/component/modal/SaveAsModal.tsx +41 -50
  151. package/src/component/modal/aboutUs/AboutUsModal.tsx +5 -4
  152. package/src/component/modal/editRange/forms/components/NewSignalTab.tsx +57 -57
  153. package/src/component/modal/setting/tanstack_general_settings/general_settings.tsx +23 -29
  154. package/src/component/panels/PeaksPanel/PeaksPanel.tsx +1 -8
  155. package/src/component/panels/PeaksPanel/PeaksPreferences.tsx +1 -1
  156. package/src/component/panels/PeaksPanel/PeaksTable.tsx +11 -9
  157. package/src/component/panels/SummaryPanel/SummaryPanel.tsx +13 -11
  158. package/src/component/panels/filtersPanel/FilterPanel.tsx +10 -0
  159. package/src/component/panels/filtersPanel/Filters/base/BaseApodizationOptions.tsx +1 -0
  160. package/src/component/panels/filtersPanel/processings_sections_panel.tsx +324 -0
  161. package/src/component/reducer/Reducer.ts +2 -0
  162. package/src/component/reducer/actions/CorrelationsActions.ts +1 -1
  163. package/src/component/reducer/actions/RangesActions.ts +39 -5
  164. package/src/component/reducer/actions/ToolsActions.ts +5 -21
  165. package/src/component/reducer/helper/getTraceSpectrumID.tsx +25 -0
  166. package/src/component/toolbar/nmr_toolbar.tsx +3 -2
  167. package/src/component/utility/CoreSlot.tsx +126 -0
  168. package/src/data/data1d/Spectrum1D/peaks/autoPeakPicking.ts +1 -0
  169. package/src/data/data1d/Spectrum1D/peaks/optimizePeaks.ts +35 -30
  170. package/src/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.ts +1 -0
  171. package/src/versionInfo.ts +1 -1
  172. package/lib/component/utility/renderCoreSlot.d.ts +0 -11
  173. package/lib/component/utility/renderCoreSlot.d.ts.map +0 -1
  174. package/lib/component/utility/renderCoreSlot.js +0 -13
  175. package/lib/component/utility/renderCoreSlot.js.map +0 -1
  176. package/src/component/utility/renderCoreSlot.tsx +0 -21
@@ -0,0 +1,134 @@
1
+ import styled from '@emotion/styled';
2
+ import type { Jcoupling, Range, Signal1D } from '@zakodium/nmr-types';
3
+
4
+ import { getOpacityBasedOnSignalKind } from '../../../data/utilities/RangeUtilities.ts';
5
+ import { useChartData } from '../../context/ChartContext.tsx';
6
+ import { useDispatch } from '../../context/DispatchContext.tsx';
7
+ import { useScale2DX, useScale2DY } from '../utilities/scale.js';
8
+
9
+ interface Range1DTraceProps {
10
+ position: number;
11
+ size: number;
12
+ orientation?: 'horizontal' | 'vertical';
13
+ opacity?: number;
14
+ onClick?: (e: React.MouseEvent<SVGGElement, MouseEvent>) => void;
15
+ }
16
+
17
+ interface ElementLayout {
18
+ groupTransform: string;
19
+ pathD: string;
20
+ }
21
+
22
+ const Path = styled.path`
23
+ fill: none;
24
+ stroke-width: 1px;
25
+ shape-rendering: crispedges;
26
+ stroke: black;
27
+
28
+ &:hover {
29
+ stroke: red;
30
+ }
31
+ `;
32
+ const length = 5;
33
+ const innerMargin = 10;
34
+
35
+ function Range1DTrace(props: Range1DTraceProps) {
36
+ const {
37
+ position,
38
+ size,
39
+ orientation = 'horizontal',
40
+ opacity = 1,
41
+ onClick,
42
+ } = props;
43
+ const { margin } = useChartData();
44
+
45
+ const layout: ElementLayout =
46
+ orientation === 'vertical'
47
+ ? {
48
+ groupTransform: `translate(${margin.left - innerMargin} ${position})`,
49
+ pathD: `M0 0 L${length} 0 L${length} ${size} L0 ${size}`,
50
+ }
51
+ : {
52
+ groupTransform: `translate(${position} ${margin.top - innerMargin})`,
53
+ pathD: `M0 0 L0 ${length} L${size} ${length} L${size} 0`,
54
+ };
55
+
56
+ return (
57
+ <g transform={layout.groupTransform} style={{ opacity }} onClick={onClick}>
58
+ <rect
59
+ x={orientation === 'vertical' ? -(margin.left - innerMargin) : 0}
60
+ y={orientation === 'vertical' ? 0 : -(margin.top - innerMargin)}
61
+ width={orientation === 'vertical' ? margin.left : size}
62
+ height={orientation === 'vertical' ? size : margin.top}
63
+ fill="transparent"
64
+ />
65
+ <Path d={layout.pathD} />
66
+ </g>
67
+ );
68
+ }
69
+
70
+ interface Ranges1DProps {
71
+ ranges: Range[];
72
+ orientation: 'horizontal' | 'vertical';
73
+ spectrumId: string;
74
+ }
75
+
76
+ export function Ranges1D(props: Ranges1DProps) {
77
+ const { ranges, orientation, spectrumId } = props;
78
+ const scaleX = useScale2DX();
79
+ const scaleY = useScale2DY();
80
+ const dispatch = useDispatch();
81
+ const scale = orientation === 'horizontal' ? scaleX : scaleY;
82
+
83
+ return ranges.map((range) => {
84
+ const opacity = getOpacityBasedOnSignalKind(range);
85
+
86
+ const { from, to, id } = range;
87
+ const fromInPixel = scale(from);
88
+ const toInPixel = scale(to);
89
+ const start = Math.min(fromInPixel, toInPixel);
90
+ const size = Math.abs(fromInPixel - toInPixel);
91
+
92
+ function handleAddSignal(e: React.MouseEvent<SVGGElement, MouseEvent>) {
93
+ const boundingRect = e.currentTarget.getBoundingClientRect();
94
+ const x = e.clientX - boundingRect.left + start;
95
+ const y = e.clientY - boundingRect.top + start;
96
+
97
+ const valueInPixel = orientation === 'horizontal' ? x : y;
98
+ const delta = scale.invert(valueInPixel);
99
+
100
+ const updatedRange = structuredClone(range);
101
+ const signal: Signal1D = {
102
+ id: crypto.randomUUID(),
103
+ delta,
104
+ js: [
105
+ {
106
+ multiplicity: 'm',
107
+ } as Jcoupling,
108
+ ],
109
+ kind: 'signal',
110
+ multiplicity: 'm',
111
+ };
112
+ updatedRange.signals.push(signal);
113
+
114
+ dispatch({
115
+ type: 'UPDATE_RANGE',
116
+ payload: {
117
+ range: updatedRange,
118
+ spectrumId,
119
+ },
120
+ });
121
+ }
122
+
123
+ return (
124
+ <Range1DTrace
125
+ orientation={orientation}
126
+ key={id}
127
+ position={start}
128
+ size={size}
129
+ onClick={handleAddSignal}
130
+ opacity={opacity}
131
+ />
132
+ );
133
+ });
134
+ }
@@ -0,0 +1,145 @@
1
+ import type { Range, Signal1D } from '@zakodium/nmr-types';
2
+ import type { RefObject } from 'react';
3
+ import { useMemo, useRef, useState } from 'react';
4
+
5
+ import { Anchor } from '../../AnchorSVG.tsx';
6
+ import { useChartData } from '../../context/ChartContext.tsx';
7
+ import { useDispatch } from '../../context/DispatchContext.tsx';
8
+ import { useScale2DX, useScale2DY } from '../utilities/scale.js';
9
+
10
+ interface Signals1DProps {
11
+ spectrumId: string;
12
+ ranges: Range[];
13
+ svgRef: RefObject<SVGSVGElement>;
14
+ orientation: 'horizontal' | 'vertical';
15
+ }
16
+
17
+ interface SignalWithRange extends Signal1D {
18
+ from: number;
19
+ to: number;
20
+ rangeID: string;
21
+ }
22
+
23
+ export function Signals1D(props: Signals1DProps) {
24
+ const { ranges, svgRef, orientation, spectrumId } = props;
25
+ const {
26
+ margin: { top, left },
27
+ } = useChartData();
28
+ const scaleX = useScale2DX();
29
+ const scaleY = useScale2DY();
30
+ const size = orientation === 'horizontal' ? top : left;
31
+ const scale = orientation === 'horizontal' ? scaleX : scaleY;
32
+ const draggingAnchorRef = useRef<{ index: number; delta: number } | null>(
33
+ null,
34
+ );
35
+ // Only used during active drag for local updates
36
+ const [draggingAnchor, setDraggingAnchor] = useState<{
37
+ index: number;
38
+ delta: number;
39
+ } | null>(null);
40
+ const dispatch = useDispatch();
41
+
42
+ function handleDragMove(
43
+ index: number,
44
+ newPosition: { x: number; y: number },
45
+ range: { from: number; to: number },
46
+ ) {
47
+ // console.log(newX)
48
+
49
+ const delta = orientation === 'horizontal' ? newPosition.x : newPosition.y;
50
+ const from = orientation === 'horizontal' ? range.from : range.to;
51
+ const to = orientation === 'horizontal' ? range.to : range.from;
52
+ const clampedX = Math.max(scale(to), Math.min(scale(from), delta));
53
+ const updated = { index, delta: scale.invert(clampedX) };
54
+ draggingAnchorRef.current = updated;
55
+ setDraggingAnchor(updated);
56
+ }
57
+ function handleDragEnd(signal: SignalWithRange) {
58
+ const finalDelta = draggingAnchorRef.current?.delta;
59
+
60
+ if (!finalDelta) return;
61
+
62
+ draggingAnchorRef.current = null;
63
+ setDraggingAnchor(null);
64
+ dispatch({
65
+ type: 'CHANGE_SIGNAL_DELTA',
66
+ payload: {
67
+ value: finalDelta,
68
+ rangeId: signal.rangeID,
69
+ signalId: signal.id,
70
+ spectrumId,
71
+ },
72
+ });
73
+ }
74
+
75
+ function handleDelete(signal: SignalWithRange) {
76
+ dispatch({
77
+ type: 'DELETE_1D_SIGNAL',
78
+ payload: {
79
+ rangeId: signal.rangeID,
80
+ signalId: signal.id,
81
+ spectrumId,
82
+ },
83
+ });
84
+ }
85
+
86
+ const signals = useMemo(() => {
87
+ const result: SignalWithRange[] = [];
88
+ let flatIndex = 0;
89
+
90
+ for (const range of ranges ?? []) {
91
+ for (const signal of range.signals ?? []) {
92
+ const isDragging = draggingAnchor?.index === flatIndex;
93
+
94
+ result.push({
95
+ ...signal,
96
+ delta: isDragging ? draggingAnchor.delta : signal.delta,
97
+ from: range.from,
98
+ to: range.to,
99
+ rangeID: range.id,
100
+ });
101
+
102
+ flatIndex++;
103
+ }
104
+ }
105
+
106
+ return result;
107
+ }, [ranges, draggingAnchor?.index, draggingAnchor?.delta]);
108
+ return (
109
+ <g>
110
+ {signals.map((signal, index) => {
111
+ const { rangeID, id, delta, from, to } = signal;
112
+ const x = orientation === 'horizontal' ? scale(delta) : size - 5;
113
+ const y = orientation === 'horizontal' ? size - 5 : scale(delta);
114
+
115
+ return (
116
+ <Anchor
117
+ key={`${id}-${rangeID}`}
118
+ position={{ x, y }}
119
+ svgRef={svgRef}
120
+ shape="circle"
121
+ onDragMove={(newPosition) =>
122
+ handleDragMove(index, newPosition, { from, to })
123
+ }
124
+ onDragEnd={() => handleDragEnd(signal)}
125
+ onDelete={() => handleDelete(signal)}
126
+ cursorOrientation={orientation}
127
+ anchorStyle={{
128
+ guideStyle: 'dashed',
129
+ size: 8,
130
+ hoverSize: 15,
131
+ dragSize: 15,
132
+ hoverStroke: 'red',
133
+ dragStroke: 'darkgreen',
134
+ guideColor: 'red',
135
+ guideDragColor: 'darkgreen',
136
+ fill: 'red',
137
+ stroke: 'transparent',
138
+ }}
139
+ svgHeight={100}
140
+ />
141
+ );
142
+ })}
143
+ </g>
144
+ );
145
+ }
@@ -1,11 +1,14 @@
1
1
  import type { Spectrum1D } from '@zakodium/nmrium-core';
2
- import { memo } from 'react';
2
+ import { memo, useRef } from 'react';
3
3
 
4
4
  import { useChartData } from '../../context/ChartContext.js';
5
5
  import useXYReduce from '../../hooks/useXYReduce.js';
6
6
  import { PathBuilder } from '../../utility/PathBuilder.js';
7
7
  import { use1DTraceYScale, useScale2DX } from '../utilities/scale.js';
8
8
 
9
+ import { Ranges1D } from './Ranges1D.tsx';
10
+ import { Signals1D } from './Signals1D.tsx';
11
+
9
12
  interface Top1DChartProps {
10
13
  verticalMargin?: number;
11
14
  data: Spectrum1D;
@@ -37,8 +40,10 @@ function usePath(spectrum: Spectrum1D, options: UsePathOptions) {
37
40
  function Top1DChart({ verticalMargin = 10, data: spectrum }: Top1DChartProps) {
38
41
  const { width, margin, displayerKey } = useChartData();
39
42
  const height = margin.top;
43
+ const svgRef = useRef<SVGSVGElement>(null);
40
44
 
41
45
  const path = usePath(spectrum, { height, verticalMargin });
46
+ const ranges = spectrum.ranges.values;
42
47
 
43
48
  if (!width || !height) {
44
49
  return null;
@@ -46,11 +51,20 @@ function Top1DChart({ verticalMargin = 10, data: spectrum }: Top1DChartProps) {
46
51
 
47
52
  const innerWidth = width - margin.left - margin.right;
48
53
  return (
49
- <svg viewBox={`0 0 ${width} ${height}`} width={width} height={height}>
54
+ <svg
55
+ ref={svgRef}
56
+ viewBox={`0 0 ${width} ${height}`}
57
+ width={width}
58
+ height={height}
59
+ style={{ overflow: 'visible' }}
60
+ >
50
61
  <defs>
51
62
  <clipPath id={`${displayerKey}clip-top`}>
52
63
  <rect width={innerWidth} height={height} x={margin.left} y="0" />
53
64
  </clipPath>
65
+ <clipPath id={`${displayerKey}clip-top-ranges`}>
66
+ <rect width={innerWidth} height={height + 20} x={margin.left} y="0" />
67
+ </clipPath>
54
68
  </defs>
55
69
  <g clipPath={`url(#${displayerKey}clip-top)`}>
56
70
  <path
@@ -61,6 +75,19 @@ function Top1DChart({ verticalMargin = 10, data: spectrum }: Top1DChartProps) {
61
75
  d={path}
62
76
  />
63
77
  </g>
78
+ <g clipPath={`url(#${displayerKey}clip-top-ranges)`}>
79
+ <Ranges1D
80
+ ranges={ranges}
81
+ orientation="horizontal"
82
+ spectrumId={spectrum.id}
83
+ />
84
+ <Signals1D
85
+ ranges={ranges}
86
+ svgRef={svgRef}
87
+ orientation="horizontal"
88
+ spectrumId={spectrum.id}
89
+ />
90
+ </g>
64
91
  </svg>
65
92
  );
66
93
  }
@@ -24,6 +24,7 @@ export function FTContainer(props: FTContainerProps) {
24
24
  <>
25
25
  {spectra.x && <Top1DChart data={spectra.x} />}
26
26
  {spectra.y && <Left1DChart data={spectra.y} />}
27
+
27
28
  <ClipPathContainer>
28
29
  <Contours />
29
30
  </ClipPathContainer>