nmrium 0.56.0 → 0.57.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/component/1d/ExclusionZoneAnnotation.d.ts +0 -1
- package/lib/component/1d/database/DatabaseSpectrum.js +14 -19
- package/lib/component/1d/jCouplingGraph/JGraphContext.d.ts +0 -1
- package/lib/component/1d/peaks/PeakAnnotationsSpreadMode.d.ts +0 -1
- package/lib/component/1d/peaks/PeakEditionManager.js +16 -10
- package/lib/component/1d/utilities/getDecimalsCount.js +1 -1
- package/lib/component/1d/utilities/intersectionResolver.js +1 -1
- package/lib/component/1d-2d/FieldEdition.d.ts +3 -1
- package/lib/component/1d-2d/FieldEdition.js +26 -10
- package/lib/component/2d/1d-tracer/Left1DChart.d.ts +0 -1
- package/lib/component/2d/1d-tracer/Top1DChart.d.ts +0 -1
- package/lib/component/2d/XAxis.d.ts +0 -1
- package/lib/component/2d/YAxis.d.ts +0 -1
- package/lib/component/2d/ft/Contours.js +7 -7
- package/lib/component/assignment/AssignmentsContext.d.ts +0 -1
- package/lib/component/context/ChartContext.d.ts +0 -1
- package/lib/component/context/DispatchContext.d.ts +0 -1
- package/lib/component/context/GlobalContext.d.ts +0 -1
- package/lib/component/context/KeyModifierContext.js +1 -1
- package/lib/component/context/LoaderContext.d.ts +0 -1
- package/lib/component/context/PreferencesContext.d.ts +0 -1
- package/lib/component/context/ScaleContext.d.ts +0 -1
- package/lib/component/elements/ActionButtons.d.ts +1 -0
- package/lib/component/elements/ActionButtons.js +4 -4
- package/lib/component/elements/ColorInput.d.ts +0 -1
- package/lib/component/elements/ColorPickerDropdownController.d.ts +2 -0
- package/lib/component/elements/ColorPickerDropdownController.js +8 -0
- package/lib/component/elements/ColumnWrapper.d.ts +0 -1
- package/lib/component/elements/ContextMenu.d.ts +0 -1
- package/lib/component/elements/Input.d.ts +1 -0
- package/lib/component/elements/Input.js +2 -1
- package/lib/component/elements/Input2.d.ts +13 -0
- package/lib/component/elements/Input2.js +118 -0
- package/lib/component/elements/Input2Controller.d.ts +12 -0
- package/lib/component/elements/Input2Controller.js +22 -0
- package/lib/component/elements/MoleculeSelection.js +1 -1
- package/lib/component/elements/NumberInput.js +1 -1
- package/lib/component/elements/NumberInput2.d.ts +12 -0
- package/lib/component/elements/NumberInput2.js +65 -0
- package/lib/component/elements/NumberInput2Controller.d.ts +8 -0
- package/lib/component/elements/NumberInput2Controller.js +15 -0
- package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +3 -3
- package/lib/component/elements/ReactTable/Style.d.ts +3 -1
- package/lib/component/elements/ReactTable/Style.js +11 -1
- package/lib/component/elements/ReactTable/utility/ReactTableContext.d.ts +0 -1
- package/lib/component/elements/Select2.d.ts +26 -0
- package/lib/component/elements/Select2.js +25 -0
- package/lib/component/elements/Select2Controller.d.ts +7 -0
- package/lib/component/elements/Select2Controller.js +12 -0
- package/lib/component/elements/draggable/useDraggable.d.ts +0 -1
- package/lib/component/elements/dropDownButton/DropDownButton.d.ts +2 -4
- package/lib/component/elements/dropDownButton/DropDownButton.js +11 -37
- package/lib/component/elements/dropDownButton/DropDownList.js +3 -32
- package/lib/component/elements/formik/FormikColorPicker.d.ts +0 -1
- package/lib/component/elements/formik/FormikColumnFormatField.d.ts +0 -1
- package/lib/component/elements/formik/FormikInput.d.ts +0 -1
- package/lib/component/elements/formik/FormikInput2.d.ts +11 -0
- package/lib/component/elements/formik/FormikInput2.js +26 -0
- package/lib/component/elements/formik/FormikOnChange.d.ts +0 -1
- package/lib/component/elements/popup/Modal/Context.d.ts +0 -1
- package/lib/component/elements/popup/Modal/ModalContent.d.ts +0 -1
- package/lib/component/elements/resizer/SVGResizer.d.ts +0 -1
- package/lib/component/elements/useFormValidateField.d.ts +1 -0
- package/lib/component/elements/useFormValidateField.js +9 -0
- package/lib/component/header/ApodizationOptionsPanel.js +26 -11
- package/lib/component/header/AutoPeakPickingOptionPanel.d.ts +1 -4
- package/lib/component/header/AutoPeakPickingOptionPanel.js +16 -16
- package/lib/component/header/BaseLineCorrectionPanel.js +49 -27
- package/lib/component/header/Header.js +1 -1
- package/lib/component/header/PhaseCorrectionPanel.js +12 -24
- package/lib/component/header/RangesPickingOptionPanel.js +12 -12
- package/lib/component/header/ZeroFillingOptionsPanel.js +18 -7
- package/lib/component/header/Zones2DOptionPanel.js +19 -18
- package/lib/component/hooks/useWorkspaceAction.d.ts +1 -1
- package/lib/component/modal/editRange/forms/components/SignalTab.d.ts +0 -1
- package/lib/component/modal/editRange/forms/components/SignalsContent.d.ts +0 -1
- package/lib/component/modal/setting/GeneralSettings.d.ts +5 -1
- package/lib/component/modal/setting/GeneralSettings.js +107 -111
- package/lib/component/modal/setting/WorkspaceItem.js +4 -9
- package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.d.ts +1 -1
- package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.js +95 -59
- package/lib/component/modal/setting/settings-tabs/DisplayTabContent.js +33 -25
- package/lib/component/modal/setting/settings-tabs/GeneralTabContent.js +15 -4
- package/lib/component/modal/setting/settings-tabs/ImportationFiltersTabContent.js +56 -39
- package/lib/component/modal/setting/settings-tabs/InfoBlockTabContent.js +36 -36
- package/lib/component/modal/setting/settings-tabs/NucleiTabContent.js +44 -36
- package/lib/component/modal/setting/settings-tabs/OnLoadProcessingTabContent.js +16 -11
- package/lib/component/modal/setting/settings-tabs/SpectraColorsTabContent.js +47 -40
- package/lib/component/modal/setting/settings-tabs/ToolsTabContent.js +50 -40
- package/lib/component/modal/setting/settingsValidation.js +8 -34
- package/lib/component/panels/AutomaticAssignment/AutomaticAssignmentTable.d.ts +0 -1
- package/lib/component/panels/IntegralsPanel/IntegralTable.d.ts +0 -1
- package/lib/component/panels/IntegralsPanel/IntegralsPreferences.d.ts +0 -1
- package/lib/component/panels/Panels.js +31 -8
- package/lib/component/panels/PeaksPanel/PeaksPreferences.d.ts +0 -1
- package/lib/component/panels/PeaksPanel/PeaksTable.d.ts +0 -1
- package/lib/component/panels/RangesPanel/RangesPreferences.d.ts +0 -1
- package/lib/component/panels/RangesPanel/TableColumns/RangeAssignmentsColumn.d.ts +0 -1
- package/lib/component/panels/SpectraPanel/SpectraPreferences.d.ts +0 -1
- package/lib/component/panels/SpectraPanel/SpectraPreferences.js +32 -24
- package/lib/component/panels/SpectraPanel/SpectraTable.js +17 -2
- package/lib/component/panels/SpectraPanel/SpectrumListPanel.d.ts +0 -1
- package/lib/component/panels/SpectraPanel/base/ColorIndicator.d.ts +0 -1
- package/lib/component/panels/SpectraPanel/base/SpectraColumnsManager.d.ts +3 -3
- package/lib/component/panels/SpectraPanel/base/SpectraColumnsManager.js +25 -16
- package/lib/component/panels/SpectraPanel/base/setting/Spectrum1DHistogram.d.ts +0 -1
- package/lib/component/panels/SpectraPanel/base/setting/Spectrum1DSetting.js +15 -5
- package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DHistogram.d.ts +0 -1
- package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DSetting.js +44 -6
- package/lib/component/panels/SpectraPanel/base/setting/SpectrumSetting.d.ts +0 -1
- package/lib/component/panels/SummaryPanel/Overview.d.ts +0 -1
- package/lib/component/panels/SummaryPanel/SummaryPanel.d.ts +0 -1
- package/lib/component/panels/SummaryPanel/utilities/Utilities.d.ts +1 -1
- package/lib/component/panels/ZonesPanel/ZonesPreferences.d.ts +0 -1
- package/lib/component/panels/databasePanel/DatabasePanel.js +17 -3
- package/lib/component/panels/databasePanel/DatabasePreferences.d.ts +0 -1
- package/lib/component/panels/databasePanel/DatabaseTable.d.ts +11 -4
- package/lib/component/panels/databasePanel/DatabaseTable.js +20 -5
- package/lib/component/panels/informationPanel/InformationEditionModal.d.ts +6 -0
- package/lib/component/panels/informationPanel/InformationEditionModal.js +105 -0
- package/lib/component/panels/informationPanel/InformationPanel.d.ts +1 -0
- package/lib/component/panels/{InformationPanel.js → informationPanel/InformationPanel.js} +2 -2
- package/lib/component/panels/multipleAnalysisPanel/preferences/MultipleAnalysisCodeEditor.d.ts +0 -1
- package/lib/component/panels/multipleAnalysisPanel/preferences/index.d.ts +0 -1
- package/lib/component/panels/predictionPanel/PredictionOptionsPanel.d.ts +0 -1
- package/lib/component/panels/predictionPanel/PredictionOptionsPanel.js +1 -1
- package/lib/component/panels/predictionPanel/PredictionPreferences.d.ts +0 -1
- package/lib/component/panels/spectrumSimulation/SpectrumSimulationPreferences.d.ts +0 -1
- package/lib/component/reducer/Reducer.d.ts +1 -1
- package/lib/component/reducer/Reducer.js +2 -0
- package/lib/component/reducer/actions/DatabaseActions.js +22 -5
- package/lib/component/reducer/actions/SpectraActions.d.ts +8 -2
- package/lib/component/reducer/actions/SpectraActions.js +58 -21
- package/lib/component/reducer/actions/ToolsActions.js +3 -4
- package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.d.ts +7 -7
- package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +2 -0
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +1 -1
- package/lib/component/utility/checkUniqueByKey.d.ts +2 -0
- package/lib/component/utility/checkUniqueByKey.js +40 -0
- package/lib/component/utility/colorToHexWithAlpha.d.ts +9 -0
- package/lib/component/utility/colorToHexWithAlpha.js +4 -0
- package/lib/component/workspaces/exercise.js +2 -0
- package/lib/component/workspaces/process1D.js +0 -1
- package/lib/component/workspaces/workspaceDefaultProperties.js +1 -0
- package/lib/data/PredictionManager.js +3 -5
- package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +13 -13
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +9 -9
- package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +13 -13
- package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +13 -13
- package/lib/data/data1d/database.d.ts +1 -0
- package/lib/data/data1d/database.js +4 -2
- package/lib/data/data2d/Spectrum2D/contours.d.ts +8 -22
- package/lib/data/data2d/Spectrum2D/contours.js +88 -67
- package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +4 -2
- package/lib/data/data2d/Spectrum2D/zones/detectZonesManual.d.ts +20 -20
- package/lib/data/data2d/Spectrum2D/zones/initiateZones.d.ts +20 -20
- package/lib/data/getDefaultMatrixFilters.d.ts +1 -1
- package/lib/data/initiateFilters.d.ts +1 -1
- package/lib/data/matrixGeneration.js +1 -2
- package/lib/data/types/common/Keys.d.ts +3 -0
- package/lib/data/types/common/Keys.js +1 -0
- package/lib/data/utilities/generateNumbersPowerOfX.d.ts +2 -2
- package/lib/versionInfo.js +1 -1
- package/package.json +32 -31
- package/lib/component/elements/formik/FormikSlider.d.ts +0 -6
- package/lib/component/elements/formik/FormikSlider.js +0 -15
- package/lib/component/panels/InformationPanel.d.ts +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { extent } from 'd3';
|
|
2
3
|
import throttle from 'lodash/throttle';
|
|
3
4
|
import { readFromWebSource } from 'nmr-load-save';
|
|
4
5
|
import { useCallback, useContext, useEffect, useRef, useState } from 'react';
|
|
@@ -7,13 +8,11 @@ import { useScaleChecked } from '../../context/ScaleContext';
|
|
|
7
8
|
import { useToaster } from '../../context/ToasterContext';
|
|
8
9
|
import { HighlightEventSource, useHighlightData } from '../../highlight';
|
|
9
10
|
import { usePanelPreferences } from '../../hooks/usePanelPreferences';
|
|
10
|
-
import { useVerticalAlign } from '../../hooks/useVerticalAlign';
|
|
11
11
|
import { spinnerContext } from '../../loader/SpinnerContext';
|
|
12
12
|
import { PathBuilder } from '../../utility/PathBuilder';
|
|
13
|
-
import {
|
|
13
|
+
import { getYScaleWithRation } from '../utilities/scale';
|
|
14
14
|
function DatabaseSpectrum() {
|
|
15
|
-
const { displayerKey, height,
|
|
16
|
-
const verticalAlign = useVerticalAlign();
|
|
15
|
+
const { displayerKey, height, margin } = useChartData();
|
|
17
16
|
const [path, setPath] = useState();
|
|
18
17
|
const [isLoading, setLoading] = useState(false);
|
|
19
18
|
const { highlight } = useHighlightData();
|
|
@@ -22,21 +21,16 @@ function DatabaseSpectrum() {
|
|
|
22
21
|
const { color, marginBottom } = usePanelPreferences('database');
|
|
23
22
|
const { jcampURL: jcampRelativeURL = '', baseURL } = highlight?.sourceData?.extra || {};
|
|
24
23
|
const getSpinner = useContext(spinnerContext);
|
|
25
|
-
const scaleY = useCallback(() =>
|
|
26
|
-
height,
|
|
27
|
-
margin: { top: margin.top, bottom: margin.bottom + marginBottom },
|
|
28
|
-
verticalAlign,
|
|
24
|
+
const scaleY = useCallback((yDomain) => getYScaleWithRation({
|
|
29
25
|
yDomain,
|
|
30
|
-
yDomains,
|
|
31
|
-
}), [
|
|
32
|
-
verticalAlign,
|
|
33
26
|
height,
|
|
34
|
-
margin
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
margin: {
|
|
28
|
+
...margin,
|
|
29
|
+
bottom: margin.bottom + marginBottom,
|
|
30
|
+
top: margin.top,
|
|
31
|
+
},
|
|
32
|
+
scaleRatio: 1,
|
|
33
|
+
}), [height, margin, marginBottom]);
|
|
40
34
|
const loadSpectrum = useRef(throttle(async (baseURL, jcampRelativeURL) => {
|
|
41
35
|
try {
|
|
42
36
|
setLoading(true);
|
|
@@ -48,9 +42,10 @@ function DatabaseSpectrum() {
|
|
|
48
42
|
const spectrum = data?.spectra?.[0] || null;
|
|
49
43
|
if (spectrum) {
|
|
50
44
|
const pathBuilder = new PathBuilder();
|
|
51
|
-
const finalScaleX = scaleX();
|
|
52
|
-
const finalScaleY = scaleY();
|
|
53
45
|
const { x, re: y } = spectrum.data;
|
|
46
|
+
const yDomain = extent(y);
|
|
47
|
+
const finalScaleX = scaleX();
|
|
48
|
+
const finalScaleY = scaleY(yDomain);
|
|
54
49
|
pathBuilder.moveTo(finalScaleX(x[0]), finalScaleY(y[0]));
|
|
55
50
|
for (let i = 1; i < x.length; i++) {
|
|
56
51
|
pathBuilder.lineTo(finalScaleX(x[i]), finalScaleY(y[i]));
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { PeaksAnnotationsProps } from './Peaks';
|
|
3
2
|
declare function PeakAnnotationsTreeStyle(props: PeaksAnnotationsProps): import("react/jsx-runtime").JSX.Element;
|
|
4
3
|
declare const _default: import("react").MemoExoticComponent<typeof PeakAnnotationsTreeStyle>;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { yupResolver } from '@hookform/resolvers/yup';
|
|
3
3
|
import { createContext, useCallback, useContext, useMemo, useState, } from 'react';
|
|
4
|
+
import { useForm } from 'react-hook-form';
|
|
4
5
|
import * as Yup from 'yup';
|
|
5
6
|
import { useChartData } from '../../context/ChartContext';
|
|
6
7
|
import { useDispatch } from '../../context/DispatchContext';
|
|
7
8
|
import { useScaleChecked } from '../../context/ScaleContext';
|
|
8
|
-
import
|
|
9
|
+
import { NumberInput2Controller } from '../../elements/NumberInput2Controller';
|
|
9
10
|
import { useActiveSpectrum } from '../../hooks/useActiveSpectrum';
|
|
10
11
|
const validationSchema = Yup.object({
|
|
11
12
|
value: Yup.number().required(),
|
|
@@ -71,6 +72,10 @@ export function PeakEditionProvider({ children }) {
|
|
|
71
72
|
}
|
|
72
73
|
function PeakEditionField({ value, onClose }) {
|
|
73
74
|
const dispatch = useDispatch();
|
|
75
|
+
const { control, handleSubmit } = useForm({
|
|
76
|
+
defaultValues: { value },
|
|
77
|
+
resolver: yupResolver(validationSchema),
|
|
78
|
+
});
|
|
74
79
|
function keyDownCheck(event) {
|
|
75
80
|
if (event.key === 'Enter') {
|
|
76
81
|
return true;
|
|
@@ -80,20 +85,21 @@ function PeakEditionField({ value, onClose }) {
|
|
|
80
85
|
return false;
|
|
81
86
|
}
|
|
82
87
|
}
|
|
83
|
-
function
|
|
88
|
+
function handleOnSubmit({ value: newValue }) {
|
|
84
89
|
if (value) {
|
|
85
90
|
const shift = newValue - value;
|
|
86
91
|
dispatch({ type: 'SHIFT_SPECTRUM', payload: { shift } });
|
|
87
92
|
onClose();
|
|
88
93
|
}
|
|
89
94
|
}
|
|
90
|
-
return (_jsx(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
95
|
+
return (_jsx(NumberInput2Controller, { control: control, name: "value", style: {
|
|
96
|
+
height: `${InputDimension.height}px`,
|
|
97
|
+
outline: 'none',
|
|
98
|
+
}, autoSelect: true, onKeyDown: (e) => {
|
|
99
|
+
if (keyDownCheck(e)) {
|
|
100
|
+
void handleSubmit(handleOnSubmit)();
|
|
101
|
+
}
|
|
102
|
+
}, onClick: stopPropagation, onMouseDown: stopPropagation, buttonPosition: "none" }));
|
|
97
103
|
}
|
|
98
104
|
export function PeakEditionListener(props) {
|
|
99
105
|
const { children, x, y, value, useScaleX = false, useScaleY = false, dx = 0, dy = -InputDimension.height, id, } = props;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export function getDecimalsCount(max, format) {
|
|
2
2
|
const numberOfDigits = format.replace(/\./, '').length;
|
|
3
|
-
const fractionDigits = format.split('.')[1].length;
|
|
3
|
+
const fractionDigits = (format.split('.')[1] || '').length;
|
|
4
4
|
return (Math.max(String(max.toFixed(0)).length, numberOfDigits - fractionDigits) +
|
|
5
5
|
fractionDigits);
|
|
6
6
|
}
|
|
@@ -25,7 +25,7 @@ function resolveGroupsIntersection(groups, options) {
|
|
|
25
25
|
const { maxIteration = 3, groupMargin = 0 } = options;
|
|
26
26
|
let iteration = 1;
|
|
27
27
|
let hasIntersection = true;
|
|
28
|
-
const newGroups =
|
|
28
|
+
const newGroups = structuredClone(groups);
|
|
29
29
|
while (iteration < maxIteration && hasIntersection) {
|
|
30
30
|
iteration++;
|
|
31
31
|
hasIntersection = false;
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
import { PopoverProps } from '@blueprintjs/core';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
4
|
type InputType = 'number' | 'text';
|
|
5
|
-
interface
|
|
5
|
+
interface FieldProps {
|
|
6
6
|
value: number | string;
|
|
7
7
|
inputType?: InputType;
|
|
8
8
|
onChange: (value: any) => void;
|
|
9
|
+
}
|
|
10
|
+
interface FieldEditionsProps extends FieldProps {
|
|
9
11
|
children: ReactNode;
|
|
10
12
|
PopoverProps?: PopoverProps;
|
|
11
13
|
}
|
|
@@ -2,10 +2,12 @@ import { jsx as _jsx } 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 {
|
|
5
|
+
import { yupResolver } from '@hookform/resolvers/yup';
|
|
6
6
|
import { useState } from 'react';
|
|
7
|
+
import { useForm } from 'react-hook-form';
|
|
7
8
|
import * as Yup from 'yup';
|
|
8
|
-
import
|
|
9
|
+
import { Input2Controller } from '../elements/Input2Controller';
|
|
10
|
+
import { NumberInput2Controller } from '../elements/NumberInput2Controller';
|
|
9
11
|
const InputDimension = { height: 28, width: 100 };
|
|
10
12
|
const validationSchema = (inputType) => Yup.object({
|
|
11
13
|
value: (inputType === 'number' ? Yup.number() : Yup.string()).required(),
|
|
@@ -24,7 +26,7 @@ function keyDownCheck(event) {
|
|
|
24
26
|
export function FieldEdition(props) {
|
|
25
27
|
const { value, inputType = 'text', onChange, children, PopoverProps } = props;
|
|
26
28
|
const [isOpen, setIsOpen] = useState(false);
|
|
27
|
-
function
|
|
29
|
+
function handleChange({ value: newValue }) {
|
|
28
30
|
onChange(newValue);
|
|
29
31
|
setIsOpen(false);
|
|
30
32
|
}
|
|
@@ -32,11 +34,25 @@ export function FieldEdition(props) {
|
|
|
32
34
|
.field-edition-popover {
|
|
33
35
|
border-radius: 5px;
|
|
34
36
|
}
|
|
35
|
-
`, popoverClassName: "field-edition-popover", isOpen: isOpen, onClose: () => setIsOpen(false), onInteraction: () => setIsOpen(true), content: _jsx(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
`, popoverClassName: "field-edition-popover", isOpen: isOpen, onClose: () => setIsOpen(false), onInteraction: () => setIsOpen(true), content: _jsx(Field, { onChange: handleChange, value: value, inputType: inputType }), ...PopoverProps, children: children }));
|
|
38
|
+
}
|
|
39
|
+
function Field(props) {
|
|
40
|
+
const { value, inputType = 'text', onChange } = props;
|
|
41
|
+
const { control, handleSubmit } = useForm({
|
|
42
|
+
defaultValues: { value },
|
|
43
|
+
resolver: yupResolver(validationSchema(inputType)),
|
|
44
|
+
});
|
|
45
|
+
function handleKeyDown(event) {
|
|
46
|
+
if (keyDownCheck(event)) {
|
|
47
|
+
void handleSubmit(onChange)();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const style = {
|
|
51
|
+
height: `${InputDimension.height}px`,
|
|
52
|
+
outline: 'none',
|
|
53
|
+
};
|
|
54
|
+
if (inputType === 'number') {
|
|
55
|
+
return (_jsx(NumberInput2Controller, { name: "value", control: control, style: style, onKeyDown: handleKeyDown, onClick: stopPropagation, onMouseDown: stopPropagation, autoFocus: true, buttonPosition: "none" }));
|
|
56
|
+
}
|
|
57
|
+
return (_jsx(Input2Controller, { name: "value", control: control, style: style, onKeyDown: handleKeyDown, onClick: stopPropagation, onMouseDown: stopPropagation, autoFocus: true }));
|
|
42
58
|
}
|
|
@@ -28,12 +28,10 @@ function usePath(spectrum, contours) {
|
|
|
28
28
|
pathBuilder.closePath();
|
|
29
29
|
return pathBuilder.toString();
|
|
30
30
|
}
|
|
31
|
-
const useContoursLevel = (spectrum, sign) => {
|
|
32
|
-
const {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
const level = levels?.[id]?.[sign];
|
|
36
|
-
return typeof level !== 'number' ? defaultLevel[sign] : level;
|
|
31
|
+
const useContoursLevel = (spectrum, sign, quadrant = 'rr') => {
|
|
32
|
+
const { display: { contourOptions }, } = spectrum;
|
|
33
|
+
const level = contourOptions[sign];
|
|
34
|
+
return level ?? getDefaultContoursLevel(spectrum, quadrant)[sign];
|
|
37
35
|
};
|
|
38
36
|
function ContoursPaths({ id: spectrumID, sign, color, spectrum, onTimeout, }) {
|
|
39
37
|
const activeSpectrum = useActiveSpectrum();
|
|
@@ -63,7 +61,9 @@ function ContoursInner({ spectra, displayerKey }) {
|
|
|
63
61
|
function timeoutHandler() {
|
|
64
62
|
debounceAlert.current();
|
|
65
63
|
}
|
|
66
|
-
return (_jsx("g", { clipPath: `url(#${displayerKey}clip-chart-2d)`, className: "contours", children: spectra?.map((spectrum) =>
|
|
64
|
+
return (_jsx("g", { clipPath: `url(#${displayerKey}clip-chart-2d)`, className: "contours", children: spectra?.map((spectrum) => {
|
|
65
|
+
return (_jsxs("g", { children: [spectrum.display.isPositiveVisible && (_jsx(ContoursPaths, { id: spectrum.id, sign: "positive", spectrum: spectrum, color: spectrum.display.positiveColor, onTimeout: timeoutHandler })), spectrum.display.isNegativeVisible && (_jsx(ContoursPaths, { id: spectrum.id, sign: "negative", spectrum: spectrum, color: spectrum.display.negativeColor, onTimeout: timeoutHandler }))] }, spectrum.id));
|
|
66
|
+
}) }));
|
|
67
67
|
}
|
|
68
68
|
const MemoizedContours = memo(ContoursInner);
|
|
69
69
|
export default function Contours() {
|
|
@@ -21,7 +21,7 @@ export function useKeyModifiers() {
|
|
|
21
21
|
}
|
|
22
22
|
return context;
|
|
23
23
|
}
|
|
24
|
-
const isMac = navigator
|
|
24
|
+
const isMac = globalThis.navigator?.userAgent?.toLowerCase().includes('mac');
|
|
25
25
|
export function getModifiers(event) {
|
|
26
26
|
const { shiftKey, altKey, metaKey } = event;
|
|
27
27
|
const ctrlKey = isMac ? metaKey : event.ctrlKey;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import Button from '
|
|
2
|
+
import { Button } from '@blueprintjs/core';
|
|
3
3
|
export default function ActionButtons(props) {
|
|
4
|
-
const { onDone, onCancel, doneLabel = 'Apply', cancelLabel = 'Cancel', style = {}, } = props;
|
|
5
|
-
return (_jsxs("div", { style: { margin: '0 10px', display: 'flex', ...style }, children: [_jsx(Button
|
|
4
|
+
const { onDone, onCancel, doneLabel = 'Apply', cancelLabel = 'Cancel', style = {}, disabledDone = false, } = props;
|
|
5
|
+
return (_jsxs("div", { style: { margin: '0 10px', display: 'flex', ...style }, children: [_jsx(Button, { disabled: disabledDone, intent: "success", onClick: onDone, style: style?.flexDirection === 'row-reverse'
|
|
6
6
|
? {
|
|
7
7
|
marginLeft: '10px',
|
|
8
8
|
}
|
|
9
|
-
: {}, children: doneLabel }), _jsx(Button
|
|
9
|
+
: {}, children: doneLabel }), _jsx(Button, { outlined: true, intent: "danger", onClick: onCancel, style: !style.flexDirection || style.flexDirection === 'row'
|
|
10
10
|
? {
|
|
11
11
|
marginLeft: '10px',
|
|
12
12
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Controller } from 'react-hook-form';
|
|
3
|
+
import { ColorPickerDropdown } from 'react-science/ui';
|
|
4
|
+
export function ColorPickerDropdownController(props) {
|
|
5
|
+
return (_jsx(Controller, { ...props, render: ({ field }) => {
|
|
6
|
+
return (_jsx(ColorPickerDropdown, { onChangeComplete: ({ hex }) => field.onChange(hex), color: { hex: field.value } }));
|
|
7
|
+
} }));
|
|
8
|
+
}
|
|
@@ -13,6 +13,7 @@ export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElem
|
|
|
13
13
|
onClear?: () => void;
|
|
14
14
|
datalist?: string[];
|
|
15
15
|
debounceTime?: number;
|
|
16
|
+
small?: boolean;
|
|
16
17
|
}
|
|
17
18
|
declare const Input: import("react").ForwardRefExoticComponent<InputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
18
19
|
export default Input;
|
|
@@ -36,7 +36,7 @@ const Input = forwardRef((props, ref) => {
|
|
|
36
36
|
const { value: externalValue = undefined, name, style = {
|
|
37
37
|
input: {},
|
|
38
38
|
inputWrapper: {},
|
|
39
|
-
}, onChange, checkValue = () => true, type = 'text', autoSelect = false, className, renderIcon, canClear = false, onClear, datalist = [], debounceTime = 0, ...otherProps } = props;
|
|
39
|
+
}, onChange, checkValue = () => true, type = 'text', autoSelect = false, className, renderIcon, canClear = false, onClear, datalist = [], debounceTime = 0, small = false, ...otherProps } = props;
|
|
40
40
|
const [internalValue, setInternalValue] = useState();
|
|
41
41
|
const value = debounceTime ? internalValue : externalValue;
|
|
42
42
|
const localRef = useRef();
|
|
@@ -82,6 +82,7 @@ const Input = forwardRef((props, ref) => {
|
|
|
82
82
|
}, className: `input ${className || ''} `, children: [renderIcon?.(), _jsx("input", { ...otherProps, className: isDebounced ? 'debounce-end' : '', ref: combinedRef, name: name, style: {
|
|
83
83
|
...styles.input,
|
|
84
84
|
...style?.input,
|
|
85
|
+
padding: !small ? '0.4rem' : '0 0.4rem',
|
|
85
86
|
}, type: type, value: mapValue(value), onChange: onChangeHandler, list: `${name || ''}-data-list` }), canClear && value && (_jsx("button", { type: "button", style: styles.clearButton, onClick: clearHandler, children: _jsx("span", { style: { display: 'block', margin: '0 auto' }, children: "\u2715" }) })), _jsx("datalist", { id: `${name || ''}-data-list`, children: datalist.map((value) => (_jsx("option", { value: value }, value))) })] }));
|
|
86
87
|
});
|
|
87
88
|
export default Input;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { InputGroupProps } from '@blueprintjs/core';
|
|
2
|
+
interface BaseInputProps {
|
|
3
|
+
debounceTime?: number;
|
|
4
|
+
autoSelect?: boolean;
|
|
5
|
+
checkValue?: (element?: number | string) => boolean;
|
|
6
|
+
onChange?: (value: string, event?: React.ChangeEvent<HTMLInputElement>) => void;
|
|
7
|
+
}
|
|
8
|
+
export interface Input2Props<FilterItem extends string = string> extends Omit<InputGroupProps, 'onChange' | 'inputRef'>, BaseInputProps {
|
|
9
|
+
getFilterValue?: (item: FilterItem) => string;
|
|
10
|
+
filterItems?: FilterItem[];
|
|
11
|
+
}
|
|
12
|
+
declare const Input2: import("react").ForwardRefExoticComponent<Input2Props<string> & import("react").RefAttributes<unknown>>;
|
|
13
|
+
export { Input2 };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Classes, MenuItem } from '@blueprintjs/core';
|
|
3
|
+
import { Suggest } from '@blueprintjs/select';
|
|
4
|
+
import debounce from 'lodash/debounce';
|
|
5
|
+
import { useEffect, useRef, useMemo, useState, isValidElement, forwardRef, } from 'react';
|
|
6
|
+
import useCombinedRefs from '../hooks/useCombinedRefs';
|
|
7
|
+
function useInput(props) {
|
|
8
|
+
const { value: externalValue, debounceTime, ref, autoSelect, onChange, checkValue, } = props;
|
|
9
|
+
const [internalValue, setValue] = useState();
|
|
10
|
+
const value = debounceTime ? internalValue : externalValue;
|
|
11
|
+
const localRef = useRef();
|
|
12
|
+
const innerRef = useCombinedRefs([ref, localRef]);
|
|
13
|
+
const [isDebounced, setDebouncedStatus] = useState(false);
|
|
14
|
+
const debounceOnChange = useMemo(() => debounce((val, event) => {
|
|
15
|
+
onChange?.(val, event);
|
|
16
|
+
setDebouncedStatus(true);
|
|
17
|
+
}, debounceTime), [debounceTime, onChange]);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (debounceTime) {
|
|
20
|
+
setValue(externalValue);
|
|
21
|
+
}
|
|
22
|
+
}, [debounceTime, externalValue]);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (autoSelect) {
|
|
25
|
+
innerRef?.current?.select();
|
|
26
|
+
}
|
|
27
|
+
}, [autoSelect, innerRef]);
|
|
28
|
+
function handleChange(val, event) {
|
|
29
|
+
if (!event)
|
|
30
|
+
return;
|
|
31
|
+
event?.stopPropagation();
|
|
32
|
+
event?.preventDefault();
|
|
33
|
+
setDebouncedStatus(false);
|
|
34
|
+
if (!checkValue || checkValue?.(val)) {
|
|
35
|
+
if (debounceTime) {
|
|
36
|
+
setValue(val);
|
|
37
|
+
debounceOnChange(val, event);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
onChange?.(val, event);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
handleChange,
|
|
46
|
+
setValue,
|
|
47
|
+
innerRef,
|
|
48
|
+
debounceOnChange,
|
|
49
|
+
isDebounced,
|
|
50
|
+
value,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function getIcon(leftIcon) {
|
|
54
|
+
if (isValidElement(leftIcon)) {
|
|
55
|
+
return _jsx("span", { className: Classes.ICON, children: leftIcon });
|
|
56
|
+
}
|
|
57
|
+
return leftIcon;
|
|
58
|
+
}
|
|
59
|
+
function getClasses(isDebounced) {
|
|
60
|
+
const classes = ['text-input'];
|
|
61
|
+
if (isDebounced) {
|
|
62
|
+
classes.push('debounce-end');
|
|
63
|
+
}
|
|
64
|
+
return classes.join(' ');
|
|
65
|
+
}
|
|
66
|
+
function InnerInput(props, ref) {
|
|
67
|
+
const { debounceTime = 0, onChange, checkValue, value: externalValue, getFilterValue = (item) => item, filterItems, leftIcon, autoSelect = false, ...otherInputProps } = props;
|
|
68
|
+
const { handleChange, setValue, isDebounced, innerRef, value } = useInput({
|
|
69
|
+
value: externalValue,
|
|
70
|
+
ref,
|
|
71
|
+
autoSelect,
|
|
72
|
+
debounceTime,
|
|
73
|
+
onChange,
|
|
74
|
+
checkValue,
|
|
75
|
+
});
|
|
76
|
+
function handleItemSelect(item, event) {
|
|
77
|
+
const val = getFilterValue(item);
|
|
78
|
+
setValue(val);
|
|
79
|
+
onChange?.(val, event);
|
|
80
|
+
}
|
|
81
|
+
function renderItem(item, { handleClick, modifiers }) {
|
|
82
|
+
const { active, matchesPredicate } = modifiers;
|
|
83
|
+
if (!matchesPredicate) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
const val = getFilterValue(item);
|
|
87
|
+
return (_jsx(MenuItem, { text: val, onClick: handleClick, roleStructure: "listoption", active: active }, val));
|
|
88
|
+
}
|
|
89
|
+
function itemPredicate(query, item) {
|
|
90
|
+
return getFilterValue(item).toLowerCase().includes(query.toLowerCase());
|
|
91
|
+
}
|
|
92
|
+
const icon = getIcon(leftIcon);
|
|
93
|
+
const classes = getClasses(isDebounced);
|
|
94
|
+
return (_jsx(Suggest, { inputProps: {
|
|
95
|
+
placeholder: '',
|
|
96
|
+
leftIcon: icon,
|
|
97
|
+
inputClassName: classes,
|
|
98
|
+
inputRef: innerRef,
|
|
99
|
+
...otherInputProps,
|
|
100
|
+
}, items: [], query: value || '', onQueryChange: handleChange, popoverProps: { disabled: true }, ...(filterItems &&
|
|
101
|
+
filterItems.length > 0 && {
|
|
102
|
+
items: filterItems,
|
|
103
|
+
itemRenderer: renderItem,
|
|
104
|
+
onItemSelect: handleItemSelect,
|
|
105
|
+
inputValueRenderer: getFilterValue,
|
|
106
|
+
itemPredicate,
|
|
107
|
+
popoverProps: { minimal: true, placement: 'bottom' },
|
|
108
|
+
popoverContentProps: {
|
|
109
|
+
style: {
|
|
110
|
+
maxHeight: '250px',
|
|
111
|
+
overflowY: 'auto',
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
noResults: (_jsx(MenuItem, { disabled: true, text: "No results.", roleStructure: "listoption" })),
|
|
115
|
+
}), closeOnSelect: true, resetOnQuery: true }));
|
|
116
|
+
}
|
|
117
|
+
const Input2 = forwardRef(InnerInput);
|
|
118
|
+
export { Input2 };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ControllerProps, FieldValues } from 'react-hook-form';
|
|
2
|
+
import { Input2Props } from './Input2';
|
|
3
|
+
export interface InputMapValueFunctions {
|
|
4
|
+
mapOnChangeValue?: (value: string) => any;
|
|
5
|
+
mapValue?: (value: any) => string;
|
|
6
|
+
}
|
|
7
|
+
interface Input2ControllerProps<TFieldValues extends FieldValues = FieldValues> extends Omit<Input2Props, 'name'>, Pick<ControllerProps<TFieldValues>, 'control' | 'name'>, InputMapValueFunctions {
|
|
8
|
+
controllerProps?: Omit<ControllerProps<TFieldValues>, 'render'>;
|
|
9
|
+
noShadowBox?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function Input2Controller<TFieldValues extends FieldValues = FieldValues>(props: Input2ControllerProps<TFieldValues>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Controller } from 'react-hook-form';
|
|
3
|
+
import { Input2 } from './Input2';
|
|
4
|
+
export function Input2Controller(props) {
|
|
5
|
+
const { controllerProps, onChange, name, control, intent = 'none', mapOnChangeValue, mapValue, noShadowBox = false, style, ...otherInputProps } = props;
|
|
6
|
+
return (_jsx(Controller, { name: name, control: control, ...controllerProps, render: ({ field, fieldState: { invalid } }) => {
|
|
7
|
+
const { value: originValue, ...otherFieldProps } = field;
|
|
8
|
+
const value = mapValue?.(originValue) || originValue;
|
|
9
|
+
return (_jsx(Input2, { value: value, ...otherFieldProps, onChange: (value, event) => {
|
|
10
|
+
if (typeof mapOnChangeValue === 'function') {
|
|
11
|
+
field.onChange(mapOnChangeValue(value));
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
field.onChange(value);
|
|
15
|
+
}
|
|
16
|
+
onChange?.(value, event);
|
|
17
|
+
}, style: {
|
|
18
|
+
...style,
|
|
19
|
+
...(noShadowBox && !invalid && { boxShadow: 'none' }),
|
|
20
|
+
}, intent: invalid ? 'danger' : intent, ...otherInputProps }));
|
|
21
|
+
} }));
|
|
22
|
+
}
|
|
@@ -2,7 +2,7 @@ import { jsxs as _jsxs, jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
4
|
import { useCallback, useEffect, useState } from 'react';
|
|
5
|
-
import MF from 'react-mf
|
|
5
|
+
import { MF } from 'react-mf';
|
|
6
6
|
import { MolfileSvgRenderer } from 'react-ocl/full';
|
|
7
7
|
import NextPrev from './NextPrev';
|
|
8
8
|
const toolbarStyle = css `
|
|
@@ -8,7 +8,7 @@ const inputStyle = {
|
|
|
8
8
|
border: '0.55px solid #c7c7c7',
|
|
9
9
|
textAlign: 'center',
|
|
10
10
|
};
|
|
11
|
-
const NumberInput = forwardRef(({ name, value: valueProp, style = {}, onChange, pattern =
|
|
11
|
+
const NumberInput = forwardRef(({ name, value: valueProp, style = {}, onChange, pattern = String.raw `^\d*.\d*$`, step = 'any', min = 'any', max = 'any', autoSelect = false, ...otherProps }, ref) => {
|
|
12
12
|
const combinedRef = useCombinedRefs([ref]);
|
|
13
13
|
useEffect(() => {
|
|
14
14
|
if (autoSelect) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** @jsxImportSource @emotion/react */
|
|
2
|
+
import { HTMLInputProps, NumericInputProps } from '@blueprintjs/core';
|
|
3
|
+
interface ValueProps extends Pick<React.InputHTMLAttributes<HTMLInputElement>, 'name' | 'style'>, Pick<NumericInputProps, 'onValueChange' | 'value'> {
|
|
4
|
+
checkValue?: (element?: number) => boolean;
|
|
5
|
+
debounceTime?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface NumberInput2Props extends Omit<HTMLInputProps & NumericInputProps, 'value' | 'onValueChange'>, ValueProps {
|
|
8
|
+
format?: () => (element: string) => number | string;
|
|
9
|
+
autoSelect?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare const NumberInput2: import("react").ForwardRefExoticComponent<NumberInput2Props & import("react").RefAttributes<unknown>>;
|
|
12
|
+
export { NumberInput2 };
|