@zag-js/tabs 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
@@ -110,6 +110,6 @@ declare function connect<T extends PropTypes>(state: State, send: Send, normaliz
110
110
  indicatorProps: T["element"];
111
111
  };
112
112
 
113
- declare function machine(ctx: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
113
+ declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
114
114
 
115
115
  export { UserDefinedContext as Context, connect, machine };
package/dist/index.js CHANGED
@@ -194,6 +194,15 @@ function prevById(v, id, loop = true) {
194
194
  // ../../utilities/core/dist/index.mjs
195
195
  var first = (v) => v[0];
196
196
  var last = (v) => v[v.length - 1];
197
+ var isArray = (v) => Array.isArray(v);
198
+ var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
199
+ function compact(obj) {
200
+ if (obj === void 0)
201
+ return obj;
202
+ return Object.fromEntries(
203
+ Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject(value) ? compact(value) : value])
204
+ );
205
+ }
197
206
 
198
207
  // src/tabs.dom.ts
199
208
  var dom = defineDomHelpers({
@@ -405,7 +414,8 @@ function connect(state, send, normalize) {
405
414
  // src/tabs.machine.ts
406
415
  var import_core = require("@zag-js/core");
407
416
  var { not } = import_core.guards;
408
- function machine(ctx) {
417
+ function machine(userContext) {
418
+ const ctx = compact(userContext);
409
419
  return (0, import_core.createMachine)(
410
420
  {
411
421
  initial: "unknown",
package/dist/index.mjs CHANGED
@@ -167,6 +167,15 @@ function prevById(v, id, loop = true) {
167
167
  // ../../utilities/core/dist/index.mjs
168
168
  var first = (v) => v[0];
169
169
  var last = (v) => v[v.length - 1];
170
+ var isArray = (v) => Array.isArray(v);
171
+ var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
172
+ function compact(obj) {
173
+ if (obj === void 0)
174
+ return obj;
175
+ return Object.fromEntries(
176
+ Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject(value) ? compact(value) : value])
177
+ );
178
+ }
170
179
 
171
180
  // src/tabs.dom.ts
172
181
  var dom = defineDomHelpers({
@@ -378,7 +387,8 @@ function connect(state, send, normalize) {
378
387
  // src/tabs.machine.ts
379
388
  import { createMachine, guards } from "@zag-js/core";
380
389
  var { not } = guards;
381
- function machine(ctx) {
390
+ function machine(userContext) {
391
+ const ctx = compact(userContext);
382
392
  return createMachine(
383
393
  {
384
394
  initial: "unknown",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/tabs",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Core logic for the tabs widget implemented as a state machine",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -29,12 +29,12 @@
29
29
  "url": "https://github.com/chakra-ui/zag/issues"
30
30
  },
31
31
  "dependencies": {
32
- "@zag-js/core": "0.2.0",
32
+ "@zag-js/core": "0.2.1",
33
33
  "@zag-js/types": "0.3.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@zag-js/dom-utils": "0.2.0",
37
- "@zag-js/utils": "0.2.0"
37
+ "@zag-js/utils": "0.3.0"
38
38
  },
39
39
  "scripts": {
40
40
  "build-fast": "tsup src/index.ts --format=esm,cjs",