@v-c/input-number 0.0.1 → 1.0.0

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.
@@ -9,6 +9,7 @@ let __v_c_mini_decimal = require("@v-c/mini-decimal");
9
9
  __v_c_mini_decimal = require_rolldown_runtime.__toESM(__v_c_mini_decimal);
10
10
  let __v_c_util = require("@v-c/util");
11
11
  let __v_c_util_dist_Dom_focus = require("@v-c/util/dist/Dom/focus");
12
+ let __v_c_util_dist_KeyCode = require("@v-c/util/dist/KeyCode");
12
13
  let __v_c_util_dist_omit = require("@v-c/util/dist/omit");
13
14
  __v_c_util_dist_omit = require_rolldown_runtime.__toESM(__v_c_util_dist_omit);
14
15
  function _isSlot(s) {
@@ -138,7 +139,6 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
138
139
  setUncontrolledDecimalValue(updateValue);
139
140
  const outValue = updateValue.isEmpty() ? null : getDecimalValue(props.stringMode, updateValue);
140
141
  props.onChange?.(outValue);
141
- emit("change", outValue);
142
142
  if (props.value === void 0) setInputValue(updateValue, userTyping);
143
143
  emit("update:value", outValue);
144
144
  }
@@ -156,7 +156,6 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
156
156
  if (!finalDecimal.isNaN()) triggerValueUpdate(finalDecimal, true);
157
157
  }
158
158
  props.onInput?.(inputStr);
159
- emit("input", inputStr);
160
159
  onNextPromise(() => {
161
160
  let nextInputStr = inputStr;
162
161
  if (!props.parser) nextInputStr = inputStr.replace(/。/g, ".");
@@ -165,12 +164,10 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
165
164
  };
166
165
  const onCompositionStart = (e) => {
167
166
  compositionRef.value = true;
168
- emit("compositionstart", e);
169
167
  props.onCompositionStart?.(e);
170
168
  };
171
169
  const onCompositionEnd = (e) => {
172
170
  compositionRef.value = false;
173
- emit("compositionend", e);
174
171
  props.onCompositionEnd?.(e);
175
172
  if (inputRef.value) collectInputValue(inputRef.value.value);
176
173
  };
@@ -189,11 +186,6 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
189
186
  type: up ? "up" : "down",
190
187
  emitter
191
188
  });
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
189
  inputRef.value?.focus();
198
190
  };
199
191
  const flushInputValue = (userTyping) => {
@@ -206,22 +198,19 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
206
198
  };
207
199
  const onBeforeInput = (e) => {
208
200
  userTypingRef.value = true;
209
- emit("beforeinput", e);
210
201
  props.onBeforeInput?.(e);
211
202
  };
