nmrium 0.36.0 → 0.37.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.
Files changed (72) hide show
  1. package/lib/component/2d/ft/Contours.js +0 -6
  2. package/lib/component/NMRium.d.ts +2 -0
  3. package/lib/component/NMRium.js +7 -8
  4. package/lib/component/elements/RemoveAssignmentsButton.d.ts +4 -0
  5. package/lib/component/{panels/RangesPanel/TableColumns → elements}/RemoveAssignmentsButton.js +14 -1
  6. package/lib/component/header/Header.js +1 -1
  7. package/lib/component/modal/AboutPredictionModal.d.ts +2 -0
  8. package/lib/component/modal/AboutPredictionModal.js +49 -0
  9. package/lib/component/panels/IntegralsPanel/IntegralTable.js +17 -13
  10. package/lib/component/panels/IntegralsPanel/IntegralsPreferences.js +8 -5
  11. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts +1 -0
  12. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +3 -2
  13. package/lib/component/panels/RangesPanel/RangesTableRow.d.ts +0 -1
  14. package/lib/component/panels/RangesPanel/RangesTableRow.js +0 -11
  15. package/lib/component/panels/RangesPanel/TableColumns/RangeAssignmentsColumn.js +2 -3
  16. package/lib/component/panels/RangesPanel/TableColumns/SignalAssignmentsColumn.js +2 -3
  17. package/lib/component/panels/SpectrumsPanel/SpectraPreferences.js +2 -2
  18. package/lib/component/panels/SpectrumsPanel/base/SpectraColumnsManager.js +1 -1
  19. package/lib/component/panels/ZonesPanel/TableColumns/ActionsColumn.d.ts +2 -10
  20. package/lib/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumn.d.ts +2 -3
  21. package/lib/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumn.js +12 -16
  22. package/lib/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumns.d.ts +1 -5
  23. package/lib/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumns.js +2 -2
  24. package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumn.d.ts +2 -3
  25. package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumn.js +27 -19
  26. package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumns.d.ts +1 -5
  27. package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumns.js +2 -2
  28. package/lib/component/panels/ZonesPanel/ZonesTableRow.js +2 -22
  29. package/lib/component/panels/predictionPanel/PredictionPanel.js +6 -1
  30. package/lib/component/reducer/actions/LoadActions.js +14 -6
  31. package/lib/component/reducer/actions/MoleculeActions.js +26 -2
  32. package/lib/component/reducer/actions/PreferencesActions.js +17 -4
  33. package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +1 -0
  34. package/lib/component/workspaces/Workspace.d.ts +2 -1
  35. package/lib/component/workspaces/exercise.js +31 -0
  36. package/lib/component/workspaces/workspaceDefaultProperties.js +1 -0
  37. package/lib/data/data2d/Processing2D.d.ts +3 -3
  38. package/lib/data/data2d/Spectrum2D/contours.d.ts +1 -4
  39. package/lib/data/data2d/Spectrum2D/contours.js +0 -1
  40. package/lib/data/utilities/ZoneUtilities.js +0 -1
  41. package/lib/types/NMRiumGeneralPreferences.d.ts +1 -0
  42. package/lib/versionInfo.js +1 -1
  43. package/lib-cjs/component/2d/ft/Contours.js +0 -6
  44. package/lib-cjs/component/NMRium.js +4 -5
  45. package/lib-cjs/component/{panels/RangesPanel/TableColumns → elements}/RemoveAssignmentsButton.js +15 -2
  46. package/lib-cjs/component/header/Header.js +1 -1
  47. package/lib-cjs/component/modal/AboutPredictionModal.js +54 -0
  48. package/lib-cjs/component/panels/IntegralsPanel/IntegralTable.js +17 -13
  49. package/lib-cjs/component/panels/IntegralsPanel/IntegralsPreferences.js +7 -4
  50. package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +3 -2
  51. package/lib-cjs/component/panels/RangesPanel/RangesTableRow.js +0 -12
  52. package/lib-cjs/component/panels/RangesPanel/TableColumns/RangeAssignmentsColumn.js +2 -3
  53. package/lib-cjs/component/panels/RangesPanel/TableColumns/SignalAssignmentsColumn.js +2 -3
  54. package/lib-cjs/component/panels/SpectrumsPanel/SpectraPreferences.js +2 -2
  55. package/lib-cjs/component/panels/SpectrumsPanel/base/SpectraColumnsManager.js +1 -1
  56. package/lib-cjs/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumn.js +12 -19
  57. package/lib-cjs/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumns.js +2 -2
  58. package/lib-cjs/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumn.js +27 -22
  59. package/lib-cjs/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumns.js +2 -2
  60. package/lib-cjs/component/panels/ZonesPanel/ZonesTableRow.js +1 -21
  61. package/lib-cjs/component/panels/predictionPanel/PredictionPanel.js +6 -1
  62. package/lib-cjs/component/reducer/actions/LoadActions.js +14 -6
  63. package/lib-cjs/component/reducer/actions/MoleculeActions.js +25 -1
  64. package/lib-cjs/component/reducer/actions/PreferencesActions.js +17 -4
  65. package/lib-cjs/component/reducer/preferences/panelsPreferencesDefaultValues.js +1 -0
  66. package/lib-cjs/component/workspaces/exercise.js +31 -0
  67. package/lib-cjs/component/workspaces/workspaceDefaultProperties.js +1 -0
  68. package/lib-cjs/data/data2d/Spectrum2D/contours.js +0 -1
  69. package/lib-cjs/data/utilities/ZoneUtilities.js +0 -1
  70. package/lib-cjs/versionInfo.js +1 -1
  71. package/package.json +21 -21
  72. package/lib/component/panels/RangesPanel/TableColumns/RemoveAssignmentsButton.d.ts +0 -3
@@ -27,12 +27,6 @@ function usePath(spectrum, contours) {
27
27
  }
28
28
  }
29
29
  }
30
- else {
31
- pathBuilder.moveTo(_scaleX(element[0].x + shift.x), _scaleY(element[0].y + shift.y));
32
- for (let j = 1; j < element.length; j++) {
33
- pathBuilder.lineTo(_scaleX(element[j].x + shift.x), _scaleY(element[j].y + shift.y));
34
- }
35
- }
36
30
  }
37
31
  pathBuilder.closePath();
38
32
  return pathBuilder.toString();
@@ -2,6 +2,7 @@
2
2
  import { CorrelationData } from 'nmr-correlation';
3
3
  import { Source, NmriumState, Spectrum } from 'nmr-load-save';
4
4
  import { ReactElement, ReactNode } from 'react';
5
+ import { ErrorBoundaryPropsWithComponent } from 'react-error-boundary';
5
6
  import { BlobObject } from './utility/export';
