nmrium 0.31.0 → 0.33.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/Chart1D.js +1 -1
- package/lib/component/1d/FooterBanner.js +17 -10
- package/lib/component/1d/{Integral.d.ts → integral/Integral.d.ts} +0 -0
- package/lib/component/1d/{Integral.js → integral/Integral.js} +2 -2
- package/lib/component/1d/integral/IntegralIndicator.d.ts +9 -0
- package/lib/component/1d/integral/IntegralIndicator.js +27 -0
- package/lib/component/1d/{IntegralResizable.d.ts → integral/IntegralResizable.d.ts} +0 -0
- package/lib/component/1d/integral/IntegralResizable.js +69 -0
- package/lib/component/1d/{IntegralsSeries.d.ts → integral/IntegralsSeries.d.ts} +0 -0
- package/lib/component/1d/{IntegralsSeries.js → integral/IntegralsSeries.js} +3 -3
- package/lib/component/1d/ranges/Range.js +27 -50
- package/lib/component/1d/utilities/scale.js +2 -2
- package/lib/component/2d/Contours.js +61 -42
- package/lib/component/2d/Left1DChart.js +1 -1
- package/lib/component/2d/Top1DChart.js +1 -1
- package/lib/component/EventsTrackers/BrushTracker.js +30 -21
- package/lib/component/NMRium.d.ts +1 -1
- package/lib/component/NMRium.js +1 -1
- package/lib/component/SplitPaneWrapper.js +1 -1
- package/lib/component/elements/EditableColumn.d.ts +3 -1
- package/lib/component/elements/EditableColumn.js +18 -3
- package/lib/component/elements/formik/FormikColorPicker.d.ts +0 -1
- package/lib/component/elements/formik/FormikColorPicker.js +5 -8
- package/lib/component/elements/formik/FormikInput.d.ts +0 -1
- package/lib/component/elements/formik/FormikInput.js +8 -19
- package/lib/component/elements/formik/FormikOnChange.d.ts +1 -1
- package/lib/component/elements/formik/FormikOnChange.js +13 -10
- package/lib/component/elements/formik/FormikSlider.d.ts +2 -4
- package/lib/component/elements/formik/FormikSlider.js +8 -11
- package/lib/component/hooks/useActiveSpectrumStyleOptions.js +1 -1
- package/lib/component/hooks/useExport.js +1 -1
- package/lib/component/loader/DropZone.js +9 -1
- package/lib/component/modal/ExportAsMatrixModal.js +1 -1
- package/lib/component/modal/editRange/forms/components/SignalFormInfo.js +1 -1
- package/lib/component/modal/setting/GeneralTabContent.js +1 -1
- package/lib/component/panels/MoleculesPanel/MoleculeHeader.js +1 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +1 -1
- package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +1 -1
- package/lib/component/panels/PeaksPanel/PeaksTable.js +1 -1
- package/lib/component/panels/RangesPanel/RangesHeader.js +1 -1
- package/lib/component/panels/RangesPanel/RangesPanel.js +1 -1
- package/lib/component/panels/RangesPanel/RangesTableRow.js +1 -3
- package/lib/component/panels/SpectrumsPanel/SpectrumsTabs.js +1 -1
- package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum1DSetting.d.ts +1 -1
- package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum1DSetting.js +2 -1
- package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum2DSetting.d.ts +1 -1
- package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum2DSetting.js +2 -1
- package/lib/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +3 -26
- package/lib/component/panels/extra/preferences/ColumnsHelper.js +5 -2
- package/lib/component/reducer/Reducer.d.ts +20 -59
- package/lib/component/reducer/Reducer.js +24 -10
- package/lib/component/reducer/actions/DomainActions.js +3 -2
- package/lib/component/reducer/actions/FiltersActions.js +12 -3
- package/lib/component/reducer/actions/IntegralsActions.js +6 -5
- package/lib/component/reducer/actions/PeaksActions.js +7 -6
- package/lib/component/reducer/actions/PreferencesActions.js +18 -36
- package/lib/component/reducer/actions/RangesActions.d.ts +1 -1
- package/lib/component/reducer/actions/RangesActions.js +20 -16
- package/lib/component/reducer/actions/SpectrumsActions.js +13 -6
- package/lib/component/reducer/actions/ToolsActions.d.ts +1 -1
- package/lib/component/reducer/actions/ToolsActions.js +15 -28
- package/lib/component/reducer/actions/ZonesActions.js +9 -8
- package/lib/component/reducer/core/Constants.js +1 -1
- package/lib/component/reducer/helper/getActiveSpectrum.d.ts +3 -0
- package/lib/component/reducer/helper/getActiveSpectrum.js +4 -0
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +2 -2
- package/lib/component/toolbar/BasicToolBar.js +8 -7
- package/lib/component/utility/FileUtility.d.ts +1 -8
- package/lib/component/utility/FileUtility.js +2 -17
- package/lib/component/utility/{Export.d.ts → export.d.ts} +0 -0
- package/lib/component/utility/{Export.js → export.js} +27 -44
- package/lib/component/utility/formatNumber.d.ts +6 -1
- package/lib/component/utility/formatNumber.js +4 -3
- package/lib/component/workspaces/Workspace.d.ts +1 -1
- package/lib/component/workspaces/exercise.js +4 -4
- package/lib/component/workspaces/workspaceDefaultProperties.js +1 -1
- package/lib/data/Filters.d.ts +1 -2
- package/lib/data/Filters.js +1 -2
- package/lib/data/SpectraManager.d.ts +1 -2
- package/lib/data/SpectraManager.js +22 -55
- package/lib/data/data1d/filter1d/fft.js +21 -4
- package/lib/data/data1d/filter1d/phaseCorrection.js +11 -5
- package/lib/data/data2d/Processing2D.js +3 -2
- package/lib/data/data2d/Spectrum2D/contours.d.ts +40 -0
- package/lib/data/data2d/Spectrum2D/contours.js +132 -0
- package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +2 -3
- package/lib/data/types/common/Source.d.ts +1 -0
- package/lib/data/types/data2d/Data2D.d.ts +2 -0
- package/lib/data/types/data2d/Datum2D.d.ts +0 -1
- package/lib/data/utilities/calculateSanPlot.d.ts +8 -0
- package/lib/data/utilities/calculateSanPlot.js +31 -0
- package/lib/types/NMRiumGeneralPreferences.d.ts +2 -2
- package/lib/versionInfo.js +1 -1
- package/lib-cjs/component/1d/Chart1D.js +1 -1
- package/lib-cjs/component/1d/FooterBanner.js +16 -9
- package/lib-cjs/component/1d/{Integral.js → integral/Integral.js} +2 -2
- package/lib-cjs/component/1d/integral/IntegralIndicator.js +31 -0
- package/lib-cjs/component/1d/integral/IntegralResizable.js +74 -0
- package/lib-cjs/component/1d/{IntegralsSeries.js → integral/IntegralsSeries.js} +3 -3
- package/lib-cjs/component/1d/ranges/Range.js +27 -50
- package/lib-cjs/component/1d/utilities/scale.js +2 -2
- package/lib-cjs/component/2d/Contours.js +60 -41
- package/lib-cjs/component/2d/Left1DChart.js +1 -1
- package/lib-cjs/component/2d/Top1DChart.js +1 -1
- package/lib-cjs/component/EventsTrackers/BrushTracker.js +30 -21
- package/lib-cjs/component/NMRium.js +2 -2
- package/lib-cjs/component/SplitPaneWrapper.js +1 -1
- package/lib-cjs/component/elements/EditableColumn.js +18 -3
- package/lib-cjs/component/elements/formik/FormikColorPicker.js +4 -7
- package/lib-cjs/component/elements/formik/FormikInput.js +8 -19
- package/lib-cjs/component/elements/formik/FormikOnChange.js +13 -10
- package/lib-cjs/component/elements/formik/FormikSlider.js +7 -10
- package/lib-cjs/component/hooks/useActiveSpectrumStyleOptions.js +1 -1
- package/lib-cjs/component/hooks/useExport.js +6 -6
- package/lib-cjs/component/loader/DropZone.js +9 -1
- package/lib-cjs/component/modal/ExportAsMatrixModal.js +2 -2
- package/lib-cjs/component/modal/editRange/forms/components/SignalFormInfo.js +1 -1
- package/lib-cjs/component/modal/setting/GeneralTabContent.js +1 -1
- package/lib-cjs/component/panels/MoleculesPanel/MoleculeHeader.js +1 -1
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +4 -4
- package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +2 -2
- package/lib-cjs/component/panels/PeaksPanel/PeaksTable.js +1 -1
- package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +2 -2
- package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +2 -2
- package/lib-cjs/component/panels/RangesPanel/RangesTableRow.js +1 -3
- package/lib-cjs/component/panels/SpectrumsPanel/SpectrumsTabs.js +2 -2
- package/lib-cjs/component/panels/SpectrumsPanel/base/setting/Spectrum1DSetting.js +2 -1
- package/lib-cjs/component/panels/SpectrumsPanel/base/setting/Spectrum2DSetting.js +2 -1
- package/lib-cjs/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +2 -25
- package/lib-cjs/component/panels/extra/preferences/ColumnsHelper.js +5 -2
- package/lib-cjs/component/reducer/Reducer.js +23 -9
- package/lib-cjs/component/reducer/actions/DomainActions.js +3 -2
- package/lib-cjs/component/reducer/actions/FiltersActions.js +12 -3
- package/lib-cjs/component/reducer/actions/IntegralsActions.js +6 -5
- package/lib-cjs/component/reducer/actions/PeaksActions.js +7 -6
- package/lib-cjs/component/reducer/actions/PreferencesActions.js +18 -36
- package/lib-cjs/component/reducer/actions/RangesActions.js +20 -16
- package/lib-cjs/component/reducer/actions/SpectrumsActions.js +12 -5
- package/lib-cjs/component/reducer/actions/ToolsActions.js +15 -28
- package/lib-cjs/component/reducer/actions/ZonesActions.js +9 -8
- package/lib-cjs/component/reducer/core/Constants.js +1 -1
- package/lib-cjs/component/reducer/helper/getActiveSpectrum.js +8 -0
- package/lib-cjs/component/toolbar/BasicToolBar.js +7 -6
- package/lib-cjs/component/utility/FileUtility.js +2 -18
- package/lib-cjs/component/utility/{Export.js → export.js} +51 -45
- package/lib-cjs/component/utility/formatNumber.js +4 -3
- package/lib-cjs/component/workspaces/exercise.js +4 -4
- package/lib-cjs/component/workspaces/workspaceDefaultProperties.js +1 -1
- package/lib-cjs/data/Filters.js +1 -3
- package/lib-cjs/data/SpectraManager.js +23 -57
- package/lib-cjs/data/data1d/filter1d/fft.js +20 -3
- package/lib-cjs/data/data1d/filter1d/phaseCorrection.js +10 -4
- package/lib-cjs/data/data2d/Processing2D.js +3 -2
- package/lib-cjs/data/data2d/Spectrum2D/contours.js +138 -0
- package/lib-cjs/data/data2d/Spectrum2D/initiateDatum2D.js +2 -3
- package/lib-cjs/data/utilities/calculateSanPlot.js +35 -0
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +21 -20
- package/lib/component/1d/IntegralResizable.js +0 -72
- package/lib/component/panels/RangesPanel/TableColumns/format.d.ts +0 -1
- package/lib/component/panels/RangesPanel/TableColumns/format.js +0 -8
- package/lib/data/data1d/Data1DManager.d.ts +0 -3
- package/lib/data/data1d/Data1DManager.js +0 -98
- package/lib/data/data1d/filter1d/absolute.d.ts +0 -13
- package/lib/data/data1d/filter1d/absolute.js +0 -26
- package/lib/data/data2d/Data2DManager.d.ts +0 -3
- package/lib/data/data2d/Data2DManager.js +0 -34
- package/lib/data/types/data2d/Contour.d.ts +0 -4
- package/lib/data/types/data2d/Contour.js +0 -1
- package/lib/data/types/data2d/Contours.d.ts +0 -2
- package/lib/data/types/data2d/Contours.js +0 -1
- package/lib-cjs/component/1d/IntegralResizable.js +0 -77
- package/lib-cjs/component/panels/RangesPanel/TableColumns/format.js +0 -14
- package/lib-cjs/data/data1d/Data1DManager.js +0 -104
- package/lib-cjs/data/data1d/filter1d/absolute.js +0 -32
- package/lib-cjs/data/data2d/Data2DManager.js +0 -40
- package/lib-cjs/data/types/data2d/Contour.js +0 -2
- package/lib-cjs/data/types/data2d/Contours.js +0 -2
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
7
7
|
/** @jsxImportSource @emotion/react */
|
|
8
8
|
const react_1 = require("@emotion/react");
|
|
9
|
-
const react_2 = require("react");
|
|
10
9
|
const RangeUtilities_1 = require("../../../data/utilities/RangeUtilities");
|
|
11
10
|
const AssignmentsContext_1 = require("../../assignment/AssignmentsContext");
|
|
12
11
|
const filterForIDsWithAssignment_1 = require("../../assignment/utilities/filterForIDsWithAssignment");
|
|
@@ -17,18 +16,17 @@ const Resizer_1 = __importDefault(require("../../elements/resizer/Resizer"));
|
|
|
17
16
|
const highlight_1 = require("../../highlight");
|
|
18
17
|
const Types_1 = require("../../reducer/types/Types");
|
|
19
18
|
const ToolTypes_1 = require("../../toolbar/ToolTypes");
|
|
20
|
-
const
|
|
19
|
+
const IntegralIndicator_1 = require("../integral/IntegralIndicator");
|
|
21
20
|
const MultiplicityTree_1 = __importDefault(require("../multiplicityTree/MultiplicityTree"));
|
|
22
21
|
const stylesOnHover = (0, react_1.css) `
|
|
23
22
|
pointer-events: bounding-box;
|
|
24
23
|
@-moz-document url-prefix() {
|
|
25
24
|
pointer-events: fill;
|
|
26
25
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
.delete-button {
|
|
26
|
+
.highlight {
|
|
27
|
+
fill: transparent;
|
|
28
|
+
}
|
|
29
|
+
.target {
|
|
32
30
|
visibility: hidden;
|
|
33
31
|
}
|
|
34
32
|
`;
|
|
@@ -38,13 +36,10 @@ const stylesHighlighted = (0, react_1.css) `
|
|
|
38
36
|
@-moz-document url-prefix() {
|
|
39
37
|
pointer-events: fill;
|
|
40
38
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
.delete-button {
|
|
39
|
+
fill: #ff6f0057;
|
|
40
|
+
|
|
41
|
+
.target {
|
|
46
42
|
visibility: visible;
|
|
47
|
-
cursor: pointer;
|
|
48
43
|
}
|
|
49
44
|
`;
|
|
50
45
|
function Range({ rangeData, showMultiplicityTrees, selectedTool, relativeFormat, }) {
|
|
@@ -55,20 +50,8 @@ function Range({ rangeData, showMultiplicityTrees, selectedTool, relativeFormat,
|
|
|
55
50
|
const highlightRange = (0, highlight_1.useHighlight)([assignmentRange.id].concat(assignmentRange.assigned?.x || []).concat((0, filterForIDsWithAssignment_1.filterForIDsWithAssignment)(assignmentData, signals.map((_signal) => _signal.id))), { type: highlight_1.HighlightEventSource.RANGE, extra: { id } });
|
|
56
51
|
const { scaleX } = (0, ScaleContext_1.useScaleChecked)();
|
|
57
52
|
const dispatch = (0, DispatchContext_1.useDispatch)();
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
(0, react_2.useEffect)(() => {
|
|
61
|
-
if (selectedTool && selectedTool === ToolTypes_1.options.editRange.id) {
|
|
62
|
-
setIsBlockedByEditing(true);
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
setIsBlockedByEditing(false);
|
|
66
|
-
}
|
|
67
|
-
}, [selectedTool]);
|
|
68
|
-
(0, react_2.useEffect)(() => {
|
|
69
|
-
setReduceOpacity(!(0, RangeUtilities_1.checkRangeKind)(rangeData));
|
|
70
|
-
}, [rangeData]);
|
|
71
|
-
const handleOnStopResizing = (0, react_2.useCallback)((position) => {
|
|
53
|
+
const isBlockedByEditing = selectedTool && selectedTool === ToolTypes_1.options.editRange.id;
|
|
54
|
+
function handleOnStopResizing(position) {
|
|
72
55
|
dispatch({
|
|
73
56
|
type: Types_1.RESIZE_RANGE,
|
|
74
57
|
data: {
|
|
@@ -77,40 +60,34 @@ function Range({ rangeData, showMultiplicityTrees, selectedTool, relativeFormat,
|
|
|
77
60
|
to: scaleX().invert(position.x1),
|
|
78
61
|
},
|
|
79
62
|
});
|
|
80
|
-
}
|
|
81
|
-
|
|
63
|
+
}
|
|
64
|
+
function mouseEnterHandler() {
|
|
82
65
|
assignmentRange.show('x');
|
|
83
66
|
highlightRange.show();
|
|
84
|
-
}
|
|
85
|
-
|
|
67
|
+
}
|
|
68
|
+
function mouseLeaveHandler() {
|
|
86
69
|
assignmentRange.hide();
|
|
87
70
|
highlightRange.hide();
|
|
88
|
-
}
|
|
89
|
-
|
|
71
|
+
}
|
|
72
|
+
function assignHandler(e) {
|
|
90
73
|
if (selectedTool === ToolTypes_1.options.rangePicking.id &&
|
|
91
74
|
e.shiftKey &&
|
|
92
75
|
!isBlockedByEditing) {
|
|
93
76
|
assignmentRange.setActive('x');
|
|
94
77
|
}
|
|
95
|
-
}
|
|
78
|
+
}
|
|
96
79
|
const from = scaleX()(rangeData.from);
|
|
97
80
|
const to = scaleX()(rangeData.to);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
highlightRange.isActive ||
|
|
109
|
-
assignmentRange.isActive
|
|
110
|
-
? 1
|
|
111
|
-
: 0.6, children: integration !== undefined
|
|
112
|
-
? (0, formatNumber_1.formatNumber)(integration, relativeFormat)
|
|
113
|
-
: '' })] })) }, `${id}_${to}_${from}`), showMultiplicityTrees &&
|
|
81
|
+
const isNotSignal = !(0, RangeUtilities_1.checkRangeKind)(rangeData);
|
|
82
|
+
return ((0, jsx_runtime_1.jsxs)("g", { "data-test-id": "range", style: { outline: 'none' }, onMouseEnter: mouseEnterHandler, onMouseLeave: mouseLeaveHandler, onClick: assignHandler, children: [(0, jsx_runtime_1.jsx)(Resizer_1.default, { tag: "svg", initialPosition: { x1: to, x2: from }, onEnd: handleOnStopResizing, parentElement: viewerRef, disabled: selectedTool !== ToolTypes_1.options.rangePicking.id, children: ({ x1, x2 }, isActive) => {
|
|
83
|
+
const width = x2 - x1;
|
|
84
|
+
return ((0, jsx_runtime_1.jsxs)("g", { css: isBlockedByEditing ||
|
|
85
|
+
highlightRange.isActive ||
|
|
86
|
+
assignmentRange.isActive ||
|
|
87
|
+
isActive
|
|
88
|
+
? stylesHighlighted
|
|
89
|
+
: stylesOnHover, children: [(0, jsx_runtime_1.jsx)("rect", { width: width, height: "100%", className: "highlight", "data-no-export": "true" }), (0, jsx_runtime_1.jsx)(IntegralIndicator_1.IntegralIndicator, { value: integration, format: relativeFormat, width: width, opacity: isNotSignal ? 0.5 : 1 })] }));
|
|
90
|
+
} }, `${id}_${to}_${from}`), showMultiplicityTrees &&
|
|
114
91
|
signals &&
|
|
115
92
|
signals.length > 0 &&
|
|
116
93
|
signals.map((_signal) => ((0, jsx_runtime_1.jsx)(MultiplicityTree_1.default, { rangeFrom: rangeData.from, rangeTo: rangeData.to, signal: _signal }, _signal.id)))] }, id));
|
|
@@ -13,8 +13,8 @@ exports.getXScale = getXScale;
|
|
|
13
13
|
function getYScale(state, spectrumId = null) {
|
|
14
14
|
const { height, margin, verticalAlign, yDomain, yDomains } = state;
|
|
15
15
|
const _height = verticalAlign.align === 'center'
|
|
16
|
-
? (height -
|
|
17
|
-
: height - margin.bottom -
|
|
16
|
+
? (height - 40) / 2
|
|
17
|
+
: height - margin.bottom - 40;
|
|
18
18
|
let domainY = [];
|
|
19
19
|
if (spectrumId === null || yDomains[spectrumId] === undefined) {
|
|
20
20
|
domainY = [0, yDomain[1]];
|
|
@@ -4,67 +4,86 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const debounce_1 = __importDefault(require("lodash/debounce"));
|
|
7
8
|
const get_1 = __importDefault(require("lodash/get"));
|
|
8
9
|
const react_1 = require("react");
|
|
9
10
|
const Spectrum2D_1 = require("../../data/data2d/Spectrum2D");
|
|
11
|
+
const contours_1 = require("../../data/data2d/Spectrum2D/contours");
|
|
10
12
|
const ChartContext_1 = require("../context/ChartContext");
|
|
11
13
|
const PreferencesContext_1 = require("../context/PreferencesContext");
|
|
14
|
+
const Alert_1 = require("../elements/popup/Alert");
|
|
12
15
|
const Reducer_1 = require("../reducer/Reducer");
|
|
13
16
|
const PathBuilder_1 = require("../utility/PathBuilder");
|
|
17
|
+
const nucleusToString_1 = __importDefault(require("../utility/nucleusToString"));
|
|
14
18
|
const scale_1 = require("./utilities/scale");
|
|
15
|
-
function
|
|
16
|
-
const { margin, width, height, xDomain, yDomain
|
|
17
|
-
const activeSpectrum = (0, Reducer_1.useActiveSpectrum)();
|
|
18
|
-
const preferences = (0, PreferencesContext_1.usePreferences)();
|
|
19
|
+
function usePath(datum, contours) {
|
|
20
|
+
const { margin, width, height, xDomain, yDomain } = (0, ChartContext_1.useChartData)();
|
|
19
21
|
const { xShift, yShift } = (0, Spectrum2D_1.getShift)(datum);
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (lines.length < 1e6) {
|
|
31
|
-
for (let i = 0; i < lines.length; i += 4) {
|
|
32
|
-
pathBuilder.moveTo(_scaleX(lines[i] + xShift), _scaleY(lines[i + 1] + yShift));
|
|
33
|
-
pathBuilder.lineTo(_scaleX(lines[i + 2] + xShift), _scaleY(lines[i + 3] + yShift));
|
|
34
|
-
}
|
|
22
|
+
const _scaleX = (0, scale_1.get2DXScale)({ margin, width, xDomain });
|
|
23
|
+
const _scaleY = (0, scale_1.get2DYScale)({ margin, height, yDomain });
|
|
24
|
+
const pathBuilder = new PathBuilder_1.PathBuilder();
|
|
25
|
+
for (const element of contours) {
|
|
26
|
+
if (element.lines) {
|
|
27
|
+
const lines = element.lines;
|
|
28
|
+
if (lines.length < 1e6) {
|
|
29
|
+
for (let i = 0; i < lines.length; i += 4) {
|
|
30
|
+
pathBuilder.moveTo(_scaleX(lines[i] + xShift), _scaleY(lines[i + 1] + yShift));
|
|
31
|
+
pathBuilder.lineTo(_scaleX(lines[i + 2] + xShift), _scaleY(lines[i + 3] + yShift));
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
pathBuilder.moveTo(_scaleX(element[0].x + xShift), _scaleY(element[0].y + yShift));
|
|
37
|
+
for (let j = 1; j < element.length; j++) {
|
|
38
|
+
pathBuilder.lineTo(_scaleX(element[j].x + xShift), _scaleY(element[j].y + yShift));
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
|
-
pathBuilder.closePath();
|
|
45
|
-
return pathBuilder.toString();
|
|
46
41
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
42
|
+
pathBuilder.closePath();
|
|
43
|
+
return pathBuilder.toString();
|
|
44
|
+
}
|
|
45
|
+
const useContoursLevel = (datum, sign) => {
|
|
46
|
+
const { view: { zoom: { levels }, }, } = (0, ChartContext_1.useChartData)();
|
|
47
|
+
const { id, display: { contourOptions }, } = datum;
|
|
48
|
+
const defaultLevel = (0, contours_1.getDefaultContoursLevel)(contourOptions);
|
|
49
|
+
const level = levels?.[id]?.[sign];
|
|
50
|
+
return isNaN(level) ? defaultLevel[sign] : level;
|
|
51
|
+
};
|
|
52
|
+
function ContoursPaths({ id: spectrumID, sign, color, datum, onTimeout, }) {
|
|
53
|
+
const activeSpectrum = (0, Reducer_1.useActiveSpectrum)();
|
|
54
|
+
const preferences = (0, PreferencesContext_1.usePreferences)();
|
|
55
|
+
const level = useContoursLevel(datum, sign);
|
|
56
|
+
const contours = (0, react_1.useMemo)(() => {
|
|
57
|
+
const { contours, timeout } = (0, contours_1.drawContours)(level, datum, sign === 'negative');
|
|
58
|
+
if (timeout) {
|
|
59
|
+
onTimeout();
|
|
60
|
+
}
|
|
61
|
+
return contours;
|
|
62
|
+
}, [datum, level, onTimeout, sign]);
|
|
63
|
+
const path = usePath(datum, contours);
|
|
64
|
+
const opacity = activeSpectrum === null || spectrumID === activeSpectrum.id
|
|
65
|
+
? '1'
|
|
66
|
+
: (0, get_1.default)(preferences.current, 'general.dimmedSpectraOpacity', 0.1);
|
|
67
|
+
return ((0, jsx_runtime_1.jsx)("path", { fill: "none", "data-test-id": "spectrum-line", stroke: color, strokeWidth: "1", opacity: opacity, d: path }));
|
|
58
68
|
}
|
|
59
69
|
function ContoursInner({ data, displayerKey }) {
|
|
60
|
-
|
|
70
|
+
const alert = (0, Alert_1.useAlert)();
|
|
71
|
+
const debounceAlert = (0, react_1.useRef)((0, debounce_1.default)(() => {
|
|
72
|
+
alert.error('Too many contour lines, only showing the first ones');
|
|
73
|
+
}, 2000));
|
|
74
|
+
function timeoutHandler() {
|
|
75
|
+
debounceAlert.current();
|
|
76
|
+
}
|
|
77
|
+
return ((0, jsx_runtime_1.jsx)("g", { clipPath: `url(#${displayerKey}clip-chart-2d)`, className: "contours", children: data?.map((datum) => ((0, jsx_runtime_1.jsxs)("g", { children: [datum.display.isPositiveVisible && ((0, jsx_runtime_1.jsx)(ContoursPaths, { id: datum.id, sign: "positive", datum: datum, color: datum.display.positiveColor, onTimeout: timeoutHandler })), datum.display.isNegativeVisible && ((0, jsx_runtime_1.jsx)(ContoursPaths, { id: datum.id, sign: "negative", datum: datum, color: datum.display.negativeColor, onTimeout: timeoutHandler }))] }, datum.id))) }));
|
|
61
78
|
}
|
|
62
79
|
const MemoizedContours = (0, react_1.memo)(ContoursInner);
|
|
63
80
|
function Contours() {
|
|
64
|
-
const { data: spectra, displayerKey } = (0, ChartContext_1.useChartData)();
|
|
81
|
+
const { data: spectra, displayerKey, view: { spectra: { activeTab }, }, } = (0, ChartContext_1.useChartData)();
|
|
65
82
|
const data = (0, react_1.useMemo)(() => {
|
|
66
|
-
return spectra.filter((datum) => datum.info.dimension === 2 &&
|
|
67
|
-
|
|
83
|
+
return spectra.filter((datum) => datum.info.dimension === 2 &&
|
|
84
|
+
datum.info.isFt &&
|
|
85
|
+
activeTab === (0, nucleusToString_1.default)(datum.info.nucleus));
|
|
86
|
+
}, [activeTab, spectra]);
|
|
68
87
|
return (0, jsx_runtime_1.jsx)(MemoizedContours, { ...{ data, displayerKey } });
|
|
69
88
|
}
|
|
70
89
|
exports.default = Contours;
|
|
@@ -66,6 +66,6 @@ function Left1DChart({ margin: marignValue = 10, data: spectrum, }) {
|
|
|
66
66
|
const mainHeight = originHeight - margin.bottom - margin.top;
|
|
67
67
|
if (!mainHeight || !height)
|
|
68
68
|
return null;
|
|
69
|
-
return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: `0 0 ${height} ${mainHeight + margin.top}`, width: height, height: mainHeight + margin.top, children: [(0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsx)("clipPath", { id: `${displayerKey}clip-left`, children: (0, jsx_runtime_1.jsx)("rect", { width: height, height: mainHeight, x: "0", y: margin.top }) }) }), (0, jsx_runtime_1.jsx)("g", { clipPath: `url(#${displayerKey}clip-left)`, children: (0, jsx_runtime_1.jsx)("path", { className: "line", stroke:
|
|
69
|
+
return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: `0 0 ${height} ${mainHeight + margin.top}`, width: height, height: mainHeight + margin.top, children: [(0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsx)("clipPath", { id: `${displayerKey}clip-left`, children: (0, jsx_runtime_1.jsx)("rect", { width: height, height: mainHeight, x: "0", y: margin.top }) }) }), (0, jsx_runtime_1.jsx)("g", { clipPath: `url(#${displayerKey}clip-left)`, children: (0, jsx_runtime_1.jsx)("path", { className: "line", stroke: spectrum.display.color, fill: "none", d: paths }) })] }));
|
|
70
70
|
}
|
|
71
71
|
exports.default = (0, react_1.memo)(Left1DChart);
|
|
@@ -62,6 +62,6 @@ function Top1DChart({ margin: marginProps = 10, data: spectrum, }) {
|
|
|
62
62
|
if (!width || !height) {
|
|
63
63
|
return null;
|
|
64
64
|
}
|
|
65
|
-
return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: `0 0 ${width} ${height}`, width: width, height: height, children: [(0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsx)("clipPath", { id: `${displayerKey}clip-top`, children: (0, jsx_runtime_1.jsx)("rect", { width: width - originMargin.left - originMargin.right, height: height, x: originMargin.left, y: `${0}` }) }) }), (0, jsx_runtime_1.jsx)("g", { clipPath: `url(#${displayerKey}clip-top)`, children: (0, jsx_runtime_1.jsx)("path", { className: "line", stroke:
|
|
65
|
+
return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: `0 0 ${width} ${height}`, width: width, height: height, children: [(0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsx)("clipPath", { id: `${displayerKey}clip-top`, children: (0, jsx_runtime_1.jsx)("rect", { width: width - originMargin.left - originMargin.right, height: height, x: originMargin.left, y: `${0}` }) }) }), (0, jsx_runtime_1.jsx)("g", { clipPath: `url(#${displayerKey}clip-top)`, children: (0, jsx_runtime_1.jsx)("path", { className: "line", stroke: spectrum.display.color, fill: "none", strokeWidth: "1px", d: paths }) })] }));
|
|
66
66
|
}
|
|
67
67
|
exports.default = (0, react_1.memo)(Top1DChart);
|
|
@@ -19,6 +19,9 @@ const initialState = {
|
|
|
19
19
|
startY: 0,
|
|
20
20
|
endY: 0,
|
|
21
21
|
};
|
|
22
|
+
function stopPageScrolling(event) {
|
|
23
|
+
event.preventDefault();
|
|
24
|
+
}
|
|
22
25
|
exports.BrushContext = (0, react_1.createContext)(initialState);
|
|
23
26
|
function BrushTracker({ children, className, style, onBrush = () => null, onZoom = () => null, onDoubleClick = () => null, onClick = () => null, noPropagation, }) {
|
|
24
27
|
const [state, dispatch] = (0, react_1.useReducer)(reducer, initialState);
|
|
@@ -41,6 +44,24 @@ function BrushTracker({ children, className, style, onBrush = () => null, onZoom
|
|
|
41
44
|
});
|
|
42
45
|
setMouseDownTime(event.timeStamp);
|
|
43
46
|
}
|
|
47
|
+
function moveCallback(event) {
|
|
48
|
+
dispatch({
|
|
49
|
+
type: 'MOVE',
|
|
50
|
+
screenX: event.screenX,
|
|
51
|
+
screenY: event.screenY,
|
|
52
|
+
clientX: event.clientX,
|
|
53
|
+
clientY: event.clientY,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function mouseUpCallback() {
|
|
57
|
+
dispatch({
|
|
58
|
+
type: 'UP',
|
|
59
|
+
});
|
|
60
|
+
window.removeEventListener('mousemove', moveCallback);
|
|
61
|
+
window.removeEventListener('mouseup', mouseUpCallback);
|
|
62
|
+
}
|
|
63
|
+
window.addEventListener('mousemove', moveCallback);
|
|
64
|
+
window.addEventListener('mouseup', mouseUpCallback);
|
|
44
65
|
return false;
|
|
45
66
|
}, [noPropagation]);
|
|
46
67
|
const clickHandler = (0, react_1.useCallback)((e) => {
|
|
@@ -80,35 +101,23 @@ function BrushTracker({ children, className, style, onBrush = () => null, onZoom
|
|
|
80
101
|
});
|
|
81
102
|
}
|
|
82
103
|
}, [onBrush, state]);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const upCallback = (0, react_1.useCallback)((event) => {
|
|
93
|
-
dispatch({
|
|
94
|
-
type: 'UP',
|
|
95
|
-
clientX: event.clientX,
|
|
96
|
-
clientY: event.clientY,
|
|
97
|
-
});
|
|
98
|
-
return false;
|
|
99
|
-
}, []);
|
|
100
|
-
return ((0, jsx_runtime_1.jsx)(exports.BrushContext.Provider, { value: state, children: (0, jsx_runtime_1.jsx)("div", { className: className, style: style, onMouseDown: mouseDownHandler, onMouseUp: upCallback, onMouseMove: moveCallback, onClick: clickHandler, onWheel: handleMouseWheel, children: children }) }));
|
|
104
|
+
return ((0, jsx_runtime_1.jsx)(exports.BrushContext.Provider, { value: state, children: (0, jsx_runtime_1.jsx)("div", { className: className, style: style, onMouseDown: mouseDownHandler, onClick: clickHandler, onWheel: handleMouseWheel, onMouseEnter: () => {
|
|
105
|
+
// disable page scrolling once the mouse over the Displayer
|
|
106
|
+
window.addEventListener('wheel', stopPageScrolling, {
|
|
107
|
+
passive: false,
|
|
108
|
+
});
|
|
109
|
+
}, onMouseLeave: () => {
|
|
110
|
+
// disable page scrolling once the mouse over the Displayer
|
|
111
|
+
window.removeEventListener('wheel', stopPageScrolling);
|
|
112
|
+
}, children: children }) }));
|
|
101
113
|
}
|
|
102
114
|
exports.BrushTracker = BrushTracker;
|
|
103
115
|
function reducer(state, action) {
|
|
104
116
|
switch (action.type) {
|
|
105
117
|
case 'UP':
|
|
106
118
|
if (state.step === 'brushing' || state.step === 'start') {
|
|
107
|
-
const { clientX, clientY } = action;
|
|
108
119
|
return {
|
|
109
120
|
...state,
|
|
110
|
-
endX: clientX - state.boundingRect.x,
|
|
111
|
-
endY: clientY - state.boundingRect.y,
|
|
112
121
|
step: state.step === 'start' ? 'initial' : 'end',
|
|
113
122
|
};
|
|
114
123
|
}
|
|
@@ -58,7 +58,7 @@ const Constants_1 = require("./reducer/core/Constants");
|
|
|
58
58
|
const preferencesReducer_1 = __importStar(require("./reducer/preferences/preferencesReducer"));
|
|
59
59
|
const Types_1 = require("./reducer/types/Types");
|
|
60
60
|
const ToolBar_1 = __importDefault(require("./toolbar/ToolBar"));
|
|
61
|
-
const
|
|
61
|
+
const export_1 = require("./utility/export");
|
|
62
62
|
const viewerContainerStyle = (0, react_1.css) `
|
|
63
63
|
border: 0.55px #e6e6e6 solid;
|
|
64
64
|
display: flex;
|
|
@@ -162,7 +162,7 @@ function InnerNMRium({ data: dataProp = defaultData, workspace, preferences = de
|
|
|
162
162
|
}, [preferences, workspace]);
|
|
163
163
|
(0, react_2.useImperativeHandle)(innerRef, () => ({
|
|
164
164
|
getSpectraViewerAsBlob: () => {
|
|
165
|
-
return rootRef?.current ? (0,
|
|
165
|
+
return rootRef?.current ? (0, export_1.getBlob)(rootRef.current, 'nmrSVG') : null;
|
|
166
166
|
},
|
|
167
167
|
}), []);
|
|
168
168
|
(0, react_2.useEffect)(() => {
|
|
@@ -7,6 +7,6 @@ const PreferencesContext_1 = require("./context/PreferencesContext");
|
|
|
7
7
|
function SplitPaneWrapper({ children }) {
|
|
8
8
|
const { current } = (0, PreferencesContext_1.usePreferences)();
|
|
9
9
|
const { hidePanelOnLoad = false, initialPanelWidth = '560px' } = current?.display?.general || {};
|
|
10
|
-
return ((0, jsx_runtime_1.jsx)(analysis_ui_components_1.SplitPane, {
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)(analysis_ui_components_1.SplitPane, { initialSize: initialPanelWidth, direction: "horizontal", controlledSide: "end", initialClosed: hidePanelOnLoad ? true : 600, children: children }, hidePanelOnLoad ? 'true' : 'false'));
|
|
11
11
|
}
|
|
12
12
|
exports.SplitPaneWrapper = SplitPaneWrapper;
|
|
@@ -7,7 +7,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
7
7
|
const react_1 = require("react");
|
|
8
8
|
const Input_1 = __importDefault(require("./Input"));
|
|
9
9
|
const EditableColumn = (0, react_1.forwardRef)(function EditableColumn(props, ref) {
|
|
10
|
-
const { onSave = () => null, value, type = 'text', style, onEditStart = () => null, editStatus = false, validate = () => true, } = props;
|
|
10
|
+
const { onSave = () => null, value, type = 'text', style, onEditStart = () => null, editStatus = false, validate = () => true, textOverFlowEllipses = false, ...InputProps } = props;
|
|
11
11
|
const [enabled, enableEdit] = (0, react_1.useState)();
|
|
12
12
|
const [isValid, setValid] = (0, react_1.useState)(true);
|
|
13
13
|
(0, react_1.useEffect)(() => {
|
|
@@ -48,11 +48,26 @@ const EditableColumn = (0, react_1.forwardRef)(function EditableColumn(props, re
|
|
|
48
48
|
window.removeEventListener('mousedown', mouseClickCallback);
|
|
49
49
|
}
|
|
50
50
|
}, [mouseClickCallback, onSave, validate]);
|
|
51
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
51
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
52
|
+
display: 'table',
|
|
53
|
+
width: '100%',
|
|
54
|
+
height: '100%',
|
|
55
|
+
...(textOverFlowEllipses
|
|
56
|
+
? { whiteSpace: 'nowrap', overflow: 'hidden', display: 'inline-flex' }
|
|
57
|
+
: {}),
|
|
58
|
+
...style,
|
|
59
|
+
}, className: "editable-column-input", onDoubleClick: startEditHandler, children: [!enabled && ((0, jsx_runtime_1.jsx)("span", { style: {
|
|
60
|
+
display: 'table-cell',
|
|
61
|
+
verticalAlign: 'middle',
|
|
62
|
+
width: 'inherit',
|
|
63
|
+
...(textOverFlowEllipses
|
|
64
|
+
? { textOverflow: 'ellipsis', overflow: 'hidden' }
|
|
65
|
+
: {}),
|
|
66
|
+
}, children: value })), enabled && ((0, jsx_runtime_1.jsx)("div", { style: { display: 'table-cell', verticalAlign: 'middle' }, children: (0, jsx_runtime_1.jsx)(Input_1.default, { style: {
|
|
52
67
|
inputWrapper: {
|
|
53
68
|
width: '100%',
|
|
54
69
|
...(!isValid && { borderColor: 'red' }),
|
|
55
70
|
},
|
|
56
|
-
}, enableAutoSelect: true, className: "editable-column", value: value, type: type, onKeyUp: editHandler }) }))] }));
|
|
71
|
+
}, enableAutoSelect: true, className: "editable-column", value: value, type: type, onKeyUp: editHandler, ...InputProps }) }))] }));
|
|
57
72
|
});
|
|
58
73
|
exports.default = EditableColumn;
|
|
@@ -10,15 +10,12 @@ const get_1 = __importDefault(require("lodash/get"));
|
|
|
10
10
|
const react_1 = require("react");
|
|
11
11
|
const getColor_1 = require("../../../data/utilities/getColor");
|
|
12
12
|
function FormikColorPicker(props) {
|
|
13
|
-
const { onColorChange = () => null, name
|
|
14
|
-
const { values, setFieldValue
|
|
15
|
-
|
|
13
|
+
const { onColorChange = () => null, name } = props;
|
|
14
|
+
const { values, setFieldValue } = (0, formik_1.useFormikContext)();
|
|
15
|
+
function colorChangeHandler(color) {
|
|
16
16
|
setFieldValue(name, `${color.hex}${Math.round(color.rgb.a * 255).toString(16)}`, false);
|
|
17
17
|
onColorChange(color);
|
|
18
|
-
|
|
19
|
-
setTimeout(submitForm, 1);
|
|
20
|
-
}
|
|
21
|
-
}, [name, onColorChange, setFieldValue, submitForm, triggerSubmit]);
|
|
18
|
+
}
|
|
22
19
|
return ((0, jsx_runtime_1.jsx)(analysis_ui_components_1.ColorPicker, { color: { hex: (0, get_1.default)(values, name, '#000') }, presetColors: getColor_1.COLORS, onChangeComplete: colorChangeHandler, style: { boxShadow: 'none' } }));
|
|
23
20
|
}
|
|
24
21
|
exports.default = (0, react_1.memo)(FormikColorPicker);
|
|
@@ -6,29 +6,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
7
|
const formik_1 = require("formik");
|
|
8
8
|
const get_1 = __importDefault(require("lodash/get"));
|
|
9
|
-
const react_1 = require("react");
|
|
10
9
|
const Input_1 = __importDefault(require("../Input"));
|
|
11
10
|
function FormikInput(props) {
|
|
12
|
-
const { name, style = { label: {}, input: {} }, onChange = () => null, checkValue = () => true, type = 'text', className = '', value = null, format = () => (value) => value, checkErrorAfterInputTouched = true,
|
|
13
|
-
const { values, handleChange,
|
|
14
|
-
|
|
11
|
+
const { name, style = { label: {}, input: {} }, onChange = () => null, checkValue = () => true, type = 'text', className = '', value = null, format = () => (value) => value, checkErrorAfterInputTouched = true, ...resProps } = props;
|
|
12
|
+
const { values, handleChange, errors, touched } = (0, formik_1.useFormikContext)();
|
|
13
|
+
function changeHandler(e) {
|
|
15
14
|
onChange(e);
|
|
16
15
|
handleChange(e);
|
|
17
|
-
}
|
|
18
|
-
(0,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
setTimeout(submitForm, 1);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}, [name, setFieldValue, submitForm, triggerSubmit, value]);
|
|
26
|
-
const isInvalid = (0, react_1.useMemo)(() => {
|
|
27
|
-
if (checkErrorAfterInputTouched) {
|
|
28
|
-
return (0, get_1.default)(errors, name) && (0, get_1.default)(touched, name);
|
|
29
|
-
}
|
|
30
|
-
return (0, get_1.default)(errors, name);
|
|
31
|
-
}, [checkErrorAfterInputTouched, errors, name, touched]);
|
|
16
|
+
}
|
|
17
|
+
let isInvalid = (0, get_1.default)(errors, name);
|
|
18
|
+
if (checkErrorAfterInputTouched) {
|
|
19
|
+
isInvalid = (0, get_1.default)(errors, name) && (0, get_1.default)(touched, name);
|
|
20
|
+
}
|
|
32
21
|
return ((0, jsx_runtime_1.jsx)(Input_1.default, { name: name, value: value ? value : (0, get_1.default)(values, name), onChange: changeHandler, type: type, style: {
|
|
33
22
|
...style,
|
|
34
23
|
inputWrapper: {
|
|
@@ -5,22 +5,25 @@ const react_1 = require("react");
|
|
|
5
5
|
const FormikOnChange = (props) => {
|
|
6
6
|
const { onChange = () => null, enableValidation = true } = props;
|
|
7
7
|
const oldValuesRef = (0, react_1.useRef)({});
|
|
8
|
-
const { values, errors,
|
|
8
|
+
const { values, errors, setTouched, initialValues } = (0, formik_1.useFormikContext)();
|
|
9
9
|
(0, react_1.useEffect)(() => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const isNewValue = JSON.stringify(values) !== JSON.stringify(initialValues);
|
|
11
|
+
if (isNewValue) {
|
|
12
|
+
if (enableValidation) {
|
|
13
|
+
if (Object.keys(errors).length === 0 &&
|
|
14
|
+
JSON.stringify(oldValuesRef.current) !== JSON.stringify(values)) {
|
|
15
|
+
onChange(values);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
setTouched(errors);
|
|
19
|
+
}
|
|
14
20
|
}
|
|
15
21
|
else {
|
|
16
|
-
|
|
22
|
+
onChange(values);
|
|
17
23
|
}
|
|
18
24
|
}
|
|
19
|
-
else {
|
|
20
|
-
onChange(values);
|
|
21
|
-
}
|
|
22
25
|
oldValuesRef.current = values;
|
|
23
|
-
}, [values, enableValidation, errors, onChange,
|
|
26
|
+
}, [values, enableValidation, errors, onChange, setTouched, initialValues]);
|
|
24
27
|
return null;
|
|
25
28
|
};
|
|
26
29
|
exports.default = (0, react_1.memo)(FormikOnChange);
|
|
@@ -5,19 +5,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
7
|
const formik_1 = require("formik");
|
|
8
|
+
const debounce_1 = __importDefault(require("lodash/debounce"));
|
|
8
9
|
const get_1 = __importDefault(require("lodash/get"));
|
|
9
10
|
const react_1 = require("react");
|
|
10
11
|
const react_slider_1 = __importDefault(require("react-slider"));
|
|
11
12
|
function FormikSlider(props) {
|
|
12
|
-
const {
|
|
13
|
-
const { values, setFieldValue
|
|
14
|
-
const
|
|
15
|
-
onAfterChange(value);
|
|
13
|
+
const { name, debounceTime = 0 } = props;
|
|
14
|
+
const { values, setFieldValue } = (0, formik_1.useFormikContext)();
|
|
15
|
+
const debounceOnChange = (0, react_1.useRef)((0, debounce_1.default)((value) => {
|
|
16
16
|
setFieldValue(name, value);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
}, [name, onAfterChange, setFieldValue, submitForm, triggerSubmit]);
|
|
21
|
-
return ((0, jsx_runtime_1.jsx)(react_slider_1.default, { className: "horizontal-slider", thumbClassName: "thumb", trackClassName: "track", defaultValue: (0, get_1.default)(values, name, [0, 100]), onAfterChange: changeHandler, renderThumb: (props, state) => ((0, jsx_runtime_1.jsx)("div", { ...props, children: (0, jsx_runtime_1.jsx)("span", { children: state.valueNow }) })), pearling: true, minDistance: 10, ...sliderProps }));
|
|
17
|
+
}, debounceTime)).current;
|
|
18
|
+
return ((0, jsx_runtime_1.jsx)(react_slider_1.default, { className: "horizontal-slider", thumbClassName: "thumb", trackClassName: "track", defaultValue: (0, get_1.default)(values, name, [0, 100]), onAfterChange: (value) => debounceOnChange(value), renderThumb: (props, state) => ((0, jsx_runtime_1.jsx)("div", { ...props, children: (0, jsx_runtime_1.jsx)("span", { children: state.valueNow }) })), pearling: true, minDistance: 10 }));
|
|
22
19
|
}
|
|
23
|
-
exports.default =
|
|
20
|
+
exports.default = FormikSlider;
|
|
@@ -14,7 +14,7 @@ function useActiveSpectrumStyleOptions(id) {
|
|
|
14
14
|
const isActive = activeSpectrum === null ? true : id === activeSpectrum.id;
|
|
15
15
|
const opacity = isActive
|
|
16
16
|
? 1
|
|
17
|
-
: (0, get_1.default)(preferences.current, 'general.
|
|
17
|
+
: (0, get_1.default)(preferences.current, 'general.dimmedSpectraOpacity', 0.1);
|
|
18
18
|
return { isActive, opacity };
|
|
19
19
|
}, [activeSpectrum, id, preferences]);
|
|
20
20
|
}
|