nmrium 0.56.0 → 0.57.1

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 (167) hide show
  1. package/lib/component/1d/ExclusionZoneAnnotation.d.ts +0 -1
  2. package/lib/component/1d/database/DatabaseSpectrum.js +14 -19
  3. package/lib/component/1d/jCouplingGraph/JGraphContext.d.ts +0 -1
  4. package/lib/component/1d/peaks/PeakAnnotationsSpreadMode.d.ts +0 -1
  5. package/lib/component/1d/peaks/PeakEditionManager.js +16 -10
  6. package/lib/component/1d/utilities/getDecimalsCount.js +1 -1
  7. package/lib/component/1d/utilities/intersectionResolver.js +1 -1
  8. package/lib/component/1d-2d/FieldEdition.d.ts +3 -1
  9. package/lib/component/1d-2d/FieldEdition.js +26 -10
  10. package/lib/component/2d/1d-tracer/Left1DChart.d.ts +0 -1
  11. package/lib/component/2d/1d-tracer/Top1DChart.d.ts +0 -1
  12. package/lib/component/2d/XAxis.d.ts +0 -1
  13. package/lib/component/2d/YAxis.d.ts +0 -1
  14. package/lib/component/2d/ft/Contours.js +7 -7
  15. package/lib/component/assignment/AssignmentsContext.d.ts +0 -1
  16. package/lib/component/context/ChartContext.d.ts +0 -1
  17. package/lib/component/context/DispatchContext.d.ts +0 -1
  18. package/lib/component/context/GlobalContext.d.ts +0 -1
  19. package/lib/component/context/KeyModifierContext.js +1 -1
  20. package/lib/component/context/LoaderContext.d.ts +0 -1
  21. package/lib/component/context/PreferencesContext.d.ts +0 -1
  22. package/lib/component/context/ScaleContext.d.ts +0 -1
  23. package/lib/component/elements/ActionButtons.d.ts +1 -0
  24. package/lib/component/elements/ActionButtons.js +4 -4
  25. package/lib/component/elements/ColorInput.d.ts +0 -1
  26. package/lib/component/elements/ColorPickerDropdownController.d.ts +2 -0
  27. package/lib/component/elements/ColorPickerDropdownController.js +8 -0
  28. package/lib/component/elements/ColumnWrapper.d.ts +0 -1
  29. package/lib/component/elements/ContextMenu.d.ts +0 -1
  30. package/lib/component/elements/Input.d.ts +1 -0
  31. package/lib/component/elements/Input.js +2 -1
  32. package/lib/component/elements/Input2.d.ts +13 -0
  33. package/lib/component/elements/Input2.js +118 -0
  34. package/lib/component/elements/Input2Controller.d.ts +12 -0
  35. package/lib/component/elements/Input2Controller.js +22 -0
  36. package/lib/component/elements/MoleculeSelection.js +1 -1
  37. package/lib/component/elements/NumberInput.js +1 -1
  38. package/lib/component/elements/NumberInput2.d.ts +12 -0
  39. package/lib/component/elements/NumberInput2.js +65 -0
  40. package/lib/component/elements/NumberInput2Controller.d.ts +8 -0
  41. package/lib/component/elements/NumberInput2Controller.js +15 -0
  42. package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +3 -3
  43. package/lib/component/elements/ReactTable/Style.d.ts +3 -1
  44. package/lib/component/elements/ReactTable/Style.js +11 -1
  45. package/lib/component/elements/ReactTable/utility/ReactTableContext.d.ts +0 -1
  46. package/lib/component/elements/Select2.d.ts +26 -0
  47. package/lib/component/elements/Select2.js +25 -0
  48. package/lib/component/elements/Select2Controller.d.ts +7 -0
  49. package/lib/component/elements/Select2Controller.js +12 -0
  50. package/lib/component/elements/draggable/useDraggable.d.ts +0 -1
  51. package/lib/component/elements/dropDownButton/DropDownButton.d.ts +2 -4
  52. package/lib/component/elements/dropDownButton/DropDownButton.js +11 -37
  53. package/lib/component/elements/dropDownButton/DropDownList.js +3 -32
  54. package/lib/component/elements/formik/FormikColorPicker.d.ts +0 -1
  55. package/lib/component/elements/formik/FormikColumnFormatField.d.ts +0 -1
  56. package/lib/component/elements/formik/FormikInput.d.ts +0 -1
  57. package/lib/component/elements/formik/FormikInput2.d.ts +11 -0
  58. package/lib/component/elements/formik/FormikInput2.js +26 -0
  59. package/lib/component/elements/formik/FormikOnChange.d.ts +0 -1
  60. package/lib/component/elements/popup/Modal/Context.d.ts +0 -1
  61. package/lib/component/elements/popup/Modal/ModalContent.d.ts +0 -1
  62. package/lib/component/elements/resizer/SVGResizer.d.ts +0 -1
  63. package/lib/component/elements/useFormValidateField.d.ts +1 -0
  64. package/lib/component/elements/useFormValidateField.js +9 -0
  65. package/lib/component/header/ApodizationOptionsPanel.js +26 -11
  66. package/lib/component/header/AutoPeakPickingOptionPanel.d.ts +1 -4
  67. package/lib/component/header/AutoPeakPickingOptionPanel.js +16 -16
  68. package/lib/component/header/BaseLineCorrectionPanel.js +49 -27
  69. package/lib/component/header/Header.js +1 -1
  70. package/lib/component/header/PhaseCorrectionPanel.js +12 -24
  71. package/lib/component/header/RangesPickingOptionPanel.js +12 -12
  72. package/lib/component/header/ZeroFillingOptionsPanel.js +18 -7
  73. package/lib/component/header/Zones2DOptionPanel.js +19 -18
  74. package/lib/component/hooks/useWorkspaceAction.d.ts +1 -1
  75. package/lib/component/modal/editRange/forms/components/SignalTab.d.ts +0 -1
  76. package/lib/component/modal/editRange/forms/components/SignalsContent.d.ts +0 -1
  77. package/lib/component/modal/setting/GeneralSettings.d.ts +5 -1
  78. package/lib/component/modal/setting/GeneralSettings.js +107 -111
  79. package/lib/component/modal/setting/WorkspaceItem.js +4 -9
  80. package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.d.ts +1 -1
  81. package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.js +95 -59
  82. package/lib/component/modal/setting/settings-tabs/DisplayTabContent.js +33 -25
  83. package/lib/component/modal/setting/settings-tabs/GeneralTabContent.js +15 -4
  84. package/lib/component/modal/setting/settings-tabs/ImportationFiltersTabContent.js +56 -39
  85. package/lib/component/modal/setting/settings-tabs/InfoBlockTabContent.js +36 -36
  86. package/lib/component/modal/setting/settings-tabs/NucleiTabContent.js +44 -36
  87. package/lib/component/modal/setting/settings-tabs/OnLoadProcessingTabContent.js +16 -11
  88. package/lib/component/modal/setting/settings-tabs/SpectraColorsTabContent.js +47 -40
  89. package/lib/component/modal/setting/settings-tabs/ToolsTabContent.js +50 -40
  90. package/lib/component/modal/setting/settingsValidation.js +8 -34
  91. package/lib/component/panels/AutomaticAssignment/AutomaticAssignmentTable.d.ts +0 -1
  92. package/lib/component/panels/IntegralsPanel/IntegralTable.d.ts +0 -1
  93. package/lib/component/panels/IntegralsPanel/IntegralsPreferences.d.ts +0 -1
  94. package/lib/component/panels/Panels.js +31 -8
  95. package/lib/component/panels/PeaksPanel/PeaksPreferences.d.ts +0 -1
  96. package/lib/component/panels/PeaksPanel/PeaksTable.d.ts +0 -1
  97. package/lib/component/panels/RangesPanel/RangesPreferences.d.ts +0 -1
  98. package/lib/component/panels/RangesPanel/TableColumns/RangeAssignmentsColumn.d.ts +0 -1
  99. package/lib/component/panels/SpectraPanel/SpectraPreferences.d.ts +0 -1
  100. package/lib/component/panels/SpectraPanel/SpectraPreferences.js +32 -24
  101. package/lib/component/panels/SpectraPanel/SpectraTable.js +17 -2
  102. package/lib/component/panels/SpectraPanel/SpectrumListPanel.d.ts +0 -1
  103. package/lib/component/panels/SpectraPanel/base/ColorIndicator.d.ts +0 -1
  104. package/lib/component/panels/SpectraPanel/base/SpectraColumnsManager.d.ts +3 -3
  105. package/lib/component/panels/SpectraPanel/base/SpectraColumnsManager.js +25 -16
  106. package/lib/component/panels/SpectraPanel/base/setting/Spectrum1DHistogram.d.ts +0 -1
  107. package/lib/component/panels/SpectraPanel/base/setting/Spectrum1DSetting.js +15 -5
  108. package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DHistogram.d.ts +0 -1
  109. package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DSetting.js +44 -6
  110. package/lib/component/panels/SpectraPanel/base/setting/SpectrumSetting.d.ts +0 -1
  111. package/lib/component/panels/SummaryPanel/Overview.d.ts +0 -1
  112. package/lib/component/panels/SummaryPanel/SummaryPanel.d.ts +0 -1
  113. package/lib/component/panels/SummaryPanel/utilities/Utilities.d.ts +1 -1
  114. package/lib/component/panels/ZonesPanel/ZonesPreferences.d.ts +0 -1
  115. package/lib/component/panels/databasePanel/DatabasePanel.js +17 -3
  116. package/lib/component/panels/databasePanel/DatabasePreferences.d.ts +0 -1
  117. package/lib/component/panels/databasePanel/DatabaseTable.d.ts +11 -4
  118. package/lib/component/panels/databasePanel/DatabaseTable.js +20 -5
  119. package/lib/component/panels/informationPanel/InformationEditionModal.d.ts +6 -0
  120. package/lib/component/panels/informationPanel/InformationEditionModal.js +105 -0
  121. package/lib/component/panels/informationPanel/InformationPanel.d.ts +1 -0
  122. package/lib/component/panels/{InformationPanel.js → informationPanel/InformationPanel.js} +2 -2
  123. package/lib/component/panels/multipleAnalysisPanel/preferences/MultipleAnalysisCodeEditor.d.ts +0 -1
  124. package/lib/component/panels/multipleAnalysisPanel/preferences/index.d.ts +0 -1
  125. package/lib/component/panels/predictionPanel/PredictionOptionsPanel.d.ts +0 -1
  126. package/lib/component/panels/predictionPanel/PredictionOptionsPanel.js +1 -1
  127. package/lib/component/panels/predictionPanel/PredictionPreferences.d.ts +0 -1
  128. package/lib/component/panels/spectrumSimulation/SpectrumSimulationPreferences.d.ts +0 -1
  129. package/lib/component/reducer/Reducer.d.ts +1 -1
  130. package/lib/component/reducer/Reducer.js +2 -0
  131. package/lib/component/reducer/actions/DatabaseActions.js +22 -5
  132. package/lib/component/reducer/actions/SpectraActions.d.ts +8 -2
  133. package/lib/component/reducer/actions/SpectraActions.js +58 -21
  134. package/lib/component/reducer/actions/ToolsActions.js +3 -4
  135. package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.d.ts +7 -7
  136. package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +2 -0
  137. package/lib/component/reducer/preferences/preferencesReducer.d.ts +1 -1
  138. package/lib/component/utility/checkUniqueByKey.d.ts +2 -0
  139. package/lib/component/utility/checkUniqueByKey.js +40 -0
  140. package/lib/component/utility/colorToHexWithAlpha.d.ts +9 -0
  141. package/lib/component/utility/colorToHexWithAlpha.js +4 -0
  142. package/lib/component/workspaces/exercise.js +2 -0
  143. package/lib/component/workspaces/process1D.js +0 -1
  144. package/lib/component/workspaces/workspaceDefaultProperties.js +1 -0
  145. package/lib/data/PredictionManager.js +3 -5
  146. package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +13 -13
  147. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +9 -9
  148. package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +13 -13
  149. package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +13 -13
  150. package/lib/data/data1d/database.d.ts +1 -0
  151. package/lib/data/data1d/database.js +4 -2
  152. package/lib/data/data2d/Spectrum2D/contours.d.ts +8 -22
  153. package/lib/data/data2d/Spectrum2D/contours.js +88 -67
  154. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +4 -2
  155. package/lib/data/data2d/Spectrum2D/zones/detectZonesManual.d.ts +20 -20
  156. package/lib/data/data2d/Spectrum2D/zones/initiateZones.d.ts +20 -20
  157. package/lib/data/getDefaultMatrixFilters.d.ts +1 -1
  158. package/lib/data/initiateFilters.d.ts +1 -1
  159. package/lib/data/matrixGeneration.js +1 -2
  160. package/lib/data/types/common/Keys.d.ts +3 -0
  161. package/lib/data/types/common/Keys.js +1 -0
  162. package/lib/data/utilities/generateNumbersPowerOfX.d.ts +2 -2
  163. package/lib/versionInfo.js +1 -1
  164. package/package.json +32 -31
  165. package/lib/component/elements/formik/FormikSlider.d.ts +0 -6
  166. package/lib/component/elements/formik/FormikSlider.js +0 -15
  167. package/lib/component/panels/InformationPanel.d.ts +0 -1
