@0xsquid/ui 0.7.3 → 0.7.5
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 +164 -6
- package/dist/cjs/types/components/controls/NumericInput.d.ts +11 -0
- package/dist/cjs/types/components/controls/index.d.ts +1 -0
- package/dist/cjs/types/components/layout/DetailsToolbar.d.ts +4 -3
- package/dist/cjs/types/components/layout/SwapConfiguration.d.ts +5 -3
- package/dist/cjs/types/core/themes.d.ts +2 -2
- package/dist/cjs/types/core/utils.d.ts +7 -0
- package/dist/cjs/types/index.d.ts +2 -1
- package/dist/cjs/types/providers/SquidConfigProvider.d.ts +2 -2
- package/dist/cjs/types/services/internal/colorService.d.ts +2 -2
- package/dist/cjs/types/types/config.d.ts +2 -2
- package/dist/cjs/types/types/index.d.ts +1 -0
- package/dist/esm/index.js +165 -7
- package/dist/esm/types/components/controls/NumericInput.d.ts +11 -0
- package/dist/esm/types/components/controls/index.d.ts +1 -0
- package/dist/esm/types/components/layout/DetailsToolbar.d.ts +4 -3
- package/dist/esm/types/components/layout/SwapConfiguration.d.ts +5 -3
- package/dist/esm/types/core/themes.d.ts +2 -2
- package/dist/esm/types/core/utils.d.ts +7 -0
- package/dist/esm/types/index.d.ts +2 -1
- package/dist/esm/types/providers/SquidConfigProvider.d.ts +2 -2
- package/dist/esm/types/services/internal/colorService.d.ts +2 -2
- package/dist/esm/types/types/config.d.ts +2 -2
- package/dist/esm/types/types/index.d.ts +1 -0
- package/dist/index.d.ts +22 -19
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -2532,6 +2532,24 @@ const twMerge = /*#__PURE__*/createTailwindMerge(getDefaultConfig);
|
|
|
2532
2532
|
const cn = (...inputs) => {
|
|
2533
2533
|
return twMerge(clsx(inputs));
|
|
2534
2534
|
};
|
|
2535
|
+
function debounce(func, delay) {
|
|
2536
|
+
let timeoutId;
|
|
2537
|
+
const debounced = function (...args) {
|
|
2538
|
+
// @ts-expect-error - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
2539
|
+
const context = this;
|
|
2540
|
+
const later = () => {
|
|
2541
|
+
timeoutId = null;
|
|
2542
|
+
func.apply(context, args);
|
|
2543
|
+
};
|
|
2544
|
+
clearTimeout(timeoutId);
|
|
2545
|
+
timeoutId = setTimeout(later, delay);
|
|
2546
|
+
};
|
|
2547
|
+
debounced.cancel = () => {
|
|
2548
|
+
clearTimeout(timeoutId);
|
|
2549
|
+
timeoutId = null;
|
|
2550
|
+
};
|
|
2551
|
+
return debounced;
|
|
2552
|
+
}
|
|
2535
2553
|
|
|
2536
2554
|
const badgeSizeClassMap = {
|
|
2537
2555
|
sm: 'tw-w-4 tw-h-4',
|
|
@@ -2794,6 +2812,135 @@ const PasteButton = () => {
|
|
|
2794
2812
|
return (jsxRuntime.jsx("button", { className: "tw-h-[30px] tw-rounded-full tw-border tw-border-grey-700 tw-bg-grey-800 tw-px-2 tw-text-grey-300", children: jsxRuntime.jsx(CaptionText, { children: "Paste" }) }));
|
|
2795
2813
|
};
|
|
2796
2814
|
|
|
2815
|
+
const NumericInput = (_a) => {
|
|
2816
|
+
var _b;
|
|
2817
|
+
var { onParsedValueChanged, initialValue = '', forcedUpdateValue, maxDecimals, balance, sourceTokenUsdPrice } = _a, props = __rest(_a, ["onParsedValueChanged", "initialValue", "forcedUpdateValue", "maxDecimals", "balance", "sourceTokenUsdPrice"]);
|
|
2818
|
+
const [inputValue, setInputValue] = react.useState(initialValue);
|
|
2819
|
+
// Probably a better way to handle this
|
|
2820
|
+
// This was introduce to handle the "MAX" button setting an amount
|
|
2821
|
+
// Other than that, this component is only sending value to the exterior
|
|
2822
|
+
// Without this, we were losing inputs such as ".05" that were forced parsed to "0.05" after debounce
|
|
2823
|
+
react.useEffect(() => {
|
|
2824
|
+
if (forcedUpdateValue && forcedUpdateValue !== '0') {
|
|
2825
|
+
setInputValue(forcedUpdateValue);
|
|
2826
|
+
}
|
|
2827
|
+
}, [forcedUpdateValue]);
|
|
2828
|
+
/**
|
|
2829
|
+
* Get the number of decimals of inputValue
|
|
2830
|
+
* If there are more decimals than the maxDecimals
|
|
2831
|
+
* remove the extra decimals
|
|
2832
|
+
*/
|
|
2833
|
+
react.useEffect(() => {
|
|
2834
|
+
var _a;
|
|
2835
|
+
const split = inputValue.split('.');
|
|
2836
|
+
if (split.length > 1) {
|
|
2837
|
+
const decimals = (_a = split[1]) !== null && _a !== void 0 ? _a : '';
|
|
2838
|
+
if (maxDecimals && decimals.length > maxDecimals) {
|
|
2839
|
+
const newValue = `${split[0]}.${decimals.slice(0, maxDecimals)}`;
|
|
2840
|
+
setInputValue(newValue);
|
|
2841
|
+
onParsedValueChanged(newValue);
|
|
2842
|
+
}
|
|
2843
|
+
}
|
|
2844
|
+
}, [maxDecimals]);
|
|
2845
|
+
const debouncePriceChanged = (value = '') => {
|
|
2846
|
+
if (value.endsWith('.'))
|
|
2847
|
+
return;
|
|
2848
|
+
onParsedValueChanged(value);
|
|
2849
|
+
};
|
|
2850
|
+
// useCallback to memoizes the debounce function, prevents recreating it
|
|
2851
|
+
const debouncePriceUpdate = react.useCallback(debounce(debouncePriceChanged, 700), []);
|
|
2852
|
+
const handlePriceChanged = (event) => {
|
|
2853
|
+
var _a;
|
|
2854
|
+
try {
|
|
2855
|
+
const formattedInput = event.currentTarget.value
|
|
2856
|
+
.replace(/[^0-9\.\,$%]/g, '')
|
|
2857
|
+
.replace(',', '.');
|
|
2858
|
+
if (formattedInput.includes('$') || formattedInput.includes('%')) {
|
|
2859
|
+
let cleanedInput = formattedInput;
|
|
2860
|
+
if (formattedInput.includes('$') && formattedInput.includes('%')) {
|
|
2861
|
+
// only allow one of them
|
|
2862
|
+
cleanedInput = formattedInput
|
|
2863
|
+
.replaceAll('$', '')
|
|
2864
|
+
.replaceAll('%', '')
|
|
2865
|
+
.concat('%');
|
|
2866
|
+
}
|
|
2867
|
+
else if (formattedInput.includes('%')) {
|
|
2868
|
+
// remove duplicates & always add % at the end
|
|
2869
|
+
cleanedInput = formattedInput.replaceAll('%', '').concat('%');
|
|
2870
|
+
}
|
|
2871
|
+
else if (formattedInput.includes('$')) {
|
|
2872
|
+
// Always add $ at the beginning
|
|
2873
|
+
cleanedInput = formattedInput.replaceAll('$', '');
|
|
2874
|
+
cleanedInput = `$${cleanedInput}`;
|
|
2875
|
+
}
|
|
2876
|
+
setInputValue(cleanedInput);
|
|
2877
|
+
debouncePriceUpdate.cancel();
|
|
2878
|
+
return;
|
|
2879
|
+
}
|
|
2880
|
+
// This is to prevent the user from typing more decimals than the decimals attribute of the token
|
|
2881
|
+
if (maxDecimals !== undefined) {
|
|
2882
|
+
const split = formattedInput.split('.');
|
|
2883
|
+
if (split.length > 1) {
|
|
2884
|
+
const decimals = (_a = split[1]) !== null && _a !== void 0 ? _a : '';
|
|
2885
|
+
if (decimals.length > maxDecimals) {
|
|
2886
|
+
// Don't update anything
|
|
2887
|
+
return;
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2890
|
+
}
|
|
2891
|
+
// if input includes at least one character different than `0` (zero), `.` (dot), or `,` (comma)
|
|
2892
|
+
// means that user is typing a valid amount, for example: 1.02 or 0.005
|
|
2893
|
+
// if so, then update the input value and fetch the price
|
|
2894
|
+
if (/[^0,.]/.test(formattedInput)) {
|
|
2895
|
+
setInputValue(formattedInput);
|
|
2896
|
+
debouncePriceUpdate(formattedInput);
|
|
2897
|
+
}
|
|
2898
|
+
else if (
|
|
2899
|
+
// Means the user is currently typing and will add decimal, no need to fetch or parse
|
|
2900
|
+
// example input: 0.00
|
|
2901
|
+
(formattedInput.includes('.') && formattedInput.endsWith('0')) ||
|
|
2902
|
+
formattedInput.endsWith('.') ||
|
|
2903
|
+
(formattedInput === '0' && (inputValue === '' || inputValue === '0'))) {
|
|
2904
|
+
setInputValue(formattedInput);
|
|
2905
|
+
}
|
|
2906
|
+
else if (!isNaN(+formattedInput)) {
|
|
2907
|
+
setInputValue(formattedInput.toString());
|
|
2908
|
+
debouncePriceUpdate(formattedInput.toString());
|
|
2909
|
+
// onParsedValueChanged(formattedInput.toString());
|
|
2910
|
+
}
|
|
2911
|
+
else {
|
|
2912
|
+
setInputValue('');
|
|
2913
|
+
}
|
|
2914
|
+
}
|
|
2915
|
+
catch (error) {
|
|
2916
|
+
setInputValue('');
|
|
2917
|
+
}
|
|
2918
|
+
};
|
|
2919
|
+
const handleSubmit = (event) => {
|
|
2920
|
+
event.preventDefault();
|
|
2921
|
+
if (inputValue.includes('%')) {
|
|
2922
|
+
const percentage = Number(inputValue.replace('%', ''));
|
|
2923
|
+
// If the percentage is greater than 100, set it to 100
|
|
2924
|
+
const formattedPercentage = percentage > 100 ? 100 : percentage;
|
|
2925
|
+
const valueByPercentage = Number(balance) * (formattedPercentage / 100);
|
|
2926
|
+
// If the value is 0, we want to show 0, not 0.0000
|
|
2927
|
+
const formattedValue = valueByPercentage === 0 ? '0' : valueByPercentage.toFixed(4);
|
|
2928
|
+
setInputValue(formattedValue);
|
|
2929
|
+
onParsedValueChanged(formattedValue);
|
|
2930
|
+
}
|
|
2931
|
+
if (inputValue.includes('$')) {
|
|
2932
|
+
const usdAmount = Number(inputValue.replace('$', ''));
|
|
2933
|
+
if (usdAmount > 0) {
|
|
2934
|
+
const newValue = usdAmount / Number(sourceTokenUsdPrice !== null && sourceTokenUsdPrice !== void 0 ? sourceTokenUsdPrice : 0);
|
|
2935
|
+
const newValueFormatted = newValue.toFixed(4);
|
|
2936
|
+
setInputValue(newValueFormatted);
|
|
2937
|
+
onParsedValueChanged(newValueFormatted);
|
|
2938
|
+
}
|
|
2939
|
+
}
|
|
2940
|
+
};
|
|
2941
|
+
return (jsxRuntime.jsx("form", { className: "tw-px-squid-m tw-pb-[15px] tw-pt-[5px]", onSubmit: handleSubmit, children: jsxRuntime.jsx("input", Object.assign({}, props, { onChange: handlePriceChanged, value: inputValue, type: "string", placeholder: (_b = props.placeholder) !== null && _b !== void 0 ? _b : '0', className: "tw-h-[55px] tw-w-full tw-rounded-squid-s tw-bg-transparent tw-px-squid-xs tw-py-squid-s tw-text-heading-small tw-font-heading-regular tw-text-grey-300 placeholder:tw-text-grey-600 hover:tw-bg-material-light-thin focus:tw-bg-material-light-thin focus:tw-text-royal-400 focus:tw-outline-none" })) }));
|
|
2942
|
+
};
|
|
2943
|
+
|
|
2797
2944
|
// font size, line height, and letter spacing classes
|
|
2798
2945
|
const textClassMap = {
|
|
2799
2946
|
small: 'tw-text-heading-small tw-tracking-heading-small tw-leading-heading-small',
|
|
@@ -2966,7 +3113,16 @@ const detailStateClassMap = {
|
|
|
2966
3113
|
error: 'tw-opacity-33 tw-pointer-events-none',
|
|
2967
3114
|
full: '',
|
|
2968
3115
|
};
|
|
2969
|
-
function DetailsToolbar({
|
|
3116
|
+
function DetailsToolbar({ errorMessage, boostMode = 'normal', onToggleBoostMode, onInvertSwapButtonClick, onFeeButtonClick, feeInUsd, estimatedTime, canToggleBoostMode, boostDisabledMessage, helpButton, isLoading, isEmpty, }) {
|
|
3117
|
+
const state = react.useMemo(() => {
|
|
3118
|
+
if (errorMessage)
|
|
3119
|
+
return 'error';
|
|
3120
|
+
if (isLoading)
|
|
3121
|
+
return 'loading';
|
|
3122
|
+
if (isEmpty)
|
|
3123
|
+
return 'empty';
|
|
3124
|
+
return 'full';
|
|
3125
|
+
}, [errorMessage, isLoading, isEmpty]);
|
|
2970
3126
|
const detailClassName = cn('tw-w-[190px]', detailStateClassMap[state]);
|
|
2971
3127
|
return (jsxRuntime.jsx("aside", { className: cn('tw-h-squid-[50px] tw-flex tw-w-[480px] tw-items-center tw-justify-around tw-bg-grey-900 tw-py-squid-xxs tw-text-grey-500', state === 'error' ? 'tw-px-squid-l' : 'tw-px-squid-m'), children: state === 'error' && errorMessage ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ErrorMessage, { message: errorMessage }), helpButton ? (jsxRuntime.jsx(Button, { onClick: helpButton.onClick, size: "md", variant: "tertiary", label: helpButton.label })) : null] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: detailClassName, children: jsxRuntime.jsx(FeeButton, { feeInUsd: feeInUsd, onClick: onFeeButtonClick }) }), jsxRuntime.jsx("div", { className: "tw-flex tw-h-squid-xl tw-w-squid-xxl tw-items-center tw-justify-center", children: state === 'loading' ? (jsxRuntime.jsx(Loader, { size: "32" })) : (jsxRuntime.jsx(Button, { variant: "tertiary", size: "md", onClick: onInvertSwapButtonClick, className: "tw-border-transparent tw-bg-transparent hover:tw-bg-material-light-thin", icon: jsxRuntime.jsx(ChevronLargeDownIcon, {}) })) }), jsxRuntime.jsx("div", { className: detailClassName, children: jsxRuntime.jsx(Boost, { estimatedTime: estimatedTime !== null && estimatedTime !== void 0 ? estimatedTime : '0s', boostMode: boostMode, onToggleBoostMode: onToggleBoostMode, canToggleBoostMode: state === 'loading' ? false : canToggleBoostMode, boostDisabledMessage: boostDisabledMessage }) })] })) }));
|
|
2972
3128
|
}
|
|
@@ -2976,7 +3132,7 @@ function DropdownMenuItem({ label, imageUrl, icon, labelClassName, }) {
|
|
|
2976
3132
|
}
|
|
2977
3133
|
|
|
2978
3134
|
function useModal(props) {
|
|
2979
|
-
const [isModalOpen, setIsModalOpen] = react.useState(Boolean(
|
|
3135
|
+
const [isModalOpen, setIsModalOpen] = react.useState(Boolean(void 0 ));
|
|
2980
3136
|
const modalRef = react.useRef(null);
|
|
2981
3137
|
const openModalButtonRef = react.useRef(null);
|
|
2982
3138
|
react.useEffect(() => {
|
|
@@ -3144,15 +3300,17 @@ function SwapInputsIcon() {
|
|
|
3144
3300
|
return (jsxRuntime.jsxs("svg", { width: "20", height: "21", viewBox: "0 0 20 21", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("g", { "clip-path": "url(#clip0_40_7936)", children: jsxRuntime.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M20 10.5C20 16.0228 15.5228 20.5 10 20.5C4.47715 20.5 0 16.0228 0 10.5C0 4.97715 4.47715 0.5 10 0.5C15.5228 0.5 20 4.97715 20 10.5ZM8.38268 4.57612C8.75636 4.7309 9 5.09554 9 5.5V15.5C9 16.0523 8.55228 16.5 8 16.5C7.44772 16.5 7 16.0523 7 15.5V7.91421L5.70711 9.20711C5.31658 9.59763 4.68342 9.59763 4.29289 9.20711C3.90237 8.81658 3.90237 8.18342 4.29289 7.79289L7.29289 4.79289C7.57889 4.5069 8.00901 4.42134 8.38268 4.57612ZM11 15.5C11 15.9045 11.2436 16.2691 11.6173 16.4239C11.991 16.5787 12.4211 16.4931 12.7071 16.2071L15.7071 13.2071C16.0976 12.8166 16.0976 12.1834 15.7071 11.7929C15.3166 11.4024 14.6834 11.4024 14.2929 11.7929L13 13.0858V5.5C13 4.94771 12.5523 4.5 12 4.5C11.4477 4.5 11 4.94771 11 5.5V15.5Z", fill: "currentColor" }) }), jsxRuntime.jsx("defs", { children: jsxRuntime.jsx("clipPath", { id: "clip0_40_7936", children: jsxRuntime.jsx("rect", { width: "20", height: "20", fill: "white", transform: "translate(0 0.5)" }) }) })] }));
|
|
3145
3301
|
}
|
|
3146
3302
|
|
|
3147
|
-
function SwapConfiguration({ priceImpactPercentage, amount, swapAmountUsd = '0', balance = '0', isFetching = false, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, address, error, }) {
|
|
3303
|
+
function SwapConfiguration({ priceImpactPercentage, amount, forcedAmount, swapAmountUsd = '0', balance = '0', isFetching = false, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, onBalanceButtonClick, address, error, criticalPriceImpactPercentage = 5, }) {
|
|
3148
3304
|
var _a;
|
|
3149
|
-
const priceImpactClass = ((_a = Number(priceImpactPercentage)) !== null && _a !== void 0 ? _a : 0) >
|
|
3305
|
+
const priceImpactClass = ((_a = Number(priceImpactPercentage)) !== null && _a !== void 0 ? _a : 0) > Number(criticalPriceImpactPercentage)
|
|
3150
3306
|
? 'tw-text-status-negative'
|
|
3151
3307
|
: 'tw-text-grey-300';
|
|
3152
3308
|
const isInteractive = direction === 'from';
|
|
3153
3309
|
// improve accessibility
|
|
3154
3310
|
const BalanceButtonTag = isInteractive ? 'button' : 'div';
|
|
3155
|
-
return (jsxRuntime.jsxs("section", { className: "tw-h-[205px] tw-max-h-[205px] tw-bg-grey-900 tw-pb-squid-m", children: [jsxRuntime.jsx("header", { className: "tw-flex tw-items-center tw-gap-1 tw-px-squid-l tw-py-squid-xs tw-leading-5 tw-text-grey-300", children: jsxRuntime.jsxs("button", { onClick: onWalletButtonClick, className: "-tw-ml-squid-xs tw-flex tw-h-squid-l tw-items-center tw-gap-squid-xxs tw-rounded-squid-s tw-px-squid-xs tw-text-grey-600 hover:tw-bg-material-light-thin", children: [jsxRuntime.jsx(BodyText, { className: "tw-text-grey-500", size: "small", children: direction === 'from' ? 'Pay' : 'Receive' }), jsxRuntime.jsx(BodyText, { size: "small", children: ":" }), jsxRuntime.jsxs("div", { className: "tw-flex tw-items-center tw-gap-1", children: [jsxRuntime.jsx(BodyText, { size: "small", className: address ? 'tw-text-grey-300' : 'tw-text-royal-400', children: address ? address : 'Connect wallet' }), jsxRuntime.jsx(ChevronArrowIcon, { className: address ? 'tw-text-grey-600' : 'tw-text-royal-400' })] })] }) }), jsxRuntime.jsx("div", { className: "tw-px-squid-l", children: jsxRuntime.jsx(AssetsButton, { onClick: onAssetsButtonClick, chainImageUrl: chain === null || chain === void 0 ? void 0 : chain.iconUrl, tokenImageUrl: token === null || token === void 0 ? void 0 : token.iconUrl, tokenSymbol: token === null || token === void 0 ? void 0 : token.symbol, chainBgColor: chain === null || chain === void 0 ? void 0 : chain.bgColor, tokenBgColor: token === null || token === void 0 ? void 0 : token.bgColor, tokenTextColor: token === null || token === void 0 ? void 0 : token.textColor }) }), direction === 'from' ? (jsxRuntime.jsx(
|
|
3311
|
+
return (jsxRuntime.jsxs("section", { className: "tw-h-[205px] tw-max-h-[205px] tw-bg-grey-900 tw-pb-squid-m", children: [jsxRuntime.jsx("header", { className: "tw-flex tw-items-center tw-gap-1 tw-px-squid-l tw-py-squid-xs tw-leading-5 tw-text-grey-300", children: jsxRuntime.jsxs("button", { onClick: onWalletButtonClick, className: "-tw-ml-squid-xs tw-flex tw-h-squid-l tw-items-center tw-gap-squid-xxs tw-rounded-squid-s tw-px-squid-xs tw-text-grey-600 hover:tw-bg-material-light-thin", children: [jsxRuntime.jsx(BodyText, { className: "tw-text-grey-500", size: "small", children: direction === 'from' ? 'Pay' : 'Receive' }), jsxRuntime.jsx(BodyText, { size: "small", children: ":" }), jsxRuntime.jsxs("div", { className: "tw-flex tw-items-center tw-gap-1", children: [jsxRuntime.jsx(BodyText, { size: "small", className: address ? 'tw-text-grey-300' : 'tw-text-royal-400', children: address ? address : 'Connect wallet' }), jsxRuntime.jsx(ChevronArrowIcon, { className: address ? 'tw-text-grey-600' : 'tw-text-royal-400' })] })] }) }), jsxRuntime.jsx("div", { className: "tw-px-squid-l", children: jsxRuntime.jsx(AssetsButton, { onClick: onAssetsButtonClick, chainImageUrl: chain === null || chain === void 0 ? void 0 : chain.iconUrl, tokenImageUrl: token === null || token === void 0 ? void 0 : token.iconUrl, tokenSymbol: token === null || token === void 0 ? void 0 : token.symbol, chainBgColor: chain === null || chain === void 0 ? void 0 : chain.bgColor, tokenBgColor: token === null || token === void 0 ? void 0 : token.bgColor, tokenTextColor: token === null || token === void 0 ? void 0 : token.textColor }) }), direction === 'from' ? (jsxRuntime.jsx(NumericInput, { forcedUpdateValue: forcedAmount, initialValue: amount, onParsedValueChanged: (value) => onAmountChange === null || onAmountChange === void 0 ? void 0 : onAmountChange(value) })) : (jsxRuntime.jsx("div", { className: "tw-w-full tw-px-squid-m tw-pb-[15px] tw-pt-[5px]", children: jsxRuntime.jsx("div", { className: "tw-flex tw-h-[55px] tw-w-full tw-items-center tw-rounded-squid-s tw-bg-transparent tw-px-squid-xs tw-py-squid-s tw-text-heading-small tw-font-heading-regular tw-text-grey-300", children: jsxRuntime.jsx("span", { children: amount }) }) })), !(token === null || token === void 0 ? void 0 : token.iconUrl) || isFetching ? null : (jsxRuntime.jsxs("footer", { className: "tw-flex tw-h-squid-m tw-max-h-squid-m tw-items-center tw-justify-between tw-gap-2 tw-px-squid-m tw-text-grey-500", children: [error ? (jsxRuntime.jsx("div", { className: "tw-px-squid-xs", children: jsxRuntime.jsx(ErrorMessage, { message: error.message }) })) : (jsxRuntime.jsxs("div", { className: cn('tw-flex tw-h-squid-l tw-items-center tw-gap-1.5 tw-rounded-squid-s tw-px-squid-xs', isInteractive && 'hover:tw-bg-material-light-thin'), children: [jsxRuntime.jsx(SwapInputsIcon, {}), jsxRuntime.jsx(UsdAmount, { usdAmount: swapAmountUsd }), priceImpactPercentage && direction === 'to' ? (jsxRuntime.jsxs("span", { className: clsx('tw-flex tw-items-center', priceImpactClass), children: [jsxRuntime.jsx(ArrowTriangle, {}), jsxRuntime.jsx(CaptionText, { bold: true, children: priceImpactPercentage.toString().concat('%') })] })) : null] })), jsxRuntime.jsxs(BalanceButtonTag, { onClick: onBalanceButtonClick, className: cn('tw-flex tw-h-squid-l tw-items-center tw-gap-1.5 tw-rounded-squid-s tw-px-squid-xs', isInteractive
|
|
3312
|
+
? 'hover:tw-bg-material-light-thin'
|
|
3313
|
+
: 'tw-pointer-events-none'), children: [jsxRuntime.jsx(CaptionText, { className: "tw-opacity-66", children: "Balance" }), jsxRuntime.jsx(CaptionText, { children: balance }), jsxRuntime.jsx(MaxIcon, {})] })] }))] }));
|
|
3156
3314
|
}
|
|
3157
3315
|
|
|
3158
3316
|
function SwapProgressViewHeader({ title, description, }) {
|
|
@@ -3279,6 +3437,7 @@ exports.Menu = Menu;
|
|
|
3279
3437
|
exports.MenuItem = MenuItem;
|
|
3280
3438
|
exports.Modal = Modal;
|
|
3281
3439
|
exports.NavigationBar = NavigationBar;
|
|
3440
|
+
exports.NumericInput = NumericInput;
|
|
3282
3441
|
exports.ProductCard = ProductCard;
|
|
3283
3442
|
exports.SectionTitle = SectionTitle;
|
|
3284
3443
|
exports.SettingsButton = SettingsButton;
|
|
@@ -3294,4 +3453,3 @@ exports.Switch = Switch;
|
|
|
3294
3453
|
exports.TokenPair = TokenPair;
|
|
3295
3454
|
exports.Tooltip = Tooltip;
|
|
3296
3455
|
exports.UsdAmount = UsdAmount;
|
|
3297
|
-
exports.useModal = useModal;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { InputHTMLAttributes } from 'react';
|
|
2
|
+
interface Props extends InputHTMLAttributes<HTMLInputElement> {
|
|
3
|
+
onParsedValueChanged: (value: string) => void;
|
|
4
|
+
initialValue?: string;
|
|
5
|
+
forcedUpdateValue?: string;
|
|
6
|
+
maxDecimals?: number;
|
|
7
|
+
balance?: string;
|
|
8
|
+
sourceTokenUsdPrice?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare const NumericInput: ({ onParsedValueChanged, initialValue, forcedUpdateValue, maxDecimals, balance, sourceTokenUsdPrice, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { BoostMode
|
|
1
|
+
import { BoostMode } from '../../types/components';
|
|
2
2
|
interface DetailsToolbarProps {
|
|
3
|
-
state?: DetailsToolbarState;
|
|
4
3
|
errorMessage?: string;
|
|
5
4
|
boostMode?: BoostMode;
|
|
6
5
|
onToggleBoostMode?: ({ boostMode }: {
|
|
@@ -12,10 +11,12 @@ interface DetailsToolbarProps {
|
|
|
12
11
|
estimatedTime?: string;
|
|
13
12
|
canToggleBoostMode?: boolean;
|
|
14
13
|
boostDisabledMessage?: string;
|
|
14
|
+
isLoading?: boolean;
|
|
15
|
+
isEmpty?: boolean;
|
|
15
16
|
helpButton?: {
|
|
16
17
|
label: string;
|
|
17
18
|
onClick: () => void;
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
|
-
export declare function DetailsToolbar({
|
|
21
|
+
export declare function DetailsToolbar({ errorMessage, boostMode, onToggleBoostMode, onInvertSwapButtonClick, onFeeButtonClick, feeInUsd, estimatedTime, canToggleBoostMode, boostDisabledMessage, helpButton, isLoading, isEmpty, }: DetailsToolbarProps): import("react/jsx-runtime").JSX.Element;
|
|
21
22
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { SwapDirection } from '../../types/components';
|
|
3
2
|
interface SwapConfigurationProps {
|
|
4
3
|
direction: SwapDirection;
|
|
5
4
|
priceImpactPercentage?: string;
|
|
6
5
|
amount?: string;
|
|
6
|
+
forcedAmount?: string;
|
|
7
7
|
swapAmountUsd?: string;
|
|
8
8
|
balance?: string;
|
|
9
9
|
isFetching?: boolean;
|
|
@@ -18,12 +18,14 @@ interface SwapConfigurationProps {
|
|
|
18
18
|
textColor: string;
|
|
19
19
|
};
|
|
20
20
|
address?: string;
|
|
21
|
-
onAmountChange?: (
|
|
21
|
+
onAmountChange?: (amount: string) => void;
|
|
22
22
|
onWalletButtonClick?: () => void;
|
|
23
23
|
onAssetsButtonClick?: () => void;
|
|
24
|
+
onBalanceButtonClick?: () => void;
|
|
24
25
|
error?: {
|
|
25
26
|
message: string;
|
|
26
27
|
};
|
|
28
|
+
criticalPriceImpactPercentage?: number;
|
|
27
29
|
}
|
|
28
|
-
export declare function SwapConfiguration({ priceImpactPercentage, amount, swapAmountUsd, balance, isFetching, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, address, error, }: SwapConfigurationProps): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
export declare function SwapConfiguration({ priceImpactPercentage, amount, forcedAmount, swapAmountUsd, balance, isFetching, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, onBalanceButtonClick, address, error, criticalPriceImpactPercentage, }: SwapConfigurationProps): import("react/jsx-runtime").JSX.Element;
|
|
29
31
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ThemeType } from '../types/components';
|
|
2
|
-
import {
|
|
2
|
+
import { SquidTheme } from '../types/config';
|
|
3
3
|
export type Theme = {
|
|
4
4
|
name: string;
|
|
5
5
|
themeImgPath: string;
|
|
6
6
|
websiteBackgroundColor: string;
|
|
7
|
-
theme:
|
|
7
|
+
theme: SquidTheme;
|
|
8
8
|
type: ThemeType;
|
|
9
9
|
};
|
|
10
10
|
export declare const themes: Theme[];
|
|
@@ -8,3 +8,10 @@ import { ClassValue } from 'clsx';
|
|
|
8
8
|
* @returns The combined class names as a string.
|
|
9
9
|
*/
|
|
10
10
|
export declare const cn: (...inputs: ClassValue[]) => string;
|
|
11
|
+
type AnyFunction = (...args: any[]) => any;
|
|
12
|
+
interface DebouncedFunction<F extends AnyFunction> {
|
|
13
|
+
(...args: Parameters<F>): void;
|
|
14
|
+
cancel: () => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function debounce<F extends AnyFunction>(func: F, delay: number): DebouncedFunction<F>;
|
|
17
|
+
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { SquidTheme } from '../types/config';
|
|
3
3
|
import { ThemeType } from '../types/components';
|
|
4
4
|
export declare function SquidConfigProvider({ theme, children, themeType, }: {
|
|
5
|
-
theme:
|
|
5
|
+
theme: SquidTheme;
|
|
6
6
|
children?: React.ReactNode;
|
|
7
7
|
themeType?: ThemeType;
|
|
8
8
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SquidTheme } from '../../types/config';
|
|
2
2
|
/**
|
|
3
3
|
* Parsing the user readable config to css variables
|
|
4
4
|
* @param style
|
|
5
5
|
*/
|
|
6
|
-
export declare const getParsedStyle: (style?:
|
|
6
|
+
export declare const getParsedStyle: (style?: SquidTheme) => {
|
|
7
7
|
[key: string]: string | undefined;
|
|
8
8
|
} | undefined;
|
|
9
9
|
export declare function getContrastColor({ r, g, b, }: {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The color format must be of type #FFFFFF
|
|
3
3
|
*/
|
|
4
4
|
export type ColorType = `#${string}${string}${string}${string}${string}${string}`;
|
|
5
|
-
export interface
|
|
5
|
+
export interface SquidTheme {
|
|
6
6
|
'grey-100': string;
|
|
7
7
|
'grey-200': string;
|
|
8
8
|
'grey-300': string;
|
|
@@ -41,6 +41,6 @@ export declare const SQUID_THEME_CSS_VARIABLE_PREFIX = "--squid-theme-";
|
|
|
41
41
|
/**
|
|
42
42
|
* Mapping between readable variables name and css variables used TailwindCSS config
|
|
43
43
|
*/
|
|
44
|
-
export declare const themeTypesKeys: Record<keyof
|
|
44
|
+
export declare const themeTypesKeys: Record<keyof SquidTheme, {
|
|
45
45
|
cssVariable: string;
|
|
46
46
|
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { SquidTheme } from './config';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { useMemo,
|
|
2
|
+
import { useMemo, useState, useEffect, useCallback, useRef } from 'react';
|
|
3
3
|
|
|
4
4
|
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}
|
|
5
5
|
|
|
@@ -2530,6 +2530,24 @@ const twMerge = /*#__PURE__*/createTailwindMerge(getDefaultConfig);
|
|
|
2530
2530
|
const cn = (...inputs) => {
|
|
2531
2531
|
return twMerge(clsx(inputs));
|
|
2532
2532
|
};
|
|
2533
|
+
function debounce(func, delay) {
|
|
2534
|
+
let timeoutId;
|
|
2535
|
+
const debounced = function (...args) {
|
|
2536
|
+
// @ts-expect-error - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
2537
|
+
const context = this;
|
|
2538
|
+
const later = () => {
|
|
2539
|
+
timeoutId = null;
|
|
2540
|
+
func.apply(context, args);
|
|
2541
|
+
};
|
|
2542
|
+
clearTimeout(timeoutId);
|
|
2543
|
+
timeoutId = setTimeout(later, delay);
|
|
2544
|
+
};
|
|
2545
|
+
debounced.cancel = () => {
|
|
2546
|
+
clearTimeout(timeoutId);
|
|
2547
|
+
timeoutId = null;
|
|
2548
|
+
};
|
|
2549
|
+
return debounced;
|
|
2550
|
+
}
|
|
2533
2551
|
|
|
2534
2552
|
const badgeSizeClassMap = {
|
|
2535
2553
|
sm: 'tw-w-4 tw-h-4',
|
|
@@ -2792,6 +2810,135 @@ const PasteButton = () => {
|
|
|
2792
2810
|
return (jsx("button", { className: "tw-h-[30px] tw-rounded-full tw-border tw-border-grey-700 tw-bg-grey-800 tw-px-2 tw-text-grey-300", children: jsx(CaptionText, { children: "Paste" }) }));
|
|
2793
2811
|
};
|
|
2794
2812
|
|
|
2813
|
+
const NumericInput = (_a) => {
|
|
2814
|
+
var _b;
|
|
2815
|
+
var { onParsedValueChanged, initialValue = '', forcedUpdateValue, maxDecimals, balance, sourceTokenUsdPrice } = _a, props = __rest(_a, ["onParsedValueChanged", "initialValue", "forcedUpdateValue", "maxDecimals", "balance", "sourceTokenUsdPrice"]);
|
|
2816
|
+
const [inputValue, setInputValue] = useState(initialValue);
|
|
2817
|
+
// Probably a better way to handle this
|
|
2818
|
+
// This was introduce to handle the "MAX" button setting an amount
|
|
2819
|
+
// Other than that, this component is only sending value to the exterior
|
|
2820
|
+
// Without this, we were losing inputs such as ".05" that were forced parsed to "0.05" after debounce
|
|
2821
|
+
useEffect(() => {
|
|
2822
|
+
if (forcedUpdateValue && forcedUpdateValue !== '0') {
|
|
2823
|
+
setInputValue(forcedUpdateValue);
|
|
2824
|
+
}
|
|
2825
|
+
}, [forcedUpdateValue]);
|
|
2826
|
+
/**
|
|
2827
|
+
* Get the number of decimals of inputValue
|
|
2828
|
+
* If there are more decimals than the maxDecimals
|
|
2829
|
+
* remove the extra decimals
|
|
2830
|
+
*/
|
|
2831
|
+
useEffect(() => {
|
|
2832
|
+
var _a;
|
|
2833
|
+
const split = inputValue.split('.');
|
|
2834
|
+
if (split.length > 1) {
|
|
2835
|
+
const decimals = (_a = split[1]) !== null && _a !== void 0 ? _a : '';
|
|
2836
|
+
if (maxDecimals && decimals.length > maxDecimals) {
|
|
2837
|
+
const newValue = `${split[0]}.${decimals.slice(0, maxDecimals)}`;
|
|
2838
|
+
setInputValue(newValue);
|
|
2839
|
+
onParsedValueChanged(newValue);
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
}, [maxDecimals]);
|
|
2843
|
+
const debouncePriceChanged = (value = '') => {
|
|
2844
|
+
if (value.endsWith('.'))
|
|
2845
|
+
return;
|
|
2846
|
+
onParsedValueChanged(value);
|
|
2847
|
+
};
|
|
2848
|
+
// useCallback to memoizes the debounce function, prevents recreating it
|
|
2849
|
+
const debouncePriceUpdate = useCallback(debounce(debouncePriceChanged, 700), []);
|
|
2850
|
+
const handlePriceChanged = (event) => {
|
|
2851
|
+
var _a;
|
|
2852
|
+
try {
|
|
2853
|
+
const formattedInput = event.currentTarget.value
|
|
2854
|
+
.replace(/[^0-9\.\,$%]/g, '')
|
|
2855
|
+
.replace(',', '.');
|
|
2856
|
+
if (formattedInput.includes('$') || formattedInput.includes('%')) {
|
|
2857
|
+
let cleanedInput = formattedInput;
|
|
2858
|
+
if (formattedInput.includes('$') && formattedInput.includes('%')) {
|
|
2859
|
+
// only allow one of them
|
|
2860
|
+
cleanedInput = formattedInput
|
|
2861
|
+
.replaceAll('$', '')
|
|
2862
|
+
.replaceAll('%', '')
|
|
2863
|
+
.concat('%');
|
|
2864
|
+
}
|
|
2865
|
+
else if (formattedInput.includes('%')) {
|
|
2866
|
+
// remove duplicates & always add % at the end
|
|
2867
|
+
cleanedInput = formattedInput.replaceAll('%', '').concat('%');
|
|
2868
|
+
}
|
|
2869
|
+
else if (formattedInput.includes('$')) {
|
|
2870
|
+
// Always add $ at the beginning
|
|
2871
|
+
cleanedInput = formattedInput.replaceAll('$', '');
|
|
2872
|
+
cleanedInput = `$${cleanedInput}`;
|
|
2873
|
+
}
|
|
2874
|
+
setInputValue(cleanedInput);
|
|
2875
|
+
debouncePriceUpdate.cancel();
|
|
2876
|
+
return;
|
|
2877
|
+
}
|
|
2878
|
+
// This is to prevent the user from typing more decimals than the decimals attribute of the token
|
|
2879
|
+
if (maxDecimals !== undefined) {
|
|
2880
|
+
const split = formattedInput.split('.');
|
|
2881
|
+
if (split.length > 1) {
|
|
2882
|
+
const decimals = (_a = split[1]) !== null && _a !== void 0 ? _a : '';
|
|
2883
|
+
if (decimals.length > maxDecimals) {
|
|
2884
|
+
// Don't update anything
|
|
2885
|
+
return;
|
|
2886
|
+
}
|
|
2887
|
+
}
|
|
2888
|
+
}
|
|
2889
|
+
// if input includes at least one character different than `0` (zero), `.` (dot), or `,` (comma)
|
|
2890
|
+
// means that user is typing a valid amount, for example: 1.02 or 0.005
|
|
2891
|
+
// if so, then update the input value and fetch the price
|
|
2892
|
+
if (/[^0,.]/.test(formattedInput)) {
|
|
2893
|
+
setInputValue(formattedInput);
|
|
2894
|
+
debouncePriceUpdate(formattedInput);
|
|
2895
|
+
}
|
|
2896
|
+
else if (
|
|
2897
|
+
// Means the user is currently typing and will add decimal, no need to fetch or parse
|
|
2898
|
+
// example input: 0.00
|
|
2899
|
+
(formattedInput.includes('.') && formattedInput.endsWith('0')) ||
|
|
2900
|
+
formattedInput.endsWith('.') ||
|
|
2901
|
+
(formattedInput === '0' && (inputValue === '' || inputValue === '0'))) {
|
|
2902
|
+
setInputValue(formattedInput);
|
|
2903
|
+
}
|
|
2904
|
+
else if (!isNaN(+formattedInput)) {
|
|
2905
|
+
setInputValue(formattedInput.toString());
|
|
2906
|
+
debouncePriceUpdate(formattedInput.toString());
|
|
2907
|
+
// onParsedValueChanged(formattedInput.toString());
|
|
2908
|
+
}
|
|
2909
|
+
else {
|
|
2910
|
+
setInputValue('');
|
|
2911
|
+
}
|
|
2912
|
+
}
|
|
2913
|
+
catch (error) {
|
|
2914
|
+
setInputValue('');
|
|
2915
|
+
}
|
|
2916
|
+
};
|
|
2917
|
+
const handleSubmit = (event) => {
|
|
2918
|
+
event.preventDefault();
|
|
2919
|
+
if (inputValue.includes('%')) {
|
|
2920
|
+
const percentage = Number(inputValue.replace('%', ''));
|
|
2921
|
+
// If the percentage is greater than 100, set it to 100
|
|
2922
|
+
const formattedPercentage = percentage > 100 ? 100 : percentage;
|
|
2923
|
+
const valueByPercentage = Number(balance) * (formattedPercentage / 100);
|
|
2924
|
+
// If the value is 0, we want to show 0, not 0.0000
|
|
2925
|
+
const formattedValue = valueByPercentage === 0 ? '0' : valueByPercentage.toFixed(4);
|
|
2926
|
+
setInputValue(formattedValue);
|
|
2927
|
+
onParsedValueChanged(formattedValue);
|
|
2928
|
+
}
|
|
2929
|
+
if (inputValue.includes('$')) {
|
|
2930
|
+
const usdAmount = Number(inputValue.replace('$', ''));
|
|
2931
|
+
if (usdAmount > 0) {
|
|
2932
|
+
const newValue = usdAmount / Number(sourceTokenUsdPrice !== null && sourceTokenUsdPrice !== void 0 ? sourceTokenUsdPrice : 0);
|
|
2933
|
+
const newValueFormatted = newValue.toFixed(4);
|
|
2934
|
+
setInputValue(newValueFormatted);
|
|
2935
|
+
onParsedValueChanged(newValueFormatted);
|
|
2936
|
+
}
|
|
2937
|
+
}
|
|
2938
|
+
};
|
|
2939
|
+
return (jsx("form", { className: "tw-px-squid-m tw-pb-[15px] tw-pt-[5px]", onSubmit: handleSubmit, children: jsx("input", Object.assign({}, props, { onChange: handlePriceChanged, value: inputValue, type: "string", placeholder: (_b = props.placeholder) !== null && _b !== void 0 ? _b : '0', className: "tw-h-[55px] tw-w-full tw-rounded-squid-s tw-bg-transparent tw-px-squid-xs tw-py-squid-s tw-text-heading-small tw-font-heading-regular tw-text-grey-300 placeholder:tw-text-grey-600 hover:tw-bg-material-light-thin focus:tw-bg-material-light-thin focus:tw-text-royal-400 focus:tw-outline-none" })) }));
|
|
2940
|
+
};
|
|
2941
|
+
|
|
2795
2942
|
// font size, line height, and letter spacing classes
|
|
2796
2943
|
const textClassMap = {
|
|
2797
2944
|
small: 'tw-text-heading-small tw-tracking-heading-small tw-leading-heading-small',
|
|
@@ -2964,7 +3111,16 @@ const detailStateClassMap = {
|
|
|
2964
3111
|
error: 'tw-opacity-33 tw-pointer-events-none',
|
|
2965
3112
|
full: '',
|
|
2966
3113
|
};
|
|
2967
|
-
function DetailsToolbar({
|
|
3114
|
+
function DetailsToolbar({ errorMessage, boostMode = 'normal', onToggleBoostMode, onInvertSwapButtonClick, onFeeButtonClick, feeInUsd, estimatedTime, canToggleBoostMode, boostDisabledMessage, helpButton, isLoading, isEmpty, }) {
|
|
3115
|
+
const state = useMemo(() => {
|
|
3116
|
+
if (errorMessage)
|
|
3117
|
+
return 'error';
|
|
3118
|
+
if (isLoading)
|
|
3119
|
+
return 'loading';
|
|
3120
|
+
if (isEmpty)
|
|
3121
|
+
return 'empty';
|
|
3122
|
+
return 'full';
|
|
3123
|
+
}, [errorMessage, isLoading, isEmpty]);
|
|
2968
3124
|
const detailClassName = cn('tw-w-[190px]', detailStateClassMap[state]);
|
|
2969
3125
|
return (jsx("aside", { className: cn('tw-h-squid-[50px] tw-flex tw-w-[480px] tw-items-center tw-justify-around tw-bg-grey-900 tw-py-squid-xxs tw-text-grey-500', state === 'error' ? 'tw-px-squid-l' : 'tw-px-squid-m'), children: state === 'error' && errorMessage ? (jsxs(Fragment, { children: [jsx(ErrorMessage, { message: errorMessage }), helpButton ? (jsx(Button, { onClick: helpButton.onClick, size: "md", variant: "tertiary", label: helpButton.label })) : null] })) : (jsxs(Fragment, { children: [jsx("div", { className: detailClassName, children: jsx(FeeButton, { feeInUsd: feeInUsd, onClick: onFeeButtonClick }) }), jsx("div", { className: "tw-flex tw-h-squid-xl tw-w-squid-xxl tw-items-center tw-justify-center", children: state === 'loading' ? (jsx(Loader, { size: "32" })) : (jsx(Button, { variant: "tertiary", size: "md", onClick: onInvertSwapButtonClick, className: "tw-border-transparent tw-bg-transparent hover:tw-bg-material-light-thin", icon: jsx(ChevronLargeDownIcon, {}) })) }), jsx("div", { className: detailClassName, children: jsx(Boost, { estimatedTime: estimatedTime !== null && estimatedTime !== void 0 ? estimatedTime : '0s', boostMode: boostMode, onToggleBoostMode: onToggleBoostMode, canToggleBoostMode: state === 'loading' ? false : canToggleBoostMode, boostDisabledMessage: boostDisabledMessage }) })] })) }));
|
|
2970
3126
|
}
|
|
@@ -2974,7 +3130,7 @@ function DropdownMenuItem({ label, imageUrl, icon, labelClassName, }) {
|
|
|
2974
3130
|
}
|
|
2975
3131
|
|
|
2976
3132
|
function useModal(props) {
|
|
2977
|
-
const [isModalOpen, setIsModalOpen] = useState(Boolean(
|
|
3133
|
+
const [isModalOpen, setIsModalOpen] = useState(Boolean(void 0 ));
|
|
2978
3134
|
const modalRef = useRef(null);
|
|
2979
3135
|
const openModalButtonRef = useRef(null);
|
|
2980
3136
|
useEffect(() => {
|
|
@@ -3142,15 +3298,17 @@ function SwapInputsIcon() {
|
|
|
3142
3298
|
return (jsxs("svg", { width: "20", height: "21", viewBox: "0 0 20 21", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx("g", { "clip-path": "url(#clip0_40_7936)", children: jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M20 10.5C20 16.0228 15.5228 20.5 10 20.5C4.47715 20.5 0 16.0228 0 10.5C0 4.97715 4.47715 0.5 10 0.5C15.5228 0.5 20 4.97715 20 10.5ZM8.38268 4.57612C8.75636 4.7309 9 5.09554 9 5.5V15.5C9 16.0523 8.55228 16.5 8 16.5C7.44772 16.5 7 16.0523 7 15.5V7.91421L5.70711 9.20711C5.31658 9.59763 4.68342 9.59763 4.29289 9.20711C3.90237 8.81658 3.90237 8.18342 4.29289 7.79289L7.29289 4.79289C7.57889 4.5069 8.00901 4.42134 8.38268 4.57612ZM11 15.5C11 15.9045 11.2436 16.2691 11.6173 16.4239C11.991 16.5787 12.4211 16.4931 12.7071 16.2071L15.7071 13.2071C16.0976 12.8166 16.0976 12.1834 15.7071 11.7929C15.3166 11.4024 14.6834 11.4024 14.2929 11.7929L13 13.0858V5.5C13 4.94771 12.5523 4.5 12 4.5C11.4477 4.5 11 4.94771 11 5.5V15.5Z", fill: "currentColor" }) }), jsx("defs", { children: jsx("clipPath", { id: "clip0_40_7936", children: jsx("rect", { width: "20", height: "20", fill: "white", transform: "translate(0 0.5)" }) }) })] }));
|
|
3143
3299
|
}
|
|
3144
3300
|
|
|
3145
|
-
function SwapConfiguration({ priceImpactPercentage, amount, swapAmountUsd = '0', balance = '0', isFetching = false, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, address, error, }) {
|
|
3301
|
+
function SwapConfiguration({ priceImpactPercentage, amount, forcedAmount, swapAmountUsd = '0', balance = '0', isFetching = false, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, onBalanceButtonClick, address, error, criticalPriceImpactPercentage = 5, }) {
|
|
3146
3302
|
var _a;
|
|
3147
|
-
const priceImpactClass = ((_a = Number(priceImpactPercentage)) !== null && _a !== void 0 ? _a : 0) >
|
|
3303
|
+
const priceImpactClass = ((_a = Number(priceImpactPercentage)) !== null && _a !== void 0 ? _a : 0) > Number(criticalPriceImpactPercentage)
|
|
3148
3304
|
? 'tw-text-status-negative'
|
|
3149
3305
|
: 'tw-text-grey-300';
|
|
3150
3306
|
const isInteractive = direction === 'from';
|
|
3151
3307
|
// improve accessibility
|
|
3152
3308
|
const BalanceButtonTag = isInteractive ? 'button' : 'div';
|
|
3153
|
-
return (jsxs("section", { className: "tw-h-[205px] tw-max-h-[205px] tw-bg-grey-900 tw-pb-squid-m", children: [jsx("header", { className: "tw-flex tw-items-center tw-gap-1 tw-px-squid-l tw-py-squid-xs tw-leading-5 tw-text-grey-300", children: jsxs("button", { onClick: onWalletButtonClick, className: "-tw-ml-squid-xs tw-flex tw-h-squid-l tw-items-center tw-gap-squid-xxs tw-rounded-squid-s tw-px-squid-xs tw-text-grey-600 hover:tw-bg-material-light-thin", children: [jsx(BodyText, { className: "tw-text-grey-500", size: "small", children: direction === 'from' ? 'Pay' : 'Receive' }), jsx(BodyText, { size: "small", children: ":" }), jsxs("div", { className: "tw-flex tw-items-center tw-gap-1", children: [jsx(BodyText, { size: "small", className: address ? 'tw-text-grey-300' : 'tw-text-royal-400', children: address ? address : 'Connect wallet' }), jsx(ChevronArrowIcon, { className: address ? 'tw-text-grey-600' : 'tw-text-royal-400' })] })] }) }), jsx("div", { className: "tw-px-squid-l", children: jsx(AssetsButton, { onClick: onAssetsButtonClick, chainImageUrl: chain === null || chain === void 0 ? void 0 : chain.iconUrl, tokenImageUrl: token === null || token === void 0 ? void 0 : token.iconUrl, tokenSymbol: token === null || token === void 0 ? void 0 : token.symbol, chainBgColor: chain === null || chain === void 0 ? void 0 : chain.bgColor, tokenBgColor: token === null || token === void 0 ? void 0 : token.bgColor, tokenTextColor: token === null || token === void 0 ? void 0 : token.textColor }) }), direction === 'from' ? (jsx(
|
|
3309
|
+
return (jsxs("section", { className: "tw-h-[205px] tw-max-h-[205px] tw-bg-grey-900 tw-pb-squid-m", children: [jsx("header", { className: "tw-flex tw-items-center tw-gap-1 tw-px-squid-l tw-py-squid-xs tw-leading-5 tw-text-grey-300", children: jsxs("button", { onClick: onWalletButtonClick, className: "-tw-ml-squid-xs tw-flex tw-h-squid-l tw-items-center tw-gap-squid-xxs tw-rounded-squid-s tw-px-squid-xs tw-text-grey-600 hover:tw-bg-material-light-thin", children: [jsx(BodyText, { className: "tw-text-grey-500", size: "small", children: direction === 'from' ? 'Pay' : 'Receive' }), jsx(BodyText, { size: "small", children: ":" }), jsxs("div", { className: "tw-flex tw-items-center tw-gap-1", children: [jsx(BodyText, { size: "small", className: address ? 'tw-text-grey-300' : 'tw-text-royal-400', children: address ? address : 'Connect wallet' }), jsx(ChevronArrowIcon, { className: address ? 'tw-text-grey-600' : 'tw-text-royal-400' })] })] }) }), jsx("div", { className: "tw-px-squid-l", children: jsx(AssetsButton, { onClick: onAssetsButtonClick, chainImageUrl: chain === null || chain === void 0 ? void 0 : chain.iconUrl, tokenImageUrl: token === null || token === void 0 ? void 0 : token.iconUrl, tokenSymbol: token === null || token === void 0 ? void 0 : token.symbol, chainBgColor: chain === null || chain === void 0 ? void 0 : chain.bgColor, tokenBgColor: token === null || token === void 0 ? void 0 : token.bgColor, tokenTextColor: token === null || token === void 0 ? void 0 : token.textColor }) }), direction === 'from' ? (jsx(NumericInput, { forcedUpdateValue: forcedAmount, initialValue: amount, onParsedValueChanged: (value) => onAmountChange === null || onAmountChange === void 0 ? void 0 : onAmountChange(value) })) : (jsx("div", { className: "tw-w-full tw-px-squid-m tw-pb-[15px] tw-pt-[5px]", children: jsx("div", { className: "tw-flex tw-h-[55px] tw-w-full tw-items-center tw-rounded-squid-s tw-bg-transparent tw-px-squid-xs tw-py-squid-s tw-text-heading-small tw-font-heading-regular tw-text-grey-300", children: jsx("span", { children: amount }) }) })), !(token === null || token === void 0 ? void 0 : token.iconUrl) || isFetching ? null : (jsxs("footer", { className: "tw-flex tw-h-squid-m tw-max-h-squid-m tw-items-center tw-justify-between tw-gap-2 tw-px-squid-m tw-text-grey-500", children: [error ? (jsx("div", { className: "tw-px-squid-xs", children: jsx(ErrorMessage, { message: error.message }) })) : (jsxs("div", { className: cn('tw-flex tw-h-squid-l tw-items-center tw-gap-1.5 tw-rounded-squid-s tw-px-squid-xs', isInteractive && 'hover:tw-bg-material-light-thin'), children: [jsx(SwapInputsIcon, {}), jsx(UsdAmount, { usdAmount: swapAmountUsd }), priceImpactPercentage && direction === 'to' ? (jsxs("span", { className: clsx('tw-flex tw-items-center', priceImpactClass), children: [jsx(ArrowTriangle, {}), jsx(CaptionText, { bold: true, children: priceImpactPercentage.toString().concat('%') })] })) : null] })), jsxs(BalanceButtonTag, { onClick: onBalanceButtonClick, className: cn('tw-flex tw-h-squid-l tw-items-center tw-gap-1.5 tw-rounded-squid-s tw-px-squid-xs', isInteractive
|
|
3310
|
+
? 'hover:tw-bg-material-light-thin'
|
|
3311
|
+
: 'tw-pointer-events-none'), children: [jsx(CaptionText, { className: "tw-opacity-66", children: "Balance" }), jsx(CaptionText, { children: balance }), jsx(MaxIcon, {})] })] }))] }));
|
|
3154
3312
|
}
|
|
3155
3313
|
|
|
3156
3314
|
function SwapProgressViewHeader({ title, description, }) {
|
|
@@ -3254,4 +3412,4 @@ function SquidConfigProvider({ theme, children, themeType = 'light', }) {
|
|
|
3254
3412
|
return (jsx("div", { style: parsedStyle, "data-squid-theme-type": themeType, className: clsx('tw-text-base-content tw-group tw-relative tw-font-geist'), children: children }));
|
|
3255
3413
|
}
|
|
3256
3414
|
|
|
3257
|
-
export { AddressButton, ArrowButton, AssetsButton, BadgeImage, BodyText, Boost, BoostButton, Button, CaptionText, Chip, DetailsToolbar, DropdownMenu, DropdownMenuItem, ErrorMessage, FeeButton, HeadingText, HistoryItem, Input, ListItem, Menu, MenuItem, Modal, NavigationBar, ProductCard, SectionTitle, SettingsButton, SettingsItem, SettingsSlider, SquidConfigProvider, SwapConfiguration, SwapDetailListItem, SwapProgressViewHeader, SwapStepItem, SwapStepsCollapsed, Switch, TokenPair, Tooltip, UsdAmount
|
|
3415
|
+
export { AddressButton, ArrowButton, AssetsButton, BadgeImage, BodyText, Boost, BoostButton, Button, CaptionText, Chip, DetailsToolbar, DropdownMenu, DropdownMenuItem, ErrorMessage, FeeButton, HeadingText, HistoryItem, Input, ListItem, Menu, MenuItem, Modal, NavigationBar, NumericInput, ProductCard, SectionTitle, SettingsButton, SettingsItem, SettingsSlider, SquidConfigProvider, SwapConfiguration, SwapDetailListItem, SwapProgressViewHeader, SwapStepItem, SwapStepsCollapsed, Switch, TokenPair, Tooltip, UsdAmount };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { InputHTMLAttributes } from 'react';
|
|
2
|
+
interface Props extends InputHTMLAttributes<HTMLInputElement> {
|
|
3
|
+
onParsedValueChanged: (value: string) => void;
|
|
4
|
+
initialValue?: string;
|
|
5
|
+
forcedUpdateValue?: string;
|
|
6
|
+
maxDecimals?: number;
|
|
7
|
+
balance?: string;
|
|
8
|
+
sourceTokenUsdPrice?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare const NumericInput: ({ onParsedValueChanged, initialValue, forcedUpdateValue, maxDecimals, balance, sourceTokenUsdPrice, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { BoostMode
|
|
1
|
+
import { BoostMode } from '../../types/components';
|
|
2
2
|
interface DetailsToolbarProps {
|
|
3
|
-
state?: DetailsToolbarState;
|
|
4
3
|
errorMessage?: string;
|
|
5
4
|
boostMode?: BoostMode;
|
|
6
5
|
onToggleBoostMode?: ({ boostMode }: {
|
|
@@ -12,10 +11,12 @@ interface DetailsToolbarProps {
|
|
|
12
11
|
estimatedTime?: string;
|
|
13
12
|
canToggleBoostMode?: boolean;
|
|
14
13
|
boostDisabledMessage?: string;
|
|
14
|
+
isLoading?: boolean;
|
|
15
|
+
isEmpty?: boolean;
|
|
15
16
|
helpButton?: {
|
|
16
17
|
label: string;
|
|
17
18
|
onClick: () => void;
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
|
-
export declare function DetailsToolbar({
|
|
21
|
+
export declare function DetailsToolbar({ errorMessage, boostMode, onToggleBoostMode, onInvertSwapButtonClick, onFeeButtonClick, feeInUsd, estimatedTime, canToggleBoostMode, boostDisabledMessage, helpButton, isLoading, isEmpty, }: DetailsToolbarProps): import("react/jsx-runtime").JSX.Element;
|
|
21
22
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { SwapDirection } from '../../types/components';
|
|
3
2
|
interface SwapConfigurationProps {
|
|
4
3
|
direction: SwapDirection;
|
|
5
4
|
priceImpactPercentage?: string;
|
|
6
5
|
amount?: string;
|
|
6
|
+
forcedAmount?: string;
|
|
7
7
|
swapAmountUsd?: string;
|
|
8
8
|
balance?: string;
|
|
9
9
|
isFetching?: boolean;
|
|
@@ -18,12 +18,14 @@ interface SwapConfigurationProps {
|
|
|
18
18
|
textColor: string;
|
|
19
19
|
};
|
|
20
20
|
address?: string;
|
|
21
|
-
onAmountChange?: (
|
|
21
|
+
onAmountChange?: (amount: string) => void;
|
|
22
22
|
onWalletButtonClick?: () => void;
|
|
23
23
|
onAssetsButtonClick?: () => void;
|
|
24
|
+
onBalanceButtonClick?: () => void;
|
|
24
25
|
error?: {
|
|
25
26
|
message: string;
|
|
26
27
|
};
|
|
28
|
+
criticalPriceImpactPercentage?: number;
|
|
27
29
|
}
|
|
28
|
-
export declare function SwapConfiguration({ priceImpactPercentage, amount, swapAmountUsd, balance, isFetching, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, address, error, }: SwapConfigurationProps): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
export declare function SwapConfiguration({ priceImpactPercentage, amount, forcedAmount, swapAmountUsd, balance, isFetching, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, onBalanceButtonClick, address, error, criticalPriceImpactPercentage, }: SwapConfigurationProps): import("react/jsx-runtime").JSX.Element;
|
|
29
31
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ThemeType } from '../types/components';
|
|
2
|
-
import {
|
|
2
|
+
import { SquidTheme } from '../types/config';
|
|
3
3
|
export type Theme = {
|
|
4
4
|
name: string;
|
|
5
5
|
themeImgPath: string;
|
|
6
6
|
websiteBackgroundColor: string;
|
|
7
|
-
theme:
|
|
7
|
+
theme: SquidTheme;
|
|
8
8
|
type: ThemeType;
|
|
9
9
|
};
|
|
10
10
|
export declare const themes: Theme[];
|
|
@@ -8,3 +8,10 @@ import { ClassValue } from 'clsx';
|
|
|
8
8
|
* @returns The combined class names as a string.
|
|
9
9
|
*/
|
|
10
10
|
export declare const cn: (...inputs: ClassValue[]) => string;
|
|
11
|
+
type AnyFunction = (...args: any[]) => any;
|
|
12
|
+
interface DebouncedFunction<F extends AnyFunction> {
|
|
13
|
+
(...args: Parameters<F>): void;
|
|
14
|
+
cancel: () => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function debounce<F extends AnyFunction>(func: F, delay: number): DebouncedFunction<F>;
|
|
17
|
+
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { SquidTheme } from '../types/config';
|
|
3
3
|
import { ThemeType } from '../types/components';
|
|
4
4
|
export declare function SquidConfigProvider({ theme, children, themeType, }: {
|
|
5
|
-
theme:
|
|
5
|
+
theme: SquidTheme;
|
|
6
6
|
children?: React.ReactNode;
|
|
7
7
|
themeType?: ThemeType;
|
|
8
8
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SquidTheme } from '../../types/config';
|
|
2
2
|
/**
|
|
3
3
|
* Parsing the user readable config to css variables
|
|
4
4
|
* @param style
|
|
5
5
|
*/
|
|
6
|
-
export declare const getParsedStyle: (style?:
|
|
6
|
+
export declare const getParsedStyle: (style?: SquidTheme) => {
|
|
7
7
|
[key: string]: string | undefined;
|
|
8
8
|
} | undefined;
|
|
9
9
|
export declare function getContrastColor({ r, g, b, }: {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The color format must be of type #FFFFFF
|
|
3
3
|
*/
|
|
4
4
|
export type ColorType = `#${string}${string}${string}${string}${string}${string}`;
|
|
5
|
-
export interface
|
|
5
|
+
export interface SquidTheme {
|
|
6
6
|
'grey-100': string;
|
|
7
7
|
'grey-200': string;
|
|
8
8
|
'grey-300': string;
|
|
@@ -41,6 +41,6 @@ export declare const SQUID_THEME_CSS_VARIABLE_PREFIX = "--squid-theme-";
|
|
|
41
41
|
/**
|
|
42
42
|
* Mapping between readable variables name and css variables used TailwindCSS config
|
|
43
43
|
*/
|
|
44
|
-
export declare const themeTypesKeys: Record<keyof
|
|
44
|
+
export declare const themeTypesKeys: Record<keyof SquidTheme, {
|
|
45
45
|
cssVariable: string;
|
|
46
46
|
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { SquidTheme } from './config';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
-
import React$1 from 'react';
|
|
3
|
+
import React$1, { InputHTMLAttributes } from 'react';
|
|
4
4
|
|
|
5
5
|
interface BadgeImageProps {
|
|
6
6
|
imageUrl?: string;
|
|
@@ -56,7 +56,6 @@ type SwapStep = {
|
|
|
56
56
|
descriptionBlocks: SwapStepDescriptionBlock[];
|
|
57
57
|
chipContent: React.ReactNode;
|
|
58
58
|
};
|
|
59
|
-
type DetailsToolbarState = 'full' | 'loading' | 'empty' | 'error';
|
|
60
59
|
type ThemeType = 'light' | 'dark';
|
|
61
60
|
|
|
62
61
|
interface BoostButtonProps {
|
|
@@ -103,6 +102,16 @@ interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
|
103
102
|
}
|
|
104
103
|
declare function Input({ placeholder, showIcon, showPasteButton, className, icon, ...props }: InputProps): react_jsx_runtime.JSX.Element;
|
|
105
104
|
|
|
105
|
+
interface Props extends InputHTMLAttributes<HTMLInputElement> {
|
|
106
|
+
onParsedValueChanged: (value: string) => void;
|
|
107
|
+
initialValue?: string;
|
|
108
|
+
forcedUpdateValue?: string;
|
|
109
|
+
maxDecimals?: number;
|
|
110
|
+
balance?: string;
|
|
111
|
+
sourceTokenUsdPrice?: number;
|
|
112
|
+
}
|
|
113
|
+
declare const NumericInput: ({ onParsedValueChanged, initialValue, forcedUpdateValue, maxDecimals, balance, sourceTokenUsdPrice, ...props }: Props) => react_jsx_runtime.JSX.Element;
|
|
114
|
+
|
|
106
115
|
interface SettingsSliderProps {
|
|
107
116
|
value: number;
|
|
108
117
|
type: 'percentage' | 'amount';
|
|
@@ -142,7 +151,6 @@ interface BoostProps {
|
|
|
142
151
|
declare function Boost({ boostMode, onToggleBoostMode, estimatedTime, boostDisabledMessage, canToggleBoostMode, }: BoostProps): react_jsx_runtime.JSX.Element;
|
|
143
152
|
|
|
144
153
|
interface DetailsToolbarProps {
|
|
145
|
-
state?: DetailsToolbarState;
|
|
146
154
|
errorMessage?: string;
|
|
147
155
|
boostMode?: BoostMode;
|
|
148
156
|
onToggleBoostMode?: ({ boostMode }: {
|
|
@@ -154,12 +162,14 @@ interface DetailsToolbarProps {
|
|
|
154
162
|
estimatedTime?: string;
|
|
155
163
|
canToggleBoostMode?: boolean;
|
|
156
164
|
boostDisabledMessage?: string;
|
|
165
|
+
isLoading?: boolean;
|
|
166
|
+
isEmpty?: boolean;
|
|
157
167
|
helpButton?: {
|
|
158
168
|
label: string;
|
|
159
169
|
onClick: () => void;
|
|
160
170
|
};
|
|
161
171
|
}
|
|
162
|
-
declare function DetailsToolbar({
|
|
172
|
+
declare function DetailsToolbar({ errorMessage, boostMode, onToggleBoostMode, onInvertSwapButtonClick, onFeeButtonClick, feeInUsd, estimatedTime, canToggleBoostMode, boostDisabledMessage, helpButton, isLoading, isEmpty, }: DetailsToolbarProps): react_jsx_runtime.JSX.Element;
|
|
163
173
|
|
|
164
174
|
interface DropdownMenuItemProps {
|
|
165
175
|
label: string;
|
|
@@ -291,6 +301,7 @@ interface SwapConfigurationProps {
|
|
|
291
301
|
direction: SwapDirection;
|
|
292
302
|
priceImpactPercentage?: string;
|
|
293
303
|
amount?: string;
|
|
304
|
+
forcedAmount?: string;
|
|
294
305
|
swapAmountUsd?: string;
|
|
295
306
|
balance?: string;
|
|
296
307
|
isFetching?: boolean;
|
|
@@ -305,14 +316,16 @@ interface SwapConfigurationProps {
|
|
|
305
316
|
textColor: string;
|
|
306
317
|
};
|
|
307
318
|
address?: string;
|
|
308
|
-
onAmountChange?: (
|
|
319
|
+
onAmountChange?: (amount: string) => void;
|
|
309
320
|
onWalletButtonClick?: () => void;
|
|
310
321
|
onAssetsButtonClick?: () => void;
|
|
322
|
+
onBalanceButtonClick?: () => void;
|
|
311
323
|
error?: {
|
|
312
324
|
message: string;
|
|
313
325
|
};
|
|
326
|
+
criticalPriceImpactPercentage?: number;
|
|
314
327
|
}
|
|
315
|
-
declare function SwapConfiguration({ priceImpactPercentage, amount, swapAmountUsd, balance, isFetching, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, address, error, }: SwapConfigurationProps): react_jsx_runtime.JSX.Element;
|
|
328
|
+
declare function SwapConfiguration({ priceImpactPercentage, amount, forcedAmount, swapAmountUsd, balance, isFetching, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, onBalanceButtonClick, address, error, criticalPriceImpactPercentage, }: SwapConfigurationProps): react_jsx_runtime.JSX.Element;
|
|
316
329
|
|
|
317
330
|
interface SwapProgressViewHeaderProps {
|
|
318
331
|
title: string;
|
|
@@ -356,7 +369,7 @@ interface HeadingTextProps {
|
|
|
356
369
|
}
|
|
357
370
|
declare function HeadingText({ children, bold, size }: HeadingTextProps): react_jsx_runtime.JSX.Element;
|
|
358
371
|
|
|
359
|
-
interface
|
|
372
|
+
interface SquidTheme {
|
|
360
373
|
'grey-100': string;
|
|
361
374
|
'grey-200': string;
|
|
362
375
|
'grey-300': string;
|
|
@@ -393,19 +406,9 @@ interface ConfigTheme {
|
|
|
393
406
|
}
|
|
394
407
|
|
|
395
408
|
declare function SquidConfigProvider({ theme, children, themeType, }: {
|
|
396
|
-
theme:
|
|
409
|
+
theme: SquidTheme;
|
|
397
410
|
children?: React.ReactNode;
|
|
398
411
|
themeType?: ThemeType;
|
|
399
412
|
}): react_jsx_runtime.JSX.Element;
|
|
400
413
|
|
|
401
|
-
|
|
402
|
-
initialIsModalOpen?: boolean;
|
|
403
|
-
}): {
|
|
404
|
-
isModalOpen: boolean;
|
|
405
|
-
openModal: () => void;
|
|
406
|
-
closeModal: () => void;
|
|
407
|
-
modalRef: React.RefObject<HTMLDivElement>;
|
|
408
|
-
openModalButtonRef: React.RefObject<HTMLButtonElement>;
|
|
409
|
-
};
|
|
410
|
-
|
|
411
|
-
export { AddressButton, ArrowButton, AssetsButton, BadgeImage, BodyText, Boost, BoostButton, Button, CaptionText, Chip, DetailsToolbar, DropdownMenu, DropdownMenuItem, type DropdownMenuItemProps, ErrorMessage, FeeButton, HeadingText, HistoryItem, Input, ListItem, Menu, MenuItem, Modal, NavigationBar, ProductCard, SectionTitle, SettingsButton, type SettingsButtonProps, SettingsItem, type SettingsItemProps, SettingsSlider, type SettingsSliderProps, SquidConfigProvider, SwapConfiguration, SwapDetailListItem, SwapProgressViewHeader, SwapStepItem, SwapStepsCollapsed, Switch, TokenPair, Tooltip, type TooltipThreshold, type TooltipWidth, UsdAmount, useModal };
|
|
414
|
+
export { AddressButton, ArrowButton, AssetsButton, BadgeImage, BodyText, Boost, BoostButton, Button, CaptionText, Chip, DetailsToolbar, DropdownMenu, DropdownMenuItem, type DropdownMenuItemProps, ErrorMessage, FeeButton, HeadingText, HistoryItem, Input, ListItem, Menu, MenuItem, Modal, NavigationBar, NumericInput, ProductCard, SectionTitle, SettingsButton, type SettingsButtonProps, SettingsItem, type SettingsItemProps, SettingsSlider, type SettingsSliderProps, SquidConfigProvider, type SquidTheme, SwapConfiguration, SwapDetailListItem, SwapProgressViewHeader, SwapStepItem, SwapStepsCollapsed, Switch, TokenPair, Tooltip, type TooltipThreshold, type TooltipWidth, UsdAmount };
|