@gearbox-protocol/ui-kit 3.0.0 → 3.1.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -6
- package/dist/cjs/components/assets-list-cell/assets-list-cell.cjs +1 -1
- package/dist/cjs/components/auth/connect-required.cjs +1 -1
- package/dist/cjs/components/auth/index.cjs +1 -1
- package/dist/cjs/components/auth/signin-required.cjs +1 -1
- package/dist/cjs/components/auth/wallet-ui-context.cjs +1 -0
- package/dist/cjs/components/block-sync/block-sync.cjs +1 -1
- package/dist/cjs/components/checkbox/checkbox-labeled.cjs +1 -1
- package/dist/cjs/components/client-adapters/styled-rounded-image/styled-rounded-image.cjs +1 -1
- package/dist/cjs/components/complex-input/complex-input.cjs +1 -1
- package/dist/cjs/components/compound-apy/compound-apy.cjs +1 -1
- package/dist/cjs/components/connectkit/connect-kit-wallet-adapter.cjs +1 -0
- package/dist/cjs/components/connectkit/index.cjs +1 -0
- package/dist/cjs/components/detailed-page-title/detailed-page-title.cjs +1 -1
- package/dist/cjs/components/graph/graph.cjs +1 -1
- package/dist/cjs/components/index.cjs +1 -1
- package/dist/cjs/components/markdown-viewer/markdown-viewer.cjs +1 -1
- package/dist/cjs/components/next/connectkit/index.cjs +1 -0
- package/dist/cjs/components/next/connectkit/siwe-provider.cjs +1 -0
- package/dist/cjs/components/next/index.cjs +1 -1
- package/dist/cjs/components/table/editable-grid-table.cjs +1 -1
- package/dist/cjs/components/table/editable-table.cjs +1 -1
- package/dist/cjs/components/time-to-liquidation/time-to-liquidation.cjs +1 -1
- package/dist/cjs/components/tokens-list-cell/tokens-list-cell.cjs +1 -1
- package/dist/cjs/components/with-copy/with-copy.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/esm/components/assets-list-cell/assets-list-cell.js +3 -4
- package/dist/esm/components/auth/connect-required.js +18 -11
- package/dist/esm/components/auth/index.js +5 -4
- package/dist/esm/components/auth/signin-required.js +30 -23
- package/dist/esm/components/auth/wallet-ui-context.js +13 -0
- package/dist/esm/components/block-sync/block-sync.js +3 -4
- package/dist/esm/components/checkbox/checkbox-labeled.js +1 -2
- package/dist/esm/components/client-adapters/styled-rounded-image/styled-rounded-image.js +1 -2
- package/dist/esm/components/complex-input/complex-input.js +3 -4
- package/dist/esm/components/compound-apy/compound-apy.js +3 -4
- package/dist/esm/components/connectkit/connect-kit-wallet-adapter.js +32 -0
- package/dist/esm/components/connectkit/index.js +6 -0
- package/dist/esm/components/detailed-page-title/detailed-page-title.js +1 -2
- package/dist/esm/components/graph/graph.js +167 -164
- package/dist/esm/components/index.js +608 -607
- package/dist/esm/components/markdown-viewer/markdown-viewer.js +3 -4
- package/dist/esm/components/next/connectkit/index.js +4 -0
- package/dist/esm/components/next/{siwe-provider.js → connectkit/siwe-provider.js} +1 -1
- package/dist/esm/components/next/index.js +6 -8
- package/dist/esm/components/table/editable-grid-table.js +36 -37
- package/dist/esm/components/table/editable-table.js +17 -18
- package/dist/esm/components/time-to-liquidation/time-to-liquidation.js +1 -2
- package/dist/esm/components/tokens-list-cell/tokens-list-cell.js +3 -4
- package/dist/esm/components/with-copy/with-copy.js +3 -4
- package/dist/esm/index.js +768 -767
- package/dist/types/components/auth/connect-required.d.ts +10 -11
- package/dist/types/components/auth/index.d.ts +1 -1
- package/dist/types/components/auth/signin-required.d.ts +7 -5
- package/dist/types/components/auth/wallet-ui-context.d.ts +36 -0
- package/dist/types/components/connectkit/connect-kit-wallet-adapter.d.ts +12 -0
- package/dist/types/components/connectkit/index.d.ts +2 -0
- package/dist/types/components/connectkit/siwe-provider.d.ts +30 -0
- package/dist/types/components/next/connectkit/index.d.ts +1 -0
- package/dist/types/components/next/connectkit/siwe-provider.d.ts +8 -0
- package/dist/types/components/next/index.d.ts +0 -1
- package/package.json +21 -4
- package/dist/cjs/components/next/siwe-provider.cjs +0 -1
- package/dist/types/components/auth/siwe-provider.d.ts +0 -31
- package/dist/types/components/next/siwe-provider.d.ts +0 -7
- /package/dist/cjs/components/{auth → connectkit}/siwe-provider.cjs +0 -0
- /package/dist/esm/components/{auth → connectkit}/siwe-provider.js +0 -0
|
@@ -2,28 +2,27 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
import { Address } from 'viem';
|
|
3
3
|
import { TabButtonProps } from '../buttons';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* ConnectRequired — component that requires a connected wallet to display content.
|
|
6
6
|
*
|
|
7
7
|
* @usage
|
|
8
|
-
* Use
|
|
9
|
-
* action buttons, editable content, owner-specific features
|
|
8
|
+
* Use ConnectRequired to protect content that requires a wallet connection:
|
|
9
|
+
* action buttons, editable content, owner-specific features.
|
|
10
10
|
*
|
|
11
11
|
* Props:
|
|
12
|
-
* - `owner` — optional address that must match
|
|
13
|
-
* - `children` — content displayed when
|
|
12
|
+
* - `owner` — optional address that must match connected address to display content.
|
|
13
|
+
* - `children` — content displayed when connected (required).
|
|
14
14
|
* - All Button props are supported (variant, size, className, onClick, etc.).
|
|
15
15
|
*
|
|
16
16
|
* Behavior:
|
|
17
17
|
* - If user is connected: renders children (or "You are not the author" if owner mismatch).
|
|
18
|
-
* - If wallet
|
|
19
|
-
*
|
|
18
|
+
* - If wallet not connected: shows "Connect Wallet" button that calls `openConnectModal` from {@link WalletUIProvider}.
|
|
19
|
+
*
|
|
20
|
+
* When no {@link WalletUIProvider} is mounted, the gate is skipped and `children` are rendered (graceful degradation).
|
|
20
21
|
*
|
|
21
22
|
* Note: Uses TabButton by default, but switches to Button if custom props are provided.
|
|
22
|
-
* Button text changes based on authentication state and loading status.
|
|
23
23
|
*
|
|
24
|
-
* Do NOT use
|
|
25
|
-
* - for public content that
|
|
26
|
-
* - when you need different authentication flow (use appropriate authentication components).
|
|
24
|
+
* Do NOT use ConnectRequired:
|
|
25
|
+
* - for public content that does not require a wallet (render content directly).
|
|
27
26
|
*/
|
|
28
27
|
export interface ConnectRequiredProps extends TabButtonProps {
|
|
29
28
|
owner?: Address;
|
|
@@ -16,15 +16,17 @@ import { TabButtonProps } from '../buttons';
|
|
|
16
16
|
*
|
|
17
17
|
* Behavior:
|
|
18
18
|
* - If `skipSignIn={true}` or user is signed in: renders children (or "You are not the author" if owner mismatch).
|
|
19
|
-
* - If wallet connected but not signed in: shows "Sign In as {address}"
|
|
20
|
-
* - If wallet not connected: shows "Connect Wallet"
|
|
19
|
+
* - If wallet connected but not signed in: shows "Sign In as {address}" or "Try Again".
|
|
20
|
+
* - If wallet not connected: shows "Connect Wallet".
|
|
21
|
+
*
|
|
22
|
+
* Requires {@link WalletUIProvider} with SIWE state (e.g. {@link ConnectKitWalletAdapter} from
|
|
23
|
+
* `@gearbox-protocol/ui-kit/connectkit`). Without a provider, the sign-in gate is skipped and `children`
|
|
24
|
+
* are rendered (graceful degradation).
|
|
21
25
|
*
|
|
22
26
|
* Note: Uses TabButton by default, but switches to Button if custom props are provided.
|
|
23
|
-
* Button text changes based on authentication state and loading status.
|
|
24
27
|
*
|
|
25
28
|
* Do NOT use SignInRequired:
|
|
26
|
-
* - for public content that
|
|
27
|
-
* - when you need different authentication flow (use appropriate authentication components).
|
|
29
|
+
* - for public content that does not require authentication (render content directly).
|
|
28
30
|
*/
|
|
29
31
|
export interface SignInRequiredProps extends TabButtonProps {
|
|
30
32
|
owner?: Address;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* SIWE-related state exposed by a wallet UI adapter (e.g. ConnectKit).
|
|
4
|
+
*/
|
|
5
|
+
export interface WalletUISIWEState {
|
|
6
|
+
isSignedIn: boolean;
|
|
7
|
+
isRejected: boolean;
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
data: {
|
|
10
|
+
address?: string;
|
|
11
|
+
} | null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Values provided by {@link WalletUIProvider} so auth helpers work without importing ConnectKit.
|
|
15
|
+
*/
|
|
16
|
+
export interface WalletUIContextValue {
|
|
17
|
+
openConnectModal: () => void;
|
|
18
|
+
openSIWE?: () => void;
|
|
19
|
+
siwe?: WalletUISIWEState;
|
|
20
|
+
}
|
|
21
|
+
export interface WalletUIProviderProps {
|
|
22
|
+
value: WalletUIContextValue;
|
|
23
|
+
children?: ReactNode;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Supplies wallet modal + optional SIWE actions for {@link ConnectRequired}, {@link SignInRequired},
|
|
27
|
+
* and editable tables that use them.
|
|
28
|
+
*
|
|
29
|
+
* Use {@link ConnectKitWalletAdapter} from `@gearbox-protocol/ui-kit/connectkit` when using ConnectKit,
|
|
30
|
+
* or provide your own `value` (e.g. RainbowKit `useConnectModal`).
|
|
31
|
+
*/
|
|
32
|
+
export declare function WalletUIProvider({ value, children }: WalletUIProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
/**
|
|
34
|
+
* Returns the wallet UI adapter value, or `null` when no {@link WalletUIProvider} is mounted.
|
|
35
|
+
*/
|
|
36
|
+
export declare function useWalletUI(): WalletUIContextValue | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface ConnectKitWalletAdapterProps {
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Bridges ConnectKit (`useModal`, `useSIWE`) into {@link WalletUIProvider} so
|
|
7
|
+
* {@link ConnectRequired}, {@link SignInRequired}, and editable tables work without importing ConnectKit
|
|
8
|
+
* from application code.
|
|
9
|
+
*
|
|
10
|
+
* Place inside `ConnectKitProvider` (and typically inside or beside {@link SIWEClientProvider} when using SIWE).
|
|
11
|
+
*/
|
|
12
|
+
export declare function ConnectKitWalletAdapter({ children, }: ConnectKitWalletAdapterProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SIWEClientProvider — provider component for Sign-In With Ethereum (SIWE) authentication.
|
|
3
|
+
*
|
|
4
|
+
* Requires `connectkit` and must be used under `ConnectKitProvider` + `WagmiProvider`.
|
|
5
|
+
*
|
|
6
|
+
* @usage
|
|
7
|
+
* Use SIWEClientProvider to wrap your application and enable SIWE authentication:
|
|
8
|
+
* app root, authentication context, wallet-based authentication.
|
|
9
|
+
*
|
|
10
|
+
* Props:
|
|
11
|
+
* - `apiRoutePrefix` — API route prefix for SIWE endpoints (required):
|
|
12
|
+
* - `/nonce` — endpoint for fetching nonce (relative to prefix).
|
|
13
|
+
* - `/signin` — endpoint for verifying signature.
|
|
14
|
+
* - `/session` — endpoint for getting current session.
|
|
15
|
+
* - `/logout` — endpoint for signing out.
|
|
16
|
+
* - `statement` — optional custom statement for SIWE message (defaults to "Sign In With Ethereum.").
|
|
17
|
+
* - `children` — application content wrapped by provider (required).
|
|
18
|
+
* - `onRefresh` — optional callback after sign-in or sign-out (e.g. Next.js `router.refresh()`).
|
|
19
|
+
*
|
|
20
|
+
* Note: wraps ConnectKit's `SIWEProvider` with custom HTTP API integration.
|
|
21
|
+
*
|
|
22
|
+
* Import from `@gearbox-protocol/ui-kit/connectkit` so `connectkit` stays an optional peer dependency.
|
|
23
|
+
*/
|
|
24
|
+
export interface SIWEClientProviderProps {
|
|
25
|
+
apiRoutePrefix: string;
|
|
26
|
+
statement?: string;
|
|
27
|
+
children?: React.ReactNode;
|
|
28
|
+
onRefresh?: () => void;
|
|
29
|
+
}
|
|
30
|
+
export declare function SIWEClientProvider({ apiRoutePrefix, statement, children, onRefresh, ...props }: SIWEClientProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { type NextSIWEClientProviderProps, SIWEClientProvider, } from './siwe-provider';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SIWEClientProviderProps as BaseSIWEClientProviderProps } from '../../connectkit/siwe-provider';
|
|
2
|
+
export type NextSIWEClientProviderProps = Omit<BaseSIWEClientProviderProps, "onRefresh">;
|
|
3
|
+
/**
|
|
4
|
+
* Next.js variant of {@link SIWEClientProvider} that calls `router.refresh()` after sign-in and sign-out.
|
|
5
|
+
*
|
|
6
|
+
* Import from `@gearbox-protocol/ui-kit/next/connectkit`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function SIWEClientProvider(props: NextSIWEClientProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -8,5 +8,4 @@ export { preloadTokenIcons } from '../token-icon';
|
|
|
8
8
|
export { BackButton } from './back-button';
|
|
9
9
|
export { NextMarkdownViewer, type NextMarkdownViewerProps, } from './next-markdown-viewer';
|
|
10
10
|
export { NextNavigationProvider } from './next-navigation-provider';
|
|
11
|
-
export { SIWEClientProvider } from './siwe-provider';
|
|
12
11
|
export { TokenIcon } from './token-icon';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/ui-kit",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.1.0-next.2",
|
|
4
4
|
"description": "Internal UI components",
|
|
5
5
|
"repository": "https://github.com/gearbox-protocol/ui-kit",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,7 +34,22 @@
|
|
|
34
34
|
"./globals.css": "./dist/globals.css",
|
|
35
35
|
"./grid-safelist.css": "./dist/grid-safelist.css",
|
|
36
36
|
"./theme.css": "./src/styles/theme.css",
|
|
37
|
-
"./base.css": "./src/styles/base.css"
|
|
37
|
+
"./base.css": "./src/styles/base.css",
|
|
38
|
+
"./sdk-legacy": {
|
|
39
|
+
"types": "./dist/types/sdk-legacy/index.d.ts",
|
|
40
|
+
"import": "./dist/esm/sdk-legacy/index.js",
|
|
41
|
+
"default": "./dist/cjs/sdk-legacy/index.cjs"
|
|
42
|
+
},
|
|
43
|
+
"./connectkit": {
|
|
44
|
+
"types": "./dist/types/components/connectkit/index.d.ts",
|
|
45
|
+
"import": "./dist/esm/components/connectkit/index.js",
|
|
46
|
+
"default": "./dist/cjs/components/connectkit/index.cjs"
|
|
47
|
+
},
|
|
48
|
+
"./next/connectkit": {
|
|
49
|
+
"types": "./dist/types/components/next/connectkit/index.d.ts",
|
|
50
|
+
"import": "./dist/esm/components/next/connectkit/index.js",
|
|
51
|
+
"default": "./dist/cjs/components/next/connectkit/index.cjs"
|
|
52
|
+
}
|
|
38
53
|
},
|
|
39
54
|
"files": [
|
|
40
55
|
"dist",
|
|
@@ -51,8 +66,8 @@
|
|
|
51
66
|
"check": "biome check --write",
|
|
52
67
|
"check:ci": "biome check --diagnostic-level=error",
|
|
53
68
|
"typecheck:ci": "tsc --noEmit",
|
|
54
|
-
"test": "vitest run",
|
|
55
|
-
"test:watch": "vitest",
|
|
69
|
+
"test": "pnpm exec vitest run",
|
|
70
|
+
"test:watch": "pnpm exec vitest",
|
|
56
71
|
"storybook": "storybook dev -p 6006",
|
|
57
72
|
"build-storybook": "storybook build"
|
|
58
73
|
},
|
|
@@ -93,6 +108,7 @@
|
|
|
93
108
|
"tailwindcss-animate": "^1.0.7"
|
|
94
109
|
},
|
|
95
110
|
"peerDependencies": {
|
|
111
|
+
"axios": "^1.0.0",
|
|
96
112
|
"@gearbox-protocol/sdk": "*",
|
|
97
113
|
"@tanstack/react-query": "^5.64.1",
|
|
98
114
|
"@types/react": "^18 || ^19",
|
|
@@ -126,6 +142,7 @@
|
|
|
126
142
|
}
|
|
127
143
|
},
|
|
128
144
|
"devDependencies": {
|
|
145
|
+
"axios": "^1.12.2",
|
|
129
146
|
"@biomejs/biome": "^2.2.4",
|
|
130
147
|
"@chromatic-com/storybook": "^4.1.3",
|
|
131
148
|
"@commitlint/cli": "^20.1.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),o=require("next/navigation"),i=require("../auth/siwe-provider.cjs");function n(e){const r=o.useRouter();return t.jsx(i.SIWEClientProvider,{...e,onRefresh:()=>r.refresh()})}exports.SIWEClientProvider=n;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SIWEClientProvider — provider component for Sign-In With Ethereum (SIWE) authentication.
|
|
3
|
-
*
|
|
4
|
-
* @usage
|
|
5
|
-
* Use SIWEClientProvider to wrap your application and enable SIWE authentication:
|
|
6
|
-
* app root, authentication context, wallet-based authentication.
|
|
7
|
-
*
|
|
8
|
-
* Props:
|
|
9
|
-
* - `apiRoutePrefix` — API route prefix for SIWE endpoints (required):
|
|
10
|
-
* - `/api/nonce` — endpoint for fetching nonce.
|
|
11
|
-
* - `/api/signin` — endpoint for verifying signature.
|
|
12
|
-
* - `/api/session` — endpoint for getting current session.
|
|
13
|
-
* - `/api/logout` — endpoint for signing out.
|
|
14
|
-
* - `statement` — optional custom statement for SIWE message (defaults to "Sign In With Ethereum.").
|
|
15
|
-
* - `children` — application content wrapped by provider (required).
|
|
16
|
-
*
|
|
17
|
-
* Note: SIWEClientProvider wraps ConnectKit's SIWEProvider with custom API integration.
|
|
18
|
-
* Handles nonce generation, message creation, signature verification, session management, and sign out.
|
|
19
|
-
* Automatically refreshes router on sign in/out.
|
|
20
|
-
*
|
|
21
|
-
* Do NOT use SIWEClientProvider:
|
|
22
|
-
* - when you don't need SIWE authentication (use regular ConnectKit providers).
|
|
23
|
-
*/
|
|
24
|
-
interface SIWEProviderProps {
|
|
25
|
-
apiRoutePrefix: string;
|
|
26
|
-
statement?: string;
|
|
27
|
-
children?: React.ReactNode;
|
|
28
|
-
onRefresh?: () => void;
|
|
29
|
-
}
|
|
30
|
-
export declare function SIWEClientProvider({ apiRoutePrefix, statement, children, onRefresh, ...props }: SIWEProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
31
|
-
export {};
|
|
File without changes
|
|
File without changes
|