@zonos/amino 5.4.23 → 5.4.25

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.
@@ -8,6 +8,10 @@ export type ToastProps = BaseProps & {
8
8
  direction?: Direction;
9
9
  /** Dismiss delay (default 6000 ms) */
10
10
  duration?: number;
11
+ /** Pass a unique identifier for the toast (used for dismissing)
12
+ * @default uuid created in Amino
13
+ */
14
+ id?: string;
11
15
  intent?: Extract<Intent, 'success' | 'warning' | 'error' | 'info'>;
12
16
  /** If true, toast will be shown in the persistent stack */
13
17
  isPersistent?: boolean;
@@ -5,7 +5,11 @@ export type ToastContextFunctionType = (toast: ReactNode, props?: BaseProps, loc
5
5
  bottom?: string;
6
6
  left?: string;
7
7
  }) => void;
8
- export declare const ToastContext: import("react").Context<ToastContextFunctionType>;
8
+ export declare const ToastContext: import("react").Context<{
9
+ notify: ToastContextFunctionType;
10
+ dismissAllToasts: () => void;
11
+ dismissToast: (toastId: string) => void;
12
+ }>;
9
13
  type Props = {
10
14
  children: ReactNode;
11
15
  };
@@ -1 +1 @@
1
- "use strict";var t=require("../../_tslib-bd4862e8.js"),e=require("react/jsx-runtime"),o=require("react"),n=require("clsx"),s=require("framer-motion"),r=require("uuid"),i=require("../button/Button.js"),a=require("../flex/Flex.js"),u=require("./Toast.js"),l=require("../../icons/RemoveIcon.js"),d=require("../../style-inject.es-d4ddeae4.js");function _(t){return t&&t.__esModule?t:{default:t}}require("../button/RippleGroup.js"),require("../button/_Ripple.js"),require("../../utils/getAminoColor.js"),require("../../styles/constants/theme.js"),require("../button/useRipple.js"),require("../spinner/Spinner.js"),require("../../icons/CheckCircleIcon.js"),require("../../icons/icon-base/_IconBase.js"),require("../../icons/InfoIcon.js"),require("../../icons/RemoveCircleIcon.js"),require("../../icons/WarningIcon.js");var m=_(n),p="Amino_ToastContext-module__toastContainer--v8ymm",c="Amino_ToastContext-module__toastsWrapper--W5SKw",x="Amino_ToastContext-module__regularToastsWrapper--onKC-",T="Amino_ToastContext-module__persistentToastsWrapper--5dhd9",f="Amino_ToastContext-module__clearAllButton--r43o-",h="Amino_ToastContext-module__expanded--mPeFN",C="Amino_ToastContext-module__persistentToast--yMpFG";d.styleInject(".Amino_ToastContext-module__toastContainer--v8ymm{bottom:var(--amino-toast-context-bottom);display:flex;flex-direction:column;justify-content:flex-end;left:var(--amino-toast-context-left);position:fixed;width:100%;z-index:9999999}.Amino_ToastContext-module__toastsWrapper--W5SKw{align-items:center;display:flex;flex-direction:column;gap:16px}.Amino_ToastContext-module__regularToastsWrapper--onKC-{margin-bottom:16px}.Amino_ToastContext-module__persistentToastsWrapper--5dhd9{margin:0 auto;max-height:60vh;max-width:600px;min-height:var(--amino-toast-persistent-height);position:relative;width:100%;z-index:1000}.Amino_ToastContext-module__persistentToastsWrapper--5dhd9:hover{cursor:pointer}.Amino_ToastContext-module__persistentToastsWrapper--5dhd9 .Amino_ToastContext-module__clearAllButton--r43o-{-webkit-backdrop-filter:blur(5px);backdrop-filter:blur(5px);background-color:#0000000f;border-radius:var(--amino-radius-4);margin-left:auto}.Amino_ToastContext-module__persistentToastsWrapper--5dhd9.Amino_ToastContext-module__expanded--mPeFN{position:relative;width:100%}.Amino_ToastContext-module__persistentToastsWrapper--5dhd9.Amino_ToastContext-module__expanded--mPeFN .Amino_ToastContext-module__clearAllButton--r43o-{margin-bottom:-8px}.Amino_ToastContext-module__persistentToastsWrapper--5dhd9 .Amino_ToastContext-module__persistentToast--yMpFG{width:100%;z-index:8}.Amino_ToastContext-module__persistentToastsWrapper--5dhd9 .Amino_ToastContext-module__persistentToast--yMpFG:first-of-type{z-index:10}.Amino_ToastContext-module__persistentToastsWrapper--5dhd9 .Amino_ToastContext-module__persistentToast--yMpFG:nth-of-type(2){z-index:9}.Amino_ToastContext-module__persistentToastsWrapper--5dhd9:not(.Amino_ToastContext-module__expanded--mPeFN) .Amino_ToastContext-module__persistentToast--yMpFG{filter:brightness(2);opacity:0;position:absolute;scale:.5;transform-origin:bottom center;transition:all .3s cubic-bezier(.4,0,.2,1)}.Amino_ToastContext-module__persistentToastsWrapper--5dhd9:not(.Amino_ToastContext-module__expanded--mPeFN) .Amino_ToastContext-module__persistentToast--yMpFG:first-of-type{bottom:0;filter:brightness(1);opacity:1;scale:1}.Amino_ToastContext-module__persistentToastsWrapper--5dhd9:not(.Amino_ToastContext-module__expanded--mPeFN) .Amino_ToastContext-module__persistentToast--yMpFG:nth-of-type(2){bottom:-8px;filter:brightness(1.5);opacity:1;scale:.9}.Amino_ToastContext-module__persistentToastsWrapper--5dhd9:not(.Amino_ToastContext-module__expanded--mPeFN) .Amino_ToastContext-module__persistentToast--yMpFG:nth-of-type(3){bottom:-16px;filter:brightness(2);opacity:.8;scale:.8}");var A=o.createContext((function(t,e){}));exports.ToastContext=A,exports.ToastContextProvider=function(n){var d=n.children,_=t.__read(o.useState([]),2),v=_[0],b=_[1],y=t.__read(o.useState([]),2),j=y[0],g=y[1],q=t.__read(o.useState(!1),2),W=q[0],F=q[1],P=t.__read(o.useState({bottom:"",left:""}),2),N=P[0],k=P[1],I=o.useCallback((function(e,o){var n={isPersistent:null==o?void 0:o.isPersistent,props:o,toast:e,uuid:r.v4()};(null==o?void 0:o.isPersistent)?g((function(e){return t.__spreadArray([n],t.__read(e),!1)})):(b((function(e){return t.__spreadArray(t.__spreadArray([],t.__read(e),!1),[n],!1)})),setTimeout((function(){return b((function(t){return t.slice(1)}))}),(null==o?void 0:o.duration)||6e3))}),[b,g]),w=o.useCallback((function(t,e,o){o&&k({bottom:o.bottom||"",left:o.left||""}),I(t,e)}),[I]),G=function(t,e){t.stopPropagation(),function(t){g((function(e){return e.filter((function(e){return e.uuid!==t}))}))}(e)},M=function(t){var e=t.currentTarget.querySelector(".toast-actions");e&&!e.contains(t.target)&&F((function(t){return!t}))},S=o.useRef(null),B=t.__read(o.useState(0),2),K=B[0],R=B[1],z=j.find(Boolean);return o.useEffect((function(){S.current&&R(S.current.offsetHeight)}),[z]),e.jsxs(A.Provider,{value:w,children:[d,e.jsxs("div",{className:p,style:{"--amino-toast-context-bottom":N.bottom||"40px","--amino-toast-context-left":N.left||"auto","--amino-toast-persistent-height":j.length>0&&!W?"".concat(K+40,"px"):"unset"},children:[e.jsx("div",{className:m.default(c,x),children:e.jsx(s.AnimatePresence,{children:v.map((function(t){var o=t.props,n=t.toast,s=t.uuid,r="toast-".concat(n,"-").concat(s);return e.jsx(a.Flex,{children:e.jsx(u.Toast,{direction:null==o?void 0:o.direction,intent:null==o?void 0:o.intent,toastKey:r,children:n})},r)}))})}),e.jsxs("div",{className:m.default(c,T,W&&h),children:[!!j.length&&e.jsx(i.Button,{className:f,icon:e.jsx(l.RemoveIcon,{}),onClick:function(){g([]),F(!1)},variant:"text",children:"Clear all"}),e.jsx(s.AnimatePresence,{children:j.map((function(o,n){var s=o.props,r=o.toast,i=o.uuid,l="persistent-toast-".concat(r,"-").concat(i);return e.jsx("div",{ref:0===n?S:null,className:C,onClick:M,onKeyDown:function(t){"Enter"!==t.key&&" "!==t.key||M(t)},role:"button",tabIndex:0,children:e.jsx(a.Flex,{fullWidth:!0,children:e.jsx(u.Toast,t.__assign({isPersistent:!0,onDismiss:function(t){var e;null===(e=null==s?void 0:s.onDismiss)||void 0===e||e.call(s,t),G(t,i)},toastKey:l},s,{children:0===n||W?r:""}))})},l)}))})]})]})]})};
1
+ "use strict";var t=require("../../_tslib-bd4862e8.js"),e=require("react/jsx-runtime"),o=require("react"),n=require("clsx"),s=require("framer-motion"),i=require("uuid"),r=require("../button/Button.js"),a=require("../flex/Flex.js"),u=require("./Toast.js"),l=require("../../icons/RemoveIcon.js"),d=require("../../style-inject.es-d4ddeae4.js");function m(t){return t&&t.__esModule?t:{default:t}}require("../button/RippleGroup.js"),require("../button/_Ripple.js"),require("../../utils/getAminoColor.js"),require("../../styles/constants/theme.js"),require("../button/useRipple.js"),require("../spinner/Spinner.js"),require("../../icons/CheckCircleIcon.js"),require("../../icons/icon-base/_IconBase.js"),require("../../icons/InfoIcon.js"),require("../../icons/RemoveCircleIcon.js"),require("../../icons/WarningIcon.js");var _=m(n),c="Amino_ToastContext-module__toastContainer--v8ymm",p="Amino_ToastContext-module__toastsWrapper--W5SKw",x="Amino_ToastContext-module__regularToastsWrapper--onKC-",f="Amino_ToastContext-module__persistentToastsWrapper--5dhd9",T="Amino_ToastContext-module__clearAllButton--r43o-",C="Amino_ToastContext-module__expanded--mPeFN",h="Amino_ToastContext-module__persistentToast--yMpFG";d.styleInject(".Amino_ToastContext-module__toastContainer--v8ymm{bottom:var(--amino-toast-context-bottom);display:flex;flex-direction:column;justify-content:flex-end;left:var(--amino-toast-context-left);position:fixed;width:100%;z-index:9999999}.Amino_ToastContext-module__toastsWrapper--W5SKw{align-items:center;display:flex;flex-direction:column;gap:16px}.Amino_ToastContext-module__regularToastsWrapper--onKC-{margin-bottom:16px}.Amino_ToastContext-module__persistentToastsWrapper--5dhd9{margin:0 auto;max-height:60vh;max-width:600px;min-height:var(--amino-toast-persistent-height);position:relative;width:100%;z-index:1000}.Amino_ToastContext-module__persistentToastsWrapper--5dhd9:hover{cursor:pointer}.Amino_ToastContext-module__persistentToastsWrapper--5dhd9 .Amino_ToastContext-module__clearAllButton--r43o-{-webkit-backdrop-filter:blur(5px);backdrop-filter:blur(5px);background-color:#0000000f;border-radius:var(--amino-radius-4);margin-left:auto}.Amino_ToastContext-module__persistentToastsWrapper--5dhd9.Amino_ToastContext-module__expanded--mPeFN{position:relative;width:100%}.Amino_ToastContext-module__persistentToastsWrapper--5dhd9.Amino_ToastContext-module__expanded--mPeFN .Amino_ToastContext-module__clearAllButton--r43o-{margin-bottom:-8px}.Amino_ToastContext-module__persistentToastsWrapper--5dhd9 .Amino_ToastContext-module__persistentToast--yMpFG{width:100%;z-index:8}.Amino_ToastContext-module__persistentToastsWrapper--5dhd9 .Amino_ToastContext-module__persistentToast--yMpFG:first-of-type{z-index:10}.Amino_ToastContext-module__persistentToastsWrapper--5dhd9 .Amino_ToastContext-module__persistentToast--yMpFG:nth-of-type(2){z-index:9}.Amino_ToastContext-module__persistentToastsWrapper--5dhd9:not(.Amino_ToastContext-module__expanded--mPeFN) .Amino_ToastContext-module__persistentToast--yMpFG{filter:brightness(2);opacity:0;position:absolute;scale:.5;transform-origin:bottom center;transition:all .3s cubic-bezier(.4,0,.2,1)}.Amino_ToastContext-module__persistentToastsWrapper--5dhd9:not(.Amino_ToastContext-module__expanded--mPeFN) .Amino_ToastContext-module__persistentToast--yMpFG:first-of-type{bottom:0;filter:brightness(1);opacity:1;scale:1}.Amino_ToastContext-module__persistentToastsWrapper--5dhd9:not(.Amino_ToastContext-module__expanded--mPeFN) .Amino_ToastContext-module__persistentToast--yMpFG:nth-of-type(2){bottom:-8px;filter:brightness(1.5);opacity:1;scale:.9}.Amino_ToastContext-module__persistentToastsWrapper--5dhd9:not(.Amino_ToastContext-module__expanded--mPeFN) .Amino_ToastContext-module__persistentToast--yMpFG:nth-of-type(3){bottom:-16px;filter:brightness(2);opacity:.8;scale:.8}");var A=o.createContext({dismissAllToasts:function(){},dismissToast:function(t){},notify:function(t,e){}});exports.ToastContext=A,exports.ToastContextProvider=function(n){var d=n.children,m=t.__read(o.useState([]),2),v=m[0],b=m[1],y=t.__read(o.useState([]),2),j=y[0],g=y[1],q=t.__read(o.useState(!1),2),W=q[0],F=q[1],P=t.__read(o.useState({bottom:"",left:""}),2),k=P[0],N=P[1],I=o.useCallback((function(e,o){var n={isPersistent:null==o?void 0:o.isPersistent,props:o,toast:e,uuid:(null==o?void 0:o.id)||i.v4()};(null==o?void 0:o.isPersistent)?g((function(e){return t.__spreadArray([n],t.__read(e),!1)})):(b((function(e){return t.__spreadArray(t.__spreadArray([],t.__read(e),!1),[n],!1)})),setTimeout((function(){return b((function(t){return t.slice(1)}))}),(null==o?void 0:o.duration)||6e3))}),[b,g]),M=o.useCallback((function(t,e,o){o&&N({bottom:o.bottom||"",left:o.left||""}),I(t,e)}),[I]),w=o.useCallback((function(t){b((function(e){return e.filter((function(e){return e.uuid!==t}))})),g((function(e){return e.filter((function(e){return e.uuid!==t}))}))}),[g]),G=o.useCallback((function(){g([]),b([]),F(!1)}),[g,b,F]),S=function(t){var e=t.currentTarget.querySelector(".toast-actions");e&&!e.contains(t.target)&&F((function(t){return!t}))},B=o.useRef(null),K=t.__read(o.useState(0),2),R=K[0],z=K[1],D=j.find(Boolean);o.useEffect((function(){B.current&&z(B.current.offsetHeight)}),[D]);var E=o.useMemo((function(){return{dismissAllToasts:G,dismissToast:w,notify:M}}),[G,w,M]);return e.jsxs(A.Provider,{value:E,children:[d,e.jsxs("div",{className:c,style:{"--amino-toast-context-bottom":k.bottom||"40px","--amino-toast-context-left":k.left||"auto","--amino-toast-persistent-height":j.length>0&&!W?"".concat(R+40,"px"):"unset"},children:[e.jsx("div",{className:_.default(p,x),children:e.jsx(s.AnimatePresence,{children:v.map((function(t){var o=t.props,n=t.toast,s=t.uuid,i="toast-".concat(n,"-").concat(s);return e.jsx(a.Flex,{children:e.jsx(u.Toast,{direction:null==o?void 0:o.direction,intent:null==o?void 0:o.intent,toastKey:i,children:n})},i)}))})}),e.jsxs("div",{className:_.default(p,f,W&&C),children:[!!j.length&&e.jsx(r.Button,{className:T,icon:e.jsx(l.RemoveIcon,{}),onClick:G,variant:"text",children:"Clear all"}),e.jsx(s.AnimatePresence,{children:j.map((function(o,n){var s=o.props,i=o.toast,r=o.uuid,l="persistent-toast-".concat(i,"-").concat(r);return e.jsx("div",{ref:0===n?B:null,className:h,onClick:S,onKeyDown:function(t){"Enter"!==t.key&&" "!==t.key||S(t)},role:"button",tabIndex:0,children:e.jsx(a.Flex,{fullWidth:!0,children:e.jsx(u.Toast,t.__assign({isPersistent:!0,onDismiss:function(t){var e;null===(e=null==s?void 0:s.onDismiss)||void 0===e||e.call(s,t),function(t,e){t.stopPropagation(),w(e)}(t,r)},toastKey:l},s,{children:0===n||W?i:""}))})},l)}))})]})]})]})};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zonos/amino",
3
- "version": "5.4.23",
3
+ "version": "5.4.25",
4
4
  "description": "Core UI components for Amino",
5
5
  "repository": "git@github.com:Zonos/amino.git",
6
6
  "license": "MIT",
@@ -1 +1,5 @@
1
- export declare const useNotify: () => import("../../components/toast/ToastContext").ToastContextFunctionType;
1
+ export declare const useNotify: () => {
2
+ notify: import("../../components/toast/ToastContext").ToastContextFunctionType;
3
+ dismissAllToasts: () => void;
4
+ dismissToast: (toastId: string) => void;
5
+ };