nmrium 0.45.1-pre.1701344673 → 0.46.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 (74) hide show
  1. package/lib/component/1d/tool/PeakPointer.js +6 -16
  2. package/lib/component/1d/utilities/scale.js +13 -8
  3. package/lib/component/1d-2d/components/SpectrumInfoBlock.js +15 -4
  4. package/lib/component/elements/ContextMenuBluePrint.d.ts +16 -0
  5. package/lib/component/elements/ContextMenuBluePrint.js +20 -0
  6. package/lib/component/elements/DropdownMenu.d.ts +9 -0
  7. package/lib/component/elements/DropdownMenu.js +7 -0
  8. package/lib/component/elements/Header.d.ts +1 -1
  9. package/lib/component/elements/Header.js +4 -6
  10. package/lib/component/elements/ReactTable/Elements/ReactTableRow.d.ts +2 -2
  11. package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +2 -2
  12. package/lib/component/elements/ReactTable/ReactTable.d.ts +5 -5
  13. package/lib/component/header/Header.js +3 -4
  14. package/lib/component/hooks/useCheckToolsVisibility.d.ts +1 -1
  15. package/lib/component/hooks/useToolsFunctions.js +2 -2
  16. package/lib/component/modal/MoleculeStructureEditorModal.d.ts +0 -8
  17. package/lib/component/modal/MoleculeStructureEditorModal.js +31 -8
  18. package/lib/component/modal/PredictSpectraModal.js +3 -2
  19. package/lib/component/modal/aboutUs/AboutUsModal.js +1 -5
  20. package/lib/component/modal/editRange/forms/components/AddSignalFormTab.js +1 -0
  21. package/lib/component/modal/editRange/forms/validation/EditRangeValidation.js +4 -1
  22. package/lib/component/modal/metaImportation/MetaImportationModal.js +1 -1
  23. package/lib/component/modal/setting/GeneralSettings.js +1 -1
  24. package/lib/component/modal/setting/settings-tabs/InfoBlockTabContent.js +1 -1
  25. package/lib/component/modal/setting/settingsValidation.js +3 -1
  26. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +7 -14
  27. package/lib/component/panels/RangesPanel/RangesHeader.js +1 -1
  28. package/lib/component/panels/RangesPanel/RangesPanel.js +1 -2
  29. package/lib/component/panels/RangesPanel/RangesTable.d.ts +2 -2
  30. package/lib/component/panels/RangesPanel/RangesTableRow.d.ts +2 -2
  31. package/lib/component/panels/RangesPanel/RangesTableRow.js +2 -2
  32. package/lib/component/panels/SpectrumsPanel/SpectraTable.js +12 -17
  33. package/lib/component/panels/ZonesPanel/ZonesTableRow.d.ts +2 -2
  34. package/lib/component/panels/ZonesPanel/ZonesTableRow.js +2 -2
  35. package/lib/component/panels/extra/preferences/ColumnsHelper.js +1 -2
  36. package/lib/component/panels/filtersPanel/FiltersTable.js +1 -1
  37. package/lib/component/panels/multipleAnalysisPanel/preferences/index.js +6 -2
  38. package/lib/component/reducer/actions/MoleculeActions.d.ts +4 -1
  39. package/lib/component/reducer/actions/MoleculeActions.js +6 -2
  40. package/lib/component/reducer/actions/PeaksActions.js +4 -3
  41. package/lib/component/reducer/actions/utilities/deepReplaceDiaIDs.d.ts +3 -0
  42. package/lib/component/reducer/actions/utilities/deepReplaceDiaIDs.js +24 -0
  43. package/lib/component/reducer/helper/Zoom1DManager.js +1 -1
  44. package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +1 -1
  45. package/lib/component/toolbar/BasicToolBar.js +53 -34
  46. package/lib/component/toolbar/FunctionToolBar.js +102 -9
  47. package/lib/component/toolbar/ToolBar.js +1 -1
  48. package/lib/component/utility/getClosePeak.d.ts +10 -0
  49. package/lib/component/utility/getClosePeak.js +15 -0
  50. package/lib/component/utility/maxAbsoluteValue.d.ts +3 -0
  51. package/lib/component/utility/maxAbsoluteValue.js +21 -0
  52. package/lib/data/data1d/Spectrum1D/index.d.ts +0 -1
  53. package/lib/data/data1d/Spectrum1D/index.js +0 -1
  54. package/lib/data/data1d/Spectrum1D/initiateDatum1D.js +2 -2
  55. package/lib/data/data1d/Spectrum1D/peaks/autoPeakPicking.js +1 -1
  56. package/lib/data/data1d/Spectrum1D/ranges/addRange.js +1 -1
  57. package/lib/data/data1d/Spectrum1D/ranges/detectRange.js +1 -1
  58. package/lib/data/data2d/Spectrum2D/contours.js +2 -2
  59. package/lib/data/data2d/Spectrum2D/getMissingProjection.js +2 -2
  60. package/lib/data/data2d/Spectrum2D/getSlice.js +3 -3
  61. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +1 -1
  62. package/lib/data/parseMeta/mapErrors.js +3 -1
  63. package/lib/versionInfo.js +1 -1
  64. package/package.json +39 -38
  65. package/lib/component/elements/ToolbarMenu.d.ts +0 -18
  66. package/lib/component/elements/ToolbarMenu.js +0 -102
  67. package/lib/component/elements/toggle/ToggleButton.d.ts +0 -13
  68. package/lib/component/elements/toggle/ToggleButton.js +0 -24
  69. package/lib/component/elements/toggle/ToggleButtonGroup.d.ts +0 -8
  70. package/lib/component/elements/toggle/ToggleButtonGroup.js +0 -48
  71. package/lib/data/data1d/Spectrum1D/peaks/lookupPeak.d.ts +0 -17
  72. package/lib/data/data1d/Spectrum1D/peaks/lookupPeak.js +0 -18
  73. package/lib/data/data2d/Processing2D.d.ts +0 -32
  74. package/lib/data/data2d/Processing2D.js +0 -130
