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,370 @@
1
+ import type {
2
+ CSSProperties,
3
+ KeyboardEvent,
4
+ MouseEvent,
5
+ RefObject,
6
+ } from 'react';
7
+ import { useRef, useState } from 'react';
8
+
9
+ type CursorOrientation = 'horizontal' | 'vertical';
10
+
11
+ const CUR_MOVE = `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='12' viewBox='0 0 22 12'%3E%3Cpath d='M1 6h20M1 6l4-4M1 6l4 4M21 6l-4-4M21 6l-4 4' fill='none' stroke='black' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") 11 6, ew-resize`;
12
+ const CUR_MOVE_VERTICAL = `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='22' viewBox='0 0 12 22'%3E%3Cpath d='M6 1v20M6 1l-4 4M6 1l4 4M6 21l-4-4M6 21l4-4' fill='none' stroke='black' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") 6 11, ns-resize`;
13
+ type AnchorShape = 'diamond' | 'circle' | 'square' | 'triangle';
14
+
15
+ interface AnchorStyle {
16
+ size?: number;
17
+ hoverSize?: number;
18
+ dragSize?: number;
19
+ fill?: string;
20
+ stroke?: string;
21
+ hoverFill?: string;
22
+ hoverStroke?: string;
23
+ dragFill?: string;
24
+ dragStroke?: string;
25
+ strokeWidth?: number;
26
+ guideColor?: string;
27
+ guideDragColor?: string;
28
+ guideStyle?: 'solid' | 'dashed' | 'dotted';
29
+ }
30
+
31
+ interface AnchorPosition {
32
+ x: number;
33
+ y: number;
34
+ }
35
+
36
+ interface AnchorProps {
37
+ position: AnchorPosition;
38
+ shape?: AnchorShape;
39
+ svgRef: RefObject<SVGSVGElement>;
40
+ svgHeight: number;
41
+ anchorStyle?: AnchorStyle;
42
+ restoreFocusOnLeave?: boolean;
43
+ onDragMove: (newPosition: AnchorPosition) => void;
44
+ onDragEnd: (lastPosition: AnchorPosition) => void;
45
+ onDelete: () => void;
46
+ cursorOrientation?: CursorOrientation;
47
+ }
48
+
49
+ interface DragState {
50
+ startX: number;
51
+ startY: number;
52
+ startAnchorX: number;
53
+ startAnchorY: number;
54
+ }
55
+
56
+ type InteractionState = 'idle' | 'hovered' | 'dragging';
57
+
58
+ interface VisualTokens {
59
+ fill: string;
60
+ stroke: string;
61
+ cursor: string;
62
+ }
63
+
64
+ function resolveVisuals(
65
+ state: InteractionState,
66
+ idleFill: string,
67
+ idleStroke: string,
68
+ hoverFill: string,
69
+ hoverStroke: string,
70
+ dragFill: string,
71
+ dragStroke: string,
72
+ cursorOrientation: CursorOrientation,
73
+ ): VisualTokens {
74
+ const cursor =
75
+ cursorOrientation === 'horizontal' ? CUR_MOVE : CUR_MOVE_VERTICAL;
76
+ if (state === 'dragging') {
77
+ return {
78
+ fill: dragFill,
79
+ stroke: dragStroke,
80
+ cursor,
81
+ };
82
+ }
83
+
84
+ if (state === 'hovered') {
85
+ return {
86
+ fill: hoverFill,
87
+ stroke: hoverStroke,
88
+ cursor,
89
+ };
90
+ }
91
+
92
+ return {
93
+ fill: idleFill,
94
+ stroke: idleStroke,
95
+ cursor: 'default',
96
+ };
97
+ }
98
+
99
+ function clientToSvg(
100
+ event: MouseEvent<SVGGElement>,
101
+ svg: SVGSVGElement | null,
102
+ ): { x: number; y: number } {
103
+ const { clientX, clientY } = event;
104
+ if (!svg) return { x: clientX, y: clientY };
105
+
106
+ const pt = svg.createSVGPoint();
107
+ pt.x = clientX;
108
+ pt.y = clientY;
109
+
110
+ const ctm = svg.getScreenCTM();
111
+
112
+ if (!ctm) return { x: clientX, y: clientY };
113
+
114
+ return pt.matrixTransform(ctm.inverse());
115
+ }
116
+
117
+ interface ShapeRendererProps {
118
+ shape?: AnchorShape;
119
+ fill: string;
120
+ stroke: string;
121
+ strokeWidth: number;
122
+ size: number;
123
+ }
124
+
125
+ function ShapeRenderer({
126
+ shape,
127
+ fill,
128
+ stroke,
129
+ strokeWidth,
130
+ size,
131
+ }: ShapeRendererProps) {
132
+ const half = size / 2;
133
+ const inset = strokeWidth / 2;
134
+
135
+ const common: CSSProperties = {
136
+ filter: 'drop-shadow(0 2px 4px rgba(0,0,0,.14))',
137
+ pointerEvents: 'all',
138
+ };
139
+
140
+ if (shape === 'circle') {
141
+ return (
142
+ <circle
143
+ cx={0}
144
+ cy={0}
145
+ r={half - inset}
146
+ fill={fill}
147
+ stroke={stroke}
148
+ strokeWidth={strokeWidth}
149
+ style={common}
150
+ />
151
+ );
152
+ }
153
+
154
+ if (shape === 'diamond') {
155
+ return (
156
+ <polygon
157
+ points={`
158
+ 0,-${half - inset}
159
+ ${half - inset},0
160
+ 0,${half - inset}
161
+ -${half - inset},0
162
+ `}
163
+ fill={fill}
164
+ stroke={stroke}
165
+ strokeWidth={strokeWidth}
166
+ strokeLinejoin="round"
167
+ style={common}
168
+ />
169
+ );
170
+ }
171
+
172
+ if (shape === 'triangle') {
173
+ return (
174
+ <polygon
175
+ points={`
176
+ 0,-${half - inset}
177
+ ${half - inset},${half - inset}
178
+ -${half - inset},${half - inset}
179
+ `}
180
+ fill={fill}
181
+ stroke={stroke}
182
+ strokeWidth={strokeWidth}
183
+ strokeLinejoin="round"
184
+ style={common}
185
+ />
186
+ );
187
+ }
188
+
189
+ return (
190
+ <rect
191
+ x={-half + inset}
192
+ y={-half + inset}
193
+ width={size - strokeWidth}
194
+ height={size - strokeWidth}
195
+ rx={1}
196
+ fill={fill}
197
+ stroke={stroke}
198
+ strokeWidth={strokeWidth}
199
+ style={common}
200
+ />
201
+ );
202
+ }
203
+
204
+ export function Anchor({
205
+ position,
206
+ shape,
207
+ svgRef,
208
+ svgHeight,
209
+ anchorStyle = {},
210
+ restoreFocusOnLeave = false,
211
+ onDragMove,
212
+ onDragEnd,
213
+ onDelete,
214
+ cursorOrientation = 'horizontal',
215
+ }: AnchorProps) {
216
+ const {
217
+ size = 16,
218
+ hoverSize = size,
219
+ dragSize = size,
220
+ fill: idleFill = '#ffffff',
221
+ stroke: idleStroke = '#d1d5db',
222
+ hoverFill = '#f3f4f6',
223
+ hoverStroke = '#9ca3af',
224
+ dragFill = '#f3f4f6',
225
+ dragStroke = '#6b7280',
226
+ strokeWidth = 1,
227
+ guideColor = 'rgba(156,163,175,0.6)',
228
+ guideDragColor = 'rgba(107,114,128,0.8)',
229
+ guideStyle = 'solid',
230
+ } = anchorStyle;
231
+
232
+ const [hovered, setHovered] = useState(false);
233
+ const [dragging, setDragging] = useState(false);
234
+
235
+ const dragState = useRef<DragState | null>(null);
236
+ const prevFocus = useRef<Element | null>(null);
237
+
238
+ const interactionState: InteractionState = dragging
239
+ ? 'dragging'
240
+ : hovered
241
+ ? 'hovered'
242
+ : 'idle';
243
+
244
+ const { fill, stroke, cursor } = resolveVisuals(
245
+ interactionState,
246
+ idleFill,
247
+ idleStroke,
248
+ hoverFill,
249
+ hoverStroke,
250
+ dragFill,
251
+ dragStroke,
252
+ cursorOrientation,
253
+ );
254
+
255
+ function handleMouseDown(e: MouseEvent<SVGGElement>) {
256
+ e.preventDefault();
257
+ setDragging(true);
258
+ const { x, y } = clientToSvg(e, svgRef.current);
259
+ dragState.current = {
260
+ startX: x,
261
+ startY: y,
262
+ startAnchorX: position.x,
263
+ startAnchorY: position.y,
264
+ };
265
+
266
+ const onMove = (e: globalThis.MouseEvent) => {
267
+ const current = dragState.current;
268
+ if (!current) return;
269
+ const { x, y } = clientToSvg(
270
+ e as unknown as MouseEvent<SVGGElement>,
271
+ svgRef.current,
272
+ );
273
+ const newX = current.startAnchorX + x - current.startX;
274
+ const newY = current.startAnchorY + y - current.startY;
275
+
276
+ onDragMove({ x: newX, y: newY });
277
+ };
278
+
279
+ const onUp = () => {
280
+ setDragging(false);
281
+ dragState.current = null;
282
+ onDragEnd({ x: position.x, y: position.y });
283
+
284
+ window.removeEventListener('mousemove', onMove);
285
+ window.removeEventListener('mouseup', onUp);
286
+ };
287
+
288
+ window.addEventListener('mousemove', onMove);
289
+ window.addEventListener('mouseup', onUp);
290
+ }
291
+
292
+ function handleKeyDown(e: KeyboardEvent<SVGGElement>) {
293
+ if (e.key === 'Delete' || e.key === 'Backspace') {
294
+ e.preventDefault();
295
+ onDelete();
296
+ }
297
+ }
298
+
299
+ function handleMouseEnter(e: MouseEvent<SVGGElement>) {
300
+ setHovered(true);
301
+ prevFocus.current = document.activeElement;
302
+ e.currentTarget.focus();
303
+ }
304
+
305
+ function handleMouseLeave(e: MouseEvent<SVGGElement>) {
306
+ setHovered(false);
307
+
308
+ if (restoreFocusOnLeave && prevFocus.current instanceof HTMLElement) {
309
+ prevFocus.current.focus();
310
+ } else {
311
+ e.currentTarget.blur();
312
+ }
313
+
314
+ prevFocus.current = null;
315
+ }
316
+
317
+ return (
318
+ <>
319
+ {(hovered || dragging) && (
320
+ <line
321
+ x1={position.x}
322
+ y1={0}
323
+ x2={position.x}
324
+ y2={svgHeight}
325
+ stroke={dragging ? guideDragColor : guideColor}
326
+ strokeWidth={1}
327
+ strokeDasharray={
328
+ guideStyle === 'dashed'
329
+ ? '6 4'
330
+ : guideStyle === 'dotted'
331
+ ? '1 3'
332
+ : undefined
333
+ }
334
+ pointerEvents="none"
335
+ />
336
+ )}
337
+
338
+ <g
339
+ transform={`translate(${position.x} ${position.y})`}
340
+ style={{
341
+ cursor,
342
+ outline: 'none',
343
+ }}
344
+ tabIndex={0}
345
+ data-self-control="true"
346
+ onMouseDown={handleMouseDown}
347
+ onMouseEnter={handleMouseEnter}
348
+ onMouseLeave={handleMouseLeave}
349
+ onKeyDown={handleKeyDown}
350
+ >
351
+ {(hovered || dragging) && (
352
+ <circle
353
+ r={(hovered ? hoverSize : dragSize) * 1.5}
354
+ fill={stroke}
355
+ opacity={dragging ? 0.2 : 0.15}
356
+ pointerEvents="none"
357
+ />
358
+ )}
359
+
360
+ <ShapeRenderer
361
+ shape={shape}
362
+ fill={fill}
363
+ stroke={stroke}
364
+ strokeWidth={strokeWidth}
365
+ size={hovered ? hoverSize : dragging ? dragSize : size}
366
+ />
367
+ </g>
368
+ </>
369
+ );
370
+ }
@@ -215,6 +215,12 @@ export function BrushTracker(options: BrushTrackerProps) {
215
215
  (event: PointerEvent) => {
216
216
  event.persist();
217
217
  const currentTarget = event.currentTarget;
218
+
219
+ const target = event.target as HTMLElement;
220
+ if (target.closest('[data-self-control="true"]')) {
221
+ return;
222
+ }
223
+
218
224
  isDraggingRef.current = false; // Reset dragging flag
219
225
 
220
226
  //check that the right or left mouse button pressed
@@ -74,6 +74,11 @@ function getModifiersKey(event: EventModifierKeys) {
74
74
  return toModifiersKey(keyModifiers);
75
75
  }
76
76
 
77
+ export function useIsPrimaryKeyActivated() {
78
+ const { primaryKeyIdentifier } = useMapKeyModifiers();
79
+ return primaryKeyIdentifier === 'shift[false]_ctrl[false]_alt[false]';
80
+ }
81
+
77
82
  export function useMapKeyModifiers() {
78
83
  const {
79
84
  current: {
@@ -12,7 +12,6 @@ import {
12
12
  Overlay2,
13
13
  mergeRefs,
14
14
  } from '@blueprintjs/core';
15
- import { SmallCross } from '@blueprintjs/icons';
16
15
  import { Global } from '@emotion/react';
17
16
  import styled from '@emotion/styled';
18
17
  import type { MouseEvent, ReactNode, RefObject } from 'react';
@@ -224,7 +223,7 @@ function CloseButton(
224
223
  <Button
225
224
  aria-label="Close"
226
225
  className={Classes.DIALOG_CLOSE_BUTTON}
227
- icon={<SmallCross size={IconSize.STANDARD} />}
226
+ icon="small-cross"
228
227
  variant="minimal"
229
228
  onClick={onClose}
230
229
  />
@@ -207,7 +207,7 @@ const InnerHeader = styled.div`
207
207
  `;
208
208
 
209
209
  interface BaseSectionProps {
210
- title: string;
210
+ title: ReactNode;
211
211
  serial?: number;
212
212
  rightElement?: ReactNode | ((isOpen: boolean) => ReactNode);
213
213
  leftElement?: ReactNode | ((isOpen: boolean) => ReactNode);
@@ -216,14 +216,14 @@ interface BaseSectionProps {
216
216
  }
217
217
 
218
218
  interface SectionItemProps extends BaseSectionProps {
219
- id?: string;
219
+ id: string;
220
220
  index?: number;
221
221
  onClick?: (id: any, event?: MouseEvent<HTMLDivElement>) => void;
222
222
  children?: ReactNode | ((options: { isOpen?: boolean }) => ReactNode);
223
223
  isOpen: boolean;
224
224
  sticky?: boolean;
225
225
  onReorder?: (sourceId: number, targetId: number) => void;
226
- dragLabel?: string;
226
+ dragLabel?: ReactNode;
227
227
  }
228
228
 
229
229
  interface SectionProps {
@@ -271,7 +271,7 @@ function SectionItem(props: SectionItemProps) {
271
271
  const {
272
272
  title,
273
273
  dragLabel = title,
274
- id = title,
274
+ id,
275
275
  onClick,
276
276
  serial,
277
277
  rightElement,
@@ -1,6 +1,6 @@
1
1
  import { DialogFooter } from '@blueprintjs/core';
2
2
  import { useMemo } from 'react';
3
- import { Button, Form, useForm } from 'react-science/ui';
3
+ import { AppForm, Button, useForm } from 'react-science/ui';
4
4
  import { z } from 'zod/v4';
5
5
 
6
6
  import { ExportFields } from '../../modal/setting/tanstack_general_settings/tabs/export_tab.fields.tsx';
@@ -67,36 +67,27 @@ function InnerExportOptionsModal(props: InnerExportOptionsModalProps) {
67
67
  canEscapeKeyClose
68
68
  autoFocus
69
69
  >
70
- <form.AppForm>
71
- <Form
72
- layout="inline"
73
- noValidate
74
- onSubmit={(event) => {
75
- event.preventDefault();
76
- void form.handleSubmit();
77
- }}
78
- >
79
- <StyledDialogBody>
80
- <ExportFields form={form} fields="values" />
81
- </StyledDialogBody>
82
- <DialogFooter
83
- actions={
84
- <>
85
- <Button
86
- variant="outlined"
87
- intent="danger"
88
- onClick={() => onCloseDialog?.()}
89
- >
90
- Cancel
91
- </Button>
92
- <form.SubmitButton intent="success">
93
- {confirmButtonText}
94
- </form.SubmitButton>
95
- </>
96
- }
97
- />
98
- </Form>
99
- </form.AppForm>
70
+ <AppForm form={form} layout="inline">
71
+ <StyledDialogBody>
72
+ <ExportFields form={form} fields="values" />
73
+ </StyledDialogBody>
74
+ <DialogFooter
75
+ actions={
76
+ <>
77
+ <Button
78
+ variant="outlined"
79
+ intent="danger"
80
+ onClick={() => onCloseDialog?.()}
81
+ >
82
+ Cancel
83
+ </Button>
84
+ <form.SubmitButton intent="success">
85
+ {confirmButtonText}
86
+ </form.SubmitButton>
87
+ </>
88
+ }
89
+ />
90
+ </AppForm>
100
91
  </StandardDialog>
101
92
  );
102
93
  }
@@ -10,7 +10,6 @@ import { Toolbar, useFullscreen } from 'react-science/ui';
10
10
 
11
11
  import { docsBaseUrl } from '../../constants.js';
12
12
  import { useChartData } from '../context/ChartContext.js';
13
- import { useCore } from '../context/CoreContext.js';
14
13
  import {
15
14
  usePreferences,
16
15
  useWorkspacesList,
@@ -28,7 +27,7 @@ import AboutUsModal from '../modal/aboutUs/AboutUsModal.js';
28
27
  import WorkspaceItem from '../modal/setting/WorkspaceItem.js';
29
28
  import { GeneralSettingsToolbarItem } from '../modal/setting/general_settings.js';
30
29
  import { options } from '../toolbar/ToolTypes.js';
31
- import { renderCoreSlot } from '../utility/renderCoreSlot.js';
30
+ import { CoreSlot } from '../utility/CoreSlot.tsx';
32
31
 
33
32
  import { AutoPeakPickingOptionPanel } from './AutoPeakPickingOptionPanel.js';
34
33
  import { HeaderWrapper } from './HeaderWrapper.js';
@@ -63,7 +62,6 @@ interface HeaderInnerProps {
63
62
 
64
63
  function HeaderInner(props: HeaderInnerProps) {
65
64
  const { selectedOptionPanel, height } = props;
66
- const core = useCore();
67
65
 
68
66
  const {
69
67
  current: {
@@ -149,7 +147,7 @@ function HeaderInner(props: HeaderInnerProps) {
149
147
  }}
150
148
  >
151
149
  <PluginTopBarRight>
152
- {renderCoreSlot(core, 'topbar.right')}
150
+ <CoreSlot slot="topbar.right" />
153
151
  </PluginTopBarRight>
154
152
 
155
153
  {!hideWorkspaces && (
@@ -2,11 +2,7 @@ import { Button, DialogBody, DialogFooter } from '@blueprintjs/core';
2
2
  import { revalidateLogic } from '@tanstack/react-form';
3
3
  import type { Workspace } from '@zakodium/nmrium-core';
4
4
  import { useRef } from 'react';
5
- import {
6
- Form,
7
- useForm as useReactScienceForm,
8
- useOnOff,
9
- } from 'react-science/ui';
5
+ import { AppForm, useForm, useOnOff } from 'react-science/ui';
10
6
  import { z } from 'zod/v4';
11
7
 
12
8
  import { usePreferences } from '../context/PreferencesContext.js';
@@ -30,7 +26,7 @@ export function useSaveSettings() {
30
26
 
31
27
  const { saveWorkspace, addNewWorkspace } = useWorkspaceAction();
32
28
 
33
- const form = useReactScienceForm({
29
+ const form = useForm({
34
30
  defaultValues: { workspaceName: '' },
35
31
  validationLogic: revalidateLogic({ modeAfterSubmission: 'change' }),
36
32
  validators: { onDynamic: schema },
@@ -67,14 +63,7 @@ export function useSaveSettings() {
67
63
  title="Save workspace"
68
64
  role="dialog"
69
65
  >
70
- <Form
71
- layout="stacked"
72
- noValidate
73
- onSubmit={(event) => {
74
- event.preventDefault();
75
- void form.handleSubmit();
76
- }}
77
- >
66
+ <AppForm form={form} layout="stacked">
78
67
  <DialogBody>
79
68
  <form.AppField name="workspaceName">
80
69
  {(field) => (
@@ -107,7 +96,7 @@ export function useSaveSettings() {
107
96
  </>
108
97
  }
109
98
  />
110
- </Form>
99
+ </AppForm>
111
100
  </StandardDialog>
112
101
  );
113
102
  },
@@ -5,10 +5,9 @@ import type {
5
5
  Spectrum1D,
6
6
  Spectrum,
7
7
  } from '@zakodium/nmrium-core';
8
- import type { FormEvent } from 'react';
9
8
  import {
9
+ AppForm,
10
10
  FieldGroupSVGTextStyleFields,
11
- Form,
12
11
  assert,
13
12
  svgTextStyleFieldsSchema,
14
13
  useForm,
@@ -191,13 +190,8 @@ function InnerPublicationStringModal(props: InnerPublicationStringModalProps) {
191
190
 
192
191
  if (!spectrum || !isSpectrum1D(spectrum)) return null;
193
192
 
194
- function onSubmit(event: FormEvent<HTMLFormElement>) {
195
- event.preventDefault();
196
- void form.handleSubmit(event);
197
- }
198
-
199
193
  return (
200
- <form.AppForm>
194
+ <>
201
195
  <StandardDialog
202
196
  isOpen
203
197
  title="Publication string"
@@ -207,7 +201,7 @@ function InnerPublicationStringModal(props: InnerPublicationStringModalProps) {
207
201
  onClose={onClose}
208
202
  style={{ minWidth: 600 }}
209
203
  >
210
- <Form noValidate onSubmit={onSubmit} layout="inline">
204
+ <AppForm form={form} layout="inline">
211
205
  <HelpForm>This configuration is at the nucleus level.</HelpForm>
212
206
  <StyledDialogBody>
213
207
  <form.AppField name="acs.signalKind">
@@ -265,7 +259,7 @@ function InnerPublicationStringModal(props: InnerPublicationStringModalProps) {
265
259
  </form.AppField>
266
260
  )}
267
261
  </DialogFooter>
268
- </Form>
262
+ </AppForm>
269
263
  </StandardDialog>
270
264
 
271
265
  <ClipboardFallbackModal
@@ -274,7 +268,7 @@ function InnerPublicationStringModal(props: InnerPublicationStringModalProps) {
274
268
  text={text}
275
269
  label="Preview publication string"
276
270
  />
277
- </form.AppForm>
271
+ </>
278
272
  );
279
273
  }
280
274