@v-c/input-number 1.0.0 → 1.0.2

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.
@@ -134,9 +134,9 @@ var InputNumber_default = /* @__PURE__ */ defineComponent((props, { attrs, slots
134
134
  if (!updateValue.equals(decimalValue.value)) {
135
135
  setUncontrolledDecimalValue(updateValue);
136
136
  const outValue = updateValue.isEmpty() ? null : getDecimalValue(props.stringMode, updateValue);
137
+ emit("update:value", outValue);
137
138
  props.onChange?.(outValue);
138
139
  if (props.value === void 0) setInputValue(updateValue, userTyping);
139
- emit("update:value", outValue);
140
140
  }
141
141
  return updateValue;
142
142
  }
@@ -271,7 +271,7 @@ var InputNumber_default = /* @__PURE__ */ defineComponent((props, { attrs, slots
271
271
  return () => {
272
272
  const { prefixCls = defaults.prefixCls, classNames: classNames$1, styles, step = defaults.step, disabled, readOnly, controls = defaults.controls, mode = defaults.mode } = props;
273
273
  const mergedPrefixCls = prefixCls || defaults.prefixCls;
274
- const { class: className, style,...restAttrs } = attrs;
274
+ const { class: className, style, ...restAttrs } = attrs;
275
275
  const mergedClassName = props.className || className;
276
276
  const mergedStyle = {
277
277
  ...styles?.root,
@@ -419,7 +419,6 @@ var InputNumber_default = /* @__PURE__ */ defineComponent((props, { attrs, slots
419
419
  default: void 0
420
420
  },
421
421
  class: {
422
- type: null,
423
422
  required: false,
424
423
  default: void 0
425
424
  },
@@ -429,7 +428,6 @@ var InputNumber_default = /* @__PURE__ */ defineComponent((props, { attrs, slots
429
428
  default: void 0
430
429
  },
431
430
  style: {
432
- type: null,
433
431
  required: false,
434
432
  default: void 0
435
433
  },
@@ -444,27 +442,22 @@ var InputNumber_default = /* @__PURE__ */ defineComponent((props, { attrs, slots
444
442
  default: void 0
445
443
  },
446
444
  min: {
447
- type: null,
448
445
  required: false,
449
446
  default: void 0
450
447
  },
451
448
  max: {
452
- type: null,
453
449
  required: false,
454
450
  default: void 0
455
451
  },
456
452
  step: {
457
- type: null,
458
453
  required: false,
459
454
  default: void 0
460
455
  },
461
456
  defaultValue: {
462
- type: null,
463
457
  required: false,
464
458
  default: void 0
465
459
  },
466
460
  value: {
467
- type: null,
468
461
  required: false,
469
462
  default: void 0
470
463
  },
@@ -479,22 +472,18 @@ var InputNumber_default = /* @__PURE__ */ defineComponent((props, { attrs, slots
479
472
  default: void 0
480
473
  },
481
474
  prefix: {
482
- type: null,
483
475
  required: false,
484
476
  default: void 0
485
477
  },
486
478
  suffix: {
487
- type: null,
488
479
  required: false,
489
480
  default: void 0
490
481
  },
491
482
  upHandler: {
492
- type: null,
493
483
  required: false,
494
484
  default: void 0
495
485
  },
496
486
  downHandler: {
497
- type: null,
498
487
  required: false,
499
488
  default: void 0
500
489
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@v-c/input-number",
3
3
  "type": "module",
4
- "version": "1.0.0",
4
+ "version": "1.0.2",
5
5
  "description": "",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -10,7 +10,7 @@
10
10
  ".": {
11
11
  "types": "./dist/index.d.ts",
12
12
  "import": "./dist/index.js",
13
- "require": "./dist/index.cjs"
13
+ "default": "./dist/index.js"
14
14
  },
15
15
  "./dist/*": "./dist/*",
16
16
  "./package.json": "./package.json"
@@ -24,9 +24,9 @@
24
24
  "vue": "^3.0.0"
25
25
  },
26
26
  "dependencies": {
27
- "@v-c/mini-decimal": "^1.0.0",
28
- "@v-c/util": "^1.0.1",
29
- "@v-c/input": "^1.0.0"
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",
@@ -1,651 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- const require_rolldown_runtime = require("./_virtual/rolldown_runtime.cjs");
3
- const require_useCursor = require("./hooks/useCursor.cjs");
4
- const require_useFrame = require("./hooks/useFrame.cjs");
5
- const require_StepHandler = require("./StepHandler.cjs");
6
- const require_numberUtil = require("./utils/numberUtil.cjs");
7
- 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_KeyCode = require("@v-c/util/dist/KeyCode");
13
- let __v_c_util_dist_omit = require("@v-c/util/dist/omit");
14
- __v_c_util_dist_omit = require_rolldown_runtime.__toESM(__v_c_util_dist_omit);
15
- function _isSlot(s) {
16
- return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !(0, vue.isVNode)(s);
17
- }
18
- var defaults = {
19
- prefixCls: "vc-input-number",
20
- step: 1,
21
- controls: true,
22
- changeOnWheel: false,
23
- mode: "input",
24
- stringMode: false
25
- };
26
- function getDecimalValue(stringMode, decimalValue) {
27
- if (stringMode || decimalValue.isEmpty()) return decimalValue.toString();
28
- return decimalValue.toNumber();
29
- }
30
- function getDecimalIfValidate(value) {
31
- const decimal = (0, __v_c_mini_decimal.default)(value);
32
- return decimal.isInvalidate() ? null : decimal;
33
- }
34
- var InputNumber = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slots, expose, emit }) => {
35
- const focus = (0, vue.shallowRef)(false);
36
- const userTypingRef = (0, vue.shallowRef)(false);
37
- const compositionRef = (0, vue.shallowRef)(false);
38
- const shiftKeyRef = (0, vue.shallowRef)(false);
39
- const rootRef = (0, vue.shallowRef)();
40
- const inputRef = (0, vue.shallowRef)();
41
- expose({
42
- focus: (option) => {
43
- if (inputRef.value) (0, __v_c_util_dist_Dom_focus.triggerFocus)(inputRef.value, option);
44
- },
45
- blur: () => {
46
- inputRef.value?.blur?.();
47
- },
48
- nativeElement: (0, vue.computed)(() => rootRef.value || inputRef.value || null),
49
- input: inputRef
50
- });
51
- const decimalValue = (0, vue.shallowRef)((0, __v_c_mini_decimal.default)(props.value ?? props.defaultValue ?? ""));
52
- const setUncontrolledDecimalValue = (newDecimal) => {
53
- if (props.value === void 0) decimalValue.value = newDecimal;
54
- };
55
- const getPrecision = (numStr, userTyping) => {
56
- if (userTyping) return;
57
- if (props.precision !== void 0 && props.precision >= 0) return props.precision;
58
- return Math.max((0, __v_c_mini_decimal.getNumberPrecision)(numStr), (0, __v_c_mini_decimal.getNumberPrecision)(props.step ?? 1));
59
- };
60
- const mergedParser = (num) => {
61
- const numStr = String(num);
62
- if (props.parser) return props.parser(numStr);
63
- let parsedStr = numStr;
64
- if (props.decimalSeparator) parsedStr = parsedStr.replace(props.decimalSeparator, ".");
65
- return parsedStr.replace(/[^\w.-]+/g, "");
66
- };
67
- const inputValue = (0, vue.shallowRef)("");
68
- const inputValueRef = (0, vue.shallowRef)("");
69
- const mergedFormatter = (number, userTyping) => {
70
- if (props.formatter) return props.formatter(number, {
71
- userTyping,
72
- input: String(inputValueRef.value)
73
- });
74
- let str = typeof number === "number" ? (0, __v_c_mini_decimal.num2str)(number) : number;
75
- if (!userTyping) {
76
- const mergedPrecision = getPrecision(str, userTyping);
77
- if ((0, __v_c_mini_decimal.validateNumber)(str) && (props.decimalSeparator || mergedPrecision !== void 0 && mergedPrecision >= 0)) {
78
- const separatorStr = props.decimalSeparator || ".";
79
- str = (0, __v_c_mini_decimal.toFixed)(str, separatorStr, mergedPrecision);
80
- }
81
- }
82
- return str;
83
- };
84
- const syncInputValue = () => {
85
- const initValue = props.defaultValue ?? props.value;
86
- if (decimalValue.value.isInvalidate() && ["string", "number"].includes(typeof initValue)) inputValue.value = Number.isNaN(initValue) ? "" : initValue;
87
- else inputValue.value = mergedFormatter(decimalValue.value.toString(), false);
88
- inputValueRef.value = inputValue.value;
89
- };
90
- syncInputValue();
91
- (0, vue.watch)(inputValue, (val) => {
92
- inputValueRef.value = val;
93
- });
94
- const setInputValue = (newValue, userTyping) => {
95
- inputValue.value = mergedFormatter(newValue.isInvalidate() ? newValue.toString(false) : newValue.toString(!userTyping), userTyping);
96
- };
97
- const maxDecimal = (0, vue.computed)(() => props.max !== void 0 ? getDecimalIfValidate(props.max) : null);
98
- const minDecimal = (0, vue.computed)(() => props.min !== void 0 ? getDecimalIfValidate(props.min) : null);
99
- const upDisabled = (0, vue.computed)(() => {
100
- if (!maxDecimal.value || !decimalValue.value || decimalValue.value.isInvalidate()) return false;
101
- return maxDecimal.value.lessEquals(decimalValue.value);
102
- });
103
- const downDisabled = (0, vue.computed)(() => {
104
- if (!minDecimal.value || !decimalValue.value || decimalValue.value.isInvalidate()) return false;
105
- return decimalValue.value.lessEquals(minDecimal.value);
106
- });
107
- const recordCursorRef = (0, vue.shallowRef)(() => {});
108
- const restoreCursorRef = (0, vue.shallowRef)(() => {});
109
- (0, vue.watchEffect)(() => {
110
- if (inputRef.value) {
111
- const [record, restore] = require_useCursor.default(inputRef.value, focus.value);
112
- recordCursorRef.value = record;
113
- restoreCursorRef.value = restore;
114
- }
115
- });
116
- const recordCursor = () => recordCursorRef.value?.();
117
- const restoreCursor = () => restoreCursorRef.value?.();
118
- const getRangeValue = (target) => {
119
- if (maxDecimal.value && !target.lessEquals(maxDecimal.value)) return maxDecimal.value;
120
- if (minDecimal.value && !minDecimal.value.lessEquals(target)) return minDecimal.value;
121
- return null;
122
- };
123
- const isInRange = (target) => !getRangeValue(target);
124
- const triggerValueUpdate = (newValue, userTyping) => {
125
- let updateValue = newValue;
126
- let isRangeValidate = isInRange(updateValue) || updateValue.isEmpty();
127
- if (!updateValue.isEmpty() && !userTyping) {
128
- updateValue = getRangeValue(updateValue) || updateValue;
129
- isRangeValidate = true;
130
- }
131
- if (!props.readOnly && !props.disabled && isRangeValidate) {
132
- const numStr = updateValue.toString();
133
- const mergedPrecision = getPrecision(numStr, userTyping);
134
- if (mergedPrecision !== void 0 && mergedPrecision >= 0) {
135
- updateValue = (0, __v_c_mini_decimal.default)((0, __v_c_mini_decimal.toFixed)(numStr, ".", mergedPrecision));
136
- if (!isInRange(updateValue)) updateValue = (0, __v_c_mini_decimal.default)((0, __v_c_mini_decimal.toFixed)(numStr, ".", mergedPrecision, true));
137
- }
138
- if (!updateValue.equals(decimalValue.value)) {
139
- setUncontrolledDecimalValue(updateValue);
140
- const outValue = updateValue.isEmpty() ? null : getDecimalValue(props.stringMode, updateValue);
141
- props.onChange?.(outValue);
142
- if (props.value === void 0) setInputValue(updateValue, userTyping);
143
- emit("update:value", outValue);
144
- }
145
- return updateValue;
146
- }
147
- return decimalValue.value;
148
- };
149
- const onNextPromise = require_useFrame.default();
150
- const collectInputValue = (inputStr) => {
151
- recordCursor();
152
- inputValueRef.value = inputStr;
153
- inputValue.value = inputStr;
154
- if (!compositionRef.value) {
155
- const finalDecimal = (0, __v_c_mini_decimal.default)(mergedParser(inputStr));
156
- if (!finalDecimal.isNaN()) triggerValueUpdate(finalDecimal, true);
157
- }
158
- props.onInput?.(inputStr);
159
- onNextPromise(() => {
160
- let nextInputStr = inputStr;
161
- if (!props.parser) nextInputStr = inputStr.replace(/。/g, ".");
162
- if (nextInputStr !== inputStr) collectInputValue(nextInputStr);
163
- });
164
- };
165
- const onCompositionStart = (e) => {
166
- compositionRef.value = true;
167
- props.onCompositionStart?.(e);
168
- };
169
- const onCompositionEnd = (e) => {
170
- compositionRef.value = false;
171
- props.onCompositionEnd?.(e);
172
- if (inputRef.value) collectInputValue(inputRef.value.value);
173
- };
174
- const onInternalInput = (e) => {
175
- collectInputValue(e.target.value);
176
- };
177
- const onInternalStep = (up, emitter) => {
178
- if (up && upDisabled.value || !up && downDisabled.value) return;
179
- userTypingRef.value = false;
180
- let stepDecimal = (0, __v_c_mini_decimal.default)(shiftKeyRef.value ? require_numberUtil.getDecupleSteps(props.step ?? 1) : props.step ?? 1);
181
- if (!up) stepDecimal = stepDecimal.negate();
182
- const updatedValue = triggerValueUpdate((decimalValue.value || (0, __v_c_mini_decimal.default)(0)).add(stepDecimal.toString()), false);
183
- const outValue = getDecimalValue(props.stringMode, updatedValue);
184
- props.onStep?.(outValue, {
185
- offset: shiftKeyRef.value ? require_numberUtil.getDecupleSteps(props.step ?? 1) : props.step ?? 1,
186
- type: up ? "up" : "down",
187
- emitter
188
- });
189
- inputRef.value?.focus();
190
- };
191
- const flushInputValue = (userTyping) => {
192
- const parsedValue = (0, __v_c_mini_decimal.default)(mergedParser(inputValue.value));
193
- let formatValue;
194
- if (!parsedValue.isNaN()) formatValue = triggerValueUpdate(parsedValue, userTyping);
195
- else formatValue = triggerValueUpdate(decimalValue.value, userTyping);
196
- if (props.value !== void 0) setInputValue(decimalValue.value, false);
197
- else if (!formatValue.isNaN()) setInputValue(formatValue, false);
198
- };
199
- const onBeforeInput = (e) => {
200
- userTypingRef.value = true;
201
- props.onBeforeInput?.(e);
202
- };
203
- const onKeyDown = (event) => {
204
- const { key, shiftKey } = event;
205
- userTypingRef.value = true;
206
- shiftKeyRef.value = shiftKey;
207
- if (key === __v_c_util_dist_KeyCode.KeyCodeStr.Enter) {
208
- if (!compositionRef.value) userTypingRef.value = false;
209
- flushInputValue(false);
210
- props.onPressEnter?.(event);
211
- }
212
- if (props.keyboard === false) {
213
- props.onKeyDown?.(event);
214
- return;
215
- }
216
- if (!compositionRef.value && [
217
- "Up",
218
- "ArrowUp",
219
- "Down",
220
- "ArrowDown"
221
- ].includes(key)) {
222
- onInternalStep(key === "Up" || key === "ArrowUp", "keyboard");
223
- event.preventDefault();
224
- }
225
- props.onKeyDown?.(event);
226
- };
227
- const onKeyUp = (event) => {
228
- userTypingRef.value = false;
229
- shiftKeyRef.value = false;
230
- props.onKeyUp?.(event);
231
- };
232
- (0, vue.watchEffect)((onCleanup) => {
233
- if (props.changeOnWheel && focus.value && inputRef.value) {
234
- const onWheel = (event) => {
235
- onInternalStep(event.deltaY < 0, "wheel");
236
- event.preventDefault();
237
- };
238
- inputRef.value.addEventListener("wheel", onWheel, { passive: false });
239
- onCleanup(() => inputRef.value?.removeEventListener("wheel", onWheel));
240
- }
241
- });
242
- const onBlur = (e) => {
243
- if (props.changeOnBlur ?? true) flushInputValue(false);
244
- focus.value = false;
245
- userTypingRef.value = false;
246
- props.onBlur?.(e);
247
- };
248
- const onFocus = (e) => {
249
- focus.value = true;
250
- props.onFocus?.(e);
251
- };
252
- const onInternalMouseDown = (event) => {
253
- if (inputRef.value && event.target !== inputRef.value) {
254
- inputRef.value.focus();
255
- event.preventDefault();
256
- }
257
- props.onMouseDown?.(event);
258
- };
259
- (0, vue.watch)([
260
- () => props.precision,
261
- () => props.formatter,
262
- () => props.decimalSeparator
263
- ], () => {
264
- if (!decimalValue.value.isInvalidate()) setInputValue(decimalValue.value, false);
265
- });
266
- (0, vue.watch)(() => props.value, (newVal) => {
267
- const newValue = (0, __v_c_mini_decimal.default)(newVal ?? "");
268
- decimalValue.value = newValue;
269
- const currentParsedValue = (0, __v_c_mini_decimal.default)(mergedParser(inputValue.value));
270
- if (!newValue.equals(currentParsedValue) || !userTypingRef.value || props.formatter) setInputValue(newValue, userTypingRef.value);
271
- });
272
- (0, vue.watch)(() => inputValue.value, () => {
273
- if (props.formatter) restoreCursor();
274
- });
275
- return () => {
276
- const { prefixCls = defaults.prefixCls, classNames, styles, step = defaults.step, disabled, readOnly, controls = defaults.controls, mode = defaults.mode } = props;
277
- const mergedPrefixCls = prefixCls || defaults.prefixCls;
278
- const { class: className, style,...restAttrs } = attrs;
279
- const mergedClassName = props.className || className;
280
- const mergedStyle = {
281
- ...styles?.root,
282
- ...props.style,
283
- ...style
284
- };
285
- const prefixNode = slots.prefix?.() ?? props.prefix;
286
- const suffixNode = slots.suffix?.() ?? props.suffix;
287
- const upNode = slots.upHandler?.() ?? props.upHandler;
288
- const downNode = slots.downHandler?.() ?? props.downHandler;
289
- const upHandlerNode = (0, vue.createVNode)(require_StepHandler.default, {
290
- "prefixCls": mergedPrefixCls,
291
- "action": "up",
292
- "disabled": upDisabled.value,
293
- "onStep": onInternalStep,
294
- "className": classNames?.action,
295
- "style": styles?.action
296
- }, _isSlot(upNode) ? upNode : { default: () => [upNode] });
297
- const downHandlerNode = (0, vue.createVNode)(require_StepHandler.default, {
298
- "prefixCls": mergedPrefixCls,
299
- "action": "down",
300
- "disabled": downDisabled.value,
301
- "onStep": onInternalStep,
302
- "className": classNames?.action,
303
- "style": styles?.action
304
- }, _isSlot(downNode) ? downNode : { default: () => [downNode] });
305
- const inputAttrs = (0, __v_c_util_dist_omit.default)({ ...restAttrs }, [
306
- "prefixCls",
307
- "classNames",
308
- "styles",
309
- "defaultValue",
310
- "value",
311
- "prefix",
312
- "suffix",
313
- "upHandler",
314
- "downHandler",
315
- "keyboard",
316
- "changeOnWheel",
317
- "controls",
318
- "mode",
319
- "parser",
320
- "formatter",
321
- "precision",
322
- "decimalSeparator",
323
- "onChange",
324
- "onInput",
325
- "onPressEnter",
326
- "onStep",
327
- "changeOnBlur",
328
- "class",
329
- "style",
330
- "onMouseDown",
331
- "onClick",
332
- "onMouseUp",
333
- "onMouseLeave",
334
- "onMouseMove",
335
- "onMouseEnter",
336
- "onMouseOut",
337
- "onFocus",
338
- "onBlur",
339
- "onKeyDown",
340
- "onKeyUp",
341
- "onCompositionStart",
342
- "onCompositionEnd",
343
- "onBeforeInput"
344
- ]);
345
- return (0, vue.createVNode)("div", {
346
- "ref": rootRef,
347
- "class": (0, __v_c_util.clsx)(mergedPrefixCls, `${mergedPrefixCls}-mode-${mode}`, mergedClassName, classNames?.root, {
348
- [`${mergedPrefixCls}-focused`]: focus.value,
349
- [`${mergedPrefixCls}-disabled`]: disabled,
350
- [`${mergedPrefixCls}-readonly`]: readOnly,
351
- [`${mergedPrefixCls}-not-a-number`]: decimalValue.value.isNaN(),
352
- [`${mergedPrefixCls}-out-of-range`]: !decimalValue.value.isInvalidate() && !isInRange(decimalValue.value)
353
- }),
354
- "style": mergedStyle,
355
- "onMousedown": onInternalMouseDown,
356
- "onMouseup": (e) => {
357
- props.onMouseUp?.(e);
358
- },
359
- "onMouseleave": (e) => {
360
- props.onMouseLeave?.(e);
361
- },
362
- "onMousemove": (e) => {
363
- props.onMouseMove?.(e);
364
- },
365
- "onMouseenter": (e) => {
366
- props.onMouseEnter?.(e);
367
- },
368
- "onMouseout": (e) => {
369
- props.onMouseOut?.(e);
370
- },
371
- "onClick": (e) => {
372
- props.onClick?.(e);
373
- }
374
- }, [
375
- mode === "spinner" && controls && downHandlerNode,
376
- !!prefixNode && (0, vue.createVNode)("div", {
377
- "class": (0, __v_c_util.clsx)(`${mergedPrefixCls}-prefix`, classNames?.prefix),
378
- "style": styles?.prefix
379
- }, [prefixNode]),
380
- (0, vue.createVNode)("input", (0, vue.mergeProps)({
381
- "autocomplete": "off",
382
- "role": "spinbutton",
383
- "aria-valuemin": props.min,
384
- "aria-valuemax": props.max,
385
- "aria-valuenow": decimalValue.value.isInvalidate() ? null : decimalValue.value.toString(),
386
- "step": step,
387
- "ref": inputRef,
388
- "class": (0, __v_c_util.clsx)(`${mergedPrefixCls}-input`, classNames?.input),
389
- "style": styles?.input,
390
- "value": inputValue.value,
391
- "onInput": onInternalInput,
392
- "disabled": disabled,
393
- "readonly": readOnly,
394
- "onFocus": onFocus,
395
- "onBlur": onBlur,
396
- "onKeydown": onKeyDown,
397
- "onKeyup": onKeyUp,
398
- "onCompositionstart": onCompositionStart,
399
- "onCompositionend": onCompositionEnd,
400
- "onBeforeinput": onBeforeInput
401
- }, inputAttrs), null),
402
- !!suffixNode && (0, vue.createVNode)("div", {
403
- "class": (0, __v_c_util.clsx)(`${mergedPrefixCls}-suffix`, classNames?.suffix),
404
- "style": styles?.suffix
405
- }, [suffixNode]),
406
- mode === "spinner" && controls && upHandlerNode,
407
- mode === "input" && controls && (0, vue.createVNode)("div", {
408
- "class": (0, __v_c_util.clsx)(`${mergedPrefixCls}-actions`, classNames?.actions),
409
- "style": styles?.actions
410
- }, [upHandlerNode, downHandlerNode])
411
- ]);
412
- };
413
- }, {
414
- props: /* @__PURE__ */ (0, vue.mergeDefaults)({
415
- mode: {
416
- type: String,
417
- required: false,
418
- default: void 0
419
- },
420
- prefixCls: {
421
- type: String,
422
- required: false,
423
- default: void 0
424
- },
425
- class: {
426
- type: null,
427
- required: false,
428
- default: void 0
429
- },
430
- className: {
431
- type: String,
432
- required: false,
433
- default: void 0
434
- },
435
- style: {
436
- type: null,
437
- required: false,
438
- default: void 0
439
- },
440
- classNames: {
441
- type: Object,
442
- required: false,
443
- default: void 0
444
- },
445
- styles: {
446
- type: Object,
447
- required: false,
448
- default: void 0
449
- },
450
- min: {
451
- type: null,
452
- required: false,
453
- default: void 0
454
- },
455
- max: {
456
- type: null,
457
- required: false,
458
- default: void 0
459
- },
460
- step: {
461
- type: null,
462
- required: false,
463
- default: void 0
464
- },
465
- defaultValue: {
466
- type: null,
467
- required: false,
468
- default: void 0
469
- },
470
- value: {
471
- type: null,
472
- required: false,
473
- default: void 0
474
- },
475
- disabled: {
476
- type: Boolean,
477
- required: false,
478
- default: void 0
479
- },
480
- readOnly: {
481
- type: Boolean,
482
- required: false,
483
- default: void 0
484
- },
485
- prefix: {
486
- type: null,
487
- required: false,
488
- default: void 0
489
- },
490
- suffix: {
491
- type: null,
492
- required: false,
493
- default: void 0
494
- },
495
- upHandler: {
496
- type: null,
497
- required: false,
498
- default: void 0
499
- },
500
- downHandler: {
501
- type: null,
502
- required: false,
503
- default: void 0
504
- },
505
- keyboard: {
506
- type: Boolean,
507
- required: false,
508
- default: void 0
509
- },
510
- changeOnWheel: {
511
- type: Boolean,
512
- required: false,
513
- default: void 0
514
- },
515
- controls: {
516
- type: Boolean,
517
- required: false,
518
- default: void 0
519
- },
520
- parser: {
521
- type: Function,
522
- required: false,
523
- default: void 0
524
- },
525
- formatter: {
526
- type: Function,
527
- required: false,
528
- default: void 0
529
- },
530
- precision: {
531
- type: Number,
532
- required: false,
533
- default: void 0
534
- },
535
- decimalSeparator: {
536
- type: String,
537
- required: false,
538
- default: void 0
539
- },
540
- onInput: {
541
- type: Function,
542
- required: false,
543
- default: void 0
544
- },
545
- onChange: {
546
- type: Function,
547
- required: false,
548
- default: void 0
549
- },
550
- onPressEnter: {
551
- type: Function,
552
- required: false,
553
- default: void 0
554
- },
555
- onStep: {
556
- type: Function,
557
- required: false,
558
- default: void 0
559
- },
560
- changeOnBlur: {
561
- type: Boolean,
562
- required: false,
563
- default: void 0
564
- },
565
- tabIndex: {
566
- type: Number,
567
- required: false,
568
- default: void 0
569
- },
570
- onMouseDown: {
571
- type: Function,
572
- required: false,
573
- default: void 0
574
- },
575
- onClick: {
576
- type: Function,
577
- required: false,
578
- default: void 0
579
- },
580
- onMouseUp: {
581
- type: Function,
582
- required: false,
583
- default: void 0
584
- },
585
- onMouseLeave: {
586
- type: Function,
587
- required: false,
588
- default: void 0
589
- },
590
- onMouseMove: {
591
- type: Function,
592
- required: false,
593
- default: void 0
594
- },
595
- onMouseEnter: {
596
- type: Function,
597
- required: false,
598
- default: void 0
599
- },
600
- onMouseOut: {
601
- type: Function,
602
- required: false,
603
- default: void 0
604
- },
605
- onFocus: {
606
- type: Function,
607
- required: false,
608
- default: void 0
609
- },
610
- onBlur: {
611
- type: Function,
612
- required: false,
613
- default: void 0
614
- },
615
- onKeyDown: {
616
- type: Function,
617
- required: false,
618
- default: void 0
619
- },
620
- onKeyUp: {
621
- type: Function,
622
- required: false,
623
- default: void 0
624
- },
625
- onCompositionStart: {
626
- type: Function,
627
- required: false,
628
- default: void 0
629
- },
630
- onCompositionEnd: {
631
- type: Function,
632
- required: false,
633
- default: void 0
634
- },
635
- onBeforeInput: {
636
- type: Function,
637
- required: false,
638
- default: void 0
639
- },
640
- stringMode: {
641
- type: Boolean,
642
- required: false,
643
- default: void 0
644
- }
645
- }, defaults),
646
- name: "InputNumber",
647
- inheritAttrs: false,
648
- emits: ["update:value"]
649
- });
650
- var InputNumber_default = InputNumber;
651
- exports.default = InputNumber_default;
@@ -1,78 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- const require_rolldown_runtime = require("./_virtual/rolldown_runtime.cjs");
3
- 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");
8
- var STEP_INTERVAL = 200;
9
- var STEP_DELAY = 600;
10
- var StepHandler_default = /* @__PURE__ */ (0, vue.defineComponent)({
11
- name: "StepHandler",
12
- props: {
13
- prefixCls: {
14
- type: String,
15
- required: true
16
- },
17
- action: {
18
- type: String,
19
- required: true
20
- },
21
- disabled: {
22
- type: Boolean,
23
- default: false
24
- },
25
- className: String,
26
- style: Object,
27
- onStep: {
28
- type: Function,
29
- required: true
30
- }
31
- },
32
- slots: Object,
33
- emits: ["step"],
34
- setup(props, { slots, emit }) {
35
- const stepTimeoutRef = (0, vue.ref)(null);
36
- const frameIds = (0, vue.ref)([]);
37
- const onStopStep = () => {
38
- clearTimeout(stepTimeoutRef.value);
39
- };
40
- const onStepMouseDown = (e, up) => {
41
- e.preventDefault();
42
- onStopStep();
43
- emit("step", up, "handler");
44
- function loopStep() {
45
- emit("step", up, "handler");
46
- stepTimeoutRef.value = setTimeout(loopStep, STEP_INTERVAL);
47
- }
48
- stepTimeoutRef.value = setTimeout(loopStep, STEP_DELAY);
49
- };
50
- (0, vue.onUnmounted)(() => {
51
- onStopStep();
52
- frameIds.value.forEach((id) => __v_c_util_dist_raf.default.cancel(id));
53
- });
54
- return () => {
55
- const { prefixCls, action, disabled, className, style } = props;
56
- const isUpAction = action === "up";
57
- 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
- return (0, vue.createVNode)("span", {
62
- "unselectable": "on",
63
- "role": "button",
64
- "onMouseup": safeOnStopStep,
65
- "onMouseleave": safeOnStopStep,
66
- "onMousedown": (e) => onStepMouseDown(e, isUpAction),
67
- "aria-label": isUpAction ? "Increase Value" : "Decrease Value",
68
- "aria-disabled": disabled,
69
- "class": mergedClassName,
70
- "style": style
71
- }, [children.length > 0 ? children : (0, vue.createVNode)("span", {
72
- "unselectable": "on",
73
- "class": `${prefixCls}-action-${action}-inner`
74
- }, null)]);
75
- };
76
- }
77
- });
78
- exports.default = StepHandler_default;
@@ -1,21 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __copyProps = (to, from, except, desc) => {
8
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
9
- key = keys[i];
10
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
11
- get: ((k) => from[k]).bind(null, key),
12
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
13
- });
14
- }
15
- return to;
16
- };
17
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
18
- value: mod,
19
- enumerable: true
20
- }) : target, mod));
21
- exports.__toESM = __toESM;
@@ -1,39 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
3
- 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);
6
- function useCursor(input, focused) {
7
- const selectionRef = (0, vue.ref)(null);
8
- function recordCursor() {
9
- try {
10
- const { selectionStart: start, selectionEnd: end, value } = input;
11
- selectionRef.value = {
12
- start,
13
- end,
14
- value,
15
- beforeTxt: value.substring(0, start),
16
- afterTxt: value.substring(end)
17
- };
18
- } catch (e) {}
19
- }
20
- function restoreCursor() {
21
- if (input && selectionRef.value && focused) try {
22
- const { value } = input;
23
- const { beforeTxt, afterTxt, start } = selectionRef.value;
24
- let startPos = value.length;
25
- if (beforeTxt && value.startsWith(beforeTxt)) startPos = beforeTxt.length;
26
- else if (afterTxt && value.endsWith(afterTxt)) startPos = value.length - selectionRef.value.afterTxt.length;
27
- else {
28
- const beforeLastChar = beforeTxt[start - 1];
29
- const newIndex = value.indexOf(beforeLastChar, start - 1);
30
- if (newIndex !== -1) startPos = newIndex + 1;
31
- }
32
- input.setSelectionRange(startPos, startPos);
33
- } catch (e) {
34
- (0, __v_c_util_dist_warning.default)(false, `Something warning of cursor restore. Please fire issue about this: ${e.message}`);
35
- }
36
- }
37
- return [recordCursor, restoreCursor];
38
- }
39
- exports.default = useCursor;
@@ -1,19 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
3
- 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);
6
- var useFrame_default = () => {
7
- const idRef = (0, vue.ref)(0);
8
- const cleanUp = () => {
9
- __v_c_util_dist_raf.default.cancel(idRef.value);
10
- };
11
- (0, vue.onUnmounted)(cleanUp);
12
- return (callback) => {
13
- cleanUp();
14
- idRef.value = (0, __v_c_util_dist_raf.default)(() => {
15
- callback();
16
- });
17
- };
18
- };
19
- exports.default = useFrame_default;
package/dist/index.cjs DELETED
@@ -1,4 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- const require_InputNumber = require("./InputNumber.cjs");
3
- var src_default = require_InputNumber.default;
4
- exports.default = src_default;
@@ -1,8 +0,0 @@
1
- const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
2
- let __v_c_mini_decimal = require("@v-c/mini-decimal");
3
- 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
- if (!stepStr.includes(".")) return `${step}0`;
6
- return (0, __v_c_mini_decimal.trimNumber)(stepStr.replace(/(\d)\.(\d)/g, "$1$2.")).fullStr;
7
- }
8
- exports.getDecupleSteps = getDecupleSteps;