- 新增家庭共享订阅管理 - 新增用户邀请统计 - 新增签名和订阅模式设置表单 - 更新 API 服务层和国际化文件 - UI 组件优化(enhanced-input、pro-table)
This commit is contained in:
@@ -30,7 +30,8 @@ export function EnhancedInput<T = string>({
|
||||
...props
|
||||
}: EnhancedInputProps<T>) {
|
||||
const getProcessedValue = (inputValue: unknown) => {
|
||||
if (inputValue === "" || inputValue === 0 || inputValue === "0") return "";
|
||||
if (inputValue === "" || inputValue === undefined || inputValue === null)
|
||||
return "";
|
||||
const newValue = String(inputValue ?? "");
|
||||
return formatInput ? formatInput(inputValue as T) : newValue;
|
||||
};
|
||||
@@ -69,13 +70,6 @@ export function EnhancedInput<T = string>({
|
||||
let inputValue = e.target.value;
|
||||
|
||||
if (props.type === "number") {
|
||||
if (inputValue === "0") {
|
||||
setValue("");
|
||||
setInternalValue(0);
|
||||
onValueChange?.(processValue(0));
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
/^-?\d*\.?\d*$/.test(inputValue) ||
|
||||
inputValue === "-" ||
|
||||
@@ -99,7 +93,7 @@ export function EnhancedInput<T = string>({
|
||||
} else {
|
||||
setInternalValue(inputValue);
|
||||
}
|
||||
setValue(inputValue === "0" ? "" : inputValue);
|
||||
setValue(inputValue);
|
||||
}
|
||||
} else {
|
||||
setValue(inputValue);
|
||||
@@ -111,19 +105,15 @@ export function EnhancedInput<T = string>({
|
||||
};
|
||||
|
||||
const handleBlur = () => {
|
||||
if (props.type === "number" && value) {
|
||||
if (value === "-" || value === ".") {
|
||||
setValue("");
|
||||
setInternalValue("");
|
||||
onValueBlur?.("" as T);
|
||||
return;
|
||||
}
|
||||
|
||||
if (value === "0") {
|
||||
setValue("");
|
||||
onValueBlur?.(processValue(0));
|
||||
return;
|
||||
}
|
||||
if (
|
||||
props.type === "number" &&
|
||||
value !== "" &&
|
||||
(value === "-" || value === ".")
|
||||
) {
|
||||
setValue("");
|
||||
setInternalValue("");
|
||||
onValueBlur?.("" as T);
|
||||
return;
|
||||
}
|
||||
|
||||
const outputValue = processValue(value);
|
||||
|
||||
Reference in New Issue
Block a user