nmrium 2.4.0 → 2.5.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/HorizontalAxis1D.d.ts.map +1 -1
- package/lib/component/1d/HorizontalAxis1D.js +4 -1
- package/lib/component/1d/HorizontalAxis1D.js.map +1 -1
- package/lib/component/1d/SVGContent1D.d.ts.map +1 -1
- package/lib/component/1d/SVGContent1D.js +2 -1
- package/lib/component/1d/SVGContent1D.js.map +1 -1
- package/lib/component/1d/Viewer1D.d.ts.map +1 -1
- package/lib/component/1d/Viewer1D.js +2 -1
- package/lib/component/1d/Viewer1D.js.map +1 -1
- package/lib/component/1d/integral/IntegralResizable.d.ts.map +1 -1
- package/lib/component/1d/integral/IntegralResizable.js +4 -4
- package/lib/component/1d/integral/IntegralResizable.js.map +1 -1
- package/lib/component/1d/ranges/Range.d.ts.map +1 -1
- package/lib/component/1d/ranges/Range.js +3 -3
- package/lib/component/1d/ranges/Range.js.map +1 -1
- package/lib/component/1d/ranges/Signals.d.ts +2 -0
- package/lib/component/1d/ranges/Signals.d.ts.map +1 -0
- package/lib/component/1d/ranges/Signals.js +16 -0
- package/lib/component/1d/ranges/Signals.js.map +1 -0
- package/lib/component/1d-2d/components/RangeIndicator.d.ts +13 -0
- package/lib/component/1d-2d/components/RangeIndicator.d.ts.map +1 -0
- package/lib/component/1d-2d/components/RangeIndicator.js +52 -0
- package/lib/component/1d-2d/components/RangeIndicator.js.map +1 -0
- package/lib/component/1d-2d/components/Signals1D.d.ts +19 -0
- package/lib/component/1d-2d/components/Signals1D.d.ts.map +1 -0
- package/lib/component/1d-2d/components/Signals1D.js +155 -0
- package/lib/component/1d-2d/components/Signals1D.js.map +1 -0
- package/lib/component/1d-2d/tools/CrossLinePointer.d.ts +16 -1
- package/lib/component/1d-2d/tools/CrossLinePointer.d.ts.map +1 -1
- package/lib/component/1d-2d/tools/CrossLinePointer.js +25 -15
- package/lib/component/1d-2d/tools/CrossLinePointer.js.map +1 -1
- package/lib/component/1d-2d/tools/CursorToolIcon.d.ts +9 -0
- package/lib/component/1d-2d/tools/CursorToolIcon.d.ts.map +1 -0
- package/lib/component/1d-2d/tools/CursorToolIcon.js +58 -0
- package/lib/component/1d-2d/tools/CursorToolIcon.js.map +1 -0
- package/lib/component/2d/1d-tracer/Left1DChart.d.ts.map +1 -1
- package/lib/component/2d/1d-tracer/Left1DChart.js +3 -2
- package/lib/component/2d/1d-tracer/Left1DChart.js.map +1 -1
- package/lib/component/2d/1d-tracer/Ranges1D.d.ts.map +1 -1
- package/lib/component/2d/1d-tracer/Ranges1D.js +4 -60
- package/lib/component/2d/1d-tracer/Ranges1D.js.map +1 -1
- package/lib/component/2d/1d-tracer/Top1DChart.d.ts.map +1 -1
- package/lib/component/2d/1d-tracer/Top1DChart.js +3 -2
- package/lib/component/2d/1d-tracer/Top1DChart.js.map +1 -1
- package/lib/component/2d/DirectAxis2D.d.ts.map +1 -1
- package/lib/component/2d/DirectAxis2D.js +4 -1
- package/lib/component/2d/DirectAxis2D.js.map +1 -1
- package/lib/component/2d/IndirectAxis2D.d.ts.map +1 -1
- package/lib/component/2d/IndirectAxis2D.js +5 -2
- package/lib/component/2d/IndirectAxis2D.js.map +1 -1
- package/lib/component/2d/Viewer2D.d.ts.map +1 -1
- package/lib/component/2d/Viewer2D.js +2 -1
- package/lib/component/2d/Viewer2D.js.map +1 -1
- package/lib/component/AnchorSVG.d.ts +5 -6
- package/lib/component/AnchorSVG.d.ts.map +1 -1
- package/lib/component/AnchorSVG.js +9 -6
- package/lib/component/AnchorSVG.js.map +1 -1
- package/lib/component/EventsTrackers/BrushTracker.d.ts.map +1 -1
- package/lib/component/EventsTrackers/BrushTracker.js +14 -4
- package/lib/component/EventsTrackers/BrushTracker.js.map +1 -1
- package/lib/component/EventsTrackers/MouseTracker.d.ts +3 -0
- package/lib/component/EventsTrackers/MouseTracker.d.ts.map +1 -1
- package/lib/component/EventsTrackers/MouseTracker.js +15 -0
- package/lib/component/EventsTrackers/MouseTracker.js.map +1 -1
- package/lib/component/context/KeyModifierContext.d.ts +1 -0
- package/lib/component/context/KeyModifierContext.d.ts.map +1 -1
- package/lib/component/context/KeyModifierContext.js +22 -6
- package/lib/component/context/KeyModifierContext.js.map +1 -1
- package/lib/component/elements/D3Axis.d.ts.map +1 -1
- package/lib/component/elements/D3Axis.js +4 -3
- package/lib/component/elements/D3Axis.js.map +1 -1
- package/lib/component/header/AutoPeakPickingOptionPanel.d.ts.map +1 -1
- package/lib/component/header/AutoPeakPickingOptionPanel.js +59 -31
- package/lib/component/header/AutoPeakPickingOptionPanel.js.map +1 -1
- package/lib/component/header/RangesPickingOptionPanel.d.ts.map +1 -1
- package/lib/component/header/RangesPickingOptionPanel.js +34 -19
- package/lib/component/header/RangesPickingOptionPanel.js.map +1 -1
- package/lib/component/hooks/useAddMultipletSignal.d.ts +7 -0
- package/lib/component/hooks/useAddMultipletSignal.d.ts.map +1 -0
- package/lib/component/hooks/useAddMultipletSignal.js +28 -0
- package/lib/component/hooks/useAddMultipletSignal.js.map +1 -0
- package/lib/component/hooks/useFilter.d.ts.map +1 -1
- package/lib/component/hooks/useFilter.js.map +1 -1
- package/lib/component/hooks/useSpectrum.d.ts +3 -1
- package/lib/component/hooks/useSpectrum.d.ts.map +1 -1
- package/lib/component/hooks/useSpectrum.js +1 -1
- package/lib/component/hooks/useSpectrum.js.map +1 -1
- package/lib/component/hooks/useSpectrumWithDataSource.d.ts +1 -1
- package/lib/component/hooks/useSpectrumWithDataSource.d.ts.map +1 -1
- package/lib/component/hooks/useSpectrumWithDataSource.js.map +1 -1
- package/lib/component/hooks/useTempSpectrum.d.ts +1 -1
- package/lib/component/hooks/useTempSpectrum.d.ts.map +1 -1
- package/lib/component/hooks/use_ticks_config.d.ts +1 -4
- package/lib/component/hooks/use_ticks_config.d.ts.map +1 -1
- package/lib/component/hooks/use_ticks_config.js +1 -6
- package/lib/component/hooks/use_ticks_config.js.map +1 -1
- package/lib/component/modal/PublicationStringModal.d.ts +1 -1
- package/lib/component/modal/PublicationStringModal.d.ts.map +1 -1
- package/lib/component/modal/PublicationStringModal.js +2 -2
- package/lib/component/modal/PublicationStringModal.js.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/errors/context.d.ts +118 -0
- package/lib/component/modal/setting/tanstack_general_settings/errors/context.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/errors/renderer.d.ts +118 -0
- package/lib/component/modal/setting/tanstack_general_settings/errors/renderer.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_body.d.ts +118 -0
- package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_body.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_footer.d.ts +96 -0
- package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_footer.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_header.d.ts +96 -0
- package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_header.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/hooks/use_safe_workspace.d.ts +16 -0
- package/lib/component/modal/setting/tanstack_general_settings/hooks/use_safe_workspace.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/auto_processing_tab.d.ts +96 -0
- package/lib/component/modal/setting/tanstack_general_settings/tabs/auto_processing_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/axis_tab.d.ts +96 -0
- package/lib/component/modal/setting/tanstack_general_settings/tabs/axis_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/axis_tab.js +12 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/axis_tab.js.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/database_tab.d.ts +96 -0
- package/lib/component/modal/setting/tanstack_general_settings/tabs/database_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/export_tab.d.ts +96 -0
- package/lib/component/modal/setting/tanstack_general_settings/tabs/export_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/external_api_tab.d.ts +96 -0
- package/lib/component/modal/setting/tanstack_general_settings/tabs/external_api_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/general_tab.d.ts +96 -0
- package/lib/component/modal/setting/tanstack_general_settings/tabs/general_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/import_filters_tab.d.ts +96 -0
- package/lib/component/modal/setting/tanstack_general_settings/tabs/import_filters_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/nuclei_tab.d.ts +96 -0
- package/lib/component/modal/setting/tanstack_general_settings/tabs/nuclei_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/panels_tab.d.ts +96 -0
- package/lib/component/modal/setting/tanstack_general_settings/tabs/panels_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/spectra_colors_tab.d.ts +96 -0
- package/lib/component/modal/setting/tanstack_general_settings/tabs/spectra_colors_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/spectra_label_tab.d.ts +96 -0
- package/lib/component/modal/setting/tanstack_general_settings/tabs/spectra_label_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/title_block_tab.d.ts +96 -0
- package/lib/component/modal/setting/tanstack_general_settings/tabs/title_block_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/tabs/tools_tab.d.ts +96 -0
- package/lib/component/modal/setting/tanstack_general_settings/tabs/tools_tab.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/validation/axis_tab_validation.d.ts +22 -0
- package/lib/component/modal/setting/tanstack_general_settings/validation/axis_tab_validation.d.ts.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/validation/axis_tab_validation.js +15 -2
- package/lib/component/modal/setting/tanstack_general_settings/validation/axis_tab_validation.js.map +1 -1
- package/lib/component/modal/setting/tanstack_general_settings/validation.d.ts +22 -0
- package/lib/component/modal/setting/tanstack_general_settings/validation.d.ts.map +1 -1
- package/lib/component/panels/MoleculesPanel/hooks/useAtomAssignment.js +1 -1
- package/lib/component/panels/MoleculesPanel/hooks/useAtomAssignment.js.map +1 -1
- package/lib/component/panels/RangesPanel/RangesPanel.d.ts.map +1 -1
- package/lib/component/panels/RangesPanel/RangesPanel.js +1 -3
- package/lib/component/panels/RangesPanel/RangesPanel.js.map +1 -1
- package/lib/component/panels/RangesPanel/RangesTableRow.d.ts.map +1 -1
- package/lib/component/panels/RangesPanel/RangesTableRow.js +10 -12
- package/lib/component/panels/RangesPanel/RangesTableRow.js.map +1 -1
- package/lib/component/panels/RangesPanel/TableColumns/SignalAssignmentsColumn.d.ts +1 -1
- package/lib/component/panels/RangesPanel/TableColumns/SignalAssignmentsColumn.d.ts.map +1 -1
- package/lib/component/panels/RangesPanel/TableColumns/SignalAssignmentsColumn.js +1 -1
- package/lib/component/panels/RangesPanel/TableColumns/SignalAssignmentsColumn.js.map +1 -1
- package/lib/component/panels/filtersPanel/processings_sections_panel.d.ts.map +1 -1
- package/lib/component/panels/filtersPanel/processings_sections_panel.js +13 -23
- package/lib/component/panels/filtersPanel/processings_sections_panel.js.map +1 -1
- package/lib/component/panels/hooks/use_processings_mutation.d.ts +10 -0
- package/lib/component/panels/hooks/use_processings_mutation.d.ts.map +1 -0
- package/lib/component/panels/hooks/use_processings_mutation.js +130 -0
- package/lib/component/panels/hooks/use_processings_mutation.js.map +1 -0
- package/lib/component/panels/informationPanel/InformationPanel.js +1 -1
- package/lib/component/panels/informationPanel/InformationPanel.js.map +1 -1
- package/lib/component/reducer/Reducer.d.ts.map +1 -1
- package/lib/component/reducer/Reducer.js +2 -0
- package/lib/component/reducer/Reducer.js.map +1 -1
- package/lib/component/reducer/actions/CorrelationsActions.js +1 -1
- package/lib/component/reducer/actions/CorrelationsActions.js.map +1 -1
- package/lib/component/reducer/actions/FiltersActions.d.ts +2 -0
- package/lib/component/reducer/actions/FiltersActions.d.ts.map +1 -1
- package/lib/component/reducer/actions/FiltersActions.js +1 -1
- package/lib/component/reducer/actions/FiltersActions.js.map +1 -1
- package/lib/component/reducer/actions/RangesActions.d.ts.map +1 -1
- package/lib/component/reducer/actions/RangesActions.js +13 -24
- package/lib/component/reducer/actions/RangesActions.js.map +1 -1
- package/lib/component/reducer/actions/SpectraActions.d.ts +8 -2
- package/lib/component/reducer/actions/SpectraActions.d.ts.map +1 -1
- package/lib/component/reducer/actions/SpectraActions.js +6 -1
- package/lib/component/reducer/actions/SpectraActions.js.map +1 -1
- package/lib/component/reducer/preferences/actions/setPreferences.d.ts +2 -2
- package/lib/component/reducer/preferences/actions/setPreferences.d.ts.map +1 -1
- package/lib/component/reducer/preferences/actions/setPreferences.js +8 -5
- package/lib/component/reducer/preferences/actions/setPreferences.js.map +1 -1
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +1 -1
- package/lib/component/reducer/preferences/preferencesReducer.d.ts.map +1 -1
- package/lib/component/toolbar/ToolTypes.d.ts +21 -1
- package/lib/component/toolbar/ToolTypes.d.ts.map +1 -1
- package/lib/component/toolbar/ToolTypes.js +40 -0
- package/lib/component/toolbar/ToolTypes.js.map +1 -1
- package/lib/component/toolbar/nmr_toolbar.d.ts.map +1 -1
- package/lib/component/toolbar/nmr_toolbar.js +9 -35
- package/lib/component/toolbar/nmr_toolbar.js.map +1 -1
- package/lib/component/workspaces/workspaceDefaultProperties.d.ts.map +1 -1
- package/lib/component/workspaces/workspaceDefaultProperties.js +19 -2
- package/lib/component/workspaces/workspaceDefaultProperties.js.map +1 -1
- package/lib/data/data1d/Spectrum1D/initiateDatum1D.d.ts.map +1 -1
- package/lib/data/data1d/Spectrum1D/initiateDatum1D.js +13 -5
- package/lib/data/data1d/Spectrum1D/initiateDatum1D.js.map +1 -1
- package/lib/data/data2d/Spectrum2D/initiateDatum2D.d.ts.map +1 -1
- package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +12 -4
- package/lib/data/data2d/Spectrum2D/initiateDatum2D.js.map +1 -1
- package/lib/data/data2d/Spectrum2D/isSpectrum2D.d.ts +1 -1
- package/lib/data/data2d/Spectrum2D/isSpectrum2D.d.ts.map +1 -1
- package/lib/data/data2d/Spectrum2D/isSpectrum2D.js.map +1 -1
- package/lib/data/utilities/RangeUtilities.d.ts +1 -6
- package/lib/data/utilities/RangeUtilities.d.ts.map +1 -1
- package/lib/data/utilities/RangeUtilities.js +10 -27
- package/lib/data/utilities/RangeUtilities.js.map +1 -1
- package/lib/versionInfo.js +1 -1
- package/package.json +15 -14
- package/src/component/1d/HorizontalAxis1D.tsx +12 -2
- package/src/component/1d/SVGContent1D.tsx +2 -0
- package/src/component/1d/Viewer1D.tsx +2 -0
- package/src/component/1d/integral/IntegralResizable.tsx +6 -6
- package/src/component/1d/ranges/Range.tsx +6 -6
- package/src/component/1d/ranges/Signals.tsx +28 -0
- package/src/component/1d-2d/components/RangeIndicator.tsx +106 -0
- package/src/component/1d-2d/components/Signals1D.tsx +306 -0
- package/src/component/1d-2d/tools/CrossLinePointer.tsx +75 -32
- package/src/component/1d-2d/tools/CursorToolIcon.tsx +110 -0
- package/src/component/2d/1d-tracer/Left1DChart.tsx +4 -2
- package/src/component/2d/1d-tracer/Ranges1D.tsx +4 -100
- package/src/component/2d/1d-tracer/Top1DChart.tsx +4 -2
- package/src/component/2d/DirectAxis2D.tsx +12 -3
- package/src/component/2d/IndirectAxis2D.tsx +9 -5
- package/src/component/2d/Viewer2D.tsx +5 -2
- package/src/component/AnchorSVG.tsx +27 -28
- package/src/component/EventsTrackers/BrushTracker.tsx +21 -7
- package/src/component/EventsTrackers/MouseTracker.tsx +21 -0
- package/src/component/context/KeyModifierContext.tsx +27 -8
- package/src/component/elements/D3Axis.tsx +31 -9
- package/src/component/header/AutoPeakPickingOptionPanel.tsx +173 -102
- package/src/component/header/RangesPickingOptionPanel.tsx +72 -59
- package/src/component/hooks/useAddMultipletSignal.tsx +32 -0
- package/src/component/hooks/useFilter.ts +2 -1
- package/src/component/hooks/useSpectrum.ts +7 -1
- package/src/component/hooks/useSpectrumWithDataSource.ts +16 -8
- package/src/component/hooks/use_ticks_config.ts +1 -7
- package/src/component/modal/PublicationStringModal.tsx +3 -3
- package/src/component/modal/setting/tanstack_general_settings/tabs/axis_tab.tsx +76 -12
- package/src/component/modal/setting/tanstack_general_settings/validation/axis_tab_validation.ts +16 -2
- package/src/component/panels/MoleculesPanel/hooks/useAtomAssignment.tsx +1 -1
- package/src/component/panels/RangesPanel/RangesPanel.tsx +1 -3
- package/src/component/panels/RangesPanel/RangesTableRow.tsx +10 -12
- package/src/component/panels/RangesPanel/TableColumns/SignalAssignmentsColumn.tsx +2 -2
- package/src/component/panels/filtersPanel/processings_sections_panel.tsx +27 -44
- package/src/component/panels/hooks/use_processings_mutation.ts +171 -0
- package/src/component/panels/informationPanel/InformationPanel.tsx +1 -1
- package/src/component/reducer/Reducer.ts +2 -0
- package/src/component/reducer/actions/CorrelationsActions.ts +1 -1
- package/src/component/reducer/actions/FiltersActions.ts +1 -1
- package/src/component/reducer/actions/RangesActions.ts +14 -25
- package/src/component/reducer/actions/SpectraActions.ts +20 -1
- package/src/component/reducer/preferences/actions/setPreferences.ts +18 -10
- package/src/component/reducer/preferences/preferencesReducer.ts +1 -1
- package/src/component/toolbar/ToolTypes.ts +92 -1
- package/src/component/toolbar/nmr_toolbar.tsx +12 -69
- package/src/component/workspaces/workspaceDefaultProperties.ts +19 -2
- package/src/data/data1d/Spectrum1D/initiateDatum1D.ts +14 -8
- package/src/data/data2d/Spectrum2D/initiateDatum2D.ts +12 -4
- package/src/data/data2d/Spectrum2D/isSpectrum2D.ts +1 -1
- package/src/data/utilities/RangeUtilities.ts +12 -36
- package/src/versionInfo.ts +1 -1
- package/lib/component/1d/integral/IntegralIndicator.d.ts +0 -9
- package/lib/component/1d/integral/IntegralIndicator.d.ts.map +0 -1
- package/lib/component/1d/integral/IntegralIndicator.js +0 -22
- package/lib/component/1d/integral/IntegralIndicator.js.map +0 -1
- package/lib/component/2d/1d-tracer/Signals1D.d.ts +0 -11
- package/lib/component/2d/1d-tracer/Signals1D.d.ts.map +0 -1
- package/lib/component/2d/1d-tracer/Signals1D.js +0 -90
- package/lib/component/2d/1d-tracer/Signals1D.js.map +0 -1
- package/src/component/1d/integral/IntegralIndicator.tsx +0 -43
- package/src/component/2d/1d-tracer/Signals1D.tsx +0 -145
|
@@ -1,72 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { Jcoupling, Range, Signal1D } from '@zakodium/nmr-types';
|
|
1
|
+
import type { Range } from '@zakodium/nmr-types';
|
|
3
2
|
|
|
4
3
|
import { getOpacityBasedOnSignalKind } from '../../../data/utilities/RangeUtilities.ts';
|
|
5
|
-
import {
|
|
6
|
-
import { useDispatch } from '../../context/DispatchContext.tsx';
|
|
4
|
+
import { RangeIndicator } from '../../1d-2d/components/RangeIndicator.tsx';
|
|
7
5
|
import { useScale2DX, useScale2DY } from '../utilities/scale.js';
|
|
8
6
|
|
|
9
|
-
interface Range1DTraceProps {
|
|
10
|
-
position: number;
|
|
11
|
-
size: number;
|
|
12
|
-
orientation?: 'horizontal' | 'vertical';
|
|
13
|
-
opacity?: number;
|
|
14
|
-
onClick?: (e: React.MouseEvent<SVGGElement, MouseEvent>) => void;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface ElementLayout {
|
|
18
|
-
groupTransform: string;
|
|
19
|
-
pathD: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const Path = styled.path`
|
|
23
|
-
fill: none;
|
|
24
|
-
stroke-width: 1px;
|
|
25
|
-
shape-rendering: crispedges;
|
|
26
|
-
stroke: black;
|
|
27
|
-
|
|
28
|
-
&:hover {
|
|
29
|
-
stroke: red;
|
|
30
|
-
}
|
|
31
|
-
`;
|
|
32
|
-
const length = 5;
|
|
33
|
-
const innerMargin = 10;
|
|
34
|
-
|
|
35
|
-
function Range1DTrace(props: Range1DTraceProps) {
|
|
36
|
-
const {
|
|
37
|
-
position,
|
|
38
|
-
size,
|
|
39
|
-
orientation = 'horizontal',
|
|
40
|
-
opacity = 1,
|
|
41
|
-
onClick,
|
|
42
|
-
} = props;
|
|
43
|
-
const { margin } = useChartData();
|
|
44
|
-
|
|
45
|
-
const layout: ElementLayout =
|
|
46
|
-
orientation === 'vertical'
|
|
47
|
-
? {
|
|
48
|
-
groupTransform: `translate(${margin.left - innerMargin} ${position})`,
|
|
49
|
-
pathD: `M0 0 L${length} 0 L${length} ${size} L0 ${size}`,
|
|
50
|
-
}
|
|
51
|
-
: {
|
|
52
|
-
groupTransform: `translate(${position} ${margin.top - innerMargin})`,
|
|
53
|
-
pathD: `M0 0 L0 ${length} L${size} ${length} L${size} 0`,
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<g transform={layout.groupTransform} style={{ opacity }} onClick={onClick}>
|
|
58
|
-
<rect
|
|
59
|
-
x={orientation === 'vertical' ? -(margin.left - innerMargin) : 0}
|
|
60
|
-
y={orientation === 'vertical' ? 0 : -(margin.top - innerMargin)}
|
|
61
|
-
width={orientation === 'vertical' ? margin.left : size}
|
|
62
|
-
height={orientation === 'vertical' ? size : margin.top}
|
|
63
|
-
fill="transparent"
|
|
64
|
-
/>
|
|
65
|
-
<Path d={layout.pathD} />
|
|
66
|
-
</g>
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
7
|
interface Ranges1DProps {
|
|
71
8
|
ranges: Range[];
|
|
72
9
|
orientation: 'horizontal' | 'vertical';
|
|
@@ -74,10 +11,9 @@ interface Ranges1DProps {
|
|
|
74
11
|
}
|
|
75
12
|
|
|
76
13
|
export function Ranges1D(props: Ranges1DProps) {
|
|
77
|
-
const { ranges, orientation
|
|
14
|
+
const { ranges, orientation } = props;
|
|
78
15
|
const scaleX = useScale2DX();
|
|
79
16
|
const scaleY = useScale2DY();
|
|
80
|
-
const dispatch = useDispatch();
|
|
81
17
|
const scale = orientation === 'horizontal' ? scaleX : scaleY;
|
|
82
18
|
|
|
83
19
|
return ranges.map((range) => {
|
|
@@ -89,44 +25,12 @@ export function Ranges1D(props: Ranges1DProps) {
|
|
|
89
25
|
const start = Math.min(fromInPixel, toInPixel);
|
|
90
26
|
const size = Math.abs(fromInPixel - toInPixel);
|
|
91
27
|
|
|
92
|
-
function handleAddSignal(e: React.MouseEvent<SVGGElement, MouseEvent>) {
|
|
93
|
-
const boundingRect = e.currentTarget.getBoundingClientRect();
|
|
94
|
-
const x = e.clientX - boundingRect.left + start;
|
|
95
|
-
const y = e.clientY - boundingRect.top + start;
|
|
96
|
-
|
|
97
|
-
const valueInPixel = orientation === 'horizontal' ? x : y;
|
|
98
|
-
const delta = scale.invert(valueInPixel);
|
|
99
|
-
|
|
100
|
-
const updatedRange = structuredClone(range);
|
|
101
|
-
const signal: Signal1D = {
|
|
102
|
-
id: crypto.randomUUID(),
|
|
103
|
-
delta,
|
|
104
|
-
js: [
|
|
105
|
-
{
|
|
106
|
-
multiplicity: 'm',
|
|
107
|
-
} as Jcoupling,
|
|
108
|
-
],
|
|
109
|
-
kind: 'signal',
|
|
110
|
-
multiplicity: 'm',
|
|
111
|
-
};
|
|
112
|
-
updatedRange.signals.push(signal);
|
|
113
|
-
|
|
114
|
-
dispatch({
|
|
115
|
-
type: 'UPDATE_RANGE',
|
|
116
|
-
payload: {
|
|
117
|
-
range: updatedRange,
|
|
118
|
-
spectrumId,
|
|
119
|
-
},
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
28
|
return (
|
|
124
|
-
<
|
|
29
|
+
<RangeIndicator
|
|
125
30
|
orientation={orientation}
|
|
126
31
|
key={id}
|
|
127
32
|
position={start}
|
|
128
33
|
size={size}
|
|
129
|
-
onClick={handleAddSignal}
|
|
130
34
|
opacity={opacity}
|
|
131
35
|
/>
|
|
132
36
|
);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Spectrum1D } from '@zakodium/nmrium-core';
|
|
2
2
|
import { memo, useRef } from 'react';
|
|
3
3
|
|
|
4
|
+
import { Signals1D } from '../../1d-2d/components/Signals1D.tsx';
|
|
4
5
|
import { useChartData } from '../../context/ChartContext.js';
|
|
5
6
|
import useXYReduce from '../../hooks/useXYReduce.js';
|
|
6
7
|
import { PathBuilder } from '../../utility/PathBuilder.js';
|
|
7
8
|
import { use1DTraceYScale, useScale2DX } from '../utilities/scale.js';
|
|
8
9
|
|
|
9
10
|
import { Ranges1D } from './Ranges1D.tsx';
|
|
10
|
-
import { Signals1D } from './Signals1D.tsx';
|
|
11
11
|
|
|
12
12
|
interface Top1DChartProps {
|
|
13
13
|
verticalMargin?: number;
|
|
@@ -41,6 +41,7 @@ function Top1DChart({ verticalMargin = 10, data: spectrum }: Top1DChartProps) {
|
|
|
41
41
|
const { width, margin, displayerKey } = useChartData();
|
|
42
42
|
const height = margin.top;
|
|
43
43
|
const svgRef = useRef<SVGSVGElement>(null);
|
|
44
|
+
const scale = useScale2DX();
|
|
44
45
|
|
|
45
46
|
const path = usePath(spectrum, { height, verticalMargin });
|
|
46
47
|
const ranges = spectrum.ranges.values;
|
|
@@ -83,9 +84,10 @@ function Top1DChart({ verticalMargin = 10, data: spectrum }: Top1DChartProps) {
|
|
|
83
84
|
/>
|
|
84
85
|
<Signals1D
|
|
85
86
|
ranges={ranges}
|
|
86
|
-
svgRef={svgRef}
|
|
87
87
|
orientation="horizontal"
|
|
88
88
|
spectrumId={spectrum.id}
|
|
89
|
+
scale={scale}
|
|
90
|
+
position={margin.top}
|
|
89
91
|
/>
|
|
90
92
|
</g>
|
|
91
93
|
</svg>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { memo, useRef } from 'react';
|
|
2
2
|
import { useLinearPrimaryTicks } from 'react-d3-utils';
|
|
3
|
+
import { SVGStyledText } from 'react-science/ui';
|
|
3
4
|
|
|
4
5
|
import { useIsInset } from '../1d/inset/InsetProvider.tsx';
|
|
5
6
|
import { AxisUnitPicker } from '../1d-2d/components/axis_unit_picker.tsx';
|
|
@@ -8,6 +9,7 @@ import { D3Axis } from '../elements/D3Axis.js';
|
|
|
8
9
|
import { useCheckExportStatus } from '../hooks/useViewportSize.tsx';
|
|
9
10
|
import { axisUnitToLabel, useDirectAxisUnit } from '../hooks/use_axis_unit.ts';
|
|
10
11
|
import { useGridline2DConfig } from '../hooks/use_gridlines_config.ts';
|
|
12
|
+
import { useTicksConfig } from '../hooks/use_ticks_config.ts';
|
|
11
13
|
|
|
12
14
|
import { useScale2DX } from './utilities/scale.js';
|
|
13
15
|
|
|
@@ -93,11 +95,18 @@ interface UnitLabelProps {
|
|
|
93
95
|
}
|
|
94
96
|
function UnitLabel(props: UnitLabelProps) {
|
|
95
97
|
const { width, children } = props;
|
|
96
|
-
|
|
98
|
+
const { labelStyle } = useTicksConfig();
|
|
97
99
|
return (
|
|
98
|
-
<
|
|
100
|
+
<SVGStyledText
|
|
101
|
+
fill="black"
|
|
102
|
+
x={width - 60}
|
|
103
|
+
y="20"
|
|
104
|
+
dy="0.71em"
|
|
105
|
+
textAnchor="end"
|
|
106
|
+
{...labelStyle}
|
|
107
|
+
>
|
|
99
108
|
{children}
|
|
100
|
-
</
|
|
109
|
+
</SVGStyledText>
|
|
101
110
|
);
|
|
102
111
|
}
|
|
103
112
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { memo, useRef } from 'react';
|
|
2
2
|
import { useLinearPrimaryTicks } from 'react-d3-utils';
|
|
3
|
+
import { SVGStyledText } from 'react-science/ui';
|
|
3
4
|
|
|
4
5
|
import { useIsInset } from '../1d/inset/InsetProvider.tsx';
|
|
5
6
|
import { AxisUnitPicker } from '../1d-2d/components/axis_unit_picker.tsx';
|
|
@@ -13,6 +14,7 @@ import {
|
|
|
13
14
|
useIndirectAxisUnit,
|
|
14
15
|
} from '../hooks/use_axis_unit.ts';
|
|
15
16
|
import { useGridline2DConfig } from '../hooks/use_gridlines_config.ts';
|
|
17
|
+
import { useTicksConfig } from '../hooks/use_ticks_config.ts';
|
|
16
18
|
|
|
17
19
|
import { useScale2DY } from './utilities/scale.js';
|
|
18
20
|
|
|
@@ -108,8 +110,8 @@ interface UnitLabelProps {
|
|
|
108
110
|
}
|
|
109
111
|
function UnitLabel(props: UnitLabelProps) {
|
|
110
112
|
const { children } = props;
|
|
111
|
-
|
|
112
|
-
const { getTextWidth } = useTextMetrics({ labelSize:
|
|
113
|
+
const { labelStyle } = useTicksConfig();
|
|
114
|
+
const { getTextWidth } = useTextMetrics({ labelSize: labelStyle.fontSize });
|
|
113
115
|
const labelHeight = getTextWidth(children);
|
|
114
116
|
|
|
115
117
|
return (
|
|
@@ -124,14 +126,16 @@ function UnitLabel(props: UnitLabelProps) {
|
|
|
124
126
|
y={-5}
|
|
125
127
|
opacity={0.8}
|
|
126
128
|
/>
|
|
127
|
-
|
|
128
|
-
|
|
129
|
+
|
|
130
|
+
<SVGStyledText
|
|
131
|
+
fill="black"
|
|
129
132
|
transform="rotate(-90)"
|
|
130
133
|
dominantBaseline="middle"
|
|
131
134
|
textAnchor="end"
|
|
135
|
+
{...labelStyle}
|
|
132
136
|
>
|
|
133
137
|
{children}
|
|
134
|
-
</
|
|
138
|
+
</SVGStyledText>
|
|
135
139
|
</>
|
|
136
140
|
);
|
|
137
141
|
}
|
|
@@ -5,6 +5,7 @@ import { SVGRootContainer } from '../1d-2d/components/SVGRootContainer.js';
|
|
|
5
5
|
import { ViewerResponsiveWrapper } from '../1d-2d/components/ViewerResponsiveWrapper.js';
|
|
6
6
|
import BrushXY from '../1d-2d/tools/BrushXY.js';
|
|
7
7
|
import CrossLinePointer from '../1d-2d/tools/CrossLinePointer.js';
|
|
8
|
+
import { CursorToolIcon } from '../1d-2d/tools/CursorToolIcon.tsx';
|
|
8
9
|
import { MouseTracker } from '../EventsTrackers/MouseTracker.js';
|
|
9
10
|
import { useChartData } from '../context/ChartContext.js';
|
|
10
11
|
import Spinner from '../loader/Spinner.js';
|
|
@@ -60,8 +61,10 @@ function Viewer2D(props: Viewer2DProps) {
|
|
|
60
61
|
selectedTool === options.phaseCorrectionTwoDimensions.id && (
|
|
61
62
|
<PhaseTraces />
|
|
62
63
|
)}
|
|
63
|
-
|
|
64
|
-
<CrossLinePointer />
|
|
64
|
+
<CursorToolIcon />
|
|
65
|
+
<CrossLinePointer axis="X" dimensionBorder={DIMENSION.TOP} />
|
|
66
|
+
<CrossLinePointer axis="Y" dimensionBorder={DIMENSION.LEFT} />
|
|
67
|
+
<CrossLinePointer axis="XY" dimensionBorder={DIMENSION.MAIN} />
|
|
65
68
|
<XYLabelPointer data1D={spectrumData} layout={DIMENSION} />
|
|
66
69
|
|
|
67
70
|
<>
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
CSSProperties,
|
|
3
|
-
KeyboardEvent,
|
|
4
|
-
MouseEvent,
|
|
5
|
-
RefObject,
|
|
6
|
-
} from 'react';
|
|
1
|
+
import type { CSSProperties, KeyboardEvent, MouseEvent } from 'react';
|
|
7
2
|
import { useRef, useState } from 'react';
|
|
8
3
|
|
|
9
4
|
type CursorOrientation = 'horizontal' | 'vertical';
|
|
@@ -36,13 +31,13 @@ interface AnchorPosition {
|
|
|
36
31
|
interface AnchorProps {
|
|
37
32
|
position: AnchorPosition;
|
|
38
33
|
shape?: AnchorShape;
|
|
39
|
-
svgRef: RefObject<SVGSVGElement>;
|
|
40
34
|
svgHeight: number;
|
|
41
35
|
anchorStyle?: AnchorStyle;
|
|
42
36
|
restoreFocusOnLeave?: boolean;
|
|
43
|
-
onDragMove
|
|
44
|
-
onDragEnd
|
|
45
|
-
|
|
37
|
+
onDragMove?: (newPosition: AnchorPosition) => void;
|
|
38
|
+
onDragEnd?: (lastPosition: AnchorPosition) => void;
|
|
39
|
+
onDragStart?: (position: AnchorPosition) => void;
|
|
40
|
+
onDelete?: () => void;
|
|
46
41
|
cursorOrientation?: CursorOrientation;
|
|
47
42
|
}
|
|
48
43
|
|
|
@@ -201,18 +196,19 @@ function ShapeRenderer({
|
|
|
201
196
|
);
|
|
202
197
|
}
|
|
203
198
|
|
|
204
|
-
export function Anchor({
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
199
|
+
export function Anchor(props: AnchorProps) {
|
|
200
|
+
const {
|
|
201
|
+
position,
|
|
202
|
+
shape,
|
|
203
|
+
svgHeight,
|
|
204
|
+
anchorStyle = {},
|
|
205
|
+
restoreFocusOnLeave = false,
|
|
206
|
+
onDragStart,
|
|
207
|
+
onDragMove,
|
|
208
|
+
onDragEnd,
|
|
209
|
+
onDelete,
|
|
210
|
+
cursorOrientation = 'horizontal',
|
|
211
|
+
} = props;
|
|
216
212
|
const {
|
|
217
213
|
size = 16,
|
|
218
214
|
hoverSize = size,
|
|
@@ -255,31 +251,34 @@ export function Anchor({
|
|
|
255
251
|
function handleMouseDown(e: MouseEvent<SVGGElement>) {
|
|
256
252
|
e.preventDefault();
|
|
257
253
|
setDragging(true);
|
|
258
|
-
|
|
254
|
+
|
|
255
|
+
const svg = e.currentTarget.ownerSVGElement;
|
|
256
|
+
|
|
257
|
+
const { x, y } = clientToSvg(e, svg);
|
|
259
258
|
dragState.current = {
|
|
260
259
|
startX: x,
|
|
261
260
|
startY: y,
|
|
262
261
|
startAnchorX: position.x,
|
|
263
262
|
startAnchorY: position.y,
|
|
264
263
|
};
|
|
265
|
-
|
|
264
|
+
onDragStart?.(position);
|
|
266
265
|
const onMove = (e: globalThis.MouseEvent) => {
|
|
267
266
|
const current = dragState.current;
|
|
268
267
|
if (!current) return;
|
|
269
268
|
const { x, y } = clientToSvg(
|
|
270
269
|
e as unknown as MouseEvent<SVGGElement>,
|
|
271
|
-
|
|
270
|
+
svg,
|
|
272
271
|
);
|
|
273
272
|
const newX = current.startAnchorX + x - current.startX;
|
|
274
273
|
const newY = current.startAnchorY + y - current.startY;
|
|
275
274
|
|
|
276
|
-
onDragMove({ x: newX, y: newY });
|
|
275
|
+
onDragMove?.({ x: newX, y: newY });
|
|
277
276
|
};
|
|
278
277
|
|
|
279
278
|
const onUp = () => {
|
|
280
279
|
setDragging(false);
|
|
281
280
|
dragState.current = null;
|
|
282
|
-
onDragEnd({ x: position.x, y: position.y });
|
|
281
|
+
onDragEnd?.({ x: position.x, y: position.y });
|
|
283
282
|
|
|
284
283
|
window.removeEventListener('mousemove', onMove);
|
|
285
284
|
window.removeEventListener('mouseup', onUp);
|
|
@@ -292,7 +291,7 @@ export function Anchor({
|
|
|
292
291
|
function handleKeyDown(e: KeyboardEvent<SVGGElement>) {
|
|
293
292
|
if (e.key === 'Delete' || e.key === 'Backspace') {
|
|
294
293
|
e.preventDefault();
|
|
295
|
-
onDelete();
|
|
294
|
+
onDelete?.();
|
|
296
295
|
}
|
|
297
296
|
}
|
|
298
297
|
|
|
@@ -134,7 +134,9 @@ interface BrushTrackerProps {
|
|
|
134
134
|
brushDetectionOptions?: BaseDetectBrushingOptions;
|
|
135
135
|
clickTriggerMode?: 'native' | 'debounced';
|
|
136
136
|
}
|
|
137
|
-
|
|
137
|
+
function isSelfControlledTarget(target: EventTarget) {
|
|
138
|
+
return (target as Element).closest('[data-self-control="true"]') !== null;
|
|
139
|
+
}
|
|
138
140
|
function getMouseXY(event: MouseEvent, currentTarget?: Element) {
|
|
139
141
|
const boundingRect = (
|
|
140
142
|
currentTarget ?? event.currentTarget
|
|
@@ -169,6 +171,7 @@ export function BrushTracker(options: BrushTrackerProps) {
|
|
|
169
171
|
const boundingRectRef = useRef<DOMRect | null>(null);
|
|
170
172
|
const startPositionRef = useRef<Position>({ x: 0, y: 0 });
|
|
171
173
|
const lastRef = useRef<Position>({ x: 0, y: 0 });
|
|
174
|
+
const isSelfControlledRef = useRef(false);
|
|
172
175
|
|
|
173
176
|
const handleClickWithDebounce = useCallback(
|
|
174
177
|
(event: MouseEvent, currentTarget: Element) => {
|
|
@@ -199,25 +202,36 @@ export function BrushTracker(options: BrushTrackerProps) {
|
|
|
199
202
|
);
|
|
200
203
|
|
|
201
204
|
function handleClick(event: MouseEvent) {
|
|
202
|
-
if (
|
|
205
|
+
if (
|
|
206
|
+
isDraggingRef.current ||
|
|
207
|
+
clickTriggerMode !== 'native' ||
|
|
208
|
+
isSelfControlledRef.current
|
|
209
|
+
) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
203
213
|
const { x, y } = getMouseXY(event);
|
|
204
214
|
onClick({ ...event, x, y });
|
|
205
215
|
}
|
|
206
216
|
|
|
207
217
|
function handleDoubleClick(event: MouseEvent) {
|
|
208
|
-
if (
|
|
209
|
-
|
|
218
|
+
if (
|
|
219
|
+
isDraggingRef.current ||
|
|
220
|
+
clickTriggerMode !== 'native' ||
|
|
221
|
+
isSelfControlledRef.current
|
|
222
|
+
) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
210
225
|
const { x, y } = getMouseXY(event);
|
|
211
226
|
onDoubleClick({ ...event, x, y });
|
|
212
227
|
}
|
|
213
|
-
|
|
214
228
|
const pointerDownHandler = useCallback(
|
|
215
229
|
(event: PointerEvent) => {
|
|
216
230
|
event.persist();
|
|
217
231
|
const currentTarget = event.currentTarget;
|
|
232
|
+
isSelfControlledRef.current = isSelfControlledTarget(event.target);
|
|
218
233
|
|
|
219
|
-
|
|
220
|
-
if (target.closest('[data-self-control="true"]')) {
|
|
234
|
+
if (isSelfControlledRef.current) {
|
|
221
235
|
return;
|
|
222
236
|
}
|
|
223
237
|
|
|
@@ -23,12 +23,33 @@ interface MouseTrackerProps {
|
|
|
23
23
|
noPropagation?: boolean;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
const disableMouseAttribute = 'data-disable-mouse-tracking' as const;
|
|
27
|
+
|
|
28
|
+
function isMouseTrackingDisabled(target: EventTarget) {
|
|
29
|
+
return (
|
|
30
|
+
(target as Element).closest(`[${CSS.escape(disableMouseAttribute)}]`) !==
|
|
31
|
+
null
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const disableMouseTrackingProps = {
|
|
36
|
+
[disableMouseAttribute]: true,
|
|
37
|
+
} as const;
|
|
38
|
+
|
|
26
39
|
export function MouseTracker(props: MouseTrackerProps) {
|
|
27
40
|
const { children, className, style, noPropagation } = props;
|
|
28
41
|
const [mouseTrackerState, setMouseTrackerState] =
|
|
29
42
|
useState<MouseTrackerData | null>(null);
|
|
30
43
|
const mouseMoveHandler = useCallback(
|
|
31
44
|
(event: MouseEvent) => {
|
|
45
|
+
if (isMouseTrackingDisabled(event.target)) {
|
|
46
|
+
setMouseTrackerState(null);
|
|
47
|
+
if (noPropagation) {
|
|
48
|
+
event.stopPropagation();
|
|
49
|
+
}
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
32
53
|
const boundingRect = event.currentTarget.getBoundingClientRect();
|
|
33
54
|
const x = event.clientX - boundingRect.x;
|
|
34
55
|
const y = event.clientY - boundingRect.y;
|
|
@@ -22,6 +22,7 @@ interface KeyModifiers {
|
|
|
22
22
|
}
|
|
23
23
|
interface KeyModifiersState extends KeyModifiers {
|
|
24
24
|
modifiersKey: ModifiersKey | null;
|
|
25
|
+
isPrimary: boolean;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
const defaultKeyModifiersState: KeyModifiersState = {
|
|
@@ -29,6 +30,7 @@ const defaultKeyModifiersState: KeyModifiersState = {
|
|
|
29
30
|
shiftKey: false,
|
|
30
31
|
altKey: false,
|
|
31
32
|
modifiersKey: null,
|
|
33
|
+
isPrimary: false,
|
|
32
34
|
};
|
|
33
35
|
|
|
34
36
|
const KeyModifierContext = createContext<KeyModifiersState>(
|
|
@@ -96,27 +98,35 @@ export function useMapKeyModifiers() {
|
|
|
96
98
|
}, [invert]);
|
|
97
99
|
}
|
|
98
100
|
|
|
101
|
+
function isPrimaryActive(shiftKey: boolean, invert: boolean): boolean {
|
|
102
|
+
const primaryKey = getPrimaryKey(invert);
|
|
103
|
+
const shiftOnlyKey = toModifiersKey({
|
|
104
|
+
shiftKey,
|
|
105
|
+
ctrlKey: false,
|
|
106
|
+
altKey: false,
|
|
107
|
+
});
|
|
108
|
+
return shiftOnlyKey === primaryKey;
|
|
109
|
+
}
|
|
110
|
+
|
|
99
111
|
export function KeyModifiersProvider({ children }: KeyModifierProviderProps) {
|
|
100
|
-
const [modifiers, setModifiers] = useState<KeyModifiersState>(
|
|
101
|
-
defaultKeyModifiersState,
|
|
102
|
-
);
|
|
103
112
|
const {
|
|
104
113
|
current: {
|
|
105
114
|
general: { invert },
|
|
106
115
|
},
|
|
107
116
|
} = usePreferences();
|
|
117
|
+
const [modifiers, setModifiers] = useState<KeyModifiers>(
|
|
118
|
+
defaultKeyModifiersState,
|
|
119
|
+
);
|
|
108
120
|
|
|
109
121
|
useEffect(() => {
|
|
110
122
|
function handleKeyDown(event: KeyboardEvent) {
|
|
111
123
|
const keyModifiers = getModifiers(event);
|
|
112
|
-
|
|
113
|
-
setModifiers({ ...keyModifiers, modifiersKey });
|
|
124
|
+
setModifiers(keyModifiers);
|
|
114
125
|
}
|
|
115
126
|
|
|
116
127
|
function handleKeyUp(event: KeyboardEvent) {
|
|
117
128
|
const keyModifiers = getModifiers(event);
|
|
118
|
-
|
|
119
|
-
setModifiers({ ...keyModifiers, modifiersKey });
|
|
129
|
+
setModifiers(keyModifiers);
|
|
120
130
|
}
|
|
121
131
|
|
|
122
132
|
document.addEventListener('keydown', handleKeyDown);
|
|
@@ -128,8 +138,17 @@ export function KeyModifiersProvider({ children }: KeyModifierProviderProps) {
|
|
|
128
138
|
};
|
|
129
139
|
}, [invert]);
|
|
130
140
|
|
|
141
|
+
const state = useMemo(() => {
|
|
142
|
+
const modifiersKey = toModifiersKey(modifiers);
|
|
143
|
+
return {
|
|
144
|
+
...modifiers,
|
|
145
|
+
isPrimary: isPrimaryActive(modifiers.shiftKey, invert),
|
|
146
|
+
modifiersKey,
|
|
147
|
+
};
|
|
148
|
+
}, [invert, modifiers]);
|
|
149
|
+
|
|
131
150
|
return (
|
|
132
|
-
<KeyModifierContext.Provider value={
|
|
151
|
+
<KeyModifierContext.Provider value={state}>
|
|
133
152
|
{children}
|
|
134
153
|
</KeyModifierContext.Provider>
|
|
135
154
|
);
|
|
@@ -51,6 +51,8 @@ function isVerticalAxis(axisPosition: AxisPosition) {
|
|
|
51
51
|
|
|
52
52
|
function BaseLine(props: BaseLineProps) {
|
|
53
53
|
const { axisPosition, tickLength = 6, scale } = props;
|
|
54
|
+
const { primaryTicks } = useTicksConfig();
|
|
55
|
+
|
|
54
56
|
const [x1, x2] = scale.range();
|
|
55
57
|
const sign = ['left', 'top'].includes(axisPosition) ? -1 : 1;
|
|
56
58
|
|
|
@@ -60,12 +62,20 @@ function BaseLine(props: BaseLineProps) {
|
|
|
60
62
|
path = `M${sign * tickLength},${x2} H0 V${x1} H${sign * tickLength}`;
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
return
|
|
65
|
+
return (
|
|
66
|
+
<path
|
|
67
|
+
d={path}
|
|
68
|
+
stroke="black"
|
|
69
|
+
fill="none"
|
|
70
|
+
className="domain"
|
|
71
|
+
{...primaryTicks.tickStyle}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
64
74
|
}
|
|
65
75
|
|
|
66
76
|
function Tickets(props: TicketsProps) {
|
|
67
77
|
const { ticks, tickLength = 6, axisPosition } = props;
|
|
68
|
-
const
|
|
78
|
+
const { primaryTicks, secondaryTicks } = useTicksConfig();
|
|
69
79
|
|
|
70
80
|
if (!Array.isArray(ticks) || ticks.length === 0) return null;
|
|
71
81
|
|
|
@@ -127,19 +137,31 @@ function Tickets(props: TicketsProps) {
|
|
|
127
137
|
transform={`translate(${isVertical ? `0,${position}` : `${position},0`})`}
|
|
128
138
|
className="tick"
|
|
129
139
|
>
|
|
130
|
-
{
|
|
131
|
-
<line
|
|
140
|
+
{secondaryTicks.enabled && isFirst && (
|
|
141
|
+
<line
|
|
142
|
+
{...positionSecondaryFirstLineConfig}
|
|
143
|
+
stroke="black"
|
|
144
|
+
{...secondaryTicks.tickStyle}
|
|
145
|
+
/>
|
|
132
146
|
)}
|
|
133
147
|
|
|
134
|
-
<line
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
148
|
+
<line
|
|
149
|
+
{...positionPrimaryLineConfig}
|
|
150
|
+
stroke="black"
|
|
151
|
+
{...primaryTicks.tickStyle}
|
|
152
|
+
/>
|
|
153
|
+
|
|
154
|
+
{secondaryTicks.enabled && (
|
|
155
|
+
<line
|
|
156
|
+
{...positionSecondaryLineConfig}
|
|
157
|
+
stroke="black"
|
|
158
|
+
{...secondaryTicks.tickStyle}
|
|
159
|
+
/>
|
|
138
160
|
)}
|
|
139
161
|
|
|
140
162
|
<SVGStyledText
|
|
141
163
|
fill="black"
|
|
142
|
-
{...
|
|
164
|
+
{...primaryTicks.textStyle}
|
|
143
165
|
{...positionTextConfig}
|
|
144
166
|
>
|
|
145
167
|
{label}
|