nmrium 0.57.1 → 0.59.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 (139) hide show
  1. package/lib/component/1d/integral/IntegralResizable.js +2 -2
  2. package/lib/component/1d/matrix/useMatrix.d.ts +1 -1
  3. package/lib/component/1d/multiAnalysis/AnalysisRange.js +1 -1
  4. package/lib/component/1d/ranges/Atoms.js +6 -4
  5. package/lib/component/1d-2d/components/SpectrumInfoBlock.d.ts +1 -1
  6. package/lib/component/1d-2d/components/SpectrumInfoBlock.js +114 -7
  7. package/lib/component/2d/Viewer2D.js +6 -2
  8. package/lib/component/2d/zones/Zone.js +2 -2
  9. package/lib/component/EventsTrackers/KeysListenerTracker.js +8 -8
  10. package/lib/component/context/ChartContext.js +12 -1
  11. package/lib/component/context/ShareDataContext.d.ts +1 -1
  12. package/lib/component/context/ShareDataContext.js +2 -4
  13. package/lib/component/context/ToasterContext.d.ts +1 -0
  14. package/lib/component/context/ToasterContext.js +12 -3
  15. package/lib/component/elements/ActionsButtonsPopover.d.ts +7 -1
  16. package/lib/component/elements/ActionsButtonsPopover.js +7 -6
  17. package/lib/component/elements/Alert.d.ts +20 -0
  18. package/lib/component/elements/Alert.js +80 -0
  19. package/lib/component/elements/ContextMenuBluePrint.d.ts +7 -2
  20. package/lib/component/elements/ContextMenuBluePrint.js +9 -3
  21. package/lib/component/elements/Input2.js +2 -2
  22. package/lib/component/elements/Input2Controller.d.ts +4 -2
  23. package/lib/component/elements/Input2Controller.js +22 -6
  24. package/lib/component/elements/MoleculeSelection.js +2 -2
  25. package/lib/component/elements/NextPrev.d.ts +4 -5
  26. package/lib/component/elements/NextPrev.js +76 -79
  27. package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +1 -1
  28. package/lib/component/elements/ReactTable/ReactTableFlexLayout.d.ts +0 -3
  29. package/lib/component/elements/ReactTable/ReactTableFlexLayout.js +1 -1
  30. package/lib/component/elements/Select2.d.ts +12 -7
  31. package/lib/component/elements/Select2.js +5 -4
  32. package/lib/component/elements/Select2Controller.d.ts +2 -2
  33. package/lib/component/elements/Select2Controller.js +5 -5
  34. package/lib/component/elements/ToolbarPopoverItem.d.ts +7 -6
  35. package/lib/component/elements/ToolbarPopoverItem.js +13 -5
  36. package/lib/component/elements/print/PrintContent.d.ts +17 -0
  37. package/lib/component/elements/print/PrintContent.js +281 -0
  38. package/lib/component/elements/print/PrintProvider.d.ts +12 -0
  39. package/lib/component/elements/print/PrintProvider.js +28 -0
  40. package/lib/component/elements/print/index.d.ts +2 -0
  41. package/lib/component/elements/print/index.js +2 -0
  42. package/lib/component/header/ApodizationOptionsPanel.js +14 -7
  43. package/lib/component/header/BaseLineCorrectionPanel.js +20 -10
  44. package/lib/component/header/ZeroFillingOptionsPanel.js +17 -10
  45. package/lib/component/hooks/useSaveSettings.js +43 -26
  46. package/lib/component/hooks/useToggleSpectraVisibility.d.ts +14 -9
  47. package/lib/component/hooks/useToggleSpectraVisibility.js +45 -16
  48. package/lib/component/hooks/useWorkspaceAction.js +12 -14
  49. package/lib/component/loader/DropZone.js +3 -67
  50. package/lib/component/loader/useLoadFiles.d.ts +1 -0
  51. package/lib/component/loader/useLoadFiles.js +78 -0
  52. package/lib/component/main/InnerNMRium.d.ts +4 -3
  53. package/lib/component/main/InnerNMRium.js +4 -9
  54. package/lib/component/main/InnerNMRiumContents.d.ts +3 -2
  55. package/lib/component/main/InnerNMRiumContents.js +33 -29
  56. package/lib/component/main/NMRium.d.ts +2 -5
  57. package/lib/component/main/NMRium.js +1 -1
  58. package/lib/component/main/NMRiumRefAPI.d.ts +7 -0
  59. package/lib/component/main/NMRiumRefAPI.js +12 -0
  60. package/lib/component/main/NMRiumViewer.d.ts +10 -0
  61. package/lib/component/main/NMRiumViewer.js +35 -0
  62. package/lib/component/main/index.d.ts +1 -0
  63. package/lib/component/modal/CopyClipboardModal.d.ts +3 -2
  64. package/lib/component/modal/CopyClipboardModal.js +18 -32
  65. package/lib/component/modal/ExportAsJcampModal.d.ts +6 -3
  66. package/lib/component/modal/ExportAsJcampModal.js +69 -35
  67. package/lib/component/modal/ImportPublicationStringModal.js +1 -1
  68. package/lib/component/modal/LoadJCAMPModal.d.ts +3 -1
  69. package/lib/component/modal/LoadJCAMPModal.js +17 -18
  70. package/lib/component/modal/SaveAsModal.d.ts +3 -1
  71. package/lib/component/modal/SaveAsModal.js +20 -30
  72. package/lib/component/modal/changeSum/ChangeSumModal.js +1 -1
  73. package/lib/component/modal/changeSum/ChangeSumModalContents.js +35 -47
  74. package/lib/component/modal/changeSum/SelectMolecule.d.ts +2 -5
  75. package/lib/component/modal/changeSum/SelectMolecule.js +9 -8
  76. package/lib/component/modal/setting/GeneralSettings.js +4 -2
  77. package/lib/component/modal/setting/settings-tabs/ExternalAPIsTabContent.d.ts +1 -0
  78. package/lib/component/modal/setting/settings-tabs/ExternalAPIsTabContent.js +89 -0
  79. package/lib/component/modal/setting/settingsValidation.js +15 -1
  80. package/lib/component/panels/IntegralsPanel/IntegralPanel.js +8 -5
  81. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +5 -1
  82. package/lib/component/panels/MoleculesPanel/MoleculePanel.js +5 -3
  83. package/lib/component/panels/Panels.js +15 -15
  84. package/lib/component/panels/PeaksPanel/PeaksPanel.js +8 -5
  85. package/lib/component/panels/RangesPanel/RangesHeader.js +52 -12
  86. package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +13 -6
  87. package/lib/component/panels/SpectraPanel/SpectraTable.js +63 -21
  88. package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnHeader.js +6 -2
  89. package/lib/component/panels/SummaryPanel/CorrelationTable/CorrelationTableRow.js +6 -2
  90. package/lib/component/panels/SummaryPanel/SummaryPanel.js +4 -0
  91. package/lib/component/panels/ZonesPanel/ZonesPanel.js +16 -8
  92. package/lib/component/panels/databasePanel/DatabasePanel.js +7 -8
  93. package/lib/component/panels/filtersPanel/FilterPanel.js +9 -6
  94. package/lib/component/panels/filtersPanel/FiltersTable.js +12 -10
  95. package/lib/component/panels/header/DefaultPanelHeader.d.ts +1 -0
  96. package/lib/component/panels/header/DefaultPanelHeader.js +2 -2
  97. package/lib/component/panels/multipleAnalysisPanel/AlignSpectra.js +10 -12
  98. package/lib/component/panels/predictionPanel/PredictionPanel.js +2 -2
  99. package/lib/component/reducer/IgnoreActions.js +1 -0
  100. package/lib/component/reducer/Reducer.js +2 -4
  101. package/lib/component/reducer/actions/DatabaseActions.d.ts +15 -13
  102. package/lib/component/reducer/actions/DatabaseActions.js +52 -34
  103. package/lib/component/reducer/actions/DomainActions.d.ts +2 -2
  104. package/lib/component/reducer/actions/FiltersActions.js +9 -4
  105. package/lib/component/reducer/actions/SpectraActions.d.ts +2 -1
  106. package/lib/component/reducer/actions/SpectraActions.js +53 -43
  107. package/lib/component/reducer/helper/removeSpectrumRelatedObjectsById.d.ts +3 -0
  108. package/lib/component/reducer/helper/removeSpectrumRelatedObjectsById.js +16 -0
  109. package/lib/component/reducer/preferences/actions/changeInformationBlockPosition.d.ts +3 -0
  110. package/lib/component/reducer/preferences/actions/changeInformationBlockPosition.js +5 -0
  111. package/lib/component/reducer/preferences/actions/changePrintPageSettings.d.ts +3 -0
  112. package/lib/component/reducer/preferences/actions/changePrintPageSettings.js +6 -0
  113. package/lib/component/reducer/preferences/actions/toggleInformationBlock.d.ts +3 -0
  114. package/lib/component/reducer/preferences/actions/toggleInformationBlock.js +7 -0
  115. package/lib/component/reducer/preferences/preferencesReducer.d.ts +12 -2
  116. package/lib/component/reducer/preferences/preferencesReducer.js +9 -0
  117. package/lib/component/toolbar/ToolBar.js +33 -14
  118. package/lib/component/workspaces/workspaceDefaultProperties.js +2 -0
  119. package/lib/data/SpectraManager.d.ts +7 -10
  120. package/lib/data/SpectraManager.js +51 -30
  121. package/lib/data/data1d/Spectrum1D/SumManager.d.ts +0 -1
  122. package/lib/data/data1d/Spectrum1D/SumManager.js +2 -10
  123. package/lib/data/data1d/Spectrum1D/get1DColor.d.ts +1 -1
  124. package/lib/data/data1d/Spectrum1D/index.d.ts +1 -1
  125. package/lib/data/data1d/Spectrum1D/index.js +1 -1
  126. package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +10 -10
  127. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +2 -1
  128. package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +10 -10
  129. package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +10 -10
  130. package/lib/data/data1d/Spectrum1D/ranges/resurrectSpectrum.d.ts +13 -0
  131. package/lib/data/data1d/Spectrum1D/ranges/resurrectSpectrum.js +65 -0
  132. package/lib/data/molecules/MoleculeManager.js +16 -38
  133. package/lib/data/utilities/getCustomColor.d.ts +1 -1
  134. package/lib/data/utilities/removeByPaths.d.ts +3 -0
  135. package/lib/data/utilities/removeByPaths.js +33 -0
  136. package/lib/versionInfo.js +1 -1
  137. package/package.json +36 -36
  138. package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.d.ts +0 -11
  139. package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.js +0 -29
