@zag-js/number-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,16 +3,16 @@ import {
3
3
  } from "./chunk-XHRILSH3.mjs";
4
4
  import {
5
5
  dom
6
- } from "./chunk-2SIS62IB.mjs";
6
+ } from "./chunk-EUVYGWZ6.mjs";
7
7
  import {
8
8
  utils
9
- } from "./chunk-GWZPUXGU.mjs";
9
+ } from "./chunk-HP6F2HUY.mjs";
10
10
  import {
11
11
  getNativeEvent,
12
12
  isLeftClick,
13
13
  isTouchEvent,
14
14
  roundToDevicePixel
15
- } from "./chunk-DDNK5RLW.mjs";
15
+ } from "./chunk-VCZUWKJT.mjs";
16
16
 
17
17
  // ../../utilities/dom/src/attrs.ts
18
18
  var dataAttr = (guard) => {
@@ -4,7 +4,7 @@ import {
4
4
  roundToDevicePixel,
5
5
  supportsPointerEvent,
6
6
  wrap
7
- } from "./chunk-DDNK5RLW.mjs";
7
+ } from "./chunk-VCZUWKJT.mjs";
8
8
 
9
9
  // ../../utilities/dom/src/constants.ts
10
10
  var MAX_Z_INDEX = 2147483647;
@@ -4,7 +4,7 @@ import {
4
4
  formatDecimal,
5
5
  increment,
6
6
  isModifiedEvent
7
- } from "./chunk-DDNK5RLW.mjs";
7
+ } from "./chunk-VCZUWKJT.mjs";
8
8
 
9
9
  // src/number-input.utils.ts
10
10
  var utils = {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  dom
3
- } from "./chunk-2SIS62IB.mjs";
3
+ } from "./chunk-EUVYGWZ6.mjs";
4
4
  import {
5
5
  utils
6
- } from "./chunk-GWZPUXGU.mjs";
6
+ } from "./chunk-HP6F2HUY.mjs";
7
7
  import {
8
8
  getWindow,
9
9
  hasProp,
@@ -14,7 +14,7 @@ import {
14
14
  isWithinRange,
15
15
  supportsPointerEvent,
16
16
  valueOf
17
- } from "./chunk-DDNK5RLW.mjs";
17
+ } from "./chunk-VCZUWKJT.mjs";
18
18
 
19
19
  // src/number-input.machine.ts
20
20
  import { choose, createMachine, guards } from "@zag-js/core";
@@ -106,7 +106,10 @@ function requestPointerLock(doc, handlers = {}) {
106
106
  }
107
107
  if (!supported)
108
108
  return;
109
- body.requestPointerLock();
109
+ try {
110
+ body.requestPointerLock();
111
+ } catch {
112
+ }
110
113
  const cleanup = callAll(
111
114
  addPointerlockChangeListener(doc, onPointerChange),
112
115
  addPointerlockErrorListener(doc, onPointerError)
@@ -41,25 +41,7 @@ function defineDomHelpers(helpers) {
41
41
  return (_a = dom.getDoc(ctx).defaultView) != null ? _a : window;
42
42
  },
43
43
  getActiveElement: (ctx) => dom.getDoc(ctx).activeElement,
44
- getById: (ctx, id) => dom.getRootNode(ctx).getElementById(id),
45
- createEmitter: (ctx, target) => {
46
- const win = dom.getWin(ctx);
47
- return function emit(evt, detail, options) {
48
- const { bubbles = true, cancelable, composed = true } = options != null ? options : {};
49
- const eventName = `zag:${evt}`;
50
- const init = { bubbles, cancelable, composed, detail };
51
- const event = new win.CustomEvent(eventName, init);
52
- target.dispatchEvent(event);
53
- };
54
- },
55
- createListener: (target) => {
56
- return function listen(evt, handler) {
57
- const eventName = `zag:${evt}`;
58
- const listener = (e) => handler(e);
59
- target.addEventListener(eventName, listener);
60
- return () => target.removeEventListener(eventName, listener);
61
- };
62
- }
44
+ getById: (ctx, id) => dom.getRootNode(ctx).getElementById(id)
63
45
  };
