nmrium 0.50.1 → 0.51.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 (151) 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 +29 -15
  23. package/lib/component/context/ToasterContext.d.ts +13 -0
  24. package/lib/component/context/ToasterContext.js +34 -0
  25. package/lib/component/elements/Select.js +2 -2
  26. package/lib/component/elements/ToolbarPopoverItem.js +1 -1
  27. package/lib/component/header/AutoPeakPickingOptionPanel.js +6 -3
  28. package/lib/component/header/Header.d.ts +1 -11
  29. package/lib/component/header/Header.js +5 -6
  30. package/lib/component/header/PhaseCorrectionPanel.js +24 -33
  31. package/lib/component/header/PhaseCorrectionTwoDimensionsPanel.d.ts +1 -1
  32. package/lib/component/header/PhaseCorrectionTwoDimensionsPanel.js +96 -42
  33. package/lib/component/header/RangesPickingOptionPanel.js +6 -3
  34. package/lib/component/hooks/useDialogToggle.d.ts +5 -0
  35. package/lib/component/hooks/useDialogToggle.js +16 -0
  36. package/lib/component/hooks/useExport.d.ts +9 -1
  37. package/lib/component/hooks/useExport.js +34 -36
  38. package/lib/component/hooks/useSaveSettings.js +6 -3
  39. package/lib/component/hooks/useToolsFunctions.js +6 -4
  40. package/lib/component/loader/DropZone.js +14 -14
  41. package/lib/component/main/InnerNMRium.js +5 -9
  42. package/lib/component/main/InnerNMRiumContents.d.ts +0 -2
  43. package/lib/component/main/InnerNMRiumContents.js +5 -3
  44. package/lib/component/main/NMRium.js +2 -2
  45. package/lib/component/modal/AboutPredictionModal.js +1 -1
  46. package/lib/component/modal/ExportAsJcampModal.js +15 -15
  47. package/lib/component/modal/ImportPublicationStringModal.js +5 -3
  48. package/lib/component/modal/LoadJCAMPModal.js +6 -4
  49. package/lib/component/modal/PredictSpectraModal.js +11 -9
  50. package/lib/component/modal/SaveAsModal.d.ts +3 -4
  51. package/lib/component/modal/SaveAsModal.js +27 -27
  52. package/lib/component/modal/editRange/EditRangeModal.js +2 -2
  53. package/lib/component/modal/editRange/forms/components/DeltaInput.d.ts +2 -3
  54. package/lib/component/modal/editRange/forms/components/DeltaInput.js +2 -3
  55. package/lib/component/modal/editRange/forms/components/InfoBlock.d.ts +1 -0
  56. package/lib/component/modal/editRange/forms/components/{SignalFormInfo.js → InfoBlock.js} +2 -2
  57. package/lib/component/modal/editRange/forms/components/NewSignalTab.d.ts +5 -0
  58. package/lib/component/modal/editRange/forms/components/NewSignalTab.js +85 -0
  59. package/lib/component/modal/editRange/forms/components/SignalTab.d.ts +7 -0
  60. package/lib/component/modal/editRange/forms/components/SignalTab.js +24 -0
  61. package/lib/component/modal/editRange/forms/components/SignalsContent.d.ts +8 -0
  62. package/lib/component/modal/editRange/forms/components/SignalsContent.js +57 -0
  63. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.d.ts +5 -0
  64. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.js +133 -0
  65. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.d.ts +5 -0
  66. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.js +141 -0
  67. package/lib/component/modal/metaImportation/MetaImportationModal.d.ts +7 -4
  68. package/lib/component/modal/metaImportation/MetaImportationModal.js +23 -13
  69. package/lib/component/modal/metaImportation/utils/mapColumnToSelectItems.js +1 -1
  70. package/lib/component/modal/setting/GeneralSettings.js +7 -4
  71. package/lib/component/panels/AutomaticAssignment/useAutoAssignments.js +7 -4
  72. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +13 -7
  73. package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +6 -4
  74. package/lib/component/panels/PeaksPanel/PeaksPanel.js +6 -3
  75. package/lib/component/panels/RangesPanel/RangesHeader.js +3 -3
  76. package/lib/component/panels/RangesPanel/RangesPanel.js +4 -4
  77. package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +3 -3
  78. package/lib/component/panels/SpectrumsPanel/SpectraTable.js +11 -5
  79. package/lib/component/panels/databasePanel/DatabasePanel.js +37 -19
  80. package/lib/component/panels/databasePanel/DatabaseSearchOptions.js +1 -1
  81. package/lib/component/panels/filtersPanel/FilterPanel.js +5 -3
  82. package/lib/component/panels/filtersPanel/FiltersTable.js +27 -23
  83. package/lib/component/panels/header/SpectraAutomaticPickingButton.js +6 -4
  84. package/lib/component/panels/multipleAnalysisPanel/AlignSpectra.js +2 -2
  85. package/lib/component/panels/multipleAnalysisPanel/AnalysisChart.js +3 -3
  86. package/lib/component/panels/multipleAnalysisPanel/MultipleSpectraAnalysisPanel.js +5 -5
  87. package/lib/component/panels/multipleAnalysisPanel/preferences/index.js +4 -2
  88. package/lib/component/panels/predictionPanel/PredictionPanel.js +7 -5
  89. package/lib/component/panels/predictionPanel/PredictionSimpleOptions.js +1 -0
  90. package/lib/component/reducer/Reducer.d.ts +2 -2
  91. package/lib/component/reducer/Reducer.js +23 -16
  92. package/lib/component/reducer/actions/FiltersActions.d.ts +11 -4
  93. package/lib/component/reducer/actions/FiltersActions.js +243 -91
  94. package/lib/component/reducer/actions/IntegralsActions.js +2 -2
  95. package/lib/component/reducer/actions/MoleculeActions.js +0 -1
  96. package/lib/component/reducer/actions/RangesActions.js +16 -6
  97. package/lib/component/reducer/actions/ToolsActions.d.ts +3 -3
  98. package/lib/component/reducer/actions/ToolsActions.js +75 -14
  99. package/lib/component/reducer/helper/Zoom1DManager.d.ts +4 -3
  100. package/lib/component/reducer/helper/Zoom1DManager.js +4 -4
  101. package/lib/component/reducer/helper/ZoomHistoryManager.js +1 -5
  102. package/lib/component/reducer/helper/findStrongestPeak.d.ts +6 -0
  103. package/lib/component/reducer/helper/findStrongestPeak.js +13 -0
  104. package/lib/component/reducer/helper/getTwoDimensionPhaseCorrectionOptions.d.ts +2 -1
  105. package/lib/component/reducer/helper/getTwoDimensionPhaseCorrectionOptions.js +7 -1
  106. package/lib/component/toolbar/ToolBar.js +17 -12
  107. package/lib/component/utility/Events.d.ts +11 -0
  108. package/lib/component/utility/Events.js +22 -0
  109. package/lib/data/data1d/Spectrum1D/ranges/addRange.d.ts +0 -33
  110. package/lib/data/data1d/Spectrum1D/ranges/addRange.js +5 -15
  111. package/lib/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +6 -4
  112. package/lib/data/data1d/Spectrum1D/ranges/changeRange.js +1 -1
  113. package/lib/data/data1d/Spectrum1D/ranges/detectRange.js +1 -1
  114. package/lib/data/data1d/Spectrum1D/ranges/detectRanges.d.ts +6 -4
  115. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +13 -3
  116. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +6 -0
  117. package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.d.ts +13 -3
  118. package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.js +78 -18
  119. package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +2 -2
  120. package/lib/data/data1d/spectrumSimulation.d.ts +1 -1
  121. package/lib/data/data2d/Spectrum2D/contours.js +3 -3
  122. package/lib/data/data2d/Spectrum2D/getMissingProjection.js +2 -2
  123. package/lib/data/data2d/Spectrum2D/getSlice.js +3 -3
  124. package/lib/data/getDefaultMatrixFilters.js +2 -2
  125. package/lib/data/matrixGeneration.js +1 -1
  126. package/lib/data/utilities/calculateSanPlot.d.ts +1 -6
  127. package/lib/versionInfo.js +1 -1
  128. package/package.json +31 -30
  129. package/lib/component/elements/popup/Alert/AlertBlock.d.ts +0 -8
  130. package/lib/component/elements/popup/Alert/AlertBlock.js +0 -30
  131. package/lib/component/elements/popup/Alert/Context.d.ts +0 -27
  132. package/lib/component/elements/popup/Alert/Context.js +0 -10
  133. package/lib/component/elements/popup/Alert/ProgressIndicator.d.ts +0 -1
  134. package/lib/component/elements/popup/Alert/ProgressIndicator.js +0 -33
  135. package/lib/component/elements/popup/Alert/Provider.d.ts +0 -19
  136. package/lib/component/elements/popup/Alert/Provider.js +0 -127
  137. package/lib/component/elements/popup/Alert/index.d.ts +0 -3
  138. package/lib/component/elements/popup/Alert/index.js +0 -3
  139. package/lib/component/modal/editRange/forms/components/AddSignalFormTab.d.ts +0 -10
  140. package/lib/component/modal/editRange/forms/components/AddSignalFormTab.js +0 -81
  141. package/lib/component/modal/editRange/forms/components/CouplingsTable.d.ts +0 -13
  142. package/lib/component/modal/editRange/forms/components/CouplingsTable.js +0 -63
  143. package/lib/component/modal/editRange/forms/components/SignalFormInfo.d.ts +0 -1
  144. package/lib/component/modal/editRange/forms/components/SignalFormTab.d.ts +0 -8
  145. package/lib/component/modal/editRange/forms/components/SignalFormTab.js +0 -18
  146. package/lib/component/modal/editRange/forms/components/SignalsForm.d.ts +0 -10
  147. package/lib/component/modal/editRange/forms/components/SignalsForm.js +0 -114
  148. package/lib/component/modal/metaImportation/index.d.ts +0 -2
  149. package/lib/component/modal/metaImportation/index.js +0 -17
  150. package/lib/component/reducer/helper/getStrongestPeak.d.ts +0 -7
  151. package/lib/component/reducer/helper/getStrongestPeak.js +0 -15