6
7
  import { CustomWorkspaces, WorkspacePreferences as NMRiumPreferences } from './workspaces/Workspace';
7
8
  export { serializeNmriumState } from 'nmr-load-save';
@@ -12,6 +13,7 @@ export type OnNMRiumChange = (state: NmriumState, source: 'data' | 'view' | 'set
12
13
  export interface NMRiumProps {
13
14
  data?: NMRiumData;
14
15
  onChange?: OnNMRiumChange;
16
+ onError?: ErrorBoundaryPropsWithComponent['onError'];
15
17
  workspace?: NMRiumWorkspace;
16
18
  customWorkspaces?: CustomWorkspaces;
17
19
  preferences?: NMRiumPreferences;
@@ -3,9 +3,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
3
3
  import { css } from '@emotion/react';
4
4
  import { readNMRiumObject } from 'nmr-load-save';
5
5
  import { useEffect, useCallback, useReducer, useMemo, useRef, memo, forwardRef, useImperativeHandle, } from 'react';
6
- import { ErrorBoundary } from 'react-error-boundary';
7
- import { RootLayout } from 'react-science/ui';
8
- import { useToggle, useFullscreen } from 'react-use';
6
+ import { ErrorBoundary, } from 'react-error-boundary';
7
+ import { RootLayout, useOnOff } from 'react-science/ui';
8
+ import { useFullscreen } from 'react-use';
9
9
  import { toJSON } from '../data/SpectraManager';
10
10
  import checkModifierKeyActivated from '../data/utilities/checkModifierKeyActivated';
11
11
  import Viewer1D from './1d/Viewer1D';
@@ -80,21 +80,20 @@ const defaultData = {
80
80
  spectra: [],
81
81
  };
82
82
  const NMRium = forwardRef(function NMRium(props, ref) {
83
- return (_jsx(RootLayout, { style: { width: '100%' }, children: _jsx(ErrorBoundary, { FallbackComponent: ErrorOverlay, children: _jsx(InnerNMRium, { ...props, innerRef: ref }) }) }));
83
+ const { onError, ...otherProps } = props;
84
+ return (_jsx(RootLayout, { style: { width: '100%' }, children: _jsx(ErrorBoundary, { FallbackComponent: ErrorOverlay, onError: onError, children: _jsx(InnerNMRium, { ...otherProps, innerRef: ref }) }) }));
84
85
  });
85
86
  function InnerNMRium({ data: dataProp = defaultData, workspace, customWorkspaces, preferences, getSpinner = defaultGetSpinner, onChange, emptyText, innerRef, }) {
86
87
  const rootRef = useRef(null);
87
88
  const elementsWrapperRef = useRef(null);
88
89
  const viewerRef = useRef(null);
89
- const [show, toggle] = useToggle(false);
90
+ const [show, , setOff, toggle] = useOnOff(false);
90
91
  const handleChange = useRef(onChange);
91
92
  useEffect(() => {
92
93
  handleChange.current = onChange;
93
94
  }, [onChange]);
94
95
  const isFullscreen = useFullscreen(rootRef, show, {
95
- onClose: () => {
96
- toggle(false);
97
- },
96
+ onClose: setOff,
98
97
  });
99
98
  const [state, dispatch] = useReducer(spectrumReducer, initialState, initState);
100
99
  const [preferencesState, dispatchPreferences] = useReducer(preferencesReducer, preferencesInitialState, initPreferencesState);
@@ -0,0 +1,4 @@
1
+ export declare const removeAssignmentCssStyle: import("@emotion/react").SerializedStyles;
2
+ export declare function RemoveAssignmentsButton({ onClick }: {
3
+ onClick: any;
4
+ }): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -1,5 +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 { css } from '@emotion/react';
2
4
  import { FaMinusCircle } from 'react-icons/fa';
5
+ export const removeAssignmentCssStyle = css `
6
+ .remove-assignment {
7
+ visibility: hidden;
8
+ }
9
+
10
+ &:hover {
11
+ .remove-assignment {
12
+ visibility: visible;
13
+ }
14
+ }
15
+ `;
3
16
  export function RemoveAssignmentsButton({ onClick }) {
4
17
  return (_jsx("sup", { className: "remove-assignment", children: _jsx("button", { type: "button", style: {
5
18
  padding: 0,
@@ -100,7 +100,7 @@ function HeaderInner(props) {
100
100
  alignItems: 'center',
101
101
  }, children: [_jsx("div", { children: _jsx(Toolbar, { orientation: "horizontal", children: _jsx(AboutUsModal, {}) }) }), _jsx("div", { className: "toolOptionsPanel", style: { flex: 1 }, children: selectedPanel })] }), _jsxs(HeaderContainer, { style: {
102
102
  alignItems: 'center',
103
- }, children: [!hideGeneralSettings && (_jsx(DropDownButton, { data: workspacesList, selectedKey: workspace.current, onSelect: changeWorkspaceHandler, renderItem: renderItem })), _jsx(SaveButton, {}), _jsx(LogsHistory, {}), _jsx("div", { children: _jsxs(Toolbar, { orientation: "horizontal", children: [_jsx(Toolbar.Item, { id: "user-manual", title: "User manual", onClick: () => window.open(docsBaseUrl, '_blank'), children: _jsx(FaQuestionCircle, {}) }), !hideGeneralSettings && (_jsx(GeneralSettingsModal, { height: height / 2 })), !isFullscreen && (_jsx(Toolbar.Item, { id: "full-screen", onClick: onMaximize, title: "Full Screen", className: "windowButton", children: _jsx(FaRegWindowMaximize, {}) }))] }) })] })] }) }));
103
+ }, children: [!hideGeneralSettings && (_jsxs(_Fragment, { children: [_jsx(DropDownButton, { data: workspacesList, selectedKey: workspace.current, onSelect: changeWorkspaceHandler, renderItem: renderItem }), _jsx(SaveButton, {})] })), !general?.hideLogs && _jsx(LogsHistory, {}), _jsx("div", { children: _jsxs(Toolbar, { orientation: "horizontal", children: [_jsx(Toolbar.Item, { id: "user-manual", title: "User manual", onClick: () => window.open(docsBaseUrl, '_blank'), children: _jsx(FaQuestionCircle, {}) }), !hideGeneralSettings && (_jsx(GeneralSettingsModal, { height: height / 2 })), !isFullscreen && (_jsx(Toolbar.Item, { id: "full-screen", onClick: onMaximize, title: "Full Screen", className: "windowButton", children: _jsx(FaRegWindowMaximize, {}) }))] }) })] })] }) }));
104
104
  }
