nmrium 0.58.0 → 0.59.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 (112) hide show
  1. package/lib/component/1d/integral/IntegralResizable.js +2 -2
  2. package/lib/component/1d/matrix/useMatrix.d.ts +1 -1
  3. package/lib/component/1d/multiAnalysis/AnalysisRange.js +1 -1
  4. package/lib/component/1d/ranges/Atoms.js +6 -4
  5. package/lib/component/2d/Viewer2D.js +6 -2
  6. package/lib/component/2d/zones/Zone.js +2 -2
  7. package/lib/component/EventsTrackers/KeysListenerTracker.js +8 -8
  8. package/lib/component/context/ChartContext.js +12 -1
  9. package/lib/component/context/ShareDataContext.d.ts +1 -1
  10. package/lib/component/context/ShareDataContext.js +2 -4
  11. package/lib/component/context/ToasterContext.d.ts +1 -0
  12. package/lib/component/context/ToasterContext.js +12 -3
  13. package/lib/component/elements/ActionsButtonsPopover.js +1 -3
  14. package/lib/component/elements/Alert.d.ts +20 -0
  15. package/lib/component/elements/Alert.js +80 -0
  16. package/lib/component/elements/ContextMenuBluePrint.d.ts +7 -2
  17. package/lib/component/elements/ContextMenuBluePrint.js +9 -3
  18. package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +1 -1
  19. package/lib/component/elements/ReactTable/ReactTableFlexLayout.d.ts +0 -3
  20. package/lib/component/elements/ReactTable/ReactTableFlexLayout.js +1 -1
  21. package/lib/component/elements/Select2.d.ts +12 -7
  22. package/lib/component/elements/Select2.js +5 -4
  23. package/lib/component/elements/Select2Controller.d.ts +2 -2
  24. package/lib/component/elements/Select2Controller.js +5 -5
  25. package/lib/component/elements/ToolbarPopoverItem.d.ts +7 -6
  26. package/lib/component/elements/ToolbarPopoverItem.js +13 -5
  27. package/lib/component/elements/print/PrintContent.d.ts +17 -0
  28. package/lib/component/elements/print/PrintContent.js +281 -0
  29. package/lib/component/elements/print/PrintProvider.d.ts +12 -0
  30. package/lib/component/elements/print/PrintProvider.js +28 -0
  31. package/lib/component/elements/print/index.d.ts +2 -0
  32. package/lib/component/elements/print/index.js +2 -0
  33. package/lib/component/header/BaseLineCorrectionPanel.js +3 -0
  34. package/lib/component/hooks/useToggleSpectraVisibility.d.ts +14 -9
  35. package/lib/component/hooks/useToggleSpectraVisibility.js +45 -16
  36. package/lib/component/loader/DropZone.js +3 -67
  37. package/lib/component/loader/useLoadFiles.d.ts +1 -0
  38. package/lib/component/loader/useLoadFiles.js +78 -0
  39. package/lib/component/main/InnerNMRium.d.ts +4 -3
  40. package/lib/component/main/InnerNMRium.js +4 -9
  41. package/lib/component/main/InnerNMRiumContents.d.ts +3 -2
  42. package/lib/component/main/InnerNMRiumContents.js +33 -29
  43. package/lib/component/main/NMRium.d.ts +2 -5
  44. package/lib/component/main/NMRium.js +1 -1
  45. package/lib/component/main/NMRiumRefAPI.d.ts +7 -0
  46. package/lib/component/main/NMRiumRefAPI.js +12 -0
  47. package/lib/component/main/NMRiumViewer.d.ts +10 -0
  48. package/lib/component/main/NMRiumViewer.js +35 -0
  49. package/lib/component/main/index.d.ts +1 -0
  50. package/lib/component/modal/CopyClipboardModal.d.ts +3 -2
  51. package/lib/component/modal/CopyClipboardModal.js +18 -32
  52. package/lib/component/modal/ExportAsJcampModal.d.ts +6 -3
  53. package/lib/component/modal/ExportAsJcampModal.js +69 -35
  54. package/lib/component/modal/ImportPublicationStringModal.js +1 -1
  55. package/lib/component/modal/setting/GeneralSettings.js +4 -2
  56. package/lib/component/modal/setting/settings-tabs/ExternalAPIsTabContent.d.ts +1 -0
  57. package/lib/component/modal/setting/settings-tabs/ExternalAPIsTabContent.js +89 -0
  58. package/lib/component/modal/setting/settingsValidation.js +15 -1
  59. package/lib/component/panels/IntegralsPanel/IntegralPanel.js +8 -5
  60. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +5 -1
  61. package/lib/component/panels/Panels.js +2 -2
  62. package/lib/component/panels/PeaksPanel/PeaksPanel.js +8 -5
  63. package/lib/component/panels/RangesPanel/RangesHeader.js +52 -12
  64. package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +13 -6
  65. package/lib/component/panels/SpectraPanel/SpectraTable.js +63 -21
  66. package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnHeader.js +6 -2
  67. package/lib/component/panels/SummaryPanel/CorrelationTable/CorrelationTableRow.js +6 -2
  68. package/lib/component/panels/SummaryPanel/SummaryPanel.js +4 -0
  69. package/lib/component/panels/ZonesPanel/ZonesPanel.js +16 -8
  70. package/lib/component/panels/databasePanel/DatabasePanel.js +7 -8
  71. package/lib/component/panels/filtersPanel/FilterPanel.js +9 -6
  72. package/lib/component/panels/filtersPanel/FiltersTable.js +12 -10
  73. package/lib/component/panels/header/DefaultPanelHeader.d.ts +1 -0
  74. package/lib/component/panels/header/DefaultPanelHeader.js +2 -2
  75. package/lib/component/panels/multipleAnalysisPanel/AlignSpectra.js +10 -12
  76. package/lib/component/reducer/IgnoreActions.js +1 -0
  77. package/lib/component/reducer/Reducer.js +2 -4
  78. package/lib/component/reducer/actions/DatabaseActions.d.ts +15 -13
  79. package/lib/component/reducer/actions/DatabaseActions.js +52 -34
  80. package/lib/component/reducer/actions/DomainActions.d.ts +2 -2
  81. package/lib/component/reducer/actions/FiltersActions.js +9 -4
  82. package/lib/component/reducer/actions/SpectraActions.d.ts +2 -1
  83. package/lib/component/reducer/actions/SpectraActions.js +53 -43
  84. package/lib/component/reducer/helper/removeSpectrumRelatedObjectsById.d.ts +3 -0
  85. package/lib/component/reducer/helper/removeSpectrumRelatedObjectsById.js +16 -0
  86. package/lib/component/reducer/preferences/actions/changePrintPageSettings.d.ts +3 -0
  87. package/lib/component/reducer/preferences/actions/changePrintPageSettings.js +6 -0
  88. package/lib/component/reducer/preferences/preferencesReducer.d.ts +3 -2
  89. package/lib/component/reducer/preferences/preferencesReducer.js +4 -1
  90. package/lib/component/toolbar/ToolBar.js +33 -14
  91. package/lib/component/workspaces/workspaceDefaultProperties.js +2 -0
  92. package/lib/data/SpectraManager.d.ts +7 -10
  93. package/lib/data/SpectraManager.js +51 -30
  94. package/lib/data/data1d/Spectrum1D/SumManager.d.ts +0 -1
  95. package/lib/data/data1d/Spectrum1D/SumManager.js +2 -10
  96. package/lib/data/data1d/Spectrum1D/get1DColor.d.ts +1 -1
  97. package/lib/data/data1d/Spectrum1D/index.d.ts +1 -1
  98. package/lib/data/data1d/Spectrum1D/index.js +1 -1
  99. package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +10 -10
  100. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +2 -1
  101. package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +10 -10
  102. package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +10 -10
  103. package/lib/data/data1d/Spectrum1D/ranges/resurrectSpectrum.d.ts +13 -0
  104. package/lib/data/data1d/Spectrum1D/ranges/resurrectSpectrum.js +65 -0
  105. package/lib/data/molecules/MoleculeManager.js +16 -38
  106. package/lib/data/utilities/getCustomColor.d.ts +1 -1
  107. package/lib/data/utilities/removeByPaths.d.ts +3 -0
  108. package/lib/data/utilities/removeByPaths.js +33 -0
  109. package/lib/versionInfo.js +1 -1
  110. package/package.json +34 -34
  111. package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.d.ts +0 -11
  112. package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.js +0 -29
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect, useReducer, useRef, useImperativeHandle, } from 'react';
2
+ import { useEffect, useReducer, useRef } from 'react';
3
3
  import { useFullscreen } from 'react-science/ui';
