@0xsquid/ui 0.15.1 → 0.15.3
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/dist/cjs/index.js +50 -44
- package/dist/cjs/types/components/layout/SwapStepsCollapsed.d.ts +4 -1
- package/dist/cjs/types/components/views/SwapProgressView.d.ts +0 -9
- package/dist/cjs/types/stories/views/SwapProgressView.stories.d.ts +2 -0
- package/dist/cjs/types/types/index.d.ts +1 -1
- package/dist/esm/index.js +51 -45
- package/dist/esm/types/components/layout/SwapStepsCollapsed.d.ts +4 -1
- package/dist/esm/types/components/views/SwapProgressView.d.ts +0 -9
- package/dist/esm/types/stories/views/SwapProgressView.stories.d.ts +2 -0
- package/dist/esm/types/types/index.d.ts +1 -1
- package/dist/index.css +40 -8
- package/dist/index.d.ts +10 -7
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -6878,23 +6878,15 @@ function SwapProgressViewHeader({ title, description, }) {
|
|
|
6878
6878
|
return (jsxRuntime.jsxs("header", { className: "tw-flex tw-h-[95px] tw-w-full tw-flex-col tw-gap-squid-s tw-bg-grey-800 tw-px-squid-m tw-py-squid-s", children: [jsxRuntime.jsx(BodyText, { size: "large", className: "tw-h-squid-m !tw-leading-[20px] tw-text-grey-300", children: title }), jsxRuntime.jsx(CaptionText, { className: "tw-h-squid-l tw-text-grey-500", children: description })] }));
|
|
6879
6879
|
}
|
|
6880
6880
|
|
|
6881
|
-
|
|
6881
|
+
const SwapStepsCollapsed = React.forwardRef(({ steps, currentStepIndex: _newStepIndex, onOpen, onClose }, ref) => {
|
|
6882
6882
|
const newStepIndex = Math.round(_newStepIndex);
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
setCurrentStepIndex(Math.round(newStepIndex));
|
|
6887
|
-
}, ANIMATION_DURATIONS.CHANGE_SWAP_STEP);
|
|
6888
|
-
return () => {
|
|
6889
|
-
clearTimeout(timeoutId);
|
|
6890
|
-
};
|
|
6891
|
-
}, [newStepIndex]);
|
|
6883
|
+
React.useImperativeHandle(ref, () => ({
|
|
6884
|
+
handleToggleRouteSteps,
|
|
6885
|
+
}));
|
|
6892
6886
|
// handles whether route component is mounted
|
|
6893
6887
|
const [isRouteVisible, setIsRouteVisible] = React.useState(false);
|
|
6894
6888
|
// handles whether route component is animating to show
|
|
6895
6889
|
const [isShowRouteAnimationRunning, setIsShowRouteAnimationRunning] = React.useState(false);
|
|
6896
|
-
steps[currentStepIndex];
|
|
6897
|
-
currentStepIndex === steps.length - 1;
|
|
6898
6890
|
React.useEffect(() => {
|
|
6899
6891
|
// we do not want to unmount the route component if the animation to show route is running
|
|
6900
6892
|
if (isShowRouteAnimationRunning)
|
|
@@ -6907,8 +6899,16 @@ function SwapStepsCollapsed({ steps, currentStepIndex: _newStepIndex, onOpen, on
|
|
|
6907
6899
|
clearTimeout(timeoutId);
|
|
6908
6900
|
};
|
|
6909
6901
|
}, [isShowRouteAnimationRunning]);
|
|
6902
|
+
const routeStepsListRef = React.useRef(null);
|
|
6910
6903
|
const handleToggleRouteSteps = () => {
|
|
6911
6904
|
if (isRouteVisible) {
|
|
6905
|
+
if (routeStepsListRef.current) {
|
|
6906
|
+
// reset scroll position of route steps list
|
|
6907
|
+
routeStepsListRef.current.scrollTo({
|
|
6908
|
+
top: routeStepsListRef.current.scrollHeight,
|
|
6909
|
+
behavior: 'instant',
|
|
6910
|
+
});
|
|
6911
|
+
}
|
|
6912
6912
|
setIsShowRouteAnimationRunning(false);
|
|
6913
6913
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
6914
6914
|
}
|
|
@@ -6918,33 +6918,35 @@ function SwapStepsCollapsed({ steps, currentStepIndex: _newStepIndex, onOpen, on
|
|
|
6918
6918
|
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
|
6919
6919
|
}
|
|
6920
6920
|
};
|
|
6921
|
-
return (jsxRuntime.jsx("div", { className: "tw-relative tw-h-[60px] tw-min-w-[400px] tw-rounded-squid-l", children: jsxRuntime.
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
[
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
: 'tw-
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
:
|
|
6936
|
-
? `transform ${ANIMATION_DURATIONS.
|
|
6937
|
-
:
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
:
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
|
|
6946
|
-
|
|
6947
|
-
|
|
6921
|
+
return (jsxRuntime.jsx("div", { className: "tw-relative tw-h-[60px] tw-min-w-[400px] tw-rounded-squid-l", children: jsxRuntime.jsx("div", { className: cn('tw-absolute tw-bottom-0 tw-z-10 tw-flex tw-w-full tw-max-w-[400px] tw-flex-col tw-justify-end tw-gap-squid-xxs tw-overflow-hidden tw-rounded-squid-l', isRouteVisible ? 'tw-h-[535px]' : 'tw-h-[60px]'), children: jsxRuntime.jsxs("div", { className: "tw-flex tw-flex-col tw-justify-end", children: [!isRouteVisible && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("span", { className: "tw-absolute tw-left-0 tw-top-0 tw-z-10 tw-h-[21px] tw-w-full tw-bg-gradient-to-b tw-from-grey-800 tw-transition-colors group-hover/swap-step-item-button:tw-from-grey-700" }), jsxRuntime.jsx("span", { className: "tw-absolute tw-bottom-0 tw-left-0 tw-z-10 tw-h-[21px] tw-w-full tw-bg-gradient-to-t tw-from-grey-800 tw-transition-colors group-hover/swap-step-item-button:tw-from-grey-700" })] })), jsxRuntime.jsx("div", { onClick: handleToggleRouteSteps, style: {
|
|
6922
|
+
[CSS_VARS.FADE_OUT_DURATION]: `${ANIMATION_DURATIONS.HIDE_ROUTE}ms`,
|
|
6923
|
+
[CSS_VARS.FADE_IN_DURATION]: `${ANIMATION_DURATIONS.SHOW_ROUTE}ms`,
|
|
6924
|
+
}, className: cn('tw-absolute tw-top-0 tw-h-[535px] tw-w-full tw-rounded-squid-l tw-bg-material-dark-thick tw-backdrop-blur/10 ', isShowRouteAnimationRunning
|
|
6925
|
+
? 'tw-animate-fade-in'
|
|
6926
|
+
: 'tw-animate-fade-out') }), jsxRuntime.jsx("div", { style: {
|
|
6927
|
+
zIndex: 20,
|
|
6928
|
+
display: isRouteVisible ? 'none' : 'block',
|
|
6929
|
+
}, onClick: handleToggleRouteSteps, className: "tw-absolute tw-inset-0 tw-h-[60px] tw-cursor-pointer tw-rounded-squid-l tw-border tw-border-material-light-thin" }), jsxRuntime.jsx("div", { onClick: isShowRouteAnimationRunning ? undefined : handleToggleRouteSteps, style: {
|
|
6930
|
+
[CSS_VARS.COLLAPSE_ROUTE_DURATION]: `${ANIMATION_DURATIONS.HIDE_ROUTE}ms`,
|
|
6931
|
+
[CSS_VARS.EXPAND_ROUTE_DURATION]: `${ANIMATION_DURATIONS.SHOW_ROUTE}ms`,
|
|
6932
|
+
}, className: cn('tw-relative tw-h-[60px] tw-max-h-[535px] tw-w-full tw-overflow-hidden tw-rounded-squid-l tw-border tw-border-material-light-thin tw-bg-grey-800 tw-backdrop-blur-2xl', isShowRouteAnimationRunning
|
|
6933
|
+
? 'tw-animate-expand-route'
|
|
6934
|
+
: 'tw-animate-collapse-route'), children: jsxRuntime.jsxs("div", { className: "tw-flex tw-max-h-[535px] tw-grow-0 tw-flex-col tw-gap-squid-xxs tw-pt-[52px]", style: {
|
|
6935
|
+
transition: isShowRouteAnimationRunning
|
|
6936
|
+
? `transform ${ANIMATION_DURATIONS.SHOW_ROUTE}ms ${ANIMATION_TIMINGS.CHANGE_SWAP_STEP}`
|
|
6937
|
+
: isRouteVisible
|
|
6938
|
+
? `transform ${ANIMATION_DURATIONS.HIDE_ROUTE}ms ${ANIMATION_TIMINGS.CHANGE_SWAP_STEP}`
|
|
6939
|
+
: `transform ${ANIMATION_DURATIONS.CHANGE_SWAP_STEP}ms ${ANIMATION_TIMINGS.CHANGE_SWAP_STEP}`,
|
|
6940
|
+
transform: isShowRouteAnimationRunning
|
|
6941
|
+
? 'translateY(0)'
|
|
6942
|
+
: `translateY(calc(-100% + 85px + ${(newStepIndex + 1) * 50}px))`,
|
|
6943
|
+
}, children: [jsxRuntime.jsx("div", { className: cn('tw-absolute tw-top-0 tw-z-10 tw-flex tw-h-[52px] tw-w-full tw-items-center tw-justify-center tw-gap-squid-xs tw-self-stretch tw-bg-transparent tw-p-squid-xs'), children: jsxRuntime.jsx("button", { onClick: handleToggleRouteSteps, className: "tw-flex tw-h-squid-xl tw-w-40 tw-items-center tw-justify-center tw-rounded-squid-xs tw-px-10 hover:tw-bg-material-light-thin", children: jsxRuntime.jsx("span", { className: "tw-flex tw-h-8 tw-w-8 tw-items-center tw-justify-center tw-text-grey-300", children: jsxRuntime.jsx(ChevronLargeDownIcon, { size: "32" }) }) }) }), jsxRuntime.jsx("ul", { ref: routeStepsListRef, style: {
|
|
6944
|
+
zIndex: isRouteVisible ? 0 : -10,
|
|
6945
|
+
scrollbarWidth: 'none',
|
|
6946
|
+
}, className: "tw-relative tw-flex tw-max-h-[413px] tw-w-[400px] tw-flex-1 tw-grow-0 tw-flex-col-reverse tw-items-center tw-self-stretch tw-overflow-y-auto tw-overflow-x-hidden tw-px-squid-xs tw-py-[15px]", children: steps.map((step, index) => (jsxRuntime.jsx(SwapStepItem, { descriptionBlocks: step.descriptionBlocks,
|
|
6947
|
+
// show separator for all steps except the first one
|
|
6948
|
+
showStepSeparator: index > 0, link: step.link, status: newStepIndex < index ? 'pending' : step.status }, index))) }), jsxRuntime.jsx("footer", { className: "tw-flex tw-w-full tw-items-end tw-justify-center tw-gap-squid-xs tw-self-stretch tw-p-squid-s", children: jsxRuntime.jsx(Button, { size: "md", variant: "secondary", label: "View on Squidscan", className: "tw-w-full" }) })] }) })] }) }) }));
|
|
6949
|
+
});
|
|
6948
6950
|
|
|
6949
6951
|
function TokenPair({ firstToken, secondToken }) {
|
|
6950
6952
|
return (jsxRuntime.jsxs("div", { className: "tw-relative tw-h-[42px] tw-w-[94px]", children: [jsxRuntime.jsxs("svg", { width: "94", height: "42", viewBox: "0 0 94 42", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "tw-absolute tw-z-10 tw-text-material-light-average", children: [jsxRuntime.jsx("g", { filter: "url(#filter0_b_457_51391)", children: jsxRuntime.jsx("path", { d: "M58.5042 35.4956L58.5043 35.4957C62.5071 39.4985 67.7544 41.5 73.0001 41.5C84.3219 41.5 93.5 32.3218 93.5 21C93.5 9.67822 84.3219 0.5 73.0001 0.5C67.7544 0.499977 62.5071 2.50151 58.5043 6.50431C57.9743 7.03437 57.4538 7.57007 56.9412 8.09756L56.9403 8.09852C55.2889 9.79812 53.7279 11.4027 52.097 12.5879C50.4734 13.7678 48.8225 14.5 47 14.5C45.1775 14.5 43.5266 13.7678 41.903 12.5879C40.2721 11.4027 38.7111 9.79812 37.0597 8.09852L37.0589 8.09766C36.5463 7.57013 36.0258 7.03441 35.4957 6.50431C31.4929 2.50151 26.2456 0.499977 20.9999 0.5C15.7543 0.500023 10.5071 2.50156 6.50431 6.50431C2.50153 10.5071 0.5 15.7544 0.5 21C0.5 26.2456 2.50153 31.4929 6.50431 35.4957C10.5071 39.4984 15.7543 41.5 20.9999 41.5C26.2456 41.5 31.4929 39.4985 35.4957 35.4957L35.4958 35.4956C36.023 34.968 36.5408 34.4349 37.0508 33.9099L37.0521 33.9086C38.7042 32.2077 40.2665 30.6013 41.8988 29.4147C43.5238 28.2333 45.1763 27.5 47 27.5C48.8237 27.5 50.4762 28.2333 52.1012 29.4147C53.7335 30.6013 55.2958 32.2077 56.9479 33.9086L56.9492 33.9099C57.4592 34.4349 57.977 34.968 58.5042 35.4956Z", stroke: "currentColor" }) }), jsxRuntime.jsx("defs", { children: jsxRuntime.jsxs("filter", { id: "filter0_b_457_51391", x: "-20", y: "-20", width: "134", height: "82", filterUnits: "userSpaceOnUse", "color-interpolation-filters": "sRGB", children: [jsxRuntime.jsx("feFlood", { "flood-opacity": "0", result: "BackgroundImageFix" }), jsxRuntime.jsx("feGaussianBlur", { in: "BackgroundImageFix", stdDeviation: "10" }), jsxRuntime.jsx("feComposite", { in2: "SourceAlpha", operator: "in", result: "effect1_backgroundBlur_457_51391" }), jsxRuntime.jsx("feBlend", { mode: "normal", in: "SourceGraphic", in2: "effect1_backgroundBlur_457_51391", result: "shape" })] }) })] }), jsxRuntime.jsxs("div", { className: "tw-token-pair-mask tw-z-10 tw-flex tw-h-full tw-w-full tw-items-center tw-justify-between", style: {
|
|
@@ -42281,7 +42283,11 @@ function SwapProgressView({ steps, isOpen = true, handleClose, handleComplete, s
|
|
|
42281
42283
|
headerDescription,
|
|
42282
42284
|
};
|
|
42283
42285
|
}, [swapState, fromToken, toToken, toAmount, toChain]);
|
|
42284
|
-
|
|
42286
|
+
const trackTransactionViewRef = React.useRef(null);
|
|
42287
|
+
const handleCollapseRouteSteps = () => { var _a; return (_a = trackTransactionViewRef.current) === null || _a === void 0 ? void 0 : _a.handleToggleRouteSteps(); };
|
|
42288
|
+
return (jsxRuntime.jsxs(Modal, { isOpen: isOpen, onBackdropClick:
|
|
42289
|
+
// close route steps modal when open and backdrop is clicked
|
|
42290
|
+
!showSwapInfoSection ? handleCollapseRouteSteps : handleClose, children: [jsxRuntime.jsxs(ModalContent, { style: {
|
|
42285
42291
|
[CSS_VARS.SCALE_AND_FADE_DOWN_DURATION]: `${ANIMATION_DURATIONS.SHOW_ROUTE}ms`,
|
|
42286
42292
|
[CSS_VARS.SCALE_AND_FADE_UP_DURATION]: `${ANIMATION_DURATIONS.HIDE_ROUTE}ms`,
|
|
42287
42293
|
}, borderType: "outline", className: cn('!tw-max-h-[470px]',
|
|
@@ -42299,9 +42305,9 @@ function SwapProgressView({ steps, isOpen = true, handleClose, handleComplete, s
|
|
|
42299
42305
|
}, secondToken: {
|
|
42300
42306
|
bgColor: toToken.bgColor,
|
|
42301
42307
|
imageUrl: toToken.logoUrl,
|
|
42302
|
-
} })) }), jsxRuntime.jsx(SwapProgressViewHeader, { title: headerTitle, description: headerDescription }), jsxRuntime.jsxs("ul", { className: "tw-flex tw-h-[195px] tw-w-full tw-flex-col tw-items-center tw-justify-center tw-gap-squid-xxs tw-rounded-squid-l tw-py-squid-s", children: [jsxRuntime.jsx(SwapDetailListItem, { icon: jsxRuntime.jsx(ArrowsSwapIcon, {}), label: "Swap", detail: jsxRuntime.jsx(SwapDetailItemValues, { fromContent: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("img", { className: "tw-h-squid-m tw-w-squid-m tw-rounded-full", src: fromToken.logoUrl }), jsxRuntime.jsx(CaptionText, { children: fromAmount })] }), toContent: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("img", { className: "tw-h-squid-m tw-w-squid-m tw-rounded-full", src: toToken.logoUrl }), jsxRuntime.jsx(CaptionText, { children: toAmount })] }) }) }), jsxRuntime.jsx(SwapDetailListItem, { icon: jsxRuntime.jsx(ChainLink, { size: "24", strokeWidth: "1.5" }), label: "Chain", detail: jsxRuntime.jsx(SwapDetailItemValues, { fromContent: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("img", { className: "tw-h-squid-m tw-w-squid-m tw-rounded-squid-xxs", src: fromChain.logoUrl }), jsxRuntime.jsx(CaptionText, { children: fromChain.networkName })] }), toContent: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("img", { className: "tw-h-squid-m tw-w-squid-m tw-rounded-squid-xxs", src: toChain.logoUrl }), jsxRuntime.jsx(CaptionText, { children: toChain.networkName })] }) }) }), jsxRuntime.jsx(SwapDetailListItem, { icon: jsxRuntime.jsx(WalletFilledIcon, { size: "24" }), label: "Wallet", detail: jsxRuntime.jsx(SwapDetailItemValues, { fromContent: fromAddressFormatted, toContent: toAddressFormatted }) }), jsxRuntime.jsx(SwapDetailListItem, { icon: jsxRuntime.jsx(TimeFliesIcon, {}), label: "Time to complete", detail: swapState === SwapState.PROGRESS ? (jsxRuntime.jsx(SwapDetailItemValues, { fromContent: timer, toContent: estimatedTimeToComplete })) : swapState === SwapState.COMPLETED ? (jsxRuntime.jsx(CaptionText, { children: timer })) : (jsxRuntime.jsx(CaptionText, { children: estimatedTimeToComplete })) })] })] }), jsxRuntime.jsx(TrackTransactionView, { onTxEnd: () => stopTimer(), onTxStart: () => startTimer(), rawSteps: steps, onClose: handleRouteStepsClosed, onOpen: handleRouteStepsOpen, swapState: swapState }), swapState === SwapState.PARTIAL_SUCCESS ? (jsxRuntime.jsxs("div", { className: "tw-flex tw-w-full tw-items-center tw-gap-squid-xxs", children: [jsxRuntime.jsx(Button, { size: "lg", variant: "secondary", label: swapProgressButtonTexts[swapState], onClick: handleClose, className: "tw-min-h-button" }), jsxRuntime.jsx(Button, { size: "lg", variant: "primary", label: "Complete", onClick: handleComplete, className: "tw-min-h-button" })] })) : (jsxRuntime.jsx(Button, { size: "lg", variant: "primary", label: swapProgressButtonTexts[swapState], onClick: handleClose, className: "tw-min-h-button" }))] }));
|
|
42308
|
+
} })) }), jsxRuntime.jsx(SwapProgressViewHeader, { title: headerTitle, description: headerDescription }), jsxRuntime.jsxs("ul", { className: "tw-flex tw-h-[195px] tw-w-full tw-flex-col tw-items-center tw-justify-center tw-gap-squid-xxs tw-rounded-squid-l tw-py-squid-s", children: [jsxRuntime.jsx(SwapDetailListItem, { icon: jsxRuntime.jsx(ArrowsSwapIcon, {}), label: "Swap", detail: jsxRuntime.jsx(SwapDetailItemValues, { fromContent: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("img", { className: "tw-h-squid-m tw-w-squid-m tw-rounded-full", src: fromToken.logoUrl }), jsxRuntime.jsx(CaptionText, { children: fromAmount })] }), toContent: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("img", { className: "tw-h-squid-m tw-w-squid-m tw-rounded-full", src: toToken.logoUrl }), jsxRuntime.jsx(CaptionText, { children: toAmount })] }) }) }), jsxRuntime.jsx(SwapDetailListItem, { icon: jsxRuntime.jsx(ChainLink, { size: "24", strokeWidth: "1.5" }), label: "Chain", detail: jsxRuntime.jsx(SwapDetailItemValues, { fromContent: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("img", { className: "tw-h-squid-m tw-w-squid-m tw-rounded-squid-xxs", src: fromChain.logoUrl }), jsxRuntime.jsx(CaptionText, { children: fromChain.networkName })] }), toContent: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("img", { className: "tw-h-squid-m tw-w-squid-m tw-rounded-squid-xxs", src: toChain.logoUrl }), jsxRuntime.jsx(CaptionText, { children: toChain.networkName })] }) }) }), jsxRuntime.jsx(SwapDetailListItem, { icon: jsxRuntime.jsx(WalletFilledIcon, { size: "24" }), label: "Wallet", detail: jsxRuntime.jsx(SwapDetailItemValues, { fromContent: fromAddressFormatted, toContent: toAddressFormatted }) }), jsxRuntime.jsx(SwapDetailListItem, { icon: jsxRuntime.jsx(TimeFliesIcon, {}), label: "Time to complete", detail: swapState === SwapState.PROGRESS ? (jsxRuntime.jsx(SwapDetailItemValues, { fromContent: timer, toContent: estimatedTimeToComplete })) : swapState === SwapState.COMPLETED ? (jsxRuntime.jsx(CaptionText, { children: timer })) : (jsxRuntime.jsx(CaptionText, { children: estimatedTimeToComplete })) })] })] }), jsxRuntime.jsx(TrackTransactionView, { ref: trackTransactionViewRef, onTxEnd: () => stopTimer(), onTxStart: () => startTimer(), rawSteps: steps, onClose: handleRouteStepsClosed, onOpen: handleRouteStepsOpen, swapState: swapState }), !showSwapInfoSection ? (jsxRuntime.jsx(Button, { size: "lg", variant: "primary", label: "Cancel", onClick: handleCollapseRouteSteps, className: "tw-min-h-button" })) : swapState === SwapState.PARTIAL_SUCCESS ? (jsxRuntime.jsxs("div", { className: "tw-flex tw-w-full tw-items-center tw-gap-squid-xxs", children: [jsxRuntime.jsx(Button, { size: "lg", variant: "secondary", label: swapProgressButtonTexts[swapState], onClick: handleClose, className: "tw-min-h-button" }), jsxRuntime.jsx(Button, { size: "lg", variant: "primary", label: "Complete", onClick: handleComplete, className: "tw-min-h-button" })] })) : (jsxRuntime.jsx(Button, { size: "lg", variant: "primary", label: swapProgressButtonTexts[swapState], onClick: handleClose, className: "tw-min-h-button" }))] }));
|
|
42303
42309
|
}
|
|
42304
|
-
const TrackTransactionView = ({ swapState, rawSteps, onOpen, onClose, onTxStart, onTxEnd,
|
|
42310
|
+
const TrackTransactionView = React.forwardRef(({ swapState, rawSteps, onOpen, onClose, onTxStart, onTxEnd }, ref) => {
|
|
42305
42311
|
const { currentStepIndex, steps } = React.useMemo(() => {
|
|
42306
42312
|
if (swapState === SwapState.COMPLETED) {
|
|
42307
42313
|
onTxEnd();
|
|
@@ -42340,8 +42346,8 @@ const TrackTransactionView = ({ swapState, rawSteps, onOpen, onClose, onTxStart,
|
|
|
42340
42346
|
currentStepIndex: 0,
|
|
42341
42347
|
};
|
|
42342
42348
|
}, [swapState, rawSteps]);
|
|
42343
|
-
return rawSteps.length > 0 ? (jsxRuntime.jsx(SwapStepsCollapsed, { steps: steps, currentStepIndex: currentStepIndex, onClose: onClose, onOpen: onOpen })) : null;
|
|
42344
|
-
};
|
|
42349
|
+
return rawSteps.length > 0 ? (jsxRuntime.jsx(SwapStepsCollapsed, { ref: ref, steps: steps, currentStepIndex: currentStepIndex, onClose: onClose, onOpen: onOpen })) : null;
|
|
42350
|
+
});
|
|
42345
42351
|
const SwapDetailItemValues = ({ fromContent, toContent, }) => {
|
|
42346
42352
|
return (jsxRuntime.jsxs("div", { className: "tw-flex tw-items-center tw-justify-center tw-gap-squid-xxs", children: [typeof fromContent === 'string' ? (jsxRuntime.jsx(CaptionText, { children: fromContent })) : (fromContent), jsxRuntime.jsx("span", { className: "tw-text-grey-500", children: jsxRuntime.jsx(ChevronLargeRightIcon, {}) }), typeof toContent === 'string' ? (jsxRuntime.jsx(CaptionText, { children: toContent })) : (toContent)] }));
|
|
42347
42353
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { SwapStep } from '../../types/components';
|
|
2
3
|
interface SwapStepsCollapsedProps {
|
|
3
4
|
steps: SwapStep[];
|
|
@@ -5,5 +6,7 @@ interface SwapStepsCollapsedProps {
|
|
|
5
6
|
onOpen?: () => void;
|
|
6
7
|
onClose?: () => void;
|
|
7
8
|
}
|
|
8
|
-
export declare
|
|
9
|
+
export declare const SwapStepsCollapsed: import("react").ForwardRefExoticComponent<SwapStepsCollapsedProps & import("react").RefAttributes<{
|
|
10
|
+
handleToggleRouteSteps: () => void;
|
|
11
|
+
}>>;
|
|
9
12
|
export {};
|
|
@@ -27,13 +27,4 @@ export declare function SwapProgressView({ steps, isOpen, handleClose, handleCom
|
|
|
27
27
|
swapState: SwapState;
|
|
28
28
|
estimatedTimeToComplete?: string;
|
|
29
29
|
}): import("react/jsx-runtime").JSX.Element;
|
|
30
|
-
interface Props {
|
|
31
|
-
rawSteps: SwapStep[];
|
|
32
|
-
swapState?: SwapState;
|
|
33
|
-
onOpen?: () => void;
|
|
34
|
-
onClose?: () => void;
|
|
35
|
-
onTxStart: () => void;
|
|
36
|
-
onTxEnd: () => void;
|
|
37
|
-
}
|
|
38
|
-
export declare const TrackTransactionView: ({ swapState, rawSteps, onOpen, onClose, onTxStart, onTxEnd, }: Props) => import("react/jsx-runtime").JSX.Element | null;
|
|
39
30
|
export {};
|
|
@@ -4,6 +4,8 @@ declare const meta: Meta<typeof SwapProgressView>;
|
|
|
4
4
|
export default meta;
|
|
5
5
|
type Story = StoryObj<typeof meta>;
|
|
6
6
|
export declare const WithControls: Story;
|
|
7
|
+
export declare const ShortRoute: Story;
|
|
8
|
+
export declare const LongRoute: Story;
|
|
7
9
|
export declare const Completed: Story;
|
|
8
10
|
export declare const Error: Story;
|
|
9
11
|
export declare const Confirm: Story;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export type { SquidTheme } from './config';
|
|
2
|
-
export type { SwapState, ThemeType, SwapStep } from './components';
|
|
2
|
+
export type { SwapState, ThemeType, SwapStep, SwapStepItemStatus, } from './components';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { useMemo, useRef, useState, useEffect, useCallback } from 'react';
|
|
3
|
+
import { useMemo, useRef, useState, useEffect, useCallback, forwardRef, useImperativeHandle } from 'react';
|
|
4
4
|
|
|
5
5
|
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
6
6
|
|
|
@@ -6858,23 +6858,15 @@ function SwapProgressViewHeader({ title, description, }) {
|
|
|
6858
6858
|
return (jsxs("header", { className: "tw-flex tw-h-[95px] tw-w-full tw-flex-col tw-gap-squid-s tw-bg-grey-800 tw-px-squid-m tw-py-squid-s", children: [jsx(BodyText, { size: "large", className: "tw-h-squid-m !tw-leading-[20px] tw-text-grey-300", children: title }), jsx(CaptionText, { className: "tw-h-squid-l tw-text-grey-500", children: description })] }));
|
|
6859
6859
|
}
|
|
6860
6860
|
|
|
6861
|
-
|
|
6861
|
+
const SwapStepsCollapsed = forwardRef(({ steps, currentStepIndex: _newStepIndex, onOpen, onClose }, ref) => {
|
|
6862
6862
|
const newStepIndex = Math.round(_newStepIndex);
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
setCurrentStepIndex(Math.round(newStepIndex));
|
|
6867
|
-
}, ANIMATION_DURATIONS.CHANGE_SWAP_STEP);
|
|
6868
|
-
return () => {
|
|
6869
|
-
clearTimeout(timeoutId);
|
|
6870
|
-
};
|
|
6871
|
-
}, [newStepIndex]);
|
|
6863
|
+
useImperativeHandle(ref, () => ({
|
|
6864
|
+
handleToggleRouteSteps,
|
|
6865
|
+
}));
|
|
6872
6866
|
// handles whether route component is mounted
|
|
6873
6867
|
const [isRouteVisible, setIsRouteVisible] = useState(false);
|
|
6874
6868
|
// handles whether route component is animating to show
|
|
6875
6869
|
const [isShowRouteAnimationRunning, setIsShowRouteAnimationRunning] = useState(false);
|
|
6876
|
-
steps[currentStepIndex];
|
|
6877
|
-
currentStepIndex === steps.length - 1;
|
|
6878
6870
|
useEffect(() => {
|
|
6879
6871
|
// we do not want to unmount the route component if the animation to show route is running
|
|
6880
6872
|
if (isShowRouteAnimationRunning)
|
|
@@ -6887,8 +6879,16 @@ function SwapStepsCollapsed({ steps, currentStepIndex: _newStepIndex, onOpen, on
|
|
|
6887
6879
|
clearTimeout(timeoutId);
|
|
6888
6880
|
};
|
|
6889
6881
|
}, [isShowRouteAnimationRunning]);
|
|
6882
|
+
const routeStepsListRef = useRef(null);
|
|
6890
6883
|
const handleToggleRouteSteps = () => {
|
|
6891
6884
|
if (isRouteVisible) {
|
|
6885
|
+
if (routeStepsListRef.current) {
|
|
6886
|
+
// reset scroll position of route steps list
|
|
6887
|
+
routeStepsListRef.current.scrollTo({
|
|
6888
|
+
top: routeStepsListRef.current.scrollHeight,
|
|
6889
|
+
behavior: 'instant',
|
|
6890
|
+
});
|
|
6891
|
+
}
|
|
6892
6892
|
setIsShowRouteAnimationRunning(false);
|
|
6893
6893
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
6894
6894
|
}
|
|
@@ -6898,33 +6898,35 @@ function SwapStepsCollapsed({ steps, currentStepIndex: _newStepIndex, onOpen, on
|
|
|
6898
6898
|
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
|
6899
6899
|
}
|
|
6900
6900
|
};
|
|
6901
|
-
return (jsx("div", { className: "tw-relative tw-h-[60px] tw-min-w-[400px] tw-rounded-squid-l", children:
|
|
6902
|
-
|
|
6903
|
-
|
|
6904
|
-
|
|
6905
|
-
|
|
6906
|
-
|
|
6907
|
-
|
|
6908
|
-
|
|
6909
|
-
[
|
|
6910
|
-
|
|
6911
|
-
|
|
6912
|
-
: 'tw-
|
|
6913
|
-
|
|
6914
|
-
|
|
6915
|
-
:
|
|
6916
|
-
? `transform ${ANIMATION_DURATIONS.
|
|
6917
|
-
:
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
:
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
|
|
6901
|
+
return (jsx("div", { className: "tw-relative tw-h-[60px] tw-min-w-[400px] tw-rounded-squid-l", children: jsx("div", { className: cn('tw-absolute tw-bottom-0 tw-z-10 tw-flex tw-w-full tw-max-w-[400px] tw-flex-col tw-justify-end tw-gap-squid-xxs tw-overflow-hidden tw-rounded-squid-l', isRouteVisible ? 'tw-h-[535px]' : 'tw-h-[60px]'), children: jsxs("div", { className: "tw-flex tw-flex-col tw-justify-end", children: [!isRouteVisible && (jsxs(Fragment, { children: [jsx("span", { className: "tw-absolute tw-left-0 tw-top-0 tw-z-10 tw-h-[21px] tw-w-full tw-bg-gradient-to-b tw-from-grey-800 tw-transition-colors group-hover/swap-step-item-button:tw-from-grey-700" }), jsx("span", { className: "tw-absolute tw-bottom-0 tw-left-0 tw-z-10 tw-h-[21px] tw-w-full tw-bg-gradient-to-t tw-from-grey-800 tw-transition-colors group-hover/swap-step-item-button:tw-from-grey-700" })] })), jsx("div", { onClick: handleToggleRouteSteps, style: {
|
|
6902
|
+
[CSS_VARS.FADE_OUT_DURATION]: `${ANIMATION_DURATIONS.HIDE_ROUTE}ms`,
|
|
6903
|
+
[CSS_VARS.FADE_IN_DURATION]: `${ANIMATION_DURATIONS.SHOW_ROUTE}ms`,
|
|
6904
|
+
}, className: cn('tw-absolute tw-top-0 tw-h-[535px] tw-w-full tw-rounded-squid-l tw-bg-material-dark-thick tw-backdrop-blur/10 ', isShowRouteAnimationRunning
|
|
6905
|
+
? 'tw-animate-fade-in'
|
|
6906
|
+
: 'tw-animate-fade-out') }), jsx("div", { style: {
|
|
6907
|
+
zIndex: 20,
|
|
6908
|
+
display: isRouteVisible ? 'none' : 'block',
|
|
6909
|
+
}, onClick: handleToggleRouteSteps, className: "tw-absolute tw-inset-0 tw-h-[60px] tw-cursor-pointer tw-rounded-squid-l tw-border tw-border-material-light-thin" }), jsx("div", { onClick: isShowRouteAnimationRunning ? undefined : handleToggleRouteSteps, style: {
|
|
6910
|
+
[CSS_VARS.COLLAPSE_ROUTE_DURATION]: `${ANIMATION_DURATIONS.HIDE_ROUTE}ms`,
|
|
6911
|
+
[CSS_VARS.EXPAND_ROUTE_DURATION]: `${ANIMATION_DURATIONS.SHOW_ROUTE}ms`,
|
|
6912
|
+
}, className: cn('tw-relative tw-h-[60px] tw-max-h-[535px] tw-w-full tw-overflow-hidden tw-rounded-squid-l tw-border tw-border-material-light-thin tw-bg-grey-800 tw-backdrop-blur-2xl', isShowRouteAnimationRunning
|
|
6913
|
+
? 'tw-animate-expand-route'
|
|
6914
|
+
: 'tw-animate-collapse-route'), children: jsxs("div", { className: "tw-flex tw-max-h-[535px] tw-grow-0 tw-flex-col tw-gap-squid-xxs tw-pt-[52px]", style: {
|
|
6915
|
+
transition: isShowRouteAnimationRunning
|
|
6916
|
+
? `transform ${ANIMATION_DURATIONS.SHOW_ROUTE}ms ${ANIMATION_TIMINGS.CHANGE_SWAP_STEP}`
|
|
6917
|
+
: isRouteVisible
|
|
6918
|
+
? `transform ${ANIMATION_DURATIONS.HIDE_ROUTE}ms ${ANIMATION_TIMINGS.CHANGE_SWAP_STEP}`
|
|
6919
|
+
: `transform ${ANIMATION_DURATIONS.CHANGE_SWAP_STEP}ms ${ANIMATION_TIMINGS.CHANGE_SWAP_STEP}`,
|
|
6920
|
+
transform: isShowRouteAnimationRunning
|
|
6921
|
+
? 'translateY(0)'
|
|
6922
|
+
: `translateY(calc(-100% + 85px + ${(newStepIndex + 1) * 50}px))`,
|
|
6923
|
+
}, children: [jsx("div", { className: cn('tw-absolute tw-top-0 tw-z-10 tw-flex tw-h-[52px] tw-w-full tw-items-center tw-justify-center tw-gap-squid-xs tw-self-stretch tw-bg-transparent tw-p-squid-xs'), children: jsx("button", { onClick: handleToggleRouteSteps, className: "tw-flex tw-h-squid-xl tw-w-40 tw-items-center tw-justify-center tw-rounded-squid-xs tw-px-10 hover:tw-bg-material-light-thin", children: jsx("span", { className: "tw-flex tw-h-8 tw-w-8 tw-items-center tw-justify-center tw-text-grey-300", children: jsx(ChevronLargeDownIcon, { size: "32" }) }) }) }), jsx("ul", { ref: routeStepsListRef, style: {
|
|
6924
|
+
zIndex: isRouteVisible ? 0 : -10,
|
|
6925
|
+
scrollbarWidth: 'none',
|
|
6926
|
+
}, className: "tw-relative tw-flex tw-max-h-[413px] tw-w-[400px] tw-flex-1 tw-grow-0 tw-flex-col-reverse tw-items-center tw-self-stretch tw-overflow-y-auto tw-overflow-x-hidden tw-px-squid-xs tw-py-[15px]", children: steps.map((step, index) => (jsx(SwapStepItem, { descriptionBlocks: step.descriptionBlocks,
|
|
6927
|
+
// show separator for all steps except the first one
|
|
6928
|
+
showStepSeparator: index > 0, link: step.link, status: newStepIndex < index ? 'pending' : step.status }, index))) }), jsx("footer", { className: "tw-flex tw-w-full tw-items-end tw-justify-center tw-gap-squid-xs tw-self-stretch tw-p-squid-s", children: jsx(Button, { size: "md", variant: "secondary", label: "View on Squidscan", className: "tw-w-full" }) })] }) })] }) }) }));
|
|
6929
|
+
});
|
|
6928
6930
|
|
|
6929
6931
|
function TokenPair({ firstToken, secondToken }) {
|
|
6930
6932
|
return (jsxs("div", { className: "tw-relative tw-h-[42px] tw-w-[94px]", children: [jsxs("svg", { width: "94", height: "42", viewBox: "0 0 94 42", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "tw-absolute tw-z-10 tw-text-material-light-average", children: [jsx("g", { filter: "url(#filter0_b_457_51391)", children: jsx("path", { d: "M58.5042 35.4956L58.5043 35.4957C62.5071 39.4985 67.7544 41.5 73.0001 41.5C84.3219 41.5 93.5 32.3218 93.5 21C93.5 9.67822 84.3219 0.5 73.0001 0.5C67.7544 0.499977 62.5071 2.50151 58.5043 6.50431C57.9743 7.03437 57.4538 7.57007 56.9412 8.09756L56.9403 8.09852C55.2889 9.79812 53.7279 11.4027 52.097 12.5879C50.4734 13.7678 48.8225 14.5 47 14.5C45.1775 14.5 43.5266 13.7678 41.903 12.5879C40.2721 11.4027 38.7111 9.79812 37.0597 8.09852L37.0589 8.09766C36.5463 7.57013 36.0258 7.03441 35.4957 6.50431C31.4929 2.50151 26.2456 0.499977 20.9999 0.5C15.7543 0.500023 10.5071 2.50156 6.50431 6.50431C2.50153 10.5071 0.5 15.7544 0.5 21C0.5 26.2456 2.50153 31.4929 6.50431 35.4957C10.5071 39.4984 15.7543 41.5 20.9999 41.5C26.2456 41.5 31.4929 39.4985 35.4957 35.4957L35.4958 35.4956C36.023 34.968 36.5408 34.4349 37.0508 33.9099L37.0521 33.9086C38.7042 32.2077 40.2665 30.6013 41.8988 29.4147C43.5238 28.2333 45.1763 27.5 47 27.5C48.8237 27.5 50.4762 28.2333 52.1012 29.4147C53.7335 30.6013 55.2958 32.2077 56.9479 33.9086L56.9492 33.9099C57.4592 34.4349 57.977 34.968 58.5042 35.4956Z", stroke: "currentColor" }) }), jsx("defs", { children: jsxs("filter", { id: "filter0_b_457_51391", x: "-20", y: "-20", width: "134", height: "82", filterUnits: "userSpaceOnUse", "color-interpolation-filters": "sRGB", children: [jsx("feFlood", { "flood-opacity": "0", result: "BackgroundImageFix" }), jsx("feGaussianBlur", { in: "BackgroundImageFix", stdDeviation: "10" }), jsx("feComposite", { in2: "SourceAlpha", operator: "in", result: "effect1_backgroundBlur_457_51391" }), jsx("feBlend", { mode: "normal", in: "SourceGraphic", in2: "effect1_backgroundBlur_457_51391", result: "shape" })] }) })] }), jsxs("div", { className: "tw-token-pair-mask tw-z-10 tw-flex tw-h-full tw-w-full tw-items-center tw-justify-between", style: {
|
|
@@ -42261,7 +42263,11 @@ function SwapProgressView({ steps, isOpen = true, handleClose, handleComplete, s
|
|
|
42261
42263
|
headerDescription,
|
|
42262
42264
|
};
|
|
42263
42265
|
}, [swapState, fromToken, toToken, toAmount, toChain]);
|
|
42264
|
-
|
|
42266
|
+
const trackTransactionViewRef = useRef(null);
|
|
42267
|
+
const handleCollapseRouteSteps = () => { var _a; return (_a = trackTransactionViewRef.current) === null || _a === void 0 ? void 0 : _a.handleToggleRouteSteps(); };
|
|
42268
|
+
return (jsxs(Modal, { isOpen: isOpen, onBackdropClick:
|
|
42269
|
+
// close route steps modal when open and backdrop is clicked
|
|
42270
|
+
!showSwapInfoSection ? handleCollapseRouteSteps : handleClose, children: [jsxs(ModalContent, { style: {
|
|
42265
42271
|
[CSS_VARS.SCALE_AND_FADE_DOWN_DURATION]: `${ANIMATION_DURATIONS.SHOW_ROUTE}ms`,
|
|
42266
42272
|
[CSS_VARS.SCALE_AND_FADE_UP_DURATION]: `${ANIMATION_DURATIONS.HIDE_ROUTE}ms`,
|
|
42267
42273
|
}, borderType: "outline", className: cn('!tw-max-h-[470px]',
|
|
@@ -42279,9 +42285,9 @@ function SwapProgressView({ steps, isOpen = true, handleClose, handleComplete, s
|
|
|
42279
42285
|
}, secondToken: {
|
|
42280
42286
|
bgColor: toToken.bgColor,
|
|
42281
42287
|
imageUrl: toToken.logoUrl,
|
|
42282
|
-
} })) }), jsx(SwapProgressViewHeader, { title: headerTitle, description: headerDescription }), jsxs("ul", { className: "tw-flex tw-h-[195px] tw-w-full tw-flex-col tw-items-center tw-justify-center tw-gap-squid-xxs tw-rounded-squid-l tw-py-squid-s", children: [jsx(SwapDetailListItem, { icon: jsx(ArrowsSwapIcon, {}), label: "Swap", detail: jsx(SwapDetailItemValues, { fromContent: jsxs(Fragment, { children: [jsx("img", { className: "tw-h-squid-m tw-w-squid-m tw-rounded-full", src: fromToken.logoUrl }), jsx(CaptionText, { children: fromAmount })] }), toContent: jsxs(Fragment, { children: [jsx("img", { className: "tw-h-squid-m tw-w-squid-m tw-rounded-full", src: toToken.logoUrl }), jsx(CaptionText, { children: toAmount })] }) }) }), jsx(SwapDetailListItem, { icon: jsx(ChainLink, { size: "24", strokeWidth: "1.5" }), label: "Chain", detail: jsx(SwapDetailItemValues, { fromContent: jsxs(Fragment, { children: [jsx("img", { className: "tw-h-squid-m tw-w-squid-m tw-rounded-squid-xxs", src: fromChain.logoUrl }), jsx(CaptionText, { children: fromChain.networkName })] }), toContent: jsxs(Fragment, { children: [jsx("img", { className: "tw-h-squid-m tw-w-squid-m tw-rounded-squid-xxs", src: toChain.logoUrl }), jsx(CaptionText, { children: toChain.networkName })] }) }) }), jsx(SwapDetailListItem, { icon: jsx(WalletFilledIcon, { size: "24" }), label: "Wallet", detail: jsx(SwapDetailItemValues, { fromContent: fromAddressFormatted, toContent: toAddressFormatted }) }), jsx(SwapDetailListItem, { icon: jsx(TimeFliesIcon, {}), label: "Time to complete", detail: swapState === SwapState.PROGRESS ? (jsx(SwapDetailItemValues, { fromContent: timer, toContent: estimatedTimeToComplete })) : swapState === SwapState.COMPLETED ? (jsx(CaptionText, { children: timer })) : (jsx(CaptionText, { children: estimatedTimeToComplete })) })] })] }), jsx(TrackTransactionView, { onTxEnd: () => stopTimer(), onTxStart: () => startTimer(), rawSteps: steps, onClose: handleRouteStepsClosed, onOpen: handleRouteStepsOpen, swapState: swapState }), swapState === SwapState.PARTIAL_SUCCESS ? (jsxs("div", { className: "tw-flex tw-w-full tw-items-center tw-gap-squid-xxs", children: [jsx(Button, { size: "lg", variant: "secondary", label: swapProgressButtonTexts[swapState], onClick: handleClose, className: "tw-min-h-button" }), jsx(Button, { size: "lg", variant: "primary", label: "Complete", onClick: handleComplete, className: "tw-min-h-button" })] })) : (jsx(Button, { size: "lg", variant: "primary", label: swapProgressButtonTexts[swapState], onClick: handleClose, className: "tw-min-h-button" }))] }));
|
|
42288
|
+
} })) }), jsx(SwapProgressViewHeader, { title: headerTitle, description: headerDescription }), jsxs("ul", { className: "tw-flex tw-h-[195px] tw-w-full tw-flex-col tw-items-center tw-justify-center tw-gap-squid-xxs tw-rounded-squid-l tw-py-squid-s", children: [jsx(SwapDetailListItem, { icon: jsx(ArrowsSwapIcon, {}), label: "Swap", detail: jsx(SwapDetailItemValues, { fromContent: jsxs(Fragment, { children: [jsx("img", { className: "tw-h-squid-m tw-w-squid-m tw-rounded-full", src: fromToken.logoUrl }), jsx(CaptionText, { children: fromAmount })] }), toContent: jsxs(Fragment, { children: [jsx("img", { className: "tw-h-squid-m tw-w-squid-m tw-rounded-full", src: toToken.logoUrl }), jsx(CaptionText, { children: toAmount })] }) }) }), jsx(SwapDetailListItem, { icon: jsx(ChainLink, { size: "24", strokeWidth: "1.5" }), label: "Chain", detail: jsx(SwapDetailItemValues, { fromContent: jsxs(Fragment, { children: [jsx("img", { className: "tw-h-squid-m tw-w-squid-m tw-rounded-squid-xxs", src: fromChain.logoUrl }), jsx(CaptionText, { children: fromChain.networkName })] }), toContent: jsxs(Fragment, { children: [jsx("img", { className: "tw-h-squid-m tw-w-squid-m tw-rounded-squid-xxs", src: toChain.logoUrl }), jsx(CaptionText, { children: toChain.networkName })] }) }) }), jsx(SwapDetailListItem, { icon: jsx(WalletFilledIcon, { size: "24" }), label: "Wallet", detail: jsx(SwapDetailItemValues, { fromContent: fromAddressFormatted, toContent: toAddressFormatted }) }), jsx(SwapDetailListItem, { icon: jsx(TimeFliesIcon, {}), label: "Time to complete", detail: swapState === SwapState.PROGRESS ? (jsx(SwapDetailItemValues, { fromContent: timer, toContent: estimatedTimeToComplete })) : swapState === SwapState.COMPLETED ? (jsx(CaptionText, { children: timer })) : (jsx(CaptionText, { children: estimatedTimeToComplete })) })] })] }), jsx(TrackTransactionView, { ref: trackTransactionViewRef, onTxEnd: () => stopTimer(), onTxStart: () => startTimer(), rawSteps: steps, onClose: handleRouteStepsClosed, onOpen: handleRouteStepsOpen, swapState: swapState }), !showSwapInfoSection ? (jsx(Button, { size: "lg", variant: "primary", label: "Cancel", onClick: handleCollapseRouteSteps, className: "tw-min-h-button" })) : swapState === SwapState.PARTIAL_SUCCESS ? (jsxs("div", { className: "tw-flex tw-w-full tw-items-center tw-gap-squid-xxs", children: [jsx(Button, { size: "lg", variant: "secondary", label: swapProgressButtonTexts[swapState], onClick: handleClose, className: "tw-min-h-button" }), jsx(Button, { size: "lg", variant: "primary", label: "Complete", onClick: handleComplete, className: "tw-min-h-button" })] })) : (jsx(Button, { size: "lg", variant: "primary", label: swapProgressButtonTexts[swapState], onClick: handleClose, className: "tw-min-h-button" }))] }));
|
|
42283
42289
|
}
|
|
42284
|
-
const TrackTransactionView = ({ swapState, rawSteps, onOpen, onClose, onTxStart, onTxEnd,
|
|
42290
|
+
const TrackTransactionView = forwardRef(({ swapState, rawSteps, onOpen, onClose, onTxStart, onTxEnd }, ref) => {
|
|
42285
42291
|
const { currentStepIndex, steps } = useMemo(() => {
|
|
42286
42292
|
if (swapState === SwapState.COMPLETED) {
|
|
42287
42293
|
onTxEnd();
|
|
@@ -42320,8 +42326,8 @@ const TrackTransactionView = ({ swapState, rawSteps, onOpen, onClose, onTxStart,
|
|
|
42320
42326
|
currentStepIndex: 0,
|
|
42321
42327
|
};
|
|
42322
42328
|
}, [swapState, rawSteps]);
|
|
42323
|
-
return rawSteps.length > 0 ? (jsx(SwapStepsCollapsed, { steps: steps, currentStepIndex: currentStepIndex, onClose: onClose, onOpen: onOpen })) : null;
|
|
42324
|
-
};
|
|
42329
|
+
return rawSteps.length > 0 ? (jsx(SwapStepsCollapsed, { ref: ref, steps: steps, currentStepIndex: currentStepIndex, onClose: onClose, onOpen: onOpen })) : null;
|
|
42330
|
+
});
|
|
42325
42331
|
const SwapDetailItemValues = ({ fromContent, toContent, }) => {
|
|
42326
42332
|
return (jsxs("div", { className: "tw-flex tw-items-center tw-justify-center tw-gap-squid-xxs", children: [typeof fromContent === 'string' ? (jsx(CaptionText, { children: fromContent })) : (fromContent), jsx("span", { className: "tw-text-grey-500", children: jsx(ChevronLargeRightIcon, {}) }), typeof toContent === 'string' ? (jsx(CaptionText, { children: toContent })) : (toContent)] }));
|
|
42327
42333
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { SwapStep } from '../../types/components';
|
|
2
3
|
interface SwapStepsCollapsedProps {
|
|
3
4
|
steps: SwapStep[];
|
|
@@ -5,5 +6,7 @@ interface SwapStepsCollapsedProps {
|
|
|
5
6
|
onOpen?: () => void;
|
|
6
7
|
onClose?: () => void;
|
|
7
8
|
}
|
|
8
|
-
export declare
|
|
9
|
+
export declare const SwapStepsCollapsed: import("react").ForwardRefExoticComponent<SwapStepsCollapsedProps & import("react").RefAttributes<{
|
|
10
|
+
handleToggleRouteSteps: () => void;
|
|
11
|
+
}>>;
|
|
9
12
|
export {};
|
|
@@ -27,13 +27,4 @@ export declare function SwapProgressView({ steps, isOpen, handleClose, handleCom
|
|
|
27
27
|
swapState: SwapState;
|
|
28
28
|
estimatedTimeToComplete?: string;
|
|
29
29
|
}): import("react/jsx-runtime").JSX.Element;
|
|
30
|
-
interface Props {
|
|
31
|
-
rawSteps: SwapStep[];
|
|
32
|
-
swapState?: SwapState;
|
|
33
|
-
onOpen?: () => void;
|
|
34
|
-
onClose?: () => void;
|
|
35
|
-
onTxStart: () => void;
|
|
36
|
-
onTxEnd: () => void;
|
|
37
|
-
}
|
|
38
|
-
export declare const TrackTransactionView: ({ swapState, rawSteps, onOpen, onClose, onTxStart, onTxEnd, }: Props) => import("react/jsx-runtime").JSX.Element | null;
|
|
39
30
|
export {};
|
|
@@ -4,6 +4,8 @@ declare const meta: Meta<typeof SwapProgressView>;
|
|
|
4
4
|
export default meta;
|
|
5
5
|
type Story = StoryObj<typeof meta>;
|
|
6
6
|
export declare const WithControls: Story;
|
|
7
|
+
export declare const ShortRoute: Story;
|
|
8
|
+
export declare const LongRoute: Story;
|
|
7
9
|
export declare const Completed: Story;
|
|
8
10
|
export declare const Error: Story;
|
|
9
11
|
export declare const Confirm: Story;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export type { SquidTheme } from './config';
|
|
2
|
-
export type { SwapState, ThemeType, SwapStep } from './components';
|
|
2
|
+
export type { SwapState, ThemeType, SwapStep, SwapStepItemStatus, } from './components';
|
package/dist/index.css
CHANGED
|
@@ -741,10 +741,6 @@ video {
|
|
|
741
741
|
top: 11px;
|
|
742
742
|
}
|
|
743
743
|
|
|
744
|
-
.tw-top-\[52px\] {
|
|
745
|
-
top: 52px;
|
|
746
|
-
}
|
|
747
|
-
|
|
748
744
|
.tw-top-squid-xxs {
|
|
749
745
|
top: 0.3125rem;
|
|
750
746
|
}
|
|
@@ -1351,6 +1347,10 @@ video {
|
|
|
1351
1347
|
flex-shrink: 0;
|
|
1352
1348
|
}
|
|
1353
1349
|
|
|
1350
|
+
.tw-grow-0 {
|
|
1351
|
+
flex-grow: 0;
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
1354
|
.-tw-translate-x-1\/2 {
|
|
1355
1355
|
--tw-translate-x: -50%;
|
|
1356
1356
|
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
@@ -1438,6 +1438,34 @@ video {
|
|
|
1438
1438
|
animation: tw-expand-route var(--squid-animation-expand-to-top-duration, 0s) linear both;
|
|
1439
1439
|
}
|
|
1440
1440
|
|
|
1441
|
+
@keyframes tw-fade-in {
|
|
1442
|
+
0% {
|
|
1443
|
+
opacity: 0;
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
100% {
|
|
1447
|
+
opacity: 1;
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
.tw-animate-fade-in {
|
|
1452
|
+
animation: tw-fade-in var(--squid-animation-fade-in-duration, 0s) ease-out both;
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
@keyframes tw-fade-out {
|
|
1456
|
+
0% {
|
|
1457
|
+
opacity: 1;
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
100% {
|
|
1461
|
+
opacity: 0;
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
.tw-animate-fade-out {
|
|
1466
|
+
animation: tw-fade-out var(--squid-animation-fade-out-duration, 0s) ease-out both;
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1441
1469
|
@keyframes tw-hide {
|
|
1442
1470
|
0% {
|
|
1443
1471
|
display: block;
|
|
@@ -1493,8 +1521,8 @@ video {
|
|
|
1493
1521
|
}
|
|
1494
1522
|
|
|
1495
1523
|
100% {
|
|
1496
|
-
transform: scale(0.
|
|
1497
|
-
opacity: 0;
|
|
1524
|
+
transform: scale(0.9);
|
|
1525
|
+
opacity: 0.5;
|
|
1498
1526
|
}
|
|
1499
1527
|
}
|
|
1500
1528
|
|
|
@@ -1504,8 +1532,8 @@ video {
|
|
|
1504
1532
|
|
|
1505
1533
|
@keyframes tw-scale-and-fade-up {
|
|
1506
1534
|
0% {
|
|
1507
|
-
transform: scale(0.
|
|
1508
|
-
opacity: 0;
|
|
1535
|
+
transform: scale(0.9);
|
|
1536
|
+
opacity: 0.5;
|
|
1509
1537
|
}
|
|
1510
1538
|
|
|
1511
1539
|
100% {
|
|
@@ -2224,6 +2252,10 @@ video {
|
|
|
2224
2252
|
padding-right: 0.625rem;
|
|
2225
2253
|
}
|
|
2226
2254
|
|
|
2255
|
+
.tw-pt-\[52px\] {
|
|
2256
|
+
padding-top: 52px;
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2227
2259
|
.tw-pt-\[5px\] {
|
|
2228
2260
|
padding-top: 5px;
|
|
2229
2261
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
-
import React$1 from 'react';
|
|
3
|
+
import * as React$1 from 'react';
|
|
4
|
+
import React__default from 'react';
|
|
4
5
|
|
|
5
6
|
interface BadgeImageProps {
|
|
6
7
|
imageUrl?: string;
|
|
@@ -175,8 +176,8 @@ declare function Switch({ checked, onChange, size, disabled, }: SwitchProps): re
|
|
|
175
176
|
type TooltipWidth = 'max' | 'container';
|
|
176
177
|
type TooltipThreshold = 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl';
|
|
177
178
|
interface TooltipProps {
|
|
178
|
-
children:
|
|
179
|
-
tooltipContent:
|
|
179
|
+
children: React__default.ReactNode;
|
|
180
|
+
tooltipContent: React__default.ReactNode;
|
|
180
181
|
threshold?: TooltipThreshold;
|
|
181
182
|
tooltipWidth?: TooltipWidth;
|
|
182
183
|
containerClassName?: string;
|
|
@@ -367,13 +368,13 @@ interface InfoBoxProps {
|
|
|
367
368
|
declare function InfoBox({ title, description, icon }: InfoBoxProps): react_jsx_runtime.JSX.Element;
|
|
368
369
|
|
|
369
370
|
type Rounded = 'sm' | 'lg';
|
|
370
|
-
interface MenuProps extends
|
|
371
|
+
interface MenuProps extends React__default.ComponentProps<'div'> {
|
|
371
372
|
containerClassName?: string;
|
|
372
373
|
contentClassName?: string;
|
|
373
374
|
title?: string;
|
|
374
375
|
displayControls?: boolean;
|
|
375
376
|
rounded?: Rounded;
|
|
376
|
-
menuRef?:
|
|
377
|
+
menuRef?: React__default.RefObject<HTMLDivElement>;
|
|
377
378
|
}
|
|
378
379
|
declare function Menu({ children, containerClassName, contentClassName, title, displayControls, rounded, menuRef, ...props }: MenuProps): react_jsx_runtime.JSX.Element;
|
|
379
380
|
|
|
@@ -464,7 +465,9 @@ interface SwapStepsCollapsedProps {
|
|
|
464
465
|
onOpen?: () => void;
|
|
465
466
|
onClose?: () => void;
|
|
466
467
|
}
|
|
467
|
-
declare
|
|
468
|
+
declare const SwapStepsCollapsed: React$1.ForwardRefExoticComponent<SwapStepsCollapsedProps & React$1.RefAttributes<{
|
|
469
|
+
handleToggleRouteSteps: () => void;
|
|
470
|
+
}>>;
|
|
468
471
|
|
|
469
472
|
interface TokenPairProps {
|
|
470
473
|
firstToken: {
|
|
@@ -565,4 +568,4 @@ declare function useDropdownMenu(props?: {
|
|
|
565
568
|
openDropdownButtonRef: React.RefObject<HTMLButtonElement>;
|
|
566
569
|
};
|
|
567
570
|
|
|
568
|
-
export { AddressButton, ArrowButton, AssetsButton, BadgeImage, BodyText, Boost, BoostButton, BorderedContainer, Button, CaptionText, Chip, DetailsToolbar, DropdownMenu, DropdownMenuItem, type DropdownMenuItemProps, ErrorMessage, FeeButton, HeadingText, HistoryItem, InfoBox, Input, ListItem, LoadingSkeleton, Menu, MenuItem, Modal, ModalContent, ModalContentDivider, NavigationBar, NumericInput, ProductCard, ProfileHeaderBackground, SectionTitle, SettingsButton, type SettingsButtonProps, type SettingsControl, SettingsItem, type SettingsItemProps, SettingsSlider, type SettingsSliderProps, SquidConfigProvider, type SquidTheme, SwapConfiguration, SwapDetailListItem, SwapProgressView, SwapProgressViewHeader, SwapState, type SwapStep, SwapStepItem, SwapStepsCollapsed, Switch, type ThemeType, TokenPair, Tooltip, type TooltipProps, type TooltipThreshold, type TooltipWidth, UsdAmount, useDropdownMenu };
|
|
571
|
+
export { AddressButton, ArrowButton, AssetsButton, BadgeImage, BodyText, Boost, BoostButton, BorderedContainer, Button, CaptionText, Chip, DetailsToolbar, DropdownMenu, DropdownMenuItem, type DropdownMenuItemProps, ErrorMessage, FeeButton, HeadingText, HistoryItem, InfoBox, Input, ListItem, LoadingSkeleton, Menu, MenuItem, Modal, ModalContent, ModalContentDivider, NavigationBar, NumericInput, ProductCard, ProfileHeaderBackground, SectionTitle, SettingsButton, type SettingsButtonProps, type SettingsControl, SettingsItem, type SettingsItemProps, SettingsSlider, type SettingsSliderProps, SquidConfigProvider, type SquidTheme, SwapConfiguration, SwapDetailListItem, SwapProgressView, SwapProgressViewHeader, SwapState, type SwapStep, SwapStepItem, type SwapStepItemStatus, SwapStepsCollapsed, Switch, type ThemeType, TokenPair, Tooltip, type TooltipProps, type TooltipThreshold, type TooltipWidth, UsdAmount, useDropdownMenu };
|