nmrium 0.42.0 → 0.43.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 (217) hide show
  1. package/lib/component/1d/ApodizationLine.js +1 -1
  2. package/lib/component/1d/Chart1D.js +3 -2
  3. package/lib/component/1d/Line.js +1 -1
  4. package/lib/component/1d/Viewer1D.js +15 -3
  5. package/lib/component/1d/integral/IntegralResizable.js +4 -3
  6. package/lib/component/1d/multiAnalysis/AnalysisRange.js +3 -1
  7. package/lib/component/1d/peaks/PeakAnnotations.js +20 -25
  8. package/lib/component/1d/peaks/PeakAnnotationsSpreadMode.d.ts +2 -0
  9. package/lib/component/1d/peaks/PeakAnnotationsSpreadMode.js +59 -0
  10. package/lib/component/1d/peaks/PeakEditionManager.d.ts +18 -0
  11. package/lib/component/1d/peaks/PeakEditionManager.js +98 -0
  12. package/lib/component/1d/peaks/Peaks.d.ts +1 -0
  13. package/lib/component/1d/peaks/Peaks.js +22 -0
  14. package/lib/component/1d/ranges/Range.js +3 -1
  15. package/lib/component/1d/tool/BaseLineZones.d.ts +1 -1
  16. package/lib/component/1d/tool/BaseLineZones.js +11 -31
  17. package/lib/component/1d/utilities/intersectionResolver.d.ts +25 -0
  18. package/lib/component/1d/utilities/intersectionResolver.js +71 -0
  19. package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js +3 -2
  20. package/lib/component/2d/SlicingView.js +1 -1
  21. package/lib/component/2d/ft/Contours.js +1 -1
  22. package/lib/component/EventsTrackers/KeysListenerTracker.d.ts +5 -1
  23. package/lib/component/EventsTrackers/KeysListenerTracker.js +47 -6
  24. package/lib/component/assignment/index.d.ts +6 -1
  25. package/lib/component/assignment/index.js +5 -1
  26. package/lib/component/context/DispatchContext.d.ts +1 -2
  27. package/lib/component/context/KeyModifierContext.d.ts +13 -0
  28. package/lib/component/context/KeyModifierContext.js +39 -0
  29. package/lib/component/context/PreferencesContext.d.ts +39 -39
  30. package/lib/component/elements/Button.js +2 -0
  31. package/lib/component/elements/NumberInput.d.ts +1 -0
  32. package/lib/component/elements/NumberInput.js +10 -3
  33. package/lib/component/elements/formik/FormikOnChange.js +1 -1
  34. package/lib/component/elements/popup/Modal/ConfirmDialog.js +1 -1
  35. package/lib/component/header/ApodizationOptionsPanel.js +23 -14
  36. package/lib/component/header/BaseLineCorrectionPanel.js +31 -10
  37. package/lib/component/header/Header.d.ts +10 -3
  38. package/lib/component/header/Header.js +5 -5
  39. package/lib/component/header/ZeroFillingOptionsPanel.js +37 -31
  40. package/lib/component/highlight/index.d.ts +1 -0
  41. package/lib/component/highlight/index.js +1 -0
  42. package/lib/component/hooks/useActiveSpectrumPeaksViewState.js +1 -0
  43. package/lib/component/hooks/useCheckToolsVisibility.js +7 -3
  44. package/lib/component/hooks/useResizerStatus.d.ts +2 -0
  45. package/lib/component/hooks/useResizerStatus.js +7 -0
  46. package/lib/component/hooks/useSpectrum.js +1 -1
  47. package/lib/component/main/ErrorOverlay.js +20 -0
  48. package/lib/component/main/InnerNMRium.d.ts +7 -0
  49. package/lib/component/main/InnerNMRium.js +52 -0
  50. package/lib/component/main/InnerNMRiumContents.d.ts +14 -0
  51. package/lib/component/main/InnerNMRiumContents.js +89 -0
  52. package/lib/component/main/NMRium.d.ts +23 -0
  53. package/lib/component/main/NMRium.js +13 -0
  54. package/lib/component/main/NMRiumStateProvider.d.ts +9 -0
  55. package/lib/component/main/NMRiumStateProvider.js +74 -0
  56. package/lib/component/{SplitPaneWrapper.js → main/SplitPaneWrapper.js} +1 -1
  57. package/lib/component/main/StateError.d.ts +4 -0
  58. package/lib/component/main/StateError.js +16 -0
  59. package/lib/component/main/index.d.ts +3 -0
  60. package/lib/component/main/index.js +3 -0
  61. package/lib/component/main/types.d.ts +18 -0
  62. package/lib/component/main/types.js +2 -0
  63. package/lib/component/modal/PredictSpectraModal.js +1 -1
  64. package/lib/component/modal/changeSum/ChangeSumModal.d.ts +5 -16
  65. package/lib/component/modal/changeSum/ChangeSumModal.js +6 -115
  66. package/lib/component/modal/changeSum/ChangeSumModalContents.d.ts +18 -0
  67. package/lib/component/modal/changeSum/ChangeSumModalContents.js +94 -0
  68. package/lib/component/modal/setting/GeneralSettings.js +2 -2
  69. package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.d.ts +1 -1
  70. package/lib/component/panels/IntegralsPanel/IntegralPanel.js +6 -11
  71. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +2 -4
  72. package/lib/component/panels/MoleculesPanel/Utilities.d.ts +3 -9
  73. package/lib/component/panels/MoleculesPanel/Utilities.js +14 -10
  74. package/lib/component/panels/MoleculesPanel/useAtomAssignment.d.ts +3 -3
  75. package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +4 -4
  76. package/lib/component/panels/PeaksPanel/PeaksPanel.js +11 -5
  77. package/lib/component/panels/RangesPanel/RangesHeader.js +6 -10
  78. package/lib/component/panels/SpectrumsPanel/base/ShowHideSpectrumButton.js +1 -1
  79. package/lib/component/panels/SummaryPanel/SummaryPanel.js +4 -3
  80. package/lib/component/panels/ZonesPanel/ZonesPanel.js +3 -2
  81. package/lib/component/panels/ZonesPanel/ZonesPreferences.js +1 -1
  82. package/lib/component/panels/header/DefaultPanelHeader.d.ts +3 -4
  83. package/lib/component/panels/header/DefaultPanelHeader.js +9 -5
  84. package/lib/component/panels/predictionPanel/PredictionPanel.js +1 -1
  85. package/lib/component/panels/predictionPanel/PredictionSimpleOptions.js +0 -1
  86. package/lib/component/panels/spectrumSimulation/SpectrumSimulation.js +1 -1
  87. package/lib/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +1 -2
  88. package/lib/component/reducer/IgnoreActions.js +0 -1
  89. package/lib/component/reducer/Reducer.d.ts +1 -6
  90. package/lib/component/reducer/Reducer.js +30 -6
  91. package/lib/component/reducer/actions/FiltersActions.d.ts +32 -11
  92. package/lib/component/reducer/actions/FiltersActions.js +96 -28
  93. package/lib/component/reducer/actions/IntegralsActions.d.ts +6 -2
  94. package/lib/component/reducer/actions/IntegralsActions.js +44 -20
  95. package/lib/component/reducer/actions/MoleculeActions.js +1 -1
  96. package/lib/component/reducer/actions/PeaksActions.d.ts +6 -4
  97. package/lib/component/reducer/actions/PeaksActions.js +19 -1
  98. package/lib/component/reducer/actions/RangesActions.d.ts +6 -2
  99. package/lib/component/reducer/actions/RangesActions.js +31 -3
  100. package/lib/component/reducer/preferences/preferencesReducer.d.ts +1 -1
  101. package/lib/component/reducer/preferences/utilities/getPreferencesByWorkspace.d.ts +1 -1
  102. package/lib/component/toolbar/FunctionToolBar.js +13 -3
  103. package/lib/component/toolbar/ToolTypes.d.ts +1 -0
  104. package/lib/component/toolbar/ToolTypes.js +36 -0
  105. package/lib/component/utility/export.js +7 -4
  106. package/lib/component/utility/filterType.d.ts +3 -0
  107. package/lib/component/utility/filterType.js +1 -0
  108. package/lib/component/workspaces/basic.js +2 -0
  109. package/lib/component/workspaces/embedded.js +2 -0
  110. package/lib/component/workspaces/exercise.js +2 -0
  111. package/lib/component/workspaces/prediction.js +9 -0
  112. package/lib/component/workspaces/process1D.js +2 -0
  113. package/lib/component/workspaces/workspaceDefaultProperties.js +2 -0
  114. package/lib/data/PredictionManager.d.ts +3 -3
  115. package/lib/data/PredictionManager.js +10 -10
  116. package/lib/data/data1d/Spectrum1D/ranges/addRange.d.ts +1 -2
  117. package/lib/data/data1d/Spectrum1D/ranges/addRange.js +2 -8
  118. package/lib/data/molecules/Molecule.js +2 -2
  119. package/lib/data/utilities/checkModifierKeyActivated.d.ts +1 -1
  120. package/lib/data/utilities/checkModifierKeyActivated.js +8 -13
  121. package/lib/versionInfo.js +1 -1
  122. package/lib-cjs/component/1d/ApodizationLine.js +1 -1
  123. package/lib-cjs/component/1d/Chart1D.js +3 -2
  124. package/lib-cjs/component/1d/Line.js +1 -1
  125. package/lib-cjs/component/1d/Viewer1D.js +15 -3
  126. package/lib-cjs/component/1d/integral/IntegralResizable.js +4 -3
  127. package/lib-cjs/component/1d/multiAnalysis/AnalysisRange.js +3 -1
  128. package/lib-cjs/component/1d/peaks/PeakAnnotations.js +19 -24
  129. package/lib-cjs/component/1d/peaks/PeakAnnotationsSpreadMode.js +64 -0
  130. package/lib-cjs/component/1d/peaks/PeakEditionManager.js +129 -0
  131. package/lib-cjs/component/1d/peaks/Peaks.js +29 -0
  132. package/lib-cjs/component/1d/ranges/Range.js +3 -1
  133. package/lib-cjs/component/1d/tool/BaseLineZones.js +11 -34
  134. package/lib-cjs/component/1d/utilities/intersectionResolver.js +75 -0
  135. package/lib-cjs/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js +3 -2
  136. package/lib-cjs/component/2d/SlicingView.js +1 -1
  137. package/lib-cjs/component/2d/ft/Contours.js +1 -1
  138. package/lib-cjs/component/EventsTrackers/KeysListenerTracker.js +46 -5
  139. package/lib-cjs/component/assignment/index.js +5 -1
  140. package/lib-cjs/component/context/KeyModifierContext.js +44 -0
  141. package/lib-cjs/component/elements/Button.js +2 -0
  142. package/lib-cjs/component/elements/NumberInput.js +12 -2
  143. package/lib-cjs/component/elements/formik/FormikOnChange.js +1 -1
  144. package/lib-cjs/component/elements/popup/Modal/ConfirmDialog.js +1 -1
  145. package/lib-cjs/component/header/ApodizationOptionsPanel.js +23 -14
  146. package/lib-cjs/component/header/BaseLineCorrectionPanel.js +30 -9
  147. package/lib-cjs/component/header/Header.js +5 -5
  148. package/lib-cjs/component/header/ZeroFillingOptionsPanel.js +35 -29
  149. package/lib-cjs/component/highlight/index.js +1 -0
  150. package/lib-cjs/component/hooks/useActiveSpectrumPeaksViewState.js +1 -0
  151. package/lib-cjs/component/hooks/useCheckToolsVisibility.js +7 -3
  152. package/lib-cjs/component/hooks/useResizerStatus.js +11 -0
  153. package/lib-cjs/component/hooks/useSpectrum.js +1 -1
  154. package/lib-cjs/component/main/ErrorOverlay.js +26 -0
  155. package/lib-cjs/component/main/InnerNMRium.js +82 -0
  156. package/lib-cjs/component/main/InnerNMRiumContents.js +96 -0
  157. package/lib-cjs/component/main/NMRium.js +19 -0
  158. package/lib-cjs/component/main/NMRiumStateProvider.js +80 -0
  159. package/lib-cjs/component/{SplitPaneWrapper.js → main/SplitPaneWrapper.js} +1 -1
  160. package/lib-cjs/component/main/StateError.js +20 -0
  161. package/lib-cjs/component/main/index.js +21 -0
  162. package/lib-cjs/component/main/types.js +3 -0
  163. package/lib-cjs/component/modal/PredictSpectraModal.js +1 -1
  164. package/lib-cjs/component/modal/changeSum/ChangeSumModal.js +6 -141
  165. package/lib-cjs/component/modal/changeSum/ChangeSumModalContents.js +124 -0
  166. package/lib-cjs/component/modal/setting/GeneralSettings.js +2 -2
  167. package/lib-cjs/component/panels/IntegralsPanel/IntegralPanel.js +29 -11
  168. package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +2 -4
  169. package/lib-cjs/component/panels/MoleculesPanel/Utilities.js +14 -10
  170. package/lib-cjs/component/panels/MoleculesPanel/useAtomAssignment.js +4 -4
  171. package/lib-cjs/component/panels/PeaksPanel/PeaksPanel.js +32 -3
  172. package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +29 -10
  173. package/lib-cjs/component/panels/SpectrumsPanel/base/ShowHideSpectrumButton.js +1 -1
  174. package/lib-cjs/component/panels/SummaryPanel/SummaryPanel.js +27 -3
  175. package/lib-cjs/component/panels/ZonesPanel/ZonesPanel.js +26 -2
  176. package/lib-cjs/component/panels/ZonesPanel/ZonesPreferences.js +1 -1
  177. package/lib-cjs/component/panels/header/DefaultPanelHeader.js +11 -5
  178. package/lib-cjs/component/panels/predictionPanel/PredictionPanel.js +1 -1
  179. package/lib-cjs/component/panels/predictionPanel/PredictionSimpleOptions.js +0 -1
  180. package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulation.js +1 -1
  181. package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +1 -2
  182. package/lib-cjs/component/reducer/IgnoreActions.js +0 -1
  183. package/lib-cjs/component/reducer/Reducer.js +29 -5
  184. package/lib-cjs/component/reducer/actions/FiltersActions.js +98 -28
  185. package/lib-cjs/component/reducer/actions/IntegralsActions.js +45 -20
  186. package/lib-cjs/component/reducer/actions/MoleculeActions.js +1 -1
  187. package/lib-cjs/component/reducer/actions/PeaksActions.js +20 -1
  188. package/lib-cjs/component/reducer/actions/RangesActions.js +31 -2
  189. package/lib-cjs/component/toolbar/FunctionToolBar.js +13 -3
  190. package/lib-cjs/component/toolbar/ToolTypes.js +36 -0
  191. package/lib-cjs/component/utility/export.js +7 -4
  192. package/lib-cjs/component/utility/filterType.js +2 -0
  193. package/lib-cjs/component/workspaces/basic.js +2 -0
  194. package/lib-cjs/component/workspaces/embedded.js +2 -0
  195. package/lib-cjs/component/workspaces/exercise.js +2 -0
  196. package/lib-cjs/component/workspaces/prediction.js +9 -0
  197. package/lib-cjs/component/workspaces/process1D.js +2 -0
  198. package/lib-cjs/component/workspaces/workspaceDefaultProperties.js +2 -0
  199. package/lib-cjs/data/PredictionManager.js +9 -9
  200. package/lib-cjs/data/data1d/Spectrum1D/ranges/addRange.js +1 -7
  201. package/lib-cjs/data/molecules/Molecule.js +2 -2
  202. package/lib-cjs/data/utilities/checkModifierKeyActivated.js +8 -13
  203. package/lib-cjs/versionInfo.js +1 -1
  204. package/package.json +26 -25
  205. package/lib/component/1d/peaks/PeakAnnotation.d.ts +0 -12
  206. package/lib/component/1d/peaks/PeakAnnotation.js +0 -116
  207. package/lib/component/ErrorOverlay.js +0 -27
  208. package/lib/component/NMRium.d.ts +0 -42
  209. package/lib/component/NMRium.js +0 -237
  210. package/lib/component/reducer/actions/GlobalActions.d.ts +0 -9
  211. package/lib/component/reducer/actions/GlobalActions.js +0 -4
  212. package/lib-cjs/component/1d/peaks/PeakAnnotation.js +0 -118
  213. package/lib-cjs/component/ErrorOverlay.js +0 -30
  214. package/lib-cjs/component/NMRium.js +0 -267
  215. package/lib-cjs/component/reducer/actions/GlobalActions.js +0 -7
  216. /package/lib/component/{ErrorOverlay.d.ts → main/ErrorOverlay.d.ts} +0 -0
  217. /package/lib/component/{SplitPaneWrapper.d.ts → main/SplitPaneWrapper.d.ts} +0 -0
