@zag-js/pin-input 0.2.7 → 0.2.8

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.
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-BJXKBZJG.mjs";
4
4
  import {
5
5
  dom
6
- } from "./chunk-OI3DK2PT.mjs";
6
+ } from "./chunk-APRO2TYE.mjs";
7
7
 
8
8
  // ../../utilities/dom/src/attrs.ts
9
9
  var dataAttr = (guard) => {
@@ -29,25 +29,7 @@ function defineDomHelpers(helpers) {
29
29
  return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
30
30
  },
31
31
  getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
32
- getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
33
- createEmitter: (ctx, target) => {
34
- const win = dom2.getWin(ctx);
35
- return function emit(evt, detail, options) {
36
- const { bubbles = true, cancelable, composed = true } = options != null ? options : {};
37
- const eventName = `zag:${evt}`;
38
- const init = { bubbles, cancelable, composed, detail };
39
- const event = new win.CustomEvent(eventName, init);
40
- target.dispatchEvent(event);
41
- };
42
- },
43
- createListener: (target) => {
44
- return function listen(evt, handler) {
45
- const eventName = `zag:${evt}`;
46
- const listener = (e) => handler(e);
47
- target.addEventListener(eventName, listener);
48
- return () => target.removeEventListener(eventName, listener);
49
- };
50
- }
32
+ getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
51
33
  };
52
34
  return {
53
35
  ...dom2,
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  dom,
6
6
  getWindow
7
- } from "./chunk-OI3DK2PT.mjs";
7
+ } from "./chunk-APRO2TYE.mjs";
8
8
 
9
9
  // src/pin-input.machine.ts
10
10
  import { createMachine, guards } from "@zag-js/core";
@@ -266,7 +266,7 @@ function machine(userContext) {
266
266
  setPastedValue(ctx2, evt) {
267
267
  raf(() => {
268
268
  const startIndex = ctx2.focusedValue ? 1 : 0;
269
- const value = evt.value.substring(startIndex, ctx2.valueLength);
269
+ const value = evt.value.substring(startIndex, startIndex + ctx2.valueLength);
270
270
  assign(ctx2, value);
271
271
  });
272
272
  },
package/dist/index.js CHANGED
@@ -92,25 +92,7 @@ function defineDomHelpers(helpers) {
92
92
  return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
93
93
  },
94
94
  getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
95
- getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
96
- createEmitter: (ctx, target) => {
97
- const win = dom2.getWin(ctx);
98
- return function emit(evt, detail, options) {
99
- const { bubbles = true, cancelable, composed = true } = options != null ? options : {};
100
- const eventName = `zag:${evt}`;
101
- const init = { bubbles, cancelable, composed, detail };
102
- const event = new win.CustomEvent(eventName, init);
103
- target.dispatchEvent(event);
104
- };
105
- },
106
- createListener: (target) => {
107
- return function listen(evt, handler) {
108
- const eventName = `zag:${evt}`;
109
- const listener = (e) => handler(e);
110
- target.addEventListener(eventName, listener);
111
- return () => target.removeEventListener(eventName, listener);
112
- };
113
- }
95
+ getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
114
96
  };
115
97
  return {
116
98
  ...dom2,
@@ -593,7 +575,7 @@ function machine(userContext) {
593
575
  setPastedValue(ctx2, evt) {
594
576
  raf(() => {
595
577
  const startIndex = ctx2.focusedValue ? 1 : 0;
596
- const value = evt.value.substring(startIndex, ctx2.valueLength);
578
+ const value = evt.value.substring(startIndex, startIndex + ctx2.valueLength);
597
579
  assign(ctx2, value);
598
580
  });
599
581
  },
package/dist/index.mjs CHANGED
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  connect
3
- } from "./chunk-QX3A66VS.mjs";
3
+ } from "./chunk-3SENCEI3.mjs";
4
4
  import {
5
5
  anatomy
6
6
  } from "./chunk-BJXKBZJG.mjs";
7
7
  import {
8
8
  machine
9
- } from "./chunk-6HKN4SOY.mjs";
9
+ } from "./chunk-CDDLX3AG.mjs";
10
10
  import "./chunk-NT4W6JYX.mjs";
11
- import "./chunk-OI3DK2PT.mjs";
11
+ import "./chunk-APRO2TYE.mjs";
12
12
  export {
13
13
  anatomy,
14
14
  connect,
@@ -68,25 +68,7 @@ function defineDomHelpers(helpers) {
68
68
  return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
69
69
  },
70
70
  getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
71
- getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
72
- createEmitter: (ctx, target) => {
73
- const win = dom2.getWin(ctx);
74
- return function emit(evt, detail, options) {
75
- const { bubbles = true, cancelable, composed = true } = options != null ? options : {};
76
- const eventName = `zag:${evt}`;
77
- const init = { bubbles, cancelable, composed, detail };
78
- const event = new win.CustomEvent(eventName, init);
79
- target.dispatchEvent(event);
80
- };
81
- },
82
- createListener: (target) => {
83
- return function listen(evt, handler) {
84
- const eventName = `zag:${evt}`;
85
- const listener = (e) => handler(e);
86
- target.addEventListener(eventName, listener);
87
- return () => target.removeEventListener(eventName, listener);
88
- };
89
- }
71
+ getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
90
72
  };
