@homebound/beam 2.369.1 → 2.369.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,7 @@ export interface ToastNoticeProps extends Omit<BannerProps, "onClose"> {
5
5
  export type ToastContextProps = {
6
6
  notice: ToastNoticeProps | undefined;
7
7
  setNotice: React.Dispatch<React.SetStateAction<ToastNoticeProps | undefined>>;
8
+ clear: () => void;
8
9
  };
9
10
  export declare const ToastContext: React.Context<ToastContextProps>;
10
11
  export declare function ToastProvider(props: {
@@ -7,11 +7,13 @@ exports.ToastContext = (0, react_1.createContext)({
7
7
  setNotice: () => {
8
8
  throw new Error("Missing ToastProvider");
9
9
  },
10
+ clear: () => { },
10
11
  notice: undefined,
11
12
  });
12
13
  function ToastProvider(props) {
13
14
  const [notice, setNotice] = (0, react_1.useState)();
14
- const contextValue = (0, react_1.useMemo)(() => ({ setNotice, notice }), [setNotice, notice]);
15
+ const clear = (0, react_1.useCallback)(() => setNotice(undefined), [setNotice]);
16
+ const contextValue = (0, react_1.useMemo)(() => ({ setNotice, notice, clear }), [notice, clear]);
15
17
  return (0, jsx_runtime_1.jsx)(exports.ToastContext.Provider, { value: contextValue, children: props.children });
16
18
  }
17
19
  exports.ToastProvider = ToastProvider;
@@ -1,5 +1,6 @@
1
1
  import { ToastNoticeProps } from "./ToastContext";
2
2
  export interface UseToastProps {
3
3
  showToast: (props: ToastNoticeProps) => void;
4
+ clear: () => void;
4
5
  }
5
6
  export declare function useToast(): UseToastProps;
@@ -4,8 +4,8 @@ exports.useToast = void 0;
4
4
  const react_1 = require("react");
5
5
  const ToastContext_1 = require("./ToastContext");
6
6
  function useToast() {
7
- const { setNotice } = (0, ToastContext_1.useToastContext)();
7
+ const { setNotice, clear } = (0, ToastContext_1.useToastContext)();
8
8
  const showToast = (0, react_1.useCallback)((props) => setNotice(props), [setNotice]);
9
- return { showToast };
9
+ return { showToast, clear };
10
10
  }
11
11
  exports.useToast = useToast;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.369.1",
3
+ "version": "2.369.2",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",