@@ -18,8 +18,9 @@ const useExport_1 = __importDefault(require("../hooks/useExport"));
18
18
  const useToolsFunctions_1 = __importDefault(require("../hooks/useToolsFunctions"));
19
19
  const Constants_1 = require("../reducer/core/Constants");
20
20
  const ToolTypes_1 = require("../toolbar/ToolTypes");
21
- function KeysListenerTracker() {
22
- const { keysPreferences, displayerMode, overDisplayer, data, view: { spectra: { activeTab }, }, } = (0, ChartContext_1.useChartData)();
21
+ function KeysListenerTracker(props) {
22
+ const { mainDivRef } = props;
23
+ const { keysPreferences, displayerMode, data, view: { spectra: { activeTab }, }, } = (0, ChartContext_1.useChartData)();
23
24
  const dispatch = (0, DispatchContext_1.useDispatch)();
24
25
  const { dispatch: dispatchPreferences } = (0, PreferencesContext_1.usePreferences)();
25
26
  const alert = (0, Alert_1.useAlert)();
@@ -29,6 +30,25 @@ function KeysListenerTracker() {
29
30
  const { saveToClipboardHandler, saveAsJSONHandler, saveAsHandler } = (0, useExport_1.default)();
30
31
  const isToolVisible = (0, useCheckToolsVisibility_1.useCheckToolsVisibility)();
31
32
  const { highlight, remove } = (0, index_1.useHighlightData)();
33
+ const mouseIsOverDisplayer = (0, react_1.useRef)(false);
34
+ (0, react_1.useEffect)(() => {
35
+ const div = mainDivRef.current;
36
+ if (!div) {
37
+ return;
38
+ }
39
+ function mouseEnterHandler() {
40
+ mouseIsOverDisplayer.current = true;
41
+ }
42
+ function mouseLeaveHandler() {
43
+ mouseIsOverDisplayer.current = false;
44
+ }
45
+ div.addEventListener('mouseenter', mouseEnterHandler);
46
+ div.addEventListener('mouseleave', mouseLeaveHandler);
47
+ return () => {
48
+ div.removeEventListener('mouseenter', mouseEnterHandler);
49
+ div.removeEventListener('mouseleave', mouseLeaveHandler);
50
+ };
51
+ }, [mainDivRef]);
32
52
  const assignmentData = (0, AssignmentsContext_1.useAssignmentData)();
33
53
  const allow1DTool = (0, react_1.useMemo)(() => {
34
54
  return displayerMode === Constants_1.DISPLAYER_MODE.DM_1D && data && data.length > 0;
@@ -175,6 +195,15 @@ function KeysListenerTracker() {
175
195
  }
176
196
  break;
177
197
  }
198
+ case index_1.HighlightEventSource.BASELINE_ZONE: {
199
+ const { id } = extra || {};
200
+ if (id) {
201
+ dispatch({ type: 'DELETE_BASE_LINE_ZONE', payload: { id } });
202
+ // remove keys from the highlighted list after delete
203
+ remove();
204
+ }
205
+ break;
206
+ }
178
207
  default:
179
208
  break;
180
209
  }
@@ -228,7 +257,6 @@ function KeysListenerTracker() {
228
257
  handleFullZoomOut();
229
258
  }
230
259
  break;
231
- case 'z':
232
260
  case 'Escape':
233
261
  if (isToolVisible('zoom')) {
234
262
  handleChangeOption(ToolTypes_1.options.zoom.id);
@@ -243,6 +271,12 @@ function KeysListenerTracker() {
243
271
  }
244
272
  break;
245
273
  }
274
+ case 'z': {
275
+ if (isToolVisible('zeroFilling')) {
276
+ handleChangeOption(ToolTypes_1.options.zeroFilling.id);
277
+ }
278
+ break;
279
+ }
246
280
  case 'a': {
247
281
  if (isToolVisible('apodization')) {
248
282
  handleChangeOption(ToolTypes_1.options.apodization.id);
@@ -252,6 +286,14 @@ function KeysListenerTracker() {
252
286
  }
253
287
  break;
254
288
  }
289
+ case 't': {
290
+ if (isToolVisible('fft')) {
291
+ dispatch({
292
+ type: 'APPLY_FFT_FILTER',
293
+ });
294
+ }
295
+ break;
296
+ }
255
297
  case 'b': {
256
298
  if (isToolVisible('baselineCorrection')) {
257
299
  handleChangeOption(ToolTypes_1.options.baselineCorrection.id);
@@ -348,7 +390,7 @@ function KeysListenerTracker() {
348
390
  saveToClipboardHandler,
349
391
  ]);
350
392
  const handleOnKeyDown = (0, react_1.useCallback)((e) => {
351
- if (checkNotInputField(e) && overDisplayer) {
393
+ if (checkNotInputField(e) && mouseIsOverDisplayer.current) {
352
394
  const num = Number(e.code.slice(-1)) || 0;
353
395
  if (num > 0) {
354
396
  keysPreferencesListenerHandler(e, num);
@@ -366,7 +408,6 @@ function KeysListenerTracker() {
366
408
  deleteHandler,
367
409
  highlight,
368
410
  keysPreferencesListenerHandler,
369
- overDisplayer,
370
411
  toolsListenerHandler,
371
412
  ]);
372
413
  (0, react_1.useEffect)(() => {
@@ -6,16 +6,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.AssignmentProvider = void 0;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const react_1 = require("react");
9
+ const ChartContext_1 = require("../context/ChartContext");
9
10
  const AssignmentsContext_1 = require("./AssignmentsContext");
10
11
  const AssignmentsReducer_1 = __importDefault(require("./AssignmentsReducer"));
11
12
  function AssignmentProvider(props) {
12
- const { spectraData: spectra, children } = props;
13
+ const { children } = props;
14
+ const { data: spectra } = (0, ChartContext_1.useChartData)();
13
15
  const [data, dispatch] = (0, react_1.useReducer)(AssignmentsReducer_1.default, AssignmentsContext_1.assignmentState);
14
16
  const state = (0, react_1.useMemo)(() => ({ data, dispatch }), [data]);
15
17
  (0, react_1.useEffect)(() => {
16
18
  if (spectra) {
17
19
  dispatch({
18
20
  type: 'INITIATE_ASSIGNMENTS',
21
+ // TODO: Fix this type error. It's been here for a long time because this component wasn't typed.
22
+ // @ts-expect-error This should be fixed.
19
23
  payload: { spectra },
20
24
  });
21
25
  }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KeyModifiersProvider = exports.useKeyModifiers = exports.KeyModifierContext = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const defaultKeyModifiersState = {
7
+ ctrlKey: false,
8
+ shiftKey: false,
9
+ altKey: false,
10
+ };
11
+ exports.KeyModifierContext = (0, react_1.createContext)(defaultKeyModifiersState);
12
+ function useKeyModifiers() {
13
+ const context = (0, react_1.useContext)(exports.KeyModifierContext);
14
+ if (!context) {
15
+ throw new Error('key modifiers context was not found');
16
+ }
17
+ return context;
18
+ }
19
+ exports.useKeyModifiers = useKeyModifiers;
20
+ const isMac = navigator !== undefined && navigator.userAgent.toLowerCase().includes('mac');
21
+ function getModifiers(event) {
22
+ const { shiftKey, altKey, metaKey } = event;
23
+ const ctrlKey = isMac ? metaKey : event.ctrlKey;
24
+ return { ctrlKey, shiftKey, altKey };
25
+ }
26
+ function KeyModifiersProvider({ children }) {
27
+ const [modifiers, setModifiers] = (0, react_1.useState)(defaultKeyModifiersState);
28
+ (0, react_1.useEffect)(() => {
29
+ function handleKeyDown(event) {
30
+ setModifiers(getModifiers(event));
31
+ }
32
+ function handleKeyUp(event) {
33
+ setModifiers(getModifiers(event));
34
+ }
35
+ document.addEventListener('keydown', handleKeyDown);
36
+ document.addEventListener('keyup', handleKeyUp);
37
+ return () => {
38
+ document.removeEventListener('keydown', handleKeyDown);
39
+ document.removeEventListener('keyup', handleKeyUp);
40
+ };
41
+ }, []);
42
+ return ((0, jsx_runtime_1.jsx)(exports.KeyModifierContext.Provider, { value: modifiers, children: children }));
43
+ }
44
+ exports.KeyModifiersProvider = KeyModifiersProvider;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
4
+ //TODO resolve the eslint rules
5
+ /* eslint-disable react/no-unused-prop-types */
4
6
  /** @jsxImportSource @emotion/react */
5
7
  const react_1 = require("@emotion/react");
6
8
  const fa_1 = require("react-icons/fa");
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  const jsx_runtime_1 = require("react/jsx-runtime");
4
7
  const react_1 = require("react");
8
+ const useCombinedRefs_1 = __importDefault(require("../hooks/useCombinedRefs"));
5
9
  const inputStyle = {
6
10
  height: '100%',
7
11
  width: '100px',
@@ -9,7 +13,13 @@ const inputStyle = {
9
13
  border: '0.55px solid #c7c7c7',
10
14
  textAlign: 'center',
11
15
  };
12
- const NumberInput = (0, react_1.forwardRef)(({ name, value: valueProp, style = {}, onChange, pattern = '^\\d*.\\d*$', step = 'any', min = 'any', max = 'any', ...otherProps }, ref) => {
13
- return ((0, jsx_runtime_1.jsx)("input", { ref: ref, name: name, style: { ...inputStyle, ...style }, type: "number", pattern: pattern, value: valueProp, step: step, onChange: onChange, min: min, max: max, ...otherProps }));
16
+ const NumberInput = (0, react_1.forwardRef)(({ name, value: valueProp, style = {}, onChange, pattern = '^\\d*.\\d*$', step = 'any', min = 'any', max = 'any', autoSelect = false, ...otherProps }, ref) => {
17
+ const combinedRef = (0, useCombinedRefs_1.default)([ref]);
18
+ (0, react_1.useEffect)(() => {
19
+ if (autoSelect) {
20
+ combinedRef?.current?.select();
21
+ }
22
+ }, [autoSelect, combinedRef]);
23
+ return ((0, jsx_runtime_1.jsx)("input", { ref: combinedRef, name: name, style: { ...inputStyle, ...style }, type: "number", pattern: pattern, value: valueProp, step: step, onChange: onChange, min: min, max: max, ...otherProps }));
14
24
  });
15
25
  exports.default = NumberInput;
@@ -21,7 +21,7 @@ const FormikOnChange = (props) => {
21
21
  debounceOnChange.current(values);
22
22
  }
23
23
  else {
24
- setTouched(errors);
24
+ void setTouched(errors);
25
25
  }
26
26
  }
27
27
  else {
@@ -62,6 +62,6 @@ function ConfirmationDialog({ style = {}, buttons = [], onClose, message, render
62
62
  onClose();
63
63
  }
64
64
  }, [onClose]);
65
- return ((0, jsx_runtime_1.jsxs)("div", { style: style, css: styles, "data-test-id": id, children: [render ? (render({ message, className: 'message' })) : ((0, jsx_runtime_1.jsx)("p", { className: "message", children: message })), (0, jsx_runtime_1.jsx)("div", { className: "buttons-container", children: buttons.map((option) => ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: (e) => optionsHandler(e, option), style: option.style && option.style, children: option.text }, option.text))) })] }));
65
+ return ((0, jsx_runtime_1.jsxs)("div", { style: style, css: styles, "data-testid": id, children: [render ? (render({ message, className: 'message' })) : ((0, jsx_runtime_1.jsx)("p", { className: "message", children: message })), (0, jsx_runtime_1.jsx)("div", { className: "buttons-container", children: buttons.map((option) => ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: (e) => optionsHandler(e, option), style: option.style && option.style, children: option.text }, option.text))) })] }));
66
66
  }
67
67
  exports.default = ConfirmationDialog;
@@ -56,21 +56,30 @@ const initialValues = {
56
56
  };
57
57
  function ApodizationOptionsInnerPanel(props) {
58
58
  const dispatch = (0, DispatchContext_1.useDispatch)();
59
- const formRef = (0, react_1.useRef)(null);
59
+ const previousPreviewRef = (0, react_1.useRef)(initialValues.livePreview);
60
60
  function handleApplyFilter(values, triggerSource = 'apply') {
61
- const { livePreview, ...filterOptions } = values;
62
- if (livePreview && triggerSource === 'onChange') {
63
- dispatch({
64
- type: 'CALCULATE_APODIZATION_FILTER',
65
- payload: filterOptions,
66
- });
67
- }
68
- else if (triggerSource === 'apply') {
69
- dispatch({
70
- type: 'APPLY_APODIZATION_FILTER',
71
- payload: filterOptions,
72
- });
61
+ const { livePreview, ...options } = values;
62
+ switch (triggerSource) {
63
+ case 'onChange': {
64
+ if (livePreview || previousPreviewRef.current !== livePreview) {
65
+ dispatch({
66
+ type: 'CALCULATE_APODIZATION_FILTER',
67
+ payload: { livePreview, options },
68
+ });
69
+ }
70
+ break;
71
+ }
72
+ case 'apply': {
73
+ dispatch({
74
+ type: 'APPLY_APODIZATION_FILTER',
75
+ payload: { options },
76
+ });
77
+ break;
78
+ }
79
+ default:
80
+ break;
73
81
  }
82
+ previousPreviewRef.current = livePreview;
74
83
  }
75
84
  function handleCancelFilter() {
76
85
  dispatch({
@@ -81,7 +90,7 @@ function ApodizationOptionsInnerPanel(props) {
81
90
  if (props.filter) {
82
91
  formData = { ...initialValues, ...props.filter.value, livePreview: true };
83
92
  }
84
- return ((0, jsx_runtime_1.jsxs)(HeaderContainer_1.HeaderContainer, { children: [(0, jsx_runtime_1.jsx)(formik_1.Formik, { innerRef: formRef, onSubmit: (values) => handleApplyFilter(values), initialValues: formData, validationSchema: validationSchema, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Label_1.default, { title: "Line broadening : ", shortTitle: "LB :", style: Header_1.headerLabelStyle, children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { type: "number", name: "lineBroadening", min: 0, max: 1, style: inputStyle, debounceTime: 250 }) }), (0, jsx_runtime_1.jsx)(Label_1.default, { title: "Gauss broadening :", shortTitle: "GB :", style: Header_1.headerLabelStyle, children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { type: "number", name: "gaussBroadening", min: 0, max: 1, style: inputStyle, debounceTime: 250 }) }), (0, jsx_runtime_1.jsx)(Label_1.default, { title: "lineBroadeningCenter [0 - 1] : ", shortTitle: "LB Center :", style: Header_1.headerLabelStyle, children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { type: "number", name: "lineBroadeningCenter", min: 0, max: 1, style: inputStyle, debounceTime: 250 }) }), (0, jsx_runtime_1.jsx)(Label_1.default, { title: "Live preview ", htmlFor: "livePreview", style: { label: { padding: '0 5px' } }, children: (0, jsx_runtime_1.jsx)(FormikCheckBox_1.default, { name: "livePreview" }) }), (0, jsx_runtime_1.jsx)(FormikOnChange_1.default, { onChange: (values) => handleApplyFilter(values, 'onChange'), enableOnload: true })] }) }), (0, jsx_runtime_1.jsx)(ActionButtons_1.default, { onDone: () => formRef.current?.submitForm(), onCancel: handleCancelFilter })] }));
93
+ return ((0, jsx_runtime_1.jsx)(HeaderContainer_1.HeaderContainer, { children: (0, jsx_runtime_1.jsx)(formik_1.Formik, { onSubmit: (values) => handleApplyFilter(values), initialValues: formData, validationSchema: validationSchema, children: ({ submitForm }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Label_1.default, { title: "Line broadening : ", shortTitle: "LB :", style: Header_1.headerLabelStyle, children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { type: "number", name: "lineBroadening", min: 0, max: 1, style: inputStyle, debounceTime: 250 }) }), (0, jsx_runtime_1.jsx)(Label_1.default, { title: "Gauss broadening :", shortTitle: "GB :", style: Header_1.headerLabelStyle, children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { type: "number", name: "gaussBroadening", min: 0, max: 1, style: inputStyle, debounceTime: 250 }) }), (0, jsx_runtime_1.jsx)(Label_1.default, { title: "lineBroadeningCenter [0 - 1] : ", shortTitle: "LB Center :", style: Header_1.headerLabelStyle, children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { type: "number", name: "lineBroadeningCenter", min: 0, max: 1, style: inputStyle, debounceTime: 250 }) }), (0, jsx_runtime_1.jsx)(Label_1.default, { title: "Live preview ", htmlFor: "livePreview", style: { label: { padding: '0 5px' } }, children: (0, jsx_runtime_1.jsx)(FormikCheckBox_1.default, { name: "livePreview" }) }), (0, jsx_runtime_1.jsx)(FormikOnChange_1.default, { onChange: (values) => handleApplyFilter(values, 'onChange'), enableOnload: true }), (0, jsx_runtime_1.jsx)(ActionButtons_1.default, { onDone: submitForm, onCancel: handleCancelFilter })] })) }) }));
85
94
  }
