@rainlanguage/ui-components 0.0.1-alpha.24 → 0.0.1-alpha.240
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/README.md +14 -6
- package/dist/__fixtures__/settings.yaml +123 -0
- package/dist/__mocks__/CodeMirrorRainlang.svelte +4 -0
- package/dist/__mocks__/CodeMirrorRainlang.svelte.d.ts +18 -0
- package/dist/__mocks__/MockCodeMirrorEditor.svelte +17 -0
- package/dist/__mocks__/MockCodeMirrorEditor.svelte.d.ts +21 -0
- package/dist/__mocks__/MockComponent.js +1 -1
- package/dist/__mocks__/MockComponent.svelte +10 -2
- package/dist/__mocks__/MockComponent.svelte.d.ts +4 -1
- package/dist/__mocks__/mockWeb3Config.d.ts +1 -1
- package/dist/__mocks__/mockWeb3Config.js +10 -7
- package/dist/__mocks__/queries.js +9 -9
- package/dist/__mocks__/stores.d.ts +55 -45
- package/dist/__mocks__/stores.js +85 -68
- package/dist/app.css +3 -3
- package/dist/components/ButtonDarkMode.svelte +7 -1
- package/dist/components/ButtonLoading.svelte +1 -1
- package/dist/components/ButtonScrub.svelte +22 -0
- package/dist/components/ButtonScrub.svelte.d.ts +25 -0
- package/dist/components/ButtonVaultLink.svelte +12 -11
- package/dist/components/ButtonVaultLink.svelte.d.ts +4 -3
- package/dist/components/CheckboxInactiveOrdersVault.svelte +20 -0
- package/dist/components/CheckboxInactiveOrdersVault.svelte.d.ts +19 -0
- package/dist/components/CheckboxZeroBalanceVault.svelte.d.ts +2 -2
- package/dist/components/CodeMirrorDotrain.svelte +4 -0
- package/dist/components/CodeMirrorDotrain.svelte.d.ts +1 -0
- package/dist/components/CodeMirrorRainlang.svelte +20 -12
- package/dist/components/CodeMirrorRainlang.svelte.d.ts +3 -2
- package/dist/components/EditableSpan.svelte +3 -14
- package/dist/components/EditableSpan.svelte.d.ts +0 -1
- package/dist/components/Hash.svelte +6 -5
- package/dist/components/License.svelte +5 -4
- package/dist/components/ListViewRaindexFilters.svelte +64 -0
- package/dist/components/ListViewRaindexFilters.svelte.d.ts +32 -0
- package/dist/components/LocalDbStatusBadge.svelte +27 -0
- package/dist/components/LocalDbStatusBadge.svelte.d.ts +19 -0
- package/dist/components/LocalDbStatusCard.svelte +43 -0
- package/dist/components/LocalDbStatusCard.svelte.d.ts +20 -0
- package/dist/components/LocalDbStatusModal.svelte +105 -0
- package/dist/components/LocalDbStatusModal.svelte.d.ts +21 -0
- package/dist/components/OrderOrVaultHash.svelte +12 -12
- package/dist/components/OrderOrVaultHash.svelte.d.ts +4 -4
- package/dist/components/PageHeader.svelte +1 -1
- package/dist/components/Sensitive.svelte +16 -0
- package/dist/components/Sensitive.svelte.d.ts +28 -0
- package/dist/components/TanstackAppTable.svelte +270 -60
- package/dist/components/TanstackAppTable.svelte.d.ts +15 -9
- package/dist/components/ToastDetail.svelte +42 -0
- package/dist/components/ToastDetail.svelte.d.ts +20 -0
- package/dist/components/Tooltip.svelte +8 -0
- package/dist/components/Tooltip.svelte.d.ts +21 -0
- package/dist/components/VaultBalanceChangeTypeFilter.svelte +23 -0
- package/dist/components/VaultBalanceChangeTypeFilter.svelte.d.ts +19 -0
- package/dist/components/VaultCard.svelte +18 -0
- package/dist/components/VaultCard.svelte.d.ts +19 -0
- package/dist/components/charts/LightweightChart.svelte +1 -1
- package/dist/components/charts/LightweightChart.svelte.d.ts +5 -5
- package/dist/components/charts/OrderTradesChart.svelte +319 -28
- package/dist/components/charts/OrderTradesChart.svelte.d.ts +4 -4
- package/dist/components/charts/TanstackLightweightChartLine.svelte +5 -9
- package/dist/components/charts/VaultBalanceChart.svelte +8 -26
- package/dist/components/charts/VaultBalanceChart.svelte.d.ts +1 -7
- package/dist/components/charts/transformAndSortData.d.ts +24 -0
- package/dist/components/charts/transformAndSortData.js +111 -0
- package/dist/components/checkbox/CheckboxActiveOrders.svelte +11 -0
- package/dist/components/checkbox/CheckboxActiveOrders.svelte.d.ts +19 -0
- package/dist/components/deployment/ButtonSelectOption.svelte +2 -0
- package/dist/components/deployment/ButtonSelectOption.svelte.d.ts +1 -0
- package/dist/components/deployment/ComposedRainlangModal.svelte +3 -2
- package/dist/components/deployment/ComposedRainlangModal.svelte.d.ts +1 -4
- package/dist/components/deployment/DeploymentSectionHeader.svelte +7 -4
- package/dist/components/deployment/DeploymentSteps.svelte +196 -221
- package/dist/components/deployment/DeploymentSteps.svelte.d.ts +6 -12
- package/dist/components/deployment/DeploymentTile.svelte +2 -2
- package/dist/components/deployment/DeploymentTile.svelte.d.ts +1 -1
- package/dist/components/deployment/DeploymentsSection.svelte +15 -22
- package/dist/components/deployment/DeploymentsSection.svelte.d.ts +3 -2
- package/dist/components/deployment/DepositInput.svelte +10 -11
- package/dist/components/deployment/DepositInput.svelte.d.ts +2 -3
- package/dist/components/deployment/DisclaimerModal.svelte +6 -7
- package/dist/components/deployment/FieldDefinitionInput.svelte +10 -14
- package/dist/components/deployment/FieldDefinitionInput.svelte.d.ts +2 -3
- package/dist/components/deployment/InvalidOrdersSection.svelte +17 -0
- package/dist/components/deployment/InvalidOrdersSection.svelte.d.ts +19 -0
- package/dist/components/deployment/{StrategyPage.svelte → OrderPage.svelte} +15 -24
- package/dist/components/deployment/OrderPage.svelte.d.ts +21 -0
- package/dist/components/deployment/SelectToken.svelte +127 -50
- package/dist/components/deployment/SelectToken.svelte.d.ts +5 -4
- package/dist/components/deployment/TokenBalance.svelte +19 -0
- package/dist/components/deployment/TokenBalance.svelte.d.ts +19 -0
- package/dist/components/deployment/TokenIOInput.svelte +27 -17
- package/dist/components/deployment/TokenIOInput.svelte.d.ts +3 -3
- package/dist/components/deployment/TokenSelectionModal.svelte +148 -0
- package/dist/components/deployment/TokenSelectionModal.svelte.d.ts +20 -0
- package/dist/components/deployment/{ValidStrategiesSection.svelte → ValidOrdersSection.svelte} +7 -7
- package/dist/components/deployment/ValidOrdersSection.svelte.d.ts +19 -0
- package/dist/components/deployment/VaultIdInformation.svelte +17 -0
- package/dist/components/deployment/VaultIdInformation.svelte.d.ts +21 -0
- package/dist/components/detail/OrderDetail.svelte +220 -82
- package/dist/components/detail/OrderDetail.svelte.d.ts +21 -15
- package/dist/components/detail/TanstackOrderQuote.svelte +114 -46
- package/dist/components/detail/TanstackOrderQuote.svelte.d.ts +14 -16
- package/dist/components/detail/VaultDetail.svelte +82 -79
- package/dist/components/detail/VaultDetail.svelte.d.ts +12 -18
- package/dist/components/dropdown/DropdownActiveNetworks.svelte +44 -0
- package/dist/components/dropdown/DropdownActiveNetworks.svelte.d.ts +19 -0
- package/dist/components/dropdown/DropdownCheckbox.svelte +4 -4
- package/dist/components/dropdown/DropdownRaindexesFilter.svelte +172 -0
- package/dist/components/dropdown/DropdownRaindexesFilter.svelte.d.ts +25 -0
- package/dist/components/dropdown/DropdownTokensFilter.svelte +152 -0
- package/dist/components/dropdown/DropdownTokensFilter.svelte.d.ts +28 -0
- package/dist/components/icon/Refresh.svelte +4 -2
- package/dist/components/icon/Refresh.svelte.d.ts +2 -0
- package/dist/components/input/InputOrderHash.svelte +1 -1
- package/dist/components/input/InputOrderHash.svelte.d.ts +3 -3
- package/dist/components/input/InputOwnerFilter.svelte +48 -0
- package/dist/components/input/InputOwnerFilter.svelte.d.ts +19 -0
- package/dist/components/input/InputRegistryUrl.svelte +36 -14
- package/dist/components/input/InputToken.svelte +2 -2
- package/dist/components/input/InputTokenAmount.svelte +30 -20
- package/dist/components/input/InputTokenAmount.svelte.d.ts +3 -3
- package/dist/components/tables/OrderAPY.svelte +6 -33
- package/dist/components/tables/OrderAPY.svelte.d.ts +1 -4
- package/dist/components/tables/OrderTradesListTable.svelte +132 -124
- package/dist/components/tables/OrderTradesListTable.svelte.d.ts +4 -4
- package/dist/components/tables/OrderVaultsVolTable.svelte +17 -22
- package/dist/components/tables/OrderVaultsVolTable.svelte.d.ts +2 -2
- package/dist/components/tables/OrdersListTable.svelte +206 -115
- package/dist/components/tables/OrdersListTable.svelte.d.ts +18 -23
- package/dist/components/tables/VaultBalanceChangesTable.svelte +83 -43
- package/dist/components/tables/VaultBalanceChangesTable.svelte.d.ts +13 -11
- package/dist/components/tables/VaultsListTable.svelte +275 -150
- package/dist/components/tables/VaultsListTable.svelte.d.ts +24 -33
- package/dist/components/transactions/FixedBottomTransaction.svelte +64 -0
- package/dist/components/transactions/FixedBottomTransaction.svelte.d.ts +16 -0
- package/dist/components/transactions/TransactionDetail.svelte +31 -0
- package/dist/components/transactions/TransactionDetail.svelte.d.ts +20 -0
- package/dist/components/transactions/TransactionList.svelte +17 -0
- package/dist/components/transactions/TransactionList.svelte.d.ts +16 -0
- package/dist/components/transactions/getStatusEmoji.d.ts +2 -0
- package/dist/components/transactions/getStatusEmoji.js +20 -0
- package/dist/components/wallet/WalletConnect.svelte +5 -4
- package/dist/components/wallet/WalletConnect.svelte.d.ts +0 -1
- package/dist/consts.d.ts +1 -0
- package/dist/consts.js +1 -0
- package/dist/errors/DeploymentStepsError.d.ts +11 -5
- package/dist/errors/DeploymentStepsError.js +13 -7
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/hooks/useLocalDb.d.ts +3 -0
- package/dist/hooks/useLocalDb.js +10 -0
- package/dist/hooks/useRaindexClient.d.ts +3 -0
- package/dist/hooks/useRaindexClient.js +11 -0
- package/dist/hooks/useRaindexOrderBuilder.d.ts +3 -0
- package/dist/hooks/useRaindexOrderBuilder.js +11 -0
- package/dist/index.d.ts +122 -91
- package/dist/index.js +118 -87
- package/dist/models/Transaction.d.ts +75 -0
- package/dist/models/Transaction.js +100 -0
- package/dist/providers/LocalDbProvider.svelte +8 -0
- package/dist/providers/LocalDbProvider.svelte.d.ts +21 -0
- package/dist/providers/RaindexClientProvider.svelte +8 -0
- package/dist/providers/RaindexClientProvider.svelte.d.ts +21 -0
- package/dist/providers/RaindexOrderBuilderProvider.svelte +8 -0
- package/dist/providers/RaindexOrderBuilderProvider.svelte.d.ts +21 -0
- package/dist/providers/dotrainRegistry/DotrainRegistryProvider.svelte +8 -0
- package/dist/providers/dotrainRegistry/DotrainRegistryProvider.svelte.d.ts +24 -0
- package/dist/providers/dotrainRegistry/context.d.ts +9 -0
- package/dist/providers/dotrainRegistry/context.js +43 -0
- package/dist/providers/dotrainRegistry/useDotrainRegistry.d.ts +5 -0
- package/dist/providers/dotrainRegistry/useDotrainRegistry.js +35 -0
- package/dist/providers/registry/RegistryManager.d.ts +65 -0
- package/dist/providers/registry/RegistryManager.js +134 -0
- package/dist/providers/registry/RegistryProvider.svelte +6 -0
- package/dist/providers/registry/RegistryProvider.svelte.d.ts +21 -0
- package/dist/providers/registry/context.d.ts +10 -0
- package/dist/providers/registry/context.js +46 -0
- package/dist/providers/registry/useRegistry.d.ts +7 -0
- package/dist/providers/registry/useRegistry.js +29 -0
- package/dist/providers/toasts/ToastProvider.svelte +17 -0
- package/dist/providers/toasts/ToastProvider.svelte.d.ts +18 -0
- package/dist/providers/toasts/context.d.ts +14 -0
- package/dist/providers/toasts/context.js +22 -0
- package/dist/providers/toasts/useToasts.d.ts +16 -0
- package/dist/providers/toasts/useToasts.js +63 -0
- package/dist/providers/transactions/TransactionManager.d.ts +234 -0
- package/dist/providers/transactions/TransactionManager.js +509 -0
- package/dist/providers/transactions/TransactionProvider.svelte +11 -0
- package/dist/providers/transactions/TransactionProvider.svelte.d.ts +24 -0
- package/dist/providers/transactions/context.d.ts +19 -0
- package/dist/providers/transactions/context.js +28 -0
- package/dist/providers/transactions/useTransactions.d.ts +13 -0
- package/dist/providers/transactions/useTransactions.js +18 -0
- package/dist/providers/wallet/WalletProvider.svelte +7 -0
- package/dist/providers/wallet/WalletProvider.svelte.d.ts +21 -0
- package/dist/providers/wallet/context.d.ts +10 -0
- package/dist/providers/wallet/context.js +47 -0
- package/dist/providers/wallet/useAccount.d.ts +8 -0
- package/dist/providers/wallet/useAccount.js +148 -0
- package/dist/queries/keys.d.ts +1 -0
- package/dist/queries/keys.js +10 -9
- package/dist/queries/queryClient.d.ts +2 -2
- package/dist/queries/queryClient.js +16 -11
- package/dist/services/awaitTransactionIndexing.d.ts +107 -0
- package/dist/services/awaitTransactionIndexing.js +60 -0
- package/dist/services/getExplorerLink.d.ts +1 -1
- package/dist/services/getExplorerLink.js +3 -5
- package/dist/services/handleShareChoices.d.ts +2 -2
- package/dist/services/handleShareChoices.js +6 -5
- package/dist/services/historicalOrderCharts.d.ts +3 -3
- package/dist/services/historicalOrderCharts.js +364 -371
- package/dist/services/index.d.ts +5 -2
- package/dist/services/index.js +3 -1
- package/dist/services/loadRegistryUrl.d.ts +2 -0
- package/dist/services/loadRegistryUrl.js +22 -0
- package/dist/services/pairTradesChartData.d.ts +47 -0
- package/dist/services/pairTradesChartData.js +194 -0
- package/dist/services/registry.d.ts +5 -5
- package/dist/services/registry.js +17 -217
- package/dist/services/time.d.ts +12 -0
- package/dist/services/time.js +88 -6
- package/dist/services/validateAmount.d.ts +30 -0
- package/dist/services/validateAmount.js +53 -0
- package/dist/storesGeneric/cachedWritableStore.d.ts +57 -0
- package/dist/storesGeneric/cachedWritableStore.js +93 -0
- package/dist/storesGeneric/scrub.d.ts +14 -0
- package/dist/storesGeneric/scrub.js +22 -0
- package/dist/test/matchers.d.ts +2 -2
- package/dist/test/matchers.js +2 -2
- package/dist/types/account.d.ts +3 -0
- package/dist/types/appStores.d.ts +9 -16
- package/dist/types/modal.d.ts +26 -14
- package/dist/types/order.d.ts +10 -0
- package/dist/types/order.js +1 -0
- package/dist/types/toast.d.ts +11 -0
- package/dist/types/toast.js +1 -0
- package/dist/types/tokenBalance.d.ts +6 -0
- package/dist/types/tokenBalance.js +1 -0
- package/dist/types/transaction.d.ts +67 -22
- package/dist/types/transaction.js +31 -1
- package/dist/utils/breadcrumbs.js +2 -2
- package/dist/utils/codeMirrorThemes.js +80 -74
- package/dist/utils/configHelpers.d.ts +4 -0
- package/dist/utils/configHelpers.js +21 -0
- package/dist/utils/constructHashLink.d.ts +24 -0
- package/dist/utils/constructHashLink.js +117 -0
- package/dist/utils/getNetworkName.d.ts +1 -0
- package/dist/utils/getNetworkName.js +13 -0
- package/dist/utils/hex.js +1 -1
- package/dist/utils/lightweightChartsThemes.d.ts +1 -1
- package/dist/utils/lightweightChartsThemes.js +11 -11
- package/dist/utils/localDbStatus.d.ts +26 -0
- package/dist/utils/localDbStatus.js +22 -0
- package/dist/utils/number.d.ts +0 -7
- package/dist/utils/number.js +5 -30
- package/dist/utils/stripTrailingWhitespace.d.ts +16 -0
- package/dist/utils/stripTrailingWhitespace.js +22 -0
- package/dist/utils/tokens.d.ts +2 -0
- package/dist/utils/tokens.js +3 -0
- package/dist/utils/vaultBalanceChangeLabels.d.ts +4 -0
- package/dist/utils/vaultBalanceChangeLabels.js +18 -0
- package/package.json +89 -84
- package/dist/__fixtures__/orderDetail.d.ts +0 -99
- package/dist/__fixtures__/orderDetail.js +0 -204
- package/dist/__fixtures__/settings-12-11-24.json +0 -160
- package/dist/__mocks__/mockTransactionStore.d.ts +0 -22
- package/dist/__mocks__/mockTransactionStore.js +0 -56
- package/dist/__mocks__/settings.d.ts +0 -3
- package/dist/__mocks__/settings.js +0 -37
- package/dist/components/CheckboxMyItemsOnly.svelte +0 -23
- package/dist/components/CheckboxMyItemsOnly.svelte.d.ts +0 -21
- package/dist/components/ListViewOrderbookFilters.svelte +0 -58
- package/dist/components/ListViewOrderbookFilters.svelte.d.ts +0 -28
- package/dist/components/deployment/InvalidStrategiesSection.svelte +0 -19
- package/dist/components/deployment/InvalidStrategiesSection.svelte.d.ts +0 -19
- package/dist/components/deployment/StrategyPage.svelte.d.ts +0 -19
- package/dist/components/deployment/ValidStrategiesSection.svelte.d.ts +0 -19
- package/dist/components/deployment/getDeploymentTransactionArgs.d.ts +0 -17
- package/dist/components/deployment/getDeploymentTransactionArgs.js +0 -28
- package/dist/components/detail/DepositOrWithdrawButtons.svelte +0 -44
- package/dist/components/detail/DepositOrWithdrawButtons.svelte.d.ts +0 -26
- package/dist/components/dropdown/DropdownActiveSubgraphs.svelte +0 -38
- package/dist/components/dropdown/DropdownActiveSubgraphs.svelte.d.ts +0 -21
- package/dist/components/dropdown/DropdownOrderListAccounts.svelte +0 -15
- package/dist/components/dropdown/DropdownOrderListAccounts.svelte.d.ts +0 -20
- package/dist/components/dropdown/DropdownOrderStatus.svelte +0 -31
- package/dist/components/dropdown/DropdownOrderStatus.svelte.d.ts +0 -19
- package/dist/hooks/useGui.d.ts +0 -3
- package/dist/hooks/useGui.js +0 -11
- package/dist/providers/GuiProvider.svelte +0 -8
- package/dist/providers/GuiProvider.svelte.d.ts +0 -21
- package/dist/stores/transactionStore.d.ts +0 -98
- package/dist/stores/transactionStore.js +0 -303
- package/dist/types/strategy.d.ts +0 -10
- package/dist/utils/time.d.ts +0 -12
- package/dist/utils/time.js +0 -27
- package/dist/utils/vault.d.ts +0 -2
- package/dist/utils/vault.js +0 -29
- /package/dist/types/{strategy.js → account.js} +0 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
<script>import { Button, Dropdown, Label, Checkbox, Input } from "flowbite-svelte";
|
|
2
|
+
import { ChevronDownSolid, SearchSolid } from "flowbite-svelte-icons";
|
|
3
|
+
import { isEmpty } from "lodash";
|
|
4
|
+
import { getNetworkName } from "../../utils/getNetworkName";
|
|
5
|
+
import { useRaindexClient } from "../../hooks/useRaindexClient";
|
|
6
|
+
export let activeRaindexAddresses;
|
|
7
|
+
export let selectedRaindexAddresses;
|
|
8
|
+
export let selectedChainIds;
|
|
9
|
+
export let label = "Filter by raindex";
|
|
10
|
+
export let allLabel = "All raindexes";
|
|
11
|
+
export let emptyMessage = "No raindexes available";
|
|
12
|
+
const raindexClient = useRaindexClient();
|
|
13
|
+
let filteredRaindexes = [];
|
|
14
|
+
let searchTerm = "";
|
|
15
|
+
let selectedIndex = 0;
|
|
16
|
+
$: raindexesResult = raindexClient.getAllRaindexes();
|
|
17
|
+
$: raindexesMap = raindexesResult?.value ?? /* @__PURE__ */ new Map();
|
|
18
|
+
$: raindexesError = raindexesResult?.error;
|
|
19
|
+
$: availableRaindexes = (() => {
|
|
20
|
+
const items = [];
|
|
21
|
+
raindexesMap.forEach((cfg, key) => {
|
|
22
|
+
if (selectedChainIds.length === 0 || selectedChainIds.includes(cfg.network.chainId)) {
|
|
23
|
+
items.push({
|
|
24
|
+
key,
|
|
25
|
+
address: cfg.address,
|
|
26
|
+
label: cfg.label,
|
|
27
|
+
chainId: cfg.network.chainId
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return items;
|
|
32
|
+
})();
|
|
33
|
+
$: selectedCount = selectedRaindexAddresses.length;
|
|
34
|
+
$: allSelected = selectedCount === availableRaindexes.length && availableRaindexes.length > 0;
|
|
35
|
+
$: buttonText = selectedCount === 0 ? "Select raindexes" : allSelected ? allLabel : `${selectedCount} raindex${selectedCount > 1 ? "es" : ""}`;
|
|
36
|
+
$: {
|
|
37
|
+
if (searchTerm.trim() === "") {
|
|
38
|
+
filteredRaindexes = availableRaindexes;
|
|
39
|
+
selectedIndex = 0;
|
|
40
|
+
} else {
|
|
41
|
+
const term = searchTerm.toLowerCase();
|
|
42
|
+
filteredRaindexes = availableRaindexes.filter(
|
|
43
|
+
(raindex) => raindex.label?.toLowerCase().includes(term) || raindex.address?.toLowerCase().includes(term) || raindex.key?.toLowerCase().includes(term)
|
|
44
|
+
);
|
|
45
|
+
selectedIndex = filteredRaindexes.length > 0 ? 0 : -1;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
$: sortedFilteredRaindexes = [...filteredRaindexes].sort((a, b) => {
|
|
49
|
+
const aSelected = selectedRaindexAddresses.some(
|
|
50
|
+
(addr) => addr.toLowerCase() === a.address.toLowerCase()
|
|
51
|
+
);
|
|
52
|
+
const bSelected = selectedRaindexAddresses.some(
|
|
53
|
+
(addr) => addr.toLowerCase() === b.address.toLowerCase()
|
|
54
|
+
);
|
|
55
|
+
if (aSelected === bSelected) return 0;
|
|
56
|
+
return aSelected ? -1 : 1;
|
|
57
|
+
});
|
|
58
|
+
function getDisplayName(raindex) {
|
|
59
|
+
const truncatedAddr = `${raindex.address.slice(0, 6)}...${raindex.address.slice(-4)}`;
|
|
60
|
+
return raindex.label ? `${raindex.label} (${truncatedAddr})` : truncatedAddr;
|
|
61
|
+
}
|
|
62
|
+
function updateSelectedRaindexes(newSelection) {
|
|
63
|
+
activeRaindexAddresses.set(newSelection);
|
|
64
|
+
}
|
|
65
|
+
function toggleRaindex({ address }) {
|
|
66
|
+
if (!address) return;
|
|
67
|
+
const normalizedAddress = address.toLowerCase();
|
|
68
|
+
const isSelected = selectedRaindexAddresses.some(
|
|
69
|
+
(addr) => addr.toLowerCase() === normalizedAddress
|
|
70
|
+
);
|
|
71
|
+
const newSelection = isSelected ? $activeRaindexAddresses.filter((addr) => addr.toLowerCase() !== normalizedAddress) : [...$activeRaindexAddresses, normalizedAddress];
|
|
72
|
+
updateSelectedRaindexes(newSelection);
|
|
73
|
+
}
|
|
74
|
+
function handleKeyDown(event) {
|
|
75
|
+
if (!sortedFilteredRaindexes.length) return;
|
|
76
|
+
switch (event.key) {
|
|
77
|
+
case "Enter":
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
if (sortedFilteredRaindexes.length > 0) {
|
|
80
|
+
const raindexToToggle = sortedFilteredRaindexes[selectedIndex];
|
|
81
|
+
if (raindexToToggle) {
|
|
82
|
+
toggleRaindex(raindexToToggle);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
case "ArrowDown":
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
selectedIndex = Math.min(selectedIndex + 1, sortedFilteredRaindexes.length - 1);
|
|
89
|
+
break;
|
|
90
|
+
case "ArrowUp":
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
selectedIndex = Math.max(selectedIndex - 1, 0);
|
|
93
|
+
break;
|
|
94
|
+
case "Escape":
|
|
95
|
+
searchTerm = "";
|
|
96
|
+
selectedIndex = -1;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
</script>
|
|
101
|
+
|
|
102
|
+
<div class="flex flex-col gap-x-2">
|
|
103
|
+
<Label>{label}</Label>
|
|
104
|
+
<div>
|
|
105
|
+
<Button
|
|
106
|
+
color="alternative"
|
|
107
|
+
class="flex w-full justify-between overflow-hidden pl-2 pr-0 text-left"
|
|
108
|
+
data-testid="dropdown-raindexes-filter-button"
|
|
109
|
+
aria-label="Select raindexes to filter"
|
|
110
|
+
aria-expanded="false"
|
|
111
|
+
aria-haspopup="listbox"
|
|
112
|
+
>
|
|
113
|
+
<div class="w-[110px] overflow-hidden text-ellipsis whitespace-nowrap">
|
|
114
|
+
{buttonText}
|
|
115
|
+
</div>
|
|
116
|
+
<ChevronDownSolid class="mx-2 h-3 w-3 text-black dark:text-white" />
|
|
117
|
+
</Button>
|
|
118
|
+
|
|
119
|
+
<Dropdown
|
|
120
|
+
class="max-h-[75vh] w-full min-w-60 overflow-y-auto py-0"
|
|
121
|
+
data-testid="dropdown-raindexes-filter"
|
|
122
|
+
>
|
|
123
|
+
{#if raindexesError}
|
|
124
|
+
<div class="ml-2 w-full rounded-lg p-3 text-red-500">
|
|
125
|
+
Cannot load raindexes list: {raindexesError.readableMsg || 'Unknown error'}
|
|
126
|
+
</div>
|
|
127
|
+
{:else if isEmpty(availableRaindexes)}
|
|
128
|
+
<div class="ml-2 w-full rounded-lg p-3">{emptyMessage}</div>
|
|
129
|
+
{:else}
|
|
130
|
+
<div class="sticky top-0 bg-white p-3 dark:bg-gray-800">
|
|
131
|
+
<Input
|
|
132
|
+
placeholder="Search raindexes..."
|
|
133
|
+
bind:value={searchTerm}
|
|
134
|
+
autofocus
|
|
135
|
+
on:keydown={handleKeyDown}
|
|
136
|
+
data-testid="raindexes-filter-search"
|
|
137
|
+
>
|
|
138
|
+
<SearchSolid slot="left" class="h-4 w-4 text-gray-500" />
|
|
139
|
+
</Input>
|
|
140
|
+
</div>
|
|
141
|
+
|
|
142
|
+
{#if isEmpty(filteredRaindexes)}
|
|
143
|
+
<div class="ml-2 w-full rounded-lg p-3">No raindexes match your search</div>
|
|
144
|
+
{:else}
|
|
145
|
+
{#each sortedFilteredRaindexes as raindex, index (`${raindex.address}-${raindex.chainId}`)}
|
|
146
|
+
<Checkbox
|
|
147
|
+
data-testid="dropdown-raindexes-filter-option"
|
|
148
|
+
class="w-full rounded-lg p-3 hover:bg-gray-100 dark:hover:bg-gray-600 {selectedIndex ===
|
|
149
|
+
index
|
|
150
|
+
? 'bg-blue-100 dark:bg-blue-900'
|
|
151
|
+
: ''}"
|
|
152
|
+
on:click={() => toggleRaindex(raindex)}
|
|
153
|
+
checked={!!(
|
|
154
|
+
raindex.address &&
|
|
155
|
+
selectedRaindexAddresses.some(
|
|
156
|
+
(addr) => addr.toLowerCase() === raindex.address.toLowerCase()
|
|
157
|
+
)
|
|
158
|
+
)}
|
|
159
|
+
>
|
|
160
|
+
<div class="ml-2 flex w-full">
|
|
161
|
+
<div class="flex-1 text-sm font-medium">{getDisplayName(raindex)}</div>
|
|
162
|
+
<div class="text-xs text-gray-500">
|
|
163
|
+
{getNetworkName(raindex.chainId)}
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
</Checkbox>
|
|
167
|
+
{/each}
|
|
168
|
+
{/if}
|
|
169
|
+
{/if}
|
|
170
|
+
</Dropdown>
|
|
171
|
+
</div>
|
|
172
|
+
</div>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { Address } from '@rainlanguage/raindex';
|
|
3
|
+
import type { AppStoresInterface } from '../../types/appStores';
|
|
4
|
+
declare const __propDef: {
|
|
5
|
+
props: {
|
|
6
|
+
activeRaindexAddresses: AppStoresInterface["activeRaindexAddresses"];
|
|
7
|
+
selectedRaindexAddresses: Address[];
|
|
8
|
+
selectedChainIds: number[];
|
|
9
|
+
label?: string;
|
|
10
|
+
allLabel?: string;
|
|
11
|
+
emptyMessage?: string;
|
|
12
|
+
};
|
|
13
|
+
events: {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
};
|
|
16
|
+
slots: {};
|
|
17
|
+
exports?: {} | undefined;
|
|
18
|
+
bindings?: string | undefined;
|
|
19
|
+
};
|
|
20
|
+
export type DropdownRaindexesFilterProps = typeof __propDef.props;
|
|
21
|
+
export type DropdownRaindexesFilterEvents = typeof __propDef.events;
|
|
22
|
+
export type DropdownRaindexesFilterSlots = typeof __propDef.slots;
|
|
23
|
+
export default class DropdownRaindexesFilter extends SvelteComponent<DropdownRaindexesFilterProps, DropdownRaindexesFilterEvents, DropdownRaindexesFilterSlots> {
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
<script>import { Button, Dropdown, Label, Checkbox, Input } from "flowbite-svelte";
|
|
2
|
+
import { ChevronDownSolid, SearchSolid } from "flowbite-svelte-icons";
|
|
3
|
+
import { isEmpty } from "lodash";
|
|
4
|
+
import { getTokenDisplayName } from "../../utils/tokens";
|
|
5
|
+
import { getNetworkName } from "../../utils/getNetworkName";
|
|
6
|
+
export let tokensQuery;
|
|
7
|
+
export let activeTokens;
|
|
8
|
+
export let selectedTokens;
|
|
9
|
+
export let label = "Filter by tokens";
|
|
10
|
+
export let allLabel = "All tokens";
|
|
11
|
+
export let emptyMessage = "No tokens available";
|
|
12
|
+
export let loadingMessage = "Loading tokens...";
|
|
13
|
+
let filteredTokens = [];
|
|
14
|
+
let searchTerm = "";
|
|
15
|
+
let selectedIndex = 0;
|
|
16
|
+
$: availableTokens = $tokensQuery?.data || [];
|
|
17
|
+
$: selectedCount = selectedTokens.length;
|
|
18
|
+
$: allSelected = selectedCount === availableTokens.length && availableTokens.length > 0;
|
|
19
|
+
$: buttonText = selectedCount === 0 ? "Select tokens" : allSelected ? allLabel : `${selectedCount} token${selectedCount > 1 ? "s" : ""}`;
|
|
20
|
+
$: {
|
|
21
|
+
let tokensToFilter = availableTokens;
|
|
22
|
+
const getKey = (token) => `${token.address}-${token.chainId}`;
|
|
23
|
+
const uniqueTokensMap = /* @__PURE__ */ new Map();
|
|
24
|
+
tokensToFilter.forEach((token) => {
|
|
25
|
+
const key = getKey(token);
|
|
26
|
+
if (token.address && !uniqueTokensMap.has(key)) {
|
|
27
|
+
uniqueTokensMap.set(key, token);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const uniqueTokens = Array.from(uniqueTokensMap.values());
|
|
31
|
+
if (searchTerm.trim() === "") {
|
|
32
|
+
filteredTokens = uniqueTokens;
|
|
33
|
+
} else {
|
|
34
|
+
const term = searchTerm.toLowerCase();
|
|
35
|
+
filteredTokens = uniqueTokens.filter(
|
|
36
|
+
(token) => token.symbol?.toLowerCase().includes(term) || token.name?.toLowerCase().includes(term) || token.address?.toLowerCase().includes(term)
|
|
37
|
+
);
|
|
38
|
+
selectedIndex = filteredTokens.length > 0 ? 0 : -1;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
$: sortedFilteredTokens = [...filteredTokens].sort((a, b) => {
|
|
42
|
+
const aSelected = selectedTokens.includes(a.address);
|
|
43
|
+
const bSelected = selectedTokens.includes(b.address);
|
|
44
|
+
if (aSelected === bSelected) return 0;
|
|
45
|
+
return aSelected ? -1 : 1;
|
|
46
|
+
});
|
|
47
|
+
function updateSelectedTokens(newSelection) {
|
|
48
|
+
activeTokens.set(newSelection);
|
|
49
|
+
}
|
|
50
|
+
function toggleToken({ address }) {
|
|
51
|
+
if (!address) return;
|
|
52
|
+
const isSelected = selectedTokens.includes(address);
|
|
53
|
+
const newSelection = isSelected ? $activeTokens.filter((addr) => addr !== address) : [...$activeTokens, address];
|
|
54
|
+
updateSelectedTokens(newSelection);
|
|
55
|
+
}
|
|
56
|
+
function handleKeyDown(event) {
|
|
57
|
+
if (!sortedFilteredTokens.length) return;
|
|
58
|
+
switch (event.key) {
|
|
59
|
+
case "Enter":
|
|
60
|
+
event.preventDefault();
|
|
61
|
+
if (sortedFilteredTokens.length > 0) {
|
|
62
|
+
const tokenToToggle = sortedFilteredTokens[selectedIndex];
|
|
63
|
+
if (tokenToToggle) {
|
|
64
|
+
toggleToken(tokenToToggle);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
case "ArrowDown":
|
|
69
|
+
event.preventDefault();
|
|
70
|
+
selectedIndex = Math.min(selectedIndex + 1, sortedFilteredTokens.length - 1);
|
|
71
|
+
break;
|
|
72
|
+
case "ArrowUp":
|
|
73
|
+
event.preventDefault();
|
|
74
|
+
selectedIndex = Math.max(selectedIndex - 1, 0);
|
|
75
|
+
break;
|
|
76
|
+
case "Escape":
|
|
77
|
+
searchTerm = "";
|
|
78
|
+
selectedIndex = -1;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
</script>
|
|
83
|
+
|
|
84
|
+
<div class="flex flex-col gap-x-2">
|
|
85
|
+
<Label>{label}</Label>
|
|
86
|
+
<div>
|
|
87
|
+
<Button
|
|
88
|
+
color="alternative"
|
|
89
|
+
class="flex w-full justify-between overflow-hidden pl-2 pr-0 text-left"
|
|
90
|
+
data-testid="dropdown-tokens-filter-button"
|
|
91
|
+
aria-label="Select tokens to filter"
|
|
92
|
+
aria-expanded="false"
|
|
93
|
+
aria-haspopup="listbox"
|
|
94
|
+
>
|
|
95
|
+
<div class="w-[90px] overflow-hidden text-ellipsis whitespace-nowrap">
|
|
96
|
+
{buttonText}
|
|
97
|
+
</div>
|
|
98
|
+
<ChevronDownSolid class="mx-2 h-3 w-3 text-black dark:text-white" />
|
|
99
|
+
</Button>
|
|
100
|
+
|
|
101
|
+
<Dropdown
|
|
102
|
+
class="max-h-[75vh] w-full min-w-60 overflow-y-auto py-0"
|
|
103
|
+
data-testid="dropdown-tokens-filter"
|
|
104
|
+
>
|
|
105
|
+
{#if $tokensQuery.isLoading}
|
|
106
|
+
<div class="ml-2 w-full rounded-lg p-3">{loadingMessage}</div>
|
|
107
|
+
{:else if $tokensQuery.isError}
|
|
108
|
+
<div class="ml-2 w-full rounded-lg p-3 text-red-500">
|
|
109
|
+
Cannot load tokens list: {$tokensQuery.error?.message || 'Unknown error'}
|
|
110
|
+
</div>
|
|
111
|
+
{:else if isEmpty(availableTokens)}
|
|
112
|
+
<div class="ml-2 w-full rounded-lg p-3">{emptyMessage}</div>
|
|
113
|
+
{:else}
|
|
114
|
+
<!-- Search input -->
|
|
115
|
+
<div class="sticky top-0 bg-white p-3 dark:bg-gray-800">
|
|
116
|
+
<Input
|
|
117
|
+
placeholder="Search tokens..."
|
|
118
|
+
bind:value={searchTerm}
|
|
119
|
+
autofocus
|
|
120
|
+
on:keydown={handleKeyDown}
|
|
121
|
+
data-testid="tokens-filter-search"
|
|
122
|
+
>
|
|
123
|
+
<SearchSolid slot="left" class="h-4 w-4 text-gray-500" />
|
|
124
|
+
</Input>
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
{#if isEmpty(filteredTokens)}
|
|
128
|
+
<div class="ml-2 w-full rounded-lg p-3">No tokens match your search</div>
|
|
129
|
+
{:else}
|
|
130
|
+
{#each sortedFilteredTokens as token, index (`${token.address}-${token.chainId}`)}
|
|
131
|
+
<Checkbox
|
|
132
|
+
data-testid="dropdown-tokens-filter-option"
|
|
133
|
+
class="w-full rounded-lg p-3 hover:bg-gray-100 dark:hover:bg-gray-600 {selectedIndex ===
|
|
134
|
+
index
|
|
135
|
+
? 'bg-blue-100 dark:bg-blue-900'
|
|
136
|
+
: ''}"
|
|
137
|
+
on:click={() => toggleToken(token)}
|
|
138
|
+
checked={!!(token.address && selectedTokens.includes(token.address))}
|
|
139
|
+
>
|
|
140
|
+
<div class="ml-2 flex w-full">
|
|
141
|
+
<div class="flex-1 text-sm font-medium">{getTokenDisplayName(token)}</div>
|
|
142
|
+
<div class="text-xs text-gray-500">
|
|
143
|
+
{getNetworkName(token.chainId)}
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
</Checkbox>
|
|
147
|
+
{/each}
|
|
148
|
+
{/if}
|
|
149
|
+
{/if}
|
|
150
|
+
</Dropdown>
|
|
151
|
+
</div>
|
|
152
|
+
</div>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { Address, RaindexVaultToken } from '@rainlanguage/raindex';
|
|
3
|
+
import type { AppStoresInterface } from '../../types/appStores';
|
|
4
|
+
import type { Readable } from 'svelte/store';
|
|
5
|
+
import type { QueryObserverResult } from '@tanstack/svelte-query';
|
|
6
|
+
declare const __propDef: {
|
|
7
|
+
props: {
|
|
8
|
+
tokensQuery: Readable<QueryObserverResult<RaindexVaultToken[], Error>>;
|
|
9
|
+
activeTokens: AppStoresInterface["activeTokens"];
|
|
10
|
+
selectedTokens: Address[];
|
|
11
|
+
label?: string;
|
|
12
|
+
allLabel?: string;
|
|
13
|
+
emptyMessage?: string;
|
|
14
|
+
loadingMessage?: string;
|
|
15
|
+
};
|
|
16
|
+
events: {
|
|
17
|
+
[evt: string]: CustomEvent<any>;
|
|
18
|
+
};
|
|
19
|
+
slots: {};
|
|
20
|
+
exports?: {} | undefined;
|
|
21
|
+
bindings?: string | undefined;
|
|
22
|
+
};
|
|
23
|
+
export type DropdownTokensFilterProps = typeof __propDef.props;
|
|
24
|
+
export type DropdownTokensFilterEvents = typeof __propDef.events;
|
|
25
|
+
export type DropdownTokensFilterSlots = typeof __propDef.slots;
|
|
26
|
+
export default class DropdownTokensFilter extends SvelteComponent<DropdownTokensFilterProps, DropdownTokensFilterEvents, DropdownTokensFilterSlots> {
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -11,14 +11,16 @@ const sizes = {
|
|
|
11
11
|
export let size = ctx.size || "md";
|
|
12
12
|
export let role = ctx.role || "img";
|
|
13
13
|
export let ariaLabel = "refresh";
|
|
14
|
+
export let title = "Refresh";
|
|
14
15
|
export let spin = false;
|
|
16
|
+
export let testId = "refresh-button";
|
|
15
17
|
</script>
|
|
16
18
|
|
|
17
19
|
<svg
|
|
18
|
-
data-testid=
|
|
20
|
+
data-testid={testId}
|
|
19
21
|
xmlns="http://www.w3.org/2000/svg"
|
|
20
22
|
fill="none"
|
|
21
|
-
{...$$restProps}
|
|
23
|
+
{...{ title, ...$$restProps }}
|
|
22
24
|
class={twMerge(
|
|
23
25
|
'shrink-0 cursor-pointer outline-none',
|
|
24
26
|
sizes[size],
|
|
@@ -6,7 +6,9 @@ declare const __propDef: {
|
|
|
6
6
|
size?: ("xs" | "sm" | "md" | "lg" | "xl") | undefined;
|
|
7
7
|
role?: AriaRole | undefined;
|
|
8
8
|
ariaLabel?: string | undefined;
|
|
9
|
+
title?: string | undefined;
|
|
9
10
|
spin?: boolean | undefined;
|
|
11
|
+
testId?: string | undefined;
|
|
10
12
|
};
|
|
11
13
|
events: {
|
|
12
14
|
click: MouseEvent;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type {
|
|
2
|
+
import type { AppStoresInterface } from '../../types/appStores';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
|
-
orderHash:
|
|
6
|
-
value?: string
|
|
5
|
+
orderHash: AppStoresInterface["orderHash"];
|
|
6
|
+
value?: `0x${string}`;
|
|
7
7
|
};
|
|
8
8
|
events: {
|
|
9
9
|
[evt: string]: CustomEvent<any>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<script>import { Button, Label } from "flowbite-svelte";
|
|
2
|
+
import { useAccount } from "../../providers/wallet/useAccount";
|
|
3
|
+
export let ownerFilter;
|
|
4
|
+
const { account } = useAccount();
|
|
5
|
+
let value = "";
|
|
6
|
+
$: value = $ownerFilter;
|
|
7
|
+
function handleChange(event) {
|
|
8
|
+
const input = event.target;
|
|
9
|
+
value = input.value;
|
|
10
|
+
ownerFilter.set(value);
|
|
11
|
+
}
|
|
12
|
+
function handleMyItems() {
|
|
13
|
+
if (!$account) return;
|
|
14
|
+
if ($ownerFilter.toLowerCase() === $account.toLowerCase()) {
|
|
15
|
+
ownerFilter.set("");
|
|
16
|
+
value = "";
|
|
17
|
+
} else {
|
|
18
|
+
ownerFilter.set($account);
|
|
19
|
+
value = $account;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<div data-testid="owner-filter-input" class="flex flex-col gap-x-2">
|
|
25
|
+
<Label>Owner</Label>
|
|
26
|
+
<div class="flex items-center gap-2">
|
|
27
|
+
<div class="w-full lg:w-32">
|
|
28
|
+
<input
|
|
29
|
+
type="text"
|
|
30
|
+
bind:value
|
|
31
|
+
on:input={handleChange}
|
|
32
|
+
placeholder="0x..."
|
|
33
|
+
class="focus:border-primary-500 focus:ring-primary-500 dark:focus:border-primary-500 dark:focus:ring-primary-500 block w-full rounded-lg border-gray-300 bg-gray-50 p-2.5 text-sm text-gray-900 disabled:cursor-not-allowed disabled:opacity-50 rtl:text-right dark:border-gray-500 dark:bg-gray-600 dark:text-white dark:placeholder-gray-400"
|
|
34
|
+
/>
|
|
35
|
+
</div>
|
|
36
|
+
<Button
|
|
37
|
+
size="xs"
|
|
38
|
+
color={$account && $ownerFilter.toLowerCase() === $account.toLowerCase()
|
|
39
|
+
? 'primary'
|
|
40
|
+
: 'alternative'}
|
|
41
|
+
disabled={!$account}
|
|
42
|
+
on:click={handleMyItems}
|
|
43
|
+
data-testid="my-items-button"
|
|
44
|
+
>
|
|
45
|
+
My Items
|
|
46
|
+
</Button>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { AppStoresInterface } from '../../types/appStores';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
ownerFilter: AppStoresInterface["ownerFilter"];
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {};
|
|
11
|
+
exports?: {} | undefined;
|
|
12
|
+
bindings?: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
export type InputOwnerFilterProps = typeof __propDef.props;
|
|
15
|
+
export type InputOwnerFilterEvents = typeof __propDef.events;
|
|
16
|
+
export type InputOwnerFilterSlots = typeof __propDef.slots;
|
|
17
|
+
export default class InputOwnerFilter extends SvelteComponent<InputOwnerFilterProps, InputOwnerFilterEvents, InputOwnerFilterSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -1,18 +1,40 @@
|
|
|
1
1
|
<script>import { Button, Input } from "flowbite-svelte";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { useRegistry } from "../../providers/registry/useRegistry";
|
|
3
|
+
import { loadRegistryUrl } from "../../services/loadRegistryUrl";
|
|
4
|
+
const registry = useRegistry();
|
|
5
|
+
let newRegistryUrl = registry.getCurrentRegistry();
|
|
6
|
+
let error = null;
|
|
7
|
+
let loading = false;
|
|
8
|
+
async function handleClick() {
|
|
9
|
+
loading = true;
|
|
10
|
+
error = null;
|
|
11
|
+
try {
|
|
12
|
+
if (!registry) {
|
|
13
|
+
throw new Error("Registry manager not yet available.");
|
|
14
|
+
}
|
|
15
|
+
await loadRegistryUrl(newRegistryUrl, registry);
|
|
16
|
+
} catch (err) {
|
|
17
|
+
error = err instanceof Error ? err.message : "Unknown error";
|
|
18
|
+
}
|
|
19
|
+
loading = false;
|
|
20
|
+
}
|
|
8
21
|
</script>
|
|
9
22
|
|
|
10
|
-
<div class="
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
<div class="flex w-full flex-col items-end gap-2">
|
|
24
|
+
<div class="flex w-full items-start gap-4" data-testid="registry-input">
|
|
25
|
+
<Input
|
|
26
|
+
id="order-url"
|
|
27
|
+
type="url"
|
|
28
|
+
placeholder="Enter URL to raw order registry file"
|
|
29
|
+
bind:value={newRegistryUrl}
|
|
30
|
+
/>
|
|
31
|
+
<Button class="w-36 text-nowrap" on:click={handleClick} disabled={loading}>
|
|
32
|
+
{loading ? 'Loading registry...' : 'Load registry URL'}
|
|
33
|
+
</Button>
|
|
34
|
+
</div>
|
|
35
|
+
<div class="h-4">
|
|
36
|
+
{#if error}
|
|
37
|
+
<p data-testid="registry-error" class="text-red-500">{error}</p>
|
|
38
|
+
{/if}
|
|
39
|
+
</div>
|
|
18
40
|
</div>
|
|
@@ -35,10 +35,10 @@ function decimalsComplete({ detail }) {
|
|
|
35
35
|
</div>
|
|
36
36
|
|
|
37
37
|
{#if !isAddressValid && address.length > 0}
|
|
38
|
-
<Helper class="mt-2 text-sm" color="red">Invalid
|
|
38
|
+
<Helper class="mt-2 text-sm" color="red">Invalid address</Helper>
|
|
39
39
|
{/if}
|
|
40
40
|
|
|
41
|
-
<Helper class="mt-2 text-sm">Token
|
|
41
|
+
<Helper class="mt-2 text-sm">Token address</Helper>
|
|
42
42
|
</div>
|
|
43
43
|
<div class="w-32 grow-0 break-all" data-testid="token-decimals-input">
|
|
44
44
|
<input
|
|
@@ -1,30 +1,41 @@
|
|
|
1
|
-
<script>import { InputAddon, Button
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
<script>import { InputAddon, Button } from "flowbite-svelte";
|
|
2
|
+
import { Float } from "@rainlanguage/raindex";
|
|
3
|
+
import { validateAmount } from "../../services/validateAmount";
|
|
4
4
|
export let symbol = void 0;
|
|
5
|
-
export let decimals = 0;
|
|
6
5
|
export let maxValue = void 0;
|
|
6
|
+
export let value = Float.parse("0").value;
|
|
7
7
|
let inputValue = "";
|
|
8
|
-
|
|
8
|
+
let decimalsError = null;
|
|
9
9
|
function handleInput(event) {
|
|
10
10
|
const input = event.target;
|
|
11
11
|
inputValue = input.value;
|
|
12
|
+
const decimalsValidation = validateAmount(inputValue);
|
|
13
|
+
decimalsError = decimalsValidation.errorMessage;
|
|
14
|
+
if (!decimalsValidation.isValid) {
|
|
15
|
+
value = Float.parse("0").value;
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
12
18
|
if (inputValue === "") {
|
|
13
|
-
value =
|
|
19
|
+
value = Float.parse("0").value;
|
|
14
20
|
} else {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
let parsedValue = Float.parse(inputValue);
|
|
22
|
+
if (parsedValue.error) {
|
|
23
|
+
value = Float.parse("0").value;
|
|
24
|
+
return;
|
|
19
25
|
}
|
|
26
|
+
value = parsedValue.value;
|
|
20
27
|
}
|
|
21
28
|
}
|
|
22
29
|
function fillMaxValue() {
|
|
23
30
|
if (!maxValue) return;
|
|
24
31
|
value = maxValue;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
decimalsError = null;
|
|
33
|
+
let formattedValue = value.format().value;
|
|
34
|
+
if (!formattedValue) {
|
|
35
|
+
inputValue = "";
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
inputValue = formattedValue;
|
|
28
39
|
}
|
|
29
40
|
</script>
|
|
30
41
|
|
|
@@ -39,7 +50,7 @@ function fillMaxValue() {
|
|
|
39
50
|
/>
|
|
40
51
|
|
|
41
52
|
{#if maxValue}
|
|
42
|
-
<div class="absolute right-
|
|
53
|
+
<div class="absolute right-2 flex h-10 flex-col justify-center">
|
|
43
54
|
<Button color="blue" class="px-2 py-1" size="xs" pill on:click={fillMaxValue}>MAX</Button>
|
|
44
55
|
</div>
|
|
45
56
|
{/if}
|
|
@@ -53,11 +64,10 @@ function fillMaxValue() {
|
|
|
53
64
|
</InputAddon>
|
|
54
65
|
{/if}
|
|
55
66
|
</div>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
</Alert>
|
|
67
|
+
|
|
68
|
+
{#if decimalsError}
|
|
69
|
+
<p class="mt-1 text-sm text-red-500" data-testid="decimals-error">
|
|
70
|
+
{decimalsError}
|
|
71
|
+
</p>
|
|
62
72
|
{/if}
|
|
63
73
|
</div>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
+
import { Float } from '@rainlanguage/raindex';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
4
5
|
symbol?: string | undefined;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
value?: bigint;
|
|
6
|
+
maxValue?: Float | undefined;
|
|
7
|
+
value?: Float;
|
|
8
8
|
};
|
|
9
9
|
events: {
|
|
10
10
|
[evt: string]: CustomEvent<any>;
|