@zag-js/number-input 0.2.8 → 0.2.10

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
@@ -53,11 +53,11 @@ var MAX_Z_INDEX = 2147483647;
53
53
  // ../../utilities/core/src/functions.ts
54
54
  var runIfFn = (v, ...a) => {
55
55
  const res = typeof v === "function" ? v(...a) : v;
56
- return res != null ? res : void 0;
56
+ return res ?? void 0;
57
57
  };
58
58
  var callAll = (...fns) => (...a) => {
59
59
  fns.forEach(function(fn) {
60
- fn == null ? void 0 : fn(...a);
60
+ fn?.(...a);
61
61
  });
62
62
  };
63
63
 
@@ -78,9 +78,8 @@ function compact(obj) {
78
78
  // ../../utilities/dom/src/platform.ts
79
79
  var isDom = () => typeof window !== "undefined";
80
80
  function getPlatform() {
81
- var _a;
82
81
  const agent = navigator.userAgentData;
83
- return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
82
+ return agent?.platform ?? navigator.platform;
84
83
  }
85
84
  var pt = (v) => isDom() && v.test(getPlatform());
86
85
  var vn = (v) => isDom() && v.test(navigator.vendor);
@@ -92,31 +91,23 @@ function isDocument(el) {
92
91
  return el.nodeType === Node.DOCUMENT_NODE;
93
92
  }
94
93
  function isWindow(value) {
95
- return (value == null ? void 0 : value.toString()) === "[object Window]";
94
+ return value?.toString() === "[object Window]";
96
95
  }
97
96
  function getDocument(el) {
98
- var _a;
99
97
  if (isWindow(el))
100
98
  return el.document;
101
99
  if (isDocument(el))
102
100
  return el;
103
- return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
101
+ return el?.ownerDocument ?? document;
104
102
  }
105
103
  function getWindow(el) {
106
- var _a;
107
- return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
104
+ return el?.ownerDocument.defaultView ?? window;
108
105
  }
109
106
  function defineDomHelpers(helpers) {
110
107
  const dom2 = {
111
- getRootNode: (ctx) => {
112
- var _a, _b;
113
- return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
114
- },
108
+ getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
115
109
  getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
116
- getWin: (ctx) => {
117
- var _a;
118
- return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
119
- },
110
+ getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
120
111
  getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
121
112
  getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
122
113
  };
@@ -128,8 +119,7 @@ function defineDomHelpers(helpers) {
128
119
 
129
120
  // ../../utilities/dom/src/event.ts
130
121
  function getNativeEvent(e) {
131
- var _a;
132
- return (_a = e.nativeEvent) != null ? _a : e;
122
+ return e.nativeEvent ?? e;
133
123
  }
134
124
  var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
135
125
  var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
@@ -144,8 +134,7 @@ var fallback = {
144
134
  clientY: 0
145
135
  };
146
136
  function getEventPoint(event, type = "page") {
147
- var _a, _b;
148
- const point = isTouchEvent(event) ? (_b = (_a = event.touches[0]) != null ? _a : event.changedTouches[0]) != null ? _b : fallback : event;
137
+ const point = isTouchEvent(event) ? event.touches[0] ?? event.changedTouches[0] ?? fallback : event;
149
138
  return { x: point[`${type}X`], y: point[`${type}Y`] };
150
139
  }
151
140
 
@@ -166,9 +155,9 @@ function getEventStep(event) {
166
155
  var isRef = (v) => hasProp(v, "current");
167
156
  function addDomEvent(target, eventName, handler, options) {
168
157
  const node = isRef(target) ? target.current : runIfFn(target);
169
- node == null ? void 0 : node.addEventListener(eventName, handler, options);
158
+ node?.addEventListener(eventName, handler, options);
170
159
  return () => {
171
- node == null ? void 0 : node.removeEventListener(eventName, handler, options);
160
+ node?.removeEventListener(eventName, handler, options);
172
161
  };
173
162
  }
174
163
 
@@ -214,13 +203,13 @@ function requestPointerLock(doc, handlers = {}) {
214
203
  const locked = !!doc.pointerLockElement;
215
204
  function onPointerChange() {
216
205
  if (locked)
217
- onPointerLock == null ? void 0 : onPointerLock();
206
+ onPointerLock?.();
218
207
  else
219
- onPointerUnlock == null ? void 0 : onPointerUnlock();
208
+ onPointerUnlock?.();
220
209
  }
221
210
  function onPointerError(event) {
222
211
  if (locked)
223
- onPointerUnlock == null ? void 0 : onPointerUnlock();
212
+ onPointerUnlock?.();
224
213
  console.error("PointerLock error occured:", event);
225
214
  exit();
226
215
  }
@@ -310,31 +299,13 @@ function decimalOperation(a, op, b) {
310
299
 
311
300
  // src/number-input.dom.ts
312
301
  var dom = defineDomHelpers({
313
- getRootId: (ctx) => {
314
- var _a, _b;
315
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.root) != null ? _b : `number-input:${ctx.id}`;
316
- },
317
- getInputId: (ctx) => {
318
- var _a, _b;
319
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.input) != null ? _b : `number-input:${ctx.id}:input`;
320
- },
321
- getIncrementTriggerId: (ctx) => {
322
- var _a, _b;
323
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.incrementTrigger) != null ? _b : `number-input:${ctx.id}:inc`;
324
- },
325
- getDecrementTriggerId: (ctx) => {
326
- var _a, _b;
327
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.decrementTrigger) != null ? _b : `number-input:${ctx.id}:dec`;
328
- },
329
- getScrubberId: (ctx) => {
330
- var _a, _b;
331
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.scrubber) != null ? _b : `number-input:${ctx.id}:scrubber`;
332
- },
302
+ getRootId: (ctx) => ctx.ids?.root ?? `number-input:${ctx.id}`,
303
+ getInputId: (ctx) => ctx.ids?.input ?? `number-input:${ctx.id}:input`,
304
+ getIncrementTriggerId: (ctx) => ctx.ids?.incrementTrigger ?? `number-input:${ctx.id}:inc`,
305
+ getDecrementTriggerId: (ctx) => ctx.ids?.decrementTrigger ?? `number-input:${ctx.id}:dec`,
306
+ getScrubberId: (ctx) => ctx.ids?.scrubber ?? `number-input:${ctx.id}:scrubber`,
333
307
  getCursorId: (ctx) => `number-input:${ctx.id}:cursor`,
334
- getLabelId: (ctx) => {
335
- var _a, _b;
336
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.label) != null ? _b : `number-input:${ctx.id}:label`;
337
- },
308
+ getLabelId: (ctx) => ctx.ids?.label ?? `number-input:${ctx.id}:label`,
338
309
  getInputEl: (ctx) => dom.getById(ctx, dom.getInputId(ctx)),
339
310
  getIncrementTriggerEl: (ctx) => dom.getById(ctx, dom.getIncrementTriggerId(ctx)),
340
311
  getDecrementTriggerEl: (ctx) => dom.getById(ctx, dom.getDecrementTriggerId(ctx)),
@@ -355,8 +326,7 @@ var dom = defineDomHelpers({
355
326
  return;
356
327
  dom.createVirtualCursor(ctx);
357
328
  return () => {
358
- var _a;
359
- (_a = dom.getCursorEl(ctx)) == null ? void 0 : _a.remove();
329
+ dom.getCursorEl(ctx)?.remove();
360
330
  };
361
331
  },
362
332
  preventTextSelection(ctx) {
@@ -426,39 +396,35 @@ var dom = defineDomHelpers({
426
396
  // src/number-input.utils.ts
427
397
  var utils = {
428
398
  isValidNumericEvent: (ctx, event) => {
429
- var _a, _b;
430
399
  if (event.key == null)
431
400
  return true;
432
401
  const isModifier = isModifiedEvent(event);
433
402
  const isSingleKey = event.key.length === 1;
434
403
  if (isModifier || !isSingleKey)
435
404
  return true;
436
- return (_b = (_a = ctx.validateCharacter) == null ? void 0 : _a.call(ctx, event.key)) != null ? _b : utils.isFloatingPoint(event.key);
405
+ return ctx.validateCharacter?.(event.key) ?? utils.isFloatingPoint(event.key);
437
406
  },
438
407
  isFloatingPoint: (v) => /^[0-9+\-.]$/.test(v),
439
408
  sanitize: (ctx, value) => {
440
- var _a;
441
- return value.split("").filter((_a = ctx.validateCharacter) != null ? _a : utils.isFloatingPoint).join("");
409
+ return value.split("").filter(ctx.validateCharacter ?? utils.isFloatingPoint).join("");
442
410
  },
443
411
  increment: (ctx, step) => {
444
- const value = increment(ctx.value, step != null ? step : ctx.step);
412
+ const value = increment(ctx.value, step ?? ctx.step);
445
413
  return formatDecimal(clamp(value, ctx), ctx);
446
414
  },
447
415
  decrement: (ctx, step) => {
448
- const value = decrement(ctx.value, step != null ? step : ctx.step);
416
+ const value = decrement(ctx.value, step ?? ctx.step);
449
417
  return formatDecimal(clamp(value, ctx), ctx);
450
418
  },
451
419
  clamp: (ctx) => {
452
420
  return formatDecimal(clamp(ctx.value, ctx), ctx);
453
421
  },
454
422
  parse: (ctx, value) => {
455
- var _a, _b;
456
- return (_b = (_a = ctx.parse) == null ? void 0 : _a.call(ctx, value)) != null ? _b : value;
423
+ return ctx.parse?.(value) ?? value;
457
424
  },
458
425
  format: (ctx, value) => {
459
- var _a, _b;
460
426
  const _val = value.toString();
461
- return (_b = (_a = ctx.format) == null ? void 0 : _a.call(ctx, _val)) != null ? _b : _val;
427
+ return ctx.format?.(_val) ?? _val;
462
428
  },
463
429
  round: (ctx) => {
464
430
  return formatDecimal(ctx.value, ctx);
@@ -499,12 +465,10 @@ function connect(state, send, normalize) {
499
465
  send({ type: "SET_VALUE", value: state.context.min });
500
466
  },
501
467
  focus() {
502
- var _a;
503
- (_a = dom.getInputEl(state.context)) == null ? void 0 : _a.focus();
468
+ dom.getInputEl(state.context)?.focus();
504
469
  },
505
470
  blur() {
506
- var _a;
507
- (_a = dom.getInputEl(state.context)) == null ? void 0 : _a.blur();
471
+ dom.getInputEl(state.context)?.blur();
508
472
  },
509
473
  rootProps: normalize.element({
510
474
  id: dom.getRootId(state.context),
@@ -663,20 +627,18 @@ var import_core = require("@zag-js/core");
663
627
 
664
628
  // ../../utilities/form-utils/src/input-event.ts
665
629
  function getDescriptor(el, options) {
666
- var _a;
667
630
  const { type, property = "value" } = options;
668
631
  const proto = getWindow(el)[type].prototype;
669
- return (_a = Object.getOwnPropertyDescriptor(proto, property)) != null ? _a : {};
632
+ return Object.getOwnPropertyDescriptor(proto, property) ?? {};
670
633
  }
671
634
  function dispatchInputValueEvent(el, value) {
672
- var _a;
673
635
  if (!el)
674
636
  return;
675
637
  const win = getWindow(el);
676
638
  if (!(el instanceof win.HTMLInputElement))
677
639
  return;
678
640
  const desc = getDescriptor(el, { type: "HTMLInputElement", property: "value" });
679
- (_a = desc.set) == null ? void 0 : _a.call(el, value);
641
+ desc.set?.call(el, value);
680
642
  const event = new win.Event("input", { bubbles: true });
681
643
  el.dispatchEvent(event);
682
644
  }
@@ -688,7 +650,7 @@ function machine(userContext) {
688
650
  return (0, import_core.createMachine)(
689
651
  {
690
652
  id: "number-input",
691
- initial: "unknown",
653
+ initial: "idle",
692
654
  context: {
693
655
  dir: "ltr",
694
656
  focusInputOnChange: true,
@@ -720,20 +682,15 @@ function machine(userContext) {
720
682
  isValueEmpty: (ctx2) => ctx2.value === "",
721
683
  canIncrement: (ctx2) => ctx2.allowOverflow || !ctx2.isAtMax,
722
684
  canDecrement: (ctx2) => ctx2.allowOverflow || !ctx2.isAtMin,
723
- valueText: (ctx2) => {
724
- var _a, _b;
725
- return (_b = (_a = ctx2.translations).valueText) == null ? void 0 : _b.call(_a, ctx2.value);
726
- },
727
- formattedValue: (ctx2) => {
728
- var _a, _b;
729
- return (_b = (_a = ctx2.format) == null ? void 0 : _a.call(ctx2, ctx2.value).toString()) != null ? _b : ctx2.value;
730
- }
685
+ valueText: (ctx2) => ctx2.translations.valueText?.(ctx2.value),
686
+ formattedValue: (ctx2) => ctx2.format?.(ctx2.value).toString() ?? ctx2.value
731
687
  },
732
688
  watch: {
733
689
  value: ["invokeOnChange", "dispatchChangeEvent"],
734
690
  isOutOfRange: ["invokeOnInvalid"],
735
691
  scrubberCursorPoint: ["setVirtualCursorPosition"]
736
692
  },
693
+ entry: ["syncInputValue"],
737
694
  on: {
738
695
  SET_VALUE: [
739
696
  {
@@ -755,14 +712,6 @@ function machine(userContext) {
755
712
  }
756
713
  },
757
714
  states: {
758
- unknown: {
759
- on: {
760
- SETUP: {
761
- target: "idle",
762
- actions: "syncInputValue"
763
- }
764
- }
765
- },
766
715
  idle: {
767
716
  exit: "invokeOnFocus",
768
717
  on: {
@@ -896,15 +845,9 @@ function machine(userContext) {
896
845
  spinOnPress: (ctx2) => !!ctx2.spinOnPress,
897
846
  isAtMax: (ctx2) => ctx2.isAtMax,
898
847
  isInRange: (ctx2) => !ctx2.isOutOfRange,
899
- isDecrementHint: (ctx2, evt) => {
900
- var _a;
901
- return ((_a = evt.hint) != null ? _a : ctx2.hint) === "decrement";
902
- },
848
+ isDecrementHint: (ctx2, evt) => (evt.hint ?? ctx2.hint) === "decrement",
903
849
  isEmptyValue: (ctx2) => ctx2.isValueEmpty,
904
- isIncrementHint: (ctx2, evt) => {
905
- var _a;
906
- return ((_a = evt.hint) != null ? _a : ctx2.hint) === "increment";
907
- },
850
+ isIncrementHint: (ctx2, evt) => (evt.hint ?? ctx2.hint) === "increment",
908
851
  isInvalidExponential: (ctx2) => ctx2.value.toString().startsWith("e")
909
852
  },
910
853
  activities: {
@@ -969,7 +912,7 @@ function machine(userContext) {
969
912
  if (!ctx2.focusInputOnChange)
970
913
  return;
971
914
  const input = dom.getInputEl(ctx2);
972
- raf(() => input == null ? void 0 : input.focus());
915
+ raf(() => input?.focus());
973
916
  },
974
917
  increment(ctx2, evt) {
975
918
  ctx2.value = utils.increment(ctx2, evt.step);
@@ -986,8 +929,7 @@ function machine(userContext) {
986
929
  }
987
930
  },
988
931
  setValue(ctx2, evt) {
989
- var _a, _b;
990
- const value = (_b = (_a = evt.target) == null ? void 0 : _a.value) != null ? _b : evt.value;
932
+ const value = evt.target?.value ?? evt.value;
991
933
  ctx2.value = utils.sanitize(ctx2, utils.parse(ctx2, value.toString()));
992
934
  },
993
935
  clearValue(ctx2) {
@@ -1009,14 +951,12 @@ function machine(userContext) {
1009
951
  ctx2.hint = "set";
1010
952
  },
1011
953
  invokeOnChange(ctx2) {
1012
- var _a;
1013
- (_a = ctx2.onChange) == null ? void 0 : _a.call(ctx2, {
954
+ ctx2.onChange?.({
1014
955
  value: ctx2.value,
1015
956
  valueAsNumber: ctx2.valueAsNumber
1016
957
  });
1017
958
  },
1018
959
  invokeOnFocus(ctx2, evt) {
1019
- var _a;
1020
960
  let srcElement = null;
1021
961
  if (evt.type === "PRESS_DOWN") {
1022
962
  srcElement = dom.getPressedTriggerEl(ctx2, evt.hint);
@@ -1025,25 +965,23 @@ function machine(userContext) {
1025
965
  } else if (evt.type === "PRESS_DOWN_SCRUBBER") {
1026
966
  srcElement = dom.getScrubberEl(ctx2);
1027
967
  }
1028
- (_a = ctx2.onFocus) == null ? void 0 : _a.call(ctx2, {
968
+ ctx2.onFocus?.({
1029
969
  value: ctx2.value,
1030
970
  valueAsNumber: ctx2.valueAsNumber,
1031
971
  srcElement
1032
972
  });
1033
973
  },
1034
974
  invokeOnBlur(ctx2) {
1035
- var _a;
1036
- (_a = ctx2.onBlur) == null ? void 0 : _a.call(ctx2, {
975
+ ctx2.onBlur?.({
1037
976
  value: ctx2.value,
1038
977
  valueAsNumber: ctx2.valueAsNumber
1039
978
  });
1040
979
  },
1041
980
  invokeOnInvalid(ctx2) {
1042
- var _a;
1043
981
  if (!ctx2.isOutOfRange)
1044
982
  return;
1045
983
  const reason = ctx2.valueAsNumber > ctx2.max ? "rangeOverflow" : "rangeUnderflow";
1046
- (_a = ctx2.onInvalid) == null ? void 0 : _a.call(ctx2, {
984
+ ctx2.onInvalid?.({
1047
985
  reason,
1048
986
  value: ctx2.formattedValue,
1049
987
  valueAsNumber: ctx2.valueAsNumber
package/dist/index.mjs CHANGED
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  connect
3
- } from "./chunk-2UDY2X4M.mjs";
3
+ } from "./chunk-4ASBTBA5.mjs";
4
4
  import {
5
5
  anatomy
6
6
  } from "./chunk-XHRILSH3.mjs";
7
7
  import {
8
8
  machine
9
- } from "./chunk-MIZ4MW4C.mjs";
10
- import "./chunk-EUVYGWZ6.mjs";
11
- import "./chunk-HP6F2HUY.mjs";
12
- import "./chunk-VCZUWKJT.mjs";
9
+ } from "./chunk-4A67X5BX.mjs";
10
+ import "./chunk-GQN3V2LU.mjs";
11
+ import "./chunk-6CS5P7OC.mjs";
12
+ import "./chunk-EPCXXTFL.mjs";
13
13
  export {
14
14
  anatomy,
15
15
  connect,
@@ -43,9 +43,8 @@ var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
43
43
  // ../../utilities/dom/src/platform.ts
44
44
  var isDom = () => typeof window !== "undefined";
45
45
  function getPlatform() {
46
- var _a;
47
46
  const agent = navigator.userAgentData;
48
- return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
47
+ return agent?.platform ?? navigator.platform;
49
48
  }
50
49
  var pt = (v) => isDom() && v.test(getPlatform());
51
50
  var vn = (v) => isDom() && v.test(navigator.vendor);
@@ -57,27 +56,20 @@ function isDocument(el) {
57
56
  return el.nodeType === Node.DOCUMENT_NODE;
58
57
  }
59
58
  function isWindow(value) {
60
- return (value == null ? void 0 : value.toString()) === "[object Window]";
59
+ return value?.toString() === "[object Window]";
61
60
  }
62
61
  function getDocument(el) {
63
- var _a;
64
62
  if (isWindow(el))
65
63
  return el.document;
66
64
  if (isDocument(el))
67
65
  return el;
68
- return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
66
+ return el?.ownerDocument ?? document;
69
67
  }
70
68
  function defineDomHelpers(helpers) {
71
69
  const dom2 = {
72
- getRootNode: (ctx) => {
73
- var _a, _b;
74
- return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
75
- },
70
+ getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
76
71
  getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
77
- getWin: (ctx) => {
78
- var _a;
79
- return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
80
- },
72
+ getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
81
73
  getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
82
74
  getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
83
75
  };
@@ -89,8 +81,7 @@ function defineDomHelpers(helpers) {
89
81
 
90
82
  // ../../utilities/dom/src/event.ts
91
83
  function getNativeEvent(e) {
92
- var _a;
93
- return (_a = e.nativeEvent) != null ? _a : e;
84
+ return e.nativeEvent ?? e;
94
85
  }
95
86
  var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
96
87
  var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
@@ -105,8 +96,7 @@ var fallback = {
105
96
  clientY: 0
106
97
  };
107
98
  function getEventPoint(event, type = "page") {
108
- var _a, _b;
109
- const point = isTouchEvent(event) ? (_b = (_a = event.touches[0]) != null ? _a : event.changedTouches[0]) != null ? _b : fallback : event;
99
+ const point = isTouchEvent(event) ? event.touches[0] ?? event.changedTouches[0] ?? fallback : event;
110
100
  return { x: point[`${type}X`], y: point[`${type}Y`] };
111
101
  }
112
102
 
@@ -189,31 +179,13 @@ var parts = anatomy.build();
189
179
 
190
180
  // src/number-input.dom.ts
191
181
  var dom = defineDomHelpers({
192
- getRootId: (ctx) => {
193
- var _a, _b;
194
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.root) != null ? _b : `number-input:${ctx.id}`;
195
- },
196
- getInputId: (ctx) => {
197
- var _a, _b;
198
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.input) != null ? _b : `number-input:${ctx.id}:input`;
199
- },
200
- getIncrementTriggerId: (ctx) => {
201
- var _a, _b;
202
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.incrementTrigger) != null ? _b : `number-input:${ctx.id}:inc`;
203
- },
204
- getDecrementTriggerId: (ctx) => {
205
- var _a, _b;
206
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.decrementTrigger) != null ? _b : `number-input:${ctx.id}:dec`;
207
- },
208
- getScrubberId: (ctx) => {
209
- var _a, _b;
210
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.scrubber) != null ? _b : `number-input:${ctx.id}:scrubber`;
211
- },
182
+ getRootId: (ctx) => ctx.ids?.root ?? `number-input:${ctx.id}`,
183
+ getInputId: (ctx) => ctx.ids?.input ?? `number-input:${ctx.id}:input`,
184
+ getIncrementTriggerId: (ctx) => ctx.ids?.incrementTrigger ?? `number-input:${ctx.id}:inc`,
185
+ getDecrementTriggerId: (ctx) => ctx.ids?.decrementTrigger ?? `number-input:${ctx.id}:dec`,
186
+ getScrubberId: (ctx) => ctx.ids?.scrubber ?? `number-input:${ctx.id}:scrubber`,
212
187
  getCursorId: (ctx) => `number-input:${ctx.id}:cursor`,
213
- getLabelId: (ctx) => {
214
- var _a, _b;
215
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.label) != null ? _b : `number-input:${ctx.id}:label`;
216
- },
188
+ getLabelId: (ctx) => ctx.ids?.label ?? `number-input:${ctx.id}:label`,
217
189
  getInputEl: (ctx) => dom.getById(ctx, dom.getInputId(ctx)),
218
190
  getIncrementTriggerEl: (ctx) => dom.getById(ctx, dom.getIncrementTriggerId(ctx)),
219
191
  getDecrementTriggerEl: (ctx) => dom.getById(ctx, dom.getDecrementTriggerId(ctx)),
@@ -234,8 +206,7 @@ var dom = defineDomHelpers({
234
206
  return;
235
207
  dom.createVirtualCursor(ctx);
236
208
  return () => {
237
- var _a;
238
- (_a = dom.getCursorEl(ctx)) == null ? void 0 : _a.remove();
209
+ dom.getCursorEl(ctx)?.remove();
239
210
  };
240
211
  },
241
212
  preventTextSelection(ctx) {
@@ -305,39 +276,35 @@ var dom = defineDomHelpers({
305
276
  // src/number-input.utils.ts
306
277
  var utils = {
307
278
  isValidNumericEvent: (ctx, event) => {
308
- var _a, _b;
309
279
  if (event.key == null)
310
280
  return true;
311
281
  const isModifier = isModifiedEvent(event);
312
282
  const isSingleKey = event.key.length === 1;
313
283
  if (isModifier || !isSingleKey)
314
284
  return true;
315
- return (_b = (_a = ctx.validateCharacter) == null ? void 0 : _a.call(ctx, event.key)) != null ? _b : utils.isFloatingPoint(event.key);
285
+ return ctx.validateCharacter?.(event.key) ?? utils.isFloatingPoint(event.key);
316
286
  },
317
287
  isFloatingPoint: (v) => /^[0-9+\-.]$/.test(v),
318
288
  sanitize: (ctx, value) => {
319
- var _a;
320
- return value.split("").filter((_a = ctx.validateCharacter) != null ? _a : utils.isFloatingPoint).join("");
289
+ return value.split("").filter(ctx.validateCharacter ?? utils.isFloatingPoint).join("");
321
290
  },
322
291
  increment: (ctx, step) => {
323
- const value = increment(ctx.value, step != null ? step : ctx.step);
292
+ const value = increment(ctx.value, step ?? ctx.step);
324
293
  return formatDecimal(clamp(value, ctx), ctx);
325
294
  },
326
295
  decrement: (ctx, step) => {
327
- const value = decrement(ctx.value, step != null ? step : ctx.step);
296
+ const value = decrement(ctx.value, step ?? ctx.step);
328
297
  return formatDecimal(clamp(value, ctx), ctx);
329
298
  },
330
299
  clamp: (ctx) => {
331
300
  return formatDecimal(clamp(ctx.value, ctx), ctx);
332
301
  },
333
302
  parse: (ctx, value) => {
334
- var _a, _b;
335
- return (_b = (_a = ctx.parse) == null ? void 0 : _a.call(ctx, value)) != null ? _b : value;
303
+ return ctx.parse?.(value) ?? value;
336
304
  },
337
305
  format: (ctx, value) => {
338
- var _a, _b;
339
306
  const _val = value.toString();
340
- return (_b = (_a = ctx.format) == null ? void 0 : _a.call(ctx, _val)) != null ? _b : _val;
307
+ return ctx.format?.(_val) ?? _val;
341
308
  },
342
309
  round: (ctx) => {
343
310
  return formatDecimal(ctx.value, ctx);
@@ -378,12 +345,10 @@ function connect(state, send, normalize) {
378
345
  send({ type: "SET_VALUE", value: state.context.min });
379
346
  },
380
347
  focus() {
381
- var _a;
382
- (_a = dom.getInputEl(state.context)) == null ? void 0 : _a.focus();
348
+ dom.getInputEl(state.context)?.focus();
383
349
  },
384
350
  blur() {
385
- var _a;
386
- (_a = dom.getInputEl(state.context)) == null ? void 0 : _a.blur();
351
+ dom.getInputEl(state.context)?.blur();
387
352
  },
388
353
  rootProps: normalize.element({
389
354
  id: dom.getRootId(state.context),
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  connect
3
- } from "./chunk-2UDY2X4M.mjs";
3
+ } from "./chunk-4ASBTBA5.mjs";
4
4
  import "./chunk-XHRILSH3.mjs";
5
- import "./chunk-EUVYGWZ6.mjs";
6
- import "./chunk-HP6F2HUY.mjs";
7
- import "./chunk-VCZUWKJT.mjs";
5
+ import "./chunk-GQN3V2LU.mjs";
6
+ import "./chunk-6CS5P7OC.mjs";
7
+ import "./chunk-EPCXXTFL.mjs";
8
8
  export {
9
9
  connect
10
10
  };
@@ -30,9 +30,8 @@ var MAX_Z_INDEX = 2147483647;
30
30
  // ../../utilities/dom/src/platform.ts
31
31
  var isDom = () => typeof window !== "undefined";
32
32
  function getPlatform() {
33
- var _a;
34
33
  const agent = navigator.userAgentData;
35
- return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
34
+ return agent?.platform ?? navigator.platform;
36
35
  }
37
36
  var pt = (v) => isDom() && v.test(getPlatform());
38
37
  var vn = (v) => isDom() && v.test(navigator.vendor);
@@ -44,27 +43,20 @@ function isDocument(el) {
44
43
  return el.nodeType === Node.DOCUMENT_NODE;
45
44
  }
46
45
  function isWindow(value) {
47
- return (value == null ? void 0 : value.toString()) === "[object Window]";
46
+ return value?.toString() === "[object Window]";
48
47
  }
49
48
  function getDocument(el) {
50
- var _a;
51
49
  if (isWindow(el))
52
50
  return el.document;
53
51
  if (isDocument(el))
54
52
  return el;
55
- return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
53
+ return el?.ownerDocument ?? document;
56
54
  }
57
55
  function defineDomHelpers(helpers) {
58
56
  const dom2 = {
59
- getRootNode: (ctx) => {
60
- var _a, _b;
61
- return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
62
- },
57
+ getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
63
58
  getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
64
- getWin: (ctx) => {
65
- var _a;
66
- return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
67
- },
59
+ getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
68
60
  getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
69
61
  getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
70
62
  };
@@ -90,31 +82,13 @@ function roundToDevicePixel(num) {
90
82
 
91
83
  // src/number-input.dom.ts
92
84
  var dom = defineDomHelpers({
93
- getRootId: (ctx) => {
94
- var _a, _b;
95
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.root) != null ? _b : `number-input:${ctx.id}`;
96
- },
97
- getInputId: (ctx) => {
98
- var _a, _b;
99
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.input) != null ? _b : `number-input:${ctx.id}:input`;
100
- },
101
- getIncrementTriggerId: (ctx) => {
102
- var _a, _b;
103
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.incrementTrigger) != null ? _b : `number-input:${ctx.id}:inc`;
104
- },
105
- getDecrementTriggerId: (ctx) => {
106
- var _a, _b;
107
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.decrementTrigger) != null ? _b : `number-input:${ctx.id}:dec`;
108
- },
109
- getScrubberId: (ctx) => {
110
- var _a, _b;
111
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.scrubber) != null ? _b : `number-input:${ctx.id}:scrubber`;
112
- },
85
+ getRootId: (ctx) => ctx.ids?.root ?? `number-input:${ctx.id}`,
86
+ getInputId: (ctx) => ctx.ids?.input ?? `number-input:${ctx.id}:input`,
87
+ getIncrementTriggerId: (ctx) => ctx.ids?.incrementTrigger ?? `number-input:${ctx.id}:inc`,
88
+ getDecrementTriggerId: (ctx) => ctx.ids?.decrementTrigger ?? `number-input:${ctx.id}:dec`,
89
+ getScrubberId: (ctx) => ctx.ids?.scrubber ?? `number-input:${ctx.id}:scrubber`,
113
90
  getCursorId: (ctx) => `number-input:${ctx.id}:cursor`,
114
- getLabelId: (ctx) => {
115
- var _a, _b;
116
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.label) != null ? _b : `number-input:${ctx.id}:label`;
117
- },
91
+ getLabelId: (ctx) => ctx.ids?.label ?? `number-input:${ctx.id}:label`,
118
92
  getInputEl: (ctx) => dom.getById(ctx, dom.getInputId(ctx)),
119
93
  getIncrementTriggerEl: (ctx) => dom.getById(ctx, dom.getIncrementTriggerId(ctx)),
120
94
  getDecrementTriggerEl: (ctx) => dom.getById(ctx, dom.getDecrementTriggerId(ctx)),
@@ -135,8 +109,7 @@ var dom = defineDomHelpers({
135
109
  return;
136
110
  dom.createVirtualCursor(ctx);
137
111
  return () => {
138
- var _a;
139
- (_a = dom.getCursorEl(ctx)) == null ? void 0 : _a.remove();
112
+ dom.getCursorEl(ctx)?.remove();
140
113
  };
141
114
  },
142
115
  preventTextSelection(ctx) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  dom
3
- } from "./chunk-EUVYGWZ6.mjs";
4
- import "./chunk-VCZUWKJT.mjs";
3
+ } from "./chunk-GQN3V2LU.mjs";
4
+ import "./chunk-EPCXXTFL.mjs";
5
5
  export {
6
6
  dom
7
7
  };