86
95
  const MemoizedApodizationPanel = (0, react_1.memo)(ApodizationOptionsInnerPanel);
87
96
  function ApodizationOptionsPanel() {
@@ -93,16 +93,37 @@ const formData = (algorithm, filterValues) => {
93
93
  };
94
94
  function BaseLineCorrectionInnerPanel(props) {
95
95
  const dispatch = (0, DispatchContext_1.useDispatch)();
96
- const formRef = (0, react_1.useRef)(null);
96
+ const previousPreviewRef = (0, react_1.useRef)(true);
97
97
  const { algorithm: baseAlgorithm = 'polynomial' } = props?.filter?.value || {};
98
98
  const [algorithm, setAlgorithm] = (0, react_1.useState)(baseAlgorithm);
99
99
  const handleApplyFilter = (values, triggerSource = 'apply') => {
100
- dispatch({
101
- type: triggerSource === 'onChange'
102
- ? 'CALCULATE_BASE_LINE_CORRECTION_FILTER'
103
- : 'APPLY_BASE_LINE_CORRECTION_FILTER',
104
- payload: values,
105
- });
100
+ const { livePreview, ...options } = values;
101
+ switch (triggerSource) {
102
+ case 'onChange': {
103
+ if (livePreview || previousPreviewRef !== livePreview) {
104
+ dispatch({
105
+ type: 'CALCULATE_BASE_LINE_CORRECTION_FILTER',
106
+ payload: {
107
+ options,
108
+ livePreview,
109
+ },
110
+ });
111
+ }
112
+ break;
113
+ }
114
+ case 'apply': {
115
+ dispatch({
116
+ type: 'APPLY_BASE_LINE_CORRECTION_FILTER',
117
+ payload: {
118
+ options,
119
+ },
120
+ });
121
+ break;
122
+ }
123
+ default:
124
+ break;
125
+ }
126
+ previousPreviewRef.current = livePreview;
106
127
  };
107
128
  const handleCancelFilter = () => {
108
129
  dispatch({
@@ -113,8 +134,8 @@ function BaseLineCorrectionInnerPanel(props) {
113
134
  setAlgorithm(selectedAlgorithm);
114
135
  }
115
136
  const form = formData(algorithm, props?.filter?.value || {});
116
- return ((0, jsx_runtime_1.jsxs)(HeaderContainer_1.HeaderContainer, { children: [(0, jsx_runtime_1.jsx)(Label_1.default, { title: "Algorithm: ", style: Header_1.headerLabelStyle, children: (0, jsx_runtime_1.jsx)(Select_1.default, { items: getAlgorithmsList(), value: algorithm, onChange: handleChangeAlgorithm }) }), (0, jsx_runtime_1.jsx)(formik_1.Formik, { innerRef: formRef, onSubmit: (values) => handleApplyFilter(values), initialValues: form.values, validationSchema: form.validation, enableReinitialize: true, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [algorithm && algorithm === 'airpls' && ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex' }, children: [(0, jsx_runtime_1.jsx)(Label_1.default, { title: "maxIterations:", style: Header_1.headerLabelStyle, children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { type: "number", name: "maxIterations", debounceTime: 250, style: inputStyle }) }), (0, jsx_runtime_1.jsx)(Label_1.default, { title: "tolerance:", style: Header_1.headerLabelStyle, children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { type: "number", name: "tolerance", debounceTime: 250, style: inputStyle }) })] })), algorithm &&
117
- ['autoPolynomial', 'polynomial'].includes(algorithm) && ((0, jsx_runtime_1.jsx)(Label_1.default, { title: "degree [ 1 - 6 ]:", shortTitle: "degree :", style: Header_1.headerLabelStyle, children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { type: "number", name: "degree", min: 1, max: 6, style: inputStyle, debounceTime: 250 }) })), (0, jsx_runtime_1.jsx)(Label_1.default, { title: "live preview ", htmlFor: "livePreview", style: Header_1.headerLabelStyle, children: (0, jsx_runtime_1.jsx)(FormikCheckBox_1.default, { name: "livePreview" }) }), (0, jsx_runtime_1.jsx)(FormikOnChange_1.default, { onChange: (values) => handleApplyFilter(values, 'onChange'), enableOnload: true })] }) }), (0, jsx_runtime_1.jsx)(ActionButtons_1.default, { onDone: () => formRef.current?.submitForm(), onCancel: handleCancelFilter })] }));
137
+ return ((0, jsx_runtime_1.jsxs)(HeaderContainer_1.HeaderContainer, { children: [(0, jsx_runtime_1.jsx)(Label_1.default, { title: "Algorithm: ", style: Header_1.headerLabelStyle, children: (0, jsx_runtime_1.jsx)(Select_1.default, { items: getAlgorithmsList(), value: algorithm, onChange: handleChangeAlgorithm }) }), (0, jsx_runtime_1.jsx)(formik_1.Formik, { onSubmit: (values) => handleApplyFilter(values), initialValues: form.values, validationSchema: form.validation, enableReinitialize: true, children: ({ submitForm }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [algorithm && algorithm === 'airpls' && ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex' }, children: [(0, jsx_runtime_1.jsx)(Label_1.default, { title: "maxIterations:", style: Header_1.headerLabelStyle, children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { type: "number", name: "maxIterations", debounceTime: 250, style: inputStyle }) }), (0, jsx_runtime_1.jsx)(Label_1.default, { title: "tolerance:", style: Header_1.headerLabelStyle, children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { type: "number", name: "tolerance", debounceTime: 250, style: inputStyle }) })] })), algorithm &&
138
+ ['autoPolynomial', 'polynomial'].includes(algorithm) && ((0, jsx_runtime_1.jsx)(Label_1.default, { title: "degree [ 1 - 6 ]:", shortTitle: "degree :", style: Header_1.headerLabelStyle, children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { type: "number", name: "degree", min: 1, max: 6, style: inputStyle, debounceTime: 250 }) })), (0, jsx_runtime_1.jsx)(Label_1.default, { title: "live preview ", htmlFor: "livePreview", style: Header_1.headerLabelStyle, children: (0, jsx_runtime_1.jsx)(FormikCheckBox_1.default, { name: "livePreview" }) }), (0, jsx_runtime_1.jsx)(FormikOnChange_1.default, { onChange: (values) => handleApplyFilter(values, 'onChange'), enableOnload: true }), (0, jsx_runtime_1.jsx)(ActionButtons_1.default, { onDone: submitForm, onCancel: handleCancelFilter })] })) })] }));
118
139
  }
