|
1 | | -import type { ProcessingOperatorId } from '@zakodium/nmr-types'; |
2 | | -import type { |
3 | | - ProcessingOperatorUI, |
4 | | - ProcessingOperatorUIToolProps, |
5 | | -} from '@zakodium/nmrium-core'; |
6 | | -import type { PartialPick } from '@zakodium/utils'; |
7 | 1 | import { ErrorBoundary } from 'react-error-boundary'; |
8 | 2 |
|
9 | | -import { useCore } from '../../context/CoreContext.tsx'; |
10 | 3 | import { ToolbarItemError } from '../toolbar_item_error.tsx'; |
11 | 4 |
|
12 | | -interface CoreOperatorPanelToolProps { |
13 | | - operator: ProcessingOperatorUI<ProcessingOperatorId>; |
14 | | -} |
| 5 | +import type { CoreOperatorToolProps } from './core_operator_tool.commons.ts'; |
| 6 | +import { useToolProps } from './core_operator_tool.commons.ts'; |
15 | 7 |
|
16 | | -export function CoreOperatorPanelTool( |
17 | | - props: PartialPick< |
18 | | - Omit<ProcessingOperatorUIToolProps<ProcessingOperatorId>, 'core'>, |
19 | | - 'spectrum' |
20 | | - > & |
21 | | - CoreOperatorPanelToolProps, |
22 | | -) { |
23 | | - const { spectrum, activeOperatorId, onTriggerOperation, operator } = props; |
24 | | - const core = useCore(); |
| 8 | +export function CoreOperatorPanelTool(props: CoreOperatorToolProps) { |
| 9 | + const { spectrum, operatorUI } = props; |
| 10 | + const toolProps = useToolProps(props); |
25 | 11 |
|
26 | 12 | if (!spectrum) return null; |
27 | | - if (!operator.PanelTool) return null; |
| 13 | + if (!toolProps) return null; |
| 14 | + if (!operatorUI.PanelTool) return null; |
28 | 15 |
|
29 | | - const { PanelTool } = operator; |
| 16 | + const { PanelTool } = operatorUI; |
30 | 17 |
|
31 | 18 | return ( |
32 | 19 | <ErrorBoundary FallbackComponent={ToolbarItemError}> |
33 | | - <PanelTool |
34 | | - core={core} |
35 | | - spectrum={spectrum} |
36 | | - activeOperatorId={activeOperatorId} |
37 | | - onTriggerOperation={onTriggerOperation} |
38 | | - /> |
| 20 | + <PanelTool {...toolProps} /> |
39 | 21 | </ErrorBoundary> |
40 | 22 | ); |
41 | 23 | } |
0 commit comments