Skip to content

Commit 5718750

Browse files
committed
refactor(types): extract shared props for Autocomplete/RenderAutocomplete
Signed-off-by: jiwlee <[email protected]>
1 parent 3372612 commit 5718750

File tree

1 file changed

+16
-30
lines changed

1 file changed

+16
-30
lines changed

v2/components/autocomplete/autocomplete.tsx

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,43 +21,29 @@ export const useAutocomplete = (init: string): [string, SetInputFxn, Autocomplet
2121
return [state, setState, autocomplete];
2222
};
2323

24-
export const Autocomplete = (
25-
props: React.InputHTMLAttributes<HTMLInputElement> & {
26-
items: string[];
27-
abbreviations?: Map<string, string>;
28-
inputStyle?: React.CSSProperties;
29-
onItemClick?: (item: string) => void;
30-
icon?: string;
31-
inputref?: React.MutableRefObject<HTMLInputElement>;
32-
value: string;
33-
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
34-
className?: string;
35-
style?: React.CSSProperties;
36-
glob?: boolean | IOptions;
37-
}
38-
) => {
24+
type Props = React.InputHTMLAttributes<HTMLInputElement> & {
25+
items: string[];
26+
abbreviations?: Map<string, string>;
27+
inputStyle?: React.CSSProperties;
28+
onItemClick?: (item: string) => void;
29+
icon?: string;
30+
inputref?: React.MutableRefObject<HTMLInputElement>;
31+
value: string;
32+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
33+
className?: string;
34+
style?: React.CSSProperties;
35+
glob?: boolean | IOptions;
36+
};
37+
38+
export const Autocomplete = (props: Props) => {
3939
return (
4040
<KeybindingProvider>
4141
<RenderAutocomplete {...props} />
4242
</KeybindingProvider>
4343
);
4444
};
4545

46-
export const RenderAutocomplete = (
47-
props: React.InputHTMLAttributes<HTMLInputElement> & {
48-
items: string[];
49-
abbreviations?: Map<string, string>;
50-
inputStyle?: React.CSSProperties;
51-
onItemClick?: (item: string) => void;
52-
icon?: string;
53-
inputref?: React.MutableRefObject<HTMLInputElement>;
54-
value: string;
55-
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
56-
className?: string;
57-
style?: React.CSSProperties;
58-
glob?: boolean | IOptions;
59-
}
60-
) => {
46+
export const RenderAutocomplete = (props: Props) => {
6147
const [curItems, setCurItems] = React.useState(props.items || []);
6248
const nullInputRef = React.useRef<HTMLInputElement>(null);
6349
const inputRef = props.inputref || nullInputRef;

0 commit comments

Comments
 (0)