@@ -1,107 +1,117 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { CheckBoxCell } from '../../../elements/CheckBoxCell';
2
+ import { Checkbox } from '@blueprintjs/core';
3
+ import { useMemo } from 'react';
4
+ import { useFormContext } from 'react-hook-form';
3
5
  import ReactTable from '../../../elements/ReactTable/ReactTable';
4
6
  const LIST = [
5
7
  {
6
8
  label: 'Zoom in',
7
- name: 'toolBarButtons.zoom',
9
+ name: 'zoom',
8
10
  },
9
11
  {
10
12
  label: 'Zoom out',
11
- name: 'toolBarButtons.zoomOut',
13
+ name: 'zoomOut',
12
14
  },
13
15
  {
14
16
  label: 'Import',
15
- name: 'toolBarButtons.import',
17
+ name: 'import',
16
18
  },
17
19
  {
18
20
  label: 'Export As',
19
- name: 'toolBarButtons.exportAs',
21
+ name: 'exportAs',
20
22
  },
21
23
  {
22
24
  label: 'Stack Alignments',
23
- name: 'toolBarButtons.spectraStackAlignments',
25
+ name: 'spectraStackAlignments',
24
26
  },
25
27
  {
26
28
  label: 'Center Alignments',
27
- name: 'toolBarButtons.spectraCenterAlignments',
29
+ name: 'spectraCenterAlignments',
28
30
  },
29
31
  {
30
32
  label: 'Real/Imaginary ',
31
- name: 'toolBarButtons.realImaginary',
33
+ name: 'realImaginary',
32
34
  },
33
35
  {
34
36
  label: 'Peak picking',
35
- name: 'toolBarButtons.peakPicking',
37
+ name: 'peakPicking',
36
38
  },
37
39
  {
38
40
  label: 'Integral',
39
- name: 'toolBarButtons.integral',
41
+ name: 'integral',
40
42
  },
41
43
  {
42
44
  label: 'Zone Picking',
43
- name: 'toolBarButtons.zonePicking',
45
+ name: 'zonePicking',
44
46
  },
45
47
  {
46
48
  label: 'Range picking',
47
- name: 'toolBarButtons.rangePicking',
49
+ name: 'rangePicking',
48
50
  },
49
51
  {
50
52
  label: 'Slicing',
51
- name: 'toolBarButtons.slicing',
53
+ name: 'slicing',
52
54
  },
53
55
  {
54
56
  label: 'Apodization',
55
- name: 'toolBarButtons.apodization',
57
+ name: 'apodization',
56
58
  },
57
59
  {
58
60
  label: 'Zero filling',
59
- name: 'toolBarButtons.zeroFilling',
61
+ name: 'zeroFilling',
60
62
  },
61
63
  {
62
64
  label: 'Fourier transform',
63
- name: 'toolBarButtons.fft',
65
+ name: 'fft',
64
66
  },
65
67
  {
66
68
  label: 'Phase correction',
67
- name: 'toolBarButtons.phaseCorrection',
69
+ name: 'phaseCorrection',
68
70
  },
69
71
  {
70
72
  label: 'Baseline correction',
71
- name: 'toolBarButtons.baselineCorrection',
73
+ name: 'baselineCorrection',
72
74
  },
73
75
  {
74
76
  label: 'Exclusion zones',
75
- name: 'toolBarButtons.exclusionZones',
77
+ name: 'exclusionZones',
76
78
  },
77
79
  {
78
80
  label: 'Multiple spectra analysis',
79
- name: 'toolBarButtons.multipleSpectraAnalysis',
81
+ name: 'multipleSpectraAnalysis',
80
82
  },
81
83
  {
82
84
  label: 'Auto range and zone picking',
83
- name: 'toolBarButtons.autoRangeAndZonePicking',
84
- },
85
- ];
86
- const COLUMNS = [
87
- {
88
- index: 1,
89
- Header: '#',
90
- accessor: (_, index) => index + 1,
91
- },
92
- {
93
- index: 1,
94
- Header: 'Tool',
95
- accessor: 'label',
96
- style: { width: '60%' },
97
- },
98
- {
99
- index: 2,
100
- Header: 'Active',
101
- Cell: ({ row }) => (_jsx(CheckBoxCell, { name: `display.${row.original.name}`, defaultValue: false })),
85
+ name: 'autoRangeAndZonePicking',
102
86
  },
103
87
  ];