64
46
  return {
65
47
  ...dom,
package/dist/index.js CHANGED
@@ -118,25 +118,7 @@ function defineDomHelpers(helpers) {
118
118
  return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
119
119
  },
120
120
  getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
121
- getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
122
- createEmitter: (ctx, target) => {
123
- const win = dom2.getWin(ctx);
124
- return function emit(evt, detail, options) {
125
- const { bubbles = true, cancelable, composed = true } = options != null ? options : {};
126
- const eventName = `zag:${evt}`;
127
- const init = { bubbles, cancelable, composed, detail };
128
- const event = new win.CustomEvent(eventName, init);
129
- target.dispatchEvent(event);
130
- };
131
- },
132
- createListener: (target) => {
133
- return function listen(evt, handler) {
134
- const eventName = `zag:${evt}`;
135
- const listener = (e) => handler(e);
136
- target.addEventListener(eventName, listener);
137
- return () => target.removeEventListener(eventName, listener);
138
- };
139
- }
121
+ getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
140
122
  };
141
123
  return {
142
124
  ...dom2,
@@ -247,7 +229,10 @@ function requestPointerLock(doc, handlers = {}) {
247
229
  }
248
230
  if (!supported)
249
231
  return;
250
- body.requestPointerLock();
232
+ try {
233
+ body.requestPointerLock();
234
+ } catch {
235
+ }
251
236
  const cleanup = callAll(
252
237
  addPointerlockChangeListener(doc, onPointerChange),
253
238
  addPointerlockErrorListener(doc, onPointerError)
package/dist/index.mjs CHANGED
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  connect
3
- } from "./chunk-TSELS3UE.mjs";
3
+ } from "./chunk-2UDY2X4M.mjs";
4
4
  import {
5
5
  anatomy
6
6
  } from "./chunk-XHRILSH3.mjs";
7
7
  import {
8
8
  machine
9
- } from "./chunk-7E3ZO263.mjs";
10
- import "./chunk-2SIS62IB.mjs";
11
- import "./chunk-GWZPUXGU.mjs";
12
- import "./chunk-DDNK5RLW.mjs";
9
+ } from "./chunk-MIZ4MW4C.mjs";
10
+ import "./chunk-EUVYGWZ6.mjs";
11
+ import "./chunk-HP6F2HUY.mjs";
12
+ import "./chunk-VCZUWKJT.mjs";
13
13
  export {
14
14
  anatomy,
15
15
  connect,
@@ -79,25 +79,7 @@ function defineDomHelpers(helpers) {
79
79
  return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
80
80
  },
81
81
  getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
82
- getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
83
- createEmitter: (ctx, target) => {
84
- const win = dom2.getWin(ctx);
85
- return function emit(evt, detail, options) {
86
- const { bubbles = true, cancelable, composed = true } = options != null ? options : {};
87
- const eventName = `zag:${evt}`;
88
- const init = { bubbles, cancelable, composed, detail };
89
- const event = new win.CustomEvent(eventName, init);
90
- target.dispatchEvent(event);
91
- };
92
- },
93
- createListener: (target) => {
94
- return function listen(evt, handler) {
95
- const eventName = `zag:${evt}`;
96
- const listener = (e) => handler(e);
97
- target.addEventListener(eventName, listener);
98
- return () => target.removeEventListener(eventName, listener);
99
- };
100
- }
82
+ getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
101
83
  };
102
84
  return {
103
85
  ...dom2,
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  connect
3
- } from "./chunk-TSELS3UE.mjs";
3
+ } from "./chunk-2UDY2X4M.mjs";
4
4
  import "./chunk-XHRILSH3.mjs";
5
- import "./chunk-2SIS62IB.mjs";
6
- import "./chunk-GWZPUXGU.mjs";
7
- import "./chunk-DDNK5RLW.mjs";
5
+ import "./chunk-EUVYGWZ6.mjs";
6
+ import "./chunk-HP6F2HUY.mjs";
7
+ import "./chunk-VCZUWKJT.mjs";
8
8
  export {
9
9
  connect
10
10
  };
