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 various typescript inconsistencies #319

Merged
merged 3 commits into from
Oct 6, 2020
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
4 changes: 2 additions & 2 deletions src/SnackbarContent/SnackbarContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ const styles = (theme: Theme) => createStyles({
}
});

export interface SnackbarContent extends WithStyles<typeof styles>, React.HTMLAttributes<HTMLDivElement> { }
interface SnackbarContentProps extends WithStyles<typeof styles>, React.HTMLAttributes<HTMLDivElement> { }

const SnackbarContent: React.FC<SnackbarContent> = forwardRef<HTMLDivElement, SnackbarContent>(({ classes, className, ...props }, ref) => (
const SnackbarContent = forwardRef<HTMLDivElement, SnackbarContentProps>(({ classes, className, ...props }, ref) => (
<div ref={ref} className={clsx(classes.root, className)} {...props} />
))

Expand Down
13 changes: 10 additions & 3 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type CloseReason = 'timeout' | 'clickaway' | 'maxsnack' | 'instructed';

export type SnackbarMessage = string | React.ReactNode;
export type SnackbarAction = React.ReactNode | ((key: SnackbarKey) => React.ReactNode);
export type SnackbarContent = React.ReactNode | ((key: SnackbarKey, message: SnackbarMessage) => React.ReactNode);
export type SnackbarContentCallback = React.ReactNode | ((key: SnackbarKey, message: SnackbarMessage) => React.ReactNode);


// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -192,7 +192,7 @@ export interface SharedProps extends Omit<SnackbarProps, 'classes'>, Partial<Tra
* Replace the snackbar. Callback used for displaying entirely customized snackbar.
* @param {string|number} key key of a snackbar
*/
content?: SnackbarContent;
content?: SnackbarContentCallback;
/**
* Callback used for getting action(s). actions are mostly buttons displayed in Snackbar.
* @param {string|number} key key of a snackbar
Expand Down Expand Up @@ -253,9 +253,16 @@ export interface SnackbarProviderProps extends SharedProps {
* Little icon that is displayed at left corner of a snackbar.
*/
iconVariant?: Partial<IconVariant>;
/**
* SnackbarProvider's ref
*/
ref?: React.Ref<SnackbarProvider>;
}

export const SnackbarProvider: React.ComponentType<SnackbarProviderProps>;
export class SnackbarProvider extends React.Component<SnackbarProviderProps> {
enqueueSnackbar: ProviderContext['enqueueSnackbar'];
closeSnackbar: ProviderContext['closeSnackbar'];
}

export interface ProviderContext {
enqueueSnackbar: (message: SnackbarMessage, options?: OptionsObject) => SnackbarKey;
Expand Down
Loading