@zakodium/nmrium-core-plugins-ui 0.1.51 → 0.1.53

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 (26) hide show
  1. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction.d.ts.map +1 -1
  2. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction.hook.d.ts +68 -1
  3. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction.hook.d.ts.map +1 -1
  4. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction.hook.js +45 -5
  5. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction.hook.js.map +1 -1
  6. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction.js +4 -0
  7. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction.js.map +1 -1
  8. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_chart_brush_tracker.d.ts +3 -0
  9. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_chart_brush_tracker.d.ts.map +1 -0
  10. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_chart_brush_tracker.js +22 -0
  11. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_chart_brush_tracker.js.map +1 -0
  12. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_chart_svg.d.ts +3 -0
  13. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_chart_svg.d.ts.map +1 -0
  14. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_chart_svg.js +21 -0
  15. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_chart_svg.js.map +1 -0
  16. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_expanded.js +2 -2
  17. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_expanded.js.map +1 -1
  18. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_topbar.js +2 -2
  19. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_topbar.js.map +1 -1
  20. package/package.json +4 -4
  21. package/src/plugins/spectrum_1d_processings_ui/operators/phase_correction.hook.ts +60 -6
  22. package/src/plugins/spectrum_1d_processings_ui/operators/phase_correction.ts +4 -0
  23. package/src/plugins/spectrum_1d_processings_ui/operators/phase_correction_chart_brush_tracker.tsx +28 -0
  24. package/src/plugins/spectrum_1d_processings_ui/operators/phase_correction_chart_svg.tsx +48 -0
  25. package/src/plugins/spectrum_1d_processings_ui/operators/phase_correction_expanded.tsx +2 -2
  26. package/src/plugins/spectrum_1d_processings_ui/operators/phase_correction_topbar.tsx +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"phase_correction.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/phase_correction.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,iBAAiB,yGAS5B,CAAC"}
