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

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,27 +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
- // ../../types/dist/index.mjs
223
- function createNormalizer(fn) {
224
- return new Proxy({}, {
225
- get() {
226
- return fn;
227
- }
228
- });
229
- }
230
- var normalizeProp = createNormalizer((v) => v);
231
-
232
223
  // ../../utilities/core/dist/index.mjs
233
224
  var isDom = () => typeof window !== "undefined";
234
225
  function getPlatform() {
@@ -380,7 +371,7 @@ var utils = {
380
371
  };
381
372
 
382
373
  // src/number-input.connect.ts
383
- function connect(state, send, normalize = normalizeProp) {
374
+ function connect(state, send, normalize) {
384
375
  const isFocused = state.hasTag("focus");
385
376
  const isInvalid = state.context.isOutOfRange || !!state.context.invalid;
386
377
  const isDisabled = !!state.context.disabled;
@@ -870,7 +861,7 @@ function machine(ctx = {}) {
870
861
  setValue(ctx2, evt) {
871
862
  var _a, _b;
872
863
  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));
864
+ ctx2.value = utils.sanitize(ctx2, utils.parse(ctx2, value.toString()));
874
865
  },
875
866
  clearValue(ctx2) {
876
867
  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,27 +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
- // ../../types/dist/index.mjs
200
- function createNormalizer(fn) {
201
- return new Proxy({}, {
202
- get() {
203
- return fn;
204
- }
205
- });
206
- }
207
- var normalizeProp = createNormalizer((v) => v);
208
-
209
200
  // ../../utilities/core/dist/index.mjs
210
201
  var isDom = () => typeof window !== "undefined";
211
202
  function getPlatform() {
@@ -357,7 +348,7 @@ var utils = {
357
348
  };
358
349
 
359
350
  // src/number-input.connect.ts
360
- function connect(state, send, normalize = normalizeProp) {
351
+ function connect(state, send, normalize) {
361
352
  const isFocused = state.hasTag("focus");
362
353
  const isInvalid = state.context.isOutOfRange || !!state.context.invalid;
363
354
  const isDisabled = !!state.context.disabled;
@@ -847,7 +838,7 @@ function machine(ctx = {}) {
847
838
  setValue(ctx2, evt) {
848
839
  var _a, _b;
849
840
  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));
841
+ ctx2.value = utils.sanitize(ctx2, utils.parse(ctx2, value.toString()));
851
842
  },
852
843
  clearValue(ctx2) {
853
844
  ctx2.value = "";
@@ -1,6 +1,6 @@
1
- import { PropTypes, ReactPropTypes } from "@zag-js/types";
1
+ import type { NormalizeProps, PropTypes } from "@zag-js/types";
2
2
  import { Send, State } from "./number-input.types";
3
- export declare function connect<T extends PropTypes = ReactPropTypes>(state: State, send: Send, normalize?: import("@zag-js/types").NormalizeProps): {
3
+ export declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
4
4
  isFocused: boolean;
5
5
  isInvalid: boolean;
6
6
  value: string;
@@ -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-20220627111117",
3
+ "version": "0.0.0-dev-20220628115342",
4
4
  "description": "Core logic for the number-input widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -29,11 +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-20220627111117",
33
- "@zag-js/dom-utils": "0.0.0-dev-20220627111117",
32
+ "@zag-js/core": "0.0.0-dev-20220628115342",
33
+ "@zag-js/dom-utils": "0.0.0-dev-20220628115342",
34
34
  "@zag-js/number-utils": "0.1.2",
35
- "@zag-js/rect-utils": "0.1.2",
36
- "@zag-js/types": "0.2.0",
35
+ "@zag-js/types": "0.0.0-dev-20220628115342",
37
36
  "@zag-js/utils": "0.1.2"
38
37
  },
39
38
  "scripts": {