Skip to content

Instantly share code, notes, and snippets.

@a8t
Last active October 7, 2020 16:03
Show Gist options
  • Save a8t/70f1569d56255cd4b96a21df13109642 to your computer and use it in GitHub Desktop.
Save a8t/70f1569d56255cd4b96a21df13109642 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
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