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