nmrium 0.54.0 → 0.55.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 (106) hide show
  1. package/lib/component/1d/XAxis.js +1 -1
  2. package/lib/component/1d/integral/IntegralsSeries.js +2 -2
  3. package/lib/component/1d/integral/Integration.d.ts +3 -1
  4. package/lib/component/1d/integral/Integration.js +3 -2
  5. package/lib/component/1d/peaks/PeakEditionManager.js +5 -3
  6. package/lib/component/1d/ranges/AssignmentActionsButtons.d.ts +1 -0
  7. package/lib/component/1d/ranges/AssignmentActionsButtons.js +3 -3
  8. package/lib/component/1d/ranges/AssignmentLabel.d.ts +1 -1
  9. package/lib/component/1d/ranges/AssignmentLabel.js +31 -4
  10. package/lib/component/1d/ranges/Atoms.js +4 -5
  11. package/lib/component/1d/ranges/Range.js +48 -6
  12. package/lib/component/1d/ranges/Ranges.js +2 -1
  13. package/lib/component/1d/ranges/RangesIntegrals.js +11 -4
  14. package/lib/component/1d-2d/FieldEdition.d.ts +13 -0
  15. package/lib/component/1d-2d/FieldEdition.js +42 -0
  16. package/lib/component/2d/Chart2D.js +5 -3
  17. package/lib/component/2d/zones/Zone.js +18 -2
  18. package/lib/component/2d/zones/ZonesAssignmentsLabels.d.ts +7 -0
  19. package/lib/component/2d/zones/ZonesAssignmentsLabels.js +286 -0
  20. package/lib/component/EventsTrackers/KeysListenerTracker.js +14 -1
  21. package/lib/component/context/ShareDataContext.d.ts +10 -0
  22. package/lib/component/context/ShareDataContext.js +22 -0
  23. package/lib/component/elements/ActionsButtonsPopover.d.ts +10 -0
  24. package/lib/component/elements/ActionsButtonsPopover.js +22 -0
  25. package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +7 -5
  26. package/lib/component/elements/ReactTable/ReactTable.d.ts +2 -2
  27. package/lib/component/elements/SVGButton.d.ts +14 -0
  28. package/lib/component/elements/SVGButton.js +6 -0
  29. package/lib/component/elements/SVGGroup.js +15 -13
  30. package/lib/component/elements/SVGText.d.ts +8 -0
  31. package/lib/component/elements/SVGText.js +24 -0
  32. package/lib/component/elements/draggable/SVGDraggable.d.ts +2 -2
  33. package/lib/component/elements/formik/FormikInput.d.ts +2 -1
  34. package/lib/component/elements/formik/FormikInput.js +4 -3
  35. package/lib/component/header/Header.js +7 -10
  36. package/lib/component/hooks/useActiveSpectrumZonesViewState.js +1 -0
  37. package/lib/component/hooks/useCheckPointsNumberInWindowArea.d.ts +1 -1
  38. package/lib/component/hooks/useFormatNumberByNucleus.d.ts +1 -1
  39. package/lib/component/hooks/useFormatNumberByNucleus.js +8 -7
  40. package/lib/component/hooks/useIntegralPath.d.ts +2 -0
  41. package/lib/component/hooks/useIntegralPath.js +3 -1
  42. package/lib/component/hooks/usePanelPreferences.js +1 -2
  43. package/lib/component/hooks/useSaveSettings.js +7 -14
  44. package/lib/component/hooks/useTriggerNewAssignmentLabel.d.ts +4 -0
  45. package/lib/component/hooks/useTriggerNewAssignmentLabel.js +8 -0
  46. package/lib/component/hooks/useWorkspaceAction.d.ts +7 -0
  47. package/lib/component/hooks/useWorkspaceAction.js +89 -0
  48. package/lib/component/loader/DropZone.js +0 -3
  49. package/lib/component/main/InnerNMRium.js +3 -1
  50. package/lib/component/main/InnerNMRiumContents.js +14 -2
  51. package/lib/component/main/NMRiumStateProvider.js +4 -2
  52. package/lib/component/modal/editRange/forms/components/DeltaInput.js +3 -3
  53. package/lib/component/modal/editRange/forms/components/NewSignalTab.js +17 -12
  54. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.js +30 -13
  55. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.js +26 -16
  56. package/lib/component/modal/setting/GeneralSettings.js +7 -21
  57. package/lib/component/modal/setting/WorkspaceItem.js +1 -1
  58. package/lib/component/modal/setting/settings-tabs/NucleiTabContent.d.ts +2 -0
  59. package/lib/component/modal/setting/settings-tabs/NucleiTabContent.js +99 -0
  60. package/lib/component/modal/setting/settingsValidation.js +36 -40
  61. package/lib/component/panels/SpectraPanel/SpectraPreferences.js +13 -1
  62. package/lib/component/panels/SpectraPanel/base/setting/PlotChart.js +1 -1
  63. package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DHistogram.js +1 -1
  64. package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentLabelColumn.d.ts +6 -0
  65. package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentLabelColumn.js +16 -0
  66. package/lib/component/panels/ZonesPanel/ZonesPanel.js +18 -2
  67. package/lib/component/panels/ZonesPanel/ZonesPreferences.js +15 -9
  68. package/lib/component/panels/ZonesPanel/ZonesTable.js +2 -2
  69. package/lib/component/panels/ZonesPanel/ZonesTableRow.js +3 -2
  70. package/lib/component/panels/multipleAnalysisPanel/preferences/index.js +1 -1
  71. package/lib/component/reducer/IgnoreActions.js +1 -0
  72. package/lib/component/reducer/Reducer.js +6 -0
  73. package/lib/component/reducer/actions/DomainActions.d.ts +7 -2
  74. package/lib/component/reducer/actions/DomainActions.js +29 -1
  75. package/lib/component/reducer/actions/RangesActions.js +12 -6
  76. package/lib/component/reducer/actions/ZonesActions.d.ts +15 -2
  77. package/lib/component/reducer/actions/ZonesActions.js +47 -13
  78. package/lib/component/reducer/helper/setRangesViewProperty.d.ts +1 -0
  79. package/lib/component/reducer/helper/setRangesViewProperty.js +11 -11
  80. package/lib/component/reducer/preferences/actions/addWorkspace.js +4 -23
  81. package/lib/component/reducer/preferences/actions/analyzeSpectra.js +4 -4
  82. package/lib/component/reducer/preferences/actions/initPreferences.js +2 -4
  83. package/lib/component/reducer/preferences/actions/matrixGeneration.js +3 -3
  84. package/lib/component/reducer/preferences/actions/removeWorkspace.js +0 -5
  85. package/lib/component/reducer/preferences/actions/setActiveWorkspace.js +0 -4
  86. package/lib/component/reducer/preferences/actions/setPanelsPreferences.js +1 -1
  87. package/lib/component/reducer/preferences/actions/setPreferences.js +2 -16
  88. package/lib/component/reducer/preferences/preferencesReducer.d.ts +7 -0
  89. package/lib/component/reducer/preferences/preferencesReducer.js +21 -18
  90. package/lib/component/toolbar/ToolBar.js +18 -14
  91. package/lib/component/utility/PreferencesHelper.js +5 -4
  92. package/lib/component/utility/export.js +4 -0
  93. package/lib/component/workspaces/assignment.js +0 -1
  94. package/lib/component/workspaces/basic.js +0 -1
  95. package/lib/component/workspaces/embedded.js +0 -1
  96. package/lib/component/workspaces/exercise.js +26 -29
  97. package/lib/component/workspaces/prediction.js +171 -174
  98. package/lib/component/workspaces/process1D.js +0 -1
  99. package/lib/component/workspaces/simulation.js +35 -38
  100. package/lib/component/workspaces/workspaceDefaultProperties.js +9 -11
  101. package/lib/versionInfo.js +1 -1
  102. package/package.json +31 -31
  103. package/lib/component/modal/setting/settings-tabs/FormattingTabContent.d.ts +0 -2
  104. package/lib/component/modal/setting/settings-tabs/FormattingTabContent.js +0 -80
  105. package/lib/component/reducer/preferences/utilities/mapNucleiFormatting.d.ts +0 -2
  106. package/lib/component/reducer/preferences/utilities/mapNucleiFormatting.js +0 -10
