@xdcs-protocol/ui-kit 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +54 -0
  2. package/dist/index.cjs.js +69 -0
  3. package/dist/index.es.js +6422 -0
  4. package/dist/types/App.d.ts +2 -0
  5. package/dist/types/components/Header.d.ts +2 -0
  6. package/dist/types/components/LeftPanel.d.ts +10 -0
  7. package/dist/types/components/MainLayout.d.ts +2 -0
  8. package/dist/types/components/Navbar.d.ts +2 -0
  9. package/dist/types/components/NavbarMenu.d.ts +2 -0
  10. package/dist/types/components/RightPanel.d.ts +2 -0
  11. package/dist/types/components/StyledSlider.d.ts +2 -0
  12. package/dist/types/components/ThreeDots.d.ts +2 -0
  13. package/dist/types/components/ToggleTheme.d.ts +1 -0
  14. package/dist/types/components/WalletNavbar.d.ts +3 -0
  15. package/dist/types/components/XDCLiquidStaking.d.ts +8 -0
  16. package/dist/types/components/core/AddressFieldTools.d.ts +18 -0
  17. package/dist/types/components/store/useThemeStore.d.ts +18 -0
  18. package/dist/types/config/chains.d.ts +7 -0
  19. package/dist/types/helpers/text.d.ts +58 -0
  20. package/dist/types/hooks/store/useMockAppStore.d.ts +2 -0
  21. package/dist/types/hooks/useWalletContext.d.ts +4 -0
  22. package/dist/types/index.d.ts +8 -0
  23. package/dist/types/main.d.ts +1 -0
  24. package/dist/types/stories/Button.d.ts +15 -0
  25. package/dist/types/stories/Button.stories.d.ts +23 -0
  26. package/dist/types/stories/Header.d.ts +12 -0
  27. package/dist/types/stories/Header.stories.d.ts +18 -0
  28. package/dist/types/stories/Page.d.ts +3 -0
  29. package/dist/types/stories/Page.stories.d.ts +12 -0
  30. package/dist/types/theme.d.ts +2 -0
  31. package/dist/types/types/WalletStore.d.ts +28 -0
  32. package/dist/types/types/index.d.ts +1 -0
  33. package/dist/vite.svg +1 -0
  34. package/package.json +83 -0
