Last active
October 7, 2020 16:03
-
-
Save a8t/70f1569d56255cd4b96a21df13109642 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const documentUploadSheetStates = { | |
initial: 'idle', | |
states: { | |
idle: { | |
on: { | |
DELETE_ALL: 'idle', | |
FOCUS_INPUT: 'typing', | |
}, | |
}, | |
typing: { | |
on: { | |
ENTER_FILENAME: { | |
actions: 'setEmail', | |
}, | |
DELETE_ALL: 'idle', | |
BLUR_INPUT: 'idle', | |
}, | |
}, | |
}, | |
actions: { | |
setEmail: assign((context, event) => ({ | |
fileName: event.value, | |
})), | |
}, | |
}; | |
const userInterfaceMachine = Machine( | |
{ | |
id: 'UI', | |
initial: 'allClosed', | |
context: { | |
selectedDocumentTypeId: '', | |
fileName: '', | |
}, | |
states: { | |
allClosed: { | |
on: { | |
INITIALIZE_UPLOAD_PROCESS: 'documentTypePickerSheetOpen', | |
}, | |
}, | |
documentTypePickerSheetOpen: { | |
on: { | |
CANCEL: 'allClosed', | |
SELECT_DOCUMENT_TYPE: { | |
target: 'documentUploadSheetOpen', | |
actions: [ | |
'setSelectedDocumentType', 'openFilePicker' | |
], | |
}, | |
}, | |
}, | |
documentUploadSheetOpen: { | |
on: { | |
CANCEL: 'allClosed', | |
SUBMIT: 'allClosed', | |
}, | |
...documentUploadSheetStates, | |
}, | |
}, | |
}, | |
{ | |
actions: { | |
setSelectedDocumentType: assign((context, event) => ({ | |
selectedDocumentTypeId: event.value, | |
})), | |
openFilePicker: ()=> {} | |
}, | |
}, | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment