Created
          April 9, 2021 17:57 
        
      - 
      
- 
        Save AlexFrazer/a8c7bf23c194ef0d0be5c16b621aa0ef 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
    
  
  
    
  | // Available variables: | |
| // - Machine | |
| // - interpret | |
| // - assign | |
| // - send | |
| // - sendParent | |
| // - spawn | |
| // - raise | |
| // - actions | |
| // - XState (all XState exports) | |
| const fetchMachine = Machine({ | |
| id: 'formInput', | |
| initial: 'active', | |
| states: { | |
| active: { | |
| on: { | |
| DISABLE: 'disabled', | |
| }, | |
| type: 'parallel', | |
| states: { | |
| focus: { | |
| initial: 'unfocused', | |
| states: { | |
| focused: { | |
| on: { | |
| BLUR: 'unfocused', | |
| }, | |
| }, | |
| unfocused: { | |
| on: { | |
| FOCUS: 'focused', | |
| }, | |
| }, | |
| }, | |
| }, | |
| validation: { | |
| initial: 'pending', | |
| on: { | |
| CHANGE: { | |
| target: '.pending', | |
| actions: 'setValue', | |
| }, | |
| }, | |
| states: { | |
| pending: { | |
| invoke: { | |
| src: 'validateField', | |
| onDone: { | |
| target: 'valid', | |
| actions: [ | |
| sendParent('valid'), | |
| assign({ | |
| isValid: false, | |
| }), | |
| ] | |
| }, | |
| onError: { | |
| target: 'invalid', | |
| actions: [ | |
| sendParent('valid'), | |
| assign({ | |
| isValid: false, | |
| }) | |
| ] | |
| }, | |
| }, | |
| }, | |
| valid: {}, | |
| invalid: {}, | |
| }, | |
| }, | |
| }, | |
| }, | |
| disabled: { | |
| on: { | |
| ENABLE: 'active', | |
| }, | |
| }, | |
| }, | |
| }); | |
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment