@zakodium/nmrium-core-plugins-ui 0.1.28 → 0.1.30
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/fft.d.ts.map +1 -1
- package/lib/plugins/spectrum_1d_processings_ui/operators/fft.js +2 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/fft.js.map +1 -1
- package/lib/plugins/spectrum_1d_processings_ui/operators/fft_tool.d.ts +3 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/fft_tool.d.ts.map +1 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/fft_tool.js +45 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/fft_tool.js.map +1 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction.hook.d.ts +112 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction.hook.d.ts.map +1 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction.hook.js +37 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction.hook.js.map +1 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_expanded.d.ts.map +1 -1
- package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_expanded.js +4 -29
- package/lib/plugins/spectrum_1d_processings_ui/operators/phase_correction_expanded.js.map +1 -1
- package/lib/plugins/spectrum_1d_processings_ui/operators/shift_x.hook.d.ts +39 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/shift_x.hook.d.ts.map +1 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/shift_x.hook.js +38 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/shift_x.hook.js.map +1 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/shift_x_expanded.d.ts.map +1 -1
- package/lib/plugins/spectrum_1d_processings_ui/operators/shift_x_expanded.js +4 -42
- package/lib/plugins/spectrum_1d_processings_ui/operators/shift_x_expanded.js.map +1 -1
- package/lib/plugins/spectrum_1d_processings_ui/operators/zero_filling.hook.d.ts +45 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/zero_filling.hook.d.ts.map +1 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/zero_filling.hook.js +58 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/zero_filling.hook.js.map +1 -0
- package/lib/plugins/spectrum_1d_processings_ui/operators/zero_filling_expand.d.ts.map +1 -1
- package/lib/plugins/spectrum_1d_processings_ui/operators/zero_filling_expand.js +5 -50
- package/lib/plugins/spectrum_1d_processings_ui/operators/zero_filling_expand.js.map +1 -1
- package/package.json +2 -2
- package/src/plugins/spectrum_1d_processings_ui/operators/fft.tsx +3 -0
- package/src/plugins/spectrum_1d_processings_ui/operators/fft_tool.tsx +75 -0
- package/src/plugins/spectrum_1d_processings_ui/operators/phase_correction.hook.ts +48 -0
- package/src/plugins/spectrum_1d_processings_ui/operators/phase_correction_expanded.tsx +5 -36
- package/src/plugins/spectrum_1d_processings_ui/operators/shift_x.hook.ts +53 -0
- package/src/plugins/spectrum_1d_processings_ui/operators/shift_x_expanded.tsx +5 -50
- package/src/plugins/spectrum_1d_processings_ui/operators/zero_filling.hook.ts +76 -0
- package/src/plugins/spectrum_1d_processings_ui/operators/zero_filling_expand.tsx +5 -64
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fft.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/fft.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fft.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/fft.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,KAAK,6FAIhB,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { defineProcessingOperatorUI } from '@zakodium/nmrium-core';
|
|
2
|
+
import { FFTTool } from "./fft_tool.js";
|
|
2
3
|
export const fft1D = defineProcessingOperatorUI({
|
|
3
4
|
id: '@zakodium/nmrium-core-plugins#fft1D',
|
|
4
5
|
name: 'FFT',
|
|
6
|
+
Tool: FFTTool,
|
|
5
7
|
});
|
|
6
8
|
//# sourceMappingURL=fft.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fft.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/fft.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,CAAC,MAAM,KAAK,GAAG,0BAA0B,CAAC;IAC9C,EAAE,EAAE,qCAAqC;IACzC,IAAI,EAAE,KAAK;
|
|
1
|
+
{"version":3,"file":"fft.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/fft.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAgB,CAAC;AAEzC,MAAM,CAAC,MAAM,KAAK,GAAG,0BAA0B,CAAC;IAC9C,EAAE,EAAE,qCAAqC;IACzC,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,OAAO;CACd,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fft_tool.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/fft_tool.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,6BAA6B,EAE9B,MAAM,uBAAuB,CAAC;AAmB/B,wBAAgB,OAAO,CACrB,KAAK,EAAE,6BAA6B,CAAC,qCAAqC,CAAC,sCAiD5E"}
|
|
@@ -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 { SvgNmrFourierTransform } from 'cheminfo-font';
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
import { Toolbar, TooltipHelpContent } from 'react-science/ui';
|
|
7
|
+
import { useEventCallback } from 'usehooks-ts';
|
|
8
|
+
function defaultFFTOperation() {
|
|
9
|
+
return {
|
|
10
|
+
operatorId: '@zakodium/nmrium-core-plugins#fft1D',
|
|
11
|
+
settings: null,
|
|
12
|
+
options: undefined,
|
|
13
|
+
error: undefined,
|
|
14
|
+
uid: generateID(),
|
|
15
|
+
enabled: true,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function FFTTool(props) {
|
|
19
|
+
const { spectrum, activeOperatorId, onTriggerOperation } = props;
|
|
20
|
+
const isActive = activeOperatorId === '@zakodium/nmrium-core-plugins#fft1D';
|
|
21
|
+
const isVisible = isSpectrum1DFid(spectrum) && spectrum.info.isComplex;
|
|
22
|
+
const triggerOperation = useEventCallback((event) => {
|
|
23
|
+
if ('stopImmediatePropagation' in event) {
|
|
24
|
+
// stopPropagation is not enough because
|
|
25
|
+
// nmrium keyboard listener is also on document
|
|
26
|
+
event.stopImmediatePropagation();
|
|
27
|
+
}
|
|
28
|
+
onTriggerOperation(defaultFFTOperation());
|
|
29
|
+
});
|
|
30
|
+
const hotkeys = useMemo(() => {
|
|
31
|
+
return [
|
|
32
|
+
{
|
|
33
|
+
combo: 't',
|
|
34
|
+
label: 'Fourier Transform',
|
|
35
|
+
global: true,
|
|
36
|
+
onKeyDown: triggerOperation,
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
}, [triggerOperation]);
|
|
40
|
+
useHotkeys(isVisible ? hotkeys : []);
|
|
41
|
+
if (!isVisible)
|
|
42
|
+
return null;
|
|
43
|
+
return (_jsx(Toolbar.Item, { id: "@zakodium/nmrium-core-plugins#fft1D", icon: _jsx(SvgNmrFourierTransform, {}), tooltip: _jsx(TooltipHelpContent, { title: "Fourier transform", shortcuts: ['t'], description: "Perform a Fourier transform on the FID.", link: "https://docs.nmrium.org/help/ft/" }), active: isActive, onClick: triggerOperation }));
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=fft_tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fft_tool.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/fft_tool.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAK/C,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAEvD,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,mBAAmB;IAC1B,OAAO;QACL,UAAU,EAAE,qCAAqC;QACjD,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,SAAS;QAClB,KAAK,EAAE,SAAS;QAChB,GAAG,EAAE,UAAU,EAAE;QACjB,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,OAAO,CACrB,KAA2E;IAE3E,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,GAAG,KAAK,CAAC;IAEjE,MAAM,QAAQ,GAAG,gBAAgB,KAAK,qCAAqC,CAAC;IAC5E,MAAM,SAAS,GAAG,eAAe,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC;IAEvE,MAAM,gBAAgB,GAAG,gBAAgB,CACvC,CAAC,KAAiC,EAAE,EAAE;QACpC,IAAI,0BAA0B,IAAI,KAAK,EAAE,CAAC;YACxC,wCAAwC;YACxC,+CAA+C;YAC/C,KAAK,CAAC,wBAAwB,EAAE,CAAC;QACnC,CAAC;QAED,kBAAkB,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAC5C,CAAC,CACF,CAAC;IAEF,MAAM,OAAO,GAAG,OAAO,CAAiB,GAAG,EAAE;QAC3C,OAAO;YACL;gBACE,KAAK,EAAE,GAAG;gBACV,KAAK,EAAE,mBAAmB;gBAC1B,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,qCAAqC,EACxC,IAAI,EAAE,KAAC,sBAAsB,KAAG,EAChC,OAAO,EACL,KAAC,kBAAkB,IACjB,KAAK,EAAC,mBAAmB,EACzB,SAAS,EAAE,CAAC,GAAG,CAAC,EAChB,WAAW,EAAC,yCAAyC,EACrD,IAAI,EAAC,kCAAkC,GACvC,EAEJ,MAAM,EAAE,QAAQ,EAChB,OAAO,EAAE,gBAAgB,GACzB,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { ProcessingOperatorUISettingsFormProps } from '@zakodium/nmrium-core';
|
|
2
|
+
export declare function usePhaseCorrectionForm(props: ProcessingOperatorUISettingsFormProps<'@zakodium/nmrium-core-plugins#phaseCorrection1D'>): import("@tanstack/react-form").AppFieldExtendedReactFormApi<{
|
|
3
|
+
mode: "absolute";
|
|
4
|
+
} | {
|
|
5
|
+
mode: "manual";
|
|
6
|
+
ph0: number;
|
|
7
|
+
ph1: number;
|
|
8
|
+
} | {
|
|
9
|
+
mode: "automatic";
|
|
10
|
+
}, import("@tanstack/react-form").FormValidateOrFn<{
|
|
11
|
+
mode: "absolute";
|
|
12
|
+
} | {
|
|
13
|
+
mode: "manual";
|
|
14
|
+
ph0: number;
|
|
15
|
+
ph1: number;
|
|
16
|
+
} | {
|
|
17
|
+
mode: "automatic";
|
|
18
|
+
}> | undefined, import("@tanstack/react-form").FormValidateOrFn<{
|
|
19
|
+
mode: "absolute";
|
|
20
|
+
} | {
|
|
21
|
+
mode: "manual";
|
|
22
|
+
ph0: number;
|
|
23
|
+
ph1: number;
|
|
24
|
+
} | {
|
|
25
|
+
mode: "automatic";
|
|
26
|
+
}> | undefined, import("@tanstack/react-form").FormAsyncValidateOrFn<{
|
|
27
|
+
mode: "absolute";
|
|
28
|
+
} | {
|
|
29
|
+
mode: "manual";
|
|
30
|
+
ph0: number;
|
|
31
|
+
ph1: number;
|
|
32
|
+
} | {
|
|
33
|
+
mode: "automatic";
|
|
34
|
+
}> | undefined, import("@tanstack/react-form").FormValidateOrFn<{
|
|
35
|
+
mode: "absolute";
|
|
36
|
+
} | {
|
|
37
|
+
mode: "manual";
|
|
38
|
+
ph0: number;
|
|
39
|
+
ph1: number;
|
|
40
|
+
} | {
|
|
41
|
+
mode: "automatic";
|
|
42
|
+
}> | undefined, import("@tanstack/react-form").FormAsyncValidateOrFn<{
|
|
43
|
+
mode: "absolute";
|
|
44
|
+
} | {
|
|
45
|
+
mode: "manual";
|
|
46
|
+
ph0: number;
|
|
47
|
+
ph1: number;
|
|
48
|
+
} | {
|
|
49
|
+
mode: "automatic";
|
|
50
|
+
}> | undefined, import("@tanstack/react-form").FormValidateOrFn<{
|
|
51
|
+
mode: "absolute";
|
|
52
|
+
} | {
|
|
53
|
+
mode: "manual";
|
|
54
|
+
ph0: number;
|
|
55
|
+
ph1: number;
|
|
56
|
+
} | {
|
|
57
|
+
mode: "automatic";
|
|
58
|
+
}> | undefined, import("@tanstack/react-form").FormAsyncValidateOrFn<{
|
|
59
|
+
mode: "absolute";
|
|
60
|
+
} | {
|
|
61
|
+
mode: "manual";
|
|
62
|
+
ph0: number;
|
|
63
|
+
ph1: number;
|
|
64
|
+
} | {
|
|
65
|
+
mode: "automatic";
|
|
66
|
+
}> | undefined, import("zod").ZodType<{
|
|
67
|
+
mode: "absolute";
|
|
68
|
+
} | {
|
|
69
|
+
mode: "manual";
|
|
70
|
+
ph0: number;
|
|
71
|
+
ph1: number;
|
|
72
|
+
} | {
|
|
73
|
+
mode: "automatic";
|
|
74
|
+
}, any, import("zod/v4/core").$ZodTypeInternals<{
|
|
75
|
+
mode: "absolute";
|
|
76
|
+
} | {
|
|
77
|
+
mode: "manual";
|
|
78
|
+
ph0: number;
|
|
79
|
+
ph1: number;
|
|
80
|
+
} | {
|
|
81
|
+
mode: "automatic";
|
|
82
|
+
}, any>>, import("@tanstack/react-form").FormAsyncValidateOrFn<{
|
|
83
|
+
mode: "absolute";
|
|
84
|
+
} | {
|
|
85
|
+
mode: "manual";
|
|
86
|
+
ph0: number;
|
|
87
|
+
ph1: number;
|
|
88
|
+
} | {
|
|
89
|
+
mode: "automatic";
|
|
90
|
+
}> | undefined, import("@tanstack/react-form").FormAsyncValidateOrFn<{
|
|
91
|
+
mode: "absolute";
|
|
92
|
+
} | {
|
|
93
|
+
mode: "manual";
|
|
94
|
+
ph0: number;
|
|
95
|
+
ph1: number;
|
|
96
|
+
} | {
|
|
97
|
+
mode: "automatic";
|
|
98
|
+
}> | undefined, unknown, {
|
|
99
|
+
readonly Input: typeof import("react-science/ui")._Input;
|
|
100
|
+
readonly NumericInput: typeof import("react-science/ui")._NumericInput;
|
|
101
|
+
readonly Checkbox: typeof import("react-science/ui")._Checkbox;
|
|
102
|
+
readonly Select: typeof import("react-science/ui")._Select;
|
|
103
|
+
readonly Switch: typeof import("react-science/ui")._Switch;
|
|
104
|
+
readonly ColorPicker: typeof import("react-science/ui")._ColorPicker;
|
|
105
|
+
readonly RadioGroup: typeof import("react-science/ui")._RadioGroup;
|
|
106
|
+
readonly DraggableNumericInput: typeof import("react-science/ui")._DraggableNumericInput;
|
|
107
|
+
}, {
|
|
108
|
+
readonly SubmitButton: typeof import("react-science/ui")._SubmitButton;
|
|
109
|
+
readonly ResetButton: typeof import("react-science/ui")._ResetButton;
|
|
110
|
+
readonly Section: typeof import("react-science/ui")._Section;
|
|
111
|
+
}>;
|
|
112
|
+
//# sourceMappingURL=phase_correction.hook.d.ts.map
|
|
@@ -0,0 +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":"AACA,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,uBAAuB,CAAC;AAInF,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,qCAAqC,CAAC,iDAAiD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyChG"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { revalidateLogic } from '@tanstack/react-form';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { useForm } from 'react-science/ui';
|
|
4
|
+
export function usePhaseCorrectionForm(props) {
|
|
5
|
+
const { operation, core, onSubmit, onChange } = props;
|
|
6
|
+
const { settings } = operation;
|
|
7
|
+
const operator = core.getOperationOperator('@zakodium/nmrium-core-plugins#phaseCorrection1D', operation);
|
|
8
|
+
const { schemaSettings } = operator;
|
|
9
|
+
const form = useForm({
|
|
10
|
+
defaultValues: settings,
|
|
11
|
+
validators: { onDynamic: schemaSettings },
|
|
12
|
+
validationLogic: revalidateLogic(),
|
|
13
|
+
onSubmit: ({ value }) => {
|
|
14
|
+
if (!onSubmit)
|
|
15
|
+
return;
|
|
16
|
+
const newOperation = {
|
|
17
|
+
...operation,
|
|
18
|
+
settings: schemaSettings.parse(value),
|
|
19
|
+
};
|
|
20
|
+
onSubmit(newOperation);
|
|
21
|
+
},
|
|
22
|
+
listeners: {
|
|
23
|
+
onChange: ({ formApi }) => {
|
|
24
|
+
const result = schemaSettings.safeParse(formApi.state.values);
|
|
25
|
+
if (!result.success)
|
|
26
|
+
return;
|
|
27
|
+
const liveOperation = { ...operation, settings: result.data };
|
|
28
|
+
onChange(liveOperation);
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
form.reset(settings, { keepDefaultValues: true });
|
|
34
|
+
}, [form, settings]);
|
|
35
|
+
return form;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=phase_correction.hook.js.map
|
|
@@ -0,0 +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;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,MAAM,UAAU,sBAAsB,CACpC,KAA+F;IAE/F,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAEtD,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAC;IAC/B,MAAM,QAAQ,GAAG,IAAI,CAAC,oBAAoB,CACxC,iDAAiD,EACjD,SAAS,CACV,CAAC;IAEF,MAAM,EAAE,cAAc,EAAE,GAAG,QAAQ,CAAC;IACpC,MAAM,IAAI,GAAG,OAAO,CAAC;QACnB,aAAa,EAAE,QAAQ;QACvB,UAAU,EAAE,EAAE,SAAS,EAAE,cAAc,EAAE;QACzC,eAAe,EAAE,eAAe,EAAE;QAClC,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;YACtB,IAAI,CAAC,QAAQ;gBAAE,OAAO;YAEtB,MAAM,YAAY,GAAG;gBACnB,GAAG,SAAS;gBACZ,QAAQ,EAAE,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC;aACtC,CAAC;YAEF,QAAQ,CAAC,YAAY,CAAC,CAAC;QACzB,CAAC;QACD,SAAS,EAAE;YACT,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;gBACxB,MAAM,MAAM,GAAG,cAAc,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;gBAC9D,IAAI,CAAC,MAAM,CAAC,OAAO;oBAAE,OAAO;gBAE5B,MAAM,aAAa,GAAG,EAAE,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;gBAC9D,QAAQ,CAAC,aAAa,CAAC,CAAC;YAC1B,CAAC;SACF;KACF,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;IAErB,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phase_correction_expanded.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/phase_correction_expanded.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"phase_correction_expanded.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/phase_correction_expanded.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,uBAAuB,CAAC;AAOnF,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,qCAAqC,CAAC,iDAAiD,CAAC,+BAmEhG"}
|
|
@@ -1,37 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { revalidateLogic } from '@tanstack/react-form';
|
|
3
2
|
import { castSpectrum1D } from '@zakodium/nmrium-core';
|
|
4
3
|
import { autoPhaseCorrection } from 'nmr-processing';
|
|
5
|
-
import { AppForm
|
|
4
|
+
import { AppForm } from 'react-science/ui';
|
|
5
|
+
import { usePhaseCorrectionForm } from "./phase_correction.hook.js";
|
|
6
6
|
export function PhaseCorrectionExpanded(props) {
|
|
7
|
-
const
|
|
7
|
+
const form = usePhaseCorrectionForm(props);
|
|
8
|
+
const { spectrum, children } = props;
|
|
8
9
|
castSpectrum1D(spectrum);
|
|
9
|
-
const { settings } = operation;
|
|
10
|
-
const operator = core.getOperationOperator('@zakodium/nmrium-core-plugins#phaseCorrection1D', operation);
|
|
11
|
-
const { schemaSettings } = operator;
|
|
12
|
-
const form = useForm({
|
|
13
|
-
defaultValues: settings,
|
|
14
|
-
validators: { onDynamic: schemaSettings },
|
|
15
|
-
validationLogic: revalidateLogic(),
|
|
16
|
-
onSubmit: ({ value }) => {
|
|
17
|
-
if (!onSubmit)
|
|
18
|
-
return;
|
|
19
|
-
const newOperation = {
|
|
20
|
-
...operation,
|
|
21
|
-
settings: schemaSettings.parse(value),
|
|
22
|
-
};
|
|
23
|
-
onSubmit(newOperation);
|
|
24
|
-
},
|
|
25
|
-
listeners: {
|
|
26
|
-
onChange: ({ formApi }) => {
|
|
27
|
-
const result = schemaSettings.safeParse(formApi.state.values);
|
|
28
|
-
if (!result.success)
|
|
29
|
-
return;
|
|
30
|
-
const liveOperation = { ...operation, settings: result.data };
|
|
31
|
-
onChange(liveOperation);
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
10
|
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: {
|
|
36
11
|
onChange: ({ value, fieldApi }) => {
|
|
37
12
|
if (value === 'manual') {
|
|
@@ -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":";
|
|
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,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,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,IAAI,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAC3C,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,IACZ,IAAI,EAAC,MAAM,EACX,SAAS,EAAE;oBACT,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;wBAChC,IAAI,KAAK,KAAK,QAAQ,EAAE,CAAC;4BACvB,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;4BAEnD,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;4BACxC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;wBAC1C,CAAC;oBACH,CAAC;iBACF,YAEA,CAAC,KAAK,EAAE,EAAE,CAAC,CACV,8BACE,KAAC,KAAK,CAAC,MAAM,IACX,KAAK,EAAC,MAAM,EACZ,MAAM,EAAC,QAAQ,EACf,KAAK,EAAE;gCACL,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE;gCAC1C,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;gCACpC,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE;6BACzC,GACD,EAED,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"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ProcessingOperatorUISettingsFormProps } from '@zakodium/nmrium-core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare function useShiftXForm(props: ProcessingOperatorUISettingsFormProps<'@zakodium/nmrium-core-plugins#shiftX1D'>): import("@tanstack/react-form").AppFieldExtendedReactFormApi<{
|
|
4
|
+
shift: number;
|
|
5
|
+
}, import("@tanstack/react-form").FormValidateOrFn<{
|
|
6
|
+
shift: number;
|
|
7
|
+
}> | undefined, import("@tanstack/react-form").FormValidateOrFn<{
|
|
8
|
+
shift: number;
|
|
9
|
+
}> | undefined, import("@tanstack/react-form").FormAsyncValidateOrFn<{
|
|
10
|
+
shift: number;
|
|
11
|
+
}> | undefined, import("@tanstack/react-form").FormValidateOrFn<{
|
|
12
|
+
shift: number;
|
|
13
|
+
}> | undefined, import("@tanstack/react-form").FormAsyncValidateOrFn<{
|
|
14
|
+
shift: number;
|
|
15
|
+
}> | undefined, import("@tanstack/react-form").FormValidateOrFn<{
|
|
16
|
+
shift: number;
|
|
17
|
+
}> | undefined, import("@tanstack/react-form").FormAsyncValidateOrFn<{
|
|
18
|
+
shift: number;
|
|
19
|
+
}> | undefined, z.ZodObject<{
|
|
20
|
+
shift: z.ZodType<number, any, z.core.$ZodTypeInternals<number, any>>;
|
|
21
|
+
}, z.core.$strip>, import("@tanstack/react-form").FormAsyncValidateOrFn<{
|
|
22
|
+
shift: number;
|
|
23
|
+
}> | undefined, import("@tanstack/react-form").FormAsyncValidateOrFn<{
|
|
24
|
+
shift: number;
|
|
25
|
+
}> | undefined, unknown, {
|
|
26
|
+
readonly Input: typeof import("react-science/ui")._Input;
|
|
27
|
+
readonly NumericInput: typeof import("react-science/ui")._NumericInput;
|
|
28
|
+
readonly Checkbox: typeof import("react-science/ui")._Checkbox;
|
|
29
|
+
readonly Select: typeof import("react-science/ui")._Select;
|
|
30
|
+
readonly Switch: typeof import("react-science/ui")._Switch;
|
|
31
|
+
readonly ColorPicker: typeof import("react-science/ui")._ColorPicker;
|
|
32
|
+
readonly RadioGroup: typeof import("react-science/ui")._RadioGroup;
|
|
33
|
+
readonly DraggableNumericInput: typeof import("react-science/ui")._DraggableNumericInput;
|
|
34
|
+
}, {
|
|
35
|
+
readonly SubmitButton: typeof import("react-science/ui")._SubmitButton;
|
|
36
|
+
readonly ResetButton: typeof import("react-science/ui")._ResetButton;
|
|
37
|
+
readonly Section: typeof import("react-science/ui")._Section;
|
|
38
|
+
}>;
|
|
39
|
+
//# sourceMappingURL=shift_x.hook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shift_x.hook.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/shift_x.hook.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,uBAAuB,CAAC;AAGnF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,wBAAgB,aAAa,CAC3B,KAAK,EAAE,qCAAqC,CAAC,wCAAwC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CvF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { revalidateLogic } from '@tanstack/react-form';
|
|
2
|
+
import { useEffect, useMemo } from 'react';
|
|
3
|
+
import { useForm } from 'react-science/ui';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
export function useShiftXForm(props) {
|
|
6
|
+
const { operation, core, onChange, onSubmit } = props;
|
|
7
|
+
const { settings } = operation;
|
|
8
|
+
const defaultValues = useMemo(() => ({ shift: settings }), [settings]);
|
|
9
|
+
const operator = core.getOperationOperator('@zakodium/nmrium-core-plugins#shiftX1D', operation);
|
|
10
|
+
const { schemaSettings } = operator;
|
|
11
|
+
const validation = useMemo(() => z.object({ shift: schemaSettings }), [schemaSettings]);
|
|
12
|
+
const form = useForm({
|
|
13
|
+
defaultValues,
|
|
14
|
+
validators: { onDynamic: validation },
|
|
15
|
+
validationLogic: revalidateLogic(),
|
|
16
|
+
onSubmit: ({ value }) => {
|
|
17
|
+
if (!onChange)
|
|
18
|
+
return;
|
|
19
|
+
const { shift } = validation.parse(value);
|
|
20
|
+
const newOperation = { ...operation, settings: shift };
|
|
21
|
+
onSubmit(newOperation);
|
|
22
|
+
},
|
|
23
|
+
listeners: {
|
|
24
|
+
onChange: ({ formApi }) => {
|
|
25
|
+
const result = validation.safeParse(formApi.state.values);
|
|
26
|
+
if (!result.success)
|
|
27
|
+
return;
|
|
28
|
+
const liveOperation = { ...operation, settings: result.data.shift };
|
|
29
|
+
onChange(liveOperation);
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
form.reset(defaultValues, { keepDefaultValues: true });
|
|
35
|
+
}, [form, defaultValues]);
|
|
36
|
+
return form;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=shift_x.hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shift_x.hook.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/shift_x.hook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,UAAU,aAAa,CAC3B,KAAsF;IAEtF,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAEtD,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAC;IAC/B,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEvE,MAAM,QAAQ,GAAG,IAAI,CAAC,oBAAoB,CACxC,wCAAwC,EACxC,SAAS,CACV,CAAC;IACF,MAAM,EAAE,cAAc,EAAE,GAAG,QAAQ,CAAC;IACpC,MAAM,UAAU,GAAG,OAAO,CACxB,GAAG,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,EACzC,CAAC,cAAc,CAAC,CACjB,CAAC;IAEF,MAAM,IAAI,GAAG,OAAO,CAAC;QACnB,aAAa;QACb,UAAU,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE;QACrC,eAAe,EAAE,eAAe,EAAE;QAClC,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;YACtB,IAAI,CAAC,QAAQ;gBAAE,OAAO;YAEtB,MAAM,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAC1C,MAAM,YAAY,GAAG,EAAE,GAAG,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;YAEvD,QAAQ,CAAC,YAAY,CAAC,CAAC;QACzB,CAAC;QACD,SAAS,EAAE;YACT,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,QAAQ,CAAC,aAAa,CAAC,CAAC;YAC1B,CAAC;SACF;KACF,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC;IAE1B,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1 +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":"
|
|
1
|
+
{"version":3,"file":"shift_x_expanded.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/shift_x_expanded.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,uBAAuB,CAAC;AAKnF,wBAAgB,cAAc,CAC5B,KAAK,EAAE,qCAAqC,CAAC,wCAAwC,CAAC,+BAkBvF"}
|
|
@@ -1,47 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { AppForm, useForm } from 'react-science/ui';
|
|
5
|
-
import { z } from 'zod';
|
|
2
|
+
import { AppForm } from 'react-science/ui';
|
|
3
|
+
import { useShiftXForm } from "./shift_x.hook.js";
|
|
6
4
|
export function ShiftXExpanded(props) {
|
|
7
|
-
const
|
|
8
|
-
const {
|
|
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
|
-
onSubmit(newOperation);
|
|
34
|
-
},
|
|
35
|
-
listeners: {
|
|
36
|
-
onChange: ({ formApi }) => {
|
|
37
|
-
const result = validation.safeParse(formApi.state.values);
|
|
38
|
-
if (!result.success)
|
|
39
|
-
return;
|
|
40
|
-
const liveOperation = { ...operation, settings: result.data.shift };
|
|
41
|
-
onChange(liveOperation);
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
});
|
|
5
|
+
const form = useShiftXForm(props);
|
|
6
|
+
const { children } = props;
|
|
45
7
|
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" }) })] }));
|
|
46
8
|
}
|
|
47
9
|
//# sourceMappingURL=shift_x_expanded.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shift_x_expanded.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/shift_x_expanded.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"shift_x_expanded.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/shift_x_expanded.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,UAAU,cAAc,CAC5B,KAAsF;IAEtF,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAE3B,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"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ProcessingOperatorUISettingsFormProps } from '@zakodium/nmrium-core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare function useZeroFillingForm(props: ProcessingOperatorUISettingsFormProps<'@zakodium/nmrium-core-plugins#zeroFilling1D'>): {
|
|
4
|
+
form: import("@tanstack/react-form").AppFieldExtendedReactFormApi<{
|
|
5
|
+
size: number;
|
|
6
|
+
}, import("@tanstack/react-form").FormValidateOrFn<{
|
|
7
|
+
size: number;
|
|
8
|
+
}> | undefined, import("@tanstack/react-form").FormValidateOrFn<{
|
|
9
|
+
size: number;
|
|
10
|
+
}> | undefined, import("@tanstack/react-form").FormAsyncValidateOrFn<{
|
|
11
|
+
size: number;
|
|
12
|
+
}> | undefined, import("@tanstack/react-form").FormValidateOrFn<{
|
|
13
|
+
size: number;
|
|
14
|
+
}> | undefined, import("@tanstack/react-form").FormAsyncValidateOrFn<{
|
|
15
|
+
size: number;
|
|
16
|
+
}> | undefined, import("@tanstack/react-form").FormValidateOrFn<{
|
|
17
|
+
size: number;
|
|
18
|
+
}> | undefined, import("@tanstack/react-form").FormAsyncValidateOrFn<{
|
|
19
|
+
size: number;
|
|
20
|
+
}> | undefined, z.ZodObject<{
|
|
21
|
+
size: z.ZodType<number, any, z.core.$ZodTypeInternals<number, any>>;
|
|
22
|
+
}, z.core.$strip>, import("@tanstack/react-form").FormAsyncValidateOrFn<{
|
|
23
|
+
size: number;
|
|
24
|
+
}> | undefined, import("@tanstack/react-form").FormAsyncValidateOrFn<{
|
|
25
|
+
size: number;
|
|
26
|
+
}> | undefined, unknown, {
|
|
27
|
+
readonly Input: typeof import("react-science/ui")._Input;
|
|
28
|
+
readonly NumericInput: typeof import("react-science/ui")._NumericInput;
|
|
29
|
+
readonly Checkbox: typeof import("react-science/ui")._Checkbox;
|
|
30
|
+
readonly Select: typeof import("react-science/ui")._Select;
|
|
31
|
+
readonly Switch: typeof import("react-science/ui")._Switch;
|
|
32
|
+
readonly ColorPicker: typeof import("react-science/ui")._ColorPicker;
|
|
33
|
+
readonly RadioGroup: typeof import("react-science/ui")._RadioGroup;
|
|
34
|
+
readonly DraggableNumericInput: typeof import("react-science/ui")._DraggableNumericInput;
|
|
35
|
+
}, {
|
|
36
|
+
readonly SubmitButton: typeof import("react-science/ui")._SubmitButton;
|
|
37
|
+
readonly ResetButton: typeof import("react-science/ui")._ResetButton;
|
|
38
|
+
readonly Section: typeof import("react-science/ui")._Section;
|
|
39
|
+
}>;
|
|
40
|
+
options: {
|
|
41
|
+
label: string;
|
|
42
|
+
value: number;
|
|
43
|
+
}[];
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=zero_filling.hook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zero_filling.hook.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/zero_filling.hook.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,uBAAuB,CAAC;AAGnF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAmBxB,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,qCAAqC,CAAC,6CAA6C,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmD5F"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { revalidateLogic } from '@tanstack/react-form';
|
|
2
|
+
import { useEffect, useMemo } from 'react';
|
|
3
|
+
import { useForm } from 'react-science/ui';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
const DEFAULT_OPTIONS = [
|
|
6
|
+
{ label: '256', value: 2 ** 8 },
|
|
7
|
+
{ label: '512', value: 2 ** 9 },
|
|
8
|
+
{ label: '1K', value: 2 ** 10 },
|
|
9
|
+
{ label: '2K', value: 2 ** 11 },
|
|
10
|
+
{ label: '4K', value: 2 ** 12 },
|
|
11
|
+
{ label: '8K', value: 2 ** 13 },
|
|
12
|
+
{ label: '16K', value: 2 ** 14 },
|
|
13
|
+
{ label: '32K', value: 2 ** 15 },
|
|
14
|
+
{ label: '64K', value: 2 ** 16 },
|
|
15
|
+
{ label: '128K', value: 2 ** 17 },
|
|
16
|
+
{ label: '256K', value: 2 ** 18 },
|
|
17
|
+
{ label: '512K', value: 2 ** 19 },
|
|
18
|
+
{ label: '1M', value: 2 ** 20 },
|
|
19
|
+
{ label: '2M', value: 2 ** 21 },
|
|
20
|
+
];
|
|
21
|
+
export function useZeroFillingForm(props) {
|
|
22
|
+
const { operation, onSubmit, onChange, core } = props;
|
|
23
|
+
const operator = core.getOperationOperator('@zakodium/nmrium-core-plugins#zeroFilling1D', operation);
|
|
24
|
+
const validator = useMemo(() => z.object({ size: operator.schemaSettings }), [operator]);
|
|
25
|
+
const defaultValues = useMemo(() => ({ size: operation.settings }), [operation.settings]);
|
|
26
|
+
const form = useForm({
|
|
27
|
+
defaultValues,
|
|
28
|
+
validators: { onDynamic: validator },
|
|
29
|
+
validationLogic: revalidateLogic(),
|
|
30
|
+
onSubmit: ({ value }) => {
|
|
31
|
+
const { size: settings } = validator.parse(value);
|
|
32
|
+
onSubmit({ ...operation, settings });
|
|
33
|
+
},
|
|
34
|
+
listeners: {
|
|
35
|
+
onChange: ({ formApi }) => {
|
|
36
|
+
const result = validator.safeParse(formApi.state.values);
|
|
37
|
+
if (!result.success)
|
|
38
|
+
return;
|
|
39
|
+
onChange({ ...operation, settings: result.data.size });
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
form.reset(defaultValues, { keepDefaultValues: true });
|
|
45
|
+
}, [form, defaultValues]);
|
|
46
|
+
const options = useMemo(() => {
|
|
47
|
+
const settings = operation.settings;
|
|
48
|
+
if (DEFAULT_OPTIONS.some((o) => o.value === settings)) {
|
|
49
|
+
return DEFAULT_OPTIONS;
|
|
50
|
+
}
|
|
51
|
+
return [
|
|
52
|
+
...DEFAULT_OPTIONS,
|
|
53
|
+
{ label: String(settings), value: settings },
|
|
54
|
+
].toSorted((a, b) => a.value - b.value);
|
|
55
|
+
}, [operation.settings]);
|
|
56
|
+
return { form, options };
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=zero_filling.hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zero_filling.hook.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/zero_filling.hook.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zero_filling_expand.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/zero_filling_expand.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"zero_filling_expand.d.ts","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/zero_filling_expand.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,uBAAuB,CAAC;AAKnF,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,qCAAqC,CAAC,6CAA6C,CAAC,+BAoB5F"}
|
|
@@ -1,55 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { AppForm, useForm } from 'react-science/ui';
|
|
5
|
-
import { z } from 'zod';
|
|
6
|
-
const options = [
|
|
7
|
-
{ label: '256', value: 2 ** 8 },
|
|
8
|
-
{ label: '512', value: 2 ** 9 },
|
|
9
|
-
{ label: '1K', value: 2 ** 10 },
|
|
10
|
-
{ label: '2K', value: 2 ** 11 },
|
|
11
|
-
{ label: '4K', value: 2 ** 12 },
|
|
12
|
-
{ label: '8K', value: 2 ** 13 },
|
|
13
|
-
{ label: '16K', value: 2 ** 14 },
|
|
14
|
-
{ label: '32K', value: 2 ** 15 },
|
|
15
|
-
{ label: '64K', value: 2 ** 16 },
|
|
16
|
-
{ label: '128K', value: 2 ** 17 },
|
|
17
|
-
{ label: '256K', value: 2 ** 18 },
|
|
18
|
-
{ label: '512K', value: 2 ** 19 },
|
|
19
|
-
{ label: '1M', value: 2 ** 20 },
|
|
20
|
-
{ label: '2M', value: 2 ** 21 },
|
|
21
|
-
];
|
|
2
|
+
import { AppForm } from 'react-science/ui';
|
|
3
|
+
import { useZeroFillingForm } from "./zero_filling.hook.js";
|
|
22
4
|
export function ZeroFillingExpand(props) {
|
|
23
|
-
const {
|
|
24
|
-
const
|
|
25
|
-
const validator = useMemo(() => z.object({
|
|
26
|
-
size: operator.schemaSettings,
|
|
27
|
-
}), [operator]);
|
|
28
|
-
const defaultValues = useMemo(() => ({ size: operation.settings }), [operation.settings]);
|
|
29
|
-
const form = useForm({
|
|
30
|
-
defaultValues,
|
|
31
|
-
validators: { onDynamic: validator },
|
|
32
|
-
validationLogic: revalidateLogic(),
|
|
33
|
-
onSubmit: ({ value }) => {
|
|
34
|
-
const { size: settings } = validator.parse(value);
|
|
35
|
-
onSubmit({ ...operation, settings });
|
|
36
|
-
},
|
|
37
|
-
listeners: {
|
|
38
|
-
onChange: ({ formApi }) => {
|
|
39
|
-
const result = validator.safeParse(formApi.state.values);
|
|
40
|
-
if (!result.success)
|
|
41
|
-
return;
|
|
42
|
-
onChange({ ...operation, settings: result.data.size });
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
const allOptions = useMemo(() => {
|
|
47
|
-
const settings = operation.settings;
|
|
48
|
-
if (options.some((o) => o.value === settings))
|
|
49
|
-
return options;
|
|
50
|
-
return [...options, { label: String(settings), value: settings }].toSorted((a, b) => a.value - b.value);
|
|
51
|
-
}, [operation.settings]);
|
|
5
|
+
const { children } = props;
|
|
6
|
+
const { form, options } = useZeroFillingForm(props);
|
|
52
7
|
const { AppField, SubmitButton } = form;
|
|
53
|
-
return (_jsxs(AppForm, { form: form, layout: "inline", children: [children(_jsx(SubmitButton, { variant: "outlined", size: "small", intent: "success", children: "Apply" })), _jsx(AppField, { name: "size", children: ({ Select }) => _jsx(Select, { label: "Size", items:
|
|
8
|
+
return (_jsxs(AppForm, { form: form, layout: "inline", children: [children(_jsx(SubmitButton, { variant: "outlined", size: "small", intent: "success", children: "Apply" })), _jsx(AppField, { name: "size", children: ({ Select }) => _jsx(Select, { label: "Size", items: options }) })] }));
|
|
54
9
|
}
|
|
55
10
|
//# sourceMappingURL=zero_filling_expand.js.map
|
|
@@ -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":";
|
|
1
|
+
{"version":3,"file":"zero_filling_expand.js","sourceRoot":"","sources":["../../../../src/plugins/spectrum_1d_processings_ui/operators/zero_filling_expand.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,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"}
|
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.30",
|
|
4
4
|
"license": "CC-BY-NC-SA-4.0",
|
|
5
5
|
"description": "UI related plugins needed for cheminfo/nmrium",
|
|
6
6
|
"keywords": [],
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"typescript": "~6.0.3",
|
|
45
45
|
"vitest": "^4.1.10"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "018413b9504e9e805e601b3d08391d752342a2cf"
|
|
48
48
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
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 { SvgNmrFourierTransform } 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 defaultFFTOperation(): Spectrum1DProcessingTypeRegistry['@zakodium/nmrium-core-plugins#fft1D'] {
|
|
15
|
+
return {
|
|
16
|
+
operatorId: '@zakodium/nmrium-core-plugins#fft1D',
|
|
17
|
+
settings: null,
|
|
18
|
+
options: undefined,
|
|
19
|
+
error: undefined,
|
|
20
|
+
uid: generateID(),
|
|
21
|
+
enabled: true,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function FFTTool(
|
|
26
|
+
props: ProcessingOperatorUIToolProps<'@zakodium/nmrium-core-plugins#fft1D'>,
|
|
27
|
+
) {
|
|
28
|
+
const { spectrum, activeOperatorId, onTriggerOperation } = props;
|
|
29
|
+
|
|
30
|
+
const isActive = activeOperatorId === '@zakodium/nmrium-core-plugins#fft1D';
|
|
31
|
+
const isVisible = isSpectrum1DFid(spectrum) && spectrum.info.isComplex;
|
|
32
|
+
|
|
33
|
+
const triggerOperation = useEventCallback(
|
|
34
|
+
(event: KeyboardEvent | MouseEvent) => {
|
|
35
|
+
if ('stopImmediatePropagation' in event) {
|
|
36
|
+
// stopPropagation is not enough because
|
|
37
|
+
// nmrium keyboard listener is also on document
|
|
38
|
+
event.stopImmediatePropagation();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
onTriggerOperation(defaultFFTOperation());
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const hotkeys = useMemo<HotkeyConfig[]>(() => {
|
|
46
|
+
return [
|
|
47
|
+
{
|
|
48
|
+
combo: 't',
|
|
49
|
+
label: 'Fourier Transform',
|
|
50
|
+
global: true,
|
|
51
|
+
onKeyDown: triggerOperation,
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
}, [triggerOperation]);
|
|
55
|
+
|
|
56
|
+
useHotkeys(isVisible ? hotkeys : []);
|
|
57
|
+
if (!isVisible) return null;
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<Toolbar.Item
|
|
61
|
+
id="@zakodium/nmrium-core-plugins#fft1D"
|
|
62
|
+
icon={<SvgNmrFourierTransform />}
|
|
63
|
+
tooltip={
|
|
64
|
+
<TooltipHelpContent
|
|
65
|
+
title="Fourier transform"
|
|
66
|
+
shortcuts={['t']}
|
|
67
|
+
description="Perform a Fourier transform on the FID."
|
|
68
|
+
link="https://docs.nmrium.org/help/ft/"
|
|
69
|
+
/>
|
|
70
|
+
}
|
|
71
|
+
active={isActive}
|
|
72
|
+
onClick={triggerOperation}
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
@@ -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,48 +1,17 @@
|
|
|
1
|
-
import { revalidateLogic } from '@tanstack/react-form';
|
|
2
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
|
|
4
|
+
import { AppForm } from 'react-science/ui';
|
|
5
|
+
|
|
6
|
+
import { usePhaseCorrectionForm } from './phase_correction.hook.ts';
|
|
6
7
|
|
|
7
8
|
export function PhaseCorrectionExpanded(
|
|
8
9
|
props: ProcessingOperatorUISettingsFormProps<'@zakodium/nmrium-core-plugins#phaseCorrection1D'>,
|
|
9
10
|
) {
|
|
10
|
-
const
|
|
11
|
-
|
|
11
|
+
const form = usePhaseCorrectionForm(props);
|
|
12
|
+
const { spectrum, children } = props;
|
|
12
13
|
castSpectrum1D(spectrum);
|
|
13
14
|
|
|
14
|
-
const { settings } = operation;
|
|
15
|
-
const operator = core.getOperationOperator(
|
|
16
|
-
'@zakodium/nmrium-core-plugins#phaseCorrection1D',
|
|
17
|
-
operation,
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
const { schemaSettings } = operator;
|
|
21
|
-
const form = useForm({
|
|
22
|
-
defaultValues: settings,
|
|
23
|
-
validators: { onDynamic: schemaSettings },
|
|
24
|
-
validationLogic: revalidateLogic(),
|
|
25
|
-
onSubmit: ({ value }) => {
|
|
26
|
-
if (!onSubmit) return;
|
|
27
|
-
|
|
28
|
-
const newOperation = {
|
|
29
|
-
...operation,
|
|
30
|
-
settings: schemaSettings.parse(value),
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
onSubmit(newOperation);
|
|
34
|
-
},
|
|
35
|
-
listeners: {
|
|
36
|
-
onChange: ({ formApi }) => {
|
|
37
|
-
const result = schemaSettings.safeParse(formApi.state.values);
|
|
38
|
-
if (!result.success) return;
|
|
39
|
-
|
|
40
|
-
const liveOperation = { ...operation, settings: result.data };
|
|
41
|
-
onChange(liveOperation);
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
|
|
46
15
|
return (
|
|
47
16
|
<AppForm form={form} layout="stacked">
|
|
48
17
|
{children?.(
|
|
@@ -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,58 +1,13 @@
|
|
|
1
|
-
import { revalidateLogic } from '@tanstack/react-form';
|
|
2
1
|
import type { ProcessingOperatorUISettingsFormProps } from '@zakodium/nmrium-core';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import {
|
|
2
|
+
import { AppForm } from 'react-science/ui';
|
|
3
|
+
|
|
4
|
+
import { useShiftXForm } from './shift_x.hook.ts';
|
|
6
5
|
|
|
7
6
|
export function ShiftXExpanded(
|
|
8
7
|
props: ProcessingOperatorUISettingsFormProps<'@zakodium/nmrium-core-plugins#shiftX1D'>,
|
|
9
8
|
) {
|
|
10
|
-
const
|
|
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
|
-
onSubmit(newOperation);
|
|
45
|
-
},
|
|
46
|
-
listeners: {
|
|
47
|
-
onChange: ({ formApi }) => {
|
|
48
|
-
const result = validation.safeParse(formApi.state.values);
|
|
49
|
-
if (!result.success) return;
|
|
50
|
-
|
|
51
|
-
const liveOperation = { ...operation, settings: result.data.shift };
|
|
52
|
-
onChange(liveOperation);
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
});
|
|
9
|
+
const form = useShiftXForm(props);
|
|
10
|
+
const { children } = props;
|
|
56
11
|
|
|
57
12
|
return (
|
|
58
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,72 +1,13 @@
|
|
|
1
|
-
import { revalidateLogic } from '@tanstack/react-form';
|
|
2
1
|
import type { ProcessingOperatorUISettingsFormProps } from '@zakodium/nmrium-core';
|
|
3
|
-
import {
|
|
4
|
-
import { AppForm, useForm } from 'react-science/ui';
|
|
5
|
-
import { z } from 'zod';
|
|
2
|
+
import { AppForm } from 'react-science/ui';
|
|
6
3
|
|
|
7
|
-
|
|
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
7
|
props: ProcessingOperatorUISettingsFormProps<'@zakodium/nmrium-core-plugins#zeroFilling1D'>,
|
|
26
8
|
) {
|
|
27
|
-
const {
|
|
28
|
-
const
|
|
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
|
-
onSubmit({ ...operation, settings });
|
|
51
|
-
},
|
|
52
|
-
listeners: {
|
|
53
|
-
onChange: ({ formApi }) => {
|
|
54
|
-
const result = validator.safeParse(formApi.state.values);
|
|
55
|
-
if (!result.success) return;
|
|
56
|
-
|
|
57
|
-
onChange({ ...operation, settings: result.data.size });
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
const allOptions = useMemo(() => {
|
|
63
|
-
const settings = operation.settings;
|
|
64
|
-
if (options.some((o) => o.value === settings)) return options;
|
|
65
|
-
|
|
66
|
-
return [...options, { label: String(settings), value: settings }].toSorted(
|
|
67
|
-
(a, b) => a.value - b.value,
|
|
68
|
-
);
|
|
69
|
-
}, [operation.settings]);
|
|
9
|
+
const { children } = props;
|
|
10
|
+
const { form, options } = useZeroFillingForm(props);
|
|
70
11
|
|
|
71
12
|
const { AppField, SubmitButton } = form;
|
|
72
13
|
|
|
@@ -79,7 +20,7 @@ export function ZeroFillingExpand(
|
|
|
79
20
|
)}
|
|
80
21
|
|
|
81
22
|
<AppField name="size">
|
|
82
|
-
{({ Select }) => <Select label="Size" items={
|
|
23
|
+
{({ Select }) => <Select label="Size" items={options} />}
|
|
83
24
|
</AppField>
|
|
84
25
|
</AppForm>
|
|
85
26
|
);
|