@0xsquid/ui 0.7.2 → 0.7.4
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 +160 -8
- package/dist/cjs/types/components/badges/LoadingSkeleton.d.ts +4 -0
- 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/SwapConfiguration.d.ts +4 -3
- package/dist/cjs/types/components/lists/ListItem.d.ts +4 -1
- package/dist/cjs/types/core/utils.d.ts +7 -0
- package/dist/cjs/types/stories/lists/ListItem.stories.d.ts +3 -0
- package/dist/esm/index.js +161 -10
- package/dist/esm/types/components/badges/LoadingSkeleton.d.ts +4 -0
- 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/SwapConfiguration.d.ts +4 -3
- package/dist/esm/types/components/lists/ListItem.d.ts +4 -1
- package/dist/esm/types/core/utils.d.ts +7 -0
- package/dist/esm/types/stories/lists/ListItem.stories.d.ts +3 -0
- package/dist/index.css +17 -0
- package/dist/index.d.ts +20 -5
- 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',
|
|
@@ -3043,15 +3190,20 @@ function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted,
|
|
|
3043
3190
|
] })) : null] }) }));
|
|
3044
3191
|
}
|
|
3045
3192
|
|
|
3193
|
+
function LoadingSkeleton({ className, height = '20', }) {
|
|
3194
|
+
return (jsxRuntime.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "100", height: height, viewBox: "0 0 100 20", fill: "none", className: className, children: [jsxRuntime.jsxs("g", { "clip-path": "url(#clip0_1083_18992)", children: [jsxRuntime.jsx("mask", { id: "mask0_1083_18992", style: { maskType: 'alpha' }, maskUnits: "userSpaceOnUse", x: "0", y: "0", width: "100", height: "20", children: jsxRuntime.jsx("rect", { width: "100", height: "20", fill: "url(#paint0_linear_1083_18992)" }) }), jsxRuntime.jsx("g", { mask: "url(#mask0_1083_18992)", children: jsxRuntime.jsx("rect", { width: "100", height: "20", fill: "currentColor" }) })] }), jsxRuntime.jsxs("defs", { children: [jsxRuntime.jsxs("linearGradient", { id: "paint0_linear_1083_18992", x1: "0", y1: "10", x2: "100", y2: "10", gradientUnits: "userSpaceOnUse", className: "tw-animate-loading-gradient", children: [jsxRuntime.jsx("stop", { "stop-color": "#D9D9D9", "stop-opacity": "0.33" }), jsxRuntime.jsx("stop", { offset: "0.395881", "stop-color": "#737373", "stop-opacity": "0.33" }), jsxRuntime.jsx("stop", { offset: "0.597867", "stop-color": "#737373", "stop-opacity": "0.66" }), jsxRuntime.jsx("stop", { offset: "0.697004", "stop-color": "#737373", "stop-opacity": "0.33" })] }), jsxRuntime.jsx("clipPath", { id: "clip0_1083_18992", children: jsxRuntime.jsx("path", { d: "M0 10C0 4.47715 4.47715 0 10 0H90C95.5228 0 100 4.47715 100 10C100 15.5228 95.5229 20 90 20H10C4.47716 20 0 15.5228 0 10Z", fill: "white" }) })] })] }));
|
|
3195
|
+
}
|
|
3196
|
+
|
|
3046
3197
|
const listItemSizeMap = {
|
|
3047
3198
|
small: 'tw-max-w-list-item-small tw-h-list-item-small tw-px-squid-xs',
|
|
3048
3199
|
large: 'tw-max-w-list-item-large tw-h-list-item-large tw-px-squid-xs',
|
|
3049
3200
|
};
|
|
3050
3201
|
function ListItem(_a) {
|
|
3051
|
-
var { itemTitle, mainImageUrl, subtitle, detail, icon, secondaryImageUrl, size = 'large', mainIcon, className, isSelected, onDetailClick, showDetailOnHoverOnly, rounded = false, detailButtonClassName } = _a, props = __rest(_a, ["itemTitle", "mainImageUrl", "subtitle", "detail", "icon", "secondaryImageUrl", "size", "mainIcon", "className", "isSelected", "onDetailClick", "showDetailOnHoverOnly", "rounded", "detailButtonClassName"]);
|
|
3052
|
-
return (jsxRuntime.jsx("li", Object.assign({}, props, { className: cn('tw-group/list-item tw-flex tw-bg-grey-900 tw-text-grey-300', listItemSizeMap[size], className), children: jsxRuntime.jsxs("div", { className: cn('tw-flex tw-w-full tw-cursor-pointer tw-items-center tw-justify-start tw-gap-squid-xs tw-rounded-squid-s tw-px-squid-xs tw-py-squid-xxs hover:tw-bg-material-light-thin', isSelected && 'tw-bg-material-light-thin'), children: [size === 'large' ? (jsxRuntime.jsx("div", { className: "tw-h-10 tw-w-10", children: mainIcon ? (mainIcon) : (jsxRuntime.jsx(BadgeImage, { extraMarginForBadge: false, imageUrl: mainImageUrl, badgeUrl: secondaryImageUrl, size: "md", rounded: rounded })) })) : (jsxRuntime.jsx("div", { className: "tw-flex tw-min-h-[30px] tw-min-w-[30px] tw-items-center tw-justify-center", children: mainIcon ? (mainIcon) : (jsxRuntime.jsx("img", { src: mainImageUrl, className: "tw-h-[30px] tw-w-[30px] tw-rounded-squid-xs" })) })), jsxRuntime.jsxs("div", { className: cn('tw-flex tw-h-[40px] tw-
|
|
3202
|
+
var { itemTitle, mainImageUrl, subtitle, detail, icon, secondaryImageUrl, size = 'large', mainIcon, className, isSelected, onDetailClick, showDetailOnHoverOnly, rounded = false, detailButtonClassName, loading } = _a, props = __rest(_a, ["itemTitle", "mainImageUrl", "subtitle", "detail", "icon", "secondaryImageUrl", "size", "mainIcon", "className", "isSelected", "onDetailClick", "showDetailOnHoverOnly", "rounded", "detailButtonClassName", "loading"]);
|
|
3203
|
+
return (jsxRuntime.jsx("li", Object.assign({}, props, { className: cn('tw-group/list-item tw-flex tw-max-w-full tw-bg-grey-900 tw-text-grey-300', listItemSizeMap[size], className), children: jsxRuntime.jsxs("div", { className: cn('tw-flex tw-w-full tw-max-w-full tw-cursor-pointer tw-items-center tw-justify-start tw-gap-squid-xs tw-rounded-squid-s tw-px-squid-xs tw-py-squid-xxs hover:tw-bg-material-light-thin', isSelected && 'tw-bg-material-light-thin'), children: [size === 'large' ? (jsxRuntime.jsx("div", { className: "tw-h-10 tw-w-10", children: mainIcon ? (mainIcon) : (jsxRuntime.jsx(BadgeImage, { extraMarginForBadge: false, imageUrl: mainImageUrl, badgeUrl: secondaryImageUrl, size: "md", rounded: rounded })) })) : (jsxRuntime.jsx("div", { className: "tw-flex tw-min-h-[30px] tw-min-w-[30px] tw-items-center tw-justify-center", children: mainIcon ? (mainIcon) : (jsxRuntime.jsx("img", { src: mainImageUrl, className: "tw-h-[30px] tw-w-[30px] tw-rounded-squid-xs" })) })), jsxRuntime.jsxs("div", { className: cn('tw-flex tw-h-[40px] tw-flex-1 tw-flex-col tw-items-start tw-justify-center tw-gap-squid-xs',
|
|
3053
3204
|
// 'large' variant has extra padding
|
|
3054
|
-
size === 'large'
|
|
3205
|
+
size === 'large' ? 'tw-w-[56%] tw-pl-squid-xxs' : 'tw-w-[67%]'), children: [typeof itemTitle === 'string' ? (jsxRuntime.jsx(BodyText, { size: "small", className: "tw-max-w-full tw-truncate !tw-leading-[18px]", children: itemTitle })) : (itemTitle), size === 'large' &&
|
|
3206
|
+
((loading === null || loading === void 0 ? void 0 : loading.subtitle) ? (jsxRuntime.jsx(LoadingSkeleton, { className: "-tw-translate-x-6 tw-text-grey-500", height: "10" })) : subtitle ? (jsxRuntime.jsx(CaptionText, { className: "tw-h-squid-xs !tw-leading-[10px] tw-text-grey-500", children: subtitle })) : null)] }), jsxRuntime.jsxs("button", { onClick: (event) => {
|
|
3055
3207
|
// prevent click event from bubbling up to parent
|
|
3056
3208
|
event.stopPropagation();
|
|
3057
3209
|
onDetailClick === null || onDetailClick === void 0 ? void 0 : onDetailClick();
|
|
@@ -3079,9 +3231,6 @@ function SettingsItem({ icon, label, controls, transparentControls = false, show
|
|
|
3079
3231
|
function SwapDetailListItem({ label, detail, icon, isLoading = false, }) {
|
|
3080
3232
|
return (jsxRuntime.jsx("li", { className: "tw-swap-detail-list-item-gradient tw-h-squid-l tw-w-full tw-bg-grey-800 tw-px-squid-xs tw-text-grey-300", children: jsxRuntime.jsxs("div", { className: "tw-flex tw-h-squid-l tw-items-center tw-justify-between tw-gap-squid-xs tw-rounded-squid-xs tw-px-squid-xs", children: [jsxRuntime.jsx("div", { className: "tw-h-6 tw-w-6 tw-text-grey-500", children: icon }), jsxRuntime.jsx(CaptionText, { className: "tw-flex-1 tw-text-grey-500", children: label }), isLoading ? (jsxRuntime.jsx(LoadingSkeleton, { className: "tw-text-grey-500" })) : typeof detail === 'string' ? (jsxRuntime.jsx(CaptionText, { children: detail })) : (detail)] }) }));
|
|
3081
3233
|
}
|
|
3082
|
-
function LoadingSkeleton({ className }) {
|
|
3083
|
-
return (jsxRuntime.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "100", height: "20", viewBox: "0 0 100 20", fill: "none", className: className, children: [jsxRuntime.jsxs("g", { "clip-path": "url(#clip0_1083_18992)", children: [jsxRuntime.jsx("mask", { id: "mask0_1083_18992", style: { maskType: 'alpha' }, maskUnits: "userSpaceOnUse", x: "0", y: "0", width: "100", height: "20", children: jsxRuntime.jsx("rect", { width: "100", height: "20", fill: "url(#paint0_linear_1083_18992)" }) }), jsxRuntime.jsx("g", { mask: "url(#mask0_1083_18992)", children: jsxRuntime.jsx("rect", { width: "100", height: "20", fill: "currentColor" }) })] }), jsxRuntime.jsxs("defs", { children: [jsxRuntime.jsxs("linearGradient", { id: "paint0_linear_1083_18992", x1: "0", y1: "10", x2: "100", y2: "10", gradientUnits: "userSpaceOnUse", className: "tw-animate-loading-gradient", children: [jsxRuntime.jsx("stop", { "stop-color": "#D9D9D9", "stop-opacity": "0.33" }), jsxRuntime.jsx("stop", { offset: "0.395881", "stop-color": "#737373", "stop-opacity": "0.33" }), jsxRuntime.jsx("stop", { offset: "0.597867", "stop-color": "#737373", "stop-opacity": "0.66" }), jsxRuntime.jsx("stop", { offset: "0.697004", "stop-color": "#737373", "stop-opacity": "0.33" })] }), jsxRuntime.jsx("clipPath", { id: "clip0_1083_18992", children: jsxRuntime.jsx("path", { d: "M0 10C0 4.47715 4.47715 0 10 0H90C95.5228 0 100 4.47715 100 10C100 15.5228 95.5229 20 90 20H10C4.47716 20 0 15.5228 0 10Z", fill: "white" }) })] })] }));
|
|
3084
|
-
}
|
|
3085
3234
|
|
|
3086
3235
|
function SwapStepSeparator() {
|
|
3087
3236
|
return (jsxRuntime.jsx("span", { className: "tw-flex tw-h-squid-m tw-w-squid-xxl tw-items-center tw-justify-center tw-self-stretch tw-py-0.5", children: jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "4", height: "21", viewBox: "0 0 4 21", fill: "none", children: jsxRuntime.jsx("path", { d: "M2 2.5V18.5", stroke: "currentColor", "stroke-width": "4", "stroke-linecap": "round" }) }) }));
|
|
@@ -3142,7 +3291,7 @@ function SwapInputsIcon() {
|
|
|
3142
3291
|
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)" }) }) })] }));
|
|
3143
3292
|
}
|
|
3144
3293
|
|
|
3145
|
-
function SwapConfiguration({ priceImpactPercentage, amount, swapAmountUsd = '0', balance = '0', isFetching = false, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, address, error, }) {
|
|
3294
|
+
function SwapConfiguration({ priceImpactPercentage, amount, forcedAmount, swapAmountUsd = '0', balance = '0', isFetching = false, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, onBalanceButtonClick, address, error, }) {
|
|
3146
3295
|
var _a;
|
|
3147
3296
|
const priceImpactClass = ((_a = Number(priceImpactPercentage)) !== null && _a !== void 0 ? _a : 0) > 5
|
|
3148
3297
|
? 'tw-text-status-negative'
|
|
@@ -3150,7 +3299,9 @@ function SwapConfiguration({ priceImpactPercentage, amount, swapAmountUsd = '0',
|
|
|
3150
3299
|
const isInteractive = direction === 'from';
|
|
3151
3300
|
// improve accessibility
|
|
3152
3301
|
const BalanceButtonTag = isInteractive ? 'button' : 'div';
|
|
3153
|
-
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(
|
|
3302
|
+
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
|
|
3303
|
+
? 'hover:tw-bg-material-light-thin'
|
|
3304
|
+
: 'tw-pointer-events-none'), children: [jsxRuntime.jsx(CaptionText, { className: "tw-opacity-66", children: "Balance" }), jsxRuntime.jsx(CaptionText, { children: balance }), jsxRuntime.jsx(MaxIcon, {})] })] }))] }));
|
|
3154
3305
|
}
|
|
3155
3306
|
|
|
3156
3307
|
function SwapProgressViewHeader({ title, description, }) {
|
|
@@ -3277,6 +3428,7 @@ exports.Menu = Menu;
|
|
|
3277
3428
|
exports.MenuItem = MenuItem;
|
|
3278
3429
|
exports.Modal = Modal;
|
|
3279
3430
|
exports.NavigationBar = NavigationBar;
|
|
3431
|
+
exports.NumericInput = NumericInput;
|
|
3280
3432
|
exports.ProductCard = ProductCard;
|
|
3281
3433
|
exports.SectionTitle = SectionTitle;
|
|
3282
3434
|
exports.SettingsButton = SettingsButton;
|
|
@@ -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,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,13 @@ 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
|
};
|
|
27
28
|
}
|
|
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;
|
|
29
|
+
export declare function SwapConfiguration({ priceImpactPercentage, amount, forcedAmount, swapAmountUsd, balance, isFetching, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, onBalanceButtonClick, address, error, }: SwapConfigurationProps): import("react/jsx-runtime").JSX.Element;
|
|
29
30
|
export {};
|
|
@@ -14,7 +14,10 @@ interface ListItemProps extends React.HTMLAttributes<HTMLLIElement> {
|
|
|
14
14
|
showDetailOnHoverOnly?: boolean;
|
|
15
15
|
rounded?: boolean;
|
|
16
16
|
detailButtonClassName?: string;
|
|
17
|
+
loading?: {
|
|
18
|
+
subtitle?: boolean;
|
|
19
|
+
};
|
|
17
20
|
}
|
|
18
21
|
type ListItemSize = 'small' | 'large';
|
|
19
|
-
export declare function ListItem({ itemTitle, mainImageUrl, subtitle, detail, icon, secondaryImageUrl, size, mainIcon, className, isSelected, onDetailClick, showDetailOnHoverOnly, rounded, detailButtonClassName, ...props }: ListItemProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare function ListItem({ itemTitle, mainImageUrl, subtitle, detail, icon, secondaryImageUrl, size, mainIcon, className, isSelected, onDetailClick, showDetailOnHoverOnly, rounded, detailButtonClassName, loading, ...props }: ListItemProps): import("react/jsx-runtime").JSX.Element;
|
|
20
23
|
export {};
|
|
@@ -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 {};
|
|
@@ -4,6 +4,7 @@ declare const meta: Meta<typeof ListItem>;
|
|
|
4
4
|
export default meta;
|
|
5
5
|
type Story = StoryObj<typeof meta>;
|
|
6
6
|
export declare const Large: Story;
|
|
7
|
+
export declare const LargeWithLongTitle: Story;
|
|
7
8
|
export declare const LargeRoundedFull: Story;
|
|
8
9
|
export declare const LargeWithSubtitle: Story;
|
|
9
10
|
export declare const LargeWithDetail: Story;
|
|
@@ -13,7 +14,9 @@ export declare const LargeShowDetailOnHoverOnly: Story;
|
|
|
13
14
|
export declare const LargeWithSecondaryImage: Story;
|
|
14
15
|
export declare const LargeSelected: Story;
|
|
15
16
|
export declare const LargeWithCustomIconAsImage: Story;
|
|
17
|
+
export declare const LargeLoading: Story;
|
|
16
18
|
export declare const Small: Story;
|
|
19
|
+
export declare const SmallWithLongTitle: Story;
|
|
17
20
|
export declare const SmallWithIcon: Story;
|
|
18
21
|
export declare const SmallShowDetailOnHoverOnly: Story;
|
|
19
22
|
export declare const SmallSelected: Story;
|
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',
|
|
@@ -3041,15 +3188,20 @@ function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted,
|
|
|
3041
3188
|
] })) : null] }) }));
|
|
3042
3189
|
}
|
|
3043
3190
|
|
|
3191
|
+
function LoadingSkeleton({ className, height = '20', }) {
|
|
3192
|
+
return (jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "100", height: height, viewBox: "0 0 100 20", fill: "none", className: className, children: [jsxs("g", { "clip-path": "url(#clip0_1083_18992)", children: [jsx("mask", { id: "mask0_1083_18992", style: { maskType: 'alpha' }, maskUnits: "userSpaceOnUse", x: "0", y: "0", width: "100", height: "20", children: jsx("rect", { width: "100", height: "20", fill: "url(#paint0_linear_1083_18992)" }) }), jsx("g", { mask: "url(#mask0_1083_18992)", children: jsx("rect", { width: "100", height: "20", fill: "currentColor" }) })] }), jsxs("defs", { children: [jsxs("linearGradient", { id: "paint0_linear_1083_18992", x1: "0", y1: "10", x2: "100", y2: "10", gradientUnits: "userSpaceOnUse", className: "tw-animate-loading-gradient", children: [jsx("stop", { "stop-color": "#D9D9D9", "stop-opacity": "0.33" }), jsx("stop", { offset: "0.395881", "stop-color": "#737373", "stop-opacity": "0.33" }), jsx("stop", { offset: "0.597867", "stop-color": "#737373", "stop-opacity": "0.66" }), jsx("stop", { offset: "0.697004", "stop-color": "#737373", "stop-opacity": "0.33" })] }), jsx("clipPath", { id: "clip0_1083_18992", children: jsx("path", { d: "M0 10C0 4.47715 4.47715 0 10 0H90C95.5228 0 100 4.47715 100 10C100 15.5228 95.5229 20 90 20H10C4.47716 20 0 15.5228 0 10Z", fill: "white" }) })] })] }));
|
|
3193
|
+
}
|
|
3194
|
+
|
|
3044
3195
|
const listItemSizeMap = {
|
|
3045
3196
|
small: 'tw-max-w-list-item-small tw-h-list-item-small tw-px-squid-xs',
|
|
3046
3197
|
large: 'tw-max-w-list-item-large tw-h-list-item-large tw-px-squid-xs',
|
|
3047
3198
|
};
|
|
3048
3199
|
function ListItem(_a) {
|
|
3049
|
-
var { itemTitle, mainImageUrl, subtitle, detail, icon, secondaryImageUrl, size = 'large', mainIcon, className, isSelected, onDetailClick, showDetailOnHoverOnly, rounded = false, detailButtonClassName } = _a, props = __rest(_a, ["itemTitle", "mainImageUrl", "subtitle", "detail", "icon", "secondaryImageUrl", "size", "mainIcon", "className", "isSelected", "onDetailClick", "showDetailOnHoverOnly", "rounded", "detailButtonClassName"]);
|
|
3050
|
-
return (jsx("li", Object.assign({}, props, { className: cn('tw-group/list-item tw-flex tw-bg-grey-900 tw-text-grey-300', listItemSizeMap[size], className), children: jsxs("div", { className: cn('tw-flex tw-w-full tw-cursor-pointer tw-items-center tw-justify-start tw-gap-squid-xs tw-rounded-squid-s tw-px-squid-xs tw-py-squid-xxs hover:tw-bg-material-light-thin', isSelected && 'tw-bg-material-light-thin'), children: [size === 'large' ? (jsx("div", { className: "tw-h-10 tw-w-10", children: mainIcon ? (mainIcon) : (jsx(BadgeImage, { extraMarginForBadge: false, imageUrl: mainImageUrl, badgeUrl: secondaryImageUrl, size: "md", rounded: rounded })) })) : (jsx("div", { className: "tw-flex tw-min-h-[30px] tw-min-w-[30px] tw-items-center tw-justify-center", children: mainIcon ? (mainIcon) : (jsx("img", { src: mainImageUrl, className: "tw-h-[30px] tw-w-[30px] tw-rounded-squid-xs" })) })), jsxs("div", { className: cn('tw-flex tw-h-[40px] tw-
|
|
3200
|
+
var { itemTitle, mainImageUrl, subtitle, detail, icon, secondaryImageUrl, size = 'large', mainIcon, className, isSelected, onDetailClick, showDetailOnHoverOnly, rounded = false, detailButtonClassName, loading } = _a, props = __rest(_a, ["itemTitle", "mainImageUrl", "subtitle", "detail", "icon", "secondaryImageUrl", "size", "mainIcon", "className", "isSelected", "onDetailClick", "showDetailOnHoverOnly", "rounded", "detailButtonClassName", "loading"]);
|
|
3201
|
+
return (jsx("li", Object.assign({}, props, { className: cn('tw-group/list-item tw-flex tw-max-w-full tw-bg-grey-900 tw-text-grey-300', listItemSizeMap[size], className), children: jsxs("div", { className: cn('tw-flex tw-w-full tw-max-w-full tw-cursor-pointer tw-items-center tw-justify-start tw-gap-squid-xs tw-rounded-squid-s tw-px-squid-xs tw-py-squid-xxs hover:tw-bg-material-light-thin', isSelected && 'tw-bg-material-light-thin'), children: [size === 'large' ? (jsx("div", { className: "tw-h-10 tw-w-10", children: mainIcon ? (mainIcon) : (jsx(BadgeImage, { extraMarginForBadge: false, imageUrl: mainImageUrl, badgeUrl: secondaryImageUrl, size: "md", rounded: rounded })) })) : (jsx("div", { className: "tw-flex tw-min-h-[30px] tw-min-w-[30px] tw-items-center tw-justify-center", children: mainIcon ? (mainIcon) : (jsx("img", { src: mainImageUrl, className: "tw-h-[30px] tw-w-[30px] tw-rounded-squid-xs" })) })), jsxs("div", { className: cn('tw-flex tw-h-[40px] tw-flex-1 tw-flex-col tw-items-start tw-justify-center tw-gap-squid-xs',
|
|
3051
3202
|
// 'large' variant has extra padding
|
|
3052
|
-
size === 'large'
|
|
3203
|
+
size === 'large' ? 'tw-w-[56%] tw-pl-squid-xxs' : 'tw-w-[67%]'), children: [typeof itemTitle === 'string' ? (jsx(BodyText, { size: "small", className: "tw-max-w-full tw-truncate !tw-leading-[18px]", children: itemTitle })) : (itemTitle), size === 'large' &&
|
|
3204
|
+
((loading === null || loading === void 0 ? void 0 : loading.subtitle) ? (jsx(LoadingSkeleton, { className: "-tw-translate-x-6 tw-text-grey-500", height: "10" })) : subtitle ? (jsx(CaptionText, { className: "tw-h-squid-xs !tw-leading-[10px] tw-text-grey-500", children: subtitle })) : null)] }), jsxs("button", { onClick: (event) => {
|
|
3053
3205
|
// prevent click event from bubbling up to parent
|
|
3054
3206
|
event.stopPropagation();
|
|
3055
3207
|
onDetailClick === null || onDetailClick === void 0 ? void 0 : onDetailClick();
|
|
@@ -3077,9 +3229,6 @@ function SettingsItem({ icon, label, controls, transparentControls = false, show
|
|
|
3077
3229
|
function SwapDetailListItem({ label, detail, icon, isLoading = false, }) {
|
|
3078
3230
|
return (jsx("li", { className: "tw-swap-detail-list-item-gradient tw-h-squid-l tw-w-full tw-bg-grey-800 tw-px-squid-xs tw-text-grey-300", children: jsxs("div", { className: "tw-flex tw-h-squid-l tw-items-center tw-justify-between tw-gap-squid-xs tw-rounded-squid-xs tw-px-squid-xs", children: [jsx("div", { className: "tw-h-6 tw-w-6 tw-text-grey-500", children: icon }), jsx(CaptionText, { className: "tw-flex-1 tw-text-grey-500", children: label }), isLoading ? (jsx(LoadingSkeleton, { className: "tw-text-grey-500" })) : typeof detail === 'string' ? (jsx(CaptionText, { children: detail })) : (detail)] }) }));
|
|
3079
3231
|
}
|
|
3080
|
-
function LoadingSkeleton({ className }) {
|
|
3081
|
-
return (jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "100", height: "20", viewBox: "0 0 100 20", fill: "none", className: className, children: [jsxs("g", { "clip-path": "url(#clip0_1083_18992)", children: [jsx("mask", { id: "mask0_1083_18992", style: { maskType: 'alpha' }, maskUnits: "userSpaceOnUse", x: "0", y: "0", width: "100", height: "20", children: jsx("rect", { width: "100", height: "20", fill: "url(#paint0_linear_1083_18992)" }) }), jsx("g", { mask: "url(#mask0_1083_18992)", children: jsx("rect", { width: "100", height: "20", fill: "currentColor" }) })] }), jsxs("defs", { children: [jsxs("linearGradient", { id: "paint0_linear_1083_18992", x1: "0", y1: "10", x2: "100", y2: "10", gradientUnits: "userSpaceOnUse", className: "tw-animate-loading-gradient", children: [jsx("stop", { "stop-color": "#D9D9D9", "stop-opacity": "0.33" }), jsx("stop", { offset: "0.395881", "stop-color": "#737373", "stop-opacity": "0.33" }), jsx("stop", { offset: "0.597867", "stop-color": "#737373", "stop-opacity": "0.66" }), jsx("stop", { offset: "0.697004", "stop-color": "#737373", "stop-opacity": "0.33" })] }), jsx("clipPath", { id: "clip0_1083_18992", children: jsx("path", { d: "M0 10C0 4.47715 4.47715 0 10 0H90C95.5228 0 100 4.47715 100 10C100 15.5228 95.5229 20 90 20H10C4.47716 20 0 15.5228 0 10Z", fill: "white" }) })] })] }));
|
|
3082
|
-
}
|
|
3083
3232
|
|
|
3084
3233
|
function SwapStepSeparator() {
|
|
3085
3234
|
return (jsx("span", { className: "tw-flex tw-h-squid-m tw-w-squid-xxl tw-items-center tw-justify-center tw-self-stretch tw-py-0.5", children: jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "4", height: "21", viewBox: "0 0 4 21", fill: "none", children: jsx("path", { d: "M2 2.5V18.5", stroke: "currentColor", "stroke-width": "4", "stroke-linecap": "round" }) }) }));
|
|
@@ -3140,7 +3289,7 @@ function SwapInputsIcon() {
|
|
|
3140
3289
|
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)" }) }) })] }));
|
|
3141
3290
|
}
|
|
3142
3291
|
|
|
3143
|
-
function SwapConfiguration({ priceImpactPercentage, amount, swapAmountUsd = '0', balance = '0', isFetching = false, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, address, error, }) {
|
|
3292
|
+
function SwapConfiguration({ priceImpactPercentage, amount, forcedAmount, swapAmountUsd = '0', balance = '0', isFetching = false, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, onBalanceButtonClick, address, error, }) {
|
|
3144
3293
|
var _a;
|
|
3145
3294
|
const priceImpactClass = ((_a = Number(priceImpactPercentage)) !== null && _a !== void 0 ? _a : 0) > 5
|
|
3146
3295
|
? 'tw-text-status-negative'
|
|
@@ -3148,7 +3297,9 @@ function SwapConfiguration({ priceImpactPercentage, amount, swapAmountUsd = '0',
|
|
|
3148
3297
|
const isInteractive = direction === 'from';
|
|
3149
3298
|
// improve accessibility
|
|
3150
3299
|
const BalanceButtonTag = isInteractive ? 'button' : 'div';
|
|
3151
|
-
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(
|
|
3300
|
+
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
|
|
3301
|
+
? 'hover:tw-bg-material-light-thin'
|
|
3302
|
+
: 'tw-pointer-events-none'), children: [jsx(CaptionText, { className: "tw-opacity-66", children: "Balance" }), jsx(CaptionText, { children: balance }), jsx(MaxIcon, {})] })] }))] }));
|
|
3152
3303
|
}
|
|
3153
3304
|
|
|
3154
3305
|
function SwapProgressViewHeader({ title, description, }) {
|
|
@@ -3252,4 +3403,4 @@ function SquidConfigProvider({ theme, children, themeType = 'light', }) {
|
|
|
3252
3403
|
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 }));
|
|
3253
3404
|
}
|
|
3254
3405
|
|
|
3255
|
-
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, useModal };
|
|
3406
|
+
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, 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,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,13 @@ 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
|
};
|
|
27
28
|
}
|
|
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;
|
|
29
|
+
export declare function SwapConfiguration({ priceImpactPercentage, amount, forcedAmount, swapAmountUsd, balance, isFetching, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, onBalanceButtonClick, address, error, }: SwapConfigurationProps): import("react/jsx-runtime").JSX.Element;
|
|
29
30
|
export {};
|
|
@@ -14,7 +14,10 @@ interface ListItemProps extends React.HTMLAttributes<HTMLLIElement> {
|
|
|
14
14
|
showDetailOnHoverOnly?: boolean;
|
|
15
15
|
rounded?: boolean;
|
|
16
16
|
detailButtonClassName?: string;
|
|
17
|
+
loading?: {
|
|
18
|
+
subtitle?: boolean;
|
|
19
|
+
};
|
|
17
20
|
}
|
|
18
21
|
type ListItemSize = 'small' | 'large';
|
|
19
|
-
export declare function ListItem({ itemTitle, mainImageUrl, subtitle, detail, icon, secondaryImageUrl, size, mainIcon, className, isSelected, onDetailClick, showDetailOnHoverOnly, rounded, detailButtonClassName, ...props }: ListItemProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare function ListItem({ itemTitle, mainImageUrl, subtitle, detail, icon, secondaryImageUrl, size, mainIcon, className, isSelected, onDetailClick, showDetailOnHoverOnly, rounded, detailButtonClassName, loading, ...props }: ListItemProps): import("react/jsx-runtime").JSX.Element;
|
|
20
23
|
export {};
|
|
@@ -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 {};
|
|
@@ -4,6 +4,7 @@ declare const meta: Meta<typeof ListItem>;
|
|
|
4
4
|
export default meta;
|
|
5
5
|
type Story = StoryObj<typeof meta>;
|
|
6
6
|
export declare const Large: Story;
|
|
7
|
+
export declare const LargeWithLongTitle: Story;
|
|
7
8
|
export declare const LargeRoundedFull: Story;
|
|
8
9
|
export declare const LargeWithSubtitle: Story;
|
|
9
10
|
export declare const LargeWithDetail: Story;
|
|
@@ -13,7 +14,9 @@ export declare const LargeShowDetailOnHoverOnly: Story;
|
|
|
13
14
|
export declare const LargeWithSecondaryImage: Story;
|
|
14
15
|
export declare const LargeSelected: Story;
|
|
15
16
|
export declare const LargeWithCustomIconAsImage: Story;
|
|
17
|
+
export declare const LargeLoading: Story;
|
|
16
18
|
export declare const Small: Story;
|
|
19
|
+
export declare const SmallWithLongTitle: Story;
|
|
17
20
|
export declare const SmallWithIcon: Story;
|
|
18
21
|
export declare const SmallShowDetailOnHoverOnly: Story;
|
|
19
22
|
export declare const SmallSelected: Story;
|
package/dist/index.css
CHANGED
|
@@ -1139,10 +1139,18 @@ video {
|
|
|
1139
1139
|
width: 54px;
|
|
1140
1140
|
}
|
|
1141
1141
|
|
|
1142
|
+
.tw-w-\[56\%\] {
|
|
1143
|
+
width: 56%;
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1142
1146
|
.tw-w-\[60px\] {
|
|
1143
1147
|
width: 60px;
|
|
1144
1148
|
}
|
|
1145
1149
|
|
|
1150
|
+
.tw-w-\[67\%\] {
|
|
1151
|
+
width: 67%;
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1146
1154
|
.tw-w-\[72px\] {
|
|
1147
1155
|
width: 72px;
|
|
1148
1156
|
}
|
|
@@ -1245,6 +1253,10 @@ video {
|
|
|
1245
1253
|
max-width: 72px;
|
|
1246
1254
|
}
|
|
1247
1255
|
|
|
1256
|
+
.tw-max-w-full {
|
|
1257
|
+
max-width: 100%;
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1248
1260
|
.tw-max-w-list-item-large {
|
|
1249
1261
|
max-width: 23.75rem;
|
|
1250
1262
|
}
|
|
@@ -1279,6 +1291,11 @@ video {
|
|
|
1279
1291
|
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));
|
|
1280
1292
|
}
|
|
1281
1293
|
|
|
1294
|
+
.-tw-translate-x-6 {
|
|
1295
|
+
--tw-translate-x: -1.5rem;
|
|
1296
|
+
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));
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1282
1299
|
.-tw-translate-x-\[2px\] {
|
|
1283
1300
|
--tw-translate-x: -2px;
|
|
1284
1301
|
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));
|
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;
|
|
@@ -103,6 +103,16 @@ interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
|
103
103
|
}
|
|
104
104
|
declare function Input({ placeholder, showIcon, showPasteButton, className, icon, ...props }: InputProps): react_jsx_runtime.JSX.Element;
|
|
105
105
|
|
|
106
|
+
interface Props extends InputHTMLAttributes<HTMLInputElement> {
|
|
107
|
+
onParsedValueChanged: (value: string) => void;
|
|
108
|
+
initialValue?: string;
|
|
109
|
+
forcedUpdateValue?: string;
|
|
110
|
+
maxDecimals?: number;
|
|
111
|
+
balance?: string;
|
|
112
|
+
sourceTokenUsdPrice?: number;
|
|
113
|
+
}
|
|
114
|
+
declare const NumericInput: ({ onParsedValueChanged, initialValue, forcedUpdateValue, maxDecimals, balance, sourceTokenUsdPrice, ...props }: Props) => react_jsx_runtime.JSX.Element;
|
|
115
|
+
|
|
106
116
|
interface SettingsSliderProps {
|
|
107
117
|
value: number;
|
|
108
118
|
type: 'percentage' | 'amount';
|
|
@@ -197,9 +207,12 @@ interface ListItemProps extends React.HTMLAttributes<HTMLLIElement> {
|
|
|
197
207
|
showDetailOnHoverOnly?: boolean;
|
|
198
208
|
rounded?: boolean;
|
|
199
209
|
detailButtonClassName?: string;
|
|
210
|
+
loading?: {
|
|
211
|
+
subtitle?: boolean;
|
|
212
|
+
};
|
|
200
213
|
}
|
|
201
214
|
type ListItemSize = 'small' | 'large';
|
|
202
|
-
declare function ListItem({ itemTitle, mainImageUrl, subtitle, detail, icon, secondaryImageUrl, size, mainIcon, className, isSelected, onDetailClick, showDetailOnHoverOnly, rounded, detailButtonClassName, ...props }: ListItemProps): react_jsx_runtime.JSX.Element;
|
|
215
|
+
declare function ListItem({ itemTitle, mainImageUrl, subtitle, detail, icon, secondaryImageUrl, size, mainIcon, className, isSelected, onDetailClick, showDetailOnHoverOnly, rounded, detailButtonClassName, loading, ...props }: ListItemProps): react_jsx_runtime.JSX.Element;
|
|
203
216
|
|
|
204
217
|
interface MenuItemProps {
|
|
205
218
|
label: string;
|
|
@@ -288,6 +301,7 @@ interface SwapConfigurationProps {
|
|
|
288
301
|
direction: SwapDirection;
|
|
289
302
|
priceImpactPercentage?: string;
|
|
290
303
|
amount?: string;
|
|
304
|
+
forcedAmount?: string;
|
|
291
305
|
swapAmountUsd?: string;
|
|
292
306
|
balance?: string;
|
|
293
307
|
isFetching?: boolean;
|
|
@@ -302,14 +316,15 @@ interface SwapConfigurationProps {
|
|
|
302
316
|
textColor: string;
|
|
303
317
|
};
|
|
304
318
|
address?: string;
|
|
305
|
-
onAmountChange?: (
|
|
319
|
+
onAmountChange?: (amount: string) => void;
|
|
306
320
|
onWalletButtonClick?: () => void;
|
|
307
321
|
onAssetsButtonClick?: () => void;
|
|
322
|
+
onBalanceButtonClick?: () => void;
|
|
308
323
|
error?: {
|
|
309
324
|
message: string;
|
|
310
325
|
};
|
|
311
326
|
}
|
|
312
|
-
declare function SwapConfiguration({ priceImpactPercentage, amount, swapAmountUsd, balance, isFetching, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, address, error, }: SwapConfigurationProps): react_jsx_runtime.JSX.Element;
|
|
327
|
+
declare function SwapConfiguration({ priceImpactPercentage, amount, forcedAmount, swapAmountUsd, balance, isFetching, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, onBalanceButtonClick, address, error, }: SwapConfigurationProps): react_jsx_runtime.JSX.Element;
|
|
313
328
|
|
|
314
329
|
interface SwapProgressViewHeaderProps {
|
|
315
330
|
title: string;
|
|
@@ -405,4 +420,4 @@ declare function useModal(props?: {
|
|
|
405
420
|
openModalButtonRef: React.RefObject<HTMLButtonElement>;
|
|
406
421
|
};
|
|
407
422
|
|
|
408
|
-
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 };
|
|
423
|
+
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, SwapConfiguration, SwapDetailListItem, SwapProgressViewHeader, SwapStepItem, SwapStepsCollapsed, Switch, TokenPair, Tooltip, type TooltipThreshold, type TooltipWidth, UsdAmount, useModal };
|