@@ -11,7 +11,7 @@ import { IntegralIndicator } from './IntegralIndicator';
11
11
  const stylesOnHover = css `
12
12
  pointer-events: bounding-box;
13
13
 
14
- @-moz-document url-prefix("") {
14
+ @document url-prefix("") {
15
15
  pointer-events: fill;
16
16
  }
17
17
 
@@ -26,7 +26,7 @@ const stylesOnHover = css `
26
26
  const stylesHighlighted = css `
27
27
  pointer-events: bounding-box;
28
28
 
29
- @-moz-document url-prefix("") {
29
+ @document url-prefix("") {
30
30
  pointer-events: fill;
31
31
  }
32
32
 
@@ -13,7 +13,7 @@ export declare function sliceArrayForDomain<T extends string[] | NumberArray>(ar
13
13
  toIndex: number;
14
14
  }): T;
15
15
  export declare function useMatrix(): {
16
- x: Float64Array | never[];
16
+ x: never[] | Float64Array;
17
17
  matrixY: Float64Array[];
18
18
  } | null;
19
19
  interface InterpolateColorsPointsOptions {
@@ -11,7 +11,7 @@ const styles = {
11
11
  common: css `
12
12
  pointer-events: bounding-box;
13
13
 
14
- @-moz-document url-prefix("") {
14
+ @document url-prefix("") {
15
15
  pointer-events: fill;
16
16
  }
17
17
  `,
@@ -22,10 +22,12 @@ function useAtoms(range) {
22
22
  for (const [id, topicMoleculeObject] of Object.entries(topicMolecule)) {
23
23
  const atoms = [];
24
24
  const diaIDsObject = topicMoleculeObject.getDiaIDsObject();
25
- for (const id of diaIDs) {
26
- const existingAtoms = diaIDsObject[id]?.existingAtoms;
27
- if (existingAtoms?.length > 0) {
28
- atoms.push(...existingAtoms);
25
+ if (diaIDsObject) {
26
+ for (const id of diaIDs) {
27
+ const existingAtoms = diaIDsObject[id]?.existingAtoms;
28
+ if (existingAtoms?.length > 0) {
29
+ atoms.push(...existingAtoms);
30
+ }
29
31
  }
30
32
  }
31
33
  if (atoms.length > 0) {
@@ -1,2 +1,2 @@
1
- declare function SpectrumInfoBlock(): import("react/jsx-runtime").JSX.Element | null;
1
+ declare function SpectrumInfoBlock(): import("@emotion/react/jsx-runtime").JSX.Element | null;
2
2
  export default SpectrumInfoBlock;
@@ -1,10 +1,21 @@
1
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ /** @jsxImportSource @emotion/react */
2
3
  import lodashGet from 'lodash/get';
4
+ import { useState } from 'react';
5
+ import { BsArrowsMove } from 'react-icons/bs';
6
+ import { FaTimes } from 'react-icons/fa';
7
+ import { useMeasure } from 'react-use';
3
8
  import { useChartData } from '../../context/ChartContext';
9
+ import { useGlobal } from '../../context/GlobalContext';
4
10
  import { usePreferences } from '../../context/PreferencesContext';
11
+ import { ActionsButtonsPopover, } from '../../elements/ActionsButtonsPopover';
5
12
  import { SVGGroup } from '../../elements/SVGGroup';
13
+ import useDraggable from '../../elements/draggable/useDraggable';
6
14
  import useSpectrum from '../../hooks/useSpectrum';
7
15
  import { formatNumber } from '../../utility/formatNumber';
16
+ const verticalSpace = 5;
17
+ const boxPadding = 0;
18
+ const dragShiftY = 24;
8
19
  const styles = {
9
20
  label: {
10
21
  fontSize: '11px',
@@ -34,16 +45,112 @@ function getInfoValue(spectrum, field) {
34
45
  return JSON.stringify(value);
35
46
  }
36
47
  }
48
+ function useInfoPosition(margin) {
49
+ const { left, top } = margin;
50
+ const { current: { infoBlock }, } = usePreferences();
51
+ const { x, y } = infoBlock?.position || { x: left, y: top };
52
+ return { x, y };
53
+ }
37
54
  function SpectrumInfoBlock() {
38
- const { margin } = useChartData();
55
+ const { height, width, margin } = useChartData();
39
56
  const spectrum = useSpectrum();
57
+ const { viewerRef } = useGlobal();
58
+ const coordinate = useInfoPosition(margin);
59
+ const { dispatch } = usePreferences();
60
+ const [isMoveActive, setIsMoveActive] = useState(false);
61
+ const [currentPosition, setCurrentPosition] = useState(coordinate);
40
62
  const { current: { infoBlock: { visible, fields }, }, } = usePreferences();
63
+ const infoFields = fields.filter((field) => field.visible);
64
+ const totalSpace = verticalSpace *
65
+ ((infoFields?.length < 2
66
+ ? 2
67
+ : infoFields?.length - (infoFields?.length % 2)
68
+ ? 2
69
+ : 1) || 0);
70
+ const [ref, boxSize] = useMeasure();
71
+ const { onPointerDown } = useDraggable({
72
+ position: coordinate,
73
+ onChange: (dragEvent) => {
74
+ const { action, position } = dragEvent;
75
+ switch (action) {
76
+ case 'start': {
77
+ setCurrentPosition({ x: position.x, y: position.y + dragShiftY });
78
+ setIsMoveActive(true);
79
+ break;
80
+ }
81
+ case 'move': {
82
+ setCurrentPosition({
83
+ x: position.x,
84
+ y: position.y + dragShiftY,
85
+ });
86
+ break;
87
+ }
88
+ case 'end':
89
+ dispatch({
90
+ type: 'CHANGE_INFORMATION_BLOCK_POSITION',
91
+ payload: {
92
+ coordination: {
93
+ x: position.x,
94
+ y: position.y,
95
+ },
96
+ },
97
+ });
98
+ setIsMoveActive(false);
99
+ break;
100
+ default:
101
+ break;
102
+ }
103
+ },
104
+ parentElement: viewerRef,
105
+ });
41
106
  if (!visible || !spectrum)
42
107
  return null;
43
- return (_jsx("g", { className: "spectra-info-block", transform: `translate(${margin.left + 5} ${margin.top})`, children: fields
44
- .filter((field) => field.visible)
45
- .map((field, index) => {
46
- return (_jsxs(SVGGroup, { transform: `translate(0,${20 * (index + 1)})`, space: 5, children: [_jsxs("text", { alignmentBaseline: "middle", style: styles.label, children: [field.label, " :"] }), _jsx("text", { alignmentBaseline: "middle", style: styles.value, children: getInfoValue(spectrum, field) })] }, field.jpath + field.label));
47
- }) }));
108
+ const bothSidePadding = boxPadding * 2;
109
+ const shift = dragShiftY / 2;
110
+ let { x, y } = currentPosition;
111
+ if (x + boxSize.width + boxPadding > width - margin.right) {
112
+ x = width - margin.right - boxSize.width - boxPadding;
113
+ }
114
+ if (x - boxPadding < margin.left) {
115
+ x = margin.left + boxPadding;
116
+ }
117
+ if (y + boxSize.height + bothSidePadding + shift > height - margin.bottom) {
118
+ y = height - margin.bottom - boxSize.height - bothSidePadding - shift;
119
+ }
120
+ if (y + shift < margin.top) {
121
+ y = margin.top - shift;
122
+ }
123
+ const boxWidth = boxSize.width + bothSidePadding;
124
+ const boxHeight = boxSize.height + bothSidePadding;
125
+ const actionsButtons = [
126
+ {
127
+ icon: _jsx(BsArrowsMove, {}),
128
+ onPointerDown: (event) => {
129
+ event.stopPropagation();
130
+ onPointerDown(event);
131
+ },
132
+ intent: 'none',
133
+ title: 'Move information block',
134
+ style: { cursor: 'move' },
135
+ },
136
+ {
137
+ icon: _jsx(FaTimes, {}),
138
+ onClick: () => {
139
+ dispatch({
140
+ type: 'TOGGLE_INFORMATION_BLOCK',
141
+ payload: { visible: false },
142
+ });
143
+ },
144
+ intent: 'danger',
145
+ title: 'Hide information block',
146
+ },
147
+ ];
148
+ return (_jsx(ActionsButtonsPopover, { targetTagName: "g", buttons: actionsButtons, positioningStrategy: "fixed", position: "top-left", direction: "row", space: 2, ...(isMoveActive && { isOpen: true }), modifiers: {
149
+ offset: {
150
+ data: { x, y },
151
+ },
152
+ }, children: _jsxs("g", { className: "spectra-info-block", transform: `translate(${x} ${y})`, children: [_jsx("rect", { "data-no-export": "true", x: -boxPadding, y: -boxPadding + totalSpace, width: boxWidth, height: boxHeight, rx: "5", fill: isMoveActive ? 'white' : 'transparent', opacity: isMoveActive ? 0.9 : 0 }), _jsx("g", { ref: ref, children: infoFields.map((field, index) => {
153
+ return (_jsxs(SVGGroup, { transform: `translate(0,${20 * (index + 1)})`, space: verticalSpace, children: [_jsxs("text", { alignmentBaseline: "middle", style: styles.label, children: [field.label, " :"] }), _jsx("text", { alignmentBaseline: "middle", style: styles.value, children: getInfoValue(spectrum, field) })] }, field.jpath + field.label));
154
+ }) })] }) }));
48
155
  }
49
156
  export default SpectrumInfoBlock;
@@ -8,6 +8,7 @@ import { MouseTracker } from '../EventsTrackers/MouseTracker';
8
8
  import { useChartData } from '../context/ChartContext';
9
9
  import { useDispatch } from '../context/DispatchContext';
10
10
  import { useMapKeyModifiers } from '../context/KeyModifierContext';
11
+ import { usePrintPage } from '../elements/print';
11
12
  import Spinner from '../loader/Spinner';
12
13
  import { options } from '../toolbar/ToolTypes';
13
14
  import { PhaseTraces } from './1d-tracer/phase-correction-traces';
@@ -159,9 +160,12 @@ function Viewer2D({ emptyText = undefined }) {
159
160
  export function ViewerResponsiveWrapper(props) {
160
161
  const dispatch = useDispatch();
161
162
  const { width, height, children } = props;
163
+ const printOptions = usePrintPage();
162
164
  useEffect(() => {
163
- dispatch({ type: 'SET_DIMENSIONS', payload: { width, height } });
164
- }, [width, height, dispatch]);
165
+ if (!printOptions) {
166
+ dispatch({ type: 'SET_DIMENSIONS', payload: { width, height } });
167
+ }
168
+ }, [width, height, dispatch, printOptions]);
165
169
  return children;
166
170
  }
167
171
  export default Viewer2D;
@@ -15,7 +15,7 @@ import Signal from './Signal';
15
15
  const stylesOnHover = css `
16
16
  pointer-events: bounding-box;
17
17
 
18
- @-moz-document url-prefix("") {
18
+ @document url-prefix("") {
19
19
  pointer-events: fill;
20
20
  }
21
21
 
@@ -28,7 +28,7 @@ const stylesOnHover = css `
28
28
  const stylesHighlighted = css `
29
29
  pointer-events: bounding-box;
30
30
 
31
- @-moz-document url-prefix("") {
31
+ @document url-prefix("") {
32
32
  pointer-events: fill;
33
33
  }
34
34
 
@@ -8,7 +8,7 @@ import { useDispatch } from '../context/DispatchContext';
8
8
  import { useLoader } from '../context/LoaderContext';
9
9
  import { usePreferences } from '../context/PreferencesContext';
10
10
  import { useToaster } from '../context/ToasterContext';
11
- import { useModal } from '../elements/popup/Modal';
11
+ import { useAlert } from '../elements/Alert';
12
12
  import { HighlightEventSource, useHighlightData } from '../highlight/index';
13
13
  import { useCheckToolsVisibility } from '../hooks/useCheckToolsVisibility';
14
14
  import useExport from '../hooks/useExport';
@@ -21,7 +21,7 @@ function KeysListenerTracker(props) {
21
21
  const dispatch = useDispatch();
22
22
  const { dispatch: dispatchPreferences, current: { nuclei }, } = usePreferences();
23
23
  const toaster = useToaster();
24
- const modal = useModal();
24
+ const alert = useAlert();
25
25
  const openLoader = useLoader();
26
26
  const [isSaveModalOpened, openSaveAsDialog, closeSaveAsDialog] = useOnOff(false);
27
27
  const { handleChangeOption, handleFullZoomOut, alignSpectraVerticallyHandler, changeDisplayViewModeHandler, } = useToolsFunctions();
@@ -131,7 +131,7 @@ function KeysListenerTracker(props) {
131
131
  const buttons = [
132
132
  {
133
133
  text: 'Yes, for all spectra',
134
- handler: async () => {
134
+ onClick: async () => {
135
135
  if (zone) {
136
136
  const hideLoading = toaster.showLoading({
137
137
  message: 'Delete all spectra exclusion zones in progress',
@@ -148,7 +148,7 @@ function KeysListenerTracker(props) {
148
148
  },
149
149
  {
150
150
  text: 'Yes',
151
- handler: async () => {
151
+ onClick: async () => {
152
152
  if (spectrumID) {
153
153
  const hideLoading = toaster.showLoading({
154
154
  message: 'Delete exclusion zones in progress',
@@ -166,7 +166,7 @@ function KeysListenerTracker(props) {
166
166
  },
167
167
  { text: 'No' },
168
168
  ];
169
- modal.showConfirmDialog({
169
+ alert.showAlert({
170
170
  message: 'Are you sure you want to delete the exclusion zone/s?',
171
171
  buttons,
172
172
  });
@@ -177,7 +177,7 @@ function KeysListenerTracker(props) {
177
177
  const buttons = [
178
178
  {
179
179
  text: 'Yes',
180
- handler: async () => {
180
+ onClick: async () => {
181
181
  if (zone) {
182
182
  const hideLoading = toaster.showLoading({
183
183
  message: 'Delete all spectra exclusion zones in progress',
@@ -195,7 +195,7 @@ function KeysListenerTracker(props) {
195
195
  },
196
196
  { text: 'No' },
197
197
  ];
198
- modal.showConfirmDialog({
198
+ alert.showAlert({
199
199
  message: 'Are you sure you want to delete the Matrix generation exclusion zones?',
200
200
  buttons,
201
201
  });
@@ -241,7 +241,7 @@ function KeysListenerTracker(props) {
241
241
  dispatch,
242
242
  remove,
243
243
  assignmentData,
244
- modal,
244
+ alert,
245
245
  toaster,
246
246
  dispatchPreferences,
247
247
  activeTab,
@@ -1,7 +1,18 @@
1
+ import { produce } from 'immer';
1
2
  import { createContext, useContext } from 'react';
3
+ import { usePrintPage } from '../elements/print';
2
4
  import { initialState } from '../reducer/Reducer';
3
5
  export const ChartContext = createContext(initialState);
4
6
  export const ChartDataProvider = ChartContext.Provider;
5
7
  export function useChartData() {
6
- return useContext(ChartContext);
8
+ const data = useContext(ChartContext);
9
+ const printOptions = usePrintPage();
10
+ if (!printOptions)
11
+ return data;
12
+ const { width, height } = printOptions;
13
+ const updatedData = produce(data, (draft) => {
14
+ draft.width = width;
15
+ draft.height = height;
16
+ });
17
+ return updatedData;
7
18
  }
@@ -4,7 +4,7 @@ interface ShareDataState<T> {
4
4
  setData: (data: T) => void;
5
5
  }
6
6
  export declare function useShareData<T>(): ShareDataState<T>;
7
- export declare function ShareDataProvider<T>({ children, }: {
7
+ export declare function ShareDataProvider({ children }: {
8
8
  children: React.ReactNode;
9
9
  }): import("react/jsx-runtime").JSX.Element;
10
10
  export {};
@@ -8,14 +8,12 @@ export function useShareData() {
8
8
  }
9
9
  return context;
10
10
  }
11
- export function ShareDataProvider({ children, }) {
11
+ export function ShareDataProvider({ children }) {
12
12
  const [data, setData] = useState(null);
13
13
  const state = useMemo(() => {
14
14
  return {
15
15
  data,
16
- setData: (newData) => {
17
- setData(newData);
18
- },
16
+ setData,
19
17
  };
20
18
  }, [data]);
21
19
  return (_jsx(ShareDataContext.Provider, { value: state, children: children }));
@@ -3,6 +3,7 @@ import { ReactNode } from 'react';
3
3
  interface ToasterContextProps {
4
4
  toaster: OverlayToaster | null;
5
5
  showLoading: (options: ToastProps) => () => void;
6
+ showAsyncLoading: (options: ToastProps) => Promise<() => void>;
6
7
  show: (options: ToastProps) => void;
7
8
  }
8
9
  export declare function useToaster(): ToasterContextProps;
@@ -22,13 +22,22 @@ export function ToasterProvider({ children }) {
22
22
  timeout: 0,
23
23
  ...otherProps,
24
24
  });
25
- return () => {
25
+ function dismiss() {
26
26
  if (toastKey) {
27
27
  toasterRef.current?.dismiss(toastKey);
28
28
  }
29
- };
29
+ }
30
+ return dismiss;
30
31
  }
31
- return { toaster: toasterRef.current, showLoading, show };
32
+ function showAsyncLoading(options) {
33
+ return new Promise((resolve) => {
34
+ const hideLoading = showLoading(options);
35
+ setTimeout(() => {
36
+ resolve(hideLoading);
37
+ }, 100);
38
+ });
39
+ }
40
+ return { toaster: toasterRef.current, showLoading, showAsyncLoading, show };
32
41
  }, []);
33
42
  return (_jsxs(_Fragment, { children: [_jsx(OverlayToaster, { className: Classes.DARK, position: Position.BOTTOM, ref: toasterRef }), _jsx(ToasterContext.Provider, { value: toaster, children: children })] }));
34
43
  }
@@ -1,10 +1,16 @@
1
1
  /** @jsxImportSource @emotion/react */
2
2
  import { PopoverProps } from '@blueprintjs/core';
3
+ import { Interpolation, Theme } from '@emotion/react';
4
+ import { CSSProperties } from 'react';
3
5
  import { ButtonProps } from 'react-science/ui';
4
6
  export interface ActionsButtonsPopoverProps extends Omit<PopoverProps, 'interactionKind' | 'content'> {
5
- buttons: Array<Pick<ButtonProps, 'icon' | 'onClick' | 'intent' | 'disabled'> & {
7
+ buttons: Array<Pick<ButtonProps, 'icon' | 'onClick' | 'intent' | 'disabled' | 'onPointerDown' | 'style'> & {
6
8
  title?: string;
7
9
  visible?: boolean;
10
+ css?: Interpolation<Theme>;
8
11
  }>;
12
+ contentStyle?: CSSProperties;
13
+ direction?: 'column' | 'row';
14
+ space?: number;
9
15
  }
10
16
  export declare function ActionsButtonsPopover(props: ActionsButtonsPopoverProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -1,11 +1,12 @@
1
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
2
  /** @jsxImportSource @emotion/react */
3
3
  import { Popover } from '@blueprintjs/core';
4
4
  import { css } from '@emotion/react';
5
+ import { Fragment } from 'react';
5
6
  import { Button } from 'react-science/ui';
6
7
  export function ActionsButtonsPopover(props) {
7
- const { buttons, children, ...otherProps } = props;
8
- return (_jsx(Popover, { minimal: true, position: "auto-start", popoverClassName: "actions-buttons-popover", interactionKind: "hover", enforceFocus: false, content: _jsx("div", { style: { display: 'flex', flexDirection: 'column' }, css: css `
8
+ const { buttons, children, space, direction = 'column', contentStyle = {}, ...otherProps } = props;
9
+ return (_jsx(Popover, { minimal: true, position: "auto-start", popoverClassName: "actions-buttons-popover", interactionKind: "hover", enforceFocus: false, content: _jsx("div", { style: { display: 'flex', flexDirection: direction, ...contentStyle }, css: css `
9
10
  button,
10
11
  a[role='button'] {
11
12
  border-radius: 50%;
@@ -16,7 +17,7 @@ export function ActionsButtonsPopover(props) {
16
17
  }
17
18
  `, children: buttons
18
19
  .filter((button) => button?.visible !== false)
19
- .map(({ icon, onClick, intent, title, disabled }, index) => {
20
- return (_jsx(Button, { disabled: disabled, icon: icon, onClick: onClick, tooltipProps: { content: title || '', compact: true }, intent: intent }, title || index));
21
- }) }), ...otherProps, children: children }));
20
+ .map(({ title, visible, ...otherProps }, index, array) => (_jsxs(Fragment, { children: [_jsx(Button, { tooltipProps: { content: title || '', compact: true }, ...otherProps }), index < array.length - 1 && (_jsx("div", { style: {
21
+ margin: direction === 'row' ? `0 ${space}px` : `${space}px 0`,
22
+ } }, `spacer-${index}`))] }, title || index))) }), ...otherProps, children: children }));
22
23
  }
@@ -0,0 +1,20 @@
1
+ /** @jsxImportSource @emotion/react */
2
+ import { ButtonProps } from '@blueprintjs/core';
3
+ import React, { ReactNode } from 'react';
4
+ export interface AlertButton extends ButtonProps {
5
+ text: ReactNode;
6
+ preventClose?: boolean;
7
+ }
8
+ interface AlertConfig {
9
+ message: ReactNode;
10
+ buttons: AlertButton[];
11
+ onClose?: () => void;
12
+ }
13
+ interface AlertContextType {
14
+ showAlert: (config: AlertConfig) => void;
15
+ }
16
+ export declare function useAlert(): AlertContextType;
17
+ export declare const AlertProvider: React.FC<{
18
+ children: ReactNode;
19
+ }>;
20
+ export {};
@@ -0,0 +1,80 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ /** @jsxImportSource @emotion/react */
3
+ import { Button, Dialog, DialogBody, DialogFooter, } from '@blueprintjs/core';
4
+ import styled from '@emotion/styled';
5
+ import { v4 } from '@lukeed/uuid';
6
+ import { createContext, useState, useContext, useMemo, } from 'react';
7
+ const Message = styled.p `
8
+ font-weight: bold;
9
+ font-size: 14px;
10
+ text-align: center;
11
+ color: #af0000;
12
+ `;
13
+ const Footer = styled(DialogFooter) `
14
+ button {
15
+ margin: 0 3px;
16
+ }
17
+
18
+ button:first-of-type {
19
+ margin-right: 0;
20
+ }
21
+
22
+ button:last-of-type {
23
+ margin-left: 0;
24
+ }
25
+ `;
26
+ const ButtonsGroup = styled.div `
27
+ display: flex;
28
+ flex-direction: row-reverse;
29
+ `;
30
+ const Body = styled(DialogBody) `
31
+ background-color: white;
32
+ padding: 25px;
33
+
34
+ p {
35
+ margin: 0;
36
+ }
37
+ `;
38
+ const Alert = styled(Dialog) `
39
+ border-top: 10px solid rgb(237 0 0);
40
+ `;
41
+ const AlertContext = createContext(null);
42
+ export function useAlert() {
43
+ const context = useContext(AlertContext);
44
+ if (!context) {
45
+ throw new Error('Alert context was not found');
46
+ }
47
+ return context;
48
+ }
49
+ export const AlertProvider = ({ children, }) => {
50
+ const [alerts, setAlerts] = useState([]);
51
+ function hideAlert(id) {
52
+ setAlerts((prevAlerts) => prevAlerts.filter((alert) => alert.id !== id));
53
+ }
54
+ const alertState = useMemo(() => {
55
+ function showAlert(config) {
56
+ const id = v4();
57
+ setAlerts((prevAlerts) => [...prevAlerts, { id, ...config }]);
58
+ }
59
+ return { showAlert };
60
+ }, []);
61
+ return (_jsxs(_Fragment, { children: [_jsx(Alerts, { alerts: alerts, onHide: hideAlert }), _jsx(AlertContext.Provider, { value: alertState, children: children })] }));
62
+ };
63
+ function Alerts(props) {
64
+ const { alerts, onHide } = props;
65
+ function optionsHandler(e, options) {
66
+ const { onClick = () => null, preventClose = false, id } = options;
67
+ onClick(e);
68
+ e.stopPropagation();
69
+ if (!preventClose) {
70
+ onHide(id);
71
+ }
72
+ }
73
+ return alerts.map(({ id, buttons, message, onClose }) => (_jsxs(Alert, { isOpen: true, onClose: () => {
74
+ onHide(id);
75
+ onClose?.();
76
+ }, role: "alertdialog", children: [_jsx(Body, { children: _jsx(Message, { className: "message", children: message }) }), _jsx(Footer, { children: _jsx(ButtonsGroup, { children: buttons.map((item, index) => {
77
+ const { text, onClick, preventClose, ...otherItemProps } = item;
78
+ return (_jsx(Button, { onClick: (e) => optionsHandler(e, { onClick, preventClose, id }), ...otherItemProps, children: text }, index));
79
+ }) }) })] }, id)));
80
+ }
@@ -1,7 +1,11 @@
1
- import { ContextMenuProps as BluePrintContextMenuProps, MenuItemProps } from '@blueprintjs/core';
1
+ import { ContextMenuProps as BluePrintContextMenuProps, MenuItemProps, TooltipProps } from '@blueprintjs/core';
2
2
  import { ComponentProps, ElementType, ReactNode } from 'react';
3
- export interface ContextMenuItem extends MenuItemProps {
3
+ export type ContextMenuCheck = boolean | ((data: any) => boolean);
4
+ export interface ContextMenuItem extends Omit<MenuItemProps, 'disabled'> {
4
5
  data?: object;
6
+ tooltip?: TooltipProps;
7
+ disabled?: ContextMenuCheck;
8
+ visible?: ContextMenuCheck;
5
9
  }
6
10
  type ElementProps<E = 'div'> = E extends ElementType ? ComponentProps<E> : never;
7
11
  export interface BaseContextMenuProps {
@@ -11,6 +15,7 @@ export interface BaseContextMenuProps {
11
15
  export interface ContextMenuProps<E> extends BaseContextMenuProps, Omit<BluePrintContextMenuProps, 'onSelect' | 'content' | 'children'> {
12
16
  as?: E;
13
17
  children: ReactNode;
18
+ data?: any;
14
19
  }
15
20
  export declare function ContextMenu<E extends ElementType = 'div'>(props: ContextMenuProps<E> & ElementProps<E>): import("react/jsx-runtime").JSX.Element;
16
21
  export {};
@@ -1,12 +1,18 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Menu, MenuItem, showContextMenu, } from '@blueprintjs/core';
2
+ import { Menu, MenuItem, showContextMenu, Tooltip, } from '@blueprintjs/core';
3
3
  export function ContextMenu(props) {
4
- const { options, onSelect, children, as: Wrapper = 'div', ...other } = props;
4
+ const { options, onSelect, children, as: Wrapper = 'div', data, ...other } = props;
5
5
  function handleContextMenu(event) {
6
6
  if (!Array.isArray(options) || options.length === 0) {
7
7
  return;
8
8
  }
9
- const content = (_jsx(Menu, { children: options.map((option) => (_jsx(MenuItem, { ...option, onClick: () => onSelect(option?.data) }, JSON.stringify(option)))) }));
9
+ const content = (_jsx(Menu, { children: options
10
+ .filter(({ visible = true }) => typeof visible === 'function' ? visible(data) : visible)
11
+ .map(({ tooltip = {}, ...options }) => {
12
+ const { disabled = false, visible, ...otherOptions } = options;
13
+ const isDisabled = typeof disabled === 'function' ? disabled(data) : disabled;
14
+ return (_jsx(Tooltip, { disabled: !tooltip?.content, renderTarget: ({ isOpen, ...targetProps }) => (_jsx("div", { ...targetProps, children: _jsx(MenuItem, { disabled: isDisabled, ...otherOptions, onClick: () => onSelect(otherOptions?.data) }) })), ...tooltip }, otherOptions.text));
15
+ }) }));
10
16
  event.preventDefault();
11
17
  showContextMenu({
12
18
  content,
@@ -64,7 +64,7 @@ function getClasses(isDebounced) {
64
64
  return classes.join(' ');
65
65
  }
66
66
  function InnerInput(props, ref) {
67
- const { debounceTime = 0, onChange, checkValue, value: externalValue, getFilterValue = (item) => item, filterItems, leftIcon, autoSelect = false, ...otherInputProps } = props;
67
+ const { debounceTime = 0, onChange, checkValue, value: externalValue, getFilterValue = (item) => item, filterItems, leftIcon, autoSelect = false, fill, ...otherInputProps } = props;
68
68
  const { handleChange, setValue, isDebounced, innerRef, value } = useInput({
69
69
  value: externalValue,
70
70
  ref,
@@ -97,7 +97,7 @@ function InnerInput(props, ref) {
97
97
  inputClassName: classes,
98
98
  inputRef: innerRef,
99
99
  ...otherInputProps,
100
- }, items: [], query: value || '', onQueryChange: handleChange, popoverProps: { disabled: true }, ...(filterItems &&
100
+ }, items: [], query: value ?? '', onQueryChange: handleChange, fill: fill, popoverProps: { disabled: true }, ...(filterItems &&
101
101
  filterItems.length > 0 && {
102
102
  items: filterItems,
103
103
  itemRenderer: renderItem,
@@ -1,3 +1,4 @@
1
+ /** @jsxImportSource @emotion/react */
1
2
  import { ControllerProps, FieldValues } from 'react-hook-form';
2
3
  import { Input2Props } from './Input2';
3
4
  export interface InputMapValueFunctions {
@@ -5,8 +6,9 @@ export interface InputMapValueFunctions {
5
6
  mapValue?: (value: any) => string;
6
7
  }
7
8
  interface Input2ControllerProps<TFieldValues extends FieldValues = FieldValues> extends Omit<Input2Props, 'name'>, Pick<ControllerProps<TFieldValues>, 'control' | 'name'>, InputMapValueFunctions {
8
- controllerProps?: Omit<ControllerProps<TFieldValues>, 'render'>;
9
+ controllerProps?: Omit<ControllerProps<TFieldValues>, 'control' | 'name' | 'render'>;
9
10
  noShadowBox?: boolean;
11
+ enableErrorMessage?: boolean;
10
12
  }
11
- export declare function Input2Controller<TFieldValues extends FieldValues = FieldValues>(props: Input2ControllerProps<TFieldValues>): import("react/jsx-runtime").JSX.Element;
13
+ export declare function Input2Controller<TFieldValues extends FieldValues = FieldValues>(props: Input2ControllerProps<TFieldValues>): import("@emotion/react/jsx-runtime").JSX.Element;
12
14
  export {};