@zag-js/core
Advanced tools
Comparing version 0.0.0-dev-20240611102459 to 0.0.0-dev-20240611130830
@@ -20,6 +20,3 @@ "use strict"; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var __publicField = (obj, key, value) => { | ||
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
return value; | ||
}; | ||
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
@@ -46,4 +43,3 @@ // src/index.ts | ||
function clear(v) { | ||
while (v.length > 0) | ||
v.pop(); | ||
while (v.length > 0) v.pop(); | ||
return v; | ||
@@ -145,4 +141,3 @@ } | ||
function toArray(value) { | ||
if (!value) | ||
return []; | ||
if (!value) return []; | ||
return isArray(value) ? value.slice() : [value]; | ||
@@ -250,4 +245,3 @@ } | ||
get changed() { | ||
if (this.event.value === "machine.init" /* Init */ || !this.previousValue) | ||
return false; | ||
if (this.event.value === "machine.init" /* Init */ || !this.previousValue) return false; | ||
return this.value !== this.previousValue; | ||
@@ -262,4 +256,3 @@ } | ||
return (context, event) => { | ||
if (isNumber(delay)) | ||
return delay; | ||
if (isNumber(delay)) return delay; | ||
if (isFunction(delay)) { | ||
@@ -369,4 +362,3 @@ return delay(context, event); | ||
const { watch } = this.config; | ||
if (!watch) | ||
return; | ||
if (!watch) return; | ||
let prev = (0, import_store2.snapshot)(this.state.context); | ||
@@ -377,4 +369,3 @@ const cleanup = (0, import_store2.subscribe)(this.state.context, () => { | ||
const isEqual = this.options.compareFns?.[key] ?? Object.is; | ||
if (isEqual(prev[key], next[key])) | ||
continue; | ||
if (isEqual(prev[key], next[key])) continue; | ||
this.executeActions(fn, this.state.event); | ||
@@ -388,4 +379,3 @@ } | ||
__publicField(this, "stop", () => { | ||
if (this.status === "Stopped" /* Stopped */) | ||
return; | ||
if (this.status === "Stopped" /* Stopped */) return; | ||
this.performExitEffects(this.state.value, toEvent("machine.stop" /* Stop */)); | ||
@@ -466,4 +456,3 @@ this.executeActions(this.config.exit, toEvent("machine.stop" /* Stop */)); | ||
const actor = runIfFn(src); | ||
if (id) | ||
actor.id = id; | ||
if (id) actor.id = id; | ||
actor.type = "machine.actor" /* Actor */; | ||
@@ -478,4 +467,3 @@ actor.setParent(this); | ||
__publicField(this, "stopActivity", (key) => { | ||
if (!this.state.value) | ||
return; | ||
if (!this.state.value) return; | ||
const cleanups = this.activityEvents.get(this.state.value); | ||
@@ -486,4 +474,3 @@ cleanups?.get(key)?.(); | ||
__publicField(this, "addActivityCleanup", (state, key, cleanup) => { | ||
if (!state) | ||
return; | ||
if (!state) return; | ||
if (!this.activityEvents.has(state)) { | ||
@@ -509,4 +496,3 @@ this.activityEvents.set(state, /* @__PURE__ */ new Map([[key, cleanup]])); | ||
__publicField(this, "setContext", (context) => { | ||
if (!context) | ||
return; | ||
if (!context) return; | ||
deepMerge(this.state.context, compact(context)); | ||
@@ -522,4 +508,3 @@ }); | ||
__publicField(this, "getStateNode", (state) => { | ||
if (!state) | ||
return; | ||
if (!state) return; | ||
return this.config.states?.[state]; | ||
@@ -568,4 +553,3 @@ }); | ||
const event = this.state.event; | ||
if (!stateNode || !stateNode.after) | ||
return; | ||
if (!stateNode || !stateNode.after) return; | ||
const entries = []; | ||
@@ -575,4 +559,3 @@ const exits = []; | ||
const transition = this.determineTransition(stateNode.after, event); | ||
if (!transition) | ||
return; | ||
if (!transition) return; | ||
if (!hasProp(transition, "delay")) { | ||
@@ -639,4 +622,3 @@ throw new Error(`[@zag-js/core > after] Delay is required for after transition: ${JSON.stringify(transition)}`); | ||
__publicField(this, "createEveryActivities", (every, callbackfn) => { | ||
if (!every) | ||
return; | ||
if (!every) return; | ||
if (isArray(every)) { | ||
@@ -651,4 +633,3 @@ const picked = toArray(every).find((transition) => { | ||
}); | ||
if (!picked) | ||
return; | ||
if (!picked) return; | ||
const determineDelay = determineDelayFn(picked.delay, this.delayMap); | ||
@@ -688,4 +669,3 @@ const delay = determineDelay(this.contextSnapshot, this.state.event); | ||
const currentState = this.state.value; | ||
if (currentState === "") | ||
return; | ||
if (currentState === "") return; | ||
const stateNode = current ? this.getStateNode(current) : void 0; | ||
@@ -900,4 +880,3 @@ this.stopActivities(currentState); | ||
if (isString(a)) { | ||
if (isString(b)) | ||
return `${a};${b}`; | ||
if (isString(b)) return `${a};${b}`; | ||
a = serialize(a); | ||
@@ -904,0 +883,0 @@ } else if (isString(b)) { |
{ | ||
"name": "@zag-js/core", | ||
"version": "0.0.0-dev-20240611102459", | ||
"version": "0.0.0-dev-20240611130830", | ||
"description": "A minimal implementation of xstate fsm for UI machines", | ||
@@ -30,7 +30,7 @@ "keywords": [ | ||
"klona": "2.0.6", | ||
"@zag-js/store": "0.0.0-dev-20240611102459" | ||
"@zag-js/store": "0.0.0-dev-20240611130830" | ||
}, | ||
"devDependencies": { | ||
"clean-package": "2.2.0", | ||
"@zag-js/utils": "0.0.0-dev-20240611102459" | ||
"@zag-js/utils": "0.0.0-dev-20240611130830" | ||
}, | ||
@@ -37,0 +37,0 @@ "clean-package": "../../clean-package.config.json", |
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
296333
3529
+ Added@zag-js/store@0.0.0-dev-20240611130830(transitive)
- Removed@zag-js/store@0.0.0-dev-20240611102459(transitive)