Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
iamhosseindhv committed Apr 17, 2020
1 parent b407193 commit 3e649c9
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 107 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"scripts": {
"types": "tsc",
"build": "NODE_ENV=production BABEL_ENV=production babel src -d build --copy-files --extensions \".js,.ts,.tsx\"",
"prebuild": "rimraf build",
"prebuild": "rimraf build && npm run docs",
"prepublishOnly": "npm run build",
"docs": "rimraf typedoc.json && typedoc --tsconfig",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
Expand Down
12 changes: 6 additions & 6 deletions src/SnackbarItem/SnackbarItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ const SnackbarItem: React.FC<SnackbarItemProps> = (props) => {
}, []);

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const handleClose = (key: SnackbarKey) => (event: React.SyntheticEvent<any> | null, reason: CloseReason): void => {
const { snack } = props;
if (snack.onClose) {
snack.onClose(event, reason, key);
const handleClose = (key: SnackbarKey) => (event: React.SyntheticEvent<any> | null, reason: string): void => {
const cause = reason as CloseReason;
if (props.snack.onClose) {
props.snack.onClose(event, cause, key);
}
props.onClose(event, reason, key);
props.onClose(event, cause, key);
};

const handleEntered = (key: SnackbarKey) => (node: HTMLElement, isAppearing: boolean): void => {
Expand Down Expand Up @@ -131,7 +131,7 @@ const SnackbarItem: React.FC<SnackbarItemProps> = (props) => {
const getUnusedCallbacks = () => (
['onEnter', 'onEntering', 'onExit', 'onExiting'].reduce((acc, cbName) => ({
...acc,
[cbName]: (...args): void => {
[cbName]: (...args: any[]): void => {
const { snack } = props;
if (typeof snack[cbName] === 'function') {
snack[cbName](...args, snack.key);
Expand Down
17 changes: 9 additions & 8 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export interface TransitionHandlerProps {
export interface SnackbarProps extends StandardProps<React.HTMLAttributes<HTMLDivElement>, SnackbarClassKey> {
/**
* The anchor of the `Snackbar`.
* @default { horizontal: left, vertical: bottom }
*/
anchorOrigin?: SnackbarOrigin;
/**
Expand All @@ -125,10 +126,12 @@ export interface SnackbarProps extends StandardProps<React.HTMLAttributes<HTMLDi
*/
autoHideDuration?: number | null;
/**
* @ignore
* Properties applied to ClickAwayListener component
*/
ClickAwayListenerProps?: Partial<ClickAwayListenerProps>;
/**
* @ignore
* Properties applied to SnackbarContent component
*/
ContentProps?: Partial<SnackbarContentProps>;
Expand All @@ -142,7 +145,7 @@ export interface SnackbarProps extends StandardProps<React.HTMLAttributes<HTMLDi
* If `autoHideDuration` property isn't specified, it does nothing.
* If `autoHideDuration` property is specified but `resumeHideDuration` isn't,
* we use the default value.
* @default `autoHideDuration / 2` ms.
* @default autoHideDuration / 2 ms.
*/
resumeHideDuration?: number;
/**
Expand All @@ -159,10 +162,7 @@ export interface SnackbarProps extends StandardProps<React.HTMLAttributes<HTMLDi
* ```
* or individually:
* ```js
* timeout={{
* enter: 300,
* exit: 500,
* }}
* timeout={{ enter: 300, exit: 500 }}
* ```
* @default { enter: 225, exit: 195 }
*/
Expand Down Expand Up @@ -206,7 +206,7 @@ export interface SharedProps extends Omit<SnackbarProps, 'classes'>, Partial<Tra
export interface OptionsObject extends SharedProps {
/**
* Unique identifier to reference a snackbar.
* @default randomly generated unique string
* @default random unique string
*/
key?: SnackbarKey;
/**
Expand All @@ -222,12 +222,13 @@ export interface OptionsObject extends SharedProps {
*/
export interface SnackbarProviderProps extends SharedProps {
/**
* Most of the time, this is your App. every component from this point onward
* Most of the time this is your App. every component from this point onward
* will be able to show snackbars.
*/
children: React.ReactNode;
children: React.ReactNode | React.ReactNode[];
/**
* Denser margins for snackbars. Recommended to be used on mobile devices.
* @default false
*/
dense?: boolean;
/**
Expand Down
Loading

0 comments on commit 3e649c9

Please sign in to comment.