@zakodium/nmrium-core-plugins-ui 0.1.24 → 0.1.26
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.
- package/lib/plugins/spectrum_1d_processings_ui/operators/index.js.map +1 -1
- package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction.d.ts.map +1 -1
- package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction.js +2 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction.js.map +1 -1
- package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_tool.d.ts +3 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_tool.d.ts.map +1 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_tool.js +46 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_tool.js.map +1 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/shift_x.d.ts.map +1 -1
- package/lib/plugins/spectrum_1d_processings_ui/operators/shift_x.js +4 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/shift_x.js.map +1 -1
- package/lib/plugins/spectrum_1d_processings_ui/operators/shift_x_expanded.d.ts +3 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/shift_x_expanded.d.ts.map +1 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/shift_x_expanded.js +48 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/shift_x_expanded.js.map +1 -0
- package/package.json +3 -3
- package/src/plugins/spectrum_1d_processings_ui/operators/index.ts +1 -1
- package/src/plugins/spectrum_1d_processings_ui/operators/phase_correction.ts +2 -0
- package/src/plugins/spectrum_1d_processings_ui/operators/phase_correction_tool.tsx +78 -0
- package/src/plugins/spectrum_1d_processings_ui/operators/{shift_x.tsx → shift_x.ts} +5 -0
- package/src/plugins/spectrum_1d_processings_ui/operators/shift_x_expanded.tsx +71 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAsB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAW,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAsB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAW,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAoB,CAAC;AAEnD,MAAM,CAAC,MAAM,WAAW,GAAqC;IAC3D,eAAe;IACf,aAAa;IACb,aAAa;IACb,KAAK;IACL,QAAQ;IACR,iBAAiB;CAClB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phase_correction.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/phase_correction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"phase_correction.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/phase_correction.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,iBAAiB,yGAQ5B,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineProcessingOperatorUI } from '@zakodium/nmrium-core';
|
|
2
2
|
import { PhaseCorrectionExpanded } from "./phase_correction_expanded.js";
|
|
3
|
+
import { PhaseCorrectionTool } from "./phase_correction_tool.js";
|
|
3
4
|
export const phaseCorrection1D = defineProcessingOperatorUI({
|
|
4
5
|
id: '@zakodium/nmrium-core-plugins#phaseCorrection1D',
|
|
5
6
|
name: 'Phase correction',
|
|
@@ -7,5 +8,6 @@ export const phaseCorrection1D = defineProcessingOperatorUI({
|
|
|
7
8
|
isLiveEditable: true,
|
|
8
9
|
Expanded: PhaseCorrectionExpanded,
|
|
9
10
|
defaultShouldProcessAll: false,
|
|
11
|
+
Tool: PhaseCorrectionTool,
|
|
10
12
|
});
|
|
11
13
|
//# 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;
|
|
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;AAElE,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;CAC1B,CAAC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ProcessingOperatorUIToolProps } from '@zakodium/nmrium-core';
|
|
2
|
+
export declare function PhaseCorrectionTool(props: ProcessingOperatorUIToolProps<'@zakodium/nmrium-core-plugins#phaseCorrection1D'>): import("react").JSX.Element | null;
|
|
3
|
+
//# sourceMappingURL=phase_correction_tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phase_correction_tool.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/phase_correction_tool.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,6BAA6B,EAE9B,MAAM,uBAAuB,CAAC;AAmB/B,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,6BAA6B,CAAC,iDAAiD,CAAC,sCAoDxF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useHotkeys } from '@blueprintjs/core';
|
|
3
|
+
import { generateID, isSpectrum1DFt } from '@zakodium/nmrium-core';
|
|
4
|
+
import { SvgNmrPhaseCorrection } from 'cheminfo-font';
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
import { Toolbar, TooltipHelpContent } from 'react-science/ui';
|
|
7
|
+
import { useEventCallback } from 'usehooks-ts';
|
|
8
|
+
function defaultPhaseCorrectionOperation() {
|
|
9
|
+
return {
|
|
10
|
+
operatorId: '@zakodium/nmrium-core-plugins#phaseCorrection1D',
|
|
11
|
+
settings: { mode: 'automatic' },
|
|
12
|
+
options: undefined,
|
|
13
|
+
error: undefined,
|
|
14
|
+
uid: generateID(),
|
|
15
|
+
enabled: true,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function PhaseCorrectionTool(props) {
|
|
19
|
+
const { spectrum, liveSpectrum, onTriggerOperation } = props;
|
|
20
|
+
const firstLiveProcessing = liveSpectrum?.processings?.[0]?.operatorId;
|
|
21
|
+
const isActive = firstLiveProcessing === '@zakodium/nmrium-core-plugins#phaseCorrection1D';
|
|
22
|
+
const isVisible = isSpectrum1DFt(spectrum) && spectrum.info.isComplex;
|
|
23
|
+
const triggerOperation = useEventCallback((event) => {
|
|
24
|
+
if ('stopImmediatePropagation' in event) {
|
|
25
|
+
// stopPropagation is not enough because
|
|
26
|
+
// nmrium keyboard listener is also on document
|
|
27
|
+
event.stopImmediatePropagation();
|
|
28
|
+
}
|
|
29
|
+
onTriggerOperation(defaultPhaseCorrectionOperation());
|
|
30
|
+
});
|
|
31
|
+
const hotkeys = useMemo(() => {
|
|
32
|
+
return [
|
|
33
|
+
{
|
|
34
|
+
combo: 'a',
|
|
35
|
+
label: 'Phase correction',
|
|
36
|
+
global: true,
|
|
37
|
+
onKeyDown: triggerOperation,
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
}, [triggerOperation]);
|
|
41
|
+
useHotkeys(isVisible ? hotkeys : []);
|
|
42
|
+
if (!isVisible)
|
|
43
|
+
return null;
|
|
44
|
+
return (_jsx(Toolbar.Item, { id: "@zakodium/nmrium-core-plugins#phaseCorrection1D", icon: _jsx(SvgNmrPhaseCorrection, {}), tooltip: _jsx(TooltipHelpContent, { title: "Phase correction", shortcuts: ['a'], description: "Correct the spectrum phase manually or automatically. For manual phase correction, define the pivot click, then press the PH0 and PH1 button, and move the mouse horizontally.", link: "https://docs.nmrium.org/help/phase/" }), active: isActive, onClick: triggerOperation }));
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=phase_correction_tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phase_correction_tool.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/phase_correction_tool.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAK/C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,OAAO,EAAE,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AU,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACrC,IAAI,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IAE5B,OAAO,CACL,KAAC,OAAO,CAAC,IAAI,IACX,EAAE,EAAC,iDAAiD,EACpD,IAAI,EAAE,KAAC,qBAAqB,KAAG,EAC/B,OAAO,EACL,KAAC,kBAAkB,IACjB,KAAK,EAAC,kBAAkB,EACxB,SAAS,EAAE,CAAC,GAAG,CAAC,EAChB,WAAW,EAAC,gLAAgL,EAC5L,IAAI,EAAC,qCAAqC,GAC1C,EAEJ,MAAM,EAAE,QAAQ,EAChB,OAAO,EAAE,gBAAgB,GACzB,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shift_x.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/shift_x.
|
|
1
|
+
{"version":3,"file":"shift_x.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/shift_x.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,QAAQ,gGAMnB,CAAC"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { defineProcessingOperatorUI } from '@zakodium/nmrium-core';
|
|
2
|
+
import { ShiftXExpanded } from "./shift_x_expanded.js";
|
|
2
3
|
export const shiftX1D = defineProcessingOperatorUI({
|
|
3
4
|
id: '@zakodium/nmrium-core-plugins#shiftX1D',
|
|
4
5
|
name: 'Shift x',
|
|
6
|
+
Expanded: ShiftXExpanded,
|
|
7
|
+
isEditable: true,
|
|
8
|
+
isLiveEditable: true,
|
|
5
9
|
});
|
|
6
10
|
//# sourceMappingURL=shift_x.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shift_x.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/shift_x.
|
|
1
|
+
{"version":3,"file":"shift_x.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/shift_x.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAwB,CAAC;AAExD,MAAM,CAAC,MAAM,QAAQ,GAAG,0BAA0B,CAAC;IACjD,EAAE,EAAE,wCAAwC;IAC5C,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE,cAAc;IACxB,UAAU,EAAE,IAAI;IAChB,cAAc,EAAE,IAAI;CACrB,CAAC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ProcessingOperatorUIExpandedProps } from '@zakodium/nmrium-core';
|
|
2
|
+
export declare function ShiftXExpanded(props: ProcessingOperatorUIExpandedProps<'@zakodium/nmrium-core-plugins#shiftX1D'>): import("react").JSX.Element;
|
|
3
|
+
//# sourceMappingURL=shift_x_expanded.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shift_x_expanded.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/shift_x_expanded.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,uBAAuB,CAAC;AAK/E,wBAAgB,cAAc,CAC5B,KAAK,EAAE,iCAAiC,CAAC,wCAAwC,CAAC,+BA+DnF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { revalidateLogic } from '@tanstack/react-form';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { AppForm, useForm } from 'react-science/ui';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
export function ShiftXExpanded(props) {
|
|
7
|
+
const { operation, core, children, onChange, onLiveChange, onMount } = props;
|
|
8
|
+
const { settings } = operation;
|
|
9
|
+
const operator = core.getOperationOperator('@zakodium/nmrium-core-plugins#shiftX1D', operation);
|
|
10
|
+
const defaultValues = useMemo(() => {
|
|
11
|
+
return {
|
|
12
|
+
shift: settings,
|
|
13
|
+
};
|
|
14
|
+
}, [settings]);
|
|
15
|
+
const { schemaSettings } = operator;
|
|
16
|
+
const validation = useMemo(() => {
|
|
17
|
+
return z.object({
|
|
18
|
+
shift: schemaSettings,
|
|
19
|
+
});
|
|
20
|
+
}, [schemaSettings]);
|
|
21
|
+
const form = useForm({
|
|
22
|
+
defaultValues,
|
|
23
|
+
validators: { onDynamic: validation },
|
|
24
|
+
validationLogic: revalidateLogic(),
|
|
25
|
+
onSubmit: ({ value }) => {
|
|
26
|
+
if (!onChange)
|
|
27
|
+
return;
|
|
28
|
+
const { shift } = validation.parse(value);
|
|
29
|
+
const newOperation = {
|
|
30
|
+
...operation,
|
|
31
|
+
settings: shift,
|
|
32
|
+
};
|
|
33
|
+
onChange(newOperation);
|
|
34
|
+
},
|
|
35
|
+
listeners: {
|
|
36
|
+
onMount: () => onMount(),
|
|
37
|
+
onChange: ({ formApi }) => {
|
|
38
|
+
const result = validation.safeParse(formApi.state.values);
|
|
39
|
+
if (!result.success)
|
|
40
|
+
return;
|
|
41
|
+
const liveOperation = { ...operation, settings: result.data.shift };
|
|
42
|
+
onLiveChange(liveOperation);
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
return (_jsxs(AppForm, { form: form, layout: "inline", children: [children?.(_jsx(form.SubmitButton, { variant: "outlined", size: "small", intent: "success", children: "Apply" })), _jsx(form.AppField, { name: "shift", children: (field) => _jsx(field.NumericInput, { label: "Shift" }) })] }));
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=shift_x_expanded.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shift_x_expanded.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/shift_x_expanded.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe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,CAAC,YAAY,CAAC,CAAC;QACzB,CAAC;QACD,SAAS,EAAE;YACT,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE;YACxB,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;gBACxB,MAAM,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;gBAC1D,IAAI,CAAC,MAAM,CAAC,OAAO;oBAAE,OAAO;gBAE5B,MAAM,aAAa,GAAG,EAAE,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;gBACpE,YAAY,CAAC,aAAa,CAAC,CAAC;YAC9B,CAAC;SACF;KACF,CAAC,CAAC;IAEH,OAAO,CACL,MAAC,OAAO,IAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAC,QAAQ,aACjC,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,OAAO,YACxB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAC,KAAK,CAAC,YAAY,IAAC,KAAK,EAAC,OAAO,GAAG,GAClC,IACR,CACX,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.
|
|
3
|
+
"version": "0.1.26",
|
|
4
4
|
"license": "CC-BY-NC-SA-4.0",
|
|
5
5
|
"description": "UI related plugins needed for cheminfo/nmrium",
|
|
6
6
|
"keywords": [],
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@blueprintjs/select": "^6.3.3",
|
|
29
29
|
"@tanstack/react-form": "^1.33.2",
|
|
30
30
|
"@zakodium/nmrium-core": "^0.7.50",
|
|
31
|
-
"@zakodium/nmrium-core-plugins": "^0.7.
|
|
31
|
+
"@zakodium/nmrium-core-plugins": "^0.7.67",
|
|
32
32
|
"fifo-logger": "^2.0.1",
|
|
33
33
|
"react": "^18.3.1",
|
|
34
34
|
"react-dom": "^18.3.1",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"typescript": "~6.0.3",
|
|
44
44
|
"vitest": "^4.1.10"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "5862adcdc11eb074b88b8303366f4ef923f36ee0"
|
|
47
47
|
}
|
|
@@ -4,7 +4,7 @@ import { apodization1D } from './apodization.ts';
|
|
|
4
4
|
import { digitalFilter1D } from './digital_filter.tsx';
|
|
5
5
|
import { fft1D } from './fft.tsx';
|
|
6
6
|
import { phaseCorrection1D } from './phase_correction.ts';
|
|
7
|
-
import { shiftX1D } from './shift_x.
|
|
7
|
+
import { shiftX1D } from './shift_x.ts';
|
|
8
8
|
import { zeroFilling1D } from './zero_filling.tsx';
|
|
9
9
|
|
|
10
10
|
export const operatorsUI: Array<ProcessingOperatorUI<any>> = [
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineProcessingOperatorUI } from '@zakodium/nmrium-core';
|
|
2
2
|
|
|
3
3
|
import { PhaseCorrectionExpanded } from './phase_correction_expanded.tsx';
|
|
4
|
+
import { PhaseCorrectionTool } from './phase_correction_tool.tsx';
|
|
4
5
|
|
|
5
6
|
export const phaseCorrection1D = defineProcessingOperatorUI({
|
|
6
7
|
id: '@zakodium/nmrium-core-plugins#phaseCorrection1D',
|
|
@@ -9,4 +10,5 @@ export const phaseCorrection1D = defineProcessingOperatorUI({
|
|
|
9
10
|
isLiveEditable: true,
|
|
10
11
|
Expanded: PhaseCorrectionExpanded,
|
|
11
12
|
defaultShouldProcessAll: false,
|
|
13
|
+
Tool: PhaseCorrectionTool,
|
|
12
14
|
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { HotkeyConfig } from '@blueprintjs/core';
|
|
2
|
+
import { useHotkeys } from '@blueprintjs/core';
|
|
3
|
+
import type {
|
|
4
|
+
ProcessingOperatorUIToolProps,
|
|
5
|
+
Spectrum1DProcessingTypeRegistry,
|
|
6
|
+
} from '@zakodium/nmrium-core';
|
|
7
|
+
import { generateID, isSpectrum1DFt } from '@zakodium/nmrium-core';
|
|
8
|
+
import { SvgNmrPhaseCorrection } from 'cheminfo-font';
|
|
9
|
+
import type { MouseEvent } from 'react';
|
|
10
|
+
import { useMemo } from 'react';
|
|
11
|
+
import { Toolbar, TooltipHelpContent } from 'react-science/ui';
|
|
12
|
+
import { useEventCallback } from 'usehooks-ts';
|
|
13
|
+
|
|
14
|
+
function defaultPhaseCorrectionOperation(): Spectrum1DProcessingTypeRegistry['@zakodium/nmrium-core-plugins#phaseCorrection1D'] {
|
|
15
|
+
return {
|
|
16
|
+
operatorId: '@zakodium/nmrium-core-plugins#phaseCorrection1D',
|
|
17
|
+
settings: { mode: 'automatic' },
|
|
18
|
+
options: undefined,
|
|
19
|
+
error: undefined,
|
|
20
|
+
uid: generateID(),
|
|
21
|
+
enabled: true,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function PhaseCorrectionTool(
|
|
26
|
+
props: ProcessingOperatorUIToolProps<'@zakodium/nmrium-core-plugins#phaseCorrection1D'>,
|
|
27
|
+
) {
|
|
28
|
+
const { spectrum, liveSpectrum, onTriggerOperation } = props;
|
|
29
|
+
|
|
30
|
+
const firstLiveProcessing = liveSpectrum?.processings?.[0]?.operatorId;
|
|
31
|
+
const isActive =
|
|
32
|
+
firstLiveProcessing === '@zakodium/nmrium-core-plugins#phaseCorrection1D';
|
|
33
|
+
|
|
34
|
+
const isVisible = isSpectrum1DFt(spectrum) && spectrum.info.isComplex;
|
|
35
|
+
|
|
36
|
+
const triggerOperation = useEventCallback(
|
|
37
|
+
(event: KeyboardEvent | MouseEvent) => {
|
|
38
|
+
if ('stopImmediatePropagation' in event) {
|
|
39
|
+
// stopPropagation is not enough because
|
|
40
|
+
// nmrium keyboard listener is also on document
|
|
41
|
+
event.stopImmediatePropagation();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
onTriggerOperation(defaultPhaseCorrectionOperation());
|
|
45
|
+
},
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const hotkeys = useMemo<HotkeyConfig[]>(() => {
|
|
49
|
+
return [
|
|
50
|
+
{
|
|
51
|
+
combo: 'a',
|
|
52
|
+
label: 'Phase correction',
|
|
53
|
+
global: true,
|
|
54
|
+
onKeyDown: triggerOperation,
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
}, [triggerOperation]);
|
|
58
|
+
|
|
59
|
+
useHotkeys(isVisible ? hotkeys : []);
|
|
60
|
+
if (!isVisible) return null;
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<Toolbar.Item
|
|
64
|
+
id="@zakodium/nmrium-core-plugins#phaseCorrection1D"
|
|
65
|
+
icon={<SvgNmrPhaseCorrection />}
|
|
66
|
+
tooltip={
|
|
67
|
+
<TooltipHelpContent
|
|
68
|
+
title="Phase correction"
|
|
69
|
+
shortcuts={['a']}
|
|
70
|
+
description="Correct the spectrum phase manually or automatically. For manual phase correction, define the pivot click, then press the PH0 and PH1 button, and move the mouse horizontally."
|
|
71
|
+
link="https://docs.nmrium.org/help/phase/"
|
|
72
|
+
/>
|
|
73
|
+
}
|
|
74
|
+
active={isActive}
|
|
75
|
+
onClick={triggerOperation}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { defineProcessingOperatorUI } from '@zakodium/nmrium-core';
|
|
2
2
|
|
|
3
|
+
import { ShiftXExpanded } from './shift_x_expanded.tsx';
|
|
4
|
+
|
|
3
5
|
export const shiftX1D = defineProcessingOperatorUI({
|
|
4
6
|
id: '@zakodium/nmrium-core-plugins#shiftX1D',
|
|
5
7
|
name: 'Shift x',
|
|
8
|
+
Expanded: ShiftXExpanded,
|
|
9
|
+
isEditable: true,
|
|
10
|
+
isLiveEditable: true,
|
|
6
11
|
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { revalidateLogic } from '@tanstack/react-form';
|
|
2
|
+
import type { ProcessingOperatorUIExpandedProps } from '@zakodium/nmrium-core';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { AppForm, useForm } from 'react-science/ui';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
|
|
7
|
+
export function ShiftXExpanded(
|
|
8
|
+
props: ProcessingOperatorUIExpandedProps<'@zakodium/nmrium-core-plugins#shiftX1D'>,
|
|
9
|
+
) {
|
|
10
|
+
const { operation, core, children, onChange, onLiveChange, onMount } = props;
|
|
11
|
+
|
|
12
|
+
const { settings } = operation;
|
|
13
|
+
const operator = core.getOperationOperator(
|
|
14
|
+
'@zakodium/nmrium-core-plugins#shiftX1D',
|
|
15
|
+
operation,
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const defaultValues = useMemo(() => {
|
|
19
|
+
return {
|
|
20
|
+
shift: settings,
|
|
21
|
+
};
|
|
22
|
+
}, [settings]);
|
|
23
|
+
|
|
24
|
+
const { schemaSettings } = operator;
|
|
25
|
+
const validation = useMemo(() => {
|
|
26
|
+
return z.object({
|
|
27
|
+
shift: schemaSettings,
|
|
28
|
+
});
|
|
29
|
+
}, [schemaSettings]);
|
|
30
|
+
|
|
31
|
+
const form = useForm({
|
|
32
|
+
defaultValues,
|
|
33
|
+
validators: { onDynamic: validation },
|
|
34
|
+
validationLogic: revalidateLogic(),
|
|
35
|
+
onSubmit: ({ value }) => {
|
|
36
|
+
if (!onChange) return;
|
|
37
|
+
|
|
38
|
+
const { shift } = validation.parse(value);
|
|
39
|
+
const newOperation = {
|
|
40
|
+
...operation,
|
|
41
|
+
settings: shift,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
onChange(newOperation);
|
|
45
|
+
},
|
|
46
|
+
listeners: {
|
|
47
|
+
onMount: () => onMount(),
|
|
48
|
+
onChange: ({ formApi }) => {
|
|
49
|
+
const result = validation.safeParse(formApi.state.values);
|
|
50
|
+
if (!result.success) return;
|
|
51
|
+
|
|
52
|
+
const liveOperation = { ...operation, settings: result.data.shift };
|
|
53
|
+
onLiveChange(liveOperation);
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<AppForm form={form} layout="inline">
|
|
60
|
+
{children?.(
|
|
61
|
+
<form.SubmitButton variant="outlined" size="small" intent="success">
|
|
62
|
+
Apply
|
|
63
|
+
</form.SubmitButton>,
|
|
64
|
+
)}
|
|
65
|
+
|
|
66
|
+
<form.AppField name="shift">
|
|
67
|
+
{(field) => <field.NumericInput label="Shift" />}
|
|
68
|
+
</form.AppField>
|
|
69
|
+
</AppForm>
|
|
70
|
+
);
|
|
71
|
+
}
|