@zag-js/core 1.22.0 → 1.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,12 +1,14 @@
1
+ import { isActiveElement } from '@zag-js/dom-query';
2
+
1
3
  interface Props {
2
- [key: string]: any;
4
+ [key: string | symbol]: any;
3
5
  }
4
6
  type TupleTypes<T extends any[]> = T[number];
5
7
  type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
6
8
  declare function mergeProps<T extends Props>(...args: T[]): UnionToIntersection<TupleTypes<T[]>>;
7
9
 
8
10
  type NoInfer<T> = [T][T extends any ? 0 : never];
9
- declare function memo<TDeps extends any[], TDepArgs, TResult>(getDeps: (depArgs: TDepArgs) => [...TDeps], fn: (...args: NoInfer<[...TDeps]>) => TResult, opts?: {
11
+ declare function memo<TDeps extends any[], TDepArgs, TResult>(getDeps: (depArgs: TDepArgs) => [...TDeps], fn: (args: NoInfer<[...TDeps]>, deps: TDepArgs) => TResult, opts?: {
10
12
  onChange?: ((result: TResult) => void) | undefined;
11
13
  }): (depArgs: TDepArgs) => TResult;
12
14
 
@@ -246,7 +248,7 @@ declare function createScope(props: Pick<Scope, "id" | "ids" | "getRootNode">):
246
248
  getDoc: () => Document;
247
249
  getWin: () => Window & typeof globalThis;
248
250
  getActiveElement: () => HTMLElement | null;
249
- isActiveElement: (elem: HTMLElement | null) => boolean;
251
+ isActiveElement: typeof isActiveElement;
250
252
  getById: <T extends Element = HTMLElement>(id: string) => T | null;
251
253
  id?: string | undefined | undefined;
252
254
  ids?: Record<string, any> | undefined;
package/dist/index.d.ts CHANGED
@@ -1,12 +1,14 @@
1
+ import { isActiveElement } from '@zag-js/dom-query';
2
+
1
3
  interface Props {
2
- [key: string]: any;
4
+ [key: string | symbol]: any;
3
5
  }
4
6
  type TupleTypes<T extends any[]> = T[number];
5
7
  type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
6
8
  declare function mergeProps<T extends Props>(...args: T[]): UnionToIntersection<TupleTypes<T[]>>;
7
9
 
8
10
  type NoInfer<T> = [T][T extends any ? 0 : never];
9
- declare function memo<TDeps extends any[], TDepArgs, TResult>(getDeps: (depArgs: TDepArgs) => [...TDeps], fn: (...args: NoInfer<[...TDeps]>) => TResult, opts?: {
11
+ declare function memo<TDeps extends any[], TDepArgs, TResult>(getDeps: (depArgs: TDepArgs) => [...TDeps], fn: (args: NoInfer<[...TDeps]>, deps: TDepArgs) => TResult, opts?: {
10
12
  onChange?: ((result: TResult) => void) | undefined;
11
13
  }): (depArgs: TDepArgs) => TResult;
12
14
 
@@ -246,7 +248,7 @@ declare function createScope(props: Pick<Scope, "id" | "ids" | "getRootNode">):
246
248
  getDoc: () => Document;
247
249
  getWin: () => Window & typeof globalThis;
248
250
  getActiveElement: () => HTMLElement | null;
249
- isActiveElement: (elem: HTMLElement | null) => boolean;
251
+ isActiveElement: typeof isActiveElement;
250
252
  getById: <T extends Element = HTMLElement>(id: string) => T | null;
251
253
  id?: string | undefined | undefined;
252
254
  ids?: Record<string, any> | undefined;
package/dist/index.js CHANGED
@@ -46,6 +46,10 @@ function mergeProps(...args) {
46
46
  result[key] = props[key];
47
47
  }
48
48
  }
49
+ const symbols = Object.getOwnPropertySymbols(props);
50
+ for (let symbol of symbols) {
51
+ result[symbol] = props[symbol];
52
+ }
49
53
  }
50
54
  return result;
51
55
  }
@@ -57,7 +61,7 @@ function memo(getDeps, fn, opts) {
57
61
  const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index) => !utils.isEqual(deps[index], dep));
58
62
  if (!depsChanged) return result;
59
63
  deps = newDeps;
60
- result = fn(...newDeps);
64
+ result = fn(newDeps, depArgs);
61
65
  opts?.onChange?.(result);
62
66
  return result;
63
67
  };
@@ -113,7 +117,6 @@ function createScope(props) {
113
117
  const getDoc = () => domQuery.getDocument(getRootNode());
114
118
  const getWin = () => getDoc().defaultView ?? window;
115
119
  const getActiveElementFn = () => domQuery.getActiveElement(getRootNode());
116
- const isActiveElement = (elem) => elem === getActiveElementFn();
117
120
  const getById = (id) => getRootNode().getElementById(id);
118
121
  return {
119
122
  ...props,
@@ -121,7 +124,7 @@ function createScope(props) {
121
124
  getDoc,
122
125
  getWin,
123
126
  getActiveElement: getActiveElementFn,
124
- isActiveElement,
127
+ isActiveElement: domQuery.isActiveElement,
125
128
  getById
126
129
  };
127
130
  }
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { callAll, isEqual, isString } from '@zag-js/utils';
2
- import { getActiveElement, getDocument } from '@zag-js/dom-query';
2
+ import { isActiveElement, getActiveElement, getDocument } from '@zag-js/dom-query';
3
3
 
4
4
  // src/merge-props.ts
5
5
  var clsx = (...args) => args.map((str) => str?.trim?.()).filter(Boolean).join(" ");
@@ -44,6 +44,10 @@ function mergeProps(...args) {
44
44
  result[key] = props[key];
45
45
  }
46
46
  }
47
+ const symbols = Object.getOwnPropertySymbols(props);
48
+ for (let symbol of symbols) {
49
+ result[symbol] = props[symbol];
50
+ }
47
51
  }
48
52
  return result;
49
53
  }
@@ -55,7 +59,7 @@ function memo(getDeps, fn, opts) {
55
59
  const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index) => !isEqual(deps[index], dep));
56
60
  if (!depsChanged) return result;
57
61
  deps = newDeps;
58
- result = fn(...newDeps);
62
+ result = fn(newDeps, depArgs);
59
63
  opts?.onChange?.(result);
60
64
  return result;
61
65
  };
@@ -111,7 +115,6 @@ function createScope(props) {
111
115
  const getDoc = () => getDocument(getRootNode());
112
116
  const getWin = () => getDoc().defaultView ?? window;
113
117
  const getActiveElementFn = () => getActiveElement(getRootNode());
114
- const isActiveElement = (elem) => elem === getActiveElementFn();
115
118
  const getById = (id) => getRootNode().getElementById(id);
116
119
  return {
117
120
  ...props,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/core",
3
- "version": "1.22.0",
3
+ "version": "1.23.0",
4
4
  "description": "A minimal implementation of xstate fsm for UI machines",
5
5
  "keywords": [
6
6
  "ui-machines",
@@ -25,8 +25,8 @@
25
25
  "url": "https://github.com/chakra-ui/zag/issues"
26
26
  },
27
27
  "dependencies": {
28
- "@zag-js/utils": "1.22.0",
29
- "@zag-js/dom-query": "1.22.0"
28
+ "@zag-js/utils": "1.23.0",
29
+ "@zag-js/dom-query": "1.23.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "clean-package": "2.2.0"