nmrium 0.50.1 → 0.52.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 (219) hide show
  1. package/lib/component/1d/Chart1D.js +1 -1
  2. package/lib/component/1d/LinesSeries.js +2 -2
  3. package/lib/component/1d/Viewer1D.js +6 -11
  4. package/lib/component/1d/database/DatabaseSpectrum.js +3 -3
  5. package/lib/component/2d/1d-tracer/HorizontalSliceChart.js +6 -2
  6. package/lib/component/2d/1d-tracer/VerticalSliceChart.js +8 -1
  7. package/lib/component/2d/1d-tracer/phase-correction-traces/PhaseTraceWithMouse.js +2 -21
  8. package/lib/component/2d/1d-tracer/phase-correction-traces/PhaseTraces.js +1 -1
  9. package/lib/component/2d/1d-tracer/phase-correction-traces/SpectraPhaseTraces.d.ts +1 -1
  10. package/lib/component/2d/1d-tracer/phase-correction-traces/SpectraPhaseTraces.js +6 -17
  11. package/lib/component/2d/1d-tracer/phase-correction-traces/SpectrumPhaseTrace.d.ts +6 -10
  12. package/lib/component/2d/1d-tracer/phase-correction-traces/SpectrumPhaseTrace.js +62 -13
  13. package/lib/component/2d/1d-tracer/phase-correction-traces/useActivePhaseTraces.d.ts +1 -0
  14. package/lib/component/2d/1d-tracer/phase-correction-traces/useActivePhaseTraces.js +2 -1
  15. package/lib/component/2d/Viewer2D.js +16 -15
  16. package/lib/component/2d/ft/Contours.js +6 -3
  17. package/lib/component/2d/utilities/scale.d.ts +2 -1
  18. package/lib/component/2d/utilities/scale.js +12 -2
  19. package/lib/component/EventsTrackers/BrushTracker.d.ts +5 -3
  20. package/lib/component/EventsTrackers/BrushTracker.js +2 -2
  21. package/lib/component/EventsTrackers/KeysListenerTracker.d.ts +1 -1
  22. package/lib/component/EventsTrackers/KeysListenerTracker.js +32 -18
  23. package/lib/component/context/DispatchContext.d.ts +1 -1
  24. package/lib/component/context/ToasterContext.d.ts +13 -0
  25. package/lib/component/context/ToasterContext.js +34 -0
  26. package/lib/component/elements/Label.js +1 -1
  27. package/lib/component/elements/Select.js +2 -2
  28. package/lib/component/elements/ToolbarPopoverItem.js +1 -1
  29. package/lib/component/header/ApodizationOptionsPanel.js +1 -1
  30. package/lib/component/header/AutoPeakPickingOptionPanel.js +7 -4
  31. package/lib/component/header/BaseLineCorrectionPanel.js +2 -2
  32. package/lib/component/header/Header.d.ts +1 -11
  33. package/lib/component/header/Header.js +5 -6
  34. package/lib/component/header/PhaseCorrectionPanel.js +24 -33
  35. package/lib/component/header/PhaseCorrectionTwoDimensionsPanel.d.ts +1 -1
  36. package/lib/component/header/PhaseCorrectionTwoDimensionsPanel.js +96 -42
  37. package/lib/component/header/RangesPickingOptionPanel.js +7 -4
  38. package/lib/component/header/ZeroFillingOptionsPanel.js +1 -1
  39. package/lib/component/header/Zones2DOptionPanel.js +6 -2
  40. package/lib/component/hooks/useDialogToggle.d.ts +5 -0
  41. package/lib/component/hooks/useDialogToggle.js +16 -0
  42. package/lib/component/hooks/useExport.d.ts +9 -1
  43. package/lib/component/hooks/useExport.js +34 -36
  44. package/lib/component/hooks/useSaveSettings.js +6 -3
  45. package/lib/component/hooks/useToolsFunctions.d.ts +1 -1
  46. package/lib/component/hooks/useToolsFunctions.js +9 -7
  47. package/lib/component/loader/DropZone.js +14 -14
  48. package/lib/component/main/InnerNMRium.js +5 -9
  49. package/lib/component/main/InnerNMRiumContents.d.ts +0 -2
  50. package/lib/component/main/InnerNMRiumContents.js +5 -3
  51. package/lib/component/main/NMRium.js +2 -2
  52. package/lib/component/modal/AboutPredictionModal.js +1 -1
  53. package/lib/component/modal/AboutSpectrumSimulationModal.js +1 -1
  54. package/lib/component/modal/EditPeakShapeModal.js +1 -1
  55. package/lib/component/modal/ExportAsJcampModal.js +15 -15
  56. package/lib/component/modal/ImportPublicationStringModal.js +5 -3
  57. package/lib/component/modal/LoadJCAMPModal.js +7 -5
  58. package/lib/component/modal/LogsHistoryModal.js +1 -1
  59. package/lib/component/modal/MultipletAnalysisModal.js +1 -1
  60. package/lib/component/modal/PredictSpectraModal.js +11 -9
  61. package/lib/component/modal/SaveAsModal.d.ts +3 -4
  62. package/lib/component/modal/SaveAsModal.js +27 -27
  63. package/lib/component/modal/editRange/EditRangeModal.js +2 -2
  64. package/lib/component/modal/editRange/forms/components/DeltaInput.d.ts +2 -3
  65. package/lib/component/modal/editRange/forms/components/DeltaInput.js +2 -3
  66. package/lib/component/modal/editRange/forms/components/InfoBlock.d.ts +1 -0
  67. package/lib/component/modal/editRange/forms/components/{SignalFormInfo.js → InfoBlock.js} +2 -2
  68. package/lib/component/modal/editRange/forms/components/NewSignalTab.d.ts +5 -0
  69. package/lib/component/modal/editRange/forms/components/NewSignalTab.js +85 -0
  70. package/lib/component/modal/editRange/forms/components/SignalTab.d.ts +7 -0
  71. package/lib/component/modal/editRange/forms/components/SignalTab.js +24 -0
  72. package/lib/component/modal/editRange/forms/components/SignalsContent.d.ts +8 -0
  73. package/lib/component/modal/editRange/forms/components/SignalsContent.js +57 -0
  74. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.d.ts +5 -0
  75. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.js +133 -0
  76. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.d.ts +5 -0
  77. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.js +141 -0
  78. package/lib/component/modal/editZone/EditPathLengthFormik.js +2 -2
  79. package/lib/component/modal/editZone/EditZoneModal.js +1 -1
  80. package/lib/component/modal/metaImportation/MetaImportationModal.d.ts +7 -4
  81. package/lib/component/modal/metaImportation/MetaImportationModal.js +23 -13
  82. package/lib/component/modal/metaImportation/utils/mapColumnToSelectItems.js +1 -1
  83. package/lib/component/modal/setting/GeneralSettings.js +9 -6
  84. package/lib/component/modal/setting/settings-tabs/GeneralTabContent.js +1 -1
  85. package/lib/component/modal/setting/settings-tabs/InfoBlockTabContent.js +1 -1
  86. package/lib/component/modal/setting/settings-tabs/OnLoadProcessingTabContent.js +1 -1
  87. package/lib/component/panels/AutomaticAssignment/useAutoAssignments.js +7 -4
  88. package/lib/component/panels/IntegralsPanel/IntegralsPreferences.js +1 -1
  89. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +13 -7
  90. package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +6 -4
  91. package/lib/component/panels/Panels.js +5 -5
  92. package/lib/component/panels/PeaksPanel/PeaksPanel.js +6 -3
  93. package/lib/component/panels/RangesPanel/RangesHeader.js +3 -3
  94. package/lib/component/panels/RangesPanel/RangesPanel.js +5 -5
  95. package/lib/component/panels/RangesPanel/RangesPreferences.js +1 -1
  96. package/lib/component/panels/SpectraPanel/SpectraPanelHeader.d.ts +5 -0
  97. package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/SpectraPanelHeader.js +11 -11
  98. package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/SpectraTable.js +12 -6
  99. package/lib/component/panels/SpectraPanel/SpectraTabs.d.ts +1 -0
  100. package/lib/component/panels/{SpectrumsPanel/SpectrumsTabs.js → SpectraPanel/SpectraTabs.js} +6 -6
  101. package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/SpectrumListPanel.js +2 -2
  102. package/lib/component/panels/databasePanel/DatabasePanel.js +37 -19
  103. package/lib/component/panels/databasePanel/DatabasePreferences.js +1 -1
  104. package/lib/component/panels/databasePanel/DatabaseSearchOptions.js +1 -1
  105. package/lib/component/panels/filtersPanel/FilterPanel.js +5 -3
  106. package/lib/component/panels/filtersPanel/FiltersTable.js +27 -23
  107. package/lib/component/panels/header/SpectraAutomaticPickingButton.js +7 -5
  108. package/lib/component/panels/multipleAnalysisPanel/AlignSpectra.js +2 -2
  109. package/lib/component/panels/multipleAnalysisPanel/AnalysisChart.js +5 -5
  110. package/lib/component/panels/multipleAnalysisPanel/MultipleSpectraAnalysisPanel.js +6 -6
  111. package/lib/component/panels/multipleAnalysisPanel/preferences/index.js +5 -3
  112. package/lib/component/panels/predictionPanel/PredictionOptionsPanel.js +2 -2
  113. package/lib/component/panels/predictionPanel/PredictionPanel.js +7 -5
  114. package/lib/component/panels/predictionPanel/PredictionSimpleOptions.js +2 -1
  115. package/lib/component/panels/spectrumSimulation/SpectrumSimulationPreferences.js +1 -1
  116. package/lib/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +1 -1
  117. package/lib/component/reducer/IgnoreActions.js +1 -1
  118. package/lib/component/reducer/Reducer.d.ts +3 -2
  119. package/lib/component/reducer/Reducer.js +40 -32
  120. package/lib/component/reducer/actions/DomainActions.js +3 -3
  121. package/lib/component/reducer/actions/FiltersActions.d.ts +11 -4
  122. package/lib/component/reducer/actions/FiltersActions.js +243 -91
  123. package/lib/component/reducer/actions/IntegralsActions.js +2 -2
  124. package/lib/component/reducer/actions/LoadActions.js +1 -1
  125. package/lib/component/reducer/actions/MoleculeActions.js +0 -1
  126. package/lib/component/reducer/actions/PreferencesActions.js +2 -2
  127. package/lib/component/reducer/actions/RangesActions.js +16 -6
  128. package/lib/component/reducer/actions/ToolsActions.d.ts +6 -6
  129. package/lib/component/reducer/actions/ToolsActions.js +83 -22
  130. package/lib/component/reducer/actions/ZonesActions.d.ts +2 -0
  131. package/lib/component/reducer/actions/ZonesActions.js +5 -1
  132. package/lib/component/reducer/helper/Zoom1DManager.d.ts +4 -3
  133. package/lib/component/reducer/helper/Zoom1DManager.js +4 -4
  134. package/lib/component/reducer/helper/ZoomHistoryManager.js +1 -5
  135. package/lib/component/reducer/helper/findStrongestPeak.d.ts +6 -0
  136. package/lib/component/reducer/helper/findStrongestPeak.js +13 -0
  137. package/lib/component/reducer/helper/getTwoDimensionPhaseCorrectionOptions.d.ts +2 -1
  138. package/lib/component/reducer/helper/getTwoDimensionPhaseCorrectionOptions.js +7 -1
  139. package/lib/component/toolbar/ToolBar.js +32 -27
  140. package/lib/component/toolbar/toolbarMenu.js +4 -4
  141. package/lib/component/utility/Events.d.ts +11 -0
  142. package/lib/component/utility/Events.js +22 -0
  143. package/lib/constants.js +5 -5
  144. package/lib/data/data1d/Spectrum1D/ranges/addRange.d.ts +0 -33
  145. package/lib/data/data1d/Spectrum1D/ranges/addRange.js +5 -15
  146. package/lib/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +6 -4
  147. package/lib/data/data1d/Spectrum1D/ranges/changeRange.js +1 -1
  148. package/lib/data/data1d/Spectrum1D/ranges/detectRange.js +1 -1
  149. package/lib/data/data1d/Spectrum1D/ranges/detectRanges.d.ts +6 -4
  150. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +13 -3
  151. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +6 -0
  152. package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.d.ts +13 -3
  153. package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.js +78 -18
  154. package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +2 -2
  155. package/lib/data/data1d/spectrumSimulation.d.ts +1 -1
  156. package/lib/data/data2d/Spectrum2D/contours.js +3 -3
  157. package/lib/data/data2d/Spectrum2D/getMissingProjection.js +2 -2
  158. package/lib/data/data2d/Spectrum2D/getSlice.js +4 -4
  159. package/lib/data/data2d/Spectrum2D/zones/getDetectionZones.d.ts +1 -0
  160. package/lib/data/getDefaultMatrixFilters.js +2 -2
  161. package/lib/data/matrixGeneration.js +1 -1
  162. package/lib/data/utilities/calculateSanPlot.d.ts +1 -6
  163. package/lib/versionInfo.js +1 -1
  164. package/package.json +32 -30
  165. package/lib/component/elements/popup/Alert/AlertBlock.d.ts +0 -8
  166. package/lib/component/elements/popup/Alert/AlertBlock.js +0 -30
  167. package/lib/component/elements/popup/Alert/Context.d.ts +0 -27
  168. package/lib/component/elements/popup/Alert/Context.js +0 -10
  169. package/lib/component/elements/popup/Alert/ProgressIndicator.d.ts +0 -1
  170. package/lib/component/elements/popup/Alert/ProgressIndicator.js +0 -33
  171. package/lib/component/elements/popup/Alert/Provider.d.ts +0 -19
  172. package/lib/component/elements/popup/Alert/Provider.js +0 -127
  173. package/lib/component/elements/popup/Alert/index.d.ts +0 -3
  174. package/lib/component/elements/popup/Alert/index.js +0 -3
  175. package/lib/component/modal/editRange/forms/components/AddSignalFormTab.d.ts +0 -10
  176. package/lib/component/modal/editRange/forms/components/AddSignalFormTab.js +0 -81
  177. package/lib/component/modal/editRange/forms/components/CouplingsTable.d.ts +0 -13
  178. package/lib/component/modal/editRange/forms/components/CouplingsTable.js +0 -63
  179. package/lib/component/modal/editRange/forms/components/SignalFormInfo.d.ts +0 -1
  180. package/lib/component/modal/editRange/forms/components/SignalFormTab.d.ts +0 -8
  181. package/lib/component/modal/editRange/forms/components/SignalFormTab.js +0 -18
  182. package/lib/component/modal/editRange/forms/components/SignalsForm.d.ts +0 -10
  183. package/lib/component/modal/editRange/forms/components/SignalsForm.js +0 -114
  184. package/lib/component/modal/metaImportation/index.d.ts +0 -2
  185. package/lib/component/modal/metaImportation/index.js +0 -17
  186. package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.d.ts +0 -5
  187. package/lib/component/panels/SpectrumsPanel/SpectrumsTabs.d.ts +0 -1
  188. package/lib/component/reducer/helper/getStrongestPeak.d.ts +0 -7
  189. package/lib/component/reducer/helper/getStrongestPeak.js +0 -15
  190. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/SpectraPreferences.d.ts +0 -0
  191. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/SpectraPreferences.js +0 -0
  192. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/SpectraTable.d.ts +0 -0
  193. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/SpectrumListPanel.d.ts +0 -0
  194. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/base/ColorIndicator.d.ts +0 -0
  195. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/base/ColorIndicator.js +0 -0
  196. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/base/RenderAsHTML.d.ts +0 -0
  197. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/base/RenderAsHTML.js +0 -0
  198. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/base/ShowHideSpectrumButton.d.ts +0 -0
  199. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/base/ShowHideSpectrumButton.js +0 -0
  200. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/base/SpectraColumnsManager.d.ts +0 -0
  201. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/base/SpectraColumnsManager.js +0 -0
  202. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/base/SpectrumName.d.ts +0 -0
  203. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/base/SpectrumName.js +0 -0
  204. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/base/setting/PlotChart.d.ts +0 -0
  205. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/base/setting/PlotChart.js +0 -0
  206. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/base/setting/Spectrum1DHistogram.d.ts +0 -0
  207. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/base/setting/Spectrum1DHistogram.js +0 -0
  208. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/base/setting/Spectrum1DSetting.d.ts +0 -0
  209. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/base/setting/Spectrum1DSetting.js +0 -0
  210. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/base/setting/Spectrum2DHistogram.d.ts +0 -0
  211. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/base/setting/Spectrum2DHistogram.js +0 -0
  212. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/base/setting/Spectrum2DSetting.d.ts +0 -0
  213. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/base/setting/Spectrum2DSetting.js +0 -0
  214. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/base/setting/SpectrumSetting.d.ts +0 -0
  215. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/base/setting/SpectrumSetting.js +0 -0
  216. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/base/setting/processSnapPlot.d.ts +0 -0
  217. /package/lib/component/panels/{SpectrumsPanel → SpectraPanel}/base/setting/processSnapPlot.js +0 -0
  218. /package/lib/component/reducer/actions/{SpectrumsActions.d.ts → SpectraActions.d.ts} +0 -0
  219. /package/lib/component/reducer/actions/{SpectrumsActions.js → SpectraActions.js} +0 -0