104
88
  function ToolsTabContent() {
105
- return (_jsx("div", { style: { width: '100%', overflow: 'hidden' }, children: _jsx(ReactTable, { columns: COLUMNS, data: LIST }) }));
89
+ const { register } = useFormContext();
90
+ const COLUMNS = useMemo(() => [
91
+ {
92
+ index: 1,
93
+ Header: '#',
94
+ accessor: (_, index) => index + 1,
95
+ },
96
+ {
97
+ index: 1,
98
+ Header: 'Tool',
99
+ accessor: 'label',
100
+ style: { width: '60%' },
101
+ },
102
+ {
103
+ index: 2,
104
+ Header: 'Active',
105
+ style: { textAlign: 'center' },
106
+ Cell: ({ row }) => {
107
+ const name = `display.toolBarButtons.${row.original.name}`;
108
+ return (_jsx(Checkbox, { style: { margin: 0 }, ...register(name), defaultChecked: false }));
109
+ },
110
+ },
111
+ ], [register]);
112
+ return (_jsx("div", { style: { width: '100%', overflow: 'hidden' }, children: _jsx(ReactTable, { columns: COLUMNS, data: LIST, rowStyle: {
113
+ hover: { backgroundColor: '#f7f7f7' },
114
+ active: { backgroundColor: '#f5f5f5' },
115
+ } }) }));
106
116
  }
