Skip to content

Instantly share code, notes, and snippets.

@cellog
Last active November 11, 2019 16:36
Show Gist options
  • Save cellog/afe560cdc9e1af916cf2652a584a2b58 to your computer and use it in GitHub Desktop.
Save cellog/afe560cdc9e1af916cf2652a584a2b58 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const fetchMachine = Machine({
id: 'Dataset upload/edit',
initial: 'idle',
context: {
title: "Untitled",
description: ''
},
states: {
idle: {
on: {
'click Title': 'edit Title',
'click Description': 'edit Description',
'click Upload Files': 'ITAR popup',
}
},
'edit Title': {
on: {
CHANGE: {
target: '',
actions: assign({
title: (context, event) => event.text
})
},
BLUR: 'idle',
}
},
'edit Description': {
on: {
CHANGE: {
target: '',
actions: assign({
description: (context, event) => event.text
})
},
BLUR: 'idle'
}
},
'ITAR popup': {
states: {
Checkboxes: {
type: 'parallel',
states: {
'I agree to terms': {
initial: 'unchecked',
states: {
checked: {
on: {
CLICK: 'unchecked',
}
},
unchecked: {
on: {
CLICK: 'checked',
}
}
}
},
'I am me': {
initial: 'unchecked',
states: {
checked: {
on: {
CLICK: 'unchecked',
}
},
unchecked: {
on: {
CLICK: 'checked',
}
}
}
},
},
onDone: 'Continue.enabled'
},
Continue: {
initial: 'disabled',
states: {
enabled: {
on: {
CLICK: '#Dataset upload/edit.Files Upload popup'
}
},
disabled: { type: 'final' },
}
},
},
},
'Files Upload popup': {
states: {
Upload: {
initial: 'disabled',
states: {
enabled: {
on: {
CLICK: '#Dataset upload/edit.idle',
}
},
disabled: { type: 'final' },
}
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment