@zag-js/number-input 0.0.0-dev-20220627213436 → 0.0.0-dev-20220703125047
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 +37 -39
- package/dist/index.mjs +37 -39
- package/dist/number-input.connect.d.ts +2 -2
- package/dist/number-input.utils.d.ts +0 -1
- package/package.json +4 -4
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
|
|
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 :
|
|
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 =
|
|
153
|
+
const cleanup = callAll(addPointerlockChangeListener(doc, onPointerChange), addPointerlockErrorListener(doc, onPointerError));
|
|
150
154
|
return function dispose() {
|
|
151
155
|
if (!supported)
|
|
152
156
|
return;
|
|
@@ -220,16 +224,6 @@ function decimalOperation(a, op, b) {
|
|
|
220
224
|
}
|
|
221
225
|
var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigits: 20 });
|
|
222
226
|
|
|
223
|
-
// ../../types/dist/index.mjs
|
|
224
|
-
function createNormalizer(fn) {
|
|
225
|
-
return new Proxy({}, {
|
|
226
|
-
get() {
|
|
227
|
-
return fn;
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
var normalizeProp = createNormalizer((v) => v);
|
|
232
|
-
|
|
233
227
|
// ../../utilities/core/dist/index.mjs
|
|
234
228
|
var isDom = () => typeof window !== "undefined";
|
|
235
229
|
function getPlatform() {
|
|
@@ -247,7 +241,11 @@ var isIos = () => isApple() && !isMac();
|
|
|
247
241
|
var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
|
|
248
242
|
var isLeftClick = (v) => v.button === 0;
|
|
249
243
|
var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
|
|
250
|
-
var
|
|
244
|
+
var callAll2 = (...fns) => (...a) => {
|
|
245
|
+
fns.forEach(function(fn) {
|
|
246
|
+
fn == null ? void 0 : fn(...a);
|
|
247
|
+
});
|
|
248
|
+
};
|
|
251
249
|
|
|
252
250
|
// src/number-input.dom.ts
|
|
253
251
|
var dom = {
|
|
@@ -381,7 +379,7 @@ var utils = {
|
|
|
381
379
|
};
|
|
382
380
|
|
|
383
381
|
// src/number-input.connect.ts
|
|
384
|
-
function connect(state, send, normalize
|
|
382
|
+
function connect(state, send, normalize) {
|
|
385
383
|
const isFocused = state.hasTag("focus");
|
|
386
384
|
const isInvalid = state.context.isOutOfRange || !!state.context.invalid;
|
|
387
385
|
const isDisabled = !!state.context.disabled;
|
|
@@ -837,7 +835,7 @@ function machine(ctx = {}) {
|
|
|
837
835
|
function onMouseup() {
|
|
838
836
|
send("POINTER_UP_SCRUBBER");
|
|
839
837
|
}
|
|
840
|
-
return
|
|
838
|
+
return callAll2(addDomEvent(doc, "mousemove", onMousemove, false), addDomEvent(doc, "mouseup", onMouseup, false));
|
|
841
839
|
}
|
|
842
840
|
},
|
|
843
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
|
|
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 :
|
|
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 =
|
|
130
|
+
const cleanup = callAll(addPointerlockChangeListener(doc, onPointerChange), addPointerlockErrorListener(doc, onPointerError));
|
|
127
131
|
return function dispose() {
|
|
128
132
|
if (!supported)
|
|
129
133
|
return;
|
|
@@ -197,16 +201,6 @@ function decimalOperation(a, op, b) {
|
|
|
197
201
|
}
|
|
198
202
|
var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigits: 20 });
|
|
199
203
|
|
|
200
|
-
// ../../types/dist/index.mjs
|
|
201
|
-
function createNormalizer(fn) {
|
|
202
|
-
return new Proxy({}, {
|
|
203
|
-
get() {
|
|
204
|
-
return fn;
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
var normalizeProp = createNormalizer((v) => v);
|
|
209
|
-
|
|
210
204
|
// ../../utilities/core/dist/index.mjs
|
|
211
205
|
var isDom = () => typeof window !== "undefined";
|
|
212
206
|
function getPlatform() {
|
|
@@ -224,7 +218,11 @@ var isIos = () => isApple() && !isMac();
|
|
|
224
218
|
var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
|
|
225
219
|
var isLeftClick = (v) => v.button === 0;
|
|
226
220
|
var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
|
|
227
|
-
var
|
|
221
|
+
var callAll2 = (...fns) => (...a) => {
|
|
222
|
+
fns.forEach(function(fn) {
|
|
223
|
+
fn == null ? void 0 : fn(...a);
|
|
224
|
+
});
|
|
225
|
+
};
|
|
228
226
|
|
|
229
227
|
// src/number-input.dom.ts
|
|
230
228
|
var dom = {
|
|
@@ -358,7 +356,7 @@ var utils = {
|
|
|
358
356
|
};
|
|
359
357
|
|
|
360
358
|
// src/number-input.connect.ts
|
|
361
|
-
function connect(state, send, normalize
|
|
359
|
+
function connect(state, send, normalize) {
|
|
362
360
|
const isFocused = state.hasTag("focus");
|
|
363
361
|
const isInvalid = state.context.isOutOfRange || !!state.context.invalid;
|
|
364
362
|
const isDisabled = !!state.context.disabled;
|
|
@@ -814,7 +812,7 @@ function machine(ctx = {}) {
|
|
|
814
812
|
function onMouseup() {
|
|
815
813
|
send("POINTER_UP_SCRUBBER");
|
|
816
814
|
}
|
|
817
|
-
return
|
|
815
|
+
return callAll2(addDomEvent(doc, "mousemove", onMousemove, false), addDomEvent(doc, "mouseup", onMouseup, false));
|
|
818
816
|
}
|
|
819
817
|
},
|
|
820
818
|
actions: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
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
|
|
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/number-input",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20220703125047",
|
|
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-
|
|
33
|
-
"@zag-js/dom-utils": "0.0.0-dev-
|
|
32
|
+
"@zag-js/core": "0.0.0-dev-20220703125047",
|
|
33
|
+
"@zag-js/dom-utils": "0.0.0-dev-20220703125047",
|
|
34
34
|
"@zag-js/number-utils": "0.1.2",
|
|
35
|
-
"@zag-js/types": "0.
|
|
35
|
+
"@zag-js/types": "0.0.0-dev-20220703125047",
|
|
36
36
|
"@zag-js/utils": "0.1.2"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|