@zakodium/nmrium-core-plugins-ui 0.1.27 → 0.1.29

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 (62) hide show
  1. package/lib/plugins/spectrum_1d_processings_ui/operators/apodization.d.ts.map +1 -1
  2. package/lib/plugins/spectrum_1d_processings_ui/operators/apodization.hook.d.ts +400 -0
  3. package/lib/plugins/spectrum_1d_processings_ui/operators/apodization.hook.d.ts.map +1 -0
  4. package/lib/plugins/spectrum_1d_processings_ui/operators/apodization.hook.js +34 -0
  5. package/lib/plugins/spectrum_1d_processings_ui/operators/apodization.hook.js.map +1 -0
  6. package/lib/plugins/spectrum_1d_processings_ui/operators/apodization.js +2 -0
  7. package/lib/plugins/spectrum_1d_processings_ui/operators/apodization.js.map +1 -1
  8. package/lib/plugins/spectrum_1d_processings_ui/operators/apodization_expanded.d.ts +2 -2
  9. package/lib/plugins/spectrum_1d_processings_ui/operators/apodization_expanded.d.ts.map +1 -1
  10. package/lib/plugins/spectrum_1d_processings_ui/operators/apodization_expanded.js +4 -26
  11. package/lib/plugins/spectrum_1d_processings_ui/operators/apodization_expanded.js.map +1 -1
  12. package/lib/plugins/spectrum_1d_processings_ui/operators/apodization_tool.d.ts.map +1 -1
  13. package/lib/plugins/spectrum_1d_processings_ui/operators/apodization_tool.js +2 -3
  14. package/lib/plugins/spectrum_1d_processings_ui/operators/apodization_tool.js.map +1 -1
  15. package/lib/plugins/spectrum_1d_processings_ui/operators/apodization_topbar.d.ts +3 -0
  16. package/lib/plugins/spectrum_1d_processings_ui/operators/apodization_topbar.d.ts.map +1 -0
  17. package/lib/plugins/spectrum_1d_processings_ui/operators/apodization_topbar.js +33 -0
  18. package/lib/plugins/spectrum_1d_processings_ui/operators/apodization_topbar.js.map +1 -0
  19. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction.hook.d.ts +112 -0
  20. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction.hook.d.ts.map +1 -0
  21. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction.hook.js +37 -0
  22. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction.hook.js.map +1 -0
  23. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_expanded.d.ts +2 -2
  24. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_expanded.d.ts.map +1 -1
  25. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_expanded.js +4 -30
  26. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_expanded.js.map +1 -1
  27. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_tool.d.ts.map +1 -1
  28. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_tool.js +2 -3
  29. package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_tool.js.map +1 -1
  30. package/lib/plugins/spectrum_1d_processings_ui/operators/shift_x.hook.d.ts +39 -0
  31. package/lib/plugins/spectrum_1d_processings_ui/operators/shift_x.hook.d.ts.map +1 -0
  32. package/lib/plugins/spectrum_1d_processings_ui/operators/shift_x.hook.js +38 -0
  33. package/lib/plugins/spectrum_1d_processings_ui/operators/shift_x.hook.js.map +1 -0
  34. package/lib/plugins/spectrum_1d_processings_ui/operators/shift_x_expanded.d.ts +2 -2
  35. package/lib/plugins/spectrum_1d_processings_ui/operators/shift_x_expanded.d.ts.map +1 -1
  36. package/lib/plugins/spectrum_1d_processings_ui/operators/shift_x_expanded.js +4 -43
  37. package/lib/plugins/spectrum_1d_processings_ui/operators/shift_x_expanded.js.map +1 -1
  38. package/lib/plugins/spectrum_1d_processings_ui/operators/zero_filling.hook.d.ts +45 -0
  39. package/lib/plugins/spectrum_1d_processings_ui/operators/zero_filling.hook.d.ts.map +1 -0
  40. package/lib/plugins/spectrum_1d_processings_ui/operators/zero_filling.hook.js +58 -0
  41. package/lib/plugins/spectrum_1d_processings_ui/operators/zero_filling.hook.js.map +1 -0
  42. package/lib/plugins/spectrum_1d_processings_ui/operators/zero_filling_expand.d.ts +2 -2
  43. package/lib/plugins/spectrum_1d_processings_ui/operators/zero_filling_expand.d.ts.map +1 -1
  44. package/lib/plugins/spectrum_1d_processings_ui/operators/zero_filling_expand.js +5 -51
  45. package/lib/plugins/spectrum_1d_processings_ui/operators/zero_filling_expand.js.map +1 -1
  46. package/lib/plugins/spectrum_1d_processings_ui/operators/zero_filling_tool.d.ts.map +1 -1
  47. package/lib/plugins/spectrum_1d_processings_ui/operators/zero_filling_tool.js +2 -3
  48. package/lib/plugins/spectrum_1d_processings_ui/operators/zero_filling_tool.js.map +1 -1
  49. package/package.json +5 -4
  50. package/src/plugins/spectrum_1d_processings_ui/operators/apodization.hook.ts +43 -0
  51. package/src/plugins/spectrum_1d_processings_ui/operators/apodization.ts +2 -0
  52. package/src/plugins/spectrum_1d_processings_ui/operators/apodization_expanded.tsx +7 -32
  53. package/src/plugins/spectrum_1d_processings_ui/operators/apodization_tool.tsx +2 -3
  54. package/src/plugins/spectrum_1d_processings_ui/operators/apodization_topbar.tsx +64 -0
  55. package/src/plugins/spectrum_1d_processings_ui/operators/phase_correction.hook.ts +48 -0
  56. package/src/plugins/spectrum_1d_processings_ui/operators/phase_correction_expanded.tsx +7 -47
  57. package/src/plugins/spectrum_1d_processings_ui/operators/phase_correction_tool.tsx +2 -3
  58. package/src/plugins/spectrum_1d_processings_ui/operators/shift_x.hook.ts +53 -0
  59. package/src/plugins/spectrum_1d_processings_ui/operators/shift_x_expanded.tsx +7 -53
  60. package/src/plugins/spectrum_1d_processings_ui/operators/zero_filling.hook.ts +76 -0
  61. package/src/plugins/spectrum_1d_processings_ui/operators/zero_filling_expand.tsx +7 -67
  62. package/src/plugins/spectrum_1d_processings_ui/operators/zero_filling_tool.tsx +2 -3