1
+ {"version":3,"file":"phase_correction.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/phase_correction.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,iBAAiB,yGAW5B,CAAC"}
@@ -2,124 +2,172 @@ import type { ProcessingOperatorUISettingsFormProps } from '@zakodium/nmrium-cor
2
2
  export declare function usePhaseCorrectionForm(props: ProcessingOperatorUISettingsFormProps<'@zakodium/nmrium-core-plugins#phaseCorrection1D'>): {
3
3
  form: import("@tanstack/react-form").AppFieldExtendedReactFormApi<{
4
4
  mode: "absolute";
5
+ pivotIndex?: number | undefined;
5
6
  } | {
6
7
  mode: "manual";
7
8
  ph0: number;
8
9
  ph1: number;
10
+ pivotIndex?: number | undefined;
9
11
  } | {
10
12
  mode: "automatic-compute";
13
+ pivotIndex?: number | undefined;
11
14
  } | {
12
15
  mode: "automatic-info";
16
+ pivotIndex?: number | undefined;
13
17
  }, import("@tanstack/react-form").FormValidateOrFn<{
14
18
  mode: "absolute";
19
+ pivotIndex?: number | undefined;
15
20
  } | {
16
21
  mode: "manual";
17
22
  ph0: number;
18
23
  ph1: number;
24
+ pivotIndex?: number | undefined;
19
25
  } | {
20
26
  mode: "automatic-compute";
27
+ pivotIndex?: number | undefined;
21
28
  } | {
22
29
  mode: "automatic-info";
30
+ pivotIndex?: number | undefined;
23
31
  }> | undefined, import("@tanstack/react-form").FormValidateOrFn<{
24
32
  mode: "absolute";
33
+ pivotIndex?: number | undefined;
25
34
  } | {
26
35
  mode: "manual";
27
36
  ph0: number;
28
37
  ph1: number;
38
+ pivotIndex?: number | undefined;
29
39
  } | {
30
40
  mode: "automatic-compute";
41
+ pivotIndex?: number | undefined;
31
42
  } | {
32
43
  mode: "automatic-info";
44
+ pivotIndex?: number | undefined;
33
45
  }> | undefined, import("@tanstack/react-form").FormAsyncValidateOrFn<{
34
46
  mode: "absolute";
47
+ pivotIndex?: number | undefined;
35
48
  } | {
36
49
  mode: "manual";
37
50
  ph0: number;
38
51
  ph1: number;
52
+ pivotIndex?: number | undefined;
39
53
  } | {
40
54
  mode: "automatic-compute";
55
+ pivotIndex?: number | undefined;
41
56
  } | {
42
57
  mode: "automatic-info";
58
+ pivotIndex?: number | undefined;
43
59
  }> | undefined, import("@tanstack/react-form").FormValidateOrFn<{
44
60
  mode: "absolute";
61
+ pivotIndex?: number | undefined;
45
62
  } | {
46
63
  mode: "manual";
47
64
  ph0: number;
48
65
  ph1: number;
66
+ pivotIndex?: number | undefined;
49
67
  } | {
50
68
  mode: "automatic-compute";
69
+ pivotIndex?: number | undefined;
51
70
  } | {
52
71
  mode: "automatic-info";
72
+ pivotIndex?: number | undefined;
53
73
  }> | undefined, import("@tanstack/react-form").FormAsyncValidateOrFn<{
54
74
  mode: "absolute";
75
+ pivotIndex?: number | undefined;
55
76
  } | {
56
77
  mode: "manual";
57
78
  ph0: number;
58
79
  ph1: number;
80
+ pivotIndex?: number | undefined;
59
81
  } | {
60
82
  mode: "automatic-compute";
83
+ pivotIndex?: number | undefined;
61
84
  } | {
62
85
  mode: "automatic-info";
86
+ pivotIndex?: number | undefined;
63
87
  }> | undefined, import("@tanstack/react-form").FormValidateOrFn<{
64
88
  mode: "absolute";
89
+ pivotIndex?: number | undefined;
65
90
  } | {
66
91
  mode: "manual";
67
92
  ph0: number;
68
93
  ph1: number;
94
+ pivotIndex?: number | undefined;
69
95
  } | {
70
96
  mode: "automatic-compute";
97
+ pivotIndex?: number | undefined;
71
98
  } | {
72
99
  mode: "automatic-info";
100
+ pivotIndex?: number | undefined;
73
101
  }> | undefined, import("@tanstack/react-form").FormAsyncValidateOrFn<{
74
102
  mode: "absolute";
103
+ pivotIndex?: number | undefined;
75
104
  } | {
76
105
  mode: "manual";
77
106
  ph0: number;
78
107
  ph1: number;
108
+ pivotIndex?: number | undefined;
79
109
  } | {
80
110
  mode: "automatic-compute";
111
+ pivotIndex?: number | undefined;
81
112
  } | {
82
113
  mode: "automatic-info";
114
+ pivotIndex?: number | undefined;
83
115
  }> | undefined, import("zod").ZodType<{
84
116
  mode: "absolute";
117
+ pivotIndex?: number | undefined;
85
118
  } | {
86
119
  mode: "manual";
87
120
  ph0: number;
88
121
  ph1: number;
122
+ pivotIndex?: number | undefined;
89
123
  } | {
90
124
  mode: "automatic-compute";
125
+ pivotIndex?: number | undefined;
91
126
  } | {
92
127
  mode: "automatic-info";
128
+ pivotIndex?: number | undefined;
93
129
  }, any, import("zod/v4/core").$ZodTypeInternals<{
94
130
  mode: "absolute";
131
+ pivotIndex?: number | undefined;
95
132
  } | {
96
133
  mode: "manual";
97
134
  ph0: number;
98
135
  ph1: number;
136
+ pivotIndex?: number | undefined;
99
137
  } | {
100
138
  mode: "automatic-compute";
139
+ pivotIndex?: number | undefined;
101
140
  } | {
102
141
  mode: "automatic-info";
142
+ pivotIndex?: number | undefined;
103
143
  }, any>>, import("@tanstack/react-form").FormAsyncValidateOrFn<{
104
144
  mode: "absolute";
145
+ pivotIndex?: number | undefined;
105
146
  } | {
106
147
  mode: "manual";
107
148
  ph0: number;
108
149
  ph1: number;
150
+ pivotIndex?: number | undefined;
109
151
  } | {
110
152
  mode: "automatic-compute";
153
+ pivotIndex?: number | undefined;
111
154
  } | {
112
155
  mode: "automatic-info";
156
+ pivotIndex?: number | undefined;
113
157
  }> | undefined, import("@tanstack/react-form").FormAsyncValidateOrFn<{
114
158
  mode: "absolute";
159
+ pivotIndex?: number | undefined;
115
160
  } | {
116
161
  mode: "manual";
117
162
  ph0: number;
118
163
  ph1: number;
164
+ pivotIndex?: number | undefined;
119
165
  } | {
120
166
  mode: "automatic-compute";
167
+ pivotIndex?: number | undefined;
121
168
  } | {
122
169
  mode: "automatic-info";
170
+ pivotIndex?: number | undefined;
123
171
  }> | undefined, unknown, {
124
172
  readonly Input: typeof import("react-science/ui")._Input;
125
173
  readonly NumericInput: typeof import("react-science/ui")._NumericInput;
@@ -138,14 +186,33 @@ export declare function usePhaseCorrectionForm(props: ProcessingOperatorUISettin
138
186
  selectModeProps: Pick<import("react-science/ui").SelectProps, "itemDisabled" | "items">;
139
187
  appFieldModeListeners: import("@tanstack/react-form").FieldListeners<{
140
188
  mode: "absolute";
189
+ pivotIndex?: number | undefined;
141
190
  } | {
142
191
  mode: "manual";
143
192
  ph0: number;
144
193
  ph1: number;
194
+ pivotIndex?: number | undefined;
145
195
  } | {
146
196
  mode: "automatic-compute";
197
+ pivotIndex?: number | undefined;
147
198
  } | {
148
199
  mode: "automatic-info";
149
- }, "mode" | "ph0" | "ph1", number | "absolute" | "manual" | "automatic-compute" | "automatic-info">;
200
+ pivotIndex?: number | undefined;
201
+ }, "mode" | "pivotIndex" | "ph0" | "ph1", number | "absolute" | "manual" | "automatic-compute" | "automatic-info" | undefined>;
202
+ appFieldPh1Listeners: import("@tanstack/react-form").FieldListeners<{
203
+ mode: "absolute";
204
+ pivotIndex?: number | undefined;
205
+ } | {
206
+ mode: "manual";
207
+ ph0: number;
208
+ ph1: number;
209
+ pivotIndex?: number | undefined;
210
+ } | {
211
+ mode: "automatic-compute";
212
+ pivotIndex?: number | undefined;
213
+ } | {
214
+ mode: "automatic-info";
215
+ pivotIndex?: number | undefined;
216
+ }, "mode" | "pivotIndex" | "ph0" | "ph1", number | "absolute" | "manual" | "automatic-compute" | "automatic-info" | undefined>;
150
217
  };
151
218
  //# sourceMappingURL=phase_correction.hook.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"phase_correction.hook.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/phase_correction.hook.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,uBAAuB,CAAC;AA6BnF,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,qCAAqC,CAAC,iDAAiD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkFhG"}
1
+ {"version":3,"file":"phase_correction.hook.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/phase_correction.hook.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,uBAAuB,CAAC;AA8BnF,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,qCAAqC,CAAC,iDAAiD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8HhG"}
@@ -1,8 +1,9 @@
1
1
  import { revalidateLogic } from '@tanstack/react-form';
2
2
  import { castSpectrum1D } from '@zakodium/nmrium-core';
3
- import { cast } from '@zakodium/utils';
3
+ import { assert, cast } from '@zakodium/utils';
4
+ import { xFindClosestIndex, xMaxAbsoluteValue } from 'ml-spectra-processing';
4
5
  import { autoPhaseCorrection } from 'nmr-processing';
5
- import { useEffect, useMemo } from 'react';
6
+ import { useEffect, useMemo, useRef } from 'react';
6
7
  import { useForm } from 'react-science/ui';
7
8
  const items = [
8
9
  {
@@ -75,10 +76,49 @@ export function usePhaseCorrectionForm(props) {
75
76
  if (phases.ph0 === 0 && phases.ph1 === 0) {
76
77
  phases = autoPhaseCorrection(spectrum, { magnitudeMode: true });
77
78
  }
78
- form.setFieldValue('ph0', phases.ph0);
79
- form.setFieldValue('ph1', phases.ph1);
79
+ const { ph0, ph1 } = phases;
80
+ prevPh1Ref.current = ph1;
81
+ form.setFieldValue('ph0', ph0, { dontRunListeners: true });
82
+ form.setFieldValue('ph1', ph1, { dontRunListeners: true });
83
+ // reuse previous pivotIndex or compute it if missing
84
+ const formPivot = form.state.values.pivotIndex;
85
+ const pivotIndex = typeof formPivot === 'number' ? formPivot : findStrongestPeak(spectrum);
86
+ form.setFieldValue('pivotIndex', pivotIndex, { dontRunListeners: true });
87
+ const settings = {
88
+ mode: 'manual',
89
+ ph0,
90
+ ph1,
91
+ pivotIndex,
92
+ };
93
+ onChange({ ...operation, settings });
94
+ },
95
+ };
96
+ const prevPh1Ref = useRef(form.state.values.mode === 'manual' ? form.state.values.ph1 : 0);
97
+ const appFieldPh1Listeners = {
98
+ onChange: ({ value, fieldApi }) => {
99
+ // It is not strictly typed to `<AppField name="mode">`,
100
+ // so little safety check if the listener is attached to the right field.
101
+ // NB: `Extract<AppFieldProps, {name: 'mode'}>` returns `never`.
102
+ if (fieldApi.name !== 'ph1')
103
+ return;
104
+ assert(form.state.values.mode === 'manual');
105
+ const ph1 = Number(value);
106
+ if (Number.isNaN(ph1))
107
+ return;
108
+ const diff = ph1 - prevPh1Ref.current;
109
+ const pivotIndex = form.state.values.pivotIndex ?? 0;
110
+ const length = spectrum.data.re.length;
111
+ const factor = length - pivotIndex;
112
+ const ph0 = form.state.values.ph0 - (diff * factor) / length;
113
+ prevPh1Ref.current = ph1;
114
+ form.setFieldValue('ph0', ph0);
80
115
  },
81
116
  };
82
- return { form, selectModeProps, appFieldModeListeners };
117
+ return { form, selectModeProps, appFieldModeListeners, appFieldPh1Listeners };
118
+ }
119
+ function findStrongestPeak(spectrum) {
120
+ const re = spectrum.data.re;
121
+ const maxY = xMaxAbsoluteValue(re);
122
+ return xFindClosestIndex(re, maxY, { sorted: false });
83
123
  }
84
124
  //# sourceMappingURL=phase_correction.hook.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"phase_correction.hook.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/phase_correction.hook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAU3C,MAAM,KAAK,GAAW;IACpB;QACE,KAAK,EAAE,mBAAmB;QAC1B,KAAK,EAAE,iCAAiC;KACzC;IACD;QACE,KAAK,EAAE,gBAAgB;QACvB,KAAK,EAAE,sCAAsC;KAC9C;IACD,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;IACpC,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE;CACzC,CAAC;AAEF,MAAM,UAAU,sBAAsB,CACpC,KAA+F;IAE/F,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAChE,cAAc,CAAC,QAAQ,CAAC,C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QACjC,CAAC;KACF,CAAC;IAEF,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,CAAC;AAChF,CAAC;AAED,SAAS,iBAAiB,CAAC,QAAoB;IAC7C,MAAM,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;IAC5B,MAAM,IAAI,GAAG,iBAAiB,CAAC,EAAE,CAAC,CAAC;IACnC,OAAO,iBAAiB,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;AACxD,CAAC"}
@@ -1,4 +1,6 @@
1
1
  import { defineProcessingOperatorUI } from '@zakodium/nmrium-core';
2
+ import { PhaseCorrectionChartBrushTracker } from "./phase_correction_chart_brush_tracker.js";
3
+ import { PhaseCorrectionChartSvg } from "./phase_correction_chart_svg.js";
2
4
  import { PhaseCorrectionExpanded } from "./phase_correction_expanded.js";
3
5
  import { PhaseCorrectionTool } from "./phase_correction_tool.js";
4
6
  import { PhaseCorrectionTopbar } from "./phase_correction_topbar.js";
@@ -11,5 +13,7 @@ export const phaseCorrection1D = defineProcessingOperatorUI({
11
13
  defaultShouldProcessAll: false,
12
14
  Tool: PhaseCorrectionTool,
13
15
  TopBar: PhaseCorrectionTopbar,
16
+ ChartBrushTracker: PhaseCorrectionChartBrushTracker,
17
+ ChartSVG: PhaseCorrectionChartSvg,
14
18
  });
15
19
  //# sourceMappingURL=phase_correction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"phase_correction.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/phase_correction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAiC,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA6B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA+B,CAAC;AAEtE,MAAM,CAAC,MAAM,iBAAiB,GAAG,0BAA0B,CAAC;IAC1D,EAAE,EAAE,iDAAiD;IACrD,IAAI,EAAE,kBAAkB;IACxB,UAAU,EAAE,IAAI;IAChB,cAAc,EAAE,IAAI;IACpB,QAAQ,EAAE,uBAAuB;IACjC,uBAAuB,EAAE,KAAK;IAC9B,IAAI,EAAE,mBAAmB;IACzB,MAAM,EAAE,qBAAqB;CAC9B,CAAC,CAAC"}
1
+ {"version":3,"file":"phase_correction.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/phase_correction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,OAAO,EAAE,gCAAgC,EAAE,MAAM,2CAA4C,CAAC;AAC9F,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAkC,CAAC;AAC3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAiC,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA6B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA+B,CAAC;AAEtE,MAAM,CAAC,MAAM,iBAAiB,GAAG,0BAA0B,CAAC;IAC1D,EAAE,EAAE,iDAAiD;IACrD,IAAI,EAAE,kBAAkB;IACxB,UAAU,EAAE,IAAI;IAChB,cAAc,EAAE,IAAI;IACpB,QAAQ,EAAE,uBAAuB;IACjC,uBAAuB,EAAE,KAAK;IAC9B,IAAI,EAAE,mBAAmB;IACzB,MAAM,EAAE,qBAAqB;IAC7B,iBAAiB,EAAE,gCAAgC;IACnD,QAAQ,EAAE,uBAAuB;CAClC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ProcessingOperatorUIChartBrushTrackerProps } from '@zakodium/nmrium-core';
2
+ export declare function PhaseCorrectionChartBrushTracker(props: ProcessingOperatorUIChartBrushTrackerProps<'@zakodium/nmrium-core-plugins#phaseCorrection1D'>): null;
3
+ //# sourceMappingURL=phase_correction_chart_brush_tracker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phase_correction_chart_brush_tracker.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/phase_correction_chart_brush_tracker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0CAA0C,EAAE,MAAM,uBAAuB,CAAC;AAIxF,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,0CAA0C,CAAC,iDAAiD,CAAC,QAsBrG"}
@@ -0,0 +1,22 @@
1
+ import { castSpectrum1D } from '@zakodium/nmrium-core';
2
+ import { xFindClosestIndex } from 'ml-spectra-processing';
3
+ export function PhaseCorrectionChartBrushTracker(props) {
4
+ const { useBrushTrackerEvent, scaleX, onChange, operation, spectrum } = props;
5
+ castSpectrum1D(spectrum);
6
+ useBrushTrackerEvent({
7
+ onClick: (event) => {
8
+ const chartX = event.position.x;
9
+ const spectrumX = scaleX.invert(chartX);
10
+ const index = xFindClosestIndex(spectrum.data.x, spectrumX);
11
+ onChange({
12
+ ...operation,
13
+ settings: {
14
+ ...operation.settings,
15
+ pivotIndex: index,
16
+ },
17
+ });
18
+ },
19
+ });
20
+ return null;
21
+ }
22
+ //# sourceMappingURL=phase_correction_chart_brush_tracker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phase_correction_chart_brush_tracker.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/phase_correction_chart_brush_tracker.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,MAAM,UAAU,gCAAgC,CAC9C,KAAoG;IAEpG,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC9E,cAAc,CAAC,QAAQ,CAAC,CAAC;IAEzB,oBAAoB,CAAC;QACnB,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACjB,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;YAChC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACxC,MAAM,KAAK,GAAG,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;YAE5D,QAAQ,CAAC;gBACP,GAAG,SAAS;gBACZ,QAAQ,EAAE;oBACR,GAAG,SAAS,CAAC,QAAQ;oBACrB,UAAU,EAAE,KAAK;iBAClB;aACF,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ProcessingOperatorUIChartSVGProps } from '@zakodium/nmrium-core';
2
+ export declare function PhaseCorrectionChartSvg(props: ProcessingOperatorUIChartSVGProps<'@zakodium/nmrium-core-plugins#phaseCorrection1D'>): import("react").JSX.Element | null;
3
+ //# sourceMappingURL=phase_correction_chart_svg.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phase_correction_chart_svg.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/phase_correction_chart_svg.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,uBAAuB,CAAC;AAG/E,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,iCAAiC,CAAC,iDAAiD,CAAC,sCAiB5F"}
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { castSpectrum1D } from '@zakodium/nmrium-core';
3
+ export function PhaseCorrectionChartSvg(props) {
4
+ const { spectrum, operation, scaleX, scaleY, indicatorLineColor } = props;
5
+ castSpectrum1D(spectrum);
6
+ const { pivotIndex } = operation.settings;
7
+ if (typeof pivotIndex !== 'number')
8
+ return null;
9
+ const pivotX = scaleX(spectrum.data.x[pivotIndex]);
10
+ const baselineY = scaleY(0);
11
+ return (_jsxs(_Fragment, { children: [_jsx(PivotIndicator, { x: pivotX, stroke: indicatorLineColor }), _jsx(BaselineIndicator, { y: baselineY, stroke: indicatorLineColor })] }));
12
+ }
13
+ function PivotIndicator(props) {
14
+ const { x, stroke } = props;
15
+ return (_jsx("line", { x1: x, x2: x, y1: 0, y2: "100%", strokeWidth: 2, stroke: stroke }));
16
+ }
17
+ function BaselineIndicator(props) {
18
+ const { y, stroke } = props;
19
+ return (_jsx("line", { x1: 0, x2: "100%", y1: y, y2: y, strokeWidth: 1, stroke: stroke }));
20
+ }
21
+ //# sourceMappingURL=phase_correction_chart_svg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phase_correction_chart_svg.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/phase_correction_chart_svg.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,MAAM,UAAU,uBAAuB,CACrC,KAA2F;IAE3F,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,EAAE,GAAG,KAAK,CAAC;IAC1E,cAAc,CAAC,QAAQ,CAAC,CAAC;IAEzB,MAAM,EAAE,UAAU,EAAE,GAAG,SAAS,CAAC,QAAQ,CAAC;IAC1C,IAAI,OAAO,UAAU,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAEhD,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;IACnD,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAE5B,OAAO,CACL,8BACE,KAAC,cAAc,IAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,GAAI,EACzD,KAAC,iBAAiB,IAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,kBAAkB,GAAI,IAC9D,CACJ,CAAC;AACJ,CAAC;AAOD,SAAS,cAAc,CAAC,KAA0B;IAChD,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IAE5B,OAAO,CACL,eAAM,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAC,MAAM,EAAC,WAAW,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,GAAI,CACxE,CAAC;AACJ,CAAC;AAOD,SAAS,iBAAiB,CAAC,KAA6B;IACtD,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IAE5B,OAAO,CACL,eAAM,EAAE,EAAE,CAAC,EAAE,EAAE,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,GAAI,CACxE,CAAC;AACJ,CAAC"}
@@ -3,9 +3,9 @@ import { castSpectrum1D } from '@zakodium/nmrium-core';
3
3
  import { AppForm } from 'react-science/ui';
4
4
  import { usePhaseCorrectionForm } from "./phase_correction.hook.js";
5
5
  export function PhaseCorrectionExpanded(props) {
6
- const { form, selectModeProps, appFieldModeListeners } = usePhaseCorrectionForm(props);
6
+ const { form, selectModeProps, appFieldModeListeners, appFieldPh1Listeners } = usePhaseCorrectionForm(props);
7
7
  const { spectrum, children } = props;
8
8
  castSpectrum1D(spectrum);
9
- return (_jsxs(AppForm, { form: form, layout: "stacked", children: [children?.(_jsx(form.SubmitButton, { variant: "outlined", size: "small", intent: "success", children: "Apply" })), _jsx(form.AppField, { name: "mode", listeners: appFieldModeListeners, children: (field) => (_jsxs(_Fragment, { children: [_jsx(field.Select, { label: "Mode", layout: "inline", ...selectModeProps }), field.state.value === 'manual' && (_jsxs(_Fragment, { children: [_jsx(form.AppField, { name: "ph0", children: (field) => (_jsx(field.DraggableNumericInput, { label: "PH0", draggableLabel: "Change PH0 (click and drag)", draggableIntent: "success" })) }), _jsx(form.AppField, { name: "ph1", children: (field) => (_jsx(field.DraggableNumericInput, { label: "PH1", draggableLabel: "Change PH1 (click and drag)", draggableIntent: "success" })) })] }))] })) })] }));
9
+ return (_jsxs(AppForm, { form: form, layout: "stacked", children: [children?.(_jsx(form.SubmitButton, { variant: "outlined", size: "small", intent: "success", children: "Apply" })), _jsx(form.AppField, { name: "mode", listeners: appFieldModeListeners, children: (field) => (_jsxs(_Fragment, { children: [_jsx(field.Select, { label: "Mode", layout: "inline", ...selectModeProps }), field.state.value === 'manual' && (_jsxs(_Fragment, { children: [_jsx(form.AppField, { name: "ph0", children: (field) => (_jsx(field.DraggableNumericInput, { label: "PH0", draggableLabel: "Change PH0 (click and drag)", draggableIntent: "success" })) }), _jsx(form.AppField, { name: "ph1", listeners: appFieldPh1Listeners, children: (field) => (_jsx(field.DraggableNumericInput, { label: "PH1", draggableLabel: "Change PH1 (click and drag)", draggableIntent: "success" })) })] }))] })) })] }));
10
10
  }
11
11
  //# sourceMappingURL=phase_correction_expanded.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"phase_correction_expanded.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/phase_correction_expanded.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,MAAM,UAAU,uBAAuB,CACrC,KAA+F;IAE/F,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,qBAAqB,EAAE,GACpD,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAChC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACrC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAEzB,OAAO,CACL,MAAC,OAAO,IAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAC,SAAS,aAClC,QAAQ,EAAE,CACT,KAAC,IAAI,CAAC,YAAY,IAAC,OAAO,EAAC,UAAU,EAAC,IAAI,EAAC,OAAO,EAAC,MAAM,EAAC,SAAS,sBAE/C,CACrB,EAED,KAAC,IAAI,CAAC,QAAQ,IAAC,IAAI,EAAC,MAAM,EAAC,SAAS,EAAE,qBAAqB,YACxD,CAAC,KAAK,EAAE,EAAE,CAAC,CACV,8BACE,KAAC,KAAK,CAAC,MAAM,IAAC,KAAK,EAAC,MAAM,EAAC,MAAM,EAAC,QAAQ,KAAK,eAAe,GAAI,EAEjE,KAAK,CAAC,KAAK,CAAC,KAAK,KAAK,QAAQ,IAAI,CACjC,8BACE,KAAC,IAAI,CAAC,QAAQ,IAAC,IAAI,EAAC,KAAK,YACtB,CAAC,KAAK,EAAE,EAAE,CAAC,CACV,KAAC,KAAK,CAAC,qBAAqB,IAC1B,KAAK,EAAC,KAAK,EACX,cAAc,EAAC,6BAA6B,EAC5C,eAAe,EAAC,SAAS,GACzB,CACH,GACa,EAEhB,KAAC,IAAI,CAAC,QAAQ,IAAC,IAAI,EAAC,KAAK,YACtB,CAAC,KAAK,EAAE,EAAE,CAAC,CACV,KAAC,KAAK,CAAC,qBAAqB,IAC1B,KAAK,EAAC,KAAK,EACX,cAAc,EAAC,6BAA6B,EAC5C,eAAe,EAAC,SAAS,GACzB,CACH,GACa,IACf,CACJ,IACA,CACJ,GACa,IACR,CACX,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"phase_correction_expanded.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/phase_correction_expanded.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,sBAAsB,EAAE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J,IACA,CACJ,GACa,IACR,CACX,CAAC;AACJ,CAAC"}
@@ -5,7 +5,7 @@ import { usePhaseCorrectionForm } from "./phase_correction.hook.js";
5
5
  export function PhaseCorrectionTopbar(props) {
6
6
  const { children, spectrum } = props;
7
7
  castSpectrum1D(spectrum);
8
- const { form, selectModeProps, appFieldModeListeners } = usePhaseCorrectionForm(props);
9
- return (_jsxs(HorizontalAppForm, { form: form, layout: "inline", children: [_jsx(form.AppField, { name: "mode", listeners: appFieldModeListeners, children: (field) => (_jsxs(_Fragment, { children: [_jsx(field.Select, { layout: "inline", ...selectModeProps }), field.state.value === 'manual' && (_jsxs(_Fragment, { children: [_jsx(form.AppField, { name: "ph0", children: (field) => (_jsx(field.DraggableNumericInput, { hideInput: true, draggableLabel: "Change PH0 (click and drag)", draggableIntent: "success" })) }), _jsx(form.AppField, { name: "ph1", children: (field) => (_jsx(field.DraggableNumericInput, { hideInput: true, draggableLabel: "Change PH1 (click and drag)", draggableIntent: "success" })) })] }))] })) }), children(_jsx(form.SubmitButton, { variant: "outlined", size: "small", intent: "success", children: "Apply" }))] }));
8
+ const { form, selectModeProps, appFieldModeListeners, appFieldPh1Listeners } = usePhaseCorrectionForm(props);
9
+ return (_jsxs(HorizontalAppForm, { form: form, layout: "inline", children: [_jsx(form.AppField, { name: "mode", listeners: appFieldModeListeners, children: (field) => (_jsxs(_Fragment, { children: [_jsx(field.Select, { layout: "inline", ...selectModeProps }), field.state.value === 'manual' && (_jsxs(_Fragment, { children: [_jsx(form.AppField, { name: "ph0", children: (field) => (_jsx(field.DraggableNumericInput, { hideInput: true, draggableLabel: "Change PH0 (click and drag)", draggableIntent: "success" })) }), _jsx(form.AppField, { name: "ph1", listeners: appFieldPh1Listeners, children: (field) => (_jsx(field.DraggableNumericInput, { hideInput: true, draggableLabel: "Change PH1 (click and drag)", draggableIntent: "success" })) })] }))] })) }), children(_jsx(form.SubmitButton, { variant: "outlined", size: "small", intent: "success", children: "Apply" }))] }));
10
10
  }
11
11
  //# sourceMappingURL=phase_correction_topbar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"phase_correction_topbar.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/phase_correction_topbar.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAkC,CAAC;AAErE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,MAAM,UAAU,qBAAqB,CACnC,KAA+F;IAE/F,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACrC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAEzB,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,qBAAqB,EAAE,GACpD,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAEhC,OAAO,CACL,MAAC,iBAAiB,IAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAC,QAAQ,aAC5C,KAAC,IAAI,CAAC,QAAQ,IAAC,IAAI,EAAC,MAAM,EAAC,SAAS,EAAE,qBAAqB,YACxD,CAAC,KAAK,EAAE,EAAE,CAAC,CACV,8BACE,KAAC,KAAK,CAAC,MAAM,IAAC,MAAM,EAAC,QAAQ,KAAK,eAAe,GAAI,EAEpD,KAAK,CAAC,KAAK,CAAC,KAAK,KAAK,QAAQ,IAAI,CACjC,8BACE,KAAC,IAAI,CAAC,QAAQ,IAAC,IAAI,EAAC,KAAK,YACtB,CAAC,KAAK,EAAE,EAAE,CAAC,CACV,KAAC,KAAK,CAAC,qBAAqB,IAC1B,SAAS,QACT,cAAc,EAAC,6BAA6B,EAC5C,eAAe,EAAC,SAAS,GACzB,CACH,GACa,EAEhB,KAAC,IAAI,CAAC,QAAQ,IAAC,IAAI,EAAC,KAAK,YACtB,CAAC,KAAK,EAAE,EAAE,CAAC,CACV,KAAC,KAAK,CAAC,qBAAqB,IAC1B,SAAS,QACT,cAAc,EAAC,6BAA6B,EAC5C,eAAe,EAAC,SAAS,GACzB,CACH,GACa,IACf,CACJ,IACA,CACJ,GACa,EAEf,QAAQ,CACP,KAAC,IAAI,CAAC,YAAY,IAAC,OAAO,EAAC,UAAU,EAAC,IAAI,EAAC,OAAO,EAAC,MAAM,EAAC,SAAS,sBAE/C,CACrB,IACiB,CACrB,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"phase_correction_topbar.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/phase_correction_topbar.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAkC,CAAC;AAErE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,MAAM,UAAU,qBAAqB,CACnC,KAA+F;IAE/F,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACrC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAEzB,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,GAC1E,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAEhC,OAAO,CACL,MAAC,iBAAiB,IAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAC,QAAQ,aAC5C,KAAC,IAAI,CAAC,QAAQ,IAAC,IAAI,EAAC,MAAM,EAAC,SAAS,EAAE,qBAAqB,YACxD,CAAC,KAAK,EAAE,EAAE,CAAC,CACV,8BACE,KAAC,KAAK,CAAC,MAAM,IAAC,MAAM,EAAC,QAAQ,KAAK,eAAe,GAAI,EAEpD,KAAK,CAAC,KAAK,CAAC,KAAK,KAAK,QAAQ,IAAI,CACjC,8BACE,KAAC,IAAI,CAAC,QAAQ,IAAC,IAAI,EAAC,KAAK,YACtB,CAAC,KAAK,EAAE,EAAE,CAAC,CACV,KAAC,KAAK,CAAC,qBAAqB,IAC1B,SAAS,QACT,cAAc,EAAC,6BAA6B,EAC5C,eAAe,EAAC,SAAS,GACzB,CACH,GACa,EAEhB,KAAC,IAAI,CAAC,QAAQ,IAAC,IAAI,EAAC,KAAK,EAAC,SAAS,EAAE,oBAAoB,YACtD,CAAC,KAAK,EAAE,EAAE,CAAC,CACV,KAAC,KAAK,CAAC,qBAAqB,IAC1B,SAAS,QACT,cAAc,EAAC,6BAA6B,EAC5C,eAAe,EAAC,SAAS,GACzB,CACH,GACa,IACf,CACJ,IACA,CACJ,GACa,EAEf,QAAQ,CACP,KAAC,IAAI,CAAC,YAAY,IAAC,OAAO,EAAC,UAAU,EAAC,IAAI,EAAC,OAAO,EAAC,MAAM,EAAC,SAAS,sBAE/C,CACrB,IACiB,CACrB,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zakodium/nmrium-core-plugins-ui",
3
- "version": "0.1.51",
3
+ "version": "0.1.53",
4
4
  "license": "CC-BY-NC-SA-4.0",
5
5
  "description": "UI related plugins needed for cheminfo/nmrium",
6
6
  "keywords": [],
@@ -29,8 +29,8 @@
29
29
  "@emotion/react": "^11.14.0",
30
30
  "@emotion/styled": "^11.14.1",
31
31
  "@tanstack/react-form": "^1.33.4",
32
- "@zakodium/nmrium-core": "^0.7.65",
33
- "@zakodium/nmrium-core-plugins": "^0.7.87",
32
+ "@zakodium/nmrium-core": "^0.7.66",
33
+ "@zakodium/nmrium-core-plugins": "^0.7.88",
34
34
  "@zakodium/utils": "^0.5.1",
35
35
  "cheminfo-font": "^1.27.0",
36
36
  "fifo-logger": "^2.0.1",
@@ -52,5 +52,5 @@
52
52
  "volta": {
53
53
  "extends": "../../../package.json"
54
54
  },
55
- "gitHead": "dbf4ebe256de67a8767921eaeb8ce1982a23fb80"
55
+ "gitHead": "e3f9894f682f35e4745e7629df511b4f099924bb"
56
56
  }
@@ -1,11 +1,15 @@
1
1
  import { revalidateLogic } from '@tanstack/react-form';
2
- import type { Spectrum1DProcessingTypeRegistry } from '@zakodium/nmr-types';
2
+ import type {
3
+ Spectrum1D,
4
+ Spectrum1DProcessingTypeRegistry,
5
+ } from '@zakodium/nmr-types';
3
6
  import type { ProcessingOperatorUISettingsFormProps } from '@zakodium/nmrium-core';
4
7
  import { castSpectrum1D } from '@zakodium/nmrium-core';
5
- import { cast } from '@zakodium/utils';
8
+ import { assert, cast } from '@zakodium/utils';
9
+ import { xFindClosestIndex, xMaxAbsoluteValue } from 'ml-spectra-processing';
6
10
  import { autoPhaseCorrection } from 'nmr-processing';
7
11
  import type { ComponentProps } from 'react';
8
- import { useEffect, useMemo } from 'react';
12
+ import { useEffect, useMemo, useRef } from 'react';
9
13
  import { useForm } from 'react-science/ui';
10
14
 
11
15
  type Mode =
@@ -106,10 +110,60 @@ export function usePhaseCorrectionForm(
106
110
  phases = autoPhaseCorrection(spectrum, { magnitudeMode: true });
107
111
  }
108
112
 
109
- form.setFieldValue('ph0', phases.ph0);
110
- form.setFieldValue('ph1', phases.ph1);
113
+ const { ph0, ph1 } = phases;
114
+
115
+ prevPh1Ref.current = ph1;
116
+ form.setFieldValue('ph0', ph0, { dontRunListeners: true });
117
+ form.setFieldValue('ph1', ph1, { dontRunListeners: true });
118
+
119
+ // reuse previous pivotIndex or compute it if missing
120
+ const formPivot = form.state.values.pivotIndex;
121
+ const pivotIndex =
122
+ typeof formPivot === 'number' ? formPivot : findStrongestPeak(spectrum);
123
+
124
+ form.setFieldValue('pivotIndex', pivotIndex, { dontRunListeners: true });
125
+
126
+ const settings = {
127
+ mode: 'manual' as const,
128
+ ph0,
129
+ ph1,
130
+ pivotIndex,
131
+ };
132
+ onChange({ ...operation, settings });
111
133
  },
