@v-c/input-number 0.0.2 → 1.0.1

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.
@@ -1,16 +1,20 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
2
5
  const require_rolldown_runtime = require("./_virtual/rolldown_runtime.cjs");
3
6
  const require_useCursor = require("./hooks/useCursor.cjs");
4
7
  const require_useFrame = require("./hooks/useFrame.cjs");
5
8
  const require_StepHandler = require("./StepHandler.cjs");
6
9
  const require_numberUtil = require("./utils/numberUtil.cjs");
7
10
  let vue = require("vue");
8
- let __v_c_mini_decimal = require("@v-c/mini-decimal");
9
- __v_c_mini_decimal = require_rolldown_runtime.__toESM(__v_c_mini_decimal);
10
- let __v_c_util = require("@v-c/util");
11
- let __v_c_util_dist_Dom_focus = require("@v-c/util/dist/Dom/focus");
12
- let __v_c_util_dist_omit = require("@v-c/util/dist/omit");
13
- __v_c_util_dist_omit = require_rolldown_runtime.__toESM(__v_c_util_dist_omit);
11
+ let _v_c_mini_decimal = require("@v-c/mini-decimal");
12
+ _v_c_mini_decimal = require_rolldown_runtime.__toESM(_v_c_mini_decimal);
13
+ let _v_c_util = require("@v-c/util");
14
+ let _v_c_util_dist_Dom_focus = require("@v-c/util/dist/Dom/focus");
15
+ let _v_c_util_dist_KeyCode = require("@v-c/util/dist/KeyCode");
16
+ let _v_c_util_dist_omit = require("@v-c/util/dist/omit");
17
+ _v_c_util_dist_omit = require_rolldown_runtime.__toESM(_v_c_util_dist_omit);
14
18
  function _isSlot(s) {
15
19
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !(0, vue.isVNode)(s);
16
20
  }
@@ -27,7 +31,7 @@ function getDecimalValue(stringMode, decimalValue) {
27
31
  return decimalValue.toNumber();
28
32
  }
29
33
  function getDecimalIfValidate(value) {
30
- const decimal = (0, __v_c_mini_decimal.default)(value);
34
+ const decimal = (0, _v_c_mini_decimal.default)(value);
31
35
  return decimal.isInvalidate() ? null : decimal;
32
36
  }