105
105
  function SaveButton() {
106
106
  const { workspace, workspaces, originalWorkspaces } = usePreferences();
@@ -0,0 +1,2 @@
1
+ declare function AboutPredictionModal(): import("@emotion/react/jsx-runtime").JSX.Element;
2
+ export default AboutPredictionModal;
@@ -0,0 +1,49 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
2
+ /** @jsxImportSource @emotion/react */
3
+ import { css } from '@emotion/react';
4
+ import { FaInfo } from 'react-icons/fa';
5
+ import { Modal, useOnOff } from 'react-science/ui';
6
+ import Button from '../elements/Button';
7
+ const styles = css `
8
+ width: 600px;
9
+
10
+ .content {
11
+ padding: 2em;
12
+ }
13
+
14
+ ul {
15
+ list-style-type: disc;
16
+ margin-left: 25px;
17
+ }
18
+
19
+ p,
20
+ li {
21
+ user-select: text;
22
+ font-size: 1.1em;
23
+ }
24
+
25
+ a {
26
+ color: #00bcd4;
27
+ }
28
+
29
+ a:hover,
30
+ a:focus {
31
+ text-decoration: underline;
32
+ }
33
+
34
+ .header span {
35
+ color: #464646;
36
+ font-size: 15px;
37
+ flex: 1;
38
+ user-select: none;
39
+ }
40
+
41
+ p {
42
+ padding: 0.8em 0;
43
+ }
44
+ `;
45
+ function AboutPredictionModal() {
46
+ const [isOpenDialog, openDialog, closeDialog] = useOnOff(false);
47
+ return (_jsxs(_Fragment, { children: [_jsx(Button.BarButton, { onClick: openDialog, tooltipOrientation: "horizontal", toolTip: "About Prediction", children: _jsx(FaInfo, {}) }), _jsx(Modal, { hasCloseButton: true, isOpen: isOpenDialog, onRequestClose: closeDialog, children: _jsxs("div", { css: styles, children: [_jsx(Modal.Header, { children: _jsx("div", { className: "header", children: _jsx("span", { children: "About Prediction" }) }) }), _jsx(Modal.Body, { children: _jsxs("div", { className: "content", children: [_jsx("p", { children: "If you are using our tools please cite us:" }), _jsxs("ul", { children: [_jsxs("li", { children: ["Banfi, D.; Patiny, L.", ' ', _jsx("a", { href: "http://dx.doi.org/10.2533/chimia.2008.280", target: "_blank", rel: "noreferrer", children: "www.nmrdb.org: Resurrecting and processing NMR spectra on-line" }), ' ', "Chimia, 2008, 62(4), 280-281."] }), _jsxs("li", { children: ["Andr\u00E9s M. Castillo, Luc Patiny and Julien Wist.", ' ', _jsx("a", { href: "http://dx.doi.org/10.1016/j.jmr.2010.12.008", target: "_blank", rel: "noreferrer", children: "Fast and Accurate Algorithm for the Simulation of NMR spectra of Large Spin Systems" }), ". Journal of Magnetic Resonance 2011."] })] }), _jsx("p", { children: "1H NMR prediction was possible thanks to the tool of the FCT-Universidade NOVA de Lisboa developed by Yuri Binev and Joao Aires-de-Sousa:" }), _jsxs("ul", { children: [_jsxs("li", { children: ["Y. Binev, M.M. Marques, J. Aires-de-Sousa,", ' ', _jsx("a", { href: "http://dx.doi.org/10.1021/ci700172n", target: "_blank", rel: "noreferrer", children: "Prediction of 1H NMR coupling constants with associative neural networks trained for chemical shifts" }), ' ', "J. Chem. Inf. Model. 2007, 47/(6), 2089-2097."] }), _jsxs("li", { children: ["Aires-de-Sousa, M. Hemmer, J. Gasteiger,", ' ', _jsx("a", { href: "http://dx.doi.org/10.1021/ac010737m", target: "_blank", rel: "noreferrer", children: "\u201C Prediction of 1H NMR Chemical Shifts Using Neural Networks\u201D" }), ", Analytical Chemistry, 2002, 74(1), 80-90."] })] }), _jsx("p", { children: "13 NMR prediction was possible thanks to NMRshiftDB:" }), _jsx("ul", { children: _jsxs("li", { children: ["Steinbeck, Christoph, Stefan Krause, and Stefan Kuhn.", ' ', _jsx("a", { href: "http://dx.doi.org/10.1021/ci0341363", target: "_blank", rel: "noreferrer", children: "NMRShiftDB Constructing a Free Chemical Information System with Open-Source Components." }), ' ', "Journal of chemical information and computer sciences, 2003, 43(6): 1733-1739."] }) })] }) })] }) })] }));
48
+ }
49
+ export default AboutPredictionModal;
@@ -37,37 +37,27 @@ function IntegralTable({ activeTab, data }) {
37
37
  index: 1,
38
38
  Header: '#',
39
39
  accessor: (_, index) => index + 1,
40
- width: 10,
40
+ style: { width: '30px', maxWidth: '30px' },
41
41
  },
42
42
  {
43
43
  index: 2,
44
44
  Header: 'From',
45
45
  sortType: 'basic',
46
- resizable: true,
47
46
  accessor: (row) => row.from.toFixed(2),
48
47
  },
49
48
  {
50
49
  index: 3,
51
50
  Header: 'To',
52
51
  sortType: 'basic',
53
- resizable: true,
54
52
  accessor: (row) => row.to.toFixed(2),
55
53
  },
56
- {
57
- index: 6,
58
- Header: 'Kind',
59
- sortType: 'basic',
60
- resizable: true,
61
- accessor: 'kind',
62
- Cell: ({ row }) => (_jsx(Select, { onChange: (value) => changeIntegralDataHandler(value, row), items: SignalKinds, style: selectStyle, defaultValue: row.original.kind })),
63
- },
64
54
  {
65
55
  index: 7,
66
56
  style: { width: '1%', maxWidth: '24px', minWidth: '24px' },
67
57
  id: 'delete-button',
68
58
  Cell: ({ row }) => (_jsx("button", { type: "button", className: "delete-button", onClick: (e) => deleteIntegralHandler(e, row), children: _jsx(FaRegTrashAlt, {}) })),
69
59
  },
70
- ], [changeIntegralDataHandler, deleteIntegralHandler]);
60
+ ], [deleteIntegralHandler]);
71
61
  const saveRelativeHandler = useCallback((event, row) => {
72
62
  const data = { value: event.target.value, id: row.id };
73
63
  dispatch({
@@ -103,7 +93,21 @@ function IntegralTable({ activeTab, data }) {
103
93
  return (_jsx(EditableColumn, { value: integral, onSave: (event) => saveRelativeHandler(event, row.original), type: "number" }));
104
94
  },
105
95
  },
106
- ], [activeTab, integralsPreferences, saveRelativeHandler]);
96
+ {
97
+ index: 6,
98
+ Header: 'Kind',
99
+ sortType: 'basic',
100
+ resizable: true,
101
+ accessor: 'kind',
102
+ showWhen: 'showKind',
103
+ Cell: ({ row }) => (_jsx(Select, { onChange: (value) => changeIntegralDataHandler(value, row), items: SignalKinds, style: selectStyle, defaultValue: row.original.kind })),
104
+ },
105
+ ], [
106
+ activeTab,
107
+ changeIntegralDataHandler,
108
+ integralsPreferences,
109
+ saveRelativeHandler,
110
+ ]);
107
111
  const tableColumns = useMemo(() => {
108
112
  let columns = [...initialColumns];
109
113
  for (const col of COLUMNS) {
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Formik } from 'formik';
3
- import { useEffect, useCallback, useImperativeHandle, useRef, memo, forwardRef, useMemo, } from 'react';
3
+ import { useCallback, useImperativeHandle, useRef, memo, forwardRef, useMemo, } from 'react';
4
4
  import { usePreferences } from '../../context/PreferencesContext';
5
5
  import Label from '../../elements/Label';
6
6
  import FormikColorInput from '../../elements/formik/FormikColorInput';
@@ -23,6 +23,12 @@ const formatFields = [
23
23
  checkControllerName: 'relative.show',
24
24
  formatControllerName: 'relative.format',
25
25
  },
26
+ {
27
+ id: 3,
28
+ label: 'Kind :',
29
+ checkControllerName: 'showKind',
30
+ hideFormatField: true,
31
+ },
26
32
  ];
27
33
  function IntegralsPreferences(props, ref) {
28
34
  const preferences = usePreferences();
@@ -30,9 +36,6 @@ function IntegralsPreferences(props, ref) {
30
36
  const nuclei = useMemo(() => getUniqueNuclei(nucleus), [nucleus]);
31
37
  const preferencesByNuclei = usePanelPreferencesByNuclei('integrals', nuclei);
32
38
  const formRef = useRef();
33
- useEffect(() => {
34
- formRef.current.setValues(preferencesByNuclei);
35
- }, [preferencesByNuclei]);
36
39
  const saveHandler = useCallback((values) => {
37
40
  preferences.dispatch({
38
41
  type: 'SET_PANELS_PREFERENCES',
@@ -44,7 +47,7 @@ function IntegralsPreferences(props, ref) {
44
47
  formRef.current.submitForm();
45
48
  },
46
49
  }));
47
- return (_jsx(PreferencesContainer, { children: _jsx(Formik, { initialValues: {}, onSubmit: saveHandler, innerRef: formRef, children: _jsx(_Fragment, { children: nuclei?.map((n) => (_jsx(NucleusPreferences, { nucleus: n, fields: formatFields, renderTop: () => (_jsxs(_Fragment, { children: [_jsx(FormikColorInput, { name: `nuclei.${n}.color` }), _jsx(Label, { title: "stroke width :", style: {
50
+ return (_jsx(PreferencesContainer, { children: _jsx(Formik, { initialValues: preferencesByNuclei, onSubmit: saveHandler, innerRef: formRef, children: _jsx(_Fragment, { children: nuclei?.map((n) => (_jsx(NucleusPreferences, { nucleus: n, fields: formatFields, renderTop: () => (_jsxs(_Fragment, { children: [_jsx(FormikColorInput, { name: `nuclei.${n}.color` }), _jsx(Label, { title: "stroke width :", style: {
48
51
  label: {
49
52
  fontSize: '11px',
50
53
  fontWeight: 'bold',
@@ -5,6 +5,7 @@ export interface MoleculeHeaderActionsOptions {
5
5
  hideExport?: boolean;
6
6
  hideDelete?: boolean;
7
7
  hidePredict?: boolean;
8
+ showAboutPredict?: boolean;
8
9
  }
9
10
  interface MoleculePanelHeaderProps {
10
11
  currentIndex: number;
@@ -15,6 +15,7 @@ import MenuButton from '../../elements/MenuButton';
15
15
  import ToolTip from '../../elements/ToolTip/ToolTip';
16
16
  import { useAlert } from '../../elements/popup/Alert';
17
17
  import { positions, useModal } from '../../elements/popup/Modal';
18
+ import AboutPredictionModal from '../../modal/AboutPredictionModal';
18
19
  import PredictSpectraModal from '../../modal/PredictSpectraModal';
19
20
  import { ADD_MOLECULE, DELETE_MOLECULE, FLOAT_MOLECULE_OVER_SPECTRUM, TOGGLE_MOLECULE_ATOM_NUMBER, } from '../../reducer/types/Types';
20
21
  import { copyPNGToClipboard, copyTextToClipboard, exportAsSVG, } from '../../utility/export';
@@ -22,7 +23,7 @@ const toolbarStyle = css `
22
23
  display: flex;
23
24
  flex-direction: row;
24
25
  border-bottom: 0.55px solid rgb(240 240 240);
25
- padding: 0 5px;
26
+ padding: 2px 5px;
26
27
 
27
28
  button svg {
28
29
  fill: #4e4e4e;
@@ -168,7 +169,7 @@ export default function MoleculePanelHeader({ currentIndex, molecules, molecules
168
169
  });
169
170
  }
170
171
  const hasMolecules = molecules && molecules.length > 0;
171
- return (_jsxs("div", { css: toolbarStyle, children: [!actionsOptions.hideExport && (_jsx(MenuButton, { component: _jsx(FaFileExport, {}), toolTip: "Export As", items: MOL_EXPORT_MENU, onClick: exportHandler })), !actionsOptions.hidePast && (_jsx(ToolTip, { title: "Paste molfile", popupPlacement: "left", children: _jsx("button", { className: "bar-button", type: "button", onClick: handlePaste, children: _jsx(FaPaste, {}) }) })), !actionsOptions.hideAdd && (_jsx(ToolTip, { title: "Add molecule", popupPlacement: "left", children: _jsx("button", { className: "bar-button", type: "button", onClick: onOpenMoleculeEditor, children: _jsx(FaPlus, {}) }) })), !actionsOptions.hideDelete && (_jsx(ToolTip, { title: "Delete molecule", popupPlacement: "left", children: _jsx("button", { className: "bar-button", type: "button", onClick: handleDelete, children: _jsx(FaRegTrashAlt, {}) }) })), !actionsOptions.hidePredict && hasMolecules && (_jsx(ButtonToolTip, { popupTitle: "Predict spectra", popupPlacement: "left", onClick: openPredictSpectraModal, children: _jsx(SvgNmrFt, {}) })), _jsx(ActiveButton, { value: moleculesView?.[moleculeKey]?.floating.visible || false, popupTitle: "Float molecule", popupPlacement: "left", onClick: floatMoleculeHandler, disabled: !hasMolecules, children: _jsx(IoOpenOutline, {}) }), _jsx(ActiveButton, { style: { marginLeft: '2px' }, value: moleculesView?.[moleculeKey]?.showAtomNumber || false, popupTitle: "Show atom number", popupPlacement: "left", onClick: showAtomNumbersHandler, disabled: !hasMolecules, children: _jsx("p", { style: atomLabelStyle, children: "#" }) }), _jsxs("p", { children: [molecules &&
172
+ return (_jsxs("div", { css: toolbarStyle, children: [actionsOptions?.showAboutPredict && _jsx(AboutPredictionModal, {}), !actionsOptions.hideExport && (_jsx(MenuButton, { component: _jsx(FaFileExport, {}), toolTip: "Export As", items: MOL_EXPORT_MENU, onClick: exportHandler })), !actionsOptions.hidePast && (_jsx(ToolTip, { title: "Paste molfile", popupPlacement: "left", children: _jsx("button", { className: "bar-button", type: "button", onClick: handlePaste, children: _jsx(FaPaste, {}) }) })), !actionsOptions.hideAdd && (_jsx(ToolTip, { title: "Add molecule", popupPlacement: "left", children: _jsx("button", { className: "bar-button", type: "button", onClick: onOpenMoleculeEditor, children: _jsx(FaPlus, {}) }) })), !actionsOptions.hideDelete && (_jsx(ToolTip, { title: "Delete molecule", popupPlacement: "left", children: _jsx("button", { className: "bar-button", type: "button", onClick: handleDelete, children: _jsx(FaRegTrashAlt, {}) }) })), !actionsOptions.hidePredict && hasMolecules && (_jsx(ButtonToolTip, { popupTitle: "Predict spectra", popupPlacement: "left", onClick: openPredictSpectraModal, children: _jsx(SvgNmrFt, {}) })), _jsx(ActiveButton, { value: moleculesView?.[moleculeKey]?.floating.visible || false, popupTitle: "Float molecule", popupPlacement: "left", onClick: floatMoleculeHandler, disabled: !hasMolecules, children: _jsx(IoOpenOutline, {}) }), _jsx(ActiveButton, { style: { marginLeft: '2px' }, value: moleculesView?.[moleculeKey]?.showAtomNumber || false, popupTitle: "Show atom number", popupPlacement: "left", onClick: showAtomNumbersHandler, disabled: !hasMolecules, children: _jsx("p", { style: atomLabelStyle, children: "#" }) }), _jsxs("p", { children: [molecules &&
172
173
  molecules.length > 0 &&
173
174
  `${+(currentIndex + 1)} / ${molecules.length}`, ' '] })] }));
174
175
  }
@@ -3,7 +3,6 @@ import { CSSProperties } from 'react';
3
3
  import { ContextMenuProps } from '../../elements/ReactTable/ReactTable';
4
4
  import { WorkSpacePanelPreferences } from '../../workspaces/Workspace';
5
5
  import { RangeData } from './hooks/useMapRanges';
6
- export declare const AssignmentColumnCssStyle: import("@emotion/react").SerializedStyles;
7
6
  interface RangesTableRowProps extends ContextMenuProps {
8
7
  rowData: any;
9
8
  onUnlink: (a: any, b?: any) => void;
@@ -22,17 +22,6 @@ const HighlightedRowStyle = css `
22
22
  const ConstantlyHighlightedRowStyle = css `
23
23
  background-color: #f5f5dc;
24
24
  `;
25
- export const AssignmentColumnCssStyle = css `
26
- .remove-assignment {
27
- visibility: hidden;
28
- }
29
-
30
- &:hover {
31
- .remove-assignment {
32
- visibility: visible;
33
- }
34
- }
35
- `;
36
25
  function RangesTableRow({ rowData, onUnlink, onContextMenuSelect, contextMenu = [], preferences, info, }) {
37
26
  const assignmentData = useAssignmentData();
38
27
  const assignmentRange = useAssignment(rowData.id);
@@ -1,9 +1,8 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
2
  /** @jsxImportSource @emotion/react */
3
3
  import { memo } from 'react';
4
+ import { RemoveAssignmentsButton, removeAssignmentCssStyle, } from '../../../elements/RemoveAssignmentsButton';
4
5
  import { HighlightEventSource } from '../../../highlight';
5
- import { AssignmentColumnCssStyle } from '../RangesTableRow';
6
- import { RemoveAssignmentsButton } from './RemoveAssignmentsButton';
7
6
  const columnStyle = {
8
7
  padding: 0,
9
8
  textAlign: 'center',
@@ -37,6 +36,6 @@ function RangeAssignmentsColumn({ row, assignment, highlight, onLink, onUnlink,
37
36
  return (_jsx("td", { ...rowSpanTags, style: {
38
37
  ...columnStyle,
39
38
  ...rowSpanTags.style,
40
- }, ...onHover, ...{ onClick: (e) => onLink?.(e, assignment) }, css: !assignment.isActive && AssignmentColumnCssStyle, children: (totalNumberOfAtoms > 0 || assignment.isActive) && (_jsxs(_Fragment, { children: [totalNumberOfAtoms, " ", ' ( ', _jsx("span", { style: getStyle(flag, isCompletelyAssigned), children: diaIDs?.length || 0 }), ' ) ', _jsx(RemoveAssignmentsButton, { onClick: (e) => onUnlink?.(e, true) })] })) }));
39
+ }, ...onHover, ...{ onClick: (e) => onLink?.(e, assignment) }, css: !assignment.isActive && removeAssignmentCssStyle, children: (totalNumberOfAtoms > 0 || assignment.isActive) && (_jsxs(_Fragment, { children: [totalNumberOfAtoms, " ", ' ( ', _jsx("span", { style: getStyle(flag, isCompletelyAssigned), children: diaIDs?.length || 0 }), ' ) ', _jsx(RemoveAssignmentsButton, { onClick: (e) => onUnlink?.(e, true) })] })) }));
41
40
  }
42
41
  export default memo(RangeAssignmentsColumn);
@@ -2,8 +2,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/reac
2
2
  /** @jsxImportSource @emotion/react */
3
3
  import lodashGet from 'lodash/get';
4
4
  import { memo } from 'react';
5
- import { AssignmentColumnCssStyle, } from '../RangesTableRow';
6
- import { RemoveAssignmentsButton } from './RemoveAssignmentsButton';
5
+ import { RemoveAssignmentsButton, removeAssignmentCssStyle, } from '../../../elements/RemoveAssignmentsButton';
7
6
  function SignalAssignmentsColumn({ row, onHover, assignment, highlight, onLink, onUnlink, }) {
8
7
  const diaIDs = lodashGet(row, 'tableMetaInfo.signal.diaIDs', []);
9
8
  const tdCss = assignment.isActive || highlight.isActive
@@ -15,6 +14,6 @@ function SignalAssignmentsColumn({ row, onHover, assignment, highlight, onLink,
15
14
  function assignHandler(e) {
16
15
  onLink?.(e, assignment);
17
16
  }
18
- return (_jsx("td", { ...onHover, onClick: assignHandler, style: { padding: '0', ...tdCss }, css: !assignment.isActive && AssignmentColumnCssStyle, children: (diaIDs?.length > 0 || assignment.isActive) && (_jsxs(_Fragment, { children: [_jsx("span", { children: diaIDs?.length || 0 }), _jsx(RemoveAssignmentsButton, { onClick: (e) => onUnlink?.(e, false) })] })) }));
17
+ return (_jsx("td", { ...onHover, onClick: assignHandler, style: { padding: '0', ...tdCss }, css: !assignment.isActive && removeAssignmentCssStyle, children: (diaIDs?.length > 0 || assignment.isActive) && (_jsxs(_Fragment, { children: [_jsx("span", { children: diaIDs?.length || 0 }), _jsx(RemoveAssignmentsButton, { onClick: (e) => onUnlink?.(e, false) })] })) }));
19
18
  }
20
19
  export default memo(SignalAssignmentsColumn);
@@ -30,7 +30,7 @@ function SpectraPreferences(props, ref) {
30
30
  }), []);
31
31
  const handleAdd = useCallback((nucleus, index) => {
32
32
  const data = formRef.current.values;
33
- let columns = data.nuclei[nucleus].columns;
33
+ let columns = data.nuclei[nucleus]?.columns || [];
34
34
  columns = [
35
35
  ...columns.slice(0, index),
36
36
  {
@@ -53,7 +53,7 @@ function SpectraPreferences(props, ref) {
53
53
  }, []);
54
54
  const handleDelete = useCallback((nucleus, index) => {
55
55
  const data = formRef.current.values;
56
- const columns = data.nuclei[nucleus].columns.filter((_, columnIndex) => columnIndex !== index);
56
+ const columns = data.nuclei[nucleus]?.columns.filter((_, columnIndex) => columnIndex !== index);
57
57
  formRef.current.setValues({
58
58
  ...data,
59
59
  nuclei: {
@@ -54,5 +54,5 @@ export function SpectraColumnsManager({ nucleus, onAdd, onDelete, datalist, mapO
54
54
  },
55
55
  },
56
56
  ], [datalist, mapOnChangeValue, mapValue, nucleus, onAdd, onDelete]);
57
- return (_jsx(ReactTable, { data: nucleiPreferences.nuclei[nucleus].columns, columns: COLUMNS }));
57
+ return (_jsx(ReactTable, { data: nucleiPreferences.nuclei[nucleus]?.columns || [], columns: COLUMNS }));
58
58
  }
@@ -1,5 +1,5 @@
1
- export interface RowDataProps {
2
- id: number;
1
+ import { Zone } from 'nmr-load-save';
2
+ export interface RowDataProps extends Zone {
3
3
  tableMetaInfo: {
4
4
  id: number;
5
5
  signalIndex: number;
@@ -9,14 +9,6 @@ export interface RowDataProps {
9
9
  };
10
10
  experiment: string;
11
11
  };
12
- x: {
13
- from: number;
14
- to: number;
15
- };
16
- y: {
17
- from: number;
18
- to: number;
19
- };
20
12
  }
21
13
  interface ActionsColumnProps {
22
14
  rowData: RowDataProps;
@@ -1,3 +1,4 @@
1
+ /** @jsxImportSource @emotion/react */
1
2
  import { AssignmentsData, Axis } from '../../../assignment/AssignmentsContext';
2
3
  import { RowDataProps } from './ActionsColumn';
3
4
  export interface SignalAssignmentsColumnProps {
@@ -9,9 +10,7 @@ export interface SignalAssignmentsColumnProps {
9
10
  onHover: () => void;
10
11
  onClick: (event: any, assignment: AssignmentsData, axis: Axis) => void;
11
12
  onUnlink: (event: any, flag: boolean, axis: Axis) => void;
12
- showUnlinkButton: boolean;
13
13
  axis: Axis;
14
- setShowUnlinkButton: (element: boolean) => void;
15
14
  }
16
- declare function SignalAssignmentsColumn({ rowData, assignment, highlight, onHover, onClick, onUnlink, axis, showUnlinkButton, setShowUnlinkButton, }: SignalAssignmentsColumnProps): import("react/jsx-runtime").JSX.Element;
15
+ declare function SignalAssignmentsColumn({ rowData, assignment, highlight, onHover, onClick, onUnlink, axis, }: SignalAssignmentsColumnProps): import("@emotion/react/jsx-runtime").JSX.Element;
17
16
  export default SignalAssignmentsColumn;
@@ -1,18 +1,14 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import lodashGet from 'lodash/get';
3
- import { FaMinusCircle } from 'react-icons/fa';
4
- function SignalAssignmentsColumn({ rowData, assignment, highlight, onHover, onClick, onUnlink, axis, showUnlinkButton, setShowUnlinkButton, }) {
5
- return (_jsx("td", { ...onHover, ...{ onClick: (e) => onClick(e, assignment, axis) }, style: highlight.isActive ||
6
- (assignment.isActive && assignment.activated?.axis === axis)
7
- ? {
8
- color: 'red',
9
- fontWeight: 'bold',
10
- }
11
- : undefined, children: lodashGet(rowData, `tableMetaInfo.signal.${axis}.diaIDs`, []).length >
12
- 0 ? (_jsxs("div", { onMouseEnter: () => setShowUnlinkButton(true), onMouseLeave: () => setShowUnlinkButton(false), children: [rowData.tableMetaInfo.signal[axis].diaIDs.length, ' ', _jsx("sup", { children: _jsx("button", { type: "button", style: {
13
- visibility: showUnlinkButton ? 'visible' : 'hidden',
14
- padding: 0,
15
- margin: 0,
16
- }, onClick: (e) => onUnlink(e, false, axis), children: _jsx(FaMinusCircle, { color: "red" }) }) })] })) : assignment.isActive && assignment.activated?.axis === axis ? ('0') : ('') }));
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ import { RemoveAssignmentsButton, removeAssignmentCssStyle, } from '../../../elements/RemoveAssignmentsButton';
3
+ function SignalAssignmentsColumn({ rowData, assignment, highlight, onHover, onClick, onUnlink, axis, }) {
4
+ const diaIDs = rowData?.tableMetaInfo?.signal?.[axis]?.diaIDs || [];
5
+ const isAssignmentActive = assignment.isActive && assignment.activated?.axis === axis;
6
+ const tdCss = assignment.isActive || highlight.isActive
7
+ ? {
8
+ color: 'red',
9
+ fontWeight: 'bold',
10
+ }
11
+ : {};
12
+ return (_jsx("td", { ...onHover, ...{ onClick: (e) => onClick(e, assignment, axis) }, style: { padding: '0', ...tdCss }, css: !isAssignmentActive && removeAssignmentCssStyle, children: (diaIDs?.length > 0 || isAssignmentActive) && (_jsxs(_Fragment, { children: [_jsx("span", { children: diaIDs?.length || 0 }), _jsx(RemoveAssignmentsButton, { onClick: (e) => onUnlink(e, false, axis) })] })) }));
17
13
  }
18
14
  export default SignalAssignmentsColumn;
@@ -4,10 +4,6 @@ interface SignalAssignmentsColumnsProps {
4
4
  rowData: RowDataProps;
5
5
  onHoverSignalX: any;
6
6
  onHoverSignalY: any;
7
- showUnlinkButtonSignalX: boolean;
8
- showUnlinkButtonSignalY: boolean;
9
- setShowUnlinkButtonSignalX: (element: boolean) => void;
10
- setShowUnlinkButtonSignalY: (element: boolean) => void;
11
7
  onClick: (event: any, assignment: AssignmentsData, axis: Axis) => void;
12
8
  onUnlink: (event: any, flag: boolean, axis: Axis) => void;
13
9
  highlightSignalX: {
@@ -18,5 +14,5 @@ interface SignalAssignmentsColumnsProps {
18
14
  };
19
15
  assignmentSignal: AssignmentsData;
20
16
  }
21
- declare function SignalAssignmentsColumns({ rowData, assignmentSignal, onHoverSignalX, onHoverSignalY, showUnlinkButtonSignalX, showUnlinkButtonSignalY, setShowUnlinkButtonSignalX, setShowUnlinkButtonSignalY, onClick, onUnlink, highlightSignalX, highlightSignalY, }: SignalAssignmentsColumnsProps): import("react/jsx-runtime").JSX.Element;
17
+ declare function SignalAssignmentsColumns({ rowData, assignmentSignal, onHoverSignalX, onHoverSignalY, onClick, onUnlink, highlightSignalX, highlightSignalY, }: SignalAssignmentsColumnsProps): import("react/jsx-runtime").JSX.Element;
22
18
  export default SignalAssignmentsColumns;
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Fragment } from 'react';
3
3
  import SignalAssignmentsColumn from './SignalAssignmentsColumn';
4
- function SignalAssignmentsColumns({ rowData, assignmentSignal, onHoverSignalX, onHoverSignalY, showUnlinkButtonSignalX, showUnlinkButtonSignalY, setShowUnlinkButtonSignalX, setShowUnlinkButtonSignalY, onClick, onUnlink, highlightSignalX, highlightSignalY, }) {
5
- return (_jsxs(Fragment, { children: [_jsx(SignalAssignmentsColumn, { rowData: rowData, assignment: assignmentSignal, highlight: highlightSignalX, onHover: onHoverSignalX, onClick: onClick, onUnlink: onUnlink, axis: "x", showUnlinkButton: showUnlinkButtonSignalX, setShowUnlinkButton: setShowUnlinkButtonSignalX }), _jsx(SignalAssignmentsColumn, { rowData: rowData, assignment: assignmentSignal, highlight: highlightSignalY, onHover: onHoverSignalY, onClick: onClick, onUnlink: onUnlink, axis: "y", showUnlinkButton: showUnlinkButtonSignalY, setShowUnlinkButton: setShowUnlinkButtonSignalY })] }));
4
+ function SignalAssignmentsColumns({ rowData, assignmentSignal, onHoverSignalX, onHoverSignalY, onClick, onUnlink, highlightSignalX, highlightSignalY, }) {
5
+ return (_jsxs(Fragment, { children: [_jsx(SignalAssignmentsColumn, { rowData: rowData, assignment: assignmentSignal, highlight: highlightSignalX, onHover: onHoverSignalX, onClick: onClick, onUnlink: onUnlink, axis: "x" }), _jsx(SignalAssignmentsColumn, { rowData: rowData, assignment: assignmentSignal, highlight: highlightSignalY, onHover: onHoverSignalY, onClick: onClick, onUnlink: onUnlink, axis: "y" })] }));
6
6
  }
7
7
  export default SignalAssignmentsColumns;
@@ -1,3 +1,4 @@
1
+ /** @jsxImportSource @emotion/react */
1
2
  import { MouseEvent } from 'react';
2
3
  import { AssignmentsData, Axis } from '../../../assignment/AssignmentsContext';
3
4
  import { RowDataProps } from './ActionsColumn';
@@ -11,9 +12,7 @@ export interface ZoneAssignmentColumnProps {
11
12
  isActive: any;
12
13
  };
13
14
  assignment: AssignmentsData;
14
- showUnlinkButton: boolean;
15
- setShowUnlinkButton: (element: boolean) => void;
16
15
  rowSpanTags: any;
17
16
  }
18
- declare function ZoneAssignmentColumn({ rowData, assignment, highlight, onHover, onClick, onUnlink, axis, showUnlinkButton, setShowUnlinkButton, rowSpanTags, }: ZoneAssignmentColumnProps): import("react/jsx-runtime").JSX.Element;
17
+ declare function ZoneAssignmentColumn({ rowData, assignment, highlight, onHover, onClick, onUnlink, axis, rowSpanTags, }: ZoneAssignmentColumnProps): import("@emotion/react/jsx-runtime").JSX.Element;
19
18
  export default ZoneAssignmentColumn;
@@ -1,21 +1,29 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import lodashGet from 'lodash/get';
3
- import { FaMinusCircle } from 'react-icons/fa';
4
- function ZoneAssignmentColumn({ rowData, assignment, highlight, onHover, onClick, onUnlink, axis, showUnlinkButton, setShowUnlinkButton, rowSpanTags, }) {
5
- return (_jsx("td", { ...rowSpanTags, ...onHover, ...{ onClick: (e) => onClick(e, assignment, axis) }, children: lodashGet(rowData, `${axis}.nbAtoms`, 0) > 0 ? (lodashGet(rowData, `${axis}.diaIDs`, []).length > 0 ? (_jsxs("div", { onMouseEnter: () => setShowUnlinkButton(true), onMouseLeave: () => setShowUnlinkButton(false), children: [rowData[axis].nbAtoms, " ", `(`, _jsx("span", { style: (assignment.isActive && assignment.activated?.axis === axis) ||
6
- (assignment.isOver && assignment.highlighted?.axis === axis) ||
7
- highlight.isActive
8
- ? {
9
- color: 'red',
10
- fontWeight: 'bold',
11
- }
12
- : { color: 'black', fontWeight: 'normal' }, children: lodashGet(rowData, `${axis}.diaIDs`, []).length }), `)`, ' ', _jsx("sup", { children: _jsx("button", { type: "button", style: {
13
- visibility: showUnlinkButton ? 'visible' : 'hidden',
14
- padding: 0,
15
- margin: 0,
16
- }, onClick: (e) => onUnlink(e, true, axis), children: _jsx(FaMinusCircle, { color: "red" }) }) })] })) : assignment.isActive && assignment.activated?.axis === axis ? (_jsxs("div", { children: [`${lodashGet(rowData, `${axis}.nbAtoms`, '')} (`, _jsx("span", { style: {
17
- color: 'red',
18
- fontWeight: 'bold',
19
- }, children: "0" }), ')'] })) : (rowData[axis].nbAtoms)) : assignment.isActive && assignment.activated?.axis === axis ? (_jsxs("div", { children: ['0 (', _jsx("span", { style: { color: 'red', fontWeight: 'bold' }, children: "0" }), ')'] })) : ('') }));
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ import { RemoveAssignmentsButton, removeAssignmentCssStyle, } from '../../../elements/RemoveAssignmentsButton';
3
+ function getStyle(flag, isCompletelyAssigned) {
4
+ if (flag) {
5
+ return {
6
+ color: 'red',
7
+ fontWeight: 'bold',
8
+ };
9
+ }
10
+ else if (isCompletelyAssigned) {
11
+ return { color: 'green', fontWeight: 'bold' };
12
+ }
13
+ else {
14
+ return { color: 'black', fontWeight: 'normal' };
15
+ }
16
+ }
17
+ function ZoneAssignmentColumn({ rowData, assignment, highlight, onHover, onClick, onUnlink, axis, rowSpanTags, }) {
18
+ const diaIDs = rowData?.[axis].diaIDs || []; // diaIds at the level of zone
19
+ const isAssignmentActive = assignment.isActive && assignment.activated?.axis === axis;
20
+ const flag = isAssignmentActive ||
21
+ (assignment.isOver && assignment.highlighted?.axis === axis) ||
22
+ highlight.isActive;
23
+ let totalNumberOfAtoms = rowData?.[axis]?.nbAtoms || 0;
24
+ for (const signal of rowData?.signals || []) {
25
+ totalNumberOfAtoms += signal?.[axis]?.nbAtoms || 0;
26
+ }
27
+ return (_jsx("td", { ...rowSpanTags, ...onHover, ...{ onClick: (e) => onClick(e, assignment, axis) }, css: !isAssignmentActive && removeAssignmentCssStyle, children: (totalNumberOfAtoms > 0 || isAssignmentActive) && (_jsxs(_Fragment, { children: [totalNumberOfAtoms, " ", ' ( ', _jsx("span", { style: getStyle(flag, false), children: diaIDs?.length || 0 }), ' ) ', _jsx(RemoveAssignmentsButton, { onClick: (e) => onUnlink(e, true, axis) })] })) }));
20
28
  }
21
29
  export default ZoneAssignmentColumn;
@@ -7,10 +7,6 @@ interface ZoneAssignmentsColumnsProps {
7
7
  onClick: (event: any, assignment: AssignmentsData, axis: Axis) => void;
8
8
  onUnlink: (event: any, flag: boolean, axis: Axis) => void;
9
9
  rowSpanTags: any;
10
- showUnlinkButtonZoneX: boolean;
11
- showUnlinkButtonZoneY: boolean;
12
- setShowUnlinkButtonZoneX: (element: boolean) => void;
13
- setShowUnlinkButtonZoneY: (element: boolean) => void;
14
10
  assignmentZone: AssignmentsData;
15
11
  highlightZoneX: {
16
12
  isActive: any;
@@ -19,5 +15,5 @@ interface ZoneAssignmentsColumnsProps {
19
15
  isActive: any;
20
16
  };
21
17
  }
22
- declare function ZoneAssignmentsColumns({ rowData, assignmentZone, onHoverZoneX, onHoverZoneY, showUnlinkButtonZoneX, showUnlinkButtonZoneY, setShowUnlinkButtonZoneX, setShowUnlinkButtonZoneY, rowSpanTags, onClick, onUnlink, highlightZoneX, highlightZoneY, }: ZoneAssignmentsColumnsProps): import("react/jsx-runtime").JSX.Element;
18
+ declare function ZoneAssignmentsColumns({ rowData, assignmentZone, onHoverZoneX, onHoverZoneY, rowSpanTags, onClick, onUnlink, highlightZoneX, highlightZoneY, }: ZoneAssignmentsColumnsProps): import("react/jsx-runtime").JSX.Element;
23
19
  export default ZoneAssignmentsColumns;
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Fragment } from 'react';
3
3
  import ZoneAssignmentColumn from './ZoneAssignmentsColumn';
4
- function ZoneAssignmentsColumns({ rowData, assignmentZone, onHoverZoneX, onHoverZoneY, showUnlinkButtonZoneX, showUnlinkButtonZoneY, setShowUnlinkButtonZoneX, setShowUnlinkButtonZoneY, rowSpanTags, onClick, onUnlink, highlightZoneX, highlightZoneY, }) {
5
- return (_jsxs(Fragment, { children: [_jsx(ZoneAssignmentColumn, { rowData: rowData, assignment: assignmentZone, highlight: highlightZoneX, onHover: onHoverZoneX, onClick: onClick, onUnlink: onUnlink, axis: 'x', showUnlinkButton: showUnlinkButtonZoneX, setShowUnlinkButton: setShowUnlinkButtonZoneX, rowSpanTags: rowSpanTags }), _jsx(ZoneAssignmentColumn, { rowData: rowData, assignment: assignmentZone, highlight: highlightZoneY, onHover: onHoverZoneY, onClick: onClick, onUnlink: onUnlink, axis: 'y', showUnlinkButton: showUnlinkButtonZoneY, setShowUnlinkButton: setShowUnlinkButtonZoneY, rowSpanTags: rowSpanTags })] }));
4
+ function ZoneAssignmentsColumns({ rowData, assignmentZone, onHoverZoneX, onHoverZoneY, rowSpanTags, onClick, onUnlink, highlightZoneX, highlightZoneY, }) {
5
+ return (_jsxs(Fragment, { children: [_jsx(ZoneAssignmentColumn, { rowData: rowData, assignment: assignmentZone, highlight: highlightZoneX, onHover: onHoverZoneX, onClick: onClick, onUnlink: onUnlink, axis: 'x', rowSpanTags: rowSpanTags }), _jsx(ZoneAssignmentColumn, { rowData: rowData, assignment: assignmentZone, highlight: highlightZoneY, onHover: onHoverZoneY, onClick: onClick, onUnlink: onUnlink, axis: 'y', rowSpanTags: rowSpanTags })] }));
6
6
  }
7
7
  export default ZoneAssignmentsColumns;