4
4
  import { AssignmentProvider } from '../assignment';
5
5
  import { GlobalProvider } from '../context/GlobalContext';
@@ -8,14 +8,14 @@ import { LoggerProvider } from '../context/LoggerContext';
8
8
  import { PreferencesProvider } from '../context/PreferencesContext';
9
9
  import { ToasterProvider } from '../context/ToasterContext';
10
10
  import { TopicMoleculeProvider } from '../context/TopicMoleculeContext';
11
+ import { AlertProvider } from '../elements/Alert';
11
12
  import { ModalProvider } from '../elements/popup/Modal';
12
13
  import { HighlightProvider } from '../highlight';
13
14
  import { defaultGetSpinner, SpinnerProvider } from '../loader/SpinnerContext';
14
15
  import preferencesReducer, { preferencesInitialState, initPreferencesState, readSettings, } from '../reducer/preferences/preferencesReducer';
15
- import { getBlob } from '../utility/export';
16
16
  import { InnerNMRiumContents } from './InnerNMRiumContents';
17
17
  import NMRiumStateProvider from './NMRiumStateProvider';
18
- export function InnerNMRium({ data: nmriumData, workspace, customWorkspaces, preferences, getSpinner = defaultGetSpinner, onChange, emptyText, innerRef, }) {
18
+ export function InnerNMRium({ data: nmriumData, workspace, customWorkspaces, preferences, getSpinner = defaultGetSpinner, onChange, emptyText, apiRef, }) {
19
19
  const rootRef = useRef(null);
20
20
  const elementsWrapperRef = useRef(null);
21
21
  const viewerRef = useRef(null);
@@ -38,14 +38,9 @@ export function InnerNMRium({ data: nmriumData, workspace, customWorkspaces, pre
38
38
  },
39
39
  });
40
40
  }, [customWorkspaces, preferences, workspace]);
41
- useImperativeHandle(innerRef, () => ({
42
- getSpectraViewerAsBlob: () => {
43
- return rootRef?.current ? getBlob(rootRef.current, 'nmrSVG') : null;
44
- },
45
- }), []);
46
41
  return (_jsx("div", { ref: mainDivRef, style: { height: '100%', position: 'relative' }, translate: "no", children: _jsx(GlobalProvider, { value: {
47
42
  rootRef: rootRef.current,
48
43
  elementsWrapperRef: elementsWrapperRef.current,
49
44
  viewerRef: viewerRef.current,
50
- }, 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(HighlightProvider, { children: _jsx(AssignmentProvider, { children: _jsx(SpinnerProvider, { value: getSpinner, children: _jsx(InnerNMRiumContents, { emptyText: emptyText, mainDivRef: mainDivRef, elementsWrapperRef: elementsWrapperRef, rootRef: rootRef, viewerRef: viewerRef }) }) }) }) }) }) }) }) }) }) }) }) }));
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 }) }) }) }) }) }) }) }) }) }) }) }) }) }));
51
46
  }