107
117
  export default ToolsTabContent;
@@ -1,40 +1,14 @@
1
- import { array, object, string, ValidationError, number } from 'yup';
1
+ import { array, object, string, number } from 'yup';
2
+ import { checkUniqueByKey } from '../../utility/checkUniqueByKey';
2
3
  const nucleiValidation = array()
3
4
  .of(object().shape({
4
- nucleus: string().trim().required('Nucleus is a required field'),
5
- ppmFormat: string().trim().required('PPM format is a required field'),
6
- hzFormat: string().trim().required('Hz format is a required field'),
5
+ nucleus: string().required('Nucleus is a required field'),
6
+ ppmFormat: string().required('PPM format is a required field'),
7
+ hzFormat: string().required('Hz format is a required field'),
7
8
  }))
8
9
  .test('Unique', 'Nuclei need te be unique', function check(nuclei) {
9
- if (!nuclei)
10
- return true;
11
- const nucleusFrequencies = {};
12
- let index = 0;
13
- for (const nucleiPreferences of nuclei) {
14
- const key = nucleiPreferences.nucleus?.toLowerCase() || '';
15
- if (key) {
16
- if (nucleusFrequencies[key]) {
17
- ++nucleusFrequencies[key].value;
18
- nucleusFrequencies[key].fieldsIndexes.push(index);
19
- }
20
- else {
21
- nucleusFrequencies[key] = { value: 1, fieldsIndexes: [index] };
22
- }
23
- }
24
- index++;
25
- }
26
- const errors = [];
27
- for (const key in nucleusFrequencies) {
28
- const { value, fieldsIndexes } = nucleusFrequencies[key];
29
- if (value > 1) {
30
- for (const index of fieldsIndexes) {
31
- errors.push(new ValidationError(`${key} nucleus must te be unique`, nuclei[index].nucleus,
32
- // eslint-disable-next-line no-invalid-this
33
- `${this.path}.${index}.name`));
34
- }
35
- }
36
- }
37
- return new ValidationError(errors);
10
+ // eslint-disable-next-line no-invalid-this
11
+ return checkUniqueByKey(nuclei, 'nucleus', this);
38
12
  });
