nmrium 0.19.0 → 0.20.2

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 (126) hide show
  1. package/lib/component/1d/Chart1D.js +3 -3
  2. package/lib/component/1d/ExclusionZoneAnnotation.d.ts +11 -0
  3. package/lib/component/1d/ExclusionZoneAnnotation.js +18 -0
  4. package/lib/component/1d/ExclusionZonesAnnotations.d.ts +3 -0
  5. package/lib/component/1d/ExclusionZonesAnnotations.js +28 -0
  6. package/lib/component/1d/Line.js +11 -23
  7. package/lib/component/1d/Viewer1D.js +36 -5
  8. package/lib/component/1d/ranges/Ranges.js +3 -3
  9. package/lib/component/1d/{BaseLineZones.d.ts → tool/BaseLineZones.d.ts} +0 -0
  10. package/lib/component/1d/{BaseLineZones.js → tool/BaseLineZones.js} +5 -5
  11. package/lib/component/1d/utilities/useIntegralPath.js +9 -10
  12. package/lib/component/2d/Contours.js +12 -11
  13. package/lib/component/2d/Left1DChart.js +7 -9
  14. package/lib/component/2d/Top1DChart.js +7 -7
  15. package/lib/component/2d/tools/slicing/HorizontalSliceChart.js +7 -7
  16. package/lib/component/2d/tools/slicing/VerticalSliceChart.js +7 -9
  17. package/lib/component/EventsTrackers/BrushTracker.js +2 -2
  18. package/lib/component/EventsTrackers/KeysListenerTracker.js +12 -3
  19. package/lib/component/NMRium.d.ts +1 -1
  20. package/lib/component/NMRium.js +28 -25
  21. package/lib/component/elements/NumberInput.d.ts +1 -2
  22. package/lib/component/elements/Tab/Tab.js +1 -0
  23. package/lib/component/hooks/useActiveSpectrumStyleOptions.d.ts +6 -0
  24. package/lib/component/hooks/useActiveSpectrumStyleOptions.js +15 -0
  25. package/lib/component/hooks/useXYReduce.d.ts +2 -1
  26. package/lib/component/loader/DropZone.js +1 -1
  27. package/lib/component/modal/ModalStyle.js +5 -2
  28. package/lib/component/modal/MoleculeStructureEditorModal.js +3 -2
  29. package/lib/component/modal/MultipleSpectraFiltersModal/index.js +10 -1
  30. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.d.ts +2 -0
  31. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +35 -0
  32. package/lib/component/panels/MoleculesPanel/MoleculePanel.js +49 -51
  33. package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +3 -8
  34. package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +2 -23
  35. package/lib/component/panels/Panels.js +10 -0
  36. package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum2DHistogram.js +1 -1
  37. package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/MoveLink.d.ts +5 -5
  38. package/lib/component/panels/SummaryPanel/SummaryPanel.js +1 -1
  39. package/lib/component/panels/SummaryPanel/Utilities.d.ts +7 -7
  40. package/lib/component/panels/ZonesPanel/ZonesTable.js +9 -2
  41. package/lib/component/reducer/Reducer.d.ts +11 -27
  42. package/lib/component/reducer/Reducer.js +4 -5
  43. package/lib/component/reducer/actions/CorrelationsActions.d.ts +7 -7
  44. package/lib/component/reducer/actions/CorrelationsActions.js +1 -1
  45. package/lib/component/reducer/actions/FiltersActions.d.ts +3 -1
  46. package/lib/component/reducer/actions/FiltersActions.js +60 -18
  47. package/lib/component/reducer/actions/LoadActions.js +2 -3
  48. package/lib/component/reducer/actions/MoleculeActions.js +2 -2
  49. package/lib/component/reducer/actions/PreferencesActions.js +4 -7
  50. package/lib/component/reducer/actions/RangesActions.js +1 -1
  51. package/lib/component/reducer/actions/ToolsActions.d.ts +1 -3
  52. package/lib/component/reducer/actions/ToolsActions.js +1 -30
  53. package/lib/component/reducer/helper/getRange.d.ts +6 -1
  54. package/lib/component/reducer/helper/getRange.js +1 -1
  55. package/lib/component/toolbar/FunctionToolBar.js +2 -5
  56. package/lib/component/utility/PathBuilder.d.ts +7 -0
  57. package/lib/component/utility/PathBuilder.js +17 -0
  58. package/lib/component/utility/getSpectraByNucleus.d.ts +3 -0
  59. package/lib/component/utility/getSpectraByNucleus.js +4 -0
  60. package/lib/data/Filters.d.ts +2 -1
  61. package/lib/data/Filters.js +2 -1
  62. package/lib/data/data1d/Spectrum1D/ranges/addRange.js +5 -2
  63. package/lib/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +6 -1
  64. package/lib/data/data1d/Spectrum1D/ranges/detectRange.js +0 -1
  65. package/lib/data/data1d/Spectrum1D/ranges/detectSignal.d.ts +3 -2
  66. package/lib/data/data1d/Spectrum1D/ranges/detectSignal.js +23 -15
  67. package/lib/data/data1d/filter1d/exclusionZones.d.ts +16 -0
  68. package/lib/data/data1d/filter1d/exclusionZones.js +28 -0
  69. package/lib/data/types/data1d/ExclusionZone.d.ts +5 -0
  70. package/lib/data/types/data1d/ExclusionZone.js +1 -0
  71. package/lib/versionInfo.js +1 -1
  72. package/lib-cjs/component/1d/Chart1D.js +3 -3
  73. package/lib-cjs/component/1d/ExclusionZoneAnnotation.js +23 -0
  74. package/lib-cjs/component/1d/ExclusionZonesAnnotations.js +52 -0
  75. package/lib-cjs/component/1d/Line.js +11 -23
  76. package/lib-cjs/component/1d/Viewer1D.js +36 -5
  77. package/lib-cjs/component/1d/ranges/Ranges.js +1 -1
  78. package/lib-cjs/component/1d/{BaseLineZones.js → tool/BaseLineZones.js} +5 -5
  79. package/lib-cjs/component/1d/utilities/useIntegralPath.js +9 -10
  80. package/lib-cjs/component/2d/Contours.js +12 -11
  81. package/lib-cjs/component/2d/Left1DChart.js +7 -9
  82. package/lib-cjs/component/2d/Top1DChart.js +7 -7
  83. package/lib-cjs/component/2d/tools/slicing/HorizontalSliceChart.js +7 -7
  84. package/lib-cjs/component/2d/tools/slicing/VerticalSliceChart.js +7 -9
  85. package/lib-cjs/component/EventsTrackers/BrushTracker.js +2 -2
  86. package/lib-cjs/component/EventsTrackers/KeysListenerTracker.js +12 -3
  87. package/lib-cjs/component/NMRium.js +28 -25
  88. package/lib-cjs/component/elements/Tab/Tab.js +1 -0
  89. package/lib-cjs/component/hooks/useActiveSpectrumStyleOptions.js +21 -0
  90. package/lib-cjs/component/loader/DropZone.js +1 -1
  91. package/lib-cjs/component/modal/ModalStyle.js +5 -2
  92. package/lib-cjs/component/modal/MoleculeStructureEditorModal.js +3 -2
  93. package/lib-cjs/component/modal/MultipleSpectraFiltersModal/index.js +10 -1
  94. package/lib-cjs/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +40 -0
  95. package/lib-cjs/component/panels/MoleculesPanel/MoleculePanel.js +49 -51
  96. package/lib-cjs/component/panels/MoleculesPanel/useAtomAssignment.js +3 -8
  97. package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +1 -22
  98. package/lib-cjs/component/panels/Panels.js +10 -0
  99. package/lib-cjs/component/panels/SpectrumsPanel/base/setting/Spectrum2DHistogram.js +1 -1
  100. package/lib-cjs/component/panels/ZonesPanel/ZonesTable.js +8 -1
  101. package/lib-cjs/component/reducer/Reducer.js +4 -5
  102. package/lib-cjs/component/reducer/actions/FiltersActions.js +62 -18
  103. package/lib-cjs/component/reducer/actions/LoadActions.js +2 -3
  104. package/lib-cjs/component/reducer/actions/MoleculeActions.js +2 -2
  105. package/lib-cjs/component/reducer/actions/PreferencesActions.js +4 -7
  106. package/lib-cjs/component/reducer/actions/RangesActions.js +1 -1
  107. package/lib-cjs/component/reducer/actions/ToolsActions.js +1 -32
  108. package/lib-cjs/component/reducer/helper/getRange.js +1 -1
  109. package/lib-cjs/component/toolbar/FunctionToolBar.js +2 -5
  110. package/lib-cjs/component/utility/PathBuilder.js +21 -0
  111. package/lib-cjs/component/utility/getSpectraByNucleus.js +11 -0
  112. package/lib-cjs/data/Filters.js +3 -1
  113. package/lib-cjs/data/data1d/Spectrum1D/ranges/addRange.js +5 -2
  114. package/lib-cjs/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +6 -1
  115. package/lib-cjs/data/data1d/Spectrum1D/ranges/detectRange.js +0 -1
  116. package/lib-cjs/data/data1d/Spectrum1D/ranges/detectSignal.js +24 -15
  117. package/lib-cjs/data/data1d/filter1d/exclusionZones.js +34 -0
  118. package/lib-cjs/data/types/data1d/ExclusionZone.js +2 -0
  119. package/lib-cjs/versionInfo.js +1 -1
  120. package/package.json +28 -29
  121. package/lib/component/1d/ExclusionZone.d.ts +0 -8
  122. package/lib/component/1d/ExclusionZone.js +0 -30
  123. package/lib/component/1d/ExclusionZones.d.ts +0 -2
  124. package/lib/component/1d/ExclusionZones.js +0 -10
  125. package/lib-cjs/component/1d/ExclusionZone.js +0 -32
  126. package/lib-cjs/component/1d/ExclusionZones.js +0 -16
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
22
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.resetSpectrumByFilter = exports.filterSnapshotHandler = exports.handleBaseLineCorrectionFilter = exports.deleteSpectraFilter = exports.deleteFilter = exports.enableFilter = exports.handleMultipleSpectraFilter = exports.calculateManualPhaseCorrection = exports.applyAbsoluteFilter = exports.applyAutoPhaseCorrectionFilter = exports.applyManualPhaseCorrectionFilter = exports.applyFFTFilter = exports.applyZeroFillingFilter = exports.shiftSpectrumAlongXAxis = void 0;
25
+ exports.handleDeleteExclusionZone = exports.handleAddExclusionZone = exports.resetSpectrumByFilter = exports.filterSnapshotHandler = exports.handleBaseLineCorrectionFilter = exports.deleteSpectraFilter = exports.deleteFilter = exports.enableFilter = exports.handleMultipleSpectraFilter = exports.calculateManualPhaseCorrection = exports.applyAbsoluteFilter = exports.applyAutoPhaseCorrectionFilter = exports.applyManualPhaseCorrectionFilter = exports.applyFFTFilter = exports.applyZeroFillingFilter = exports.shiftSpectrumAlongXAxis = void 0;
26
26
  const immer_1 = require("immer");