119
140
  const MemoizedBaseLineCorrectionPanel = (0, react_1.memo)(BaseLineCorrectionInnerPanel);
120
141
  function BaseLineCorrectionPanel() {
@@ -67,7 +67,7 @@ const styles = (0, react_1.css) `
67
67
  }
68
68
  `;
69
69
  function HeaderInner(props) {
70
- const { isFullscreen, onMaximize = () => null, selectedOptionPanel, height, } = props;
70
+ const { isFullscreenEnabled, onEnableFullscreen, selectedOptionPanel, height, } = props;
71
71
  const { current: { display: { general }, }, workspace, dispatch, } = (0, PreferencesContext_1.usePreferences)();
72
72
  const workspacesList = (0, PreferencesContext_1.useWorkspacesList)();
73
73
  const hideGeneralSettings = !!(general?.hideGeneralSettings && workspace.base);
@@ -106,7 +106,7 @@ function HeaderInner(props) {
106
106
  alignItems: 'center',
107
107
  }, children: [(0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(ui_1.Toolbar, { orientation: "horizontal", children: (0, jsx_runtime_1.jsx)(AboutUsModal_1.default, {}) }) }), (0, jsx_runtime_1.jsx)("div", { className: "toolOptionsPanel", style: { flex: 1 }, children: selectedPanel })] }), (0, jsx_runtime_1.jsxs)(HeaderContainer_1.HeaderContainer, { style: {
108
108
  alignItems: 'center',
109
- }, children: [!hideGeneralSettings && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(DropDownButton_1.default, { data: workspacesList, selectedKey: workspace.current, onSelect: changeWorkspaceHandler, renderItem: renderItem }), (0, jsx_runtime_1.jsx)(SaveButton, {})] })), !general?.hideLogs && (0, jsx_runtime_1.jsx)(LogsHistoryModal_1.LogsHistoryModal, {}), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)(ui_1.Toolbar, { orientation: "horizontal", children: [(0, jsx_runtime_1.jsx)(ui_1.Toolbar.Item, { id: "user-manual", title: "User manual", onClick: () => window.open(constants_1.docsBaseUrl, '_blank'), children: (0, jsx_runtime_1.jsx)(fa_1.FaQuestionCircle, {}) }), !hideGeneralSettings && ((0, jsx_runtime_1.jsx)(GeneralSettings_1.default, { height: height / 2 })), !isFullscreen && ((0, jsx_runtime_1.jsx)(ui_1.Toolbar.Item, { id: "full-screen", onClick: onMaximize, title: "Full Screen", className: "windowButton", children: (0, jsx_runtime_1.jsx)(fa_1.FaRegWindowMaximize, {}) }))] }) })] })] }) }));
109
+ }, children: [!hideGeneralSettings && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(DropDownButton_1.default, { data: workspacesList, selectedKey: workspace.current, onSelect: changeWorkspaceHandler, renderItem: renderItem }), (0, jsx_runtime_1.jsx)(SaveButton, {})] })), !general?.hideLogs && (0, jsx_runtime_1.jsx)(LogsHistoryModal_1.LogsHistoryModal, {}), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)(ui_1.Toolbar, { orientation: "horizontal", children: [(0, jsx_runtime_1.jsx)(ui_1.Toolbar.Item, { id: "user-manual", title: "User manual", onClick: () => window.open(constants_1.docsBaseUrl, '_blank'), children: (0, jsx_runtime_1.jsx)(fa_1.FaQuestionCircle, {}) }), !hideGeneralSettings && ((0, jsx_runtime_1.jsx)(GeneralSettings_1.default, { height: height / 2 })), !isFullscreenEnabled && ((0, jsx_runtime_1.jsx)(ui_1.Toolbar.Item, { id: "full-screen", onClick: onEnableFullscreen, title: "Full Screen", className: "windowButton", children: (0, jsx_runtime_1.jsx)(fa_1.FaRegWindowMaximize, {}) }))] }) })] })] }) }));
110
110
  }