212
203
  const onKeyDown = (event) => {
213
204
  const { key, shiftKey } = event;
214
205
  userTypingRef.value = true;
215
206
  shiftKeyRef.value = shiftKey;
216
- if (key === "Enter") {
207
+ if (key === __v_c_util_dist_KeyCode.KeyCodeStr.Enter) {
217
208
  if (!compositionRef.value) userTypingRef.value = false;
218
209
  flushInputValue(false);
219
- emit("pressEnter", event);
220
210
  props.onPressEnter?.(event);
221
211
  }
222
212
  if (props.keyboard === false) {
223
213
  props.onKeyDown?.(event);
224
- emit("keydown", event);
225
214
  return;
226
215
  }
227
216
  if (!compositionRef.value && [
@@ -234,12 +223,10 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
234
223
  event.preventDefault();
235
224
  }
236
225
  props.onKeyDown?.(event);
237
- emit("keydown", event);
238
226
  };
239
227
  const onKeyUp = (event) => {
240
228
  userTypingRef.value = false;
241
229
  shiftKeyRef.value = false;
242
- emit("keyup", event);
243
230
  props.onKeyUp?.(event);
244
231
  };
245
232
  (0, vue.watchEffect)((onCleanup) => {
@@ -256,12 +243,10 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
256
243
  if (props.changeOnBlur ?? true) flushInputValue(false);
257
244
  focus.value = false;
258
245
  userTypingRef.value = false;
259
- emit("blur", e);
260
246
  props.onBlur?.(e);
261
247
  };
262
248
  const onFocus = (e) => {
263
249
  focus.value = true;
264
- emit("focus", e);
265
250
  props.onFocus?.(e);
266
251
  };
267
252
  const onInternalMouseDown = (event) => {
@@ -269,7 +254,6 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
269
254
  inputRef.value.focus();
270
255
  event.preventDefault();
271
256
  }
272
- emit("mousedown", event);
273
257
  props.onMouseDown?.(event);
274
258
  };
275
259
  (0, vue.watch)([
@@ -370,32 +354,26 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
370
354
  "style": mergedStyle,
371
355
  "onMousedown": onInternalMouseDown,
372
356
  "onMouseup": (e) => {
373
- emit("mouseup", e);
374
357
  props.onMouseUp?.(e);
375
358
  },
376
359
  "onMouseleave": (e) => {
377
- emit("mouseleave", e);
378
360
  props.onMouseLeave?.(e);
379
361
  },
380
362
  "onMousemove": (e) => {
381
- emit("mousemove", e);
382
363
  props.onMouseMove?.(e);
383
364
  },
384
365
  "onMouseenter": (e) => {
385
- emit("mouseenter", e);
386
366
  props.onMouseEnter?.(e);
387
367
  },
388
368
  "onMouseout": (e) => {
389
- emit("mouseout", e);
390
369
  props.onMouseOut?.(e);
391
370
  },
392
371
  "onClick": (e) => {
393
- emit("click", e);
394
372
  props.onClick?.(e);
395
373
  }
396
374
  }, [
397
375
  mode === "spinner" && controls && downHandlerNode,
398
- prefixNode !== void 0 && (0, vue.createVNode)("div", {
376
+ !!prefixNode && (0, vue.createVNode)("div", {
399
377
  "class": (0, __v_c_util.clsx)(`${mergedPrefixCls}-prefix`, classNames?.prefix),
400
378
  "style": styles?.prefix
401
379
  }, [prefixNode]),
@@ -410,7 +388,7 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
410
388
  "class": (0, __v_c_util.clsx)(`${mergedPrefixCls}-input`, classNames?.input),
411
389
  "style": styles?.input,
412
390
  "value": inputValue.value,
413
- "onChange": onInternalInput,
391
+ "onInput": onInternalInput,
414
392
  "disabled": disabled,
415
393
  "readonly": readOnly,
416
394
  "onFocus": onFocus,
@@ -421,7 +399,7 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
421
399
  "onCompositionend": onCompositionEnd,
422
400
  "onBeforeinput": onBeforeInput
423
401
  }, inputAttrs), null),
424
- suffixNode !== void 0 && (0, vue.createVNode)("div", {
402
+ !!suffixNode && (0, vue.createVNode)("div", {
425
403
  "class": (0, __v_c_util.clsx)(`${mergedPrefixCls}-suffix`, classNames?.suffix),
426
404
  "style": styles?.suffix
427
405
  }, [suffixNode]),
@@ -667,27 +645,7 @@ var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slot
667
645
  }, defaults),
668
646
  name: "InputNumber",
669
647
  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
- ]
648
+ emits: ["update:value"]
691
649
  });
692
650
  var InputNumber_default = InputNumber;
693
651
  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([
@@ -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]),
@@ -663,26 +641,6 @@ var InputNumber_default = /* @__PURE__ */ defineComponent((props, { attrs, slots
663
641
  }, defaults),
664
642
  name: "InputNumber",
665
643
  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
- ]
644
+ emits: ["update:value"]
687
645
  });
688
646
  export { InputNumber_default as default };
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.1",
4
+ "version": "1.0.0",
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.1",
28
- "@v-c/util": "0.0.18",
29
- "@v-c/mini-decimal": "0.0.2"
27
+ "@v-c/mini-decimal": "^1.0.0",
28
+ "@v-c/util": "^1.0.1",
29
+ "@v-c/input": "^1.0.0"
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
  }