@@ -1,48 +0,0 @@
1
- import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
- import { useCallback, useState, useMemo, useEffect, Children, cloneElement, } from 'react';
3
- import ToggleButton from './ToggleButton';
4
- export default function ToggleButtonGroup({ children, value, onChange = () => null, }) {
5
- const [toggleButtons, setToggleButtons] = useState([]);
6
- const handleOnChange = useCallback((val) => {
7
- const _toggles = [...toggleButtons];
8
- const toggles = _toggles.map((toggle) => {
9
- return {
10
- value: toggle.value,
11
- isActive: toggle.value === val,
12
- };
13
- });
14
- setToggleButtons(toggles);
15
- onChange(val);
16
- }, [onChange, toggleButtons]);
17
- const mappedChildren = useMemo(() => {
18
- let index = 0;
19
- return Children.map(children, (child) => {
20
- if (child) {
21
- if (child.type === ToggleButton) {
22
- const _child = cloneElement(child, {
23
- onChange: handleOnChange,
24
- isActive: toggleButtons[index]?.isActive,
25
- index,
26
- });
27
- index++;
28
- return _child;
29
- }
30
- else {
31
- return cloneElement(child);
32
- }
33
- }
34
- });
35
- }, [children, handleOnChange, toggleButtons]);
36
- useEffect(() => {
37
- const val = Children.map(children, (child) => {
38
- if (child && child.type === ToggleButton) {
39
- return {
40
- value: child.props.value,
41
- isActive: child.props.value === value,
42
- };
43
- }
44
- });
45
- setToggleButtons(val);
46
- }, [children, value]);
47
- return _jsx(_Fragment, { children: mappedChildren });
48
- }
@@ -1,17 +0,0 @@
1
- import { NmrData1D } from 'cheminfo-types';
2
- /**
3
- *
4
- * @param {object<{x:Array<number>,re:Array<number>}>} data
5
- * @param {object<{from:number,to:number}>} options
6
- */
7
- interface LookupPeakOptions {
8
- from: number;
9
- to: number;
10
- }
11
- interface LookupPeakResult {
12
- x: number;
13
- y: number;
14
- xIndex: number;
15
- }
16
- export declare function lookupPeak(data: NmrData1D, options: LookupPeakOptions): LookupPeakResult | null;
17
- export {};
@@ -1,18 +0,0 @@
1
- import max from 'ml-array-max';
2
- export function lookupPeak(data, options) {
3
- const { from, to } = options;
4
- let minIndex = data.x.findIndex((number) => number >= from);
5
- let maxIndex = data.x.findIndex((number) => number >= to) - 1;
6
- if (minIndex > maxIndex) {
7
- minIndex = maxIndex;
8
- maxIndex = minIndex;
9
- }
10
- const dataRange = data.re.slice(minIndex, maxIndex);
11
- if (dataRange && dataRange.length > 0) {
12
- const yValue = max(dataRange);
13
- const xIndex = dataRange.indexOf(yValue);
14
- const xValue = data.x[minIndex + xIndex];
15
- return { x: xValue, y: yValue, xIndex: minIndex + xIndex };
16
- }
17
- return null;
18
- }
@@ -1,32 +0,0 @@
1
- export declare const defaultContourOptions: {
2
- positive: {
3
- contourLevels: number[];
4
- numberOfLayers: number;
5
- };
6
- negative: {
7
- contourLevels: number[];
8
- numberOfLayers: number;
9
- };
10
- };
11
- export default class Processing2D {
12
- private options;
13
- private currentLevelPositive;
14
- private currentLevelNegative;
15
- private conrec;
16
- private median;
17
- private minMax;
18
- constructor(minMax: any, options?: any, defaultLevel?: any);
19
- getLevel(): {
20
- levelPositive: number;
21
- levelNegative: number;
22
- };
23
- setLevel(levelPositive: any, levelNegative: any): void;
24
- setOptions(options: any): void;
25
- wheel(value: any): void;
26
- shiftWheel(value: any): never[] | undefined;
27
- drawContours(): {
28
- positive: Readonly<import("ml-conrec").DrawContourResult<"basic">>;
29
- negative: Readonly<import("ml-conrec").DrawContourResult<"basic">>;
30
- };
31
- getContours(zoomLevel: any, options?: any): Readonly<import("ml-conrec").DrawContourResult<"basic">>;
32
- }
@@ -1,130 +0,0 @@
1
- import { Conrec } from 'ml-conrec';
2
- import { calculateSanPlot } from '../utilities/calculateSanPlot';
3
- export const defaultContourOptions = {
4
- positive: {
5
- contourLevels: [0, 21],
6
- numberOfLayers: 10,
7
- },
8
- negative: {
9
- contourLevels: [0, 21],
10
- numberOfLayers: 10,
11
- },
12
- };
13
- export default class Processing2D {
14
- constructor(minMax, options = defaultContourOptions, defaultLevel = {}) {
15
- this.options = options;
16
- const { positive = 10, negative = 10 } = defaultLevel;
17
- this.currentLevelPositive = positive;
18
- this.currentLevelNegative = negative;
19
- const xs = getRange(minMax.minX, minMax.maxX, minMax.z[0].length);
20
- const ys = getRange(minMax.minY, minMax.maxY, minMax.z.length);
21
- this.conrec = new Conrec(minMax.z, { xs, ys, swapAxes: false });
22
- const sanResult = calculateSanPlot('2D', minMax);
23
- this.median = sanResult.positive;
24
- this.minMax = minMax;
25
- }
26
- getLevel() {
27
- return {
28
- levelPositive: this.currentLevelPositive,
29
- levelNegative: this.currentLevelNegative,
30
- };
31
- }
32
- setLevel(levelPositive, levelNegative) {
33
- this.currentLevelPositive = levelPositive;
34
- this.currentLevelNegative = levelNegative;
35
- }
36
- setOptions(options) {
37
- const positiveBoundary = options.positive.contourLevels;
38
- const negativeBoundary = options.negative.contourLevels;
39
- if (this.currentLevelPositive >= positiveBoundary[1]) {
40
- this.currentLevelPositive = positiveBoundary[1];
41
- }
42
- else if (this.currentLevelPositive <= positiveBoundary[0]) {
43
- this.currentLevelPositive = positiveBoundary[0];
44
- }
45
- if (this.currentLevelNegative >= negativeBoundary[1]) {
46
- this.currentLevelNegative = negativeBoundary[1];
47
- }
48
- else if (this.currentLevelNegative <= negativeBoundary[0]) {
49
- this.currentLevelNegative = negativeBoundary[0];
50
- }
51
- this.options = options;
52
- }
53
- wheel(value) {
54
- const sign = Math.sign(value);
55
- const positiveBoundary = this.options.positive.contourLevels;
56
- const negativeBoundary = this.options.negative.contourLevels;
57
- if ((this.currentLevelPositive > positiveBoundary[0] && sign === -1) ||
58
- (this.currentLevelPositive < positiveBoundary[1] && sign === 1)) {
59
- this.currentLevelPositive += sign;
60
- }
61
- if ((this.currentLevelNegative > negativeBoundary[0] && sign === -1) ||
62
- (this.currentLevelNegative < negativeBoundary[1] && sign === 1)) {
63
- this.currentLevelNegative += sign;
64
- }
65
- }
66
- shiftWheel(value) {
67
- const sign = Math.sign(value);
68
- const [min, max] = this.options.positive.contourLevels;
69
- if ((this.currentLevelPositive === min && sign === -1) ||
70
- (this.currentLevelPositive >= max && sign === 1)) {
71
- return;
72
- }
73
- this.currentLevelPositive += sign;
74
- return [];
75
- }
76
- drawContours() {
77
- const zoomPositive = this.currentLevelPositive / 2 + 1;
78
- const zoomNegative = this.currentLevelNegative / 2 + 1;
79
- const { positive: { numberOfLayers: numberOfPositiveLayer }, negative: { numberOfLayers: numberOfNegativeLayer }, } = this.options;
80
- return {
81
- positive: this.getContours(zoomPositive, {
82
- nbLevels: numberOfPositiveLayer,
83
- }),
84
- negative: this.getContours(zoomNegative, {
85
- negative: true,
86
- nbLevels: numberOfNegativeLayer,
87
- }),
88
- };
89
- }
90
- getContours(zoomLevel, options = {}) {
91
- const { negative = false, timeout = 2000, nbLevels = 10 } = options;
92
- const max = Math.max(Math.abs(this.minMax.maxZ), Math.abs(this.minMax.minZ));
93
- let _range = getRange(this.median * 1 * Math.pow(2, zoomLevel), max, nbLevels, 2);
94
- if (negative) {
95
- _range = _range.map((value) => -value);
96
- }
97
- const contours = this.conrec.drawContour({
98
- contourDrawer: 'basic',
99
- levels: _range,
100
- timeout,
101
- });
102
- return Object.freeze(contours);
103
- }
104
- }
105
- function getRange(min, max, length, exp) {
106
- if (exp !== undefined) {
107
- const factors = [];
108
- factors[0] = 0;
109
- for (let i = 1; i <= length; i++) {
110
- factors[i] = factors[i - 1] + (exp - 1) / Math.pow(exp, i);
111
- }
112
- const lastFactor = factors[length];
113
- const result = new Array(length);
114
- for (let i = 0; i < length; i++) {
115
- result[i] = (max - min) * (1 - factors[i + 1] / lastFactor) + min;
116
- }
117
- return result;
118
- }
119
- else {
120
- const step = (max - min) / (length - 1);
121
- return range(min, max + step / 2, step);
122
- }
123
- }
124
- function range(from, to, step) {
125
- const result = [];
126
- for (let i = from; i < to; i += step) {
127
- result.push(i);
128
- }
129
- return result;
130
- }