Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ComboBox typings for trigger props #262

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/components/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ export function ComboBoxRenderFunction<T extends HTMLElement>(
);
}

export const ComboBox = forwardRef<HTMLDivElement, ComboBoxProps<HTMLElement>>(ComboBoxRenderFunction);
type CustomForwardRefResult = <T extends HTMLElement>(
props: React.PropsWithoutRef<ComboBoxProps<T>> & React.RefAttributes<HTMLDivElement>,
) => React.ReactElement;

export const ComboBox = forwardRef(ComboBoxRenderFunction) as CustomForwardRefResult;

export default ComboBox;
2 changes: 1 addition & 1 deletion src/components/FormMultiInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
import { ComboBox } from './ComboBox';

interface FormMultiInputProps {
items?: Array<{ title: string; id: any }>;

Check warning on line 17 in src/components/FormMultiInput.tsx

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
id?: string;
name?: string;
label?: string;
query?: string;
value?: Array<{ title: string; id: any }>;

Check warning on line 22 in src/components/FormMultiInput.tsx

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
disabled?: boolean;
placeholder?: string;
error?: React.ComponentProps<typeof ComboBox>['error'];
className?: string;

onChange?: (value: Array<{ title: string; id: any }>) => void;

Check warning on line 28 in src/components/FormMultiInput.tsx

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
onInput?: (query: string) => void;
onClick?: (item: { title: string; id: any }) => void;

Check warning on line 30 in src/components/FormMultiInput.tsx

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
}

const StyledFormInputContainer = styled.div`
Expand Down Expand Up @@ -55,7 +55,7 @@
min-width: 100px;
`;

const StyledComboBox = styled(ComboBox)`
const StyledComboBox = styled(ComboBox<HTMLButtonElement>)`
margin-left: ${gapS};
`;

Expand Down Expand Up @@ -87,14 +87,14 @@
}, [inputState, onInput]);

const onValueDelete = useCallback(
(deleted: { title: string; id: any }) => () => {

Check warning on line 90 in src/components/FormMultiInput.tsx

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
onChange?.(value.filter((item) => item.id !== deleted.id));
},
[onChange, value],
);

const onValueAdd = useCallback(
(added: { title: string; id: any }) => {

Check warning on line 97 in src/components/FormMultiInput.tsx

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
onChange?.([...value, added]);
},
[onChange, value],
Expand Down
Loading