nmrium 0.58.0 → 0.60.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 (194) hide show
  1. package/lib/component/1d/LinesSeries.js +17 -5
  2. package/lib/component/1d/Viewer1D.js +10 -4
  3. package/lib/component/1d/integral/IntegralResizable.js +2 -2
  4. package/lib/component/1d/matrix/useMatrix.d.ts +1 -1
  5. package/lib/component/1d/multiAnalysis/AnalysisRange.js +1 -1
  6. package/lib/component/1d/ranges/Atoms.js +6 -4
  7. package/lib/component/1d/ranges/Range.js +4 -2
  8. package/lib/component/1d/tool/PivotIndicator.d.ts +1 -0
  9. package/lib/component/1d/tool/{VerticalIndicator.js → PivotIndicator.js} +8 -4
  10. package/lib/component/1d-2d/tools/BrushXY.js +0 -1
  11. package/lib/component/1d-2d/tools/CrossLinePointer.js +0 -1
  12. package/lib/component/2d/Viewer2D.js +7 -3
  13. package/lib/component/2d/tools/PivotIndicator.d.ts +1 -2
  14. package/lib/component/2d/tools/PivotIndicator.js +2 -3
  15. package/lib/component/2d/zones/Zone.js +2 -2
  16. package/lib/component/EventsTrackers/KeysListenerTracker.js +8 -8
  17. package/lib/component/context/ChartContext.js +12 -1
  18. package/lib/component/context/ShareDataContext.d.ts +1 -1
  19. package/lib/component/context/ShareDataContext.js +2 -4
  20. package/lib/component/context/ToasterContext.d.ts +1 -0
  21. package/lib/component/context/ToasterContext.js +12 -3
  22. package/lib/component/elements/ActionsButtonsPopover.js +1 -3
  23. package/lib/component/elements/Alert.d.ts +20 -0
  24. package/lib/component/elements/Alert.js +80 -0
  25. package/lib/component/elements/ContextMenuBluePrint.d.ts +7 -2
  26. package/lib/component/elements/ContextMenuBluePrint.js +9 -3
  27. package/lib/component/elements/DialogManager.d.ts +34 -0
  28. package/lib/component/elements/DialogManager.js +96 -0
  29. package/lib/component/elements/DraggableDialog.d.ts +13 -0
  30. package/lib/component/elements/DraggableDialog.js +156 -0
  31. package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +1 -1
  32. package/lib/component/elements/ReactTable/ReactTableFlexLayout.d.ts +0 -3
  33. package/lib/component/elements/ReactTable/ReactTableFlexLayout.js +1 -1
  34. package/lib/component/elements/Select2.d.ts +12 -7
  35. package/lib/component/elements/Select2.js +5 -4
  36. package/lib/component/elements/Select2Controller.d.ts +2 -2
  37. package/lib/component/elements/Select2Controller.js +5 -5
  38. package/lib/component/elements/TabTitle.d.ts +9 -0
  39. package/lib/component/elements/TabTitle.js +18 -0
  40. package/lib/component/elements/ToolbarPopoverItem.d.ts +7 -6
  41. package/lib/component/elements/ToolbarPopoverItem.js +13 -5
  42. package/lib/component/elements/print/PrintContent.d.ts +17 -0
  43. package/lib/component/elements/print/PrintContent.js +281 -0
  44. package/lib/component/elements/print/PrintProvider.d.ts +12 -0
  45. package/lib/component/elements/print/PrintProvider.js +28 -0
  46. package/lib/component/elements/print/index.d.ts +2 -0
  47. package/lib/component/elements/print/index.js +2 -0
  48. package/lib/component/header/ApodizationOptionsPanel.js +2 -2
  49. package/lib/component/header/BaseLineCorrectionPanel.js +3 -0
  50. package/lib/component/hooks/useSaveSettings.d.ts +1 -1
  51. package/lib/component/hooks/useSaveSettings.js +18 -22
  52. package/lib/component/hooks/useToggleSpectraVisibility.d.ts +14 -9
  53. package/lib/component/hooks/useToggleSpectraVisibility.js +45 -16
  54. package/lib/component/loader/DropZone.js +3 -67
  55. package/lib/component/loader/useLoadFiles.d.ts +1 -0
  56. package/lib/component/loader/useLoadFiles.js +78 -0
  57. package/lib/component/main/InnerNMRium.d.ts +4 -3
  58. package/lib/component/main/InnerNMRium.js +5 -10
  59. package/lib/component/main/InnerNMRiumContents.d.ts +3 -2
  60. package/lib/component/main/InnerNMRiumContents.js +38 -29
  61. package/lib/component/main/NMRium.d.ts +2 -5
  62. package/lib/component/main/NMRium.js +1 -1
  63. package/lib/component/main/NMRiumRefAPI.d.ts +7 -0
  64. package/lib/component/main/NMRiumRefAPI.js +12 -0
  65. package/lib/component/main/NMRiumViewer.d.ts +10 -0
  66. package/lib/component/main/NMRiumViewer.js +35 -0
  67. package/lib/component/main/index.d.ts +1 -0
  68. package/lib/component/modal/CopyClipboardModal.d.ts +3 -2
  69. package/lib/component/modal/CopyClipboardModal.js +18 -32
  70. package/lib/component/modal/EditPeakShapeModal.d.ts +4 -6
  71. package/lib/component/modal/EditPeakShapeModal.js +45 -33
  72. package/lib/component/modal/ExportAsJcampModal.d.ts +6 -3
  73. package/lib/component/modal/ExportAsJcampModal.js +69 -35
  74. package/lib/component/modal/ImportPublicationStringModal.js +1 -1
  75. package/lib/component/modal/editRange/EditRangeModal.d.ts +2 -10
  76. package/lib/component/modal/editRange/EditRangeModal.js +26 -54
  77. package/lib/component/modal/editZone/EditZoneModal.d.ts +3 -8
  78. package/lib/component/modal/editZone/EditZoneModal.js +74 -91
  79. package/lib/component/modal/editZone/SignalsForm.d.ts +1 -2
  80. package/lib/component/modal/editZone/SignalsForm.js +33 -50
  81. package/lib/component/modal/editZone/validation/isDefaultPathLength.d.ts +1 -2
  82. package/lib/component/modal/editZone/validation/isDefaultPathLength.js +3 -5
  83. package/lib/component/modal/setting/GeneralSettings.js +4 -2
  84. package/lib/component/modal/setting/settings-tabs/ExternalAPIsTabContent.d.ts +1 -0
  85. package/lib/component/modal/setting/settings-tabs/ExternalAPIsTabContent.js +89 -0
  86. package/lib/component/modal/setting/settingsValidation.js +15 -1
  87. package/lib/component/panels/IntegralsPanel/IntegralPanel.js +8 -5
  88. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +5 -1
  89. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +13 -3
  90. package/lib/component/panels/Panels.js +2 -2
  91. package/lib/component/panels/PeaksPanel/PeaksPanel.js +8 -5
  92. package/lib/component/panels/PeaksPanel/PeaksTable.js +7 -13
  93. package/lib/component/panels/RangesPanel/RangesHeader.js +52 -15
  94. package/lib/component/panels/RangesPanel/RangesTable.js +6 -3
  95. package/lib/component/panels/RangesPanel/TableColumns/ActionsColumn.js +21 -3
  96. package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.d.ts +6 -5
  97. package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.js +41 -64
  98. package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +13 -6
  99. package/lib/component/panels/SpectraPanel/SpectraTable.js +63 -21
  100. package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnField.d.ts +1 -2
  101. package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnField.js +33 -41
  102. package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnHeader.js +68 -53
  103. package/lib/component/panels/SummaryPanel/CorrelationTable/CorrelationTableRow.js +70 -58
  104. package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.d.ts +13 -8
  105. package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.js +17 -81
  106. package/lib/component/panels/SummaryPanel/SummaryPanel.d.ts +3 -0
  107. package/lib/component/panels/SummaryPanel/SummaryPanel.js +8 -1
  108. package/lib/component/panels/SummaryPanel/utilities/Utilities.js +1 -1
  109. package/lib/component/panels/ZonesPanel/TableColumns/ActionsColumn.js +62 -43
  110. package/lib/component/panels/ZonesPanel/ZonesPanel.js +16 -8
  111. package/lib/component/panels/ZonesPanel/ZonesTable.js +4 -1
  112. package/lib/component/panels/ZonesPanel/hooks/useZoneActions.d.ts +5 -0
  113. package/lib/component/panels/ZonesPanel/hooks/useZoneActions.js +40 -0
  114. package/lib/component/panels/databasePanel/DatabasePanel.js +7 -8
  115. package/lib/component/panels/filtersPanel/FilterPanel.js +9 -6
  116. package/lib/component/panels/filtersPanel/FiltersTable.js +12 -10
  117. package/lib/component/panels/header/DefaultPanelHeader.d.ts +1 -0
  118. package/lib/component/panels/header/DefaultPanelHeader.js +2 -2
  119. package/lib/component/panels/multipleAnalysisPanel/AlignSpectra.js +10 -12
  120. package/lib/component/reducer/IgnoreActions.js +1 -0
  121. package/lib/component/reducer/Reducer.js +2 -4
  122. package/lib/component/reducer/actions/DatabaseActions.d.ts +15 -13
  123. package/lib/component/reducer/actions/DatabaseActions.js +52 -34
  124. package/lib/component/reducer/actions/DomainActions.d.ts +2 -2
  125. package/lib/component/reducer/actions/FiltersActions.js +9 -4
  126. package/lib/component/reducer/actions/RangesActions.d.ts +1 -0
  127. package/lib/component/reducer/actions/RangesActions.js +9 -4
  128. package/lib/component/reducer/actions/SpectraActions.d.ts +2 -1
  129. package/lib/component/reducer/actions/SpectraActions.js +53 -43
  130. package/lib/component/reducer/actions/ToolsActions.js +0 -17
  131. package/lib/component/reducer/helper/removeSpectrumRelatedObjectsById.d.ts +3 -0
  132. package/lib/component/reducer/helper/removeSpectrumRelatedObjectsById.js +16 -0
  133. package/lib/component/reducer/preferences/actions/changePrintPageSettings.d.ts +3 -0
  134. package/lib/component/reducer/preferences/actions/changePrintPageSettings.js +6 -0
  135. package/lib/component/reducer/preferences/actions/matrixGeneration.d.ts +0 -4
  136. package/lib/component/reducer/preferences/actions/matrixGeneration.js +1 -2
  137. package/lib/component/reducer/preferences/preferencesReducer.d.ts +3 -2
  138. package/lib/component/reducer/preferences/preferencesReducer.js +4 -1
  139. package/lib/component/toolbar/ToolBar.js +33 -14
  140. package/lib/component/toolbar/ToolTypes.d.ts +1 -1
  141. package/lib/component/toolbar/ToolTypes.js +0 -14
  142. package/lib/component/workspaces/workspaceDefaultProperties.js +2 -0
  143. package/lib/data/SpectraManager.d.ts +7 -10
  144. package/lib/data/SpectraManager.js +51 -30
  145. package/lib/data/data1d/Spectrum1D/SumManager.d.ts +0 -1
  146. package/lib/data/data1d/Spectrum1D/SumManager.js +2 -10
  147. package/lib/data/data1d/Spectrum1D/get1DColor.d.ts +1 -1
  148. package/lib/data/data1d/Spectrum1D/index.d.ts +1 -1
  149. package/lib/data/data1d/Spectrum1D/index.js +1 -1
  150. package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +10 -16
  151. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +1 -7
  152. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +2 -1
  153. package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +10 -16
  154. package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +10 -16
  155. package/lib/data/data1d/Spectrum1D/ranges/resurrectSpectrum.d.ts +13 -0
  156. package/lib/data/data1d/Spectrum1D/ranges/resurrectSpectrum.js +65 -0
  157. package/lib/data/molecules/MoleculeManager.d.ts +1 -1
  158. package/lib/data/molecules/MoleculeManager.js +21 -49
  159. package/lib/data/utilities/getCustomColor.d.ts +1 -1
  160. package/lib/data/utilities/removeByPaths.d.ts +3 -0
  161. package/lib/data/utilities/removeByPaths.js +33 -0
  162. package/lib/versionInfo.js +1 -1
  163. package/package.json +34 -34
  164. package/lib/component/1d/tool/VerticalIndicator.d.ts +0 -2
  165. package/lib/component/elements/ContextMenu.d.ts +0 -9
  166. package/lib/component/elements/ContextMenu.js +0 -116
  167. package/lib/component/elements/popup/Modal/ConfirmDialog.d.ts +0 -21
  168. package/lib/component/elements/popup/Modal/ConfirmDialog.js +0 -68
  169. package/lib/component/elements/popup/Modal/Context.d.ts +0 -2
  170. package/lib/component/elements/popup/Modal/Context.js +0 -6
  171. package/lib/component/elements/popup/Modal/Modal.d.ts +0 -9
  172. package/lib/component/elements/popup/Modal/Modal.js +0 -42
  173. package/lib/component/elements/popup/Modal/ModalContent.d.ts +0 -6
  174. package/lib/component/elements/popup/Modal/ModalContent.js +0 -27
  175. package/lib/component/elements/popup/Modal/Provider.d.ts +0 -11
  176. package/lib/component/elements/popup/Modal/Provider.js +0 -172
  177. package/lib/component/elements/popup/Modal/index.d.ts +0 -4
  178. package/lib/component/elements/popup/Modal/index.js +0 -4
  179. package/lib/component/elements/popup/Transition.d.ts +0 -14
  180. package/lib/component/elements/popup/Transition.js +0 -35
  181. package/lib/component/elements/popup/Wrapper.d.ts +0 -8
  182. package/lib/component/elements/popup/Wrapper.js +0 -83
  183. package/lib/component/elements/popup/options.d.ts +0 -28
  184. package/lib/component/elements/popup/options.js +0 -25
  185. package/lib/component/elements/popup/utility.d.ts +0 -2
  186. package/lib/component/elements/popup/utility.js +0 -13
  187. package/lib/component/modal/editZone/EditPathLengthFormik.d.ts +0 -5
  188. package/lib/component/modal/editZone/EditPathLengthFormik.js +0 -67
  189. package/lib/component/modal/editZone/SignalFormTab.d.ts +0 -5
  190. package/lib/component/modal/editZone/SignalFormTab.js +0 -6
  191. package/lib/component/modal/editZone/validation/EditZoneValidation.d.ts +0 -14
  192. package/lib/component/modal/editZone/validation/EditZoneValidation.js +0 -14
  193. package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.d.ts +0 -11
  194. package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.js +0 -29
