@zag-js/popover 0.2.0 → 0.2.1

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.ts CHANGED
@@ -98,6 +98,6 @@ declare function connect<T extends PropTypes>(state: State, send: Send, normaliz
98
98
  closeButtonProps: T["button"];
99
99
  };
100
100
 
101
- declare function machine(ctx: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
101
+ declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
102
102
 
103
103
  export { UserDefinedContext as Context, connect, machine };
package/dist/index.js CHANGED
@@ -212,6 +212,15 @@ var runIfFn2 = (v, ...a) => {
212
212
  const res = typeof v === "function" ? v(...a) : v;
213
213
  return res != null ? res : void 0;
214
214
  };
215
+ var isArray = (v) => Array.isArray(v);
216
+ var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
217
+ function compact(obj) {
218
+ if (obj === void 0)
219
+ return obj;
220
+ return Object.fromEntries(
221
+ Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject(value) ? compact(value) : value])
222
+ );
223
+ }
215
224
 
216
225
  // src/popover.dom.ts
217
226
  var dom = defineDomHelpers({
@@ -356,7 +365,8 @@ var import_popper2 = require("@zag-js/popper");
356
365
  var import_remove_scroll = require("@zag-js/remove-scroll");
357
366
  var import_focus_trap = require("focus-trap");
358
367
  var { and, or, not } = import_core.guards;
359
- function machine(ctx) {
368
+ function machine(userContext) {
369
+ const ctx = compact(userContext);
360
370
  return (0, import_core.createMachine)(
361
371
  {
362
372
  id: "popover",
package/dist/index.mjs CHANGED
@@ -185,6 +185,15 @@ var runIfFn2 = (v, ...a) => {
185
185
  const res = typeof v === "function" ? v(...a) : v;
186
186
  return res != null ? res : void 0;
187
187
  };
188
+ var isArray = (v) => Array.isArray(v);
189
+ var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
190
+ function compact(obj) {
191
+ if (obj === void 0)
192
+ return obj;
193
+ return Object.fromEntries(
194
+ Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject(value) ? compact(value) : value])
195
+ );
196
+ }
188
197
 
189
198
  // src/popover.dom.ts
190
199
  var dom = defineDomHelpers({
@@ -329,7 +338,8 @@ import { getPlacement } from "@zag-js/popper";
329
338
  import { preventBodyScroll } from "@zag-js/remove-scroll";
330
339
  import { createFocusTrap } from "focus-trap";
331
340
  var { and, or, not } = guards;
332
- function machine(ctx) {
341
+ function machine(userContext) {
342
+ const ctx = compact(userContext);
333
343
  return createMachine(
334
344
  {
335
345
  id: "popover",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/popover",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Core logic for the popover widget implemented as a state machine",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@zag-js/aria-hidden": "0.2.0",
33
- "@zag-js/core": "0.2.0",
33
+ "@zag-js/core": "0.2.1",
34
34
  "@zag-js/dismissable": "0.2.0",
35
35
  "@zag-js/popper": "0.2.0",
36
36
  "@zag-js/remove-scroll": "0.2.0",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "@zag-js/dom-utils": "0.2.0",
42
- "@zag-js/utils": "0.2.0"
42
+ "@zag-js/utils": "0.3.0"
43
43
  },
44
44
  "scripts": {
45
45
  "build-fast": "tsup src/index.ts --format=esm,cjs",