111
111
  function SaveButton() {
112
112
  const { workspace, workspaces, originalWorkspaces } = (0, PreferencesContext_1.usePreferences)();
@@ -123,11 +123,11 @@ function SaveButton() {
123
123
  }), toolTip: "Save workspace locally in the browser", children: (0, jsx_runtime_1.jsx)(fa_1.FaRegSave, {}) }), (0, jsx_runtime_1.jsx)(SaveSettingsModal, {})] }));
124
124
  }
125
125
  const MemoizedHeader = (0, react_2.memo)(HeaderInner);
126
- function HeaderWrapper({ isFullscreen, onMaximize }) {
126
+ function HeaderWrapper({ isFullscreenEnabled, onEnableFullscreen, }) {
127
127
  const { toolOptions: { selectedOptionPanel }, height, } = (0, ChartContext_1.useChartData)();
128
128
  return ((0, jsx_runtime_1.jsx)(MemoizedHeader, { selectedOptionPanel,
129
- isFullscreen,
130
- onMaximize,
129
+ isFullscreenEnabled,
130
+ onEnableFullscreen,
131
131
  height }));
132
132
  }
133
133
  exports.default = HeaderWrapper;
@@ -6,16 +6,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const jsx_runtime_1 = require("react/jsx-runtime");
7
7
  const nmr_processing_1 = require("nmr-processing");
8
8
  const react_1 = require("react");
9
- const ui_1 = require("react-science/ui");
10
9
  const generateNumbersPowerOfX_1 = __importDefault(require("../../data/utilities/generateNumbersPowerOfX"));
11
10
  const DispatchContext_1 = require("../context/DispatchContext");
12
11
  const ActionButtons_1 = __importDefault(require("../elements/ActionButtons"));
13
12
  const Label_1 = __importDefault(require("../elements/Label"));
14
- const Select_1 = __importDefault(require("../elements/Select"));
15
13
  const useFilter_1 = require("../hooks/useFilter");
16
14
  const useSpectrum_1 = __importDefault(require("../hooks/useSpectrum"));
17
15
  const Header_1 = require("./Header");
18
16
  const HeaderContainer_1 = require("./HeaderContainer");
17
+ const formik_1 = require("formik");
18
+ const FormikSelect_1 = __importDefault(require("../elements/formik/FormikSelect"));
19
+ const FormikCheckBox_1 = __importDefault(require("../elements/formik/FormikCheckBox"));
20
+ const FormikOnChange_1 = __importDefault(require("../elements/formik/FormikOnChange"));
19
21
  const Sizes = (0, generateNumbersPowerOfX_1.default)(8, 21);
20
22
  function useInitZeroFillingSize() {
21
23
  const filter = (0, useFilter_1.useFilter)(nmr_processing_1.Filters.zeroFilling.id);
@@ -29,40 +31,44 @@ function useInitZeroFillingSize() {
29
31
  return 0;
30
32
  }
31
33
  function ZeroFillingOptionsInnerPanel(props) {
34
+ const { size } = props;
32
35
  const dispatch = (0, DispatchContext_1.useDispatch)();
33
- const [livePreview, setLivePreview] = (0, react_1.useState)(true);
34
- const [size, setSize] = (0, react_1.useState)(props.size);
35
- function handleApplyFilter() {
36
- dispatch({
37
- type: 'APPLY_ZERO_FILLING_FILTER',
38
- payload: {
39
- nbPoints: size,
40
- },
41
- });
36
+ const previousPreviewRef = (0, react_1.useRef)(true);
37
+ function handleApplyFilter(values, triggerSource = 'apply') {
38
+ const { livePreview, ...options } = values;
39
+ switch (triggerSource) {
40
+ case 'onChange': {
41
+ if (livePreview || previousPreviewRef !== livePreview) {
42
+ dispatch({
43
+ type: 'CALCULATE_ZERO_FILLING_FILTER',
44
+ payload: {
45
+ options,
46
+ livePreview,
47
+ },
48
+ });
49
+ }
50
+ break;
51
+ }
52
+ case 'apply': {
53
+ dispatch({
54
+ type: 'APPLY_ZERO_FILLING_FILTER',
55
+ payload: {
56
+ options,
57
+ },
58
+ });
59
+ break;
60
+ }
61
+ default:
62
+ break;
63
+ }
64
+ previousPreviewRef.current = livePreview;
42
65
  }
43
66
  function handleCancelFilter() {
44
67
  dispatch({
45
68
  type: 'RESET_SELECTED_TOOL',
46
69
  });
47
70
  }
48
- function dispatchLiveChanges(nbPoints) {
49
- dispatch({
50
- type: 'CALCULATE_ZERO_FILLING_FILTER',
51
- payload: {
52
- nbPoints,
53
- },
54
- });
55
- }
56
- function handleChangeSizeHandler(value) {
57
- setSize(value);
58
- }
59
- (0, react_1.useEffect)(() => {
60
- if (livePreview && size) {
61
- dispatchLiveChanges(size);
62
- }
63
- // eslint-disable-next-line react-hooks/exhaustive-deps
64
- }, [size, livePreview]);
65
- return ((0, jsx_runtime_1.jsxs)(HeaderContainer_1.HeaderContainer, { children: [(0, jsx_runtime_1.jsx)(Label_1.default, { title: "Size: ", style: Header_1.headerLabelStyle, children: (0, jsx_runtime_1.jsx)(Select_1.default, { items: Sizes, style: { marginLeft: 10, marginRight: 10 }, value: size, onChange: handleChangeSizeHandler }) }), (0, jsx_runtime_1.jsx)(ui_1.Checkbox, { label: "Live preview", checked: livePreview, onChange: setLivePreview }), (0, jsx_runtime_1.jsx)(ActionButtons_1.default, { onDone: handleApplyFilter, onCancel: handleCancelFilter })] }));
71
+ return ((0, jsx_runtime_1.jsx)(HeaderContainer_1.HeaderContainer, { children: (0, jsx_runtime_1.jsx)(formik_1.Formik, { onSubmit: (values) => handleApplyFilter(values), initialValues: { nbPoints: size, livePreview: true }, children: ({ submitForm }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Label_1.default, { title: "Size: ", style: Header_1.headerLabelStyle, children: (0, jsx_runtime_1.jsx)(FormikSelect_1.default, { items: Sizes, style: { marginLeft: 10, marginRight: 10 }, name: "nbPoints" }) }), (0, jsx_runtime_1.jsx)(Label_1.default, { title: "Live preview ", htmlFor: "livePreview", style: { label: { padding: '0 5px' } }, children: (0, jsx_runtime_1.jsx)(FormikCheckBox_1.default, { name: "livePreview" }) }), (0, jsx_runtime_1.jsx)(FormikOnChange_1.default, { onChange: (values) => handleApplyFilter(values, 'onChange'), enableOnload: true }), (0, jsx_runtime_1.jsx)(ActionButtons_1.default, { onDone: submitForm, onCancel: handleCancelFilter })] })) }) }));
66
72
  }
