@rabbitio/ui-kit 1.0.0-beta.82 → 1.0.0-beta.84
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/coverage/clover.xml +1272 -546
- package/coverage/coverage-final.json +27 -17
- package/coverage/index.html +125 -50
- package/coverage/rabbit-ui-kit/index.html +1 -1
- package/coverage/rabbit-ui-kit/index.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/analyticsAdapters/googleAnalyticsAdapter.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/analyticsAdapters/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/analyticsAdapters/mixpanelAdapter.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/axiosAdapter.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/adapters/qrUtils.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/amountUtils.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/errorUtils.js.html +13 -13
- package/coverage/rabbit-ui-kit/src/common-apis/external-apis/apiGroups.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/external-apis/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/external-apis/ipAddressProviders.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/fiatCurrenciesService.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/globalConstants.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/models/blockchain.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/models/coin.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/models/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/models/protocol.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/utils/cache.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/utils/emailAPI.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/utils/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/utils/logging/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/utils/logging/logger.js.html +4 -4
- package/coverage/rabbit-ui-kit/src/common-apis/utils/logging/logsStorage.js.html +3 -3
- package/coverage/rabbit-ui-kit/src/common-apis/utils/postponeExecution.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/common-apis/utils/safeStringify.js.html +27 -27
- package/coverage/rabbit-ui-kit/src/index.html +5 -5
- package/coverage/rabbit-ui-kit/src/index.js.html +16 -4
- package/coverage/rabbit-ui-kit/src/robust-api-caller/cacheAndConcurrentRequestsResolver.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/robust-api-caller/cachedRobustExternalApiCallerService.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/robust-api-caller/cancelProcessing.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/robust-api-caller/concurrentCalculationsMetadataHolder.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/robust-api-caller/externalApiProvider.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/robust-api-caller/externalServicesStatsCollector.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/robust-api-caller/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/robust-api-caller/robustExternalAPICallerService.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/index.html +28 -28
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/letsExchangeSwapProvider.js.html +37 -7
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/swapProvider.js.html +58 -16
- package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/swapspaceSwapProvider.js.html +79 -31
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/baseSwapCreationInfo.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/existingSwap.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/existingSwapWithFiatData.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/index.html +22 -7
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/partner.js.html +106 -0
- package/coverage/rabbit-ui-kit/src/swaps-lib/models/swapProviderCoinInfo.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/swaps-lib/services/index.html +5 -5
- package/coverage/rabbit-ui-kit/src/swaps-lib/services/publicSwapService.js.html +78 -12
- package/coverage/rabbit-ui-kit/src/swaps-lib/utils/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/swaps-lib/utils/swapUtils.js.html +2 -2
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/arrowIcon.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/arrowTosca.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/arrowWhite.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/darkRectangle.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/determinedError.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/failedValidationIcon.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/index.html +35 -5
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/infoIcon.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/messageIcon.jsx.html +346 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/noticeQuestionIcon.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/successfulValidationIcon.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/supportDialogImage.jsx.html +268 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/walletIcon.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/AssetIcon/AssetIcon.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/AssetIcon/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/AssetSelection/AssetSelection.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/AssetSelection/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/BackgroundTitle/BackgroundTitle.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/BackgroundTitle/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/InformationMessage/InformationMessage.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/InformationMessage/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Input/Input.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Input/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/LoadingDots/LoadingDots.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/LoadingDots/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/NoticeIcon/NoticeIcon.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/NoticeIcon/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/QrCode/QrCode.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/QrCode/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/RateSelector/RateSelector.jsx.html +3 -3
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/RateSelector/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/SupportChat/SupportChat.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/SupportChat/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Textarea/Textarea.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Textarea/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/TitleBox/TitleBox.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/TitleBox/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Tooltip/Tooltip.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Tooltip/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/TwoLinesOfText/LinesOfText.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/TwoLinesOfText/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Validation/Validation.jsx.html +12 -18
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Validation/index.html +5 -5
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/Button/Button.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/Button/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/Close/Close.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/Close/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/LinkButton/LinkButton.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/LinkButton/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/RadioButtonWithText/RadioButtonWithText.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/RadioButtonWithText/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/AmountInput/AmountInput.jsx.html +79 -52
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/AmountInput/index.html +5 -5
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/CoinPicker/CoinPicker.jsx.html +87 -231
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/CoinPicker/index.html +5 -5
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/ColoredNotice/ColoredNotice.jsx.html +211 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/ColoredNotice/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/LineWithIconLink/LineWithIconLink.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/LineWithIconLink/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/LogoCarousel/LogoCarousel.jsx.html +196 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/LogoCarousel/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/SearchableCoinsList/SearchableCoinsList.jsx.html +496 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/SearchableCoinsList/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/TitledLineWithIconLink/TitledLineWithIconLink.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/TitledLineWithIconLink/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/CoinPickerDialogStep/CoinPickerDialogStep.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/CoinPickerDialogStep/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/Dialog.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/DialogButtons/DialogButtons.jsx.html +34 -4
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/DialogButtons/index.html +5 -5
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/DialogStep/DialogStep.jsx.html +52 -4
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/DialogStep/index.html +5 -5
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/SwapForm/SwapForm.jsx.html +85 -16
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/SwapForm/index.html +5 -5
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/WaitlistSubscription/WaitlistSubscription.jsx.html +559 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/WaitlistSubscription/index.html +116 -0
- package/coverage/rabbit-ui-kit/src/ui-kit/components/templates/DeterminedErrorDialogStep/DeterminedErrorDialogStep.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/components/templates/DeterminedErrorDialogStep/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/hooks/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/hooks/useCallHandlingErrors.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/hooks/useIsHydrated.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/hooks/useReferredState.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/utils/index.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/utils/inputValueProviders.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/utils/textUtils.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/utils/uiUtils.js.html +1 -1
- package/coverage/rabbit-ui-kit/src/ui-kit/utils/urlQueryUtils.js.html +1 -1
- package/coverage/rabbit-ui-kit/stories/atoms/BackgroundTitle.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/atoms/LinesOfText.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/atoms/LoadingDots.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/atoms/QrCode.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/atoms/RateSelector.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/atoms/Validation.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/atoms/buttons/Button.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/atoms/buttons/Close.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/atoms/buttons/LinkButton.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/atoms/buttons/index.html +1 -1
- package/coverage/rabbit-ui-kit/stories/atoms/index.html +1 -1
- package/coverage/rabbit-ui-kit/stories/molecules/CoinPicker.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/molecules/ColoredNotice.stories.jsx.html +178 -0
- package/coverage/rabbit-ui-kit/stories/molecules/LineWithIconLink.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/molecules/LogoCarousel.stories.jsx.html +160 -0
- package/coverage/rabbit-ui-kit/stories/molecules/TitledLineWithIconLink.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/molecules/index.html +35 -5
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/Dialog.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogButtons/DialogButtons.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogButtons/index.html +1 -1
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogStep/DialogStep.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogStep/index.html +1 -1
- package/coverage/rabbit-ui-kit/stories/organisms/Dialog/index.html +1 -1
- package/coverage/rabbit-ui-kit/stories/organisms/WaitlistSubscription.stories.jsx.html +151 -0
- package/coverage/rabbit-ui-kit/stories/organisms/index.html +116 -0
- package/coverage/rabbit-ui-kit/stories/stubs/coins.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/stubs/exampleContent.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/stubs/index.html +1 -1
- package/coverage/rabbit-ui-kit/stories/templates/DeterminedErrorDialogStep.stories.jsx.html +1 -1
- package/coverage/rabbit-ui-kit/stories/templates/index.html +1 -1
- package/dist/global.css.map +1 -1
- package/dist/index.cjs +1151 -536
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +93 -0
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +955 -447
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +1148 -537
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +1151 -536
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/index.js +4 -0
- package/src/swaps-lib/external-apis/letsExchangeSwapProvider.js +13 -3
- package/src/swaps-lib/external-apis/swapProvider.js +22 -8
- package/src/swaps-lib/external-apis/swapspaceSwapProvider.js +23 -7
- package/src/swaps-lib/models/partner.js +7 -0
- package/src/swaps-lib/services/publicSwapService.js +30 -8
- package/src/swaps-lib/utils/swapUtils.js +1 -1
- package/src/ui-kit/assets/styles/global.scss +4 -7
- package/src/ui-kit/assets/wrappedImages/messageIcon.jsx +87 -0
- package/src/ui-kit/assets/wrappedImages/supportDialogImage.jsx +61 -0
- package/src/ui-kit/components/atoms/RateSelector/RateSelector.jsx +2 -2
- package/src/ui-kit/components/atoms/Validation/Validation.jsx +7 -9
- package/src/ui-kit/components/atoms/Validation/validation.module.scss +4 -0
- package/src/ui-kit/components/molecules/AmountInput/AmountInput.jsx +57 -48
- package/src/ui-kit/components/molecules/AmountInput/amount-input.module.scss +33 -0
- package/src/ui-kit/components/molecules/CoinPicker/CoinPicker.jsx +84 -132
- package/src/ui-kit/components/molecules/ColoredNotice/ColoredNotice.jsx +42 -0
- package/src/ui-kit/components/molecules/ColoredNotice/colored-notice.module.scss +20 -0
- package/src/ui-kit/components/molecules/LogoCarousel/LogoCarousel.jsx +37 -0
- package/src/ui-kit/components/molecules/LogoCarousel/logo-carousel.module.scss +64 -0
- package/src/ui-kit/components/molecules/SearchableCoinsList/SearchableCoinsList.jsx +137 -0
- package/src/ui-kit/components/organisms/Dialog/DialogButtons/DialogButtons.jsx +10 -0
- package/src/ui-kit/components/organisms/Dialog/DialogStep/DialogStep.jsx +16 -0
- package/src/ui-kit/components/organisms/SwapForm/SwapForm.jsx +35 -12
- package/src/ui-kit/components/organisms/WaitlistSubscription/WaitlistSubscription.jsx +158 -0
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
gap: 10px;
|
|
10
10
|
justify-content: space-between;
|
|
11
11
|
transition: 0.2s box-shadow ease;
|
|
12
|
+
height: 86.5px;
|
|
12
13
|
|
|
13
14
|
&.upper-form-position {
|
|
14
15
|
border-bottom-left-radius: 4px;
|
|
@@ -152,6 +153,38 @@
|
|
|
152
153
|
align-items: center;
|
|
153
154
|
font-size: 14px;
|
|
154
155
|
|
|
156
|
+
&-enter {
|
|
157
|
+
opacity: 0;
|
|
158
|
+
margin-top: -19px;
|
|
159
|
+
transform: translateY(24px);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
&-enter-active {
|
|
163
|
+
opacity: 1;
|
|
164
|
+
transition:
|
|
165
|
+
opacity 0.2s $transitionEaseOut,
|
|
166
|
+
margin-top 0.2s $transitionEaseOut,
|
|
167
|
+
transform 0.2s $transitionEaseOut;
|
|
168
|
+
margin-top: 0;
|
|
169
|
+
transform: translateY(0);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
&-exit {
|
|
173
|
+
opacity: 1;
|
|
174
|
+
margin-top: 0;
|
|
175
|
+
transform: translateY(0);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
&-exit-active {
|
|
179
|
+
opacity: 0;
|
|
180
|
+
transition:
|
|
181
|
+
opacity 0.1s $transitionEaseOut,
|
|
182
|
+
margin-top 0.2s $transitionEaseOut,
|
|
183
|
+
transform 0.2s $transitionEaseOut;
|
|
184
|
+
margin-top: -19px;
|
|
185
|
+
transform: translateY(24px);
|
|
186
|
+
}
|
|
187
|
+
|
|
155
188
|
&-currency,
|
|
156
189
|
&-input,
|
|
157
190
|
&-placeholder {
|
|
@@ -15,6 +15,7 @@ import { FALLBACK_ASSET_ICON_URL } from "../../../../common-apis/globalConstants
|
|
|
15
15
|
import { AssetIcon } from "../../atoms/AssetIcon/AssetIcon.jsx";
|
|
16
16
|
import { Button } from "../../atoms/buttons/Button/Button.jsx";
|
|
17
17
|
import { LoadingDots } from "../../atoms/LoadingDots/LoadingDots.jsx";
|
|
18
|
+
import { SearchableCoinsList } from "../SearchableCoinsList/SearchableCoinsList.jsx";
|
|
18
19
|
|
|
19
20
|
export const COIN_PICKER_MODES = {
|
|
20
21
|
BUTTON: "BUTTON",
|
|
@@ -92,7 +93,6 @@ export const CoinPicker = ({
|
|
|
92
93
|
const handleError = useCallHandlingErrors();
|
|
93
94
|
|
|
94
95
|
const [coins, setCoins] = useState(null);
|
|
95
|
-
const [filteredCoins, setFilteredCoins] = useState([]);
|
|
96
96
|
const [initiallyEnabledCoins, setInitiallyEnabledCoins] = useReferredState({});
|
|
97
97
|
const [currentlyEnabledCoins, setCurrentlyEnabledCoins] = useReferredState({});
|
|
98
98
|
const [searchFieldValue, setSearchFieldValue] = useState("");
|
|
@@ -102,9 +102,9 @@ export const CoinPicker = ({
|
|
|
102
102
|
const [coinsContent, setCoinsContent] = useState(null);
|
|
103
103
|
const [isCoinsDataReloadable, setIsCoinsDataReloadable] = useState(false);
|
|
104
104
|
|
|
105
|
-
const [limitedCoinsNumber, setLimitedCoinsNumber] = useState(0);
|
|
106
|
-
const [displayedCoins, setDisplayedCoins] = useState([]);
|
|
107
105
|
const [isListFull, setIsListFull] = useState(true);
|
|
106
|
+
const [isSearchResultEmpty, setIsSearchResultEmpty] = useState(false);
|
|
107
|
+
const [triggerLoadMoreCoins, setTriggerLoadMoreCoins] = useState(0);
|
|
108
108
|
|
|
109
109
|
const searchRef = useRef();
|
|
110
110
|
const scrollContainerRef = useRef();
|
|
@@ -158,58 +158,11 @@ export const CoinPicker = ({
|
|
|
158
158
|
handleClick(coin.ticker);
|
|
159
159
|
};
|
|
160
160
|
|
|
161
|
-
const handleSearchAsset = value => {
|
|
162
|
-
// TODO: [refactoring, high] use unified search function. task_id=be0475316f374dd4a926c948d969e704
|
|
163
|
-
setSearchFieldValue(value); // Trim the input to handle leading/trailing spaces
|
|
164
|
-
const searchTerm = value.trim().toLowerCase();
|
|
165
|
-
if (searchTerm !== "") {
|
|
166
|
-
const searchWords = searchTerm.split(/\s+/); // Split search terms on whitespace
|
|
167
|
-
|
|
168
|
-
const filteredAndSortedCoins = coins
|
|
169
|
-
.filter(coin => {
|
|
170
|
-
// Check if all search words are found in any of the given properties
|
|
171
|
-
return searchWords.every(
|
|
172
|
-
word =>
|
|
173
|
-
coin?.latinName?.toLowerCase().includes(word) ||
|
|
174
|
-
coin?.ticker?.toLowerCase().includes(word) ||
|
|
175
|
-
coin?.tickerPrintable?.toLowerCase().includes(word)
|
|
176
|
-
);
|
|
177
|
-
})
|
|
178
|
-
.sort((a, b) => {
|
|
179
|
-
// Check for exact matches
|
|
180
|
-
const aMatch =
|
|
181
|
-
a.latinName.toLowerCase() === searchTerm ||
|
|
182
|
-
a.ticker.toLowerCase() === searchTerm ||
|
|
183
|
-
a.tickerPrintable.toLowerCase() === searchTerm
|
|
184
|
-
? 1
|
|
185
|
-
: 0;
|
|
186
|
-
const bMatch =
|
|
187
|
-
b.latinName.toLowerCase() === searchTerm ||
|
|
188
|
-
b.ticker.toLowerCase() === searchTerm ||
|
|
189
|
-
b.tickerPrintable.toLowerCase() === searchTerm
|
|
190
|
-
? 1
|
|
191
|
-
: 0;
|
|
192
|
-
if (bMatch - aMatch !== 0) {
|
|
193
|
-
// Prioritize exact matches to the top
|
|
194
|
-
return bMatch - aMatch;
|
|
195
|
-
} else {
|
|
196
|
-
// Sort remaining items alphabetically by latinName
|
|
197
|
-
return a.latinName.toLowerCase().localeCompare(b.latinName.toLowerCase());
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
setFilteredCoins(filteredAndSortedCoins);
|
|
202
|
-
} else {
|
|
203
|
-
setFilteredCoins(coins); // Reset to original list if search term is empty
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
|
|
207
161
|
const loadCoinsAndSaveToState = () => {
|
|
208
162
|
(async () => {
|
|
209
163
|
try {
|
|
210
164
|
const data = loadCoinsAndContent ? await loadCoinsAndContent() : await defaultLoadCoinsAndContent();
|
|
211
165
|
setCoins(data.coins);
|
|
212
|
-
setFilteredCoins(data.coins);
|
|
213
166
|
setCoinsContent(data.content);
|
|
214
167
|
setIsCoinsDataReloadable(!!data.isCoinsDataReloadable);
|
|
215
168
|
} catch (e) {
|
|
@@ -256,30 +209,6 @@ export const CoinPicker = ({
|
|
|
256
209
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
257
210
|
}, [search, searchAdaptive, coins]);
|
|
258
211
|
|
|
259
|
-
useEffect(() => {
|
|
260
|
-
if (filteredCoins?.length > partialLoadingIncrement && partialLoadingEnabled) {
|
|
261
|
-
setLimitedCoinsNumber(partialLoadingIncrement);
|
|
262
|
-
} else {
|
|
263
|
-
setLimitedCoinsNumber(0);
|
|
264
|
-
setDisplayedCoins(filteredCoins);
|
|
265
|
-
setIsListFull(true);
|
|
266
|
-
}
|
|
267
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
268
|
-
}, [filteredCoins]);
|
|
269
|
-
|
|
270
|
-
useEffect(() => {
|
|
271
|
-
if (limitedCoinsNumber > 0) {
|
|
272
|
-
const coinsToDisplay = filteredCoins.slice(0, limitedCoinsNumber);
|
|
273
|
-
setDisplayedCoins(coinsToDisplay);
|
|
274
|
-
setIsListFull(coinsToDisplay.length === filteredCoins.length);
|
|
275
|
-
}
|
|
276
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
277
|
-
}, [limitedCoinsNumber]);
|
|
278
|
-
|
|
279
|
-
const displayMoreCoins = () => {
|
|
280
|
-
setLimitedCoinsNumber(prev => prev + partialLoadingIncrement);
|
|
281
|
-
};
|
|
282
|
-
|
|
283
212
|
const skeleton = () => {
|
|
284
213
|
let skeletonItems = [];
|
|
285
214
|
for (let i = 0; i < skeletonItemsCount; i++) {
|
|
@@ -317,11 +246,10 @@ export const CoinPicker = ({
|
|
|
317
246
|
setScrollWrapperClass(s["reached-bottom"]);
|
|
318
247
|
};
|
|
319
248
|
|
|
320
|
-
|
|
321
|
-
useEffect(handleScroll, []);
|
|
249
|
+
const displayMoreCoins = () => setTriggerLoadMoreCoins(prev => prev + 1);
|
|
322
250
|
|
|
323
251
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
324
|
-
useEffect(handleScroll, [
|
|
252
|
+
useEffect(handleScroll, []);
|
|
325
253
|
|
|
326
254
|
const shouldShowSkeleton = coins == null;
|
|
327
255
|
|
|
@@ -332,7 +260,10 @@ export const CoinPicker = ({
|
|
|
332
260
|
<div className={s["coin-picker-search"]}>
|
|
333
261
|
<Input
|
|
334
262
|
value={searchFieldValue}
|
|
335
|
-
onChange={e =>
|
|
263
|
+
onChange={e => {
|
|
264
|
+
setSearchFieldValue(e.target.value);
|
|
265
|
+
handleScroll();
|
|
266
|
+
}}
|
|
336
267
|
placeholder={texts.searchPlaceholder}
|
|
337
268
|
isSmallHeight={true}
|
|
338
269
|
clearButton
|
|
@@ -357,61 +288,82 @@ export const CoinPicker = ({
|
|
|
357
288
|
onScroll={handleScroll}
|
|
358
289
|
>
|
|
359
290
|
<div className={s["coin-picker-wrapper-content-assets"]}>
|
|
360
|
-
{shouldShowSkeleton
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
291
|
+
{shouldShowSkeleton ? (
|
|
292
|
+
skeleton()
|
|
293
|
+
) : (
|
|
294
|
+
<SearchableCoinsList
|
|
295
|
+
searchQuery={searchFieldValue}
|
|
296
|
+
onListUpdated={() => handleScroll()}
|
|
297
|
+
setIsListFull={setIsListFull}
|
|
298
|
+
setIsSearchResultEmpty={setIsSearchResultEmpty}
|
|
299
|
+
triggerLoadMoreCoins={triggerLoadMoreCoins}
|
|
300
|
+
coinsList={allCoins}
|
|
301
|
+
coinsBundle={allCoins.map((coin, index) => {
|
|
302
|
+
return {
|
|
303
|
+
coin: coin,
|
|
304
|
+
component: () => {
|
|
305
|
+
const { assetIconSrc, assetIconProtocolSrc } = coinToIconPaths(coin);
|
|
306
|
+
|
|
307
|
+
return (
|
|
308
|
+
<div
|
|
309
|
+
className={s["item"]}
|
|
310
|
+
key={`picker-${coin.ticker}-${index}`}
|
|
311
|
+
onClick={e => handleError(() => handleCoinClick(coin), e)}
|
|
312
|
+
>
|
|
313
|
+
<div
|
|
314
|
+
className={
|
|
315
|
+
s["link"] +
|
|
316
|
+
(currentlyEnabledCoins.current[coin.ticker] !==
|
|
317
|
+
initiallyEnabledCoins.current[coin.ticker]
|
|
318
|
+
? " " + s["outline"]
|
|
319
|
+
: "")
|
|
320
|
+
}
|
|
321
|
+
>
|
|
322
|
+
<AssetIcon
|
|
323
|
+
assetIconSrc={assetIconSrc}
|
|
324
|
+
assetIconProtocolSrc={assetIconProtocolSrc}
|
|
325
|
+
fallbackSrc={FALLBACK_ASSET_ICON_URL}
|
|
326
|
+
/>
|
|
327
|
+
<div className={s["content"]} key={coin.ticker}>
|
|
328
|
+
<p className={s["name"]}>{coin.latinName}</p>
|
|
329
|
+
<p className={s["amount"]}>
|
|
330
|
+
{coinsContent?.find(i => i.coin === coin)
|
|
331
|
+
?.subtitle ?? ""}
|
|
332
|
+
</p>
|
|
333
|
+
</div>
|
|
334
|
+
{mode === COIN_PICKER_MODES.BUTTON ? (
|
|
335
|
+
<div className={s["arrow"]}>
|
|
336
|
+
<ArrowIcon />
|
|
337
|
+
</div>
|
|
338
|
+
) : mode === COIN_PICKER_MODES.CHECKBOX ? (
|
|
339
|
+
<div className={s["toggle-container"]}>
|
|
340
|
+
<RadioButtonWithText
|
|
341
|
+
onStateChange={resetButtonLoader =>
|
|
342
|
+
handleToggleClick(
|
|
343
|
+
coin.ticker,
|
|
344
|
+
resetButtonLoader
|
|
345
|
+
)
|
|
346
|
+
}
|
|
347
|
+
isSwitchedOn={
|
|
348
|
+
currentlyEnabledCoins.current[coin.ticker]
|
|
349
|
+
}
|
|
350
|
+
id={index}
|
|
351
|
+
/>
|
|
352
|
+
</div>
|
|
353
|
+
) : (
|
|
354
|
+
""
|
|
355
|
+
)}
|
|
356
|
+
</div>
|
|
357
|
+
</div>
|
|
358
|
+
);
|
|
359
|
+
},
|
|
360
|
+
};
|
|
361
|
+
})}
|
|
362
|
+
/>
|
|
363
|
+
)}
|
|
412
364
|
</div>
|
|
413
365
|
|
|
414
|
-
{
|
|
366
|
+
{isSearchResultEmpty ? (
|
|
415
367
|
<div className={s["coin-picker-wrapper-content-asset-not-found"]}>
|
|
416
368
|
<h6>{texts.noAssetsMessage}</h6>
|
|
417
369
|
</div>
|
|
@@ -425,7 +377,7 @@ export const CoinPicker = ({
|
|
|
425
377
|
size="sm"
|
|
426
378
|
loader={false}
|
|
427
379
|
content={texts.loadMoreButton}
|
|
428
|
-
onClick={displayMoreCoins}
|
|
380
|
+
onClick={() => displayMoreCoins()}
|
|
429
381
|
handleError={handleError}
|
|
430
382
|
/>
|
|
431
383
|
</div>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
|
|
4
|
+
import s from "./colored-notice.module.scss";
|
|
5
|
+
|
|
6
|
+
import { Button } from "../../atoms/buttons/Button/Button";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* ColoredNotice component displays a notice with optional text and a button.
|
|
10
|
+
*
|
|
11
|
+
* @component
|
|
12
|
+
* @param {Object} props - The component props.
|
|
13
|
+
* @param {string} [props.text] - The text to be displayed in the notice.
|
|
14
|
+
* @param {string} [props.buttonTitle] - The title of the button.
|
|
15
|
+
* @param {function} [props.onButtonClick] - Callback function to be called when the button is clicked.
|
|
16
|
+
* @returns {JSX.Element} The ColoredNotice component.
|
|
17
|
+
*/
|
|
18
|
+
export const ColoredNotice = ({
|
|
19
|
+
text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor.",
|
|
20
|
+
buttonTitle,
|
|
21
|
+
onButtonClick = () => {},
|
|
22
|
+
}) => {
|
|
23
|
+
return (
|
|
24
|
+
<div className={s["colored-notice"]}>
|
|
25
|
+
<p className={s["colored-notice-text"]}>{text}</p>
|
|
26
|
+
{buttonTitle ? (
|
|
27
|
+
<Button mode="primary" size="sm" content={buttonTitle} loader={false} onClick={onButtonClick} />
|
|
28
|
+
) : null}
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
ColoredNotice.propTypes = {
|
|
34
|
+
text: PropTypes.string,
|
|
35
|
+
buttonTitle: PropTypes.string,
|
|
36
|
+
onButtonClick: PropTypes.func,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
ColoredNotice.defaultProps = {
|
|
40
|
+
text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor.",
|
|
41
|
+
onButtonClick: () => {},
|
|
42
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
@use "../../../assets/styles/index" as *;
|
|
2
|
+
|
|
3
|
+
.colored-notice {
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: flex-start;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
gap: Margin("3");
|
|
8
|
+
justify-content: space-between;
|
|
9
|
+
padding: Padding("5");
|
|
10
|
+
border-radius: $borderRadius;
|
|
11
|
+
background-color: LightColor(army-20);
|
|
12
|
+
width: 100%;
|
|
13
|
+
box-shadow: 0px 0px 0px 1px rgba(SolidColor("army"), 0.1) inset;
|
|
14
|
+
|
|
15
|
+
&-text {
|
|
16
|
+
color: SolidColor("tosca");
|
|
17
|
+
margin: 0;
|
|
18
|
+
text-align: left;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
|
|
4
|
+
import s from "./logo-carousel.module.scss";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* LogoCarousel component renders a set of logos in a sliding carousel.
|
|
8
|
+
*
|
|
9
|
+
* @component
|
|
10
|
+
*
|
|
11
|
+
* @param {Object} props - The props object for this component.
|
|
12
|
+
* @param {Array<{logo: string, url: string}>} props.logos - Array of objects representing logos and their corresponding URLs.
|
|
13
|
+
*/
|
|
14
|
+
export const LogoCarousel = ({ logos }) => {
|
|
15
|
+
return (
|
|
16
|
+
<div className={s["logo-carousel"]}>
|
|
17
|
+
{[...Array(2)].map((z, i) => (
|
|
18
|
+
<div className={s["logo-carousel-slide"]} key={"logo-carousel-slide-" + i}>
|
|
19
|
+
{logos.map((item, index) => (
|
|
20
|
+
<a key={"logo-carousel-slide-" + i + "-" + index} href={item.url} target="_blank">
|
|
21
|
+
<img src={item.logo} alt="logo" />
|
|
22
|
+
</a>
|
|
23
|
+
))}
|
|
24
|
+
</div>
|
|
25
|
+
))}
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
LogoCarousel.propTypes = {
|
|
31
|
+
logos: PropTypes.arrayOf(
|
|
32
|
+
PropTypes.shape({
|
|
33
|
+
logo: PropTypes.string.isRequired,
|
|
34
|
+
url: PropTypes.string.isRequired,
|
|
35
|
+
})
|
|
36
|
+
).isRequired,
|
|
37
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
@use "../../../assets/styles/index" as *;
|
|
2
|
+
|
|
3
|
+
@keyframes slide {
|
|
4
|
+
from {
|
|
5
|
+
transform: translateX(0);
|
|
6
|
+
}
|
|
7
|
+
to {
|
|
8
|
+
transform: translateX(-100%);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.logo-carousel {
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
white-space: nowrap;
|
|
15
|
+
position: relative;
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
justify-content: flex-start;
|
|
19
|
+
width: 100%;
|
|
20
|
+
gap: clamp(30px, 5vw, 40px);
|
|
21
|
+
box-sizing: border-box;
|
|
22
|
+
mask-image: linear-gradient(
|
|
23
|
+
90deg,
|
|
24
|
+
rgba(0, 0, 0, 0) 0%,
|
|
25
|
+
rgba(0, 0, 0, 1) 60px,
|
|
26
|
+
rgba(0, 0, 0, 1) calc(100% - 60px),
|
|
27
|
+
rgba(0, 0, 0, 0) 100%
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
&:hover &-slide {
|
|
31
|
+
animation-play-state: paused;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&-slide {
|
|
35
|
+
display: inline-block;
|
|
36
|
+
animation: 25s slide infinite linear;
|
|
37
|
+
display: inherit;
|
|
38
|
+
align-items: inherit;
|
|
39
|
+
justify-content: inherit;
|
|
40
|
+
gap: inherit;
|
|
41
|
+
|
|
42
|
+
a {
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
transition: 0.1s $transitionEaseOut;
|
|
46
|
+
transform: scale(1);
|
|
47
|
+
|
|
48
|
+
@media (hover: hover) {
|
|
49
|
+
&:hover {
|
|
50
|
+
transform: scale(1.02);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&:active {
|
|
55
|
+
transition: 0.02s $transitionEaseOut;
|
|
56
|
+
transform: scale(0.99);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
img {
|
|
60
|
+
height: clamp(30px, 5vw, 35px);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import { useReferredState } from "../../../hooks/useReferredState";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { Coin } from "../../../../common-apis/models/coin";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A component that displays a list of coins that can be searched and filtered.
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} props - The properties object.
|
|
10
|
+
* @param {Coin[]} props.coinsList - The list of all available coins.
|
|
11
|
+
* @param {Array<{coin: Coin, component: React.Component}>} props.coinsBundle - The bundle of coin components to be displayed.
|
|
12
|
+
* @param {string} props.searchQuery - The search query to filter coins.
|
|
13
|
+
* @param {boolean} props.partialLoadingEnabled - Determines if partial loading is enabled.
|
|
14
|
+
* @param {number} props.partialLoadingIncrement - The increment of coins to load when loading more.
|
|
15
|
+
* @param {Function} props.onListUpdated - Callback when the list of displayed coins is updated.
|
|
16
|
+
* @param {Function} props.setIsListFull - Callback to set if the list is fully displayed.
|
|
17
|
+
* @param {Function} props.setIsSearchResultEmpty - Callback to set if the search result is empty.
|
|
18
|
+
* @param {number} props.triggerLoadMoreCoins - Triggers loading more coins.
|
|
19
|
+
*/
|
|
20
|
+
export const SearchableCoinsList = ({
|
|
21
|
+
coinsList,
|
|
22
|
+
coinsBundle,
|
|
23
|
+
searchQuery,
|
|
24
|
+
partialLoadingEnabled = true,
|
|
25
|
+
partialLoadingIncrement = 100,
|
|
26
|
+
onListUpdated = () => {},
|
|
27
|
+
setIsListFull = () => {},
|
|
28
|
+
setIsSearchResultEmpty = () => {},
|
|
29
|
+
triggerLoadMoreCoins,
|
|
30
|
+
}) => {
|
|
31
|
+
const [filteredCoins, setFilteredCoins] = useState([]);
|
|
32
|
+
const [limitedCoinsNumber, setLimitedCoinsNumber] = useReferredState(0);
|
|
33
|
+
const [displayedCoins, setDisplayedCoins] = useState([]);
|
|
34
|
+
|
|
35
|
+
const handleSearchAsset = value => {
|
|
36
|
+
const searchTerm = value.trim().toLowerCase();
|
|
37
|
+
if (searchTerm !== "") {
|
|
38
|
+
const searchWords = searchTerm.split(/\s+/); // Split search terms on whitespace
|
|
39
|
+
|
|
40
|
+
const filteredAndSortedCoins = coinsList
|
|
41
|
+
.filter(coin => {
|
|
42
|
+
// Check if all search words are found in any of the given properties
|
|
43
|
+
return searchWords.every(
|
|
44
|
+
word =>
|
|
45
|
+
coin?.latinName?.toLowerCase().includes(word) ||
|
|
46
|
+
coin?.ticker?.toLowerCase().includes(word) ||
|
|
47
|
+
coin?.tickerPrintable?.toLowerCase().includes(word)
|
|
48
|
+
);
|
|
49
|
+
})
|
|
50
|
+
.sort((a, b) => {
|
|
51
|
+
// Check for exact matches
|
|
52
|
+
const aMatch =
|
|
53
|
+
a.latinName.toLowerCase() === searchTerm ||
|
|
54
|
+
a.ticker.toLowerCase() === searchTerm ||
|
|
55
|
+
a.tickerPrintable.toLowerCase() === searchTerm
|
|
56
|
+
? 1
|
|
57
|
+
: 0;
|
|
58
|
+
const bMatch =
|
|
59
|
+
b.latinName.toLowerCase() === searchTerm ||
|
|
60
|
+
b.ticker.toLowerCase() === searchTerm ||
|
|
61
|
+
b.tickerPrintable.toLowerCase() === searchTerm
|
|
62
|
+
? 1
|
|
63
|
+
: 0;
|
|
64
|
+
if (bMatch - aMatch !== 0) {
|
|
65
|
+
// Prioritize exact matches to the top
|
|
66
|
+
return bMatch - aMatch;
|
|
67
|
+
} else {
|
|
68
|
+
// Sort remaining items alphabetically by latinName
|
|
69
|
+
return a.latinName.toLowerCase().localeCompare(b.latinName.toLowerCase());
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
setFilteredCoins(filteredAndSortedCoins);
|
|
74
|
+
} else {
|
|
75
|
+
setFilteredCoins(coinsList); // Reset to original list if search term is empty
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const updateDisplayedCoins = () => {
|
|
80
|
+
const fullList = limitedCoinsNumber.current >= filteredCoins.length;
|
|
81
|
+
setDisplayedCoins(fullList ? filteredCoins : filteredCoins.slice(0, limitedCoinsNumber.current));
|
|
82
|
+
setIsListFull(fullList);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const displayMoreCoins = () => {
|
|
86
|
+
setLimitedCoinsNumber(prev => prev + partialLoadingIncrement);
|
|
87
|
+
updateDisplayedCoins();
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
91
|
+
useEffect(() => onListUpdated(), [displayedCoins]);
|
|
92
|
+
|
|
93
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
94
|
+
useEffect(() => displayMoreCoins(), [triggerLoadMoreCoins]);
|
|
95
|
+
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (filteredCoins?.length > partialLoadingIncrement && partialLoadingEnabled) {
|
|
98
|
+
setLimitedCoinsNumber(partialLoadingIncrement);
|
|
99
|
+
updateDisplayedCoins();
|
|
100
|
+
} else {
|
|
101
|
+
setLimitedCoinsNumber(0);
|
|
102
|
+
setDisplayedCoins(filteredCoins);
|
|
103
|
+
setIsListFull(true);
|
|
104
|
+
}
|
|
105
|
+
setIsSearchResultEmpty(filteredCoins?.length === 0 && searchQuery !== "");
|
|
106
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
107
|
+
}, [filteredCoins]);
|
|
108
|
+
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
if (coinsBundle != null) handleSearchAsset(searchQuery);
|
|
111
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
112
|
+
}, [coinsList, searchQuery]);
|
|
113
|
+
|
|
114
|
+
return displayedCoins
|
|
115
|
+
.map(coin => coinsBundle.find(bundleItem => bundleItem.coin.ticker === coin.ticker).component)
|
|
116
|
+
.map(Item => <Item />);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
SearchableCoinsList.propTypes = {
|
|
120
|
+
coinsList: PropTypes.array.isRequired,
|
|
121
|
+
coinsBundle: PropTypes.array.isRequired,
|
|
122
|
+
searchQuery: PropTypes.string.isRequired,
|
|
123
|
+
partialLoadingEnabled: PropTypes.bool,
|
|
124
|
+
partialLoadingIncrement: PropTypes.number,
|
|
125
|
+
onListUpdated: PropTypes.func,
|
|
126
|
+
setIsListFull: PropTypes.func,
|
|
127
|
+
setIsSearchResultEmpty: PropTypes.func,
|
|
128
|
+
triggerLoadMoreCoins: PropTypes.number,
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
SearchableCoinsList.defaultProps = {
|
|
132
|
+
partialLoadingEnabled: true,
|
|
133
|
+
partialLoadingIncrement: 100,
|
|
134
|
+
onListUpdated: () => {},
|
|
135
|
+
setIsListFull: () => {},
|
|
136
|
+
setIsSearchResultEmpty: () => {},
|
|
137
|
+
};
|