27
27
  const Filters = __importStar(require("../../../data/Filters"));
28
28
  const FiltersManager = __importStar(require("../../../data/FiltersManager"));
@@ -30,8 +30,11 @@ const Spectrum1D_1 = require("../../../data/data1d/Spectrum1D");
30
30
  const autoPhaseCorrection_1 = require("../../../data/data1d/filter1d/autoPhaseCorrection");
31
31
  const phaseCorrection_1 = require("../../../data/data1d/filter1d/phaseCorrection");
32
32
  const Spectrum2D_1 = require("../../../data/data2d/Spectrum2D");
33
+ const generateID_1 = __importDefault(require("../../../data/utilities/generateID"));
34
+ const getSpectraByNucleus_1 = require("../../utility/getSpectraByNucleus");
33
35
  const nucleusToString_1 = __importDefault(require("../../utility/nucleusToString"));
34
36
  const ZoomHistoryManager_1 = __importDefault(require("../helper/ZoomHistoryManager"));
37
+ const getRange_1 = __importDefault(require("../helper/getRange"));
35
38
  const DomainActions_1 = require("./DomainActions");
36
39
  const PreferencesActions_1 = require("./PreferencesActions");
37
40
  const ToolsActions_1 = require("./ToolsActions");
@@ -281,25 +284,66 @@ function filterSnapshotHandler(draft, action) {
281
284
  }