@@ -1,10 +0,0 @@
1
- /// <reference types="react" />
2
- import { WorkSpacePanelPreferences } from 'nmr-load-save';
3
- interface AddSignalFormTabProps {
4
- onFocus: (element: any) => void;
5
- onBlur?: () => void;
6
- range: any;
7
- preferences: WorkSpacePanelPreferences['ranges'];
8
- }
9
- declare const _default: import("react").ForwardRefExoticComponent<AddSignalFormTabProps & import("react").RefAttributes<unknown>>;
10
- export default _default;
@@ -1,81 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
2
- /** @jsxImportSource @emotion/react */
3
- import { css } from '@emotion/react';
4
- import { Formik, useFormikContext } from 'formik';
5
- import { translateMultiplet } from 'nmr-processing';
6
- import { forwardRef, useCallback, useMemo } from 'react';
7
- import { FaPlus } from 'react-icons/fa';
8
- import * as Yup from 'yup';
9
- import Button from '../../../../elements/Button';
10
- import FormikInput from '../../../../elements/formik/FormikInput';
11
- import { formatNumber } from '../../../../utility/formatNumber';
12
- const styles = {
13
- container: css `
14
- text-align: center;
15
- width: 100%;
16
- height: 100%;
17
- padding: 0.4rem;
18
- `,
19
- inputInfo: css `
20
- font-size: 10px;
21
- color: black;
22
- font-weight: bold;
23
- `,
24
- infoText: css `
25
- padding: 10px;
26
- font-size: 13px;
27
- `,
28
- signalContainer: css `
29
- border: 0.55px solid #dedede;
30
- `,
31
- inputContainer: css `
32
- display: flex;
33
- justify-content: center;
34
- `,
35
- };
36
- // TODO: this seems to be a hacky use of ref.
37
- function AddSignalFormTab({ onFocus, onBlur, range, preferences }, ref) {
38
- const { values, setFieldValue } = useFormikContext();
39
- const saveHandler = useCallback((val) => {
40
- const newSignal = {
41
- multiplicity: 'm',
42
- kind: 'signal',
43
- delta: Number(val.newSignalDelta),
44
- js: [{ multiplicity: translateMultiplet('m'), coupling: '' }],
45
- };
46
- const _signals = values.signals.slice().concat(newSignal);
47
- void setFieldValue('signals', _signals);
48
- void setFieldValue('activeTab', String(_signals.length - 1));
49
- }, [setFieldValue, values.signals]);
50
- const validation = useMemo(() => {
51
- return Yup.object().shape({
52
- newSignalDelta: Yup.number()
53
- .test(`test-range`, '', function testNewSignalDelta(value) {
54
- // eslint-disable-next-line no-invalid-this
55
- const { path, createError } = this;
56
- if (value && value > range.from && value < range.to) {
57
- return true;
58
- }
59
- const errorMessage = ` ${value ? value.toFixed(5) : 0} ppm out of the range`;
60
- return createError({ path, message: errorMessage });
61
- })
62
- .required(),
63
- });
64
- }, [range]);
65
- const triggerSubmitHandler = useCallback(() => {
66
- ref.current.submitForm();
67
- }, [ref]);
68
- return (_jsx("div", { css: styles.container, children: _jsxs("div", { children: [_jsx("p", { css: styles.infoText, children: "Edit or select a delta value of new signal (ppm):" }), _jsx(Formik, { innerRef: ref, validationSchema: validation, initialValues: {
69
- newSignalDelta: (range.from + range.to) / 2,
70
- }, onSubmit: saveHandler, children: _jsxs(_Fragment, { children: [_jsxs("div", { css: styles.inputContainer, children: [_jsx(FormikInput, { name: "newSignalDelta", type: "number", placeholder: `𝛅 (ppm)`, onFocus: onFocus, onBlur: onBlur, style: {
71
- input: {
72
- width: '250px',
73
- height: '30px',
74
- padding: '0.25rem 0.5rem',
75
- },
76
- }, checkErrorAfterInputTouched: false }), _jsx(Button.Done, { style: {
77
- marginLeft: '5px',
78
- height: '30px',
79
- }, onClick: triggerSubmitHandler, children: _jsx(FaPlus, { title: "Add new signal" }) })] }), _jsxs("p", { css: styles.inputInfo, children: ["[", `${formatNumber(range.from, preferences.from.format)} ppm - ${formatNumber(range.to, preferences.to.format)} ppm`, "]"] })] }) })] }) }));
80
- }
81
- export default forwardRef(AddSignalFormTab);
@@ -1,13 +0,0 @@
1
- /// <reference types="react" />
2
- interface CouplingsTableProps {
3
- push: (element: {
4
- multiplicity?: string;
5
- coupling: string;
6
- }) => void;
7
- remove: (element: number) => void;
8
- onFocus: (element: any) => void;
9
- onBlur?: () => void;
10
- }
11
- declare function CouplingsTable({ push, remove, onFocus, onBlur, }: CouplingsTableProps): import("@emotion/react/jsx-runtime").JSX.Element;
12
- declare const _default: import("react").MemoExoticComponent<typeof CouplingsTable>;
13
- export default _default;
@@ -1,63 +0,0 @@
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 lodashGet from 'lodash/get';
6
- import { translateMultiplet } from 'nmr-processing';
7
- import { memo, useCallback } from 'react';
8
- import { FaPlus, FaRegTrashAlt } from 'react-icons/fa';
9
- import { Multiplets } from '../../../../../data/constants/Multiplets';
10
- import Button from '../../../../elements/Button';
11
- import FormikInput from '../../../../elements/formik/FormikInput';
12
- import FormikSelect from '../../../../elements/formik/FormikSelect';
13
- import { hasCouplingConstant } from '../../../../panels/extra/utilities/MultiplicityUtilities';
14
- const CouplingsTableStyle = css `
15
- border-spacing: 0;
16
- border: 1px solid #dedede;
17
- width: 100%;
18
- height: 100%;
19
- font-size: 12px;
20
-
21
- th,
22
- td {
23
- text-align: center;
24
- margin: 0;
25
- padding: 0.3rem;
26
- border-bottom: 1px solid #f5f5f5;
27
-
28
- .select-box {
29
- background-color: transparent;
30
- border: 0.5px solid #dedede;
31
- height: 100%;
32
- width: 100% !important;
33
- text-align: center;
34
- margin: 0;
35
- }
36
- }
37
- `;
38
- function CouplingsTable({ push, remove, onFocus, onBlur, }) {
39
- const { values, setFieldValue } = useFormikContext();
40
- const multiplicityChangeHandler = useCallback((value, name) => {
41
- if (!hasCouplingConstant(value)) {
42
- void setFieldValue(name, '');
43
- }
44
- }, [setFieldValue]);
45
- const couplingsList = lodashGet(values, `signals[${values.activeTab}].js`, []);
46
- return (_jsxs("div", { children: [_jsxs(Button.Done, { fill: "outline", style: { overflow: 'auto' }, onClick: () => push({
47
- multiplicity: translateMultiplet('m'),
48
- coupling: '',
49
- }), children: [_jsx(FaPlus, { title: "Add new coupling", style: { display: 'inline-block' } }), _jsx("span", { style: { display: 'inline-block', paddingLeft: '5px' }, children: "Add New Coupling" })] }), _jsx("div", { style: { maxHeight: '300px', overflow: 'auto' }, children: _jsxs("table", { css: CouplingsTableStyle, children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "#" }), _jsx("th", { children: "Multiplicity" }), _jsx("th", { children: "J (Hz)" }), _jsx("th", { children: '' })] }) }), _jsx("tbody", { style: { overflow: 'auto' }, children: couplingsList.map((_coupling, i) => (_jsxs("tr", { children: [_jsx("td", { children: i + 1 }), _jsx("td", { children: _jsx(FormikSelect, { className: "select-box", name: `signals.${values.activeTab}.js.${i}.multiplicity`, items: Multiplets, itemValueField: "label", onChange: (value) => {
50
- multiplicityChangeHandler(value, `signals.${values.activeTab}.js.${i}.coupling`);
51
- }, style: {
52
- height: '26px',
53
- } }) }), _jsx("td", { children: _jsx(FormikInput, { name: `signals.${values.activeTab}.js.${i}.coupling`, type: "number", placeholder: 'J (Hz)', disabled: !hasCouplingConstant(_coupling.multiplicity), onFocus: onFocus, onBlur: onBlur, style: {
54
- input: {
55
- width: '100%',
56
- height: '26px',
57
- padding: '0.25rem 0.5rem',
58
- },
59
- }, checkErrorAfterInputTouched: false }) }), _jsx("td", { children: _jsx("div", { style: { display: 'flex' }, children: _jsx(Button.Danger, { fill: "clear", onClick: () => {
60
- remove(i);
61
- }, children: _jsx(FaRegTrashAlt, { title: "Delete coupling" }) }) }) })] }, `editCouplings${values.activeTab}${i}`))) })] }) })] }));
62
- }
63
- export default memo(CouplingsTable);
@@ -1 +0,0 @@
1
- export declare function SignalFormInfo(): import("react/jsx-runtime").JSX.Element;
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- interface SignalFormTabProps {
3
- onFocus: (element: any) => void;
4
- onBlur?: () => void;
5
- }
6
- declare function SignalFormTab({ onFocus, onBlur }: SignalFormTabProps): import("react/jsx-runtime").JSX.Element;
7
- declare const _default: import("react").MemoExoticComponent<typeof SignalFormTab>;
8
- export default _default;
@@ -1,18 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useFormikContext, FieldArray } from 'formik';
3
- import { memo } from 'react';
4
- import CouplingsTable from './CouplingsTable';
5
- const style = {
6
- borderSpacing: '0',
7
- width: '100%',
8
- fontSize: '12px',
9
- height: '100%',
10
- margin: '0',
11
- padding: '0.4rem',
12
- textAlign: 'center',
13
- };
14
- function SignalFormTab({ onFocus, onBlur }) {
15
- const { values } = useFormikContext();
16
- return (_jsx("div", { style: style, children: _jsx(FieldArray, { name: `signals.${values.activeTab}.js`, render: ({ push, remove }) => (_jsx(CouplingsTable, { push: push, remove: remove, onFocus: onFocus, onBlur: onBlur })) }) }));
17
- }
18
- export default memo(SignalFormTab);
@@ -1,10 +0,0 @@
1
- /// <reference types="react" />
2
- import { WorkSpacePanelPreferences } from 'nmr-load-save';
3
- import { Range } from 'nmr-processing';
4
- interface SignalsFormProps {
5
- range: Range;
6
- preferences: WorkSpacePanelPreferences['ranges'];
7
- }
8
- declare function SignalsForm({ range, preferences }: SignalsFormProps): import("@emotion/react/jsx-runtime").JSX.Element;
9
- declare const _default: import("react").MemoExoticComponent<typeof SignalsForm>;
10
- export default _default;
@@ -1,114 +0,0 @@
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, useState, useRef } 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 useSpectrum from '../../../../hooks/useSpectrum';
10
- import Events from '../../../../utility/Events';
11
- import { formatNumber } from '../../../../utility/formatNumber';
12
- import AddSignalFormTab from './AddSignalFormTab';
13
- import DeltaInput from './DeltaInput';
14
- import { SignalFormInfo } from './SignalFormInfo';
15
- import SignalFormTab from './SignalFormTab';
16
- const tabStylesAddition = css `
17
- color: red;
18
- `;
19
- const tabStyles = css `
20
- padding: 0 1.5rem !important;
21
- height: 40px;
22
- `;
23
- const newTabStyles = css `
24
- padding: 0 !important;
25
- height: 40px;
26
- `;
27
- function SignalsForm({ range, preferences }) {
28
- const newSignalFormRef = useRef();
29
- const [activeField, setActiveField] = useState(null);
30
- const { values, setFieldValue, errors, } = useFormikContext();
31
- const { info } = useSpectrum({ info: {} });
32
- useEffect(() => {
33
- function handle(event) {
34
- if (info?.originFrequency && activeField) {
35
- if (values.activeTab === 'addSignalTab') {
36
- newSignalFormRef.current.setValues({
37
- [activeField]: (event.range[1] - event.range[0]) / 2 + event.range[0],
38
- });
39
- }
40
- else if (activeField.includes('delta')) {
41
- setFieldValue(activeField, (event.range[1] - event.range[0]) / 2 + event.range[0]);
42
- }
43
- else {
44
- const value = Number(formatNumber(Math.abs(event.range[0] - event.range[1]) * info.originFrequency, preferences.deltaHz.format));
45
- setFieldValue(activeField, value);
46
- }
47
- }
48
- setActiveField(null);
49
- }
50
- Events.on('brushEnd', handle);
51
- return () => {
52
- Events.off('brushEnd', handle);
53
- };
54
- }, [
55
- activeField,
56
- setFieldValue,
57
- values.activeTab,
58
- info,
59
- preferences?.deltaHz?.format,
60
- ]);
61
- useEffect(() => {
62
- function handle(event) {
63
- if (activeField) {
64
- if (values.activeTab === 'addSignalTab') {
65
- newSignalFormRef.current.setValues({ [activeField]: event.xPPM });
66
- }
67
- else if (activeField.includes('delta')) {
68
- setFieldValue(activeField, event.xPPM);
69
- }
70
- }
71
- setActiveField(null);
72
- }
73
- Events.on('mouseClick', handle);
74
- return () => {
75
- Events.off('mouseClick', handle);
76
- };
77
- }, [values.activeTab, activeField, setFieldValue]);
78
- const handleOnFocus = useCallback((event) => {
79
- setActiveField(event.target.name);
80
- }, [setActiveField]);
81
- const tapClickHandler = useCallback(({ tabid }) => {
82
- setFieldValue('activeTab', tabid);
83
- }, [setFieldValue]);
84
- const handleDeleteSignal = useCallback(({ tabid }) => {
85
- const _signals = values.signals.filter((_signal, i) => i !== Number(tabid));
86
- setFieldValue('signals', _signals);
87
- }, [setFieldValue, values.signals]);
88
- useEffect(() => {
89
- setFieldValue('activeTab', values.signals.length > 0
90
- ? (values.signals.length - 1).toString()
91
- : 'addSignalTab');
92
- }, [setFieldValue, values.signals.length]);
93
- const tabContainsErrors = useCallback((i) => {
94
- return !!errors?.signals?.[i];
95
- }, [errors]);
96
- const signalFormTabs = useMemo(() => {
97
- const signalTabs = values.signals.length > 0
98
- ? values.signals.map((signal, i) => (_jsx(Tab
99
- // eslint-disable-next-line react/no-array-index-key
100
- , { tabid: `${i}`, tabstyles: tabContainsErrors(i) ? tabStylesAddition : tabStyles, canDelete: true, render: () => (_jsx(DeltaInput, { signal: signal, index: i, onFocus: handleOnFocus })), children: _jsx(SignalFormTab, { onFocus: handleOnFocus }) }, `signalForm${i}`)))
101
- : [];
102
- const addSignalTab = (_jsx(Tab, { tabid: "addSignalTab", canDelete: false, tabstyles: newTabStyles, render: () => (_jsxs("div", { style: {
103
- display: 'flex',
104
- alignItems: 'center',
105
- padding: '0 1.5rem',
106
- fontSize: '12px',
107
- color: '#28ba62',
108
- textWrap: 'nowrap',
109
- }, children: [_jsx(FaPlus, { style: { display: 'inline-block' } }), _jsx("span", { style: { display: 'inline-block' }, children: "New Signal" })] })), children: _jsx(AddSignalFormTab, { onFocus: handleOnFocus, range: range, ref: newSignalFormRef, preferences: preferences }) }, "addSignalTab"));
110
- return [...signalTabs, addSignalTab];
111
- }, [handleOnFocus, preferences, range, tabContainsErrors, values.signals]);
112
- return (_jsxs("div", { children: [_jsx(SignalFormInfo, {}), _jsx(Tabs, { activeTab: values.activeTab, onClick: tapClickHandler, onDelete: handleDeleteSignal, children: signalFormTabs })] }));
113
- }
114
- export default memo(SignalsForm);
@@ -1,2 +0,0 @@
1
- export { default as MetaImportationModal } from './MetaImportationModal';
2
- export declare function useMetaInformationImportationModal(): (file?: File) => void;
@@ -1,17 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useCallback } from 'react';
3
- import { useModal } from '../../elements/popup/Modal/Context';
4
- import { positions } from '../../elements/popup/options';
5
- import MetaImportationModal from './MetaImportationModal';
6
- export { default as MetaImportationModal } from './MetaImportationModal';
7
- export function useMetaInformationImportationModal() {
8
- const modal = useModal();
9
- return useCallback((file) => {
10
- modal.show(_jsx(MetaImportationModal, { file: file, onClose: () => modal.close() }), {
11
- position: positions.MIDDLE,
12
- enableResizing: true,
13
- width: 900,
14
- height: 600,
15
- });
16
- }, [modal]);
17
- }
@@ -1,7 +0,0 @@
1
- import { Draft } from 'immer';
2
- import { State } from '../Reducer';
3
- export declare function getStrongestPeak(draft: Draft<State>): {
4
- xValue: number;
5
- yValue: number;
6
- index: number;
7
- } | undefined;
@@ -1,15 +0,0 @@
1
- import { max } from 'd3';
2
- import { getActiveSpectrum } from './getActiveSpectrum';
3
- export function getStrongestPeak(draft) {
4
- const activeSpectrum = getActiveSpectrum(draft);
5
- if (activeSpectrum) {
6
- const activeData = draft.data[activeSpectrum?.index].data;
7
- const strongestPeakValue = max(activeData.re);
8
- const index = activeData.re.indexOf(strongestPeakValue);
9
- return {
10
- xValue: activeData.x[index],
11
- yValue: strongestPeakValue,
12
- index,
13
- };
14
- }
15
- }