@@ -1,12 +1,13 @@
1
1
  /** @jsxImportSource @emotion/react */
2
- import { RefObject } from 'react';
3
- import { NMRiumProps } from '.';
2
+ import { ForwardedRef, RefObject } from 'react';
3
+ import { NMRiumProps, NMRiumRefAPI } from '.';
4
4
  interface InnerNMRiumContentsProps {
5
5
  emptyText: NMRiumProps['emptyText'];
6
6
  mainDivRef: RefObject<HTMLDivElement>;
7
7
  elementsWrapperRef: RefObject<HTMLDivElement>;
8
8
  rootRef: RefObject<HTMLDivElement>;
9
9
  viewerRef: RefObject<HTMLDivElement>;
10
+ apiRef: ForwardedRef<NMRiumRefAPI>;
10
11
  }
11
12
  export declare function InnerNMRiumContents(props: InnerNMRiumContentsProps): import("@emotion/react/jsx-runtime").JSX.Element;
12
13
  export {};
@@ -1,18 +1,18 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
2
2
  /** @jsxImportSource @emotion/react */
3
3
  import { Global, css } from '@emotion/react';
4
- import { useCallback } from 'react';
4
+ import { useCallback, } from 'react';
5
5
  import { useFullscreen } from 'react-science/ui';
6
6
  import checkModifierKeyActivated from '../../data/utilities/checkModifierKeyActivated';
7
- import Viewer1D from '../1d/Viewer1D';
8
- import FloatMoleculeStructures from '../1d-2d/components/FloatMoleculeStructures';
9
- import Viewer2D from '../2d/Viewer2D';
10
7
  import KeysListenerTracker from '../EventsTrackers/KeysListenerTracker';
11
- import { useChartData } from '../context/ChartContext';
8
+ import { usePreferences } from '../context/PreferencesContext';
9
+ import { PrintContent } from '../elements/print/PrintContent';
12
10
  import Header from '../header/Header';
13
11
  import DropZone from '../loader/DropZone';
14
12
  import Panels from '../panels/Panels';
15
13
  import ToolBar from '../toolbar/ToolBar';
14
+ import { useNMRiumRefAPI } from './NMRiumRefAPI';
15
+ import { NMRiumViewer } from './NMRiumViewer';
16
16
  import { SplitPaneWrapper } from './SplitPaneWrapper';
17
17
  import { StateError } from './StateError';
18
18
  const viewerContainerStyle = css `
@@ -63,40 +63,44 @@ const containerStyles = css `
63
63
  }
64
64
  `;
65
65
  export function InnerNMRiumContents(props) {
66
- const { emptyText, mainDivRef, elementsWrapperRef, rootRef, viewerRef } = props;
67
- const { displayerMode } = useChartData();
66
+ const { emptyText, mainDivRef, elementsWrapperRef, rootRef, viewerRef, apiRef, } = props;
68
67
  const { isFullScreen } = useFullscreen();
69
68
  const preventContextMenuHandler = useCallback((e) => {
70
69
  if (!checkModifierKeyActivated(e)) {
71
70
  e.preventDefault();
72
71
  }
73
72
  }, []);
73
+ useNMRiumRefAPI(apiRef, rootRef);
74
74
  return (_jsxs(_Fragment, { children: [_jsx(StateError, {}), _jsx(Global, { styles: css `
75
75
  .actions-buttons-popover {
76
76
  border-radius: 10px;
77
77
  padding: 5px;
78
78
  background-color: white;
79
79
  }
80
- ` }), _jsx("div", { className: "nmrium-container", ref: rootRef, css: containerStyles, onContextMenu: preventContextMenuHandler, style: { height: '100%', width: '100%' }, children: _jsx(DropZone, { children: _jsxs("div", { style: {
81
- display: 'flex',
82
- flexDirection: 'column',
83
- backgroundColor: 'white',
84
- width: '100%',
85
- }, children: [_jsx(Header, {}), _jsxs("div", { style: {
86
- display: 'flex',
87
- flexDirection: 'row',
88
- height: '100%',
89
- }, children: [_jsx(ToolBar, {}), _jsxs(SplitPaneWrapper, { children: [_jsxs("div", { css: viewerContainerStyle, children: [_jsx(KeysListenerTracker, { mainDivRef: mainDivRef }), _jsxs("div", { id: "nmrium-viewer", "data-testid": "viewer", ref: viewerRef, style: {
90
- width: '100%',
91
- height: '100%',
92
- position: 'relative',
93
- }, children: [_jsx(FloatMoleculeStructures, {}), displayerMode === '1D' ? (_jsx(Viewer1D, { emptyText: emptyText })) : (_jsx(Viewer2D, { emptyText: emptyText }))] })] }), _jsx(Panels, {})] }), _jsx("div", { ref: elementsWrapperRef, id: "main-wrapper", style: {
94
- position: 'absolute',
95
- pointerEvents: 'none',
96
- zIndex: 10,
97
- left: 0,
98
- right: 0,
99
- top: 0,
100
- bottom: 0,
101
- } }, String(isFullScreen))] })] }) }) })] }));
80
+ ` }), _jsxs("div", { className: "nmrium-container", ref: rootRef, css: containerStyles, onContextMenu: preventContextMenuHandler, style: { height: '100%', width: '100%' }, children: [_jsx(DropZone, { children: _jsxs("div", { style: {
81
+ display: 'flex',
82
+ flexDirection: 'column',
83
+ backgroundColor: 'white',
84
+ width: '100%',
85
+ }, children: [_jsx(Header, {}), _jsxs("div", { style: {
86
+ display: 'flex',
87
+ flexDirection: 'row',
88
+ height: '100%',
89
+ }, children: [_jsx(ToolBar, {}), _jsxs(SplitPaneWrapper, { children: [_jsxs("div", { css: viewerContainerStyle, children: [_jsx(KeysListenerTracker, { mainDivRef: mainDivRef }), _jsx(NMRiumViewer, { emptyText: emptyText, viewerRef: viewerRef })] }), _jsx(Panels, {})] }), _jsx("div", { ref: elementsWrapperRef, id: "main-wrapper", style: {
90
+ position: 'absolute',
91
+ pointerEvents: 'none',
92
+ zIndex: 10,
93
+ left: 0,
94
+ right: 0,
95
+ top: 0,
96
+ bottom: 0,
97
+ } }, String(isFullScreen))] })] }) }), _jsx("div", {}), _jsx(PrintWrapper, { children: _jsx(NMRiumViewer, { emptyText: emptyText, viewerRef: viewerRef }) })] })] }));
98
+ }
99
+ function PrintWrapper(props) {
100
+ const { children } = props;
101
+ const { current: { printPageOptions }, dispatch, } = usePreferences();
102
+ function handleSavePrintOptions(options) {
103
+ dispatch({ type: 'CHANGE_PRINT_PAGE_SETTINGS', payload: options });
104
+ }
105
+ return (_jsx(PrintContent, { defaultPrintPageOptions: printPageOptions, onPrint: handleSavePrintOptions, children: children }));
102
106
  }
