nmrium 0.57.1 → 0.58.0
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/component/1d-2d/components/SpectrumInfoBlock.d.ts +1 -1
- package/lib/component/1d-2d/components/SpectrumInfoBlock.js +114 -7
- package/lib/component/elements/ActionsButtonsPopover.d.ts +7 -1
- package/lib/component/elements/ActionsButtonsPopover.js +9 -6
- package/lib/component/elements/Input2.js +2 -2
- package/lib/component/elements/Input2Controller.d.ts +4 -2
- package/lib/component/elements/Input2Controller.js +22 -6
- package/lib/component/elements/MoleculeSelection.js +2 -2
- package/lib/component/elements/NextPrev.d.ts +4 -5
- package/lib/component/elements/NextPrev.js +76 -79
- package/lib/component/header/ApodizationOptionsPanel.js +14 -7
- package/lib/component/header/BaseLineCorrectionPanel.js +17 -10
- package/lib/component/header/ZeroFillingOptionsPanel.js +17 -10
- package/lib/component/hooks/useSaveSettings.js +43 -26
- package/lib/component/hooks/useWorkspaceAction.js +12 -14
- package/lib/component/modal/LoadJCAMPModal.d.ts +3 -1
- package/lib/component/modal/LoadJCAMPModal.js +17 -18
- package/lib/component/modal/SaveAsModal.d.ts +3 -1
- package/lib/component/modal/SaveAsModal.js +20 -30
- package/lib/component/modal/changeSum/ChangeSumModal.js +1 -1
- package/lib/component/modal/changeSum/ChangeSumModalContents.js +35 -47
- package/lib/component/modal/changeSum/SelectMolecule.d.ts +2 -5
- package/lib/component/modal/changeSum/SelectMolecule.js +9 -8
- package/lib/component/panels/MoleculesPanel/MoleculePanel.js +5 -3
- package/lib/component/panels/Panels.js +13 -13
- package/lib/component/panels/predictionPanel/PredictionPanel.js +2 -2
- package/lib/component/reducer/preferences/actions/changeInformationBlockPosition.d.ts +3 -0
- package/lib/component/reducer/preferences/actions/changeInformationBlockPosition.js +5 -0
- package/lib/component/reducer/preferences/actions/toggleInformationBlock.d.ts +3 -0
- package/lib/component/reducer/preferences/actions/toggleInformationBlock.js +7 -0
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +10 -1
- package/lib/component/reducer/preferences/preferencesReducer.js +6 -0
- package/lib/versionInfo.js +1 -1
- package/package.json +16 -16
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare function SpectrumInfoBlock(): import("react/jsx-runtime").JSX.Element | null;
|
|
1
|
+
declare function SpectrumInfoBlock(): import("@emotion/react/jsx-runtime").JSX.Element | null;
|
|
2
2
|
export default SpectrumInfoBlock;
|
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource @emotion/react */
|
|
2
3
|
import lodashGet from 'lodash/get';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import { BsArrowsMove } from 'react-icons/bs';
|
|
6
|
+
import { FaTimes } from 'react-icons/fa';
|
|
7
|
+
import { useMeasure } from 'react-use';
|
|
3
8
|
import { useChartData } from '../../context/ChartContext';
|
|
9
|
+
import { useGlobal } from '../../context/GlobalContext';
|
|
4
10
|
import { usePreferences } from '../../context/PreferencesContext';
|
|
11
|
+
import { ActionsButtonsPopover, } from '../../elements/ActionsButtonsPopover';
|
|
5
12
|
import { SVGGroup } from '../../elements/SVGGroup';
|
|
13
|
+
import useDraggable from '../../elements/draggable/useDraggable';
|
|
6
14
|
import useSpectrum from '../../hooks/useSpectrum';
|
|
7
15
|
import { formatNumber } from '../../utility/formatNumber';
|
|
16
|
+
const verticalSpace = 5;
|
|
17
|
+
const boxPadding = 0;
|
|
18
|
+
const dragShiftY = 24;
|
|
8
19
|
const styles = {
|
|
9
20
|
label: {
|
|
10
21
|
fontSize: '11px',
|
|
@@ -34,16 +45,112 @@ function getInfoValue(spectrum, field) {
|
|
|
34
45
|
return JSON.stringify(value);
|
|
35
46
|
}
|
|
36
47
|
}
|
|
48
|
+
function useInfoPosition(margin) {
|
|
49
|
+
const { left, top } = margin;
|
|
50
|
+
const { current: { infoBlock }, } = usePreferences();
|
|
51
|
+
const { x, y } = infoBlock?.position || { x: left, y: top };
|
|
52
|
+
return { x, y };
|
|
53
|
+
}
|
|
37
54
|
function SpectrumInfoBlock() {
|
|
38
|
-
const { margin } = useChartData();
|
|
55
|
+
const { height, width, margin } = useChartData();
|
|
39
56
|
const spectrum = useSpectrum();
|
|
57
|
+
const { viewerRef } = useGlobal();
|
|
58
|
+
const coordinate = useInfoPosition(margin);
|
|
59
|
+
const { dispatch } = usePreferences();
|
|
60
|
+
const [isMoveActive, setIsMoveActive] = useState(false);
|
|
61
|
+
const [currentPosition, setCurrentPosition] = useState(coordinate);
|
|
40
62
|
const { current: { infoBlock: { visible, fields }, }, } = usePreferences();
|
|
63
|
+
const infoFields = fields.filter((field) => field.visible);
|
|
64
|
+
const totalSpace = verticalSpace *
|
|
65
|
+
((infoFields?.length < 2
|
|
66
|
+
? 2
|
|
67
|
+
: infoFields?.length - (infoFields?.length % 2)
|
|
68
|
+
? 2
|
|
69
|
+
: 1) || 0);
|
|
70
|
+
const [ref, boxSize] = useMeasure();
|
|
71
|
+
const { onPointerDown } = useDraggable({
|
|
72
|
+
position: coordinate,
|
|
73
|
+
onChange: (dragEvent) => {
|
|
74
|
+
const { action, position } = dragEvent;
|
|
75
|
+
switch (action) {
|
|
76
|
+
case 'start': {
|
|
77
|
+
setCurrentPosition({ x: position.x, y: position.y + dragShiftY });
|
|
78
|
+
setIsMoveActive(true);
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
case 'move': {
|
|
82
|
+
setCurrentPosition({
|
|
83
|
+
x: position.x,
|
|
84
|
+
y: position.y + dragShiftY,
|
|
85
|
+
});
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
case 'end':
|
|
89
|
+
dispatch({
|
|
90
|
+
type: 'CHANGE_INFORMATION_BLOCK_POSITION',
|
|
91
|
+
payload: {
|
|
92
|
+
coordination: {
|
|
93
|
+
x: position.x,
|
|
94
|
+
y: position.y,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
setIsMoveActive(false);
|
|
99
|
+
break;
|
|
100
|
+
default:
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
parentElement: viewerRef,
|
|
105
|
+
});
|
|
41
106
|
if (!visible || !spectrum)
|
|
42
107
|
return null;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
108
|
+
const bothSidePadding = boxPadding * 2;
|
|
109
|
+
const shift = dragShiftY / 2;
|
|
110
|
+
let { x, y } = currentPosition;
|
|
111
|
+
if (x + boxSize.width + boxPadding > width - margin.right) {
|
|
112
|
+
x = width - margin.right - boxSize.width - boxPadding;
|
|
113
|
+
}
|
|
114
|
+
if (x - boxPadding < margin.left) {
|
|
115
|
+
x = margin.left + boxPadding;
|
|
116
|
+
}
|
|
117
|
+
if (y + boxSize.height + bothSidePadding + shift > height - margin.bottom) {
|
|
118
|
+
y = height - margin.bottom - boxSize.height - bothSidePadding - shift;
|
|
119
|
+
}
|
|
120
|
+
if (y + shift < margin.top) {
|
|
121
|
+
y = margin.top - shift;
|
|
122
|
+
}
|
|
123
|
+
const boxWidth = boxSize.width + bothSidePadding;
|
|
124
|
+
const boxHeight = boxSize.height + bothSidePadding;
|
|
125
|
+
const actionsButtons = [
|
|
126
|
+
{
|
|
127
|
+
icon: _jsx(BsArrowsMove, {}),
|
|
128
|
+
onPointerDown: (event) => {
|
|
129
|
+
event.stopPropagation();
|
|
130
|
+
onPointerDown(event);
|
|
131
|
+
},
|
|
132
|
+
intent: 'none',
|
|
133
|
+
title: 'Move information block',
|
|
134
|
+
style: { cursor: 'move' },
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
icon: _jsx(FaTimes, {}),
|
|
138
|
+
onClick: () => {
|
|
139
|
+
dispatch({
|
|
140
|
+
type: 'TOGGLE_INFORMATION_BLOCK',
|
|
141
|
+
payload: { visible: false },
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
intent: 'danger',
|
|
145
|
+
title: 'Hide information block',
|
|
146
|
+
},
|
|
147
|
+
];
|
|
148
|
+
return (_jsx(ActionsButtonsPopover, { targetTagName: "g", buttons: actionsButtons, positioningStrategy: "fixed", position: "top-left", direction: "row", space: 2, ...(isMoveActive && { isOpen: true }), modifiers: {
|
|
149
|
+
offset: {
|
|
150
|
+
data: { x, y },
|
|
151
|
+
},
|
|
152
|
+
}, children: _jsxs("g", { className: "spectra-info-block", transform: `translate(${x} ${y})`, children: [_jsx("rect", { "data-no-export": "true", x: -boxPadding, y: -boxPadding + totalSpace, width: boxWidth, height: boxHeight, rx: "5", fill: isMoveActive ? 'white' : 'transparent', opacity: isMoveActive ? 0.9 : 0 }), _jsx("g", { ref: ref, children: infoFields.map((field, index) => {
|
|
153
|
+
return (_jsxs(SVGGroup, { transform: `translate(0,${20 * (index + 1)})`, space: verticalSpace, children: [_jsxs("text", { alignmentBaseline: "middle", style: styles.label, children: [field.label, " :"] }), _jsx("text", { alignmentBaseline: "middle", style: styles.value, children: getInfoValue(spectrum, field) })] }, field.jpath + field.label));
|
|
154
|
+
}) })] }) }));
|
|
48
155
|
}
|
|
49
156
|
export default SpectrumInfoBlock;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
/** @jsxImportSource @emotion/react */
|
|
2
2
|
import { PopoverProps } from '@blueprintjs/core';
|
|
3
|
+
import { Interpolation, Theme } from '@emotion/react';
|
|
4
|
+
import { CSSProperties } from 'react';
|
|
3
5
|
import { ButtonProps } from 'react-science/ui';
|
|
4
6
|
export interface ActionsButtonsPopoverProps extends Omit<PopoverProps, 'interactionKind' | 'content'> {
|
|
5
|
-
buttons: Array<Pick<ButtonProps, 'icon' | 'onClick' | 'intent' | 'disabled'> & {
|
|
7
|
+
buttons: Array<Pick<ButtonProps, 'icon' | 'onClick' | 'intent' | 'disabled' | 'onPointerDown' | 'style'> & {
|
|
6
8
|
title?: string;
|
|
7
9
|
visible?: boolean;
|
|
10
|
+
css?: Interpolation<Theme>;
|
|
8
11
|
}>;
|
|
12
|
+
contentStyle?: CSSProperties;
|
|
13
|
+
direction?: 'column' | 'row';
|
|
14
|
+
space?: number;
|
|
9
15
|
}
|
|
10
16
|
export declare function ActionsButtonsPopover(props: ActionsButtonsPopoverProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import { Popover } from '@blueprintjs/core';
|
|
4
4
|
import { css } from '@emotion/react';
|
|
5
|
+
import { Fragment } from 'react';
|
|
5
6
|
import { Button } from 'react-science/ui';
|
|
6
7
|
export function ActionsButtonsPopover(props) {
|
|
7
|
-
const { buttons, children, ...otherProps } = props;
|
|
8
|
-
return (_jsx(Popover, { minimal: true, position: "auto-start", popoverClassName: "actions-buttons-popover", interactionKind: "hover", enforceFocus: false, content: _jsx("div", { style: { display: 'flex', flexDirection:
|
|
8
|
+
const { buttons, children, space, direction = 'column', contentStyle = {}, ...otherProps } = props;
|
|
9
|
+
return (_jsx(Popover, { minimal: true, position: "auto-start", popoverClassName: "actions-buttons-popover", interactionKind: "hover", enforceFocus: false, content: _jsx("div", { style: { display: 'flex', flexDirection: direction, ...contentStyle }, css: css `
|
|
9
10
|
button,
|
|
10
11
|
a[role='button'] {
|
|
11
12
|
border-radius: 50%;
|
|
@@ -16,7 +17,9 @@ export function ActionsButtonsPopover(props) {
|
|
|
16
17
|
}
|
|
17
18
|
`, children: buttons
|
|
18
19
|
.filter((button) => button?.visible !== false)
|
|
19
|
-
.map(({
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
.map(({ title, ...otherProps }, index, array) => (_jsxs(Fragment, { children: [_jsx(Button, { tooltipProps: { content: title || '', compact: true }, ...otherProps }), index < array.length - 1 && (
|
|
21
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
22
|
+
_jsx("div", { style: {
|
|
23
|
+
margin: direction === 'row' ? `0 ${space}px` : `${space}px 0`,
|
|
24
|
+
} }, `spacer-${index}`))] }, title || index))) }), ...otherProps, children: children }));
|
|
22
25
|
}
|
|
@@ -64,7 +64,7 @@ function getClasses(isDebounced) {
|
|
|
64
64
|
return classes.join(' ');
|
|
65
65
|
}
|
|
66
66
|
function InnerInput(props, ref) {
|
|
67
|
-
const { debounceTime = 0, onChange, checkValue, value: externalValue, getFilterValue = (item) => item, filterItems, leftIcon, autoSelect = false, ...otherInputProps } = props;
|
|
67
|
+
const { debounceTime = 0, onChange, checkValue, value: externalValue, getFilterValue = (item) => item, filterItems, leftIcon, autoSelect = false, fill, ...otherInputProps } = props;
|
|
68
68
|
const { handleChange, setValue, isDebounced, innerRef, value } = useInput({
|
|
69
69
|
value: externalValue,
|
|
70
70
|
ref,
|
|
@@ -97,7 +97,7 @@ function InnerInput(props, ref) {
|
|
|
97
97
|
inputClassName: classes,
|
|
98
98
|
inputRef: innerRef,
|
|
99
99
|
...otherInputProps,
|
|
100
|
-
}, items: [], query: value
|
|
100
|
+
}, items: [], query: value ?? '', onQueryChange: handleChange, fill: fill, popoverProps: { disabled: true }, ...(filterItems &&
|
|
101
101
|
filterItems.length > 0 && {
|
|
102
102
|
items: filterItems,
|
|
103
103
|
itemRenderer: renderItem,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @jsxImportSource @emotion/react */
|
|
1
2
|
import { ControllerProps, FieldValues } from 'react-hook-form';
|
|
2
3
|
import { Input2Props } from './Input2';
|
|
3
4
|
export interface InputMapValueFunctions {
|
|
@@ -5,8 +6,9 @@ export interface InputMapValueFunctions {
|
|
|
5
6
|
mapValue?: (value: any) => string;
|
|
6
7
|
}
|
|
7
8
|
interface Input2ControllerProps<TFieldValues extends FieldValues = FieldValues> extends Omit<Input2Props, 'name'>, Pick<ControllerProps<TFieldValues>, 'control' | 'name'>, InputMapValueFunctions {
|
|
8
|
-
controllerProps?: Omit<ControllerProps<TFieldValues>, 'render'>;
|
|
9
|
+
controllerProps?: Omit<ControllerProps<TFieldValues>, 'control' | 'name' | 'render'>;
|
|
9
10
|
noShadowBox?: boolean;
|
|
11
|
+
enableErrorMessage?: boolean;
|
|
10
12
|
}
|
|
11
|
-
export declare function Input2Controller<TFieldValues extends FieldValues = FieldValues>(props: Input2ControllerProps<TFieldValues>): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare function Input2Controller<TFieldValues extends FieldValues = FieldValues>(props: Input2ControllerProps<TFieldValues>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
12
14
|
export {};
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource @emotion/react */
|
|
3
|
+
import { FormGroup } from '@blueprintjs/core';
|
|
4
|
+
import { css } from '@emotion/react';
|
|
2
5
|
import { Controller } from 'react-hook-form';
|
|
3
6
|
import { Input2 } from './Input2';
|
|
4
7
|
export function Input2Controller(props) {
|
|
5
|
-
const { controllerProps, onChange, name, control, intent = 'none', mapOnChangeValue, mapValue, noShadowBox = false, style, ...otherInputProps } = props;
|
|
6
|
-
return (_jsx(Controller, { name: name, control: control, ...controllerProps, render: ({ field, fieldState: { invalid } }) => {
|
|
8
|
+
const { controllerProps, onChange, name, control, intent = 'none', mapOnChangeValue, mapValue, noShadowBox = false, enableErrorMessage = false, style, fill, ...otherInputProps } = props;
|
|
9
|
+
return (_jsx(Controller, { name: name, control: control, ...controllerProps, render: ({ field, fieldState: { invalid, error } }) => {
|
|
7
10
|
const { value: originValue, ...otherFieldProps } = field;
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
let value = originValue;
|
|
12
|
+
if (typeof mapValue === 'function') {
|
|
13
|
+
value = mapValue(originValue);
|
|
14
|
+
}
|
|
15
|
+
const inputComponent = (_jsx(Input2, { value: value, ...otherFieldProps, onChange: (value, event) => {
|
|
10
16
|
if (typeof mapOnChangeValue === 'function') {
|
|
11
17
|
field.onChange(mapOnChangeValue(value));
|
|
12
18
|
}
|
|
@@ -17,6 +23,16 @@ export function Input2Controller(props) {
|
|
|
17
23
|
}, style: {
|
|
18
24
|
...style,
|
|
19
25
|
...(noShadowBox && !invalid && { boxShadow: 'none' }),
|
|
20
|
-
}, intent: invalid ? 'danger' : intent, ...otherInputProps }));
|
|
26
|
+
}, intent: invalid ? 'danger' : intent, fill: fill, ...otherInputProps }));
|
|
27
|
+
if (enableErrorMessage && error?.message) {
|
|
28
|
+
return (_jsx(FormGroup, { fill: fill, ...(fill && {
|
|
29
|
+
css: css `
|
|
30
|
+
div {
|
|
31
|
+
flex: 1;
|
|
32
|
+
}
|
|
33
|
+
`,
|
|
34
|
+
}), helperText: error.message, intent: invalid ? 'danger' : intent, children: inputComponent }));
|
|
35
|
+
}
|
|
36
|
+
return inputComponent;
|
|
21
37
|
} }));
|
|
22
38
|
}
|
|
@@ -4,7 +4,7 @@ import { css } from '@emotion/react';
|
|
|
4
4
|
import { useCallback, useEffect, useState } from 'react';
|
|
5
5
|
import { MF } from 'react-mf';
|
|
6
6
|
import { MolfileSvgRenderer } from 'react-ocl/full';
|
|
7
|
-
import NextPrev from './NextPrev';
|
|
7
|
+
import { NextPrev } from './NextPrev';
|
|
8
8
|
const toolbarStyle = css `
|
|
9
9
|
display: flex;
|
|
10
10
|
flex-direction: row;
|
|
@@ -75,5 +75,5 @@ export default function MoleculeSelection(props) {
|
|
|
75
75
|
}, [onChange]);
|
|
76
76
|
return (_jsxs("div", { children: [_jsx("div", { css: toolbarStyle, children: _jsxs("p", { children: [molecules &&
|
|
77
77
|
molecules.length > 0 &&
|
|
78
|
-
`${+(currentIndex + 1)} / ${molecules.length}`, ' '] }) }), _jsx("div", { css: moleculeContainerStyle, children: _jsx(NextPrev, {
|
|
78
|
+
`${+(currentIndex + 1)} / ${molecules.length}`, ' '] }) }), _jsx("div", { css: moleculeContainerStyle, children: _jsx(NextPrev, { index: currentIndex, onChange: onChangeHandler, children: molecules?.map((mol, index) => (_jsxs("div", { className: "slider", children: [_jsx("div", { children: mol.molfile && (_jsx(MolfileSvgRenderer, { id: `molSVG${index}`, width: 120, molfile: mol.molfile })) }), _jsxs("p", { children: [_jsx(MF, { mf: mol.mf }), " - ", mol.mw?.toFixed(2)] })] }, mol.id))) }) })] }));
|
|
79
79
|
}
|
|
@@ -2,12 +2,11 @@ import { CSSProperties, ReactElement } from 'react';
|
|
|
2
2
|
interface NextPrevProps {
|
|
3
3
|
children: ReactElement | ReactElement[];
|
|
4
4
|
loop?: boolean;
|
|
5
|
-
|
|
6
|
-
onChange
|
|
5
|
+
index: number;
|
|
6
|
+
onChange: (element: number) => void;
|
|
7
7
|
style?: {
|
|
8
8
|
arrowContainer?: CSSProperties;
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
-
declare function NextPrev(props: NextPrevProps): import("@emotion/react/jsx-runtime").JSX.Element | null;
|
|
12
|
-
|
|
13
|
-
export default _default;
|
|
11
|
+
export declare function NextPrev(props: NextPrevProps): import("@emotion/react/jsx-runtime").JSX.Element | null;
|
|
12
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
|
-
import
|
|
4
|
+
import styled from '@emotion/styled';
|
|
5
|
+
import { Children } from 'react';
|
|
5
6
|
import { FaAngleLeft } from 'react-icons/fa';
|
|
6
7
|
import { useMeasure } from 'react-use';
|
|
7
8
|
function Arrow({ direction, onClick, style = {} }) {
|
|
@@ -34,88 +35,84 @@ function Arrow({ direction, onClick, style = {} }) {
|
|
|
34
35
|
}
|
|
35
36
|
`, style: style, children: _jsx(FaAngleLeft, { style: { transform: `scaleX(${direction === 'right' ? '-1' : '1'})` } }) }));
|
|
36
37
|
}
|
|
38
|
+
const Container = styled.div `
|
|
39
|
+
position: relative;
|
|
40
|
+
height: 100%;
|
|
41
|
+
width: 100%;
|
|
42
|
+
margin: 0 auto;
|
|
43
|
+
overflow: hidden;
|
|
44
|
+
display: block;
|
|
45
|
+
`;
|
|
46
|
+
const TransformController = styled.div(({ translation, slidersWidth }) => `transform: translateX(-${translation}px);
|
|
47
|
+
transition: transform ease-out ${transition}s;
|
|
48
|
+
height: 100%;
|
|
49
|
+
width: ${slidersWidth}px;
|
|
50
|
+
display: flex;
|
|
51
|
+
`);
|
|
37
52
|
const transition = 0.45;
|
|
38
|
-
function NextPrev(props) {
|
|
39
|
-
const { children, loop = false,
|
|
53
|
+
export function NextPrev(props) {
|
|
54
|
+
const { children, loop = false, index = 0, onChange = () => null, style = {}, } = props;
|
|
40
55
|
const [ref, { width }] = useMeasure();
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
`, children: child }, child.key));
|
|
50
|
-
}), [children, width]);
|
|
51
|
-
const nextHandler = useCallback(() => {
|
|
52
|
-
setActiveIndex((preActiveIndex) => {
|
|
53
|
-
if (Sliders && preActiveIndex === Sliders.length - 1) {
|
|
54
|
-
onChange(preActiveIndex);
|
|
55
|
-
if (loop) {
|
|
56
|
-
return 0;
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
return preActiveIndex;
|
|
60
|
-
}
|
|
56
|
+
const slidersCount = Children.count(children);
|
|
57
|
+
const lastIndex = slidersCount > 0 ? slidersCount - 1 : 0;
|
|
58
|
+
const activeIndex = index > lastIndex ? lastIndex : index;
|
|
59
|
+
function nextHandler() {
|
|
60
|
+
if (index === lastIndex) {
|
|
61
|
+
onChange(index);
|
|
62
|
+
if (loop) {
|
|
63
|
+
return 0;
|
|
61
64
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return nextIndex;
|
|
65
|
-
});
|
|
66
|
-
}, [Sliders, loop, onChange]);
|
|
67
|
-
const prevHandler = useCallback(() => {
|
|
68
|
-
setActiveIndex((preActiveIndex) => {
|
|
69
|
-
if (preActiveIndex === 0) {
|
|
70
|
-
onChange(preActiveIndex);
|
|
71
|
-
if (loop) {
|
|
72
|
-
return 0;
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
return preActiveIndex;
|
|
76
|
-
}
|
|
65
|
+
else {
|
|
66
|
+
return index;
|
|
77
67
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
68
|
+
}
|
|
69
|
+
const nextIndex = index + 1;
|
|
70
|
+
onChange(nextIndex);
|
|
71
|
+
}
|
|
72
|
+
function prevHandler() {
|
|
73
|
+
if (index === 0) {
|
|
74
|
+
onChange(index);
|
|
75
|
+
if (loop) {
|
|
76
|
+
return 0;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
return index;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const prevIndex = index - 1;
|
|
83
|
+
onChange(prevIndex);
|
|
84
|
+
}
|
|
85
|
+
if (!width && slidersCount === 0)
|
|
84
86
|
return null;
|
|
85
87
|
const translation = width * activeIndex;
|
|
86
|
-
const slidersWidth = width *
|
|
87
|
-
return (_jsxs(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
visibility: 'hidden',
|
|
117
|
-
pointerEvents: 'none',
|
|
118
|
-
}),
|
|
119
|
-
} })] })] }));
|
|
88
|
+
const slidersWidth = width * slidersCount;
|
|
89
|
+
return (_jsxs(Container, { ref: ref, children: [_jsx(TransformController, { translation: translation, slidersWidth: slidersWidth, children: Children.map(children, (child) => {
|
|
90
|
+
return (_jsx("div", { css: css `
|
|
91
|
+
width: ${width}px;
|
|
92
|
+
height: 100%;
|
|
93
|
+
`, children: child }, child.key));
|
|
94
|
+
}) }), _jsx(SliderControllers, { onNext: nextHandler, onPrevious: prevHandler, activeIndex: activeIndex, lastIndex: lastIndex, style: style?.arrowContainer })] }));
|
|
95
|
+
}
|
|
96
|
+
function SliderControllers(props) {
|
|
97
|
+
const { onNext, onPrevious, activeIndex, lastIndex, style } = props;
|
|
98
|
+
return (_jsxs("div", { style: {
|
|
99
|
+
position: 'absolute',
|
|
100
|
+
top: '50%',
|
|
101
|
+
padding: '0 10px',
|
|
102
|
+
justifyContent: 'space-between',
|
|
103
|
+
width: '100%',
|
|
104
|
+
display: 'flex',
|
|
105
|
+
pointerEvents: 'none',
|
|
106
|
+
...style,
|
|
107
|
+
}, children: [_jsx(Arrow, { direction: "left", onClick: onPrevious, style: {
|
|
108
|
+
...(activeIndex === 0 && {
|
|
109
|
+
visibility: 'hidden',
|
|
110
|
+
pointerEvents: 'none',
|
|
111
|
+
}),
|
|
112
|
+
} }), _jsx(Arrow, { direction: "right", onClick: onNext, style: {
|
|
113
|
+
...(activeIndex === lastIndex && {
|
|
114
|
+
visibility: 'hidden',
|
|
115
|
+
pointerEvents: 'none',
|
|
116
|
+
}),
|
|
117
|
+
} })] }));
|
|
120
118
|
}
|
|
121
|
-
export default memo(NextPrev);
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Checkbox } from '@blueprintjs/core';
|
|
3
3
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
4
4
|
import { Filters, } from 'nmr-processing';
|
|
5
|
-
import { useRef, memo } from 'react';
|
|
5
|
+
import { useRef, memo, useCallback, useEffect } from 'react';
|
|
6
6
|
import { useForm } from 'react-hook-form';
|
|
7
7
|
import * as Yup from 'yup';
|
|
8
8
|
import { defaultApodizationOptions } from '../../data/constants/DefaultApodizationOptions';
|
|
@@ -26,16 +26,20 @@ const initialValues = {
|
|
|
26
26
|
function ApodizationOptionsInnerPanel(props) {
|
|
27
27
|
const dispatch = useDispatch();
|
|
28
28
|
const previousPreviewRef = useRef(initialValues.livePreview);
|
|
29
|
+
const onChange = useCallback((values) => {
|
|
30
|
+
const { livePreview, ...options } = values;
|
|
31
|
+
if (livePreview || previousPreviewRef.current !== livePreview) {
|
|
32
|
+
dispatch({
|
|
33
|
+
type: 'CALCULATE_APODIZATION_FILTER',
|
|
34
|
+
payload: { livePreview, options },
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}, [dispatch]);
|
|
29
38
|
function handleApplyFilter(values, triggerSource = 'apply') {
|
|
30
39
|
const { livePreview, ...options } = values;
|
|
31
40
|
switch (triggerSource) {
|
|
32
41
|
case 'onChange': {
|
|
33
|
-
|
|
34
|
-
dispatch({
|
|
35
|
-
type: 'CALCULATE_APODIZATION_FILTER',
|
|
36
|
-
payload: { livePreview, options },
|
|
37
|
-
});
|
|
38
|
-
}
|
|
42
|
+
onChange(values);
|
|
39
43
|
break;
|
|
40
44
|
}
|
|
41
45
|
case 'apply': {
|
|
@@ -68,6 +72,9 @@ function ApodizationOptionsInnerPanel(props) {
|
|
|
68
72
|
void handleSubmit((values) => handleApplyFilter(values, 'onChange'))();
|
|
69
73
|
}
|
|
70
74
|
const { onChange: onLivePreviewChange, ...otherLivePreviewOptions } = register('livePreview');
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
void handleSubmit((values) => onChange(values))();
|
|
77
|
+
}, [handleSubmit, onChange]);
|
|
71
78
|
return (_jsxs(HeaderContainer, { children: [_jsx(Label, { title: "Line broadening:", shortTitle: "LB:", style: headerLabelStyle, children: _jsx(NumberInput2Controller, { control: control, name: "lineBroadening", debounceTime: 250, min: 0, max: 1, stepSize: 0.1, style: { width: '60px' }, onValueChange: () => {
|
|
72
79
|
submitHandler();
|
|
73
80
|
} }) }), _jsx(Label, { title: "Gauss broadening:", shortTitle: "GB:", style: headerLabelStyle, children: _jsx(NumberInput2Controller, { control: control, name: "gaussBroadening", debounceTime: 250, min: 0, max: 1, stepSize: 0.1, style: { width: '60px' }, onValueChange: () => {
|
|
@@ -3,7 +3,7 @@ import { Checkbox } from '@blueprintjs/core';
|
|
|
3
3
|
import { Select } from '@blueprintjs/select';
|
|
4
4
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
5
5
|
import { Filters } from 'nmr-processing';
|
|
6
|
-
import { memo, useRef } from 'react';
|
|
6
|
+
import { memo, useCallback, useEffect, useRef } from 'react';
|
|
7
7
|
import { useForm } from 'react-hook-form';
|
|
8
8
|
import { Button, useSelect } from 'react-science/ui';
|
|
9
9
|
import * as Yup from 'yup';
|
|
@@ -73,19 +73,23 @@ function BaseLineCorrectionInnerPanel(props) {
|
|
|
73
73
|
defaultSelectedItem: algorithmsList.find((item) => item.value === baseAlgorithm),
|
|
74
74
|
itemTextKey: 'label',
|
|
75
75
|
});
|
|
76
|
+
const onChange = useCallback((values) => {
|
|
77
|
+
const { livePreview, ...options } = values;
|
|
78
|
+
if (livePreview || previousPreviewRef !== livePreview) {
|
|
79
|
+
dispatch({
|
|
80
|
+
type: 'CALCULATE_BASE_LINE_CORRECTION_FILTER',
|
|
81
|
+
payload: {
|
|
82
|
+
options,
|
|
83
|
+
livePreview,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}, [dispatch]);
|
|
76
88
|
const handleApplyFilter = (values, triggerSource = 'apply') => {
|
|
77
89
|
const { livePreview, ...options } = values;
|
|
78
90
|
switch (triggerSource) {
|
|
79
91
|
case 'onChange': {
|
|
80
|
-
|
|
81
|
-
dispatch({
|
|
82
|
-
type: 'CALCULATE_BASE_LINE_CORRECTION_FILTER',
|
|
83
|
-
payload: {
|
|
84
|
-
options,
|
|
85
|
-
livePreview,
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
}
|
|
92
|
+
onChange(values);
|
|
89
93
|
break;
|
|
90
94
|
}
|
|
91
95
|
case 'apply': {
|
|
@@ -116,6 +120,9 @@ function BaseLineCorrectionInnerPanel(props) {
|
|
|
116
120
|
void handleSubmit((values) => handleApplyFilter(values, 'onChange'))();
|
|
117
121
|
}
|
|
118
122
|
const { onChange: onLivePreviewChange, ...otherLivePreviewRegisterOptions } = register(`livePreview`);
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
void handleSubmit((values) => onChange(values))();
|
|
125
|
+
}, [handleSubmit, onChange]);
|
|
119
126
|
return (_jsxs(HeaderContainer, { children: [_jsx(Label, { title: "Algorithm: ", style: headerLabelStyle, children: _jsx(Select, { items: algorithmsList, filterable: false, itemsEqual: "value", onItemSelect: (item) => {
|
|
120
127
|
onItemSelect(item);
|
|
121
128
|
const { values } = getData(item.value, props?.filter?.value || {});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Checkbox } from '@blueprintjs/core';
|
|
3
3
|
import { Filters } from 'nmr-processing';
|
|
4
|
-
import { memo, useRef } from 'react';
|
|
4
|
+
import { memo, useCallback, useEffect, useRef } from 'react';
|
|
5
5
|
import { useForm } from 'react-hook-form';
|
|
6
6
|
import generateNumbersPowerOfX from '../../data/utilities/generateNumbersPowerOfX';
|
|
7
7
|
import { useDispatch } from '../context/DispatchContext';
|
|
@@ -31,19 +31,23 @@ function ZeroFillingOptionsInnerPanel(props) {
|
|
|
31
31
|
const { handleSubmit, register, control } = useForm({
|
|
32
32
|
defaultValues: { nbPoints: size, livePreview: true },
|
|
33
33
|
});
|
|
34
|
+
const onChange = useCallback((values) => {
|
|
35
|
+
const { livePreview, ...options } = values;
|
|
36
|
+
if (livePreview || previousPreviewRef !== livePreview) {
|
|
37
|
+
dispatch({
|
|
38
|
+
type: 'CALCULATE_ZERO_FILLING_FILTER',
|
|
39
|
+
payload: {
|
|
40
|
+
options,
|
|
41
|
+
livePreview,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}, [dispatch]);
|
|
34
46
|
function handleApplyFilter(values, triggerSource = 'apply') {
|
|
35
47
|
const { livePreview, ...options } = values;
|
|
36
48
|
switch (triggerSource) {
|
|
37
49
|
case 'onChange': {
|
|
38
|
-
|
|
39
|
-
dispatch({
|
|
40
|
-
type: 'CALCULATE_ZERO_FILLING_FILTER',
|
|
41
|
-
payload: {
|
|
42
|
-
options,
|
|
43
|
-
livePreview,
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
}
|
|
50
|
+
onChange(values);
|
|
47
51
|
break;
|
|
48
52
|
}
|
|
49
53
|
case 'apply': {
|
|
@@ -69,6 +73,9 @@ function ZeroFillingOptionsInnerPanel(props) {
|
|
|
69
73
|
function submitHandler(triggerSource = 'apply') {
|
|
70
74
|
void handleSubmit((values) => handleApplyFilter(values, triggerSource))();
|
|
71
75
|
}
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
void handleSubmit((values) => onChange(values))();
|
|
78
|
+
}, [handleSubmit, onChange]);
|
|
72
79
|
return (_jsxs(HeaderContainer, { children: [_jsx(Label, { title: "Size:", style: headerLabelStyle, children: _jsx(Select2Controller, { control: control, name: "nbPoints", items: sizes, onItemSelect: () => {
|
|
73
80
|
submitHandler('onChange');
|
|
74
81
|
} }) }), _jsx(Label, { title: "Live preview", style: { label: { padding: '0 5px' } }, children: _jsx(Checkbox, { style: { margin: 0 }, ...otherLivePreviewRegisterOptions, onChange: (event) => {
|