Created
October 20, 2020 04:42
-
-
Save rayou/a90d77dcf3425391d59998b0faa68043 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 dropdownMachine = Machine({ | |
| id: "dropdown", | |
| initial: "idle", | |
| context: { | |
| items: [], | |
| query: "", | |
| }, | |
| on: { | |
| UPDATE_ITEMS: { | |
| actions: "updateItems", | |
| }, | |
| }, | |
| states: { | |
| idle: { | |
| on: { | |
| FOCUS: { | |
| target: "focus", | |
| actions: [ | |
| "selectText", | |
| "updateContainerHeight", | |
| "scrollToSelectedItem", | |
| ], | |
| }, | |
| }, | |
| }, | |
| focus: { | |
| initial: "focused", | |
| on: { | |
| EDITING: { | |
| target: ".editing", | |
| actions: "assignQuery", | |
| }, | |
| BLUR: "idle", | |
| }, | |
| states: { | |
| focused: {}, | |
| editing: {}, | |
| }, | |
| }, | |
| }, | |
| }, | |
| { | |
| actions: { | |
| updateItems: assign((ctx, evt) => ({ | |
| items: evt.type === "UPDATE_ITEMS" ? evt.items : ctx.items, | |
| })), | |
| assignQuery: assign((ctx, evt) => ({ | |
| query: evt.type === "EDITING" ? evt.query : ctx.query, | |
| })), | |
| }, | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment