@zag-js/number-input 0.1.9 → 0.1.12

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.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export { connect } from "./number-input.connect";
2
2
  export { machine } from "./number-input.machine";
3
3
  export type { UserDefinedContext as Context } from "./number-input.types";
4
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __defProps = Object.defineProperties;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -42,103 +43,95 @@ __export(src_exports, {
42
43
  module.exports = __toCommonJS(src_exports);
43
44
 
44
45
  // ../../utilities/dom/dist/index.mjs
46
+ var __defProp2 = Object.defineProperty;
47
+ var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
48
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
49
+ var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
50
+ var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
51
+ var __spreadValues2 = (a, b) => {
52
+ for (var prop in b || (b = {}))
53
+ if (__hasOwnProp2.call(b, prop))
54
+ __defNormalProp2(a, prop, b[prop]);
55
+ if (__getOwnPropSymbols2)
56
+ for (var prop of __getOwnPropSymbols2(b)) {
57
+ if (__propIsEnum2.call(b, prop))
58
+ __defNormalProp2(a, prop, b[prop]);
59
+ }
60
+ return a;
61
+ };
45
62
  var dataAttr = (guard) => {
46
63
  return guard ? "" : void 0;
47
64
  };
48
65
  var ariaAttr = (guard) => {
49
66
  return guard ? "true" : void 0;
50
67
  };
51
- function raf(fn) {
52
- const id = globalThis.requestAnimationFrame(fn);
53
- return function cleanup() {
54
- globalThis.cancelAnimationFrame(id);
55
- };
56
- }
57
- var isDom = () => typeof window !== "undefined";
58
- var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
59
- var isTouchDevice = isDom() && !!navigator.maxTouchPoints;
68
+ var MAX_Z_INDEX = 2147483647;
60
69
  var runIfFn = (v, ...a) => {
61
70
  const res = typeof v === "function" ? v(...a) : v;
62
71
  return res != null ? res : void 0;
63
72
  };
64
- var noop = () => {
73
+ var callAll = (...fns) => (...a) => {
74
+ fns.forEach(function(fn) {
75
+ fn == null ? void 0 : fn(...a);
76
+ });
65
77
  };
66
- var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
67
- function getListenerElements() {
68
- ;
69
- globalThis.__listenerElements__ = globalThis.__listenerElements__ || /* @__PURE__ */ new Map();
70
- return globalThis.__listenerElements__;
78
+ var isArray = (v) => Array.isArray(v);
79
+ var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
80
+ var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
81
+ var isDom = () => typeof window !== "undefined";
82
+ function getPlatform() {
83
+ var _a;
84
+ const agent = navigator.userAgentData;
85
+ return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
86
+ }
87
+ var pt = (v) => isDom() && v.test(getPlatform());
88
+ var vn = (v) => isDom() && v.test(navigator.vendor);
89
+ var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
90
+ var isMac = () => pt(/^Mac/) && !isTouchDevice;
91
+ var isSafari = () => isApple() && vn(/apple/i);
92
+ var isApple = () => pt(/mac|iphone|ipad|ipod/i);
93
+ var isIos = () => isApple() && !isMac();
94
+ function isDocument(el) {
95
+ return el.nodeType === Node.DOCUMENT_NODE;
71
96
  }
72
- function getListenerCache() {
73
- ;
74
- globalThis.__listenerCache__ = globalThis.__listenerCache__ || /* @__PURE__ */ new Map();
75
- return globalThis.__listenerCache__;
97
+ function isWindow(value) {
98
+ return (value == null ? void 0 : value.toString()) === "[object Window]";
76
99
  }
77
- function addGlobalEventListener(node, type, handler, options) {
100
+ function getDocument(el) {
78
101
  var _a;
79
- if (!node)
80
- return noop;
81
- const hash = JSON.stringify({ type, options });
82
- const listenerElements = getListenerElements();
83
- const listenerCache = getListenerCache();
84
- const group = listenerElements.get(node);
85
- if (!listenerElements.has(node)) {
86
- const group2 = /* @__PURE__ */ new Map([[hash, /* @__PURE__ */ new Set([handler])]]);
87
- listenerElements.set(node, group2);
88
- } else if (group == null ? void 0 : group.has(hash)) {
89
- (_a = group == null ? void 0 : group.get(hash)) == null ? void 0 : _a.add(handler);
90
- } else {
91
- group == null ? void 0 : group.set(hash, /* @__PURE__ */ new Set([handler]));
92
- }
93
- function attach(node2) {
94
- var _a2, _b;
95
- function listener(event) {
96
- var _a3;
97
- const group2 = listenerElements.get(node2);
98
- (_a3 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a3.forEach((fn) => fn(event));
99
- }
100
- if (!(listenerCache == null ? void 0 : listenerCache.has(node2))) {
101
- listenerCache.set(node2, /* @__PURE__ */ new Map([[hash, listener]]));
102
- node2.addEventListener(type, listener, options);
103
- return;
104
- }
105
- if (!((_a2 = listenerCache == null ? void 0 : listenerCache.get(node2)) == null ? void 0 : _a2.has(hash))) {
106
- (_b = listenerCache.get(node2)) == null ? void 0 : _b.set(hash, listener);
107
- node2.addEventListener(type, listener, options);
108
- }
109
- }
110
- attach(node);
111
- return function remove() {
112
- var _a2, _b, _c, _d;
113
- if (!listenerElements.has(node))
114
- return;
115
- const group2 = listenerElements.get(node);
116
- (_a2 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a2.delete(handler);
117
- if (((_b = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _b.size) === 0) {
118
- const listener = (_c = listenerCache.get(node)) == null ? void 0 : _c.get(hash);
119
- node.removeEventListener(type, listener, options);
120
- group2 == null ? void 0 : group2.delete(hash);
121
- (_d = listenerCache.get(node)) == null ? void 0 : _d.delete(hash);
122
- if ((group2 == null ? void 0 : group2.size) === 0) {
123
- listenerElements.delete(node);
124
- listenerCache.delete(node);
125
- }
126
- }
127
- };
102
+ if (isWindow(el))
103
+ return el.document;
104
+ if (isDocument(el))
105
+ return el;
106
+ return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
128
107
  }
129
- var isRef = (v) => hasProp(v, "current");
130
- function addDomEvent(target, event, listener, options) {
131
- const node = isRef(target) ? target.current : runIfFn(target);
132
- return addGlobalEventListener(node, event, listener, options);
108
+ function defineDomHelpers(helpers) {
109
+ const dom2 = {
110
+ getRootNode: (ctx) => {
111
+ var _a, _b;
112
+ return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
113
+ },
114
+ getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
115
+ getWin: (ctx) => {
116
+ var _a;
117
+ return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
118
+ },
119
+ getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
120
+ getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
121
+ };
122
+ return __spreadValues2(__spreadValues2({}, dom2), helpers);
133
123
  }
134
- var MAX_Z_INDEX = 2147483647;
135
124
  function getNativeEvent(e) {
136
125
  var _a;
137
126
  return (_a = e.nativeEvent) != null ? _a : e;
138
127
  }
128
+ var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
129
+ var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
130
+ var isLeftClick = (v) => v.button === 0;
131
+ var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
139
132
  function observeAttributes(node, attributes, fn) {
140
133
  if (!node)
141
- return noop;
134
+ return;
142
135
  const attrs = Array.isArray(attributes) ? attributes : [attributes];
143
136
  const win = node.ownerDocument.defaultView || window;
144
137
  const obs = new win.MutationObserver((changes) => {
@@ -151,6 +144,17 @@ function observeAttributes(node, attributes, fn) {
151
144
  obs.observe(node, { attributes: true, attributeFilter: attrs });
152
145
  return () => obs.disconnect();
153
146
  }
147
+ var fallback = {
148
+ pageX: 0,
149
+ pageY: 0,
150
+ clientX: 0,
151
+ clientY: 0
152
+ };
153
+ function getEventPoint(event, type = "page") {
154
+ var _a, _b;
155
+ const point = isTouchEvent(event) ? (_b = (_a = event.touches[0]) != null ? _a : event.changedTouches[0]) != null ? _b : fallback : event;
156
+ return { x: point[`${type}X`], y: point[`${type}Y`] };
157
+ }
154
158
  var PAGE_KEYS = /* @__PURE__ */ new Set(["PageUp", "PageDown"]);
155
159
  var ARROW_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
156
160
  function getEventStep(event) {
@@ -162,29 +166,19 @@ function getEventStep(event) {
162
166
  return isSkipKey ? 10 : 1;
163
167
  }
164
168
  }
165
- function itemById(v, id) {
166
- return v.find((node) => node.id === id);
167
- }
168
- function indexOfId(v, id) {
169
- const item = itemById(v, id);
170
- return item ? v.indexOf(item) : -1;
169
+ var isRef = (v) => hasProp(v, "current");
170
+ function addDomEvent(target, eventName, handler, options) {
171
+ const node = isRef(target) ? target.current : runIfFn(target);
172
+ node == null ? void 0 : node.addEventListener(eventName, handler, options);
173
+ return () => {
174
+ node == null ? void 0 : node.removeEventListener(eventName, handler, options);
175
+ };
171
176
  }
172
- var getValueText = (item) => {
173
- var _a, _b;
174
- return (_b = (_a = item.dataset.valuetext) != null ? _a : item.textContent) != null ? _b : "";
175
- };
176
- var match = (valueText, query2) => valueText.toLowerCase().startsWith(query2.toLowerCase());
177
- var wrap = (v, idx) => {
178
- return v.map((_, index) => v[(Math.max(idx, 0) + index) % v.length]);
179
- };
180
- function findByText(v, text, currentId) {
181
- const index = currentId ? indexOfId(v, currentId) : -1;
182
- let items = currentId ? wrap(v, index) : v;
183
- const isSingleKey = text.length === 1;
184
- if (isSingleKey) {
185
- items = items.filter((item) => item.id !== currentId);
186
- }
187
- return items.find((item) => match(getValueText(item), text));
177
+ function raf(fn) {
178
+ const id = globalThis.requestAnimationFrame(fn);
179
+ return function cleanup() {
180
+ globalThis.cancelAnimationFrame(id);
181
+ };
188
182
  }
189
183
  function addPointerlockChangeListener(doc, fn) {
190
184
  return addDomEvent(doc, "pointerlockchange", fn, false);
@@ -218,7 +212,7 @@ function requestPointerLock(doc, handlers = {}) {
218
212
  if (!supported)
219
213
  return;
220
214
  body.requestPointerLock();
221
- const cleanup = pipe(addPointerlockChangeListener(doc, onPointerChange), addPointerlockErrorListener(doc, onPointerError));
215
+ const cleanup = callAll(addPointerlockChangeListener(doc, onPointerChange), addPointerlockErrorListener(doc, onPointerError));
222
216
  return function dispose() {
223
217
  if (!supported)
224
218
  return;
@@ -226,38 +220,10 @@ function requestPointerLock(doc, handlers = {}) {
226
220
  exit();
227
221
  };
228
222
  }
229
- function findByTypeahead(_items, options) {
230
- const { state: state2, activeId, key, timeout = 350 } = options;
231
- const search = state2.keysSoFar + key;
232
- const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
233
- const query2 = isRepeated ? search[0] : search;
234
- let items = _items.slice();
235
- const next = findByText(items, query2, activeId);
236
- function cleanup() {
237
- clearTimeout(state2.timer);
238
- state2.timer = -1;
239
- }
240
- function update(value) {
241
- state2.keysSoFar = value;
242
- cleanup();
243
- if (value !== "") {
244
- state2.timer = +setTimeout(() => {
245
- update("");
246
- cleanup();
247
- }, timeout);
248
- }
249
- }
250
- update(search);
251
- return next;
252
- }
253
- findByTypeahead.defaultOptions = {
254
- keysSoFar: "",
255
- timer: -1
256
- };
257
223
 
258
224
  // ../../utilities/number/dist/index.mjs
259
225
  var __pow = Math.pow;
260
- function wrap2(num, max) {
226
+ function wrap(num, max) {
261
227
  return (num % max + max) % max;
262
228
  }
263
229
  function roundToDevicePixel(num) {
@@ -320,91 +286,37 @@ function decimalOperation(a, op, b) {
320
286
  }
321
287
  var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigits: 20 });
322
288
 
323
- // ../../utilities/rect/dist/index.mjs
324
- var isDom2 = () => typeof window !== "undefined";
325
- var isArray = (v) => Array.isArray(v);
326
- var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
327
- var hasProp2 = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
328
- var isTouchDevice2 = isDom2() && !!navigator.maxTouchPoints;
329
- var isTouchEvent = (v) => isObject(v) && hasProp2(v, "touches");
330
- var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
331
- function getEventPoint(e, t = "page") {
332
- const p = isTouchEvent(e) ? e.touches[0] || e.changedTouches[0] || fallback : e;
333
- return { x: p[`${t}X`], y: p[`${t}Y`] };
334
- }
335
-
336
- // ../../types/dist/index.mjs
337
- function createNormalizer(fn) {
338
- return new Proxy({}, {
339
- get() {
340
- return fn;
341
- }
342
- });
343
- }
344
- var normalizeProp = createNormalizer((v) => v);
345
-
346
- // ../../utilities/core/dist/index.mjs
347
- var isDom3 = () => typeof window !== "undefined";
348
- function getPlatform() {
349
- var _a;
350
- const agent = navigator.userAgentData;
351
- return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
352
- }
353
- var pt = (v) => isDom3() && v.test(getPlatform());
354
- var vn = (v) => isDom3() && v.test(navigator.vendor);
355
- var isTouchDevice3 = isDom3() && !!navigator.maxTouchPoints;
356
- var isMac = () => pt(/^Mac/) && !isTouchDevice3;
357
- var isSafari = () => isApple() && vn(/apple/i);
358
- var isApple = () => pt(/mac|iphone|ipad|ipod/i);
359
- var isIos = () => isApple() && !isMac();
360
- var supportsPointerEvent = () => isDom3() && window.onpointerdown === null;
361
- var isLeftClick = (v) => v.button === 0;
362
- var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
363
- var pipe2 = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
364
-
365
289
  // src/number-input.dom.ts
366
- var dom = {
367
- getDoc: (ctx) => {
368
- var _a;
369
- return (_a = ctx.doc) != null ? _a : document;
370
- },
371
- getWin: (ctx) => {
372
- var _a;
373
- return (_a = dom.getDoc(ctx).defaultView) != null ? _a : window;
374
- },
375
- getRootNode: (ctx) => {
376
- var _a;
377
- return (_a = ctx.rootNode) != null ? _a : dom.getDoc(ctx);
378
- },
290
+ var dom = defineDomHelpers({
379
291
  getRootId: (ctx) => {
380
292
  var _a, _b;
381
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.root) != null ? _b : `number-input:${ctx.uid}`;
293
+ return (_b = (_a = ctx.ids) == null ? void 0 : _a.root) != null ? _b : `number-input:${ctx.id}`;
382
294
  },
383
295
  getInputId: (ctx) => {
384
296
  var _a, _b;
385
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.input) != null ? _b : `number-input:${ctx.uid}:input`;
297
+ return (_b = (_a = ctx.ids) == null ? void 0 : _a.input) != null ? _b : `number-input:${ctx.id}:input`;
386
298
  },
387
299
  getIncButtonId: (ctx) => {
388
300
  var _a, _b;
389
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.incBtn) != null ? _b : `number-input:${ctx.uid}:inc-btn`;
301
+ return (_b = (_a = ctx.ids) == null ? void 0 : _a.incBtn) != null ? _b : `number-input:${ctx.id}:inc-btn`;
390
302
  },
391
303
  getDecButtonId: (ctx) => {
392
304
  var _a, _b;
393
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.decBtn) != null ? _b : `number-input:${ctx.uid}:dec-btn`;
305
+ return (_b = (_a = ctx.ids) == null ? void 0 : _a.decBtn) != null ? _b : `number-input:${ctx.id}:dec-btn`;
394
306
  },
395
307
  getScrubberId: (ctx) => {
396
308
  var _a, _b;
397
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.scrubber) != null ? _b : `number-input:${ctx.uid}:scrubber`;
309
+ return (_b = (_a = ctx.ids) == null ? void 0 : _a.scrubber) != null ? _b : `number-input:${ctx.id}:scrubber`;
398
310
  },
399
- getCursorId: (ctx) => `number-input:${ctx.uid}:cursor`,
311
+ getCursorId: (ctx) => `number-input:${ctx.id}:cursor`,
400
312
  getLabelId: (ctx) => {
401
313
  var _a, _b;
402
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.label) != null ? _b : `number-input:${ctx.uid}:label`;
314
+ return (_b = (_a = ctx.ids) == null ? void 0 : _a.label) != null ? _b : `number-input:${ctx.id}:label`;
403
315
  },
404
- getInputEl: (ctx) => dom.getRootNode(ctx).getElementById(dom.getInputId(ctx)),
405
- getIncButtonEl: (ctx) => dom.getRootNode(ctx).getElementById(dom.getIncButtonId(ctx)),
406
- getDecButtonEl: (ctx) => dom.getRootNode(ctx).getElementById(dom.getDecButtonId(ctx)),
407
- getScrubberEl: (ctx) => dom.getRootNode(ctx).getElementById(dom.getScrubberId(ctx)),
316
+ getInputEl: (ctx) => dom.getById(ctx, dom.getInputId(ctx)),
317
+ getIncButtonEl: (ctx) => dom.getById(ctx, dom.getIncButtonId(ctx)),
318
+ getDecButtonEl: (ctx) => dom.getById(ctx, dom.getDecButtonId(ctx)),
319
+ getScrubberEl: (ctx) => dom.getById(ctx, dom.getScrubberId(ctx)),
408
320
  getCursorEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getCursorId(ctx)),
409
321
  getMousementValue(ctx, event) {
410
322
  const x = roundToDevicePixel(event.movementX);
@@ -421,7 +333,7 @@ var dom = {
421
333
  const win = dom.getWin(ctx);
422
334
  const width = win.innerWidth;
423
335
  const half = roundToDevicePixel(7.5);
424
- point.x = wrap2(point.x + half, width) - half;
336
+ point.x = wrap(point.x + half, width) - half;
425
337
  return { hint, point };
426
338
  },
427
339
  createVirtualCursor(ctx) {
@@ -449,7 +361,7 @@ var dom = {
449
361
  </svg>`;
450
362
  doc.body.appendChild(el);
451
363
  }
452
- };
364
+ });
453
365
 
454
366
  // src/number-input.utils.ts
455
367
  var utils = {
@@ -494,16 +406,18 @@ var utils = {
494
406
  };
495
407
 
496
408
  // src/number-input.connect.ts
497
- function connect(state, send, normalize = normalizeProp) {
409
+ function connect(state, send, normalize) {
498
410
  const isFocused = state.hasTag("focus");
499
411
  const isInvalid = state.context.isOutOfRange || !!state.context.invalid;
500
412
  const isDisabled = !!state.context.disabled;
413
+ const isValueEmpty = state.context.isValueEmpty;
501
414
  const isIncrementDisabled = isDisabled || !state.context.canIncrement;
502
415
  const isDecrementDisabled = isDisabled || !state.context.canDecrement;
503
416
  const messages = state.context.messages;
504
417
  return {
505
418
  isFocused,
506
419
  isInvalid,
420
+ isValueEmpty,
507
421
  value: state.context.formattedValue,
508
422
  valueAsNumber: state.context.valueAsNumber,
509
423
  setValue(value) {
@@ -683,13 +597,21 @@ function connect(state, send, normalize = normalizeProp) {
683
597
 
684
598
  // src/number-input.machine.ts
685
599
  var import_core = require("@zag-js/core");
600
+
601
+ // ../../utilities/core/dist/index.mjs
602
+ var callAll2 = (...fns) => (...a) => {
603
+ fns.forEach(function(fn) {
604
+ fn == null ? void 0 : fn(...a);
605
+ });
606
+ };
607
+
608
+ // src/number-input.machine.ts
686
609
  var { not, and } = import_core.guards;
687
- function machine(ctx = {}) {
610
+ function machine(ctx) {
688
611
  return (0, import_core.createMachine)({
689
612
  id: "number-input",
690
613
  initial: "unknown",
691
614
  context: __spreadProps(__spreadValues({
692
- uid: "",
693
615
  dir: "ltr",
694
616
  focusInputOnChange: true,
695
617
  clampValueOnBlur: true,
@@ -715,6 +637,7 @@ function machine(ctx = {}) {
715
637
  isAtMin: (ctx2) => isAtMin(ctx2.value, ctx2),
716
638
  isAtMax: (ctx2) => isAtMax(ctx2.value, ctx2),
717
639
  isOutOfRange: (ctx2) => !isWithinRange(ctx2.value, ctx2),
640
+ isValueEmpty: (ctx2) => ctx2.value === "",
718
641
  canIncrement: (ctx2) => ctx2.allowOverflow || !ctx2.isAtMax,
719
642
  canDecrement: (ctx2) => ctx2.allowOverflow || !ctx2.isAtMin,
720
643
  valueText: (ctx2) => {
@@ -749,7 +672,7 @@ function machine(ctx = {}) {
749
672
  on: {
750
673
  SETUP: {
751
674
  target: "idle",
752
- actions: ["setupDocument", "syncInputValue"]
675
+ actions: "syncInputValue"
753
676
  }
754
677
  }
755
678
  },
@@ -801,7 +724,7 @@ function machine(ctx = {}) {
801
724
  actions: ["clearValue", "clearHint"]
802
725
  },
803
726
  {
804
- guard: and("clampOnBlur", not("isInRange")),
727
+ guard: and("clampOnBlur", not("isInRange"), not("isEmptyValue")),
805
728
  target: "idle",
806
729
  actions: ["clampValue", "clearHint"]
807
730
  },
@@ -891,6 +814,7 @@ function machine(ctx = {}) {
891
814
  var _a;
892
815
  return ((_a = evt.hint) != null ? _a : ctx2.hint) === "decrement";
893
816
  },
817
+ isEmptyValue: (ctx2) => ctx2.isValueEmpty,
894
818
  isIncrementHint: (ctx2, evt) => {
895
819
  var _a;
896
820
  return ((_a = evt.hint) != null ? _a : ctx2.hint) === "increment";
@@ -950,17 +874,10 @@ function machine(ctx = {}) {
950
874
  function onMouseup() {
951
875
  send("POINTER_UP_SCRUBBER");
952
876
  }
953
- return pipe2(addDomEvent(doc, "mousemove", onMousemove, false), addDomEvent(doc, "mouseup", onMouseup, false));
877
+ return callAll2(addDomEvent(doc, "mousemove", onMousemove, false), addDomEvent(doc, "mouseup", onMouseup, false));
954
878
  }
955
879
  },
956
880
  actions: {
957
- setupDocument: (ctx2, evt) => {
958
- if (evt.doc)
959
- ctx2.doc = (0, import_core.ref)(evt.doc);
960
- if (evt.root)
961
- ctx2.rootNode = (0, import_core.ref)(evt.root);
962
- ctx2.uid = evt.id;
963
- },
964
881
  focusInput(ctx2) {
965
882
  if (!ctx2.focusInputOnChange)
966
883
  return;
@@ -984,7 +901,7 @@ function machine(ctx = {}) {
984
901
  setValue(ctx2, evt) {
985
902
  var _a, _b;
986
903
  const value = (_b = (_a = evt.target) == null ? void 0 : _a.value) != null ? _b : evt.value;
987
- ctx2.value = utils.sanitize(ctx2, utils.parse(ctx2, value));
904
+ ctx2.value = utils.sanitize(ctx2, utils.parse(ctx2, value.toString()));
988
905
  },
989
906
  clearValue(ctx2) {
990
907
  ctx2.value = "";
@@ -1069,4 +986,3 @@ function machine(ctx = {}) {
1069
986
  hookSync: true
1070
987
  });
1071
988
  }
1072
- //# sourceMappingURL=index.js.map