nmrium 0.59.0 → 0.60.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 (95) hide show
  1. package/lib/component/1d/LinesSeries.js +17 -5
  2. package/lib/component/1d/Viewer1D.js +10 -4
  3. package/lib/component/1d/ranges/Range.js +4 -2
  4. package/lib/component/1d/tool/PivotIndicator.d.ts +1 -0
  5. package/lib/component/1d/tool/{VerticalIndicator.js → PivotIndicator.js} +8 -4
  6. package/lib/component/1d-2d/tools/BrushXY.js +0 -1
  7. package/lib/component/1d-2d/tools/CrossLinePointer.js +0 -1
  8. package/lib/component/2d/Viewer2D.js +1 -1
  9. package/lib/component/2d/tools/PivotIndicator.d.ts +1 -2
  10. package/lib/component/2d/tools/PivotIndicator.js +2 -3
  11. package/lib/component/elements/DialogManager.d.ts +34 -0
  12. package/lib/component/elements/DialogManager.js +96 -0
  13. package/lib/component/elements/DraggableDialog.d.ts +13 -0
  14. package/lib/component/elements/DraggableDialog.js +156 -0
  15. package/lib/component/elements/TabTitle.d.ts +9 -0
  16. package/lib/component/elements/TabTitle.js +18 -0
  17. package/lib/component/header/ApodizationOptionsPanel.js +2 -2
  18. package/lib/component/hooks/useSaveSettings.d.ts +1 -1
  19. package/lib/component/hooks/useSaveSettings.js +18 -22
  20. package/lib/component/main/InnerNMRium.js +2 -2
  21. package/lib/component/main/InnerNMRiumContents.js +5 -0
  22. package/lib/component/modal/EditPeakShapeModal.d.ts +4 -6
  23. package/lib/component/modal/EditPeakShapeModal.js +45 -33
  24. package/lib/component/modal/editRange/EditRangeModal.d.ts +2 -10
  25. package/lib/component/modal/editRange/EditRangeModal.js +26 -54
  26. package/lib/component/modal/editZone/EditZoneModal.d.ts +3 -8
  27. package/lib/component/modal/editZone/EditZoneModal.js +74 -91
  28. package/lib/component/modal/editZone/SignalsForm.d.ts +1 -2
  29. package/lib/component/modal/editZone/SignalsForm.js +33 -50
  30. package/lib/component/modal/editZone/validation/isDefaultPathLength.d.ts +1 -2
  31. package/lib/component/modal/editZone/validation/isDefaultPathLength.js +3 -5
  32. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +13 -3
  33. package/lib/component/panels/PeaksPanel/PeaksTable.js +7 -13
  34. package/lib/component/panels/RangesPanel/RangesHeader.js +0 -3
  35. package/lib/component/panels/RangesPanel/RangesTable.js +6 -3
  36. package/lib/component/panels/RangesPanel/TableColumns/ActionsColumn.js +21 -3
  37. package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.d.ts +6 -5
  38. package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.js +41 -64
  39. package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnField.d.ts +1 -2
  40. package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnField.js +33 -41
  41. package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnHeader.js +66 -55
  42. package/lib/component/panels/SummaryPanel/CorrelationTable/CorrelationTableRow.js +68 -60
  43. package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.d.ts +13 -8
  44. package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.js +17 -81
  45. package/lib/component/panels/SummaryPanel/SummaryPanel.d.ts +3 -0
  46. package/lib/component/panels/SummaryPanel/SummaryPanel.js +4 -1
  47. package/lib/component/panels/SummaryPanel/utilities/Utilities.js +1 -1
  48. package/lib/component/panels/ZonesPanel/TableColumns/ActionsColumn.js +62 -43
  49. package/lib/component/panels/ZonesPanel/ZonesTable.js +4 -1
  50. package/lib/component/panels/ZonesPanel/hooks/useZoneActions.d.ts +5 -0
  51. package/lib/component/panels/ZonesPanel/hooks/useZoneActions.js +40 -0
  52. package/lib/component/reducer/actions/RangesActions.d.ts +1 -0
  53. package/lib/component/reducer/actions/RangesActions.js +9 -4
  54. package/lib/component/reducer/actions/ToolsActions.js +0 -17
  55. package/lib/component/reducer/preferences/actions/matrixGeneration.d.ts +0 -4
  56. package/lib/component/reducer/preferences/actions/matrixGeneration.js +1 -2
  57. package/lib/component/toolbar/ToolTypes.d.ts +1 -1
  58. package/lib/component/toolbar/ToolTypes.js +0 -14
  59. package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +1 -7
  60. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +1 -7
  61. package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +1 -7
  62. package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +1 -7
  63. package/lib/data/molecules/MoleculeManager.d.ts +1 -1
  64. package/lib/data/molecules/MoleculeManager.js +5 -11
  65. package/lib/versionInfo.js +1 -1
  66. package/package.json +2 -2
  67. package/lib/component/1d/tool/VerticalIndicator.d.ts +0 -2
  68. package/lib/component/elements/ContextMenu.d.ts +0 -9
  69. package/lib/component/elements/ContextMenu.js +0 -116
  70. package/lib/component/elements/popup/Modal/ConfirmDialog.d.ts +0 -21
  71. package/lib/component/elements/popup/Modal/ConfirmDialog.js +0 -68
  72. package/lib/component/elements/popup/Modal/Context.d.ts +0 -2
  73. package/lib/component/elements/popup/Modal/Context.js +0 -6
  74. package/lib/component/elements/popup/Modal/Modal.d.ts +0 -9
  75. package/lib/component/elements/popup/Modal/Modal.js +0 -42
  76. package/lib/component/elements/popup/Modal/ModalContent.d.ts +0 -6
  77. package/lib/component/elements/popup/Modal/ModalContent.js +0 -27
  78. package/lib/component/elements/popup/Modal/Provider.d.ts +0 -11
  79. package/lib/component/elements/popup/Modal/Provider.js +0 -172
  80. package/lib/component/elements/popup/Modal/index.d.ts +0 -4
  81. package/lib/component/elements/popup/Modal/index.js +0 -4
  82. package/lib/component/elements/popup/Transition.d.ts +0 -14
  83. package/lib/component/elements/popup/Transition.js +0 -35
  84. package/lib/component/elements/popup/Wrapper.d.ts +0 -8
  85. package/lib/component/elements/popup/Wrapper.js +0 -83
  86. package/lib/component/elements/popup/options.d.ts +0 -28
  87. package/lib/component/elements/popup/options.js +0 -25
  88. package/lib/component/elements/popup/utility.d.ts +0 -2
  89. package/lib/component/elements/popup/utility.js +0 -13
  90. package/lib/component/modal/editZone/EditPathLengthFormik.d.ts +0 -5
  91. package/lib/component/modal/editZone/EditPathLengthFormik.js +0 -67
  92. package/lib/component/modal/editZone/SignalFormTab.d.ts +0 -5
  93. package/lib/component/modal/editZone/SignalFormTab.js +0 -6
  94. package/lib/component/modal/editZone/validation/EditZoneValidation.d.ts +0 -14
  95. package/lib/component/modal/editZone/validation/EditZoneValidation.js +0 -14
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
3
3
  import { css } from '@emotion/react';
