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