@@ -11,7 +11,6 @@ import DownloadIcon from "@mui/icons-material/Download";
1111import RemoveCircleOutlineIcon from "@mui/icons-material/RemoveCircleOutline" ;
1212import AddIcon from "@mui/icons-material/Add" ;
1313import RemoveIcon from "@mui/icons-material/Remove" ;
14- import { sequenceSheetsToGroovyDSL } from "./ssnutilities" ;
1514
1615const BASE_COLS = [ "A" , "B" , "C" , "D" ] ;
1716const OPERATION_NAMES = [ "create" , "push" , "pop" , "size" ] ;
@@ -118,6 +117,17 @@ export interface SequenceSheetData {
118117 rows : any [ ] ;
119118 invocations : Invocation [ ] ;
120119}
120+ export interface SequenceSheetDataModel {
121+ name : string ;
122+ signature : string ;
123+ body : string ;
124+ invocations : Invocation [ ] ;
125+ }
126+ export interface SequenceSheetSetModel {
127+ sheets : SequenceSheetDataModel [ ] ;
128+ interfaceSpecification : string ;
129+ }
130+
121131interface SequenceSheetEditorProps {
122132 value : SequenceSheetData ;
123133 onChange : ( next : SequenceSheetData ) => void ;
@@ -181,7 +191,7 @@ export const SequenceSheetEditor: React.FC<SequenceSheetEditorProps> = ({
181191 handleChangeField ( "rows" , nextRows ) ;
182192 return newRow ;
183193 } ;
184- const handleExport = ( ) => {
194+ const handleExportJSONL = ( ) => {
185195 const jsonl = gridToJSONL ( value . rows , value . columns ) ;
186196
187197 // const sheet1 = {
@@ -201,17 +211,29 @@ export const SequenceSheetEditor: React.FC<SequenceSheetEditorProps> = ({
201211 a . click ( ) ;
202212 a . remove ( ) ;
203213 setSnackMsg ( "Exported as file." ) ;
204- } ;
205- const handleImport = ( ) => {
206- const result = jsonlToRows ( importText ) ;
214+ } ;
215+
216+ const handleImport = ( text : string ) => {
217+ const model : SequenceSheetDataModel = JSON . parse ( text ) ;
218+
219+ const result = jsonlToRows ( model . body ) ;
207220 if ( "error" in result ) {
208221 setSnackMsg ( result . error ) ;
209222 } else {
210223 const importedRows = result . rows . map ( ( row , idx ) => ( {
211224 ...row ,
212225 id : idx ,
213226 } ) ) ;
214- onChange ( { ...value , columns : result . cols , rows : importedRows } ) ;
227+
228+ const newValue : SequenceSheetData = {
229+ name : model . name ,
230+ signature : model . signature ,
231+ columns : result . cols ,
232+ rows : importedRows ,
233+ invocations : model . invocations
234+ } ;
235+
236+ onChange ( newValue ) ;
215237 setSnackMsg ( "Imported!" ) ;
216238 }
217239 } ;
@@ -248,12 +270,12 @@ export const SequenceSheetEditor: React.FC<SequenceSheetEditorProps> = ({
248270 } ;
249271
250272 // --- Invocations Logic ---
251- const handleAddInvocation = ( ) => {
273+ const handleAddInvocation = ( sequenceSheetName : string ) => {
252274 handleChangeField ( "invocations" , [
253275 ...value . invocations ,
254276 {
255277 id : nextInvId ,
256- sequenceSheetName : "" ,
278+ sequenceSheetName : sequenceSheetName ,
257279 signature : "" ,
258280 params : [ "" ] ,
259281 } ,
@@ -287,9 +309,9 @@ export const SequenceSheetEditor: React.FC<SequenceSheetEditorProps> = ({
287309 value . invocations . map ( ( inv ) =>
288310 inv . id === invId
289311 ? {
290- ...inv ,
291- params : inv . params . map ( ( v , idx ) => ( idx === paramIdx ? paramVal : v ) ) ,
292- }
312+ ...inv ,
313+ params : inv . params . map ( ( v , idx ) => ( idx === paramIdx ? paramVal : v ) ) ,
314+ }
293315 : inv
294316 )
295317 ) ;
@@ -414,7 +436,7 @@ export const SequenceSheetEditor: React.FC<SequenceSheetEditorProps> = ({
414436 < Button
415437 variant = "outlined"
416438 startIcon = { < DownloadIcon /> }
417- onClick = { handleExport }
439+ onClick = { handleExportJSONL }
418440 >
419441 Export JSONL
420442 </ Button >
@@ -482,7 +504,7 @@ export const SequenceSheetEditor: React.FC<SequenceSheetEditorProps> = ({
482504 < Typography variant = "h6" sx = { { mt : 6 } } > Invocations of Sequence Sheets</ Typography >
483505 < Button
484506 startIcon = { < AddIcon /> }
485- onClick = { handleAddInvocation }
507+ onClick = { ( e ) => handleAddInvocation ( value . name ) }
486508 sx = { { mt : 1 , mb : 2 } }
487509 variant = "contained"
488510 >
@@ -501,6 +523,7 @@ export const SequenceSheetEditor: React.FC<SequenceSheetEditorProps> = ({
501523 < TextField
502524 label = "Sequence Sheet Name"
503525 value = { inv . sequenceSheetName }
526+ disabled = { true }
504527 onChange = { e =>
505528 handleInvocationFieldChange ( inv . id , "sequenceSheetName" , e . target . value )
506529 }
0 commit comments