4
4
  import { get1DDataXY } from '../../data/data1d/Spectrum1D/get1DDataXY';
5
5
  import { isSpectrum1D } from '../../data/data1d/Spectrum1D/isSpectrum1D';
6
+ import { useBrushTracker } from '../EventsTrackers/BrushTracker';
6
7
  import { useChartData } from '../context/ChartContext';
7
8
  import { useScaleChecked } from '../context/ScaleContext';
8
9
  import { useActiveSpectra } from '../hooks/useActiveSpectra';
@@ -19,16 +20,27 @@ const style = css `
19
20
  }
20
21
  `;
21
22
  function LinesSeries() {
22
- const { data, displayerKey, xDomains, width, margin, height, toolOptions: { selectedTool }, } = useChartData();
23
+ const { data, displayerKey, xDomains } = useChartData();
23
24
  const activeSpectra = useActiveSpectra();
25
+ const spectra = (data?.filter((d) => isSpectrum1D(d) && d.display.isVisible && xDomains[d.id]) || []);
26
+ return (_jsxs("g", { clipPath: `url(#${displayerKey}clip-chart-1d)`, className: "spectra", children: [spectra.map((d, i) => (_jsxs("g", { children: [_jsx(Line, { display: d.display, id: d.id, data: get1DDataXY(d), index: i }), _jsx(HeadlightRectStackMode, { spectrumID: d.id, index: i })] }, d.id))), activeSpectra?.map((activeSpectrum) => (_jsx("use", { href: `#${activeSpectrum.id}` }, activeSpectrum.id)))] }));
27
+ }
28
+ function HeadlightRectStackMode(props) {
29
+ const { spectrumID, index } = props;
30
+ const { step } = useBrushTracker();
31
+ const { width, margin, height, toolOptions: { selectedTool }, } = useChartData();
24
32
  const { shiftY } = useScaleChecked();
25
33
  const verticalAlign = useVerticalAlign();
26
34
  const innerWidth = width - margin.left - margin.right;
27
35
  const innerHeight = height - margin.bottom - SPECTRA_BOTTOM_MARGIN;
28
- const spectra = (data?.filter((d) => isSpectrum1D(d) && d.display.isVisible && xDomains[d.id]) || []);
29
36
  const { setActiveSpectrum } = useSetActiveSpectrumAction();
30
- return (_jsxs("g", { clipPath: `url(#${displayerKey}clip-chart-1d)`, className: "spectra", children: [spectra.map((d, i) => (_jsxs("g", { children: [_jsx(Line, { display: d.display, id: d.id, data: get1DDataXY(d), index: i }), verticalAlign === 'stack' && selectedTool === 'zoom' && (_jsx("rect", { css: style, y: innerHeight - shiftY * i - BOX_SIZE / 2, x: margin.left, width: `${innerWidth}px`, height: `${BOX_SIZE}px`, onClick: (e) => {
31
- setActiveSpectrum(e, d.id);
32
- }, "data-no-export": "true" }))] }, d.id))), activeSpectra?.map((activeSpectrum) => (_jsx("use", { href: `#${activeSpectrum.id}` }, activeSpectrum.id)))] }));
37
+ if (verticalAlign !== 'stack' ||
38
+ selectedTool !== 'zoom' ||
39
+ step === 'brushing') {
40
+ return null;
41
+ }
42
+ return (_jsx("rect", { css: style, y: innerHeight - shiftY * index - BOX_SIZE / 2, x: margin.left, width: `${innerWidth}px`, height: `${BOX_SIZE}px`, onClick: (e) => {
43
+ setActiveSpectrum(e, spectrumID);
44
+ }, "data-no-export": "true" }));
33
45
  }
34
46
  export default LinesSeries;
@@ -30,7 +30,7 @@ import Chart1D from './Chart1D';
30
30
  import FooterBanner from './FooterBanner';
31
31
  import BaseLine from './tool/BaseLine';
32
32
  import PeakPointer from './tool/PeakPointer';