@@ -1,7 +1,7 @@
1
1
  import type { CustomWorkspaces, WorkspacePreferences as NMRiumPreferences } from 'nmr-load-save';
2
2
  import { ReactElement, ReactNode } from 'react';
3
3
  import { ErrorBoundaryPropsWithComponent } from 'react-error-boundary';
4
- import { BlobObject } from '../utility/export';
4
+ import { NMRiumRefAPI } from './NMRiumRefAPI';
5
5
  import { NMRiumChangeCb, NMRiumData, NMRiumWorkspace } from './types';
6
6
  export interface NMRiumProps {
7
7
  data?: NMRiumData;
@@ -17,7 +17,4 @@ export interface NMRiumProps {
17
17
  */
18
18
  getSpinner?: () => ReactElement;
19
19
  }
20
- export interface NMRiumRef {
21
- getSpectraViewerAsBlob: () => BlobObject | null;
22
- }
23
- export declare const NMRium: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<NMRiumProps & import("react").RefAttributes<NMRiumRef>>>;
20
+ export declare const NMRium: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<NMRiumProps & import("react").RefAttributes<NMRiumRefAPI>>>;
@@ -6,7 +6,7 @@ import ErrorOverlay from './ErrorOverlay';
6
6
  import { InnerNMRium } from './InnerNMRium';
7
7
  const NMRiumBase = forwardRef(function NMRium(props, ref) {
8
8
  const { noErrorBoundary = false, onError, ...otherProps } = props;
9
- const innerNmrium = _jsx(InnerNMRium, { ...otherProps, innerRef: ref });
9
+ const innerNmrium = _jsx(InnerNMRium, { ...otherProps, apiRef: ref });
10
10
  const children = noErrorBoundary ? (innerNmrium) : (_jsx(ErrorBoundary, { FallbackComponent: ErrorOverlay, onError: onError, children: innerNmrium }));
11
11
  return (_jsx(FullScreenProvider, { children: _jsx(RootLayout, { style: { width: '100%' }, children: children }) }));
12
12
  });
@@ -0,0 +1,7 @@
1
+ import { ForwardedRef, RefObject } from 'react';
2
+ import { BlobObject } from '../utility/export';
3
+ export interface NMRiumRefAPI {
4
+ getSpectraViewerAsBlob: () => BlobObject | null;
5
+ loadFiles: (files: File[]) => void;
6
+ }
7
+ export declare function useNMRiumRefAPI(ref: ForwardedRef<NMRiumRefAPI>, rootRef: RefObject<HTMLDivElement>): void;
@@ -0,0 +1,12 @@
1
+ import { useImperativeHandle } from 'react';
2
+ import { useLoadFiles } from '../loader/useLoadFiles';
3
+ import { getBlob } from '../utility/export';
4
+ export function useNMRiumRefAPI(ref, rootRef) {
5
+ const loadFiles = useLoadFiles();
6
+ useImperativeHandle(ref, () => ({
7
+ getSpectraViewerAsBlob: () => {
8
+ return rootRef.current ? getBlob(rootRef.current, 'nmrSVG') : null;
9
+ },
10
+ loadFiles,
11
+ }), [rootRef, loadFiles]);
12
+ }
@@ -0,0 +1,10 @@
1
+ import { CSSProperties, RefObject } from 'react';
2
+ import { NMRiumProps } from './NMRium';
3
+ interface NMRiumViewerProps {
4
+ emptyText: NMRiumProps['emptyText'];
5
+ viewerRef: RefObject<HTMLDivElement>;
6
+ style?: CSSProperties;
7
+ onRender?: () => void;
8
+ }
9
+ export declare function NMRiumViewer(props: NMRiumViewerProps): import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1,35 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useDeferredValue, useEffect } from 'react';
3
+ import Viewer1D from '../1d/Viewer1D';
4
+ import FloatMoleculeStructures from '../1d-2d/components/FloatMoleculeStructures';
5
+ import Viewer2D from '../2d/Viewer2D';
6
+ import { useChartData } from '../context/ChartContext';
7
+ export function NMRiumViewer(props) {
8
+ const { emptyText, viewerRef, onRender, style = {} } = props;
9
+ const { displayerMode, width, height } = useChartData();
10
+ const renderDimension = useDeferredValue({ width, height });
11
+ useEffect(() => {
12
+ function handleRenderComplete() {
13
+ if (typeof onRender !== 'function') {
14
+ return;
15
+ }
16
+ setTimeout(() => {
17
+ if (renderDimension.width !== width ||
18
+ renderDimension.height !== height) {
19
+ onRender();
20
+ }
21
+ }, 0);
22
+ }
23
+ const animationFrameId = requestAnimationFrame(handleRenderComplete);
24
+ return () => {
25
+ cancelAnimationFrame(animationFrameId);
26
+ };
27
+ }, [onRender, width, height, renderDimension.width, renderDimension.height]);
28
+ return (_jsxs("div", { id: "nmrium-viewer", "data-testid": "viewer", ref: viewerRef, style: {
29
+ width: '100%',
30
+ height: '100%',
31
+ position: 'relative',
32
+ backgroundColor: 'white',
33
+ ...style,
34
+ }, children: [_jsx(FloatMoleculeStructures, {}), displayerMode === '1D' ? (_jsx(Viewer1D, { emptyText: emptyText })) : (_jsx(Viewer2D, { emptyText: emptyText }))] }));
35
+ }
@@ -1,3 +1,4 @@
1
1
  export * from './types';