@@ -1 +1 @@
1
- {"version":3,"file":"zero_filling_expand.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/zero_filling_expand.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,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,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,MAAM,UAAU,iBAAiB,CAC/B,KAA2F;IAE3F,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC3B,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAEpD,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IAExC,OAAO,CACL,MAAC,OAAO,IAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAC,QAAQ,aACjC,QAAQ,CACP,KAAC,YAAY,IAAC,OAAO,EAAC,UAAU,EAAC,IAAI,EAAC,OAAO,EAAC,MAAM,EAAC,SAAS,sBAE/C,CAChB,EAED,KAAC,QAAQ,IAAC,IAAI,EAAC,MAAM,YAClB,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,KAAC,MAAM,IAAC,KAAK,EAAC,MAAM,EAAC,KAAK,EAAE,OAAO,GAAI,GAC/C,IACH,CACX,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"zero_filling_tool.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/zero_filling_tool.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,6BAA6B,EAG9B,MAAM,uBAAuB,CAAC;AA6B/B,wBAAgB,eAAe,CAC7B,KAAK,EAAE,6BAA6B,CAAC,6CAA6C,CAAC,sCAoDpF"}
1
+ {"version":3,"file":"zero_filling_tool.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/zero_filling_tool.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,6BAA6B,EAG9B,MAAM,uBAAuB,CAAC;AA6B/B,wBAAgB,eAAe,CAC7B,KAAK,EAAE,6BAA6B,CAAC,6CAA6C,CAAC,sCAmDpF"}
@@ -18,9 +18,8 @@ function defaultZeroFillingOperation(spectrum) {
18
18
  };
19
19
  }
