@sheinx/hooks 3.9.14-beta.8 → 3.9.14-beta.9
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-input-number.d.ts","sourceRoot":"","sources":["use-input-number.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAK3D,QAAA,MAAM,eAAe,UAAW,gBAAgB;;;;;;;;
|
|
1
|
+
{"version":3,"file":"use-input-number.d.ts","sourceRoot":"","sources":["use-input-number.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAK3D,QAAA,MAAM,eAAe,UAAW,gBAAgB;;;;;;;;CA6L/C,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -54,10 +54,12 @@ var useNumberFormat = function useNumberFormat(props) {
|
|
|
54
54
|
setInternalInputValue = _React$useState2[1];
|
|
55
55
|
var focusedRef = _react.default.useRef(false);
|
|
56
56
|
(0, _react.useEffect)(function () {
|
|
57
|
+
// 将外部值转为字符串后再比较,避免 number 5 vs string "5" 的类型不匹配误判
|
|
58
|
+
var stringValue = getStringValue(props.value);
|
|
57
59
|
// 聚焦编辑期间不同步外部值,避免 form 回填 defaultValue 覆盖用户输入
|
|
58
60
|
// 但当外部值被清空时(如 clearable 触发),即使聚焦也需要同步
|
|
59
|
-
if (
|
|
60
|
-
setInternalInputValue(
|
|
61
|
+
if (stringValue !== inernalInputValue && (!focusedRef.current || props.value == null || props.value === '')) {
|
|
62
|
+
setInternalInputValue(stringValue);
|
|
61
63
|
}
|
|
62
64
|
}, [props.value]);
|
|
63
65
|
var getNumberValue = function getNumberValue(value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-input-number.d.ts","sourceRoot":"","sources":["use-input-number.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAK3D,QAAA,MAAM,eAAe,UAAW,gBAAgB;;;;;;;;
|
|
1
|
+
{"version":3,"file":"use-input-number.d.ts","sourceRoot":"","sources":["use-input-number.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAK3D,QAAA,MAAM,eAAe,UAAW,gBAAgB;;;;;;;;CA6L/C,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -45,10 +45,12 @@ var useNumberFormat = function useNumberFormat(props) {
|
|
|
45
45
|
setInternalInputValue = _React$useState2[1];
|
|
46
46
|
var focusedRef = React.useRef(false);
|
|
47
47
|
useEffect(function () {
|
|
48
|
+
// 将外部值转为字符串后再比较,避免 number 5 vs string "5" 的类型不匹配误判
|
|
49
|
+
var stringValue = getStringValue(props.value);
|
|
48
50
|
// 聚焦编辑期间不同步外部值,避免 form 回填 defaultValue 覆盖用户输入
|
|
49
51
|
// 但当外部值被清空时(如 clearable 触发),即使聚焦也需要同步
|
|
50
|
-
if (
|
|
51
|
-
setInternalInputValue(
|
|
52
|
+
if (stringValue !== inernalInputValue && (!focusedRef.current || props.value == null || props.value === '')) {
|
|
53
|
+
setInternalInputValue(stringValue);
|
|
52
54
|
}
|
|
53
55
|
}, [props.value]);
|
|
54
56
|
var getNumberValue = function getNumberValue(value) {
|