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