20
20
  export function ZeroFillingTool(props) {
21
- const { liveSpectrum, onTriggerOperation, spectrum } = props;
22
- const firstLiveProcessing = liveSpectrum?.processings?.[0]?.operatorId;
23
- const isActive = firstLiveProcessing === '@zakodium/nmrium-core-plugins#zeroFilling1D';
21
+ const { onTriggerOperation, spectrum, activeOperatorId } = props;
22
+ const isActive = activeOperatorId === '@zakodium/nmrium-core-plugins#zeroFilling1D';
24
23
  const isVisible = isSpectrum1DFid(spectrum) && spectrum.info.isComplex;
25
24
  const triggerOperation = useEventCallback((event) => {
26
25
  if ('stopImmediatePropagation' in event) {
@@ -1 +1 @@
1
- {"version":3,"file":"zero_filling_tool.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/zero_filling_tool.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAM/C,OAAO,EACL,cAAc,EACd,UAAU,EACV,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,SAAS,2BAA2B,CAClC,QAAkB;IAElB,cAAc,CAAC,QAAQ,CAAC,CAAC;IAEzB,MAAM,eAAe,GAAG,kBAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAEnE,OAAO;QACL,UAAU,EAAE,6CAA6C;QACzD,QAAQ,EAAE,eAAe;QACzB,OAAO,EAAE,SAAS;QAClB,KAAK,EAAE,SAAS;QAChB,GAAG,EAAE,UAAU,EAAE;QACjB,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,KAA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,EAAE,QAAQ,EAChB,OAAO,EAAE,gBAAgB,GACzB,CACH,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAc;IACxC,OAAO,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;AAChD,CAAC"}
1
+ {"version":3,"file":"zero_filling_tool.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/zero_filling_tool.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAM/C,OAAO,EACL,cAAc,EACd,UAAU,EACV,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,SAAS,2BAA2B,CAClC,QAAkB;IAElB,cAAc,CAAC,QAAQ,CAAC,CAAC;IAEzB,MAAM,eAAe,GAAG,kBAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAEnE,OAAO;QACL,UAAU,EAAE,6CAA6C;QACzD,QAAQ,EAAE,eAAe;QACzB,OAAO,EAAE,SAAS;QAClB,KAAK,EAAE,SAAS;QAChB,GAAG,EAAE,UAAU,EAAE;QACjB,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,KAAmF;IAEnF,MAAM,EAAE,kBAAkB,EAAE,QAAQ,EAAE,gBAAgB,EAAE,GAAG,KAAK,CAAC;IAEjE,MAAM,QAAQ,GACZ,gBAAgB,KAAK,6CAA6C,CAAC;IAErE,MAAM,SAAS,GAAG,eAAe,CAA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1
1
  {
2
2
  "name": "@zakodium/nmrium-core-plugins-ui",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
4
4
  "license": "CC-BY-NC-SA-4.0",
5
5
  "description": "UI related plugins needed for cheminfo/nmrium",
6
6
  "keywords": [],
@@ -26,9 +26,10 @@
26
26
  "@blueprintjs/core": "^6.17.2",
27
27
  "@blueprintjs/icons": "^6.13.0",
28
28
  "@blueprintjs/select": "^6.3.3",
29
+ "@emotion/styled": "^11.14.1",
29
30
  "@tanstack/react-form": "^1.33.2",
30
- "@zakodium/nmrium-core": "^0.7.50",
31
- "@zakodium/nmrium-core-plugins": "^0.7.67",
31
+ "@zakodium/nmrium-core": "^0.7.51",
32
+ "@zakodium/nmrium-core-plugins": "^0.7.68",
32
33
  "fifo-logger": "^2.0.1",
33
34
  "react": "^18.3.1",
34
35
  "react-dom": "^18.3.1",
@@ -43,5 +44,5 @@
43
44
  "typescript": "~6.0.3",
44
45
  "vitest": "^4.1.10"
45
46
  },
46
- "gitHead": "c18d499dbfc4de25c2bcca78a00c0dfc6c362cc6"
47
+ "gitHead": "81f8fd5aee7cd864addbe7a5dd5cfa98eb0b99c3"
47
48
  }
@@ -0,0 +1,43 @@
1
+ import { revalidateLogic } from '@tanstack/react-form';
2
+ import type { ProcessingOperatorUISettingsFormProps } from '@zakodium/nmrium-core';
3
+ import { useEffect } from 'react';
4
+ import { useForm } from 'react-science/ui';
5
+
6
+ export function useApodizationForm(
7
+ props: ProcessingOperatorUISettingsFormProps<'@zakodium/nmrium-core-plugins#apodization1D'>,
8
+ ) {
9
+ const { operation, onSubmit, onChange, core } = props;
10
+ const operator = core.getOperationOperator(
11
+ '@zakodium/nmrium-core-plugins#apodization1D',
12
+ operation,
13
+ );
14
+
15
+ const validator = operator.schemaSettings;
16
+ const defaultValues = operation.settings;
17
+ const form = useForm({
18
+ defaultValues,
19
+ validators: { onDynamic: validator },
20
+ validationLogic: revalidateLogic(),
21
+ onSubmit: ({ value }) => {
22
+ if (!onSubmit) return;
23
+
24
+ const newOperation = { ...operation, settings: validator.parse(value) };
25
+ onSubmit(newOperation);
26
+ },
27
+ listeners: {
28
+ onChange: ({ formApi }) => {
29
+ const result = validator.safeParse(formApi.state.values);
30
+ if (!result.success) return;
31
+
32
+ const liveOperation = { ...operation, settings: result.data };
33
+ onChange(liveOperation);
34
+ },
35
+ },
36
+ });
37
+
38
+ useEffect(() => {
39
+ form.reset(defaultValues, { keepDefaultValues: true });
40
+ }, [form, defaultValues]);
41
+
42
+ return form;
43
+ }
@@ -2,6 +2,7 @@ import { defineProcessingOperatorUI } from '@zakodium/nmrium-core';
2
2
 
3
3
  import { ApodizationExpanded } from './apodization_expanded.tsx';
4
4
  import { ApodizationTool } from './apodization_tool.tsx';
5
+ import { ApodizationTopBar } from './apodization_topbar.tsx';
5
6
 
6
7
  export const apodization1D = defineProcessingOperatorUI({
7
8
  id: '@zakodium/nmrium-core-plugins#apodization1D',
@@ -11,4 +12,5 @@ export const apodization1D = defineProcessingOperatorUI({
11
12
  defaultShouldProcessAll: false,
12
13
  Expanded: ApodizationExpanded,
13
14
  Tool: ApodizationTool,
15
+ TopBar: ApodizationTopBar,
14
16
  });
@@ -1,38 +1,13 @@
1
- import { revalidateLogic } from '@tanstack/react-form';
2
- import type { ProcessingOperatorUIExpandedProps } from '@zakodium/nmrium-core';
3
- import { AppForm, useForm } from 'react-science/ui';
1
+ import type { ProcessingOperatorUISettingsFormProps } from '@zakodium/nmrium-core';
2
+ import { AppForm } from 'react-science/ui';
3
+
4
+ import { useApodizationForm } from './apodization.hook.ts';
4
5
 
5
6
  export function ApodizationExpanded(
6
- props: ProcessingOperatorUIExpandedProps<'@zakodium/nmrium-core-plugins#apodization1D'>,
7
+ props: ProcessingOperatorUISettingsFormProps<'@zakodium/nmrium-core-plugins#apodization1D'>,
7
8
  ) {
8
- const { operation, onChange, onLiveChange, onMount, core, children } = props;
9
- const operator = core.getOperationOperator(
10
- '@zakodium/nmrium-core-plugins#apodization1D',
11
- operation,
12
- );
13
-
14
- const validator = operator.schemaSettings;
15
- const form = useForm({
16
- defaultValues: operation.settings,
17
- validators: { onDynamic: validator },
18
- validationLogic: revalidateLogic(),
19
- onSubmit: ({ value }) => {
20
- if (!onChange) return;
21
-
22
- const newOperation = { ...operation, settings: validator.parse(value) };
23
- onChange(newOperation);
24
- },
25
- listeners: {
26
- onMount: () => onMount(),
27
- onChange: ({ formApi }) => {
28
- const result = validator.safeParse(formApi.state.values);
29
- if (!result.success) return;
30
-
31
- const liveOperation = { ...operation, settings: result.data };
32
- onLiveChange(liveOperation);
33
- },
34
- },
35
- });
9
+ const { children } = props;
10
+ const form = useApodizationForm(props);
36
11
 
37
12
  const { AppField, SubmitButton } = form;
38
13
 
@@ -27,11 +27,10 @@ const NO_SHORTCUTS: HotkeyConfig[] = [];
27
27
  export function ApodizationTool(
28
28
  props: ProcessingOperatorUIToolProps<'@zakodium/nmrium-core-plugins#apodization1D'>,
29
29
  ) {
30
- const { spectrum, liveSpectrum, onTriggerOperation } = props;
30
+ const { spectrum, activeOperatorId, onTriggerOperation } = props;
31
31
 
32
- const firstLiveProcessing = liveSpectrum?.processings?.[0]?.operatorId;
33
32
  const isActive =
34
- firstLiveProcessing === '@zakodium/nmrium-core-plugins#apodization1D';
33
+ activeOperatorId === '@zakodium/nmrium-core-plugins#apodization1D';
35
34
 
36
35
  const isVisible = isSpectrum1DFid(spectrum) && spectrum.info.isComplex;
37
36
 
@@ -0,0 +1,64 @@
1
+ import { Classes } from '@blueprintjs/core';
2
+ import styled from '@emotion/styled';
3
+ import type { ProcessingOperatorUISettingsFormProps } from '@zakodium/nmrium-core';
4
+ import { AppForm } from 'react-science/ui';
5
+
6
+ import { useApodizationForm } from './apodization.hook.ts';
7
+
8
+ export function ApodizationTopBar(
9
+ props: ProcessingOperatorUISettingsFormProps<'@zakodium/nmrium-core-plugins#apodization1D'>,
10
+ ) {
11
+ const { children } = props;
12
+ const form = useApodizationForm(props);
13
+
14
+ const { AppField, SubmitButton, Subscribe } = form;
15
+
16
+ return (
17
+ <HorizontalAppForm form={form} layout="inline">
18
+ <Subscribe selector={(state) => state.values.exponential?.apply ?? false}>
19
+ {(apply) => (
20
+ <AppField name="exponential.options.lineBroadening">
21
+ {({ NumericInput }) => (
22
+ <NumericInput
23
+ readOnly={!apply}
24
+ disabled={!apply}
25
+ label="Line broadening"
26
+ minorStepSize={0.01}
27
+ step={0.1}
28
+ majorStepSize={1}
29
+ />
30
+ )}
31
+ </AppField>
32
+ )}
33
+ </Subscribe>
34
+
35
+ {children(
36
+ <SubmitButton variant="outlined" size="small" intent="success">
37
+ Apply
38
+ </SubmitButton>,
39
+ )}
40
+ </HorizontalAppForm>
41
+ );
42
+ }
43
+
44
+ const HorizontalAppForm = styled(AppForm)`
45
+ display: contents;
46
+
47
+ .${Classes.FORM_GROUP} {
48
+ min-height: unset;
49
+ width: unset;
50
+ display: flex;
51
+ flex-direction: row;
52
+ align-items: center;
53
+ gap: 5px;
54
+
55
+ > :not(.${Classes.LABEL}) {
56
+ min-width: unset;
57
+ width: unset;
58
+ }
59
+
60
+ .${Classes.INPUT} {
61
+ width: 5em;
62
+ }
63
+ }
64
+ `;
@@ -0,0 +1,48 @@
1
+ import { revalidateLogic } from '@tanstack/react-form';
2
+ import type { ProcessingOperatorUISettingsFormProps } from '@zakodium/nmrium-core';
3
+ import { useEffect } from 'react';
4
+ import { useForm } from 'react-science/ui';
5
+
6
+ export function usePhaseCorrectionForm(
7
+ props: ProcessingOperatorUISettingsFormProps<'@zakodium/nmrium-core-plugins#phaseCorrection1D'>,
8
+ ) {
9
+ const { operation, core, onSubmit, onChange } = props;
10
+
11
+ const { settings } = operation;
12
+ const operator = core.getOperationOperator(
13
+ '@zakodium/nmrium-core-plugins#phaseCorrection1D',
14
+ operation,
15
+ );
16
+
17
+ const { schemaSettings } = operator;
18
+ const form = useForm({
19
+ defaultValues: settings,
20
+ validators: { onDynamic: schemaSettings },
21
+ validationLogic: revalidateLogic(),
22
+ onSubmit: ({ value }) => {
23
+ if (!onSubmit) return;
24
+
25
+ const newOperation = {
26
+ ...operation,
27
+ settings: schemaSettings.parse(value),
28
+ };
29
+
30
+ onSubmit(newOperation);
31
+ },
32
+ listeners: {
33
+ onChange: ({ formApi }) => {
34
+ const result = schemaSettings.safeParse(formApi.state.values);
35
+ if (!result.success) return;
36
+
37
+ const liveOperation = { ...operation, settings: result.data };
38
+ onChange(liveOperation);
39
+ },
40
+ },
41
+ });
42
+
43
+ useEffect(() => {
44
+ form.reset(settings, { keepDefaultValues: true });
45
+ }, [form, settings]);
46
+
47
+ return form;
48
+ }
@@ -1,57 +1,17 @@
1
- import { revalidateLogic } from '@tanstack/react-form';
2
- import type { ProcessingOperatorUIExpandedProps } from '@zakodium/nmrium-core';
1
+ import type { ProcessingOperatorUISettingsFormProps } from '@zakodium/nmrium-core';
3
2
  import { castSpectrum1D } from '@zakodium/nmrium-core';
4
3
  import { autoPhaseCorrection } from 'nmr-processing';
5
- import { AppForm, useForm } from 'react-science/ui';
4
+ import { AppForm } from 'react-science/ui';
5
+
6
+ import { usePhaseCorrectionForm } from './phase_correction.hook.ts';
6
7
 
7
8
  export function PhaseCorrectionExpanded(
8
- props: ProcessingOperatorUIExpandedProps<'@zakodium/nmrium-core-plugins#phaseCorrection1D'>,
9
+ props: ProcessingOperatorUISettingsFormProps<'@zakodium/nmrium-core-plugins#phaseCorrection1D'>,
9
10
  ) {
10
- const {
11
- operation,
12
- core,
13
- children,
14
- onChange,
15
- onLiveChange,
16
- onMount,
17
- spectrum,
18
- } = props;
19
-
11
+ const form = usePhaseCorrectionForm(props);
12
+ const { spectrum, children } = props;
20
13
  castSpectrum1D(spectrum);
21
14
 
22
- const { settings } = operation;
23
- const operator = core.getOperationOperator(
24
- '@zakodium/nmrium-core-plugins#phaseCorrection1D',
25
- operation,
26
- );
27
-
28
- const { schemaSettings } = operator;
29
- const form = useForm({
30
- defaultValues: settings,
31
- validators: { onDynamic: schemaSettings },
32
- validationLogic: revalidateLogic(),
33
- onSubmit: ({ value }) => {
34
- if (!onChange) return;
35
-
36
- const newOperation = {
37
- ...operation,
38
- settings: schemaSettings.parse(value),
39
- };
40
-
41
- onChange(newOperation);
42
- },
43
- listeners: {
44
- onMount: () => onMount(),
45
- onChange: ({ formApi }) => {
46
- const result = schemaSettings.safeParse(formApi.state.values);
47
- if (!result.success) return;
48
-
49
- const liveOperation = { ...operation, settings: result.data };
50
- onLiveChange(liveOperation);
51
- },
52
- },
53
- });
54
-
55
15
  return (
56
16
  <AppForm form={form} layout="stacked">
57
17
  {children?.(
@@ -25,11 +25,10 @@ function defaultPhaseCorrectionOperation(): Spectrum1DProcessingTypeRegistry['@z
25
25
  export function PhaseCorrectionTool(
26
26
  props: ProcessingOperatorUIToolProps<'@zakodium/nmrium-core-plugins#phaseCorrection1D'>,
27
27
  ) {
28
- const { spectrum, liveSpectrum, onTriggerOperation } = props;
28
+ const { spectrum, activeOperatorId, onTriggerOperation } = props;
29
29
 
30
- const firstLiveProcessing = liveSpectrum?.processings?.[0]?.operatorId;
31
30
  const isActive =
32
- firstLiveProcessing === '@zakodium/nmrium-core-plugins#phaseCorrection1D';
31
+ activeOperatorId === '@zakodium/nmrium-core-plugins#phaseCorrection1D';
33
32
 
34
33
  const isVisible = isSpectrum1DFt(spectrum) && spectrum.info.isComplex;
35
34
 
@@ -0,0 +1,53 @@
1
+ import { revalidateLogic } from '@tanstack/react-form';
2
+ import type { ProcessingOperatorUISettingsFormProps } from '@zakodium/nmrium-core';
3
+ import { useEffect, useMemo } from 'react';
4
+ import { useForm } from 'react-science/ui';
5
+ import { z } from 'zod';
6
+
7
+ export function useShiftXForm(
8
+ props: ProcessingOperatorUISettingsFormProps<'@zakodium/nmrium-core-plugins#shiftX1D'>,
9
+ ) {
10
+ const { operation, core, onChange, onSubmit } = props;
11
+
12
+ const { settings } = operation;
13
+ const defaultValues = useMemo(() => ({ shift: settings }), [settings]);
14
+
15
+ const operator = core.getOperationOperator(
16
+ '@zakodium/nmrium-core-plugins#shiftX1D',
17
+ operation,
18
+ );
19
+ const { schemaSettings } = operator;
20
+ const validation = useMemo(
21
+ () => z.object({ shift: schemaSettings }),
22
+ [schemaSettings],
23
+ );
24
+
25
+ const form = useForm({
26
+ defaultValues,
27
+ validators: { onDynamic: validation },
28
+ validationLogic: revalidateLogic(),
29
+ onSubmit: ({ value }) => {
30
+ if (!onChange) return;
31
+
32
+ const { shift } = validation.parse(value);
33
+ const newOperation = { ...operation, settings: shift };
34
+
35
+ onSubmit(newOperation);
36
+ },
37
+ listeners: {
38
+ onChange: ({ formApi }) => {
39
+ const result = validation.safeParse(formApi.state.values);
40
+ if (!result.success) return;
41
+
42
+ const liveOperation = { ...operation, settings: result.data.shift };
43
+ onChange(liveOperation);
44
+ },
45
+ },
46
+ });
47
+
48
+ useEffect(() => {
49
+ form.reset(defaultValues, { keepDefaultValues: true });
50
+ }, [form, defaultValues]);
51
+
52
+ return form;
53
+ }
@@ -1,59 +1,13 @@
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';
1
+ import type { ProcessingOperatorUISettingsFormProps } from '@zakodium/nmrium-core';
2
+ import { AppForm } from 'react-science/ui';
3
+
4
+ import { useShiftXForm } from './shift_x.hook.ts';
6
5
 
7
6
  export function ShiftXExpanded(
8
- props: ProcessingOperatorUIExpandedProps<'@zakodium/nmrium-core-plugins#shiftX1D'>,
7
+ props: ProcessingOperatorUISettingsFormProps<'@zakodium/nmrium-core-plugins#shiftX1D'>,
9
8
  ) {
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
- });
9
+ const form = useShiftXForm(props);
10
+ const { children } = props;
57
11
 
58
12
  return (
59
13
  <AppForm form={form} layout="inline">
@@ -0,0 +1,76 @@
1
+ import { revalidateLogic } from '@tanstack/react-form';
2
+ import type { ProcessingOperatorUISettingsFormProps } from '@zakodium/nmrium-core';
3
+ import { useEffect, useMemo } from 'react';
4
+ import { useForm } from 'react-science/ui';
5
+ import { z } from 'zod';
6
+
7
+ const DEFAULT_OPTIONS = [
8
+ { label: '256', value: 2 ** 8 },
9
+ { label: '512', value: 2 ** 9 },
10
+ { label: '1K', value: 2 ** 10 },
11
+ { label: '2K', value: 2 ** 11 },
12
+ { label: '4K', value: 2 ** 12 },
13
+ { label: '8K', value: 2 ** 13 },
14
+ { label: '16K', value: 2 ** 14 },
15
+ { label: '32K', value: 2 ** 15 },
16
+ { label: '64K', value: 2 ** 16 },
17
+ { label: '128K', value: 2 ** 17 },
18
+ { label: '256K', value: 2 ** 18 },
19
+ { label: '512K', value: 2 ** 19 },
20
+ { label: '1M', value: 2 ** 20 },
21
+ { label: '2M', value: 2 ** 21 },
22
+ ];
23
+
24
+ export function useZeroFillingForm(
25
+ props: ProcessingOperatorUISettingsFormProps<'@zakodium/nmrium-core-plugins#zeroFilling1D'>,
26
+ ) {
27
+ const { operation, onSubmit, onChange, core } = props;
28
+ const operator = core.getOperationOperator(
29
+ '@zakodium/nmrium-core-plugins#zeroFilling1D',
30
+ operation,
31
+ );
32
+
33
+ const validator = useMemo(
34
+ () => z.object({ size: operator.schemaSettings }),
35
+ [operator],
36
+ );
37
+ const defaultValues = useMemo(
38
+ () => ({ size: operation.settings }),
39
+ [operation.settings],
40
+ );
41
+ const form = useForm({
42
+ defaultValues,
43
+ validators: { onDynamic: validator },
44
+ validationLogic: revalidateLogic(),
45
+ onSubmit: ({ value }) => {
46
+ const { size: settings } = validator.parse(value);
47
+ onSubmit({ ...operation, settings });
48
+ },
49
+ listeners: {
50
+ onChange: ({ formApi }) => {
51
+ const result = validator.safeParse(formApi.state.values);
52
+ if (!result.success) return;
53
+
54
+ onChange({ ...operation, settings: result.data.size });
55
+ },
56
+ },
57
+ });
58
+
59
+ useEffect(() => {
60
+ form.reset(defaultValues, { keepDefaultValues: true });
61
+ }, [form, defaultValues]);
62
+
63
+ const options = useMemo(() => {
64
+ const settings = operation.settings;
65
+ if (DEFAULT_OPTIONS.some((o) => o.value === settings)) {
66
+ return DEFAULT_OPTIONS;
67
+ }
68
+
69
+ return [
70
+ ...DEFAULT_OPTIONS,
71
+ { label: String(settings), value: settings },
72
+ ].toSorted((a, b) => a.value - b.value);
73
+ }, [operation.settings]);
74
+
75
+ return { form, options };
76
+ }
@@ -1,73 +1,13 @@
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';
1
+ import type { ProcessingOperatorUISettingsFormProps } from '@zakodium/nmrium-core';
2
+ import { AppForm } from 'react-science/ui';
6
3
 
7
- const options = [
8
- { label: '256', value: 2 ** 8 },
9
- { label: '512', value: 2 ** 9 },
10
- { label: '1K', value: 2 ** 10 },
11
- { label: '2K', value: 2 ** 11 },
12
- { label: '4K', value: 2 ** 12 },
13
- { label: '8K', value: 2 ** 13 },
14
- { label: '16K', value: 2 ** 14 },
15
- { label: '32K', value: 2 ** 15 },
16
- { label: '64K', value: 2 ** 16 },
17
- { label: '128K', value: 2 ** 17 },
18
- { label: '256K', value: 2 ** 18 },
19
- { label: '512K', value: 2 ** 19 },
20
- { label: '1M', value: 2 ** 20 },
21
- { label: '2M', value: 2 ** 21 },
22
- ];
4
+ import { useZeroFillingForm } from './zero_filling.hook.ts';
23
5
 
24
6
  export function ZeroFillingExpand(
25
- props: ProcessingOperatorUIExpandedProps<'@zakodium/nmrium-core-plugins#zeroFilling1D'>,
7
+ props: ProcessingOperatorUISettingsFormProps<'@zakodium/nmrium-core-plugins#zeroFilling1D'>,
26
8
  ) {
27
- const { operation, onChange, onLiveChange, onMount, core, children } = props;
28
- const operator = core.getOperationOperator(
29
- '@zakodium/nmrium-core-plugins#zeroFilling1D',
30
- operation,
31
- );
32
-
33
- const validator = useMemo(
34
- () =>
35
- z.object({
36
- size: operator.schemaSettings,
37
- }),
38
- [operator],
39
- );
40
- const defaultValues = useMemo(
41
- () => ({ size: operation.settings }),
42
- [operation.settings],
43
- );
44
- const form = useForm({
45
- defaultValues,
46
- validators: { onDynamic: validator },
47
- validationLogic: revalidateLogic(),
48
- onSubmit: ({ value }) => {
49
- const { size: settings } = validator.parse(value);
50
- onChange({ ...operation, settings });
51
- },
52
- listeners: {
53
- onMount: () => onMount(),
54
- onChange: ({ formApi }) => {
55
- const result = validator.safeParse(formApi.state.values);
56
- if (!result.success) return;
57
-
58
- onLiveChange({ ...operation, settings: result.data.size });
59
- },
60
- },
61
- });
62
-
63
- const allOptions = useMemo(() => {
64
- const settings = operation.settings;
65
- if (options.some((o) => o.value === settings)) return options;
66
-
67
- return [...options, { label: String(settings), value: settings }].toSorted(
68
- (a, b) => a.value - b.value,
69
- );
70
- }, [operation.settings]);
9
+ const { children } = props;
10
+ const { form, options } = useZeroFillingForm(props);
71
11
 
72
12
  const { AppField, SubmitButton } = form;
73
13
 
@@ -80,7 +20,7 @@ export function ZeroFillingExpand(
80
20
  )}
81
21
 
82
22
  <AppField name="size">
83
- {({ Select }) => <Select label="Size" items={allOptions} />}
23
+ {({ Select }) => <Select label="Size" items={options} />}
84
24
  </AppField>
85
25
  </AppForm>
86
26
  );