@@ -0,0 +1,2 @@
1
+ declare function App(): import("react/jsx-runtime").JSX.Element;
2
+ export default App;
@@ -0,0 +1,2 @@
1
+ declare const Header: () => import("react/jsx-runtime").JSX.Element;
2
+ export default Header;
@@ -0,0 +1,10 @@
1
+ export declare const boldSx: {
2
+ fontFamily: string;
3
+ fontWeight: number;
4
+ fontSize: string;
5
+ lineHeight: string;
6
+ letterSpacing: string;
7
+ mb: number;
8
+ };
9
+ declare const LeftPanel: () => import("react/jsx-runtime").JSX.Element;
10
+ export default LeftPanel;
@@ -0,0 +1,2 @@
1
+ declare const MainLayout: () => import("react/jsx-runtime").JSX.Element;
2
+ export default MainLayout;
@@ -0,0 +1,2 @@
1
+ declare function Navbar(): import("react/jsx-runtime").JSX.Element;
2
+ export default Navbar;
@@ -0,0 +1,2 @@
1
+ declare const NavbarMenu: () => import("react/jsx-runtime").JSX.Element;
2
+ export default NavbarMenu;
@@ -0,0 +1,2 @@
1
+ declare const RightPanel: () => import("react/jsx-runtime").JSX.Element;
2
+ export default RightPanel;
@@ -0,0 +1,2 @@
1
+ declare const StyledSlider: import("@emotion/styled").StyledComponent<import("@mui/material").SliderOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "components" | "disabled" | "className" | "style" | "classes" | "sx" | "track" | "defaultValue" | "tabIndex" | "color" | "aria-label" | "aria-labelledby" | "aria-valuetext" | "onChange" | "scale" | "size" | "name" | "value" | "slots" | "slotProps" | "orientation" | "max" | "min" | "componentsProps" | "disableSwap" | "getAriaLabel" | "getAriaValueText" | "marks" | "onChangeCommitted" | "shiftStep" | "step" | "valueLabelDisplay" | "valueLabelFormat"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
2
+ export default StyledSlider;
@@ -0,0 +1,2 @@
1
+ declare const ThreeDotsMenu: () => import("react/jsx-runtime").JSX.Element;
2
+ export default ThreeDotsMenu;
@@ -0,0 +1 @@
1
+ export default function ThemeToggle(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ declare const WalletNavbar: React.FC;
3
+ export default WalletNavbar;
@@ -0,0 +1,8 @@
1
+ export declare const regularSx: {
2
+ fontFamily: string;
3
+ fontWeight: number;
4
+ fontStyle: string;
5
+ lineHeight: string;
6
+ letterSpacing: string;
7
+ };
8
+ export default function XDCLiquidStaking(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,18 @@
1
+ export interface AddressFieldToolsProps {
2
+ address: string;
3
+ symbol?: string;
4
+ decimal?: number;
5
+ showAddress?: boolean;
6
+ showCopyButton?: boolean;
7
+ showInBlockExplorer?: boolean;
8
+ withBackground?: boolean;
9
+ isTransaction?: boolean;
10
+ showAddToWallet?: boolean;
11
+ shrinkAddress?: boolean;
12
+ chainId?: number;
13
+ onCopy?: (text: string) => void;
14
+ onOpenExplorer?: (url: string) => void;
15
+ onAddToWallet?: () => Promise<void> | void;
16
+ }
17
+ declare const AddressFieldTools: ({ address, showAddress, showCopyButton, showInBlockExplorer, withBackground, isTransaction, showAddToWallet, shrinkAddress, chainId, onCopy, onOpenExplorer, onAddToWallet, }: AddressFieldToolsProps) => import("react/jsx-runtime").JSX.Element;
18
+ export default AddressFieldTools;
@@ -0,0 +1,18 @@
1
+ type ThemeMode = "light" | "dark";
2
+ export interface ThemeStore {
3
+ mode: ThemeMode;
4
+ toggleMode: () => void;
5
+ setMode: (mode: ThemeMode) => void;
6
+ }
7
+ declare const useThemeStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<ThemeStore>, "persist"> & {
8
+ persist: {
9
+ setOptions: (options: Partial<import("zustand/middleware").PersistOptions<ThemeStore, ThemeStore>>) => void;
10
+ clearStorage: () => void;
11
+ rehydrate: () => Promise<void> | void;
12
+ hasHydrated: () => boolean;
13
+ onHydrate: (fn: (state: ThemeStore) => void) => () => void;
14
+ onFinishHydration: (fn: (state: ThemeStore) => void) => () => void;
15
+ getOptions: () => Partial<import("zustand/middleware").PersistOptions<ThemeStore, ThemeStore>>;
16
+ };
17
+ }>;
18
+ export { useThemeStore };
@@ -0,0 +1,7 @@
1
+ export declare const CHAIN_CONFIG: Record<number, {
2
+ name: string;
3
+ logoLight: string;
4
+ logoDark: string;
5
+ explorer: string;
6
+ prefix?: string;
7
+ }>;
@@ -0,0 +1,58 @@
1
+ import { type Address } from "../types";
2
+ export declare const ethToXdcAddress: (address: string) => string;
3
+ export declare const xdcToEthAddress: (address: string) => string;
4
+ export declare const MAX_FILE_SIZE: number;
5
+ export declare const ACCEPTED_IMAGE_TYPES: string[];
6
+ export declare const ellipsisShrinkStr: (str: string, start: number, end: number) => string;
7
+ export declare const checksumAddress: (address: Address) => string;
8
+ export declare const formatAddressShort: (address: Address) => string;
9
+ /**
10
+ * Formats a floating-point number to a string with specified precision.
11
+ *
12
+ * @param n - The floating-point number to format.
13
+ * @param precision - The number of decimal places to include in the result (default is 5).
14
+ * @returns A string representation of the number with the specified precision.
15
+ * If the number is effectively zero, returns '0' with specified precision.
16
+ * Ensures a minimum of `precision` decimal places in the result.
17
+ */
18
+ export declare const formatFloat: (n: number, precision?: number) => string;
19
+ export declare const convertFromWei: (value: string) => string;
20
+ /**
21
+ * Converts a number to a BigInt with scaling based on precision.
22
+ * @param number - The input number to convert.
23
+ * @param precision - The number of decimal places to scale by (default is 2).
24
+ * @returns The scaled BigInt representation of the number.
25
+ * @throws Error if the input is not a valid number.
26
+ */
27
+ export declare function percentToBigInt(number: number, precision?: number): bigint;
28
+ /**
29
+ * Converts a BigInt back to a number with the original scale.
30
+ * @param bigIntValue - The BigInt to convert back.
31
+ * @param precision - The number of decimal places to scale down by (default is 2).
32
+ * @returns The original number representation.
33
+ * @throws Error if the input is not a valid BigInt.
34
+ */
35
+ export declare function bigIntToPercent(bigIntValue: bigint, precision?: number): number;
36
+ /**
37
+ * Takes an array of objects and a key string, and returns a dictionary where the values of the key
38
+ * are the keys of the dictionary, and the values are the objects from the original array.
39
+ * @param array - The array of objects to convert.
40
+ * @param key - The key string to use as the dictionary key.
41
+ * @returns A dictionary with the specified key as the key and the objects as the values.
42
+ */
43
+ export declare const arrayToDict: (array: any[], key: string) => any;
44
+ /**
45
+ * Takes an array of objects and a key string, and returns a dictionary where the values of the key
46
+ * within the `token` object are the keys of the dictionary, and the values are the objects from the
47
+ * original array.
48
+ * @param array - The array of objects to convert.
49
+ * @param key - The key string to use as the dictionary key within the `token` object.
50
+ * @returns A dictionary with the specified key as the key and the objects as the values.
51
+ */
52
+ export declare const arrayToDictForToken: (array: any[], key: string) => any;
53
+ /**
54
+ * Converts a Date object to a Unix timestamp in seconds.
55
+ * @param date - The date object to convert.
56
+ * @returns The Unix timestamp in seconds.
57
+ */
58
+ export declare const toEpoch: (date: any) => number;
@@ -0,0 +1,2 @@
1
+ import type { WalletStoreState } from "../../types/WalletStore";
2
+ export declare const useMockAppWalletStore: import("zustand").UseBoundStore<import("zustand").StoreApi<WalletStoreState>>;
@@ -0,0 +1,4 @@
1
+ import type { UseBoundStore, StoreApi } from "zustand";
2
+ import type { WalletStoreState } from "../types/WalletStore";
3
+ export declare const WalletStoreContext: import("react").Context<UseBoundStore<StoreApi<WalletStoreState>> | undefined>;
4
+ export declare const useWalletStore: <T>(selector: (state: WalletStoreState) => T) => T;
@@ -0,0 +1,8 @@
1
+ import LeftPanel from "./components/LeftPanel";
2
+ import MainLayout from "./components/MainLayout";
3
+ export { LeftPanel };
4
+ export { getTheme } from "./theme";
5
+ export { MainLayout as ValidProtocolLayout };
6
+ export { useThemeStore } from "./components/store/useThemeStore";
7
+ export type { WalletStoreState } from "./types/WalletStore";
8
+ export { WalletStoreContext, useWalletStore } from "./hooks/useWalletContext";
@@ -0,0 +1 @@
1
+ import "./index.css";
@@ -0,0 +1,15 @@
1
+ import "./button.css";
2
+ export interface ButtonProps {
3
+ /** Is this the principal call to action on the page? */
4
+ primary?: boolean;
5
+ /** What background color to use */
6
+ backgroundColor?: string;
7
+ /** How large should the button be? */
8
+ size?: "small" | "medium" | "large";
9
+ /** Button contents */
10
+ label: string;
11
+ /** Optional click handler */
12
+ onClick?: () => void;
13
+ }
14
+ /** Primary UI component for user interaction */
15
+ export declare const Button: ({ primary, size, backgroundColor, label, ...props }: ButtonProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,23 @@
1
+ import type { StoryObj } from '@storybook/react-vite';
2
+ declare const meta: {
3
+ title: string;
4
+ component: ({ primary, size, backgroundColor, label, ...props }: import("./Button").ButtonProps) => import("react/jsx-runtime").JSX.Element;
5
+ parameters: {
6
+ layout: string;
7
+ };
8
+ tags: string[];
9
+ argTypes: {
10
+ backgroundColor: {
11
+ control: "color";
12
+ };
13
+ };
14
+ args: {
15
+ onClick: import("@vitest/spy").Mock<(...args: any[]) => any>;
16
+ };
17
+ };
18
+ export default meta;
19
+ type Story = StoryObj<typeof meta>;
20
+ export declare const Primary: Story;
21
+ export declare const Secondary: Story;
22
+ export declare const Large: Story;
23
+ export declare const Small: Story;
@@ -0,0 +1,12 @@
1
+ import "./header.css";
2
+ type User = {
3
+ name: string;
4
+ };
5
+ export interface HeaderProps {
6
+ user?: User;
7
+ onLogin?: () => void;
8
+ onLogout?: () => void;
9
+ onCreateAccount?: () => void;
10
+ }
11
+ export declare const Header: ({ user, onLogin, onLogout, onCreateAccount, }: HeaderProps) => import("react/jsx-runtime").JSX.Element;
12
+ export {};
@@ -0,0 +1,18 @@
1
+ import type { StoryObj } from '@storybook/react-vite';
2
+ declare const meta: {
3
+ title: string;
4
+ component: ({ user, onLogin, onLogout, onCreateAccount, }: import("./Header").HeaderProps) => import("react/jsx-runtime").JSX.Element;
5
+ tags: string[];
6
+ parameters: {
7
+ layout: string;
8
+ };
9
+ args: {
10
+ onLogin: import("@vitest/spy").Mock<(...args: any[]) => any>;
11
+ onLogout: import("@vitest/spy").Mock<(...args: any[]) => any>;
12
+ onCreateAccount: import("@vitest/spy").Mock<(...args: any[]) => any>;
13
+ };
14
+ };
15
+ export default meta;
16
+ type Story = StoryObj<typeof meta>;
17
+ export declare const LoggedIn: Story;
18
+ export declare const LoggedOut: Story;
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ import "./page.css";
3
+ export declare const Page: React.FC;
@@ -0,0 +1,12 @@
1
+ import type { StoryObj } from '@storybook/react-vite';
2
+ declare const meta: {
3
+ title: string;
4
+ component: import("react").FC<{}>;
5
+ parameters: {
6
+ layout: string;
7
+ };
8
+ };
9
+ export default meta;
10
+ type Story = StoryObj<typeof meta>;
11
+ export declare const LoggedOut: Story;
12
+ export declare const LoggedIn: Story;
@@ -0,0 +1,2 @@
1
+ import type { PaletteMode } from "@mui/material";
2
+ export declare const getTheme: (mode: PaletteMode) => import("@mui/material").Theme;
@@ -0,0 +1,28 @@
1
+ export interface WalletStoreState {
2
+ account: string;
3
+ balance: number;
4
+ wallet: any;
5
+ logoUrl: string;
6
+ liquidStakingUrl?: string;
7
+ nativeStakingUrl?: string;
8
+ anchorStakingUrl?: string;
9
+ privateStakingUrl?: string;
10
+ prfiLiquidStakingUrl?: string;
11
+ bridgeUrl?: string;
12
+ masternodeDashboardUrl?: string;
13
+ defiDashboardUrl?: string;
14
+ docsUrl?: string;
15
+ isSupported: boolean;
16
+ onConnect: () => Promise<void>;
17
+ onDisconnect: () => Promise<void>;
18
+ setWalletData: (wallet: any, account: string, isSupported: boolean, balance?: number, logoUrl?: string) => void;
19
+ clearWalletData: () => void;
20
+ setBalance?: (balance: number) => void;
21
+ setAccount?: (account: string) => void;
22
+ menuItems: ThreeDotsMenuItem[];
23
+ setMenuItems: (items: ThreeDotsMenuItem[]) => void;
24
+ }
25
+ export interface ThreeDotsMenuItem {
26
+ title: string;
27
+ onClick: () => void;
28
+ }
@@ -0,0 +1 @@
1
+ export type Address = `0x${string}`;
package/dist/vite.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
package/package.json ADDED
@@ -0,0 +1,83 @@
1
+ {
2
+ "name": "@xdcs-protocol/ui-kit",
3
+ "version": "1.0.1",
4
+ "description": "Common React components library.",
5
+ "main": "dist/index.cjs.js",
6
+ "module": "dist/index.es.js",
7
+ "types": "dist/types/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.es.js",
11
+ "require": "./dist/index.cjs.js",
12
+ "types": "./dist/types/index.d.ts"
13
+ },
14
+ "./hooks/useWalletContext": {
15
+ "import": "./dist/hooks/useWalletContext.es.js",
16
+ "require": "./dist/hooks/useWalletContext.cjs.js",
17
+ "types": "./dist/types/hooks/useWalletContext.d.ts"
18
+ },
19
+ "./types/WalletStore": {
20
+ "types": "./dist/types/types/WalletStore.d.ts"
21
+ }
22
+ },
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "scripts": {
27
+ "dev": "vite",
28
+ "build": "tsc --project tsconfig.build.json && vite build && cp -r temp/types dist/ && rm -rf temp",
29
+ "lint": "eslint .",
30
+ "preview": "vite preview",
31
+ "storybook": "storybook dev -p 6006",
32
+ "build-storybook": "storybook build"
33
+ },
34
+ "peerDependencies": {
35
+ "@emotion/react": "^11.14.0",
36
+ "@emotion/styled": "^11.14.0",
37
+ "@mui/icons-material": "^5.15.20",
38
+ "@mui/material": "^5.15.20",
39
+ "@web3-onboard/walletconnect": "^2.6.2",
40
+ "react": "^18.3.1",
41
+ "react-dom": "^18.3.1",
42
+ "react-hot-toast": "^2.6.0",
43
+ "react-query": "^3.39.3",
44
+ "react-router-dom": "^6.24.0",
45
+ "zustand": "^4.5.2",
46
+ "web3-utils": "^4.3.1"
47
+ },
48
+ "devDependencies": {
49
+ "@chromatic-com/storybook": "^4.1.1",
50
+ "@emotion/react": "^11.14.0",
51
+ "@emotion/styled": "^11.14.0",
52
+ "@eslint/js": "^9.25.0",
53
+ "@mui/icons-material": "^5.15.20",
54
+ "@mui/material": "^5.15.20",
55
+ "@storybook/addon-a11y": "^9.1.10",
56
+ "@storybook/addon-docs": "^9.1.10",
57
+ "@storybook/addon-onboarding": "^9.1.10",
58
+ "@storybook/addon-vitest": "^9.1.10",
59
+ "@storybook/react-vite": "^9.1.10",
60
+ "@types/react": "^19.1.2",
61
+ "@types/react-dom": "^19.1.2",
62
+ "@vitejs/plugin-react": "^4.4.1",
63
+ "@vitest/browser": "^3.2.4",
64
+ "@vitest/coverage-v8": "^3.2.4",
65
+ "eslint": "^9.25.0",
66
+ "eslint-plugin-react-hooks": "^5.2.0",
67
+ "eslint-plugin-react-refresh": "^0.4.19",
68
+ "eslint-plugin-storybook": "^9.1.10",
69
+ "globals": "^16.0.0",
70
+ "playwright": "^1.56.0",
71
+ "react": "^18.3.1",
72
+ "react-dom": "^18.3.1",
73
+ "react-query": "^3.39.3",
74
+ "react-router-dom": "^6.24.0",
75
+ "storybook": "^9.1.10",
76
+ "typescript": "~5.8.3",
77
+ "typescript-eslint": "^8.30.1",
78
+ "vite": "^6.3.5",
79
+ "vitest": "^3.2.4",
80
+ "web3-utils": "^4.3.1"
81
+ },
82
+ "dependencies": {}
83
+ }