nmrium 0.19.0 → 0.19.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.
@@ -1,11 +1,11 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
2
2
  /** @jsxImportSource @emotion/react */
3
3
  import { css } from '@emotion/react';
4
4
  import OCL from 'openchemlib/full';
5
5
  import { useState, useCallback, useEffect, memo } from 'react';
6
+ import { ResponsiveChart } from 'react-d3-utils';
6
7
  import { MF } from 'react-mf';
7
8
  import OCLnmr from 'react-ocl-nmr';
8
- import { useMeasure } from 'react-use';
9
9
  import { useChartData } from '../../context/ChartContext';
10
10
  import { useDispatch } from '../../context/DispatchContext';
11
11
  import NextPrev from '../../elements/NextPrev';
@@ -25,6 +25,7 @@ const styles = css `
25
25
  .molecule-container {
26
26
  width: 100%;
27
27
  height: 100%;
28
+ max-height: calc(100% - 25px);
28
29
 
29
30
  .slider {
30
31
  display: flex;
@@ -55,8 +56,21 @@ const styles = css `
55
56
  }
56
57
  }
57
58
  `;
59
+ const toolbarStyle = css `
60
+ display: flex;
61
+ flex-direction: row;
62
+ border-bottom: 0.55px solid rgb(240, 240, 240);
63
+ padding: 0px 5px;
64
+
65
+ p {
66
+ margin: 0;
67
+ text-align: right;
68
+ width: 100%;
69
+ line-height: 22px;
70
+ padding: 0px 10px;
71
+ }
72
+ `;
58
73
  function MoleculePanelInner({ zones, ranges, molecules: moleculesProp, activeTab, displayerMode, }) {
59
- const [refContainer, { width, height }] = useMeasure();
60
74
  const [currentIndex, setCurrentIndex] = useState(0);
61
75
  const [molecules, setMolecules] = useState([]);
62
76
  const dispatch = useDispatch();
@@ -85,15 +99,17 @@ function MoleculePanelInner({ zones, ranges, molecules: moleculesProp, activeTab
85
99
  const moleculeIndexHandler = useCallback((index) => {
86
100
  setCurrentIndex(index);
87
101
  }, []);
88
- return (_jsxs("div", { css: styles, children: [_jsx(MoleculePanelHeader, { currentIndex: currentIndex, molecules: molecules, onOpenMoleculeEditor: () => openMoleculeEditorHandler(), onMoleculeIndexChange: moleculeIndexHandler }, void 0), _jsx("div", { className: "molecule-container", children: _jsx(NextPrev, { onChange: (slideIndex) => setCurrentIndex(slideIndex), defaultIndex: currentIndex, children: molecules && molecules.length > 0 ? (molecules.map((mol, index) => (_jsxs("div", { className: "slider", onDoubleClick: () => openMoleculeEditorHandler(mol), style: {
89
- backgroundColor: (index + 1) % 2 !== 0 ? '#fafafa' : 'white',
90
- }, children: [_jsx("div", { className: "mol-svg-container", ref: refContainer, children: _jsx(OCLnmr, { OCL: OCL, id: `molSVG${index}`, width: width > 0 ? width : 100, height: height > 0 ? height : 100, molfile: mol.molfile || '', setMolfile: (molfile) => handleReplaceMolecule(mol.key, molfile), setSelectedAtom: handleOnClickAtom, atomHighlightColor: currentDiaIDsToHighlight &&
91
- currentDiaIDsToHighlight.length > 0
92
- ? 'red'
93
- : '#FFD700', atomHighlightOpacity: 0.35, highlights: currentDiaIDsToHighlight &&
94
- currentDiaIDsToHighlight.length > 0
95
- ? currentDiaIDsToHighlight
96
- : assignedDiaIDsMerged, setHoverAtom: handleOnAtomHover }, void 0) }, void 0), _jsxs("p", { children: [_jsx(MF, { mf: mol.mf }, void 0), " - ", mol.mw?.toFixed(2)] }, void 0)] }, mol.key)))) : (_jsx("div", { style: { width: '100%', height: '100%' }, onClick: () => openMoleculeEditorHandler() }, void 0)) }, void 0) }, void 0)] }, void 0));
102
+ return (_jsxs("div", { css: styles, children: [_jsx(MoleculePanelHeader, { currentIndex: currentIndex, molecules: molecules, onOpenMoleculeEditor: () => openMoleculeEditorHandler(), onMoleculeIndexChange: moleculeIndexHandler }, void 0), _jsx("div", { className: "molecule-container", children: _jsx(ResponsiveChart, { children: ({ height, width }) => {
103
+ return (_jsx(NextPrev, { onChange: (slideIndex) => setCurrentIndex(slideIndex), defaultIndex: currentIndex, children: molecules && molecules.length > 0 ? (molecules.map((mol, index) => (_jsxs(_Fragment, { children: [_jsx("div", { css: toolbarStyle, children: _jsxs("p", { children: [_jsx(MF, { mf: mol.mf }, void 0), " - ", mol.mw?.toFixed(2)] }, void 0) }, void 0), _jsx("div", { className: "slider", onDoubleClick: () => openMoleculeEditorHandler(mol), style: {
104
+ backgroundColor: (index + 1) % 2 !== 0 ? '#fafafa' : 'white',
105
+ }, children: _jsx("div", { className: "mol-svg-container", children: _jsx(OCLnmr, { OCL: OCL, id: `molSVG${index}`, width: width, height: height, molfile: mol.molfile || '', setMolfile: (molfile) => handleReplaceMolecule(mol.key, molfile), setSelectedAtom: handleOnClickAtom, atomHighlightColor: currentDiaIDsToHighlight &&
106
+ currentDiaIDsToHighlight.length > 0
107
+ ? 'red'
108
+ : '#FFD700', atomHighlightOpacity: 0.35, highlights: currentDiaIDsToHighlight &&
109
+ currentDiaIDsToHighlight.length > 0
110
+ ? currentDiaIDsToHighlight
111
+ : assignedDiaIDsMerged, setHoverAtom: handleOnAtomHover }, void 0) }, void 0) }, mol.key)] }, void 0)))) : (_jsx("div", { style: { width: '100%', height: '100%' }, onClick: () => openMoleculeEditorHandler() }, void 0)) }, void 0));
112
+ } }, void 0) }, void 0)] }, void 0));
97
113
  }
98
114
  const MemoizedMoleculePanel = memo(MoleculePanelInner);
99
115
  const emptyData = { ranges: {}, zones: {} };
@@ -1 +1 @@
1
- export default { version: 'v0.19.0' };
1
+ export default { version: 'v0.19.1' };
@@ -8,9 +8,9 @@ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
8
8
  const react_1 = require("@emotion/react");
9
9
  const full_1 = __importDefault(require("openchemlib/full"));
10
10
  const react_2 = require("react");
11
+ const react_d3_utils_1 = require("react-d3-utils");
11
12
  const react_mf_1 = require("react-mf");
12
13
  const react_ocl_nmr_1 = __importDefault(require("react-ocl-nmr"));
13
- const react_use_1 = require("react-use");
14
14
  const ChartContext_1 = require("../../context/ChartContext");
15
15
  const DispatchContext_1 = require("../../context/DispatchContext");
16
16
  const NextPrev_1 = __importDefault(require("../../elements/NextPrev"));
@@ -30,6 +30,7 @@ const styles = (0, react_1.css) `
30
30
  .molecule-container {
31
31
  width: 100%;
32
32
  height: 100%;
33
+ max-height: calc(100% - 25px);
33
34
 
34
35
  .slider {
35
36
  display: flex;
@@ -60,8 +61,21 @@ const styles = (0, react_1.css) `
60
61
  }
61
62
  }
62
63
  `;
64
+ const toolbarStyle = (0, react_1.css) `
65
+ display: flex;
66
+ flex-direction: row;
67
+ border-bottom: 0.55px solid rgb(240, 240, 240);
68
+ padding: 0px 5px;
69
+
70
+ p {
71
+ margin: 0;
72
+ text-align: right;
73
+ width: 100%;
74
+ line-height: 22px;
75
+ padding: 0px 10px;
76
+ }
77
+ `;
63
78
  function MoleculePanelInner({ zones, ranges, molecules: moleculesProp, activeTab, displayerMode, }) {
64
- const [refContainer, { width, height }] = (0, react_use_1.useMeasure)();
65
79
  const [currentIndex, setCurrentIndex] = (0, react_2.useState)(0);
66
80
  const [molecules, setMolecules] = (0, react_2.useState)([]);
67
81
  const dispatch = (0, DispatchContext_1.useDispatch)();
@@ -90,15 +104,17 @@ function MoleculePanelInner({ zones, ranges, molecules: moleculesProp, activeTab
90
104
  const moleculeIndexHandler = (0, react_2.useCallback)((index) => {
91
105
  setCurrentIndex(index);
92
106
  }, []);
93
- return ((0, jsx_runtime_1.jsxs)("div", { css: styles, children: [(0, jsx_runtime_1.jsx)(MoleculePanelHeader_1.default, { currentIndex: currentIndex, molecules: molecules, onOpenMoleculeEditor: () => openMoleculeEditorHandler(), onMoleculeIndexChange: moleculeIndexHandler }, void 0), (0, jsx_runtime_1.jsx)("div", { className: "molecule-container", children: (0, jsx_runtime_1.jsx)(NextPrev_1.default, { onChange: (slideIndex) => setCurrentIndex(slideIndex), defaultIndex: currentIndex, children: molecules && molecules.length > 0 ? (molecules.map((mol, index) => ((0, jsx_runtime_1.jsxs)("div", { className: "slider", onDoubleClick: () => openMoleculeEditorHandler(mol), style: {
94
- backgroundColor: (index + 1) % 2 !== 0 ? '#fafafa' : 'white',
95
- }, children: [(0, jsx_runtime_1.jsx)("div", { className: "mol-svg-container", ref: refContainer, children: (0, jsx_runtime_1.jsx)(react_ocl_nmr_1.default, { OCL: full_1.default, id: `molSVG${index}`, width: width > 0 ? width : 100, height: height > 0 ? height : 100, molfile: mol.molfile || '', setMolfile: (molfile) => handleReplaceMolecule(mol.key, molfile), setSelectedAtom: handleOnClickAtom, atomHighlightColor: currentDiaIDsToHighlight &&
96
- currentDiaIDsToHighlight.length > 0
97
- ? 'red'
98
- : '#FFD700', atomHighlightOpacity: 0.35, highlights: currentDiaIDsToHighlight &&
99
- currentDiaIDsToHighlight.length > 0
100
- ? currentDiaIDsToHighlight
101
- : assignedDiaIDsMerged, setHoverAtom: handleOnAtomHover }, void 0) }, void 0), (0, jsx_runtime_1.jsxs)("p", { children: [(0, jsx_runtime_1.jsx)(react_mf_1.MF, { mf: mol.mf }, void 0), " - ", mol.mw?.toFixed(2)] }, void 0)] }, mol.key)))) : ((0, jsx_runtime_1.jsx)("div", { style: { width: '100%', height: '100%' }, onClick: () => openMoleculeEditorHandler() }, void 0)) }, void 0) }, void 0)] }, void 0));
107
+ return ((0, jsx_runtime_1.jsxs)("div", { css: styles, children: [(0, jsx_runtime_1.jsx)(MoleculePanelHeader_1.default, { currentIndex: currentIndex, molecules: molecules, onOpenMoleculeEditor: () => openMoleculeEditorHandler(), onMoleculeIndexChange: moleculeIndexHandler }, void 0), (0, jsx_runtime_1.jsx)("div", { className: "molecule-container", children: (0, jsx_runtime_1.jsx)(react_d3_utils_1.ResponsiveChart, { children: ({ height, width }) => {
108
+ return ((0, jsx_runtime_1.jsx)(NextPrev_1.default, { onChange: (slideIndex) => setCurrentIndex(slideIndex), defaultIndex: currentIndex, children: molecules && molecules.length > 0 ? (molecules.map((mol, index) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { css: toolbarStyle, children: (0, jsx_runtime_1.jsxs)("p", { children: [(0, jsx_runtime_1.jsx)(react_mf_1.MF, { mf: mol.mf }, void 0), " - ", mol.mw?.toFixed(2)] }, void 0) }, void 0), (0, jsx_runtime_1.jsx)("div", { className: "slider", onDoubleClick: () => openMoleculeEditorHandler(mol), style: {
109
+ backgroundColor: (index + 1) % 2 !== 0 ? '#fafafa' : 'white',
110
+ }, children: (0, jsx_runtime_1.jsx)("div", { className: "mol-svg-container", children: (0, jsx_runtime_1.jsx)(react_ocl_nmr_1.default, { OCL: full_1.default, id: `molSVG${index}`, width: width, height: height, molfile: mol.molfile || '', setMolfile: (molfile) => handleReplaceMolecule(mol.key, molfile), setSelectedAtom: handleOnClickAtom, atomHighlightColor: currentDiaIDsToHighlight &&
111
+ currentDiaIDsToHighlight.length > 0
112
+ ? 'red'
113
+ : '#FFD700', atomHighlightOpacity: 0.35, highlights: currentDiaIDsToHighlight &&
114
+ currentDiaIDsToHighlight.length > 0
115
+ ? currentDiaIDsToHighlight
116
+ : assignedDiaIDsMerged, setHoverAtom: handleOnAtomHover }, void 0) }, void 0) }, mol.key)] }, void 0)))) : ((0, jsx_runtime_1.jsx)("div", { style: { width: '100%', height: '100%' }, onClick: () => openMoleculeEditorHandler() }, void 0)) }, void 0));
117
+ } }, void 0) }, void 0)] }, void 0));
102
118
  }
103
119
  const MemoizedMoleculePanel = (0, react_2.memo)(MoleculePanelInner);
104
120
  const emptyData = { ranges: {}, zones: {} };
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = { version: 'v0.19.0' };
3
+ exports.default = { version: 'v0.19.1' };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nmrium",
3
3
  "description": "React component to display and process nuclear magnetic resonance (NMR) spectra.",
4
- "version": "0.19.0",
4
+ "version": "0.19.1",
5
5
  "license": "MIT",
6
6
  "main": "lib-cjs/component/NMRium.js",
7
7
  "module": "lib/component/NMRium.js",