nmrium 0.53.0 → 0.55.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/Viewer1D.js +48 -17
- package/lib/component/1d/XAxis.js +1 -1
- package/lib/component/1d/integral/IntegralsSeries.js +2 -2
- package/lib/component/1d/integral/Integration.d.ts +3 -1
- package/lib/component/1d/integral/Integration.js +3 -2
- package/lib/component/1d/peaks/PeakEditionManager.js +5 -3
- package/lib/component/1d/ranges/AssignmentActionsButtons.d.ts +1 -0
- package/lib/component/1d/ranges/AssignmentActionsButtons.js +3 -3
- package/lib/component/1d/ranges/AssignmentLabel.d.ts +1 -1
- package/lib/component/1d/ranges/AssignmentLabel.js +31 -4
- package/lib/component/1d/ranges/Atoms.js +4 -5
- package/lib/component/1d/ranges/Range.js +62 -12
- package/lib/component/1d/ranges/Ranges.js +2 -1
- package/lib/component/1d/ranges/RangesIntegrals.js +11 -4
- package/lib/component/1d/tool/XLabelPointer.js +4 -12
- package/lib/component/1d-2d/FieldEdition.d.ts +13 -0
- package/lib/component/1d-2d/FieldEdition.js +42 -0
- package/lib/component/2d/Chart2D.js +5 -3
- package/lib/component/2d/tools/XYLabelPointer.js +3 -9
- package/lib/component/2d/zones/Zone.js +18 -2
- package/lib/component/2d/zones/ZonesAssignmentsLabels.d.ts +7 -0
- package/lib/component/2d/zones/ZonesAssignmentsLabels.js +286 -0
- package/lib/component/EventsTrackers/KeysListenerTracker.js +14 -1
- package/lib/component/context/LoggerContext.js +11 -4
- package/lib/component/context/ShareDataContext.d.ts +10 -0
- package/lib/component/context/ShareDataContext.js +22 -0
- package/lib/component/elements/ActionsButtonsPopover.d.ts +10 -0
- package/lib/component/elements/ActionsButtonsPopover.js +22 -0
- package/lib/component/elements/CloseButton.d.ts +1 -1
- package/lib/component/elements/CustomToolTip.d.ts +8 -0
- package/lib/component/elements/CustomToolTip.js +107 -0
- package/lib/component/elements/EditableColumn.js +3 -2
- package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +7 -5
- package/lib/component/elements/ReactTable/ReactTable.d.ts +2 -2
- package/lib/component/elements/SVGButton.d.ts +14 -0
- package/lib/component/elements/SVGButton.js +6 -0
- package/lib/component/elements/SVGGroup.js +15 -13
- package/lib/component/elements/SVGText.d.ts +8 -0
- package/lib/component/elements/SVGText.js +24 -0
- package/lib/component/elements/SaveButton.d.ts +1 -1
- package/lib/component/elements/draggable/SVGDraggable.d.ts +2 -2
- package/lib/component/elements/formik/FormikError.js +2 -4
- package/lib/component/elements/formik/FormikInput.d.ts +2 -1
- package/lib/component/elements/formik/FormikInput.js +5 -4
- package/lib/component/header/Header.js +8 -11
- package/lib/component/header/PhaseCorrectionTwoDimensionsPanel.js +41 -10
- package/lib/component/hooks/useActiveSpectrumZonesViewState.js +1 -0
- package/lib/component/hooks/useCheckPointsNumberInWindowArea.d.ts +1 -1
- package/lib/component/hooks/useFormatNumberByNucleus.d.ts +1 -1
- package/lib/component/hooks/useFormatNumberByNucleus.js +8 -7
- package/lib/component/hooks/useIntegralPath.d.ts +2 -0
- package/lib/component/hooks/useIntegralPath.js +3 -1
- package/lib/component/hooks/usePanelPreferences.js +1 -2
- package/lib/component/hooks/useSaveSettings.js +7 -14
- package/lib/component/hooks/useTriggerNewAssignmentLabel.d.ts +4 -0
- package/lib/component/hooks/useTriggerNewAssignmentLabel.js +8 -0
- package/lib/component/hooks/useWorkspaceAction.d.ts +7 -0
- package/lib/component/hooks/useWorkspaceAction.js +89 -0
- package/lib/component/loader/DropZone.js +0 -3
- package/lib/component/main/InnerNMRium.js +3 -1
- package/lib/component/main/InnerNMRiumContents.js +14 -2
- package/lib/component/main/NMRiumStateProvider.js +15 -3
- package/lib/component/modal/AboutPredictionModal.js +1 -1
- package/lib/component/modal/AboutSpectrumSimulationModal.js +1 -1
- package/lib/component/modal/CopyClipboardModal.js +1 -1
- package/lib/component/modal/EditPeakShapeModal.js +1 -1
- package/lib/component/modal/ImportPublicationStringModal.js +11 -5
- package/lib/component/modal/PredictSpectraModal.js +1 -1
- package/lib/component/modal/aboutUs/AboutUsModal.js +1 -1
- package/lib/component/modal/changeSum/ChangeSumModal.js +1 -1
- package/lib/component/modal/editRange/EditRangeModal.js +1 -1
- package/lib/component/modal/editRange/forms/components/DeltaInput.js +3 -3
- package/lib/component/modal/editRange/forms/components/NewSignalTab.js +17 -12
- package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.js +30 -13
- package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.js +26 -16
- package/lib/component/modal/editZone/EditZoneModal.js +1 -1
- package/lib/component/modal/setting/GeneralSettings.js +18 -39
- package/lib/component/modal/setting/WorkspaceItem.js +1 -1
- package/lib/component/modal/setting/settings-tabs/NucleiTabContent.d.ts +2 -0
- package/lib/component/modal/setting/settings-tabs/NucleiTabContent.js +99 -0
- package/lib/component/modal/setting/settingsValidation.js +36 -40
- package/lib/component/panels/AutomaticAssignment/AutomaticAssignment.js +2 -2
- package/lib/component/panels/IntegralsPanel/IntegralPanel.js +2 -2
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +2 -2
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +1 -1
- package/lib/component/panels/PeaksPanel/PeaksPanel.js +5 -5
- package/lib/component/panels/RangesPanel/RangesHeader.js +11 -11
- package/lib/component/panels/RangesPanel/RangesPreferences.js +16 -16
- package/lib/component/panels/RangesPanel/RangesTable.js +1 -1
- package/lib/component/panels/RangesPanel/RangesTableRow.js +2 -2
- package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +22 -8
- package/lib/component/panels/SpectraPanel/SpectraPreferences.js +13 -1
- package/lib/component/panels/SpectraPanel/base/setting/PlotChart.js +1 -1
- package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DHistogram.js +1 -1
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.js +1 -1
- package/lib/component/panels/SummaryPanel/SetMolecularFormulaModal.d.ts +5 -5
- package/lib/component/panels/SummaryPanel/SetMolecularFormulaModal.js +79 -89
- package/lib/component/panels/SummaryPanel/SetShiftTolerancesModal.d.ts +5 -4
- package/lib/component/panels/SummaryPanel/SetShiftTolerancesModal.js +66 -98
- package/lib/component/panels/SummaryPanel/SummaryPanel.js +13 -32
- package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentLabelColumn.d.ts +6 -0
- package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentLabelColumn.js +16 -0
- package/lib/component/panels/ZonesPanel/ZonesPanel.js +22 -6
- package/lib/component/panels/ZonesPanel/ZonesPreferences.js +15 -9
- package/lib/component/panels/ZonesPanel/ZonesTable.js +2 -2
- package/lib/component/panels/ZonesPanel/ZonesTableRow.js +3 -2
- package/lib/component/panels/databasePanel/DatabaseSearchOptions.js +2 -2
- package/lib/component/panels/header/DefaultPanelHeader.js +2 -2
- package/lib/component/panels/header/PreferencesHeader.js +1 -1
- package/lib/component/panels/header/SpectraAutomaticPickingButton.js +1 -1
- package/lib/component/panels/multipleAnalysisPanel/MultipleSpectraAnalysisPanel.js +4 -4
- package/lib/component/panels/multipleAnalysisPanel/preferences/index.js +1 -1
- package/lib/component/reducer/IgnoreActions.js +1 -0
- package/lib/component/reducer/Reducer.js +8 -0
- package/lib/component/reducer/actions/DomainActions.d.ts +7 -2
- package/lib/component/reducer/actions/DomainActions.js +29 -1
- package/lib/component/reducer/actions/FiltersActions.d.ts +3 -2
- package/lib/component/reducer/actions/FiltersActions.js +27 -1
- package/lib/component/reducer/actions/MoleculeActions.js +1 -1
- package/lib/component/reducer/actions/RangesActions.d.ts +2 -3
- package/lib/component/reducer/actions/RangesActions.js +28 -26
- package/lib/component/reducer/actions/SpectraActions.d.ts +5 -4
- package/lib/component/reducer/actions/SpectraActions.js +5 -1
- package/lib/component/reducer/actions/ZonesActions.d.ts +15 -2
- package/lib/component/reducer/actions/ZonesActions.js +47 -13
- package/lib/component/reducer/helper/setRangesViewProperty.d.ts +1 -0
- package/lib/component/reducer/helper/setRangesViewProperty.js +11 -11
- package/lib/component/reducer/preferences/actions/addWorkspace.js +4 -23
- package/lib/component/reducer/preferences/actions/analyzeSpectra.js +4 -4
- package/lib/component/reducer/preferences/actions/initPreferences.js +2 -4
- package/lib/component/reducer/preferences/actions/matrixGeneration.js +3 -3
- package/lib/component/reducer/preferences/actions/removeWorkspace.js +0 -5
- package/lib/component/reducer/preferences/actions/setActiveWorkspace.js +0 -4
- package/lib/component/reducer/preferences/actions/setPanelsPreferences.js +1 -1
- package/lib/component/reducer/preferences/actions/setPreferences.js +2 -16
- package/lib/component/reducer/preferences/actions/setWorkspace.js +4 -3
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +7 -0
- package/lib/component/reducer/preferences/preferencesReducer.js +21 -18
- package/lib/component/toolbar/ToolBar.js +115 -25
- package/lib/component/utility/PreferencesHelper.js +5 -4
- package/lib/component/utility/export.js +4 -0
- package/lib/component/workspaces/assignment.js +0 -1
- package/lib/component/workspaces/basic.js +0 -1
- package/lib/component/workspaces/embedded.js +0 -1
- package/lib/component/workspaces/exercise.js +26 -29
- package/lib/component/workspaces/prediction.js +171 -174
- package/lib/component/workspaces/process1D.js +0 -1
- package/lib/component/workspaces/simulation.js +35 -38
- package/lib/component/workspaces/workspaceDefaultProperties.js +16 -23
- package/lib/data/data1d/Spectrum1D/get1DColor.d.ts +10 -3
- package/lib/data/data1d/Spectrum1D/get1DColor.js +28 -2
- package/lib/data/data1d/Spectrum1D/index.d.ts +2 -2
- package/lib/data/data1d/Spectrum1D/index.js +2 -2
- package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +50 -0
- package/lib/data/data1d/Spectrum1D/ranges/createRange.js +51 -0
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +2 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +4 -2
- package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +52 -0
- package/lib/data/data1d/Spectrum1D/ranges/resizeRange.js +28 -0
- package/lib/data/data2d/Spectrum2D/get2DColor.d.ts +11 -3
- package/lib/data/data2d/Spectrum2D/get2DColor.js +20 -4
- package/lib/data/data2d/Spectrum2D/getSlice.js +1 -1
- package/lib/data/data2d/Spectrum2D/zones/detectZonesManual.d.ts +1 -0
- package/lib/data/data2d/Spectrum2D/zones/initiateZones.d.ts +1 -0
- package/lib/data/utilities/generateColor.d.ts +7 -3
- package/lib/data/utilities/generateColor.js +5 -17
- package/lib/versionInfo.js +1 -1
- package/package.json +35 -35
- package/lib/component/elements/MolecularFormulaInput.d.ts +0 -6
- package/lib/component/elements/MolecularFormulaInput.js +0 -63
- package/lib/component/modal/setting/settings-tabs/FormattingTabContent.d.ts +0 -2
- package/lib/component/modal/setting/settings-tabs/FormattingTabContent.js +0 -80
- package/lib/component/reducer/preferences/utilities/mapNucleiFormatting.d.ts +0 -2
- package/lib/component/reducer/preferences/utilities/mapNucleiFormatting.js +0 -10
- package/lib/data/data1d/Spectrum1D/ranges/addRange.d.ts +0 -7
- package/lib/data/data1d/Spectrum1D/ranges/addRange.js +0 -31
- package/lib/data/data1d/Spectrum1D/ranges/changeRange.d.ts +0 -3
- package/lib/data/data1d/Spectrum1D/ranges/changeRange.js +0 -32
|
@@ -9,17 +9,12 @@ import { getLayoutID, LAYOUT } from '../utilities/DimensionLayout';
|
|
|
9
9
|
import { get1DYScale, useScale2DX, useScale2DY } from '../utilities/scale';
|
|
10
10
|
const style = {
|
|
11
11
|
cursor: 'crosshair',
|
|
12
|
-
transformOrigin: 'bottom right',
|
|
13
12
|
position: 'absolute',
|
|
14
|
-
|
|
15
|
-
left: '-88px',
|
|
13
|
+
paddingRight: '5px',
|
|
16
14
|
fontWeight: 'bold',
|
|
17
15
|
pointerEvents: 'none',
|
|
18
16
|
overflow: 'visible',
|
|
19
17
|
userSelect: 'none',
|
|
20
|
-
width: '85px',
|
|
21
|
-
textAlign: 'right',
|
|
22
|
-
zIndex: 9,
|
|
23
18
|
};
|
|
24
19
|
function XYLabelPointer({ layout, data1D }) {
|
|
25
20
|
const position = useMouseTracker();
|
|
@@ -33,7 +28,6 @@ function XYLabelPointer({ layout, data1D }) {
|
|
|
33
28
|
});
|
|
34
29
|
const nuclei = activeTab.split(',');
|
|
35
30
|
const [formatX, formatY] = useFormatNumberByNucleus(nuclei);
|
|
36
|
-
// const spectrum = useSpectrum();
|
|
37
31
|
const scale2DX = useScale2DX();
|
|
38
32
|
const scale2DY = useScale2DY();
|
|
39
33
|
const scaleX = useMemo(() => {
|
|
@@ -118,7 +112,7 @@ function XYLabelPointer({ layout, data1D }) {
|
|
|
118
112
|
};
|
|
119
113
|
return (_jsxs("div", { style: {
|
|
120
114
|
...style,
|
|
121
|
-
transform: `translate(${position.x}px, ${position.y}px)`,
|
|
122
|
-
}, children: [_jsx("span", { children: formatY(getYValue()) }), _jsx("span", { style: { color: 'gray' }, children: ',' }), _jsx("span", { style: { color: 'red' }, children: formatX(getXValue()) })] }
|
|
115
|
+
transform: `translate(${position.x}px, ${position.y}px) translate(-100%,-100%)`,
|
|
116
|
+
}, children: [_jsx("span", { children: formatY(getYValue()) }), _jsx("span", { style: { color: 'gray' }, children: ',' }), _jsx("span", { style: { color: 'red' }, children: formatX(getXValue()) })] }));
|
|
123
117
|
}
|
|
124
118
|
export default XYLabelPointer;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
|
+
import styled from '@emotion/styled';
|
|
4
5
|
import { useState, useEffect } from 'react';
|
|
6
|
+
import { PiTextTBold } from 'react-icons/pi';
|
|
5
7
|
import { checkZoneKind } from '../../../data/utilities/ZoneUtilities';
|
|
6
8
|
import { useAssignment } from '../../assignment/AssignmentsContext';
|
|
9
|
+
import { useShareData } from '../../context/ShareDataContext';
|
|
10
|
+
import { SVGButton } from '../../elements/SVGButton';
|
|
7
11
|
import { HighlightEventSource, useHighlight } from '../../highlight';
|
|
8
12
|
import { useActiveSpectrumZonesViewState } from '../../hooks/useActiveSpectrumZonesViewState';
|
|
9
13
|
import { useScale2DX, useScale2DY } from '../utilities/scale';
|
|
@@ -37,8 +41,20 @@ const stylesHighlighted = css `
|
|
|
37
41
|
cursor: pointer;
|
|
38
42
|
}
|
|
39
43
|
`;
|
|
44
|
+
const GroupContainer = styled.g `
|
|
45
|
+
.target {
|
|
46
|
+
visibility: hidden;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&:hover {
|
|
50
|
+
.target {
|
|
51
|
+
visibility: visible;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
40
55
|
function Zone({ zoneData }) {
|
|
41
|
-
const { x, y, id, signals } = zoneData;
|
|
56
|
+
const { x, y, id, signals, assignment } = zoneData;
|
|
57
|
+
const { setData } = useShareData();
|
|
42
58
|
const assignmentZone = useAssignment(id);
|
|
43
59
|
const { showZones } = useActiveSpectrumZonesViewState();
|
|
44
60
|
const highlightZone = useHighlight([assignmentZone.id], {
|
|
@@ -61,6 +77,6 @@ function Zone({ zoneData }) {
|
|
|
61
77
|
}, onMouseLeave: () => {
|
|
62
78
|
assignmentZone.hide();
|
|
63
79
|
highlightZone.hide();
|
|
64
|
-
}, children: [showZones && (
|
|
80
|
+
}, children: [showZones && (_jsxs(GroupContainer, { transform: `translate(${scaleX(x2)},${scaleY(y1)})`, children: [_jsx("g", { "data-no-export": "true", transform: "translate(-16 -16)", className: "target", children: !assignment && (_jsx(SVGButton, { renderIcon: (props) => _jsx(PiTextTBold, { ...props }), backgroundColor: "green", title: "Add assignment label", style: { cursor: 'hand' }, onClick: () => setData({ id }) })) }), _jsx("rect", { x: "0", width: scaleX(x1) - scaleX(x2), height: scaleY(y2) - scaleY(y1), className: "integral-area", fill: "#0000000f", stroke: reduceOpacity ? '#343a40' : 'darkgreen', strokeWidth: reduceOpacity ? '0' : '1' })] })), signals.map((_signal, i) => (_jsx(Signal, { signal: _signal }, String(id + i))))] }, id));
|
|
65
81
|
}
|
|
66
82
|
export default Zone;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Zone } from 'nmr-processing';
|
|
2
|
+
interface AssignmentLabelProps {
|
|
3
|
+
zone: Zone;
|
|
4
|
+
}
|
|
5
|
+
export declare function AssignmentLabel(props: AssignmentLabelProps): import("react/jsx-runtime").JSX.Element | null;
|
|
6
|
+
export default function ZonesAssignmentsLabels(): import("react/jsx-runtime").JSX.Element | null;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
4
|
+
import { PiTextTSlash } from 'react-icons/pi';
|
|
5
|
+
import { FieldEdition } from '../../1d-2d/FieldEdition';
|
|
6
|
+
import { useChartData } from '../../context/ChartContext';
|
|
7
|
+
import { useDispatch } from '../../context/DispatchContext';
|
|
8
|
+
import { useGlobal } from '../../context/GlobalContext';
|
|
9
|
+
import { useShareData } from '../../context/ShareDataContext';
|
|
10
|
+
import { SVGButton } from '../../elements/SVGButton';
|
|
11
|
+
import { SVGGroup } from '../../elements/SVGGroup';
|
|
12
|
+
import useDraggable from '../../elements/draggable/useDraggable';
|
|
13
|
+
import { useHighlight } from '../../highlight';
|
|
14
|
+
import { useActiveSpectrumZonesViewState } from '../../hooks/useActiveSpectrumZonesViewState';
|
|
15
|
+
import useSpectrum from '../../hooks/useSpectrum';
|
|
16
|
+
import { useScale2DX, useScale2DY } from '../utilities/scale';
|
|
17
|
+
const distance = 30;
|
|
18
|
+
const iconSize = 16;
|
|
19
|
+
const LabelBoxPadding = { left: 35, right: 0, top: 15, bottom: 15 };
|
|
20
|
+
function getDistance(x1, y1, x2, y2) {
|
|
21
|
+
const deltaX = x2 - x1;
|
|
22
|
+
const deltaY = y2 - y1;
|
|
23
|
+
return Math.hypot(deltaX, deltaY);
|
|
24
|
+
}
|
|
25
|
+
function radiansToDegrees(radians) {
|
|
26
|
+
return radians * (180 / Math.PI);
|
|
27
|
+
}
|
|
28
|
+
function getAngleFromSides(a, b, c) {
|
|
29
|
+
const radians = Math.acos((b ** 2 + c ** 2 - a ** 2) / (2 * b * c));
|
|
30
|
+
return radiansToDegrees(radians);
|
|
31
|
+
}
|
|
32
|
+
function findBestLink(sourcePoints, targetPoints) {
|
|
33
|
+
const result = [];
|
|
34
|
+
for (const sourcePoint of sourcePoints) {
|
|
35
|
+
const { a, b } = sourcePoint;
|
|
36
|
+
for (const targetPoint of targetPoints) {
|
|
37
|
+
const { x, y } = targetPoint;
|
|
38
|
+
const aLength = getDistance(a.x, a.y, x, y);
|
|
39
|
+
const bLength = getDistance(b.x, b.y, x, y);
|
|
40
|
+
const deltaLength = getDistance(a.x, a.y, b.x, b.y);
|
|
41
|
+
const distance = Math.min(aLength, bLength);
|
|
42
|
+
const angle = Number(getAngleFromSides(deltaLength, aLength, bLength).toFixed(1));
|
|
43
|
+
result.push({ distance, angle, targetPoint, sourcePoint });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
result.sort((a, b) => {
|
|
47
|
+
if (a.angle !== b.angle) {
|
|
48
|
+
return b.angle - a.angle;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return a.distance - b.distance;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return result[0];
|
|
55
|
+
}
|
|
56
|
+
function useLinkPath(currentPosition, targetBoundary, sourceElementBoundary, options = {}) {
|
|
57
|
+
const { sideLength = 6, shift = 5 } = options;
|
|
58
|
+
const { x1, x2, y1, y2 } = targetBoundary;
|
|
59
|
+
const { x, y } = currentPosition;
|
|
60
|
+
const scaleX = useScale2DX();
|
|
61
|
+
const scaleY = useScale2DY();
|
|
62
|
+
const { width, height } = sourceElementBoundary;
|
|
63
|
+
const centerX = width / 2;
|
|
64
|
+
const centerY = height / 2;
|
|
65
|
+
const leftX = x - centerX - shift;
|
|
66
|
+
const rightX = x + centerX + shift;
|
|
67
|
+
const topY = y - height;
|
|
68
|
+
const bottomY = y + shift;
|
|
69
|
+
const targetWidth = scaleX(x2) - scaleX(x1);
|
|
70
|
+
const targetHeight = scaleY(y2) - scaleY(y1);
|
|
71
|
+
const targetXCenter = scaleX(x1) + targetWidth / 2;
|
|
72
|
+
const targetYCenter = scaleY(y1) + targetHeight / 2;
|
|
73
|
+
const sourcePoints = [
|
|
74
|
+
{
|
|
75
|
+
a: { x, y: bottomY },
|
|
76
|
+
b: { x: x + sideLength, y: bottomY },
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
a: { x, y: topY },
|
|
80
|
+
b: { x: x + sideLength, y: topY },
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
a: { x: leftX, y: y - centerY - sideLength / 2 },
|
|
84
|
+
b: { x: leftX, y: y - centerY + sideLength / 2 },
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
a: { x: rightX, y: y - centerY - sideLength / 2 },
|
|
88
|
+
b: { x: rightX, y: y - centerY + sideLength / 2 },
|
|
89
|
+
},
|
|
90
|
+
];
|
|
91
|
+
/**
|
|
92
|
+
* Zone coordination
|
|
93
|
+
* xMid= x2-x1/2;
|
|
94
|
+
* yMid= y2-y1/2;
|
|
95
|
+
* (x1,y1) ---------- (xMid,y1) ---------- (x2,y1)
|
|
96
|
+
* | |
|
|
97
|
+
* | |
|
|
98
|
+
* (x1,yMid) (x2,yMid)
|
|
99
|
+
* | |
|
|
100
|
+
* | |
|
|
101
|
+
* (x1,y2) ---------- (xMid,y2) ---------- (x2,y2)
|
|
102
|
+
*
|
|
103
|
+
*/
|
|
104
|
+
const targetPoints = [
|
|
105
|
+
{
|
|
106
|
+
//Left Top
|
|
107
|
+
x: scaleX(x1),
|
|
108
|
+
y: scaleY(y1),
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
//Center Top
|
|
112
|
+
x: targetXCenter,
|
|
113
|
+
y: scaleY(y1),
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
//Right Top
|
|
117
|
+
x: scaleX(x2),
|
|
118
|
+
y: scaleY(y1),
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
//Right Center
|
|
122
|
+
x: scaleX(x2),
|
|
123
|
+
y: targetYCenter,
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
//Right Bottom
|
|
127
|
+
x: scaleX(x2),
|
|
128
|
+
y: scaleY(y2),
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
//Center Bottom
|
|
132
|
+
x: targetXCenter,
|
|
133
|
+
y: scaleY(y2),
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
//Left Bottom
|
|
137
|
+
x: scaleX(x1),
|
|
138
|
+
y: scaleY(y2),
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
//Left Center
|
|
142
|
+
x: scaleX(x1),
|
|
143
|
+
y: targetYCenter,
|
|
144
|
+
},
|
|
145
|
+
];
|
|
146
|
+
const link = findBestLink(sourcePoints, targetPoints);
|
|
147
|
+
return `${link.sourcePoint.a.x},${link.sourcePoint.a.y} ${link.sourcePoint.b.x},${link.sourcePoint.b.y} ${link.targetPoint.x},${link.targetPoint.y}`;
|
|
148
|
+
}
|
|
149
|
+
const GroupContainer = styled.g(({ isMoveActive }) => !isMoveActive
|
|
150
|
+
? `
|
|
151
|
+
|
|
152
|
+
pointer-events: bounding-box;
|
|
153
|
+
|
|
154
|
+
.target {
|
|
155
|
+
visibility: hidden;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
&:hover {
|
|
159
|
+
.target {
|
|
160
|
+
visibility: visible;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
`
|
|
164
|
+
: ``);
|
|
165
|
+
export function AssignmentLabel(props) {
|
|
166
|
+
const { zone } = props;
|
|
167
|
+
const { id, x, y, assignment } = zone;
|
|
168
|
+
const dispatch = useDispatch();
|
|
169
|
+
const { isActive } = useHighlight([zone.id]);
|
|
170
|
+
const { assignmentsLabelsCoordinates } = useActiveSpectrumZonesViewState();
|
|
171
|
+
const scaleX = useScale2DX();
|
|
172
|
+
const scaleY = useScale2DY();
|
|
173
|
+
const { viewerRef } = useGlobal();
|
|
174
|
+
const textRef = useRef(null);
|
|
175
|
+
const [labelBoundary, setLabelBoundary] = useState({
|
|
176
|
+
width: 0,
|
|
177
|
+
height: 0,
|
|
178
|
+
});
|
|
179
|
+
const [isMoveActive, setIsMoveActive] = useState(false);
|
|
180
|
+
const { data: newAssignmentLabelState, setData: updateNewAssignmentLabelState, } = useShareData();
|
|
181
|
+
function dismissNewLabel() {
|
|
182
|
+
if (newAssignmentLabelState) {
|
|
183
|
+
updateNewAssignmentLabelState(null);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
let coordinate = {
|
|
187
|
+
x: scaleX(x.to),
|
|
188
|
+
y: scaleY(y.from) - distance,
|
|
189
|
+
};
|
|
190
|
+
if (assignmentsLabelsCoordinates?.[id]) {
|
|
191
|
+
coordinate = {
|
|
192
|
+
x: scaleX(assignmentsLabelsCoordinates[id].x),
|
|
193
|
+
y: scaleY(assignmentsLabelsCoordinates[id].y),
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
const [currentPosition, setCurrentPosition] = useState(coordinate);
|
|
197
|
+
useEffect(() => {
|
|
198
|
+
setCurrentPosition({ x: coordinate.x, y: coordinate.y });
|
|
199
|
+
}, [coordinate.x, coordinate.y]);
|
|
200
|
+
useLayoutEffect(() => {
|
|
201
|
+
if (textRef.current) {
|
|
202
|
+
const { width, height } = textRef.current.getBBox();
|
|
203
|
+
setLabelBoundary({ width, height });
|
|
204
|
+
}
|
|
205
|
+
}, [assignment]);
|
|
206
|
+
const { onPointerDown } = useDraggable({
|
|
207
|
+
position: coordinate,
|
|
208
|
+
onChange: (dragEvent) => {
|
|
209
|
+
const { action, position } = dragEvent;
|
|
210
|
+
const boundary = textRef.current?.getBBox();
|
|
211
|
+
if (!boundary)
|
|
212
|
+
return;
|
|
213
|
+
const centerX = width / 2 + LabelBoxPadding.left;
|
|
214
|
+
const centerY = height + iconSize;
|
|
215
|
+
switch (action) {
|
|
216
|
+
case 'start': {
|
|
217
|
+
setCurrentPosition({ x: position.x, y: position.y });
|
|
218
|
+
setIsMoveActive(true);
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
case 'move': {
|
|
222
|
+
setCurrentPosition({
|
|
223
|
+
x: position.x + centerX,
|
|
224
|
+
y: position.y + centerY,
|
|
225
|
+
});
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
case 'end':
|
|
229
|
+
dispatch({
|
|
230
|
+
type: 'SET_ZONE_ASSIGNMENT_LABEL_COORDINATION',
|
|
231
|
+
payload: {
|
|
232
|
+
zoneID: zone.id,
|
|
233
|
+
coordination: {
|
|
234
|
+
x: scaleX.invert(position.x + centerX),
|
|
235
|
+
y: scaleY.invert(position.y + centerY),
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
setIsMoveActive(false);
|
|
240
|
+
break;
|
|
241
|
+
default:
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
parentElement: viewerRef,
|
|
246
|
+
});
|
|
247
|
+
const path = useLinkPath(currentPosition, { x1: x.to, x2: x.from, y1: y.from, y2: y.to }, labelBoundary);
|
|
248
|
+
if (!assignment && newAssignmentLabelState?.id !== id) {
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
function handleChange(value) {
|
|
252
|
+
dismissNewLabel();
|
|
253
|
+
dispatch({
|
|
254
|
+
type: 'CHANGE_ZONE_ASSIGNMENT_LABEL',
|
|
255
|
+
payload: {
|
|
256
|
+
value,
|
|
257
|
+
zoneID: id,
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
const { width, height } = labelBoundary;
|
|
262
|
+
return (_jsxs(GroupContainer, { isMoveActive: isMoveActive, children: [_jsx("polygon", { points: path, fill: isActive ? '#ff6f0091' : 'black' }), _jsxs("g", { style: {
|
|
263
|
+
transform: `translate(${currentPosition.x}px,${currentPosition.y}px)`,
|
|
264
|
+
}, children: [_jsx("rect", { "data-no-export": "true", fill: "transparent", x: -(width / 2 + LabelBoxPadding.left), width: width + LabelBoxPadding.left + LabelBoxPadding.right, height: height + LabelBoxPadding.top + LabelBoxPadding.bottom, y: -(height + LabelBoxPadding.top) }), _jsx(FieldEdition, { onChange: handleChange, inputType: "text", value: assignment || '', PopoverProps: {
|
|
265
|
+
position: 'top',
|
|
266
|
+
targetTagName: 'g',
|
|
267
|
+
...(newAssignmentLabelState?.id === id
|
|
268
|
+
? { isOpen: true, onClose: () => dismissNewLabel() }
|
|
269
|
+
: {}),
|
|
270
|
+
}, children: _jsx("text", { fontWeight: isActive ? 'bold' : 'normal', ref: textRef, textAnchor: "middle", fill: "black", style: { cursor: 'hand' }, children: assignment }) }), _jsxs(SVGGroup, { space: 2, "data-no-export": "true", transform: `translate(-${width / 2 + iconSize * 2 + 2} -${height + iconSize})`, className: "target", children: [_jsx(SVGButton, { title: "Move label", size: iconSize, icon: "move", onPointerDown: onPointerDown, style: { cursor: 'move' } }), _jsx(SVGButton, { size: iconSize, title: "Remove label", renderIcon: (props) => _jsx(PiTextTSlash, { ...props }), backgroundColor: "red", style: { cursor: 'hand' }, onClick: () => handleChange('') })] })] })] }));
|
|
271
|
+
}
|
|
272
|
+
function ZonesAssignmentsLabelsInner({ zones, displayerKey }) {
|
|
273
|
+
return (_jsx("g", { clipPath: `url(#${displayerKey}clip-chart-2d)`, className: "2d-zones-assignments-labels", children: zones.values.map((zone) => (_jsx(AssignmentLabel, { zone: zone }, zone.id))) }));
|
|
274
|
+
}
|
|
275
|
+
const emptyData = { zones: {}, display: {} };
|
|
276
|
+
export default function ZonesAssignmentsLabels() {
|
|
277
|
+
const { displayerKey } = useChartData();
|
|
278
|
+
const { zones, display } = useSpectrum(emptyData);
|
|
279
|
+
const { showAssignmentsLabels } = useActiveSpectrumZonesViewState();
|
|
280
|
+
const { data: NewAssignmentLabelState } = useShareData();
|
|
281
|
+
if ((!display.isVisible || !showAssignmentsLabels) &&
|
|
282
|
+
!NewAssignmentLabelState) {
|
|
283
|
+
return null;
|
|
284
|
+
}
|
|
285
|
+
return _jsx(ZonesAssignmentsLabelsInner, { zones, displayerKey });
|
|
286
|
+
}
|
|
@@ -19,7 +19,7 @@ function KeysListenerTracker(props) {
|
|
|
19
19
|
const { mainDivRef } = props;
|
|
20
20
|
const { keysPreferences, displayerMode, data, view: { spectra: { activeTab }, }, } = useChartData();
|
|
21
21
|
const dispatch = useDispatch();
|
|
22
|
-
const { dispatch: dispatchPreferences } = usePreferences();
|
|
22
|
+
const { dispatch: dispatchPreferences, current: { nuclei }, } = usePreferences();
|
|
23
23
|
const toaster = useToaster();
|
|
24
24
|
const modal = useModal();
|
|
25
25
|
const openLoader = useLoader();
|
|
@@ -394,6 +394,18 @@ function KeysListenerTracker(props) {
|
|
|
394
394
|
default:
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
|
+
if (e.shiftKey) {
|
|
398
|
+
switch (e.key) {
|
|
399
|
+
case 'F': {
|
|
400
|
+
dispatch({
|
|
401
|
+
type: 'SET_AXIS_DOMAIN',
|
|
402
|
+
payload: { nucleiPreferences: nuclei },
|
|
403
|
+
});
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
default:
|
|
407
|
+
}
|
|
408
|
+
}
|
|
397
409
|
if (e.shiftKey && (e.metaKey || e.ctrlKey)) {
|
|
398
410
|
switch (e.key) {
|
|
399
411
|
case 's':
|
|
@@ -417,6 +429,7 @@ function KeysListenerTracker(props) {
|
|
|
417
429
|
handleChangeOption,
|
|
418
430
|
handleFullZoomOut,
|
|
419
431
|
isToolVisible,
|
|
432
|
+
nuclei,
|
|
420
433
|
openLoader,
|
|
421
434
|
openSaveAsDialog,
|
|
422
435
|
saveAsJSONHandler,
|
|
@@ -26,8 +26,10 @@ export function LoggerProvider({ children }) {
|
|
|
26
26
|
const [logsHistory, setLogsHistory] = useState([]);
|
|
27
27
|
const [isLogHistoryOpened, openLogHistory] = useState(false);
|
|
28
28
|
const popupLoggingLevelRef = useRef();
|
|
29
|
-
const loggerRef = useRef(new FifoLogger(
|
|
30
|
-
|
|
29
|
+
const loggerRef = useRef(new FifoLogger());
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
function handleLogger({ detail: { logs } }) {
|
|
32
|
+
const log = logs.at(-1);
|
|
31
33
|
if (log &&
|
|
32
34
|
popupLoggingLevelRef.current &&
|
|
33
35
|
log.level === LOGGER_LEVELS[popupLoggingLevelRef.current]) {
|
|
@@ -38,8 +40,13 @@ export function LoggerProvider({ children }) {
|
|
|
38
40
|
console.error(log.error);
|
|
39
41
|
}
|
|
40
42
|
setLogsHistory(logs.slice());
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
+
}
|
|
44
|
+
const loggerInstance = loggerRef.current;
|
|
45
|
+
loggerInstance.addEventListener('change', handleLogger);
|
|
46
|
+
return () => {
|
|
47
|
+
loggerInstance.removeEventListener('change', handleLogger);
|
|
48
|
+
};
|
|
49
|
+
}, []);
|
|
43
50
|
useEffect(() => {
|
|
44
51
|
if (loggingLevel) {
|
|
45
52
|
loggerRef.current.setLevel(loggingLevel);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface ShareDataState<T> {
|
|
3
|
+
data: T | null;
|
|
4
|
+
setData: (data: T) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare function useShareData<T>(): ShareDataState<T>;
|
|
7
|
+
export declare function ShareDataProvider<T>({ children, }: {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useMemo, useState } from 'react';
|
|
3
|
+
const ShareDataContext = createContext(null);
|
|
4
|
+
export function useShareData() {
|
|
5
|
+
const context = useContext(ShareDataContext);
|
|
6
|
+
if (!context) {
|
|
7
|
+
throw new Error('useShareData must be used within an ShareDataProvider');
|
|
8
|
+
}
|
|
9
|
+
return context;
|
|
10
|
+
}
|
|
11
|
+
export function ShareDataProvider({ children, }) {
|
|
12
|
+
const [data, setData] = useState(null);
|
|
13
|
+
const state = useMemo(() => {
|
|
14
|
+
return {
|
|
15
|
+
data,
|
|
16
|
+
setData: (newData) => {
|
|
17
|
+
setData(newData);
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}, [data]);
|
|
21
|
+
return (_jsx(ShareDataContext.Provider, { value: state, children: children }));
|
|
22
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @jsxImportSource @emotion/react */
|
|
2
|
+
import { PopoverProps } from '@blueprintjs/core';
|
|
3
|
+
import { ButtonProps } from 'react-science/ui';
|
|
4
|
+
export interface ActionsButtonsPopoverProps extends Omit<PopoverProps, 'interactionKind' | 'content'> {
|
|
5
|
+
buttons: Array<Pick<ButtonProps, 'icon' | 'onClick' | 'intent' | 'disabled'> & {
|
|
6
|
+
title?: string;
|
|
7
|
+
visible?: boolean;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
export declare function ActionsButtonsPopover(props: ActionsButtonsPopoverProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource @emotion/react */
|
|
3
|
+
import { Popover } from '@blueprintjs/core';
|
|
4
|
+
import { css } from '@emotion/react';
|
|
5
|
+
import { Button } from 'react-science/ui';
|
|
6
|
+
export function ActionsButtonsPopover(props) {
|
|
7
|
+
const { buttons, children, ...otherProps } = props;
|
|
8
|
+
return (_jsx(Popover, { minimal: true, position: "auto-start", popoverClassName: "actions-buttons-popover", interactionKind: "hover", enforceFocus: false, content: _jsx("div", { style: { display: 'flex', flexDirection: 'column' }, css: css `
|
|
9
|
+
button,
|
|
10
|
+
a[role='button'] {
|
|
11
|
+
border-radius: 50%;
|
|
12
|
+
min-width: 16px;
|
|
13
|
+
min-height: 16px;
|
|
14
|
+
font-size: 10px;
|
|
15
|
+
padding: 5px;
|
|
16
|
+
}
|
|
17
|
+
`, children: buttons
|
|
18
|
+
.filter((button) => button?.visible !== false)
|
|
19
|
+
.map(({ icon, onClick, intent, title, disabled }, index) => {
|
|
20
|
+
return (_jsx(Button, { disabled: disabled, icon: icon, onClick: onClick, tooltipProps: { content: title || '', compact: true }, intent: intent }, title || index));
|
|
21
|
+
}) }), ...otherProps, children: children }));
|
|
22
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ToolbarItemProps } from 'react-science/ui';
|
|
2
|
-
export declare function CloseButton(props: Pick<ToolbarItemProps, 'onClick' | '
|
|
2
|
+
export declare function CloseButton(props: Pick<ToolbarItemProps, 'onClick' | 'tooltip' | 'className'>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource @emotion/react */
|
|
3
|
+
import { css } from '@emotion/react';
|
|
4
|
+
const styles = {
|
|
5
|
+
titleContainer: {
|
|
6
|
+
display: 'flex',
|
|
7
|
+
justifyContent: 'space-between',
|
|
8
|
+
flexWrap: 'wrap',
|
|
9
|
+
alignItems: 'center',
|
|
10
|
+
},
|
|
11
|
+
title: {
|
|
12
|
+
fontSize: '0.9rem',
|
|
13
|
+
flex: 1,
|
|
14
|
+
padding: '5px 0',
|
|
15
|
+
textAlign: 'left',
|
|
16
|
+
color: 'white',
|
|
17
|
+
},
|
|
18
|
+
description: {
|
|
19
|
+
paddingTop: '1rem',
|
|
20
|
+
fontSize: '0.7rem',
|
|
21
|
+
textAlign: 'left',
|
|
22
|
+
color: 'white',
|
|
23
|
+
},
|
|
24
|
+
shortcutContainer: {
|
|
25
|
+
display: 'flex',
|
|
26
|
+
textWrap: 'nowrap',
|
|
27
|
+
color: 'white',
|
|
28
|
+
},
|
|
29
|
+
shortcutItem: {
|
|
30
|
+
display: 'flex',
|
|
31
|
+
justifyContent: 'center',
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
padding: '0.2rem',
|
|
34
|
+
border: '1px solid #ccc',
|
|
35
|
+
borderRadius: '4px',
|
|
36
|
+
height: 'calc(0.2rem + 20px)',
|
|
37
|
+
minWidth: 'calc(0.2rem + 20px)' /* Adjust padding and border width */,
|
|
38
|
+
marginLeft: '5px',
|
|
39
|
+
fontSize: '0.75rem',
|
|
40
|
+
fontWeight: 'bold',
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
export function CustomToolTip(props) {
|
|
44
|
+
const { title, shortcuts = [], subTitles = [], description = '', link, } = props;
|
|
45
|
+
return (_jsxs("div", { style: {
|
|
46
|
+
width: 250,
|
|
47
|
+
padding: '0.5rem',
|
|
48
|
+
}, children: [_jsxs("div", { style: styles.titleContainer, children: [_jsx("span", { style: styles.title, children: title }), _jsx(ShortCuts, { shortcuts: shortcuts })] }), _jsx(SubTitles, { items: subTitles }), (description || link) && (_jsxs("p", { style: styles.description, children: [description, link && (_jsx("a", { style: description ? { paddingLeft: '5px' } : {}, target: "_blank", href: link, rel: "noreferrer", children: "Learn more" }))] }))] }));
|
|
49
|
+
}
|
|
50
|
+
function ShortCuts({ shortcuts, style = {}, }) {
|
|
51
|
+
return (_jsx("div", { style: styles.shortcutContainer, children: shortcuts.map((key, index) => {
|
|
52
|
+
return (_jsx("div", { style: {
|
|
53
|
+
...styles.shortcutItem,
|
|
54
|
+
...(index === 0 && { margin: 0 }),
|
|
55
|
+
...style,
|
|
56
|
+
}, children: _jsx("span", { children: key }) }, key));
|
|
57
|
+
}) }));
|
|
58
|
+
}
|
|
59
|
+
const subTitleStyle = css `
|
|
60
|
+
padding-left: 5px;
|
|
61
|
+
list-style: none;
|
|
62
|
+
|
|
63
|
+
li {
|
|
64
|
+
position: relative;
|
|
65
|
+
padding-left: 15px;
|
|
66
|
+
box-sizing: border-box;
|
|
67
|
+
|
|
68
|
+
&::before {
|
|
69
|
+
position: absolute;
|
|
70
|
+
top: 15px;
|
|
71
|
+
left: 0;
|
|
72
|
+
width: 10px;
|
|
73
|
+
height: 1px;
|
|
74
|
+
margin: auto;
|
|
75
|
+
content: '';
|
|
76
|
+
background-color: white;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&::after {
|
|
80
|
+
position: absolute;
|
|
81
|
+
top: 0;
|
|
82
|
+
bottom: 0;
|
|
83
|
+
left: 0;
|
|
84
|
+
width: 1px;
|
|
85
|
+
height: 100%;
|
|
86
|
+
content: '';
|
|
87
|
+
background-color: white;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
&:last-child::after {
|
|
91
|
+
height: 15px;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
li:first-child {
|
|
96
|
+
padding-top: 5px;
|
|
97
|
+
|
|
98
|
+
&::before {
|
|
99
|
+
top: 20px;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
`;
|
|
103
|
+
function SubTitles({ items }) {
|
|
104
|
+
if (!items || items.length === 0)
|
|
105
|
+
return null;
|
|
106
|
+
return (_jsx("ul", { css: subTitleStyle, children: items.map(({ shortcuts = [], title }) => (_jsx("li", { children: _jsxs("div", { style: styles.titleContainer, children: [_jsx("span", { style: { ...styles.title, fontSize: '0.7rem' }, children: title }), _jsx(ShortCuts, { style: { padding: '0.1rem' }, shortcuts: shortcuts })] }) }, title))) }));
|
|
107
|
+
}
|
|
@@ -34,13 +34,14 @@ const EditableColumn = forwardRef(function EditableColumn(props, ref) {
|
|
|
34
34
|
onEditStart(true);
|
|
35
35
|
enableEdit(true);
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function saveHandler(event) {
|
|
38
38
|
const valid = validate(val);
|
|
39
39
|
setValid(valid);
|
|
40
40
|
// when press Enter or Tab
|
|
41
41
|
if (valid && ['Enter', 'Tab'].includes(event.key)) {
|
|
42
42
|
onSave(event);
|
|
43
43
|
enableEdit(false);
|
|
44
|
+
window.removeEventListener('mousedown', mouseClickCallback);
|
|
44
45
|
}
|
|
45
46
|
// close edit mode if press Enter, Tab or Escape
|
|
46
47
|
if (['Escape'].includes(event.key)) {
|
|
@@ -76,6 +77,6 @@ const EditableColumn = forwardRef(function EditableColumn(props, ref) {
|
|
|
76
77
|
width: '100%',
|
|
77
78
|
minWidth: '60px',
|
|
78
79
|
},
|
|
79
|
-
}, autoSelect: true, className: "editable-column", value: val, type: type, onChange: handleChange,
|
|
80
|
+
}, autoSelect: true, className: "editable-column", value: val, type: type, onChange: handleChange, onKeyDown: saveHandler, onMouseDown: (e) => e.stopPropagation(), ...InputProps }) }))] }));
|
|
80
81
|
});
|
|
81
82
|
export default EditableColumn;
|