@zag-js/core
Advanced tools
Comparing version 0.0.0-dev-20220604174031 to 0.0.0-dev-20220604230945
@@ -5,3 +5,3 @@ import { StateMachine as S } from "./types"; | ||
declare function not<TContext, TState extends S.StateSchema, TEvent extends S.EventObject>(condition: S.Guard<TContext, TState, TEvent>): S.GuardHelper<TContext, TState, TEvent>; | ||
declare function isIn<TContext, TState extends S.StateSchema, TEvent extends S.EventObject>(...values: TState["value"][]): S.GuardExpression<TContext, TState, TEvent>; | ||
declare function stateIn<TContext, TState extends S.StateSchema, TEvent extends S.EventObject>(...values: TState["value"][]): S.GuardExpression<TContext, TState, TEvent>; | ||
export declare const guards: { | ||
@@ -11,3 +11,3 @@ or: typeof or; | ||
not: typeof not; | ||
isIn: typeof isIn; | ||
stateIn: typeof stateIn; | ||
}; | ||
@@ -14,0 +14,0 @@ export declare function choose<TContext, TState extends S.StateSchema, TEvent extends S.EventObject = S.AnyEventObject>(actions: Array<{ |
@@ -160,6 +160,6 @@ var __defProp = Object.defineProperty; | ||
} | ||
function isIn(...values) { | ||
function stateIn(...values) { | ||
return (_ctx, _evt, meta) => meta.state.matches(...values); | ||
} | ||
var guards = { or, and, not, isIn }; | ||
var guards = { or, and, not, stateIn }; | ||
function choose(actions) { | ||
@@ -355,2 +355,4 @@ return { | ||
return; | ||
this.performExitEffects(this.state.value, toEvent("machine.stop" /* Stop */)); | ||
this.executeActions(this.config.exit, toEvent("machine.stop" /* Stop */)); | ||
this.setState(null); | ||
@@ -365,3 +367,2 @@ this.setEvent("machine.stop" /* Stop */); | ||
this.stopContextListeners(); | ||
this.executeActions(this.config.exit, toEvent("machine.stop" /* Stop */)); | ||
this.status = "Stopped" /* Stopped */; | ||
@@ -368,0 +369,0 @@ return this; |
@@ -132,3 +132,3 @@ export declare type Dict<T = any> = Record<string, T>; | ||
type GuardMeta<TContext extends Dict, TState extends StateSchema, TEvent extends EventObject> = { | ||
state: State<TContext, TState, TEvent>; | ||
state: Pick<State<TContext, TState, TEvent>, "matches">; | ||
}; | ||
@@ -135,0 +135,0 @@ type GuardExpression<TContext, TState extends StateSchema, TEvent extends EventObject, TReturn = boolean> = (context: TContext, event: TEvent, guardMeta: GuardMeta<TContext, TState, TEvent>) => TReturn; |
{ | ||
"name": "@zag-js/core", | ||
"version": "0.0.0-dev-20220604174031", | ||
"version": "0.0.0-dev-20220604230945", | ||
"description": "A minimal implementation of xstate fsm for UI machines", | ||
@@ -40,3 +40,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@zag-js/utils": "0.0.0-dev-20220604174031", | ||
"@zag-js/utils": "0.0.0-dev-20220604230945", | ||
"klona": "^2.0.5", | ||
@@ -43,0 +43,0 @@ "valtio": "^1.6.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
237252
2082
+ Added@zag-js/utils@0.0.0-dev-20220604230945(transitive)
- Removed@zag-js/utils@0.0.0-dev-20220604174031(transitive)