@@ -0,0 +1,85 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ import { Formik, useFormikContext } from 'formik';
3
+ import { translateMultiplet } from 'nmr-processing';
4
+ import { useRef } from 'react';
5
+ import * as Yup from 'yup';
6
+ import { useChartData } from '../../../../context/ChartContext';
7
+ import Button from '../../../../elements/Button';
8
+ import FormikInput from '../../../../elements/formik/FormikInput';
9
+ import { usePanelPreferences } from '../../../../hooks/usePanelPreferences';
10
+ import { useEvent } from '../../../../utility/Events';
11
+ import { formatNumber } from '../../../../utility/formatNumber';
12
+ const styles = {
13
+ container: {
14
+ padding: '0.4rem',
15
+ },
16
+ innerContainer: {
17
+ width: '70%',
18
+ display: 'block',
19
+ margin: 'auto',
20
+ },
21
+ infoText: {
22
+ padding: '10px 0',
23
+ fontSize: '13px',
24
+ textAlign: 'left',
25
+ },
26
+ };
27
+ export function NewSignalTab(props) {
28
+ const { range } = props;
29
+ const { values, setFieldValue } = useFormikContext();
30
+ const newSignalFormRef = useRef();
31
+ const { view: { spectra: { activeTab }, }, } = useChartData();
32
+ const rangesPreferences = usePanelPreferences('ranges', activeTab);
33
+ function saveHandler(val) {
34
+ const newSignal = {
35
+ multiplicity: 'm',
36
+ kind: 'signal',
37
+ delta: Number(val.newSignalDelta),
38
+ js: [{ multiplicity: translateMultiplet('m'), coupling: '' }],
39
+ };
40
+ const _signals = values.signals.slice().concat(newSignal);
41
+ void setFieldValue('signals', _signals);
42
+ void setFieldValue('signalIndex', String(_signals.length - 1));
43
+ }
44
+ useEvent({
45
+ onClick: (options) => {
46
+ if (values.signalIndex === '-1') {
47
+ newSignalFormRef.current.setValues({ newSignalDelta: options.xPPM });
48
+ }
49
+ },
50
+ onBrushEnd: (options) => {
51
+ const { range: [from, to], } = options;
52
+ if (values.signalIndex === '-1') {
53
+ newSignalFormRef.current.setValues({
54
+ newSignalDelta: (to - from) / 2 + from,
55
+ });
56
+ }
57
+ },
58
+ });
59
+ return (_jsx("div", { style: styles.container, children: _jsx(Formik, { innerRef: newSignalFormRef, validationSchema: getSignalValidationSchema(range), initialValues: {
60
+ newSignalDelta: (range.from + range.to) / 2,
61
+ }, onSubmit: saveHandler, children: _jsxs("div", { style: styles.innerContainer, children: [_jsxs("p", { style: styles.infoText, children: ["Edit or select a delta value of new signal in range [", `${formatNumber(range.from, rangesPreferences.from.format)} ppm - ${formatNumber(range.to, rangesPreferences.to.format)} ppm`, "]:"] }), _jsx(FormikInput, { name: "newSignalDelta", type: "number", placeholder: `𝛅(ppm)`, style: {
62
+ input: {
63
+ height: '30px',
64
+ padding: '0.25rem 0.5rem',
65
+ },
66
+ }, checkErrorAfterInputTouched: false }), _jsx(Button.Done, { style: {
67
+ marginTop: '20px',
68
+ height: '30px',
69
+ }, onClick: () => newSignalFormRef.current.submitForm(), children: "Add a signal" })] }) }) }));
70
+ }
71
+ function getSignalValidationSchema(range) {
72
+ return Yup.object().shape({
73
+ newSignalDelta: Yup.number()
74
+ .test(`test-range`, '', function testNewSignalDelta(value) {
75
+ // eslint-disable-next-line no-invalid-this
76
+ const { path, createError } = this;
77
+ if (value && value >= range.from && value <= range.to) {
78
+ return true;
79
+ }
80
+ const errorMessage = ` ${value ? value.toFixed(5) : 0} ppm out of the range`;
81
+ return createError({ path, message: errorMessage });
82
+ })
83
+ .required(),
84
+ });
85
+ }
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ interface SignalTabProps {
3
+ index: number;
4
+ }
5
+ declare function SignalTab({ index }: SignalTabProps): import("@emotion/react/jsx-runtime").JSX.Element;
6
+ declare const _default: import("react").MemoExoticComponent<typeof SignalTab>;
7
+ export default _default;
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ /** @jsxImportSource @emotion/react */
3
+ import { Tab, Tabs } from '@blueprintjs/core';
4
+ import { css } from '@emotion/react';
5
+ import { memo } from 'react';
6
+ import { SignalJCouplingsTable } from './signal-tabs/SignalJCouplingsTable';
7
+ import { SignalPeaksTable } from './signal-tabs/SignalPeaksTable';
8
+ const style = {
9
+ borderSpacing: '0',
10
+ width: '100%',
11
+ fontSize: '12px',
12
+ height: '100%',
13
+ margin: '0',
14
+ padding: '0.4rem',
15
+ textAlign: 'center',
16
+ };
17
+ function SignalTab({ index }) {
18
+ return (_jsx("div", { style: style, css: css `
19
+ div[role='tabpanel'] {
20
+ width: 100%;
21
+ }
22
+ `, children: _jsxs(Tabs, { vertical: true, fill: true, renderActiveTabPanelOnly: true, children: [_jsx(Tab, { id: "couplings", title: "Couplings", panel: _jsx(SignalJCouplingsTable, { index: index }) }), _jsx(Tab, { id: "peaks", title: "Peaks", panel: _jsx(SignalPeaksTable, { index: index }) })] }) }));
23
+ }
24
+ export default memo(SignalTab);
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { Range } from 'nmr-processing';
3
+ interface SignalsFormProps {
4
+ range: Range;
5
+ }
6
+ declare function SignalsContent({ range }: SignalsFormProps): import("@emotion/react/jsx-runtime").JSX.Element;
7
+ declare const _default: import("react").MemoExoticComponent<typeof SignalsContent>;
8
+ export default _default;
@@ -0,0 +1,57 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ /** @jsxImportSource @emotion/react */
3
+ import { css } from '@emotion/react';
4
+ import { useFormikContext } from 'formik';
5
+ import { useCallback, useMemo, memo, useEffect } from 'react';
6
+ import { FaPlus } from 'react-icons/fa';
7
+ import Tab from '../../../../elements/Tab/Tab';
8
+ import Tabs from '../../../../elements/Tab/Tabs';
9
+ import { DeltaInput } from './DeltaInput';
10
+ import { InfoBlock } from './InfoBlock';
11
+ import { NewSignalTab } from './NewSignalTab';
12
+ import SignalTab from './SignalTab';
13
+ const tabStylesAddition = css `
14
+ color: red;
15
+ `;
16
+ const tabStyles = css `
17
+ padding: 0 1.5rem !important;
18
+ height: 40px;
19
+ `;
20
+ const newTabStyles = css `
21
+ padding: 0 !important;
22
+ height: 40px;
23
+ `;
24
+ function SignalsContent({ range }) {
25
+ const { values, setFieldValue, errors, } = useFormikContext();
26
+ const tapClickHandler = useCallback(({ tabid }) => {
27
+ setFieldValue('signalIndex', tabid);
28
+ }, [setFieldValue]);
29
+ const handleDeleteSignal = useCallback(({ tabid }) => {
30
+ const _signals = values.signals.filter((_signal, i) => i !== Number(tabid));
31
+ setFieldValue('signals', _signals);
32
+ }, [setFieldValue, values.signals]);
33
+ useEffect(() => {
34
+ setFieldValue('signalIndex', values.signals.length > 0 ? (values.signals.length - 1).toString() : '-1');
35
+ }, [setFieldValue, values.signals.length]);
36
+ const tabContainsErrors = useCallback((i) => {
37
+ return !!errors?.signals?.[i];
38
+ }, [errors]);
39
+ const signalFormTabs = useMemo(() => {
40
+ const signalTabs = values.signals.length > 0
41
+ ? values.signals.map((signal, i) => (_jsx(Tab
42
+ // eslint-disable-next-line react/no-array-index-key
43
+ , { tabid: `${i}`, tabstyles: tabContainsErrors(i) ? tabStylesAddition : tabStyles, canDelete: true, render: () => _jsx(DeltaInput, { signal: signal, index: i }), children: _jsx(SignalTab, { index: i }) }, `signalForm${i}`)))
44
+ : [];
45
+ const addSignalTab = (_jsx(Tab, { tabid: "-1", canDelete: false, tabstyles: newTabStyles, render: () => (_jsxs("div", { style: {
46
+ display: 'flex',
47
+ alignItems: 'center',
48
+ padding: '0 1.5rem',
49
+ fontSize: '12px',
50
+ color: '#28ba62',
51
+ textWrap: 'nowrap',
52
+ }, children: [_jsx(FaPlus, { style: { display: 'inline-block' } }), _jsx("span", { style: { display: 'inline-block' }, children: "New Signal" })] })), children: _jsx(NewSignalTab, { range: range }) }, "addSignalTab"));
53
+ return [...signalTabs, addSignalTab];
54
+ }, [range, tabContainsErrors, values.signals]);
55
+ return (_jsxs("div", { children: [_jsx(InfoBlock, {}), _jsx(Tabs, { activeTab: values.signalIndex, onClick: tapClickHandler, onDelete: handleDeleteSignal, children: signalFormTabs })] }));
56
+ }
57
+ export default memo(SignalsContent);
@@ -0,0 +1,5 @@
1
+ interface SignalJCouplingsTableProps {
2
+ index: number;
3
+ }
4
+ export declare function SignalJCouplingsTable(props: SignalJCouplingsTableProps): import("react/jsx-runtime").JSX.Element;
5
+ export {};
@@ -0,0 +1,133 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useFormikContext } from 'formik';
3
+ import { translateMultiplet } from 'nmr-processing';
4
+ import { useCallback, useMemo, useState } from 'react';
5
+ import { FaPlus, FaRegTrashAlt } from 'react-icons/fa';
6
+ import { Toolbar } from 'react-science/ui';
7
+ import { Multiplets } from '../../../../../../data/constants/Multiplets';
8
+ import { isSpectrum1D } from '../../../../../../data/data1d/Spectrum1D';
9
+ import { useChartData } from '../../../../../context/ChartContext';
10
+ import Button from '../../../../../elements/Button';
11
+ import ReactTable from '../../../../../elements/ReactTable/ReactTable';
12
+ import FormikInput from '../../../../../elements/formik/FormikInput';
13
+ import FormikSelect from '../../../../../elements/formik/FormikSelect';
14
+ import { usePanelPreferences } from '../../../../../hooks/usePanelPreferences';
15
+ import useSpectrum from '../../../../../hooks/useSpectrum';
16
+ import { hasCouplingConstant } from '../../../../../panels/extra/utilities/MultiplicityUtilities';
17
+ import { useEvent } from '../../../../../utility/Events';
18
+ import { formatNumber } from '../../../../../utility/formatNumber';
19
+ const styles = {
20
+ input: {
21
+ width: '100%',
22
+ padding: '0.25rem 0.5rem',
23
+ },
24
+ select: {
25
+ height: '26px',
26
+ width: '100%',
27
+ },
28
+ column: {
29
+ padding: '2px',
30
+ },
31
+ };
32
+ function getJCouplingKey(signalIndex, jIndex, jCouplingKey) {
33
+ return `signals[${signalIndex}].js.${jIndex}.${jCouplingKey}`;
34
+ }
35
+ export function SignalJCouplingsTable(props) {
36
+ const { values, setFieldValue } = useFormikContext();
37
+ const signal = values?.signals?.[values?.signalIndex] || {};
38
+ const jCouplings = signal?.js || [];
39
+ const [lastSelectedCouplingIndex, setLastSelectedCouplingIndex] = useState(null);
40
+ const spectrum = useSpectrum();
41
+ const { view: { spectra: { activeTab }, }, } = useChartData();
42
+ const rangesPreferences = usePanelPreferences('ranges', activeTab);
43
+ useEvent({
44
+ onClick: (options) => {
45
+ if (`${props.index}` === values.signalIndex &&
46
+ typeof lastSelectedCouplingIndex === 'number') {
47
+ const x = formatNumber(options.xPPM, rangesPreferences.deltaHz.format);
48
+ void setFieldValue(getJCouplingKey(values.signalIndex, lastSelectedCouplingIndex, 'coupling'), x);
49
+ }
50
+ },
51
+ onBrushEnd: (options) => {
52
+ const { range: [from, to], } = options;
53
+ if (`${props.index}` === values.signalIndex &&
54
+ typeof lastSelectedCouplingIndex === 'number' &&
55
+ isSpectrum1D(spectrum)) {
56
+ const value = Number(formatNumber(Math.abs(to - from) * spectrum.info.originFrequency, rangesPreferences.deltaHz.format));
57
+ void setFieldValue(getJCouplingKey(values.signalIndex, lastSelectedCouplingIndex, 'coupling'), value);
58
+ }
59
+ },
60
+ });
61
+ const addHandler = useCallback((data) => {
62
+ const coupling = {
63
+ multiplicity: translateMultiplet('m'),
64
+ coupling: '',
65
+ };
66
+ void setFieldValue(`signals[${values?.signalIndex}].js`, [
67
+ ...data,
68
+ coupling,
69
+ ]);
70
+ setLastSelectedCouplingIndex(data.length);
71
+ }, [setFieldValue, values?.signalIndex]);
72
+ const deleteHandler = useCallback((data, index) => {
73
+ const jCouplings = data.filter((_, columnIndex) => columnIndex !== index);
74
+ void setFieldValue(`signals[${values?.signalIndex}].js`, jCouplings);
75
+ if (lastSelectedCouplingIndex === index) {
76
+ setLastSelectedCouplingIndex(null);
77
+ }
78
+ }, [lastSelectedCouplingIndex, setFieldValue, values?.signalIndex]);
79
+ function deleteAllHandler() {
80
+ void setFieldValue(`signals[${values?.signalIndex}].js`, []);
81
+ setLastSelectedCouplingIndex(null);
82
+ }
83
+ const multiplicityChangeHandler = useCallback((value, name) => {
84
+ if (!hasCouplingConstant(value)) {
85
+ void setFieldValue(name, '');
86
+ }
87
+ }, [setFieldValue]);
88
+ const COLUMNS = useMemo(() => [
89
+ {
90
+ Header: '#',
91
+ style: { width: '25px', ...styles.column },
92
+ accessor: (_, index) => index + 1,
93
+ },
94
+ {
95
+ Header: 'Multiplicity',
96
+ style: { padding: 0, ...styles.column },
97
+ Cell: ({ row }) => {
98
+ return (_jsx(FormikSelect, { className: "select-box", name: getJCouplingKey(values.signalIndex, row.index, 'multiplicity'), items: Multiplets, itemValueField: "label", onChange: (value) => {
99
+ multiplicityChangeHandler(value, getJCouplingKey(values.signalIndex, row.index, 'coupling'));
100
+ }, style: styles.select, onClick: (e) => e.stopPropagation() }));
101
+ },
102
+ },
103
+ {
104
+ Header: 'J (Hz)',
105
+ style: { padding: 0, ...styles.column },
106
+ Cell: ({ row }) => {
107
+ return (_jsx(FormikInput, { name: getJCouplingKey(values.signalIndex, row.index, 'coupling'), type: "number", placeholder: 'J (Hz)', style: { input: styles.input }, disabled: !hasCouplingConstant(row.original?.multiplicity), onClick: (e) => e.stopPropagation() }));
108
+ },
109
+ },
110
+ {
111
+ Header: '',
112
+ style: { width: '70px', ...styles.column },
113
+ id: 'action-button',
114
+ Cell: ({ data, row }) => {
115
+ const record = row.original;
116
+ return (_jsx("div", { style: { display: 'flex', justifyContent: 'space-around' }, children: !record?.name && (_jsx(Button.Danger, { fill: "outline", onClick: (e) => {
117
+ e.stopPropagation();
118
+ deleteHandler(data, row.index);
119
+ }, children: _jsx(FaRegTrashAlt, {}) })) }));
120
+ },
121
+ },
122
+ ], [deleteHandler, multiplicityChangeHandler, values.signalIndex]);
123
+ function selectRowHandler(index) {
124
+ setLastSelectedCouplingIndex((prevIndex) => prevIndex === index ? null : index);
125
+ }
126
+ function handleActiveRow(row) {
127
+ return row?.index === lastSelectedCouplingIndex;
128
+ }
129
+ return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx("div", { style: { padding: '5px 0', display: 'flex' }, children: _jsxs(Toolbar, { children: [_jsx(Toolbar.Item, { icon: _jsx(FaPlus, {}), title: "Add a new J coupling", intent: "success", onClick: () => addHandler(jCouplings) }), _jsx(Toolbar.Item, { icon: _jsx(FaRegTrashAlt, {}), title: "Delete all J couplings", intent: "danger", onClick: deleteAllHandler })] }) }), _jsx("div", { style: {
130
+ maxHeight: '300px',
131
+ overflow: 'auto',
132
+ }, children: _jsx(ReactTable, { data: jCouplings, columns: COLUMNS, onClick: (e, rowData) => selectRowHandler(rowData.index), activeRow: handleActiveRow, emptyDataRowText: "No J Couplings" }) })] }));
133
+ }
@@ -0,0 +1,5 @@
1
+ interface SignalPeaksTableProps {
2
+ index: number;
3
+ }
4
+ export declare function SignalPeaksTable(props: SignalPeaksTableProps): import("react/jsx-runtime").JSX.Element;
5
+ export {};
@@ -0,0 +1,141 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { v4 } from '@lukeed/uuid';
3
+ import { useFormikContext } from 'formik';
4
+ import { xFindClosestIndex } from 'ml-spectra-processing';
5
+ import { getShiftX } from 'nmr-processing';
6
+ import { useCallback, useMemo, useState } from 'react';
7
+ import { FaPlus, FaRegTrashAlt } from 'react-icons/fa';
8
+ import { Toolbar } from 'react-science/ui';
9
+ import { useChartData } from '../../../../../context/ChartContext';
10
+ import Button from '../../../../../elements/Button';
11
+ import ReactTable from '../../../../../elements/ReactTable/ReactTable';
12
+ import FormikInput from '../../../../../elements/formik/FormikInput';
13
+ import { usePanelPreferences } from '../../../../../hooks/usePanelPreferences';
14
+ import useSpectrum from '../../../../../hooks/useSpectrum';
15
+ import { useEvent } from '../../../../../utility/Events';
16
+ import { formatNumber } from '../../../../../utility/formatNumber';
17
+ const styles = {
18
+ input: {
19
+ width: '100%',
20
+ padding: '0.25rem 0.5rem',
21
+ },
22
+ column: {
23
+ padding: '2px',
24
+ },
25
+ };
26
+ function getPeakKey(signalIndex, peakIndex, key) {
27
+ const path = `signals[${signalIndex}].peaks.${peakIndex}`;
28
+ if (!key) {
29
+ return path;
30
+ }
31
+ return `${path}.${key}`;
32
+ }
33
+ export function SignalPeaksTable(props) {
34
+ const { values, setFieldValue } = useFormikContext();
35
+ const signal = values?.signals?.[values?.signalIndex] || {};
36
+ const peaks = signal?.peaks || [];
37
+ const delta = signal?.delta || 0;
38
+ const spectrum = useSpectrum();
39
+ const { data: { x: xArray, re }, } = spectrum;
40
+ const shiftX = getShiftX(spectrum);
41
+ const [lastSelectedPeakIndex, setLastSelectedPeakIndex] = useState(null);
42
+ const { view: { spectra: { activeTab }, }, } = useChartData();
43
+ const rangesPreferences = usePanelPreferences('ranges', activeTab);
44
+ useEvent({
45
+ onClick: (options) => {
46
+ if (`${props.index}` === values.signalIndex &&
47
+ typeof lastSelectedPeakIndex === 'number') {
48
+ const delta = formatNumber(options.xPPM, rangesPreferences.deltaPPM.format);
49
+ const xIndex = xFindClosestIndex(xArray, delta, { sorted: false });
50
+ const intensity = formatNumber(re[xIndex], rangesPreferences.deltaPPM.format);
51
+ void setFieldValue(getPeakKey(values?.signalIndex, lastSelectedPeakIndex), {
52
+ ...peaks[lastSelectedPeakIndex],
53
+ x: delta,
54
+ y: intensity,
55
+ });
56
+ }
57
+ },
58
+ onBrushEnd: (options) => {
59
+ const { range: [from, to], } = options;
60
+ if (`${props.index}` === values.signalIndex &&
61
+ typeof lastSelectedPeakIndex === 'number') {
62
+ const value = Number(formatNumber((to - from) / 2 + from, rangesPreferences.deltaPPM.format));
63
+ void setFieldValue(getPeakKey(values.signalIndex, lastSelectedPeakIndex, 'x'), value);
64
+ }
65
+ },
66
+ });
67
+ const addHandler = useCallback((data) => {
68
+ const xIndex = xFindClosestIndex(xArray, delta, { sorted: false });
69
+ const peak = {
70
+ id: v4(),
71
+ x: delta,
72
+ y: xIndex !== -1 ? re[xIndex] : 0,
73
+ originalX: delta - shiftX,
74
+ width: 1,
75
+ };
76
+ void setFieldValue(`signals[${values?.signalIndex}].peaks`, [
77
+ ...data,
78
+ peak,
79
+ ]);
80
+ setLastSelectedPeakIndex(data?.length || 0);
81
+ }, [delta, re, setFieldValue, shiftX, values?.signalIndex, xArray]);
82
+ const deleteHandler = useCallback((data, index) => {
83
+ const peaks = data.filter((_, columnIndex) => columnIndex !== index);
84
+ void setFieldValue(`signals[${values?.signalIndex}].peaks`, peaks);
85
+ if (lastSelectedPeakIndex === index) {
86
+ setLastSelectedPeakIndex(null);
87
+ }
88
+ }, [lastSelectedPeakIndex, setFieldValue, values?.signalIndex]);
89
+ function deleteAllHandler() {
90
+ void setFieldValue(`signals[${values?.signalIndex}].peaks`, []);
91
+ setLastSelectedPeakIndex(null);
92
+ }
93
+ const changeDeltaHandler = useCallback((event, index) => {
94
+ const delta = Number(event.target.value);
95
+ const xIndex = xFindClosestIndex(xArray, delta, { sorted: false });
96
+ void setFieldValue(`signals[${values?.signalIndex}].peaks.${index}.y`, re[xIndex]);
97
+ }, [re, setFieldValue, values?.signalIndex, xArray]);
98
+ const COLUMNS = useMemo(() => [
99
+ {
100
+ Header: '#',
101
+ style: { width: '25px', ...styles.column },
102
+ accessor: (_, index) => index + 1,
103
+ },
104
+ {
105
+ Header: 'delta',
106
+ style: { padding: 0, ...styles.column },
107
+ Cell: ({ row }) => {
108
+ return (_jsx(FormikInput, { name: `signals.${values?.signalIndex}.peaks.${row.index}.x`, style: { input: styles.input }, onChange: (event) => changeDeltaHandler(event, row.index), type: "number", onClick: (e) => e.stopPropagation() }));
109
+ },
110
+ },
111
+ {
112
+ Header: 'Intensity',
113
+ style: { padding: 0, ...styles.column },
114
+ Cell: ({ row }) => {
115
+ return (_jsx(FormikInput, { name: `signals.${values?.signalIndex}.peaks.${row.index}.y`, style: { input: styles.input }, readOnly: true }));
116
+ },
117
+ },
118
+ {
119
+ Header: '',
120
+ style: { width: '70px', ...styles.column },
121
+ id: 'action-button',
122
+ Cell: ({ data, row }) => {
123
+ const record = row.original;
124
+ return (_jsx("div", { style: { display: 'flex', justifyContent: 'space-around' }, children: !record?.name && (_jsx(Button.Danger, { fill: "outline", onClick: (e) => {
125
+ e.stopPropagation();
126
+ deleteHandler(data, row.index);
127
+ }, children: _jsx(FaRegTrashAlt, {}) })) }));
128
+ },
129
+ },
130
+ ], [changeDeltaHandler, deleteHandler, values?.signalIndex]);
131
+ function selectRowHandler(index) {
132
+ setLastSelectedPeakIndex((prevIndex) => prevIndex === index ? null : index);
133
+ }
134
+ function handleActiveRow(row) {
135
+ return row?.index === lastSelectedPeakIndex;
136
+ }
137
+ return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx("div", { style: { padding: '5px 0', display: 'flex' }, children: _jsxs(Toolbar, { children: [_jsx(Toolbar.Item, { icon: _jsx(FaPlus, {}), title: "Add a new peak", intent: "success", onClick: () => addHandler(peaks) }), _jsx(Toolbar.Item, { icon: _jsx(FaRegTrashAlt, {}), title: "Delete all peaks", intent: "danger", onClick: deleteAllHandler })] }) }), _jsx("div", { style: {
138
+ maxHeight: '300px',
139
+ overflow: 'auto',
140
+ }, children: _jsx(ReactTable, { data: peaks, columns: COLUMNS, onClick: (e, rowData) => selectRowHandler(rowData.index), activeRow: handleActiveRow, emptyDataRowText: "No peaks" }) })] }));
141
+ }
@@ -47,14 +47,14 @@ const editPathLengthsStyles = css `
47
47
  `;