33
- import VerticalIndicator from './tool/VerticalIndicator';
33
+ import { PivotIndicator } from './tool/PivotIndicator';
34
34
  import XLabelPointer from './tool/XLabelPointer';
35
35
  import { getXScale } from './utilities/scale';
36
36
  function Viewer1D({ emptyText = undefined }) {
@@ -181,7 +181,6 @@ function Viewer1D({ emptyText = undefined }) {
181
181
  payload: {
182
182
  zone: { from, to },
183
183
  nucleus: activeTab,
184
- range: { from: xDomain[0], to: xDomain[1] },
185
184
  },
186
185
  });
187
186
  break;
@@ -230,7 +229,6 @@ function Viewer1D({ emptyText = undefined }) {
230
229
  logger,
231
230
  dispatchPreferences,
232
231
  activeTab,
233
- xDomain,
234
232
  openAnalysisModal,
235
233
  ]);
236
234
  const handelOnDoubleClick = useCallback(() => {
@@ -297,6 +295,14 @@ function Viewer1D({ emptyText = undefined }) {
297
295
  }
298
296
  break;
299
297
  }
298
+ case 'phaseCorrection':
299
+ dispatch({
300
+ type: 'SET_ONE_DIMENSION_PIVOT_POINT',
301
+ payload: {
302
+ value: event.x,
303
+ },
304
+ });
305
+ break;
300
306
  case 'zoom':
301
307
  case 'matrixGenerationExclusionZones':
302
308
  if (!showStocsy || !event.shiftKey)
@@ -338,6 +344,6 @@ function Viewer1D({ emptyText = undefined }) {
338
344
  width: '100%',
339
345
  height: `100%`,
340
346
  position: 'absolute',
341
- }, children: [_jsx(CrossLinePointer, {}), _jsx(BrushXY, { brushType: BRUSH_TYPE.X }), _jsx(XLabelPointer, {}), _jsx(PeakPointer, {}), _jsx(VerticalIndicator, {}), _jsx(FooterBanner, {}), _jsx(Chart1D, { width: widthProp, height: heightProp, margin: margin, mode: mode, displayerKey: displayerKey }), _jsx(BaseLine, {})] }) }))] }) })) }), brushData && (_jsx(MultipletAnalysisModal, { isOpen: isOpenAnalysisModal, onClose: closeAnalysisModal, data: data, activeSpectrum: activeSpectrum, scaleX: scaleState.scaleX, ...brushData }))] }));
347
+ }, children: [_jsx(CrossLinePointer, {}), _jsx(BrushXY, { brushType: BRUSH_TYPE.X }), _jsx(XLabelPointer, {}), _jsx(PeakPointer, {}), _jsx(FooterBanner, {}), _jsx(Chart1D, { width: widthProp, height: heightProp, margin: margin, mode: mode, displayerKey: displayerKey }), _jsx(BaseLine, {}), _jsx(PivotIndicator, {})] }) }))] }) })) }), brushData && (_jsx(MultipletAnalysisModal, { isOpen: isOpenAnalysisModal, onClose: closeAnalysisModal, data: data, activeSpectrum: activeSpectrum, scaleX: scaleState.scaleX, ...brushData }))] }));
342
348
  }
343
349
  export default Viewer1D;
@@ -12,12 +12,13 @@ import { useDispatch } from '../../context/DispatchContext';
12
12
  import { useLogger } from '../../context/LoggerContext';
13
13
  import { useShareData } from '../../context/ShareDataContext';
14
14
  import { ActionsButtonsPopover, } from '../../elements/ActionsButtonsPopover';
15
+ import { useDialogData } from '../../elements/DialogManager';
15
16
  import { ResizerWithScale } from '../../elements/ResizerWithScale';
16
17
  import { HighlightEventSource, useHighlight } from '../../highlight';
