17
17
18
18
import type { ChangeEvent , ClassAttributes , InputHTMLAttributes } from "react" ;
19
19
import AutoNumericComponent from "./AutoNumericComponent" ;
20
+ import type { CallbackOptions } from "autonumeric" ;
20
21
21
- type InputProps = Omit <
22
+ /** Same as {@link JSX!IntrinsicElements.input.props} excluding the `ref` property. */
23
+ export type InputProps = Omit <
22
24
InputHTMLAttributes < HTMLInputElement > & ClassAttributes < HTMLInputElement > ,
23
25
"ref"
24
26
> ;
25
27
28
+ /** React {@link JSX!IntrinsicElements.input} component integrated with {@link !AutoNumeric}.
29
+ *
30
+ * @param options - Options of the component.
31
+ * @param options.inputProps - Options passed to {@link JSX!IntrinsicElements.input}. Same as {@link
32
+ * JSX!IntrinsicElements.input.props} excluding the `ref` property.
33
+ * @param options.autoNumericOptions - Options passed to {@link !AutoNumeric}. Same as {@link
34
+ * AutoNumeric!Options}.
35
+ * @returns The React component.
36
+ */
37
+ export function AutoNumericInput ( {
38
+ inputProps,
39
+ autoNumericOptions,
40
+ } : {
41
+ inputProps ?: InputProps ;
42
+ autoNumericOptions ?: CallbackOptions ;
43
+ } ) : JSX . Element ;
44
+
45
+ /** React {@link JSX!IntrinsicElements.input} component integrated with {@link !AutoNumeric} and
46
+ * permits interaction with a React state.
47
+ *
48
+ * @param options - Options of the component.
49
+ * @param options.inputProps - Options passed to {@link JSX!IntrinsicElements.input}. Same as {@link
50
+ * JSX!IntrinsicElements.input.props}.
51
+ * @param options.autoNumericOptions - Options passed to {@link !AutoNumeric}. Same as {@link
52
+ * AutoNumeric!Options}.
53
+ * @param options.valueState - The state from the parent component to be passed in.
54
+ * @param options.valueStateSetter - The callback function that sets `options.valueState`.
55
+ * @returns The React component.
56
+ */
57
+ // eslint-disable-next-line @typescript-eslint/unified-signatures
58
+ export function AutoNumericInput ( {
59
+ inputProps,
60
+ autoNumericOptions,
61
+ valueState,
62
+ valueStateSetter,
63
+ } : {
64
+ inputProps ?: InputProps ;
65
+ autoNumericOptions ?: CallbackOptions ;
66
+ valueState : string ;
67
+ valueStateSetter : React . Dispatch < React . SetStateAction < string > > ;
68
+ } ) : JSX . Element ;
69
+
26
70
export function AutoNumericInput ( {
27
71
inputProps,
28
72
autoNumericOptions,
@@ -31,17 +75,13 @@ export function AutoNumericInput({
31
75
} :
32
76
| {
33
77
inputProps ?: InputProps ;
34
- autoNumericOptions ?: Parameters <
35
- typeof AutoNumericComponent
36
- > [ 0 ] [ "autoNumericOptions" ] ;
78
+ autoNumericOptions ?: CallbackOptions ;
37
79
valueState : string ;
38
80
valueStateSetter : React . Dispatch < React . SetStateAction < string > > ;
39
81
}
40
82
| {
41
83
inputProps ?: InputProps ;
42
- autoNumericOptions ?: Parameters <
43
- typeof AutoNumericComponent
44
- > [ 0 ] [ "autoNumericOptions" ] ;
84
+ autoNumericOptions ?: CallbackOptions ;
45
85
valueState ?: undefined ;
46
86
valueStateSetter ?: undefined ;
47
87
} ) : JSX . Element {
0 commit comments