nmrium 0.25.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/multiplicityTree/MultiplicityTree.js +5 -5
- package/lib/component/1d/ranges/Range.js +6 -5
- 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/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/elements/Button.js +2 -1
- 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/header/BaseLineCorrectionPanel.js +1 -1
- package/lib/component/modal/setting/FormattingTabContent.js +17 -11
- package/lib/component/modal/setting/GeneralSettings.js +2 -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 +1 -1
- 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/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 +10 -13
- package/lib/component/reducer/types/Types.d.ts +1 -0
- package/lib/component/reducer/types/Types.js +1 -0
- 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/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/multiplicityTree/MultiplicityTree.js +6 -6
- package/lib-cjs/component/1d/ranges/Range.js +8 -7
- 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/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/elements/Button.js +2 -1
- 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/header/BaseLineCorrectionPanel.js +1 -1
- package/lib-cjs/component/modal/setting/FormattingTabContent.js +17 -11
- package/lib-cjs/component/modal/setting/GeneralSettings.js +2 -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 +2 -2
- 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/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 +10 -13
- package/lib-cjs/component/reducer/types/Types.js +2 -1
- 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/toJSON.js +1 -0
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +19 -19
|
@@ -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
|
}
|
|
@@ -131,12 +131,13 @@ const Button = (props) => {
|
|
|
131
131
|
], ...restProps, children: _jsxs("span", { style: { flex: 1 }, children: [" ", props.children] }) }));
|
|
132
132
|
};
|
|
133
133
|
function ThemeButton(props) {
|
|
134
|
+
const { colorTheme, ...buttonProps } = props;
|
|
134
135
|
const { base, shade, tint } = colorPalettes[props.colorTheme];
|
|
135
136
|
const { color = { base: shade, hover: 'white' }, backgroundColor = {
|
|
136
137
|
base: base,
|
|
137
138
|
hover: shade,
|
|
138
139
|
active: tint,
|
|
139
|
-
}, fill = 'solid', ...restProps } =
|
|
140
|
+
}, fill = 'solid', ...restProps } = buttonProps;
|
|
140
141
|
return _jsx(Button, { ...{ fill, ...restProps, backgroundColor, color } });
|
|
141
142
|
}
|
|
142
143
|
Button.Done = (props) => {
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
/** @jsxImportSource @emotion/react */
|
|
2
2
|
/// <reference types="react" />
|
|
3
3
|
import { HighlightedSource } from '../../../highlight/index';
|
|
4
|
-
interface
|
|
4
|
+
export interface ClickEvent {
|
|
5
|
+
onClick?: (event: Event, data: unknown) => void;
|
|
6
|
+
}
|
|
7
|
+
interface ReactTableRowProps extends ClickEvent {
|
|
5
8
|
row: any;
|
|
6
9
|
highlightedSource?: HighlightedSource;
|
|
7
10
|
onContextMenu: () => void;
|
|
8
11
|
isVisible: boolean;
|
|
12
|
+
isRowActive: boolean;
|
|
9
13
|
}
|
|
10
14
|
declare const _default: import("react").ForwardRefExoticComponent<ReactTableRowProps & import("react").RefAttributes<unknown>>;
|
|
11
15
|
export default _default;
|
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
|
-
import {
|
|
3
|
+
import { css } from '@emotion/react';
|
|
4
|
+
import { useMemo, forwardRef, useEffect, useCallback } from 'react';
|
|
4
5
|
import { HighlightedSource, useHighlight } from '../../../highlight/index';
|
|
5
|
-
|
|
6
|
+
function highlightStyle(isActive, row) {
|
|
7
|
+
if (isActive) {
|
|
8
|
+
return { backgroundColor: '#ff6f0057' };
|
|
9
|
+
}
|
|
10
|
+
else if (row.original?.isConstantlyHighlighted === true) {
|
|
11
|
+
return { backgroundColor: '#f5f5dc' };
|
|
12
|
+
}
|
|
13
|
+
return {};
|
|
14
|
+
}
|
|
15
|
+
const rowCss = css `
|
|
16
|
+
&:hover {
|
|
17
|
+
background-color: #ff6f0091 !important;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&:active {
|
|
21
|
+
background-color: #ff6f0070 !important;
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
6
24
|
function getIDs(row) {
|
|
7
25
|
const id = row.original.id;
|
|
8
26
|
if (id) {
|
|
@@ -16,7 +34,7 @@ function getIDs(row) {
|
|
|
16
34
|
return [''];
|
|
17
35
|
}
|
|
18
36
|
function ReactTableRow(props, ref) {
|
|
19
|
-
const { row, highlightedSource = HighlightedSource.UNKNOWN, onContextMenu, } = props;
|
|
37
|
+
const { row, highlightedSource = HighlightedSource.UNKNOWN, onContextMenu, onClick, isRowActive = false, } = props;
|
|
20
38
|
const data = useMemo(() => ({
|
|
21
39
|
type: highlightedSource,
|
|
22
40
|
extra: row.original,
|
|
@@ -28,12 +46,14 @@ function ReactTableRow(props, ref) {
|
|
|
28
46
|
};
|
|
29
47
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
30
48
|
}, []);
|
|
49
|
+
const clickHandler = useCallback((event) => {
|
|
50
|
+
onClick?.(event, row);
|
|
51
|
+
}, [onClick, row]);
|
|
31
52
|
return useMemo(() => {
|
|
32
|
-
return (_jsx("tr", { ref: ref, onContextMenu: onContextMenu, css:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
: null, ...row.getRowProps(), ...highlight.onHover, children: row.cells.map((cell) => {
|
|
53
|
+
return (_jsx("tr", { ref: ref, onContextMenu: onContextMenu, css: [
|
|
54
|
+
highlightStyle(highlight.isActive || isRowActive, row),
|
|
55
|
+
onClick && rowCss,
|
|
56
|
+
], ...row.getRowProps(), ...highlight.onHover, children: row.cells.map((cell) => {
|
|
37
57
|
const { style, padding } = cell.column;
|
|
38
58
|
if (cell.isRowSpanned) {
|
|
39
59
|
return null;
|
|
@@ -42,9 +62,17 @@ function ReactTableRow(props, ref) {
|
|
|
42
62
|
return (_jsx("td", { rowSpan: cell.rowSpan, ...cell.getCellProps(), onContextMenu: (e) => {
|
|
43
63
|
e.preventDefault();
|
|
44
64
|
return false;
|
|
45
|
-
}, style: { padding, ...style }, children: cell.render('Cell') }, cell.key));
|
|
65
|
+
}, style: { padding, ...style }, onClick: clickHandler, children: cell.render('Cell') }, cell.key));
|
|
46
66
|
}
|
|
47
67
|
}) }, row.getRowProps().key));
|
|
48
|
-
}, [
|
|
68
|
+
}, [
|
|
69
|
+
clickHandler,
|
|
70
|
+
highlight.isActive,
|
|
71
|
+
highlight.onHover,
|
|
72
|
+
onClick,
|
|
73
|
+
onContextMenu,
|
|
74
|
+
ref,
|
|
75
|
+
row,
|
|
76
|
+
]);
|
|
49
77
|
}
|
|
50
78
|
export default forwardRef(ReactTableRow);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { HighlightedSource } from '../../highlight';
|
|
3
|
-
|
|
3
|
+
import { ClickEvent } from './Elements/ReactTableRow';
|
|
4
|
+
interface ReactTableProps extends ClickEvent {
|
|
4
5
|
data: any;
|
|
5
6
|
columns: any;
|
|
6
7
|
highlightedSource?: HighlightedSource;
|
|
@@ -11,6 +12,7 @@ interface ReactTableProps {
|
|
|
11
12
|
approxItemHeight?: number;
|
|
12
13
|
groupKey?: string;
|
|
13
14
|
enableVirtualScroll?: boolean;
|
|
15
|
+
highlightActiveRow?: boolean;
|
|
14
16
|
}
|
|
15
17
|
export interface TableVirtualConfig {
|
|
16
18
|
offsetHeight: number;
|
|
@@ -19,9 +19,10 @@ const styles = {
|
|
|
19
19
|
},
|
|
20
20
|
};
|
|
21
21
|
const ReactTableInner = forwardRef(function ReactTableInner(props, ref) {
|
|
22
|
-
const { data, columns, highlightedSource, context = null, onScroll, approxItemHeight = 40, enableVirtualScroll = false, groupKey, } = props;
|
|
22
|
+
const { data, columns, highlightedSource, context = null, onScroll, approxItemHeight = 40, enableVirtualScroll = false, groupKey, onClick, highlightActiveRow = false, } = props;
|
|
23
23
|
const contextRef = useRef(null);
|
|
24
24
|
const { index: indexBoundary } = useReactTableContext();
|
|
25
|
+
const [rowIndex, setRowIndex] = useState();
|
|
25
26
|
const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow, rowSpanHeaders, } = useTable({
|
|
26
27
|
columns,
|
|
27
28
|
data,
|
|
@@ -35,6 +36,10 @@ const ReactTableInner = forwardRef(function ReactTableInner(props, ref) {
|
|
|
35
36
|
const rowsData = enableVirtualScroll
|
|
36
37
|
? rows.slice(indexBoundary.start, indexBoundary.end)
|
|
37
38
|
: rows;
|
|
39
|
+
const clickHandler = useCallback((event, row) => {
|
|
40
|
+
setRowIndex(row.index);
|
|
41
|
+
onClick?.(event, row);
|
|
42
|
+
}, [onClick]);
|
|
38
43
|
return (_jsxs("div", { ref: ref, className: "table-container", style: {
|
|
39
44
|
overflowY: 'auto',
|
|
40
45
|
position: 'relative',
|
|
@@ -47,7 +52,7 @@ const ReactTableInner = forwardRef(function ReactTableInner(props, ref) {
|
|
|
47
52
|
} })), _jsxs("table", { ...getTableProps(), css: ReactTableStyle, style: styles.table(enableVirtualScroll), children: [_jsx(ReactTableHeader, { headerGroups: headerGroups }), _jsx("tbody", { ...getTableBodyProps(), children: rowsData.map((row, index) => {
|
|
48
53
|
prepareRow(row);
|
|
49
54
|
prepareRowSpan(rows, enableVirtualScroll ? index + indexBoundary.start : index, rowSpanHeaders, groupKey);
|
|
50
|
-
return (_jsx(ReactTableRow, { row: row, ...row.getRowProps(), onContextMenu: (e) => contextMenuHandler(e, row), highlightedSource: highlightedSource }, row.key));
|
|
55
|
+
return (_jsx(ReactTableRow, { row: row, ...row.getRowProps(), onContextMenu: (e) => contextMenuHandler(e, row), onClick: highlightActiveRow ? clickHandler : onClick, highlightedSource: highlightedSource, isRowActive: rowIndex === index }, row.key));
|
|
51
56
|
}) })] }), _jsx(ContextMenu, { ref: contextRef, context: context })] }));
|
|
52
57
|
});
|
|
53
58
|
function ReactTable(props) {
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
declare const HighlightedRowStyle: import("@emotion/utils").SerializedStyles;
|
|
2
|
-
declare const ConstantlyHighlightedRowStyle: import("@emotion/utils").SerializedStyles;
|
|
3
1
|
declare const ReactTableStyle: import("@emotion/utils").SerializedStyles;
|
|
4
|
-
export { ReactTableStyle
|
|
2
|
+
export { ReactTableStyle };
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { css } from '@emotion/react';
|
|
2
|
-
const HighlightedRowStyle = css `
|
|
3
|
-
background-color: #ff6f0057;
|
|
4
|
-
`;
|
|
5
|
-
const ConstantlyHighlightedRowStyle = css `
|
|
6
|
-
background-color: #f5f5dc;
|
|
7
|
-
`;
|
|
8
2
|
const ReactTableStyle = css `
|
|
9
3
|
border-spacing: 0;
|
|
10
4
|
border: 1px solid #dedede;
|
|
@@ -46,4 +40,4 @@ const ReactTableStyle = css `
|
|
|
46
40
|
}
|
|
47
41
|
}
|
|
48
42
|
`;
|
|
49
|
-
export { ReactTableStyle
|
|
43
|
+
export { ReactTableStyle };
|
|
@@ -3,12 +3,12 @@ import { useCallback, useRef, useState, useMemo } from 'react';
|
|
|
3
3
|
import * as Yup from 'yup';
|
|
4
4
|
import { baselineAlgorithms } from '../../data/data1d/filter1d/baselineCorrection';
|
|
5
5
|
import { useDispatch } from '../context/DispatchContext';
|
|
6
|
+
import ActionButtons from '../elements/ActionButtons';
|
|
6
7
|
import Label from '../elements/Label';
|
|
7
8
|
import Select from '../elements/Select';
|
|
8
9
|
import FormikForm from '../elements/formik/FormikForm';
|
|
9
10
|
import FormikInput from '../elements/formik/FormikInput';
|
|
10
11
|
import { RESET_SELECTED_TOOL, APPLY_BASE_LINE_CORRECTION_FILTER, } from '../reducer/types/Types';
|
|
11
|
-
import ActionButtons from '../elements/ActionButtons';
|
|
12
12
|
const styles = {
|
|
13
13
|
container: {
|
|
14
14
|
padding: '5px',
|
|
@@ -47,24 +47,30 @@ const styles = css `
|
|
|
47
47
|
`;
|
|
48
48
|
function FormattingTabContent() {
|
|
49
49
|
const { values, setFieldValue } = useFormikContext();
|
|
50
|
-
const
|
|
51
|
-
const deleteHandler = useCallback((
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
const nuclei = useMemo(() => lodashGet(values, 'formatting.nuclei', {}), [values]);
|
|
51
|
+
const deleteHandler = useCallback((key) => {
|
|
52
|
+
let _nuclei = {};
|
|
53
|
+
for (const nucleus in nuclei) {
|
|
54
|
+
if (nucleus !== key) {
|
|
55
|
+
_nuclei[nucleus] = nuclei[nucleus];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
setFieldValue('formatting.nuclei', _nuclei);
|
|
59
|
+
}, [nuclei, setFieldValue]);
|
|
55
60
|
const addNewNucleusFormatHandler = useCallback(() => {
|
|
56
61
|
const newFormat = {
|
|
57
|
-
key: generateID(),
|
|
58
62
|
name: '',
|
|
59
63
|
ppm: '0.00',
|
|
60
64
|
hz: '0.00',
|
|
61
65
|
};
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
const key = generateID();
|
|
67
|
+
const newNuclei = { ...nuclei, [key]: newFormat };
|
|
68
|
+
setFieldValue('formatting.nuclei', newNuclei);
|
|
69
|
+
}, [nuclei, setFieldValue]);
|
|
70
|
+
const nucleiList = Object.keys(nuclei);
|
|
71
|
+
return (_jsxs(Fragment, { children: [_jsx("p", { className: "section-header", children: "Nuclei Formatting" }), _jsx("div", { css: styles, children: _jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { className: "counter-col", children: "#" }), _jsx("th", { className: "nucleus-label-col", children: "Nucleus " }), _jsx("th", { className: "nucleus-format-input-col", children: "\u03B4 (ppm)" }), _jsx("th", { className: "nucleus-format-input-col", children: "Coupling (Hz)" }), _jsx("th", { className: "nucleus-format-input-col" })] }) }), _jsx("tbody", { children: nucleiList?.map((key, index) => {
|
|
66
72
|
const num = index + 1;
|
|
67
|
-
return (_jsxs("tr", { children: [_jsxs("td", { className: "counter-col", children: [_jsxs("span", { children: [num, " - "] }), ' '] }), _jsx("td", { className: "nucleus-label-col", children: _jsx(FormikInput, { name: `formatting.
|
|
73
|
+
return (_jsxs("tr", { children: [_jsxs("td", { className: "counter-col", children: [_jsxs("span", { children: [num, " - "] }), ' '] }), _jsx("td", { className: "nucleus-label-col", children: _jsx(FormikInput, { name: `formatting.nuclei.${key}.name`, className: "width-100", checkErrorAfterInputTouched: false }) }), _jsx("td", { className: "nucleus-format-input-col", children: _jsx(FormikInput, { name: `formatting.nuclei.${key}.ppm`, className: "width-100" }) }), _jsx("td", { className: "nucleus-format-input-col", children: _jsx(FormikInput, { name: `formatting.nuclei.${key}.hz`, className: "width-100" }) }), _jsxs("td", { className: "operation-container", children: [_jsx(CloseButton, { onClick: () => deleteHandler(key), popupTitle: `remove ${nuclei[key].name}`, popupPlacement: "right" }), nucleiList.length === index + 1 && (_jsx("button", { className: "add", type: "button", onClick: addNewNucleusFormatHandler, children: _jsx(FaPlus, {}) }))] })] }, `${key}`));
|
|
68
74
|
}) })] }) })] }));
|
|
69
75
|
}
|
|
70
76
|
export default FormattingTabContent;
|
|
@@ -15,6 +15,7 @@ import ControllersTabContent from './ControllersTabContent';
|
|
|
15
15
|
import DisplayTabContent from './DisplayTabContent';
|
|
16
16
|
import FormattingTabContent from './FormattingTabContent';
|
|
17
17
|
import WorkspaceItem from './WorkspaceItem';
|
|
18
|
+
import { validation } from './settingsValidation';
|
|
18
19
|
const styles = css `
|
|
19
20
|
.main-content {
|
|
20
21
|
width: 100%;
|
|
@@ -146,6 +147,6 @@ function GeneralSettings({ onClose }) {
|
|
|
146
147
|
const renderItem = useCallback((item) => {
|
|
147
148
|
return (_jsx(WorkspaceItem, { item: item, onSave: addWorkSpaceHandler, onDelete: deleteWorkSpaceHandler }));
|
|
148
149
|
}, [addWorkSpaceHandler, deleteWorkSpaceHandler]);
|
|
149
|
-
return (_jsxs("div", { css: [ModalStyles, styles], children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: "General Settings" }), _jsx(CloseButton, { onClick: onClose, className: "close-bt" })] }), _jsxs("div", { className: "workspace-container", children: [_jsx("span", { className: "label", children: "Workspace : " }), _jsx(DropDownButton, { data: workspacesList, renderItem: renderItem, selectedKey: preferences?.workspace.current, onSelect: ChangeWorkspaceHandler })] }), _jsx("div", { className: "main-content", children: _jsx(FormikForm, { ref: refForm, initialValues: preferences.current, onSubmit: submitHandler, children: _jsxs(Tabs, { position: PositionsEnum.LEFT, activeTab: activeTab, onClick: tabChangeHandler, children: [_jsx(Tab, { tablabel: "Controllers", tabid: "controllers", children: _jsx("div", { className: "inner-content", children: _jsx(ControllersTabContent, {}) }) }), _jsx(Tab, { tablabel: "Formatting", tabid: "formatting", children: _jsx("div", { className: "inner-content", children: _jsx(FormattingTabContent, {}) }) }), _jsx(Tab, { tablabel: "Display", tabid: "display", children: _jsx("div", { className: "inner-content", children: _jsx(DisplayTabContent, { preferences: preferences.current.display }) }) })] }) }, JSON.stringify(preferences.current)) }), _jsx("div", { className: "footer-container", children: _jsx(ActionButtons, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: handleSave, doneLabel: "Save", onCancel: handleReset, cancelLabel: "Reset" }) })] }));
|
|
150
|
+
return (_jsxs("div", { css: [ModalStyles, styles], children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: "General Settings" }), _jsx(CloseButton, { onClick: onClose, className: "close-bt" })] }), _jsxs("div", { className: "workspace-container", children: [_jsx("span", { className: "label", children: "Workspace : " }), _jsx(DropDownButton, { data: workspacesList, renderItem: renderItem, selectedKey: preferences?.workspace.current, onSelect: ChangeWorkspaceHandler })] }), _jsx("div", { className: "main-content", children: _jsx(FormikForm, { ref: refForm, initialValues: preferences.current, validationSchema: validation, onSubmit: submitHandler, children: _jsxs(Tabs, { position: PositionsEnum.LEFT, activeTab: activeTab, onClick: tabChangeHandler, children: [_jsx(Tab, { tablabel: "Controllers", tabid: "controllers", children: _jsx("div", { className: "inner-content", children: _jsx(ControllersTabContent, {}) }) }), _jsx(Tab, { tablabel: "Formatting", tabid: "formatting", children: _jsx("div", { className: "inner-content", children: _jsx(FormattingTabContent, {}) }) }), _jsx(Tab, { tablabel: "Display", tabid: "display", children: _jsx("div", { className: "inner-content", children: _jsx(DisplayTabContent, { preferences: preferences.current.display }) }) })] }) }, JSON.stringify(preferences.current)) }), _jsx("div", { className: "footer-container", children: _jsx(ActionButtons, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: handleSave, doneLabel: "Save", onCancel: handleReset, cancelLabel: "Reset" }) })] }));
|
|
150
151
|
}
|
|
151
152
|
export default GeneralSettings;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as Yup from 'yup';
|
|
2
|
+
export declare const validation: import("yup/lib/Lazy").default<Yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
3
|
+
formatting: Yup.ObjectSchema<any, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<any>, import("yup/lib/object").AssertsShape<any>>;
|
|
4
|
+
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
5
|
+
formatting: Yup.ObjectSchema<any, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<any>, import("yup/lib/object").AssertsShape<any>>;
|
|
6
|
+
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
7
|
+
formatting: Yup.ObjectSchema<any, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<any>, import("yup/lib/object").AssertsShape<any>>;
|
|
8
|
+
}>>>, import("yup/lib/object").AnyObject>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as Yup from 'yup';
|
|
2
|
+
const formattingValidation = (obj) => Object.keys(obj.formatting.nuclei).reduce((validate, key) => {
|
|
3
|
+
validate[key] = Yup.object().shape({
|
|
4
|
+
name: Yup.string().trim().required('Nucleus is a required field'),
|
|
5
|
+
ppm: Yup.string().trim().required('PPM format is a required field'),
|
|
6
|
+
hz: Yup.string().trim().required('Hz format is a required field'),
|
|
7
|
+
});
|
|
8
|
+
return validate;
|
|
9
|
+
}, {});
|
|
10
|
+
export const validation = Yup.lazy((obj) => Yup.object().shape({
|
|
11
|
+
formatting: Yup.object().shape({
|
|
12
|
+
nuclei: Yup.object()
|
|
13
|
+
.shape(formattingValidation(obj))
|
|
14
|
+
.test('Unique', 'Nuclei need te be unique', function check(nuclei) {
|
|
15
|
+
let nucleusFrequencies = {};
|
|
16
|
+
for (const key of Object.keys(nuclei)) {
|
|
17
|
+
const _key = nuclei[key].name?.toLowerCase() || '';
|
|
18
|
+
if (_key) {
|
|
19
|
+
if (nucleusFrequencies[_key]) {
|
|
20
|
+
++nucleusFrequencies[_key].value;
|
|
21
|
+
nucleusFrequencies[_key].fields.push(key);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
nucleusFrequencies[_key] = { value: 1, fields: [key] };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const errors = Object.keys(nucleusFrequencies).reduce((errorList, key) => {
|
|
29
|
+
const { value, fields } = nucleusFrequencies[key];
|
|
30
|
+
if (value > 1) {
|
|
31
|
+
for (let field of fields) {
|
|
32
|
+
errorList.push(new Yup.ValidationError(`${key} nucleus must te be unique`, nuclei[key].name, `${this.path}.${field}.name`));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return errorList;
|
|
36
|
+
}, []);
|
|
37
|
+
return new Yup.ValidationError(errors);
|
|
38
|
+
}),
|
|
39
|
+
}),
|
|
40
|
+
}));
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import { SvgNmrAssignment2 } from 'cheminfo-font';
|
|
4
|
-
import {
|
|
4
|
+
import { FaBolt } from 'react-icons/fa';
|
|
5
5
|
import Button from '../../elements/ButtonToolTip';
|
|
6
6
|
import { tablePanelStyle } from '../extra/BasicPanelStyle';
|
|
7
7
|
import DefaultPanelHeader from '../header/DefaultPanelHeader';
|
|
8
|
+
import { SpectraAutomaticPickingButton } from '../header/SpectraAutomaticPickingButton';
|
|
9
|
+
import AutomaticAssignmentTable from './AutomaticAssignmentTable';
|
|
10
|
+
import { useAutoAssignments } from './useAutoAssignments';
|
|
8
11
|
function AutomaticAssignment() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return (_jsxs("div", { css: tablePanelStyle, children: [_jsx(DefaultPanelHeader, { showSettingButton: false, canDelete: false, children: _jsx(Button, { popupTitle: "automatic assignment", onClick: automaticAssignmentHandler, children: _jsx(SvgNmrAssignment2, { style: { fontSize: '18px' } }) }) }), _jsx("div", { className: "inner-container" })] }));
|
|
12
|
+
const { getAssignments, assignments, restAssignments } = useAutoAssignments();
|
|
13
|
+
return (_jsxs("div", { css: tablePanelStyle, children: [_jsxs(DefaultPanelHeader, { showSettingButton: false, canDelete: false, children: [_jsx(SpectraAutomaticPickingButton, {}), _jsx(Button, { popupTitle: "automatic assignment", onClick: getAssignments, children: _jsx(SvgNmrAssignment2, { style: { fontSize: '18px' } }) }), _jsx(Button, { popupTitle: "reset assignment", onClick: restAssignments, children: _jsx(FaBolt, {}) })] }), _jsx("div", { className: "inner-container", children: _jsx(AutomaticAssignmentTable, { data: assignments }) })] }));
|
|
12
14
|
}
|
|
13
15
|
export default AutomaticAssignment;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { AutoAssignmentsData } from './useAutoAssignments';
|
|
2
3
|
interface AutomaticAssignmentTableProps {
|
|
3
|
-
data:
|
|
4
|
+
data: AutoAssignmentsData[];
|
|
4
5
|
}
|
|
5
|
-
declare function
|
|
6
|
-
declare const _default: import("react").MemoExoticComponent<typeof
|
|
6
|
+
declare function AutomaticAssignmentTable({ data }: AutomaticAssignmentTableProps): JSX.Element;
|
|
7
|
+
declare const _default: import("react").MemoExoticComponent<typeof AutomaticAssignmentTable>;
|
|
7
8
|
export default _default;
|