rc-input-number
Advanced tools
Comparing version 7.1.4 to 7.2.0
@@ -21,3 +21,6 @@ import * as React from 'react'; | ||
/** Transform `value` to display value show in input */ | ||
formatter?: (value: T | undefined) => string; | ||
formatter?: (value: T | undefined, info: { | ||
userTyping: boolean; | ||
input: string; | ||
}) => string; | ||
/** Syntactic sugar of `formatter`. Config precision of display. */ | ||
@@ -24,0 +27,0 @@ precision?: number; |
@@ -6,2 +6,3 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; | ||
var _excluded = ["prefixCls", "className", "style", "min", "max", "step", "defaultValue", "value", "disabled", "readOnly", "upHandler", "downHandler", "keyboard", "stringMode", "parser", "formatter", "precision", "decimalSeparator", "onChange", "onInput", "onPressEnter", "onStep"]; | ||
import * as React from 'react'; | ||
@@ -60,3 +61,3 @@ import classNames from 'classnames'; | ||
onStep = props.onStep, | ||
inputProps = _objectWithoutProperties(props, ["prefixCls", "className", "style", "min", "max", "step", "defaultValue", "value", "disabled", "readOnly", "upHandler", "downHandler", "keyboard", "stringMode", "parser", "formatter", "precision", "decimalSeparator", "onChange", "onInput", "onPressEnter", "onStep"]); | ||
inputProps = _objectWithoutProperties(props, _excluded); | ||
@@ -130,5 +131,9 @@ var inputClassName = "".concat(prefixCls, "-input"); | ||
var inputValueRef = React.useRef(''); | ||
var mergedFormatter = React.useCallback(function (number, userTyping) { | ||
if (formatter) { | ||
return formatter(number); | ||
return formatter(number, { | ||
userTyping: userTyping, | ||
input: String(inputValueRef.current) | ||
}); | ||
} | ||
@@ -172,4 +177,5 @@ | ||
inputValue = _React$useState6[0], | ||
setInternalInputValue = _React$useState6[1]; // Should always be string | ||
setInternalInputValue = _React$useState6[1]; | ||
inputValueRef.current = inputValue; // Should always be string | ||
@@ -426,3 +432,3 @@ function setInputValue(newValue, userTyping) { | ||
// Update value as effect | ||
setInputValue(newValue, false); | ||
setInputValue(newValue, userTypingRef.current); | ||
} | ||
@@ -429,0 +435,0 @@ }, [value]); // ============================ Cursor ============================ |
@@ -16,2 +16,4 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
this.origin = ''; | ||
this.number = void 0; | ||
this.empty = void 0; | ||
@@ -108,2 +110,3 @@ if (!value && value !== 0 || !String(value).trim()) { | ||
export var BigIntDecimal = /*#__PURE__*/function () { | ||
/** BigInt will convert `0009` to `9`. We need record the len of decimal */ | ||
function BigIntDecimal(value) { | ||
@@ -113,2 +116,8 @@ _classCallCheck(this, BigIntDecimal); | ||
this.origin = ''; | ||
this.negative = void 0; | ||
this.integer = void 0; | ||
this.decimal = void 0; | ||
this.decimalLen = void 0; | ||
this.empty = void 0; | ||
this.nan = void 0; | ||
@@ -115,0 +124,0 @@ if (!value && value !== 0 || !String(value).trim()) { |
@@ -21,3 +21,6 @@ import * as React from 'react'; | ||
/** Transform `value` to display value show in input */ | ||
formatter?: (value: T | undefined) => string; | ||
formatter?: (value: T | undefined, info: { | ||
userTyping: boolean; | ||
input: string; | ||
}) => string; | ||
/** Syntactic sugar of `formatter`. Config precision of display. */ | ||
@@ -24,0 +27,0 @@ precision?: number; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -40,2 +40,4 @@ value: true | ||
var _excluded = ["prefixCls", "className", "style", "min", "max", "step", "defaultValue", "value", "disabled", "readOnly", "upHandler", "downHandler", "keyboard", "stringMode", "parser", "formatter", "precision", "decimalSeparator", "onChange", "onInput", "onPressEnter", "onStep"]; | ||
/** | ||
@@ -84,3 +86,3 @@ * We support `stringMode` which need handle correct type when user call in onChange | ||
onStep = props.onStep, | ||
inputProps = (0, _objectWithoutProperties2.default)(props, ["prefixCls", "className", "style", "min", "max", "step", "defaultValue", "value", "disabled", "readOnly", "upHandler", "downHandler", "keyboard", "stringMode", "parser", "formatter", "precision", "decimalSeparator", "onChange", "onInput", "onPressEnter", "onStep"]); | ||
inputProps = (0, _objectWithoutProperties2.default)(props, _excluded); | ||
var inputClassName = "".concat(prefixCls, "-input"); | ||
@@ -153,5 +155,9 @@ var inputRef = React.useRef(null); | ||
var inputValueRef = React.useRef(''); | ||
var mergedFormatter = React.useCallback(function (number, userTyping) { | ||
if (formatter) { | ||
return formatter(number); | ||
return formatter(number, { | ||
userTyping: userTyping, | ||
input: String(inputValueRef.current) | ||
}); | ||
} | ||
@@ -195,4 +201,5 @@ | ||
inputValue = _React$useState6[0], | ||
setInternalInputValue = _React$useState6[1]; // Should always be string | ||
setInternalInputValue = _React$useState6[1]; | ||
inputValueRef.current = inputValue; // Should always be string | ||
@@ -449,3 +456,3 @@ function setInputValue(newValue, userTyping) { | ||
// Update value as effect | ||
setInputValue(newValue, false); | ||
setInputValue(newValue, userTypingRef.current); | ||
} | ||
@@ -452,0 +459,0 @@ }, [value]); // ============================ Cursor ============================ |
@@ -29,2 +29,4 @@ "use strict"; | ||
this.origin = ''; | ||
this.number = void 0; | ||
this.empty = void 0; | ||
@@ -123,5 +125,12 @@ if (!value && value !== 0 || !String(value).trim()) { | ||
var BigIntDecimal = /*#__PURE__*/function () { | ||
/** BigInt will convert `0009` to `9`. We need record the len of decimal */ | ||
function BigIntDecimal(value) { | ||
(0, _classCallCheck2.default)(this, BigIntDecimal); | ||
this.origin = ''; | ||
this.negative = void 0; | ||
this.integer = void 0; | ||
this.decimal = void 0; | ||
this.decimalLen = void 0; | ||
this.empty = void 0; | ||
this.nan = void 0; | ||
@@ -128,0 +137,0 @@ if (!value && value !== 0 || !String(value).trim()) { |
{ | ||
"name": "rc-input-number", | ||
"version": "7.1.4", | ||
"version": "7.2.0", | ||
"description": "React input-number component", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
95667
2255