91
73
  return {
92
74
  ...dom2,
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  connect
3
- } from "./chunk-QX3A66VS.mjs";
3
+ } from "./chunk-3SENCEI3.mjs";
4
4
  import "./chunk-BJXKBZJG.mjs";
5
5
  import "./chunk-NT4W6JYX.mjs";
6
- import "./chunk-OI3DK2PT.mjs";
6
+ import "./chunk-APRO2TYE.mjs";
7
7
  export {
8
8
  connect
9
9
  };
@@ -18,10 +18,6 @@ declare const dom: {
18
18
  getById: <T = HTMLElement>(ctx: {
19
19
  getRootNode?: (() => Node | Document | ShadowRoot) | undefined;
20
20
  }, id: string) => T | null;
21
- createEmitter: (ctx: {
22
- getRootNode?: (() => Node | Document | ShadowRoot) | undefined;
23
- }, target: HTMLElement) => (evt: string, detail: Record<string, any>, options?: EventInit | undefined) => void;
24
- createListener: (target: HTMLElement) => <T_1 = any>(evt: string, handler: (e: CustomEvent<T_1>) => void) => () => void;
25
21
  } & {
26
22
  getRootId: (ctx: MachineContext) => string;
27
23
  getInputId: (ctx: MachineContext, id: string) => string;
@@ -51,25 +51,7 @@ function defineDomHelpers(helpers) {
51
51
  return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
52
52
  },
53
53
  getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
54
- getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
55
- createEmitter: (ctx, target) => {
56
- const win = dom2.getWin(ctx);
57
- return function emit(evt, detail, options) {
58
- const { bubbles = true, cancelable, composed = true } = options != null ? options : {};
59
- const eventName = `zag:${evt}`;
60
- const init = { bubbles, cancelable, composed, detail };
61
- const event = new win.CustomEvent(eventName, init);
62
- target.dispatchEvent(event);
63
- };
64
- },
65
- createListener: (target) => {
66
- return function listen(evt, handler) {
67
- const eventName = `zag:${evt}`;
68
- const listener = (e) => handler(e);
69
- target.addEventListener(eventName, listener);
70
- return () => target.removeEventListener(eventName, listener);
71
- };
72
- }
54
+ getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
73
55
  };
74
56
  return {
75
57
  ...dom2,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  dom
3
- } from "./chunk-OI3DK2PT.mjs";
3
+ } from "./chunk-APRO2TYE.mjs";
4
4
  export {
5
5
  dom
6
6
  };
@@ -69,25 +69,7 @@ function defineDomHelpers(helpers) {
69
69
  return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
70
70
  },
71
71
  getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
72
- getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
73
- createEmitter: (ctx, target) => {
74
- const win = dom2.getWin(ctx);
75
- return function emit(evt, detail, options) {
76
- const { bubbles = true, cancelable, composed = true } = options != null ? options : {};
77
- const eventName = `zag:${evt}`;
78
- const init = { bubbles, cancelable, composed, detail };
79
- const event = new win.CustomEvent(eventName, init);
80
- target.dispatchEvent(event);
81
- };
82
- },
83
- createListener: (target) => {
84
- return function listen(evt, handler) {
85
- const eventName = `zag:${evt}`;
86
- const listener = (e) => handler(e);
87
- target.addEventListener(eventName, listener);
88
- return () => target.removeEventListener(eventName, listener);
89
- };
90
- }
72
+ getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
91
73
  };
92
74
  return {
93
75
  ...dom2,
@@ -382,7 +364,7 @@ function machine(userContext) {
382
364
  setPastedValue(ctx2, evt) {
383
365
  raf(() => {
384
366
  const startIndex = ctx2.focusedValue ? 1 : 0;
385
- const value = evt.value.substring(startIndex, ctx2.valueLength);
367
+ const value = evt.value.substring(startIndex, startIndex + ctx2.valueLength);
386
368
  assign(ctx2, value);
387
369
  });
388
370
  },
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  machine
3
- } from "./chunk-6HKN4SOY.mjs";
3
+ } from "./chunk-CDDLX3AG.mjs";
4
4
  import "./chunk-NT4W6JYX.mjs";
5
- import "./chunk-OI3DK2PT.mjs";
5
+ import "./chunk-APRO2TYE.mjs";
6
6
  export {
7
7
  machine
8
8
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/pin-input",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "Core logic for the pin-input widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -27,12 +27,12 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@zag-js/anatomy": "0.1.3",
30
- "@zag-js/core": "0.2.4",
31
- "@zag-js/types": "0.3.2"
30
+ "@zag-js/core": "0.2.5",
31
+ "@zag-js/types": "0.3.3"
32
32
  },
33
33
  "devDependencies": {
34
34
  "clean-package": "2.2.0",
35
- "@zag-js/dom-utils": "0.2.2",
35
+ "@zag-js/dom-utils": "0.2.3",
36
36
  "@zag-js/form-utils": "0.2.3",
37
37
  "@zag-js/utils": "0.3.2"
38
38
  },