@zakodium/nmrium-core-plugins-ui 0.1.25 → 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.
@@ -1 +1 @@
1
- {"version":3,"file":"phase_correction.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/phase_correction.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB,yGAO5B,CAAC"}
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;AAE1E,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;CAC/B,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,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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CAAC,CACF,CAAC;IAEF,MAAM,OAAO,GAAG,OAAO,CAAiB,GAAG,EAAE;QAC3C,OAAO;YACL;gBACE,KAAK,EAAE,GAAG;gBACV,KAAK,EAAE,kBAAkB;gBACzB,MAAM,EAAE,IAAI;gBACZ,SAAS,EAAE,gBAAgB;aAC5B;SACF,CAAC;IACJ,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAEvB,UAAU,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zakodium/nmrium-core-plugins-ui",
3
- "version": "0.1.25",
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": [],
@@ -43,5 +43,5 @@
43
43
  "typescript": "~6.0.3",
44
44
  "vitest": "^4.1.10"
45
45
  },
46
- "gitHead": "80667e0063863c55c90ac6cd4f8e3159a2aeaa04"
46
+ "gitHead": "5862adcdc11eb074b88b8303366f4ef923f36ee0"
47
47
  }
@@ -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
+ }