Created
June 23, 2021 17:04
-
-
Save garrettlancaster/112bb646beb0d2809709836eb6786859 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 machine = Machine({ | |
initial: 'Closed', | |
states: { | |
Closed: { | |
on: { | |
keydown: { | |
cond: 'isChar', | |
target: 'Open', | |
actions: 'focus' | |
} | |
} | |
}, | |
Open: { | |
on: { | |
closed: 'Closed' | |
} | |
} | |
} | |
}, { | |
actions: { | |
focus: (_, {select}) => { | |
console.log('focus', select) | |
Select2.focusSearch(select) | |
} | |
}, | |
guards: { | |
isChar: (_, {keydown}) => { | |
if (!keydown) { return; } | |
return keydown.key.length === 1; | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment