nmrium 0.19.1 → 0.20.1
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/Chart1D.js +3 -3
- package/lib/component/1d/ExclusionZoneAnnotation.d.ts +11 -0
- package/lib/component/1d/ExclusionZoneAnnotation.js +18 -0
- package/lib/component/1d/ExclusionZonesAnnotations.d.ts +3 -0
- package/lib/component/1d/ExclusionZonesAnnotations.js +28 -0
- package/lib/component/1d/Line.js +11 -23
- package/lib/component/1d/Viewer1D.js +36 -5
- package/lib/component/1d/ranges/Ranges.js +3 -3
- package/lib/component/1d/{BaseLineZones.d.ts → tool/BaseLineZones.d.ts} +0 -0
- package/lib/component/1d/{BaseLineZones.js → tool/BaseLineZones.js} +5 -5
- package/lib/component/1d/utilities/useIntegralPath.js +9 -10
- package/lib/component/2d/Contours.js +12 -11
- package/lib/component/2d/Left1DChart.js +7 -9
- package/lib/component/2d/Top1DChart.js +7 -7
- package/lib/component/2d/tools/slicing/HorizontalSliceChart.js +7 -7
- package/lib/component/2d/tools/slicing/VerticalSliceChart.js +7 -9
- package/lib/component/EventsTrackers/BrushTracker.js +2 -2
- package/lib/component/EventsTrackers/KeysListenerTracker.js +12 -3
- package/lib/component/NMRium.d.ts +1 -1
- package/lib/component/NMRium.js +28 -25
- package/lib/component/hooks/useActiveSpectrumStyleOptions.d.ts +6 -0
- package/lib/component/hooks/useActiveSpectrumStyleOptions.js +15 -0
- package/lib/component/hooks/useXYReduce.d.ts +2 -1
- package/lib/component/loader/DropZone.js +1 -1
- package/lib/component/modal/ModalStyle.js +5 -2
- package/lib/component/modal/MoleculeStructureEditorModal.js +3 -2
- package/lib/component/modal/MultipleSpectraFiltersModal/index.js +10 -1
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.d.ts +2 -0
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +35 -0
- package/lib/component/panels/MoleculesPanel/MoleculePanel.js +49 -67
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +3 -8
- package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +2 -23
- package/lib/component/panels/Panels.js +10 -0
- package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum2DHistogram.js +1 -1
- package/lib/component/panels/ZonesPanel/ZonesTable.js +9 -2
- package/lib/component/reducer/Reducer.d.ts +0 -16
- package/lib/component/reducer/Reducer.js +4 -5
- package/lib/component/reducer/actions/FiltersActions.d.ts +3 -1
- package/lib/component/reducer/actions/FiltersActions.js +60 -18
- package/lib/component/reducer/actions/LoadActions.js +2 -3
- package/lib/component/reducer/actions/MoleculeActions.js +2 -2
- package/lib/component/reducer/actions/PreferencesActions.js +4 -7
- package/lib/component/reducer/actions/RangesActions.js +1 -1
- package/lib/component/reducer/actions/ToolsActions.d.ts +1 -3
- package/lib/component/reducer/actions/ToolsActions.js +1 -30
- package/lib/component/reducer/helper/getRange.d.ts +6 -1
- package/lib/component/reducer/helper/getRange.js +1 -1
- package/lib/component/toolbar/FunctionToolBar.js +2 -5
- package/lib/component/utility/PathBuilder.d.ts +7 -0
- package/lib/component/utility/PathBuilder.js +17 -0
- package/lib/component/utility/getSpectraByNucleus.d.ts +3 -0
- package/lib/component/utility/getSpectraByNucleus.js +4 -0
- package/lib/data/Filters.d.ts +2 -1
- package/lib/data/Filters.js +2 -1
- package/lib/data/data1d/Spectrum1D/ranges/addRange.js +5 -2
- package/lib/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +6 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectRange.js +0 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectSignal.d.ts +3 -2
- package/lib/data/data1d/Spectrum1D/ranges/detectSignal.js +23 -15
- package/lib/data/data1d/filter1d/exclusionZones.d.ts +16 -0
- package/lib/data/data1d/filter1d/exclusionZones.js +28 -0
- package/lib/data/types/data1d/ExclusionZone.d.ts +5 -0
- package/lib/data/types/data1d/ExclusionZone.js +1 -0
- package/lib/versionInfo.js +1 -1
- package/lib-cjs/component/1d/Chart1D.js +3 -3
- package/lib-cjs/component/1d/ExclusionZoneAnnotation.js +23 -0
- package/lib-cjs/component/1d/ExclusionZonesAnnotations.js +52 -0
- package/lib-cjs/component/1d/Line.js +11 -23
- package/lib-cjs/component/1d/Viewer1D.js +36 -5
- package/lib-cjs/component/1d/ranges/Ranges.js +1 -1
- package/lib-cjs/component/1d/{BaseLineZones.js → tool/BaseLineZones.js} +5 -5
- package/lib-cjs/component/1d/utilities/useIntegralPath.js +9 -10
- package/lib-cjs/component/2d/Contours.js +12 -11
- package/lib-cjs/component/2d/Left1DChart.js +7 -9
- package/lib-cjs/component/2d/Top1DChart.js +7 -7
- package/lib-cjs/component/2d/tools/slicing/HorizontalSliceChart.js +7 -7
- package/lib-cjs/component/2d/tools/slicing/VerticalSliceChart.js +7 -9
- package/lib-cjs/component/EventsTrackers/BrushTracker.js +2 -2
- package/lib-cjs/component/EventsTrackers/KeysListenerTracker.js +12 -3
- package/lib-cjs/component/NMRium.js +28 -25
- package/lib-cjs/component/hooks/useActiveSpectrumStyleOptions.js +21 -0
- package/lib-cjs/component/loader/DropZone.js +1 -1
- package/lib-cjs/component/modal/ModalStyle.js +5 -2
- package/lib-cjs/component/modal/MoleculeStructureEditorModal.js +3 -2
- package/lib-cjs/component/modal/MultipleSpectraFiltersModal/index.js +10 -1
- package/lib-cjs/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +40 -0
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanel.js +48 -66
- package/lib-cjs/component/panels/MoleculesPanel/useAtomAssignment.js +3 -8
- package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +1 -22
- package/lib-cjs/component/panels/Panels.js +10 -0
- package/lib-cjs/component/panels/SpectrumsPanel/base/setting/Spectrum2DHistogram.js +1 -1
- package/lib-cjs/component/panels/ZonesPanel/ZonesTable.js +8 -1
- package/lib-cjs/component/reducer/Reducer.js +4 -5
- package/lib-cjs/component/reducer/actions/FiltersActions.js +62 -18
- package/lib-cjs/component/reducer/actions/LoadActions.js +2 -3
- package/lib-cjs/component/reducer/actions/MoleculeActions.js +2 -2
- package/lib-cjs/component/reducer/actions/PreferencesActions.js +4 -7
- package/lib-cjs/component/reducer/actions/RangesActions.js +1 -1
- package/lib-cjs/component/reducer/actions/ToolsActions.js +1 -32
- package/lib-cjs/component/reducer/helper/getRange.js +1 -1
- package/lib-cjs/component/toolbar/FunctionToolBar.js +2 -5
- package/lib-cjs/component/utility/PathBuilder.js +21 -0
- package/lib-cjs/component/utility/getSpectraByNucleus.js +11 -0
- package/lib-cjs/data/Filters.js +3 -1
- package/lib-cjs/data/data1d/Spectrum1D/ranges/addRange.js +5 -2
- package/lib-cjs/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +6 -1
- package/lib-cjs/data/data1d/Spectrum1D/ranges/detectRange.js +0 -1
- package/lib-cjs/data/data1d/Spectrum1D/ranges/detectSignal.js +24 -15
- package/lib-cjs/data/data1d/filter1d/exclusionZones.js +34 -0
- package/lib-cjs/data/types/data1d/ExclusionZone.js +2 -0
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +21 -21
- package/lib/component/1d/ExclusionZone.d.ts +0 -8
- package/lib/component/1d/ExclusionZone.js +0 -30
- package/lib/component/1d/ExclusionZones.d.ts +0 -2
- package/lib/component/1d/ExclusionZones.js +0 -10
- package/lib-cjs/component/1d/ExclusionZone.js +0 -32
- package/lib-cjs/component/1d/ExclusionZones.js +0 -16
|
@@ -23,51 +23,39 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
26
|
-
const get_1 = __importDefault(require("lodash/get"));
|
|
27
26
|
const react_1 = require("react");
|
|
28
27
|
const ChartContext_1 = require("../context/ChartContext");
|
|
29
|
-
const PreferencesContext_1 = require("../context/PreferencesContext");
|
|
30
28
|
const ScaleContext_1 = require("../context/ScaleContext");
|
|
29
|
+
const useActiveSpectrumStyleOptions_1 = __importDefault(require("../hooks/useActiveSpectrumStyleOptions"));
|
|
31
30
|
const useXYReduce_1 = __importStar(require("../hooks/useXYReduce"));
|
|
31
|
+
const PathBuilder_1 = require("../utility/PathBuilder");
|
|
32
32
|
const getVerticalShift_1 = __importDefault(require("./utilities/getVerticalShift"));
|
|
33
33
|
function Line({ data, id, display, index }) {
|
|
34
|
-
const {
|
|
35
|
-
const preferences = (0, PreferencesContext_1.usePreferences)();
|
|
34
|
+
const { verticalAlign } = (0, ChartContext_1.useChartData)();
|
|
36
35
|
const { scaleX, scaleY } = (0, ScaleContext_1.useScaleChecked)();
|
|
37
36
|
const xyReduce = (0, useXYReduce_1.default)(useXYReduce_1.XYReducerDomainAxis.XAxis);
|
|
38
|
-
const
|
|
39
|
-
return activeSpectrum === null
|
|
40
|
-
? true
|
|
41
|
-
: id === activeSpectrum.id
|
|
42
|
-
? true
|
|
43
|
-
: false;
|
|
44
|
-
}, [activeSpectrum, id]);
|
|
37
|
+
const { opacity } = (0, useActiveSpectrumStyleOptions_1.default)(id);
|
|
45
38
|
const vAlign = (0, react_1.useMemo)(() => {
|
|
46
39
|
return (0, getVerticalShift_1.default)(verticalAlign, { index });
|
|
47
40
|
}, [index, verticalAlign]);
|
|
48
41
|
const paths = (0, react_1.useMemo)(() => {
|
|
49
42
|
const _scaleX = scaleX();
|
|
50
43
|
const _scaleY = scaleY(id);
|
|
44
|
+
const pathBuilder = new PathBuilder_1.PathBuilder();
|
|
51
45
|
if (data?.x && data?.y && _scaleX(0)) {
|
|
52
46
|
const pathPoints = xyReduce(data);
|
|
53
|
-
|
|
54
|
-
let
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
accumulator += ` L ${_scaleX(point)} ${_scaleY(pathPoints.y[i + 1])}`;
|
|
59
|
-
return accumulator;
|
|
60
|
-
}, '');
|
|
61
|
-
return path;
|
|
47
|
+
pathBuilder.moveTo(_scaleX(pathPoints.x[0]), _scaleY(pathPoints.y[0]));
|
|
48
|
+
for (let i = 1; i < pathPoints.x.length; i++) {
|
|
49
|
+
pathBuilder.lineTo(_scaleX(pathPoints.x[i]), _scaleY(pathPoints.y[i]));
|
|
50
|
+
}
|
|
51
|
+
return pathBuilder.toString();
|
|
62
52
|
}
|
|
63
53
|
else {
|
|
64
54
|
return '';
|
|
65
55
|
}
|
|
66
56
|
}, [scaleX, scaleY, id, data, xyReduce]);
|
|
67
57
|
return ((0, jsx_runtime_1.jsx)("path", { className: "line", "data-test-id": "spectrum-line", stroke: display.color, fill: "none", style: {
|
|
68
|
-
opacity
|
|
69
|
-
? 1
|
|
70
|
-
: (0, get_1.default)(preferences, 'controllers.dimmedSpectraTransparency', 0.1),
|
|
58
|
+
opacity,
|
|
71
59
|
}, d: paths, transform: `translate(0,-${vAlign})` }, id));
|
|
72
60
|
}
|
|
73
61
|
exports.default = Line;
|
|
@@ -23,8 +23,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
26
|
+
const ml_spectra_processing_1 = require("ml-spectra-processing");
|
|
26
27
|
const react_1 = require("react");
|
|
27
28
|
const react_d3_utils_1 = require("react-d3-utils");
|
|
29
|
+
const detectSignal_1 = require("../../data/data1d/Spectrum1D/ranges/detectSignal");
|
|
28
30
|
const Viewer2D_1 = require("../2d/Viewer2D");
|
|
29
31
|
const BrushTracker_1 = require("../EventsTrackers/BrushTracker");
|
|
30
32
|
const MouseTracker_1 = require("../EventsTrackers/MouseTracker");
|
|
@@ -32,10 +34,12 @@ const ChartContext_1 = require("../context/ChartContext");
|
|
|
32
34
|
const DispatchContext_1 = require("../context/DispatchContext");
|
|
33
35
|
const PreferencesContext_1 = require("../context/PreferencesContext");
|
|
34
36
|
const ScaleContext_1 = require("../context/ScaleContext");
|
|
37
|
+
const Alert_1 = require("../elements/popup/Alert");
|
|
35
38
|
const Modal_1 = require("../elements/popup/Modal");
|
|
36
39
|
const Spinner_1 = __importDefault(require("../loader/Spinner"));
|
|
37
40
|
const MultipletAnalysisModal_1 = __importDefault(require("../modal/MultipletAnalysisModal"));
|
|
38
41
|
const Zoom_1 = require("../reducer/actions/Zoom");
|
|
42
|
+
const getRange_1 = __importDefault(require("../reducer/helper/getRange"));
|
|
39
43
|
const scaleReducer_1 = __importStar(require("../reducer/scaleReducer"));
|
|
40
44
|
const Types_1 = require("../reducer/types/Types");
|
|
41
45
|
const BrushXY_1 = __importStar(require("../tool/BrushXY"));
|
|
@@ -54,6 +58,7 @@ function Viewer1D({ emptyText = undefined }) {
|
|
|
54
58
|
const { toolOptions: { selectedTool }, isLoading, data, mode, width: widthProp, height: heightProp, margin, activeSpectrum, xDomain, xDomains, yDomain, yDomains, verticalAlign, displayerKey, } = state;
|
|
55
59
|
const dispatch = (0, DispatchContext_1.useDispatch)();
|
|
56
60
|
const modal = (0, Modal_1.useModal)();
|
|
61
|
+
const alert = (0, Alert_1.useAlert)();
|
|
57
62
|
const [scaleState, dispatchScale] = (0, react_1.useReducer)(scaleReducer_1.default, scaleReducer_1.scaleInitialState);
|
|
58
63
|
(0, react_1.useEffect)(() => {
|
|
59
64
|
if (xDomain.length > 0 && yDomain.length > 0 && widthProp && heightProp) {
|
|
@@ -119,12 +124,28 @@ function Viewer1D({ emptyText = undefined }) {
|
|
|
119
124
|
...brushData,
|
|
120
125
|
});
|
|
121
126
|
break;
|
|
122
|
-
case ToolTypes_1.options.rangesPicking.id:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
127
|
+
case ToolTypes_1.options.rangesPicking.id: {
|
|
128
|
+
const [from, to] = (0, getRange_1.default)(state, {
|
|
129
|
+
startX: brushData.startX,
|
|
130
|
+
endX: brushData.endX,
|
|
126
131
|
});
|
|
132
|
+
if (!activeSpectrum)
|
|
133
|
+
break;
|
|
134
|
+
const { data: { x }, } = state.data[activeSpectrum.index];
|
|
135
|
+
const { fromIndex, toIndex } = (0, ml_spectra_processing_1.xGetFromToIndex)(x, { from, to });
|
|
136
|
+
if (toIndex - fromIndex <= detectSignal_1.MAX_LENGTH) {
|
|
137
|
+
dispatch({
|
|
138
|
+
type: Types_1.ADD_RANGE,
|
|
139
|
+
payload: {
|
|
140
|
+
...brushData,
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
alert.error(`Advanced peak picking only available for area up to ${detectSignal_1.MAX_LENGTH} points`);
|
|
146
|
+
}
|
|
127
147
|
break;
|
|
148
|
+
}
|
|
128
149
|
case ToolTypes_1.options.multipleSpectraAnalysis.id:
|
|
129
150
|
dispatch({
|
|
130
151
|
type: Types_1.ANALYZE_SPECTRA,
|
|
@@ -163,7 +184,17 @@ function Viewer1D({ emptyText = undefined }) {
|
|
|
163
184
|
break;
|
|
164
185
|
}
|
|
165
186
|
}
|
|
166
|
-
}, [
|
|
187
|
+
}, [
|
|
188
|
+
scaleState,
|
|
189
|
+
selectedTool,
|
|
190
|
+
general.disableMultipletAnalysis,
|
|
191
|
+
modal,
|
|
192
|
+
data,
|
|
193
|
+
activeSpectrum,
|
|
194
|
+
dispatch,
|
|
195
|
+
state,
|
|
196
|
+
alert,
|
|
197
|
+
]);
|
|
167
198
|
const handelOnDoubleClick = (0, react_1.useCallback)(() => {
|
|
168
199
|
dispatch({ type: Types_1.FULL_ZOOM_OUT, zoomType: Zoom_1.ZoomType.STEP_HORIZONTAL });
|
|
169
200
|
}, [dispatch]);
|
|
@@ -10,7 +10,7 @@ const useSpectrum_1 = __importDefault(require("../../hooks/useSpectrum"));
|
|
|
10
10
|
const Range_1 = __importDefault(require("./Range"));
|
|
11
11
|
const RangeIntegral_1 = __importDefault(require("./RangeIntegral"));
|
|
12
12
|
function RangesInner({ ranges, displayerKey, selectedTool, editRangeID, showMultiplicityTrees, showRangesIntegrals, }) {
|
|
13
|
-
return ((0, jsx_runtime_1.jsx)("g", { clipPath: `url(#${displayerKey}clip-chart-1d)`, children: ranges?.values?.map((range) => ((0, jsx_runtime_1.jsxs)(
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)("g", { clipPath: `url(#${displayerKey}clip-chart-1d)`, children: ranges?.values?.map((range) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Range_1.default, { rangeData: range, selectedTool: selectedTool, showMultiplicityTrees: showMultiplicityTrees, startEditMode: editRangeID && editRangeID === range.id ? true : false }, void 0), showRangesIntegrals && (0, jsx_runtime_1.jsx)(RangeIntegral_1.default, { range: range }, void 0)] }, range.id))) }, void 0));
|
|
14
14
|
}
|
|
15
15
|
const MemoizedRanges = (0, react_1.memo)(RangesInner);
|
|
16
16
|
const empyData = { ranges: {} };
|
|
@@ -7,11 +7,11 @@ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
|
7
7
|
/** @jsxImportSource @emotion/react */
|
|
8
8
|
const react_1 = require("@emotion/react");
|
|
9
9
|
const react_2 = require("react");
|
|
10
|
-
const ChartContext_1 = require("
|
|
11
|
-
const DispatchContext_1 = require("
|
|
12
|
-
const ScaleContext_1 = require("
|
|
13
|
-
const DeleteButton_1 = __importDefault(require("
|
|
14
|
-
const Types_1 = require("
|
|
10
|
+
const ChartContext_1 = require("../../context/ChartContext");
|
|
11
|
+
const DispatchContext_1 = require("../../context/DispatchContext");
|
|
12
|
+
const ScaleContext_1 = require("../../context/ScaleContext");
|
|
13
|
+
const DeleteButton_1 = __importDefault(require("../../elements/DeleteButton"));
|
|
14
|
+
const Types_1 = require("../../reducer/types/Types");
|
|
15
15
|
const styles = (0, react_1.css) `
|
|
16
16
|
pointer-events: bounding-box;
|
|
17
17
|
user-select: 'none';
|
|
@@ -4,6 +4,7 @@ const ml_spectra_processing_1 = require("ml-spectra-processing");
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const ChartContext_1 = require("../../context/ChartContext");
|
|
6
6
|
const ScaleContext_1 = require("../../context/ScaleContext");
|
|
7
|
+
const PathBuilder_1 = require("../../utility/PathBuilder");
|
|
7
8
|
const scale_1 = require("./scale");
|
|
8
9
|
function useIntegralPath(integralOptions) {
|
|
9
10
|
const { xDomain, height, yDomain, margin, verticalAlign, data, activeSpectrum, zoom, } = (0, ChartContext_1.useChartData)();
|
|
@@ -41,27 +42,25 @@ function useIntegralPath(integralOptions) {
|
|
|
41
42
|
}
|
|
42
43
|
return { x: [], y: [] };
|
|
43
44
|
}, [activeSpectrum, data, integralOptions]);
|
|
44
|
-
const
|
|
45
|
+
const paths = (0, react_1.useMemo)(() => {
|
|
45
46
|
if (integral && scaleX) {
|
|
46
|
-
// @ts-expect-error Types will be fixed in ml-spectra-processing.
|
|
47
47
|
const xySeries = (0, ml_spectra_processing_1.xyReduce)(integral, {
|
|
48
48
|
from: xDomain[0],
|
|
49
49
|
to: xDomain[1],
|
|
50
50
|
nbPoints: 200,
|
|
51
51
|
optimize: true,
|
|
52
52
|
});
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return path;
|
|
53
|
+
const pathBuilder = new PathBuilder_1.PathBuilder();
|
|
54
|
+
pathBuilder.moveTo(scaleX()(xySeries.x[0]), scaleY(xySeries.y[0]));
|
|
55
|
+
for (let i = 1; i < xySeries.x.length; i++) {
|
|
56
|
+
pathBuilder.lineTo(scaleX()(xySeries.x[i]), scaleY(xySeries.y[i]));
|
|
57
|
+
}
|
|
58
|
+
return pathBuilder.toString();
|
|
60
59
|
}
|
|
61
60
|
else {
|
|
62
61
|
return '';
|
|
63
62
|
}
|
|
64
63
|
}, [integral, scaleX, scaleY, xDomain]);
|
|
65
|
-
return
|
|
64
|
+
return paths;
|
|
66
65
|
}
|
|
67
66
|
exports.default = useIntegralPath;
|
|
@@ -6,12 +6,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
7
|
const get_1 = __importDefault(require("lodash/get"));
|
|
8
8
|
const react_1 = require("react");
|
|
9
|
+
const Spectrum2D_1 = require("../../data/data2d/Spectrum2D");
|
|
9
10
|
const ChartContext_1 = require("../context/ChartContext");
|
|
10
11
|
const PreferencesContext_1 = require("../context/PreferencesContext");
|
|
12
|
+
const PathBuilder_1 = require("../utility/PathBuilder");
|
|
11
13
|
const scale_1 = require("./utilities/scale");
|
|
12
|
-
function ContoursPaths({ id: spectrumID, sign, color }) {
|
|
14
|
+
function ContoursPaths({ id: spectrumID, sign, color, datum, }) {
|
|
13
15
|
const { margin, width, height, xDomain, yDomain, contours, activeSpectrum } = (0, ChartContext_1.useChartData)();
|
|
14
16
|
const preferences = (0, PreferencesContext_1.usePreferences)();
|
|
17
|
+
const { xShift, yShift } = (0, Spectrum2D_1.getShift)(datum);
|
|
15
18
|
const isActive = (0, react_1.useMemo)(() => {
|
|
16
19
|
return activeSpectrum === null
|
|
17
20
|
? true
|
|
@@ -22,28 +25,26 @@ function ContoursPaths({ id: spectrumID, sign, color }) {
|
|
|
22
25
|
function buildContourPath(data) {
|
|
23
26
|
const _scaleX = (0, scale_1.get2DXScale)({ margin, width, xDomain });
|
|
24
27
|
const _scaleY = (0, scale_1.get2DYScale)({ margin, height, yDomain });
|
|
25
|
-
|
|
28
|
+
const path = new PathBuilder_1.PathBuilder();
|
|
26
29
|
for (const element of data) {
|
|
27
30
|
if (element.lines) {
|
|
28
31
|
const lines = element.lines;
|
|
29
32
|
if (lines.length < 1e6) {
|
|
30
33
|
for (let i = 0; i < lines.length; i += 4) {
|
|
31
|
-
path
|
|
32
|
-
path
|
|
34
|
+
path.moveTo(_scaleX(lines[i] + xShift), _scaleY(lines[i + 1] + yShift));
|
|
35
|
+
path.lineTo(_scaleX(lines[i + 2] + xShift), _scaleY(lines[i + 3] + yShift));
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
39
|
else {
|
|
37
|
-
path
|
|
40
|
+
path.moveTo(_scaleX(element[0].x + xShift), _scaleY(element[0].y + yShift));
|
|
38
41
|
for (let j = 1; j < element.length; j++) {
|
|
39
|
-
path
|
|
42
|
+
path.lineTo(_scaleX(element[j].x + xShift), _scaleY(element[j].y + yShift));
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
path += 'Z';
|
|
46
|
-
return path;
|
|
46
|
+
path.closePath();
|
|
47
|
+
return path.toString();
|
|
47
48
|
}
|
|
48
49
|
const data = (0, react_1.useMemo)(() => {
|
|
49
50
|
return (0, get_1.default)(contours, `${spectrumID}.${sign}`, []);
|
|
@@ -55,7 +56,7 @@ function ContoursPaths({ id: spectrumID, sign, color }) {
|
|
|
55
56
|
}, d: buildContourPath(data) }, void 0));
|
|
56
57
|
}
|
|
57
58
|
function ContoursInner({ data, displayerKey }) {
|
|
58
|
-
return ((0, jsx_runtime_1.jsx)("g", { clipPath: `url(#${displayerKey}clip-chart-2d)`, className: "contours", children: data?.map((datum, index) => ((0, jsx_runtime_1.jsxs)("g", { children: [datum.display.isPositiveVisible && ((0, jsx_runtime_1.jsx)(ContoursPaths, { id: datum.id, sign: "positive", color: datum.display.positiveColor }, void 0)), datum.display.isNegativeVisible && ((0, jsx_runtime_1.jsx)(ContoursPaths, { id: datum.id, sign: "negative", color: datum.display.negativeColor }, void 0))] }, `${datum.id + index}`))) }, void 0));
|
|
59
|
+
return ((0, jsx_runtime_1.jsx)("g", { clipPath: `url(#${displayerKey}clip-chart-2d)`, className: "contours", children: data?.map((datum, index) => ((0, jsx_runtime_1.jsxs)("g", { children: [datum.display.isPositiveVisible && ((0, jsx_runtime_1.jsx)(ContoursPaths, { id: datum.id, sign: "positive", datum: datum, color: datum.display.positiveColor }, void 0)), datum.display.isNegativeVisible && ((0, jsx_runtime_1.jsx)(ContoursPaths, { id: datum.id, sign: "negative", datum: datum, color: datum.display.negativeColor }, void 0))] }, `${datum.id + index}`))) }, void 0));
|
|
59
60
|
}
|
|
60
61
|
const MemoizedContours = (0, react_1.memo)(ContoursInner);
|
|
61
62
|
function Contours() {
|
|
@@ -23,6 +23,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
23
23
|
const react_1 = require("react");
|
|
24
24
|
const ChartContext_1 = require("../context/ChartContext");
|
|
25
25
|
const useXYReduce_1 = __importStar(require("../hooks/useXYReduce"));
|
|
26
|
+
const PathBuilder_1 = require("../utility/PathBuilder");
|
|
26
27
|
const scale_1 = require("./utilities/scale");
|
|
27
28
|
function Left1DChart({ margin: marignValue = 10, data: spectrum, }) {
|
|
28
29
|
const { height: originHeight, margin, yDomain, yDomains, displayerKey, } = (0, ChartContext_1.useChartData)();
|
|
@@ -38,15 +39,12 @@ function Left1DChart({ margin: marignValue = 10, data: spectrum, }) {
|
|
|
38
39
|
const scaleY = (0, scale_1.get1DYScale)(yDomains[spectrum.id], height, marignValue);
|
|
39
40
|
const { x, re: y } = spectrum.data;
|
|
40
41
|
const pathPoints = xyReduce({ x, y });
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
let
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return accumulator;
|
|
48
|
-
}, '');
|
|
49
|
-
return path;
|
|
42
|
+
const pathBuilder = new PathBuilder_1.PathBuilder();
|
|
43
|
+
pathBuilder.moveTo(scaleY(pathPoints.y[pathPoints.y.length - 1]), scaleX(pathPoints.x.length - 1));
|
|
44
|
+
for (let i = pathPoints.x.length - 2; i >= 0; i--) {
|
|
45
|
+
pathBuilder.lineTo(scaleY(pathPoints.y[i]), scaleX(pathPoints.x[i]));
|
|
46
|
+
}
|
|
47
|
+
return pathBuilder.toString();
|
|
50
48
|
}
|
|
51
49
|
else {
|
|
52
50
|
return undefined;
|
|
@@ -23,6 +23,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
23
23
|
const react_1 = require("react");
|
|
24
24
|
const ChartContext_1 = require("../context/ChartContext");
|
|
25
25
|
const useXYReduce_1 = __importStar(require("../hooks/useXYReduce"));
|
|
26
|
+
const PathBuilder_1 = require("../utility/PathBuilder");
|
|
26
27
|
const scale_1 = require("./utilities/scale");
|
|
27
28
|
function Top1DChart({ margin: marginProps = 10, data: spectrum, }) {
|
|
28
29
|
const { width, margin: originMargin, xDomain, yDomains, displayerKey, } = (0, ChartContext_1.useChartData)();
|
|
@@ -34,13 +35,12 @@ function Top1DChart({ margin: marginProps = 10, data: spectrum, }) {
|
|
|
34
35
|
const scaleY = (0, scale_1.get1DYScale)(yDomains[spectrum.id], height, marginProps);
|
|
35
36
|
const { x, re: y } = spectrum.data;
|
|
36
37
|
const pathPoints = xyReduce({ x, y });
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return path;
|
|
38
|
+
const pathBuilder = new PathBuilder_1.PathBuilder();
|
|
39
|
+
pathBuilder.moveTo(scaleX(pathPoints.x[0]), scaleY(pathPoints.y[0]));
|
|
40
|
+
for (let i = 1; i < pathPoints.x.length; i++) {
|
|
41
|
+
pathBuilder.lineTo(scaleX(pathPoints.x[i]), scaleY(pathPoints.y[i]));
|
|
42
|
+
}
|
|
43
|
+
return pathBuilder.toString();
|
|
44
44
|
}
|
|
45
45
|
else {
|
|
46
46
|
return undefined;
|
|
@@ -23,6 +23,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
23
23
|
const react_1 = require("react");
|
|
24
24
|
const ChartContext_1 = require("../../../context/ChartContext");
|
|
25
25
|
const useXYReduce_1 = __importStar(require("../../../hooks/useXYReduce"));
|
|
26
|
+
const PathBuilder_1 = require("../../../utility/PathBuilder");
|
|
26
27
|
const scale_1 = require("../../utilities/scale");
|
|
27
28
|
const SliceScale_1 = require("./SliceScale");
|
|
28
29
|
function HorizontalSliceChart({ margin: marginProps = 10, data, }) {
|
|
@@ -35,13 +36,12 @@ function HorizontalSliceChart({ margin: marginProps = 10, data, }) {
|
|
|
35
36
|
const scaleX = (0, scale_1.get2DXScale)({ margin: originMargin, width, xDomain });
|
|
36
37
|
const scaleY = (0, SliceScale_1.getYScale)(height, y, marginProps);
|
|
37
38
|
const pathPoints = xyReduce({ x, y });
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return path;
|
|
39
|
+
const pathBuilder = new PathBuilder_1.PathBuilder();
|
|
40
|
+
pathBuilder.moveTo(scaleX(pathPoints.x[0]), scaleY(pathPoints.y[0]));
|
|
41
|
+
for (let i = 1; i < pathPoints.x.length; i++) {
|
|
42
|
+
pathBuilder.lineTo(scaleX(pathPoints.x[i]), scaleY(pathPoints.y[i]));
|
|
43
|
+
}
|
|
44
|
+
return pathBuilder.toString();
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
47
|
return undefined;
|
|
@@ -23,6 +23,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
23
23
|
const react_1 = require("react");
|
|
24
24
|
const ChartContext_1 = require("../../../context/ChartContext");
|
|
25
25
|
const useXYReduce_1 = __importStar(require("../../../hooks/useXYReduce"));
|
|
26
|
+
const PathBuilder_1 = require("../../../utility/PathBuilder");
|
|
26
27
|
const scale_1 = require("../../utilities/scale");
|
|
27
28
|
const SliceScale_1 = require("./SliceScale");
|
|
28
29
|
function VerticalSliceChart({ margin: marignValue = 10, data, }) {
|
|
@@ -35,15 +36,12 @@ function VerticalSliceChart({ margin: marignValue = 10, data, }) {
|
|
|
35
36
|
const scaleX = (0, scale_1.get2DYScale)({ height: originHeight, margin, yDomain });
|
|
36
37
|
const scaleY = (0, SliceScale_1.getYScale)(height, y, marignValue);
|
|
37
38
|
const pathPoints = xyReduce({ x, y });
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return accumulator;
|
|
45
|
-
}, '');
|
|
46
|
-
return path;
|
|
39
|
+
const pathBuilder = new PathBuilder_1.PathBuilder();
|
|
40
|
+
pathBuilder.moveTo(scaleY(pathPoints.y[pathPoints.y.length - 1]), scaleX(pathPoints.x.length - 1));
|
|
41
|
+
for (let i = pathPoints.x.length - 2; i >= 0; i--) {
|
|
42
|
+
pathBuilder.lineTo(scaleY(pathPoints.y[i]), scaleX(pathPoints.x[i]));
|
|
43
|
+
}
|
|
44
|
+
return pathBuilder.toString();
|
|
47
45
|
}
|
|
48
46
|
else {
|
|
49
47
|
return undefined;
|
|
@@ -72,8 +72,8 @@ function BrushTracker({ children, className, style, onBrush = () => null, onZoom
|
|
|
72
72
|
onZoom({ deltaY: deltaY || deltaX, shiftKey, deltaMode, x, y });
|
|
73
73
|
}, [onZoom]);
|
|
74
74
|
(0, react_1.useEffect)(() => {
|
|
75
|
-
const { step, startX, endX } = state;
|
|
76
|
-
if (step === 'end' && Math.
|
|
75
|
+
const { step, startX, endX, startY, endY } = state;
|
|
76
|
+
if (step === 'end' && Math.hypot(endX - startX, endY - startY) > 5) {
|
|
77
77
|
onBrush(state);
|
|
78
78
|
dispatch({
|
|
79
79
|
type: 'DONE',
|
|
@@ -31,7 +31,7 @@ function KeysListenerTracker() {
|
|
|
31
31
|
const allow2DTool = (0, react_1.useMemo)(() => {
|
|
32
32
|
return displayerMode === Constants_1.DISPLAYER_MODE.DM_2D && data && data.length > 0;
|
|
33
33
|
}, [data, displayerMode]);
|
|
34
|
-
const deleteHandler = (0, react_1.useCallback)((sourceData) => {
|
|
34
|
+
const deleteHandler = (0, react_1.useCallback)(async (sourceData) => {
|
|
35
35
|
const { type, extra: { id }, } = sourceData;
|
|
36
36
|
switch (type) {
|
|
37
37
|
case index_1.HighlightedSource.INTEGRAL: {
|
|
@@ -79,12 +79,15 @@ function KeysListenerTracker() {
|
|
|
79
79
|
break;
|
|
80
80
|
}
|
|
81
81
|
case index_1.HighlightedSource.EXCLUSION_ZONE: {
|
|
82
|
+
const hideLoading = await alert.showLoading(`Exclusion filter in progress`);
|
|
82
83
|
dispatch({
|
|
83
84
|
type: Types_1.DELETE_EXCLUSION_ZONE,
|
|
84
85
|
payload: {
|
|
85
86
|
id,
|
|
87
|
+
spectrumID: sourceData.extra.spectrumID,
|
|
86
88
|
},
|
|
87
89
|
});
|
|
90
|
+
hideLoading();
|
|
88
91
|
// remove keys from the highlighted list after delete
|
|
89
92
|
remove();
|
|
90
93
|
break;
|
|
@@ -92,7 +95,7 @@ function KeysListenerTracker() {
|
|
|
92
95
|
default:
|
|
93
96
|
break;
|
|
94
97
|
}
|
|
95
|
-
}, [assignmentData, dispatch, remove]);
|
|
98
|
+
}, [assignmentData, dispatch, remove, alert]);
|
|
96
99
|
const keysPreferencesListenerHandler = (0, react_1.useCallback)((e, num) => {
|
|
97
100
|
if (data && data.length > 0 && num >= 1 && num <= 9) {
|
|
98
101
|
if (e.shiftKey) {
|
|
@@ -164,6 +167,12 @@ function KeysListenerTracker() {
|
|
|
164
167
|
}
|
|
165
168
|
break;
|
|
166
169
|
}
|
|
170
|
+
case 'e': {
|
|
171
|
+
if (allow1DTool) {
|
|
172
|
+
handleChangeOption(ToolTypes_1.options.exclusionZones.id);
|
|
173
|
+
}
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
167
176
|
default:
|
|
168
177
|
}
|
|
169
178
|
}
|
|
@@ -233,7 +242,7 @@ function KeysListenerTracker() {
|
|
|
233
242
|
else {
|
|
234
243
|
if (['Delete', 'Backspace'].includes(e.key) && highlight.sourceData) {
|
|
235
244
|
e.preventDefault();
|
|
236
|
-
deleteHandler(highlight.sourceData);
|
|
245
|
+
void deleteHandler(highlight.sourceData);
|
|
237
246
|
}
|
|
238
247
|
else {
|
|
239
248
|
toolsListenerHandler(e);
|
|
@@ -131,7 +131,10 @@ const defaultPreferences = {};
|
|
|
131
131
|
const defaultData = {
|
|
132
132
|
spectra: [],
|
|
133
133
|
};
|
|
134
|
-
function NMRium(
|
|
134
|
+
function NMRium(props) {
|
|
135
|
+
return ((0, jsx_runtime_1.jsx)(analysis_ui_components_1.RootLayout, { style: { width: '100%' }, children: (0, jsx_runtime_1.jsx)(react_error_boundary_1.ErrorBoundary, { FallbackComponent: ErrorOverlay_1.default, children: (0, jsx_runtime_1.jsx)(InnerNMRium, { ...props }, void 0) }, void 0) }, void 0));
|
|
136
|
+
}
|
|
137
|
+
function InnerNMRium({ data: dataProp = defaultData, mode = NMRiumMode.DEFAULT, preferences = defaultPreferences, getSpinner = SpinnerContext_1.defaultGetSpinner, onDataChange, emptyText, }) {
|
|
135
138
|
const rootRef = (0, react_2.useRef)(null);
|
|
136
139
|
const elementsWraperRef = (0, react_2.useRef)(null);
|
|
137
140
|
const [show, toggle] = (0, react_use_1.useToggle)(false);
|
|
@@ -181,30 +184,30 @@ function NMRium({ data: dataProp = defaultData, mode = NMRiumMode.DEFAULT, prefe
|
|
|
181
184
|
const mouseLeaveHandler = (0, react_2.useCallback)(() => {
|
|
182
185
|
dispatchMiddleWare({ type: Types_1.SET_MOUSE_OVER_DISPLAYER, payload: false });
|
|
183
186
|
}, [dispatchMiddleWare]);
|
|
184
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
187
|
+
return ((0, jsx_runtime_1.jsx)(GlobalContext_1.GlobalProvider, { value: {
|
|
188
|
+
rootRef: rootRef.current,
|
|
189
|
+
elementsWraperRef: elementsWraperRef.current,
|
|
190
|
+
}, children: (0, jsx_runtime_1.jsx)(PreferencesContext_1.PreferencesProvider, { value: preferencesState, children: (0, jsx_runtime_1.jsx)("div", { onMouseEnter: mouseEnterHandler, onMouseLeave: mouseLeaveHandler, style: { height: '100%', position: 'relative' }, children: (0, jsx_runtime_1.jsx)(Alert_1.AlertProvider, { wrapperRef: elementsWraperRef.current, children: (0, jsx_runtime_1.jsx)(DispatchContext_1.DispatchProvider, { value: dispatchMiddleWare, children: (0, jsx_runtime_1.jsx)(ChartContext_1.ChartDataProvider, { value: state, children: (0, jsx_runtime_1.jsx)(Modal_1.ModalProvider, { wrapperRef: elementsWraperRef.current, children: (0, jsx_runtime_1.jsx)(highlight_1.HighlightProvider, { children: (0, jsx_runtime_1.jsx)(assignment_1.AssignmentProvider, { spectraData: spectraData, children: (0, jsx_runtime_1.jsx)(SpinnerContext_1.SpinnerProvider, { value: getSpinner, children: (0, jsx_runtime_1.jsx)("div", { className: "nmrium-container", ref: rootRef, css: containerStyles, onContextMenu: preventContextMenuHandler, style: { height: '100%', width: '100%' }, children: (0, jsx_runtime_1.jsx)(DropZone_1.default, { children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
191
|
+
display: 'flex',
|
|
192
|
+
flexDirection: 'column',
|
|
193
|
+
backgroundColor: 'white',
|
|
194
|
+
width: '100%',
|
|
195
|
+
}, children: [(0, jsx_runtime_1.jsx)(Header_1.default, { isFullscreen: isFullscreen, onMaximize: toggle }, void 0), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
188
196
|
display: 'flex',
|
|
189
|
-
flexDirection: '
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
left: 0,
|
|
205
|
-
right: 0,
|
|
206
|
-
top: 0,
|
|
207
|
-
bottom: 0,
|
|
208
|
-
} }, String(isFullscreen))] }, void 0)] }, void 0) }, void 0) }, void 0) }, void 0) }, void 0) }, void 0) }, void 0) }, void 0) }, void 0) }, void 0) }, void 0) }, void 0) }, void 0) }, void 0) }, void 0));
|
|
197
|
+
flexDirection: 'row',
|
|
198
|
+
height: '100%',
|
|
199
|
+
}, children: [(0, jsx_runtime_1.jsx)(ToolBar_1.default, {}, void 0), (0, jsx_runtime_1.jsxs)(analysis_ui_components_1.SplitPane, { initialSeparation: "590px", orientation: "horizontal", sideSeparation: "end", children: [(0, jsx_runtime_1.jsxs)("div", { css: viewerContainerStyle, children: [(0, jsx_runtime_1.jsx)(KeysListenerTracker_1.default, {}, void 0), (0, jsx_runtime_1.jsx)("div", { "data-test-id": "viewer", style: {
|
|
200
|
+
width: '100%',
|
|
201
|
+
height: '100%',
|
|
202
|
+
}, children: displayerMode ===
|
|
203
|
+
Constants_1.DISPLAYER_MODE.DM_1D ? ((0, jsx_runtime_1.jsx)(Viewer1D_1.default, { emptyText: emptyText }, void 0)) : ((0, jsx_runtime_1.jsx)(Viewer2D_1.default, { emptyText: emptyText }, void 0)) }, void 0)] }, void 0), (0, jsx_runtime_1.jsx)(Panels_1.default, {}, void 0)] }, void 0), (0, jsx_runtime_1.jsx)("div", { ref: elementsWraperRef, id: "main-wrapper", style: {
|
|
204
|
+
position: 'absolute',
|
|
205
|
+
pointerEvents: 'none',
|
|
206
|
+
zIndex: 0,
|
|
207
|
+
left: 0,
|
|
208
|
+
right: 0,
|
|
209
|
+
top: 0,
|
|
210
|
+
bottom: 0,
|
|
211
|
+
} }, String(isFullscreen))] }, void 0)] }, void 0) }, void 0) }, void 0) }, void 0) }, void 0) }, void 0) }, void 0) }, void 0) }, void 0) }, void 0) }, void 0) }, void 0) }, void 0));
|
|
209
212
|
}
|
|
210
213
|
exports.default = (0, react_2.memo)(NMRium);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const get_1 = __importDefault(require("lodash/get"));
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const ChartContext_1 = require("../context/ChartContext");
|
|
9
|
+
const PreferencesContext_1 = require("../context/PreferencesContext");
|
|
10
|
+
function useActiveSpectrumStyleOptions(id) {
|
|
11
|
+
const { activeSpectrum } = (0, ChartContext_1.useChartData)();
|
|
12
|
+
const preferences = (0, PreferencesContext_1.usePreferences)();
|
|
13
|
+
return (0, react_1.useMemo)(() => {
|
|
14
|
+
const isActive = activeSpectrum === null ? true : id === activeSpectrum.id ? true : false;
|
|
15
|
+
const opacity = isActive
|
|
16
|
+
? 1
|
|
17
|
+
: (0, get_1.default)(preferences, 'controllers.dimmedSpectraTransparency', 0.1);
|
|
18
|
+
return { isActive, opacity };
|
|
19
|
+
}, [activeSpectrum, id, preferences]);
|
|
20
|
+
}
|
|
21
|
+
exports.default = useActiveSpectrumStyleOptions;
|
|
@@ -204,7 +204,7 @@ function DropZone(props) {
|
|
|
204
204
|
const open = (0, react_2.useCallback)(() => {
|
|
205
205
|
openImportDialog();
|
|
206
206
|
}, [openImportDialog]);
|
|
207
|
-
return ((0, jsx_runtime_1.jsx)(LoaderContext_1.LoaderProvider, { value: open, children: (0, jsx_runtime_1.jsxs)("div", { ...getRootProps(), css: containerStyle, children: [(0, jsx_runtime_1.jsx)("input", { ...getInputProps() }, void 0), isDragActive && ((0, jsx_runtime_1.jsxs)("div", { css: style, style: {
|
|
207
|
+
return ((0, jsx_runtime_1.jsx)(LoaderContext_1.LoaderProvider, { value: open, children: (0, jsx_runtime_1.jsxs)("div", { ...getRootProps(), role: "none", css: containerStyle, children: [(0, jsx_runtime_1.jsx)("input", { ...getInputProps() }, void 0), isDragActive && ((0, jsx_runtime_1.jsxs)("div", { css: style, style: {
|
|
208
208
|
width: `${width}px`,
|
|
209
209
|
height: `${height}px`,
|
|
210
210
|
marginTop: '30px',
|
|
@@ -34,12 +34,15 @@ exports.ModalStyles = (0, react_1.css) `
|
|
|
34
34
|
button:focus {
|
|
35
35
|
outline: none;
|
|
36
36
|
}
|
|
37
|
-
button:hover {
|
|
37
|
+
button:not([disabled]):hover {
|
|
38
38
|
color: #007bff;
|
|
39
39
|
}
|
|
40
|
-
.btn:hover {
|
|
40
|
+
.btn:not([disabled]):hover {
|
|
41
41
|
background-color: #ffffff;
|
|
42
42
|
}
|
|
43
|
+
.btn:disabled {
|
|
44
|
+
opacity: 0.5;
|
|
45
|
+
}
|
|
43
46
|
.btn {
|
|
44
47
|
border: none;
|
|
45
48
|
padding: 0 15px;
|
|
@@ -20,7 +20,8 @@ function MoleculeStructureEditorModal(props) {
|
|
|
20
20
|
}
|
|
21
21
|
}, [selectedMolecule]);
|
|
22
22
|
const cb = (0, react_1.useCallback)((newMolfile) => {
|
|
23
|
-
|
|
23
|
+
const molText = /(?<s>M {2}V30 BEGIN BOND)(?<mol>.*?)(?<e>M {2}V30 END BOND)/gs.exec(newMolfile)?.groups?.mol;
|
|
24
|
+
setMolfile(molText?.trim() ? newMolfile : null);
|
|
24
25
|
}, [setMolfile]);
|
|
25
26
|
const handleClose = (0, react_1.useCallback)(() => {
|
|
26
27
|
onClose();
|
|
@@ -35,6 +36,6 @@ function MoleculeStructureEditorModal(props) {
|
|
|
35
36
|
onClose('new');
|
|
36
37
|
}
|
|
37
38
|
}, [dispatch, selectedMolecule, molfile, onClose]);
|
|
38
|
-
return ((0, jsx_runtime_1.jsxs)("div", { css: ModalStyle_1.ModalStyles, children: [(0, jsx_runtime_1.jsx)(full_1.StructureEditor, { initialMolfile: selectedMolecule?.molfile, svgMenu: true, fragment: false, onChange: cb }, void 0), (0, jsx_runtime_1.jsxs)("div", { className: "footer-container", children: [(0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn", onClick: handleSave, children: "Save" }, void 0), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn", onClick: handleClose, children: "Close" }, void 0)] }, void 0)] }, void 0));
|
|
39
|
+
return ((0, jsx_runtime_1.jsxs)("div", { css: ModalStyle_1.ModalStyles, children: [(0, jsx_runtime_1.jsx)(full_1.StructureEditor, { initialMolfile: selectedMolecule?.molfile, svgMenu: true, fragment: false, onChange: cb }, void 0), (0, jsx_runtime_1.jsxs)("div", { className: "footer-container", children: [(0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn", onClick: handleSave, disabled: !molfile, children: "Save" }, void 0), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn", onClick: handleClose, children: "Close" }, void 0)] }, void 0)] }, void 0));
|
|
39
40
|
}
|
|
40
41
|
exports.default = MoleculeStructureEditorModal;
|