39
13
  const databasesValidation = object().shape({
40
14
  data: array().of(object().shape({
@@ -59,7 +33,7 @@ const spectraColorsSchemaValidation = object({
59
33
  })),
60
34
  });
61
35
  const generalValidation = object({
62
- dimmedSpectraOpacity: number().required(),
36
+ dimmedSpectraOpacity: number().min(0).max(1).required(),
63
37
  });
64
38
  export const validation = object().shape({
65
39
  nuclei: nucleiValidation,
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { AutoAssignmentsData } from './useAutoAssignments';
3
2
  interface AutomaticAssignmentTableProps {
4
3
  data: AutoAssignmentsData[];
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Info1D, Integral } from 'nmr-processing';
3
2
  import { IntegralPanelInnerProps } from './IntegralPanel';
4
3
  interface IntegralTableProps extends Pick<IntegralPanelInnerProps, 'activeTab'> {
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  declare const _default: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Omit<any, "ref"> & import("react").RefAttributes<unknown>>>;
3
2
  export default _default;
@@ -1,12 +1,13 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import lodashGet from 'lodash/get';
3
3
  import { useCallback, memo } from 'react';
4
- import { Accordion } from 'react-science/ui';
4
+ import { FaRegEdit } from 'react-icons/fa';
5
+ import { Accordion, Toolbar, } from 'react-science/ui';
5
6
  import { useChartData } from '../context/ChartContext';
6
7
  import { usePreferences } from '../context/PreferencesContext';
7
8
  import useCheckExperimentalFeature from '../hooks/useCheckExperimentalFeature';
9
+ import { useDialogToggle } from '../hooks/useDialogToggle';
8
10
  import AutomaticAssignment from './AutomaticAssignment/AutomaticAssignment';
9
- import InformationPanel from './InformationPanel';
10
11
  import IntegralPanel from './IntegralsPanel/IntegralPanel';
11
12
  import { MatrixGenerationPanel } from './MatrixGenerationPanel/MatrixGenerationPanel';
12
13
  import MoleculePanel from './MoleculesPanel/MoleculePanel';
@@ -17,6 +18,8 @@ import SummaryPanel from './SummaryPanel/SummaryPanel';
17
18
  import ZonesPanel from './ZonesPanel/ZonesPanel';
18
19
  import DatabasePanel from './databasePanel/DatabasePanel';
19
20
  import FilterPanel from './filtersPanel/FilterPanel';
21
+ import { InformationEditionModal } from './informationPanel/InformationEditionModal';
22
+ import { InformationPanel } from './informationPanel/InformationPanel';
20
23
  import MultipleSpectraAnalysisPanel from './multipleAnalysisPanel/MultipleSpectraAnalysisPanel';
21
24
  import PredictionPane from './predictionPanel/PredictionPanel';
22
25
  import SpectrumSimulation from './spectrumSimulation/SpectrumSimulation';
@@ -28,6 +31,7 @@ const accordionItems = [
28
31
  mode: null,
29
32
  },
30
33
  {
34
+ id: 'informationPanel',
31
35
  title: 'Information',
32
36
  component: _jsx(InformationPanel, {}),
33
37
  style: { overflow: 'hidden' },
@@ -140,6 +144,9 @@ function usePanelPreferences() {
140
144
  function PanelsInner({ displayerMode: displayedMode }) {
141
145
  const getPanelPreferences = usePanelPreferences();
142
146
  const isExperimental = useCheckExperimentalFeature();
147
+ const { dialog, openDialog, closeDialog } = useDialogToggle({
148
+ informationModal: false,
149
+ });
143
150
  const check = useCallback((item) => {
144
151
  const panelOptions = getPanelPreferences(item);
145
152
  return ((panelOptions?.display &&
@@ -147,13 +154,29 @@ function PanelsInner({ displayerMode: displayedMode }) {
147
154
  (item.mode == null || item.mode === displayedMode)) ||
148
155
  (item.isExperimental && isExperimental));
149
156
  }, [displayedMode, getPanelPreferences, isExperimental]);
150
- const isOpened = useCallback((item) => {
157
+ function isOpened(item) {
151
158
  const panelOptions = getPanelPreferences(item);
152
159
  return panelOptions?.display && panelOptions?.open;
153
- }, [getPanelPreferences]);
154
- return (_jsx("div", { style: { width: '100%', height: '100%', flex: '1 1 0%' }, children: _jsx(Accordion, { children: accordionItems.map((item) => {
155
- return (check(item) && (_jsx(Accordion.Item, { title: item.title, defaultOpened: isOpened(item), children: item.component }, item.title)));
156
- }) }) }));
160
+ }
161
+ const toolbars = {
162
+ informationPanel: [
163
+ {
164
+ icon: _jsx(FaRegEdit, {}),
165
+ onClick: ({ event }) => {
166
+ event.stopPropagation();
167
+ openDialog('informationModal');
168
+ },
169
+ },
170
+ ],
171
+ };
172
+ return (_jsxs("div", { style: { width: '100%', height: '100%', flex: '1 1 0%' }, children: [_jsx(InformationEditionModal, { isOpen: dialog.informationModal, onCloseDialog: closeDialog }), _jsx(Accordion, { children: accordionItems.map((item) => {
173
+ const { title, component, id } = item;
174
+ let toolbar;
175
+ if (id && toolbars[id]) {
176
+ toolbar = (_jsx(Toolbar, { children: toolbars[id]?.map((options, index) => (_jsx(Toolbar.Item, { ...options }, index))) }));
177
+ }
178
+ return (check(item) && (_jsx(Accordion.Item, { title: title, defaultOpened: isOpened(item), toolbar: toolbar, children: component }, title)));
179
+ }) })] }));
157
180
  }
158
181
  const MemoizedPanels = memo(PanelsInner);
159
182
  export default function Panels() {
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  declare const _default: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Omit<any, "ref"> & import("react").RefAttributes<unknown>>>;
3
2
  export default _default;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Info1D } from 'nmr-processing';
3
2
  import { PeakRecord } from './PeaksPanel';
4
3
  interface PeaksTableProps {
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  declare const _default: import("react").ForwardRefExoticComponent<Omit<any, "ref"> & import("react").RefAttributes<unknown>>;
3
2
  export default _default;
@@ -1,5 +1,4 @@
1
1
  /** @jsxImportSource @emotion/react */
2
- /// <reference types="react" />
3
2
  import { AssignmentsData } from '../../../assignment/AssignmentsContext';
4
3
  import { RangeColumnProps } from '../RangesTableRow';
5
4
  interface RemoveAssignmentsButtonProps {
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  declare const _default: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Omit<any, "ref"> & import("react").RefAttributes<unknown>>>;
3
2
  export default _default;
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Formik } from 'formik';
3
- import { useImperativeHandle, useRef, memo, forwardRef, useCallback, useMemo, } from 'react';
2
+ import { yupResolver } from '@hookform/resolvers/yup';
3
+ import { useImperativeHandle, memo, forwardRef, useCallback, useMemo, } from 'react';
4
+ import { FormProvider, useForm } from 'react-hook-form';
4
5
  import * as Yup from 'yup';
5
6
  import { useChartData } from '../../context/ChartContext';
6
7
  import { usePreferences } from '../../context/PreferencesContext';
@@ -8,11 +9,17 @@ import { GroupPane } from '../../elements/GroupPane';
8
9
  import { Scroller } from '../../elements/Scroller';
9
10
  import useNucleus from '../../hooks/useNucleus';
10
11
  import { usePanelPreferencesByNuclei } from '../../hooks/usePanelPreferences';
11
- import { convertPathArrayToString } from '../../utility/convertPathArrayToString';
12
12
  import { getSpectraObjectPaths } from '../../utility/getSpectraObjectPaths';
13
13
  import { NucleusGroup } from '../extra/preferences/NucleusGroup';
14
14
  import { PreferencesContainer } from '../extra/preferences/PreferencesContainer';
15
15
  import { SpectraColumnsManager } from './base/SpectraColumnsManager';
16
+ function replaceNucleusKeys(data, searchValue, replaceValue) {
17
+ const nuclei = {};
18
+ for (const key in data.nuclei) {
19
+ nuclei[key.replace(searchValue, replaceValue)] = data.nuclei[key];
20
+ }
21
+ return { ...data, nuclei };
22
+ }
16
23
  const groupPaneStyle = {
17
24
  header: {
18
25
  color: 'black',
@@ -45,30 +52,34 @@ const spectraPreferencesValidation = Yup.lazy((obj) => Yup.object().shape({
45
52
  nuclei: Yup.object().shape(validationColumns(obj)),
46
53
  }));
47
54
  function SpectraPreferences(props, ref) {
48
- const formRef = useRef(null);
49
55
  const { data, view: { spectra: { activeTab }, }, } = useChartData();
50
56
  const preferences = usePreferences();
51
57
  const nuclei = useNucleus();
52
58
  const preferencesByNuclei = usePanelPreferencesByNuclei('spectra', nuclei);
59
+ const methods = useForm({
60
+ defaultValues: replaceNucleusKeys(preferencesByNuclei, ',', '_'),
61
+ resolver: yupResolver(spectraPreferencesValidation),
62
+ });
63
+ const { handleSubmit, getValues, reset, formState: { isValid }, } = methods;
53
64
  const { datalist, paths } = useMemo(() => getSpectraObjectPaths(data), [data]);
54
- function saveHandler(values) {
65
+ const saveHandler = useCallback((values) => {
55
66
  preferences.dispatch({
56
67
  type: 'SET_PANELS_PREFERENCES',
57
- payload: { key: 'spectra', value: values },
68
+ payload: {
69
+ key: 'spectra',
70
+ value: replaceNucleusKeys(values, '_', ','),
71
+ },
58
72
  });
59
- }
73
+ return true;
74
+ }, [preferences]);
60
75
  useImperativeHandle(ref, () => ({
61
76
  saveSetting: () => {
62
- if (!formRef.current)
63
- return;
64
- void formRef.current.submitForm();
65
- return formRef.current?.isValid;
77
+ void handleSubmit(saveHandler)();
78
+ return isValid;
66
79
  },
67
- }), []);
80
+ }), [handleSubmit, isValid, saveHandler]);
68
81
  const handleAdd = useCallback((nucleus, index) => {
69
- if (!formRef.current)
70
- return;
71
- const data = formRef.current.values;
82
+ const data = getValues();
72
83
  let columns = data.nuclei[nucleus]?.columns || [];
73
84
  columns = [
74
85
  ...columns.slice(0, index),
@@ -79,7 +90,7 @@ function SpectraPreferences(props, ref) {
79
90
  },
80
91
  ...columns.slice(index),
81
92
  ];
82
- void formRef.current.setValues({
93
+ reset({
83
94
  ...data,
84
95
  nuclei: {
85
96
  ...data.nuclei,
@@ -89,13 +100,11 @@ function SpectraPreferences(props, ref) {
89
100
  },
90
101
  },
91
102
  });
92
- }, []);
103
+ }, [getValues, reset]);
93
104
  const handleDelete = useCallback((nucleus, index) => {
94
- if (!formRef.current)
95
- return;
96
- const data = formRef.current.values;
105
+ const data = getValues();
97
106
  const columns = data.nuclei[nucleus]?.columns.filter((_, columnIndex) => columnIndex !== index);
98
- void formRef.current.setValues({
107
+ reset({
99
108
  ...data,
100
109
  nuclei: {
101
110
  ...data.nuclei,
@@ -105,7 +114,7 @@ function SpectraPreferences(props, ref) {
105
114
  },
106
115
  },
107
116
  });
108
- }, []);
117
+ }, [getValues, reset]);
109
118
  const mapOnChangeValueHandler = useCallback((key) => {
110
119
  const path = paths?.[key];
111
120
  if (path) {
@@ -113,7 +122,6 @@ function SpectraPreferences(props, ref) {
113
122
  }
114
123
  return key || ' ';
115
124
  }, [paths]);
116
- const mapValue = useCallback((value) => convertPathArrayToString(value), []);
117
- return (_jsx(PreferencesContainer, { children: _jsx(Formik, { innerRef: formRef, onSubmit: saveHandler, initialValues: preferencesByNuclei, validationSchema: spectraPreferencesValidation, children: _jsx(Scroller, { scrollTo: activeTab, children: nuclei?.map((n) => (_jsx(Scroller.Item, { elementKey: n, children: _jsx(NucleusGroup, { nucleus: n, children: _jsx(GroupPane, { text: "General", style: groupPaneStyle, children: _jsx(SpectraColumnsManager, { nucleus: n, onAdd: handleAdd, onDelete: handleDelete, mapOnChangeValue: mapOnChangeValueHandler, mapValue: mapValue, datalist: datalist }) }) }) }, n))) }) }) }));
125
+ return (_jsx(PreferencesContainer, { children: _jsx(FormProvider, { ...methods, children: _jsx(Scroller, { scrollTo: activeTab, children: nuclei?.map((n) => (_jsx(Scroller.Item, { elementKey: n, children: _jsx(NucleusGroup, { nucleus: n, children: _jsx(GroupPane, { text: "General", style: groupPaneStyle, children: _jsx(SpectraColumnsManager, { nucleus: n.replace(',', '_'), onAdd: handleAdd, onDelete: handleDelete, mapOnChangeValue: mapOnChangeValueHandler, datalist: datalist }) }) }) }, n))) }) }) }));
118
126
  }
119
127
  export default memo(forwardRef(SpectraPreferences));
@@ -175,7 +175,7 @@ export function SpectraTable(props) {
175
175
  });
176
176
  }
177
177
  else {
178
- const pathString = Array.isArray(path) ? path.join('.') : '';
178
+ const pathString = pathToString(path);
179
179
  let style = columnStyle;
180
180
  let cellRender = null;
181
181
  if (pathString === 'info.name') {
@@ -193,7 +193,7 @@ export function SpectraTable(props) {
193
193
  }
194
194
  const cell = {
195
195
  Header: () => _jsx(ColumnHeader, { label: col.label, col: col }),
196
- accessor: (row) => lodashGet(row, path, ''),
196
+ accessor: (row) => getValue(row, path),
197
197
  ...(cellRender && { Cell: cellRender }),
198
198
  id: `${index}`,
199
199
  style,
@@ -251,3 +251,18 @@ function convertSpectrumToText(spectrum) {
251
251
  }
252
252
  return lines.join('\n');
253
253
  }
254
+ function pathToString(path) {
255
+ return Array.isArray(path) ? path.join('.') : '';
256
+ }
257
+ function getValue(row, path) {
258
+ const value = lodashGet(row, path, '');
259
+ const pathString = pathToString(path);
260
+ if (Array.isArray(value) &&
261
+ ['info.baseFrequency', 'info.originFrequency'].includes(pathString)) {
262
+ return value[0];
263
+ }
264
+ if (Array.isArray(value)) {
265
+ return value.join(',');
266
+ }
267
+ return value;
268
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  declare function SpectrumListPanel(): import("react/jsx-runtime").JSX.Element;
3
2
  declare const _default: import("react").MemoExoticComponent<typeof SpectrumListPanel>;
4
3
  export default _default;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Display1D, Display2D } from 'nmr-load-save';
3
2
  interface ColorIndicatorProps {
4
3
  onClick: (e: any) => void;
@@ -1,9 +1,9 @@
1
- import { InputMapValueFunctions } from '../../../elements/formik/FormikInput';
2
- interface SpectraColumnsManagerProps extends InputMapValueFunctions {
1
+ interface SpectraColumnsManagerProps {
3
2
  nucleus: string;
4
3
  onAdd: (nucleus: string, index: number) => void;
5
4
  onDelete: (nucleus: string, index: number) => void;
6
5
  datalist?: string[];
6
+ mapOnChangeValue: (value: string) => string;
7
7
  }
8
- export declare function SpectraColumnsManager({ nucleus, onAdd, onDelete, datalist, mapOnChangeValue, mapValue, }: SpectraColumnsManagerProps): import("react/jsx-runtime").JSX.Element;
8
+ export declare function SpectraColumnsManager({ nucleus, onAdd, onDelete, datalist, mapOnChangeValue, }: SpectraColumnsManagerProps): import("react/jsx-runtime").JSX.Element;
9
9
  export {};
@@ -1,11 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useFormikContext } from 'formik';
2
+ import { Checkbox, Classes } from '@blueprintjs/core';
3
3
  import { useMemo } from 'react';
4
- import { FaPlus, FaTimes } from 'react-icons/fa';
5
- import Button from '../../../elements/Button';
6
- import { CheckBoxCell } from '../../../elements/CheckBoxCell';
4
+ import { useFormContext } from 'react-hook-form';
5
+ import { FaPlus, FaRegTrashAlt } from 'react-icons/fa';
6
+ import { Button } from 'react-science/ui';
7
+ import { Input2Controller } from '../../../elements/Input2Controller';
7
8
  import ReactTable from '../../../elements/ReactTable/ReactTable';
8
- import FormikInput from '../../../elements/formik/FormikInput';
9
+ import { convertPathArrayToString } from '../../../utility/convertPathArrayToString';
9
10
  const inputStyle = {
10
11
  input: {
11
12
  width: '100%',
@@ -19,8 +20,11 @@ const inputStyle = {
19
20
  borderColor: 'white',
20
21
  },
21
22
  };
22
- export function SpectraColumnsManager({ nucleus, onAdd, onDelete, datalist, mapOnChangeValue, mapValue, }) {
23
- const { values: nucleiPreferences } = useFormikContext();
23
+ function getObjectKey(nucleus, index, key) {
24
+ return `nuclei.${nucleus}.columns.${index}.${key}`;
25
+ }
26
+ export function SpectraColumnsManager({ nucleus, onAdd, onDelete, datalist, mapOnChangeValue, }) {
27
+ const { control, getValues, register } = useFormContext();
24
28
  const COLUMNS = useMemo(() => [
25
29
  {
26
30
  Header: '#',
@@ -31,7 +35,8 @@ export function SpectraColumnsManager({ nucleus, onAdd, onDelete, datalist, mapO
31
35
  Header: 'Label',
32
36
  style: { padding: 0 },
33
37
  Cell: ({ row }) => {
34
- return (_jsx(FormikInput, { name: `nuclei.${nucleus}.columns.${row.index}.label`, style: inputStyle }));
38
+ const name = getObjectKey(nucleus, row.index, 'label');
39
+ return (_jsx(Input2Controller, { control: control, name: name, style: { backgroundColor: 'transparent' }, noShadowBox: true }));
35
40
  },
36
41
  },
37
42
  {
@@ -45,23 +50,27 @@ export function SpectraColumnsManager({ nucleus, onAdd, onDelete, datalist, mapO
45
50
  padding: '0.25rem 0.5rem',
46
51
  }, children: column?.jpath?.join('.') || column.description }));
47
52
  }
48
- return (_jsx(FormikInput, { name: `nuclei.${nucleus}.columns.${row.index}.jpath`, style: inputStyle, datalist: datalist, mapOnChangeValue: mapOnChangeValue, mapValue: mapValue }));
53
+ const name = getObjectKey(nucleus, row.index, 'jpath');
54
+ return (_jsx(Input2Controller, { control: control, name: name, filterItems: datalist, mapOnChangeValue: mapOnChangeValue, mapValue: convertPathArrayToString, style: { backgroundColor: 'transparent' }, noShadowBox: true }));
49
55
  },
50
56
  },
51
57
  {
52
58
  Header: 'Visible',
53
- style: { width: '30px' },
54
- Cell: ({ row }) => (_jsx(CheckBoxCell, { name: `nuclei.${nucleus}.columns.${row.index}.visible`, defaultValue: true })),
59
+ style: { width: '30px', textAlign: 'center' },
60
+ Cell: ({ row }) => (_jsx(Checkbox, { style: { margin: 0 }, ...register(getObjectKey(nucleus, row.index, 'visible')) })),
55
61
  },
56
62
  {
57
63
  Header: '',
58
- style: { width: '80px' },
59
- id: 'add-button',
64
+ style: { width: '65px' },
65
+ id: 'op-buttons',
60
66
  Cell: ({ row }) => {
61
67
  const record = row.original;
62
- return (_jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx(Button.Done, { fill: "outline", onClick: () => onAdd(nucleus, row.index + 1), children: _jsx(FaPlus, {}) }), !record?.name && (_jsx(Button.Danger, { fill: "outline", onClick: () => onDelete(nucleus, row.index), children: _jsx(FaTimes, {}) }))] }));
68
+ return (_jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx(Button, { small: true, intent: "success", outlined: true, tooltipProps: { content: '', disabled: true }, onClick: () => onAdd(nucleus, row.index + 1), children: _jsx(FaPlus, { className: Classes.ICON }) }), !record?.name && (_jsx(Button, { small: true, outlined: true, intent: "danger", tooltipProps: { content: '', disabled: true }, onClick: () => onDelete(nucleus, row.index), children: _jsx(FaRegTrashAlt, { className: Classes.ICON }) }))] }));
63
69
  },
64
70
  },
65
- ], [datalist, mapOnChangeValue, mapValue, nucleus, onAdd, onDelete]);
66
- return (_jsx(ReactTable, { data: nucleiPreferences.nuclei[nucleus]?.columns || [], columns: COLUMNS }));
71
+ ], [control, datalist, mapOnChangeValue, nucleus, onAdd, onDelete, register]);
72
+ return (_jsx(ReactTable, { data: getValues().nuclei[nucleus]?.columns || [], columns: COLUMNS, rowStyle: {
73
+ hover: { backgroundColor: '#f7f7f7' },
74
+ active: { backgroundColor: '#f5f5f5' },
75
+ } }));
67
76
  }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  interface Spectrum1DHistogramProps {
3
2
  color?: string;
4
3
  data: any;
@@ -1,9 +1,19 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Formik } from 'formik';
3
- import FormikColorPicker from '../../../../elements/formik/FormikColorPicker';
4
- import FormikOnChange from '../../../../elements/formik/FormikOnChange';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Controller, useForm } from 'react-hook-form';
3
+ import { ColorPicker } from 'react-science/ui';
4
+ import { COLORS } from '../../../../../data/utilities/generateColor';
5
+ import { colorToHexWithAlpha } from '../../../../utility/colorToHexWithAlpha';
5
6
  import Spectrum1DHistogram from './Spectrum1DHistogram';
6
7
  function Spectrum1DSetting({ data: SpectrumData, onSubmit, }) {
7
- return (_jsx(Formik, { initialValues: SpectrumData.display, onSubmit: onSubmit, children: _jsxs(_Fragment, { children: [_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: '1.25rem' }, children: [_jsx("div", { style: { display: 'block', position: 'relative' }, children: _jsx(FormikColorPicker, { name: "color" }) }), _jsx(Spectrum1DHistogram, { color: "red", data: SpectrumData.data })] }), _jsx(FormikOnChange, { onChange: onSubmit })] }) }));
8
+ const { control, handleSubmit } = useForm({
9
+ defaultValues: SpectrumData.display,
10
+ });
11
+ return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: '1.25rem' }, children: [_jsx("div", { style: { display: 'block', position: 'relative' }, children: _jsx(Controller, { name: "color", control: control, render: ({ field }) => {
12
+ const { value, onChange } = field;
13
+ return (_jsx(ColorPicker, { onChangeComplete: (color) => {
14
+ onChange(colorToHexWithAlpha(color));
15
+ void handleSubmit(onSubmit)();
16
+ }, color: { hex: value || '#000' }, presetColors: COLORS, style: { boxShadow: 'none' } }));
17
+ } }) }), _jsx(Spectrum1DHistogram, { color: "red", data: SpectrumData.data })] }));
8
18
  }
9
19
  export default Spectrum1DSetting;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  interface Spectrum2DHistogramProps {
3
2
  color?: string;
4
3
  data: any;