@zag-js/pin-input 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
@@ -142,6 +142,6 @@ declare function connect<T extends PropTypes>(state: State, send: Send, normaliz
142
142
  }): T["input"];
143
143
  };
144
144
 
145
- declare function machine(ctx: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
145
+ declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
146
146
 
147
147
  export { UserDefinedContext as Context, connect, machine };
package/dist/index.js CHANGED
@@ -136,6 +136,15 @@ var visuallyHiddenStyle = {
136
136
  };
137
137
 
138
138
  // ../../utilities/core/dist/index.mjs
139
+ var isArray = (v) => Array.isArray(v);
140
+ var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
141
+ function compact(obj) {
142
+ if (obj === void 0)
143
+ return obj;
144
+ return Object.fromEntries(
145
+ Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject(value) ? compact(value) : value])
146
+ );
147
+ }
139
148
  function invariant(...a) {
140
149
  const m = a.length === 1 ? a[0] : a[1];
141
150
  const c = a.length === 2 ? a[0] : true;
@@ -334,7 +343,8 @@ function dispatchInputValueEvent(el, value) {
334
343
 
335
344
  // src/pin-input.machine.ts
336
345
  var { and, not } = import_core.guards;
337
- function machine(ctx) {
346
+ function machine(userContext) {
347
+ const ctx = compact(userContext);
338
348
  return (0, import_core.createMachine)(
339
349
  {
340
350
  id: "pin-input",
package/dist/index.mjs CHANGED
@@ -109,6 +109,15 @@ var visuallyHiddenStyle = {
109
109
  };
110
110
 
111
111
  // ../../utilities/core/dist/index.mjs
112
+ var isArray = (v) => Array.isArray(v);
113
+ var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
114
+ function compact(obj) {
115
+ if (obj === void 0)
116
+ return obj;
117
+ return Object.fromEntries(
118
+ Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject(value) ? compact(value) : value])
119
+ );
120
+ }
112
121
  function invariant(...a) {
113
122
  const m = a.length === 1 ? a[0] : a[1];
114
123
  const c = a.length === 2 ? a[0] : true;
@@ -307,7 +316,8 @@ function dispatchInputValueEvent(el, value) {
307
316
 
308
317
  // src/pin-input.machine.ts
309
318
  var { and, not } = guards;
310
- function machine(ctx) {
319
+ function machine(userContext) {
320
+ const ctx = compact(userContext);
311
321
  return createMachine(
312
322
  {
313
323
  id: "pin-input",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/pin-input",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Core logic for the pin-input widget implemented as a state machine",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -29,13 +29,13 @@
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
37
  "@zag-js/form-utils": "0.2.0",
38
- "@zag-js/utils": "0.2.0"
38
+ "@zag-js/utils": "0.3.0"
39
39
  },
40
40
  "scripts": {
41
41
  "build-fast": "tsup src/index.ts --format=esm,cjs",