Skip to content

Commit

Permalink
Merge branch 'main' into fix-395
Browse files Browse the repository at this point in the history
  • Loading branch information
wobsoriano authored Aug 28, 2024
2 parents 18fa6e5 + 2b99cd8 commit 461b745
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"import": "./dist/index.mjs",
"require": "./dist/index.js"
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
Expand Down
14 changes: 7 additions & 7 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ const Toast = (props: ToastProps) => {
toastDescriptionClassname,
classNames?.description,
toast?.classNames?.description,
)}
)}
>
{toast.description}
</div>
Expand Down Expand Up @@ -534,16 +534,15 @@ const Toaster = (props: ToasterProps) => {
const lastFocusedElementRef = React.useRef<HTMLElement>(null);
const isFocusWithinRef = React.useRef(false);

const removeToast = React.useCallback(
(toastToRemove: ToastT) => {
const removeToast = React.useCallback((toastToRemove: ToastT) => {
setToasts((toasts) => {
if (!toasts.find((toast) => toast.id === toastToRemove.id)?.delete) {
ToastState.dismiss(toastToRemove.id);
}

setToasts((toasts) => toasts.filter(({ id }) => id !== toastToRemove.id))
},
[toasts],
);
return toasts.filter(({ id }) => id !== toastToRemove.id);
});
}, []);

React.useEffect(() => {
return ToastState.subscribe((toast) => {
Expand Down Expand Up @@ -755,3 +754,4 @@ const Toaster = (props: ToasterProps) => {
);
};
export { toast, Toaster, type ExternalToast, type ToastT, type ToasterProps, useSonner };
export { type ToastClassnames, type ToastToDismiss, type Action } from './types';
4 changes: 4 additions & 0 deletions src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,10 @@
width: 100%;
}

[data-sonner-toaster][dir='rtl'] {
left: calc(var(--mobile-offset) * -1);
}

[data-sonner-toaster] [data-sonner-toast] {
left: 0;
right: 0;
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export interface ToastIcons {
loading?: React.ReactNode;
}

interface Action {
export interface Action {
label: React.ReactNode;
onClick: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
actionButtonStyle?: React.CSSProperties;
Expand Down

0 comments on commit 461b745

Please sign in to comment.