2
2
  export { serializeNmriumState as serializeNMRiumState } from 'nmr-load-save';
3
3
  export * from './NMRium';
4
+ export type { NMRiumRefAPI } from './NMRiumRefAPI';
@@ -1,7 +1,8 @@
1
1
  interface CopyClipboardModalProps {
2
- text: string;
2
+ text?: string;
3
+ title: string;
3
4
  onClose: () => void;
4
5
  onCopyClick: (text: string) => void;
5
6
  }
6
- declare function CopyClipboardModal({ text, onClose, onCopyClick, }: CopyClipboardModalProps): import("@emotion/react/jsx-runtime").JSX.Element;
7
+ declare function CopyClipboardModal(props: CopyClipboardModalProps): import("@emotion/react/jsx-runtime").JSX.Element | undefined;
7
8
  export default CopyClipboardModal;
@@ -1,39 +1,25 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
2
  /** @jsxImportSource @emotion/react */
3
+ import { Button, Dialog, DialogBody, DialogFooter } from '@blueprintjs/core';
3
4
  import { css } from '@emotion/react';
5
+ import styled from '@emotion/styled';
4
6
  import { FaCopy } from 'react-icons/fa';
5
- import { CloseButton } from '../elements/CloseButton';
6
- const styles = css `
7
- overflow: auto;
8
- width: 400px;
9
-
10
- .inner-container {
11
- padding: 5px;
12
- width: 100%;
13
- height: 180px;
14
- border: none;
15
- }
16
-
17
- .main-buttons-container {
18
- padding: 5px 0;
19
- border-bottom: 0.55px solid #ebebeb;
20
- display: flex;
21
- justify-content: space-between;
22
- }
23
-
24
- button {
25
- background-color: transparent;
26
- border: none;
27
- padding: 0 5px;
28
- }
29
-
30
- button:disabled {
31
- opacity: 0.6;
32
- }
7
+ const Body = styled.div `
8
+ padding: 5px;
9
+ width: 100%;
10
+ height: 180px;
11
+ border: none;
33
12
  `;
34
- function CopyClipboardModal({ text, onClose, onCopyClick, }) {
35
- return (_jsxs("div", { css: styles, children: [_jsxs("div", { className: "main-buttons-container handle", children: [_jsx("button", { type: "button", onClick: () => onCopyClick(text), children: _jsx(FaCopy, {}) }), _jsx(CloseButton, { tooltip: "Close", onClick: onClose })] }), _jsx("div", { className: "inner-container",
36
- // eslint-disable-next-line react/no-danger
37
- dangerouslySetInnerHTML: { __html: text } })] }));
13
+ function CopyClipboardModal(props) {
14
+ const { text, ...otherProps } = props;
15
+ if (!text)
16
+ return;
17
+ return _jsx(InnerCopyClipboardModal, { text: text, ...otherProps });
18
+ }
19
+ function InnerCopyClipboardModal(props) {
20
+ const { text, title, onClose, onCopyClick } = props;
21
+ return (_jsxs(Dialog, { isOpen: true, title: title, onClose: onClose, children: [_jsx(DialogBody, { css: css `
22
+ background-color: white;
23
+ `, children: _jsx(Body, { dangerouslySetInnerHTML: { __html: text } }) }), _jsx(DialogFooter, { children: _jsx(Button, { onClick: () => onCopyClick(text), intent: "success", icon: _jsx(FaCopy, {}) }) })] }));
38
24
  }
39
25
  export default CopyClipboardModal;
@@ -1,7 +1,10 @@
1
1
  import { Spectrum } from 'nmr-load-save';
2
- interface ExportAsJCAMPProps {
2
+ interface InnerExportAsJCAMPProps {
3
3
  closeDialog: () => void;
4
- spectrum: Spectrum;
4
+ spectrum?: Spectrum;
5
5
  }
6
- declare function ExportAsJcampModal(props: ExportAsJCAMPProps): import("@emotion/react/jsx-runtime").JSX.Element;
6
+ interface ExportAsJCAMPProps extends InnerExportAsJCAMPProps {
7
+ exportActiveSpectrum?: boolean;
8
+ }
9
+ declare function ExportAsJcampModal(props: ExportAsJCAMPProps): import("@emotion/react/jsx-runtime").JSX.Element | null;
7
10
  export default ExportAsJcampModal;
@@ -2,52 +2,82 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
2
  /** @jsxImportSource @emotion/react */
3
3
  import { Dialog, DialogBody, DialogFooter } from '@blueprintjs/core';
4
4
  import { css } from '@emotion/react';
5
- import { Formik } from 'formik';
6
5
  import { useRef } from 'react';
7
- import { DataExportStage, exportAsJcamp, } from '../../data/SpectraManager';
6
+ import { exportAsJcamp } from '../../data/SpectraManager';
8
7
  import { useToaster } from '../context/ToasterContext';
9
8
  import ActionButtons from '../elements/ActionButtons';
10
- import FormikCheckBox from '../elements/formik/FormikCheckBox';
11
- import FormikSelect from '../elements/formik/FormikSelect';
12
- const initValues = {
13
- onlyReal: true,
14
- dataExportStage: 'PROCESSED',
15
- };
16
- const styles = {
17
- container: {
18
- width: '25em',
19
- padding: '1.5em 3em',
20
- display: 'flex',
21
- flexDirection: 'column',
9
+ import Label from '../elements/Label';
10
+ import { Select2 } from '../elements/Select2';
11
+ import useSpectrum from '../hooks/useSpectrum';
12
+ const originalFidExportDataTypes = [
13
+ {
14
+ label: 'Original FID',
15
+ value: 'originalFid',
16
+ },
17
+ ];
18
+ const originalFtDataTypes = [
19
+ {
20
+ label: 'Original FT real',
21
+ value: 'originalFtReal',
22
22
  },
23
- row: {
24
- display: 'flex',
25
- paddingBottom: '0.5em',
23
+ {
24
+ label: 'Original FT real and imaginary',
25
+ value: 'originalFtRealImaginary',
26
26
  },
27
- label: {
28
- flex: 6,
29
- fontSize: '1em',
30
- fontWeight: 'bold',
27
+ ];
28
+ const processedDataTypes = [
29
+ {
30
+ label: 'Processed real',
31
+ value: 'processedReal',
31
32
  },
32
- innerContainer: {
33
- flex: 6,
34
- justifyContent: 'flex-start',
33
+ {
34
+ label: 'Processed real and imaginary',
35
+ value: 'processedRealImaginary',
35
36
  },
37
+ ];
38
+ const labelStyle = {
39
+ wrapper: { display: 'flex', height: '100%', flex: 1 },
40
+ container: { alignItems: 'flex-start' },
41
+ label: { paddingTop: '5px', width: 80 },
36
42
  };
37
- const DATA_STAGES = Object.keys(DataExportStage).map((key) => ({
38
- label: key,
39
- value: DataExportStage[key],
40
- }));
41
43
  function ExportAsJcampModal(props) {
44
+ const { spectrum, exportActiveSpectrum = false } = props;
45
+ const activeSpectrum = useSpectrum();
46
+ if (!exportActiveSpectrum && !spectrum) {
47
+ return null;
48
+ }
49
+ if (exportActiveSpectrum && !activeSpectrum)
50
+ return null;
51
+ const currentSpectrum = exportActiveSpectrum ? activeSpectrum : spectrum;
52
+ if (!currentSpectrum)
53
+ return null;
54
+ return _jsx(InnerExportAsJcampModal, { spectrum: currentSpectrum, ...props });
55
+ }
56
+ function getExportDataTypes(spectrum) {
57
+ const { originalInfo, filters } = spectrum;
58
+ const menuItems = [];
59
+ if (originalInfo?.isFt) {
60
+ menuItems.push(...originalFtDataTypes);
61
+ }
62
+ if (originalInfo?.isFid) {
63
+ menuItems.push(...originalFidExportDataTypes);
64
+ }
65
+ if (filters?.length > 0) {
66
+ menuItems.push(...processedDataTypes);
67
+ }
68
+ return menuItems;
69
+ }
70
+ function InnerExportAsJcampModal(props) {
42
71
  const { closeDialog, spectrum } = props;
43
- const refForm = useRef(null);
44
72
  const toaster = useToaster();
45
- function submitHandler(options) {
73
+ const exportDataTypes = getExportDataTypes(spectrum);
74
+ const exportDataAsRef = useRef(exportDataTypes[0].value);
75
+ function submitHandler() {
46
76
  const hideLoading = toaster.showLoading({
47
77
  message: 'export as JCAMP-DX in progress',
48
78
  });
49
79
  try {
50
- exportAsJcamp(spectrum, options);
80
+ exportAsJcamp(spectrum, exportDataAsRef.current);
51
81
  }
52
82
  catch (error) {
53
83
  toaster.show({ message: error.message, intent: 'danger' });
@@ -57,10 +87,14 @@ function ExportAsJcampModal(props) {
57
87
  hideLoading();
58
88
  }
59
89
  }
60
- return (_jsxs(Dialog, { isOpen: true, onClose: closeDialog, title: "Export as JCAMP", children: [_jsx(DialogBody, { css: css `
90
+ function handleChangeExportDataType(data) {
91
+ exportDataAsRef.current = data.value;
92
+ }
93
+ return (_jsxs(Dialog, { isOpen: true, style: { width: 400 }, onClose: closeDialog, title: "Export as JCAMP", children: [_jsx(DialogBody, { css: css `
61
94
  background-color: white;
62
- `, children: _jsx(Formik, { innerRef: refForm, initialValues: initValues, onSubmit: submitHandler, children: _jsxs("div", { style: styles.container, children: [_jsxs("div", { style: styles.row, children: [_jsx("span", { style: styles.label, children: " Data " }), _jsx("div", { style: styles.innerContainer, children: _jsx(FormikSelect, { name: "dataExportStage", items: DATA_STAGES, style: { width: '100%' } }) })] }), _jsxs("div", { style: styles.row, children: [_jsx("span", { style: styles.label, children: " Only real " }), _jsx("div", { style: styles.innerContainer, children: _jsx(FormikCheckBox, { name: "onlyReal" }) })] })] }) }) }), _jsx(DialogFooter, { children: _jsx("div", { style: { display: 'flex', justifyContent: 'flex-end' }, children: _jsx(ActionButtons, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: () => refForm.current?.submitForm(), doneLabel: "export", onCancel: () => {
63
- closeDialog?.();
64
- } }) }) })] }));
95
+ padding: 1.5em 3em;
96
+ `, children: _jsx(Label, { title: "Data", style: labelStyle, children: _jsx(Select2, { defaultSelectedItem: exportDataTypes[0], onItemSelect: handleChangeExportDataType, items: exportDataTypes }) }) }), _jsx(DialogFooter, { children: _jsx(ActionButtons, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: submitHandler, doneLabel: "export", onCancel: () => {
97
+ closeDialog?.();
98
+ } }) })] }));
65
99
  }
66
100
  export default ExportAsJcampModal;
@@ -27,7 +27,7 @@ function handleRowStyle(data) {
27
27
  return { base: { backgroundColor } };
28
28
  }
29
29
  const INITIAL_VALUES = {
30
- publicationText: '1H NMR (CDCl3, 400MHz) δ 10.58 (b, 1H), 7.40 (d, 1H, J = 8.0 Hz), 6.19 (d, 1H, J = 7.6 Hz), 4.88 (s, 1H), 2.17 (s, 3H), 1.02 (s, 9H), 1.01 (s, 9H), 0.89 (s, 9H)',
30
+ publicationText: '1H NMR (CDCl3, 400MHz) δ 1 (s, 1H), 2 (d, 1H, J=7), 3 (t, 1H, J=7), 4 (q, 1H, J=7), 5 (quint, 1H, J=7), 6 (hex, 1H, J=7), 7 (hept, 1H, J=7), 8 (dd, 1H, J=7, J=4)',
31
31
  };
32
32
  export function ImportPublicationStringModal(props) {
33
33
  const { onClose, isOpen } = props;
@@ -22,6 +22,7 @@ import PredefinedWorkspaces from '../../workspaces';
22
22
  import WorkspaceItem from './WorkspaceItem';
23
23
  import DatabasesTabContent from './settings-tabs/DatabasesTabContent';
24
24
  import DisplayTabContent from './settings-tabs/DisplayTabContent';
25
+ import { ExternalAPIsTabContent } from './settings-tabs/ExternalAPIsTabContent';
25
26
  import GeneralTabContent from './settings-tabs/GeneralTabContent';
26
27
  import ImportationFiltersTabContent from './settings-tabs/ImportationFiltersTabContent';
27
28
  import InfoBlockTabContent from './settings-tabs/InfoBlockTabContent';
@@ -65,7 +66,7 @@ function InnerGeneralSettingsModal(props) {
65
66
  defaultValues: currentWorkspace,
66
67
  resolver: yupResolver(validation),
67
68
  });
68
- const { reset, getValues } = methods;
69
+ const { reset, getValues, watch } = methods;
69
70
  const workspacesList = useMemo(() => {
70
71
  return baseWorkspaces.concat([
71
72
  {
@@ -103,6 +104,7 @@ function InnerGeneralSettingsModal(props) {
103
104
  });
104
105
  }
105
106
  }, [dispatch, preferences.workspace, workspaces, reset]);
107
+ const isExperimentalFeatures = watch('display.general.experimentalFeatures.display') || false;
106
108
  useEffect(() => {
107
109
  if (pastRef.current) {
108
110
  setWorkspaceSetting(pastRef.current);
@@ -130,7 +132,7 @@ function InnerGeneralSettingsModal(props) {
130
132
  overflow: auto;
131
133
  max-height: 100%;
132
134
  }
133
- `, children: [_jsx(Tab, { title: "General", id: "general", panel: _jsx(GeneralTabContent, {}) }), _jsx(Tab, { title: "Nuclei", id: "nuclei", panel: _jsx(NucleiTabContent, {}) }), _jsx(Tab, { title: "Panels", id: "display", panel: _jsx(DisplayTabContent, {}) }), _jsx(Tab, { title: "Tools", id: "tools", panel: _jsx(ToolsTabContent, {}) }), _jsx(Tab, { title: "Databases", id: "databases", panel: _jsx(DatabasesTabContent, { currentWorkspace: workspaceName, originalWorkspaces: originalWorkspaces }) }), _jsx(Tab, { title: "Import filters", id: "importation-filters", panel: _jsx(ImportationFiltersTabContent, {}) }), _jsx(Tab, { title: "Title block", id: "title-block", panel: _jsx(InfoBlockTabContent, {}) }), _jsx(Tab, { title: "Auto processing", id: "on-load-processing", panel: _jsx(OnLoadProcessingTabContent, {}) }), _jsx(Tab, { title: "Spectra colors", id: "spectra-colors", panel: _jsx(SpectraColorsTabContent, {}) })] }) }) }), _jsx(DialogFooter, { children: _jsx(DialogActionButtons, { onCloseDialog: onCloseDialog, onSave: onSave }) })] }) }));
135
+ `, children: [_jsx(Tab, { title: "General", id: "general", panel: _jsx(GeneralTabContent, {}) }), _jsx(Tab, { title: "Nuclei", id: "nuclei", panel: _jsx(NucleiTabContent, {}) }), _jsx(Tab, { title: "Panels", id: "display", panel: _jsx(DisplayTabContent, {}) }), _jsx(Tab, { title: "Tools", id: "tools", panel: _jsx(ToolsTabContent, {}) }), _jsx(Tab, { title: "Databases", id: "databases", panel: _jsx(DatabasesTabContent, { currentWorkspace: workspaceName, originalWorkspaces: originalWorkspaces }) }), _jsx(Tab, { title: "Import filters", id: "importation-filters", panel: _jsx(ImportationFiltersTabContent, {}) }), _jsx(Tab, { title: "Title block", id: "title-block", panel: _jsx(InfoBlockTabContent, {}) }), _jsx(Tab, { title: "Auto processing", id: "on-load-processing", panel: _jsx(OnLoadProcessingTabContent, {}) }), _jsx(Tab, { title: "Spectra colors", id: "spectra-colors", panel: _jsx(SpectraColorsTabContent, {}) }), isExperimentalFeatures && (_jsx(Tab, { title: "External APIs", id: "external-apis", panel: _jsx(ExternalAPIsTabContent, {}) }))] }) }) }), _jsx(DialogFooter, { children: _jsx(DialogActionButtons, { onCloseDialog: onCloseDialog, onSave: onSave }) })] }) }));
134
136
  }
135
137
  function WorkSpaceActionsButtons(props) {
136
138
  const { readText, rawWriteWithType, shouldFallback, cleanShouldFallback, text, } = useClipboard();
@@ -0,0 +1 @@
1
+ export declare function ExternalAPIsTabContent(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,89 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Classes } from '@blueprintjs/core';
3
+ import { EXTERNAL_API_KEYS } from 'nmr-load-save';
4
+ import { useCallback, useMemo } from 'react';
5
+ import { useFormContext, useWatch } from 'react-hook-form';
6
+ import { FaPlus, FaRegTrashAlt } from 'react-icons/fa';
7
+ import { Button } from 'react-science/ui';
8
+ import { GroupPane } from '../../../elements/GroupPane';
9
+ import { Input2Controller } from '../../../elements/Input2Controller';
10
+ import ReactTable from '../../../elements/ReactTable/ReactTable';
11
+ import { Select2Controller } from '../../../elements/Select2Controller';
12
+ import { Section } from '../GeneralSettings';
13
+ function getKeyPath(index, key) {
14
+ return `externalAPIs.${index}.${key}`;
15
+ }
16
+ export function ExternalAPIsTabContent() {
17
+ const { control, setValue } = useFormContext();
18
+ const fields = useWatch({
19
+ name: 'externalAPIs',
20
+ }) || [];
21
+ const addHandler = useCallback((data, index) => {
22
+ let columns = [];
23
+ const emptyField = {
24
+ key: '',
25
+ serverLink: '',
26
+ APIKey: '',
27
+ };
28
+ if (data && Array.isArray(data)) {
29
+ columns = [...data.slice(0, index), emptyField, ...data.slice(index)];
30
+ }
31
+ else {
32
+ columns.push(emptyField);
33
+ }
34
+ setValue('externalAPIs', columns);
35
+ }, [setValue]);
36
+ const deleteHandler = useCallback((data, index) => {
37
+ const _fields = data.filter((_, columnIndex) => columnIndex !== index);
38
+ setValue('externalAPIs', _fields);
39
+ }, [setValue]);
40
+ const COLUMNS = useMemo(() => [
41
+ {
42
+ Header: '#',
43
+ style: { width: '25px', textAlign: 'center' },
44
+ accessor: (_, index) => index + 1,
45
+ },
46
+ {
47
+ Header: 'Service',
48
+ Cell: ({ row }) => {
49
+ const name = getKeyPath(row.index, 'key');
50
+ return (_jsx(Select2Controller, { placeholder: "Select API provider", control: control, name: name, items: [...EXTERNAL_API_KEYS], itemTextKey: "description", itemValueKey: "key", fill: true }));
51
+ },
52
+ },
53
+ {
54
+ Header: 'Server link',
55
+ Cell: ({ row }) => {
56
+ const name = getKeyPath(row.index, 'serverLink');
57
+ return (_jsx(Input2Controller, { control: control, name: name, noShadowBox: true, style: { backgroundColor: 'transparent' } }));
58
+ },
59
+ },
60
+ {
61
+ Header: 'API key',
62
+ Cell: ({ row }) => {
63
+ const name = getKeyPath(row.index, 'APIKey');
64
+ return (_jsx(Input2Controller, { control: control, name: name, noShadowBox: true, style: { backgroundColor: 'transparent' } }));
65
+ },
66
+ },
67
+ {
68
+ Header: '',
69
+ style: { width: '60px' },
70
+ id: 'op-buttons',
71
+ Cell: ({ data, row }) => {
72
+ const record = row.original;
73
+ return (_jsxs("div", { style: { display: 'flex', justifyContent: 'space-evenly' }, children: [_jsx(Button, { small: true, intent: "success", outlined: true, onClick: () => addHandler(data, row.index + 1), children: _jsx(FaPlus, { className: Classes.ICON }) }), !record?.name && (_jsx(Button, { small: true, outlined: true, intent: "danger", onClick: () => deleteHandler(data, row.index), children: _jsx(FaRegTrashAlt, { className: Classes.ICON }) }))] }));
74
+ },
75
+ },
76
+ ], [addHandler, control, deleteHandler]);
77
+ return (_jsx(GroupPane, { text: "External APIs", renderHeader: (text) => {
78
+ return _jsx(Header, { text: text, onAdd: () => addHandler(fields, 0) });
79
+ }, children: _jsx(ReactTable, { style: {
80
+ 'thead tr th': { zIndex: 1 },
81
+ td: { padding: 0 },
82
+ }, rowStyle: {
83
+ hover: { backgroundColor: '#f7f7f7' },
84
+ active: { backgroundColor: '#f5f5f5' },
85
+ }, data: fields, columns: COLUMNS, emptyDataRowText: "No external APIs" }) }));
86
+ }
87
+ function Header({ onAdd, text }) {
88
+ return (_jsxs(Section, { children: [_jsx("p", { style: { flex: 1 }, children: text }), _jsx(Button, { outlined: true, small: true, intent: "success", tooltipProps: { content: '', disabled: true }, onClick: onAdd, children: "Add an external API" })] }));
89
+ }