17
18
  import { useActiveSpectrumRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState';
18
19
  import { useResizerStatus } from '../../hooks/useResizerStatus';
19
20
  import useSpectrum from '../../hooks/useSpectrum';
20
- import { options } from '../../toolbar/ToolTypes';
21
+ import { EditRangeModal } from '../../modal/editRange/EditRangeModal';
21
22
  import { IntegralIndicator } from '../integral/IntegralIndicator';
22
23
  import { useScaleX } from '../utilities/scale';
23
24
  import { AssignmentLabel } from './AssignmentLabel';
@@ -43,7 +44,8 @@ function Range({ range, selectedTool, relativeFormat }) {
43
44
  const { logger } = useLogger();
44
45
  const spectrum = useSpectrum();
45
46
  const { showIntegralsValues } = useActiveSpectrumRangesViewState();
46
- const isBlockedByEditing = selectedTool && selectedTool === options.editRange.id;
47
+ const { isDialogOpen } = useDialogData();
48
+ const isBlockedByEditing = selectedTool && isDialogOpen(EditRangeModal);
47
49
  function handleOnStopResizing(position) {
48
50
  if (!spectrum || !isSpectrum1D(spectrum))
49
51
  return;
@@ -0,0 +1 @@
1
+ export declare function PivotIndicator(): import("react/jsx-runtime").JSX.Element | null;
@@ -8,17 +8,21 @@ const styles = {
8
8
  top: '0px',
9
9
  left: '0px',
10
10
  width: 1,
11
- backgroundColor: 'red',
11
+ backgroundColor: 'yellow',
12
12
  };
13
- function VerticalIndicator() {
13
+ export function PivotIndicator() {
14
14
  const { height, toolOptions: { selectedTool, data: { pivot }, }, } = useChartData();
15
15
  const { scaleX } = useScaleChecked();
16
16
  if (options.phaseCorrection.id !== selectedTool)
17
17
  return null;
18
+ const x = Math.round(scaleX()(pivot.value));
19
+ return _jsx(Indicator, { height: height, x: x });
20
+ }
21
+ function Indicator(props) {
22
+ const { x, height } = props;
18
23
  return (_jsx("div", { style: {
19
24
  ...styles,
20
- transform: `translate(${scaleX()(pivot.value)}px, 0px)`,
25
+ transform: `translate(${x}px, 0px)`,
21
26
  height,
22
27
  } }));
23
28
  }
24
- export default VerticalIndicator;
@@ -24,7 +24,6 @@ const allowTools = new Set([
24
24
  options.rangePicking.id,
25
25
  options.zonePicking.id,
26
26
  options.slicing.id,
27
- options.editRange.id,
28
27
  options.multipleSpectraAnalysis.id,
29
28
  options.exclusionZones.id,
30
29
  options.databaseRangesSelection.id,
@@ -22,7 +22,6 @@ const allowTools = new Set([
22
22
  options.slicing.id,
23
23
  options.integral.id,
24
24
  options.rangePicking.id,
25
- options.editRange.id,
26
25
  options.multipleSpectraAnalysis.id,
27
26
  options.exclusionZones.id,
28
27
  options.databaseRangesSelection.id,
@@ -15,7 +15,7 @@ import { PhaseTraces } from './1d-tracer/phase-correction-traces';
15
15
  import Chart2D from './Chart2D';
16
16
  import FooterBanner from './FooterBanner';
17
17
  import SlicingView from './SlicingView';
18
- import PivotIndicator from './tools/PivotIndicator';
18
+ import { PivotIndicator } from './tools/PivotIndicator';
19
19
  import XYLabelPointer from './tools/XYLabelPointer';
20
20
  import { get2DDimensionLayout, getLayoutID } from './utilities/DimensionLayout';
21
21
  import { get2DXScale, get2DYScale } from './utilities/scale';
@@ -1,2 +1 @@
1
- declare function PivotIndicator(): import("react/jsx-runtime").JSX.Element | null;
2
- export default PivotIndicator;
1
+ export declare function PivotIndicator(): import("react/jsx-runtime").JSX.Element | null;
@@ -9,7 +9,7 @@ function getStyle(direction, translate) {
9
9
  position: 'absolute',
10
10
  top: '0px',
11
11
  left: '0px',
12
- backgroundColor: 'black',
12
+ backgroundColor: 'yellow',
13
13
  zIndex: 9,
14
14
  };
15
15
  if (direction === 'horizontal') {
@@ -27,7 +27,7 @@ function getStyle(direction, translate) {
27
27
  transform: `translateY(${translate}px)`,
28
28
  };
29
29
  }
30
- function PivotIndicator() {
30
+ export function PivotIndicator() {
31
31
  const { pivot, activeTraceDirection } = useActivePhaseTraces();
32
32
  const { toolOptions: { selectedTool }, width, height, margin, yDomain, xDomain, mode, } = useChartData();
33
33
  if (options.phaseCorrectionTwoDimensions.id !== selectedTool || !pivot) {
@@ -44,4 +44,3 @@ function PivotIndicator() {
44
44
  }
45
45
  return _jsx("div", { style: getStyle(activeTraceDirection, translate) });
46
46
  }
47
- export default PivotIndicator;
@@ -0,0 +1,34 @@
1
+ interface DialogItem {
2
+ isOpen: boolean;
3
+ data: any;
4
+ }
5
+ type DialogStates = Record<string, DialogItem>;
6
+ type ComponentIdentifier = string | React.ComponentType<any>;
7
+ export interface DialogProps<T> {
8
+ dialogData: T;
9
+ onCloseDialog: () => void;
10
+ onOpenDialog: () => void;
11
+ }
12
+ interface DialogContextType {
13
+ openDialog: <T>(identifier: ComponentIdentifier, data?: T) => void;
14
+ closeDialog: (identifier: ComponentIdentifier) => void;
15
+ }
16
+ interface DialogDataContextType {
17
+ dialogStates: DialogStates;
18
+ getDialogData: <T>(identifier: ComponentIdentifier) => T | null;
19
+ isDialogOpen: (identifier: ComponentIdentifier) => boolean;
20
+ getDialog: (identifier: ComponentIdentifier) => DialogItem;
21
+ }
22
+ export declare function DialogProvider({ children }: {
23
+ children: any;
24
+ }): import("react/jsx-runtime").JSX.Element;
25
+ export declare function useDialog(): DialogContextType;
26
+ export declare function useDialogData(): DialogDataContextType;
27
+ type WrapperParameters<P> = Omit<P, keyof DialogProps<any>>;
28
+ interface WithDialogOptions {
29
+ dialogName?: string;
30
+ /** force re-render the dialog */
31
+ force?: boolean;
32
+ }
33
+ export declare function withDialog<P extends object>(WrappedComponent: React.ComponentType<P>, options?: WithDialogOptions): (props: WrapperParameters<P>) => import("react/jsx-runtime").JSX.Element | null;
34
+ export {};
@@ -0,0 +1,96 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useMemo, useState } from 'react';
3
+ const DialogContext = createContext(null);
4
+ const DialogDataContext = createContext(null);
5
+ function getDialogIdentifier(componentIdentifier) {
6
+ if (typeof componentIdentifier === 'string') {
7
+ return componentIdentifier;
8
+ }
9
+ else {
10
+ const name = componentIdentifier.displayName || componentIdentifier.name;
11
+ if (!name) {
12
+ throw new Error('Dialog identifier should be defined');
13
+ }
14
+ return name;
15
+ }
16
+ }
17
+ export function DialogProvider({ children }) {
18
+ const [dialogStates, setDialog] = useState({});
19
+ const state = useMemo(() => {
20
+ function closeDialog(componentIdentifier) {
21
+ const identifier = getDialogIdentifier(componentIdentifier);
22
+ setDialog((prevDialogState) => {
23
+ return {
24
+ ...prevDialogState,
25
+ [identifier]: { isOpen: false, data: null },
26
+ };
27
+ });
28
+ }
29
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
30
+ function openDialog(componentIdentifier, data) {
31
+ const identifier = getDialogIdentifier(componentIdentifier);
32
+ setDialog((prevDialogState) => ({
33
+ ...prevDialogState,
34
+ [identifier]: { isOpen: true, data },
35
+ }));
36
+ }
37
+ return { openDialog, closeDialog };
38
+ }, []);
39
+ const dataState = useMemo(() => {
40
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
41
+ function getDialogData(componentIdentifier) {
42
+ const identifier = getDialogIdentifier(componentIdentifier);
43
+ return dialogStates?.[identifier]?.data;
44
+ }
45
+ function isDialogOpen(componentIdentifier) {
46
+ const identifier = getDialogIdentifier(componentIdentifier);
47
+ return dialogStates?.[identifier]?.isOpen || false;
48
+ }
49
+ function getDialog(componentIdentifier) {
50
+ const identifier = getDialogIdentifier(componentIdentifier);
51
+ return dialogStates?.[identifier];
52
+ }
53
+ return { dialogStates, getDialog, getDialogData, isDialogOpen };
54
+ }, [dialogStates]);
55
+ return (_jsx(DialogContext.Provider, { value: state, children: _jsx(DialogDataContext.Provider, { value: dataState, children: children }) }));
56
+ }
57
+ export function useDialog() {
58
+ const context = useContext(DialogContext);
59
+ if (!context) {
60
+ throw new Error('useDialog must be used within a DialogProvider');
61
+ }
62
+ return context;
63
+ }
64
+ export function useDialogData() {
65
+ const context = useContext(DialogDataContext);
66
+ if (!context) {
67
+ throw new Error('useDialogData must be used within a DialogProvider');
68
+ }
69
+ return context;
70
+ }
71
+ export function withDialog(WrappedComponent, options = {}) {
72
+ const { dialogName, force = false } = options;
73
+ return (props) => {
74
+ const { closeDialog, openDialog } = useDialog();
75
+ const { getDialog } = useDialogData();
76
+ const dialogIdentifier = dialogName || getDialogIdentifier(WrappedComponent);
77
+ const { isOpen, data } = getDialog(dialogIdentifier) || {
78
+ isOpen: false,
79
+ data: null,
80
+ };
81
+ function handleCloseDialog() {
82
+ closeDialog(dialogIdentifier);
83
+ }
84
+ function handleOpenDialog() {
85
+ openDialog(dialogIdentifier);
86
+ }
87
+ if (!isOpen) {
88
+ return null;
89
+ }
90
+ // Generate a unique key based on dialogIdentifier and data to force re-render the dialog
91
+ const key = force
92
+ ? `${dialogIdentifier}-${JSON.stringify(data)}`
93
+ : undefined;
94
+ return (_jsx(WrappedComponent, { onCloseDialog: handleCloseDialog, onOpenDialog: handleOpenDialog, dialogData: data, ...props }, key));
95
+ };
96
+ }
@@ -0,0 +1,13 @@
1
+ /** @jsxImportSource @emotion/react */
2
+ import { DialogProps, OverlayProps } from '@blueprintjs/core';
3
+ import { ReactNode } from 'react';
4
+ type DialogPlacement = 'top' | 'bottom' | 'center' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'center-left' | 'center-right';
5
+ interface HeaderElement {
6
+ headerLeftElement?: ReactNode;
7
+ headerRightElement?: ReactNode;
8
+ }
9
+ interface DraggableDialogProps extends Omit<DialogProps, 'hasBackdrop'>, Pick<OverlayProps, 'hasBackdrop'>, HeaderElement {
10
+ placement?: DialogPlacement;
11
+ }
12
+ export declare function DraggableDialog(props: DraggableDialogProps): import("@emotion/react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -0,0 +1,156 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ /** @jsxImportSource @emotion/react */
3
+ import { Button, Classes, H6, Icon, IconSize, mergeRefs, Overlay2, } from '@blueprintjs/core';
4
+ import { SmallCross } from '@blueprintjs/icons';
5
+ import { css, Global } from '@emotion/react';
6
+ import styled from '@emotion/styled';
7
+ import { useLayoutEffect, useRef } from 'react';
8
+ const Container = styled.div `
9
+ min-height: 100%;
10
+ pointer-events: none;
11
+ user-select: none;
12
+ position: absolute;
13
+ top: 0;
14
+ left: 0;
15
+ width: 100%;
16
+ `;
17
+ export function DraggableDialog(props) {
18
+ const { onClose, headerLeftElement, headerRightElement, placement, hasBackdrop, ...otherProps } = props;
19
+ const dialogRef = useRef(null);
20
+ return (_jsxs(_Fragment, { children: [_jsx(Global, { styles: css `
21
+ div[class*='-portal']:has(.draggable-portal) {
22
+ height: 100%;
23
+ pointer-events: ${hasBackdrop === undefined || hasBackdrop
24
+ ? 'all'
25
+ : 'none'};
26
+ }
27
+ ` }), _jsx(Overlay2, { ...otherProps, childRef: dialogRef, onClose: onClose, className: "draggable-portal", hasBackdrop: hasBackdrop, children: _jsx(InnerDraggableDialog, { innerDialogRef: dialogRef, ...props }) })] }));
28
+ }
29
+ function InnerDraggableDialog(props) {
30
+ const { children, containerRef, role = 'dialog', style, className = '', isCloseButtonShown, onClose, icon, title, headerLeftElement, headerRightElement, placement = 'center', innerDialogRef, } = props;
31
+ const offsetRef = useRef({
32
+ x: 0,
33
+ y: 0,
34
+ });
35
+ const containerRefInternal = useRef(null);
36
+ useLayoutEffect(() => {
37
+ const updateTransform = () => {
38
+ if (!innerDialogRef.current || !containerRefInternal.current) {
39
+ return;
40
+ }
41
+ const dialogRect = innerDialogRef.current.getBoundingClientRect();
42
+ const parentContainerRect = containerRefInternal.current.getBoundingClientRect();
43
+ const { transformX, transformY } = calculateTransform(placement, {
44
+ dialogRect,
45
+ parentContainerRect,
46
+ });
47
+ innerDialogRef.current.style.transform = `translate(${transformX}px, ${transformY}px)`;
48
+ };
49
+ const frameId = requestAnimationFrame(updateTransform);
50
+ return () => {
51
+ cancelAnimationFrame(frameId);
52
+ };
53
+ }, [innerDialogRef, placement]);
54
+ function handleMouseDown(event) {
55
+ const target = event.currentTarget;
56
+ if (!containerRefInternal.current) {
57
+ return;
58
+ }
59
+ const dialogRect = target.getBoundingClientRect();
60
+ const containerRect = containerRefInternal.current.getBoundingClientRect();
61
+ const offsetX = event.clientX - (dialogRect.left - containerRect.left);
62
+ const offsetY = event.clientY - (dialogRect.top - containerRect.top);
63
+ offsetRef.current = {
64
+ x: offsetX,
65
+ y: offsetY,
66
+ };
67
+ function handleMouseMove(event) {
68
+ target.style.cursor = 'move';
69
+ if (!innerDialogRef.current || !offsetRef.current) {
70
+ return;
71
+ }
72
+ const offsetX = event.clientX - offsetRef.current.x;
73
+ const offsetY = event.clientY - offsetRef.current.y;
74
+ innerDialogRef.current.style.transform = `translate(${offsetX}px, ${offsetY}px)`;
75
+ }
76
+ function handleMouseUp() {
77
+ target.style.cursor = 'default';
78
+ window.removeEventListener('mousemove', handleMouseMove);
79
+ window.removeEventListener('mouseup', handleMouseUp);
80
+ }
81
+ window.addEventListener('mousemove', handleMouseMove);
82
+ window.addEventListener('mouseup', handleMouseUp);
83
+ }
84
+ return (_jsx(Container, { ref: containerRefInternal, children: _jsxs("div", { ref: containerRef === undefined
85
+ ? innerDialogRef
86
+ : mergeRefs(containerRef, innerDialogRef), className: `${Classes.DIALOG} ${className}`, role: role, style: {
87
+ ...style,
88
+ position: 'fixed',
89
+ margin: 0,
90
+ }, children: [_jsx(Header, { isCloseButtonShown,
91
+ onClose,
92
+ icon,
93
+ title,
94
+ headerLeftElement,
95
+ headerRightElement, onMouseDown: handleMouseDown }), children] }) }));
96
+ }
97
+ function CloseButton(props) {
98
+ const { isCloseButtonShown = true, onClose } = props;
99
+ if (!isCloseButtonShown) {
100
+ return null;
101
+ }
102
+ return (_jsx(Button, { "aria-label": "Close", className: Classes.DIALOG_CLOSE_BUTTON, icon: _jsx(SmallCross, { size: IconSize.STANDARD }), minimal: true, onClick: onClose }));
103
+ }
104
+ function Header(props) {
105
+ const { icon, title, onMouseDown, headerRightElement, headerLeftElement, ...otherProps } = props;
106
+ if (title == null) {
107
+ return null;
108
+ }
109
+ return (_jsxs("div", { className: Classes.DIALOG_HEADER, onMouseDown: onMouseDown, children: [_jsx(Icon, { icon: icon, size: IconSize.STANDARD, tabIndex: -1 }), headerLeftElement, _jsx(H6, { children: title }), headerRightElement, _jsx(CloseButton, { ...otherProps })] }));
110
+ }
111
+ function calculateTransform(placement, option) {
112
+ let transformX = 0;
113
+ let transformY = 0;
114
+ const { parentContainerRect, dialogRect } = option;
115
+ switch (placement) {
116
+ case 'top':
117
+ transformX = (parentContainerRect.width - dialogRect.width) / 2;
118
+ transformY = 0;
119
+ break;
120
+ case 'bottom':
121
+ transformX = (parentContainerRect.width - dialogRect.width) / 2;
122
+ transformY = parentContainerRect.height - dialogRect.height;
123
+ break;
124
+ case 'center':
125
+ transformX = (parentContainerRect.width - dialogRect.width) / 2;
126
+ transformY = (parentContainerRect.height - dialogRect.height) / 2;
127
+ break;
128
+ case 'top-left':
129
+ transformX = 0;
130
+ transformY = 0;
131
+ break;
132
+ case 'top-right':
133
+ transformX = parentContainerRect.width - dialogRect.width;
134
+ transformY = 0;
135
+ break;
136
+ case 'bottom-left':
137
+ transformX = 0;
138
+ transformY = parentContainerRect.height - dialogRect.height;
139
+ break;
140
+ case 'bottom-right':
141
+ transformX = parentContainerRect.width - dialogRect.width;
142
+ transformY = parentContainerRect.height - dialogRect.height;
143
+ break;
144
+ case 'center-left':
145
+ transformX = 0;
146
+ transformY = (parentContainerRect.height - dialogRect.height) / 2;
147
+ break;
148
+ case 'center-right':
149
+ transformX = parentContainerRect.width - dialogRect.width;
150
+ transformY = (parentContainerRect.height - dialogRect.height) / 2;
151
+ break;
152
+ default:
153
+ break;
154
+ }
155
+ return { transformX, transformY };
156
+ }
@@ -0,0 +1,9 @@
1
+ /** @jsxImportSource @emotion/react */
2
+ import { ButtonProps } from '@blueprintjs/core';
3
+ import { ReactNode } from 'react';
4
+ interface TabTitleProps {
5
+ onDelete?: ButtonProps['onClick'];
6
+ children?: ReactNode;
7
+ }
8
+ export declare function TabTitle(props: TabTitleProps): import("@emotion/react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
+ /** @jsxImportSource @emotion/react */
3
+ import { Button, Popover } from '@blueprintjs/core';
4
+ import styled from '@emotion/styled';
5
+ export function TabTitle(props) {
6
+ const { onDelete, children } = props;
7
+ function handleOnDelete(event) {
8
+ event.stopPropagation();
9
+ onDelete?.(event);
10
+ }
11
+ return (_jsx(Popover, { minimal: true, popoverClassName: "popover-tab", position: "top-left", interactionKind: "hover", enforceFocus: false, disabled: typeof onDelete !== 'function', content: _jsx(TabCloseButton, { icon: "cross", intent: "danger", className: "tab-close-btn", onClick: handleOnDelete, small: true }), children: children }));
12
+ }
13
+ const TabCloseButton = styled(Button) `
14
+ border-radius: 50%;
15
+ box-shadow:
16
+ rgb(9 30 66 / 25%) 0 4px 8px -2px,
17
+ rgb(9 30 66 / 8%) 0 0 0 1px !important;
18
+ `;
@@ -75,9 +75,9 @@ function ApodizationOptionsInnerPanel(props) {
75
75
  useEffect(() => {
76
76
  void handleSubmit((values) => onChange(values))();
77
77
  }, [handleSubmit, onChange]);
78
- return (_jsxs(HeaderContainer, { children: [_jsx(Label, { title: "Line broadening:", shortTitle: "LB:", style: headerLabelStyle, children: _jsx(NumberInput2Controller, { control: control, name: "lineBroadening", debounceTime: 250, min: 0, max: 1, stepSize: 0.1, style: { width: '60px' }, onValueChange: () => {
78
+ return (_jsxs(HeaderContainer, { children: [_jsx(Label, { title: "Line broadening:", shortTitle: "LB:", style: headerLabelStyle, children: _jsx(NumberInput2Controller, { control: control, name: "lineBroadening", debounceTime: 250, stepSize: 0.1, style: { width: '60px' }, onValueChange: () => {
79
79
  submitHandler();
80
- } }) }), _jsx(Label, { title: "Gauss broadening:", shortTitle: "GB:", style: headerLabelStyle, children: _jsx(NumberInput2Controller, { control: control, name: "gaussBroadening", debounceTime: 250, min: 0, max: 1, stepSize: 0.1, style: { width: '60px' }, onValueChange: () => {
80
+ } }) }), _jsx(Label, { title: "Gauss broadening:", shortTitle: "GB:", style: headerLabelStyle, children: _jsx(NumberInput2Controller, { control: control, name: "gaussBroadening", debounceTime: 250, stepSize: 0.1, style: { width: '60px' }, onValueChange: () => {
81
81
  submitHandler();
82
82
  } }) }), _jsx(Label, { title: "Line broadening center [0 - 1]:", shortTitle: "LB center:", style: headerLabelStyle, children: _jsx(NumberInput2Controller, { control: control, name: "lineBroadeningCenter", debounceTime: 250, min: 0, max: 1, stepSize: 0.1, style: { width: '60px' }, onValueChange: () => {
83
83
  submitHandler();
@@ -1,5 +1,5 @@
1
1
  import { Workspace } from 'nmr-load-save';
2
2
  export declare function useSaveSettings(): {
3
3
  saveSettings: (values?: Partial<Workspace>) => void;
4
- SaveSettingsModal: () => import("react/jsx-runtime").JSX.Element;
4
+ SaveSettingsModal: () => import("@emotion/react/jsx-runtime").JSX.Element;
5
5
  };
@@ -1,5 +1,7 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Dialog } from '@blueprintjs/core';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ /** @jsxImportSource @emotion/react */
3
+ import { Dialog, DialogBody, DialogFooter } from '@blueprintjs/core';
4
+ import styled from '@emotion/styled';
3
5
  import { yupResolver } from '@hookform/resolvers/yup';
4
6
  import { useRef } from 'react';
5
7
  import { useForm } from 'react-hook-form';
@@ -7,8 +9,8 @@ import { useOnOff } from 'react-science/ui';
7
9
  import * as Yup from 'yup';
8
10
  import { usePreferences } from '../context/PreferencesContext';
9
11
  import { useToaster } from '../context/ToasterContext';
12
+ import ActionButtons from '../elements/ActionButtons';
10
13
  import { Input2Controller } from '../elements/Input2Controller';
11
- import ConfirmationDialog from '../elements/popup/Modal/ConfirmDialog';
12
14
  import { useWorkspaceAction } from './useWorkspaceAction';
13
15
  const schema = Yup.object().shape({
14
16
  workspaceName: Yup.string().required(),
@@ -64,25 +66,19 @@ export function useSaveSettings() {
64
66
  return {
65
67
  saveSettings,
66
68
  SaveSettingsModal: () => {
67
- const alertConfig = {
68
- message: 'Please enter a new user workspace name in order to save your changes locally',
69
- render: (props) => (_jsx(WorkspaceAddForm, { ...props, onEnter: () => {
70
- void handleSubmit(handleAddNewWorkspace)();
71
- }, control: control })),
72
- buttons: [
73
- {
74
- text: 'Save',
75
- handler: () => {
76
- void handleSubmit(handleAddNewWorkspace)();
77
- },
78
- preventClose: true,
79
- },
80
- { text: 'Cancel' },
81
- ],
82
- id: 'save-workspace-dialog',
83
- onClose: closeDialog,
84
- };
85
- return (_jsx(Dialog, { onClose: closeDialog, isOpen: isOpenDialog, title: "Save workspace", children: _jsx(ConfirmationDialog, { disableDefaultStyle: true, ...alertConfig }) }));
69
+ return (_jsxs(Dialog, { onClose: closeDialog, isOpen: isOpenDialog, title: "Save workspace", role: "dialog", children: [_jsxs(DialogContent, { children: [_jsx(Title, { children: "Please enter a new user workspace name in order to save your changes locally" }), _jsx(WorkspaceAddForm, { onEnter: () => {
70
+ void handleSubmit(handleAddNewWorkspace)();
71
+ }, control: control })] }), _jsx(DialogFooter, { children: _jsx(ActionButtons, { style: { flexDirection: 'row-reverse', margin: 0 }, onCancel: closeDialog, doneLabel: "Save workspace", onDone: () => void handleSubmit(handleAddNewWorkspace)() }) })] }));
86
72
  },
87
73
  };
88
74
  }
75
+ const DialogContent = styled(DialogBody) `
76
+ background-color: white;
77
+ text-align: center;
78
+ `;
79
+ const Title = styled.p `
80
+ padding: 0 30px;
81
+ font-weight: bold;
82
+ text-align: left;
83
+ font-size: 1em;
84
+ `;
@@ -9,7 +9,7 @@ import { PreferencesProvider } from '../context/PreferencesContext';
9
9
  import { ToasterProvider } from '../context/ToasterContext';
10
10
  import { TopicMoleculeProvider } from '../context/TopicMoleculeContext';
11
11
  import { AlertProvider } from '../elements/Alert';
12
- import { ModalProvider } from '../elements/popup/Modal';
12
+ import { DialogProvider } from '../elements/DialogManager';
13
13
  import { HighlightProvider } from '../highlight';
14
14
  import { defaultGetSpinner, SpinnerProvider } from '../loader/SpinnerContext';
15
15
  import preferencesReducer, { preferencesInitialState, initPreferencesState, readSettings, } from '../reducer/preferences/preferencesReducer';
@@ -42,5 +42,5 @@ export function InnerNMRium({ data: nmriumData, workspace, customWorkspaces, pre
42
42
  rootRef: rootRef.current,
43
43
  elementsWrapperRef: elementsWrapperRef.current,
44
44
  viewerRef: viewerRef.current,
45
- }, children: _jsx(PreferencesProvider, { value: preferencesState, children: _jsx(LoggerProvider, { children: _jsx(KeyModifiersProvider, { children: _jsx(ToasterProvider, { children: _jsx(NMRiumStateProvider, { onChange: onChange, nmriumData: nmriumData, children: _jsx(TopicMoleculeProvider, { children: _jsx(ModalProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(AlertProvider, { children: _jsx(HighlightProvider, { children: _jsx(AssignmentProvider, { children: _jsx(SpinnerProvider, { value: getSpinner, children: _jsx(InnerNMRiumContents, { emptyText: emptyText, mainDivRef: mainDivRef, elementsWrapperRef: elementsWrapperRef, rootRef: rootRef, viewerRef: viewerRef, apiRef: apiRef }) }) }) }) }) }) }) }) }) }) }) }) }) }));
45
+ }, children: _jsx(PreferencesProvider, { value: preferencesState, children: _jsx(LoggerProvider, { children: _jsx(KeyModifiersProvider, { children: _jsx(ToasterProvider, { children: _jsx(NMRiumStateProvider, { onChange: onChange, nmriumData: nmriumData, children: _jsx(TopicMoleculeProvider, { children: _jsx(DialogProvider, { children: _jsx(AlertProvider, { children: _jsx(HighlightProvider, { children: _jsx(AssignmentProvider, { children: _jsx(SpinnerProvider, { value: getSpinner, children: _jsx(InnerNMRiumContents, { emptyText: emptyText, mainDivRef: mainDivRef, elementsWrapperRef: elementsWrapperRef, rootRef: rootRef, viewerRef: viewerRef, apiRef: apiRef }) }) }) }) }) }) }) }) }) }) }) }) }) }));
46
46
  }
@@ -77,6 +77,11 @@ export function InnerNMRiumContents(props) {
77
77
  padding: 5px;
78
78
  background-color: white;
79
79
  }
80
+
81
+ .popover-tab {
82
+ background-color: transparent;
83
+ box-shadow: none;
84
+ }
80
85
  ` }), _jsxs("div", { className: "nmrium-container", ref: rootRef, css: containerStyles, onContextMenu: preventContextMenuHandler, style: { height: '100%', width: '100%' }, children: [_jsx(DropZone, { children: _jsxs("div", { style: {
81
86
  display: 'flex',
82
87
  flexDirection: 'column',