33
37
  var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slots, expose, emit }) => {
@@ -39,7 +43,7 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
39
43
  const inputRef = (0, vue.shallowRef)();
40
44
  expose({
41
45
  focus: (option) => {
42
- if (inputRef.value) (0, __v_c_util_dist_Dom_focus.triggerFocus)(inputRef.value, option);
46
+ if (inputRef.value) (0, _v_c_util_dist_Dom_focus.triggerFocus)(inputRef.value, option);
43
47
  },
44
48
  blur: () => {
45
49
  inputRef.value?.blur?.();
@@ -47,14 +51,14 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
47
51
  nativeElement: (0, vue.computed)(() => rootRef.value || inputRef.value || null),
48
52
  input: inputRef
49
53
  });
50
- const decimalValue = (0, vue.shallowRef)((0, __v_c_mini_decimal.default)(props.value ?? props.defaultValue ?? ""));
54
+ const decimalValue = (0, vue.shallowRef)((0, _v_c_mini_decimal.default)(props.value ?? props.defaultValue ?? ""));
51
55
  const setUncontrolledDecimalValue = (newDecimal) => {
52
56
  if (props.value === void 0) decimalValue.value = newDecimal;
53
57
  };
54
58
  const getPrecision = (numStr, userTyping) => {
55
59
  if (userTyping) return;
56
60
  if (props.precision !== void 0 && props.precision >= 0) return props.precision;
57
- return Math.max((0, __v_c_mini_decimal.getNumberPrecision)(numStr), (0, __v_c_mini_decimal.getNumberPrecision)(props.step ?? 1));
61
+ return Math.max((0, _v_c_mini_decimal.getNumberPrecision)(numStr), (0, _v_c_mini_decimal.getNumberPrecision)(props.step ?? 1));
58
62
  };
59
63
  const mergedParser = (num) => {
60
64
  const numStr = String(num);
@@ -70,12 +74,12 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
70
74
  userTyping,
71
75
  input: String(inputValueRef.value)
72
76
  });
73
- let str = typeof number === "number" ? (0, __v_c_mini_decimal.num2str)(number) : number;
77
+ let str = typeof number === "number" ? (0, _v_c_mini_decimal.num2str)(number) : number;
74
78
  if (!userTyping) {
75
79
  const mergedPrecision = getPrecision(str, userTyping);
76
- if ((0, __v_c_mini_decimal.validateNumber)(str) && (props.decimalSeparator || mergedPrecision !== void 0 && mergedPrecision >= 0)) {
80
+ if ((0, _v_c_mini_decimal.validateNumber)(str) && (props.decimalSeparator || mergedPrecision !== void 0 && mergedPrecision >= 0)) {
77
81
  const separatorStr = props.decimalSeparator || ".";
78
- str = (0, __v_c_mini_decimal.toFixed)(str, separatorStr, mergedPrecision);
82
+ str = (0, _v_c_mini_decimal.toFixed)(str, separatorStr, mergedPrecision);
79
83
  }
80
84
  }
81
85
  return str;
@@ -131,14 +135,13 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
131
135
  const numStr = updateValue.toString();
132
136
  const mergedPrecision = getPrecision(numStr, userTyping);
133
137
  if (mergedPrecision !== void 0 && mergedPrecision >= 0) {
134
- updateValue = (0, __v_c_mini_decimal.default)((0, __v_c_mini_decimal.toFixed)(numStr, ".", mergedPrecision));
135
- if (!isInRange(updateValue)) updateValue = (0, __v_c_mini_decimal.default)((0, __v_c_mini_decimal.toFixed)(numStr, ".", mergedPrecision, true));
138
+ updateValue = (0, _v_c_mini_decimal.default)((0, _v_c_mini_decimal.toFixed)(numStr, ".", mergedPrecision));
139
+ if (!isInRange(updateValue)) updateValue = (0, _v_c_mini_decimal.default)((0, _v_c_mini_decimal.toFixed)(numStr, ".", mergedPrecision, true));
136
140
  }
137
141
  if (!updateValue.equals(decimalValue.value)) {
138
142
  setUncontrolledDecimalValue(updateValue);
139
143
  const outValue = updateValue.isEmpty() ? null : getDecimalValue(props.stringMode, updateValue);
140
144
  props.onChange?.(outValue);
141
- emit("change", outValue);
142
145
  if (props.value === void 0) setInputValue(updateValue, userTyping);
143
146
  emit("update:value", outValue);
144
147
  }
@@ -152,11 +155,10 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
152
155
  inputValueRef.value = inputStr;
153
156
  inputValue.value = inputStr;
154
157
  if (!compositionRef.value) {
155
- const finalDecimal = (0, __v_c_mini_decimal.default)(mergedParser(inputStr));
158
+ const finalDecimal = (0, _v_c_mini_decimal.default)(mergedParser(inputStr));
156
159
  if (!finalDecimal.isNaN()) triggerValueUpdate(finalDecimal, true);
157
160
  }
158
161
  props.onInput?.(inputStr);
159
- emit("input", inputStr);
160
162
  onNextPromise(() => {
161
163
  let nextInputStr = inputStr;
162
164
  if (!props.parser) nextInputStr = inputStr.replace(/。/g, ".");
@@ -165,12 +167,10 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
165
167
  };
166
168
  const onCompositionStart = (e) => {
167
169
  compositionRef.value = true;
168
- emit("compositionstart", e);
169
170
  props.onCompositionStart?.(e);
170
171
  };
171
172
  const onCompositionEnd = (e) => {
172
173
  compositionRef.value = false;
173
- emit("compositionend", e);
174
174
  props.onCompositionEnd?.(e);
175
175
  if (inputRef.value) collectInputValue(inputRef.value.value);
176
176
  };
@@ -180,24 +180,19 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
180
180
  const onInternalStep = (up, emitter) => {
181
181
  if (up && upDisabled.value || !up && downDisabled.value) return;
182
182
  userTypingRef.value = false;
183
- let stepDecimal = (0, __v_c_mini_decimal.default)(shiftKeyRef.value ? require_numberUtil.getDecupleSteps(props.step ?? 1) : props.step ?? 1);
183
+ let stepDecimal = (0, _v_c_mini_decimal.default)(shiftKeyRef.value ? require_numberUtil.getDecupleSteps(props.step ?? 1) : props.step ?? 1);
184
184
  if (!up) stepDecimal = stepDecimal.negate();
185
- const updatedValue = triggerValueUpdate((decimalValue.value || (0, __v_c_mini_decimal.default)(0)).add(stepDecimal.toString()), false);
185
+ const updatedValue = triggerValueUpdate((decimalValue.value || (0, _v_c_mini_decimal.default)(0)).add(stepDecimal.toString()), false);
186
186
  const outValue = getDecimalValue(props.stringMode, updatedValue);
187
187
  props.onStep?.(outValue, {
188
188
  offset: shiftKeyRef.value ? require_numberUtil.getDecupleSteps(props.step ?? 1) : props.step ?? 1,
189
189
  type: up ? "up" : "down",
190
190
  emitter
191
191
  });
192
- emit("step", outValue, {
193
- offset: shiftKeyRef.value ? require_numberUtil.getDecupleSteps(props.step ?? 1) : props.step ?? 1,
194
- type: up ? "up" : "down",
195
- emitter
196
- });
197
192
  inputRef.value?.focus();
198
193
  };
199
194
  const flushInputValue = (userTyping) => {
200
- const parsedValue = (0, __v_c_mini_decimal.default)(mergedParser(inputValue.value));
195
+ const parsedValue = (0, _v_c_mini_decimal.default)(mergedParser(inputValue.value));
201
196
  let formatValue;
202
197
  if (!parsedValue.isNaN()) formatValue = triggerValueUpdate(parsedValue, userTyping);
203
198
  else formatValue = triggerValueUpdate(decimalValue.value, userTyping);
@@ -206,22 +201,19 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
206
201
  };
207
202
  const onBeforeInput = (e) => {
208
203
  userTypingRef.value = true;
209
- emit("beforeinput", e);
210
204
  props.onBeforeInput?.(e);
211
205
  };
212
206
  const onKeyDown = (event) => {
213
207
  const { key, shiftKey } = event;
214
208
  userTypingRef.value = true;
215
209
  shiftKeyRef.value = shiftKey;
216
- if (key === "Enter") {
210
+ if (key === _v_c_util_dist_KeyCode.KeyCodeStr.Enter) {
217
211
  if (!compositionRef.value) userTypingRef.value = false;
218
212
  flushInputValue(false);
219
- emit("pressEnter", event);
220
213
  props.onPressEnter?.(event);
221
214
  }
222
215
  if (props.keyboard === false) {
223
216
  props.onKeyDown?.(event);
224
- emit("keydown", event);
225
217
  return;
226
218
  }
227
219
  if (!compositionRef.value && [
@@ -234,12 +226,10 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
234
226
  event.preventDefault();
235
227
  }
236
228
  props.onKeyDown?.(event);
237
- emit("keydown", event);
238
229
  };
239
230
  const onKeyUp = (event) => {
240
231
  userTypingRef.value = false;
241
232
  shiftKeyRef.value = false;
242
- emit("keyup", event);
243
233
  props.onKeyUp?.(event);
244
234
  };
245
235
  (0, vue.watchEffect)((onCleanup) => {
@@ -256,12 +246,10 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
256
246
  if (props.changeOnBlur ?? true) flushInputValue(false);
257
247
  focus.value = false;
258
248
  userTypingRef.value = false;
259
- emit("blur", e);
260
249
  props.onBlur?.(e);
261
250
  };
262
251
  const onFocus = (e) => {
263
252
  focus.value = true;
264
- emit("focus", e);
265
253
  props.onFocus?.(e);
266
254
  };
267
255
  const onInternalMouseDown = (event) => {
@@ -269,7 +257,6 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
269
257
  inputRef.value.focus();
270
258
  event.preventDefault();
271
259
  }
272
- emit("mousedown", event);
273
260
  props.onMouseDown?.(event);
274
261
  };
275
262
  (0, vue.watch)([
@@ -280,9 +267,9 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
280
267
  if (!decimalValue.value.isInvalidate()) setInputValue(decimalValue.value, false);
281
268
  });
282
269
  (0, vue.watch)(() => props.value, (newVal) => {
283
- const newValue = (0, __v_c_mini_decimal.default)(newVal ?? "");
270
+ const newValue = (0, _v_c_mini_decimal.default)(newVal ?? "");
284
271
  decimalValue.value = newValue;
285
- const currentParsedValue = (0, __v_c_mini_decimal.default)(mergedParser(inputValue.value));
272
+ const currentParsedValue = (0, _v_c_mini_decimal.default)(mergedParser(inputValue.value));
286
273
  if (!newValue.equals(currentParsedValue) || !userTypingRef.value || props.formatter) setInputValue(newValue, userTypingRef.value);
287
274
  });
288
275
  (0, vue.watch)(() => inputValue.value, () => {
@@ -291,7 +278,7 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
291
278
  return () => {
292
279
  const { prefixCls = defaults.prefixCls, classNames, styles, step = defaults.step, disabled, readOnly, controls = defaults.controls, mode = defaults.mode } = props;
293
280
  const mergedPrefixCls = prefixCls || defaults.prefixCls;
294
- const { class: className, style,...restAttrs } = attrs;
281
+ const { class: className, style, ...restAttrs } = attrs;
295
282
  const mergedClassName = props.className || className;
296
283
  const mergedStyle = {
297
284
  ...styles?.root,
@@ -318,7 +305,7 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
318
305
  "className": classNames?.action,
319
306
  "style": styles?.action
320
307
  }, _isSlot(downNode) ? downNode : { default: () => [downNode] });
321
- const inputAttrs = (0, __v_c_util_dist_omit.default)({ ...restAttrs }, [
308
+ const inputAttrs = (0, _v_c_util_dist_omit.default)({ ...restAttrs }, [
322
309
  "prefixCls",
323
310
  "classNames",
324
311
  "styles",
@@ -360,7 +347,7 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
360
347
  ]);
361
348
  return (0, vue.createVNode)("div", {
362
349
  "ref": rootRef,
363
- "class": (0, __v_c_util.clsx)(mergedPrefixCls, `${mergedPrefixCls}-mode-${mode}`, mergedClassName, classNames?.root, {
350
+ "class": (0, _v_c_util.clsx)(mergedPrefixCls, `${mergedPrefixCls}-mode-${mode}`, mergedClassName, classNames?.root, {
364
351
  [`${mergedPrefixCls}-focused`]: focus.value,
365
352
  [`${mergedPrefixCls}-disabled`]: disabled,
366
353
  [`${mergedPrefixCls}-readonly`]: readOnly,
@@ -370,33 +357,27 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
370
357
  "style": mergedStyle,
371
358
  "onMousedown": onInternalMouseDown,
372
359
  "onMouseup": (e) => {
373
- emit("mouseup", e);
374
360
  props.onMouseUp?.(e);
375
361
  },
376
362
  "onMouseleave": (e) => {
377
- emit("mouseleave", e);
378
363
  props.onMouseLeave?.(e);
379
364
  },
380
365
  "onMousemove": (e) => {
381
- emit("mousemove", e);
382
366
  props.onMouseMove?.(e);
383
367
  },
384
368
  "onMouseenter": (e) => {
385
- emit("mouseenter", e);
386
369
  props.onMouseEnter?.(e);
387
370
  },
388
371
  "onMouseout": (e) => {
389
- emit("mouseout", e);
390
372
  props.onMouseOut?.(e);
391
373
  },
392
374
  "onClick": (e) => {
393
- emit("click", e);
394
375
  props.onClick?.(e);
395
376
  }
396
377
  }, [
397
378
  mode === "spinner" && controls && downHandlerNode,
398
- prefixNode !== void 0 && (0, vue.createVNode)("div", {
399
- "class": (0, __v_c_util.clsx)(`${mergedPrefixCls}-prefix`, classNames?.prefix),
379
+ !!prefixNode && (0, vue.createVNode)("div", {
380
+ "class": (0, _v_c_util.clsx)(`${mergedPrefixCls}-prefix`, classNames?.prefix),
400
381
  "style": styles?.prefix
401
382
  }, [prefixNode]),
402
383
  (0, vue.createVNode)("input", (0, vue.mergeProps)({
@@ -407,10 +388,10 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
407
388
  "aria-valuenow": decimalValue.value.isInvalidate() ? null : decimalValue.value.toString(),
408
389
  "step": step,
409
390
  "ref": inputRef,
410
- "class": (0, __v_c_util.clsx)(`${mergedPrefixCls}-input`, classNames?.input),
391
+ "class": (0, _v_c_util.clsx)(`${mergedPrefixCls}-input`, classNames?.input),
411
392
  "style": styles?.input,
412
393
  "value": inputValue.value,
413
- "onChange": onInternalInput,
394
+ "onInput": onInternalInput,
414
395
  "disabled": disabled,
415
396
  "readonly": readOnly,
416
397
  "onFocus": onFocus,
@@ -421,13 +402,13 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
421
402
  "onCompositionend": onCompositionEnd,
422
403
  "onBeforeinput": onBeforeInput
423
404
  }, inputAttrs), null),
424
- suffixNode !== void 0 && (0, vue.createVNode)("div", {
425
- "class": (0, __v_c_util.clsx)(`${mergedPrefixCls}-suffix`, classNames?.suffix),
405
+ !!suffixNode && (0, vue.createVNode)("div", {
406
+ "class": (0, _v_c_util.clsx)(`${mergedPrefixCls}-suffix`, classNames?.suffix),
426
407
  "style": styles?.suffix
427
408
  }, [suffixNode]),
428
409
  mode === "spinner" && controls && upHandlerNode,
429
410
  mode === "input" && controls && (0, vue.createVNode)("div", {
430
- "class": (0, __v_c_util.clsx)(`${mergedPrefixCls}-actions`, classNames?.actions),
411
+ "class": (0, _v_c_util.clsx)(`${mergedPrefixCls}-actions`, classNames?.actions),
431
412
  "style": styles?.actions
432
413
  }, [upHandlerNode, downHandlerNode])
433
414
  ]);
@@ -445,7 +426,6 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
445
426
  default: void 0
446
427
  },
447
428
  class: {
448
- type: null,
449
429
  required: false,
450
430
  default: void 0
451
431
  },
@@ -455,7 +435,6 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
455
435
  default: void 0
456
436
  },
457
437
  style: {
458
- type: null,
459
438
  required: false,
460
439
  default: void 0
461
440
  },
@@ -470,27 +449,22 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
470
449
  default: void 0
471
450
  },
472
451
  min: {
473
- type: null,
474
452
  required: false,
475
453
  default: void 0
476
454
  },
477
455
  max: {
478
- type: null,
479
456
  required: false,
480
457
  default: void 0
481
458
  },
482
459
  step: {
483
- type: null,
484
460
  required: false,
485
461
  default: void 0
486
462
  },
487
463
  defaultValue: {
488
- type: null,
489
464
  required: false,
490
465
  default: void 0
491
466
  },
492
467
  value: {
493
- type: null,
494
468
  required: false,
495
469
  default: void 0
496
470
  },
@@ -505,22 +479,18 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
505
479
  default: void 0
506
480
  },
507
481
  prefix: {
508
- type: null,
509
482
  required: false,
510
483
  default: void 0
511
484
  },
512
485
  suffix: {
513
- type: null,
514
486
  required: false,
515
487
  default: void 0
516
488
  },
517
489
  upHandler: {
518
- type: null,
519
490
  required: false,
520
491
  default: void 0
521
492
  },
522
493
  downHandler: {
523
- type: null,
524
494
  required: false,
525
495
  default: void 0
526
496
  },
@@ -667,27 +637,7 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
667
637
  }, defaults),
668
638
  name: "InputNumber",
669
639
  inheritAttrs: false,
670
- emits: [
671
- "change",
672
- "update:value",
673
- "input",
674
- "pressEnter",
675
- "step",
676
- "mousedown",
677
- "click",
678
- "mouseup",
679
- "mouseleave",
680
- "mousemove",
681
- "mouseenter",
682
- "mouseout",
683
- "focus",
684
- "blur",
685
- "keydown",
686
- "keyup",
687
- "compositionstart",
688
- "compositionend",
689
- "beforeinput"
690
- ]
640
+ emits: ["update:value"]
691
641
  });
692
642
  var InputNumber_default = InputNumber;
693
643
  exports.default = InputNumber_default;
@@ -6,6 +6,7 @@ import { computed, createVNode, defineComponent, isVNode, mergeDefaults, mergePr
6
6
  import getMiniDecimal, { getNumberPrecision, num2str, toFixed, validateNumber } from "@v-c/mini-decimal";
7
7
  import { clsx } from "@v-c/util";
8
8
  import { triggerFocus } from "@v-c/util/dist/Dom/focus";
9
+ import { KeyCodeStr } from "@v-c/util/dist/KeyCode";
9
10
  import omit from "@v-c/util/dist/omit";
10
11
  function _isSlot(s) {
11
12
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
@@ -134,7 +135,6 @@ var InputNumber_default = /* @__PURE__ */ defineComponent((props, { attrs, slots
134
135
  setUncontrolledDecimalValue(updateValue);
135
136
  const outValue = updateValue.isEmpty() ? null : getDecimalValue(props.stringMode, updateValue);
136
137
  props.onChange?.(outValue);
137
- emit("change", outValue);
138
138
  if (props.value === void 0) setInputValue(updateValue, userTyping);
139
139
  emit("update:value", outValue);
140
140
  }
@@ -152,7 +152,6 @@ var InputNumber_default = /* @__PURE__ */ defineComponent((props, { attrs, slots
152
152
  if (!finalDecimal.isNaN()) triggerValueUpdate(finalDecimal, true);
153
153
  }
154
154
  props.onInput?.(inputStr);
155
- emit("input", inputStr);
156
155
  onNextPromise(() => {
157
156
  let nextInputStr = inputStr;
158
157
  if (!props.parser) nextInputStr = inputStr.replace(/。/g, ".");
@@ -161,12 +160,10 @@ var InputNumber_default = /* @__PURE__ */ defineComponent((props, { attrs, slots
161
160
  };
162
161
  const onCompositionStart = (e) => {
163
162
  compositionRef.value = true;
164
- emit("compositionstart", e);
165
163
  props.onCompositionStart?.(e);
166
164
  };
167
165
  const onCompositionEnd = (e) => {
168
166
  compositionRef.value = false;
169
- emit("compositionend", e);
170
167
  props.onCompositionEnd?.(e);
171
168
  if (inputRef.value) collectInputValue(inputRef.value.value);
172
169
  };
@@ -185,11 +182,6 @@ var InputNumber_default = /* @__PURE__ */ defineComponent((props, { attrs, slots
185
182
  type: up ? "up" : "down",
186
183
  emitter
187
184
  });
188
- emit("step", outValue, {
189
- offset: shiftKeyRef.value ? getDecupleSteps(props.step ?? 1) : props.step ?? 1,
190
- type: up ? "up" : "down",
191
- emitter
192
- });
193
185
  inputRef.value?.focus();
194
186
  };
195
187
  const flushInputValue = (userTyping) => {
@@ -202,22 +194,19 @@ var InputNumber_default = /* @__PURE__ */ defineComponent((props, { attrs, slots
202
194
  };
203
195
  const onBeforeInput = (e) => {
204
196
  userTypingRef.value = true;
205
- emit("beforeinput", e);
206
197
  props.onBeforeInput?.(e);
207
198
  };
208
199
  const onKeyDown = (event) => {
209
200
  const { key, shiftKey } = event;
210
201
  userTypingRef.value = true;
211
202
  shiftKeyRef.value = shiftKey;
212
- if (key === "Enter") {
203
+ if (key === KeyCodeStr.Enter) {
213
204
  if (!compositionRef.value) userTypingRef.value = false;
214
205
  flushInputValue(false);
215
- emit("pressEnter", event);
216
206
  props.onPressEnter?.(event);
217
207
  }
218
208
  if (props.keyboard === false) {
219
209
  props.onKeyDown?.(event);
220
- emit("keydown", event);
221
210
  return;
222
211
  }
223
212
  if (!compositionRef.value && [
@@ -230,12 +219,10 @@ var InputNumber_default = /* @__PURE__ */ defineComponent((props, { attrs, slots
230
219
  event.preventDefault();
231
220
  }
232
221
  props.onKeyDown?.(event);
233
- emit("keydown", event);
234
222
  };
235
223
  const onKeyUp = (event) => {
236
224
  userTypingRef.value = false;
237
225
  shiftKeyRef.value = false;
238
- emit("keyup", event);
239
226
  props.onKeyUp?.(event);
240
227
  };
241
228
  watchEffect((onCleanup) => {
@@ -252,12 +239,10 @@ var InputNumber_default = /* @__PURE__ */ defineComponent((props, { attrs, slots
252
239
  if (props.changeOnBlur ?? true) flushInputValue(false);
253
240
  focus.value = false;
254
241
  userTypingRef.value = false;
255
- emit("blur", e);
256
242
  props.onBlur?.(e);
257
243
  };
258
244
  const onFocus = (e) => {
259
245
  focus.value = true;
260
- emit("focus", e);
261
246
  props.onFocus?.(e);
262
247
  };
263
248
  const onInternalMouseDown = (event) => {
@@ -265,7 +250,6 @@ var InputNumber_default = /* @__PURE__ */ defineComponent((props, { attrs, slots
265
250
  inputRef.value.focus();
266
251
  event.preventDefault();
267
252
  }
268
- emit("mousedown", event);
269
253
  props.onMouseDown?.(event);
270
254
  };
271
255
  watch([
@@ -287,7 +271,7 @@ var InputNumber_default = /* @__PURE__ */ defineComponent((props, { attrs, slots
287
271
  return () => {
288
272
  const { prefixCls = defaults.prefixCls, classNames: classNames$1, styles, step = defaults.step, disabled, readOnly, controls = defaults.controls, mode = defaults.mode } = props;
289
273
  const mergedPrefixCls = prefixCls || defaults.prefixCls;
290
- const { class: className, style,...restAttrs } = attrs;
274
+ const { class: className, style, ...restAttrs } = attrs;
291
275
  const mergedClassName = props.className || className;
292
276
  const mergedStyle = {
293
277
  ...styles?.root,
@@ -366,32 +350,26 @@ var InputNumber_default = /* @__PURE__ */ defineComponent((props, { attrs, slots
366
350
  "style": mergedStyle,
367
351
  "onMousedown": onInternalMouseDown,
368
352
  "onMouseup": (e) => {
369
- emit("mouseup", e);
370
353
  props.onMouseUp?.(e);
371
354
  },
372
355
  "onMouseleave": (e) => {
373
- emit("mouseleave", e);
374
356
  props.onMouseLeave?.(e);
375
357
  },
376
358
  "onMousemove": (e) => {
377
- emit("mousemove", e);
378
359
  props.onMouseMove?.(e);
379
360
  },
380
361
  "onMouseenter": (e) => {
381
- emit("mouseenter", e);
382
362
  props.onMouseEnter?.(e);
383
363
  },
384
364
  "onMouseout": (e) => {
385
- emit("mouseout", e);
386
365
  props.onMouseOut?.(e);
387
366
  },
388
367
  "onClick": (e) => {
389
- emit("click", e);
390
368
  props.onClick?.(e);
391
369
  }
392
370
  }, [
393
371
  mode === "spinner" && controls && downHandlerNode,
394
- prefixNode !== void 0 && createVNode("div", {
372
+ !!prefixNode && createVNode("div", {
395
373
  "class": clsx(`${mergedPrefixCls}-prefix`, classNames$1?.prefix),
396
374
  "style": styles?.prefix
397
375
  }, [prefixNode]),
@@ -406,7 +384,7 @@ var InputNumber_default = /* @__PURE__ */ defineComponent((props, { attrs, slots
406
384
  "class": clsx(`${mergedPrefixCls}-input`, classNames$1?.input),
407
385
  "style": styles?.input,
408
386
  "value": inputValue.value,
409
- "onChange": onInternalInput,
387
+ "onInput": onInternalInput,
410
388
  "disabled": disabled,
411
389
  "readonly": readOnly,
412
390
  "onFocus": onFocus,
@@ -417,7 +395,7 @@ var InputNumber_default = /* @__PURE__ */ defineComponent((props, { attrs, slots
417
395
  "onCompositionend": onCompositionEnd,
418
396
  "onBeforeinput": onBeforeInput
419
397
  }, inputAttrs), null),
420
- suffixNode !== void 0 && createVNode("div", {
398
+ !!suffixNode && createVNode("div", {
421
399
  "class": clsx(`${mergedPrefixCls}-suffix`, classNames$1?.suffix),
422
400
  "style": styles?.suffix
423
401
  }, [suffixNode]),
@@ -441,7 +419,6 @@ var InputNumber_default = /* @__PURE__ */ defineComponent((props, { attrs, slots
441
419
  default: void 0
442
420
  },
443
421
  class: {
444
- type: null,
445
422
  required: false,
446
423
  default: void 0
447
424
  },
@@ -451,7 +428,6 @@ var InputNumber_default = /* @__PURE__ */ defineComponent((props, { attrs, slots
451
428
  default: void 0
452
429
  },
453
430
  style: {
454
- type: null,
455
431
  required: false,
456
432
  default: void 0
457
433
  },
@@ -466,27 +442,22 @@ var InputNumber_default = /* @__PURE__ */ defineComponent((props, { attrs, slots
466
442
  default: void 0
467
443
  },
468
444
  min: {
469
- type: null,
470
445
  required: false,
471
446
  default: void 0
472
447
  },
473
448
  max: {
474
- type: null,
475
449
  required: false,
476
450
  default: void 0
477
451
  },
478
452
  step: {
479
- type: null,
480
453
  required: false,
481
454
  default: void 0
482
455
  },
483
456
  defaultValue: {
484
- type: null,
485
457
  required: false,
486
458
  default: void 0
487
459
  },
488
460
  value: {
489
- type: null,
490
461
  required: false,
491
462
  default: void 0
492
463
  },
@@ -501,22 +472,18 @@ var InputNumber_default = /* @__PURE__ */ defineComponent((props, { attrs, slots
501
472
  default: void 0
502
473
  },
503
474
  prefix: {
504
- type: null,
505
475
  required: false,
506
476
  default: void 0
507
477
  },
508
478
  suffix: {
509
- type: null,
510
479
  required: false,
511
480
  default: void 0
512
481
  },
513
482
  upHandler: {
514
- type: null,
515
483
  required: false,
516
484
  default: void 0
517
485
  },
518
486
  downHandler: {
519
- type: null,
520
487
  required: false,
521
488
  default: void 0
522
489
  },
@@ -663,26 +630,6 @@ var InputNumber_default = /* @__PURE__ */ defineComponent((props, { attrs, slots
663
630
  }, defaults),
664
631
  name: "InputNumber",
665
632
  inheritAttrs: false,
666
- emits: [
667
- "change",
668
- "update:value",
669
- "input",
670
- "pressEnter",
671
- "step",
672
- "mousedown",
673
- "click",
674
- "mouseup",
675
- "mouseleave",
676
- "mousemove",
677
- "mouseenter",
678
- "mouseout",
679
- "focus",
680
- "blur",
681
- "keydown",
682
- "keyup",
683
- "compositionstart",
684
- "compositionend",
685
- "beforeinput"
686
- ]
633
+ emits: ["update:value"]
687
634
  });
688
635
  export { InputNumber_default as default };
@@ -1,10 +1,13 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
2
5
  const require_rolldown_runtime = require("./_virtual/rolldown_runtime.cjs");
3
6
  let vue = require("vue");
4
- let __v_c_util = require("@v-c/util");
5
- let __v_c_util_dist_raf = require("@v-c/util/dist/raf");
6
- __v_c_util_dist_raf = require_rolldown_runtime.__toESM(__v_c_util_dist_raf);
7
- let __v_c_util_dist_props_util = require("@v-c/util/dist/props-util");
7
+ let _v_c_util = require("@v-c/util");
8
+ let _v_c_util_dist_raf = require("@v-c/util/dist/raf");
9
+ _v_c_util_dist_raf = require_rolldown_runtime.__toESM(_v_c_util_dist_raf);
10
+ let _v_c_util_dist_props_util = require("@v-c/util/dist/props-util");
8
11
  var STEP_INTERVAL = 200;
9
12
  var STEP_DELAY = 600;
10
13
  var StepHandler_default = /* @__PURE__ */ (0, vue.defineComponent)({
@@ -49,15 +52,15 @@ var StepHandler_default = /* @__PURE__ */ (0, vue.defineComponent)({
49
52
  };
50
53
  (0, vue.onUnmounted)(() => {
51
54
  onStopStep();
52
- frameIds.value.forEach((id) => __v_c_util_dist_raf.default.cancel(id));
55
+ frameIds.value.forEach((id) => _v_c_util_dist_raf.default.cancel(id));
53
56
  });
54
57
  return () => {
55
58
  const { prefixCls, action, disabled, className, style } = props;
56
59
  const isUpAction = action === "up";
57
60
  const actionClassName = `${prefixCls}-action`;
58
- const mergedClassName = (0, __v_c_util.classNames)(actionClassName, `${actionClassName}-${action}`, { [`${actionClassName}-${action}-disabled`]: disabled }, className);
59
- const safeOnStopStep = () => frameIds.value.push((0, __v_c_util_dist_raf.default)(onStopStep));
60
- const children = (0, __v_c_util_dist_props_util.filterEmpty)(slots?.default?.());
61
+ const mergedClassName = (0, _v_c_util.classNames)(actionClassName, `${actionClassName}-${action}`, { [`${actionClassName}-${action}-disabled`]: disabled }, className);
62
+ const safeOnStopStep = () => frameIds.value.push((0, _v_c_util_dist_raf.default)(onStopStep));
63
+ const children = (0, _v_c_util_dist_props_util.filterEmpty)(slots?.default?.());
61
64
  return (0, vue.createVNode)("span", {
62
65
  "unselectable": "on",
63
66
  "role": "button",
@@ -1,8 +1,11 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
2
5
  const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
3
6
  let vue = require("vue");
4
- let __v_c_util_dist_warning = require("@v-c/util/dist/warning");
5
- __v_c_util_dist_warning = require_rolldown_runtime.__toESM(__v_c_util_dist_warning);
7
+ let _v_c_util_dist_warning = require("@v-c/util/dist/warning");
8
+ _v_c_util_dist_warning = require_rolldown_runtime.__toESM(_v_c_util_dist_warning);
6
9
  function useCursor(input, focused) {
7
10
  const selectionRef = (0, vue.ref)(null);
8
11
  function recordCursor() {
@@ -31,7 +34,7 @@ function useCursor(input, focused) {
31
34
  }
32
35
  input.setSelectionRange(startPos, startPos);
33
36
  } catch (e) {
34
- (0, __v_c_util_dist_warning.default)(false, `Something warning of cursor restore. Please fire issue about this: ${e.message}`);
37
+ (0, _v_c_util_dist_warning.default)(false, `Something warning of cursor restore. Please fire issue about this: ${e.message}`);
35
38
  }
36
39
  }
37
40
  return [recordCursor, restoreCursor];
@@ -1,17 +1,20 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
2
5
  const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
3
6
  let vue = require("vue");
4
- let __v_c_util_dist_raf = require("@v-c/util/dist/raf");
5
- __v_c_util_dist_raf = require_rolldown_runtime.__toESM(__v_c_util_dist_raf);
7
+ let _v_c_util_dist_raf = require("@v-c/util/dist/raf");
8
+ _v_c_util_dist_raf = require_rolldown_runtime.__toESM(_v_c_util_dist_raf);
6
9
  var useFrame_default = () => {
7
10
  const idRef = (0, vue.ref)(0);
8
11
  const cleanUp = () => {
9
- __v_c_util_dist_raf.default.cancel(idRef.value);
12
+ _v_c_util_dist_raf.default.cancel(idRef.value);
10
13
  };
11
14
  (0, vue.onUnmounted)(cleanUp);
12
15
  return (callback) => {
13
16
  cleanUp();
14
- idRef.value = (0, __v_c_util_dist_raf.default)(() => {
17
+ idRef.value = (0, _v_c_util_dist_raf.default)(() => {
15
18
  callback();
16
19
  });
17
20
  };
package/dist/index.cjs CHANGED
@@ -1,4 +1,7 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
2
5
  const require_InputNumber = require("./InputNumber.cjs");
3
6
  var src_default = require_InputNumber.default;
4
7
  exports.default = src_default;
@@ -1,8 +1,9 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
1
2
  const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
2
- let __v_c_mini_decimal = require("@v-c/mini-decimal");
3
+ let _v_c_mini_decimal = require("@v-c/mini-decimal");
3
4
  function getDecupleSteps(step) {
4
- const stepStr = typeof step === "number" ? (0, __v_c_mini_decimal.num2str)(step) : (0, __v_c_mini_decimal.trimNumber)(step).fullStr;
5
+ const stepStr = typeof step === "number" ? (0, _v_c_mini_decimal.num2str)(step) : (0, _v_c_mini_decimal.trimNumber)(step).fullStr;
5
6
  if (!stepStr.includes(".")) return `${step}0`;
6
- return (0, __v_c_mini_decimal.trimNumber)(stepStr.replace(/(\d)\.(\d)/g, "$1$2.")).fullStr;
7
+ return (0, _v_c_mini_decimal.trimNumber)(stepStr.replace(/(\d)\.(\d)/g, "$1$2.")).fullStr;
7
8
  }
8
9
  exports.getDecupleSteps = getDecupleSteps;
package/package.json CHANGED
@@ -1,15 +1,11 @@
1
1
  {
2
2
  "name": "@v-c/input-number",
3
3
  "type": "module",
4
- "version": "0.0.2",
4
+ "version": "1.0.1",
5
5
  "description": "",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
- "files": [
10
- "dist",
11
- "package.json"
12
- ],
13
9
  "exports": {
14
10
  ".": {
15
11
  "types": "./dist/index.d.ts",
@@ -20,18 +16,23 @@
20
16
  "./package.json": "./package.json"
21
17
  },
22
18
  "main": "dist/index.js",
19
+ "files": [
20
+ "dist",
21
+ "package.json"
22
+ ],
23
23
  "peerDependencies": {
24
24
  "vue": "^3.0.0"
25
25
  },
26
26
  "dependencies": {
27
- "@v-c/input": "^0.0.2",
28
- "@v-c/mini-decimal": "^0.0.2",
29
- "@v-c/util": "^0.0.19"
27
+ "@v-c/input": "^1.0.2",
28
+ "@v-c/mini-decimal": "^1.0.1",
29
+ "@v-c/util": "^1.0.9"
30
30
  },
31
31
  "scripts": {
32
32
  "build": "vite build",
33
33
  "prepublish": "pnpm build",
34
34
  "test": "vitest run",
35
- "bump": "bumpp --release patch"
35
+ "patch": "bumpp --release patch",
36
+ "bump": "bumpp"
36
37
  }
37
38
  }