282
285
  exports.filterSnapshotHandler = filterSnapshotHandler;
283
286
  function handleMultipleSpectraFilter(draft, action) {
284
- if (draft.data && draft.data.length > 0) {
285
- for (let datum of draft.data) {
286
- if (datum.info?.dimension === 1 &&
287
- datum.info.nucleus === draft.activeTab &&
288
- Array.isArray(action.payload)) {
289
- const filters = action.payload.map((filter) => {
290
- if (filter.name === Filters.equallySpaced.id) {
291
- const exclusions = draft.toolOptions.data.exclusionZones[draft.activeTab] || [];
292
- return {
293
- ...filter,
294
- options: { ...filter.options, exclusions },
295
- };
296
- }
297
- return filter;
298
- });
299
- FiltersManager.applyFilter(datum, filters);
300
- }
287
+ const spectra = (0, getSpectraByNucleus_1.getSpectraByNucleus)(draft.activeTab, draft.data);
288
+ if (spectra && spectra.length > 0 && Array.isArray(action.payload)) {
289
+ const exclusions = spectra[0].filters.find((f) => f.name === Filters.exclusionZones.id)
290
+ ?.value || [];
291
+ for (const spectrum of spectra) {
292
+ const filters = action.payload.map((filter) => {
293
+ if (filter.name === Filters.equallySpaced.id) {
294
+ return {
295
+ ...filter,
296
+ options: { ...filter.options, exclusions },
297
+ };
298
+ }
299
+ return filter;
300
+ });
301
+ FiltersManager.applyFilter(spectrum, filters);
301
302
  }
302
303
  }
303
304
  (0, DomainActions_1.setDomain)(draft);
304
305
  }
305
306
  exports.handleMultipleSpectraFilter = handleMultipleSpectraFilter;
307
+ function handleAddExclusionZone(draft, action) {
308
+ const { from: startX, to: endX } = action.payload;
309
+ const range = (0, getRange_1.default)(draft, { startX, endX });
310
+ let spectra;
311
+ if (draft.activeSpectrum?.id) {
312
+ const index = draft.activeSpectrum?.index;
313
+ spectra = [draft.data[index]];
314
+ }
315
+ else {
316
+ spectra = (0, getSpectraByNucleus_1.getSpectraByNucleus)(draft.activeTab, draft.data);
317
+ }
318
+ for (const spectrum of spectra) {
319
+ FiltersManager.applyFilter(spectrum, [
320
+ {
321
+ name: Filters.exclusionZones.id,
322
+ options: [
323
+ {
324
+ id: (0, generateID_1.default)(),
325
+ from: range[0],
326
+ to: range[1],
327
+ },
328
+ ],
329
+ },
330
+ ]);
331
+ }
332
+ (0, DomainActions_1.setDomain)(draft);
333
+ }
334
+ exports.handleAddExclusionZone = handleAddExclusionZone;
335
+ function handleDeleteExclusionZone(draft, action) {
336
+ const { id, spectrumID } = action.payload;
337
+ const spectrumIndex = draft.data.findIndex((spectrum) => spectrum.id === spectrumID);
338
+ const exclusionZonesFilter = draft.data[spectrumIndex].filters.find((filter) => filter.name === Filters.exclusionZones.id);
339
+ if (exclusionZonesFilter) {
340
+ if (exclusionZonesFilter.value.length === 1) {
341
+ FiltersManager.deleteFilter(draft.data[spectrumIndex], exclusionZonesFilter.id);
342
+ }
343
+ else {
344
+ exclusionZonesFilter.value = exclusionZonesFilter.value.filter((zone) => zone.id !== id);
345
+ FiltersManager.reapplyFilters(draft.data[spectrumIndex]);
346
+ }
347
+ }
348
+ }
349
+ exports.handleDeleteExclusionZone = handleDeleteExclusionZone;
@@ -35,17 +35,16 @@ function setColors(draft, colors) {
35
35
  draft.usedColors['2d'] = draft.usedColors['2d'].concat(colors['2d']);
36
36
  }
37
37
  function setData(draft, data) {
38
- const { spectra, molecules, correlations, exclusionZones = {}, usedColors, } = data || {
38
+ const { spectra, molecules, correlations, usedColors } = data || {
39
39
  spectra: [],
40
40
  molecules: [],
41
41
  correlations: {},
42
42
  multipleAnalysis: {},
43
- exclusionZones: {},
43
+ exclusionZones: [],
44
44
  };
45
45
  setColors(draft, usedColors);
46
46
  draft.data = spectra;
47
47
  draft.molecules = MoleculeManager.fromJSON(molecules);
48
- draft.toolOptions.data.exclusionZones = exclusionZones;
49
48
  if (!correlations || Object.keys(correlations).length === 0) {
50
49
  draft.correlations = (0, nmr_correlation_1.buildCorrelationData)([], {
51
50
  tolerance: Constants_1.DefaultTolerance,
@@ -38,8 +38,8 @@ function addMoleculeHandler(draft, molfile) {
38
38
  * if it's the first creation of a molecule after the molecules list was empty,
39
39
  * set the relative sum for ranges and integrals base on the first molecule
40
40
  */
41
- if (isEmpty) {
42
- const molecule = draft.molecules[0];
41
+ const molecule = draft.molecules[0] || null;
42
+ if (isEmpty && molecule) {
43
43
  (0, SumManager_1.changeSpectraRelativeSum)(draft, molecule.key, molecule);
44
44
  }
45
45
  }
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.applyKeyPreferencesHandler = exports.setKeyPreferencesHandler = exports.changeSpectrumVerticalAlignment = void 0;
7
- const immer_1 = require("immer");
8
7
  const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
9
8
  const GroupByInfoKey_1 = __importDefault(require("../../utility/GroupByInfoKey"));
10
9
  const nucleusToString_1 = __importDefault(require("../../utility/nucleusToString"));
@@ -50,8 +49,7 @@ function changeSpectrumVerticalAlignment(draft, options) {
50
49
  }
51
50
  exports.changeSpectrumVerticalAlignment = changeSpectrumVerticalAlignment;
52
51
  function setKeyPreferencesHandler(draft, keyCode) {
53
- const state = (0, immer_1.original)(draft);
54
- const { activeTab, data, activeSpectrum, zoom, xDomain, xDomains, yDomain, yDomains, originDomain, margin, displayerMode, tabActiveSpectrum, } = state;
52
+ const { activeTab, data, activeSpectrum, zoom, xDomain, xDomains, yDomain, yDomains, originDomain, margin, displayerMode, tabActiveSpectrum, } = draft;
55
53
  if (activeTab) {
56
54
  const groupByNucleus = (0, GroupByInfoKey_1.default)('nucleus');
57
55
  const spectrumsGroupsList = groupByNucleus(data);
@@ -89,11 +87,10 @@ function setKeyPreferencesHandler(draft, keyCode) {
89
87
  }
90
88
  exports.setKeyPreferencesHandler = setKeyPreferencesHandler;
91
89
  function applyKeyPreferencesHandler(draft, keyCode) {
92
- const state = (0, immer_1.original)(draft);
93
- const preferences = state.keysPreferences[keyCode];
90
+ const preferences = draft.keysPreferences[keyCode];
94
91
  if (preferences) {
95
92
  draft.activeTab = preferences.activeTab;
96
- state.data.forEach((datum, index) => {
93
+ draft.data.forEach((datum, index) => {
97
94
  if ((0, nucleusToString_1.default)(datum.info.nucleus) === preferences.activeTab) {
98
95
  draft.data[index].display = Object.assign((0, cloneDeep_1.default)(datum.display), preferences.data[datum.id].display);
99
96
  }
@@ -111,7 +108,7 @@ function applyKeyPreferencesHandler(draft, keyCode) {
111
108
  if (draft.displayerMode === Constants_1.DISPLAYER_MODE.DM_2D) {
112
109
  for (const datumID of Object.keys(preferences.level)) {
113
110
  const { levelPositive, levelNegative } = preferences.level[datumID];
114
- const index = state.data.findIndex((datum) => datum.id === datumID);
111
+ const index = draft.data.findIndex((datum) => datum.id === datumID);
115
112
  const processController = draft.data[index]
116
113
  .processingController;
117
114
  processController.setLevel(levelPositive, levelNegative);
@@ -237,7 +237,7 @@ function handleChangeRangeSum(draft, options) {
237
237
  }
238
238
  exports.handleChangeRangeSum = handleChangeRangeSum;
239
239
  function handleAddRange(draft, action) {
240
- const { startX, endX } = action;
240
+ const { startX, endX } = action.payload;
241
241
  const { activeSpectrum, activeTab: nucleus, molecules } = draft;
242
242
  const range = (0, getRange_1.default)(draft, { startX, endX });
243
243
  if (activeSpectrum?.id) {
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
22
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.handleDeleteExclusionZone = exports.handleAddExclusionZone = exports.resetSpectraScale = exports.setSpectraSameTopHandler = exports.setTab = exports.setActiveTab = exports.levelChangeHandler = exports.handelSetActiveTab = exports.zoomOut = exports.handleZoom = exports.setVerticalIndicatorXPosition = exports.handleBrushEnd = exports.handleToggleRealImaginaryVisibility = exports.handleDeleteBaseLineZone = exports.handleAddBaseLineZone = exports.handleChangeSpectrumDisplayMode = exports.setSpectrumsVerticalAlign = exports.setSelectedOptionPanel = exports.setSelectedTool = exports.resetSelectedTool = void 0;
25
+ exports.resetSpectraScale = exports.setSpectraSameTopHandler = exports.setTab = exports.setActiveTab = exports.levelChangeHandler = exports.handelSetActiveTab = exports.zoomOut = exports.handleZoom = exports.setVerticalIndicatorXPosition = exports.handleBrushEnd = exports.handleToggleRealImaginaryVisibility = exports.handleDeleteBaseLineZone = exports.handleAddBaseLineZone = exports.handleChangeSpectrumDisplayMode = exports.setSpectrumsVerticalAlign = exports.setSelectedOptionPanel = exports.setSelectedTool = exports.resetSelectedTool = void 0;
26
26
  const d3_1 = require("d3");
27
27
  const immer_1 = require("immer");
28
28
  const ml_spectra_processing_1 = require("ml-spectra-processing");
@@ -493,34 +493,3 @@ function resetSpectraScale(draft) {
493
493
  (0, Zoom_1.setZoom)(draft, { scale: 0.8 });
494
494
  }
495
495
  exports.resetSpectraScale = resetSpectraScale;
496
- function handleAddExclusionZone(draft, action) {
497
- const { from, to } = action.payload;
498
- const scaleX = (0, scale_1.getXScale)(draft);
499
- const start = scaleX.invert(from);
500
- const end = scaleX.invert(to);
501
- let zone = [];
502
- if (start > end) {
503
- zone = [end, start];
504
- }
505
- else {
506
- zone = [start, end];
507
- }
508
- const newExclusionZone = {
509
- id: (0, generateID_1.default)(),
510
- from: zone[0],
511
- to: zone[1],
512
- };
513
- if (draft.toolOptions.data.exclusionZones[draft.activeTab]) {
514
- draft.toolOptions.data.exclusionZones[draft.activeTab].push(newExclusionZone);
515
- }
516
- else {
517
- draft.toolOptions.data.exclusionZones[draft.activeTab] = [newExclusionZone];
518
- }
519
- }
520
- exports.handleAddExclusionZone = handleAddExclusionZone;
521
- function handleDeleteExclusionZone(draft, action) {
522
- const id = action.payload.id;
523
- const index = draft.toolOptions.data.exclusionZones[draft.activeTab].findIndex((zone) => zone.id === id);
524
- draft.toolOptions.data.exclusionZones[draft.activeTab].splice(index, 1);
525
- }
526
- exports.handleDeleteExclusionZone = handleDeleteExclusionZone;
@@ -6,7 +6,7 @@ function getRange(draft, options) {
6
6
  const scaleX = (0, scale_1.getXScale)(draft);
7
7
  const start = scaleX.invert(startX);
8
8
  const end = scaleX.invert(endX);
9
- const range = [];
9
+ const range = [0, 0];
10
10
  if (start > end) {
11
11
  range[0] = end;
12
12
  range[1] = start;
@@ -61,9 +61,6 @@ function FunctionToolBarInner({ defaultValue, activeSpectrum, info, datum, displ
61
61
  const isButtonVisible = (0, react_1.useCallback)((toolKey) => {
62
62
  return !(0, get_1.default)(preferences, `display.toolBarButtons.${toolKey}`);
63
63
  }, [preferences]);
64
- const isPanelVisible = (0, react_1.useCallback)((panelKey) => {
65
- return !(0, get_1.default)(preferences, `display.panels.${panelKey}`);
66
- }, [preferences]);
67
64
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(ToggleButtonGroup_1.default, { value: option, onChange: handleChange, children: [isButtonVisible('hideZoomTool') && ((0, jsx_runtime_1.jsx)(ToggleButton_1.default, { value: ToolTypes_1.options.zoom.id, id: "zoomIn", title: `${ToolTypes_1.options.zoom.label} ( Press z )`, children: (0, jsx_runtime_1.jsx)("div", { style: { fontSize: 14 }, children: (0, jsx_runtime_1.jsx)(fa_1.FaSearchPlus, {}, void 0) }, void 0) }, ToolTypes_1.options.zoom.id)), isButtonVisible('hideZoomOutTool') && ((0, jsx_runtime_1.jsx)(analysis_ui_components_1.Toolbar.Item, { id: "zoom-out", onClick: handleFullZoomOut, title: "Horizontal zoom out ( Press f ), Horizontal and Vertical zoom out, double click ( Press ff )", children: (0, jsx_runtime_1.jsx)("div", { style: { fontSize: 14 }, children: (0, jsx_runtime_1.jsx)(fa_1.FaExpand, {}, void 0) }, void 0) }, void 0)), displayerMode === Constants_1.DISPLAYER_MODE.DM_1D &&
68
65
  isButtonVisible('hidePeakTool') && ((0, jsx_runtime_1.jsx)(ToggleButton_1.default, { value: ToolTypes_1.options.peakPicking.id, title: `${ToolTypes_1.options.peakPicking.label} ( Press p )`, isVisible: activeSpectrum && !info?.isFid ? true : false, id: "peakPicking", children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrPeakPicking, {}, void 0) }, ToolTypes_1.options.peakPicking.id)), displayerMode === Constants_1.DISPLAYER_MODE.DM_1D &&
69
66
  isButtonVisible('hideIntegralTool') && ((0, jsx_runtime_1.jsx)(ToggleButton_1.default, { value: ToolTypes_1.options.integral.id, isVisible: activeSpectrum && !info?.isFid ? true : false, id: "integralPicking", title: `${ToolTypes_1.options.integral.label} ( Press i )`, children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrIntegrate, {}, void 0) }, ToolTypes_1.options.integral.id)), displayerMode === Constants_1.DISPLAYER_MODE.DM_2D &&
@@ -85,8 +82,8 @@ function FunctionToolBarInner({ defaultValue, activeSpectrum, info, datum, displ
85
82
  ? true
86
83
  : false, children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrBaselineCorrection, {}, void 0) }, ToolTypes_1.options.baseLineCorrection.id)), displayerMode === Constants_1.DISPLAYER_MODE.DM_1D &&
87
84
  isButtonVisible('hideExclusionZonesTool') &&
88
- isPanelVisible('hideMultipleSpectraAnalysisPanel') &&
89
- !info?.isFid && ((0, jsx_runtime_1.jsx)(ToggleButton_1.default, { value: ToolTypes_1.options.exclusionZones.id, title: ToolTypes_1.options.exclusionZones.label, id: "exclusionZones", children: (0, jsx_runtime_1.jsx)("div", { style: { fontSize: 18 }, children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrMultipleAnalysis, {}, void 0) }, void 0) }, ToolTypes_1.options.exclusionZones.id))] }, void 0), displayerMode === Constants_1.DISPLAYER_MODE.DM_1D &&
85
+ !info?.isFid &&
86
+ ftCounter > 0 && ((0, jsx_runtime_1.jsx)(ToggleButton_1.default, { value: ToolTypes_1.options.exclusionZones.id, title: `${ToolTypes_1.options.exclusionZones.label} ( Press e )`, id: "exclusionZones", children: (0, jsx_runtime_1.jsx)("div", { style: { fontSize: 18 }, children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrMultipleAnalysis, {}, void 0) }, void 0) }, ToolTypes_1.options.exclusionZones.id))] }, void 0), displayerMode === Constants_1.DISPLAYER_MODE.DM_1D &&
90
87
  isButtonVisible('hideFFTTool') &&
91
88
  info &&
92
89
  Filters.fft.isApplicable({ info }) && ((0, jsx_runtime_1.jsx)(analysis_ui_components_1.Toolbar.Item, { id: "fft-filter", className: "cheminfo", title: "FFT Filter", onClick: handleOnFFTFilter, children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrFourierTransform, {}, void 0) }, void 0))] }, void 0));
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PathBuilder = void 0;
4
+ class PathBuilder {
5
+ constructor() {
6
+ this.array = [];
7
+ }
8
+ moveTo(x, y) {
9
+ this.array.push(`M ${x} ${y}`);
10
+ }
11
+ lineTo(x, y) {
12
+ this.array.push(`L ${x} ${y}`);
13
+ }
14
+ closePath() {
15
+ this.array.push('Z');
16
+ }
17
+ toString() {
18
+ return this.array.join(' ');
19
+ }
20
+ }
21
+ exports.PathBuilder = PathBuilder;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getSpectraByNucleus = void 0;
7
+ const nucleusToString_1 = __importDefault(require("./nucleusToString"));
8
+ function getSpectraByNucleus(nucleus, data) {
9
+ return data.filter((spectrum) => (0, nucleusToString_1.default)(spectrum.info.nucleus) === nucleus);
10
+ }
11
+ exports.getSpectraByNucleus = getSpectraByNucleus;
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
19
19
  return result;
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.shift2DY = exports.shift2DX = exports.pareto = exports.centerMean = exports.standardDeviation = exports.equallySpaced = exports.fromTo = exports.digitalFilter = exports.zeroFilling = exports.shiftX = exports.autoPhaseCorrection = exports.phaseCorrection = exports.fft = exports.lineBroadening = exports.baselineCorrection = exports.absolute = void 0;
22
+ exports.shift2DY = exports.shift2DX = exports.exclusionZones = exports.pareto = exports.centerMean = exports.standardDeviation = exports.equallySpaced = exports.fromTo = exports.digitalFilter = exports.zeroFilling = exports.shiftX = exports.autoPhaseCorrection = exports.phaseCorrection = exports.fft = exports.lineBroadening = exports.baselineCorrection = exports.absolute = void 0;
23
23
  const absolute = __importStar(require("./data1d/filter1d/absolute"));
24
24
  exports.absolute = absolute;
25
25
  const autoPhaseCorrection = __importStar(require("./data1d/filter1d/autoPhaseCorrection"));
@@ -32,6 +32,8 @@ const digitalFilter = __importStar(require("./data1d/filter1d/digitalFilter"));
32
32
  exports.digitalFilter = digitalFilter;
33
33
  const equallySpaced = __importStar(require("./data1d/filter1d/equallySpaced"));
34
34
  exports.equallySpaced = equallySpaced;
35
+ const exclusionZones = __importStar(require("./data1d/filter1d/exclusionZones"));
36
+ exports.exclusionZones = exclusionZones;
35
37
  const fft = __importStar(require("./data1d/filter1d/fft"));
36
38
  exports.fft = fft;
37
39
  const fromTo = __importStar(require("./data1d/filter1d/fromTo"));
@@ -15,14 +15,17 @@ function addRange(datum, options) {
15
15
  const { from, to, molecules, nucleus } = options;
16
16
  const { x, re } = datum.data;
17
17
  const absolute = (0, ml_spectra_processing_1.xyIntegration)({ x, y: re }, { from, to, reverse: true });
18
- const signals = (0, detectSignal_1.default)(x, re, from, to, datum.info.originFrequency);
18
+ // detectSignal use the advance multiplet-analysis that can crash if too many points
19
+ const signal = (0, detectSignal_1.default)(x, re, from, to, datum.info.originFrequency);
20
+ if (!signal)
21
+ return;
19
22
  try {
20
23
  const range = {
21
24
  id: (0, generateID_1.default)(),
22
25
  from,
23
26
  to,
24
27
  absolute,
25
- signals: [{ id: (0, generateID_1.default)(), ...signals }],
28
+ signals: [{ id: (0, generateID_1.default)(), ...signal }],
26
29
  kind: SignalsKinds_1.DatumKind.signal,
27
30
  integration: 0,
28
31
  };
@@ -32,12 +32,17 @@ function autoRangesDetection(datum1D, options = {}) {
32
32
  re = re.slice(windowFromIndex, windowToIndex);
33
33
  }
34
34
  if (originFrequency) {
35
- let ws = Math.max(Math.round(1 / originFrequency / (x[1] - x[0])), 5);
35
+ // we calculate the number of points per Hz
36
+ let pointsPerHz = 1 / originFrequency / (x[1] - x[0]);
37
+ // we can consider a peak with of 0.5 Hz for the windowSize
38
+ let ws = Math.max(Math.round(pointsPerHz / 2), 5);
36
39
  peakPickingOptions.sgOptions = {
37
40
  windowSize: ws - (ws % 2) + 1,
38
41
  polynomial: 3,
39
42
  };
40
43
  }
44
+ peakPickingOptions.smoothY = undefined;
45
+ peakPickingOptions.sgOptions = undefined;
41
46
  const ranges = (0, nmr_processing_1.xyAutoRangesPicking)({ x, y: re }, {
42
47
  peakPicking: peakPickingOptions,
43
48
  ranges: rangesOptions,
@@ -11,7 +11,6 @@ function detectRange(datum, options) {
11
11
  const { from, to } = options;
12
12
  const { x, re: y } = datum.data;
13
13
  const absolute = (0, ml_spectra_processing_1.xyIntegration)({ x, y }, { from, to, reverse: true });
14
- // @ts-expect-error Types will be fixed in ml-spectra-processing.
15
14
  const min = (0, ml_spectra_processing_1.xyMinYPoint)({ x, y }, { from, to }).y;
16
15
  const max = (0, ml_spectra_processing_1.xyMaxYPoint)({ x, y }, { from, to }).y;
17
16
  const shiftX = (0, getShiftX_1.getShiftX)(datum);
@@ -1,26 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MAX_LENGTH = void 0;
3
4
  const ml_spectra_processing_1 = require("ml-spectra-processing");
4
5
  const multiplet_analysis_1 = require("multiplet-analysis");
6
+ exports.MAX_LENGTH = 2048;
5
7
  function detectSignal(x, re, from, to, frequency) {
6
8
  const { fromIndex, toIndex } = (0, ml_spectra_processing_1.xGetFromToIndex)(x, {
7
9
  from: from,
8
10
  to: to,
9
11
  });
10
- const data = {
11
- x: x.slice(fromIndex, toIndex),
12
- y: re.slice(fromIndex, toIndex),
13
- };
14
- const result = (0, multiplet_analysis_1.analyseMultiplet)(data, {
15
- frequency: frequency,
16
- takeBestPartMultiplet: true,
17
- symmetrizeEachStep: true,
18
- });
19
- return {
20
- multiplicity: result.js.map((j) => j.multiplicity).join(''),
21
- kind: 'signal',
22
- delta: result.chemShift,
23
- js: result.js,
24
- };
12
+ if (toIndex - fromIndex <= exports.MAX_LENGTH) {
13
+ const data = {
14
+ x: x.subarray(fromIndex, toIndex),
15
+ y: re.subarray(fromIndex, toIndex),
16
+ };
17
+ const result = (0, multiplet_analysis_1.analyseMultiplet)(data, {
18
+ frequency: frequency,
19
+ takeBestPartMultiplet: true,
20
+ symmetrizeEachStep: true,
21
+ });
22
+ if (result && result.chemShift === undefined)
23
+ return;
24
+ return {
25
+ multiplicity: result.js.map((j) => j.multiplicity).join(''),
26
+ kind: 'signal',
27
+ delta: result.chemShift,
28
+ js: result.js,
29
+ };
30
+ }
31
+ else {
32
+ throw new Error(`length of signal should not exceed ${exports.MAX_LENGTH} points`);
33
+ }
25
34
  }
26
35
  exports.default = detectSignal;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.reduce = exports.isApplicable = exports.apply = exports.name = exports.id = void 0;
4
+ const ml_spectra_processing_1 = require("ml-spectra-processing");
5
+ exports.id = 'exclusionZones';
6
+ exports.name = 'Exclusion Zones';
7
+ /**
8
+ *
9
+ * @param {Datum1d} datum1d
10
+ */
11
+ function apply(datum1D, zones = []) {
12
+ if (!isApplicable(datum1D)) {
13
+ throw new Error('Exclusion Zones filter not applicable on this data');
14
+ }
15
+ const { x, re, im } = datum1D.data;
16
+ datum1D.data.re = (0, ml_spectra_processing_1.xySetYValue)({ x, y: re }, { zones }).y;
17
+ datum1D.data.im = (im
18
+ ? (0, ml_spectra_processing_1.xySetYValue)({ x, y: re }, { zones })
19
+ : im);
20
+ }
21
+ exports.apply = apply;
22
+ function isApplicable(datum1D) {
23
+ if (datum1D.info.isComplex && datum1D.info.isFt)
24
+ return true;
25
+ return false;
26
+ }
27
+ exports.isApplicable = isApplicable;
28
+ function reduce(previousValue, newValue) {
29
+ return {
30
+ once: true,
31
+ reduce: (0, ml_spectra_processing_1.zonesNormalize)(previousValue.concat(newValue)),
32
+ };
33
+ }
34
+ exports.reduce = reduce;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = { version: 'v0.19.0' };
3
+ exports.default = { version: 'v0.20.2' };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nmrium",
3
3
  "description": "React component to display and process nuclear magnetic resonance (NMR) spectra.",
4
- "version": "0.19.0",
4
+ "version": "0.20.2",
5
5
  "license": "MIT",
6
6
  "main": "lib-cjs/component/NMRium.js",
7
7
  "module": "lib/component/NMRium.js",
@@ -14,10 +14,10 @@
14
14
  "build": "vite build --outDir build",
15
15
  "build-no-minify": "cross-env NO_MINIFY=true npm run build",
16
16
  "build-with-profiling": "cross-env WITH_PROFILING=true npm run build",
17
- "check-types": "tsc --noEmit",
17
+ "check-types": "tsc --project tsconfig.esm.json",
18
18
  "compile": "tsc --project tsconfig.esm.json && tsc --project tsconfig.cjs.json",
19
19
  "clean-lib": "rimraf lib lib-cjs",
20
- "dev": "vite --host localhost --strictPort --open",
20
+ "dev": "vite --host localhost --port 3000 --strictPort --open",
21
21
  "eslint": "eslint . --cache",
22
22
  "eslint-fix": "npm run eslint -- --fix",
23
23
  "install:clean": "rm -rf node_modules/ && rm -rf package-lock.json && npm install && npm start",
@@ -38,17 +38,17 @@
38
38
  "url": "git+https://github.com/cheminfo/nmrium.git"
39
39
  },
40
40
  "volta": {
41
- "node": "16.13.2"
41
+ "node": "16.14.0"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "react": ">=16.0.0",
45
45
  "react-dom": ">=16.0.0"
46
46
  },
47
47
  "dependencies": {
48
- "@emotion/react": "^11.7.1",
49
- "analysis-ui-components": "^0.9.2",
48
+ "@emotion/react": "^11.8.1",
49
+ "analysis-ui-components": "^0.10.3",
50
50
  "cheminfo-font": "^1.8.1",
51
- "cheminfo-types": "^0.9.1",
51
+ "cheminfo-types": "^1.1.0",
52
52
  "d3": "^7.3.0",
53
53
  "eventemitter3": "^4.0.7",
54
54
  "file-saver": "^2.0.5",
@@ -56,7 +56,7 @@
56
56
  "immer": "^9.0.12",
57
57
  "jszip": "^3.7.1",
58
58
  "lodash": "^4.17.21",
59
- "mf-parser": "^1.4.0",
59
+ "mf-parser": "^1.4.4",
60
60
  "ml-airpls": "^1.0.0",
61
61
  "ml-array-max": "^1.2.4",
62
62
  "ml-array-mean": "^1.1.6",
@@ -64,29 +64,29 @@
64
64
  "ml-array-xy-equally-spaced": "^1.2.1",
65
65
  "ml-baseline-correction-regression": "^1.0.0",
66
66
  "ml-conrec": "^3.2.1",
67
- "ml-gsd": "^9.1.0",
68
- "ml-spectra-processing": "^8.1.0",
67
+ "ml-gsd": "^10.1.2",
68
+ "ml-spectra-processing": "^11.0.0",
69
69
  "ml-stat": "^1.3.3",
70
70
  "multiplet-analysis": "^2.0.0",
71
- "nmr-correlation": "^2.2.0",
72
- "nmr-parser": "^1.7.2",
73
- "nmr-processing": "^6.0.4",
71
+ "nmr-correlation": "^2.2.5",
72
+ "nmr-parser": "^1.7.3",
73
+ "nmr-processing": "^7.0.1",
74
74
  "nmredata": "^0.6.1",
75
75
  "numeral": "^2.0.6",
76
76
  "openchemlib": "^7.4.3",
77
- "openchemlib-utils": "^1.8.0",
78
- "re-resizable": "^6.9.1",
77
+ "openchemlib-utils": "^1.9.0",
78
+ "re-resizable": "^6.9.2",
79
79
  "react-color": "2.17.2",
80
- "react-d3-utils": "^0.4.0",
80
+ "react-d3-utils": "^0.5.0",
81
81
  "react-draggable": "^4.4.4",
82
- "react-dropzone": "^11.5.1",
82
+ "react-dropzone": "^12.0.4",
83
83
  "react-error-boundary": "^3.1.4",
84
84
  "react-icons": "^4.3.1",
85
85
  "react-inspector": "^5.1.1",
86
86
  "react-mf": "^2.0.1",
87
- "react-ocl": "^4.3.3",
87
+ "react-ocl": "^4.3.4",
88
88
  "react-ocl-nmr": "^1.1.0",
89
- "react-plot": "^0.14.0",
89
+ "react-plot": "^0.16.0",
90
90
  "react-rnd": "^10.3.5",
91
91
  "react-slider": "^1.3.1",
92
92
  "react-table": "^7.7.0",
@@ -99,30 +99,29 @@
99
99
  "@babel/plugin-transform-modules-commonjs": "^7.16.8",
100
100
  "@babel/preset-react": "^7.16.7",
101
101
  "@babel/preset-typescript": "^7.16.7",
102
- "@playwright/test": "^1.18.0",
102
+ "@playwright/test": "^1.19.2",
103
103
  "@simbathesailor/use-what-changed": "^2.0.0",
104
104
  "@types/d3": "^7.1.0",
105
- "@types/jest": "^27.4.0",
106
- "@types/node": "^17.0.10",
107
- "@types/react": "^17.0.38",
105
+ "@types/jest": "^27.4.1",
106
+ "@types/node": "^17.0.21",
107
+ "@types/react": "^17.0.39",
108
108
  "@types/react-dom": "^17.0.11",
109
109
  "@types/react-router-dom": "^5.3.3",
110
- "@vitejs/plugin-react": "^1.1.4",
110
+ "@vitejs/plugin-react": "^1.2.0",
111
111
  "@zakodium/eslint-config": "^5.1.0",
112
112
  "cross-env": "^7.0.3",
113
- "eslint": "^8.7.0",
114
- "jest": "^27.4.7",
113
+ "eslint": "^8.10.0",
114
+ "jest": "^27.5.1",
115
115
  "modern-normalize": "^1.1.0",
116
116
  "prettier": "^2.5.1",
117
- "rc-menu": "^9.3.1",
117
+ "rc-menu": "^9.3.2",
118
118
  "react": "^17.0.2",
119
119
  "react-dom": "^17.0.2",
120
120
  "react-router-dom": "^5.3.0",
121
- "reactstrap": "^8.10.1",
122
121
  "rimraf": "^3.0.2",
123
122
  "rollup-plugin-analyzer": "^4.0.0",
124
123
  "serve": "^13.0.2",
125
124
  "typescript": "~4.5.5",
126
- "vite": "^2.7.13"
125
+ "vite": "^2.8.4"
127
126
  }
128
127
  }
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- import { ExclusionZoneState } from '../reducer/Reducer';
3
- interface ExclusionZoneProps {
4
- zone: ExclusionZoneState;
5
- }
6
- declare function ExclusionZone({ zone }: ExclusionZoneProps): import("@emotion/react/jsx-runtime").JSX.Element;
7
- declare const _default: import("react").MemoExoticComponent<typeof ExclusionZone>;
8
- export default _default;