nmrium 0.58.0 → 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.
- package/lib/component/1d/integral/IntegralResizable.js +2 -2
- package/lib/component/1d/matrix/useMatrix.d.ts +1 -1
- package/lib/component/1d/multiAnalysis/AnalysisRange.js +1 -1
- package/lib/component/1d/ranges/Atoms.js +6 -4
- package/lib/component/2d/Viewer2D.js +6 -2
- package/lib/component/2d/zones/Zone.js +2 -2
- package/lib/component/EventsTrackers/KeysListenerTracker.js +8 -8
- package/lib/component/context/ChartContext.js +12 -1
- package/lib/component/context/ShareDataContext.d.ts +1 -1
- package/lib/component/context/ShareDataContext.js +2 -4
- package/lib/component/context/ToasterContext.d.ts +1 -0
- package/lib/component/context/ToasterContext.js +12 -3
- package/lib/component/elements/ActionsButtonsPopover.js +1 -3
- package/lib/component/elements/Alert.d.ts +20 -0
- package/lib/component/elements/Alert.js +80 -0
- package/lib/component/elements/ContextMenuBluePrint.d.ts +7 -2
- package/lib/component/elements/ContextMenuBluePrint.js +9 -3
- package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +1 -1
- package/lib/component/elements/ReactTable/ReactTableFlexLayout.d.ts +0 -3
- package/lib/component/elements/ReactTable/ReactTableFlexLayout.js +1 -1
- package/lib/component/elements/Select2.d.ts +12 -7
- package/lib/component/elements/Select2.js +5 -4
- package/lib/component/elements/Select2Controller.d.ts +2 -2
- package/lib/component/elements/Select2Controller.js +5 -5
- package/lib/component/elements/ToolbarPopoverItem.d.ts +7 -6
- package/lib/component/elements/ToolbarPopoverItem.js +13 -5
- package/lib/component/elements/print/PrintContent.d.ts +17 -0
- package/lib/component/elements/print/PrintContent.js +281 -0
- package/lib/component/elements/print/PrintProvider.d.ts +12 -0
- package/lib/component/elements/print/PrintProvider.js +28 -0
- package/lib/component/elements/print/index.d.ts +2 -0
- package/lib/component/elements/print/index.js +2 -0
- package/lib/component/header/BaseLineCorrectionPanel.js +3 -0
- package/lib/component/hooks/useToggleSpectraVisibility.d.ts +14 -9
- package/lib/component/hooks/useToggleSpectraVisibility.js +45 -16
- package/lib/component/loader/DropZone.js +3 -67
- package/lib/component/loader/useLoadFiles.d.ts +1 -0
- package/lib/component/loader/useLoadFiles.js +78 -0
- package/lib/component/main/InnerNMRium.d.ts +4 -3
- package/lib/component/main/InnerNMRium.js +4 -9
- package/lib/component/main/InnerNMRiumContents.d.ts +3 -2
- package/lib/component/main/InnerNMRiumContents.js +33 -29
- package/lib/component/main/NMRium.d.ts +2 -5
- package/lib/component/main/NMRium.js +1 -1
- package/lib/component/main/NMRiumRefAPI.d.ts +7 -0
- package/lib/component/main/NMRiumRefAPI.js +12 -0
- package/lib/component/main/NMRiumViewer.d.ts +10 -0
- package/lib/component/main/NMRiumViewer.js +35 -0
- package/lib/component/main/index.d.ts +1 -0
- package/lib/component/modal/CopyClipboardModal.d.ts +3 -2
- package/lib/component/modal/CopyClipboardModal.js +18 -32
- package/lib/component/modal/ExportAsJcampModal.d.ts +6 -3
- package/lib/component/modal/ExportAsJcampModal.js +69 -35
- package/lib/component/modal/ImportPublicationStringModal.js +1 -1
- package/lib/component/modal/setting/GeneralSettings.js +4 -2
- package/lib/component/modal/setting/settings-tabs/ExternalAPIsTabContent.d.ts +1 -0
- package/lib/component/modal/setting/settings-tabs/ExternalAPIsTabContent.js +89 -0
- package/lib/component/modal/setting/settingsValidation.js +15 -1
- package/lib/component/panels/IntegralsPanel/IntegralPanel.js +8 -5
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +5 -1
- package/lib/component/panels/Panels.js +2 -2
- package/lib/component/panels/PeaksPanel/PeaksPanel.js +8 -5
- package/lib/component/panels/RangesPanel/RangesHeader.js +52 -12
- package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +13 -6
- package/lib/component/panels/SpectraPanel/SpectraTable.js +63 -21
- package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnHeader.js +6 -2
- package/lib/component/panels/SummaryPanel/CorrelationTable/CorrelationTableRow.js +6 -2
- package/lib/component/panels/SummaryPanel/SummaryPanel.js +4 -0
- package/lib/component/panels/ZonesPanel/ZonesPanel.js +16 -8
- package/lib/component/panels/databasePanel/DatabasePanel.js +7 -8
- package/lib/component/panels/filtersPanel/FilterPanel.js +9 -6
- package/lib/component/panels/filtersPanel/FiltersTable.js +12 -10
- package/lib/component/panels/header/DefaultPanelHeader.d.ts +1 -0
- package/lib/component/panels/header/DefaultPanelHeader.js +2 -2
- package/lib/component/panels/multipleAnalysisPanel/AlignSpectra.js +10 -12
- package/lib/component/reducer/IgnoreActions.js +1 -0
- package/lib/component/reducer/Reducer.js +2 -4
- package/lib/component/reducer/actions/DatabaseActions.d.ts +15 -13
- package/lib/component/reducer/actions/DatabaseActions.js +52 -34
- package/lib/component/reducer/actions/DomainActions.d.ts +2 -2
- package/lib/component/reducer/actions/FiltersActions.js +9 -4
- package/lib/component/reducer/actions/SpectraActions.d.ts +2 -1
- package/lib/component/reducer/actions/SpectraActions.js +53 -43
- package/lib/component/reducer/helper/removeSpectrumRelatedObjectsById.d.ts +3 -0
- package/lib/component/reducer/helper/removeSpectrumRelatedObjectsById.js +16 -0
- package/lib/component/reducer/preferences/actions/changePrintPageSettings.d.ts +3 -0
- package/lib/component/reducer/preferences/actions/changePrintPageSettings.js +6 -0
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +3 -2
- package/lib/component/reducer/preferences/preferencesReducer.js +4 -1
- package/lib/component/toolbar/ToolBar.js +33 -14
- package/lib/component/workspaces/workspaceDefaultProperties.js +2 -0
- package/lib/data/SpectraManager.d.ts +7 -10
- package/lib/data/SpectraManager.js +51 -30
- package/lib/data/data1d/Spectrum1D/SumManager.d.ts +0 -1
- package/lib/data/data1d/Spectrum1D/SumManager.js +2 -10
- package/lib/data/data1d/Spectrum1D/get1DColor.d.ts +1 -1
- package/lib/data/data1d/Spectrum1D/index.d.ts +1 -1
- package/lib/data/data1d/Spectrum1D/index.js +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +10 -10
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +2 -1
- package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +10 -10
- package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +10 -10
- package/lib/data/data1d/Spectrum1D/ranges/resurrectSpectrum.d.ts +13 -0
- package/lib/data/data1d/Spectrum1D/ranges/resurrectSpectrum.js +65 -0
- package/lib/data/molecules/MoleculeManager.js +16 -38
- package/lib/data/utilities/getCustomColor.d.ts +1 -1
- package/lib/data/utilities/removeByPaths.d.ts +3 -0
- package/lib/data/utilities/removeByPaths.js +33 -0
- package/lib/versionInfo.js +1 -1
- package/package.json +34 -34
- package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.d.ts +0 -11
- 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
|
-
|
|
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
|
-
|
|
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:
|
|
16
|
+
x: never[] | Float64Array;
|
|
17
17
|
matrixY: Float64Array[];
|
|
18
18
|
} | null;
|
|
19
19
|
interface InterpolateColorsPointsOptions {
|
|
@@ -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
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
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) {
|
|
@@ -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
|
-
|
|
164
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
25
|
+
function dismiss() {
|
|
26
26
|
if (toastKey) {
|
|
27
27
|
toasterRef.current?.dismiss(toastKey);
|
|
28
28
|
}
|
|
29
|
-
}
|
|
29
|
+
}
|
|
30
|
+
return dismiss;
|
|
30
31
|
}
|
|
31
|
-
|
|
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
|
}
|
|
@@ -17,9 +17,7 @@ export function ActionsButtonsPopover(props) {
|
|
|
17
17
|
}
|
|
18
18
|
`, children: buttons
|
|
19
19
|
.filter((button) => button?.visible !== false)
|
|
20
|
-
.map(({ title, ...otherProps }, index, array) => (_jsxs(Fragment, { children: [_jsx(Button, { tooltipProps: { content: title || '', compact: true }, ...otherProps }), index < array.length - 1 && (
|
|
21
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
22
|
-
_jsx("div", { style: {
|
|
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: {
|
|
23
21
|
margin: direction === 'row' ? `0 ${space}px` : `${space}px 0`,
|
|
24
22
|
} }, `spacer-${index}`))] }, title || index))) }), ...otherProps, children: children }));
|
|
25
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
|
|
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
|
|
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,
|
|
@@ -52,7 +52,7 @@ function ReactTableRow(props) {
|
|
|
52
52
|
onClick?.(event, row);
|
|
53
53
|
}, [onClick, row]);
|
|
54
54
|
const { key: rowKey, ...otherKeyProps } = row.getRowProps();
|
|
55
|
-
return (_jsx(ContextMenu, { options: contextMenu, onSelect: (selected) => onContextMenuSelect?.(selected, row.original), as: "tr", style: { position: 'static' }, css: getRowStyle(highlight.isActive || isRowActive, rowStyle, disableDefaultRowStyle), ...otherKeyProps, ...highlight.onHover, children: row.cells.map((cell) => {
|
|
55
|
+
return (_jsx(ContextMenu, { data: row.original, options: contextMenu, onSelect: (selected) => onContextMenuSelect?.(selected, row.original), as: "tr", style: { position: 'static' }, css: getRowStyle(highlight.isActive || isRowActive, rowStyle, disableDefaultRowStyle), ...otherKeyProps, ...highlight.onHover, children: row.cells.map((cell) => {
|
|
56
56
|
const { column: { style }, isRowSpanned, } = cell;
|
|
57
57
|
if (isRowSpanned) {
|
|
58
58
|
return null;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
/** @jsxImportSource @emotion/react */
|
|
2
2
|
import { CSSProperties } from 'react';
|
|
3
|
-
import { UseSortByOptions } from 'react-table';
|
|
4
3
|
interface ReactTableFlexLayoutProps {
|
|
5
4
|
data: any;
|
|
6
5
|
columns: any;
|
|
7
6
|
onMouseDown?: () => void;
|
|
8
7
|
style?: CSSProperties;
|
|
9
8
|
}
|
|
10
|
-
export interface TableOptions<D extends Record<string, unknown>> extends UseSortByOptions<D> {
|
|
11
|
-
}
|
|
12
9
|
declare function ReactTableFlexLayout({ data, columns, onMouseDown, style, }: ReactTableFlexLayoutProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
13
10
|
export default ReactTableFlexLayout;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { useTable, useSortBy, useFlexLayout
|
|
2
|
+
import { useTable, useSortBy, useFlexLayout } from 'react-table';
|
|
3
3
|
import { ReactTableStyle } from './Style';
|
|
4
4
|
function ReactTableFlexLayout({ data, columns, onMouseDown = () => null, style = {}, }) {
|
|
5
5
|
const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow } = useTable({
|
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
import { ButtonProps } from '@blueprintjs/core';
|
|
2
2
|
import { SelectProps } from '@blueprintjs/select';
|
|
3
|
-
import { ReactNode } from 'react';
|
|
3
|
+
import { ForwardedRef, ReactNode } from 'react';
|
|
4
4
|
import { useSelect } from 'react-science/ui';
|
|
5
5
|
import { FilterType } from '../utility/filterType';
|
|
6
6
|
interface ItemOptions<T> {
|
|
7
7
|
renderItem?: (item: T) => ReactNode;
|
|
8
8
|
defaultSelectedItem?: T;
|
|
9
9
|
}
|
|
10
|
-
interface ItemSelectOptions<T extends
|
|
10
|
+
interface ItemSelectOptions<T extends Record<string, any> = SelectDefaultItem> {
|
|
11
11
|
itemTextKey?: keyof FilterType<T, string>;
|
|
12
12
|
itemValueKey?: keyof T;
|
|
13
13
|
selectedItemValue?: T[keyof T];
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
filterPlaceholder?: string;
|
|
14
16
|
}
|
|
15
|
-
type SelectOptions<T extends
|
|
17
|
+
type SelectOptions<T extends Record<string, any> = SelectDefaultItem> = ItemOptions<T> & ItemSelectOptions<T>;
|
|
16
18
|
type ReturnedUseSelectOptions = ReturnType<typeof useSelect>;
|
|
17
|
-
export type Select2Props<T extends
|
|
19
|
+
export type Select2Props<T extends Record<string, any> = SelectDefaultItem> = Omit<SelectProps<T>, keyof Omit<ReturnedUseSelectOptions, 'onItemSelect' | 'value'>> & SelectOptions<T> & {
|
|
18
20
|
selectedButtonProps?: Omit<ButtonProps, 'text'>;
|
|
19
|
-
}
|
|
20
|
-
export declare function getDefaultSelectedItem<T extends
|
|
21
|
+
} & Pick<ButtonProps, 'intent'>;
|
|
22
|
+
export declare function getDefaultSelectedItem<T extends Record<string, any> = SelectDefaultItem>(items: T[], itemValueKey?: keyof T, value?: any): T | undefined;
|
|
21
23
|
export interface SelectDefaultItem {
|
|
22
24
|
label: string;
|
|
23
25
|
value: any;
|
|
24
26
|
}
|
|
25
|
-
|
|
27
|
+
declare function InnerSelect2<T extends Record<string, any> = SelectDefaultItem>(props: Select2Props<T>, ref: any): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export declare const Select2: <T extends Record<string, any> = SelectDefaultItem>(props: Select2Props<T> & {
|
|
29
|
+
ref?: ForwardedRef<HTMLButtonElement>;
|
|
30
|
+
}) => ReturnType<typeof InnerSelect2>;
|
|
26
31
|
export {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Button } from '@blueprintjs/core';
|
|
3
3
|
import { Select } from '@blueprintjs/select';
|
|
4
|
-
import { useEffect } from 'react';
|
|
4
|
+
import { forwardRef, useEffect } from 'react';
|
|
5
5
|
import { useSelect } from 'react-science/ui';
|
|
6
6
|
export function getDefaultSelectedItem(items, itemValueKey, value) {
|
|
7
7
|
return items.find((item) => itemValueKey && item[itemValueKey] === value);
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
const { items, defaultSelectedItem, itemTextKey = 'label', itemValueKey = 'value', selectedItemValue, onItemSelect, selectedButtonProps, fill, ...otherProps } = props;
|
|
9
|
+
function InnerSelect2(props, ref) {
|
|
10
|
+
const { items, defaultSelectedItem, itemTextKey = 'label', itemValueKey = 'value', selectedItemValue, onItemSelect, selectedButtonProps, fill, intent, placeholder = '', filterPlaceholder, ...otherProps } = props;
|
|
11
11
|
const { value: item, onItemSelect: innerOnItemSelect, setValue, ...defaultSelectProps } = useSelect({
|
|
12
12
|
defaultSelectedItem: defaultSelectedItem ??
|
|
13
13
|
getDefaultSelectedItem(items, itemValueKey, selectedItemValue),
|
|
@@ -21,5 +21,6 @@ export function Select2(props) {
|
|
|
21
21
|
return (_jsx(Select, { items: items, filterable: false, onItemSelect: (item, event) => {
|
|
22
22
|
innerOnItemSelect(item);
|
|
23
23
|
onItemSelect(item, event);
|
|
24
|
-
}, ...defaultSelectProps, ...otherProps, fill: fill, children: _jsx(Button, { fill: fill, text: item?.[itemTextKey] ? String(item[itemTextKey]) :
|
|
24
|
+
}, ...defaultSelectProps, ...otherProps, placeholder: filterPlaceholder, fill: fill, children: _jsx(Button, { ref: ref, fill: fill, text: item?.[itemTextKey] ? String(item[itemTextKey]) : placeholder, ...selectedButtonProps, rightIcon: "double-caret-vertical", intent: intent }) }));
|
|
25
25
|
}
|
|
26
|
+
export const Select2 = forwardRef(InnerSelect2);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ControllerProps, FieldValues } from 'react-hook-form';
|
|
2
2
|
import { Select2Props, SelectDefaultItem } from './Select2';
|
|
3
|
-
type Select2ControllerProps<T extends
|
|
3
|
+
type Select2ControllerProps<T extends Record<string, any> = SelectDefaultItem, TFieldValues extends FieldValues = FieldValues> = {
|
|
4
4
|
controllerProps?: Omit<ControllerProps<TFieldValues>, 'render'>;
|
|
5
5
|
} & Pick<ControllerProps<TFieldValues>, 'control' | 'name'> & Omit<Select2Props<T>, 'onItemSelect' | 'selectedItemValue'> & Partial<Pick<Select2Props<T>, 'onItemSelect'>>;
|
|
6
|
-
export declare function Select2Controller<T extends
|
|
6
|
+
export declare function Select2Controller<T extends Record<string, any>, TFieldValues extends FieldValues = FieldValues>(props: Select2ControllerProps<T, TFieldValues>): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export {};
|
|
@@ -2,11 +2,11 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { Controller } from 'react-hook-form';
|
|
3
3
|
import { Select2 } from './Select2';
|
|
4
4
|
export function Select2Controller(props) {
|
|
5
|
-
const { name, control, controllerProps = {}, onItemSelect, ...otherSelectProps } = props;
|
|
6
|
-
return (_jsx(Controller, { name: name, control: control, ...controllerProps, render: ({ field }) => {
|
|
7
|
-
return (_jsx(Select2, { selectedItemValue: field.value, onItemSelect: (item, event) => {
|
|
8
|
-
field.onChange(item
|
|
5
|
+
const { name, control, controllerProps = {}, onItemSelect, intent, itemValueKey = 'value', ...otherSelectProps } = props;
|
|
6
|
+
return (_jsx(Controller, { name: name, control: control, ...controllerProps, render: ({ field, fieldState: { invalid } }) => {
|
|
7
|
+
return (_jsx(Select2, { itemValueKey: itemValueKey, selectedItemValue: field.value, onItemSelect: (item, event) => {
|
|
8
|
+
field.onChange(item[itemValueKey]);
|
|
9
9
|
onItemSelect?.(item, event);
|
|
10
|
-
}, ...otherSelectProps }));
|
|
10
|
+
}, ...otherSelectProps, intent: invalid ? 'danger' : intent }));
|
|
11
11
|
} }));
|
|
12
12
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { MenuItemProps } from '@blueprintjs/core';
|
|
2
2
|
import { ToolbarPopoverItemProps as BaseToolbarPopoverItemProps, ToolbarItemProps } from 'react-science/ui';
|
|
3
|
-
export interface ToolbarPopoverMenuItem extends MenuItemProps {
|
|
4
|
-
data?:
|
|
3
|
+
export interface ToolbarPopoverMenuItem<T = object> extends MenuItemProps {
|
|
4
|
+
data?: T;
|
|
5
5
|
}
|
|
6
|
-
interface ToolbarPopoverItemProps extends Omit<BaseToolbarPopoverItemProps, 'onClick' | 'content' | 'itemProps'>, ToolbarItemProps {
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
interface ToolbarPopoverItemProps<T = object> extends Omit<BaseToolbarPopoverItemProps, 'onClick' | 'content' | 'itemProps'>, Pick<ToolbarItemProps, 'tooltip' | 'icon' | 'tooltipProps' | 'active' | 'id'> {
|
|
7
|
+
itemProps?: Omit<ToolbarItemProps, 'onClick' | 'disabled'>;
|
|
8
|
+
options: Array<ToolbarPopoverMenuItem<T>>;
|
|
9
|
+
onClick: (data?: T) => void;
|
|
9
10
|
}
|
|
10
|
-
export declare function ToolbarPopoverItem(props: ToolbarPopoverItemProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function ToolbarPopoverItem<T = object>(props: ToolbarPopoverItemProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
11
12
|
export {};
|
|
@@ -2,9 +2,17 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { Menu, MenuItem } from '@blueprintjs/core';
|
|
3
3
|
import { Toolbar, } from 'react-science/ui';
|
|
4
4
|
export function ToolbarPopoverItem(props) {
|
|
5
|
-
const { options, onClick,
|
|
6
|
-
return (_jsx(Toolbar.PopoverItem, { content: _jsx(Menu, { children: options.map((option) => {
|
|
7
|
-
const { data, ...otherOptions } = option;
|
|
8
|
-
return (_jsx(MenuItem, { ...otherOptions, onClick: () => onClick(data) }, JSON.stringify(
|
|
9
|
-
}) }), itemProps:
|
|
5
|
+
const { options, onClick, icon, tooltip, tooltipProps, active, id, itemProps, disabled, ...otherPopoverItemProps } = props;
|
|
6
|
+
return (_jsx(Toolbar.PopoverItem, { disabled: disabled, ...otherPopoverItemProps, content: _jsx(Menu, { children: options.map((option) => {
|
|
7
|
+
const { data, text, ...otherOptions } = option;
|
|
8
|
+
return (_jsx(MenuItem, { text: text, ...otherOptions, onClick: () => onClick(data) }, JSON.stringify({ data, text })));
|
|
9
|
+
}) }), itemProps: {
|
|
10
|
+
icon,
|
|
11
|
+
tooltip,
|
|
12
|
+
tooltipProps,
|
|
13
|
+
active,
|
|
14
|
+
id,
|
|
15
|
+
disabled,
|
|
16
|
+
...itemProps,
|
|
17
|
+
} }));
|
|
10
18
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PrintPageOptions } from 'nmr-load-save';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
interface BasePrintProps {
|
|
4
|
+
onPrint: (options: PrintPageOptions) => void;
|
|
5
|
+
defaultPrintPageOptions: Partial<PrintPageOptions>;
|
|
6
|
+
}
|
|
7
|
+
interface InnerPrintFrameProps {
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
onAfterPrint?: () => void;
|
|
10
|
+
onBeforePrint?: () => void;
|
|
11
|
+
printPageOptions?: Partial<PrintPageOptions>;
|
|
12
|
+
}
|
|
13
|
+
interface PrintFrameProps extends InnerPrintFrameProps, Partial<BasePrintProps> {
|
|
14
|
+
}
|
|
15
|
+
export declare function PrintContent(props: PrintFrameProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare function InnerPrintFrame(props: InnerPrintFrameProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
17
|
+
export {};
|