nmrium 0.38.2 → 0.40.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/component/1d/multiAnalysis/MultiAnalysisRanges.js +1 -1
- package/lib/component/EventsTrackers/KeysListenerTracker.js +90 -67
- package/lib/component/NMRium.d.ts +1 -0
- package/lib/component/NMRium.js +4 -2
- package/lib/component/context/LoggerContext.js +12 -2
- package/lib/component/context/PreferencesContext.d.ts +4 -2
- package/lib/component/elements/formik/FormikError.d.ts +8 -0
- package/lib/component/elements/formik/FormikError.js +22 -0
- package/lib/component/elements/popup/Alert/AlertBlock.d.ts +7 -0
- package/lib/component/elements/popup/Alert/AlertBlock.js +24 -0
- package/lib/component/elements/popup/Alert/Provider.js +2 -20
- package/lib/component/elements/popup/Modal/ConfirmDialog.js +2 -1
- package/lib/component/header/Header.js +2 -2
- package/lib/component/hooks/useSaveSettings.js +18 -16
- package/lib/component/modal/AboutUsModal.js +4 -2
- package/lib/component/modal/LoadJCAMPModal.js +41 -28
- package/lib/component/modal/LogsHistoryModal.d.ts +6 -0
- package/lib/component/{header/LogsHistory.js → modal/LogsHistoryModal.js} +6 -4
- package/lib/component/modal/PredictSpectraModal.js +12 -2
- package/lib/component/modal/editRange/EditRangeModal.d.ts +7 -6
- package/lib/component/modal/editRange/EditRangeModal.js +33 -13
- package/lib/component/modal/setting/GeneralSettings.js +29 -28
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +18 -16
- package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +9 -13
- package/lib/component/panels/MultipleSpectraAnalysisPanel/preferences/AnalysisTablePreferences.js +1 -1
- package/lib/component/panels/Panels.js +2 -2
- package/lib/component/panels/RangesPanel/RangesHeader.js +9 -15
- package/lib/component/panels/RangesPanel/RangesPanel.js +7 -10
- package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.d.ts +1 -1
- package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.js +9 -12
- package/lib/component/panels/SpectrumsPanel/SpectraTable.js +7 -10
- package/lib/component/panels/predictionPanel/PredictionPanel.js +3 -1
- package/lib/component/reducer/actions/DatabaseActions.js +6 -4
- package/lib/component/reducer/actions/DomainActions.js +3 -0
- package/lib/component/reducer/actions/IntegralsActions.js +3 -1
- package/lib/component/reducer/actions/SpectrumsActions.js +6 -6
- package/lib/component/reducer/actions/ToolsActions.js +3 -32
- package/lib/component/reducer/actions/ZonesActions.js +2 -4
- package/lib/component/reducer/helper/ZoomHistoryManager.d.ts +8 -0
- package/lib/component/reducer/helper/ZoomHistoryManager.js +35 -0
- package/lib/component/reducer/preferences/actions/addWorkspace.js +2 -2
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +2 -2
- package/lib/component/utility/export.d.ts +5 -4
- package/lib/component/utility/export.js +24 -52
- package/lib/data/PredictionManager.d.ts +3 -1
- package/lib/data/PredictionManager.js +27 -1
- package/lib/data/data1d/Spectrum1D/generateSpectrumFromPublicationString.d.ts +1 -2
- package/lib/data/data1d/Spectrum1D/integrals/initiateIntegrals.d.ts +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectSignal.js +13 -6
- package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.d.ts +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.js +23 -18
- package/lib/utils/clipboard/clipboard.d.ts +12 -0
- package/lib/utils/clipboard/clipboard.js +15 -0
- package/lib/utils/clipboard/clipboardComponents.d.ts +45 -0
- package/lib/utils/clipboard/clipboardComponents.js +150 -0
- package/lib/utils/clipboard/clipboardHooks.d.ts +94 -0
- package/lib/utils/clipboard/clipboardHooks.js +142 -0
- package/lib/utils/clipboard/types.d.ts +1 -0
- package/lib/utils/clipboard/types.js +1 -0
- package/lib/versionInfo.js +1 -1
- package/lib-cjs/component/1d/multiAnalysis/MultiAnalysisRanges.js +1 -1
- package/lib-cjs/component/EventsTrackers/KeysListenerTracker.js +90 -67
- package/lib-cjs/component/NMRium.js +4 -2
- package/lib-cjs/component/context/LoggerContext.js +11 -1
- package/lib-cjs/component/elements/formik/FormikError.js +27 -0
- package/lib-cjs/component/elements/popup/Alert/AlertBlock.js +30 -0
- package/lib-cjs/component/elements/popup/Alert/Provider.js +2 -20
- package/lib-cjs/component/elements/popup/Modal/ConfirmDialog.js +2 -1
- package/lib-cjs/component/header/Header.js +2 -2
- package/lib-cjs/component/hooks/useSaveSettings.js +17 -15
- package/lib-cjs/component/modal/AboutUsModal.js +4 -2
- package/lib-cjs/component/modal/LoadJCAMPModal.js +41 -28
- package/lib-cjs/component/{header/LogsHistory.js → modal/LogsHistoryModal.js} +8 -6
- package/lib-cjs/component/modal/PredictSpectraModal.js +12 -2
- package/lib-cjs/component/modal/editRange/EditRangeModal.js +32 -12
- package/lib-cjs/component/modal/setting/GeneralSettings.js +29 -28
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +17 -15
- package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +9 -13
- package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/preferences/AnalysisTablePreferences.js +1 -1
- package/lib-cjs/component/panels/Panels.js +2 -2
- package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +9 -15
- package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +7 -10
- package/lib-cjs/component/panels/RangesPanel/hooks/useEditRangeModal.js +9 -12
- package/lib-cjs/component/panels/SpectrumsPanel/SpectraTable.js +7 -10
- package/lib-cjs/component/panels/predictionPanel/PredictionPanel.js +3 -1
- package/lib-cjs/component/reducer/actions/DatabaseActions.js +6 -4
- package/lib-cjs/component/reducer/actions/DomainActions.js +3 -0
- package/lib-cjs/component/reducer/actions/IntegralsActions.js +3 -1
- package/lib-cjs/component/reducer/actions/SpectrumsActions.js +6 -6
- package/lib-cjs/component/reducer/actions/ToolsActions.js +26 -32
- package/lib-cjs/component/reducer/actions/ZonesActions.js +2 -4
- package/lib-cjs/component/reducer/helper/ZoomHistoryManager.js +37 -0
- package/lib-cjs/component/reducer/preferences/actions/addWorkspace.js +2 -2
- package/lib-cjs/component/utility/export.js +24 -54
- package/lib-cjs/data/PredictionManager.js +27 -1
- package/lib-cjs/data/data1d/Spectrum1D/ranges/detectSignal.js +13 -6
- package/lib-cjs/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.js +23 -18
- package/lib-cjs/utils/clipboard/clipboard.js +23 -0
- package/lib-cjs/utils/clipboard/clipboardComponents.js +158 -0
- package/lib-cjs/utils/clipboard/clipboardHooks.js +147 -0
- package/lib-cjs/utils/clipboard/types.js +2 -0
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +17 -17
- package/lib/component/header/LogsHistory.d.ts +0 -1
|
@@ -0,0 +1,158 @@
|
|
|
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
|
+
exports.ClipboardFallbackModal = exports.ClipboardFallback = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const ui_1 = require("react-science/ui");
|
|
11
|
+
const Button_1 = __importDefault(require("../../component/elements/Button"));
|
|
12
|
+
const ClipboardForm = styled_1.default.form `
|
|
13
|
+
padding: 0.5rem;
|
|
14
|
+
|
|
15
|
+
& > label {
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
gap: 0.5rem;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
textarea {
|
|
22
|
+
padding: 0.5rem;
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
const Actions = styled_1.default.div `
|
|
26
|
+
display: flex;
|
|
27
|
+
gap: 0.5rem;
|
|
28
|
+
justify-content: flex-end;
|
|
29
|
+
`;
|
|
30
|
+
function throwError(props, prop) {
|
|
31
|
+
throw new Error(`props.${prop} is mandatory with ${String(props.mode)} mode`);
|
|
32
|
+
}
|
|
33
|
+
function assertReadProps(props) {
|
|
34
|
+
if (typeof props.onRead !== 'function')
|
|
35
|
+
throwError(props, 'onRead');
|
|
36
|
+
}
|
|
37
|
+
function assertReadTextProps(props) {
|
|
38
|
+
if (typeof props.onReadText !== 'function')
|
|
39
|
+
throwError(props, 'onReadText');
|
|
40
|
+
}
|
|
41
|
+
function assertWriteProps(props) {
|
|
42
|
+
if (!props.file)
|
|
43
|
+
throwError(props, 'file');
|
|
44
|
+
if (typeof props.onDismiss !== 'function')
|
|
45
|
+
throwError(props, 'onDismiss');
|
|
46
|
+
}
|
|
47
|
+
function assertWriteTextProps(props) {
|
|
48
|
+
if (typeof props.text !== 'string')
|
|
49
|
+
throwError(props, 'text');
|
|
50
|
+
if (typeof props.onDismiss !== 'function')
|
|
51
|
+
throwError(props, 'onDismiss');
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* switch between ClipboardFallback variant over mode props
|
|
55
|
+
* mode === read => ClipboardFallbackReadProps
|
|
56
|
+
* mode === readText => ClipboardFallbackReadTextProps
|
|
57
|
+
* mode === write => ClipboardFallbackWriteProps
|
|
58
|
+
* mode === writeText => ClipboardFallbackWriteTextProps
|
|
59
|
+
*
|
|
60
|
+
* implement what you need in function what part of the clipboard api from useClipboard you use
|
|
61
|
+
* props will be checked at runtime
|
|
62
|
+
*
|
|
63
|
+
* @param props
|
|
64
|
+
*/
|
|
65
|
+
function ClipboardFallback(props) {
|
|
66
|
+
switch (props.mode) {
|
|
67
|
+
case 'read':
|
|
68
|
+
assertReadProps(props);
|
|
69
|
+
return (0, jsx_runtime_1.jsx)(ClipboardFallbackRead, { ...props });
|
|
70
|
+
case 'readText':
|
|
71
|
+
assertReadTextProps(props);
|
|
72
|
+
return (0, jsx_runtime_1.jsx)(ClipboardFallbackReadText, { ...props });
|
|
73
|
+
case 'write': {
|
|
74
|
+
assertWriteProps(props);
|
|
75
|
+
return (0, jsx_runtime_1.jsx)(ClipboardFallbackWrite, { ...props });
|
|
76
|
+
}
|
|
77
|
+
case 'writeText':
|
|
78
|
+
assertWriteTextProps(props);
|
|
79
|
+
return (0, jsx_runtime_1.jsx)(ClipboardFallbackWriteText, { ...props });
|
|
80
|
+
default:
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.ClipboardFallback = ClipboardFallback;
|
|
85
|
+
/**
|
|
86
|
+
* return null if !props.mode
|
|
87
|
+
*
|
|
88
|
+
* @param props
|
|
89
|
+
* @see ClipboardFallback
|
|
90
|
+
*/
|
|
91
|
+
function ClipboardFallbackModal(props) {
|
|
92
|
+
if (!props.mode)
|
|
93
|
+
return null;
|
|
94
|
+
const titles = {
|
|
95
|
+
read: `Import data from file`,
|
|
96
|
+
readText: `Paste text from clipboard`,
|
|
97
|
+
write: `Export data to file`,
|
|
98
|
+
writeText: `Copy text from text area`,
|
|
99
|
+
};
|
|
100
|
+
return ((0, jsx_runtime_1.jsxs)(ui_1.Modal, { hasCloseButton: true, isOpen: true, onRequestClose: props.onDismiss, children: [(0, jsx_runtime_1.jsx)(ui_1.Modal.Header, { children: (0, jsx_runtime_1.jsx)("h2", { children: titles[props.mode] }) }), (0, jsx_runtime_1.jsx)(ui_1.Modal.Body, { children: (0, jsx_runtime_1.jsx)(ClipboardFallback, { ...props }) })] }));
|
|
101
|
+
}
|
|
102
|
+
exports.ClipboardFallbackModal = ClipboardFallbackModal;
|
|
103
|
+
function ClipboardFallbackRead(props) {
|
|
104
|
+
const onFileRef = (0, react_1.useRef)(props.onRead);
|
|
105
|
+
onFileRef.current = props.onRead;
|
|
106
|
+
const onSubmit = (0, react_1.useCallback)((event) => {
|
|
107
|
+
event.preventDefault();
|
|
108
|
+
const data = new FormData(event.currentTarget);
|
|
109
|
+
const file = data.get('file');
|
|
110
|
+
if (!(file instanceof File))
|
|
111
|
+
return;
|
|
112
|
+
onFileRef.current(file);
|
|
113
|
+
}, []);
|
|
114
|
+
if (props.mode !== 'read')
|
|
115
|
+
return null;
|
|
116
|
+
return ((0, jsx_runtime_1.jsxs)(ClipboardForm, { onSubmit: onSubmit, children: [(0, jsx_runtime_1.jsxs)("label", { children: [(0, jsx_runtime_1.jsx)("span", { children: props.label ?? 'File' }), (0, jsx_runtime_1.jsx)("input", { name: "file", type: "file" })] }), (0, jsx_runtime_1.jsx)("p", { children: "We were not able to read from your clipboard. Please input your data in the file field" }), (0, jsx_runtime_1.jsxs)(Actions, { children: [(0, jsx_runtime_1.jsx)(Button_1.default.Done, { type: "submit", children: "Submit" }), (0, jsx_runtime_1.jsx)(Button_1.default.Secondary, { type: "reset", onClick: props.onDismiss, children: "Cancel" })] })] }));
|
|
117
|
+
}
|
|
118
|
+
function ClipboardFallbackReadText(props) {
|
|
119
|
+
const onTextRef = (0, react_1.useRef)(props.onReadText);
|
|
120
|
+
onTextRef.current = props.onReadText;
|
|
121
|
+
const onSubmit = (0, react_1.useCallback)((event) => {
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
const data = new FormData(event.currentTarget);
|
|
124
|
+
const text = data.get('text');
|
|
125
|
+
if (typeof text !== 'string')
|
|
126
|
+
return;
|
|
127
|
+
onTextRef.current(text);
|
|
128
|
+
}, []);
|
|
129
|
+
if (props.mode !== 'readText')
|
|
130
|
+
return null;
|
|
131
|
+
return ((0, jsx_runtime_1.jsxs)(ClipboardForm, { onSubmit: onSubmit, children: [(0, jsx_runtime_1.jsxs)("label", { children: [(0, jsx_runtime_1.jsx)("span", { children: props.label ?? 'Text' }), (0, jsx_runtime_1.jsx)("textarea", { name: "text", cols: 50, rows: 10 })] }), (0, jsx_runtime_1.jsx)("p", { children: "We were not able to read text from your clipboard. Please paste your data in the text area." }), (0, jsx_runtime_1.jsxs)(Actions, { children: [(0, jsx_runtime_1.jsx)(Button_1.default.Done, { type: "submit", children: "Submit" }), (0, jsx_runtime_1.jsx)(Button_1.default.Secondary, { type: "reset", onClick: props.onDismiss, children: "Cancel" })] })] }));
|
|
132
|
+
}
|
|
133
|
+
function ClipboardFallbackWrite(props) {
|
|
134
|
+
const onDismissRef = (0, react_1.useRef)(props.onDismiss);
|
|
135
|
+
onDismissRef.current = props.onDismiss;
|
|
136
|
+
const onSubmit = (0, react_1.useCallback)((event) => {
|
|
137
|
+
event.preventDefault();
|
|
138
|
+
onDismissRef.current();
|
|
139
|
+
}, []);
|
|
140
|
+
const downloadLink = (0, react_1.useMemo)(() => URL.createObjectURL(props.file), [props.file]);
|
|
141
|
+
(0, react_1.useEffect)(() => {
|
|
142
|
+
return () => URL.revokeObjectURL(downloadLink);
|
|
143
|
+
}, [downloadLink]);
|
|
144
|
+
if (props.mode !== 'write')
|
|
145
|
+
return null;
|
|
146
|
+
return ((0, jsx_runtime_1.jsxs)(ClipboardForm, { onSubmit: onSubmit, children: [(0, jsx_runtime_1.jsx)("p", { children: props.label ?? 'Download' }), (0, jsx_runtime_1.jsx)("a", { href: downloadLink, download: props.file.name, children: "We were not able to write data to your clipboard. Please download your data with this link." }), (0, jsx_runtime_1.jsx)(Actions, { children: (0, jsx_runtime_1.jsx)(Button_1.default.Secondary, { type: "submit", children: "Dismiss" }) })] }));
|
|
147
|
+
}
|
|
148
|
+
function ClipboardFallbackWriteText(props) {
|
|
149
|
+
const onDismissRef = (0, react_1.useRef)(props.onDismiss);
|
|
150
|
+
onDismissRef.current = props.onDismiss;
|
|
151
|
+
const onSubmit = (0, react_1.useCallback)((event) => {
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
onDismissRef.current();
|
|
154
|
+
}, []);
|
|
155
|
+
if (props.mode !== 'writeText')
|
|
156
|
+
return null;
|
|
157
|
+
return ((0, jsx_runtime_1.jsxs)(ClipboardForm, { onSubmit: onSubmit, children: [(0, jsx_runtime_1.jsx)("span", { children: props.label ?? 'Text' }), (0, jsx_runtime_1.jsx)("textarea", { name: "text", cols: 30, rows: 10, ref: (node) => node?.select(), children: props.text }), (0, jsx_runtime_1.jsx)("p", { children: "We were not able to write text to your clipboard. Please copy your data in the text area." }), (0, jsx_runtime_1.jsx)(Actions, { children: (0, jsx_runtime_1.jsx)(Button_1.default.Secondary, { type: "submit", children: "Dismiss" }) })] }));
|
|
158
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useClipboard = exports.useNavigatorPermission = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const clipboard_1 = require("./clipboard");
|
|
6
|
+
function useNavigatorPermission(now, permissionName, onGranted, onError = reportError) {
|
|
7
|
+
const [state, setState] = (0, react_1.useState)();
|
|
8
|
+
(0, react_1.useEffect)(() => {
|
|
9
|
+
if (!now)
|
|
10
|
+
return;
|
|
11
|
+
let canceled = false;
|
|
12
|
+
let status;
|
|
13
|
+
function onPermissionChange() {
|
|
14
|
+
if (canceled)
|
|
15
|
+
return;
|
|
16
|
+
setState(status.state);
|
|
17
|
+
if (status.state === 'granted') {
|
|
18
|
+
onGranted?.();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
void navigator.permissions
|
|
22
|
+
.query({ name: permissionName })
|
|
23
|
+
.then((pStatus) => {
|
|
24
|
+
if (canceled)
|
|
25
|
+
return;
|
|
26
|
+
status = pStatus;
|
|
27
|
+
setState(status.state);
|
|
28
|
+
status.addEventListener('change', onPermissionChange);
|
|
29
|
+
})
|
|
30
|
+
.catch((error) => {
|
|
31
|
+
if (canceled)
|
|
32
|
+
return;
|
|
33
|
+
onError(error);
|
|
34
|
+
});
|
|
35
|
+
return () => {
|
|
36
|
+
canceled = true;
|
|
37
|
+
if (status) {
|
|
38
|
+
status.removeEventListener('change', onPermissionChange);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}, [now, permissionName, onGranted, onError]);
|
|
42
|
+
return { state, isGranted: state === 'granted' };
|
|
43
|
+
}
|
|
44
|
+
exports.useNavigatorPermission = useNavigatorPermission;
|
|
45
|
+
/**
|
|
46
|
+
* Give you a wrapped clipboard api and a shouldFallback state.
|
|
47
|
+
* ignore if read and readText return promise filled with undefined, and rely on shouldFallback to display an alternative interaction.
|
|
48
|
+
* You should use ClipboardFallback component
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```tsx
|
|
52
|
+
* const { readText, shouldFallback, setShouldFallback } = useClipboard();
|
|
53
|
+
*
|
|
54
|
+
* function handlePasteAction() {
|
|
55
|
+
* // yes you can safely ignore error here,
|
|
56
|
+
* // readText() will never throw, error is caught and set shouldFallback to corresponding mode
|
|
57
|
+
* void readText().then(handlePaste);
|
|
58
|
+
* }
|
|
59
|
+
*
|
|
60
|
+
* function handlePaste(text: string | undefined) {
|
|
61
|
+
* if (!text) return;
|
|
62
|
+
*
|
|
63
|
+
* setState(text);
|
|
64
|
+
* setShouldFallback(null);
|
|
65
|
+
* }
|
|
66
|
+
*
|
|
67
|
+
* return (
|
|
68
|
+
* <>
|
|
69
|
+
* <button onClick={handlePasteAction}>Paste</button>
|
|
70
|
+
* <ClipboardFallbackModal
|
|
71
|
+
* mode={shouldFallback}
|
|
72
|
+
* onDismiss={() => setShouldFallback(null)}
|
|
73
|
+
* onReadText={handlePaste}
|
|
74
|
+
* />
|
|
75
|
+
* </>
|
|
76
|
+
* )
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
function useClipboard() {
|
|
80
|
+
const [shouldFallback, setShouldFallback] = (0, react_1.useState)();
|
|
81
|
+
const [text, setText] = (0, react_1.useState)();
|
|
82
|
+
const [blobs, setBlobs] = (0, react_1.useState)();
|
|
83
|
+
const cleanShouldFallback = (0, react_1.useCallback)(() => {
|
|
84
|
+
setShouldFallback(undefined);
|
|
85
|
+
setText(undefined);
|
|
86
|
+
setBlobs(undefined);
|
|
87
|
+
}, []);
|
|
88
|
+
const clipboardAPI = (0, react_1.useMemo)(() => ({
|
|
89
|
+
async read() {
|
|
90
|
+
try {
|
|
91
|
+
return await (0, clipboard_1.read)();
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
setShouldFallback('read');
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
async readText() {
|
|
98
|
+
try {
|
|
99
|
+
return await (0, clipboard_1.readText)();
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
setShouldFallback('readText');
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
async write(data) {
|
|
106
|
+
try {
|
|
107
|
+
return await (0, clipboard_1.write)(data);
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
const blobs = await Promise.all(data.map((ci) => ci.getType(ci.types[0])));
|
|
111
|
+
setBlobs(blobs);
|
|
112
|
+
setShouldFallback('write');
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
async rawWriteWithType(data, type = 'text/plain') {
|
|
116
|
+
try {
|
|
117
|
+
const item = await (0, clipboard_1.newClipboardItem)({
|
|
118
|
+
[type]: new Promise((resolve) => {
|
|
119
|
+
resolve(new Blob([data], { type }));
|
|
120
|
+
}),
|
|
121
|
+
});
|
|
122
|
+
return await (0, clipboard_1.write)([item]);
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
setText(data);
|
|
126
|
+
setShouldFallback('writeText');
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
async writeText(data) {
|
|
130
|
+
try {
|
|
131
|
+
return await (0, clipboard_1.writeText)(data);
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
setText(data);
|
|
135
|
+
setShouldFallback('writeText');
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
}), []);
|
|
139
|
+
return {
|
|
140
|
+
...clipboardAPI,
|
|
141
|
+
shouldFallback,
|
|
142
|
+
text,
|
|
143
|
+
blobs,
|
|
144
|
+
cleanShouldFallback,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
exports.useClipboard = useClipboard;
|
package/lib-cjs/versionInfo.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nmrium",
|
|
3
3
|
"description": "React component to display and process nuclear magnetic resonance (NMR) spectra.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.40.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib-cjs/component/NMRium.js",
|
|
7
7
|
"module": "lib/component/NMRium.js",
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"install:clean": "rm -rf node_modules/ && rm -rf package-lock.json && npm install && npm start",
|
|
28
28
|
"prepack": "npm run clean-lib && npm run compile",
|
|
29
29
|
"prepublishOnly": "npm run set-version-npm",
|
|
30
|
-
"prettier": "prettier --check src",
|
|
31
|
-
"prettier-write": "prettier --write src",
|
|
30
|
+
"prettier": "prettier --check src test-e2e",
|
|
31
|
+
"prettier-write": "prettier --write src test-e2e",
|
|
32
32
|
"set-version-npm": "VERSION=$(jq .version package.json | tr -d '\"') && echo \"export default { version: 'v$VERSION' };\" > src/versionInfo.ts",
|
|
33
33
|
"set-version-sha": "SHA=$(git rev-parse HEAD) && echo \"export default { version: 'git-$SHA' };\" > src/versionInfo.ts",
|
|
34
34
|
"start": "npm run dev",
|
|
35
35
|
"stylelint": "stylelint \"**/*.{css,tsx}\"",
|
|
36
36
|
"stylelint-fix": "npm run stylelint -- --fix",
|
|
37
|
-
"test": "npm run test-only && npm run
|
|
37
|
+
"test": "npm run test-only && npm run eslint && npm run prettier && npm run check-types && npm run stylelint && npm run build-no-minify && npm run test-e2e",
|
|
38
38
|
"test-only": "vitest run --coverage",
|
|
39
39
|
"test-e2e": "playwright test --project chromium",
|
|
40
40
|
"test-e2e-server": "serve -l tcp://localhost:3000 build"
|
|
@@ -81,12 +81,12 @@
|
|
|
81
81
|
"ml-baseline-correction-regression": "^1.0.2",
|
|
82
82
|
"ml-conrec": "^5.0.2",
|
|
83
83
|
"ml-gsd": "^12.1.3",
|
|
84
|
-
"ml-spectra-processing": "^12.
|
|
84
|
+
"ml-spectra-processing": "^12.5.0",
|
|
85
85
|
"ml-stat": "^1.3.3",
|
|
86
86
|
"multiplet-analysis": "^2.1.1",
|
|
87
87
|
"nmr-correlation": "^2.3.3",
|
|
88
88
|
"nmr-load-save": "^0.13.2",
|
|
89
|
-
"nmr-processing": "^9.7.
|
|
89
|
+
"nmr-processing": "^9.7.4",
|
|
90
90
|
"nmredata": "^0.9.2",
|
|
91
91
|
"numeral": "^2.0.6",
|
|
92
92
|
"openchemlib": "^8.3.0",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"react-plot": "^1.4.2",
|
|
105
105
|
"react-rnd": "^10.4.1",
|
|
106
106
|
"react-science": "^0.24.2",
|
|
107
|
-
"react-slider": "^2.0.
|
|
107
|
+
"react-slider": "^2.0.6",
|
|
108
108
|
"react-table": "^7.8.0",
|
|
109
109
|
"react-transition-group": "^4.4.5",
|
|
110
110
|
"react-use": "^17.4.0",
|
|
@@ -118,32 +118,32 @@
|
|
|
118
118
|
"@playwright/test": "^1.35.1",
|
|
119
119
|
"@simbathesailor/use-what-changed": "^2.0.0",
|
|
120
120
|
"@types/d3": "^7.4.0",
|
|
121
|
-
"@types/node": "^20.
|
|
121
|
+
"@types/node": "^20.4.0",
|
|
122
122
|
"@types/papaparse": "^5.3.7",
|
|
123
|
-
"@types/react": "^18.2.
|
|
123
|
+
"@types/react": "^18.2.14",
|
|
124
124
|
"@types/react-dom": "^18.2.6",
|
|
125
125
|
"@types/react-table": "^7.7.14",
|
|
126
126
|
"@vitejs/plugin-react-swc": "^3.3.2",
|
|
127
|
-
"@vitest/coverage-v8": "^0.32.
|
|
127
|
+
"@vitest/coverage-v8": "^0.32.4",
|
|
128
128
|
"cross-env": "^7.0.3",
|
|
129
129
|
"cspell": "^6.31.1",
|
|
130
|
-
"eslint": "^8.
|
|
130
|
+
"eslint": "^8.44.0",
|
|
131
131
|
"eslint-config-cheminfo-react": "^9.1.1",
|
|
132
132
|
"eslint-config-cheminfo-typescript": "^11.3.1",
|
|
133
133
|
"modern-normalize": "^2.0.0",
|
|
134
134
|
"postcss-styled-syntax": "^0.4.0",
|
|
135
135
|
"prettier": "^2.8.8",
|
|
136
|
-
"rc-menu": "^9.
|
|
136
|
+
"rc-menu": "^9.11.0",
|
|
137
137
|
"react": "^18.2.0",
|
|
138
138
|
"react-dom": "^18.2.0",
|
|
139
|
-
"react-router-dom": "^6.
|
|
139
|
+
"react-router-dom": "^6.14.1",
|
|
140
140
|
"rimraf": "^5.0.1",
|
|
141
141
|
"rollup-plugin-analyzer": "^4.0.0",
|
|
142
142
|
"serve": "^14.2.0",
|
|
143
|
-
"stylelint": "^15.
|
|
144
|
-
"stylelint-config-standard": "^
|
|
145
|
-
"typescript": "~5.1.
|
|
143
|
+
"stylelint": "^15.10.1",
|
|
144
|
+
"stylelint-config-standard": "^34.0.0",
|
|
145
|
+
"typescript": "~5.1.6",
|
|
146
146
|
"vite": "^4.3.9",
|
|
147
|
-
"vitest": "^0.32.
|
|
147
|
+
"vitest": "^0.32.4"
|
|
148
148
|
}
|
|
149
149
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function LogsHistory(): import("react/jsx-runtime").JSX.Element;
|