Skip to content

Commit 86af9fd

Browse files
author
sergey.platonov
committed
fix: Correct types for customInput property
1 parent e2179f9 commit 86af9fd

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/number_format_base.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,15 +412,17 @@ export default function NumberFormatBase<BaseType = InputAttributes>(
412412
// add input mode on element based on format prop and device once the component is mounted
413413
const inputMode: InputAttributes['inputMode'] = mounted && addInputMode() ? 'numeric' : undefined;
414414

415-
const inputProps = Object.assign({ inputMode }, otherProps, {
415+
const inputProps: InputAttributes = {
416+
inputMode,
417+
...otherProps,
416418
type,
417419
value: formattedValue,
418420
onChange: _onChange,
419421
onKeyDown: _onKeyDown,
420422
onMouseUp: _onMouseUp,
421423
onFocus: _onFocus,
422424
onBlur: _onBlur,
423-
});
425+
};
424426

425427
if (displayType === 'text') {
426428
return renderText ? (
@@ -432,7 +434,6 @@ export default function NumberFormatBase<BaseType = InputAttributes>(
432434
);
433435
} else if (customInput) {
434436
const CustomInput = customInput;
435-
/* @ts-ignore */
436437
return <CustomInput {...inputProps} ref={getInputRef} />;
437438
}
438439

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export type InputAttributes = Omit<
5252
type NumberFormatProps<Props, BaseType = InputAttributes> = Props &
5353
Omit<InputAttributes, keyof BaseType> &
5454
Omit<BaseType, keyof Props | 'ref'> & {
55-
customInput?: React.ComponentType<BaseType>;
55+
customInput?: React.ComponentType<React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;
5656
};
5757

5858
export type OnValueChange = (values: NumberFormatValues, sourceInfo: SourceInfo) => void;

0 commit comments

Comments
 (0)