chore: painting cache

This commit is contained in:
jialin
2024-12-27 14:56:06 +08:00
parent 542f048a67
commit bca56bfaad
17 changed files with 1411 additions and 1047 deletions
+9 -4
View File
@@ -15,6 +15,7 @@ const SealSelect: React.FC<SelectProps & SealFormItemProps> = (props) => {
required,
description,
options,
allowNull,
isInFormItems = true,
...rest
} = props;
@@ -22,6 +23,8 @@ const SealSelect: React.FC<SelectProps & SealFormItemProps> = (props) => {
const [isFocus, setIsFocus] = useState(false);
const inputRef = useRef<any>(null);
let status = '';
// the status can be controlled by Form.Item
if (isInFormItems) {
const statusData = Form?.Item?.useStatus?.();
status = statusData?.status || '';
@@ -41,10 +44,10 @@ const SealSelect: React.FC<SelectProps & SealFormItemProps> = (props) => {
}, [options, intl]);
useEffect(() => {
if (isNotEmptyValue(props.value)) {
if (isNotEmptyValue(props.value) || (allowNull && props.value === null)) {
setIsFocus(true);
}
}, [props.value]);
}, [props.value, allowNull]);
const handleClickWrapper = () => {
if (!props.disabled && !isFocus) {
@@ -54,7 +57,7 @@ const SealSelect: React.FC<SelectProps & SealFormItemProps> = (props) => {
};
const handleChange = (val: any, options: any) => {
if (isNotEmptyValue(val)) {
if (isNotEmptyValue(val) || (allowNull && val === null)) {
setIsFocus(true);
} else {
setIsFocus(false);
@@ -68,7 +71,9 @@ const SealSelect: React.FC<SelectProps & SealFormItemProps> = (props) => {
};
const handleOnBlur = (e: any) => {
if (!props.value) {
if (allowNull && props.value === null) {
setIsFocus(true);
} else if (!props.value) {
setIsFocus(false);
}
props.onBlur?.(e);
+1
View File
@@ -7,6 +7,7 @@ export interface SealFormItemProps {
description?: React.ReactNode;
extra?: React.ReactNode;
addAfter?: React.ReactNode;
allowNull?: boolean;
loading?: React.ReactNode;
trim?: boolean;
checkStatus?: 'success' | 'error' | 'warning' | '';