112
134
  };
113
135
 
114
- return { form, selectModeProps, appFieldModeListeners };
136
+ const prevPh1Ref = useRef(
137
+ form.state.values.mode === 'manual' ? form.state.values.ph1 : 0,
138
+ );
139
+ const appFieldPh1Listeners: AppFieldProps['listeners'] = {
140
+ onChange: ({ value, fieldApi }) => {
141
+ // It is not strictly typed to `<AppField name="mode">`,
142
+ // so little safety check if the listener is attached to the right field.
143
+ // NB: `Extract<AppFieldProps, {name: 'mode'}>` returns `never`.
144
+ if (fieldApi.name !== 'ph1') return;
145
+ assert(form.state.values.mode === 'manual');
146
+
147
+ const ph1 = Number(value);
148
+ if (Number.isNaN(ph1)) return;
149
+
150
+ const diff = ph1 - prevPh1Ref.current;
151
+ const pivotIndex = form.state.values.pivotIndex ?? 0;
152
+ const length = spectrum.data.re.length;
153
+ const factor = length - pivotIndex;
154
+
155
+ const ph0 = form.state.values.ph0 - (diff * factor) / length;
156
+
157
+ prevPh1Ref.current = ph1;
158
+ form.setFieldValue('ph0', ph0);
159
+ },
160
+ };
161
+
162
+ return { form, selectModeProps, appFieldModeListeners, appFieldPh1Listeners };
163
+ }
164
+
165
+ function findStrongestPeak(spectrum: Spectrum1D) {
166
+ const re = spectrum.data.re;
167
+ const maxY = xMaxAbsoluteValue(re);
168
+ return xFindClosestIndex(re, maxY, { sorted: false });
115
169
  }
