nmrium 0.46.0 → 0.47.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 (65) hide show
  1. package/lib/component/1d/Chart1D.js +3 -1
  2. package/lib/component/1d/Viewer1D.js +4 -21
  3. package/lib/component/1d/integral/Integration.js +2 -1
  4. package/lib/component/1d/ranges/Range.js +3 -1
  5. package/lib/component/2d/1d-tracer/Top1DChart.js +1 -1
  6. package/lib/component/2d/zones/Signal.js +1 -1
  7. package/lib/component/2d/zones/Zone.js +1 -1
  8. package/lib/component/elements/Header.js +1 -1
  9. package/lib/component/elements/formik/FormikColorPickerDropdown.d.ts +6 -0
  10. package/lib/component/elements/formik/FormikColorPickerDropdown.js +14 -0
  11. package/lib/component/hooks/useActiveSpectrumIntegralsViewState.js +1 -0
  12. package/lib/component/hooks/useActiveSpectrumRangesViewState.js +1 -0
  13. package/lib/component/loader/DropZone.js +4 -2
  14. package/lib/component/modal/MultipletAnalysisModal.js +1 -1
  15. package/lib/component/modal/setting/GeneralSettings.js +2 -1
  16. package/lib/component/modal/setting/settings-tabs/FormattingTabContent.js +1 -1
  17. package/lib/component/modal/setting/settings-tabs/SpectraColorsTabContent.d.ts +2 -0
  18. package/lib/component/modal/setting/settings-tabs/SpectraColorsTabContent.js +131 -0
  19. package/lib/component/modal/setting/settingsValidation.js +12 -1
  20. package/lib/component/panels/IntegralsPanel/IntegralPanel.js +16 -2
  21. package/lib/component/panels/IntegralsPanel/IntegralsPreferences.js +2 -2
  22. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +1 -1
  23. package/lib/component/panels/RangesPanel/RangesHeader.js +10 -2
  24. package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/MoveLink.js +1 -1
  25. package/lib/component/panels/SummaryPanel/utilities/Utilities.js +1 -1
  26. package/lib/component/panels/databasePanel/DatabasePreferences.js +2 -2
  27. package/lib/component/panels/databasePanel/DatabaseSearchOptions.js +1 -1
  28. package/lib/component/panels/filtersPanel/FiltersTable.js +3 -2
  29. package/lib/component/reducer/Reducer.js +2 -0
  30. package/lib/component/reducer/actions/DatabaseActions.js +1 -1
  31. package/lib/component/reducer/actions/IntegralsActions.d.ts +8 -2
  32. package/lib/component/reducer/actions/IntegralsActions.js +10 -1
  33. package/lib/component/reducer/actions/LoadActions.d.ts +3 -1
  34. package/lib/component/reducer/actions/LoadActions.js +9 -4
  35. package/lib/component/reducer/actions/PeaksActions.js +1 -1
  36. package/lib/component/reducer/actions/SpectrumsActions.js +9 -3
  37. package/lib/component/toolbar/BasicToolBar.js +4 -4
  38. package/lib/component/toolbar/FunctionToolBar.js +2 -1
  39. package/lib/component/workspaces/exercise.js +1 -0
  40. package/lib/component/workspaces/prediction.js +5 -0
  41. package/lib/component/workspaces/simulation.js +5 -0
  42. package/lib/component/workspaces/workspaceDefaultProperties.js +41 -0
  43. package/lib/data/PredictionManager.js +1 -1
  44. package/lib/data/constants/Multiplets.js +1 -1
  45. package/lib/data/data1d/Spectrum1D/get1DColor.d.ts +9 -1
  46. package/lib/data/data1d/Spectrum1D/get1DColor.js +12 -4
  47. package/lib/data/data1d/Spectrum1D/initiateDatum1D.d.ts +2 -1
  48. package/lib/data/data1d/Spectrum1D/initiateDatum1D.js +2 -2
  49. package/lib/data/data1d/Spectrum1D/ranges/addRange.d.ts +1 -1
  50. package/lib/data/data1d/Spectrum1D/ranges/changeRange.js +6 -3
  51. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +7 -1
  52. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +32 -19
  53. package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.d.ts +10 -0
  54. package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.js +70 -0
  55. package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +1 -0
  56. package/lib/data/data2d/Spectrum2D/get2DColor.d.ts +9 -2
  57. package/lib/data/data2d/Spectrum2D/get2DColor.js +13 -5
  58. package/lib/data/data2d/Spectrum2D/initiateDatum2D.d.ts +7 -2
  59. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +3 -2
  60. package/lib/data/utilities/getCustomColor.d.ts +4 -0
  61. package/lib/data/utilities/getCustomColor.js +38 -0
  62. package/lib/versionInfo.js +1 -1
  63. package/package.json +11 -11
  64. package/lib/component/elements/formik/FormikColorInput.d.ts +0 -8
  65. package/lib/component/elements/formik/FormikColorInput.js +0 -15
