import { Machine } from 'xstate'; import { EditContext, EditSchema, EditEvent } from '../index.data'; import { guards, actions } from './helper'; function getMachine(defaultContext = {}) { return Machine({ id: 'cell-picker-machine', context: { usage: 'cell-picker', ...defaultContext } as EditContext, initial: 'idle', states: { idle: { on: { 'MOUSE.DOWN': { cond: guards.hasSelected, target: 'selecting.cell', actions: actions.select, }, }, }, selecting: { states: { cell: { on: { 'MOUSE.DOWN': { cond: guards.hasSelected, actions: actions.select, }, 'MOUSE.MOVE': { cond: guards.hasSelected, actions: actions.select, }, 'MOUSE.UP': { cond: guards.hasSelected, actions: actions.select, }, }, }, rows: {}, }, }, editing: {}, } as any, }); } export default getMachine;