diff --git a/.eslintrc.js b/.eslintrc.js index 0f9947af0b8..204c96cbffe 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -43,7 +43,7 @@ module.exports = { '**/dist/', '**/.next/', '**/.swc/', - '**/out/' + '**/out/', ], rules: { 'no-case-declarations': 'off', @@ -214,7 +214,7 @@ module.exports = { name: 'react-router-dom', importNames: ['Link', 'useNavigate', 'useSearchParams'], message: - 'Please use `LinkWithQuery`, `useSearchParamsMerged`, and `useNavigateWithQuery` from "~/ui/utils/LinkWithQuery" instead.', + 'Please use `LinkWithQuery`, `useSearchParamsMerged`, and `useNavigateWithQuery` from "~/components/ui/LinkWithQuery" instead.', }, ], }, diff --git a/apps/core/src/hooks/useKioskClient.ts b/apps/core/src/hooks/useKioskClient.ts index 1483c8bed05..79f2d1a7b95 100644 --- a/apps/core/src/hooks/useKioskClient.ts +++ b/apps/core/src/hooks/useKioskClient.ts @@ -4,7 +4,7 @@ import { useContext } from 'react'; -import { KioskClientContext } from '../components/KioskClientProvider'; +import { KioskClientContext } from '../components'; export function useKioskClient() { const kioskClient = useContext(KioskClientContext); diff --git a/apps/explorer/.storybook/main.js b/apps/explorer/.storybook/main.js deleted file mode 100644 index 58efad40fda..00000000000 --- a/apps/explorer/.storybook/main.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// SPDX-License-Identifier: Apache-2.0 - -module.exports = { - stories: [ - { - directory: '../src/ui/stories', - titlePrefix: 'UI', - files: '**/*.stories.*', - }, - ], - addons: ['@storybook/addon-a11y', '@storybook/addon-essentials'], - framework: '@storybook/react-vite', - staticDirs: ['../public'], -}; diff --git a/apps/explorer/.storybook/manager.js b/apps/explorer/.storybook/manager.js deleted file mode 100644 index 7837bed817b..00000000000 --- a/apps/explorer/.storybook/manager.js +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// SPDX-License-Identifier: Apache-2.0 - -import { addons } from '@storybook/addons'; -import { themes } from '@storybook/theming'; - -// Force the theme to light, as our components do not suppor theming -addons.setConfig({ - theme: themes.light, -}); diff --git a/apps/explorer/.storybook/preview-head.html b/apps/explorer/.storybook/preview-head.html deleted file mode 100644 index 17767f3a958..00000000000 --- a/apps/explorer/.storybook/preview-head.html +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/apps/explorer/.storybook/preview.js b/apps/explorer/.storybook/preview.js deleted file mode 100644 index 9dd7511f5a7..00000000000 --- a/apps/explorer/.storybook/preview.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// SPDX-License-Identifier: Apache-2.0 - -import '../src/index.css'; - -export const parameters = { - actions: { argTypesRegex: '^on[A-Z].*' }, - controls: { - matchers: { - color: /(background|color)$/i, - date: /Date$/, - }, - }, -}; diff --git a/apps/explorer/package.json b/apps/explorer/package.json index d4676917524..016f9f91ed3 100644 --- a/apps/explorer/package.json +++ b/apps/explorer/package.json @@ -15,9 +15,6 @@ "lint": "pnpm eslint:check && pnpm prettier:check", "lint:fix": "pnpm eslint:fix && pnpm prettier:fix", "preview": "vite preview", - "storybook": "storybook dev", - "build-storybook": "storybook build", - "preview-storybook": "pnpm dlx serve ./storybook-static", "ampli": "ampli", "pull-amplitude": "ampli pull web && node prependLicense.mjs && prettier -w ampli.json src/utils/analytics/ampli/index.ts" }, @@ -81,12 +78,6 @@ "@amplitude/ampli": "^1.31.5", "@babel/core": "^7.22.9", "@playwright/test": "^1.36.1", - "@storybook/addon-a11y": "^7.1.0", - "@storybook/addon-essentials": "^7.1.0", - "@storybook/addons": "^7.1.0", - "@storybook/react": "^7.1.0", - "@storybook/react-vite": "^7.1.0", - "@storybook/theming": "^7.1.0", "@testing-library/dom": "^9.3.1", "@testing-library/jest-dom": "^5.17.0", "@testing-library/react": "^14.0.0", @@ -102,7 +93,6 @@ "onchange": "^7.1.0", "postcss": "^8.4.31", "start-server-and-test": "^2.0.0", - "storybook": "^7.1.0", "tailwindcss": "^3.3.3", "tsconfig-paths": "^4.2.0", "typescript": "^5.3.3", diff --git a/apps/explorer/src/components/AccountCardGraph.tsx b/apps/explorer/src/components/AccountCardGraph.tsx index 383298b2006..1da31d7d01f 100644 --- a/apps/explorer/src/components/AccountCardGraph.tsx +++ b/apps/explorer/src/components/AccountCardGraph.tsx @@ -14,7 +14,7 @@ import { FormattedStatsAmount } from './home-metrics/FormattedStatsAmount'; import { ErrorBoundary } from './error-boundary/ErrorBoundary'; import { useGetAddressMetrics } from '~/hooks/useGetAddressMetrics'; import { useGetAllEpochAddressMetrics } from '~/hooks/useGetAllEpochAddressMetrics'; -import { Card } from '~/ui/Card'; +import { Card } from '~/components/ui'; const GRAPH_DATA_FIELD = 'cumulativeAddresses'; const GRAPH_DATA_TEXT = 'Total accounts'; diff --git a/apps/explorer/src/components/IotaTokenCard.tsx b/apps/explorer/src/components/IotaTokenCard.tsx index 090b9a2d779..0a7a9691ccd 100644 --- a/apps/explorer/src/components/IotaTokenCard.tsx +++ b/apps/explorer/src/components/IotaTokenCard.tsx @@ -6,8 +6,7 @@ import { COIN_GECKO_IOTA_URL, useIotaCoinData } from '@iota/core'; import { Iota } from '@iota/icons'; import { Text } from '@iota/ui'; -import { Card } from '~/ui/Card'; -import { ButtonOrLink } from '~/ui/ButtonOrLink'; +import { ButtonOrLink, Card } from '~/components/ui'; export function IotaTokenCard(): JSX.Element { const { data } = useIotaCoinData(); diff --git a/apps/explorer/src/components/TransactionsCardGraph.tsx b/apps/explorer/src/components/TransactionsCardGraph.tsx index 7e3cb596a42..b5b498302eb 100644 --- a/apps/explorer/src/components/TransactionsCardGraph.tsx +++ b/apps/explorer/src/components/TransactionsCardGraph.tsx @@ -11,7 +11,7 @@ import clsx from 'clsx'; import { AreaGraph } from './AreaGraph'; import { FormattedStatsAmount } from './home-metrics/FormattedStatsAmount'; import { ErrorBoundary } from './error-boundary/ErrorBoundary'; -import { Card } from '~/ui/Card'; +import { Card } from '~/components/ui'; interface TooltipContentProps { data: { diff --git a/apps/explorer/src/components/activity/index.tsx b/apps/explorer/src/components/activity/Activity.tsx similarity index 93% rename from apps/explorer/src/components/activity/index.tsx rename to apps/explorer/src/components/activity/Activity.tsx index ba43a189393..5a5efea376f 100644 --- a/apps/explorer/src/components/activity/index.tsx +++ b/apps/explorer/src/components/activity/Activity.tsx @@ -3,19 +3,14 @@ // SPDX-License-Identifier: Apache-2.0 import { useFeatureIsOn } from '@growthbook/growthbook-react'; -// import { Filter16 } from '@iota/icons'; import { Heading } from '@iota/ui'; import { useState } from 'react'; import toast from 'react-hot-toast'; +import { CheckpointsTable } from '../checkpoints/CheckpointsTable'; import { EpochsActivityTable } from './EpochsActivityTable'; import { TransactionsActivityTable } from './TransactionsActivityTable'; -import { CheckpointsTable } from '../checkpoints/CheckpointsTable'; -// import { useNetwork } from '~/context'; -// import { DropdownMenu, DropdownMenuCheckboxItem } from '~/ui/DropdownMenu'; -import { PlayPause } from '~/ui/PlayPause'; -import { Tabs, TabsContent, TabsList, TabsTrigger } from '~/ui/Tabs'; -// import { Network } from '~/utils/api/defaultRpcClient'; +import { PlayPause, Tabs, TabsContent, TabsList, TabsTrigger } from '~/components/ui'; const VALID_TABS = ['transactions', 'epochs', 'checkpoints']; diff --git a/apps/explorer/src/components/activity/EpochsActivityTable.tsx b/apps/explorer/src/components/activity/EpochsActivityTable.tsx index 89cc8ea1f5f..a1f31b20ed2 100644 --- a/apps/explorer/src/components/activity/EpochsActivityTable.tsx +++ b/apps/explorer/src/components/activity/EpochsActivityTable.tsx @@ -8,12 +8,15 @@ import { Text } from '@iota/ui'; import { useQuery } from '@tanstack/react-query'; import { useState } from 'react'; -import { generateTableDataFromEpochsData } from './utils'; -import { Link } from '~/ui/Link'; -import { Pagination, useCursorPagination } from '~/ui/Pagination'; -import { PlaceholderTable } from '~/ui/PlaceholderTable'; -import { TableCard } from '~/ui/TableCard'; -import { numberSuffix } from '~/utils/numberUtil'; +import { + Link, + Pagination, + PlaceholderTable, + TableCard, + useCursorPagination, +} from '~/components/ui'; +import { generateTableDataFromEpochsData } from '~/lib/ui'; +import { numberSuffix } from '~/lib/utils'; const DEFAULT_EPOCHS_LIMIT = 20; diff --git a/apps/explorer/src/components/activity/TransactionsActivityTable.tsx b/apps/explorer/src/components/activity/TransactionsActivityTable.tsx index 465199cf944..ef0b3b9abac 100644 --- a/apps/explorer/src/components/activity/TransactionsActivityTable.tsx +++ b/apps/explorer/src/components/activity/TransactionsActivityTable.tsx @@ -8,16 +8,19 @@ import { Text } from '@iota/ui'; import { useQuery } from '@tanstack/react-query'; import { useEffect, useRef, useState } from 'react'; -import { genTableDataFromTxData } from '../transactions/TxCardUtils'; +import { + Link, + Pagination, + PlaceholderTable, + TableCard, + useCursorPagination, +} from '~/components/ui'; import { DEFAULT_TRANSACTIONS_LIMIT, useGetTransactionBlocks, } from '~/hooks/useGetTransactionBlocks'; -import { Link } from '~/ui/Link'; -import { Pagination, useCursorPagination } from '~/ui/Pagination'; -import { PlaceholderTable } from '~/ui/PlaceholderTable'; -import { TableCard } from '~/ui/TableCard'; -import { numberSuffix } from '~/utils/numberUtil'; +import { numberSuffix } from '~/lib/utils'; +import { genTableDataFromTxData } from '../transactions/TxCardUtils'; interface TransactionsActivityTableProps { disablePagination?: boolean; diff --git a/apps/explorer/src/components/activity/index.ts b/apps/explorer/src/components/activity/index.ts new file mode 100644 index 00000000000..ab3b776230c --- /dev/null +++ b/apps/explorer/src/components/activity/index.ts @@ -0,0 +1,6 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './Activity'; +export * from './EpochsActivityTable'; +export * from './TransactionsActivityTable'; diff --git a/apps/explorer/src/components/checkpoints/CheckpointsTable.tsx b/apps/explorer/src/components/checkpoints/CheckpointsTable.tsx index bede195b2ec..cd6f6f44716 100644 --- a/apps/explorer/src/components/checkpoints/CheckpointsTable.tsx +++ b/apps/explorer/src/components/checkpoints/CheckpointsTable.tsx @@ -7,13 +7,16 @@ import { ArrowRight12 } from '@iota/icons'; import { Text } from '@iota/ui'; import { useMemo, useState } from 'react'; +import { + Link, + Pagination, + PlaceholderTable, + TableCard, + useCursorPagination, +} from '~/components/ui'; import { DEFAULT_CHECKPOINTS_LIMIT, useGetCheckpoints } from '~/hooks/useGetCheckpoints'; -import { generateTableDataFromCheckpointsData } from './utils'; -import { Link } from '~/ui/Link'; -import { Pagination, useCursorPagination } from '~/ui/Pagination'; -import { PlaceholderTable } from '~/ui/PlaceholderTable'; -import { TableCard } from '~/ui/TableCard'; -import { numberSuffix } from '~/utils/numberUtil'; +import { generateTableDataFromCheckpointsData } from '~/lib/ui'; +import { numberSuffix } from '~/lib/utils'; interface CheckpointsTableProps { disablePagination?: boolean; diff --git a/apps/explorer/src/components/checkpoints/index.ts b/apps/explorer/src/components/checkpoints/index.ts new file mode 100644 index 00000000000..90ba63db958 --- /dev/null +++ b/apps/explorer/src/components/checkpoints/index.ts @@ -0,0 +1,4 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './CheckpointsTable'; diff --git a/apps/explorer/src/components/error-boundary/ErrorBoundary.tsx b/apps/explorer/src/components/error-boundary/ErrorBoundary.tsx index 6db84a4aa59..1319556bb76 100644 --- a/apps/explorer/src/components/error-boundary/ErrorBoundary.tsx +++ b/apps/explorer/src/components/error-boundary/ErrorBoundary.tsx @@ -5,7 +5,7 @@ import { ErrorBoundary as ReactErrorBoundary } from 'react-error-boundary'; import { useLocation } from 'react-router-dom'; -import { Banner } from '~/ui/Banner'; +import { Banner } from '~/components/ui'; import type { ReactNode } from 'react'; import type { FallbackProps } from 'react-error-boundary'; diff --git a/apps/explorer/src/components/error-boundary/index.ts b/apps/explorer/src/components/error-boundary/index.ts new file mode 100644 index 00000000000..3651091927c --- /dev/null +++ b/apps/explorer/src/components/error-boundary/index.ts @@ -0,0 +1,4 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './ErrorBoundary'; diff --git a/apps/explorer/src/components/footer/Footer.tsx b/apps/explorer/src/components/footer/Footer.tsx index 9c5aeea27a2..dbd0fea8b3b 100644 --- a/apps/explorer/src/components/footer/Footer.tsx +++ b/apps/explorer/src/components/footer/Footer.tsx @@ -7,7 +7,7 @@ import { Text } from '@iota/ui'; import { LegalLinks, LegalText } from './Legal'; import { FooterIcon } from './FooterIcon'; import { ReactComponent as MystenLabsRed } from '../../assets/mysten_labs_red.svg'; -import { Link } from '~/ui/Link'; +import { Link } from '~/components/ui'; import { FOOTER_LINKS, SOCIAL_LINKS } from '~/lib/constants'; import Icon from '../Icon'; diff --git a/apps/explorer/src/components/footer/Legal.tsx b/apps/explorer/src/components/footer/Legal.tsx index 4ef68051c4f..a59fa594181 100644 --- a/apps/explorer/src/components/footer/Legal.tsx +++ b/apps/explorer/src/components/footer/Legal.tsx @@ -6,7 +6,7 @@ import { useProductAnalyticsConfig } from '@iota/core'; import { Text } from '@iota/ui'; import { LEGAL_LINKS } from '~/lib/constants'; -import { Link } from '~/ui/Link'; +import { Link } from '~/components/ui'; export function LegalText(): JSX.Element { return ( diff --git a/apps/explorer/src/components/footer/index.ts b/apps/explorer/src/components/footer/index.ts new file mode 100644 index 00000000000..0d6e56596de --- /dev/null +++ b/apps/explorer/src/components/footer/index.ts @@ -0,0 +1,6 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './Footer'; +export * from './FooterIcon'; +export * from './Legal'; diff --git a/apps/explorer/src/components/gas-breakdown/index.tsx b/apps/explorer/src/components/gas-breakdown/GasBreakdown.tsx similarity index 95% rename from apps/explorer/src/components/gas-breakdown/index.tsx rename to apps/explorer/src/components/gas-breakdown/GasBreakdown.tsx index 24af4d9f214..fb6ac2c0774 100644 --- a/apps/explorer/src/components/gas-breakdown/index.tsx +++ b/apps/explorer/src/components/gas-breakdown/GasBreakdown.tsx @@ -11,12 +11,15 @@ import { import { IOTA_TYPE_ARG } from '@iota/iota.js/utils'; import { Heading, Text } from '@iota/ui'; -import { CopyToClipboard } from '~/ui/CopyToClipboard'; -import { DescriptionItem } from '~/ui/DescriptionList'; -import { Divider } from '~/ui/Divider'; -import { AddressLink, ObjectLink } from '~/ui/InternalLink'; -import { CollapsibleCard } from '~/ui/collapsible/CollapsibleCard'; -import { CollapsibleSection } from '~/ui/collapsible/CollapsibleSection'; +import { + AddressLink, + CollapsibleCard, + CollapsibleSection, + CopyToClipboard, + DescriptionItem, + Divider, + ObjectLink, +} from '~/components/ui'; interface GasProps { amount?: bigint | number | string; diff --git a/apps/explorer/src/components/gas-breakdown/index.ts b/apps/explorer/src/components/gas-breakdown/index.ts new file mode 100644 index 00000000000..9b39098b647 --- /dev/null +++ b/apps/explorer/src/components/gas-breakdown/index.ts @@ -0,0 +1,4 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './GasBreakdown'; diff --git a/apps/explorer/src/components/header/Header.tsx b/apps/explorer/src/components/header/Header.tsx index 192f065270b..b6d9a6440d4 100644 --- a/apps/explorer/src/components/header/Header.tsx +++ b/apps/explorer/src/components/header/Header.tsx @@ -6,9 +6,9 @@ import { Iota, IotaLogoTxt } from '@iota/icons'; import clsx from 'clsx'; import { useEffect, useState } from 'react'; -import NetworkSelect from '../network/Network'; +import { NetworkSelector } from '../network'; import Search from '../search/Search'; -import { LinkWithQuery } from '~/ui/LinkWithQuery'; +import { LinkWithQuery } from '~/components/ui'; function Header(): JSX.Element { const [isScrolled, setIsScrolled] = useState(window.scrollY > 0); @@ -42,7 +42,7 @@ function Header(): JSX.Element {
- + diff --git a/apps/explorer/src/components/header/index.ts b/apps/explorer/src/components/header/index.ts new file mode 100644 index 00000000000..8a717a10a0b --- /dev/null +++ b/apps/explorer/src/components/header/index.ts @@ -0,0 +1,4 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './Header'; diff --git a/apps/explorer/src/components/home-metrics/CurrentEpoch.tsx b/apps/explorer/src/components/home-metrics/CurrentEpoch.tsx index 0bc63761b96..23332566bcc 100644 --- a/apps/explorer/src/components/home-metrics/CurrentEpoch.tsx +++ b/apps/explorer/src/components/home-metrics/CurrentEpoch.tsx @@ -2,17 +2,15 @@ // Modifications Copyright (c) 2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import { formatDate, formatAmountParts } from '@iota/core'; -import { Text, Heading } from '@iota/ui'; +import { formatAmountParts, formatDate } from '@iota/core'; +import { Heading, Text } from '@iota/ui'; import { format, isToday, isYesterday } from 'date-fns'; import { useMemo } from 'react'; -import { Checkpoint } from '~/components/home-metrics/Checkpoint'; +import { Checkpoint } from '~/components'; +import { Card, LinkWithQuery, ProgressBar } from '~/components/ui'; +import { ampli } from '~/lib/utils'; import { useEpochProgress } from '~/pages/epochs/utils'; -import { Card } from '~/ui/Card'; -import { ProgressBar } from '~/ui/ProgressBar'; -import { LinkWithQuery } from '~/ui/LinkWithQuery'; -import { ampli } from '~/utils/analytics/ampli'; export function CurrentEpoch(): JSX.Element { const { epoch, progress, label, end, start } = useEpochProgress(); diff --git a/apps/explorer/src/components/home-metrics/FormattedStatsAmount.tsx b/apps/explorer/src/components/home-metrics/FormattedStatsAmount.tsx index 4d5f858fd87..5bac73e23d9 100644 --- a/apps/explorer/src/components/home-metrics/FormattedStatsAmount.tsx +++ b/apps/explorer/src/components/home-metrics/FormattedStatsAmount.tsx @@ -4,7 +4,7 @@ import { formatAmountParts } from '@iota/core'; -import { Stats, type StatsProps } from '~/ui/Stats'; +import { Stats, type StatsProps } from '~/components/ui'; interface FormattedStatsAmountProps { amount?: string | number | bigint; diff --git a/apps/explorer/src/components/home-metrics/OnTheNetwork.tsx b/apps/explorer/src/components/home-metrics/OnTheNetwork.tsx index de7814be3a7..294831091e2 100644 --- a/apps/explorer/src/components/home-metrics/OnTheNetwork.tsx +++ b/apps/explorer/src/components/home-metrics/OnTheNetwork.tsx @@ -6,10 +6,9 @@ import { CoinFormat, formatBalance } from '@iota/core'; import { useIotaClientQuery } from '@iota/dapp-kit'; import { Heading } from '@iota/ui'; -import { FormattedStatsAmount, StatsWrapper } from './FormattedStatsAmount'; +import { Card, Divider } from '~/components/ui'; import { useGetNetworkMetrics } from '~/hooks/useGetNetworkMetrics'; -import { Card } from '~/ui/Card'; -import { Divider } from '~/ui/Divider'; +import { FormattedStatsAmount, StatsWrapper } from './FormattedStatsAmount'; export function OnTheNetwork(): JSX.Element { const { data: networkMetrics } = useGetNetworkMetrics(); diff --git a/apps/explorer/src/components/home-metrics/index.tsx b/apps/explorer/src/components/home-metrics/index.ts similarity index 100% rename from apps/explorer/src/components/home-metrics/index.tsx rename to apps/explorer/src/components/home-metrics/index.ts diff --git a/apps/explorer/src/components/index.ts b/apps/explorer/src/components/index.ts new file mode 100644 index 00000000000..af1cb20afc2 --- /dev/null +++ b/apps/explorer/src/components/index.ts @@ -0,0 +1,34 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './activity'; +export * from './checkpoints'; +export * from './error-boundary'; +export * from './footer'; +export * from './gas-breakdown'; +export * from './header'; +export * from './home-metrics'; +export * from './layout'; +export * from './module'; +export * from './network'; +export * from './object'; +export * from './owned-coins'; +export * from './owned-objects'; +export * from './search'; +export * from './syntax-highlighter'; +export * from './table'; +export * from './top-packages'; +export * from './top-validators-card'; +export * from './transaction-blocks-for-address'; +export * from './transactions'; +export * from './tx-time'; +export * from './ui'; +export * from './validator'; +export * from './validator-map'; + +export * from './AccountCardGraph'; +export * from './AreaGraph'; +export * from './GraphTooltipContent'; +export * from './Icon'; +export * from './IotaTokenCard'; +export * from './TransactionsCardGraph'; diff --git a/apps/explorer/src/components/layout/index.tsx b/apps/explorer/src/components/layout/Layout.tsx similarity index 87% rename from apps/explorer/src/components/layout/index.tsx rename to apps/explorer/src/components/layout/Layout.tsx index 0201628528b..64b033974f5 100644 --- a/apps/explorer/src/components/layout/index.tsx +++ b/apps/explorer/src/components/layout/Layout.tsx @@ -2,18 +2,18 @@ // Modifications Copyright (c) 2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import { useCookieConsentBanner, KioskClientProvider } from '@iota/core'; +import { KioskClientProvider, useCookieConsentBanner } from '@iota/core'; import { IotaClientProvider, WalletProvider } from '@iota/dapp-kit'; +import type { Network } from '@iota/iota.js/client'; import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; import { Fragment } from 'react'; import { resolveValue, Toaster, type ToastType } from 'react-hot-toast'; import { Outlet, ScrollRestoration } from 'react-router-dom'; -import { useInitialPageView } from '../../hooks/useInitialPageView'; -import { NetworkContext, useNetwork } from '~/context'; -import { Banner, type BannerProps } from '~/ui/Banner'; -import { persistableStorage } from '~/utils/analytics/amplitude'; -import { type Network, createIotaClient, SupportedNetworks } from '~/utils/api/defaultRpcClient'; +import { NetworkContext } from '~/contexts'; +import { useInitialPageView, useNetwork } from '~/hooks'; +import { createIotaClient, persistableStorage, SupportedNetworks } from '~/lib/utils'; +import { Banner, type BannerProps } from '~/components/ui'; const TOAST_VARIANTS: Partial> = { success: 'positive', diff --git a/apps/explorer/src/components/layout/PageLayout.tsx b/apps/explorer/src/components/layout/PageLayout.tsx index 836bdb282c1..c1181bbd489 100644 --- a/apps/explorer/src/components/layout/PageLayout.tsx +++ b/apps/explorer/src/components/layout/PageLayout.tsx @@ -5,15 +5,15 @@ import { useFeatureIsOn } from '@growthbook/growthbook-react'; import { useAppsBackend, useElementDimensions } from '@iota/core'; import { LoadingIndicator } from '@iota/ui'; +import { Network } from '@iota/iota.js/client'; import { useQuery } from '@tanstack/react-query'; import clsx from 'clsx'; import { type ReactNode, useRef } from 'react'; import Footer from '../footer/Footer'; import Header from '../header/Header'; -import { useNetworkContext } from '~/context'; -import { Banner } from '~/ui/Banner'; -import { Network } from '~/utils/api/defaultRpcClient'; +import { useNetworkContext } from '~/contexts'; +import { Banner } from '~/components/ui'; type PageLayoutProps = { gradient?: { diff --git a/apps/explorer/src/components/layout/index.ts b/apps/explorer/src/components/layout/index.ts new file mode 100644 index 00000000000..f669d3e93e3 --- /dev/null +++ b/apps/explorer/src/components/layout/index.ts @@ -0,0 +1,5 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './Layout'; +export * from './PageLayout'; diff --git a/apps/explorer/src/components/module/ModuleCodeTabs.tsx b/apps/explorer/src/components/module/ModuleCodeTabs.tsx index b824530e2b3..3948066d2ec 100644 --- a/apps/explorer/src/components/module/ModuleCodeTabs.tsx +++ b/apps/explorer/src/components/module/ModuleCodeTabs.tsx @@ -2,7 +2,7 @@ // Modifications Copyright (c) 2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import { Tabs, TabsContent, TabsList, TabsTrigger } from '~/ui/Tabs'; +import { Tabs, TabsContent, TabsList, TabsTrigger } from '~/components/ui'; import { Text } from '@iota/ui'; import ModuleView from './ModuleView'; diff --git a/apps/explorer/src/components/module/ModuleView.tsx b/apps/explorer/src/components/module/ModuleView.tsx index 7291b8dfe9f..156e8fced73 100644 --- a/apps/explorer/src/components/module/ModuleView.tsx +++ b/apps/explorer/src/components/module/ModuleView.tsx @@ -5,12 +5,12 @@ import { type IotaMoveNormalizedType } from '@iota/iota.js/client'; import { normalizeIotaAddress } from '@iota/iota.js/utils'; import cl from 'clsx'; -import Highlight, { defaultProps, Prism } from 'prism-react-renderer'; +import { Highlight, Prism } from 'prism-react-renderer'; import 'prism-themes/themes/prism-one-light.css'; import { useMemo } from 'react'; import { useNormalizedMoveModule } from '~/hooks/useNormalizedMoveModule'; -import { LinkWithQuery } from '~/ui/LinkWithQuery'; +import { LinkWithQuery } from '~/components/ui'; import type { Language } from 'prism-react-renderer'; @@ -18,7 +18,6 @@ import styles from './ModuleView.module.css'; // Include Rust language support. // TODO: Write a custom prismjs syntax for Move Bytecode. -// @ts-expect-error: Defining global prism object: globalThis.Prism = Prism; // @ts-expect-error: This file is untyped: import('prismjs/components/prism-rust').catch(() => {}); @@ -81,12 +80,7 @@ function ModuleView({ id, name, code }: ModuleViewProps): JSX.Element { return (
- + {({ className, style, tokens, getLineProps, getTokenProps }) => (
                             {tokens.map((line, i) => (
diff --git a/apps/explorer/src/components/module/PkgModulesWrapper.tsx b/apps/explorer/src/components/module/PkgModulesWrapper.tsx
index df823113811..0a03da4c9ce 100644
--- a/apps/explorer/src/components/module/PkgModulesWrapper.tsx
+++ b/apps/explorer/src/components/module/PkgModulesWrapper.tsx
@@ -5,30 +5,33 @@
 import { Search24 } from '@iota/icons';
 import { Combobox, ComboboxInput, ComboboxList } from '@iota/ui';
 import clsx from 'clsx';
-import { useState, useCallback, useEffect } from 'react';
+import { useCallback, useEffect, useState } from 'react';
 import { type Direction } from 'react-resizable-panels';
 
-import { ModuleFunctionsInteraction } from './module-functions-interaction';
+import {
+    ListItem,
+    SplitPanes,
+    TabHeader,
+    useSearchParamsMerged,
+    VerticalList,
+} from '~/components/ui';
 import { useBreakpoint } from '~/hooks/useBreakpoint';
-import { SplitPanes } from '~/ui/SplitPanes';
-import { TabHeader } from '~/ui/Tabs';
-import { ListItem, VerticalList } from '~/ui/VerticalList';
-import { useSearchParamsMerged } from '~/ui/LinkWithQuery';
+import { ModuleFunctionsInteraction } from './module-functions-interaction';
 import { ModuleCodeTabs } from './ModuleCodeTabs';
 
 type ModuleType = [moduleName: string, code: string];
 
-interface PkgModuleViewWrapperProps {
+interface PkgModulesWrapperProps {
     id: string;
     modules: ModuleType[];
     splitPanelOrientation: Direction;
 }
 
-function PkgModuleViewWrapper({
+export function PkgModulesWrapper({
     id,
     modules,
     splitPanelOrientation,
-}: PkgModuleViewWrapperProps): JSX.Element {
+}: PkgModulesWrapperProps): JSX.Element {
     const isMediumOrAbove = useBreakpoint('md');
 
     const [searchParams, setSearchParams] = useSearchParamsMerged();
@@ -157,4 +160,3 @@ function PkgModuleViewWrapper({
         
); } -export default PkgModuleViewWrapper; diff --git a/apps/explorer/src/components/module/index.ts b/apps/explorer/src/components/module/index.ts new file mode 100644 index 00000000000..7ee1c7f744c --- /dev/null +++ b/apps/explorer/src/components/module/index.ts @@ -0,0 +1,6 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './ModuleCodeTabs'; +export * from './ModuleView'; +export * from './PkgModulesWrapper'; diff --git a/apps/explorer/src/components/module/module-functions-interaction/FunctionExecutionResult.tsx b/apps/explorer/src/components/module/module-functions-interaction/FunctionExecutionResult.tsx index 2a34e10c8ec..7e94d3fda84 100644 --- a/apps/explorer/src/components/module/module-functions-interaction/FunctionExecutionResult.tsx +++ b/apps/explorer/src/components/module/module-functions-interaction/FunctionExecutionResult.tsx @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 import { LinkGroup } from './LinkGroup'; -import { Banner } from '~/ui/Banner'; +import { Banner } from '~/components/ui'; import type { IotaTransactionBlockResponse, OwnedObjectRef } from '@iota/iota.js/client'; diff --git a/apps/explorer/src/components/module/module-functions-interaction/LinkGroup.tsx b/apps/explorer/src/components/module/module-functions-interaction/LinkGroup.tsx index 0da225c5597..701c41669aa 100644 --- a/apps/explorer/src/components/module/module-functions-interaction/LinkGroup.tsx +++ b/apps/explorer/src/components/module/module-functions-interaction/LinkGroup.tsx @@ -2,7 +2,7 @@ // Modifications Copyright (c) 2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import { Link } from '~/ui/Link'; +import { Link } from '~/components/ui'; type LinkGroupProps = { title: string; diff --git a/apps/explorer/src/components/module/module-functions-interaction/ModuleFunction.tsx b/apps/explorer/src/components/module/module-functions-interaction/ModuleFunction.tsx index af54255b3b0..f901cf614d1 100644 --- a/apps/explorer/src/components/module/module-functions-interaction/ModuleFunction.tsx +++ b/apps/explorer/src/components/module/module-functions-interaction/ModuleFunction.tsx @@ -3,25 +3,23 @@ // SPDX-License-Identifier: Apache-2.0 import { useZodForm } from '@iota/core'; -import { ArrowRight12 } from '@iota/icons'; -import { TransactionBlock, getPureSerializationType } from '@iota/iota.js/transactions'; -import { Button } from '@iota/ui'; import { ConnectButton, useCurrentAccount, useSignAndExecuteTransactionBlock, } from '@iota/dapp-kit'; +import { ArrowRight12 } from '@iota/icons'; +import { TransactionBlock, getPureSerializationType } from '@iota/iota.js/transactions'; +import { Button } from '@iota/ui'; import { useMutation } from '@tanstack/react-query'; import clsx from 'clsx'; import { useMemo } from 'react'; import { useWatch } from 'react-hook-form'; import { z } from 'zod'; +import { DisclosureBox, Input } from '~/components/ui'; +import { useFunctionParamsDetails, useFunctionTypeArguments } from '~/hooks'; import { FunctionExecutionResult } from './FunctionExecutionResult'; -import { useFunctionParamsDetails } from './useFunctionParamsDetails'; -import { useFunctionTypeArguments } from './useFunctionTypeArguments'; -import { DisclosureBox } from '~/ui/DisclosureBox'; -import { Input } from '~/ui/Input'; import type { IotaMoveNormalizedFunction } from '@iota/iota.js/client'; import type { TypeOf } from 'zod'; diff --git a/apps/explorer/src/components/module/module-functions-interaction/index.tsx b/apps/explorer/src/components/module/module-functions-interaction/ModuleFunctionsInteraction.tsx similarity index 98% rename from apps/explorer/src/components/module/module-functions-interaction/index.tsx rename to apps/explorer/src/components/module/module-functions-interaction/ModuleFunctionsInteraction.tsx index e478ebaa162..d1b2805ec39 100644 --- a/apps/explorer/src/components/module/module-functions-interaction/index.tsx +++ b/apps/explorer/src/components/module/module-functions-interaction/ModuleFunctionsInteraction.tsx @@ -7,7 +7,7 @@ import { useMemo } from 'react'; import { ModuleFunction } from './ModuleFunction'; import { useNormalizedMoveModule } from '~/hooks/useNormalizedMoveModule'; -import { Banner } from '~/ui/Banner'; +import { Banner } from '~/components/ui'; type ModuleFunctionsInteractionProps = { packageId: string; diff --git a/apps/explorer/src/components/module/module-functions-interaction/index.ts b/apps/explorer/src/components/module/module-functions-interaction/index.ts new file mode 100644 index 00000000000..e85be9e78fb --- /dev/null +++ b/apps/explorer/src/components/module/module-functions-interaction/index.ts @@ -0,0 +1,7 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './FunctionExecutionResult'; +export * from './LinkGroup'; +export * from './ModuleFunction'; +export * from './ModuleFunctionsInteraction'; diff --git a/apps/explorer/src/components/network/Network.tsx b/apps/explorer/src/components/network/WrappedNetworkSelect.tsx similarity index 80% rename from apps/explorer/src/components/network/Network.tsx rename to apps/explorer/src/components/network/WrappedNetworkSelect.tsx index b993f305b00..26c00d92be2 100644 --- a/apps/explorer/src/components/network/Network.tsx +++ b/apps/explorer/src/components/network/WrappedNetworkSelect.tsx @@ -5,12 +5,12 @@ import { useIotaClientQuery } from '@iota/dapp-kit'; import { useContext } from 'react'; -import { NetworkContext } from '../../context'; -import { NetworkSelect, type NetworkOption } from '~/ui/header/NetworkSelect'; -import { ampli } from '~/utils/analytics/ampli'; +import { NetworkContext } from '~/contexts'; +import { NetworkSelect, type NetworkOption } from '~/components/ui'; +import { ampli } from '~/lib/utils'; import { getAllNetworks } from '@iota/iota.js/client'; -export default function WrappedNetworkSelect(): JSX.Element { +export function NetworkSelector(): JSX.Element { const [network, setNetwork] = useContext(NetworkContext); const { data } = useIotaClientQuery('getLatestIotaSystemState'); const { data: binaryVersion } = useIotaClientQuery('getRpcApiVersion'); diff --git a/apps/explorer/src/components/network/index.ts b/apps/explorer/src/components/network/index.ts new file mode 100644 index 00000000000..1ed2883c8df --- /dev/null +++ b/apps/explorer/src/components/network/index.ts @@ -0,0 +1,4 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './WrappedNetworkSelect'; diff --git a/apps/explorer/src/components/object/DynamicFieldsCard.tsx b/apps/explorer/src/components/object/DynamicFieldsCard.tsx index 937844a19ff..dd7f2fe6253 100644 --- a/apps/explorer/src/components/object/DynamicFieldsCard.tsx +++ b/apps/explorer/src/components/object/DynamicFieldsCard.tsx @@ -8,8 +8,8 @@ import { LoadingIndicator } from '@iota/ui'; import { useRef, useEffect, useState, useMemo } from 'react'; import { UnderlyingObjectCard } from './UnderlyingObjectCard'; -import { FieldsCard, FieldCollapsible, FieldsContainer } from '~/components/object/FieldsUtils'; -import { ObjectLink } from '~/ui/InternalLink'; +import { FieldsCard, FieldCollapsible, FieldsContainer } from '~/components'; +import { ObjectLink } from '~/components/ui'; interface DynamicFieldRowProps { id: string; diff --git a/apps/explorer/src/components/object/FieldItem.tsx b/apps/explorer/src/components/object/FieldItem.tsx index f631415693c..301cb092ffa 100644 --- a/apps/explorer/src/components/object/FieldItem.tsx +++ b/apps/explorer/src/components/object/FieldItem.tsx @@ -5,10 +5,9 @@ import { type IotaMoveNormalizedType } from '@iota/iota.js/client'; import { Text } from '@iota/ui'; -import { getFieldTypeValue } from './utils'; -import { SyntaxHighlighter } from '~/components/syntax-highlighter'; -import { AddressLink, ObjectLink } from '~/ui/InternalLink'; -import { Link } from '~/ui/Link'; +import { SyntaxHighlighter } from '~/components'; +import { AddressLink, Link, ObjectLink } from '~/components/ui'; +import { getFieldTypeValue } from '~/lib/ui'; interface FieldItemProps { value: string | number | object | boolean; diff --git a/apps/explorer/src/components/object/FieldsUtils.tsx b/apps/explorer/src/components/object/FieldsUtils.tsx index 8dcf731d628..01ba4d034a5 100644 --- a/apps/explorer/src/components/object/FieldsUtils.tsx +++ b/apps/explorer/src/components/object/FieldsUtils.tsx @@ -5,8 +5,7 @@ import clsx from 'clsx'; import { type ReactNode } from 'react'; -import { Card } from '~/ui/Card'; -import { CollapsibleSection } from '~/ui/collapsible/CollapsibleSection'; +import { Card, CollapsibleSection } from '~/components/ui'; interface FieldCollapsibleProps { name: string | ReactNode; diff --git a/apps/explorer/src/components/object/ObjectFieldsCard.tsx b/apps/explorer/src/components/object/ObjectFieldsCard.tsx index 83a5e65010f..f6e2a9cc652 100644 --- a/apps/explorer/src/components/object/ObjectFieldsCard.tsx +++ b/apps/explorer/src/components/object/ObjectFieldsCard.tsx @@ -4,16 +4,15 @@ import { Search24 } from '@iota/icons'; import { type IotaMoveNormalizedStruct, type IotaObjectResponse } from '@iota/iota.js/client'; -import { Text, LoadingIndicator, Combobox, ComboboxInput, ComboboxList } from '@iota/ui'; +import { Combobox, ComboboxInput, ComboboxList, LoadingIndicator, Text } from '@iota/ui'; import clsx from 'clsx'; import { useCallback, useEffect, useState } from 'react'; +import { FieldCollapsible, FieldsCard, FieldsContainer } from '~/components'; +import { Banner, Description } from '~/components/ui'; +import { getFieldTypeValue } from '~/lib/ui'; import { FieldItem } from './FieldItem'; import { ScrollToViewCard } from './ScrollToViewCard'; -import { getFieldTypeValue } from './utils'; -import { FieldsCard, FieldCollapsible, FieldsContainer } from '~/components/object/FieldsUtils'; -import { Banner } from '~/ui/Banner'; -import { Description } from '~/ui/Description'; const DEFAULT_OPEN_FIELDS = 3; const DEFAULT_FIELDS_COUNT_TO_SHOW_SEARCH = 10; diff --git a/apps/explorer/src/components/object/UnderlyingObjectCard.tsx b/apps/explorer/src/components/object/UnderlyingObjectCard.tsx index 1004a0a962e..27814429b73 100644 --- a/apps/explorer/src/components/object/UnderlyingObjectCard.tsx +++ b/apps/explorer/src/components/object/UnderlyingObjectCard.tsx @@ -6,7 +6,7 @@ import { useIotaClientQuery } from '@iota/dapp-kit'; import { LoadingIndicator } from '@iota/ui'; import { FieldItem } from './FieldItem'; -import { Banner } from '~/ui/Banner'; +import { Banner } from '~/components/ui'; import type { DynamicFieldName } from '@iota/iota.js/client'; diff --git a/apps/explorer/src/components/object/index.ts b/apps/explorer/src/components/object/index.ts new file mode 100644 index 00000000000..413c6bd5f88 --- /dev/null +++ b/apps/explorer/src/components/object/index.ts @@ -0,0 +1,9 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './DynamicFieldsCard'; +export * from './FieldItem'; +export * from './FieldsUtils'; +export * from './ObjectFieldsCard'; +export * from './ScrollToViewCard'; +export * from './UnderlyingObjectCard'; diff --git a/apps/explorer/src/components/owned-coins/CoinIcon.tsx b/apps/explorer/src/components/owned-coins/CoinIcon.tsx index bcce5048e76..6304c77f1bd 100644 --- a/apps/explorer/src/components/owned-coins/CoinIcon.tsx +++ b/apps/explorer/src/components/owned-coins/CoinIcon.tsx @@ -7,7 +7,7 @@ import { Iota, Unstaked } from '@iota/icons'; import { IOTA_TYPE_ARG } from '@iota/iota.js/utils'; import { cva, type VariantProps } from 'class-variance-authority'; -import { ImageIcon } from '~/ui/ImageIcon'; +import { ImageIcon } from '~/components/ui'; const imageStyle = cva(['flex rounded-2xl'], { variants: { diff --git a/apps/explorer/src/components/owned-coins/CoinItem.tsx b/apps/explorer/src/components/owned-coins/CoinItem.tsx index ec5cc957742..8f890409af2 100644 --- a/apps/explorer/src/components/owned-coins/CoinItem.tsx +++ b/apps/explorer/src/components/owned-coins/CoinItem.tsx @@ -6,7 +6,7 @@ import { useFormatCoin } from '@iota/core'; import { type CoinStruct } from '@iota/iota.js/client'; import { Text } from '@iota/ui'; -import { ObjectLink } from '~/ui/InternalLink'; +import { ObjectLink } from '~/components/ui'; type CoinItemProps = { coin: CoinStruct; diff --git a/apps/explorer/src/components/owned-coins/OwnedCoinView.tsx b/apps/explorer/src/components/owned-coins/OwnedCoinView.tsx index 9a76284bd00..5b730365805 100644 --- a/apps/explorer/src/components/owned-coins/OwnedCoinView.tsx +++ b/apps/explorer/src/components/owned-coins/OwnedCoinView.tsx @@ -10,12 +10,11 @@ import * as Collapsible from '@radix-ui/react-collapsible'; import clsx from 'clsx'; import { useState } from 'react'; -import { type CoinBalanceVerified } from '.'; +import { Banner, Tooltip } from '~/components/ui'; +import { ampli } from '~/lib/utils'; import { CoinIcon } from './CoinIcon'; +import { type CoinBalanceVerified } from './OwnedCoins'; import CoinsPanel from './OwnedCoinsPanel'; -import { Banner } from '~/ui/Banner'; -import { Tooltip } from '~/ui/Tooltip'; -import { ampli } from '~/utils/analytics/ampli'; type OwnedCoinViewProps = { coin: CoinBalanceVerified; diff --git a/apps/explorer/src/components/owned-coins/index.tsx b/apps/explorer/src/components/owned-coins/OwnedCoins.tsx similarity index 99% rename from apps/explorer/src/components/owned-coins/index.tsx rename to apps/explorer/src/components/owned-coins/OwnedCoins.tsx index 3ed75a1305c..867dac719f3 100644 --- a/apps/explorer/src/components/owned-coins/index.tsx +++ b/apps/explorer/src/components/owned-coins/OwnedCoins.tsx @@ -12,7 +12,7 @@ import { useMemo, useState } from 'react'; import OwnedCoinView from './OwnedCoinView'; import { useRecognizedPackages } from '~/hooks/useRecognizedPackages'; -import { Pagination } from '~/ui/Pagination'; +import { Pagination } from '~/components/ui'; export type CoinBalanceVerified = CoinBalance & { isRecognized?: boolean; diff --git a/apps/explorer/src/components/owned-coins/index.ts b/apps/explorer/src/components/owned-coins/index.ts new file mode 100644 index 00000000000..21ab7bc1bfe --- /dev/null +++ b/apps/explorer/src/components/owned-coins/index.ts @@ -0,0 +1,8 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './CoinIcon'; +export * from './CoinItem'; +export * from './OwnedCoinView'; +export * from './OwnedCoins'; +export * from './OwnedCoinsPanel'; diff --git a/apps/explorer/src/components/owned-objects/ListView.tsx b/apps/explorer/src/components/owned-objects/ListView.tsx index 4364509e021..7d705b8e259 100644 --- a/apps/explorer/src/components/owned-objects/ListView.tsx +++ b/apps/explorer/src/components/owned-objects/ListView.tsx @@ -7,12 +7,10 @@ import { formatAddress } from '@iota/iota.js/utils'; import { Placeholder, Text } from '@iota/ui'; import { type ReactNode } from 'react'; -import { OwnedObjectsText } from '~/components/owned-objects/OwnedObjectsText'; +import { OwnedObjectsText } from '~/components'; +import { ObjectLink, ObjectVideoImage } from '~/components/ui'; import { useResolveVideo } from '~/hooks/useResolveVideo'; -import { ObjectLink } from '~/ui/InternalLink'; -import { ObjectVideoImage } from '~/ui/ObjectVideoImage'; -import { parseObjectType } from '~/utils/objectUtils'; -import { trimStdLibPrefix } from '~/utils/stringUtils'; +import { parseObjectType, trimStdLibPrefix } from '~/lib/utils'; interface ListViewItemProps { assetCell?: ReactNode; diff --git a/apps/explorer/src/components/owned-objects/OwnedObject.tsx b/apps/explorer/src/components/owned-objects/OwnedObject.tsx index 569388d55ed..bccb9d4bce4 100644 --- a/apps/explorer/src/components/owned-objects/OwnedObject.tsx +++ b/apps/explorer/src/components/owned-objects/OwnedObject.tsx @@ -5,9 +5,8 @@ import { type IotaObjectResponse } from '@iota/iota.js/client'; import { useResolveVideo } from '~/hooks/useResolveVideo'; -import { ObjectDetails } from '~/ui/ObjectDetails'; -import { parseObjectType } from '~/utils/objectUtils'; -import { trimStdLibPrefix } from '~/utils/stringUtils'; +import { parseObjectType, trimStdLibPrefix } from '~/lib/utils'; +import { ObjectDetails } from '~/components/ui'; type OwnedObjectProps = { obj: IotaObjectResponse; diff --git a/apps/explorer/src/components/owned-objects/index.tsx b/apps/explorer/src/components/owned-objects/OwnedObjects.tsx similarity index 97% rename from apps/explorer/src/components/owned-objects/index.tsx rename to apps/explorer/src/components/owned-objects/OwnedObjects.tsx index b429ac1f7b4..e63ec707c59 100644 --- a/apps/explorer/src/components/owned-objects/index.tsx +++ b/apps/explorer/src/components/owned-objects/OwnedObjects.tsx @@ -8,11 +8,9 @@ import { Heading, IconButton, RadioGroup, RadioGroupItem, Text } from '@iota/ui' import clsx from 'clsx'; import { useEffect, useMemo, useState } from 'react'; -import { ListView } from '~/components/owned-objects/ListView'; -import { SmallThumbnailsView } from '~/components/owned-objects/SmallThumbnailsView'; -import { ThumbnailsView } from '~/components/owned-objects/ThumbnailsView'; +import { ListView, SmallThumbnailsView, ThumbnailsView } from '~/components'; import { ObjectViewMode } from '~/lib/enums'; -import { Pagination, useCursorPagination } from '~/ui/Pagination'; +import { Pagination, useCursorPagination } from '~/components/ui'; const PAGE_SIZES = [10, 20, 30, 40, 50]; const SHOW_PAGINATION_MAX_ITEMS = 9; diff --git a/apps/explorer/src/components/owned-objects/SmallThumbnailsView.tsx b/apps/explorer/src/components/owned-objects/SmallThumbnailsView.tsx index ed7e086aa8e..04a537be28a 100644 --- a/apps/explorer/src/components/owned-objects/SmallThumbnailsView.tsx +++ b/apps/explorer/src/components/owned-objects/SmallThumbnailsView.tsx @@ -7,12 +7,10 @@ import { formatAddress } from '@iota/iota.js/utils'; import { Placeholder } from '@iota/ui'; import { type ReactNode } from 'react'; -import { OwnedObjectsText } from '~/components/owned-objects/OwnedObjectsText'; +import { OwnedObjectsText } from '~/components'; +import { ObjectLink, ObjectVideoImage } from '~/components/ui'; import { useResolveVideo } from '~/hooks/useResolveVideo'; -import { ObjectLink } from '~/ui/InternalLink'; -import { ObjectVideoImage } from '~/ui/ObjectVideoImage'; -import { parseObjectType } from '~/utils/objectUtils'; -import { trimStdLibPrefix } from '~/utils/stringUtils'; +import { parseObjectType, trimStdLibPrefix } from '~/lib/utils'; interface SmallThumbnailsViewProps { limit: number; diff --git a/apps/explorer/src/components/owned-objects/ThumbnailsView.tsx b/apps/explorer/src/components/owned-objects/ThumbnailsView.tsx index a92aa00c5c8..03ddf408acb 100644 --- a/apps/explorer/src/components/owned-objects/ThumbnailsView.tsx +++ b/apps/explorer/src/components/owned-objects/ThumbnailsView.tsx @@ -6,11 +6,9 @@ import { type IotaObjectResponse } from '@iota/iota.js/client'; import { formatAddress } from '@iota/iota.js/utils'; import { Placeholder, Text } from '@iota/ui'; +import { ObjectLink, ObjectVideoImage } from '~/components/ui'; import { useResolveVideo } from '~/hooks/useResolveVideo'; -import { ObjectLink } from '~/ui/InternalLink'; -import { ObjectVideoImage } from '~/ui/ObjectVideoImage'; -import { parseObjectType } from '~/utils/objectUtils'; -import { trimStdLibPrefix } from '~/utils/stringUtils'; +import { parseObjectType, trimStdLibPrefix } from '~/lib/utils'; function Thumbnail({ obj }: { obj: IotaObjectResponse }): JSX.Element { const video = useResolveVideo(obj); diff --git a/apps/explorer/src/components/owned-objects/index.ts b/apps/explorer/src/components/owned-objects/index.ts new file mode 100644 index 00000000000..0bcd90bd8c9 --- /dev/null +++ b/apps/explorer/src/components/owned-objects/index.ts @@ -0,0 +1,9 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './ListView'; +export * from './OwnedObject'; +export * from './OwnedObjects'; +export * from './OwnedObjectsText'; +export * from './SmallThumbnailsView'; +export * from './ThumbnailsView'; diff --git a/apps/explorer/src/components/search/Search.tsx b/apps/explorer/src/components/search/Search.tsx index bbadd61fd9f..91f2b4739f0 100644 --- a/apps/explorer/src/components/search/Search.tsx +++ b/apps/explorer/src/components/search/Search.tsx @@ -2,13 +2,12 @@ // Modifications Copyright (c) 2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import { useState, useCallback, useEffect } from 'react'; +import { useCallback, useEffect, useState } from 'react'; +import { Search as SearchBox, useNavigateWithQuery, type SearchResult } from '~/components/ui'; import { useDebouncedValue } from '~/hooks/useDebouncedValue'; import { useSearch } from '~/hooks/useSearch'; -import { Search as SearchBox, type SearchResult } from '~/ui/Search'; -import { useNavigateWithQuery } from '~/ui/LinkWithQuery'; -import { ampli } from '~/utils/analytics/ampli'; +import { ampli } from '~/lib/utils'; function Search(): JSX.Element { const [query, setQuery] = useState(''); diff --git a/apps/explorer/src/components/search/index.ts b/apps/explorer/src/components/search/index.ts new file mode 100644 index 00000000000..b7aa76607b7 --- /dev/null +++ b/apps/explorer/src/components/search/index.ts @@ -0,0 +1,4 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './Search'; diff --git a/apps/explorer/src/components/syntax-highlighter/index.tsx b/apps/explorer/src/components/syntax-highlighter/SyntaxHighlighter.tsx similarity index 93% rename from apps/explorer/src/components/syntax-highlighter/index.tsx rename to apps/explorer/src/components/syntax-highlighter/SyntaxHighlighter.tsx index a2d142478c1..59dd797e928 100644 --- a/apps/explorer/src/components/syntax-highlighter/index.tsx +++ b/apps/explorer/src/components/syntax-highlighter/SyntaxHighlighter.tsx @@ -4,7 +4,7 @@ import { useOnScreen } from '@iota/core'; import { useRef, useEffect, useState } from 'react'; -import Highlight, { defaultProps } from 'prism-react-renderer'; +import { Highlight } from 'prism-react-renderer'; import 'prism-themes/themes/prism-one-light.css'; import type { Language } from 'prism-react-renderer'; @@ -26,7 +26,7 @@ export function SyntaxHighlighter({ code, language }: SyntaxHighlighterProps): J }, [isIntersecting]); return (
- + {({ style, tokens, getLineProps, getTokenProps }) => (
                         {tokens.slice(0, loadedLines).map((line, i) => (
diff --git a/apps/explorer/src/components/syntax-highlighter/index.ts b/apps/explorer/src/components/syntax-highlighter/index.ts
new file mode 100644
index 00000000000..0b6ce182e60
--- /dev/null
+++ b/apps/explorer/src/components/syntax-highlighter/index.ts
@@ -0,0 +1,4 @@
+// Copyright (c) 2024 IOTA Stiftung
+// SPDX-License-Identifier: Apache-2.0
+
+export * from './SyntaxHighlighter';
diff --git a/apps/explorer/src/components/table/TableFooter.tsx b/apps/explorer/src/components/table/TableFooter.tsx
index 7d2e4a5346c..2139f18e920 100644
--- a/apps/explorer/src/components/table/TableFooter.tsx
+++ b/apps/explorer/src/components/table/TableFooter.tsx
@@ -5,9 +5,13 @@
 import { ArrowRight12 } from '@iota/icons';
 import { Text } from '@iota/ui';
 
-import { Link } from '~/ui/Link';
-import { Pagination, type PaginationResponse, type usePaginationStack } from '~/ui/Pagination';
-import { numberSuffix } from '~/utils/numberUtil';
+import {
+    Link,
+    Pagination,
+    type PaginationResponse,
+    type usePaginationStack,
+} from '~/components/ui';
+import { numberSuffix } from '~/lib/utils';
 
 interface TableFooterProps {
     label: string;
diff --git a/apps/explorer/src/components/table/index.ts b/apps/explorer/src/components/table/index.ts
new file mode 100644
index 00000000000..e0cb5d82526
--- /dev/null
+++ b/apps/explorer/src/components/table/index.ts
@@ -0,0 +1,6 @@
+// Copyright (c) 2024 IOTA Stiftung
+// SPDX-License-Identifier: Apache-2.0
+
+export * from './HighlightedTableCol';
+export * from './IotaAmount';
+export * from './TableFooter';
diff --git a/apps/explorer/src/components/top-packages/TopPackagesCard.tsx b/apps/explorer/src/components/top-packages/TopPackagesCard.tsx
index 95ce5991b66..646ef685f47 100644
--- a/apps/explorer/src/components/top-packages/TopPackagesCard.tsx
+++ b/apps/explorer/src/components/top-packages/TopPackagesCard.tsx
@@ -5,11 +5,10 @@
 import { useQuery } from '@tanstack/react-query';
 import { useState } from 'react';
 
-import { TopPackagesTable } from './TopPackagesTable';
-import { ErrorBoundary } from '../error-boundary/ErrorBoundary';
+import { FilterList, TabHeader } from '~/components/ui';
 import { useEnhancedRpcClient } from '~/hooks/useEnhancedRpc';
-import { FilterList } from '~/ui/FilterList';
-import { TabHeader } from '~/ui/Tabs';
+import { ErrorBoundary } from '../error-boundary/ErrorBoundary';
+import { TopPackagesTable } from './TopPackagesTable';
 
 type DateFilter = '3D' | '7D' | '30D';
 type ApiDateFilter = 'rank3Days' | 'rank7Days' | 'rank30Days';
diff --git a/apps/explorer/src/components/top-packages/TopPackagesTable.tsx b/apps/explorer/src/components/top-packages/TopPackagesTable.tsx
index 5e35b12657e..6bd1f5a26e0 100644
--- a/apps/explorer/src/components/top-packages/TopPackagesTable.tsx
+++ b/apps/explorer/src/components/top-packages/TopPackagesTable.tsx
@@ -6,9 +6,7 @@ import { type MoveCallMetric } from '@iota/iota.js/client';
 import { Text } from '@iota/ui';
 import { useMemo } from 'react';
 
-import { ObjectLink } from '~/ui/InternalLink';
-import { PlaceholderTable } from '~/ui/PlaceholderTable';
-import { TableCard } from '~/ui/TableCard';
+import { ObjectLink, PlaceholderTable, TableCard } from '~/components/ui';
 
 interface TopPackagesTableProps {
     data: MoveCallMetric[];
diff --git a/apps/explorer/src/components/top-packages/index.ts b/apps/explorer/src/components/top-packages/index.ts
new file mode 100644
index 00000000000..9bdbcca1924
--- /dev/null
+++ b/apps/explorer/src/components/top-packages/index.ts
@@ -0,0 +1,5 @@
+// Copyright (c) 2024 IOTA Stiftung
+// SPDX-License-Identifier: Apache-2.0
+
+export * from './TopPackagesCard';
+export * from './TopPackagesTable';
diff --git a/apps/explorer/src/components/top-validators-card/TopValidatorsCard.tsx b/apps/explorer/src/components/top-validators-card/TopValidatorsCard.tsx
index 86d57cb1de8..a379b125f46 100644
--- a/apps/explorer/src/components/top-validators-card/TopValidatorsCard.tsx
+++ b/apps/explorer/src/components/top-validators-card/TopValidatorsCard.tsx
@@ -8,15 +8,18 @@ import { type IotaValidatorSummary } from '@iota/iota.js/client';
 import { Text } from '@iota/ui';
 import { type ReactNode, useMemo } from 'react';
 
+import { HighlightedTableCol } from '~/components';
+import {
+    AddressLink,
+    Banner,
+    ImageIcon,
+    Link,
+    PlaceholderTable,
+    TableCard,
+    ValidatorLink,
+} from '~/components/ui';
+import { ampli } from '~/lib/utils';
 import { StakeColumn } from './StakeColumn';
-import { HighlightedTableCol } from '~/components/table/HighlightedTableCol';
-import { Banner } from '~/ui/Banner';
-import { ImageIcon } from '~/ui/ImageIcon';
-import { AddressLink, ValidatorLink } from '~/ui/InternalLink';
-import { Link } from '~/ui/Link';
-import { PlaceholderTable } from '~/ui/PlaceholderTable';
-import { TableCard } from '~/ui/TableCard';
-import { ampli } from '~/utils/analytics/ampli';
 
 const NUMBER_OF_VALIDATORS = 10;
 
diff --git a/apps/explorer/src/components/top-validators-card/index.ts b/apps/explorer/src/components/top-validators-card/index.ts
new file mode 100644
index 00000000000..8dbd58fa832
--- /dev/null
+++ b/apps/explorer/src/components/top-validators-card/index.ts
@@ -0,0 +1,5 @@
+// Copyright (c) 2024 IOTA Stiftung
+// SPDX-License-Identifier: Apache-2.0
+
+export * from './StakeColumn';
+export * from './TopValidatorsCard';
diff --git a/apps/explorer/src/components/transaction-blocks-for-address/index.tsx b/apps/explorer/src/components/transaction-blocks-for-address/TransactionBlocksForAddress.tsx
similarity index 96%
rename from apps/explorer/src/components/transaction-blocks-for-address/index.tsx
rename to apps/explorer/src/components/transaction-blocks-for-address/TransactionBlocksForAddress.tsx
index 5173197b867..2706953beb6 100644
--- a/apps/explorer/src/components/transaction-blocks-for-address/index.tsx
+++ b/apps/explorer/src/components/transaction-blocks-for-address/TransactionBlocksForAddress.tsx
@@ -6,16 +6,14 @@ import { type TransactionFilter } from '@iota/iota.js/client';
 import { Heading, RadioGroup, RadioGroupItem } from '@iota/ui';
 import { type Dispatch, type SetStateAction, useReducer, useState } from 'react';
 
-import { genTableDataFromTxData } from '../transactions/TxCardUtils';
+import clsx from 'clsx';
+import { Pagination, PlaceholderTable, TableCard } from '~/components/ui';
 import {
     DEFAULT_TRANSACTIONS_LIMIT,
     useGetTransactionBlocks,
 } from '~/hooks/useGetTransactionBlocks';
-import { Pagination } from '~/ui/Pagination';
-import { PlaceholderTable } from '~/ui/PlaceholderTable';
-import { TableCard } from '~/ui/TableCard';
-import clsx from 'clsx';
 import { ObjectFilterValue } from '~/lib/enums';
+import { genTableDataFromTxData } from '../transactions/TxCardUtils';
 
 type TransactionBlocksForAddressProps = {
     address: string;
@@ -88,7 +86,7 @@ export function FiltersControl({ filterValue, setFilterValue }: FiltersControlPr
     );
 }
 
-function TransactionBlocksForAddress({
+export function TransactionBlocksForAddress({
     address,
     filter = ObjectFilterValue.Changed,
     header,
@@ -182,5 +180,3 @@ function TransactionBlocksForAddress({
         
); } - -export default TransactionBlocksForAddress; diff --git a/apps/explorer/src/components/transaction-blocks-for-address/index.ts b/apps/explorer/src/components/transaction-blocks-for-address/index.ts new file mode 100644 index 00000000000..2ce7ac946ba --- /dev/null +++ b/apps/explorer/src/components/transaction-blocks-for-address/index.ts @@ -0,0 +1,4 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './TransactionBlocksForAddress'; diff --git a/apps/explorer/src/components/transactions/ProgTxnBlockCard.tsx b/apps/explorer/src/components/transactions/ProgTxnBlockCard.tsx index e1e77c14a42..bb985129cb7 100644 --- a/apps/explorer/src/components/transactions/ProgTxnBlockCard.tsx +++ b/apps/explorer/src/components/transactions/ProgTxnBlockCard.tsx @@ -5,8 +5,12 @@ import clsx from 'clsx'; import { type ReactNode } from 'react'; -import { ExpandableList, ExpandableListControl, ExpandableListItems } from '~/ui/ExpandableList'; -import { CollapsibleCard } from '~/ui/collapsible/CollapsibleCard'; +import { + CollapsibleCard, + ExpandableList, + ExpandableListControl, + ExpandableListItems, +} from '~/components/ui'; interface ProgrammableTxnBlockCardProps { items: ReactNode[]; diff --git a/apps/explorer/src/components/transactions/TransactionsForAddress.tsx b/apps/explorer/src/components/transactions/TransactionsForAddress.tsx index 3e4e656e95e..289ec1c887c 100644 --- a/apps/explorer/src/components/transactions/TransactionsForAddress.tsx +++ b/apps/explorer/src/components/transactions/TransactionsForAddress.tsx @@ -7,9 +7,8 @@ import { type IotaTransactionBlockResponse } from '@iota/iota.js/client'; import { LoadingIndicator, Text } from '@iota/ui'; import { useQuery } from '@tanstack/react-query'; +import { Banner, TableCard } from '~/components/ui'; import { genTableDataFromTxData } from './TxCardUtils'; -import { Banner } from '~/ui/Banner'; -import { TableCard } from '~/ui/TableCard'; interface TransactionsForAddressProps { address: string; diff --git a/apps/explorer/src/components/transactions/TxCardUtils.tsx b/apps/explorer/src/components/transactions/TxCardUtils.tsx index e8340d2d213..331f49167d6 100644 --- a/apps/explorer/src/components/transactions/TxCardUtils.tsx +++ b/apps/explorer/src/components/transactions/TxCardUtils.tsx @@ -8,8 +8,8 @@ import { type IotaClient, type IotaTransactionBlockResponse } from '@iota/iota.j import { IotaAmount } from '../table/IotaAmount'; import { TxTimeType } from '../tx-time/TxTimeType'; -import { HighlightedTableCol } from '~/components/table/HighlightedTableCol'; -import { AddressLink, TransactionLink } from '~/ui/InternalLink'; +import { HighlightedTableCol } from '~/components'; +import { AddressLink, TransactionLink } from '~/components/ui'; import { type ReactNode } from 'react'; interface TransactionData { diff --git a/apps/explorer/src/components/transactions/index.ts b/apps/explorer/src/components/transactions/index.ts new file mode 100644 index 00000000000..968ecec6a40 --- /dev/null +++ b/apps/explorer/src/components/transactions/index.ts @@ -0,0 +1,6 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './ProgTxnBlockCard'; +export * from './TransactionsForAddress'; +export * from './TxCardUtils'; diff --git a/apps/explorer/src/components/tx-time/index.ts b/apps/explorer/src/components/tx-time/index.ts new file mode 100644 index 00000000000..e139bced96c --- /dev/null +++ b/apps/explorer/src/components/tx-time/index.ts @@ -0,0 +1,4 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './TxTimeType'; diff --git a/apps/explorer/src/ui/Amount.tsx b/apps/explorer/src/components/ui/Amount.tsx similarity index 100% rename from apps/explorer/src/ui/Amount.tsx rename to apps/explorer/src/components/ui/Amount.tsx diff --git a/apps/explorer/src/ui/Banner.tsx b/apps/explorer/src/components/ui/Banner.tsx similarity index 100% rename from apps/explorer/src/ui/Banner.tsx rename to apps/explorer/src/components/ui/Banner.tsx diff --git a/apps/explorer/src/ui/ButtonOrLink.tsx b/apps/explorer/src/components/ui/ButtonOrLink.tsx similarity index 84% rename from apps/explorer/src/ui/ButtonOrLink.tsx rename to apps/explorer/src/components/ui/ButtonOrLink.tsx index 5452f25b398..21ed2e161cd 100644 --- a/apps/explorer/src/ui/ButtonOrLink.tsx +++ b/apps/explorer/src/components/ui/ButtonOrLink.tsx @@ -4,10 +4,13 @@ import { type ComponentProps, forwardRef } from 'react'; -import { LinkWithQuery, type LinkProps } from './LinkWithQuery'; +import { LinkWithQuery, type RouterLinkProps } from './LinkWithQuery'; export interface ButtonOrLinkProps - extends Omit & ComponentProps<'a'> & ComponentProps<'button'>, 'ref'> {} + extends Omit< + Partial & ComponentProps<'a'> & ComponentProps<'button'>, + 'ref' + > {} export const ButtonOrLink = forwardRef( // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/apps/explorer/src/ui/Card.tsx b/apps/explorer/src/components/ui/Card.tsx similarity index 100% rename from apps/explorer/src/ui/Card.tsx rename to apps/explorer/src/components/ui/Card.tsx diff --git a/apps/explorer/src/ui/CoinsStack.tsx b/apps/explorer/src/components/ui/CoinsStack.tsx similarity index 97% rename from apps/explorer/src/ui/CoinsStack.tsx rename to apps/explorer/src/components/ui/CoinsStack.tsx index 669b108bca5..7165c65af98 100644 --- a/apps/explorer/src/ui/CoinsStack.tsx +++ b/apps/explorer/src/components/ui/CoinsStack.tsx @@ -7,7 +7,7 @@ import { Iota, Unstaked } from '@iota/icons'; import { type CoinMetadata } from '@iota/iota.js/client'; import clsx from 'clsx'; -import { Image } from '~/ui/image/Image'; +import { Image } from '~/components/ui'; interface CoinIconProps { coinMetadata?: CoinMetadata | null; diff --git a/apps/explorer/src/ui/CopyToClipboard.tsx b/apps/explorer/src/components/ui/CopyToClipboard.tsx similarity index 98% rename from apps/explorer/src/ui/CopyToClipboard.tsx rename to apps/explorer/src/components/ui/CopyToClipboard.tsx index 6925354d10e..ef9513f49d4 100644 --- a/apps/explorer/src/ui/CopyToClipboard.tsx +++ b/apps/explorer/src/components/ui/CopyToClipboard.tsx @@ -9,7 +9,7 @@ import { motion } from 'framer-motion'; import { useEffect, useState } from 'react'; import { toast } from 'react-hot-toast'; -import { Link } from '~/ui/Link'; +import { Link } from '~/components/ui'; const iconStyles = cva([], { variants: { diff --git a/apps/explorer/src/ui/DateCard.tsx b/apps/explorer/src/components/ui/DateCard.tsx similarity index 100% rename from apps/explorer/src/ui/DateCard.tsx rename to apps/explorer/src/components/ui/DateCard.tsx diff --git a/apps/explorer/src/ui/DateFilter.tsx b/apps/explorer/src/components/ui/DateFilter.tsx similarity index 100% rename from apps/explorer/src/ui/DateFilter.tsx rename to apps/explorer/src/components/ui/DateFilter.tsx diff --git a/apps/explorer/src/ui/Description.tsx b/apps/explorer/src/components/ui/Description.tsx similarity index 100% rename from apps/explorer/src/ui/Description.tsx rename to apps/explorer/src/components/ui/Description.tsx diff --git a/apps/explorer/src/ui/DescriptionList.tsx b/apps/explorer/src/components/ui/DescriptionList.tsx similarity index 100% rename from apps/explorer/src/ui/DescriptionList.tsx rename to apps/explorer/src/components/ui/DescriptionList.tsx diff --git a/apps/explorer/src/ui/DisclosureBox.tsx b/apps/explorer/src/components/ui/DisclosureBox.tsx similarity index 100% rename from apps/explorer/src/ui/DisclosureBox.tsx rename to apps/explorer/src/components/ui/DisclosureBox.tsx diff --git a/apps/explorer/src/ui/Divider.tsx b/apps/explorer/src/components/ui/Divider.tsx similarity index 100% rename from apps/explorer/src/ui/Divider.tsx rename to apps/explorer/src/components/ui/Divider.tsx diff --git a/apps/explorer/src/ui/DropdownMenu.tsx b/apps/explorer/src/components/ui/DropdownMenu.tsx similarity index 100% rename from apps/explorer/src/ui/DropdownMenu.tsx rename to apps/explorer/src/components/ui/DropdownMenu.tsx diff --git a/apps/explorer/src/ui/ExpandableList.tsx b/apps/explorer/src/components/ui/ExpandableList.tsx similarity index 100% rename from apps/explorer/src/ui/ExpandableList.tsx rename to apps/explorer/src/components/ui/ExpandableList.tsx diff --git a/apps/explorer/src/ui/FilterList.tsx b/apps/explorer/src/components/ui/FilterList.tsx similarity index 100% rename from apps/explorer/src/ui/FilterList.tsx rename to apps/explorer/src/components/ui/FilterList.tsx diff --git a/apps/explorer/src/ui/ImageIcon.tsx b/apps/explorer/src/components/ui/ImageIcon.tsx similarity index 100% rename from apps/explorer/src/ui/ImageIcon.tsx rename to apps/explorer/src/components/ui/ImageIcon.tsx diff --git a/apps/explorer/src/ui/Input.tsx b/apps/explorer/src/components/ui/Input.tsx similarity index 100% rename from apps/explorer/src/ui/Input.tsx rename to apps/explorer/src/components/ui/Input.tsx diff --git a/apps/explorer/src/ui/InternalLink.tsx b/apps/explorer/src/components/ui/InternalLink.tsx similarity index 97% rename from apps/explorer/src/ui/InternalLink.tsx rename to apps/explorer/src/components/ui/InternalLink.tsx index dee5f307376..a3921a5205a 100644 --- a/apps/explorer/src/ui/InternalLink.tsx +++ b/apps/explorer/src/components/ui/InternalLink.tsx @@ -6,7 +6,7 @@ import { isIotaNSName } from '@iota/core'; import { formatAddress, formatDigest } from '@iota/iota.js/utils'; import { type ReactNode } from 'react'; -import { Link, type LinkProps } from '~/ui/Link'; +import { Link, type LinkProps } from '~/components/ui'; interface BaseInternalLinkProps extends LinkProps { noTruncate?: boolean; diff --git a/apps/explorer/src/ui/Label.tsx b/apps/explorer/src/components/ui/Label.tsx similarity index 100% rename from apps/explorer/src/ui/Label.tsx rename to apps/explorer/src/components/ui/Label.tsx diff --git a/apps/explorer/src/ui/Link.tsx b/apps/explorer/src/components/ui/Link.tsx similarity index 100% rename from apps/explorer/src/ui/Link.tsx rename to apps/explorer/src/components/ui/Link.tsx diff --git a/apps/explorer/src/ui/LinkWithQuery.tsx b/apps/explorer/src/components/ui/LinkWithQuery.tsx similarity index 98% rename from apps/explorer/src/ui/LinkWithQuery.tsx rename to apps/explorer/src/components/ui/LinkWithQuery.tsx index 03f1188a2b9..f8f110fae29 100644 --- a/apps/explorer/src/ui/LinkWithQuery.tsx +++ b/apps/explorer/src/components/ui/LinkWithQuery.tsx @@ -16,7 +16,7 @@ import { type LinkProps, } from 'react-router-dom'; -export { LinkProps }; +export { LinkProps as RouterLinkProps }; /** Query params that we want to be preserved between all pages. */ export const PRESERVE_QUERY = ['network']; diff --git a/apps/explorer/src/ui/ListboxSelect.tsx b/apps/explorer/src/components/ui/ListboxSelect.tsx similarity index 100% rename from apps/explorer/src/ui/ListboxSelect.tsx rename to apps/explorer/src/components/ui/ListboxSelect.tsx diff --git a/apps/explorer/src/ui/ObjectDetails.tsx b/apps/explorer/src/components/ui/ObjectDetails.tsx similarity index 97% rename from apps/explorer/src/ui/ObjectDetails.tsx rename to apps/explorer/src/components/ui/ObjectDetails.tsx index 2c06e04a83d..2bcaf71d770 100644 --- a/apps/explorer/src/ui/ObjectDetails.tsx +++ b/apps/explorer/src/components/ui/ObjectDetails.tsx @@ -7,7 +7,7 @@ import { cva } from 'class-variance-authority'; import { useState } from 'react'; import { ObjectLink } from './InternalLink'; -import { ObjectVideoImage } from '~/ui/ObjectVideoImage'; +import { ObjectVideoImage } from '~/components/ui'; const textStyles = cva(['flex min-w-0 flex-col flex-nowrap'], { variants: { diff --git a/apps/explorer/src/ui/ObjectVideoImage.tsx b/apps/explorer/src/components/ui/ObjectVideoImage.tsx similarity index 96% rename from apps/explorer/src/ui/ObjectVideoImage.tsx rename to apps/explorer/src/components/ui/ObjectVideoImage.tsx index 73cc077a25b..08253b387f9 100644 --- a/apps/explorer/src/ui/ObjectVideoImage.tsx +++ b/apps/explorer/src/components/ui/ObjectVideoImage.tsx @@ -6,8 +6,7 @@ import { MediaPlay16 } from '@iota/icons'; import { cva, type VariantProps } from 'class-variance-authority'; import clsx from 'clsx'; -import { ObjectModal } from '~/ui/modal/ObjectModal'; -import { Image, type ImageProps } from '~/ui/image/Image'; +import { Image, ObjectModal, type ImageProps } from '~/components/ui'; const imageStyles = cva(['z-0 flex-shrink-0 relative'], { variants: { diff --git a/apps/explorer/src/ui/PageHeader.tsx b/apps/explorer/src/components/ui/PageHeader.tsx similarity index 98% rename from apps/explorer/src/ui/PageHeader.tsx rename to apps/explorer/src/components/ui/PageHeader.tsx index 5fa551c60a1..900dbe6849c 100644 --- a/apps/explorer/src/ui/PageHeader.tsx +++ b/apps/explorer/src/components/ui/PageHeader.tsx @@ -5,9 +5,8 @@ import { Flag16, Info12 } from '@iota/icons'; import { Heading, Placeholder, Text } from '@iota/ui'; +import { Banner, CopyToClipboard } from '~/components/ui'; import { ReactComponent as CallIcon } from './icons/transactions/call.svg'; -import { Banner } from '~/ui/Banner'; -import { CopyToClipboard } from '~/ui/CopyToClipboard'; type PageHeaderType = 'Transaction' | 'Checkpoint' | 'Address' | 'Object' | 'Package'; diff --git a/apps/explorer/src/ui/Pagination.tsx b/apps/explorer/src/components/ui/Pagination.tsx similarity index 100% rename from apps/explorer/src/ui/Pagination.tsx rename to apps/explorer/src/components/ui/Pagination.tsx diff --git a/apps/explorer/src/ui/PlaceholderTable.tsx b/apps/explorer/src/components/ui/PlaceholderTable.tsx similarity index 100% rename from apps/explorer/src/ui/PlaceholderTable.tsx rename to apps/explorer/src/components/ui/PlaceholderTable.tsx diff --git a/apps/explorer/src/ui/PlayPause.tsx b/apps/explorer/src/components/ui/PlayPause.tsx similarity index 100% rename from apps/explorer/src/ui/PlayPause.tsx rename to apps/explorer/src/components/ui/PlayPause.tsx diff --git a/apps/explorer/src/ui/ProgressBar.tsx b/apps/explorer/src/components/ui/ProgressBar.tsx similarity index 100% rename from apps/explorer/src/ui/ProgressBar.tsx rename to apps/explorer/src/components/ui/ProgressBar.tsx diff --git a/apps/explorer/src/ui/ProgressCircle.tsx b/apps/explorer/src/components/ui/ProgressCircle.tsx similarity index 100% rename from apps/explorer/src/ui/ProgressCircle.tsx rename to apps/explorer/src/components/ui/ProgressCircle.tsx diff --git a/apps/explorer/src/ui/RingChart.tsx b/apps/explorer/src/components/ui/RingChart.tsx similarity index 100% rename from apps/explorer/src/ui/RingChart.tsx rename to apps/explorer/src/components/ui/RingChart.tsx diff --git a/apps/explorer/src/ui/Search.tsx b/apps/explorer/src/components/ui/Search.tsx similarity index 100% rename from apps/explorer/src/ui/Search.tsx rename to apps/explorer/src/components/ui/Search.tsx diff --git a/apps/explorer/src/ui/SplitPanes.tsx b/apps/explorer/src/components/ui/SplitPanes.tsx similarity index 100% rename from apps/explorer/src/ui/SplitPanes.tsx rename to apps/explorer/src/components/ui/SplitPanes.tsx diff --git a/apps/explorer/src/ui/Stats.tsx b/apps/explorer/src/components/ui/Stats.tsx similarity index 96% rename from apps/explorer/src/ui/Stats.tsx rename to apps/explorer/src/components/ui/Stats.tsx index d85de273fcb..d90f305420f 100644 --- a/apps/explorer/src/ui/Stats.tsx +++ b/apps/explorer/src/components/ui/Stats.tsx @@ -6,8 +6,8 @@ import { Heading, Text } from '@iota/ui'; import clsx from 'clsx'; import { ReactComponent as InfoSvg } from './icons/info_10x10.svg'; -import { Tooltip } from '~/ui/Tooltip'; -import { ampli } from '~/utils/analytics/ampli'; +import { Tooltip } from '~/components/ui'; +import { ampli } from '~/lib/utils'; import type { ReactNode } from 'react'; diff --git a/apps/explorer/src/ui/StatusIcon.tsx b/apps/explorer/src/components/ui/StatusIcon.tsx similarity index 100% rename from apps/explorer/src/ui/StatusIcon.tsx rename to apps/explorer/src/components/ui/StatusIcon.tsx diff --git a/apps/explorer/src/ui/TableCard.tsx b/apps/explorer/src/components/ui/TableCard.tsx similarity index 100% rename from apps/explorer/src/ui/TableCard.tsx rename to apps/explorer/src/components/ui/TableCard.tsx diff --git a/apps/explorer/src/ui/TableHeader.tsx b/apps/explorer/src/components/ui/TableHeader.tsx similarity index 100% rename from apps/explorer/src/ui/TableHeader.tsx rename to apps/explorer/src/components/ui/TableHeader.tsx diff --git a/apps/explorer/src/ui/Tabs.tsx b/apps/explorer/src/components/ui/Tabs.tsx similarity index 98% rename from apps/explorer/src/ui/Tabs.tsx rename to apps/explorer/src/components/ui/Tabs.tsx index 64c8c9e0f38..e08055edab4 100644 --- a/apps/explorer/src/ui/Tabs.tsx +++ b/apps/explorer/src/components/ui/Tabs.tsx @@ -16,7 +16,7 @@ import { import { Tooltip } from './Tooltip'; import { ReactComponent as InfoSvg } from './icons/info_10x10.svg'; -import { ampli } from '~/utils/analytics/ampli'; +import { ampli } from '~/lib/utils'; type TabSize = 'md' | 'lg' | 'sm'; diff --git a/apps/explorer/src/ui/Tooltip.tsx b/apps/explorer/src/components/ui/Tooltip.tsx similarity index 100% rename from apps/explorer/src/ui/Tooltip.tsx rename to apps/explorer/src/components/ui/Tooltip.tsx diff --git a/apps/explorer/src/ui/VerticalList.tsx b/apps/explorer/src/components/ui/VerticalList.tsx similarity index 100% rename from apps/explorer/src/ui/VerticalList.tsx rename to apps/explorer/src/components/ui/VerticalList.tsx diff --git a/apps/explorer/src/ui/collapsible/CollapsibleCard.tsx b/apps/explorer/src/components/ui/collapsible/CollapsibleCard.tsx similarity index 98% rename from apps/explorer/src/ui/collapsible/CollapsibleCard.tsx rename to apps/explorer/src/components/ui/collapsible/CollapsibleCard.tsx index dade2a1b72d..ed7424f22d8 100644 --- a/apps/explorer/src/ui/collapsible/CollapsibleCard.tsx +++ b/apps/explorer/src/components/ui/collapsible/CollapsibleCard.tsx @@ -8,7 +8,7 @@ import * as Collapsible from '@radix-ui/react-collapsible'; import clsx from 'clsx'; import { type ReactNode, useState } from 'react'; -import { Card, type CardProps } from '~/ui/Card'; +import { Card, type CardProps } from '~/components/ui'; type Size = 'md' | 'sm'; diff --git a/apps/explorer/src/ui/collapsible/CollapsibleSection.tsx b/apps/explorer/src/components/ui/collapsible/CollapsibleSection.tsx similarity index 97% rename from apps/explorer/src/ui/collapsible/CollapsibleSection.tsx rename to apps/explorer/src/components/ui/collapsible/CollapsibleSection.tsx index fa9ae4768ac..b89709f4c91 100644 --- a/apps/explorer/src/ui/collapsible/CollapsibleSection.tsx +++ b/apps/explorer/src/components/ui/collapsible/CollapsibleSection.tsx @@ -7,7 +7,7 @@ import * as Collapsible from '@radix-ui/react-collapsible'; import clsx from 'clsx'; import { type ReactNode, useState } from 'react'; -import { Divider } from '~/ui/Divider'; +import { Divider } from '~/components/ui'; interface CollapsibleSectionProps { children: ReactNode; diff --git a/apps/explorer/src/components/ui/collapsible/index.ts b/apps/explorer/src/components/ui/collapsible/index.ts new file mode 100644 index 00000000000..8a454d7b3e4 --- /dev/null +++ b/apps/explorer/src/components/ui/collapsible/index.ts @@ -0,0 +1,5 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './CollapsibleCard'; +export * from './CollapsibleSection'; diff --git a/apps/explorer/src/ui/header/NavItem.tsx b/apps/explorer/src/components/ui/header/NavItem.tsx similarity index 100% rename from apps/explorer/src/ui/header/NavItem.tsx rename to apps/explorer/src/components/ui/header/NavItem.tsx diff --git a/apps/explorer/src/ui/header/NetworkSelect.tsx b/apps/explorer/src/components/ui/header/NetworkSelect.tsx similarity index 99% rename from apps/explorer/src/ui/header/NetworkSelect.tsx rename to apps/explorer/src/components/ui/header/NetworkSelect.tsx index c5dc31fbf31..59e6c71f00e 100644 --- a/apps/explorer/src/ui/header/NetworkSelect.tsx +++ b/apps/explorer/src/components/ui/header/NetworkSelect.tsx @@ -5,7 +5,7 @@ /** * This is an App UI Component, which is responsible for network selection. * It's as context un-aware as it reasonably can be, being a controlled component. - * In the future, this should move outside of the base `~/ui/` directory, but for + * In the future, this should move outside of the base `~/components/ui/` directory, but for * now we are including App UI Components in the base UI component directory. */ diff --git a/apps/explorer/src/components/ui/header/index.ts b/apps/explorer/src/components/ui/header/index.ts new file mode 100644 index 00000000000..04c198254e6 --- /dev/null +++ b/apps/explorer/src/components/ui/header/index.ts @@ -0,0 +1,5 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './NavItem'; +export * from './NetworkSelect'; diff --git a/apps/explorer/src/ui/icons/check_12x12.svg b/apps/explorer/src/components/ui/icons/check_12x12.svg similarity index 100% rename from apps/explorer/src/ui/icons/check_12x12.svg rename to apps/explorer/src/components/ui/icons/check_12x12.svg diff --git a/apps/explorer/src/ui/icons/check_16x16.svg b/apps/explorer/src/components/ui/icons/check_16x16.svg similarity index 100% rename from apps/explorer/src/ui/icons/check_16x16.svg rename to apps/explorer/src/components/ui/icons/check_16x16.svg diff --git a/apps/explorer/src/ui/icons/check_24x24.svg b/apps/explorer/src/components/ui/icons/check_24x24.svg similarity index 100% rename from apps/explorer/src/ui/icons/check_24x24.svg rename to apps/explorer/src/components/ui/icons/check_24x24.svg diff --git a/apps/explorer/src/ui/icons/info.svg b/apps/explorer/src/components/ui/icons/info.svg similarity index 100% rename from apps/explorer/src/ui/icons/info.svg rename to apps/explorer/src/components/ui/icons/info.svg diff --git a/apps/explorer/src/ui/icons/info_10x10.svg b/apps/explorer/src/components/ui/icons/info_10x10.svg similarity index 100% rename from apps/explorer/src/ui/icons/info_10x10.svg rename to apps/explorer/src/components/ui/icons/info_10x10.svg diff --git a/apps/explorer/src/ui/icons/menu.svg b/apps/explorer/src/components/ui/icons/menu.svg similarity index 100% rename from apps/explorer/src/ui/icons/menu.svg rename to apps/explorer/src/components/ui/icons/menu.svg diff --git a/apps/explorer/src/ui/icons/transactions/call.svg b/apps/explorer/src/components/ui/icons/transactions/call.svg similarity index 100% rename from apps/explorer/src/ui/icons/transactions/call.svg rename to apps/explorer/src/components/ui/icons/transactions/call.svg diff --git a/apps/explorer/src/ui/icons/x.svg b/apps/explorer/src/components/ui/icons/x.svg similarity index 100% rename from apps/explorer/src/ui/icons/x.svg rename to apps/explorer/src/components/ui/icons/x.svg diff --git a/apps/explorer/src/ui/image/Image.tsx b/apps/explorer/src/components/ui/image/Image.tsx similarity index 100% rename from apps/explorer/src/ui/image/Image.tsx rename to apps/explorer/src/components/ui/image/Image.tsx diff --git a/apps/explorer/src/components/ui/image/index.ts b/apps/explorer/src/components/ui/image/index.ts new file mode 100644 index 00000000000..3e8e038690d --- /dev/null +++ b/apps/explorer/src/components/ui/image/index.ts @@ -0,0 +1,4 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './Image'; diff --git a/apps/explorer/src/components/ui/index.ts b/apps/explorer/src/components/ui/index.ts new file mode 100644 index 00000000000..9846be657de --- /dev/null +++ b/apps/explorer/src/components/ui/index.ts @@ -0,0 +1,48 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './collapsible'; +export * from './header'; +export * from './image'; +export * from './modal'; + +export * from './Amount'; +export * from './Banner'; +export * from './ButtonOrLink'; +export * from './Card'; +export * from './CoinsStack'; +export * from './CopyToClipboard'; +export * from './DateCard'; +export * from './DateFilter'; +export * from './Description'; +export * from './DescriptionList'; +export * from './DisclosureBox'; +export * from './Divider'; +export * from './DropdownMenu'; +export * from './ExpandableList'; +export * from './FilterList'; +export * from './ImageIcon'; +export * from './Input'; +export * from './InternalLink'; +export * from './Label'; +export * from './Link'; +export * from './LinkWithQuery'; +export * from './ListboxSelect'; +export * from './ObjectDetails'; +export * from './ObjectVideoImage'; +export * from './PageHeader'; +export * from './Pagination'; +export * from './PlaceholderTable'; +export * from './PlayPause'; +export * from './ProgressBar'; +export * from './ProgressCircle'; +export * from './RingChart'; +export * from './Search'; +export * from './SplitPanes'; +export * from './Stats'; +export * from './StatusIcon'; +export * from './TableCard'; +export * from './TableHeader'; +export * from './Tabs'; +export * from './Tooltip'; +export * from './VerticalList'; diff --git a/apps/explorer/src/ui/modal/index.tsx b/apps/explorer/src/components/ui/modal/Modal.tsx similarity index 100% rename from apps/explorer/src/ui/modal/index.tsx rename to apps/explorer/src/components/ui/modal/Modal.tsx diff --git a/apps/explorer/src/ui/modal/ObjectModal.tsx b/apps/explorer/src/components/ui/modal/ObjectModal.tsx similarity index 97% rename from apps/explorer/src/ui/modal/ObjectModal.tsx rename to apps/explorer/src/components/ui/modal/ObjectModal.tsx index f98baf25019..80c79c5718d 100644 --- a/apps/explorer/src/ui/modal/ObjectModal.tsx +++ b/apps/explorer/src/components/ui/modal/ObjectModal.tsx @@ -5,7 +5,7 @@ import { X12 } from '@iota/icons'; import { Text, Heading, IconButton } from '@iota/ui'; -import { Modal, type ModalProps } from './index'; +import { Modal, type ModalProps } from './Modal'; import { Image } from '../image/Image'; export interface ObjectModalProps extends Omit { diff --git a/apps/explorer/src/components/ui/modal/index.ts b/apps/explorer/src/components/ui/modal/index.ts new file mode 100644 index 00000000000..f3989c974c6 --- /dev/null +++ b/apps/explorer/src/components/ui/modal/index.ts @@ -0,0 +1,5 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './Modal'; +export * from './ObjectModal'; diff --git a/apps/explorer/src/ui/stories/Amount.stories.tsx b/apps/explorer/src/components/ui/stories/Amount.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/Amount.stories.tsx rename to apps/explorer/src/components/ui/stories/Amount.stories.tsx diff --git a/apps/explorer/src/ui/stories/Banner.stories.tsx b/apps/explorer/src/components/ui/stories/Banner.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/Banner.stories.tsx rename to apps/explorer/src/components/ui/stories/Banner.stories.tsx diff --git a/apps/explorer/src/ui/stories/Card.stories.tsx b/apps/explorer/src/components/ui/stories/Card.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/Card.stories.tsx rename to apps/explorer/src/components/ui/stories/Card.stories.tsx diff --git a/apps/explorer/src/ui/stories/CoinsStack.stories.tsx b/apps/explorer/src/components/ui/stories/CoinsStack.stories.tsx similarity index 92% rename from apps/explorer/src/ui/stories/CoinsStack.stories.tsx rename to apps/explorer/src/components/ui/stories/CoinsStack.stories.tsx index 64cf7e657fe..0a10d7f2dec 100644 --- a/apps/explorer/src/ui/stories/CoinsStack.stories.tsx +++ b/apps/explorer/src/components/ui/stories/CoinsStack.stories.tsx @@ -6,7 +6,7 @@ import { IotaClientProvider } from '@iota/dapp-kit'; import { type Meta, type StoryObj } from '@storybook/react'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; -import { CoinsStack, type CoinsStackProps } from '~/ui/CoinsStack'; +import { CoinsStack, type CoinsStackProps } from '~/components/ui'; export default { component: CoinsStack, diff --git a/apps/explorer/src/ui/stories/CollapsibleCard.stories.tsx b/apps/explorer/src/components/ui/stories/CollapsibleCard.stories.tsx similarity index 85% rename from apps/explorer/src/ui/stories/CollapsibleCard.stories.tsx rename to apps/explorer/src/components/ui/stories/CollapsibleCard.stories.tsx index cfca567d7b9..71b3ae2ba72 100644 --- a/apps/explorer/src/ui/stories/CollapsibleCard.stories.tsx +++ b/apps/explorer/src/components/ui/stories/CollapsibleCard.stories.tsx @@ -4,8 +4,7 @@ import { type Meta, type StoryObj } from '@storybook/react'; -import { CollapsibleCard, type CollapsibleCardProps } from '~/ui/collapsible/CollapsibleCard'; -import { CollapsibleSection } from '~/ui/collapsible/CollapsibleSection'; +import { CollapsibleCard, CollapsibleSection, type CollapsibleCardProps } from '~/components/ui'; export default { component: CollapsibleCard, diff --git a/apps/explorer/src/ui/stories/CopyToClipboard.stories.tsx b/apps/explorer/src/components/ui/stories/CopyToClipboard.stories.tsx similarity index 88% rename from apps/explorer/src/ui/stories/CopyToClipboard.stories.tsx rename to apps/explorer/src/components/ui/stories/CopyToClipboard.stories.tsx index bc246708a40..69d8393b1dc 100644 --- a/apps/explorer/src/ui/stories/CopyToClipboard.stories.tsx +++ b/apps/explorer/src/components/ui/stories/CopyToClipboard.stories.tsx @@ -4,7 +4,7 @@ import { Toaster } from 'react-hot-toast'; -import { CopyToClipboard, type CopyToClipboardProps } from '~/ui/CopyToClipboard'; +import { CopyToClipboard, type CopyToClipboardProps } from '~/components/ui'; import type { Meta, StoryObj } from '@storybook/react'; diff --git a/apps/explorer/src/ui/stories/DateCard.stories.tsx b/apps/explorer/src/components/ui/stories/DateCard.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/DateCard.stories.tsx rename to apps/explorer/src/components/ui/stories/DateCard.stories.tsx diff --git a/apps/explorer/src/ui/stories/DateFilter.stories.tsx b/apps/explorer/src/components/ui/stories/DateFilter.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/DateFilter.stories.tsx rename to apps/explorer/src/components/ui/stories/DateFilter.stories.tsx diff --git a/apps/explorer/src/ui/stories/DescriptionList.stories.tsx b/apps/explorer/src/components/ui/stories/DescriptionList.stories.tsx similarity index 96% rename from apps/explorer/src/ui/stories/DescriptionList.stories.tsx rename to apps/explorer/src/components/ui/stories/DescriptionList.stories.tsx index 8ccf35ca070..d7d6b394e77 100644 --- a/apps/explorer/src/ui/stories/DescriptionList.stories.tsx +++ b/apps/explorer/src/components/ui/stories/DescriptionList.stories.tsx @@ -7,7 +7,7 @@ import { type Meta, type StoryObj } from '@storybook/react'; import { MemoryRouter } from 'react-router-dom'; import { DescriptionList, DescriptionItem, type DescriptionListProps } from '../DescriptionList'; -import { Link } from '~/ui/Link'; +import { Link } from '~/components/ui'; export default { component: DescriptionList, diff --git a/apps/explorer/src/ui/stories/DisclosureBox.stories.tsx b/apps/explorer/src/components/ui/stories/DisclosureBox.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/DisclosureBox.stories.tsx rename to apps/explorer/src/components/ui/stories/DisclosureBox.stories.tsx diff --git a/apps/explorer/src/ui/stories/Divider.stories.tsx b/apps/explorer/src/components/ui/stories/Divider.stories.tsx similarity index 90% rename from apps/explorer/src/ui/stories/Divider.stories.tsx rename to apps/explorer/src/components/ui/stories/Divider.stories.tsx index 70fd13d3e46..7ea335fa8ba 100644 --- a/apps/explorer/src/ui/stories/Divider.stories.tsx +++ b/apps/explorer/src/components/ui/stories/Divider.stories.tsx @@ -2,7 +2,7 @@ // Modifications Copyright (c) 2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import { Divider, type DividerProps } from '~/ui/Divider'; +import { Divider, type DividerProps } from '~/components/ui'; import type { Meta, StoryObj } from '@storybook/react'; diff --git a/apps/explorer/src/ui/stories/DropdownMenu.stories.tsx b/apps/explorer/src/components/ui/stories/DropdownMenu.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/DropdownMenu.stories.tsx rename to apps/explorer/src/components/ui/stories/DropdownMenu.stories.tsx diff --git a/apps/explorer/src/ui/stories/ExpandableList.stories.tsx b/apps/explorer/src/components/ui/stories/ExpandableList.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/ExpandableList.stories.tsx rename to apps/explorer/src/components/ui/stories/ExpandableList.stories.tsx diff --git a/apps/explorer/src/ui/stories/FilterList.stories.tsx b/apps/explorer/src/components/ui/stories/FilterList.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/FilterList.stories.tsx rename to apps/explorer/src/components/ui/stories/FilterList.stories.tsx diff --git a/apps/explorer/src/ui/stories/Image.stories.tsx b/apps/explorer/src/components/ui/stories/Image.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/Image.stories.tsx rename to apps/explorer/src/components/ui/stories/Image.stories.tsx diff --git a/apps/explorer/src/ui/stories/ImageIcon.stories.tsx b/apps/explorer/src/components/ui/stories/ImageIcon.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/ImageIcon.stories.tsx rename to apps/explorer/src/components/ui/stories/ImageIcon.stories.tsx diff --git a/apps/explorer/src/ui/stories/Input.stories.tsx b/apps/explorer/src/components/ui/stories/Input.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/Input.stories.tsx rename to apps/explorer/src/components/ui/stories/Input.stories.tsx diff --git a/apps/explorer/src/ui/stories/Link.stories.tsx b/apps/explorer/src/components/ui/stories/Link.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/Link.stories.tsx rename to apps/explorer/src/components/ui/stories/Link.stories.tsx diff --git a/apps/explorer/src/ui/stories/ListboxSelect.stories.tsx b/apps/explorer/src/components/ui/stories/ListboxSelect.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/ListboxSelect.stories.tsx rename to apps/explorer/src/components/ui/stories/ListboxSelect.stories.tsx diff --git a/apps/explorer/src/ui/stories/Modal.stories.tsx b/apps/explorer/src/components/ui/stories/Modal.stories.tsx similarity index 99% rename from apps/explorer/src/ui/stories/Modal.stories.tsx rename to apps/explorer/src/components/ui/stories/Modal.stories.tsx index 0d4bb5c0050..f949146e5a5 100644 --- a/apps/explorer/src/ui/stories/Modal.stories.tsx +++ b/apps/explorer/src/components/ui/stories/Modal.stories.tsx @@ -16,7 +16,7 @@ import { ModalContent, ModalHeading, type ModalProps, -} from '../modal'; +} from '../modal/Modal'; import { ObjectModal, type ObjectModalProps } from '../modal/ObjectModal'; export default { diff --git a/apps/explorer/src/ui/stories/ObjectDetails.stories.tsx b/apps/explorer/src/components/ui/stories/ObjectDetails.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/ObjectDetails.stories.tsx rename to apps/explorer/src/components/ui/stories/ObjectDetails.stories.tsx diff --git a/apps/explorer/src/ui/stories/PageHeader.stories.tsx b/apps/explorer/src/components/ui/stories/PageHeader.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/PageHeader.stories.tsx rename to apps/explorer/src/components/ui/stories/PageHeader.stories.tsx diff --git a/apps/explorer/src/ui/stories/Pagination.stories.tsx b/apps/explorer/src/components/ui/stories/Pagination.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/Pagination.stories.tsx rename to apps/explorer/src/components/ui/stories/Pagination.stories.tsx diff --git a/apps/explorer/src/ui/stories/PlaceholderTable.stories.tsx b/apps/explorer/src/components/ui/stories/PlaceholderTable.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/PlaceholderTable.stories.tsx rename to apps/explorer/src/components/ui/stories/PlaceholderTable.stories.tsx diff --git a/apps/explorer/src/ui/stories/PlayPause.stories.tsx b/apps/explorer/src/components/ui/stories/PlayPause.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/PlayPause.stories.tsx rename to apps/explorer/src/components/ui/stories/PlayPause.stories.tsx diff --git a/apps/explorer/src/ui/stories/ProgressBar.stories.tsx b/apps/explorer/src/components/ui/stories/ProgressBar.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/ProgressBar.stories.tsx rename to apps/explorer/src/components/ui/stories/ProgressBar.stories.tsx diff --git a/apps/explorer/src/ui/stories/ProgressCircle.stories.tsx b/apps/explorer/src/components/ui/stories/ProgressCircle.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/ProgressCircle.stories.tsx rename to apps/explorer/src/components/ui/stories/ProgressCircle.stories.tsx diff --git a/apps/explorer/src/ui/stories/RingChart.stories.tsx b/apps/explorer/src/components/ui/stories/RingChart.stories.tsx similarity index 88% rename from apps/explorer/src/ui/stories/RingChart.stories.tsx rename to apps/explorer/src/components/ui/stories/RingChart.stories.tsx index 93cf3453904..17f5dfaceef 100644 --- a/apps/explorer/src/ui/stories/RingChart.stories.tsx +++ b/apps/explorer/src/components/ui/stories/RingChart.stories.tsx @@ -4,7 +4,7 @@ import { type Meta, type StoryObj } from '@storybook/react'; -import { RingChart, type RingChartProps } from '~/ui/RingChart'; +import { RingChart, type RingChartProps } from '~/components/ui'; export default { component: RingChart, diff --git a/apps/explorer/src/ui/stories/Search.stories.tsx b/apps/explorer/src/components/ui/stories/Search.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/Search.stories.tsx rename to apps/explorer/src/components/ui/stories/Search.stories.tsx diff --git a/apps/explorer/src/ui/stories/SplitPanes.stories.tsx b/apps/explorer/src/components/ui/stories/SplitPanes.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/SplitPanes.stories.tsx rename to apps/explorer/src/components/ui/stories/SplitPanes.stories.tsx diff --git a/apps/explorer/src/ui/stories/Stats.stories.tsx b/apps/explorer/src/components/ui/stories/Stats.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/Stats.stories.tsx rename to apps/explorer/src/components/ui/stories/Stats.stories.tsx diff --git a/apps/explorer/src/ui/stories/TableCard.stories.tsx b/apps/explorer/src/components/ui/stories/TableCard.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/TableCard.stories.tsx rename to apps/explorer/src/components/ui/stories/TableCard.stories.tsx diff --git a/apps/explorer/src/ui/stories/TableHeader.stories.tsx b/apps/explorer/src/components/ui/stories/TableHeader.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/TableHeader.stories.tsx rename to apps/explorer/src/components/ui/stories/TableHeader.stories.tsx diff --git a/apps/explorer/src/ui/stories/Tabs.stories.tsx b/apps/explorer/src/components/ui/stories/Tabs.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/Tabs.stories.tsx rename to apps/explorer/src/components/ui/stories/Tabs.stories.tsx diff --git a/apps/explorer/src/ui/stories/Tooltip.stories.tsx b/apps/explorer/src/components/ui/stories/Tooltip.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/Tooltip.stories.tsx rename to apps/explorer/src/components/ui/stories/Tooltip.stories.tsx diff --git a/apps/explorer/src/ui/stories/VerticalList.stories.tsx b/apps/explorer/src/components/ui/stories/VerticalList.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/VerticalList.stories.tsx rename to apps/explorer/src/components/ui/stories/VerticalList.stories.tsx diff --git a/apps/explorer/src/ui/stories/header/NavItem.stories.tsx b/apps/explorer/src/components/ui/stories/header/NavItem.stories.tsx similarity index 100% rename from apps/explorer/src/ui/stories/header/NavItem.stories.tsx rename to apps/explorer/src/components/ui/stories/header/NavItem.stories.tsx diff --git a/apps/explorer/src/ui/stories/header/NetworkSelect.stories.tsx b/apps/explorer/src/components/ui/stories/header/NetworkSelect.stories.tsx similarity index 91% rename from apps/explorer/src/ui/stories/header/NetworkSelect.stories.tsx rename to apps/explorer/src/components/ui/stories/header/NetworkSelect.stories.tsx index 8c4e3ba264e..cab132f3c28 100644 --- a/apps/explorer/src/ui/stories/header/NetworkSelect.stories.tsx +++ b/apps/explorer/src/components/ui/stories/header/NetworkSelect.stories.tsx @@ -5,7 +5,7 @@ import { type Meta, type StoryObj } from '@storybook/react'; import { useState } from 'react'; -import { NetworkSelect, type NetworkSelectProps } from '~/ui/header/NetworkSelect'; +import { NetworkSelect, type NetworkSelectProps } from '~/components/ui'; export default { component: NetworkSelect, diff --git a/apps/explorer/src/components/validator-map/ValidatorLocation.tsx b/apps/explorer/src/components/validator-map/ValidatorLocation.tsx index b8cfaa11c4d..dd02f975c74 100644 --- a/apps/explorer/src/components/validator-map/ValidatorLocation.tsx +++ b/apps/explorer/src/components/validator-map/ValidatorLocation.tsx @@ -4,7 +4,7 @@ import { useCallback } from 'react'; -import { type ValidatorMapValidator } from './types'; +import { type ValidatorMapValidator } from '~/lib/ui/interfaces'; interface ValidatorLocationProps { validator: ValidatorMapValidator; diff --git a/apps/explorer/src/components/validator-map/index.tsx b/apps/explorer/src/components/validator-map/ValidatorMap.tsx similarity index 97% rename from apps/explorer/src/components/validator-map/index.tsx rename to apps/explorer/src/components/validator-map/ValidatorMap.tsx index f6baab76684..1014b2e10fc 100644 --- a/apps/explorer/src/components/validator-map/index.tsx +++ b/apps/explorer/src/components/validator-map/ValidatorMap.tsx @@ -4,17 +4,17 @@ import { useAppsBackend } from '@iota/core'; import { useIotaClientQuery } from '@iota/dapp-kit'; -import { Heading, Text, Placeholder } from '@iota/ui'; +import { Network } from '@iota/iota.js/client'; +import { Heading, Placeholder, Text } from '@iota/ui'; import { useQuery } from '@tanstack/react-query'; import { ParentSize } from '@visx/responsive'; import { TooltipWithBounds, useTooltip } from '@visx/tooltip'; import React, { type ReactNode, useCallback, useMemo } from 'react'; +import { useNetwork } from '~/hooks'; +import { Card } from '~/components/ui'; import { WorldMap } from './WorldMap'; -import { type ValidatorMapResponse, type ValidatorMapValidator } from './types'; -import { useNetwork } from '~/context'; -import { Card } from '~/ui/Card'; -import { Network } from '~/utils/api/defaultRpcClient'; +import { type ValidatorMapResponse, type ValidatorMapValidator } from '~/lib/ui'; type ValidatorsMap = Record; diff --git a/apps/explorer/src/components/validator-map/WorldMap.tsx b/apps/explorer/src/components/validator-map/WorldMap.tsx index 6123c4f56de..c221b4389e8 100644 --- a/apps/explorer/src/components/validator-map/WorldMap.tsx +++ b/apps/explorer/src/components/validator-map/WorldMap.tsx @@ -9,12 +9,12 @@ import * as topojson from 'topojson-client'; import { MapFeature } from './MapFeature'; import { ValidatorLocation } from './ValidatorLocation'; import world from './topology.json'; -import { type Feature, type ValidatorMapValidator } from './types'; +import { type ValidatorMapFeature, type ValidatorMapValidator } from '~/lib/ui'; // @ts-expect-error: The types of `world` here aren't aligned but they are correct const land = topojson.feature(world, world.objects.countries) as unknown as { type: 'FeatureCollection'; - features: Feature[]; + features: ValidatorMapFeature[]; }; // We hide Antarctica because there will not be validators there: diff --git a/apps/explorer/src/components/validator-map/index.ts b/apps/explorer/src/components/validator-map/index.ts new file mode 100644 index 00000000000..83084ef3742 --- /dev/null +++ b/apps/explorer/src/components/validator-map/index.ts @@ -0,0 +1,7 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './MapFeature'; +export * from './ValidatorLocation'; +export * from './ValidatorMap'; +export * from './WorldMap'; diff --git a/apps/explorer/src/components/validator/ValidatorMeta.tsx b/apps/explorer/src/components/validator/ValidatorMeta.tsx index c8040aad76c..2061052cef1 100644 --- a/apps/explorer/src/components/validator/ValidatorMeta.tsx +++ b/apps/explorer/src/components/validator/ValidatorMeta.tsx @@ -6,10 +6,13 @@ import { ArrowUpRight12 } from '@iota/icons'; import { type IotaValidatorSummary } from '@iota/iota.js/client'; import { Heading, Text } from '@iota/ui'; -import { CopyToClipboard } from '~/ui/CopyToClipboard'; -import { DescriptionList, DescriptionItem } from '~/ui/DescriptionList'; -import { ImageIcon } from '~/ui/ImageIcon'; -import { AddressLink } from '~/ui/InternalLink'; +import { + AddressLink, + CopyToClipboard, + DescriptionItem, + DescriptionList, + ImageIcon, +} from '~/components/ui'; type ValidatorMetaProps = { validatorData: IotaValidatorSummary; diff --git a/apps/explorer/src/components/validator/ValidatorStats.tsx b/apps/explorer/src/components/validator/ValidatorStats.tsx index 1b8fd429235..58988229cde 100644 --- a/apps/explorer/src/components/validator/ValidatorStats.tsx +++ b/apps/explorer/src/components/validator/ValidatorStats.tsx @@ -5,9 +5,8 @@ import { type IotaValidatorSummary } from '@iota/iota.js/client'; import { Heading } from '@iota/ui'; +import { Card, Stats } from '~/components/ui'; import { DelegationAmount } from './DelegationAmount'; -import { Card } from '~/ui/Card'; -import { Stats } from '~/ui/Stats'; type StatsCardProps = { validatorData: IotaValidatorSummary; diff --git a/apps/explorer/src/components/validator/index.ts b/apps/explorer/src/components/validator/index.ts new file mode 100644 index 00000000000..1a572359043 --- /dev/null +++ b/apps/explorer/src/components/validator/index.ts @@ -0,0 +1,6 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './DelegationAmount'; +export * from './ValidatorMeta'; +export * from './ValidatorStats'; diff --git a/apps/explorer/src/contexts/index.ts b/apps/explorer/src/contexts/index.ts new file mode 100644 index 00000000000..ecbff639b22 --- /dev/null +++ b/apps/explorer/src/contexts/index.ts @@ -0,0 +1,4 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './networkContext'; diff --git a/apps/explorer/src/contexts/networkContext.ts b/apps/explorer/src/contexts/networkContext.ts new file mode 100644 index 00000000000..71ab798fdb7 --- /dev/null +++ b/apps/explorer/src/contexts/networkContext.ts @@ -0,0 +1,14 @@ +// Copyright (c) Mysten Labs, Inc. +// Modifications Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import { createContext, useContext } from 'react'; +import { type Network } from '@iota/iota.js/client'; + +export const NetworkContext = createContext< + [Network | string, (network: Network | string) => void] +>(['', () => null]); + +export function useNetworkContext(): [Network | string, (network: Network | string) => void] { + return useContext(NetworkContext); +} diff --git a/apps/explorer/src/hooks/index.ts b/apps/explorer/src/hooks/index.ts new file mode 100644 index 00000000000..9fbe82e3302 --- /dev/null +++ b/apps/explorer/src/hooks/index.ts @@ -0,0 +1,23 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './useBreakpoint'; +export * from './useDebouncedValue'; +export * from './useEnhancedRpc'; +export * from './useFunctionParamsDetails'; +export * from './useFunctionTypeArguments'; +export * from './useGetAddressMetrics'; +export * from './useGetAllEpochAddressMetrics'; +export * from './useGetCheckpoints'; +export * from './useGetNetworkMetrics'; +export * from './useGetTransactionBlocks'; +export * from './useImage'; +export * from './useImageMod'; +export * from './useInitialPageView'; +export * from './useMediaQuery'; +export * from './useNetwork'; +export * from './useNormalizedMoveModule'; +export * from './useRecognizedPackages'; +export * from './useResolveVideo'; +export * from './useSearch'; +export * from './useVerifiedSourceCode'; diff --git a/apps/explorer/src/hooks/useEnhancedRpc.ts b/apps/explorer/src/hooks/useEnhancedRpc.ts index 5349458da11..7ec2321ab6b 100644 --- a/apps/explorer/src/hooks/useEnhancedRpc.ts +++ b/apps/explorer/src/hooks/useEnhancedRpc.ts @@ -2,11 +2,10 @@ // Modifications Copyright (c) 2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 import { useIotaClient } from '@iota/dapp-kit'; -import { IotaClient } from '@iota/iota.js/client'; +import { IotaClient, Network } from '@iota/iota.js/client'; import { useMemo } from 'react'; -import { useNetwork } from '~/context'; -import { Network } from '~/utils/api/defaultRpcClient'; +import { useNetwork } from '~/hooks'; // TODO: Use enhanced RPC locally by default export function useEnhancedRpcClient(): IotaClient { diff --git a/apps/explorer/src/components/module/module-functions-interaction/useFunctionParamsDetails.ts b/apps/explorer/src/hooks/useFunctionParamsDetails.ts similarity index 91% rename from apps/explorer/src/components/module/module-functions-interaction/useFunctionParamsDetails.ts rename to apps/explorer/src/hooks/useFunctionParamsDetails.ts index de7e42ae038..fc65866d8cf 100644 --- a/apps/explorer/src/components/module/module-functions-interaction/useFunctionParamsDetails.ts +++ b/apps/explorer/src/hooks/useFunctionParamsDetails.ts @@ -4,7 +4,7 @@ import { useMemo } from 'react'; -import { getNormalizedFunctionParameterTypeDetails } from '../utils'; +import { getNormalizedFunctionParameterTypeDetails } from '~/lib/utils'; import type { IotaMoveNormalizedType } from '@iota/iota.js/client'; diff --git a/apps/explorer/src/components/module/module-functions-interaction/useFunctionTypeArguments.ts b/apps/explorer/src/hooks/useFunctionTypeArguments.ts similarity index 100% rename from apps/explorer/src/components/module/module-functions-interaction/useFunctionTypeArguments.ts rename to apps/explorer/src/hooks/useFunctionTypeArguments.ts diff --git a/apps/explorer/src/hooks/useInitialPageView.ts b/apps/explorer/src/hooks/useInitialPageView.ts index 5266d4810e5..0471b2b04fa 100644 --- a/apps/explorer/src/hooks/useInitialPageView.ts +++ b/apps/explorer/src/hooks/useInitialPageView.ts @@ -5,7 +5,7 @@ import { useEffect } from 'react'; import { useLocation } from 'react-router-dom'; -import { ampli } from '~/utils/analytics/ampli'; +import { ampli } from '~/lib/utils'; export function useInitialPageView(activeNetwork: string): void { const location = useLocation(); diff --git a/apps/explorer/src/context.ts b/apps/explorer/src/hooks/useNetwork.ts similarity index 66% rename from apps/explorer/src/context.ts rename to apps/explorer/src/hooks/useNetwork.ts index afd47ef19ad..216fdcd269c 100644 --- a/apps/explorer/src/context.ts +++ b/apps/explorer/src/hooks/useNetwork.ts @@ -1,24 +1,13 @@ -// Copyright (c) Mysten Labs, Inc. -// Modifications Copyright (c) 2024 IOTA Stiftung +// Copyright (c) 2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import * as Sentry from '@sentry/react'; -import { createContext, useContext, useLayoutEffect, useMemo } from 'react'; +import { getDefaultNetwork, Network } from '@iota/iota.js/client'; +import { useLayoutEffect, useMemo } from 'react'; // eslint-disable-next-line no-restricted-imports import { useSearchParams } from 'react-router-dom'; - -import { Network } from './utils/api/defaultRpcClient'; -import { growthbook } from './utils/growthbook'; -import { queryClient } from './utils/queryClient'; -import { getDefaultNetwork } from '@iota/iota.js/client'; - -export const NetworkContext = createContext< - [Network | string, (network: Network | string) => void] ->(['', () => null]); - -export function useNetworkContext(): [Network | string, (network: Network | string) => void] { - return useContext(NetworkContext); -} +import { growthbook } from '~/lib/utils/growthbook'; +import { queryClient } from '~/lib/utils/queryClient'; +import * as Sentry from '@sentry/react'; export function useNetwork(): [string, (network: Network | string) => void] { const [searchParams, setSearchParams] = useSearchParams(); diff --git a/apps/explorer/src/hooks/useRecognizedPackages.ts b/apps/explorer/src/hooks/useRecognizedPackages.ts index 5fa36bba2fb..88d31017fa7 100644 --- a/apps/explorer/src/hooks/useRecognizedPackages.ts +++ b/apps/explorer/src/hooks/useRecognizedPackages.ts @@ -4,9 +4,9 @@ import { useFeatureValue } from '@growthbook/growthbook-react'; import { IOTA_FRAMEWORK_ADDRESS, IOTA_SYSTEM_ADDRESS } from '@iota/iota.js/utils'; +import { Network } from '@iota/iota.js/client'; -import { useNetwork } from '~/context'; -import { Network } from '~/utils/api/defaultRpcClient'; +import { useNetwork } from './'; const DEFAULT_RECOGNIZED_PACKAGES = [IOTA_FRAMEWORK_ADDRESS, IOTA_SYSTEM_ADDRESS]; diff --git a/apps/explorer/src/hooks/useVerifiedSourceCode.ts b/apps/explorer/src/hooks/useVerifiedSourceCode.ts index 7c36e40ac02..72aa9cea9b5 100644 --- a/apps/explorer/src/hooks/useVerifiedSourceCode.ts +++ b/apps/explorer/src/hooks/useVerifiedSourceCode.ts @@ -4,7 +4,7 @@ import { useFeatureIsOn } from '@growthbook/growthbook-react'; import { useIotaClientContext } from '@iota/dapp-kit'; -import { Network } from '~/utils/api/defaultRpcClient'; +import { Network } from '@iota/iota.js/client'; import { type UseQueryResult, useQuery } from '@tanstack/react-query'; type UseVerifiedSourceCodeArgs = { diff --git a/apps/explorer/src/index.tsx b/apps/explorer/src/index.tsx index c18abd97c01..670a7e6ad93 100644 --- a/apps/explorer/src/index.tsx +++ b/apps/explorer/src/index.tsx @@ -10,11 +10,10 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; import { RouterProvider } from 'react-router-dom'; +import { growthbook, initAmplitude, initSentry, queryClient } from './lib/utils'; import { router } from './pages'; -import { initAmplitude } from './utils/analytics/amplitude'; -import { growthbook } from './utils/growthbook'; -import { queryClient } from './utils/queryClient'; -import './utils/sentry'; + +initSentry(); import '@iota/dapp-kit/dist/index.css'; import './index.css'; diff --git a/apps/explorer/src/lib/constants/index.ts b/apps/explorer/src/lib/constants/index.ts index 87548a0821e..5c33042b10e 100644 --- a/apps/explorer/src/lib/constants/index.ts +++ b/apps/explorer/src/lib/constants/index.ts @@ -2,3 +2,4 @@ // SPDX-License-Identifier: Apache-2.0 export * from './footer.constants'; +export * from './validator.constants'; diff --git a/apps/explorer/src/utils/validatorConstants.ts b/apps/explorer/src/lib/constants/validator.constants.ts similarity index 100% rename from apps/explorer/src/utils/validatorConstants.ts rename to apps/explorer/src/lib/constants/validator.constants.ts diff --git a/apps/explorer/src/lib/index.ts b/apps/explorer/src/lib/index.ts new file mode 100644 index 00000000000..85dd3303d09 --- /dev/null +++ b/apps/explorer/src/lib/index.ts @@ -0,0 +1,6 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './constants'; +export * from './enums'; +export * from './utils'; diff --git a/apps/explorer/src/lib/ui/index.ts b/apps/explorer/src/lib/ui/index.ts new file mode 100644 index 00000000000..21e9ab8bdfc --- /dev/null +++ b/apps/explorer/src/lib/ui/index.ts @@ -0,0 +1,5 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './interfaces'; +export * from './utils'; diff --git a/apps/explorer/src/lib/ui/interfaces/index.ts b/apps/explorer/src/lib/ui/interfaces/index.ts new file mode 100644 index 00000000000..6f5b1d939cd --- /dev/null +++ b/apps/explorer/src/lib/ui/interfaces/index.ts @@ -0,0 +1,4 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './validatorMap.interfaces'; diff --git a/apps/explorer/src/components/validator-map/types.ts b/apps/explorer/src/lib/ui/interfaces/validatorMap.interfaces.ts similarity index 96% rename from apps/explorer/src/components/validator-map/types.ts rename to apps/explorer/src/lib/ui/interfaces/validatorMap.interfaces.ts index ea7dd04ed1c..9e39bf71a31 100644 --- a/apps/explorer/src/components/validator-map/types.ts +++ b/apps/explorer/src/lib/ui/interfaces/validatorMap.interfaces.ts @@ -2,7 +2,7 @@ // Modifications Copyright (c) 2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -export interface Feature { +export interface ValidatorMapFeature { type: 'Feature'; id: string; geometry: { coordinates: [number, number][][]; type: 'Polygon' }; diff --git a/apps/explorer/src/ui/types.ts b/apps/explorer/src/lib/ui/types/extractProps.types.ts similarity index 100% rename from apps/explorer/src/ui/types.ts rename to apps/explorer/src/lib/ui/types/extractProps.types.ts diff --git a/apps/explorer/src/lib/ui/types/index.ts b/apps/explorer/src/lib/ui/types/index.ts new file mode 100644 index 00000000000..32d19e632e9 --- /dev/null +++ b/apps/explorer/src/lib/ui/types/index.ts @@ -0,0 +1,4 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './extractProps.types'; diff --git a/apps/explorer/src/components/checkpoints/utils.tsx b/apps/explorer/src/lib/ui/utils/generateTableDataFromCheckpointsData.tsx similarity index 90% rename from apps/explorer/src/components/checkpoints/utils.tsx rename to apps/explorer/src/lib/ui/utils/generateTableDataFromCheckpointsData.tsx index 539fc5bd511..e3ffdefedf7 100644 --- a/apps/explorer/src/components/checkpoints/utils.tsx +++ b/apps/explorer/src/lib/ui/utils/generateTableDataFromCheckpointsData.tsx @@ -5,10 +5,9 @@ import { type CheckpointPage } from '@iota/iota.js/client'; import { Text } from '@iota/ui'; -import { TxTimeType } from '../tx-time/TxTimeType'; -import { HighlightedTableCol } from '~/components/table/HighlightedTableCol'; -import { CheckpointLink, CheckpointSequenceLink } from '~/ui/InternalLink'; import { type ReactNode } from 'react'; +import { HighlightedTableCol, TxTimeType } from '~/components'; +import { CheckpointLink, CheckpointSequenceLink } from '~/components/ui'; interface CheckpointData { digest: ReactNode; diff --git a/apps/explorer/src/components/activity/utils.tsx b/apps/explorer/src/lib/ui/utils/generateTableDataFromEpochsData.tsx similarity index 89% rename from apps/explorer/src/components/activity/utils.tsx rename to apps/explorer/src/lib/ui/utils/generateTableDataFromEpochsData.tsx index 2db5875c88b..667cc436d5b 100644 --- a/apps/explorer/src/components/activity/utils.tsx +++ b/apps/explorer/src/lib/ui/utils/generateTableDataFromEpochsData.tsx @@ -5,11 +5,9 @@ import { type EpochMetricsPage } from '@iota/iota.js/client'; import { Text } from '@iota/ui'; -import { IotaAmount } from '../table/IotaAmount'; -import { TxTimeType } from '../tx-time/TxTimeType'; -import { HighlightedTableCol } from '~/components/table/HighlightedTableCol'; -import { CheckpointSequenceLink, EpochLink } from '~/ui/InternalLink'; -import { getEpochStorageFundFlow } from '~/utils/getStorageFundFlow'; +import { IotaAmount, TxTimeType, HighlightedTableCol } from '~/components'; +import { CheckpointSequenceLink, EpochLink } from '~/components/ui'; +import { getEpochStorageFundFlow } from '~/lib/utils'; import { type ReactNode } from 'react'; interface EpochData { diff --git a/apps/explorer/src/lib/ui/utils/index.ts b/apps/explorer/src/lib/ui/utils/index.ts new file mode 100644 index 00000000000..9c93389b7d4 --- /dev/null +++ b/apps/explorer/src/lib/ui/utils/index.ts @@ -0,0 +1,6 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './generateTableDataFromCheckpointsData'; +export * from './generateTableDataFromEpochsData'; +export * from './objectField'; diff --git a/apps/explorer/src/components/object/utils.ts b/apps/explorer/src/lib/ui/utils/objectField.ts similarity index 100% rename from apps/explorer/src/components/object/utils.ts rename to apps/explorer/src/lib/ui/utils/objectField.ts diff --git a/apps/explorer/src/utils/analytics/ampli/index.ts b/apps/explorer/src/lib/utils/analytics/ampli/index.ts similarity index 100% rename from apps/explorer/src/utils/analytics/ampli/index.ts rename to apps/explorer/src/lib/utils/analytics/ampli/index.ts diff --git a/apps/explorer/src/utils/analytics/amplitude.ts b/apps/explorer/src/lib/utils/analytics/amplitude.ts similarity index 100% rename from apps/explorer/src/utils/analytics/amplitude.ts rename to apps/explorer/src/lib/utils/analytics/amplitude.ts diff --git a/apps/explorer/src/lib/utils/analytics/index.ts b/apps/explorer/src/lib/utils/analytics/index.ts new file mode 100644 index 00000000000..df4936717e0 --- /dev/null +++ b/apps/explorer/src/lib/utils/analytics/index.ts @@ -0,0 +1,6 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './ampli'; + +export * from './amplitude'; diff --git a/apps/explorer/src/utils/api/defaultRpcClient.ts b/apps/explorer/src/lib/utils/api/defaultRpcClient.ts similarity index 96% rename from apps/explorer/src/utils/api/defaultRpcClient.ts rename to apps/explorer/src/lib/utils/api/defaultRpcClient.ts index ad745e03acb..83678cee750 100644 --- a/apps/explorer/src/utils/api/defaultRpcClient.ts +++ b/apps/explorer/src/lib/utils/api/defaultRpcClient.ts @@ -12,8 +12,6 @@ import { getAllNetworks, } from '@iota/iota.js/client'; -export { Network } from '@iota/iota.js/client'; - export const SupportedNetworks = getAllNetworks(); // The Explorer always shows the Custom RPC input so there is no need to confuse it more by having a Custom Network here delete SupportedNetworks[Network.Custom]; diff --git a/apps/explorer/src/lib/utils/api/index.ts b/apps/explorer/src/lib/utils/api/index.ts new file mode 100644 index 00000000000..da472c960ce --- /dev/null +++ b/apps/explorer/src/lib/utils/api/index.ts @@ -0,0 +1,4 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './defaultRpcClient'; diff --git a/apps/explorer/src/utils/getStorageFundFlow.ts b/apps/explorer/src/lib/utils/getStorageFundFlow.ts similarity index 100% rename from apps/explorer/src/utils/getStorageFundFlow.ts rename to apps/explorer/src/lib/utils/getStorageFundFlow.ts diff --git a/apps/explorer/src/utils/getValidatorMoveEvent.ts b/apps/explorer/src/lib/utils/getValidatorMoveEvent.ts similarity index 100% rename from apps/explorer/src/utils/getValidatorMoveEvent.ts rename to apps/explorer/src/lib/utils/getValidatorMoveEvent.ts diff --git a/apps/explorer/src/utils/growthbook.ts b/apps/explorer/src/lib/utils/growthbook.ts similarity index 100% rename from apps/explorer/src/utils/growthbook.ts rename to apps/explorer/src/lib/utils/growthbook.ts diff --git a/apps/explorer/src/lib/utils/index.ts b/apps/explorer/src/lib/utils/index.ts new file mode 100644 index 00000000000..3e76f856e81 --- /dev/null +++ b/apps/explorer/src/lib/utils/index.ts @@ -0,0 +1,15 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from './analytics'; +export * from './api'; + +export * from './getStorageFundFlow'; +export * from './getValidatorMoveEvent'; +export * from './growthbook'; +export * from './numberUtils'; +export * from './objectUtils'; +export * from './queryClient'; +export * from './sentry'; +export * from './stringUtils'; +export * from './iotaMoveTypeConverters'; diff --git a/apps/explorer/src/components/module/utils.ts b/apps/explorer/src/lib/utils/iotaMoveTypeConverters.ts similarity index 100% rename from apps/explorer/src/components/module/utils.ts rename to apps/explorer/src/lib/utils/iotaMoveTypeConverters.ts diff --git a/apps/explorer/src/utils/numberUtil.ts b/apps/explorer/src/lib/utils/numberUtils.ts similarity index 100% rename from apps/explorer/src/utils/numberUtil.ts rename to apps/explorer/src/lib/utils/numberUtils.ts diff --git a/apps/explorer/src/utils/objectUtils.ts b/apps/explorer/src/lib/utils/objectUtils.ts similarity index 100% rename from apps/explorer/src/utils/objectUtils.ts rename to apps/explorer/src/lib/utils/objectUtils.ts diff --git a/apps/explorer/src/utils/queryClient.ts b/apps/explorer/src/lib/utils/queryClient.ts similarity index 100% rename from apps/explorer/src/utils/queryClient.ts rename to apps/explorer/src/lib/utils/queryClient.ts diff --git a/apps/explorer/src/lib/utils/sentry.ts b/apps/explorer/src/lib/utils/sentry.ts new file mode 100644 index 00000000000..d12773041aa --- /dev/null +++ b/apps/explorer/src/lib/utils/sentry.ts @@ -0,0 +1,61 @@ +// Copyright (c) Mysten Labs, Inc. +// Modifications Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import * as Sentry from '@sentry/react'; +import { useEffect } from 'react'; +import { + createRoutesFromChildren, + matchRoutes, + useLocation, + useNavigationType, +} from 'react-router-dom'; + +const SENTRY_ENABLED = import.meta.env.PROD; +const SENTRY_SAMPLE_RATE = import.meta.env.VITE_SENTRY_SAMPLE_RATE + ? parseFloat(import.meta.env.VITE_SENTRY_SAMPLE_RATE) + : 1; + +export function initSentry() { + Sentry.init({ + enabled: SENTRY_ENABLED, + dsn: import.meta.env.PROD + ? import.meta.env.VITE_PROD_SENTRY_DSN + : import.meta.env.VITE_DEV_SENTRY_DSN, + environment: import.meta.env.VITE_VERCEL_ENV, + integrations: [ + new Sentry.BrowserTracing({ + routingInstrumentation: Sentry.reactRouterV6Instrumentation( + useEffect, + useLocation, + useNavigationType, + createRoutesFromChildren, + matchRoutes, + ), + }), + ], + tracesSampleRate: SENTRY_SAMPLE_RATE, + beforeSend(event) { + try { + // Filter out any code from unknown sources: + if ( + !event.exception?.values?.[0].stacktrace || + event.exception?.values?.[0].stacktrace?.frames?.[0].filename === '' + ) { + return null; + } + // eslint-disable-next-line no-empty + } catch (e) {} + + return event; + }, + + denyUrls: [ + // Chrome extensions + /extensions\//i, + /^chrome(?:-extension)?:\/\//i, + //, + ], + allowUrls: [/.*\.iota\.io/i, /.*-mysten-labs\.vercel\.app/i, 'explorer-topaz.vercel.app'], + }); +} diff --git a/apps/explorer/src/utils/stringUtils.ts b/apps/explorer/src/lib/utils/stringUtils.ts similarity index 100% rename from apps/explorer/src/utils/stringUtils.ts rename to apps/explorer/src/lib/utils/stringUtils.ts diff --git a/apps/explorer/src/pages/address-result/AddressResult.tsx b/apps/explorer/src/pages/address-result/AddressResult.tsx index 717b0ae328a..90f5dc8061b 100644 --- a/apps/explorer/src/pages/address-result/AddressResult.tsx +++ b/apps/explorer/src/pages/address-result/AddressResult.tsx @@ -7,18 +7,17 @@ import { Domain32 } from '@iota/icons'; import { LoadingIndicator } from '@iota/ui'; import { useParams } from 'react-router-dom'; -import { PageLayout } from '~/components/layout/PageLayout'; -import { OwnedCoins } from '~/components/owned-coins'; -import { OwnedObjects } from '~/components/owned-objects'; -import { ErrorBoundary } from '~/components/error-boundary/ErrorBoundary'; -import { TransactionsForAddress } from '~/components/transactions/TransactionsForAddress'; +import { + ErrorBoundary, + OwnedCoins, + OwnedObjects, + PageLayout, + TransactionsForAddress, +} from '~/components'; +import { Divider, PageHeader, SplitPanes, TabHeader, TabsList, TabsTrigger } from '~/components/ui'; import { useBreakpoint } from '~/hooks/useBreakpoint'; -import { Divider } from '~/ui/Divider'; -import { PageHeader } from '~/ui/PageHeader'; -import { SplitPanes } from '~/ui/SplitPanes'; -import { TabHeader, TabsList, TabsTrigger } from '~/ui/Tabs'; -import { TotalStaked } from './TotalStaked'; import { LocalStorageSplitPaneKey } from '~/lib/enums'; +import { TotalStaked } from './TotalStaked'; interface AddressResultPageHeaderProps { address: string; diff --git a/apps/explorer/src/pages/checkpoints/CheckpointDetail.tsx b/apps/explorer/src/pages/checkpoints/CheckpointDetail.tsx index 6bdbe826050..0313e5281eb 100644 --- a/apps/explorer/src/pages/checkpoints/CheckpointDetail.tsx +++ b/apps/explorer/src/pages/checkpoints/CheckpointDetail.tsx @@ -3,18 +3,24 @@ // SPDX-License-Identifier: Apache-2.0 import { useIotaClient } from '@iota/dapp-kit'; -import { Text, LoadingIndicator } from '@iota/ui'; +import { LoadingIndicator, Text } from '@iota/ui'; import { useQuery } from '@tanstack/react-query'; import { useParams } from 'react-router-dom'; +import { IotaAmount, PageLayout } from '~/components'; +import { + Banner, + DescriptionItem, + DescriptionList, + EpochLink, + PageHeader, + TabHeader, + Tabs, + TabsContent, + TabsList, + TabsTrigger, +} from '~/components/ui'; import { CheckpointTransactionBlocks } from './CheckpointTransactionBlocks'; -import { PageLayout } from '~/components/layout/PageLayout'; -import { IotaAmount } from '~/components/table/IotaAmount'; -import { Banner } from '~/ui/Banner'; -import { DescriptionList, DescriptionItem } from '~/ui/DescriptionList'; -import { EpochLink } from '~/ui/InternalLink'; -import { PageHeader } from '~/ui/PageHeader'; -import { TabHeader, Tabs, TabsContent, TabsList, TabsTrigger } from '~/ui/Tabs'; export default function CheckpointDetail(): JSX.Element { const { id } = useParams<{ id: string }>(); diff --git a/apps/explorer/src/pages/checkpoints/CheckpointTransactionBlocks.tsx b/apps/explorer/src/pages/checkpoints/CheckpointTransactionBlocks.tsx index 7e5985d447c..c92f90ca881 100644 --- a/apps/explorer/src/pages/checkpoints/CheckpointTransactionBlocks.tsx +++ b/apps/explorer/src/pages/checkpoints/CheckpointTransactionBlocks.tsx @@ -4,14 +4,12 @@ import { useState } from 'react'; -import { genTableDataFromTxData } from '~/components/transactions/TxCardUtils'; +import { genTableDataFromTxData } from '~/components'; +import { Pagination, PlaceholderTable, TableCard, useCursorPagination } from '~/components/ui'; import { DEFAULT_TRANSACTIONS_LIMIT, useGetTransactionBlocks, } from '~/hooks/useGetTransactionBlocks'; -import { Pagination, useCursorPagination } from '~/ui/Pagination'; -import { PlaceholderTable } from '~/ui/PlaceholderTable'; -import { TableCard } from '~/ui/TableCard'; export function CheckpointTransactionBlocks({ id }: { id: string }): JSX.Element { const [limit, setLimit] = useState(DEFAULT_TRANSACTIONS_LIMIT); diff --git a/apps/explorer/src/pages/epochs/EpochDetail.tsx b/apps/explorer/src/pages/epochs/EpochDetail.tsx index efa10daafaf..21a94b581ea 100644 --- a/apps/explorer/src/pages/epochs/EpochDetail.tsx +++ b/apps/explorer/src/pages/epochs/EpochDetail.tsx @@ -10,18 +10,23 @@ import { useQuery } from '@tanstack/react-query'; import { useMemo } from 'react'; import { useParams } from 'react-router-dom'; +import { CheckpointsTable, PageLayout } from '~/components'; +import { + Banner, + Stats, + TableCard, + Tabs, + TabsContent, + TabsList, + TabsTrigger, + type StatsProps, +} from '~/components/ui'; +import { useEnhancedRpcClient } from '~/hooks/useEnhancedRpc'; +import { getEpochStorageFundFlow } from '~/lib/utils'; +import { validatorsTableData } from '../validators/Validators'; import { EpochProgress } from './stats/EpochProgress'; import { EpochStats } from './stats/EpochStats'; import { ValidatorStatus } from './stats/ValidatorStatus'; -import { validatorsTableData } from '../validators/Validators'; -import { PageLayout } from '~/components/layout/PageLayout'; -import { CheckpointsTable } from '~/components/checkpoints/CheckpointsTable'; -import { useEnhancedRpcClient } from '~/hooks/useEnhancedRpc'; -import { Banner } from '~/ui/Banner'; -import { Stats, type StatsProps } from '~/ui/Stats'; -import { TableCard } from '~/ui/TableCard'; -import { Tabs, TabsContent, TabsList, TabsTrigger } from '~/ui/Tabs'; -import { getEpochStorageFundFlow } from '~/utils/getStorageFundFlow'; function IotaStats({ amount, diff --git a/apps/explorer/src/pages/epochs/EpochTimer.tsx b/apps/explorer/src/pages/epochs/EpochTimer.tsx index 695c29806c7..fe08dbfccee 100644 --- a/apps/explorer/src/pages/epochs/EpochTimer.tsx +++ b/apps/explorer/src/pages/epochs/EpochTimer.tsx @@ -5,7 +5,7 @@ import { Text } from '@iota/ui'; import { useEpochProgress } from '~/pages/epochs/utils'; -import { ProgressCircle } from '~/ui/ProgressCircle'; +import { ProgressCircle } from '~/components/ui'; export function EpochTimer(): JSX.Element | null { const { epoch, progress, label } = useEpochProgress(); diff --git a/apps/explorer/src/pages/epochs/stats/EpochProgress.tsx b/apps/explorer/src/pages/epochs/stats/EpochProgress.tsx index 3b4ab972323..c6c4cab02a9 100644 --- a/apps/explorer/src/pages/epochs/stats/EpochProgress.tsx +++ b/apps/explorer/src/pages/epochs/stats/EpochProgress.tsx @@ -6,9 +6,8 @@ import { formatDate } from '@iota/core'; import { Heading, Text } from '@iota/ui'; import clsx from 'clsx'; +import { Card, ProgressBar } from '~/components/ui'; import { getElapsedTime, useEpochProgress } from '~/pages/epochs/utils'; -import { Card } from '~/ui/Card'; -import { ProgressBar } from '~/ui/ProgressBar'; interface EpochProgressProps { epoch?: string; diff --git a/apps/explorer/src/pages/epochs/stats/EpochStats.tsx b/apps/explorer/src/pages/epochs/stats/EpochStats.tsx index 862640930f0..625503835c3 100644 --- a/apps/explorer/src/pages/epochs/stats/EpochStats.tsx +++ b/apps/explorer/src/pages/epochs/stats/EpochStats.tsx @@ -5,7 +5,7 @@ import { Heading } from '@iota/ui'; import { type ReactNode } from 'react'; -import { Card } from '~/ui/Card'; +import { Card } from '~/components/ui'; interface EpochStatsProps { label: string; diff --git a/apps/explorer/src/pages/epochs/stats/ValidatorStatus.tsx b/apps/explorer/src/pages/epochs/stats/ValidatorStatus.tsx index 08dde6751ae..9a98d3749f6 100644 --- a/apps/explorer/src/pages/epochs/stats/ValidatorStatus.tsx +++ b/apps/explorer/src/pages/epochs/stats/ValidatorStatus.tsx @@ -7,8 +7,7 @@ import { useIotaClientQuery } from '@iota/dapp-kit'; import { Heading, Text } from '@iota/ui'; import { useMemo } from 'react'; -import { Card } from '~/ui/Card'; -import { RingChart, RingChartLegend } from '~/ui/RingChart'; +import { Card, RingChart, RingChartLegend } from '~/components/ui'; export function ValidatorStatus(): JSX.Element | null { const { data } = useIotaClientQuery('getLatestIotaSystemState'); diff --git a/apps/explorer/src/pages/home/Home.tsx b/apps/explorer/src/pages/home/Home.tsx index b88ec8f6c30..ac6b4cee70a 100644 --- a/apps/explorer/src/pages/home/Home.tsx +++ b/apps/explorer/src/pages/home/Home.tsx @@ -5,21 +5,23 @@ import clsx from 'clsx'; import { lazy, Suspense } from 'react'; -import { AccountsCardGraph } from '~/components/AccountCardGraph'; -import { Activity } from '~/components/activity'; -import { CurrentEpoch, OnTheNetwork } from '~/components/home-metrics'; -import { PageLayout } from '~/components/layout/PageLayout'; -import { IotaTokenCard } from '~/components/IotaTokenCard'; -import { TransactionsCardGraph } from '~/components/TransactionsCardGraph'; -import { ErrorBoundary } from '~/components/error-boundary/ErrorBoundary'; -import { TopPackagesCard } from '~/components/top-packages/TopPackagesCard'; -import { TopValidatorsCard } from '~/components/top-validators-card/TopValidatorsCard'; -import { useNetwork } from '~/context'; -import { Card } from '~/ui/Card'; -import { TabHeader } from '~/ui/Tabs'; -import { Network } from '~/utils/api/defaultRpcClient'; +import { Network } from '@iota/iota.js/client'; +import { + AccountsCardGraph, + Activity, + CurrentEpoch, + ErrorBoundary, + IotaTokenCard, + OnTheNetwork, + PageLayout, + TopPackagesCard, + TopValidatorsCard, + TransactionsCardGraph, +} from '~/components'; +import { Card, TabHeader } from '~/components/ui'; +import { useNetwork } from '~/hooks'; -const ValidatorMap = lazy(() => import('../../components/validator-map')); +const ValidatorMap = lazy(() => import('../../components/validator-map/ValidatorMap')); const TRANSACTIONS_LIMIT = 25; diff --git a/apps/explorer/src/pages/id-page/PageContent.tsx b/apps/explorer/src/pages/id-page/PageContent.tsx index f61f4bb8092..0a56c4a7462 100644 --- a/apps/explorer/src/pages/id-page/PageContent.tsx +++ b/apps/explorer/src/pages/id-page/PageContent.tsx @@ -3,20 +3,19 @@ // SPDX-License-Identifier: Apache-2.0 import { useGetObject } from '@iota/core'; -import { Banner } from '~/ui/Banner'; -import { Divider } from '~/ui/Divider'; -import { FieldsContent } from '~/pages/object-result/views/TokenView'; -import { TabHeader } from '~/ui/Tabs'; -import { ErrorBoundary } from '~/components/error-boundary/ErrorBoundary'; -import { TransactionsForAddressTable } from '~/components/transactions/TransactionsForAddress'; -import TransactionBlocksForAddress from '~/components/transaction-blocks-for-address'; -import { useBreakpoint } from '~/hooks/useBreakpoint'; -import { OwnedCoins } from '~/components/owned-coins'; -import { OwnedObjects } from '~/components/owned-objects'; -import { SplitPanes } from '~/ui/SplitPanes'; import { useIotaClient } from '@iota/dapp-kit'; import { useQuery } from '@tanstack/react-query'; +import { + ErrorBoundary, + OwnedCoins, + OwnedObjects, + TransactionBlocksForAddress, + TransactionsForAddressTable, +} from '~/components'; +import { Banner, Divider, SplitPanes, TabHeader } from '~/components/ui'; +import { useBreakpoint } from '~/hooks/useBreakpoint'; import { LocalStorageSplitPaneKey } from '~/lib/enums'; +import { FieldsContent } from '~/pages/object-result/views/TokenView'; const LEFT_RIGHT_PANEL_MIN_SIZE = 30; diff --git a/apps/explorer/src/pages/id-page/index.tsx b/apps/explorer/src/pages/id-page/index.tsx index 8fa95ab25dd..8d1a5893039 100644 --- a/apps/explorer/src/pages/id-page/index.tsx +++ b/apps/explorer/src/pages/id-page/index.tsx @@ -2,20 +2,19 @@ // Modifications Copyright (c) 2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import { useParams } from 'react-router-dom'; import { isIotaNSName, useGetObject, useResolveIotaNSAddress, useResolveIotaNSName, } from '@iota/core'; -import { PageLayout } from '~/components/layout/PageLayout'; -import { PageHeader } from '~/ui/PageHeader'; import { ObjectDetailsHeader } from '@iota/icons'; +import { useParams } from 'react-router-dom'; +import { ErrorBoundary, PageLayout } from '~/components'; import { TotalStaked } from '~/pages/address-result/TotalStaked'; -import { ErrorBoundary } from '~/components/error-boundary/ErrorBoundary'; -import { ObjectView } from '~/pages/object-result/views/ObjectView'; import { PageContent } from '~/pages/id-page/PageContent'; +import { ObjectView } from '~/pages/object-result/views/ObjectView'; +import { PageHeader } from '~/components/ui'; interface HeaderProps { address: string; diff --git a/apps/explorer/src/pages/index.tsx b/apps/explorer/src/pages/index.tsx index bffe9612502..0a0cca466e7 100644 --- a/apps/explorer/src/pages/index.tsx +++ b/apps/explorer/src/pages/index.tsx @@ -14,7 +14,7 @@ import { Recent } from './recent'; import TransactionResult from './transaction-result/TransactionResult'; import { ValidatorDetails } from './validator/ValidatorDetails'; import { ValidatorPageResult } from './validators/Validators'; -import { Layout } from '~/components/layout'; +import { Layout } from '~/components'; import { IdPage } from '~/pages/id-page'; interface RedirectWithIdProps { diff --git a/apps/explorer/src/pages/object-result/ObjectResult.tsx b/apps/explorer/src/pages/object-result/ObjectResult.tsx index 6b9fb41bd36..f9195bff690 100644 --- a/apps/explorer/src/pages/object-result/ObjectResult.tsx +++ b/apps/explorer/src/pages/object-result/ObjectResult.tsx @@ -8,14 +8,12 @@ import { LoadingIndicator } from '@iota/ui'; import clsx from 'clsx'; import { useParams } from 'react-router-dom'; +import { ErrorBoundary, PageLayout } from '~/components'; +import { Banner, PageHeader } from '~/components/ui'; +import { ObjectView } from '~/pages/object-result/views/ObjectView'; import { translate, type DataType } from './ObjectResultType'; import PkgView from './views/PkgView'; import { TokenView } from './views/TokenView'; -import { PageLayout } from '~/components/layout/PageLayout'; -import { ErrorBoundary } from '~/components/error-boundary/ErrorBoundary'; -import { ObjectView } from '~/pages/object-result/views/ObjectView'; -import { Banner } from '~/ui/Banner'; -import { PageHeader } from '~/ui/PageHeader'; const PACKAGE_TYPE_NAME = 'Move Package'; diff --git a/apps/explorer/src/pages/object-result/ObjectResultType.tsx b/apps/explorer/src/pages/object-result/ObjectResultType.tsx index d9850b67397..f0108265353 100644 --- a/apps/explorer/src/pages/object-result/ObjectResultType.tsx +++ b/apps/explorer/src/pages/object-result/ObjectResultType.tsx @@ -2,7 +2,7 @@ // Modifications Copyright (c) 2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import { parseObjectType } from '../../utils/objectUtils'; +import { parseObjectType } from '../../lib/utils'; import type { IotaObjectResponse, ObjectOwner, MoveStruct } from '@iota/iota.js/client'; diff --git a/apps/explorer/src/pages/object-result/views/ObjectView.tsx b/apps/explorer/src/pages/object-result/views/ObjectView.tsx index 9d913d9b3cb..ce7323dc26a 100644 --- a/apps/explorer/src/pages/object-result/views/ObjectView.tsx +++ b/apps/explorer/src/pages/object-result/views/ObjectView.tsx @@ -4,28 +4,38 @@ import { CoinFormat, useFormatCoin, useResolveIotaNSName } from '@iota/core'; import { ArrowUpRight16, Info16 } from '@iota/icons'; -import { type ObjectOwner, type IotaObjectResponse } from '@iota/iota.js/client'; +import { type IotaObjectResponse, type ObjectOwner } from '@iota/iota.js/client'; import { formatAddress, + IOTA_TYPE_ARG, normalizeStructTag, parseStructTag, - IOTA_TYPE_ARG, } from '@iota/iota.js/utils'; import { Heading, Text } from '@iota/ui'; import { useQuery } from '@tanstack/react-query'; import clsx from 'clsx'; import { type ReactNode, useEffect, useState } from 'react'; +import { + AddressLink, + Card, + Description, + Divider, + Link, + ObjectLink, + ObjectVideoImage, + Tooltip, + TransactionLink, +} from '~/components/ui'; import { useResolveVideo } from '~/hooks/useResolveVideo'; -import { Card } from '~/ui/Card'; -import { Description } from '~/ui/Description'; -import { Divider } from '~/ui/Divider'; -import { AddressLink, ObjectLink, TransactionLink } from '~/ui/InternalLink'; -import { Link } from '~/ui/Link'; -import { ObjectVideoImage } from '~/ui/ObjectVideoImage'; -import { extractName, getDisplayUrl, parseImageURL, parseObjectType } from '~/utils/objectUtils'; -import { genFileTypeMsg, trimStdLibPrefix } from '~/utils/stringUtils'; -import { Tooltip } from '~/ui/Tooltip'; +import { + extractName, + genFileTypeMsg, + getDisplayUrl, + parseImageURL, + parseObjectType, + trimStdLibPrefix, +} from '~/lib/utils'; interface HeroVideoImageProps { title: string; diff --git a/apps/explorer/src/pages/object-result/views/PkgView.tsx b/apps/explorer/src/pages/object-result/views/PkgView.tsx index e72c83bbbef..3b942e0668f 100644 --- a/apps/explorer/src/pages/object-result/views/PkgView.tsx +++ b/apps/explorer/src/pages/object-result/views/PkgView.tsx @@ -2,22 +2,26 @@ // Modifications Copyright (c) 2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import { LoadingIndicator, RadioGroup, RadioGroupItem } from '@iota/ui'; import { useGetTransaction } from '@iota/core'; +import { LoadingIndicator, RadioGroup, RadioGroupItem } from '@iota/ui'; import { useState } from 'react'; import { type Direction } from 'react-resizable-panels'; -import { ErrorBoundary } from '../../../components/error-boundary/ErrorBoundary'; -import PkgModulesWrapper from '../../../components/module/PkgModulesWrapper'; -import { getOwnerStr } from '../../../utils/objectUtils'; -import { trimStdLibPrefix } from '../../../utils/stringUtils'; +import { ErrorBoundary, PkgModulesWrapper, TransactionBlocksForAddress } from '~/components'; +import { + AddressLink, + ObjectLink, + TabHeader, + Tabs, + TabsContent, + TabsList, + TabsTrigger, +} from '~/components/ui'; +import { getOwnerStr, trimStdLibPrefix } from '~/lib/utils'; import { type DataType } from '../ObjectResultType'; -import TransactionBlocksForAddress from '~/components/transaction-blocks-for-address'; -import { AddressLink, ObjectLink } from '~/ui/InternalLink'; -import { TabHeader, Tabs, TabsContent, TabsList, TabsTrigger } from '~/ui/Tabs'; -import styles from './ObjectView.module.css'; import { ObjectFilterValue } from '~/lib/enums'; +import styles from './ObjectView.module.css'; const GENESIS_TX_DIGEST = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA='; diff --git a/apps/explorer/src/pages/object-result/views/TokenView.tsx b/apps/explorer/src/pages/object-result/views/TokenView.tsx index 7986bd8a549..ee9120b018e 100644 --- a/apps/explorer/src/pages/object-result/views/TokenView.tsx +++ b/apps/explorer/src/pages/object-result/views/TokenView.tsx @@ -8,10 +8,8 @@ import { type IotaObjectResponse } from '@iota/iota.js/client'; import { Heading } from '@iota/ui'; import { type ReactNode, useState } from 'react'; -import { DynamicFieldsCard } from '~/components/object/DynamicFieldsCard'; -import { ObjectFieldsCard } from '~/components/object/ObjectFieldsCard'; -import TransactionBlocksForAddress from '~/components/transaction-blocks-for-address'; -import { Tabs, TabsContent, TabsList, TabsTrigger } from '~/ui/Tabs'; +import { DynamicFieldsCard, ObjectFieldsCard, TransactionBlocksForAddress } from '~/components'; +import { Tabs, TabsContent, TabsList, TabsTrigger } from '~/components/ui'; interface FieldsContainerProps { children: ReactNode; diff --git a/apps/explorer/src/pages/recent/index.tsx b/apps/explorer/src/pages/recent/index.tsx index 782b56d3cbd..1cf5d1ff36a 100644 --- a/apps/explorer/src/pages/recent/index.tsx +++ b/apps/explorer/src/pages/recent/index.tsx @@ -2,10 +2,8 @@ // Modifications Copyright (c) 2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import { Activity } from '../../components/activity'; -import { ErrorBoundary } from '../../components/error-boundary/ErrorBoundary'; -import { PageLayout } from '~/components/layout/PageLayout'; -import { useSearchParamsMerged } from '~/ui/LinkWithQuery'; +import { Activity, ErrorBoundary, PageLayout } from '~/components'; +import { useSearchParamsMerged } from '~/components/ui'; const TRANSACTIONS_LIMIT = 20; diff --git a/apps/explorer/src/pages/transaction-result/Events.tsx b/apps/explorer/src/pages/transaction-result/Events.tsx index bb29230b6ed..5ccc1aff48b 100644 --- a/apps/explorer/src/pages/transaction-result/Events.tsx +++ b/apps/explorer/src/pages/transaction-result/Events.tsx @@ -4,17 +4,14 @@ import { ChevronRight12 } from '@iota/icons'; import { type IotaEvent } from '@iota/iota.js/client'; -import { parseStructTag, formatAddress } from '@iota/iota.js/utils'; +import { formatAddress, parseStructTag } from '@iota/iota.js/utils'; import { Text } from '@iota/ui'; import * as Collapsible from '@radix-ui/react-collapsible'; import clsx from 'clsx'; import { useState } from 'react'; -import { SyntaxHighlighter } from '~/components/syntax-highlighter'; -import { CopyToClipboard } from '~/ui/CopyToClipboard'; -import { DescriptionItem } from '~/ui/DescriptionList'; -import { Divider } from '~/ui/Divider'; -import { ObjectLink } from '~/ui/InternalLink'; +import { SyntaxHighlighter } from '~/components'; +import { CopyToClipboard, DescriptionItem, Divider, ObjectLink } from '~/components/ui'; function Event({ event, divider }: { event: IotaEvent; divider: boolean }): JSX.Element { const [open, setOpen] = useState(false); diff --git a/apps/explorer/src/pages/transaction-result/Signatures.tsx b/apps/explorer/src/pages/transaction-result/Signatures.tsx index 1eda425356e..82b41b87603 100644 --- a/apps/explorer/src/pages/transaction-result/Signatures.tsx +++ b/apps/explorer/src/pages/transaction-result/Signatures.tsx @@ -5,17 +5,15 @@ import { type IotaTransactionBlockResponse } from '@iota/iota.js/client'; import { parseSerializedSignature, - type SignatureScheme, type PublicKey, + type SignatureScheme, } from '@iota/iota.js/cryptography'; import { parsePartialSignatures } from '@iota/iota.js/multisig'; -import { toB64, normalizeIotaAddress } from '@iota/iota.js/utils'; +import { normalizeIotaAddress, toB64 } from '@iota/iota.js/utils'; import { publicKeyFromRawBytes } from '@iota/iota.js/verify'; import { Text } from '@iota/ui'; -import { DescriptionItem, DescriptionList } from '~/ui/DescriptionList'; -import { AddressLink } from '~/ui/InternalLink'; -import { TabHeader } from '~/ui/Tabs'; +import { AddressLink, DescriptionItem, DescriptionList, TabHeader } from '~/components/ui'; type SignaturePubkeyPair = { signatureScheme: SignatureScheme; diff --git a/apps/explorer/src/pages/transaction-result/TransactionData.tsx b/apps/explorer/src/pages/transaction-result/TransactionData.tsx index b747197b7b9..b9e1a03b888 100644 --- a/apps/explorer/src/pages/transaction-result/TransactionData.tsx +++ b/apps/explorer/src/pages/transaction-result/TransactionData.tsx @@ -9,7 +9,7 @@ import { } from '@iota/iota.js/client'; import { TransactionDetailCard } from './transaction-summary/TransactionDetailCard'; -import { GasBreakdown } from '~/components/gas-breakdown'; +import { GasBreakdown } from '~/components'; import { useRecognizedPackages } from '~/hooks/useRecognizedPackages'; import { InputsCard } from '~/pages/transaction-result/programmable-transaction-view/InputsCard'; import { TransactionsCard } from '~/pages/transaction-result/programmable-transaction-view/TransactionsCard'; diff --git a/apps/explorer/src/pages/transaction-result/TransactionResult.tsx b/apps/explorer/src/pages/transaction-result/TransactionResult.tsx index 49506ed622b..ddb571117f6 100644 --- a/apps/explorer/src/pages/transaction-result/TransactionResult.tsx +++ b/apps/explorer/src/pages/transaction-result/TransactionResult.tsx @@ -2,15 +2,13 @@ // Modifications Copyright (c) 2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import { type IotaTransactionBlockResponse } from '@iota/iota.js/client'; import { useGetTransaction } from '@iota/core'; +import { type IotaTransactionBlockResponse } from '@iota/iota.js/client'; import { useParams } from 'react-router-dom'; +import { PageLayout } from '~/components'; +import { Banner, PageHeader, StatusIcon } from '~/components/ui'; import { TransactionView } from './TransactionView'; -import { PageLayout } from '~/components/layout/PageLayout'; -import { Banner } from '~/ui/Banner'; -import { PageHeader } from '~/ui/PageHeader'; -import { StatusIcon } from '~/ui/StatusIcon'; interface TransactionResultPageHeaderProps { transaction?: IotaTransactionBlockResponse; diff --git a/apps/explorer/src/pages/transaction-result/TransactionView.tsx b/apps/explorer/src/pages/transaction-result/TransactionView.tsx index 7eb616b585c..5251589c9bf 100644 --- a/apps/explorer/src/pages/transaction-result/TransactionView.tsx +++ b/apps/explorer/src/pages/transaction-result/TransactionView.tsx @@ -6,17 +6,16 @@ import { type IotaTransactionBlockResponse } from '@iota/iota.js/client'; import clsx from 'clsx'; import { type ReactNode, useState } from 'react'; -import { Signatures } from './Signatures'; -import { ErrorBoundary } from '~/components/error-boundary/ErrorBoundary'; +import { ErrorBoundary } from '~/components'; +import { SplitPanes, Tabs, TabsContent, TabsList, TabsTrigger } from '~/components/ui'; import { useBreakpoint } from '~/hooks/useBreakpoint'; import { Events } from '~/pages/transaction-result/Events'; import { TransactionData } from '~/pages/transaction-result/TransactionData'; import { TransactionSummary } from '~/pages/transaction-result/transaction-summary'; -import { SplitPanes } from '~/ui/SplitPanes'; -import { Tabs, TabsContent, TabsList, TabsTrigger } from '~/ui/Tabs'; +import { Signatures } from './Signatures'; -import styles from './TransactionResult.module.css'; import { LocalStorageSplitPaneKey } from '~/lib/enums'; +import styles from './TransactionResult.module.css'; interface TabsContentContainerProps { value: string; diff --git a/apps/explorer/src/pages/transaction-result/programmable-transaction-view/InputsCard.tsx b/apps/explorer/src/pages/transaction-result/programmable-transaction-view/InputsCard.tsx index 59f2d7dedba..398e27c0dfc 100644 --- a/apps/explorer/src/pages/transaction-result/programmable-transaction-view/InputsCard.tsx +++ b/apps/explorer/src/pages/transaction-result/programmable-transaction-view/InputsCard.tsx @@ -5,9 +5,8 @@ import { type IotaCallArg } from '@iota/iota.js/client'; import { Text } from '@iota/ui'; -import { ProgrammableTxnBlockCard } from '~/components/transactions/ProgTxnBlockCard'; -import { AddressLink, ObjectLink } from '~/ui/InternalLink'; -import { CollapsibleSection } from '~/ui/collapsible/CollapsibleSection'; +import { ProgrammableTxnBlockCard } from '~/components'; +import { AddressLink, CollapsibleSection, ObjectLink } from '~/components/ui'; const REGEX_NUMBER = /^\d+$/; diff --git a/apps/explorer/src/pages/transaction-result/programmable-transaction-view/Transaction.tsx b/apps/explorer/src/pages/transaction-result/programmable-transaction-view/Transaction.tsx index b1f44eb3bce..1af159812b3 100644 --- a/apps/explorer/src/pages/transaction-result/programmable-transaction-view/Transaction.tsx +++ b/apps/explorer/src/pages/transaction-result/programmable-transaction-view/Transaction.tsx @@ -11,8 +11,8 @@ import { Text } from '@iota/ui'; import { type ReactNode } from 'react'; import { flattenIotaArguments } from './utils'; -import { ErrorBoundary } from '~/components/error-boundary/ErrorBoundary'; -import { ObjectLink } from '~/ui/InternalLink'; +import { ErrorBoundary } from '~/components'; +import { ObjectLink } from '~/components/ui'; interface TransactionProps { type: string; diff --git a/apps/explorer/src/pages/transaction-result/programmable-transaction-view/TransactionsCard.tsx b/apps/explorer/src/pages/transaction-result/programmable-transaction-view/TransactionsCard.tsx index c17e2adbd61..8dcad913503 100644 --- a/apps/explorer/src/pages/transaction-result/programmable-transaction-view/TransactionsCard.tsx +++ b/apps/explorer/src/pages/transaction-result/programmable-transaction-view/TransactionsCard.tsx @@ -5,8 +5,8 @@ import { type IotaTransaction } from '@iota/iota.js/client'; import { Transaction } from './Transaction'; -import { ProgrammableTxnBlockCard } from '~/components/transactions/ProgTxnBlockCard'; -import { CollapsibleSection } from '~/ui/collapsible/CollapsibleSection'; +import { ProgrammableTxnBlockCard } from '~/components'; +import { CollapsibleSection } from '~/components/ui'; interface TransactionsCardProps { transactions: IotaTransaction[]; diff --git a/apps/explorer/src/pages/transaction-result/transaction-summary/BalanceChanges.tsx b/apps/explorer/src/pages/transaction-result/transaction-summary/BalanceChanges.tsx index 234c874d8d1..a505a6731b4 100644 --- a/apps/explorer/src/pages/transaction-result/transaction-summary/BalanceChanges.tsx +++ b/apps/explorer/src/pages/transaction-result/transaction-summary/BalanceChanges.tsx @@ -3,23 +3,19 @@ // SPDX-License-Identifier: Apache-2.0 import { + type BalanceChange, type BalanceChangeSummary, CoinFormat, - useFormatCoin, + getRecognizedUnRecognizedTokenChanges, useCoinMetadata, - type BalanceChange, + useFormatCoin, useResolveIotaNSName, - getRecognizedUnRecognizedTokenChanges, } from '@iota/core'; import { Heading, Text } from '@iota/ui'; import clsx from 'clsx'; import { useMemo } from 'react'; -import { Banner } from '~/ui/Banner'; -import { Coin } from '~/ui/CoinsStack'; -import { AddressLink } from '~/ui/InternalLink'; -import { CollapsibleCard } from '~/ui/collapsible/CollapsibleCard'; -import { CollapsibleSection } from '~/ui/collapsible/CollapsibleSection'; +import { AddressLink, Banner, Coin, CollapsibleCard, CollapsibleSection } from '~/components/ui'; interface BalanceChangesProps { changes: BalanceChangeSummary; diff --git a/apps/explorer/src/pages/transaction-result/transaction-summary/ObjectChanges.tsx b/apps/explorer/src/pages/transaction-result/transaction-summary/ObjectChanges.tsx index 0c47895b697..9a15b5fe7e0 100644 --- a/apps/explorer/src/pages/transaction-result/transaction-summary/ObjectChanges.tsx +++ b/apps/explorer/src/pages/transaction-result/transaction-summary/ObjectChanges.tsx @@ -4,17 +4,17 @@ import { ObjectChangeLabels, + useResolveIotaNSName, + type IotaObjectChangeTypes, type IotaObjectChangeWithDisplay, type ObjectChangesByOwner, type ObjectChangeSummary, - type IotaObjectChangeTypes, - useResolveIotaNSName, } from '@iota/core'; import { ChevronRight12 } from '@iota/icons'; import { - type IotaObjectChangePublished, - type IotaObjectChange, type DisplayFieldsResponse, + type IotaObjectChange, + type IotaObjectChangePublished, } from '@iota/iota.js/client'; import { parseStructTag } from '@iota/iota.js/utils'; import { Text } from '@iota/ui'; @@ -22,11 +22,16 @@ import * as Collapsible from '@radix-ui/react-collapsible'; import clsx from 'clsx'; import { useState, type ReactNode } from 'react'; +import { + AddressLink, + CollapsibleCard, + CollapsibleSection, + ExpandableList, + ExpandableListControl, + ExpandableListItems, + ObjectLink, +} from '~/components/ui'; import { ObjectDisplay } from './ObjectDisplay'; -import { ExpandableList, ExpandableListControl, ExpandableListItems } from '~/ui/ExpandableList'; -import { AddressLink, ObjectLink } from '~/ui/InternalLink'; -import { CollapsibleCard } from '~/ui/collapsible/CollapsibleCard'; -import { CollapsibleSection } from '~/ui/collapsible/CollapsibleSection'; interface ItemProps { label: string; diff --git a/apps/explorer/src/pages/transaction-result/transaction-summary/ObjectDisplay.tsx b/apps/explorer/src/pages/transaction-result/transaction-summary/ObjectDisplay.tsx index a9ab7f5fdaa..68726374900 100644 --- a/apps/explorer/src/pages/transaction-result/transaction-summary/ObjectDisplay.tsx +++ b/apps/explorer/src/pages/transaction-result/transaction-summary/ObjectDisplay.tsx @@ -5,9 +5,7 @@ import { type DisplayFieldsResponse } from '@iota/iota.js/client'; import { useState } from 'react'; -import { ObjectLink } from '~/ui/InternalLink'; -import { ObjectModal } from '~/ui/modal/ObjectModal'; -import { Image } from '~/ui/image/Image'; +import { Image, ObjectLink, ObjectModal } from '~/components/ui'; interface ObjectDisplayProps { objectId: string; diff --git a/apps/explorer/src/pages/transaction-result/transaction-summary/TransactionDetailCard.tsx b/apps/explorer/src/pages/transaction-result/transaction-summary/TransactionDetailCard.tsx index 7a2165d0dae..e96bf30ce38 100644 --- a/apps/explorer/src/pages/transaction-result/transaction-summary/TransactionDetailCard.tsx +++ b/apps/explorer/src/pages/transaction-result/transaction-summary/TransactionDetailCard.tsx @@ -6,10 +6,14 @@ import { formatDate, useResolveIotaNSName } from '@iota/core'; import { Heading, Text } from '@iota/ui'; import { type ReactNode } from 'react'; +import { + AddressLink, + CheckpointSequenceLink, + CollapsibleCard, + CollapsibleSection, + EpochLink, +} from '~/components/ui'; import { useBreakpoint } from '~/hooks/useBreakpoint'; -import { AddressLink, CheckpointSequenceLink, EpochLink } from '~/ui/InternalLink'; -import { CollapsibleCard } from '~/ui/collapsible/CollapsibleCard'; -import { CollapsibleSection } from '~/ui/collapsible/CollapsibleSection'; export function TransactionDetail({ label, diff --git a/apps/explorer/src/pages/transaction-result/transaction-summary/UpgradedSystemPackages.tsx b/apps/explorer/src/pages/transaction-result/transaction-summary/UpgradedSystemPackages.tsx index f6209c3217a..8309cf75b7f 100644 --- a/apps/explorer/src/pages/transaction-result/transaction-summary/UpgradedSystemPackages.tsx +++ b/apps/explorer/src/pages/transaction-result/transaction-summary/UpgradedSystemPackages.tsx @@ -4,9 +4,7 @@ import { Text } from '@iota/ui'; -import { ObjectLink } from '~/ui/InternalLink'; -import { CollapsibleCard } from '~/ui/collapsible/CollapsibleCard'; -import { CollapsibleSection } from '~/ui/collapsible/CollapsibleSection'; +import { CollapsibleCard, CollapsibleSection, ObjectLink } from '~/components/ui'; import type { OwnedObjectRef } from '@iota/iota.js/client'; diff --git a/apps/explorer/src/pages/validator/ValidatorDetails.tsx b/apps/explorer/src/pages/validator/ValidatorDetails.tsx index 0e32a8181ed..15e439ca303 100644 --- a/apps/explorer/src/pages/validator/ValidatorDetails.tsx +++ b/apps/explorer/src/pages/validator/ValidatorDetails.tsx @@ -9,12 +9,10 @@ import { LoadingIndicator, Text } from '@iota/ui'; import React, { useMemo } from 'react'; import { useParams } from 'react-router-dom'; -import { PageLayout } from '~/components/layout/PageLayout'; -import { ValidatorMeta } from '~/components/validator/ValidatorMeta'; -import { ValidatorStats } from '~/components/validator/ValidatorStats'; -import { Banner } from '~/ui/Banner'; -import { getValidatorMoveEvent } from '~/utils/getValidatorMoveEvent'; -import { VALIDATOR_LOW_STAKE_GRACE_PERIOD } from '~/utils/validatorConstants'; +import { PageLayout, ValidatorMeta, ValidatorStats } from '~/components'; +import { VALIDATOR_LOW_STAKE_GRACE_PERIOD } from '~/lib/constants'; +import { getValidatorMoveEvent } from '~/lib/utils'; +import { Banner } from '~/components/ui'; const getAtRiskRemainingEpochs = ( data: IotaSystemStateSummary | undefined, diff --git a/apps/explorer/src/pages/validators/Validators.tsx b/apps/explorer/src/pages/validators/Validators.tsx index 06c7cdc914e..770f0f810c4 100644 --- a/apps/explorer/src/pages/validators/Validators.tsx +++ b/apps/explorer/src/pages/validators/Validators.tsx @@ -5,35 +5,33 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { + formatPercentageDisplay, roundFloat, useGetValidatorsApy, - type ApyByValidator, useGetValidatorsEvents, - formatPercentageDisplay, + type ApyByValidator, } from '@iota/core'; import { useIotaClientQuery } from '@iota/dapp-kit'; import { type IotaEvent, type IotaValidatorSummary } from '@iota/iota.js/client'; import { Heading, Text } from '@iota/ui'; import { lazy, Suspense, useMemo } from 'react'; -import { PageLayout } from '~/components/layout/PageLayout'; -import { ErrorBoundary } from '~/components/error-boundary/ErrorBoundary'; -import { StakeColumn } from '~/components/top-validators-card/StakeColumn'; -import { DelegationAmount } from '~/components/validator/DelegationAmount'; -import { Banner } from '~/ui/Banner'; -import { Card } from '~/ui/Card'; -import { ImageIcon } from '~/ui/ImageIcon'; -import { Link } from '~/ui/Link'; -import { PlaceholderTable } from '~/ui/PlaceholderTable'; -import { Stats } from '~/ui/Stats'; -import { TableCard } from '~/ui/TableCard'; -import { TableHeader } from '~/ui/TableHeader'; -import { Tooltip } from '~/ui/Tooltip'; -import { ampli } from '~/utils/analytics/ampli'; -import { getValidatorMoveEvent } from '~/utils/getValidatorMoveEvent'; -import { VALIDATOR_LOW_STAKE_GRACE_PERIOD } from '~/utils/validatorConstants'; +import { DelegationAmount, ErrorBoundary, PageLayout, StakeColumn } from '~/components'; +import { + Banner, + Card, + ImageIcon, + Link, + PlaceholderTable, + Stats, + TableCard, + TableHeader, + Tooltip, +} from '~/components/ui'; +import { VALIDATOR_LOW_STAKE_GRACE_PERIOD } from '~/lib/constants'; +import { ampli, getValidatorMoveEvent } from '~/lib/utils'; -const ValidatorMap = lazy(() => import('../../components/validator-map')); +const ValidatorMap = lazy(() => import('../../components/validator-map/ValidatorMap')); export function validatorsTableData( validators: IotaValidatorSummary[], diff --git a/apps/explorer/src/utils/sentry.ts b/apps/explorer/src/utils/sentry.ts deleted file mode 100644 index b29d51d0abd..00000000000 --- a/apps/explorer/src/utils/sentry.ts +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// Modifications Copyright (c) 2024 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -import * as Sentry from '@sentry/react'; -import { useEffect } from 'react'; -import { - createRoutesFromChildren, - matchRoutes, - useLocation, - useNavigationType, -} from 'react-router-dom'; - -const SENTRY_ENABLED = import.meta.env.PROD; -const SENTRY_SAMPLE_RATE = import.meta.env.VITE_SENTRY_SAMPLE_RATE - ? parseFloat(import.meta.env.VITE_SENTRY_SAMPLE_RATE) - : 1; - -Sentry.init({ - enabled: SENTRY_ENABLED, - dsn: import.meta.env.PROD - ? import.meta.env.VITE_PROD_SENTRY_DSN - : import.meta.env.VITE_DEV_SENTRY_DSN, - environment: import.meta.env.VITE_VERCEL_ENV, - integrations: [ - new Sentry.BrowserTracing({ - routingInstrumentation: Sentry.reactRouterV6Instrumentation( - useEffect, - useLocation, - useNavigationType, - createRoutesFromChildren, - matchRoutes, - ), - }), - ], - tracesSampleRate: SENTRY_SAMPLE_RATE, - beforeSend(event) { - try { - // Filter out any code from unknown sources: - if ( - !event.exception?.values?.[0].stacktrace || - event.exception?.values?.[0].stacktrace?.frames?.[0].filename === '' - ) { - return null; - } - // eslint-disable-next-line no-empty - } catch (e) {} - - return event; - }, - - denyUrls: [ - // Chrome extensions - /extensions\//i, - /^chrome(?:-extension)?:\/\//i, - //, - ], - allowUrls: [/.*\.iota\.io/i, /.*-mysten-labs\.vercel\.app/i, 'explorer-topaz.vercel.app'], -}); diff --git a/apps/wallet/.storybook/main.js b/apps/wallet/.storybook/main.js deleted file mode 100644 index c996479e7ee..00000000000 --- a/apps/wallet/.storybook/main.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// SPDX-License-Identifier: Apache-2.0 - -const { default: getWebpackConfig } = require('../configs/webpack/webpack.config.dev.ts'); -const MiniCssExtractPlugin = require('mini-css-extract-plugin'); -const path = require('path'); - -module.exports = { - stories: ['../src/ui/**/*.mdx', '../src/ui/**/*.stories.@(js|jsx|ts|tsx)'], - addons: [ - '@storybook/addon-links', - '@storybook/addon-essentials', - '@storybook/addon-interactions', - ], - framework: { - name: '@storybook/react-webpack5', - options: {}, - }, - docs: { - docsPage: true, - }, - webpackFinal: async (config) => { - const custom = await getWebpackConfig(); - - config.plugins.push(new MiniCssExtractPlugin()); - config.resolve.alias = custom.resolve.alias; - - const cssRule = custom.module.rules.find((rule) => rule.test?.test('.css')); - const tsRule = custom.module.rules.find((rule) => rule.test?.test('.tsx')); - tsRule.include = path.resolve('../icons/src'); - - config.module.rules = [ - ...config.module.rules.filter((rule) => !rule.test?.test('.css')), - tsRule, - cssRule, - ]; - - return config; - }, -}; diff --git a/apps/wallet/.storybook/manager.js b/apps/wallet/.storybook/manager.js deleted file mode 100644 index 7837bed817b..00000000000 --- a/apps/wallet/.storybook/manager.js +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// SPDX-License-Identifier: Apache-2.0 - -import { addons } from '@storybook/addons'; -import { themes } from '@storybook/theming'; - -// Force the theme to light, as our components do not suppor theming -addons.setConfig({ - theme: themes.light, -}); diff --git a/apps/wallet/.storybook/preview.js b/apps/wallet/.storybook/preview.js deleted file mode 100644 index c5aac559152..00000000000 --- a/apps/wallet/.storybook/preview.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// SPDX-License-Identifier: Apache-2.0 - -import '../src/ui/styles/global.scss'; -import '@fontsource-variable/inter'; -import '@fontsource-variable/red-hat-mono'; -import 'bootstrap-icons/font/bootstrap-icons.scss'; - -import { MemoryRouter } from 'react-router-dom'; - -export const parameters = { - actions: { argTypesRegex: '^on[A-Z].*' }, - controls: { - matchers: { - color: /(background|color)$/i, - date: /Date$/, - }, - }, - viewport: { - viewports: { - extension: { - name: 'Chrome Extension', - styles: { - height: '600px', - width: '360px', - }, - type: 'mobile', - }, - }, - defaultViewport: 'extension', - }, -}; - -export const decorators = [ - (Story) => ( - - - - ), -]; diff --git a/apps/wallet/package.json b/apps/wallet/package.json index 56c63172c62..035e6bc75a7 100644 --- a/apps/wallet/package.json +++ b/apps/wallet/package.json @@ -20,9 +20,6 @@ "test:watch": "vitest", "playwright": "cross-env PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=\"1\" playwright", "pack:zip": "web-ext build --source-dir ./dist --overwrite-dest", - "storybook": "storybook dev -p 6007", - "build-storybook": "storybook build", - "preview-storybook": "pnpm dlx serve ./storybook-static -l 6007", "ampli": "ampli", "pull-amplitude": "ampli pull web && node prependLicense.mjs && prettier -w ampli.json src/shared/analytics/ampli/index.ts", "demoApp:dev": "pnpm vite -c ./tests/demo-app/vite.config.ts ./tests/demo-app/ --port 5181" @@ -46,15 +43,6 @@ "@playwright/test": "^1.36.1", "@sentry/react": "^7.59.2", "@sentry/webpack-plugin": "^1.20.0", - "@storybook/addon-a11y": "^7.1.0", - "@storybook/addon-essentials": "^7.1.0", - "@storybook/addon-interactions": "^7.1.0", - "@storybook/addon-links": "^7.1.0", - "@storybook/addons": "^7.1.0", - "@storybook/blocks": "^7.1.0", - "@storybook/react": "^7.1.0", - "@storybook/react-webpack5": "^7.1.0", - "@storybook/theming": "^7.1.0", "@svgr/webpack": "^7.0.0", "@types/git-rev-sync": "^2.0.0", "@types/node": "^20.4.2", @@ -82,7 +70,6 @@ "postcss-preset-env": "^9.0.0", "sass": "^1.63.6", "sass-loader": "^13.3.2", - "storybook": "^7.1.0", "tailwindcss": "^3.3.3", "tailwindcss-animate": "^1.0.6", "ts-loader": "^9.4.4", diff --git a/apps/wallet/src/ui/app/shared/Badge.stories.tsx b/apps/wallet/src/ui/app/shared/Badge.stories.tsx deleted file mode 100644 index c89dcd1882d..00000000000 --- a/apps/wallet/src/ui/app/shared/Badge.stories.tsx +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// Modifications Copyright (c) 2024 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -import { type Meta, type StoryObj } from '@storybook/react'; - -import { Badge } from './Badge'; - -export default { - component: Badge, -} as Meta; - -export const Success: StoryObj = { - args: { - label: 'New', - variant: 'success', - }, -}; - -export const Warning: StoryObj = { - args: { - label: 'At Risk', - variant: 'warning', - }, -}; diff --git a/apps/wallet/src/ui/app/shared/ButtonConnectedTo.stories.tsx b/apps/wallet/src/ui/app/shared/ButtonConnectedTo.stories.tsx deleted file mode 100644 index ff5ae31a687..00000000000 --- a/apps/wallet/src/ui/app/shared/ButtonConnectedTo.stories.tsx +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// Modifications Copyright (c) 2024 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -import { StakeAdd16 } from '@iota/icons'; -import { type Meta, type StoryObj } from '@storybook/react'; - -import { ButtonConnectedTo } from './ButtonConnectedTo'; - -export default { - component: ButtonConnectedTo, -} as Meta; - -export const Default: StoryObj = { - args: { - text: 'Button', - }, -}; - -export const LightGrey: StoryObj = { - args: { - text: 'Button', - bgOnHover: 'grey', - }, -}; - -export const Disabled: StoryObj = { - args: { - text: 'Button', - bgOnHover: 'grey', - disabled: true, - }, -}; - -export const LongText: StoryObj = { - render: (props) => { - return ( -
- -
- ); - }, - args: { - text: 'Button with very long text', - bgOnHover: 'grey', - iconBefore: , - iconAfter: , - }, -}; diff --git a/apps/wallet/src/ui/app/shared/ButtonUI.stories.tsx b/apps/wallet/src/ui/app/shared/ButtonUI.stories.tsx deleted file mode 100644 index dbf28b3b7dd..00000000000 --- a/apps/wallet/src/ui/app/shared/ButtonUI.stories.tsx +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// Modifications Copyright (c) 2024 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -import { Add16, StakeAdd16 } from '@iota/icons'; -import { type Meta, type StoryObj } from '@storybook/react'; - -import { Button } from './ButtonUI'; - -export default { - component: Button, -} as Meta; - -export const Default: StoryObj = { - args: { - text: 'Default Button', - }, -}; - -export const AllButton: StoryObj = { - render: (props) => { - const variants = [ - 'primary', - 'secondary', - 'outline', - 'outlineWarning', - 'warning', - 'plain', - ] as const; - const sizes = ['tall', 'narrow', 'xs'] as const; - return ( -
- {sizes.map((size) => - variants.map((variant) => ( -
-
{`${variant}-${size}`}
-
- )), - )} -
- ); - }, -}; - -export const AllLink: StoryObj = { - ...AllButton, - args: { to: '.' }, -}; -export const AllAnchor: StoryObj = { - ...AllButton, - args: { href: 'https://example.com' }, -}; diff --git a/apps/wallet/src/ui/app/shared/ConfirmationModal.stories.tsx b/apps/wallet/src/ui/app/shared/ConfirmationModal.stories.tsx deleted file mode 100644 index 8d98129034d..00000000000 --- a/apps/wallet/src/ui/app/shared/ConfirmationModal.stories.tsx +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// Modifications Copyright (c) 2024 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -import { type Meta, type StoryObj } from '@storybook/react'; -import { useState } from 'react'; - -import { Button } from './ButtonUI'; -import { ConfirmationModal } from './ConfirmationModal'; - -export default { - component: ConfirmationModal, - decorators: [ - (Story, ctx) => { - const [isOpen, setIsOpen] = useState(false); - return ( - <> -