@razorpay/blade 12.33.2 → 12.34.0
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.
- package/build/lib/web/development/components/Toast/ToastContainer.web.js +12 -8
- package/build/lib/web/development/components/Toast/ToastContainer.web.js.map +1 -1
- package/build/lib/web/production/components/Toast/ToastContainer.web.js +12 -8
- package/build/lib/web/production/components/Toast/ToastContainer.web.js.map +1 -1
- package/build/types/components/index.d.ts +11 -1
- package/package.json +2 -2
|
@@ -20,7 +20,7 @@ import { metaAttribute } from '../../utils/metaAttribute/metaAttribute.web.js';
|
|
|
20
20
|
import { MetaConstants } from '../../utils/metaAttribute/metaConstants.js';
|
|
21
21
|
import { makeAnalyticsAttribute } from '../../utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js';
|
|
22
22
|
|
|
23
|
-
var _excluded = ["reverseOrder", "position", "toastOptions", "containerClassName"];
|
|
23
|
+
var _excluded = ["reverseOrder", "position", "offsetBottom", "toastOptions", "containerClassName"];
|
|
24
24
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
25
25
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
26
26
|
var StyledToastWrapper = /*#__PURE__*/styled(BaseBox).withConfig({
|
|
@@ -80,6 +80,7 @@ var Toaster = function Toaster(_ref2) {
|
|
|
80
80
|
var reverseOrder = _ref2.reverseOrder,
|
|
81
81
|
_ref2$position = _ref2.position,
|
|
82
82
|
position = _ref2$position === void 0 ? 'top-center' : _ref2$position,
|
|
83
|
+
offsetBottom = _ref2.offsetBottom,
|
|
83
84
|
toastOptions = _ref2.toastOptions,
|
|
84
85
|
containerClassName = _ref2.containerClassName,
|
|
85
86
|
rest = _objectWithoutProperties(_ref2, _excluded);
|
|
@@ -98,7 +99,8 @@ var Toaster = function Toaster(_ref2) {
|
|
|
98
99
|
setHasManuallyExpanded = _React$useState4[1];
|
|
99
100
|
var isMobile = useIsMobile();
|
|
100
101
|
var minToasts = isMobile ? MIN_TOAST_MOBILE : MIN_TOAST_DESKTOP;
|
|
101
|
-
var
|
|
102
|
+
var defaultGutter = isMobile ? CONTAINER_GUTTER_MOBILE : CONTAINER_GUTTER_DESKTOP;
|
|
103
|
+
var bottomGutter = offsetBottom !== null && offsetBottom !== void 0 ? offsetBottom : defaultGutter;
|
|
102
104
|
var infoToasts = React__default.useMemo(function () {
|
|
103
105
|
return toasts.filter(function (toast) {
|
|
104
106
|
return !isPromotionalToast(toast);
|
|
@@ -219,11 +221,11 @@ var Toaster = function Toaster(_ref2) {
|
|
|
219
221
|
return /*#__PURE__*/jsxs(BaseBox, _objectSpread(_objectSpread(_objectSpread({
|
|
220
222
|
position: "fixed",
|
|
221
223
|
zIndex: TOAST_Z_INDEX,
|
|
222
|
-
top: makeSize(
|
|
223
|
-
left: makeSize(
|
|
224
|
-
right: makeSize(
|
|
225
|
-
bottom: makeSize(
|
|
226
|
-
width: "calc(100% - ".concat(
|
|
224
|
+
top: makeSize(defaultGutter),
|
|
225
|
+
left: makeSize(defaultGutter),
|
|
226
|
+
right: makeSize(defaultGutter),
|
|
227
|
+
bottom: makeSize(bottomGutter),
|
|
228
|
+
width: "calc(100% - ".concat(defaultGutter * 2, "px)"),
|
|
227
229
|
maxWidth: makeSize(TOAST_MAX_WIDTH),
|
|
228
230
|
pointerEvents: "none",
|
|
229
231
|
className: containerClassName
|
|
@@ -304,8 +306,10 @@ var Toaster = function Toaster(_ref2) {
|
|
|
304
306
|
})]
|
|
305
307
|
}));
|
|
306
308
|
};
|
|
307
|
-
var ToastContainer = function ToastContainer() {
|
|
309
|
+
var ToastContainer = function ToastContainer(_ref4) {
|
|
310
|
+
var offsetBottom = _ref4.offsetBottom;
|
|
308
311
|
return /*#__PURE__*/jsx(Toaster, {
|
|
312
|
+
offsetBottom: offsetBottom,
|
|
309
313
|
position: "bottom-left"
|
|
310
314
|
});
|
|
311
315
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToastContainer.web.js","sources":["../../../../../../src/components/Toast/ToastContainer.web.tsx"],"sourcesContent":["import type { ToastPosition, ToasterProps, Toast } from 'react-hot-toast';\nimport { resolveValue, useToaster } from 'react-hot-toast';\nimport React from 'react';\nimport styled from 'styled-components';\nimport {\n PEEKS,\n MAX_TOASTS,\n SCALE_FACTOR,\n GUTTER,\n PEEK_GUTTER,\n TOAST_MAX_WIDTH,\n TOAST_Z_INDEX,\n MIN_TOAST_MOBILE,\n MIN_TOAST_DESKTOP,\n CONTAINER_GUTTER_MOBILE,\n CONTAINER_GUTTER_DESKTOP,\n} from './constants';\nimport { makeMotionTime, makeSize, useTheme } from '~utils';\nimport BaseBox from '~components/Box/BaseBox';\nimport type { Theme } from '~components/BladeProvider';\nimport { useIsMobile } from '~utils/useIsMobile';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\ntype CalculateYPositionProps = {\n toast: Toast;\n index: number;\n isExpanded: boolean;\n reverseOrder?: boolean;\n};\n\nconst StyledToastWrapper = styled(BaseBox)<{\n isVisible: boolean;\n index: number;\n isExpanded: boolean;\n isPromotional: boolean;\n}>(({ isVisible, index, isExpanded, isPromotional }) => {\n let opacity = isVisible ? 1 : 0;\n // Only make the PEEKING and MAX_TOASTS toasts visible,\n // Every other toasts should be hidden\n if (index < PEEKS + MAX_TOASTS) {\n opacity = 1;\n } else if (isPromotional || isExpanded) {\n opacity = 1;\n } else {\n opacity = 0;\n }\n\n return {\n '& > *': {\n pointerEvents: opacity === 1 ? 'auto' : 'none',\n },\n opacity,\n };\n});\n\nconst getPositionStyle = (\n position: ToastPosition,\n offset: number,\n scale: number,\n theme: Theme,\n): React.CSSProperties => {\n const top = position.includes('top');\n const verticalStyle: React.CSSProperties = top ? { top: 0 } : { bottom: 0 };\n const horizontalStyle: React.CSSProperties = position.includes('center')\n ? {\n justifyContent: 'center',\n }\n : position.includes('right')\n ? {\n justifyContent: 'flex-end',\n }\n : {};\n\n return {\n left: 0,\n right: 0,\n display: 'flex',\n position: 'absolute',\n transformOrigin: 'center',\n transition: `${makeMotionTime(theme.motion.duration.gentle)} ${theme.motion.easing.standard}`,\n transitionProperty: 'transform, opacity, height',\n transform: `translateY(${offset * (top ? 1 : -1)}px) scale(${scale})`,\n ...verticalStyle,\n ...horizontalStyle,\n };\n};\n\nfunction isPromotionalToast(toast: Toast): boolean {\n // @ts-expect-error\n return toast.type == 'promotional';\n}\n\nconst Toaster: React.FC<ToasterProps> = ({\n reverseOrder,\n position = 'top-center',\n toastOptions,\n containerClassName,\n ...rest\n}) => {\n const { toasts, handlers } = useToaster(toastOptions);\n const { theme } = useTheme();\n const [frontToastHeight, setFrontToastHeight] = React.useState(0);\n const [hasManuallyExpanded, setHasManuallyExpanded] = React.useState(false);\n const isMobile = useIsMobile();\n const minToasts = isMobile ? MIN_TOAST_MOBILE : MIN_TOAST_DESKTOP;\n const containerGutter = isMobile ? CONTAINER_GUTTER_MOBILE : CONTAINER_GUTTER_DESKTOP;\n\n const infoToasts = React.useMemo(() => toasts.filter((toast) => !isPromotionalToast(toast)), [\n toasts,\n ]);\n const promoToasts = React.useMemo(() => toasts.filter((toast) => isPromotionalToast(toast)), [\n toasts,\n ]);\n\n // always keep promo toasts at the bottom of the stack\n const recomputedToasts = React.useMemo(() => [...infoToasts, ...promoToasts], [\n infoToasts,\n promoToasts,\n ]);\n\n const hasPromoToast = promoToasts.length > 0 && promoToasts[0]?.visible;\n const promoToastHeight = promoToasts[0]?.height ?? 0;\n const isExpanded = hasManuallyExpanded || recomputedToasts.length <= minToasts;\n\n React.useLayoutEffect(() => {\n // find the first toast which is visible\n const firstToast = infoToasts.find((t, index) => t.visible && index === 0);\n if (firstToast) {\n setFrontToastHeight(firstToast.height ?? 0);\n }\n }, [infoToasts]);\n\n // calculate total height of all toasts\n const totalHeight = React.useMemo(() => {\n return (\n recomputedToasts\n // only consider visible recomputedToasts\n .filter((toast) => toast.visible)\n .reduce((prevHeight, toast) => prevHeight + (toast.height ?? 0), 0) +\n recomputedToasts.length * GUTTER\n );\n }, [recomputedToasts]);\n\n // Stacking logic explained in detail:\n // https://www.loom.com/share/522d9a445e2f41e1886cce4decb9ab9d?sid=4287acf6-8d44-431b-93e1-c1a0d40a0aba\n //\n // 1. 3 toasts can be stacked on top of each other\n // 2. After 3 toasts, the toasts will be scaled down and peek from behind\n // 3. There can be maximum of 3 toasts peeking from behind\n // 4. After 3 peeking toasts, the toasts will be hidden\n // 5. If there is a promo toast, all toasts will be lifted up\n // 6. Promo toasts will always be on the bottom\n const calculateYPosition = React.useCallback(\n ({ toast, index }: CalculateYPositionProps) => {\n // find the current toast index\n const toastIndex = infoToasts.findIndex((t) => t.id === toast.id);\n // number of toasts before this toast\n const toastsBefore = infoToasts.filter((toast, i) => i < toastIndex && toast.visible).length;\n\n let scale = Math.max(0.7, 1 - toastsBefore * SCALE_FACTOR);\n // first toast should always have a scale of 1\n if (index < MAX_TOASTS) {\n scale = 1;\n }\n\n // y position of toast,\n let offset = infoToasts\n .filter((toast) => toast.visible)\n .slice(0, toastsBefore)\n .reduce((y, toast) => {\n // if the toast is expanded, add the height of the toast + gutter\n if (isExpanded) {\n return y + (toast.height ?? 0) + GUTTER;\n }\n // if the toast is not expanded, add only the peek gutter\n return y + PEEK_GUTTER;\n }, 0);\n\n // lift all info toasts up if there is a promo toast\n if (hasPromoToast) {\n offset += GUTTER + promoToastHeight;\n }\n\n // if this is a promo toast, then put it at the bottom and force the scale to 1\n if (isPromotionalToast(toast)) {\n offset = 0;\n scale = 1;\n }\n\n return { offset, scale: isExpanded ? 1 : scale };\n },\n [hasPromoToast, infoToasts, isExpanded, promoToastHeight],\n );\n\n const handleMouseEnter = (): void => {\n if (isMobile) return;\n setHasManuallyExpanded(true);\n handlers.startPause();\n };\n\n const handleMouseLeave = (): void => {\n if (isMobile) return;\n setHasManuallyExpanded(false);\n handlers.endPause();\n };\n\n const handleToastClick = (): void => {\n if (!isMobile) return;\n setHasManuallyExpanded((prev) => {\n const next = !prev;\n if (next) {\n handlers.startPause();\n } else {\n handlers.endPause();\n }\n return next;\n });\n };\n\n return (\n <BaseBox\n position=\"fixed\"\n zIndex={TOAST_Z_INDEX}\n top={makeSize(containerGutter)}\n left={makeSize(containerGutter)}\n right={makeSize(containerGutter)}\n bottom={makeSize(containerGutter)}\n width={`calc(100% - ${containerGutter * 2}px)`}\n maxWidth={makeSize(TOAST_MAX_WIDTH)}\n pointerEvents=\"none\"\n className={containerClassName}\n {...metaAttribute({ name: MetaConstants.ToastContainer })}\n {...makeAnalyticsAttribute(rest)}\n >\n {/*\n * Mouseover container,\n * fills in the gap between toasts so that mouseleave doesn't trigger in the gaps\n */}\n <BaseBox\n position=\"absolute\"\n bottom={`${promoToastHeight}px`}\n left=\"0px\"\n width=\"100%\"\n pointerEvents={isExpanded ? 'all' : 'none'}\n height={makeSize(isExpanded ? totalHeight - promoToastHeight : frontToastHeight)}\n zIndex={-100}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n onClick={handleToastClick}\n {...metaAttribute({ testID: 'toast-mouseover-container' })}\n />\n {recomputedToasts.map((toast, index) => {\n const toastPosition = toast.position ?? position;\n const isPromotional = isPromotionalToast(toast);\n const { offset, scale } = calculateYPosition({\n toast,\n isExpanded,\n reverseOrder,\n index,\n });\n const positionStyle = getPositionStyle(toastPosition, offset, scale, theme);\n // recalculate height of toast\n const ref = (el: HTMLDivElement): void => {\n if (el && typeof toast.height !== 'number') {\n const height = el.getBoundingClientRect().height;\n handlers.updateHeight(toast.id, height);\n }\n };\n\n let toastHeight = toast.height;\n if (index > MAX_TOASTS - 1 && !isPromotional) {\n toastHeight = frontToastHeight;\n }\n if (isExpanded) {\n toastHeight = toast.height;\n }\n\n return (\n <StyledToastWrapper\n key={toast.id}\n index={index}\n ref={ref}\n isExpanded={isExpanded}\n isVisible={toast.visible}\n isPromotional={isPromotional}\n style={{\n ...positionStyle,\n zIndex: -1 * index,\n height: toastHeight,\n overflow: 'hidden',\n }}\n onMouseEnter={() => {\n if (isPromotional) return;\n handleMouseEnter();\n }}\n onMouseLeave={() => {\n if (isPromotional) return;\n handleMouseLeave();\n }}\n onClick={() => {\n if (isPromotional) return;\n handleToastClick();\n }}\n >\n <BaseBox height=\"fit-content\" width=\"100%\">\n {resolveValue(toast.message, { ...toast, index })}\n </BaseBox>\n </StyledToastWrapper>\n );\n })}\n </BaseBox>\n );\n};\n\nconst ToastContainer = (): React.ReactElement => {\n return <Toaster position=\"bottom-left\" />;\n};\n\nexport { ToastContainer };\n"],"names":["StyledToastWrapper","styled","BaseBox","withConfig","displayName","componentId","_ref","isVisible","index","isExpanded","isPromotional","opacity","PEEKS","MAX_TOASTS","pointerEvents","getPositionStyle","position","offset","scale","theme","top","includes","verticalStyle","bottom","horizontalStyle","justifyContent","_objectSpread","left","right","display","transformOrigin","transition","concat","makeMotionTime","motion","duration","gentle","easing","standard","transitionProperty","transform","isPromotionalToast","toast","type","Toaster","_ref2","_promoToasts$","_promoToasts$0$height","_promoToasts$2","reverseOrder","_ref2$position","toastOptions","containerClassName","rest","_objectWithoutProperties","_excluded","_useToaster","useToaster","toasts","handlers","_useTheme","useTheme","_React$useState","React","useState","_React$useState2","_slicedToArray","frontToastHeight","setFrontToastHeight","_React$useState3","_React$useState4","hasManuallyExpanded","setHasManuallyExpanded","isMobile","useIsMobile","minToasts","MIN_TOAST_MOBILE","MIN_TOAST_DESKTOP","containerGutter","CONTAINER_GUTTER_MOBILE","CONTAINER_GUTTER_DESKTOP","infoToasts","useMemo","filter","promoToasts","recomputedToasts","_toConsumableArray","hasPromoToast","length","visible","promoToastHeight","height","useLayoutEffect","firstToast","find","t","_firstToast$height","totalHeight","reduce","prevHeight","_toast$height","GUTTER","calculateYPosition","useCallback","_ref3","toastIndex","findIndex","id","toastsBefore","i","Math","max","SCALE_FACTOR","slice","y","_toast$height2","PEEK_GUTTER","handleMouseEnter","startPause","handleMouseLeave","endPause","handleToastClick","prev","next","_jsxs","zIndex","TOAST_Z_INDEX","makeSize","width","maxWidth","TOAST_MAX_WIDTH","className","metaAttribute","name","MetaConstants","ToastContainer","makeAnalyticsAttribute","children","_jsx","onMouseEnter","onMouseLeave","onClick","testID","map","_toast$position","toastPosition","_calculateYPosition","positionStyle","ref","el","getBoundingClientRect","updateHeight","toastHeight","style","overflow","resolveValue","message"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,IAAMA,kBAAkB,gBAAGC,MAAM,CAACC,OAAO,CAAC,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,uCAAA;EAAAC,WAAA,EAAA,UAAA;AAAA,CAKvC,CAAA,CAAA,UAAAC,IAAA,EAAqD;AAAA,EAAA,IAAlDC,SAAS,GAAAD,IAAA,CAATC,SAAS;IAAEC,KAAK,GAAAF,IAAA,CAALE,KAAK;IAAEC,UAAU,GAAAH,IAAA,CAAVG,UAAU;IAAEC,aAAa,GAAAJ,IAAA,CAAbI,aAAa,CAAA;AAC/C,EAAA,IAAIC,OAAO,GAAGJ,SAAS,GAAG,CAAC,GAAG,CAAC,CAAA;AAC/B;AACA;AACA,EAAA,IAAIC,KAAK,GAAGI,KAAK,GAAGC,UAAU,EAAE;AAC9BF,IAAAA,OAAO,GAAG,CAAC,CAAA;AACb,GAAC,MAAM,IAAID,aAAa,IAAID,UAAU,EAAE;AACtCE,IAAAA,OAAO,GAAG,CAAC,CAAA;AACb,GAAC,MAAM;AACLA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,IAAIjI,aAAa,EAAE,OAAA;AACnB2G,UAAAA,gBAAgB,EAAE,CAAA;SAClB;QACFuB,YAAY,EAAE,SAAAA,YAAAA,GAAM;AAClB,UAAA,IAAIlI,aAAa,EAAE,OAAA;AACnB6G,UAAAA,gBAAgB,EAAE,CAAA;SAClB;QACFsB,OAAO,EAAE,SAAAA,OAAAA,GAAM;AACb,UAAA,IAAInI,aAAa,EAAE,OAAA;AACnB+G,UAAAA,gBAAgB,EAAE,CAAA;SAClB;QAAAgB,QAAA,eAEFC,GAAA,CAACxI,OAAO,EAAA;AAACyF,UAAAA,MAAM,EAAC,aAAa;AAACqC,UAAAA,KAAK,EAAC,MAAM;UAAAS,QAAA,EACvCkB,YAAY,CAACjH,KAAK,CAACkH,OAAO,EAAAlI,aAAA,CAAAA,aAAA,CAAA,EAAA,EAAOgB,KAAK,CAAA,EAAA,EAAA,EAAA;AAAElC,YAAAA,KAAK,EAALA,KAAAA;WAAO,CAAA,CAAA;SACzC,CAAA;OA3BJkC,EAAAA,KAAK,CAACiE,EA4BO,CAAC,CAAA;AAEzB,KAAC,CAAC,CAAA;AAAA,GAAA,CACK,CAAC,CAAA;AAEd,CAAC,CAAA;AAED,IAAM4B,cAAc,GAAG,SAAjBA,cAAcA,GAA6B;EAC/C,oBAAOG,GAAA,CAAC9F,OAAO,EAAA;AAAC5B,IAAAA,QAAQ,EAAC,aAAA;AAAa,GAAE,CAAC,CAAA;AAC3C;;;;"}
|
|
1
|
+
{"version":3,"file":"ToastContainer.web.js","sources":["../../../../../../src/components/Toast/ToastContainer.web.tsx"],"sourcesContent":["import type { ToastPosition, ToasterProps, Toast } from 'react-hot-toast';\nimport { resolveValue, useToaster } from 'react-hot-toast';\nimport React from 'react';\nimport styled from 'styled-components';\nimport {\n PEEKS,\n MAX_TOASTS,\n SCALE_FACTOR,\n GUTTER,\n PEEK_GUTTER,\n TOAST_MAX_WIDTH,\n TOAST_Z_INDEX,\n MIN_TOAST_MOBILE,\n MIN_TOAST_DESKTOP,\n CONTAINER_GUTTER_MOBILE,\n CONTAINER_GUTTER_DESKTOP,\n} from './constants';\nimport { makeMotionTime, makeSize, useTheme } from '~utils';\nimport BaseBox from '~components/Box/BaseBox';\nimport type { Theme } from '~components/BladeProvider';\nimport { useIsMobile } from '~utils/useIsMobile';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\ntype CalculateYPositionProps = {\n toast: Toast;\n index: number;\n isExpanded: boolean;\n reverseOrder?: boolean;\n};\n\nconst StyledToastWrapper = styled(BaseBox)<{\n isVisible: boolean;\n index: number;\n isExpanded: boolean;\n isPromotional: boolean;\n}>(({ isVisible, index, isExpanded, isPromotional }) => {\n let opacity: number = isVisible ? 1 : 0;\n // Only make the PEEKING and MAX_TOASTS toasts visible,\n // Every other toasts should be hidden\n if (index < PEEKS + MAX_TOASTS) {\n opacity = 1;\n } else if (isPromotional || isExpanded) {\n opacity = 1;\n } else {\n opacity = 0;\n }\n\n return {\n '& > *': {\n pointerEvents: opacity === 1 ? 'auto' : 'none',\n },\n opacity,\n };\n});\n\nconst getPositionStyle = (\n position: ToastPosition,\n offset: number,\n scale: number,\n theme: Theme,\n): React.CSSProperties => {\n const top = position.includes('top');\n const verticalStyle: React.CSSProperties = top ? { top: 0 } : { bottom: 0 };\n const horizontalStyle: React.CSSProperties = position.includes('center')\n ? {\n justifyContent: 'center',\n }\n : position.includes('right')\n ? {\n justifyContent: 'flex-end',\n }\n : {};\n\n return {\n left: 0,\n right: 0,\n display: 'flex',\n position: 'absolute',\n transformOrigin: 'center',\n transition: `${makeMotionTime(theme.motion.duration.gentle)} ${theme.motion.easing.standard}`,\n transitionProperty: 'transform, opacity, height',\n transform: `translateY(${offset * (top ? 1 : -1)}px) scale(${scale})`,\n ...verticalStyle,\n ...horizontalStyle,\n };\n};\n\nfunction isPromotionalToast(toast: Toast): boolean {\n // @ts-expect-error\n return toast.type == 'promotional';\n}\n\nconst Toaster: React.FC<ToasterProps & { offsetBottom?: number }> = ({\n reverseOrder,\n position = 'top-center',\n offsetBottom,\n toastOptions,\n containerClassName,\n ...rest\n}) => {\n const { toasts, handlers } = useToaster(toastOptions);\n const { theme } = useTheme();\n const [frontToastHeight, setFrontToastHeight] = React.useState(0);\n const [hasManuallyExpanded, setHasManuallyExpanded] = React.useState(false);\n const isMobile = useIsMobile();\n const minToasts = isMobile ? MIN_TOAST_MOBILE : MIN_TOAST_DESKTOP;\n const defaultGutter = isMobile ? CONTAINER_GUTTER_MOBILE : CONTAINER_GUTTER_DESKTOP;\n const bottomGutter = offsetBottom ?? defaultGutter;\n\n const infoToasts = React.useMemo(() => toasts.filter((toast) => !isPromotionalToast(toast)), [\n toasts,\n ]);\n const promoToasts = React.useMemo(() => toasts.filter((toast) => isPromotionalToast(toast)), [\n toasts,\n ]);\n\n // always keep promo toasts at the bottom of the stack\n const recomputedToasts = React.useMemo(() => [...infoToasts, ...promoToasts], [\n infoToasts,\n promoToasts,\n ]);\n\n const hasPromoToast = promoToasts.length > 0 && promoToasts[0]?.visible;\n const promoToastHeight = promoToasts[0]?.height ?? 0;\n const isExpanded = hasManuallyExpanded || recomputedToasts.length <= minToasts;\n\n React.useLayoutEffect(() => {\n // find the first toast which is visible\n const firstToast = infoToasts.find((t, index) => t.visible && index === 0);\n if (firstToast) {\n setFrontToastHeight(firstToast.height ?? 0);\n }\n }, [infoToasts]);\n\n // calculate total height of all toasts\n const totalHeight = React.useMemo(() => {\n return (\n recomputedToasts\n // only consider visible recomputedToasts\n .filter((toast) => toast.visible)\n .reduce((prevHeight, toast) => prevHeight + (toast.height ?? 0), 0) +\n recomputedToasts.length * GUTTER\n );\n }, [recomputedToasts]);\n\n // Stacking logic explained in detail:\n // https://www.loom.com/share/522d9a445e2f41e1886cce4decb9ab9d?sid=4287acf6-8d44-431b-93e1-c1a0d40a0aba\n //\n // 1. 3 toasts can be stacked on top of each other\n // 2. After 3 toasts, the toasts will be scaled down and peek from behind\n // 3. There can be maximum of 3 toasts peeking from behind\n // 4. After 3 peeking toasts, the toasts will be hidden\n // 5. If there is a promo toast, all toasts will be lifted up\n // 6. Promo toasts will always be on the bottom\n const calculateYPosition = React.useCallback(\n ({ toast, index }: CalculateYPositionProps) => {\n // find the current toast index\n const toastIndex = infoToasts.findIndex((t) => t.id === toast.id);\n // number of toasts before this toast\n const toastsBefore = infoToasts.filter((toast, i) => i < toastIndex && toast.visible).length;\n\n let scale = Math.max(0.7, 1 - toastsBefore * SCALE_FACTOR);\n // first toast should always have a scale of 1\n if (index < MAX_TOASTS) {\n scale = 1;\n }\n\n // y position of toast,\n let offset = infoToasts\n .filter((toast) => toast.visible)\n .slice(0, toastsBefore)\n .reduce((y, toast) => {\n // if the toast is expanded, add the height of the toast + gutter\n if (isExpanded) {\n return y + (toast.height ?? 0) + GUTTER;\n }\n // if the toast is not expanded, add only the peek gutter\n return y + PEEK_GUTTER;\n }, 0);\n\n // lift all info toasts up if there is a promo toast\n if (hasPromoToast) {\n offset += GUTTER + promoToastHeight;\n }\n\n // if this is a promo toast, then put it at the bottom and force the scale to 1\n if (isPromotionalToast(toast)) {\n offset = 0;\n scale = 1;\n }\n\n return { offset, scale: isExpanded ? 1 : scale };\n },\n [hasPromoToast, infoToasts, isExpanded, promoToastHeight],\n );\n\n const handleMouseEnter = (): void => {\n if (isMobile) return;\n setHasManuallyExpanded(true);\n handlers.startPause();\n };\n\n const handleMouseLeave = (): void => {\n if (isMobile) return;\n setHasManuallyExpanded(false);\n handlers.endPause();\n };\n\n const handleToastClick = (): void => {\n if (!isMobile) return;\n setHasManuallyExpanded((prev) => {\n const next = !prev;\n if (next) {\n handlers.startPause();\n } else {\n handlers.endPause();\n }\n return next;\n });\n };\n\n return (\n <BaseBox\n position=\"fixed\"\n zIndex={TOAST_Z_INDEX}\n top={makeSize(defaultGutter)}\n left={makeSize(defaultGutter)}\n right={makeSize(defaultGutter)}\n bottom={makeSize(bottomGutter)}\n width={`calc(100% - ${defaultGutter * 2}px)`}\n maxWidth={makeSize(TOAST_MAX_WIDTH)}\n pointerEvents=\"none\"\n className={containerClassName}\n {...metaAttribute({ name: MetaConstants.ToastContainer })}\n {...makeAnalyticsAttribute(rest)}\n >\n {/*\n * Mouseover container,\n * fills in the gap between toasts so that mouseleave doesn't trigger in the gaps\n */}\n <BaseBox\n position=\"absolute\"\n bottom={`${promoToastHeight}px`}\n left=\"0px\"\n width=\"100%\"\n pointerEvents={isExpanded ? 'all' : 'none'}\n height={makeSize(isExpanded ? totalHeight - promoToastHeight : frontToastHeight)}\n zIndex={-100}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n onClick={handleToastClick}\n {...metaAttribute({ testID: 'toast-mouseover-container' })}\n />\n {recomputedToasts.map((toast, index) => {\n const toastPosition = toast.position ?? position;\n const isPromotional = isPromotionalToast(toast);\n const { offset, scale } = calculateYPosition({\n toast,\n isExpanded,\n reverseOrder,\n index,\n });\n const positionStyle = getPositionStyle(toastPosition, offset, scale, theme);\n // recalculate height of toast\n const ref = (el: HTMLDivElement): void => {\n if (el && typeof toast.height !== 'number') {\n const height = el.getBoundingClientRect().height;\n handlers.updateHeight(toast.id, height);\n }\n };\n\n let toastHeight = toast.height;\n if (index > MAX_TOASTS - 1 && !isPromotional) {\n toastHeight = frontToastHeight;\n }\n if (isExpanded) {\n toastHeight = toast.height;\n }\n\n return (\n <StyledToastWrapper\n key={toast.id}\n index={index}\n ref={ref}\n isExpanded={isExpanded}\n isVisible={toast.visible}\n isPromotional={isPromotional}\n style={{\n ...positionStyle,\n zIndex: -1 * index,\n height: toastHeight,\n overflow: 'hidden',\n }}\n onMouseEnter={() => {\n if (isPromotional) return;\n handleMouseEnter();\n }}\n onMouseLeave={() => {\n if (isPromotional) return;\n handleMouseLeave();\n }}\n onClick={() => {\n if (isPromotional) return;\n handleToastClick();\n }}\n >\n <BaseBox height=\"fit-content\" width=\"100%\">\n {resolveValue(toast.message, { ...toast, index })}\n </BaseBox>\n </StyledToastWrapper>\n );\n })}\n </BaseBox>\n );\n};\n\ntype ToastContainerProps = {\n /**\n * The offset from the bottom of the screen to the toast container.\n * This is useful when you want to position the toast container at a different\n * position from the bottom of the screen.\n *\n * @default isMobile ? 16px : 24px\n */\n offsetBottom?: number;\n};\n\nconst ToastContainer = ({ offsetBottom }: ToastContainerProps): React.ReactElement => {\n return <Toaster offsetBottom={offsetBottom} position=\"bottom-left\" />;\n};\n\nexport { ToastContainer };\n"],"names":["StyledToastWrapper","styled","BaseBox","withConfig","displayName","componentId","_ref","isVisible","index","isExpanded","isPromotional","opacity","PEEKS","MAX_TOASTS","pointerEvents","getPositionStyle","position","offset","scale","theme","top","includes","verticalStyle","bottom","horizontalStyle","justifyContent","_objectSpread","left","right","display","transformOrigin","transition","concat","makeMotionTime","motion","duration","gentle","easing","standard","transitionProperty","transform","isPromotionalToast","toast","type","Toaster","_ref2","_promoToasts$","_promoToasts$0$height","_promoToasts$2","reverseOrder","_ref2$position","offsetBottom","toastOptions","containerClassName","rest","_objectWithoutProperties","_excluded","_useToaster","useToaster","toasts","handlers","_useTheme","useTheme","_React$useState","React","useState","_React$useState2","_slicedToArray","frontToastHeight","setFrontToastHeight","_React$useState3","_React$useState4","hasManuallyExpanded","setHasManuallyExpanded","isMobile","useIsMobile","minToasts","MIN_TOAST_MOBILE","MIN_TOAST_DESKTOP","defaultGutter","CONTAINER_GUTTER_MOBILE","CONTAINER_GUTTER_DESKTOP","bottomGutter","infoToasts","useMemo","filter","promoToasts","recomputedToasts","_toConsumableArray","hasPromoToast","length","visible","promoToastHeight","height","useLayoutEffect","firstToast","find","t","_firstToast$height","totalHeight","reduce","prevHeight","_toast$height","GUTTER","calculateYPosition","useCallback","_ref3","toastIndex","findIndex","id","toastsBefore","i","Math","max","SCALE_FACTOR","slice","y","_toast$height2","PEEK_GUTTER","handleMouseEnter","startPause","handleMouseLeave","endPause","handleToastClick","prev","next","_jsxs","zIndex","TOAST_Z_INDEX","makeSize","width","maxWidth","TOAST_MAX_WIDTH","className","metaAttribute","name","MetaConstants","ToastContainer","makeAnalyticsAttribute","children","_jsx","onMouseEnter","onMouseLeave","onClick","testID","map","_toast$position","toastPosition","_calculateYPosition","positionStyle","ref","el","getBoundingClientRect","updateHeight","toastHeight","style","overflow","resolveValue","message","_ref4"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,IAAMA,kBAAkB,gBAAGC,MAAM,CAACC,OAAO,CAAC,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,uCAAA;EAAAC,WAAA,EAAA,UAAA;AAAA,CAKvC,CAAA,CAAA,UAAAC,IAAA,EAAqD;AAAA,EAAA,IAAlDC,SAAS,GAAAD,IAAA,CAATC,SAAS;IAAEC,KAAK,GAAAF,IAAA,CAALE,KAAK;IAAEC,UAAU,GAAAH,IAAA,CAAVG,UAAU;IAAEC,aAAa,GAAAJ,IAAA,CAAbI,aAAa,CAAA;AAC/C,EAAA,IAAIC,OAAe,GAAGJ,SAAS,GAAG,CAAC,GAAG,CAAC,CAAA;AACvC;AACA;AACA,EAAA,IAAIC,KAAK,GAAGI,KAAK,GAAGC,UAAU,EAAE;AAC9BF,IAAAA,OAAO,GAAG,CAAC,CAAA;AACb,GAAC,MAAM,IAAID,aAAa,IAAID,UAAU,EAAE;AACtCE,IAAAA,OAAO,GAAG,CAAC,CAAA;AACb,GAAC,MAAM;AACLA,IAAAA,OAAO,GAAG,CAAC,CAAA;AACb,GAAA;EAEA,OAAO;AACL,IAAA,OAAO,EAAE;AACPG,MAAAA,aAAa,EAAEH,OAAO,KAAK,CAAC,GAAG,MAAM,GAAG,MAAA;KACzC;AACDA,IAAAA,OAAO,EAAPA,OAAAA;GACD,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,IAAMI,gBAAgB,GAAG,SAAnBA,gBAAgBA,CACpBC,QAAuB,EACvBC,MAAc,EACdC,KAAa,EACbC,KAAY,EACY;AACxB,EAAA,IAAMC,GAAG,GAAGJ,QAAQ,CAACK,QAAQ,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SAAAA,OAAAA,GAAM;AACb,UAAA,IAAIrI,aAAa,EAAE,OAAA;AACnBiH,UAAAA,gBAAgB,EAAE,CAAA;SAClB;QAAAgB,QAAA,eAEFC,GAAA,CAAC1I,OAAO,EAAA;AAAC2F,UAAAA,MAAM,EAAC,aAAa;AAACqC,UAAAA,KAAK,EAAC,MAAM;UAAAS,QAAA,EACvCkB,YAAY,CAACnH,KAAK,CAACoH,OAAO,EAAApI,aAAA,CAAAA,aAAA,CAAA,EAAA,EAAOgB,KAAK,CAAA,EAAA,EAAA,EAAA;AAAElC,YAAAA,KAAK,EAALA,KAAAA;WAAO,CAAA,CAAA;SACzC,CAAA;OA3BJkC,EAAAA,KAAK,CAACmE,EA4BO,CAAC,CAAA;AAEzB,KAAC,CAAC,CAAA;AAAA,GAAA,CACK,CAAC,CAAA;AAEd,CAAC,CAAA;AAaD,IAAM4B,cAAc,GAAG,SAAjBA,cAAcA,CAAAsB,KAAA,EAAkE;AAAA,EAAA,IAA5D5G,YAAY,GAAA4G,KAAA,CAAZ5G,YAAY,CAAA;EACpC,oBAAOyF,GAAA,CAAChG,OAAO,EAAA;AAACO,IAAAA,YAAY,EAAEA,YAAa;AAACnC,IAAAA,QAAQ,EAAC,aAAA;AAAa,GAAE,CAAC,CAAA;AACvE;;;;"}
|
|
@@ -20,7 +20,7 @@ import { metaAttribute } from '../../utils/metaAttribute/metaAttribute.web.js';
|
|
|
20
20
|
import { MetaConstants } from '../../utils/metaAttribute/metaConstants.js';
|
|
21
21
|
import { makeAnalyticsAttribute } from '../../utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js';
|
|
22
22
|
|
|
23
|
-
var _excluded = ["reverseOrder", "position", "toastOptions", "containerClassName"];
|
|
23
|
+
var _excluded = ["reverseOrder", "position", "offsetBottom", "toastOptions", "containerClassName"];
|
|
24
24
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
25
25
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
26
26
|
var StyledToastWrapper = /*#__PURE__*/styled(BaseBox).withConfig({
|
|
@@ -80,6 +80,7 @@ var Toaster = function Toaster(_ref2) {
|
|
|
80
80
|
var reverseOrder = _ref2.reverseOrder,
|
|
81
81
|
_ref2$position = _ref2.position,
|
|
82
82
|
position = _ref2$position === void 0 ? 'top-center' : _ref2$position,
|
|
83
|
+
offsetBottom = _ref2.offsetBottom,
|
|
83
84
|
toastOptions = _ref2.toastOptions,
|
|
84
85
|
containerClassName = _ref2.containerClassName,
|
|
85
86
|
rest = _objectWithoutProperties(_ref2, _excluded);
|
|
@@ -98,7 +99,8 @@ var Toaster = function Toaster(_ref2) {
|
|
|
98
99
|
setHasManuallyExpanded = _React$useState4[1];
|
|
99
100
|
var isMobile = useIsMobile();
|
|
100
101
|
var minToasts = isMobile ? MIN_TOAST_MOBILE : MIN_TOAST_DESKTOP;
|
|
101
|
-
var
|
|
102
|
+
var defaultGutter = isMobile ? CONTAINER_GUTTER_MOBILE : CONTAINER_GUTTER_DESKTOP;
|
|
103
|
+
var bottomGutter = offsetBottom !== null && offsetBottom !== void 0 ? offsetBottom : defaultGutter;
|
|
102
104
|
var infoToasts = React__default.useMemo(function () {
|
|
103
105
|
return toasts.filter(function (toast) {
|
|
104
106
|
return !isPromotionalToast(toast);
|
|
@@ -219,11 +221,11 @@ var Toaster = function Toaster(_ref2) {
|
|
|
219
221
|
return /*#__PURE__*/jsxs(BaseBox, _objectSpread(_objectSpread(_objectSpread({
|
|
220
222
|
position: "fixed",
|
|
221
223
|
zIndex: TOAST_Z_INDEX,
|
|
222
|
-
top: makeSize(
|
|
223
|
-
left: makeSize(
|
|
224
|
-
right: makeSize(
|
|
225
|
-
bottom: makeSize(
|
|
226
|
-
width: "calc(100% - ".concat(
|
|
224
|
+
top: makeSize(defaultGutter),
|
|
225
|
+
left: makeSize(defaultGutter),
|
|
226
|
+
right: makeSize(defaultGutter),
|
|
227
|
+
bottom: makeSize(bottomGutter),
|
|
228
|
+
width: "calc(100% - ".concat(defaultGutter * 2, "px)"),
|
|
227
229
|
maxWidth: makeSize(TOAST_MAX_WIDTH),
|
|
228
230
|
pointerEvents: "none",
|
|
229
231
|
className: containerClassName
|
|
@@ -304,8 +306,10 @@ var Toaster = function Toaster(_ref2) {
|
|
|
304
306
|
})]
|
|
305
307
|
}));
|
|
306
308
|
};
|
|
307
|
-
var ToastContainer = function ToastContainer() {
|
|
309
|
+
var ToastContainer = function ToastContainer(_ref4) {
|
|
310
|
+
var offsetBottom = _ref4.offsetBottom;
|
|
308
311
|
return /*#__PURE__*/jsx(Toaster, {
|
|
312
|
+
offsetBottom: offsetBottom,
|
|
309
313
|
position: "bottom-left"
|
|
310
314
|
});
|
|
311
315
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToastContainer.web.js","sources":["../../../../../../src/components/Toast/ToastContainer.web.tsx"],"sourcesContent":["import type { ToastPosition, ToasterProps, Toast } from 'react-hot-toast';\nimport { resolveValue, useToaster } from 'react-hot-toast';\nimport React from 'react';\nimport styled from 'styled-components';\nimport {\n PEEKS,\n MAX_TOASTS,\n SCALE_FACTOR,\n GUTTER,\n PEEK_GUTTER,\n TOAST_MAX_WIDTH,\n TOAST_Z_INDEX,\n MIN_TOAST_MOBILE,\n MIN_TOAST_DESKTOP,\n CONTAINER_GUTTER_MOBILE,\n CONTAINER_GUTTER_DESKTOP,\n} from './constants';\nimport { makeMotionTime, makeSize, useTheme } from '~utils';\nimport BaseBox from '~components/Box/BaseBox';\nimport type { Theme } from '~components/BladeProvider';\nimport { useIsMobile } from '~utils/useIsMobile';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\ntype CalculateYPositionProps = {\n toast: Toast;\n index: number;\n isExpanded: boolean;\n reverseOrder?: boolean;\n};\n\nconst StyledToastWrapper = styled(BaseBox)<{\n isVisible: boolean;\n index: number;\n isExpanded: boolean;\n isPromotional: boolean;\n}>(({ isVisible, index, isExpanded, isPromotional }) => {\n let opacity = isVisible ? 1 : 0;\n // Only make the PEEKING and MAX_TOASTS toasts visible,\n // Every other toasts should be hidden\n if (index < PEEKS + MAX_TOASTS) {\n opacity = 1;\n } else if (isPromotional || isExpanded) {\n opacity = 1;\n } else {\n opacity = 0;\n }\n\n return {\n '& > *': {\n pointerEvents: opacity === 1 ? 'auto' : 'none',\n },\n opacity,\n };\n});\n\nconst getPositionStyle = (\n position: ToastPosition,\n offset: number,\n scale: number,\n theme: Theme,\n): React.CSSProperties => {\n const top = position.includes('top');\n const verticalStyle: React.CSSProperties = top ? { top: 0 } : { bottom: 0 };\n const horizontalStyle: React.CSSProperties = position.includes('center')\n ? {\n justifyContent: 'center',\n }\n : position.includes('right')\n ? {\n justifyContent: 'flex-end',\n }\n : {};\n\n return {\n left: 0,\n right: 0,\n display: 'flex',\n position: 'absolute',\n transformOrigin: 'center',\n transition: `${makeMotionTime(theme.motion.duration.gentle)} ${theme.motion.easing.standard}`,\n transitionProperty: 'transform, opacity, height',\n transform: `translateY(${offset * (top ? 1 : -1)}px) scale(${scale})`,\n ...verticalStyle,\n ...horizontalStyle,\n };\n};\n\nfunction isPromotionalToast(toast: Toast): boolean {\n // @ts-expect-error\n return toast.type == 'promotional';\n}\n\nconst Toaster: React.FC<ToasterProps> = ({\n reverseOrder,\n position = 'top-center',\n toastOptions,\n containerClassName,\n ...rest\n}) => {\n const { toasts, handlers } = useToaster(toastOptions);\n const { theme } = useTheme();\n const [frontToastHeight, setFrontToastHeight] = React.useState(0);\n const [hasManuallyExpanded, setHasManuallyExpanded] = React.useState(false);\n const isMobile = useIsMobile();\n const minToasts = isMobile ? MIN_TOAST_MOBILE : MIN_TOAST_DESKTOP;\n const containerGutter = isMobile ? CONTAINER_GUTTER_MOBILE : CONTAINER_GUTTER_DESKTOP;\n\n const infoToasts = React.useMemo(() => toasts.filter((toast) => !isPromotionalToast(toast)), [\n toasts,\n ]);\n const promoToasts = React.useMemo(() => toasts.filter((toast) => isPromotionalToast(toast)), [\n toasts,\n ]);\n\n // always keep promo toasts at the bottom of the stack\n const recomputedToasts = React.useMemo(() => [...infoToasts, ...promoToasts], [\n infoToasts,\n promoToasts,\n ]);\n\n const hasPromoToast = promoToasts.length > 0 && promoToasts[0]?.visible;\n const promoToastHeight = promoToasts[0]?.height ?? 0;\n const isExpanded = hasManuallyExpanded || recomputedToasts.length <= minToasts;\n\n React.useLayoutEffect(() => {\n // find the first toast which is visible\n const firstToast = infoToasts.find((t, index) => t.visible && index === 0);\n if (firstToast) {\n setFrontToastHeight(firstToast.height ?? 0);\n }\n }, [infoToasts]);\n\n // calculate total height of all toasts\n const totalHeight = React.useMemo(() => {\n return (\n recomputedToasts\n // only consider visible recomputedToasts\n .filter((toast) => toast.visible)\n .reduce((prevHeight, toast) => prevHeight + (toast.height ?? 0), 0) +\n recomputedToasts.length * GUTTER\n );\n }, [recomputedToasts]);\n\n // Stacking logic explained in detail:\n // https://www.loom.com/share/522d9a445e2f41e1886cce4decb9ab9d?sid=4287acf6-8d44-431b-93e1-c1a0d40a0aba\n //\n // 1. 3 toasts can be stacked on top of each other\n // 2. After 3 toasts, the toasts will be scaled down and peek from behind\n // 3. There can be maximum of 3 toasts peeking from behind\n // 4. After 3 peeking toasts, the toasts will be hidden\n // 5. If there is a promo toast, all toasts will be lifted up\n // 6. Promo toasts will always be on the bottom\n const calculateYPosition = React.useCallback(\n ({ toast, index }: CalculateYPositionProps) => {\n // find the current toast index\n const toastIndex = infoToasts.findIndex((t) => t.id === toast.id);\n // number of toasts before this toast\n const toastsBefore = infoToasts.filter((toast, i) => i < toastIndex && toast.visible).length;\n\n let scale = Math.max(0.7, 1 - toastsBefore * SCALE_FACTOR);\n // first toast should always have a scale of 1\n if (index < MAX_TOASTS) {\n scale = 1;\n }\n\n // y position of toast,\n let offset = infoToasts\n .filter((toast) => toast.visible)\n .slice(0, toastsBefore)\n .reduce((y, toast) => {\n // if the toast is expanded, add the height of the toast + gutter\n if (isExpanded) {\n return y + (toast.height ?? 0) + GUTTER;\n }\n // if the toast is not expanded, add only the peek gutter\n return y + PEEK_GUTTER;\n }, 0);\n\n // lift all info toasts up if there is a promo toast\n if (hasPromoToast) {\n offset += GUTTER + promoToastHeight;\n }\n\n // if this is a promo toast, then put it at the bottom and force the scale to 1\n if (isPromotionalToast(toast)) {\n offset = 0;\n scale = 1;\n }\n\n return { offset, scale: isExpanded ? 1 : scale };\n },\n [hasPromoToast, infoToasts, isExpanded, promoToastHeight],\n );\n\n const handleMouseEnter = (): void => {\n if (isMobile) return;\n setHasManuallyExpanded(true);\n handlers.startPause();\n };\n\n const handleMouseLeave = (): void => {\n if (isMobile) return;\n setHasManuallyExpanded(false);\n handlers.endPause();\n };\n\n const handleToastClick = (): void => {\n if (!isMobile) return;\n setHasManuallyExpanded((prev) => {\n const next = !prev;\n if (next) {\n handlers.startPause();\n } else {\n handlers.endPause();\n }\n return next;\n });\n };\n\n return (\n <BaseBox\n position=\"fixed\"\n zIndex={TOAST_Z_INDEX}\n top={makeSize(containerGutter)}\n left={makeSize(containerGutter)}\n right={makeSize(containerGutter)}\n bottom={makeSize(containerGutter)}\n width={`calc(100% - ${containerGutter * 2}px)`}\n maxWidth={makeSize(TOAST_MAX_WIDTH)}\n pointerEvents=\"none\"\n className={containerClassName}\n {...metaAttribute({ name: MetaConstants.ToastContainer })}\n {...makeAnalyticsAttribute(rest)}\n >\n {/*\n * Mouseover container,\n * fills in the gap between toasts so that mouseleave doesn't trigger in the gaps\n */}\n <BaseBox\n position=\"absolute\"\n bottom={`${promoToastHeight}px`}\n left=\"0px\"\n width=\"100%\"\n pointerEvents={isExpanded ? 'all' : 'none'}\n height={makeSize(isExpanded ? totalHeight - promoToastHeight : frontToastHeight)}\n zIndex={-100}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n onClick={handleToastClick}\n {...metaAttribute({ testID: 'toast-mouseover-container' })}\n />\n {recomputedToasts.map((toast, index) => {\n const toastPosition = toast.position ?? position;\n const isPromotional = isPromotionalToast(toast);\n const { offset, scale } = calculateYPosition({\n toast,\n isExpanded,\n reverseOrder,\n index,\n });\n const positionStyle = getPositionStyle(toastPosition, offset, scale, theme);\n // recalculate height of toast\n const ref = (el: HTMLDivElement): void => {\n if (el && typeof toast.height !== 'number') {\n const height = el.getBoundingClientRect().height;\n handlers.updateHeight(toast.id, height);\n }\n };\n\n let toastHeight = toast.height;\n if (index > MAX_TOASTS - 1 && !isPromotional) {\n toastHeight = frontToastHeight;\n }\n if (isExpanded) {\n toastHeight = toast.height;\n }\n\n return (\n <StyledToastWrapper\n key={toast.id}\n index={index}\n ref={ref}\n isExpanded={isExpanded}\n isVisible={toast.visible}\n isPromotional={isPromotional}\n style={{\n ...positionStyle,\n zIndex: -1 * index,\n height: toastHeight,\n overflow: 'hidden',\n }}\n onMouseEnter={() => {\n if (isPromotional) return;\n handleMouseEnter();\n }}\n onMouseLeave={() => {\n if (isPromotional) return;\n handleMouseLeave();\n }}\n onClick={() => {\n if (isPromotional) return;\n handleToastClick();\n }}\n >\n <BaseBox height=\"fit-content\" width=\"100%\">\n {resolveValue(toast.message, { ...toast, index })}\n </BaseBox>\n </StyledToastWrapper>\n );\n })}\n </BaseBox>\n );\n};\n\nconst ToastContainer = (): React.ReactElement => {\n return <Toaster position=\"bottom-left\" />;\n};\n\nexport { ToastContainer };\n"],"names":["StyledToastWrapper","styled","BaseBox","withConfig","displayName","componentId","_ref","isVisible","index","isExpanded","isPromotional","opacity","PEEKS","MAX_TOASTS","pointerEvents","getPositionStyle","position","offset","scale","theme","top","includes","verticalStyle","bottom","horizontalStyle","justifyContent","_objectSpread","left","right","display","transformOrigin","transition","concat","makeMotionTime","motion","duration","gentle","easing","standard","transitionProperty","transform","isPromotionalToast","toast","type","Toaster","_ref2","_promoToasts$","_promoToasts$0$height","_promoToasts$2","reverseOrder","_ref2$position","toastOptions","containerClassName","rest","_objectWithoutProperties","_excluded","_useToaster","useToaster","toasts","handlers","_useTheme","useTheme","_React$useState","React","useState","_React$useState2","_slicedToArray","frontToastHeight","setFrontToastHeight","_React$useState3","_React$useState4","hasManuallyExpanded","setHasManuallyExpanded","isMobile","useIsMobile","minToasts","MIN_TOAST_MOBILE","MIN_TOAST_DESKTOP","containerGutter","CONTAINER_GUTTER_MOBILE","CONTAINER_GUTTER_DESKTOP","infoToasts","useMemo","filter","promoToasts","recomputedToasts","_toConsumableArray","hasPromoToast","length","visible","promoToastHeight","height","useLayoutEffect","firstToast","find","t","_firstToast$height","totalHeight","reduce","prevHeight","_toast$height","GUTTER","calculateYPosition","useCallback","_ref3","toastIndex","findIndex","id","toastsBefore","i","Math","max","SCALE_FACTOR","slice","y","_toast$height2","PEEK_GUTTER","handleMouseEnter","startPause","handleMouseLeave","endPause","handleToastClick","prev","next","_jsxs","zIndex","TOAST_Z_INDEX","makeSize","width","maxWidth","TOAST_MAX_WIDTH","className","metaAttribute","name","MetaConstants","ToastContainer","makeAnalyticsAttribute","children","_jsx","onMouseEnter","onMouseLeave","onClick","testID","map","_toast$position","toastPosition","_calculateYPosition","positionStyle","ref","el","getBoundingClientRect","updateHeight","toastHeight","style","overflow","resolveValue","message"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,IAAMA,kBAAkB,gBAAGC,MAAM,CAACC,OAAO,CAAC,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,uCAAA;EAAAC,WAAA,EAAA,UAAA;AAAA,CAKvC,CAAA,CAA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M4B,cAAc,GAAG,SAAjBA,cAAcA,GAA6B;EAC/C,oBAAOG,GAAA,CAAC9F,OAAO,EAAA;AAAC5B,IAAAA,QAAQ,EAAC,aAAA;AAAa,GAAE,CAAC,CAAA;AAC3C;;;;"}
|
|
1
|
+
{"version":3,"file":"ToastContainer.web.js","sources":["../../../../../../src/components/Toast/ToastContainer.web.tsx"],"sourcesContent":["import type { ToastPosition, ToasterProps, Toast } from 'react-hot-toast';\nimport { resolveValue, useToaster } from 'react-hot-toast';\nimport React from 'react';\nimport styled from 'styled-components';\nimport {\n PEEKS,\n MAX_TOASTS,\n SCALE_FACTOR,\n GUTTER,\n PEEK_GUTTER,\n TOAST_MAX_WIDTH,\n TOAST_Z_INDEX,\n MIN_TOAST_MOBILE,\n MIN_TOAST_DESKTOP,\n CONTAINER_GUTTER_MOBILE,\n CONTAINER_GUTTER_DESKTOP,\n} from './constants';\nimport { makeMotionTime, makeSize, useTheme } from '~utils';\nimport BaseBox from '~components/Box/BaseBox';\nimport type { Theme } from '~components/BladeProvider';\nimport { useIsMobile } from '~utils/useIsMobile';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\ntype CalculateYPositionProps = {\n toast: Toast;\n index: number;\n isExpanded: boolean;\n reverseOrder?: boolean;\n};\n\nconst StyledToastWrapper = styled(BaseBox)<{\n isVisible: boolean;\n index: number;\n isExpanded: boolean;\n isPromotional: boolean;\n}>(({ isVisible, index, isExpanded, isPromotional }) => {\n let opacity: number = isVisible ? 1 : 0;\n // Only make the PEEKING and MAX_TOASTS toasts visible,\n // Every other toasts should be hidden\n if (index < PEEKS + MAX_TOASTS) {\n opacity = 1;\n } else if (isPromotional || isExpanded) {\n opacity = 1;\n } else {\n opacity = 0;\n }\n\n return {\n '& > *': {\n pointerEvents: opacity === 1 ? 'auto' : 'none',\n },\n opacity,\n };\n});\n\nconst getPositionStyle = (\n position: ToastPosition,\n offset: number,\n scale: number,\n theme: Theme,\n): React.CSSProperties => {\n const top = position.includes('top');\n const verticalStyle: React.CSSProperties = top ? { top: 0 } : { bottom: 0 };\n const horizontalStyle: React.CSSProperties = position.includes('center')\n ? {\n justifyContent: 'center',\n }\n : position.includes('right')\n ? {\n justifyContent: 'flex-end',\n }\n : {};\n\n return {\n left: 0,\n right: 0,\n display: 'flex',\n position: 'absolute',\n transformOrigin: 'center',\n transition: `${makeMotionTime(theme.motion.duration.gentle)} ${theme.motion.easing.standard}`,\n transitionProperty: 'transform, opacity, height',\n transform: `translateY(${offset * (top ? 1 : -1)}px) scale(${scale})`,\n ...verticalStyle,\n ...horizontalStyle,\n };\n};\n\nfunction isPromotionalToast(toast: Toast): boolean {\n // @ts-expect-error\n return toast.type == 'promotional';\n}\n\nconst Toaster: React.FC<ToasterProps & { offsetBottom?: number }> = ({\n reverseOrder,\n position = 'top-center',\n offsetBottom,\n toastOptions,\n containerClassName,\n ...rest\n}) => {\n const { toasts, handlers } = useToaster(toastOptions);\n const { theme } = useTheme();\n const [frontToastHeight, setFrontToastHeight] = React.useState(0);\n const [hasManuallyExpanded, setHasManuallyExpanded] = React.useState(false);\n const isMobile = useIsMobile();\n const minToasts = isMobile ? MIN_TOAST_MOBILE : MIN_TOAST_DESKTOP;\n const defaultGutter = isMobile ? CONTAINER_GUTTER_MOBILE : CONTAINER_GUTTER_DESKTOP;\n const bottomGutter = offsetBottom ?? defaultGutter;\n\n const infoToasts = React.useMemo(() => toasts.filter((toast) => !isPromotionalToast(toast)), [\n toasts,\n ]);\n const promoToasts = React.useMemo(() => toasts.filter((toast) => isPromotionalToast(toast)), [\n toasts,\n ]);\n\n // always keep promo toasts at the bottom of the stack\n const recomputedToasts = React.useMemo(() => [...infoToasts, ...promoToasts], [\n infoToasts,\n promoToasts,\n ]);\n\n const hasPromoToast = promoToasts.length > 0 && promoToasts[0]?.visible;\n const promoToastHeight = promoToasts[0]?.height ?? 0;\n const isExpanded = hasManuallyExpanded || recomputedToasts.length <= minToasts;\n\n React.useLayoutEffect(() => {\n // find the first toast which is visible\n const firstToast = infoToasts.find((t, index) => t.visible && index === 0);\n if (firstToast) {\n setFrontToastHeight(firstToast.height ?? 0);\n }\n }, [infoToasts]);\n\n // calculate total height of all toasts\n const totalHeight = React.useMemo(() => {\n return (\n recomputedToasts\n // only consider visible recomputedToasts\n .filter((toast) => toast.visible)\n .reduce((prevHeight, toast) => prevHeight + (toast.height ?? 0), 0) +\n recomputedToasts.length * GUTTER\n );\n }, [recomputedToasts]);\n\n // Stacking logic explained in detail:\n // https://www.loom.com/share/522d9a445e2f41e1886cce4decb9ab9d?sid=4287acf6-8d44-431b-93e1-c1a0d40a0aba\n //\n // 1. 3 toasts can be stacked on top of each other\n // 2. After 3 toasts, the toasts will be scaled down and peek from behind\n // 3. There can be maximum of 3 toasts peeking from behind\n // 4. After 3 peeking toasts, the toasts will be hidden\n // 5. If there is a promo toast, all toasts will be lifted up\n // 6. Promo toasts will always be on the bottom\n const calculateYPosition = React.useCallback(\n ({ toast, index }: CalculateYPositionProps) => {\n // find the current toast index\n const toastIndex = infoToasts.findIndex((t) => t.id === toast.id);\n // number of toasts before this toast\n const toastsBefore = infoToasts.filter((toast, i) => i < toastIndex && toast.visible).length;\n\n let scale = Math.max(0.7, 1 - toastsBefore * SCALE_FACTOR);\n // first toast should always have a scale of 1\n if (index < MAX_TOASTS) {\n scale = 1;\n }\n\n // y position of toast,\n let offset = infoToasts\n .filter((toast) => toast.visible)\n .slice(0, toastsBefore)\n .reduce((y, toast) => {\n // if the toast is expanded, add the height of the toast + gutter\n if (isExpanded) {\n return y + (toast.height ?? 0) + GUTTER;\n }\n // if the toast is not expanded, add only the peek gutter\n return y + PEEK_GUTTER;\n }, 0);\n\n // lift all info toasts up if there is a promo toast\n if (hasPromoToast) {\n offset += GUTTER + promoToastHeight;\n }\n\n // if this is a promo toast, then put it at the bottom and force the scale to 1\n if (isPromotionalToast(toast)) {\n offset = 0;\n scale = 1;\n }\n\n return { offset, scale: isExpanded ? 1 : scale };\n },\n [hasPromoToast, infoToasts, isExpanded, promoToastHeight],\n );\n\n const handleMouseEnter = (): void => {\n if (isMobile) return;\n setHasManuallyExpanded(true);\n handlers.startPause();\n };\n\n const handleMouseLeave = (): void => {\n if (isMobile) return;\n setHasManuallyExpanded(false);\n handlers.endPause();\n };\n\n const handleToastClick = (): void => {\n if (!isMobile) return;\n setHasManuallyExpanded((prev) => {\n const next = !prev;\n if (next) {\n handlers.startPause();\n } else {\n handlers.endPause();\n }\n return next;\n });\n };\n\n return (\n <BaseBox\n position=\"fixed\"\n zIndex={TOAST_Z_INDEX}\n top={makeSize(defaultGutter)}\n left={makeSize(defaultGutter)}\n right={makeSize(defaultGutter)}\n bottom={makeSize(bottomGutter)}\n width={`calc(100% - ${defaultGutter * 2}px)`}\n maxWidth={makeSize(TOAST_MAX_WIDTH)}\n pointerEvents=\"none\"\n className={containerClassName}\n {...metaAttribute({ name: MetaConstants.ToastContainer })}\n {...makeAnalyticsAttribute(rest)}\n >\n {/*\n * Mouseover container,\n * fills in the gap between toasts so that mouseleave doesn't trigger in the gaps\n */}\n <BaseBox\n position=\"absolute\"\n bottom={`${promoToastHeight}px`}\n left=\"0px\"\n width=\"100%\"\n pointerEvents={isExpanded ? 'all' : 'none'}\n height={makeSize(isExpanded ? totalHeight - promoToastHeight : frontToastHeight)}\n zIndex={-100}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n onClick={handleToastClick}\n {...metaAttribute({ testID: 'toast-mouseover-container' })}\n />\n {recomputedToasts.map((toast, index) => {\n const toastPosition = toast.position ?? position;\n const isPromotional = isPromotionalToast(toast);\n const { offset, scale } = calculateYPosition({\n toast,\n isExpanded,\n reverseOrder,\n index,\n });\n const positionStyle = getPositionStyle(toastPosition, offset, scale, theme);\n // recalculate height of toast\n const ref = (el: HTMLDivElement): void => {\n if (el && typeof toast.height !== 'number') {\n const height = el.getBoundingClientRect().height;\n handlers.updateHeight(toast.id, height);\n }\n };\n\n let toastHeight = toast.height;\n if (index > MAX_TOASTS - 1 && !isPromotional) {\n toastHeight = frontToastHeight;\n }\n if (isExpanded) {\n toastHeight = toast.height;\n }\n\n return (\n <StyledToastWrapper\n key={toast.id}\n index={index}\n ref={ref}\n isExpanded={isExpanded}\n isVisible={toast.visible}\n isPromotional={isPromotional}\n style={{\n ...positionStyle,\n zIndex: -1 * index,\n height: toastHeight,\n overflow: 'hidden',\n }}\n onMouseEnter={() => {\n if (isPromotional) return;\n handleMouseEnter();\n }}\n onMouseLeave={() => {\n if (isPromotional) return;\n handleMouseLeave();\n }}\n onClick={() => {\n if (isPromotional) return;\n handleToastClick();\n }}\n >\n <BaseBox height=\"fit-content\" width=\"100%\">\n {resolveValue(toast.message, { ...toast, index })}\n </BaseBox>\n </StyledToastWrapper>\n );\n })}\n </BaseBox>\n );\n};\n\ntype ToastContainerProps = {\n /**\n * The offset from the bottom of the screen to the toast container.\n * This is useful when you want to position the toast container at a different\n * position from the bottom of the screen.\n *\n * @default isMobile ? 16px : 24px\n */\n offsetBottom?: number;\n};\n\nconst ToastContainer = ({ offsetBottom }: ToastContainerProps): React.ReactElement => {\n return <Toaster offsetBottom={offsetBottom} position=\"bottom-left\" />;\n};\n\nexport { ToastContainer };\n"],"names":["StyledToastWrapper","styled","BaseBox","withConfig","displayName","componentId","_ref","isVisible","index","isExpanded","isPromotional","opacity","PEEKS","MAX_TOASTS","pointerEvents","getPositionStyle","position","offset","scale","theme","top","includes","verticalStyle","bottom","horizontalStyle","justifyContent","_objectSpread","left","right","display","transformOrigin","transition","concat","makeMotionTime","motion","duration","gentle","easing","standard","transitionProperty","transform","isPromotionalToast","toast","type","Toaster","_ref2","_promoToasts$","_promoToasts$0$height","_promoToasts$2","reverseOrder","_ref2$position","offsetBottom","toastOptions","containerClassName","rest","_objectWithoutProperties","_excluded","_useToaster","useToaster","toasts","handlers","_useTheme","useTheme","_React$useState","React","useState","_React$useState2","_slicedToArray","frontToastHeight","setFrontToastHeight","_React$useState3","_React$useState4","hasManuallyExpanded","setHasManuallyExpanded","isMobile","useIsMobile","minToasts","MIN_TOAST_MOBILE","MIN_TOAST_DESKTOP","defaultGutter","CONTAINER_GUTTER_MOBILE","CONTAINER_GUTTER_DESKTOP","bottomGutter","infoToasts","useMemo","filter","promoToasts","recomputedToasts","_toConsumableArray","hasPromoToast","length","visible","promoToastHeight","height","useLayoutEffect","firstToast","find","t","_firstToast$height","totalHeight","reduce","prevHeight","_toast$height","GUTTER","calculateYPosition","useCallback","_ref3","toastIndex","findIndex","id","toastsBefore","i","Math","max","SCALE_FACTOR","slice","y","_toast$height2","PEEK_GUTTER","handleMouseEnter","startPause","handleMouseLeave","endPause","handleToastClick","prev","next","_jsxs","zIndex","TOAST_Z_INDEX","makeSize","width","maxWidth","TOAST_MAX_WIDTH","className","metaAttribute","name","MetaConstants","ToastContainer","makeAnalyticsAttribute","children","_jsx","onMouseEnter","onMouseLeave","onClick","testID","map","_toast$position","toastPosition","_calculateYPosition","positionStyle","ref","el","getBoundingClientRect","updateHeight","toastHeight","style","overflow","resolveValue","message","_ref4"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,IAAMA,kBAAkB,gBAAGC,MAAM,CAACC,OAAO,CAAC,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,uCAAA;EAAAC,WAAA,EAAA,UAAA;AAAA,CAKvC,CAAA,CAAA,UAAAC,IAAA,EAAqD;AAAA,EAAA,IAAlDC,SAAS,GAAAD,IAAA,CAATC,SAAS;IAAEC,KAAK,GAAAF,IAAA,CAALE,KAAK;IAAEC,UAAU,GAAAH,IAAA,CAAVG,UAAU;IAAEC,aAAa,GAAAJ,IAAA,CAAbI,aAAa,CAAA;AAC/C,EAAA,IAAIC,OAAe,GAAGJ,SAAS,GAAG,CAAC,GAAG,CAAC,CAAA;AACvC;AACA;AACA,EAAA,IAAIC,KAAK,GAAGI,KAAK,GAAGC,UAAU,EAAE;AAC9BF,IAAAA,OAAO,GAAG,CAAC,CAA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QAAQ,EAAC,aAAA;AAAa,GAAE,CAAC,CAAA;AACvE;;;;"}
|
|
@@ -27236,7 +27236,17 @@ type TagProps = {
|
|
|
27236
27236
|
_isTagInsideInput?: boolean;
|
|
27237
27237
|
} & StyledPropsBlade & DataAnalyticsAttribute & TestID;
|
|
27238
27238
|
|
|
27239
|
-
|
|
27239
|
+
type ToastContainerProps = {
|
|
27240
|
+
/**
|
|
27241
|
+
* The offset from the bottom of the screen to the toast container.
|
|
27242
|
+
* This is useful when you want to position the toast container at a different
|
|
27243
|
+
* position from the bottom of the screen.
|
|
27244
|
+
*
|
|
27245
|
+
* @default isMobile ? 16px : 24px
|
|
27246
|
+
*/
|
|
27247
|
+
offsetBottom?: number;
|
|
27248
|
+
};
|
|
27249
|
+
declare const ToastContainer: ({ offsetBottom }: ToastContainerProps) => React__default.ReactElement;
|
|
27240
27250
|
|
|
27241
27251
|
type ToastProps = {
|
|
27242
27252
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@razorpay/blade",
|
|
3
3
|
"description": "The Design System that powers Razorpay",
|
|
4
|
-
"version": "12.
|
|
4
|
+
"version": "12.34.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=18.12.1"
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
"react:storybook:serve:test": "wait-on http://127.0.0.1:9009/ && yarn test:react:interaction",
|
|
117
117
|
"test:react:interaction": "cross-env FRAMEWORK=REACT test-storybook -c ./.storybook/react --url http://127.0.0.1:9009/",
|
|
118
118
|
"test:react:interaction:ci": "yarn react:storybook:build && run-p react:storybook:serve react:storybook:serve:test --race",
|
|
119
|
-
"test:react": "cross-env FRAMEWORK=REACT jest -c ./jest.web.config.js --shard=$SHARD --forceExit",
|
|
119
|
+
"test:react": "cross-env FRAMEWORK=REACT jest -c ./jest.web.config.js --shard=$SHARD --coverage --forceExit",
|
|
120
120
|
"test:react-native": "cross-env FRAMEWORK=REACT_NATIVE jest -c ./jest.native.config.js --shard=$SHARD --forceExit",
|
|
121
121
|
"start:ios": "cross-env NODE_OPTIONS=--openssl-legacy-provider run-p react-native:storybook:start react-native:storybook:ios",
|
|
122
122
|
"start:android": "cross-env NODE_OPTIONS=--openssl-legacy-provider run-p react-native:storybook:start react-native:storybook:android",
|