@@ -1,13 +1,21 @@
1
1
  import { generate2DColor } from '../../utilities/generateColor';
2
- export function get2DColor(options, usedColors, regenerate = false) {
2
+ import { getCustomColor } from '../../utilities/getCustomColor';
3
+ export function get2DColor(spectrum, options) {
4
+ const { regenerate = false, usedColors = {}, colors } = options;
3
5
  let color = {};
4
- if (options?.display?.negativeColor === undefined ||
5
- options?.display?.positiveColor === undefined ||
6
+ if (spectrum?.display?.negativeColor === undefined ||
7
+ spectrum?.display?.positiveColor === undefined ||
6
8
  regenerate) {
7
- color = generate2DColor(options.info.experiment, usedColors['2d'] || []);
9
+ const customColor = getCustomColor(spectrum, colors);
10
+ if (customColor) {
11
+ color = customColor;
12
+ }
13
+ else {
14
+ color = generate2DColor(spectrum.info.experiment, usedColors?.['2d'] || []);
15
+ }
8
16
  }
9
17
  else {
10
- const { positiveColor = 'red', negativeColor = 'blue' } = options?.display || {};
18
+ const { positiveColor = 'red', negativeColor = 'blue' } = spectrum?.display || {};
11
19
  color = { positiveColor, negativeColor };
12
20
  }
13
21
  if (usedColors['2d']) {
@@ -1,2 +1,7 @@
1
- import { Spectrum2D } from 'nmr-load-save';
2
- export declare function initiateDatum2D(spectrum: any, usedColors?: {}): Spectrum2D;
1
+ import { Spectrum2D, SpectrumTwoDimensionsColor } from 'nmr-load-save';
2
+ import { UsedColors } from '../../../types/UsedColors';
3
+ export interface InitiateDatum2DOptions {
4
+ usedColors?: UsedColors;
5
+ colors?: SpectrumTwoDimensionsColor[];
6
+ }
7
+ export declare function initiateDatum2D(spectrum: any, options?: InitiateDatum2DOptions): Spectrum2D;
@@ -5,7 +5,8 @@ import { DEFAULT_CONTOURS_OPTIONS } from './contours';
5
5
  import { get2DColor } from './get2DColor';
6
6
  import { initiateZones } from './zones/initiateZones';
7
7
  const defaultMinMax = { z: [], minX: 0, minY: 0, maxX: 0, maxY: 0 };
8
- export function initiateDatum2D(spectrum, usedColors = {}) {
8
+ export function initiateDatum2D(spectrum, options = {}) {
9
+ const { usedColors, colors } = options;
9
10
  const datum = { ...spectrum };
10
11
  datum.id = spectrum.id || v4();
11
12
  datum.display = {
@@ -15,7 +16,7 @@ export function initiateDatum2D(spectrum, usedColors = {}) {
15
16
  contourOptions: DEFAULT_CONTOURS_OPTIONS,
16
17
  dimension: 2,
17
18
  ...spectrum.display,
18
- ...get2DColor(spectrum, usedColors),
19
+ ...get2DColor(spectrum, { usedColors, colors }),
19
20
  };
20
21
  datum.info = {
21
22
  nucleus: ['1H', '1H'],
@@ -0,0 +1,4 @@
1
+ import { Color2D, Spectrum1D, Spectrum2D, SpectrumOneDimensionColor, SpectrumTwoDimensionsColor } from 'nmr-load-save';
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;
4
+ export {};
@@ -0,0 +1,38 @@
1
+ import lodashGet from 'lodash/get';
2
+ function getValue(spectrum, jpath) {
3
+ const value = lodashGet(spectrum, jpath);
4
+ if (typeof value === 'string') {
5
+ return value;
6
+ }
7
+ if (['number', 'boolean'].includes(typeof value)) {
8
+ return String(value);
9
+ }
10
+ if (value) {
11
+ return JSON.stringify(value);
12
+ }
13
+ return value;
14
+ }
15
+ function isInstanceOfOneDimensionColor(item) {
16
+ return 'color' in item;
17
+ }
18
+ export function getCustomColor(spectrum, colors) {
19
+ if (!colors || colors.length === 0)
20
+ return null;
21
+ let color = null;
22
+ for (const item of colors) {
23
+ const value = getValue(spectrum, item.jpath);
24
+ if (value &&
25
+ item.value &&
26
+ value.toLocaleLowerCase().includes(item.value.toLocaleLowerCase())) {
27
+ if (isInstanceOfOneDimensionColor(item)) {
28
+ color = item.color;
29
+ }
30
+ else {
31
+ const { negativeColor, positiveColor } = item;
32
+ color = { negativeColor, positiveColor };
33
+ }
34
+ break;
35
+ }
36
+ }
37
+ return color;
38
+ }
@@ -1 +1 @@
1
- export default { version: 'v0.46.0' };
1
+ export default { version: 'v0.47.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.46.0",
4
+ "version": "0.47.0",
5
5
  "license": "MIT",
6
6
  "module": "lib/component/main/index.js",
7
7
  "types": "lib/component/main/index.d.ts",
@@ -86,8 +86,8 @@
86
86
  "ml-stat": "^1.3.3",
87
87
  "multiplet-analysis": "^2.1.2",
88
88
  "nmr-correlation": "^2.3.3",
89
- "nmr-load-save": "^0.23.11",
90
- "nmr-processing": "^11.6.1",
89
+ "nmr-load-save": "^0.24.0",
90
+ "nmr-processing": "^11.7.0",
91
91
  "nmredata": "^0.9.9",
92
92
  "numeral": "^2.0.6",
93
93
  "openchemlib": "^8.7.2",
@@ -96,7 +96,7 @@
96
96
  "re-resizable": "6.9.11",
97
97
  "react-d3-utils": "^1.0.0",
98
98
  "react-dropzone": "^14.2.3",
99
- "react-error-boundary": "^4.0.11",
99
+ "react-error-boundary": "^4.0.12",
100
100
  "react-icons": "^4.12.0",
101
101
  "react-inspector": "^6.0.2",
102
102
  "react-mf": "^2.0.2",
@@ -104,13 +104,13 @@
104
104
  "react-ocl-nmr": "^3.0.1",
105
105
  "react-plot": "^1.4.2",
106
106
  "react-rnd": "^10.4.1",
107
- "react-science": "^0.32.1",
107
+ "react-science": "^0.32.2",
108
108
  "react-slider": "^2.0.6",
109
109
  "react-table": "^7.8.0",
110
110
  "react-transition-group": "^4.4.5",
111
111
  "react-use": "^17.4.2",
112
112
  "smart-array-filter": "^4.0.2",
113
- "yup": "^1.3.2"
113
+ "yup": "^1.3.3"
114
114
  },
115
115
  "devDependencies": {
116
116
  "@babel/plugin-transform-modules-commonjs": "^7.23.3",
@@ -120,16 +120,16 @@
120
120
  "@simbathesailor/use-what-changed": "^2.0.0",
121
121
  "@types/d3": "^7.4.3",
122
122
  "@types/lodash": "^4.14.202",
123
- "@types/node": "^20.10.4",
123
+ "@types/node": "^20.10.5",
124
124
  "@types/papaparse": "^5.3.14",
125
125
  "@types/react": "^18.2.45",
126
- "@types/react-dom": "^18.2.17",
126
+ "@types/react-dom": "^18.2.18",
127
127
  "@types/react-table": "^7.7.18",
128
128
  "@vitejs/plugin-react-swc": "^3.5.0",
129
129
  "@vitest/coverage-v8": "^1.0.4",
130
130
  "cross-env": "^7.0.3",
131
131
  "cspell": "^8.1.3",
132
- "eslint": "^8.55.0",
132
+ "eslint": "^8.56.0",
133
133
  "eslint-config-cheminfo-react": "^10.1.0",
134
134
  "eslint-config-cheminfo-typescript": "^12.1.0",
135
135
  "modern-normalize": "^2.0.0",
@@ -145,7 +145,7 @@
145
145
  "stylelint": "^16.0.2",
146
146
  "stylelint-config-standard": "^35.0.0",
147
147
  "typescript": "^5.3.3",
148
- "vite": "^5.0.8",
148
+ "vite": "^5.0.10",
149
149
  "vitest": "^1.0.4"
150
150
  }
151
- }
151
+ }
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- import { ColorInputProps } from '../ColorInput';
3
- interface FormikColorPickerProps extends ColorInputProps {
4
- name: string;
5
- }
6
- declare function FormikColorPicker(props: FormikColorPickerProps): import("react/jsx-runtime").JSX.Element;
7
- declare const _default: import("react").MemoExoticComponent<typeof FormikColorPicker>;
8
- export default _default;
@@ -1,15 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useFormikContext } from 'formik';
3
- import lodashGet from 'lodash/get';
4
- import { useCallback, memo } from 'react';
5
- import ColorInput from '../ColorInput';
6
- function FormikColorPicker(props) {
7
- const { onColorChange = () => null, name, ...colorPickerProps } = props;
8
- const { values, setFieldValue } = useFormikContext();
9
- const colorChangeHandler = useCallback((color) => {
10
- onColorChange(color);
11
- void setFieldValue(name, color.hex);
12
- }, [name, onColorChange, setFieldValue]);
13
- return (_jsx(ColorInput, { ...colorPickerProps, name: name, onColorChange: colorChangeHandler, value: lodashGet(values, name) }));
14
- }
15
- export default memo(FormikColorPicker);