nmrium 0.24.0 → 0.26.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/IntegralResizable.js +13 -13
- package/lib/component/1d/multiAnalysis/AnalysisRange.js +30 -31
- package/lib/component/1d/multiplicityTree/MultiplicityTree.js +5 -5
- package/lib/component/1d/ranges/Range.js +24 -33
- package/lib/component/2d/zones/Signal.js +8 -8
- package/lib/component/2d/zones/Zone.js +3 -3
- package/lib/component/EventsTrackers/KeysListenerTracker.js +1 -1
- package/lib/component/NMRium.js +22 -29
- 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 +12 -3
- package/lib/component/context/GlobalContext.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/ContextMenu.js +6 -6
- 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/ToolTip/ToolTip.js +3 -2
- package/lib/component/elements/resizer/DivResizer.d.ts +2 -0
- package/lib/component/elements/resizer/DivResizer.js +107 -0
- package/lib/component/elements/resizer/Resizer.d.ts +18 -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 +71 -0
- package/lib/component/elements/resizer/useDraggable.d.ts +19 -0
- package/lib/component/elements/resizer/useDraggable.js +52 -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.js +11 -9
- package/lib/component/loader/DropZone.js +1 -0
- 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.js +2 -1
- 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/setting/FormattingTabContent.js +17 -11
- package/lib/component/modal/setting/GeneralSettings.js +3 -1
- package/lib/component/modal/setting/settingsValidation.d.ts +8 -0
- package/lib/component/modal/setting/settingsValidation.js +40 -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 +60 -0
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +11 -5
- package/lib/component/panels/MoleculesPanel/Utilities.d.ts +20 -11
- package/lib/component/panels/MoleculesPanel/Utilities.js +50 -68
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.d.ts +2 -2
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +55 -60
- package/lib/component/panels/RangesPanel/RangesHeader.js +2 -2
- package/lib/component/panels/RangesPanel/RangesPanel.js +1 -1
- package/lib/component/panels/RangesPanel/RangesTableRow.js +12 -11
- 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/SignalAssignmentsColumn.d.ts +2 -3
- package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.js +1 -1
- package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +5 -18
- 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/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/ZonesTableRow.d.ts +2 -1
- package/lib/component/panels/ZonesPanel/ZonesTableRow.js +20 -20
- 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 +2 -0
- package/lib/component/reducer/Reducer.js +4 -1
- 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 +10 -5
- package/lib/component/reducer/preferencesReducer.d.ts +1 -8
- package/lib/component/reducer/preferencesReducer.js +16 -16
- package/lib/component/reducer/types/Types.d.ts +1 -0
- package/lib/component/reducer/types/Types.js +1 -0
- package/lib/component/utility/Export.d.ts +3 -3
- package/lib/component/utility/Export.js +10 -9
- package/lib/component/utility/FormatNumber.js +1 -1
- package/lib/component/workspaces/Workspace.d.ts +2 -4
- package/lib/component/workspaces/basic.js +8 -9
- package/lib/data/SpectraManager.js +23 -15
- package/lib/data/data1d/Data1DManager.d.ts +1 -1
- package/lib/data/data1d/Data1DManager.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 +1 -2
- package/lib/data/data1d/database.js +1 -1
- package/lib/data/data1d/filter1d/exclusionZones.d.ts +1 -4
- package/lib/data/data2d/Data2DManager.d.ts +1 -1
- package/lib/data/data2d/Data2DManager.js +2 -1
- package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +1 -1
- package/lib/data/data2d/Spectrum2D/toJSON.d.ts +2 -0
- package/lib/data/data2d/Spectrum2D/toJSON.js +1 -0
- package/lib/data/types/common/Source.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/IntegralResizable.js +12 -12
- package/lib-cjs/component/1d/multiAnalysis/AnalysisRange.js +29 -30
- package/lib-cjs/component/1d/multiplicityTree/MultiplicityTree.js +6 -6
- package/lib-cjs/component/1d/ranges/Range.js +26 -35
- 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 +2 -2
- package/lib-cjs/component/NMRium.js +22 -29
- 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/elements/ActionButtons.js +20 -0
- package/lib-cjs/component/elements/Button.js +150 -4
- package/lib-cjs/component/elements/ContextMenu.js +6 -6
- 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/ToolTip/ToolTip.js +3 -2
- package/lib-cjs/component/elements/resizer/DivResizer.js +113 -0
- package/lib-cjs/component/elements/resizer/Resizer.js +18 -0
- package/lib-cjs/component/elements/resizer/SVGResizer.js +77 -0
- package/lib-cjs/component/elements/resizer/useDraggable.js +55 -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/loader/DropZone.js +1 -0
- 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 +5 -1
- 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/setting/FormattingTabContent.js +17 -11
- package/lib-cjs/component/modal/setting/GeneralSettings.js +3 -1
- package/lib-cjs/component/modal/setting/settingsValidation.js +66 -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 +67 -0
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +12 -6
- package/lib-cjs/component/panels/MoleculesPanel/Utilities.js +50 -68
- package/lib-cjs/component/panels/MoleculesPanel/useAtomAssignment.js +55 -60
- package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +3 -3
- package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +2 -2
- package/lib-cjs/component/panels/RangesPanel/RangesTableRow.js +15 -14
- package/lib-cjs/component/panels/RangesPanel/TableColumns/RangeAssignmentsColumn.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/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/ZoneAssignmentsColumn.js +4 -4
- package/lib-cjs/component/panels/ZonesPanel/ZonesPanel.js +2 -2
- package/lib-cjs/component/panels/ZonesPanel/ZonesTableRow.js +21 -21
- 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 +4 -1
- package/lib-cjs/component/reducer/actions/AssignmentsActions.js +21 -0
- package/lib-cjs/component/reducer/actions/LoadActions.js +9 -4
- package/lib-cjs/component/reducer/preferencesReducer.js +16 -16
- package/lib-cjs/component/reducer/types/Types.js +2 -1
- package/lib-cjs/component/utility/Export.js +10 -9
- package/lib-cjs/component/utility/FormatNumber.js +1 -1
- package/lib-cjs/component/workspaces/basic.js +8 -9
- package/lib-cjs/data/SpectraManager.js +23 -15
- package/lib-cjs/data/data1d/Data1DManager.js +2 -1
- package/lib-cjs/data/data1d/Spectrum1D/toJSON.js +1 -0
- package/lib-cjs/data/data2d/Data2DManager.js +2 -1
- package/lib-cjs/data/data2d/Spectrum2D/initiateDatum2D.js +1 -1
- package/lib-cjs/data/data2d/Spectrum2D/toJSON.js +1 -0
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +25 -26
- package/lib/component/1d/Resizable.d.ts +0 -12
- package/lib/component/1d/Resizable.js +0 -105
- package/lib-cjs/component/1d/Resizable.js +0 -110
|
@@ -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,13 @@
|
|
|
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
|
+
}>;
|
|
6
|
+
export declare const GlobalProvider: import("react").Provider<{
|
|
7
|
+
rootRef: HTMLDivElement | null;
|
|
8
|
+
elementsWrapperRef: HTMLDivElement | null;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function useGlobal(): {
|
|
11
|
+
rootRef: HTMLDivElement | null;
|
|
12
|
+
elementsWrapperRef: HTMLDivElement | null;
|
|
13
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createContext, useContext } from 'react';
|
|
2
|
-
export const GlobalConetxt = createContext({});
|
|
2
|
+
export const GlobalConetxt = createContext({ rootRef: null, elementsWrapperRef: null });
|
|
3
3
|
export const GlobalProvider = GlobalConetxt.Provider;
|
|
4
4
|
export function useGlobal() {
|
|
5
5
|
return useContext(GlobalConetxt);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CSSProperties, MouseEvent } from 'react';
|
|
2
|
+
interface ActionButtonsProps {
|
|
3
|
+
onDone: (event?: MouseEvent) => void;
|
|
4
|
+
onCancel: (event?: MouseEvent) => void;
|
|
5
|
+
doneLabel?: string;
|
|
6
|
+
cancelLabel?: string;
|
|
7
|
+
style?: CSSProperties;
|
|
8
|
+
}
|
|
9
|
+
export default function ActionButtons(props: ActionButtonsProps): JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Button from './Button';
|
|
3
|
+
export default function ActionButtons(props) {
|
|
4
|
+
const { onDone, onCancel, doneLabel = 'Apply', cancelLabel = 'Cancel', style = {}, } = props;
|
|
5
|
+
return (_jsxs("div", { style: { margin: '0 10px', display: 'flex', ...style }, children: [_jsx(Button.Done, { onClick: onDone, style: style?.flexDirection === 'row-reverse'
|
|
6
|
+
? {
|
|
7
|
+
marginLeft: '10px',
|
|
8
|
+
}
|
|
9
|
+
: {}, children: doneLabel }), _jsx(Button.Danger, { fill: "outline", onClick: onCancel, style: !style.flexDirection || style.flexDirection === 'row'
|
|
10
|
+
? {
|
|
11
|
+
marginLeft: '10px',
|
|
12
|
+
}
|
|
13
|
+
: {}, children: cancelLabel })] }));
|
|
14
|
+
}
|
|
@@ -1,6 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/** @jsxImportSource @emotion/react */
|
|
2
|
+
import { CSSObject } from '@emotion/react';
|
|
3
|
+
import { ReactNode, ButtonHTMLAttributes, CSSProperties, MouseEvent } from 'react';
|
|
4
|
+
declare type Size = 'xSmall' | 'small' | 'medium' | 'large';
|
|
5
|
+
declare type Color = CSSProperties['color'];
|
|
6
|
+
interface BaseColor {
|
|
7
|
+
base: Color;
|
|
8
|
+
hover: Color;
|
|
9
|
+
active?: Color;
|
|
4
10
|
}
|
|
5
|
-
|
|
6
|
-
|
|
11
|
+
declare type Fill = 'clear' | 'outline' | 'solid';
|
|
12
|
+
interface ButtonStyle {
|
|
13
|
+
color: BaseColor;
|
|
14
|
+
size: Size;
|
|
15
|
+
borderColor: Color;
|
|
16
|
+
backgroundColor: BaseColor;
|
|
17
|
+
borderRadius?: CSSProperties['borderRadius'];
|
|
18
|
+
fill?: Fill;
|
|
19
|
+
style?: CSSObject;
|
|
20
|
+
}
|
|
21
|
+
interface ButtonProps extends Partial<ButtonStyle>, Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'color' | 'style'> {
|
|
22
|
+
onClick?: (event?: MouseEvent<HTMLButtonElement>) => void;
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
}
|
|
25
|
+
declare const Button: {
|
|
26
|
+
(props: ButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
27
|
+
Done(props: ButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
28
|
+
Danger(props: ButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
29
|
+
Action(props: ButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
30
|
+
};
|
|
31
|
+
export default Button;
|