@zag-js/core
Advanced tools
Comparing version 0.0.0-dev-20221111132133 to 0.0.0-dev-20221111134129
export { proxy, ref, snapshot, subscribe } from '@zag-js/store'; | ||
declare function deepMerge<T extends Record<string, any>>(source: T, ...objects: T[]): T; | ||
declare type Dict<T = any> = Record<string, T>; | ||
@@ -421,2 +423,2 @@ declare type MaybeArray<T> = T | T[]; | ||
export { AnyMachine, ContextFrom, EventFrom, Machine, MachineSrc, StateFrom, StateMachine, choose, createMachine, guards, mergeProps }; | ||
export { AnyMachine, ContextFrom, EventFrom, Machine, MachineSrc, StateFrom, StateMachine, choose, createMachine, deepMerge, guards, mergeProps }; |
@@ -31,2 +31,3 @@ "use strict"; | ||
createMachine: () => createMachine, | ||
deepMerge: () => deepMerge, | ||
guards: () => guards, | ||
@@ -95,2 +96,20 @@ mergeProps: () => mergeProps, | ||
// src/deep-merge.ts | ||
function deepMerge(source, ...objects) { | ||
for (const obj of objects) { | ||
const target = compact(obj); | ||
for (const key in target) { | ||
if (isObject(obj[key])) { | ||
if (!source[key]) { | ||
source[key] = {}; | ||
} | ||
deepMerge(source[key], obj[key]); | ||
} else { | ||
source[key] = obj[key]; | ||
} | ||
} | ||
} | ||
return source; | ||
} | ||
// src/utils.ts | ||
@@ -479,3 +498,3 @@ var import_store = require("@zag-js/store"); | ||
return; | ||
Object.assign(this.state.context, compact(context)); | ||
deepMerge(this.state.context, context); | ||
}); | ||
@@ -853,2 +872,3 @@ __publicField(this, "withContext", (context) => { | ||
createMachine, | ||
deepMerge, | ||
guards, | ||
@@ -855,0 +875,0 @@ mergeProps, |
{ | ||
"name": "@zag-js/core", | ||
"version": "0.0.0-dev-20221111132133", | ||
"version": "0.0.0-dev-20221111134129", | ||
"description": "A minimal implementation of xstate fsm for UI machines", | ||
@@ -35,3 +35,3 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@zag-js/utils": "0.0.0-dev-20221111132133" | ||
"@zag-js/utils": "0.0.0-dev-20221111134129" | ||
}, | ||
@@ -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
90834
2115