nmrium 0.40.1 → 0.42.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/FooterBanner.js +5 -4
- package/lib/component/1d/Viewer1D.js +121 -104
- package/lib/component/1d/database/ResurrectedDatabaseRanges.js +1 -1
- package/lib/component/1d/jCouplingGraph/JGraphContext.d.ts +1 -1
- package/lib/component/1d/jCouplingGraph/JsCouplingLinks.js +1 -1
- package/lib/component/1d/multiplicityTree/TreeColors.d.ts +1 -1
- package/lib/component/1d/multiplicityTree/TreeColors.js +1 -6
- package/lib/component/1d/multiplicityTree/TreeNodes.d.ts +1 -1
- package/lib/component/1d/tool/BaseLineZones.d.ts +1 -1
- package/lib/component/1d/tool/BaseLineZones.js +7 -4
- package/lib/component/1d/tool/PeakPointer.js +1 -1
- package/lib/component/1d/utilities/scale.js +1 -3
- package/lib/component/1d-2d/components/FloatMoleculeStructures/index.d.ts +1 -1
- package/lib/component/1d-2d/components/SpectrumInfoBlock.js +4 -1
- package/lib/component/1d-2d/tools/BrushXY.js +10 -7
- package/lib/component/1d-2d/tools/CrossLinePointer.js +1 -1
- package/lib/component/2d/FooterBanner.js +3 -2
- package/lib/component/2d/Viewer2D.js +51 -29
- package/lib/component/2d/XAxis.js +1 -1
- package/lib/component/2d/YAxis.js +1 -1
- package/lib/component/2d/utilities/SliceScale.d.ts +2 -2
- package/lib/component/2d/utilities/scale.d.ts +5 -5
- package/lib/component/2d/zones/Signal.js +1 -2
- package/lib/component/EventsTrackers/BrushTracker.d.ts +4 -1
- package/lib/component/EventsTrackers/BrushTracker.js +21 -6
- package/lib/component/NMRium.d.ts +2 -2
- package/lib/component/NMRium.js +39 -26
- package/lib/component/assignment/AssignmentsReducer.d.ts +1 -1
- package/lib/component/assignment/actions/setActiveAssignment.js +1 -1
- package/lib/component/elements/Input.js +1 -0
- package/lib/component/elements/InputRange.js +1 -1
- package/lib/component/elements/MenuButton.d.ts +1 -1
- package/lib/component/elements/MoleculeSelection.d.ts +1 -1
- package/lib/component/elements/ReactTable/ReactTable.d.ts +1 -1
- package/lib/component/elements/Scroller.d.ts +15 -0
- package/lib/component/elements/Scroller.js +31 -0
- package/lib/component/elements/Tab/DeleteButton.d.ts +1 -1
- package/lib/component/elements/ToolbarMenu.d.ts +1 -1
- package/lib/component/elements/accordion/Accordion.d.ts +1 -1
- package/lib/component/elements/draggable/SVGDraggable.d.ts +1 -1
- package/lib/component/elements/draggable/useDraggable.d.ts +1 -1
- package/lib/component/elements/dropDownButton/DropDownButton.d.ts +1 -1
- package/lib/component/elements/dropDownButton/DropDownList.js +3 -1
- package/lib/component/elements/formik/SelectBox.d.ts +1 -1
- package/lib/component/elements/popup/Alert/AlertBlock.d.ts +3 -2
- package/lib/component/elements/popup/Alert/AlertBlock.js +21 -15
- package/lib/component/elements/popup/Alert/Context.d.ts +26 -2
- package/lib/component/elements/popup/Alert/Context.js +6 -2
- package/lib/component/elements/popup/Alert/Provider.d.ts +4 -3
- package/lib/component/elements/popup/Alert/Provider.js +3 -3
- package/lib/component/elements/popup/Modal/ConfirmDialog.d.ts +1 -1
- package/lib/component/elements/popup/Modal/Provider.js +3 -1
- package/lib/component/elements/popup/options.d.ts +22 -19
- package/lib/component/elements/resizer/Resizer.d.ts +2 -2
- package/lib/component/elements/toggle/ToggleButton.d.ts +2 -2
- package/lib/component/elements/toggle/ToggleButton.js +1 -1
- package/lib/component/header/ZeroFillingOptionsPanel.js +3 -8
- package/lib/component/highlight/index.d.ts +1 -1
- package/lib/component/hooks/useCheckToolsVisibility.js +2 -2
- package/lib/component/hooks/useExport.js +2 -1
- package/lib/component/hooks/useFormatNumberByNucleus.d.ts +1 -1
- package/lib/component/hooks/usePanelPreferences.js +2 -2
- package/lib/component/hooks/useSaveSettings.js +9 -11
- package/lib/component/hooks/useXScale.d.ts +1 -1
- package/lib/component/hooks/useXYReduce.d.ts +2 -2
- package/lib/component/modal/AboutPredictionModal.js +1 -1
- package/lib/component/modal/AboutSpectrumSimulationModal.d.ts +2 -0
- package/lib/component/modal/AboutSpectrumSimulationModal.js +49 -0
- package/lib/component/modal/AlignSpectraModal.js +11 -1
- package/lib/component/modal/MultipletAnalysisModal.js +2 -1
- package/lib/component/modal/PredictSpectraModal.d.ts +1 -2
- package/lib/component/modal/PredictSpectraModal.js +25 -28
- package/lib/component/modal/changeSum/ChangeSumModal.js +1 -1
- package/lib/component/modal/editRange/forms/components/SignalsForm.js +1 -1
- package/lib/component/modal/editZone/SignalsForm.js +1 -1
- package/lib/component/modal/metaImportation/MetaImportationModal.js +1 -1
- package/lib/component/modal/setting/settings-tabs/DisplayTabContent.js +4 -0
- package/lib/component/modal/setting/settings-tabs/FormattingTabContent.js +1 -1
- package/lib/component/modal/setting/settings-tabs/InfoBlockTabContent.js +9 -2
- package/lib/component/modal/setting/settingsValidation.js +2 -2
- package/lib/component/panels/IntegralsPanel/IntegralPanel.d.ts +1 -1
- package/lib/component/panels/IntegralsPanel/IntegralTable.d.ts +1 -1
- package/lib/component/panels/IntegralsPanel/IntegralTable.js +4 -7
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts +1 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +6 -6
- package/lib/component/panels/MoleculesPanel/Utilities.d.ts +1 -1
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +3 -5
- package/lib/component/panels/Panels.js +13 -0
- package/lib/component/panels/PeaksPanel/PeaksTable.js +1 -1
- package/lib/component/panels/SpectrumsPanel/SpectraPreferences.js +4 -3
- package/lib/component/panels/SpectrumsPanel/SpectraTable.js +1 -1
- package/lib/component/panels/SpectrumsPanel/base/setting/SpectrumSetting.js +3 -1
- package/lib/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +2 -2
- package/lib/component/panels/SummaryPanel/utilities/Utilities.d.ts +2 -1
- package/lib/component/panels/SummaryPanel/utilities/Utilities.js +1 -1
- package/lib/component/panels/ZonesPanel/ZonesTable.d.ts +1 -1
- package/lib/component/panels/databasePanel/DatabasePanel.d.ts +1 -1
- package/lib/component/panels/databasePanel/DatabasePanel.js +34 -27
- package/lib/component/panels/databasePanel/DatabaseTable.js +1 -1
- package/lib/component/panels/extra/utilities/MultiplicityUtilities.js +2 -2
- package/lib/component/panels/extra/utilities/UseToggleStatus.js +1 -1
- package/lib/component/panels/filtersPanel/FiltersTable.js +2 -2
- package/lib/component/panels/predictionPanel/PredictionOptionsPanel.js +2 -1
- package/lib/component/panels/predictionPanel/PredictionPanel.js +3 -2
- package/lib/component/panels/predictionPanel/PredictionSimpleOptions.js +2 -2
- package/lib/component/panels/spectrumSimulation/SpectrumSimulation.d.ts +1 -0
- package/lib/component/panels/spectrumSimulation/SpectrumSimulation.js +88 -0
- package/lib/component/panels/spectrumSimulation/SpectrumSimulationPreferences.d.ts +11 -0
- package/lib/component/panels/spectrumSimulation/SpectrumSimulationPreferences.js +37 -0
- package/lib/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.d.ts +4 -0
- package/lib/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +25 -0
- package/lib/component/panels/spectrumSimulation/SpinSystemTable.d.ts +5 -0
- package/lib/component/panels/spectrumSimulation/SpinSystemTable.js +60 -0
- package/lib/component/reducer/Reducer.d.ts +13 -12
- package/lib/component/reducer/Reducer.js +253 -239
- package/lib/component/reducer/actions/AssignmentsActions.d.ts +1 -1
- package/lib/component/reducer/actions/AssignmentsActions.js +1 -1
- package/lib/component/reducer/actions/DatabaseActions.js +2 -1
- package/lib/component/reducer/actions/DomainActions.d.ts +7 -2
- package/lib/component/reducer/actions/DomainActions.js +30 -1
- package/lib/component/reducer/actions/FiltersActions.js +4 -4
- package/lib/component/reducer/actions/LoadActions.js +1 -1
- package/lib/component/reducer/actions/MoleculeActions.d.ts +8 -2
- package/lib/component/reducer/actions/MoleculeActions.js +58 -3
- package/lib/component/reducer/actions/SpectrumsActions.d.ts +8 -2
- package/lib/component/reducer/actions/SpectrumsActions.js +43 -4
- package/lib/component/reducer/actions/ToolsActions.js +2 -2
- package/lib/component/reducer/actions/ZonesActions.js +1 -1
- package/lib/component/reducer/helper/ZoomHistoryManager.d.ts +4 -6
- package/lib/component/reducer/preferences/actions/addWorkspace.js +19 -15
- package/lib/component/reducer/preferences/actions/setActiveWorkspace.js +1 -1
- package/lib/component/reducer/preferences/actions/setPreferences.js +3 -4
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +1 -1
- package/lib/component/reducer/preferences/preferencesReducer.js +5 -1
- package/lib/component/reducer/preferences/utilities/flatObject.js +1 -1
- package/lib/component/toolbar/ToolTypes.d.ts +4 -4
- package/lib/component/utility/PathBuilder.js +11 -0
- package/lib/component/utility/export.js +9 -9
- package/lib/component/utility/getSpectraObjectPaths.js +1 -1
- package/lib/component/utility/getUniqueNuclei.js +1 -1
- package/lib/component/utility/jpathToArray.js +1 -1
- package/lib/component/workspaces/index.d.ts +1 -0
- package/lib/component/workspaces/index.js +2 -0
- package/lib/component/workspaces/simulation.d.ts +2 -0
- package/lib/component/workspaces/simulation.js +68 -0
- package/lib/component/workspaces/workspaceDefaultProperties.js +9 -5
- package/lib/data/PredictionManager.d.ts +8 -7
- package/lib/data/PredictionManager.js +95 -22
- package/lib/data/SpectraManager.js +1 -1
- package/lib/data/constants/DefaultPathLengths.d.ts +1 -3
- package/lib/data/constants/SignalsKinds.d.ts +2 -2
- package/lib/data/data1d/Spectrum1D/generateJGraphData.js +3 -3
- package/lib/data/data1d/Spectrum1D/getReferenceShift.js +5 -4
- package/lib/data/data1d/Spectrum1D/integrals/changeIntegralsRelative.d.ts +1 -1
- package/lib/data/data1d/Spectrum1D/integrals/changeIntegralsRelative.js +12 -13
- package/lib/data/data1d/Spectrum1D/ranges/changeRangeRelativeValue.js +10 -9
- package/lib/data/data1d/database.d.ts +9 -7
- package/lib/data/data1d/database.js +13 -6
- package/lib/data/data1d/multipleSpectraAnalysis.d.ts +1 -1
- package/lib/data/data1d/multipleSpectraAnalysis.js +1 -1
- package/lib/data/data1d/spectrumSimulation.d.ts +14 -0
- package/lib/data/data1d/spectrumSimulation.js +53 -0
- package/lib/data/data2d/Spectrum2D/contours.d.ts +8 -4
- package/lib/data/data2d/Spectrum2D/contours.js +7 -1
- package/lib/data/data2d/Spectrum2D/getMissingProjection.js +6 -6
- package/lib/data/data2d/Spectrum2D/getShift.js +1 -1
- package/lib/data/data2d/Spectrum2D/getSlice.js +4 -4
- package/lib/data/data2d/Spectrum2D/zones/getDetectionZones.js +5 -5
- package/lib/data/getDefaultMatrixFilters.d.ts +2 -2
- package/lib/data/matrixGeneration.js +1 -1
- package/lib/data/molecules/MoleculeManager.d.ts +2 -1
- package/lib/data/molecules/MoleculeManager.js +21 -7
- package/lib/data/parseMeta/linkMetaWithSpectra.js +2 -1
- package/lib/data/types/data1d/MatrixOptions.d.ts +2 -2
- package/lib/data/utilities/FindUtilities.js +4 -4
- package/lib/data/utilities/RangeUtilities.d.ts +1 -1
- package/lib/data/utilities/ZoneUtilities.d.ts +1 -1
- package/lib/data/utilities/calculateSanPlot.js +3 -3
- package/lib/data/utilities/generateNumbersPowerOfX.js +1 -1
- package/lib/utils/clipboard/clipboard.d.ts +1 -1
- package/lib/versionInfo.js +1 -1
- package/lib-cjs/component/1d/FooterBanner.js +5 -4
- package/lib-cjs/component/1d/Viewer1D.js +120 -103
- package/lib-cjs/component/1d/database/ResurrectedDatabaseRanges.js +1 -1
- package/lib-cjs/component/1d/jCouplingGraph/JsCouplingLinks.js +1 -1
- package/lib-cjs/component/1d/multiplicityTree/TreeColors.js +1 -6
- package/lib-cjs/component/1d/tool/BaseLineZones.js +6 -3
- package/lib-cjs/component/1d/tool/PeakPointer.js +1 -1
- package/lib-cjs/component/1d/utilities/scale.js +1 -3
- package/lib-cjs/component/1d-2d/components/SpectrumInfoBlock.js +4 -1
- package/lib-cjs/component/1d-2d/tools/BrushXY.js +10 -7
- package/lib-cjs/component/1d-2d/tools/CrossLinePointer.js +1 -1
- package/lib-cjs/component/2d/FooterBanner.js +3 -2
- package/lib-cjs/component/2d/Viewer2D.js +50 -28
- package/lib-cjs/component/2d/XAxis.js +1 -1
- package/lib-cjs/component/2d/YAxis.js +1 -1
- package/lib-cjs/component/2d/zones/Signal.js +1 -2
- package/lib-cjs/component/EventsTrackers/BrushTracker.js +21 -6
- package/lib-cjs/component/NMRium.js +37 -24
- package/lib-cjs/component/assignment/actions/setActiveAssignment.js +1 -1
- package/lib-cjs/component/elements/Input.js +1 -0
- package/lib-cjs/component/elements/InputRange.js +1 -1
- package/lib-cjs/component/elements/Scroller.js +35 -0
- package/lib-cjs/component/elements/dropDownButton/DropDownList.js +3 -1
- package/lib-cjs/component/elements/popup/Alert/AlertBlock.js +21 -15
- package/lib-cjs/component/elements/popup/Alert/Context.js +6 -2
- package/lib-cjs/component/elements/popup/Alert/Provider.js +2 -2
- package/lib-cjs/component/elements/popup/Modal/Provider.js +3 -1
- package/lib-cjs/component/header/ZeroFillingOptionsPanel.js +3 -8
- package/lib-cjs/component/hooks/useCheckToolsVisibility.js +2 -2
- package/lib-cjs/component/hooks/useExport.js +2 -1
- package/lib-cjs/component/hooks/usePanelPreferences.js +1 -1
- package/lib-cjs/component/hooks/useSaveSettings.js +9 -11
- package/lib-cjs/component/modal/AboutPredictionModal.js +1 -1
- package/lib-cjs/component/modal/AboutSpectrumSimulationModal.js +54 -0
- package/lib-cjs/component/modal/AlignSpectraModal.js +11 -1
- package/lib-cjs/component/modal/MultipletAnalysisModal.js +2 -1
- package/lib-cjs/component/modal/PredictSpectraModal.js +24 -27
- package/lib-cjs/component/modal/changeSum/ChangeSumModal.js +1 -1
- package/lib-cjs/component/modal/editRange/forms/components/SignalsForm.js +1 -1
- package/lib-cjs/component/modal/editZone/SignalsForm.js +1 -1
- package/lib-cjs/component/modal/metaImportation/MetaImportationModal.js +1 -1
- package/lib-cjs/component/modal/setting/settings-tabs/DisplayTabContent.js +4 -0
- package/lib-cjs/component/modal/setting/settings-tabs/FormattingTabContent.js +1 -1
- package/lib-cjs/component/modal/setting/settings-tabs/InfoBlockTabContent.js +9 -2
- package/lib-cjs/component/modal/setting/settingsValidation.js +2 -2
- package/lib-cjs/component/panels/IntegralsPanel/IntegralTable.js +4 -7
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +6 -6
- package/lib-cjs/component/panels/MoleculesPanel/useAtomAssignment.js +3 -5
- package/lib-cjs/component/panels/Panels.js +13 -0
- package/lib-cjs/component/panels/PeaksPanel/PeaksTable.js +1 -1
- package/lib-cjs/component/panels/SpectrumsPanel/SpectraPreferences.js +3 -2
- package/lib-cjs/component/panels/SpectrumsPanel/SpectraTable.js +1 -1
- package/lib-cjs/component/panels/SpectrumsPanel/base/setting/SpectrumSetting.js +3 -1
- package/lib-cjs/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +2 -2
- package/lib-cjs/component/panels/SummaryPanel/utilities/Utilities.js +1 -1
- package/lib-cjs/component/panels/databasePanel/DatabasePanel.js +34 -27
- package/lib-cjs/component/panels/databasePanel/DatabaseTable.js +1 -1
- package/lib-cjs/component/panels/extra/utilities/MultiplicityUtilities.js +2 -2
- package/lib-cjs/component/panels/extra/utilities/UseToggleStatus.js +1 -1
- package/lib-cjs/component/panels/filtersPanel/FiltersTable.js +2 -2
- package/lib-cjs/component/panels/predictionPanel/PredictionOptionsPanel.js +2 -1
- package/lib-cjs/component/panels/predictionPanel/PredictionPanel.js +3 -2
- package/lib-cjs/component/panels/predictionPanel/PredictionSimpleOptions.js +1 -1
- package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulation.js +94 -0
- package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulationPreferences.js +42 -0
- package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +31 -0
- package/lib-cjs/component/panels/spectrumSimulation/SpinSystemTable.js +67 -0
- package/lib-cjs/component/reducer/Reducer.js +253 -239
- package/lib-cjs/component/reducer/actions/AssignmentsActions.js +1 -1
- package/lib-cjs/component/reducer/actions/DatabaseActions.js +2 -1
- package/lib-cjs/component/reducer/actions/DomainActions.js +31 -1
- package/lib-cjs/component/reducer/actions/FiltersActions.js +4 -4
- package/lib-cjs/component/reducer/actions/LoadActions.js +1 -1
- package/lib-cjs/component/reducer/actions/MoleculeActions.js +62 -3
- package/lib-cjs/component/reducer/actions/SpectrumsActions.js +43 -3
- package/lib-cjs/component/reducer/actions/ToolsActions.js +2 -2
- package/lib-cjs/component/reducer/actions/ZonesActions.js +1 -1
- package/lib-cjs/component/reducer/preferences/actions/addWorkspace.js +19 -15
- package/lib-cjs/component/reducer/preferences/actions/setActiveWorkspace.js +1 -1
- package/lib-cjs/component/reducer/preferences/actions/setPreferences.js +3 -4
- package/lib-cjs/component/reducer/preferences/preferencesReducer.js +5 -1
- package/lib-cjs/component/reducer/preferences/utilities/flatObject.js +1 -1
- package/lib-cjs/component/utility/PathBuilder.js +11 -0
- package/lib-cjs/component/utility/export.js +9 -9
- package/lib-cjs/component/utility/getSpectraObjectPaths.js +1 -1
- package/lib-cjs/component/utility/getUniqueNuclei.js +1 -1
- package/lib-cjs/component/utility/jpathToArray.js +1 -1
- package/lib-cjs/component/workspaces/index.js +2 -0
- package/lib-cjs/component/workspaces/simulation.js +71 -0
- package/lib-cjs/component/workspaces/workspaceDefaultProperties.js +9 -5
- package/lib-cjs/data/PredictionManager.js +96 -22
- package/lib-cjs/data/SpectraManager.js +1 -1
- package/lib-cjs/data/data1d/Spectrum1D/generateJGraphData.js +3 -3
- package/lib-cjs/data/data1d/Spectrum1D/getReferenceShift.js +5 -4
- package/lib-cjs/data/data1d/Spectrum1D/integrals/changeIntegralsRelative.js +12 -13
- package/lib-cjs/data/data1d/Spectrum1D/ranges/changeRangeRelativeValue.js +10 -9
- package/lib-cjs/data/data1d/database.js +13 -6
- package/lib-cjs/data/data1d/multipleSpectraAnalysis.js +1 -1
- package/lib-cjs/data/data1d/spectrumSimulation.js +58 -0
- package/lib-cjs/data/data2d/Spectrum2D/contours.js +7 -1
- package/lib-cjs/data/data2d/Spectrum2D/getMissingProjection.js +6 -6
- package/lib-cjs/data/data2d/Spectrum2D/getShift.js +1 -1
- package/lib-cjs/data/data2d/Spectrum2D/getSlice.js +4 -4
- package/lib-cjs/data/data2d/Spectrum2D/zones/getDetectionZones.js +5 -5
- package/lib-cjs/data/matrixGeneration.js +1 -1
- package/lib-cjs/data/molecules/MoleculeManager.js +23 -8
- package/lib-cjs/data/parseMeta/linkMetaWithSpectra.js +2 -1
- package/lib-cjs/data/utilities/FindUtilities.js +4 -4
- package/lib-cjs/data/utilities/calculateSanPlot.js +3 -3
- package/lib-cjs/data/utilities/generateNumbersPowerOfX.js +1 -1
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +21 -20
|
@@ -27,7 +27,7 @@ function YAxis(props) {
|
|
|
27
27
|
useEffect(() => {
|
|
28
28
|
if (!show || !yDomain)
|
|
29
29
|
return;
|
|
30
|
-
|
|
30
|
+
const scaleY = get2DYScale({ height, yDomain, margin }, !!spectrum?.info?.isFid);
|
|
31
31
|
const axis = d3.axisRight(scaleY).ticks(8).tickFormat(d3.format('0'));
|
|
32
32
|
// @ts-expect-error well typed
|
|
33
33
|
d3.select(refAxis.current).call(axis);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
declare function getTopXScale(width: number, margin: {
|
|
2
2
|
right: number;
|
|
3
3
|
left: number;
|
|
4
|
-
}, x:
|
|
4
|
+
}, x: number[]): {
|
|
5
5
|
xDomain: [number, number] | [undefined, undefined];
|
|
6
6
|
scaleX: import("d3-scale").ScaleLinear<number, number, never>;
|
|
7
7
|
};
|
|
8
8
|
declare function getLeftXScale(width: number, margin: {
|
|
9
9
|
bottom: number;
|
|
10
10
|
top: number;
|
|
11
|
-
}, x:
|
|
11
|
+
}, x: number[]): {
|
|
12
12
|
xDomain: [number, number] | [undefined, undefined];
|
|
13
13
|
scaleX: import("d3-scale").ScaleLinear<number, number, never>;
|
|
14
14
|
};
|
|
@@ -5,7 +5,7 @@ declare function get2DXScale(props: {
|
|
|
5
5
|
right: number;
|
|
6
6
|
left: number;
|
|
7
7
|
};
|
|
8
|
-
xDomain:
|
|
8
|
+
xDomain: number[];
|
|
9
9
|
}, reverse?: boolean): import("d3-scale").ScaleLinear<number, number, never>;
|
|
10
10
|
declare function get2DYScale(props: {
|
|
11
11
|
height: number;
|
|
@@ -13,7 +13,7 @@ declare function get2DYScale(props: {
|
|
|
13
13
|
bottom: number;
|
|
14
14
|
top: number;
|
|
15
15
|
};
|
|
16
|
-
yDomain:
|
|
16
|
+
yDomain: number[];
|
|
17
17
|
}, reverse?: boolean): import("d3-scale").ScaleLinear<number, number, never>;
|
|
18
18
|
interface TopLayout {
|
|
19
19
|
width: number;
|
|
@@ -21,7 +21,7 @@ interface TopLayout {
|
|
|
21
21
|
right: number;
|
|
22
22
|
left: number;
|
|
23
23
|
};
|
|
24
|
-
xDomain:
|
|
24
|
+
xDomain: number[];
|
|
25
25
|
}
|
|
26
26
|
interface LeftLayout {
|
|
27
27
|
height: number;
|
|
@@ -29,8 +29,8 @@ interface LeftLayout {
|
|
|
29
29
|
bottom: number;
|
|
30
30
|
top: number;
|
|
31
31
|
};
|
|
32
|
-
yDomain:
|
|
32
|
+
yDomain: number[];
|
|
33
33
|
}
|
|
34
34
|
declare function get1DXScale(props: TopLayout | LeftLayout, layout: Layout): import("d3-scale").ScaleLinear<number, number, never> | undefined;
|
|
35
|
-
declare function get1DYScale(yDomain:
|
|
35
|
+
declare function get1DYScale(yDomain: number[], height: number, margin?: number): import("d3-scale").ScaleLinear<number, number, never>;
|
|
36
36
|
export { get2DXScale, get2DYScale, get1DXScale, get1DYScale };
|
|
@@ -40,7 +40,6 @@ function Signal({ signal, isVisible }) {
|
|
|
40
40
|
assignment.hide();
|
|
41
41
|
highlight.hide();
|
|
42
42
|
}, cx: scaleX(signal.x.delta || 0), cy: scaleY(signal.y.delta || 0), r: isHighlighted ? 6 : 4, fill: isHighlighted ? 'green' : 'darkgreen' }, signal.id)] })), _jsx("g", { className: "zone-signal-peak", style: { pointerEvents: 'none' }, children: isVisible.peaks &&
|
|
43
|
-
signal?.peaks
|
|
44
|
-
signal.peaks.map((peak, i) => (_jsx("circle", { cx: scaleX(peak.x), cy: scaleY(peak.y), r: 2, fill: "black" }, `${signal.id + i}`))) })] }));
|
|
43
|
+
signal?.peaks?.map((peak, i) => (_jsx("circle", { cx: scaleX(peak.x), cy: scaleY(peak.y), r: 2, fill: "black" }, `${signal.id + i}`))) })] }));
|
|
45
44
|
}
|
|
46
45
|
export default memo(Signal);
|
|
@@ -8,7 +8,9 @@ interface BrushTrackerContext {
|
|
|
8
8
|
endY: number;
|
|
9
9
|
shiftKey: boolean;
|
|
10
10
|
altKey: boolean;
|
|
11
|
+
mouseButton: MouseButton;
|
|
11
12
|
}
|
|
13
|
+
type MouseButton = 'main' | 'secondary' | 'unknown';
|
|
12
14
|
export declare const BrushContext: import("react").Context<BrushTrackerContext>;
|
|
13
15
|
export declare function useBrushTracker(): BrushTrackerContext;
|
|
14
16
|
interface Position {
|
|
@@ -23,10 +25,11 @@ interface BrushTrackerProps {
|
|
|
23
25
|
children: ReactNode;
|
|
24
26
|
className?: string;
|
|
25
27
|
style?: CSSProperties;
|
|
28
|
+
onBrushEnd?: OnBrush;
|
|
26
29
|
onBrush?: OnBrush;
|
|
27
30
|
onZoom?: OnZoom;
|
|
28
31
|
onDoubleClick?: OnClick;
|
|
29
32
|
onClick?: OnClick;
|
|
30
33
|
noPropagation?: boolean;
|
|
31
34
|
}
|
|
32
|
-
export declare function BrushTracker({ children, className, style, onBrush, onZoom, onDoubleClick, onClick, noPropagation, }: BrushTrackerProps): import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
export declare function BrushTracker({ children, className, style, onBrushEnd, onBrush, onZoom, onDoubleClick, onClick, noPropagation, }: BrushTrackerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,8 +2,13 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import lodashDebounce from 'lodash/debounce';
|
|
3
3
|
import lodashMap from 'lodash/map';
|
|
4
4
|
import { createContext, useCallback, useEffect, useReducer, useRef, useState, useContext, } from 'react';
|
|
5
|
+
const MouseButtons = {
|
|
6
|
+
0: 'main',
|
|
7
|
+
2: 'secondary',
|
|
8
|
+
};
|
|
5
9
|
const initialState = {
|
|
6
10
|
step: 'initial',
|
|
11
|
+
mouseButton: 'unknown',
|
|
7
12
|
shiftKey: false,
|
|
8
13
|
altKey: false,
|
|
9
14
|
startX: 0,
|
|
@@ -26,18 +31,21 @@ export function useBrushTracker() {
|
|
|
26
31
|
}
|
|
27
32
|
return useContext(BrushContext);
|
|
28
33
|
}
|
|
29
|
-
export function BrushTracker({ children, className, style, onBrush
|
|
34
|
+
export function BrushTracker({ children, className, style, onBrushEnd, onBrush, onZoom = () => null, onDoubleClick = () => null, onClick = () => null, noPropagation, }) {
|
|
30
35
|
const [state, dispatch] = useReducer(reducer, initialState);
|
|
31
36
|
const [mouseDownTime, setMouseDownTime] = useState(0);
|
|
32
37
|
const debounceClickEventsRef = useRef([]);
|
|
38
|
+
const lastPointRef = useRef(0);
|
|
33
39
|
const mouseDownHandler = useCallback((event) => {
|
|
34
|
-
|
|
40
|
+
//check that the right or left mouse button pressed
|
|
41
|
+
if ([0, 2].includes(event.button)) {
|
|
35
42
|
if (noPropagation) {
|
|
36
43
|
event.stopPropagation();
|
|
37
44
|
}
|
|
38
45
|
dispatch({
|
|
39
46
|
type: 'DOWN',
|
|
40
47
|
payload: {
|
|
48
|
+
mouseButton: MouseButtons[event.button],
|
|
41
49
|
shiftKey: event.shiftKey,
|
|
42
50
|
altKey: event.altKey,
|
|
43
51
|
screenX: event.screenX,
|
|
@@ -100,13 +108,19 @@ export function BrushTracker({ children, className, style, onBrush = () => null,
|
|
|
100
108
|
}, [onZoom]);
|
|
101
109
|
useEffect(() => {
|
|
102
110
|
const { step, startX, endX, startY, endY } = state;
|
|
103
|
-
|
|
104
|
-
|
|
111
|
+
const point = Math.hypot(endX - startX, endY - startY);
|
|
112
|
+
if ((step === 'end' || step === 'brushing') &&
|
|
113
|
+
lastPointRef.current !== point) {
|
|
114
|
+
onBrush?.(state);
|
|
115
|
+
lastPointRef.current = point;
|
|
116
|
+
}
|
|
117
|
+
if (step === 'end' && point > 5) {
|
|
118
|
+
onBrushEnd?.(state);
|
|
105
119
|
dispatch({
|
|
106
120
|
type: 'DONE',
|
|
107
121
|
});
|
|
108
122
|
}
|
|
109
|
-
}, [onBrush, state]);
|
|
123
|
+
}, [onBrush, onBrushEnd, state]);
|
|
110
124
|
return (_jsx(BrushContext.Provider, { value: state, children: _jsx("div", { className: className, style: style, onMouseDown: mouseDownHandler, onClick: clickHandler, onWheel: handleMouseWheel, onMouseEnter: () => {
|
|
111
125
|
// disable page scrolling once the mouse over the Displayer
|
|
112
126
|
window.addEventListener('wheel', stopPageScrolling, {
|
|
@@ -129,13 +143,14 @@ function reducer(state, action) {
|
|
|
129
143
|
return state;
|
|
130
144
|
case 'DOWN':
|
|
131
145
|
if (state.step === 'initial' || state.step === 'end') {
|
|
132
|
-
const { shiftKey, altKey, screenX, screenY, clientX, clientY, boundingRect, } = action.payload;
|
|
146
|
+
const { shiftKey, altKey, mouseButton, screenX, screenY, clientX, clientY, boundingRect, } = action.payload;
|
|
133
147
|
const x = clientX - boundingRect.x;
|
|
134
148
|
const y = clientY - boundingRect.y;
|
|
135
149
|
return {
|
|
136
150
|
...state,
|
|
137
151
|
shiftKey,
|
|
138
152
|
altKey,
|
|
153
|
+
mouseButton,
|
|
139
154
|
startX: x,
|
|
140
155
|
startY: y,
|
|
141
156
|
startScreenX: screenX,
|
|
@@ -7,7 +7,7 @@ import { ErrorBoundaryPropsWithComponent } from 'react-error-boundary';
|
|
|
7
7
|
import { BlobObject } from './utility/export';
|
|
8
8
|
export { serializeNmriumState } from 'nmr-load-save';
|
|
9
9
|
export type { NmriumState, WorkspacePreferences as NMRiumPreferences, } from 'nmr-load-save';
|
|
10
|
-
export type NMRiumWorkspace = 'exercise' | 'process1D' | 'default' | 'prediction' | 'embedded' | 'assignment' | (string & {});
|
|
10
|
+
export type NMRiumWorkspace = 'exercise' | 'process1D' | 'default' | 'prediction' | 'embedded' | 'assignment' | 'simulation' | (string & {});
|
|
11
11
|
export type OnNMRiumChange = (state: NmriumState, source: 'data' | 'view' | 'settings') => void;
|
|
12
12
|
export interface NMRiumProps {
|
|
13
13
|
data?: NMRiumData;
|
|
@@ -32,7 +32,7 @@ type DeepPartial<T> = {
|
|
|
32
32
|
export interface NMRiumData {
|
|
33
33
|
source?: WebSource;
|
|
34
34
|
molecules?: Molecules;
|
|
35
|
-
spectra: DeepPartial<Spectrum
|
|
35
|
+
spectra: Array<DeepPartial<Spectrum>>;
|
|
36
36
|
correlations?: CorrelationData;
|
|
37
37
|
}
|
|
38
38
|
export interface NMRiumRef {
|
package/lib/component/NMRium.js
CHANGED
|
@@ -15,10 +15,10 @@ import ErrorOverlay from './ErrorOverlay';
|
|
|
15
15
|
import KeysListenerTracker from './EventsTrackers/KeysListenerTracker';
|
|
16
16
|
import { SplitPaneWrapper } from './SplitPaneWrapper';
|
|
17
17
|
import { AssignmentProvider } from './assignment';
|
|
18
|
-
import { ChartDataProvider } from './context/ChartContext';
|
|
18
|
+
import { ChartDataProvider, useChartData } from './context/ChartContext';
|
|
19
19
|
import { DispatchProvider } from './context/DispatchContext';
|
|
20
20
|
import { GlobalProvider } from './context/GlobalContext';
|
|
21
|
-
import { LoggerProvider } from './context/LoggerContext';
|
|
21
|
+
import { LoggerProvider, useLogger } from './context/LoggerContext';
|
|
22
22
|
import { PreferencesProvider } from './context/PreferencesContext';
|
|
23
23
|
import { AlertProvider } from './elements/popup/Alert';
|
|
24
24
|
import { ModalProvider } from './elements/popup/Modal';
|
|
@@ -37,7 +37,7 @@ const viewerContainerStyle = css `
|
|
|
37
37
|
border: 0.55px #e6e6e6 solid;
|
|
38
38
|
display: flex;
|
|
39
39
|
flex: 1;
|
|
40
|
-
flex-direction:
|
|
40
|
+
flex-direction: column;
|
|
41
41
|
height: 100%;
|
|
42
42
|
margin-left: -1px;
|
|
43
43
|
`;
|
|
@@ -197,28 +197,41 @@ function InnerNMRium({ data: dataProp = defaultData, workspace, customWorkspaces
|
|
|
197
197
|
rootRef: rootRef.current,
|
|
198
198
|
elementsWrapperRef: elementsWrapperRef.current,
|
|
199
199
|
viewerRef: viewerRef.current,
|
|
200
|
-
}, children: _jsx(PreferencesProvider, { value: preferencesState, children: _jsx("div", { ref: mainDivRef, style: { height: '100%', position: 'relative' }, children: _jsx(LoggerProvider, { children: _jsx(AlertProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(DispatchProvider, { value: dispatch, children: _jsx(ChartDataProvider, { value: state, children: _jsx(ModalProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(HighlightProvider, { children: _jsx(AssignmentProvider, { spectraData: spectraData, children:
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
200
|
+
}, children: _jsx(PreferencesProvider, { value: preferencesState, children: _jsx("div", { ref: mainDivRef, style: { height: '100%', position: 'relative' }, children: _jsx(LoggerProvider, { children: _jsx(AlertProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(DispatchProvider, { value: dispatch, children: _jsx(ChartDataProvider, { value: state, children: _jsx(ModalProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(HighlightProvider, { children: _jsx(AssignmentProvider, { spectraData: spectraData, children: _jsxs(SpinnerProvider, { value: getSpinner, children: [_jsx(StateError, {}), _jsx("div", { className: "nmrium-container", ref: rootRef, css: containerStyles, onContextMenu: preventContextMenuHandler, style: { height: '100%', width: '100%' }, children: _jsx(DropZone, { children: _jsxs("div", { style: {
|
|
201
|
+
display: 'flex',
|
|
202
|
+
flexDirection: 'column',
|
|
203
|
+
backgroundColor: 'white',
|
|
204
|
+
width: '100%',
|
|
205
|
+
}, children: [_jsx(Header, { isFullscreen: isFullscreen, onMaximize: toggle }), _jsxs("div", { style: {
|
|
206
|
+
display: 'flex',
|
|
207
|
+
flexDirection: 'row',
|
|
208
|
+
height: '100%',
|
|
209
|
+
}, children: [_jsx(ToolBar, {}), _jsxs(SplitPaneWrapper, { children: [_jsxs("div", { css: viewerContainerStyle, children: [_jsx(KeysListenerTracker, {}), _jsxs("div", { id: "nmrium-viewer", "data-test-id": "viewer", ref: viewerRef, style: {
|
|
210
|
+
width: '100%',
|
|
211
|
+
height: '100%',
|
|
212
|
+
position: 'relative',
|
|
213
|
+
}, children: [_jsx(FloatMoleculeStructures, {}), displayerMode ===
|
|
214
|
+
DISPLAYER_MODE.DM_1D ? (_jsx(Viewer1D, { emptyText: emptyText })) : (_jsx(Viewer2D, { emptyText: emptyText }))] })] }), _jsx(Panels, {})] }), _jsx("div", { ref: elementsWrapperRef, id: "main-wrapper", style: {
|
|
215
|
+
position: 'absolute',
|
|
216
|
+
pointerEvents: 'none',
|
|
217
|
+
zIndex: 2,
|
|
218
|
+
left: 0,
|
|
219
|
+
right: 0,
|
|
220
|
+
top: 0,
|
|
221
|
+
bottom: 0,
|
|
222
|
+
} }, String(isFullscreen))] })] }) }) })] }) }) }) }) }) }) }) }) }) }) }));
|
|
223
223
|
}
|
|
224
224
|
export default memo(NMRium);
|
|
225
|
+
/**
|
|
226
|
+
* Alert user in UI when state have errorAction (error from reducer)
|
|
227
|
+
*/
|
|
228
|
+
function StateError() {
|
|
229
|
+
const { errorAction } = useChartData();
|
|
230
|
+
const { logger } = useLogger();
|
|
231
|
+
useEffect(() => {
|
|
232
|
+
if (!errorAction)
|
|
233
|
+
return;
|
|
234
|
+
logger.error(errorAction);
|
|
235
|
+
}, [errorAction, logger]);
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
@@ -2,7 +2,7 @@ import { NmrData1D, NmrData2D } from 'cheminfo-types';
|
|
|
2
2
|
import { ActionType } from '../reducer/types/ActionType';
|
|
3
3
|
import { AssignmentDimension, AssignmentState, Axis } from './AssignmentsContext';
|
|
4
4
|
export type InitiateAction = ActionType<'INITIATE_ASSIGNMENTS', {
|
|
5
|
-
spectra:
|
|
5
|
+
spectra: Array<NmrData1D | NmrData2D>;
|
|
6
6
|
}>;
|
|
7
7
|
export type ToggleAction = ActionType<'TOGGLE', {
|
|
8
8
|
atomIDs: string[];
|
|
@@ -125,6 +125,7 @@ const Input = forwardRef((props, ref) => {
|
|
|
125
125
|
onClear?.();
|
|
126
126
|
}
|
|
127
127
|
return (_jsxs("div", { style: {
|
|
128
|
+
...(renderIcon || (canClear && { padding: '0 5px' })),
|
|
128
129
|
...styles.inputWrapper,
|
|
129
130
|
...style?.inputWrapper,
|
|
130
131
|
}, className: `input ${className || ''}`, children: [renderIcon?.(), _jsx("input", { ...otherProps, ref: combinedRef, name: name, style: {
|
|
@@ -36,7 +36,7 @@ function InputRange(props, ref) {
|
|
|
36
36
|
}));
|
|
37
37
|
const mouseDownCallback = useCallback((event) => {
|
|
38
38
|
function mouseMoveCallback(event) {
|
|
39
|
-
|
|
39
|
+
const diff = event.clientX - previousPosition.current;
|
|
40
40
|
previousPosition.current = event.clientX;
|
|
41
41
|
if (event.buttons === 1) {
|
|
42
42
|
const step = diff / (event.shiftKey ? 10 : 1);
|
|
@@ -3,7 +3,7 @@ interface MenuButtonProps {
|
|
|
3
3
|
component: any;
|
|
4
4
|
toolTip: string;
|
|
5
5
|
className?: string;
|
|
6
|
-
items:
|
|
6
|
+
items: any[];
|
|
7
7
|
onClick: (element: any) => void;
|
|
8
8
|
}
|
|
9
9
|
export default function MenuButton({ style, component, toolTip, className, items, onClick, }: MenuButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -8,7 +8,7 @@ import { ClickEvent } from './Elements/ReactTableRow';
|
|
|
8
8
|
interface ExtraColumn<T extends object> {
|
|
9
9
|
enableRowSpan?: boolean;
|
|
10
10
|
style?: CSSProperties;
|
|
11
|
-
Cell?: (cell: CellProps<T
|
|
11
|
+
Cell?: (cell: CellProps<T>) => JSX.Element | string;
|
|
12
12
|
}
|
|
13
13
|
export type Column<T extends object> = ReactColumn<T> & ExtraColumn<T> & UseSortByColumnOptions<T>;
|
|
14
14
|
interface SortEvent {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
interface ScrollerProps {
|
|
3
|
+
scrollTo: string;
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export declare function Scroller(props: ScrollerProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare namespace Scroller {
|
|
8
|
+
var Item: typeof ScrollerElement;
|
|
9
|
+
}
|
|
10
|
+
interface ScrollerElementProps {
|
|
11
|
+
elementKey: string;
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
declare function ScrollerElement(props: ScrollerElementProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Children, createContext, isValidElement, useContext, useEffect, useRef, } from 'react';
|
|
3
|
+
const ScrollContext = createContext('');
|
|
4
|
+
const ScrollProvider = ScrollContext.Provider;
|
|
5
|
+
function useScrollKey() {
|
|
6
|
+
const context = useContext(ScrollContext);
|
|
7
|
+
if (!context) {
|
|
8
|
+
throw new Error('Scroller context was not found');
|
|
9
|
+
}
|
|
10
|
+
return context;
|
|
11
|
+
}
|
|
12
|
+
export function Scroller(props) {
|
|
13
|
+
const { scrollTo, children } = props;
|
|
14
|
+
const isAllScrollItem = Children.toArray(children).some((child) => isValidElement(child) && child.type === ScrollerElement);
|
|
15
|
+
if (!isAllScrollItem && Children.count(children) > 0) {
|
|
16
|
+
throw new Error("one of the children should be of type <Scroller.Item elementKey='...' > children </Scroller.Item>");
|
|
17
|
+
}
|
|
18
|
+
return _jsxs(ScrollProvider, { value: scrollTo, children: [" ", children, " "] });
|
|
19
|
+
}
|
|
20
|
+
function ScrollerElement(props) {
|
|
21
|
+
const { children, elementKey } = props;
|
|
22
|
+
const scrollToKey = useScrollKey();
|
|
23
|
+
const ref = useRef(null);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (ref.current && elementKey === scrollToKey) {
|
|
26
|
+
ref.current.scrollIntoView({ behavior: 'smooth' });
|
|
27
|
+
}
|
|
28
|
+
}, [elementKey, scrollToKey]);
|
|
29
|
+
return _jsx("div", { ref: ref, children: children });
|
|
30
|
+
}
|
|
31
|
+
Scroller.Item = ScrollerElement;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CSSProperties } from 'react';
|
|
2
2
|
interface DeleteButtonProps {
|
|
3
|
-
onDelete: (element: React.MouseEvent<HTMLButtonElement
|
|
3
|
+
onDelete: (element: React.MouseEvent<HTMLButtonElement>) => void;
|
|
4
4
|
className?: string;
|
|
5
5
|
style?: CSSProperties;
|
|
6
6
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
interface MenuButtonProps {
|
|
2
2
|
component: any;
|
|
3
3
|
toolTip: string;
|
|
4
|
-
items:
|
|
4
|
+
items: any[];
|
|
5
5
|
onClick: (element: any) => void;
|
|
6
6
|
}
|
|
7
7
|
export default function ToolbarMenu({ component, toolTip, items, onClick, }: MenuButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
interface AccordionProps {
|
|
3
|
-
children:
|
|
3
|
+
children: ReactNode[];
|
|
4
4
|
defaultOpenIndex: number | null;
|
|
5
5
|
}
|
|
6
6
|
declare function Accordion({ children, defaultOpenIndex }: AccordionProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactFragment } from 'react';
|
|
2
2
|
import { Position } from './useDraggable';
|
|
3
|
-
type ChildType =
|
|
3
|
+
type ChildType = React.ReactElement[] | React.ReactElement | ReactFragment | boolean | null;
|
|
4
4
|
type PositionChangeHandler = (data: Position) => void;
|
|
5
5
|
export interface DraggableProps {
|
|
6
6
|
children?: ChildType | ((x1: number, x2: number) => ChildType);
|
|
@@ -10,7 +10,7 @@ interface UseDraggable {
|
|
|
10
10
|
dragHandleClassName?: string;
|
|
11
11
|
}
|
|
12
12
|
export interface Draggable {
|
|
13
|
-
onMouseDown: (event: React.MouseEvent<HTMLDivElement | SVGElement
|
|
13
|
+
onMouseDown: (event: React.MouseEvent<HTMLDivElement | SVGElement>) => void;
|
|
14
14
|
position: {
|
|
15
15
|
value: Position;
|
|
16
16
|
action: Action;
|
|
@@ -11,7 +11,7 @@ export interface ItemProps {
|
|
|
11
11
|
visibleKey?: string;
|
|
12
12
|
}
|
|
13
13
|
export interface DropDownListProps<T> {
|
|
14
|
-
data:
|
|
14
|
+
data: T[];
|
|
15
15
|
renderItem?: ((item: DropDownListItem) => ReactNode) | null;
|
|
16
16
|
}
|
|
17
17
|
interface DropDownButtonProps<T> extends DropDownListProps<T>, ItemProps {
|
|
@@ -8,7 +8,9 @@ const styles = {
|
|
|
8
8
|
position: absolute;
|
|
9
9
|
height: auto;
|
|
10
10
|
z-index: 99999999999999;
|
|
11
|
-
box-shadow:
|
|
11
|
+
box-shadow:
|
|
12
|
+
0 19px 38px rgb(0 0 0 / 30%),
|
|
13
|
+
0 15px 12px rgb(0 0 0 / 22%);
|
|
12
14
|
border-radius: 10px;
|
|
13
15
|
margin-bottom: 20px;
|
|
14
16
|
overflow: hidden;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ErrorMessageProps } from './ErrorMessage';
|
|
2
2
|
interface SelectBoxProps extends ErrorMessageProps {
|
|
3
|
-
values:
|
|
3
|
+
values: any[];
|
|
4
4
|
}
|
|
5
5
|
declare function SelectBox({ values, ...props }: SelectBoxProps): import("@emotion/react/jsx-runtime").JSX.Element | null;
|
|
6
6
|
export default SelectBox;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { Alert } from './Context';
|
|
1
2
|
interface AlertBlockProps {
|
|
2
3
|
offset: string;
|
|
3
|
-
alert:
|
|
4
|
+
alert: Alert;
|
|
4
5
|
onClose: () => void;
|
|
5
6
|
}
|
|
6
|
-
export default function AlertBlock(props: AlertBlockProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export default function AlertBlock(props: AlertBlockProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
7
8
|
export {};
|
|
@@ -1,24 +1,30 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource @emotion/react */
|
|
3
|
+
import { css } from '@emotion/react';
|
|
2
4
|
import { FaTimes } from 'react-icons/fa';
|
|
3
5
|
import { types } from '../options';
|
|
4
6
|
import ProgressIndicator from './ProgressIndicator';
|
|
7
|
+
const style = css `
|
|
8
|
+
padding: 25px;
|
|
9
|
+
border-radius: 10px;
|
|
10
|
+
pointer-events: all;
|
|
11
|
+
min-height: 60px;
|
|
12
|
+
position: relative;
|
|
13
|
+
|
|
14
|
+
> button {
|
|
15
|
+
position: absolute;
|
|
16
|
+
right: 5px;
|
|
17
|
+
top: 5px;
|
|
18
|
+
border: none;
|
|
19
|
+
background-color: transparent;
|
|
20
|
+
color: white;
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
5
23
|
export default function AlertBlock(props) {
|
|
6
24
|
const { offset, alert, onClose } = props;
|
|
7
|
-
return (_jsxs("div", { style: {
|
|
25
|
+
return (_jsxs("div", { css: style, style: {
|
|
8
26
|
margin: offset,
|
|
9
|
-
padding: '25px',
|
|
10
|
-
borderRadius: '10px',
|
|
11
|
-
pointerEvents: 'all',
|
|
12
27
|
backgroundColor: alert.options.backgroundColor,
|
|
13
28
|
color: alert.options.color,
|
|
14
|
-
|
|
15
|
-
position: 'relative',
|
|
16
|
-
}, children: [_jsx("button", { style: {
|
|
17
|
-
position: 'absolute',
|
|
18
|
-
right: '5px',
|
|
19
|
-
top: '5px',
|
|
20
|
-
border: 'none',
|
|
21
|
-
backgroundColor: 'transparent',
|
|
22
|
-
color: 'white',
|
|
23
|
-
}, type: "button", onClick: onClose, children: _jsx(FaTimes, {}) }), _jsx("span", { children: alert.message }), alert.options.type === types.PROGRESS_INDICATOR && _jsx(ProgressIndicator, {})] }, alert.id));
|
|
29
|
+
}, children: [_jsx("button", { type: "button", onClick: onClose, children: _jsx(FaTimes, {}) }), _jsx("span", { children: alert.message }), alert.options.type === types.PROGRESS_INDICATOR && _jsx(ProgressIndicator, {})] }, alert.id));
|
|
24
30
|
}
|
|
@@ -1,3 +1,27 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
export
|
|
2
|
+
import { Position, Type } from '../options';
|
|
3
|
+
export interface AlertOption {
|
|
4
|
+
position?: Position;
|
|
5
|
+
timeout?: number;
|
|
6
|
+
type?: Type;
|
|
7
|
+
/** CSS string color */
|
|
8
|
+
backgroundColor?: string;
|
|
9
|
+
/** CSS string color */
|
|
10
|
+
color?: string;
|
|
11
|
+
onOpen?: () => void;
|
|
12
|
+
}
|
|
13
|
+
export interface Alert {
|
|
14
|
+
id: string;
|
|
15
|
+
message?: string;
|
|
16
|
+
options: AlertOption;
|
|
17
|
+
close: () => void;
|
|
18
|
+
}
|
|
19
|
+
export interface AlertAPI {
|
|
20
|
+
show: (message?: string, options?: AlertOption) => Alert;
|
|
21
|
+
success: (message?: string, options?: AlertOption) => Alert;
|
|
22
|
+
error: (message?: string, options?: AlertOption) => Alert;
|
|
23
|
+
info: (message?: string, options?: AlertOption) => Alert;
|
|
24
|
+
showLoading: (message?: string, options?: AlertOption) => Promise<() => void>;
|
|
25
|
+
}
|
|
26
|
+
export declare const AlertProvider: import("react").Provider<AlertAPI | null>;
|
|
27
|
+
export declare function useAlert(): AlertAPI;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { createContext, useContext } from 'react';
|
|
2
|
-
const AlertContext = createContext(
|
|
2
|
+
const AlertContext = createContext(null);
|
|
3
3
|
export const AlertProvider = AlertContext.Provider;
|
|
4
4
|
export function useAlert() {
|
|
5
|
-
|
|
5
|
+
const context = useContext(AlertContext);
|
|
6
|
+
if (!context) {
|
|
7
|
+
throw new Error('useAlert should be mount into an AlertProvider');
|
|
8
|
+
}
|
|
9
|
+
return context;
|
|
6
10
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import { Position, Type, Transition as TransitionOption } from '../options';
|
|
2
3
|
interface ProviderProps {
|
|
3
4
|
children: ReactNode;
|
|
4
5
|
offset?: string;
|
|
5
|
-
position?:
|
|
6
|
+
position?: Position;
|
|
6
7
|
timeout?: number;
|
|
7
|
-
type?:
|
|
8
|
-
transition?:
|
|
8
|
+
type?: Type;
|
|
9
|
+
transition?: TransitionOption;
|
|
9
10
|
containerStyle?: CSSProperties;
|
|
10
11
|
wrapperRef?: any;
|
|
11
12
|
context?: {
|
|
@@ -5,7 +5,7 @@ import { createPortal } from 'react-dom';
|
|
|
5
5
|
import { TransitionGroup } from 'react-transition-group';
|
|
6
6
|
import Transition from '../Transition';
|
|
7
7
|
import Wrapper from '../Wrapper';
|
|
8
|
-
import { positions, transitions, types } from '../options';
|
|
8
|
+
import { positions, transitions, types, } from '../options';
|
|
9
9
|
import AlertBlock from './AlertBlock';
|
|
10
10
|
import { AlertProvider } from './Context';
|
|
11
11
|
function Provider({ children, wrapperRef = null, offset = '5px', position = positions.BOTTOM_CENTER, timeout = 3000, type, transition = transitions.FADE, ...props }) {
|
|
@@ -52,10 +52,10 @@ function Provider({ children, wrapperRef = null, offset = '5px', position = posi
|
|
|
52
52
|
id,
|
|
53
53
|
message,
|
|
54
54
|
options: alertOptions,
|
|
55
|
+
close: () => remove(alert),
|
|
55
56
|
};
|
|
56
|
-
alert.close = () => remove(alert);
|
|
57
57
|
if (alert.options.timeout) {
|
|
58
|
-
const timerId = setTimeout(() => {
|
|
58
|
+
const timerId = window.setTimeout(() => {
|
|
59
59
|
remove(alert);
|
|
60
60
|
timersId.current.splice(timersId.current.indexOf(timerId), 1);
|
|
61
61
|
}, alert.options.timeout);
|