@@ -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) => string;
@@ -66,25 +66,7 @@ function defineDomHelpers(helpers) {
66
66
  return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
67
67
  },
68
68
  getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
69
- getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
70
- createEmitter: (ctx, target) => {
71
- const win = dom2.getWin(ctx);
72
- return function emit(evt, detail, options) {
73
- const { bubbles = true, cancelable, composed = true } = options != null ? options : {};
74
- const eventName = `zag:${evt}`;
75
- const init = { bubbles, cancelable, composed, detail };
76
- const event = new win.CustomEvent(eventName, init);
77
- target.dispatchEvent(event);
78
- };
79
- },
80
- createListener: (target) => {
81
- return function listen(evt, handler) {
82
- const eventName = `zag:${evt}`;
83
- const listener = (e) => handler(e);
84
- target.addEventListener(eventName, listener);
85
- return () => target.removeEventListener(eventName, listener);
86
- };
87
- }
69
+ getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
88
70
  };
89
71
  return {
90
72
  ...dom2,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  dom
3
- } from "./chunk-2SIS62IB.mjs";
4
- import "./chunk-DDNK5RLW.mjs";
3
+ } from "./chunk-EUVYGWZ6.mjs";
4
+ import "./chunk-VCZUWKJT.mjs";
5
5
  export {
6
6
  dom
7
7
  };
@@ -96,25 +96,7 @@ function defineDomHelpers(helpers) {
96
96
  return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
97
97
  },
98
98
  getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
99
- getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
100
- createEmitter: (ctx, target) => {
101
- const win = dom2.getWin(ctx);
102
- return function emit(evt, detail, options) {
103
- const { bubbles = true, cancelable, composed = true } = options != null ? options : {};
104
- const eventName = `zag:${evt}`;
105
- const init = { bubbles, cancelable, composed, detail };
106
- const event = new win.CustomEvent(eventName, init);
107
- target.dispatchEvent(event);
108
- };
109
- },
110
- createListener: (target) => {
111
- return function listen(evt, handler) {
112
- const eventName = `zag:${evt}`;
113
- const listener = (e) => handler(e);
114
- target.addEventListener(eventName, listener);
115
- return () => target.removeEventListener(eventName, listener);
116
- };
117
- }
99
+ getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
118
100
  };
119
101
  return {
120
102
  ...dom2,
@@ -193,7 +175,10 @@ function requestPointerLock(doc, handlers = {}) {
193
175
  }
194
176
  if (!supported)
195
177
  return;
196
- body.requestPointerLock();
178
+ try {
179
+ body.requestPointerLock();
180
+ } catch {
181
+ }
197
182
  const cleanup = callAll(
198
183
  addPointerlockChangeListener(doc, onPointerChange),
199
184
  addPointerlockErrorListener(doc, onPointerError)
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  machine
3
- } from "./chunk-7E3ZO263.mjs";
4
- import "./chunk-2SIS62IB.mjs";
5
- import "./chunk-GWZPUXGU.mjs";
6
- import "./chunk-DDNK5RLW.mjs";
3
+ } from "./chunk-MIZ4MW4C.mjs";
4
+ import "./chunk-EUVYGWZ6.mjs";
5
+ import "./chunk-HP6F2HUY.mjs";
6
+ import "./chunk-VCZUWKJT.mjs";
7
7
  export {
8
8
  machine
9
9
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  utils
3
- } from "./chunk-GWZPUXGU.mjs";
4
- import "./chunk-DDNK5RLW.mjs";
3
+ } from "./chunk-HP6F2HUY.mjs";
4
+ import "./chunk-VCZUWKJT.mjs";
5
5
  export {
6
6
  utils
7
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/number-input",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "Core logic for the number-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/number-utils": "0.2.2",
38
38
  "@zag-js/utils": "0.3.2"