@zag-js/core
Advanced tools
Comparing version 0.0.0-dev-20221103102301 to 0.0.0-dev-20221108152001
@@ -346,3 +346,3 @@ export { proxy, ref, snapshot, subscribe } from '@zag-js/store'; | ||
withContext: (context: Partial<Writable<TContext>>) => Machine<TContext, TState, TEvent>; | ||
setActions: (actions: Partial<StateMachine.MachineOptions<TContext, TState, TEvent>>["actions"]) => void; | ||
setOptions: (options: Partial<StateMachine.MachineOptions<TContext, TState, TEvent>>) => void; | ||
private getStateNode; | ||
@@ -349,0 +349,0 @@ private getNextStateInfo; |
@@ -72,2 +72,9 @@ "use strict"; | ||
var isFunction = (v) => typeof v === "function"; | ||
function compact(obj) { | ||
if (obj === void 0) | ||
return obj; | ||
return Object.fromEntries( | ||
Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject(value) ? compact(value) : value]) | ||
); | ||
} | ||
function warn(...a) { | ||
@@ -471,12 +478,14 @@ const m = a.length === 1 ? a[0] : a[1]; | ||
return; | ||
for (const key in context) { | ||
this.state.context[key] = context[key]; | ||
} | ||
Object.assign(this.state.context, compact(context)); | ||
}); | ||
__publicField(this, "withContext", (context) => { | ||
const newContext = { ...this.config.context, ...context }; | ||
const newContext = { ...this.config.context, ...compact(context) }; | ||
return new Machine({ ...this.config, context: newContext }, this.options); | ||
}); | ||
__publicField(this, "setActions", (actions) => { | ||
this.actionMap = { ...this.actionMap, ...actions }; | ||
__publicField(this, "setOptions", (options) => { | ||
const opts = compact(options); | ||
this.actionMap = { ...this.actionMap, ...opts.actions }; | ||
this.delayMap = { ...this.delayMap, ...opts.delays }; | ||
this.activityMap = { ...this.activityMap, ...opts.activities }; | ||
this.guardMap = { ...this.guardMap, ...opts.guards }; | ||
}); | ||
@@ -483,0 +492,0 @@ __publicField(this, "getStateNode", (state) => { |
{ | ||
"name": "@zag-js/core", | ||
"version": "0.0.0-dev-20221103102301", | ||
"version": "0.0.0-dev-20221108152001", | ||
"description": "A minimal implementation of xstate fsm for UI machines", | ||
@@ -31,7 +31,7 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@zag-js/store": "0.0.0-dev-20221103102301", | ||
"@zag-js/store": "0.2.0", | ||
"klona": "2.0.5" | ||
}, | ||
"devDependencies": { | ||
"@zag-js/utils": "0.0.0-dev-20221103102301" | ||
"@zag-js/utils": "0.0.0-dev-20221108152001" | ||
}, | ||
@@ -38,0 +38,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
90221
2084
+ Added@zag-js/store@0.2.0(transitive)
- Removed@zag-js/store@0.0.0-dev-20221103102301(transitive)
Updated@zag-js/store@0.2.0