@zonos/amino 5.4.22 → 5.4.24
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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var o=require("../../_tslib-bd4862e8.js"),a=require("react"),n=require("react/jsx-runtime"),e=require("clsx"),
|
|
1
|
+
"use strict";var o=require("../../_tslib-bd4862e8.js"),a=require("react"),n=require("react/jsx-runtime"),e=require("clsx"),t=require("framer-motion"),i=require("../button/Button.js"),s=require("../flex/Flex.js"),r=require("../../icons/CheckCircleIcon.js"),m=require("../../icons/InfoIcon.js"),_=require("../../icons/RemoveCircleIcon.js"),l=require("../../icons/RemoveIcon.js"),u=require("../../icons/WarningIcon.js"),c=require("../../style-inject.es-d4ddeae4.js");function d(o){return o&&o.__esModule?o:{default:o}}require("../button/RippleGroup.js"),require("uuid"),require("../button/_Ripple.js"),require("../../utils/getAminoColor.js"),require("../../styles/constants/theme.js"),require("../button/useRipple.js"),require("../spinner/Spinner.js"),require("../../icons/icon-base/_IconBase.js");var T=d(e),g="Amino_Toast-module__aminoToast--Q7M1O",A="Amino_Toast-module__toastContent--C37MQ",f="Amino_Toast-module__toastIcon--Zo6w6",v="Amino_Toast-module__persistentToast--A93HB",h="Amino_Toast-module__dismissButton--HfPB9",M="Amino_Toast-module__aminoSuccessToast--M03g9",Q="Amino_Toast-module__aminoErrorToast--8Xban",j="Amino_Toast-module__aminoWarningToast--rFQsd",p="Amino_Toast-module__aminoInfoToast--HSKJi";c.styleInject(".Amino_Toast-module__aminoToast--Q7M1O{background:linear-gradient(90deg,#94969e66 0,#94969e00 50%),var(--amino-gray-1000);border-radius:var(--amino-radius-12);box-shadow:var(--amino-v3-shadow-large);color:var(--amino-gray-0);flex:1;font-weight:500;line-height:24px;padding:16px;-webkit-user-select:none;user-select:none;z-index:999999}.Amino_Toast-module__aminoToast--Q7M1O .Amino_Toast-module__toastContent--C37MQ{align-self:center}.Amino_Toast-module__aminoToast--Q7M1O .Amino_Toast-module__toastContent--C37MQ .Amino_Toast-module__toastIcon--Zo6w6{align-self:flex-start}.Amino_Toast-module__aminoToast--Q7M1O.Amino_Toast-module__persistentToast--A93HB{cursor:pointer}.Amino_Toast-module__aminoToast--Q7M1O.Amino_Toast-module__persistentToast--A93HB:hover{transform:scale(.95)}.Amino_Toast-module__aminoToast--Q7M1O .Amino_Toast-module__dismissButton--HfPB9{height:24px}.Amino_Toast-module__aminoToast--Q7M1O svg{color:var(--amino-gray-500)}[data-theme=night] .Amino_Toast-module__aminoToast--Q7M1O{background:linear-gradient(90deg,#94969e3d 0,#94969e00 50%),var(--amino-gray-50);color:var(--amino-gray-1000)}[data-theme=night] .Amino_Toast-module__aminoToast--Q7M1O svg{color:var(--amino-gray-600)}.Amino_Toast-module__aminoToast--Q7M1O.Amino_Toast-module__aminoSuccessToast--M03g9{background:linear-gradient(90deg,#56c76f66 0,#56c76f00 50%),var(--amino-gray-1000)}.Amino_Toast-module__aminoToast--Q7M1O.Amino_Toast-module__aminoSuccessToast--M03g9 svg{color:var(--amino-green-500)}[data-theme=night] .Amino_Toast-module__aminoToast--Q7M1O.Amino_Toast-module__aminoSuccessToast--M03g9{background:linear-gradient(90deg,#56c76f3d 0,#56c76f00 50%),var(--amino-gray-50)}[data-theme=night] .Amino_Toast-module__aminoToast--Q7M1O.Amino_Toast-module__aminoSuccessToast--M03g9 svg{color:var(--amino-green-600)}.Amino_Toast-module__aminoToast--Q7M1O.Amino_Toast-module__aminoErrorToast--8Xban{background:linear-gradient(90deg,#f95c6766 0,#f95c6700 50%),var(--amino-gray-1000)}.Amino_Toast-module__aminoToast--Q7M1O.Amino_Toast-module__aminoErrorToast--8Xban svg{color:var(--amino-red-500)}[data-theme=night] .Amino_Toast-module__aminoToast--Q7M1O.Amino_Toast-module__aminoErrorToast--8Xban{background:linear-gradient(90deg,#f95c673d 0,#f95c6700 50%),var(--amino-gray-50)}[data-theme=night] .Amino_Toast-module__aminoToast--Q7M1O.Amino_Toast-module__aminoErrorToast--8Xban svg{color:var(--amino-red-600)}.Amino_Toast-module__aminoToast--Q7M1O.Amino_Toast-module__aminoWarningToast--rFQsd{background:linear-gradient(90deg,#f88c5366 0,#f88c5300 50%),var(--amino-gray-1000)}.Amino_Toast-module__aminoToast--Q7M1O.Amino_Toast-module__aminoWarningToast--rFQsd svg{color:var(--amino-orange-500)}[data-theme=night] .Amino_Toast-module__aminoToast--Q7M1O.Amino_Toast-module__aminoWarningToast--rFQsd{background:linear-gradient(90deg,#f88c533d 0,#f88c5300 50%),var(--amino-gray-50)}[data-theme=night] .Amino_Toast-module__aminoToast--Q7M1O.Amino_Toast-module__aminoWarningToast--rFQsd svg{color:var(--amino-orange-600)}.Amino_Toast-module__aminoToast--Q7M1O.Amino_Toast-module__aminoInfoToast--HSKJi{background:linear-gradient(90deg,#5f92f666 0,#5f92f600 50%),var(--amino-gray-1000)}.Amino_Toast-module__aminoToast--Q7M1O.Amino_Toast-module__aminoInfoToast--HSKJi svg{color:var(--amino-blue-500)}[data-theme=night] .Amino_Toast-module__aminoToast--Q7M1O.Amino_Toast-module__aminoInfoToast--HSKJi{background:linear-gradient(90deg,#5f92f63d 0,#5f92f600 50%),var(--amino-gray-50)}[data-theme=night] .Amino_Toast-module__aminoToast--Q7M1O.Amino_Toast-module__aminoInfoToast--HSKJi svg{color:var(--amino-blue-600)}");exports.Toast=function(e){var c=e.actions,d=e.children,x=e.direction,b=e.intent,y=e.isPersistent,I=e.onDismiss,O=e.style,q=e.toastKey,k=function(){switch(x){case"top":return{opacity:0,translateX:0,translateY:-10};case"bottom":return{opacity:0,translateX:0,translateY:10};case"left":return{opacity:0,translateX:-10,translateY:0};default:return{opacity:0,translateX:10,translateY:0}}},C={animate:{opacity:1,translateX:0,translateY:0},exit:k(),initial:k()},S=function(){switch(b){case"success":return{class:M,icon:n.jsx(r.CheckCircleIcon,{})};case"error":return{class:Q,icon:n.jsx(_.RemoveCircleIcon,{})};case"warning":return{class:j,icon:n.jsx(u.WarningIcon,{})};case"info":return{class:p,icon:n.jsx(m.InfoIcon,{})};default:return{class:g,icon:n.jsx(m.InfoIcon,{})}}}();return a.createElement(t.motion.div,o.__assign({className:T.default(g,S.class,y&&v),layout:!0,style:o.__assign({},O)},C,{key:q}),n.jsxs(s.Flex,{alignItems:"flex-start",gap:12,justifyContent:"space-between",children:[n.jsxs(s.Flex,{alignItems:"center",className:A,gap:12,children:[n.jsx("div",{className:f,children:S.icon}),n.jsx("div",{children:d})]}),n.jsxs(s.Flex,{alignItems:"center",className:"toast-actions",gap:12,children:[c,y&&n.jsx(i.Button,{className:h,icon:n.jsx(l.RemoveIcon,{}),onClick:function(o){return null==I?void 0:I(o)},variant:"plain"})]})]}))};
|
|
@@ -5,7 +5,10 @@ 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<
|
|
8
|
+
export declare const ToastContext: import("react").Context<{
|
|
9
|
+
notify: ToastContextFunctionType;
|
|
10
|
+
dismissToast: (toastId: string) => void;
|
|
11
|
+
}>;
|
|
9
12
|
type Props = {
|
|
10
13
|
children: ReactNode;
|
|
11
14
|
};
|
|
@@ -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"),
|
|
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-",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({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=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);o.useEffect((function(){S.current&&R(S.current.offsetHeight)}),[z]);var D=o.useMemo((function(){return{dismissToast:w,notify:M}}),[w,M]);return e.jsxs(A.Provider,{value:D,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(K+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&&h),children:[!!j.length&&e.jsx(r.Button,{className:T,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,i=o.toast,r=o.uuid,l="persistent-toast-".concat(i,"-").concat(r);return e.jsx("div",{ref:0===n?S:null,className:C,onClick:G,onKeyDown:function(t){"Enter"!==t.key&&" "!==t.key||G(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 +1,4 @@
|
|
|
1
|
-
export declare const useNotify: () =>
|
|
1
|
+
export declare const useNotify: () => {
|
|
2
|
+
notify: import("../../components/toast/ToastContext").ToastContextFunctionType;
|
|
3
|
+
dismissToast: (toastId: string) => void;
|
|
4
|
+
};
|