67
73
  const MemoizedZeroFillingOptionsPanel = (0, react_1.memo)(ZeroFillingOptionsInnerPanel);
68
74
  function ZeroFillingOptionsPanel() {
@@ -10,6 +10,7 @@ var HighlightEventSource;
10
10
  HighlightEventSource["SIGNAL"] = "SIGNAL";
11
11
  HighlightEventSource["RANGE"] = "RANGE";
12
12
  HighlightEventSource["ZONE"] = "ZONE";
13
+ HighlightEventSource["BASELINE_ZONE"] = "BASELINE_ZONE";
13
14
  HighlightEventSource["EXCLUSION_ZONE"] = "EXCLUSION_ZONE";
14
15
  HighlightEventSource["MATRIX_GENERATION_EXCLUSION_ZONE"] = "MATRIX_GENERATION_EXCLUSION_ZONE";
15
16
  HighlightEventSource["MULTIPLE_ANALYSIS_ZONE"] = "MULTIPLE_ANALYSIS_ZONE";
@@ -7,6 +7,7 @@ exports.defaultPeaksViewState = {
7
7
  isPeaksVisible: true,
8
8
  showPeaksShapes: false,
9
9
  showPeaksSum: false,
10
+ displayingMode: 'spread',
10
11
  };
11
12
  function useActiveSpectrumPeaksViewState() {
12
13
  const activeSpectrum = (0, useActiveSpectrum_1.useActiveSpectrum)();
@@ -9,24 +9,28 @@ const react_1 = require("react");
9
9
  const ChartContext_1 = require("../context/ChartContext");
10
10
  const PreferencesContext_1 = require("../context/PreferencesContext");
11
11
  const ToolTypes_1 = require("../toolbar/ToolTypes");
12
+ const useCheckExperimentalFeature_1 = __importDefault(require("./useCheckExperimentalFeature"));
12
13
  const useSpectrum_1 = __importDefault(require("./useSpectrum"));
13
14
  function useCheckToolsVisibility() {
14
15
  const { displayerMode } = (0, ChartContext_1.useChartData)();
15
16
  const preferences = (0, PreferencesContext_1.usePreferences)();
16
17
  const spectrum = (0, useSpectrum_1.default)(null);
18
+ const isExperimentalFeatureActivated = (0, useCheckExperimentalFeature_1.default)();
17
19
  return (0, react_1.useCallback)((toolKey, checkOptions = {}) => {
18
20
  const { checkMode = true, checkSpectrumType = true, extraInfoCheckParameters, } = checkOptions;
21
+ const { spectraOptions, mode, isExperimental } = ToolTypes_1.options[toolKey];
19
22
  const flag = (0, get_1.default)(preferences.current, `display.toolBarButtons.${toolKey}`, false);
20
- const { spectraOptions, mode } = ToolTypes_1.options[toolKey];
21
23
  const modeFlag = !checkMode || (checkMode && (!mode || displayerMode === mode));
22
24
  const spectrumCheckFlag = !checkSpectrumType ||
23
25
  (checkSpectrumType && checkSpectrum(spectrum, spectraOptions));
24
- return (flag &&
26
+ const isToolActivated = (flag && !isExperimental) ||
27
+ (isExperimental && isExperimentalFeatureActivated);
28
+ return (isToolActivated &&
25
29
  modeFlag &&
26
30
  spectrumCheckFlag &&
27
31
  (!extraInfoCheckParameters ||
28
32
  checkInfo(extraInfoCheckParameters, spectrum?.info)));
29
- }, [displayerMode, preferences, spectrum]);
33
+ }, [displayerMode, isExperimentalFeatureActivated, preferences, spectrum]);
30
34
  }
31
35
  exports.useCheckToolsVisibility = useCheckToolsVisibility;
32
36
  function checkSpectrum(spectrum, options) {
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useResizerStatus = void 0;
4
+ const ChartContext_1 = require("../context/ChartContext");
5
+ const KeyModifierContext_1 = require("../context/KeyModifierContext");
6
+ function useResizerStatus(toolKey) {
7
+ const { toolOptions: { selectedTool }, } = (0, ChartContext_1.useChartData)();
8
+ const { shiftKey } = (0, KeyModifierContext_1.useKeyModifiers)();
9
+ return !shiftKey && selectedTool === toolKey;
10
+ }
11
+ exports.useResizerStatus = useResizerStatus;
@@ -7,7 +7,7 @@ function useSpectrum(defaultValue = null) {
7
7
  const { data } = (0, ChartContext_1.useChartData)();
8
8
  const activeSpectrum = (0, useActiveSpectrum_1.useActiveSpectrum)();
9
9
  return (0, react_1.useMemo)(() => {
10
- if (data && activeSpectrum && activeSpectrum.id) {
10
+ if (data && activeSpectrum?.id) {
11
11
  const datum = data.find((datum) => datum.id === activeSpectrum.id) || defaultValue;
12
12
  return datum;
13
13
  }
@@ -0,0 +1,26 @@
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
+ const jsx_runtime_1 = require("react/jsx-runtime");
7
+ const styled_1 = __importDefault(require("@emotion/styled"));
8
+ const WrongP = styled_1.default.p `
9
+ background-color: white;
10
+ padding: 20px;
11
+ border-radius: 10px;
12
+ font-size: 30px;
13
+ text-align: center;
14
+ `;
15
+ const Details = styled_1.default.details `
16
+ margin-top: 10px;
17
+ white-space: pre-wrap;
18
+ background-color: white;
19
+ padding: 20px;
20
+ border-radius: 10px;
21
+ color: red;
22
+ `;
23
+ function ErrorOverlay(props) {
24
+ return ((0, jsx_runtime_1.jsxs)("div", { style: { margin: 25 }, children: [(0, jsx_runtime_1.jsx)(WrongP, { children: "Something went wrong." }), (0, jsx_runtime_1.jsxs)(Details, { children: [(0, jsx_runtime_1.jsx)("p", { style: { textDecoration: 'underline' }, children: props.error.message }), props.error.stack] })] }));
25
+ }
26
+ exports.default = ErrorOverlay;