48
48
  function EditPathLengthFormik({ signalIndex }) {
49
49
  const { errors, values, } = useFormikContext();
50
- return (_jsxs("div", { css: editPathLengthsStyles, children: [_jsx("p", { children: "Setting of the minimum and maximum path length (J coupling)." }), _jsxs("div", { className: "input-container", children: [_jsx(Label, { title: "Min: ", children: _jsx(FormikNumberInput, { name: `signals[${signalIndex}].j.pathLength.from`, defaultValue: values.signals[signalIndex].j?.pathLength?.from ||
50
+ return (_jsxs("div", { css: editPathLengthsStyles, children: [_jsx("p", { children: "Setting of the minimum and maximum path length (J coupling)." }), _jsxs("div", { className: "input-container", children: [_jsx(Label, { title: "Min:", children: _jsx(FormikNumberInput, { name: `signals[${signalIndex}].j.pathLength.from`, defaultValue: values.signals[signalIndex].j?.pathLength?.from ||
51
51
  DefaultPathLengths[values.experimentType]?.from ||
52
52
  1, style: {
53
53
  color: errors.signals?.[signalIndex].j?.pathLength?.from
54
54
  ? 'red'
55
55
  : 'black',
56
56
  }, min: 1, max: values.signals[signalIndex].j?.pathLength?.to ||
57
- DefaultPathLengths[values.experimentType]?.to, pattern: "[1-9]+" }) }), _jsx(Label, { title: "Max: ", children: _jsx(FormikNumberInput, { name: `signals[${signalIndex}].j.pathLength.to`, defaultValue: values.signals[signalIndex].j?.pathLength?.to ||
57
+ DefaultPathLengths[values.experimentType]?.to, pattern: "[1-9]+" }) }), _jsx(Label, { title: "Max:", children: _jsx(FormikNumberInput, { name: `signals[${signalIndex}].j.pathLength.to`, defaultValue: values.signals[signalIndex].j?.pathLength?.to ||
58
58
  DefaultPathLengths[values.experimentType]?.to ||
59
59
  1, style: {
60
60
  color: errors.signals?.[signalIndex].j?.pathLength?.to
@@ -96,6 +96,6 @@ function EditZoneModal({ onSaveEditZoneModal = () => null, onCloseEditZoneModal
96
96
  }),
97
97
  };
98
98
  }, [rowData.signals, rowData.tableMetaInfo.experiment]);
99
- return (_jsx("div", { css: styles, children: _jsx(Formik, { innerRef: formRef, initialValues: data, validationSchema: zoneFormValidation, onSubmit: handleOnSave, children: _jsxs(_Fragment, { children: [_jsxs("div", { className: "header handle", children: [_jsx(Button, { onClick: handleOnZoom, className: "zoom-button", children: _jsx(FaSearchPlus, { title: "Set to default view on range in spectrum" }) }), _jsx("span", { children: `Zone and Signal edition` }), _jsx(SaveButton, { onClick: () => formRef.current.submitForm(), title: "Save and Exit" }), _jsx(CloseButton, { title: "Close", onClick: handleOnClose })] }), _jsx(SignalsForm, {})] }) }) }));
99
+ return (_jsx("div", { css: styles, children: _jsx(Formik, { innerRef: formRef, initialValues: data, validationSchema: zoneFormValidation, onSubmit: handleOnSave, children: _jsxs(_Fragment, { children: [_jsxs("div", { className: "header handle", children: [_jsx(Button, { onClick: handleOnZoom, className: "zoom-button", children: _jsx(FaSearchPlus, { title: "Set to default view on range in spectrum" }) }), _jsx("span", { children: `Zone and Signal edition` }), _jsx(SaveButton, { onClick: () => formRef.current.submitForm(), title: "Save and exit" }), _jsx(CloseButton, { title: "Close", onClick: handleOnClose })] }), _jsx(SignalsForm, {})] }) }) }));
100
100
  }
101
101
  export default EditZoneModal;
@@ -1,6 +1,9 @@
1
- interface MetaImportationModalProps {
2
- onClose?: () => void;
1
+ interface InnerMetaImportationModalPropsProps {
3
2
  file?: File;
3
+ onCloseDialog: () => void;
4
4
  }
5
- declare function MetaImportationModal({ onClose, file }: MetaImportationModalProps): import("@emotion/react/jsx-runtime").JSX.Element;
6
- export default MetaImportationModal;
5
+ interface MetaImportationModalPropsProps extends InnerMetaImportationModalPropsProps {
6
+ isOpen: boolean;
7
+ }
8
+ export declare function MetaImportationModal(props: MetaImportationModalPropsProps): import("@emotion/react/jsx-runtime").JSX.Element | null;
9
+ export {};
@@ -1,5 +1,6 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
2
  /** @jsxImportSource @emotion/react */
3
+ import { Dialog, DialogBody, DialogFooter } from '@blueprintjs/core';
3
4
  import { Formik } from 'formik';
4
5
  import { useState, useMemo, useRef, useEffect } from 'react';
5
6
  import { DropZone } from 'react-science/ui';
@@ -7,16 +8,14 @@ import * as Yup from 'yup';
7
8
  import { isMetaFile, linkMetaWithSpectra, parseMetaFile, TargetPathError, mapErrors, } from '../../../data/parseMeta';
8
9
  import { useChartData } from '../../context/ChartContext';
9
10
  import { useDispatch } from '../../context/DispatchContext';
11
+ import { useToaster } from '../../context/ToasterContext';
10
12
  import Button from '../../elements/Button';
11
- import { CloseButton } from '../../elements/CloseButton';
12
13
  import Label from '../../elements/Label';
13
14
  import ReactTable from '../../elements/ReactTable/ReactTable';
14
15
  import FormikInput from '../../elements/formik/FormikInput';
15
16
  import FormikSelect from '../../elements/formik/FormikSelect';
16
- import { useAlert } from '../../elements/popup/Alert/Context';
17
17
  import { convertPathArrayToString } from '../../utility/convertPathArrayToString';
18
18
  import { getSpectraObjectPaths } from '../../utility/getSpectraObjectPaths';
19
- import { ModalStyles } from '../ModalStyle';
20
19
  import { mapColumnToSelectItems } from './utils/mapColumnToSelectItems';
21
20
  const styles = {
22
21
  container: {
@@ -63,8 +62,14 @@ const validationSchema = Yup.object({
63
62
  source: Yup.string().required(),
64
63
  target: Yup.array(Yup.string()).min(1).required(),
65
64
  });
66
- function MetaImportationModal({ onClose, file }) {
67
- const alert = useAlert();
65
+ export function MetaImportationModal(props) {
66
+ const { isOpen, onCloseDialog, file } = props;
67
+ if (!isOpen)
68
+ return null;
69
+ return (_jsx(Dialog, { isOpen: true, title: "Import meta information", style: { width: 900, height: 600 }, onClose: onCloseDialog, children: _jsx(InnerMetaImportationModal, { onCloseDialog, file }) }));
70
+ }
71
+ function InnerMetaImportationModal({ file, onCloseDialog, }) {
72
+ const toaster = useToaster();
68
73
  const dispatch = useDispatch();
69
74
  const formRef = useRef(null);
70
75
  const [parseResult, setParseResult] = useState();
@@ -129,7 +134,10 @@ function MetaImportationModal({ onClose, file }) {
129
134
  setCompareResults(compareResult);
130
135
  }
131
136
  else {
132
- alert.error(`No matches found: Source field [${source}] => Target field [${target}]`);
137
+ toaster.show({
138
+ message: `No matches found: Source field [${source}] => Target field [${target}]`,
139
+ intent: 'danger',
140
+ });
133
141
  }
134
142
  }
135
143
  catch (error) {
@@ -137,7 +145,10 @@ function MetaImportationModal({ onClose, file }) {
137
145
  void formRef.current?.setFieldValue('target', null);
138
146
  formRef.current?.setFieldError('target', '');
139
147
  }
140
- alert.error(error.message);
148
+ toaster.show({
149
+ message: error.message,
150
+ intent: 'danger',
151
+ });
141
152
  }
142
153
  }
143
154
  }
@@ -166,11 +177,11 @@ function MetaImportationModal({ onClose, file }) {
166
177
  type: 'IMPORT_SPECTRA_META_INFO',
167
178
  payload: { spectraMeta: matches },
168
179
  });
169
- onClose?.();
180
+ onCloseDialog?.();
170
181
  }
171
- return (_jsxs("div", { css: ModalStyles, style: { overflow: 'hidden' }, children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: "Import Meta Information" }), _jsx(CloseButton, { title: "Close", onClick: onClose, className: "close-bt" })] }), _jsx("div", { style: styles.container, children: _jsx("div", { style: { flex: 1, width: '100%' }, children: !parseResult ? (_jsx(DropZone, { fileValidator: fileValidator, emptyDescription: "Drag and Drop CSV or tab-delimited file (.csv, .txt or .tsv)", onDrop: handleDrop })) : (_jsxs(_Fragment, { children: [_jsxs("div", { style: { height: '130px' }, children: [_jsx(Formik, { innerRef: formRef, initialValues: {
182
+ return (_jsxs(_Fragment, { children: [_jsx(DialogBody, { children: _jsx("div", { style: { width: '100%', height: '100%' }, onDrop: (e) => e.preventDefault(), children: !parseResult ? (_jsx(DropZone, { validator: fileValidator, emptyDescription: "Drag and Drop CSV or tab-delimited file (.csv, .txt or .tsv)", onDrop: handleDrop, noDragEventsBubbling: true })) : (_jsxs(_Fragment, { children: [_jsxs("div", { style: { height: '130px' }, children: [_jsx(Formik, { innerRef: formRef, initialValues: {
172
183
  source: null,
173
- target: '',
184
+ target: [],
174
185
  }, onSubmit: handleLinkSpectra, validationSchema: validationSchema, children: _jsxs(_Fragment, { children: [_jsx(Label, { title: "Source field", style: { label: { width: '100px' } }, children: _jsx(FormikSelect, { name: "source", items: mapColumnToSelectItems(parseResult?.meta.fields || []), style: {
175
186
  width: '300px',
176
187
  padding: '5px',
@@ -184,7 +195,7 @@ function MetaImportationModal({ onClose, file }) {
184
195
  padding: '5px',
185
196
  fontSize: '14px',
186
197
  },
187
- }, placeholder: "Example: info.plus", datalist: datalist, mapOnChangeValue: (key) => paths?.[key] || null, mapValue: (paths) => convertPathArrayToString(paths) }) })] }) }), _jsx(Button.Done, { onClick: () => formRef.current?.submitForm(), children: "Link Spectra" })] }), _jsx("div", { style: { height: 'calc(100% - 160px)' }, children: _jsx(ReactTable, { columns: columns, data: metaData, approxItemHeight: 25, approxColumnWidth: 100, enableVirtualScroll: true, enableColumnsVirtualScroll: true, activeRow: handleActiveRow, rowStyle: handleRowStyle }) })] })) }) }), _jsx("div", { className: "footer-container", children: _jsx(Button.Done, { onClick: handleImport, disabled: Object.keys(matches).length === 0, children: "Import" }) })] }));
198
+ }, placeholder: "Example: info.plus", datalist: datalist, mapOnChangeValue: (key) => paths?.[key] || key, mapValue: (paths) => convertPathArrayToString(paths) }) })] }) }), _jsx(Button.Done, { onClick: () => formRef.current?.submitForm(), children: "Link Spectra" })] }), _jsx("div", { style: { height: 'calc(100% - 160px)' }, children: _jsx(ReactTable, { columns: columns, data: metaData, approxItemHeight: 25, approxColumnWidth: 100, enableVirtualScroll: true, enableColumnsVirtualScroll: true, activeRow: handleActiveRow, rowStyle: handleRowStyle }) })] })) }) }), _jsx(DialogFooter, { children: _jsx(Button.Done, { onClick: handleImport, disabled: Object.keys(matches).length === 0, children: "Import" }) })] }));
188
199
  }
189
200
  function fileValidator(file) {
190
201
  if (!isMetaFile(file)) {
@@ -195,4 +206,3 @@ function fileValidator(file) {
195
206
  }
196
207
  return null;
197
208
  }
198
- export default MetaImportationModal;
@@ -1,5 +1,5 @@
1
1
  export function mapColumnToSelectItems(fields) {
2
- const items = [{ value: null, label: 'Select source field' }];
2
+ const items = [{ value: '', label: 'Select source field' }];
3
3
  for (const fieldName of fields) {
4
4
  if (fieldName) {
5
5
  items.push({ value: fieldName, label: fieldName });