@@ -2,6 +2,7 @@ import { mergeRefs } from "@react-aria/utils";
22import { resolveCurrencyFormat } from "@sumup/intl" ;
33import { type FocusEvent , type FormEvent , type ForwardedRef , forwardRef , useRef } from "react" ;
44import {
5+ type InputAttributes ,
56 NumberFormatBase ,
67 type NumberFormatBaseProps ,
78 type NumberFormatValues ,
@@ -10,14 +11,18 @@ import {
1011
1112import { setCaretPosition } from "./utils" ;
1213
13- export interface CurrencyInputProps extends Omit < NumberFormatBaseProps , "format" | "prefix" > {
14- currency ?: string ;
14+ type CurrencyInputProps < BaseType = InputAttributes > = Omit <
15+ NumberFormatBaseProps < BaseType > ,
16+ "format" | "prefix" | "customInput"
17+ > & {
1518 locale ?: string ;
19+ currency ?: string ;
1620 withCurrencySymbol ?: boolean ;
17- }
21+ customInput ?: React . ComponentType < BaseType > ;
22+ } ;
1823
19- function RenderCurrencyInput (
20- { locale = "en" , currency = "USD" , withCurrencySymbol = true , ...props } : CurrencyInputProps ,
24+ function RenderCurrencyInput < BaseType = InputAttributes > (
25+ { locale = "en" , currency = "USD" , withCurrencySymbol = true , ...props } : CurrencyInputProps < BaseType > ,
2126 forwadedRef : ForwardedRef < HTMLInputElement > ,
2227) {
2328 const innerRef = useRef < HTMLInputElement > ( null ) ;
@@ -106,10 +111,12 @@ function RenderCurrencyInput(
106111 setCaretPosition ( innerRef . current , positionLastDigit + ( minimumFractionDigits ?? 0 ) ) ;
107112 }
108113
114+ // @ts -expect-error - onInput is not part of the type
109115 props ?. onInput ?.( event ) ;
110116 }
111117
112118 return (
119+ // @ts -expect-error
113120 < NumberFormatBase
114121 { ...props }
115122 format = { format }
@@ -123,4 +130,7 @@ function RenderCurrencyInput(
123130 ) ;
124131}
125132
126- export const CurrencyInput = forwardRef < HTMLInputElement , CurrencyInputProps > ( RenderCurrencyInput ) ;
133+ // @ts -expect-error - forwardRef is not part of the type
134+ export const CurrencyInput : < BaseType = InputAttributes > (
135+ props : CurrencyInputProps < BaseType > & { ref ?: ForwardedRef < HTMLInputElement > } ,
136+ ) => ReturnType < typeof RenderCurrencyInput < BaseType > > = forwardRef ( RenderCurrencyInput ) ;
0 commit comments