55 VSCodeProgressRing ,
66} from "@vscode/webview-ui-toolkit/react" ;
77import * as React from "react" ;
8- import { ChangeEvent , useCallback , useMemo } from "react" ;
8+ import { useCallback } from "react" ;
99import { styled } from "styled-components" ;
1010import { vscode } from "../vscode-api" ;
1111
@@ -14,7 +14,6 @@ import { ModeledMethod } from "../../model-editor/modeled-method";
1414import { KindInput } from "./KindInput" ;
1515import { extensiblePredicateDefinitions } from "../../model-editor/predicates" ;
1616import { Mode } from "../../model-editor/shared/mode" ;
17- import { Dropdown } from "../common/Dropdown" ;
1817import { MethodClassifications } from "./MethodClassifications" ;
1918import {
2019 ModelingStatus ,
@@ -24,6 +23,7 @@ import { InProgressDropdown } from "./InProgressDropdown";
2423import { MethodName } from "./MethodName" ;
2524import { ModelTypeDropdown } from "./ModelTypeDropdown" ;
2625import { ModelInputDropdown } from "./ModelInputDropdown" ;
26+ import { ModelOutputDropdown } from "./ModelOutputDropdown" ;
2727
2828const ApiOrMethodCell = styled ( VSCodeDataGridCell ) `
2929 display: flex;
@@ -73,30 +73,6 @@ export const MethodRow = (props: MethodRowProps) => {
7373function ModelableMethodRow ( props : MethodRowProps ) {
7474 const { method, modeledMethod, methodIsUnsaved, mode, onChange } = props ;
7575
76- const argumentsList = useMemo ( ( ) => {
77- if ( method . methodParameters === "()" ) {
78- return [ ] ;
79- }
80- return method . methodParameters
81- . substring ( 1 , method . methodParameters . length - 1 )
82- . split ( "," ) ;
83- } , [ method . methodParameters ] ) ;
84-
85- const handleOutputInput = useCallback (
86- ( e : ChangeEvent < HTMLSelectElement > ) => {
87- if ( ! modeledMethod ) {
88- return ;
89- }
90-
91- const target = e . target as HTMLSelectElement ;
92-
93- onChange ( method , {
94- ...modeledMethod ,
95- output : target . value ,
96- } ) ;
97- } ,
98- [ onChange , method , modeledMethod ] ,
99- ) ;
10076 const handleKindChange = useCallback (
10177 ( kind : string ) => {
10278 if ( ! modeledMethod ) {
@@ -116,20 +92,6 @@ function ModelableMethodRow(props: MethodRowProps) {
11692 [ method ] ,
11793 ) ;
11894
119- const outputOptions = useMemo (
120- ( ) => [
121- { value : "ReturnValue" , label : "ReturnValue" } ,
122- { value : "Argument[this]" , label : "Argument[this]" } ,
123- ...argumentsList . map ( ( argument , index ) => ( {
124- value : `Argument[${ index } ]` ,
125- label : `Argument[${ index } ]: ${ argument } ` ,
126- } ) ) ,
127- ] ,
128- [ argumentsList ] ,
129- ) ;
130-
131- const showOutputCell =
132- modeledMethod ?. type && [ "source" , "summary" ] . includes ( modeledMethod ?. type ) ;
13395 const predicate =
13496 modeledMethod ?. type && modeledMethod . type !== "none"
13597 ? extensiblePredicateDefinitions [ modeledMethod . type ]
@@ -185,12 +147,10 @@ function ModelableMethodRow(props: MethodRowProps) {
185147 />
186148 </ VSCodeDataGridCell >
187149 < VSCodeDataGridCell gridColumn = { 4 } >
188- < Dropdown
189- value = { modeledMethod ?. output }
190- options = { outputOptions }
191- disabled = { ! showOutputCell }
192- onChange = { handleOutputInput }
193- aria-label = "Output"
150+ < ModelOutputDropdown
151+ method = { method }
152+ modeledMethod = { modeledMethod }
153+ onChange = { onChange }
194154 />
195155 </ VSCodeDataGridCell >
196156 < VSCodeDataGridCell gridColumn = { 5 } >
0 commit comments