@zag-js/number-input 0.0.0-dev-20220626181040 → 0.0.0-dev-20220627213436

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,13 +49,14 @@ 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));
52
54
  var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
55
+ var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
53
56
  var runIfFn = (v, ...a) => {
54
57
  const res = typeof v === "function" ? v(...a) : v;
55
58
  return res != null ? res : void 0;
56
59
  };
57
- var noop = () => {
58
- };
59
60
  var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
60
61
  var isRef = (v) => hasProp(v, "current");
61
62
  function addDomEvent(target, eventName, handler, options) {
@@ -78,7 +79,7 @@ function getNativeEvent(e) {
78
79
  }
79
80
  function observeAttributes(node, attributes, fn) {
80
81
  if (!node)
81
- return noop;
82
+ return;
82
83
  const attrs = Array.isArray(attributes) ? attributes : [attributes];
83
84
  const win = node.ownerDocument.defaultView || window;
84
85
  const obs = new win.MutationObserver((changes) => {
@@ -91,6 +92,17 @@ function observeAttributes(node, attributes, fn) {
91
92
  obs.observe(node, { attributes: true, attributeFilter: attrs });
92
93
  return () => obs.disconnect();
93
94
  }
95
+ var fallback2 = {
96
+ pageX: 0,
97
+ pageY: 0,
98
+ clientX: 0,
99
+ clientY: 0
100
+ };
101
+ function getEventPoint(event, type = "page") {
102
+ var _a, _b;
103
+ const point = isTouchEvent(event) ? (_b = (_a = event.touches[0]) != null ? _a : event.changedTouches[0]) != null ? _b : fallback2 : event;
104
+ return { x: point[`${type}X`], y: point[`${type}Y`] };
105
+ }
94
106
  var PAGE_KEYS = /* @__PURE__ */ new Set(["PageUp", "PageDown"]);
95
107
  var ARROW_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
96
108
  function getEventStep(event) {
@@ -208,17 +220,6 @@ function decimalOperation(a, op, b) {
208
220
  }
209
221
  var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigits: 20 });
210
222
 
211
- // ../../utilities/rect/dist/index.mjs
212
- var isArray = (v) => Array.isArray(v);
213
- var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
214
- var hasProp2 = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
215
- var isTouchEvent = (v) => isObject(v) && hasProp2(v, "touches");
216
- var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
217
- function getEventPoint(e, t = "page") {
218
- const p = isTouchEvent(e) ? e.touches[0] || e.changedTouches[0] || fallback : e;
219
- return { x: p[`${t}X`], y: p[`${t}Y`] };
220
- }
221
-
222
223
  // ../../types/dist/index.mjs
223
224
  function createNormalizer(fn) {
224
225
  return new Proxy({}, {
@@ -870,7 +871,7 @@ function machine(ctx = {}) {
870
871
  setValue(ctx2, evt) {
871
872
  var _a, _b;
872
873
  const value = (_b = (_a = evt.target) == null ? void 0 : _a.value) != null ? _b : evt.value;
873
- ctx2.value = utils.sanitize(ctx2, utils.parse(ctx2, value));
874
+ ctx2.value = utils.sanitize(ctx2, utils.parse(ctx2, value.toString()));
874
875
  },
875
876
  clearValue(ctx2) {
876
877
  ctx2.value = "";
package/dist/index.mjs CHANGED
@@ -26,13 +26,14 @@ 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));
29
31
  var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
32
+ var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
30
33
  var runIfFn = (v, ...a) => {
31
34
  const res = typeof v === "function" ? v(...a) : v;
32
35
  return res != null ? res : void 0;
33
36
  };
34
- var noop = () => {
35
- };
36
37
  var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
37
38
  var isRef = (v) => hasProp(v, "current");
38
39
  function addDomEvent(target, eventName, handler, options) {
@@ -55,7 +56,7 @@ function getNativeEvent(e) {
55
56
  }
56
57
  function observeAttributes(node, attributes, fn) {
57
58
  if (!node)
58
- return noop;
59
+ return;
59
60
  const attrs = Array.isArray(attributes) ? attributes : [attributes];
60
61
  const win = node.ownerDocument.defaultView || window;
61
62
  const obs = new win.MutationObserver((changes) => {
@@ -68,6 +69,17 @@ function observeAttributes(node, attributes, fn) {
68
69
  obs.observe(node, { attributes: true, attributeFilter: attrs });
69
70
  return () => obs.disconnect();
70
71
  }
72
+ var fallback2 = {
73
+ pageX: 0,
74
+ pageY: 0,
75
+ clientX: 0,
76
+ clientY: 0
77
+ };
78
+ function getEventPoint(event, type = "page") {
79
+ var _a, _b;
80
+ const point = isTouchEvent(event) ? (_b = (_a = event.touches[0]) != null ? _a : event.changedTouches[0]) != null ? _b : fallback2 : event;
81
+ return { x: point[`${type}X`], y: point[`${type}Y`] };
82
+ }
71
83
  var PAGE_KEYS = /* @__PURE__ */ new Set(["PageUp", "PageDown"]);
72
84
  var ARROW_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
73
85
  function getEventStep(event) {
@@ -185,17 +197,6 @@ function decimalOperation(a, op, b) {
185
197
  }
186
198
  var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigits: 20 });
187
199
 
188
- // ../../utilities/rect/dist/index.mjs
189
- var isArray = (v) => Array.isArray(v);
190
- var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
191
- var hasProp2 = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
192
- var isTouchEvent = (v) => isObject(v) && hasProp2(v, "touches");
193
- var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
194
- function getEventPoint(e, t = "page") {
195
- const p = isTouchEvent(e) ? e.touches[0] || e.changedTouches[0] || fallback : e;
196
- return { x: p[`${t}X`], y: p[`${t}Y`] };
197
- }
198
-
199
200
  // ../../types/dist/index.mjs
200
201
  function createNormalizer(fn) {
201
202
  return new Proxy({}, {
@@ -847,7 +848,7 @@ function machine(ctx = {}) {
847
848
  setValue(ctx2, evt) {
848
849
  var _a, _b;
849
850
  const value = (_b = (_a = evt.target) == null ? void 0 : _a.value) != null ? _b : evt.value;
850
- ctx2.value = utils.sanitize(ctx2, utils.parse(ctx2, value));
851
+ ctx2.value = utils.sanitize(ctx2, utils.parse(ctx2, value.toString()));
851
852
  },
852
853
  clearValue(ctx2) {
853
854
  ctx2.value = "";
@@ -1,6 +1,5 @@
1
1
  import type { StateMachine as S } from "@zag-js/core";
2
2
  import { FormatDecimalOptions } from "@zag-js/number-utils";
3
- import type { Point } from "@zag-js/rect-utils";
4
3
  import type { Context, DirectionProperty } from "@zag-js/types";
5
4
  declare type ValidityState = "rangeUnderflow" | "rangeOverflow";
6
5
  declare type ElementIds = Partial<{
@@ -186,7 +185,10 @@ declare type PrivateContext = Context<{
186
185
  * @internal
187
186
  * The scrubber cursor position
188
187
  */
189
- scrubberCursorPoint: Point | null;
188
+ scrubberCursorPoint: {
189
+ x: number;
190
+ y: number;
191
+ } | null;
190
192
  }>;
191
193
  export declare type MachineContext = PublicContext & PrivateContext & ComputedContext;
192
194
  export declare type MachineState = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/number-input",
3
- "version": "0.0.0-dev-20220626181040",
3
+ "version": "0.0.0-dev-20220627213436",
4
4
  "description": "Core logic for the number-input widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -29,10 +29,9 @@
29
29
  "url": "https://github.com/chakra-ui/zag/issues"
30
30
  },
31
31
  "dependencies": {
32
- "@zag-js/core": "0.0.0-dev-20220626181040",
33
- "@zag-js/dom-utils": "0.0.0-dev-20220626181040",
32
+ "@zag-js/core": "0.0.0-dev-20220627213436",
33
+ "@zag-js/dom-utils": "0.0.0-dev-20220627213436",
34
34
  "@zag-js/number-utils": "0.1.2",
35
- "@zag-js/rect-utils": "0.1.2",
36
35
  "@zag-js/types": "0.2.0",
37
36
  "@zag-js/utils": "0.1.2"
38
37
  },