nmrium 0.39.0 → 0.41.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/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/context/LoggerContext.js +11 -6
- 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/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 +8 -0
- package/lib/component/elements/popup/Alert/AlertBlock.js +30 -0
- 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 +5 -23
- package/lib/component/elements/popup/Modal/ConfirmDialog.d.ts +1 -1
- package/lib/component/elements/popup/Modal/ConfirmDialog.js +2 -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/Header.js +2 -2
- 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/useXScale.d.ts +1 -1
- package/lib/component/hooks/useXYReduce.d.ts +2 -2
- package/lib/component/modal/AboutSpectrumSimulationModal.d.ts +2 -0
- package/lib/component/modal/AboutSpectrumSimulationModal.js +49 -0
- package/lib/component/modal/AboutUsModal.js +4 -2
- package/lib/component/modal/AlignSpectraModal.js +11 -1
- package/lib/component/modal/LogsHistoryModal.d.ts +6 -0
- package/lib/component/{header/LogsHistory.js → modal/LogsHistoryModal.js} +6 -4
- 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/GeneralSettings.js +28 -27
- 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/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 +19 -19
- package/lib/component/panels/MoleculesPanel/Utilities.d.ts +1 -1
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +3 -5
- package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +9 -13
- package/lib/component/panels/Panels.js +13 -0
- package/lib/component/panels/PeaksPanel/PeaksTable.js +1 -1
- package/lib/component/panels/RangesPanel/RangesHeader.js +9 -15
- package/lib/component/panels/RangesPanel/RangesPanel.js +7 -10
- package/lib/component/panels/SpectrumsPanel/SpectraTable.js +8 -11
- 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 +1 -1
- 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 +251 -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 +2 -0
- package/lib/component/reducer/actions/MoleculeActions.js +51 -2
- 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/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/export.d.ts +5 -4
- package/lib/component/utility/export.js +33 -61
- 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 +1 -0
- 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 +5 -5
- package/lib/data/data1d/database.js +3 -3
- 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 +1 -1
- package/lib/data/molecules/MoleculeManager.js +7 -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 +12 -0
- package/lib/utils/clipboard/clipboard.js +15 -0
- package/lib/utils/clipboard/clipboardComponents.d.ts +45 -0
- package/lib/utils/clipboard/clipboardComponents.js +150 -0
- package/lib/utils/clipboard/clipboardHooks.d.ts +94 -0
- package/lib/utils/clipboard/clipboardHooks.js +142 -0
- package/lib/utils/clipboard/types.d.ts +1 -0
- package/lib/utils/clipboard/types.js +1 -0
- 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/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/context/LoggerContext.js +10 -5
- package/lib-cjs/component/elements/InputRange.js +1 -1
- package/lib-cjs/component/elements/dropDownButton/DropDownList.js +3 -1
- package/lib-cjs/component/elements/popup/Alert/AlertBlock.js +36 -0
- package/lib-cjs/component/elements/popup/Alert/Context.js +6 -2
- package/lib-cjs/component/elements/popup/Alert/Provider.js +4 -22
- package/lib-cjs/component/elements/popup/Modal/ConfirmDialog.js +2 -1
- package/lib-cjs/component/elements/popup/Modal/Provider.js +3 -1
- package/lib-cjs/component/header/Header.js +2 -2
- 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/modal/AboutSpectrumSimulationModal.js +54 -0
- package/lib-cjs/component/modal/AboutUsModal.js +4 -2
- package/lib-cjs/component/modal/AlignSpectraModal.js +11 -1
- package/lib-cjs/component/{header/LogsHistory.js → modal/LogsHistoryModal.js} +8 -6
- 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/GeneralSettings.js +28 -27
- 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/settingsValidation.js +2 -2
- package/lib-cjs/component/panels/IntegralsPanel/IntegralTable.js +4 -7
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +18 -18
- package/lib-cjs/component/panels/MoleculesPanel/useAtomAssignment.js +3 -5
- package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +9 -13
- package/lib-cjs/component/panels/Panels.js +13 -0
- package/lib-cjs/component/panels/PeaksPanel/PeaksTable.js +1 -1
- package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +9 -15
- package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +7 -10
- package/lib-cjs/component/panels/SpectrumsPanel/SpectraTable.js +8 -11
- 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 +1 -1
- 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 +251 -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 +54 -2
- 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/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/export.js +33 -63
- 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 +1 -0
- 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 +3 -3
- 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 +7 -7
- 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/utils/clipboard/clipboard.js +23 -0
- package/lib-cjs/utils/clipboard/clipboardComponents.js +158 -0
- package/lib-cjs/utils/clipboard/clipboardHooks.js +147 -0
- package/lib-cjs/utils/clipboard/types.js +2 -0
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +26 -25
- package/lib/component/header/LogsHistory.d.ts +0 -1
|
@@ -8,16 +8,16 @@ export function getMissingProjection(datum, nucleus, datumInfo, usedColors) {
|
|
|
8
8
|
// temporary because nucleus was undefined;
|
|
9
9
|
if (index === -1)
|
|
10
10
|
index = 0;
|
|
11
|
-
|
|
11
|
+
const info = {
|
|
12
12
|
nucleus: datumInfo.nucleus[index],
|
|
13
13
|
isFid: false,
|
|
14
14
|
isComplex: false,
|
|
15
15
|
dimension: 1,
|
|
16
16
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const from = index === 0 ? datum.minX : datum.minY;
|
|
18
|
+
const to = index === 0 ? datum.maxX : datum.maxY;
|
|
19
|
+
const nbPoints = index === 0 ? datum.z[0].length : datum.z.length;
|
|
20
|
+
const projection = new Float64Array(nbPoints);
|
|
21
21
|
if (index === 1) {
|
|
22
22
|
for (let i = 0; i < datum.z.length; i++) {
|
|
23
23
|
for (let j = 0; j < datum.z[0].length; j++) {
|
|
@@ -32,7 +32,7 @@ export function getMissingProjection(datum, nucleus, datumInfo, usedColors) {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
const data = {
|
|
36
36
|
x: zoneToX({ from, to }, nbPoints),
|
|
37
37
|
re: projection,
|
|
38
38
|
};
|
|
@@ -13,26 +13,26 @@ export function getSlice(spectrum, position) {
|
|
|
13
13
|
return;
|
|
14
14
|
if (yIndex < 0 || yIndex >= data.z.length)
|
|
15
15
|
return;
|
|
16
|
-
|
|
16
|
+
const infoX = {
|
|
17
17
|
nucleus: info.nucleus[0],
|
|
18
18
|
isFid: false,
|
|
19
19
|
isComplex: false,
|
|
20
20
|
dimension: 1,
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
const dataX = {
|
|
23
23
|
x: zoneToX({ from: data.minX, to: data.maxX }, data.z[0].length),
|
|
24
24
|
re: new Float64Array(data.z[0].length),
|
|
25
25
|
};
|
|
26
26
|
for (let i = 0; i < data.z[0].length; i++) {
|
|
27
27
|
dataX.re[i] += data.z[yIndex][i];
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
const infoY = {
|
|
30
30
|
nucleus: info.nucleus[1],
|
|
31
31
|
isFid: false,
|
|
32
32
|
isComplex: false,
|
|
33
33
|
dimension: 1,
|
|
34
34
|
};
|
|
35
|
-
|
|
35
|
+
const dataY = {
|
|
36
36
|
x: zoneToX({ from: data.minY, to: data.maxY }, data.z.length),
|
|
37
37
|
re: new Float64Array(data.z.length),
|
|
38
38
|
};
|
|
@@ -28,7 +28,7 @@ export function getDetectionZones(spectrum, options) {
|
|
|
28
28
|
function autoZonesDetection(data, options) {
|
|
29
29
|
const { clean, tolerances, thresholdFactor, maxPercentCutOff, convolutionByFFT, info: { nucleus: nuclei, originFrequency }, } = options;
|
|
30
30
|
const { enhanceSymmetry = nuclei[0] === nuclei[1] } = options;
|
|
31
|
-
|
|
31
|
+
const zones = xyzAutoZonesPicking(data, {
|
|
32
32
|
nuclei,
|
|
33
33
|
tolerances,
|
|
34
34
|
observedFrequencies: originFrequency,
|
|
@@ -54,7 +54,7 @@ function getSubMatrix(datum, selectedZone) {
|
|
|
54
54
|
[xIndexFrom, xIndexTo] = [xIndexTo, xIndexFrom];
|
|
55
55
|
if (yIndexFrom > yIndexTo)
|
|
56
56
|
[yIndexFrom, yIndexTo] = [yIndexTo, yIndexFrom];
|
|
57
|
-
|
|
57
|
+
const dataMatrix = {
|
|
58
58
|
z: [],
|
|
59
59
|
maxX: data.minX + xIndexTo * xStep,
|
|
60
60
|
minX: data.minX + xIndexFrom * xStep,
|
|
@@ -63,14 +63,14 @@ function getSubMatrix(datum, selectedZone) {
|
|
|
63
63
|
};
|
|
64
64
|
let maxZ = Number.MIN_SAFE_INTEGER;
|
|
65
65
|
let minZ = Number.MAX_SAFE_INTEGER;
|
|
66
|
-
|
|
66
|
+
const nbXPoints = xIndexTo - xIndexFrom + 1;
|
|
67
67
|
for (let j = yIndexFrom; j < yIndexTo; j++) {
|
|
68
|
-
|
|
68
|
+
const row = new Float32Array(nbXPoints);
|
|
69
69
|
let xIndex = xIndexFrom;
|
|
70
70
|
for (let i = 0; i < nbXPoints; i++) {
|
|
71
71
|
row[i] = data.z[j][xIndex++];
|
|
72
72
|
}
|
|
73
|
-
for (
|
|
73
|
+
for (const rowValue of row) {
|
|
74
74
|
if (maxZ < rowValue)
|
|
75
75
|
maxZ = rowValue;
|
|
76
76
|
if (minZ > rowValue)
|
|
@@ -5,10 +5,10 @@ interface FilterOptionsInfo {
|
|
|
5
5
|
description: string;
|
|
6
6
|
}
|
|
7
7
|
type FiltersObjectRecord = Record<string, FilterOptionsInfo>;
|
|
8
|
-
export type MatrixFilters = {
|
|
8
|
+
export type MatrixFilters = Array<{
|
|
9
9
|
name: FilterXYType['name'];
|
|
10
10
|
options: FiltersObjectRecord;
|
|
11
|
-
}
|
|
11
|
+
}>;
|
|
12
12
|
export declare function getDefaultMatrixFilters(): {
|
|
13
13
|
name: "fromTo" | "centerMean" | "centerMedian" | "normed" | "divideBySD" | "rescale" | "paretoNormalization" | "airPLSBaseline" | "iterativePolynomialBaseline" | "rollingAverageBaseline" | "rollingBallBaseline" | "rollingMedianBaseline" | "firstDerivative" | "secondDerivative" | "thirdDerivative" | "savitzkyGolay" | "ensureGrowing" | "equallySpaced" | "filterX" | "calibrateX" | "xFunction" | "yFunction";
|
|
14
14
|
options: FiltersObjectRecord;
|
|
@@ -13,7 +13,7 @@ function isLeave(fieldOptions) {
|
|
|
13
13
|
function flattenFields(filterName, data, properties, keysPath, parentObject, level) {
|
|
14
14
|
for (const fieldKey in data) {
|
|
15
15
|
let _keysPath = [];
|
|
16
|
-
|
|
16
|
+
const _keysPathObject = parentObject || null;
|
|
17
17
|
let _level = level || 0;
|
|
18
18
|
if (keysPath) {
|
|
19
19
|
_keysPath = _keysPath.concat(keysPath);
|
|
@@ -3,5 +3,5 @@ export declare function fromJSON(mols: StateMolecule[], reservedMolecules?: Stat
|
|
|
3
3
|
export declare function addMolfile(molecules: StateMoleculeExtended[], molfile: string): void;
|
|
4
4
|
export declare function setMolfile(molecules: StateMoleculeExtended[], currentMolecule: StateMolecule): void;
|
|
5
5
|
export declare function extractNumber(value: string): string | null;
|
|
6
|
-
export declare function extractLabelsNumbers(molecules: Pick<StateMolecule, 'label'
|
|
6
|
+
export declare function extractLabelsNumbers(molecules: Array<Pick<StateMolecule, 'label'>>): number[];
|
|
7
7
|
export declare function getLabelNumber(reserveNumbers: number[]): number;
|
|
@@ -6,7 +6,7 @@ export function fromJSON(mols, reservedMolecules = []) {
|
|
|
6
6
|
for (const mol of mols) {
|
|
7
7
|
const molecule = OCLMolecule.fromMolfile(mol.molfile);
|
|
8
8
|
const fragments = molecule.getFragments();
|
|
9
|
-
for (
|
|
9
|
+
for (const fragment of fragments) {
|
|
10
10
|
molecules.push(initMolecule({
|
|
11
11
|
molfile: fragment.toMolfileV3(),
|
|
12
12
|
label: mol.label || `P${getLabelNumber(reservedNumbers)}`,
|
|
@@ -21,8 +21,8 @@ export function addMolfile(molecules, molfile) {
|
|
|
21
21
|
// try to parse molfile
|
|
22
22
|
// this will throw if the molecule can not be parsed !
|
|
23
23
|
const molecule = OCLMolecule.fromMolfile(molfile);
|
|
24
|
-
|
|
25
|
-
for (
|
|
24
|
+
const fragments = molecule.getFragments();
|
|
25
|
+
for (const fragment of fragments) {
|
|
26
26
|
molecules.push(initMolecule({
|
|
27
27
|
molfile: fragment.toMolfileV3(),
|
|
28
28
|
label: `P${getLabelNumber(reservedNumbers)}`,
|
|
@@ -35,11 +35,11 @@ export function setMolfile(molecules, currentMolecule) {
|
|
|
35
35
|
const reservedNumbers = extractLabelsNumbers(molecules);
|
|
36
36
|
// try to parse molfile
|
|
37
37
|
// this will throw if the molecule can not be parsed !
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
const molecule = OCLMolecule.fromMolfile(molfile);
|
|
39
|
+
const fragments = molecule.getFragments();
|
|
40
40
|
if (fragments.length > 1) {
|
|
41
41
|
molecules = molecules.filter((m) => m.id !== id);
|
|
42
|
-
for (
|
|
42
|
+
for (const fragment of fragments) {
|
|
43
43
|
molecules.push(initMolecule({
|
|
44
44
|
molfile: fragment.toMolfileV3(),
|
|
45
45
|
label: `P${getLabelNumber(reservedNumbers)}`,
|
|
@@ -53,7 +53,7 @@ export function setMolfile(molecules, currentMolecule) {
|
|
|
53
53
|
id,
|
|
54
54
|
label,
|
|
55
55
|
});
|
|
56
|
-
|
|
56
|
+
const molIndex = molecules.findIndex((m) => m.id === id);
|
|
57
57
|
molecules.splice(molIndex, 1, _mol);
|
|
58
58
|
}
|
|
59
59
|
// we will split if we have many fragments
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import lodashGet from 'lodash/get';
|
|
2
2
|
import { prepareKey } from './prepareKey';
|
|
3
3
|
function linkMetaWithSpectra(options) {
|
|
4
|
-
|
|
4
|
+
const { autolink = false, parseMetaFileResult, spectra } = options;
|
|
5
|
+
let { source, target } = options;
|
|
5
6
|
const targetValues = {};
|
|
6
7
|
const { data, meta: { fields = [] }, } = parseMetaFileResult;
|
|
7
8
|
if (!autolink) {
|
|
@@ -6,7 +6,7 @@ function findSpectrum(spectraData, spectrumID, checkIsVisible) {
|
|
|
6
6
|
return spectrum;
|
|
7
7
|
}
|
|
8
8
|
function findSignal1D(spectrum, signalID) {
|
|
9
|
-
for (
|
|
9
|
+
for (const range of spectrum.ranges.values) {
|
|
10
10
|
const signalIndex = range.signals.findIndex((_signal) => _signal.id === signalID);
|
|
11
11
|
if (signalIndex >= 0) {
|
|
12
12
|
return range.signals[signalIndex];
|
|
@@ -14,7 +14,7 @@ function findSignal1D(spectrum, signalID) {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
function findSignal2D(spectrum, signalID) {
|
|
17
|
-
for (
|
|
17
|
+
for (const zone of spectrum.zones.values) {
|
|
18
18
|
const signalIndex = zone.signals.findIndex((_signal) => _signal.id === signalID);
|
|
19
19
|
if (signalIndex >= 0) {
|
|
20
20
|
return zone.signals[signalIndex];
|
|
@@ -22,7 +22,7 @@ function findSignal2D(spectrum, signalID) {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
function findRange(spectrum, signalID) {
|
|
25
|
-
for (
|
|
25
|
+
for (const range of spectrum.ranges.values) {
|
|
26
26
|
const signalIndex = range.signals.findIndex((_signal) => _signal.id === signalID);
|
|
27
27
|
if (signalIndex >= 0) {
|
|
28
28
|
return range;
|
|
@@ -30,7 +30,7 @@ function findRange(spectrum, signalID) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
function findZone(spectrum, signalID) {
|
|
33
|
-
for (
|
|
33
|
+
for (const zone of spectrum.zones.values) {
|
|
34
34
|
const signalIndex = zone.signals.findIndex((_signal) => _signal.id === signalID);
|
|
35
35
|
if (signalIndex >= 0) {
|
|
36
36
|
return zone;
|
|
@@ -19,5 +19,5 @@ export declare function unlink(range: Range, options?: UnlinkOptions): Range;
|
|
|
19
19
|
export declare function addDefaultSignal(range: any): void;
|
|
20
20
|
export declare function checkRangeKind(range: any): boolean;
|
|
21
21
|
export declare function checkSignalKinds(range: any, kinds: any): boolean;
|
|
22
|
-
export declare function unlinkInAssignmentData(assignmentData: any, ranges: Partial<Range
|
|
22
|
+
export declare function unlinkInAssignmentData(assignmentData: any, ranges: Array<Partial<Range>>): void;
|
|
23
23
|
export {};
|
|
@@ -6,4 +6,4 @@ export declare function resetDiaIDs(zone: Zone, axis: string): Zone;
|
|
|
6
6
|
export declare function checkZoneKind(zone: Zone): boolean;
|
|
7
7
|
export declare function checkSignalKinds(zone: Zone, kinds: string[]): boolean;
|
|
8
8
|
export declare function unlink(zone: Zone, isOnZoneLevel?: boolean, signalIndex?: number, axis?: string): Zone;
|
|
9
|
-
export declare function unlinkInAssignmentData(assignmentData: any, zones: Partial<Zone
|
|
9
|
+
export declare function unlinkInAssignmentData(assignmentData: any, zones: Array<Partial<Zone>>, axis?: string): void;
|
|
@@ -16,9 +16,9 @@ function prepare1DData(data) {
|
|
|
16
16
|
return array;
|
|
17
17
|
}
|
|
18
18
|
function prepare2DData(data) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const cols = data.z[0].length;
|
|
20
|
+
const rows = data.z.length;
|
|
21
|
+
const jump = Math.floor((cols * rows) / 204800) || 1;
|
|
22
22
|
const array = new Float64Array(((cols * rows) / jump) >> 0);
|
|
23
23
|
let index = 0;
|
|
24
24
|
for (let r = 0; r < rows; r += 1) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function readText(): Promise<string>;
|
|
2
|
+
export declare function read(): Promise<ClipboardItems>;
|
|
3
|
+
export declare function writeText(data: string): Promise<void>;
|
|
4
|
+
export interface ClipboardItemInterface {
|
|
5
|
+
readonly presentationStyle?: PresentationStyle;
|
|
6
|
+
readonly lastModified?: number;
|
|
7
|
+
readonly delayed?: boolean;
|
|
8
|
+
readonly types: readonly string[];
|
|
9
|
+
getType(type: string): Promise<Blob>;
|
|
10
|
+
}
|
|
11
|
+
export declare function write(data: ClipboardItemInterface[]): Promise<void>;
|
|
12
|
+
export declare function newClipboardItem(items: Record<string, string | Blob | PromiseLike<string | Blob>>, options?: ClipboardItemOptions): Promise<ClipboardItem>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function readText() {
|
|
2
|
+
return import('clipboard-polyfill').then((c) => c.readText());
|
|
3
|
+
}
|
|
4
|
+
export function read() {
|
|
5
|
+
return import('clipboard-polyfill').then((c) => c.read());
|
|
6
|
+
}
|
|
7
|
+
export function writeText(data) {
|
|
8
|
+
return import('clipboard-polyfill').then((c) => c.writeText(data));
|
|
9
|
+
}
|
|
10
|
+
export function write(data) {
|
|
11
|
+
return import('clipboard-polyfill').then((c) => c.write(data));
|
|
12
|
+
}
|
|
13
|
+
export function newClipboardItem(items, options) {
|
|
14
|
+
return import('clipboard-polyfill').then((c) => new c.ClipboardItem(items, options));
|
|
15
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ClipboardMode } from './types';
|
|
2
|
+
export interface CFBP {
|
|
3
|
+
mode: ClipboardMode | undefined;
|
|
4
|
+
label?: string;
|
|
5
|
+
onDismiss: () => void;
|
|
6
|
+
}
|
|
7
|
+
export interface ClipboardFallbackProps extends CFBP, Partial<Omit<ClipboardFallbackReadProps, 'mode' | 'label' | 'onDismiss'>>, Partial<Omit<ClipboardFallbackReadTextProps, 'mode' | 'label' | 'onDismiss'>>, Partial<Omit<ClipboardFallbackWriteProps, 'mode' | 'label' | 'onDismiss'>>, Partial<Omit<ClipboardFallbackWriteTextProps, 'mode' | 'label' | 'onDismiss'>> {
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* switch between ClipboardFallback variant over mode props
|
|
11
|
+
* mode === read => ClipboardFallbackReadProps
|
|
12
|
+
* mode === readText => ClipboardFallbackReadTextProps
|
|
13
|
+
* mode === write => ClipboardFallbackWriteProps
|
|
14
|
+
* mode === writeText => ClipboardFallbackWriteTextProps
|
|
15
|
+
*
|
|
16
|
+
* implement what you need in function what part of the clipboard api from useClipboard you use
|
|
17
|
+
* props will be checked at runtime
|
|
18
|
+
*
|
|
19
|
+
* @param props
|
|
20
|
+
*/
|
|
21
|
+
export declare function ClipboardFallback(props: ClipboardFallbackProps): import("react/jsx-runtime").JSX.Element | null;
|
|
22
|
+
/**
|
|
23
|
+
* return null if !props.mode
|
|
24
|
+
*
|
|
25
|
+
* @param props
|
|
26
|
+
* @see ClipboardFallback
|
|
27
|
+
*/
|
|
28
|
+
export declare function ClipboardFallbackModal(props: ClipboardFallbackProps): import("react/jsx-runtime").JSX.Element | null;
|
|
29
|
+
interface ClipboardFallbackReadProps extends CFBP {
|
|
30
|
+
onRead: (file: File) => void;
|
|
31
|
+
mode: 'read';
|
|
32
|
+
}
|
|
33
|
+
interface ClipboardFallbackReadTextProps extends CFBP {
|
|
34
|
+
onReadText: (text: string) => void;
|
|
35
|
+
mode: 'readText';
|
|
36
|
+
}
|
|
37
|
+
interface ClipboardFallbackWriteProps extends CFBP {
|
|
38
|
+
file: File;
|
|
39
|
+
mode: 'write';
|
|
40
|
+
}
|
|
41
|
+
interface ClipboardFallbackWriteTextProps extends CFBP {
|
|
42
|
+
text: string;
|
|
43
|
+
mode: 'writeText';
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
4
|
+
import { Modal } from 'react-science/ui';
|
|
5
|
+
import Button from '../../component/elements/Button';
|
|
6
|
+
const ClipboardForm = styled.form `
|
|
7
|
+
padding: 0.5rem;
|
|
8
|
+
|
|
9
|
+
& > label {
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
gap: 0.5rem;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
textarea {
|
|
16
|
+
padding: 0.5rem;
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
const Actions = styled.div `
|
|
20
|
+
display: flex;
|
|
21
|
+
gap: 0.5rem;
|
|
22
|
+
justify-content: flex-end;
|
|
23
|
+
`;
|
|
24
|
+
function throwError(props, prop) {
|
|
25
|
+
throw new Error(`props.${prop} is mandatory with ${String(props.mode)} mode`);
|
|
26
|
+
}
|
|
27
|
+
function assertReadProps(props) {
|
|
28
|
+
if (typeof props.onRead !== 'function')
|
|
29
|
+
throwError(props, 'onRead');
|
|
30
|
+
}
|
|
31
|
+
function assertReadTextProps(props) {
|
|
32
|
+
if (typeof props.onReadText !== 'function')
|
|
33
|
+
throwError(props, 'onReadText');
|
|
34
|
+
}
|
|
35
|
+
function assertWriteProps(props) {
|
|
36
|
+
if (!props.file)
|
|
37
|
+
throwError(props, 'file');
|
|
38
|
+
if (typeof props.onDismiss !== 'function')
|
|
39
|
+
throwError(props, 'onDismiss');
|
|
40
|
+
}
|
|
41
|
+
function assertWriteTextProps(props) {
|
|
42
|
+
if (typeof props.text !== 'string')
|
|
43
|
+
throwError(props, 'text');
|
|
44
|
+
if (typeof props.onDismiss !== 'function')
|
|
45
|
+
throwError(props, 'onDismiss');
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* switch between ClipboardFallback variant over mode props
|
|
49
|
+
* mode === read => ClipboardFallbackReadProps
|
|
50
|
+
* mode === readText => ClipboardFallbackReadTextProps
|
|
51
|
+
* mode === write => ClipboardFallbackWriteProps
|
|
52
|
+
* mode === writeText => ClipboardFallbackWriteTextProps
|
|
53
|
+
*
|
|
54
|
+
* implement what you need in function what part of the clipboard api from useClipboard you use
|
|
55
|
+
* props will be checked at runtime
|
|
56
|
+
*
|
|
57
|
+
* @param props
|
|
58
|
+
*/
|
|
59
|
+
export function ClipboardFallback(props) {
|
|
60
|
+
switch (props.mode) {
|
|
61
|
+
case 'read':
|
|
62
|
+
assertReadProps(props);
|
|
63
|
+
return _jsx(ClipboardFallbackRead, { ...props });
|
|
64
|
+
case 'readText':
|
|
65
|
+
assertReadTextProps(props);
|
|
66
|
+
return _jsx(ClipboardFallbackReadText, { ...props });
|
|
67
|
+
case 'write': {
|
|
68
|
+
assertWriteProps(props);
|
|
69
|
+
return _jsx(ClipboardFallbackWrite, { ...props });
|
|
70
|
+
}
|
|
71
|
+
case 'writeText':
|
|
72
|
+
assertWriteTextProps(props);
|
|
73
|
+
return _jsx(ClipboardFallbackWriteText, { ...props });
|
|
74
|
+
default:
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* return null if !props.mode
|
|
80
|
+
*
|
|
81
|
+
* @param props
|
|
82
|
+
* @see ClipboardFallback
|
|
83
|
+
*/
|
|
84
|
+
export function ClipboardFallbackModal(props) {
|
|
85
|
+
if (!props.mode)
|
|
86
|
+
return null;
|
|
87
|
+
const titles = {
|
|
88
|
+
read: `Import data from file`,
|
|
89
|
+
readText: `Paste text from clipboard`,
|
|
90
|
+
write: `Export data to file`,
|
|
91
|
+
writeText: `Copy text from text area`,
|
|
92
|
+
};
|
|
93
|
+
return (_jsxs(Modal, { hasCloseButton: true, isOpen: true, onRequestClose: props.onDismiss, children: [_jsx(Modal.Header, { children: _jsx("h2", { children: titles[props.mode] }) }), _jsx(Modal.Body, { children: _jsx(ClipboardFallback, { ...props }) })] }));
|
|
94
|
+
}
|
|
95
|
+
function ClipboardFallbackRead(props) {
|
|
96
|
+
const onFileRef = useRef(props.onRead);
|
|
97
|
+
onFileRef.current = props.onRead;
|
|
98
|
+
const onSubmit = useCallback((event) => {
|
|
99
|
+
event.preventDefault();
|
|
100
|
+
const data = new FormData(event.currentTarget);
|
|
101
|
+
const file = data.get('file');
|
|
102
|
+
if (!(file instanceof File))
|
|
103
|
+
return;
|
|
104
|
+
onFileRef.current(file);
|
|
105
|
+
}, []);
|
|
106
|
+
if (props.mode !== 'read')
|
|
107
|
+
return null;
|
|
108
|
+
return (_jsxs(ClipboardForm, { onSubmit: onSubmit, children: [_jsxs("label", { children: [_jsx("span", { children: props.label ?? 'File' }), _jsx("input", { name: "file", type: "file" })] }), _jsx("p", { children: "We were not able to read from your clipboard. Please input your data in the file field" }), _jsxs(Actions, { children: [_jsx(Button.Done, { type: "submit", children: "Submit" }), _jsx(Button.Secondary, { type: "reset", onClick: props.onDismiss, children: "Cancel" })] })] }));
|
|
109
|
+
}
|
|
110
|
+
function ClipboardFallbackReadText(props) {
|
|
111
|
+
const onTextRef = useRef(props.onReadText);
|
|
112
|
+
onTextRef.current = props.onReadText;
|
|
113
|
+
const onSubmit = useCallback((event) => {
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
const data = new FormData(event.currentTarget);
|
|
116
|
+
const text = data.get('text');
|
|
117
|
+
if (typeof text !== 'string')
|
|
118
|
+
return;
|
|
119
|
+
onTextRef.current(text);
|
|
120
|
+
}, []);
|
|
121
|
+
if (props.mode !== 'readText')
|
|
122
|
+
return null;
|
|
123
|
+
return (_jsxs(ClipboardForm, { onSubmit: onSubmit, children: [_jsxs("label", { children: [_jsx("span", { children: props.label ?? 'Text' }), _jsx("textarea", { name: "text", cols: 50, rows: 10 })] }), _jsx("p", { children: "We were not able to read text from your clipboard. Please paste your data in the text area." }), _jsxs(Actions, { children: [_jsx(Button.Done, { type: "submit", children: "Submit" }), _jsx(Button.Secondary, { type: "reset", onClick: props.onDismiss, children: "Cancel" })] })] }));
|
|
124
|
+
}
|
|
125
|
+
function ClipboardFallbackWrite(props) {
|
|
126
|
+
const onDismissRef = useRef(props.onDismiss);
|
|
127
|
+
onDismissRef.current = props.onDismiss;
|
|
128
|
+
const onSubmit = useCallback((event) => {
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
onDismissRef.current();
|
|
131
|
+
}, []);
|
|
132
|
+
const downloadLink = useMemo(() => URL.createObjectURL(props.file), [props.file]);
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
return () => URL.revokeObjectURL(downloadLink);
|
|
135
|
+
}, [downloadLink]);
|
|
136
|
+
if (props.mode !== 'write')
|
|
137
|
+
return null;
|
|
138
|
+
return (_jsxs(ClipboardForm, { onSubmit: onSubmit, children: [_jsx("p", { children: props.label ?? 'Download' }), _jsx("a", { href: downloadLink, download: props.file.name, children: "We were not able to write data to your clipboard. Please download your data with this link." }), _jsx(Actions, { children: _jsx(Button.Secondary, { type: "submit", children: "Dismiss" }) })] }));
|
|
139
|
+
}
|
|
140
|
+
function ClipboardFallbackWriteText(props) {
|
|
141
|
+
const onDismissRef = useRef(props.onDismiss);
|
|
142
|
+
onDismissRef.current = props.onDismiss;
|
|
143
|
+
const onSubmit = useCallback((event) => {
|
|
144
|
+
event.preventDefault();
|
|
145
|
+
onDismissRef.current();
|
|
146
|
+
}, []);
|
|
147
|
+
if (props.mode !== 'writeText')
|
|
148
|
+
return null;
|
|
149
|
+
return (_jsxs(ClipboardForm, { onSubmit: onSubmit, children: [_jsx("span", { children: props.label ?? 'Text' }), _jsx("textarea", { name: "text", cols: 30, rows: 10, ref: (node) => node?.select(), children: props.text }), _jsx("p", { children: "We were not able to write text to your clipboard. Please copy your data in the text area." }), _jsx(Actions, { children: _jsx(Button.Secondary, { type: "submit", children: "Dismiss" }) })] }));
|
|
150
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { ClipboardMode } from './types';
|
|
2
|
+
type PN = PermissionName | 'clipboard-read' | 'clipboard-write';
|
|
3
|
+
export interface UsePermissionReturn {
|
|
4
|
+
state: PermissionState | undefined;
|
|
5
|
+
isGranted: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function useNavigatorPermission(now: boolean, permissionName: PN, onGranted?: () => void, onError?: typeof reportError): UsePermissionReturn;
|
|
8
|
+
export interface UseClipboardReturn {
|
|
9
|
+
/**
|
|
10
|
+
* polyfill native api (stable)
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Fallback on 'read' mode
|
|
14
|
+
*/
|
|
15
|
+
read: () => Promise<ClipboardItems | undefined>;
|
|
16
|
+
/**
|
|
17
|
+
* Fallback on 'readText' mode
|
|
18
|
+
*/
|
|
19
|
+
readText: () => Promise<string | undefined>;
|
|
20
|
+
/**
|
|
21
|
+
* Fallback on 'write' mode with blobs (get blob for each first type for each item) state
|
|
22
|
+
*/
|
|
23
|
+
write: (data: ClipboardItems) => Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Fallback on 'writeText' mode with text state
|
|
26
|
+
*/
|
|
27
|
+
writeText: (data: string) => Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* custom helper (stable)
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* use write but no need do to manually ClipboardItems transform
|
|
33
|
+
* Fallback on 'writeText' mode with text state
|
|
34
|
+
* @param data
|
|
35
|
+
* @param type a mime type default to 'text/plain'
|
|
36
|
+
*/
|
|
37
|
+
rawWriteWithType: (data: string, type?: 'text/html' | 'text/plain' | string) => Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* state for alternative
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* state to know if you need to display an alternative interface
|
|
43
|
+
*/
|
|
44
|
+
shouldFallback: ClipboardMode | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* state for 'writeText' / 'rawWriteWithType' mode fallback
|
|
47
|
+
*/
|
|
48
|
+
text: string | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* state for 'write' mode fallback
|
|
51
|
+
*/
|
|
52
|
+
blobs: Blob[] | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* method to clean up state for alternative interface (set shouldFallback to undefined, text to undefined and blobs to undefined)
|
|
55
|
+
* stable
|
|
56
|
+
*/
|
|
57
|
+
cleanShouldFallback: () => void;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Give you a wrapped clipboard api and a shouldFallback state.
|
|
61
|
+
* ignore if read and readText return promise filled with undefined, and rely on shouldFallback to display an alternative interaction.
|
|
62
|
+
* You should use ClipboardFallback component
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```tsx
|
|
66
|
+
* const { readText, shouldFallback, setShouldFallback } = useClipboard();
|
|
67
|
+
*
|
|
68
|
+
* function handlePasteAction() {
|
|
69
|
+
* // yes you can safely ignore error here,
|
|
70
|
+
* // readText() will never throw, error is caught and set shouldFallback to corresponding mode
|
|
71
|
+
* void readText().then(handlePaste);
|
|
72
|
+
* }
|
|
73
|
+
*
|
|
74
|
+
* function handlePaste(text: string | undefined) {
|
|
75
|
+
* if (!text) return;
|
|
76
|
+
*
|
|
77
|
+
* setState(text);
|
|
78
|
+
* setShouldFallback(null);
|
|
79
|
+
* }
|
|
80
|
+
*
|
|
81
|
+
* return (
|
|
82
|
+
* <>
|
|
83
|
+
* <button onClick={handlePasteAction}>Paste</button>
|
|
84
|
+
* <ClipboardFallbackModal
|
|
85
|
+
* mode={shouldFallback}
|
|
86
|
+
* onDismiss={() => setShouldFallback(null)}
|
|
87
|
+
* onReadText={handlePaste}
|
|
88
|
+
* />
|
|
89
|
+
* </>
|
|
90
|
+
* )
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare function useClipboard(): UseClipboardReturn;
|
|
94
|
+
export {};
|