@@ -54,7 +54,7 @@ function XAxis(props) {
54
54
  .tickFormat(() => '');
55
55
  // @ts-expect-error This line of code is actually well typed ...
56
56
  d3.select(refAxis.current).call(xAxis);
57
- // @ts-expect-error ditto
57
+ // @ts-expect-error This line of code is actually well typed ...
58
58
  d3.select(refGrid.current).call(grid);
59
59
  }, [height, margin.bottom, margin.top, scaleX, show, xDomain]);
60
60
  if (!width || !height || !scaleX) {
@@ -5,11 +5,11 @@ import useSpectrum from '../../hooks/useSpectrum';
5
5
  import { Integration } from './Integration';
6
6
  const emptyData = { integrals: {}, info: {}, display: {} };
7
7
  export default function IntegralsSeries() {
8
- const { displayerKey, view: { spectra: { activeTab: nucleus }, }, } = useChartData();
8
+ const { displayerKey, view: { spectra: { activeTab: nucleus }, }, xDomain: [from, to], } = useChartData();
9
9
  const integrals = useIntegrals();
10
10
  if (!integrals)
11
11
  return null;
12
- return (_jsx("g", { clipPath: `url(#${displayerKey}clip-chart-1d)`, className: "integrals", children: integrals.values.map((integral) => (_jsx(Integration, { nucleus: nucleus, integral: integral, max: integrals.max }, integral.id))) }));
12
+ return (_jsx("g", { clipPath: `url(#${displayerKey}clip-chart-1d)`, className: "integrals", children: integrals.values.map((integral) => (_jsx(Integration, { nucleus: nucleus, integral: integral, max: integrals.max, from, to }, integral.id))) }));
13
13
  }
14
14
  function useIntegrals() {
15
15
  const spectrum = useSpectrum(emptyData);
@@ -3,6 +3,8 @@ interface IntegralProps {
3
3
  integral: IntegralData;
4
4
  nucleus: string;
5
5
  max: number;
6
+ from: number;
7
+ to: number;
6
8
  }
7
- export declare function Integration({ integral, nucleus, max }: IntegralProps): import("react/jsx-runtime").JSX.Element;
9
+ export declare function Integration(props: IntegralProps): import("react/jsx-runtime").JSX.Element;
8
10
  export {};
@@ -3,10 +3,11 @@ import { useActiveSpectrumIntegralsViewState } from '../../hooks/useActiveSpectr
3
3
  import useIntegralPath from '../../hooks/useIntegralPath';
4
4
  import { usePanelPreferences } from '../../hooks/usePanelPreferences';
5
5
  import IntegralResizable from './IntegralResizable';
6
- export function Integration({ integral, nucleus, max }) {
6
+ export function Integration(props) {
7
+ const { integral, nucleus, max, from, to } = props;
7
8
  const { x, y } = integral;
8
9
  const { scaleRatio } = useActiveSpectrumIntegralsViewState();
9
- const path = useIntegralPath({ x, y, max, scaleRatio });
10
+ const path = useIntegralPath({ x, y, max, scaleRatio, from, to });
10
11
  const { showIntegralsValues } = useActiveSpectrumIntegralsViewState();
11
12
  const integralPreferences = usePanelPreferences('integrals', nucleus);
12
13
  return (_jsxs("g", { children: [_jsx("path", { className: "line", stroke: integralPreferences.color, strokeWidth: integralPreferences.strokeWidth, fill: "none", d: path }), showIntegralsValues && (_jsx(IntegralResizable, { integralData: integral, integralFormat: integralPreferences.relative.format }))] }));
@@ -12,7 +12,9 @@ const validationSchema = Yup.object({
12
12
  });
13
13
  const InputDimension = { height: 28, width: 100 };
14
14
  const peaksEditionContext = {
15
- onEdit: () => { },
15
+ onEdit: () => {
16
+ // Empty default.
17
+ },
16
18
  };
17
19
  const PeaksEditionContext = createContext(peaksEditionContext);
18
20
  function usePeaksEditionManager() {
@@ -59,9 +61,9 @@ export function PeakEditionProvider({ children }) {
59
61
  setPeak(null);
60
62
  }
61
63
  }, []);
62
- const editiionManagerState = useMemo(() => ({ onEdit: handleOnEdit, id: peak?.id }), [peak?.id, handleOnEdit]);
64
+ const editionManagerState = useMemo(() => ({ onEdit: handleOnEdit, id: peak?.id }), [peak?.id, handleOnEdit]);
63
65
  const { x, y } = getPosition();
64
- return (_jsx(PeaksEditionContext.Provider, { value: editiionManagerState, children: _jsxs("div", { onClick: () => setPeak(null), onContextMenu: () => setPeak(null), style: { position: 'relative' }, children: [peak && (_jsx("div", { style: {
66
+ return (_jsx(PeaksEditionContext.Provider, { value: editionManagerState, children: _jsxs("div", { onClick: () => setPeak(null), onContextMenu: () => setPeak(null), style: { position: 'relative' }, children: [peak && (_jsx("div", { style: {
65
67
  position: 'absolute',
66
68
  display: 'block',
67
69
  transform: `translate(${x}px,${y}px)`,
@@ -6,5 +6,6 @@ export interface AssignmentActionsButtonsProps extends Omit<ButtonProps, 'childr
6
6
  className?: string;
7
7
  onAssign: ButtonProps['onClick'];
8
8
  onUnAssign: ButtonProps['onClick'];
9
+ onAddAssignmentLabel?: ButtonProps['onClick'];
9
10
  }
10
11
  export declare function AssignmentActionsButtons(props: AssignmentActionsButtonsProps): import("react/jsx-runtime").JSX.Element;
@@ -1,11 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { FaLink, FaMinus } from 'react-icons/fa';
2
+ import { LuLink, LuUnlink } from 'react-icons/lu';
3
3
  import Button from '../../elements/Button';
4
4
  const styles = {
5
5
  button: { width: '16px', height: '16px', padding: 0 },
6
6
  icon: { fontSize: 9, margin: 'auto' },
7
7
  };
8
8
  export function AssignmentActionsButtons(props) {
9
- const { isActive, onAssign, onUnAssign, x = 0, y = 5, className = 'target', ...otherProps } = props;
10
- return (_jsxs("foreignObject", { width: "16px", height: "34px", x: x, y: y, className: className, "data-no-export": "true", children: [_jsx(Button, { theme: "success", style: styles.button, onClick: onAssign, ...otherProps, children: _jsx(FaLink, { style: styles.icon }) }), isActive && (_jsx(Button, { theme: "danger", style: { ...styles.button, marginTop: '2px' }, onClick: onUnAssign, ...otherProps, children: _jsx(FaMinus, { style: styles.icon }) }))] }));
9
+ const { isActive, onAssign, onUnAssign, onAddAssignmentLabel, x = 0, y = 5, className = 'target', ...otherProps } = props;
10
+ return (_jsxs("foreignObject", { width: "16px", height: "52px", x: x - 16, y: y, className: className, "data-no-export": "true", children: [_jsx(Button, { theme: "success", style: styles.button, onClick: onAssign, ...otherProps, children: _jsx(LuLink, { style: styles.icon }) }), isActive && (_jsx(Button, { theme: "danger", style: { ...styles.button, marginTop: '2px' }, onClick: onUnAssign, ...otherProps, children: _jsx(LuUnlink, { style: styles.icon }) }))] }));
11
11
  }
@@ -1,7 +1,7 @@
1
1
  import { Range } from 'nmr-processing';
2
2
  interface AssignmentLabelProps {
3
3
  range: Range;
4
- x: number;
4
+ width: number;
5
5
  }
6
6
  export declare function AssignmentLabel(props: AssignmentLabelProps): import("react/jsx-runtime").JSX.Element | null;
7
7
  export {};
@@ -1,10 +1,37 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useRef } from 'react';
3
+ import { FieldEdition } from '../../1d-2d/FieldEdition';
4
+ import { useChartData } from '../../context/ChartContext';
5
+ import { useDispatch } from '../../context/DispatchContext';
2
6
  import { useActiveSpectrumRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState';
3
- const marginTop = 55;
7
+ import { useTriggerNewAssignmentLabel } from '../../hooks/useTriggerNewAssignmentLabel';
8
+ const marginTop = 15;
4
9
  export function AssignmentLabel(props) {
5
- const { range, x } = props;
10
+ const { range, width } = props;
11
+ const { id, assignment } = range;
6
12
  const { showAssignmentsLabels } = useActiveSpectrumRangesViewState();
7
- if (!range.assignment || !showAssignmentsLabels)
13
+ const dispatch = useDispatch();
14
+ const textRef = useRef(null);
15
+ const { margin } = useChartData();
16
+ const { isNewAssignment, dismissNewLabel } = useTriggerNewAssignmentLabel(id);
17
+ if ((!range.assignment || !showAssignmentsLabels) && !isNewAssignment) {
8
18
  return null;
9
- return (_jsx("text", { x: x - 5, y: marginTop, fontSize: "12px", fill: "black", textAnchor: "end", children: range.assignment }));
19
+ }
20
+ function handleChange(value) {
21
+ dismissNewLabel();
22
+ dispatch({
23
+ type: 'CHANGE_RANGE_ASSIGNMENT_LABEL',
24
+ payload: {
25
+ value,
26
+ rangeID: id,
27
+ },
28
+ });
29
+ }
30
+ return (_jsx("g", { transform: `translate(${width / 2} ${margin?.top + marginTop})`, children: _jsx(FieldEdition, { onChange: handleChange, inputType: "text", value: assignment || '', PopoverProps: {
31
+ position: 'bottom',
32
+ targetTagName: 'g',
33
+ ...(isNewAssignment
34
+ ? { isOpen: true, onClose: () => dismissNewLabel() }
35
+ : {}),
36
+ }, children: _jsx("text", { ref: textRef, textAnchor: "middle", fill: "black", style: { cursor: 'hand' }, width: width, children: assignment }) }) }));
10
37
  }
@@ -1,9 +1,10 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useChartData } from '../../context/ChartContext';
3
3
  import { useTopicMolecule } from '../../context/TopicMoleculeContext';
4
+ import { SVGGroup } from '../../elements/SVGGroup';
5
+ import { SVGText } from '../../elements/SVGText';
4
6
  const fontSize = 12;
5
- const lineHeight = fontSize * 1.1;
6
- const marginTop = 55;
7
+ const marginTop = 45;
7
8
  function getDiaIds(range) {
8
9
  const { diaIDs = [], signals } = range;
9
10
  const ids = diaIDs.slice();
@@ -37,7 +38,5 @@ export function Atoms(props) {
37
38
  const { range, x } = props;
38
39
  const { view: { molecules }, } = useChartData();
39
40
  const atomsList = useAtoms(range).filter((atomsList) => molecules?.[atomsList.id]?.showAtomNumber);
40
- return (_jsx("g", { transform: `translate(${x},${marginTop})`, children: atomsList.map((row, rowIndex) => (
41
- // eslint-disable-next-line react/no-array-index-key
42
- _jsx("g", { transform: `translate(${rowIndex * lineHeight}, 0)`, children: row.atoms.map((item, colIndex) => (_jsx("text", { x: 0, y: colIndex * lineHeight, fontSize: fontSize, fill: "black", children: item }, colIndex))) }, rowIndex))) }));
41
+ return (_jsx(SVGGroup, { direction: "column", transform: `translate(${x},${marginTop})`, space: 5, children: atomsList.map((row) => (_jsx(SVGText, { x: 0, fontSize: fontSize, borderRadius: 5, padding: 2, rectProps: { fill: 'white', stroke: 'black', strokeWidth: 0.5 }, children: row.atoms.join(',') }, range.id + row.atoms.join(',')))) }));
43
42
  }
@@ -1,6 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
2
  /** @jsxImportSource @emotion/react */
3
3
  import { css } from '@emotion/react';
4
+ import { LuUnlink, LuLink } from 'react-icons/lu';
5
+ import { PiTextTBold, PiTextTSlashBold } from 'react-icons/pi';
4
6
  import { isSpectrum1D, resizeRange } from '../../../data/data1d/Spectrum1D';
5
7
  import { isRangeAssigned } from '../../../data/data1d/Spectrum1D/isRangeAssigned';
6
8
  import { checkRangeKind } from '../../../data/utilities/RangeUtilities';
@@ -8,6 +10,8 @@ import { useAssignment, useAssignmentData, } from '../../assignment/AssignmentsC
8
10
  import { filterForIDsWithAssignment } from '../../assignment/utilities/filterForIDsWithAssignment';
9
11
  import { useDispatch } from '../../context/DispatchContext';
10
12
  import { useLogger } from '../../context/LoggerContext';
13
+ import { useShareData } from '../../context/ShareDataContext';
14
+ import { ActionsButtonsPopover, } from '../../elements/ActionsButtonsPopover';
11
15
  import { ResizerWithScale } from '../../elements/ResizerWithScale';
12
16
  import { HighlightEventSource, useHighlight } from '../../highlight';
13
17
  import { useActiveSpectrumRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState';
@@ -16,7 +20,6 @@ import useSpectrum from '../../hooks/useSpectrum';
16
20
  import { options } from '../../toolbar/ToolTypes';
17
21
  import { IntegralIndicator } from '../integral/IntegralIndicator';
18
22
  import { useScaleX } from '../utilities/scale';
19
- import { AssignmentActionsButtons } from './AssignmentActionsButtons';
20
23
  import { AssignmentLabel } from './AssignmentLabel';
21
24
  import { Atoms } from './Atoms';
22
25
  const style = css `
@@ -31,7 +34,7 @@ const style = css `
31
34
  }
32
35
  `;
33
36
  function Range({ range, selectedTool, relativeFormat }) {
34
- const { id, integration, signals, from, to, diaIDs: rangeDiaIDs } = range;
37
+ const { id, integration, signals, from, to, diaIDs: rangeDiaIDs, assignment, } = range;
35
38
  const assignmentData = useAssignmentData();
36
39
  const assignmentRange = useAssignment(id);
37
40
  const highlightRange = useHighlight([assignmentRange.id].concat(assignmentRange.assigned?.x || []).concat(filterForIDsWithAssignment(assignmentData, signals.map((_signal) => _signal.id))), { type: HighlightEventSource.RANGE, extra: { id } });
@@ -83,10 +86,49 @@ function Range({ range, selectedTool, relativeFormat }) {
83
86
  const isHighlighted = isBlockedByEditing || highlightRange.isActive || assignmentRange.isActive;
84
87
  const isAssigned = isRangeAssigned(range);
85
88
  const isResizingActive = useResizerStatus('rangePicking');
86
- const startX = scaleX()(from) - 16;
87
- return (_jsxs("g", { "data-testid": "range", style: { outline: 'none' }, onMouseEnter: mouseEnterHandler, onMouseLeave: mouseLeaveHandler, ...(!assignmentRange.isActive && { css: style }), children: [_jsx(ResizerWithScale, { from: from, to: to, onEnd: handleOnStopResizing, disabled: !isResizingActive, children: ({ x1, x2 }, isActive) => {
89
+ const { setData: addNewAssignmentLabel } = useShareData();
90
+ const isAssignmentActive = !!(assignmentRange.isActive || rangeDiaIDs);
91
+ function removeAssignemntlabel() {
92
+ dispatch({
93
+ type: 'CHANGE_RANGE_ASSIGNMENT_LABEL',
94
+ payload: {
95
+ value: '',
96
+ rangeID: id,
97
+ },
98
+ });
99
+ }
100
+ const actionsButtons = [
101
+ {
102
+ icon: _jsx(LuLink, {}),
103
+ onClick: assignHandler,
104
+ intent: 'success',
105
+ title: 'Assign range',
106
+ },
107
+ {
108
+ icon: _jsx(LuUnlink, {}),
109
+ onClick: () => unAssignHandler(),
110
+ intent: 'danger',
111
+ title: 'Unassign range',
112
+ visible: isAssignmentActive,
113
+ },
114
+ {
115
+ icon: _jsx(PiTextTBold, {}),
116
+ onClick: () => addNewAssignmentLabel(range.id),
117
+ intent: 'success',
118
+ title: 'Add assignment label',
119
+ visible: !assignment,
120
+ },
121
+ {
122
+ icon: _jsx(PiTextTSlashBold, {}),
123
+ onClick: removeAssignemntlabel,
124
+ intent: 'danger',
125
+ title: 'Remove assignment label',
126
+ visible: !!assignment,
127
+ },
128
+ ];
129
+ return (_jsx("g", { "data-testid": "range", style: { outline: 'none' }, onMouseEnter: mouseEnterHandler, onMouseLeave: mouseLeaveHandler, ...(!assignmentRange.isActive && { css: style }), children: _jsx(ActionsButtonsPopover, { targetTagName: "g", ...(assignmentRange.isActive && { isOpen: true }), buttons: actionsButtons, children: _jsx(ResizerWithScale, { from: from, to: to, onEnd: handleOnStopResizing, disabled: !isResizingActive, children: ({ x1, x2 }, isActive) => {
88
130
  const width = x2 - x1;
89
- return (_jsxs("g", { children: [isAssigned && !isHighlighted && !isActive && (_jsx("rect", { width: width, height: "10px", fill: "#ffd700", opacity: "0.35", "data-no-export": "true" })), _jsx("rect", { width: width, height: "100%", fill: isHighlighted || isActive ? '#ff6f0057' : 'transparent', "data-no-export": "true" }), showIntegralsValues && (_jsx(IntegralIndicator, { value: integration, format: relativeFormat, width: width, opacity: isNotSignal ? 0.5 : 1 }))] }));
90
- } }), _jsx(AssignmentLabel, { range: range, x: startX }), _jsx(Atoms, { range: range, x: startX }), _jsx(AssignmentActionsButtons, { isActive: !!(assignmentRange.isActive || rangeDiaIDs), x: startX, onAssign: assignHandler, onUnAssign: () => unAssignHandler() })] }, id));
131
+ return (_jsxs("g", { children: [isAssigned && !isHighlighted && !isActive && (_jsx("rect", { width: width, height: "10px", fill: "#ffd700", opacity: "0.35", "data-no-export": "true" })), _jsx("rect", { width: width, height: "100%", fill: isHighlighted || isActive ? '#ff6f0057' : 'transparent', "data-no-export": "true" }), _jsx(AssignmentLabel, { range: range, width: width }), _jsx(Atoms, { range: range, x: width / 2 }), showIntegralsValues && (_jsx(IntegralIndicator, { value: integration, format: relativeFormat, width: width, opacity: isNotSignal ? 0.5 : 1 }))] }));
132
+ } }) }) }, id));
91
133
  }
92
134
  export default Range;
@@ -1,12 +1,13 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { memo } from 'react';
3
3
  import { useChartData } from '../../context/ChartContext';
4
+ import { ShareDataProvider } from '../../context/ShareDataContext';
4
5
  import { useActiveSpectrumRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState';
5
6
  import { usePanelPreferences } from '../../hooks/usePanelPreferences';
6
7
  import useSpectrum from '../../hooks/useSpectrum';
7
8
  import Range from './Range';
8
9
  function RangesInner({ ranges, displayerKey, selectedTool, showMultiplicityTrees, relativeFormat, }) {
9
- return (_jsx("g", { clipPath: `url(#${displayerKey}clip-chart-1d)`, children: ranges?.values?.map((range) => (_jsx(Range, { range: range, selectedTool: selectedTool, showMultiplicityTrees: showMultiplicityTrees, relativeFormat: relativeFormat }, range.id))) }));
10
+ return (_jsx(ShareDataProvider, { children: _jsx("g", { clipPath: `url(#${displayerKey}clip-chart-1d)`, children: ranges?.values?.map((range) => (_jsx(Range, { range: range, selectedTool: selectedTool, showMultiplicityTrees: showMultiplicityTrees, relativeFormat: relativeFormat }, range.id))) }) }));
10
11
  }
11
12
  const MemoizedRanges = memo(RangesInner);
12
13
  const emptyData = { ranges: {}, info: {}, display: {} };
@@ -5,14 +5,21 @@ import { useActiveSpectrumRangesViewState } from '../../hooks/useActiveSpectrumR
5
5
  import useIntegralPath from '../../hooks/useIntegralPath';
6
6
  import useSpectrum from '../../hooks/useSpectrum';
7
7
  function Integral(props) {
8
- const { x, y, max } = props;
8
+ const { x, y, max, from, to } = props;
9
9
  const { integralsScaleRatio } = useActiveSpectrumRangesViewState();
10
- const path = useIntegralPath({ x, y, max, scaleRatio: integralsScaleRatio });
10
+ const path = useIntegralPath({
11
+ x,
12
+ y,
13
+ max,
14
+ scaleRatio: integralsScaleRatio,
15
+ from,
16
+ to,
17
+ });
11
18
  return (_jsx("path", { className: "line", stroke: "black", strokeWidth: "1", fill: "none", d: path }));
12
19
  }
13
20
  const emptyData = { ranges: {}, info: {}, display: {} };
14
21
  function RangesIntegrals() {
15
- const { displayerKey } = useChartData();
22
+ const { displayerKey, xDomain: [from, to], } = useChartData();
16
23
  const spectrum = useSpectrum(emptyData);
17
24
  const integrals = useIntegrals();
18
25
  if (!spectrum.ranges?.values ||
@@ -22,7 +29,7 @@ function RangesIntegrals() {
22
29
  return null;
23
30
  }
24
31
  return (_jsx("g", { clipPath: `url(#${displayerKey}clip-chart-1d)`, children: integrals.values.map((integral) => {
25
- return _jsx(Integral, { ...integral, max: integrals.max }, integral.id);
32
+ return (_jsx(Integral, { ...integral, max: integrals.max, from, to }, integral.id));
26
33
  }) }));
27
34
  }
28
35
  function useIntegrals() {
@@ -0,0 +1,13 @@
1
+ /** @jsxImportSource @emotion/react */
2
+ import { PopoverProps } from '@blueprintjs/core';
3
+ import { ReactNode } from 'react';
4
+ type InputType = 'number' | 'text';
5
+ interface FieldEditionsProps {
6
+ value: number | string;
7
+ inputType?: InputType;
8
+ onChange: (value: any) => void;
9
+ children: ReactNode;
10
+ PopoverProps?: PopoverProps;
11
+ }
12
+ export declare function FieldEdition(props: FieldEditionsProps): import("@emotion/react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -0,0 +1,42 @@
1
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
+ /** @jsxImportSource @emotion/react */
3
+ import { Popover } from '@blueprintjs/core';
4
+ import { css } from '@emotion/react';
5
+ import { Formik } from 'formik';
6
+ import { useState } from 'react';
7
+ import * as Yup from 'yup';
8
+ import FormikInput from '../elements/formik/FormikInput';
9
+ const InputDimension = { height: 28, width: 100 };
10
+ const validationSchema = (inputType) => Yup.object({
11
+ value: (inputType === 'number' ? Yup.number() : Yup.string()).required(),
12
+ });
13
+ function stopPropagation(e) {
14
+ e.stopPropagation();
15
+ }
16
+ function keyDownCheck(event) {
17
+ if (event.key === 'Enter') {
18
+ return true;
19
+ }
20
+ else if (event.key === 'Escape') {
21
+ return false;
22
+ }
23
+ }
24
+ export function FieldEdition(props) {
25
+ const { value, inputType = 'text', onChange, children, PopoverProps } = props;
26
+ const [isOpen, setIsOpen] = useState(false);
27
+ function handleOnSubmit({ value: newValue }) {
28
+ onChange(newValue);
29
+ setIsOpen(false);
30
+ }
31
+ return (_jsx(Popover, { css: css `
32
+ .field-edition-popover {
33
+ border-radius: 5px;
34
+ }
35
+ `, popoverClassName: "field-edition-popover", isOpen: isOpen, onClose: () => setIsOpen(false), onInteraction: () => setIsOpen(true), content: _jsx(Formik, { initialValues: { value }, onSubmit: handleOnSubmit, validationSchema: validationSchema(inputType), children: ({ submitForm }) => (_jsx(FormikInput, { type: inputType, style: {
36
+ input: {
37
+ height: `${InputDimension.height}px`,
38
+ padding: '5px',
39
+ outline: 'none',
40
+ },
41
+ }, name: "value", autoSelect: true, onKeyDown: (e) => keyDownCheck(e) && submitForm(), onClick: stopPropagation, onMouseDown: stopPropagation })) }), ...PopoverProps, children: children }));
42
+ }
@@ -3,18 +3,20 @@ import { memo } from 'react';
3
3
  import SpectrumInfoBlock from '../1d-2d/components/SpectrumInfoBlock';
4
4
  import { useChartData } from '../context/ChartContext';
5
5
  import { usePreferences } from '../context/PreferencesContext';
6
+ import { ShareDataProvider } from '../context/ShareDataContext';
6
7
  import XAxis from './XAxis';
7
8
  import YAxis from './YAxis';
8
9
  import { FidContainer } from './fid/FidContainer';
9
10
  import { FTContainer } from './ft/FTContainer';
10
11
  import IndicationLines from './zones/IndicationLines';
11
12
  import Zones from './zones/Zones';
12
- function chart2DInner({ spectra, width, height, margin, displayerKey, spectraRendering, }) {
13
+ import ZonesAssignmentsLabels from './zones/ZonesAssignmentsLabels';
14
+ function Chart2DInner({ spectra, width, height, margin, displayerKey, spectraRendering, }) {
13
15
  return (_jsxs("svg", { id: "nmrSVG", viewBox: `0 0 ${width} ${height}`, width: width, height: height, fontFamily: "Arial, Helvetica, sans-serif", shapeRendering: spectraRendering, style: {
14
16
  position: 'absolute',
15
- }, children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-chart-2d`, children: _jsx("rect", { width: width - margin.left - margin.right, height: height - margin.top - margin.bottom, x: margin.left, y: margin.top }) }) }), _jsx("rect", { width: width - margin.left - margin.right, height: height - margin.top - margin.bottom, x: margin.left, y: margin.top, stroke: "black", strokeWidth: "1", fill: "transparent" }), _jsx(FTContainer, { spectra: spectra }), _jsx(FidContainer, {}), _jsx(Zones, {}), _jsx(IndicationLines, { axis: "X", show: true }), _jsx(IndicationLines, { axis: "Y", show: true }), _jsx(SpectrumInfoBlock, {}), _jsxs("g", { className: "container", style: { pointerEvents: 'none' }, children: [_jsx(XAxis, {}), _jsx(YAxis, {})] })] }));
17
+ }, children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-chart-2d`, children: _jsx("rect", { width: width - margin.left - margin.right, height: height - margin.top - margin.bottom, x: margin.left, y: margin.top }) }) }), _jsx("rect", { width: width - margin.left - margin.right, height: height - margin.top - margin.bottom, x: margin.left, y: margin.top, stroke: "black", strokeWidth: "1", fill: "transparent" }), _jsx(FTContainer, { spectra: spectra }), _jsx(FidContainer, {}), _jsxs(ShareDataProvider, { children: [_jsx(Zones, {}), _jsx(ZonesAssignmentsLabels, {})] }), _jsx(IndicationLines, { axis: "X", show: true }), _jsx(IndicationLines, { axis: "Y", show: true }), _jsx(SpectrumInfoBlock, {}), _jsxs("g", { className: "container", style: { pointerEvents: 'none' }, children: [_jsx(XAxis, {}), _jsx(YAxis, {})] })] }));
16
18
  }
17
- const MemoizedChart2D = memo(chart2DInner);
19
+ const MemoizedChart2D = memo(Chart2DInner);
18
20
  export default function Chart2D({ spectra }) {
19
21
  const { width, height, margin, displayerKey } = useChartData();
20
22
  const { current: { general: { spectraRendering }, }, } = usePreferences();
@@ -1,9 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
2
  /** @jsxImportSource @emotion/react */
3
3
  import { css } from '@emotion/react';
4
+ import styled from '@emotion/styled';
4
5
  import { useState, useEffect } from 'react';
6
+ import { PiTextTBold } from 'react-icons/pi';
5
7
  import { checkZoneKind } from '../../../data/utilities/ZoneUtilities';
6
8
  import { useAssignment } from '../../assignment/AssignmentsContext';
9
+ import { useShareData } from '../../context/ShareDataContext';
10
+ import { SVGButton } from '../../elements/SVGButton';
7
11
  import { HighlightEventSource, useHighlight } from '../../highlight';
8
12
  import { useActiveSpectrumZonesViewState } from '../../hooks/useActiveSpectrumZonesViewState';
9
13
  import { useScale2DX, useScale2DY } from '../utilities/scale';
@@ -37,8 +41,20 @@ const stylesHighlighted = css `
37
41
  cursor: pointer;
38
42
  }
39
43
  `;
44
+ const GroupContainer = styled.g `
45
+ .target {
46
+ visibility: hidden;
47
+ }
48
+
49
+ &:hover {
50
+ .target {
51
+ visibility: visible;
52
+ }
53
+ }
54
+ `;
40
55
  function Zone({ zoneData }) {
41
- const { x, y, id, signals } = zoneData;
56
+ const { x, y, id, signals, assignment } = zoneData;
57
+ const { setData } = useShareData();
42
58
  const assignmentZone = useAssignment(id);
43
59
  const { showZones } = useActiveSpectrumZonesViewState();
44
60
  const highlightZone = useHighlight([assignmentZone.id], {
@@ -61,6 +77,6 @@ function Zone({ zoneData }) {
61
77
  }, onMouseLeave: () => {
62
78
  assignmentZone.hide();
63
79
  highlightZone.hide();
64
- }, children: [showZones && (_jsx("g", { transform: `translate(${scaleX(x2)},${scaleY(y1)})`, children: _jsx("rect", { x: "0", width: scaleX(x1) - scaleX(x2), height: scaleY(y2) - scaleY(y1), className: "integral-area", fill: "#0000000f", stroke: reduceOpacity ? '#343a40' : 'darkgreen', strokeWidth: reduceOpacity ? '0' : '1' }) })), signals.map((_signal, i) => (_jsx(Signal, { signal: _signal }, String(id + i))))] }, id));
80
+ }, children: [showZones && (_jsxs(GroupContainer, { transform: `translate(${scaleX(x2)},${scaleY(y1)})`, children: [_jsx("g", { "data-no-export": "true", transform: "translate(-16 -16)", className: "target", children: !assignment && (_jsx(SVGButton, { renderIcon: (props) => _jsx(PiTextTBold, { ...props }), backgroundColor: "green", title: "Add assignment label", style: { cursor: 'hand' }, onClick: () => setData({ id }) })) }), _jsx("rect", { x: "0", width: scaleX(x1) - scaleX(x2), height: scaleY(y2) - scaleY(y1), className: "integral-area", fill: "#0000000f", stroke: reduceOpacity ? '#343a40' : 'darkgreen', strokeWidth: reduceOpacity ? '0' : '1' })] })), signals.map((_signal, i) => (_jsx(Signal, { signal: _signal }, String(id + i))))] }, id));
65
81
  }
66
82
  export default Zone;
@@ -0,0 +1,7 @@
1
+ import { Zone } from 'nmr-processing';
2
+ interface AssignmentLabelProps {
3
+ zone: Zone;
4
+ }
5
+ export declare function AssignmentLabel(props: AssignmentLabelProps): import("react/jsx-runtime").JSX.Element | null;
6
+ export default function ZonesAssignmentsLabels(): import("react/jsx-runtime").JSX.Element | null;
7
+ export {};