diff --git a/packages/color-editable-input/README.md b/packages/color-editable-input/README.md index 10c79683b..ca126083d 100644 --- a/packages/color-editable-input/README.md +++ b/packages/color-editable-input/README.md @@ -49,6 +49,7 @@ export interface EditableInputProps extends Omit, value: string | number) => void; + renderInput?: (props: React.InputHTMLAttributes, ref: React.Ref) => React.ReactNode; } declare const EditableInput: React.ForwardRefExoticComponent>; export default EditableInput; diff --git a/packages/color-editable-input/src/index.tsx b/packages/color-editable-input/src/index.tsx index 01d6d2261..b26334cf3 100644 --- a/packages/color-editable-input/src/index.tsx +++ b/packages/color-editable-input/src/index.tsx @@ -12,6 +12,7 @@ export interface EditableInputProps extends Omit, value: string | number) => void; + renderInput?: (props: React.InputHTMLAttributes, ref: React.Ref) => React.ReactNode; } const EditableInput = React.forwardRef((props, ref) => { @@ -26,6 +27,7 @@ const EditableInput = React.forwardRef((pr inputStyle, onChange, onBlur, + renderInput, ...other } = props; const [value, setValue] = useState(initValue); @@ -90,18 +92,19 @@ const EditableInput = React.forwardRef((pr boxShadow: 'var(--editable-input-box-shadow)', ...inputStyle, } as React.CSSProperties; + + const inputProps: React.InputHTMLAttributes = { + value, + onChange: handleChange, + onBlur: handleBlur, + autoComplete: 'off', + onFocus: () => (isFocus.current = true), + ...other, + style: editableStyle, + }; return (
- (isFocus.current = true)} - {...other} - style={editableStyle} - /> + {renderInput ? renderInput(inputProps, ref) : } {label && (