import { EditContext, EditEvent } from './index.data'; import { ActionMeta } from 'xstate'; import * as R from 'rambda'; import { isPlainObject } from 'valor-app-utils'; export function wrapAction( f: ( context: EditContext, { selectedRow, selectedCell, state }: EditEvent, meta?: ActionMeta, ) => any, ) { return { type: 'xstate.assign', assignment: f, }; } function isIdle(stateValue: any) { return stateValue === 'idle'; } function isSelecting(stateValue: any) { return ( stateValue === 'selecting' || (isPlainObject(stateValue) && !R.isNil(stateValue.selecting)) ); } function isEditing(stateValue: any) { return stateValue === 'editing' || (isPlainObject(stateValue) && !R.isNil(stateValue.editing)); } function isPicking(stateValue: any) { return true; } export const fsmPred = { isIdle, isSelecting, isEditing, isPicking, };