@@ -1,5 +1,7 @@
1
1
  import { defineProcessingOperatorUI } from '@zakodium/nmrium-core';
2
2
 
3
+ import { PhaseCorrectionChartBrushTracker } from './phase_correction_chart_brush_tracker.tsx';
4
+ import { PhaseCorrectionChartSvg } from './phase_correction_chart_svg.tsx';
3
5
  import { PhaseCorrectionExpanded } from './phase_correction_expanded.tsx';
4
6
  import { PhaseCorrectionTool } from './phase_correction_tool.tsx';
5
7
  import { PhaseCorrectionTopbar } from './phase_correction_topbar.tsx';
@@ -13,4 +15,6 @@ export const phaseCorrection1D = defineProcessingOperatorUI({
13
15
  defaultShouldProcessAll: false,
14
16
  Tool: PhaseCorrectionTool,
15
17
  TopBar: PhaseCorrectionTopbar,
18
+ ChartBrushTracker: PhaseCorrectionChartBrushTracker,
19
+ ChartSVG: PhaseCorrectionChartSvg,
16
20
  });
@@ -0,0 +1,28 @@
1
+ import type { ProcessingOperatorUIChartBrushTrackerProps } from '@zakodium/nmrium-core';
2
+ import { castSpectrum1D } from '@zakodium/nmrium-core';
3
+ import { xFindClosestIndex } from 'ml-spectra-processing';
4
+
5
+ export function PhaseCorrectionChartBrushTracker(
6
+ props: ProcessingOperatorUIChartBrushTrackerProps<'@zakodium/nmrium-core-plugins#phaseCorrection1D'>,
7
+ ) {
8
+ const { useBrushTrackerEvent, scaleX, onChange, operation, spectrum } = props;
9
+ castSpectrum1D(spectrum);
10
+
11
+ useBrushTrackerEvent({
12
+ onClick: (event) => {
13
+ const chartX = event.position.x;
14
+ const spectrumX = scaleX.invert(chartX);
15
+ const index = xFindClosestIndex(spectrum.data.x, spectrumX);
16
+
17
+ onChange({
18
+ ...operation,
19
+ settings: {
20
+ ...operation.settings,
21
+ pivotIndex: index,
22
+ },
23
+ });
24
+ },
25
+ });
26
+
27
+ return null;
28
+ }
@@ -0,0 +1,48 @@
1
+ import type { ProcessingOperatorUIChartSVGProps } from '@zakodium/nmrium-core';
2
+ import { castSpectrum1D } from '@zakodium/nmrium-core';
3
+
4
+ export function PhaseCorrectionChartSvg(
5
+ props: ProcessingOperatorUIChartSVGProps<'@zakodium/nmrium-core-plugins#phaseCorrection1D'>,
6
+ ) {
7
+ const { spectrum, operation, scaleX, scaleY, indicatorLineColor } = props;
8
+ castSpectrum1D(spectrum);
9
+
10
+ const { pivotIndex } = operation.settings;
11
+ if (typeof pivotIndex !== 'number') return null;
12
+
13
+ const pivotX = scaleX(spectrum.data.x[pivotIndex]);
14
+ const baselineY = scaleY(0);
15
+
16
+ return (
17
+ <>
18
+ <PivotIndicator x={pivotX} stroke={indicatorLineColor} />
19
+ <BaselineIndicator y={baselineY} stroke={indicatorLineColor} />
20
+ </>
21
+ );
22
+ }
23
+
24
+ interface PivotIndicatorProps {
25
+ x: number;
26
+ stroke: string;
27
+ }
28
+
29
+ function PivotIndicator(props: PivotIndicatorProps) {
30
+ const { x, stroke } = props;
31
+
32
+ return (
33
+ <line x1={x} x2={x} y1={0} y2="100%" strokeWidth={2} stroke={stroke} />
34
+ );
35
+ }
36
+
37
+ interface BaselineIndicatorProps {
38
+ y: number;
39
+ stroke: string;
40
+ }
41
+
42
+ function BaselineIndicator(props: BaselineIndicatorProps) {
43
+ const { y, stroke } = props;
44
+
45
+ return (
46
+ <line x1={0} x2="100%" y1={y} y2={y} strokeWidth={1} stroke={stroke} />
47
+ );
48
+ }
@@ -7,7 +7,7 @@ import { usePhaseCorrectionForm } from './phase_correction.hook.ts';
7
7
  export function PhaseCorrectionExpanded(
8
8
  props: ProcessingOperatorUISettingsFormProps<'@zakodium/nmrium-core-plugins#phaseCorrection1D'>,
9
9
  ) {
10
- const { form, selectModeProps, appFieldModeListeners } =
10
+ const { form, selectModeProps, appFieldModeListeners, appFieldPh1Listeners } =
11
11
  usePhaseCorrectionForm(props);
12
12
  const { spectrum, children } = props;
13
13
  castSpectrum1D(spectrum);
@@ -37,7 +37,7 @@ export function PhaseCorrectionExpanded(
37
37
  )}
38
38
  </form.AppField>
39
39
 
40
- <form.AppField name="ph1">
40
+ <form.AppField name="ph1" listeners={appFieldPh1Listeners}>
41
41
  {(field) => (
42
42
  <field.DraggableNumericInput
43
43
  label="PH1"
@@ -11,7 +11,7 @@ export function PhaseCorrectionTopbar(
11
11
  const { children, spectrum } = props;
12
12
  castSpectrum1D(spectrum);
13
13
 
14
- const { form, selectModeProps, appFieldModeListeners } =
14
+ const { form, selectModeProps, appFieldModeListeners, appFieldPh1Listeners } =
15
15
  usePhaseCorrectionForm(props);
16
16
 
17
17
  return (
@@ -33,7 +33,7 @@ export function PhaseCorrectionTopbar(
33
33
  )}
34
34
  </form.AppField>
35
35
 
36
- <form.AppField name="ph1">
36
+ <form.AppField name="ph1" listeners={appFieldPh1Listeners}>
37
37
  {(field) => (
38
38
  <field.DraggableNumericInput
39
39
  hideInput