@@ -11,18 +11,12 @@ export declare function initiateRanges(inputSpectrum: Partial<Spectrum1D>, spect
11
11
  delta: number;
12
12
  multiplicity: string;
13
13
  js: import("nmr-processing").Jcoupling[];
14
- atoms?: number[];
15
- assignment?: string;
16
- diaIDs?: string[];
17
- nbAtoms?: number;
18
- integration?: number;
19
- statistic?: {
20
- mean: number;
21
- sd: number;
22
- min: number;
23
- max: number;
24
- nb: number;
25
- };
14
+ atoms?: number[] | undefined;
15
+ assignment?: string | undefined;
16
+ diaIDs?: string[] | undefined;
17
+ nbAtoms?: number | undefined;
18
+ integration?: number | undefined;
19
+ statistics?: import("nmr-processing").NMRSignalStatistics | undefined;
26
20
  kind: string;
27
21
  id: string;
28
22
  peaks: {
@@ -43,9 +37,9 @@ export declare function initiateRanges(inputSpectrum: Partial<Spectrum1D>, spect
43
37
  kind: string;
44
38
  integration: number;
45
39
  nbAtoms?: number;
46
- multiplicity?: string;
47
- assignment?: string;
48
- diaIDs?: string[];
49
- pubIntegral?: number;
40
+ multiplicity?: string | undefined;
41
+ assignment?: string | undefined;
42
+ diaIDs?: string[] | undefined;
43
+ pubIntegral?: number | undefined;
50
44
  }[];
51
45
  };
@@ -13,18 +13,12 @@ export declare function resizeRange(spectrum: Spectrum1D, options: {
13
13
  delta: number;
14
14
  multiplicity: string;
15
15
  js: import("nmr-processing").Jcoupling[];
16
- atoms?: number[];
17
- assignment?: string;
18
- diaIDs?: string[];
19
- nbAtoms?: number;
20
- integration?: number;
21
- statistic?: {
22
- mean: number;
23
- sd: number;
24
- min: number;
25
- max: number;
26
- nb: number;
27
- };
16
+ atoms?: number[] | undefined;
17
+ assignment?: string | undefined;
18
+ diaIDs?: string[] | undefined;
19
+ nbAtoms?: number | undefined;
20
+ integration?: number | undefined;
21
+ statistics?: import("nmr-processing").NMRSignalStatistics | undefined;
28
22
  kind: string;
29
23
  id: string;
30
24
  peaks: {
@@ -45,8 +39,8 @@ export declare function resizeRange(spectrum: Spectrum1D, options: {
45
39
  kind: string;
46
40
  integration: number;
47
41
  nbAtoms?: number;
48
- multiplicity?: string;
49
- assignment?: string;
50
- diaIDs?: string[];
51
- pubIntegral?: number;
42
+ multiplicity?: string | undefined;
43
+ assignment?: string | undefined;
44
+ diaIDs?: string[] | undefined;
45
+ pubIntegral?: number | undefined;
52
46
  };
@@ -0,0 +1,13 @@
1
+ import { Spectrum1D } from 'nmr-load-save';
2
+ import { Info1D, NMRRange, NMRSignal1D } from 'nmr-processing';
3
+ import { UsedColors } from '../../../../types/UsedColors';
4
+ interface ResurrectSpectrumOptions {
5
+ info: Partial<Info1D>;
6
+ usedColors: UsedColors;
7
+ from?: number;
8
+ to?: number;
9
+ spectrumID?: string;
10
+ }
11
+ declare function resurrectSpectrumFromRanges(ranges: NMRRange[], options: ResurrectSpectrumOptions): Spectrum1D | undefined;
12
+ declare function resurrectSpectrumFromSignals(signals: NMRSignal1D[], options: ResurrectSpectrumOptions): Spectrum1D | undefined;
13
+ export { resurrectSpectrumFromRanges, resurrectSpectrumFromSignals };
@@ -0,0 +1,65 @@
1
+ import { rangesToXY, signalsToXY, } from 'nmr-processing';
2
+ import { initiateDatum1D } from '../initiateDatum1D';
3
+ function resurrectSpectrumFromRanges(ranges, options) {
4
+ const { spectrumID, usedColors, from, to, info } = options;
5
+ const { nucleus, solvent, name = null, baseFrequency = 400, originFrequency = 400, numberOfPoints = 2 ** 17, } = info;
6
+ try {
7
+ const { x, y } = rangesToXY(ranges, {
8
+ nucleus,
9
+ frequency: baseFrequency,
10
+ nbPoints: numberOfPoints,
11
+ from,
12
+ to,
13
+ });
14
+ const datum = initiateDatum1D({
15
+ id: spectrumID,
16
+ data: { x, im: null, re: y },
17
+ info: {
18
+ numberOfPoints,
19
+ nucleus,
20
+ originFrequency,
21
+ baseFrequency,
22
+ pulseSequence: '',
23
+ solvent,
24
+ isFt: true,
25
+ name,
26
+ },
27
+ ranges: { values: ranges, options: { sum: 100 } },
28
+ }, { usedColors });
29
+ return datum;
30
+ }
31
+ catch (error) {
32
+ reportError(error);
33
+ }
34
+ }
35
+ function resurrectSpectrumFromSignals(signals, options) {
36
+ const { spectrumID, usedColors, from, to, info } = options;
37
+ const { nucleus, solvent, name = null, baseFrequency = 400, originFrequency = 400, numberOfPoints: nbPoints = 2 ** 17, } = info;
38
+ try {
39
+ const { x, y } = signalsToXY(signals, {
40
+ frequency: baseFrequency,
41
+ nbPoints,
42
+ from,
43
+ to,
44
+ });
45
+ const datum = initiateDatum1D({
46
+ id: spectrumID,
47
+ data: { x, im: null, re: y },
48
+ info: {
49
+ nucleus,
50
+ originFrequency,
51
+ baseFrequency,
52
+ pulseSequence: '',
53
+ solvent,
54
+ isFt: true,
55
+ name,
56
+ },
57
+ ranges: { values: signals, options: { sum: 100 } },
58
+ }, { usedColors });
59
+ return datum;
60
+ }
61
+ catch (error) {
62
+ reportError(error);
63
+ }
64
+ }
65
+ export { resurrectSpectrumFromRanges, resurrectSpectrumFromSignals };
@@ -5,4 +5,4 @@ export declare function setMolfile(molecules: StateMoleculeExtended[], currentMo
5
5
  export declare function extractNumber(value: string): string | null;
6
6
  export declare function extractLabelsNumbers(molecules: Array<Pick<StateMolecule, 'label'>>): number[];
7
7
  export declare function getLabelNumber(reserveNumbers: number[]): number;
8
- export declare function getMolecules(text: string): Promise<import("nmr-load-save").StateMolecule[]>;
8
+ export declare function getMolecules(text: string): import("nmr-load-save").StateMolecule[];
@@ -1,5 +1,4 @@
1
- import { fileCollectionFromFiles } from 'filelist-utils';
2
- import { read } from 'nmr-load-save';
1
+ import { readSDF, readSMILES } from 'nmr-load-save';
3
2
  import { Molecule as OCLMolecule } from 'openchemlib/full';
4
3
  import { initMolecule } from './Molecule';
5
4
  export function fromJSON(mols, reservedMolecules = []) {
@@ -7,14 +6,11 @@ export function fromJSON(mols, reservedMolecules = []) {
7
6
  const molecules = [];
8
7
  for (const mol of mols) {
9
8
  const molecule = OCLMolecule.fromMolfile(mol.molfile);
10
- const fragments = molecule.getFragments();
11
- for (const fragment of fragments) {
12
- molecules.push(initMolecule({
13
- molfile: fragment.toMolfileV3(),
14
- label: mol.label || `P${getLabelNumber(reservedNumbers)}`,
15
- id: mol.id,
16
- }));
17
- }
9
+ molecules.push(initMolecule({
10
+ molfile: molecule.toMolfileV3(),
11
+ label: mol.label || `P${getLabelNumber(reservedNumbers)}`,
12
+ id: mol.id,
13
+ }));
18
14
  }
19
15
  return molecules;
20
16
  }
@@ -23,42 +19,23 @@ export function addMolfile(molecules, molfile) {
23
19
  // try to parse molfile
24
20
  // this will throw if the molecule can not be parsed !
25
21
  const molecule = OCLMolecule.fromMolfile(molfile);
26
- const fragments = molecule.getFragments();
27
- for (const fragment of fragments) {
28
- molecules.push(initMolecule({
29
- molfile: fragment.toMolfileV3(),
30
- label: `P${getLabelNumber(reservedNumbers)}`,
31
- }));
32
- }
33
- // we will split if we have many fragments
22
+ molecules.push(initMolecule({
23
+ molfile: molecule.toMolfileV3(),
24
+ label: `P${getLabelNumber(reservedNumbers)}`,
25
+ }));
34
26
  }
35
27
  export function setMolfile(molecules, currentMolecule) {
36
28
  const { molfile, id, label } = currentMolecule;
37
- const reservedNumbers = extractLabelsNumbers(molecules);
38
29
  // try to parse molfile
39
30
  // this will throw if the molecule can not be parsed !
40
31
  const molecule = OCLMolecule.fromMolfile(molfile);
41
- const fragments = molecule.getFragments();
42
- if (fragments.length > 1) {
43
- molecules = molecules.filter((m) => m.id !== id);
44
- for (const fragment of fragments) {
45
- molecules.push(initMolecule({
46
- molfile: fragment.toMolfileV3(),
47
- label: `P${getLabelNumber(reservedNumbers)}`,
48
- }));
49
- }
50
- }
51
- else if (fragments.length === 1) {
52
- const fragment = fragments[0];
53
- const _mol = initMolecule({
54
- molfile: fragment.toMolfileV3(),
55
- id,
56
- label,
57
- });
58
- const molIndex = molecules.findIndex((m) => m.id === id);
59
- molecules.splice(molIndex, 1, _mol);
60
- }
61
- // we will split if we have many fragments
32
+ const _mol = initMolecule({
33
+ molfile: molecule.toMolfileV3(),
34
+ id,
35
+ label,
36
+ });
37
+ const molIndex = molecules.findIndex((m) => m.id === id);
38
+ molecules.splice(molIndex, 1, _mol);
62
39
  }
63
40
  export function extractNumber(value) {
64
41
  return /(?<number>\d+)/.exec(value)?.groups?.number || null;
@@ -82,15 +59,10 @@ export function getLabelNumber(reserveNumbers) {
82
59
  }
83
60
  return 1;
84
61
  }
85
- export async function getMolecules(text) {
86
- let extension = 'smi';
62
+ export function getMolecules(text) {
63
+ // parse SDF
87
64
  if (/v[23]000/i.test(text)) {
88
- extension = 'sdf';
65
+ return readSDF(text);
89
66
  }
90
- const file = new File([text], `file.${extension}`, {
91
- type: 'text/plain',
92
- });
93
- const collection = await fileCollectionFromFiles([file]);
94
- const { nmriumState: { data }, } = await read(collection);
95
- return data?.molecules || [];
67
+ return readSMILES(text);
96
68
  }
@@ -1,4 +1,4 @@
1
1
  import { Color2D, Spectrum1D, Spectrum2D, SpectrumOneDimensionColor, SpectrumTwoDimensionsColor } from 'nmr-load-save';
2
2
  type ReturnColor<ColorType> = ColorType extends SpectrumOneDimensionColor ? string : Color2D;
3
- export declare function getCustomColor<SpectrumType extends Spectrum1D | Spectrum2D, ColorType extends SpectrumOneDimensionColor | SpectrumTwoDimensionsColor>(spectrum: SpectrumType, colors?: ColorType[]): ReturnColor<ColorType> | null;
3
+ export declare function getCustomColor<ColorType extends SpectrumOneDimensionColor | SpectrumTwoDimensionsColor>(spectrum: Spectrum1D | Spectrum2D, colors?: ColorType[]): ReturnColor<ColorType> | null;
4
4
  export {};
@@ -0,0 +1,3 @@
1
+ type Path = [string, string | null];
2
+ export declare function removeByPaths(obj: any, pathsWithKeys: Path[], matchValue: string | number): void;
3
+ export {};
@@ -0,0 +1,33 @@
1
+ export function removeByPaths(obj, pathsWithKeys, matchValue) {
2
+ for (const [path, key] of pathsWithKeys) {
3
+ remove(obj, path, key, matchValue);
4
+ }
5
+ }
6
+ function remove(obj, path, key, value) {
7
+ const pathParts = path.split('.');
8
+ let current = obj;
9
+ for (let i = 0; i < pathParts.length - 1; i++) {
10
+ current = current[pathParts[i]];
11
+ if (current === undefined || current === null) {
12
+ // eslint-disable-next-line no-console
13
+ console.error('Path not found:', path);
14
+ return;
15
+ }
16
+ }
17
+ const finalKey = pathParts.at(-1);
18
+ if (!finalKey)
19
+ return;
20
+ const target = current[finalKey];
21
+ if (Array.isArray(target)) {
22
+ if (target.length > 0 && typeof target[0] === 'object' && key) {
23
+ current[finalKey] = target.filter((item) => item[key] !== value);
24
+ }
25
+ }
26
+ else if (typeof target === 'object' && target !== null) {
27
+ // eslint-disable-next-line unicorn/no-lonely-if
28
+ if (Object.hasOwn(target, value)) {
29
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
30
+ delete target[value];
31
+ }
32
+ }
33
+ }
@@ -1 +1 @@
1
- export default { version: 'v0.58.0' };
1
+ export default { version: 'v0.60.0' };
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.58.0",
4
+ "version": "0.60.0",
5
5
  "license": "MIT",
6
6
  "module": "lib/component/main/index.js",
7
7
  "types": "lib/component/main/index.d.ts",
@@ -19,7 +19,7 @@
19
19
  "compile": "tsc --project tsconfig.esm.json",
20
20
  "copy-samples-toc": "cp src/demo/samples.json build/",
21
21
  "clean-lib": "rimraf lib",
22
- "dev": "vite --host localhost --port 3000 --strictPort --open",
22
+ "dev": "vite --host localhost --port 3000 --open",
23
23
  "eslint": "eslint . --cache",
24
24
  "eslint-fix": "npm run eslint -- --fix",
25
25
  "install:clean": "rm -rf node_modules/ && rm -rf package-lock.json && npm install && npm start",
@@ -46,7 +46,7 @@
46
46
  "url": "git+https://github.com/cheminfo/nmrium.git"
47
47
  },
48
48
  "volta": {
49
- "node": "20.15.0"
49
+ "node": "22.5.1"
50
50
  },
51
51
  "overrides": {
52
52
  "react": "$react",
@@ -57,22 +57,22 @@
57
57
  "react-dom": ">=18.0.0"
58
58
  },
59
59
  "dependencies": {
60
- "@blueprintjs/core": "^5.10.5",
61
- "@blueprintjs/icons": "^5.10.0",
62
- "@blueprintjs/select": "^5.2.1",
63
- "@emotion/react": "^11.11.4",
64
- "@emotion/styled": "^11.11.5",
60
+ "@blueprintjs/core": "^5.11.0",
61
+ "@blueprintjs/icons": "^5.11.0",
62
+ "@blueprintjs/select": "^5.2.2",
63
+ "@emotion/react": "^11.13.0",
64
+ "@emotion/styled": "^11.13.0",
65
65
  "@hookform/resolvers": "^3.9.0",
66
66
  "@lukeed/uuid": "^2.0.1",
67
67
  "cheminfo-font": "^1.13.0",
68
- "cheminfo-types": "^1.7.3",
68
+ "cheminfo-types": "^1.8.0",
69
69
  "clipboard-polyfill": "^4.1.0",
70
70
  "convert-to-jcamp": "^5.4.10",
71
71
  "d3": "^7.9.0",
72
72
  "eventemitter3": "^5.0.1",
73
73
  "fifo-logger": "^1.0.0",
74
74
  "file-saver": "^2.0.5",
75
- "filelist-utils": "^1.11.0",
75
+ "filelist-utils": "^1.11.1",
76
76
  "formik": "^2.4.6",
77
77
  "immer": "^10.1.1",
78
78
  "jszip": "^3.10.1",
@@ -86,71 +86,71 @@
86
86
  "ml-gsd": "^12.1.6",
87
87
  "ml-matrix": "^6.11.1",
88
88
  "ml-signal-processing": "^1.0.4",
89
- "ml-spectra-processing": "^14.5.1",
89
+ "ml-spectra-processing": "^14.5.3",
90
90
  "ml-stat": "^1.3.3",
91
91
  "ml-tree-similarity": "^2.2.0",
92
92
  "multiplet-analysis": "^2.1.2",
93
93
  "nmr-correlation": "^2.3.3",
94
- "nmr-load-save": "^0.34.2",
95
- "nmr-processing": "^12.7.1",
94
+ "nmr-load-save": "^0.37.1",
95
+ "nmr-processing": "^12.11.0",
96
96
  "nmredata": "^0.9.11",
97
97
  "numeral": "^2.0.6",
98
- "openchemlib": "^8.14.0",
99
- "openchemlib-utils": "^6.3.0",
98
+ "openchemlib": "^8.15.0",
99
+ "openchemlib-utils": "^6.4.1",
100
100
  "papaparse": "^5.4.1",
101
101
  "re-resizable": "6.9.17",
102
102
  "react-d3-utils": "^1.0.0",
103
103
  "react-dropzone": "^14.2.3",
104
104
  "react-error-boundary": "^4.0.13",
105
- "react-hook-form": "^7.52.1",
105
+ "react-hook-form": "^7.52.2",
106
106
  "react-icons": "^5.2.1",
107
107
  "react-inspector": "^6.0.2",
108
108
  "react-mf": "^2.0.3",
109
109
  "react-ocl": "^6.1.0",
110
110
  "react-ocl-nmr": "^3.0.2",
111
- "react-plot": "^1.4.2",
112
- "react-rnd": "^10.4.11",
113
- "react-science": "^4.1.2",
111
+ "react-plot": "^2.0.0",
112
+ "react-rnd": "^10.4.12",
113
+ "react-science": "^6.0.0",
114
114
  "react-table": "^7.8.0",
115
115
  "react-transition-group": "^4.4.5",
116
- "react-use": "^17.5.0",
116
+ "react-use": "^17.5.1",
117
117
  "smart-array-filter": "^4.0.2",
118
118
  "yup": "^1.4.0"
119
119
  },
120
120
  "devDependencies": {
121
- "@babel/plugin-transform-modules-commonjs": "^7.24.7",
121
+ "@babel/plugin-transform-modules-commonjs": "^7.24.8",
122
122
  "@babel/preset-react": "^7.24.7",
123
123
  "@babel/preset-typescript": "^7.24.7",
124
- "@playwright/test": "^1.45.1",
124
+ "@playwright/test": "^1.46.0",
125
125
  "@simbathesailor/use-what-changed": "^2.0.0",
126
126
  "@types/d3": "^7.4.3",
127
- "@types/lodash": "^4.17.6",
128
- "@types/node": "^20.14.10",
127
+ "@types/lodash": "^4.17.7",
128
+ "@types/node": "^22.1.0",
129
129
  "@types/papaparse": "^5.3.14",
130
130
  "@types/react": "^18.3.3",
131
131
  "@types/react-dom": "^18.3.0",
132
132
  "@types/react-table": "^7.7.20",
133
133
  "@vitejs/plugin-react-swc": "^3.7.0",
134
- "@vitest/coverage-v8": "^2.0.2",
134
+ "@vitest/coverage-v8": "^2.0.5",
135
135
  "cross-env": "^7.0.3",
136
- "cspell": "^8.10.4",
136
+ "cspell": "^8.13.2",
137
137
  "eslint": "^8.57.0",
138
- "eslint-config-cheminfo-react": "^12.0.0",
139
- "eslint-config-cheminfo-typescript": "^13.0.0",
138
+ "eslint-config-cheminfo-react": "^13.0.0",
139
+ "eslint-config-cheminfo-typescript": "^15.0.0",
140
140
  "modern-normalize": "^2.0.0",
141
141
  "postcss-styled-syntax": "^0.6.4",
142
- "prettier": "^3.3.2",
142
+ "prettier": "^3.3.3",
143
143
  "rc-menu": "^9.14.1",
144
144
  "react": "^18.3.1",
145
145
  "react-dom": "^18.3.1",
146
- "react-router-dom": "^6.24.1",
146
+ "react-router-dom": "^6.26.0",
147
147
  "rimraf": "^6.0.1",
148
148
  "rollup-plugin-analyzer": "^4.0.0",
149
149
  "serve": "^14.2.3",
150
- "stylelint": "^16.6.1",
150
+ "stylelint": "^16.8.1",
151
151
  "stylelint-config-standard": "^36.0.1",
152
- "typescript": "^5.5.3",
153
- "vite": "^5.3.3",
154
- "vitest": "^2.0.2"
152
+ "typescript": "^5.5.4",
153
+ "vite": "^5.4.0",
154
+ "vitest": "^2.0.5"
155
155
  }
156
156
  }
@@ -1,2 +0,0 @@
1
- declare function VerticalIndicator(): import("react/jsx-runtime").JSX.Element | null;
2
- export default VerticalIndicator;
@@ -1,9 +0,0 @@
1
- interface ContextMenuItem<T> {
2
- onClick: (data?: T) => void;
3
- label: string;
4
- }
5
- export interface ContextMenuProps<T = unknown> {
6
- context: Array<ContextMenuItem<T>>;
7
- }
8
- declare const _default: import("react").ForwardRefExoticComponent<ContextMenuProps<unknown> & import("react").RefAttributes<unknown>>;
9
- export default _default;
@@ -1,116 +0,0 @@
1
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
- /** @jsxImportSource @emotion/react */
3
- import { css } from '@emotion/react';
4
- import { useState, useImperativeHandle, useCallback, useRef, useEffect, forwardRef, } from 'react';
5
- import { createPortal } from 'react-dom';
6
- import { useGlobal } from '../context/GlobalContext';
7
- const styles = css `
8
- box-shadow: 0 0 10px rgb(0 0 0 / 25%);
9
- margin: 0;
10
- border-radius: 2px;
11
- display: flex;
12
- flex-direction: column;
13
- position: fixed;
14
- z-index: 99999;
15
- padding: 2px;
16
- background-color: white;
17
- width: 150px;
18
- pointer-events: all;
19
-
20
- button {
21
- background-color: transparent;
22
- border: none;
23
- border-bottom: 0.55px solid #f0f0f0;
24
- font-size: 11px;
25
- padding: 5px;
26
- text-align: left;
27
- outline: none;
28
- }
29
-
30
- button:hover {
31
- background-color: #fafafa;
32
- outline: none;
33
- }
34
-
35
- button:active {
36
- background-color: #eaeaea;
37
- outline: none;
38
- }
39
-
40
- button:last-of-type {
41
- border: none;
42
- }
43
- `;
44
- // TODO: remove this hacky ref usage.
45
- function ContextMenu({ context }, ref) {
46
- const [position, setPosition] = useState({
47
- left: 0,
48
- top: 0,
49
- });
50
- const { rootRef, elementsWrapperRef } = useGlobal();
51
- const [data, setData] = useState();
52
- const [isVisible, show] = useState();
53
- const [sourceElement, setSourceElement] = useState(null);
54
- const root = useRef();
55
- useEffect(() => {
56
- root.current = document.createElement('div');
57
- if (elementsWrapperRef) {
58
- elementsWrapperRef.append(root.current);
59
- }
60
- return () => {
61
- if (root.current && elementsWrapperRef) {
62
- root.current.remove();
63
- }
64
- };
65
- }, [elementsWrapperRef]);
66
- const contextMenuHandler = (event) => {
67
- event.preventDefault();
68
- setSourceElement(event.target.parentElement);
69
- show(true);
70
- const clickX = event.clientX;
71
- const clickY = event.clientY;
72
- const screenW = window.innerWidth;
73
- const screenH = window.innerHeight;
74
- const rootW = 150;
75
- const rootH = 0;
76
- const right = screenW - clickX > rootW;
77
- const bottom = screenH - clickY <= rootH;
78
- const left = right ? `${clickX + 5}px` : `${clickX - rootW - 5}px`;
79
- const top = bottom ? `${clickY - rootH - 5}px` : `${clickY + 5}px`;
80
- setPosition({ left, top });
81
- };
82
- useImperativeHandle(ref, () => ({
83
- handleContextMenu: (e, _data) => {
84
- setData(_data);
85
- contextMenuHandler(e);
86
- },
87
- }));
88
- const clickHandler = useCallback((event, click) => {
89
- event.preventDefault();
90
- click(data);
91
- show(false);
92
- }, [data]);
93
- useEffect(() => {
94
- const _handleGlobalClick = (event) => {
95
- const wasOutside = sourceElement &&
96
- event.target.parentElement &&
97
- !event.target.parentElement.isSameNode(sourceElement);
98
- if (wasOutside && isVisible)
99
- show(false);
100
- };
101
- if (rootRef) {
102
- rootRef.addEventListener('click', _handleGlobalClick);
103
- }
104
- return () => {
105
- if (rootRef) {
106
- rootRef.removeEventListener('click', _handleGlobalClick);
107
- }
108
- };
109
- }, [isVisible, ref, rootRef, sourceElement]);
110
- if (!isVisible) {
111
- return null;
112
- }
113
- return (root.current &&
114
- createPortal(context && (_jsx("div", { ref: ref, css: [styles, position], children: context.map((c, index) => (_jsx("button", { type: "button", onClick: (e) => clickHandler(e, c.onClick), children: c.label }, index))) })), root.current));
115
- }
116
- export default forwardRef(ContextMenu);
@@ -1,21 +0,0 @@
1
- import { CSSProperties, ReactNode } from 'react';
2
- interface AlertButtonOptions {
3
- handler: (e: React.MouseEvent) => void;
4
- text: string;
5
- style?: CSSProperties;
6
- preventClose?: boolean;
7
- }
8
- interface ConfirmationDialogProps {
9
- style?: CSSProperties;
10
- buttons: AlertButtonOptions[];
11
- onClose: () => void;
12
- message: ReactNode;
13
- render?: (data: {
14
- message: ReactNode;
15
- className: string;
16
- }) => ReactNode;
17
- id?: string;
18
- disableDefaultStyle?: boolean;
19
- }
20
- declare function ConfirmationDialog({ style, buttons, onClose, message, render, id, disableDefaultStyle, }: ConfirmationDialogProps): import("@emotion/react/jsx-runtime").JSX.Element;
21
- export default ConfirmationDialog;