nmrium 0.24.1 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/component/1d/Chart1D.js +3 -2
- package/lib/component/1d/FooterBanner.js +1 -1
- package/lib/component/1d/Integral.d.ts +2 -1
- package/lib/component/1d/Integral.js +5 -12
- package/lib/component/1d/IntegralResizable.d.ts +2 -1
- package/lib/component/1d/IntegralResizable.js +21 -16
- package/lib/component/1d/IntegralsSeries.js +3 -3
- package/lib/component/1d/Line.d.ts +2 -2
- package/lib/component/1d/PeakAnnotation.js +5 -4
- package/lib/component/1d/database/DatabaseElements.d.ts +3 -0
- package/lib/component/1d/database/DatabaseElements.js +18 -0
- package/lib/component/1d/database/DatabaseSpectrum.d.ts +3 -0
- package/lib/component/1d/database/DatabaseSpectrum.js +58 -0
- package/lib/component/1d/{ResurrectedDatabaseRanges.d.ts → database/ResurrectedDatabaseRanges.d.ts} +0 -0
- package/lib/component/1d/{ResurrectedDatabaseRanges.js → database/ResurrectedDatabaseRanges.js} +9 -6
- package/lib/component/1d/jCouplingGraph/JGraph.js +4 -10
- package/lib/component/1d/multiAnalysis/AnalysisRange.js +36 -32
- package/lib/component/1d/multiplicityTree/MultiplicityTree.js +5 -5
- package/lib/component/1d/ranges/Range.d.ts +2 -1
- package/lib/component/1d/ranges/Range.js +38 -39
- package/lib/component/1d/ranges/Ranges.js +6 -3
- package/lib/component/1d/tool/XLabelPointer.js +1 -1
- package/lib/component/2d/Chart2D.js +2 -1
- package/lib/component/2d/Contours.js +4 -1
- package/lib/component/2d/FooterBanner.js +1 -1
- package/lib/component/2d/tools/XYLabelPointer.js +1 -1
- package/lib/component/2d/tools/slicing/HorizontalSliceChart.d.ts +2 -2
- package/lib/component/2d/tools/slicing/SliceScale.d.ts +1 -1
- package/lib/component/2d/tools/slicing/VerticalSliceChart.d.ts +2 -2
- package/lib/component/2d/zones/Signal.js +8 -8
- package/lib/component/2d/zones/Zone.js +3 -3
- package/lib/component/EventsTrackers/KeysListenerTracker.js +11 -5
- package/lib/component/NMRium.d.ts +5 -1
- package/lib/component/NMRium.js +28 -32
- package/lib/component/SplitPaneWrapper.d.ts +4 -0
- package/lib/component/SplitPaneWrapper.js +8 -0
- package/lib/component/assignment/AssignmentsContext.d.ts +35 -0
- package/lib/component/assignment/AssignmentsContext.js +83 -0
- package/lib/component/assignment/AssignmentsReducer.d.ts +32 -0
- package/lib/component/assignment/AssignmentsReducer.js +39 -0
- package/lib/component/assignment/actions/initAssignment.d.ts +5 -0
- package/lib/component/assignment/actions/initAssignment.js +62 -0
- package/lib/component/assignment/actions/removeAssignment.d.ts +16 -0
- package/lib/component/assignment/actions/removeAssignment.js +24 -0
- package/lib/component/assignment/actions/setActiveAssignment.d.ts +10 -0
- package/lib/component/assignment/actions/setActiveAssignment.js +8 -0
- package/lib/component/assignment/actions/toggleAssignment.d.ts +7 -0
- package/lib/component/assignment/actions/toggleAssignment.js +44 -0
- package/lib/component/assignment/index.d.ts +0 -18
- package/lib/component/assignment/index.js +12 -266
- package/lib/component/assignment/utilities/filterForIDsWithAssignment.d.ts +2 -0
- package/lib/component/assignment/utilities/filterForIDsWithAssignment.js +3 -0
- package/lib/component/context/GlobalContext.d.ts +15 -3
- package/lib/component/context/GlobalContext.js +1 -1
- package/lib/component/context/PreferencesContext.d.ts +15 -12
- package/lib/component/context/PreferencesContext.js +1 -1
- package/lib/component/elements/ActionButtons.d.ts +10 -0
- package/lib/component/elements/ActionButtons.js +14 -0
- package/lib/component/elements/Button.d.ts +30 -5
- package/lib/component/elements/Button.js +151 -4
- package/lib/component/elements/ColorInput.js +2 -2
- package/lib/component/elements/ContextMenu.d.ts +8 -3
- package/lib/component/elements/ContextMenu.js +6 -6
- package/lib/component/elements/EditableColumn.d.ts +3 -2
- package/lib/component/elements/EditableColumn.js +27 -20
- package/lib/component/elements/Input.d.ts +9 -1
- package/lib/component/elements/Input.js +18 -5
- package/lib/component/elements/ReactTable/Elements/ReactTableRow.d.ts +5 -1
- package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +38 -10
- package/lib/component/elements/ReactTable/ReactTable.d.ts +3 -1
- package/lib/component/elements/ReactTable/ReactTable.js +7 -2
- package/lib/component/elements/ReactTable/Style.d.ts +1 -3
- package/lib/component/elements/ReactTable/Style.js +1 -7
- package/lib/component/elements/Select.d.ts +1 -0
- package/lib/component/elements/Select.js +21 -15
- package/lib/component/elements/ToggleButton.d.ts +2 -1
- package/lib/component/elements/ToggleButton.js +2 -2
- package/lib/component/elements/ToolTip/ToolTip.js +3 -2
- package/lib/component/elements/draggble/SVGDraggable.d.ts +17 -0
- package/lib/component/elements/draggble/SVGDraggable.js +33 -0
- package/lib/component/elements/draggble/useDraggable.d.ts +22 -0
- package/lib/component/elements/draggble/useDraggable.js +70 -0
- package/lib/component/elements/formik/FormikColorPicker.d.ts +1 -0
- package/lib/component/elements/formik/FormikColorPicker.js +10 -7
- package/lib/component/elements/formik/FormikColumnFormatField.d.ts +5 -4
- package/lib/component/elements/formik/FormikColumnFormatField.js +2 -2
- package/lib/component/elements/formik/FormikInput.d.ts +1 -0
- package/lib/component/elements/formik/FormikInput.js +6 -3
- package/lib/component/elements/formik/FormikSlider.d.ts +1 -0
- package/lib/component/elements/formik/FormikSlider.js +6 -3
- package/lib/component/elements/popup/Alert/Provider.js +1 -1
- package/lib/component/elements/resizer/DivResizer.d.ts +2 -0
- package/lib/component/elements/resizer/DivResizer.js +62 -0
- package/lib/component/elements/resizer/Resizer.d.ts +20 -0
- package/lib/component/elements/resizer/Resizer.js +12 -0
- package/lib/component/elements/resizer/SVGResizer.d.ts +2 -0
- package/lib/component/elements/resizer/SVGResizer.js +42 -0
- package/lib/component/elements/resizer/useResizer.d.ts +11 -0
- package/lib/component/elements/resizer/useResizer.js +65 -0
- package/lib/component/header/AutoPeakPickingOptionPanel.js +4 -15
- package/lib/component/header/BaseLineCorrectionPanel.js +2 -9
- package/lib/component/header/ManualPhaseCorrectionPanel.js +2 -9
- package/lib/component/header/RangesPickingOptionPanel.js +3 -16
- package/lib/component/header/ZeroFillingOptionsPanel.js +2 -9
- package/lib/component/header/Zones2DOptionPanel.js +3 -14
- package/lib/component/hooks/useExport.d.ts +1 -1
- package/lib/component/hooks/useExport.js +11 -9
- package/lib/component/hooks/useFormatNumberByNucleus.d.ts +3 -0
- package/lib/component/{utility/FormatNumber.js → hooks/useFormatNumberByNucleus.js} +1 -10
- package/lib/component/hooks/usePanelPreferences.d.ts +7 -0
- package/lib/component/hooks/usePanelPreferences.js +54 -0
- package/lib/component/hooks/useXYReduce.d.ts +2 -2
- package/lib/component/loader/DefaultSpinnerComponent.d.ts +3 -1
- package/lib/component/loader/DefaultSpinnerComponent.js +2 -2
- package/lib/component/loader/DropZone.js +1 -0
- package/lib/component/loader/SpinnerContext.d.ts +3 -3
- package/lib/component/loader/SpinnerContext.js +2 -2
- package/lib/component/modal/AlignSpectraModal.js +2 -1
- package/lib/component/modal/ExportAsMatrixModal.js +2 -1
- package/lib/component/modal/ImportPublicationStringModal.js +2 -1
- package/lib/component/modal/LoadJCAMPModal.js +7 -6
- package/lib/component/modal/ModalStyle.js +4 -26
- package/lib/component/modal/MoleculeStructureEditorModal.d.ts +3 -4
- package/lib/component/modal/MoleculeStructureEditorModal.js +24 -2
- package/lib/component/modal/MultipleSpectraFiltersModal/index.js +2 -1
- package/lib/component/modal/PredictSpectraModal.js +2 -7
- package/lib/component/modal/SaveAsModal.d.ts +1 -1
- package/lib/component/modal/SaveAsModal.js +2 -1
- package/lib/component/modal/editRange/EditRangeModal.js +6 -5
- package/lib/component/modal/editRange/forms/components/AddSignalFormTab.d.ts +2 -0
- package/lib/component/modal/editRange/forms/components/AddSignalFormTab.js +3 -6
- package/lib/component/modal/editRange/forms/components/SignalsForm.d.ts +3 -1
- package/lib/component/modal/editRange/forms/components/SignalsForm.js +12 -9
- package/lib/component/modal/setting/DatabasesTabContent.d.ts +6 -0
- package/lib/component/modal/setting/DatabasesTabContent.js +75 -0
- package/lib/component/modal/setting/DisplayTabContent.js +11 -7
- package/lib/component/modal/setting/FormattingTabContent.js +20 -14
- package/lib/component/modal/setting/GeneralSettings.js +4 -1
- package/lib/component/modal/setting/settingsValidation.d.ts +56 -0
- package/lib/component/modal/setting/settingsValidation.js +46 -0
- package/lib/component/panels/AutomaticAssignment/AutomaticAssignment.js +6 -4
- package/lib/component/panels/AutomaticAssignment/AutomaticAssignmentTable.d.ts +4 -3
- package/lib/component/panels/AutomaticAssignment/AutomaticAssignmentTable.js +13 -6
- package/lib/component/panels/AutomaticAssignment/useAutoAssignments.d.ts +10 -0
- package/lib/component/panels/AutomaticAssignment/useAutoAssignments.js +65 -0
- package/lib/component/panels/IntegralsPanel/IntegralPanel.d.ts +0 -1
- package/lib/component/panels/IntegralsPanel/IntegralPanel.js +2 -5
- package/lib/component/panels/IntegralsPanel/IntegralTable.d.ts +2 -2
- package/lib/component/panels/IntegralsPanel/IntegralTable.js +10 -11
- package/lib/component/panels/IntegralsPanel/IntegralsPreferences.d.ts +1 -1
- package/lib/component/panels/IntegralsPanel/IntegralsPreferences.js +26 -74
- package/lib/component/panels/MoleculesPanel/MoleculeHeader.d.ts +8 -0
- package/lib/component/panels/MoleculesPanel/MoleculeHeader.js +38 -0
- package/lib/component/panels/MoleculesPanel/MoleculePanel.js +12 -23
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +21 -7
- package/lib/component/panels/MoleculesPanel/Utilities.d.ts +31 -11
- package/lib/component/panels/MoleculesPanel/Utilities.js +61 -68
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.d.ts +2 -2
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +55 -60
- package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisTable.js +1 -1
- package/lib/component/panels/Panels.js +2 -3
- package/lib/component/panels/PeaksPanel/PeaksPanel.js +3 -3
- package/lib/component/panels/PeaksPanel/PeaksPreferences.d.ts +1 -1
- package/lib/component/panels/PeaksPanel/PeaksPreferences.js +29 -82
- package/lib/component/panels/PeaksPanel/PeaksTable.d.ts +1 -5
- package/lib/component/panels/PeaksPanel/PeaksTable.js +18 -25
- package/lib/component/panels/RangesPanel/RangesHeader.d.ts +2 -1
- package/lib/component/panels/RangesPanel/RangesHeader.js +16 -10
- package/lib/component/panels/RangesPanel/RangesPanel.js +5 -11
- package/lib/component/panels/RangesPanel/RangesPreferences.d.ts +1 -1
- package/lib/component/panels/RangesPanel/RangesPreferences.js +55 -66
- package/lib/component/panels/RangesPanel/RangesTable.d.ts +11 -6
- package/lib/component/panels/RangesPanel/RangesTable.js +3 -7
- package/lib/component/panels/RangesPanel/RangesTableRow.d.ts +5 -2
- package/lib/component/panels/RangesPanel/RangesTableRow.js +15 -14
- package/lib/component/panels/RangesPanel/TableColumns/AbsoluteColumn.js +2 -2
- package/lib/component/panels/RangesPanel/TableColumns/ActionsColumn.d.ts +2 -1
- package/lib/component/panels/RangesPanel/TableColumns/ActionsColumn.js +2 -2
- package/lib/component/panels/RangesPanel/TableColumns/CouplingColumn.d.ts +2 -1
- package/lib/component/panels/RangesPanel/TableColumns/CouplingColumn.js +5 -2
- package/lib/component/panels/RangesPanel/TableColumns/RangeAssignmentsColumn.d.ts +16 -9
- package/lib/component/panels/RangesPanel/TableColumns/RangeAssignmentsColumn.js +2 -2
- package/lib/component/panels/RangesPanel/TableColumns/RangeColumn.js +2 -2
- package/lib/component/panels/RangesPanel/TableColumns/RelativeColumn.js +2 -2
- package/lib/component/panels/RangesPanel/TableColumns/SignalAssignmentsColumn.d.ts +2 -3
- package/lib/component/panels/RangesPanel/TableColumns/SignalDeltaColumn.d.ts +2 -2
- package/lib/component/panels/RangesPanel/TableColumns/SignalDeltaColumn.js +3 -4
- package/lib/component/panels/RangesPanel/TableColumns/SignalDeltaHzColumn.d.ts +13 -0
- package/lib/component/panels/RangesPanel/TableColumns/SignalDeltaHzColumn.js +14 -0
- package/lib/component/panels/RangesPanel/TableColumns/format.js +2 -2
- package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.js +1 -1
- package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +5 -18
- package/lib/component/panels/SpectrumsPanel/base/setting/PlotChart.d.ts +18 -0
- package/lib/component/panels/SpectrumsPanel/base/setting/PlotChart.js +18 -0
- package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum1DHistogram.d.ts +1 -2
- package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum1DHistogram.js +7 -68
- package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum1DSetting.js +1 -8
- package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum2DHistogram.d.ts +1 -2
- package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum2DHistogram.js +7 -68
- package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum2DSetting.js +8 -21
- package/lib/component/panels/SpectrumsPanel/base/setting/SpectrumSetting.js +2 -2
- package/lib/component/panels/SpectrumsPanel/base/setting/processSnapPlot.d.ts +6 -0
- package/lib/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +51 -0
- package/lib/component/panels/SummaryPanel/CorrelationTable/CorrelationTableRow.js +1 -1
- package/lib/component/panels/SummaryPanel/SummaryPanel.js +1 -1
- package/lib/component/panels/ZonesPanel/TableColumns/ActionsColumn.js +1 -1
- package/lib/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumn.d.ts +5 -7
- package/lib/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumn.js +2 -2
- package/lib/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumns.d.ts +4 -8
- package/lib/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumns.js +1 -1
- package/lib/component/panels/ZonesPanel/TableColumns/SignalDeltaColumn.d.ts +5 -1
- package/lib/component/panels/ZonesPanel/TableColumns/SignalDeltaColumn.js +3 -2
- package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumn.d.ts +5 -9
- package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumn.js +4 -4
- package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumns.d.ts +4 -8
- package/lib/component/panels/ZonesPanel/ZonesPanel.js +1 -1
- package/lib/component/panels/ZonesPanel/ZonesPreferences.d.ts +1 -1
- package/lib/component/panels/ZonesPanel/ZonesPreferences.js +20 -84
- package/lib/component/panels/ZonesPanel/ZonesTable.js +4 -1
- package/lib/component/panels/ZonesPanel/ZonesTableRow.d.ts +7 -2
- package/lib/component/panels/ZonesPanel/ZonesTableRow.js +22 -22
- package/lib/component/panels/databasePanel/DatabasePanel.js +73 -40
- package/lib/component/panels/databasePanel/DatabasePreferences.js +10 -42
- package/lib/component/panels/databasePanel/DatabaseTable.js +23 -11
- package/lib/component/panels/databasePanel/useDatabases.d.ts +5 -0
- package/lib/component/panels/databasePanel/useDatabases.js +10 -0
- package/lib/component/panels/extra/placeholder/NoTableData.d.ts +3 -1
- package/lib/component/panels/extra/placeholder/NoTableData.js +2 -2
- package/lib/component/panels/extra/preferences/ColumnsHelper.js +3 -3
- package/lib/component/panels/extra/preferences/NucleusPreferences.d.ts +13 -0
- package/lib/component/panels/extra/preferences/NucleusPreferences.js +22 -0
- package/lib/component/panels/extra/preferences/PreferencesContainer.d.ts +6 -0
- package/lib/component/panels/extra/preferences/PreferencesContainer.js +10 -0
- package/lib/component/panels/extra/preferences/PreferencesGroup.d.ts +7 -0
- package/lib/component/panels/extra/preferences/PreferencesGroup.js +21 -0
- package/lib/component/panels/header/SpectraAutomaticPickingButton.d.ts +2 -0
- package/lib/component/panels/header/SpectraAutomaticPickingButton.js +30 -0
- package/lib/component/panels/predictionPanel/PredictionOptions.js +2 -18
- package/lib/component/reducer/Reducer.d.ts +360 -45
- package/lib/component/reducer/Reducer.js +9 -2
- package/lib/component/reducer/actions/AssignmentsActions.d.ts +9 -0
- package/lib/component/reducer/actions/AssignmentsActions.js +18 -0
- package/lib/component/reducer/actions/LoadActions.d.ts +1 -1
- package/lib/component/reducer/actions/LoadActions.js +11 -6
- package/lib/component/reducer/actions/MoleculeActions.d.ts +4 -2
- package/lib/component/reducer/actions/MoleculeActions.js +15 -3
- package/lib/component/reducer/actions/PreferencesActions.js +1 -1
- package/lib/component/reducer/actions/ToolsActions.js +1 -1
- package/lib/component/reducer/preferences/actions/addWorkspace.d.ts +3 -0
- package/lib/component/reducer/preferences/actions/addWorkspace.js +19 -0
- package/lib/component/reducer/preferences/actions/initPreferences.d.ts +3 -0
- package/lib/component/reducer/preferences/actions/initPreferences.js +60 -0
- package/lib/component/reducer/preferences/actions/removeWorkspace.d.ts +3 -0
- package/lib/component/reducer/preferences/actions/removeWorkspace.js +20 -0
- package/lib/component/reducer/preferences/actions/resetPreferences.d.ts +3 -0
- package/lib/component/reducer/preferences/actions/resetPreferences.js +14 -0
- package/lib/component/reducer/preferences/actions/setPanelsPreferences.d.ts +3 -0
- package/lib/component/reducer/preferences/actions/setPanelsPreferences.js +13 -0
- package/lib/component/reducer/preferences/actions/setPreferences.d.ts +3 -0
- package/lib/component/reducer/preferences/actions/setPreferences.js +34 -0
- package/lib/component/reducer/preferences/actions/setWorkspace.d.ts +3 -0
- package/lib/component/reducer/preferences/actions/setWorkspace.js +8 -0
- package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.d.ts +7 -0
- package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +55 -0
- package/lib/component/reducer/{preferencesReducer.d.ts → preferences/preferencesReducer.d.ts} +132 -15
- package/lib/component/reducer/preferences/preferencesReducer.js +80 -0
- package/lib/component/reducer/preferences/utilites/checkKeysExists.d.ts +1 -0
- package/lib/component/reducer/preferences/utilites/checkKeysExists.js +14 -0
- package/lib/component/reducer/preferences/utilites/filterObject.d.ts +1 -0
- package/lib/component/reducer/preferences/utilites/filterObject.js +7 -0
- package/lib/component/reducer/preferences/utilites/flatObject.d.ts +1 -0
- package/lib/component/reducer/preferences/utilites/flatObject.js +9 -0
- package/lib/component/reducer/preferences/utilites/getActiveWorkspace.d.ts +3 -0
- package/lib/component/reducer/preferences/utilites/getActiveWorkspace.js +3 -0
- package/lib/component/reducer/preferences/utilites/getPreferencesByWorkspace.d.ts +2 -0
- package/lib/component/reducer/preferences/utilites/getPreferencesByWorkspace.js +4 -0
- package/lib/component/reducer/preferences/utilites/mapNucleiFormatting.d.ts +5 -0
- package/lib/component/reducer/preferences/utilites/mapNucleiFormatting.js +8 -0
- package/lib/component/reducer/types/Types.d.ts +3 -0
- package/lib/component/reducer/types/Types.js +3 -0
- package/lib/component/tool/FloatMoleculeStructures/ActionsButton.d.ts +4 -0
- package/lib/component/tool/FloatMoleculeStructures/ActionsButton.js +7 -0
- package/lib/component/tool/FloatMoleculeStructures/DraggableStructure.d.ts +14 -0
- package/lib/component/tool/FloatMoleculeStructures/DraggableStructure.js +43 -0
- package/lib/component/tool/FloatMoleculeStructures/index.d.ts +15 -0
- package/lib/component/tool/FloatMoleculeStructures/index.js +28 -0
- package/lib/component/utility/Export.d.ts +3 -3
- package/lib/component/utility/Export.js +16 -9
- package/lib/component/utility/PathBuilder.js +2 -1
- package/lib/component/utility/formatNumber.d.ts +3 -0
- package/lib/component/utility/formatNumber.js +10 -0
- package/lib/component/utility/getUniqueNuclei.d.ts +1 -0
- package/lib/component/utility/getUniqueNuclei.js +10 -0
- package/lib/component/workspaces/Workspace.d.ts +74 -5
- package/lib/component/workspaces/basic.js +17 -10
- package/lib/component/workspaces/embedded.d.ts +2 -0
- package/lib/component/workspaces/embedded.js +32 -0
- package/lib/component/workspaces/exercise.js +2 -0
- package/lib/component/workspaces/index.d.ts +1 -0
- package/lib/component/workspaces/index.js +2 -1
- package/lib/component/workspaces/prediction.js +2 -0
- package/lib/component/workspaces/process1D.js +2 -0
- package/lib/data/SpectraManager.js +23 -15
- package/lib/data/data1d/Data1DManager.d.ts +1 -1
- package/lib/data/data1d/Data1DManager.js +6 -1
- package/lib/data/data1d/Spectrum1D/convertDataToFloat64Array.d.ts +2 -0
- package/lib/data/data1d/Spectrum1D/convertDataToFloat64Array.js +10 -0
- package/lib/data/data1d/Spectrum1D/get1DDataXY.d.ts +2 -2
- package/lib/data/data1d/Spectrum1D/initiateDatum1D.js +2 -1
- package/lib/data/data1d/Spectrum1D/peaks/mapPeaks.js +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.js +2 -1
- package/lib/data/data1d/Spectrum1D/toJSON.d.ts +2 -0
- package/lib/data/data1d/Spectrum1D/toJSON.js +1 -0
- package/lib/data/data1d/database.d.ts +9 -15
- package/lib/data/data1d/database.js +15 -20
- package/lib/data/data1d/filter1d/absolute.d.ts +3 -2
- package/lib/data/data1d/filter1d/autoPhaseCorrection.d.ts +3 -2
- package/lib/data/data1d/filter1d/baselineCorrection.d.ts +3 -2
- package/lib/data/data1d/filter1d/centerMean.d.ts +3 -2
- package/lib/data/data1d/filter1d/digitalFilter.d.ts +3 -2
- package/lib/data/data1d/filter1d/equallySpaced.d.ts +3 -2
- package/lib/data/data1d/filter1d/exclusionZones.d.ts +1 -4
- package/lib/data/data1d/filter1d/exclusionZones.js +4 -4
- package/lib/data/data1d/filter1d/fft.d.ts +3 -2
- package/lib/data/data1d/filter1d/fft.js +2 -2
- package/lib/data/data1d/filter1d/fromTo.d.ts +3 -2
- package/lib/data/data1d/filter1d/lineBroadening.d.ts +3 -2
- package/lib/data/data1d/filter1d/lineBroadening.js +1 -1
- package/lib/data/data1d/filter1d/pareto.d.ts +3 -2
- package/lib/data/data1d/filter1d/pareto.js +2 -2
- package/lib/data/data1d/filter1d/phaseCorrection.d.ts +3 -2
- package/lib/data/data1d/filter1d/shiftX.d.ts +2 -1
- package/lib/data/data1d/filter1d/standardDeviation.d.ts +3 -2
- package/lib/data/data1d/filter1d/zeroFilling.d.ts +3 -2
- package/lib/data/data1d/filter1d/zeroFilling.js +1 -1
- package/lib/data/data2d/Data2DManager.d.ts +1 -1
- package/lib/data/data2d/Data2DManager.js +6 -1
- package/lib/data/data2d/Spectrum2D/toJSON.d.ts +2 -0
- package/lib/data/data2d/Spectrum2D/toJSON.js +1 -0
- package/lib/data/data2d/filter2d/shiftX.d.ts +4 -3
- package/lib/data/data2d/filter2d/shiftX.js +2 -2
- package/lib/data/data2d/filter2d/shiftY.d.ts +4 -3
- package/lib/data/data2d/filter2d/shiftY.js +2 -2
- package/lib/data/molecules/Molecule.d.ts +3 -3
- package/lib/data/molecules/Molecule.js +7 -1
- package/lib/data/molecules/MoleculeManager.d.ts +4 -1
- package/lib/data/molecules/MoleculeManager.js +33 -2
- package/lib/data/types/common/Source.d.ts +1 -0
- package/lib/data/types/data1d/Data1D.d.ts +3 -3
- package/lib/data/types/data1d/Info1D.d.ts +1 -0
- package/lib/data/types/data2d/Signal2DAxisData.d.ts +1 -1
- package/lib/versionInfo.js +1 -1
- package/lib-cjs/component/1d/Chart1D.js +3 -2
- package/lib-cjs/component/1d/FooterBanner.js +2 -2
- package/lib-cjs/component/1d/Integral.js +5 -12
- package/lib-cjs/component/1d/IntegralResizable.js +20 -15
- package/lib-cjs/component/1d/IntegralsSeries.js +3 -3
- package/lib-cjs/component/1d/PeakAnnotation.js +5 -4
- package/lib-cjs/component/1d/database/DatabaseElements.js +23 -0
- package/lib-cjs/component/1d/database/DatabaseSpectrum.js +60 -0
- package/lib-cjs/component/1d/{ResurrectedDatabaseRanges.js → database/ResurrectedDatabaseRanges.js} +9 -6
- package/lib-cjs/component/1d/jCouplingGraph/JGraph.js +4 -10
- package/lib-cjs/component/1d/multiAnalysis/AnalysisRange.js +35 -31
- package/lib-cjs/component/1d/multiplicityTree/MultiplicityTree.js +6 -6
- package/lib-cjs/component/1d/ranges/Range.js +40 -41
- package/lib-cjs/component/1d/ranges/Ranges.js +6 -3
- package/lib-cjs/component/1d/tool/XLabelPointer.js +2 -2
- package/lib-cjs/component/2d/Chart2D.js +2 -1
- package/lib-cjs/component/2d/Contours.js +4 -1
- package/lib-cjs/component/2d/FooterBanner.js +2 -2
- package/lib-cjs/component/2d/tools/XYLabelPointer.js +2 -2
- package/lib-cjs/component/2d/zones/Signal.js +9 -9
- package/lib-cjs/component/2d/zones/Zone.js +4 -4
- package/lib-cjs/component/EventsTrackers/KeysListenerTracker.js +12 -6
- package/lib-cjs/component/NMRium.js +27 -31
- package/lib-cjs/component/SplitPaneWrapper.js +12 -0
- package/lib-cjs/component/assignment/AssignmentsContext.js +88 -0
- package/lib-cjs/component/assignment/AssignmentsReducer.js +45 -0
- package/lib-cjs/component/assignment/actions/initAssignment.js +65 -0
- package/lib-cjs/component/assignment/actions/removeAssignment.js +29 -0
- package/lib-cjs/component/assignment/actions/setActiveAssignment.js +11 -0
- package/lib-cjs/component/assignment/actions/toggleAssignment.js +47 -0
- package/lib-cjs/component/assignment/index.js +15 -269
- package/lib-cjs/component/assignment/utilities/filterForIDsWithAssignment.js +7 -0
- package/lib-cjs/component/context/GlobalContext.js +1 -1
- package/lib-cjs/component/context/PreferencesContext.js +1 -1
- package/lib-cjs/component/elements/ActionButtons.js +20 -0
- package/lib-cjs/component/elements/Button.js +150 -4
- package/lib-cjs/component/elements/ColorInput.js +2 -2
- package/lib-cjs/component/elements/ContextMenu.js +6 -6
- package/lib-cjs/component/elements/EditableColumn.js +27 -20
- package/lib-cjs/component/elements/Input.js +18 -5
- package/lib-cjs/component/elements/ReactTable/Elements/ReactTableRow.js +42 -14
- package/lib-cjs/component/elements/ReactTable/ReactTable.js +7 -2
- package/lib-cjs/component/elements/ReactTable/Style.js +1 -9
- package/lib-cjs/component/elements/Select.js +20 -14
- package/lib-cjs/component/elements/ToggleButton.js +2 -2
- package/lib-cjs/component/elements/ToolTip/ToolTip.js +3 -2
- package/lib-cjs/component/elements/draggble/SVGDraggable.js +39 -0
- package/lib-cjs/component/elements/draggble/useDraggable.js +73 -0
- package/lib-cjs/component/elements/formik/FormikColorPicker.js +10 -7
- package/lib-cjs/component/elements/formik/FormikColumnFormatField.js +2 -2
- package/lib-cjs/component/elements/formik/FormikInput.js +6 -3
- package/lib-cjs/component/elements/formik/FormikSlider.js +6 -3
- package/lib-cjs/component/elements/popup/Alert/Provider.js +1 -1
- package/lib-cjs/component/elements/resizer/DivResizer.js +68 -0
- package/lib-cjs/component/elements/resizer/Resizer.js +18 -0
- package/lib-cjs/component/elements/resizer/SVGResizer.js +48 -0
- package/lib-cjs/component/elements/resizer/useResizer.js +71 -0
- package/lib-cjs/component/header/AutoPeakPickingOptionPanel.js +3 -14
- package/lib-cjs/component/header/BaseLineCorrectionPanel.js +2 -9
- package/lib-cjs/component/header/ManualPhaseCorrectionPanel.js +2 -9
- package/lib-cjs/component/header/RangesPickingOptionPanel.js +2 -15
- package/lib-cjs/component/header/ZeroFillingOptionsPanel.js +2 -9
- package/lib-cjs/component/header/Zones2DOptionPanel.js +2 -13
- package/lib-cjs/component/hooks/useExport.js +11 -9
- package/lib-cjs/component/{utility/FormatNumber.js → hooks/useFormatNumberByNucleus.js} +2 -12
- package/lib-cjs/component/hooks/usePanelPreferences.js +62 -0
- package/lib-cjs/component/loader/DefaultSpinnerComponent.js +2 -2
- package/lib-cjs/component/loader/DropZone.js +1 -0
- package/lib-cjs/component/loader/SpinnerContext.js +2 -2
- package/lib-cjs/component/modal/AlignSpectraModal.js +2 -1
- package/lib-cjs/component/modal/ExportAsMatrixModal.js +2 -1
- package/lib-cjs/component/modal/ImportPublicationStringModal.js +2 -1
- package/lib-cjs/component/modal/LoadJCAMPModal.js +7 -6
- package/lib-cjs/component/modal/ModalStyle.js +4 -26
- package/lib-cjs/component/modal/MoleculeStructureEditorModal.js +29 -2
- package/lib-cjs/component/modal/MultipleSpectraFiltersModal/index.js +2 -1
- package/lib-cjs/component/modal/PredictSpectraModal.js +2 -7
- package/lib-cjs/component/modal/SaveAsModal.js +2 -1
- package/lib-cjs/component/modal/editRange/EditRangeModal.js +6 -5
- package/lib-cjs/component/modal/editRange/forms/components/AddSignalFormTab.js +3 -6
- package/lib-cjs/component/modal/editRange/forms/components/SignalsForm.js +12 -9
- package/lib-cjs/component/modal/setting/DatabasesTabContent.js +80 -0
- package/lib-cjs/component/modal/setting/DisplayTabContent.js +11 -7
- package/lib-cjs/component/modal/setting/FormattingTabContent.js +19 -13
- package/lib-cjs/component/modal/setting/GeneralSettings.js +4 -1
- package/lib-cjs/component/modal/setting/settingsValidation.js +72 -0
- package/lib-cjs/component/panels/AutomaticAssignment/AutomaticAssignment.js +6 -4
- package/lib-cjs/component/panels/AutomaticAssignment/AutomaticAssignmentTable.js +13 -6
- package/lib-cjs/component/panels/AutomaticAssignment/useAutoAssignments.js +72 -0
- package/lib-cjs/component/panels/IntegralsPanel/IntegralPanel.js +2 -5
- package/lib-cjs/component/panels/IntegralsPanel/IntegralTable.js +10 -11
- package/lib-cjs/component/panels/IntegralsPanel/IntegralsPreferences.js +24 -72
- package/lib-cjs/component/panels/MoleculesPanel/MoleculeHeader.js +44 -0
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanel.js +12 -23
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +21 -7
- package/lib-cjs/component/panels/MoleculesPanel/Utilities.js +61 -68
- package/lib-cjs/component/panels/MoleculesPanel/useAtomAssignment.js +55 -60
- package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisTable.js +2 -2
- package/lib-cjs/component/panels/Panels.js +2 -3
- package/lib-cjs/component/panels/PeaksPanel/PeaksPanel.js +4 -4
- package/lib-cjs/component/panels/PeaksPanel/PeaksPreferences.js +27 -80
- package/lib-cjs/component/panels/PeaksPanel/PeaksTable.js +18 -48
- package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +17 -11
- package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +6 -12
- package/lib-cjs/component/panels/RangesPanel/RangesPreferences.js +53 -64
- package/lib-cjs/component/panels/RangesPanel/RangesTable.js +3 -7
- package/lib-cjs/component/panels/RangesPanel/RangesTableRow.js +18 -17
- package/lib-cjs/component/panels/RangesPanel/TableColumns/AbsoluteColumn.js +2 -5
- package/lib-cjs/component/panels/RangesPanel/TableColumns/ActionsColumn.js +2 -2
- package/lib-cjs/component/panels/RangesPanel/TableColumns/CouplingColumn.js +5 -2
- package/lib-cjs/component/panels/RangesPanel/TableColumns/RangeAssignmentsColumn.js +2 -2
- package/lib-cjs/component/panels/RangesPanel/TableColumns/RangeColumn.js +2 -5
- package/lib-cjs/component/panels/RangesPanel/TableColumns/RelativeColumn.js +2 -2
- package/lib-cjs/component/panels/RangesPanel/TableColumns/SignalDeltaColumn.js +3 -4
- package/lib-cjs/component/panels/RangesPanel/TableColumns/SignalDeltaHzColumn.js +16 -0
- package/lib-cjs/component/panels/RangesPanel/TableColumns/format.js +2 -2
- package/lib-cjs/component/panels/RangesPanel/hooks/useEditRangeModal.js +2 -2
- package/lib-cjs/component/panels/SpectrumsPanel/SpectraPanelHeader.js +3 -16
- package/lib-cjs/component/panels/SpectrumsPanel/base/setting/PlotChart.js +21 -0
- package/lib-cjs/component/panels/SpectrumsPanel/base/setting/Spectrum1DHistogram.js +10 -68
- package/lib-cjs/component/panels/SpectrumsPanel/base/setting/Spectrum1DSetting.js +1 -8
- package/lib-cjs/component/panels/SpectrumsPanel/base/setting/Spectrum2DHistogram.js +10 -68
- package/lib-cjs/component/panels/SpectrumsPanel/base/setting/Spectrum2DSetting.js +8 -21
- package/lib-cjs/component/panels/SpectrumsPanel/base/setting/SpectrumSetting.js +2 -2
- package/lib-cjs/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +55 -0
- package/lib-cjs/component/panels/SummaryPanel/CorrelationTable/CorrelationTableRow.js +1 -1
- package/lib-cjs/component/panels/SummaryPanel/SummaryPanel.js +2 -2
- package/lib-cjs/component/panels/ZonesPanel/TableColumns/ActionsColumn.js +2 -2
- package/lib-cjs/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumn.js +2 -2
- package/lib-cjs/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumns.js +1 -1
- package/lib-cjs/component/panels/ZonesPanel/TableColumns/SignalDeltaColumn.js +3 -2
- package/lib-cjs/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumn.js +4 -4
- package/lib-cjs/component/panels/ZonesPanel/ZonesPanel.js +2 -2
- package/lib-cjs/component/panels/ZonesPanel/ZonesPreferences.js +18 -82
- package/lib-cjs/component/panels/ZonesPanel/ZonesTable.js +4 -1
- package/lib-cjs/component/panels/ZonesPanel/ZonesTableRow.js +23 -23
- package/lib-cjs/component/panels/databasePanel/DatabasePanel.js +72 -39
- package/lib-cjs/component/panels/databasePanel/DatabasePreferences.js +10 -42
- package/lib-cjs/component/panels/databasePanel/DatabaseTable.js +22 -10
- package/lib-cjs/component/panels/databasePanel/useDatabases.js +14 -0
- package/lib-cjs/component/panels/extra/placeholder/NoTableData.js +2 -2
- package/lib-cjs/component/panels/extra/preferences/ColumnsHelper.js +3 -3
- package/lib-cjs/component/panels/extra/preferences/NucleusPreferences.js +29 -0
- package/lib-cjs/component/panels/extra/preferences/PreferencesContainer.js +14 -0
- package/lib-cjs/component/panels/extra/preferences/PreferencesGroup.js +25 -0
- package/lib-cjs/component/panels/header/SpectraAutomaticPickingButton.js +37 -0
- package/lib-cjs/component/panels/predictionPanel/PredictionOptions.js +2 -18
- package/lib-cjs/component/reducer/Reducer.js +9 -2
- package/lib-cjs/component/reducer/actions/AssignmentsActions.js +21 -0
- package/lib-cjs/component/reducer/actions/LoadActions.js +10 -5
- package/lib-cjs/component/reducer/actions/MoleculeActions.js +17 -3
- package/lib-cjs/component/reducer/actions/PreferencesActions.js +1 -1
- package/lib-cjs/component/reducer/actions/ToolsActions.js +1 -1
- package/lib-cjs/component/reducer/preferences/actions/addWorkspace.js +26 -0
- package/lib-cjs/component/reducer/preferences/actions/initPreferences.js +67 -0
- package/lib-cjs/component/reducer/preferences/actions/removeWorkspace.js +24 -0
- package/lib-cjs/component/reducer/preferences/actions/resetPreferences.js +18 -0
- package/lib-cjs/component/reducer/preferences/actions/setPanelsPreferences.js +17 -0
- package/lib-cjs/component/reducer/preferences/actions/setPreferences.js +38 -0
- package/lib-cjs/component/reducer/preferences/actions/setWorkspace.js +12 -0
- package/lib-cjs/component/reducer/preferences/panelsPreferencesDefaultValues.js +62 -0
- package/lib-cjs/component/reducer/preferences/preferencesReducer.js +87 -0
- package/lib-cjs/component/reducer/preferences/utilites/checkKeysExists.js +18 -0
- package/lib-cjs/component/reducer/preferences/utilites/filterObject.js +11 -0
- package/lib-cjs/component/reducer/preferences/utilites/flatObject.js +13 -0
- package/lib-cjs/component/reducer/preferences/utilites/getActiveWorkspace.js +7 -0
- package/lib-cjs/component/reducer/preferences/utilites/getPreferencesByWorkspace.js +11 -0
- package/lib-cjs/component/reducer/preferences/utilites/mapNucleiFormatting.js +12 -0
- package/lib-cjs/component/reducer/types/Types.js +6 -3
- package/lib-cjs/component/tool/FloatMoleculeStructures/ActionsButton.js +13 -0
- package/lib-cjs/component/tool/FloatMoleculeStructures/DraggableStructure.js +50 -0
- package/lib-cjs/component/tool/FloatMoleculeStructures/index.js +36 -0
- package/lib-cjs/component/utility/Export.js +16 -9
- package/lib-cjs/component/utility/PathBuilder.js +2 -1
- package/lib-cjs/component/utility/formatNumber.js +17 -0
- package/lib-cjs/component/utility/getUniqueNuclei.js +14 -0
- package/lib-cjs/component/workspaces/basic.js +17 -10
- package/lib-cjs/component/workspaces/embedded.js +35 -0
- package/lib-cjs/component/workspaces/exercise.js +2 -0
- package/lib-cjs/component/workspaces/index.js +2 -1
- package/lib-cjs/component/workspaces/prediction.js +2 -0
- package/lib-cjs/component/workspaces/process1D.js +2 -0
- package/lib-cjs/data/SpectraManager.js +23 -15
- package/lib-cjs/data/data1d/Data1DManager.js +6 -1
- package/lib-cjs/data/data1d/Spectrum1D/convertDataToFloat64Array.js +14 -0
- package/lib-cjs/data/data1d/Spectrum1D/initiateDatum1D.js +2 -1
- package/lib-cjs/data/data1d/Spectrum1D/peaks/mapPeaks.js +1 -1
- package/lib-cjs/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.js +2 -1
- package/lib-cjs/data/data1d/Spectrum1D/toJSON.js +1 -0
- package/lib-cjs/data/data1d/database.js +15 -21
- package/lib-cjs/data/data1d/filter1d/exclusionZones.js +4 -4
- package/lib-cjs/data/data1d/filter1d/fft.js +2 -2
- package/lib-cjs/data/data1d/filter1d/lineBroadening.js +1 -1
- package/lib-cjs/data/data1d/filter1d/pareto.js +2 -2
- package/lib-cjs/data/data1d/filter1d/shiftX.js +2 -2
- package/lib-cjs/data/data1d/filter1d/zeroFilling.js +1 -1
- package/lib-cjs/data/data2d/Data2DManager.js +6 -1
- package/lib-cjs/data/data2d/Spectrum2D/toJSON.js +1 -0
- package/lib-cjs/data/data2d/filter2d/shiftX.js +4 -4
- package/lib-cjs/data/data2d/filter2d/shiftY.js +4 -4
- package/lib-cjs/data/molecules/Molecule.js +7 -1
- package/lib-cjs/data/molecules/MoleculeManager.js +37 -3
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +49 -48
- package/lib/component/1d/Resizable.d.ts +0 -12
- package/lib/component/1d/Resizable.js +0 -105
- package/lib/component/panels/extra/preferences/defaultValues.d.ts +0 -54
- package/lib/component/panels/extra/preferences/defaultValues.js +0 -54
- package/lib/component/reducer/preferencesReducer.js +0 -272
- package/lib/component/utility/FormatNumber.d.ts +0 -6
- package/lib-cjs/component/1d/Resizable.js +0 -110
- package/lib-cjs/component/panels/extra/preferences/defaultValues.js +0 -61
- package/lib-cjs/component/reducer/preferencesReducer.js +0 -279
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { createContext, useCallback, useContext, useMemo } from 'react';
|
|
2
|
+
export const assignmentState = {
|
|
3
|
+
assignments: {},
|
|
4
|
+
activated: null,
|
|
5
|
+
highlighted: null,
|
|
6
|
+
};
|
|
7
|
+
export const assignmentContext = createContext({
|
|
8
|
+
data: assignmentState,
|
|
9
|
+
dispatch: () => null,
|
|
10
|
+
});
|
|
11
|
+
export const AssignmentProvider = assignmentContext.Provider;
|
|
12
|
+
export function useAssignmentData() {
|
|
13
|
+
const context = useContext(assignmentContext);
|
|
14
|
+
if (!context) {
|
|
15
|
+
throw new Error('Assignment context was not found');
|
|
16
|
+
}
|
|
17
|
+
return context;
|
|
18
|
+
}
|
|
19
|
+
// key can be signal id,range id or zone id
|
|
20
|
+
export function useAssignment(key) {
|
|
21
|
+
const { data: { activated, highlighted, assignments }, dispatch, } = useAssignmentData();
|
|
22
|
+
if ((typeof key !== 'string' && typeof key !== 'number') || key === '') {
|
|
23
|
+
throw new Error(`assignment key must be a non-empty string or number`);
|
|
24
|
+
}
|
|
25
|
+
const id = String(key);
|
|
26
|
+
const isActive = useMemo(() => {
|
|
27
|
+
return activated?.id === id;
|
|
28
|
+
}, [activated?.id, id]);
|
|
29
|
+
const isOver = useMemo(() => {
|
|
30
|
+
return highlighted?.id === id;
|
|
31
|
+
}, [highlighted?.id, id]);
|
|
32
|
+
const assigned = useMemo(() => {
|
|
33
|
+
return assignments[id] || null;
|
|
34
|
+
}, [assignments, id]);
|
|
35
|
+
const removeAll = useCallback((axis) => {
|
|
36
|
+
dispatch({
|
|
37
|
+
type: 'REMOVE',
|
|
38
|
+
payload: { ids: [id], axis },
|
|
39
|
+
});
|
|
40
|
+
}, [dispatch, id]);
|
|
41
|
+
const toggle = useCallback((atomIDs, dimension) => {
|
|
42
|
+
dispatch({
|
|
43
|
+
type: 'TOGGLE',
|
|
44
|
+
payload: { atomIDs, id, dimension },
|
|
45
|
+
});
|
|
46
|
+
}, [dispatch, id]);
|
|
47
|
+
const setActive = useCallback((axis) => {
|
|
48
|
+
dispatch({
|
|
49
|
+
type: 'SET_ACTIVE',
|
|
50
|
+
payload: {
|
|
51
|
+
id,
|
|
52
|
+
axis,
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
}, [dispatch, id]);
|
|
56
|
+
const show = useCallback((axis) => {
|
|
57
|
+
dispatch({
|
|
58
|
+
type: 'SHOW',
|
|
59
|
+
payload: {
|
|
60
|
+
id,
|
|
61
|
+
axis,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}, [dispatch, id]);
|
|
65
|
+
const hide = useCallback(() => {
|
|
66
|
+
dispatch({
|
|
67
|
+
type: 'HIDE',
|
|
68
|
+
});
|
|
69
|
+
}, [dispatch]);
|
|
70
|
+
return {
|
|
71
|
+
id,
|
|
72
|
+
activated,
|
|
73
|
+
isActive,
|
|
74
|
+
isOver,
|
|
75
|
+
highlighted,
|
|
76
|
+
assigned,
|
|
77
|
+
removeAll,
|
|
78
|
+
toggle,
|
|
79
|
+
setActive,
|
|
80
|
+
show,
|
|
81
|
+
hide,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Data1D } from '../../data/types/data1d';
|
|
2
|
+
import { Data2D } from '../../data/types/data2d';
|
|
3
|
+
import { ActionType } from '../reducer/types/Types';
|
|
4
|
+
import { AssignmentDimension, AssignmentState, Axis } from './AssignmentsContext';
|
|
5
|
+
export declare type InitiateAction = ActionType<'INITIATE_ASSIGNMENTS', {
|
|
6
|
+
spectra: (Data1D | Data2D)[];
|
|
7
|
+
}>;
|
|
8
|
+
export declare type ToggleAction = ActionType<'TOGGLE', {
|
|
9
|
+
atomIDs: string[];
|
|
10
|
+
id: string;
|
|
11
|
+
dimension: AssignmentDimension;
|
|
12
|
+
}>;
|
|
13
|
+
export declare type AddAction = ActionType<'ADD', {
|
|
14
|
+
id: string;
|
|
15
|
+
atomID: string;
|
|
16
|
+
axis: Axis;
|
|
17
|
+
}>;
|
|
18
|
+
export declare type RemoveAction = ActionType<'REMOVE', {
|
|
19
|
+
ids: string[];
|
|
20
|
+
atomID?: string;
|
|
21
|
+
axis: Axis;
|
|
22
|
+
}>;
|
|
23
|
+
export declare type SetActiveAction = ActionType<'SET_ACTIVE', {
|
|
24
|
+
id: string;
|
|
25
|
+
axis: Axis;
|
|
26
|
+
}>;
|
|
27
|
+
export declare type ShowAction = ActionType<'SHOW', {
|
|
28
|
+
id: string;
|
|
29
|
+
axis?: Axis;
|
|
30
|
+
}>;
|
|
31
|
+
export declare type AssignmentsActions = InitiateAction | ToggleAction | AddAction | RemoveAction | SetActiveAction | ShowAction | ActionType<'HIDE'>;
|
|
32
|
+
export default function assignmentReducer(state: AssignmentState, action: AssignmentsActions): AssignmentState;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import initAssignment from './actions/initAssignment';
|
|
2
|
+
import removeAssignments from './actions/removeAssignment';
|
|
3
|
+
import setActiveAssignment from './actions/setActiveAssignment';
|
|
4
|
+
import toggleAssignment from './actions/toggleAssignment';
|
|
5
|
+
export default function assignmentReducer(state, action) {
|
|
6
|
+
switch (action.type) {
|
|
7
|
+
case 'INITIATE_ASSIGNMENTS': {
|
|
8
|
+
return initAssignment(action);
|
|
9
|
+
}
|
|
10
|
+
case 'REMOVE': {
|
|
11
|
+
const { axis, ids, atomID } = action.payload;
|
|
12
|
+
return removeAssignments(state, { axis, ids, atomID });
|
|
13
|
+
}
|
|
14
|
+
case 'TOGGLE': {
|
|
15
|
+
return toggleAssignment(state, action);
|
|
16
|
+
}
|
|
17
|
+
case 'SET_ACTIVE': {
|
|
18
|
+
return setActiveAssignment(state, action);
|
|
19
|
+
}
|
|
20
|
+
case 'SHOW': {
|
|
21
|
+
const { id, axis } = action.payload;
|
|
22
|
+
return {
|
|
23
|
+
...state,
|
|
24
|
+
highlighted: {
|
|
25
|
+
id,
|
|
26
|
+
axis: axis || null,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
case 'HIDE': {
|
|
31
|
+
return {
|
|
32
|
+
...state,
|
|
33
|
+
highlighted: null,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
default:
|
|
37
|
+
return state;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { isSpectrum1D } from '../../../data/data1d/Spectrum1D';
|
|
2
|
+
import { assignmentState } from '../AssignmentsContext';
|
|
3
|
+
export default function initAssignment(action) {
|
|
4
|
+
const newState = {
|
|
5
|
+
...assignmentState,
|
|
6
|
+
};
|
|
7
|
+
const spectra = (action.payload.spectra || []);
|
|
8
|
+
for (const spectrum of spectra) {
|
|
9
|
+
if (isSpectrum1D(spectrum)) {
|
|
10
|
+
setRangesAssignments(newState, spectrum.ranges);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
setZonesAssignments(newState, spectrum.zones);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return newState;
|
|
17
|
+
}
|
|
18
|
+
function setRangesAssignments(state, ranges) {
|
|
19
|
+
const diaIDRecords = ranges.values.reduce((acc, { id, diaIDs, signals }) => {
|
|
20
|
+
acc.push({ id, diaIDs: diaIDs || [] });
|
|
21
|
+
for (const signal of signals) {
|
|
22
|
+
acc.push({ id: signal.id, diaIDs: signal.diaIDs || [] });
|
|
23
|
+
}
|
|
24
|
+
return acc;
|
|
25
|
+
}, []);
|
|
26
|
+
for (const { id, diaIDs } of diaIDRecords) {
|
|
27
|
+
for (const diaID of diaIDs) {
|
|
28
|
+
setAssignment(state, id, 'x', diaID);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function setZonesAssignments(state, zones) {
|
|
33
|
+
const diaIDRecords = zones.values.reduce((acc, { id, x, y, signals }) => {
|
|
34
|
+
acc.push({ id, diaIDs: { x: x.diaIDs || [], y: y.diaIDs || [] } });
|
|
35
|
+
for (const signal of signals) {
|
|
36
|
+
acc.push({
|
|
37
|
+
id: signal.id,
|
|
38
|
+
diaIDs: { x: signal.x.diaIDs || [], y: signal.y.diaIDs || [] },
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return acc;
|
|
42
|
+
}, []);
|
|
43
|
+
for (const { id, diaIDs } of diaIDRecords) {
|
|
44
|
+
['x', 'y'].forEach((axis) => {
|
|
45
|
+
for (const diaID of diaIDs[axis]) {
|
|
46
|
+
setAssignment(state, id, axis, diaID);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function setAssignment(state, id, axis, diaID) {
|
|
52
|
+
if (Array.isArray(state.assignments?.[id]?.[axis]) &&
|
|
53
|
+
!state.assignments[id][axis].includes(diaID)) {
|
|
54
|
+
state.assignments[id][axis].push(diaID);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
state.assignments = {
|
|
58
|
+
...state.assignments,
|
|
59
|
+
[id]: { ...state.assignments[id], [axis]: [diaID] },
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AssignmentState, Axis } from '../AssignmentsContext';
|
|
2
|
+
interface RemoveAction {
|
|
3
|
+
ids: string[];
|
|
4
|
+
atomID?: string;
|
|
5
|
+
axis: Axis;
|
|
6
|
+
}
|
|
7
|
+
interface AssignmentRemoveOptions extends Omit<RemoveAction, 'ids'> {
|
|
8
|
+
id: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function removeAssignment(state: AssignmentState, options: AssignmentRemoveOptions): void;
|
|
11
|
+
export default function removeAssignments(state: AssignmentState, action: RemoveAction): {
|
|
12
|
+
assignments: import("../AssignmentsContext").Assignments;
|
|
13
|
+
activated: import("../AssignmentsContext").AssignmentAction | null;
|
|
14
|
+
highlighted: import("../AssignmentsContext").AssignmentAction | null;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export function removeAssignment(state, options) {
|
|
2
|
+
const { id, atomID = '', axis } = options;
|
|
3
|
+
const atomIDs = state.assignments?.[id]?.[axis] || null;
|
|
4
|
+
if (atomIDs) {
|
|
5
|
+
if (atomID) {
|
|
6
|
+
atomIDs.filter((id) => id !== atomID);
|
|
7
|
+
state.assignments[id][axis] = atomIDs;
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
state.assignments[id][axis] = [];
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export default function removeAssignments(state, action) {
|
|
15
|
+
const newState = {
|
|
16
|
+
...state,
|
|
17
|
+
};
|
|
18
|
+
// signal id
|
|
19
|
+
const { ids, atomID = '', axis } = action;
|
|
20
|
+
for (const id of ids) {
|
|
21
|
+
removeAssignment(newState, { id, atomID, axis });
|
|
22
|
+
}
|
|
23
|
+
return newState;
|
|
24
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AssignmentState } from '../AssignmentsContext';
|
|
2
|
+
import { SetActiveAction } from '../AssignmentsReducer';
|
|
3
|
+
export default function setActiveAssignment(state: AssignmentState, action: SetActiveAction): {
|
|
4
|
+
activated: {
|
|
5
|
+
id: string;
|
|
6
|
+
axis: import("../AssignmentsContext").Axis;
|
|
7
|
+
} | null;
|
|
8
|
+
assignments: import("../AssignmentsContext").Assignments;
|
|
9
|
+
highlighted: import("../AssignmentsContext").AssignmentAction | null;
|
|
10
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AssignmentState } from '../AssignmentsContext';
|
|
2
|
+
import { ToggleAction } from '../AssignmentsReducer';
|
|
3
|
+
export default function ToggleAssignments(state: AssignmentState, action: ToggleAction): {
|
|
4
|
+
assignments: import("../AssignmentsContext").Assignments;
|
|
5
|
+
activated: import("../AssignmentsContext").AssignmentAction | null;
|
|
6
|
+
highlighted: import("../AssignmentsContext").AssignmentAction | null;
|
|
7
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { removeAssignment } from './removeAssignment';
|
|
2
|
+
function addAssignment(state, action) {
|
|
3
|
+
const { id, atomID, axis, dimension } = action;
|
|
4
|
+
const assignment = state.assignments?.[id] || null;
|
|
5
|
+
const axisAssignments = assignment?.[axis] || null;
|
|
6
|
+
// avoid duplicates
|
|
7
|
+
if (axisAssignments) {
|
|
8
|
+
if (!axisAssignments.includes(id)) {
|
|
9
|
+
axisAssignments.push(atomID);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
const otherAxis = axis === 'x' ? 'y' : 'x';
|
|
14
|
+
state.assignments = {
|
|
15
|
+
...state.assignments,
|
|
16
|
+
[id]: {
|
|
17
|
+
...state.assignments[id],
|
|
18
|
+
[axis]: [atomID],
|
|
19
|
+
...(dimension === '2D' && {
|
|
20
|
+
[otherAxis]: assignment?.[otherAxis] ? assignment[otherAxis] : [],
|
|
21
|
+
}),
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export default function ToggleAssignments(state, action) {
|
|
27
|
+
const newState = {
|
|
28
|
+
...state,
|
|
29
|
+
};
|
|
30
|
+
const { id, atomIDs: atomsKeys, dimension } = action.payload;
|
|
31
|
+
const axis = state.activated?.axis;
|
|
32
|
+
if (axis) {
|
|
33
|
+
const atomIDs = state.assignments?.[id]?.[axis] || [];
|
|
34
|
+
for (const atomID of atomsKeys) {
|
|
35
|
+
if (!atomIDs.includes(id)) {
|
|
36
|
+
addAssignment(newState, { axis, id, atomID, dimension });
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
removeAssignment(newState, { atomID, axis, id });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return newState;
|
|
44
|
+
}
|
|
@@ -1,20 +1,2 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export declare function AssignmentProvider(props: any): JSX.Element;
|
|
3
|
-
export declare function useAssignmentData(): any;
|
|
4
|
-
export declare function useAssignment(key: any): {
|
|
5
|
-
id: string;
|
|
6
|
-
isActive: any;
|
|
7
|
-
activeAxis: any;
|
|
8
|
-
assigned: any;
|
|
9
|
-
add: (_id: any) => void;
|
|
10
|
-
remove: (_id: any) => void;
|
|
11
|
-
removeAll: (axis: any) => void;
|
|
12
|
-
toggle: (_id: any) => void;
|
|
13
|
-
deleteRecord: () => void;
|
|
14
|
-
onClick: (axis: any) => void;
|
|
15
|
-
isOnHover: any;
|
|
16
|
-
onHoverAxis: any;
|
|
17
|
-
onMouseEnter: (axis: any) => void;
|
|
18
|
-
onMouseLeave: (axis: any) => void;
|
|
19
|
-
};
|
|
20
|
-
export declare function filterForIDsWithAssignment(assignmentData: any, ids: any): any;
|
|
@@ -1,272 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
function assignmentReducer(state, action) {
|
|
6
|
-
switch (action.type) {
|
|
7
|
-
case 'ADD': {
|
|
8
|
-
const newState = {
|
|
9
|
-
...state,
|
|
10
|
-
assignment: { ...state.assignment },
|
|
11
|
-
};
|
|
12
|
-
if (newState.assignment[action.payload.id[0]] === undefined) {
|
|
13
|
-
newState.assignment[action.payload.id[0]] = {};
|
|
14
|
-
}
|
|
15
|
-
if (newState.assignment[action.payload.id[0]][action.payload.axis] ===
|
|
16
|
-
undefined) {
|
|
17
|
-
newState.assignment[action.payload.id[0]][action.payload.axis] = [];
|
|
18
|
-
}
|
|
19
|
-
// avoid duplicates
|
|
20
|
-
if (!newState.assignment[action.payload.id[0]][action.payload.axis].includes(action.payload.id[1])) {
|
|
21
|
-
newState.assignment[action.payload.id[0]][action.payload.axis].push(action.payload.id[1]);
|
|
22
|
-
}
|
|
23
|
-
return newState;
|
|
24
|
-
}
|
|
25
|
-
case 'REMOVE': {
|
|
26
|
-
const newState = {
|
|
27
|
-
...state,
|
|
28
|
-
assignment: { ...state.assignment },
|
|
29
|
-
};
|
|
30
|
-
if (newState.assignment[action.payload.id[0]]?.[action.payload.axis] !==
|
|
31
|
-
undefined) {
|
|
32
|
-
newState.assignment[action.payload.id[0]][action.payload.axis] =
|
|
33
|
-
newState.assignment[action.payload.id[0]][action.payload.axis].filter((_id) => _id !== action.payload.id[1]);
|
|
34
|
-
if (newState.assignment[action.payload.id[0]][action.payload.axis]
|
|
35
|
-
.length === 0) {
|
|
36
|
-
delete newState.assignment[action.payload.id[0]][action.payload.axis];
|
|
37
|
-
}
|
|
38
|
-
if (Object.keys(newState.assignment[action.payload.id[0]]).length === 0) {
|
|
39
|
-
delete newState.assignment[action.payload.id[0]];
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return newState;
|
|
43
|
-
}
|
|
44
|
-
case 'REMOVE_ALL': {
|
|
45
|
-
const newState = {
|
|
46
|
-
...state,
|
|
47
|
-
assignment: { ...state.assignment },
|
|
48
|
-
};
|
|
49
|
-
// takes an array now to delete multiple identifiers
|
|
50
|
-
action.payload.id.forEach((_id) => {
|
|
51
|
-
if (newState.assignment[_id]?.[action.payload.axis] !== undefined) {
|
|
52
|
-
delete newState.assignment[_id][action.payload.axis];
|
|
53
|
-
if (Object.keys(newState.assignment[_id]).length === 0) {
|
|
54
|
-
delete newState.assignment[_id];
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
return newState;
|
|
59
|
-
}
|
|
60
|
-
case 'SET_IS_ACTIVE': {
|
|
61
|
-
return {
|
|
62
|
-
...state,
|
|
63
|
-
isActive: action.payload.id !== undefined && action.payload.axis !== undefined,
|
|
64
|
-
activeID: action.payload.id,
|
|
65
|
-
activeAxis: action.payload.axis,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
case 'SET_IS_ON_HOVER': {
|
|
69
|
-
return {
|
|
70
|
-
...state,
|
|
71
|
-
isOnHover: action.payload.id !== undefined,
|
|
72
|
-
onHoverID: action.payload.id,
|
|
73
|
-
onHoverAxis: action.payload.axis,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
case 'DELETE_RECORD': {
|
|
77
|
-
const newState = {
|
|
78
|
-
...state,
|
|
79
|
-
assignment: { ...state.assignment },
|
|
80
|
-
};
|
|
81
|
-
delete newState.assignment[action.payload.id];
|
|
82
|
-
if (newState.isActive && newState.activeID === action.payload.id) {
|
|
83
|
-
newState.isActive = false;
|
|
84
|
-
newState.activeID = undefined;
|
|
85
|
-
newState.activeAxis = undefined;
|
|
86
|
-
}
|
|
87
|
-
if (newState.isOnHover && newState.onHoverID === action.payload.id) {
|
|
88
|
-
newState.isOnHover = false;
|
|
89
|
-
newState.onHoverID = undefined;
|
|
90
|
-
newState.onHoverAxis = undefined;
|
|
91
|
-
}
|
|
92
|
-
return newState;
|
|
93
|
-
}
|
|
94
|
-
default: {
|
|
95
|
-
throw new Error(`unknown action type: ${action.type}`);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
const emptyState = {
|
|
100
|
-
assignment: {},
|
|
101
|
-
isActive: false,
|
|
102
|
-
activeID: undefined,
|
|
103
|
-
activeAxis: undefined,
|
|
104
|
-
isOnHover: false,
|
|
105
|
-
onHoverID: undefined,
|
|
106
|
-
onHoverAxis: undefined,
|
|
107
|
-
};
|
|
2
|
+
import { useReducer, useMemo, useEffect } from 'react';
|
|
3
|
+
import { assignmentState, assignmentContext, } from './AssignmentsContext';
|
|
4
|
+
import assignmentReducer from './AssignmentsReducer';
|
|
108
5
|
export function AssignmentProvider(props) {
|
|
109
|
-
const { spectraData } = props;
|
|
110
|
-
const [
|
|
111
|
-
const
|
|
112
|
-
function initAssignmentDataRanges(range, _contextValue) {
|
|
113
|
-
_contextValue.dispatch({
|
|
114
|
-
type: 'DELETE_RECORD',
|
|
115
|
-
payload: { id: range.id },
|
|
116
|
-
});
|
|
117
|
-
(range.diaIDs || []).forEach((_diaID) => _contextValue.dispatch({
|
|
118
|
-
type: 'ADD',
|
|
119
|
-
payload: { id: [range.id, _diaID], axis: 'x' },
|
|
120
|
-
}));
|
|
121
|
-
range.signals.forEach((signal) => (signal.diaIDs || []).forEach((_diaID) => _contextValue.dispatch({
|
|
122
|
-
type: 'ADD',
|
|
123
|
-
payload: { id: [signal.id, _diaID], axis: 'x' },
|
|
124
|
-
})));
|
|
125
|
-
}
|
|
126
|
-
function initAssignmentDataZones(zone, _contextValue) {
|
|
127
|
-
_contextValue.dispatch({
|
|
128
|
-
type: 'DELETE_RECORD',
|
|
129
|
-
payload: { id: zone.id },
|
|
130
|
-
});
|
|
131
|
-
(zone.y.diaIDs || []).forEach((_diaID) => _contextValue.dispatch({
|
|
132
|
-
type: 'ADD',
|
|
133
|
-
payload: { id: [zone.id, _diaID], axis: 'y' },
|
|
134
|
-
}));
|
|
135
|
-
(zone.x.diaIDs || []).forEach((_diaID) => _contextValue.dispatch({
|
|
136
|
-
type: 'ADD',
|
|
137
|
-
payload: { id: [zone.id, _diaID], axis: 'x' },
|
|
138
|
-
}));
|
|
139
|
-
zone.signals.forEach((signal) => {
|
|
140
|
-
(signal.x.diaIDs || []).forEach((_diaID) => _contextValue.dispatch({
|
|
141
|
-
type: 'ADD',
|
|
142
|
-
payload: { id: [signal.id, _diaID], axis: 'x' },
|
|
143
|
-
}));
|
|
144
|
-
(signal.y.diaIDs || []).forEach((_diaID) => _contextValue.dispatch({
|
|
145
|
-
type: 'ADD',
|
|
146
|
-
payload: { id: [signal.id, _diaID], axis: 'y' },
|
|
147
|
-
}));
|
|
148
|
-
});
|
|
149
|
-
}
|
|
6
|
+
const { spectraData: spectra } = props;
|
|
7
|
+
const [data, dispatch] = useReducer(assignmentReducer, assignmentState);
|
|
8
|
+
const state = useMemo(() => ({ data, dispatch }), [data]);
|
|
150
9
|
useEffect(() => {
|
|
151
|
-
if (
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
else if (spectrum.info.dimension === 2) {
|
|
157
|
-
spectrum.zones.values.forEach((zone) => initAssignmentDataZones(zone, contextValue));
|
|
158
|
-
}
|
|
10
|
+
if (spectra) {
|
|
11
|
+
dispatch({
|
|
12
|
+
type: 'INITIATE_ASSIGNMENTS',
|
|
13
|
+
payload: { spectra },
|
|
159
14
|
});
|
|
160
15
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return (_jsx(assignmentContext.Provider, { value: contextValue, children: props.children }));
|
|
164
|
-
}
|
|
165
|
-
export function useAssignmentData() {
|
|
166
|
-
return useContext(assignmentContext);
|
|
167
|
-
}
|
|
168
|
-
export function useAssignment(key) {
|
|
169
|
-
const context = useAssignmentData();
|
|
170
|
-
if ((typeof key !== 'string' && typeof key !== 'number') || key === '') {
|
|
171
|
-
throw new Error(`assignment key must be a non-empty string or number`);
|
|
172
|
-
}
|
|
173
|
-
const id = String(key);
|
|
174
|
-
const isActive = useMemo(() => {
|
|
175
|
-
return context.assignment.isActive && context.assignment.activeID === id;
|
|
176
|
-
}, [context.assignment.activeID, context.assignment.isActive, id]);
|
|
177
|
-
const activeAxis = useMemo(() => {
|
|
178
|
-
return isActive ? context.assignment.activeAxis : undefined;
|
|
179
|
-
}, [context.assignment.activeAxis, isActive]);
|
|
180
|
-
const assigned = useMemo(() => {
|
|
181
|
-
return context.assignment.assignment[id]
|
|
182
|
-
? context.assignment.assignment[id]
|
|
183
|
-
: [];
|
|
184
|
-
}, [context.assignment.assignment, id]);
|
|
185
|
-
const isOnHover = useMemo(() => {
|
|
186
|
-
return context.assignment.isOnHover && context.assignment.onHoverID === id;
|
|
187
|
-
}, [context.assignment.isOnHover, context.assignment.onHoverID, id]);
|
|
188
|
-
const onHoverAxis = useMemo(() => {
|
|
189
|
-
return isOnHover ? context.assignment.onHoverAxis : undefined;
|
|
190
|
-
}, [context.assignment.onHoverAxis, isOnHover]);
|
|
191
|
-
const add = useCallback((_id) => {
|
|
192
|
-
context.dispatch({
|
|
193
|
-
type: 'ADD',
|
|
194
|
-
payload: { id: [id, _id], axis: activeAxis },
|
|
195
|
-
});
|
|
196
|
-
}, [activeAxis, context, id]);
|
|
197
|
-
const remove = useCallback((_id) => {
|
|
198
|
-
context.dispatch({
|
|
199
|
-
type: 'REMOVE',
|
|
200
|
-
payload: { id: [id, _id], axis: activeAxis },
|
|
201
|
-
});
|
|
202
|
-
}, [activeAxis, context, id]);
|
|
203
|
-
const removeAll = useCallback((axis) => {
|
|
204
|
-
context.dispatch({
|
|
205
|
-
type: 'REMOVE_ALL',
|
|
206
|
-
payload: { id: [id], axis },
|
|
207
|
-
});
|
|
208
|
-
}, [context, id]);
|
|
209
|
-
const toggle = useCallback((_id) => {
|
|
210
|
-
if (assigned[activeAxis] === undefined ||
|
|
211
|
-
!assigned[activeAxis].includes(_id)) {
|
|
212
|
-
add(_id);
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
remove(_id);
|
|
216
|
-
}
|
|
217
|
-
}, [activeAxis, add, assigned, remove]);
|
|
218
|
-
// totally deletion of a record from assignment storage
|
|
219
|
-
const deleteRecord = useCallback(() => {
|
|
220
|
-
context.dispatch({
|
|
221
|
-
type: 'DELETE_RECORD',
|
|
222
|
-
payload: { id },
|
|
223
|
-
});
|
|
224
|
-
}, [context, id]);
|
|
225
|
-
const onClick = useCallback((axis) => {
|
|
226
|
-
context.dispatch({
|
|
227
|
-
type: 'SET_IS_ACTIVE',
|
|
228
|
-
payload: {
|
|
229
|
-
id: !isActive ? id : undefined,
|
|
230
|
-
axis: !isActive && id !== undefined ? axis : undefined,
|
|
231
|
-
},
|
|
232
|
-
});
|
|
233
|
-
}, [context, id, isActive]);
|
|
234
|
-
const setIsOnHover = useCallback((action, axis) => {
|
|
235
|
-
if (action === 'enter') {
|
|
236
|
-
context.dispatch({
|
|
237
|
-
type: 'SET_IS_ON_HOVER',
|
|
238
|
-
payload: {
|
|
239
|
-
id: id,
|
|
240
|
-
axis: id !== undefined ? axis : undefined,
|
|
241
|
-
},
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
else if (action === 'leave') {
|
|
245
|
-
context.dispatch({
|
|
246
|
-
type: 'SET_IS_ON_HOVER',
|
|
247
|
-
payload: {},
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
}, [context, id]);
|
|
251
|
-
const onMouseEnter = useCallback((axis) => setIsOnHover('enter', axis), [setIsOnHover]);
|
|
252
|
-
const onMouseLeave = useCallback((axis) => setIsOnHover('leave', axis), [setIsOnHover]);
|
|
253
|
-
return {
|
|
254
|
-
id,
|
|
255
|
-
isActive,
|
|
256
|
-
activeAxis,
|
|
257
|
-
assigned,
|
|
258
|
-
add,
|
|
259
|
-
remove,
|
|
260
|
-
removeAll,
|
|
261
|
-
toggle,
|
|
262
|
-
deleteRecord,
|
|
263
|
-
onClick,
|
|
264
|
-
isOnHover,
|
|
265
|
-
onHoverAxis,
|
|
266
|
-
onMouseEnter,
|
|
267
|
-
onMouseLeave,
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
export function filterForIDsWithAssignment(assignmentData, ids) {
|
|
271
|
-
return ids.filter((id) => Object.keys(assignmentData.assignment).filter((_id) => _id === id));
|
|
16
|
+
}, [spectra]);
|
|
17
|
+
return (_jsx(assignmentContext.Provider, { value: state, children: props.children }));
|
|
272
18
|
}
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const GlobalConetxt: import("react").Context<
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export declare const GlobalConetxt: import("react").Context<{
|
|
3
|
+
rootRef: HTMLDivElement | null;
|
|
4
|
+
elementsWrapperRef: HTMLDivElement | null;
|
|
5
|
+
viewerRef: HTMLDivElement | null;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const GlobalProvider: import("react").Provider<{
|
|
8
|
+
rootRef: HTMLDivElement | null;
|
|
9
|
+
elementsWrapperRef: HTMLDivElement | null;
|
|
10
|
+
viewerRef: HTMLDivElement | null;
|
|
11
|
+
}>;
|
|
12
|
+
export declare function useGlobal(): {
|
|
13
|
+
rootRef: HTMLDivElement | null;
|
|
14
|
+
elementsWrapperRef: HTMLDivElement | null;
|
|
15
|
+
viewerRef: HTMLDivElement | null;
|
|
16
|
+
};
|