@zag-js/number-input 0.0.0-dev-20220628115342 → 0.0.0-dev-20220703193942

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.js CHANGED
@@ -49,29 +49,6 @@ var dataAttr = (guard) => {
49
49
  var ariaAttr = (guard) => {
50
50
  return guard ? "true" : void 0;
51
51
  };
52
- var isArray = (v) => Array.isArray(v);
53
- var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
54
- var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
55
- var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
56
- var runIfFn = (v, ...a) => {
57
- const res = typeof v === "function" ? v(...a) : v;
58
- return res != null ? res : void 0;
59
- };
60
- var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
61
- var isRef = (v) => hasProp(v, "current");
62
- function addDomEvent(target, eventName, handler, options) {
63
- const node = isRef(target) ? target.current : runIfFn(target);
64
- node == null ? void 0 : node.addEventListener(eventName, handler, options);
65
- return () => {
66
- node == null ? void 0 : node.removeEventListener(eventName, handler, options);
67
- };
68
- }
69
- function raf(fn) {
70
- const id = globalThis.requestAnimationFrame(fn);
71
- return function cleanup() {
72
- globalThis.cancelAnimationFrame(id);
73
- };
74
- }
75
52
  var MAX_Z_INDEX = 2147483647;
76
53
  function getNativeEvent(e) {
77
54
  var _a;
@@ -92,7 +69,20 @@ function observeAttributes(node, attributes, fn) {
92
69
  obs.observe(node, { attributes: true, attributeFilter: attrs });
93
70
  return () => obs.disconnect();
94
71
  }
95
- var fallback2 = {
72
+ var isArray = (v) => Array.isArray(v);
73
+ var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
74
+ var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
75
+ var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
76
+ var runIfFn = (v, ...a) => {
77
+ const res = typeof v === "function" ? v(...a) : v;
78
+ return res != null ? res : void 0;
79
+ };
80
+ var callAll = (...fns) => (...a) => {
81
+ fns.forEach(function(fn) {
82
+ fn == null ? void 0 : fn(...a);
83
+ });
84
+ };
85
+ var fallback = {
96
86
  pageX: 0,
97
87
  pageY: 0,
98
88
  clientX: 0,
@@ -100,7 +90,7 @@ var fallback2 = {
100
90
  };
101
91
  function getEventPoint(event, type = "page") {
102
92
  var _a, _b;
103
- const point = isTouchEvent(event) ? (_b = (_a = event.touches[0]) != null ? _a : event.changedTouches[0]) != null ? _b : fallback2 : event;
93
+ const point = isTouchEvent(event) ? (_b = (_a = event.touches[0]) != null ? _a : event.changedTouches[0]) != null ? _b : fallback : event;
104
94
  return { x: point[`${type}X`], y: point[`${type}Y`] };
105
95
  }
106
96
  var PAGE_KEYS = /* @__PURE__ */ new Set(["PageUp", "PageDown"]);
@@ -114,6 +104,20 @@ function getEventStep(event) {
114
104
  return isSkipKey ? 10 : 1;
115
105
  }
116
106
  }
107
+ var isRef = (v) => hasProp(v, "current");
108
+ function addDomEvent(target, eventName, handler, options) {
109
+ const node = isRef(target) ? target.current : runIfFn(target);
110
+ node == null ? void 0 : node.addEventListener(eventName, handler, options);
111
+ return () => {
112
+ node == null ? void 0 : node.removeEventListener(eventName, handler, options);
113
+ };
114
+ }
115
+ function raf(fn) {
116
+ const id = globalThis.requestAnimationFrame(fn);
117
+ return function cleanup() {
118
+ globalThis.cancelAnimationFrame(id);
119
+ };
120
+ }
117
121
  function addPointerlockChangeListener(doc, fn) {
118
122
  return addDomEvent(doc, "pointerlockchange", fn, false);
119
123
  }
@@ -146,7 +150,7 @@ function requestPointerLock(doc, handlers = {}) {
146
150
  if (!supported)
147
151
  return;
148
152
  body.requestPointerLock();
149
- const cleanup = pipe(addPointerlockChangeListener(doc, onPointerChange), addPointerlockErrorListener(doc, onPointerError));
153
+ const cleanup = callAll(addPointerlockChangeListener(doc, onPointerChange), addPointerlockErrorListener(doc, onPointerError));
150
154
  return function dispose() {
151
155
  if (!supported)
152
156
  return;
@@ -237,7 +241,11 @@ var isIos = () => isApple() && !isMac();
237
241
  var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
238
242
  var isLeftClick = (v) => v.button === 0;
239
243
  var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
240
- var pipe2 = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
244
+ var callAll2 = (...fns) => (...a) => {
245
+ fns.forEach(function(fn) {
246
+ fn == null ? void 0 : fn(...a);
247
+ });
248
+ };
241
249
 
242
250
  // src/number-input.dom.ts
243
251
  var dom = {
@@ -827,7 +835,7 @@ function machine(ctx = {}) {
827
835
  function onMouseup() {
828
836
  send("POINTER_UP_SCRUBBER");
829
837
  }
830
- return pipe2(addDomEvent(doc, "mousemove", onMousemove, false), addDomEvent(doc, "mouseup", onMouseup, false));
838
+ return callAll2(addDomEvent(doc, "mousemove", onMousemove, false), addDomEvent(doc, "mouseup", onMouseup, false));
831
839
  }
832
840
  },
833
841
  actions: {
package/dist/index.mjs CHANGED
@@ -26,29 +26,6 @@ var dataAttr = (guard) => {
26
26
  var ariaAttr = (guard) => {
27
27
  return guard ? "true" : void 0;
28
28
  };
29
- var isArray = (v) => Array.isArray(v);
30
- var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
31
- var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
32
- var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
33
- var runIfFn = (v, ...a) => {
34
- const res = typeof v === "function" ? v(...a) : v;
35
- return res != null ? res : void 0;
36
- };
37
- var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
38
- var isRef = (v) => hasProp(v, "current");
39
- function addDomEvent(target, eventName, handler, options) {
40
- const node = isRef(target) ? target.current : runIfFn(target);
41
- node == null ? void 0 : node.addEventListener(eventName, handler, options);
42
- return () => {
43
- node == null ? void 0 : node.removeEventListener(eventName, handler, options);
44
- };
45
- }
46
- function raf(fn) {
47
- const id = globalThis.requestAnimationFrame(fn);
48
- return function cleanup() {
49
- globalThis.cancelAnimationFrame(id);
50
- };
51
- }
52
29
  var MAX_Z_INDEX = 2147483647;
53
30
  function getNativeEvent(e) {
54
31
  var _a;
@@ -69,7 +46,20 @@ function observeAttributes(node, attributes, fn) {
69
46
  obs.observe(node, { attributes: true, attributeFilter: attrs });
70
47
  return () => obs.disconnect();
71
48
  }
72
- var fallback2 = {
49
+ var isArray = (v) => Array.isArray(v);
50
+ var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
51
+ var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
52
+ var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
53
+ var runIfFn = (v, ...a) => {
54
+ const res = typeof v === "function" ? v(...a) : v;
55
+ return res != null ? res : void 0;
56
+ };
57
+ var callAll = (...fns) => (...a) => {
58
+ fns.forEach(function(fn) {
59
+ fn == null ? void 0 : fn(...a);
60
+ });
61
+ };
62
+ var fallback = {
73
63
  pageX: 0,
74
64
  pageY: 0,
75
65
  clientX: 0,
@@ -77,7 +67,7 @@ var fallback2 = {
77
67
  };
78
68
  function getEventPoint(event, type = "page") {
79
69
  var _a, _b;
80
- const point = isTouchEvent(event) ? (_b = (_a = event.touches[0]) != null ? _a : event.changedTouches[0]) != null ? _b : fallback2 : event;
70
+ const point = isTouchEvent(event) ? (_b = (_a = event.touches[0]) != null ? _a : event.changedTouches[0]) != null ? _b : fallback : event;
81
71
  return { x: point[`${type}X`], y: point[`${type}Y`] };
82
72
  }
83
73
  var PAGE_KEYS = /* @__PURE__ */ new Set(["PageUp", "PageDown"]);
@@ -91,6 +81,20 @@ function getEventStep(event) {
91
81
  return isSkipKey ? 10 : 1;
92
82
  }
93
83
  }
84
+ var isRef = (v) => hasProp(v, "current");
85
+ function addDomEvent(target, eventName, handler, options) {
86
+ const node = isRef(target) ? target.current : runIfFn(target);
87
+ node == null ? void 0 : node.addEventListener(eventName, handler, options);
88
+ return () => {
89
+ node == null ? void 0 : node.removeEventListener(eventName, handler, options);
90
+ };
91
+ }
92
+ function raf(fn) {
93
+ const id = globalThis.requestAnimationFrame(fn);
94
+ return function cleanup() {
95
+ globalThis.cancelAnimationFrame(id);
96
+ };
97
+ }
94
98
  function addPointerlockChangeListener(doc, fn) {
95
99
  return addDomEvent(doc, "pointerlockchange", fn, false);
96
100
  }
@@ -123,7 +127,7 @@ function requestPointerLock(doc, handlers = {}) {
123
127
  if (!supported)
124
128
  return;
125
129
  body.requestPointerLock();
126
- const cleanup = pipe(addPointerlockChangeListener(doc, onPointerChange), addPointerlockErrorListener(doc, onPointerError));
130
+ const cleanup = callAll(addPointerlockChangeListener(doc, onPointerChange), addPointerlockErrorListener(doc, onPointerError));
127
131
  return function dispose() {
128
132
  if (!supported)
129
133
  return;
@@ -214,7 +218,11 @@ var isIos = () => isApple() && !isMac();
214
218
  var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
215
219
  var isLeftClick = (v) => v.button === 0;
216
220
  var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
217
- var pipe2 = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
221
+ var callAll2 = (...fns) => (...a) => {
222
+ fns.forEach(function(fn) {
223
+ fn == null ? void 0 : fn(...a);
224
+ });
225
+ };
218
226
 
219
227
  // src/number-input.dom.ts
220
228
  var dom = {
@@ -804,7 +812,7 @@ function machine(ctx = {}) {
804
812
  function onMouseup() {
805
813
  send("POINTER_UP_SCRUBBER");
806
814
  }
807
- return pipe2(addDomEvent(doc, "mousemove", onMousemove, false), addDomEvent(doc, "mouseup", onMouseup, false));
815
+ return callAll2(addDomEvent(doc, "mousemove", onMousemove, false), addDomEvent(doc, "mouseup", onMouseup, false));
808
816
  }
809
817
  },
810
818
  actions: {
@@ -1,4 +1,3 @@
1
- import type { KeyboardEvent } from "react";
2
1
  import type { MachineContext as Ctx } from "./number-input.types";
3
2
  export declare const utils: {
4
3
  isValidNumericEvent: (ctx: Ctx, event: KeyboardEvent) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/number-input",
3
- "version": "0.0.0-dev-20220628115342",
3
+ "version": "0.0.0-dev-20220703193942",
4
4
  "description": "Core logic for the number-input widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -29,10 +29,10 @@
29
29
  "url": "https://github.com/chakra-ui/zag/issues"
30
30
  },
31
31
  "dependencies": {
32
- "@zag-js/core": "0.0.0-dev-20220628115342",
33
- "@zag-js/dom-utils": "0.0.0-dev-20220628115342",
32
+ "@zag-js/core": "0.0.0-dev-20220703193942",
33
+ "@zag-js/dom-utils": "0.0.0-dev-20220703193942",
34
34
  "@zag-js/number-utils": "0.1.2",
35
- "@zag-js/types": "0.0.0-dev-20220628115342",
35
+ "@zag-js/types": "0.0.0-dev-20220703193942",
36
36
  "@zag-js/utils": "0.1.2"
37
37
  },
38
38
  "scripts": {