@zakodium/nmrium-core-plugins-ui 0.1.23 → 0.1.24

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":"apodization.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/apodization.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa,qGAOxB,CAAC"}
1
+ {"version":3,"file":"apodization.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/apodization.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,aAAa,qGAQxB,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { defineProcessingOperatorUI } from '@zakodium/nmrium-core';
2
2
  import { ApodizationExpanded } from "./apodization_expanded.js";
3
+ import { ApodizationTool } from "./apodization_tool.js";
3
4
  export const apodization1D = defineProcessingOperatorUI({
4
5
  id: '@zakodium/nmrium-core-plugins#apodization1D',
5
6
  name: 'Apodization / Window',
@@ -7,5 +8,6 @@ export const apodization1D = defineProcessingOperatorUI({
7
8
  isLiveEditable: true,
8
9
  defaultShouldProcessAll: false,
9
10
  Expanded: ApodizationExpanded,
11
+ Tool: ApodizationTool,
10
12
  });
11
13
  //# sourceMappingURL=apodization.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"apodization.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/apodization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA4B,CAAC;AAEjE,MAAM,CAAC,MAAM,aAAa,GAAG,0BAA0B,CAAC;IACtD,EAAE,EAAE,6CAA6C;IACjD,IAAI,EAAE,sBAAsB;IAC5B,UAAU,EAAE,IAAI;IAChB,cAAc,EAAE,IAAI;IACpB,uBAAuB,EAAE,KAAK;IAC9B,QAAQ,EAAE,mBAAmB;CAC9B,CAAC,CAAC"}
1
+ {"version":3,"file":"apodization.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/apodization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA4B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAwB,CAAC;AAEzD,MAAM,CAAC,MAAM,aAAa,GAAG,0BAA0B,CAAC;IACtD,EAAE,EAAE,6CAA6C;IACjD,IAAI,EAAE,sBAAsB;IAC5B,UAAU,EAAE,IAAI;IAChB,cAAc,EAAE,IAAI;IACpB,uBAAuB,EAAE,KAAK;IAC9B,QAAQ,EAAE,mBAAmB;IAC7B,IAAI,EAAE,eAAe;CACtB,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ProcessingOperatorUIToolProps } from '@zakodium/nmrium-core';
2
+ export declare function ApodizationTool(props: ProcessingOperatorUIToolProps<'@zakodium/nmrium-core-plugins#apodization1D'>): import("react").JSX.Element | null;
3
+ //# sourceMappingURL=apodization_tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apodization_tool.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/apodization_tool.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,6BAA6B,EAE9B,MAAM,uBAAuB,CAAC;AAqB/B,wBAAgB,eAAe,CAC7B,KAAK,EAAE,6BAA6B,CAAC,6CAA6C,CAAC,sCAqDpF"}
@@ -0,0 +1,45 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useHotkeys } from '@blueprintjs/core';
3
+ import { generateID, isSpectrum1DFid } from '@zakodium/nmrium-core';
4
+ import { SvgNmrApodization } from 'cheminfo-font';
5
+ import { useMemo } from 'react';
6
+ import { Toolbar, TooltipHelpContent } from 'react-science/ui';
7
+ import { useEventCallback } from 'usehooks-ts';
8
+ function defaultApodization1DOperation() {
9
+ return {
10
+ operatorId: '@zakodium/nmrium-core-plugins#apodization1D',
11
+ settings: { exponential: { apply: true, options: { lineBroadening: 1 } } },
12
+ options: undefined,
13
+ error: undefined,
14
+ uid: generateID(),
15
+ enabled: true,
16
+ };
17
+ }
18
+ const NO_SHORTCUTS = [];
19
+ export function ApodizationTool(props) {
20
+ const { spectrum, liveSpectrum, onTriggerOperation } = props;
21
+ const firstLiveProcessing = liveSpectrum?.processings?.[0]?.operatorId;
22
+ const isActive = firstLiveProcessing === '@zakodium/nmrium-core-plugins#apodization1D';
23
+ const isVisible = isSpectrum1DFid(spectrum) && spectrum.info.isComplex;
24
+ const triggerOperation = useEventCallback((event) => {
25
+ if ('stopImmediatePropagation' in event) {
26
+ // stopPropagation is not enough because
27
+ // nmrium keyboard listener is also on document
28
+ event.stopImmediatePropagation();
29
+ }
30
+ onTriggerOperation(defaultApodization1DOperation());
31
+ });
32
+ const hotkeys = useMemo(() => [
33
+ {
34
+ combo: 'A',
35
+ label: 'Apodization',
36
+ global: true,
37
+ onKeyDown: triggerOperation,
38
+ },
39
+ ], [triggerOperation]);
40
+ useHotkeys(isVisible ? hotkeys : NO_SHORTCUTS);
41
+ if (!isVisible)
42
+ return null;
43
+ return (_jsx(Toolbar.Item, { id: "@zakodium/nmrium-core-plugins#apodization1D", icon: _jsx(SvgNmrApodization, {}), tooltip: _jsx(TooltipHelpContent, { title: "Apodization / Window", shortcuts: ['a'], description: "Apply mathematical function that the FID is multiplied by before Fourier Transform.", link: "https://docs.nmrium.org/help/apodization" }), active: isActive, onClick: triggerOperation }));
44
+ }
45
+ //# sourceMappingURL=apodization_tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apodization_tool.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/apodization_tool.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAK/C,OAAO,E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AAO,GAAG,OAAO,CACrB,GAAG,EAAE,CAAC;QACJ;YACE,KAAK,EAAE,GAAG;YACV,KAAK,EAAE,aAAa;YACpB,MAAM,EAAE,IAAI;YACZ,SAAS,EAAE,gBAAgB;SAC5B;KACF,EACD,CAAC,gBAAgB,CAAC,CACnB,CAAC;IACF,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;IAE/C,IAAI,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IAE5B,OAAO,CACL,KAAC,OAAO,CAAC,IAAI,IACX,EAAE,EAAC,6CAA6C,EAChD,IAAI,EAAE,KAAC,iBAAiB,KAAG,EAC3B,OAAO,EACL,KAAC,kBAAkB,IACjB,KAAK,EAAC,sBAAsB,EAC5B,SAAS,EAAE,CAAC,GAAG,CAAC,EAChB,WAAW,EAAC,qFAAqF,EACjG,IAAI,EAAC,0CAA0C,GAC/C,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.23",
3
+ "version": "0.1.24",
4
4
  "license": "CC-BY-NC-SA-4.0",
5
5
  "description": "UI related plugins needed for cheminfo/nmrium",
6
6
  "keywords": [],
@@ -27,12 +27,13 @@
27
27
  "@blueprintjs/icons": "^6.13.0",
28
28
  "@blueprintjs/select": "^6.3.3",
29
29
  "@tanstack/react-form": "^1.33.2",
30
- "@zakodium/nmrium-core": "^0.7.49",
31
- "@zakodium/nmrium-core-plugins": "^0.7.65",
30
+ "@zakodium/nmrium-core": "^0.7.50",
31
+ "@zakodium/nmrium-core-plugins": "^0.7.66",
32
32
  "fifo-logger": "^2.0.1",
33
33
  "react": "^18.3.1",
34
34
  "react-dom": "^18.3.1",
35
35
  "react-science": "^20.6.1",
36
+ "usehooks-ts": "^3.1.1",
36
37
  "zod": "^4.4.3"
37
38
  },
38
39
  "devDependencies": {
@@ -42,5 +43,5 @@
42
43
  "typescript": "~6.0.3",
43
44
  "vitest": "^4.1.10"
44
45
  },
45
- "gitHead": "b11e2640ef3a8c479d8fa8e90dce341a767757bc"
46
+ "gitHead": "4f2c8c505e0a7a891c941540672a807da0594dd9"
46
47
  }
@@ -1,6 +1,7 @@
1
1
  import { defineProcessingOperatorUI } from '@zakodium/nmrium-core';
2
2
 
3
3
  import { ApodizationExpanded } from './apodization_expanded.tsx';
4
+ import { ApodizationTool } from './apodization_tool.tsx';
4
5
 
5
6
  export const apodization1D = defineProcessingOperatorUI({
6
7
  id: '@zakodium/nmrium-core-plugins#apodization1D',
@@ -9,4 +10,5 @@ export const apodization1D = defineProcessingOperatorUI({
9
10
  isLiveEditable: true,
10
11
  defaultShouldProcessAll: false,
11
12
  Expanded: ApodizationExpanded,
13
+ Tool: ApodizationTool,
12
14
  });
@@ -0,0 +1,81 @@
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, isSpectrum1DFid } from '@zakodium/nmrium-core';
8
+ import { SvgNmrApodization } 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 defaultApodization1DOperation(): Spectrum1DProcessingTypeRegistry['@zakodium/nmrium-core-plugins#apodization1D'] {
15
+ return {
16
+ operatorId: '@zakodium/nmrium-core-plugins#apodization1D',
17
+ settings: { exponential: { apply: true, options: { lineBroadening: 1 } } },
18
+ options: undefined,
19
+ error: undefined,
20
+ uid: generateID(),
21
+ enabled: true,
22
+ };
23
+ }
24
+
25
+ const NO_SHORTCUTS: HotkeyConfig[] = [];
26
+
27
+ export function ApodizationTool(
28
+ props: ProcessingOperatorUIToolProps<'@zakodium/nmrium-core-plugins#apodization1D'>,
29
+ ) {
30
+ const { spectrum, liveSpectrum, onTriggerOperation } = props;
31
+
32
+ const firstLiveProcessing = liveSpectrum?.processings?.[0]?.operatorId;
33
+ const isActive =
34
+ firstLiveProcessing === '@zakodium/nmrium-core-plugins#apodization1D';
35
+
36
+ const isVisible = isSpectrum1DFid(spectrum) && spectrum.info.isComplex;
37
+
38
+ const triggerOperation = useEventCallback(
39
+ (event: KeyboardEvent | MouseEvent) => {
40
+ if ('stopImmediatePropagation' in event) {
41
+ // stopPropagation is not enough because
42
+ // nmrium keyboard listener is also on document
43
+ event.stopImmediatePropagation();
44
+ }
45
+
46
+ onTriggerOperation(defaultApodization1DOperation());
47
+ },
48
+ );
49
+
50
+ const hotkeys = useMemo<HotkeyConfig[]>(
51
+ () => [
52
+ {
53
+ combo: 'A',
54
+ label: 'Apodization',
55
+ global: true,
56
+ onKeyDown: triggerOperation,
57
+ },
58
+ ],
59
+ [triggerOperation],
60
+ );
61
+ useHotkeys(isVisible ? hotkeys : NO_SHORTCUTS);
62
+
63
+ if (!isVisible) return null;
64
+
65
+ return (
66
+ <Toolbar.Item
67
+ id="@zakodium/nmrium-core-plugins#apodization1D"
68
+ icon={<SvgNmrApodization />}
69
+ tooltip={
70
+ <TooltipHelpContent
71
+ title="Apodization / Window"
72
+ shortcuts={['a']}
73
+ description="Apply mathematical function that the FID is multiplied by before Fourier Transform."
74
+ link="https://docs.nmrium.org/help/apodization"
75
+ />
76
+ }
77
+ active={isActive}
78
+ onClick={triggerOperation}
79
+ />
80
+ );
81
+ }